Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7113050
extract-fields-from-collection.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
extract-fields-from-collection.ts
View Options
import
_locreq
from
"locreq"
;
import
{
curryImportPath
,
exec
}
from
"./utils.js"
;
const
target_locreq
=
_locreq
(
process
.
cwd
());
import
{
promises
as
fs
}
from
"fs"
;
export
default
async
function
extract_fields_from_collection
(
collection_name
:
string
)
:
Promise
<
{
name
:
string
;
type
:
string
}[]
>
{
const
rel
=
curryImportPath
(
target_locreq
.
resolve
(
"dist/back"
));
const
extractor_code
=
`import {default as Collection} from "
${
rel
(
`./back/collections/
${
collection_name
}
.js`
)
}
";
const c = new Collection();
const fields = [];
for (const field_name in c.fields){
const field = c.fields[field_name];
let type = field.typeName;
if(["derived-value", "cached-value"].includes(type)){
type = field.virtual_field.typeName
}
fields.push({name: field_name, type})
}
console.log(JSON.stringify(fields));
`
;
const
extractor_code_path
=
target_locreq
.
resolve
(
"dist/back/___extract_fields.js"
);
await
fs
.
writeFile
(
extractor_code_path
,
extractor_code
);
const
{
stdout
}
=
await
exec
(
"node"
,
[
extractor_code_path
]);
await
fs
.
unlink
(
extractor_code_path
);
return
JSON
.
parse
(
stdout
);
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jul 4, 08:37 (5 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
799871
Default Alt Text
extract-fields-from-collection.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment