@osdk/maker-experimental 0.18.0 → 0.18.1-main-56c2c9fdaf97899b89e2dfd18c578bbc6d2de4de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/build/browser/api/defineOntologyV2.js +5 -2
- package/build/browser/api/defineOntologyV2.js.map +1 -1
- package/build/browser/cli/main.js +4 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/cjs/index.cjs +8 -5
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -1
- package/build/esm/api/defineOntologyV2.js +5 -2
- package/build/esm/api/defineOntologyV2.js.map +1 -1
- package/build/esm/cli/main.js +4 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/types/api/defineOntologyV2.d.ts +1 -1
- package/build/types/api/defineOntologyV2.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @osdk/maker-experimental
|
|
2
2
|
|
|
3
|
+
## 0.18.1-main-56c2c9fdaf97899b89e2dfd18c578bbc6d2de4de
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 56c2c9f: write static object file
|
|
8
|
+
- Updated dependencies [56c2c9f]
|
|
9
|
+
- @osdk/maker@0.28.1-main-56c2c9fdaf97899b89e2dfd18c578bbc6d2de4de
|
|
10
|
+
|
|
3
11
|
## 0.18.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { getImportedTypes, getOntologyDefinition, initializeOntologyState, OntologyEntityTypeEnum } from "@osdk/maker";
|
|
17
|
+
import { getImportedTypes, getOntologyDefinition, initializeOntologyState, OntologyEntityTypeEnum, writeStaticObjects } from "@osdk/maker";
|
|
18
18
|
import * as fs from "fs";
|
|
19
19
|
import { convertOntologyDefinition } from "../conversion/toMarketplace/convertOntologyDefinition.js";
|
|
20
20
|
import { getImportedShapes } from "../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js";
|
|
21
21
|
import { getShapes } from "../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js";
|
|
22
22
|
import { OntologyRidGeneratorImpl } from "../util/generateRid.js";
|
|
23
|
-
export async function defineOntologyV2(ns, body, functionsIrFile, randomnessKey) {
|
|
23
|
+
export async function defineOntologyV2(ns, body, outputDir, functionsIrFile, randomnessKey) {
|
|
24
24
|
initializeOntologyState(ns);
|
|
25
25
|
try {
|
|
26
26
|
await body();
|
|
@@ -51,6 +51,9 @@ export async function defineOntologyV2(ns, body, functionsIrFile, randomnessKey)
|
|
|
51
51
|
const lt = link;
|
|
52
52
|
return "many" in lt && !("intermediaryObjectType" in lt) && lt.includeEmptyBackingDatasource === true;
|
|
53
53
|
}).map(([apiName]) => apiName);
|
|
54
|
+
if (outputDir) {
|
|
55
|
+
writeStaticObjects(outputDir);
|
|
56
|
+
}
|
|
54
57
|
return {
|
|
55
58
|
ontologyIr: ontDef,
|
|
56
59
|
shapes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineOntologyV2.js","names":["getImportedTypes","getOntologyDefinition","initializeOntologyState","OntologyEntityTypeEnum","fs","convertOntologyDefinition","getImportedShapes","getShapes","OntologyRidGeneratorImpl","defineOntologyV2","ns","body","functionsIrFile","randomnessKey","e","console","error","ontologyDefinition","functionsIr","JSON","parse","readFileSync","ridGenerator","ontDef","shapes","ontology","importedShapes","importedOntology","key","value","inputShapes","set","inputShapeMetadata","backingDatasourceApiNames","Object","entries","OBJECT_TYPE","filter","_","obj","includeEmptyBackingDatasource","map","apiName","backingDatasourceLinkApiNames","LINK_TYPE","link","lt","ontologyIr"],"sources":["defineOntologyV2.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { OntologyIrV2 } from \"@osdk/client.unstable\";\nimport type { IDiscoveredFunction } from \"@osdk/generator-converters.ontologyir\";\nimport type { LinkType, ObjectType } from \"@osdk/maker\";\nimport {\n getImportedTypes,\n getOntologyDefinition,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n} from \"@osdk/maker\";\nimport * as fs from \"fs\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.js\";\nimport { getImportedShapes } from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\nimport { getShapes } from \"../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js\";\nimport type { BlockShapes } from \"../util/generateRid.js\";\nimport { OntologyRidGeneratorImpl } from \"../util/generateRid.js\";\n\nexport interface OntologyV2Result {\n ontologyIr: OntologyIrV2;\n shapes: BlockShapes;\n backingDatasourceApiNames: string[];\n backingDatasourceLinkApiNames: string[];\n}\n\nexport interface FunctionsIr {\n discoveredFunctions: Array<IDiscoveredFunction>;\n}\n\nexport async function defineOntologyV2(\n ns: string,\n body: () => void | Promise<void>,\n functionsIrFile?: string,\n randomnessKey?: string,\n): Promise<OntologyV2Result> {\n initializeOntologyState(ns);\n\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected error while processing the body of the ontology\",\n e,\n );\n throw e;\n }\n\n const ontologyDefinition = getOntologyDefinition();\n\n let functionsIr: FunctionsIr | undefined;\n if (functionsIrFile) {\n functionsIr = JSON.parse(\n fs.readFileSync(functionsIrFile, \"utf-8\"),\n );\n }\n\n const ridGenerator = new OntologyRidGeneratorImpl(\n getImportedTypes(),\n randomnessKey,\n );\n const ontDef = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n functionsIr,\n randomnessKey,\n );\n\n const shapes = await getShapes(\n ontDef.ontology,\n ridGenerator,\n functionsIr,\n randomnessKey,\n );\n\n // Generate input shapes for imported entities and merge into main shapes\n const importedShapes = getImportedShapes(\n ontDef.importedOntology,\n ridGenerator,\n );\n for (const [key, value] of importedShapes.inputShapes) {\n shapes.inputShapes.set(key, value);\n }\n for (const [key, value] of importedShapes.inputShapeMetadata) {\n shapes.inputShapeMetadata.set(key, value);\n }\n\n const backingDatasourceApiNames = Object.entries(\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE],\n )\n .filter(([_, obj]) =>\n (obj as ObjectType).includeEmptyBackingDatasource === true\n )\n .map(([apiName]) => apiName);\n\n const backingDatasourceLinkApiNames = Object.entries(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE],\n )\n .filter(([_, link]) => {\n const lt = link as LinkType;\n return \"many\" in lt\n && !(\"intermediaryObjectType\" in lt)\n && (lt as LinkType & { includeEmptyBackingDatasource?: boolean })\n .includeEmptyBackingDatasource === true;\n })\n .map(([apiName]) => apiName);\n\n return {\n ontologyIr: ontDef,\n shapes,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SACEA,gBAAgB,EAChBC,qBAAqB,EACrBC,uBAAuB,EACvBC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"defineOntologyV2.js","names":["getImportedTypes","getOntologyDefinition","initializeOntologyState","OntologyEntityTypeEnum","writeStaticObjects","fs","convertOntologyDefinition","getImportedShapes","getShapes","OntologyRidGeneratorImpl","defineOntologyV2","ns","body","outputDir","functionsIrFile","randomnessKey","e","console","error","ontologyDefinition","functionsIr","JSON","parse","readFileSync","ridGenerator","ontDef","shapes","ontology","importedShapes","importedOntology","key","value","inputShapes","set","inputShapeMetadata","backingDatasourceApiNames","Object","entries","OBJECT_TYPE","filter","_","obj","includeEmptyBackingDatasource","map","apiName","backingDatasourceLinkApiNames","LINK_TYPE","link","lt","ontologyIr"],"sources":["defineOntologyV2.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { OntologyIrV2 } from \"@osdk/client.unstable\";\nimport type { IDiscoveredFunction } from \"@osdk/generator-converters.ontologyir\";\nimport type { LinkType, ObjectType } from \"@osdk/maker\";\nimport {\n getImportedTypes,\n getOntologyDefinition,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n writeStaticObjects,\n} from \"@osdk/maker\";\nimport * as fs from \"fs\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.js\";\nimport { getImportedShapes } from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\nimport { getShapes } from \"../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js\";\nimport type { BlockShapes } from \"../util/generateRid.js\";\nimport { OntologyRidGeneratorImpl } from \"../util/generateRid.js\";\n\nexport interface OntologyV2Result {\n ontologyIr: OntologyIrV2;\n shapes: BlockShapes;\n backingDatasourceApiNames: string[];\n backingDatasourceLinkApiNames: string[];\n}\n\nexport interface FunctionsIr {\n discoveredFunctions: Array<IDiscoveredFunction>;\n}\n\nexport async function defineOntologyV2(\n ns: string,\n body: () => void | Promise<void>,\n outputDir?: string,\n functionsIrFile?: string,\n randomnessKey?: string,\n): Promise<OntologyV2Result> {\n initializeOntologyState(ns);\n\n try {\n await body();\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(\n \"Unexpected error while processing the body of the ontology\",\n e,\n );\n throw e;\n }\n\n const ontologyDefinition = getOntologyDefinition();\n\n let functionsIr: FunctionsIr | undefined;\n if (functionsIrFile) {\n functionsIr = JSON.parse(\n fs.readFileSync(functionsIrFile, \"utf-8\"),\n );\n }\n\n const ridGenerator = new OntologyRidGeneratorImpl(\n getImportedTypes(),\n randomnessKey,\n );\n const ontDef = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n functionsIr,\n randomnessKey,\n );\n\n const shapes = await getShapes(\n ontDef.ontology,\n ridGenerator,\n functionsIr,\n randomnessKey,\n );\n\n // Generate input shapes for imported entities and merge into main shapes\n const importedShapes = getImportedShapes(\n ontDef.importedOntology,\n ridGenerator,\n );\n for (const [key, value] of importedShapes.inputShapes) {\n shapes.inputShapes.set(key, value);\n }\n for (const [key, value] of importedShapes.inputShapeMetadata) {\n shapes.inputShapeMetadata.set(key, value);\n }\n\n const backingDatasourceApiNames = Object.entries(\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE],\n )\n .filter(([_, obj]) =>\n (obj as ObjectType).includeEmptyBackingDatasource === true\n )\n .map(([apiName]) => apiName);\n\n const backingDatasourceLinkApiNames = Object.entries(\n ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE],\n )\n .filter(([_, link]) => {\n const lt = link as LinkType;\n return \"many\" in lt\n && !(\"intermediaryObjectType\" in lt)\n && (lt as LinkType & { includeEmptyBackingDatasource?: boolean })\n .includeEmptyBackingDatasource === true;\n })\n .map(([apiName]) => apiName);\n\n if (outputDir) {\n writeStaticObjects(outputDir);\n }\n\n return {\n ontologyIr: ontDef,\n shapes,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,S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[0-9a-f]{12}$/;
|
|
33
33
|
export default async function main(args = process.argv) {
|
|
34
34
|
consola.log("Generating BlockGeneratorResult for ontology...");
|
|
35
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.18.
|
|
35
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.18.1-main-56c2c9fdaf97899b89e2dfd18c578bbc6d2de4de" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
36
36
|
input: {
|
|
37
37
|
alias: "i",
|
|
38
38
|
describe: "Input file",
|
|
@@ -120,7 +120,7 @@ export default async function main(args = process.argv) {
|
|
|
120
120
|
shapes,
|
|
121
121
|
backingDatasourceApiNames,
|
|
122
122
|
backingDatasourceLinkApiNames
|
|
123
|
-
} = await loadOntology(commandLineOpts.input, apiNamespace, functionsIrFile, commandLineOpts.randomnessKey);
|
|
123
|
+
} = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.buildDir, functionsIrFile, commandLineOpts.randomnessKey);
|
|
124
124
|
|
|
125
125
|
// Create temp directory for block data
|
|
126
126
|
const blockDataDir = path.join(commandLineOpts.buildDir, "temp_block_data");
|
|
@@ -248,8 +248,8 @@ export default async function main(args = process.argv) {
|
|
|
248
248
|
consola.success(`Value type BlockGeneratorResult written to ${commandLineOpts.valueTypesOutput}`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
async function loadOntology(input, apiNamespace, functionsIrFile, randomnessKey) {
|
|
252
|
-
const result = await defineOntologyV2(apiNamespace, async () => await import(pathToFileURL(input).href), functionsIrFile, randomnessKey);
|
|
251
|
+
async function loadOntology(input, apiNamespace, outputDir, functionsIrFile, randomnessKey) {
|
|
252
|
+
const result = await defineOntologyV2(apiNamespace, async () => await import(pathToFileURL(input).href), outputDir, functionsIrFile, randomnessKey);
|
|
253
253
|
return result;
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["OntologyIrToFullMetadataConverter","PreviewOntologyIrConverter","cleanAndValidateLinkTypeId","consola","fs","path","pathToFileURL","invariant","yargs","hideBin","defineOntologyV2","ReadableIdGenerator","generateBackingDatasetBlockResult","generateBackingDatasetBlockResultForLink","getNonEditOnlyProperties","generateValueTypeBlockResults","getValueTypeInternalMappings","apiNamespaceRegex","uuidRegex","main","args","process","argv","log","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","valueTypesOutput","apiNamespace","buildDir","temporaryBlockDataFile","functionsDir","nodeModulesDir","functionsIrOutputFile","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","functionsIrFile","fileContent","promises","readFile","blockDataJson","JSON","parse","error","exit","previewMetadata","getPreviewFullMetadataFromBlockData","discoverTypeScriptFunctions","ontologyIr","shapes","backingDatasourceApiNames","backingDatasourceLinkApiNames","loadOntology","blockDataDir","join","existsSync","mkdir","recursive","ontologyJsonPath","ontologyJson","stringify","ontology","writeFile","valueTypeResults","valueTypes","ontologyInputMappingEntries","inputMappings","apiName","objectTypeBlockData","findObjectTypeByApiName","objectTypes","nonEditOnlyProps","inputDatasetReadableId","getForDataset","outputDatasetReadableId","getForDatasetOutput","inputShapes","has","push","prop","colInputReadableId","getForDatasetColumn","getForDatasetColumnOutput","linkApiName","linkTypeBlockData","findLinkTypeByApiName","linkTypes","datasetName","inputDsId","outputDsId","ds","datasources","datasource","columnNames","Object","values","dataset","objectTypeAPrimaryKeyMapping","map","String","objectTypeBPrimaryKeyMapping","colName","colInputId","colOutputId","backingDsGeneratorResults","Promise","all","filter","backingDsLinkGeneratorResults","p","blockGeneratorResult","block_identifier","block_data_directory","oci_block_data_metadata","maven_block_data_metadata","inputs","fromEntries","outputs","outputShapes","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","inputShapeMetadata","block_type","blockGeneratorResultJson","success","valueTypeResultsJson","result","href","find","objectType","linkTypeId","lt","linkType","id"],"sources":["main.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkTypeBlockDataV2,\n ObjectTypeBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { PreviewOntologyIrConverter } from \"@osdk/generator-converters.preview\";\nimport { cleanAndValidateLinkTypeId } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntologyV2 } from \"../api/defineOntologyV2.js\";\nimport { ReadableIdGenerator } from \"../util/generateRid.js\";\nimport {\n generateBackingDatasetBlockResult,\n generateBackingDatasetBlockResultForLink,\n getNonEditOnlyProperties,\n} from \"./generateBackingDataset.js\";\nimport {\n generateValueTypeBlockResults,\n getValueTypeInternalMappings,\n} from \"./generateValueTypeBlockResults.js\";\nimport type { BlockGeneratorResult } from \"./marketplaceSerialization/BlockGeneratorResult.js\";\nimport type { InputMappingEntry } from \"./marketplaceSerialization/supportingTypes.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n consola.log(\"Generating BlockGeneratorResult for ontology...\");\n\n const commandLineOpts: {\n input: string;\n output: string;\n valueTypesOutput: string;\n apiNamespace: string;\n buildDir: string;\n temporaryBlockDataFile?: string;\n functionsDir?: string;\n nodeModulesDir?: string;\n functionsIrOutputFile?: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file for ontology BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/block_generator_result.json\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Output file for value types BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/value_types_block_generator_result.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n buildDir: {\n alias: \"b\",\n describe: \"Directory for build files\",\n type: \"string\",\n default: \"build/\",\n coerce: path.resolve,\n },\n temporaryBlockDataFile: {\n alias: \"f\",\n describe:\n \"Path to a previously generated block data file. Supplying this field indicates that function backed actions should be generated\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsDir: {\n type: \"string\",\n coerce: path.resolve,\n },\n nodeModulesDir: {\n type: \"string\",\n coerce: path.resolve,\n },\n functionsIrOutputFile: {\n type: \"string\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n },\n })\n .parseAsync();\n\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n let functionsIrFile;\n if (commandLineOpts.temporaryBlockDataFile) {\n consola.info(\n `Loading temporary block data from ${commandLineOpts.temporaryBlockDataFile}`,\n );\n const fileContent = await fs.promises.readFile(\n commandLineOpts.temporaryBlockDataFile,\n \"utf-8\",\n );\n let blockDataJson: unknown;\n try {\n blockDataJson = JSON.parse(fileContent);\n } catch {\n consola.error(\n `Failed to parse JSON from ${commandLineOpts.temporaryBlockDataFile}`,\n );\n process.exit(1);\n }\n const previewMetadata = PreviewOntologyIrConverter\n .getPreviewFullMetadataFromBlockData(\n blockDataJson as Parameters<\n typeof PreviewOntologyIrConverter.getPreviewFullMetadataFromBlockData\n >[0],\n );\n invariant(\n commandLineOpts.functionsDir && commandLineOpts.nodeModulesDir,\n \"functionsDir and nodeModulesDir must be supplied when using temporaryBlockDataFile\",\n );\n await OntologyIrToFullMetadataConverter.discoverTypeScriptFunctions(\n commandLineOpts.functionsDir,\n commandLineOpts.nodeModulesDir,\n commandLineOpts.functionsIrOutputFile,\n previewMetadata,\n );\n functionsIrFile = commandLineOpts.functionsIrOutputFile;\n consola.info(\n `Discovered functions during block data generation at ${commandLineOpts.functionsIrOutputFile}`,\n );\n }\n\n const {\n ontologyIr,\n shapes,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n } = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n functionsIrFile,\n commandLineOpts.randomnessKey,\n );\n\n // Create temp directory for block data\n const blockDataDir = path.join(commandLineOpts.buildDir, \"temp_block_data\");\n if (!fs.existsSync(blockDataDir)) {\n await fs.promises.mkdir(blockDataDir, { recursive: true });\n }\n\n // Write ontology.json to the block data directory\n const ontologyJsonPath = path.join(blockDataDir, \"ontology.json\");\n const ontologyJson = JSON.stringify(ontologyIr.ontology, null, 2);\n await fs.promises.writeFile(ontologyJsonPath, ontologyJson);\n consola.info(`Wrote ontology.json to ${ontologyJsonPath}`);\n\n let valueTypeResults: BlockGeneratorResult[] = [];\n if (ontologyIr.valueTypes.length > 0) {\n valueTypeResults = await generateValueTypeBlockResults(\n ontologyIr.valueTypes,\n commandLineOpts.buildDir,\n );\n }\n\n // Collect input_mapping_entries for the ontology block\n // These map ontology inputs to datasource block outputs for objects with includeEmptyBackingDatasource\n const ontologyInputMappingEntries: InputMappingEntry[] = shapes.inputMappings;\n\n for (const apiName of backingDatasourceApiNames) {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n if (!objectTypeBlockData) continue;\n\n const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);\n\n // The ontology block has inputs with these readable IDs (from shape extraction)\n // Map them to the datasource block's outputs (which use the same readable IDs)\n const inputDatasetReadableId = ReadableIdGenerator.getForDataset(apiName);\n const outputDatasetReadableId = ReadableIdGenerator.getForDatasetOutput(\n apiName,\n );\n if (shapes.inputShapes.has(inputDatasetReadableId)) {\n ontologyInputMappingEntries.push({\n input: inputDatasetReadableId,\n output: outputDatasetReadableId,\n });\n }\n\n for (const prop of nonEditOnlyProps) {\n const colInputReadableId = ReadableIdGenerator.getForDatasetColumn(\n apiName,\n prop.apiName!,\n );\n const getForDatasetColumnOutput = ReadableIdGenerator\n .getForDatasetColumnOutput(apiName, prop.apiName!);\n if (shapes.inputShapes.has(colInputReadableId)) {\n ontologyInputMappingEntries.push({\n input: colInputReadableId,\n output: getForDatasetColumnOutput,\n });\n }\n }\n }\n\n // Collect input_mapping_entries for link types with includeEmptyBackingDatasource\n for (const linkApiName of backingDatasourceLinkApiNames) {\n const linkTypeBlockData = findLinkTypeByApiName(\n ontologyIr.ontology.linkTypes,\n linkApiName,\n );\n if (!linkTypeBlockData) continue;\n\n const datasetName = `link.${linkApiName}`;\n\n // Map tabularDatasource\n const inputDsId = ReadableIdGenerator.getForDataset(datasetName);\n const outputDsId = ReadableIdGenerator.getForDatasetOutput(datasetName);\n if (shapes.inputShapes.has(inputDsId)) {\n ontologyInputMappingEntries.push({\n input: inputDsId,\n output: outputDsId,\n });\n }\n\n // Map columns from the datasource\n const ds = linkTypeBlockData.datasources[0]?.datasource;\n if (ds?.type === \"dataset\") {\n const columnNames = [\n ...Object.values(ds.dataset.objectTypeAPrimaryKeyMapping).map(String),\n ...Object.values(ds.dataset.objectTypeBPrimaryKeyMapping).map(String),\n ];\n for (const colName of columnNames) {\n const colInputId = ReadableIdGenerator.getForDatasetColumn(\n datasetName,\n colName,\n );\n const colOutputId = ReadableIdGenerator.getForDatasetColumnOutput(\n datasetName,\n colName,\n );\n if (shapes.inputShapes.has(colInputId)) {\n ontologyInputMappingEntries.push({\n input: colInputId,\n output: colOutputId,\n });\n }\n }\n }\n }\n\n ontologyInputMappingEntries.push(\n ...getValueTypeInternalMappings(ontologyIr.valueTypes, shapes.inputShapes),\n );\n\n // Generate backing datasource BlockGeneratorResults for objects with includeEmptyBackingDatasource\n const backingDsGeneratorResults = await Promise.all(\n backingDatasourceApiNames.filter(apiName => {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n return objectTypeBlockData !== undefined;\n }).map(async apiName => {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n consola.info(\n `Generating backing datasource BlockGeneratorResult for ${apiName}...`,\n );\n\n return await generateBackingDatasetBlockResult(\n objectTypeBlockData!,\n commandLineOpts.buildDir,\n commandLineOpts.randomnessKey,\n );\n }),\n );\n\n // Generate backing datasource BlockGeneratorResults for link types with includeEmptyBackingDatasource\n const backingDsLinkGeneratorResults = await Promise.all(\n backingDatasourceLinkApiNames\n .map(linkApiName => {\n const linkTypeBlockData = findLinkTypeByApiName(\n ontologyIr.ontology.linkTypes,\n linkApiName,\n );\n if (!linkTypeBlockData) return undefined;\n consola.info(\n `Generating backing datasource BlockGeneratorResult for link ${linkApiName}...`,\n );\n return generateBackingDatasetBlockResultForLink(\n linkTypeBlockData,\n linkApiName,\n ontologyIr.ontology.objectTypes,\n commandLineOpts.buildDir,\n commandLineOpts.randomnessKey,\n );\n })\n .filter(\n (p): p is Promise<BlockGeneratorResult> => p !== undefined,\n ),\n );\n\n // Create BlockGeneratorResult\n const blockGeneratorResult: BlockGeneratorResult = {\n block_identifier: \"ontology\",\n block_data_directory: blockDataDir,\n oci_block_data_metadata: undefined,\n maven_block_data_metadata: undefined,\n inputs: Object.fromEntries(shapes.inputShapes),\n outputs: Object.fromEntries(shapes.outputShapes),\n input_mapping_entries: ontologyInputMappingEntries,\n external_recommendations: [],\n add_on_override: undefined,\n input_shape_metadata: Object.fromEntries(shapes.inputShapeMetadata),\n block_type: \"ONTOLOGY\",\n };\n\n // Write BlockGeneratorResult to output file\n const blockGeneratorResultJson = JSON.stringify(\n [\n blockGeneratorResult,\n ...backingDsGeneratorResults,\n ...backingDsLinkGeneratorResults,\n ...valueTypeResults,\n ],\n null,\n 2,\n );\n await fs.promises.writeFile(\n commandLineOpts.output,\n blockGeneratorResultJson,\n );\n consola.success(\n `BlockGeneratorResult written to ${commandLineOpts.output}`,\n );\n consola.info(\n `Block data directory: ${blockDataDir}`,\n );\n\n if (valueTypeResults.length > 0) {\n const valueTypeResultsJson = JSON.stringify(valueTypeResults, null, 2);\n await fs.promises.writeFile(\n commandLineOpts.valueTypesOutput,\n valueTypeResultsJson,\n );\n consola.success(\n `Value type BlockGeneratorResult written to ${commandLineOpts.valueTypesOutput}`,\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n functionsIrFile?: string,\n randomnessKey?: string,\n) {\n const result = await defineOntologyV2(\n apiNamespace,\n async () => await import(pathToFileURL(input).href),\n functionsIrFile,\n randomnessKey,\n );\n return result;\n}\n\n/**\n * Find an ObjectTypeBlockDataV2 by apiName within the ontology block data.\n */\nfunction findObjectTypeByApiName(\n objectTypes: Record<string, ObjectTypeBlockDataV2>,\n apiName: string,\n): ObjectTypeBlockDataV2 | undefined {\n return Object.values(objectTypes).find(\n (objectTypeBlockData) => objectTypeBlockData.objectType.apiName === apiName,\n );\n}\n\n/**\n * Find a LinkTypeBlockDataV2 by apiName within the ontology block data.\n */\nfunction findLinkTypeByApiName(\n linkTypes: Record<string, LinkTypeBlockDataV2>,\n apiName: string,\n): LinkTypeBlockDataV2 | undefined {\n const linkTypeId = cleanAndValidateLinkTypeId(apiName);\n return Object.values(linkTypes).find(\n (lt) => lt.linkType.id === linkTypeId,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,0BAA0B,QAAQ,oCAAoC;AAC/E,SAASC,0BAA0B,QAAQ,aAAa;AACxD,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,SACEC,iCAAiC,EACjCC,wCAAwC,EACxCC,wBAAwB,QACnB,6BAA6B;AACpC,SACEC,6BAA6B,EAC7BC,4BAA4B,QACvB,oCAAoC;AAI3C,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACfnB,OAAO,CAACoB,GAAG,CAAC,iDAAiD,CAAC;EAE9D,MAAMC,eAWL,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B;EACjC,MAAMiE,UAAU,GAAGvJ,0BAA0B,CAACsF,OAAO,CAAC;EACtD,OAAO2B,MAAM,CAACC,MAAM,CAACT,SAAS,CAAC,CAAC4C,IAAI,CACjCG,EAAE,IAAKA,EAAE,CAACC,QAAQ,CAACC,EAAE,KAAKH,UAC7B,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["OntologyIrToFullMetadataConverter","PreviewOntologyIrConverter","cleanAndValidateLinkTypeId","consola","fs","path","pathToFileURL","invariant","yargs","hideBin","defineOntologyV2","ReadableIdGenerator","generateBackingDatasetBlockResult","generateBackingDatasetBlockResultForLink","getNonEditOnlyProperties","generateValueTypeBlockResults","getValueTypeInternalMappings","apiNamespaceRegex","uuidRegex","main","args","process","argv","log","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","valueTypesOutput","apiNamespace","buildDir","temporaryBlockDataFile","functionsDir","nodeModulesDir","functionsIrOutputFile","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","functionsIrFile","fileContent","promises","readFile","blockDataJson","JSON","parse","error","exit","previewMetadata","getPreviewFullMetadataFromBlockData","discoverTypeScriptFunctions","ontologyIr","shapes","backingDatasourceApiNames","backingDatasourceLinkApiNames","loadOntology","blockDataDir","join","existsSync","mkdir","recursive","ontologyJsonPath","ontologyJson","stringify","ontology","writeFile","valueTypeResults","valueTypes","ontologyInputMappingEntries","inputMappings","apiName","objectTypeBlockData","findObjectTypeByApiName","objectTypes","nonEditOnlyProps","inputDatasetReadableId","getForDataset","outputDatasetReadableId","getForDatasetOutput","inputShapes","has","push","prop","colInputReadableId","getForDatasetColumn","getForDatasetColumnOutput","linkApiName","linkTypeBlockData","findLinkTypeByApiName","linkTypes","datasetName","inputDsId","outputDsId","ds","datasources","datasource","columnNames","Object","values","dataset","objectTypeAPrimaryKeyMapping","map","String","objectTypeBPrimaryKeyMapping","colName","colInputId","colOutputId","backingDsGeneratorResults","Promise","all","filter","backingDsLinkGeneratorResults","p","blockGeneratorResult","block_identifier","block_data_directory","oci_block_data_metadata","maven_block_data_metadata","inputs","fromEntries","outputs","outputShapes","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","inputShapeMetadata","block_type","blockGeneratorResultJson","success","valueTypeResultsJson","outputDir","result","href","find","objectType","linkTypeId","lt","linkType","id"],"sources":["main.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkTypeBlockDataV2,\n ObjectTypeBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { PreviewOntologyIrConverter } from \"@osdk/generator-converters.preview\";\nimport { cleanAndValidateLinkTypeId } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntologyV2 } from \"../api/defineOntologyV2.js\";\nimport { ReadableIdGenerator } from \"../util/generateRid.js\";\nimport {\n generateBackingDatasetBlockResult,\n generateBackingDatasetBlockResultForLink,\n getNonEditOnlyProperties,\n} from \"./generateBackingDataset.js\";\nimport {\n generateValueTypeBlockResults,\n getValueTypeInternalMappings,\n} from \"./generateValueTypeBlockResults.js\";\nimport type { BlockGeneratorResult } from \"./marketplaceSerialization/BlockGeneratorResult.js\";\nimport type { InputMappingEntry } from \"./marketplaceSerialization/supportingTypes.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n consola.log(\"Generating BlockGeneratorResult for ontology...\");\n\n const commandLineOpts: {\n input: string;\n output: string;\n valueTypesOutput: string;\n apiNamespace: string;\n buildDir: string;\n temporaryBlockDataFile?: string;\n functionsDir?: string;\n nodeModulesDir?: string;\n functionsIrOutputFile?: string;\n randomnessKey?: string;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file for ontology BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/block_generator_result.json\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Output file for value types BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/value_types_block_generator_result.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n buildDir: {\n alias: \"b\",\n describe: \"Directory for build files\",\n type: \"string\",\n default: \"build/\",\n coerce: path.resolve,\n },\n temporaryBlockDataFile: {\n alias: \"f\",\n describe:\n \"Path to a previously generated block data file. Supplying this field indicates that function backed actions should be generated\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsDir: {\n type: \"string\",\n coerce: path.resolve,\n },\n nodeModulesDir: {\n type: \"string\",\n coerce: path.resolve,\n },\n functionsIrOutputFile: {\n type: \"string\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n },\n })\n .parseAsync();\n\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (commandLineOpts.apiNamespace.slice(-1) !== \".\")\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n let functionsIrFile;\n if (commandLineOpts.temporaryBlockDataFile) {\n consola.info(\n `Loading temporary block data from ${commandLineOpts.temporaryBlockDataFile}`,\n );\n const fileContent = await fs.promises.readFile(\n commandLineOpts.temporaryBlockDataFile,\n \"utf-8\",\n );\n let blockDataJson: unknown;\n try {\n blockDataJson = JSON.parse(fileContent);\n } catch {\n consola.error(\n `Failed to parse JSON from ${commandLineOpts.temporaryBlockDataFile}`,\n );\n process.exit(1);\n }\n const previewMetadata = PreviewOntologyIrConverter\n .getPreviewFullMetadataFromBlockData(\n blockDataJson as Parameters<\n typeof PreviewOntologyIrConverter.getPreviewFullMetadataFromBlockData\n >[0],\n );\n invariant(\n commandLineOpts.functionsDir && commandLineOpts.nodeModulesDir,\n \"functionsDir and nodeModulesDir must be supplied when using temporaryBlockDataFile\",\n );\n await OntologyIrToFullMetadataConverter.discoverTypeScriptFunctions(\n commandLineOpts.functionsDir,\n commandLineOpts.nodeModulesDir,\n commandLineOpts.functionsIrOutputFile,\n previewMetadata,\n );\n functionsIrFile = commandLineOpts.functionsIrOutputFile;\n consola.info(\n `Discovered functions during block data generation at ${commandLineOpts.functionsIrOutputFile}`,\n );\n }\n\n const {\n ontologyIr,\n shapes,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n } = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.buildDir,\n functionsIrFile,\n commandLineOpts.randomnessKey,\n );\n\n // Create temp directory for block data\n const blockDataDir = path.join(commandLineOpts.buildDir, \"temp_block_data\");\n if (!fs.existsSync(blockDataDir)) {\n await fs.promises.mkdir(blockDataDir, { recursive: true });\n }\n\n // Write ontology.json to the block data directory\n const ontologyJsonPath = path.join(blockDataDir, \"ontology.json\");\n const ontologyJson = JSON.stringify(ontologyIr.ontology, null, 2);\n await fs.promises.writeFile(ontologyJsonPath, ontologyJson);\n consola.info(`Wrote ontology.json to ${ontologyJsonPath}`);\n\n let valueTypeResults: BlockGeneratorResult[] = [];\n if (ontologyIr.valueTypes.length > 0) {\n valueTypeResults = await generateValueTypeBlockResults(\n ontologyIr.valueTypes,\n commandLineOpts.buildDir,\n );\n }\n\n // Collect input_mapping_entries for the ontology block\n // These map ontology inputs to datasource block outputs for objects with includeEmptyBackingDatasource\n const ontologyInputMappingEntries: InputMappingEntry[] = shapes.inputMappings;\n\n for (const apiName of backingDatasourceApiNames) {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n if (!objectTypeBlockData) continue;\n\n const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);\n\n // The ontology block has inputs with these readable IDs (from shape extraction)\n // Map them to the datasource block's outputs (which use the same readable IDs)\n const inputDatasetReadableId = ReadableIdGenerator.getForDataset(apiName);\n const outputDatasetReadableId = ReadableIdGenerator.getForDatasetOutput(\n apiName,\n );\n if (shapes.inputShapes.has(inputDatasetReadableId)) {\n ontologyInputMappingEntries.push({\n input: inputDatasetReadableId,\n output: outputDatasetReadableId,\n });\n }\n\n for (const prop of nonEditOnlyProps) {\n const colInputReadableId = ReadableIdGenerator.getForDatasetColumn(\n apiName,\n prop.apiName!,\n );\n const getForDatasetColumnOutput = ReadableIdGenerator\n .getForDatasetColumnOutput(apiName, prop.apiName!);\n if (shapes.inputShapes.has(colInputReadableId)) {\n ontologyInputMappingEntries.push({\n input: colInputReadableId,\n output: getForDatasetColumnOutput,\n });\n }\n }\n }\n\n // Collect input_mapping_entries for link types with includeEmptyBackingDatasource\n for (const linkApiName of backingDatasourceLinkApiNames) {\n const linkTypeBlockData = findLinkTypeByApiName(\n ontologyIr.ontology.linkTypes,\n linkApiName,\n );\n if (!linkTypeBlockData) continue;\n\n const datasetName = `link.${linkApiName}`;\n\n // Map tabularDatasource\n const inputDsId = ReadableIdGenerator.getForDataset(datasetName);\n const outputDsId = ReadableIdGenerator.getForDatasetOutput(datasetName);\n if (shapes.inputShapes.has(inputDsId)) {\n ontologyInputMappingEntries.push({\n input: inputDsId,\n output: outputDsId,\n });\n }\n\n // Map columns from the datasource\n const ds = linkTypeBlockData.datasources[0]?.datasource;\n if (ds?.type === \"dataset\") {\n const columnNames = [\n ...Object.values(ds.dataset.objectTypeAPrimaryKeyMapping).map(String),\n ...Object.values(ds.dataset.objectTypeBPrimaryKeyMapping).map(String),\n ];\n for (const colName of columnNames) {\n const colInputId = ReadableIdGenerator.getForDatasetColumn(\n datasetName,\n colName,\n );\n const colOutputId = ReadableIdGenerator.getForDatasetColumnOutput(\n datasetName,\n colName,\n );\n if (shapes.inputShapes.has(colInputId)) {\n ontologyInputMappingEntries.push({\n input: colInputId,\n output: colOutputId,\n });\n }\n }\n }\n }\n\n ontologyInputMappingEntries.push(\n ...getValueTypeInternalMappings(ontologyIr.valueTypes, shapes.inputShapes),\n );\n\n // Generate backing datasource BlockGeneratorResults for objects with includeEmptyBackingDatasource\n const backingDsGeneratorResults = await Promise.all(\n backingDatasourceApiNames.filter(apiName => {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n return objectTypeBlockData !== undefined;\n }).map(async apiName => {\n const objectTypeBlockData = findObjectTypeByApiName(\n ontologyIr.ontology.objectTypes,\n apiName,\n );\n consola.info(\n `Generating backing datasource BlockGeneratorResult for ${apiName}...`,\n );\n\n return await generateBackingDatasetBlockResult(\n objectTypeBlockData!,\n commandLineOpts.buildDir,\n commandLineOpts.randomnessKey,\n );\n }),\n );\n\n // Generate backing datasource BlockGeneratorResults for link types with includeEmptyBackingDatasource\n const backingDsLinkGeneratorResults = await Promise.all(\n backingDatasourceLinkApiNames\n .map(linkApiName => {\n const linkTypeBlockData = findLinkTypeByApiName(\n ontologyIr.ontology.linkTypes,\n linkApiName,\n );\n if (!linkTypeBlockData) return undefined;\n consola.info(\n `Generating backing datasource BlockGeneratorResult for link ${linkApiName}...`,\n );\n return generateBackingDatasetBlockResultForLink(\n linkTypeBlockData,\n linkApiName,\n ontologyIr.ontology.objectTypes,\n commandLineOpts.buildDir,\n commandLineOpts.randomnessKey,\n );\n })\n .filter(\n (p): p is Promise<BlockGeneratorResult> => p !== undefined,\n ),\n );\n\n // Create BlockGeneratorResult\n const blockGeneratorResult: BlockGeneratorResult = {\n block_identifier: \"ontology\",\n block_data_directory: blockDataDir,\n oci_block_data_metadata: undefined,\n maven_block_data_metadata: undefined,\n inputs: Object.fromEntries(shapes.inputShapes),\n outputs: Object.fromEntries(shapes.outputShapes),\n input_mapping_entries: ontologyInputMappingEntries,\n external_recommendations: [],\n add_on_override: undefined,\n input_shape_metadata: Object.fromEntries(shapes.inputShapeMetadata),\n block_type: \"ONTOLOGY\",\n };\n\n // Write BlockGeneratorResult to output file\n const blockGeneratorResultJson = JSON.stringify(\n [\n blockGeneratorResult,\n ...backingDsGeneratorResults,\n ...backingDsLinkGeneratorResults,\n ...valueTypeResults,\n ],\n null,\n 2,\n );\n await fs.promises.writeFile(\n commandLineOpts.output,\n blockGeneratorResultJson,\n );\n consola.success(\n `BlockGeneratorResult written to ${commandLineOpts.output}`,\n );\n consola.info(\n `Block data directory: ${blockDataDir}`,\n );\n\n if (valueTypeResults.length > 0) {\n const valueTypeResultsJson = JSON.stringify(valueTypeResults, null, 2);\n await fs.promises.writeFile(\n commandLineOpts.valueTypesOutput,\n valueTypeResultsJson,\n );\n consola.success(\n `Value type BlockGeneratorResult written to ${commandLineOpts.valueTypesOutput}`,\n );\n }\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir?: string,\n functionsIrFile?: string,\n randomnessKey?: string,\n) {\n const result = await defineOntologyV2(\n apiNamespace,\n async () => await import(pathToFileURL(input).href),\n outputDir,\n functionsIrFile,\n randomnessKey,\n );\n return result;\n}\n\n/**\n * Find an ObjectTypeBlockDataV2 by apiName within the ontology block data.\n */\nfunction findObjectTypeByApiName(\n objectTypes: Record<string, ObjectTypeBlockDataV2>,\n apiName: string,\n): ObjectTypeBlockDataV2 | undefined {\n return Object.values(objectTypes).find(\n (objectTypeBlockData) => objectTypeBlockData.objectType.apiName === apiName,\n );\n}\n\n/**\n * Find a LinkTypeBlockDataV2 by apiName within the ontology block data.\n */\nfunction findLinkTypeByApiName(\n linkTypes: Record<string, LinkTypeBlockDataV2>,\n apiName: string,\n): LinkTypeBlockDataV2 | undefined {\n const linkTypeId = cleanAndValidateLinkTypeId(apiName);\n return Object.values(linkTypes).find(\n (lt) => lt.linkType.id === linkTypeId,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,0BAA0B,QAAQ,oCAAoC;AAC/E,SAASC,0BAA0B,QAAQ,aAAa;AACxD,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,S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AAI,CAAC,EACnDF,SAAS,EACT5F,eAAe,EACfT,aACF,CAAC;EACD,OAAOsG,MAAM;AACf;;AAEA;AACA;AACA;AACA,SAAS5D,uBAAuBA,CAC9BC,WAAkD,EAClDH,OAAe,EACoB;EACnC,OAAO2B,MAAM,CAACC,MAAM,CAACzB,WAAW,CAAC,CAAC6D,IAAI,CACnC/D,mBAAmB,IAAKA,mBAAmB,CAACgE,UAAU,CAACjE,OAAO,KAAKA,OACtE,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASkB,qBAAqBA,CAC5BC,SAA8C,EAC9CnB,OAAe,EACkB;EACjC,MAAMkE,UAAU,GAAGxJ,0BAA0B,CAACsF,OAAO,CAAC;EACtD,OAAO2B,MAAM,CAACC,MAAM,CAACT,SAAS,CAAC,CAAC6C,IAAI,CACjCG,EAAE,IAAKA,EAAE,CAACC,QAAQ,CAACC,EAAE,KAAKH,UAC7B,CAAC;AACH","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -4781,7 +4781,7 @@ var ImportedBaseParameterTypeConverter = class {
|
|
|
4781
4781
|
};
|
|
4782
4782
|
|
|
4783
4783
|
// src/api/defineOntologyV2.ts
|
|
4784
|
-
async function defineOntologyV2(ns, body, functionsIrFile, randomnessKey) {
|
|
4784
|
+
async function defineOntologyV2(ns, body, outputDir, functionsIrFile, randomnessKey) {
|
|
4785
4785
|
maker.initializeOntologyState(ns);
|
|
4786
4786
|
try {
|
|
4787
4787
|
await body();
|
|
@@ -4809,6 +4809,9 @@ async function defineOntologyV2(ns, body, functionsIrFile, randomnessKey) {
|
|
|
4809
4809
|
const lt = link;
|
|
4810
4810
|
return "many" in lt && !("intermediaryObjectType" in lt) && lt.includeEmptyBackingDatasource === true;
|
|
4811
4811
|
}).map(([apiName]) => apiName);
|
|
4812
|
+
if (outputDir) {
|
|
4813
|
+
maker.writeStaticObjects(outputDir);
|
|
4814
|
+
}
|
|
4812
4815
|
return {
|
|
4813
4816
|
ontologyIr: ontDef,
|
|
4814
4817
|
shapes,
|
|
@@ -5113,7 +5116,7 @@ var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
|
5113
5116
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
5114
5117
|
async function main(args = process.argv) {
|
|
5115
5118
|
consola.consola.log("Generating BlockGeneratorResult for ontology...");
|
|
5116
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.18.
|
|
5119
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.18.1-main-56c2c9fdaf97899b89e2dfd18c578bbc6d2de4de").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
5117
5120
|
input: {
|
|
5118
5121
|
alias: "i",
|
|
5119
5122
|
describe: "Input file",
|
|
@@ -5201,7 +5204,7 @@ async function main(args = process.argv) {
|
|
|
5201
5204
|
shapes,
|
|
5202
5205
|
backingDatasourceApiNames,
|
|
5203
5206
|
backingDatasourceLinkApiNames
|
|
5204
|
-
} = await loadOntology(commandLineOpts.input, apiNamespace, functionsIrFile, commandLineOpts.randomnessKey);
|
|
5207
|
+
} = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.buildDir, functionsIrFile, commandLineOpts.randomnessKey);
|
|
5205
5208
|
const blockDataDir = path3__namespace.join(commandLineOpts.buildDir, "temp_block_data");
|
|
5206
5209
|
if (!fs4__namespace.existsSync(blockDataDir)) {
|
|
5207
5210
|
await fs4__namespace.promises.mkdir(blockDataDir, {
|
|
@@ -5305,8 +5308,8 @@ async function main(args = process.argv) {
|
|
|
5305
5308
|
consola.consola.success(`Value type BlockGeneratorResult written to ${commandLineOpts.valueTypesOutput}`);
|
|
5306
5309
|
}
|
|
5307
5310
|
}
|
|
5308
|
-
async function loadOntology(input, apiNamespace, functionsIrFile, randomnessKey) {
|
|
5309
|
-
const result = await defineOntologyV2(apiNamespace, async () => await import(url.pathToFileURL(input).href), functionsIrFile, randomnessKey);
|
|
5311
|
+
async function loadOntology(input, apiNamespace, outputDir, functionsIrFile, randomnessKey) {
|
|
5312
|
+
const result = await defineOntologyV2(apiNamespace, async () => await import(url.pathToFileURL(input).href), outputDir, functionsIrFile, randomnessKey);
|
|
5310
5313
|
return result;
|
|
5311
5314
|
}
|
|
5312
5315
|
function findObjectTypeByApiName(objectTypes, apiName) {
|