@osdk/vite-plugin-oac 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -0
- package/build/browser/FauxFoundryTypes.js +2 -0
- package/build/browser/FauxFoundryTypes.js.map +1 -0
- package/build/browser/FoundryMiddlewareController.js +88 -0
- package/build/browser/FoundryMiddlewareController.js.map +1 -0
- package/build/browser/applySeed.js +27 -0
- package/build/browser/applySeed.js.map +1 -0
- package/build/browser/generateOntologyAssets.js +205 -0
- package/build/browser/generateOntologyAssets.js.map +1 -0
- package/build/browser/index.js +69 -0
- package/build/browser/index.js.map +1 -0
- package/build/browser/registerOntologyFullMetadata.js +194 -0
- package/build/browser/registerOntologyFullMetadata.js.map +1 -0
- package/build/browser/routeConnectToMsw.js +61 -0
- package/build/browser/routeConnectToMsw.js.map +1 -0
- package/build/browser/syncDirectories.js +204 -0
- package/build/browser/syncDirectories.js.map +1 -0
- package/build/browser/utils/readJsonFile.js +22 -0
- package/build/browser/utils/readJsonFile.js.map +1 -0
- package/build/browser/watchOntologyAsCode.js +69 -0
- package/build/browser/watchOntologyAsCode.js.map +1 -0
- package/build/cjs/index.cjs +629 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +14 -0
- package/build/esm/FauxFoundryTypes.js +2 -0
- package/build/esm/FauxFoundryTypes.js.map +1 -0
- package/build/esm/FoundryMiddlewareController.js +88 -0
- package/build/esm/FoundryMiddlewareController.js.map +1 -0
- package/build/esm/applySeed.js +27 -0
- package/build/esm/applySeed.js.map +1 -0
- package/build/esm/generateOntologyAssets.js +205 -0
- package/build/esm/generateOntologyAssets.js.map +1 -0
- package/build/esm/index.js +69 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/registerOntologyFullMetadata.js +194 -0
- package/build/esm/registerOntologyFullMetadata.js.map +1 -0
- package/build/esm/routeConnectToMsw.js +61 -0
- package/build/esm/routeConnectToMsw.js.map +1 -0
- package/build/esm/syncDirectories.js +204 -0
- package/build/esm/syncDirectories.js.map +1 -0
- package/build/esm/utils/readJsonFile.js +22 -0
- package/build/esm/utils/readJsonFile.js.map +1 -0
- package/build/esm/watchOntologyAsCode.js +69 -0
- package/build/esm/watchOntologyAsCode.js.map +1 -0
- package/build/types/FauxFoundryTypes.d.ts +2 -0
- package/build/types/FauxFoundryTypes.d.ts.map +1 -0
- package/build/types/FoundryMiddlewareController.d.ts +14 -0
- package/build/types/FoundryMiddlewareController.d.ts.map +1 -0
- package/build/types/applySeed.d.ts +2 -0
- package/build/types/applySeed.d.ts.map +1 -0
- package/build/types/generateOntologyAssets.d.ts +12 -0
- package/build/types/generateOntologyAssets.d.ts.map +1 -0
- package/build/types/index.d.ts +11 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/registerOntologyFullMetadata.d.ts +3 -0
- package/build/types/registerOntologyFullMetadata.d.ts.map +1 -0
- package/build/types/routeConnectToMsw.d.ts +6 -0
- package/build/types/routeConnectToMsw.d.ts.map +1 -0
- package/build/types/syncDirectories.d.ts +5 -0
- package/build/types/syncDirectories.d.ts.map +1 -0
- package/build/types/utils/readJsonFile.d.ts +1 -0
- package/build/types/utils/readJsonFile.d.ts.map +1 -0
- package/build/types/watchOntologyAsCode.d.ts +10 -0
- package/build/types/watchOntologyAsCode.d.ts.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/applySeed.ts","../../src/registerOntologyFullMetadata.ts","../../src/routeConnectToMsw.ts","../../src/utils/readJsonFile.ts","../../src/FoundryMiddlewareController.ts","../../src/syncDirectories.ts","../../src/generateOntologyAssets.ts","../../src/watchOntologyAsCode.ts","../../src/index.ts"],"names":["jiti","createJiti","Readable","msw","stream","fs","EventEmitter","FauxFoundry","path","crypto","execa","OntologyIrToFullMetadataConverter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,eAAsB,SAAA,CAAU,aAA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,UAAO,MAAA,CAAA,MAAA,CAAO,KAAM,CAAA,CAAA,oCAAA,EAAuC,KAAiB,YAAA,KAAA,GAAQ,MAAM,OAAU,GAAA,MAAA,CAAO,KAAK,CAAC,CAAI,CAAA,EAAA;AAAA,YACnH,SAAW,EAAA;AAAA,WACZ,CAAA;AACD,UAAM,MAAA,KAAA;AAAA;AACR;AACF;AACF,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\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\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);\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/**\n * Creates a fake implementation for an action type based on its operations\n */\nfunction createActionImplementation(actionType) {\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 objectTypeApiName = operation.objectTypeApiName;\n const primaryKey = params.primaryKey_;\n\n // Create object data from parameters, excluding the primary key\n const objectData = {};\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 batch.addObject(objectTypeApiName, primaryKey, objectData);\n break;\n }\n case \"modifyObject\":\n {\n // Handle modify object operation\n let objectTypeApiName;\n let primaryKey;\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 || 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 = {};\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 batch.modifyObject(objectTypeApiName, primaryKey, objectData);\n break;\n }\n case \"deleteObject\":\n {\n // Handle delete object operation\n let objectTypeApiName;\n let primaryKey;\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 || 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 batch.deleteObject(objectTypeApiName, 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 // 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 camelcase(apiName) {\n return apiName.toLowerCase().replace(/[-_]+(.)?/g, (_, chr) => chr ? chr.toUpperCase() : \"\");\n}\nfunction toDataValue(value, param) {\n if (param.dataType.type === \"geoshape\" && 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 * 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 { msw } from \"@osdk/faux\";\nimport { Readable } from \"stream\";\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 * 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 { FauxFoundry } from \"@osdk/faux\";\nimport EventEmitter from \"node:events\";\nimport path from \"node:path\";\nimport { applySeed } from \"./applySeed.js\";\nimport { registerOntologyFullMetadata } from \"./registerOntologyFullMetadata.js\";\nimport { routeConnectToMsw } from \"./routeConnectToMsw.js\";\nimport { readJsonFile } from \"./utils/readJsonFile.js\";\nexport class FoundryMiddlewareController {\n #fauxFoundry;\n #serverUrl;\n #defaultOntologyRid;\n mswEmitter = new EventEmitter();\n #hooks;\n constructor(serverUrl, defaultOntologyRid, oacEmitter, hooks) {\n this.#serverUrl = serverUrl;\n this.#defaultOntologyRid = defaultOntologyRid;\n this.#hooks = hooks;\n\n // create empty initial foundry\n this.#fauxFoundry = this.#createNewFauxFoundry();\n oacEmitter.on(\"generated\", () => {\n this.#reloadOntologyDefinition().catch(e => {\n // eslint-disable-next-line no-console\n console.error(\"[oac] error reloading ontology definition\", e);\n });\n });\n }\n #debugLog(message, ...optionalParams) {\n // eslint-disable-next-line no-console\n console.log(\"[oac]\", message, ...optionalParams);\n }\n #infoLog(message, ...optionalParams) {\n // eslint-disable-next-line no-console\n console.log(\"[oac]\", message, ...optionalParams);\n }\n #errorLog(message, ...optionalParams) {\n // eslint-disable-next-line no-console\n console.error(\"[oac]\", message, ...optionalParams);\n }\n #createNewFauxFoundry() {\n return new FauxFoundry(this.#serverUrl, {\n apiName: \"DefaultOntology\",\n description: \"Description\",\n displayName: \"Ontology\",\n rid: this.#defaultOntologyRid\n });\n }\n async #reloadOntologyDefinition() {\n // Start with a fresh faux foundry + data\n const fauxFoundry = this.#fauxFoundry = this.#createNewFauxFoundry();\n const ontology = fauxFoundry.getDefaultOntology();\n const ontologyFullMetadata = readJsonFile(\".ontology.json\");\n registerOntologyFullMetadata(ontology, ontologyFullMetadata);\n try {\n if (this.#hooks?.preSeed) {\n this.#debugLog(\"[oac] calling preSeed hook\");\n }\n await this.#hooks?.preSeed?.(ontology);\n } catch (e) {\n this.#errorLog(\"[oac] Unhandled error from preSeed hook. Ignoring and continuing.\", e);\n }\n this.#debugLog(\"[osdk] applying seed data\");\n await applySeed(this.#fauxFoundry, path.resolve(import.meta.dirname, \"..\", \"..\", \".ontology\", \"seed.ts\"));\n this.#infoLog(\"[osdk] Finished reloading ontology & seed data\");\n // TODO Maybe emit something that tells the front end associated with this\n // vite plugin to full reload?\n }\n middleware = async (req, res, next) => {\n return void (await routeConnectToMsw(this.#serverUrl, this.#fauxFoundry.handlers, this.mswEmitter, req, res, next));\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\";\nimport { NOISY } from \"./generateOntologyAssets.js\";\n\n/**\n * Synchronize directories by copying only changed files and removing obsolete ones\n */\nexport async function syncDirectories(sourceDir, targetDir, logger) {\n if (NOISY) {\n logger.info(`Synchronizing ${sourceDir} to ${targetDir}`, {\n timestamp: true\n });\n }\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.info(`Added: ${relativeFile}`, {\n timestamp: true\n });\n } else if (isDifferent) {\n // Changed file - update it\n await fs.promises.copyFile(sourceFile, targetFile);\n updatedCount++;\n logger.info(`Updated: ${targetFile}`, {\n timestamp: true\n });\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 timestamp: true\n });\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.info(`Removed: ${relativeFile}`, {\n timestamp: true\n });\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 timestamp: true\n });\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 timestamp: true\n });\n }\n if (NOISY) {\n // Log summary\n logger.info(`Sync complete: ${addedCount} added, ${updatedCount} updated, ${removedCount} removed, ${unchangedCount} unchanged`, {\n timestamp: true\n });\n }\n if (errors.length > 0) {\n logger.warn(`Encountered ${errors.length} errors during sync`, {\n timestamp: true\n });\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 { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { execa } from \"execa\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { syncDirectories } from \"./syncDirectories.js\";\nexport const NOISY = false;\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}) {\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 timestamp: true\n });\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) {\n if (NOISY) {\n logger.info(\"Generating Ontology IR\", {\n timestamp: true\n });\n }\n const {\n stdout,\n stderr,\n exitCode\n } = await execa(\"pnpm\", [\"exec\", \"maker\", \"-i\", \".ontology/ontology.mjs\", \"-o\", \".ontology.ir.json\"]);\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}`, {\n timestamp: true\n });\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) {\n if (NOISY) {\n logger.info(\"Converting IR to Full metadata\", {\n 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).blockData;\n const fullMeta = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(blockData);\n await fs.promises.writeFile(\"./.ontology.json\", JSON.stringify(fullMeta, null, 2));\n if (NOISY) {\n logger.info(\"Successfully converted IR to full metadata\", {\n timestamp: true\n });\n }\n } catch (error) {\n logger.error(`Failed to convert IR to full metadata: ${error instanceof Error ? error.message : String(error)}`, {\n timestamp: true\n });\n throw error;\n }\n}\n\n/**\n * Generate OSDK from full metadata\n */\nasync function fullMetadataToOsdk(logger) {\n if (NOISY) {\n logger.info(\"Generating OSDK from full metadata\", {\n timestamp: true\n });\n }\n\n // First create a clean temporary directory to generate the SDK into\n const tempDir = path.join(process.cwd(), \"node_modules\", \".tmp\", \"osdkGeneration\");\n await fs.promises.rm(tempDir, {\n recursive: true,\n force: true\n });\n await fs.promises.mkdir(tempDir, {\n recursive: true\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\", \".ontology.json\", \"--beta\", \"true\", \"--packageType\", \"module\", \"--version\", \"dev\"]);\n if (stdout && NOISY) {\n logger.info(`OSDK generation output: ${stdout}`, {\n timestamp: true\n });\n }\n if (stderr) {\n logger.error(`OSDK generation stderr: ${stderr}`, {\n timestamp: true\n });\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(\"OSDK generation successful, synchronizing with target directory\", {\n timestamp: true\n });\n }\n\n // Use granular synchronization instead of wholesale replacement\n await syncDirectories(tempSrcDir, targetDir, logger);\n if (NOISY) {\n logger.info(`Successfully synchronized ${targetDir} with newly generated code`, {\n timestamp: true\n });\n }\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: ${error instanceof Error ? error.message : String(error)}`, {\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}`, {\n timestamp: true\n });\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: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`, {\n timestamp: true\n });\n }\n throw error;\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 fs from \"node:fs\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.js\";\nexport function watchOntologyAsCode({\n watcher,\n logger,\n ontologyDir\n}) {\n const emitter = new EventEmitter();\n logger.info(`Starting OAC file watcher for ${ontologyDir}`, {\n timestamp: true\n });\n if (!fs.existsSync(ontologyDir)) {\n fs.mkdirSync(ontologyDir, {\n recursive: true\n });\n logger.info(\"Created .ontology directory\", {\n timestamp: true\n });\n }\n watcher.add(ontologyDir);\n\n // Add event listeners\n watcher.on(\"add\", handleOacFileChanged).on(\"change\", handleOacFileChanged).on(\"unlink\", handleOacFileChanged);\n\n // invoke the handler at startup\n handleOacFileChanged(undefined);\n return emitter;\n function handleOacFileChanged(filePath) {\n if (filePath && !filePath.startsWith(`${ontologyDir}/`)) {\n return;\n }\n if (filePath) {\n logger.info(`File ${filePath} changed.`, {\n timestamp: true\n });\n }\n (async () => {\n await generateOntologyAssets({\n logger,\n ontologyDir\n });\n emitter.emit(\"generated\");\n })().catch(error => {\n // eslint-disable-next-line no-console\n console.error(error);\n logger.error(`Error executing command: ${error.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 path from \"node:path\";\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 const ontologyDir = path.resolve(\".ontology\");\n let config;\n return {\n name: \"oac-vite-plugin\",\n // eslint-disable-next-line @typescript-eslint/require-await\n async configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n configureServer(server) {\n const oacEmitter = watchOntologyAsCode({\n watcher: server.watcher,\n logger: server.config.logger,\n ontologyDir\n });\n const middlewareUrl = `http${server.config.server.https ? \"s\" : \"\"}://localhost:${server.config.server.port}`;\n const foundryMiddlewareController = new FoundryMiddlewareController(middlewareUrl, `ri.ontology.main.ontology.00000000-0000-0000-0000-000000000000`, oacEmitter, opts?.hooks);\n server.middlewares.use(foundryMiddlewareController.middleware);\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 try {\n await generateOntologyAssets({\n logger: config.logger,\n ontologyDir\n });\n config.logger.info(\"Successfully generated ontology assets for build\", {\n timestamp: true\n });\n } catch (error) {\n config.logger.error(`Failed to generate ontology assets: ${error instanceof Error ? error.message : String(error)}`, {\n timestamp: true\n });\n throw error;\n }\n }\n }\n };\n}"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FauxOntology } from '@osdk/faux';
|
|
2
|
+
import { PluginOption } from 'vite';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Vite plugin for Ontology as Code (OAC) that generates ontology IR, metadata, and OSDK
|
|
6
|
+
* in both development and build modes.
|
|
7
|
+
*/
|
|
8
|
+
declare function ontologyAsCode(opts: {
|
|
9
|
+
hooks?: {
|
|
10
|
+
preSeed?: (fauxOntology: FauxOntology) => Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
}): PluginOption;
|
|
13
|
+
|
|
14
|
+
export { ontologyAsCode };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FauxFoundryTypes.js","names":[],"sources":["FauxFoundryTypes.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\";\n\nexport type FauxActionImpl = Parameters<\n ReturnType<FauxFoundry[\"getOntology\"]>[\"registerActionType\"]\n>[1];\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { FauxFoundry } from "@osdk/faux";
|
|
18
|
+
import EventEmitter from "node:events";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import { applySeed } from "./applySeed.js";
|
|
21
|
+
import { registerOntologyFullMetadata } from "./registerOntologyFullMetadata.js";
|
|
22
|
+
import { routeConnectToMsw } from "./routeConnectToMsw.js";
|
|
23
|
+
import { readJsonFile } from "./utils/readJsonFile.js";
|
|
24
|
+
export class FoundryMiddlewareController {
|
|
25
|
+
#fauxFoundry;
|
|
26
|
+
#serverUrl;
|
|
27
|
+
#defaultOntologyRid;
|
|
28
|
+
mswEmitter = new EventEmitter();
|
|
29
|
+
#hooks;
|
|
30
|
+
constructor(serverUrl, defaultOntologyRid, oacEmitter, hooks) {
|
|
31
|
+
this.#serverUrl = serverUrl;
|
|
32
|
+
this.#defaultOntologyRid = defaultOntologyRid;
|
|
33
|
+
this.#hooks = hooks;
|
|
34
|
+
|
|
35
|
+
// create empty initial foundry
|
|
36
|
+
this.#fauxFoundry = this.#createNewFauxFoundry();
|
|
37
|
+
oacEmitter.on("generated", () => {
|
|
38
|
+
this.#reloadOntologyDefinition().catch(e => {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.error("[oac] error reloading ontology definition", e);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
#debugLog(message, ...optionalParams) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.log("[oac]", message, ...optionalParams);
|
|
47
|
+
}
|
|
48
|
+
#infoLog(message, ...optionalParams) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log("[oac]", message, ...optionalParams);
|
|
51
|
+
}
|
|
52
|
+
#errorLog(message, ...optionalParams) {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.error("[oac]", message, ...optionalParams);
|
|
55
|
+
}
|
|
56
|
+
#createNewFauxFoundry() {
|
|
57
|
+
return new FauxFoundry(this.#serverUrl, {
|
|
58
|
+
apiName: "DefaultOntology",
|
|
59
|
+
description: "Description",
|
|
60
|
+
displayName: "Ontology",
|
|
61
|
+
rid: this.#defaultOntologyRid
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async #reloadOntologyDefinition() {
|
|
65
|
+
// Start with a fresh faux foundry + data
|
|
66
|
+
const fauxFoundry = this.#fauxFoundry = this.#createNewFauxFoundry();
|
|
67
|
+
const ontology = fauxFoundry.getDefaultOntology();
|
|
68
|
+
const ontologyFullMetadata = readJsonFile(".ontology.json");
|
|
69
|
+
registerOntologyFullMetadata(ontology, ontologyFullMetadata);
|
|
70
|
+
try {
|
|
71
|
+
if (this.#hooks?.preSeed) {
|
|
72
|
+
this.#debugLog("[oac] calling preSeed hook");
|
|
73
|
+
}
|
|
74
|
+
await this.#hooks?.preSeed?.(ontology);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
this.#errorLog("[oac] Unhandled error from preSeed hook. Ignoring and continuing.", e);
|
|
77
|
+
}
|
|
78
|
+
this.#debugLog("[osdk] applying seed data");
|
|
79
|
+
await applySeed(this.#fauxFoundry, path.resolve(import.meta.dirname, "..", "..", ".ontology", "seed.ts"));
|
|
80
|
+
this.#infoLog("[osdk] Finished reloading ontology & seed data");
|
|
81
|
+
// TODO Maybe emit something that tells the front end associated with this
|
|
82
|
+
// vite plugin to full reload?
|
|
83
|
+
}
|
|
84
|
+
middleware = async (req, res, next) => {
|
|
85
|
+
return void (await routeConnectToMsw(this.#serverUrl, this.#fauxFoundry.handlers, this.mswEmitter, req, res, next));
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=FoundryMiddlewareController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FoundryMiddlewareController.js","names":["FauxFoundry","EventEmitter","path","applySeed","registerOntologyFullMetadata","routeConnectToMsw","readJsonFile","FoundryMiddlewareController","fauxFoundry","serverUrl","defaultOntologyRid","mswEmitter","hooks","constructor","oacEmitter","createNewFauxFoundry","on","reloadOntologyDefinition","catch","e","console","error","debugLog","#debugLog","message","optionalParams","log","infoLog","#infoLog","errorLog","#errorLog","#createNewFauxFoundry","apiName","description","displayName","rid","#reloadOntologyDefinition","ontology","getDefaultOntology","ontologyFullMetadata","preSeed","resolve","import","meta","dirname","middleware","req","res","next","handlers"],"sources":["FoundryMiddlewareController.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 { msw } from \"@osdk/faux\";\nimport { FauxFoundry } from \"@osdk/faux\";\nimport type * as Ontologies from \"@osdk/foundry.ontologies\";\nimport EventEmitter from \"node:events\";\nimport path from \"node:path\";\nimport type { Connect } from \"vite\";\nimport { applySeed } from \"./applySeed.js\";\nimport { registerOntologyFullMetadata } from \"./registerOntologyFullMetadata.js\";\nimport { routeConnectToMsw } from \"./routeConnectToMsw.js\";\nimport { readJsonFile } from \"./utils/readJsonFile.js\";\nimport type { WatchOntologyAsCodeEvents } from \"./watchOntologyAsCode.js\";\n\nexport interface Hooks {\n preSeed?: (\n fauxOntology: ReturnType<FauxFoundry[\"getOntology\"]>,\n ) => Promise<void>;\n}\n\nexport class FoundryMiddlewareController {\n #fauxFoundry: FauxFoundry;\n #serverUrl: string;\n #defaultOntologyRid: string;\n readonly mswEmitter: EventEmitter<msw.LifeCycleEventsMap> = new EventEmitter<\n msw.LifeCycleEventsMap\n >();\n #hooks: Hooks | undefined;\n\n constructor(\n serverUrl: string,\n defaultOntologyRid: string,\n oacEmitter: EventEmitter<WatchOntologyAsCodeEvents>,\n hooks?: Hooks,\n ) {\n this.#serverUrl = serverUrl;\n this.#defaultOntologyRid = defaultOntologyRid;\n this.#hooks = hooks;\n\n // create empty initial foundry\n this.#fauxFoundry = this.#createNewFauxFoundry();\n\n oacEmitter.on(\"generated\", () => {\n this.#reloadOntologyDefinition().catch(e => {\n // eslint-disable-next-line no-console\n console.error(\"[oac] error reloading ontology definition\", e);\n });\n });\n }\n\n #debugLog(message?: any, ...optionalParams: any[]) {\n // eslint-disable-next-line no-console\n console.log(\"[oac]\", message, ...optionalParams);\n }\n\n #infoLog(message?: any, ...optionalParams: any[]) {\n // eslint-disable-next-line no-console\n console.log(\"[oac]\", message, ...optionalParams);\n }\n\n #errorLog(message?: any, ...optionalParams: any[]) {\n // eslint-disable-next-line no-console\n console.error(\"[oac]\", message, ...optionalParams);\n }\n\n #createNewFauxFoundry() {\n return new FauxFoundry(this.#serverUrl, {\n apiName: \"DefaultOntology\",\n description: \"Description\",\n displayName: \"Ontology\",\n rid: this.#defaultOntologyRid,\n });\n }\n\n async #reloadOntologyDefinition() {\n // Start with a fresh faux foundry + data\n const fauxFoundry = (this.#fauxFoundry = this.#createNewFauxFoundry());\n\n const ontology = fauxFoundry.getDefaultOntology();\n\n const ontologyFullMetadata = readJsonFile<Ontologies.OntologyFullMetadata>(\n \".ontology.json\",\n );\n registerOntologyFullMetadata(ontology, ontologyFullMetadata);\n\n try {\n if (this.#hooks?.preSeed) {\n this.#debugLog(\"[oac] calling preSeed hook\");\n }\n\n await this.#hooks?.preSeed?.(ontology);\n } catch (e) {\n this.#errorLog(\n \"[oac] Unhandled error from preSeed hook. Ignoring and continuing.\",\n e,\n );\n }\n\n this.#debugLog(\"[osdk] applying seed data\");\n await applySeed(\n this.#fauxFoundry,\n path.resolve(import.meta.dirname, \"..\", \"..\", \".ontology\", \"seed.ts\"),\n );\n\n this.#infoLog(\"[osdk] Finished reloading ontology & seed data\");\n // TODO Maybe emit something that tells the front end associated with this\n // vite plugin to full reload?\n }\n\n middleware: Connect.NextHandleFunction = async (req, res, next) => {\n return void await routeConnectToMsw(\n this.#serverUrl,\n this.#fauxFoundry.handlers,\n this.mswEmitter,\n req,\n res,\n next,\n );\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,QAAQ,YAAY;AAExC,OAAOC,YAAY,MAAM,aAAa;AACtC,OAAOC,IAAI,MAAM,WAAW;AAE5B,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,4BAA4B,QAAQ,mCAAmC;AAChF,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,yBAAyB;AAStD,OAAO,MAAMC,2BAA2B,CAAC;EACvC,CAACC,WAAW;EACZ,CAACC,SAAS;EACV,CAACC,kBAAkB;EACVC,UAAU,GAAyC,IAAIV,YAAY,CAE1E,CAAC;EACH,CAACW,KAAK;EAENC,WAAWA,CACTJ,SAAiB,EACjBC,kBAA0B,EAC1BI,UAAmD,EACnDF,KAAa,EACb;IACA,IAAI,CAAC,CAACH,SAAS,GAAGA,SAAS;IAC3B,IAAI,CAAC,CAACC,kBAAkB,GAAGA,kBAAkB;IAC7C,IAAI,CAAC,CAACE,KAAK,GAAGA,KAAK;;IAEnB;IACA,IAAI,CAAC,CAACJ,WAAW,GAAG,IAAI,CAAC,CAACO,oBAAoB,CAAC,CAAC;IAEhDD,UAAU,CAACE,EAAE,CAAC,WAAW,EAAE,MAAM;MAC/B,IAAI,CAAC,CAACC,wBAAwB,CAA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AAQ,CAAC,4BAA4B,CAAC;MAC9C;MAEA,MAAM,IAAI,CAAC,CAACV,KAAK,EAAE4B,OAAO,GAAGH,QAAQ,CAAC;IACxC,CAAC,CAAC,OAAOlB,CAAC,EAAE;MACV,IAAI,CAAC,CAACU,QAAQ,CACZ,mEAAmE,EACnEV,CACF,CAAC;IACH;IAEA,IAAI,CAAC,CAACG,QAAQ,CAAC,2BAA2B,CAAC;IAC3C,MAAMnB,SAAS,CACb,IAAI,CAAC,CAACK,WAAW,EACjBN,IAAI,CAACuC,OAAO,CAACC,MAAM,CAACC,IAAI,CAACC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,CACtE,CAAC;IAED,IAAI,CAAC,CAACjB,OAAO,CAAC,gDAAgD,CAAC;IAC/D;IACA;EACF;EAEAkB,UAAU,GAA+B,MAAAA,CAAOC,GAAG,EAAEC,GAAG,EAAEC,IAAI,KAAK;IACjE,OAAO,MAAK,MAAM3C,iBAAiB,CACjC,IAAI,CAAC,CAACI,SAAS,EACf,IAAI,CAAC,CAACD,WAAW,CAACyC,QAAQ,EAC1B,IAAI,CAACtC,UAAU,EACfmC,GAAG,EACHC,GAAG,EACHC,IACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { createJiti } from "jiti";
|
|
18
|
+
export async function applySeed(fauxFoundry, seedPath) {
|
|
19
|
+
const jiti = createJiti(import.meta.filename, {
|
|
20
|
+
moduleCache: false,
|
|
21
|
+
debug: false,
|
|
22
|
+
importMeta: import.meta
|
|
23
|
+
});
|
|
24
|
+
const module = await jiti.import(seedPath);
|
|
25
|
+
module.default(fauxFoundry);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=applySeed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applySeed.js","names":["createJiti","applySeed","fauxFoundry","seedPath","jiti","import","meta","filename","moduleCache","debug","importMeta","module","default"],"sources":["applySeed.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 { createJiti } from \"jiti\";\n\nexport async function applySeed(\n fauxFoundry: FauxFoundry,\n seedPath: string,\n): Promise<void> {\n const jiti = createJiti(import.meta.filename, {\n moduleCache: false,\n debug: false,\n importMeta: import.meta,\n });\n\n const module: { default: (fauxFoundry: FauxFoundry) => void } = await jiti\n .import(seedPath);\n module.default(fauxFoundry);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAO,eAAeC,SAASA,CAC7BC,WAAwB,EACxBC,QAAgB,EACD;EACf,MAAMC,IAAI,GAAGJ,UAAU,CAACK,MAAM,CAACC,IAAI,CAACC,QAAQ,EAAE;IAC5CC,WAAW,EAAE,KAAK;IAClBC,KAAK,EAAE,KAAK;IACZC,UAAU,EAAEL,MAAM,CAACC;EACrB,CAAC,CAAC;EAEF,MAAMK,MAAuD,GAAG,MAAMP,IAAI,CACvEC,MAAM,CAACF,QAAQ,CAAC;EACnBQ,MAAM,CAACC,OAAO,CAACV,WAAW,CAAC;AAC7B","ignoreList":[]}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
|
|
18
|
+
import { execa } from "execa";
|
|
19
|
+
import fs from "node:fs";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { syncDirectories } from "./syncDirectories.js";
|
|
22
|
+
export const NOISY = false;
|
|
23
|
+
/**
|
|
24
|
+
* Generate all ontology assets: IR, full metadata, and OSDK.
|
|
25
|
+
* This function contains the core generation logic extracted from watchOntologyAsCode
|
|
26
|
+
* so it can be used both in dev mode (via file watching) and build mode.
|
|
27
|
+
*/
|
|
28
|
+
export async function generateOntologyAssets({
|
|
29
|
+
logger,
|
|
30
|
+
ontologyDir
|
|
31
|
+
}) {
|
|
32
|
+
// Ensure the ontology directory exists
|
|
33
|
+
if (!fs.existsSync(ontologyDir)) {
|
|
34
|
+
fs.mkdirSync(ontologyDir, {
|
|
35
|
+
recursive: true
|
|
36
|
+
});
|
|
37
|
+
logger.info("Created .ontology directory", {
|
|
38
|
+
timestamp: true
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Generate the assets in sequence
|
|
43
|
+
await ontologyJsToIr(logger);
|
|
44
|
+
await ontologyIrToFullMetadata(logger);
|
|
45
|
+
await fullMetadataToOsdk(logger);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Convert ontology.mjs to IR format using the maker tool
|
|
50
|
+
*/
|
|
51
|
+
async function ontologyJsToIr(logger) {
|
|
52
|
+
if (NOISY) {
|
|
53
|
+
logger.info("Generating Ontology IR", {
|
|
54
|
+
timestamp: true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const {
|
|
58
|
+
stdout,
|
|
59
|
+
stderr,
|
|
60
|
+
exitCode
|
|
61
|
+
} = await execa("pnpm", ["exec", "maker", "-i", ".ontology/ontology.mjs", "-o", ".ontology.ir.json"]);
|
|
62
|
+
if (exitCode !== 0) {
|
|
63
|
+
logger.error(`Ontology IR generation failed with exit code ${exitCode}`, {
|
|
64
|
+
timestamp: true
|
|
65
|
+
});
|
|
66
|
+
if (stderr) {
|
|
67
|
+
logger.error(`Command stderr: ${stderr}`, {
|
|
68
|
+
timestamp: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`Failed to generate ontology IR: exit code ${exitCode}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Log stdout for debugging if needed
|
|
75
|
+
if (stdout && NOISY) {
|
|
76
|
+
logger.info(`Ontology IR generation output: ${stdout}`, {
|
|
77
|
+
timestamp: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Convert IR to full metadata format
|
|
84
|
+
*/
|
|
85
|
+
async function ontologyIrToFullMetadata(logger) {
|
|
86
|
+
if (NOISY) {
|
|
87
|
+
logger.info("Converting IR to Full metadata", {
|
|
88
|
+
timestamp: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const irContent = await fs.promises.readFile("./.ontology.ir.json", {
|
|
93
|
+
encoding: "utf-8"
|
|
94
|
+
});
|
|
95
|
+
const blockData = JSON.parse(irContent).blockData;
|
|
96
|
+
const fullMeta = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(blockData);
|
|
97
|
+
await fs.promises.writeFile("./.ontology.json", JSON.stringify(fullMeta, null, 2));
|
|
98
|
+
if (NOISY) {
|
|
99
|
+
logger.info("Successfully converted IR to full metadata", {
|
|
100
|
+
timestamp: true
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
logger.error(`Failed to convert IR to full metadata: ${error instanceof Error ? error.message : String(error)}`, {
|
|
105
|
+
timestamp: true
|
|
106
|
+
});
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Generate OSDK from full metadata
|
|
113
|
+
*/
|
|
114
|
+
async function fullMetadataToOsdk(logger) {
|
|
115
|
+
if (NOISY) {
|
|
116
|
+
logger.info("Generating OSDK from full metadata", {
|
|
117
|
+
timestamp: true
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// First create a clean temporary directory to generate the SDK into
|
|
122
|
+
const tempDir = path.join(process.cwd(), "node_modules", ".tmp", "osdkGeneration");
|
|
123
|
+
await fs.promises.rm(tempDir, {
|
|
124
|
+
recursive: true,
|
|
125
|
+
force: true
|
|
126
|
+
});
|
|
127
|
+
await fs.promises.mkdir(tempDir, {
|
|
128
|
+
recursive: true
|
|
129
|
+
});
|
|
130
|
+
try {
|
|
131
|
+
// Then generate the source code for the osdk
|
|
132
|
+
const tempSrcDir = path.join(tempDir, "src");
|
|
133
|
+
const {
|
|
134
|
+
stdout,
|
|
135
|
+
stderr,
|
|
136
|
+
exitCode
|
|
137
|
+
} = await execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", tempSrcDir, "--ontologyPath", ".ontology.json", "--beta", "true", "--packageType", "module", "--version", "dev"]);
|
|
138
|
+
if (stdout && NOISY) {
|
|
139
|
+
logger.info(`OSDK generation output: ${stdout}`, {
|
|
140
|
+
timestamp: true
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (stderr) {
|
|
144
|
+
logger.error(`OSDK generation stderr: ${stderr}`, {
|
|
145
|
+
timestamp: true
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Then if it was successful, synchronize the generated code with the target directory
|
|
150
|
+
if (exitCode === 0) {
|
|
151
|
+
const targetDir = ".osdk/src";
|
|
152
|
+
try {
|
|
153
|
+
if (NOISY) {
|
|
154
|
+
logger.info("OSDK generation successful, synchronizing with target directory", {
|
|
155
|
+
timestamp: true
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Use granular synchronization instead of wholesale replacement
|
|
160
|
+
await syncDirectories(tempSrcDir, targetDir, logger);
|
|
161
|
+
if (NOISY) {
|
|
162
|
+
logger.info(`Successfully synchronized ${targetDir} with newly generated code`, {
|
|
163
|
+
timestamp: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Clean up temporary directory after successful sync
|
|
168
|
+
await fs.promises.rm(tempDir, {
|
|
169
|
+
recursive: true,
|
|
170
|
+
force: true
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logger.error(`Failed to synchronize ${targetDir} directory: ${error instanceof Error ? error.message : String(error)}`, {
|
|
174
|
+
timestamp: true
|
|
175
|
+
});
|
|
176
|
+
logger.error(`Temporary files left at: ${tempDir}`, {
|
|
177
|
+
timestamp: true
|
|
178
|
+
});
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
logger.error(`OSDK generation failed with exit code ${exitCode}`, {
|
|
183
|
+
timestamp: true
|
|
184
|
+
});
|
|
185
|
+
logger.error(`Temporary files left at: ${tempDir}`, {
|
|
186
|
+
timestamp: true
|
|
187
|
+
});
|
|
188
|
+
throw new Error(`OSDK generation failed with exit code ${exitCode}`);
|
|
189
|
+
}
|
|
190
|
+
} catch (error) {
|
|
191
|
+
// Make sure to clean up temp directory even if there's an error
|
|
192
|
+
try {
|
|
193
|
+
await fs.promises.rm(tempDir, {
|
|
194
|
+
recursive: true,
|
|
195
|
+
force: true
|
|
196
|
+
});
|
|
197
|
+
} catch (cleanupError) {
|
|
198
|
+
logger.warn(`Failed to clean up temporary directory: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`, {
|
|
199
|
+
timestamp: true
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=generateOntologyAssets.js.map
|
|
@@ -0,0 +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,EAAi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
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 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
|
+
}
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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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