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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/build/browser/Logger.js +64 -0
  3. package/build/browser/Logger.js.map +1 -0
  4. package/build/browser/OacConfig.js +22 -0
  5. package/build/browser/OacConfig.js.map +1 -0
  6. package/build/browser/OacContext.js +42 -0
  7. package/build/browser/OacContext.js.map +1 -0
  8. package/build/browser/OacDevServer.js +80 -0
  9. package/build/browser/OacDevServer.js.map +1 -0
  10. package/build/browser/OacServerContext.js +26 -0
  11. package/build/browser/OacServerContext.js.map +1 -0
  12. package/build/browser/applyOntologyAndSeed.js +38 -0
  13. package/build/browser/applyOntologyAndSeed.js.map +1 -0
  14. package/build/browser/generateOntologyAssets.js +81 -87
  15. package/build/browser/generateOntologyAssets.js.map +1 -1
  16. package/build/browser/index.js +2 -52
  17. package/build/browser/index.js.map +1 -1
  18. package/build/browser/ontologyAsCode.js +58 -0
  19. package/build/browser/ontologyAsCode.js.map +1 -0
  20. package/build/browser/registerOntologyFullMetadata.js +90 -57
  21. package/build/browser/registerOntologyFullMetadata.js.map +1 -1
  22. package/build/browser/syncDirectories.js +11 -34
  23. package/build/browser/syncDirectories.js.map +1 -1
  24. package/build/cjs/index.cjs +487 -414
  25. package/build/cjs/index.cjs.map +1 -1
  26. package/build/cjs/index.d.cts +20 -6
  27. package/build/esm/Logger.js +64 -0
  28. package/build/esm/Logger.js.map +1 -0
  29. package/build/esm/OacConfig.js +22 -0
  30. package/build/esm/OacConfig.js.map +1 -0
  31. package/build/esm/OacContext.js +42 -0
  32. package/build/esm/OacContext.js.map +1 -0
  33. package/build/esm/OacDevServer.js +80 -0
  34. package/build/esm/OacDevServer.js.map +1 -0
  35. package/build/esm/OacServerContext.js +26 -0
  36. package/build/esm/OacServerContext.js.map +1 -0
  37. package/build/esm/applyOntologyAndSeed.js +38 -0
  38. package/build/esm/applyOntologyAndSeed.js.map +1 -0
  39. package/build/esm/generateOntologyAssets.js +81 -87
  40. package/build/esm/generateOntologyAssets.js.map +1 -1
  41. package/build/esm/index.js +2 -52
  42. package/build/esm/index.js.map +1 -1
  43. package/build/esm/ontologyAsCode.js +58 -0
  44. package/build/esm/ontologyAsCode.js.map +1 -0
  45. package/build/esm/registerOntologyFullMetadata.js +90 -57
  46. package/build/esm/registerOntologyFullMetadata.js.map +1 -1
  47. package/build/esm/syncDirectories.js +11 -34
  48. package/build/esm/syncDirectories.js.map +1 -1
  49. package/build/types/Logger.d.ts +18 -0
  50. package/build/types/Logger.d.ts.map +1 -0
  51. package/build/types/OacConfig.d.ts +12 -0
  52. package/build/types/OacConfig.d.ts.map +1 -0
  53. package/build/types/OacContext.d.ts +12 -0
  54. package/build/types/OacContext.d.ts.map +1 -0
  55. package/build/types/OacDevServer.d.ts +10 -0
  56. package/build/types/OacDevServer.d.ts.map +1 -0
  57. package/build/types/OacServerContext.d.ts +12 -0
  58. package/build/types/OacServerContext.d.ts.map +1 -0
  59. package/build/types/applyOntologyAndSeed.d.ts +3 -0
  60. package/build/types/applyOntologyAndSeed.d.ts.map +1 -0
  61. package/build/types/generateOntologyAssets.d.ts +4 -7
  62. package/build/types/generateOntologyAssets.d.ts.map +1 -1
  63. package/build/types/index.d.ts +2 -11
  64. package/build/types/index.d.ts.map +1 -1
  65. package/build/types/ontologyAsCode.d.ts +7 -0
  66. package/build/types/ontologyAsCode.d.ts.map +1 -0
  67. package/build/types/registerOntologyFullMetadata.d.ts.map +1 -1
  68. package/build/types/syncDirectories.d.ts +1 -1
  69. package/build/types/syncDirectories.d.ts.map +1 -1
  70. package/package.json +10 -7
  71. package/build/browser/FauxFoundryTypes.js +0 -2
  72. package/build/browser/FauxFoundryTypes.js.map +0 -1
  73. package/build/browser/FoundryMiddlewareController.js +0 -88
  74. package/build/browser/FoundryMiddlewareController.js.map +0 -1
  75. package/build/browser/watchOntologyAsCode.js +0 -69
  76. package/build/browser/watchOntologyAsCode.js.map +0 -1
  77. package/build/esm/FauxFoundryTypes.js +0 -2
  78. package/build/esm/FauxFoundryTypes.js.map +0 -1
  79. package/build/esm/FoundryMiddlewareController.js +0 -88
  80. package/build/esm/FoundryMiddlewareController.js.map +0 -1
  81. package/build/esm/watchOntologyAsCode.js +0 -69
  82. package/build/esm/watchOntologyAsCode.js.map +0 -1
  83. package/build/types/FauxFoundryTypes.d.ts +0 -2
  84. package/build/types/FauxFoundryTypes.d.ts.map +0 -1
  85. package/build/types/FoundryMiddlewareController.d.ts +0 -14
  86. package/build/types/FoundryMiddlewareController.d.ts.map +0 -1
  87. package/build/types/watchOntologyAsCode.d.ts +0 -10
  88. package/build/types/watchOntologyAsCode.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @osdk/vite-plugin-oac
2
+
3
+ ## 0.1.0-beta.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [52ed4a8]
8
+ - Updated dependencies [77674dd]
9
+ - Updated dependencies [c305ea8]
10
+ - Updated dependencies [7901ae0]
11
+ - Updated dependencies [9839eab]
12
+ - Updated dependencies [e99a614]
13
+ - Updated dependencies [ab2ef22]
14
+ - Updated dependencies [1608ba5]
15
+ - Updated dependencies [9839eab]
16
+ - Updated dependencies [dc7d201]
17
+ - Updated dependencies [ad18c80]
18
+ - @osdk/cli@0.27.0-beta.6
19
+ - @osdk/maker@0.11.0-beta.7
20
+ - @osdk/client.unstable@2.3.0-beta.6
21
+ - @osdk/faux@0.1.0-beta.2
22
+ - @osdk/generator-converters.ontologyir@2.3.0-beta.6
23
+ - @osdk/api@2.3.0-beta.6
@@ -0,0 +1,64 @@
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 chalk from "chalk";
18
+ export let Level = /*#__PURE__*/function (Level) {
19
+ Level[Level["debug"] = 0] = "debug";
20
+ Level[Level["info"] = 1] = "info";
21
+ Level[Level["warn"] = 2] = "warn";
22
+ Level[Level["error"] = 3] = "error";
23
+ return Level;
24
+ }({});
25
+ export class Logger {
26
+ #level;
27
+ #viteLogger;
28
+ constructor({
29
+ level,
30
+ viteLogger
31
+ }) {
32
+ this.#level = typeof level === "string" ? Level[level] : level;
33
+ this.#viteLogger = viteLogger;
34
+ }
35
+ debug(message) {
36
+ if (this.#level <= Level.debug) {
37
+ this.#viteLogger.info(`${chalk.cyan("[osdk]")} ${chalk.gray(`DEBUG: ${message}`)}`, {
38
+ timestamp: true
39
+ });
40
+ }
41
+ }
42
+ info(message) {
43
+ if (this.#level <= Level.info) {
44
+ this.#viteLogger.info(`${chalk.cyan("[osdk]")} ${message}`, {
45
+ timestamp: true
46
+ });
47
+ }
48
+ }
49
+ error(message) {
50
+ if (this.#level <= Level.error) {
51
+ this.#viteLogger.error(`${chalk.cyan("[osdk]")} ${chalk.red(message)}`, {
52
+ timestamp: true
53
+ });
54
+ }
55
+ }
56
+ warn(message) {
57
+ if (this.#level <= Level.warn) {
58
+ this.#viteLogger.warn(`${chalk.cyan("[osdk]")} ${chalk.yellow(message)}`, {
59
+ timestamp: true
60
+ });
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","names":["chalk","Level","Logger","level","viteLogger","constructor","debug","message","info","cyan","gray","timestamp","error","red","warn","yellow"],"sources":["Logger.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 chalk from \"chalk\";\nimport type { Logger as ViteLogger } from \"vite\";\n\nexport enum Level {\n debug = 0,\n info = 1,\n warn = 2,\n error = 3,\n}\n\nexport class Logger {\n #level: Level;\n #viteLogger: ViteLogger;\n\n constructor(\n { level, viteLogger }: {\n level: Level | keyof typeof Level;\n viteLogger: ViteLogger;\n },\n ) {\n this.#level = typeof level === \"string\" ? Level[level] : level;\n this.#viteLogger = viteLogger;\n }\n\n debug(message: string): void {\n if (this.#level <= Level.debug) {\n this.#viteLogger.info(\n `${chalk.cyan(\"[osdk]\")} ${chalk.gray(`DEBUG: ${message}`)}`,\n { timestamp: true },\n );\n }\n }\n\n info(message: string): void {\n if (this.#level <= Level.info) {\n this.#viteLogger.info(`${chalk.cyan(\"[osdk]\")} ${message}`, {\n timestamp: true,\n });\n }\n }\n\n error(message: string): void {\n if (this.#level <= Level.error) {\n this.#viteLogger.error(`${chalk.cyan(\"[osdk]\")} ${chalk.red(message)}`, {\n timestamp: true,\n });\n }\n }\n\n warn(message: string): void {\n if (this.#level <= Level.warn) {\n this.#viteLogger.warn(\n `${chalk.cyan(\"[osdk]\")} ${chalk.yellow(message)}`,\n { timestamp: true },\n );\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AAGzB,WAAYC,KAAK,0BAALA,KAAK;EAALA,KAAK,CAALA,KAAK;EAALA,KAAK,CAALA,KAAK;EAALA,KAAK,CAALA,KAAK;EAALA,KAAK,CAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,OAAO,MAAMC,MAAM,CAAC;EAClB,CAACC,KAAK;EACN,CAACC,UAAU;EAEXC,WAAWA,CACT;IAAEF,KAAK;IAAEC;EAGT,CAAC,EACD;IACA,IAAI,CAAC,CAACD,KAAK,GAAG,OAAOA,KAAK,KAAK,QAAQ,GAAGF,KAAK,CAACE,KAAK,CAAC,GAAGA,KAAK;IAC9D,IAAI,CAAC,CAACC,UAAU,GAAGA,UAAU;EAC/B;EAEAE,KAAKA,CAACC,OAAe,EAAQ;IAC3B,IAAI,IAAI,CAAC,CAACJ,KAAK,IAAIF,KAAK,CAACK,KAAK,EAAE;MAC9B,IAAI,CAAC,CAACF,UAAU,CAACI,IAAI,CACnB,GAAGR,KAAK,CAACS,IAAI,CAAC,QAAQ,CAAC,IAAIT,KAAK,CAACU,IAAI,CAAC,UAAUH,OAAO,EAAE,CAAC,EAAE,EAC5D;QAAEI,SAAS,EAAE;MAAK,CACpB,CAAC;IACH;EACF;EAEAH,IAAIA,CAACD,OAAe,EAAQ;IAC1B,IAAI,IAAI,CAAC,CAACJ,KAAK,IAAIF,KAAK,CAACO,IAAI,EAAE;MAC7B,IAAI,CAAC,CAACJ,UAAU,CAACI,IAAI,CAAC,GAAGR,KAAK,CAACS,IAAI,CAAC,QAAQ,CAAC,IAAIF,OAAO,EAAE,EAAE;QAC1DI,SAAS,EAAE;MACb,CAAC,CAAC;IACJ;EACF;EAEAC,KAAKA,CAACL,OAAe,EAAQ;IAC3B,IAAI,IAAI,CAAC,CAACJ,KAAK,IAAIF,KAAK,CAACW,KAAK,EAAE;MAC9B,IAAI,CAAC,CAACR,UAAU,CAACQ,KAAK,CAAC,GAAGZ,KAAK,CAACS,IAAI,CAAC,QAAQ,CAAC,IAAIT,KAAK,CAACa,GAAG,CAACN,OAAO,CAAC,EAAE,EAAE;QACtEI,SAAS,EAAE;MACb,CAAC,CAAC;IACJ;EACF;EAEAG,IAAIA,CAACP,OAAe,EAAQ;IAC1B,IAAI,IAAI,CAAC,CAACJ,KAAK,IAAIF,KAAK,CAACa,IAAI,EAAE;MAC7B,IAAI,CAAC,CAACV,UAAU,CAACU,IAAI,CACnB,GAAGd,KAAK,CAACS,IAAI,CAAC,QAAQ,CAAC,IAAIT,KAAK,CAACe,MAAM,CAACR,OAAO,CAAC,EAAE,EAClD;QAAEI,SAAS,EAAE;MAAK,CACpB,CAAC;IACH;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export class OacConfig {
18
+ constructor(config) {
19
+ Object.assign(this, config);
20
+ }
21
+ }
22
+ //# sourceMappingURL=OacConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OacConfig.js","names":["OacConfig","constructor","config","Object","assign"],"sources":["OacConfig.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 type { Level } from \"./Logger.js\";\n\nexport interface OacConfig {\n hooks?: {\n preSeed?: (fauxOntology: FauxOntology) => Promise<void>;\n };\n ontologyDir: string;\n loggerLevel?: keyof typeof Level;\n}\n\nexport class OacConfig {\n constructor(config: OacConfig) {\n Object.assign(this, config);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAO,MAAMA,SAAS,CAAC;EACrBC,WAAWA,CAACC,MAAiB,EAAE;IAC7BC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEF,MAAM,CAAC;EAC7B;AACF","ignoreList":[]}
@@ -0,0 +1,42 @@
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 * as path from "node:path";
19
+ import { Level as LoggerLevel, Logger } from "./Logger.js";
20
+ import { OacConfig } from "./OacConfig.js";
21
+ export class OacContext extends OacConfig {
22
+ constructor(config, resolvedConfig) {
23
+ super(config);
24
+ this.serverUrl = `http${resolvedConfig.server.https ? "s" : ""}://localhost:${resolvedConfig.server.port}`;
25
+ this.defaultOntologyRid = `ri.ontology.main.ontology.00000000-0000-0000-0000-000000000000`;
26
+ this.workDir = path.join("node_modules", ".osdk", ".oac");
27
+ this.logger = new Logger({
28
+ level: config.loggerLevel ?? LoggerLevel.info,
29
+ viteLogger: resolvedConfig.logger
30
+ });
31
+ this.workDir = path.join("node_modules", ".osdk", ".oac");
32
+ }
33
+ fauxFoundryFactory = () => {
34
+ return new FauxFoundry(this.serverUrl, {
35
+ apiName: "DefaultOntology",
36
+ description: "Description",
37
+ displayName: "Ontology",
38
+ rid: this.defaultOntologyRid
39
+ });
40
+ };
41
+ }
42
+ //# sourceMappingURL=OacContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OacContext.js","names":["FauxFoundry","path","Level","LoggerLevel","Logger","OacConfig","OacContext","constructor","config","resolvedConfig","serverUrl","server","https","port","defaultOntologyRid","workDir","join","logger","level","loggerLevel","info","viteLogger","fauxFoundryFactory","apiName","description","displayName","rid"],"sources":["OacContext.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 { FauxFoundry } from \"@osdk/faux\";\nimport * as path from \"node:path\";\nimport type { ResolvedConfig } from \"vite\";\nimport { Level as LoggerLevel, Logger } from \"./Logger.js\";\nimport { OacConfig } from \"./OacConfig.js\";\n\nexport class OacContext extends OacConfig {\n workDir: string;\n logger: Logger;\n serverUrl: string;\n defaultOntologyRid: string;\n\n constructor(config: OacConfig, resolvedConfig: ResolvedConfig) {\n super(config);\n\n this.serverUrl = `http${\n resolvedConfig.server.https ? \"s\" : \"\"\n }://localhost:${resolvedConfig.server.port}`;\n this.defaultOntologyRid =\n `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\n fauxFoundryFactory: () => FauxFoundry = () => {\n return new FauxFoundry(this.serverUrl, {\n apiName: \"DefaultOntology\",\n description: \"Description\",\n displayName: \"Ontology\",\n rid: this.defaultOntologyRid,\n });\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,YAAY;AACxC,OAAO,KAAKC,IAAI,MAAM,WAAW;AAEjC,SAASC,KAAK,IAAIC,WAAW,EAAEC,MAAM,QAAQ,aAAa;AAC1D,SAASC,SAAS,QAAQ,gBAAgB;AAE1C,OAAO,MAAMC,UAAU,SAASD,SAAS,CAAC;EAMxCE,WAAWA,CAACC,MAAiB,EAAEC,cAA8B,EAAE;IAC7D,KAAK,CAACD,MAAM,CAAC;IAEb,IAAI,CAACE,SAAS,GAAG,OACfD,cAAc,CAACE,MAAM,CAACC,KAAK,GAAG,GAAG,GAAG,EAAE,gBACxBH,cAAc,CAACE,MAAM,CAACE,IAAI,EAAE;IAC5C,IAAI,CAACC,kBAAkB,GACrB,gEAAgE;IAClE,IAAI,CAACC,OAAO,GAAGd,IAAI,CAACe,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC;IACzD,IAAI,CAACC,MAAM,GAAG,IAAIb,MAAM,CAAC;MACvBc,KAAK,EAAEV,MAAM,CAACW,WAAW,IAAIhB,WAAW,CAACiB,IAAI;MAC7CC,UAAU,EAAEZ,cAAc,CAACQ;IAC7B,CAAC,CAAC;IACF,IAAI,CAACF,OAAO,GAAGd,IAAI,CAACe,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC;EAC3D;EAEAM,kBAAkB,GAAsBA,CAAA,KAAM;IAC5C,OAAO,IAAItB,WAAW,CAAC,IAAI,CAACU,SAAS,EAAE;MACrCa,OAAO,EAAE,iBAAiB;MAC1BC,WAAW,EAAE,aAAa;MAC1BC,WAAW,EAAE,UAAU;MACvBC,GAAG,EAAE,IAAI,CAACZ;IACZ,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,80 @@
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 EventEmitter from "node:events";
18
+ import * as fs from "node:fs";
19
+ import * as util from "node:util";
20
+ import { applyOntologyAndSeed } from "./applyOntologyAndSeed.js";
21
+ import { generateOntologyAssets } from "./generateOntologyAssets.js";
22
+ import { OacServerContext } from "./OacServerContext.js";
23
+ import { routeConnectToMsw } from "./routeConnectToMsw.js";
24
+ export class OacDevServer extends OacServerContext {
25
+ constructor(config, server) {
26
+ super(config, server);
27
+
28
+ // create one up front so its never null
29
+ this.foundry = this.fauxFoundryFactory();
30
+ this.emitter.on("generatedOntologyAssets", async () => {
31
+ this.foundry = this.fauxFoundryFactory();
32
+ await applyOntologyAndSeed(this.foundry, this);
33
+ server.hot.send({
34
+ type: "full-reload"
35
+ });
36
+ });
37
+ server.middlewares.use(this.#connectMiddleware);
38
+ }
39
+ #connectMiddleware = async (req, res, next) => {
40
+ const mswEmitter = new EventEmitter();
41
+ return void (await routeConnectToMsw(this.serverUrl, this.foundry.handlers, mswEmitter, req, res, next));
42
+ };
43
+ watchOntologyAsCode = async () => {
44
+ const {
45
+ ontologyDir,
46
+ watcher
47
+ } = this;
48
+ this.logger.info(`Starting OAC file watcher for ${ontologyDir}`);
49
+ if (!fs.existsSync(ontologyDir)) {
50
+ fs.mkdirSync(ontologyDir, {
51
+ recursive: true
52
+ });
53
+ }
54
+ watcher.add(ontologyDir);
55
+
56
+ // Add event listeners
57
+ watcher.on("add", this.#handleOacFileChanged).on("change", this.#handleOacFileChanged).on("unlink", this.#handleOacFileChanged);
58
+
59
+ // invoke the handler at startup
60
+ await this.#handleOacFileChanged(undefined);
61
+ };
62
+ #handleOacFileChanged = async filePath => {
63
+ if (filePath && !filePath.startsWith(`${this.ontologyDir}/`)) {
64
+ return;
65
+ }
66
+ if (filePath) {
67
+ this.logger.info(`File ${filePath} changed.`);
68
+ }
69
+ try {
70
+ await fs.promises.mkdir(this.workDir, {
71
+ recursive: true
72
+ });
73
+ await generateOntologyAssets(this);
74
+ await this.emitter.emit("generatedOntologyAssets");
75
+ } catch (error) {
76
+ this.logger.error(`Error generating ontology assets: ${util.inspect(error)}`);
77
+ }
78
+ };
79
+ }
80
+ //# sourceMappingURL=OacDevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OacDevServer.js","names":["EventEmitter","fs","util","applyOntologyAndSeed","generateOntologyAssets","OacServerContext","routeConnectToMsw","OacDevServer","constructor","config","server","foundry","fauxFoundryFactory","emitter","on","hot","send","type","middlewares","use","connectMiddleware","#connectMiddleware","req","res","next","mswEmitter","serverUrl","handlers","watchOntologyAsCode","ontologyDir","watcher","logger","info","existsSync","mkdirSync","recursive","add","handleOacFileChanged","undefined","filePath","startsWith","promises","mkdir","workDir","emit","error","inspect"],"sources":["OacDevServer.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, msw } from \"@osdk/faux\";\nimport EventEmitter from \"node:events\";\nimport * as fs from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport * as util from \"node:util\";\nimport type { Connect, ViteDevServer } from \"vite\";\nimport { applyOntologyAndSeed } from \"./applyOntologyAndSeed.js\";\nimport { generateOntologyAssets } from \"./generateOntologyAssets.js\";\nimport type { OacConfig } from \"./OacConfig.js\";\nimport { OacServerContext } from \"./OacServerContext.js\";\nimport { routeConnectToMsw } from \"./routeConnectToMsw.js\";\n\nexport class OacDevServer extends OacServerContext {\n foundry: FauxFoundry;\n\n constructor(config: OacConfig, server: ViteDevServer) {\n super(config, server);\n\n // create one up front so its never null\n this.foundry = this.fauxFoundryFactory();\n\n this.emitter.on(\"generatedOntologyAssets\", async () => {\n this.foundry = this.fauxFoundryFactory();\n await applyOntologyAndSeed(this.foundry, this);\n server.hot.send({ type: \"full-reload\" });\n });\n\n server.middlewares.use(this.#connectMiddleware);\n }\n\n #connectMiddleware = async (\n req: Connect.IncomingMessage,\n res: ServerResponse<IncomingMessage>,\n next: Connect.NextFunction,\n ): Promise<void> => {\n const mswEmitter = new EventEmitter<msw.LifeCycleEventsMap>();\n\n return void await routeConnectToMsw(\n this.serverUrl,\n this.foundry.handlers,\n mswEmitter,\n req,\n res,\n next,\n );\n };\n\n watchOntologyAsCode = async (): Promise<void> => {\n const { ontologyDir, watcher } = this;\n\n this.logger.info(`Starting OAC file watcher for ${ontologyDir}`);\n\n if (!fs.existsSync(ontologyDir)) {\n fs.mkdirSync(ontologyDir, { recursive: true });\n }\n\n watcher.add(ontologyDir);\n\n // Add event listeners\n watcher\n .on(\"add\", this.#handleOacFileChanged)\n .on(\"change\", this.#handleOacFileChanged)\n .on(\"unlink\", this.#handleOacFileChanged);\n\n // invoke the handler at startup\n await this.#handleOacFileChanged(undefined);\n\n return;\n };\n\n #handleOacFileChanged = async (filePath: string | undefined) => {\n if (filePath && !filePath.startsWith(`${this.ontologyDir}/`)) {\n return;\n }\n\n if (filePath) {\n this.logger.info(`File ${filePath} changed.`);\n }\n\n try {\n await fs.promises.mkdir(this.workDir, { recursive: true });\n await generateOntologyAssets(this);\n await this.emitter.emit(\"generatedOntologyAssets\");\n } catch (error) {\n this.logger.error(\n `Error generating ontology assets: ${util.inspect(error)}`,\n );\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,YAAY,MAAM,aAAa;AACtC,OAAO,KAAKC,EAAE,MAAM,SAAS;AAE7B,OAAO,KAAKC,IAAI,MAAM,WAAW;AAEjC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,sBAAsB,QAAQ,6BAA6B;AAEpE,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,iBAAiB,QAAQ,wBAAwB;AAE1D,OAAO,MAAMC,YAAY,SAASF,gBAAgB,CAAC;EAGjDG,WAAWA,CAACC,MAAiB,EAAEC,MAAqB,EAAE;IACpD,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;;IAErB;IACA,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,kBAAkB,CAAC,CAAC;IAExC,IAAI,CAACC,OAAO,CAACC,EAAE,CAAC,yBAAyB,EAAE,YAAY;MACrD,IAAI,CAACH,OAAO,GAAG,IAAI,CAACC,kBAAkB,CAAC,CAAC;MACxC,MAAMT,oBAAoB,CAAC,IAAI,CAACQ,OAAO,EAAE,IAAI,CAAC;MAC9CD,MAAM,CAACK,GAAG,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE;MAAc,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEFP,MAAM,CAACQ,WAAW,CAACC,GAAG,CAAC,IAAI,CAAC,CAACC,iBAAiB,CAAC;EACjD;EAEA,CAACA,iBAAiB,GAAG,MAAAC,CACnBC,GAA4B,EAC5BC,GAAoC,EACpCC,IAA0B,KACR;IAClB,MAAMC,UAAU,GAAG,IAAIzB,YAAY,CAAyB,CAAC;IAE7D,OAAO,MAAK,MAAMM,iBAAiB,CACjC,IAAI,CAACoB,SAAS,EACd,IAAI,CAACf,OAAO,CAACgB,QAAQ,EACrBF,UAAU,EACVH,GAAG,EACHC,GAAG,EACHC,IACF,CAAC;EACH,CAAC;EAEDI,mBAAmB,GAAG,MAAAA,CAAA,KAA2B;IAC/C,MAAM;MAAEC,WAAW;MAAEC;IAAQ,CAAC,GAAG,IAAI;IAErC,IAAI,CAACC,MAAM,CAACC,IAAI,CAAC,iCAAiCH,WAAW,EAAE,CAAC;IAEhE,IAAI,CAAC5B,EAAE,CAACgC,UAAU,CAACJ,WAAW,CAAC,EAAE;MAC/B5B,EAAE,CAACiC,SAAS,CAACL,WAAW,EAAE;QAAEM,SAAS,EAAE;MAAK,CAAC,CAAC;IAChD;IAEAL,OAAO,CAACM,GAAG,CAACP,WAAW,CAAC;;IAExB;IACAC,OAAO,CACJhB,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAACuB,oBAAoB,CAAC,CACrCvB,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAACuB,oBAAoB,CAAC,CACxCvB,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAACuB,oBAAoB,CAAC;;IAE3C;IACA,MAAM,IAAI,CAAC,CAACA,oBAAoB,CAACC,SAAS,CAAC;EAG7C,CAAC;EAED,CAACD,oBAAoB,GAAG,MAAOE,QAA4B,IAAK;IAC9D,IAAIA,QAAQ,IAAI,CAACA,QAAQ,CAACC,UAAU,CAAC,GAAG,IAAI,CAACX,WAAW,GAAG,CAAC,EAAE;MAC5D;IACF;IAEA,IAAIU,QAAQ,EAAE;MACZ,IAAI,CAACR,MAAM,CAACC,IAAI,CAAC,QAAQO,QAAQ,WAAW,CAAC;IAC/C;IAEA,IAAI;MACF,MAAMtC,EAAE,CAACwC,QAAQ,CAACC,KAAK,CAAC,IAAI,CAACC,OAAO,EAAE;QAAER,SAAS,EAAE;MAAK,CAAC,CAAC;MAC1D,MAAM/B,sBAAsB,CAAC,IAAI,CAAC;MAClC,MAAM,IAAI,CAACS,OAAO,CAAC+B,IAAI,CAAC,yBAAyB,CAAC;IACpD,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,IAAI,CAACd,MAAM,CAACc,KAAK,CACf,qCAAqC3C,IAAI,CAAC4C,OAAO,CAACD,KAAK,CAAC,EAC1D,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,26 @@
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 Emittery from "emittery";
18
+ import { OacContext } from "./OacContext.js";
19
+ export class OacServerContext extends OacContext {
20
+ constructor(config, server) {
21
+ super(config, server.config);
22
+ this.watcher = server.watcher;
23
+ this.emitter = new Emittery();
24
+ }
25
+ }
26
+ //# sourceMappingURL=OacServerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OacServerContext.js","names":["Emittery","OacContext","OacServerContext","constructor","config","server","watcher","emitter"],"sources":["OacServerContext.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 Emittery from \"emittery\";\nimport type { FSWatcher, ViteDevServer } from \"vite\";\nimport type { OacConfig } from \"./OacConfig.js\";\nimport { OacContext } from \"./OacContext.js\";\n\nexport interface OacServerEvents {\n generatedOntologyAssets: undefined;\n}\n\nexport class OacServerContext extends OacContext {\n watcher: FSWatcher;\n emitter: Emittery<OacServerEvents>;\n\n constructor(config: OacConfig, server: ViteDevServer) {\n super(config, server.config);\n this.watcher = server.watcher;\n this.emitter = new Emittery<OacServerEvents>();\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,QAAQ,MAAM,UAAU;AAG/B,SAASC,UAAU,QAAQ,iBAAiB;AAM5C,OAAO,MAAMC,gBAAgB,SAASD,UAAU,CAAC;EAI/CE,WAAWA,CAACC,MAAiB,EAAEC,MAAqB,EAAE;IACpD,KAAK,CAACD,MAAM,EAAEC,MAAM,CAACD,MAAM,CAAC;IAC5B,IAAI,CAACE,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAG,IAAIP,QAAQ,CAAkB,CAAC;EAChD;AACF","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import * as path from "node:path";
18
+ import { inspect } from "node:util";
19
+ import { applySeed } from "./applySeed.js";
20
+ import { ontologyFullMetadataPath } from "./generateOntologyAssets.js";
21
+ import { registerOntologyFullMetadata } from "./registerOntologyFullMetadata.js";
22
+ import { readJsonFile } from "./utils/readJsonFile.js";
23
+ export async function applyOntologyAndSeed(fauxFoundry, ctx) {
24
+ const ontology = fauxFoundry.getDefaultOntology();
25
+ const ontologyFullMetadata = readJsonFile(ontologyFullMetadataPath(ctx.workDir));
26
+ registerOntologyFullMetadata(ontology, ontologyFullMetadata);
27
+ try {
28
+ if (ctx.hooks?.preSeed) {
29
+ ctx.logger.debug("calling preSeed hook");
30
+ }
31
+ await ctx.hooks?.preSeed?.(ontology);
32
+ } catch (e) {
33
+ ctx.logger.error(`Unhandled error from preSeed hook. Ignoring and continuing. ${inspect(e)}`);
34
+ }
35
+ ctx.logger.debug("applying seed data");
36
+ await applySeed(fauxFoundry, path.resolve(ctx.ontologyDir, "seed.ts"));
37
+ }
38
+ //# sourceMappingURL=applyOntologyAndSeed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyOntologyAndSeed.js","names":["path","inspect","applySeed","ontologyFullMetadataPath","registerOntologyFullMetadata","readJsonFile","applyOntologyAndSeed","fauxFoundry","ctx","ontology","getDefaultOntology","ontologyFullMetadata","workDir","hooks","preSeed","logger","debug","e","error","resolve","ontologyDir"],"sources":["applyOntologyAndSeed.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { FauxFoundry } from \"@osdk/faux\";\nimport type { OntologyFullMetadata } from \"@osdk/foundry.ontologies\";\nimport * as path from \"node:path\";\nimport { inspect } from \"node:util\";\nimport { applySeed } from \"./applySeed.js\";\nimport { ontologyFullMetadataPath } from \"./generateOntologyAssets.js\";\nimport { type OacContext } from \"./OacContext.js\";\nimport { registerOntologyFullMetadata } from \"./registerOntologyFullMetadata.js\";\nimport { readJsonFile } from \"./utils/readJsonFile.js\";\n\nexport async function applyOntologyAndSeed(\n fauxFoundry: FauxFoundry,\n ctx: OacContext,\n): Promise<void> {\n const ontology = fauxFoundry.getDefaultOntology();\n\n const ontologyFullMetadata = readJsonFile<OntologyFullMetadata>(\n ontologyFullMetadataPath(ctx.workDir),\n );\n registerOntologyFullMetadata(ontology, ontologyFullMetadata);\n\n try {\n if (ctx.hooks?.preSeed) {\n ctx.logger.debug(\"calling preSeed hook\");\n }\n\n await ctx.hooks?.preSeed?.(ontology);\n } catch (e) {\n ctx.logger.error(\n `Unhandled error from preSeed hook. Ignoring and continuing. ${\n inspect(e)\n }`,\n );\n }\n\n ctx.logger.debug(\"applying seed data\");\n await applySeed(\n fauxFoundry,\n path.resolve(ctx.ontologyDir, \"seed.ts\"),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,KAAKA,IAAI,MAAM,WAAW;AACjC,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,wBAAwB,QAAQ,6BAA6B;AAEtE,SAASC,4BAA4B,QAAQ,mCAAmC;AAChF,SAASC,YAAY,QAAQ,yBAAyB;AAEtD,OAAO,eAAeC,oBAAoBA,CACxCC,WAAwB,EACxBC,GAAe,EACA;EACf,MAAMC,QAAQ,GAAGF,WAAW,CAACG,kBAAkB,CAAC,CAAC;EAEjD,MAAMC,oBAAoB,GAAGN,YAAY,CACvCF,wBAAwB,CAACK,GAAG,CAACI,OAAO,CACtC,CAAC;EACDR,4BAA4B,CAACK,QAAQ,EAAEE,oBAAoB,CAAC;EAE5D,IAAI;IACF,IAAIH,GAAG,CAACK,KAAK,EAAEC,OAAO,EAAE;MACtBN,GAAG,CAACO,MAAM,CAACC,KAAK,CAAC,sBAAsB,CAAC;IAC1C;IAEA,MAAMR,GAAG,CAACK,KAAK,EAAEC,OAAO,GAAGL,QAAQ,CAAC;EACtC,CAAC,CAAC,OAAOQ,CAAC,EAAE;IACVT,GAAG,CAACO,MAAM,CAACG,KAAK,CACd,+DACEjB,OAAO,CAACgB,CAAC,CAAC,EAEd,CAAC;EACH;EAEAT,GAAG,CAACO,MAAM,CAACC,KAAK,CAAC,oBAAoB,CAAC;EACtC,MAAMd,SAAS,CACbK,WAAW,EACXP,IAAI,CAACmB,OAAO,CAACX,GAAG,CAACY,WAAW,EAAE,SAAS,CACzC,CAAC;AACH","ignoreList":[]}
@@ -16,94 +16,91 @@
16
16
 
17
17
  import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
18
18
  import { execa } from "execa";
19
- import fs from "node:fs";
20
- import path from "node:path";
19
+ import * as fs from "node:fs";
20
+ import * as path from "node:path";
21
+ import { inspect } from "node:util";
21
22
  import { syncDirectories } from "./syncDirectories.js";
22
- export const NOISY = false;
23
+
23
24
  /**
24
25
  * Generate all ontology assets: IR, full metadata, and OSDK.
25
26
  * This function contains the core generation logic extracted from watchOntologyAsCode
26
27
  * so it can be used both in dev mode (via file watching) and build mode.
27
28
  */
28
- export async function generateOntologyAssets({
29
- logger,
30
- ontologyDir
31
- }) {
29
+ export async function generateOntologyAssets(opts) {
30
+ const {
31
+ ontologyDir,
32
+ logger
33
+ } = opts;
34
+ await fs.promises.mkdir(opts.workDir, {
35
+ recursive: true
36
+ });
37
+
32
38
  // Ensure the ontology directory exists
33
39
  if (!fs.existsSync(ontologyDir)) {
34
40
  fs.mkdirSync(ontologyDir, {
35
41
  recursive: true
36
42
  });
37
- logger.info("Created .ontology directory", {
38
- timestamp: true
39
- });
43
+ logger.info("Created .ontology directory");
40
44
  }
41
45
 
42
46
  // Generate the assets in sequence
43
- await ontologyJsToIr(logger);
44
- await ontologyIrToFullMetadata(logger);
45
- await fullMetadataToOsdk(logger);
47
+ await ontologyJsToIr(opts);
48
+ await ontologyIrToFullMetadata(opts);
49
+ await fullMetadataToOsdk(opts);
50
+ }
51
+ export function ontologyIrPath(workDir) {
52
+ return path.join(workDir, ".ontology.ir.json");
53
+ }
54
+ export function ontologyFullMetadataPath(workDir) {
55
+ return path.join(workDir, ".ontology.json");
46
56
  }
47
57
 
48
58
  /**
49
59
  * Convert ontology.mjs to IR format using the maker tool
50
60
  */
51
- async function ontologyJsToIr(logger) {
52
- if (NOISY) {
53
- logger.info("Generating Ontology IR", {
54
- timestamp: true
55
- });
56
- }
61
+ async function ontologyJsToIr({
62
+ logger,
63
+ ontologyDir,
64
+ workDir
65
+ }) {
66
+ logger.debug("Generating Ontology IR");
57
67
  const {
58
68
  stdout,
59
69
  stderr,
60
70
  exitCode
61
- } = await execa("pnpm", ["exec", "maker", "-i", ".ontology/ontology.mjs", "-o", ".ontology.ir.json"]);
71
+ } = await execa("pnpm", ["exec", "maker", "-i", `${ontologyDir}/ontology.mts`, "-o", ontologyIrPath(workDir)]);
62
72
  if (exitCode !== 0) {
63
- logger.error(`Ontology IR generation failed with exit code ${exitCode}`, {
64
- timestamp: true
65
- });
73
+ logger.error(`Ontology IR generation failed with exit code ${exitCode}`);
66
74
  if (stderr) {
67
- logger.error(`Command stderr: ${stderr}`, {
68
- timestamp: true
69
- });
75
+ logger.error(`Command stderr: ${stderr}`);
70
76
  }
71
77
  throw new Error(`Failed to generate ontology IR: exit code ${exitCode}`);
72
78
  }
73
79
 
74
80
  // Log stdout for debugging if needed
75
- if (stdout && NOISY) {
76
- logger.info(`Ontology IR generation output: ${stdout}`, {
77
- timestamp: true
78
- });
81
+ if (stdout) {
82
+ logger.debug(`Ontology IR generation output: ${stdout}`);
79
83
  }
80
84
  }
81
85
 
82
86
  /**
83
87
  * Convert IR to full metadata format
84
88
  */
85
- async function ontologyIrToFullMetadata(logger) {
86
- if (NOISY) {
87
- logger.info("Converting IR to Full metadata", {
88
- timestamp: true
89
- });
90
- }
89
+ async function ontologyIrToFullMetadata({
90
+ logger,
91
+ workDir
92
+ }) {
93
+ logger.debug("Converting IR to Full metadata");
91
94
  try {
92
- const irContent = await fs.promises.readFile("./.ontology.ir.json", {
95
+ const irContent = await fs.promises.readFile(ontologyIrPath(workDir), {
93
96
  encoding: "utf-8"
94
97
  });
95
98
  const blockData = JSON.parse(irContent).blockData;
96
99
  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
- }
100
+ await fs.promises.writeFile(ontologyFullMetadataPath(workDir), JSON.stringify(fullMeta, null, 2));
101
+ logger.debug("Successfully converted IR to full metadata");
103
102
  } catch (error) {
104
- logger.error(`Failed to convert IR to full metadata: ${error instanceof Error ? error.message : String(error)}`, {
105
- timestamp: true
106
- });
103
+ logger.error(`Failed to convert IR to full metadata: ${inspect(error)}`);
107
104
  throw error;
108
105
  }
109
106
  }
@@ -111,15 +108,14 @@ async function ontologyIrToFullMetadata(logger) {
111
108
  /**
112
109
  * Generate OSDK from full metadata
113
110
  */
114
- async function fullMetadataToOsdk(logger) {
115
- if (NOISY) {
116
- logger.info("Generating OSDK from full metadata", {
117
- timestamp: true
118
- });
119
- }
111
+ async function fullMetadataToOsdk({
112
+ logger,
113
+ workDir
114
+ }) {
115
+ logger.debug("Generating OSDK from full metadata");
120
116
 
121
117
  // First create a clean temporary directory to generate the SDK into
122
- const tempDir = path.join(process.cwd(), "node_modules", ".tmp", "osdkGeneration");
118
+ const tempDir = path.join(workDir, ".osdkGenerationTmp", "src");
123
119
  await fs.promises.rm(tempDir, {
124
120
  recursive: true,
125
121
  force: true
@@ -127,6 +123,12 @@ async function fullMetadataToOsdk(logger) {
127
123
  await fs.promises.mkdir(tempDir, {
128
124
  recursive: true
129
125
  });
126
+
127
+ // The osdk cli currently mutes package.json files which we don't want in this case
128
+ // so we give it a fake package.json file
129
+ await fs.promises.writeFile(path.join(tempDir, "..", "package.json"), JSON.stringify({}, null, 2), {
130
+ encoding: "utf-8"
131
+ });
130
132
  try {
131
133
  // Then generate the source code for the osdk
132
134
  const tempSrcDir = path.join(tempDir, "src");
@@ -134,35 +136,23 @@ async function fullMetadataToOsdk(logger) {
134
136
  stdout,
135
137
  stderr,
136
138
  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
- }
139
+ } = await execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", tempSrcDir, "--ontologyPath", ontologyFullMetadataPath(workDir), "--beta", "true", "--packageType", "module", "--version", "dev"]);
140
+ logger.debug(`OSDK generation output: ${stdout}`);
143
141
  if (stderr) {
144
- logger.error(`OSDK generation stderr: ${stderr}`, {
145
- timestamp: true
146
- });
142
+ logger.error(`OSDK generation stderr: ${stderr}`);
147
143
  }
148
144
 
149
145
  // Then if it was successful, synchronize the generated code with the target directory
150
146
  if (exitCode === 0) {
147
+ // TODO we should just generate this whole thing into the work dir?
151
148
  const targetDir = ".osdk/src";
152
149
  try {
153
- if (NOISY) {
154
- logger.info("OSDK generation successful, synchronizing with target directory", {
155
- timestamp: true
156
- });
157
- }
150
+ logger.debug("OSDK generation successful, synchronizing with target directory");
158
151
 
159
152
  // Use granular synchronization instead of wholesale replacement
160
153
  await syncDirectories(tempSrcDir, targetDir, logger);
161
- if (NOISY) {
162
- logger.info(`Successfully synchronized ${targetDir} with newly generated code`, {
163
- timestamp: true
164
- });
165
- }
154
+ logger.debug(`Successfully synchronized ${targetDir} with newly generated code`);
155
+ await compileOsdk(logger);
166
156
 
167
157
  // Clean up temporary directory after successful sync
168
158
  await fs.promises.rm(tempDir, {
@@ -170,21 +160,13 @@ async function fullMetadataToOsdk(logger) {
170
160
  force: true
171
161
  });
172
162
  } 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
- });
163
+ logger.error(`Failed to synchronize ${targetDir} directory: ${inspect(error)}`);
164
+ logger.error(`Temporary files left at: ${tempDir}`);
179
165
  throw error;
180
166
  }
181
167
  } 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
- });
168
+ logger.error(`OSDK generation failed with exit code ${exitCode}`);
169
+ logger.error(`Temporary files left at: ${tempDir}`);
188
170
  throw new Error(`OSDK generation failed with exit code ${exitCode}`);
189
171
  }
190
172
  } catch (error) {
@@ -195,11 +177,23 @@ async function fullMetadataToOsdk(logger) {
195
177
  force: true
196
178
  });
197
179
  } catch (cleanupError) {
198
- logger.warn(`Failed to clean up temporary directory: ${cleanupError instanceof Error ? cleanupError.message : String(cleanupError)}`, {
199
- timestamp: true
200
- });
180
+ logger.warn(`Failed to clean up temporary directory: ${inspect(cleanupError)}`);
201
181
  }
202
182
  throw error;
203
183
  }
204
184
  }
185
+ async function compileOsdk(logger) {
186
+ const {
187
+ stdout,
188
+ stderr,
189
+ exitCode
190
+ } = await execa("pnpm", ["exec", "tsc"], {
191
+ cwd: ".osdk"
192
+ });
193
+ logger.debug(`OSDK generation output: ${stdout}`);
194
+ if (stderr) {
195
+ logger.error(`OSDK generation stderr: ${stderr}`);
196
+ }
197
+ return exitCode;
198
+ }
205
199
  //# sourceMappingURL=generateOntologyAssets.js.map