@osdk/maker 0.14.0-beta.1 → 0.14.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/README.md +86 -22
- package/build/browser/api/action/DefaultFormat.js +2 -0
- package/build/browser/api/action/DefaultFormat.js.map +1 -0
- package/build/browser/api/action/TableConfiguration.js +2 -0
- package/build/browser/api/action/TableConfiguration.js.map +1 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +91 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/browser/api/code-snippets/snippetTypes.js +60 -0
- package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/browser/api/defineAction.js +131 -414
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +85 -0
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateObjectAction.js +80 -0
- package/build/browser/api/defineCreateObjectAction.js.map +1 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js +95 -0
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineDeleteObjectAction.js +56 -0
- package/build/browser/api/defineDeleteObjectAction.js.map +1 -0
- package/build/browser/api/defineLink.js +5 -13
- package/build/browser/api/defineLink.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +84 -0
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/browser/api/defineModifyObjectAction.js +93 -0
- package/build/browser/api/defineModifyObjectAction.js.map +1 -0
- package/build/browser/api/defineObject.js +94 -3
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +5 -1
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/links/LinkType.js.map +1 -1
- package/build/browser/api/object/ObjectType.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/browser/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/browser/api/test/actions.test.js +12034 -0
- package/build/browser/api/test/actions.test.js.map +1 -0
- package/build/browser/api/test/interfaces.test.js +924 -0
- package/build/browser/api/test/interfaces.test.js.map +1 -0
- package/build/browser/api/test/links.test.js +1974 -0
- package/build/browser/api/test/links.test.js.map +1 -0
- package/build/browser/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/browser/api/test/markingconstraint.test.js.map +1 -0
- package/build/browser/api/test/misc.test.js +1058 -0
- package/build/browser/api/test/misc.test.js.map +1 -0
- package/build/browser/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/browser/api/test/objectStatus.test.js.map +1 -0
- package/build/browser/api/test/objects.test.js +2591 -0
- package/build/browser/api/test/objects.test.js.map +1 -0
- package/build/browser/api/test/spt.test.js +387 -0
- package/build/browser/api/test/spt.test.js.map +1 -0
- package/build/browser/api/test/valueTypes.test.js +156 -0
- package/build/browser/api/test/valueTypes.test.js.map +1 -0
- package/build/browser/cli/main.js +23 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertActionValidation.js +2 -16
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +4 -4
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
- package/build/browser/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertLink.js +109 -24
- package/build/browser/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertObject.js +81 -4
- package/build/browser/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/browser/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/browser/index.js +8 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +1293 -832
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +184 -115
- package/build/esm/api/action/DefaultFormat.js +2 -0
- package/build/esm/api/action/DefaultFormat.js.map +1 -0
- package/build/esm/api/action/TableConfiguration.js +2 -0
- package/build/esm/api/action/TableConfiguration.js.map +1 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +91 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/esm/api/code-snippets/snippetTypes.js +60 -0
- package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/esm/api/defineAction.js +131 -414
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +85 -0
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateObjectAction.js +80 -0
- package/build/esm/api/defineCreateObjectAction.js.map +1 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js +95 -0
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -0
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineDeleteObjectAction.js +56 -0
- package/build/esm/api/defineDeleteObjectAction.js.map +1 -0
- package/build/esm/api/defineLink.js +5 -13
- package/build/esm/api/defineLink.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +84 -0
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -0
- package/build/esm/api/defineModifyObjectAction.js +93 -0
- package/build/esm/api/defineModifyObjectAction.js.map +1 -0
- package/build/esm/api/defineObject.js +94 -3
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +5 -1
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/links/LinkType.js.map +1 -1
- package/build/esm/api/object/ObjectType.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDatasourceDefinition.js.map +1 -1
- package/build/esm/api/object/ObjectTypeDefinition.js.map +1 -1
- package/build/esm/api/test/actions.test.js +12034 -0
- package/build/esm/api/test/actions.test.js.map +1 -0
- package/build/esm/api/test/interfaces.test.js +924 -0
- package/build/esm/api/test/interfaces.test.js.map +1 -0
- package/build/esm/api/test/links.test.js +1974 -0
- package/build/esm/api/test/links.test.js.map +1 -0
- package/build/esm/api/{markingconstraint.test.js → test/markingconstraint.test.js} +28 -2
- package/build/esm/api/test/markingconstraint.test.js.map +1 -0
- package/build/esm/api/test/misc.test.js +1058 -0
- package/build/esm/api/test/misc.test.js.map +1 -0
- package/build/esm/api/{objectStatus.test.js → test/objectStatus.test.js} +2 -2
- package/build/esm/api/test/objectStatus.test.js.map +1 -0
- package/build/esm/api/test/objects.test.js +2591 -0
- package/build/esm/api/test/objects.test.js.map +1 -0
- package/build/esm/api/test/spt.test.js +387 -0
- package/build/esm/api/test/spt.test.js.map +1 -0
- package/build/esm/api/test/valueTypes.test.js +156 -0
- package/build/esm/api/test/valueTypes.test.js.map +1 -0
- package/build/esm/cli/main.js +23 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertActionParameterConditionalOverride.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertActionValidation.js +2 -16
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +4 -4
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js +3 -2
- package/build/esm/conversion/toMarketplace/convertDatasourceDefinition.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertLink.js +109 -24
- package/build/esm/conversion/toMarketplace/convertLink.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertObject.js +81 -4
- package/build/esm/conversion/toMarketplace/convertObject.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js +2 -2
- package/build/esm/conversion/toMarketplace/convertSectionConditionalOverride.js.map +1 -1
- package/build/esm/index.js +8 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/api/action/DefaultFormat.d.ts +1 -0
- package/build/types/api/action/DefaultFormat.d.ts.map +1 -0
- package/build/types/api/action/TableConfiguration.d.ts +8 -0
- package/build/types/api/action/TableConfiguration.d.ts.map +1 -0
- package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
- package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts +23 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +34 -10
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineCreateOrModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineDeleteObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteObjectAction.d.ts.map +1 -0
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineModifyObjectAction.d.ts +3 -0
- package/build/types/api/defineModifyObjectAction.d.ts.map +1 -0
- package/build/types/api/defineObject.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +1 -1
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/links/LinkType.d.ts +7 -7
- package/build/types/api/object/ObjectType.d.ts +1 -1
- package/build/types/api/object/ObjectType.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts +41 -1
- package/build/types/api/object/ObjectTypeDatasourceDefinition.d.ts.map +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts +1 -1
- package/build/types/api/object/ObjectTypeDefinition.d.ts.map +1 -1
- package/build/types/api/test/actions.test.d.ts.map +1 -0
- package/build/types/api/test/interfaces.test.d.ts.map +1 -0
- package/build/types/api/test/links.test.d.ts.map +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts +1 -0
- package/build/types/api/test/markingconstraint.test.d.ts.map +1 -0
- package/build/types/api/test/misc.test.d.ts +1 -0
- package/build/types/api/test/misc.test.d.ts.map +1 -0
- package/build/types/api/test/objectStatus.test.d.ts +1 -0
- package/build/types/api/test/objectStatus.test.d.ts.map +1 -0
- package/build/types/api/test/objects.test.d.ts +1 -0
- package/build/types/api/test/objects.test.d.ts.map +1 -0
- package/build/types/api/test/spt.test.d.ts +1 -0
- package/build/types/api/test/spt.test.d.ts.map +1 -0
- package/build/types/api/test/valueTypes.test.d.ts +1 -0
- package/build/types/api/test/valueTypes.test.d.ts.map +1 -0
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts +2 -2
- package/build/types/conversion/toMarketplace/convertActionParameterConditionalOverride.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts +0 -1
- package/build/types/conversion/toMarketplace/convertActionValidation.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertConditionDefinition.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertLink.d.ts +6 -0
- package/build/types/conversion/toMarketplace/convertLink.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertObject.d.ts.map +1 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts +2 -1
- package/build/types/conversion/toMarketplace/convertSectionConditionalOverride.d.ts.map +1 -1
- package/build/types/index.d.ts +8 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +8 -5
- package/build/browser/api/markingconstraint.test.js.map +0 -1
- package/build/browser/api/objectStatus.test.js.map +0 -1
- package/build/browser/api/overall.test.js +0 -14002
- package/build/browser/api/overall.test.js.map +0 -1
- package/build/esm/api/markingconstraint.test.js.map +0 -1
- package/build/esm/api/objectStatus.test.js.map +0 -1
- package/build/esm/api/overall.test.js +0 -14002
- package/build/esm/api/overall.test.js.map +0 -1
- package/build/types/api/markingconstraint.test.d.ts.map +0 -1
- package/build/types/api/objectStatus.test.d.ts.map +0 -1
- package/build/types/api/overall.test.d.ts.map +0 -1
- /package/build/types/api/{markingconstraint.test.d.ts → test/actions.test.d.ts} +0 -0
- /package/build/types/api/{objectStatus.test.d.ts → test/interfaces.test.d.ts} +0 -0
- /package/build/types/api/{overall.test.d.ts → test/links.test.d.ts} +0 -0
package/build/cjs/index.cjs
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var consola = require('consola');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
6
|
+
var fs3 = require('fs/promises');
|
|
7
|
+
var path3 = require('path');
|
|
8
|
+
var invariant7 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
|
-
var
|
|
11
|
+
var fs2 = require('fs');
|
|
12
|
+
var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
13
|
+
var Mustache = require('mustache');
|
|
12
14
|
var crypto = require('crypto');
|
|
13
15
|
|
|
14
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,11 +33,12 @@ function _interopNamespace(e) {
|
|
|
31
33
|
return Object.freeze(n);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
36
|
+
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
37
|
+
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
38
|
+
var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
|
|
37
39
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
38
|
-
var
|
|
40
|
+
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
41
|
+
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
39
42
|
|
|
40
43
|
// src/cli/main.ts
|
|
41
44
|
|
|
@@ -66,6 +69,193 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2)
|
|
|
66
69
|
return OntologyEntityTypeEnum2;
|
|
67
70
|
})({});
|
|
68
71
|
|
|
72
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
73
|
+
function convertCardinality(cardinality) {
|
|
74
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
75
|
+
return "ONE_TO_MANY";
|
|
76
|
+
}
|
|
77
|
+
return "ONE_TO_ONE";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/conversion/toMarketplace/convertLink.ts
|
|
81
|
+
function convertLink(linkType) {
|
|
82
|
+
validateLink(linkType);
|
|
83
|
+
let definition;
|
|
84
|
+
let datasource = void 0;
|
|
85
|
+
if ("one" in linkType) {
|
|
86
|
+
const {
|
|
87
|
+
apiName: oneObjectApiName,
|
|
88
|
+
object: oneObject
|
|
89
|
+
} = getObject(linkType.one.object);
|
|
90
|
+
const {
|
|
91
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
92
|
+
definition = {
|
|
93
|
+
type: "oneToMany",
|
|
94
|
+
oneToMany: {
|
|
95
|
+
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
96
|
+
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
97
|
+
objectTypeRidManySide: toManyObjectApiName,
|
|
98
|
+
objectTypeRidOneSide: oneObjectApiName,
|
|
99
|
+
oneToManyLinkMetadata: linkType.one.metadata,
|
|
100
|
+
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
101
|
+
from: {
|
|
102
|
+
apiName: oneObject.primaryKeyPropertyApiName,
|
|
103
|
+
object: oneObjectApiName
|
|
104
|
+
},
|
|
105
|
+
to: {
|
|
106
|
+
apiName: linkType.manyForeignKeyProperty,
|
|
107
|
+
object: toManyObjectApiName
|
|
108
|
+
}
|
|
109
|
+
}]
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
113
|
+
const {
|
|
114
|
+
apiName: manyObjectApiName} = getObject(linkType.many.object);
|
|
115
|
+
const {
|
|
116
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
117
|
+
definition = {
|
|
118
|
+
type: "intermediary",
|
|
119
|
+
intermediary: {
|
|
120
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
121
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
122
|
+
objectTypeRidA: manyObjectApiName,
|
|
123
|
+
objectTypeRidB: toManyObjectApiName,
|
|
124
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
125
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
126
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
const {
|
|
131
|
+
apiName: manyObjectApiName,
|
|
132
|
+
object: manyObject
|
|
133
|
+
} = getObject(linkType.many.object);
|
|
134
|
+
const {
|
|
135
|
+
apiName: toManyObjectApiName,
|
|
136
|
+
object: toManyObject
|
|
137
|
+
} = getObject(linkType.toMany.object);
|
|
138
|
+
definition = {
|
|
139
|
+
type: "manyToMany",
|
|
140
|
+
manyToMany: {
|
|
141
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
142
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
143
|
+
objectTypeRidA: manyObjectApiName,
|
|
144
|
+
objectTypeRidB: toManyObjectApiName,
|
|
145
|
+
peeringMetadata: void 0,
|
|
146
|
+
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
147
|
+
from: {
|
|
148
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
149
|
+
object: manyObjectApiName
|
|
150
|
+
},
|
|
151
|
+
to: {
|
|
152
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
153
|
+
object: manyObjectApiName
|
|
154
|
+
}
|
|
155
|
+
}],
|
|
156
|
+
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
157
|
+
from: {
|
|
158
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
159
|
+
object: toManyObjectApiName
|
|
160
|
+
},
|
|
161
|
+
to: {
|
|
162
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
163
|
+
object: toManyObjectApiName
|
|
164
|
+
}
|
|
165
|
+
}]
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
datasource = {
|
|
169
|
+
datasourceName: linkType.apiName,
|
|
170
|
+
datasource: {
|
|
171
|
+
type: "dataset",
|
|
172
|
+
dataset: {
|
|
173
|
+
datasetRid: "link-".concat(linkType.apiName),
|
|
174
|
+
writebackDatasetRid: void 0,
|
|
175
|
+
objectTypeAPrimaryKeyMapping: [{
|
|
176
|
+
property: {
|
|
177
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
178
|
+
object: manyObjectApiName
|
|
179
|
+
},
|
|
180
|
+
column: manyObject.primaryKeyPropertyApiName
|
|
181
|
+
}],
|
|
182
|
+
objectTypeBPrimaryKeyMapping: [{
|
|
183
|
+
property: {
|
|
184
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
185
|
+
object: toManyObjectApiName
|
|
186
|
+
},
|
|
187
|
+
column: toManyObject.primaryKeyPropertyApiName
|
|
188
|
+
}]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
editsConfiguration: {
|
|
192
|
+
onlyAllowPrivilegedEdits: false
|
|
193
|
+
},
|
|
194
|
+
redacted: linkType.redacted
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
linkType: {
|
|
199
|
+
definition,
|
|
200
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
201
|
+
status: linkType.status ?? {
|
|
202
|
+
type: "active",
|
|
203
|
+
active: {}
|
|
204
|
+
},
|
|
205
|
+
redacted: linkType.redacted ?? false
|
|
206
|
+
},
|
|
207
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
208
|
+
entityMetadata: {
|
|
209
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function validateLink(linkDefinition) {
|
|
214
|
+
if ("one" in linkDefinition) {
|
|
215
|
+
const {
|
|
216
|
+
object: oneObject
|
|
217
|
+
} = getObject(linkDefinition.one.object);
|
|
218
|
+
const {
|
|
219
|
+
apiName: toManyObjectApiName,
|
|
220
|
+
object: toManyObject
|
|
221
|
+
} = getObject(linkDefinition.toMany.object);
|
|
222
|
+
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
223
|
+
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${toManyObjectApiName}`) : invariant7__default.default(false) : void 0;
|
|
224
|
+
!/([a-z][a-z0-9\\-]*)/.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant7__default.default(false) : void 0;
|
|
225
|
+
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
226
|
+
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant7__default.default(false) : void 0;
|
|
227
|
+
}
|
|
228
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
229
|
+
const {
|
|
230
|
+
apiName: intermediaryObjectTypeApiName} = getObject(linkDefinition.intermediaryObjectType);
|
|
231
|
+
const {
|
|
232
|
+
apiName: manyObjectApiName,
|
|
233
|
+
object: manyObject
|
|
234
|
+
} = getObject(linkDefinition.many.object);
|
|
235
|
+
const {
|
|
236
|
+
apiName: toManyObjectApiName} = getObject(linkDefinition.toMany.object);
|
|
237
|
+
const {
|
|
238
|
+
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
239
|
+
const {
|
|
240
|
+
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
241
|
+
!("one" in linkDefinition.many.linkToIntermediary && manyIntermediaryOneObjectApiName === manyObject.apiName && manyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectA ${manyObjectApiName}`) : invariant7__default.default(false) : void 0;
|
|
242
|
+
const {
|
|
243
|
+
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
244
|
+
const {
|
|
245
|
+
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
246
|
+
!("one" in linkDefinition.toMany.linkToIntermediary && toManyIntermediaryOneObjectApiName === toManyObjectApiName && toManyIntermediaryToManyObjectApiName === intermediaryObjectTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${intermediaryObjectTypeApiName} to objectB ${toManyObjectApiName}`) : invariant7__default.default(false) : void 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function getObject(object) {
|
|
250
|
+
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
251
|
+
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
252
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object ${objectApiName} is not defined`) : invariant7__default.default(false) : void 0;
|
|
253
|
+
return {
|
|
254
|
+
apiName: objectApiName,
|
|
255
|
+
object: fullObject
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
69
259
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
70
260
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
71
261
|
let properties = interfaceType.propertiesV2;
|
|
@@ -107,12 +297,20 @@ function defineObject(objectDef) {
|
|
|
107
297
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
108
298
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
109
299
|
}
|
|
110
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
111
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
112
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
113
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
114
|
-
const
|
|
115
|
-
|
|
300
|
+
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Invalid API name ${objectDef.apiName}. API names must match the regex ${API_NAME_PATTERN}.`) : invariant7__default.default(false) : void 0;
|
|
301
|
+
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Title property ${objectDef.titlePropertyApiName} is not defined on object ${objectDef.apiName}`) : invariant7__default.default(false) : void 0;
|
|
302
|
+
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} does not exist on object ${objectDef.apiName}`) : invariant7__default.default(false) : void 0;
|
|
303
|
+
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} on object ${objectDef.apiName} cannot be edit-only`) : invariant7__default.default(false) : void 0;
|
|
304
|
+
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
305
|
+
retentionPeriods.forEach((retentionPeriod) => {
|
|
306
|
+
!(retentionPeriod === void 0 || ISO_8601_DURATION.test(retentionPeriod)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Retention period "${retentionPeriod}" on object "${objectDef.apiName}" is not a valid ISO 8601 duration string`) : invariant7__default.default(false) : void 0;
|
|
307
|
+
});
|
|
308
|
+
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
309
|
+
!(baseDatasources.length <= 1) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object ${objectDef.apiName} has more than one base datasource (got: [${baseDatasources.map((ds) => ds.type).join(", ")}])`) : invariant7__default.default(false) : void 0;
|
|
310
|
+
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
311
|
+
if (derivedDatasources.length > 0) {
|
|
312
|
+
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
313
|
+
}
|
|
116
314
|
if (objectDef.status === "experimental") {
|
|
117
315
|
const activeProperties = [];
|
|
118
316
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -120,14 +318,14 @@ function defineObject(objectDef) {
|
|
|
120
318
|
activeProperties.push(apiName2);
|
|
121
319
|
}
|
|
122
320
|
});
|
|
123
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
321
|
+
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant7__default.default(false) : void 0;
|
|
124
322
|
}
|
|
125
323
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
126
324
|
const deadline = objectDef.status.deadline;
|
|
127
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
325
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant7__default.default(false) : void 0;
|
|
128
326
|
}
|
|
129
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
130
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
327
|
+
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Title property ${objectDef.titlePropertyApiName} must be a primitive type`) : invariant7__default.default(false) : void 0;
|
|
328
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant7__default.default(false) : void 0;
|
|
131
329
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
132
330
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
133
331
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -146,7 +344,7 @@ function defineObject(objectDef) {
|
|
|
146
344
|
};
|
|
147
345
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
148
346
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
149
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
347
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant7__default.default(false) : void 0;
|
|
150
348
|
});
|
|
151
349
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
152
350
|
const finalObject = {
|
|
@@ -197,6 +395,72 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
197
395
|
type: property.type
|
|
198
396
|
};
|
|
199
397
|
}
|
|
398
|
+
function validateDerivedDatasource(objectDef, datasource) {
|
|
399
|
+
!(datasource.linkDefinition.length > 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Derived datasource for object '${objectDef.apiName}' must have at least one link.`) : invariant7__default.default(false) : void 0;
|
|
400
|
+
datasource.linkDefinition.forEach((link) => {
|
|
401
|
+
const linkApiName = link.linkType.apiName;
|
|
402
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0 || importedTypes[OntologyEntityTypeEnum.LINK_TYPE][linkApiName] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Link type '${linkApiName}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant7__default.default(false) : void 0;
|
|
403
|
+
});
|
|
404
|
+
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
405
|
+
!(objectDef.properties?.[prop] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${prop}' used in derived datasource for object '${objectDef.apiName}' is not defined.`) : invariant7__default.default(false) : void 0;
|
|
406
|
+
});
|
|
407
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
408
|
+
if (isLinkedProperties) {
|
|
409
|
+
validateLinkedProperties(datasource);
|
|
410
|
+
} else {
|
|
411
|
+
validateAggregations(datasource, objectDef);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function validateLinkedProperties(datasource, objectDef) {
|
|
415
|
+
const foreignProperties = Object.values(datasource.propertyMapping);
|
|
416
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
417
|
+
foreignProperties.forEach((prop) => {
|
|
418
|
+
!(finalObject.properties?.find((p) => p.apiName === prop) !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${prop}' on object '${finalObject.apiName}' is not defined`) : invariant7__default.default(false) : void 0;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function validateAggregations(datasource, objectDef) {
|
|
422
|
+
const props = datasource.propertyMapping;
|
|
423
|
+
Object.entries(props).forEach(([propName, agg]) => {
|
|
424
|
+
const property = objectDef.properties[propName];
|
|
425
|
+
switch (agg.type) {
|
|
426
|
+
case "collectList":
|
|
427
|
+
case "collectSet":
|
|
428
|
+
!isCollectible(property) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not collectible`) : invariant7__default.default(false) : void 0;
|
|
429
|
+
!(agg.limit <= 100) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `[Error] Limit for collection '${propName}' on object '${objectDef.apiName}' is greater than 100`) : invariant7__default.default(false) : void 0;
|
|
430
|
+
break;
|
|
431
|
+
case "avg":
|
|
432
|
+
case "sum":
|
|
433
|
+
!isNumeric(property.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not numeric`) : invariant7__default.default(false) : void 0;
|
|
434
|
+
break;
|
|
435
|
+
case "min":
|
|
436
|
+
case "max":
|
|
437
|
+
case "approximateCardinality":
|
|
438
|
+
case "exactCardinality":
|
|
439
|
+
!isPrimitive(property.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${propName}' on object '${objectDef.apiName}' is not primitive`) : invariant7__default.default(false) : void 0;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
if (agg.type !== "count") {
|
|
443
|
+
const foreignProperty = agg.property;
|
|
444
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
445
|
+
!(finalObject.properties?.find((p) => p.apiName === foreignProperty) !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property '${foreignProperty}' on object '${finalObject.apiName}' is not defined`) : invariant7__default.default(false) : void 0;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
function isCollectible(property) {
|
|
450
|
+
if (!(property.array ?? false)) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
const typeType = typeof property.type === "string" ? property.type : property.type.type;
|
|
454
|
+
return ["boolean", "byte", "date", "double", "float", "geohash", "geoshape", "integer", "long", "mediareference", "short", "string", "struct", "timestamp"].includes(typeType);
|
|
455
|
+
}
|
|
456
|
+
function isNumeric(type) {
|
|
457
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
458
|
+
return ["byte", "double", "float", "integer", "long", "short"].includes(typeType);
|
|
459
|
+
}
|
|
460
|
+
function isPrimitive(type) {
|
|
461
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
462
|
+
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
463
|
+
}
|
|
200
464
|
|
|
201
465
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
202
466
|
function convertActionSections(action) {
|
|
@@ -224,14 +488,14 @@ function convertActionSections(action) {
|
|
|
224
488
|
}
|
|
225
489
|
}]));
|
|
226
490
|
}
|
|
227
|
-
function convertConditionDefinition(condition,
|
|
491
|
+
function convertConditionDefinition(condition, actionParameters) {
|
|
228
492
|
switch (condition.type) {
|
|
229
493
|
case "and":
|
|
230
494
|
if ("conditions" in condition) {
|
|
231
495
|
return {
|
|
232
496
|
type: "and",
|
|
233
497
|
and: {
|
|
234
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c,
|
|
498
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
235
499
|
}
|
|
236
500
|
};
|
|
237
501
|
} else {
|
|
@@ -242,7 +506,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
242
506
|
return {
|
|
243
507
|
type: "or",
|
|
244
508
|
or: {
|
|
245
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c,
|
|
509
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
246
510
|
}
|
|
247
511
|
};
|
|
248
512
|
} else {
|
|
@@ -278,7 +542,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
278
542
|
}
|
|
279
543
|
};
|
|
280
544
|
case "parameter":
|
|
281
|
-
!
|
|
545
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant7__default.default(false) : void 0;
|
|
282
546
|
return {
|
|
283
547
|
type: "comparison",
|
|
284
548
|
comparison: {
|
|
@@ -296,7 +560,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
296
560
|
}
|
|
297
561
|
|
|
298
562
|
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
299
|
-
function convertActionParameterConditionalOverride(override, validation,
|
|
563
|
+
function convertActionParameterConditionalOverride(override, validation, actionParameters) {
|
|
300
564
|
let parameterBlockOverride;
|
|
301
565
|
switch (override.type) {
|
|
302
566
|
case "required":
|
|
@@ -361,7 +625,7 @@ function convertActionParameterConditionalOverride(override, validation, objectP
|
|
|
361
625
|
throw new Error(`Unknown parameter override type`);
|
|
362
626
|
}
|
|
363
627
|
return {
|
|
364
|
-
condition: convertConditionDefinition(override.condition,
|
|
628
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
365
629
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
366
630
|
};
|
|
367
631
|
}
|
|
@@ -393,9 +657,9 @@ function convertActionVisibility(visibility) {
|
|
|
393
657
|
}
|
|
394
658
|
|
|
395
659
|
// src/conversion/toMarketplace/convertSectionConditionalOverride.ts
|
|
396
|
-
function convertSectionConditionalOverride(override, defaultVisibility,
|
|
660
|
+
function convertSectionConditionalOverride(override, defaultVisibility, actionParameters) {
|
|
397
661
|
return {
|
|
398
|
-
condition: convertConditionDefinition(override.condition,
|
|
662
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
399
663
|
sectionBlockOverrides: [{
|
|
400
664
|
type: "visibility",
|
|
401
665
|
visibility: {
|
|
@@ -441,7 +705,7 @@ function convertActionValidation(action) {
|
|
|
441
705
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
442
706
|
}
|
|
443
707
|
},
|
|
444
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation,
|
|
708
|
+
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation, action.parameters)) ?? []
|
|
445
709
|
}];
|
|
446
710
|
})),
|
|
447
711
|
sectionValidations: {
|
|
@@ -457,7 +721,7 @@ function convertActionValidation(action) {
|
|
|
457
721
|
visible: {}
|
|
458
722
|
}
|
|
459
723
|
},
|
|
460
|
-
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible",
|
|
724
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", action.parameters)) ?? []
|
|
461
725
|
}]))
|
|
462
726
|
}
|
|
463
727
|
};
|
|
@@ -484,20 +748,6 @@ function convertParameterRequirementConstraint(required) {
|
|
|
484
748
|
}
|
|
485
749
|
};
|
|
486
750
|
}
|
|
487
|
-
function getActionTypeObjectParameters(actionType) {
|
|
488
|
-
switch (actionType.rules[0].type) {
|
|
489
|
-
case "addObjectRule":
|
|
490
|
-
return Object.keys(actionType.rules[0].addObjectRule.propertyValues);
|
|
491
|
-
case "modifyObjectRule":
|
|
492
|
-
return Object.keys(actionType.rules[0].modifyObjectRule.propertyValues);
|
|
493
|
-
case "addOrModifyObjectRuleV2":
|
|
494
|
-
return Object.keys(actionType.rules[0].addOrModifyObjectRuleV2.propertyValues);
|
|
495
|
-
case "deleteObjectRule":
|
|
496
|
-
return [];
|
|
497
|
-
default:
|
|
498
|
-
return void 0;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
751
|
function convertNullabilityToDataConstraint(prop) {
|
|
502
752
|
if (typeof prop.type === "object" && prop.type.type === "marking") {
|
|
503
753
|
if (prop.nullability === void 0) {
|
|
@@ -510,7 +760,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
510
760
|
}
|
|
511
761
|
};
|
|
512
762
|
}
|
|
513
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
763
|
+
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Marking property type has noNulls set to false, marking properties must not be nullable") : invariant7__default.default(false) : void 0;
|
|
514
764
|
return {
|
|
515
765
|
propertyTypeConstraints: [],
|
|
516
766
|
nullability: void 0,
|
|
@@ -714,134 +964,12 @@ function convertInterface(interfaceType) {
|
|
|
714
964
|
};
|
|
715
965
|
}
|
|
716
966
|
|
|
717
|
-
// src/conversion/toMarketplace/convertCardinality.ts
|
|
718
|
-
function convertCardinality(cardinality) {
|
|
719
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
720
|
-
return "ONE_TO_MANY";
|
|
721
|
-
}
|
|
722
|
-
return "ONE_TO_ONE";
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// src/conversion/toMarketplace/convertLink.ts
|
|
726
|
-
function convertLink(linkType) {
|
|
727
|
-
let definition;
|
|
728
|
-
let datasource = void 0;
|
|
729
|
-
if ("one" in linkType) {
|
|
730
|
-
definition = {
|
|
731
|
-
type: "oneToMany",
|
|
732
|
-
oneToMany: {
|
|
733
|
-
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
734
|
-
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
735
|
-
objectTypeRidManySide: linkType.toMany.object.apiName,
|
|
736
|
-
objectTypeRidOneSide: linkType.one.object.apiName,
|
|
737
|
-
oneToManyLinkMetadata: linkType.one.metadata,
|
|
738
|
-
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
739
|
-
from: {
|
|
740
|
-
apiName: linkType.one.object.primaryKeyPropertyApiName,
|
|
741
|
-
object: linkType.one.object.apiName
|
|
742
|
-
},
|
|
743
|
-
to: {
|
|
744
|
-
apiName: linkType.manyForeignKeyProperty,
|
|
745
|
-
object: linkType.toMany.object.apiName
|
|
746
|
-
}
|
|
747
|
-
}]
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
} else if ("intermediaryObjectType" in linkType) {
|
|
751
|
-
definition = {
|
|
752
|
-
type: "intermediary",
|
|
753
|
-
intermediary: {
|
|
754
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
755
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
756
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
757
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
758
|
-
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
759
|
-
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
760
|
-
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
} else {
|
|
764
|
-
definition = {
|
|
765
|
-
type: "manyToMany",
|
|
766
|
-
manyToMany: {
|
|
767
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
768
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
769
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
770
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
771
|
-
peeringMetadata: void 0,
|
|
772
|
-
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
773
|
-
from: {
|
|
774
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
775
|
-
object: linkType.many.object.apiName
|
|
776
|
-
},
|
|
777
|
-
to: {
|
|
778
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
779
|
-
object: linkType.many.object.apiName
|
|
780
|
-
}
|
|
781
|
-
}],
|
|
782
|
-
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
783
|
-
from: {
|
|
784
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
785
|
-
object: linkType.toMany.object.apiName
|
|
786
|
-
},
|
|
787
|
-
to: {
|
|
788
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
789
|
-
object: linkType.toMany.object.apiName
|
|
790
|
-
}
|
|
791
|
-
}]
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
datasource = {
|
|
795
|
-
datasourceName: linkType.apiName,
|
|
796
|
-
datasource: {
|
|
797
|
-
type: "dataset",
|
|
798
|
-
dataset: {
|
|
799
|
-
datasetRid: "link-".concat(linkType.apiName),
|
|
800
|
-
writebackDatasetRid: void 0,
|
|
801
|
-
objectTypeAPrimaryKeyMapping: [{
|
|
802
|
-
property: {
|
|
803
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
804
|
-
object: linkType.many.object.apiName
|
|
805
|
-
},
|
|
806
|
-
column: linkType.many.object.primaryKeyPropertyApiName
|
|
807
|
-
}],
|
|
808
|
-
objectTypeBPrimaryKeyMapping: [{
|
|
809
|
-
property: {
|
|
810
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
811
|
-
object: linkType.toMany.object.apiName
|
|
812
|
-
},
|
|
813
|
-
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
814
|
-
}]
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
editsConfiguration: {
|
|
818
|
-
onlyAllowPrivilegedEdits: false
|
|
819
|
-
},
|
|
820
|
-
redacted: linkType.redacted
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
return {
|
|
824
|
-
linkType: {
|
|
825
|
-
definition,
|
|
826
|
-
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
827
|
-
status: linkType.status ?? {
|
|
828
|
-
type: "active",
|
|
829
|
-
active: {}
|
|
830
|
-
},
|
|
831
|
-
redacted: linkType.redacted ?? false
|
|
832
|
-
},
|
|
833
|
-
datasources: datasource !== void 0 ? [datasource] : [],
|
|
834
|
-
entityMetadata: {
|
|
835
|
-
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
|
|
840
967
|
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
841
968
|
function convertDatasourceDefinition(objectType, properties) {
|
|
842
|
-
|
|
969
|
+
const baseDatasource = objectType.datasources?.find((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
970
|
+
switch (baseDatasource?.type) {
|
|
843
971
|
case "stream":
|
|
844
|
-
const window =
|
|
972
|
+
const window = baseDatasource.retentionPeriod;
|
|
845
973
|
const retentionPolicy = window ? {
|
|
846
974
|
type: "time",
|
|
847
975
|
time: {
|
|
@@ -1030,7 +1158,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1030
1158
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1031
1159
|
function convertObjectPropertyType(property) {
|
|
1032
1160
|
const apiName = namespace + property.apiName;
|
|
1033
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1161
|
+
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property type ${apiName} of type '${getPropertyTypeName(property.type)}' should not have render hints`) : invariant7__default.default(false) : void 0;
|
|
1034
1162
|
const output = {
|
|
1035
1163
|
apiName: property.apiName,
|
|
1036
1164
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1060,12 +1188,16 @@ function convertObjectPropertyType(property) {
|
|
|
1060
1188
|
|
|
1061
1189
|
// src/conversion/toMarketplace/convertObject.ts
|
|
1062
1190
|
function convertObject(objectType) {
|
|
1063
|
-
const
|
|
1191
|
+
const {
|
|
1192
|
+
derivedDatasources,
|
|
1193
|
+
derivedPropertyNames
|
|
1194
|
+
} = extractDerivedDatasources(objectType);
|
|
1195
|
+
const propertyDatasources = (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName)).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
1064
1196
|
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1065
1197
|
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1066
1198
|
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1067
1199
|
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1068
|
-
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, objectType.properties ?? []), classificationInputGroup, mandatoryInputGroup);
|
|
1200
|
+
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName))), classificationInputGroup, mandatoryInputGroup);
|
|
1069
1201
|
const implementations = objectType.implementsInterfaces ?? [];
|
|
1070
1202
|
return {
|
|
1071
1203
|
objectType: {
|
|
@@ -1099,7 +1231,7 @@ function convertObject(objectType) {
|
|
|
1099
1231
|
})),
|
|
1100
1232
|
allImplementsInterfaces: {}
|
|
1101
1233
|
},
|
|
1102
|
-
datasources: [...propertyDatasources, objectDatasource],
|
|
1234
|
+
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1103
1235
|
entityMetadata: {
|
|
1104
1236
|
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1105
1237
|
}
|
|
@@ -1142,6 +1274,80 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1142
1274
|
return [];
|
|
1143
1275
|
}
|
|
1144
1276
|
}
|
|
1277
|
+
function extractDerivedDatasources(objectType) {
|
|
1278
|
+
const inputDerivedDatasources = (objectType.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
1279
|
+
const derivedDatasources = inputDerivedDatasources.map((ds, i) => buildDerivedDatasource(ds, i, objectType.apiName));
|
|
1280
|
+
const derivedPropertyNames = inputDerivedDatasources.flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
1281
|
+
return {
|
|
1282
|
+
derivedDatasources,
|
|
1283
|
+
derivedPropertyNames
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
function buildDerivedDatasource(datasource, index, objectTypeApiName) {
|
|
1287
|
+
const linkDefinition = {
|
|
1288
|
+
type: "multiHopLink",
|
|
1289
|
+
multiHopLink: {
|
|
1290
|
+
steps: datasource.linkDefinition.map((step) => ({
|
|
1291
|
+
type: "searchAround",
|
|
1292
|
+
searchAround: {
|
|
1293
|
+
linkTypeIdentifier: {
|
|
1294
|
+
type: "linkType",
|
|
1295
|
+
linkType: cleanAndValidateLinkTypeId(step.linkType.apiName)
|
|
1296
|
+
},
|
|
1297
|
+
linkTypeSide: step.side ?? "SOURCE"
|
|
1298
|
+
}
|
|
1299
|
+
}))
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
1303
|
+
const derivedDefinition = isLinkedProperties ? {
|
|
1304
|
+
type: "linkedProperties",
|
|
1305
|
+
linkedProperties: {
|
|
1306
|
+
linkDefinition,
|
|
1307
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, targetProp]) => [sourceProp, {
|
|
1308
|
+
type: "propertyType",
|
|
1309
|
+
propertyType: targetProp
|
|
1310
|
+
}]))
|
|
1311
|
+
}
|
|
1312
|
+
} : {
|
|
1313
|
+
type: "aggregatedProperties",
|
|
1314
|
+
aggregatedProperties: {
|
|
1315
|
+
linkDefinition,
|
|
1316
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, agg]) => [sourceProp, buildAggregation(agg)]))
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
const fullDefinition = {
|
|
1320
|
+
type: "derived",
|
|
1321
|
+
derived: {
|
|
1322
|
+
definition: derivedDefinition
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
return buildDatasource(objectTypeApiName + ".derived." + index.toString(), fullDefinition);
|
|
1326
|
+
}
|
|
1327
|
+
function buildAggregation(agg) {
|
|
1328
|
+
const type = agg.type;
|
|
1329
|
+
const limit = "limit" in agg ? agg.limit : void 0;
|
|
1330
|
+
const foreignProperty = "property" in agg ? agg.property : void 0;
|
|
1331
|
+
const innerDef = {};
|
|
1332
|
+
if (type !== "count") {
|
|
1333
|
+
if (["collectList", "collectSet"].includes(type)) {
|
|
1334
|
+
innerDef["linkedProperty"] = {
|
|
1335
|
+
type: "propertyType",
|
|
1336
|
+
propertyType: foreignProperty
|
|
1337
|
+
};
|
|
1338
|
+
innerDef["limit"] = limit;
|
|
1339
|
+
} else {
|
|
1340
|
+
innerDef["property"] = {
|
|
1341
|
+
type: "propertyType",
|
|
1342
|
+
propertyType: foreignProperty
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
return {
|
|
1347
|
+
type,
|
|
1348
|
+
[type]: innerDef
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1145
1351
|
|
|
1146
1352
|
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1147
1353
|
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
@@ -1240,8 +1446,105 @@ function getFormContentOrdering(action, parameterOrdering) {
|
|
|
1240
1446
|
return formContentOrdering;
|
|
1241
1447
|
}
|
|
1242
1448
|
|
|
1243
|
-
// src/api/
|
|
1244
|
-
var
|
|
1449
|
+
// src/api/code-snippets/snippetTypes.ts
|
|
1450
|
+
var interfaceSnippets = /* @__PURE__ */ (function(interfaceSnippets2) {
|
|
1451
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfacesReference"] = 0] = "loadInterfacesReference";
|
|
1452
|
+
interfaceSnippets2[interfaceSnippets2["loadAllInterfacesReference"] = 1] = "loadAllInterfacesReference";
|
|
1453
|
+
interfaceSnippets2[interfaceSnippets2["loadOrderedInterfacesReference"] = 2] = "loadOrderedInterfacesReference";
|
|
1454
|
+
interfaceSnippets2[interfaceSnippets2["searchInterfacesReference"] = 3] = "searchInterfacesReference";
|
|
1455
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfaceMetadataSnippet"] = 4] = "loadInterfaceMetadataSnippet";
|
|
1456
|
+
interfaceSnippets2[interfaceSnippets2["subscribeToObjectSetInstructions"] = 5] = "subscribeToObjectSetInstructions";
|
|
1457
|
+
return interfaceSnippets2;
|
|
1458
|
+
})({});
|
|
1459
|
+
var actionSnippets = /* @__PURE__ */ (function(actionSnippets2) {
|
|
1460
|
+
actionSnippets2[actionSnippets2["applyAction"] = 0] = "applyAction";
|
|
1461
|
+
actionSnippets2[actionSnippets2["batchApplyAction"] = 1] = "batchApplyAction";
|
|
1462
|
+
return actionSnippets2;
|
|
1463
|
+
})({});
|
|
1464
|
+
var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
|
|
1465
|
+
objectSnippets2[objectSnippets2["loadSingleObjectGuide"] = 0] = "loadSingleObjectGuide";
|
|
1466
|
+
objectSnippets2[objectSnippets2["loadObjectsReference"] = 1] = "loadObjectsReference";
|
|
1467
|
+
objectSnippets2[objectSnippets2["loadAllObjectsReference"] = 2] = "loadAllObjectsReference";
|
|
1468
|
+
objectSnippets2[objectSnippets2["loadOrderedInterfacesReference"] = 3] = "loadOrderedInterfacesReference";
|
|
1469
|
+
objectSnippets2[objectSnippets2["searchObjectsGuide"] = 4] = "searchObjectsGuide";
|
|
1470
|
+
objectSnippets2[objectSnippets2["aggregationTemplate"] = 5] = "aggregationTemplate";
|
|
1471
|
+
objectSnippets2[objectSnippets2["objectSetOperationsGuide"] = 6] = "objectSetOperationsGuide";
|
|
1472
|
+
objectSnippets2[objectSnippets2["loadObjectMetadataSnippet"] = 7] = "loadObjectMetadataSnippet";
|
|
1473
|
+
objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
|
|
1474
|
+
return objectSnippets2;
|
|
1475
|
+
})({});
|
|
1476
|
+
|
|
1477
|
+
// src/api/code-snippets/createCodeSnippets.ts
|
|
1478
|
+
function createCodeSnippets(ontology, packageName, outputDir) {
|
|
1479
|
+
if (outputDir === void 0) {
|
|
1480
|
+
outputDir = "./code-snippets";
|
|
1481
|
+
}
|
|
1482
|
+
if (!fs2__namespace.existsSync(outputDir)) {
|
|
1483
|
+
fs2__namespace.mkdirSync(outputDir, {
|
|
1484
|
+
recursive: true
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
if (packageName === void 0) {
|
|
1488
|
+
packageName = "";
|
|
1489
|
+
}
|
|
1490
|
+
consola.consola.info("Generating code snippets to ", outputDir);
|
|
1491
|
+
for (const type of Object.values(OntologyEntityTypeEnum)) {
|
|
1492
|
+
for (const object of Object.values(ontology[type])) {
|
|
1493
|
+
let snippet = {};
|
|
1494
|
+
switch (type) {
|
|
1495
|
+
case OntologyEntityTypeEnum.OBJECT_TYPE:
|
|
1496
|
+
snippet = generateObjectSnippet(object, packageName);
|
|
1497
|
+
break;
|
|
1498
|
+
case OntologyEntityTypeEnum.ACTION_TYPE:
|
|
1499
|
+
snippet = generateActionSnippet(object, packageName);
|
|
1500
|
+
break;
|
|
1501
|
+
case OntologyEntityTypeEnum.INTERFACE_TYPE:
|
|
1502
|
+
snippet = generateInterfaceSnippet(object, packageName);
|
|
1503
|
+
break;
|
|
1504
|
+
default:
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
fs2__namespace.writeFileSync(path3__namespace.join(outputDir, object.apiName), JSON.stringify(snippet));
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
consola.consola.info("Finished Code Snippet Generation");
|
|
1511
|
+
}
|
|
1512
|
+
function generateInterfaceSnippet(interfaceType, packageName) {
|
|
1513
|
+
const interfaceContext = {
|
|
1514
|
+
"interfaceApiName": interfaceType.apiName,
|
|
1515
|
+
"packageName": packageName,
|
|
1516
|
+
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1517
|
+
"propertyNames": Object.keys(interfaceType.propertiesV2)
|
|
1518
|
+
};
|
|
1519
|
+
return getSnippets(interfaceSnippets, interfaceContext);
|
|
1520
|
+
}
|
|
1521
|
+
function generateObjectSnippet(objectType, packageName) {
|
|
1522
|
+
const objectContext = {
|
|
1523
|
+
"objectType": objectType.apiName,
|
|
1524
|
+
"packageName": packageName,
|
|
1525
|
+
"objectOrInterfaceApiName": objectType.apiName
|
|
1526
|
+
};
|
|
1527
|
+
return getSnippets(objectSnippets, objectContext);
|
|
1528
|
+
}
|
|
1529
|
+
function generateActionSnippet(actionType, packageName) {
|
|
1530
|
+
const actionContext = {
|
|
1531
|
+
"actionApiName": actionType.apiName,
|
|
1532
|
+
"packageName": packageName
|
|
1533
|
+
};
|
|
1534
|
+
return getSnippets(actionSnippets, actionContext);
|
|
1535
|
+
}
|
|
1536
|
+
function getSnippets(snippetType, context) {
|
|
1537
|
+
const allSnippets = {};
|
|
1538
|
+
for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
|
|
1539
|
+
const latestTemplate = Object.values(typescriptSdkDocs.TYPESCRIPT_OSDK_SNIPPETS.versions).find((v) => v.snippets[templateName])?.snippets[templateName][0].template ?? "";
|
|
1540
|
+
const renderedTemplate = Mustache__default.default.render(latestTemplate, context);
|
|
1541
|
+
allSnippets[templateName] = renderedTemplate;
|
|
1542
|
+
}
|
|
1543
|
+
return allSnippets;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// src/api/defineOntology.ts
|
|
1547
|
+
var ontologyDefinition;
|
|
1245
1548
|
var importedTypes;
|
|
1246
1549
|
var dependencies;
|
|
1247
1550
|
var namespace;
|
|
@@ -1255,7 +1558,7 @@ function updateOntology(entity) {
|
|
|
1255
1558
|
}
|
|
1256
1559
|
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1257
1560
|
}
|
|
1258
|
-
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1561
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, codeSnippetFiles, snippetPackageName, snippetFileOutputDir, randomnessKey) {
|
|
1259
1562
|
namespace = ns;
|
|
1260
1563
|
dependencies = {};
|
|
1261
1564
|
ontologyDefinition = {
|
|
@@ -1286,10 +1589,13 @@ async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey
|
|
|
1286
1589
|
if (dependencyFile) {
|
|
1287
1590
|
writeDependencyFile(dependencyFile);
|
|
1288
1591
|
}
|
|
1592
|
+
if (codeSnippetFiles) {
|
|
1593
|
+
createCodeSnippets(ontologyDefinition, snippetPackageName, snippetFileOutputDir);
|
|
1594
|
+
}
|
|
1289
1595
|
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1290
1596
|
}
|
|
1291
1597
|
function writeStaticObjects(outputDir) {
|
|
1292
|
-
const codegenDir =
|
|
1598
|
+
const codegenDir = path3__namespace.resolve(outputDir, "codegen");
|
|
1293
1599
|
const typeDirs = {
|
|
1294
1600
|
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1295
1601
|
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
@@ -1298,31 +1604,31 @@ function writeStaticObjects(outputDir) {
|
|
|
1298
1604
|
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1299
1605
|
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1300
1606
|
};
|
|
1301
|
-
if (!
|
|
1302
|
-
|
|
1607
|
+
if (!fs2__namespace.existsSync(codegenDir)) {
|
|
1608
|
+
fs2__namespace.mkdirSync(codegenDir, {
|
|
1303
1609
|
recursive: true
|
|
1304
1610
|
});
|
|
1305
1611
|
}
|
|
1306
1612
|
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1307
|
-
const currentTypeDirPath =
|
|
1308
|
-
if (
|
|
1309
|
-
|
|
1613
|
+
const currentTypeDirPath = path3__namespace.join(codegenDir, typeDirNameFromMap);
|
|
1614
|
+
if (fs2__namespace.existsSync(currentTypeDirPath)) {
|
|
1615
|
+
fs2__namespace.rmSync(currentTypeDirPath, {
|
|
1310
1616
|
recursive: true,
|
|
1311
1617
|
force: true
|
|
1312
1618
|
});
|
|
1313
1619
|
}
|
|
1314
|
-
|
|
1620
|
+
fs2__namespace.mkdirSync(currentTypeDirPath, {
|
|
1315
1621
|
recursive: true
|
|
1316
1622
|
});
|
|
1317
1623
|
});
|
|
1318
1624
|
const topLevelExportStatements = [];
|
|
1319
1625
|
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1320
1626
|
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1321
|
-
const typeDirPath =
|
|
1627
|
+
const typeDirPath = path3__namespace.join(codegenDir, typeDirName);
|
|
1322
1628
|
const entityModuleNames = [];
|
|
1323
1629
|
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1324
1630
|
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1325
|
-
const filePath =
|
|
1631
|
+
const filePath = path3__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1326
1632
|
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1327
1633
|
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1328
1634
|
const content = `
|
|
@@ -1334,7 +1640,7 @@ const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey ===
|
|
|
1334
1640
|
|
|
1335
1641
|
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1336
1642
|
`;
|
|
1337
|
-
|
|
1643
|
+
fs2__namespace.writeFileSync(filePath, content, {
|
|
1338
1644
|
flag: "w"
|
|
1339
1645
|
});
|
|
1340
1646
|
entityModuleNames.push(entityFileNameBase);
|
|
@@ -1345,8 +1651,8 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
|
|
|
1345
1651
|
});
|
|
1346
1652
|
if (topLevelExportStatements.length > 0) {
|
|
1347
1653
|
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1348
|
-
const mainIndexFilePath =
|
|
1349
|
-
|
|
1654
|
+
const mainIndexFilePath = path3__namespace.join(outputDir, "index.ts");
|
|
1655
|
+
fs2__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1350
1656
|
flag: "w"
|
|
1351
1657
|
});
|
|
1352
1658
|
}
|
|
@@ -1702,7 +2008,7 @@ function getEntityTypeName(type) {
|
|
|
1702
2008
|
}[type];
|
|
1703
2009
|
}
|
|
1704
2010
|
function writeDependencyFile(dependencyFile) {
|
|
1705
|
-
|
|
2011
|
+
fs2__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
|
|
1706
2012
|
}
|
|
1707
2013
|
function dependencyInjectionString() {
|
|
1708
2014
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
@@ -1719,20 +2025,20 @@ function addNamespaceIfNone(apiName) {
|
|
|
1719
2025
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1720
2026
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1721
2027
|
async function main(args = process.argv) {
|
|
1722
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.
|
|
2028
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.11").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1723
2029
|
input: {
|
|
1724
2030
|
alias: "i",
|
|
1725
2031
|
describe: "Input file",
|
|
1726
2032
|
type: "string",
|
|
1727
2033
|
default: ".ontology/ontology.ts",
|
|
1728
|
-
coerce:
|
|
2034
|
+
coerce: path3__namespace.resolve
|
|
1729
2035
|
},
|
|
1730
2036
|
output: {
|
|
1731
2037
|
alias: "o",
|
|
1732
2038
|
describe: "Output file",
|
|
1733
2039
|
type: "string",
|
|
1734
2040
|
default: "ontology.json",
|
|
1735
|
-
coerce:
|
|
2041
|
+
coerce: path3__namespace.resolve
|
|
1736
2042
|
},
|
|
1737
2043
|
apiNamespace: {
|
|
1738
2044
|
describe: "Api name prefix for namespaced ontology types",
|
|
@@ -1744,95 +2050,91 @@ async function main(args = process.argv) {
|
|
|
1744
2050
|
describe: "Snapshot directory",
|
|
1745
2051
|
type: "string",
|
|
1746
2052
|
default: "snapshots",
|
|
1747
|
-
coerce:
|
|
2053
|
+
coerce: path3__namespace.resolve
|
|
1748
2054
|
},
|
|
1749
2055
|
outputDir: {
|
|
1750
2056
|
alias: "d",
|
|
1751
2057
|
describe: "Directory for generated ontology entities",
|
|
1752
2058
|
type: "string",
|
|
1753
|
-
coerce:
|
|
2059
|
+
coerce: path3__namespace.resolve
|
|
1754
2060
|
},
|
|
1755
2061
|
valueTypesOutput: {
|
|
1756
2062
|
describe: "Value Type Output File",
|
|
1757
2063
|
type: "string",
|
|
1758
2064
|
default: "value-types.json",
|
|
1759
|
-
coerce:
|
|
2065
|
+
coerce: path3__namespace.resolve
|
|
1760
2066
|
},
|
|
1761
2067
|
dependencies: {
|
|
1762
2068
|
describe: "File to write dependencies to",
|
|
1763
2069
|
type: "string",
|
|
1764
|
-
coerce:
|
|
2070
|
+
coerce: path3__namespace.resolve
|
|
2071
|
+
},
|
|
2072
|
+
generateCodeSnippets: {
|
|
2073
|
+
describe: "Enable code snippet files creation",
|
|
2074
|
+
type: "boolean",
|
|
2075
|
+
default: false
|
|
2076
|
+
},
|
|
2077
|
+
codeSnippetPackageName: {
|
|
2078
|
+
describe: "The package name that will be displayed in the code snippets",
|
|
2079
|
+
default: "",
|
|
2080
|
+
type: "string"
|
|
2081
|
+
},
|
|
2082
|
+
codeSnippetDir: {
|
|
2083
|
+
describe: "Directory for generated code snippet files",
|
|
2084
|
+
type: "string",
|
|
2085
|
+
default: "./",
|
|
2086
|
+
coerce: path3__namespace.resolve
|
|
1765
2087
|
},
|
|
1766
2088
|
randomnessKey: {
|
|
1767
2089
|
describe: "Value used to assure uniqueness of entities",
|
|
1768
2090
|
type: "string",
|
|
1769
|
-
coerce:
|
|
2091
|
+
coerce: path3__namespace.resolve
|
|
1770
2092
|
}
|
|
1771
2093
|
}).parseAsync();
|
|
1772
2094
|
let apiNamespace = "";
|
|
1773
2095
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1774
2096
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
1775
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
1776
|
-
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ?
|
|
2097
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is too long.") : invariant7__default.default(false) : void 0;
|
|
2098
|
+
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant7__default.default(false) : void 0;
|
|
1777
2099
|
}
|
|
1778
2100
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2101
|
+
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2102
|
+
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2103
|
+
}
|
|
1779
2104
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1780
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2105
|
+
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant7__default.default(false) : void 0;
|
|
1781
2106
|
}
|
|
1782
|
-
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
2107
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
1783
2108
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1784
|
-
await
|
|
2109
|
+
await fs3__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1785
2110
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1786
|
-
await
|
|
2111
|
+
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1787
2112
|
}
|
|
1788
2113
|
}
|
|
1789
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
|
|
1790
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
2114
|
+
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2115
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
1791
2116
|
return q;
|
|
1792
2117
|
}
|
|
1793
2118
|
var MAX_SEARCH_DEPTH = 5;
|
|
1794
2119
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
1795
|
-
let dir =
|
|
2120
|
+
let dir = path3__namespace.dirname(fileInPackage);
|
|
1796
2121
|
let packageJsonPath = null;
|
|
1797
2122
|
for (let i = 0; i < MAX_SEARCH_DEPTH; i++) {
|
|
1798
|
-
const candidate =
|
|
1799
|
-
if (
|
|
2123
|
+
const candidate = path3__namespace.join(dir, "package.json");
|
|
2124
|
+
if (fs2__namespace.existsSync(candidate)) {
|
|
1800
2125
|
packageJsonPath = candidate;
|
|
1801
2126
|
break;
|
|
1802
2127
|
}
|
|
1803
|
-
const parentDir =
|
|
2128
|
+
const parentDir = path3__namespace.dirname(dir);
|
|
1804
2129
|
if (parentDir === dir) break;
|
|
1805
2130
|
dir = parentDir;
|
|
1806
2131
|
}
|
|
1807
2132
|
if (!packageJsonPath) {
|
|
1808
2133
|
throw new Error(`Could not find a package.json within ${MAX_SEARCH_DEPTH} parent directories of ${fileInPackage}`);
|
|
1809
2134
|
}
|
|
1810
|
-
const packageJson = JSON.parse(
|
|
2135
|
+
const packageJson = JSON.parse(fs2__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1811
2136
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1812
2137
|
}
|
|
1813
|
-
function convertMappingValue(value) {
|
|
1814
|
-
switch (value.type) {
|
|
1815
|
-
case "uuid":
|
|
1816
|
-
return {
|
|
1817
|
-
type: "uniqueIdentifier",
|
|
1818
|
-
uniqueIdentifier: {
|
|
1819
|
-
linkId: value.linkId ?? crypto.randomUUID()
|
|
1820
|
-
}
|
|
1821
|
-
};
|
|
1822
|
-
case "currentTime":
|
|
1823
|
-
return {
|
|
1824
|
-
type: "currentTime",
|
|
1825
|
-
currentTime: {}
|
|
1826
|
-
};
|
|
1827
|
-
case "currentUser":
|
|
1828
|
-
return {
|
|
1829
|
-
type: "currentUser",
|
|
1830
|
-
currentUser: {}
|
|
1831
|
-
};
|
|
1832
|
-
default:
|
|
1833
|
-
return value;
|
|
1834
|
-
}
|
|
1835
|
-
}
|
|
1836
2138
|
|
|
1837
2139
|
// src/api/action/ActionParameterType.ts
|
|
1838
2140
|
function isActionParameterTypePrimitive(type) {
|
|
@@ -1842,512 +2144,214 @@ function isActionParameterTypePrimitive(type) {
|
|
|
1842
2144
|
// src/api/defineAction.ts
|
|
1843
2145
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1844
2146
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2147
|
+
var CREATE_INTERFACE_OBJECT_PARAMETER = "objectTypeParameter";
|
|
2148
|
+
var MODIFY_INTERFACE_OBJECT_PARAMETER = "interfaceObjectToModifyParameter";
|
|
2149
|
+
function defineAction(actionDef) {
|
|
2150
|
+
const apiName = namespace + actionDef.apiName;
|
|
2151
|
+
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
2152
|
+
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2153
|
+
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
1849
2154
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1890
|
-
}
|
|
1891
|
-
}))],
|
|
1892
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1893
|
-
entities: {
|
|
1894
|
-
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2155
|
+
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant7__default.default(false) : void 0;
|
|
2156
|
+
const parameterIdsSet = new Set(parameterIds);
|
|
2157
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter ids must be unique`) : invariant7__default.default(false) : void 0;
|
|
2158
|
+
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2159
|
+
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant7__default.default(false) : void 0;
|
|
2160
|
+
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2161
|
+
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2162
|
+
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant7__default.default(false) : void 0;
|
|
2163
|
+
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant7__default.default(false) : void 0;
|
|
2164
|
+
actionDef.rules.forEach((rule) => {
|
|
2165
|
+
if (rule.type === "modifyObjectRule") {
|
|
2166
|
+
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant7__default.default(false) : void 0;
|
|
2167
|
+
}
|
|
2168
|
+
if (rule.type === "deleteObjectRule") {
|
|
2169
|
+
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant7__default.default(false) : void 0;
|
|
2170
|
+
}
|
|
2171
|
+
if (rule.type === "modifyInterfaceRule") {
|
|
2172
|
+
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2173
|
+
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant7__default.default(false) : void 0;
|
|
2174
|
+
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2175
|
+
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant7__default.default(false) : void 0;
|
|
2176
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2177
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2178
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant7__default.default(false) : void 0;
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
if (rule.type === "addInterfaceRule") {
|
|
2182
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2183
|
+
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant7__default.default(false) : void 0;
|
|
2184
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2185
|
+
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant7__default.default(false) : void 0;
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
});
|
|
2189
|
+
const fullAction = {
|
|
2190
|
+
...actionDef,
|
|
2191
|
+
apiName,
|
|
2192
|
+
entities: actionDef.entities ?? {
|
|
2193
|
+
affectedInterfaceTypes: [],
|
|
1895
2194
|
affectedObjectTypes: [],
|
|
1896
2195
|
affectedLinkTypes: [],
|
|
1897
2196
|
typeGroups: []
|
|
1898
2197
|
},
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1905
|
-
type: "parameterId",
|
|
1906
|
-
parameterId: id
|
|
1907
|
-
}]))
|
|
1908
|
-
}
|
|
1909
|
-
}],
|
|
1910
|
-
...def.validation ? {
|
|
1911
|
-
validation: convertValidationRule(def.validation)
|
|
1912
|
-
} : {}
|
|
1913
|
-
});
|
|
2198
|
+
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2199
|
+
};
|
|
2200
|
+
validateActionConfiguration(fullAction);
|
|
2201
|
+
updateOntology(fullAction);
|
|
2202
|
+
return fullAction;
|
|
1914
2203
|
}
|
|
1915
|
-
function
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
typeGroups: []
|
|
2204
|
+
function isPropertyParameter(def, name, type) {
|
|
2205
|
+
return !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2206
|
+
}
|
|
2207
|
+
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
2208
|
+
const targetParams = getTargetParameters(def, parameterSet);
|
|
2209
|
+
return [...targetParams, ...Array.from(parameterSet).map((id) => ({
|
|
2210
|
+
id,
|
|
2211
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? propertyMap[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2212
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(propertyMap[id]),
|
|
2213
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2214
|
+
...def.parameterConfiguration?.[id],
|
|
2215
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(propertyMap[id]?.type)),
|
|
2216
|
+
required: def.parameterConfiguration?.[id].required ?? propertyMap[id]?.nullability?.noNulls ?? false
|
|
2217
|
+
} : {
|
|
2218
|
+
required: propertyMap[id]?.array ?? false ? {
|
|
2219
|
+
listLength: propertyMap[id]?.nullability?.noEmptyCollections ? {
|
|
2220
|
+
min: 1
|
|
2221
|
+
} : {}
|
|
2222
|
+
} : requiredMap?.[id] ?? propertyMap[id]?.nullability?.noNulls ?? false,
|
|
2223
|
+
allowedValues: extractAllowedValuesFromPropertyType(propertyMap[id]?.type)
|
|
1936
2224
|
},
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2225
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2226
|
+
description: def.parameterConfiguration?.[id]?.description
|
|
2227
|
+
}))];
|
|
2228
|
+
}
|
|
2229
|
+
function getTargetParameters(def, parameterSet) {
|
|
2230
|
+
const targetParams = [];
|
|
2231
|
+
parameterSet.forEach((name) => {
|
|
2232
|
+
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2233
|
+
targetParams.push({
|
|
2234
|
+
id: MODIFY_OBJECT_PARAMETER,
|
|
2235
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2236
|
+
type: {
|
|
2237
|
+
type: "objectReference",
|
|
2238
|
+
objectReference: {
|
|
2239
|
+
objectTypeId: def.objectType.apiName
|
|
2240
|
+
}
|
|
1947
2241
|
},
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
2242
|
+
validation: {
|
|
2243
|
+
...def.parameterConfiguration?.[name],
|
|
2244
|
+
allowedValues: {
|
|
2245
|
+
type: "objectQuery"
|
|
2246
|
+
},
|
|
2247
|
+
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2248
|
+
},
|
|
2249
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2250
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2251
|
+
});
|
|
2252
|
+
parameterSet.delete(MODIFY_OBJECT_PARAMETER);
|
|
2253
|
+
}
|
|
2254
|
+
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2255
|
+
targetParams.push({
|
|
2256
|
+
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2257
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2258
|
+
type: {
|
|
2259
|
+
type: "objectReference",
|
|
2260
|
+
objectReference: {
|
|
2261
|
+
objectTypeId: def.objectType.apiName,
|
|
2262
|
+
maybeCreateObjectOption: !("primaryKeyOption" in def) ? {
|
|
2263
|
+
type: "autoGenerated",
|
|
2264
|
+
autoGenerated: {}
|
|
2265
|
+
} : def.primaryKeyOption === "autoGenerated" ? {
|
|
2266
|
+
type: "autoGenerated",
|
|
2267
|
+
autoGenerated: {}
|
|
2268
|
+
} : {
|
|
2269
|
+
type: "userInput",
|
|
2270
|
+
userInput: {}
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
},
|
|
2274
|
+
validation: {
|
|
2275
|
+
...def.parameterConfiguration?.[name],
|
|
2276
|
+
allowedValues: {
|
|
2277
|
+
type: "objectQuery"
|
|
2278
|
+
},
|
|
2279
|
+
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2280
|
+
},
|
|
2281
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2282
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2283
|
+
});
|
|
2284
|
+
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2285
|
+
}
|
|
2286
|
+
if (name === CREATE_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
2287
|
+
targetParams.push({
|
|
2288
|
+
id: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2289
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to create",
|
|
2290
|
+
type: {
|
|
2291
|
+
type: "objectTypeReference",
|
|
2292
|
+
objectTypeReference: {
|
|
2293
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
2294
|
+
}
|
|
2295
|
+
},
|
|
2296
|
+
validation: {
|
|
2297
|
+
...def.parameterConfiguration?.[name],
|
|
2298
|
+
required: true,
|
|
2299
|
+
allowedValues: def.objectType === void 0 ? {
|
|
2300
|
+
type: "objectTypeReference",
|
|
2301
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
2302
|
+
} : {
|
|
2303
|
+
type: "oneOf",
|
|
2304
|
+
oneOf: [{
|
|
2305
|
+
label: def.objectType.displayName,
|
|
2306
|
+
value: {
|
|
2307
|
+
type: "objectType",
|
|
2308
|
+
objectType: {
|
|
2309
|
+
objectTypeId: def.objectType.apiName
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}]
|
|
2313
|
+
}
|
|
2314
|
+
},
|
|
2315
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2316
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2317
|
+
});
|
|
2318
|
+
parameterSet.delete(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2319
|
+
}
|
|
2320
|
+
if (name === MODIFY_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
2321
|
+
targetParams.push({
|
|
2322
|
+
id: MODIFY_INTERFACE_OBJECT_PARAMETER,
|
|
2323
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to modify",
|
|
2324
|
+
type: {
|
|
2325
|
+
type: "interfaceReference",
|
|
2326
|
+
interfaceReference: {
|
|
2327
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
2328
|
+
}
|
|
2329
|
+
},
|
|
2330
|
+
validation: {
|
|
2331
|
+
...def.parameterConfiguration?.[name],
|
|
2332
|
+
required: true,
|
|
2333
|
+
allowedValues: def.objectType === void 0 ? {
|
|
2334
|
+
type: "interfaceObjectQuery"
|
|
2335
|
+
} : {
|
|
2336
|
+
type: "oneOf",
|
|
2337
|
+
oneOf: [{
|
|
2338
|
+
label: def.objectType.displayName,
|
|
2339
|
+
value: {
|
|
2340
|
+
type: "objectType",
|
|
2341
|
+
objectType: {
|
|
2342
|
+
objectTypeId: def.objectType.apiName
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
}]
|
|
2346
|
+
}
|
|
2347
|
+
},
|
|
2348
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2349
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2350
|
+
});
|
|
2351
|
+
parameterSet.delete(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
1969
2352
|
}
|
|
1970
2353
|
});
|
|
1971
|
-
|
|
1972
|
-
function defineModifyInterfaceObjectAction(def) {
|
|
1973
|
-
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1974
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1975
|
-
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1976
|
-
}
|
|
1977
|
-
return defineAction({
|
|
1978
|
-
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1979
|
-
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1980
|
-
parameters: [{
|
|
1981
|
-
id: "interfaceObjectToModifyParameter",
|
|
1982
|
-
displayName: "Object type to modify",
|
|
1983
|
-
type: {
|
|
1984
|
-
type: "interfaceReference",
|
|
1985
|
-
interfaceReference: {
|
|
1986
|
-
interfaceTypeRid: def.interfaceType.apiName
|
|
1987
|
-
}
|
|
1988
|
-
},
|
|
1989
|
-
validation: {
|
|
1990
|
-
required: true,
|
|
1991
|
-
allowedValues: def.objectType === void 0 ? {
|
|
1992
|
-
type: "interfaceObjectQuery"
|
|
1993
|
-
} : {
|
|
1994
|
-
type: "oneOf",
|
|
1995
|
-
oneOf: [{
|
|
1996
|
-
label: def.objectType.displayName,
|
|
1997
|
-
value: {
|
|
1998
|
-
type: "objectType",
|
|
1999
|
-
objectType: {
|
|
2000
|
-
objectTypeId: def.objectType.apiName
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
}]
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
}, ...allProperties.map(([id, prop]) => ({
|
|
2007
|
-
id,
|
|
2008
|
-
displayName: prop.sharedPropertyType.displayName ?? prop.sharedPropertyType.nonNameSpacedApiName,
|
|
2009
|
-
type: extractActionParameterType(prop.sharedPropertyType),
|
|
2010
|
-
typeClasses: prop.sharedPropertyType.typeClasses ?? [],
|
|
2011
|
-
validation: {
|
|
2012
|
-
required: prop.sharedPropertyType.array ?? false ? {
|
|
2013
|
-
listLength: {}
|
|
2014
|
-
} : prop.required,
|
|
2015
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
2016
|
-
}
|
|
2017
|
-
}))],
|
|
2018
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
2019
|
-
entities: {
|
|
2020
|
-
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2021
|
-
affectedObjectTypes: [],
|
|
2022
|
-
affectedLinkTypes: [],
|
|
2023
|
-
typeGroups: []
|
|
2024
|
-
},
|
|
2025
|
-
rules: [{
|
|
2026
|
-
type: "modifyInterfaceRule",
|
|
2027
|
-
modifyInterfaceRule: {
|
|
2028
|
-
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
2029
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
2030
|
-
type: "parameterId",
|
|
2031
|
-
parameterId: id
|
|
2032
|
-
}]))
|
|
2033
|
-
}
|
|
2034
|
-
}],
|
|
2035
|
-
...def.validation ? {
|
|
2036
|
-
validation: convertValidationRule(def.validation)
|
|
2037
|
-
} : {}
|
|
2038
|
-
});
|
|
2039
|
-
}
|
|
2040
|
-
function defineModifyObjectAction(def) {
|
|
2041
|
-
validateActionParameters(def);
|
|
2042
|
-
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2043
|
-
const parameterNames = new Set(propertyParameters);
|
|
2044
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2045
|
-
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
2046
|
-
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2047
|
-
if (def.parameterOrdering) {
|
|
2048
|
-
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
2049
|
-
def.parameterOrdering = [MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2050
|
-
}
|
|
2051
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2052
|
-
}
|
|
2053
|
-
const parameters = createParameters(def, parameterNames);
|
|
2054
|
-
parameters.forEach((p) => {
|
|
2055
|
-
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2056
|
-
p.defaultValue = {
|
|
2057
|
-
type: "objectParameterPropertyValue",
|
|
2058
|
-
objectParameterPropertyValue: {
|
|
2059
|
-
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
2060
|
-
propertyTypeId: p.id
|
|
2061
|
-
}
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
});
|
|
2065
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2066
|
-
return defineAction({
|
|
2067
|
-
apiName: actionApiName,
|
|
2068
|
-
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
2069
|
-
parameters,
|
|
2070
|
-
status: def.status ?? "active",
|
|
2071
|
-
rules: [{
|
|
2072
|
-
type: "modifyObjectRule",
|
|
2073
|
-
modifyObjectRule: {
|
|
2074
|
-
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2075
|
-
propertyValues: {
|
|
2076
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2077
|
-
type: "parameterId",
|
|
2078
|
-
parameterId: p
|
|
2079
|
-
}])),
|
|
2080
|
-
...mappings
|
|
2081
|
-
},
|
|
2082
|
-
structFieldValues: {}
|
|
2083
|
-
}
|
|
2084
|
-
}],
|
|
2085
|
-
entities: {
|
|
2086
|
-
affectedInterfaceTypes: [],
|
|
2087
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2088
|
-
affectedLinkTypes: [],
|
|
2089
|
-
typeGroups: []
|
|
2090
|
-
},
|
|
2091
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2092
|
-
...def.actionLevelValidation ? {
|
|
2093
|
-
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2094
|
-
} : {},
|
|
2095
|
-
...def.defaultFormat && {
|
|
2096
|
-
defaultFormat: def.defaultFormat
|
|
2097
|
-
},
|
|
2098
|
-
...def.enableLayoutSwitch && {
|
|
2099
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2100
|
-
},
|
|
2101
|
-
...def.displayAndFormat && {
|
|
2102
|
-
displayAndFormat: def.displayAndFormat
|
|
2103
|
-
},
|
|
2104
|
-
...def.sections && {
|
|
2105
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2106
|
-
},
|
|
2107
|
-
...def.submissionMetadata && {
|
|
2108
|
-
submissionMetadata: def.submissionMetadata
|
|
2109
|
-
}
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
function defineDeleteObjectAction(def) {
|
|
2113
|
-
return defineAction({
|
|
2114
|
-
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2115
|
-
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
2116
|
-
parameters: [{
|
|
2117
|
-
id: "objectToDeleteParameter",
|
|
2118
|
-
displayName: "Delete object",
|
|
2119
|
-
type: {
|
|
2120
|
-
type: "objectReference",
|
|
2121
|
-
objectReference: {
|
|
2122
|
-
objectTypeId: def.objectType.apiName
|
|
2123
|
-
}
|
|
2124
|
-
},
|
|
2125
|
-
validation: {
|
|
2126
|
-
required: true,
|
|
2127
|
-
allowedValues: {
|
|
2128
|
-
type: "objectQuery"
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
}],
|
|
2132
|
-
status: def.status ?? "active",
|
|
2133
|
-
rules: [{
|
|
2134
|
-
type: "deleteObjectRule",
|
|
2135
|
-
deleteObjectRule: {
|
|
2136
|
-
objectToDelete: "objectToDeleteParameter"
|
|
2137
|
-
}
|
|
2138
|
-
}],
|
|
2139
|
-
entities: {
|
|
2140
|
-
affectedInterfaceTypes: [],
|
|
2141
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2142
|
-
affectedLinkTypes: [],
|
|
2143
|
-
typeGroups: []
|
|
2144
|
-
},
|
|
2145
|
-
...def.actionLevelValidation ? {
|
|
2146
|
-
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2147
|
-
} : {}
|
|
2148
|
-
});
|
|
2149
|
-
}
|
|
2150
|
-
function defineCreateOrModifyObjectAction(def) {
|
|
2151
|
-
validateActionParameters(def);
|
|
2152
|
-
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
2153
|
-
const parameterNames = new Set(propertyParameters);
|
|
2154
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2155
|
-
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2156
|
-
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2157
|
-
if (def.parameterOrdering) {
|
|
2158
|
-
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2159
|
-
def.parameterOrdering = [CREATE_OR_MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2160
|
-
}
|
|
2161
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2162
|
-
}
|
|
2163
|
-
const parameters = createParameters(def, parameterNames);
|
|
2164
|
-
parameters.forEach((p) => {
|
|
2165
|
-
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2166
|
-
p.defaultValue = {
|
|
2167
|
-
type: "objectParameterPropertyValue",
|
|
2168
|
-
objectParameterPropertyValue: {
|
|
2169
|
-
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2170
|
-
propertyTypeId: p.id
|
|
2171
|
-
}
|
|
2172
|
-
};
|
|
2173
|
-
}
|
|
2174
|
-
});
|
|
2175
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2176
|
-
return defineAction({
|
|
2177
|
-
apiName: actionApiName,
|
|
2178
|
-
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2179
|
-
parameters,
|
|
2180
|
-
status: def.status ?? "active",
|
|
2181
|
-
rules: [{
|
|
2182
|
-
type: "addOrModifyObjectRuleV2",
|
|
2183
|
-
addOrModifyObjectRuleV2: {
|
|
2184
|
-
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2185
|
-
propertyValues: {
|
|
2186
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2187
|
-
type: "parameterId",
|
|
2188
|
-
parameterId: p
|
|
2189
|
-
}])),
|
|
2190
|
-
...mappings
|
|
2191
|
-
},
|
|
2192
|
-
structFieldValues: {}
|
|
2193
|
-
}
|
|
2194
|
-
}],
|
|
2195
|
-
entities: {
|
|
2196
|
-
affectedInterfaceTypes: [],
|
|
2197
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2198
|
-
affectedLinkTypes: [],
|
|
2199
|
-
typeGroups: []
|
|
2200
|
-
},
|
|
2201
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2202
|
-
...def.actionLevelValidation ? {
|
|
2203
|
-
validation: convertValidationRule(def.actionLevelValidation, Object.keys(def.objectType.properties ?? {}))
|
|
2204
|
-
} : {},
|
|
2205
|
-
...def.defaultFormat && {
|
|
2206
|
-
defaultFormat: def.defaultFormat
|
|
2207
|
-
},
|
|
2208
|
-
...def.enableLayoutSwitch && {
|
|
2209
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2210
|
-
},
|
|
2211
|
-
...def.displayAndFormat && {
|
|
2212
|
-
displayAndFormat: def.displayAndFormat
|
|
2213
|
-
},
|
|
2214
|
-
...def.sections && {
|
|
2215
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2216
|
-
},
|
|
2217
|
-
...def.submissionMetadata && {
|
|
2218
|
-
submissionMetadata: def.submissionMetadata
|
|
2219
|
-
}
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
function defineAction(actionDef) {
|
|
2223
|
-
const apiName = namespace + actionDef.apiName;
|
|
2224
|
-
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
2225
|
-
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2226
|
-
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2227
|
-
}
|
|
2228
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant6__default.default(false) : void 0;
|
|
2229
|
-
const parameterIdsSet = new Set(parameterIds);
|
|
2230
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ids must be unique`) : invariant6__default.default(false) : void 0;
|
|
2231
|
-
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2232
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant6__default.default(false) : void 0;
|
|
2233
|
-
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2234
|
-
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2235
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant6__default.default(false) : void 0;
|
|
2236
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant6__default.default(false) : void 0;
|
|
2237
|
-
actionDef.rules.forEach((rule) => {
|
|
2238
|
-
if (rule.type === "modifyObjectRule") {
|
|
2239
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2240
|
-
}
|
|
2241
|
-
if (rule.type === "deleteObjectRule") {
|
|
2242
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant6__default.default(false) : void 0;
|
|
2243
|
-
}
|
|
2244
|
-
if (rule.type === "modifyInterfaceRule") {
|
|
2245
|
-
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2246
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant6__default.default(false) : void 0;
|
|
2247
|
-
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2248
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2249
|
-
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2250
|
-
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2251
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant6__default.default(false) : void 0;
|
|
2252
|
-
});
|
|
2253
|
-
}
|
|
2254
|
-
if (rule.type === "addInterfaceRule") {
|
|
2255
|
-
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2256
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant6__default.default(false) : void 0;
|
|
2257
|
-
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2258
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2259
|
-
});
|
|
2260
|
-
}
|
|
2261
|
-
});
|
|
2262
|
-
const fullAction = {
|
|
2263
|
-
...actionDef,
|
|
2264
|
-
apiName,
|
|
2265
|
-
entities: actionDef.entities ?? {
|
|
2266
|
-
affectedInterfaceTypes: [],
|
|
2267
|
-
affectedObjectTypes: [],
|
|
2268
|
-
affectedLinkTypes: [],
|
|
2269
|
-
typeGroups: []
|
|
2270
|
-
},
|
|
2271
|
-
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2272
|
-
};
|
|
2273
|
-
validateActionConfiguration(fullAction);
|
|
2274
|
-
updateOntology(fullAction);
|
|
2275
|
-
return fullAction;
|
|
2276
|
-
}
|
|
2277
|
-
function createParameters(def, parameterSet) {
|
|
2278
|
-
const targetParam = [];
|
|
2279
|
-
parameterSet.forEach((name) => {
|
|
2280
|
-
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2281
|
-
targetParam.push({
|
|
2282
|
-
id: MODIFY_OBJECT_PARAMETER,
|
|
2283
|
-
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2284
|
-
type: {
|
|
2285
|
-
type: "objectReference",
|
|
2286
|
-
objectReference: {
|
|
2287
|
-
objectTypeId: def.objectType.apiName
|
|
2288
|
-
}
|
|
2289
|
-
},
|
|
2290
|
-
validation: {
|
|
2291
|
-
...def.parameterConfiguration?.[name],
|
|
2292
|
-
allowedValues: {
|
|
2293
|
-
type: "objectQuery"
|
|
2294
|
-
},
|
|
2295
|
-
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2296
|
-
},
|
|
2297
|
-
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2298
|
-
description: def.parameterConfiguration?.[name]?.description
|
|
2299
|
-
});
|
|
2300
|
-
parameterSet.delete(MODIFY_OBJECT_PARAMETER);
|
|
2301
|
-
}
|
|
2302
|
-
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2303
|
-
targetParam.push({
|
|
2304
|
-
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2305
|
-
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2306
|
-
type: {
|
|
2307
|
-
type: "objectReference",
|
|
2308
|
-
objectReference: {
|
|
2309
|
-
objectTypeId: def.objectType.apiName,
|
|
2310
|
-
maybeCreateObjectOption: !def.primaryKeyOption || def.primaryKeyOption === "autoGenerated" ? {
|
|
2311
|
-
type: "autoGenerated",
|
|
2312
|
-
autoGenerated: {}
|
|
2313
|
-
} : {
|
|
2314
|
-
type: "userInput",
|
|
2315
|
-
userInput: {}
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
},
|
|
2319
|
-
validation: {
|
|
2320
|
-
...def.parameterConfiguration?.[name],
|
|
2321
|
-
allowedValues: {
|
|
2322
|
-
type: "objectQuery"
|
|
2323
|
-
},
|
|
2324
|
-
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2325
|
-
},
|
|
2326
|
-
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2327
|
-
description: def.parameterConfiguration?.[name]?.description
|
|
2328
|
-
});
|
|
2329
|
-
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2330
|
-
}
|
|
2331
|
-
});
|
|
2332
|
-
return [...targetParam, ...Array.from(parameterSet).map((id) => ({
|
|
2333
|
-
id,
|
|
2334
|
-
displayName: def.parameterConfiguration?.[id]?.displayName ?? def.objectType.properties?.[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2335
|
-
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(def.objectType.properties?.[id]),
|
|
2336
|
-
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2337
|
-
...def.parameterConfiguration?.[id],
|
|
2338
|
-
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)),
|
|
2339
|
-
required: def.parameterConfiguration?.[id].required ?? def.objectType.properties?.[id]?.nullability?.noNulls ?? false
|
|
2340
|
-
} : {
|
|
2341
|
-
required: def.objectType.properties?.[id].array ?? false ? {
|
|
2342
|
-
listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
|
|
2343
|
-
min: 1
|
|
2344
|
-
} : {}
|
|
2345
|
-
} : def.objectType.properties?.[id].nullability?.noNulls ?? false,
|
|
2346
|
-
allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
|
|
2347
|
-
},
|
|
2348
|
-
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2349
|
-
description: def.parameterConfiguration?.[id]?.description
|
|
2350
|
-
}))];
|
|
2354
|
+
return targetParams;
|
|
2351
2355
|
}
|
|
2352
2356
|
function referencedParameterIds(actionDef) {
|
|
2353
2357
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2612,104 +2616,425 @@ function kebab(s) {
|
|
|
2612
2616
|
function sanitize(s) {
|
|
2613
2617
|
return s.includes(".") ? s : namespace + s;
|
|
2614
2618
|
}
|
|
2615
|
-
function convertValidationRule(actionValidation,
|
|
2619
|
+
function convertValidationRule(actionValidation, actionParameters) {
|
|
2616
2620
|
return actionValidation.map((rule) => {
|
|
2617
2621
|
return {
|
|
2618
|
-
condition: convertConditionDefinition(rule.condition,
|
|
2622
|
+
condition: convertConditionDefinition(rule.condition, actionParameters),
|
|
2619
2623
|
displayMetadata: rule.displayMetadata ?? {
|
|
2620
2624
|
failureMessage: "Did not satisfy validation",
|
|
2621
2625
|
typeClasses: []
|
|
2622
2626
|
}
|
|
2623
|
-
};
|
|
2627
|
+
};
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
function validateActionConfiguration(action) {
|
|
2631
|
+
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
2632
|
+
const parameterMap = action.parameters?.reduce((acc, param) => {
|
|
2633
|
+
acc[param.id] = param;
|
|
2634
|
+
return acc;
|
|
2635
|
+
}, {}) ?? {};
|
|
2636
|
+
const orderedParameters = action.parameterOrdering?.map((id) => parameterMap[id]) ?? action.parameters;
|
|
2637
|
+
orderedParameters?.forEach((param) => {
|
|
2638
|
+
param.validation.conditionalOverrides?.forEach((override) => {
|
|
2639
|
+
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
2640
|
+
});
|
|
2641
|
+
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
2642
|
+
seenParameterIds.add(param.id);
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
function validateParameterCondition(condition, currentParameterId, seenParameterIds, parameters) {
|
|
2646
|
+
switch (condition.type) {
|
|
2647
|
+
case "parameter":
|
|
2648
|
+
const overrideParamId = condition.parameterId;
|
|
2649
|
+
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter condition on ${currentParameterId} is referencing unknown parameter ${overrideParamId}`) : invariant7__default.default(false) : void 0;
|
|
2650
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant7__default.default(false) : void 0;
|
|
2651
|
+
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter condition on ${currentParameterId} is referencing later parameter ${overrideParamId}`) : invariant7__default.default(false) : void 0;
|
|
2652
|
+
break;
|
|
2653
|
+
case "and":
|
|
2654
|
+
if ("conditions" in condition) {
|
|
2655
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2656
|
+
}
|
|
2657
|
+
break;
|
|
2658
|
+
case "or":
|
|
2659
|
+
if ("conditions" in condition) {
|
|
2660
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
2661
|
+
}
|
|
2662
|
+
break;
|
|
2663
|
+
case "comparison":
|
|
2664
|
+
case "group":
|
|
2665
|
+
case "not":
|
|
2666
|
+
case "markings":
|
|
2667
|
+
case "regex":
|
|
2668
|
+
case "redacted":
|
|
2669
|
+
case "true":
|
|
2670
|
+
break;
|
|
2671
|
+
default:
|
|
2672
|
+
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2676
|
+
if (!defaultValue) return;
|
|
2677
|
+
switch (defaultValue.type) {
|
|
2678
|
+
case "objectParameterPropertyValue":
|
|
2679
|
+
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant7__default.default(false) : void 0;
|
|
2680
|
+
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant7__default.default(false) : void 0;
|
|
2681
|
+
break;
|
|
2682
|
+
case "staticValue":
|
|
2683
|
+
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant7__default.default(false) : void 0;
|
|
2684
|
+
break;
|
|
2685
|
+
case "staticObject":
|
|
2686
|
+
case "interfaceParameterPropertyValue":
|
|
2687
|
+
case "objectQueryPrefill":
|
|
2688
|
+
case "objectQueryPropertyValue":
|
|
2689
|
+
case "objectSetRidPrefill":
|
|
2690
|
+
case "redacted":
|
|
2691
|
+
break;
|
|
2692
|
+
default:
|
|
2693
|
+
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
function validateActionParameters(def, properties, name) {
|
|
2697
|
+
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2698
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter ${id} does not exist as a property on ${name} and its type is not explicitly defined`) : invariant7__default.default(false) : void 0;
|
|
2699
|
+
});
|
|
2700
|
+
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2701
|
+
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id))) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Property ${id} does not exist as a property on ${name}`) : invariant7__default.default(false) : void 0;
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
2705
|
+
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}).filter((id) => id !== priorityId), ...properties.filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2706
|
+
}
|
|
2707
|
+
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2708
|
+
const orderingSet = new Set(parameterOrdering);
|
|
2709
|
+
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2710
|
+
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2711
|
+
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant7__default.default(false) : void 0;
|
|
2712
|
+
}
|
|
2713
|
+
function isTargetParameter(parameterId) {
|
|
2714
|
+
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
2715
|
+
}
|
|
2716
|
+
function addNamespaceToActionDefinition(def) {
|
|
2717
|
+
def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [getInterfaceParameterName(def, id), config]));
|
|
2718
|
+
def.nonParameterMappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [addNamespaceIfNone(id), value]));
|
|
2719
|
+
def.excludedProperties = (def.excludedProperties ?? []).map((id) => addNamespaceIfNone(id));
|
|
2720
|
+
def.sections = def.sections?.map((section) => ({
|
|
2721
|
+
...section,
|
|
2722
|
+
parameters: section.parameters.map((p) => getInterfaceParameterName(def, p))
|
|
2723
|
+
}));
|
|
2724
|
+
}
|
|
2725
|
+
function getInterfaceParameterName(def, parameter) {
|
|
2726
|
+
return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
|
|
2727
|
+
}
|
|
2728
|
+
function convertMappingValue(value) {
|
|
2729
|
+
switch (value.type) {
|
|
2730
|
+
case "uuid":
|
|
2731
|
+
return {
|
|
2732
|
+
type: "uniqueIdentifier",
|
|
2733
|
+
uniqueIdentifier: {
|
|
2734
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
case "currentTime":
|
|
2738
|
+
return {
|
|
2739
|
+
type: "currentTime",
|
|
2740
|
+
currentTime: {}
|
|
2741
|
+
};
|
|
2742
|
+
case "currentUser":
|
|
2743
|
+
return {
|
|
2744
|
+
type: "currentUser",
|
|
2745
|
+
currentUser: {}
|
|
2746
|
+
};
|
|
2747
|
+
default:
|
|
2748
|
+
return value;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
// src/api/defineCreateInterfaceObjectAction.ts
|
|
2753
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
2754
|
+
addNamespaceToActionDefinition(def);
|
|
2755
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2756
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2757
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
2758
|
+
const parameterNames = new Set(propertyParameters);
|
|
2759
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
2760
|
+
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2761
|
+
const actionApiName = def.apiName ?? `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
2762
|
+
if (def.parameterOrdering) {
|
|
2763
|
+
if (!def.parameterOrdering.includes(CREATE_INTERFACE_OBJECT_PARAMETER)) {
|
|
2764
|
+
def.parameterOrdering.unshift(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2765
|
+
}
|
|
2766
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2767
|
+
}
|
|
2768
|
+
const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2769
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2770
|
+
return defineAction({
|
|
2771
|
+
apiName: actionApiName,
|
|
2772
|
+
displayName: def.displayName ?? `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
2773
|
+
parameters,
|
|
2774
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
2775
|
+
entities: {
|
|
2776
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2777
|
+
affectedObjectTypes: [],
|
|
2778
|
+
affectedLinkTypes: [],
|
|
2779
|
+
typeGroups: []
|
|
2780
|
+
},
|
|
2781
|
+
rules: [{
|
|
2782
|
+
type: "addInterfaceRule",
|
|
2783
|
+
addInterfaceRule: {
|
|
2784
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
2785
|
+
objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2786
|
+
sharedPropertyValues: {
|
|
2787
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
2788
|
+
type: "parameterId",
|
|
2789
|
+
parameterId: id
|
|
2790
|
+
}])),
|
|
2791
|
+
...mappings
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}],
|
|
2795
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
|
|
2796
|
+
...def.actionLevelValidation ? {
|
|
2797
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2798
|
+
} : {},
|
|
2799
|
+
...def.defaultFormat && {
|
|
2800
|
+
defaultFormat: def.defaultFormat
|
|
2801
|
+
},
|
|
2802
|
+
...def.enableLayoutSwitch && {
|
|
2803
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2804
|
+
},
|
|
2805
|
+
...def.tableConfiguration && {
|
|
2806
|
+
displayAndFormat: {
|
|
2807
|
+
table: def.tableConfiguration
|
|
2808
|
+
}
|
|
2809
|
+
},
|
|
2810
|
+
...def.sections && {
|
|
2811
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2812
|
+
},
|
|
2813
|
+
...def.submissionMetadata && {
|
|
2814
|
+
submissionMetadata: def.submissionMetadata
|
|
2815
|
+
}
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
// src/api/defineCreateObjectAction.ts
|
|
2820
|
+
function defineCreateObjectAction(def) {
|
|
2821
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2822
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
2823
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && !isStruct(def.objectType.properties?.[id].type) && !propertiesWithDerivedDatasources.includes(id));
|
|
2824
|
+
const parameterNames = new Set(propertyParameters);
|
|
2825
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2826
|
+
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2827
|
+
if (def.parameterOrdering) {
|
|
2828
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2829
|
+
}
|
|
2830
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
2831
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2832
|
+
return defineAction({
|
|
2833
|
+
apiName: actionApiName,
|
|
2834
|
+
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
2835
|
+
parameters,
|
|
2836
|
+
status: def.status ?? "active",
|
|
2837
|
+
entities: {
|
|
2838
|
+
affectedInterfaceTypes: [],
|
|
2839
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2840
|
+
affectedLinkTypes: [],
|
|
2841
|
+
typeGroups: []
|
|
2842
|
+
},
|
|
2843
|
+
rules: [{
|
|
2844
|
+
type: "addObjectRule",
|
|
2845
|
+
addObjectRule: {
|
|
2846
|
+
objectTypeId: def.objectType.apiName,
|
|
2847
|
+
propertyValues: {
|
|
2848
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2849
|
+
type: "parameterId",
|
|
2850
|
+
parameterId: p
|
|
2851
|
+
}])),
|
|
2852
|
+
...mappings
|
|
2853
|
+
},
|
|
2854
|
+
structFieldValues: {}
|
|
2855
|
+
}
|
|
2856
|
+
}],
|
|
2857
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters),
|
|
2858
|
+
...def.actionLevelValidation ? {
|
|
2859
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2860
|
+
} : {},
|
|
2861
|
+
...def.defaultFormat && {
|
|
2862
|
+
defaultFormat: def.defaultFormat
|
|
2863
|
+
},
|
|
2864
|
+
...def.enableLayoutSwitch && {
|
|
2865
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2866
|
+
},
|
|
2867
|
+
...def.tableConfiguration && {
|
|
2868
|
+
displayAndFormat: {
|
|
2869
|
+
table: def.tableConfiguration
|
|
2870
|
+
}
|
|
2871
|
+
},
|
|
2872
|
+
...def.sections && {
|
|
2873
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2874
|
+
},
|
|
2875
|
+
...def.submissionMetadata && {
|
|
2876
|
+
submissionMetadata: def.submissionMetadata
|
|
2877
|
+
}
|
|
2878
|
+
});
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
// src/api/defineCreateOrModifyObjectAction.ts
|
|
2882
|
+
function defineCreateOrModifyObjectAction(def) {
|
|
2883
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2884
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
2885
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => !Object.keys(def.nonParameterMappings ?? {}).includes(id) && !def.excludedProperties?.includes(id) && !isStruct(def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName && !propertiesWithDerivedDatasources.includes(id));
|
|
2886
|
+
const parameterNames = new Set(propertyParameters);
|
|
2887
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2888
|
+
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2889
|
+
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2890
|
+
if (def.parameterOrdering) {
|
|
2891
|
+
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2892
|
+
def.parameterOrdering.unshift(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2893
|
+
}
|
|
2894
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2895
|
+
}
|
|
2896
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
2897
|
+
parameters.forEach((p) => {
|
|
2898
|
+
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2899
|
+
p.defaultValue = {
|
|
2900
|
+
type: "objectParameterPropertyValue",
|
|
2901
|
+
objectParameterPropertyValue: {
|
|
2902
|
+
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2903
|
+
propertyTypeId: p.id
|
|
2904
|
+
}
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2909
|
+
return defineAction({
|
|
2910
|
+
apiName: actionApiName,
|
|
2911
|
+
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2912
|
+
parameters,
|
|
2913
|
+
status: def.status ?? "active",
|
|
2914
|
+
rules: [{
|
|
2915
|
+
type: "addOrModifyObjectRuleV2",
|
|
2916
|
+
addOrModifyObjectRuleV2: {
|
|
2917
|
+
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2918
|
+
propertyValues: {
|
|
2919
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2920
|
+
type: "parameterId",
|
|
2921
|
+
parameterId: p
|
|
2922
|
+
}])),
|
|
2923
|
+
...mappings
|
|
2924
|
+
},
|
|
2925
|
+
structFieldValues: {}
|
|
2926
|
+
}
|
|
2927
|
+
}],
|
|
2928
|
+
entities: {
|
|
2929
|
+
affectedInterfaceTypes: [],
|
|
2930
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
2931
|
+
affectedLinkTypes: [],
|
|
2932
|
+
typeGroups: []
|
|
2933
|
+
},
|
|
2934
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2935
|
+
...def.actionLevelValidation ? {
|
|
2936
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2937
|
+
} : {},
|
|
2938
|
+
...def.defaultFormat && {
|
|
2939
|
+
defaultFormat: def.defaultFormat
|
|
2940
|
+
},
|
|
2941
|
+
...def.enableLayoutSwitch && {
|
|
2942
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2943
|
+
},
|
|
2944
|
+
...def.tableConfiguration && {
|
|
2945
|
+
displayAndFormat: {
|
|
2946
|
+
table: def.tableConfiguration
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
...def.sections && {
|
|
2950
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2951
|
+
},
|
|
2952
|
+
...def.submissionMetadata && {
|
|
2953
|
+
submissionMetadata: def.submissionMetadata
|
|
2954
|
+
}
|
|
2624
2955
|
});
|
|
2625
2956
|
}
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2957
|
+
|
|
2958
|
+
// src/api/defineDeleteInterfaceObjectAction.ts
|
|
2959
|
+
function defineDeleteInterfaceObjectAction(def) {
|
|
2960
|
+
return defineAction({
|
|
2961
|
+
apiName: def.apiName ?? `delete-interface-object-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}`,
|
|
2962
|
+
displayName: def.displayName ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,
|
|
2963
|
+
parameters: [{
|
|
2964
|
+
id: "objectToDeleteParameter",
|
|
2965
|
+
displayName: "Delete object",
|
|
2966
|
+
type: {
|
|
2967
|
+
type: "interfaceReference",
|
|
2968
|
+
interfaceReference: {
|
|
2969
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
2970
|
+
}
|
|
2971
|
+
},
|
|
2972
|
+
validation: {
|
|
2973
|
+
required: true,
|
|
2974
|
+
allowedValues: {
|
|
2975
|
+
type: "interfaceObjectQuery"
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
}],
|
|
2979
|
+
status: def.status ?? "active",
|
|
2980
|
+
rules: [{
|
|
2981
|
+
type: "deleteObjectRule",
|
|
2982
|
+
deleteObjectRule: {
|
|
2983
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2984
|
+
}
|
|
2985
|
+
}],
|
|
2986
|
+
entities: {
|
|
2987
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2988
|
+
affectedObjectTypes: [],
|
|
2989
|
+
affectedLinkTypes: [],
|
|
2990
|
+
typeGroups: []
|
|
2991
|
+
}
|
|
2639
2992
|
});
|
|
2640
2993
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2994
|
+
|
|
2995
|
+
// src/api/defineDeleteObjectAction.ts
|
|
2996
|
+
function defineDeleteObjectAction(def) {
|
|
2997
|
+
return defineAction({
|
|
2998
|
+
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2999
|
+
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
3000
|
+
parameters: [{
|
|
3001
|
+
id: "objectToDeleteParameter",
|
|
3002
|
+
displayName: "Delete object",
|
|
3003
|
+
type: {
|
|
3004
|
+
type: "objectReference",
|
|
3005
|
+
objectReference: {
|
|
3006
|
+
objectTypeId: def.objectType.apiName
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
validation: {
|
|
3010
|
+
required: true,
|
|
3011
|
+
allowedValues: {
|
|
3012
|
+
type: "objectQuery"
|
|
3013
|
+
}
|
|
2652
3014
|
}
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3015
|
+
}],
|
|
3016
|
+
status: def.status ?? "active",
|
|
3017
|
+
rules: [{
|
|
3018
|
+
type: "deleteObjectRule",
|
|
3019
|
+
deleteObjectRule: {
|
|
3020
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2657
3021
|
}
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2672
|
-
if (!defaultValue) return;
|
|
2673
|
-
switch (defaultValue.type) {
|
|
2674
|
-
case "objectParameterPropertyValue":
|
|
2675
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2676
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant6__default.default(false) : void 0;
|
|
2677
|
-
break;
|
|
2678
|
-
case "staticValue":
|
|
2679
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant6__default.default(false) : void 0;
|
|
2680
|
-
break;
|
|
2681
|
-
case "staticObject":
|
|
2682
|
-
case "interfaceParameterPropertyValue":
|
|
2683
|
-
case "objectQueryPrefill":
|
|
2684
|
-
case "objectQueryPropertyValue":
|
|
2685
|
-
case "objectSetRidPrefill":
|
|
2686
|
-
case "redacted":
|
|
2687
|
-
break;
|
|
2688
|
-
default:
|
|
2689
|
-
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2690
|
-
}
|
|
2691
|
-
}
|
|
2692
|
-
function validateActionParameters(def) {
|
|
2693
|
-
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2694
|
-
!(def.objectType.properties?.[id] !== void 0 || def.parameterConfiguration?.[id].customParameterType !== void 0 || id === MODIFY_OBJECT_PARAMETER || id === CREATE_OR_MODIFY_OBJECT_PARAMETER) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant6__default.default(false) : void 0;
|
|
2695
|
-
});
|
|
2696
|
-
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2697
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant6__default.default(false) : void 0;
|
|
3022
|
+
}],
|
|
3023
|
+
entities: {
|
|
3024
|
+
affectedInterfaceTypes: [],
|
|
3025
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3026
|
+
affectedLinkTypes: [],
|
|
3027
|
+
typeGroups: []
|
|
3028
|
+
},
|
|
3029
|
+
...def.actionLevelValidation ? {
|
|
3030
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
3031
|
+
} : {}
|
|
2698
3032
|
});
|
|
2699
3033
|
}
|
|
2700
|
-
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
2701
|
-
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}), ...Object.keys(def.objectType.properties ?? {}).filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2702
|
-
}
|
|
2703
|
-
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2704
|
-
const orderingSet = new Set(parameterOrdering);
|
|
2705
|
-
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2706
|
-
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2707
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant6__default.default(false) : void 0;
|
|
2708
|
-
}
|
|
2709
3034
|
function defineSharedPropertyType(sptDef) {
|
|
2710
3035
|
const apiName = namespace + sptDef.apiName;
|
|
2711
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2712
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
3036
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} already exists`) : invariant7__default.default(false) : void 0;
|
|
3037
|
+
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Shared property type ${apiName} of type '${getPropertyTypeName(sptDef.type)}' should not have render hints`) : invariant7__default.default(false) : void 0;
|
|
2713
3038
|
const fullSpt = {
|
|
2714
3039
|
...sptDef,
|
|
2715
3040
|
apiName,
|
|
@@ -2758,7 +3083,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
2758
3083
|
// src/api/defineInterface.ts
|
|
2759
3084
|
function defineInterface(interfaceDef) {
|
|
2760
3085
|
const apiName = namespace + interfaceDef.apiName;
|
|
2761
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3086
|
+
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Interface ${apiName} already exists`) : invariant7__default.default(false) : void 0;
|
|
2762
3087
|
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2763
3088
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2764
3089
|
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
@@ -2777,7 +3102,7 @@ function defineInterface(interfaceDef) {
|
|
|
2777
3102
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2778
3103
|
type: "active"
|
|
2779
3104
|
});
|
|
2780
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3105
|
+
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Deprecated status must include message and deadline properties.`) : invariant7__default.default(false) : void 0;
|
|
2781
3106
|
const fullInterface = {
|
|
2782
3107
|
apiName,
|
|
2783
3108
|
displayMetadata: {
|
|
@@ -2803,7 +3128,7 @@ function defineInterface(interfaceDef) {
|
|
|
2803
3128
|
}
|
|
2804
3129
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2805
3130
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2806
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
3131
|
+
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Invalid data type ${JSON.stringify(type)} for property ${apiName} on InterfaceType ${apiName}`) : invariant7__default.default(false) : void 0;
|
|
2807
3132
|
const spt = defineSharedPropertyType({
|
|
2808
3133
|
apiName,
|
|
2809
3134
|
displayName: apiName,
|
|
@@ -2813,16 +3138,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2813
3138
|
return spt;
|
|
2814
3139
|
} else {
|
|
2815
3140
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2816
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3141
|
+
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `property key and it's apiName must be identical. ${JSON.stringify({
|
|
2817
3142
|
key: apiName,
|
|
2818
3143
|
apiName: type.apiName
|
|
2819
|
-
})}`) :
|
|
3144
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
2820
3145
|
return type;
|
|
2821
3146
|
}
|
|
2822
3147
|
}
|
|
2823
3148
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2824
3149
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2825
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3150
|
+
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Link with apiName ${fromLinkMeta.apiName} already exists on ${linkDef.apiName}`) : invariant7__default.default(false) : void 0;
|
|
2826
3151
|
linkDef.from.links.push({
|
|
2827
3152
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2828
3153
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2850,19 +3175,9 @@ function getLinkMeta(meta) {
|
|
|
2850
3175
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
2851
3176
|
};
|
|
2852
3177
|
}
|
|
2853
|
-
|
|
3178
|
+
|
|
3179
|
+
// src/api/defineLink.ts
|
|
2854
3180
|
function defineLink(linkDefinition) {
|
|
2855
|
-
if ("one" in linkDefinition) {
|
|
2856
|
-
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2857
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant6__default.default(false) : void 0;
|
|
2858
|
-
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant6__default.default(false) : void 0;
|
|
2859
|
-
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2860
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant6__default.default(false) : void 0;
|
|
2861
|
-
}
|
|
2862
|
-
if ("intermediaryObjectType" in linkDefinition) {
|
|
2863
|
-
!("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" ? invariant6__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}`) : invariant6__default.default(false) : void 0;
|
|
2864
|
-
!("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" ? invariant6__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}`) : invariant6__default.default(false) : void 0;
|
|
2865
|
-
}
|
|
2866
3181
|
let fullLinkDefinition;
|
|
2867
3182
|
if ("one" in linkDefinition) {
|
|
2868
3183
|
fullLinkDefinition = {
|
|
@@ -2886,6 +3201,7 @@ function defineLink(linkDefinition) {
|
|
|
2886
3201
|
const linkType = {
|
|
2887
3202
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2888
3203
|
...fullLinkDefinition,
|
|
3204
|
+
apiName: linkDefinition.apiName,
|
|
2889
3205
|
__type: OntologyEntityTypeEnum.LINK_TYPE
|
|
2890
3206
|
};
|
|
2891
3207
|
updateOntology(linkType);
|
|
@@ -2921,6 +3237,148 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
2921
3237
|
typeClasses: []
|
|
2922
3238
|
};
|
|
2923
3239
|
}
|
|
3240
|
+
|
|
3241
|
+
// src/api/defineModifyInterfaceObjectAction.ts
|
|
3242
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
3243
|
+
addNamespaceToActionDefinition(def);
|
|
3244
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3245
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3246
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
3247
|
+
const parameterNames = new Set(propertyParameters);
|
|
3248
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3249
|
+
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3250
|
+
const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
|
|
3251
|
+
if (def.parameterOrdering) {
|
|
3252
|
+
if (!def.parameterOrdering.includes(MODIFY_INTERFACE_OBJECT_PARAMETER)) {
|
|
3253
|
+
def.parameterOrdering.unshift(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3254
|
+
}
|
|
3255
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3256
|
+
}
|
|
3257
|
+
const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
3258
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3259
|
+
return defineAction({
|
|
3260
|
+
apiName: actionApiName,
|
|
3261
|
+
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
3262
|
+
parameters,
|
|
3263
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
3264
|
+
entities: {
|
|
3265
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
3266
|
+
affectedObjectTypes: [],
|
|
3267
|
+
affectedLinkTypes: [],
|
|
3268
|
+
typeGroups: []
|
|
3269
|
+
},
|
|
3270
|
+
rules: [{
|
|
3271
|
+
type: "modifyInterfaceRule",
|
|
3272
|
+
modifyInterfaceRule: {
|
|
3273
|
+
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3274
|
+
sharedPropertyValues: {
|
|
3275
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
3276
|
+
type: "parameterId",
|
|
3277
|
+
parameterId: id
|
|
3278
|
+
}])),
|
|
3279
|
+
...mappings
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}],
|
|
3283
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
|
|
3284
|
+
...def.actionLevelValidation ? {
|
|
3285
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3286
|
+
} : {},
|
|
3287
|
+
...def.defaultFormat && {
|
|
3288
|
+
defaultFormat: def.defaultFormat
|
|
3289
|
+
},
|
|
3290
|
+
...def.enableLayoutSwitch && {
|
|
3291
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3292
|
+
},
|
|
3293
|
+
...def.tableConfiguration && {
|
|
3294
|
+
displayAndFormat: {
|
|
3295
|
+
table: def.tableConfiguration
|
|
3296
|
+
}
|
|
3297
|
+
},
|
|
3298
|
+
...def.sections && {
|
|
3299
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3300
|
+
},
|
|
3301
|
+
...def.submissionMetadata && {
|
|
3302
|
+
submissionMetadata: def.submissionMetadata
|
|
3303
|
+
}
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
|
|
3307
|
+
// src/api/defineModifyObjectAction.ts
|
|
3308
|
+
function defineModifyObjectAction(def) {
|
|
3309
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3310
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
3311
|
+
const parameterNames = new Set(propertyParameters);
|
|
3312
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3313
|
+
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
3314
|
+
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
3315
|
+
if (def.parameterOrdering) {
|
|
3316
|
+
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
3317
|
+
def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);
|
|
3318
|
+
}
|
|
3319
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3320
|
+
}
|
|
3321
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
3322
|
+
parameters.forEach((p) => {
|
|
3323
|
+
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
3324
|
+
p.defaultValue = {
|
|
3325
|
+
type: "objectParameterPropertyValue",
|
|
3326
|
+
objectParameterPropertyValue: {
|
|
3327
|
+
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
3328
|
+
propertyTypeId: p.id
|
|
3329
|
+
}
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
});
|
|
3333
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3334
|
+
return defineAction({
|
|
3335
|
+
apiName: actionApiName,
|
|
3336
|
+
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
3337
|
+
parameters,
|
|
3338
|
+
status: def.status ?? "active",
|
|
3339
|
+
rules: [{
|
|
3340
|
+
type: "modifyObjectRule",
|
|
3341
|
+
modifyObjectRule: {
|
|
3342
|
+
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
3343
|
+
propertyValues: {
|
|
3344
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
3345
|
+
type: "parameterId",
|
|
3346
|
+
parameterId: p
|
|
3347
|
+
}])),
|
|
3348
|
+
...mappings
|
|
3349
|
+
},
|
|
3350
|
+
structFieldValues: {}
|
|
3351
|
+
}
|
|
3352
|
+
}],
|
|
3353
|
+
entities: {
|
|
3354
|
+
affectedInterfaceTypes: [],
|
|
3355
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3356
|
+
affectedLinkTypes: [],
|
|
3357
|
+
typeGroups: []
|
|
3358
|
+
},
|
|
3359
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, MODIFY_OBJECT_PARAMETER),
|
|
3360
|
+
...def.actionLevelValidation ? {
|
|
3361
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3362
|
+
} : {},
|
|
3363
|
+
...def.defaultFormat && {
|
|
3364
|
+
defaultFormat: def.defaultFormat
|
|
3365
|
+
},
|
|
3366
|
+
...def.enableLayoutSwitch && {
|
|
3367
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3368
|
+
},
|
|
3369
|
+
...def.tableConfiguration && {
|
|
3370
|
+
displayAndFormat: {
|
|
3371
|
+
table: def.tableConfiguration
|
|
3372
|
+
}
|
|
3373
|
+
},
|
|
3374
|
+
...def.sections && {
|
|
3375
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3376
|
+
},
|
|
3377
|
+
...def.submissionMetadata && {
|
|
3378
|
+
submissionMetadata: def.submissionMetadata
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
2924
3382
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
2925
3383
|
switch (true) {
|
|
2926
3384
|
case (typeof valueType === "object" && valueType.type === "array"):
|
|
@@ -2973,7 +3431,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2973
3431
|
version
|
|
2974
3432
|
} = valueTypeDef;
|
|
2975
3433
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
2976
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
3434
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Version is not a valid semver") : invariant7__default.default(false) : void 0;
|
|
2977
3435
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2978
3436
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2979
3437
|
const output = {
|
|
@@ -3029,8 +3487,8 @@ function importSharedPropertyType(opts) {
|
|
|
3029
3487
|
} = opts;
|
|
3030
3488
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3031
3489
|
if (packageName !== void 0) {
|
|
3032
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
3033
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
3490
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Package name format invalid ends with period") : invariant7__default.default(false) : void 0;
|
|
3491
|
+
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Package name includes upper case characters") : invariant7__default.default(false) : void 0;
|
|
3034
3492
|
}
|
|
3035
3493
|
const spt = {
|
|
3036
3494
|
apiName: fullApiName,
|
|
@@ -3053,7 +3511,9 @@ function wrapWithProxy(entity) {
|
|
|
3053
3511
|
});
|
|
3054
3512
|
}
|
|
3055
3513
|
|
|
3514
|
+
exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
|
|
3056
3515
|
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
3516
|
+
exports.MODIFY_INTERFACE_OBJECT_PARAMETER = MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
3057
3517
|
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
3058
3518
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
3059
3519
|
exports.addDependency = addDependency;
|
|
@@ -3066,6 +3526,7 @@ exports.defineAction = defineAction;
|
|
|
3066
3526
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
3067
3527
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
3068
3528
|
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
3529
|
+
exports.defineDeleteInterfaceObjectAction = defineDeleteInterfaceObjectAction;
|
|
3069
3530
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
3070
3531
|
exports.defineInterface = defineInterface;
|
|
3071
3532
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|