@osdk/generator-converters.preview 0.1.0-beta.1 → 0.1.0-beta.3

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 (33) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/browser/ActionLogicRuleConverter.js +24 -2
  3. package/build/browser/ActionLogicRuleConverter.js.map +1 -1
  4. package/build/browser/PreviewOntologyIrConverter.js +15 -28
  5. package/build/browser/PreviewOntologyIrConverter.js.map +1 -1
  6. package/build/browser/cli/generate-sdk.js +249 -31
  7. package/build/browser/cli/generate-sdk.js.map +1 -1
  8. package/build/browser/ridUtils.js +10 -5
  9. package/build/browser/ridUtils.js.map +1 -1
  10. package/build/cjs/index.cjs +26 -31
  11. package/build/cjs/index.cjs.map +1 -1
  12. package/build/cjs/index.d.cts +2 -2
  13. package/build/esm/ActionLogicRuleConverter.js +24 -2
  14. package/build/esm/ActionLogicRuleConverter.js.map +1 -1
  15. package/build/esm/PreviewOntologyIrConverter.js +15 -28
  16. package/build/esm/PreviewOntologyIrConverter.js.map +1 -1
  17. package/build/esm/cli/generate-sdk.js +249 -31
  18. package/build/esm/cli/generate-sdk.js.map +1 -1
  19. package/build/esm/ridUtils.js +10 -5
  20. package/build/esm/ridUtils.js.map +1 -1
  21. package/build/types/ActionLogicRuleConverter.d.ts +7 -1
  22. package/build/types/ActionLogicRuleConverter.d.ts.map +1 -1
  23. package/build/types/PreviewOntologyIrConverter.d.ts +2 -2
  24. package/build/types/PreviewOntologyIrConverter.d.ts.map +1 -1
  25. package/build/types/ridUtils.d.ts +3 -2
  26. package/build/types/ridUtils.d.ts.map +1 -1
  27. package/package.json +11 -8
  28. package/build/browser/ridUtils.test.js +0 -43
  29. package/build/browser/ridUtils.test.js.map +0 -1
  30. package/build/esm/ridUtils.test.js +0 -43
  31. package/build/esm/ridUtils.test.js.map +0 -1
  32. package/build/types/ridUtils.test.d.ts +0 -1
  33. package/build/types/ridUtils.test.d.ts.map +0 -1
@@ -1 +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,CA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AAK;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":[]}
1
+ {"version":3,"file":"generate-sdk.js","names":["generateClientSdkVersionTwoPointZero","OntologyIrToFullMetadataConverter","consola","spawnSync","fsSync","fs","os","path","yargs","hideBin","PreviewOntologyIrConverter","PYTHON_SDK_PACKAGE_NAME","generatePythonSdk","previewMetadata","pythonBinary","pythonMetadata","actionTypes","Object","fromEntries","entries","map","key","fullMeta","actionType","globalFunctions","queryTypes","valueTypes","objectTypes","keys","length","info","ontologyApiName","ontology","apiName","siteResult","encoding","status","stdout","trim","warn","stderr","error","sitePackages","tmpDir","mkdtempSync","join","tmpdir","tmpMetadata","writeFileSync","JSON","stringify","packageName","genResult","stdio","rmSync","recursive","force","generatedPackage","destPackage","cpSync","main","argv","process","strict","help","version","usage","options","describe","type","demandOption","coerce","resolve","parse","inputFile","input","packageVersion","outputDir","access","exit","fileContent","readFile","irJson","parsed","ir","getPreviewFullMetadataFromIr","pythonFunctionsDir","functionsDir","effectivePythonRootDir","pythonRootProjectDir","dirname","undefined","getOsdkQueryTypes","nodeModulesPath","functionNames","metadata","fullOutputDir","mkdir","existingEntries","readdir","entry","rm","writeFile","filePath","contents","fullPath","isAbsolute","dirPath","Map","metadataPath","pythonMetadataPath","functionsProjectRoot","runtimeMetadataDir","runtimeMetadataPath","ontologyRid","rid","objectTypeMetadata","objData","objType","objectType","propertyTypeMetadata","properties","propApiName","propDef","propertyTypeApiName","dataType","objectTypeApiName","primaryKeyPropertyTypeId","primaryKey","linkTypeMetadata","interfaceTypeMetadata","magritteSourceMetadata","e","success","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 { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport { spawnSync } from \"node:child_process\";\nimport * as fsSync from \"node:fs\";\nimport * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { PreviewOntologyIrConverter } from \"../PreviewOntologyIrConverter.js\";\n\nconst PYTHON_SDK_PACKAGE_NAME = \"ontology_sdk\";\n\n/**\n * Generates the Python SDK package into the conda environment's site-packages\n * so that Python function discovery can resolve ontology type imports.\n */\nfunction generatePythonSdk(\n previewMetadata: ReturnType<\n typeof PreviewOntologyIrConverter.getPreviewFullMetadataFromIr\n >,\n pythonBinary: string,\n): void {\n // Build the Python-compatible metadata: unwrap actionTypes and add globalFunctions\n const pythonMetadata = {\n ...previewMetadata,\n actionTypes: Object.fromEntries(\n Object.entries(previewMetadata.actionTypes).map(([key, fullMeta]) => [\n key,\n fullMeta.actionType,\n ]),\n ),\n globalFunctions: { queryTypes: {}, valueTypes: {} },\n };\n\n const objectTypes = Object.keys(previewMetadata.objectTypes ?? {});\n if (objectTypes.length === 0) {\n consola.info(\"No object types found, skipping Python SDK generation.\");\n return;\n }\n\n const ontologyApiName = previewMetadata.ontology?.apiName ?? \"ontology\";\n\n // Discover site-packages from the conda environment\n const siteResult = spawnSync(\n pythonBinary,\n [\"-c\", \"import site; print(site.getsitepackages()[0])\"],\n { encoding: \"utf-8\" },\n );\n if (siteResult.status !== 0 || !siteResult.stdout?.trim()) {\n consola.warn(\n `Could not discover Python site-packages: ${\n siteResult.stderr || siteResult.error\n }`,\n );\n return;\n }\n const sitePackages = siteResult.stdout.trim();\n consola.info(`Python site-packages: ${sitePackages}`);\n\n // Write metadata to a temp file for the generator\n const tmpDir = fsSync.mkdtempSync(path.join(os.tmpdir(), \"python-sdk-\"));\n const tmpMetadata = path.join(tmpDir, \"metadata.json\");\n fsSync.writeFileSync(\n tmpMetadata,\n JSON.stringify(pythonMetadata, null, 2),\n \"utf-8\",\n );\n\n // Run the Python SDK generator into the temp directory.\n // The generator creates <output-dir>/ontology_sdk/ which is a project\n // directory containing ontology_sdk/ (the actual Python package), setup.py, etc.\n consola.info(\"Generating Python SDK...\");\n const packageName = PYTHON_SDK_PACKAGE_NAME;\n const genResult = spawnSync(\n pythonBinary,\n [\n \"-m\",\n \"foundry_sdk_generator\",\n \"generate_package\",\n \"--output-dir\",\n tmpDir,\n \"--package-name\",\n packageName,\n \"--package-version\",\n \"0.0.0\",\n \"--ontology\",\n ontologyApiName,\n \"--object-types\",\n objectTypes.join(\",\"),\n \"--cache-path\",\n tmpMetadata,\n \"--force\",\n ],\n { encoding: \"utf-8\", stdio: \"pipe\" },\n );\n\n if (genResult.status !== 0) {\n consola.warn(\n `Python SDK generation failed (non-fatal): ${\n genResult.stderr || genResult.stdout\n }`,\n );\n fsSync.rmSync(tmpDir, { recursive: true, force: true });\n return;\n }\n\n // The generator creates <tmpDir>/ontology_sdk/ontology_sdk/ (the importable\n // package). Copy just the inner package into site-packages so Python can\n // resolve `import ontology_sdk`.\n const generatedPackage = path.join(tmpDir, packageName, packageName);\n const destPackage = path.join(sitePackages, packageName);\n\n // Remove any previous version\n fsSync.rmSync(destPackage, { recursive: true, force: true });\n fsSync.cpSync(generatedPackage, destPackage, { recursive: true });\n\n // Clean up temp directory\n fsSync.rmSync(tmpDir, { recursive: true, force: true });\n\n consola.info(`Python SDK installed to ${destPackage}`);\n}\n\nasync function main(): Promise<void> {\n const argv = await yargs(hideBin(process.argv))\n .strict()\n .help()\n .version(false) // so that we can use --version argument for the package version\n .usage(\n \"$0 --input <path> --package-name <name> --version <ver> --output-dir <dir>\",\n )\n .options({\n \"input\": {\n describe: \"Path to the OntologyIR JSON file\",\n type: \"string\",\n demandOption: true,\n coerce: path.resolve,\n },\n \"package-name\": {\n describe: \"Name for the generated SDK package\",\n type: \"string\",\n demandOption: true,\n },\n \"version\": {\n describe: \"Version string for the generated SDK\",\n type: \"string\",\n demandOption: true,\n },\n \"output-dir\": {\n describe: \"Directory where the SDK will be generated\",\n type: \"string\",\n demandOption: true,\n coerce: path.resolve,\n },\n \"functions-dir\": {\n describe:\n \"Path to TypeScript functions source directory (enables TS function discovery)\",\n type: \"string\",\n coerce: path.resolve,\n },\n \"node-modules-path\": {\n describe:\n \"Path to node_modules containing @foundry packages (for TS function discovery)\",\n type: \"string\",\n coerce: path.resolve,\n },\n \"python-functions-dir\": {\n describe:\n \"Path to Python functions source directory (enables Python function discovery)\",\n type: \"string\",\n coerce: path.resolve,\n },\n \"python-root-project-dir\": {\n describe:\n \"Root project directory for Python functions (defaults to parent of python-functions-dir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n \"python-binary\": {\n describe:\n \"Path to Python binary (required when using --python-functions-dir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parse();\n\n const inputFile = argv.input;\n const packageName = argv.packageName;\n const packageVersion = argv.version;\n const outputDir = argv.outputDir;\n\n // Validate input file exists\n try {\n await fs.access(inputFile);\n } catch {\n consola.error(`Input file does not exist: ${inputFile}`);\n process.exit(1);\n }\n\n consola.info(`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 {\n consola.error(`Failed to parse JSON from ${inputFile}`);\n process.exit(1);\n }\n\n // Basic structural validation before passing to converter\n const ir = irJson as Record<string, unknown>;\n if (\n !ir\n || typeof ir !== \"object\"\n || !(\"objectTypes\" in ir)\n || !(\"actionTypes\" in ir)\n ) {\n consola.error(\n `Invalid OntologyIR structure in ${inputFile}. Expected objectTypes and actionTypes fields.`,\n );\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 // Generate the Python SDK before function discovery so that Python functions\n // that import ontology types (e.g. `from ontology_sdk.ontology.objects import X`)\n // can be successfully parsed during discovery.\n if (argv.pythonBinary && argv.pythonFunctionsDir) {\n generatePythonSdk(\n previewMetadata,\n argv.pythonBinary,\n );\n }\n\n // Function discovery is optional - only run if at least one functions flag is provided\n if (argv.functionsDir || argv.pythonFunctionsDir) {\n if (argv.pythonFunctionsDir && !argv.pythonBinary) {\n consola.error(\n \"--python-binary is required when using --python-functions-dir\",\n );\n process.exit(1);\n }\n\n const effectivePythonRootDir = argv.pythonRootProjectDir\n ?? (argv.pythonFunctionsDir\n ? path.dirname(argv.pythonFunctionsDir)\n : undefined);\n\n const queryTypes = await OntologyIrToFullMetadataConverter\n .getOsdkQueryTypes(\n argv.pythonBinary,\n argv.functionsDir,\n argv.nodeModulesPath,\n argv.pythonFunctionsDir,\n effectivePythonRootDir,\n previewMetadata,\n );\n\n const functionNames = Object.keys(queryTypes);\n if (functionNames.length > 0) {\n previewMetadata.queryTypes = queryTypes;\n consola.info(\n `Discovered ${functionNames.length} function(s): ${\n functionNames.join(\", \")\n }`,\n );\n } else {\n consola.info(\"No functions discovered.\");\n }\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 // Clean the output directory before generation. The generator's verifyOutDir\n // requires an empty directory, but a previous SDK build may exist from\n // function discovery (so TypeScript functions can resolve @ontology/sdk imports).\n const existingEntries = await fs.readdir(fullOutputDir);\n for (const entry of existingEntries) {\n await fs.rm(path.join(fullOutputDir, entry), {\n recursive: true,\n force: true,\n });\n }\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 consola.info(`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 consola.info(`Wrote ${metadataPath}`);\n\n // Write Python-compatible metadata that the foundry-sdk-generator expects.\n // This uses the unwrapped actionTypes (ActionTypeV2 instead of\n // ActionTypeFullMetadata) and adds the globalFunctions key.\n if (argv.pythonFunctionsDir) {\n const pythonMetadataPath = path.join(\n fullOutputDir,\n \"python-ontology-metadata.json\",\n );\n await fs.writeFile(\n pythonMetadataPath,\n JSON.stringify(\n { ...metadata, globalFunctions: { queryTypes: {}, valueTypes: {} } },\n null,\n 2,\n ),\n \"utf-8\",\n );\n consola.info(`Wrote ${pythonMetadataPath}`);\n }\n\n // Write runtime metadata.json for the TypeScript functions runtime.\n // The runtime needs entity metadata to resolve ontology types during\n // function discovery. Without this, functions using Client/Osdk.Instance\n // produce diagnostics that block ALL function discovery.\n if (argv.functionsDir) {\n const functionsProjectRoot = path.resolve(argv.functionsDir, \"..\", \"..\");\n const runtimeMetadataDir = path.join(\n functionsProjectRoot,\n \".dev-server\",\n \"var\",\n \"conf\",\n );\n const runtimeMetadataPath = path.join(runtimeMetadataDir, \"metadata.json\");\n\n const ontologyRid = previewMetadata.ontology.rid;\n\n const objectTypeMetadata: Record<string, unknown> = {};\n if (previewMetadata.objectTypes) {\n for (\n const [apiName, objData] of Object.entries(previewMetadata.objectTypes)\n ) {\n const objType = objData.objectType;\n const propertyTypeMetadata: Record<\n string,\n { propertyTypeApiName: string; type?: unknown }\n > = {};\n if (objType.properties) {\n for (\n const [propApiName, propDef] of Object.entries(objType.properties)\n ) {\n propertyTypeMetadata[propApiName] = {\n propertyTypeApiName: propApiName,\n type: propDef.dataType,\n };\n }\n }\n objectTypeMetadata[apiName] = {\n objectTypeApiName: apiName,\n primaryKeyPropertyTypeId: objType.primaryKey,\n propertyTypeMetadata,\n linkTypeMetadata: {},\n };\n }\n }\n\n const runtimeMetadata = {\n ontologyRid,\n objectTypeMetadata,\n interfaceTypeMetadata: {},\n magritteSourceMetadata: {},\n };\n\n try {\n await fs.mkdir(runtimeMetadataDir, { recursive: true });\n await fs.writeFile(\n runtimeMetadataPath,\n JSON.stringify(runtimeMetadata),\n \"utf-8\",\n );\n consola.info(`Wrote runtime metadata to ${runtimeMetadataPath}`);\n } catch (e) {\n consola.warn(`Could not write runtime metadata: ${e}`);\n }\n }\n\n consola.success(\"Done!\");\n}\n\nmain().catch((err: unknown) => {\n consola.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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,CAACqC,IAAI,CAAC,qCAAqC6F,CAAC,EAAE,CAAC;IACxD;EACF;EAEAlI,OAAO,CAACmI,OAAO,CAAC,OAAO,CAAC;AAC1B;AAEAzE,IAAI,CAAC,CAAC,CAAC0E,KAAK,CAAEC,GAAY,IAAK;EAC7BrI,OAAO,CAACuC,KAAK,CAAC8F,GAAG,YAAYC,KAAK,GAAGD,GAAG,CAACE,OAAO,GAAGF,GAAG,CAAC;EACvDzE,OAAO,CAACiB,IAAI,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC","ignoreList":[]}
@@ -17,12 +17,17 @@
17
17
  import { createHash } from "node:crypto";
18
18
 
19
19
  /**
20
- * Generate a deterministic UUID from a string.
21
- * Uses SHA-256 hash truncated to UUID format for consistency.
20
+ * Generate a deterministic UUID v5-like identifier from a string.
21
+ * Uses SHA-256 hash truncated to UUID format with version (5) and
22
+ * variant (RFC 4122) bits set for spec compliance.
22
23
  */
23
24
  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)}`;
25
+ const hashBytes = createHash("sha256").update(str).digest();
26
+ // Set version to 5 (name-based SHA) in byte 6: clear top nibble, set to 0101
27
+ hashBytes[6] = hashBytes[6] & 0x0f | 0x50;
28
+ // Set variant to RFC 4122 in byte 8: clear top 2 bits, set to 10
29
+ hashBytes[8] = hashBytes[8] & 0x3f | 0x80;
30
+ const hex = hashBytes.subarray(0, 16).toString("hex");
31
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
27
32
  }
28
33
  //# sourceMappingURL=ridUtils.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"ridUtils.js","names":["createHash","toUuid","str","hashBytes","update","digest","hex","subarray","toString","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 v5-like identifier from a string.\n * Uses SHA-256 hash truncated to UUID format with version (5) and\n * variant (RFC 4122) bits set for spec compliance.\n */\nexport function toUuid(str: string): string {\n const hashBytes = createHash(\"sha256\").update(str).digest();\n // Set version to 5 (name-based SHA) in byte 6: clear top nibble, set to 0101\n hashBytes[6] = (hashBytes[6] & 0x0f) | 0x50;\n // Set variant to RFC 4122 in byte 8: clear top 2 bits, set to 10\n hashBytes[8] = (hashBytes[8] & 0x3f) | 0x80;\n\n const hex = hashBytes.subarray(0, 16).toString(\"hex\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${\n hex.slice(16, 20)\n }-${hex.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;AACA,OAAO,SAASC,MAAMA,CAACC,GAAW,EAAU;EAC1C,MAAMC,SAAS,GAAGH,UAAU,CAAC,QAAQ,CAAC,CAACI,MAAM,CAACF,GAAG,CAAC,CAACG,MAAM,CAAC,CAAC;EAC3D;EACAF,SAAS,CAAC,CAAC,CAAC,GAAIA,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAI,IAAI;EAC3C;EACAA,SAAS,CAAC,CAAC,CAAC,GAAIA,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAI,IAAI;EAE3C,MAAMG,GAAG,GAAGH,SAAS,CAACI,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAACC,QAAQ,CAAC,KAAK,CAAC;EACrD,OAAO,GAAGF,GAAG,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAIH,GAAG,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAIH,GAAG,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAChEH,GAAG,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IACfH,GAAG,CAACG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE;AACzB","ignoreList":[]}
@@ -51,9 +51,12 @@ function getObjectReferenceType(action, paramKey) {
51
51
  }
52
52
  return param.type.objectReference;
53
53
  }
54
- function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
54
+ function convertIrLogicRulesToActionLogicRules(rules, action, ir) {
55
55
  const objectLookup = buildObjectTypeLookup(ir);
56
56
  const interfaceLookup = buildInterfaceTypeLookup(ir);
57
+ return rules.map((irRule) => convertSingleRule(irRule, action, objectLookup, interfaceLookup));
58
+ }
59
+ function convertSingleRule(irRule, action, objectLookup, interfaceLookup) {
57
60
  switch (irRule.type) {
58
61
  case "addObjectRule": {
59
62
  const r = irRule.addObjectRule;
@@ -83,10 +86,14 @@ function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
83
86
  case "modifyObjectRule": {
84
87
  const r = irRule.modifyObjectRule;
85
88
  getObjectReferenceType(action, r.objectToModify);
89
+ const modifyPropertyArguments = {};
90
+ for (const [k, v] of Object.entries(r.propertyValues)) {
91
+ modifyPropertyArguments[k] = v;
92
+ }
86
93
  const result = {
87
94
  type: "modifyObject",
88
95
  objectToModify: r.objectToModify,
89
- propertyArguments: {},
96
+ propertyArguments: modifyPropertyArguments,
90
97
  structPropertyArguments: {}
91
98
  };
92
99
  return result;
@@ -130,8 +137,11 @@ function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
130
137
  }
131
138
  }
132
139
  function toUuid(str) {
133
- const hashHex = crypto.createHash("sha256").update(str).digest("hex");
134
- return `${hashHex.slice(0, 8)}-${hashHex.slice(8, 12)}-${hashHex.slice(12, 16)}-${hashHex.slice(16, 20)}-${hashHex.slice(20, 32)}`;
140
+ const hashBytes = crypto.createHash("sha256").update(str).digest();
141
+ hashBytes[6] = hashBytes[6] & 15 | 80;
142
+ hashBytes[8] = hashBytes[8] & 63 | 128;
143
+ const hex = hashBytes.subarray(0, 16).toString("hex");
144
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
135
145
  }
136
146
 
137
147
  // src/PreviewOntologyIrConverter.ts
@@ -183,40 +193,25 @@ var PreviewOntologyIrConverter = class {
183
193
  }
184
194
  /**
185
195
  * Convert IR action types to ActionTypeFullMetadata format.
186
- * Uses base converter for parameters and operations, adds fullLogicRules.
196
+ * Reuses base converter for action type conversion, then process
197
+ * RIDs to use UUID-based format and adds fullLogicRules.
187
198
  */
188
199
  static convertActionTypesWithFullLogicRules(actions, ir) {
200
+ const baseActionTypes = generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getOsdkActionTypes(actions);
201
+ const actionsByApiName = new Map(actions.map((a) => [a.actionType.metadata.apiName, a]));
189
202
  const result = {};
190
- for (const action of actions) {
191
- const metadata = action.actionType.metadata;
192
- const actionType = {
193
- rid: `ri.ontology.main.action-type.${toUuid(metadata.apiName)}`,
194
- apiName: metadata.apiName,
195
- displayName: metadata.displayMetadata.displayName,
196
- description: metadata.displayMetadata.description,
197
- parameters: generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getOsdkActionParameters(action),
198
- operations: generatorConverters_ontologyir.OntologyIrToFullMetadataConverter.getOsdkActionOperations(action),
199
- status: this.convertActionTypeStatus(metadata.status)
200
- };
201
- result[actionType.apiName] = {
202
- actionType,
203
- fullLogicRules: action.actionType.actionTypeLogic.logic.rules.map((rule) => convertIrLogicRuleToActionLogicRule(rule, action, ir))
203
+ for (const [apiName, baseActionType] of Object.entries(baseActionTypes)) {
204
+ const action = actionsByApiName.get(apiName);
205
+ result[apiName] = {
206
+ actionType: {
207
+ ...baseActionType,
208
+ rid: `ri.ontology.main.action-type.${toUuid(apiName)}`
209
+ },
210
+ fullLogicRules: convertIrLogicRulesToActionLogicRules(action.actionType.actionTypeLogic.logic.rules, action, ir)
204
211
  };
205
212
  }
206
213
  return result;
207
214
  }
208
- static convertActionTypeStatus(status) {
209
- switch (status.type) {
210
- case "active":
211
- return "ACTIVE";
212
- case "deprecated":
213
- return "DEPRECATED";
214
- case "experimental":
215
- return "EXPERIMENTAL";
216
- case "example":
217
- throw new Error("Example status cannot be mapped to ActionTypeStatus");
218
- }
219
- }
220
215
  };
221
216
 
222
217
  exports.PreviewOntologyIrConverter = PreviewOntologyIrConverter;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ActionLogicRuleConverter.ts","../../src/ridUtils.ts","../../src/PreviewOntologyIrConverter.ts"],"names":["createHash","OntologyIrToFullMetadataConverter"],"mappings":";;;;;;;;AAgBA,SAAS,sBAAsB,EAAI,EAAA;AACjC,EAAI,IAAA,CAAC,IAAI,WAAa,EAAA;AACpB,IAAO,OAAA,MAAA;AAAA;AAET,EAAM,MAAA,IAAA,uBAAW,GAAI,EAAA;AACrB,EAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,EAAW,KAAA,MAAA,CAAC,KAAK,KAAK,CAAA,IAAK,OAAO,OAAQ,CAAA,EAAA,CAAG,WAAW,CAAG,EAAA;AACzD,IAAM,MAAA,OAAA,GAAU,MAAM,UAAW,CAAA,OAAA;AACjC,IAAK,IAAA,CA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A,gEAAkC,CAAA,uBAAA,CAAwB,MAAM,CAAA;AAAA,QAC5E,UAAA,EAAYA,gEAAkC,CAAA,uBAAA,CAAwB,MAAM,CAAA;AAAA,QAC5E,MAAQ,EAAA,IAAA,CAAK,uBAAwB,CAAA,QAAA,CAAS,MAAM;AAAA,OACtD;AACA,MAAO,MAAA,CAAA,UAAA,CAAW,OAAO,CAAI,GAAA;AAAA,QAC3B,UAAA;AAAA,QACA,cAAgB,EAAA,MAAA,CAAO,UAAW,CAAA,eAAA,CAAgB,KAAM,CAAA,KAAA,CAAM,GAAI,CAAA,CAAA,IAAA,KAAQ,mCAAoC,CAAA,IAAA,EAAM,MAAQ,EAAA,EAAE,CAAC;AAAA,OACjI;AAAA;AAEF,IAAO,OAAA,MAAA;AAAA;AACT,EACA,OAAO,wBAAwB,MAAQ,EAAA;AACrC,IAAA,QAAQ,OAAO,IAAM;AAAA,MACnB,KAAK,QAAA;AACH,QAAO,OAAA,QAAA;AAAA,MACT,KAAK,YAAA;AACH,QAAO,OAAA,YAAA;AAAA,MACT,KAAK,cAAA;AACH,QAAO,OAAA,cAAA;AAAA,MACT,KAAK,SAAA;AACH,QAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AACzE;AAEJ","file":"index.cjs","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\nfunction buildObjectTypeLookup(ir) {\n if (!ir?.objectTypes) {\n return undefined;\n }\n const byId = new Map();\n const byHyphenated = new Map();\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 {\n byId,\n byHyphenated\n };\n}\nfunction buildInterfaceTypeLookup(ir) {\n if (!ir?.interfaceTypes) {\n return undefined;\n }\n const byId = new Map();\n const byHyphenated = new Map();\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 {\n byId,\n byHyphenated\n };\n}\nfunction resolveApiName(id, lookup) {\n if (!lookup) {\n return id;\n }\n return lookup.byId.get(id) ?? lookup.byHyphenated.get(id) ?? id;\n}\nfunction getObjectReferenceType(action, paramKey) {\n const param = action.actionType.metadata.parameters[paramKey];\n if (!param || param.type.type !== \"objectReference\") {\n throw new Error(`Parameter '${paramKey}' must be an objectReference type`);\n }\n return param.type.objectReference;\n}\n\n/**\n * Convert OntologyIrLogicRule to ActionLogicRule for use in ActionTypeFullMetadata.\n */\nexport function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {\n const objectLookup = buildObjectTypeLookup(ir);\n const interfaceLookup = buildInterfaceTypeLookup(ir);\n switch (irRule.type) {\n case \"addObjectRule\":\n {\n const r = irRule.addObjectRule;\n const propertyArguments = {};\n for (const [k, v] of Object.entries(r.propertyValues)) {\n propertyArguments[k] = v;\n }\n const result = {\n type: \"createObject\",\n objectTypeApiName: resolveApiName(r.objectTypeId, objectLookup),\n propertyArguments,\n structPropertyArguments: {}\n };\n return result;\n }\n case \"addOrModifyObjectRuleV2\":\n {\n const r = irRule.addOrModifyObjectRuleV2;\n const objRef = getObjectReferenceType(action, r.objectToModify);\n const result = {\n type: \"createOrModifyObject\",\n objectTypeApiName: resolveApiName(objRef.objectTypeId, objectLookup),\n propertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"modifyObjectRule\":\n {\n const r = irRule.modifyObjectRule;\n getObjectReferenceType(action, r.objectToModify);\n const result = {\n type: \"modifyObject\",\n objectToModify: r.objectToModify,\n propertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"deleteObjectRule\":\n {\n const r = irRule.deleteObjectRule;\n const result = {\n type: \"deleteObject\",\n objectToDelete: r.objectToDelete\n };\n return result;\n }\n case \"addInterfaceRule\":\n {\n const r = irRule.addInterfaceRule;\n const interfaceApiName = resolveApiName(r.interfaceApiName, interfaceLookup);\n const result = {\n type: \"createInterface\",\n interfaceTypeApiName: interfaceApiName,\n objectType: interfaceApiName,\n sharedPropertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"modifyInterfaceRule\":\n {\n const r = irRule.modifyInterfaceRule;\n const result = {\n type: \"modifyInterface\",\n interfaceObjectToModify: r.interfaceObjectToModifyParameter,\n sharedPropertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"addLinkRule\":\n throw new Error(\"addLinkRule is not supported for ActionLogicRule\");\n case \"deleteLinkRule\":\n throw new Error(\"deleteLinkRule is not supported for ActionLogicRule\");\n default:\n throw new Error(`Unsupported logic rule type: ${irRule.type}`);\n }\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 { 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) {\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)}-${hashHex.slice(12, 16)}-${hashHex.slice(16, 20)}-${hashHex.slice(20, 32)}`;\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 { 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 */\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(ir) {\n const baseMetadata = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ir);\n const actionTypes = this.convertActionTypesWithFullLogicRules(Object.values(ir.actionTypes), ir);\n\n // Post-process object types to use UUID-based RIDs\n const objectTypes = this.convertObjectTypesWithUuidRids(baseMetadata.objectTypes);\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 static convertObjectTypesWithUuidRids(objectTypes) {\n const result = {};\n for (const [apiName, fullMetadata] of Object.entries(objectTypes)) {\n const objectType = fullMetadata.objectType;\n const properties = {};\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 result[apiName] = {\n ...fullMetadata,\n objectType: {\n ...objectType,\n rid: `ri.ontology.main.object-type.${toUuid(apiName)}`,\n properties\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 static convertActionTypesWithFullLogicRules(actions, ir) {\n const result = {};\n for (const action of actions) {\n const metadata = action.actionType.metadata;\n const actionType = {\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(action),\n operations: OntologyIrToFullMetadataConverter.getOsdkActionOperations(action),\n status: this.convertActionTypeStatus(metadata.status)\n };\n result[actionType.apiName] = {\n actionType,\n fullLogicRules: action.actionType.actionTypeLogic.logic.rules.map(rule => convertIrLogicRuleToActionLogicRule(rule, action, ir))\n };\n }\n return result;\n }\n static convertActionTypeStatus(status) {\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(\"Example status cannot be mapped to ActionTypeStatus\");\n }\n }\n}"]}
1
+ {"version":3,"sources":["../../src/ActionLogicRuleConverter.ts","../../src/ridUtils.ts","../../src/PreviewOntologyIrConverter.ts"],"names":["createHash","OntologyIrToFullMetadataConverter"],"mappings":";;;;;;;;AAgBA,SAAS,sBAAsB,EAAI,EAAA;AACjC,EAAI,IAAA,CAAC,IAAI,WAAa,EAAA;AACpB,IAAO,OAAA,MAAA;AAAA;AAET,EAAM,MAAA,IAAA,uBAAW,GAAI,EAAA;AACrB,EAAM,MAAA,YAAA,uBAAmB,GAAI,EAAA;AAC7B,EAAW,KAAA,MAAA,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.\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\nfunction buildObjectTypeLookup(ir) {\n if (!ir?.objectTypes) {\n return undefined;\n }\n const byId = new Map();\n const byHyphenated = new Map();\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 {\n byId,\n byHyphenated\n };\n}\nfunction buildInterfaceTypeLookup(ir) {\n if (!ir?.interfaceTypes) {\n return undefined;\n }\n const byId = new Map();\n const byHyphenated = new Map();\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 {\n byId,\n byHyphenated\n };\n}\nfunction resolveApiName(id, lookup) {\n if (!lookup) {\n return id;\n }\n return lookup.byId.get(id) ?? lookup.byHyphenated.get(id) ?? id;\n}\nfunction getObjectReferenceType(action, paramKey) {\n const param = action.actionType.metadata.parameters[paramKey];\n if (!param || param.type.type !== \"objectReference\") {\n throw new Error(`Parameter '${paramKey}' must be an objectReference type`);\n }\n return param.type.objectReference;\n}\n\n/**\n * Build lookups once and convert all logic rules for an action.\n * Avoids rebuilding lookup Maps on every rule.\n */\nexport function convertIrLogicRulesToActionLogicRules(rules, action, ir) {\n const objectLookup = buildObjectTypeLookup(ir);\n const interfaceLookup = buildInterfaceTypeLookup(ir);\n return rules.map(irRule => convertSingleRule(irRule, action, objectLookup, interfaceLookup));\n}\n\n/**\n * Convert a single OntologyIrLogicRule to ActionLogicRule.\n * Kept as a public API for callers that only need a single rule conversion.\n */\nexport function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {\n const objectLookup = buildObjectTypeLookup(ir);\n const interfaceLookup = buildInterfaceTypeLookup(ir);\n return convertSingleRule(irRule, action, objectLookup, interfaceLookup);\n}\nfunction convertSingleRule(irRule, action, objectLookup, interfaceLookup) {\n switch (irRule.type) {\n case \"addObjectRule\":\n {\n const r = irRule.addObjectRule;\n const propertyArguments = {};\n for (const [k, v] of Object.entries(r.propertyValues)) {\n propertyArguments[k] = v;\n }\n const result = {\n type: \"createObject\",\n objectTypeApiName: resolveApiName(r.objectTypeId, objectLookup),\n propertyArguments,\n structPropertyArguments: {}\n };\n return result;\n }\n case \"addOrModifyObjectRuleV2\":\n {\n const r = irRule.addOrModifyObjectRuleV2;\n const objRef = getObjectReferenceType(action, r.objectToModify);\n // propertyArguments left empty: the downstream generator resolves\n // property mappings from the action parameter configuration rather\n // than from the logic rule itself for createOrModify rules.\n const result = {\n type: \"createOrModifyObject\",\n objectTypeApiName: resolveApiName(objRef.objectTypeId, objectLookup),\n propertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"modifyObjectRule\":\n {\n const r = irRule.modifyObjectRule;\n // Validate that the parameter is an objectReference (throws if not)\n getObjectReferenceType(action, r.objectToModify);\n const modifyPropertyArguments = {};\n for (const [k, v] of Object.entries(r.propertyValues)) {\n modifyPropertyArguments[k] = v;\n }\n const result = {\n type: \"modifyObject\",\n objectToModify: r.objectToModify,\n propertyArguments: modifyPropertyArguments,\n structPropertyArguments: {}\n };\n return result;\n }\n case \"deleteObjectRule\":\n {\n const r = irRule.deleteObjectRule;\n const result = {\n type: \"deleteObject\",\n objectToDelete: r.objectToDelete\n };\n return result;\n }\n case \"addInterfaceRule\":\n {\n const r = irRule.addInterfaceRule;\n const interfaceApiName = resolveApiName(r.interfaceApiName, interfaceLookup);\n const result = {\n type: \"createInterface\",\n interfaceTypeApiName: interfaceApiName,\n objectType: interfaceApiName,\n sharedPropertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"modifyInterfaceRule\":\n {\n const r = irRule.modifyInterfaceRule;\n const result = {\n type: \"modifyInterface\",\n interfaceObjectToModify: r.interfaceObjectToModifyParameter,\n sharedPropertyArguments: {},\n structPropertyArguments: {}\n };\n return result;\n }\n case \"addLinkRule\":\n throw new Error(\"addLinkRule is not supported for ActionLogicRule\");\n case \"deleteLinkRule\":\n throw new Error(\"deleteLinkRule is not supported for ActionLogicRule\");\n default:\n throw new Error(`Unsupported logic rule type: ${irRule.type}`);\n }\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 { createHash } from \"node:crypto\";\n\n/**\n * Generate a deterministic UUID v5-like identifier from a string.\n * Uses SHA-256 hash truncated to UUID format with version (5) and\n * variant (RFC 4122) bits set for spec compliance.\n */\nexport function toUuid(str) {\n const hashBytes = createHash(\"sha256\").update(str).digest();\n // Set version to 5 (name-based SHA) in byte 6: clear top nibble, set to 0101\n hashBytes[6] = hashBytes[6] & 0x0f | 0x50;\n // Set variant to RFC 4122 in byte 8: clear top 2 bits, set to 10\n hashBytes[8] = hashBytes[8] & 0x3f | 0x80;\n const hex = hashBytes.subarray(0, 16).toString(\"hex\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;\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 { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { convertIrLogicRulesToActionLogicRules } from \"./ActionLogicRuleConverter.js\";\nimport { toUuid } from \"./ridUtils.js\";\n\n/**\n * Extended return type that uses ActionTypeFullMetadata instead of ActionTypeV2.\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(ir) {\n const baseMetadata = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ir);\n const actionTypes = this.convertActionTypesWithFullLogicRules(Object.values(ir.actionTypes), ir);\n\n // Post-process object types to use UUID-based RIDs\n const objectTypes = this.convertObjectTypesWithUuidRids(baseMetadata.objectTypes);\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 static convertObjectTypesWithUuidRids(objectTypes) {\n const result = {};\n for (const [apiName, fullMetadata] of Object.entries(objectTypes)) {\n const objectType = fullMetadata.objectType;\n const properties = {};\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 result[apiName] = {\n ...fullMetadata,\n objectType: {\n ...objectType,\n rid: `ri.ontology.main.object-type.${toUuid(apiName)}`,\n properties\n }\n };\n }\n return result;\n }\n\n /**\n * Convert IR action types to ActionTypeFullMetadata format.\n * Reuses base converter for action type conversion, then process\n * RIDs to use UUID-based format and adds fullLogicRules.\n */\n static convertActionTypesWithFullLogicRules(actions, ir) {\n const baseActionTypes = OntologyIrToFullMetadataConverter.getOsdkActionTypes(actions);\n\n // Build a lookup from apiName to the original IR action for logic rules\n const actionsByApiName = new Map(actions.map(a => [a.actionType.metadata.apiName, a]));\n const result = {};\n for (const [apiName, baseActionType] of Object.entries(baseActionTypes)) {\n const action = actionsByApiName.get(apiName);\n result[apiName] = {\n actionType: {\n ...baseActionType,\n rid: `ri.ontology.main.action-type.${toUuid(apiName)}`\n },\n fullLogicRules: convertIrLogicRulesToActionLogicRules(action.actionType.actionTypeLogic.logic.rules, action, ir)\n };\n }\n return result;\n }\n}"]}
@@ -23,10 +23,10 @@ declare class PreviewOntologyIrConverter {
23
23
  private static convertObjectTypesWithUuidRids;
24
24
  /**
25
25
  * Convert IR action types to ActionTypeFullMetadata format.
26
- * Uses base converter for parameters and operations, adds fullLogicRules.
26
+ * Reuses base converter for action type conversion, then process
27
+ * RIDs to use UUID-based format and adds fullLogicRules.
27
28
  */
28
29
  private static convertActionTypesWithFullLogicRules;
29
- private static convertActionTypeStatus;
30
30
  }
31
31
 
32
32
  export { type PreviewOntologyFullMetadata, PreviewOntologyIrConverter };
@@ -61,11 +61,25 @@ function getObjectReferenceType(action, paramKey) {
61
61
  }
62
62
 
63
63
  /**
64
- * Convert OntologyIrLogicRule to ActionLogicRule for use in ActionTypeFullMetadata.
64
+ * Build lookups once and convert all logic rules for an action.
65
+ * Avoids rebuilding lookup Maps on every rule.
66
+ */
67
+ export function convertIrLogicRulesToActionLogicRules(rules, action, ir) {
68
+ const objectLookup = buildObjectTypeLookup(ir);
69
+ const interfaceLookup = buildInterfaceTypeLookup(ir);
70
+ return rules.map(irRule => convertSingleRule(irRule, action, objectLookup, interfaceLookup));
71
+ }
72
+
73
+ /**
74
+ * Convert a single OntologyIrLogicRule to ActionLogicRule.
75
+ * Kept as a public API for callers that only need a single rule conversion.
65
76
  */
66
77
  export function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
67
78
  const objectLookup = buildObjectTypeLookup(ir);
68
79
  const interfaceLookup = buildInterfaceTypeLookup(ir);
80
+ return convertSingleRule(irRule, action, objectLookup, interfaceLookup);
81
+ }
82
+ function convertSingleRule(irRule, action, objectLookup, interfaceLookup) {
69
83
  switch (irRule.type) {
70
84
  case "addObjectRule":
71
85
  {
@@ -86,6 +100,9 @@ export function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
86
100
  {
87
101
  const r = irRule.addOrModifyObjectRuleV2;
88
102
  const objRef = getObjectReferenceType(action, r.objectToModify);
103
+ // propertyArguments left empty: the downstream generator resolves
104
+ // property mappings from the action parameter configuration rather
105
+ // than from the logic rule itself for createOrModify rules.
89
106
  const result = {
90
107
  type: "createOrModifyObject",
91
108
  objectTypeApiName: resolveApiName(objRef.objectTypeId, objectLookup),
@@ -97,11 +114,16 @@ export function convertIrLogicRuleToActionLogicRule(irRule, action, ir) {
97
114
  case "modifyObjectRule":
98
115
  {
99
116
  const r = irRule.modifyObjectRule;
117
+ // Validate that the parameter is an objectReference (throws if not)
100
118
  getObjectReferenceType(action, r.objectToModify);
119
+ const modifyPropertyArguments = {};
120
+ for (const [k, v] of Object.entries(r.propertyValues)) {
121
+ modifyPropertyArguments[k] = v;
122
+ }
101
123
  const result = {
102
124
  type: "modifyObject",
103
125
  objectToModify: r.objectToModify,
104
- propertyArguments: {},
126
+ propertyArguments: modifyPropertyArguments,
105
127
  structPropertyArguments: {}
106
128
  };
107
129
  return result;
@@ -1 +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,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H,MAAM,CAACuB,mBAAmB;QACpC,MAAMd,MAEL,GAAG;UACFb,IAAI,EAAE,iBAAiB;UACvB4B,uBAAuB,EAAErB,CAAC,CAACsB,gCAAgC;UAC3DH,uBAAuB,EAAE,CAAC,CAAC;UAC3BV,uBAAuB,EAAE,CAAC;QAC5B,CAAC;QACD,OAAOH,MAAM;MACf;IAEA,KAAK,aAAa;MAChB,MAAM,IAAIZ,KAAK,CAAC,kDAAkD,CAAC;IAErE,KAAK,gBAAgB;MACnB,MAAM,IAAIA,KAAK,CAAC,qDAAqD,CAAC;IAExE;MACE,MAAM,IAAIA,KAAK,CACb,gCAAiCG,MAAM,CAAsBJ,IAAI,EACnE,CAAC;EACL;AACF","ignoreList":[]}
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","convertIrLogicRulesToActionLogicRules","rules","objectLookup","interfaceLookup","map","irRule","convertSingleRule","convertIrLogicRuleToActionLogicRule","r","addObjectRule","propertyArguments","k","v","propertyValues","result","objectTypeApiName","objectTypeId","structPropertyArguments","addOrModifyObjectRuleV2","objRef","objectToModify","modifyObjectRule","modifyPropertyArguments","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 * Build lookups once and convert all logic rules for an action.\n * Avoids rebuilding lookup Maps on every rule.\n */\nexport function convertIrLogicRulesToActionLogicRules(\n rules: OntologyIrLogicRule[],\n action: OntologyIrActionTypeBlockDataV2,\n ir?: OntologyIrOntologyBlockDataV2,\n): Ontologies.ActionLogicRule[] {\n const objectLookup = buildObjectTypeLookup(ir);\n const interfaceLookup = buildInterfaceTypeLookup(ir);\n\n return rules.map(irRule =>\n convertSingleRule(irRule, action, objectLookup, interfaceLookup)\n );\n}\n\n/**\n * Convert a single OntologyIrLogicRule to ActionLogicRule.\n * Kept as a public API for callers that only need a single rule conversion.\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 return convertSingleRule(irRule, action, objectLookup, interfaceLookup);\n}\n\nfunction convertSingleRule(\n irRule: OntologyIrLogicRule,\n action: OntologyIrActionTypeBlockDataV2,\n objectLookup: ApiNameLookup | undefined,\n interfaceLookup: ApiNameLookup | undefined,\n): Ontologies.ActionLogicRule {\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 // propertyArguments left empty: the downstream generator resolves\n // property mappings from the action parameter configuration rather\n // than from the logic rule itself for createOrModify rules.\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 // Validate that the parameter is an objectReference (throws if not)\n getObjectReferenceType(action, r.objectToModify);\n const modifyPropertyArguments: Record<\n Ontologies.PropertyApiName,\n Ontologies.LogicRuleArgument\n > = {};\n for (const [k, v] of Object.entries(r.propertyValues)) {\n modifyPropertyArguments[k] = v as Ontologies.LogicRuleArgument;\n }\n const result: Ontologies.ModifyObjectLogicRule & {\n type: \"modifyObject\";\n } = {\n type: \"modifyObject\",\n objectToModify: r.objectToModify,\n propertyArguments: modifyPropertyArguments,\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,CAAC;EACxD;EACA,OAAO;IAAEP,IAAI;IAAEE;EAAa,CAAC;AAC/B;AAEA,SAASS,wBAAwBA,CAC/Bd,EAA6C,EAClB;EAC3B,IAAI,CAACA,EAAE,EAAEe,cAAc,EAAE;IACvB,OAAOb,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,CAACe,cAAc,CAAC,EAAE;IAC5D,MAAML,OAAO,GAAGH,KAAK,CAACS,aAAa,CAACN,OAAO;IAC3CP,IAAI,CAACS,GAAG,CAACN,GAAG,EAAEI,OAAO,CAAC;IACtBL,YAAY,CAACO,GAAG,CAACF,OAAO,CAACG,OAAO,CAAC,KAAK,E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IAAIhB,KAAK,CAAC,kDAAkD,CAAC;IAErE,KAAK,gBAAgB;MACnB,MAAM,IAAIA,KAAK,CAAC,qDAAqD,CAAC;IAExE;MACE,MAAM,IAAIA,KAAK,CACb,gCAAiCO,MAAM,CAAsBR,IAAI,EACnE,CAAC;EACL;AACF","ignoreList":[]}
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
18
- import { convertIrLogicRuleToActionLogicRule } from "./ActionLogicRuleConverter.js";
18
+ import { convertIrLogicRulesToActionLogicRules } from "./ActionLogicRuleConverter.js";
19
19
  import { toUuid } from "./ridUtils.js";
20
20
 
21
21
  /**
@@ -78,39 +78,26 @@ export class PreviewOntologyIrConverter {
78
78
 
79
79
  /**
80
80
  * Convert IR action types to ActionTypeFullMetadata format.
81
- * Uses base converter for parameters and operations, adds fullLogicRules.
81
+ * Reuses base converter for action type conversion, then process
82
+ * RIDs to use UUID-based format and adds fullLogicRules.
82
83
  */
83
84
  static convertActionTypesWithFullLogicRules(actions, ir) {
85
+ const baseActionTypes = OntologyIrToFullMetadataConverter.getOsdkActionTypes(actions);
86
+
87
+ // Build a lookup from apiName to the original IR action for logic rules
88
+ const actionsByApiName = new Map(actions.map(a => [a.actionType.metadata.apiName, a]));
84
89
  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))
90
+ for (const [apiName, baseActionType] of Object.entries(baseActionTypes)) {
91
+ const action = actionsByApiName.get(apiName);
92
+ result[apiName] = {
93
+ actionType: {
94
+ ...baseActionType,
95
+ rid: `ri.ontology.main.action-type.${toUuid(apiName)}`
96
+ },
97
+ fullLogicRules: convertIrLogicRulesToActionLogicRules(action.actionType.actionTypeLogic.logic.rules, action, ir)
99
98
  };
100
99
  }
101
100
  return result;
102
101
  }
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
102
  }
116
103
  //# sourceMappingURL=PreviewOntologyIrConverter.js.map
@@ -1 +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;A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f;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":[]}
1
+ {"version":3,"file":"PreviewOntologyIrConverter.js","names":["OntologyIrToFullMetadataConverter","convertIrLogicRulesToActionLogicRules","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","baseActionTypes","getOsdkActionTypes","actionsByApiName","Map","map","a","actionType","metadata","baseActionType","action","get","fullLogicRules","actionTypeLogic","logic","rules"],"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 OntologyIrOntologyBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { convertIrLogicRulesToActionLogicRules } 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 * Reuses base converter for action type conversion, then process\n * RIDs to use UUID-based format and adds fullLogicRules.\n */\n private static convertActionTypesWithFullLogicRules(\n actions: OntologyIrActionTypeBlockDataV2[],\n ir: OntologyIrOntologyBlockDataV2,\n ): Record<string, Ontologies.ActionTypeFullMetadata> {\n const baseActionTypes = OntologyIrToFullMetadataConverter\n .getOsdkActionTypes(actions);\n\n // Build a lookup from apiName to the original IR action for logic rules\n const actionsByApiName = new Map(\n actions.map(a => [a.actionType.metadata.apiName, a]),\n );\n\n const result: Record<string, Ontologies.ActionTypeFullMetadata> = {};\n for (const [apiName, baseActionType] of Object.entries(baseActionTypes)) {\n const action = actionsByApiName.get(apiName)!;\n result[apiName] = {\n actionType: {\n ...baseActionType,\n rid: `ri.ontology.main.action-type.${toUuid(apiName)}`,\n },\n fullLogicRules: convertIrLogicRulesToActionLogicRules(\n action.actionType.actionTypeLogic.logic.rules,\n action,\n ir,\n ),\n };\n }\n\n return result;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,iCAAiC,QAAQ,uCAAuC;AACzF,SAASC,qCAAqC,QAAQ,+BAA+B;AACrF,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,CAAC,EAC7BH,EACF,CAAC;;IAED;IACA,MAAMO,WAAW,GAAG,IAAI,CAACC,8BAA8B,CACrDP,YAAY,CAAC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