@osdk/maker 0.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021 → 0.76.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/CHANGELOG.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # @osdk/maker
2
2
 
3
- ## 0.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021
3
+ ## 0.76.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
+ - dec2ee4: Preserve action-level validation and failure messages in interface delete actions.
7
8
  - c11669e: Fix incomplete Marketplace mappings for SPTs imported ontology objects
9
+ - a38af5a: Regenerate OMS bindings to add phonetic search support and align Maker with marketplace datasource types.
8
10
 
9
11
  ### Patch Changes
10
12
 
11
- - dec2ee4: Preserve action-level validation and failure messages in interface delete actions.
12
- - a38af5a: Regenerate OMS bindings to add phonetic search support and align Maker with marketplace datasource types.
13
13
  - Updated dependencies [43dd010]
14
14
  - Updated dependencies [a9fafd0]
15
- - @osdk/generator-converters.ontologyir@2.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021
16
- - @osdk/api@2.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021
15
+ - @osdk/generator-converters.ontologyir@2.76.0
16
+ - @osdk/api@2.76.0
17
17
 
18
18
  ## 0.75.0
19
19
 
@@ -27,7 +27,7 @@ import { reconcileOntologySchemaLockfile } from "../lockfile/reconcileOntologySc
27
27
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/u;
28
28
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
29
29
  export default async function main(args = process.argv) {
30
- const commandLineOpts = await yargs(hideBin(args)).version("0.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
30
+ const commandLineOpts = await yargs(hideBin(args)).version("0.76.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
31
31
  input: {
32
32
  alias: "i",
33
33
  describe: "Input file",
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["fs","path","pathToFileURL","consola","LogLevels","invariant","yargs","hideBin","defineOntology","DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME","reconcileOntologySchemaLockfile","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","lockfile","writeLocks","yes","verbose","count","middleware","level","logLevelFor","implies","fail","msg","err","usage","showHelp","Error","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","lockfilePath","join","dirname","ontologyIr","loadOntology","ontology","assumeYes","writeFile","JSON","stringify","key","value","valueTypes","importedValueTypes","verbosity","debug","trace","dependencyFile","snippetPackageName","beforeWrite","q","href"],"sources":["main.ts"],"sourcesContent":["/*\n * Copyright 2024 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/promises\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { LogLevel } from \"consola\";\nimport { consola, LogLevels } from \"consola\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport type { OntologyDefinition } from \"../api/common/OntologyDefinition.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME } from \"../lockfile/OntologySchemaLockfile.js\";\nimport { reconcileOntologySchemaLockfile } from \"../lockfile/reconcileOntologySchemaLockfile.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/u;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n lockfile?: string;\n writeLocks?: boolean;\n yes?: boolean;\n verbose: number;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n },\n lockfile: {\n describe: `Ontology schema lockfile path (default: ${DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME} beside --input)`,\n type: \"string\",\n // No `default`: it depends on --input, which `coerce` cannot see. Resolved after parsing.\n coerce: path.resolve,\n },\n writeLocks: {\n describe:\n \"Update the ontology schema lockfile instead of failing when it is out of date\",\n type: \"boolean\",\n // NB: no default since \"implied\" below\n },\n yes: {\n alias: \"y\",\n describe:\n \"Accept detected ontology schema migration finalizations/deletions without prompting\",\n type: \"boolean\",\n // NB: no default since \"implied\" below\n },\n verbose: {\n alias: \"v\",\n describe:\n \"Enable verbose logging: -v for debug, including stack traces on failure, -vv for trace\",\n type: \"boolean\",\n count: true,\n },\n })\n .middleware(({ verbose }) => {\n consola.level = logLevelFor(verbose);\n }, true)\n // --yes only answers the prompt that --write-locks can raise, so on its own it does nothing.\n .implies(\"yes\", \"writeLocks\")\n // Without this, the usage error that `implies` raises calls `process.exit` from inside the\n // library, which takes the whole host process with it.\n .fail((msg, err, usage) => {\n if (err) {\n throw err;\n }\n\n // Registering a failure handler suppresses yargs' showHelpOnFail behavior, so reinstate it.\n usage.showHelp(\"error\");\n throw new Error(msg);\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace =\n commandLineOpts.apiNamespace.slice(-1) !== \".\"\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets &&\n (commandLineOpts.codeSnippetPackageName !== \"\" ||\n commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n // The lockfile is a checked-in source artifact describing the ontology definition, not a build artifact\n // like `output`, so it belongs beside the definition rather than wherever maker was invoked.\n const lockfilePath =\n commandLineOpts.lockfile ??\n path.join(\n path.dirname(commandLineOpts.input),\n DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME,\n );\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n // An ontology that fails lockfile checks would fail at installation-time, so the ontology-ir\n // should never reach disk at all.\n async (ontology) =>\n await reconcileOntologySchemaLockfile({\n ontology,\n lockfilePath,\n writeLocks: commandLineOpts.writeLocks ?? false,\n assumeYes: commandLineOpts.yes ?? false,\n }),\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n (key, value) => (key === \"linkedInterfaces\" ? undefined : value),\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0 ||\n ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(ontologyIr.valueTypes, null, 2),\n );\n }\n}\n\nfunction logLevelFor(verbosity: number): LogLevel {\n if (verbosity === 0) return LogLevels.info;\n if (verbosity === 1) return LogLevels.debug;\n return LogLevels.trace;\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey: string | undefined,\n beforeWrite: (ontology: OntologyDefinition) => Promise<void>,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(pathToFileURL(input).href),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n beforeWrite,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,aAAa,QAAQ,UAAU;AAGxC,SAASC,OAAO,EAAEC,SAAS,QAAQ,SAAS;AAC5C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AAGvC,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,qCAAqC,QAAQ,uCAAuC;AAC7F,SAASC,+BAA+B,QAAQ,gDAAgD;AAEhG,MAAMC,iBAAiB,GAAG,gCAAgC;AAC1D,MAAMC,SAAS,GACb,iEAAiE;AAEnE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eAgBL,GAAG,MAAMX,KAAK,CAACC,OAAO,CAACO,IAAI,CAAC,CAAC,CAC3BI,OAAO,CAAC,0DAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEf,KAAK,CAAC,CAAC,CAACgB,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5CC,MAAM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,EACbQ,YAAoB,EACpBE,SAA6B,EAC7B+C,cAAkC,EAClC5C,oBAA6B,EAC7B6C,kBAA0B,EAC1B3C,cAAsB,EACtBC,aAAiC,EACjC2C,WAA4D,EAC5D;EACA,MAAMC,CAAC,GAAG,MAAM9E,cAAc,CAC5B0B,YAAY,EACZ,YAAY,MAAM,MAAM,CAAChC,aAAa,CAACwB,KAAK,CAAC,CAAC6D,IAAI,CAAC,EACnDnD,SAAS,EACT+C,cAAc,EACd5C,oBAAoB,EACpB6C,kBAAkB,EAClB3C,cAAc,EACdC,aAAa,EACb2C,WACF,CAAC;EACD,OAAOC,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"main.js","names":["fs","path","pathToFileURL","consola","LogLevels","invariant","yargs","hideBin","defineOntology","DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME","reconcileOntologySchemaLockfile","apiNamespaceRegex","uuidRegex","main","args","process","argv","commandLineOpts","version","wrap","Math","min","terminalWidth","strict","help","options","input","alias","describe","type","default","coerce","resolve","output","apiNamespace","snapshotDir","outputDir","valueTypesOutput","dependencies","generateCodeSnippets","codeSnippetPackageName","codeSnippetDir","randomnessKey","lockfile","writeLocks","yes","verbose","count","middleware","level","logLevelFor","implies","fail","msg","err","usage","showHelp","Error","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","lockfilePath","join","dirname","ontologyIr","loadOntology","ontology","assumeYes","writeFile","JSON","stringify","key","value","valueTypes","importedValueTypes","verbosity","debug","trace","dependencyFile","snippetPackageName","beforeWrite","q","href"],"sources":["main.ts"],"sourcesContent":["/*\n * Copyright 2024 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/promises\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { LogLevel } from \"consola\";\nimport { consola, LogLevels } from \"consola\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport type { OntologyDefinition } from \"../api/common/OntologyDefinition.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\nimport { DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME } from \"../lockfile/OntologySchemaLockfile.js\";\nimport { reconcileOntologySchemaLockfile } from \"../lockfile/reconcileOntologySchemaLockfile.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/u;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;\n\nexport default async function main(\n args: string[] = process.argv,\n): Promise<void> {\n const commandLineOpts: {\n input: string;\n output: string;\n apiNamespace: string;\n snapshotDir: string;\n valueTypesOutput: string;\n outputDir?: string;\n dependencies?: string;\n generateCodeSnippets: boolean;\n codeSnippetPackageName: string;\n codeSnippetDir: string;\n randomnessKey?: string;\n lockfile?: string;\n writeLocks?: boolean;\n yes?: boolean;\n verbose: number;\n } = await yargs(hideBin(args))\n .version(process.env.PACKAGE_VERSION ?? \"\")\n .wrap(Math.min(150, yargs().terminalWidth()))\n .strict()\n .help()\n .options({\n input: {\n alias: \"i\",\n describe: \"Input file\",\n type: \"string\",\n default: \".ontology/ontology.ts\",\n coerce: path.resolve,\n },\n output: {\n alias: \"o\",\n describe: \"Output file\",\n type: \"string\",\n default: \"ontology.json\",\n coerce: path.resolve,\n },\n apiNamespace: {\n describe: \"Api name prefix for namespaced ontology types\",\n type: \"string\",\n default: \"\",\n },\n snapshotDir: {\n alias: \"s\",\n describe: \"Snapshot directory\",\n type: \"string\",\n default: \"snapshots\",\n coerce: path.resolve,\n },\n outputDir: {\n alias: \"d\",\n describe: \"Directory for generated ontology entities\",\n type: \"string\",\n coerce: path.resolve,\n },\n valueTypesOutput: {\n describe: \"Value Type Output File\",\n type: \"string\",\n default: \"value-types.json\",\n coerce: path.resolve,\n },\n dependencies: {\n describe: \"File to write dependencies to\",\n type: \"string\",\n coerce: path.resolve,\n },\n generateCodeSnippets: {\n describe: \"Enable code snippet files creation\",\n type: \"boolean\",\n default: false,\n },\n codeSnippetPackageName: {\n describe:\n \"The package name that will be displayed in the code snippets\",\n default: \"\",\n type: \"string\",\n },\n codeSnippetDir: {\n describe: \"Directory for generated code snippet files\",\n type: \"string\",\n default: \"./\",\n coerce: path.resolve,\n },\n randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\n type: \"string\",\n },\n lockfile: {\n describe: `Ontology schema lockfile path (default: ${DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME} beside --input)`,\n type: \"string\",\n // No `default`: it depends on --input, which `coerce` cannot see. Resolved after parsing.\n coerce: path.resolve,\n },\n writeLocks: {\n describe:\n \"Update the ontology schema lockfile instead of failing when it is out of date\",\n type: \"boolean\",\n // NB: no default since \"implied\" below\n },\n yes: {\n alias: \"y\",\n describe:\n \"Accept detected ontology schema migration finalizations/deletions without prompting\",\n type: \"boolean\",\n // NB: no default since \"implied\" below\n },\n verbose: {\n alias: \"v\",\n describe:\n \"Enable verbose logging: -v for debug, including stack traces on failure, -vv for trace\",\n type: \"boolean\",\n count: true,\n },\n })\n .middleware(({ verbose }) => {\n consola.level = logLevelFor(verbose);\n }, true)\n // --yes only answers the prompt that --write-locks can raise, so on its own it does nothing.\n .implies(\"yes\", \"writeLocks\")\n // Without this, the usage error that `implies` raises calls `process.exit` from inside the\n // library, which takes the whole host process with it.\n .fail((msg, err, usage) => {\n if (err) {\n throw err;\n }\n\n // Registering a failure handler suppresses yargs' showHelpOnFail behavior, so reinstate it.\n usage.showHelp(\"error\");\n throw new Error(msg);\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace =\n commandLineOpts.apiNamespace.slice(-1) !== \".\"\n ? commandLineOpts.apiNamespace + \".\"\n : commandLineOpts.apiNamespace;\n invariant(apiNamespace.length < 1024, \"API namespace is too long.\");\n invariant(\n apiNamespaceRegex.test(apiNamespace),\n \"API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$\",\n );\n }\n consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (\n !commandLineOpts.generateCodeSnippets &&\n (commandLineOpts.codeSnippetPackageName !== \"\" ||\n commandLineOpts.codeSnippetDir !== path.resolve(\"./\"))\n ) {\n consola.info(\n \"Package name and/or directory supplied for code snippets, but code snippet generation is false.\",\n );\n }\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n uuidRegex.test(commandLineOpts.randomnessKey),\n \"Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee\",\n );\n }\n\n // The lockfile is a checked-in source artifact describing the ontology definition, not a build artifact\n // like `output`, so it belongs beside the definition rather than wherever maker was invoked.\n const lockfilePath =\n commandLineOpts.lockfile ??\n path.join(\n path.dirname(commandLineOpts.input),\n DEFAULT_ONTOLOGY_SCHEMA_LOCKFILE_NAME,\n );\n\n const ontologyIr = await loadOntology(\n commandLineOpts.input,\n apiNamespace,\n commandLineOpts.outputDir,\n commandLineOpts.dependencies,\n commandLineOpts.generateCodeSnippets,\n commandLineOpts.codeSnippetPackageName,\n commandLineOpts.codeSnippetDir,\n commandLineOpts.randomnessKey,\n // An ontology that fails lockfile checks would fail at installation-time, so the ontology-ir\n // should never reach disk at all.\n async (ontology) =>\n await reconcileOntologySchemaLockfile({\n ontology,\n lockfilePath,\n writeLocks: commandLineOpts.writeLocks ?? false,\n assumeYes: commandLineOpts.yes ?? false,\n }),\n );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n (key, value) => (key === \"linkedInterfaces\" ? undefined : value),\n 2,\n ),\n );\n // No point in generating block if there aren't any value types\n if (\n ontologyIr.valueTypes.valueTypes.length > 0 ||\n ontologyIr.importedValueTypes.valueTypes.length > 0\n ) {\n await fs.writeFile(\n commandLineOpts.valueTypesOutput,\n JSON.stringify(ontologyIr.valueTypes, null, 2),\n );\n }\n}\n\nfunction logLevelFor(verbosity: number): LogLevel {\n if (verbosity === 0) return LogLevels.info;\n if (verbosity === 1) return LogLevels.debug;\n return LogLevels.trace;\n}\n\nasync function loadOntology(\n input: string,\n apiNamespace: string,\n outputDir: string | undefined,\n dependencyFile: string | undefined,\n generateCodeSnippets: boolean,\n snippetPackageName: string,\n codeSnippetDir: string,\n randomnessKey: string | undefined,\n beforeWrite: (ontology: OntologyDefinition) => Promise<void>,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(pathToFileURL(input).href),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n beforeWrite,\n );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,aAAa,QAAQ,UAAU;AAGxC,SAASC,OAAO,EAAEC,SAAS,QAAQ,SAAS;AAC5C,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AAGvC,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,qCAAqC,QAAQ,uCAAuC;AAC7F,SAASC,+BAA+B,QAAQ,gDAAgD;AAEhG,MAAMC,iBAAiB,GAAG,gCAAgC;AAC1D,MAAMC,SAAS,GACb,iEAAiE;AAEnE,eAAe,eAAeC,IAAIA,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CAAC,CAC/C,CAAC;EACH;AACF;AAEA,SAAS5B,WAAWA,CAAC8B,SAAiB,EAAY;EAChD,IAAIA,SAAS,KAAK,CAAC,EAAE,OAAO5E,SAAS,CAAC4D,IAAI;EAC1C,IAAIgB,SAAS,KAAK,CAAC,EAAE,OAAO5E,SAAS,CAAC6E,KAAK;EAC3C,OAAO7E,SAAS,CAAC8E,KAAK;AACxB;AAEA,eAAeZ,YAAYA,CACzB5C,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7B+C,cAAkC,EAClC5C,oBAA6B,EAC7B6C,kBAA0B,EAC1B3C,cAAsB,EACtBC,aAAiC,EACjC2C,WAA4D,EAC5D;EACA,MAAMC,CAAC,GAAG,MAAM9E,cAAc,CAC5B0B,YAAY,EACZ,YAAY,MAAM,MAAM,CAAChC,aAAa,CAACwB,KAAK,CAAC,CAAC6D,IAAI,CAAC,EACnDnD,SAAS,EACT+C,cAAc,EACd5C,oBAAoB,EACpB6C,kBAAkB,EAClB3C,cAAc,EACdC,aAAa,EACb2C,WACF,CAAC;EACD,OAAOC,CAAC;AACV","ignoreList":[]}
@@ -6365,7 +6365,7 @@ async function readIfExists(path5) {
6365
6365
  var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/u;
6366
6366
  var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
6367
6367
  async function main(args = process.argv) {
6368
- const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.76.0-main-0c092519b1e0bcb2ce003bbf6dc8d474c35b7021").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
6368
+ const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.76.0").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
6369
6369
  input: {
6370
6370
  alias: "i",
6371
6371
  describe: "Input file",