@osdk/maker-experimental 0.6.0-beta.9 → 0.6.0
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 +61 -0
- package/build/browser/api/defineOntologyV2.js +6 -1
- package/build/browser/api/defineOntologyV2.js.map +1 -1
- package/build/browser/cli/generateBackingDataset.js +82 -36
- package/build/browser/cli/generateBackingDataset.js.map +1 -1
- package/build/browser/cli/main.js +55 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/cjs/index.cjs +109 -31
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -0
- package/build/esm/api/defineOntologyV2.js +6 -1
- package/build/esm/api/defineOntologyV2.js.map +1 -1
- package/build/esm/cli/generateBackingDataset.js +82 -36
- package/build/esm/cli/generateBackingDataset.js.map +1 -1
- package/build/esm/cli/main.js +55 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/types/api/defineOntologyV2.d.ts +1 -0
- package/build/types/api/defineOntologyV2.d.ts.map +1 -1
- package/build/types/cli/generateBackingDataset.d.ts +5 -1
- package/build/types/cli/generateBackingDataset.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @osdk/maker-experimental
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 425cb92: Simulated release
|
|
8
|
+
- f487a6a: Maker experimental
|
|
9
|
+
- e462938: Support PSGs in OAC
|
|
10
|
+
- a73bafd: Fix link type block data gen
|
|
11
|
+
- fd3f6d3: Add support for empty backing datasources
|
|
12
|
+
- 9ee82f4: Dedupe many-to-many PK property names in datasource
|
|
13
|
+
- 771e3e6: Update datasource generation
|
|
14
|
+
- 764fe55: Support multi block-generation-result outputs.
|
|
15
|
+
- e8ca289: Fix key resolution
|
|
16
|
+
- 35f2f1a: Add Media inputs/outputs for Queries
|
|
17
|
+
- 4ec5877: Fix link dataset shapes
|
|
18
|
+
- eac64f4: Link backing dataset generation
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [322c5bc]
|
|
23
|
+
- Updated dependencies [322c5bc]
|
|
24
|
+
- Updated dependencies [322c5bc]
|
|
25
|
+
- Updated dependencies [cc7f505]
|
|
26
|
+
- Updated dependencies [4bb9769]
|
|
27
|
+
- Updated dependencies [8f92197]
|
|
28
|
+
- Updated dependencies [f294f5a]
|
|
29
|
+
- Updated dependencies [963626f]
|
|
30
|
+
- Updated dependencies [f487a6a]
|
|
31
|
+
- Updated dependencies [e462938]
|
|
32
|
+
- Updated dependencies [6499ff9]
|
|
33
|
+
- Updated dependencies [0e45a37]
|
|
34
|
+
- Updated dependencies [fcf81ba]
|
|
35
|
+
- Updated dependencies [ab50d31]
|
|
36
|
+
- Updated dependencies [034081a]
|
|
37
|
+
- Updated dependencies [77aa4a9]
|
|
38
|
+
- Updated dependencies [fd3f6d3]
|
|
39
|
+
- Updated dependencies [9ee82f4]
|
|
40
|
+
- Updated dependencies [0df859a]
|
|
41
|
+
- Updated dependencies [5b938ef]
|
|
42
|
+
- Updated dependencies [d284bf2]
|
|
43
|
+
- Updated dependencies [4ef6adc]
|
|
44
|
+
- Updated dependencies [60b5ffb]
|
|
45
|
+
- Updated dependencies [7fa6de3]
|
|
46
|
+
- Updated dependencies [2b15836]
|
|
47
|
+
- Updated dependencies [684b6c6]
|
|
48
|
+
- Updated dependencies [8c30908]
|
|
49
|
+
- Updated dependencies [acb4ed6]
|
|
50
|
+
- Updated dependencies [e8ca289]
|
|
51
|
+
- Updated dependencies [4a856cb]
|
|
52
|
+
- Updated dependencies [b68cebd]
|
|
53
|
+
- Updated dependencies [35f2f1a]
|
|
54
|
+
- Updated dependencies [e0ba9eb]
|
|
55
|
+
- Updated dependencies [972bda6]
|
|
56
|
+
- Updated dependencies [6941b4f]
|
|
57
|
+
- Updated dependencies [e9f9f58]
|
|
58
|
+
- Updated dependencies [eac64f4]
|
|
59
|
+
- Updated dependencies [61e33ab]
|
|
60
|
+
- @osdk/api@2.8.0
|
|
61
|
+
- @osdk/client.unstable@2.8.0
|
|
62
|
+
- @osdk/maker@0.16.0
|
|
63
|
+
|
|
3
64
|
## 0.6.0-beta.9
|
|
4
65
|
|
|
5
66
|
### Minor Changes
|
|
@@ -32,10 +32,15 @@ export async function defineOntologyV2(ns, body, randomnessKey) {
|
|
|
32
32
|
const ontDef = convertOntologyDefinition(ontologyDefinition, ridGenerator, randomnessKey);
|
|
33
33
|
const shapes = await getShapes(ontDef.ontology, ridGenerator, randomnessKey);
|
|
34
34
|
const backingDatasourceApiNames = Object.entries(ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE]).filter(([_, obj]) => obj.includeEmptyBackingDatasource === true).map(([apiName]) => apiName);
|
|
35
|
+
const backingDatasourceLinkApiNames = Object.entries(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE]).filter(([_, link]) => {
|
|
36
|
+
const lt = link;
|
|
37
|
+
return "many" in lt && !("intermediaryObjectType" in lt) && lt.includeEmptyBackingDatasource === true;
|
|
38
|
+
}).map(([apiName]) => apiName);
|
|
35
39
|
return {
|
|
36
40
|
ontologyIr: ontDef,
|
|
37
41
|
shapes,
|
|
38
|
-
backingDatasourceApiNames
|
|
42
|
+
backingDatasourceApiNames,
|
|
43
|
+
backingDatasourceLinkApiNames
|
|
39
44
|
};
|
|
40
45
|
}
|
|
41
46
|
//# sourceMappingURL=defineOntologyV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineOntologyV2.js","names":["getOntologyDefinition","initializeOntologyState","OntologyEntityTypeEnum","convertOntologyDefinition","getShapes","OntologyRidGeneratorImpl","defineOntologyV2","ns","body","randomnessKey","e","console","error","ontologyDefinition","ridGenerator","ontDef","shapes","ontology","backingDatasourceApiNames","Object","entries","OBJECT_TYPE","filter","_","obj","includeEmptyBackingDatasource","map","apiName","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 { ObjectType } from \"@osdk/maker\";\nimport {\n getOntologyDefinition,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n} from \"@osdk/maker\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.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}\n\nexport async function defineOntologyV2(\n ns: string,\n body: () => void | Promise<void>,\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 const ridGenerator = new OntologyRidGeneratorImpl(randomnessKey);\n const ontDef = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n randomnessKey,\n );\n\n const shapes = await getShapes(\n ontDef.ontology,\n ridGenerator,\n randomnessKey,\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 return { ontologyIr: ontDef
|
|
1
|
+
{"version":3,"file":"defineOntologyV2.js","names":["getOntologyDefinition","initializeOntologyState","OntologyEntityTypeEnum","convertOntologyDefinition","getShapes","OntologyRidGeneratorImpl","defineOntologyV2","ns","body","randomnessKey","e","console","error","ontologyDefinition","ridGenerator","ontDef","shapes","ontology","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 { LinkType, ObjectType } from \"@osdk/maker\";\nimport {\n getOntologyDefinition,\n initializeOntologyState,\n OntologyEntityTypeEnum,\n} from \"@osdk/maker\";\nimport { convertOntologyDefinition } from \"../conversion/toMarketplace/convertOntologyDefinition.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 async function defineOntologyV2(\n ns: string,\n body: () => void | Promise<void>,\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 const ridGenerator = new OntologyRidGeneratorImpl(randomnessKey);\n const ontDef = convertOntologyDefinition(\n ontologyDefinition,\n ridGenerator,\n randomnessKey,\n );\n\n const shapes = await getShapes(\n ontDef.ontology,\n ridGenerator,\n randomnessKey,\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;;AAIA,SACEA,qBAAqB,EACrBC,uBAAuB,EACvBC,sBAAsB,QACjB,aAAa;AACpB,SAASC,yBAAyB,QAAQ,0DAA0D;AACpG,SAASC,SAAS,QAAQ,iEAAiE;AAE3F,SAASC,wBAAwB,QAAQ,wBAAwB;AASjE,OAAO,eAAeC,gBAAgBA,CACpCC,EAAU,EACVC,IAAgC,EAChCC,aAAsB,EACK;EAC3BR,uBAAuB,CAACM,EAAE,CAAC;EAE3B,IAAI;IACF,MAAMC,IAAI,CAAC,CAAC;EACd,CAAC,CAAC,OAAOE,CAAC,EAAE;IACV;IACAC,OAAO,CAACC,KAAK,CACX,4DAA4D,EAC5DF,CACF,CAAC;IACD,MAAMA,CAAC;EACT;EAEA,MAAMG,kBAAkB,GAAGb,qBAAqB,CAAC,CAAC;EAElD,MAAMc,YAAY,GAAG,IAAIT,wBAAwB,CAACI,aAAa,CAAC;EAChE,MAAMM,MAAM,GAAGZ,yBAAyB,CACtCU,kBAAkB,EAClBC,YAAY,EACZL,aACF,CAAC;EAED,MAAMO,MAAM,GAAG,MAAMZ,SAAS,CAC5BW,MAAM,CAACE,QAAQ,EACfH,YAAY,EACZL,aACF,CAAC;EAED,MAAMS,yBAAyB,GAAGC,MAAM,CAACC,OAAO,CAC9CP,kBAAkB,CAACX,sBAAsB,CAACmB,WAAW,CACvD,CAAC,CACEC,MAAM,CAAC,CAAC,CAACC,CAAC,EAAEC,GAAG,CAAC,KACdA,GAAG,CAAgBC,6BAA6B,KAAK,IACxD,CAAC,CACAC,GAAG,CAAC,CAAC,CAACC,OAAO,CAAC,KAAKA,OAAO,CAAC;EAE9B,MAAMC,6BAA6B,GAAGT,MAAM,CAACC,OAAO,CAClDP,kBAAkB,CAACX,sBAAsB,CAAC2B,SAAS,CACrD,CAAC,CACEP,MAAM,CAAC,CAAC,CAACC,CAAC,EAAEO,IAAI,CAAC,KAAK;IACrB,MAAMC,EAAE,GAAGD,IAAgB;IAC3B,OAAO,MAAM,IAAIC,EAAE,IACd,EAAE,wBAAwB,IAAIA,EAAE,CAAC,IAChCA,EAAE,CACDN,6BAA6B,KAAK,IAAI;EAC/C,CAAC,CAAC,CACDC,GAAG,CAAC,CAAC,CAACC,OAAO,CAAC,KAAKA,OAAO,CAAC;EAE9B,OAAO;IACLK,UAAU,EAAEjB,MAAM;IAClBC,MAAM;IACNE,yBAAyB;IACzBU;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -82,33 +82,23 @@ export function getNonEditOnlyProperties(objectTypeBlockData) {
|
|
|
82
82
|
const editOnlyRids = getEditOnlyPropertyRids(objectTypeBlockData.datasources);
|
|
83
83
|
return Object.entries(objectTypeBlockData.objectType.propertyTypes).filter(([rid]) => !editOnlyRids.has(rid)).map(([_, prop]) => prop);
|
|
84
84
|
}
|
|
85
|
-
|
|
86
85
|
/**
|
|
87
|
-
*
|
|
86
|
+
* Shared logic to generate a STATIC_DATASET BlockGeneratorResult from a list of columns.
|
|
87
|
+
* Used by both object type and link type backing dataset generators.
|
|
88
88
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
|
|
92
|
-
const dsName = `${apiName}-backing-ds`;
|
|
93
|
-
|
|
94
|
-
// Build output shapes for the dataset block
|
|
89
|
+
async function generateBackingDatasetBlock(datasetName, blockIdentifier, dirSuffix, columns, buildDir, randomnessKey) {
|
|
90
|
+
// Build output shapes
|
|
95
91
|
const outputs = {};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
92
|
+
const datasourceReadableId = ReadableIdGenerator.getForDatasetOutput(datasetName);
|
|
93
|
+
const columnReadableIds = columns.map(col => ReadableIdGenerator.getForDatasetColumnOutput(datasetName, col.name));
|
|
94
|
+
const datasourceBlockInternalId = toBlockShapeId(datasourceReadableId, randomnessKey);
|
|
99
95
|
|
|
100
96
|
// tabularDatasource output shape
|
|
101
|
-
const columnReadableIds = [];
|
|
102
|
-
for (const prop of nonEditOnlyProps) {
|
|
103
|
-
const colReadableId = ReadableIdGenerator.getForDatasetColumnOutput(apiName, prop.apiName);
|
|
104
|
-
columnReadableIds.push(colReadableId);
|
|
105
|
-
}
|
|
106
|
-
const datasourceBlockInternalId = toBlockShapeId(datasourceReadableId, randomnessKey);
|
|
107
97
|
outputs[datasourceReadableId] = {
|
|
108
98
|
type: "tabularDatasource",
|
|
109
99
|
tabularDatasource: {
|
|
110
100
|
about: {
|
|
111
|
-
fallbackTitle:
|
|
101
|
+
fallbackTitle: blockIdentifier,
|
|
112
102
|
fallbackDescription: "",
|
|
113
103
|
localizedTitle: {},
|
|
114
104
|
localizedDescription: {}
|
|
@@ -121,22 +111,22 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
121
111
|
}
|
|
122
112
|
};
|
|
123
113
|
|
|
124
|
-
// datasourceColumn output shapes
|
|
125
|
-
for (let i = 0; i <
|
|
126
|
-
const
|
|
114
|
+
// datasourceColumn output shapes
|
|
115
|
+
for (let i = 0; i < columns.length; i++) {
|
|
116
|
+
const col = columns[i];
|
|
127
117
|
const colReadableId = columnReadableIds[i];
|
|
128
118
|
outputs[colReadableId] = {
|
|
129
119
|
type: "datasourceColumn",
|
|
130
120
|
datasourceColumn: {
|
|
131
121
|
about: {
|
|
132
|
-
fallbackTitle:
|
|
122
|
+
fallbackTitle: col.name,
|
|
133
123
|
fallbackDescription: "",
|
|
134
124
|
localizedTitle: {},
|
|
135
125
|
localizedDescription: {}
|
|
136
126
|
},
|
|
137
127
|
type: {
|
|
138
128
|
type: "concrete",
|
|
139
|
-
concrete: typeToConcreteDataType(
|
|
129
|
+
concrete: typeToConcreteDataType(col.type)
|
|
140
130
|
},
|
|
141
131
|
datasource: datasourceBlockInternalId,
|
|
142
132
|
typeclasses: []
|
|
@@ -147,11 +137,11 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
147
137
|
// Generate internal IDs for block-data.json columns.
|
|
148
138
|
// These are distinct from the block shape IDs that appear in the manifest outputs.
|
|
149
139
|
// The add-on maps these internal IDs -> block shape IDs.
|
|
150
|
-
const columnInternalIds =
|
|
151
|
-
const compassReadableId = `${
|
|
140
|
+
const columnInternalIds = columns.map(col => toBlockShapeId(`column-internal-${datasetName}-${col.name}`, randomnessKey));
|
|
141
|
+
const compassReadableId = `${blockIdentifier}-compass-resource`;
|
|
152
142
|
const compassBlockShapeId = toBlockShapeId(compassReadableId, randomnessKey);
|
|
153
|
-
const datasourceInternalId = toBlockShapeId(`datasource-internal-${
|
|
154
|
-
const locationInternalId = toBlockShapeId(`location-internal-${
|
|
143
|
+
const datasourceInternalId = toBlockShapeId(`datasource-internal-${datasetName}`, randomnessKey);
|
|
144
|
+
const locationInternalId = toBlockShapeId(`location-internal-${datasetName}`, randomnessKey);
|
|
155
145
|
const addOnOverride = {
|
|
156
146
|
idToBlockShapeId: {
|
|
157
147
|
"dataset-internal-shape-id": datasourceBlockInternalId,
|
|
@@ -166,16 +156,16 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
166
156
|
};
|
|
167
157
|
|
|
168
158
|
// Create block data directory
|
|
169
|
-
const dsBlockDataDir = path.join(buildDir, `temp_block_data_${
|
|
159
|
+
const dsBlockDataDir = path.join(buildDir, `temp_block_data_${dirSuffix}`);
|
|
170
160
|
await fs.promises.mkdir(dsBlockDataDir, {
|
|
171
161
|
recursive: true
|
|
172
162
|
});
|
|
173
163
|
|
|
174
164
|
// Write schema.json
|
|
175
165
|
const schemaJson = {
|
|
176
|
-
fieldSchemaList:
|
|
177
|
-
type: propertyTypeToSchemaType(
|
|
178
|
-
name:
|
|
166
|
+
fieldSchemaList: columns.map(col => ({
|
|
167
|
+
type: propertyTypeToSchemaType(col.type),
|
|
168
|
+
name: col.name,
|
|
179
169
|
nullable: null,
|
|
180
170
|
userDefinedTypeClass: null,
|
|
181
171
|
customMetadata: {},
|
|
@@ -199,7 +189,7 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
199
189
|
const blockDataJson = {
|
|
200
190
|
type: "v1",
|
|
201
191
|
v1: {
|
|
202
|
-
columns: Object.fromEntries(
|
|
192
|
+
columns: Object.fromEntries(columns.map((col, i) => [columnInternalIds[i], col.name])),
|
|
203
193
|
hasSchema: true
|
|
204
194
|
}
|
|
205
195
|
};
|
|
@@ -219,7 +209,7 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
219
209
|
type: "compassResource",
|
|
220
210
|
compassResource: {
|
|
221
211
|
about: {
|
|
222
|
-
fallbackTitle:
|
|
212
|
+
fallbackTitle: blockIdentifier,
|
|
223
213
|
fallbackDescription: "",
|
|
224
214
|
localizedTitle: {},
|
|
225
215
|
localizedDescription: {}
|
|
@@ -234,12 +224,12 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
234
224
|
}
|
|
235
225
|
};
|
|
236
226
|
return {
|
|
237
|
-
block_identifier:
|
|
227
|
+
block_identifier: blockIdentifier,
|
|
238
228
|
block_data_directory: dsBlockDataDir,
|
|
239
229
|
oci_block_data_metadata: undefined,
|
|
240
230
|
maven_block_data_metadata: undefined,
|
|
241
|
-
inputs
|
|
242
|
-
outputs
|
|
231
|
+
inputs,
|
|
232
|
+
outputs,
|
|
243
233
|
input_mapping_entries: [],
|
|
244
234
|
external_recommendations: [],
|
|
245
235
|
add_on_override: addOnOverride,
|
|
@@ -247,4 +237,60 @@ export async function generateBackingDatasetBlockResult(objectTypeBlockData, bui
|
|
|
247
237
|
block_type: "STATIC_DATASET"
|
|
248
238
|
};
|
|
249
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Generate a backing datasource BlockGeneratorResult for an object type.
|
|
243
|
+
*/
|
|
244
|
+
export async function generateBackingDatasetBlockResult(objectTypeBlockData, buildDir, randomnessKey) {
|
|
245
|
+
const apiName = objectTypeBlockData.objectType.apiName;
|
|
246
|
+
const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
|
|
247
|
+
const columns = nonEditOnlyProps.map(prop => ({
|
|
248
|
+
name: prop.apiName,
|
|
249
|
+
type: prop.type
|
|
250
|
+
}));
|
|
251
|
+
return generateBackingDatasetBlock(apiName, `${apiName}-backing-ds`, `${apiName}_backing_ds`, columns, buildDir, randomnessKey);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Generate a backing datasource BlockGeneratorResult for a many-to-many link type.
|
|
256
|
+
*/
|
|
257
|
+
export async function generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, objectTypes, buildDir, randomnessKey) {
|
|
258
|
+
const definition = linkTypeBlockData.linkType.definition;
|
|
259
|
+
if (definition.type !== "manyToMany") {
|
|
260
|
+
throw new Error(`Link type "${linkApiName}" is not a many-to-many link type`);
|
|
261
|
+
}
|
|
262
|
+
const m2m = definition.manyToMany;
|
|
263
|
+
const datasource = linkTypeBlockData.datasources[0]?.datasource;
|
|
264
|
+
if (!datasource || datasource.type !== "dataset") {
|
|
265
|
+
throw new Error(`Link type "${linkApiName}" does not have a dataset datasource`);
|
|
266
|
+
}
|
|
267
|
+
const ds = datasource.dataset;
|
|
268
|
+
|
|
269
|
+
// Extract column names and PK RIDs from the datasource mappings
|
|
270
|
+
const pkRidA = Object.keys(ds.objectTypeAPrimaryKeyMapping)[0];
|
|
271
|
+
const columnA = Object.values(ds.objectTypeAPrimaryKeyMapping)[0];
|
|
272
|
+
const pkRidB = Object.keys(ds.objectTypeBPrimaryKeyMapping)[0];
|
|
273
|
+
const columnB = Object.values(ds.objectTypeBPrimaryKeyMapping)[0];
|
|
274
|
+
|
|
275
|
+
// Resolve column types from the referenced object types
|
|
276
|
+
const objectTypeA = objectTypes[m2m.objectTypeRidA];
|
|
277
|
+
const objectTypeB = objectTypes[m2m.objectTypeRidB];
|
|
278
|
+
if (!objectTypeA || !objectTypeB) {
|
|
279
|
+
throw new Error(`Could not find object types for link "${linkApiName}"`);
|
|
280
|
+
}
|
|
281
|
+
const propTypeA = objectTypeA.objectType.propertyTypes[pkRidA]?.type;
|
|
282
|
+
const propTypeB = objectTypeB.objectType.propertyTypes[pkRidB]?.type;
|
|
283
|
+
if (!propTypeA || !propTypeB) {
|
|
284
|
+
throw new Error(`Could not find primary key property types for link "${linkApiName}"`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Dataset name must match what convertLink.ts registered with generateDatasetLocator
|
|
288
|
+
return generateBackingDatasetBlock(`link.${linkApiName}`, `${linkApiName}-link-backing-ds`, `${linkApiName}_link_backing_ds`, [{
|
|
289
|
+
name: columnA,
|
|
290
|
+
type: propTypeA
|
|
291
|
+
}, {
|
|
292
|
+
name: columnB,
|
|
293
|
+
type: propTypeB
|
|
294
|
+
}], buildDir, randomnessKey);
|
|
295
|
+
}
|
|
250
296
|
//# sourceMappingURL=generateBackingDataset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateBackingDataset.js","names":["fs","path","typeToConcreteDataType","ReadableIdGenerator","toBlockShapeId","propertyTypeToSchemaType","propType","typeStr","type","Error","getEditOnlyPropertyRids","datasources","editOnlyRids","Set","ds","def","datasource","propertyMapping","datasetV2","datasetV3","rid","mapping","Object","entries","add","getNonEditOnlyProperties","objectTypeBlockData","objectType","propertyTypes","filter","has","map","_","prop","generateBackingDatasetBlockResult","buildDir","randomnessKey","apiName","nonEditOnlyProps","dsName","outputs","datasourceReadableId","getForDatasetOutput","columnReadableIds","colReadableId","getForDatasetColumnOutput","push","datasourceBlockInternalId","tabularDatasource","about","fallbackTitle","fallbackDescription","localizedTitle","localizedDescription","schema","id","buildRequirements","isBuildable","i","length","datasourceColumn","concrete","typeclasses","columnInternalIds","compassReadableId","compassBlockShapeId","datasourceInternalId","locationInternalId","addOnOverride","idToBlockShapeId","fromEntries","internalId","idToInputGroupId","outputToLocationInput","dsBlockDataDir","join","promises","mkdir","recursive","schemaJson","fieldSchemaList","name","nullable","userDefinedTypeClass","customMetadata","arraySubtype","precision","scale","mapKeyType","mapValueType","subSchemas","primaryKey","dataFrameReaderClass","format","options","writeFile","JSON","stringify","blockDataJson","v1","columns","hasSchema","emptyZip","Buffer","from","inputs","compassResource","allowedTypes","typeConstraints","compassFolderTypeConstraints","constraints","block_identifier","block_data_directory","oci_block_data_metadata","undefined","maven_block_data_metadata","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","block_type"],"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 type {\n ObjectTypeBlockDataV2,\n PropertyType,\n PropertyTypeMappingInfo,\n} from \"@osdk/client.unstable\";\nimport type { InputShape, OutputShape } from \"@osdk/client.unstable/api\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n typeToConcreteDataType,\n} 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 \"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 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 * Extract the set of edit-only property RIDs from the wire format datasources.\n */\nfunction getEditOnlyPropertyRids(\n datasources: ObjectTypeBlockDataV2[\"datasources\"],\n): Set<string> {\n const editOnlyRids = new Set<string>();\n for (const ds of 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 === \"editOnly\") {\n editOnlyRids.add(rid);\n }\n }\n }\n }\n return editOnlyRids;\n}\n\n/**\n * Extract non-edit-only properties from ObjectTypeBlockDataV2.\n */\nexport function getNonEditOnlyProperties(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n): PropertyType[] {\n const editOnlyRids = getEditOnlyPropertyRids(\n objectTypeBlockData.datasources,\n );\n return Object.entries(objectTypeBlockData.objectType.propertyTypes)\n .filter(([rid]) => !editOnlyRids.has(rid))\n .map(([_, prop]) => prop);\n}\n\n/**\n * Generate a backing datasource BlockGeneratorResult for an object type.\n */\nexport async function generateBackingDatasetBlockResult(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n buildDir: string,\n randomnessKey?: string,\n): Promise<BlockGeneratorResult> {\n const apiName = objectTypeBlockData.objectType.apiName!;\n\n const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);\n\n const dsName = `${apiName}-backing-ds`;\n\n // Build output shapes for the dataset block\n const outputs: Record<string, OutputShape> = {};\n\n // Readable IDs for dataset outputs (must match what the ontology block uses as inputs)\n const datasourceReadableId = ReadableIdGenerator.getForDatasetOutput(apiName);\n\n // tabularDatasource output shape\n const columnReadableIds: ReadableId[] = [];\n for (const prop of nonEditOnlyProps) {\n const colReadableId = ReadableIdGenerator.getForDatasetColumnOutput(\n apiName,\n prop.apiName!,\n );\n columnReadableIds.push(colReadableId);\n }\n\n const datasourceBlockInternalId = toBlockShapeId(\n datasourceReadableId,\n randomnessKey,\n );\n\n outputs[datasourceReadableId] = {\n type: \"tabularDatasource\",\n tabularDatasource: {\n about: {\n fallbackTitle: dsName,\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 for each non-edit-only property\n for (let i = 0; i < nonEditOnlyProps.length; i++) {\n const prop = nonEditOnlyProps[i];\n const colReadableId = columnReadableIds[i];\n\n outputs[colReadableId] = {\n type: \"datasourceColumn\",\n datasourceColumn: {\n about: {\n fallbackTitle: prop.apiName!,\n fallbackDescription: \"\",\n localizedTitle: {},\n localizedDescription: {},\n },\n type: {\n type: \"concrete\",\n concrete: typeToConcreteDataType(prop.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 = nonEditOnlyProps.map((prop) =>\n toBlockShapeId(\n `column-internal-${apiName}-${prop.apiName!}`,\n randomnessKey,\n )\n );\n\n const compassReadableId = `${dsName}-compass-resource` as ReadableId;\n const compassBlockShapeId = toBlockShapeId(\n compassReadableId,\n randomnessKey,\n );\n\n const datasourceInternalId = toBlockShapeId(\n `datasource-internal-${apiName}`,\n randomnessKey,\n );\n const locationInternalId = toBlockShapeId(\n `location-internal-${apiName}`,\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(\n buildDir,\n `temp_block_data_${apiName}_backing_ds`,\n );\n await fs.promises.mkdir(dsBlockDataDir, { recursive: true });\n\n // Write schema.json\n const schemaJson = {\n fieldSchemaList: nonEditOnlyProps.map((prop) => ({\n type: propertyTypeToSchemaType(prop.type),\n name: prop.apiName!,\n nullable: null,\n userDefinedTypeClass: null,\n customMetadata: {},\n arraySubtype: null,\n precision: null,\n scale: null,\n mapKeyType: null,\n mapValueType: null,\n subSchemas: null,\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 nonEditOnlyProps.map((prop, i) => [\n columnInternalIds[i],\n prop.apiName!,\n ]),\n ),\n hasSchema: true,\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(\n path.join(dsBlockDataDir, \"VERSION\"),\n \"\\\"1\\\"\",\n );\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,\n 0x4b,\n 0x05,\n 0x06,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n ]);\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"files.zip\"),\n emptyZip,\n );\n\n // Build inputs (compassResource for install location)\n const inputs: Record<string, InputShape> = {};\n inputs[compassReadableId] = {\n type: \"compassResource\",\n compassResource: {\n about: {\n fallbackTitle: dsName,\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\n return {\n block_identifier: dsName,\n block_data_directory: dsBlockDataDir,\n oci_block_data_metadata: undefined,\n maven_block_data_metadata: undefined,\n inputs: inputs as any,\n outputs: outputs as any,\n input_mapping_entries: [],\n external_recommendations: [],\n add_on_override: addOnOverride,\n input_shape_metadata: {},\n block_type: \"STATIC_DATASET\",\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SACEC,sBAAsB,QACjB,6CAA6C;AAEpD,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,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;MACE,MAAM,IAAIE,KAAK,CACb,8BAA8BF,OAAO,kCAAkC,GACnE,yHACN,CAAC;EACL;AACF;;AAEA;AACA;AACA;AACA,SAASG,uBAAuB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,CACf;QACEpG,IAAI,EAAE,8BAA8B;QACpCqG,4BAA4B,EAAE;UAC5BC,WAAW,EAAE,CAAC,kBAAkB;QAClC;MACF,CAAC;IAEL;EACF,CAAe;EAEf,OAAO;IACLC,gBAAgB,EAAExE,MAAM;IACxByE,oBAAoB,EAAEtC,cAAc;IACpCuC,uBAAuB,EAAEC,SAAS;IAClCC,yBAAyB,EAAED,SAAS;IACpCT,MAAM,EAAEA,MAAa;IACrBjE,OAAO,EAAEA,OAAc;IACvB4E,qBAAqB,EAAE,EAAE;IACzBC,wBAAwB,EAAE,EAAE;IAC5BC,eAAe,EAAElD,aAAa;IAC9BmD,oBAAoB,EAAE,CAAC,CAAC;IACxBC,UAAU,EAAE;EACd,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"generateBackingDataset.js","names":["fs","path","typeToConcreteDataType","ReadableIdGenerator","toBlockShapeId","propertyTypeToSchemaType","propType","typeStr","type","Error","getEditOnlyPropertyRids","datasources","editOnlyRids","Set","ds","def","datasource","propertyMapping","datasetV2","datasetV3","rid","mapping","Object","entries","add","getNonEditOnlyProperties","objectTypeBlockData","objectType","propertyTypes","filter","has","map","_","prop","generateBackingDatasetBlock","datasetName","blockIdentifier","dirSuffix","columns","buildDir","randomnessKey","outputs","datasourceReadableId","getForDatasetOutput","columnReadableIds","col","getForDatasetColumnOutput","name","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","nullable","userDefinedTypeClass","customMetadata","arraySubtype","precision","scale","mapKeyType","mapValueType","subSchemas","primaryKey","dataFrameReaderClass","format","options","writeFile","JSON","stringify","blockDataJson","v1","hasSchema","emptyZip","Buffer","from","inputs","compassResource","allowedTypes","typeConstraints","compassFolderTypeConstraints","constraints","block_identifier","block_data_directory","oci_block_data_metadata","undefined","maven_block_data_metadata","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","block_type","generateBackingDatasetBlockResult","apiName","nonEditOnlyProps","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 type {\n LinkTypeBlockDataV2,\n ObjectTypeBlockDataV2,\n PropertyType,\n PropertyTypeMappingInfo,\n Type,\n} from \"@osdk/client.unstable\";\nimport type { InputShape, OutputShape } from \"@osdk/client.unstable/api\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport {\n typeToConcreteDataType,\n} 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 \"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 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 * Extract the set of edit-only property RIDs from the wire format datasources.\n */\nfunction getEditOnlyPropertyRids(\n datasources: ObjectTypeBlockDataV2[\"datasources\"],\n): Set<string> {\n const editOnlyRids = new Set<string>();\n for (const ds of 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 === \"editOnly\") {\n editOnlyRids.add(rid);\n }\n }\n }\n }\n return editOnlyRids;\n}\n\n/**\n * Extract non-edit-only properties from ObjectTypeBlockDataV2.\n */\nexport function getNonEditOnlyProperties(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n): PropertyType[] {\n const editOnlyRids = getEditOnlyPropertyRids(\n objectTypeBlockData.datasources,\n );\n return Object.entries(objectTypeBlockData.objectType.propertyTypes)\n .filter(([rid]) => !editOnlyRids.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 = ReadableIdGenerator.getForDatasetOutput(\n datasetName,\n );\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(\n `column-internal-${datasetName}-${col.name}`,\n randomnessKey,\n )\n );\n\n const compassReadableId = `${blockIdentifier}-compass-resource` as ReadableId;\n const compassBlockShapeId = toBlockShapeId(\n compassReadableId,\n randomnessKey,\n );\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 type: propertyTypeToSchemaType(col.type),\n name: col.name,\n nullable: null,\n userDefinedTypeClass: null,\n customMetadata: {},\n arraySubtype: null,\n precision: null,\n scale: null,\n mapKeyType: null,\n mapValueType: null,\n subSchemas: null,\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 },\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(\n path.join(dsBlockDataDir, \"VERSION\"),\n \"\\\"1\\\"\",\n );\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,\n 0x4b,\n 0x05,\n 0x06,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n 0x00,\n ]);\n await fs.promises.writeFile(\n path.join(dsBlockDataDir, \"files.zip\"),\n emptyZip,\n );\n\n // Build inputs (compassResource for install location)\n const inputs: Record<ReadableId, InputShape> = {} as Record<\n ReadableId,\n InputShape\n >;\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\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 */\nexport async function generateBackingDatasetBlockResult(\n objectTypeBlockData: ObjectTypeBlockDataV2,\n buildDir: string,\n randomnessKey?: string,\n): Promise<BlockGeneratorResult> {\n const apiName = objectTypeBlockData.objectType.apiName!;\n const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);\n\n const columns: BackingDatasetColumn[] = nonEditOnlyProps.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 */\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(\n `Could not find object types for link \"${linkApiName}\"`,\n );\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;;AAUA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAC7B,OAAO,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,MAAM,CAAC3H,EAAE,CAAC6H,4BAA4B,CAAC,CAAC,CAAC,CAAC;;EAEjE;EACA,MAAME,WAAW,GAAGd,WAAW,CAACG,GAAG,CAACY,cAAc,CAAC;EACnD,MAAMC,WAAW,GAAGhB,WAAW,CAACG,GAAG,CAACc,cAAc,CAAC;EACnD,IAAI,CAACH,WAAW,IAAI,CAACE,WAAW,EAAE;IAChC,MAAM,IAAItI,KAAK,CACb,yCAAyCqH,WAAW,GACtD,CAAC;EACH;EACA,MAAMmB,SAAS,GAAGJ,WAAW,CAAClH,UAAU,CAACC,aAAa,CAACyG,MAAM,CAAC,EAAE7H,IAAI;EACpE,MAAM0I,SAAS,GAAGH,WAAW,CAACpH,UAAU,CAACC,aAAa,CAAC8G,MAAM,CAAC,EAAElI,IAAI;EACpE,IAAI,CAACyI,SAAS,IAAI,CAACC,SAAS,EAAE;IAC5B,MAAM,IAAIzI,KAAK,CACb,uDAAuDqH,WAAW,GACpE,CAAC;EACH;;EAEA;EACA,OAAO5F,2BAA2B,CAChC,QAAQ4F,WAAW,EAAE,EACrB,GAAGA,WAAW,kBAAkB,EAChC,GAAGA,WAAW,kBAAkB,EAChC,CACE;IAAE/E,IAAI,EAAEyF,OAAO;IAAEhI,IAAI,EAAEyI;EAAU,CAAC,EAClC;IAAElG,IAAI,EAAE6F,OAAO;IAAEpI,IAAI,EAAE0I;EAAU,CAAC,CACnC,EACD3G,QAAQ,EACRC,aACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { cleanAndValidateLinkTypeId } from "@osdk/maker";
|
|
17
18
|
import { consola } from "consola";
|
|
18
19
|
import { createJiti } from "jiti";
|
|
19
20
|
import * as fs from "node:fs";
|
|
@@ -23,12 +24,12 @@ import yargs from "yargs";
|
|
|
23
24
|
import { hideBin } from "yargs/helpers";
|
|
24
25
|
import { defineOntologyV2 } from "../api/defineOntologyV2.js";
|
|
25
26
|
import { ReadableIdGenerator } from "../util/generateRid.js";
|
|
26
|
-
import { generateBackingDatasetBlockResult, getNonEditOnlyProperties } from "./generateBackingDataset.js";
|
|
27
|
+
import { generateBackingDatasetBlockResult, generateBackingDatasetBlockResultForLink, getNonEditOnlyProperties } from "./generateBackingDataset.js";
|
|
27
28
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
28
29
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
29
30
|
export default async function main(args = process.argv) {
|
|
30
31
|
consola.log("Generating BlockGeneratorResult for ontology...");
|
|
31
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.6.0
|
|
32
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.6.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
32
33
|
input: {
|
|
33
34
|
alias: "i",
|
|
34
35
|
describe: "Input file",
|
|
@@ -73,7 +74,8 @@ export default async function main(args = process.argv) {
|
|
|
73
74
|
const {
|
|
74
75
|
ontologyIr,
|
|
75
76
|
shapes,
|
|
76
|
-
backingDatasourceApiNames
|
|
77
|
+
backingDatasourceApiNames,
|
|
78
|
+
backingDatasourceLinkApiNames
|
|
77
79
|
} = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.randomnessKey);
|
|
78
80
|
|
|
79
81
|
// Create temp directory for block data
|
|
@@ -120,6 +122,39 @@ export default async function main(args = process.argv) {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
// Collect input_mapping_entries for link types with includeEmptyBackingDatasource
|
|
126
|
+
for (const linkApiName of backingDatasourceLinkApiNames) {
|
|
127
|
+
const linkTypeBlockData = findLinkTypeByApiName(ontologyIr.ontology.linkTypes, linkApiName);
|
|
128
|
+
if (!linkTypeBlockData) continue;
|
|
129
|
+
const datasetName = `link.${linkApiName}`;
|
|
130
|
+
|
|
131
|
+
// Map tabularDatasource
|
|
132
|
+
const inputDsId = ReadableIdGenerator.getForDataset(datasetName);
|
|
133
|
+
const outputDsId = ReadableIdGenerator.getForDatasetOutput(datasetName);
|
|
134
|
+
if (shapes.inputShapes.has(inputDsId)) {
|
|
135
|
+
ontologyInputMappingEntries.push({
|
|
136
|
+
input: inputDsId,
|
|
137
|
+
output: outputDsId
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Map columns from the datasource
|
|
142
|
+
const ds = linkTypeBlockData.datasources[0]?.datasource;
|
|
143
|
+
if (ds?.type === "dataset") {
|
|
144
|
+
const columnNames = [...Object.values(ds.dataset.objectTypeAPrimaryKeyMapping).map(String), ...Object.values(ds.dataset.objectTypeBPrimaryKeyMapping).map(String)];
|
|
145
|
+
for (const colName of columnNames) {
|
|
146
|
+
const colInputId = ReadableIdGenerator.getForDatasetColumn(datasetName, colName);
|
|
147
|
+
const colOutputId = ReadableIdGenerator.getForDatasetColumnOutput(datasetName, colName);
|
|
148
|
+
if (shapes.inputShapes.has(colInputId)) {
|
|
149
|
+
ontologyInputMappingEntries.push({
|
|
150
|
+
input: colInputId,
|
|
151
|
+
output: colOutputId
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
123
158
|
// Generate backing datasource BlockGeneratorResults for objects with includeEmptyBackingDatasource
|
|
124
159
|
const backingDsGeneratorResults = await Promise.all(backingDatasourceApiNames.filter(apiName => {
|
|
125
160
|
const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
|
|
@@ -130,6 +165,14 @@ export default async function main(args = process.argv) {
|
|
|
130
165
|
return await generateBackingDatasetBlockResult(objectTypeBlockData, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
131
166
|
}));
|
|
132
167
|
|
|
168
|
+
// Generate backing datasource BlockGeneratorResults for link types with includeEmptyBackingDatasource
|
|
169
|
+
const backingDsLinkGeneratorResults = await Promise.all(backingDatasourceLinkApiNames.map(linkApiName => {
|
|
170
|
+
const linkTypeBlockData = findLinkTypeByApiName(ontologyIr.ontology.linkTypes, linkApiName);
|
|
171
|
+
if (!linkTypeBlockData) return undefined;
|
|
172
|
+
consola.info(`Generating backing datasource BlockGeneratorResult for link ${linkApiName}...`);
|
|
173
|
+
return generateBackingDatasetBlockResultForLink(linkTypeBlockData, linkApiName, ontologyIr.ontology.objectTypes, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
|
|
174
|
+
}).filter(p => p !== undefined));
|
|
175
|
+
|
|
133
176
|
// Create BlockGeneratorResult
|
|
134
177
|
const blockGeneratorResult = {
|
|
135
178
|
block_identifier: "ontology",
|
|
@@ -146,7 +189,7 @@ export default async function main(args = process.argv) {
|
|
|
146
189
|
};
|
|
147
190
|
|
|
148
191
|
// Write BlockGeneratorResult to output file
|
|
149
|
-
const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...backingDsGeneratorResults], null, 2);
|
|
192
|
+
const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...backingDsGeneratorResults, ...backingDsLinkGeneratorResults], null, 2);
|
|
150
193
|
await fs.promises.writeFile(commandLineOpts.output, blockGeneratorResultJson);
|
|
151
194
|
consola.success(`BlockGeneratorResult written to ${commandLineOpts.output}`);
|
|
152
195
|
consola.info(`Block data directory: ${blockDataDir}`);
|
|
@@ -169,4 +212,12 @@ async function loadOntology(input, apiNamespace, randomnessKey) {
|
|
|
169
212
|
function findObjectTypeByApiName(objectTypes, apiName) {
|
|
170
213
|
return Object.values(objectTypes).find(objectTypeBlockData => objectTypeBlockData.objectType.apiName === apiName);
|
|
171
214
|
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Find a LinkTypeBlockDataV2 by apiName within the ontology block data.
|
|
218
|
+
*/
|
|
219
|
+
function findLinkTypeByApiName(linkTypes, apiName) {
|
|
220
|
+
const linkTypeId = cleanAndValidateLinkTypeId(apiName);
|
|
221
|
+
return Object.values(linkTypes).find(lt => lt.linkType.id === linkTypeId);
|
|
222
|
+
}
|
|
172
223
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["consola","createJiti","fs","path","invariant","yargs","hideBin","defineOntologyV2","ReadableIdGenerator","generateBackingDatasetBlockResult","getNonEditOnlyProperties","apiNamespaceRegex","uuidRegex","main","args","process","argv","log","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","buildDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","shapes","backingDatasourceApiNames","loadOntology","blockDataDir","join","existsSync","promises","mkdir","recursive","ontologyJsonPath","ontologyJson","JSON","stringify","ontology","writeFile","ontologyInputMappingEntries","apiName","objectTypeBlockData","findObjectTypeByApiName","objectTypes","nonEditOnlyProps","inputDatasetReadableId","getForDataset","outputDatasetReadableId","getForDatasetOutput","inputShapes","has","push","prop","colInputReadableId","getForDatasetColumn","getForDatasetColumnOutput","backingDsGeneratorResults","Promise","all","filter","map","blockGeneratorResult","block_identifier","block_data_directory","oci_block_data_metadata","maven_block_data_metadata","inputs","Object","fromEntries","outputs","outputShapes","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","inputShapeMetadata","block_type","blockGeneratorResultJson","success","result","jiti","import","meta","filename","moduleCache","debug","importMeta","values","find","objectType"],"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 { ObjectTypeBlockDataV2 } from \"@osdk/client.unstable\";\nimport { consola } from \"consola\";\nimport { createJiti } from \"jiti\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\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 getNonEditOnlyProperties,\n} from \"./generateBackingDataset.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 apiNamespace: string;\n buildDir: 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 BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/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 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 const { ontologyIr, shapes, backingDatasourceApiNames } = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\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 // 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[] = [];\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 // 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 // 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 [blockGeneratorResult, ...backingDsGeneratorResults],\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\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n randomnessKey?: string,\n) {\n const result = await defineOntologyV2(\n apiNamespace,\n async () => {\n const jiti = createJiti(import.meta.filename, {\n moduleCache: true,\n debug: false,\n importMeta: import.meta,\n });\n const module = await jiti.import(input);\n },\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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,OAAO,QAAQ,SAAS;AACjC,SAASC,UAAU,QAAQ,MAAM;AACjC,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,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,wBAAwB,QACnB,6BAA6B;AAIpC,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACfhB,OAAO,CAACiB,GAAG,CAAC,iDAAiD,CAAC;EAE9D,MAAMC,eAML,GAAG,MAAMb,KAAK,CAACC,O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ACF,CAAC;EACDpG,OAAO,CAACqG,OAAO,CACb,mCAAmCnF,eAAe,CAACgB,MAAM,EAC3D,CAAC;EACDlC,OAAO,CAAC4C,IAAI,CACV,yBAAyBM,YAAY,EACvC,CAAC;AACH;AAEA,eAAeD,YAAYA,CACzBtB,KAAa,EACbQ,YAAoB,EACpBE,aAAsB,EACtB;EACA,MAAMiE,MAAM,GAAG,MAAM/F,gBAAgB,CACnC4B,YAAY,EACZ,YAAY;IACV,MAAMoE,IAAI,GAAGtG,UAAU,CAACuG,MAAM,CAACC,IAAI,CAACC,QAAQ,EAAE;MAC5CC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAE,KAAK;MACZC,UAAU,EAAEL,MAAM,CAACC;IACrB,CAAC,CAAC;IACa,MAAMF,IAAI,CAACC,MAAM,CAAC7E,KAAK,CAAC;EACzC,CAAC,EACDU,aACF,CAAC;EACD,OAAOiE,MAAM;AACf;;AAEA;AACA;AACA;AACA,SAASrC,uBAAuBA,CAC9BC,WAAkD,EAClDH,OAAe,EACoB;EACnC,OAAO2B,MAAM,CAACoB,MAAM,CAAC5C,WAAW,CAAC,CAAC6C,IAAI,CACnC/C,mBAAmB,IAAKA,mBAAmB,CAACgD,UAAU,CAACjD,OAAO,KAAKA,OACtE,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"main.js","names":["cleanAndValidateLinkTypeId","consola","createJiti","fs","path","invariant","yargs","hideBin","defineOntologyV2","ReadableIdGenerator","generateBackingDatasetBlockResult","generateBackingDatasetBlockResultForLink","getNonEditOnlyProperties","apiNamespaceRegex","uuidRegex","main","args","process","argv","log","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","buildDir","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","shapes","backingDatasourceApiNames","backingDatasourceLinkApiNames","loadOntology","blockDataDir","join","existsSync","promises","mkdir","recursive","ontologyJsonPath","ontologyJson","JSON","stringify","ontology","writeFile","ontologyInputMappingEntries","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","result","jiti","import","meta","filename","moduleCache","debug","importMeta","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 { cleanAndValidateLinkTypeId } from \"@osdk/maker\";\nimport { consola } from \"consola\";\nimport { createJiti } from \"jiti\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\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 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 apiNamespace: string;\n buildDir: 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 BlockGeneratorResult JSON\",\n type: \"string\",\n default: \"build/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 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 const {\n ontologyIr,\n shapes,\n backingDatasourceApiNames,\n backingDatasourceLinkApiNames,\n } = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\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 // 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[] = [];\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 // 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 ],\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\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n randomnessKey?: string,\n) {\n const result = await defineOntologyV2(\n apiNamespace,\n async () => {\n const jiti = createJiti(import.meta.filename, {\n moduleCache: true,\n debug: false,\n importMeta: import.meta,\n });\n const module = await jiti.import(input);\n },\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,0BAA0B,QAAQ,aAAa;AACxD,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,UAAU,QAAQ,MAAM;AACjC,OAAO,KAAKC,EAAE,MAAM,SAAS;AAC7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,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;AAIpC,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACfjB,OAAO,CAACkB,GAAG,CAAC,iDAAiD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