{"version":3,"sources":["../../src/OacConfig.ts","../../src/syncDirectories.ts","../../src/generateOntologyAssets.ts","../../src/Logger.ts","../../src/OacContext.ts","../../src/applySeed.ts","../../src/registerOntologyFullMetadata.ts","../../src/utils/readJsonFile.ts","../../src/applyOntologyAndSeed.ts","../../src/OacServerContext.ts","../../src/routeConnectToMsw.ts","../../src/OacDevServer.ts","../../src/ontologyAsCode.ts"],"names":["fs","path","crypto","fs2","path2","execa","OntologyIrToFullMetadataConverter","inspect","Level","chalk","path3","FauxFoundry","jiti","createJiti","invariant","fs3","path4","Emittery","Readable","msw","stream","EventEmitter","fs4","util","fs5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,YAAN,MAAgB;AAAA,EACrB,YAAY,MAAA,EAAQ;AAClB,IAAA,MAAA,CAAO,MAAA,CAAO,MAAM,MAAM,CAAA;AAAA,EAC5B;AACF;ACEA,eAAsB,eAAA,CAAgB,SAAA,EAAW,SAAA,EAAW,MAAA,EAAQ;AAClE,EAAA,MAAA,CAAO,KAAA,CAAM,CAAA,cAAA,EAAiB,SAAS,CAAA,IAAA,EAAO,SAAS,CAAA,CAAE,CAAA;AAGzD,EAAA,MAAMA,qBAAA,CAAG,QAAA,CAAS,KAAA,CAAM,SAAA,EAAW;AAAA,IACjC,SAAA,EAAW;AAAA,GACZ,CAAA;AAGD,EAAA,MAAM,CAAC,WAAA,EAAa,WAAW,CAAA,GAAI,MAAM,OAAA,CAAQ,GAAA,CAAI,CAAC,WAAA,CAAY,SAAS,CAAA,EAAG,WAAA,CAAY,SAAS,CAAC,CAAC,CAAA;AACrG,EAAA,IAAI,YAAA,GAAe,CAAA;AACnB,EAAA,IAAI,UAAA,GAAa,CAAA;AACjB,EAAA,IAAI,YAAA,GAAe,CAAA;AACnB,EAAA,IAAI,cAAA,GAAiB,CAAA;AACrB,EAAA,MAAM,SAAS,EAAC;AAGhB,EAAA,KAAA,MAAW,gBAAgB,WAAA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J,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,iBAAA;AAAA,IACN,eAAe,cAAA,EAAgB;AAC7B,MAAA,UAAA,GAAa,cAAA;AAAA,IACf,CAAA;AAAA,IACA,MAAM,gBAAgB,MAAA,EAAQ;AAC5B,MAAA,MAAM,YAAA,GAAe,IAAI,YAAA,CAAa,SAAA,EAAW,MAAM,CAAA;AAGvD,MAAA,MAAM,aAAa,mBAAA,EAAoB;AAAA,IACzC,CAAA;AAAA,IACA,MAAM,UAAA,GAAa;AACjB,MAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,SAAA,EAAW,UAAU,CAAA;AAEhD,MAAA,IAAI,UAAA,CAAW,YAAY,OAAA,EAAS;AAClC,QAAA,GAAA,CAAI,MAAA,CAAO,KAAK,yCAAyC,CAAA;AACzD,QAAA,IAAI;AACF,UAAA,MAASC,aAAA,CAAA,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,OAAA,EAAS;AAAA,YACnC,SAAA,EAAW;AAAA,WACZ,CAAA;AACD,UAAA,MAAM,uBAAuB,GAAG,CAAA;AAChC,UAAA,GAAA,CAAI,MAAA,CAAO,KAAK,kDAAkD,CAAA;AAAA,QACpE,SAAS,KAAA,EAAO;AACd,UAAA,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,CAAA,oCAAA,EAAuC,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA,CAAE,CAAA;AAChH,UAAA,MAAM,KAAA;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF","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\nexport class OacConfig {\n  constructor(config) {\n    Object.assign(this, config);\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 crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n/**\n * Synchronize directories by copying only changed files and removing obsolete ones\n */\nexport async function syncDirectories(sourceDir, targetDir, logger) {\n  logger.debug(`Synchronizing ${sourceDir} to ${targetDir}`);\n\n  // Ensure target directory exists\n  await fs.promises.mkdir(targetDir, {\n    recursive: true\n  });\n\n  // Get all files in both directories\n  const [sourceFiles, targetFiles] = await Promise.all([getAllFiles(sourceDir), getAllFiles(targetDir)]);\n  let updatedCount = 0;\n  let addedCount = 0;\n  let removedCount = 0;\n  let unchangedCount = 0;\n  const errors = [];\n\n  // Process files from source directory\n  for (const relativeFile of sourceFiles) {\n    const sourceFile = path.join(sourceDir, relativeFile);\n    const targetFile = path.join(targetDir, relativeFile);\n    try {\n      const targetExists = targetFiles.includes(relativeFile);\n      const isDifferent = await areFilesDifferent(sourceFile, targetFile);\n      if (!targetExists) {\n        // New file - need to create directory structure\n        await fs.promises.mkdir(path.dirname(targetFile), {\n          recursive: true\n        });\n        await fs.promises.copyFile(sourceFile, targetFile);\n        addedCount++;\n        logger.debug(`Added: ${relativeFile}`);\n      } else if (isDifferent) {\n        // Changed file - update it\n        await fs.promises.copyFile(sourceFile, targetFile);\n        updatedCount++;\n        logger.debug(`Updated: ${targetFile}`);\n      } else {\n        // File is unchanged\n        unchangedCount++;\n      }\n    } catch (error) {\n      const errorMsg = `Failed to sync ${relativeFile}: ${error instanceof Error ? error.message : String(error)}`;\n      errors.push(errorMsg);\n      logger.error(errorMsg);\n    }\n  }\n\n  // Remove files that exist in target but not in source\n  for (const relativeFile of targetFiles) {\n    if (!sourceFiles.includes(relativeFile)) {\n      const targetFile = path.join(targetDir, relativeFile);\n      try {\n        await fs.promises.unlink(targetFile);\n        removedCount++;\n        logger.debug(`Removed: ${relativeFile}`);\n      } catch (error) {\n        const errorMsg = `Failed to remove ${relativeFile}: ${error instanceof Error ? error.message : String(error)}`;\n        errors.push(errorMsg);\n        logger.error(errorMsg);\n      }\n    }\n  }\n\n  // Clean up empty directories in target\n  try {\n    await removeEmptyDirectories(targetDir);\n  } catch (error) {\n    logger.warn(`Failed to clean up empty directories: ${error instanceof Error ? error.message : String(error)}`);\n  }\n\n  // Log summary\n  logger.debug(`Sync complete: ${addedCount} added, ${updatedCount} updated, ${removedCount} removed, ${unchangedCount} unchanged`);\n  if (errors.length > 0) {\n    logger.warn(`Encountered ${errors.length} errors during sync`);\n  }\n}\n\n/**\n * Remove empty directories recursively\n */\nasync function removeEmptyDirectories(dir) {\n  try {\n    const entries = await fs.promises.readdir(dir, {\n      withFileTypes: true\n    });\n\n    // First, recursively clean subdirectories\n    for (const entry of entries) {\n      if (entry.isDirectory()) {\n        const subdir = path.join(dir, entry.name);\n        await removeEmptyDirectories(subdir);\n      }\n    }\n\n    // Then check if this directory is now empty\n    const remainingEntries = await fs.promises.readdir(dir);\n    if (remainingEntries.length === 0) {\n      // Don't remove the root target directory itself\n      const targetDir = \".osdk/src\";\n      if (path.resolve(dir) !== path.resolve(targetDir)) {\n        await fs.promises.rmdir(dir);\n      }\n    }\n  } catch (error) {\n    // Ignore errors when cleaning up directories\n  }\n}\n\n/**\n * Calculate SHA-256 hash of a file's contents\n */\nasync function getFileHash(filePath) {\n  try {\n    const content = await fs.promises.readFile(filePath);\n    return crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n  } catch (error) {\n    // Return empty hash for non-existent files\n    return \"\";\n  }\n}\n\n/**\n * Check if two files are different by comparing their hashes\n */\nasync function areFilesDifferent(sourceFile, targetFile) {\n  try {\n    const [sourceHash, targetHash] = await Promise.all([getFileHash(sourceFile), getFileHash(targetFile)]);\n    return sourceHash !== targetHash || sourceHash === \"\"; // Different if hashes differ or source doesn't exist\n  } catch (error) {\n    // If we can't compare, assume they're different to be safe\n    return true;\n  }\n}\n\n/**\n * Recursively get all files in a directory\n */\nasync function getAllFiles(dir, baseDir = dir) {\n  const files = [];\n  try {\n    const entries = await fs.promises.readdir(dir, {\n      withFileTypes: true\n    });\n    for (const entry of entries) {\n      const fullPath = path.join(dir, entry.name);\n      const relativePath = path.relative(baseDir, fullPath);\n      if (entry.isDirectory()) {\n        const subFiles = await getAllFiles(fullPath, baseDir);\n        files.push(...subFiles);\n      } else if (entry.isFile()) {\n        files.push(relativePath);\n      }\n    }\n  } catch (error) {\n    // Directory doesn't exist or can't be read\n  }\n  return files;\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 * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { inspect } from \"node:util\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { execa } from \"execa\";\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(opts) {\n  const {\n    ontologyDir,\n    logger\n  } = opts;\n  await fs.promises.mkdir(opts.workDir, {\n    recursive: true\n  });\n\n  // Ensure the ontology directory exists\n  if (!fs.existsSync(ontologyDir)) {\n    fs.mkdirSync(ontologyDir, {\n      recursive: true\n    });\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}\nexport function ontologyIrPath(workDir) {\n  return path.join(workDir, \".ontology.ir.json\");\n}\nexport function ontologyFullMetadataPath(workDir) {\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,\n  ontologyDir,\n  workDir\n}) {\n  logger.debug(\"Generating Ontology IR\");\n  const {\n    stdout,\n    stderr,\n    exitCode\n  } = await execa(\"pnpm\", [\"exec\", \"maker\", \"-i\", `${ontologyDir}/ontology.mts`, \"-o\", ontologyIrPath(workDir)]);\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,\n  workDir\n}) {\n  logger.debug(\"Converting IR to Full metadata\");\n  try {\n    const irContent = await fs.promises.readFile(ontologyIrPath(workDir), {\n      encoding: \"utf-8\"\n    });\n    const blockData = JSON.parse(irContent).blockData;\n    const fullMeta = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(blockData);\n    await fs.promises.writeFile(ontologyFullMetadataPath(workDir), JSON.stringify(fullMeta, null, 2));\n    logger.debug(\"Successfully converted IR to full metadata\");\n  } catch (error) {\n    logger.error(`Failed to convert IR to full metadata: ${inspect(error)}`);\n    throw error;\n  }\n}\n\n/**\n * Generate OSDK from full metadata\n */\nasync function fullMetadataToOsdk({\n  logger,\n  workDir\n}) {\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(workDir, \".osdkGenerationTmp\", \"src\");\n  await fs.promises.rm(tempDir, {\n    recursive: true,\n    force: true\n  });\n  await fs.promises.mkdir(tempDir, {\n    recursive: true\n  });\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(path.join(tempDir, \"..\", \"package.json\"), JSON.stringify({}, null, 2), {\n    encoding: \"utf-8\"\n  });\n  try {\n    // Then generate the source code for the osdk\n    const tempSrcDir = path.join(tempDir, \"src\");\n    const {\n      stdout,\n      stderr,\n      exitCode\n    } = await execa(\"pnpm\", [\"exec\", \"osdk\", \"unstable\", \"typescript\", \"generate\", \"--outDir\", tempSrcDir, \"--ontologyPath\", ontologyFullMetadataPath(workDir), \"--beta\", \"true\", \"--packageType\", \"module\", \"--version\", \"dev\"]);\n    logger.debug(`OSDK generation output: ${stdout}`);\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(\"OSDK generation successful, synchronizing with target directory\");\n\n        // Use granular synchronization instead of wholesale replacement\n        await syncDirectories(tempSrcDir, targetDir, logger);\n        logger.debug(`Successfully synchronized ${targetDir} with newly generated code`);\n        await compileOsdk(logger);\n\n        // Clean up temporary directory after successful sync\n        await fs.promises.rm(tempDir, {\n          recursive: true,\n          force: true\n        });\n      } catch (error) {\n        logger.error(`Failed to synchronize ${targetDir} directory: ${inspect(error)}`);\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, {\n        recursive: true,\n        force: true\n      });\n    } catch (cleanupError) {\n      logger.warn(`Failed to clean up temporary directory: ${inspect(cleanupError)}`);\n    }\n    throw error;\n  }\n}\nasync function compileOsdk(logger) {\n  const {\n    stdout,\n    stderr,\n    exitCode\n  } = await execa(\"pnpm\", [\"exec\", \"tsc\"], {\n    cwd: \".osdk\"\n  });\n  logger.debug(`OSDK generation output: ${stdout}`);\n  if (stderr) {\n    logger.error(`OSDK generation stderr: ${stderr}`);\n  }\n  return exitCode;\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 chalk from \"chalk\";\nexport let Level = /*#__PURE__*/function (Level) {\n  Level[Level[\"debug\"] = 0] = \"debug\";\n  Level[Level[\"info\"] = 1] = \"info\";\n  Level[Level[\"warn\"] = 2] = \"warn\";\n  Level[Level[\"error\"] = 3] = \"error\";\n  return Level;\n}({});\nexport class Logger {\n  #level;\n  #viteLogger;\n  constructor({\n    level,\n    viteLogger\n  }) {\n    this.#level = typeof level === \"string\" ? Level[level] : level;\n    this.#viteLogger = viteLogger;\n  }\n  debug(message) {\n    if (this.#level <= Level.debug) {\n      this.#viteLogger.info(`${chalk.cyan(\"[osdk]\")} ${chalk.gray(`DEBUG: ${message}`)}`, {\n        timestamp: true\n      });\n    }\n  }\n  info(message) {\n    if (this.#level <= Level.info) {\n      this.#viteLogger.info(`${chalk.cyan(\"[osdk]\")} ${message}`, {\n        timestamp: true\n      });\n    }\n  }\n  error(message) {\n    if (this.#level <= Level.error) {\n      this.#viteLogger.error(`${chalk.cyan(\"[osdk]\")} ${chalk.red(message)}`, {\n        timestamp: true\n      });\n    }\n  }\n  warn(message) {\n    if (this.#level <= Level.warn) {\n      this.#viteLogger.warn(`${chalk.cyan(\"[osdk]\")} ${chalk.yellow(message)}`, {\n        timestamp: true\n      });\n    }\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 * as path from \"node:path\";\nimport { FauxFoundry } from \"@osdk/faux\";\nimport { Level as LoggerLevel, Logger } from \"./Logger.js\";\nimport { OacConfig } from \"./OacConfig.js\";\nexport class OacContext extends OacConfig {\n  constructor(config, resolvedConfig) {\n    super(config);\n    this.serverUrl = `http${resolvedConfig.server.https ? \"s\" : \"\"}://localhost:${resolvedConfig.server.port}`;\n    this.defaultOntologyRid = `ri.ontology.main.ontology.00000000-0000-0000-0000-000000000000`;\n    this.workDir = path.join(\"node_modules\", \".osdk\", \".oac\");\n    this.logger = new Logger({\n      level: config.loggerLevel ?? LoggerLevel.info,\n      viteLogger: resolvedConfig.logger\n    });\n    this.workDir = path.join(\"node_modules\", \".osdk\", \".oac\");\n  }\n  fauxFoundryFactory = () => {\n    return new FauxFoundry(this.serverUrl, {\n      apiName: \"DefaultOntology\",\n      description: \"Description\",\n      displayName: \"Ontology\",\n      rid: this.defaultOntologyRid\n    });\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 { createJiti } from \"jiti\";\nexport async function applySeed(fauxFoundry, seedPath) {\n  const jiti = createJiti(import.meta.filename, {\n    moduleCache: false,\n    debug: false,\n    importMeta: import.meta\n  });\n  const module = await jiti.import(seedPath);\n  module.default(fauxFoundry);\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 { inspect } from \"node:util\";\nimport invariant from \"tiny-invariant\";\ninspect.defaultOptions = {\n  colors: true,\n  depth: Infinity\n};\nexport function registerOntologyFullMetadata(ontology, ontologyFullMetadata) {\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, ontologyFullMetadata);\n    const actionTypeWithCamelCaseApiName = {\n      ...actionType,\n      apiName: camelcase(actionType.apiName)\n    };\n    ontology.registerActionType(actionTypeWithCamelCaseApiName, implementation);\n  });\n  Object.values(ontologyFullMetadata.sharedPropertyTypes).forEach(actionType => {\n    ontology.registerSharedPropertyType(actionType);\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(actionType, fullMetadata) {\n  return (batch, payload, _ctx) => {\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          {\n            // Handle create object operation\n            const objectType = getObjectTypeForOperation(operation, fullMetadata);\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(objectType.objectType.apiName, primaryKey, objectData);\n\n            // TODO: this shouldn't send params but the actual object!\n            handleObjectLinks(batch, fullMetadata, objectType.objectType.apiName, primaryKey, params);\n            break;\n          }\n        case \"modifyObject\":\n          {\n            // Handle modify object operation\n            const {\n              objectType\n            } = getObjectTypeForOperation(operation, fullMetadata);\n            const primaryKey = extractAndDelete(params, \"objectToModifyParameter\");\n            const targetObject = batch.getObject(objectType.apiName, primaryKey);\n            !targetObject ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Could not find object ${objectType.apiName} with PK ${primaryKey}`) : invariant(false) : void 0;\n            if (objectType.primaryKey in params) {\n              // TODO Is this true? Or are you allowed to change the PK value?\n              !(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;\n              // delete the key since we don't store it directly on the object\n              delete params[objectType.primaryKey];\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(batch, fullMetadata, objectType.apiName, primaryKey, params);\n            break;\n          }\n        case \"deleteObject\":\n          {\n            const {\n              objectType\n            } = getObjectTypeForOperation(operation, fullMetadata);\n            const primaryKey = extractAndDelete(params, \"objectToDeleteParameter\");\n\n            // Handle delete object operation\n            batch.deleteObject(objectType.apiName, primaryKey);\n            break;\n          }\n        case \"createLink\":\n          {\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 || params.linkedObjectPrimaryKey;\n            if (aSidePrimaryKey && bSidePrimaryKey) {\n              batch.addLink(aSideObjectTypeApiName, aSidePrimaryKey, linkTypeApiNameAtoB, bSideObjectTypeApiName, bSidePrimaryKey);\n            }\n            break;\n          }\n        case \"deleteLink\":\n          {\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 || params.linkedObjectPrimaryKey;\n            if (aSidePrimaryKey && bSidePrimaryKey) {\n              batch.removeLink(aSideObjectTypeApiName, aSidePrimaryKey, linkTypeApiNameAtoB, bSideObjectTypeApiName, bSidePrimaryKey);\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(`Operation type ${operation.type} not implemented yet`);\n          break;\n        default:\n          throw new Error(`Unknown operation type: ${operation.type}`);\n      }\n    }\n  };\n}\nfunction extractAndDelete(obj, key) {\n  const value = obj[key];\n  delete obj[key];\n  return value;\n}\nfunction getObjectTypeForOperation(operation, fullMetadata) {\n  const objectTypeApiName = operation.objectTypeApiName;\n  const objectType = fullMetadata.objectTypes[objectTypeApiName];\n  !objectType ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n  return objectType;\n}\nfunction paramsToDataValues(params, actionType) {\n  const objectData = {};\n  for (const [key, value] of Object.entries(params)) {\n    objectData[key] = toDataValue(value, actionType.parameters[key]);\n  }\n  return objectData;\n}\nfunction camelcase(apiName) {\n  return apiName.toLowerCase().replace(/[-_]+(.)?/gu, (_, chr) => chr ? chr.toUpperCase() : \"\");\n}\nfunction toDataValue(value, param) {\n  if (param.dataType.type === \"geohash\" && typeof value === \"string\") {\n    return latLonStringToGeoJSON(value);\n  }\n  return value;\n}\nfunction latLonStringToGeoJSON(latLonStr) {\n  // Split the string by comma and parse as floats\n  const [lat, lon] = latLonStr.split(\",\").map(Number);\n\n  // Basic validation\n  if (isNaN(lat) || isNaN(lon) || lat < -90 || lat > 90 || lon < -180 || lon > 180) {\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(batch, fullMetadata, objectTypeApiName, primaryKey, params) {\n  // HACK HACK HACK\n  fullMetadata.objectTypes[objectTypeApiName].linkTypes.forEach(link => {\n    const cardinality = link.cardinality;\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(objectTypeApiName, primaryKey, link.apiName, link.objectTypeApiName, foreignObject.__primaryKey);\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(objectTypeApiName, primaryKey, link.apiName, link.objectTypeApiName, foreignObject.__primaryKey);\n        }\n      }\n    }\n  });\n}\nfunction anyValueMatches(obj, primaryKey) {\n  return Object.values(obj).some(val => val === primaryKey);\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 * as fs from \"node:fs\";\nexport function readJsonFile(arg0) {\n  const content = fs.readFileSync(arg0, \"utf-8\");\n  return JSON.parse(content);\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 * as path from \"node:path\";\nimport { inspect } from \"node:util\";\nimport { applySeed } from \"./applySeed.js\";\nimport { ontologyFullMetadataPath } from \"./generateOntologyAssets.js\";\nimport { registerOntologyFullMetadata } from \"./registerOntologyFullMetadata.js\";\nimport { readJsonFile } from \"./utils/readJsonFile.js\";\nexport async function applyOntologyAndSeed(fauxFoundry, ctx) {\n  const ontology = fauxFoundry.getDefaultOntology();\n  const ontologyFullMetadata = readJsonFile(ontologyFullMetadataPath(ctx.workDir));\n  registerOntologyFullMetadata(ontology, ontologyFullMetadata);\n  try {\n    if (ctx.hooks?.preSeed) {\n      ctx.logger.debug(\"calling preSeed hook\");\n    }\n    await ctx.hooks?.preSeed?.(ontology);\n  } catch (e) {\n    ctx.logger.error(`Unhandled error from preSeed hook. Ignoring and continuing. ${inspect(e)}`);\n  }\n  ctx.logger.debug(\"applying seed data\");\n  await applySeed(fauxFoundry, path.resolve(ctx.ontologyDir, \"seed.ts\"));\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 Emittery from \"emittery\";\nimport { OacContext } from \"./OacContext.js\";\nexport class OacServerContext extends OacContext {\n  constructor(config, server) {\n    super(config, server.config);\n    this.watcher = server.watcher;\n    this.emitter = new Emittery();\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 { Readable } from \"stream\";\nimport { msw } from \"@osdk/faux\";\nexport async function routeConnectToMsw(baseUrl, handlers, emitter, req, res, next) {\n  const method = req.method ?? \"GET\";\n  const canRequestHaveBody = method !== \"HEAD\" && method !== \"GET\";\n  const mockRequest = new Request(new URL(req.url, baseUrl), {\n    method,\n    headers: new Headers(req.headers),\n    credentials: \"omit\",\n    // @ts-expect-error Internal Undici property.\n    duplex: canRequestHaveBody ? \"half\" : undefined,\n    body: canRequestHaveBody ? Readable.toWeb(req) : undefined\n  });\n  await msw.handleRequest(mockRequest, crypto.randomUUID(), handlers, {\n    onUnhandledRequest: \"bypass\"\n  }, emitter, {\n    resolutionContext: {\n      baseUrl\n    },\n    // eslint-disable-next-line @typescript-eslint/require-await\n    async onMockedResponse(mockedResponse) {\n      const {\n        status,\n        statusText,\n        headers\n      } = mockedResponse;\n      res.statusCode = status;\n      res.statusMessage = statusText;\n      headers.forEach((value, name) => {\n        res.appendHeader(name, value);\n      });\n      if (mockedResponse.body) {\n        // @ts-expect-error Types don't match exactly\n        const stream = Readable.fromWeb(mockedResponse.body);\n        stream.pipe(res);\n      } else {\n        res.end();\n      }\n    },\n    onPassthroughResponse() {\n      next();\n    }\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 EventEmitter from \"node:events\";\nimport * as fs from \"node:fs\";\nimport * as util from \"node:util\";\nimport { applyOntologyAndSeed } from \"./applyOntologyAndSeed.js\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.js\";\nimport { OacServerContext } from \"./OacServerContext.js\";\nimport { routeConnectToMsw } from \"./routeConnectToMsw.js\";\nexport class OacDevServer extends OacServerContext {\n  constructor(config, server) {\n    super(config, server);\n\n    // create one up front so its never null\n    this.foundry = this.fauxFoundryFactory();\n    this.emitter.on(\"generatedOntologyAssets\", async () => {\n      this.foundry = this.fauxFoundryFactory();\n      await applyOntologyAndSeed(this.foundry, this);\n      server.hot.send({\n        type: \"full-reload\"\n      });\n    });\n    server.middlewares.use(this.#connectMiddleware);\n  }\n  #connectMiddleware = async (req, res, next) => {\n    const mswEmitter = new EventEmitter();\n    return void (await routeConnectToMsw(this.serverUrl, this.foundry.handlers, mswEmitter, req, res, next));\n  };\n  watchOntologyAsCode = async () => {\n    const {\n      ontologyDir,\n      watcher\n    } = this;\n    this.logger.info(`Starting OAC file watcher for ${ontologyDir}`);\n    if (!fs.existsSync(ontologyDir)) {\n      fs.mkdirSync(ontologyDir, {\n        recursive: true\n      });\n    }\n    watcher.add(ontologyDir);\n\n    // Add event listeners\n    watcher.on(\"add\", this.#handleOacFileChanged).on(\"change\", this.#handleOacFileChanged).on(\"unlink\", this.#handleOacFileChanged);\n\n    // invoke the handler at startup\n    await this.#handleOacFileChanged(undefined);\n    return;\n  };\n  #handleOacFileChanged = async filePath => {\n    if (filePath && !filePath.startsWith(`${this.ontologyDir}/`)) {\n      return;\n    }\n    if (filePath) {\n      this.logger.info(`File ${filePath} changed.`);\n    }\n    try {\n      await fs.promises.mkdir(this.workDir, {\n        recursive: true\n      });\n      await generateOntologyAssets(this);\n      await this.emitter.emit(\"generatedOntologyAssets\");\n    } catch (error) {\n      this.logger.error(`Error generating ontology assets: ${util.inspect(error)}`);\n    }\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 * as fs from \"node:fs\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.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(oacConfig) {\n  let viteConfig;\n  return {\n    name: \"oac-vite-plugin\",\n    configResolved(resolvedConfig) {\n      viteConfig = resolvedConfig;\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    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        try {\n          await fs.promises.mkdir(ctx.workDir, {\n            recursive: true\n          });\n          await generateOntologyAssets(ctx);\n          ctx.logger.info(\"Successfully generated ontology assets for build\");\n        } catch (error) {\n          ctx.logger.error(`Failed to generate ontology assets: ${error instanceof Error ? error.message : String(error)}`);\n          throw error;\n        }\n      }\n    }\n  };\n}"]}