@osdk/maker 0.14.0-beta.6 → 0.14.0-beta.7
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 +11 -0
- package/README.md +86 -22
- package/build/browser/api/defineCreateObjectAction.js +3 -1
- package/build/browser/api/defineCreateObjectAction.js.map +1 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js +2 -1
- package/build/browser/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/browser/api/defineDeleteInterfaceObjectAction.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/defineObject.js +94 -3
- package/build/browser/api/defineObject.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 +788 -2
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/objects.test.js +1109 -12
- package/build/browser/api/test/objects.test.js.map +1 -1
- package/build/browser/cli/main.js +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/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +442 -194
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +139 -99
- package/build/esm/api/defineCreateObjectAction.js +3 -1
- package/build/esm/api/defineCreateObjectAction.js.map +1 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js +2 -1
- package/build/esm/api/defineCreateOrModifyObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +53 -0
- package/build/esm/api/defineDeleteInterfaceObjectAction.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/defineObject.js +94 -3
- package/build/esm/api/defineObject.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 +788 -2
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/objects.test.js +1109 -12
- package/build/esm/api/test/objects.test.js.map +1 -1
- package/build/esm/cli/main.js +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/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/types/api/defineCreateObjectAction.d.ts.map +1 -1
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts +3 -0
- package/build/types/api/defineDeleteInterfaceObjectAction.d.ts.map +1 -0
- package/build/types/api/defineLink.d.ts.map +1 -1
- package/build/types/api/defineObject.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/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/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
package/build/cjs/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var consola = require('consola');
|
|
6
6
|
var fs2 = require('fs/promises');
|
|
7
7
|
var path2 = require('path');
|
|
8
|
-
var
|
|
8
|
+
var invariant7 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
11
|
var fs = require('fs');
|
|
@@ -33,7 +33,7 @@ function _interopNamespace(e) {
|
|
|
33
33
|
|
|
34
34
|
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
35
35
|
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
36
|
-
var
|
|
36
|
+
var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
|
|
37
37
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
38
38
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
39
39
|
|
|
@@ -66,6 +66,193 @@ var OntologyEntityTypeEnum = /* @__PURE__ */ (function(OntologyEntityTypeEnum2)
|
|
|
66
66
|
return OntologyEntityTypeEnum2;
|
|
67
67
|
})({});
|
|
68
68
|
|
|
69
|
+
// src/conversion/toMarketplace/convertCardinality.ts
|
|
70
|
+
function convertCardinality(cardinality) {
|
|
71
|
+
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
72
|
+
return "ONE_TO_MANY";
|
|
73
|
+
}
|
|
74
|
+
return "ONE_TO_ONE";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/conversion/toMarketplace/convertLink.ts
|
|
78
|
+
function convertLink(linkType) {
|
|
79
|
+
validateLink(linkType);
|
|
80
|
+
let definition;
|
|
81
|
+
let datasource = void 0;
|
|
82
|
+
if ("one" in linkType) {
|
|
83
|
+
const {
|
|
84
|
+
apiName: oneObjectApiName,
|
|
85
|
+
object: oneObject
|
|
86
|
+
} = getObject(linkType.one.object);
|
|
87
|
+
const {
|
|
88
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
89
|
+
definition = {
|
|
90
|
+
type: "oneToMany",
|
|
91
|
+
oneToMany: {
|
|
92
|
+
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
93
|
+
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
94
|
+
objectTypeRidManySide: toManyObjectApiName,
|
|
95
|
+
objectTypeRidOneSide: oneObjectApiName,
|
|
96
|
+
oneToManyLinkMetadata: linkType.one.metadata,
|
|
97
|
+
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
98
|
+
from: {
|
|
99
|
+
apiName: oneObject.primaryKeyPropertyApiName,
|
|
100
|
+
object: oneObjectApiName
|
|
101
|
+
},
|
|
102
|
+
to: {
|
|
103
|
+
apiName: linkType.manyForeignKeyProperty,
|
|
104
|
+
object: toManyObjectApiName
|
|
105
|
+
}
|
|
106
|
+
}]
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
} else if ("intermediaryObjectType" in linkType) {
|
|
110
|
+
const {
|
|
111
|
+
apiName: manyObjectApiName} = getObject(linkType.many.object);
|
|
112
|
+
const {
|
|
113
|
+
apiName: toManyObjectApiName} = getObject(linkType.toMany.object);
|
|
114
|
+
definition = {
|
|
115
|
+
type: "intermediary",
|
|
116
|
+
intermediary: {
|
|
117
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
118
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
119
|
+
objectTypeRidA: manyObjectApiName,
|
|
120
|
+
objectTypeRidB: toManyObjectApiName,
|
|
121
|
+
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
122
|
+
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
123
|
+
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
} else {
|
|
127
|
+
const {
|
|
128
|
+
apiName: manyObjectApiName,
|
|
129
|
+
object: manyObject
|
|
130
|
+
} = getObject(linkType.many.object);
|
|
131
|
+
const {
|
|
132
|
+
apiName: toManyObjectApiName,
|
|
133
|
+
object: toManyObject
|
|
134
|
+
} = getObject(linkType.toMany.object);
|
|
135
|
+
definition = {
|
|
136
|
+
type: "manyToMany",
|
|
137
|
+
manyToMany: {
|
|
138
|
+
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
139
|
+
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
140
|
+
objectTypeRidA: manyObjectApiName,
|
|
141
|
+
objectTypeRidB: toManyObjectApiName,
|
|
142
|
+
peeringMetadata: void 0,
|
|
143
|
+
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
144
|
+
from: {
|
|
145
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
146
|
+
object: manyObjectApiName
|
|
147
|
+
},
|
|
148
|
+
to: {
|
|
149
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
150
|
+
object: manyObjectApiName
|
|
151
|
+
}
|
|
152
|
+
}],
|
|
153
|
+
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
154
|
+
from: {
|
|
155
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
156
|
+
object: toManyObjectApiName
|
|
157
|
+
},
|
|
158
|
+
to: {
|
|
159
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
160
|
+
object: toManyObjectApiName
|
|
161
|
+
}
|
|
162
|
+
}]
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
datasource = {
|
|
166
|
+
datasourceName: linkType.apiName,
|
|
167
|
+
datasource: {
|
|
168
|
+
type: "dataset",
|
|
169
|
+
dataset: {
|
|
170
|
+
datasetRid: "link-".concat(linkType.apiName),
|
|
171
|
+
writebackDatasetRid: void 0,
|
|
172
|
+
objectTypeAPrimaryKeyMapping: [{
|
|
173
|
+
property: {
|
|
174
|
+
apiName: manyObject.primaryKeyPropertyApiName,
|
|
175
|
+
object: manyObjectApiName
|
|
176
|
+
},
|
|
177
|
+
column: manyObject.primaryKeyPropertyApiName
|
|
178
|
+
}],
|
|
179
|
+
objectTypeBPrimaryKeyMapping: [{
|
|
180
|
+
property: {
|
|
181
|
+
apiName: toManyObject.primaryKeyPropertyApiName,
|
|
182
|
+
object: toManyObjectApiName
|
|
183
|
+
},
|
|
184
|
+
column: toManyObject.primaryKeyPropertyApiName
|
|
185
|
+
}]
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
editsConfiguration: {
|
|
189
|
+
onlyAllowPrivilegedEdits: false
|
|
190
|
+
},
|
|
191
|
+
redacted: linkType.redacted
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
linkType: {
|
|
196
|
+
definition,
|
|
197
|
+
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
198
|
+
status: linkType.status ?? {
|
|
199
|
+
type: "active",
|
|
200
|
+
active: {}
|
|
201
|
+
},
|
|
202
|
+
redacted: linkType.redacted ?? false
|
|
203
|
+
},
|
|
204
|
+
datasources: datasource !== void 0 ? [datasource] : [],
|
|
205
|
+
entityMetadata: {
|
|
206
|
+
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function validateLink(linkDefinition) {
|
|
211
|
+
if ("one" in linkDefinition) {
|
|
212
|
+
const {
|
|
213
|
+
object: oneObject
|
|
214
|
+
} = getObject(linkDefinition.one.object);
|
|
215
|
+
const {
|
|
216
|
+
apiName: toManyObjectApiName,
|
|
217
|
+
object: toManyObject
|
|
218
|
+
} = getObject(linkDefinition.toMany.object);
|
|
219
|
+
const foreignKey = toManyObject.properties?.find((p) => p.apiName === linkDefinition.manyForeignKeyProperty);
|
|
220
|
+
!(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;
|
|
221
|
+
!/([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;
|
|
222
|
+
const typesMatch = foreignKey.type === oneObject.properties?.find((p) => p.apiName === oneObject.primaryKeyPropertyApiName)?.type;
|
|
223
|
+
!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;
|
|
224
|
+
}
|
|
225
|
+
if ("intermediaryObjectType" in linkDefinition) {
|
|
226
|
+
const {
|
|
227
|
+
apiName: intermediaryObjectTypeApiName} = getObject(linkDefinition.intermediaryObjectType);
|
|
228
|
+
const {
|
|
229
|
+
apiName: manyObjectApiName,
|
|
230
|
+
object: manyObject
|
|
231
|
+
} = getObject(linkDefinition.many.object);
|
|
232
|
+
const {
|
|
233
|
+
apiName: toManyObjectApiName} = getObject(linkDefinition.toMany.object);
|
|
234
|
+
const {
|
|
235
|
+
apiName: manyIntermediaryOneObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.one.object);
|
|
236
|
+
const {
|
|
237
|
+
apiName: manyIntermediaryToManyObjectApiName} = getObject(linkDefinition.many.linkToIntermediary.toMany.object);
|
|
238
|
+
!("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;
|
|
239
|
+
const {
|
|
240
|
+
apiName: toManyIntermediaryOneObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.one.object);
|
|
241
|
+
const {
|
|
242
|
+
apiName: toManyIntermediaryToManyObjectApiName} = getObject(linkDefinition.toMany.linkToIntermediary.toMany.object);
|
|
243
|
+
!("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;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function getObject(object) {
|
|
247
|
+
const objectApiName = typeof object === "string" ? object : object.apiName;
|
|
248
|
+
const fullObject = ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][objectApiName];
|
|
249
|
+
!(fullObject !== void 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Object ${objectApiName} is not defined`) : invariant7__default.default(false) : void 0;
|
|
250
|
+
return {
|
|
251
|
+
apiName: objectApiName,
|
|
252
|
+
object: fullObject
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
69
256
|
// src/api/interface/getFlattenedInterfaceProperties.ts
|
|
70
257
|
function getFlattenedInterfaceProperties(interfaceType) {
|
|
71
258
|
let properties = interfaceType.propertiesV2;
|
|
@@ -107,12 +294,20 @@ function defineObject(objectDef) {
|
|
|
107
294
|
if (ontologyDefinition[OntologyEntityTypeEnum.OBJECT_TYPE][apiName] !== void 0) {
|
|
108
295
|
throw new Error(`Object type with apiName ${objectDef.apiName} is already defined`);
|
|
109
296
|
}
|
|
110
|
-
!API_NAME_PATTERN.test(objectDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
111
|
-
!propertyApiNames.includes(objectDef.titlePropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
112
|
-
!propertyApiNames.includes(objectDef.primaryKeyPropertyApiName) ? process.env.NODE_ENV !== "production" ?
|
|
113
|
-
!!objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.editOnly ? process.env.NODE_ENV !== "production" ?
|
|
114
|
-
const
|
|
115
|
-
|
|
297
|
+
!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;
|
|
298
|
+
!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;
|
|
299
|
+
!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;
|
|
300
|
+
!!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;
|
|
301
|
+
const retentionPeriods = (objectDef.datasources ?? []).filter((ds) => ds.type === "stream").map((ds) => ds.retentionPeriod);
|
|
302
|
+
retentionPeriods.forEach((retentionPeriod) => {
|
|
303
|
+
!(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;
|
|
304
|
+
});
|
|
305
|
+
const baseDatasources = (objectDef.datasources ?? []).filter((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
306
|
+
!(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;
|
|
307
|
+
const derivedDatasources = (objectDef.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
308
|
+
if (derivedDatasources.length > 0) {
|
|
309
|
+
derivedDatasources.forEach((ds) => validateDerivedDatasource(objectDef, ds));
|
|
310
|
+
}
|
|
116
311
|
if (objectDef.status === "experimental") {
|
|
117
312
|
const activeProperties = [];
|
|
118
313
|
Object.entries(objectDef.properties ?? {}).forEach(([apiName2, property]) => {
|
|
@@ -120,14 +315,14 @@ function defineObject(objectDef) {
|
|
|
120
315
|
activeProperties.push(apiName2);
|
|
121
316
|
}
|
|
122
317
|
});
|
|
123
|
-
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
318
|
+
!(activeProperties.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `When object "${objectDef.apiName}" has experimental status, no properties can have "active" status, but found active properties: ${activeProperties.join(", ")}`) : invariant7__default.default(false) : void 0;
|
|
124
319
|
}
|
|
125
320
|
if (objectDef.status && typeof objectDef.status === "object" && objectDef.status.type === "deprecated") {
|
|
126
321
|
const deadline = objectDef.status.deadline;
|
|
127
|
-
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ?
|
|
322
|
+
!(deadline !== void 0 && ISO_8601_DATETIME.test(deadline)) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Deprecated status deadline "${deadline}" on object "${objectDef.apiName}" is not a valid ISO 8601 datetime string`) : invariant7__default.default(false) : void 0;
|
|
128
323
|
}
|
|
129
|
-
!!isExotic(objectDef.properties?.[objectDef.titlePropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
130
|
-
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ?
|
|
324
|
+
!!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;
|
|
325
|
+
!!isExotic(objectDef.properties?.[objectDef.primaryKeyPropertyApiName]?.type) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Primary key property ${objectDef.primaryKeyPropertyApiName} can only be primitive types`) : invariant7__default.default(false) : void 0;
|
|
131
326
|
objectDef.implementsInterfaces?.forEach((interfaceImpl) => {
|
|
132
327
|
const allInterfaceProperties = getFlattenedInterfaceProperties(interfaceImpl.implements);
|
|
133
328
|
const nonExistentInterfaceProperties = interfaceImpl.propertyMapping.map((val) => val.interfaceProperty).filter((interfaceProperty) => allInterfaceProperties[addNamespaceIfNone(interfaceProperty)] === void 0).map((interfaceProp) => ({
|
|
@@ -146,7 +341,7 @@ function defineObject(objectDef) {
|
|
|
146
341
|
};
|
|
147
342
|
const validations = Object.entries(getFlattenedInterfaceProperties(interfaceImpl.implements)).map(validateProperty);
|
|
148
343
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
149
|
-
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
344
|
+
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant7__default.default(false) : void 0;
|
|
150
345
|
});
|
|
151
346
|
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
|
|
152
347
|
const finalObject = {
|
|
@@ -197,6 +392,72 @@ function convertUserObjectPropertyType(apiName, property) {
|
|
|
197
392
|
type: property.type
|
|
198
393
|
};
|
|
199
394
|
}
|
|
395
|
+
function validateDerivedDatasource(objectDef, datasource) {
|
|
396
|
+
!(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;
|
|
397
|
+
datasource.linkDefinition.forEach((link) => {
|
|
398
|
+
const linkApiName = link.linkType.apiName;
|
|
399
|
+
!(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;
|
|
400
|
+
});
|
|
401
|
+
Object.keys(datasource.propertyMapping).forEach((prop) => {
|
|
402
|
+
!(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;
|
|
403
|
+
});
|
|
404
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
405
|
+
if (isLinkedProperties) {
|
|
406
|
+
validateLinkedProperties(datasource);
|
|
407
|
+
} else {
|
|
408
|
+
validateAggregations(datasource, objectDef);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function validateLinkedProperties(datasource, objectDef) {
|
|
412
|
+
const foreignProperties = Object.values(datasource.propertyMapping);
|
|
413
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
414
|
+
foreignProperties.forEach((prop) => {
|
|
415
|
+
!(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;
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function validateAggregations(datasource, objectDef) {
|
|
419
|
+
const props = datasource.propertyMapping;
|
|
420
|
+
Object.entries(props).forEach(([propName, agg]) => {
|
|
421
|
+
const property = objectDef.properties[propName];
|
|
422
|
+
switch (agg.type) {
|
|
423
|
+
case "collectList":
|
|
424
|
+
case "collectSet":
|
|
425
|
+
!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;
|
|
426
|
+
!(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;
|
|
427
|
+
break;
|
|
428
|
+
case "avg":
|
|
429
|
+
case "sum":
|
|
430
|
+
!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;
|
|
431
|
+
break;
|
|
432
|
+
case "min":
|
|
433
|
+
case "max":
|
|
434
|
+
case "approximateCardinality":
|
|
435
|
+
case "exactCardinality":
|
|
436
|
+
!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;
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
if (agg.type !== "count") {
|
|
440
|
+
const foreignProperty = agg.property;
|
|
441
|
+
const finalObject = getObject(datasource.linkDefinition.at(-1).linkType.toMany.object).object;
|
|
442
|
+
!(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;
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
function isCollectible(property) {
|
|
447
|
+
if (!(property.array ?? false)) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
const typeType = typeof property.type === "string" ? property.type : property.type.type;
|
|
451
|
+
return ["boolean", "byte", "date", "double", "float", "geohash", "geoshape", "integer", "long", "mediareference", "short", "string", "struct", "timestamp"].includes(typeType);
|
|
452
|
+
}
|
|
453
|
+
function isNumeric(type) {
|
|
454
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
455
|
+
return ["byte", "double", "float", "integer", "long", "short"].includes(typeType);
|
|
456
|
+
}
|
|
457
|
+
function isPrimitive(type) {
|
|
458
|
+
const typeType = typeof type === "string" ? type : type.type;
|
|
459
|
+
return ["boolean", "byte", "date", "double", "float", "integer", "long", "short", "string", "timestamp"].includes(typeType);
|
|
460
|
+
}
|
|
200
461
|
|
|
201
462
|
// src/conversion/toMarketplace/convertActionSections.ts
|
|
202
463
|
function convertActionSections(action) {
|
|
@@ -278,7 +539,7 @@ function convertConditionDefinition(condition, actionParameters) {
|
|
|
278
539
|
}
|
|
279
540
|
};
|
|
280
541
|
case "parameter":
|
|
281
|
-
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
542
|
+
!actionParameters?.some((param) => param.id === condition.parameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Action parameter condition references unknown parameter ${condition.parameterId}`) : invariant7__default.default(false) : void 0;
|
|
282
543
|
return {
|
|
283
544
|
type: "comparison",
|
|
284
545
|
comparison: {
|
|
@@ -496,7 +757,7 @@ function convertNullabilityToDataConstraint(prop) {
|
|
|
496
757
|
}
|
|
497
758
|
};
|
|
498
759
|
}
|
|
499
|
-
!prop.nullability?.noNulls ? process.env.NODE_ENV !== "production" ?
|
|
760
|
+
!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;
|
|
500
761
|
return {
|
|
501
762
|
propertyTypeConstraints: [],
|
|
502
763
|
nullability: void 0,
|
|
@@ -700,134 +961,12 @@ function convertInterface(interfaceType) {
|
|
|
700
961
|
};
|
|
701
962
|
}
|
|
702
963
|
|
|
703
|
-
// src/conversion/toMarketplace/convertCardinality.ts
|
|
704
|
-
function convertCardinality(cardinality) {
|
|
705
|
-
if (cardinality === "OneToMany" || cardinality === void 0) {
|
|
706
|
-
return "ONE_TO_MANY";
|
|
707
|
-
}
|
|
708
|
-
return "ONE_TO_ONE";
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// src/conversion/toMarketplace/convertLink.ts
|
|
712
|
-
function convertLink(linkType) {
|
|
713
|
-
let definition;
|
|
714
|
-
let datasource = void 0;
|
|
715
|
-
if ("one" in linkType) {
|
|
716
|
-
definition = {
|
|
717
|
-
type: "oneToMany",
|
|
718
|
-
oneToMany: {
|
|
719
|
-
cardinalityHint: convertCardinality(linkType.cardinality),
|
|
720
|
-
manyToOneLinkMetadata: linkType.toMany.metadata,
|
|
721
|
-
objectTypeRidManySide: linkType.toMany.object.apiName,
|
|
722
|
-
objectTypeRidOneSide: linkType.one.object.apiName,
|
|
723
|
-
oneToManyLinkMetadata: linkType.one.metadata,
|
|
724
|
-
oneSidePrimaryKeyToManySidePropertyMapping: [{
|
|
725
|
-
from: {
|
|
726
|
-
apiName: linkType.one.object.primaryKeyPropertyApiName,
|
|
727
|
-
object: linkType.one.object.apiName
|
|
728
|
-
},
|
|
729
|
-
to: {
|
|
730
|
-
apiName: linkType.manyForeignKeyProperty,
|
|
731
|
-
object: linkType.toMany.object.apiName
|
|
732
|
-
}
|
|
733
|
-
}]
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
} else if ("intermediaryObjectType" in linkType) {
|
|
737
|
-
definition = {
|
|
738
|
-
type: "intermediary",
|
|
739
|
-
intermediary: {
|
|
740
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
741
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
742
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
743
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
744
|
-
intermediaryObjectTypeRid: linkType.intermediaryObjectType.apiName,
|
|
745
|
-
aToIntermediaryLinkTypeRid: cleanAndValidateLinkTypeId(linkType.many.linkToIntermediary.apiName),
|
|
746
|
-
intermediaryToBLinkTypeRid: cleanAndValidateLinkTypeId(linkType.toMany.linkToIntermediary.apiName)
|
|
747
|
-
}
|
|
748
|
-
};
|
|
749
|
-
} else {
|
|
750
|
-
definition = {
|
|
751
|
-
type: "manyToMany",
|
|
752
|
-
manyToMany: {
|
|
753
|
-
objectTypeAToBLinkMetadata: linkType.many.metadata,
|
|
754
|
-
objectTypeBToALinkMetadata: linkType.toMany.metadata,
|
|
755
|
-
objectTypeRidA: linkType.many.object.apiName,
|
|
756
|
-
objectTypeRidB: linkType.toMany.object.apiName,
|
|
757
|
-
peeringMetadata: void 0,
|
|
758
|
-
objectTypeAPrimaryKeyPropertyMapping: [{
|
|
759
|
-
from: {
|
|
760
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
761
|
-
object: linkType.many.object.apiName
|
|
762
|
-
},
|
|
763
|
-
to: {
|
|
764
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
765
|
-
object: linkType.many.object.apiName
|
|
766
|
-
}
|
|
767
|
-
}],
|
|
768
|
-
objectTypeBPrimaryKeyPropertyMapping: [{
|
|
769
|
-
from: {
|
|
770
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
771
|
-
object: linkType.toMany.object.apiName
|
|
772
|
-
},
|
|
773
|
-
to: {
|
|
774
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
775
|
-
object: linkType.toMany.object.apiName
|
|
776
|
-
}
|
|
777
|
-
}]
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
datasource = {
|
|
781
|
-
datasourceName: linkType.apiName,
|
|
782
|
-
datasource: {
|
|
783
|
-
type: "dataset",
|
|
784
|
-
dataset: {
|
|
785
|
-
datasetRid: "link-".concat(linkType.apiName),
|
|
786
|
-
writebackDatasetRid: void 0,
|
|
787
|
-
objectTypeAPrimaryKeyMapping: [{
|
|
788
|
-
property: {
|
|
789
|
-
apiName: linkType.many.object.primaryKeyPropertyApiName,
|
|
790
|
-
object: linkType.many.object.apiName
|
|
791
|
-
},
|
|
792
|
-
column: linkType.many.object.primaryKeyPropertyApiName
|
|
793
|
-
}],
|
|
794
|
-
objectTypeBPrimaryKeyMapping: [{
|
|
795
|
-
property: {
|
|
796
|
-
apiName: linkType.toMany.object.primaryKeyPropertyApiName,
|
|
797
|
-
object: linkType.toMany.object.apiName
|
|
798
|
-
},
|
|
799
|
-
column: linkType.toMany.object.primaryKeyPropertyApiName
|
|
800
|
-
}]
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
editsConfiguration: {
|
|
804
|
-
onlyAllowPrivilegedEdits: false
|
|
805
|
-
},
|
|
806
|
-
redacted: linkType.redacted
|
|
807
|
-
};
|
|
808
|
-
}
|
|
809
|
-
return {
|
|
810
|
-
linkType: {
|
|
811
|
-
definition,
|
|
812
|
-
id: cleanAndValidateLinkTypeId(linkType.apiName),
|
|
813
|
-
status: linkType.status ?? {
|
|
814
|
-
type: "active",
|
|
815
|
-
active: {}
|
|
816
|
-
},
|
|
817
|
-
redacted: linkType.redacted ?? false
|
|
818
|
-
},
|
|
819
|
-
datasources: datasource !== void 0 ? [datasource] : [],
|
|
820
|
-
entityMetadata: {
|
|
821
|
-
arePatchesEnabled: linkType.editsEnabled ?? false
|
|
822
|
-
}
|
|
823
|
-
};
|
|
824
|
-
}
|
|
825
|
-
|
|
826
964
|
// src/conversion/toMarketplace/convertDatasourceDefinition.ts
|
|
827
965
|
function convertDatasourceDefinition(objectType, properties) {
|
|
828
|
-
|
|
966
|
+
const baseDatasource = objectType.datasources?.find((ds) => ["dataset", "stream", "restrictedView"].includes(ds.type));
|
|
967
|
+
switch (baseDatasource?.type) {
|
|
829
968
|
case "stream":
|
|
830
|
-
const window =
|
|
969
|
+
const window = baseDatasource.retentionPeriod;
|
|
831
970
|
const retentionPolicy = window ? {
|
|
832
971
|
type: "time",
|
|
833
972
|
time: {
|
|
@@ -1016,7 +1155,7 @@ function convertValueTypeDataConstraints(dataConstraints) {
|
|
|
1016
1155
|
// src/conversion/toMarketplace/convertObjectPropertyType.ts
|
|
1017
1156
|
function convertObjectPropertyType(property) {
|
|
1018
1157
|
const apiName = namespace + property.apiName;
|
|
1019
|
-
!(!shouldNotHaveRenderHints(property.type) || !hasRenderHints(property.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
1158
|
+
!(!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;
|
|
1020
1159
|
const output = {
|
|
1021
1160
|
apiName: property.apiName,
|
|
1022
1161
|
sharedPropertyTypeApiName: property.sharedPropertyType?.apiName,
|
|
@@ -1046,12 +1185,16 @@ function convertObjectPropertyType(property) {
|
|
|
1046
1185
|
|
|
1047
1186
|
// src/conversion/toMarketplace/convertObject.ts
|
|
1048
1187
|
function convertObject(objectType) {
|
|
1049
|
-
const
|
|
1188
|
+
const {
|
|
1189
|
+
derivedDatasources,
|
|
1190
|
+
derivedPropertyNames
|
|
1191
|
+
} = extractDerivedDatasources(objectType);
|
|
1192
|
+
const propertyDatasources = (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName)).flatMap((prop) => extractPropertyDatasource(prop, objectType.apiName));
|
|
1050
1193
|
const classificationGroupMarkingNames = extractMarkingGroups(objectType.properties ?? [], "CBAC");
|
|
1051
1194
|
const mandatoryMarkingNames = extractMarkingGroups(objectType.properties ?? [], "MANDATORY");
|
|
1052
1195
|
const classificationInputGroup = classificationGroupMarkingNames.length > 0 ? classificationGroupMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1053
1196
|
const mandatoryInputGroup = mandatoryMarkingNames.length > 0 ? mandatoryMarkingNames.reduce((l, r) => l + "/" + r) : void 0;
|
|
1054
|
-
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, objectType.properties ?? []), classificationInputGroup, mandatoryInputGroup);
|
|
1197
|
+
const objectDatasource = buildDatasource(objectType.apiName, convertDatasourceDefinition(objectType, (objectType.properties ?? []).filter((prop) => !derivedPropertyNames.includes(prop.apiName))), classificationInputGroup, mandatoryInputGroup);
|
|
1055
1198
|
const implementations = objectType.implementsInterfaces ?? [];
|
|
1056
1199
|
return {
|
|
1057
1200
|
objectType: {
|
|
@@ -1085,7 +1228,7 @@ function convertObject(objectType) {
|
|
|
1085
1228
|
})),
|
|
1086
1229
|
allImplementsInterfaces: {}
|
|
1087
1230
|
},
|
|
1088
|
-
datasources: [...propertyDatasources, objectDatasource],
|
|
1231
|
+
datasources: [...propertyDatasources, ...derivedDatasources, objectDatasource],
|
|
1089
1232
|
entityMetadata: {
|
|
1090
1233
|
arePatchesEnabled: objectType.editsEnabled ?? false
|
|
1091
1234
|
}
|
|
@@ -1128,6 +1271,80 @@ function extractPropertyDatasource(property, objectTypeApiName) {
|
|
|
1128
1271
|
return [];
|
|
1129
1272
|
}
|
|
1130
1273
|
}
|
|
1274
|
+
function extractDerivedDatasources(objectType) {
|
|
1275
|
+
const inputDerivedDatasources = (objectType.datasources ?? []).filter((ds) => ds.type === "derived");
|
|
1276
|
+
const derivedDatasources = inputDerivedDatasources.map((ds, i) => buildDerivedDatasource(ds, i, objectType.apiName));
|
|
1277
|
+
const derivedPropertyNames = inputDerivedDatasources.flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
1278
|
+
return {
|
|
1279
|
+
derivedDatasources,
|
|
1280
|
+
derivedPropertyNames
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
function buildDerivedDatasource(datasource, index, objectTypeApiName) {
|
|
1284
|
+
const linkDefinition = {
|
|
1285
|
+
type: "multiHopLink",
|
|
1286
|
+
multiHopLink: {
|
|
1287
|
+
steps: datasource.linkDefinition.map((step) => ({
|
|
1288
|
+
type: "searchAround",
|
|
1289
|
+
searchAround: {
|
|
1290
|
+
linkTypeIdentifier: {
|
|
1291
|
+
type: "linkType",
|
|
1292
|
+
linkType: cleanAndValidateLinkTypeId(step.linkType.apiName)
|
|
1293
|
+
},
|
|
1294
|
+
linkTypeSide: step.side ?? "SOURCE"
|
|
1295
|
+
}
|
|
1296
|
+
}))
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
const isLinkedProperties = typeof Object.values(datasource.propertyMapping)[0] === "string";
|
|
1300
|
+
const derivedDefinition = isLinkedProperties ? {
|
|
1301
|
+
type: "linkedProperties",
|
|
1302
|
+
linkedProperties: {
|
|
1303
|
+
linkDefinition,
|
|
1304
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, targetProp]) => [sourceProp, {
|
|
1305
|
+
type: "propertyType",
|
|
1306
|
+
propertyType: targetProp
|
|
1307
|
+
}]))
|
|
1308
|
+
}
|
|
1309
|
+
} : {
|
|
1310
|
+
type: "aggregatedProperties",
|
|
1311
|
+
aggregatedProperties: {
|
|
1312
|
+
linkDefinition,
|
|
1313
|
+
propertyTypeMapping: Object.fromEntries(Object.entries(datasource.propertyMapping).map(([sourceProp, agg]) => [sourceProp, buildAggregation(agg)]))
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
const fullDefinition = {
|
|
1317
|
+
type: "derived",
|
|
1318
|
+
derived: {
|
|
1319
|
+
definition: derivedDefinition
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
return buildDatasource(objectTypeApiName + ".derived." + index.toString(), fullDefinition);
|
|
1323
|
+
}
|
|
1324
|
+
function buildAggregation(agg) {
|
|
1325
|
+
const type = agg.type;
|
|
1326
|
+
const limit = "limit" in agg ? agg.limit : void 0;
|
|
1327
|
+
const foreignProperty = "property" in agg ? agg.property : void 0;
|
|
1328
|
+
const innerDef = {};
|
|
1329
|
+
if (type !== "count") {
|
|
1330
|
+
if (["collectList", "collectSet"].includes(type)) {
|
|
1331
|
+
innerDef["linkedProperty"] = {
|
|
1332
|
+
type: "propertyType",
|
|
1333
|
+
propertyType: foreignProperty
|
|
1334
|
+
};
|
|
1335
|
+
innerDef["limit"] = limit;
|
|
1336
|
+
} else {
|
|
1337
|
+
innerDef["property"] = {
|
|
1338
|
+
type: "propertyType",
|
|
1339
|
+
propertyType: foreignProperty
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return {
|
|
1344
|
+
type,
|
|
1345
|
+
[type]: innerDef
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1131
1348
|
|
|
1132
1349
|
// src/conversion/toMarketplace/convertOntologyDefinitionToWireBlockData.ts
|
|
1133
1350
|
function convertOntologyDefinitionToWireBlockData(ontology) {
|
|
@@ -1705,7 +1922,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
1705
1922
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1706
1923
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1707
1924
|
async function main(args = process.argv) {
|
|
1708
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.
|
|
1925
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.7").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1709
1926
|
input: {
|
|
1710
1927
|
alias: "i",
|
|
1711
1928
|
describe: "Input file",
|
|
@@ -1758,12 +1975,12 @@ async function main(args = process.argv) {
|
|
|
1758
1975
|
let apiNamespace = "";
|
|
1759
1976
|
if (commandLineOpts.apiNamespace.length !== 0) {
|
|
1760
1977
|
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" ?
|
|
1978
|
+
!(apiNamespace.length < 1024) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is too long.") : invariant7__default.default(false) : void 0;
|
|
1979
|
+
!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
1980
|
}
|
|
1764
1981
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
1765
1982
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1766
|
-
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ?
|
|
1983
|
+
!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
1984
|
}
|
|
1768
1985
|
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
1769
1986
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
@@ -1813,37 +2030,37 @@ function defineAction(actionDef) {
|
|
|
1813
2030
|
if (ontologyDefinition[OntologyEntityTypeEnum.ACTION_TYPE][apiName] !== void 0) {
|
|
1814
2031
|
throw new Error(`Action type with apiName ${actionDef.apiName} is already defined`);
|
|
1815
2032
|
}
|
|
1816
|
-
!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(actionDef.apiName) ? process.env.NODE_ENV !== "production" ?
|
|
2033
|
+
!/^[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;
|
|
1817
2034
|
const parameterIdsSet = new Set(parameterIds);
|
|
1818
|
-
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ?
|
|
2035
|
+
!(parameterIdsSet.size === parameterIds.length) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter ids must be unique`) : invariant7__default.default(false) : void 0;
|
|
1819
2036
|
const parameterIdsNotFound = Array.from(referencedParameterIds(actionDef)).filter((p) => !parameterIdsSet.has(p));
|
|
1820
|
-
!(parameterIdsNotFound.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2037
|
+
!(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;
|
|
1821
2038
|
const definedSectionIds = new Set(Object.keys(actionDef.sections ?? []));
|
|
1822
2039
|
const undefinedSectionsInOrdering = (actionDef.formContentOrdering ?? []).flatMap((s) => s.type === "parameterId" ? [] : [s.sectionId]).filter((sId) => !definedSectionIds.has(sId));
|
|
1823
|
-
!(undefinedSectionsInOrdering.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
1824
|
-
!(actionDef.rules.length > 0) ? process.env.NODE_ENV !== "production" ?
|
|
2040
|
+
!(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;
|
|
2041
|
+
!(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;
|
|
1825
2042
|
actionDef.rules.forEach((rule) => {
|
|
1826
2043
|
if (rule.type === "modifyObjectRule") {
|
|
1827
|
-
!parameterIds.some((id) => id === rule.modifyObjectRule.objectToModify) ? process.env.NODE_ENV !== "production" ?
|
|
2044
|
+
!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;
|
|
1828
2045
|
}
|
|
1829
2046
|
if (rule.type === "deleteObjectRule") {
|
|
1830
|
-
!parameterIds.some((id) => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ?
|
|
2047
|
+
!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;
|
|
1831
2048
|
}
|
|
1832
2049
|
if (rule.type === "modifyInterfaceRule") {
|
|
1833
2050
|
const interfaceParam = actionDef.parameters.find((p) => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
|
|
1834
|
-
!(interfaceParam !== void 0 && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ?
|
|
2051
|
+
!(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;
|
|
1835
2052
|
const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
|
|
1836
|
-
!(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== void 0 || importedTypes.INTERFACE_TYPE[interfaceReference] !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2053
|
+
!(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;
|
|
1837
2054
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
|
|
1838
2055
|
Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
1839
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2056
|
+
!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;
|
|
1840
2057
|
});
|
|
1841
2058
|
}
|
|
1842
2059
|
if (rule.type === "addInterfaceRule") {
|
|
1843
2060
|
const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
|
|
1844
|
-
!(interfaceType !== void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2061
|
+
!(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;
|
|
1845
2062
|
Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach((spt) => {
|
|
1846
|
-
!Object.keys(getFlattenedInterfaceProperties(interfaceType)).includes(spt) ? process.env.NODE_ENV !== "production" ?
|
|
2063
|
+
!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;
|
|
1847
2064
|
});
|
|
1848
2065
|
}
|
|
1849
2066
|
});
|
|
@@ -2307,9 +2524,9 @@ function validateParameterCondition(condition, currentParameterId, seenParameter
|
|
|
2307
2524
|
switch (condition.type) {
|
|
2308
2525
|
case "parameter":
|
|
2309
2526
|
const overrideParamId = condition.parameterId;
|
|
2310
|
-
!parameters?.some((p) => p.id === overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2311
|
-
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2312
|
-
!seenParameterIds.has(overrideParamId) ? process.env.NODE_ENV !== "production" ?
|
|
2527
|
+
!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;
|
|
2528
|
+
!(overrideParamId !== currentParameterId) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, `Parameter condition on ${currentParameterId} is referencing itself`) : invariant7__default.default(false) : void 0;
|
|
2529
|
+
!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;
|
|
2313
2530
|
break;
|
|
2314
2531
|
case "and":
|
|
2315
2532
|
if ("conditions" in condition) {
|
|
@@ -2337,11 +2554,11 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2337
2554
|
if (!defaultValue) return;
|
|
2338
2555
|
switch (defaultValue.type) {
|
|
2339
2556
|
case "objectParameterPropertyValue":
|
|
2340
|
-
!parameters?.some((p) => p.id === defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2341
|
-
!seenParameterIds.has(defaultValue.objectParameterPropertyValue.parameterId) ? process.env.NODE_ENV !== "production" ?
|
|
2557
|
+
!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;
|
|
2558
|
+
!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;
|
|
2342
2559
|
break;
|
|
2343
2560
|
case "staticValue":
|
|
2344
|
-
!(defaultValue.staticValue.type === parameters?.find((p) => p.id === currentParameterId)?.type) ? process.env.NODE_ENV !== "production" ?
|
|
2561
|
+
!(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;
|
|
2345
2562
|
break;
|
|
2346
2563
|
case "staticObject":
|
|
2347
2564
|
case "interfaceParameterPropertyValue":
|
|
@@ -2356,10 +2573,10 @@ function validateParameterPrefill(currentParameterId, seenParameterIds, paramete
|
|
|
2356
2573
|
}
|
|
2357
2574
|
function validateActionParameters(def, properties, name) {
|
|
2358
2575
|
[...Object.keys(def.parameterConfiguration ?? {})].forEach((id) => {
|
|
2359
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id)) || def.parameterConfiguration?.[id].customParameterType !== void 0 || isTargetParameter(id)) ? process.env.NODE_ENV !== "production" ?
|
|
2576
|
+
!(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;
|
|
2360
2577
|
});
|
|
2361
2578
|
[...Object.keys(def.nonParameterMappings ?? {}), ...def.excludedProperties ?? []].forEach((id) => {
|
|
2362
|
-
!(properties.includes(id) || properties.includes(addNamespaceIfNone(id))) ? process.env.NODE_ENV !== "production" ?
|
|
2579
|
+
!(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;
|
|
2363
2580
|
});
|
|
2364
2581
|
}
|
|
2365
2582
|
function createDefaultParameterOrdering(def, properties, parameters, priorityId) {
|
|
@@ -2369,7 +2586,7 @@ function validateParameterOrdering(parameterOrdering, parameterSet, actionApiNam
|
|
|
2369
2586
|
const orderingSet = new Set(parameterOrdering);
|
|
2370
2587
|
const missingParameters = [...parameterSet].filter((param) => !orderingSet.has(param));
|
|
2371
2588
|
const extraneousParameters = parameterOrdering.filter((param) => !parameterSet.has(param));
|
|
2372
|
-
!(extraneousParameters.length === 0 && missingParameters.length === 0) ? process.env.NODE_ENV !== "production" ?
|
|
2589
|
+
!(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;
|
|
2373
2590
|
}
|
|
2374
2591
|
function isTargetParameter(parameterId) {
|
|
2375
2592
|
return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
|
|
@@ -2480,7 +2697,8 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2480
2697
|
// src/api/defineCreateObjectAction.ts
|
|
2481
2698
|
function defineCreateObjectAction(def) {
|
|
2482
2699
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2483
|
-
const
|
|
2700
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
2701
|
+
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));
|
|
2484
2702
|
const parameterNames = new Set(propertyParameters);
|
|
2485
2703
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2486
2704
|
const actionApiName = def.apiName ?? `create-object-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`;
|
|
@@ -2541,7 +2759,8 @@ function defineCreateObjectAction(def) {
|
|
|
2541
2759
|
// src/api/defineCreateOrModifyObjectAction.ts
|
|
2542
2760
|
function defineCreateOrModifyObjectAction(def) {
|
|
2543
2761
|
validateActionParameters(def, Object.keys(def.objectType.properties ?? {}), def.objectType.apiName);
|
|
2544
|
-
const
|
|
2762
|
+
const propertiesWithDerivedDatasources = (def.objectType.datasources ?? []).filter((ds) => ds.type === "derived").flatMap((ds) => Object.keys(ds.propertyMapping));
|
|
2763
|
+
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));
|
|
2545
2764
|
const parameterNames = new Set(propertyParameters);
|
|
2546
2765
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(param));
|
|
2547
2766
|
parameterNames.add(CREATE_OR_MODIFY_OBJECT_PARAMETER);
|
|
@@ -2614,6 +2833,43 @@ function defineCreateOrModifyObjectAction(def) {
|
|
|
2614
2833
|
});
|
|
2615
2834
|
}
|
|
2616
2835
|
|
|
2836
|
+
// src/api/defineDeleteInterfaceObjectAction.ts
|
|
2837
|
+
function defineDeleteInterfaceObjectAction(def) {
|
|
2838
|
+
return defineAction({
|
|
2839
|
+
apiName: def.apiName ?? `delete-interface-object-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}`,
|
|
2840
|
+
displayName: def.displayName ?? `Delete ${def.interfaceType.displayMetadata.displayName}`,
|
|
2841
|
+
parameters: [{
|
|
2842
|
+
id: "objectToDeleteParameter",
|
|
2843
|
+
displayName: "Delete object",
|
|
2844
|
+
type: {
|
|
2845
|
+
type: "interfaceReference",
|
|
2846
|
+
interfaceReference: {
|
|
2847
|
+
interfaceTypeRid: def.interfaceType.apiName
|
|
2848
|
+
}
|
|
2849
|
+
},
|
|
2850
|
+
validation: {
|
|
2851
|
+
required: true,
|
|
2852
|
+
allowedValues: {
|
|
2853
|
+
type: "interfaceObjectQuery"
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
}],
|
|
2857
|
+
status: def.status ?? "active",
|
|
2858
|
+
rules: [{
|
|
2859
|
+
type: "deleteObjectRule",
|
|
2860
|
+
deleteObjectRule: {
|
|
2861
|
+
objectToDelete: "objectToDeleteParameter"
|
|
2862
|
+
}
|
|
2863
|
+
}],
|
|
2864
|
+
entities: {
|
|
2865
|
+
affectedInterfaceTypes: [],
|
|
2866
|
+
affectedObjectTypes: [def.interfaceType.apiName],
|
|
2867
|
+
affectedLinkTypes: [],
|
|
2868
|
+
typeGroups: []
|
|
2869
|
+
}
|
|
2870
|
+
});
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2617
2873
|
// src/api/defineDeleteObjectAction.ts
|
|
2618
2874
|
function defineDeleteObjectAction(def) {
|
|
2619
2875
|
return defineAction({
|
|
@@ -2655,8 +2911,8 @@ function defineDeleteObjectAction(def) {
|
|
|
2655
2911
|
}
|
|
2656
2912
|
function defineSharedPropertyType(sptDef) {
|
|
2657
2913
|
const apiName = namespace + sptDef.apiName;
|
|
2658
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2659
|
-
!(!shouldNotHaveRenderHints(sptDef.type) || !hasRenderHints(sptDef.typeClasses)) ? process.env.NODE_ENV !== "production" ?
|
|
2914
|
+
!(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;
|
|
2915
|
+
!(!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;
|
|
2660
2916
|
const fullSpt = {
|
|
2661
2917
|
...sptDef,
|
|
2662
2918
|
apiName,
|
|
@@ -2705,7 +2961,7 @@ function combineApiNamespaceIfMissing(namespace2, apiName) {
|
|
|
2705
2961
|
// src/api/defineInterface.ts
|
|
2706
2962
|
function defineInterface(interfaceDef) {
|
|
2707
2963
|
const apiName = namespace + interfaceDef.apiName;
|
|
2708
|
-
!(ontologyDefinition[OntologyEntityTypeEnum.INTERFACE_TYPE][apiName] === void 0) ? process.env.NODE_ENV !== "production" ?
|
|
2964
|
+
!(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;
|
|
2709
2965
|
const properties = Object.fromEntries(Object.entries(interfaceDef.properties ?? {}).map(([unNamespacedPropApiName, type]) => {
|
|
2710
2966
|
if (typeof type === "object" && "propertyDefinition" in type) {
|
|
2711
2967
|
const apiName3 = combineApiNamespaceIfMissing(namespace, typeof type.propertyDefinition === "object" && "apiName" in type.propertyDefinition ? type.propertyDefinition.apiName : unNamespacedPropApiName);
|
|
@@ -2724,7 +2980,7 @@ function defineInterface(interfaceDef) {
|
|
|
2724
2980
|
const status = mapSimplifiedStatusToInterfaceTypeStatus(interfaceDef.status ?? {
|
|
2725
2981
|
type: "active"
|
|
2726
2982
|
});
|
|
2727
|
-
!(status.type !== "deprecated" || status.deprecated.message && status.deprecated.deadline) ? process.env.NODE_ENV !== "production" ?
|
|
2983
|
+
!(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;
|
|
2728
2984
|
const fullInterface = {
|
|
2729
2985
|
apiName,
|
|
2730
2986
|
displayMetadata: {
|
|
@@ -2750,7 +3006,7 @@ function defineInterface(interfaceDef) {
|
|
|
2750
3006
|
}
|
|
2751
3007
|
function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
2752
3008
|
if (typeof type === "string" || typeof type === "object" && !("apiName" in type)) {
|
|
2753
|
-
!isPropertyTypeType(type) ? process.env.NODE_ENV !== "production" ?
|
|
3009
|
+
!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;
|
|
2754
3010
|
const spt = defineSharedPropertyType({
|
|
2755
3011
|
apiName,
|
|
2756
3012
|
displayName: apiName,
|
|
@@ -2760,16 +3016,16 @@ function unifyBasePropertyDefinition(namespace2, apiName, type) {
|
|
|
2760
3016
|
return spt;
|
|
2761
3017
|
} else {
|
|
2762
3018
|
const unNamespacedTypeApiName = withoutNamespace(type.apiName);
|
|
2763
|
-
!(namespace2 + apiName === type.apiName || apiName === unNamespacedTypeApiName) ? process.env.NODE_ENV !== "production" ?
|
|
3019
|
+
!(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({
|
|
2764
3020
|
key: apiName,
|
|
2765
3021
|
apiName: type.apiName
|
|
2766
|
-
})}`) :
|
|
3022
|
+
})}`) : invariant7__default.default(false) : void 0;
|
|
2767
3023
|
return type;
|
|
2768
3024
|
}
|
|
2769
3025
|
}
|
|
2770
3026
|
function defineInterfaceLinkConstraint(linkDef) {
|
|
2771
3027
|
const fromLinkMeta = getLinkMeta(linkDef);
|
|
2772
|
-
!(linkDef.from.links.find((a) => a.metadata.apiName === fromLinkMeta.apiName) == null) ? process.env.NODE_ENV !== "production" ?
|
|
3028
|
+
!(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;
|
|
2773
3029
|
linkDef.from.links.push({
|
|
2774
3030
|
cardinality: linkDef.toMany ? "MANY" : "SINGLE",
|
|
2775
3031
|
linkedEntityTypeId: getLinkedType(linkDef.toMany ?? linkDef.toOne),
|
|
@@ -2797,19 +3053,9 @@ function getLinkMeta(meta) {
|
|
|
2797
3053
|
description: description ?? displayName ?? apiNameWithoutNamespace
|
|
2798
3054
|
};
|
|
2799
3055
|
}
|
|
2800
|
-
|
|
3056
|
+
|
|
3057
|
+
// src/api/defineLink.ts
|
|
2801
3058
|
function defineLink(linkDefinition) {
|
|
2802
|
-
if ("one" in linkDefinition) {
|
|
2803
|
-
const foreignKey = linkDefinition.toMany.object.properties?.[linkDefinition.manyForeignKeyProperty];
|
|
2804
|
-
!(foreignKey !== void 0) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Foreign key ${linkDefinition.manyForeignKeyProperty} on link ${linkDefinition.apiName} does not exist on object ${linkDefinition.toMany.object.apiName}}`) : invariant6__default.default(false) : void 0;
|
|
2805
|
-
!typeIdPattern.test(linkDefinition.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Top level link api names are expected to match the regex pattern ([a-z][a-z0-9\\-]*) ${linkDefinition.apiName} does not match`) : invariant6__default.default(false) : void 0;
|
|
2806
|
-
const typesMatch = foreignKey.type === linkDefinition.one.object.properties?.[linkDefinition.one.object.primaryKeyPropertyApiName].type;
|
|
2807
|
-
!typesMatch ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `Link ${linkDefinition.apiName} has type mismatch between the one side's primary key and the foreign key on the many side`) : invariant6__default.default(false) : void 0;
|
|
2808
|
-
}
|
|
2809
|
-
if ("intermediaryObjectType" in linkDefinition) {
|
|
2810
|
-
!("one" in linkDefinition.many.linkToIntermediary && linkDefinition.many.linkToIntermediary.one.object.apiName === linkDefinition.many.object.apiName && linkDefinition.many.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeA ${linkDefinition.many.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectA ${linkDefinition.many.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2811
|
-
!("one" in linkDefinition.toMany.linkToIntermediary && linkDefinition.toMany.linkToIntermediary.one.object.apiName === linkDefinition.toMany.object.apiName && linkDefinition.toMany.linkToIntermediary.toMany.object.apiName === linkDefinition.intermediaryObjectType.apiName) ? process.env.NODE_ENV !== "production" ? invariant6__default.default(false, `LinkTypeB ${linkDefinition.toMany.linkToIntermediary.apiName} must be a many to one link from intermediary object ${linkDefinition.intermediaryObjectType.apiName} to objectB ${linkDefinition.toMany.object.apiName}`) : invariant6__default.default(false) : void 0;
|
|
2812
|
-
}
|
|
2813
3059
|
let fullLinkDefinition;
|
|
2814
3060
|
if ("one" in linkDefinition) {
|
|
2815
3061
|
fullLinkDefinition = {
|
|
@@ -2833,6 +3079,7 @@ function defineLink(linkDefinition) {
|
|
|
2833
3079
|
const linkType = {
|
|
2834
3080
|
cardinality: "one" in linkDefinition ? linkDefinition.cardinality : void 0,
|
|
2835
3081
|
...fullLinkDefinition,
|
|
3082
|
+
apiName: linkDefinition.apiName,
|
|
2836
3083
|
__type: OntologyEntityTypeEnum.LINK_TYPE
|
|
2837
3084
|
};
|
|
2838
3085
|
updateOntology(linkType);
|
|
@@ -3062,7 +3309,7 @@ function defineValueType(valueTypeDef) {
|
|
|
3062
3309
|
version
|
|
3063
3310
|
} = valueTypeDef;
|
|
3064
3311
|
const semverValidation = /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/;
|
|
3065
|
-
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ?
|
|
3312
|
+
!semverValidation.test(version) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Version is not a valid semver") : invariant7__default.default(false) : void 0;
|
|
3066
3313
|
const typeName = typeof type.type === "string" ? type.type : type.type.type === "struct" ? "structV2" : type.type.type;
|
|
3067
3314
|
const constraints = type.constraints ? type.constraints.map((constraint) => {
|
|
3068
3315
|
const output = {
|
|
@@ -3118,8 +3365,8 @@ function importSharedPropertyType(opts) {
|
|
|
3118
3365
|
} = opts;
|
|
3119
3366
|
const fullApiName = packageName === void 0 ? apiName : `${packageName}.${apiName}`;
|
|
3120
3367
|
if (packageName !== void 0) {
|
|
3121
|
-
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ?
|
|
3122
|
-
!(packageName.match("[A-Z]") == null) ? process.env.NODE_ENV !== "production" ?
|
|
3368
|
+
!!packageName.endsWith(".") ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Package name format invalid ends with period") : invariant7__default.default(false) : void 0;
|
|
3369
|
+
!(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;
|
|
3123
3370
|
}
|
|
3124
3371
|
const spt = {
|
|
3125
3372
|
apiName: fullApiName,
|
|
@@ -3157,6 +3404,7 @@ exports.defineAction = defineAction;
|
|
|
3157
3404
|
exports.defineCreateInterfaceObjectAction = defineCreateInterfaceObjectAction;
|
|
3158
3405
|
exports.defineCreateObjectAction = defineCreateObjectAction;
|
|
3159
3406
|
exports.defineCreateOrModifyObjectAction = defineCreateOrModifyObjectAction;
|
|
3407
|
+
exports.defineDeleteInterfaceObjectAction = defineDeleteInterfaceObjectAction;
|
|
3160
3408
|
exports.defineDeleteObjectAction = defineDeleteObjectAction;
|
|
3161
3409
|
exports.defineInterface = defineInterface;
|
|
3162
3410
|
exports.defineInterfaceLinkConstraint = defineInterfaceLinkConstraint;
|