@osdk/maker 0.13.0 → 0.14.0-beta.10

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 (222) hide show
  1. package/CHANGELOG.md +102 -36
  2. package/README.md +86 -22
  3. package/build/browser/api/action/DefaultFormat.js +2 -0
  4. package/build/browser/api/action/DefaultFormat.js.map +1 -0
  5. package/build/browser/api/action/TableConfiguration.js +2 -0
  6. package/build/browser/api/action/TableConfiguration.js.map +1 -0
  7. package/build/browser/api/code-snippets/createCodeSnippets.js +91 -0
  8. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
  9. package/build/browser/api/code-snippets/snippetTypes.js +60 -0
  10. package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
  11. package/build/browser/api/defineAction.js +131 -414
  12. package/build/browser/api/defineAction.js.map +1 -1
  13. package/build/browser/api/defineCreateInterfaceObjectAction.js +85 -0
  14. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
  15. package/build/browser/api/defineCreateObjectAction.js +80 -0
  16. package/build/browser/api/defineCreateObjectAction.js.map +1 -0
  17. package/build/browser/api/defineCreateOrModifyObjectAction.js +95 -0
  18. package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
  19. package/build/browser/api/defineDeleteInterfaceObjectAction.js +53 -0
  20. package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -0
  21. package/build/browser/api/defineDeleteObjectAction.js +56 -0
  22. package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
  23. package/build/browser/api/defineLink.js +5 -13
  24. package/build/browser/api/defineLink.js.map +1 -1
  25. package/build/browser/api/defineModifyInterfaceObjectAction.js +84 -0
  26. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
  27. package/build/browser/api/defineModifyObjectAction.js +93 -0
  28. package/build/browser/api/defineModifyObjectAction.js.map +1 -0
  29. package/build/browser/api/defineObject.js +94 -3
  30. package/build/browser/api/defineObject.js.map +1 -1
  31. package/build/browser/api/defineOntology.js +6 -1
  32. package/build/browser/api/defineOntology.js.map +1 -1
  33. package/build/browser/api/links/LinkType.js.map +1 -1
  34. package/build/browser/api/object/ObjectType.js.map +1 -1
  35. package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
  36. package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
  37. package/build/browser/api/test/actions.test.js +12034 -0
  38. package/build/browser/api/test/actions.test.js.map +1 -0
  39. package/build/browser/api/test/interfaces.test.js +924 -0
  40. package/build/browser/api/test/interfaces.test.js.map +1 -0
  41. package/build/browser/api/test/links.test.js +1974 -0
  42. package/build/browser/api/test/links.test.js.map +1 -0
  43. package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  44. package/build/browser/api/test/markingconstraint.test.js.map +1 -0
  45. package/build/browser/api/test/misc.test.js +1058 -0
  46. package/build/browser/api/test/misc.test.js.map +1 -0
  47. package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  48. package/build/browser/api/test/objectStatus.test.js.map +1 -0
  49. package/build/browser/api/test/objects.test.js +2591 -0
  50. package/build/browser/api/test/objects.test.js.map +1 -0
  51. package/build/browser/api/test/spt.test.js +387 -0
  52. package/build/browser/api/test/spt.test.js.map +1 -0
  53. package/build/browser/api/test/valueTypes.test.js +156 -0
  54. package/build/browser/api/test/valueTypes.test.js.map +1 -0
  55. package/build/browser/cli/main.js +25 -6
  56. package/build/browser/cli/main.js.map +1 -1
  57. package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
  58. package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
  59. package/build/browser/conversion/toMarketplace/convertActionValidation.js +2 -2
  60. package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
  61. package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +5 -3
  62. package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
  63. package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
  64. package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
  65. package/build/browser/conversion/toMarketplace/convertLink.js +109 -24
  66. package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
  67. package/build/browser/conversion/toMarketplace/convertObject.js +81 -4
  68. package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
  69. package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
  70. package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
  71. package/build/browser/index.js +8 -1
  72. package/build/browser/index.js.map +1 -1
  73. package/build/cjs/index.cjs +1716 -797
  74. package/build/cjs/index.cjs.map +1 -1
  75. package/build/cjs/index.d.cts +184 -115
  76. package/build/esm/api/action/DefaultFormat.js +2 -0
  77. package/build/esm/api/action/DefaultFormat.js.map +1 -0
  78. package/build/esm/api/action/TableConfiguration.js +2 -0
  79. package/build/esm/api/action/TableConfiguration.js.map +1 -0
  80. package/build/esm/api/code-snippets/createCodeSnippets.js +91 -0
  81. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
  82. package/build/esm/api/code-snippets/snippetTypes.js +60 -0
  83. package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
  84. package/build/esm/api/defineAction.js +131 -414
  85. package/build/esm/api/defineAction.js.map +1 -1
  86. package/build/esm/api/defineCreateInterfaceObjectAction.js +85 -0
  87. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
  88. package/build/esm/api/defineCreateObjectAction.js +80 -0
  89. package/build/esm/api/defineCreateObjectAction.js.map +1 -0
  90. package/build/esm/api/defineCreateOrModifyObjectAction.js +95 -0
  91. package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
  92. package/build/esm/api/defineDeleteInterfaceObjectAction.js +53 -0
  93. package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -0
  94. package/build/esm/api/defineDeleteObjectAction.js +56 -0
  95. package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
  96. package/build/esm/api/defineLink.js +5 -13
  97. package/build/esm/api/defineLink.js.map +1 -1
  98. package/build/esm/api/defineModifyInterfaceObjectAction.js +84 -0
  99. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
  100. package/build/esm/api/defineModifyObjectAction.js +93 -0
  101. package/build/esm/api/defineModifyObjectAction.js.map +1 -0
  102. package/build/esm/api/defineObject.js +94 -3
  103. package/build/esm/api/defineObject.js.map +1 -1
  104. package/build/esm/api/defineOntology.js +6 -1
  105. package/build/esm/api/defineOntology.js.map +1 -1
  106. package/build/esm/api/links/LinkType.js.map +1 -1
  107. package/build/esm/api/object/ObjectType.js.map +1 -1
  108. package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
  109. package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
  110. package/build/esm/api/test/actions.test.js +12034 -0
  111. package/build/esm/api/test/actions.test.js.map +1 -0
  112. package/build/esm/api/test/interfaces.test.js +924 -0
  113. package/build/esm/api/test/interfaces.test.js.map +1 -0
  114. package/build/esm/api/test/links.test.js +1974 -0
  115. package/build/esm/api/test/links.test.js.map +1 -0
  116. package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
  117. package/build/esm/api/test/markingconstraint.test.js.map +1 -0
  118. package/build/esm/api/test/misc.test.js +1058 -0
  119. package/build/esm/api/test/misc.test.js.map +1 -0
  120. package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
  121. package/build/esm/api/test/objectStatus.test.js.map +1 -0
  122. package/build/esm/api/test/objects.test.js +2591 -0
  123. package/build/esm/api/test/objects.test.js.map +1 -0
  124. package/build/esm/api/test/spt.test.js +387 -0
  125. package/build/esm/api/test/spt.test.js.map +1 -0
  126. package/build/esm/api/test/valueTypes.test.js +156 -0
  127. package/build/esm/api/test/valueTypes.test.js.map +1 -0
  128. package/build/esm/cli/main.js +25 -6
  129. package/build/esm/cli/main.js.map +1 -1
  130. package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
  131. package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
  132. package/build/esm/conversion/toMarketplace/convertActionValidation.js +2 -2
  133. package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
  134. package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +5 -3
  135. package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
  136. package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
  137. package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
  138. package/build/esm/conversion/toMarketplace/convertLink.js +109 -24
  139. package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
  140. package/build/esm/conversion/toMarketplace/convertObject.js +81 -4
  141. package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
  142. package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
  143. package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
  144. package/build/esm/index.js +8 -1
  145. package/build/esm/index.js.map +1 -1
  146. package/build/types/api/action/DefaultFormat.d.ts +1 -0
  147. package/build/types/api/action/DefaultFormat.d.ts.map +1 -0
  148. package/build/types/api/action/TableConfiguration.d.ts +8 -0
  149. package/build/types/api/action/TableConfiguration.d.ts.map +1 -0
  150. package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
  151. package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
  152. package/build/types/api/code-snippets/snippetTypes.d.ts +23 -0
  153. package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
  154. package/build/types/api/defineAction.d.ts +34 -10
  155. package/build/types/api/defineAction.d.ts.map +1 -1
  156. package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
  157. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
  158. package/build/types/api/defineCreateObjectAction.d.ts +3 -0
  159. package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
  160. package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
  161. package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
  162. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +3 -0
  163. package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -0
  164. package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
  165. package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
  166. package/build/types/api/defineLink.d.ts.map +1 -1
  167. package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
  168. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
  169. package/build/types/api/defineModifyObjectAction.d.ts +3 -0
  170. package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
  171. package/build/types/api/defineObject.d.ts.map +1 -1
  172. package/build/types/api/defineOntology.d.ts +1 -1
  173. package/build/types/api/defineOntology.d.ts.map +1 -1
  174. package/build/types/api/links/LinkType.d.ts +7 -7
  175. package/build/types/api/object/ObjectType.d.ts +1 -1
  176. package/build/types/api/object/ObjectType.d.ts.map +1 -1
  177. package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +41 -1
  178. package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
  179. package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -1
  180. package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
  181. package/build/types/api/test/actions.test.d.ts.map +1 -0
  182. package/build/types/api/test/interfaces.test.d.ts.map +1 -0
  183. package/build/types/api/test/links.test.d.ts.map +1 -0
  184. package/build/types/api/test/markingconstraint.test.d.ts +1 -0
  185. package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
  186. package/build/types/api/test/misc.test.d.ts +1 -0
  187. package/build/types/api/test/misc.test.d.ts.map +1 -0
  188. package/build/types/api/test/objectStatus.test.d.ts +1 -0
  189. package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
  190. package/build/types/api/test/objects.test.d.ts +1 -0
  191. package/build/types/api/test/objects.test.d.ts.map +1 -0
  192. package/build/types/api/test/spt.test.d.ts +1 -0
  193. package/build/types/api/test/spt.test.d.ts.map +1 -0
  194. package/build/types/api/test/valueTypes.test.d.ts +1 -0
  195. package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
  196. package/build/types/cli/main.d.ts.map +1 -1
  197. package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +2 -2
  198. package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -1
  199. package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +2 -1
  200. package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -1
  201. package/build/types/conversion/toMarketplace/convertLink.d.ts +6 -0
  202. package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
  203. package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
  204. package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +2 -1
  205. package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -1
  206. package/build/types/index.d.ts +8 -1
  207. package/build/types/index.d.ts.map +1 -1
  208. package/package.json +6 -6
  209. package/build/browser/api/markingconstraint.test.js.map +0 -1
  210. package/build/browser/api/objectStatus.test.js.map +0 -1
  211. package/build/browser/api/overall.test.js +0 -13998
  212. package/build/browser/api/overall.test.js.map +0 -1
  213. package/build/esm/api/markingconstraint.test.js.map +0 -1
  214. package/build/esm/api/objectStatus.test.js.map +0 -1
  215. package/build/esm/api/overall.test.js +0 -13998
  216. package/build/esm/api/overall.test.js.map +0 -1
  217. package/build/types/api/markingconstraint.test.d.ts.map +0 -1
  218. package/build/types/api/objectStatus.test.d.ts.map +0 -1
  219. package/build/types/api/overall.test.d.ts.map +0 -1
  220. /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
  221. /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
  222. /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
@@ -18,13 +18,13 @@ import { consola } from "consola";
18
18
  import * as fs from "node:fs/promises";
19
19
  import * as path from "node:path";
20
20
  import invariant from "tiny-invariant";
21
- import { validate as validateUuid } from "uuid";
22
21
  import yargs from "yargs";
23
22
  import { hideBin } from "yargs/helpers";
24
23
  import { defineOntology } from "../api/defineOntology.js";
25
24
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
25
+ const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
26
26
  export default async function main(args = process.argv) {
27
- const commandLineOpts = await yargs(hideBin(args)).version("0.13.0" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
27
+ const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.10" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
28
28
  input: {
29
29
  alias: "i",
30
30
  describe: "Input file",
@@ -68,6 +68,22 @@ export default async function main(args = process.argv) {
68
68
  type: "string",
69
69
  coerce: path.resolve
70
70
  },
71
+ generateCodeSnippets: {
72
+ describe: "Enable code snippet files creation",
73
+ type: "boolean",
74
+ default: false
75
+ },
76
+ codeSnippetPackageName: {
77
+ describe: "The package name that will be displayed in the code snippets",
78
+ default: "",
79
+ type: "string"
80
+ },
81
+ codeSnippetDir: {
82
+ describe: "Directory for generated code snippet files",
83
+ type: "string",
84
+ default: "./",
85
+ coerce: path.resolve
86
+ },
71
87
  randomnessKey: {
72
88
  describe: "Value used to assure uniqueness of entities",
73
89
  type: "string",
@@ -81,10 +97,13 @@ export default async function main(args = process.argv) {
81
97
  !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(\.[a-z0-9-]+)*\.$") : invariant(false) : void 0;
82
98
  }
83
99
  consola.info(`Loading ontology from ${commandLineOpts.input}`);
100
+ if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path.resolve("./"))) {
101
+ consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
102
+ }
84
103
  if (commandLineOpts.randomnessKey !== undefined) {
85
- !validateUuid(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant(false) : void 0;
104
+ !uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant(false) : void 0;
86
105
  }
87
- const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
106
+ const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
88
107
  consola.info(`Saving ontology to ${commandLineOpts.output}`);
89
108
  await fs.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
90
109
  // No point in generating block if there aren't any value types
@@ -92,8 +111,8 @@ export default async function main(args = process.argv) {
92
111
  await fs.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
93
112
  }
94
113
  }
95
- async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
96
- const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
114
+ async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
115
+ const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
97
116
  return q;
98
117
  }
99
118
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["consola","fs","path","invariant","validate","validateUuid","yargs","hideBin","defineOntology","apiNamespaceRegex","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","randomnessKey","parseAsync","length","slice","env","NODE_ENV","test","info","undefined","ontologyIr","loadOntology","writeFile","JSON","stringify","valueTypes","importedValueTypes","dependencyFile","q"],"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 invariant from \"tiny-invariant\";\nimport { validate as validateUuid } from \"uuid\";\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { defineOntology } from \"../api/defineOntology.js\";\n\nconst apiNamespaceRegex = /^[a-z0-9-]+(\\.[a-z0-9-]+)*\\.$/;\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 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 randomnessKey: {\n describe: \"Value used to assure uniqueness of entities\",\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 consola.info(`Loading ontology from ${commandLineOpts.input}`);\n\n if (commandLineOpts.randomnessKey !== undefined) {\n invariant(\n validateUuid(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 );\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) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n dependencyFile,\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,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,QAAQ,IAAIC,YAAY,QAAQ,MAAM;AAC/C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,MAAMC,iBAAiB,GAAG,+BAA+B;AAEzD,eAAe,eAAeC,IAAIA,CAChCC,IAAc,GAAGC,OAAO,CAACC,IAAI,EACd;EACf,MAAMC,eASL,GAAG,MAAMR,KAAK,CAACC,OAAO,CAACI,IAAI,CAAC,CAAC,CAC3BI,OAAO,CAAC,YAA+B,EAAE,CAAC,CAC1CC,IAAI,CAACC,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEZ,KAAK,CAAC,CAAC,CAACa,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5CC,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,OAAO,CAAC;IACPC,KAAK,EAAE;MACLC,KAAK,EAAE,GAAG;MACVC,QAAQ,EAAE,YAAY;MACtBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,uBAAuB;MAChCC,MAAM,EAAE1B,IAAI,CAAC2B;IACf,CAAC;IACDC,MAAM,EAAE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,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7BmB,cAAkC,EAClC;EACA,MAAMC,CAAC,GAAG,MAAM7C,cAAc,CAC5BuB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTmB,cACF,CAAC;EACD,OAAOC,CAAC;AACV","ignoreList":[]}
1
+ {"version":3,"file":"main.js","names":["consola","fs","path","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"],"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 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 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 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(input),\n outputDir,\n dependencyFile,\n generateCodeSnippets,\n snippetPackageName,\n codeSnippetDir,\n randomnessKey,\n );\n return q;\n}\n"],"mappings":"AAAA;A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,IAAI,CAACC,SAAS,CACZJ,UAAU,EACV,IAAI,EACJ,CACF,CACF,CAAC;EACD;EACA,IACEA,UAAU,CAACK,UAAU,CAACA,UAAU,CAACZ,MAAM,GAAG,CAAC,IACxCO,UAAU,CAACM,kBAAkB,CAACD,UAAU,CAACZ,MAAM,GAAG,CAAC,EACtD;IACA,MAAMvC,EAAE,CAACgD,SAAS,CAChBpC,eAAe,CAACoB,gBAAgB,EAChCiB,IAAI,CAACC,SAAS,CACZJ,UAAU,CAACK,UAAU,EACrB,IAAI,EACJ,CACF,CACF,CAAC;EACH;AACF;AAEA,eAAeJ,YAAYA,CACzB1B,KAAa,EACbQ,YAAoB,EACpBE,SAA6B,EAC7BsB,cAAkC,EAClCnB,oBAA6B,EAC7BoB,kBAA0B,EAC1BlB,cAAsB,EACtBC,aAAsB,EACtB;EACA,MAAMkB,CAAC,GAAG,MAAMlD,cAAc,CAC5BwB,YAAY,EACZ,YAAY,MAAM,MAAM,CAACR,KAAK,CAAC,EAC/BU,SAAS,EACTsB,cAAc,EACdnB,oBAAoB,EACpBoB,kBAAkB,EAClBlB,cAAc,EACdC,aACF,CAAC;EACD,OAAOkB,CAAC;AACV","ignoreList":[]}
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { extractAllowedValues } from "../../api/defineOntology.js";
18
18
  import { convertConditionDefinition } from "./convertConditionDefinition.js";
19
- export function convertActionParameterConditionalOverride(override, validation) {
19
+ export function convertActionParameterConditionalOverride(override, validation, actionParameters) {
20
20
  let parameterBlockOverride;
21
21
  switch (override.type) {
22
22
  case "required":
@@ -81,7 +81,7 @@ export function convertActionParameterConditionalOverride(override, validation)
81
81
  throw new Error(`Unknown parameter override type`);
82
82
  }
83
83
  return {
84
- condition: convertConditionDefinition(override.condition),
84
+ condition: convertConditionDefinition(override.condition, actionParameters),
85
85
  parameterBlockOverrides: [parameterBlockOverride]
86
86
  };
87
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"convertActionParameterConditionalOverride.js","names":["extractAllowedValues","convertConditionDefinition","convertActionParameterConditionalOverride","override","validation","parameterBlockOverride","type","parameterRequired","required","notRequired","visibility","defaultVisibility","hidden","editable","disabled","prefill","defaultValue","allowedValues","constraint","Error","condition","parameterBlockOverrides"],"sources":["convertActionParameterConditionalOverride.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 OntologyIrConditionalOverride,\n OntologyIrParameterValidationBlockOverride,\n} from \"@osdk/client.unstable\";\nimport type { ActionParameterValidation } from \"../../api/action/ActionParameter.js\";\nimport type { ActionParameterConditionalOverride } from \"../../api/action/ActionParameterConditionalOverride.js\";\nimport { extractAllowedValues } from \"../../api/defineOntology.js\";\nimport { convertConditionDefinition } from \"./convertConditionDefinition.js\";\n\nexport function convertActionParameterConditionalOverride(\n override: ActionParameterConditionalOverride,\n validation: ActionParameterValidation,\n): OntologyIrConditionalOverride {\n let parameterBlockOverride: OntologyIrParameterValidationBlockOverride;\n switch (override.type) {\n case \"required\":\n parameterBlockOverride = {\n type: \"parameterRequired\",\n parameterRequired: {\n required: validation.required\n ? {\n type: \"notRequired\",\n notRequired: {},\n }\n : {\n type: \"required\",\n required: {},\n },\n },\n };\n break;\n case \"visibility\":\n parameterBlockOverride = {\n type: \"visibility\",\n visibility: {\n visibility: validation.defaultVisibility === \"editable\"\n ? {\n type: \"hidden\",\n hidden: {},\n }\n : {\n type: \"editable\",\n editable: {},\n },\n },\n };\n break;\n case \"disabled\":\n parameterBlockOverride = {\n type: \"visibility\",\n visibility: {\n visibility: validation.defaultVisibility === \"editable\"\n ? {\n type: \"disabled\",\n disabled: {},\n }\n : {\n type: \"editable\",\n editable: {},\n },\n },\n };\n break;\n case \"defaultValue\":\n parameterBlockOverride = {\n type: \"prefill\",\n prefill: {\n prefill: override.defaultValue,\n },\n };\n break;\n case \"constraint\":\n parameterBlockOverride = {\n type: \"allowedValues\",\n allowedValues: {\n allowedValues: extractAllowedValues(override.constraint),\n },\n };\n break;\n default:\n throw new Error(`Unknown parameter override type`);\n }\n return {\n condition: convertConditionDefinition(override.condition),\n parameterBlockOverrides: [parameterBlockOverride],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,oBAAoB,QAAQ,6BAA6B;AAClE,SAASC,0BAA0B,QAAQ,iCAAiC;AAE5E,OAAO,SAASC,yCAAyCA,CACvDC,QAA4C,EAC5CC,UAAqC,EACN;EAC/B,IAAIC,sBAAkE;EACtE,QAAQF,QAAQ,CAACG,IAAI;IACnB,KAAK,UAAU;MACbD,sBAAsB,GAAG;QACvBC,IAAI,EAAE,mBAAmB;QACzBC,iBAAiB,EAAE;UACjBC,QAAQ,EAAEJ,UAAU,CAACI,QAAQ,GACzB;YACAF,IAAI,EAAE,aAAa;YACnBG,WAAW,EAAE,CAAC;UAChB,CAAC,GACC;YACAH,IAAI,EAAE,UAAU;YAChBE,QAAQ,EAAE,CAAC;UACb;QACJ;MACF,CAAC;MACD;IACF,KAAK,YAAY;MACfH,sBAAsB,GAAG;QACvBC,IAAI,EAAE,YAAY;QAClBI,UAAU,EAAE;UACVA,UAAU,EAAEN,UAAU,CAACO,iBAAiB,KAAK,UAAU,GACnD;YACAL,IAAI,EAAE,QAAQ;YACdM,MAAM,EAAE,CAAC;UACX,CAAC,GACC;YACAN,IAAI,EAAE,UAAU;YAChBO,QAAQ,EAAE,CAAC;UACb;QACJ;MACF,CAAC;MACD;IACF,KAAK,UAAU;MACbR,sBAAsB,GAAG;QACvBC,IAAI,EAAE,YAAY;QAClBI,UAAU,EAAE;UACVA,UAAU,EAAEN,UAAU,CAACO,iBAAiB,KAAK,UAAU,GACnD;YACAL,IAAI,EAAE,UAAU;YAChBQ,QAAQ,EAAE,CAAC;UACb,CAAC,GACC;YACAR,IAAI,EAAE,UAAU;YAChBO,QAAQ,EAAE,CAAC;UACb;QACJ;MACF,CAAC;MACD;IACF,KAAK,cAAc;MACjBR,sBAAsB,GAAG;QACvBC,IAAI,EAAE,SAAS;QACfS,OAAO,EAAE;UACPA,OAAO,EAAEZ,QAAQ,CAACa;QACpB;MACF,CAAC;MACD;IACF,KAAK,YAAY;MACfX,sBAAsB,GAAG;QACvBC,IAAI,EAAE,eAAe;QACrBW,aAAa,EAAE;UACbA,aAAa,EAAEjB,oBAAoB,CAACG,QAAQ,CAACe,UAAU;QACzD;MACF,CAAC;MACD;IACF;MACE,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;EACtD;EACA,OAAO;IACLC,SAAS,EAAEnB,0BAA0B,CAACE,QAAQ,CAACiB,SAAS,CAAC;IACzDC,uBAAuB,EAAE,CAAChB,sBAAsB;EAClD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"convertActionParameterConditionalOverride.js","names":["extractAllowedValues","convertConditionDefinition","convertActionParameterConditionalOverride","override","validation","actionParameters","parameterBlockOverride","type","parameterRequired","required","notRequired","visibility","defaultVisibility","hidden","editable","disabled","prefill","defaultValue","allowedValues","constraint","Error","condition","parameterBlockOverrides"],"sources":["convertActionParameterConditionalOverride.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 OntologyIrConditionalOverride,\n OntologyIrParameterValidationBlockOverride,\n} from \"@osdk/client.unstable\";\nimport type {\n ActionParameter,\n ActionParameterValidation,\n} from \"../../api/action/ActionParameter.js\";\nimport type { ActionParameterConditionalOverride } from \"../../api/action/ActionParameterConditionalOverride.js\";\nimport { extractAllowedValues } from \"../../api/defineOntology.js\";\nimport { convertConditionDefinition } from \"./convertConditionDefinition.js\";\n\nexport function convertActionParameterConditionalOverride(\n override: ActionParameterConditionalOverride,\n validation: ActionParameterValidation,\n actionParameters?: ActionParameter[],\n): OntologyIrConditionalOverride {\n let parameterBlockOverride: OntologyIrParameterValidationBlockOverride;\n switch (override.type) {\n case \"required\":\n parameterBlockOverride = {\n type: \"parameterRequired\",\n parameterRequired: {\n required: validation.required\n ? {\n type: \"notRequired\",\n notRequired: {},\n }\n : {\n type: \"required\",\n required: {},\n },\n },\n };\n break;\n case \"visibility\":\n parameterBlockOverride = {\n type: \"visibility\",\n visibility: {\n visibility: validation.defaultVisibility === \"editable\"\n ? {\n type: \"hidden\",\n hidden: {},\n }\n : {\n type: \"editable\",\n editable: {},\n },\n },\n };\n break;\n case \"disabled\":\n parameterBlockOverride = {\n type: \"visibility\",\n visibility: {\n visibility: validation.defaultVisibility === \"editable\"\n ? {\n type: \"disabled\",\n disabled: {},\n }\n : {\n type: \"editable\",\n editable: {},\n },\n },\n };\n break;\n case \"defaultValue\":\n parameterBlockOverride = {\n type: \"prefill\",\n prefill: {\n prefill: override.defaultValue,\n },\n };\n break;\n case \"constraint\":\n parameterBlockOverride = {\n type: \"allowedValues\",\n allowedValues: {\n allowedValues: extractAllowedValues(override.constraint),\n },\n };\n break;\n default:\n throw new Error(`Unknown parameter override type`);\n }\n return {\n condition: convertConditionDefinition(override.condition, actionParameters),\n parameterBlockOverrides: [parameterBlockOverride],\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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Y;MACfX,sBAAsB,GAAG;QACvBC,IAAI,EAAE,eAAe;QACrBW,aAAa,EAAE;UACbA,aAAa,EAAElB,oBAAoB,CAACG,QAAQ,CAACgB,UAAU;QACzD;MACF,CAAC;MACD;IACF;MACE,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;EACtD;EACA,OAAO;IACLC,SAAS,EAAEpB,0BAA0B,CAACE,QAAQ,CAACkB,SAAS,EAAEhB,gBAAgB,CAAC;IAC3EiB,uBAAuB,EAAE,CAAChB,sBAAsB;EAClD,CAAC;AACH","ignoreList":[]}
@@ -47,7 +47,7 @@ export function convertActionValidation(action) {
47
47
  required: convertParameterRequirementConstraint(p.validation.required)
48
48
  }
49
49
  },
50
- conditionalOverrides: p.validation.conditionalOverrides?.map(override => convertActionParameterConditionalOverride(override, p.validation)) ?? []
50
+ conditionalOverrides: p.validation.conditionalOverrides?.map(override => convertActionParameterConditionalOverride(override, p.validation, action.parameters)) ?? []
51
51
  }];
52
52
  })),
53
53
  sectionValidations: {
@@ -63,7 +63,7 @@ export function convertActionValidation(action) {
63
63
  visible: {}
64
64
  }
65
65
  },
66
- conditionalOverrides: section.conditionalOverrides?.map(override => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible")) ?? []
66
+ conditionalOverrides: section.conditionalOverrides?.map(override => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", action.parameters)) ?? []
67
67
  }]))
68
68
  }
69
69
  };
@@ -1 +1 @@
1
- {"version":3,"file":"convertActionValidation.js","names":["extractAllowedValues","renderHintFromBaseType","convertActionParameterConditionalOverride","convertActionVisibility","convertSectionConditionalOverride","convertActionValidation","action","actionTypeLevelValidation","rules","Object","fromEntries","validation","condition","type","true","displayMetadata","failureMessage","typeClasses","map","rule","idx","parameterValidations","parameters","p","id","defaultValidation","display","renderHint","visibility","defaultVisibility","defaultValue","prefill","allowedValues","required","convertParameterRequirementConstraint","conditionalOverrides","override","sectionValidations","entries","sections","sectionId","section","defaultDisplayMetadata","hidden","visible","notRequired","min","max","listLength","listLengthValidation","minLength","maxLength"],"sources":["convertActionValidation.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 OntologyIrActionValidation,\n ParameterRequiredConfiguration,\n} from \"@osdk/client.unstable\";\nimport type { ActionParameterRequirementConstraint } from \"../../api/action/ActionParameterConfiguration.js\";\nimport type { ActionType } from \"../../api/action/ActionType.js\";\nimport {\n extractAllowedValues,\n renderHintFromBaseType,\n} from \"../../api/defineOntology.js\";\nimport { convertActionParameterConditionalOverride } from \"./convertActionParameterConditionalOverride.js\";\nimport { convertActionVisibility } from \"./convertActionVisibility.js\";\nimport { convertSectionConditionalOverride } from \"./convertSectionConditionalOverride.js\";\n\nexport function convertActionValidation(\n action: ActionType,\n): OntologyIrActionValidation {\n return {\n actionTypeLevelValidation: {\n rules: Object.fromEntries(\n (action.validation\n ?? [{\n condition: { type: \"true\", true: {} },\n displayMetadata: { failureMessage: \"\", typeClasses: [] },\n }]).map((rule, idx) => [idx, rule]),\n ),\n },\n parameterValidations: Object.fromEntries(\n (action.parameters ?? []).map(p => {\n return [\n p.id,\n {\n defaultValidation: {\n display: {\n renderHint: renderHintFromBaseType(p),\n visibility: convertActionVisibility(\n p.validation.defaultVisibility,\n ),\n ...p.defaultValue\n && { prefill: p.defaultValue },\n },\n validation: {\n allowedValues: extractAllowedValues(\n p.validation.allowedValues!,\n ),\n required: convertParameterRequirementConstraint(\n p.validation.required!,\n ),\n },\n },\n conditionalOverrides: p.validation.conditionalOverrides?.map(\n (override) =>\n convertActionParameterConditionalOverride(\n override,\n p.validation,\n ),\n ) ?? [],\n },\n ];\n }),\n ),\n sectionValidations: {\n ...Object.fromEntries(\n Object.entries(action.sections ?? {}).map((\n [sectionId, section],\n ) => [\n section.id,\n {\n defaultDisplayMetadata: section.defaultVisibility === \"hidden\"\n ? {\n visibility: {\n type: \"hidden\",\n hidden: {},\n },\n }\n : {\n visibility: {\n type: \"visible\",\n visible: {},\n },\n },\n conditionalOverrides: section.conditionalOverrides?.map(\n (override) =>\n convertSectionConditionalOverride(\n override,\n section.defaultVisibility ?? \"visible\",\n ),\n ) ?? [],\n },\n ]),\n ),\n },\n };\n}\n\nfunction convertParameterRequirementConstraint(\n required: ActionParameterRequirementConstraint,\n): ParameterRequiredConfiguration {\n if (typeof required === \"boolean\") {\n return required\n ? { type: \"required\", required: {} }\n : { type: \"notRequired\", notRequired: {} };\n }\n const { min, max } = required.listLength;\n return {\n type: \"listLengthValidation\",\n listLengthValidation: { minLength: min, maxLength: max },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SACEA,oBAAoB,EACpBC,sBAAsB,QACjB,6BAA6B;AACpC,SAASC,yCAAyC,QAAQ,gDAAgD;AAC1G,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,iCAAiC,QAAQ,wCAAwC;AAE1F,OAAO,SAASC,uBAAuBA,CACrCC,MAAkB,EACU;EAC5B,OAAO;IACLC,yBAAyB,EAAE;MACzBC,KAAK,EAAEC,MAAM,CAACC,WAAW,CACvB,CAACJ,MAAM,CAACK,UAAU,IACb,CAAC;QACFC,SAAS,EAAE;UAAEC,IAAI,EAAE,MAAM;UAAEC,IAAI,EAAE,CAAC;QAAE,CAAC;QACrCC,eAAe,EAAE;UAAEC,cAAc,EAAE,EAAE;UAAEC,WAAW,EAAE;QAAG;MACzD,CAAC,CAAC,EAAEC,GAAG,CAAC,CAACC,IAAI,EAAEC,G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;UACAf,UAAU,EAAE;YACVf,IAAI,EAAE,SAAS;YACf+B,OAAO,EAAE,CAAC;UACZ;QACF,CAAC;QACHT,oBAAoB,EAAEM,OAAO,CAACN,oBAAoB,EAAEjB,GAAG,CACpDkB,QAAQ,IACPhC,iCAAiC,CAC/BgC,QAAQ,EACRK,OAAO,CAACZ,iBAAiB,IAAI,SAC/B,CACJ,CAAC,IAAI;MACP,CAAC,CACF,CACH;IACF;EACF,CAAC;AACH;AAEA,SAASK,qCAAqCA,CAC5CD,QAA8C,EACd;EAChC,IAAI,OAAOA,QAAQ,KAAK,SAAS,EAAE;IACjC,OAAOA,QAAQ,GACX;MAAEpB,IAAI,EAAE,UAAU;MAAEoB,QAAQ,EAAE,CAAC;IAAE,CAAC,GAClC;MAAEpB,IAAI,EAAE,aAAa;MAAEgC,WAAW,EAAE,CAAC;IAAE,CAAC;EAC9C;EACA,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGd,QAAQ,CAACe,UAAU;EACxC,OAAO;IACLnC,IAAI,EAAE,sBAAsB;IAC5BoC,oBAAoB,EAAE;MAAEC,SAAS,EAAEJ,GAAG;MAAEK,SAAS,EAAEJ;IAAI;EACzD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"convertActionValidation.js","names":["extractAllowedValues","renderHintFromBaseType","convertActionParameterConditionalOverride","convertActionVisibility","convertSectionConditionalOverride","convertActionValidation","action","actionTypeLevelValidation","rules","Object","fromEntries","validation","condition","type","true","displayMetadata","failureMessage","typeClasses","map","rule","idx","parameterValidations","parameters","p","id","defaultValidation","display","renderHint","visibility","defaultVisibility","defaultValue","prefill","allowedValues","required","convertParameterRequirementConstraint","conditionalOverrides","override","sectionValidations","entries","sections","sectionId","section","defaultDisplayMetadata","hidden","visible","notRequired","min","max","listLength","listLengthValidation","minLength","maxLength"],"sources":["convertActionValidation.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 OntologyIrActionValidation,\n ParameterRequiredConfiguration,\n} from \"@osdk/client.unstable\";\nimport type { ActionParameterRequirementConstraint } from \"../../api/action/ActionParameterConfiguration.js\";\nimport type { ActionType } from \"../../api/action/ActionType.js\";\nimport {\n extractAllowedValues,\n renderHintFromBaseType,\n} from \"../../api/defineOntology.js\";\nimport { convertActionParameterConditionalOverride } from \"./convertActionParameterConditionalOverride.js\";\nimport { convertActionVisibility } from \"./convertActionVisibility.js\";\nimport { convertSectionConditionalOverride } from \"./convertSectionConditionalOverride.js\";\n\nexport function convertActionValidation(\n action: ActionType,\n): OntologyIrActionValidation {\n return {\n actionTypeLevelValidation: {\n rules: Object.fromEntries(\n (action.validation\n ?? [{\n condition: { type: \"true\", true: {} },\n displayMetadata: { failureMessage: \"\", typeClasses: [] },\n }]).map((rule, idx) => [idx, rule]),\n ),\n },\n parameterValidations: Object.fromEntries(\n (action.parameters ?? []).map(p => {\n return [\n p.id,\n {\n defaultValidation: {\n display: {\n renderHint: renderHintFromBaseType(p),\n visibility: convertActionVisibility(\n p.validation.defaultVisibility,\n ),\n ...p.defaultValue\n && { prefill: p.defaultValue },\n },\n validation: {\n allowedValues: extractAllowedValues(\n p.validation.allowedValues!,\n ),\n required: convertParameterRequirementConstraint(\n p.validation.required!,\n ),\n },\n },\n conditionalOverrides: p.validation.conditionalOverrides?.map(\n (override) =>\n convertActionParameterConditionalOverride(\n override,\n p.validation,\n action.parameters,\n ),\n ) ?? [],\n },\n ];\n }),\n ),\n sectionValidations: {\n ...Object.fromEntries(\n Object.entries(action.sections ?? {}).map((\n [sectionId, section],\n ) => [\n section.id,\n {\n defaultDisplayMetadata: section.defaultVisibility === \"hidden\"\n ? {\n visibility: {\n type: \"hidden\",\n hidden: {},\n },\n }\n : {\n visibility: {\n type: \"visible\",\n visible: {},\n },\n },\n conditionalOverrides: section.conditionalOverrides?.map(\n (override) =>\n convertSectionConditionalOverride(\n override,\n section.defaultVisibility ?? \"visible\",\n action.parameters,\n ),\n ) ?? [],\n },\n ]),\n ),\n },\n };\n}\n\nfunction convertParameterRequirementConstraint(\n required: ActionParameterRequirementConstraint,\n): ParameterRequiredConfiguration {\n if (typeof required === \"boolean\") {\n return required\n ? { type: \"required\", required: {} }\n : { type: \"notRequired\", notRequired: {} };\n }\n const { min, max } = required.listLength;\n return {\n type: \"listLengthValidation\",\n listLengthValidation: { minLength: min, maxLength: max },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SACEA,oBAAoB,EACpBC,sBAAsB,QACjB,6BAA6B;AACpC,SAASC,yCAAyC,QAAQ,gDAAgD;AAC1G,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,iCAAiC,QAAQ,wCAAwC;AAE1F,OAAO,SAASC,uBAAuBA,CACrCC,MAAkB,EACU;EAC5B,OAAO;IACLC,yBAAyB,EAAE;MACzBC,KAAK,EAAEC,MAAM,CAACC,WAAW,CACvB,CAACJ,MAAM,CAACK,UAAU,IACb,CAAC;QACFC,SAAS,EAAE;UAAEC,IAAI,EAAE,MAAM;UAAEC,IAAI,EAAE,CAAC;QAAE,CAAC;QACrCC,eAAe,EAAE;UAAEC,cAAc,EAAE,EAAE;UAAEC,WAAW,EAAE;QAAG;MACzD,CAAC,CAAC,EAAEC,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAK,CAACA,GAAG,EAAED,IAAI,CAAC,CACtC;IACF,CAAC;IACDE,oBAAoB,EAAEZ,MAAM,CAACC,WAAW,CACtC,CAACJ,MAAM,C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oB,EAAEM,OAAO,CAACN,oBAAoB,EAAEjB,GAAG,CACpDkB,QAAQ,IACPhC,iCAAiC,CAC/BgC,QAAQ,EACRK,OAAO,CAACZ,iBAAiB,IAAI,SAAS,EACtCvB,MAAM,CAACgB,UACT,CACJ,CAAC,IAAI;MACP,CAAC,CACF,CACH;IACF;EACF,CAAC;AACH;AAEA,SAASY,qCAAqCA,CAC5CD,QAA8C,EACd;EAChC,IAAI,OAAOA,QAAQ,KAAK,SAAS,EAAE;IACjC,OAAOA,QAAQ,GACX;MAAEpB,IAAI,EAAE,UAAU;MAAEoB,QAAQ,EAAE,CAAC;IAAE,CAAC,GAClC;MAAEpB,IAAI,EAAE,aAAa;MAAEgC,WAAW,EAAE,CAAC;IAAE,CAAC;EAC9C;EACA,MAAM;IAAEC,GAAG;IAAEC;EAAI,CAAC,GAAGd,QAAQ,CAACe,UAAU;EACxC,OAAO;IACLnC,IAAI,EAAE,sBAAsB;IAC5BoC,oBAAoB,EAAE;MAAEC,SAAS,EAAEJ,GAAG;MAAEK,SAAS,EAAEJ;IAAI;EACzD,CAAC;AACH","ignoreList":[]}
@@ -14,14 +14,15 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export function convertConditionDefinition(condition) {
17
+ import invariant from "tiny-invariant";
18
+ export function convertConditionDefinition(condition, actionParameters) {
18
19
  switch (condition.type) {
19
20
  case "and":
20
21
  if ("conditions" in condition) {
21
22
  return {
22
23
  type: "and",
23
24
  and: {
24
- conditions: condition.conditions.map(c => convertConditionDefinition(c))
25
+ conditions: condition.conditions.map(c => convertConditionDefinition(c, actionParameters))
25
26
  }
26
27
  };
27
28
  } else {
@@ -32,7 +33,7 @@ export function convertConditionDefinition(condition) {
32
33
  return {
33
34
  type: "or",
34
35
  or: {
35
- conditions: condition.conditions.map(c => convertConditionDefinition(c))
36
+ conditions: condition.conditions.map(c => convertConditionDefinition(c, actionParameters))
36
37
  }
37
38
  };
38
39
  } else {
@@ -68,6 +69,7 @@ export function convertConditionDefinition(condition) {
68
69
  }
69
70
  };
70
71
  case "parameter":
72
+ !actionParameters?.some(param => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant(false) : void 0;
71
73
  return {
72
74
  type: "comparison",
73
75
  comparison: {
@@ -1 +1 @@
1
- {"version":3,"file":"convertConditionDefinition.js","names":["convertConditionDefinition","condition","type","and","conditions","map","c","or","comparison","operator","left","userProperty","userId","currentUser","propertyValue","groupIds","right","staticValue","stringList","strings","name","parameterId","matches"],"sources":["convertConditionDefinition.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 { OntologyIrCondition } from \"@osdk/client.unstable\";\nimport type { ConditionDefinition } from \"../../api/action/ConditionDefinition.js\";\n\nexport function convertConditionDefinition(\n condition: ConditionDefinition,\n): OntologyIrCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertConditionDefinition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertConditionDefinition(c)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n userId: {\n type: \"currentUser\",\n currentUser: {},\n },\n propertyValue: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n },\n right: {\n type: \"staticValue\",\n staticValue: {\n type: \"stringList\",\n stringList: {\n strings: [\n condition.name,\n ],\n },\n },\n },\n },\n };\n case \"parameter\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"EQUALS\",\n left: {\n type: \"parameterId\",\n parameterId: condition.parameterId,\n },\n right: condition.matches,\n },\n };\n default:\n return condition;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASA,0BAA0BA,CACxCC,SAA8B,EACT;EACrB,QAAQA,SAAS,CAACC,IAAI;IACpB,KAAK,KAAK;MACR,IAAI,YAAY,IAAID,SAAS,EAAE;QAC7B,OAAO;UACLC,IAAI,EAAE,KAAK;UACXC,GAAG,EAAE;YACHC,UAAU,EAAEH,SAAS,CAACG,UAAU,CAACC,GAAG,CAACC,CAAC,IACpCN,0BAA0B,CAACM,CAAC,CAC9B;UACF;QACF,CAAC;MACH,CAAC,MAAM;QACL,OAAOL,SAAS;MAClB;IACF,KAAK,IAAI;MACP,IAAI,YAAY,IAAIA,SAAS,EAAE;QAC7B,OAAO;UACLC,IAAI,EAAE,IAAI;UACVK,EAAE,EAAE;YACFH,UAAU,EAAEH,SAAS,CAACG,UAAU,CAACC,GAAG,CAACC,CAAC,IACpCN,0BAA0B,CAACM,CAAC,CAC9B;UACF;QACF,CAAC;MACH,CAAC,MAAM;QACL,OAAOL,SAAS;MAClB;IACF,KAAK,OAAO;MACV,OAAO;QACLC,IAAI,EAAE,YAAY;QAClBM,UAAU,EAAE;UACVC,QAAQ,EAAE,YAAY;UACtBC,IAAI,EAAE;YACJR,IAAI,EAAE,cAAc;YACpBS,YAAY,EAAE;cACZC,MAAM,EAAE;gBACNV,IAAI,EAAE,aAAa;gBACnBW,WAAW,EAAE,CAAC;cAChB,CAAC;cACDC,aAAa,EAAE;gBACbZ,IAAI,EAAE,UAAU;gBAChBa,QAAQ,EAAE,CAAC;cACb;YACF;UACF,CAAC;UACDC,KAAK,EAAE;YACLd,IAAI,EAAE,aAAa;YACnBe,WAAW,EAAE;cACXf,IAAI,EAAE,YAAY;cAClBgB,UAAU,EAAE;gBACVC,OAAO,EAAE,CACPlB,SAAS,CAACmB,IAAI;cAElB;YACF;UACF;QACF;MACF,CAAC;IACH,KAAK,WAAW;MACd,OAAO;QACLlB,IAAI,EAAE,YAAY;QAClBM,UAAU,EAAE;UACVC,QAAQ,EAAE,QAAQ;UAClBC,IAAI,EAAE;YACJR,IAAI,EAAE,aAAa;YACnBmB,WAAW,EAAEpB,SAAS,CAACoB;UACzB,CAAC;UACDL,KAAK,EAAEf,SAAS,CAACqB;QACnB;MACF,CAAC;IACH;MACE,OAAOrB,SAAS;EACpB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"convertConditionDefinition.js","names":["invariant","convertConditionDefinition","condition","actionParameters","type","and","conditions","map","c","or","comparison","operator","left","userProperty","userId","currentUser","propertyValue","groupIds","right","staticValue","stringList","strings","name","some","param","id","parameterId","process","env","NODE_ENV","matches"],"sources":["convertConditionDefinition.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 { OntologyIrCondition } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { ActionParameter } from \"../../api/action/ActionParameter.js\";\nimport type { ConditionDefinition } from \"../../api/action/ConditionDefinition.js\";\n\nexport function convertConditionDefinition(\n condition: ConditionDefinition,\n actionParameters?: ActionParameter[],\n): OntologyIrCondition {\n switch (condition.type) {\n case \"and\":\n if (\"conditions\" in condition) {\n return {\n type: \"and\",\n and: {\n conditions: condition.conditions.map(c =>\n convertConditionDefinition(c, actionParameters)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"or\":\n if (\"conditions\" in condition) {\n return {\n type: \"or\",\n or: {\n conditions: condition.conditions.map(c =>\n convertConditionDefinition(c, actionParameters)\n ),\n },\n };\n } else {\n return condition;\n }\n case \"group\":\n return {\n type: \"comparison\",\n comparison: {\n operator: \"INTERSECTS\",\n left: {\n type: \"userProperty\",\n userProperty: {\n userId: {\n type: \"currentUser\",\n currentUser: {},\n },\n propertyValue: {\n type: \"groupIds\",\n groupIds: {},\n },\n },\n },\n right: {\n type: \"staticValue\",\n staticValue: {\n type: \"stringList\",\n stringList: {\n strings: [\n condition.name,\n ],\n },\n },\n },\n },\n };\n case \"parameter\":\n invariant(\n actionParameters?.some(param => param.id === condition.parameterId),\n `Action parameter condition references unknown parameter ${condition.parameterId}`,\n );\n return {\n type: \"comparison\",\n comparison: {\n operator: \"EQUALS\",\n left: {\n type: \"parameterId\",\n parameterId: condition.parameterId,\n },\n right: condition.matches,\n },\n };\n default:\n return condition;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAItC,OAAO,SAASC,0BAA0BA,CACxCC,SAA8B,EAC9BC,gBAAoC,EACf;EACrB,QAAQD,SAAS,CAACE,IAAI;IACpB,KAAK,KAAK;MACR,IAAI,YAAY,IAAIF,SAAS,EAAE;QAC7B,OAAO;UACLE,IAAI,EAAE,KAAK;UACXC,GAAG,EAAE;YACHC,UAAU,EAAEJ,SAAS,CAACI,UAAU,CAACC,GAAG,CAACC,CAAC,IACpCP,0BAA0B,CAACO,CAAC,EAAEL,gBAAgB,CAChD;UACF;QACF,CAAC;MACH,CAAC,MAAM;QACL,OAAOD,SAAS;MAClB;IACF,KAAK,IAAI;MACP,IAAI,YAAY,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5B,SAAS;EACpB;AACF","ignoreList":[]}
@@ -15,9 +15,10 @@
15
15
  */
16
16
 
17
17
  export function convertDatasourceDefinition(objectType, properties) {
18
- switch (objectType.datasource?.type) {
18
+ const baseDatasource = objectType.datasources?.find(ds => ["dataset", "stream", "restrictedView"].includes(ds.type));
19
+ switch (baseDatasource?.type) {
19
20
  case "stream":
20
- const window = objectType.datasource.retentionPeriod;
21
+ const window = baseDatasource.retentionPeriod;
21
22
  const retentionPolicy = window ? {
22
23
  type: "time",
23
24
  time: {
@@ -1 +1 @@
1
- {"version":3,"file":"convertDatasourceDefinition.js","names":["convertDatasourceDefinition","objectType","properties","datasource","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 OntologyIrObjectTypeDatasourceDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n switch (objectType.datasource?.type) {\n case \"stream\":\n const window = objectType.datasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"dataset\":\n default:\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,SAASA,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,QAAQD,UAAU,CAACE,UAAU,EAAEC,IAAI;IACjC,KAAK,QAAQ;MACX,MAAMC,MAAM,GAAGJ,UAAU,CAACE,UAAU,CAACG,eAAe;MACpD,MAAMC,eAAgC,GAAGF,MAAM,GAC3C;QAAED,IAAI,EAAE,MAAM;QAAEI,IAA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ACduB,MAAM,EAAE;UACNC,MAAM,EAAEd,IAAI,CAACC,OAAO;UACpBc,OAAO,EAAElB,MAAM,CAACC,WAAW,CACzBD,MAAM,CAACmB,IAAI,CAAChB,IAAI,CAACV,IAAI,CAAC2B,gBAAgB,CAAC,CAAClB,GAAG,CAAEmB,SAAS,IAAK,CACzDA,SAAS,EACT;YAAEjB,OAAO,EAAEiB,SAAS;YAAEC,QAAQ,EAAE,CAAC;UAAE,CAAC,CACrC,CACH;QACF;MACF,CAAC;MACD,OAAO,CAACnB,IAAI,CAACC,OAAO,EAAEW,aAAa,CAAC;IACtC;IACA;IACA,OAAO,CAACZ,IAAI,CAACC,OAAO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAEwB,MAAM,EAAEd,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"convertDatasourceDefinition.js","names":["convertDatasourceDefinition","objectType","properties","baseDatasource","datasources","find","ds","includes","type","window","retentionPeriod","retentionPolicy","time","none","propertyMapping","Object","fromEntries","map","prop","apiName","streamV2","streamLocator","propertySecurityGroups","undefined","restrictedViewV2","restrictedViewRid","buildPropertyMapping","datasetV2","datasetRid","editOnly","structMapping","struct","column","mapping","keys","structDefinition","fieldName","mappings"],"sources":["convertDatasourceDefinition.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 OntologyIrObjectTypeDatasourceDefinition,\n PropertyTypeMappingInfo,\n RetentionPolicy,\n} from \"@osdk/client.unstable\";\nimport type { ObjectPropertyType } from \"../../api/object/ObjectPropertyType.js\";\nimport type { ObjectType } from \"../../api/object/ObjectType.js\";\n\nexport function convertDatasourceDefinition(\n objectType: ObjectType,\n properties: ObjectPropertyType[],\n): OntologyIrObjectTypeDatasourceDefinition {\n const baseDatasource = objectType.datasources?.find(ds =>\n [\"dataset\", \"stream\", \"restrictedView\"].includes(ds.type)\n );\n switch (baseDatasource?.type) {\n case \"stream\":\n const window = baseDatasource.retentionPeriod;\n const retentionPolicy: RetentionPolicy = window\n ? { type: \"time\", time: { window } }\n : { type: \"none\", none: {} };\n const propertyMapping = Object.fromEntries(\n properties.map((\n prop,\n ) => [prop.apiName, prop.apiName]),\n );\n return {\n type: \"streamV2\",\n streamV2: {\n streamLocator: objectType.apiName,\n propertyMapping,\n retentionPolicy,\n propertySecurityGroups: undefined,\n },\n };\n case \"restrictedView\":\n return {\n type: \"restrictedViewV2\",\n restrictedViewV2: {\n restrictedViewRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n case \"dataset\":\n default:\n return {\n type: \"datasetV2\",\n datasetV2: {\n datasetRid: objectType.apiName,\n propertyMapping: buildPropertyMapping(properties),\n },\n };\n }\n}\n\nfunction buildPropertyMapping(\n properties: ObjectPropertyType[],\n): Record<string, PropertyTypeMappingInfo> {\n return Object.fromEntries(\n properties.map((prop) => {\n // editOnly\n if (prop.editOnly) {\n return [prop.apiName, { type: \"editOnly\", editOnly: {} }];\n }\n // structs\n if (typeof prop.type === \"object\" && prop.type?.type === \"struct\") {\n const structMapping = {\n type: \"struct\",\n struct: {\n column: prop.apiName,\n mapping: Object.fromEntries(\n Object.keys(prop.type.structDefinition).map((fieldName) => [\n fieldName,\n { apiName: fieldName, mappings: {} },\n ]),\n ),\n },\n };\n return [prop.apiName, structMapping];\n }\n // default: column mapping\n return [prop.apiName, { type: \"column\", column: prop.apiName }];\n }),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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wB,oBAAoBA,CAC3BxB,UAAgC,EACS;EACzC,OAAOa,MAAM,CAACC,WAAW,CACvBd,UAAU,CAACe,GAAG,CAAEC,IAAI,IAAK;IACvB;IACA,IAAIA,IAAI,CAACW,QAAQ,EAAE;MACjB,OAAO,CAACX,IAAI,CAACC,OAAO,EAAE;QAAEX,IAAI,EAAE,UAAU;QAAEqB,QAAQ,EAAE,CAAC;MAAE,CAAC,CAAC;IAC3D;IACA;IACA,IAAI,OAAOX,IAAI,CAACV,IAAI,KAAK,QAAQ,IAAIU,IAAI,CAACV,IAAI,EAAEA,IAAI,KAAK,QAAQ,EAAE;MACjE,MAAMsB,aAAa,GAAG;QACpBtB,IAAI,EAAE,QAAQ;QACduB,MAAM,EAAE;UACNC,MAAM,EAAEd,IAAI,CAACC,OAAO;UACpBc,OAAO,EAAElB,MAAM,CAACC,WAAW,CACzBD,MAAM,CAACmB,IAAI,CAAChB,IAAI,CAACV,IAAI,CAAC2B,gBAAgB,CAAC,CAAClB,GAAG,CAAEmB,SAAS,IAAK,CACzDA,SAAS,EACT;YAAEjB,OAAO,EAAEiB,SAAS;YAAEC,QAAQ,EAAE,CAAC;UAAE,CAAC,CACrC,CACH;QACF;MACF,CAAC;MACD,OAAO,CAACnB,IAAI,CAACC,OAAO,EAAEW,aAAa,CAAC;IACtC;IACA;IACA,OAAO,CAACZ,IAAI,CAACC,OAAO,EAAE;MAAEX,IAAI,EAAE,QAAQ;MAAEwB,MAAM,EAAEd,IAAI,CAACC;IAAQ,CAAC,CAAC;EACjE,CAAC,CACH,CAAC;AACH","ignoreList":[]}
@@ -14,72 +14,99 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { cleanAndValidateLinkTypeId } from "../../api/defineOntology.js";
17
+ import invariant from "tiny-invariant";
18
+ import { OntologyEntityTypeEnum } from "../../api/common/OntologyEntityTypeEnum.js";
19
+ import { cleanAndValidateLinkTypeId, ontologyDefinition } from "../../api/defineOntology.js";
18
20
  import { convertCardinality } from "./convertCardinality.js";
19
21
  export function convertLink(linkType) {
22
+ validateLink(linkType);
20
23
  let definition;
21
24
  let datasource = undefined;
22
25
  if ("one" in linkType) {
26
+ const {
27
+ apiName: oneObjectApiName,
28
+ object: oneObject
29
+ } = getObject(linkType.one.object);
30
+ const {
31
+ apiName: toManyObjectApiName,
32
+ object: toManyObject
33
+ } = getObject(linkType.toMany.object);
23
34
  definition = {
24
35
  type: "oneToMany",
25
36
  oneToMany: {
26
37
  cardinalityHint: convertCardinality(linkType.cardinality),
27
38
  manyToOneLinkMetadata: linkType.toMany.metadata,
28
- objectTypeRidManySide: linkType.toMany.object.apiName,
29
- objectTypeRidOneSide: linkType.one.object.apiName,
39
+ objectTypeRidManySide: toManyObjectApiName,
40
+ objectTypeRidOneSide: oneObjectApiName,
30
41
  oneToManyLinkMetadata: linkType.one.metadata,
31
42
  oneSidePrimaryKeyToManySidePropertyMapping: [{
32
43
  from: {
33
- apiName: linkType.one.object.primaryKeyPropertyApiName,
34
- object: linkType.one.object.apiName
44
+ apiName: oneObject.primaryKeyPropertyApiName,
45
+ object: oneObjectApiName
35
46
  },
36
47
  to: {
37
48
  apiName: linkType.manyForeignKeyProperty,
38
- object: linkType.toMany.object.apiName
49
+ object: toManyObjectApiName
39
50
  }
40
51
  }]
41
52
  }
42
53
  };
43
54
  } else if ("intermediaryObjectType" in linkType) {
55
+ const {
56
+ apiName: manyObjectApiName,
57
+ object: manyObject
58
+ } = getObject(linkType.many.object);
59
+ const {
60
+ apiName: toManyObjectApiName,
61
+ object: toManyObject
62
+ } = getObject(linkType.toMany.object);
44
63
  definition = {
45
64
  type: "intermediary",
46
65
  intermediary: {
47
66
  objectTypeAToBLinkMetadata: linkType.many.metadata,
48
67
  objectTypeBToALinkMetadata: linkType.toMany.metadata,
49
- objectTypeRidA: linkType.many.object.apiName,
50
- objectTypeRidB: linkType.toMany.object.apiName,
68
+ objectTypeRidA: manyObjectApiName,
69
+ objectTypeRidB: toManyObjectApiName,
51
70
  intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
52
71
  aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
53
72
  intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
54
73
  }
55
74
  };
56
75
  } else {
76
+ const {
77
+ apiName: manyObjectApiName,
78
+ object: manyObject
79
+ } = getObject(linkType.many.object);
80
+ const {
81
+ apiName: toManyObjectApiName,
82
+ object: toManyObject
83
+ } = getObject(linkType.toMany.object);
57
84
  definition = {
58
85
  type: "manyToMany",
59
86
  manyToMany: {
60
87
  objectTypeAToBLinkMetadata: linkType.many.metadata,
61
88
  objectTypeBToALinkMetadata: linkType.toMany.metadata,
62
- objectTypeRidA: linkType.many.object.apiName,
63
- objectTypeRidB: linkType.toMany.object.apiName,
89
+ objectTypeRidA: manyObjectApiName,
90
+ objectTypeRidB: toManyObjectApiName,
64
91
  peeringMetadata: undefined,
65
92
  objectTypeAPrimaryKeyPropertyMapping: [{
66
93
  from: {
67
- apiName: linkType.many.object.primaryKeyPropertyApiName,
68
- object: linkType.many.object.apiName
94
+ apiName: manyObject.primaryKeyPropertyApiName,
95
+ object: manyObjectApiName
69
96
  },
70
97
  to: {
71
- apiName: linkType.many.object.primaryKeyPropertyApiName,
72
- object: linkType.many.object.apiName
98
+ apiName: manyObject.primaryKeyPropertyApiName,
99
+ object: manyObjectApiName
73
100
  }
74
101
  }],
75
102
  objectTypeBPrimaryKeyPropertyMapping: [{
76
103
  from: {
77
- apiName: linkType.toMany.object.primaryKeyPropertyApiName,
78
- object: linkType.toMany.object.apiName
104
+ apiName: toManyObject.primaryKeyPropertyApiName,
105
+ object: toManyObjectApiName
79
106
  },
80
107
  to: {
81
- apiName: linkType.toMany.object.primaryKeyPropertyApiName,
82
- object: linkType.toMany.object.apiName
108
+ apiName: toManyObject.primaryKeyPropertyApiName,
109
+ object: toManyObjectApiName
83
110
  }
84
111
  }]
85
112
  }
@@ -93,17 +120,17 @@ export function convertLink(linkType) {
93
120
  writebackDatasetRid: undefined,
94
121
  objectTypeAPrimaryKeyMapping: [{
95
122
  property: {
96
- apiName: linkType.many.object.primaryKeyPropertyApiName,
97
- object: linkType.many.object.apiName
123
+ apiName: manyObject.primaryKeyPropertyApiName,
124
+ object: manyObjectApiName
98
125
  },
99
- column: linkType.many.object.primaryKeyPropertyApiName
126
+ column: manyObject.primaryKeyPropertyApiName
100
127
  }],
101
128
  objectTypeBPrimaryKeyMapping: [{
102
129
  property: {
103
- apiName: linkType.toMany.object.primaryKeyPropertyApiName,
104
- object: linkType.toMany.object.apiName
130
+ apiName: toManyObject.primaryKeyPropertyApiName,
131
+ object: toManyObjectApiName
105
132
  },
106
- column: linkType.toMany.object.primaryKeyPropertyApiName
133
+ column: toManyObject.primaryKeyPropertyApiName
107
134
  }]
108
135
  }
109
136
  },
@@ -129,4 +156,62 @@ export function convertLink(linkType) {
129
156
  }
130
157
  };
131
158
  }
159
+ function validateLink(linkDefinition) {
160
+ if ("one" in linkDefinition) {
161
+ const {
162
+ apiName: oneObjectApiName,
163
+ object: oneObject
164
+ } = getObject(linkDefinition.one.object);
165
+ const {
166
+ apiName: toManyObjectApiName,
167
+ object: toManyObject
168
+ } = getObject(linkDefinition.toMany.object);
169
+ const foreignKey = toManyObject.properties?.find(p => p.apiName === linkDefinition.manyForeignKeyProperty);
170
+ !(foreignKey !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant(false) : void 0;
171
+ !/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant(false) : void 0;
172
+ const typesMatch = foreignKey.type === oneObject.properties?.find(p => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
173
+ !typesMatch ? process.env.NODE_ENV !== "production" ? invariant(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant(false) : void 0;
174
+ }
175
+ if ("intermediaryObjectType" in linkDefinition) {
176
+ const {
177
+ apiName: intermediaryObjectTypeApiName,
178
+ object: intermediaryObjectType
179
+ } = getObject(linkDefinition.intermediaryObjectType);
180
+ const {
181
+ apiName: manyObjectApiName,
182
+ object: manyObject
183
+ } = getObject(linkDefinition.many.object);
184
+ const {
185
+ apiName: toManyObjectApiName,
186
+ object: toManyObject
187
+ } = getObject(linkDefinition.toMany.object);
188
+ const {
189
+ apiName: manyIntermediaryOneObjectApiName,
190
+ object: manyIntermediaryOneObject
191
+ } = getObject(linkDefinition.many.linkToIntermediary.one.object);
192
+ const {
193
+ apiName: manyIntermediaryToManyObjectApiName,
194
+ object: manyIntermediaryToManyObject
195
+ } = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
196
+ !("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant(false) : void 0;
197
+ const {
198
+ apiName: toManyIntermediaryOneObjectApiName,
199
+ object: toManyIntermediaryOneObject
200
+ } = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
201
+ const {
202
+ apiName: toManyIntermediaryToManyObjectApiName,
203
+ object: toManyIntermediaryToManyObject
204
+ } = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
205
+ !("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant(false) : void 0;
206
+ }
207
+ }
208
+ export function getObject(object) {
209
+ const objectApiName = typeof object === "string" ? object : object.apiName;
210
+ const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
211
+ !(fullObject !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object ${objectApiName} is not defined`) : invariant(false) : void 0;
212
+ return {
213
+ apiName: objectApiName,
214
+ object: fullObject
215
+ };
216
+ }
132
217
  //# sourceMappingURL=convertLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertLink.js","names":["cleanAndValidateLinkTypeId","convertCardinality","convertLink","linkType","definition","datasource","undefined","type","oneToMany","cardinalityHint","cardinality","manyToOneLinkMetadata","toMany","metadata","objectTypeRidManySide","object","apiName","objectTypeRidOneSide","one","oneToManyLinkMetadata","oneSidePrimaryKeyToManySidePropertyMapping","from","primaryKeyPropertyApiName","to","manyForeignKeyProperty","intermediary","objectTypeAToBLinkMetadata","many","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","active","datasources","entityMetadata","arePatchesEnabled","editsEnabled"],"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 OntologyIrManyToManyLinkTypeDatasource,\n} from \"@osdk/client.unstable\";\nimport { cleanAndValidateLinkTypeId } from \"../../api/defineOntology.js\";\nimport type { LinkType } from \"../../api/links/LinkType.js\";\nimport { convertCardinality } from \"./convertCardinality.js\";\n\nexport function convertLink(\n linkType: LinkType,\n): OntologyIrLinkTypeBlockDataV2 {\n let definition: OntologyIrLinkDefinition;\n let datasource: OntologyIrManyToManyLinkTypeDatasource | undefined =\n undefined;\n if (\"one\" in linkType) {\n definition = {\n type: \"oneToMany\",\n oneToMany: {\n cardinalityHint: convertCardinality(linkType.cardinality),\n manyToOneLinkMetadata: linkType.toMany.metadata,\n objectTypeRidManySide: linkType.toMany.object.apiName,\n objectTypeRidOneSide: linkType.one.object.apiName,\n oneToManyLinkMetadata: linkType.one.metadata,\n oneSidePrimaryKeyToManySidePropertyMapping: [{\n from: {\n apiName: linkType.one.object.primaryKeyPropertyApiName,\n object: linkType.one.object.apiName,\n },\n to: {\n apiName: linkType.manyForeignKeyProperty,\n object: linkType.toMany.object.apiName,\n },\n }],\n },\n };\n } else if (\"intermediaryObjectType\" in linkType) {\n definition = {\n type: \"intermediary\",\n intermediary: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: linkType.many.object.apiName,\n objectTypeRidB: linkType.toMany.object.apiName,\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 definition = {\n type: \"manyToMany\",\n manyToMany: {\n objectTypeAToBLinkMetadata: linkType.many.metadata,\n objectTypeBToALinkMetadata: linkType.toMany.metadata,\n objectTypeRidA: linkType.many.object.apiName,\n objectTypeRidB: linkType.toMany.object.apiName,\n peeringMetadata: undefined,\n objectTypeAPrimaryKeyPropertyMapping: [{\n from: {\n apiName: linkType.many.object.primaryKeyPropertyApiName,\n object: linkType.many.object.apiName,\n },\n to: {\n apiName: linkType.many.object.primaryKeyPropertyApiName,\n object: linkType.many.object.apiName,\n },\n }],\n objectTypeBPrimaryKeyPropertyMapping: [{\n from: {\n apiName: linkType.toMany.object.primaryKeyPropertyApiName,\n object: linkType.toMany.object.apiName,\n },\n to: {\n apiName: linkType.toMany.object.primaryKeyPropertyApiName,\n object: linkType.toMany.object.apiName,\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: linkType.many.object.primaryKeyPropertyApiName,\n object: linkType.many.object.apiName,\n },\n column: linkType.many.object.primaryKeyPropertyApiName,\n }],\n objectTypeBPrimaryKeyMapping: [{\n property: {\n apiName: linkType.toMany.object.primaryKeyPropertyApiName,\n object: linkType.toMany.object.apiName,\n },\n column: linkType.toMany.object.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: linkType.status ?? { type: \"active\", active: {} },\n redacted: linkType.redacted ?? false,\n },\n datasources: datasource !== undefined ? [datasource] : [],\n entityMetadata: {\n arePatchesEnabled: linkType.editsEnabled ?? false,\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA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MAAM,EAAE,CAAC;MAAE,CAAC;MACzDH,QAAQ,EAAEhD,QAAQ,CAACgD,QAAQ,IAAI;IACjC,CAAC;IACDI,WAAW,EAAElD,UAAU,KAAKC,SAAS,GAAG,CAACD,UAAU,CAAC,GAAG,EAAE;IACzDmD,cAAc,EAAE;MACdC,iBAAiB,EAAEtD,QAAQ,CAACuD,YAAY,IAAI;IAC9C;EACF,CAAC;AACH","ignoreList":[]}
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","active","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"],"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 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 } 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: linkType.status ?? { type: \"active\", active: {} },\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"],"mapp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