@osdk/maker-experimental 0.78.0 → 0.78.1-main-6df3c1ebcd2e692ca80dc7bd648f63a007c9e72c
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/defineFunctionBackedAction.js +6 -0
- package/build/browser/api/defineFunctionBackedAction.js.map +1 -1
- package/build/browser/api/defineOntologyV2.js +14 -2
- package/build/browser/api/defineOntologyV2.js.map +1 -1
- package/build/browser/cli/generateBackingDataset.js +17 -42
- package/build/browser/cli/generateBackingDataset.js.map +1 -1
- package/build/browser/cli/main.js +8 -5
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertInterface.js +1 -0
- package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +0 -1
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -1
- package/build/browser/util/foldersUtil.js +235 -0
- package/build/browser/util/foldersUtil.js.map +1 -0
- package/build/browser/util/generateRid.js +6 -0
- package/build/browser/util/generateRid.js.map +1 -1
- package/build/cjs/{ActionTypeShapeExtractor-6X7H535Z.cjs → ActionTypeShapeExtractor-KSX4XOP6.cjs} +6 -6
- package/build/cjs/{ActionTypeShapeExtractor-6X7H535Z.cjs.map → ActionTypeShapeExtractor-KSX4XOP6.cjs.map} +1 -1
- package/build/cjs/{chunk-HS3TD4CA.cjs → chunk-MPWLPQEH.cjs} +8 -2
- package/build/cjs/chunk-MPWLPQEH.cjs.map +1 -0
- package/build/cjs/index.cjs +415 -219
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +5 -1
- package/build/esm/api/defineFunctionBackedAction.js +6 -0
- package/build/esm/api/defineFunctionBackedAction.js.map +1 -1
- package/build/esm/api/defineOntologyV2.js +14 -2
- package/build/esm/api/defineOntologyV2.js.map +1 -1
- package/build/esm/cli/generateBackingDataset.js +17 -42
- package/build/esm/cli/generateBackingDataset.js.map +1 -1
- package/build/esm/cli/main.js +8 -5
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertInterface.js +1 -0
- package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +0 -1
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -1
- package/build/esm/util/foldersUtil.js +235 -0
- package/build/esm/util/foldersUtil.js.map +1 -0
- package/build/esm/util/generateRid.js +6 -0
- package/build/esm/util/generateRid.js.map +1 -1
- package/build/types/api/defineFunctionBackedAction.d.ts +4 -1
- package/build/types/api/defineFunctionBackedAction.d.ts.map +1 -1
- package/build/types/api/defineOntologyV2.d.ts +2 -1
- package/build/types/api/defineOntologyV2.d.ts.map +1 -1
- package/build/types/cli/generateBackingDataset.d.ts +3 -2
- package/build/types/cli/generateBackingDataset.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/util/foldersUtil.d.ts +24 -0
- package/build/types/util/foldersUtil.d.ts.map +1 -0
- package/build/types/util/generateRid.d.ts +2 -0
- package/build/types/util/generateRid.d.ts.map +1 -1
- package/package.json +3 -3
- package/build/cjs/chunk-HS3TD4CA.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @osdk/maker-experimental
|
|
2
2
|
|
|
3
|
+
## 0.78.1-main-6df3c1ebcd2e692ca80dc7bd648f63a007c9e72c
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6df3c1e: Support folder structure in OAC
|
|
8
|
+
- Updated dependencies [6df3c1e]
|
|
9
|
+
- @osdk/maker@0.82.1-main-6df3c1ebcd2e692ca80dc7bd648f63a007c9e72c
|
|
10
|
+
|
|
3
11
|
## 0.78.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -21,6 +21,12 @@ export function defineFunctionBackedAction(def) {
|
|
|
21
21
|
apiName: def.apiName ?? `${def.functionApiName.toLowerCase()}-action`,
|
|
22
22
|
displayName: def.displayName ?? `Function action ${def.functionApiName}`,
|
|
23
23
|
description: def.description,
|
|
24
|
+
...(def.folder !== undefined && {
|
|
25
|
+
folder: def.folder
|
|
26
|
+
}),
|
|
27
|
+
...(def.permission !== undefined && {
|
|
28
|
+
permission: def.permission
|
|
29
|
+
}),
|
|
24
30
|
rules: [{
|
|
25
31
|
type: "functionRule",
|
|
26
32
|
functionRule: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineFunctionBackedAction.js","names":["defineAction","kebab","defineFunctionBackedAction","def","apiName","functionApiName","toLowerCase","displayName","description","rules","type","functionRule","functionRid","functionInputValues","functionVersion","status","validation","condition","true","displayMetadata","failureMessage","typeClasses"],"sources":["defineFunctionBackedAction.ts"],"sourcesContent":["/*\n * Copyright 2026 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 {
|
|
1
|
+
{"version":3,"file":"defineFunctionBackedAction.js","names":["defineAction","kebab","defineFunctionBackedAction","def","apiName","functionApiName","toLowerCase","displayName","description","folder","undefined","permission","rules","type","functionRule","functionRid","functionInputValues","functionVersion","status","validation","condition","true","displayMetadata","failureMessage","typeClasses"],"sources":["defineFunctionBackedAction.ts"],"sourcesContent":["/*\n * Copyright 2026 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 ActionStatus,\n ActionType,\n EntityPermission,\n Folder,\n} from \"@osdk/maker\";\nimport { defineAction, kebab } from \"@osdk/maker\";\n\nexport type FunctionBackedActionTypeUserDefinition = {\n functionApiName: string;\n apiName?: string;\n displayName?: string;\n description?: string;\n status?: ActionStatus;\n permission?: EntityPermission;\n /** Folder path relative to the installation root. Defaults to the root */\n folder?: Folder;\n};\n\nexport function defineFunctionBackedAction(\n def: FunctionBackedActionTypeUserDefinition,\n): ActionType {\n const actionApiName =\n def.apiName ?? `function-action-${kebab(def.functionApiName)}`;\n return defineAction({\n apiName: def.apiName ?? `${def.functionApiName.toLowerCase()}-action`,\n displayName: def.displayName ?? `Function action ${def.functionApiName}`,\n description: def.description,\n ...(def.folder !== undefined && { folder: def.folder }),\n ...(def.permission !== undefined && { permission: def.permission }),\n rules: [\n {\n type: \"functionRule\",\n functionRule: {\n // delegate this to conversion step\n functionRid: def.functionApiName,\n functionInputValues: {},\n functionVersion: \"0.1.0\",\n },\n },\n ],\n status: def.status ?? \"active\",\n ...{\n validation: [\n {\n condition: {\n type: \"true\",\n true: {},\n },\n displayMetadata: {\n failureMessage: \"Validation failed\",\n typeClasses: [],\n },\n },\n ],\n },\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,YAAY,EAAEC,KAAK,QAAQ,aAAa;AAajD,OAAO,SAASC,0BAA0BA,CACxCC,GAA2C,EAC/B;EAEVA,GAAG,CAACC,OAAO,IAAI,mBAAmBH,KAAK,CAACE,GAAG,CAACE,eAAe,CAAC,EAAE;EAChE,OAAOL,YAAY,CAAC;IAClBI,OAAO,EAAED,GAAG,CAACC,OAAO,IAAI,GAAGD,GAAG,CAACE,eAAe,CAACC,WAAW,CAAC,CAAC,SAAS;IACrEC,WAAW,EAAEJ,GAAG,CAACI,WAAW,IAAI,mBAAmBJ,GAAG,CAACE,eAAe,EAAE;IACxEG,WAAW,EAAEL,GAAG,CAACK,WAAW;IAC5B,IAAIL,GAAG,CAACM,MAAM,KAAKC,SAAS,IAAI;MAAED,MAAM,EAAEN,GAAG,CAACM;IAAO,CAAC,CAAC;IACvD,IAAIN,GAAG,CAACQ,UAAU,KAAKD,SAAS,IAAI;MAAEC,UAAU,EAAER,GAAG,CAACQ;IAAW,CAAC,CAAC;IACnEC,KAAK,EAAE,CACL;MACEC,IAAI,EAAE,cAAc;MACpBC,YAAY,EAAE;QACZ;QACAC,WAAW,EAAEZ,GAAG,CAACE,eAAe;QAChCW,mBAAmB,EAAE,CAAC,CAAC;QACvBC,eAAe,EAAE;MACnB;IACF,CAAC,CACF;IACDC,MAAM,EAAEf,GAAG,CAACe,MAAM,IAAI,QAAQ;IAC9B,GAAG;MACDC,UAAU,EAAE,CACV;QACEC,SAAS,EAAE;UACTP,IAAI,EAAE,MAAM;UACZQ,IAAI,EAAE,CAAC;QACT,CAAC;QACDC,eAAe,EAAE;UACfC,cAAc,EAAE,mBAAmB;UACnCC,WAAW,EAAE;QACf;MACF,CAAC;IAEL;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -19,6 +19,7 @@ import { getImportedTypes, getOntologyDefinition, importOntologyEntity, initiali
|
|
|
19
19
|
import { convertOntologyFullMetadata } from "@osdk/maker-import";
|
|
20
20
|
import { convertOntologyDefinition } from "../conversion/toMarketplace/convertOntologyDefinition.js";
|
|
21
21
|
import { getImportedShapes } from "../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js";
|
|
22
|
+
import { getFolderLocationInputs, getOutputFolders } from "../util/foldersUtil.js";
|
|
22
23
|
import { getShapes } from "../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js";
|
|
23
24
|
import { OntologyRidGeneratorImpl, ReadableIdGenerator } from "../util/generateRid.js";
|
|
24
25
|
export async function defineOntologyV2(ns, body, outputDir, dependencyFile, functionsIrFile, randomnessKey, importedLinkTypeIdsByApiName, externalImportedMetadata, packagingOptions = {}, /** Runs once the ontology is fully converted, but before any block data is written to disk. */
|
|
@@ -48,6 +49,16 @@ beforeWrite) {
|
|
|
48
49
|
const ridGenerator = new OntologyRidGeneratorImpl(importedTypes, randomnessKey);
|
|
49
50
|
const ontologyIr = convertOntologyDefinition(ontologyDefinition, ridGenerator, functionsIr, randomnessKey, packagingOptions.targetEnvironment === "EDGE");
|
|
50
51
|
const shapes = await getShapes(ontologyIr.ontology, ridGenerator, functionsIr, randomnessKey);
|
|
52
|
+
const outputFolders = getOutputFolders(ontologyDefinition, shapes.outputShapes);
|
|
53
|
+
const folderLocations = getFolderLocationInputs(outputFolders, shapes.outputShapes.keys());
|
|
54
|
+
for (const [id, input] of folderLocations.inputShapes) {
|
|
55
|
+
shapes.inputShapes.set(id, input);
|
|
56
|
+
}
|
|
57
|
+
for (const [id, metadata] of folderLocations.inputShapeMetadata) {
|
|
58
|
+
shapes.inputShapeMetadata.set(id, metadata);
|
|
59
|
+
}
|
|
60
|
+
shapes.inputMappings.push(...folderLocations.inputMappings);
|
|
61
|
+
ontologyIr.ontology.blockOutputCompassLocations = Object.fromEntries(Array.from(folderLocations.outputToLocationInput, ([output, input]) => [ridGenerator.toBlockInternalId(output), ridGenerator.toBlockInternalId(input)]));
|
|
51
62
|
|
|
52
63
|
// Generate input shapes for imported entities and merge into main shapes
|
|
53
64
|
const importedShapes = getImportedShapes(ontologyIr.importedOntology, ridGenerator, importedLinkTypeIdsByApiName, externalImportedMetadata);
|
|
@@ -90,7 +101,7 @@ beforeWrite) {
|
|
|
90
101
|
const blockDataAddOn = {
|
|
91
102
|
idToBlockShapeId: Object.fromEntries(Array.from(readableIds, readableId => [readableId, ridGenerator.toBlockInternalId(readableId)])),
|
|
92
103
|
idToInputGroupId: {},
|
|
93
|
-
outputToLocationInput:
|
|
104
|
+
outputToLocationInput: Object.fromEntries(Array.from(folderLocations.outputToLocationInput, ([output, input]) => [ridGenerator.toBlockInternalId(output), input]))
|
|
94
105
|
};
|
|
95
106
|
return {
|
|
96
107
|
ontologyIr,
|
|
@@ -100,7 +111,8 @@ beforeWrite) {
|
|
|
100
111
|
importedInputPresets: importedShapes.inputPresets,
|
|
101
112
|
backingDatasourceApiNames,
|
|
102
113
|
backingDatasourceLinkApiNames,
|
|
103
|
-
backingMediaSetNames
|
|
114
|
+
backingMediaSetNames,
|
|
115
|
+
outputFolders
|
|
104
116
|
};
|
|
105
117
|
}
|
|
106
118
|
//# sourceMappingURL=defineOntologyV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineOntologyV2.js","names":["fs","getImportedTypes","getOntologyDefinition","importOntologyEntity","initializeOntologyState","OntologyEntityTypeEnum","writeDependencyFile","writeStaticObjects","convertOntologyFullMetadata","convertOntologyDefinition","getImportedShapes","getShapes","OntologyRidGeneratorImpl","ReadableIdGenerator","defineOntologyV2","ns","body","outputDir","dependencyFile","functionsIrFile","randomnessKey","importedLinkTypeIdsByApiName","externalImportedMetadata","packagingOptions","beforeWrite","e","console","error","importedOntology","entityType","SHARED_PROPERTY_TYPE","INTERFACE_TYPE","OBJECT_TYPE","ACTION_TYPE","entity","Object","values","ontologyDefinition","importedTypes","functionsIr","JSON","parse","readFileSync","ridGenerator","ontologyIr","targetEnvironment","shapes","ontology","importedShapes","key","value","inputShapes","set","inputShapeMetadata","backingDatasourceApiNames","entries","filter","_","obj","includeEmptyBackingDatasource","map","apiName","backingDatasourceLinkApiNames","LINK_TYPE","link","lt","backingMediaSetNames","flatMap","ontologyEntity","objectType","properties","includeEmptyBackingMediaSet","mediaSetName","getForMediaSetView","isOptional","isAccessedInReconcile","reconcileAccessRequirements","readableIds","Set","keys","outputShapes","blockDataAddOn","idToBlockShapeId","fromEntries","Array","from","readableId","toBlockInternalId","idToInputGroupId","outputToLocationInput","importedInputPresets","inputPresets"],"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 * as fs from \"fs\";\n\nimport type { InputPreset } from \"@osdk/client.unstable/api\";\nimport type { IDiscoveredFunction } from \"@osdk/generator-converters.ontologyir\";\nimport type { LinkType, ObjectType, OntologyDefinition } from \"@osdk/maker\";\nimport {\n getImportedTypes,\n getOntologyDefinition,\n importOntologyEntity,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n writeDependencyFile,\n writeStaticObjects,\n} from \"@osdk/maker\";\nimport { convertOntologyFullMetadata } from \"@osdk/maker-import\";\n\nimport type { BlockDataAddOn } from \"../cli/marketplaceSerialization/BlockGeneratorResult.js\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.js\";\nimport {\n type ExternalImportedOntologyMetadata,\n getImportedShapes,\n type LinkTypeIdsByApiName,\n} from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\n\nexport type { ExternalImportedOntologyMetadata } from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\nimport { getShapes } from \"../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js\";\nimport type { BlockShapes, ReadableId } from \"../util/generateRid.js\";\nimport {\n OntologyRidGeneratorImpl,\n ReadableIdGenerator,\n} from \"../util/generateRid.js\";\nimport type { OntologyIrV2 } from \"./OntologyIrV2.js\";\n\nexport interface OntologyPackagingOptions {\n // EDGE packages datasource definitions for both cloud and edge. Defaults to CLOUD.\n targetEnvironment?: \"CLOUD\" | \"EDGE\";\n}\n\nexport interface OntologyV2Result {\n ontologyIr: OntologyIrV2;\n importedTypes: OntologyDefinition;\n shapes: BlockShapes;\n blockDataAddOn: BlockDataAddOn;\n importedInputPresets: Map<ReadableId, InputPreset>;\n backingDatasourceApiNames: string[];\n backingDatasourceLinkApiNames: string[];\n backingMediaSetNames: 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 dependencyFile?: string,\n functionsIrFile?: string,\n randomnessKey?: string,\n importedLinkTypeIdsByApiName?: LinkTypeIdsByApiName,\n externalImportedMetadata?: ExternalImportedOntologyMetadata,\n packagingOptions: OntologyPackagingOptions = {},\n /** Runs once the ontology is fully converted, but before any block data is written to disk. */\n beforeWrite?: (ontology: OntologyDefinition) => void | Promise<void>,\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 if (externalImportedMetadata) {\n const importedOntology = convertOntologyFullMetadata(\n externalImportedMetadata,\n );\n for (const entityType of [\n OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n OntologyEntityTypeEnum.INTERFACE_TYPE,\n OntologyEntityTypeEnum.OBJECT_TYPE,\n OntologyEntityTypeEnum.ACTION_TYPE,\n ] as const) {\n for (const entity of Object.values(importedOntology[entityType])) {\n importOntologyEntity(entity);\n }\n }\n }\n\n const ontologyDefinition = getOntologyDefinition();\n const importedTypes = getImportedTypes();\n\n let functionsIr: FunctionsIr | undefined;\n if (functionsIrFile) {\n functionsIr = JSON.parse(fs.readFileSync(functionsIrFile, \"utf-8\"));\n }\n\n const ridGenerator = new OntologyRidGeneratorImpl(\n importedTypes,\n randomnessKey,\n );\n const ontologyIr = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n functionsIr,\n randomnessKey,\n packagingOptions.targetEnvironment === \"EDGE\",\n );\n\n const shapes = await getShapes(\n ontologyIr.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 ontologyIr.importedOntology,\n ridGenerator,\n importedLinkTypeIdsByApiName,\n externalImportedMetadata,\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(\n ([_, obj]) => (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 (\n \"many\" in lt &&\n !(\"intermediaryObjectType\" in lt) &&\n (lt as LinkType & { includeEmptyBackingDatasource?: boolean })\n .includeEmptyBackingDatasource === true\n );\n })\n .map(([apiName]) => apiName);\n\n const backingMediaSetNames = Object.values(\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE],\n ).flatMap((ontologyEntity) => {\n const objectType = ontologyEntity as ObjectType;\n return (objectType.properties ?? [])\n .filter(\n ({ includeEmptyBackingMediaSet }) =>\n includeEmptyBackingMediaSet === true,\n )\n .map(({ apiName }) => `${objectType.apiName}.${apiName}`);\n });\n\n for (const mediaSetName of backingMediaSetNames) {\n shapes.inputShapeMetadata.set(\n ReadableIdGenerator.getForMediaSetView(mediaSetName),\n {\n isOptional: false,\n isAccessedInReconcile: true,\n reconcileAccessRequirements: \"RESOURCE_EXISTENCE_REQUIRED\",\n },\n );\n }\n\n // Runs last so that an ontology which fails conversion can't have already updated the lockfile.\n await beforeWrite?.(ontologyDefinition);\n\n if (outputDir) {\n writeStaticObjects(outputDir);\n }\n if (dependencyFile) {\n writeDependencyFile(dependencyFile);\n }\n\n const readableIds = new Set([\n ...shapes.inputShapes.keys(),\n ...shapes.outputShapes.keys(),\n ]);\n const blockDataAddOn: BlockDataAddOn = {\n idToBlockShapeId: Object.fromEntries(\n Array.from(readableIds, (readableId) => [\n readableId,\n ridGenerator.toBlockInternalId(readableId),\n ]),\n ),\n idToInputGroupId: {},\n outputToLocationInput: {},\n };\n\n return {\n ontologyIr,\n importedTypes,\n shapes,\n blockDataAddOn,\n importedInputPresets: importedShapes.inputPresets,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n backingMediaSetNames,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,IAAI;AAKxB,SACEC,gBAAgB,EAChBC,qBAAqB,EACrBC,oBAAoB,EACpBC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,QACb,aAAa;AACpB,SAASC,2BAA2B,QAAQ,oBAAoB;AAGhE,SAASC,yBAAyB,QAAQ,0DAA0D;AACpG,SAEEC,iBAAiB,QAEZ,uEAAuE;AAG9E,SAASC,SAAS,QAAQ,iEAAiE;AAE3F,SACEC,wBAAwB,EACxBC,mBAAmB,QACd,wBAAwB;AAuB/B,OAAO,eAAeC,gBAAgBA,CACpCC,EAAU,EACVC,IAAgC,EAChCC,SAAkB,EAClBC,cAAuB,EACvBC,eAAwB,EACxBC,aAAsB,EACtBC,4BAAmD,EACnDC,wBAA2D,EAC3DC,gBAA0C,GAAG,CAAC,CAAC,EAC/C;AACAC,WAAoE,EACzC;EAC3BpB,uBAAuB,CAACW,EAAE,CAAC;EAE3B,IAAI;IACF,MAAMC,IAAI,CAAC,CAAC;EACd,CAAC,C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|
1
|
+
{"version":3,"file":"defineOntologyV2.js","names":["fs","getImportedTypes","getOntologyDefinition","importOntologyEntity","initializeOntologyState","OntologyEntityTypeEnum","writeDependencyFile","writeStaticObjects","convertOntologyFullMetadata","convertOntologyDefinition","getImportedShapes","getFolderLocationInputs","getOutputFolders","getShapes","OntologyRidGeneratorImpl","ReadableIdGenerator","defineOntologyV2","ns","body","outputDir","dependencyFile","functionsIrFile","randomnessKey","importedLinkTypeIdsByApiName","externalImportedMetadata","packagingOptions","beforeWrite","e","console","error","importedOntology","entityType","SHARED_PROPERTY_TYPE","INTERFACE_TYPE","OBJECT_TYPE","ACTION_TYPE","entity","Object","values","ontologyDefinition","importedTypes","functionsIr","JSON","parse","readFileSync","ridGenerator","ontologyIr","targetEnvironment","shapes","ontology","outputFolders","outputShapes","folderLocations","keys","id","input","inputShapes","set","metadata","inputShapeMetadata","inputMappings","push","blockOutputCompassLocations","fromEntries","Array","from","outputToLocationInput","output","toBlockInternalId","importedShapes","key","value","backingDatasourceApiNames","entries","filter","_","obj","includeEmptyBackingDatasource","map","apiName","backingDatasourceLinkApiNames","LINK_TYPE","link","lt","backingMediaSetNames","flatMap","ontologyEntity","objectType","properties","includeEmptyBackingMediaSet","mediaSetName","getForMediaSetView","isOptional","isAccessedInReconcile","reconcileAccessRequirements","readableIds","Set","blockDataAddOn","idToBlockShapeId","readableId","idToInputGroupId","importedInputPresets","inputPresets"],"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 * as fs from \"fs\";\n\nimport type { InputPreset } from \"@osdk/client.unstable/api\";\nimport type { IDiscoveredFunction } from \"@osdk/generator-converters.ontologyir\";\nimport type {\n Folder,\n LinkType,\n ObjectType,\n OntologyDefinition,\n} from \"@osdk/maker\";\nimport {\n getImportedTypes,\n getOntologyDefinition,\n importOntologyEntity,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n writeDependencyFile,\n writeStaticObjects,\n} from \"@osdk/maker\";\nimport { convertOntologyFullMetadata } from \"@osdk/maker-import\";\n\nimport type { BlockDataAddOn } from \"../cli/marketplaceSerialization/BlockGeneratorResult.js\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.js\";\nimport {\n type ExternalImportedOntologyMetadata,\n getImportedShapes,\n type LinkTypeIdsByApiName,\n} from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\nimport {\n getFolderLocationInputs,\n getOutputFolders,\n} from \"../util/foldersUtil.js\";\n\nexport type { ExternalImportedOntologyMetadata } from \"../conversion/toMarketplace/shapeExtractors/ImportedShapeExtractor.js\";\nimport { getShapes } from \"../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js\";\nimport type { BlockShapes, ReadableId } from \"../util/generateRid.js\";\nimport {\n OntologyRidGeneratorImpl,\n ReadableIdGenerator,\n} from \"../util/generateRid.js\";\nimport type { OntologyIrV2 } from \"./OntologyIrV2.js\";\n\nexport interface OntologyPackagingOptions {\n // EDGE packages datasource definitions for both cloud and edge. Defaults to CLOUD.\n targetEnvironment?: \"CLOUD\" | \"EDGE\";\n}\n\nexport interface OntologyV2Result {\n ontologyIr: OntologyIrV2;\n importedTypes: OntologyDefinition;\n shapes: BlockShapes;\n blockDataAddOn: BlockDataAddOn;\n importedInputPresets: Map<ReadableId, InputPreset>;\n backingDatasourceApiNames: string[];\n backingDatasourceLinkApiNames: string[];\n backingMediaSetNames: string[];\n outputFolders: Record<ReadableId, Folder>;\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 dependencyFile?: string,\n functionsIrFile?: string,\n randomnessKey?: string,\n importedLinkTypeIdsByApiName?: LinkTypeIdsByApiName,\n externalImportedMetadata?: ExternalImportedOntologyMetadata,\n packagingOptions: OntologyPackagingOptions = {},\n /** Runs once the ontology is fully converted, but before any block data is written to disk. */\n beforeWrite?: (ontology: OntologyDefinition) => void | Promise<void>,\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 if (externalImportedMetadata) {\n const importedOntology = convertOntologyFullMetadata(\n externalImportedMetadata,\n );\n for (const entityType of [\n OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n OntologyEntityTypeEnum.INTERFACE_TYPE,\n OntologyEntityTypeEnum.OBJECT_TYPE,\n OntologyEntityTypeEnum.ACTION_TYPE,\n ] as const) {\n for (const entity of Object.values(importedOntology[entityType])) {\n importOntologyEntity(entity);\n }\n }\n }\n\n const ontologyDefinition = getOntologyDefinition();\n const importedTypes = getImportedTypes();\n\n let functionsIr: FunctionsIr | undefined;\n if (functionsIrFile) {\n functionsIr = JSON.parse(fs.readFileSync(functionsIrFile, \"utf-8\"));\n }\n\n const ridGenerator = new OntologyRidGeneratorImpl(\n importedTypes,\n randomnessKey,\n );\n const ontologyIr = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n functionsIr,\n randomnessKey,\n packagingOptions.targetEnvironment === \"EDGE\",\n );\n\n const shapes = await getShapes(\n ontologyIr.ontology,\n ridGenerator,\n functionsIr,\n randomnessKey,\n );\n const outputFolders = getOutputFolders(\n ontologyDefinition,\n shapes.outputShapes,\n );\n const folderLocations = getFolderLocationInputs(\n outputFolders,\n shapes.outputShapes.keys(),\n );\n for (const [id, input] of folderLocations.inputShapes) {\n shapes.inputShapes.set(id, input);\n }\n for (const [id, metadata] of folderLocations.inputShapeMetadata) {\n shapes.inputShapeMetadata.set(id, metadata);\n }\n shapes.inputMappings.push(...folderLocations.inputMappings);\n ontologyIr.ontology.blockOutputCompassLocations = Object.fromEntries(\n Array.from(folderLocations.outputToLocationInput, ([output, input]) => [\n ridGenerator.toBlockInternalId(output),\n ridGenerator.toBlockInternalId(input),\n ]),\n );\n\n // Generate input shapes for imported entities and merge into main shapes\n const importedShapes = getImportedShapes(\n ontologyIr.importedOntology,\n ridGenerator,\n importedLinkTypeIdsByApiName,\n externalImportedMetadata,\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(\n ([_, obj]) => (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 (\n \"many\" in lt &&\n !(\"intermediaryObjectType\" in lt) &&\n (lt as LinkType & { includeEmptyBackingDatasource?: boolean })\n .includeEmptyBackingDatasource === true\n );\n })\n .map(([apiName]) => apiName);\n\n const backingMediaSetNames = Object.values(\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE],\n ).flatMap((ontologyEntity) => {\n const objectType = ontologyEntity as ObjectType;\n return (objectType.properties ?? [])\n .filter(\n ({ includeEmptyBackingMediaSet }) =>\n includeEmptyBackingMediaSet === true,\n )\n .map(({ apiName }) => `${objectType.apiName}.${apiName}`);\n });\n\n for (const mediaSetName of backingMediaSetNames) {\n shapes.inputShapeMetadata.set(\n ReadableIdGenerator.getForMediaSetView(mediaSetName),\n {\n isOptional: false,\n isAccessedInReconcile: true,\n reconcileAccessRequirements: \"RESOURCE_EXISTENCE_REQUIRED\",\n },\n );\n }\n\n // Runs last so that an ontology which fails conversion can't have already updated the lockfile.\n await beforeWrite?.(ontologyDefinition);\n\n if (outputDir) {\n writeStaticObjects(outputDir);\n }\n if (dependencyFile) {\n writeDependencyFile(dependencyFile);\n }\n\n const readableIds = new Set([\n ...shapes.inputShapes.keys(),\n ...shapes.outputShapes.keys(),\n ]);\n const blockDataAddOn: BlockDataAddOn = {\n idToBlockShapeId: Object.fromEntries(\n Array.from(readableIds, (readableId) => [\n readableId,\n ridGenerator.toBlockInternalId(readableId),\n ]),\n ),\n idToInputGroupId: {},\n outputToLocationInput: Object.fromEntries(\n Array.from(folderLocations.outputToLocationInput, ([output, input]) => [\n ridGenerator.toBlockInternalId(output),\n input,\n ]),\n ),\n };\n\n return {\n ontologyIr,\n importedTypes,\n shapes,\n blockDataAddOn,\n importedInputPresets: importedShapes.inputPresets,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n backingMediaSetNames,\n outputFolders,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,IAAI;AAUxB,SACEC,gBAAgB,EAChBC,qBAAqB,EACrBC,oBAAoB,EACpBC,uBAAuB,EACvBC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,QACb,aAAa;AACpB,SAASC,2BAA2B,QAAQ,oBAAoB;AAGhE,SAASC,yBAAyB,QAAQ,0DAA0D;AACpG,SAEEC,iBAAiB,QAEZ,uEAAuE;AAC9E,SACEC,uBAAuB,EACvBC,gBAAgB,QACX,wBAAwB;AAG/B,SAASC,SAAS,QAAQ,iEAAiE;AAE3F,SACEC,wBAAwB,EACxBC,mBAAmB,QACd,wBAAwB;AAwB/B,OAAO,eAAeC,gBAAgBA,CACpCC,EAAU,EACVC,IAAgC,EAChCC,SAAkB,EAClBC,cAAuB,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6B;IAC7BI,oBAAoB;IACpBlC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import * as fs from "node:fs";
|
|
18
18
|
import * as path from "node:path";
|
|
19
19
|
import { typeToConcreteDataType } from "../conversion/toMarketplace/typeVisitors.js";
|
|
20
|
+
import { getFolderLocationInputs } from "../util/foldersUtil.js";
|
|
20
21
|
import { ReadableIdGenerator } from "../util/generateRid.js";
|
|
21
22
|
import { toBlockShapeId } from "./marketplaceSerialization/CodeBlockSpec.js";
|
|
22
23
|
|
|
@@ -115,7 +116,7 @@ export function getBackingDatasetProperties(objectTypeBlockData) {
|
|
|
115
116
|
* Shared logic to generate a STATIC_DATASET BlockGeneratorResult from a list of columns.
|
|
116
117
|
* Used by both object type and link type backing dataset generators.
|
|
117
118
|
*/
|
|
118
|
-
async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuffix, columns, buildDir, randomnessKey) {
|
|
119
|
+
async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuffix, columns, buildDir, randomnessKey, folder) {
|
|
119
120
|
// Build output shapes
|
|
120
121
|
const outputs = {};
|
|
121
122
|
const datasourceReadableId = ReadableIdGenerator.getForDatasetOutput(datasetName);
|
|
@@ -167,21 +168,22 @@ async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuff
|
|
|
167
168
|
// These are distinct from the block shape IDs that appear in the manifest outputs.
|
|
168
169
|
// The add-on maps these internal IDs -> block shape IDs.
|
|
169
170
|
const columnInternalIds = columns.map(col => toBlockShapeId(`column-internal-${datasetName}-${col.name}`, randomnessKey));
|
|
170
|
-
const
|
|
171
|
-
|
|
171
|
+
const folderLocations = getFolderLocationInputs({
|
|
172
|
+
[datasourceReadableId]: folder ?? {
|
|
173
|
+
id: "/",
|
|
174
|
+
location: "/"
|
|
175
|
+
}
|
|
176
|
+
}, [datasourceReadableId]);
|
|
172
177
|
const datasourceInternalId = toBlockShapeId(`datasource-internal-${datasetName}`, randomnessKey);
|
|
173
|
-
const locationInternalId = toBlockShapeId(`location-internal-${datasetName}`, randomnessKey);
|
|
174
178
|
const addOnOverride = {
|
|
175
179
|
idToBlockShapeId: {
|
|
176
180
|
"dataset-internal-shape-id": datasourceBlockInternalId,
|
|
177
181
|
[datasourceInternalId]: datasourceBlockInternalId,
|
|
178
|
-
[
|
|
182
|
+
...Object.fromEntries(Array.from(folderLocations.inputShapes.keys(), input => [input, toBlockShapeId(input, randomnessKey)])),
|
|
179
183
|
...Object.fromEntries(columnInternalIds.map((internalId, i) => [internalId, toBlockShapeId(columnReadableIds[i], randomnessKey)]))
|
|
180
184
|
},
|
|
181
185
|
idToInputGroupId: {},
|
|
182
|
-
outputToLocationInput:
|
|
183
|
-
[datasourceBlockInternalId]: compassBlockShapeId
|
|
184
|
-
}
|
|
186
|
+
outputToLocationInput: Object.fromEntries(Array.from(folderLocations.outputToLocationInput, ([output, input]) => [toBlockShapeId(output, randomnessKey), input]))
|
|
185
187
|
};
|
|
186
188
|
|
|
187
189
|
// Create block data directory
|
|
@@ -220,44 +222,17 @@ async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuff
|
|
|
220
222
|
// An empty zip file is just the end-of-central-directory record (22 bytes)
|
|
221
223
|
const emptyZip = Buffer.from([0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
|
|
222
224
|
await fs.promises.writeFile(path.join(dsBlockDataDir, "files.zip"), emptyZip);
|
|
223
|
-
|
|
224
|
-
// Build inputs (compassResource for install location)
|
|
225
|
-
const inputs = {};
|
|
226
|
-
const input_shape_metadata = {};
|
|
227
|
-
inputs[compassReadableId] = {
|
|
228
|
-
type: "compassResource",
|
|
229
|
-
compassResource: {
|
|
230
|
-
about: {
|
|
231
|
-
fallbackTitle: blockIdentifier,
|
|
232
|
-
fallbackDescription: "",
|
|
233
|
-
localizedTitle: {},
|
|
234
|
-
localizedDescription: {}
|
|
235
|
-
},
|
|
236
|
-
allowedTypes: [],
|
|
237
|
-
typeConstraints: [{
|
|
238
|
-
type: "compassFolderTypeConstraints",
|
|
239
|
-
compassFolderTypeConstraints: {
|
|
240
|
-
constraints: ["INSTALL_LOCATION"]
|
|
241
|
-
}
|
|
242
|
-
}]
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
input_shape_metadata[compassReadableId] = {
|
|
246
|
-
isOptional: true,
|
|
247
|
-
reconcileAccessRequirements: "RESOURCE_EXISTENCE_REQUIRED",
|
|
248
|
-
isAccessedInReconcile: true
|
|
249
|
-
};
|
|
250
225
|
return {
|
|
251
226
|
block_identifier: blockIdentifier,
|
|
252
227
|
block_data_directory: dsBlockDataDir,
|
|
253
228
|
oci_block_data_metadata: undefined,
|
|
254
229
|
maven_block_data_metadata: undefined,
|
|
255
|
-
inputs,
|
|
230
|
+
inputs: Object.fromEntries(folderLocations.inputShapes),
|
|
256
231
|
outputs,
|
|
257
|
-
input_mapping_entries:
|
|
232
|
+
input_mapping_entries: folderLocations.inputMappings,
|
|
258
233
|
external_recommendations: [],
|
|
259
234
|
add_on_override: addOnOverride,
|
|
260
|
-
input_shape_metadata,
|
|
235
|
+
input_shape_metadata: Object.fromEntries(folderLocations.inputShapeMetadata),
|
|
261
236
|
block_type: "STATIC_DATASET"
|
|
262
237
|
};
|
|
263
238
|
}
|
|
@@ -267,14 +242,14 @@ async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuff
|
|
|
267
242
|
*/
|
|
268
243
|
// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.
|
|
269
244
|
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
270
|
-
export async function generateBackingDatasetBlockResult(objectTypeBlockData, buildDir, randomnessKey) {
|
|
245
|
+
export async function generateBackingDatasetBlockResult(objectTypeBlockData, buildDir, randomnessKey, folder) {
|
|
271
246
|
const apiName = objectTypeBlockData.objectType.apiName;
|
|
272
247
|
const backingProperties = getBackingDatasetProperties(objectTypeBlockData);
|
|
273
248
|
const columns = backingProperties.map(prop => ({
|
|
274
249
|
name: prop.apiName,
|
|
275
250
|
type: prop.type
|
|
276
251
|
}));
|
|
277
|
-
return generateBackingDatasetBlock(apiName, `${apiName}-backing-ds`, `${apiName}_backing_ds`, columns, buildDir, randomnessKey);
|
|
252
|
+
return generateBackingDatasetBlock(apiName, `${apiName}-backing-ds`, `${apiName}_backing_ds`, columns, buildDir, randomnessKey, folder);
|
|
278
253
|
}
|
|
279
254
|
|
|
280
255
|
/**
|
|
@@ -282,7 +257,7 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
282
257
|
*/
|
|
283
258
|
// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.
|
|
284
259
|
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
285
|
-
export async function generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, objectTypes, buildDir, randomnessKey) {
|
|
260
|
+
export async function generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, objectTypes, buildDir, randomnessKey, folder) {
|
|
286
261
|
const definition = linkTypeBlockData.linkType.definition;
|
|
287
262
|
if (definition.type !== "manyToMany") {
|
|
288
263
|
throw new Error(`Link type "${linkApiName}" is not a many-to-many link type`);
|
|
@@ -319,6 +294,6 @@ export async function generateBackingDatasetBlockResultForLink(linkTypeBlockData
|
|
|
319
294
|
}, {
|
|
320
295
|
name: columnB,
|
|
321
296
|
type: propTypeB
|
|
322
|
-
}], buildDir, randomnessKey);
|
|
297
|
+
}], buildDir, randomnessKey, folder);
|
|
323
298
|
}
|
|
324
299
|
//# sourceMappingURL=generateBackingDataset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateBackingDataset.js","names":["fs","path","typeToConcreteDataType","ReadableIdGenerator","toBlockShapeId","propertyTypeToSchemaType","propType","typeStr","type","Error","typeToFieldSchema","name","nullable","userDefinedTypeClass","customMetadata","arraySubtype","array","subtype","float","precision","decimal","scale","mapKeyType","mapValueType","subSchemas","struct","structFields","map","f","fieldType","apiName","getBackingDatasetProperties","objectTypeBlockData","mappedRids","Set","ds","datasources","def","datasource","propertyMapping","datasetV2","datasetV3","rid","mapping","Object","entries","add","objectType","propertyTypes","filter","has","_","prop","generateBackingDatasetBlock","datasetName","blockIdentifier","dirSuffix","columns","buildDir","randomnessKey","outputs","datasourceReadableId","getForDatasetOutput","columnReadableIds","col","getForDatasetColumnOutput","datasourceBlockInternalId","tabularDatasource","about","fallbackTitle","fallbackDescription","localizedTitle","localizedDescription","schema","id","buildRequirements","isBuildable","i","length","colReadableId","datasourceColumn","concrete","typeclasses","columnInternalIds","compassReadableId","compassBlockShapeId","datasourceInternalId","locationInternalId","addOnOverride","idToBlockShapeId","fromEntries","internalId","idToInputGroupId","outputToLocationInput","dsBlockDataDir","join","promises","mkdir","recursive","schemaJson","fieldSchemaList","primaryKey","dataFrameReaderClass","format","options","writeFile","JSON","stringify","blockDataJson","v1","hasSchema","includeData","emptyZip","Buffer","from","inputs","input_shape_metadata","compassResource","allowedTypes","typeConstraints","compassFolderTypeConstraints","constraints","isOptional","reconcileAccessRequirements","isAccessedInReconcile","block_identifier","block_data_directory","oci_block_data_metadata","undefined","maven_block_data_metadata","input_mapping_entries","external_recommendations","add_on_override","block_type","generateBackingDatasetBlockResult","backingProperties","generateBackingDatasetBlockResultForLink","linkTypeBlockData","linkApiName","objectTypes","definition","linkType","m2m","manyToMany","dataset","pkRidA","keys","objectTypeAPrimaryKeyMapping","columnA","values","pkRidB","objectTypeBPrimaryKeyMapping","columnB","objectTypeA","objectTypeRidA","objectTypeB","objectTypeRidB","propTypeA","propTypeB"],"sources":["generateBackingDataset.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 * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport type {\n LinkTypeBlockDataV2,\n ObjectTypeBlockDataV2,\n PropertyType,\n PropertyTypeMappingInfo,\n Type,\n} from \"@osdk/client.unstable\";\nimport type {\n InputShape,\n InputShapeMetadata,\n OutputShape,\n} from \"@osdk/client.unstable/api\";\n\nimport { typeToConcreteDataType } from \"../conversion/toMarketplace/typeVisitors.js\";\nimport type { ReadableId } from \"../util/generateRid.js\";\nimport { ReadableIdGenerator } from \"../util/generateRid.js\";\nimport type { BlockGeneratorResult } from \"./marketplaceSerialization/BlockGeneratorResult.js\";\nimport { toBlockShapeId } from \"./marketplaceSerialization/CodeBlockSpec.js\";\n\n/**\n * Map from maker property type to Foundry schema field type\n */\nexport function propertyTypeToSchemaType(\n propType: string | { type: string },\n): string {\n const typeStr = typeof propType === \"string\" ? propType : propType.type;\n switch (typeStr) {\n case \"geohash\":\n case \"geoshape\":\n case \"marking\":\n case \"string\":\n return \"STRING\";\n case \"boolean\":\n return \"BOOLEAN\";\n case \"integer\":\n return \"INTEGER\";\n case \"long\":\n return \"LONG\";\n case \"double\":\n return \"DOUBLE\";\n case \"float\":\n return \"FLOAT\";\n case \"byte\":\n return \"BYTE\";\n case \"short\":\n return \"SHORT\";\n case \"date\":\n return \"DATE\";\n case \"timestamp\":\n return \"TIMESTAMP\";\n case \"array\":\n return \"ARRAY\";\n case \"vector\":\n return \"ARRAY\";\n case \"decimal\":\n return \"DECIMAL\";\n case \"struct\":\n return \"STRUCT\";\n default:\n throw new Error(\n `Unsupported property type \"${typeStr}\" for empty backing datasource. ` +\n `If using a property type that doesn't support empty backing datasources please make the property an edit only property.`,\n );\n }\n}\n\n/**\n * A single field entry in a Foundry dataset schema.json `fieldSchemaList`.\n */\ninterface FieldSchema {\n type: string;\n name: string | null;\n nullable: boolean | null;\n userDefinedTypeClass: string | null;\n customMetadata: Record<string, unknown>;\n arraySubtype: FieldSchema | null;\n precision: number | null;\n scale: number | null;\n mapKeyType: FieldSchema | null;\n mapValueType: FieldSchema | null;\n subSchemas: FieldSchema[] | null;\n}\n\n/**\n * Build a Foundry schema field object for a column type.\n */\nexport function typeToFieldSchema(type: Type, name?: string): FieldSchema {\n return {\n type: propertyTypeToSchemaType(type),\n name: name ?? null,\n nullable: null,\n userDefinedTypeClass: null,\n customMetadata: {},\n arraySubtype:\n type.type === \"array\"\n ? typeToFieldSchema(type.array.subtype)\n : type.type === \"vector\"\n ? typeToFieldSchema({ type: \"float\", float: {} })\n : null,\n precision:\n type.type === \"decimal\" ? (type.decimal.precision ?? null) : null,\n scale: type.type === \"decimal\" ? (type.decimal.scale ?? null) : null,\n mapKeyType: null,\n mapValueType: null,\n subSchemas:\n type.type === \"struct\"\n ? type.struct.structFields.map((f) =>\n typeToFieldSchema(f.fieldType, f.apiName),\n )\n : null,\n };\n}\n\n/**\n * Select properties backed by dataset columns, excluding derived and edit-only properties.\n */\nexport function getBackingDatasetProperties(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n): PropertyType[] {\n const mappedRids = new Set<string>();\n for (const ds of objectTypeBlockData.datasources) {\n const def = ds.datasource;\n let propertyMapping: Record<string, PropertyTypeMappingInfo> | undefined;\n if (def.type === \"datasetV2\") {\n propertyMapping = def.datasetV2.propertyMapping;\n } else if (def.type === \"datasetV3\") {\n propertyMapping = def.datasetV3.propertyMapping;\n }\n if (propertyMapping) {\n for (const [rid, mapping] of Object.entries(propertyMapping)) {\n if (mapping.type === \"column\" || mapping.type === \"struct\") {\n mappedRids.add(rid);\n }\n }\n }\n }\n return Object.entries(objectTypeBlockData.objectType.propertyTypes)\n .filter(([rid]) => mappedRids.has(rid))\n .map(([_, prop]) => prop);\n}\n\ninterface BackingDatasetColumn {\n name: string;\n type: Type;\n}\n\n/**\n * Shared logic to generate a STATIC_DATASET BlockGeneratorResult from a list of columns.\n * Used by both object type and link type backing dataset generators.\n */\nasync function generateBackingDatasetBlock(\n datasetName: string,\n blockIdentifier: string,\n dirSuffix: string,\n columns: BackingDatasetColumn[],\n buildDir: string,\n randomnessKey?: string,\n): Promise<BlockGeneratorResult> {\n // Build output shapes\n const outputs: Record<ReadableId, OutputShape> = {} as Record<\n ReadableId,\n OutputShape\n >;\n\n const datasourceReadableId =\n ReadableIdGenerator.getForDatasetOutput(datasetName);\n const columnReadableIds: ReadableId[] = columns.map((col) =>\n ReadableIdGenerator.getForDatasetColumnOutput(datasetName, col.name),\n );\n\n const datasourceBlockInternalId = toBlockShapeId(\n datasourceReadableId,\n randomnessKey,\n );\n\n // tabularDatasource output shape\n outputs[datasourceReadableId] = {\n type: \"tabularDatasource\",\n tabularDatasource: {\n about: {\n fallbackTitle: blockIdentifier,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n schema: columnReadableIds.map((id) => toBlockShapeId(id, randomnessKey)),\n type: \"DATASET\",\n buildRequirements: { isBuildable: false },\n },\n } as OutputShape;\n\n // datasourceColumn output shapes\n for (let i = 0; i < columns.length; i++) {\n const col = columns[i];\n const colReadableId = columnReadableIds[i];\n\n outputs[colReadableId] = {\n type: \"datasourceColumn\",\n datasourceColumn: {\n about: {\n fallbackTitle: col.name,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n type: {\n type: \"concrete\",\n concrete: typeToConcreteDataType(col.type),\n },\n datasource: datasourceBlockInternalId,\n typeclasses: [],\n },\n } as OutputShape;\n }\n\n // Generate internal IDs for block-data.json columns.\n // These are distinct from the block shape IDs that appear in the manifest outputs.\n // The add-on maps these internal IDs -> block shape IDs.\n const columnInternalIds = columns.map((col) =>\n toBlockShapeId(`column-internal-${datasetName}-${col.name}`, randomnessKey),\n );\n\n const compassReadableId = `${blockIdentifier}-compass-resource` as ReadableId;\n const compassBlockShapeId = toBlockShapeId(compassReadableId, randomnessKey);\n\n const datasourceInternalId = toBlockShapeId(\n `datasource-internal-${datasetName}`,\n randomnessKey,\n );\n const locationInternalId = toBlockShapeId(\n `location-internal-${datasetName}`,\n randomnessKey,\n );\n\n const addOnOverride: Record<string, unknown> = {\n idToBlockShapeId: {\n \"dataset-internal-shape-id\": datasourceBlockInternalId,\n [datasourceInternalId]: datasourceBlockInternalId,\n [locationInternalId]: compassBlockShapeId,\n ...Object.fromEntries(\n columnInternalIds.map((internalId, i) => [\n internalId,\n toBlockShapeId(columnReadableIds[i], randomnessKey),\n ]),\n ),\n },\n idToInputGroupId: {},\n outputToLocationInput: {\n [datasourceBlockInternalId]: compassBlockShapeId,\n },\n };\n\n // Create block data directory\n const dsBlockDataDir = path.join(buildDir, `temp_block_data_${dirSuffix}`);\n await fs.promises.mkdir(dsBlockDataDir, { recursive: true });\n\n // Write schema.json\n const schemaJson = {\n fieldSchemaList: columns.map((col) =>\n typeToFieldSchema(col.type, col.name),\n ),\n primaryKey: null,\n dataFrameReaderClass:\n \"com.palantir.foundry.spark.input.ParquetDataFrameReader\",\n customMetadata: {\n format: \"parquet\",\n options: {},\n },\n };\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"schema.json\"),\n JSON.stringify(schemaJson, null, 2),\n );\n\n // Write block-data.json — column keys are the internal IDs mapped in the add-on\n const blockDataJson = {\n type: \"v1\",\n v1: {\n columns: Object.fromEntries(\n columns.map((col, i) => [columnInternalIds[i], col.name]),\n ),\n hasSchema: true,\n includeData: false,\n },\n };\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"block-data.json\"),\n JSON.stringify(blockDataJson, null, 2),\n );\n\n // Write VERSION\n await fs.promises.writeFile(path.join(dsBlockDataDir, \"VERSION\"), '\"1\"');\n\n // Write empty files.zip\n // An empty zip file is just the end-of-central-directory record (22 bytes)\n const emptyZip = Buffer.from([\n 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]);\n await fs.promises.writeFile(path.join(dsBlockDataDir, \"files.zip\"), emptyZip);\n\n // Build inputs (compassResource for install location)\n const inputs: Record<ReadableId, InputShape> = {} as Record<\n ReadableId,\n InputShape\n >;\n const input_shape_metadata: Record<ReadableId, InputShapeMetadata> =\n {} as Record<ReadableId, InputShapeMetadata>;\n inputs[compassReadableId] = {\n type: \"compassResource\",\n compassResource: {\n about: {\n fallbackTitle: blockIdentifier,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n allowedTypes: [],\n typeConstraints: [\n {\n type: \"compassFolderTypeConstraints\",\n compassFolderTypeConstraints: {\n constraints: [\"INSTALL_LOCATION\"],\n },\n },\n ],\n },\n } as InputShape;\n input_shape_metadata[compassReadableId] = {\n isOptional: true,\n reconcileAccessRequirements: \"RESOURCE_EXISTENCE_REQUIRED\",\n isAccessedInReconcile: true,\n } as InputShapeMetadata;\n\n return {\n block_identifier: blockIdentifier,\n block_data_directory: dsBlockDataDir,\n oci_block_data_metadata: undefined,\n maven_block_data_metadata: undefined,\n inputs,\n outputs,\n input_mapping_entries: [],\n external_recommendations: [],\n add_on_override: addOnOverride,\n input_shape_metadata,\n block_type: \"STATIC_DATASET\",\n };\n}\n\n/**\n * Generate a backing datasource BlockGeneratorResult for an object type.\n */\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nexport async function generateBackingDatasetBlockResult(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n buildDir: string,\n randomnessKey?: string,\n): Promise<BlockGeneratorResult> {\n const apiName = objectTypeBlockData.objectType.apiName!;\n const backingProperties = getBackingDatasetProperties(objectTypeBlockData);\n\n const columns: BackingDatasetColumn[] = backingProperties.map((prop) => ({\n name: prop.apiName!,\n type: prop.type,\n }));\n\n return generateBackingDatasetBlock(\n apiName,\n `${apiName}-backing-ds`,\n `${apiName}_backing_ds`,\n columns,\n buildDir,\n randomnessKey,\n );\n}\n\n/**\n * Generate a backing datasource BlockGeneratorResult for a many-to-many link type.\n */\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nexport async function generateBackingDatasetBlockResultForLink(\n linkTypeBlockData: LinkTypeBlockDataV2,\n linkApiName: string,\n objectTypes: Record<string, ObjectTypeBlockDataV2>,\n buildDir: string,\n randomnessKey?: string,\n): Promise<BlockGeneratorResult> {\n const definition = linkTypeBlockData.linkType.definition;\n if (definition.type !== \"manyToMany\") {\n throw new Error(\n `Link type \"${linkApiName}\" is not a many-to-many link type`,\n );\n }\n\n const m2m = definition.manyToMany;\n const datasource = linkTypeBlockData.datasources[0]?.datasource;\n if (!datasource || datasource.type !== \"dataset\") {\n throw new Error(\n `Link type \"${linkApiName}\" does not have a dataset datasource`,\n );\n }\n const ds = datasource.dataset;\n\n // Extract column names and PK RIDs from the datasource mappings\n const pkRidA = Object.keys(ds.objectTypeAPrimaryKeyMapping)[0];\n const columnA = Object.values(ds.objectTypeAPrimaryKeyMapping)[0];\n const pkRidB = Object.keys(ds.objectTypeBPrimaryKeyMapping)[0];\n const columnB = Object.values(ds.objectTypeBPrimaryKeyMapping)[0];\n\n // Resolve column types from the referenced object types\n const objectTypeA = objectTypes[m2m.objectTypeRidA];\n const objectTypeB = objectTypes[m2m.objectTypeRidB];\n if (!objectTypeA || !objectTypeB) {\n throw new Error(`Could not find object types for link \"${linkApiName}\"`);\n }\n const propTypeA = objectTypeA.objectType.propertyTypes[pkRidA]?.type;\n const propTypeB = objectTypeB.objectType.propertyTypes[pkRidB]?.type;\n if (!propTypeA || !propTypeB) {\n throw new Error(\n `Could not find primary key property types for link \"${linkApiName}\"`,\n );\n }\n\n // Dataset name must match what convertLink.ts registered with generateDatasetLocator\n return generateBackingDatasetBlock(\n `link.${linkApiName}`,\n `${linkApiName}-link-backing-ds`,\n `${linkApiName}_link_backing_ds`,\n [\n { name: columnA, type: propTypeA },\n { name: columnB, type: propTypeB },\n ],\n buildDir,\n randomnessKey,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AAejC,SAASC,sBAAsB,QAAQ,6CAA6C;AAEpF,SAASC,mBAAmB,QAAQ,wBAAwB;AAE5D,SAASC,cAAc,QAAQ,6CAA6C;;AAE5E;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,QAAmC,EAC3B;EACR,MAAMC,OAAO,GAAG,OAAOD,QAAQ,KAAK,QAAQ,GAAGA,QAAQ,GAAGA,QAAQ,CAACE,IAAI;EACvE,QAAQD,OAAO;IACb,KAAK,SAAS;IACd,KAAK,UAAU;IACf,KAAK,SAAS;IACd,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,WAAW;MACd,OAAO,WAAW;IACpB,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK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;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generateBackingDataset.js","names":["fs","path","typeToConcreteDataType","getFolderLocationInputs","ReadableIdGenerator","toBlockShapeId","propertyTypeToSchemaType","propType","typeStr","type","Error","typeToFieldSchema","name","nullable","userDefinedTypeClass","customMetadata","arraySubtype","array","subtype","float","precision","decimal","scale","mapKeyType","mapValueType","subSchemas","struct","structFields","map","f","fieldType","apiName","getBackingDatasetProperties","objectTypeBlockData","mappedRids","Set","ds","datasources","def","datasource","propertyMapping","datasetV2","datasetV3","rid","mapping","Object","entries","add","objectType","propertyTypes","filter","has","_","prop","generateBackingDatasetBlock","datasetName","blockIdentifier","dirSuffix","columns","buildDir","randomnessKey","folder","outputs","datasourceReadableId","getForDatasetOutput","columnReadableIds","col","getForDatasetColumnOutput","datasourceBlockInternalId","tabularDatasource","about","fallbackTitle","fallbackDescription","localizedTitle","localizedDescription","schema","id","buildRequirements","isBuildable","i","length","colReadableId","datasourceColumn","concrete","typeclasses","columnInternalIds","folderLocations","location","datasourceInternalId","addOnOverride","idToBlockShapeId","fromEntries","Array","from","inputShapes","keys","input","internalId","idToInputGroupId","outputToLocationInput","output","dsBlockDataDir","join","promises","mkdir","recursive","schemaJson","fieldSchemaList","primaryKey","dataFrameReaderClass","format","options","writeFile","JSON","stringify","blockDataJson","v1","hasSchema","includeData","emptyZip","Buffer","block_identifier","block_data_directory","oci_block_data_metadata","undefined","maven_block_data_metadata","inputs","input_mapping_entries","inputMappings","external_recommendations","add_on_override","input_shape_metadata","inputShapeMetadata","block_type","generateBackingDatasetBlockResult","backingProperties","generateBackingDatasetBlockResultForLink","linkTypeBlockData","linkApiName","objectTypes","definition","linkType","m2m","manyToMany","dataset","pkRidA","objectTypeAPrimaryKeyMapping","columnA","values","pkRidB","objectTypeBPrimaryKeyMapping","columnB","objectTypeA","objectTypeRidA","objectTypeB","objectTypeRidB","propTypeA","propTypeB"],"sources":["generateBackingDataset.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 * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport type {\n LinkTypeBlockDataV2,\n ObjectTypeBlockDataV2,\n PropertyType,\n PropertyTypeMappingInfo,\n Type,\n} from \"@osdk/client.unstable\";\nimport type { OutputShape } from \"@osdk/client.unstable/api\";\nimport type { Folder } from \"@osdk/maker\";\n\nimport { typeToConcreteDataType } from \"../conversion/toMarketplace/typeVisitors.js\";\nimport { getFolderLocationInputs } from \"../util/foldersUtil.js\";\nimport type { ReadableId } from \"../util/generateRid.js\";\nimport { ReadableIdGenerator } from \"../util/generateRid.js\";\nimport type {\n BlockDataAddOn,\n BlockGeneratorResult,\n} from \"./marketplaceSerialization/BlockGeneratorResult.js\";\nimport { toBlockShapeId } from \"./marketplaceSerialization/CodeBlockSpec.js\";\n\n/**\n * Map from maker property type to Foundry schema field type\n */\nexport function propertyTypeToSchemaType(\n propType: string | { type: string },\n): string {\n const typeStr = typeof propType === \"string\" ? propType : propType.type;\n switch (typeStr) {\n case \"geohash\":\n case \"geoshape\":\n case \"marking\":\n case \"string\":\n return \"STRING\";\n case \"boolean\":\n return \"BOOLEAN\";\n case \"integer\":\n return \"INTEGER\";\n case \"long\":\n return \"LONG\";\n case \"double\":\n return \"DOUBLE\";\n case \"float\":\n return \"FLOAT\";\n case \"byte\":\n return \"BYTE\";\n case \"short\":\n return \"SHORT\";\n case \"date\":\n return \"DATE\";\n case \"timestamp\":\n return \"TIMESTAMP\";\n case \"array\":\n return \"ARRAY\";\n case \"vector\":\n return \"ARRAY\";\n case \"decimal\":\n return \"DECIMAL\";\n case \"struct\":\n return \"STRUCT\";\n default:\n throw new Error(\n `Unsupported property type \"${typeStr}\" for empty backing datasource. ` +\n `If using a property type that doesn't support empty backing datasources please make the property an edit only property.`,\n );\n }\n}\n\n/**\n * A single field entry in a Foundry dataset schema.json `fieldSchemaList`.\n */\ninterface FieldSchema {\n type: string;\n name: string | null;\n nullable: boolean | null;\n userDefinedTypeClass: string | null;\n customMetadata: Record<string, unknown>;\n arraySubtype: FieldSchema | null;\n precision: number | null;\n scale: number | null;\n mapKeyType: FieldSchema | null;\n mapValueType: FieldSchema | null;\n subSchemas: FieldSchema[] | null;\n}\n\n/**\n * Build a Foundry schema field object for a column type.\n */\nexport function typeToFieldSchema(type: Type, name?: string): FieldSchema {\n return {\n type: propertyTypeToSchemaType(type),\n name: name ?? null,\n nullable: null,\n userDefinedTypeClass: null,\n customMetadata: {},\n arraySubtype:\n type.type === \"array\"\n ? typeToFieldSchema(type.array.subtype)\n : type.type === \"vector\"\n ? typeToFieldSchema({ type: \"float\", float: {} })\n : null,\n precision:\n type.type === \"decimal\" ? (type.decimal.precision ?? null) : null,\n scale: type.type === \"decimal\" ? (type.decimal.scale ?? null) : null,\n mapKeyType: null,\n mapValueType: null,\n subSchemas:\n type.type === \"struct\"\n ? type.struct.structFields.map((f) =>\n typeToFieldSchema(f.fieldType, f.apiName),\n )\n : null,\n };\n}\n\n/**\n * Select properties backed by dataset columns, excluding derived and edit-only properties.\n */\nexport function getBackingDatasetProperties(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n): PropertyType[] {\n const mappedRids = new Set<string>();\n for (const ds of objectTypeBlockData.datasources) {\n const def = ds.datasource;\n let propertyMapping: Record<string, PropertyTypeMappingInfo> | undefined;\n if (def.type === \"datasetV2\") {\n propertyMapping = def.datasetV2.propertyMapping;\n } else if (def.type === \"datasetV3\") {\n propertyMapping = def.datasetV3.propertyMapping;\n }\n if (propertyMapping) {\n for (const [rid, mapping] of Object.entries(propertyMapping)) {\n if (mapping.type === \"column\" || mapping.type === \"struct\") {\n mappedRids.add(rid);\n }\n }\n }\n }\n return Object.entries(objectTypeBlockData.objectType.propertyTypes)\n .filter(([rid]) => mappedRids.has(rid))\n .map(([_, prop]) => prop);\n}\n\ninterface BackingDatasetColumn {\n name: string;\n type: Type;\n}\n\n/**\n * Shared logic to generate a STATIC_DATASET BlockGeneratorResult from a list of columns.\n * Used by both object type and link type backing dataset generators.\n */\nasync function generateBackingDatasetBlock(\n datasetName: string,\n blockIdentifier: string,\n dirSuffix: string,\n columns: BackingDatasetColumn[],\n buildDir: string,\n randomnessKey?: string,\n folder?: Folder,\n): Promise<BlockGeneratorResult> {\n // Build output shapes\n const outputs: Record<ReadableId, OutputShape> = {} as Record<\n ReadableId,\n OutputShape\n >;\n\n const datasourceReadableId =\n ReadableIdGenerator.getForDatasetOutput(datasetName);\n const columnReadableIds: ReadableId[] = columns.map((col) =>\n ReadableIdGenerator.getForDatasetColumnOutput(datasetName, col.name),\n );\n\n const datasourceBlockInternalId = toBlockShapeId(\n datasourceReadableId,\n randomnessKey,\n );\n\n // tabularDatasource output shape\n outputs[datasourceReadableId] = {\n type: \"tabularDatasource\",\n tabularDatasource: {\n about: {\n fallbackTitle: blockIdentifier,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n schema: columnReadableIds.map((id) => toBlockShapeId(id, randomnessKey)),\n type: \"DATASET\",\n buildRequirements: { isBuildable: false },\n },\n } as OutputShape;\n\n // datasourceColumn output shapes\n for (let i = 0; i < columns.length; i++) {\n const col = columns[i];\n const colReadableId = columnReadableIds[i];\n\n outputs[colReadableId] = {\n type: \"datasourceColumn\",\n datasourceColumn: {\n about: {\n fallbackTitle: col.name,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n type: {\n type: \"concrete\",\n concrete: typeToConcreteDataType(col.type),\n },\n datasource: datasourceBlockInternalId,\n typeclasses: [],\n },\n } as OutputShape;\n }\n\n // Generate internal IDs for block-data.json columns.\n // These are distinct from the block shape IDs that appear in the manifest outputs.\n // The add-on maps these internal IDs -> block shape IDs.\n const columnInternalIds = columns.map((col) =>\n toBlockShapeId(`column-internal-${datasetName}-${col.name}`, randomnessKey),\n );\n\n const folderLocations = getFolderLocationInputs(\n { [datasourceReadableId]: folder ?? { id: \"/\", location: \"/\" } },\n [datasourceReadableId],\n );\n\n const datasourceInternalId = toBlockShapeId(\n `datasource-internal-${datasetName}`,\n randomnessKey,\n );\n const addOnOverride: BlockDataAddOn = {\n idToBlockShapeId: {\n \"dataset-internal-shape-id\": datasourceBlockInternalId,\n [datasourceInternalId]: datasourceBlockInternalId,\n ...Object.fromEntries(\n Array.from(folderLocations.inputShapes.keys(), (input) => [\n input,\n toBlockShapeId(input, randomnessKey),\n ]),\n ),\n ...Object.fromEntries(\n columnInternalIds.map((internalId, i) => [\n internalId,\n toBlockShapeId(columnReadableIds[i], randomnessKey),\n ]),\n ),\n },\n idToInputGroupId: {},\n outputToLocationInput: Object.fromEntries(\n Array.from(folderLocations.outputToLocationInput, ([output, input]) => [\n toBlockShapeId(output, randomnessKey),\n input,\n ]),\n ),\n };\n\n // Create block data directory\n const dsBlockDataDir = path.join(buildDir, `temp_block_data_${dirSuffix}`);\n await fs.promises.mkdir(dsBlockDataDir, { recursive: true });\n\n // Write schema.json\n const schemaJson = {\n fieldSchemaList: columns.map((col) =>\n typeToFieldSchema(col.type, col.name),\n ),\n primaryKey: null,\n dataFrameReaderClass:\n \"com.palantir.foundry.spark.input.ParquetDataFrameReader\",\n customMetadata: {\n format: \"parquet\",\n options: {},\n },\n };\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"schema.json\"),\n JSON.stringify(schemaJson, null, 2),\n );\n\n // Write block-data.json — column keys are the internal IDs mapped in the add-on\n const blockDataJson = {\n type: \"v1\",\n v1: {\n columns: Object.fromEntries(\n columns.map((col, i) => [columnInternalIds[i], col.name]),\n ),\n hasSchema: true,\n includeData: false,\n },\n };\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"block-data.json\"),\n JSON.stringify(blockDataJson, null, 2),\n );\n\n // Write VERSION\n await fs.promises.writeFile(path.join(dsBlockDataDir, \"VERSION\"), '\"1\"');\n\n // Write empty files.zip\n // An empty zip file is just the end-of-central-directory record (22 bytes)\n const emptyZip = Buffer.from([\n 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n ]);\n await fs.promises.writeFile(path.join(dsBlockDataDir, \"files.zip\"), emptyZip);\n\n return {\n block_identifier: blockIdentifier,\n block_data_directory: dsBlockDataDir,\n oci_block_data_metadata: undefined,\n maven_block_data_metadata: undefined,\n inputs: Object.fromEntries(folderLocations.inputShapes),\n outputs,\n input_mapping_entries: folderLocations.inputMappings,\n external_recommendations: [],\n add_on_override: addOnOverride,\n input_shape_metadata: Object.fromEntries(\n folderLocations.inputShapeMetadata,\n ),\n block_type: \"STATIC_DATASET\",\n };\n}\n\n/**\n * Generate a backing datasource BlockGeneratorResult for an object type.\n */\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nexport async function generateBackingDatasetBlockResult(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n buildDir: string,\n randomnessKey?: string,\n folder?: Folder,\n): Promise<BlockGeneratorResult> {\n const apiName = objectTypeBlockData.objectType.apiName!;\n const backingProperties = getBackingDatasetProperties(objectTypeBlockData);\n\n const columns: BackingDatasetColumn[] = backingProperties.map((prop) => ({\n name: prop.apiName!,\n type: prop.type,\n }));\n\n return generateBackingDatasetBlock(\n apiName,\n `${apiName}-backing-ds`,\n `${apiName}_backing_ds`,\n columns,\n buildDir,\n randomnessKey,\n folder,\n );\n}\n\n/**\n * Generate a backing datasource BlockGeneratorResult for a many-to-many link type.\n */\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nexport async function generateBackingDatasetBlockResultForLink(\n linkTypeBlockData: LinkTypeBlockDataV2,\n linkApiName: string,\n objectTypes: Record<string, ObjectTypeBlockDataV2>,\n buildDir: string,\n randomnessKey?: string,\n folder?: Folder,\n): Promise<BlockGeneratorResult> {\n const definition = linkTypeBlockData.linkType.definition;\n if (definition.type !== \"manyToMany\") {\n throw new Error(\n `Link type \"${linkApiName}\" is not a many-to-many link type`,\n );\n }\n\n const m2m = definition.manyToMany;\n const datasource = linkTypeBlockData.datasources[0]?.datasource;\n if (!datasource || datasource.type !== \"dataset\") {\n throw new Error(\n `Link type \"${linkApiName}\" does not have a dataset datasource`,\n );\n }\n const ds = datasource.dataset;\n\n // Extract column names and PK RIDs from the datasource mappings\n const pkRidA = Object.keys(ds.objectTypeAPrimaryKeyMapping)[0];\n const columnA = Object.values(ds.objectTypeAPrimaryKeyMapping)[0];\n const pkRidB = Object.keys(ds.objectTypeBPrimaryKeyMapping)[0];\n const columnB = Object.values(ds.objectTypeBPrimaryKeyMapping)[0];\n\n // Resolve column types from the referenced object types\n const objectTypeA = objectTypes[m2m.objectTypeRidA];\n const objectTypeB = objectTypes[m2m.objectTypeRidB];\n if (!objectTypeA || !objectTypeB) {\n throw new Error(`Could not find object types for link \"${linkApiName}\"`);\n }\n const propTypeA = objectTypeA.objectType.propertyTypes[pkRidA]?.type;\n const propTypeB = objectTypeB.objectType.propertyTypes[pkRidB]?.type;\n if (!propTypeA || !propTypeB) {\n throw new Error(\n `Could not find primary key property types for link \"${linkApiName}\"`,\n );\n }\n\n // Dataset name must match what convertLink.ts registered with generateDatasetLocator\n return generateBackingDatasetBlock(\n `link.${linkApiName}`,\n `${linkApiName}-link-backing-ds`,\n `${linkApiName}_link_backing_ds`,\n [\n { name: columnA, type: propTypeA },\n { name: columnB, type: propTypeB },\n ],\n buildDir,\n randomnessKey,\n folder,\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AAYjC,SAASC,sBAAsB,QAAQ,6CAA6C;AACpF,SAASC,uBAAuB,QAAQ,wBAAwB;AAEhE,SAASC,mBAAmB,QAAQ,wBAAwB;AAK5D,SAASC,cAAc,QAAQ,6CAA6C;;AAE5E;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,QAAmC,EAC3B;EACR,MAAMC,OAAO,GAAG,OAAOD,QAAQ,KAAK,QAAQ,GAAGA,QAAQ,GAAGA,QAAQ,CAACE,IAAI;EACvE,QAAQD,OAAO;IACb,KAAK,SAAS;IACd,KAAK,UAAU;IACf,KAAK,SAAS;IACd,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,MAAM;MACT,OAAO,MAAM;IACf,KAAK,WAAW;MACd,OAAO,WAAW;IACpB,KAAK,OAAO;MACV,OAAO,OAAO;IAChB,KAAK,QAAQ;MACX,OAAO,OAAO;IAChB,KAAK,SAAS;MACZ,OAAO,SAAS;IAClB,KAAK,QAAQ;MACX,OAAO,QAAQ;IACjB;MACE,MAAM,IAAIE,KAAK,CACb,8BAA8BF,OAAO,kCAAkC,GACrE,yHACJ,CAAC;EACL;AACF;;AAEA;AACA;AACA;;AAeA;AACA;AACA;AAC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A4B,CAAC,CAAC,CAAC,CAAC;;EAEjE;EACA,MAAME,WAAW,GAAGb,WAAW,CAACG,GAAG,CAACW,cAAc,CAAC;EACnD,MAAMC,WAAW,GAAGf,WAAW,CAACG,GAAG,CAACa,cAAc,CAAC;EACnD,IAAI,CAACH,WAAW,IAAI,CAACE,WAAW,EAAE;IAChC,MAAM,IAAIhJ,KAAK,CAAC,yCAAyCgI,WAAW,GAAG,CAAC;EAC1E;EACA,MAAMkB,SAAS,GAAGJ,WAAW,CAACxG,UAAU,CAACC,aAAa,CAACgG,MAAM,CAAC,EAAExI,IAAI;EACpE,MAAMoJ,SAAS,GAAGH,WAAW,CAAC1G,UAAU,CAACC,aAAa,CAACoG,MAAM,CAAC,EAAE5I,IAAI;EACpE,IAAI,CAACmJ,SAAS,IAAI,CAACC,SAAS,EAAE;IAC5B,MAAM,IAAInJ,KAAK,CACb,uDAAuDgI,WAAW,GACpE,CAAC;EACH;;EAEA;EACA,OAAOpF,2BAA2B,CAChC,QAAQoF,WAAW,EAAE,EACrB,GAAGA,WAAW,kBAAkB,EAChC,GAAGA,WAAW,kBAAkB,EAChC,CACE;IAAE9H,IAAI,EAAEuI,OAAO;IAAE1I,IAAI,EAAEmJ;EAAU,CAAC,EAClC;IAAEhJ,IAAI,EAAE2I,OAAO;IAAE9I,IAAI,EAAEoJ;EAAU,CAAC,CACnC,EACDlG,QAAQ,EACRC,aAAa,EACbC,MACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -26,6 +26,7 @@ import yargs from "yargs";
|
|
|
26
26
|
import { hideBin } from "yargs/helpers";
|
|
27
27
|
import { defineOntologyV2 } from "../api/defineOntologyV2.js";
|
|
28
28
|
import { getExternalRecommendations } from "../conversion/toMarketplace/RecommendationUtils.js";
|
|
29
|
+
import { generateFolderBlockResults } from "../util/foldersUtil.js";
|
|
29
30
|
import { ReadableIdGenerator } from "../util/generateRid.js";
|
|
30
31
|
import { generateBackingDatasetBlockResult, generateBackingDatasetBlockResultForLink, getBackingDatasetProperties } from "./generateBackingDataset.js";
|
|
31
32
|
import { generateBackingMediaSetBlockResult } from "./generateBackingMediaSet.js";
|
|
@@ -35,7 +36,7 @@ const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/u;
|
|
|
35
36
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
36
37
|
export default async function main(args = process.argv) {
|
|
37
38
|
consola.log("Generating BlockGeneratorResult for ontology...");
|
|
38
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.78.
|
|
39
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.78.1-main-6df3c1ebcd2e692ca80dc7bd648f63a007c9e72c" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
39
40
|
input: {
|
|
40
41
|
alias: "i",
|
|
41
42
|
describe: "Input file",
|
|
@@ -194,7 +195,8 @@ export default async function main(args = process.argv) {
|
|
|
194
195
|
importedInputPresets,
|
|
195
196
|
backingDatasourceApiNames,
|
|
196
197
|
backingDatasourceLinkApiNames,
|
|
197
|
-
backingMediaSetNames
|
|
198
|
+
backingMediaSetNames,
|
|
199
|
+
outputFolders
|
|
198
200
|
} = await loadOntology(commandLineOpts.input, apiNamespace, codegenDir, dependencyFile, functionsIrFile, commandLineOpts.randomnessKey, importedLinkTypeIdsByApiName, externalImportedMetadata, {
|
|
199
201
|
targetEnvironment: commandLineOpts.targetEnvironment
|
|
200
202
|
},
|
|
@@ -230,6 +232,7 @@ export default async function main(args = process.argv) {
|
|
|
230
232
|
directlyImportedInterfaceTypes
|
|
231
233
|
}, null, 2));
|
|
232
234
|
consola.info(`Wrote oac-imported-metadata.json to ${importedMetadataPath}`);
|
|
235
|
+
const folderResults = await generateFolderBlockResults(outputFolders, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
233
236
|
let valueTypeResults = [];
|
|
234
237
|
if (ontologyIr.valueTypes.length > 0) {
|
|
235
238
|
valueTypeResults = await generateValueTypeBlockResults(ontologyIr.valueTypes, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
@@ -319,7 +322,7 @@ export default async function main(args = process.argv) {
|
|
|
319
322
|
}).map(async apiName => {
|
|
320
323
|
const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
|
|
321
324
|
consola.info(`Generating backing datasource BlockGeneratorResult for ${apiName}...`);
|
|
322
|
-
return await generateBackingDatasetBlockResult(objectTypeBlockData, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
325
|
+
return await generateBackingDatasetBlockResult(objectTypeBlockData, commandLineOpts.buildDir, commandLineOpts.randomnessKey, outputFolders[ReadableIdGenerator.getForObjectType(apiName)]);
|
|
323
326
|
}));
|
|
324
327
|
|
|
325
328
|
// Generate backing datasource BlockGeneratorResults for link types with includeEmptyBackingDatasource
|
|
@@ -327,7 +330,7 @@ export default async function main(args = process.argv) {
|
|
|
327
330
|
const linkTypeBlockData = findLinkTypeByApiName(ontologyIr.ontology.linkTypes, linkApiName);
|
|
328
331
|
if (!linkTypeBlockData) return undefined;
|
|
329
332
|
consola.info(`Generating backing datasource BlockGeneratorResult for link ${linkApiName}...`);
|
|
330
|
-
return generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, ontologyIr.ontology.objectTypes, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
333
|
+
return generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, ontologyIr.ontology.objectTypes, commandLineOpts.buildDir, commandLineOpts.randomnessKey, outputFolders[ReadableIdGenerator.getForLinkType(cleanAndValidateLinkTypeId(linkApiName))]);
|
|
331
334
|
}).filter(p => p !== undefined));
|
|
332
335
|
const backingMediaSetGeneratorResults = await Promise.all(backingMediaSetNames.map(mediaSetName => {
|
|
333
336
|
consola.info(`Generating backing Media Set BlockGeneratorResult for ${mediaSetName}...`);
|
|
@@ -351,7 +354,7 @@ export default async function main(args = process.argv) {
|
|
|
351
354
|
};
|
|
352
355
|
|
|
353
356
|
// Write BlockGeneratorResult to output file
|
|
354
|
-
const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...directDatasourceGeneratorResults, ...backingDsGeneratorResults, ...backingDsLinkGeneratorResults, ...backingMediaSetGeneratorResults, ...valueTypeResults], null, 2);
|
|
357
|
+
const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...folderResults, ...directDatasourceGeneratorResults, ...backingDsGeneratorResults, ...backingDsLinkGeneratorResults, ...backingMediaSetGeneratorResults, ...valueTypeResults], null, 2);
|
|
355
358
|
await fs.promises.writeFile(commandLineOpts.output, blockGeneratorResultJson);
|
|
356
359
|
consola.success(`BlockGeneratorResult written to ${commandLineOpts.output}`);
|
|
357
360
|
consola.info(`Block data directory: ${blockDataDir}`);
|