@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,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,IAA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e,EAAE,IAAI,EAAE,CAAC,CAAC,EACxC,OACF,CAAC;;EAED;EACApB,OAAO,CAACW,GAAG,CAAC,SAASiC,YAAY,EAAE,CAAC;EACpC;EACA5C,OAAO,CAACW,GAAG,CAAC,OAAO,CAAC;AACtB;AAEAjB,IAAI,CAAC,CAAC,CAACoD,KAAK,CAAEC,GAAY,IAAK;EAC7B;EACA/C,OAAO,CAACC,KAAK,CAAC,QAAQ,EAAE8C,GAAG,YAAYC,KAAK,GAAGD,GAAG,CAACE,OAAO,GAAGF,GAAG,CAAC;EACjEnD,OAAO,CAACM,IAAI,CAAC,CAAC,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,CAACG,GAAG,CAACD,IAAI,CAACD,OAAO,CAAC;IACnC,CAAC,CAAC;IAEFN,EAAE,CAAC,sBAAsB,EAAE,MAAM;MAC/B,MAAME,MAAM,GAAGD,MAAM,CAAC,EAAE,CAAC;MACzBF,MAAM,CAACG,MAAM,CAAC,CAACC,OAAO,CACpB,gEACF,CAAC;IACH,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { OntologyIrActionTypeBlockDataV2, OntologyIrLogicRule, OntologyIrOntologyBlockDataV2 } from "@osdk/client.unstable";
2
+ import type * as Ontologies from "@osdk/foundry.ontologies";
3
+ /**
4
+ * Convert OntologyIrLogicRule to ActionLogicRule for use in ActionTypeFullMetadata.
5
+ */
6
+ export declare function convertIrLogicRuleToActionLogicRule(irRule: OntologyIrLogicRule, action: OntologyIrActionTypeBlockDataV2, ir?: OntologyIrOntologyBlockDataV2): Ontologies.ActionLogicRule;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,iCACA,qBACA,qCACK,uBAAwB;AAC/B,iBAAiB,gBAAgB,0BAA2B;;;;AA8D5D,OAAO,iBAAS,oCACdA,QAAQ,qBACRC,QAAQ,iCACRC,KAAK,gCACJ,WAAW","names":["irRule: OntologyIrLogicRule","action: OntologyIrActionTypeBlockDataV2","ir?: OntologyIrOntologyBlockDataV2"],"sources":["../../src/ActionLogicRuleConverter.ts"],"version":3,"file":"ActionLogicRuleConverter.d.ts"}
@@ -0,0 +1,29 @@
1
+ import type { OntologyIrOntologyBlockDataV2 } from "@osdk/client.unstable";
2
+ import type * as Ontologies from "@osdk/foundry.ontologies";
3
+ /**
4
+ * Extended return type that uses ActionTypeFullMetadata instead of ActionTypeV2.
5
+ */
6
+ export interface PreviewOntologyFullMetadata extends Omit<Ontologies.OntologyFullMetadata, "actionTypes"> {
7
+ actionTypes: Record<string, Ontologies.ActionTypeFullMetadata>;
8
+ }
9
+ /**
10
+ * Preview converter that extends the base OntologyIrToFullMetadataConverter
11
+ * to return ActionTypeFullMetadata with fullLogicRules instead of ActionTypeV2.
12
+ */
13
+ export declare class PreviewOntologyIrConverter {
14
+ /**
15
+ * Main entry point - converts IR to full metadata with enhanced action types.
16
+ * Returns ActionTypeFullMetadata which includes fullLogicRules.
17
+ */
18
+ static getPreviewFullMetadataFromIr(ir: OntologyIrOntologyBlockDataV2): PreviewOntologyFullMetadata;
19
+ /**
20
+ * Post-process object types to use UUID-based RIDs for properties.
21
+ */
22
+ private static convertObjectTypesWithUuidRids;
23
+ /**
24
+ * Convert IR action types to ActionTypeFullMetadata format.
25
+ * Uses base converter for parameters and operations, adds fullLogicRules.
26
+ */
27
+ private static convertActionTypesWithFullLogicRules;
28
+ private static convertActionTypeStatus;
29
+ }
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAGE,qCACK,uBAAwB;AAC/B,iBAAiB,gBAAgB,0BAA2B;;;;AAQ5D,iBAAiB,oCACP,KAAK,WAAW,sBAAsB,eAChD;CACE,aAAa,eAAe,WAAW;AACxC;;;;;AAMD,OAAO,cAAM,2BAA2B;;;;;CAKtC,OAAO,6BACLA,IAAI,gCACH;;;;CA8BH,eAAe;;;;;CAiCf,eAAe;CAiCf,eAAe;AAgBhB","names":["ir: OntologyIrOntologyBlockDataV2"],"sources":["../../src/PreviewOntologyIrConverter.ts"],"version":3,"file":"PreviewOntologyIrConverter.d.ts"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../src/cli/generate-sdk.ts"],"version":3,"file":"generate-sdk.d.ts"}
@@ -0,0 +1 @@
1
+ export { type PreviewOntologyFullMetadata, PreviewOntologyIrConverter } from "./PreviewOntologyIrConverter.js";
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACO,6BACL,kCACK","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate a deterministic UUID from a string.
3
+ * Uses SHA-256 hash truncated to UUID format for consistency.
4
+ */
5
+ export declare function toUuid(str: string): string;
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAsBA,OAAO,iBAAS,OAAOA","names":["str: string"],"sources":["../../src/ridUtils.ts"],"version":3,"file":"ridUtils.d.ts"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../src/ridUtils.test.ts"],"version":3,"file":"ridUtils.test.d.ts"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@osdk/generator-converters.preview",
3
+ "version": "0.1.0-beta.0",
4
+ "description": "Preview converters for OntologyIR with full action metadata",
5
+ "access": "public",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/palantir/osdk-ts.git"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "browser": "./build/browser/index.js",
14
+ "import": {
15
+ "types": "./build/types/index.d.ts",
16
+ "default": "./build/esm/index.js"
17
+ },
18
+ "require": "./build/cjs/index.cjs",
19
+ "default": "./build/browser/index.js"
20
+ },
21
+ "./*": {
22
+ "browser": "./build/browser/public/*.js",
23
+ "import": {
24
+ "types": "./build/types/public/*.d.ts",
25
+ "default": "./build/esm/public/*.js"
26
+ },
27
+ "require": "./build/cjs/public/*.cjs",
28
+ "default": "./build/browser/public/*.js"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "@osdk/foundry.ontologies": "2.45.0",
33
+ "@osdk/client.unstable": "~2.8.0-beta.2",
34
+ "@osdk/generator": "~2.8.0-beta.2",
35
+ "@osdk/generator-converters.ontologyir": "~2.8.0-beta.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^24.3.1",
39
+ "ts-expect": "^1.3.0",
40
+ "typescript": "~5.5.4",
41
+ "vitest": "^3.2.4",
42
+ "@osdk/monorepo.tsconfig": "~0.7.0-beta.1",
43
+ "@osdk/monorepo.api-extractor": "~0.7.0-beta.1"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "keywords": [],
49
+ "bin": {
50
+ "generate-sdk": "./build/esm/cli/generate-sdk.js"
51
+ },
52
+ "files": [
53
+ "build/cjs",
54
+ "build/esm",
55
+ "build/browser",
56
+ "build/types",
57
+ "CHANGELOG.md",
58
+ "package.json",
59
+ "templates",
60
+ "*.d.ts"
61
+ ],
62
+ "main": "./build/cjs/index.cjs",
63
+ "module": "./build/esm/index.js",
64
+ "types": "./build/cjs/index.d.cts",
65
+ "type": "module",
66
+ "scripts": {
67
+ "check-attw": "attw --pack .",
68
+ "check-spelling": "cspell --quiet .",
69
+ "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
70
+ "fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
71
+ "lint": "eslint . && dprint check --config $(find-up dprint.json)",
72
+ "test": "vitest run --pool=forks",
73
+ "test:watch": "vitest",
74
+ "transpileBrowser": "monorepo.tool.transpile -f esm -m normal -t browser",
75
+ "transpileCjs": "monorepo.tool.transpile -f cjs -m bundle -t node",
76
+ "transpileEsm": "monorepo.tool.transpile -f esm -m normal -t node",
77
+ "transpileTypes": "monorepo.tool.transpile -f esm -m types -t node",
78
+ "typecheck": "tsc --noEmit --emitDeclarationOnly false"
79
+ }
80
+ }