@osdk/maker-experimental 0.6.0-beta.4 → 0.6.0-beta.5

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/browser/api/defineOntologyV2.js +9 -3
  3. package/build/browser/api/defineOntologyV2.js.map +1 -1
  4. package/build/browser/cli/generateBackingDataset.js +250 -0
  5. package/build/browser/cli/generateBackingDataset.js.map +1 -0
  6. package/build/browser/cli/main.js +60 -7
  7. package/build/browser/cli/main.js.map +1 -1
  8. package/build/browser/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
  9. package/build/browser/util/generateRid.js +10 -4
  10. package/build/browser/util/generateRid.js.map +1 -1
  11. package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs → ActionTypeShapeExtractor-UWC4CVHX.cjs} +4 -4
  12. package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs.map → ActionTypeShapeExtractor-UWC4CVHX.cjs.map} +1 -1
  13. package/build/cjs/{chunk-AWYOBJ25.cjs → chunk-JC573VYW.cjs} +13 -6
  14. package/build/cjs/chunk-JC573VYW.cjs.map +1 -0
  15. package/build/cjs/index.cjs +270 -38
  16. package/build/cjs/index.cjs.map +1 -1
  17. package/build/cjs/index.d.cts +6 -1
  18. package/build/esm/api/defineOntologyV2.js +9 -3
  19. package/build/esm/api/defineOntologyV2.js.map +1 -1
  20. package/build/esm/cli/generateBackingDataset.js +250 -0
  21. package/build/esm/cli/generateBackingDataset.js.map +1 -0
  22. package/build/esm/cli/main.js +60 -7
  23. package/build/esm/cli/main.js.map +1 -1
  24. package/build/esm/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
  25. package/build/esm/util/generateRid.js +10 -4
  26. package/build/esm/util/generateRid.js.map +1 -1
  27. package/build/types/api/defineOntologyV2.d.ts +6 -1
  28. package/build/types/api/defineOntologyV2.d.ts.map +1 -1
  29. package/build/types/cli/generateBackingDataset.d.ts +16 -0
  30. package/build/types/cli/generateBackingDataset.d.ts.map +1 -0
  31. package/build/types/cli/main.d.ts.map +1 -1
  32. package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts +2 -2
  33. package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts.map +1 -1
  34. package/build/types/util/generateRid.d.ts +4 -2
  35. package/build/types/util/generateRid.d.ts.map +1 -1
  36. package/package.json +6 -6
  37. package/build/browser/api/overall.test.js +0 -713
  38. package/build/browser/api/overall.test.js.map +0 -1
  39. package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
  40. package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
  41. package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
  42. package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
  43. package/build/cjs/chunk-AWYOBJ25.cjs.map +0 -1
  44. package/build/esm/api/overall.test.js +0 -713
  45. package/build/esm/api/overall.test.js.map +0 -1
  46. package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
  47. package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
  48. package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
  49. package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
  50. package/build/types/api/overall.test.d.ts +0 -1
  51. package/build/types/api/overall.test.d.ts.map +0 -1
  52. package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts +0 -1
  53. package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts.map +0 -1
  54. package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts +0 -1
  55. package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @osdk/maker-experimental
2
2
 
3
+ ## 0.6.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - fd3f6d3: Add support for empty backing datasources
8
+ - 764fe55: Support multi block-generation-result outputs.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [cc7f505]
13
+ - Updated dependencies [4bb9769]
14
+ - Updated dependencies [0e45a37]
15
+ - Updated dependencies [fcf81ba]
16
+ - Updated dependencies [fd3f6d3]
17
+ - @osdk/maker@0.16.0-beta.11
18
+ - @osdk/api@2.8.0-beta.23
19
+ - @osdk/client.unstable@2.8.0-beta.23
20
+
3
21
  ## 0.6.0-beta.4
4
22
 
5
23
  ### Minor Changes
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { getOntologyDefinition, initializeOntologyState } from "@osdk/maker";
17
+ import { getOntologyDefinition, initializeOntologyState, OntologyEntityTypeEnum } from "@osdk/maker";
18
18
  import { convertOntologyDefinition } from "../conversion/toMarketplace/convertOntologyDefinition.js";
19
19
  import { getShapes } from "../conversion/toMarketplace/shapeExtractors/IrShapeExtractor.js";
20
20
  import { OntologyRidGeneratorImpl } from "../util/generateRid.js";
@@ -27,9 +27,15 @@ export async function defineOntologyV2(ns, body, randomnessKey) {
27
27
  console.error("Unexpected error while processing the body of the ontology", e);
28
28
  throw e;
29
29
  }
30
+ const ontologyDefinition = getOntologyDefinition();
30
31
  const ridGenerator = new OntologyRidGeneratorImpl();
31
- const ontDef = convertOntologyDefinition(getOntologyDefinition(), ridGenerator, randomnessKey);
32
+ const ontDef = convertOntologyDefinition(ontologyDefinition, ridGenerator, randomnessKey);
32
33
  const shapes = await getShapes(ontDef.ontology, ridGenerator, randomnessKey);
33
- return [ontDef, shapes];
34
+ const backingDatasourceApiNames = Object.entries(ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE]).filter(([_, obj]) => obj.includeEmptyBackingDatasource === true).map(([apiName]) => apiName);
35
+ return {
36
+ ontologyIr: ontDef,
37
+ shapes,
38
+ backingDatasourceApiNames
39
+ };
34
40
  }
35
41
  //# sourceMappingURL=defineOntologyV2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defineOntologyV2.js","names":["getOntologyDefinition","initializeOntologyState","convertOntologyDefinition","getShapes","OntologyRidGeneratorImpl","defineOntologyV2","ns","body","randomnessKey","e","console","error","ridGenerator","ontDef","shapes","ontology"],"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 { getOntologyDefinition, initializeOntologyState } 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 async function defineOntologyV2(\n ns: string,\n body: () => void | Promise<void>,\n randomnessKey?: string,\n): Promise<[OntologyIrV2, BlockShapes]> {\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 ridGenerator = new OntologyRidGeneratorImpl();\n const ontDef = convertOntologyDefinition(\n getOntologyDefinition(),\n ridGenerator,\n randomnessKey,\n );\n\n const shapes = await getShapes(\n ontDef.ontology,\n ridGenerator,\n randomnessKey,\n );\n\n return [ontDef, shapes];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,EAAEC,uBAAuB,QAAQ,aAAa;AAC5E,SAASC,yBAAyB,QAAQ,0DAA0D;AACpG,SAASC,SAAS,QAAQ,iEAAiE;AAE3F,SAASC,wBAAwB,QAAQ,wBAAwB;AAEjE,OAAO,eAAeC,gBAAgBA,CACpCC,EAAU,EACVC,IAAgC,EAChCC,aAAsB,EACgB;EACtCP,uBAAuB,CAACK,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,YAAY,GAAG,IAAIR,wBAAwB,CAAC,CAAC;EACnD,MAAMS,MAAM,GAAGX,yBAAyB,CACtCF,qBAAqB,CAAC,CAAC,EACvBY,YAAY,EACZJ,aACF,CAAC;EAED,MAAMM,MAAM,GAAG,MAAMX,SAAS,CAC5BU,MAAM,CAACE,QAAQ,EACfH,YAAY,EACZJ,aACF,CAAC;EAED,OAAO,CAACK,MAAM,EAAEC,MAAM,CAAC;AACzB","ignoreList":[]}
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();\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, shapes, backingDatasourceAp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inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import * as fs from "node:fs";
18
+ import * as path from "node:path";
19
+ import { typeToConcreteDataType } from "../conversion/toMarketplace/typeVisitors.js";
20
+ import { ReadableIdGenerator } from "../util/generateRid.js";
21
+ import { toBlockShapeId } from "./marketplaceSerialization/CodeBlockSpec.js";
22
+
23
+ /**
24
+ * Map from maker property type to Foundry schema field type
25
+ */
26
+ export function propertyTypeToSchemaType(propType) {
27
+ const typeStr = typeof propType === "string" ? propType : propType.type;
28
+ switch (typeStr) {
29
+ case "string":
30
+ return "STRING";
31
+ case "boolean":
32
+ return "BOOLEAN";
33
+ case "integer":
34
+ return "INTEGER";
35
+ case "long":
36
+ return "LONG";
37
+ case "double":
38
+ return "DOUBLE";
39
+ case "float":
40
+ return "FLOAT";
41
+ case "byte":
42
+ return "BYTE";
43
+ case "short":
44
+ return "SHORT";
45
+ case "date":
46
+ return "DATE";
47
+ case "timestamp":
48
+ return "TIMESTAMP";
49
+ default:
50
+ throw new Error(`Unsupported property type "${typeStr}" for empty backing datasource. ` + `If using a property type that doesn't support empty backing datasources please make the property an edit only property.`);
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Extract the set of edit-only property RIDs from the wire format datasources.
56
+ */
57
+ function getEditOnlyPropertyRids(datasources) {
58
+ const editOnlyRids = new Set();
59
+ for (const ds of datasources) {
60
+ const def = ds.datasource;
61
+ let propertyMapping;
62
+ if (def.type === "datasetV2") {
63
+ propertyMapping = def.datasetV2.propertyMapping;
64
+ } else if (def.type === "datasetV3") {
65
+ propertyMapping = def.datasetV3.propertyMapping;
66
+ }
67
+ if (propertyMapping) {
68
+ for (const [rid, mapping] of Object.entries(propertyMapping)) {
69
+ if (mapping.type === "editOnly") {
70
+ editOnlyRids.add(rid);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ return editOnlyRids;
76
+ }
77
+
78
+ /**
79
+ * Extract non-edit-only properties from ObjectTypeBlockDataV2.
80
+ */
81
+ export function getNonEditOnlyProperties(objectTypeBlockData) {
82
+ const editOnlyRids = getEditOnlyPropertyRids(objectTypeBlockData.datasources);
83
+ return Object.entries(objectTypeBlockData.objectType.propertyTypes).filter(([rid]) => !editOnlyRids.has(rid)).map(([_, prop]) => prop);
84
+ }
85
+
86
+ /**
87
+ * Generate a backing datasource BlockGeneratorResult for an object type.
88
+ */
89
+ export async function generateBackingDatasetBlockResult(objectTypeBlockData, buildDir, randomnessKey) {
90
+ const apiName = objectTypeBlockData.objectType.apiName;
91
+ const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
92
+ const dsName = `${apiName}-backing-ds`;
93
+
94
+ // Build output shapes for the dataset block
95
+ const outputs = {};
96
+
97
+ // Readable IDs for dataset outputs (must match what the ontology block uses as inputs)
98
+ const datasourceReadableId = ReadableIdGenerator.getForDatasetOutput(apiName);
99
+
100
+ // 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
+ outputs[datasourceReadableId] = {
108
+ type: "tabularDatasource",
109
+ tabularDatasource: {
110
+ about: {
111
+ fallbackTitle: dsName,
112
+ fallbackDescription: "",
113
+ localizedTitle: {},
114
+ localizedDescription: {}
115
+ },
116
+ schema: columnReadableIds.map(id => toBlockShapeId(id, randomnessKey)),
117
+ type: "DATASET",
118
+ buildRequirements: {
119
+ isBuildable: false
120
+ }
121
+ }
122
+ };
123
+
124
+ // datasourceColumn output shapes for each non-edit-only property
125
+ for (let i = 0; i < nonEditOnlyProps.length; i++) {
126
+ const prop = nonEditOnlyProps[i];
127
+ const colReadableId = columnReadableIds[i];
128
+ outputs[colReadableId] = {
129
+ type: "datasourceColumn",
130
+ datasourceColumn: {
131
+ about: {
132
+ fallbackTitle: prop.apiName,
133
+ fallbackDescription: "",
134
+ localizedTitle: {},
135
+ localizedDescription: {}
136
+ },
137
+ type: {
138
+ type: "concrete",
139
+ concrete: typeToConcreteDataType(prop.type)
140
+ },
141
+ datasource: datasourceBlockInternalId,
142
+ typeclasses: []
143
+ }
144
+ };
145
+ }
146
+
147
+ // Generate internal IDs for block-data.json columns.
148
+ // These are distinct from the block shape IDs that appear in the manifest outputs.
149
+ // The add-on maps these internal IDs -> block shape IDs.
150
+ const columnInternalIds = nonEditOnlyProps.map(prop => toBlockShapeId(`column-internal-${apiName}-${prop.apiName}`, randomnessKey));
151
+ const compassReadableId = `${dsName}-compass-resource`;
152
+ const compassBlockShapeId = toBlockShapeId(compassReadableId, randomnessKey);
153
+ const datasourceInternalId = toBlockShapeId(`datasource-internal-${apiName}`, randomnessKey);
154
+ const locationInternalId = toBlockShapeId(`location-internal-${apiName}`, randomnessKey);
155
+ const addOnOverride = {
156
+ idToBlockShapeId: {
157
+ "dataset-internal-shape-id": datasourceBlockInternalId,
158
+ [datasourceInternalId]: datasourceBlockInternalId,
159
+ [locationInternalId]: compassBlockShapeId,
160
+ ...Object.fromEntries(columnInternalIds.map((internalId, i) => [internalId, toBlockShapeId(columnReadableIds[i], randomnessKey)]))
161
+ },
162
+ idToInputGroupId: {},
163
+ outputToLocationInput: {
164
+ [datasourceBlockInternalId]: compassBlockShapeId
165
+ }
166
+ };
167
+
168
+ // Create block data directory
169
+ const dsBlockDataDir = path.join(buildDir, `temp_block_data_${apiName}_backing_ds`);
170
+ await fs.promises.mkdir(dsBlockDataDir, {
171
+ recursive: true
172
+ });
173
+
174
+ // Write schema.json
175
+ const schemaJson = {
176
+ fieldSchemaList: nonEditOnlyProps.map(prop => ({
177
+ type: propertyTypeToSchemaType(prop.type),
178
+ name: prop.apiName,
179
+ nullable: null,
180
+ userDefinedTypeClass: null,
181
+ customMetadata: {},
182
+ arraySubtype: null,
183
+ precision: null,
184
+ scale: null,
185
+ mapKeyType: null,
186
+ mapValueType: null,
187
+ subSchemas: null
188
+ })),
189
+ primaryKey: null,
190
+ dataFrameReaderClass: "com.palantir.foundry.spark.input.ParquetDataFrameReader",
191
+ customMetadata: {
192
+ format: "parquet",
193
+ options: {}
194
+ }
195
+ };
196
+ await fs.promises.writeFile(path.join(dsBlockDataDir, "schema.json"), JSON.stringify(schemaJson, null, 2));
197
+
198
+ // Write block-data.json — column keys are the internal IDs mapped in the add-on
199
+ const blockDataJson = {
200
+ type: "v1",
201
+ v1: {
202
+ columns: Object.fromEntries(nonEditOnlyProps.map((prop, i) => [columnInternalIds[i], prop.apiName])),
203
+ hasSchema: true
204
+ }
205
+ };
206
+ await fs.promises.writeFile(path.join(dsBlockDataDir, "block-data.json"), JSON.stringify(blockDataJson, null, 2));
207
+
208
+ // Write VERSION
209
+ await fs.promises.writeFile(path.join(dsBlockDataDir, "VERSION"), "\"1\"");
210
+
211
+ // Write empty files.zip
212
+ // An empty zip file is just the end-of-central-directory record (22 bytes)
213
+ 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]);
214
+ await fs.promises.writeFile(path.join(dsBlockDataDir, "files.zip"), emptyZip);
215
+
216
+ // Build inputs (compassResource for install location)
217
+ const inputs = {};
218
+ inputs[compassReadableId] = {
219
+ type: "compassResource",
220
+ compassResource: {
221
+ about: {
222
+ fallbackTitle: dsName,
223
+ fallbackDescription: "",
224
+ localizedTitle: {},
225
+ localizedDescription: {}
226
+ },
227
+ allowedTypes: [],
228
+ typeConstraints: [{
229
+ type: "compassFolderTypeConstraints",
230
+ compassFolderTypeConstraints: {
231
+ constraints: ["INSTALL_LOCATION"]
232
+ }
233
+ }]
234
+ }
235
+ };
236
+ return {
237
+ block_identifier: dsName,
238
+ block_data_directory: dsBlockDataDir,
239
+ oci_block_data_metadata: undefined,
240
+ maven_block_data_metadata: undefined,
241
+ inputs: inputs,
242
+ outputs: outputs,
243
+ input_mapping_entries: [],
244
+ external_recommendations: [],
245
+ add_on_override: addOnOverride,
246
+ input_shape_metadata: {},
247
+ block_type: "STATIC_DATASET"
248
+ };
249
+ }
250
+ //# sourceMappingURL=generateBackingDataset.js.map
@@ -0,0 +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;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7CA,MAAM,CAACzC,iBAAiB,CAAC,GAAG;IAC1BxD,IAAI,EAAE,iBAAiB;IACvBkG,eAAe,EAAE;MACfzD,KAAK,EAAE;QACLC,aAAa,EAAEX,MAAM;QACrBY,mBAAmB,EAAE,EAAE;QACvBC,cAAc,EAAE,CAAC,CAAC;QAClBC,oBAAoB,EAAE,CAAC;MACzB,CAAC;MACDsD,YAAY,EAAE,EAAE;MAChBC,eAAe,EAAE,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":[]}
@@ -22,11 +22,13 @@ import invariant from "tiny-invariant";
22
22
  import yargs from "yargs";
23
23
  import { hideBin } from "yargs/helpers";
24
24
  import { defineOntologyV2 } from "../api/defineOntologyV2.js";
25
+ import { ReadableIdGenerator } from "../util/generateRid.js";
26
+ import { generateBackingDatasetBlockResult, getNonEditOnlyProperties } from "./generateBackingDataset.js";
25
27
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
26
28
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
27
29
  export default async function main(args = process.argv) {
28
30
  consola.log("Generating BlockGeneratorResult for ontology...");
29
- const commandLineOpts = await yargs(hideBin(args)).version("0.6.0-beta.4" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
31
+ const commandLineOpts = await yargs(hideBin(args)).version("0.6.0-beta.5" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
30
32
  input: {
31
33
  alias: "i",
32
34
  describe: "Input file",
@@ -69,7 +71,11 @@ export default async function main(args = process.argv) {
69
71
  if (commandLineOpts.randomnessKey !== undefined) {
70
72
  !uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant(false) : void 0;
71
73
  }
72
- const [ontologyBlockDataV2, shapes] = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.randomnessKey);
74
+ const {
75
+ ontologyIr,
76
+ shapes,
77
+ backingDatasourceApiNames
78
+ } = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.randomnessKey);
73
79
 
74
80
  // Create temp directory for block data
75
81
  const blockDataDir = path.join(commandLineOpts.buildDir, "temp_block_data");
@@ -81,10 +87,50 @@ export default async function main(args = process.argv) {
81
87
 
82
88
  // Write ontology.json to the block data directory
83
89
  const ontologyJsonPath = path.join(blockDataDir, "ontology.json");
84
- const ontologyJson = JSON.stringify(ontologyBlockDataV2.ontology, null, 2);
90
+ const ontologyJson = JSON.stringify(ontologyIr.ontology, null, 2);
85
91
  await fs.promises.writeFile(ontologyJsonPath, ontologyJson);
86
92
  consola.info(`Wrote ontology.json to ${ontologyJsonPath}`);
87
93
 
94
+ // Collect input_mapping_entries for the ontology block
95
+ // These map ontology inputs to datasource block outputs for objects with includeEmptyBackingDatasource
96
+ const ontologyInputMappingEntries = [];
97
+ for (const apiName of backingDatasourceApiNames) {
98
+ const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
99
+ if (!objectTypeBlockData) continue;
100
+ const nonEditOnlyProps = getNonEditOnlyProperties(objectTypeBlockData);
101
+
102
+ // The ontology block has inputs with these readable IDs (from shape extraction)
103
+ // Map them to the datasource block's outputs (which use the same readable IDs)
104
+ const inputDatasetReadableId = ReadableIdGenerator.getForDataset(apiName);
105
+ const outputDatasetReadableId = ReadableIdGenerator.getForDatasetOutput(apiName);
106
+ if (shapes.inputShapes.has(inputDatasetReadableId)) {
107
+ ontologyInputMappingEntries.push({
108
+ input: inputDatasetReadableId,
109
+ output: outputDatasetReadableId
110
+ });
111
+ }
112
+ for (const prop of nonEditOnlyProps) {
113
+ const colInputReadableId = ReadableIdGenerator.getForDatasetColumn(apiName, prop.apiName);
114
+ const getForDatasetColumnOutput = ReadableIdGenerator.getForDatasetColumnOutput(apiName, prop.apiName);
115
+ if (shapes.inputShapes.has(colInputReadableId)) {
116
+ ontologyInputMappingEntries.push({
117
+ input: colInputReadableId,
118
+ output: getForDatasetColumnOutput
119
+ });
120
+ }
121
+ }
122
+ }
123
+
124
+ // Generate backing datasource BlockGeneratorResults for objects with includeEmptyBackingDatasource
125
+ const backingDsGeneratorResults = await Promise.all(backingDatasourceApiNames.filter(apiName => {
126
+ const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
127
+ return objectTypeBlockData !== undefined;
128
+ }).map(async apiName => {
129
+ const objectTypeBlockData = findObjectTypeByApiName(ontologyIr.ontology.objectTypes, apiName);
130
+ consola.info(`Generating backing datasource BlockGeneratorResult for ${apiName}...`);
131
+ return await generateBackingDatasetBlockResult(objectTypeBlockData, commandLineOpts.buildDir, commandLineOpts.randomnessKey);
132
+ }));
133
+
88
134
  // Create BlockGeneratorResult
89
135
  const blockGeneratorResult = {
90
136
  block_identifier: "ontology",
@@ -93,7 +139,7 @@ export default async function main(args = process.argv) {
93
139
  maven_block_data_metadata: undefined,
94
140
  inputs: Object.fromEntries(shapes.inputShapes),
95
141
  outputs: Object.fromEntries(shapes.outputShapes),
96
- input_mapping_entries: [],
142
+ input_mapping_entries: ontologyInputMappingEntries,
97
143
  external_recommendations: [],
98
144
  add_on_override: undefined,
99
145
  input_shape_metadata: Object.fromEntries(shapes.inputShapeMetadata),
@@ -101,13 +147,13 @@ export default async function main(args = process.argv) {
101
147
  };
102
148
 
103
149
  // Write BlockGeneratorResult to output file
104
- const blockGeneratorResultJson = JSON.stringify(blockGeneratorResult, null, 2);
150
+ const blockGeneratorResultJson = JSON.stringify([blockGeneratorResult, ...backingDsGeneratorResults], null, 2);
105
151
  await fs.promises.writeFile(commandLineOpts.output, blockGeneratorResultJson);
106
152
  consola.success(`BlockGeneratorResult written to ${commandLineOpts.output}`);
107
153
  consola.info(`Block data directory: ${blockDataDir}`);
108
154
  }
109
155
  async function loadOntology(input, apiNamespace, randomnessKey) {
110
- const ontologyIr = await defineOntologyV2(apiNamespace, async () => {
156
+ const result = await defineOntologyV2(apiNamespace, async () => {
111
157
  const jiti = createJiti(import.meta.filename, {
112
158
  moduleCache: true,
113
159
  debug: false,
@@ -115,6 +161,13 @@ async function loadOntology(input, apiNamespace, randomnessKey) {
115
161
  });
116
162
  await jiti.import(input);
117
163
  }, randomnessKey);
118
- return ontologyIr;
164
+ return result;
165
+ }
166
+
167
+ /**
168
+ * Find an ObjectTypeBlockDataV2 by apiName within the ontology block data.
169
+ */
170
+ function findObjectTypeByApiName(objectTypes, apiName) {
171
+ return Object.values(objectTypes).find(objectTypeBlockData => objectTypeBlockData.objectType.apiName === apiName);
119
172
  }
120
173
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["consola","createJiti","fs","path","invariant","yargs","hideBin","defineOntologyV2","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","ontologyBlockDataV2","shapes","loadOntology","blockDataDir","join","existsSync","promises","mkdir","recursive","ontologyJsonPath","ontologyJson","JSON","stringify","ontology","writeFile","blockGeneratorResult","block_identifier","block_data_directory","oci_block_data_metadata","maven_block_data_metadata","inputs","Object","fromEntries","inputShapes","outputs","outputShapes","input_mapping_entries","external_recommendations","add_on_override","input_shape_metadata","inputShapeMetadata","block_type","blockGeneratorResultJson","success","ontologyIr","jiti","import","meta","filename","moduleCache","debug","importMeta"],"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 { 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 type { BlockGeneratorResult } from \"./marketplaceSerialization/BlockGeneratorResult.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 coerce: path.resolve,\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 [ontologyBlockDataV2, shapes] = 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(ontologyBlockDataV2.ontology, null, 2);\n await fs.promises.writeFile(ontologyJsonPath, ontologyJson);\n consola.info(`Wrote ontology.json to ${ontologyJsonPath}`);\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: [],\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,\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 ontologyIr = 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 ontologyIr;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,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;AAG7D,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACfb,OAAO,CAACc,GAAG,CAAC,iDAAiD,CAAC;EAE9D,MAAMC,eAML,GAAG,MAAMV,KAAK,CA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U,EAAEL,MAAM,CAACC;IACrB,CAAC,CAAC;IACa,MAAMF,IAAI,CAACC,MAAM,CAACvD,KAAK,CAAC;EACzC,CAAC,EACDU,aACF,CAAC;EACD,OAAO2C,UAAU;AACnB","ignoreList":[]}
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 coerce: path.resolve,\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,KA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CAACQ,SAAS,CACzB3C,eAAe,CAACgB,MAAM,EACtBkE,wBACF,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 +1 @@
1
- {"version":3,"file":"BlockGeneratorResult.js","names":[],"sources":["BlockGeneratorResult.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 BlockType,\n InputShape,\n InputShapeMetadata,\n OutputShape,\n} from \"@osdk/client.unstable/api\";\nimport type { ReadableId } from \"../../util/generateRid.js\";\nimport type {\n GeneratedBlockExternalRecommendations,\n InputMappingEntry,\n} from \"./supportingTypes.js\";\n\n/**\n * Result from generating a block.\n * This matches the Rust BlockGeneratorResult interface and Java's BlockGeneratorResult.\n *\n * This is the output that will be consumed by the Rust bundling tooling to create\n * the final marketplace product.\n */\nexport interface BlockGeneratorResult {\n /**\n * Identifier for this block (e.g., \"ontology\")\n */\n block_identifier: \"ontology\";\n\n /**\n * Absolute path to the directory containing block data files.\n * For ontology blocks, this directory should contain ontology.json\n */\n block_data_directory: string;\n\n /**\n * Optional OCI block data metadata\n */\n oci_block_data_metadata?: OciBlockDataMetadata;\n\n /**\n * Optional Maven block data metadata\n */\n maven_block_data_metadata?: MavenBlockDataMetadata;\n\n /**\n * Map of input shapes keyed by ReadableId\n */\n inputs: Record<ReadableId, InputShape>;\n\n /**\n * Map of output shapes keyed by ReadableId\n */\n outputs: Record<ReadableId, OutputShape>;\n\n /**\n * List of input mapping entries that provide hints for how to connect blocks\n */\n input_mapping_entries: InputMappingEntry[];\n\n /**\n * External recommendations for connecting this block to upstream packages\n */\n external_recommendations: GeneratedBlockExternalRecommendations[];\n\n /**\n * Optional override for the block data add-on\n */\n add_on_override?: unknown;\n\n /**\n * Metadata about each input shape\n */\n input_shape_metadata: Record<ReadableId, InputShapeMetadata>;\n\n /**\n * The type of this block (e.g., ONTOLOGY, FUNCTIONS, etc.)\n */\n block_type: BlockType;\n}\n\n/**\n * Metadata for OCI block data\n */\nexport interface OciBlockDataMetadata {\n oci_directory: string;\n}\n\n/**\n * Metadata for Maven block data\n */\nexport interface MavenBlockDataMetadata {\n maven_directory: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"BlockGeneratorResult.js","names":[],"sources":["BlockGeneratorResult.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 BlockType,\n InputShape,\n InputShapeMetadata,\n OutputShape,\n} from \"@osdk/client.unstable/api\";\nimport type { ReadableId } from \"../../util/generateRid.js\";\nimport type {\n GeneratedBlockExternalRecommendations,\n InputMappingEntry,\n} from \"./supportingTypes.js\";\n\n/**\n * Result from generating a block.\n * This matches the Rust BlockGeneratorResult interface and Java's BlockGeneratorResult.\n *\n * This is the output that will be consumed by the Rust bundling tooling to create\n * the final marketplace product.\n */\nexport interface BlockGeneratorResult {\n /**\n * Identifier for this block (e.g., \"ontology\", \"car-backing-ds\")\n */\n block_identifier: string;\n\n /**\n * Absolute path to the directory containing block data files.\n * For ontology blocks, this directory should contain ontology.json\n */\n block_data_directory: string;\n\n /**\n * Optional OCI block data metadata\n */\n oci_block_data_metadata?: OciBlockDataMetadata;\n\n /**\n * Optional Maven block data metadata\n */\n maven_block_data_metadata?: MavenBlockDataMetadata;\n\n /**\n * Map of input shapes keyed by ReadableId\n */\n inputs: Record<ReadableId, InputShape>;\n\n /**\n * Map of output shapes keyed by ReadableId\n */\n outputs: Record<ReadableId, OutputShape>;\n\n /**\n * List of input mapping entries that provide hints for how to connect blocks\n */\n input_mapping_entries: InputMappingEntry[];\n\n /**\n * External recommendations for connecting this block to upstream packages\n */\n external_recommendations: GeneratedBlockExternalRecommendations[];\n\n /**\n * Optional override for the block data add-on\n */\n add_on_override?: unknown;\n\n /**\n * Metadata about each input shape\n */\n input_shape_metadata: Record<ReadableId, InputShapeMetadata>;\n\n /**\n * The type of this block (e.g., ONTOLOGY, FUNCTIONS, etc.)\n */\n block_type: BlockType;\n}\n\n/**\n * Metadata for OCI block data\n */\nexport interface OciBlockDataMetadata {\n oci_directory: string;\n}\n\n/**\n * Metadata for Maven block data\n */\nexport interface MavenBlockDataMetadata {\n maven_directory: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -63,12 +63,18 @@ export class ReadableIdGenerator {
63
63
  static getForTimeSeriesSync(timeSeriesSyncName) {
64
64
  return `time-series-sync-${timeSeriesSyncName}`;
65
65
  }
66
- static getForDataSet(dataSetName) {
66
+ static getForDataset(dataSetName) {
67
67
  return `dataset-datasource-${dataSetName}`;
68
68
  }
69
- static getForDataSetColumn(dataSetName, columnName) {
69
+ static getForDatasetOutput(dataSetName) {
70
+ return `dataset-datasource-output-${dataSetName}`;
71
+ }
72
+ static getForDatasetColumn(dataSetName, columnName) {
70
73
  return `dataset-datasource-column-${dataSetName}-${columnName}`;
71
74
  }
75
+ static getForDatasetColumnOutput(dataSetName, columnName) {
76
+ return `dataset-datasource-column-output-${dataSetName}-${columnName}`;
77
+ }
72
78
  static getForMediaSetView(mediaSetViewName) {
73
79
  return `media-set-view-${mediaSetViewName}`;
74
80
  }
@@ -356,7 +362,7 @@ export class OntologyRidGeneratorImpl {
356
362
 
357
363
  // Register column shapes
358
364
  columnNames.forEach(name => {
359
- this.columnShapes.put(ReadableIdGenerator.getForDataSetColumn(dataSetName, name), {
365
+ this.columnShapes.put(ReadableIdGenerator.getForDatasetColumn(dataSetName, name), {
360
366
  datasource: {
361
367
  type: "dataset",
362
368
  dataset: {
@@ -369,7 +375,7 @@ export class OntologyRidGeneratorImpl {
369
375
  });
370
376
 
371
377
  // Register datasource locator
372
- this.datasourceLocators.put(ReadableIdGenerator.getForDataSet(dataSetName), {
378
+ this.datasourceLocators.put(ReadableIdGenerator.getForDataset(dataSetName), {
373
379
  type: "dataset",
374
380
  dataset: {
375
381
  rid: datasetRid,