@osdk/maker 0.13.0-beta.1 → 0.13.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 +110 -0
- package/build/browser/api/defineAction.js +57 -20
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineInterface.js +11 -6
- package/build/browser/api/defineInterface.js.map +1 -1
- package/build/browser/api/defineObject.js +2 -0
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +40 -109
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +2 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/markingconstraint.test.js +3 -3
- package/build/browser/api/markingconstraint.test.js.map +1 -1
- package/build/browser/api/objectStatus.test.js +4 -4
- package/build/browser/api/objectStatus.test.js.map +1 -1
- package/build/browser/api/overall.test.js +1015 -314
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/propertyConversionUtils.js +3 -1
- package/build/browser/api/propertyConversionUtils.js.map +1 -1
- package/build/browser/api/types.js.map +1 -1
- package/build/browser/cli/main.js +5 -5
- package/build/browser/cli/main.js.map +1 -1
- package/build/cjs/index.cjs +106 -141
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +8 -10
- package/build/esm/api/defineAction.js +57 -20
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineInterface.js +11 -6
- package/build/esm/api/defineInterface.js.map +1 -1
- package/build/esm/api/defineObject.js +2 -0
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +40 -109
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +2 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/markingconstraint.test.js +3 -3
- package/build/esm/api/markingconstraint.test.js.map +1 -1
- package/build/esm/api/objectStatus.test.js +4 -4
- package/build/esm/api/objectStatus.test.js.map +1 -1
- package/build/esm/api/overall.test.js +1015 -314
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/propertyConversionUtils.js +3 -1
- package/build/esm/api/propertyConversionUtils.js.map +1 -1
- package/build/esm/api/types.js.map +1 -1
- package/build/esm/cli/main.js +5 -5
- package/build/esm/cli/main.js.map +1 -1
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineInterface.d.ts.map +1 -1
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +1 -6
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +2 -2
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/propertyConversionUtils.d.ts +2 -2
- package/build/types/api/propertyConversionUtils.d.ts.map +1 -1
- package/build/types/api/types.d.ts +6 -14
- package/build/types/api/types.d.ts.map +1 -1
- package/package.json +9 -10
package/build/cjs/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
|
40
40
|
// src/cli/main.ts
|
|
41
41
|
|
|
42
42
|
// src/api/types.ts
|
|
43
|
-
var OntologyEntityTypeEnum = /* @__PURE__ */ function(OntologyEntityTypeEnum2) {
|
|
43
|
+
var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2) {
|
|
44
44
|
OntologyEntityTypeEnum2["OBJECT_TYPE"] = "OBJECT_TYPE";
|
|
45
45
|
OntologyEntityTypeEnum2["LINK_TYPE"] = "LINK_TYPE";
|
|
46
46
|
OntologyEntityTypeEnum2["INTERFACE_TYPE"] = "INTERFACE_TYPE";
|
|
@@ -48,19 +48,21 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ function(OntologyEntityTypeEnum2) {
|
|
|
48
48
|
OntologyEntityTypeEnum2["ACTION_TYPE"] = "ACTION_TYPE";
|
|
49
49
|
OntologyEntityTypeEnum2["VALUE_TYPE"] = "VALUE_TYPE";
|
|
50
50
|
return OntologyEntityTypeEnum2;
|
|
51
|
-
}({});
|
|
51
|
+
})({});
|
|
52
52
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
53
53
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
54
54
|
|
|
55
55
|
// src/api/defineObject.ts
|
|
56
56
|
var ISO_8601_DURATION = /^P(?!$)(?:(?:((?:\d+Y)|(?:\d+(?:\.|,)\d+Y$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+D)|(?:\d+(?:\.|,)\d+D$))?(T((?:\d+H)|(?:\d+(?:\.|,)\d+H$))?((?:\d+M)|(?:\d+(?:\.|,)\d+M$))?((?:\d+S)|(?:\d+(?:\.|,)\d+S$))?)?)|(?:\d+(?:(?:\.|,)\d+)?W))$/;
|
|
57
57
|
var ISO_8601_DATETIME = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
58
|
+
var API_NAME_PATTERN = /^([a-zA-Z][a-zA-Z0-9\\-]*)$/;
|
|
58
59
|
function defineObject(objectDef) {
|
|
59
60
|
const apiName = namespace + objectDef.apiName;
|
|
60
61
|
const propertyApiNames = objectDef.properties ? Object.keys(objectDef.properties) : [];
|
|
61
62
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
62
63
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
63
64
|
}
|
|
65
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant5__default.default(false) : void 0;
|
|
64
66
|
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant5__default.default(false) : void 0;
|
|
65
67
|
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant5__default.default(false) : void 0;
|
|
66
68
|
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant5__default.default(false) : void 0;
|
|
@@ -414,7 +416,9 @@ function getPropertyTypeName(type) {
|
|
|
414
416
|
function convertValueType(valueType) {
|
|
415
417
|
return {
|
|
416
418
|
apiName: valueType.apiName,
|
|
417
|
-
version: valueType.version
|
|
419
|
+
version: valueType.version,
|
|
420
|
+
packageNamespace: valueType.packageNamespace,
|
|
421
|
+
displayMetadata: valueType.displayMetadata
|
|
418
422
|
};
|
|
419
423
|
}
|
|
420
424
|
function convertValueTypeDataConstraints(dataConstraints) {
|
|
@@ -684,10 +688,7 @@ async function defineOntology(ns, body, outputDir, dependencyFile) {
|
|
|
684
688
|
if (dependencyFile) {
|
|
685
689
|
writeDependencyFile(dependencyFile);
|
|
686
690
|
}
|
|
687
|
-
return
|
|
688
|
-
ontology: convertToWireOntologyIr(ontologyDefinition),
|
|
689
|
-
valueType: convertOntologyToValueTypeIr(ontologyDefinition)
|
|
690
|
-
};
|
|
691
|
+
return convertToWireOntologyIr(ontologyDefinition);
|
|
691
692
|
}
|
|
692
693
|
function writeStaticObjects(outputDir) {
|
|
693
694
|
const codegenDir = path2__namespace.resolve(outputDir, "codegen");
|
|
@@ -753,111 +754,32 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
|
|
|
753
754
|
}
|
|
754
755
|
function convertOntologyToValueTypeIr(ontology) {
|
|
755
756
|
return {
|
|
756
|
-
valueTypes:
|
|
757
|
-
metadata: {
|
|
758
|
-
apiName: definitions[0].apiName,
|
|
759
|
-
displayMetadata: definitions[0].displayMetadata,
|
|
760
|
-
status: definitions[0].status
|
|
761
|
-
},
|
|
762
|
-
versions: definitions.map((definition) => ({
|
|
763
|
-
version: definition.version,
|
|
764
|
-
baseType: definition.baseType,
|
|
765
|
-
constraints: definition.constraints,
|
|
766
|
-
exampleValues: definition.exampleValues
|
|
767
|
-
}))
|
|
768
|
-
}))
|
|
757
|
+
valueTypes: convertValueTypesToIr(ontology[OntologyEntityTypeEnum.VALUE_TYPE])
|
|
769
758
|
};
|
|
770
759
|
}
|
|
771
|
-
function
|
|
772
|
-
return {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
760
|
+
function convertValueTypesToIr(valueTypes) {
|
|
761
|
+
return Object.values(valueTypes).map((definitions) => ({
|
|
762
|
+
metadata: {
|
|
763
|
+
apiName: definitions[0].apiName,
|
|
764
|
+
packageNamespace: definitions[0].packageNamespace,
|
|
765
|
+
displayMetadata: definitions[0].displayMetadata,
|
|
766
|
+
status: definitions[0].status
|
|
767
|
+
},
|
|
768
|
+
// TODO(dpaquin): instead of deduping here, we should refactor the value type types from arrays to maps
|
|
769
|
+
versions: Array.from(new Map(definitions.map((definition) => [definition.version, definition])).values()).map((definition) => ({
|
|
770
|
+
version: definition.version,
|
|
771
|
+
baseType: definition.baseType,
|
|
772
|
+
constraints: definition.constraints,
|
|
773
|
+
exampleValues: definition.exampleValues
|
|
774
|
+
}))
|
|
775
|
+
}));
|
|
776
776
|
}
|
|
777
|
-
function
|
|
778
|
-
const asBlockData = convertToWireBlockData(importedTypes2);
|
|
777
|
+
function convertToWireOntologyIr(ontology) {
|
|
779
778
|
return {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
type: spt.sharedPropertyType.type,
|
|
785
|
-
valueType: spt.sharedPropertyType.valueType === void 0 ? void 0 : {
|
|
786
|
-
apiName: spt.sharedPropertyType.valueType.apiName,
|
|
787
|
-
version: spt.sharedPropertyType.valueType.version
|
|
788
|
-
}
|
|
789
|
-
})),
|
|
790
|
-
objectTypes: Object.values(asBlockData.objectTypes).map((ot) => ({
|
|
791
|
-
apiName: ot.objectType.apiName,
|
|
792
|
-
displayName: ot.objectType.displayMetadata.displayName,
|
|
793
|
-
description: ot.objectType.displayMetadata.description,
|
|
794
|
-
propertyTypes: Object.values(ot.objectType.propertyTypes).map((p) => ({
|
|
795
|
-
apiName: p.apiName,
|
|
796
|
-
displayName: p.displayMetadata.displayName,
|
|
797
|
-
description: p.displayMetadata.description,
|
|
798
|
-
type: p.type,
|
|
799
|
-
sharedPropertyType: p.sharedPropertyTypeApiName
|
|
800
|
-
}))
|
|
801
|
-
})),
|
|
802
|
-
interfaceTypes: Object.values(asBlockData.interfaceTypes).map((i) => ({
|
|
803
|
-
apiName: i.interfaceType.apiName,
|
|
804
|
-
displayName: i.interfaceType.displayMetadata.displayName,
|
|
805
|
-
description: i.interfaceType.displayMetadata.description,
|
|
806
|
-
properties: Object.values(i.interfaceType.propertiesV2).map((p) => ({
|
|
807
|
-
apiName: p.sharedPropertyType.apiName,
|
|
808
|
-
displayName: p.sharedPropertyType.displayMetadata.displayName,
|
|
809
|
-
description: p.sharedPropertyType.displayMetadata.description,
|
|
810
|
-
type: p.sharedPropertyType.type
|
|
811
|
-
})),
|
|
812
|
-
links: i.interfaceType.links.map((l) => ({
|
|
813
|
-
apiName: l.metadata.apiName,
|
|
814
|
-
displayName: l.metadata.displayName,
|
|
815
|
-
description: l.metadata.description,
|
|
816
|
-
cardinality: l.cardinality,
|
|
817
|
-
required: l.required
|
|
818
|
-
}))
|
|
819
|
-
})),
|
|
820
|
-
actionTypes: Object.values(asBlockData.actionTypes).map((a) => ({
|
|
821
|
-
apiName: a.actionType.metadata.apiName,
|
|
822
|
-
displayName: a.actionType.metadata.displayMetadata.displayName,
|
|
823
|
-
description: a.actionType.metadata.displayMetadata.description,
|
|
824
|
-
parameters: Object.values(a.actionType.metadata.parameters).map((p) => ({
|
|
825
|
-
id: p.id,
|
|
826
|
-
displayName: p.displayMetadata.displayName,
|
|
827
|
-
description: p.displayMetadata.description,
|
|
828
|
-
type: p.type
|
|
829
|
-
}))
|
|
830
|
-
})),
|
|
831
|
-
linkTypes: Object.values(asBlockData.linkTypes).map((l) => {
|
|
832
|
-
if (l.linkType.definition.type === "oneToMany") {
|
|
833
|
-
return {
|
|
834
|
-
id: l.linkType.id,
|
|
835
|
-
definition: {
|
|
836
|
-
type: "oneToMany",
|
|
837
|
-
"oneToMany": {
|
|
838
|
-
objectTypeApiNameOneSide: l.linkType.definition.oneToMany.objectTypeRidOneSide,
|
|
839
|
-
objectTypeApiNameManySide: l.linkType.definition.oneToMany.objectTypeRidManySide,
|
|
840
|
-
manyToOneLinkDisplayName: l.linkType.definition.oneToMany.manyToOneLinkMetadata.displayMetadata.displayName,
|
|
841
|
-
oneToManyLinkDisplayName: l.linkType.definition.oneToMany.oneToManyLinkMetadata.displayMetadata.displayName,
|
|
842
|
-
cardinality: l.linkType.definition.oneToMany.cardinalityHint
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
};
|
|
846
|
-
} else {
|
|
847
|
-
return {
|
|
848
|
-
id: l.linkType.id,
|
|
849
|
-
definition: {
|
|
850
|
-
type: "manyToMany",
|
|
851
|
-
"manyToMany": {
|
|
852
|
-
objectTypeApiNameA: l.linkType.definition.manyToMany.objectTypeRidA,
|
|
853
|
-
objectTypeApiNameB: l.linkType.definition.manyToMany.objectTypeRidB,
|
|
854
|
-
objectTypeAToBLinkDisplayName: l.linkType.definition.manyToMany.objectTypeAToBLinkMetadata.displayMetadata.displayName,
|
|
855
|
-
objectTypeBToALinkDisplayName: l.linkType.definition.manyToMany.objectTypeBToALinkMetadata.displayMetadata.displayName
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
})
|
|
779
|
+
ontology: convertToWireBlockData(ontology),
|
|
780
|
+
importedOntology: convertToWireBlockData(importedTypes),
|
|
781
|
+
valueTypes: convertOntologyToValueTypeIr(ontology),
|
|
782
|
+
importedValueTypes: convertOntologyToValueTypeIr(importedTypes)
|
|
861
783
|
};
|
|
862
784
|
}
|
|
863
785
|
function convertToWireBlockData(ontology) {
|
|
@@ -1217,11 +1139,22 @@ function convertInterface(interfaceType) {
|
|
|
1217
1139
|
required: spt.required,
|
|
1218
1140
|
sharedPropertyType: convertSpt(spt.sharedPropertyType)
|
|
1219
1141
|
}])),
|
|
1142
|
+
displayMetadata: {
|
|
1143
|
+
displayName: interfaceType.displayMetadata.displayName,
|
|
1144
|
+
description: interfaceType.displayMetadata.description,
|
|
1145
|
+
icon: interfaceType.displayMetadata.icon ?? {
|
|
1146
|
+
type: "blueprint",
|
|
1147
|
+
blueprint: {
|
|
1148
|
+
color: "#4C90F0",
|
|
1149
|
+
locator: "layout-hierarchy"
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1220
1153
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1221
1154
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1155
|
+
properties: [],
|
|
1222
1156
|
// TODO(mwalther): Support propertiesV3
|
|
1223
|
-
propertiesV3: {}
|
|
1224
|
-
properties: []
|
|
1157
|
+
propertiesV3: {}
|
|
1225
1158
|
};
|
|
1226
1159
|
}
|
|
1227
1160
|
function dumpOntologyFullMetadata() {
|
|
@@ -1264,7 +1197,9 @@ function convertSpt({
|
|
|
1264
1197
|
typeClasses: typeClasses ?? [],
|
|
1265
1198
|
valueType: valueType === void 0 ? void 0 : {
|
|
1266
1199
|
apiName: valueType.apiName,
|
|
1267
|
-
version: valueType.version
|
|
1200
|
+
version: valueType.version,
|
|
1201
|
+
packageNamespace: valueType.packageNamespace,
|
|
1202
|
+
displayMetadata: valueType.displayMetadata
|
|
1268
1203
|
}
|
|
1269
1204
|
};
|
|
1270
1205
|
}
|
|
@@ -1704,7 +1639,7 @@ function writeDependencyFile(dependencyFile) {
|
|
|
1704
1639
|
function dependencyInjectionString() {
|
|
1705
1640
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
1706
1641
|
return `import { addDependency } from "@osdk/maker";
|
|
1707
|
-
|
|
1642
|
+
// @ts-ignore
|
|
1708
1643
|
addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
1709
1644
|
`;
|
|
1710
1645
|
}
|
|
@@ -1721,7 +1656,7 @@ function convertCardinality(cardinality) {
|
|
|
1721
1656
|
// src/cli/main.ts
|
|
1722
1657
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1723
1658
|
async function main(args = process.argv) {
|
|
1724
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.
|
|
1659
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.11").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1725
1660
|
input: {
|
|
1726
1661
|
alias: "i",
|
|
1727
1662
|
describe: "Input file",
|
|
@@ -1773,11 +1708,11 @@ async function main(args = process.argv) {
|
|
|
1773
1708
|
!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;
|
|
1774
1709
|
}
|
|
1775
1710
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1776
|
-
const
|
|
1711
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
|
|
1777
1712
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1778
|
-
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(
|
|
1779
|
-
if (
|
|
1780
|
-
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(
|
|
1713
|
+
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1714
|
+
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1715
|
+
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1781
1716
|
}
|
|
1782
1717
|
}
|
|
1783
1718
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
@@ -1870,7 +1805,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1870
1805
|
}
|
|
1871
1806
|
}],
|
|
1872
1807
|
...validation ? {
|
|
1873
|
-
validation:
|
|
1808
|
+
validation: convertValidationRule(validation)
|
|
1874
1809
|
} : {}
|
|
1875
1810
|
});
|
|
1876
1811
|
}
|
|
@@ -1883,7 +1818,7 @@ function defineCreateObjectAction(def) {
|
|
|
1883
1818
|
if (def.parameterOrdering) {
|
|
1884
1819
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
1885
1820
|
}
|
|
1886
|
-
const parameters = createParameters(def, parameterNames
|
|
1821
|
+
const parameters = createParameters(def, parameterNames);
|
|
1887
1822
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1888
1823
|
return defineAction({
|
|
1889
1824
|
apiName: actionApiName,
|
|
@@ -1912,7 +1847,7 @@ function defineCreateObjectAction(def) {
|
|
|
1912
1847
|
}],
|
|
1913
1848
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1914
1849
|
...def.actionLevelValidation ? {
|
|
1915
|
-
validation:
|
|
1850
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
1916
1851
|
} : {},
|
|
1917
1852
|
...def.defaultFormat && {
|
|
1918
1853
|
defaultFormat: def.defaultFormat
|
|
@@ -1995,7 +1930,7 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1995
1930
|
}
|
|
1996
1931
|
}],
|
|
1997
1932
|
...validation ? {
|
|
1998
|
-
validation:
|
|
1933
|
+
validation: convertValidationRule(validation)
|
|
1999
1934
|
} : {}
|
|
2000
1935
|
});
|
|
2001
1936
|
}
|
|
@@ -2012,7 +1947,7 @@ function defineModifyObjectAction(def) {
|
|
|
2012
1947
|
}
|
|
2013
1948
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2014
1949
|
}
|
|
2015
|
-
const parameters = createParameters(def, parameterNames
|
|
1950
|
+
const parameters = createParameters(def, parameterNames);
|
|
2016
1951
|
parameters.forEach((p) => {
|
|
2017
1952
|
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2018
1953
|
p.defaultValue = {
|
|
@@ -2052,7 +1987,7 @@ function defineModifyObjectAction(def) {
|
|
|
2052
1987
|
},
|
|
2053
1988
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2054
1989
|
...def.actionLevelValidation ? {
|
|
2055
|
-
validation:
|
|
1990
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2056
1991
|
} : {},
|
|
2057
1992
|
...def.defaultFormat && {
|
|
2058
1993
|
defaultFormat: def.defaultFormat
|
|
@@ -2105,7 +2040,7 @@ function defineDeleteObjectAction(def) {
|
|
|
2105
2040
|
typeGroups: []
|
|
2106
2041
|
},
|
|
2107
2042
|
...def.actionLevelValidation ? {
|
|
2108
|
-
validation:
|
|
2043
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2109
2044
|
} : {}
|
|
2110
2045
|
});
|
|
2111
2046
|
}
|
|
@@ -2122,7 +2057,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2122
2057
|
}
|
|
2123
2058
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2124
2059
|
}
|
|
2125
|
-
const parameters = createParameters(def, parameterNames
|
|
2060
|
+
const parameters = createParameters(def, parameterNames);
|
|
2126
2061
|
parameters.forEach((p) => {
|
|
2127
2062
|
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2128
2063
|
p.defaultValue = {
|
|
@@ -2162,7 +2097,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2162
2097
|
},
|
|
2163
2098
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2164
2099
|
...def.actionLevelValidation ? {
|
|
2165
|
-
validation:
|
|
2100
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2166
2101
|
} : {},
|
|
2167
2102
|
...def.defaultFormat && {
|
|
2168
2103
|
defaultFormat: def.defaultFormat
|
|
@@ -2203,6 +2138,31 @@ function defineAction(actionDef) {
|
|
|
2203
2138
|
if (rule.type === "deleteObjectRule") {
|
|
2204
2139
|
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant5__default.default(false) : void 0;
|
|
2205
2140
|
}
|
|
2141
|
+
if (rule.type === "modifyInterfaceRule") {
|
|
2142
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2143
|
+
!(ontologyDefinition.SHARED_PROPERTY_TYPE[spt] !== void 0 || importedTypes.SHARED_PROPERTY_TYPE[spt] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist.
|
|
2144
|
+
If this SPT was imported, you may need to use [spt.apiName] as the key so that it is qualified with the right namespace`) : invariant5__default.default(false) : void 0;
|
|
2145
|
+
});
|
|
2146
|
+
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2147
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant5__default.default(false) : void 0;
|
|
2148
|
+
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2149
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant5__default.default(false) : void 0;
|
|
2150
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2151
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2152
|
+
!(interfaceType.propertiesV2[spt] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant5__default.default(false) : void 0;
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
if (rule.type === "addInterfaceRule") {
|
|
2156
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2157
|
+
!(ontologyDefinition.SHARED_PROPERTY_TYPE[spt] !== void 0 || importedTypes.SHARED_PROPERTY_TYPE[spt] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist.
|
|
2158
|
+
If this SPT was imported, you may need to use [spt.apiName] as the key so that it is qualified with the right namespace`) : invariant5__default.default(false) : void 0;
|
|
2159
|
+
});
|
|
2160
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2161
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant5__default.default(false) : void 0;
|
|
2162
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2163
|
+
!(interfaceType.propertiesV2[spt] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2206
2166
|
});
|
|
2207
2167
|
const fullAction = {
|
|
2208
2168
|
...actionDef,
|
|
@@ -2219,7 +2179,7 @@ function defineAction(actionDef) {
|
|
|
2219
2179
|
updateOntology(fullAction);
|
|
2220
2180
|
return fullAction;
|
|
2221
2181
|
}
|
|
2222
|
-
function createParameters(def, parameterSet
|
|
2182
|
+
function createParameters(def, parameterSet) {
|
|
2223
2183
|
const targetParam = [];
|
|
2224
2184
|
parameterSet.forEach((name) => {
|
|
2225
2185
|
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
@@ -2281,13 +2241,13 @@ function createParameters(def, parameterSet, defaultRequired) {
|
|
|
2281
2241
|
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2282
2242
|
...def.parameterConfiguration?.[id],
|
|
2283
2243
|
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)),
|
|
2284
|
-
required: def.parameterConfiguration?.[id].required ??
|
|
2244
|
+
required: def.parameterConfiguration?.[id].required ?? def.objectType.properties?.[id]?.nullability?.noNulls ?? false
|
|
2285
2245
|
} : {
|
|
2286
2246
|
required: def.objectType.properties?.[id].array ?? false ? {
|
|
2287
2247
|
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
2288
2248
|
min: 1
|
|
2289
2249
|
} : {}
|
|
2290
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ??
|
|
2250
|
+
} : def.objectType.properties?.[id].nullability?.noNulls ?? false,
|
|
2291
2251
|
allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
|
|
2292
2252
|
},
|
|
2293
2253
|
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
@@ -2564,13 +2524,15 @@ function sanitize2(s) {
|
|
|
2564
2524
|
return s.includes(".") ? s : namespace + s;
|
|
2565
2525
|
}
|
|
2566
2526
|
function convertValidationRule(actionValidation) {
|
|
2567
|
-
return {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2527
|
+
return actionValidation.map((rule) => {
|
|
2528
|
+
return {
|
|
2529
|
+
condition: convertConditionDefinition(rule.condition),
|
|
2530
|
+
displayMetadata: rule.displayMetadata ?? {
|
|
2531
|
+
failureMessage: "Did not satisfy validation",
|
|
2532
|
+
typeClasses: []
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
});
|
|
2574
2536
|
}
|
|
2575
2537
|
function validateActionConfiguration(action) {
|
|
2576
2538
|
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2712,16 +2674,18 @@ function defineSharedPropertyType(sptDef) {
|
|
|
2712
2674
|
function defineInterface(interfaceDef) {
|
|
2713
2675
|
const apiName = namespace + interfaceDef.apiName;
|
|
2714
2676
|
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface ${apiName} already exists`) : invariant5__default.default(false) : void 0;
|
|
2715
|
-
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([
|
|
2677
|
+
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2716
2678
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2717
|
-
|
|
2679
|
+
const apiName3 = sanitize(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
2680
|
+
return [apiName3, {
|
|
2718
2681
|
required: type.required,
|
|
2719
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2682
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type.propertyDefinition)
|
|
2720
2683
|
}];
|
|
2721
2684
|
}
|
|
2722
|
-
|
|
2685
|
+
const apiName2 = sanitize(namespace, typeof type === "object" && "apiName" in type ? type.apiName : unNamespacedPropApiName);
|
|
2686
|
+
return [apiName2, {
|
|
2723
2687
|
required: true,
|
|
2724
|
-
sharedPropertyType: unifyBasePropertyDefinition(namespace,
|
|
2688
|
+
sharedPropertyType: unifyBasePropertyDefinition(namespace, unNamespacedPropApiName, type)
|
|
2725
2689
|
}];
|
|
2726
2690
|
}));
|
|
2727
2691
|
const extendsInterfaces = interfaceDef.extends ? Array.isArray(interfaceDef.extends) ? interfaceDef.extends : [interfaceDef.extends] : [];
|
|
@@ -2948,6 +2912,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2948
2912
|
const baseType = convertValueTypeTypeToBaseType(type.type);
|
|
2949
2913
|
const vt = {
|
|
2950
2914
|
apiName,
|
|
2915
|
+
packageNamespace: namespace.substring(0, namespace.length - 1),
|
|
2951
2916
|
displayMetadata: {
|
|
2952
2917
|
displayName,
|
|
2953
2918
|
description: description ?? ""
|