@osdk/maker 0.12.2 → 0.13.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -52
- package/build/browser/api/defineAction.js +21 -19
- package/build/browser/api/defineAction.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 +33 -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 +841 -310
- 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 +67 -136
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +8 -10
- package/build/esm/api/defineAction.js +21 -19
- package/build/esm/api/defineAction.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 +33 -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 +841 -310
- 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/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 +10 -11
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,15 @@ 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
|
+
},
|
|
1220
1146
|
extendsInterfaces: interfaceType.extendsInterfaces.map((i) => i.apiName),
|
|
1221
1147
|
// these are omitted from our internal types but we need to re-add them for the final json
|
|
1148
|
+
properties: [],
|
|
1222
1149
|
// TODO(mwalther): Support propertiesV3
|
|
1223
|
-
propertiesV3: {}
|
|
1224
|
-
properties: []
|
|
1150
|
+
propertiesV3: {}
|
|
1225
1151
|
};
|
|
1226
1152
|
}
|
|
1227
1153
|
function dumpOntologyFullMetadata() {
|
|
@@ -1264,7 +1190,9 @@ function convertSpt({
|
|
|
1264
1190
|
typeClasses: typeClasses ?? [],
|
|
1265
1191
|
valueType: valueType === void 0 ? void 0 : {
|
|
1266
1192
|
apiName: valueType.apiName,
|
|
1267
|
-
version: valueType.version
|
|
1193
|
+
version: valueType.version,
|
|
1194
|
+
packageNamespace: valueType.packageNamespace,
|
|
1195
|
+
displayMetadata: valueType.displayMetadata
|
|
1268
1196
|
}
|
|
1269
1197
|
};
|
|
1270
1198
|
}
|
|
@@ -1704,7 +1632,7 @@ function writeDependencyFile(dependencyFile) {
|
|
|
1704
1632
|
function dependencyInjectionString() {
|
|
1705
1633
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
1706
1634
|
return `import { addDependency } from "@osdk/maker";
|
|
1707
|
-
|
|
1635
|
+
// @ts-ignore
|
|
1708
1636
|
addDependency("${namespaceNoDot}", new URL(import.meta.url).pathname);
|
|
1709
1637
|
`;
|
|
1710
1638
|
}
|
|
@@ -1721,7 +1649,7 @@ function convertCardinality(cardinality) {
|
|
|
1721
1649
|
// src/cli/main.ts
|
|
1722
1650
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1723
1651
|
async function main(args = process.argv) {
|
|
1724
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
1652
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.13.0-beta.10").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1725
1653
|
input: {
|
|
1726
1654
|
alias: "i",
|
|
1727
1655
|
describe: "Input file",
|
|
@@ -1773,11 +1701,11 @@ async function main(args = process.argv) {
|
|
|
1773
1701
|
!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
1702
|
}
|
|
1775
1703
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1776
|
-
const
|
|
1704
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
|
|
1777
1705
|
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(
|
|
1706
|
+
await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1707
|
+
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1708
|
+
await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1781
1709
|
}
|
|
1782
1710
|
}
|
|
1783
1711
|
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
@@ -1870,7 +1798,7 @@ function defineCreateInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1870
1798
|
}
|
|
1871
1799
|
}],
|
|
1872
1800
|
...validation ? {
|
|
1873
|
-
validation:
|
|
1801
|
+
validation: convertValidationRule(validation)
|
|
1874
1802
|
} : {}
|
|
1875
1803
|
});
|
|
1876
1804
|
}
|
|
@@ -1883,7 +1811,7 @@ function defineCreateObjectAction(def) {
|
|
|
1883
1811
|
if (def.parameterOrdering) {
|
|
1884
1812
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
1885
1813
|
}
|
|
1886
|
-
const parameters = createParameters(def, parameterNames
|
|
1814
|
+
const parameters = createParameters(def, parameterNames);
|
|
1887
1815
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
1888
1816
|
return defineAction({
|
|
1889
1817
|
apiName: actionApiName,
|
|
@@ -1912,7 +1840,7 @@ function defineCreateObjectAction(def) {
|
|
|
1912
1840
|
}],
|
|
1913
1841
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
|
|
1914
1842
|
...def.actionLevelValidation ? {
|
|
1915
|
-
validation:
|
|
1843
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
1916
1844
|
} : {},
|
|
1917
1845
|
...def.defaultFormat && {
|
|
1918
1846
|
defaultFormat: def.defaultFormat
|
|
@@ -1995,7 +1923,7 @@ function defineModifyInterfaceObjectAction(interfaceType, objectType, validation
|
|
|
1995
1923
|
}
|
|
1996
1924
|
}],
|
|
1997
1925
|
...validation ? {
|
|
1998
|
-
validation:
|
|
1926
|
+
validation: convertValidationRule(validation)
|
|
1999
1927
|
} : {}
|
|
2000
1928
|
});
|
|
2001
1929
|
}
|
|
@@ -2012,7 +1940,7 @@ function defineModifyObjectAction(def) {
|
|
|
2012
1940
|
}
|
|
2013
1941
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2014
1942
|
}
|
|
2015
|
-
const parameters = createParameters(def, parameterNames
|
|
1943
|
+
const parameters = createParameters(def, parameterNames);
|
|
2016
1944
|
parameters.forEach((p) => {
|
|
2017
1945
|
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2018
1946
|
p.defaultValue = {
|
|
@@ -2052,7 +1980,7 @@ function defineModifyObjectAction(def) {
|
|
|
2052
1980
|
},
|
|
2053
1981
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2054
1982
|
...def.actionLevelValidation ? {
|
|
2055
|
-
validation:
|
|
1983
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2056
1984
|
} : {},
|
|
2057
1985
|
...def.defaultFormat && {
|
|
2058
1986
|
defaultFormat: def.defaultFormat
|
|
@@ -2105,7 +2033,7 @@ function defineDeleteObjectAction(def) {
|
|
|
2105
2033
|
typeGroups: []
|
|
2106
2034
|
},
|
|
2107
2035
|
...def.actionLevelValidation ? {
|
|
2108
|
-
validation:
|
|
2036
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2109
2037
|
} : {}
|
|
2110
2038
|
});
|
|
2111
2039
|
}
|
|
@@ -2122,7 +2050,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2122
2050
|
}
|
|
2123
2051
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2124
2052
|
}
|
|
2125
|
-
const parameters = createParameters(def, parameterNames
|
|
2053
|
+
const parameters = createParameters(def, parameterNames);
|
|
2126
2054
|
parameters.forEach((p) => {
|
|
2127
2055
|
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2128
2056
|
p.defaultValue = {
|
|
@@ -2162,7 +2090,7 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2162
2090
|
},
|
|
2163
2091
|
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2164
2092
|
...def.actionLevelValidation ? {
|
|
2165
|
-
validation:
|
|
2093
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
2166
2094
|
} : {},
|
|
2167
2095
|
...def.defaultFormat && {
|
|
2168
2096
|
defaultFormat: def.defaultFormat
|
|
@@ -2219,7 +2147,7 @@ function defineAction(actionDef) {
|
|
|
2219
2147
|
updateOntology(fullAction);
|
|
2220
2148
|
return fullAction;
|
|
2221
2149
|
}
|
|
2222
|
-
function createParameters(def, parameterSet
|
|
2150
|
+
function createParameters(def, parameterSet) {
|
|
2223
2151
|
const targetParam = [];
|
|
2224
2152
|
parameterSet.forEach((name) => {
|
|
2225
2153
|
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
@@ -2281,13 +2209,13 @@ function createParameters(def, parameterSet, defaultRequired) {
|
|
|
2281
2209
|
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2282
2210
|
...def.parameterConfiguration?.[id],
|
|
2283
2211
|
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 ??
|
|
2212
|
+
required: def.parameterConfiguration?.[id].required ?? def.objectType.properties?.[id]?.nullability?.noNulls ?? false
|
|
2285
2213
|
} : {
|
|
2286
2214
|
required: def.objectType.properties?.[id].array ?? false ? {
|
|
2287
2215
|
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
2288
2216
|
min: 1
|
|
2289
2217
|
} : {}
|
|
2290
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ??
|
|
2218
|
+
} : def.objectType.properties?.[id].nullability?.noNulls ?? false,
|
|
2291
2219
|
allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
|
|
2292
2220
|
},
|
|
2293
2221
|
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
@@ -2564,13 +2492,15 @@ function sanitize2(s) {
|
|
|
2564
2492
|
return s.includes(".") ? s : namespace + s;
|
|
2565
2493
|
}
|
|
2566
2494
|
function convertValidationRule(actionValidation) {
|
|
2567
|
-
return {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2495
|
+
return actionValidation.map((rule) => {
|
|
2496
|
+
return {
|
|
2497
|
+
condition: convertConditionDefinition(rule.condition),
|
|
2498
|
+
displayMetadata: rule.displayMetadata ?? {
|
|
2499
|
+
failureMessage: "Did not satisfy validation",
|
|
2500
|
+
typeClasses: []
|
|
2501
|
+
}
|
|
2502
|
+
};
|
|
2503
|
+
});
|
|
2574
2504
|
}
|
|
2575
2505
|
function validateActionConfiguration(action) {
|
|
2576
2506
|
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2948,6 +2878,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2948
2878
|
const baseType = convertValueTypeTypeToBaseType(type.type);
|
|
2949
2879
|
const vt = {
|
|
2950
2880
|
apiName,
|
|
2881
|
+
packageNamespace: namespace.substring(0, namespace.length - 1),
|
|
2951
2882
|
displayMetadata: {
|
|
2952
2883
|
displayName,
|
|
2953
2884
|
description: description ?? ""
|