@osdk/maker 0.13.0 → 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 +102 -36
- 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 +6 -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 +25 -6
- 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 -2
- package/build/browser/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/browser/conversion/toMarketplace/convertConditionDefinition.js +5 -3
- 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 +1716 -797
- 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 +6 -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 +25 -6
- 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 -2
- package/build/esm/conversion/toMarketplace/convertActionValidation.js.map +1 -1
- package/build/esm/conversion/toMarketplace/convertConditionDefinition.js +5 -3
- 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/cli/main.d.ts.map +1 -1
- 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/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 +6 -6
- 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 -13998
- 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 -13998
- 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,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var consola = require('consola');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var uuid = require('uuid');
|
|
6
|
+
var fs3 = require('fs/promises');
|
|
7
|
+
var path3 = require('path');
|
|
8
|
+
var invariant7 = require('tiny-invariant');
|
|
10
9
|
var yargs = require('yargs');
|
|
11
10
|
var helpers = require('yargs/helpers');
|
|
12
|
-
var
|
|
11
|
+
var fs2 = require('fs');
|
|
12
|
+
var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
13
13
|
var crypto = require('crypto');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -32,11 +32,11 @@ function _interopNamespace(e) {
|
|
|
32
32
|
return Object.freeze(n);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
35
|
+
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
36
|
+
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
37
|
+
var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
|
|
38
38
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
39
|
-
var
|
|
39
|
+
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
40
40
|
|
|
41
41
|
// src/cli/main.ts
|
|
42
42
|
|
|
@@ -67,6 +67,193 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2)
|
|
|
67
67
|
return OntologyEntityTypeEnum2;
|
|
68
68
|
})({});
|
|
69
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
|
+
|
|
70
257
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
71
258
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
72
259
|
let properties = interfaceType.propertiesV2;
|
|
@@ -108,12 +295,20 @@ function defineObject(objectDef) {
|
|
|
108
295
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
109
296
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
110
297
|
}
|
|
111
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
112
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
113
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
114
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
115
|
-
const
|
|
116
|
-
|
|
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
|
+
}
|
|
117
312
|
if (objectDef.status === "experimental") {
|
|
118
313
|
const activeProperties = [];
|
|
119
314
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -121,14 +316,14 @@ function defineObject(objectDef) {
|
|
|
121
316
|
activeProperties.push(apiName2);
|
|
122
317
|
}
|
|
123
318
|
});
|
|
124
|
-
!(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;
|
|
125
320
|
}
|
|
126
321
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
127
322
|
const deadline = objectDef.status.deadline;
|
|
128
|
-
!(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;
|
|
129
324
|
}
|
|
130
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
131
|
-
!!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;
|
|
132
327
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
133
328
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
134
329
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -147,7 +342,7 @@ function defineObject(objectDef) {
|
|
|
147
342
|
};
|
|
148
343
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
149
344
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
150
|
-
!(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;
|
|
151
346
|
});
|
|
152
347
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
153
348
|
const finalObject = {
|
|
@@ -198,6 +393,72 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
198
393
|
type: property.type
|
|
199
394
|
};
|
|
200
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
|
+
}
|
|
201
462
|
|
|
202
463
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
203
464
|
function convertActionSections(action) {
|
|
@@ -225,16 +486,14 @@ function convertActionSections(action) {
|
|
|
225
486
|
}
|
|
226
487
|
}]));
|
|
227
488
|
}
|
|
228
|
-
|
|
229
|
-
// src/conversion/toMarketplace/convertConditionDefinition.ts
|
|
230
|
-
function convertConditionDefinition(condition) {
|
|
489
|
+
function convertConditionDefinition(condition, actionParameters) {
|
|
231
490
|
switch (condition.type) {
|
|
232
491
|
case "and":
|
|
233
492
|
if ("conditions" in condition) {
|
|
234
493
|
return {
|
|
235
494
|
type: "and",
|
|
236
495
|
and: {
|
|
237
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c))
|
|
496
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
238
497
|
}
|
|
239
498
|
};
|
|
240
499
|
} else {
|
|
@@ -245,7 +504,7 @@ function convertConditionDefinition(condition) {
|
|
|
245
504
|
return {
|
|
246
505
|
type: "or",
|
|
247
506
|
or: {
|
|
248
|
-
conditions: condition.conditions.map((c) => convertConditionDefinition(c))
|
|
507
|
+
conditions: condition.conditions.map((c) => convertConditionDefinition(c, actionParameters))
|
|
249
508
|
}
|
|
250
509
|
};
|
|
251
510
|
} else {
|
|
@@ -281,6 +540,7 @@ function convertConditionDefinition(condition) {
|
|
|
281
540
|
}
|
|
282
541
|
};
|
|
283
542
|
case "parameter":
|
|
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;
|
|
284
544
|
return {
|
|
285
545
|
type: "comparison",
|
|
286
546
|
comparison: {
|
|
@@ -298,7 +558,7 @@ function convertConditionDefinition(condition) {
|
|
|
298
558
|
}
|
|
299
559
|
|
|
300
560
|
// src/conversion/toMarketplace/convertActionParameterConditionalOverride.ts
|
|
301
|
-
function convertActionParameterConditionalOverride(override, validation) {
|
|
561
|
+
function convertActionParameterConditionalOverride(override, validation, actionParameters) {
|
|
302
562
|
let parameterBlockOverride;
|
|
303
563
|
switch (override.type) {
|
|
304
564
|
case "required":
|
|
@@ -363,7 +623,7 @@ function convertActionParameterConditionalOverride(override, validation) {
|
|
|
363
623
|
throw new Error(`Unknown parameter override type`);
|
|
364
624
|
}
|
|
365
625
|
return {
|
|
366
|
-
condition: convertConditionDefinition(override.condition),
|
|
626
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
367
627
|
parameterBlockOverrides: [parameterBlockOverride]
|
|
368
628
|
};
|
|
369
629
|
}
|
|
@@ -395,9 +655,9 @@ function convertActionVisibility(visibility) {
|
|
|
395
655
|
}
|
|
396
656
|
|
|
397
657
|
// src/conversion/toMarketplace/convertSectionConditionalOverride.ts
|
|
398
|
-
function convertSectionConditionalOverride(override, defaultVisibility) {
|
|
658
|
+
function convertSectionConditionalOverride(override, defaultVisibility, actionParameters) {
|
|
399
659
|
return {
|
|
400
|
-
condition: convertConditionDefinition(override.condition),
|
|
660
|
+
condition: convertConditionDefinition(override.condition, actionParameters),
|
|
401
661
|
sectionBlockOverrides: [{
|
|
402
662
|
type: "visibility",
|
|
403
663
|
visibility: {
|
|
@@ -443,7 +703,7 @@ function convertActionValidation(action) {
|
|
|
443
703
|
required: convertParameterRequirementConstraint(p.validation.required)
|
|
444
704
|
}
|
|
445
705
|
},
|
|
446
|
-
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation)) ?? []
|
|
706
|
+
conditionalOverrides: p.validation.conditionalOverrides?.map((override) => convertActionParameterConditionalOverride(override, p.validation, action.parameters)) ?? []
|
|
447
707
|
}];
|
|
448
708
|
})),
|
|
449
709
|
sectionValidations: {
|
|
@@ -459,7 +719,7 @@ function convertActionValidation(action) {
|
|
|
459
719
|
visible: {}
|
|
460
720
|
}
|
|
461
721
|
},
|
|
462
|
-
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible")) ?? []
|
|
722
|
+
conditionalOverrides: section.conditionalOverrides?.map((override) => convertSectionConditionalOverride(override, section.defaultVisibility ?? "visible", action.parameters)) ?? []
|
|
463
723
|
}]))
|
|
464
724
|
}
|
|
465
725
|
};
|
|
@@ -498,7 +758,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
498
758
|
}
|
|
499
759
|
};
|
|
500
760
|
}
|
|
501
|
-
!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;
|
|
502
762
|
return {
|
|
503
763
|
propertyTypeConstraints: [],
|
|
504
764
|
nullability: void 0,
|
|
@@ -702,134 +962,12 @@ function convertInterface(interfaceType) {
|
|
|
702
962
|
};
|
|
703
963
|
}
|
|
704
964
|
|
|
705
|
-
// src/conversion/toMarketplace/convertCardinality.ts
|
|
706
|
-
function convertCardinality(cardinality) {
|
|
707
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
708
|
-
return "ONE_TO_MANY";
|
|
709
|
-
}
|
|
710
|
-
return "ONE_TO_ONE";
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/conversion/toMarketplace/convertLink.ts
|
|
714
|
-
function convertLink(linkType) {
|
|
715
|
-
let definition;
|
|
716
|
-
let datasource = void 0;
|
|
717
|
-
if ("one" in linkType) {
|
|
718
|
-
definition = {
|
|
719
|
-
type: "oneToMany",
|
|
720
|
-
oneToMany: {
|
|
721
|
-
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
722
|
-
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
723
|
-
objectTypeRidManySide: linkType.toMany.object.apiName,
|
|
724
|
-
objectTypeRidOneSide: linkType.one.object.apiName,
|
|
725
|
-
oneToManyLinkMetadata: linkType.one.metadata,
|
|
726
|
-
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
727
|
-
from: {
|
|
728
|
-
apiName: linkType.one.object.primaryKeyPropertyApiName,
|
|
729
|
-
object: linkType.one.object.apiName
|
|
730
|
-
},
|
|
731
|
-
to: {
|
|
732
|
-
apiName: linkType.manyForeignKeyProperty,
|
|
733
|
-
object: linkType.toMany.object.apiName
|
|
734
|
-
}
|
|
735
|
-
}]
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
} else if ("intermediaryObjectType" in linkType) {
|
|
739
|
-
definition = {
|
|
740
|
-
type: "intermediary",
|
|
741
|
-
intermediary: {
|
|
742
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
743
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
744
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
745
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
746
|
-
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
747
|
-
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
748
|
-
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
} else {
|
|
752
|
-
definition = {
|
|
753
|
-
type: "manyToMany",
|
|
754
|
-
manyToMany: {
|
|
755
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
756
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
757
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
758
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
759
|
-
peeringMetadata: void 0,
|
|
760
|
-
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
761
|
-
from: {
|
|
762
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
763
|
-
object: linkType.many.object.apiName
|
|
764
|
-
},
|
|
765
|
-
to: {
|
|
766
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
767
|
-
object: linkType.many.object.apiName
|
|
768
|
-
}
|
|
769
|
-
}],
|
|
770
|
-
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
771
|
-
from: {
|
|
772
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
773
|
-
object: linkType.toMany.object.apiName
|
|
774
|
-
},
|
|
775
|
-
to: {
|
|
776
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
777
|
-
object: linkType.toMany.object.apiName
|
|
778
|
-
}
|
|
779
|
-
}]
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
datasource = {
|
|
783
|
-
datasourceName: linkType.apiName,
|
|
784
|
-
datasource: {
|
|
785
|
-
type: "dataset",
|
|
786
|
-
dataset: {
|
|
787
|
-
datasetRid: "link-".concat(linkType.apiName),
|
|
788
|
-
writebackDatasetRid: void 0,
|
|
789
|
-
objectTypeAPrimaryKeyMapping: [{
|
|
790
|
-
property: {
|
|
791
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
792
|
-
object: linkType.many.object.apiName
|
|
793
|
-
},
|
|
794
|
-
column: linkType.many.object.primaryKeyPropertyApiName
|
|
795
|
-
}],
|
|
796
|
-
objectTypeBPrimaryKeyMapping: [{
|
|
797
|
-
property: {
|
|
798
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
799
|
-
object: linkType.toMany.object.apiName
|
|
800
|
-
},
|
|
801
|
-
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
802
|
-
}]
|
|
803
|
-
}
|
|
804
|
-
},
|
|
805
|
-
editsConfiguration: {
|
|
806
|
-
onlyAllowPrivilegedEdits: false
|
|
807
|
-
},
|
|
808
|
-
redacted: linkType.redacted
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
return {
|
|
812
|
-
linkType: {
|
|
813
|
-
definition,
|
|
814
|
-
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
815
|
-
status: linkType.status ?? {
|
|
816
|
-
type: "active",
|
|
817
|
-
active: {}
|
|
818
|
-
},
|
|
819
|
-
redacted: linkType.redacted ?? false
|
|
820
|
-
},
|
|
821
|
-
datasources: datasource !== void 0 ? [datasource] : [],
|
|
822
|
-
entityMetadata: {
|
|
823
|
-
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
|
|
828
965
|
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
829
966
|
function convertDatasourceDefinition(objectType, properties) {
|
|
830
|
-
|
|
967
|
+
const baseDatasource = objectType.datasources?.find((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
968
|
+
switch (baseDatasource?.type) {
|
|
831
969
|
case "stream":
|
|
832
|
-
const window =
|
|
970
|
+
const window = baseDatasource.retentionPeriod;
|
|
833
971
|
const retentionPolicy = window ? {
|
|
834
972
|
type: "time",
|
|
835
973
|
time: {
|
|
@@ -1018,7 +1156,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1018
1156
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1019
1157
|
function convertObjectPropertyType(property) {
|
|
1020
1158
|
const apiName = namespace + property.apiName;
|
|
1021
|
-
!(!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;
|
|
1022
1160
|
const output = {
|
|
1023
1161
|
apiName: property.apiName,
|
|
1024
1162
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1048,12 +1186,16 @@ function convertObjectPropertyType(property) {
|
|
|
1048
1186
|
|
|
1049
1187
|
// src/conversion/toMarketplace/convertObject.ts
|
|
1050
1188
|
function convertObject(objectType) {
|
|
1051
|
-
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));
|
|
1052
1194
|
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1053
1195
|
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1054
1196
|
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1055
1197
|
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1056
|
-
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);
|
|
1057
1199
|
const implementations = objectType.implementsInterfaces ?? [];
|
|
1058
1200
|
return {
|
|
1059
1201
|
objectType: {
|
|
@@ -1087,7 +1229,7 @@ function convertObject(objectType) {
|
|
|
1087
1229
|
})),
|
|
1088
1230
|
allImplementsInterfaces: {}
|
|
1089
1231
|
},
|
|
1090
|
-
datasources: [...propertyDatasources, objectDatasource],
|
|
1232
|
+
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1091
1233
|
entityMetadata: {
|
|
1092
1234
|
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1093
1235
|
}
|
|
@@ -1130,6 +1272,80 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1130
1272
|
return [];
|
|
1131
1273
|
}
|
|
1132
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
|
+
}
|
|
1133
1349
|
|
|
1134
1350
|
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1135
1351
|
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
@@ -1228,11 +1444,546 @@ function getFormContentOrdering(action, parameterOrdering) {
|
|
|
1228
1444
|
return formContentOrdering;
|
|
1229
1445
|
}
|
|
1230
1446
|
|
|
1231
|
-
//
|
|
1232
|
-
var
|
|
1233
|
-
var
|
|
1234
|
-
|
|
1235
|
-
|
|
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;
|
|
1984
|
+
var importedTypes;
|
|
1985
|
+
var dependencies;
|
|
1986
|
+
var namespace;
|
|
1236
1987
|
function updateOntology(entity) {
|
|
1237
1988
|
if (entity.__type !== OntologyEntityTypeEnum.VALUE_TYPE) {
|
|
1238
1989
|
ontologyDefinition[entity.__type][entity.apiName] = entity;
|
|
@@ -1243,7 +1994,7 @@ function updateOntology(entity) {
|
|
|
1243
1994
|
}
|
|
1244
1995
|
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1245
1996
|
}
|
|
1246
|
-
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1997
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, codeSnippetFiles, snippetPackageName, snippetFileOutputDir, randomnessKey) {
|
|
1247
1998
|
namespace = ns;
|
|
1248
1999
|
dependencies = {};
|
|
1249
2000
|
ontologyDefinition = {
|
|
@@ -1274,10 +2025,13 @@ async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey
|
|
|
1274
2025
|
if (dependencyFile) {
|
|
1275
2026
|
writeDependencyFile(dependencyFile);
|
|
1276
2027
|
}
|
|
2028
|
+
if (codeSnippetFiles) {
|
|
2029
|
+
createCodeSnippets(ontologyDefinition, snippetPackageName, snippetFileOutputDir);
|
|
2030
|
+
}
|
|
1277
2031
|
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1278
2032
|
}
|
|
1279
2033
|
function writeStaticObjects(outputDir) {
|
|
1280
|
-
const codegenDir =
|
|
2034
|
+
const codegenDir = path3__namespace.resolve(outputDir, "codegen");
|
|
1281
2035
|
const typeDirs = {
|
|
1282
2036
|
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1283
2037
|
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
@@ -1286,42 +2040,43 @@ function writeStaticObjects(outputDir) {
|
|
|
1286
2040
|
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1287
2041
|
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1288
2042
|
};
|
|
1289
|
-
if (!
|
|
1290
|
-
|
|
2043
|
+
if (!fs2__namespace.existsSync(codegenDir)) {
|
|
2044
|
+
fs2__namespace.mkdirSync(codegenDir, {
|
|
1291
2045
|
recursive: true
|
|
1292
2046
|
});
|
|
1293
2047
|
}
|
|
1294
2048
|
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1295
|
-
const currentTypeDirPath =
|
|
1296
|
-
if (
|
|
1297
|
-
|
|
2049
|
+
const currentTypeDirPath = path3__namespace.join(codegenDir, typeDirNameFromMap);
|
|
2050
|
+
if (fs2__namespace.existsSync(currentTypeDirPath)) {
|
|
2051
|
+
fs2__namespace.rmSync(currentTypeDirPath, {
|
|
1298
2052
|
recursive: true,
|
|
1299
2053
|
force: true
|
|
1300
2054
|
});
|
|
1301
2055
|
}
|
|
1302
|
-
|
|
2056
|
+
fs2__namespace.mkdirSync(currentTypeDirPath, {
|
|
1303
2057
|
recursive: true
|
|
1304
2058
|
});
|
|
1305
2059
|
});
|
|
1306
2060
|
const topLevelExportStatements = [];
|
|
1307
2061
|
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1308
2062
|
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1309
|
-
const typeDirPath =
|
|
2063
|
+
const typeDirPath = path3__namespace.join(codegenDir, typeDirName);
|
|
1310
2064
|
const entityModuleNames = [];
|
|
1311
2065
|
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1312
2066
|
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1313
|
-
const filePath =
|
|
2067
|
+
const filePath = path3__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1314
2068
|
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1315
2069
|
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1316
2070
|
const content = `
|
|
1317
2071
|
import { wrapWithProxy, OntologyEntityTypeEnum } from '@osdk/maker';
|
|
1318
2072
|
import type { ${entityTypeName} } from '@osdk/maker';
|
|
1319
2073
|
|
|
2074
|
+
/** @type {import('@osdk/maker').${entityTypeName}} */
|
|
1320
2075
|
const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey === "VALUE_TYPE" ? entityJSON.slice(1, -2) : entityJSON} as unknown as ${entityTypeName};
|
|
1321
2076
|
|
|
1322
2077
|
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1323
2078
|
`;
|
|
1324
|
-
|
|
2079
|
+
fs2__namespace.writeFileSync(filePath, content, {
|
|
1325
2080
|
flag: "w"
|
|
1326
2081
|
});
|
|
1327
2082
|
entityModuleNames.push(entityFileNameBase);
|
|
@@ -1332,8 +2087,8 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
|
|
|
1332
2087
|
});
|
|
1333
2088
|
if (topLevelExportStatements.length > 0) {
|
|
1334
2089
|
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1335
|
-
const mainIndexFilePath =
|
|
1336
|
-
|
|
2090
|
+
const mainIndexFilePath = path3__namespace.join(outputDir, "index.ts");
|
|
2091
|
+
fs2__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1337
2092
|
flag: "w"
|
|
1338
2093
|
});
|
|
1339
2094
|
}
|
|
@@ -1689,7 +2444,7 @@ function getEntityTypeName(type) {
|
|
|
1689
2444
|
}[type];
|
|
1690
2445
|
}
|
|
1691
2446
|
function writeDependencyFile(dependencyFile) {
|
|
1692
|
-
|
|
2447
|
+
fs2__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
|
|
1693
2448
|
}
|
|
1694
2449
|
function dependencyInjectionString() {
|
|
1695
2450
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
@@ -1704,21 +2459,22 @@ function addNamespaceIfNone(apiName) {
|
|
|
1704
2459
|
|
|
1705
2460
|
// src/cli/main.ts
|
|
1706
2461
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2462
|
+
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1707
2463
|
async function main(args = process.argv) {
|
|
1708
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.
|
|
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({
|
|
1709
2465
|
input: {
|
|
1710
2466
|
alias: "i",
|
|
1711
2467
|
describe: "Input file",
|
|
1712
2468
|
type: "string",
|
|
1713
2469
|
default: ".ontology/ontology.ts",
|
|
1714
|
-
coerce:
|
|
2470
|
+
coerce: path3__namespace.resolve
|
|
1715
2471
|
},
|
|
1716
2472
|
output: {
|
|
1717
2473
|
alias: "o",
|
|
1718
2474
|
describe: "Output file",
|
|
1719
2475
|
type: "string",
|
|
1720
2476
|
default: "ontology.json",
|
|
1721
|
-
coerce:
|
|
2477
|
+
coerce: path3__namespace.resolve
|
|
1722
2478
|
},
|
|
1723
2479
|
apiNamespace: {
|
|
1724
2480
|
describe: "Api name prefix for namespaced ontology types",
|
|
@@ -1730,95 +2486,91 @@ async function main(args = process.argv) {
|
|
|
1730
2486
|
describe: "Snapshot directory",
|
|
1731
2487
|
type: "string",
|
|
1732
2488
|
default: "snapshots",
|
|
1733
|
-
coerce:
|
|
2489
|
+
coerce: path3__namespace.resolve
|
|
1734
2490
|
},
|
|
1735
2491
|
outputDir: {
|
|
1736
2492
|
alias: "d",
|
|
1737
2493
|
describe: "Directory for generated ontology entities",
|
|
1738
2494
|
type: "string",
|
|
1739
|
-
coerce:
|
|
2495
|
+
coerce: path3__namespace.resolve
|
|
1740
2496
|
},
|
|
1741
2497
|
valueTypesOutput: {
|
|
1742
2498
|
describe: "Value Type Output File",
|
|
1743
2499
|
type: "string",
|
|
1744
2500
|
default: "value-types.json",
|
|
1745
|
-
coerce:
|
|
2501
|
+
coerce: path3__namespace.resolve
|
|
1746
2502
|
},
|
|
1747
2503
|
dependencies: {
|
|
1748
2504
|
describe: "File to write dependencies to",
|
|
1749
2505
|
type: "string",
|
|
1750
|
-
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
|
|
1751
2523
|
},
|
|
1752
2524
|
randomnessKey: {
|
|
1753
2525
|
describe: "Value used to assure uniqueness of entities",
|
|
1754
2526
|
type: "string",
|
|
1755
|
-
coerce:
|
|
2527
|
+
coerce: path3__namespace.resolve
|
|
1756
2528
|
}
|
|
1757
2529
|
}).parseAsync();
|
|
1758
2530
|
let apiNamespace = "";
|
|
1759
2531
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1760
2532
|
apiNamespace = commandLineOpts.apiNamespace.slice(-1) !== "." ? commandLineOpts.apiNamespace + "." : commandLineOpts.apiNamespace;
|
|
1761
|
-
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ?
|
|
1762
|
-
!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;
|
|
1763
2535
|
}
|
|
1764
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
|
+
}
|
|
1765
2540
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1766
|
-
!
|
|
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;
|
|
1767
2542
|
}
|
|
1768
|
-
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies);
|
|
2543
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
1769
2544
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1770
|
-
await
|
|
2545
|
+
await fs3__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1771
2546
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1772
|
-
await
|
|
2547
|
+
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1773
2548
|
}
|
|
1774
2549
|
}
|
|
1775
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile) {
|
|
1776
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile);
|
|
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);
|
|
1777
2552
|
return q;
|
|
1778
2553
|
}
|
|
1779
2554
|
var MAX_SEARCH_DEPTH = 5;
|
|
1780
2555
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
1781
|
-
let dir =
|
|
2556
|
+
let dir = path3__namespace.dirname(fileInPackage);
|
|
1782
2557
|
let packageJsonPath = null;
|
|
1783
2558
|
for (let i = 0; i < MAX_SEARCH_DEPTH; i++) {
|
|
1784
|
-
const candidate =
|
|
1785
|
-
if (
|
|
2559
|
+
const candidate = path3__namespace.join(dir, "package.json");
|
|
2560
|
+
if (fs2__namespace.existsSync(candidate)) {
|
|
1786
2561
|
packageJsonPath = candidate;
|
|
1787
2562
|
break;
|
|
1788
2563
|
}
|
|
1789
|
-
const parentDir =
|
|
2564
|
+
const parentDir = path3__namespace.dirname(dir);
|
|
1790
2565
|
if (parentDir === dir) break;
|
|
1791
2566
|
dir = parentDir;
|
|
1792
2567
|
}
|
|
1793
2568
|
if (!packageJsonPath) {
|
|
1794
2569
|
throw new Error(`Could not find a package.json within ${MAX_SEARCH_DEPTH} parent directories of ${fileInPackage}`);
|
|
1795
2570
|
}
|
|
1796
|
-
const packageJson = JSON.parse(
|
|
2571
|
+
const packageJson = JSON.parse(fs2__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
1797
2572
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
1798
2573
|
}
|
|
1799
|
-
function convertMappingValue(value) {
|
|
1800
|
-
switch (value.type) {
|
|
1801
|
-
case "uuid":
|
|
1802
|
-
return {
|
|
1803
|
-
type: "uniqueIdentifier",
|
|
1804
|
-
uniqueIdentifier: {
|
|
1805
|
-
linkId: value.linkId ?? crypto.randomUUID()
|
|
1806
|
-
}
|
|
1807
|
-
};
|
|
1808
|
-
case "currentTime":
|
|
1809
|
-
return {
|
|
1810
|
-
type: "currentTime",
|
|
1811
|
-
currentTime: {}
|
|
1812
|
-
};
|
|
1813
|
-
case "currentUser":
|
|
1814
|
-
return {
|
|
1815
|
-
type: "currentUser",
|
|
1816
|
-
currentUser: {}
|
|
1817
|
-
};
|
|
1818
|
-
default:
|
|
1819
|
-
return value;
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
2574
|
|
|
1823
2575
|
// src/api/action/ActionParameterType.ts
|
|
1824
2576
|
function isActionParameterTypePrimitive(type) {
|
|
@@ -1828,472 +2580,125 @@ function isActionParameterTypePrimitive(type) {
|
|
|
1828
2580
|
// src/api/defineAction.ts
|
|
1829
2581
|
var MODIFY_OBJECT_PARAMETER = "objectToModifyParameter";
|
|
1830
2582
|
var CREATE_OR_MODIFY_OBJECT_PARAMETER = "objectToCreateOrModifyParameter";
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
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`);
|
|
1835
2590
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
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
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
1876
|
-
}
|
|
1877
|
-
}))],
|
|
1878
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
1879
|
-
entities: {
|
|
1880
|
-
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: [],
|
|
1881
2630
|
affectedObjectTypes: [],
|
|
1882
2631
|
affectedLinkTypes: [],
|
|
1883
2632
|
typeGroups: []
|
|
1884
2633
|
},
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
1891
|
-
type: "parameterId",
|
|
1892
|
-
parameterId: id
|
|
1893
|
-
}]))
|
|
1894
|
-
}
|
|
1895
|
-
}],
|
|
1896
|
-
...def.validation ? {
|
|
1897
|
-
validation: convertValidationRule(def.validation)
|
|
1898
|
-
} : {}
|
|
1899
|
-
});
|
|
2634
|
+
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2635
|
+
};
|
|
2636
|
+
validateActionConfiguration(fullAction);
|
|
2637
|
+
updateOntology(fullAction);
|
|
2638
|
+
return fullAction;
|
|
1900
2639
|
}
|
|
1901
|
-
function
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
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)
|
|
1922
2660
|
},
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
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
|
+
}
|
|
1933
2677
|
},
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
1946
|
-
},
|
|
1947
|
-
...def.displayAndFormat && {
|
|
1948
|
-
displayAndFormat: def.displayAndFormat
|
|
1949
|
-
},
|
|
1950
|
-
...def.sections && {
|
|
1951
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
1952
|
-
},
|
|
1953
|
-
...def.submissionMetadata && {
|
|
1954
|
-
submissionMetadata: def.submissionMetadata
|
|
1955
|
-
}
|
|
1956
|
-
});
|
|
1957
|
-
}
|
|
1958
|
-
function defineModifyInterfaceObjectAction(def) {
|
|
1959
|
-
const allProperties = Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).filter(([_, prop]) => !isStruct(prop.sharedPropertyType.type) && !(def.excludedProperties ?? []).includes(prop.sharedPropertyType.nonNameSpacedApiName));
|
|
1960
|
-
if (allProperties.length !== Object.entries(getFlattenedInterfaceProperties(def.interfaceType)).length) {
|
|
1961
|
-
consola.consola.info(`Some properties on ${def.interfaceType.apiName} were skipped in the modify action because they are structs`);
|
|
1962
|
-
}
|
|
1963
|
-
return defineAction({
|
|
1964
|
-
apiName: `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`,
|
|
1965
|
-
displayName: `Modify ${def.interfaceType.displayMetadata.displayName}`,
|
|
1966
|
-
parameters: [{
|
|
1967
|
-
id: "interfaceObjectToModifyParameter",
|
|
1968
|
-
displayName: "Object type to modify",
|
|
1969
|
-
type: {
|
|
1970
|
-
type: "interfaceReference",
|
|
1971
|
-
interfaceReference: {
|
|
1972
|
-
interfaceTypeRid: def.interfaceType.apiName
|
|
1973
|
-
}
|
|
1974
|
-
},
|
|
1975
|
-
validation: {
|
|
1976
|
-
required: true,
|
|
1977
|
-
allowedValues: def.objectType === void 0 ? {
|
|
1978
|
-
type: "interfaceObjectQuery"
|
|
1979
|
-
} : {
|
|
1980
|
-
type: "oneOf",
|
|
1981
|
-
oneOf: [{
|
|
1982
|
-
label: def.objectType.displayName,
|
|
1983
|
-
value: {
|
|
1984
|
-
type: "objectType",
|
|
1985
|
-
objectType: {
|
|
1986
|
-
objectTypeId: def.objectType.apiName
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
}]
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
}, ...allProperties.map(([id, prop]) => ({
|
|
1993
|
-
id,
|
|
1994
|
-
displayName: prop.sharedPropertyType.displayName ?? prop.sharedPropertyType.nonNameSpacedApiName,
|
|
1995
|
-
type: extractActionParameterType(prop.sharedPropertyType),
|
|
1996
|
-
typeClasses: prop.sharedPropertyType.typeClasses ?? [],
|
|
1997
|
-
validation: {
|
|
1998
|
-
required: prop.sharedPropertyType.array ?? false ? {
|
|
1999
|
-
listLength: {}
|
|
2000
|
-
} : prop.required,
|
|
2001
|
-
allowedValues: extractAllowedValuesFromPropertyType(prop.sharedPropertyType.type)
|
|
2002
|
-
}
|
|
2003
|
-
}))],
|
|
2004
|
-
status: def.interfaceType.status.type !== "deprecated" ? def.interfaceType.status.type : def.interfaceType.status,
|
|
2005
|
-
entities: {
|
|
2006
|
-
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
2007
|
-
affectedObjectTypes: [],
|
|
2008
|
-
affectedLinkTypes: [],
|
|
2009
|
-
typeGroups: []
|
|
2010
|
-
},
|
|
2011
|
-
rules: [{
|
|
2012
|
-
type: "modifyInterfaceRule",
|
|
2013
|
-
modifyInterfaceRule: {
|
|
2014
|
-
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
2015
|
-
sharedPropertyValues: Object.fromEntries(allProperties.map(([id, _prop]) => [id, {
|
|
2016
|
-
type: "parameterId",
|
|
2017
|
-
parameterId: id
|
|
2018
|
-
}]))
|
|
2019
|
-
}
|
|
2020
|
-
}],
|
|
2021
|
-
...def.validation ? {
|
|
2022
|
-
validation: convertValidationRule(def.validation)
|
|
2023
|
-
} : {}
|
|
2024
|
-
});
|
|
2025
|
-
}
|
|
2026
|
-
function defineModifyObjectAction(def) {
|
|
2027
|
-
validateActionParameters(def);
|
|
2028
|
-
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);
|
|
2029
|
-
const parameterNames = new Set(propertyParameters);
|
|
2030
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2031
|
-
parameterNames.add(MODIFY_OBJECT_PARAMETER);
|
|
2032
|
-
const actionApiName = def.apiName ?? `modify-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2033
|
-
if (def.parameterOrdering) {
|
|
2034
|
-
if (!def.parameterOrdering.includes(MODIFY_OBJECT_PARAMETER)) {
|
|
2035
|
-
def.parameterOrdering = [MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2036
|
-
}
|
|
2037
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2038
|
-
}
|
|
2039
|
-
const parameters = createParameters(def, parameterNames);
|
|
2040
|
-
parameters.forEach((p) => {
|
|
2041
|
-
if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2042
|
-
p.defaultValue = {
|
|
2043
|
-
type: "objectParameterPropertyValue",
|
|
2044
|
-
objectParameterPropertyValue: {
|
|
2045
|
-
parameterId: MODIFY_OBJECT_PARAMETER,
|
|
2046
|
-
propertyTypeId: p.id
|
|
2047
|
-
}
|
|
2048
|
-
};
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2052
|
-
return defineAction({
|
|
2053
|
-
apiName: actionApiName,
|
|
2054
|
-
displayName: def.displayName ?? `Modify ${def.objectType.displayName}`,
|
|
2055
|
-
parameters,
|
|
2056
|
-
status: def.status ?? "active",
|
|
2057
|
-
rules: [{
|
|
2058
|
-
type: "modifyObjectRule",
|
|
2059
|
-
modifyObjectRule: {
|
|
2060
|
-
objectToModify: MODIFY_OBJECT_PARAMETER,
|
|
2061
|
-
propertyValues: {
|
|
2062
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2063
|
-
type: "parameterId",
|
|
2064
|
-
parameterId: p
|
|
2065
|
-
}])),
|
|
2066
|
-
...mappings
|
|
2067
|
-
},
|
|
2068
|
-
structFieldValues: {}
|
|
2069
|
-
}
|
|
2070
|
-
}],
|
|
2071
|
-
entities: {
|
|
2072
|
-
affectedInterfaceTypes: [],
|
|
2073
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2074
|
-
affectedLinkTypes: [],
|
|
2075
|
-
typeGroups: []
|
|
2076
|
-
},
|
|
2077
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
|
|
2078
|
-
...def.actionLevelValidation ? {
|
|
2079
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2080
|
-
} : {},
|
|
2081
|
-
...def.defaultFormat && {
|
|
2082
|
-
defaultFormat: def.defaultFormat
|
|
2083
|
-
},
|
|
2084
|
-
...def.enableLayoutSwitch && {
|
|
2085
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2086
|
-
},
|
|
2087
|
-
...def.displayAndFormat && {
|
|
2088
|
-
displayAndFormat: def.displayAndFormat
|
|
2089
|
-
},
|
|
2090
|
-
...def.sections && {
|
|
2091
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2092
|
-
},
|
|
2093
|
-
...def.submissionMetadata && {
|
|
2094
|
-
submissionMetadata: def.submissionMetadata
|
|
2095
|
-
}
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
|
-
function defineDeleteObjectAction(def) {
|
|
2099
|
-
return defineAction({
|
|
2100
|
-
apiName: def.apiName ?? `delete-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`,
|
|
2101
|
-
displayName: def.displayName ?? `Delete ${def.objectType.displayName}`,
|
|
2102
|
-
parameters: [{
|
|
2103
|
-
id: "objectToDeleteParameter",
|
|
2104
|
-
displayName: "Delete object",
|
|
2105
|
-
type: {
|
|
2106
|
-
type: "objectReference",
|
|
2107
|
-
objectReference: {
|
|
2108
|
-
objectTypeId: def.objectType.apiName
|
|
2109
|
-
}
|
|
2110
|
-
},
|
|
2111
|
-
validation: {
|
|
2112
|
-
required: true,
|
|
2113
|
-
allowedValues: {
|
|
2114
|
-
type: "objectQuery"
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
}],
|
|
2118
|
-
status: def.status ?? "active",
|
|
2119
|
-
rules: [{
|
|
2120
|
-
type: "deleteObjectRule",
|
|
2121
|
-
deleteObjectRule: {
|
|
2122
|
-
objectToDelete: "objectToDeleteParameter"
|
|
2123
|
-
}
|
|
2124
|
-
}],
|
|
2125
|
-
entities: {
|
|
2126
|
-
affectedInterfaceTypes: [],
|
|
2127
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2128
|
-
affectedLinkTypes: [],
|
|
2129
|
-
typeGroups: []
|
|
2130
|
-
},
|
|
2131
|
-
...def.actionLevelValidation ? {
|
|
2132
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2133
|
-
} : {}
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
function defineCreateOrModifyObjectAction(def) {
|
|
2137
|
-
validateActionParameters(def);
|
|
2138
|
-
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);
|
|
2139
|
-
const parameterNames = new Set(propertyParameters);
|
|
2140
|
-
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2141
|
-
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2142
|
-
const actionApiName = def.apiName ?? `create-or-modify-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
2143
|
-
if (def.parameterOrdering) {
|
|
2144
|
-
if (!def.parameterOrdering.includes(CREATE_OR_MODIFY_OBJECT_PARAMETER)) {
|
|
2145
|
-
def.parameterOrdering = [CREATE_OR_MODIFY_OBJECT_PARAMETER, ...def.parameterOrdering];
|
|
2146
|
-
}
|
|
2147
|
-
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2148
|
-
}
|
|
2149
|
-
const parameters = createParameters(def, parameterNames);
|
|
2150
|
-
parameters.forEach((p) => {
|
|
2151
|
-
if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === void 0) {
|
|
2152
|
-
p.defaultValue = {
|
|
2153
|
-
type: "objectParameterPropertyValue",
|
|
2154
|
-
objectParameterPropertyValue: {
|
|
2155
|
-
parameterId: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2156
|
-
propertyTypeId: p.id
|
|
2157
|
-
}
|
|
2158
|
-
};
|
|
2159
|
-
}
|
|
2160
|
-
});
|
|
2161
|
-
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2162
|
-
return defineAction({
|
|
2163
|
-
apiName: actionApiName,
|
|
2164
|
-
displayName: def.displayName ?? `Create or Modify ${def.objectType.displayName}`,
|
|
2165
|
-
parameters,
|
|
2166
|
-
status: def.status ?? "active",
|
|
2167
|
-
rules: [{
|
|
2168
|
-
type: "addOrModifyObjectRuleV2",
|
|
2169
|
-
addOrModifyObjectRuleV2: {
|
|
2170
|
-
objectToModify: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2171
|
-
propertyValues: {
|
|
2172
|
-
...Object.fromEntries(propertyParameters.map((p) => [p, {
|
|
2173
|
-
type: "parameterId",
|
|
2174
|
-
parameterId: p
|
|
2175
|
-
}])),
|
|
2176
|
-
...mappings
|
|
2177
|
-
},
|
|
2178
|
-
structFieldValues: {}
|
|
2179
|
-
}
|
|
2180
|
-
}],
|
|
2181
|
-
entities: {
|
|
2182
|
-
affectedInterfaceTypes: [],
|
|
2183
|
-
affectedObjectTypes: [def.objectType.apiName],
|
|
2184
|
-
affectedLinkTypes: [],
|
|
2185
|
-
typeGroups: []
|
|
2186
|
-
},
|
|
2187
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
|
|
2188
|
-
...def.actionLevelValidation ? {
|
|
2189
|
-
validation: convertValidationRule(def.actionLevelValidation)
|
|
2190
|
-
} : {},
|
|
2191
|
-
...def.defaultFormat && {
|
|
2192
|
-
defaultFormat: def.defaultFormat
|
|
2193
|
-
},
|
|
2194
|
-
...def.enableLayoutSwitch && {
|
|
2195
|
-
enableLayoutSwitch: def.enableLayoutSwitch
|
|
2196
|
-
},
|
|
2197
|
-
...def.displayAndFormat && {
|
|
2198
|
-
displayAndFormat: def.displayAndFormat
|
|
2199
|
-
},
|
|
2200
|
-
...def.sections && {
|
|
2201
|
-
sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
|
|
2202
|
-
},
|
|
2203
|
-
...def.submissionMetadata && {
|
|
2204
|
-
submissionMetadata: def.submissionMetadata
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
}
|
|
2208
|
-
function defineAction(actionDef) {
|
|
2209
|
-
const apiName = namespace + actionDef.apiName;
|
|
2210
|
-
const parameterIds = (actionDef.parameters ?? []).map((p) => p.id);
|
|
2211
|
-
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
2212
|
-
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
2213
|
-
}
|
|
2214
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Action type apiName "${actionDef.apiName}" must be alphanumeric, lowercase, and kebab-case`) : invariant5__default.default(false) : void 0;
|
|
2215
|
-
const parameterIdsSet = new Set(parameterIds);
|
|
2216
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Parameter ids must be unique`) : invariant5__default.default(false) : void 0;
|
|
2217
|
-
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
2218
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Parameters ${JSON.stringify(parameterIdsNotFound)} were referenced but not defined`) : invariant5__default.default(false) : void 0;
|
|
2219
|
-
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
2220
|
-
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
2221
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Sections [${undefinedSectionsInOrdering}] were referenced in content ordering but not defined`) : invariant5__default.default(false) : void 0;
|
|
2222
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Action type ${actionDef.apiName} must have at least one logic rule`) : invariant5__default.default(false) : void 0;
|
|
2223
|
-
actionDef.rules.forEach((rule) => {
|
|
2224
|
-
if (rule.type === "modifyObjectRule") {
|
|
2225
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Object to modify parameter must be defined in parameters`) : invariant5__default.default(false) : void 0;
|
|
2226
|
-
}
|
|
2227
|
-
if (rule.type === "deleteObjectRule") {
|
|
2228
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Object to delete parameter must be defined in parameters`) : invariant5__default.default(false) : void 0;
|
|
2229
|
-
}
|
|
2230
|
-
if (rule.type === "modifyInterfaceRule") {
|
|
2231
|
-
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
2232
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface object to modify parameter must be an interface reference`) : invariant5__default.default(false) : void 0;
|
|
2233
|
-
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
2234
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface type ${interfaceReference} does not exist`) : invariant5__default.default(false) : void 0;
|
|
2235
|
-
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
2236
|
-
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2237
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant5__default.default(false) : void 0;
|
|
2238
|
-
});
|
|
2239
|
-
}
|
|
2240
|
-
if (rule.type === "addInterfaceRule") {
|
|
2241
|
-
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
2242
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant5__default.default(false) : void 0;
|
|
2243
|
-
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
2244
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
});
|
|
2248
|
-
const fullAction = {
|
|
2249
|
-
...actionDef,
|
|
2250
|
-
apiName,
|
|
2251
|
-
entities: actionDef.entities ?? {
|
|
2252
|
-
affectedInterfaceTypes: [],
|
|
2253
|
-
affectedObjectTypes: [],
|
|
2254
|
-
affectedLinkTypes: [],
|
|
2255
|
-
typeGroups: []
|
|
2256
|
-
},
|
|
2257
|
-
__type: OntologyEntityTypeEnum.ACTION_TYPE
|
|
2258
|
-
};
|
|
2259
|
-
validateActionConfiguration(fullAction);
|
|
2260
|
-
updateOntology(fullAction);
|
|
2261
|
-
return fullAction;
|
|
2262
|
-
}
|
|
2263
|
-
function createParameters(def, parameterSet) {
|
|
2264
|
-
const targetParam = [];
|
|
2265
|
-
parameterSet.forEach((name) => {
|
|
2266
|
-
if (name === MODIFY_OBJECT_PARAMETER) {
|
|
2267
|
-
targetParam.push({
|
|
2268
|
-
id: MODIFY_OBJECT_PARAMETER,
|
|
2269
|
-
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Modify object",
|
|
2270
|
-
type: {
|
|
2271
|
-
type: "objectReference",
|
|
2272
|
-
objectReference: {
|
|
2273
|
-
objectTypeId: def.objectType.apiName
|
|
2274
|
-
}
|
|
2275
|
-
},
|
|
2276
|
-
validation: {
|
|
2277
|
-
...def.parameterConfiguration?.[name],
|
|
2278
|
-
allowedValues: {
|
|
2279
|
-
type: "objectQuery"
|
|
2280
|
-
},
|
|
2281
|
-
required: def.parameterConfiguration?.[name]?.required ?? true
|
|
2282
|
-
},
|
|
2283
|
-
defaultValue: def.parameterConfiguration?.[name]?.defaultValue,
|
|
2284
|
-
description: def.parameterConfiguration?.[name]?.description
|
|
2285
|
-
});
|
|
2286
|
-
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);
|
|
2287
2689
|
}
|
|
2288
2690
|
if (name === CREATE_OR_MODIFY_OBJECT_PARAMETER) {
|
|
2289
|
-
|
|
2691
|
+
targetParams.push({
|
|
2290
2692
|
id: CREATE_OR_MODIFY_OBJECT_PARAMETER,
|
|
2291
2693
|
displayName: def.parameterConfiguration?.[name]?.displayName ?? "Create or modify object",
|
|
2292
2694
|
type: {
|
|
2293
2695
|
type: "objectReference",
|
|
2294
2696
|
objectReference: {
|
|
2295
2697
|
objectTypeId: def.objectType.apiName,
|
|
2296
|
-
maybeCreateObjectOption: !
|
|
2698
|
+
maybeCreateObjectOption: !("primaryKeyOption" in def) ? {
|
|
2699
|
+
type: "autoGenerated",
|
|
2700
|
+
autoGenerated: {}
|
|
2701
|
+
} : def.primaryKeyOption === "autoGenerated" ? {
|
|
2297
2702
|
type: "autoGenerated",
|
|
2298
2703
|
autoGenerated: {}
|
|
2299
2704
|
} : {
|
|
@@ -2314,26 +2719,75 @@ function createParameters(def, parameterSet) {
|
|
|
2314
2719
|
});
|
|
2315
2720
|
parameterSet.delete(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
2316
2721
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
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;
|
|
2337
2791
|
}
|
|
2338
2792
|
function referencedParameterIds(actionDef) {
|
|
2339
2793
|
const parameterIds = /* @__PURE__ */ new Set();
|
|
@@ -2598,104 +3052,425 @@ function kebab(s) {
|
|
|
2598
3052
|
function sanitize(s) {
|
|
2599
3053
|
return s.includes(".") ? s : namespace + s;
|
|
2600
3054
|
}
|
|
2601
|
-
function convertValidationRule(actionValidation) {
|
|
3055
|
+
function convertValidationRule(actionValidation, actionParameters) {
|
|
2602
3056
|
return actionValidation.map((rule) => {
|
|
2603
3057
|
return {
|
|
2604
|
-
condition: convertConditionDefinition(rule.condition),
|
|
3058
|
+
condition: convertConditionDefinition(rule.condition, actionParameters),
|
|
2605
3059
|
displayMetadata: rule.displayMetadata ?? {
|
|
2606
3060
|
failureMessage: "Did not satisfy validation",
|
|
2607
3061
|
typeClasses: []
|
|
2608
3062
|
}
|
|
2609
|
-
};
|
|
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
|
+
}
|
|
2610
3391
|
});
|
|
2611
3392
|
}
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
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
|
+
}
|
|
2625
3428
|
});
|
|
2626
3429
|
}
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
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
|
+
}
|
|
2638
3450
|
}
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
3451
|
+
}],
|
|
3452
|
+
status: def.status ?? "active",
|
|
3453
|
+
rules: [{
|
|
3454
|
+
type: "deleteObjectRule",
|
|
3455
|
+
deleteObjectRule: {
|
|
3456
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2643
3457
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
throw new Error(`Unknown condition type on parameter ${currentParameterId}`);
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
function validateParameterPrefill(currentParameterId, seenParameterIds, parameters, defaultValue) {
|
|
2658
|
-
if (!defaultValue) return;
|
|
2659
|
-
switch (defaultValue.type) {
|
|
2660
|
-
case "objectParameterPropertyValue":
|
|
2661
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default value for parameter ${currentParameterId} is referencing unknown parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant5__default.default(false) : void 0;
|
|
2662
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default value for parameter ${currentParameterId} is referencing later parameter ${defaultValue.objectParameterPropertyValue.parameterId}`) : invariant5__default.default(false) : void 0;
|
|
2663
|
-
break;
|
|
2664
|
-
case "staticValue":
|
|
2665
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Default static value for parameter ${currentParameterId} does not match type`) : invariant5__default.default(false) : void 0;
|
|
2666
|
-
break;
|
|
2667
|
-
case "staticObject":
|
|
2668
|
-
case "interfaceParameterPropertyValue":
|
|
2669
|
-
case "objectQueryPrefill":
|
|
2670
|
-
case "objectQueryPropertyValue":
|
|
2671
|
-
case "objectSetRidPrefill":
|
|
2672
|
-
case "redacted":
|
|
2673
|
-
break;
|
|
2674
|
-
default:
|
|
2675
|
-
throw new Error(`Unknown default value type for parameter ${currentParameterId}`);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
function validateActionParameters(def) {
|
|
2679
|
-
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2680
|
-
!(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" ? invariant5__default.default(false, `Parameter ${id} does not exist as a property on ${def.objectType.apiName} and its type is not explicitly defined`) : invariant5__default.default(false) : void 0;
|
|
2681
|
-
});
|
|
2682
|
-
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2683
|
-
!(def.objectType.properties?.[id] !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Property ${id} does not exist as a property on ${def.objectType.apiName}`) : invariant5__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
|
+
} : {}
|
|
2684
3468
|
});
|
|
2685
3469
|
}
|
|
2686
|
-
function createDefaultParameterOrdering(def, parameters, priorityId) {
|
|
2687
|
-
return [...priorityId ? [priorityId] : [], ...Object.keys(def.parameterConfiguration ?? {}), ...Object.keys(def.objectType.properties ?? {}).filter((id) => !def.parameterConfiguration?.[id] && parameters.some((p) => p.id === id))];
|
|
2688
|
-
}
|
|
2689
|
-
function validateParameterOrdering(parameterOrdering, parameterSet, actionApiName) {
|
|
2690
|
-
const orderingSet = new Set(parameterOrdering);
|
|
2691
|
-
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2692
|
-
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2693
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Action parameter ordering for ${actionApiName} does not match expected parameters. Extraneous parameters in ordering: {${extraneousParameters}}, Missing parameters in ordering: {${missingParameters}}`) : invariant5__default.default(false) : void 0;
|
|
2694
|
-
}
|
|
2695
3470
|
function defineSharedPropertyType(sptDef) {
|
|
2696
3471
|
const apiName = namespace + sptDef.apiName;
|
|
2697
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2698
|
-
!(!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;
|
|
2699
3474
|
const fullSpt = {
|
|
2700
3475
|
...sptDef,
|
|
2701
3476
|
apiName,
|
|
@@ -2744,7 +3519,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
2744
3519
|
// src/api/defineInterface.ts
|
|
2745
3520
|
function defineInterface(interfaceDef) {
|
|
2746
3521
|
const apiName = namespace + interfaceDef.apiName;
|
|
2747
|
-
!(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;
|
|
2748
3523
|
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2749
3524
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2750
3525
|
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
@@ -2763,7 +3538,7 @@ function defineInterface(interfaceDef) {
|
|
|
2763
3538
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2764
3539
|
type: "active"
|
|
2765
3540
|
});
|
|
2766
|
-
!(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;
|
|
2767
3542
|
const fullInterface = {
|
|
2768
3543
|
apiName,
|
|
2769
3544
|
displayMetadata: {
|
|
@@ -2789,7 +3564,7 @@ function defineInterface(interfaceDef) {
|
|
|
2789
3564
|
}
|
|
2790
3565
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2791
3566
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2792
|
-
!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;
|
|
2793
3568
|
const spt = defineSharedPropertyType({
|
|
2794
3569
|
apiName,
|
|
2795
3570
|
displayName: apiName,
|
|
@@ -2799,16 +3574,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2799
3574
|
return spt;
|
|
2800
3575
|
} else {
|
|
2801
3576
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2802
|
-
!(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({
|
|
2803
3578
|
key: apiName,
|
|
2804
3579
|
apiName: type.apiName
|
|
2805
|
-
})}`) :
|
|
3580
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
2806
3581
|
return type;
|
|
2807
3582
|
}
|
|
2808
3583
|
}
|
|
2809
3584
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2810
3585
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2811
|
-
!(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;
|
|
2812
3587
|
linkDef.from.links.push({
|
|
2813
3588
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2814
3589
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2836,19 +3611,9 @@ function getLinkMeta(meta) {
|
|
|
2836
3611
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
2837
3612
|
};
|
|
2838
3613
|
}
|
|
2839
|
-
|
|
3614
|
+
|
|
3615
|
+
// src/api/defineLink.ts
|
|
2840
3616
|
function defineLink(linkDefinition) {
|
|
2841
|
-
if ("one" in linkDefinition) {
|
|
2842
|
-
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2843
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant5__default.default(false) : void 0;
|
|
2844
|
-
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__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`) : invariant5__default.default(false) : void 0;
|
|
2845
|
-
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2846
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant5__default.default(false) : void 0;
|
|
2847
|
-
}
|
|
2848
|
-
if ("intermediaryObjectType" in linkDefinition) {
|
|
2849
|
-
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2850
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`) : invariant5__default.default(false) : void 0;
|
|
2851
|
-
}
|
|
2852
3617
|
let fullLinkDefinition;
|
|
2853
3618
|
if ("one" in linkDefinition) {
|
|
2854
3619
|
fullLinkDefinition = {
|
|
@@ -2872,6 +3637,7 @@ function defineLink(linkDefinition) {
|
|
|
2872
3637
|
const linkType = {
|
|
2873
3638
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2874
3639
|
...fullLinkDefinition,
|
|
3640
|
+
apiName: linkDefinition.apiName,
|
|
2875
3641
|
__type: OntologyEntityTypeEnum.LINK_TYPE
|
|
2876
3642
|
};
|
|
2877
3643
|
updateOntology(linkType);
|
|
@@ -2907,6 +3673,148 @@ function convertLinkTypeMetadata(metadata) {
|
|
|
2907
3673
|
typeClasses: []
|
|
2908
3674
|
};
|
|
2909
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
|
+
}
|
|
2910
3818
|
function convertValueTypeTypeToBaseType(valueType) {
|
|
2911
3819
|
switch (true) {
|
|
2912
3820
|
case (typeof valueType === "object" && valueType.type === "array"):
|
|
@@ -2959,7 +3867,7 @@ function defineValueType(valueTypeDef) {
|
|
|
2959
3867
|
version
|
|
2960
3868
|
} = valueTypeDef;
|
|
2961
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-]+)*))?)$/;
|
|
2962
|
-
!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;
|
|
2963
3871
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
2964
3872
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
2965
3873
|
const output = {
|
|
@@ -3015,8 +3923,8 @@ function importSharedPropertyType(opts) {
|
|
|
3015
3923
|
} = opts;
|
|
3016
3924
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3017
3925
|
if (packageName !== void 0) {
|
|
3018
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
3019
|
-
!(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;
|
|
3020
3928
|
}
|
|
3021
3929
|
const spt = {
|
|
3022
3930
|
apiName: fullApiName,
|
|
@@ -3038,8 +3946,18 @@ function wrapWithProxy(entity) {
|
|
|
3038
3946
|
}
|
|
3039
3947
|
});
|
|
3040
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
|
+
*/
|
|
3041
3957
|
|
|
3958
|
+
exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
|
|
3042
3959
|
exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;
|
|
3960
|
+
exports.MODIFY_INTERFACE_OBJECT_PARAMETER = MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
3043
3961
|
exports.MODIFY_OBJECT_PARAMETER = MODIFY_OBJECT_PARAMETER;
|
|
3044
3962
|
exports.OntologyEntityTypeEnum = OntologyEntityTypeEnum;
|
|
3045
3963
|
exports.addDependency = addDependency;
|
|
@@ -3052,6 +3970,7 @@ exports.defineAction = defineAction;
|
|
|
3052
3970
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
3053
3971
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
3054
3972
|
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
3973
|
+
exports.defineDeleteInterfaceObjectAction = defineDeleteInterfaceObjectAction;
|
|
3055
3974
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
3056
3975
|
exports.defineInterface = defineInterface;
|
|
3057
3976
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|