@osdk/vite-plugin-oac 0.1.0-beta.0 → 0.1.0-beta.2

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 (88) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/build/browser/Logger.js +64 -0
  3. package/build/browser/Logger.js.map +1 -0
  4. package/build/browser/OacConfig.js +22 -0
  5. package/build/browser/OacConfig.js.map +1 -0
  6. package/build/browser/OacContext.js +42 -0
  7. package/build/browser/OacContext.js.map +1 -0
  8. package/build/browser/OacDevServer.js +80 -0
  9. package/build/browser/OacDevServer.js.map +1 -0
  10. package/build/browser/OacServerContext.js +26 -0
  11. package/build/browser/OacServerContext.js.map +1 -0
  12. package/build/browser/applyOntologyAndSeed.js +38 -0
  13. package/build/browser/applyOntologyAndSeed.js.map +1 -0
  14. package/build/browser/generateOntologyAssets.js +81 -87
  15. package/build/browser/generateOntologyAssets.js.map +1 -1
  16. package/build/browser/index.js +2 -52
  17. package/build/browser/index.js.map +1 -1
  18. package/build/browser/ontologyAsCode.js +58 -0
  19. package/build/browser/ontologyAsCode.js.map +1 -0
  20. package/build/browser/registerOntologyFullMetadata.js +90 -57
  21. package/build/browser/registerOntologyFullMetadata.js.map +1 -1
  22. package/build/browser/syncDirectories.js +11 -34
  23. package/build/browser/syncDirectories.js.map +1 -1
  24. package/build/cjs/index.cjs +487 -414
  25. package/build/cjs/index.cjs.map +1 -1
  26. package/build/cjs/index.d.cts +20 -6
  27. package/build/esm/Logger.js +64 -0
  28. package/build/esm/Logger.js.map +1 -0
  29. package/build/esm/OacConfig.js +22 -0
  30. package/build/esm/OacConfig.js.map +1 -0
  31. package/build/esm/OacContext.js +42 -0
  32. package/build/esm/OacContext.js.map +1 -0
  33. package/build/esm/OacDevServer.js +80 -0
  34. package/build/esm/OacDevServer.js.map +1 -0
  35. package/build/esm/OacServerContext.js +26 -0
  36. package/build/esm/OacServerContext.js.map +1 -0
  37. package/build/esm/applyOntologyAndSeed.js +38 -0
  38. package/build/esm/applyOntologyAndSeed.js.map +1 -0
  39. package/build/esm/generateOntologyAssets.js +81 -87
  40. package/build/esm/generateOntologyAssets.js.map +1 -1
  41. package/build/esm/index.js +2 -52
  42. package/build/esm/index.js.map +1 -1
  43. package/build/esm/ontologyAsCode.js +58 -0
  44. package/build/esm/ontologyAsCode.js.map +1 -0
  45. package/build/esm/registerOntologyFullMetadata.js +90 -57
  46. package/build/esm/registerOntologyFullMetadata.js.map +1 -1
  47. package/build/esm/syncDirectories.js +11 -34
  48. package/build/esm/syncDirectories.js.map +1 -1
  49. package/build/types/Logger.d.ts +18 -0
  50. package/build/types/Logger.d.ts.map +1 -0
  51. package/build/types/OacConfig.d.ts +12 -0
  52. package/build/types/OacConfig.d.ts.map +1 -0
  53. package/build/types/OacContext.d.ts +12 -0
  54. package/build/types/OacContext.d.ts.map +1 -0
  55. package/build/types/OacDevServer.d.ts +10 -0
  56. package/build/types/OacDevServer.d.ts.map +1 -0
  57. package/build/types/OacServerContext.d.ts +12 -0
  58. package/build/types/OacServerContext.d.ts.map +1 -0
  59. package/build/types/applyOntologyAndSeed.d.ts +3 -0
  60. package/build/types/applyOntologyAndSeed.d.ts.map +1 -0
  61. package/build/types/generateOntologyAssets.d.ts +4 -7
  62. package/build/types/generateOntologyAssets.d.ts.map +1 -1
  63. package/build/types/index.d.ts +2 -11
  64. package/build/types/index.d.ts.map +1 -1
  65. package/build/types/ontologyAsCode.d.ts +7 -0
  66. package/build/types/ontologyAsCode.d.ts.map +1 -0
  67. package/build/types/registerOntologyFullMetadata.d.ts.map +1 -1
  68. package/build/types/syncDirectories.d.ts +1 -1
  69. package/build/types/syncDirectories.d.ts.map +1 -1
  70. package/package.json +12 -9
  71. package/build/browser/FauxFoundryTypes.js +0 -2
  72. package/build/browser/FauxFoundryTypes.js.map +0 -1
  73. package/build/browser/FoundryMiddlewareController.js +0 -88
  74. package/build/browser/FoundryMiddlewareController.js.map +0 -1
  75. package/build/browser/watchOntologyAsCode.js +0 -69
  76. package/build/browser/watchOntologyAsCode.js.map +0 -1
  77. package/build/esm/FauxFoundryTypes.js +0 -2
  78. package/build/esm/FauxFoundryTypes.js.map +0 -1
  79. package/build/esm/FoundryMiddlewareController.js +0 -88
  80. package/build/esm/FoundryMiddlewareController.js.map +0 -1
  81. package/build/esm/watchOntologyAsCode.js +0 -69
  82. package/build/esm/watchOntologyAsCode.js.map +0 -1
  83. package/build/types/FauxFoundryTypes.d.ts +0 -2
  84. package/build/types/FauxFoundryTypes.d.ts.map +0 -1
  85. package/build/types/FoundryMiddlewareController.d.ts +0 -14
  86. package/build/types/FoundryMiddlewareController.d.ts.map +0 -1
  87. package/build/types/watchOntologyAsCode.d.ts +0 -10
  88. package/build/types/watchOntologyAsCode.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"generateOntologyAssets.js","names":["OntologyIrToFullMetadataConverter","execa","fs","path","syncDirectories","NOISY","generateOntologyAssets","logger","ontologyDir","existsSync","mkdirSync","recursive","info","timestamp","ontologyJsToIr","ontologyIrToFullMetadata","fullMetadataToOsdk","stdout","stderr","exitCode","error","Error","irContent","promises","readFile","encoding","blockData","JSON","parse","fullMeta","getFullMetadataFromIr","writeFile","stringify","message","String","tempDir","join","process","cwd","rm","force","mkdir","tempSrcDir","targetDir","cleanupError","warn"],"sources":["generateOntologyAssets.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 {\n type OntologyIrOntologyBlockDataV2,\n OntologyIrToFullMetadataConverter,\n} from \"@osdk/generator-converters.ontologyir\";\nimport { execa } from \"execa\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Logger } from \"vite\";\nimport { syncDirectories } from \"./syncDirectories.js\";\n\nexport const NOISY = false;\n\nexport interface GenerateOntologyAssetsOptions {\n logger: Logger;\n ontologyDir: string;\n}\n\n/**\n * Generate all ontology assets: IR, full metadata, and OSDK.\n * This function contains the core generation logic extracted from watchOntologyAsCode\n * so it can be used both in dev mode (via file watching) and build mode.\n */\nexport async function generateOntologyAssets({\n logger,\n ontologyDir,\n}: GenerateOntologyAssetsOptions): Promise<void> {\n // Ensure the ontology directory exists\n if (!fs.existsSync(ontologyDir)) {\n fs.mkdirSync(ontologyDir, { recursive: true });\n logger.info(\"Created .ontology directory\", { timestamp: true });\n }\n\n // Generate the assets in sequence\n await ontologyJsToIr(logger);\n await ontologyIrToFullMetadata(logger);\n await fullMetadataToOsdk(logger);\n}\n\n/**\n * Convert ontology.mjs to IR format using the maker tool\n */\nasync function ontologyJsToIr(logger: Logger): Promise<void> {\n if (NOISY) {\n logger.info(\"Generating Ontology IR\", { timestamp: true });\n }\n\n const { stdout, stderr, exitCode } = await execa(\"pnpm\", [\n \"exec\",\n \"maker\",\n \"-i\",\n \".ontology/ontology.mjs\",\n \"-o\",\n \".ontology.ir.json\",\n ]);\n\n if (exitCode !== 0) {\n logger.error(`Ontology IR generation failed with exit code ${exitCode}`, {\n timestamp: true,\n });\n if (stderr) {\n logger.error(`Command stderr: ${stderr}`, { timestamp: true });\n }\n throw new Error(`Failed to generate ontology IR: exit code ${exitCode}`);\n }\n\n // Log stdout for debugging if needed\n if (stdout && NOISY) {\n logger.info(`Ontology IR generation output: ${stdout}`, {\n timestamp: true,\n });\n }\n}\n\n/**\n * Convert IR to full metadata format\n */\nasync function ontologyIrToFullMetadata(logger: Logger): Promise<void> {\n if (NOISY) {\n logger.info(\"Converting IR to Full metadata\", { timestamp: true });\n }\n\n try {\n const irContent = await fs.promises.readFile(\"./.ontology.ir.json\", {\n encoding: \"utf-8\",\n });\n const blockData = JSON.parse(irContent)\n .blockData as OntologyIrOntologyBlockDataV2;\n\n const fullMeta = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(\n blockData,\n );\n\n await fs.promises.writeFile(\n \"./.ontology.json\",\n JSON.stringify(fullMeta, null, 2),\n );\n\n if (NOISY) {\n logger.info(\"Successfully converted IR to full metadata\", {\n timestamp: true,\n });\n }\n } catch (error) {\n logger.error(\n `Failed to convert IR to full metadata: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { timestamp: true },\n );\n throw error;\n }\n}\n\n/**\n * Generate OSDK from full metadata\n */\nasync function fullMetadataToOsdk(logger: Logger): Promise<void> {\n if (NOISY) {\n logger.info(\"Generating OSDK from full metadata\", { timestamp: true });\n }\n\n // First create a clean temporary directory to generate the SDK into\n const tempDir = path.join(\n process.cwd(),\n \"node_modules\",\n \".tmp\",\n \"osdkGeneration\",\n );\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n await fs.promises.mkdir(tempDir, { recursive: true });\n\n try {\n // Then generate the source code for the osdk\n const tempSrcDir = path.join(tempDir, \"src\");\n const { stdout, stderr, exitCode } = await execa(\"pnpm\", [\n \"exec\",\n \"osdk\",\n \"unstable\",\n \"typescript\",\n \"generate\",\n \"--outDir\",\n tempSrcDir,\n \"--ontologyPath\",\n \".ontology.json\",\n \"--beta\",\n \"true\",\n \"--packageType\",\n \"module\",\n \"--version\",\n \"dev\",\n ]);\n\n if (stdout && NOISY) {\n logger.info(`OSDK generation output: ${stdout}`, { timestamp: true });\n }\n if (stderr) {\n logger.error(`OSDK generation stderr: ${stderr}`, { timestamp: true });\n }\n\n // Then if it was successful, synchronize the generated code with the target directory\n if (exitCode === 0) {\n const targetDir = \".osdk/src\";\n try {\n if (NOISY) {\n logger.info(\n \"OSDK generation successful, synchronizing with target directory\",\n {\n timestamp: true,\n },\n );\n }\n\n // Use granular synchronization instead of wholesale replacement\n await syncDirectories(tempSrcDir, targetDir, logger);\n\n if (NOISY) {\n logger.info(\n `Successfully synchronized ${targetDir} with newly generated code`,\n {\n timestamp: true,\n },\n );\n }\n\n // Clean up temporary directory after successful sync\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n } catch (error) {\n logger.error(\n `Failed to synchronize ${targetDir} directory: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { timestamp: true },\n );\n logger.error(`Temporary files left at: ${tempDir}`, {\n timestamp: true,\n });\n throw error;\n }\n } else {\n logger.error(`OSDK generation failed with exit code ${exitCode}`, {\n timestamp: true,\n });\n logger.error(`Temporary files left at: ${tempDir}`, { timestamp: true });\n throw new Error(`OSDK generation failed with exit code ${exitCode}`);\n }\n } catch (error) {\n // Make sure to clean up temp directory even if there's an error\n try {\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n } catch (cleanupError) {\n logger.warn(\n `Failed to clean up temporary directory: ${\n cleanupError instanceof Error\n ? cleanupError.message\n : String(cleanupError)\n }`,\n { timestamp: true },\n );\n }\n throw error;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,iCAAiC,QAC5B,uCAAuC;AAC9C,SAASC,KAAK,QAAQ,OAAO;AAC7B,OAAOC,EAAE,MAAM,SAAS;AACxB,OAAOC,IAAI,MAAM,WAAW;AAE5B,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,OAAO,MAAMC,KAAK,GAAG,KAAK;AAO1B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,sBAAsBA,CAAC;EAC3CC,MAAM;EACNC;AAC6B,CAAC,EAAiB;EAC/C;EACA,IAAI,CAACN,EAAE,CAACO,UAAU,CAACD,WAAW,CAAC,EAAE;IAC/BN,EAAE,CAACQ,SAAS,CAACF,WAAW,EAAE;MAAEG,SAAS,EAAE;IAAK,CAAC,CAAC;IAC9CJ,MAAM,CAACK,IAAI,CAAC,6BAA6B,EAAE;MAAEC,SAAS,EAAE;IAAK,CAAC,CA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AyBuB,SAAS,eAChCvB,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACa,OAAO,GAAGC,MAAM,CAACd,KAAK,CAAC,EACtD,EACF;UAAEP,SAAS,EAAE;QAAK,CACpB,CAAC;QACDN,MAAM,CAACa,KAAK,CAAC,4BAA4Be,OAAO,EAAE,EAAE;UAClDtB,SAAS,EAAE;QACb,CAAC,CAAC;QACF,MAAMO,KAAK;MACb;IACF,CAAC,MAAM;MACLb,MAAM,CAACa,KAAK,CAAC,yCAAyCD,QAAQ,EAAE,EAAE;QAChEN,SAAS,EAAE;MACb,CAAC,CAAC;MACFN,MAAM,CAACa,KAAK,CAAC,4BAA4Be,OAAO,EAAE,EAAE;QAAEtB,SAAS,EAAE;MAAK,CAAC,CAAC;MACxE,MAAM,IAAIQ,KAAK,CAAC,yCAAyCF,QAAQ,EAAE,CAAC;IACtE;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd;IACA,IAAI;MACF,MAAMlB,EAAE,CAACqB,QAAQ,CAACgB,EAAE,CAACJ,OAAO,EAAE;QAAExB,SAAS,EAAE,IAAI;QAAE6B,KAAK,EAAE;MAAK,CAAC,CAAC;IACjE,CAAC,CAAC,OAAOI,YAAY,EAAE;MACrBrC,MAAM,CAACsC,IAAI,CACT,2CACED,YAAY,YAAYvB,KAAK,GACzBuB,YAAY,CAACX,OAAO,GACpBC,MAAM,CAACU,YAAY,CAAC,EACxB,EACF;QAAE/B,SAAS,EAAE;MAAK,CACpB,CAAC;IACH;IACA,MAAMO,KAAK;EACb;AACF","ignoreList":[]}
1
+ {"version":3,"file":"generateOntologyAssets.js","names":["OntologyIrToFullMetadataConverter","execa","fs","path","inspect","syncDirectories","generateOntologyAssets","opts","ontologyDir","logger","promises","mkdir","workDir","recursive","existsSync","mkdirSync","info","ontologyJsToIr","ontologyIrToFullMetadata","fullMetadataToOsdk","ontologyIrPath","join","ontologyFullMetadataPath","debug","stdout","stderr","exitCode","error","Error","irContent","readFile","encoding","blockData","JSON","parse","fullMeta","getFullMetadataFromIr","writeFile","stringify","tempDir","rm","force","tempSrcDir","targetDir","compileOsdk","cleanupError","warn","cwd"],"sources":["generateOntologyAssets.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 {\n type OntologyIrOntologyBlockDataV2,\n OntologyIrToFullMetadataConverter,\n} from \"@osdk/generator-converters.ontologyir\";\nimport { execa } from \"execa\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { inspect } from \"node:util\";\nimport type { Logger } from \"./Logger.js\";\nimport type { OacContext } from \"./OacContext.js\";\nimport { syncDirectories } from \"./syncDirectories.js\";\n\n/**\n * Generate all ontology assets: IR, full metadata, and OSDK.\n * This function contains the core generation logic extracted from watchOntologyAsCode\n * so it can be used both in dev mode (via file watching) and build mode.\n */\nexport async function generateOntologyAssets(\n opts: OacContext,\n): Promise<void> {\n const { ontologyDir, logger } = opts;\n await fs.promises.mkdir(opts.workDir, { recursive: true });\n\n // Ensure the ontology directory exists\n if (!fs.existsSync(ontologyDir)) {\n fs.mkdirSync(ontologyDir, { recursive: true });\n logger.info(\"Created .ontology directory\");\n }\n\n // Generate the assets in sequence\n await ontologyJsToIr(opts);\n await ontologyIrToFullMetadata(opts);\n await fullMetadataToOsdk(opts);\n}\n\nexport function ontologyIrPath(workDir: string): string {\n return path.join(workDir, \".ontology.ir.json\");\n}\n\nexport function ontologyFullMetadataPath(workDir: string): string {\n return path.join(workDir, \".ontology.json\");\n}\n\n/**\n * Convert ontology.mjs to IR format using the maker tool\n */\nasync function ontologyJsToIr(\n { logger, ontologyDir, workDir }: OacContext,\n): Promise<void> {\n logger.debug(\"Generating Ontology IR\");\n\n const { stdout, stderr, exitCode } = await execa(\"pnpm\", [\n \"exec\",\n \"maker\",\n \"-i\",\n `${ontologyDir}/ontology.mts`,\n \"-o\",\n ontologyIrPath(workDir),\n ]);\n\n if (exitCode !== 0) {\n logger.error(`Ontology IR generation failed with exit code ${exitCode}`);\n if (stderr) {\n logger.error(`Command stderr: ${stderr}`);\n }\n throw new Error(`Failed to generate ontology IR: exit code ${exitCode}`);\n }\n\n // Log stdout for debugging if needed\n if (stdout) {\n logger.debug(`Ontology IR generation output: ${stdout}`);\n }\n}\n\n/**\n * Convert IR to full metadata format\n */\nasync function ontologyIrToFullMetadata(\n { logger, workDir }: OacContext,\n): Promise<void> {\n logger.debug(\"Converting IR to Full metadata\");\n\n try {\n const irContent = await fs.promises.readFile(ontologyIrPath(workDir), {\n encoding: \"utf-8\",\n });\n const blockData = JSON.parse(irContent)\n .blockData as OntologyIrOntologyBlockDataV2;\n\n const fullMeta = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(\n blockData,\n );\n\n await fs.promises.writeFile(\n ontologyFullMetadataPath(workDir),\n JSON.stringify(fullMeta, null, 2),\n );\n\n logger.debug(\"Successfully converted IR to full metadata\");\n } catch (error) {\n logger.error(\n `Failed to convert IR to full metadata: ${inspect(error)}`,\n );\n throw error;\n }\n}\n\n/**\n * Generate OSDK from full metadata\n */\nasync function fullMetadataToOsdk(\n { logger, workDir }: OacContext,\n): Promise<void> {\n logger.debug(\"Generating OSDK from full metadata\");\n\n // First create a clean temporary directory to generate the SDK into\n const tempDir = path.join(\n workDir,\n \".osdkGenerationTmp\",\n \"src\",\n );\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n await fs.promises.mkdir(tempDir, { recursive: true });\n\n // The osdk cli currently mutes package.json files which we don't want in this case\n // so we give it a fake package.json file\n await fs.promises.writeFile(\n path.join(tempDir, \"..\", \"package.json\"),\n JSON.stringify({}, null, 2),\n { encoding: \"utf-8\" },\n );\n\n try {\n // Then generate the source code for the osdk\n const tempSrcDir = path.join(tempDir, \"src\");\n const { stdout, stderr, exitCode } = await execa(\"pnpm\", [\n \"exec\",\n \"osdk\",\n \"unstable\",\n \"typescript\",\n \"generate\",\n \"--outDir\",\n tempSrcDir,\n \"--ontologyPath\",\n ontologyFullMetadataPath(workDir),\n \"--beta\",\n \"true\",\n \"--packageType\",\n \"module\",\n \"--version\",\n \"dev\",\n ]);\n\n logger.debug(`OSDK generation output: ${stdout}`);\n\n if (stderr) {\n logger.error(`OSDK generation stderr: ${stderr}`);\n }\n\n // Then if it was successful, synchronize the generated code with the target directory\n if (exitCode === 0) {\n // TODO we should just generate this whole thing into the work dir?\n const targetDir = \".osdk/src\";\n try {\n logger.debug(\n \"OSDK generation successful, synchronizing with target directory\",\n );\n\n // Use granular synchronization instead of wholesale replacement\n await syncDirectories(tempSrcDir, targetDir, logger);\n\n logger.debug(\n `Successfully synchronized ${targetDir} with newly generated code`,\n );\n\n await compileOsdk(logger);\n\n // Clean up temporary directory after successful sync\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n } catch (error) {\n logger.error(\n `Failed to synchronize ${targetDir} directory: ${inspect(error)}`,\n );\n logger.error(`Temporary files left at: ${tempDir}`);\n throw error;\n }\n } else {\n logger.error(`OSDK generation failed with exit code ${exitCode}`);\n logger.error(`Temporary files left at: ${tempDir}`);\n throw new Error(`OSDK generation failed with exit code ${exitCode}`);\n }\n } catch (error) {\n // Make sure to clean up temp directory even if there's an error\n try {\n await fs.promises.rm(tempDir, { recursive: true, force: true });\n } catch (cleanupError) {\n logger.warn(\n `Failed to clean up temporary directory: ${inspect(cleanupError)}`,\n );\n }\n throw error;\n }\n}\n\nasync function compileOsdk(logger: Logger) {\n const { stdout, stderr, exitCode } = await execa(\"pnpm\", [\n \"exec\",\n \"tsc\",\n ], {\n cwd: \".osdk\",\n });\n\n logger.debug(`OSDK generation output: ${stdout}`);\n\n if (st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,IAAI;QAAE4B,KAAK,EAAE;MAAK,CAAC,CAAC;IACjE,CAAC,CAAC,OAAOI,YAAY,EAAE;MACrBpC,MAAM,CAACqC,IAAI,CACT,2CAA2C1C,OAAO,CAACyC,YAAY,CAAC,EAClE,CAAC;IACH;IACA,MAAMlB,KAAK;EACb;AACF;AAEA,eAAeiB,WAAWA,CAACnC,MAAc,EAAE;EACzC,MAAM;IAAEe,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAG,MAAMzB,KAAK,CAAC,MAAM,EAAE,CACvD,MAAM,EACN,KAAK,CACN,EAAE;IACD8C,GAAG,EAAE;EACP,CAAC,CAAC;EAEFtC,MAAM,CAACc,KAAK,CAAC,2BAA2BC,MAAM,EAAE,CAAC;EAEjD,IAAIC,MAAM,EAAE;IACVhB,MAAM,CAACkB,KAAK,CAAC,2BAA2BF,MAAM,EAAE,CAAC;EACnD;EACA,OAAOC,QAAQ;AACjB","ignoreList":[]}
@@ -14,56 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import path from "node:path";
18
- import { FoundryMiddlewareController } from "./FoundryMiddlewareController.js";
19
- import { generateOntologyAssets } from "./generateOntologyAssets.js";
20
- import { watchOntologyAsCode } from "./watchOntologyAsCode.js";
21
-
22
- /**
23
- * Vite plugin for Ontology as Code (OAC) that generates ontology IR, metadata, and OSDK
24
- * in both development and build modes.
25
- */
26
- export function ontologyAsCode(opts) {
27
- const ontologyDir = path.resolve(".ontology");
28
- let config;
29
- return {
30
- name: "oac-vite-plugin",
31
- // eslint-disable-next-line @typescript-eslint/require-await
32
- async configResolved(resolvedConfig) {
33
- config = resolvedConfig;
34
- },
35
- configureServer(server) {
36
- const oacEmitter = watchOntologyAsCode({
37
- watcher: server.watcher,
38
- logger: server.config.logger,
39
- ontologyDir
40
- });
41
- const middlewareUrl = `http${server.config.server.https ? "s" : ""}://localhost:${server.config.server.port}`;
42
- const foundryMiddlewareController = new FoundryMiddlewareController(middlewareUrl, `ri.ontology.main.ontology.00000000-0000-0000-0000-000000000000`, oacEmitter, opts?.hooks);
43
- server.middlewares.use(foundryMiddlewareController.middleware);
44
- },
45
- async buildStart() {
46
- // Generate ontology assets during build
47
- if (config.command === "build") {
48
- config.logger.info("Generating ontology assets for build...", {
49
- timestamp: true
50
- });
51
- try {
52
- await generateOntologyAssets({
53
- logger: config.logger,
54
- ontologyDir
55
- });
56
- config.logger.info("Successfully generated ontology assets for build", {
57
- timestamp: true
58
- });
59
- } catch (error) {
60
- config.logger.error(`Failed to generate ontology assets: ${error instanceof Error ? error.message : String(error)}`, {
61
- timestamp: true
62
- });
63
- throw error;
64
- }
65
- }
66
- }
67
- };
68
- }
17
+ export { OacConfig } from "./OacConfig.js";
18
+ export { ontologyAsCode } from "./ontologyAsCode.js";
69
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["path","FoundryMiddlewareController","generateOntologyAssets","watchOntologyAsCode","ontologyAsCode","opts","ontologyDir","resolve","config","name","configResolved","resolvedConfig","configureServer","server","oacEmitter","watcher","logger","middlewareUrl","https","port","foundryMiddlewareController","hooks","middlewares","use","middleware","buildStart","command","info","timestamp","error","Error","message","String"],"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\nimport type { FauxOntology } from \"@osdk/faux\";\nimport path from \"node:path\";\nimport type { PluginOption, ResolvedConfig } from \"vite\";\nimport { FoundryMiddlewareController } from \"./FoundryMiddlewareController.js\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.js\";\nimport { watchOntologyAsCode } from \"./watchOntologyAsCode.js\";\n\n/**\n * Vite plugin for Ontology as Code (OAC) that generates ontology IR, metadata, and OSDK\n * in both development and build modes.\n */\nexport function ontologyAsCode(opts: {\n hooks?: {\n preSeed?: (fauxOntology: FauxOntology) => Promise<void>;\n };\n}): PluginOption {\n const ontologyDir = path.resolve(\".ontology\");\n\n let config: ResolvedConfig;\n\n return {\n name: \"oac-vite-plugin\",\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n\n configureServer(server) {\n const oacEmitter = watchOntologyAsCode({\n watcher: server.watcher,\n logger: server.config.logger,\n ontologyDir,\n });\n\n const middlewareUrl = `http${\n server.config.server.https ? \"s\" : \"\"\n }://localhost:${server.config.server.port}`;\n\n const foundryMiddlewareController = new FoundryMiddlewareController(\n middlewareUrl,\n `ri.ontology.main.ontology.00000000-0000-0000-0000-000000000000`,\n oacEmitter,\n opts?.hooks,\n );\n\n server.middlewares.use(foundryMiddlewareController.middleware);\n },\n\n async buildStart() {\n // Generate ontology assets during build\n if (config.command === \"build\") {\n config.logger.info(\"Generating ontology assets for build...\", {\n timestamp: true,\n });\n\n try {\n await generateOntologyAssets({\n logger: config.logger,\n ontologyDir,\n });\n\n config.logger.info(\n \"Successfully generated ontology assets for build\",\n { timestamp: true },\n );\n } catch (error) {\n config.logger.error(\n `Failed to generate ontology assets: ${\n error instanceof Error ? error.message : String(error)\n }`,\n { timestamp: true },\n );\n throw error;\n }\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,IAAI,MAAM,WAAW;AAE5B,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,IAI9B,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KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC,EACtD,EACF;YAAED,SAAS,EAAE;UAAK,CACpB,CAAC;UACD,MAAMC,KAAK;QACb;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["OacConfig","ontologyAsCode"],"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 { OacConfig } from \"./OacConfig.js\";\nexport { ontologyAsCode } from \"./ontologyAsCode.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,cAAc,QAAQ,qBAAqB","ignoreList":[]}
@@ -0,0 +1,58 @@
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 * as fs from "node:fs";
18
+ import { generateOntologyAssets } from "./generateOntologyAssets.js";
19
+ import { OacContext } from "./OacContext.js";
20
+ import { OacDevServer } from "./OacDevServer.js";
21
+
22
+ /**
23
+ * Vite plugin for Ontology as Code (OAC) that generates ontology IR, metadata, and OSDK
24
+ * in both development and build modes.
25
+ */
26
+ export function ontologyAsCode(oacConfig) {
27
+ let viteConfig;
28
+ return {
29
+ name: "oac-vite-plugin",
30
+ configResolved(resolvedConfig) {
31
+ viteConfig = resolvedConfig;
32
+ },
33
+ async configureServer(server) {
34
+ const oacDevServer = new OacDevServer(oacConfig, server);
35
+
36
+ // We await here so we get a full ontology compile and seed before the webserver starts
37
+ await oacDevServer.watchOntologyAsCode();
38
+ },
39
+ async buildStart() {
40
+ const ctx = new OacContext(oacConfig, viteConfig);
41
+ // Generate ontology assets during build
42
+ if (viteConfig.command === "build") {
43
+ ctx.logger.info("Generating ontology assets for build...");
44
+ try {
45
+ await fs.promises.mkdir(ctx.workDir, {
46
+ recursive: true
47
+ });
48
+ await generateOntologyAssets(ctx);
49
+ ctx.logger.info("Successfully generated ontology assets for build");
50
+ } catch (error) {
51
+ ctx.logger.error(`Failed to generate ontology assets: ${error instanceof Error ? error.message : String(error)}`);
52
+ throw error;
53
+ }
54
+ }
55
+ }
56
+ };
57
+ }
58
+ //# sourceMappingURL=ontologyAsCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ontologyAsCode.js","names":["fs","generateOntologyAssets","OacContext","OacDevServer","ontologyAsCode","oacConfig","viteConfig","name","configResolved","resolvedConfig","configureServer","server","oacDevServer","watchOntologyAsCode","buildStart","ctx","command","logger","info","promises","mkdir","workDir","recursive","error","Error","message","String"],"sources":["ontologyAsCode.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 * as fs from \"node:fs\";\nimport type { PluginOption, ResolvedConfig } from \"vite\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.js\";\nimport type { OacConfig } from \"./OacConfig.js\";\nimport { OacContext } from \"./OacContext.js\";\nimport { OacDevServer } from \"./OacDevServer.js\";\n\n/**\n * Vite plugin for Ontology as Code (OAC) that generates ontology IR, metadata, and OSDK\n * in both development and build modes.\n */\nexport function ontologyAsCode(\n oacConfig: OacConfig,\n): PluginOption {\n let viteConfig: ResolvedConfig;\n\n return {\n name: \"oac-vite-plugin\",\n\n configResolved(resolvedConfig) {\n viteConfig = resolvedConfig;\n },\n\n async configureServer(server) {\n const oacDevServer = new OacDevServer(oacConfig, server);\n\n // We await here so we get a full ontology compile and seed before the webserver starts\n await oacDevServer.watchOntologyAsCode();\n },\n\n async buildStart() {\n const ctx = new OacContext(oacConfig, viteConfig);\n // Generate ontology assets during build\n if (viteConfig.command === \"build\") {\n ctx.logger.info(\"Generating ontology assets for build...\");\n\n try {\n await fs.promises.mkdir(ctx.workDir, { recursive: true });\n await generateOntologyAssets(ctx);\n\n ctx.logger.info(\n \"Successfully generated ontology assets for build\",\n );\n } catch (error) {\n ctx.logger.error(\n `Failed to generate ontology assets: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n throw error;\n }\n }\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,SAAS;AAE7B,SAASC,sBAAsB,QAAQ,6BAA6B;AAEpE,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,YAAY,QAAQ,mBAAmB;;AAEhD;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,SAAoB,EACN;EACd,IAAIC,UAA0B;EAE9B,OAAO;IACLC,IAAI,EAAE,iBAAiB;IAEvBC,cAAcA,CAACC,cAAc,EAAE;MAC7BH,UAAU,GAAGG,cAAc;IAC7B,CAAC;IAED,MAAMC,eAAeA,CAACC,MAAM,EAAE;MAC5B,MAAMC,YAAY,GAAG,IAAIT,YAAY,CAACE,SAAS,EAAEM,MAAM,CAAC;;MAExD;MACA,MAAMC,YAAY,CAACC,mBAAmB,CAAC,CAAC;IAC1C,CAAC;IAED,MAAMC,UAAUA,CAAA,EAAG;MACjB,MAAMC,GAAG,GAAG,IAAIb,UAAU,CAACG,SAAS,EAAEC,UAAU,CAAC;MACjD;MACA,IAAIA,UAAU,CAACU,OAAO,KAAK,OAAO,EAAE;QAClCD,GAAG,CAACE,MAAM,CAACC,IAAI,CAAC,yCAAyC,CAAC;QAE1D,IAAI;UACF,MAAMlB,EAAE,CAACmB,QAAQ,CAACC,KAAK,CAACL,GAAG,CAACM,OAAO,EAAE;YAAEC,SAAS,EAAE;UAAK,CAAC,CAAC;UACzD,MAAMrB,sBAAsB,CAACc,GAAG,CAAC;UAEjCA,GAAG,CAACE,MAAM,CAACC,IAAI,CACb,kDACF,CAAC;QACH,CAAC,CAAC,OAAOK,KAAK,EAAE;UACdR,GAAG,CAACE,MAAM,CAACM,KAAK,CACd,uCACEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC,EAE1D,CAAC;UACD,MAAMA,KAAK;QACb;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -14,6 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { inspect } from "node:util";
18
+ import invariant from "tiny-invariant";
19
+ inspect.defaultOptions = {
20
+ colors: true,
21
+ depth: Infinity
22
+ };
17
23
  export function registerOntologyFullMetadata(ontology, ontologyFullMetadata) {
18
24
  // Register object types
19
25
  Object.values(ontologyFullMetadata.objectTypes).forEach(objectType => {
@@ -21,7 +27,7 @@ export function registerOntologyFullMetadata(ontology, ontologyFullMetadata) {
21
27
  });
22
28
  // Register action types with implementations
23
29
  Object.values(ontologyFullMetadata.actionTypes).forEach(actionType => {
24
- const implementation = createActionImplementation(actionType);
30
+ const implementation = createActionImplementation(actionType, ontologyFullMetadata);
25
31
  const actionTypeWithCamelCaseApiName = {
26
32
  ...actionType,
27
33
  apiName: camelcase(actionType.apiName)
@@ -39,10 +45,12 @@ export function registerOntologyFullMetadata(ontology, ontologyFullMetadata) {
39
45
  });
40
46
  }
41
47
 
48
+ // NOTE: The ontology full metadata is not sufficient for doing this properly.
49
+
42
50
  /**
43
51
  * Creates a fake implementation for an action type based on its operations
44
52
  */
45
- function createActionImplementation(actionType) {
53
+ function createActionImplementation(actionType, fullMetadata) {
46
54
  return (batch, payload) => {
47
55
  // Extract parameters from payload
48
56
  const params = payload.parameters;
@@ -53,73 +61,51 @@ function createActionImplementation(actionType) {
53
61
  case "createObject":
54
62
  {
55
63
  // Handle create object operation
56
- const objectTypeApiName = operation.objectTypeApiName;
57
- const primaryKey = params.primaryKey_;
64
+ const objectType = getObjectTypeForOperation(operation, fullMetadata);
58
65
 
59
- // Create object data from parameters, excluding the primary key
60
- const objectData = {};
61
- for (const [key, value] of Object.entries(params)) {
62
- if (key !== "primaryKey_") {
63
- const param = actionType.parameters[key];
64
- objectData[key] = toDataValue(value, param);
65
- }
66
- }
67
- batch.addObject(objectTypeApiName, primaryKey, objectData);
66
+ // we don't store the PK with the other properties
67
+ const primaryKeyProp = objectType.objectType.primaryKey;
68
+ const primaryKey = extractAndDelete(params, primaryKeyProp);
69
+
70
+ // Create object data from parameters
71
+ const objectData = paramsToDataValues(params, actionType);
72
+ batch.addObject(objectType.objectType.apiName, primaryKey, objectData);
73
+
74
+ // TODO: this shouldn't send params but the actual object!
75
+ handleObjectLinks(batch, fullMetadata, objectType.objectType.apiName, primaryKey, params);
68
76
  break;
69
77
  }
70
78
  case "modifyObject":
71
79
  {
72
80
  // Handle modify object operation
73
- let objectTypeApiName;
74
- let primaryKey;
75
- if (typeof operation.objectTypeApiName === "string") {
76
- objectTypeApiName = operation.objectTypeApiName;
77
- primaryKey = params.primaryKey_;
78
- } else {
79
- // If objectTypeApiName is a parameter reference
80
- const objectToModify = params[operation.objectTypeApiName];
81
- if (objectToModify) {
82
- objectTypeApiName = objectToModify.objectTypeApiName || objectToModify;
83
- primaryKey = objectToModify.primaryKeyValue || params.primaryKey_;
84
- } else {
85
- // Default to the parameter name if not found
86
- objectTypeApiName = operation.objectTypeApiName;
87
- primaryKey = params.primaryKey_;
88
- }
81
+ const {
82
+ objectType
83
+ } = getObjectTypeForOperation(operation, fullMetadata);
84
+ const primaryKey = extractAndDelete(params, "objectToModifyParameter");
85
+ const targetObject = batch.getObject(objectType.apiName, primaryKey);
86
+ !targetObject ? process.env.NODE_ENV !== "production" ? invariant(false, `Could not find object ${objectType.apiName} with PK ${primaryKey}`) : invariant(false) : void 0;
87
+ if (objectType.primaryKey in params) {
88
+ // TODO Is this true? Or are you allowed to change the PK value?
89
+ !(params[objectType.primaryKey] === primaryKey) ? process.env.NODE_ENV !== "production" ? invariant(false, `If the primary key is provided, it must match the 'objectToModifyParameter'`) : invariant(false) : void 0;
90
+ // delete the key since we don't store it directly on the object
91
+ delete params[objectType.primaryKey];
89
92
  }
93
+ const objectData = paramsToDataValues(params, actionType);
94
+ batch.modifyObject(objectType.apiName, primaryKey, objectData);
90
95
 
91
- // Create object data from parameters, excluding the primary key and objectToModifyParameter
92
- const objectData = {};
93
- for (const [key, value] of Object.entries(params)) {
94
- if (key !== "primaryKey_" && key !== "objectToModifyParameter") {
95
- const param = actionType.parameters[key];
96
- objectData[key] = toDataValue(value, param);
97
- }
98
- }
99
- batch.modifyObject(objectTypeApiName, primaryKey, objectData);
96
+ // TODO: this shouldn't send params but the actual object!
97
+ handleObjectLinks(batch, fullMetadata, objectType.apiName, primaryKey, params);
100
98
  break;
101
99
  }
102
100
  case "deleteObject":
103
101
  {
102
+ const {
103
+ objectType
104
+ } = getObjectTypeForOperation(operation, fullMetadata);
105
+ const primaryKey = extractAndDelete(params, "objectToDeleteParameter");
106
+
104
107
  // Handle delete object operation
105
- let objectTypeApiName;
106
- let primaryKey;
107
- if (typeof operation.objectTypeApiName === "string") {
108
- objectTypeApiName = operation.objectTypeApiName;
109
- primaryKey = params.primaryKey_;
110
- } else {
111
- // If objectTypeApiName is a parameter reference
112
- const objectToDelete = params[operation.objectTypeApiName];
113
- if (objectToDelete) {
114
- objectTypeApiName = objectToDelete.objectTypeApiName || objectToDelete;
115
- primaryKey = objectToDelete.primaryKeyValue || params.primaryKey_;
116
- } else {
117
- // Default to the parameter name if not found
118
- objectTypeApiName = operation.objectTypeApiName;
119
- primaryKey = params.primaryKey_;
120
- }
121
- }
122
- batch.deleteObject(objectTypeApiName, primaryKey);
108
+ batch.deleteObject(objectType.apiName, primaryKey);
123
109
  break;
124
110
  }
125
111
  case "createLink":
@@ -154,6 +140,7 @@ function createActionImplementation(actionType) {
154
140
  }
155
141
  break;
156
142
  }
143
+
157
144
  // Handle other operation types as needed
158
145
  case "createInterfaceObject":
159
146
  case "modifyInterfaceObject":
@@ -167,11 +154,29 @@ function createActionImplementation(actionType) {
167
154
  }
168
155
  };
169
156
  }
157
+ function extractAndDelete(obj, key) {
158
+ const value = obj[key];
159
+ delete obj[key];
160
+ return value;
161
+ }
162
+ function getObjectTypeForOperation(operation, fullMetadata) {
163
+ const objectTypeApiName = operation.objectTypeApiName;
164
+ const objectType = fullMetadata.objectTypes[objectTypeApiName];
165
+ !objectType ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
166
+ return objectType;
167
+ }
168
+ function paramsToDataValues(params, actionType) {
169
+ const objectData = {};
170
+ for (const [key, value] of Object.entries(params)) {
171
+ objectData[key] = toDataValue(value, actionType.parameters[key]);
172
+ }
173
+ return objectData;
174
+ }
170
175
  function camelcase(apiName) {
171
176
  return apiName.toLowerCase().replace(/[-_]+(.)?/g, (_, chr) => chr ? chr.toUpperCase() : "");
172
177
  }
173
178
  function toDataValue(value, param) {
174
- if (param.dataType.type === "geoshape" && typeof value === "string") {
179
+ if (param.dataType.type === "geohash" && typeof value === "string") {
175
180
  return latLonStringToGeoJSON(value);
176
181
  }
177
182
  return value;
@@ -191,4 +196,32 @@ function latLonStringToGeoJSON(latLonStr) {
191
196
  coordinates: [lon, lat] // GeoJSON uses [longitude, latitude]
192
197
  };
193
198
  }
199
+
200
+ /**
201
+ * Handles linking objects based on parameter values and existing objects
202
+ */
203
+ function handleObjectLinks(batch, fullMetadata, objectTypeApiName, primaryKey, params) {
204
+ // HACK HACK HACK
205
+ fullMetadata.objectTypes[objectTypeApiName].linkTypes.forEach(link => {
206
+ const cardinality = link.cardinality;
207
+ if (cardinality === "ONE") {
208
+ // This means its a one to many and we are on the one side of the link
209
+ for (const foreignObject of batch.getObjects(link.objectTypeApiName)) {
210
+ if (anyValueMatches(params, foreignObject.__primaryKey)) {
211
+ batch.addLink(objectTypeApiName, primaryKey, link.apiName, link.objectTypeApiName, foreignObject.__primaryKey);
212
+ }
213
+ }
214
+ } else {
215
+ // This means its a one to many and we are on the many side of the link
216
+ for (const foreignObject of batch.getObjects(link.objectTypeApiName)) {
217
+ if (anyValueMatches(foreignObject, primaryKey)) {
218
+ batch.addLink(objectTypeApiName, primaryKey, link.apiName, link.objectTypeApiName, foreignObject.__primaryKey);
219
+ }
220
+ }
221
+ }
222
+ });
223
+ }
224
+ function anyValueMatches(obj, primaryKey) {
225
+ return Object.values(obj).some(val => val === primaryKey);
226
+ }
194
227
  //# sourceMappingURL=registerOntologyFullMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerOntologyFullMetadata.js","names":["registerOntologyFullMetadata","ontology","ontologyFullMetadata","Object","values","objectTypes","forEach","objectType","registerObjectType","actionTypes","actionType","implementation","createActionImplementation","actionTypeWithCamelCaseApiName","apiName","camelcase","registerActionType","sharedPropertyTypes","registerSharedPropertyType","queryTypes","query","registerQueryType","interfaceTypes","iface","registerInterfaceType","batch","payload","params","parameters","operation","operations","type","objectTypeApiName","primaryKey","primaryKey_","objectData","key","value","entries","param","toDataValue","addObject","objectToModify","primaryKeyValue","modifyObject","objectToDelete","deleteObject","aSideObjectTypeApiName","bSideObjectTypeApiName","linkTypeApiNameAtoB","aSidePrimaryKey","bSidePrimaryKey","linkedObjectPrimaryKey","addLink","removeLink","Error","toLowerCase","replace","_","chr","toUpperCase","dataType","latLonStringToGeoJSON","latLonStr","lat","lon","split","map","Number","isNaN","coordinates"],"sources":["registerOntologyFullMetadata.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 { FauxFoundry } from \"@osdk/faux\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport type { FauxActionImpl } from \"./FauxFoundryTypes.js\";\n\nexport function registerOntologyFullMetadata(\n ontology: ReturnType<FauxFoundry[\"getOntology\"]>,\n ontologyFullMetadata: Ontologies.OntologyFullMetadata,\n): void {\n // Register object types\n Object.values(ontologyFullMetadata.objectTypes).forEach((objectType) => {\n ontology.registerObjectType(objectType);\n });\n // Register action types with implementations\n Object.values(ontologyFullMetadata.actionTypes).forEach((actionType) => {\n const implementation = createActionImplementation(actionType);\n const actionTypeWithCamelCaseApiName = {\n ...actionType,\n apiName: camelcase(actionType.apiName),\n };\n ontology.registerActionType(actionTypeWithCamelCaseApiName, implementation);\n });\n Object.values(ontologyFullMetadata.sharedPropertyTypes).forEach(\n (actionType) => {\n ontology.registerSharedPropertyType(actionType);\n },\n );\n Object.values(ontologyFullMetadata.queryTypes).forEach((query) => {\n ontology.registerQueryType(query);\n });\n Object.values(ontologyFullMetadata.interfaceTypes).forEach((iface) => {\n ontology.registerInterfaceType(iface);\n });\n}\n\n/**\n * Creates a fake implementation for an action type based on its operations\n */\nfunction createActionImplementation(\n actionType: Ontologies.ActionTypeV2,\n): FauxActionImpl {\n return (\n batch: {\n addObject: (\n objectType: string,\n primaryKey: string | number | boolean,\n object: Record<string, unknown>,\n ) => void;\n modifyObject: (\n objectType: string,\n primaryKey: string | number | boolean,\n update: Record<string, unknown>,\n ) => void;\n deleteObject: (\n objectType: string,\n primaryKey: string | number | boolean,\n ) => void;\n addLink: (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ) => void;\n removeLink: (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ) => void;\n },\n payload: {\n parameters: Record<string, any>;\n },\n _ctx: unknown,\n ) => {\n // Extract parameters from payload\n const params = payload.parameters;\n\n // Handle different operation types\n for (const operation of actionType.operations) {\n switch (operation.type) {\n case \"createObject\": {\n // Handle create object operation\n const objectTypeApiName = operation.objectTypeApiName;\n const primaryKey = params.primaryKey_;\n\n // Create object data from parameters, excluding the primary key\n const objectData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n if (key !== \"primaryKey_\") {\n const param = actionType.parameters[key];\n objectData[key] = toDataValue(value, param);\n }\n }\n\n batch.addObject(objectTypeApiName, primaryKey, objectData);\n break;\n }\n case \"modifyObject\": {\n // Handle modify object operation\n let objectTypeApiName: string;\n let primaryKey: string | number | boolean;\n\n if (typeof operation.objectTypeApiName === \"string\") {\n objectTypeApiName = operation.objectTypeApiName;\n primaryKey = params.primaryKey_;\n } else {\n // If objectTypeApiName is a parameter reference\n const objectToModify = params[operation.objectTypeApiName];\n if (objectToModify) {\n objectTypeApiName = objectToModify.objectTypeApiName\n || objectToModify;\n primaryKey = objectToModify.primaryKeyValue || params.primaryKey_;\n } else {\n // Default to the parameter name if not found\n objectTypeApiName = operation.objectTypeApiName;\n primaryKey = params.primaryKey_;\n }\n }\n\n // Create object data from parameters, excluding the primary key and objectToModifyParameter\n const objectData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n if (key !== \"primaryKey_\" && key !== \"objectToModifyParameter\") {\n const param = actionType.parameters[key];\n objectData[key] = toDataValue(value, param);\n }\n }\n\n batch.modifyObject(objectTypeApiName, primaryKey, objectData);\n break;\n }\n case \"deleteObject\": {\n // Handle delete object operation\n let objectTypeApiName: string;\n let primaryKey: string | number | boolean;\n\n if (typeof operation.objectTypeApiName === \"string\") {\n objectTypeApiName = operation.objectTypeApiName;\n primaryKey = params.primaryKey_;\n } else {\n // If objectTypeApiName is a parameter reference\n const objectToDelete = params[operation.objectTypeApiName];\n if (objectToDelete) {\n objectTypeApiName = objectToDelete.objectTypeApiName\n || objectToDelete;\n primaryKey = objectToDelete.primaryKeyValue || params.primaryKey_;\n } else {\n // Default to the parameter name if not found\n objectTypeApiName = operation.objectTypeApiName;\n primaryKey = params.primaryKey_;\n }\n }\n\n batch.deleteObject(objectTypeApiName, primaryKey);\n break;\n }\n case \"createLink\": {\n // Handle create link operation\n const aSideObjectTypeApiName = operation.aSideObjectTypeApiName;\n const bSideObjectTypeApiName = operation.bSideObjectTypeApiName;\n const linkTypeApiNameAtoB = operation.linkTypeApiNameAtoB;\n\n // For simplicity, assume we have the primary keys in the parameters\n // In a real implementation, we would need to extract them from the parameters\n const aSidePrimaryKey = params.aSidePrimaryKey || params.primaryKey_;\n const bSidePrimaryKey = params.bSidePrimaryKey\n || params.linkedObjectPrimaryKey;\n\n if (aSidePrimaryKey && bSidePrimaryKey) {\n batch.addLink(\n aSideObjectTypeApiName,\n aSidePrimaryKey,\n linkTypeApiNameAtoB,\n bSideObjectTypeApiName,\n bSidePrimaryKey,\n );\n }\n break;\n }\n case \"deleteLink\": {\n // Handle delete link operation\n const aSideObjectTypeApiName = operation.aSideObjectTypeApiName;\n const bSideObjectTypeApiName = operation.bSideObjectTypeApiName;\n const linkTypeApiNameAtoB = operation.linkTypeApiNameAtoB;\n\n // For simplicity, assume we have the primary keys in the parameters\n // In a real implementation, we would need to extract them from the parameters\n const aSidePrimaryKey = params.aSidePrimaryKey || params.primaryKey_;\n const bSidePrimaryKey = params.bSidePrimaryKey\n || params.linkedObjectPrimaryKey;\n\n if (aSidePrimaryKey && bSidePrimaryKey) {\n batch.removeLink(\n aSideObjectTypeApiName,\n aSidePrimaryKey,\n linkTypeApiNameAtoB,\n bSideObjectTypeApiName,\n bSidePrimaryKey,\n );\n }\n break;\n }\n // Handle other operation types as needed\n case \"createInterfaceObject\":\n case \"modifyInterfaceObject\":\n case \"deleteInterfaceObject\":\n // These operations are not implemented for now\n throw new Error(\n `Operation type ${operation.type} not implemented yet`,\n );\n break;\n default:\n throw new Error(`Unknown operation type: ${(operation as any).type}`);\n }\n }\n };\n}\n\nfunction camelcase(apiName: string): string {\n return apiName\n .toLowerCase()\n .replace(/[-_]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : \"\"));\n}\n\nfunction toDataValue(value: any, param: Ontologies.ActionParameterV2): unknown {\n if (param.dataType.type === \"geoshape\" && typeof value === \"string\") {\n return latLonStringToGeoJSON(value);\n }\n return value;\n}\n\nfunction latLonStringToGeoJSON(latLonStr: string) {\n // Split the string by comma and parse as floats\n const [lat, lon] = latLonStr.split(\",\").map(Number);\n\n // Basic validation\n if (\n isNaN(lat)\n || isNaN(lon)\n || lat < -90\n || lat > 90\n || lon < -180\n || lon > 180\n ) {\n throw new Error(\"Invalid latitude or longitude\");\n }\n\n // Return GeoJSON Point\n return {\n type: \"Point\",\n coordinates: [lon, lat], // GeoJSON uses [longitude, latitude]\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,SAASA,4BAA4BA,CA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C,CAAC,GAAG,EAAG,CAAC;AACtE;AAEA,SAASpB,WAAWA,CAACH,KAAU,EAAEE,KAAmC,EAAW;EAC7E,IAAIA,KAAK,CAACsB,QAAQ,CAAC9B,IAAI,KAAK,UAAU,IAAI,OAAOM,KAAK,KAAK,QAAQ,EAAE;IACnE,OAAOyB,qBAAqB,CAACzB,KAAK,CAAC;EACrC;EACA,OAAOA,KAAK;AACd;AAEA,SAASyB,qBAAqBA,CAACC,SAAiB,EAAE;EAChD;EACA,MAAM,CAACC,GAAG,EAAEC,GAAG,CAAC,GAAGF,SAAS,CAACG,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;;EAEnD;EACA,IACEC,KAAK,CAACL,GAAG,CAAC,IACPK,KAAK,CAACJ,GAAG,CAAC,IACVD,GAAG,GAAG,CAAC,EAAE,IACTA,GAAG,GAAG,EAAE,IACRC,GAAG,GAAG,CAAC,GAAG,IACVA,GAAG,GAAG,GAAG,EACZ;IACA,MAAM,IAAIV,KAAK,CAAC,+BAA+B,CAAC;EAClD;;EAEA;EACA,OAAO;IACLxB,IAAI,EAAE,OAAO;IACbuC,WAAW,EAAE,CAACL,GAAG,EAAED,GAAG,CAAC,CAAE;EAC3B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"registerOntologyFullMetadata.js","names":["inspect","invariant","defaultOptions","colors","depth","Infinity","registerOntologyFullMetadata","ontology","ontologyFullMetadata","Object","values","objectTypes","forEach","objectType","registerObjectType","actionTypes","actionType","implementation","createActionImplementation","actionTypeWithCamelCaseApiName","apiName","camelcase","registerActionType","sharedPropertyTypes","registerSharedPropertyType","queryTypes","query","registerQueryType","interfaceTypes","iface","registerInterfaceType","fullMetadata","batch","payload","params","parameters","operation","operations","type","getObjectTypeForOperation","primaryKeyProp","primaryKey","extractAndDelete","objectData","paramsToDataValues","addObject","handleObjectLinks","targetObject","getObject","process","env","NODE_ENV","modifyObject","deleteObject","aSideObjectTypeApiName","bSideObjectTypeApiName","linkTypeApiNameAtoB","aSidePrimaryKey","primaryKey_","bSidePrimaryKey","linkedObjectPrimaryKey","addLink","removeLink","Error","obj","key","value","objectTypeApiName","entries","toDataValue","toLowerCase","replace","_","chr","toUpperCase","param","dataType","latLonStringToGeoJSON","latLonStr","lat","lon","split","map","Number","isNaN","coordinates","linkTypes","link","cardinality","foreignObject","getObjects","anyValueMatches","__primaryKey","some","val"],"sources":["registerOntologyFullMetadata.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 BaseServerObject,\n FauxActionImpl,\n FauxDataStoreBatch,\n FauxFoundry,\n} from \"@osdk/faux\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport { inspect } from \"node:util\";\nimport invariant from \"tiny-invariant\";\n\ninspect.defaultOptions = {\n colors: true,\n depth: Infinity,\n};\n\nexport function registerOntologyFullMetadata(\n ontology: ReturnType<FauxFoundry[\"getOntology\"]>,\n ontologyFullMetadata: Ontologies.OntologyFullMetadata,\n): void {\n // Register object types\n Object.values(ontologyFullMetadata.objectTypes).forEach((objectType) => {\n ontology.registerObjectType(objectType);\n });\n // Register action types with implementations\n Object.values(ontologyFullMetadata.actionTypes).forEach((actionType) => {\n const implementation = createActionImplementation(\n actionType,\n ontologyFullMetadata,\n );\n const actionTypeWithCamelCaseApiName = {\n ...actionType,\n apiName: camelcase(actionType.apiName),\n };\n ontology.registerActionType(actionTypeWithCamelCaseApiName, implementation);\n });\n Object.values(ontologyFullMetadata.sharedPropertyTypes).forEach(\n (actionType) => {\n ontology.registerSharedPropertyType(actionType);\n },\n );\n Object.values(ontologyFullMetadata.queryTypes).forEach((query) => {\n ontology.registerQueryType(query);\n });\n Object.values(ontologyFullMetadata.interfaceTypes).forEach((iface) => {\n ontology.registerInterfaceType(iface);\n });\n}\n\n// NOTE: The ontology full metadata is not sufficient for doing this properly.\n\n/**\n * Creates a fake implementation for an action type based on its operations\n */\nfunction createActionImplementation(\n actionType: Ontologies.ActionTypeV2,\n fullMetadata: Ontologies.OntologyFullMetadata,\n): FauxActionImpl {\n return (\n batch,\n payload: {\n parameters: Record<string, any>;\n },\n _ctx: unknown,\n ) => {\n // Extract parameters from payload\n const params = payload.parameters;\n\n // Handle different operation types\n for (const operation of actionType.operations) {\n switch (operation.type) {\n case \"createObject\": {\n // Handle create object operation\n const objectType = getObjectTypeForOperation(\n operation,\n fullMetadata,\n );\n\n // we don't store the PK with the other properties\n const primaryKeyProp = objectType.objectType.primaryKey;\n const primaryKey = extractAndDelete(params, primaryKeyProp);\n\n // Create object data from parameters\n const objectData = paramsToDataValues(params, actionType);\n batch.addObject(\n objectType.objectType.apiName,\n primaryKey,\n objectData,\n );\n\n // TODO: this shouldn't send params but the actual object!\n handleObjectLinks(\n batch,\n fullMetadata,\n objectType.objectType.apiName,\n primaryKey,\n params,\n );\n break;\n }\n\n case \"modifyObject\": {\n // Handle modify object operation\n const { objectType } = getObjectTypeForOperation(\n operation,\n fullMetadata,\n );\n\n const primaryKey = extractAndDelete(\n params,\n \"objectToModifyParameter\",\n );\n\n const targetObject = batch.getObject(\n objectType.apiName,\n primaryKey,\n );\n invariant(\n targetObject,\n `Could not find object ${objectType.apiName} with PK ${primaryKey}`,\n );\n\n if (objectType.primaryKey in params) {\n // TODO Is this true? Or are you allowed to change the PK value?\n invariant(\n params[objectType.primaryKey] === primaryKey,\n `If the primary key is provided, it must match the 'objectToModifyParameter'`,\n );\n // delete the key since we don't store it directly on the object\n delete params[objectType.primaryKey];\n }\n\n const objectData = paramsToDataValues(params, actionType);\n batch.modifyObject(objectType.apiName, primaryKey, objectData);\n\n // TODO: this shouldn't send params but the actual object!\n handleObjectLinks(\n batch,\n fullMetadata,\n objectType.apiName,\n primaryKey,\n params,\n );\n\n break;\n }\n\n case \"deleteObject\": {\n const { objectType } = getObjectTypeForOperation(\n operation,\n fullMetadata,\n );\n const primaryKey = extractAndDelete(\n params,\n \"objectToDeleteParameter\",\n );\n\n // Handle delete object operation\n batch.deleteObject(objectType.apiName, primaryKey);\n break;\n }\n\n case \"createLink\": {\n // Handle create link operation\n const aSideObjectTypeApiName = operation.aSideObjectTypeApiName;\n const bSideObjectTypeApiName = operation.bSideObjectTypeApiName;\n const linkTypeApiNameAtoB = operation.linkTypeApiNameAtoB;\n\n // For simplicity, assume we have the primary keys in the parameters\n // In a real implementation, we would need to extract them from the parameters\n const aSidePrimaryKey = params.aSidePrimaryKey || params.primaryKey_;\n const bSidePrimaryKey = params.bSidePrimaryKey\n || params.linkedObjectPrimaryKey;\n\n if (aSidePrimaryKey && bSidePrimaryKey) {\n batch.addLink(\n aSideObjectTypeApiName,\n aSidePrimaryKey,\n linkTypeApiNameAtoB,\n bSideObjectTypeApiName,\n bSidePrimaryKey,\n );\n }\n break;\n }\n\n case \"deleteLink\": {\n // Handle delete link operation\n const aSideObjectTypeApiName = operation.aSideObjectTypeApiName;\n const bSideObjectTypeApiName = operation.bSideObjectTypeApiName;\n const linkTypeApiNameAtoB = operation.linkTypeApiNameAtoB;\n\n // For simplicity, assume we have the primary keys in the parameters\n // In a real implementation, we would need to extract them from the parameters\n const aSidePrimaryKey = params.aSidePrimaryKey || params.primaryKey_;\n const bSidePrimaryKey = params.bSidePrimaryKey\n || params.linkedObjectPrimaryKey;\n\n if (aSidePrimaryKey && bSidePrimaryKey) {\n batch.removeLink(\n aSideObjectTypeApiName,\n aSidePrimaryKey,\n linkTypeApiNameAtoB,\n bSideObjectTypeApiName,\n bSidePrimaryKey,\n );\n }\n break;\n }\n\n // Handle other operation types as needed\n case \"createInterfaceObject\":\n case \"modifyInterfaceObject\":\n case \"deleteInterfaceObject\":\n // These operations are not implemented for now\n throw new Error(\n `Operation type ${operation.type} not implemented yet`,\n );\n break;\n default:\n throw new Error(`Unknown operation type: ${(operation as any).type}`);\n }\n }\n };\n}\n\nfunction extractAndDelete<K extends string, O extends Record<K, any>>(\n obj: O,\n key: K,\n) {\n const value = obj[key];\n delete obj[key];\n return value;\n}\n\nfunction getObjectTypeForOperation(\n operation:\n | Ontologies.CreateObjectRule\n | Ontologies.ModifyObjectRule\n | Ontologies.DeleteObjectRule,\n fullMetadata: Ontologies.OntologyFullMetadata,\n) {\n const objectTypeApiName = operation.objectTypeApiName;\n const objectType = fullMetadata.objectTypes[objectTypeApiName];\n invariant(objectType);\n return objectType;\n}\n\nfunction paramsToDataValues(\n params: Record<string, any>,\n actionType: Ontologies.ActionTypeV2,\n) {\n const objectData: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(params)) {\n objectData[key] = toDataValue(value, actionType.parameters[key]);\n }\n return objectData;\n}\n\nfunction camelcase(apiName: string): string {\n return apiName\n .toLowerCase()\n .replace(/[-_]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : \"\"));\n}\n\nfunction toDataValue(value: any, param: Ontologies.ActionParameterV2): unknown {\n if (param.dataType.type === \"geohash\" && typeof value === \"string\") {\n return latLonStringToGeoJSON(value);\n }\n return value;\n}\n\nfunction latLonStringToGeoJSON(latLonStr: string) {\n // Split the string by comma and parse as floats\n const [lat, lon] = latLonStr.split(\",\").map(Number);\n\n // Basic validation\n if (\n isNaN(lat)\n || isNaN(lon)\n || lat < -90\n || lat > 90\n || lon < -180\n || lon > 180\n ) {\n throw new Error(\"Invalid latitude or longitude\");\n }\n\n // Return GeoJSON Point\n return {\n type: \"Point\",\n coordinates: [lon, lat], // GeoJSON uses [longitude, latitude]\n };\n}\n\n/**\n * Handles linking objects based on parameter values and existing objects\n */\nfunction handleObjectLinks(\n batch: FauxDataStoreBatch,\n fullMetadata: Ontologies.OntologyFullMetadata,\n objectTypeApiName: string,\n primaryKey: string | number | boolean,\n params: Record<string, unknown>,\n): void {\n // HACK HACK HACK\n fullMetadata.objectTypes[objectTypeApiName].linkTypes.forEach(link => {\n const cardinality = link.cardinality;\n\n if (cardinality === \"ONE\") {\n // This means its a one to many and we are on the one side of the link\n for (const foreignObject of batch.getObjects(link.objectTypeApiName)) {\n if (anyValueMatches(params, foreignObject.__primaryKey)) {\n batch.addLink(\n objectTypeApiName,\n primaryKey,\n link.apiName,\n link.objectTypeApiName,\n foreignObject.__primaryKey,\n );\n }\n }\n } else {\n // This means its a one to many and we are on the many side of the link\n for (const foreignObject of batch.getObjects(link.objectTypeApiName)) {\n if (anyValueMatches(foreignObject, primaryKey)) {\n batch.addLink(\n objectTypeApiName,\n primaryKey,\n link.apiName,\n link.objectTypeApiName,\n foreignObject.__primaryKey,\n );\n }\n }\n }\n });\n}\n\nfunction anyValueMatches(\n obj: BaseServerObject | Record<string, unknown>,\n primaryKey: string | number | boolean,\n) {\n return Object.values(obj).some(val => val === primaryKey);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,OAAO,QAAQ,WAAW;AACnC,OAAOC,SAAS,MAAM,gBAAgB;AAEtCD,OAAO,CAACE,cAAc,GAAG;EACvBC,MAAM,EAAE,IAAI;EACZC,KAAK,EAAEC;AACT,CAAC;AAED,OAAO,SAASC,4BAA4BA,CAC1CC,QAAgD,EAChDC,oBAAqD,EAC/C;EACN;EACAC,MAAM,CAACC,MAAM,CAACF,oBAAoB,CAACG,WAAW,CAAC,CAACC,OAAO,CAAEC,UAAU,IAAK;IACtEN,QAAQ,CAACO,kBAAkB,CAACD,UAAU,CAAC;EACzC,CAAC,CAAC;EACF;EACAJ,MAAM,CAACC,MAAM,CAACF,oBAAoB,CAACO,WAAW,CAAC,CAACH,OAAO,CAAEI,UAAU,IAAK;IACtE,MAAMC,cAAc,GAAGC,0BAA0B,C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aAAa,CAACG,YAAY,CAAC,EAAE;UACvD5D,KAAK,CAAC6B,OAAO,CACXM,iBAAiB,EACjB1B,UAAU,EACV8C,IAAI,CAACnE,OAAO,EACZmE,IAAI,CAACpB,iBAAiB,EACtBsB,aAAa,CAACG,YAChB,CAAC;QACH;MACF;IACF,CAAC,MAAM;MACL;MACA,KAAK,MAAMH,aAAa,IAAIzD,KAAK,CAAC0D,UAAU,CAACH,IAAI,CAACpB,iBAAiB,CAAC,EAAE;QACpE,IAAIwB,eAAe,CAACF,aAAa,EAAEhD,UAAU,CAAC,EAAE;UAC9CT,KAAK,CAAC6B,OAAO,CACXM,iBAAiB,EACjB1B,UAAU,EACV8C,IAAI,CAACnE,OAAO,EACZmE,IAAI,CAACpB,iBAAiB,EACtBsB,aAAa,CAACG,YAChB,CAAC;QACH;MACF;IACF;EACF,CAAC,CAAC;AACJ;AAEA,SAASD,eAAeA,CACtB3B,GAA+C,EAC/CvB,UAAqC,EACrC;EACA,OAAOhC,MAAM,CAACC,MAAM,CAACsD,GAAG,CAAC,CAAC6B,IAAI,CAACC,GAAG,IAAIA,GAAG,KAAKrD,UAAU,CAAC;AAC3D","ignoreList":[]}
@@ -17,17 +17,11 @@
17
17
  import crypto from "node:crypto";
18
18
  import fs from "node:fs";
19
19
  import path from "node:path";
20
- import { NOISY } from "./generateOntologyAssets.js";
21
-
22
20
  /**
23
21
  * Synchronize directories by copying only changed files and removing obsolete ones
24
22
  */
25
23
  export async function syncDirectories(sourceDir, targetDir, logger) {
26
- if (NOISY) {
27
- logger.info(`Synchronizing ${sourceDir} to ${targetDir}`, {
28
- timestamp: true
29
- });
30
- }
24
+ logger.debug(`Synchronizing ${sourceDir} to ${targetDir}`);
31
25
 
32
26
  // Ensure target directory exists
33
27
  await fs.promises.mkdir(targetDir, {
@@ -56,16 +50,12 @@ export async function syncDirectories(sourceDir, targetDir, logger) {
56
50
  });
57
51
  await fs.promises.copyFile(sourceFile, targetFile);
58
52
  addedCount++;
59
- logger.info(`Added: ${relativeFile}`, {
60
- timestamp: true
61
- });
53
+ logger.debug(`Added: ${relativeFile}`);
62
54
  } else if (isDifferent) {
63
55
  // Changed file - update it
64
56
  await fs.promises.copyFile(sourceFile, targetFile);
65
57
  updatedCount++;
66
- logger.info(`Updated: ${targetFile}`, {
67
- timestamp: true
68
- });
58
+ logger.debug(`Updated: ${targetFile}`);
69
59
  } else {
70
60
  // File is unchanged
71
61
  unchangedCount++;
@@ -73,9 +63,7 @@ export async function syncDirectories(sourceDir, targetDir, logger) {
73
63
  } catch (error) {
74
64
  const errorMsg = `Failed to sync ${relativeFile}: ${error instanceof Error ? error.message : String(error)}`;
75
65
  errors.push(errorMsg);
76
- logger.error(errorMsg, {
77
- timestamp: true
78
- });
66
+ logger.error(errorMsg);
79
67
  }
80
68
  }
81
69
 
@@ -86,15 +74,11 @@ export async function syncDirectories(sourceDir, targetDir, logger) {
86
74
  try {
87
75
  await fs.promises.unlink(targetFile);
88
76
  removedCount++;
89
- logger.info(`Removed: ${relativeFile}`, {
90
- timestamp: true
91
- });
77
+ logger.debug(`Removed: ${relativeFile}`);
92
78
  } catch (error) {
93
79
  const errorMsg = `Failed to remove ${relativeFile}: ${error instanceof Error ? error.message : String(error)}`;
94
80
  errors.push(errorMsg);
95
- logger.error(errorMsg, {
96
- timestamp: true
97
- });
81
+ logger.error(errorMsg);
98
82
  }
99
83
  }
100
84
  }
@@ -103,20 +87,13 @@ export async function syncDirectories(sourceDir, targetDir, logger) {
103
87
  try {
104
88
  await removeEmptyDirectories(targetDir);
105
89
  } catch (error) {
106
- logger.warn(`Failed to clean up empty directories: ${error instanceof Error ? error.message : String(error)}`, {
107
- timestamp: true
108
- });
109
- }
110
- if (NOISY) {
111
- // Log summary
112
- logger.info(`Sync complete: ${addedCount} added, ${updatedCount} updated, ${removedCount} removed, ${unchangedCount} unchanged`, {
113
- timestamp: true
114
- });
90
+ logger.warn(`Failed to clean up empty directories: ${error instanceof Error ? error.message : String(error)}`);
115
91
  }
92
+
93
+ // Log summary
94
+ logger.debug(`Sync complete: ${addedCount} added, ${updatedCount} updated, ${removedCount} removed, ${unchangedCount} unchanged`);
116
95
  if (errors.length > 0) {
117
- logger.warn(`Encountered ${errors.length} errors during sync`, {
118
- timestamp: true
119
- });
96
+ logger.warn(`Encountered ${errors.length} errors during sync`);
120
97
  }
121
98
  }
122
99