@osdk/maker 0.14.0-beta.1 → 0.14.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -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 +1711 -806
- 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 +4 -3
- 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,13 @@
|
|
|
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');
|
|
12
13
|
var crypto = require('crypto');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,11 +32,11 @@ function _interopNamespace(e) {
|
|
|
31
32
|
return Object.freeze(n);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
36
|
+
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
37
|
+
var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
|
|
37
38
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
38
|
-
var
|
|
39
|
+
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
39
40
|
|
|
40
41
|
// src/cli/main.ts
|
|
41
42
|
|
|
@@ -66,6 +67,193 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2)
|
|
|
66
67
|
return OntologyEntityTypeEnum2;
|
|
67
68
|
})({});
|
|
68
69
|
|
|
70
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
71
|
+
function convertCardinality(cardinality) {
|
|
72
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
73
|
+
return "ONE_TO_MANY";
|
|
74
|
+
}
|
|
75
|
+
return "ONE_TO_ONE";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/conversion/toMarketplace/convertLink.ts
|
|
79
|
+
function convertLink(linkType) {
|
|
80
|
+
validateLink(linkType);
|
|
81
|
+
let definition;
|
|
82
|
+
let datasource = void 0;
|
|
83
|
+
if ("one" in linkType) {
|
|
84
|
+
const {
|
|
85
|
+
apiName: oneObjectApiName,
|
|
86
|
+
object: oneObject
|
|
87
|
+
} = getObject(linkType.one.object);
|
|
88
|
+
const {
|
|
89
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
90
|
+
definition = {
|
|
91
|
+
type: "oneToMany",
|
|
92
|
+
oneToMany: {
|
|
93
|
+
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
94
|
+
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
95
|
+
objectTypeRidManySide: toManyObjectApiName,
|
|
96
|
+
objectTypeRidOneSide: oneObjectApiName,
|
|
97
|
+
oneToManyLinkMetadata: linkType.one.metadata,
|
|
98
|
+
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
99
|
+
from: {
|
|
100
|
+
apiName: oneObject.primaryKeyPropertyApiName,
|
|
101
|
+
object: oneObjectApiName
|
|
102
|
+
},
|
|
103
|
+
to: {
|
|
104
|
+
apiName: linkType.manyForeignKeyProperty,
|
|
105
|
+
object: toManyObjectApiName
|
|
106
|
+
}
|
|
107
|
+
}]
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
111
|
+
const {
|
|
112
|
+
apiName: manyObjectApiName} = getObject(linkType.many.object);
|
|
113
|
+
const {
|
|
114
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
115
|
+
definition = {
|
|
116
|
+
type: "intermediary",
|
|
117
|
+
intermediary: {
|
|
118
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
119
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
120
|
+
objectTypeRidA: manyObjectApiName,
|
|
121
|
+
objectTypeRidB: toManyObjectApiName,
|
|
122
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
123
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
124
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
} else {
|
|
128
|
+
const {
|
|
129
|
+
apiName: manyObjectApiName,
|
|
130
|
+
object: manyObject
|
|
131
|
+
} = getObject(linkType.many.object);
|
|
132
|
+
const {
|
|
133
|
+
apiName: toManyObjectApiName,
|
|
134
|
+
object: toManyObject
|
|
135
|
+
} = getObject(linkType.toMany.object);
|
|
136
|
+
definition = {
|
|
137
|
+
type: "manyToMany",
|
|
138
|
+
manyToMany: {
|
|
139
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
140
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
141
|
+
objectTypeRidA: manyObjectApiName,
|
|
142
|
+
objectTypeRidB: toManyObjectApiName,
|
|
143
|
+
peeringMetadata: void 0,
|
|
144
|
+
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
145
|
+
from: {
|
|
146
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
147
|
+
object: manyObjectApiName
|
|
148
|
+
},
|
|
149
|
+
to: {
|
|
150
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
151
|
+
object: manyObjectApiName
|
|
152
|
+
}
|
|
153
|
+
}],
|
|
154
|
+
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
155
|
+
from: {
|
|
156
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
157
|
+
object: toManyObjectApiName
|
|
158
|
+
},
|
|
159
|
+
to: {
|
|
160
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
161
|
+
object: toManyObjectApiName
|
|
162
|
+
}
|
|
163
|
+
}]
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
datasource = {
|
|
167
|
+
datasourceName: linkType.apiName,
|
|
168
|
+
datasource: {
|
|
169
|
+
type: "dataset",
|
|
170
|
+
dataset: {
|
|
171
|
+
datasetRid: "link-".concat(linkType.apiName),
|
|
172
|
+
writebackDatasetRid: void 0,
|
|
173
|
+
objectTypeAPrimaryKeyMapping: [{
|
|
174
|
+
property: {
|
|
175
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
176
|
+
object: manyObjectApiName
|
|
177
|
+
},
|
|
178
|
+
column: manyObject.primaryKeyPropertyApiName
|
|
179
|
+
}],
|
|
180
|
+
objectTypeBPrimaryKeyMapping: [{
|
|
181
|
+
property: {
|
|
182
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
183
|
+
object: toManyObjectApiName
|
|
184
|
+
},
|
|
185
|
+
column: toManyObject.primaryKeyPropertyApiName
|
|
186
|
+
}]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
editsConfiguration: {
|
|
190
|
+
onlyAllowPrivilegedEdits: false
|
|
191
|
+
},
|
|
192
|
+
redacted: linkType.redacted
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
linkType: {
|
|
197
|
+
definition,
|
|
198
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
199
|
+
status: linkType.status ?? {
|
|
200
|
+
type: "active",
|
|
201
|
+
active: {}
|
|
202
|
+
},
|
|
203
|
+
redacted: linkType.redacted ?? false
|
|
204
|
+
},
|
|
205
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
206
|
+
entityMetadata: {
|
|
207
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function validateLink(linkDefinition) {
|
|
212
|
+
if ("one" in linkDefinition) {
|
|
213
|
+
const {
|
|
214
|
+
object: oneObject
|
|
215
|
+
} = getObject(linkDefinition.one.object);
|
|
216
|
+
const {
|
|
217
|
+
apiName: toManyObjectApiName,
|
|
218
|
+
object: toManyObject
|
|
219
|
+
} = getObject(linkDefinition.toMany.object);
|
|
220
|
+
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
221
|
+
!(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;
|
|
222
|
+
!/([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;
|
|
223
|
+
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
224
|
+
!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;
|
|
225
|
+
}
|
|
226
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
227
|
+
const {
|
|
228
|
+
apiName: intermediaryObjectTypeApiName} = getObject(linkDefinition.intermediaryObjectType);
|
|
229
|
+
const {
|
|
230
|
+
apiName: manyObjectApiName,
|
|
231
|
+
object: manyObject
|
|
232
|
+
} = getObject(linkDefinition.many.object);
|
|
233
|
+
const {
|
|
234
|
+
apiName: toManyObjectApiName} = getObject(linkDefinition.toMany.object);
|
|
235
|
+
const {
|
|
236
|
+
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
237
|
+
const {
|
|
238
|
+
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
239
|
+
!("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;
|
|
240
|
+
const {
|
|
241
|
+
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
242
|
+
const {
|
|
243
|
+
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
244
|
+
!("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;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function getObject(object) {
|
|
248
|
+
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
249
|
+
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
250
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object ${objectApiName} is not defined`) : invariant7__default.default(false) : void 0;
|
|
251
|
+
return {
|
|
252
|
+
apiName: objectApiName,
|
|
253
|
+
object: fullObject
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
69
257
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
70
258
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
71
259
|
let properties = interfaceType.propertiesV2;
|
|
@@ -107,12 +295,20 @@ function defineObject(objectDef) {
|
|
|
107
295
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
108
296
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
109
297
|
}
|
|
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
|
-
|
|
298
|
+
!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;
|
|
299
|
+
!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;
|
|
300
|
+
!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;
|
|
301
|
+
!!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;
|
|
302
|
+
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
303
|
+
retentionPeriods.forEach((retentionPeriod) => {
|
|
304
|
+
!(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;
|
|
305
|
+
});
|
|
306
|
+
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
307
|
+
!(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;
|
|
308
|
+
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
309
|
+
if (derivedDatasources.length > 0) {
|
|
310
|
+
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
311
|
+
}
|
|
116
312
|
if (objectDef.status === "experimental") {
|
|
117
313
|
const activeProperties = [];
|
|
118
314
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -120,14 +316,14 @@ function defineObject(objectDef) {
|
|
|
120
316
|
activeProperties.push(apiName2);
|
|
121
317
|
}
|
|
122
318
|
});
|
|
123
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
319
|
+
!(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
320
|
}
|
|
125
321
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
126
322
|
const deadline = objectDef.status.deadline;
|
|
127
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
323
|
+
!(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
324
|
}
|
|
129
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
130
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
325
|
+
!!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;
|
|
326
|
+
!!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
327
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
132
328
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
133
329
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -146,7 +342,7 @@ function defineObject(objectDef) {
|
|
|
146
342
|
};
|
|
147
343
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
148
344
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
149
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
345
|
+
!(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
346
|
});
|
|
151
347
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
152
348
|
const finalObject = {
|
|
@@ -197,6 +393,72 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
197
393
|
type: property.type
|
|
198
394
|
};
|
|
199
395
|
}
|
|
396
|
+
function validateDerivedDatasource(objectDef, datasource) {
|
|
397
|
+
!(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;
|
|
398
|
+
datasource.linkDefinition.forEach((link) => {
|
|
399
|
+
const linkApiName = link.linkType.apiName;
|
|
400
|
+
!(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;
|
|
401
|
+
});
|
|
402
|
+
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
403
|
+
!(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;
|
|
404
|
+
});
|
|
405
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
406
|
+
if (isLinkedProperties) {
|
|
407
|
+
validateLinkedProperties(datasource);
|
|
408
|
+
} else {
|
|
409
|
+
validateAggregations(datasource, objectDef);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function validateLinkedProperties(datasource, objectDef) {
|
|
413
|
+
const foreignProperties = Object.values(datasource.propertyMapping);
|
|
414
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
415
|
+
foreignProperties.forEach((prop) => {
|
|
416
|
+
!(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;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
function validateAggregations(datasource, objectDef) {
|
|
420
|
+
const props = datasource.propertyMapping;
|
|
421
|
+
Object.entries(props).forEach(([propName, agg]) => {
|
|
422
|
+
const property = objectDef.properties[propName];
|
|
423
|
+
switch (agg.type) {
|
|
424
|
+
case "collectList":
|
|
425
|
+
case "collectSet":
|
|
426
|
+
!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;
|
|
427
|
+
!(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;
|
|
428
|
+
break;
|
|
429
|
+
case "avg":
|
|
430
|
+
case "sum":
|
|
431
|
+
!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;
|
|
432
|
+
break;
|
|
433
|
+
case "min":
|
|
434
|
+
case "max":
|
|
435
|
+
case "approximateCardinality":
|
|
436
|
+
case "exactCardinality":
|
|
437
|
+
!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;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
if (agg.type !== "count") {
|
|
441
|
+
const foreignProperty = agg.property;
|
|
442
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
443
|
+
!(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;
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
function isCollectible(property) {
|
|
448
|
+
if (!(property.array ?? false)) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
const typeType = typeof property.type === "string" ? property.type : property.type.type;
|
|
452
|
+
return ["boolean", "byte", "date", "double", "float", "geohash", "geoshape", "integer", "long", "mediareference", "short", "string", "struct", "timestamp"].includes(typeType);
|
|
453
|
+
}
|
|
454
|
+
function isNumeric(type) {
|
|
455
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
456
|
+
return ["byte", "double", "float", "integer", "long", "short"].includes(typeType);
|
|
457
|
+
}
|
|
458
|
+
function isPrimitive(type) {
|
|
459
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
460
|
+
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
461
|
+
}
|
|
200
462
|
|
|
201
463
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
202
464
|
function convertActionSections(action) {
|
|
@@ -224,14 +486,14 @@ function convertActionSections(action) {
|
|
|
224
486
|
}
|
|
225
487
|
}]));
|
|
226
488
|
}
|
|
227
|
-
function convertConditionDefinition(condition,
|
|
489
|
+
function convertConditionDefinition(condition, actionParameters) {
|
|
228
490
|
switch (condition.type) {
|
|
229
491
|
case "and":
|
|
230
492
|
if ("conditions" in condition) {
|
|
231
493
|
return {
|
|
232
494
|
type: "and",
|
|
233
495
|
and: {
|
|
234
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c,
|
|
496
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
235
497
|
}
|
|
236
498
|
};
|
|
237
499
|
} else {
|
|
@@ -242,7 +504,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
242
504
|
return {
|
|
243
505
|
type: "or",
|
|
244
506
|
or: {
|
|
245
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c,
|
|
507
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
246
508
|
}
|
|
247
509
|
};
|
|
248
510
|
} else {
|
|
@@ -278,7 +540,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
278
540
|
}
|
|
279
541
|
};
|
|
280
542
|
case "parameter":
|
|
281
|
-
!
|
|
543
|
+
!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
544
|
return {
|
|
283
545
|
type: "comparison",
|
|
284
546
|
comparison: {
|
|
@@ -296,7 +558,7 @@ function convertConditionDefinition(condition, objectProperties) {
|
|
|
296
558
|
}
|
|
297
559
|
|
|
298
560
|
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
299
|
-
function convertActionParameterConditionalOverride(override, validation,
|
|
561
|
+
function convertActionParameterConditionalOverride(override, validation, actionParameters) {
|
|
300
562
|
let parameterBlockOverride;
|
|
301
563
|
switch (override.type) {
|
|
302
564
|
case "required":
|
|
@@ -361,7 +623,7 @@ function convertActionParameterConditionalOverride(override, validation, objectP
|
|
|
361
623
|
throw new Error(`Unknown parameter override type`);
|
|
362
624
|
}
|
|
363
625
|
return {
|
|
364
|
-
condition: convertConditionDefinition(override.condition,
|
|
626
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
365
627
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
366
628
|
};
|
|
367
629
|
}
|
|
@@ -393,9 +655,9 @@ function convertActionVisibility(visibility) {
|
|
|
393
655
|
}
|
|
394
656
|
|
|
395
657
|
// src/conversion/toMarketplace/convertSectionConditionalOverride.ts
|
|
396
|
-
function convertSectionConditionalOverride(override, defaultVisibility,
|
|
658
|
+
function convertSectionConditionalOverride(override, defaultVisibility, actionParameters) {
|
|
397
659
|
return {
|
|
398
|
-
condition: convertConditionDefinition(override.condition,
|
|
660
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
399
661
|
sectionBlockOverrides: [{
|
|
400
662
|
type: "visibility",
|
|
401
663
|
visibility: {
|
|
@@ -441,7 +703,7 @@ function convertActionValidation(action) {
|
|
|
441
703
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
442
704
|
}
|
|
443
705
|
},
|
|
444
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation,
|
|
706
|
+
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation, action.parameters)) ?? []
|
|
445
707
|
}];
|
|
446
708
|
})),
|
|
447
709
|
sectionValidations: {
|
|
@@ -457,7 +719,7 @@ function convertActionValidation(action) {
|
|
|
457
719
|
visible: {}
|
|
458
720
|
}
|
|
459
721
|
},
|
|
460
|
-
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible",
|
|
722
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", action.parameters)) ?? []
|
|
461
723
|
}]))
|
|
462
724
|
}
|
|
463
725
|
};
|
|
@@ -484,20 +746,6 @@ function convertParameterRequirementConstraint(required) {
|
|
|
484
746
|
}
|
|
485
747
|
};
|
|
486
748
|
}
|
|
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
749
|
function convertNullabilityToDataConstraint(prop) {
|
|
502
750
|
if (typeof prop.type === "object" && prop.type.type === "marking") {
|
|
503
751
|
if (prop.nullability === void 0) {
|
|
@@ -510,7 +758,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
510
758
|
}
|
|
511
759
|
};
|
|
512
760
|
}
|
|
513
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
761
|
+
!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
762
|
return {
|
|
515
763
|
propertyTypeConstraints: [],
|
|
516
764
|
nullability: void 0,
|
|
@@ -714,134 +962,12 @@ function convertInterface(interfaceType) {
|
|
|
714
962
|
};
|
|
715
963
|
}
|
|
716
964
|
|
|
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
965
|
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
841
966
|
function convertDatasourceDefinition(objectType, properties) {
|
|
842
|
-
|
|
967
|
+
const baseDatasource = objectType.datasources?.find((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
968
|
+
switch (baseDatasource?.type) {
|
|
843
969
|
case "stream":
|
|
844
|
-
const window =
|
|
970
|
+
const window = baseDatasource.retentionPeriod;
|
|
845
971
|
const retentionPolicy = window ? {
|
|
846
972
|
type: "time",
|
|
847
973
|
time: {
|
|
@@ -1030,7 +1156,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1030
1156
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1031
1157
|
function convertObjectPropertyType(property) {
|
|
1032
1158
|
const apiName = namespace + property.apiName;
|
|
1033
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1159
|
+
!(!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
1160
|
const output = {
|
|
1035
1161
|
apiName: property.apiName,
|
|
1036
1162
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1060,12 +1186,16 @@ function convertObjectPropertyType(property) {
|
|
|
1060
1186
|
|
|
1061
1187
|
// src/conversion/toMarketplace/convertObject.ts
|
|
1062
1188
|
function convertObject(objectType) {
|
|
1063
|
-
const
|
|
1189
|
+
const {
|
|
1190
|
+
derivedDatasources,
|
|
1191
|
+
derivedPropertyNames
|
|
1192
|
+
} = extractDerivedDatasources(objectType);
|
|
1193
|
+
const propertyDatasources = (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName)).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
1064
1194
|
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1065
1195
|
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1066
1196
|
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1067
1197
|
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);
|
|
1198
|
+
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName))), classificationInputGroup, mandatoryInputGroup);
|
|
1069
1199
|
const implementations = objectType.implementsInterfaces ?? [];
|
|
1070
1200
|
return {
|
|
1071
1201
|
objectType: {
|
|
@@ -1099,7 +1229,7 @@ function convertObject(objectType) {
|
|
|
1099
1229
|
})),
|
|
1100
1230
|
allImplementsInterfaces: {}
|
|
1101
1231
|
},
|
|
1102
|
-
datasources: [...propertyDatasources, objectDatasource],
|
|
1232
|
+
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1103
1233
|
entityMetadata: {
|
|
1104
1234
|
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1105
1235
|
}
|
|
@@ -1142,6 +1272,80 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1142
1272
|
return [];
|
|
1143
1273
|
}
|
|
1144
1274
|
}
|
|
1275
|
+
function extractDerivedDatasources(objectType) {
|
|
1276
|
+
const inputDerivedDatasources = (objectType.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
1277
|
+
const derivedDatasources = inputDerivedDatasources.map((ds, i) => buildDerivedDatasource(ds, i, objectType.apiName));
|
|
1278
|
+
const derivedPropertyNames = inputDerivedDatasources.flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
1279
|
+
return {
|
|
1280
|
+
derivedDatasources,
|
|
1281
|
+
derivedPropertyNames
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
function buildDerivedDatasource(datasource, index, objectTypeApiName) {
|
|
1285
|
+
const linkDefinition = {
|
|
1286
|
+
type: "multiHopLink",
|
|
1287
|
+
multiHopLink: {
|
|
1288
|
+
steps: datasource.linkDefinition.map((step) => ({
|
|
1289
|
+
type: "searchAround",
|
|
1290
|
+
searchAround: {
|
|
1291
|
+
linkTypeIdentifier: {
|
|
1292
|
+
type: "linkType",
|
|
1293
|
+
linkType: cleanAndValidateLinkTypeId(step.linkType.apiName)
|
|
1294
|
+
},
|
|
1295
|
+
linkTypeSide: step.side ?? "SOURCE"
|
|
1296
|
+
}
|
|
1297
|
+
}))
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
1301
|
+
const derivedDefinition = isLinkedProperties ? {
|
|
1302
|
+
type: "linkedProperties",
|
|
1303
|
+
linkedProperties: {
|
|
1304
|
+
linkDefinition,
|
|
1305
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, targetProp]) => [sourceProp, {
|
|
1306
|
+
type: "propertyType",
|
|
1307
|
+
propertyType: targetProp
|
|
1308
|
+
}]))
|
|
1309
|
+
}
|
|
1310
|
+
} : {
|
|
1311
|
+
type: "aggregatedProperties",
|
|
1312
|
+
aggregatedProperties: {
|
|
1313
|
+
linkDefinition,
|
|
1314
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, agg]) => [sourceProp, buildAggregation(agg)]))
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
const fullDefinition = {
|
|
1318
|
+
type: "derived",
|
|
1319
|
+
derived: {
|
|
1320
|
+
definition: derivedDefinition
|
|
1321
|
+
}
|
|
1322
|
+
};
|
|
1323
|
+
return buildDatasource(objectTypeApiName + ".derived." + index.toString(), fullDefinition);
|
|
1324
|
+
}
|
|
1325
|
+
function buildAggregation(agg) {
|
|
1326
|
+
const type = agg.type;
|
|
1327
|
+
const limit = "limit" in agg ? agg.limit : void 0;
|
|
1328
|
+
const foreignProperty = "property" in agg ? agg.property : void 0;
|
|
1329
|
+
const innerDef = {};
|
|
1330
|
+
if (type !== "count") {
|
|
1331
|
+
if (["collectList", "collectSet"].includes(type)) {
|
|
1332
|
+
innerDef["linkedProperty"] = {
|
|
1333
|
+
type: "propertyType",
|
|
1334
|
+
propertyType: foreignProperty
|
|
1335
|
+
};
|
|
1336
|
+
innerDef["limit"] = limit;
|
|
1337
|
+
} else {
|
|
1338
|
+
innerDef["property"] = {
|
|
1339
|
+
type: "propertyType",
|
|
1340
|
+
propertyType: foreignProperty
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
return {
|
|
1345
|
+
type,
|
|
1346
|
+
[type]: innerDef
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1145
1349
|
|
|
1146
1350
|
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1147
1351
|
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
@@ -1240,8 +1444,543 @@ function getFormContentOrdering(action, parameterOrdering) {
|
|
|
1240
1444
|
return formContentOrdering;
|
|
1241
1445
|
}
|
|
1242
1446
|
|
|
1243
|
-
//
|
|
1244
|
-
var
|
|
1447
|
+
// ../../node_modules/.pnpm/mustache@4.2.0/node_modules/mustache/mustache.mjs
|
|
1448
|
+
var objectToString = Object.prototype.toString;
|
|
1449
|
+
var isArray = Array.isArray || function isArrayPolyfill(object) {
|
|
1450
|
+
return objectToString.call(object) === "[object Array]";
|
|
1451
|
+
};
|
|
1452
|
+
function isFunction(object) {
|
|
1453
|
+
return typeof object === "function";
|
|
1454
|
+
}
|
|
1455
|
+
function typeStr(obj) {
|
|
1456
|
+
return isArray(obj) ? "array" : typeof obj;
|
|
1457
|
+
}
|
|
1458
|
+
function escapeRegExp(string) {
|
|
1459
|
+
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
1460
|
+
}
|
|
1461
|
+
function hasProperty(obj, propName) {
|
|
1462
|
+
return obj != null && typeof obj === "object" && propName in obj;
|
|
1463
|
+
}
|
|
1464
|
+
function primitiveHasOwnProperty(primitive, propName) {
|
|
1465
|
+
return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
|
|
1466
|
+
}
|
|
1467
|
+
var regExpTest = RegExp.prototype.test;
|
|
1468
|
+
function testRegExp(re, string) {
|
|
1469
|
+
return regExpTest.call(re, string);
|
|
1470
|
+
}
|
|
1471
|
+
var nonSpaceRe = /\S/;
|
|
1472
|
+
function isWhitespace(string) {
|
|
1473
|
+
return !testRegExp(nonSpaceRe, string);
|
|
1474
|
+
}
|
|
1475
|
+
var entityMap = {
|
|
1476
|
+
"&": "&",
|
|
1477
|
+
"<": "<",
|
|
1478
|
+
">": ">",
|
|
1479
|
+
'"': """,
|
|
1480
|
+
"'": "'",
|
|
1481
|
+
"/": "/",
|
|
1482
|
+
"`": "`",
|
|
1483
|
+
"=": "="
|
|
1484
|
+
};
|
|
1485
|
+
function escapeHtml(string) {
|
|
1486
|
+
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
|
|
1487
|
+
return entityMap[s];
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
var whiteRe = /\s*/;
|
|
1491
|
+
var spaceRe = /\s+/;
|
|
1492
|
+
var equalsRe = /\s*=/;
|
|
1493
|
+
var curlyRe = /\s*\}/;
|
|
1494
|
+
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
|
1495
|
+
function parseTemplate(template, tags) {
|
|
1496
|
+
if (!template) return [];
|
|
1497
|
+
var lineHasNonSpace = false;
|
|
1498
|
+
var sections = [];
|
|
1499
|
+
var tokens = [];
|
|
1500
|
+
var spaces = [];
|
|
1501
|
+
var hasTag = false;
|
|
1502
|
+
var nonSpace = false;
|
|
1503
|
+
var indentation = "";
|
|
1504
|
+
var tagIndex = 0;
|
|
1505
|
+
function stripSpace() {
|
|
1506
|
+
if (hasTag && !nonSpace) {
|
|
1507
|
+
while (spaces.length) delete tokens[spaces.pop()];
|
|
1508
|
+
} else {
|
|
1509
|
+
spaces = [];
|
|
1510
|
+
}
|
|
1511
|
+
hasTag = false;
|
|
1512
|
+
nonSpace = false;
|
|
1513
|
+
}
|
|
1514
|
+
var openingTagRe, closingTagRe, closingCurlyRe;
|
|
1515
|
+
function compileTags(tagsToCompile) {
|
|
1516
|
+
if (typeof tagsToCompile === "string") tagsToCompile = tagsToCompile.split(spaceRe, 2);
|
|
1517
|
+
if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) throw new Error("Invalid tags: " + tagsToCompile);
|
|
1518
|
+
openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + "\\s*");
|
|
1519
|
+
closingTagRe = new RegExp("\\s*" + escapeRegExp(tagsToCompile[1]));
|
|
1520
|
+
closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + tagsToCompile[1]));
|
|
1521
|
+
}
|
|
1522
|
+
compileTags(tags || mustache.tags);
|
|
1523
|
+
var scanner = new Scanner(template);
|
|
1524
|
+
var start, type, value, chr, token, openSection;
|
|
1525
|
+
while (!scanner.eos()) {
|
|
1526
|
+
start = scanner.pos;
|
|
1527
|
+
value = scanner.scanUntil(openingTagRe);
|
|
1528
|
+
if (value) {
|
|
1529
|
+
for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
|
|
1530
|
+
chr = value.charAt(i);
|
|
1531
|
+
if (isWhitespace(chr)) {
|
|
1532
|
+
spaces.push(tokens.length);
|
|
1533
|
+
indentation += chr;
|
|
1534
|
+
} else {
|
|
1535
|
+
nonSpace = true;
|
|
1536
|
+
lineHasNonSpace = true;
|
|
1537
|
+
indentation += " ";
|
|
1538
|
+
}
|
|
1539
|
+
tokens.push(["text", chr, start, start + 1]);
|
|
1540
|
+
start += 1;
|
|
1541
|
+
if (chr === "\n") {
|
|
1542
|
+
stripSpace();
|
|
1543
|
+
indentation = "";
|
|
1544
|
+
tagIndex = 0;
|
|
1545
|
+
lineHasNonSpace = false;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
if (!scanner.scan(openingTagRe)) break;
|
|
1550
|
+
hasTag = true;
|
|
1551
|
+
type = scanner.scan(tagRe) || "name";
|
|
1552
|
+
scanner.scan(whiteRe);
|
|
1553
|
+
if (type === "=") {
|
|
1554
|
+
value = scanner.scanUntil(equalsRe);
|
|
1555
|
+
scanner.scan(equalsRe);
|
|
1556
|
+
scanner.scanUntil(closingTagRe);
|
|
1557
|
+
} else if (type === "{") {
|
|
1558
|
+
value = scanner.scanUntil(closingCurlyRe);
|
|
1559
|
+
scanner.scan(curlyRe);
|
|
1560
|
+
scanner.scanUntil(closingTagRe);
|
|
1561
|
+
type = "&";
|
|
1562
|
+
} else {
|
|
1563
|
+
value = scanner.scanUntil(closingTagRe);
|
|
1564
|
+
}
|
|
1565
|
+
if (!scanner.scan(closingTagRe)) throw new Error("Unclosed tag at " + scanner.pos);
|
|
1566
|
+
if (type == ">") {
|
|
1567
|
+
token = [type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace];
|
|
1568
|
+
} else {
|
|
1569
|
+
token = [type, value, start, scanner.pos];
|
|
1570
|
+
}
|
|
1571
|
+
tagIndex++;
|
|
1572
|
+
tokens.push(token);
|
|
1573
|
+
if (type === "#" || type === "^") {
|
|
1574
|
+
sections.push(token);
|
|
1575
|
+
} else if (type === "/") {
|
|
1576
|
+
openSection = sections.pop();
|
|
1577
|
+
if (!openSection) throw new Error('Unopened section "' + value + '" at ' + start);
|
|
1578
|
+
if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
|
|
1579
|
+
} else if (type === "name" || type === "{" || type === "&") {
|
|
1580
|
+
nonSpace = true;
|
|
1581
|
+
} else if (type === "=") {
|
|
1582
|
+
compileTags(value);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
stripSpace();
|
|
1586
|
+
openSection = sections.pop();
|
|
1587
|
+
if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
|
1588
|
+
return nestTokens(squashTokens(tokens));
|
|
1589
|
+
}
|
|
1590
|
+
function squashTokens(tokens) {
|
|
1591
|
+
var squashedTokens = [];
|
|
1592
|
+
var token, lastToken;
|
|
1593
|
+
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
1594
|
+
token = tokens[i];
|
|
1595
|
+
if (token) {
|
|
1596
|
+
if (token[0] === "text" && lastToken && lastToken[0] === "text") {
|
|
1597
|
+
lastToken[1] += token[1];
|
|
1598
|
+
lastToken[3] = token[3];
|
|
1599
|
+
} else {
|
|
1600
|
+
squashedTokens.push(token);
|
|
1601
|
+
lastToken = token;
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return squashedTokens;
|
|
1606
|
+
}
|
|
1607
|
+
function nestTokens(tokens) {
|
|
1608
|
+
var nestedTokens = [];
|
|
1609
|
+
var collector = nestedTokens;
|
|
1610
|
+
var sections = [];
|
|
1611
|
+
var token, section;
|
|
1612
|
+
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
1613
|
+
token = tokens[i];
|
|
1614
|
+
switch (token[0]) {
|
|
1615
|
+
case "#":
|
|
1616
|
+
case "^":
|
|
1617
|
+
collector.push(token);
|
|
1618
|
+
sections.push(token);
|
|
1619
|
+
collector = token[4] = [];
|
|
1620
|
+
break;
|
|
1621
|
+
case "/":
|
|
1622
|
+
section = sections.pop();
|
|
1623
|
+
section[5] = token[2];
|
|
1624
|
+
collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
|
|
1625
|
+
break;
|
|
1626
|
+
default:
|
|
1627
|
+
collector.push(token);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return nestedTokens;
|
|
1631
|
+
}
|
|
1632
|
+
function Scanner(string) {
|
|
1633
|
+
this.string = string;
|
|
1634
|
+
this.tail = string;
|
|
1635
|
+
this.pos = 0;
|
|
1636
|
+
}
|
|
1637
|
+
Scanner.prototype.eos = function eos() {
|
|
1638
|
+
return this.tail === "";
|
|
1639
|
+
};
|
|
1640
|
+
Scanner.prototype.scan = function scan(re) {
|
|
1641
|
+
var match = this.tail.match(re);
|
|
1642
|
+
if (!match || match.index !== 0) return "";
|
|
1643
|
+
var string = match[0];
|
|
1644
|
+
this.tail = this.tail.substring(string.length);
|
|
1645
|
+
this.pos += string.length;
|
|
1646
|
+
return string;
|
|
1647
|
+
};
|
|
1648
|
+
Scanner.prototype.scanUntil = function scanUntil(re) {
|
|
1649
|
+
var index = this.tail.search(re), match;
|
|
1650
|
+
switch (index) {
|
|
1651
|
+
case -1:
|
|
1652
|
+
match = this.tail;
|
|
1653
|
+
this.tail = "";
|
|
1654
|
+
break;
|
|
1655
|
+
case 0:
|
|
1656
|
+
match = "";
|
|
1657
|
+
break;
|
|
1658
|
+
default:
|
|
1659
|
+
match = this.tail.substring(0, index);
|
|
1660
|
+
this.tail = this.tail.substring(index);
|
|
1661
|
+
}
|
|
1662
|
+
this.pos += match.length;
|
|
1663
|
+
return match;
|
|
1664
|
+
};
|
|
1665
|
+
function Context(view, parentContext) {
|
|
1666
|
+
this.view = view;
|
|
1667
|
+
this.cache = {
|
|
1668
|
+
".": this.view
|
|
1669
|
+
};
|
|
1670
|
+
this.parent = parentContext;
|
|
1671
|
+
}
|
|
1672
|
+
Context.prototype.push = function push(view) {
|
|
1673
|
+
return new Context(view, this);
|
|
1674
|
+
};
|
|
1675
|
+
Context.prototype.lookup = function lookup(name) {
|
|
1676
|
+
var cache = this.cache;
|
|
1677
|
+
var value;
|
|
1678
|
+
if (cache.hasOwnProperty(name)) {
|
|
1679
|
+
value = cache[name];
|
|
1680
|
+
} else {
|
|
1681
|
+
var context = this, intermediateValue, names, index, lookupHit = false;
|
|
1682
|
+
while (context) {
|
|
1683
|
+
if (name.indexOf(".") > 0) {
|
|
1684
|
+
intermediateValue = context.view;
|
|
1685
|
+
names = name.split(".");
|
|
1686
|
+
index = 0;
|
|
1687
|
+
while (intermediateValue != null && index < names.length) {
|
|
1688
|
+
if (index === names.length - 1) lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
|
|
1689
|
+
intermediateValue = intermediateValue[names[index++]];
|
|
1690
|
+
}
|
|
1691
|
+
} else {
|
|
1692
|
+
intermediateValue = context.view[name];
|
|
1693
|
+
lookupHit = hasProperty(context.view, name);
|
|
1694
|
+
}
|
|
1695
|
+
if (lookupHit) {
|
|
1696
|
+
value = intermediateValue;
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
context = context.parent;
|
|
1700
|
+
}
|
|
1701
|
+
cache[name] = value;
|
|
1702
|
+
}
|
|
1703
|
+
if (isFunction(value)) value = value.call(this.view);
|
|
1704
|
+
return value;
|
|
1705
|
+
};
|
|
1706
|
+
function Writer() {
|
|
1707
|
+
this.templateCache = {
|
|
1708
|
+
_cache: {},
|
|
1709
|
+
set: function set(key, value) {
|
|
1710
|
+
this._cache[key] = value;
|
|
1711
|
+
},
|
|
1712
|
+
get: function get(key) {
|
|
1713
|
+
return this._cache[key];
|
|
1714
|
+
},
|
|
1715
|
+
clear: function clear() {
|
|
1716
|
+
this._cache = {};
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
Writer.prototype.clearCache = function clearCache() {
|
|
1721
|
+
if (typeof this.templateCache !== "undefined") {
|
|
1722
|
+
this.templateCache.clear();
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
Writer.prototype.parse = function parse(template, tags) {
|
|
1726
|
+
var cache = this.templateCache;
|
|
1727
|
+
var cacheKey = template + ":" + (tags || mustache.tags).join(":");
|
|
1728
|
+
var isCacheEnabled = typeof cache !== "undefined";
|
|
1729
|
+
var tokens = isCacheEnabled ? cache.get(cacheKey) : void 0;
|
|
1730
|
+
if (tokens == void 0) {
|
|
1731
|
+
tokens = parseTemplate(template, tags);
|
|
1732
|
+
isCacheEnabled && cache.set(cacheKey, tokens);
|
|
1733
|
+
}
|
|
1734
|
+
return tokens;
|
|
1735
|
+
};
|
|
1736
|
+
Writer.prototype.render = function render(template, view, partials, config) {
|
|
1737
|
+
var tags = this.getConfigTags(config);
|
|
1738
|
+
var tokens = this.parse(template, tags);
|
|
1739
|
+
var context = view instanceof Context ? view : new Context(view, void 0);
|
|
1740
|
+
return this.renderTokens(tokens, context, partials, template, config);
|
|
1741
|
+
};
|
|
1742
|
+
Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate, config) {
|
|
1743
|
+
var buffer = "";
|
|
1744
|
+
var token, symbol, value;
|
|
1745
|
+
for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
|
|
1746
|
+
value = void 0;
|
|
1747
|
+
token = tokens[i];
|
|
1748
|
+
symbol = token[0];
|
|
1749
|
+
if (symbol === "#") value = this.renderSection(token, context, partials, originalTemplate, config);
|
|
1750
|
+
else if (symbol === "^") value = this.renderInverted(token, context, partials, originalTemplate, config);
|
|
1751
|
+
else if (symbol === ">") value = this.renderPartial(token, context, partials, config);
|
|
1752
|
+
else if (symbol === "&") value = this.unescapedValue(token, context);
|
|
1753
|
+
else if (symbol === "name") value = this.escapedValue(token, context, config);
|
|
1754
|
+
else if (symbol === "text") value = this.rawValue(token);
|
|
1755
|
+
if (value !== void 0) buffer += value;
|
|
1756
|
+
}
|
|
1757
|
+
return buffer;
|
|
1758
|
+
};
|
|
1759
|
+
Writer.prototype.renderSection = function renderSection(token, context, partials, originalTemplate, config) {
|
|
1760
|
+
var self = this;
|
|
1761
|
+
var buffer = "";
|
|
1762
|
+
var value = context.lookup(token[1]);
|
|
1763
|
+
function subRender(template) {
|
|
1764
|
+
return self.render(template, context, partials, config);
|
|
1765
|
+
}
|
|
1766
|
+
if (!value) return;
|
|
1767
|
+
if (isArray(value)) {
|
|
1768
|
+
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
|
|
1769
|
+
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
|
|
1770
|
+
}
|
|
1771
|
+
} else if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
|
|
1772
|
+
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
|
|
1773
|
+
} else if (isFunction(value)) {
|
|
1774
|
+
if (typeof originalTemplate !== "string") throw new Error("Cannot use higher-order sections without the original template");
|
|
1775
|
+
value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
|
|
1776
|
+
if (value != null) buffer += value;
|
|
1777
|
+
} else {
|
|
1778
|
+
buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
1779
|
+
}
|
|
1780
|
+
return buffer;
|
|
1781
|
+
};
|
|
1782
|
+
Writer.prototype.renderInverted = function renderInverted(token, context, partials, originalTemplate, config) {
|
|
1783
|
+
var value = context.lookup(token[1]);
|
|
1784
|
+
if (!value || isArray(value) && value.length === 0) return this.renderTokens(token[4], context, partials, originalTemplate, config);
|
|
1785
|
+
};
|
|
1786
|
+
Writer.prototype.indentPartial = function indentPartial(partial, indentation, lineHasNonSpace) {
|
|
1787
|
+
var filteredIndentation = indentation.replace(/[^ \t]/g, "");
|
|
1788
|
+
var partialByNl = partial.split("\n");
|
|
1789
|
+
for (var i = 0; i < partialByNl.length; i++) {
|
|
1790
|
+
if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
|
|
1791
|
+
partialByNl[i] = filteredIndentation + partialByNl[i];
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
return partialByNl.join("\n");
|
|
1795
|
+
};
|
|
1796
|
+
Writer.prototype.renderPartial = function renderPartial(token, context, partials, config) {
|
|
1797
|
+
if (!partials) return;
|
|
1798
|
+
var tags = this.getConfigTags(config);
|
|
1799
|
+
var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
|
|
1800
|
+
if (value != null) {
|
|
1801
|
+
var lineHasNonSpace = token[6];
|
|
1802
|
+
var tagIndex = token[5];
|
|
1803
|
+
var indentation = token[4];
|
|
1804
|
+
var indentedValue = value;
|
|
1805
|
+
if (tagIndex == 0 && indentation) {
|
|
1806
|
+
indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
|
|
1807
|
+
}
|
|
1808
|
+
var tokens = this.parse(indentedValue, tags);
|
|
1809
|
+
return this.renderTokens(tokens, context, partials, indentedValue, config);
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
Writer.prototype.unescapedValue = function unescapedValue(token, context) {
|
|
1813
|
+
var value = context.lookup(token[1]);
|
|
1814
|
+
if (value != null) return value;
|
|
1815
|
+
};
|
|
1816
|
+
Writer.prototype.escapedValue = function escapedValue(token, context, config) {
|
|
1817
|
+
var escape = this.getConfigEscape(config) || mustache.escape;
|
|
1818
|
+
var value = context.lookup(token[1]);
|
|
1819
|
+
if (value != null) return typeof value === "number" && escape === mustache.escape ? String(value) : escape(value);
|
|
1820
|
+
};
|
|
1821
|
+
Writer.prototype.rawValue = function rawValue(token) {
|
|
1822
|
+
return token[1];
|
|
1823
|
+
};
|
|
1824
|
+
Writer.prototype.getConfigTags = function getConfigTags(config) {
|
|
1825
|
+
if (isArray(config)) {
|
|
1826
|
+
return config;
|
|
1827
|
+
} else if (config && typeof config === "object") {
|
|
1828
|
+
return config.tags;
|
|
1829
|
+
} else {
|
|
1830
|
+
return void 0;
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
Writer.prototype.getConfigEscape = function getConfigEscape(config) {
|
|
1834
|
+
if (config && typeof config === "object" && !isArray(config)) {
|
|
1835
|
+
return config.escape;
|
|
1836
|
+
} else {
|
|
1837
|
+
return void 0;
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1840
|
+
var mustache = {
|
|
1841
|
+
name: "mustache.js",
|
|
1842
|
+
version: "4.2.0",
|
|
1843
|
+
tags: ["{{", "}}"],
|
|
1844
|
+
clearCache: void 0,
|
|
1845
|
+
escape: void 0,
|
|
1846
|
+
parse: void 0,
|
|
1847
|
+
render: void 0,
|
|
1848
|
+
Scanner: void 0,
|
|
1849
|
+
Context: void 0,
|
|
1850
|
+
Writer: void 0,
|
|
1851
|
+
/**
|
|
1852
|
+
* Allows a user to override the default caching strategy, by providing an
|
|
1853
|
+
* object with set, get and clear methods. This can also be used to disable
|
|
1854
|
+
* the cache by setting it to the literal `undefined`.
|
|
1855
|
+
*/
|
|
1856
|
+
set templateCache(cache) {
|
|
1857
|
+
defaultWriter.templateCache = cache;
|
|
1858
|
+
},
|
|
1859
|
+
/**
|
|
1860
|
+
* Gets the default or overridden caching object from the default writer.
|
|
1861
|
+
*/
|
|
1862
|
+
get templateCache() {
|
|
1863
|
+
return defaultWriter.templateCache;
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
var defaultWriter = new Writer();
|
|
1867
|
+
mustache.clearCache = function clearCache2() {
|
|
1868
|
+
return defaultWriter.clearCache();
|
|
1869
|
+
};
|
|
1870
|
+
mustache.parse = function parse2(template, tags) {
|
|
1871
|
+
return defaultWriter.parse(template, tags);
|
|
1872
|
+
};
|
|
1873
|
+
mustache.render = function render2(template, view, partials, config) {
|
|
1874
|
+
if (typeof template !== "string") {
|
|
1875
|
+
throw new TypeError('Invalid template! Template should be a "string" but "' + typeStr(template) + '" was given as the first argument for mustache#render(template, view, partials)');
|
|
1876
|
+
}
|
|
1877
|
+
return defaultWriter.render(template, view, partials, config);
|
|
1878
|
+
};
|
|
1879
|
+
mustache.escape = escapeHtml;
|
|
1880
|
+
mustache.Scanner = Scanner;
|
|
1881
|
+
mustache.Context = Context;
|
|
1882
|
+
mustache.Writer = Writer;
|
|
1883
|
+
var mustache_default = mustache;
|
|
1884
|
+
|
|
1885
|
+
// src/api/code-snippets/snippetTypes.ts
|
|
1886
|
+
var interfaceSnippets = /* @__PURE__ */ (function(interfaceSnippets2) {
|
|
1887
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfacesReference"] = 0] = "loadInterfacesReference";
|
|
1888
|
+
interfaceSnippets2[interfaceSnippets2["loadAllInterfacesReference"] = 1] = "loadAllInterfacesReference";
|
|
1889
|
+
interfaceSnippets2[interfaceSnippets2["loadOrderedInterfacesReference"] = 2] = "loadOrderedInterfacesReference";
|
|
1890
|
+
interfaceSnippets2[interfaceSnippets2["searchInterfacesReference"] = 3] = "searchInterfacesReference";
|
|
1891
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfaceMetadataSnippet"] = 4] = "loadInterfaceMetadataSnippet";
|
|
1892
|
+
interfaceSnippets2[interfaceSnippets2["subscribeToObjectSetInstructions"] = 5] = "subscribeToObjectSetInstructions";
|
|
1893
|
+
return interfaceSnippets2;
|
|
1894
|
+
})({});
|
|
1895
|
+
var actionSnippets = /* @__PURE__ */ (function(actionSnippets2) {
|
|
1896
|
+
actionSnippets2[actionSnippets2["applyAction"] = 0] = "applyAction";
|
|
1897
|
+
actionSnippets2[actionSnippets2["batchApplyAction"] = 1] = "batchApplyAction";
|
|
1898
|
+
return actionSnippets2;
|
|
1899
|
+
})({});
|
|
1900
|
+
var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
|
|
1901
|
+
objectSnippets2[objectSnippets2["loadSingleObjectGuide"] = 0] = "loadSingleObjectGuide";
|
|
1902
|
+
objectSnippets2[objectSnippets2["loadObjectsReference"] = 1] = "loadObjectsReference";
|
|
1903
|
+
objectSnippets2[objectSnippets2["loadAllObjectsReference"] = 2] = "loadAllObjectsReference";
|
|
1904
|
+
objectSnippets2[objectSnippets2["loadOrderedInterfacesReference"] = 3] = "loadOrderedInterfacesReference";
|
|
1905
|
+
objectSnippets2[objectSnippets2["searchObjectsGuide"] = 4] = "searchObjectsGuide";
|
|
1906
|
+
objectSnippets2[objectSnippets2["aggregationTemplate"] = 5] = "aggregationTemplate";
|
|
1907
|
+
objectSnippets2[objectSnippets2["objectSetOperationsGuide"] = 6] = "objectSetOperationsGuide";
|
|
1908
|
+
objectSnippets2[objectSnippets2["loadObjectMetadataSnippet"] = 7] = "loadObjectMetadataSnippet";
|
|
1909
|
+
objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
|
|
1910
|
+
return objectSnippets2;
|
|
1911
|
+
})({});
|
|
1912
|
+
|
|
1913
|
+
// src/api/code-snippets/createCodeSnippets.ts
|
|
1914
|
+
function createCodeSnippets(ontology, packageName, outputDir) {
|
|
1915
|
+
if (outputDir === void 0) {
|
|
1916
|
+
outputDir = "./code-snippets";
|
|
1917
|
+
}
|
|
1918
|
+
if (!fs2__namespace.existsSync(outputDir)) {
|
|
1919
|
+
fs2__namespace.mkdirSync(outputDir, {
|
|
1920
|
+
recursive: true
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
if (packageName === void 0) {
|
|
1924
|
+
packageName = "";
|
|
1925
|
+
}
|
|
1926
|
+
consola.consola.info("Generating code snippets to ", outputDir);
|
|
1927
|
+
for (const type of Object.values(OntologyEntityTypeEnum)) {
|
|
1928
|
+
for (const object of Object.values(ontology[type])) {
|
|
1929
|
+
let snippet = {};
|
|
1930
|
+
switch (type) {
|
|
1931
|
+
case OntologyEntityTypeEnum.OBJECT_TYPE:
|
|
1932
|
+
snippet = generateObjectSnippet(object, packageName);
|
|
1933
|
+
break;
|
|
1934
|
+
case OntologyEntityTypeEnum.ACTION_TYPE:
|
|
1935
|
+
snippet = generateActionSnippet(object, packageName);
|
|
1936
|
+
break;
|
|
1937
|
+
case OntologyEntityTypeEnum.INTERFACE_TYPE:
|
|
1938
|
+
snippet = generateInterfaceSnippet(object, packageName);
|
|
1939
|
+
break;
|
|
1940
|
+
default:
|
|
1941
|
+
continue;
|
|
1942
|
+
}
|
|
1943
|
+
fs2__namespace.writeFileSync(path3__namespace.join(outputDir, object.apiName), JSON.stringify(snippet));
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
consola.consola.info("Finished Code Snippet Generation");
|
|
1947
|
+
}
|
|
1948
|
+
function generateInterfaceSnippet(interfaceType, packageName) {
|
|
1949
|
+
const interfaceContext = {
|
|
1950
|
+
"interfaceApiName": interfaceType.apiName,
|
|
1951
|
+
"packageName": packageName,
|
|
1952
|
+
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1953
|
+
"propertyNames": Object.keys(interfaceType.propertiesV2)
|
|
1954
|
+
};
|
|
1955
|
+
return getSnippets(interfaceSnippets, interfaceContext);
|
|
1956
|
+
}
|
|
1957
|
+
function generateObjectSnippet(objectType, packageName) {
|
|
1958
|
+
const objectContext = {
|
|
1959
|
+
"objectType": objectType.apiName,
|
|
1960
|
+
"packageName": packageName,
|
|
1961
|
+
"objectOrInterfaceApiName": objectType.apiName
|
|
1962
|
+
};
|
|
1963
|
+
return getSnippets(objectSnippets, objectContext);
|
|
1964
|
+
}
|
|
1965
|
+
function generateActionSnippet(actionType, packageName) {
|
|
1966
|
+
const actionContext = {
|
|
1967
|
+
"actionApiName": actionType.apiName,
|
|
1968
|
+
"packageName": packageName
|
|
1969
|
+
};
|
|
1970
|
+
return getSnippets(actionSnippets, actionContext);
|
|
1971
|
+
}
|
|
1972
|
+
function getSnippets(snippetType, context) {
|
|
1973
|
+
const allSnippets = {};
|
|
1974
|
+
for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
|
|
1975
|
+
const latestTemplate = Object.values(typescriptSdkDocs.TYPESCRIPT_OSDK_SNIPPETS.versions).find((v) => v.snippets[templateName])?.snippets[templateName][0].template ?? "";
|
|
1976
|
+
const renderedTemplate = mustache_default.render(latestTemplate, context);
|
|
1977
|
+
allSnippets[templateName] = renderedTemplate;
|
|
1978
|
+
}
|
|
1979
|
+
return allSnippets;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1982
|
+
// src/api/defineOntology.ts
|
|
1983
|
+
var ontologyDefinition;
|
|
1245
1984
|
var importedTypes;
|
|
1246
1985
|
var dependencies;
|
|
1247
1986
|
var namespace;
|
|
@@ -1255,7 +1994,7 @@ function updateOntology(entity) {
|
|
|
1255
1994
|
}
|
|
1256
1995
|
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1257
1996
|
}
|
|
1258
|
-
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1997
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, codeSnippetFiles, snippetPackageName, snippetFileOutputDir, randomnessKey) {
|
|
1259
1998
|
namespace = ns;
|
|
1260
1999
|
dependencies = {};
|
|
1261
2000
|
ontologyDefinition = {
|
|
@@ -1286,10 +2025,13 @@ async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey
|
|
|
1286
2025
|
if (dependencyFile) {
|
|
1287
2026
|
writeDependencyFile(dependencyFile);
|
|
1288
2027
|
}
|
|
2028
|
+
if (codeSnippetFiles) {
|
|
2029
|
+
createCodeSnippets(ontologyDefinition, snippetPackageName, snippetFileOutputDir);
|
|
2030
|
+
}
|
|
1289
2031
|
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1290
2032
|
}
|
|
1291
2033
|
function writeStaticObjects(outputDir) {
|
|
1292
|
-
const codegenDir =
|
|
2034
|
+
const codegenDir = path3__namespace.resolve(outputDir, "codegen");
|
|
1293
2035
|
const typeDirs = {
|
|
1294
2036
|
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1295
2037
|
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
@@ -1298,31 +2040,31 @@ function writeStaticObjects(outputDir) {
|
|
|
1298
2040
|
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1299
2041
|
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1300
2042
|
};
|
|
1301
|
-
if (!
|
|
1302
|
-
|
|
2043
|
+
if (!fs2__namespace.existsSync(codegenDir)) {
|
|
2044
|
+
fs2__namespace.mkdirSync(codegenDir, {
|
|
1303
2045
|
recursive: true
|
|
1304
2046
|
});
|
|
1305
2047
|
}
|
|
1306
2048
|
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1307
|
-
const currentTypeDirPath =
|
|
1308
|
-
if (
|
|
1309
|
-
|
|
2049
|
+
const currentTypeDirPath = path3__namespace.join(codegenDir, typeDirNameFromMap);
|
|
2050
|
+
if (fs2__namespace.existsSync(currentTypeDirPath)) {
|
|
2051
|
+
fs2__namespace.rmSync(currentTypeDirPath, {
|
|
1310
2052
|
recursive: true,
|
|
1311
2053
|
force: true
|
|
1312
2054
|
});
|
|
1313
2055
|
}
|
|
1314
|
-
|
|
2056
|
+
fs2__namespace.mkdirSync(currentTypeDirPath, {
|
|
1315
2057
|
recursive: true
|
|
1316
2058
|
});
|
|
1317
2059
|
});
|
|
1318
2060
|
const topLevelExportStatements = [];
|
|
1319
2061
|
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1320
2062
|
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1321
|
-
const typeDirPath =
|
|
2063
|
+
const typeDirPath = path3__namespace.join(codegenDir, typeDirName);
|
|
1322
2064
|
const entityModuleNames = [];
|
|
1323
2065
|
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1324
2066
|
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1325
|
-
const filePath =
|
|
2067
|
+
const filePath = path3__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1326
2068
|
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1327
2069
|
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1328
2070
|
const content = `
|
|
@@ -1334,7 +2076,7 @@ const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey ===
|
|
|
1334
2076
|
|
|
1335
2077
|
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1336
2078
|
`;
|
|
1337
|
-
|
|
2079
|
+
fs2__namespace.writeFileSync(filePath, content, {
|
|
1338
2080
|
flag: "w"
|
|
1339
2081
|
});
|
|
1340
2082
|
entityModuleNames.push(entityFileNameBase);
|
|
@@ -1345,8 +2087,8 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
|
|
|
1345
2087
|
});
|
|
1346
2088
|
if (topLevelExportStatements.length > 0) {
|
|
1347
2089
|
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1348
|
-
const mainIndexFilePath =
|
|
1349
|
-
|
|
2090
|
+
const mainIndexFilePath = path3__namespace.join(outputDir, "index.ts");
|
|
2091
|
+
fs2__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1350
2092
|
flag: "w"
|
|
1351
2093
|
});
|
|
1352
2094
|
}
|
|
@@ -1702,7 +2444,7 @@ function getEntityTypeName(type) {
|
|
|
1702
2444
|
}[type];
|
|
1703
2445
|
}
|
|
1704
2446
|
function writeDependencyFile(dependencyFile) {
|
|
1705
|
-
|
|
2447
|
+
fs2__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
|
|
1706
2448
|
}
|
|
1707
2449
|
function dependencyInjectionString() {
|
|
1708
2450
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
@@ -1719,20 +2461,20 @@ function addNamespaceIfNone(apiName) {
|
|
|
1719
2461
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1720
2462
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1721
2463
|
async function main(args = process.argv) {
|
|
1722
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.
|
|
2464
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.10").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1723
2465
|
input: {
|
|
1724
2466
|
alias: "i",
|
|
1725
2467
|
describe: "Input file",
|
|
1726
2468
|
type: "string",
|
|
1727
2469
|
default: ".ontology/ontology.ts",
|
|
1728
|
-
coerce:
|
|
2470
|
+
coerce: path3__namespace.resolve
|
|
1729
2471
|
},
|
|
1730
2472
|
output: {
|
|
1731
2473
|
alias: "o",
|
|
1732
2474
|
describe: "Output file",
|
|
1733
2475
|
type: "string",
|
|
1734
2476
|
default: "ontology.json",
|
|
1735
|
-
coerce:
|
|
2477
|
+
coerce: path3__namespace.resolve
|
|
1736
2478
|
},
|
|
1737
2479
|
apiNamespace: {
|
|
1738
2480
|
describe: "Api name prefix for namespaced ontology types",
|
|
@@ -1744,95 +2486,91 @@ async function main(args = process.argv) {
|
|
|
1744
2486
|
describe: "Snapshot directory",
|
|
1745
2487
|
type: "string",
|
|
1746
2488
|
default: "snapshots",
|
|
1747
|
-
coerce:
|
|
2489
|
+
coerce: path3__namespace.resolve
|
|
1748
2490
|
},
|
|
1749
2491
|
outputDir: {
|
|
1750
2492
|
alias: "d",
|
|
1751
2493
|
describe: "Directory for generated ontology entities",
|
|
1752
2494
|
type: "string",
|
|
1753
|
-
coerce:
|
|
2495
|
+
coerce: path3__namespace.resolve
|
|
1754
2496
|
},
|
|
1755
2497
|
valueTypesOutput: {
|
|
1756
2498
|
describe: "Value Type Output File",
|
|
1757
2499
|
type: "string",
|
|
1758
2500
|
default: "value-types.json",
|
|
1759
|
-
coerce:
|
|
2501
|
+
coerce: path3__namespace.resolve
|
|
1760
2502
|
},
|
|
1761
2503
|
dependencies: {
|
|
1762
2504
|
describe: "File to write dependencies to",
|
|
1763
2505
|
type: "string",
|
|
1764
|
-
coerce:
|
|
2506
|
+
coerce: path3__namespace.resolve
|
|
2507
|
+
},
|
|
2508
|
+
generateCodeSnippets: {
|
|
2509
|
+
describe: "Enable code snippet files creation",
|
|
2510
|
+
type: "boolean",
|
|
2511
|
+
default: false
|
|
2512
|
+
},
|
|
2513
|
+
codeSnippetPackageName: {
|
|
2514
|
+
describe: "The package name that will be displayed in the code snippets",
|
|
2515
|
+
default: "",
|
|
2516
|
+
type: "string"
|
|
2517
|
+
},
|
|
2518
|
+
codeSnippetDir: {
|
|
2519
|
+
describe: "Directory for generated code snippet files",
|
|
2520
|
+
type: "string",
|
|
2521
|
+
default: "./",
|
|
2522
|
+
coerce: path3__namespace.resolve
|
|
1765
2523
|
},
|
|
1766
2524
|
randomnessKey: {
|
|
1767
2525
|
describe: "Value used to assure uniqueness of entities",
|
|
1768
2526
|
type: "string",
|
|
1769
|
-
coerce:
|
|
2527
|
+
coerce: path3__namespace.resolve
|
|
1770
2528
|
}
|
|
1771
2529
|
}).parseAsync();
|
|
1772
2530
|
let apiNamespace = "";
|
|
1773
2531
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1774
2532
|
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" ?
|
|
2533
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is too long.") : invariant7__default.default(false) : void 0;
|
|
2534
|
+
!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
2535
|
}
|
|
1778
2536
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2537
|
+
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2538
|
+
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2539
|
+
}
|
|
1779
2540
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1780
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
2541
|
+
!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
2542
|
}
|
|
1782
|
-
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
2543
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
1783
2544
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1784
|
-
await
|
|
2545
|
+
await fs3__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1785
2546
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1786
|
-
await
|
|
2547
|
+
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1787
2548
|
}
|
|
1788
2549
|
}
|
|
1789
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
|
|
1790
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
2550
|
+
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2551
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
1791
2552
|
return q;
|
|
1792
2553
|
}
|
|
1793
2554
|
var MAX_SEARCH_DEPTH = 5;
|
|
1794
2555
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
1795
|
-
let dir =
|
|
2556
|
+
let dir = path3__namespace.dirname(fileInPackage);
|
|
1796
2557
|
let packageJsonPath = null;
|
|
1797
2558
|
for (let i = 0; i < MAX_SEARCH_DEPTH; i++) {
|
|
1798
|
-
const candidate =
|
|
1799
|
-
if (
|
|
2559
|
+
const candidate = path3__namespace.join(dir, "package.json");
|
|
2560
|
+
if (fs2__namespace.existsSync(candidate)) {
|
|
1800
2561
|
packageJsonPath = candidate;
|
|
1801
2562
|
break;
|
|
1802
2563
|
}
|
|
1803
|
-
const parentDir =
|
|
2564
|
+
const parentDir = path3__namespace.dirname(dir);
|
|
1804
2565
|
if (parentDir === dir) break;
|
|
1805
2566
|
dir = parentDir;
|
|
1806
2567
|
}
|
|
1807
2568
|
if (!packageJsonPath) {
|
|
1808
2569
|
throw new Error(`Could not find a package.json within ${MAX_SEARCH_DEPTH} parent directories of ${fileInPackage}`);
|
|
1809
2570
|
}
|
|
1810
|
-
const packageJson = JSON.parse(
|
|
2571
|
+
const packageJson = JSON.parse(fs2__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1811
2572
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1812
2573
|
}
|
|
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
2574
|
|
|
1837
2575
|
// src/api/action/ActionParameterType.ts
|
|
1838
2576
|
function isActionParameterTypePrimitive(type) {
|
|
@@ -1842,472 +2580,125 @@ function isActionParameterTypePrimitive(type) {
|
|
|
1842
2580
|
// src/api/defineAction.ts
|
|
1843
2581
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1844
2582
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
2583
|
+
var CREATE_INTERFACE_OBJECT_PARAMETER = "objectTypeParameter";
|
|
2584
|
+
var MODIFY_INTERFACE_OBJECT_PARAMETER = "interfaceObjectToModifyParameter";
|
|
2585
|
+
function defineAction(actionDef) {
|
|
2586
|
+
const apiName = namespace + actionDef.apiName;
|
|
2587
|
+
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
2588
|
+
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2589
|
+
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
1849
2590
|
}
|
|
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],
|
|
2591
|
+
!/^[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;
|
|
2592
|
+
const parameterIdsSet = new Set(parameterIds);
|
|
2593
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter ids must be unique`) : invariant7__default.default(false) : void 0;
|
|
2594
|
+
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2595
|
+
!(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;
|
|
2596
|
+
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2597
|
+
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2598
|
+
!(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;
|
|
2599
|
+
!(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;
|
|
2600
|
+
actionDef.rules.forEach((rule) => {
|
|
2601
|
+
if (rule.type === "modifyObjectRule") {
|
|
2602
|
+
!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;
|
|
2603
|
+
}
|
|
2604
|
+
if (rule.type === "deleteObjectRule") {
|
|
2605
|
+
!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;
|
|
2606
|
+
}
|
|
2607
|
+
if (rule.type === "modifyInterfaceRule") {
|
|
2608
|
+
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2609
|
+
!(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;
|
|
2610
|
+
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2611
|
+
!(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;
|
|
2612
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2613
|
+
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2614
|
+
!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;
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
if (rule.type === "addInterfaceRule") {
|
|
2618
|
+
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2619
|
+
!(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;
|
|
2620
|
+
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2621
|
+
!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;
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2625
|
+
const fullAction = {
|
|
2626
|
+
...actionDef,
|
|
2627
|
+
apiName,
|
|
2628
|
+
entities: actionDef.entities ?? {
|
|
2629
|
+
affectedInterfaceTypes: [],
|
|
1895
2630
|
affectedObjectTypes: [],
|
|
1896
2631
|
affectedLinkTypes: [],
|
|
1897
2632
|
typeGroups: []
|
|
1898
2633
|
},
|
|
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
|
-
});
|
|
2634
|
+
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2635
|
+
};
|
|
2636
|
+
validateActionConfiguration(fullAction);
|
|
2637
|
+
updateOntology(fullAction);
|
|
2638
|
+
return fullAction;
|
|
1914
2639
|
}
|
|
1915
|
-
function
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
typeGroups: []
|
|
2640
|
+
function isPropertyParameter(def, name, type) {
|
|
2641
|
+
return !Object.keys(def.nonParameterMappings ?? {}).includes(name) && !isStruct(type) && !def.excludedProperties?.includes(name);
|
|
2642
|
+
}
|
|
2643
|
+
function createParameters(def, propertyMap, parameterSet, requiredMap) {
|
|
2644
|
+
const targetParams = getTargetParameters(def, parameterSet);
|
|
2645
|
+
return [...targetParams, ...Array.from(parameterSet).map((id) => ({
|
|
2646
|
+
id,
|
|
2647
|
+
displayName: def.parameterConfiguration?.[id]?.displayName ?? propertyMap[id]?.displayName ?? uppercaseFirstLetter(id),
|
|
2648
|
+
type: def.parameterConfiguration?.[id]?.customParameterType ?? extractActionParameterType(propertyMap[id]),
|
|
2649
|
+
validation: def.parameterConfiguration?.[id] !== void 0 ? {
|
|
2650
|
+
...def.parameterConfiguration?.[id],
|
|
2651
|
+
allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(propertyMap[id]?.type)),
|
|
2652
|
+
required: def.parameterConfiguration?.[id].required ?? propertyMap[id]?.nullability?.noNulls ?? false
|
|
2653
|
+
} : {
|
|
2654
|
+
required: propertyMap[id]?.array ?? false ? {
|
|
2655
|
+
listLength: propertyMap[id]?.nullability?.noEmptyCollections ? {
|
|
2656
|
+
min: 1
|
|
2657
|
+
} : {}
|
|
2658
|
+
} : requiredMap?.[id] ?? propertyMap[id]?.nullability?.noNulls ?? false,
|
|
2659
|
+
allowedValues: extractAllowedValuesFromPropertyType(propertyMap[id]?.type)
|
|
1936
2660
|
},
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
2661
|
+
defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
|
|
2662
|
+
description: def.parameterConfiguration?.[id]?.description
|
|
2663
|
+
}))];
|
|
2664
|
+
}
|
|
2665
|
+
function getTargetParameters(def, parameterSet) {
|
|
2666
|
+
const targetParams = [];
|
|
2667
|
+
parameterSet.forEach((name) => {
|
|
2668
|
+
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2669
|
+
targetParams.push({
|
|
2670
|
+
id: MODIFY_OBJECT_PARAMETER,
|
|
2671
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2672
|
+
type: {
|
|
2673
|
+
type: "objectReference",
|
|
2674
|
+
objectReference: {
|
|
2675
|
+
objectTypeId: def.objectType.apiName
|
|
2676
|
+
}
|
|
1947
2677
|
},
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
1960
|
-
},
|
|
1961
|
-
...def.displayAndFormat && {
|
|
1962
|
-
displayAndFormat: def.displayAndFormat
|
|
1963
|
-
},
|
|
1964
|
-
...def.sections && {
|
|
1965
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
1966
|
-
},
|
|
1967
|
-
...def.submissionMetadata && {
|
|
1968
|
-
submissionMetadata: def.submissionMetadata
|
|
1969
|
-
}
|
|
1970
|
-
});
|
|
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);
|
|
2678
|
+
validation: {
|
|
2679
|
+
...def.parameterConfiguration?.[name],
|
|
2680
|
+
allowedValues: {
|
|
2681
|
+
type: "objectQuery"
|
|
2682
|
+
},
|
|
2683
|
+
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2684
|
+
},
|
|
2685
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2686
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2687
|
+
});
|
|
2688
|
+
parameterSet.delete(MODIFY_OBJECT_PARAMETER);
|
|
2301
2689
|
}
|
|
2302
2690
|
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2303
|
-
|
|
2691
|
+
targetParams.push({
|
|
2304
2692
|
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2305
2693
|
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2306
2694
|
type: {
|
|
2307
2695
|
type: "objectReference",
|
|
2308
2696
|
objectReference: {
|
|
2309
2697
|
objectTypeId: def.objectType.apiName,
|
|
2310
|
-
maybeCreateObjectOption: !
|
|
2698
|
+
maybeCreateObjectOption: !("primaryKeyOption" in def) ? {
|
|
2699
|
+
type: "autoGenerated",
|
|
2700
|
+
autoGenerated: {}
|
|
2701
|
+
} : def.primaryKeyOption === "autoGenerated" ? {
|
|
2311
2702
|
type: "autoGenerated",
|
|
2312
2703
|
autoGenerated: {}
|
|
2313
2704
|
} : {
|
|
@@ -2328,26 +2719,75 @@ function createParameters(def, parameterSet) {
|
|
|
2328
2719
|
});
|
|
2329
2720
|
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2330
2721
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2722
|
+
if (name === CREATE_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
2723
|
+
targetParams.push({
|
|
2724
|
+
id: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2725
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to create",
|
|
2726
|
+
type: {
|
|
2727
|
+
type: "objectTypeReference",
|
|
2728
|
+
objectTypeReference: {
|
|
2729
|
+
interfaceTypeRids: [def.interfaceType.apiName]
|
|
2730
|
+
}
|
|
2731
|
+
},
|
|
2732
|
+
validation: {
|
|
2733
|
+
...def.parameterConfiguration?.[name],
|
|
2734
|
+
required: true,
|
|
2735
|
+
allowedValues: def.objectType === void 0 ? {
|
|
2736
|
+
type: "objectTypeReference",
|
|
2737
|
+
interfaceTypes: [def.interfaceType.apiName]
|
|
2738
|
+
} : {
|
|
2739
|
+
type: "oneOf",
|
|
2740
|
+
oneOf: [{
|
|
2741
|
+
label: def.objectType.displayName,
|
|
2742
|
+
value: {
|
|
2743
|
+
type: "objectType",
|
|
2744
|
+
objectType: {
|
|
2745
|
+
objectTypeId: def.objectType.apiName
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
}]
|
|
2749
|
+
}
|
|
2750
|
+
},
|
|
2751
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2752
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2753
|
+
});
|
|
2754
|
+
parameterSet.delete(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2755
|
+
}
|
|
2756
|
+
if (name === MODIFY_INTERFACE_OBJECT_PARAMETER && "interfaceType" in def) {
|
|
2757
|
+
targetParams.push({
|
|
2758
|
+
id: MODIFY_INTERFACE_OBJECT_PARAMETER,
|
|
2759
|
+
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Object type to modify",
|
|
2760
|
+
type: {
|
|
2761
|
+
type: "interfaceReference",
|
|
2762
|
+
interfaceReference: {
|
|
2763
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
2764
|
+
}
|
|
2765
|
+
},
|
|
2766
|
+
validation: {
|
|
2767
|
+
...def.parameterConfiguration?.[name],
|
|
2768
|
+
required: true,
|
|
2769
|
+
allowedValues: def.objectType === void 0 ? {
|
|
2770
|
+
type: "interfaceObjectQuery"
|
|
2771
|
+
} : {
|
|
2772
|
+
type: "oneOf",
|
|
2773
|
+
oneOf: [{
|
|
2774
|
+
label: def.objectType.displayName,
|
|
2775
|
+
value: {
|
|
2776
|
+
type: "objectType",
|
|
2777
|
+
objectType: {
|
|
2778
|
+
objectTypeId: def.objectType.apiName
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
}]
|
|
2782
|
+
}
|
|
2783
|
+
},
|
|
2784
|
+
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2785
|
+
description: def.parameterConfiguration?.[name]?.description
|
|
2786
|
+
});
|
|
2787
|
+
parameterSet.delete(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
return targetParams;
|
|
2351
2791
|
}
|
|
2352
2792
|
function referencedParameterIds(actionDef) {
|
|
2353
2793
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2612,104 +3052,425 @@ function kebab(s) {
|
|
|
2612
3052
|
function sanitize(s) {
|
|
2613
3053
|
return s.includes(".") ? s : namespace + s;
|
|
2614
3054
|
}
|
|
2615
|
-
function convertValidationRule(actionValidation,
|
|
3055
|
+
function convertValidationRule(actionValidation, actionParameters) {
|
|
2616
3056
|
return actionValidation.map((rule) => {
|
|
2617
3057
|
return {
|
|
2618
|
-
condition: convertConditionDefinition(rule.condition,
|
|
3058
|
+
condition: convertConditionDefinition(rule.condition, actionParameters),
|
|
2619
3059
|
displayMetadata: rule.displayMetadata ?? {
|
|
2620
3060
|
failureMessage: "Did not satisfy validation",
|
|
2621
3061
|
typeClasses: []
|
|
2622
3062
|
}
|
|
2623
|
-
};
|
|
3063
|
+
};
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
3066
|
+
function validateActionConfiguration(action) {
|
|
3067
|
+
const seenParameterIds = /* @__PURE__ */ new Set();
|
|
3068
|
+
const parameterMap = action.parameters?.reduce((acc, param) => {
|
|
3069
|
+
acc[param.id] = param;
|
|
3070
|
+
return acc;
|
|
3071
|
+
}, {}) ?? {};
|
|
3072
|
+
const orderedParameters = action.parameterOrdering?.map((id) => parameterMap[id]) ?? action.parameters;
|
|
3073
|
+
orderedParameters?.forEach((param) => {
|
|
3074
|
+
param.validation.conditionalOverrides?.forEach((override) => {
|
|
3075
|
+
validateParameterCondition(override.condition, param.id, seenParameterIds, action.parameters);
|
|
3076
|
+
});
|
|
3077
|
+
validateParameterPrefill(param.id, seenParameterIds, action.parameters, param.defaultValue);
|
|
3078
|
+
seenParameterIds.add(param.id);
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
function validateParameterCondition(condition, currentParameterId, seenParameterIds, parameters) {
|
|
3082
|
+
switch (condition.type) {
|
|
3083
|
+
case "parameter":
|
|
3084
|
+
const overrideParamId = condition.parameterId;
|
|
3085
|
+
!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;
|
|
3086
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant7__default.default(false) : void 0;
|
|
3087
|
+
!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;
|
|
3088
|
+
break;
|
|
3089
|
+
case "and":
|
|
3090
|
+
if ("conditions" in condition) {
|
|
3091
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
3092
|
+
}
|
|
3093
|
+
break;
|
|
3094
|
+
case "or":
|
|
3095
|
+
if ("conditions" in condition) {
|
|
3096
|
+
condition.conditions.forEach((c) => validateParameterCondition(c, currentParameterId, seenParameterIds, parameters));
|
|
3097
|
+
}
|
|
3098
|
+
break;
|
|
3099
|
+
case "comparison":
|
|
3100
|
+
case "group":
|
|
3101
|
+
case "not":
|
|
3102
|
+
case "markings":
|
|
3103
|
+
case "regex":
|
|
3104
|
+
case "redacted":
|
|
3105
|
+
case "true":
|
|
3106
|
+
break;
|
|
3107
|
+
default:
|
|
3108
|
+
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
3112
|
+
if (!defaultValue) return;
|
|
3113
|
+
switch (defaultValue.type) {
|
|
3114
|
+
case "objectParameterPropertyValue":
|
|
3115
|
+
!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;
|
|
3116
|
+
!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;
|
|
3117
|
+
break;
|
|
3118
|
+
case "staticValue":
|
|
3119
|
+
!(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;
|
|
3120
|
+
break;
|
|
3121
|
+
case "staticObject":
|
|
3122
|
+
case "interfaceParameterPropertyValue":
|
|
3123
|
+
case "objectQueryPrefill":
|
|
3124
|
+
case "objectQueryPropertyValue":
|
|
3125
|
+
case "objectSetRidPrefill":
|
|
3126
|
+
case "redacted":
|
|
3127
|
+
break;
|
|
3128
|
+
default:
|
|
3129
|
+
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
function validateActionParameters(def, properties, name) {
|
|
3133
|
+
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
3134
|
+
!(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;
|
|
3135
|
+
});
|
|
3136
|
+
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
3137
|
+
!(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;
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
3141
|
+
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}).filter((id) => id !== priorityId), ...properties.filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
3142
|
+
}
|
|
3143
|
+
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
3144
|
+
const orderingSet = new Set(parameterOrdering);
|
|
3145
|
+
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
3146
|
+
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
3147
|
+
!(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;
|
|
3148
|
+
}
|
|
3149
|
+
function isTargetParameter(parameterId) {
|
|
3150
|
+
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
3151
|
+
}
|
|
3152
|
+
function addNamespaceToActionDefinition(def) {
|
|
3153
|
+
def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [getInterfaceParameterName(def, id), config]));
|
|
3154
|
+
def.nonParameterMappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [addNamespaceIfNone(id), value]));
|
|
3155
|
+
def.excludedProperties = (def.excludedProperties ?? []).map((id) => addNamespaceIfNone(id));
|
|
3156
|
+
def.sections = def.sections?.map((section) => ({
|
|
3157
|
+
...section,
|
|
3158
|
+
parameters: section.parameters.map((p) => getInterfaceParameterName(def, p))
|
|
3159
|
+
}));
|
|
3160
|
+
}
|
|
3161
|
+
function getInterfaceParameterName(def, parameter) {
|
|
3162
|
+
return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
|
|
3163
|
+
}
|
|
3164
|
+
function convertMappingValue(value) {
|
|
3165
|
+
switch (value.type) {
|
|
3166
|
+
case "uuid":
|
|
3167
|
+
return {
|
|
3168
|
+
type: "uniqueIdentifier",
|
|
3169
|
+
uniqueIdentifier: {
|
|
3170
|
+
linkId: value.linkId ?? crypto.randomUUID()
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
case "currentTime":
|
|
3174
|
+
return {
|
|
3175
|
+
type: "currentTime",
|
|
3176
|
+
currentTime: {}
|
|
3177
|
+
};
|
|
3178
|
+
case "currentUser":
|
|
3179
|
+
return {
|
|
3180
|
+
type: "currentUser",
|
|
3181
|
+
currentUser: {}
|
|
3182
|
+
};
|
|
3183
|
+
default:
|
|
3184
|
+
return value;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
// src/api/defineCreateInterfaceObjectAction.ts
|
|
3189
|
+
function defineCreateInterfaceObjectAction(def) {
|
|
3190
|
+
addNamespaceToActionDefinition(def);
|
|
3191
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3192
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3193
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
3194
|
+
const parameterNames = new Set(propertyParameters);
|
|
3195
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3196
|
+
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
3197
|
+
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)}`}`;
|
|
3198
|
+
if (def.parameterOrdering) {
|
|
3199
|
+
if (!def.parameterOrdering.includes(CREATE_INTERFACE_OBJECT_PARAMETER)) {
|
|
3200
|
+
def.parameterOrdering.unshift(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
3201
|
+
}
|
|
3202
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3203
|
+
}
|
|
3204
|
+
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])));
|
|
3205
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3206
|
+
return defineAction({
|
|
3207
|
+
apiName: actionApiName,
|
|
3208
|
+
displayName: def.displayName ?? `Create ${def.interfaceType.displayMetadata.displayName}`,
|
|
3209
|
+
parameters,
|
|
3210
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
3211
|
+
entities: {
|
|
3212
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
3213
|
+
affectedObjectTypes: [],
|
|
3214
|
+
affectedLinkTypes: [],
|
|
3215
|
+
typeGroups: []
|
|
3216
|
+
},
|
|
3217
|
+
rules: [{
|
|
3218
|
+
type: "addInterfaceRule",
|
|
3219
|
+
addInterfaceRule: {
|
|
3220
|
+
interfaceApiName: def.interfaceType.apiName,
|
|
3221
|
+
objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
3222
|
+
sharedPropertyValues: {
|
|
3223
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
3224
|
+
type: "parameterId",
|
|
3225
|
+
parameterId: id
|
|
3226
|
+
}])),
|
|
3227
|
+
...mappings
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
}],
|
|
3231
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
|
|
3232
|
+
...def.actionLevelValidation ? {
|
|
3233
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3234
|
+
} : {},
|
|
3235
|
+
...def.defaultFormat && {
|
|
3236
|
+
defaultFormat: def.defaultFormat
|
|
3237
|
+
},
|
|
3238
|
+
...def.enableLayoutSwitch && {
|
|
3239
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3240
|
+
},
|
|
3241
|
+
...def.tableConfiguration && {
|
|
3242
|
+
displayAndFormat: {
|
|
3243
|
+
table: def.tableConfiguration
|
|
3244
|
+
}
|
|
3245
|
+
},
|
|
3246
|
+
...def.sections && {
|
|
3247
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3248
|
+
},
|
|
3249
|
+
...def.submissionMetadata && {
|
|
3250
|
+
submissionMetadata: def.submissionMetadata
|
|
3251
|
+
}
|
|
3252
|
+
});
|
|
3253
|
+
}
|
|
3254
|
+
|
|
3255
|
+
// src/api/defineCreateObjectAction.ts
|
|
3256
|
+
function defineCreateObjectAction(def) {
|
|
3257
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3258
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3259
|
+
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));
|
|
3260
|
+
const parameterNames = new Set(propertyParameters);
|
|
3261
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3262
|
+
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
3263
|
+
if (def.parameterOrdering) {
|
|
3264
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3265
|
+
}
|
|
3266
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
3267
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3268
|
+
return defineAction({
|
|
3269
|
+
apiName: actionApiName,
|
|
3270
|
+
displayName: def.displayName ?? `Create ${def.objectType.displayName}`,
|
|
3271
|
+
parameters,
|
|
3272
|
+
status: def.status ?? "active",
|
|
3273
|
+
entities: {
|
|
3274
|
+
affectedInterfaceTypes: [],
|
|
3275
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3276
|
+
affectedLinkTypes: [],
|
|
3277
|
+
typeGroups: []
|
|
3278
|
+
},
|
|
3279
|
+
rules: [{
|
|
3280
|
+
type: "addObjectRule",
|
|
3281
|
+
addObjectRule: {
|
|
3282
|
+
objectTypeId: def.objectType.apiName,
|
|
3283
|
+
propertyValues: {
|
|
3284
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
3285
|
+
type: "parameterId",
|
|
3286
|
+
parameterId: p
|
|
3287
|
+
}])),
|
|
3288
|
+
...mappings
|
|
3289
|
+
},
|
|
3290
|
+
structFieldValues: {}
|
|
3291
|
+
}
|
|
3292
|
+
}],
|
|
3293
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters),
|
|
3294
|
+
...def.actionLevelValidation ? {
|
|
3295
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3296
|
+
} : {},
|
|
3297
|
+
...def.defaultFormat && {
|
|
3298
|
+
defaultFormat: def.defaultFormat
|
|
3299
|
+
},
|
|
3300
|
+
...def.enableLayoutSwitch && {
|
|
3301
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3302
|
+
},
|
|
3303
|
+
...def.tableConfiguration && {
|
|
3304
|
+
displayAndFormat: {
|
|
3305
|
+
table: def.tableConfiguration
|
|
3306
|
+
}
|
|
3307
|
+
},
|
|
3308
|
+
...def.sections && {
|
|
3309
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3310
|
+
},
|
|
3311
|
+
...def.submissionMetadata && {
|
|
3312
|
+
submissionMetadata: def.submissionMetadata
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
|
|
3317
|
+
// src/api/defineCreateOrModifyObjectAction.ts
|
|
3318
|
+
function defineCreateOrModifyObjectAction(def) {
|
|
3319
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3320
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
3321
|
+
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));
|
|
3322
|
+
const parameterNames = new Set(propertyParameters);
|
|
3323
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3324
|
+
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
3325
|
+
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
3326
|
+
if (def.parameterOrdering) {
|
|
3327
|
+
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
3328
|
+
def.parameterOrdering.unshift(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
3329
|
+
}
|
|
3330
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3331
|
+
}
|
|
3332
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
3333
|
+
parameters.forEach((p) => {
|
|
3334
|
+
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
3335
|
+
p.defaultValue = {
|
|
3336
|
+
type: "objectParameterPropertyValue",
|
|
3337
|
+
objectParameterPropertyValue: {
|
|
3338
|
+
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
3339
|
+
propertyTypeId: p.id
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
}
|
|
3343
|
+
});
|
|
3344
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3345
|
+
return defineAction({
|
|
3346
|
+
apiName: actionApiName,
|
|
3347
|
+
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
3348
|
+
parameters,
|
|
3349
|
+
status: def.status ?? "active",
|
|
3350
|
+
rules: [{
|
|
3351
|
+
type: "addOrModifyObjectRuleV2",
|
|
3352
|
+
addOrModifyObjectRuleV2: {
|
|
3353
|
+
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
3354
|
+
propertyValues: {
|
|
3355
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
3356
|
+
type: "parameterId",
|
|
3357
|
+
parameterId: p
|
|
3358
|
+
}])),
|
|
3359
|
+
...mappings
|
|
3360
|
+
},
|
|
3361
|
+
structFieldValues: {}
|
|
3362
|
+
}
|
|
3363
|
+
}],
|
|
3364
|
+
entities: {
|
|
3365
|
+
affectedInterfaceTypes: [],
|
|
3366
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3367
|
+
affectedLinkTypes: [],
|
|
3368
|
+
typeGroups: []
|
|
3369
|
+
},
|
|
3370
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
3371
|
+
...def.actionLevelValidation ? {
|
|
3372
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3373
|
+
} : {},
|
|
3374
|
+
...def.defaultFormat && {
|
|
3375
|
+
defaultFormat: def.defaultFormat
|
|
3376
|
+
},
|
|
3377
|
+
...def.enableLayoutSwitch && {
|
|
3378
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3379
|
+
},
|
|
3380
|
+
...def.tableConfiguration && {
|
|
3381
|
+
displayAndFormat: {
|
|
3382
|
+
table: def.tableConfiguration
|
|
3383
|
+
}
|
|
3384
|
+
},
|
|
3385
|
+
...def.sections && {
|
|
3386
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3387
|
+
},
|
|
3388
|
+
...def.submissionMetadata && {
|
|
3389
|
+
submissionMetadata: def.submissionMetadata
|
|
3390
|
+
}
|
|
2624
3391
|
});
|
|
2625
3392
|
}
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
3393
|
+
|
|
3394
|
+
// src/api/defineDeleteInterfaceObjectAction.ts
|
|
3395
|
+
function defineDeleteInterfaceObjectAction(def) {
|
|
3396
|
+
return defineAction({
|
|
3397
|
+
apiName: def.apiName ?? `delete-interface-object-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}`,
|
|
3398
|
+
displayName: def.displayName ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,
|
|
3399
|
+
parameters: [{
|
|
3400
|
+
id: "objectToDeleteParameter",
|
|
3401
|
+
displayName: "Delete object",
|
|
3402
|
+
type: {
|
|
3403
|
+
type: "interfaceReference",
|
|
3404
|
+
interfaceReference: {
|
|
3405
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
3406
|
+
}
|
|
3407
|
+
},
|
|
3408
|
+
validation: {
|
|
3409
|
+
required: true,
|
|
3410
|
+
allowedValues: {
|
|
3411
|
+
type: "interfaceObjectQuery"
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
}],
|
|
3415
|
+
status: def.status ?? "active",
|
|
3416
|
+
rules: [{
|
|
3417
|
+
type: "deleteObjectRule",
|
|
3418
|
+
deleteObjectRule: {
|
|
3419
|
+
objectToDelete: "objectToDeleteParameter"
|
|
3420
|
+
}
|
|
3421
|
+
}],
|
|
3422
|
+
entities: {
|
|
3423
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
3424
|
+
affectedObjectTypes: [],
|
|
3425
|
+
affectedLinkTypes: [],
|
|
3426
|
+
typeGroups: []
|
|
3427
|
+
}
|
|
2639
3428
|
});
|
|
2640
3429
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
3430
|
+
|
|
3431
|
+
// src/api/defineDeleteObjectAction.ts
|
|
3432
|
+
function defineDeleteObjectAction(def) {
|
|
3433
|
+
return defineAction({
|
|
3434
|
+
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
3435
|
+
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
3436
|
+
parameters: [{
|
|
3437
|
+
id: "objectToDeleteParameter",
|
|
3438
|
+
displayName: "Delete object",
|
|
3439
|
+
type: {
|
|
3440
|
+
type: "objectReference",
|
|
3441
|
+
objectReference: {
|
|
3442
|
+
objectTypeId: def.objectType.apiName
|
|
3443
|
+
}
|
|
3444
|
+
},
|
|
3445
|
+
validation: {
|
|
3446
|
+
required: true,
|
|
3447
|
+
allowedValues: {
|
|
3448
|
+
type: "objectQuery"
|
|
3449
|
+
}
|
|
2652
3450
|
}
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
3451
|
+
}],
|
|
3452
|
+
status: def.status ?? "active",
|
|
3453
|
+
rules: [{
|
|
3454
|
+
type: "deleteObjectRule",
|
|
3455
|
+
deleteObjectRule: {
|
|
3456
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2657
3457
|
}
|
|
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;
|
|
3458
|
+
}],
|
|
3459
|
+
entities: {
|
|
3460
|
+
affectedInterfaceTypes: [],
|
|
3461
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3462
|
+
affectedLinkTypes: [],
|
|
3463
|
+
typeGroups: []
|
|
3464
|
+
},
|
|
3465
|
+
...def.actionLevelValidation ? {
|
|
3466
|
+
validation: convertValidationRule(def.actionLevelValidation)
|
|
3467
|
+
} : {}
|
|
2698
3468
|
});
|
|
2699
3469
|
}
|
|
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
3470
|
function defineSharedPropertyType(sptDef) {
|
|
2710
3471
|
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" ?
|
|
3472
|
+
!(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;
|
|
3473
|
+
!(!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
3474
|
const fullSpt = {
|
|
2714
3475
|
...sptDef,
|
|
2715
3476
|
apiName,
|
|
@@ -2758,7 +3519,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
2758
3519
|
// src/api/defineInterface.ts
|
|
2759
3520
|
function defineInterface(interfaceDef) {
|
|
2760
3521
|
const apiName = namespace + interfaceDef.apiName;
|
|
2761
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
3522
|
+
!(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
3523
|
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2763
3524
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2764
3525
|
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
@@ -2777,7 +3538,7 @@ function defineInterface(interfaceDef) {
|
|
|
2777
3538
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2778
3539
|
type: "active"
|
|
2779
3540
|
});
|
|
2780
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
3541
|
+
!(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
3542
|
const fullInterface = {
|
|
2782
3543
|
apiName,
|
|
2783
3544
|
displayMetadata: {
|
|
@@ -2803,7 +3564,7 @@ function defineInterface(interfaceDef) {
|
|
|
2803
3564
|
}
|
|
2804
3565
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2805
3566
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2806
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
3567
|
+
!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
3568
|
const spt = defineSharedPropertyType({
|
|
2808
3569
|
apiName,
|
|
2809
3570
|
displayName: apiName,
|
|
@@ -2813,16 +3574,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2813
3574
|
return spt;
|
|
2814
3575
|
} else {
|
|
2815
3576
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2816
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3577
|
+
!(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
3578
|
key: apiName,
|
|
2818
3579
|
apiName: type.apiName
|
|
2819
|
-
})}`) :
|
|
3580
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
2820
3581
|
return type;
|
|
2821
3582
|
}
|
|
2822
3583
|
}
|
|
2823
3584
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2824
3585
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2825
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3586
|
+
!(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
3587
|
linkDef.from.links.push({
|
|
2827
3588
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2828
3589
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2850,19 +3611,9 @@ function getLinkMeta(meta) {
|
|
|
2850
3611
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
2851
3612
|
};
|
|
2852
3613
|
}
|
|
2853
|
-
|
|
3614
|
+
|
|
3615
|
+
// src/api/defineLink.ts
|
|
2854
3616
|
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
3617
|
let fullLinkDefinition;
|
|
2867
3618
|
if ("one" in linkDefinition) {
|
|
2868
3619
|
fullLinkDefinition = {
|
|
@@ -2886,6 +3637,7 @@ function defineLink(linkDefinition) {
|
|
|
2886
3637
|
const linkType = {
|
|
2887
3638
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2888
3639
|
...fullLinkDefinition,
|
|
3640
|
+
apiName: linkDefinition.apiName,
|
|
2889
3641
|
__type: OntologyEntityTypeEnum.LINK_TYPE
|
|
2890
3642
|
};
|
|
2891
3643
|
updateOntology(linkType);
|
|
@@ -2921,6 +3673,148 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
2921
3673
|
typeClasses: []
|
|
2922
3674
|
};
|
|
2923
3675
|
}
|
|
3676
|
+
|
|
3677
|
+
// src/api/defineModifyInterfaceObjectAction.ts
|
|
3678
|
+
function defineModifyInterfaceObjectAction(def) {
|
|
3679
|
+
addNamespaceToActionDefinition(def);
|
|
3680
|
+
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3681
|
+
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3682
|
+
const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
3683
|
+
const parameterNames = new Set(propertyParameters);
|
|
3684
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3685
|
+
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3686
|
+
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)}`}`;
|
|
3687
|
+
if (def.parameterOrdering) {
|
|
3688
|
+
if (!def.parameterOrdering.includes(MODIFY_INTERFACE_OBJECT_PARAMETER)) {
|
|
3689
|
+
def.parameterOrdering.unshift(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3690
|
+
}
|
|
3691
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3692
|
+
}
|
|
3693
|
+
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])));
|
|
3694
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3695
|
+
return defineAction({
|
|
3696
|
+
apiName: actionApiName,
|
|
3697
|
+
displayName: def.displayName ?? `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
3698
|
+
parameters,
|
|
3699
|
+
status: def.status ?? (def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status),
|
|
3700
|
+
entities: {
|
|
3701
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
3702
|
+
affectedObjectTypes: [],
|
|
3703
|
+
affectedLinkTypes: [],
|
|
3704
|
+
typeGroups: []
|
|
3705
|
+
},
|
|
3706
|
+
rules: [{
|
|
3707
|
+
type: "modifyInterfaceRule",
|
|
3708
|
+
modifyInterfaceRule: {
|
|
3709
|
+
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3710
|
+
sharedPropertyValues: {
|
|
3711
|
+
...Object.fromEntries(propertyParameters.map((id) => [id, {
|
|
3712
|
+
type: "parameterId",
|
|
3713
|
+
parameterId: id
|
|
3714
|
+
}])),
|
|
3715
|
+
...mappings
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
}],
|
|
3719
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
|
|
3720
|
+
...def.actionLevelValidation ? {
|
|
3721
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3722
|
+
} : {},
|
|
3723
|
+
...def.defaultFormat && {
|
|
3724
|
+
defaultFormat: def.defaultFormat
|
|
3725
|
+
},
|
|
3726
|
+
...def.enableLayoutSwitch && {
|
|
3727
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3728
|
+
},
|
|
3729
|
+
...def.tableConfiguration && {
|
|
3730
|
+
displayAndFormat: {
|
|
3731
|
+
table: def.tableConfiguration
|
|
3732
|
+
}
|
|
3733
|
+
},
|
|
3734
|
+
...def.sections && {
|
|
3735
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3736
|
+
},
|
|
3737
|
+
...def.submissionMetadata && {
|
|
3738
|
+
submissionMetadata: def.submissionMetadata
|
|
3739
|
+
}
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
// src/api/defineModifyObjectAction.ts
|
|
3744
|
+
function defineModifyObjectAction(def) {
|
|
3745
|
+
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
3746
|
+
const propertyParameters = Object.keys(def.objectType.properties ?? {}).filter((id) => isPropertyParameter(def, id, def.objectType.properties?.[id].type) && id !== def.objectType.primaryKeyPropertyApiName);
|
|
3747
|
+
const parameterNames = new Set(propertyParameters);
|
|
3748
|
+
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
3749
|
+
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
3750
|
+
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
3751
|
+
if (def.parameterOrdering) {
|
|
3752
|
+
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
3753
|
+
def.parameterOrdering.unshift(MODIFY_OBJECT_PARAMETER);
|
|
3754
|
+
}
|
|
3755
|
+
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3756
|
+
}
|
|
3757
|
+
const parameters = createParameters(def, def.objectType.properties ?? {}, parameterNames);
|
|
3758
|
+
parameters.forEach((p) => {
|
|
3759
|
+
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
3760
|
+
p.defaultValue = {
|
|
3761
|
+
type: "objectParameterPropertyValue",
|
|
3762
|
+
objectParameterPropertyValue: {
|
|
3763
|
+
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
3764
|
+
propertyTypeId: p.id
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
}
|
|
3768
|
+
});
|
|
3769
|
+
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3770
|
+
return defineAction({
|
|
3771
|
+
apiName: actionApiName,
|
|
3772
|
+
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
3773
|
+
parameters,
|
|
3774
|
+
status: def.status ?? "active",
|
|
3775
|
+
rules: [{
|
|
3776
|
+
type: "modifyObjectRule",
|
|
3777
|
+
modifyObjectRule: {
|
|
3778
|
+
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
3779
|
+
propertyValues: {
|
|
3780
|
+
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
3781
|
+
type: "parameterId",
|
|
3782
|
+
parameterId: p
|
|
3783
|
+
}])),
|
|
3784
|
+
...mappings
|
|
3785
|
+
},
|
|
3786
|
+
structFieldValues: {}
|
|
3787
|
+
}
|
|
3788
|
+
}],
|
|
3789
|
+
entities: {
|
|
3790
|
+
affectedInterfaceTypes: [],
|
|
3791
|
+
affectedObjectTypes: [def.objectType.apiName],
|
|
3792
|
+
affectedLinkTypes: [],
|
|
3793
|
+
typeGroups: []
|
|
3794
|
+
},
|
|
3795
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(def.objectType.properties ?? {}), parameters, MODIFY_OBJECT_PARAMETER),
|
|
3796
|
+
...def.actionLevelValidation ? {
|
|
3797
|
+
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3798
|
+
} : {},
|
|
3799
|
+
...def.defaultFormat && {
|
|
3800
|
+
defaultFormat: def.defaultFormat
|
|
3801
|
+
},
|
|
3802
|
+
...def.enableLayoutSwitch && {
|
|
3803
|
+
enableLayoutSwitch: def.enableLayoutSwitch
|
|
3804
|
+
},
|
|
3805
|
+
...def.tableConfiguration && {
|
|
3806
|
+
displayAndFormat: {
|
|
3807
|
+
table: def.tableConfiguration
|
|
3808
|
+
}
|
|
3809
|
+
},
|
|
3810
|
+
...def.sections && {
|
|
3811
|
+
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
3812
|
+
},
|
|
3813
|
+
...def.submissionMetadata && {
|
|
3814
|
+
submissionMetadata: def.submissionMetadata
|
|
3815
|
+
}
|
|
3816
|
+
});
|
|
3817
|
+
}
|
|
2924
3818
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
2925
3819
|
switch (true) {
|
|
2926
3820
|
case (typeof valueType === "object" && valueType.type === "array"):
|
|
@@ -2973,7 +3867,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2973
3867
|
version
|
|
2974
3868
|
} = valueTypeDef;
|
|
2975
3869
|
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" ?
|
|
3870
|
+
!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
3871
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2978
3872
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2979
3873
|
const output = {
|
|
@@ -3029,8 +3923,8 @@ function importSharedPropertyType(opts) {
|
|
|
3029
3923
|
} = opts;
|
|
3030
3924
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3031
3925
|
if (packageName !== void 0) {
|
|
3032
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
3033
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
3926
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Package name format invalid ends with period") : invariant7__default.default(false) : void 0;
|
|
3927
|
+
!(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
3928
|
}
|
|
3035
3929
|
const spt = {
|
|
3036
3930
|
apiName: fullApiName,
|
|
@@ -3052,8 +3946,18 @@ function wrapWithProxy(entity) {
|
|
|
3052
3946
|
}
|
|
3053
3947
|
});
|
|
3054
3948
|
}
|
|
3949
|
+
/*! Bundled license information:
|
|
3950
|
+
|
|
3951
|
+
mustache/mustache.mjs:
|
|
3952
|
+
(*!
|
|
3953
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
3954
|
+
* http://github.com/janl/mustache.js
|
|
3955
|
+
*)
|
|
3956
|
+
*/
|
|
3055
3957
|
|
|
3958
|
+
exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
|
|
3056
3959
|
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
3960
|
+
exports.MODIFY_INTERFACE_OBJECT_PARAMETER = MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
3057
3961
|
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
3058
3962
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
3059
3963
|
exports.addDependency = addDependency;
|
|
@@ -3066,6 +3970,7 @@ exports.defineAction = defineAction;
|
|
|
3066
3970
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
3067
3971
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
3068
3972
|
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
3973
|
+
exports.defineDeleteInterfaceObjectAction = defineDeleteInterfaceObjectAction;
|
|
3069
3974
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
3070
3975
|
exports.defineInterface = defineInterface;
|
|
3071
3976
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|