@osdk/maker 0.14.0-beta.1 → 0.14.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/README.md +86 -22
- package/build/browser/api/action/DefaultFormat.js +2 -0
- package/build/browser/api/action/DefaultFormat.js.map +1 -0
- package/build/browser/api/action/TableConfiguration.js +2 -0
- package/build/browser/api/action/TableConfiguration.js.map +1 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +91 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/browser/api/code-snippets/snippetTypes.js +60 -0
- package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/browser/api/defineAction.js +131 -414
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +85 -0
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateObjectAction.js +80 -0
- package/build/browser/api/defineCreateObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js +95 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineDeleteObjectAction.js +56 -0
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
- package/build/browser/api/defineLink.js +5 -13
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +84 -0
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineModifyObjectAction.js +93 -0
- package/build/browser/api/defineModifyObjectAction.js.map +1 -0
- package/build/browser/api/defineObject.js +94 -3
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +5 -1
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/api/test/actions.test.js +12034 -0
- package/build/browser/api/test/actions.test.js.map +1 -0
- package/build/browser/api/test/interfaces.test.js +924 -0
- package/build/browser/api/test/interfaces.test.js.map +1 -0
- package/build/browser/api/test/links.test.js +1974 -0
- package/build/browser/api/test/links.test.js.map +1 -0
- package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/browser/api/test/markingconstraint.test.js.map +1 -0
- package/build/browser/api/test/misc.test.js +1058 -0
- package/build/browser/api/test/misc.test.js.map +1 -0
- package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/browser/api/test/objectStatus.test.js.map +1 -0
- package/build/browser/api/test/objects.test.js +2591 -0
- package/build/browser/api/test/objects.test.js.map +1 -0
- package/build/browser/api/test/spt.test.js +387 -0
- package/build/browser/api/test/spt.test.js.map +1 -0
- package/build/browser/api/test/valueTypes.test.js +156 -0
- package/build/browser/api/test/valueTypes.test.js.map +1 -0
- package/build/browser/cli/main.js +23 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +2 -16
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +4 -4
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +109 -24
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObject.js +81 -4
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/browser/index.js +8 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +1293 -832
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +184 -115
- package/build/esm/api/action/DefaultFormat.js +2 -0
- package/build/esm/api/action/DefaultFormat.js.map +1 -0
- package/build/esm/api/action/TableConfiguration.js +2 -0
- package/build/esm/api/action/TableConfiguration.js.map +1 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +91 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/esm/api/code-snippets/snippetTypes.js +60 -0
- package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/esm/api/defineAction.js +131 -414
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +85 -0
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateObjectAction.js +80 -0
- package/build/esm/api/defineCreateObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js +95 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineDeleteObjectAction.js +56 -0
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
- package/build/esm/api/defineLink.js +5 -13
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +84 -0
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineModifyObjectAction.js +93 -0
- package/build/esm/api/defineModifyObjectAction.js.map +1 -0
- package/build/esm/api/defineObject.js +94 -3
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +5 -1
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/api/test/actions.test.js +12034 -0
- package/build/esm/api/test/actions.test.js.map +1 -0
- package/build/esm/api/test/interfaces.test.js +924 -0
- package/build/esm/api/test/interfaces.test.js.map +1 -0
- package/build/esm/api/test/links.test.js +1974 -0
- package/build/esm/api/test/links.test.js.map +1 -0
- package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/esm/api/test/markingconstraint.test.js.map +1 -0
- package/build/esm/api/test/misc.test.js +1058 -0
- package/build/esm/api/test/misc.test.js.map +1 -0
- package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/esm/api/test/objectStatus.test.js.map +1 -0
- package/build/esm/api/test/objects.test.js +2591 -0
- package/build/esm/api/test/objects.test.js.map +1 -0
- package/build/esm/api/test/spt.test.js +387 -0
- package/build/esm/api/test/spt.test.js.map +1 -0
- package/build/esm/api/test/valueTypes.test.js +156 -0
- package/build/esm/api/test/valueTypes.test.js.map +1 -0
- package/build/esm/cli/main.js +23 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +2 -16
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +4 -4
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +109 -24
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObject.js +81 -4
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/esm/index.js +8 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/api/action/DefaultFormat.d.ts +1 -0
- package/build/types/api/action/DefaultFormat.d.ts.map +1 -0
- package/build/types/api/action/TableConfiguration.d.ts +8 -0
- package/build/types/api/action/TableConfiguration.d.ts.map +1 -0
- package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
- package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts +23 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +34 -10
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +1 -1
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/links/LinkType.d.ts +7 -7
- package/build/types/api/object/ObjectType.d.ts +1 -1
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +41 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/api/test/actions.test.d.ts.map +1 -0
- package/build/types/api/test/interfaces.test.d.ts.map +1 -0
- package/build/types/api/test/links.test.d.ts.map +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
- package/build/types/api/test/misc.test.d.ts +1 -0
- package/build/types/api/test/misc.test.d.ts.map +1 -0
- package/build/types/api/test/objectStatus.test.d.ts +1 -0
- package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
- package/build/types/api/test/objects.test.d.ts +1 -0
- package/build/types/api/test/objects.test.d.ts.map +1 -0
- package/build/types/api/test/spt.test.d.ts +1 -0
- package/build/types/api/test/spt.test.d.ts.map +1 -0
- package/build/types/api/test/valueTypes.test.d.ts +1 -0
- package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +2 -2
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts +0 -1
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -1
- package/build/types/index.d.ts +8 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +8 -5
- package/build/browser/api/markingconstraint.test.js.map +0 -1
- package/build/browser/api/objectStatus.test.js.map +0 -1
- package/build/browser/api/overall.test.js +0 -14002
- package/build/browser/api/overall.test.js.map +0 -1
- package/build/esm/api/markingconstraint.test.js.map +0 -1
- package/build/esm/api/objectStatus.test.js.map +0 -1
- package/build/esm/api/overall.test.js +0 -14002
- package/build/esm/api/overall.test.js.map +0 -1
- package/build/types/api/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/overall.test.d.ts.map +0 -1
- /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
- /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
- /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
|
@@ -24,7 +24,7 @@ import { defineOntology } from "../api/defineOntology.js";
|
|
|
24
24
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
25
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.14.0-beta.
|
|
27
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.11" ?? "").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
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, commandLineOpts.randomnessKey);
|
|
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, randomnessKey) {
|
|
96
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
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","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","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 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 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 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.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 randomnessKey?: string,\n) {\n const q = await defineOntology(\n apiNamespace,\n async () => await import(input),\n outputDir,\n depend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;EACD,OAAOiB,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;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;AAC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ACZ,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
|
}
|
package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertActionParameterConditionalOverride.js","names":["extractAllowedValues","convertConditionDefinition","convertActionParameterConditionalOverride","override","validation","
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASA,oBAAoB,QAAQ,6BAA6B;AAClE,SAASC,0BAA0B,QAAQ,iCAAiC;AAE5E,OAAO,SAASC,yCAAyCA,CACvDC,QAA4C,EAC5CC,UAAqC,EACrCC,gBAAoC,EACL;EAC/B,IAAIC,sBAAkE;EACtE,QAAQH,QAAQ,CAACI,IAAI;IACnB,KAAK,UAAU;MACbD,sBAAsB,GAAG;QACvBC,IAAI,EAAE,mBAAmB;QACzBC,iBAAiB,EAAE;UACjBC,QAAQ,EAAEL,UAAU,CAACK,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,EAAEP,UAAU,CAACQ,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,EAAEP,UAAU,CAACQ,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,EAAEb,QAAQ,CAACc;QACpB;MACF,CAAC;MACD;IACF,KAAK,YAAY;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
|
};
|
|
@@ -90,18 +90,4 @@ function convertParameterRequirementConstraint(required) {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
export function getActionTypeObjectParameters(actionType) {
|
|
94
|
-
switch (actionType.rules[0].type) {
|
|
95
|
-
case "addObjectRule":
|
|
96
|
-
return Object.keys(actionType.rules[0].addObjectRule.propertyValues);
|
|
97
|
-
case "modifyObjectRule":
|
|
98
|
-
return Object.keys(actionType.rules[0].modifyObjectRule.propertyValues);
|
|
99
|
-
case "addOrModifyObjectRuleV2":
|
|
100
|
-
return Object.keys(actionType.rules[0].addOrModifyObjectRuleV2.propertyValues);
|
|
101
|
-
case "deleteObjectRule":
|
|
102
|
-
return [];
|
|
103
|
-
default:
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
93
|
//# sourceMappingURL=convertActionValidation.js.map
|
|
@@ -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","
|
|
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,O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CAACC,WAAW,CACnBD,MAAM,CAAC6B,OAAO,CAAChC,MAAM,CAACiC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAACrB,GAAG,CAAC,CACxC,CAACsB,SAAS,EAAEC,OAAO,CAAC,KACjB,CACHA,OAAO,CAACjB,EAAE,EACV;QACEkB,sBAAsB,EAAED,OAAO,CAACZ,iBAAiB,KAAK,QAAQ,GAC1D;UACAD,UAAU,EAAE;YACVf,IAAI,EAAE,QAAQ;YACd8B,MAAM,EAAE,CAAC;UACX;QACF,CAAC,GACC;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,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":[]}
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
-
export function convertConditionDefinition(condition,
|
|
18
|
+
export function convertConditionDefinition(condition, actionParameters) {
|
|
19
19
|
switch (condition.type) {
|
|
20
20
|
case "and":
|
|
21
21
|
if ("conditions" in condition) {
|
|
22
22
|
return {
|
|
23
23
|
type: "and",
|
|
24
24
|
and: {
|
|
25
|
-
conditions: condition.conditions.map(c => convertConditionDefinition(c,
|
|
25
|
+
conditions: condition.conditions.map(c => convertConditionDefinition(c, actionParameters))
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
} else {
|
|
@@ -33,7 +33,7 @@ export function convertConditionDefinition(condition, objectProperties) {
|
|
|
33
33
|
return {
|
|
34
34
|
type: "or",
|
|
35
35
|
or: {
|
|
36
|
-
conditions: condition.conditions.map(c => convertConditionDefinition(c,
|
|
36
|
+
conditions: condition.conditions.map(c => convertConditionDefinition(c, actionParameters))
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
} else {
|
|
@@ -69,7 +69,7 @@ export function convertConditionDefinition(condition, objectProperties) {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
case "parameter":
|
|
72
|
-
!
|
|
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;
|
|
73
73
|
return {
|
|
74
74
|
type: "comparison",
|
|
75
75
|
comparison: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertConditionDefinition.js","names":["invariant","convertConditionDefinition","condition","
|
|
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;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H,KAAK,WAAW;MACd,CACEnB,gBAAgB,EAAEoB,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACC,EAAE,KAAKvB,SAAS,CAACwB,WAAW,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADrE7B,SAAS,QAEP,2DAA2DE,SAAS,CAACwB,WAAW,EAAE,IAFpF1B,SAAS;MAIT,OAAO;QACLI,IAAI,EAAE,YAAY;QAClBM,UAAU,EAAE;UACVC,QAAQ,EAAE,QAAQ;UAClBC,IAAI,EAAE;YACJR,IAAI,EAAE,aAAa;YACnBsB,WAAW,EAAExB,SAAS,CAACwB;UACzB,CAAC;UACDR,KAAK,EAAEhB,SAAS,CAAC4B;QACnB;MACF,CAAC;IACH;MACE,OAAO5B,SAAS;EACpB;AACF","ignoreList":[]}
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export function convertDatasourceDefinition(objectType, properties) {
|
|
18
|
-
|
|
18
|
+
const baseDatasource = objectType.datasources?.find(ds => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
19
|
+
switch (baseDatasource?.type) {
|
|
19
20
|
case "stream":
|
|
20
|
-
const window =
|
|
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","
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAO,SAASA,2BAA2BA,CACzCC,UAAsB,EACtBC,UAAgC,EACU;EAC1C,MAAMC,cAAc,GAAGF,UAAU,CAACG,WAAW,EAAEC,IAAI,CAACC,EAAE,IACpD,CAAC,SAAS,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAACC,QAAQ,CAACD,EAAE,CAACE,IAAI,CAC1D,CAAC;EACD,QAAQL,cAAc,EAAEK,IAAI;IAC1B,KAAK,QAAQ;MACX,MAAMC,MAAM,GAAGN,cAAc,CAACO,eAAe;MAC7C,MAAMC,eAAgC,GAAGF,MAAM,GAC3C;QAAED,IAAI,EAAE,MAAM;QAAEI,IAAI,EAAE;UAAEH;QAAO;MAAE,CAAC,GAClC;QAAED,IAAI,EAAE,MAAM;QAAEK,IAAI,EAAE,CAAC;MAAE,CAAC;MAC9B,MAAMC,eAAe,GAAGC,MAAM,CAACC,WAAW,CACxCd,UAAU,CAACe,GAAG,CACZC,IAAI,IACD,CAACA,IAAI,CAACC,OAAO,EAAED,IAAI,CAACC,OAAO,CAAC,CACnC,CAAC;MACD,OAAO;QACLX,IAAI,EAAE,UAAU;QAChBY,QAAQ,EAAE;UACRC,aAAa,EAAEpB,UAAU,CAACkB,OAAO;UACjCL,eAAe;UACfH,eAAe;UACfW,sBAAsB,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O,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
|
|
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:
|
|
29
|
-
objectTypeRidOneSide:
|
|
39
|
+
objectTypeRidManySide: toManyObjectApiName,
|
|
40
|
+
objectTypeRidOneSide: oneObjectApiName,
|
|
30
41
|
oneToManyLinkMetadata: linkType.one.metadata,
|
|
31
42
|
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
32
43
|
from: {
|
|
33
|
-
apiName:
|
|
34
|
-
object:
|
|
44
|
+
apiName: oneObject.primaryKeyPropertyApiName,
|
|
45
|
+
object: oneObjectApiName
|
|
35
46
|
},
|
|
36
47
|
to: {
|
|
37
48
|
apiName: linkType.manyForeignKeyProperty,
|
|
38
|
-
object:
|
|
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:
|
|
50
|
-
objectTypeRidB:
|
|
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:
|
|
63
|
-
objectTypeRidB:
|
|
89
|
+
objectTypeRidA: manyObjectApiName,
|
|
90
|
+
objectTypeRidB: toManyObjectApiName,
|
|
64
91
|
peeringMetadata: undefined,
|
|
65
92
|
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
66
93
|
from: {
|
|
67
|
-
apiName:
|
|
68
|
-
object:
|
|
94
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
95
|
+
object: manyObjectApiName
|
|
69
96
|
},
|
|
70
97
|
to: {
|
|
71
|
-
apiName:
|
|
72
|
-
object:
|
|
98
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
99
|
+
object: manyObjectApiName
|
|
73
100
|
}
|
|
74
101
|
}],
|
|
75
102
|
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
76
103
|
from: {
|
|
77
|
-
apiName:
|
|
78
|
-
object:
|
|
104
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
105
|
+
object: toManyObjectApiName
|
|
79
106
|
},
|
|
80
107
|
to: {
|
|
81
|
-
apiName:
|
|
82
|
-
object:
|
|
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:
|
|
97
|
-
object:
|
|
123
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
124
|
+
object: manyObjectApiName
|
|
98
125
|
},
|
|
99
|
-
column:
|
|
126
|
+
column: manyObject.primaryKeyPropertyApiName
|
|
100
127
|
}],
|
|
101
128
|
objectTypeBPrimaryKeyMapping: [{
|
|
102
129
|
property: {
|
|
103
|
-
apiName:
|
|
104
|
-
object:
|
|
130
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
131
|
+
object: toManyObjectApiName
|
|
105
132
|
},
|
|
106
|
-
column:
|
|
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
|