@osdk/maker 0.16.0-beta.8 → 0.16.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.
Files changed (117) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/build/browser/api/defineFunction.js +6 -5
  3. package/build/browser/api/defineFunction.js.map +1 -1
  4. package/build/browser/api/defineInterface.js +3 -0
  5. package/build/browser/api/defineInterface.js.map +1 -1
  6. package/build/browser/api/defineLink.js +3 -0
  7. package/build/browser/api/defineLink.js.map +1 -1
  8. package/build/browser/api/defineObject.js +9 -2
  9. package/build/browser/api/defineObject.js.map +1 -1
  10. package/build/browser/api/interface/InterfaceType.js.map +1 -1
  11. package/build/browser/api/links/LinkType.js.map +1 -1
  12. package/build/browser/api/object/ObjectType.js.map +1 -1
  13. package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
  14. package/build/browser/cli/main.js +4 -147
  15. package/build/browser/cli/main.js.map +1 -1
  16. package/build/browser/conversion/toMarketplace/convertInterface.js +2 -1
  17. package/build/browser/conversion/toMarketplace/convertInterface.js.map +1 -1
  18. package/build/browser/conversion/toMarketplace/convertLink.js +9 -4
  19. package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
  20. package/build/browser/util/ApiNameValidator.js +26 -0
  21. package/build/browser/util/ApiNameValidator.js.map +1 -0
  22. package/build/cjs/index.cjs +107 -218
  23. package/build/cjs/index.cjs.map +1 -1
  24. package/build/cjs/index.d.cts +5 -1
  25. package/build/esm/api/defineFunction.js +6 -5
  26. package/build/esm/api/defineFunction.js.map +1 -1
  27. package/build/esm/api/defineInterface.js +3 -0
  28. package/build/esm/api/defineInterface.js.map +1 -1
  29. package/build/esm/api/defineLink.js +3 -0
  30. package/build/esm/api/defineLink.js.map +1 -1
  31. package/build/esm/api/defineObject.js +9 -2
  32. package/build/esm/api/defineObject.js.map +1 -1
  33. package/build/esm/api/interface/InterfaceType.js.map +1 -1
  34. package/build/esm/api/links/LinkType.js.map +1 -1
  35. package/build/esm/api/object/ObjectType.js.map +1 -1
  36. package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
  37. package/build/esm/cli/main.js +4 -147
  38. package/build/esm/cli/main.js.map +1 -1
  39. package/build/esm/conversion/toMarketplace/convertInterface.js +2 -1
  40. package/build/esm/conversion/toMarketplace/convertInterface.js.map +1 -1
  41. package/build/esm/conversion/toMarketplace/convertLink.js +9 -4
  42. package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
  43. package/build/esm/util/ApiNameValidator.js +26 -0
  44. package/build/esm/util/ApiNameValidator.js.map +1 -0
  45. package/build/types/api/defineFunction.d.ts.map +1 -1
  46. package/build/types/api/defineInterface.d.ts.map +1 -1
  47. package/build/types/api/defineLink.d.ts.map +1 -1
  48. package/build/types/api/defineObject.d.ts.map +1 -1
  49. package/build/types/api/interface/InterfaceType.d.ts +1 -1
  50. package/build/types/api/interface/InterfaceType.d.ts.map +1 -1
  51. package/build/types/api/links/LinkType.d.ts +2 -0
  52. package/build/types/api/links/LinkType.d.ts.map +1 -1
  53. package/build/types/api/object/ObjectType.d.ts +1 -0
  54. package/build/types/api/object/ObjectType.d.ts.map +1 -1
  55. package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -0
  56. package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
  57. package/build/types/cli/main.d.ts.map +1 -1
  58. package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
  59. package/build/types/util/ApiNameValidator.d.ts +4 -0
  60. package/build/types/util/ApiNameValidator.d.ts.map +1 -0
  61. package/package.json +6 -7
  62. package/build/browser/api/test/actions.test.js +0 -14402
  63. package/build/browser/api/test/actions.test.js.map +0 -1
  64. package/build/browser/api/test/interfaces.test.js +0 -1189
  65. package/build/browser/api/test/interfaces.test.js.map +0 -1
  66. package/build/browser/api/test/links.test.js +0 -2019
  67. package/build/browser/api/test/links.test.js.map +0 -1
  68. package/build/browser/api/test/markingconstraint.test.js +0 -134
  69. package/build/browser/api/test/markingconstraint.test.js.map +0 -1
  70. package/build/browser/api/test/misc.test.js +0 -1315
  71. package/build/browser/api/test/misc.test.js.map +0 -1
  72. package/build/browser/api/test/objectStatus.test.js +0 -252
  73. package/build/browser/api/test/objectStatus.test.js.map +0 -1
  74. package/build/browser/api/test/objects.test.js +0 -4441
  75. package/build/browser/api/test/objects.test.js.map +0 -1
  76. package/build/browser/api/test/spt.test.js +0 -751
  77. package/build/browser/api/test/spt.test.js.map +0 -1
  78. package/build/browser/api/test/valueTypes.test.js +0 -307
  79. package/build/browser/api/test/valueTypes.test.js.map +0 -1
  80. package/build/cjs/defineFunction-7ORD7HD4.cjs +0 -72
  81. package/build/cjs/defineFunction-7ORD7HD4.cjs.map +0 -1
  82. package/build/esm/api/test/actions.test.js +0 -14402
  83. package/build/esm/api/test/actions.test.js.map +0 -1
  84. package/build/esm/api/test/interfaces.test.js +0 -1189
  85. package/build/esm/api/test/interfaces.test.js.map +0 -1
  86. package/build/esm/api/test/links.test.js +0 -2019
  87. package/build/esm/api/test/links.test.js.map +0 -1
  88. package/build/esm/api/test/markingconstraint.test.js +0 -134
  89. package/build/esm/api/test/markingconstraint.test.js.map +0 -1
  90. package/build/esm/api/test/misc.test.js +0 -1315
  91. package/build/esm/api/test/misc.test.js.map +0 -1
  92. package/build/esm/api/test/objectStatus.test.js +0 -252
  93. package/build/esm/api/test/objectStatus.test.js.map +0 -1
  94. package/build/esm/api/test/objects.test.js +0 -4441
  95. package/build/esm/api/test/objects.test.js.map +0 -1
  96. package/build/esm/api/test/spt.test.js +0 -751
  97. package/build/esm/api/test/spt.test.js.map +0 -1
  98. package/build/esm/api/test/valueTypes.test.js +0 -307
  99. package/build/esm/api/test/valueTypes.test.js.map +0 -1
  100. package/build/types/api/test/actions.test.d.ts +0 -1
  101. package/build/types/api/test/actions.test.d.ts.map +0 -1
  102. package/build/types/api/test/interfaces.test.d.ts +0 -1
  103. package/build/types/api/test/interfaces.test.d.ts.map +0 -1
  104. package/build/types/api/test/links.test.d.ts +0 -1
  105. package/build/types/api/test/links.test.d.ts.map +0 -1
  106. package/build/types/api/test/markingconstraint.test.d.ts +0 -1
  107. package/build/types/api/test/markingconstraint.test.d.ts.map +0 -1
  108. package/build/types/api/test/misc.test.d.ts +0 -1
  109. package/build/types/api/test/misc.test.d.ts.map +0 -1
  110. package/build/types/api/test/objectStatus.test.d.ts +0 -1
  111. package/build/types/api/test/objectStatus.test.d.ts.map +0 -1
  112. package/build/types/api/test/objects.test.d.ts +0 -1
  113. package/build/types/api/test/objects.test.d.ts.map +0 -1
  114. package/build/types/api/test/spt.test.d.ts +0 -1
  115. package/build/types/api/test/spt.test.d.ts.map +0 -1
  116. package/build/types/api/test/valueTypes.test.d.ts +0 -1
  117. package/build/types/api/test/valueTypes.test.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectType.js","names":[],"sources":["ObjectType.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 { OntologyIrObjectType, Visibility } from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyType } from \"./ObjectPropertyType.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectType =\n & OntologyEntityBase\n & RequiredFields<\n Partial<ObjectTypeInner>,\n | \"apiName\"\n | \"primaryKeyPropertyApiName\"\n | \"displayName\"\n | \"pluralDisplayName\"\n | \"titlePropertyApiName\"\n >\n & {\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n __type: OntologyEntityTypeEnum.OBJECT_TYPE;\n };\n\nexport interface ObjectTypeInner extends\n Omit<\n OntologyIrObjectType,\n | \"titlePropertyTypeRid\"\n | \"propertyTypes\"\n | \"allImplementsInterfaces\"\n | \"implementsInterfaces2\"\n | \"displayMetadata\"\n | \"primaryKeys\"\n | \"status\"\n >\n{\n primaryKeyPropertyApiName: string;\n properties: Array<ObjectPropertyType>;\n titlePropertyApiName: string;\n implementsInterfaces: Array<InterfaceImplementation>;\n description: string | undefined;\n icon: { locator: BlueprintIcon; color: string } | undefined;\n displayName: string;\n pluralDisplayName: string;\n visibility: Visibility;\n editsEnabled: boolean;\n status?: ObjectTypeStatus;\n aliases?: Array<string>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectType.js","names":[],"sources":["ObjectType.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 { OntologyIrObjectType, Visibility } from \"@osdk/client.unstable\";\nimport type { RequiredFields } from \"../../util/RequiredFields.js\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { OntologyEntityBase } from \"../common/OntologyEntityBase.js\";\nimport type { OntologyEntityTypeEnum } from \"../common/OntologyEntityTypeEnum.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyType } from \"./ObjectPropertyType.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectType =\n & OntologyEntityBase\n & RequiredFields<\n Partial<ObjectTypeInner>,\n | \"apiName\"\n | \"primaryKeyPropertyApiName\"\n | \"displayName\"\n | \"pluralDisplayName\"\n | \"titlePropertyApiName\"\n >\n & {\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n includeEmptyBackingDatasource?: boolean;\n __type: OntologyEntityTypeEnum.OBJECT_TYPE;\n };\n\nexport interface ObjectTypeInner extends\n Omit<\n OntologyIrObjectType,\n | \"titlePropertyTypeRid\"\n | \"propertyTypes\"\n | \"allImplementsInterfaces\"\n | \"implementsInterfaces2\"\n | \"displayMetadata\"\n | \"primaryKeys\"\n | \"status\"\n >\n{\n primaryKeyPropertyApiName: string;\n properties: Array<ObjectPropertyType>;\n titlePropertyApiName: string;\n implementsInterfaces: Array<InterfaceImplementation>;\n description: string | undefined;\n icon: { locator: BlueprintIcon; color: string } | undefined;\n displayName: string;\n pluralDisplayName: string;\n visibility: Visibility;\n editsEnabled: boolean;\n status?: ObjectTypeStatus;\n aliases?: Array<string>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTypeDefinition.js","names":[],"sources":["ObjectTypeDefinition.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 { Visibility } from \"@osdk/client.unstable\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectTypeDefinition = {\n apiName: string;\n primaryKeyPropertyApiName: string;\n displayName: string;\n pluralDisplayName: string;\n titlePropertyApiName: string;\n properties?: { [key: string]: ObjectPropertyTypeUserDefinition };\n implementsInterfaces?: Array<InterfaceImplementation>;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n visibility?: Visibility;\n editsEnabled?: boolean;\n status?: ObjectTypeStatus;\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n aliases?: Array<string>;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectTypeDefinition.js","names":[],"sources":["ObjectTypeDefinition.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 { Visibility } from \"@osdk/client.unstable\";\nimport type { BlueprintIcon } from \"../common/BlueprintIcons.js\";\nimport type { InterfaceImplementation } from \"./InterfaceImplementation.js\";\nimport type { ObjectPropertyTypeUserDefinition } from \"./ObjectPropertyTypeUserDefinition.js\";\nimport type { ObjectTypeDatasourceDefinition } from \"./ObjectTypeDatasourceDefinition.js\";\nimport type { ObjectTypeStatus } from \"./ObjectTypeStatus.js\";\n\nexport type ObjectTypeDefinition = {\n apiName: string;\n primaryKeyPropertyApiName: string;\n displayName: string;\n pluralDisplayName: string;\n titlePropertyApiName: string;\n properties?: { [key: string]: ObjectPropertyTypeUserDefinition };\n implementsInterfaces?: Array<InterfaceImplementation>;\n description?: string;\n icon?: { locator: BlueprintIcon; color: string };\n visibility?: Visibility;\n editsEnabled?: boolean;\n status?: ObjectTypeStatus;\n datasources?: Array<ObjectTypeDatasourceDefinition>;\n aliases?: Array<string>;\n includeEmptyBackingDatasource?: boolean;\n};\n"],"mappings":"","ignoreList":[]}
@@ -14,33 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { OntologyIrToFullMetadataConverter } from "@osdk/generator-converters.ontologyir";
18
17
  import { consola } from "consola";
19
- import { execa } from "execa";
20
- import { createJiti } from "jiti";
21
18
  import * as fs from "node:fs/promises";
22
19
  import * as path from "node:path";
20
+ import { pathToFileURL } from "node:url";
23
21
  import invariant from "tiny-invariant";
24
22
  import yargs from "yargs";
25
23
  import { hideBin } from "yargs/helpers";
26
24
  import { defineOntology } from "../api/defineOntology.js";
27
-
28
- // Dynamic imports for optional function discovery dependencies
29
- let generateFunctionsIr;
30
- async function loadFunctionDiscoveryDeps() {
31
- try {
32
- const defineFunctionModule = await import("../api/defineFunction.js");
33
- generateFunctionsIr = defineFunctionModule.generateFunctionsIr;
34
- return true;
35
- } catch (e) {
36
- consola.warn("Failed to load function discovery dependencies:", e instanceof Error ? e.message : e);
37
- return false;
38
- }
39
- }
40
25
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
41
26
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
42
27
  export default async function main(args = process.argv) {
43
- const commandLineOpts = await yargs(hideBin(args)).version("0.16.0-beta.8" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
28
+ const commandLineOpts = await yargs(hideBin(args)).version("0.16.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
44
29
  input: {
45
30
  alias: "i",
46
31
  describe: "Input file",
@@ -102,43 +87,7 @@ export default async function main(args = process.argv) {
102
87
  },
103
88
  randomnessKey: {
104
89
  describe: "Value used to assure uniqueness of entities",
105
- type: "string",
106
- coerce: path.resolve
107
- },
108
- generateFunctionsOsdk: {
109
- describe: "Output folder for generated OSDK for functions",
110
- type: "string",
111
- coerce: path.resolve
112
- },
113
- functionsRootDir: {
114
- describe: "Root folder containing function definitions",
115
- type: "string",
116
- coerce: path.resolve
117
- },
118
- functionsOutput: {
119
- describe: "Output folder for function IR",
120
- type: "string",
121
- coerce: path.resolve
122
- },
123
- configPath: {
124
- describe: "Path to the TypeScript config file",
125
- type: "string",
126
- coerce: path.resolve
127
- },
128
- pythonFunctionsDir: {
129
- describe: "Path to Python functions source directory (enables Python function discovery)",
130
- type: "string",
131
- coerce: path.resolve
132
- },
133
- pythonBinary: {
134
- describe: "Path to Python binary (required when using --pythonFunctionsDir)",
135
- type: "string",
136
- coerce: path.resolve
137
- },
138
- pythonRootProjectDir: {
139
- describe: "Root project directory for Python functions (defaults to parent of pythonFunctionsDir)",
140
- type: "string",
141
- coerce: path.resolve
90
+ type: "string"
142
91
  }
143
92
  }).parseAsync();
144
93
  let apiNamespace = "";
@@ -161,101 +110,9 @@ export default async function main(args = process.argv) {
161
110
  if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
162
111
  await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
163
112
  }
164
- if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {
165
- consola.error("--pythonBinary is required when using --pythonFunctionsDir");
166
- return;
167
- }
168
-
169
- // Function discovery feature (requires optional dependencies)
170
- if (commandLineOpts.functionsOutput !== undefined && commandLineOpts.functionsRootDir !== undefined) {
171
- const hasFunctionDeps = await loadFunctionDiscoveryDeps();
172
- if (!hasFunctionDeps || !generateFunctionsIr) {
173
- consola.error("Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.");
174
- return;
175
- }
176
- consola.info(`Loading function IR`);
177
- const functionsIr = await generateFunctionsIr(commandLineOpts.functionsRootDir, commandLineOpts.configPath, createEntityMappings(ontologyIr));
178
- await fs.writeFile(commandLineOpts.functionsOutput, JSON.stringify(functionsIr, null, 2));
179
- return;
180
- }
181
- if (commandLineOpts.generateFunctionsOsdk !== undefined) {
182
- // Generate full ontology metadata for functions OSDK
183
- const fullMetadata = OntologyIrToFullMetadataConverter.getFullMetadataFromIr(ontologyIr.ontology);
184
-
185
- // Discover Python functions and merge into ontology metadata
186
- if (commandLineOpts.pythonFunctionsDir) {
187
- const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir ?? path.dirname(commandLineOpts.pythonFunctionsDir);
188
- const queryTypes = await OntologyIrToFullMetadataConverter.getOsdkQueryTypes(commandLineOpts.pythonBinary, undefined, undefined, commandLineOpts.pythonFunctionsDir, effectivePythonRootDir);
189
- const functionNames = Object.keys(queryTypes);
190
- if (functionNames.length > 0) {
191
- fullMetadata.queryTypes = queryTypes;
192
- consola.info(`Discovered ${functionNames.length} Python function(s): ${functionNames.join(", ")}`);
193
- } else {
194
- consola.info("No Python functions discovered.");
195
- }
196
- }
197
- consola.info(`Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`);
198
- await fs.writeFile(path.join(commandLineOpts.generateFunctionsOsdk, ".ontology.json"), JSON.stringify(fullMetadata, null, 2));
199
- await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);
200
- }
201
113
  }
202
114
  async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
203
- const q = await defineOntology(apiNamespace, async () => {
204
- const jiti = createJiti(import.meta.filename, {
205
- moduleCache: true,
206
- debug: false,
207
- importMeta: import.meta
208
- });
209
- await jiti.import(input);
210
- }, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
115
+ const q = await defineOntology(apiNamespace, async () => await import(pathToFileURL(input).href), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
211
116
  return q;
212
117
  }
213
- async function fullMetadataToOsdk(workDir) {
214
- // First create a clean temporary directory to generate the SDK into
215
- const functionOsdkDir = path.join(workDir, "generated");
216
- await fs.rm(functionOsdkDir, {
217
- recursive: true,
218
- force: true
219
- });
220
- await fs.mkdir(functionOsdkDir, {
221
- recursive: true
222
- });
223
- try {
224
- // Generate the source code for the osdk
225
- await execa("pnpm", ["exec", "osdk", "unstable", "typescript", "generate", "--outDir", functionOsdkDir, "--ontologyPath", path.join(workDir, ".ontology.json"), "--beta", "true", "--packageType", "module", "--version", "dev"]);
226
- } catch (error) {
227
- await fs.rm(functionOsdkDir, {
228
- recursive: true,
229
- force: true
230
- });
231
- throw error;
232
- }
233
- }
234
- function createEntityMappings(ontologyIr) {
235
- const entityMappings = {
236
- ontologies: {}
237
- };
238
- const ontologyRid = "ontology";
239
- entityMappings.ontologies[ontologyRid] = {
240
- objectTypes: {},
241
- interfaceTypes: {}
242
- };
243
- for (const [apiName, blockData] of Object.entries(ontologyIr.ontology.objectTypes)) {
244
- const propertyTypesMap = {};
245
- Object.keys(blockData.objectType.propertyTypes).forEach(propertyName => {
246
- propertyTypesMap[propertyName] = {
247
- propertyId: propertyName
248
- };
249
- });
250
- entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {
251
- objectTypeId: apiName,
252
- primaryKey: {
253
- propertyId: blockData.objectType.primaryKeys[0]
254
- },
255
- propertyTypes: propertyTypesMap,
256
- linkTypes: {}
257
- };
258
- }
259
- return entityMappings;
260
- }
261
118
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["OntologyIrToFullMetadataConverter","consola","execa","createJiti","fs","path","invariant","yargs","hideBin","defineOntology","generateFunctionsIr","loadFunctionDiscoveryDeps","defineFunctionModule","e","warn","Error","message","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","generateFunctionsOsdk","functionsRootDir","functionsOutput","configPath","pythonFunctionsDir","pythonBinary","pythonRootProjectDir","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","error","hasFunctionDeps","functionsIr","createEntityMappings","fullMetadata","getFullMetadataFromIr","ontology","effectivePythonRootDir","dirname","queryTypes","getOsdkQueryTypes","functionNames","Object","keys","join","fullMetadataToOsdk","dependencyFile","snippetPackageName","q","jiti","import","meta","filename","moduleCache","debug","importMeta","workDir","functionOsdkDir","rm","recursive","force","mkdir","entityMappings","ontologies","ontologyRid","objectTypes","interfaceTypes","apiName","blockData","entries","propertyTypesMap","objectType","propertyTypes","forEach","propertyName","propertyId","objectTypeId","primaryKey","primaryKeys","linkTypes"],"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 type { OntologyIr } from \"@osdk/client.unstable\";\nimport { OntologyIrToFullMetadataConverter } from \"@osdk/generator-converters.ontologyir\";\nimport { consola } from \"consola\";\nimport { execa } from \"execa\";\nimport { createJiti } from \"jiti\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport type { IEntityMetadataMapping } from \"../api/defineFunction.js\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\n// Dynamic imports for optional function discovery dependencies\nlet generateFunctionsIr:\n | ((\n rootDir: string,\n configPath: string | undefined,\n entityMappings: IEntityMetadataMapping,\n ) => Promise<unknown>)\n | undefined;\n\nasync function loadFunctionDiscoveryDeps(): Promise<boolean> {\n try {\n const defineFunctionModule = await import(\"../api/defineFunction.js\");\n generateFunctionsIr = defineFunctionModule.generateFunctionsIr;\n return true;\n } catch (e: unknown) {\n consola.warn(\n \"Failed to load function discovery dependencies:\",\n e instanceof Error ? e.message : e,\n );\n return false;\n }\n}\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\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 generateFunctionsOsdk?: string;\n functionsRootDir?: string;\n functionsOutput?: string;\n configPath?: string;\n pythonFunctionsDir?: string;\n pythonBinary?: string;\n pythonRootProjectDir?: string;\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 coerce: path.resolve,\n },\n generateFunctionsOsdk: {\n describe: \"Output folder for generated OSDK for functions\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsRootDir: {\n describe: \"Root folder containing function definitions\",\n type: \"string\",\n coerce: path.resolve,\n },\n functionsOutput: {\n describe: \"Output folder for function IR\",\n type: \"string\",\n coerce: path.resolve,\n },\n configPath: {\n describe: \"Path to the TypeScript config file\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonFunctionsDir: {\n describe:\n \"Path to Python functions source directory (enables Python function discovery)\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonBinary: {\n describe:\n \"Path to Python binary (required when using --pythonFunctionsDir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n pythonRootProjectDir: {\n describe:\n \"Root project directory for Python functions (defaults to parent of pythonFunctionsDir)\",\n type: \"string\",\n coerce: path.resolve,\n },\n })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (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\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 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 );\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\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(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\n\n if (commandLineOpts.pythonFunctionsDir && !commandLineOpts.pythonBinary) {\n consola.error(\n \"--pythonBinary is required when using --pythonFunctionsDir\",\n );\n return;\n }\n\n // Function discovery feature (requires optional dependencies)\n if (\n commandLineOpts.functionsOutput !== undefined\n && commandLineOpts.functionsRootDir !== undefined\n ) {\n const hasFunctionDeps = await loadFunctionDiscoveryDeps();\n if (!hasFunctionDeps || !generateFunctionsIr) {\n consola.error(\n \"Function discovery requires optional dependencies. Install @foundry/functions-typescript-* packages.\",\n );\n return;\n }\n consola.info(`Loading function IR`);\n const functionsIr = await generateFunctionsIr(\n commandLineOpts.functionsRootDir,\n commandLineOpts.configPath,\n createEntityMappings(ontologyIr),\n );\n await fs.writeFile(\n commandLineOpts.functionsOutput,\n JSON.stringify(functionsIr, null, 2),\n );\n return;\n }\n\n if (commandLineOpts.generateFunctionsOsdk !== undefined) {\n // Generate full ontology metadata for functions OSDK\n const fullMetadata = OntologyIrToFullMetadataConverter\n .getFullMetadataFromIr(ontologyIr.ontology);\n\n // Discover Python functions and merge into ontology metadata\n if (commandLineOpts.pythonFunctionsDir) {\n const effectivePythonRootDir = commandLineOpts.pythonRootProjectDir\n ?? path.dirname(commandLineOpts.pythonFunctionsDir);\n\n const queryTypes = await OntologyIrToFullMetadataConverter\n .getOsdkQueryTypes(\n commandLineOpts.pythonBinary,\n undefined,\n undefined,\n commandLineOpts.pythonFunctionsDir,\n effectivePythonRootDir,\n );\n\n const functionNames = Object.keys(queryTypes);\n if (functionNames.length > 0) {\n fullMetadata.queryTypes = queryTypes;\n consola.info(\n `Discovered ${functionNames.length} Python function(s): ${\n functionNames.join(\", \")\n }`,\n );\n } else {\n consola.info(\"No Python functions discovered.\");\n }\n }\n\n consola.info(\n `Saving full ontology metadata to ${commandLineOpts.generateFunctionsOsdk}`,\n );\n\n await fs.writeFile(\n path.join(commandLineOpts.generateFunctionsOsdk, \".ontology.json\"),\n JSON.stringify(fullMetadata, null, 2),\n );\n\n await fullMetadataToOsdk(commandLineOpts.generateFunctionsOsdk);\n }\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,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => {\n const jiti = createJiti(import.meta.filename, {\n moduleCache: true,\n debug: false,\n importMeta: import.meta,\n });\n await jiti.import(input);\n },\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n\nasync function fullMetadataToOsdk(\n workDir: string,\n): Promise<void> {\n // First create a clean temporary directory to generate the SDK into\n const functionOsdkDir = path.join(\n workDir,\n \"generated\",\n );\n await fs.rm(functionOsdkDir, { recursive: true, force: true });\n await fs.mkdir(functionOsdkDir, { recursive: true });\n\n try {\n // Generate the source code for the osdk\n await execa(\"pnpm\", [\n \"exec\",\n \"osdk\",\n \"unstable\",\n \"typescript\",\n \"generate\",\n \"--outDir\",\n functionOsdkDir,\n \"--ontologyPath\",\n path.join(workDir, \".ontology.json\"),\n \"--beta\",\n \"true\",\n \"--packageType\",\n \"module\",\n \"--version\",\n \"dev\",\n ]);\n } catch (error) {\n await fs.rm(functionOsdkDir, { recursive: true, force: true });\n throw error;\n }\n}\n\nfunction createEntityMappings(ontologyIr: OntologyIr): IEntityMetadataMapping {\n const entityMappings: IEntityMetadataMapping = {\n ontologies: {},\n };\n\n const ontologyRid = \"ontology\";\n entityMappings.ontologies[ontologyRid] = {\n objectTypes: {},\n interfaceTypes: {},\n };\n\n for (\n const [apiName, blockData] of Object.entries(\n ontologyIr.ontology.objectTypes,\n )\n ) {\n const propertyTypesMap: Record<string, { propertyId: string }> = {};\n\n Object.keys(blockData.objectType.propertyTypes).forEach((propertyName) => {\n propertyTypesMap[propertyName] = { propertyId: propertyName };\n });\n\n entityMappings.ontologies[ontologyRid].objectTypes[apiName] = {\n objectTypeId: apiName,\n primaryKey: {\n propertyId: blockData.objectType.primaryKeys[0],\n },\n propertyTypes: propertyTypesMap,\n linkTypes: {},\n };\n }\n\n return entityMappings;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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A,CAACV,UAAsB,EAA0B;EAC5E,MAAMuC,cAAsC,GAAG;IAC7CC,UAAU,EAAE,CAAC;EACf,CAAC;EAED,MAAMC,WAAW,GAAG,UAAU;EAC9BF,cAAc,CAACC,UAAU,CAACC,WAAW,CAAC,GAAG;IACvCC,WAAW,EAAE,CAAC,CAAC;IACfC,cAAc,EAAE,CAAC;EACnB,CAAC;EAED,KACE,MAAM,CAACC,OAAO,EAAEC,SAAS,CAAC,IAAI1B,MAAM,CAAC2B,OAAO,CAC1C9C,UAAU,CAACa,QAAQ,CAAC6B,WACtB,CAAC,EACD;IACA,MAAMK,gBAAwD,GAAG,CAAC,CAAC;IAEnE5B,MAAM,CAACC,IAAI,CAACyB,SAAS,CAACG,UAAU,CAACC,aAAa,CAAC,CAACC,OAAO,CAAEC,YAAY,IAAK;MACxEJ,gBAAgB,CAACI,YAAY,CAAC,GAAG;QAAEC,UAAU,EAAED;MAAa,CAAC;IAC/D,CAAC,CAAC;IAEFZ,cAAc,CAACC,UAAU,CAACC,WAAW,CAAC,CAACC,WAAW,CAACE,OAAO,CAAC,GAAG;MAC5DS,YAAY,EAAET,OAAO;MACrBU,UAAU,EAAE;QACVF,UAAU,EAAEP,SAAS,CAACG,UAAU,CAACO,WAAW,CAAC,CAAC;MAChD,CAAC;MACDN,aAAa,EAAEF,gBAAgB;MAC/BS,SAAS,EAAE,CAAC;IACd,CAAC;EACH;EAEA,OAAOjB,cAAc;AACvB","ignoreList":[]}
1
+ {"version":3,"file":"main.js","names":["consola","fs","path","pathToFileURL","invariant","yargs","hideBin","defineOntology","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","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","snippetPackageName","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 { consola } from \"consola\";\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport invariant from \"tiny-invariant\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\nconst uuidRegex =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\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 } = 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 })\n .parseAsync();\n let apiNamespace = \"\";\n if (commandLineOpts.apiNamespace.length !== 0) {\n apiNamespace = (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 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 );\n\n consola.info(`Saving ontology to ${commandLineOpts.output}`);\n await fs.writeFile(\n commandLineOpts.output,\n JSON.stringify(\n ontologyIr,\n null,\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(\n ontologyIr.valueTypes,\n null,\n 2,\n ),\n );\n }\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,\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 );\n return q;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,SAAS;AACjC,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,iBAAiB,GAAG,+BAA+B;AACzD,MAAMC,SAAS,GACb,gEAAgE;AAElE,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eAYL,GAAG,MAAMT,KAAK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MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAAC5B,aAAa,CAACoB,KAAK,CAAC,CAACmC,IAAI,CAAC,EACnDzB,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
@@ -41,7 +41,8 @@ export function convertInterface(interfaceType) {
41
41
  extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),
42
42
  // these are omitted from our internal types but we need to re-add them for the final json
43
43
  properties: [],
44
- propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName)))
44
+ propertiesV3: Object.fromEntries(Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) => convertInterfaceProperty(prop, apiName))),
45
+ extendsInterfacesMetadata: interfaceType.extendsInterfaces.map(i => convertInterface(i))
45
46
  };
46
47
  }
47
48
  //# sourceMappingURL=convertInterface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertInterface.js","names":["convertInterfaceProperty","convertSpt","convertInterface","interfaceType","__type","other","propertiesV2","Object","fromEntries","values","map","spt","sharedPropertyType","apiName","required","displayMetadata","displayName","description","icon","type","blueprint","color","locator","extendsInterfaces","i","properties","propertiesV3","entries","prop"],"sources":["convertInterface.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 { OntologyIrMarketplaceInterfaceType } from \"@osdk/client.unstable\";\nimport type { InterfaceType } from \"../../api/interface/InterfaceType.js\";\nimport { convertInterfaceProperty } from \"./convertInterfacePropertyType.js\";\nimport { convertSpt } from \"./convertSpt.js\";\n\nexport function convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrMarketplaceInterfaceType {\n const { __type, ...other } = interfaceType;\n return {\n ...other,\n propertiesV2: Object.fromEntries(\n Object.values(interfaceType.propertiesV2)\n .map((\n spt,\n ) => [spt.sharedPropertyType.apiName, {\n required: spt.required,\n sharedPropertyType: convertSpt(spt.sharedPropertyType),\n }]),\n ),\n displayMetadata: {\n displayName: interfaceType.displayMetadata.displayName,\n description: interfaceType.displayMetadata.description,\n icon: interfaceType.displayMetadata.icon ?? {\n type: \"blueprint\",\n blueprint: { color: \"#4C90F0\", locator: \"layout-hierarchy\" },\n },\n },\n extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),\n // these are omitted from our internal types but we need to re-add them for the final json\n properties: [],\n propertiesV3: Object.fromEntries(\n Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) =>\n convertInterfaceProperty(prop, apiName)\n ),\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,SAASC,gBAAgBA,CAC9BC,aAA4B,EACQ;EACpC,MAAM;IAAEC,MAAM;IAAE,GAAGC;EAAM,CAAC,GAAGF,aAAa;EAC1C,OAAO;IACL,GAAGE,KAAK;IACRC,YAAY,EAAEC,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,MAAM,CAACN,aAAa,CAACG,YAAY,CAAC,CACtCI,GAAG,CACFC,GAAG,IACA,CAACA,GAAG,CAACC,kBAAkB,CAACC,OAAO,EAAE;MACpCC,QAAQ,EAAEH,GAAG,CAACG,QAAQ;MACtBF,kBAAkB,EAAEX,UAAU,CAACU,GAAG,CAACC,kBAAkB;IACvD,CAAC,CAAC,CACN,CAAC;IACDG,eAAe,EAAE;MACfC,WAAW,EAAEb,aAAa,CAACY,eAAe,CAACC,WAAW;MACtDC,WAAW,EAAEd,aAAa,CAACY,eAAe,CAACE,WAAW;MACtDC,IAAI,EAAEf,aAAa,CAACY,eAAe,CAACG,IAAI,IAAI;QAC1CC,IAAI,EAAE,WAAW;QACjBC,SAAS,EAAE;UAAEC,KAAK,EAAE,SAAS;UAAEC,OAAO,EAAE;QAAmB;MAC7D;IACF,CAAC;IACDC,iBAAiB,EAAEpB,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAAIA,CAAC,CAACX,OAAO,CAAC;IACtE;IACAY,UAAU,EAAE,EAAE;IACdC,YAAY,EAAEnB,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACoB,OAAO,CAACxB,aAAa,CAACuB,YAAY,CAAC,CAAChB,GAAG,CAAC,CAAC,CAACG,OAAO,EAAEe,IAAI,CAAC,KAC7D5B,wBAAwB,CAAC4B,IAAI,EAAEf,OAAO,CACxC,CACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"convertInterface.js","names":["convertInterfaceProperty","convertSpt","convertInterface","interfaceType","__type","other","propertiesV2","Object","fromEntries","values","map","spt","sharedPropertyType","apiName","required","displayMetadata","displayName","description","icon","type","blueprint","color","locator","extendsInterfaces","i","properties","propertiesV3","entries","prop","extendsInterfacesMetadata"],"sources":["convertInterface.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 { OntologyIrMarketplaceInterfaceType } from \"@osdk/client.unstable\";\nimport type { InterfaceType } from \"../../api/interface/InterfaceType.js\";\nimport { convertInterfaceProperty } from \"./convertInterfacePropertyType.js\";\nimport { convertSpt } from \"./convertSpt.js\";\n\nexport function convertInterface(\n interfaceType: InterfaceType,\n): OntologyIrMarketplaceInterfaceType {\n const { __type, ...other } = interfaceType;\n return {\n ...other,\n propertiesV2: Object.fromEntries(\n Object.values(interfaceType.propertiesV2)\n .map((\n spt,\n ) => [spt.sharedPropertyType.apiName, {\n required: spt.required,\n sharedPropertyType: convertSpt(spt.sharedPropertyType),\n }]),\n ),\n displayMetadata: {\n displayName: interfaceType.displayMetadata.displayName,\n description: interfaceType.displayMetadata.description,\n icon: interfaceType.displayMetadata.icon ?? {\n type: \"blueprint\",\n blueprint: { color: \"#4C90F0\", locator: \"layout-hierarchy\" },\n },\n },\n extendsInterfaces: interfaceType.extendsInterfaces.map(i => i.apiName),\n // these are omitted from our internal types but we need to re-add them for the final json\n properties: [],\n propertiesV3: Object.fromEntries(\n Object.entries(interfaceType.propertiesV3).map(([apiName, prop]) =>\n convertInterfaceProperty(prop, apiName)\n ),\n ),\n extendsInterfacesMetadata: interfaceType.extendsInterfaces.map(i =>\n convertInterface(i)\n ),\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,wBAAwB,QAAQ,mCAAmC;AAC5E,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,SAASC,gBAAgBA,CAC9BC,aAA4B,EACQ;EACpC,MAAM;IAAEC,MAAM;IAAE,GAAGC;EAAM,CAAC,GAAGF,aAAa;EAC1C,OAAO;IACL,GAAGE,KAAK;IACRC,YAAY,EAAEC,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACE,MAAM,CAACN,aAAa,CAACG,YAAY,CAAC,CACtCI,GAAG,CACFC,GAAG,IACA,CAACA,GAAG,CAACC,kBAAkB,CAACC,OAAO,EAAE;MACpCC,QAAQ,EAAEH,GAAG,CAACG,QAAQ;MACtBF,kBAAkB,EAAEX,UAAU,CAACU,GAAG,CAACC,kBAAkB;IACvD,CAAC,CAAC,CACN,CAAC;IACDG,eAAe,EAAE;MACfC,WAAW,EAAEb,aAAa,CAACY,eAAe,CAACC,WAAW;MACtDC,WAAW,EAAEd,aAAa,CAACY,eAAe,CAACE,WAAW;MACtDC,IAAI,EAAEf,aAAa,CAACY,eAAe,CAACG,IAAI,IAAI;QAC1CC,IAAI,EAAE,WAAW;QACjBC,SAAS,EAAE;UAAEC,KAAK,EAAE,SAAS;UAAEC,OAAO,EAAE;QAAmB;MAC7D;IACF,CAAC;IACDC,iBAAiB,EAAEpB,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAAIA,CAAC,CAACX,OAAO,CAAC;IACtE;IACAY,UAAU,EAAE,EAAE;IACdC,YAAY,EAAEnB,MAAM,CAACC,WAAW,CAC9BD,MAAM,CAACoB,OAAO,CAACxB,aAAa,CAACuB,YAAY,CAAC,CAAChB,GAAG,CAAC,CAAC,CAACG,OAAO,EAAEe,IAAI,CAAC,KAC7D5B,wBAAwB,CAAC4B,IAAI,EAAEf,OAAO,CACxC,CACF,CAAC;IACDgB,yBAAyB,EAAE1B,aAAa,CAACoB,iBAAiB,CAACb,GAAG,CAACc,CAAC,IAC9DtB,gBAAgB,CAACsB,CAAC,CACpB;EACF,CAAC;AACH","ignoreList":[]}
@@ -16,7 +16,7 @@
16
16
 
17
17
  import invariant from "tiny-invariant";
18
18
  import { OntologyEntityTypeEnum } from "../../api/common/OntologyEntityTypeEnum.js";
19
- import { cleanAndValidateLinkTypeId, ontologyDefinition } from "../../api/defineOntology.js";
19
+ import { cleanAndValidateLinkTypeId, importedTypes, ontologyDefinition } from "../../api/defineOntology.js";
20
20
  import { convertCardinality } from "./convertCardinality.js";
21
21
  export function convertLink(linkType) {
22
22
  validateLink(linkType);
@@ -81,6 +81,11 @@ export function convertLink(linkType) {
81
81
  apiName: toManyObjectApiName,
82
82
  object: toManyObject
83
83
  } = getObject(linkType.toMany.object);
84
+ const columnA = manyObject.primaryKeyPropertyApiName;
85
+ const columnB = toManyObject.primaryKeyPropertyApiName;
86
+ const hasCollision = columnA === columnB;
87
+ const resolvedColumnA = hasCollision ? `${columnA}_from` : columnA;
88
+ const resolvedColumnB = hasCollision ? `${columnB}_to` : columnB;
84
89
  definition = {
85
90
  type: "manyToMany",
86
91
  manyToMany: {
@@ -123,14 +128,14 @@ export function convertLink(linkType) {
123
128
  apiName: manyObject.primaryKeyPropertyApiName,
124
129
  object: manyObjectApiName
125
130
  },
126
- column: manyObject.primaryKeyPropertyApiName
131
+ column: resolvedColumnA
127
132
  }],
128
133
  objectTypeBPrimaryKeyMapping: [{
129
134
  property: {
130
135
  apiName: toManyObject.primaryKeyPropertyApiName,
131
136
  object: toManyObjectApiName
132
137
  },
133
- column: toManyObject.primaryKeyPropertyApiName
138
+ column: resolvedColumnB
134
139
  }]
135
140
  }
136
141
  },
@@ -204,7 +209,7 @@ function validateLink(linkDefinition) {
204
209
  }
205
210
  export function getObject(object) {
206
211
  const objectApiName = typeof object === "string" ? object : object.apiName;
207
- const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
212
+ const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName] ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
208
213
  !(fullObject !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object ${objectApiName} is not defined`) : invariant(false) : void 0;
209
214
  return {
210
215
  apiName: objectApiName,
@@ -1 +1 @@
1
- {"version":3,"file":"convertLink.js","names":["invariant","OntologyEntityTypeEnum","cleanAndValidateLinkTypeId","ontologyDefinition","convertCardinality","convertLink","linkType","validateLink","definition","datasource","undefined","apiName","oneObjectApiName","object","oneObject","getObject","one","toManyObjectApiName","toManyObject","toMany","type","oneToMany","cardinalityHint","cardinality","manyToOneLinkMetadata","metadata","objectTypeRidManySide","objectTypeRidOneSide","oneToManyLinkMetadata","oneSidePrimaryKeyToManySidePropertyMapping","from","primaryKeyPropertyApiName","to","manyForeignKeyProperty","manyObjectApiName","manyObject","many","intermediary","objectTypeAToBLinkMetadata","objectTypeBToALinkMetadata","objectTypeRidA","objectTypeRidB","intermediaryObjectTypeRid","intermediaryObjectType","aToIntermediaryLinkTypeRid","linkToIntermediary","intermediaryToBLinkTypeRid","manyToMany","peeringMetadata","objectTypeAPrimaryKeyPropertyMapping","objectTypeBPrimaryKeyPropertyMapping","datasourceName","dataset","datasetRid","concat","writebackDatasetRid","objectTypeAPrimaryKeyMapping","property","column","objectTypeBPrimaryKeyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","id","status","convertLinkStatus","datasources","entityMetadata","arePatchesEnabled","editsEnabled","linkDefinition","foreignKey","properties","find","p","process","env","NODE_ENV","test","typesMatch","intermediaryObjectTypeApiName","manyIntermediaryOneObjectApiName","manyIntermediaryOneObject","manyIntermediaryToManyObjectApiName","manyIntermediaryToManyObject","toManyIntermediaryOneObjectApiName","toManyIntermediaryOneObject","toManyIntermediaryToManyObjectApiName","toManyIntermediaryToManyObject","objectApiName","fullObject","OBJECT_TYPE","deprecated","message","deadline","experimental","example","active"],"sources":["convertLink.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 {\n OntologyIrLinkDefinition,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrLinkTypeStatus,\n OntologyIrManyToManyLinkTypeDatasource,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {\n cleanAndValidateLinkTypeId,\n ontologyDefinition,\n} from \"../../api/defineOntology.js\";\nimport type { LinkType, UserLinkTypeStatus } from \"../../api/links/LinkType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type { ObjectTypeDefinition } from \"../../api/object/ObjectTypeDefinition.js\";\nimport { convertCardinality } from \"./convertCardinality.js\";\n\nexport function convertLink(\n linkType: LinkType,\n): OntologyIrLinkTypeBlockDataV2 {\n validateLink(linkType);\n let definition: OntologyIrLinkDefinition;\n let datasource: OntologyIrManyToManyLinkTypeDatasource | undefined =\n undefined;\n if (\"one\" in linkType) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkType.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"oneToMany\",\n oneToMany: {\n cardinalityHint: convertCardinality(linkType.cardinality),\n manyToOneLinkMetadata: linkType.toMany.metadata,\n objectTypeRidManySide: toManyObjectApiName,\n objectTypeRidOneSide: oneObjectApiName,\n oneToManyLinkMetadata: linkType.one.metadata,\n oneSidePrimaryKeyToManySidePropertyMapping: [{\n from: {\n apiName: oneObject.primaryKeyPropertyApiName,\n object: oneObjectApiName,\n },\n to: {\n apiName: linkType.manyForeignKeyProperty,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n } else if (\"intermediaryObjectType\" in linkType) {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"intermediary\",\n intermediary: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,\n aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.many.linkToIntermediary.apiName,\n ),\n intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.toMany.linkToIntermediary.apiName,\n ),\n },\n };\n } else {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"manyToMany\",\n manyToMany: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n peeringMetadata: undefined,\n objectTypeAPrimaryKeyPropertyMapping: [{\n from: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n to: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n }],\n objectTypeBPrimaryKeyPropertyMapping: [{\n from: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n to: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n\n datasource = {\n datasourceName: linkType.apiName,\n datasource: {\n type: \"dataset\",\n dataset: {\n datasetRid: \"link-\".concat(linkType.apiName),\n writebackDatasetRid: undefined,\n objectTypeAPrimaryKeyMapping: [{\n property: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n column: manyObject.primaryKeyPropertyApiName,\n }],\n objectTypeBPrimaryKeyMapping: [{\n property: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n column: toManyObject.primaryKeyPropertyApiName,\n }],\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: linkType.redacted,\n };\n }\n\n return {\n linkType: {\n definition: definition,\n id: cleanAndValidateLinkTypeId(linkType.apiName),\n status: convertLinkStatus(linkType.status),\n redacted: linkType.redacted ?? false,\n },\n datasources: datasource !== undefined ? [datasource] : [],\n entityMetadata: {\n arePatchesEnabled: linkType.editsEnabled ?? false,\n },\n };\n}\nfunction validateLink(linkDefinition: LinkType) {\n if (\"one\" in linkDefinition) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkDefinition.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n const foreignKey = toManyObject.properties?.find(p =>\n p.apiName === linkDefinition.manyForeignKeyProperty\n );\n invariant(\n foreignKey !== undefined,\n `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`,\n );\n\n invariant(\n /([a-z][a-z0-9\\\\-]*)/.test(linkDefinition.apiName),\n `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\\\-]*) ${linkDefinition.apiName} does not match`,\n );\n\n const typesMatch = foreignKey.type\n === oneObject.properties?.find(p =>\n p.apiName === oneObject.primaryKeyPropertyApiName\n )?.type;\n invariant(\n typesMatch,\n `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`,\n );\n }\n if (\"intermediaryObjectType\" in linkDefinition) {\n const {\n apiName: intermediaryObjectTypeApiName,\n object: intermediaryObjectType,\n } = getObject(linkDefinition.intermediaryObjectType);\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkDefinition.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n\n const {\n apiName: manyIntermediaryOneObjectApiName,\n object: manyIntermediaryOneObject,\n } = getObject((linkDefinition.many.linkToIntermediary as any).one.object);\n const {\n apiName: manyIntermediaryToManyObjectApiName,\n object: manyIntermediaryToManyObject,\n } = getObject(linkDefinition.many.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.many.linkToIntermediary\n && manyIntermediaryOneObjectApiName\n === manyObject.apiName\n && manyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`,\n );\n\n const {\n apiName: toManyIntermediaryOneObjectApiName,\n object: toManyIntermediaryOneObject,\n } = getObject((linkDefinition.toMany.linkToIntermediary as any).one.object);\n const {\n apiName: toManyIntermediaryToManyObjectApiName,\n object: toManyIntermediaryToManyObject,\n } = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.toMany.linkToIntermediary\n && toManyIntermediaryOneObjectApiName\n === toManyObjectApiName\n && toManyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`,\n );\n }\n}\n\nexport function getObject(\n object: string | ObjectTypeDefinition,\n): { apiName: string; object: ObjectType } {\n const objectApiName = typeof object === \"string\" ? object : object.apiName;\n const fullObject =\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];\n invariant(\n fullObject !== undefined,\n `Object ${objectApiName} is not defined`,\n );\n return { apiName: objectApiName, object: fullObject };\n}\n\nexport function convertLinkStatus(\n status: UserLinkTypeStatus | undefined,\n): OntologyIrLinkTypeStatus {\n if (\n typeof status === \"object\" && \"type\" in status\n && status.type === \"deprecated\"\n ) {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n },\n };\n }\n switch (status) {\n case \"experimental\":\n return { type: \"experimental\", experimental: {} };\n case \"example\":\n return { type: \"example\", example: {} };\n case \"active\":\n default:\n return { type: \"active\", active: {} };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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E5E,MAAM,EAAE6E;EAAW,CAAC;AACvD;AAEA,OAAO,SAASzB,iBAAiBA,CAC/BD,MAAsC,EACZ;EAC1B,IACE,OAAOA,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAIA,MAAM,IAC3CA,MAAM,CAAC5C,IAAI,KAAK,YAAY,EAC/B;IACA,OAAO;MACLA,IAAI,EAAE,YAAY;MAClBwE,UAAU,EAAE;QACVC,OAAO,EAAE7B,MAAM,CAAC6B,OAAO;QACvBC,QAAQ,EAAE9B,MAAM,CAAC8B;MACnB;IACF,CAAC;EACH;EACA,QAAQ9B,MAAM;IACZ,KAAK,cAAc;MACjB,OAAO;QAAE5C,IAAI,EAAE,cAAc;QAAE2E,YAAY,EAAE,CAAC;MAAE,CAAC;IACnD,KAAK,SAAS;MACZ,OAAO;QAAE3E,IAAI,EAAE,SAAS;QAAE4E,OAAO,EAAE,CAAC;MAAE,CAAC;IACzC,KAAK,QAAQ;IACb;MACE,OAAO;QAAE5E,IAAI,EAAE,QAAQ;QAAE6E,MAAM,EAAE,CAAC;MAAE,CAAC;EACzC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"convertLink.js","names":["invariant","OntologyEntityTypeEnum","cleanAndValidateLinkTypeId","importedTypes","ontologyDefinition","convertCardinality","convertLink","linkType","validateLink","definition","datasource","undefined","apiName","oneObjectApiName","object","oneObject","getObject","one","toManyObjectApiName","toManyObject","toMany","type","oneToMany","cardinalityHint","cardinality","manyToOneLinkMetadata","metadata","objectTypeRidManySide","objectTypeRidOneSide","oneToManyLinkMetadata","oneSidePrimaryKeyToManySidePropertyMapping","from","primaryKeyPropertyApiName","to","manyForeignKeyProperty","manyObjectApiName","manyObject","many","intermediary","objectTypeAToBLinkMetadata","objectTypeBToALinkMetadata","objectTypeRidA","objectTypeRidB","intermediaryObjectTypeRid","intermediaryObjectType","aToIntermediaryLinkTypeRid","linkToIntermediary","intermediaryToBLinkTypeRid","columnA","columnB","hasCollision","resolvedColumnA","resolvedColumnB","manyToMany","peeringMetadata","objectTypeAPrimaryKeyPropertyMapping","objectTypeBPrimaryKeyPropertyMapping","datasourceName","dataset","datasetRid","concat","writebackDatasetRid","objectTypeAPrimaryKeyMapping","property","column","objectTypeBPrimaryKeyMapping","editsConfiguration","onlyAllowPrivilegedEdits","redacted","id","status","convertLinkStatus","datasources","entityMetadata","arePatchesEnabled","editsEnabled","linkDefinition","foreignKey","properties","find","p","process","env","NODE_ENV","test","typesMatch","intermediaryObjectTypeApiName","manyIntermediaryOneObjectApiName","manyIntermediaryOneObject","manyIntermediaryToManyObjectApiName","manyIntermediaryToManyObject","toManyIntermediaryOneObjectApiName","toManyIntermediaryOneObject","toManyIntermediaryToManyObjectApiName","toManyIntermediaryToManyObject","objectApiName","fullObject","OBJECT_TYPE","deprecated","message","deadline","experimental","example","active"],"sources":["convertLink.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 {\n OntologyIrLinkDefinition,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrLinkTypeStatus,\n OntologyIrManyToManyLinkTypeDatasource,\n} from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {\n cleanAndValidateLinkTypeId,\n importedTypes,\n ontologyDefinition,\n} from \"../../api/defineOntology.js\";\nimport type { LinkType, UserLinkTypeStatus } from \"../../api/links/LinkType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\nimport type { ObjectTypeDefinition } from \"../../api/object/ObjectTypeDefinition.js\";\nimport { convertCardinality } from \"./convertCardinality.js\";\n\nexport function convertLink(\n linkType: LinkType,\n): OntologyIrLinkTypeBlockDataV2 {\n validateLink(linkType);\n let definition: OntologyIrLinkDefinition;\n let datasource: OntologyIrManyToManyLinkTypeDatasource | undefined =\n undefined;\n if (\"one\" in linkType) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkType.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"oneToMany\",\n oneToMany: {\n cardinalityHint: convertCardinality(linkType.cardinality),\n manyToOneLinkMetadata: linkType.toMany.metadata,\n objectTypeRidManySide: toManyObjectApiName,\n objectTypeRidOneSide: oneObjectApiName,\n oneToManyLinkMetadata: linkType.one.metadata,\n oneSidePrimaryKeyToManySidePropertyMapping: [{\n from: {\n apiName: oneObject.primaryKeyPropertyApiName,\n object: oneObjectApiName,\n },\n to: {\n apiName: linkType.manyForeignKeyProperty,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n } else if (\"intermediaryObjectType\" in linkType) {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n definition = {\n type: \"intermediary\",\n intermediary: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,\n aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.many.linkToIntermediary.apiName,\n ),\n intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(\n linkType.toMany.linkToIntermediary.apiName,\n ),\n },\n };\n } else {\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkType.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkType.toMany.object,\n );\n\n const columnA = manyObject.primaryKeyPropertyApiName;\n const columnB = toManyObject.primaryKeyPropertyApiName;\n const hasCollision = columnA === columnB;\n const resolvedColumnA = hasCollision ? `${columnA}_from` : columnA;\n const resolvedColumnB = hasCollision ? `${columnB}_to` : columnB;\n\n definition = {\n type: \"manyToMany\",\n manyToMany: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: manyObjectApiName,\n objectTypeRidB: toManyObjectApiName,\n peeringMetadata: undefined,\n objectTypeAPrimaryKeyPropertyMapping: [{\n from: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n to: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n }],\n objectTypeBPrimaryKeyPropertyMapping: [{\n from: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n to: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n }],\n },\n };\n\n datasource = {\n datasourceName: linkType.apiName,\n datasource: {\n type: \"dataset\",\n dataset: {\n datasetRid: \"link-\".concat(linkType.apiName),\n writebackDatasetRid: undefined,\n objectTypeAPrimaryKeyMapping: [{\n property: {\n apiName: manyObject.primaryKeyPropertyApiName,\n object: manyObjectApiName,\n },\n column: resolvedColumnA,\n }],\n objectTypeBPrimaryKeyMapping: [{\n property: {\n apiName: toManyObject.primaryKeyPropertyApiName,\n object: toManyObjectApiName,\n },\n column: resolvedColumnB,\n }],\n },\n },\n editsConfiguration: {\n onlyAllowPrivilegedEdits: false,\n },\n redacted: linkType.redacted,\n };\n }\n\n return {\n linkType: {\n definition: definition,\n id: cleanAndValidateLinkTypeId(linkType.apiName),\n status: convertLinkStatus(linkType.status),\n redacted: linkType.redacted ?? false,\n },\n datasources: datasource !== undefined ? [datasource] : [],\n entityMetadata: {\n arePatchesEnabled: linkType.editsEnabled ?? false,\n },\n };\n}\nfunction validateLink(linkDefinition: LinkType) {\n if (\"one\" in linkDefinition) {\n const { apiName: oneObjectApiName, object: oneObject } = getObject(\n linkDefinition.one.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n const foreignKey = toManyObject.properties?.find(p =>\n p.apiName === linkDefinition.manyForeignKeyProperty\n );\n invariant(\n foreignKey !== undefined,\n `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`,\n );\n\n invariant(\n /([a-z][a-z0-9\\\\-]*)/.test(linkDefinition.apiName),\n `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\\\-]*) ${linkDefinition.apiName} does not match`,\n );\n\n const typesMatch = foreignKey.type\n === oneObject.properties?.find(p =>\n p.apiName === oneObject.primaryKeyPropertyApiName\n )?.type;\n invariant(\n typesMatch,\n `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`,\n );\n }\n if (\"intermediaryObjectType\" in linkDefinition) {\n const {\n apiName: intermediaryObjectTypeApiName,\n object: intermediaryObjectType,\n } = getObject(linkDefinition.intermediaryObjectType);\n const { apiName: manyObjectApiName, object: manyObject } = getObject(\n linkDefinition.many.object,\n );\n const { apiName: toManyObjectApiName, object: toManyObject } = getObject(\n linkDefinition.toMany.object,\n );\n\n const {\n apiName: manyIntermediaryOneObjectApiName,\n object: manyIntermediaryOneObject,\n } = getObject((linkDefinition.many.linkToIntermediary as any).one.object);\n const {\n apiName: manyIntermediaryToManyObjectApiName,\n object: manyIntermediaryToManyObject,\n } = getObject(linkDefinition.many.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.many.linkToIntermediary\n && manyIntermediaryOneObjectApiName\n === manyObject.apiName\n && manyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`,\n );\n\n const {\n apiName: toManyIntermediaryOneObjectApiName,\n object: toManyIntermediaryOneObject,\n } = getObject((linkDefinition.toMany.linkToIntermediary as any).one.object);\n const {\n apiName: toManyIntermediaryToManyObjectApiName,\n object: toManyIntermediaryToManyObject,\n } = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);\n invariant(\n \"one\" in linkDefinition.toMany.linkToIntermediary\n && toManyIntermediaryOneObjectApiName\n === toManyObjectApiName\n && toManyIntermediaryToManyObjectApiName\n === intermediaryObjectTypeApiName,\n `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`,\n );\n }\n}\n\nexport function getObject(\n object: string | ObjectTypeDefinition,\n): { apiName: string; object: ObjectType } {\n const objectApiName = typeof object === \"string\" ? object : object.apiName;\n const fullObject =\n ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName]\n ?? importedTypes[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];\n invariant(\n fullObject !== undefined,\n `Object ${objectApiName} is not defined`,\n );\n return { apiName: objectApiName, object: fullObject };\n}\n\nexport function convertLinkStatus(\n status: UserLinkTypeStatus | undefined,\n): OntologyIrLinkTypeStatus {\n if (\n typeof status === \"object\" && \"type\" in status\n && status.type === \"deprecated\"\n ) {\n return {\n type: \"deprecated\",\n deprecated: {\n message: status.message,\n deadline: status.deadline,\n },\n };\n }\n switch (status) {\n case \"experimental\":\n return { type: \"experimental\", experimental: {} };\n case \"example\":\n return { type: \"example\", example: {} };\n case \"active\":\n default:\n return { type: \"active\", active: {} };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,sBAAsB,QAAQ,4CAA4C;AACnF,SACEC,0BAA0B,EAC1BC,aAAa,EACbC,kBAAkB,QACb,6BAA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AC,CAACF,aAAa,CAAC;EACvE,EACEC,UAAU,KAAKrF,SAAS,IAAAsE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD1BnF,SAAS,QAEP,UAAU+F,aAAa,iBAAiB,IAF1C/F,SAAS;EAIT,OAAO;IAAEY,OAAO,EAAEmF,aAAa;IAAEjF,MAAM,EAAEkF;EAAW,CAAC;AACvD;AAEA,OAAO,SAASzB,iBAAiBA,CAC/BD,MAAsC,EACZ;EAC1B,IACE,OAAOA,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAIA,MAAM,IAC3CA,MAAM,CAACjD,IAAI,KAAK,YAAY,EAC/B;IACA,OAAO;MACLA,IAAI,EAAE,YAAY;MAClB6E,UAAU,EAAE;QACVC,OAAO,EAAE7B,MAAM,CAAC6B,OAAO;QACvBC,QAAQ,EAAE9B,MAAM,CAAC8B;MACnB;IACF,CAAC;EACH;EACA,QAAQ9B,MAAM;IACZ,KAAK,cAAc;MACjB,OAAO;QAAEjD,IAAI,EAAE,cAAc;QAAEgF,YAAY,EAAE,CAAC;MAAE,CAAC;IACnD,KAAK,SAAS;MACZ,OAAO;QAAEhF,IAAI,EAAE,SAAS;QAAEiF,OAAO,EAAE,CAAC;MAAE,CAAC;IACzC,KAAK,QAAQ;IACb;MACE,OAAO;QAAEjF,IAAI,EAAE,QAAQ;QAAEkF,MAAM,EAAE,CAAC;MAAE,CAAC;EACzC;AACF","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright 2026 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
+ const RESERVED_KEYWORDS = new Set(["ontology", "object", "property", "link", "relation", "rid", "primarykey", "typeid", "ontologyobject"]);
18
+ export const OBJECT_API_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9]{0,99}$/;
19
+ export const API_NAME_PATTERN = /^[a-zA-Z][a-zA-Z0-9_]{0,99}$/;
20
+ export function isValidApiName(apiName) {
21
+ return API_NAME_PATTERN.test(apiName) && !RESERVED_KEYWORDS.has(apiName.toLowerCase());
22
+ }
23
+ export function isValidObjectApiName(apiName) {
24
+ return OBJECT_API_NAME_PATTERN.test(apiName) && !RESERVED_KEYWORDS.has(apiName.toLowerCase());
25
+ }
26
+ //# sourceMappingURL=ApiNameValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiNameValidator.js","names":["RESERVED_KEYWORDS","Set","OBJECT_API_NAME_PATTERN","API_NAME_PATTERN","isValidApiName","apiName","test","has","toLowerCase","isValidObjectApiName"],"sources":["ApiNameValidator.ts"],"sourcesContent":["/*\n * Copyright 2026 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\nconst RESERVED_KEYWORDS = new Set([\n \"ontology\",\n \"object\",\n \"property\",\n \"link\",\n \"relation\",\n \"rid\",\n \"primarykey\",\n \"typeid\",\n \"ontologyobject\",\n]);\nexport const OBJECT_API_NAME_PATTERN: RegExp = /^[a-zA-Z][a-zA-Z0-9]{0,99}$/;\nexport const API_NAME_PATTERN: RegExp = /^[a-zA-Z][a-zA-Z0-9_]{0,99}$/;\n\nexport function isValidApiName(apiName: string): boolean {\n return API_NAME_PATTERN.test(apiName)\n && !RESERVED_KEYWORDS.has(apiName.toLowerCase());\n}\n\nexport function isValidObjectApiName(apiName: string): boolean {\n return OBJECT_API_NAME_PATTERN.test(apiName)\n && !RESERVED_KEYWORDS.has(apiName.toLowerCase());\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAChC,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,UAAU,EACV,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,gBAAgB,CACjB,CAAC;AACF,OAAO,MAAMC,uBAA+B,GAAG,6BAA6B;AAC5E,OAAO,MAAMC,gBAAwB,GAAG,8BAA8B;AAEtE,OAAO,SAASC,cAAcA,CAACC,OAAe,EAAW;EACvD,OAAOF,gBAAgB,CAACG,IAAI,CAACD,OAAO,CAAC,IAChC,CAACL,iBAAiB,CAACO,GAAG,CAACF,OAAO,CAACG,WAAW,CAAC,CAAC,CAAC;AACpD;AAEA,OAAO,SAASC,oBAAoBA,CAACJ,OAAe,EAAW;EAC7D,OAAOH,uBAAuB,CAACI,IAAI,CAACD,OAAO,CAAC,IACvC,CAACL,iBAAiB,CAACO,GAAG,CAACF,OAAO,CAACG,WAAW,CAAC,CAAC,CAAC;AACpD","ignoreList":[]}