@osdk/maker 0.13.0-beta.12 → 0.13.0-beta.14
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 +22 -0
- package/README.md +49 -13
- package/build/browser/api/defineAction.js +30 -30
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineLink.js +30 -9
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineOntology.js +1 -1
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/overall.test.js +1798 -695
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/cli/main.js +10 -1
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +14 -1
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +2 -2
- package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -1
- package/build/cjs/index.cjs +87 -44
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +38 -3
- package/build/esm/api/defineAction.js +30 -30
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineLink.js +30 -9
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineOntology.js +1 -1
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/overall.test.js +1798 -695
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/cli/main.js +10 -1
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +14 -1
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js +2 -2
- package/build/esm/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map +1 -1
- package/build/types/api/defineAction.d.ts +8 -2
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineLink.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 +29 -0
- package/build/types/api/links/LinkType.d.ts.map +1 -1
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.d.ts.map +1 -1
- package/package.json +6 -5
|
@@ -18,12 +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";
|
|
21
22
|
import yargs from "yargs";
|
|
22
23
|
import { hideBin } from "yargs/helpers";
|
|
23
24
|
import { defineOntology } from "../api/defineOntology.js";
|
|
24
25
|
const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
25
26
|
export default async function main(args = process.argv) {
|
|
26
|
-
const commandLineOpts = await yargs(hideBin(args)).version("0.13.0-beta.
|
|
27
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.13.0-beta.14" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
27
28
|
input: {
|
|
28
29
|
alias: "i",
|
|
29
30
|
describe: "Input file",
|
|
@@ -66,6 +67,11 @@ export default async function main(args = process.argv) {
|
|
|
66
67
|
describe: "File to write dependencies to",
|
|
67
68
|
type: "string",
|
|
68
69
|
coerce: path.resolve
|
|
70
|
+
},
|
|
71
|
+
randomnessKey: {
|
|
72
|
+
describe: "Value used to assure uniqueness of entities",
|
|
73
|
+
type: "string",
|
|
74
|
+
coerce: path.resolve
|
|
69
75
|
}
|
|
70
76
|
}).parseAsync();
|
|
71
77
|
let apiNamespace = "";
|
|
@@ -75,6 +81,9 @@ export default async function main(args = process.argv) {
|
|
|
75
81
|
!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;
|
|
76
82
|
}
|
|
77
83
|
consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
84
|
+
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;
|
|
86
|
+
}
|
|
78
87
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
|
|
79
88
|
consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
80
89
|
await fs.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","names":["consola","fs","path","invariant","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","parseAsync","length","slice","env","NODE_ENV","test","info","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-]+)*\\.$/;\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 } = 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 })\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 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,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,
|
|
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 out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@ export function convertLink(linkType) {
|
|
|
40
40
|
}]
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
44
|
+
definition = {
|
|
45
|
+
type: "intermediary",
|
|
46
|
+
intermediary: {
|
|
47
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
48
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
49
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
50
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
51
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
52
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
53
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
54
|
+
}
|
|
55
|
+
};
|
|
43
56
|
} else {
|
|
44
57
|
definition = {
|
|
45
58
|
type: "manyToMany",
|
|
@@ -72,7 +85,7 @@ export function convertLink(linkType) {
|
|
|
72
85
|
}
|
|
73
86
|
};
|
|
74
87
|
datasource = {
|
|
75
|
-
|
|
88
|
+
datasourceName: linkType.apiName,
|
|
76
89
|
datasource: {
|
|
77
90
|
type: "dataset",
|
|
78
91
|
dataset: {
|
|
@@ -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","
|
|
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,0BAA0B,QAAQ,6BAA6B;AAExE,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,OAAO,SAASC,WAAWA,CACzBC,QAAkB,EACa;EAC/B,IAAIC,UAAoC;EACxC,IAAIC,UAA8D,GAChEC,SAAS;EACX,IAAI,KAAK,IAAIH,QAAQ,EAAE;IACrBC,UAAU,GAAG;MACXG,IAAI,EAAE,WAAW;MACjBC,SAAS,EAAE;QACTC,eAAe,EAAER,kBAAkB,CAACE,QAAQ,CAACO,WAAW,CAAC;QACzDC,qBAAqB,EAAER,QAAQ,CAACS,MAAM,CAACC,QAAQ;QAC/CC,qBAAqB,EAAEX,QAAQ,CAACS,MAAM,CAACG,MAAM,CAACC,OAAO;QACrDC,oBAAoB,EAAEd,QAAQ,CAACe,GAAG,CAACH,MAAM,CAACC,OAAO;QACjDG,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Q,CAACwB,IAAI,CAACZ,MAAM,CAACC;YAC/B,CAAC;YACD+B,MAAM,EAAE5C,QAAQ,CAACwB,IAAI,CAACZ,MAAM,CAACO;UAC/B,CAAC,CAAC;UACF0B,4BAA4B,EAAE,CAAC;YAC7BF,QAAQ,EAAE;cACR9B,OAAO,EAAEb,QAAQ,CAACS,MAAM,CAACG,MAAM,CAACO,yBAAyB;cACzDP,MAAM,EAAEZ,QAAQ,CAACS,MAAM,CAACG,MAAM,CAACC;YACjC,CAAC;YACD+B,MAAM,EAAE5C,QAAQ,CAACS,MAAM,CAACG,MAAM,CAACO;UACjC,CAAC;QACH;MACF,CAAC;MACD2B,kBAAkB,EAAE;QAClBC,wBAAwB,EAAE;MAC5B,CAAC;MACDC,QAAQ,EAAEhD,QAAQ,CAACgD;IACrB,CAAC;EACH;EAEA,OAAO;IACLhD,QAAQ,EAAE;MACRC,UAAU,EAAEA,UAAU;MACtBgD,EAAE,EAAEpD,0BAA0B,CAACG,QAAQ,CAACa,OAAO,CAAC;MAChDqC,MAAM,EAAElD,QAAQ,CAACkD,MAAM,IAAI;QAAE9C,IAAI,EAAE,QAAQ;QAAE+C,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":[]}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { OntologyEntityTypeEnum } from "../../api/common/OntologyEntityTypeEnum.js";
|
|
18
|
-
import { convertAction } from "../../api/defineOntology.js";
|
|
18
|
+
import { cleanAndValidateLinkTypeId, convertAction } from "../../api/defineOntology.js";
|
|
19
19
|
import { convertInterface } from "./convertInterface.js";
|
|
20
20
|
import { convertLink } from "./convertLink.js";
|
|
21
21
|
import { convertObject } from "./convertObject.js";
|
|
@@ -34,7 +34,7 @@ export function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
|
34
34
|
}];
|
|
35
35
|
})),
|
|
36
36
|
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
37
|
-
return [id, convertLink(link)];
|
|
37
|
+
return [cleanAndValidateLinkTypeId(id), convertLink(link)];
|
|
38
38
|
})),
|
|
39
39
|
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
40
40
|
return [apiName, convertAction(action)];
|
package/build/browser/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertOntologyDefinitionToWireBlockData.js","names":["OntologyEntityTypeEnum","convertAction","convertInterface","convertLink","convertObject","convertSpt","convertOntologyDefinitionToWireBlockData","ontology","objectTypes","Object","fromEntries","entries","OBJECT_TYPE","map","apiName","objectType","sharedPropertyTypes","SHARED_PROPERTY_TYPE","spt","sharedPropertyType","interfaceTypes","INTERFACE_TYPE","interfaceType","linkTypes","LINK_TYPE","id","link","actionTypes","ACTION_TYPE","action","blockPermissionInformation","filter","validation","restrictionStatus","hasRolesApplied","ontologyPackageRid","publicProject"],"sources":["convertOntologyDefinitionToWireBlockData.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 ActionTypePermissionInformation,\n OntologyIrActionTypeBlockDataV2,\n OntologyIrInterfaceTypeBlockDataV2,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrObjectTypeBlockDataV2,\n OntologyIrOntologyBlockDataV2,\n OntologyIrSharedPropertyTypeBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport { type OntologyDefinition } from \"../../api/common/OntologyDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"convertOntologyDefinitionToWireBlockData.js","names":["OntologyEntityTypeEnum","cleanAndValidateLinkTypeId","convertAction","convertInterface","convertLink","convertObject","convertSpt","convertOntologyDefinitionToWireBlockData","ontology","objectTypes","Object","fromEntries","entries","OBJECT_TYPE","map","apiName","objectType","sharedPropertyTypes","SHARED_PROPERTY_TYPE","spt","sharedPropertyType","interfaceTypes","INTERFACE_TYPE","interfaceType","linkTypes","LINK_TYPE","id","link","actionTypes","ACTION_TYPE","action","blockPermissionInformation","filter","validation","restrictionStatus","hasRolesApplied","ontologyPackageRid","publicProject"],"sources":["convertOntologyDefinitionToWireBlockData.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 ActionTypePermissionInformation,\n OntologyIrActionTypeBlockDataV2,\n OntologyIrInterfaceTypeBlockDataV2,\n OntologyIrLinkTypeBlockDataV2,\n OntologyIrObjectTypeBlockDataV2,\n OntologyIrOntologyBlockDataV2,\n OntologyIrSharedPropertyTypeBlockDataV2,\n} from \"@osdk/client.unstable\";\nimport { type OntologyDefinition } from \"../../api/common/OntologyDefinition.js\";\nimport { OntologyEntityTypeEnum } from \"../../api/common/OntologyEntityTypeEnum.js\";\nimport {\n cleanAndValidateLinkTypeId,\n convertAction,\n} from \"../../api/defineOntology.js\";\nimport { convertInterface } from \"./convertInterface.js\";\nimport { convertLink } from \"./convertLink.js\";\nimport { convertObject } from \"./convertObject.js\";\nimport { convertSpt } from \"./convertSpt.js\";\n\nexport function convertOntologyDefinitionToWireBlockData(\n ontology: OntologyDefinition,\n): OntologyIrOntologyBlockDataV2 {\n return ({\n objectTypes: Object.fromEntries(\n Object.entries(ontology[OntologyEntityTypeEnum.OBJECT_TYPE]).map<\n [string, OntologyIrObjectTypeBlockDataV2]\n >(([apiName, objectType]) => {\n return [apiName, convertObject(objectType)];\n }),\n ),\n sharedPropertyTypes: Object.fromEntries(\n Object.entries(\n ontology[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE],\n )\n .map<[string, OntologyIrSharedPropertyTypeBlockDataV2]>((\n [apiName, spt],\n ) => [apiName, { sharedPropertyType: convertSpt(spt) }]),\n ),\n interfaceTypes: Object.fromEntries(\n Object.entries(\n ontology[OntologyEntityTypeEnum.INTERFACE_TYPE],\n )\n .map<[string, OntologyIrInterfaceTypeBlockDataV2]>(\n ([apiName, interfaceType]) => {\n return [apiName, {\n interfaceType: convertInterface(interfaceType),\n }];\n },\n ),\n ),\n linkTypes: Object.fromEntries(\n Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map<\n [string, OntologyIrLinkTypeBlockDataV2]\n >(([id, link]) => {\n return [cleanAndValidateLinkTypeId(id), convertLink(link)];\n }),\n ),\n actionTypes: Object.fromEntries(\n Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map<\n [string, OntologyIrActionTypeBlockDataV2]\n >(([apiName, action]) => {\n return [apiName, convertAction(action)];\n }),\n ),\n blockPermissionInformation: {\n actionTypes: Object.fromEntries(\n Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE])\n .filter(([apiName, action]) => action.validation)\n .map<\n [string, ActionTypePermissionInformation]\n >(([apiName, action]) => {\n return [apiName, {\n restrictionStatus: {\n hasRolesApplied: true,\n ontologyPackageRid: null,\n publicProject: false,\n },\n }];\n }),\n ),\n linkTypes: {},\n objectTypes: {},\n },\n });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,sBAAsB,QAAQ,4CAA4C;AACnF,SACEC,0BAA0B,EAC1BC,aAAa,QACR,6BAA6B;AACpC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,SAASC,wCAAwCA,CACtDC,QAA4B,EACG;EAC/B,OAAQ;IACNC,WAAW,EAAEC,MAAM,CAACC,WAAW,CAC7BD,MAAM,CAACE,OAAO,CAACJ,QAAQ,CAACR,sBAAsB,CAACa,WAAW,CAAC,CAAC,CAACC,GAAG,CAE9D,CAAC,CAACC,OAAO,EAAEC,UAAU,CAAC,KAAK;MAC3B,OAAO,CAACD,OAAO,EAAEV,aAAa,CAACW,UAAU,CAAC,CAAC;IAC7C,CAAC,CACH,CAAC;IACDC,mBAAmB,EAAEP,MAAM,CAACC,WAAW,CACrCD,MAAM,CAACE,OAAO,CACZJ,QAAQ,CAACR,sBAAsB,CAACkB,oBAAoB,CACtD,CAAC,CACEJ,GAAG,CAAoD,CACtD,CAACC,OAAO,EAAEI,GAAG,CAAC,KACX,CAACJ,OAAO,EAAE;MAAEK,kBAAkB,EAAEd,UAAU,CAACa,GAAG;IAAE,CAAC,CAAC,CAC3D,CAAC;IACDE,cAAc,EAAEX,MAAM,CAACC,WAAW,CAChCD,MAAM,CAACE,OAAO,CACZJ,QAAQ,CAACR,sBAAsB,CAACsB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,EAAE,CAAC,CAAC;MACbf,WAAW,EAAE,CAAC;IAChB;EACF,CAAC;AACH","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var consola = require('consola');
|
|
|
6
6
|
var fs2 = require('fs/promises');
|
|
7
7
|
var path2 = require('path');
|
|
8
8
|
var invariant5 = require('tiny-invariant');
|
|
9
|
+
var uuid = require('uuid');
|
|
9
10
|
var yargs = require('yargs');
|
|
10
11
|
var helpers = require('yargs/helpers');
|
|
11
12
|
var fs = require('fs');
|
|
@@ -734,6 +735,19 @@ function convertLink(linkType) {
|
|
|
734
735
|
}]
|
|
735
736
|
}
|
|
736
737
|
};
|
|
738
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
739
|
+
definition = {
|
|
740
|
+
type: "intermediary",
|
|
741
|
+
intermediary: {
|
|
742
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
743
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
744
|
+
objectTypeRidA: linkType.many.object.apiName,
|
|
745
|
+
objectTypeRidB: linkType.toMany.object.apiName,
|
|
746
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
747
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
748
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
749
|
+
}
|
|
750
|
+
};
|
|
737
751
|
} else {
|
|
738
752
|
definition = {
|
|
739
753
|
type: "manyToMany",
|
|
@@ -766,7 +780,7 @@ function convertLink(linkType) {
|
|
|
766
780
|
}
|
|
767
781
|
};
|
|
768
782
|
datasource = {
|
|
769
|
-
|
|
783
|
+
datasourceName: linkType.apiName,
|
|
770
784
|
datasource: {
|
|
771
785
|
type: "dataset",
|
|
772
786
|
dataset: {
|
|
@@ -1132,7 +1146,7 @@ function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
|
1132
1146
|
}];
|
|
1133
1147
|
})),
|
|
1134
1148
|
linkTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.LINK_TYPE]).map(([id, link]) => {
|
|
1135
|
-
return [id, convertLink(link)];
|
|
1149
|
+
return [cleanAndValidateLinkTypeId(id), convertLink(link)];
|
|
1136
1150
|
})),
|
|
1137
1151
|
actionTypes: Object.fromEntries(Object.entries(ontology[OntologyEntityTypeEnum.ACTION_TYPE]).map(([apiName, action]) => {
|
|
1138
1152
|
return [apiName, convertAction(action)];
|
|
@@ -1228,7 +1242,7 @@ function updateOntology(entity) {
|
|
|
1228
1242
|
}
|
|
1229
1243
|
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1230
1244
|
}
|
|
1231
|
-
async function defineOntology(ns, body, outputDir, dependencyFile) {
|
|
1245
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, uniquenessKey) {
|
|
1232
1246
|
namespace = ns;
|
|
1233
1247
|
dependencies = {};
|
|
1234
1248
|
ontologyDefinition = {
|
|
@@ -1334,7 +1348,7 @@ function buildDatasource(apiName, definition, classificationMarkingGroupName, ma
|
|
|
1334
1348
|
} : void 0
|
|
1335
1349
|
} : void 0;
|
|
1336
1350
|
return {
|
|
1337
|
-
|
|
1351
|
+
datasourceName: apiName,
|
|
1338
1352
|
datasource: definition,
|
|
1339
1353
|
editsConfiguration: {
|
|
1340
1354
|
onlyAllowPrivilegedEdits: false
|
|
@@ -1690,7 +1704,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
1690
1704
|
// src/cli/main.ts
|
|
1691
1705
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1692
1706
|
async function main(args = process.argv) {
|
|
1693
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.
|
|
1707
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.14").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1694
1708
|
input: {
|
|
1695
1709
|
alias: "i",
|
|
1696
1710
|
describe: "Input file",
|
|
@@ -1733,6 +1747,11 @@ async function main(args = process.argv) {
|
|
|
1733
1747
|
describe: "File to write dependencies to",
|
|
1734
1748
|
type: "string",
|
|
1735
1749
|
coerce: path2__namespace.resolve
|
|
1750
|
+
},
|
|
1751
|
+
randomnessKey: {
|
|
1752
|
+
describe: "Value used to assure uniqueness of entities",
|
|
1753
|
+
type: "string",
|
|
1754
|
+
coerce: path2__namespace.resolve
|
|
1736
1755
|
}
|
|
1737
1756
|
}).parseAsync();
|
|
1738
1757
|
let apiNamespace = "";
|
|
@@ -1742,6 +1761,9 @@ async function main(args = process.argv) {
|
|
|
1742
1761
|
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant5__default.default(false) : void 0;
|
|
1743
1762
|
}
|
|
1744
1763
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1764
|
+
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1765
|
+
!uuid.validate(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant5__default.default(false) : void 0;
|
|
1766
|
+
}
|
|
1745
1767
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
|
|
1746
1768
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1747
1769
|
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
@@ -1805,36 +1827,36 @@ function isActionParameterTypePrimitive(type) {
|
|
|
1805
1827
|
// src/api/defineAction.ts
|
|
1806
1828
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1807
1829
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1808
|
-
function defineCreateInterfaceObjectAction(
|
|
1809
|
-
const allProperties = Object.entries(getFlattenedInterfaceProperties(interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type));
|
|
1810
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(interfaceType)).length) {
|
|
1811
|
-
consola.consola.info(`Some properties on ${interfaceType.apiName} were skipped in the create action because they are structs`);
|
|
1830
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
1831
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1832
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1833
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the create action because they are structs`);
|
|
1812
1834
|
}
|
|
1813
1835
|
return defineAction({
|
|
1814
|
-
apiName: `create-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1815
|
-
displayName: `Create ${interfaceType.displayMetadata.displayName}`,
|
|
1836
|
+
apiName: `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1837
|
+
displayName: `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
1816
1838
|
parameters: [{
|
|
1817
1839
|
id: "objectTypeParameter",
|
|
1818
1840
|
displayName: "Object type to create",
|
|
1819
1841
|
type: {
|
|
1820
1842
|
type: "objectTypeReference",
|
|
1821
1843
|
objectTypeReference: {
|
|
1822
|
-
interfaceTypeRids: [interfaceType.apiName]
|
|
1844
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
1823
1845
|
}
|
|
1824
1846
|
},
|
|
1825
1847
|
validation: {
|
|
1826
1848
|
required: true,
|
|
1827
|
-
allowedValues: objectType === void 0 ? {
|
|
1849
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1828
1850
|
type: "objectTypeReference",
|
|
1829
|
-
interfaceTypes: [interfaceType.apiName]
|
|
1851
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
1830
1852
|
} : {
|
|
1831
1853
|
type: "oneOf",
|
|
1832
1854
|
oneOf: [{
|
|
1833
|
-
label: objectType.displayName,
|
|
1855
|
+
label: def.objectType.displayName,
|
|
1834
1856
|
value: {
|
|
1835
1857
|
type: "objectType",
|
|
1836
1858
|
objectType: {
|
|
1837
|
-
objectTypeId: objectType.apiName
|
|
1859
|
+
objectTypeId: def.objectType.apiName
|
|
1838
1860
|
}
|
|
1839
1861
|
}
|
|
1840
1862
|
}]
|
|
@@ -1852,9 +1874,9 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1852
1874
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1853
1875
|
}
|
|
1854
1876
|
}))],
|
|
1855
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
1877
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1856
1878
|
entities: {
|
|
1857
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
1879
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1858
1880
|
affectedObjectTypes: [],
|
|
1859
1881
|
affectedLinkTypes: [],
|
|
1860
1882
|
typeGroups: []
|
|
@@ -1862,7 +1884,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1862
1884
|
rules: [{
|
|
1863
1885
|
type: "addInterfaceRule",
|
|
1864
1886
|
addInterfaceRule: {
|
|
1865
|
-
interfaceApiName: interfaceType.apiName,
|
|
1887
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
1866
1888
|
objectTypeParameter: "objectTypeParameter",
|
|
1867
1889
|
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1868
1890
|
type: "parameterId",
|
|
@@ -1870,8 +1892,8 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1870
1892
|
}]))
|
|
1871
1893
|
}
|
|
1872
1894
|
}],
|
|
1873
|
-
...validation ? {
|
|
1874
|
-
validation: convertValidationRule(validation)
|
|
1895
|
+
...def.validation ? {
|
|
1896
|
+
validation: convertValidationRule(def.validation)
|
|
1875
1897
|
} : {}
|
|
1876
1898
|
});
|
|
1877
1899
|
}
|
|
@@ -1932,35 +1954,35 @@ function defineCreateObjectAction(def) {
|
|
|
1932
1954
|
}
|
|
1933
1955
|
});
|
|
1934
1956
|
}
|
|
1935
|
-
function defineModifyInterfaceObjectAction(
|
|
1936
|
-
const allProperties = Object.entries(getFlattenedInterfaceProperties(interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type));
|
|
1937
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(interfaceType)).length) {
|
|
1938
|
-
consola.consola.info(`Some properties on ${interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1957
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
1958
|
+
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1959
|
+
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1960
|
+
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1939
1961
|
}
|
|
1940
1962
|
return defineAction({
|
|
1941
|
-
apiName: `modify-${kebab(interfaceType.apiName.split(".").pop() ?? interfaceType.apiName)}${objectType === void 0 ? "" : `-${kebab(objectType.apiName.split(".").pop() ?? objectType.apiName)}`}`,
|
|
1942
|
-
displayName: `Modify ${interfaceType.displayMetadata.displayName}`,
|
|
1963
|
+
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1964
|
+
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1943
1965
|
parameters: [{
|
|
1944
1966
|
id: "interfaceObjectToModifyParameter",
|
|
1945
1967
|
displayName: "Object type to modify",
|
|
1946
1968
|
type: {
|
|
1947
1969
|
type: "interfaceReference",
|
|
1948
1970
|
interfaceReference: {
|
|
1949
|
-
interfaceTypeRid: interfaceType.apiName
|
|
1971
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
1950
1972
|
}
|
|
1951
1973
|
},
|
|
1952
1974
|
validation: {
|
|
1953
1975
|
required: true,
|
|
1954
|
-
allowedValues: objectType === void 0 ? {
|
|
1976
|
+
allowedValues: def.objectType === void 0 ? {
|
|
1955
1977
|
type: "interfaceObjectQuery"
|
|
1956
1978
|
} : {
|
|
1957
1979
|
type: "oneOf",
|
|
1958
1980
|
oneOf: [{
|
|
1959
|
-
label: objectType.displayName,
|
|
1981
|
+
label: def.objectType.displayName,
|
|
1960
1982
|
value: {
|
|
1961
1983
|
type: "objectType",
|
|
1962
1984
|
objectType: {
|
|
1963
|
-
objectTypeId: objectType.apiName
|
|
1985
|
+
objectTypeId: def.objectType.apiName
|
|
1964
1986
|
}
|
|
1965
1987
|
}
|
|
1966
1988
|
}]
|
|
@@ -1978,9 +2000,9 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1978
2000
|
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1979
2001
|
}
|
|
1980
2002
|
}))],
|
|
1981
|
-
status: interfaceType.status.type !== "deprecated" ? interfaceType.status.type : interfaceType.status,
|
|
2003
|
+
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1982
2004
|
entities: {
|
|
1983
|
-
affectedInterfaceTypes: [interfaceType.apiName],
|
|
2005
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
1984
2006
|
affectedObjectTypes: [],
|
|
1985
2007
|
affectedLinkTypes: [],
|
|
1986
2008
|
typeGroups: []
|
|
@@ -1995,8 +2017,8 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1995
2017
|
}]))
|
|
1996
2018
|
}
|
|
1997
2019
|
}],
|
|
1998
|
-
...validation ? {
|
|
1999
|
-
validation: convertValidationRule(validation)
|
|
2020
|
+
...def.validation ? {
|
|
2021
|
+
validation: convertValidationRule(def.validation)
|
|
2000
2022
|
} : {}
|
|
2001
2023
|
});
|
|
2002
2024
|
}
|
|
@@ -2822,15 +2844,30 @@ function defineLink(linkDefinition) {
|
|
|
2822
2844
|
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2823
2845
|
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant5__default.default(false) : void 0;
|
|
2824
2846
|
}
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
one
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2847
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
2848
|
+
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2849
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2850
|
+
}
|
|
2851
|
+
let fullLinkDefinition;
|
|
2852
|
+
if ("one" in linkDefinition) {
|
|
2853
|
+
fullLinkDefinition = {
|
|
2854
|
+
...linkDefinition,
|
|
2855
|
+
one: convertUserOneToManyLinkDefinition(linkDefinition.one),
|
|
2856
|
+
toMany: convertUserOneToManyLinkDefinition(linkDefinition.toMany)
|
|
2857
|
+
};
|
|
2858
|
+
} else if ("intermediaryObjectType" in linkDefinition) {
|
|
2859
|
+
fullLinkDefinition = {
|
|
2860
|
+
...linkDefinition,
|
|
2861
|
+
many: convertUserIntermediaryLinkDefinition(linkDefinition.many),
|
|
2862
|
+
toMany: convertUserIntermediaryLinkDefinition(linkDefinition.toMany)
|
|
2863
|
+
};
|
|
2864
|
+
} else {
|
|
2865
|
+
fullLinkDefinition = {
|
|
2866
|
+
...linkDefinition,
|
|
2867
|
+
many: convertUserManyToManyLinkDefinition(linkDefinition.many),
|
|
2868
|
+
toMany: convertUserManyToManyLinkDefinition(linkDefinition.toMany)
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2834
2871
|
const linkType = {
|
|
2835
2872
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2836
2873
|
...fullLinkDefinition,
|
|
@@ -2851,6 +2888,12 @@ function convertUserManyToManyLinkDefinition(manyToMany) {
|
|
|
2851
2888
|
metadata: convertLinkTypeMetadata(manyToMany.metadata)
|
|
2852
2889
|
};
|
|
2853
2890
|
}
|
|
2891
|
+
function convertUserIntermediaryLinkDefinition(intermediary) {
|
|
2892
|
+
return {
|
|
2893
|
+
...intermediary,
|
|
2894
|
+
metadata: convertLinkTypeMetadata(intermediary.metadata)
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2854
2897
|
function convertLinkTypeMetadata(metadata) {
|
|
2855
2898
|
return {
|
|
2856
2899
|
apiName: metadata.apiName,
|