@osdk/generator-converters.preview 0.1.0-beta.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.
Files changed (40) hide show
  1. package/build/browser/ActionLogicRuleConverter.js +149 -0
  2. package/build/browser/ActionLogicRuleConverter.js.map +1 -0
  3. package/build/browser/PreviewOntologyIrConverter.js +116 -0
  4. package/build/browser/PreviewOntologyIrConverter.js.map +1 -0
  5. package/build/browser/cli/generate-sdk.js +105 -0
  6. package/build/browser/cli/generate-sdk.js.map +1 -0
  7. package/build/browser/index.js +18 -0
  8. package/build/browser/index.js.map +1 -0
  9. package/build/browser/ridUtils.js +28 -0
  10. package/build/browser/ridUtils.js.map +1 -0
  11. package/build/browser/ridUtils.test.js +43 -0
  12. package/build/browser/ridUtils.test.js.map +1 -0
  13. package/build/cjs/index.cjs +224 -0
  14. package/build/cjs/index.cjs.map +1 -0
  15. package/build/cjs/index.d.cts +32 -0
  16. package/build/esm/ActionLogicRuleConverter.js +149 -0
  17. package/build/esm/ActionLogicRuleConverter.js.map +1 -0
  18. package/build/esm/PreviewOntologyIrConverter.js +116 -0
  19. package/build/esm/PreviewOntologyIrConverter.js.map +1 -0
  20. package/build/esm/cli/generate-sdk.js +105 -0
  21. package/build/esm/cli/generate-sdk.js.map +1 -0
  22. package/build/esm/index.js +18 -0
  23. package/build/esm/index.js.map +1 -0
  24. package/build/esm/ridUtils.js +28 -0
  25. package/build/esm/ridUtils.js.map +1 -0
  26. package/build/esm/ridUtils.test.js +43 -0
  27. package/build/esm/ridUtils.test.js.map +1 -0
  28. package/build/types/ActionLogicRuleConverter.d.ts +6 -0
  29. package/build/types/ActionLogicRuleConverter.d.ts.map +1 -0
  30. package/build/types/PreviewOntologyIrConverter.d.ts +29 -0
  31. package/build/types/PreviewOntologyIrConverter.d.ts.map +1 -0
  32. package/build/types/cli/generate-sdk.d.ts +1 -0
  33. package/build/types/cli/generate-sdk.d.ts.map +1 -0
  34. package/build/types/index.d.ts +1 -0
  35. package/build/types/index.d.ts.map +1 -0
  36. package/build/types/ridUtils.d.ts +5 -0
  37. package/build/types/ridUtils.d.ts.map +1 -0
  38. package/build/types/ridUtils.test.d.ts +1 -0
  39. package/build/types/ridUtils.test.d.ts.map +1 -0
  40. package/package.json +80 -0
@@ -0,0 +1,149 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, 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
+ function buildObjectTypeLookup(ir) {
18
+ if (!ir?.objectTypes) {
19
+ return undefined;
20
+ }
21
+ const byId = new Map();
22
+ const byHyphenated = new Map();
23
+ for (const [key, value] of Object.entries(ir.objectTypes)) {
24
+ const apiName = value.objectType.apiName;
25
+ byId.set(key, apiName);
26
+ byHyphenated.set(apiName.replace(/\./g, "-"), apiName);
27
+ }
28
+ return {
29
+ byId,
30
+ byHyphenated
31
+ };
32
+ }
33
+ function buildInterfaceTypeLookup(ir) {
34
+ if (!ir?.interfaceTypes) {
35
+ return undefined;
36
+ }
37
+ const byId = new Map();
38
+ const byHyphenated = new Map();
39
+ for (const [key, value] of Object.entries(ir.interfaceTypes)) {
40
+ const apiName = value.interfaceType.apiName;
41
+ byId.set(key, apiName);
42
+ byHyphenated.set(apiName.replace(/\./g, "-"), apiName);
43
+ }
44
+ return {
45
+ byId,
46
+ byHyphenated
47
+ };
48
+ }
49
+ function resolveApiName(id, lookup) {
50
+ if (!lookup) {
51
+ return id;
52
+ }
53
+ return lookup.byId.get(id) ?? lookup.byHyphenated.get(id) ?? id;
54
+ }
55
+ function getObjectReferenceType(action, paramKey) {
56
+ const param = action.actionType.metadata.parameters[paramKey];
57
+ if (!param || param.type.type !== "objectReference") {
58
+ throw new Error(`Parameter '${paramKey}' must be an objectReference type`);
59
+ }
60
+ return param.type.objectReference;
61
+ }
62
+
63
+ /**
64
+ * Convert OntologyIrLogicRule to ActionLogicRule for use in ActionTypeFullMetadata.
65
+ */
66
+ export function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
67
+ const objectLookup = buildObjectTypeLookup(ir);
68
+ const interfaceLookup = buildInterfaceTypeLookup(ir);
69
+ switch (irRule.type) {
70
+ case "addObjectRule":
71
+ {
72
+ const r = irRule.addObjectRule;
73
+ const propertyArguments = {};
74
+ for (const [k, v] of Object.entries(r.propertyValues)) {
75
+ propertyArguments[k] = v;
76
+ }
77
+ const result = {
78
+ type: "createObject",
79
+ objectTypeApiName: resolveApiName(r.objectTypeId, objectLookup),
80
+ propertyArguments,
81
+ structPropertyArguments: {}
82
+ };
83
+ return result;
84
+ }
85
+ case "addOrModifyObjectRuleV2":
86
+ {
87
+ const r = irRule.addOrModifyObjectRuleV2;
88
+ const objRef = getObjectReferenceType(action, r.objectToModify);
89
+ const result = {
90
+ type: "createOrModifyObject",
91
+ objectTypeApiName: resolveApiName(objRef.objectTypeId, objectLookup),
92
+ propertyArguments: {},
93
+ structPropertyArguments: {}
94
+ };
95
+ return result;
96
+ }
97
+ case "modifyObjectRule":
98
+ {
99
+ const r = irRule.modifyObjectRule;
100
+ getObjectReferenceType(action, r.objectToModify);
101
+ const result = {
102
+ type: "modifyObject",
103
+ objectToModify: r.objectToModify,
104
+ propertyArguments: {},
105
+ structPropertyArguments: {}
106
+ };
107
+ return result;
108
+ }
109
+ case "deleteObjectRule":
110
+ {
111
+ const r = irRule.deleteObjectRule;
112
+ const result = {
113
+ type: "deleteObject",
114
+ objectToDelete: r.objectToDelete
115
+ };
116
+ return result;
117
+ }
118
+ case "addInterfaceRule":
119
+ {
120
+ const r = irRule.addInterfaceRule;
121
+ const interfaceApiName = resolveApiName(r.interfaceApiName, interfaceLookup);
122
+ return {
123
+ type: "createInterface",
124
+ interfaceTypeApiName: interfaceApiName,
125
+ objectType: interfaceApiName,
126
+ sharedPropertyArguments: {},
127
+ structPropertyArguments: {}
128
+ };
129
+ }
130
+ case "modifyInterfaceRule":
131
+ {
132
+ const r = irRule.modifyInterfaceRule;
133
+ const result = {
134
+ type: "modifyInterface",
135
+ interfaceObjectToModify: r.interfaceObjectToModifyParameter,
136
+ sharedPropertyArguments: {},
137
+ structPropertyArguments: {}
138
+ };
139
+ return result;
140
+ }
141
+ case "addLinkRule":
142
+ throw new Error("addLinkRule is not supported for ActionLogicRule");
143
+ case "deleteLinkRule":
144
+ throw new Error("deleteLinkRule is not supported for ActionLogicRule");
145
+ default:
146
+ throw new Error(`Unsupported logic rule type: ${irRule.type}`);
147
+ }
148
+ }
149
+ //# sourceMappingURL=ActionLogicRuleConverter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionLogicRuleConverter.js","names":["buildObjectTypeLookup","ir","objectTypes","undefined","byId","Map","byHyphenated","key","value","Object","entries","apiName","objectType","set","replace","buildInterfaceTypeLookup","interfaceTypes","interfaceType","resolveApiName","id","lookup","get","getObjectReferenceType","action","paramKey","param","actionType","metadata","parameters","type","Error","objectReference","convertIrLogicRuleToActionLogicRule","irRule","objectLookup","interfaceLookup","r","addObjectRule","propertyArguments","k","v","propertyValues","result","objectTypeApiName","objectTypeId","structPropertyArguments","addOrModifyObjectRuleV2","objRef","objectToModify","modifyObjectRule","deleteObjectRule","objectToDelete","addInterfaceRule","interfaceApiName","interfaceTypeApiName","sharedPropertyArguments","modifyInterfaceRule","interfaceObjectToModify","interfaceObjectToModifyParameter"],"sources":["ActionLogicRuleConverter.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 OntologyIrActionTypeBlockDataV2,\n OntologyIrLogicRule,\n OntologyIrOntologyBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\n\ninterface ApiNameLookup {\n byId: Map<string, string>;\n byHyphenated: Map<string, string>;\n}\n\nfunction buildObjectTypeLookup(\n ir: OntologyIrOntologyBlockDataV2 | undefined,\n): ApiNameLookup | undefined {\n if (!ir?.objectTypes) {\n return undefined;\n }\n const byId = new Map<string, string>();\n const byHyphenated = new Map<string, string>();\n for (const [key, value] of Object.entries(ir.objectTypes)) {\n const apiName = value.objectType.apiName;\n byId.set(key, apiName);\n byHyphenated.set(apiName.replace(/\\./g, \"-\"), apiName);\n }\n return { byId, byHyphenated };\n}\n\nfunction buildInterfaceTypeLookup(\n ir: OntologyIrOntologyBlockDataV2 | undefined,\n): ApiNameLookup | undefined {\n if (!ir?.interfaceTypes) {\n return undefined;\n }\n const byId = new Map<string, string>();\n const byHyphenated = new Map<string, string>();\n for (const [key, value] of Object.entries(ir.interfaceTypes)) {\n const apiName = value.interfaceType.apiName;\n byId.set(key, apiName);\n byHyphenated.set(apiName.replace(/\\./g, \"-\"), apiName);\n }\n return { byId, byHyphenated };\n}\n\nfunction resolveApiName(id: string, lookup: ApiNameLookup | undefined): string {\n if (!lookup) {\n return id;\n }\n return lookup.byId.get(id) ?? lookup.byHyphenated.get(id) ?? id;\n}\n\nfunction getObjectReferenceType(\n action: OntologyIrActionTypeBlockDataV2,\n paramKey: string,\n): { objectTypeId: string } {\n const param = action.actionType.metadata.parameters[paramKey];\n if (!param || param.type.type !== \"objectReference\") {\n throw new Error(\n `Parameter '${paramKey}' must be an objectReference type`,\n );\n }\n return param.type.objectReference;\n}\n\n/**\n * Convert OntologyIrLogicRule to ActionLogicRule for use in ActionTypeFullMetadata.\n */\nexport function convertIrLogicRuleToActionLogicRule(\n irRule: OntologyIrLogicRule,\n action: OntologyIrActionTypeBlockDataV2,\n ir?: OntologyIrOntologyBlockDataV2,\n): Ontologies.ActionLogicRule {\n const objectLookup = buildObjectTypeLookup(ir);\n const interfaceLookup = buildInterfaceTypeLookup(ir);\n\n switch (irRule.type) {\n case \"addObjectRule\": {\n const r = irRule.addObjectRule;\n const propertyArguments: Record<\n Ontologies.PropertyApiName,\n Ontologies.LogicRuleArgument\n > = {};\n for (const [k, v] of Object.entries(r.propertyValues)) {\n propertyArguments[k] = v as Ontologies.LogicRuleArgument;\n }\n const result: Ontologies.CreateObjectLogicRule & {\n type: \"createObject\";\n } = {\n type: \"createObject\",\n objectTypeApiName: resolveApiName(r.objectTypeId, objectLookup),\n propertyArguments,\n structPropertyArguments: {},\n };\n return result;\n }\n\n case \"addOrModifyObjectRuleV2\": {\n const r = irRule.addOrModifyObjectRuleV2;\n const objRef = getObjectReferenceType(action, r.objectToModify);\n const result: Ontologies.CreateOrModifyObjectLogicRule & {\n type: \"createOrModifyObject\";\n } = {\n type: \"createOrModifyObject\",\n objectTypeApiName: resolveApiName(objRef.objectTypeId, objectLookup),\n propertyArguments: {},\n structPropertyArguments: {},\n };\n return result;\n }\n\n case \"modifyObjectRule\": {\n const r = irRule.modifyObjectRule;\n getObjectReferenceType(action, r.objectToModify);\n const result: Ontologies.ModifyObjectLogicRule & {\n type: \"modifyObject\";\n } = {\n type: \"modifyObject\",\n objectToModify: r.objectToModify,\n propertyArguments: {},\n structPropertyArguments: {},\n };\n return result;\n }\n\n case \"deleteObjectRule\": {\n const r = irRule.deleteObjectRule;\n const result: Ontologies.DeleteObjectLogicRule & {\n type: \"deleteObject\";\n } = {\n type: \"deleteObject\",\n objectToDelete: r.objectToDelete,\n };\n return result;\n }\n\n case \"addInterfaceRule\": {\n const r = irRule.addInterfaceRule;\n const interfaceApiName = resolveApiName(\n r.interfaceApiName,\n interfaceLookup,\n );\n const result: Ontologies.CreateInterfaceLogicRule & {\n type: \"createInterface\";\n } = {\n type: \"createInterface\",\n interfaceTypeApiName: interfaceApiName,\n objectType: interfaceApiName,\n sharedPropertyArguments: {},\n structPropertyArguments: {},\n };\n return result;\n }\n\n case \"modifyInterfaceRule\": {\n const r = irRule.modifyInterfaceRule;\n const result: Ontologies.ModifyInterfaceLogicRule & {\n type: \"modifyInterface\";\n } = {\n type: \"modifyInterface\",\n interfaceObjectToModify: r.interfaceObjectToModifyParameter,\n sharedPropertyArguments: {},\n structPropertyArguments: {},\n };\n return result;\n }\n\n case \"addLinkRule\":\n throw new Error(\"addLinkRule is not supported for ActionLogicRule\");\n\n case \"deleteLinkRule\":\n throw new Error(\"deleteLinkRule is not supported for ActionLogicRule\");\n\n default:\n throw new Error(\n `Unsupported logic rule type: ${(irRule as { type: string }).type}`,\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,qBAAqBA,CAC5BC,EAA6C,EAClB;EAC3B,IAAI,CAACA,EAAE,EAAEC,WAAW,EAAE;IACpB,OAAOC,SAAS;EAClB;EACA,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACtC,MAAMC,YAAY,GAAG,IAAID,GAAG,CAAiB,CAAC;EAC9C,KAAK,MAAM,CAACE,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,EAAE,CAACC,WAAW,CAAC,EAAE;IACzD,MAAMS,OAAO,GAAGH,KAAK,CAACI,UAAU,CAACD,OAAO;IACxCP,IAAI,CAACS,GAAG,CAACN,GAAG,EAAEI,OAAO,CAAC;IACtBL,YAAY,CAACO,GAAG,CAACF,OAAO,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAEH,OAAO,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F","ignoreList":[]}
@@ -0,0 +1,116 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, 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 { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
18
+ import { convertIrLogicRuleToActionLogicRule } from "./ActionLogicRuleConverter.js";
19
+ import { toUuid } from "./ridUtils.js";
20
+
21
+ /**
22
+ * Extended return type that uses ActionTypeFullMetadata instead of ActionTypeV2.
23
+ */
24
+
25
+ /**
26
+ * Preview converter that extends the base OntologyIrToFullMetadataConverter
27
+ * to return ActionTypeFullMetadata with fullLogicRules instead of ActionTypeV2.
28
+ */
29
+ export class PreviewOntologyIrConverter {
30
+ /**
31
+ * Main entry point - converts IR to full metadata with enhanced action types.
32
+ * Returns ActionTypeFullMetadata which includes fullLogicRules.
33
+ */
34
+ static getPreviewFullMetadataFromIr(ir) {
35
+ const baseMetadata = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ir);
36
+ const actionTypes = this.convertActionTypesWithFullLogicRules(Object.values(ir.actionTypes), ir);
37
+
38
+ // Post-process object types to use UUID-based RIDs
39
+ const objectTypes = this.convertObjectTypesWithUuidRids(baseMetadata.objectTypes);
40
+ return {
41
+ ...baseMetadata,
42
+ objectTypes,
43
+ actionTypes,
44
+ ontology: {
45
+ apiName: "ontology",
46
+ rid: "ri.ontology.main.ontology.0",
47
+ displayName: "ontology",
48
+ description: "local ontology"
49
+ }
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Post-process object types to use UUID-based RIDs for properties.
55
+ */
56
+ static convertObjectTypesWithUuidRids(objectTypes) {
57
+ const result = {};
58
+ for (const [apiName, fullMetadata] of Object.entries(objectTypes)) {
59
+ const objectType = fullMetadata.objectType;
60
+ const properties = {};
61
+ for (const [propKey, prop] of Object.entries(objectType.properties)) {
62
+ properties[propKey] = {
63
+ ...prop,
64
+ rid: `ri.ontology.main.property.${toUuid(apiName + "." + propKey)}`
65
+ };
66
+ }
67
+ result[apiName] = {
68
+ ...fullMetadata,
69
+ objectType: {
70
+ ...objectType,
71
+ rid: `ri.ontology.main.object-type.${toUuid(apiName)}`,
72
+ properties
73
+ }
74
+ };
75
+ }
76
+ return result;
77
+ }
78
+
79
+ /**
80
+ * Convert IR action types to ActionTypeFullMetadata format.
81
+ * Uses base converter for parameters and operations, adds fullLogicRules.
82
+ */
83
+ static convertActionTypesWithFullLogicRules(actions, ir) {
84
+ const result = {};
85
+ for (const action of actions) {
86
+ const metadata = action.actionType.metadata;
87
+ const actionType = {
88
+ rid: `ri.ontology.main.action-type.${toUuid(metadata.apiName)}`,
89
+ apiName: metadata.apiName,
90
+ displayName: metadata.displayMetadata.displayName,
91
+ description: metadata.displayMetadata.description,
92
+ parameters: OntologyIrToFullMetadataConverter.getOsdkActionParameters(action),
93
+ operations: OntologyIrToFullMetadataConverter.getOsdkActionOperations(action),
94
+ status: this.convertActionTypeStatus(metadata.status)
95
+ };
96
+ result[actionType.apiName] = {
97
+ actionType,
98
+ fullLogicRules: action.actionType.actionTypeLogic.logic.rules.map(rule => convertIrLogicRuleToActionLogicRule(rule, action, ir))
99
+ };
100
+ }
101
+ return result;
102
+ }
103
+ static convertActionTypeStatus(status) {
104
+ switch (status.type) {
105
+ case "active":
106
+ return "ACTIVE";
107
+ case "deprecated":
108
+ return "DEPRECATED";
109
+ case "experimental":
110
+ return "EXPERIMENTAL";
111
+ case "example":
112
+ throw new Error("Example status cannot be mapped to ActionTypeStatus");
113
+ }
114
+ }
115
+ }
116
+ //# sourceMappingURL=PreviewOntologyIrConverter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewOntologyIrConverter.js","names":["OntologyIrToFullMetadataConverter","convertIrLogicRuleToActionLogicRule","toUuid","PreviewOntologyIrConverter","getPreviewFullMetadataFromIr","ir","baseMetadata","getFullMetadataFromIr","actionTypes","convertActionTypesWithFullLogicRules","Object","values","objectTypes","convertObjectTypesWithUuidRids","ontology","apiName","rid","displayName","description","result","fullMetadata","entries","objectType","properties","propKey","prop","actions","action","metadata","actionType","displayMetadata","parameters","getOsdkActionParameters","operations","getOsdkActionOperations","status","convertActionTypeStatus","fullLogicRules","actionTypeLogic","logic","rules","map","rule","type","Error"],"sources":["PreviewOntologyIrConverter.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 OntologyIrActionTypeBlockDataV2,\n OntologyIrActionTypeStatus,\n OntologyIrOntologyBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { convertIrLogicRuleToActionLogicRule } from \"./ActionLogicRuleConverter.js\";\nimport { toUuid } from \"./ridUtils.js\";\n\n/**\n * Extended return type that uses ActionTypeFullMetadata instead of ActionTypeV2.\n */\nexport interface PreviewOntologyFullMetadata\n extends Omit<Ontologies.OntologyFullMetadata, \"actionTypes\">\n{\n actionTypes: Record<string, Ontologies.ActionTypeFullMetadata>;\n}\n\n/**\n * Preview converter that extends the base OntologyIrToFullMetadataConverter\n * to return ActionTypeFullMetadata with fullLogicRules instead of ActionTypeV2.\n */\nexport class PreviewOntologyIrConverter {\n /**\n * Main entry point - converts IR to full metadata with enhanced action types.\n * Returns ActionTypeFullMetadata which includes fullLogicRules.\n */\n static getPreviewFullMetadataFromIr(\n ir: OntologyIrOntologyBlockDataV2,\n ): PreviewOntologyFullMetadata {\n const baseMetadata = OntologyIrToFullMetadataConverter\n .getFullMetadataFromIr(ir);\n\n const actionTypes = this.convertActionTypesWithFullLogicRules(\n Object.values(ir.actionTypes),\n ir,\n );\n\n // Post-process object types to use UUID-based RIDs\n const objectTypes = this.convertObjectTypesWithUuidRids(\n baseMetadata.objectTypes,\n );\n\n return {\n ...baseMetadata,\n objectTypes,\n actionTypes,\n ontology: {\n apiName: \"ontology\",\n rid: \"ri.ontology.main.ontology.0\",\n displayName: \"ontology\",\n description: \"local ontology\",\n },\n };\n }\n\n /**\n * Post-process object types to use UUID-based RIDs for properties.\n */\n private static convertObjectTypesWithUuidRids(\n objectTypes: Record<string, Ontologies.ObjectTypeFullMetadata>,\n ): Record<string, Ontologies.ObjectTypeFullMetadata> {\n const result: Record<string, Ontologies.ObjectTypeFullMetadata> = {};\n\n for (const [apiName, fullMetadata] of Object.entries(objectTypes)) {\n const objectType = fullMetadata.objectType;\n const properties: Record<string, Ontologies.PropertyV2> = {};\n\n for (const [propKey, prop] of Object.entries(objectType.properties)) {\n properties[propKey] = {\n ...prop,\n rid: `ri.ontology.main.property.${toUuid(apiName + \".\" + propKey)}`,\n };\n }\n\n result[apiName] = {\n ...fullMetadata,\n objectType: {\n ...objectType,\n rid: `ri.ontology.main.object-type.${toUuid(apiName)}`,\n properties,\n },\n };\n }\n\n return result;\n }\n\n /**\n * Convert IR action types to ActionTypeFullMetadata format.\n * Uses base converter for parameters and operations, adds fullLogicRules.\n */\n private static convertActionTypesWithFullLogicRules(\n actions: OntologyIrActionTypeBlockDataV2[],\n ir: OntologyIrOntologyBlockDataV2,\n ): Record<string, Ontologies.ActionTypeFullMetadata> {\n const result: Record<string, Ontologies.ActionTypeFullMetadata> = {};\n\n for (const action of actions) {\n const metadata = action.actionType.metadata;\n const actionType: Ontologies.ActionTypeV2 = {\n rid: `ri.ontology.main.action-type.${toUuid(metadata.apiName)}`,\n apiName: metadata.apiName,\n displayName: metadata.displayMetadata.displayName,\n description: metadata.displayMetadata.description,\n parameters: OntologyIrToFullMetadataConverter.getOsdkActionParameters(\n action,\n ),\n operations: OntologyIrToFullMetadataConverter.getOsdkActionOperations(\n action,\n ),\n status: this.convertActionTypeStatus(metadata.status),\n };\n\n result[actionType.apiName] = {\n actionType,\n fullLogicRules: action.actionType.actionTypeLogic.logic.rules.map(\n rule => convertIrLogicRuleToActionLogicRule(rule, action, ir),\n ),\n };\n }\n\n return result;\n }\n\n private static convertActionTypeStatus(\n status: OntologyIrActionTypeStatus,\n ): \"ACTIVE\" | \"DEPRECATED\" | \"EXPERIMENTAL\" {\n switch (status.type) {\n case \"active\":\n return \"ACTIVE\";\n case \"deprecated\":\n return \"DEPRECATED\";\n case \"experimental\":\n return \"EXPERIMENTAL\";\n case \"example\":\n throw new Error(\n \"Example status cannot be mapped to ActionTypeStatus\",\n );\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,mCAAmC,QAAQ,+BAA+B;AACnF,SAASC,MAAM,QAAQ,eAAe;;AAEtC;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,CAAC;EACtC;AACF;AACA;AACA;EACE,OAAOC,4BAA4BA,CACjCC,EAAiC,EACJ;IAC7B,MAAMC,YAAY,GAAGN,iCAAiC,CACnDO,qBAAqB,CAACF,EAAE,CAAC;IAE5B,MAAMG,WAAW,GAAG,IAAI,CAACC,oCAAoC,CAC3DC,MAAM,CAACC,MAAM,CAACN,EAAE,CAACG,WAAW,C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,GAAGD,MAAM,CAACE,UAAU,CAACD,QAAQ;MAC3C,MAAMC,UAAmC,GAAG;QAC1Cb,GAAG,EAAE,gCAAgCd,MAAM,CAAC0B,QAAQ,CAACb,OAAO,CAAC,EAAE;QAC/DA,OAAO,EAAEa,QAAQ,CAACb,OAAO;QACzBE,WAAW,EAAEW,QAAQ,CAACE,eAAe,CAACb,WAAW;QACjDC,WAAW,EAAEU,QAAQ,CAACE,eAAe,CAACZ,WAAW;QACjDa,UAAU,EAAE/B,iCAAiC,CAACgC,uBAAuB,CACnEL,MACF,CAAC;QACDM,UAAU,EAAEjC,iCAAiC,CAACkC,uBAAuB,CACnEP,MACF,CAAC;QACDQ,MAAM,EAAE,IAAI,CAACC,uBAAuB,CAACR,QAAQ,CAACO,MAAM;MACtD,CAAC;MAEDhB,MAAM,CAACU,UAAU,CAACd,OAAO,CAAC,GAAG;QAC3Bc,UAAU;QACVQ,cAAc,EAAEV,MAAM,CAACE,UAAU,CAACS,eAAe,CAACC,KAAK,CAACC,KAAK,CAACC,GAAG,CAC/DC,IAAI,IAAIzC,mCAAmC,CAACyC,IAAI,EAAEf,MAAM,EAAEtB,EAAE,CAC9D;MACF,CAAC;IACH;IAEA,OAAOc,MAAM;EACf;EAEA,OAAeiB,uBAAuBA,CACpCD,MAAkC,EACQ;IAC1C,QAAQA,MAAM,CAACQ,IAAI;MACjB,KAAK,QAAQ;QACX,OAAO,QAAQ;MACjB,KAAK,YAAY;QACf,OAAO,YAAY;MACrB,KAAK,cAAc;QACjB,OAAO,cAAc;MACvB,KAAK,SAAS;QACZ,MAAM,IAAIC,KAAK,CACb,qDACF,CAAC;IACL;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { generateClientSdkVersionTwoPointZero } from "@osdk/generator";
18
+ import * as fs from "node:fs/promises";
19
+ import * as path from "node:path";
20
+ import { PreviewOntologyIrConverter } from "../PreviewOntologyIrConverter.js";
21
+ const USAGE = `Usage: generate-sdk <input-ontology-ir.json> <package-name> <package-version> <output-dir>
22
+
23
+ Arguments:
24
+ input-ontology-ir.json Path to the OntologyIR JSON file
25
+ package-name Name for the generated SDK package
26
+ package-version Version string for the generated SDK
27
+ output-dir Directory where the SDK will be generated`;
28
+ async function main() {
29
+ const args = process.argv.slice(2);
30
+ if (args.length < 4) {
31
+ // eslint-disable-next-line no-console
32
+ console.error(USAGE);
33
+ process.exit(1);
34
+ }
35
+ const [inputArg, packageName, packageVersion, outputArg] = args;
36
+ const inputFile = path.resolve(inputArg);
37
+ const outputDir = path.resolve(outputArg);
38
+
39
+ // Validate input file exists
40
+ try {
41
+ await fs.access(inputFile);
42
+ } catch {
43
+ // eslint-disable-next-line no-console
44
+ console.error(`Error: Input file does not exist: ${inputFile}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ // eslint-disable-next-line no-console
49
+ console.log(`Converting ${inputFile}...`);
50
+ const fileContent = await fs.readFile(inputFile, "utf-8");
51
+ let irJson;
52
+ try {
53
+ const parsed = JSON.parse(fileContent);
54
+ // Handle both wrapped (ontology.objectTypes) and unwrapped (objectTypes) formats
55
+ irJson = parsed.ontology ?? parsed;
56
+ } catch (e) {
57
+ // eslint-disable-next-line no-console
58
+ console.error(`Error: Failed to parse JSON from ${inputFile}`);
59
+ process.exit(1);
60
+ }
61
+ const previewMetadata = PreviewOntologyIrConverter.getPreviewFullMetadataFromIr(irJson);
62
+
63
+ // Convert ActionTypeFullMetadata to ActionTypeV2 for generator compatibility
64
+ const metadata = {
65
+ ...previewMetadata,
66
+ actionTypes: Object.fromEntries(Object.entries(previewMetadata.actionTypes).map(([key, fullMeta]) => [key, fullMeta.actionType]))
67
+ };
68
+ const fullOutputDir = path.join(outputDir, packageName);
69
+ await fs.mkdir(fullOutputDir, {
70
+ recursive: true
71
+ });
72
+ // eslint-disable-next-line no-console
73
+ console.log(`Generating SDK to ${fullOutputDir}...`);
74
+ await generateClientSdkVersionTwoPointZero(metadata, `osdk-generator/${packageVersion} (from-ir)`, {
75
+ async writeFile(filePath, contents) {
76
+ const fullPath = path.isAbsolute(filePath) ? filePath : path.join(fullOutputDir, filePath);
77
+ await fs.mkdir(path.dirname(fullPath), {
78
+ recursive: true
79
+ });
80
+ await fs.writeFile(fullPath, contents, "utf-8");
81
+ },
82
+ async mkdir(dirPath) {
83
+ const fullPath = path.isAbsolute(dirPath) ? dirPath : path.join(fullOutputDir, dirPath);
84
+ await fs.mkdir(fullPath, {
85
+ recursive: true
86
+ });
87
+ },
88
+ async readdir(dirPath) {
89
+ return fs.readdir(dirPath);
90
+ }
91
+ }, fullOutputDir, "module", new Map(), new Map(), new Map(), false, []);
92
+ const metadataPath = path.join(fullOutputDir, "ontology-metadata.json");
93
+ await fs.writeFile(metadataPath, JSON.stringify(previewMetadata, null, 2), "utf-8");
94
+
95
+ // eslint-disable-next-line no-console
96
+ console.log(`Wrote ${metadataPath}`);
97
+ // eslint-disable-next-line no-console
98
+ console.log("Done!");
99
+ }
100
+ main().catch(err => {
101
+ // eslint-disable-next-line no-console
102
+ console.error("Error:", err instanceof Error ? err.message : err);
103
+ process.exit(1);
104
+ });
105
+ //# sourceMappingURL=generate-sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-sdk.js","names":["generateClientSdkVersionTwoPointZero","fs","path","PreviewOntologyIrConverter","USAGE","main","args","process","argv","slice","length","console","error","exit","inputArg","packageName","packageVersion","outputArg","inputFile","resolve","outputDir","access","log","fileContent","readFile","irJson","parsed","JSON","parse","ontology","e","previewMetadata","getPreviewFullMetadataFromIr","metadata","actionTypes","Object","fromEntries","entries","map","key","fullMeta","actionType","fullOutputDir","join","mkdir","recursive","writeFile","filePath","contents","fullPath","isAbsolute","dirname","dirPath","readdir","Map","metadataPath","stringify","catch","err","Error","message"],"sources":["generate-sdk.ts"],"sourcesContent":["#!/usr/bin/env node\n/*\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 { generateClientSdkVersionTwoPointZero } from \"@osdk/generator\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { PreviewOntologyIrConverter } from \"../PreviewOntologyIrConverter.js\";\n\nconst USAGE =\n `Usage: generate-sdk <input-ontology-ir.json> <package-name> <package-version> <output-dir>\n\nArguments:\n input-ontology-ir.json Path to the OntologyIR JSON file\n package-name Name for the generated SDK package\n package-version Version string for the generated SDK\n output-dir Directory where the SDK will be generated`;\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n\n if (args.length < 4) {\n // eslint-disable-next-line no-console\n console.error(USAGE);\n process.exit(1);\n }\n\n const [inputArg, packageName, packageVersion, outputArg] = args;\n const inputFile = path.resolve(inputArg);\n const outputDir = path.resolve(outputArg);\n\n // Validate input file exists\n try {\n await fs.access(inputFile);\n } catch {\n // eslint-disable-next-line no-console\n console.error(`Error: Input file does not exist: ${inputFile}`);\n process.exit(1);\n }\n\n // eslint-disable-next-line no-console\n console.log(`Converting ${inputFile}...`);\n\n const fileContent = await fs.readFile(inputFile, \"utf-8\");\n let irJson: unknown;\n try {\n const parsed = JSON.parse(fileContent);\n // Handle both wrapped (ontology.objectTypes) and unwrapped (objectTypes) formats\n irJson = parsed.ontology ?? parsed;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.error(`Error: Failed to parse JSON from ${inputFile}`);\n process.exit(1);\n }\n\n const previewMetadata = PreviewOntologyIrConverter\n .getPreviewFullMetadataFromIr(\n irJson as Parameters<\n typeof PreviewOntologyIrConverter.getPreviewFullMetadataFromIr\n >[0],\n );\n\n // Convert ActionTypeFullMetadata to ActionTypeV2 for generator compatibility\n const metadata = {\n ...previewMetadata,\n actionTypes: Object.fromEntries(\n Object.entries(previewMetadata.actionTypes).map(([key, fullMeta]) => [\n key,\n fullMeta.actionType,\n ]),\n ),\n };\n\n const fullOutputDir = path.join(outputDir, packageName);\n await fs.mkdir(fullOutputDir, { recursive: true });\n\n const hostFs = {\n async writeFile(filePath: string, contents: string): Promise<void> {\n const fullPath = path.isAbsolute(filePath)\n ? filePath\n : path.join(fullOutputDir, filePath);\n await fs.mkdir(path.dirname(fullPath), { recursive: true });\n await fs.writeFile(fullPath, contents, \"utf-8\");\n },\n async mkdir(dirPath: string): Promise<void> {\n const fullPath = path.isAbsolute(dirPath)\n ? dirPath\n : path.join(fullOutputDir, dirPath);\n await fs.mkdir(fullPath, { recursive: true });\n },\n async readdir(dirPath: string): Promise<string[]> {\n return fs.readdir(dirPath);\n },\n };\n\n // eslint-disable-next-line no-console\n console.log(`Generating SDK to ${fullOutputDir}...`);\n\n await generateClientSdkVersionTwoPointZero(\n metadata,\n `osdk-generator/${packageVersion} (from-ir)`,\n hostFs,\n fullOutputDir,\n \"module\",\n new Map(),\n new Map(),\n new Map(),\n false,\n [],\n );\n\n const metadataPath = path.join(fullOutputDir, \"ontology-metadata.json\");\n await fs.writeFile(\n metadataPath,\n JSON.stringify(previewMetadata, null, 2),\n \"utf-8\",\n );\n\n // eslint-disable-next-line no-console\n console.log(`Wrote ${metadataPath}`);\n // eslint-disable-next-line no-console\n console.log(\"Done!\");\n}\n\nmain().catch((err: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Error:\", err instanceof Error ? err.message : err);\n process.exit(1);\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,oCAAoC,QAAQ,iBAAiB;AACtE,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,0BAA0B,QAAQ,kCAAkC;AAE7E,MAAMC,KAAK,GACT;AACF;AACA;AACA;AACA;AACA;AACA,oEAAoE;AAEpE,eAAeC,IAAIA,CAAA,EAAkB;EACnC,MAAMC,IAAI,GAAGC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC;EAElC,IAAIH,IAAI,CAACI,MAAM,GAAG,CAAC,EAAE;IACnB;IACAC,OAAO,CAACC,KAAK,CAACR,KAAK,CAAC;IACpBG,OAAO,CAACM,IAAI,CAAC,CAAC,CAAC;EACjB;EAEA,MAAM,CAACC,QAAQ,EAAEC,WAAW,EAAEC,cAAc,EAAEC,SAAS,CAAC,GAAGX,IAAI;EAC/D,MAAMY,SAAS,GAAGhB,IAAI,CAACiB,OAAO,CAACL,QAAQ,CAAC;EACxC,MAAMM,SAAS,GAAGlB,IAAI,CAACiB,OAAO,CAACF,SAAS,CAAC;;EAEzC;EACA,IAAI;IACF,MAAMhB,EAAE,CAACoB,MAAM,CAACH,SAAS,CAAC;EAC5B,CAAC,CAAC,MAAM;IACN;IACAP,OAAO,CAACC,KAAK,CAAC,qCAAqCM,SAAS,EAAE,CAAC;IAC/DX,OAAO,CAACM,IAAI,CAAC,CAAC,CAAC;EACjB;;EAEA;EACAF,OAAO,CAACW,GAAG,CAAC,cAAcJ,SAAS,KAAK,CAAC;EAEzC,MAAMK,WAAW,GAAG,MAAMtB,EAAE,CAACuB,QAAQ,CAACN,SAAS,EAAE,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C,CAAC;AACjB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, 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
+ export { PreviewOntologyIrConverter } from "./PreviewOntologyIrConverter.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["PreviewOntologyIrConverter"],"sources":["index.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\nexport {\n type PreviewOntologyFullMetadata,\n PreviewOntologyIrConverter,\n} from \"./PreviewOntologyIrConverter.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,0BAA0B,QACrB,iCAAiC","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, 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 { createHash } from "node:crypto";
18
+
19
+ /**
20
+ * Generate a deterministic UUID from a string.
21
+ * Uses SHA-256 hash truncated to UUID format for consistency.
22
+ */
23
+ export function toUuid(str) {
24
+ const hashHex = createHash("sha256").update(str).digest("hex");
25
+ // Format as UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
26
+ return `${hashHex.slice(0, 8)}-${hashHex.slice(8, 12)}-${hashHex.slice(12, 16)}-${hashHex.slice(16, 20)}-${hashHex.slice(20, 32)}`;
27
+ }
28
+ //# sourceMappingURL=ridUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ridUtils.js","names":["createHash","toUuid","str","hashHex","update","digest","slice"],"sources":["ridUtils.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 { createHash } from \"node:crypto\";\n\n/**\n * Generate a deterministic UUID from a string.\n * Uses SHA-256 hash truncated to UUID format for consistency.\n */\nexport function toUuid(str: string): string {\n const hashHex = createHash(\"sha256\").update(str).digest(\"hex\");\n // Format as UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n return `${hashHex.slice(0, 8)}-${hashHex.slice(8, 12)}-${\n hashHex.slice(12, 16)\n }-${hashHex.slice(16, 20)}-${hashHex.slice(20, 32)}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,aAAa;;AAExC;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,GAAW,EAAU;EAC1C,MAAMC,OAAO,GAAGH,UAAU,CAAC,QAAQ,CAAC,CAACI,MAAM,CAACF,GAAG,CAAC,CAACG,MAAM,CAAC,KAAK,CAAC;EAC9D;EACA,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAIH,OAAO,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IACnDH,OAAO,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IACnBH,OAAO,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAIH,OAAO,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE;AACtD","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, 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 { describe, expect, it } from "vitest";
18
+ import { toUuid } from "./ridUtils.js";
19
+ describe("ridUtils", () => {
20
+ describe("toUuid", () => {
21
+ it("returns a valid UUID format", () => {
22
+ const result = toUuid("test-string");
23
+ // UUID format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
24
+ expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
25
+ });
26
+ it("is deterministic - same input produces same output", () => {
27
+ const input = "my-deterministic-input";
28
+ const result1 = toUuid(input);
29
+ const result2 = toUuid(input);
30
+ expect(result1).toBe(result2);
31
+ });
32
+ it("produces different outputs for different inputs", () => {
33
+ const result1 = toUuid("input-1");
34
+ const result2 = toUuid("input-2");
35
+ expect(result1).not.toBe(result2);
36
+ });
37
+ it("handles empty string", () => {
38
+ const result = toUuid("");
39
+ expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
40
+ });
41
+ });
42
+ });
43
+ //# sourceMappingURL=ridUtils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ridUtils.test.js","names":["describe","expect","it","toUuid","result","toMatch","input","result1","result2","toBe","not"],"sources":["ridUtils.test.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 { describe, expect, it } from \"vitest\";\nimport { toUuid } from \"./ridUtils.js\";\n\ndescribe(\"ridUtils\", () => {\n describe(\"toUuid\", () => {\n it(\"returns a valid UUID format\", () => {\n const result = toUuid(\"test-string\");\n // UUID format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n expect(result).toMatch(\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,\n );\n });\n\n it(\"is deterministic - same input produces same output\", () => {\n const input = \"my-deterministic-input\";\n const result1 = toUuid(input);\n const result2 = toUuid(input);\n expect(result1).toBe(result2);\n });\n\n it(\"produces different outputs for different inputs\", () => {\n const result1 = toUuid(\"input-1\");\n const result2 = toUuid(\"input-2\");\n expect(result1).not.toBe(result2);\n });\n\n it(\"handles empty string\", () => {\n const result = toUuid(\"\");\n expect(result).toMatch(\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,\n );\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,MAAM,QAAQ,eAAe;AAEtCH,QAAQ,CAAC,UAAU,EAAE,MAAM;EACzBA,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACvBE,EAAE,CAAC,6BAA6B,EAAE,MAAM;MACtC,MAAME,MAAM,GAAGD,MAAM,CAAC,aAAa,CAAC;MACpC;MACAF,MAAM,CAACG,MAAM,CAAC,CAACC,OAAO,CACpB,gEACF,CAAC;IACH,CAAC,CAAC;IAEFH,EAAE,CAAC,oDAAoD,EAAE,MAAM;MAC7D,MAAMI,KAAK,GAAG,wBAAwB;MACtC,MAAMC,OAAO,GAAGJ,MAAM,CAACG,KAAK,CAAC;MAC7B,MAAME,OAAO,GAAGL,MAAM,CAACG,KAAK,CAAC;MAC7BL,MAAM,CAACM,OAAO,CAAC,CAACE,IAAI,CAACD,OAAO,CAAC;IAC/B,CAAC,CAAC;IAEFN,EAAE,CAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAMK,OAAO,GAAGJ,MAAM,CAAC,SAAS,CAAC;MACjC,MAAMK,OAAO,GAAGL,MAAM,CAAC,SAAS,CAAC;MACjCF,MAAM,CAACM,OAAO,CAAC,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