@osdk/maker 0.90.0 → 0.90.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de

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,5 +1,14 @@
1
1
  # @osdk/maker
2
2
 
3
+ ## 0.90.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de
4
+
5
+ ### Patch Changes
6
+
7
+ - 8aa522d: Use SDK identifiers in generated snippets for namespaced objects, interfaces, and actions, and for hyphenated action names.
8
+ - Updated dependencies [749af7f]
9
+ - @osdk/api@2.91.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de
10
+ - @osdk/generator-converters.ontologyir@2.91.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de
11
+
3
12
  ## 0.90.0
4
13
 
5
14
  ### Minor Changes
@@ -20,6 +20,7 @@ import { TYPESCRIPT_OSDK_SNIPPETS } from "@osdk/typescript-sdk-docs";
20
20
  import { consola } from "consola";
21
21
  import Mustache from "mustache";
22
22
  import { OntologyEntityTypeEnum } from "../common/OntologyEntityTypeEnum.js";
23
+ import { withoutNamespace } from "../defineOntology.js";
23
24
  import { actionSnippets, interfaceSnippets, objectSnippets, snippetNameMapping } from "./snippetTypes.js";
24
25
  export function createCodeSnippets(ontology, packageName, outputDir) {
25
26
  if (outputDir === undefined) {
@@ -56,30 +57,38 @@ export function createCodeSnippets(ontology, packageName, outputDir) {
56
57
  consola.info("Finished Code Snippet Generation");
57
58
  }
58
59
  function generateInterfaceSnippet(interfaceType, packageName) {
60
+ const identifier = withoutNamespace(interfaceType.apiName);
59
61
  const interfaceContext = {
60
- interfaceApiName: interfaceType.apiName,
62
+ interfaceApiName: identifier,
61
63
  packageName: packageName,
62
- objectOrInterfaceApiName: interfaceType.apiName,
64
+ objectOrInterfaceApiName: identifier,
63
65
  propertyNames: Object.keys(interfaceType.propertiesV3),
64
66
  interfaceName: interfaceType.displayMetadata.displayName
65
67
  };
66
68
  return getSnippets(interfaceSnippets, interfaceContext);
67
69
  }
68
70
  function generateObjectSnippet(objectType, packageName) {
69
- const objectContext = {
70
- objectType: objectType.apiName,
71
+ const identifier = withoutNamespace(objectType.apiName);
72
+ return getSnippets(objectSnippets, {
73
+ objectType: identifier,
71
74
  packageName: packageName,
72
- objectOrInterfaceApiName: objectType.apiName
73
- };
74
- return getSnippets(objectSnippets, objectContext);
75
+ objectOrInterfaceApiName: identifier
76
+ });
75
77
  }
76
78
  function generateActionSnippet(actionType, packageName) {
77
79
  const actionContext = {
78
- actionApiName: actionType.apiName,
80
+ actionApiName: actionIdentifier(actionType.apiName),
79
81
  packageName: packageName
80
82
  };
81
83
  return getSnippets(actionSnippets, actionContext);
82
84
  }
85
+
86
+ // Snippets must use the name the TypeScript SDK generator exports. It drops
87
+ // each hyphen and capitalizes the next character, but leaves the first letter
88
+ // and any underscores alone.
89
+ function actionIdentifier(apiName) {
90
+ return withoutNamespace(apiName).replace(/-./gu, segment => segment.charAt(1).toUpperCase());
91
+ }
83
92
  function getSnippets(snippetType, context) {
84
93
  const allSnippets = {};
85
94
  for (const templateName of Object.keys(snippetType).filter(key => isNaN(Number(key)))) {
@@ -1 +1 @@
1
- {"version":3,"file":"createCodeSnippets.js","names":["fs","path","TYPESCRIPT_OSDK_SNIPPETS","consola","Mustache","OntologyEntityTypeEnum","actionSnippets","interfaceSnippets","objectSnippets","snippetNameMapping","createCodeSnippets","ontology","packageName","outputDir","undefined","existsSync","mkdirSync","recursive","info","type","Object","values","object","snippet","OBJECT_TYPE","generateObjectSnippet","ACTION_TYPE","generateActionSnippet","INTERFACE_TYPE","generateInterfaceSnippet","writeFileSync","join","apiName","JSON","stringify","interfaceType","interfaceContext","interfaceApiName","objectOrInterfaceApiName","propertyNames","keys","propertiesV3","interfaceName","displayMetadata","displayName","getSnippets","objectType","objectContext","actionType","actionContext","actionApiName","snippetType","context","allSnippets","templateName","filter","key","isNaN","Number","versions","latestTemplate","slice","reverse","find","v","snippets","at","template","renderedTemplate","render","snippetName","get"],"sources":["createCodeSnippets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport { TYPESCRIPT_OSDK_SNIPPETS } from \"@osdk/typescript-sdk-docs\";\nimport { consola } from \"consola\";\nimport Mustache from \"mustache\";\n\nimport type { ActionType } from \"../action/ActionType.js\";\nimport type { OntologyDefinition } from \"../common/OntologyDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { InterfaceType } from \"../interface/InterfaceType.js\";\nimport type { ObjectType } from \"../object/ObjectType.js\";\nimport {\n actionSnippets,\n interfaceSnippets,\n objectSnippets,\n snippetNameMapping,\n} from \"./snippetTypes.js\";\n\nexport function createCodeSnippets(\n ontology: OntologyDefinition,\n packageName: string | undefined,\n outputDir: string | undefined,\n): void {\n if (outputDir === undefined) {\n outputDir = \"./code-snippets\";\n }\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n if (packageName === undefined) {\n packageName = \"\";\n }\n consola.info(\"Generating code snippets to \", outputDir);\n for (const type of Object.values(OntologyEntityTypeEnum)) {\n for (const object of Object.values(ontology[type])) {\n let snippet = {};\n switch (type) {\n case OntologyEntityTypeEnum.OBJECT_TYPE:\n snippet = generateObjectSnippet(object, packageName);\n break;\n case OntologyEntityTypeEnum.ACTION_TYPE:\n snippet = generateActionSnippet(object, packageName);\n break;\n case OntologyEntityTypeEnum.INTERFACE_TYPE:\n snippet = generateInterfaceSnippet(object, packageName);\n break;\n default:\n continue;\n }\n fs.writeFileSync(\n path.join(outputDir, object.apiName),\n JSON.stringify(snippet),\n );\n }\n }\n consola.info(\"Finished Code Snippet Generation\");\n}\n\nfunction generateInterfaceSnippet(\n interfaceType: InterfaceType,\n packageName: string,\n) {\n const interfaceContext = {\n interfaceApiName: interfaceType.apiName,\n packageName: packageName,\n objectOrInterfaceApiName: interfaceType.apiName,\n propertyNames: Object.keys(interfaceType.propertiesV3),\n interfaceName: interfaceType.displayMetadata.displayName,\n };\n\n return getSnippets(interfaceSnippets, interfaceContext);\n}\n\nfunction generateObjectSnippet(objectType: ObjectType, packageName: string) {\n const objectContext = {\n objectType: objectType.apiName,\n packageName: packageName,\n objectOrInterfaceApiName: objectType.apiName,\n };\n return getSnippets(objectSnippets, objectContext);\n}\n\nfunction generateActionSnippet(actionType: ActionType, packageName: string) {\n const actionContext = {\n actionApiName: actionType.apiName,\n packageName: packageName,\n };\n return getSnippets(actionSnippets, actionContext);\n}\n\nfunction getSnippets(\n snippetType:\n | typeof interfaceSnippets\n | typeof actionSnippets\n | typeof objectSnippets,\n context: {},\n) {\n const allSnippets = {};\n for (const templateName of Object.keys(snippetType).filter((key) =>\n isNaN(Number(key)),\n )) {\n const versions = Object.values(TYPESCRIPT_OSDK_SNIPPETS.versions);\n const latestTemplate =\n versions\n .slice()\n .reverse()\n .find((v) => v.snippets[templateName])\n ?.snippets[templateName].at(-1)?.template ?? \"\";\n const renderedTemplate = Mustache.render(latestTemplate, context);\n const snippetName = snippetNameMapping.get(templateName);\n\n (allSnippets as any)[\n snippetName !== undefined\n ? Mustache.render(snippetName, context)\n : templateName\n ] = renderedTemplate;\n }\n return allSnippets;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,IAAI;AACxB,OAAO,KAAKC,IAAI,MAAM,MAAM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AAK,CAACC,MAAM,CAACF,GAAG,CAAC,CACnB,CAAC,EAAE;IACD,MAAMG,QAAQ,GAAGvC,MAAM,CAACC,MAAM,CAACnB,wBAAwB,CAACyD,QAAQ,CAAC;IACjE,MAAMC,cAAc,GAClBD,QAAQ,CACLE,KAAK,CAAC,CAAC,CACPC,OAAO,CAAC,CAAC,CACTC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,QAAQ,CAACX,YAAY,CAAC,CAAC,EACpCW,QAAQ,CAACX,YAAY,CAAC,CAACY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAEC,QAAQ,IAAI,EAAE;IACnD,MAAMC,gBAAgB,GAAGhE,QAAQ,CAACiE,MAAM,CAACT,cAAc,EAAER,OAAO,CAAC;IACjE,MAAMkB,WAAW,GAAG7D,kBAAkB,CAAC8D,GAAG,CAACjB,YAAY,CAAC;IAEvDD,WAAW,CACViB,WAAW,KAAKxD,SAAS,GACrBV,QAAQ,CAACiE,MAAM,CAACC,WAAW,EAAElB,OAAO,CAAC,GACrCE,YAAY,CACjB,GAAGc,gBAAgB;EACtB;EACA,OAAOf,WAAW;AACpB","ignoreList":[]}
1
+ {"version":3,"file":"createCodeSnippets.js","names":["fs","path","TYPESCRIPT_OSDK_SNIPPETS","consola","Mustache","OntologyEntityTypeEnum","withoutNamespace","actionSnippets","interfaceSnippets","objectSnippets","snippetNameMapping","createCodeSnippets","ontology","packageName","outputDir","undefined","existsSync","mkdirSync","recursive","info","type","Object","values","object","snippet","OBJECT_TYPE","generateObjectSnippet","ACTION_TYPE","generateActionSnippet","INTERFACE_TYPE","generateInterfaceSnippet","writeFileSync","join","apiName","JSON","stringify","interfaceType","identifier","interfaceContext","interfaceApiName","objectOrInterfaceApiName","propertyNames","keys","propertiesV3","interfaceName","displayMetadata","displayName","getSnippets","objectType","actionType","actionContext","actionApiName","actionIdentifier","replace","segment","charAt","toUpperCase","snippetType","context","allSnippets","templateName","filter","key","isNaN","Number","versions","latestTemplate","slice","reverse","find","v","snippets","at","template","renderedTemplate","render","snippetName","get"],"sources":["createCodeSnippets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\nimport { TYPESCRIPT_OSDK_SNIPPETS } from \"@osdk/typescript-sdk-docs\";\nimport { consola } from \"consola\";\nimport Mustache from \"mustache\";\n\nimport type { ActionType } from \"../action/ActionType.js\";\nimport type { OntologyDefinition } from \"../common/OntologyDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport { withoutNamespace } from \"../defineOntology.js\";\nimport type { InterfaceType } from \"../interface/InterfaceType.js\";\nimport type { ObjectType } from \"../object/ObjectType.js\";\nimport {\n actionSnippets,\n interfaceSnippets,\n objectSnippets,\n snippetNameMapping,\n} from \"./snippetTypes.js\";\n\nexport function createCodeSnippets(\n ontology: OntologyDefinition,\n packageName: string | undefined,\n outputDir: string | undefined,\n): void {\n if (outputDir === undefined) {\n outputDir = \"./code-snippets\";\n }\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n if (packageName === undefined) {\n packageName = \"\";\n }\n consola.info(\"Generating code snippets to \", outputDir);\n for (const type of Object.values(OntologyEntityTypeEnum)) {\n for (const object of Object.values(ontology[type])) {\n let snippet = {};\n switch (type) {\n case OntologyEntityTypeEnum.OBJECT_TYPE:\n snippet = generateObjectSnippet(object, packageName);\n break;\n case OntologyEntityTypeEnum.ACTION_TYPE:\n snippet = generateActionSnippet(object, packageName);\n break;\n case OntologyEntityTypeEnum.INTERFACE_TYPE:\n snippet = generateInterfaceSnippet(object, packageName);\n break;\n default:\n continue;\n }\n fs.writeFileSync(\n path.join(outputDir, object.apiName),\n JSON.stringify(snippet),\n );\n }\n }\n consola.info(\"Finished Code Snippet Generation\");\n}\n\nfunction generateInterfaceSnippet(\n interfaceType: InterfaceType,\n packageName: string,\n) {\n const identifier = withoutNamespace(interfaceType.apiName);\n const interfaceContext = {\n interfaceApiName: identifier,\n packageName: packageName,\n objectOrInterfaceApiName: identifier,\n propertyNames: Object.keys(interfaceType.propertiesV3),\n interfaceName: interfaceType.displayMetadata.displayName,\n };\n\n return getSnippets(interfaceSnippets, interfaceContext);\n}\n\nfunction generateObjectSnippet(objectType: ObjectType, packageName: string) {\n const identifier = withoutNamespace(objectType.apiName);\n const objectContext = {\n objectType: identifier,\n packageName: packageName,\n objectOrInterfaceApiName: identifier,\n };\n return getSnippets(objectSnippets, objectContext);\n}\n\nfunction generateActionSnippet(actionType: ActionType, packageName: string) {\n const actionContext = {\n actionApiName: actionIdentifier(actionType.apiName),\n packageName: packageName,\n };\n return getSnippets(actionSnippets, actionContext);\n}\n\n// Snippets must use the name the TypeScript SDK generator exports. It drops\n// each hyphen and capitalizes the next character, but leaves the first letter\n// and any underscores alone.\nfunction actionIdentifier(apiName: string): string {\n return withoutNamespace(apiName).replace(/-./gu, (segment) =>\n segment.charAt(1).toUpperCase(),\n );\n}\n\nfunction getSnippets(\n snippetType:\n | typeof interfaceSnippets\n | typeof actionSnippets\n | typeof objectSnippets,\n context: {},\n) {\n const allSnippets = {};\n for (const templateName of Object.keys(snippetType).filter((key) =>\n isNaN(Number(key)),\n )) {\n const versions = Object.values(TYPESCRIPT_OSDK_SNIPPETS.versions);\n const latestTemplate =\n versions\n .slice()\n .reverse()\n .find((v) => v.snippets[templateName])\n ?.snippets[templateName].at(-1)?.template ?? \"\";\n const renderedTemplate = Mustache.render(latestTemplate, context);\n const snippetName = snippetNameMapping.get(templateName);\n\n (allSnippets as any)[\n snippetName !== undefined\n ? Mustache.render(snippetName, context)\n : templateName\n ] = renderedTemplate;\n }\n return allSnippets;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,EAAE,MAAM,IAAI;AACxB,OAAO,KAAKC,IAAI,MAAM,MAAM;AAE5B,SAASC,wBAAwB,QAAQ,2BAA2B;AACpE,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAOC,QAAQ,MAAM,UAAU;AAI/B,SAASC,sBAAsB,QAAQ,qCAAqC;AAC5E,SAASC,gBAAgB,QAAQ,sBAAsB;AAGvD,SACEC,cAAc,EACdC,iBAAiB,EACjBC,cAAc,EACdC,kBAAkB,QACb,mBAAmB;AAE1B,OAAO,SAASC,kBAAkBA,CAChCC,QAA4B,EAC5BC,WAA+B,EAC/BC,SAA6B,EACvB;EACN,IAAIA,SAAS,KAAKC,SAAS,EAAE;IAC3BD,SAAS,GAAG,iBAAiB;EAC/B;EACA,IAAI,CAACd,EAAE,CAACgB,UAAU,CAACF,SAAS,CAAC,EAAE;IAC7Bd,EAAE,CAACiB,SAAS,CAACH,SAAS,EAAE;MAAEI,SAAS,EAAE;IAAK,CAAC,CAAC;EAC9C;EACA,IAAIL,WAAW,KAAKE,SAAS,EAAE;IAC7BF,WAAW,GAAG,EAAE;EAClB;EACAV,OAAO,CAACgB,IAAI,CAAC,8BAA8B,EAAEL,SAAS,CAAC;EACvD,KAAK,MAAMM,IAAI,IAAIC,MAAM,CAACC,MAAM,CAACjB,sBAAsB,CAAC,EAAE;IACxD,KAAK,MAAMkB,MAAM,IAAIF,MAAM,CAACC,MAAM,CAACV,QAAQ,CAACQ,IAAI,CAAC,CAAC,EAAE;MAClD,IAAII,OAAO,GAAG,CAAC,CAAC;MAChB,QAAQJ,IAAI;QACV,KAAKf,sBAAsB,CAACoB,WAAW;UACrCD,OAAO,GAAGE,qBAAqB,CAACH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CACjB,GAAGc,gBAAgB;EACtB;EACA,OAAOf,WAAW;AACpB","ignoreList":[]}
@@ -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.90.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
30
+ const commandLineOpts = await yargs(hideBin(args)).version("0.90.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de" ?? "").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,qC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B,MAAM,GAAG,CAAC,EACnD;IACA,MAAM3D,EAAE,CAACyE,SAAS,CAChBxD,eAAe,CAACoB,gBAAgB,EAChCqC,IAAI,CAACC,SAAS,CAACN,UAAU,CAACS,UAAU,EAAE,IAAI,EAAE,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":[]}
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,KAAK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AChBxD,eAAe,CAACgB,MAAM,EACtByC,IAAI,CAACC,SAAS,CACZN,UAAU,EACV,CAACO,GAAG,EAAEC,KAAK,KAAMD,GAAG,KAAK,kBAAkB,GAAGX,SAAS,GAAGY,KAAM,EAChE,CACF,CACF,CAAC;EACD;EACA,IACER,UAAU,CAACS,UAAU,CAACA,UAAU,CAACnB,MAAM,GAAG,CAAC,IAC3CU,UAAU,CAACU,kBAAkB,CAACD,UAAU,CAACnB,MAAM,GAAG,CAAC,EACnD;IACA,MAAM3D,EAAE,CAACyE,SAAS,CAChBxD,eAAe,CAACoB,gBAAgB,EAChCqC,IAAI,CAACC,SAAS,CAACN,UAAU,CAACS,UAAU,EAAE,IAAI,EAAE,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":[]}
@@ -2554,30 +2554,35 @@ function createCodeSnippets(ontology, packageName, outputDir) {
2554
2554
  consola.consola.info("Finished Code Snippet Generation");
2555
2555
  }
2556
2556
  function generateInterfaceSnippet(interfaceType, packageName) {
2557
+ const identifier = withoutNamespace(interfaceType.apiName);
2557
2558
  const interfaceContext = {
2558
- interfaceApiName: interfaceType.apiName,
2559
+ interfaceApiName: identifier,
2559
2560
  packageName,
2560
- objectOrInterfaceApiName: interfaceType.apiName,
2561
+ objectOrInterfaceApiName: identifier,
2561
2562
  propertyNames: Object.keys(interfaceType.propertiesV3),
2562
2563
  interfaceName: interfaceType.displayMetadata.displayName
2563
2564
  };
2564
2565
  return getSnippets(interfaceSnippets, interfaceContext);
2565
2566
  }
2566
2567
  function generateObjectSnippet(objectType, packageName) {
2568
+ const identifier = withoutNamespace(objectType.apiName);
2567
2569
  const objectContext = {
2568
- objectType: objectType.apiName,
2570
+ objectType: identifier,
2569
2571
  packageName,
2570
- objectOrInterfaceApiName: objectType.apiName
2572
+ objectOrInterfaceApiName: identifier
2571
2573
  };
2572
2574
  return getSnippets(objectSnippets, objectContext);
2573
2575
  }
2574
2576
  function generateActionSnippet(actionType, packageName) {
2575
2577
  const actionContext = {
2576
- actionApiName: actionType.apiName,
2578
+ actionApiName: actionIdentifier(actionType.apiName),
2577
2579
  packageName
2578
2580
  };
2579
2581
  return getSnippets(actionSnippets, actionContext);
2580
2582
  }
2583
+ function actionIdentifier(apiName) {
2584
+ return withoutNamespace(apiName).replace(/-./gu, (segment) => segment.charAt(1).toUpperCase());
2585
+ }
2581
2586
  function getSnippets(snippetType, context) {
2582
2587
  const allSnippets = {};
2583
2588
  for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
@@ -6686,7 +6691,7 @@ async function readIfExists(path5) {
6686
6691
  var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/u;
6687
6692
  var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
6688
6693
  async function main(args = process.argv) {
6689
- const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.90.0").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
6694
+ const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.90.1-main-8aa522dafda38bf56948bcf5dcc07e46519e06de").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
6690
6695
  input: {
6691
6696
  alias: "i",
6692
6697
  describe: "Input file",