@fibery/schema 8.1.5 → 8.1.6
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/lib/index.js +129 -141
- package/package.json +8 -7
- package/types.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -75,30 +75,35 @@ const formatWithCustomInspectParams = values => {
|
|
|
75
75
|
maxArrayLength: null
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
|
|
79
78
|
return value;
|
|
80
79
|
}).join(" ");
|
|
81
80
|
};
|
|
82
|
-
function assert(condition
|
|
81
|
+
function assert(condition) {
|
|
83
82
|
if (!condition) {
|
|
83
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
84
|
+
args[_key - 1] = arguments[_key];
|
|
85
|
+
}
|
|
84
86
|
const message = args.length > 0 ? formatWithCustomInspectParams(args) : `Assertion failed with no details`;
|
|
85
87
|
throw new Error(message);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
function assertWithTraceError(condition
|
|
90
|
+
function assertWithTraceError(condition) {
|
|
89
91
|
if (!condition) {
|
|
92
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
93
|
+
args[_key2 - 1] = arguments[_key2];
|
|
94
|
+
}
|
|
90
95
|
const message = args.length > 0 ? formatWithCustomInspectParams(args) : `Assertion failed with no details`;
|
|
91
96
|
traceError(message);
|
|
92
97
|
}
|
|
93
|
-
}
|
|
98
|
+
}
|
|
94
99
|
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
95
101
|
let traceErrorSubscribers = [console.error.bind(console)];
|
|
96
102
|
const overridden = false;
|
|
97
103
|
function subscribeOnTraceError(fn) {
|
|
98
104
|
if (overridden) {
|
|
99
105
|
throw new Error("cannot subscribe while overridden");
|
|
100
106
|
}
|
|
101
|
-
|
|
102
107
|
traceErrorSubscribers.push(fn);
|
|
103
108
|
let unsubscribed = false;
|
|
104
109
|
return function unsubscribe() {
|
|
@@ -107,12 +112,16 @@ function subscribeOnTraceError(fn) {
|
|
|
107
112
|
traceErrorSubscribers = traceErrorSubscribers.filter(x => x !== fn);
|
|
108
113
|
};
|
|
109
114
|
}
|
|
110
|
-
const traceError = external_memoize_one_default()(function traceError(
|
|
115
|
+
const traceError = external_memoize_one_default()(function traceError() {
|
|
116
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
117
|
+
args[_key3] = arguments[_key3];
|
|
118
|
+
}
|
|
111
119
|
traceErrorSubscribers.forEach(fn => {
|
|
112
120
|
fn(...args);
|
|
113
121
|
});
|
|
114
|
-
});
|
|
122
|
+
});
|
|
115
123
|
|
|
124
|
+
// eslint-disable-next-line no-console
|
|
116
125
|
let captureMessageSubscribers = [console.info.bind(console)];
|
|
117
126
|
function subscribeOnCaptureMessage(fn) {
|
|
118
127
|
captureMessageSubscribers.push(fn);
|
|
@@ -123,7 +132,10 @@ function subscribeOnCaptureMessage(fn) {
|
|
|
123
132
|
captureMessageSubscribers = captureMessageSubscribers.filter(x => x !== fn);
|
|
124
133
|
};
|
|
125
134
|
}
|
|
126
|
-
const captureMessage = external_memoize_one_default()(function captureMessage(
|
|
135
|
+
const captureMessage = external_memoize_one_default()(function captureMessage() {
|
|
136
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
137
|
+
args[_key4] = arguments[_key4];
|
|
138
|
+
}
|
|
127
139
|
captureMessageSubscribers.forEach(fn => {
|
|
128
140
|
fn(...args);
|
|
129
141
|
});
|
|
@@ -133,7 +145,6 @@ const traceErrorOncePerSession = (seed, err) => {
|
|
|
133
145
|
if (tracedErrorTracker[seed]) {
|
|
134
146
|
return;
|
|
135
147
|
}
|
|
136
|
-
|
|
137
148
|
tracedErrorTracker[seed] = true;
|
|
138
149
|
const message = [seed, err].filter(Boolean).join(": ");
|
|
139
150
|
traceError(message);
|
|
@@ -143,15 +154,14 @@ const captureMessageOncePerSession = (seed, err) => {
|
|
|
143
154
|
if (capturedMessageTracker[seed]) {
|
|
144
155
|
return;
|
|
145
156
|
}
|
|
146
|
-
|
|
147
157
|
capturedMessageTracker[seed] = true;
|
|
148
158
|
const message = [seed, err].filter(Boolean).join(": ");
|
|
149
159
|
captureMessage(message);
|
|
150
160
|
};
|
|
151
161
|
function withErrorTrace(f) {
|
|
152
|
-
return async function (
|
|
162
|
+
return async function () {
|
|
153
163
|
try {
|
|
154
|
-
return await f(...
|
|
164
|
+
return await f(...arguments);
|
|
155
165
|
} catch (err) {
|
|
156
166
|
traceError(err);
|
|
157
167
|
throw err;
|
|
@@ -166,37 +176,34 @@ class NotDefinedGetError extends Error {}
|
|
|
166
176
|
|
|
167
177
|
|
|
168
178
|
const jestKey = new Set(["nodeType", "tagName", "hasAttribute"]);
|
|
169
|
-
const withOnlyDefinedGets = (target
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
177
|
-
|
|
179
|
+
const withOnlyDefinedGets = function (target) {
|
|
180
|
+
let targetKind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "object";
|
|
181
|
+
return new Proxy(target, {
|
|
182
|
+
get(target, key) {
|
|
183
|
+
if (!(key in target) && "production" !== "production") {}
|
|
184
|
+
return target[key];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
};
|
|
178
188
|
const getNamePart = str => splitKeyword(str).name;
|
|
179
|
-
|
|
180
189
|
const capitalizeFirstChar = input => {
|
|
181
190
|
const str = input || "";
|
|
182
191
|
return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
|
|
183
192
|
};
|
|
184
|
-
|
|
185
193
|
const replaceTildes = str => (str || "").split("~").join(" ");
|
|
186
|
-
|
|
187
194
|
const toTypeOrFieldNamePartTitle = external_lodash_default().flow([capitalizeFirstChar, replaceTildes]);
|
|
188
195
|
const toTypeOrFieldTitle = external_lodash_default().flow([getNamePart, toTypeOrFieldNamePartTitle]);
|
|
189
|
-
const toPascalCase =
|
|
190
|
-
|
|
196
|
+
const toPascalCase = function () {
|
|
197
|
+
let lispCasedString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
198
|
+
return lispCasedString && external_lodash_default().last(lispCasedString.split("/")).split("-").map((external_lodash_default()).capitalize).join(" ");
|
|
199
|
+
};
|
|
191
200
|
const isObsoleteTitle = str => {
|
|
192
201
|
const {
|
|
193
202
|
name
|
|
194
203
|
} = splitKeyword(str);
|
|
195
204
|
return name.toLowerCase() === name && !hasTildes(name);
|
|
196
205
|
};
|
|
197
|
-
|
|
198
206
|
const hasTildes = str => str.includes("~");
|
|
199
|
-
|
|
200
207
|
const toNonEnumTitle = str => {
|
|
201
208
|
return isObsoleteTitle(str) ? toPascalCase(str) : toTypeOrFieldTitle(str);
|
|
202
209
|
};
|
|
@@ -217,7 +224,6 @@ const parseEnumType = type => {
|
|
|
217
224
|
targetNamespace
|
|
218
225
|
};
|
|
219
226
|
};
|
|
220
|
-
|
|
221
227
|
const toEnumTitle = type => {
|
|
222
228
|
// enum logic
|
|
223
229
|
const {
|
|
@@ -226,23 +232,19 @@ const toEnumTitle = type => {
|
|
|
226
232
|
} = parseEnumType(type);
|
|
227
233
|
return toTitle(targetName) + " " + toTitle(templateName);
|
|
228
234
|
};
|
|
229
|
-
|
|
230
235
|
const toTitle = typeOrAttr => {
|
|
231
236
|
const str = typeOrAttr || "";
|
|
232
237
|
return str.includes("_") ? toEnumTitle(str) : toNonEnumTitle(str);
|
|
233
238
|
};
|
|
234
|
-
|
|
235
239
|
const splitKeyword = keyword => {
|
|
236
240
|
const str = keyword || "";
|
|
237
241
|
const index = str.indexOf("/");
|
|
238
|
-
|
|
239
242
|
if (index === -1) {
|
|
240
243
|
return {
|
|
241
244
|
namespace: "",
|
|
242
245
|
name: str
|
|
243
246
|
};
|
|
244
247
|
}
|
|
245
|
-
|
|
246
248
|
const namespace = str.substring(0, index);
|
|
247
249
|
const name = str.substring(index + 1);
|
|
248
250
|
return {
|
|
@@ -250,28 +252,28 @@ const splitKeyword = keyword => {
|
|
|
250
252
|
name
|
|
251
253
|
};
|
|
252
254
|
};
|
|
253
|
-
|
|
254
255
|
const parseType = external_lodash_default().memoize(type => {
|
|
255
256
|
if (!type.includes("/")) {
|
|
256
257
|
traceError(`parseType invalid usage: passed type is '${type}'`);
|
|
257
258
|
}
|
|
258
|
-
|
|
259
259
|
return splitKeyword(type);
|
|
260
260
|
});
|
|
261
|
-
const makeEnumTypeNamePart =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
const makeEnumTypeNamePart = _ref => {
|
|
262
|
+
let {
|
|
263
|
+
holderType,
|
|
264
|
+
enumName
|
|
265
|
+
} = _ref;
|
|
265
266
|
const {
|
|
266
267
|
namespace,
|
|
267
268
|
name
|
|
268
269
|
} = parseType(holderType);
|
|
269
270
|
return `${enumName}_${namespace}/${name}`;
|
|
270
271
|
};
|
|
271
|
-
const attachEnumNamespace =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
const attachEnumNamespace = _ref2 => {
|
|
273
|
+
let {
|
|
274
|
+
enumNamespace,
|
|
275
|
+
typeNamePart
|
|
276
|
+
} = _ref2;
|
|
275
277
|
return `${enumNamespace}/${typeNamePart}`;
|
|
276
278
|
};
|
|
277
279
|
const removeDeletedTypesAndFields = rawSchema => {
|
|
@@ -285,11 +287,13 @@ const removeDeletedTypesAndFields = rawSchema => {
|
|
|
285
287
|
...rawTypeObjectRest
|
|
286
288
|
} = rawTypeObject;
|
|
287
289
|
const filteredRawFieldObjects = rawFieldObjects.filter(rawFieldObject => rawFieldObject["fibery/deleted?"] !== true);
|
|
288
|
-
return {
|
|
290
|
+
return {
|
|
291
|
+
...rawTypeObjectRest,
|
|
289
292
|
"fibery/fields": filteredRawFieldObjects
|
|
290
293
|
};
|
|
291
294
|
});
|
|
292
|
-
return {
|
|
295
|
+
return {
|
|
296
|
+
...schemaRest,
|
|
293
297
|
"fibery/types": filteredRawTypeObjects
|
|
294
298
|
};
|
|
295
299
|
};
|
|
@@ -297,24 +301,22 @@ const removeDeletedTypesAndFields = rawSchema => {
|
|
|
297
301
|
|
|
298
302
|
|
|
299
303
|
class FieldObject {
|
|
300
|
-
constructor({
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
constructor(_ref) {
|
|
305
|
+
let {
|
|
306
|
+
rawFieldObject,
|
|
307
|
+
holderType,
|
|
308
|
+
resolveTypeObject,
|
|
309
|
+
version
|
|
310
|
+
} = _ref;
|
|
306
311
|
if (!external_lodash_default().isPlainObject(rawFieldObject)) {
|
|
307
312
|
throw new Error("rawFieldObject arg must be plain object");
|
|
308
313
|
}
|
|
309
|
-
|
|
310
314
|
if (!external_lodash_default().isString(holderType)) {
|
|
311
315
|
throw new Error("holderType arg must be string");
|
|
312
316
|
}
|
|
313
|
-
|
|
314
317
|
if (!external_lodash_default().isFunction(resolveTypeObject)) {
|
|
315
318
|
throw new Error("resolveTypeObject arg must be function");
|
|
316
319
|
}
|
|
317
|
-
|
|
318
320
|
this.name = rawFieldObject["fibery/name"];
|
|
319
321
|
this.description = rawFieldObject["fibery/description"] || null;
|
|
320
322
|
this.id = rawFieldObject["fibery/id"];
|
|
@@ -334,6 +336,8 @@ class FieldObject {
|
|
|
334
336
|
this.isLookup = rawMeta["formula/lookup?"] || false;
|
|
335
337
|
this.hasLinkRule = rawMeta["link-rule/link-rule?"] || false;
|
|
336
338
|
this.linkRule = rawMeta["link-rule/link-rule"] || null;
|
|
339
|
+
this.isLinkRuleDisabled = rawMeta["link-rule/disabled?"] || false;
|
|
340
|
+
this.linkRuleDisableReason = rawMeta["link-rule/disable-reason"] || null;
|
|
337
341
|
this.relation = rawMeta["fibery/relation"] || null;
|
|
338
342
|
this.defaultValue = rawMeta["fibery/default-value"] || null;
|
|
339
343
|
this.objectEditorOrder = rawMeta["ui/object-editor-order"] || 0;
|
|
@@ -374,69 +378,53 @@ class FieldObject {
|
|
|
374
378
|
}
|
|
375
379
|
});
|
|
376
380
|
}
|
|
377
|
-
|
|
378
381
|
get relatedFieldObject() {
|
|
379
382
|
const {
|
|
380
383
|
name,
|
|
381
384
|
relation
|
|
382
385
|
} = this;
|
|
383
|
-
|
|
384
386
|
if (!relation) {
|
|
385
387
|
return null;
|
|
386
388
|
}
|
|
387
|
-
|
|
388
389
|
const selector = this.type !== this.holderType ? fieldObject => fieldObject.relation === relation : fieldObject => fieldObject.relation === relation && fieldObject.name !== name;
|
|
389
390
|
const fieldObject = this.typeObject.fieldObjects.find(selector);
|
|
390
|
-
|
|
391
391
|
if (!fieldObject) {
|
|
392
392
|
throw new Error(`there no other end for relation ${relation}`);
|
|
393
393
|
}
|
|
394
|
-
|
|
395
394
|
return fieldObject;
|
|
396
395
|
}
|
|
397
|
-
|
|
398
396
|
get cardinality() {
|
|
399
397
|
const {
|
|
400
398
|
isCollection,
|
|
401
399
|
relatedFieldObject,
|
|
402
400
|
typeObject
|
|
403
401
|
} = this;
|
|
404
|
-
|
|
405
402
|
if (typeObject.isPrimitive) {
|
|
406
403
|
throw new Error("Only non-basic fields have cardinality");
|
|
407
404
|
}
|
|
408
|
-
|
|
409
405
|
if (isCollection && this.rawMeta["fibery/field-reversed-collection?"]) {
|
|
410
406
|
return ":cardinality/many-to-many";
|
|
411
407
|
}
|
|
412
|
-
|
|
413
408
|
if (!relatedFieldObject) {
|
|
414
409
|
return isCollection ? ":cardinality/one-to-many" : ":cardinality/many-to-one";
|
|
415
410
|
}
|
|
416
|
-
|
|
417
411
|
const isRelationCollection = relatedFieldObject.isCollection;
|
|
418
|
-
|
|
419
412
|
if (!isCollection && !isRelationCollection) {
|
|
420
413
|
return ":cardinality/one-to-one";
|
|
421
414
|
}
|
|
422
|
-
|
|
423
415
|
if (isCollection && !isRelationCollection) {
|
|
424
416
|
return ":cardinality/one-to-many";
|
|
425
417
|
}
|
|
426
|
-
|
|
427
418
|
if (!isCollection && isRelationCollection) {
|
|
428
419
|
return ":cardinality/many-to-one";
|
|
429
420
|
}
|
|
430
|
-
|
|
431
421
|
if (isCollection && isRelationCollection) {
|
|
432
422
|
return ":cardinality/many-to-many";
|
|
433
423
|
}
|
|
434
|
-
|
|
435
424
|
throw new Error("get cardinality invariant");
|
|
436
425
|
}
|
|
437
|
-
/** @deprecated use !typeObject.isPrimitive && cardinality === ... instead */
|
|
438
|
-
|
|
439
426
|
|
|
427
|
+
/** @deprecated use !typeObject.isPrimitive && cardinality === ... instead */
|
|
440
428
|
get kind() {
|
|
441
429
|
if (this.typeObject.isPrimitive) {
|
|
442
430
|
if (this.isCollection) {
|
|
@@ -452,23 +440,22 @@ class FieldObject {
|
|
|
452
440
|
}
|
|
453
441
|
}
|
|
454
442
|
}
|
|
455
|
-
|
|
456
443
|
}
|
|
457
444
|
;// CONCATENATED MODULE: ./Schema.js
|
|
458
445
|
|
|
459
446
|
class Schema {
|
|
460
|
-
constructor({
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
447
|
+
constructor(_ref) {
|
|
448
|
+
let {
|
|
449
|
+
factory,
|
|
450
|
+
rawSchema: {
|
|
451
|
+
"fibery/id": id,
|
|
452
|
+
"fibery/types": rawTypeObjects,
|
|
453
|
+
"fibery/version": version
|
|
454
|
+
}
|
|
455
|
+
} = _ref;
|
|
468
456
|
if (!Array.isArray(rawTypeObjects)) {
|
|
469
457
|
throw new Error("rawTypeObjects arg must be array");
|
|
470
458
|
}
|
|
471
|
-
|
|
472
459
|
Object.defineProperties(this, {
|
|
473
460
|
toJSON: {
|
|
474
461
|
value: () => ({
|
|
@@ -480,7 +467,6 @@ class Schema {
|
|
|
480
467
|
enumerable: false
|
|
481
468
|
}
|
|
482
469
|
});
|
|
483
|
-
|
|
484
470
|
const getTypeComponentTypeToFieldObject = external_lodash_default().once(() => {
|
|
485
471
|
const typeComponentTypeToFieldObject = new Map();
|
|
486
472
|
this.typeObjects.flatMap(typeObject => typeObject.fieldObjects).filter(fieldObject => {
|
|
@@ -490,7 +476,6 @@ class Schema {
|
|
|
490
476
|
});
|
|
491
477
|
return typeComponentTypeToFieldObject;
|
|
492
478
|
});
|
|
493
|
-
|
|
494
479
|
this.typeObjects = rawTypeObjects.map(rawTypeObject => factory.makeTypeObject({
|
|
495
480
|
rawTypeObject,
|
|
496
481
|
resolveTypeObject: type => this.typeObjectsByName[type] || null,
|
|
@@ -502,25 +487,26 @@ class Schema {
|
|
|
502
487
|
this.id = id;
|
|
503
488
|
this.version = version;
|
|
504
489
|
}
|
|
505
|
-
|
|
506
490
|
}
|
|
507
491
|
;// CONCATENATED MODULE: external "pluralize"
|
|
508
492
|
const external_pluralize_namespaceObject = require("pluralize");
|
|
509
493
|
var external_pluralize_default = /*#__PURE__*/__webpack_require__.n(external_pluralize_namespaceObject);
|
|
510
494
|
;// CONCATENATED MODULE: ./TypeObject.js
|
|
511
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
512
|
-
|
|
495
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
496
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
497
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
513
498
|
|
|
514
499
|
|
|
515
500
|
|
|
516
501
|
class TypeObject {
|
|
517
|
-
constructor({
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
502
|
+
constructor(_ref) {
|
|
503
|
+
let {
|
|
504
|
+
rawTypeObject,
|
|
505
|
+
resolveTypeObject,
|
|
506
|
+
getTypeComponentTypeToFieldObject,
|
|
507
|
+
version,
|
|
508
|
+
factory
|
|
509
|
+
} = _ref;
|
|
524
510
|
_defineProperty(this, "_getFieldObjectShortcuts", external_lodash_default().once(() => {
|
|
525
511
|
const hasRank = this.installedMixins.has("fibery/rank-mixin");
|
|
526
512
|
return this.fieldObjects.reduce((result, fieldObject) => {
|
|
@@ -537,7 +523,6 @@ class TypeObject {
|
|
|
537
523
|
result.rankField = fieldObject.name;
|
|
538
524
|
result.rankFieldObject = fieldObject;
|
|
539
525
|
}
|
|
540
|
-
|
|
541
526
|
return result;
|
|
542
527
|
}, {
|
|
543
528
|
idField: null,
|
|
@@ -550,15 +535,12 @@ class TypeObject {
|
|
|
550
535
|
rankFieldObject: null
|
|
551
536
|
});
|
|
552
537
|
}));
|
|
553
|
-
|
|
554
538
|
if (!external_lodash_default().isPlainObject(rawTypeObject)) {
|
|
555
539
|
throw new Error("rawTypeObject arg must be plain object");
|
|
556
540
|
}
|
|
557
|
-
|
|
558
541
|
if (!external_lodash_default().isFunction(resolveTypeObject)) {
|
|
559
542
|
throw new Error("resolveTypeObject arg must be function");
|
|
560
543
|
}
|
|
561
|
-
|
|
562
544
|
this.name = rawTypeObject["fibery/name"];
|
|
563
545
|
this.description = rawTypeObject["fibery/description"] || null;
|
|
564
546
|
this.id = rawTypeObject["fibery/id"];
|
|
@@ -577,14 +559,12 @@ class TypeObject {
|
|
|
577
559
|
this.installedMixins = new Set(Object.keys(rawMeta["app/mixins"] || {}));
|
|
578
560
|
this.syncSource = rawMeta["sync/source"] || null;
|
|
579
561
|
this.version = version;
|
|
580
|
-
|
|
581
562
|
const fieldObjectsByNameOnceGetter = external_lodash_default().once(() => {
|
|
582
563
|
return factory.makeFieldObjectsByName({
|
|
583
564
|
type: this.name,
|
|
584
565
|
fieldObjects: this.fieldObjects
|
|
585
566
|
});
|
|
586
567
|
});
|
|
587
|
-
|
|
588
568
|
const fieldObjectsGetter = external_lodash_default().once(() => rawTypeObject["fibery/fields"].map(rawFieldObject => {
|
|
589
569
|
return factory.makeFieldObject({
|
|
590
570
|
rawFieldObject,
|
|
@@ -593,15 +573,12 @@ class TypeObject {
|
|
|
593
573
|
version
|
|
594
574
|
});
|
|
595
575
|
}));
|
|
596
|
-
|
|
597
576
|
Object.defineProperties(this, {
|
|
598
577
|
toJSON: {
|
|
599
578
|
value() {
|
|
600
579
|
if (false) {}
|
|
601
|
-
|
|
602
580
|
return rawTypeObject;
|
|
603
581
|
},
|
|
604
|
-
|
|
605
582
|
enumerable: false
|
|
606
583
|
},
|
|
607
584
|
fieldObjects: {
|
|
@@ -648,39 +625,30 @@ class TypeObject {
|
|
|
648
625
|
}
|
|
649
626
|
});
|
|
650
627
|
}
|
|
651
|
-
|
|
652
628
|
get idField() {
|
|
653
629
|
return this._getFieldObjectShortcuts().idField;
|
|
654
630
|
}
|
|
655
|
-
|
|
656
631
|
get idFieldObject() {
|
|
657
632
|
return this._getFieldObjectShortcuts().idFieldObject;
|
|
658
633
|
}
|
|
659
|
-
|
|
660
634
|
get publicIdField() {
|
|
661
635
|
return this._getFieldObjectShortcuts().publicIdField;
|
|
662
636
|
}
|
|
663
|
-
|
|
664
637
|
get publicIdFieldObject() {
|
|
665
638
|
return this._getFieldObjectShortcuts().publicIdFieldObject;
|
|
666
639
|
}
|
|
667
|
-
|
|
668
640
|
get titleField() {
|
|
669
641
|
return this._getFieldObjectShortcuts().titleField;
|
|
670
642
|
}
|
|
671
|
-
|
|
672
643
|
get titleFieldObject() {
|
|
673
644
|
return this._getFieldObjectShortcuts().titleFieldObject;
|
|
674
645
|
}
|
|
675
|
-
|
|
676
646
|
get rankField() {
|
|
677
647
|
return this._getFieldObjectShortcuts().rankField;
|
|
678
648
|
}
|
|
679
|
-
|
|
680
649
|
get rankFieldObject() {
|
|
681
650
|
return this._getFieldObjectShortcuts().rankFieldObject;
|
|
682
651
|
}
|
|
683
|
-
|
|
684
652
|
}
|
|
685
653
|
;// CONCATENATED MODULE: ./index.js
|
|
686
654
|
|
|
@@ -689,36 +657,50 @@ class TypeObject {
|
|
|
689
657
|
|
|
690
658
|
|
|
691
659
|
const factory = {
|
|
692
|
-
makeSchema: (rawSchema
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
660
|
+
makeSchema: function (rawSchema) {
|
|
661
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
662
|
+
shouldRemoveDeletedTypesAndFields: true
|
|
663
|
+
};
|
|
664
|
+
return new Schema({
|
|
665
|
+
rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
|
|
666
|
+
factory
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
makeTypeObject: args => new TypeObject({
|
|
670
|
+
...args,
|
|
699
671
|
factory
|
|
700
672
|
}),
|
|
701
673
|
makeTypeObjectsById: typeObjects => external_lodash_default().keyBy(typeObjects, x => x.id),
|
|
702
674
|
makeTypeObjectsByName: typeObjects => external_lodash_default().keyBy(typeObjects, x => x.name),
|
|
703
675
|
makeFieldObject: args => new FieldObject(args),
|
|
704
|
-
makeFieldObjectsById:
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
676
|
+
makeFieldObjectsById: _ref => {
|
|
677
|
+
let {
|
|
678
|
+
type,
|
|
679
|
+
fieldObjects
|
|
680
|
+
} = _ref;
|
|
681
|
+
return external_lodash_default().keyBy(fieldObjects, x => x.id);
|
|
682
|
+
},
|
|
683
|
+
makeFieldObjectsByName: _ref2 => {
|
|
684
|
+
let {
|
|
685
|
+
type,
|
|
686
|
+
fieldObjects
|
|
687
|
+
} = _ref2;
|
|
688
|
+
return external_lodash_default().keyBy(fieldObjects, x => x.name);
|
|
689
|
+
}
|
|
712
690
|
};
|
|
713
691
|
const protectiveFactory = {
|
|
714
|
-
makeSchema: (rawSchema
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
692
|
+
makeSchema: function (rawSchema) {
|
|
693
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
694
|
+
shouldRemoveDeletedTypesAndFields: true
|
|
695
|
+
};
|
|
696
|
+
return withOnlyDefinedGets(new Schema({
|
|
697
|
+
rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
|
|
698
|
+
factory: protectiveFactory
|
|
699
|
+
}), `schema`);
|
|
700
|
+
},
|
|
720
701
|
makeTypeObject: args => {
|
|
721
|
-
const typeObject = new TypeObject({
|
|
702
|
+
const typeObject = new TypeObject({
|
|
703
|
+
...args,
|
|
722
704
|
factory: protectiveFactory
|
|
723
705
|
});
|
|
724
706
|
return withOnlyDefinedGets(typeObject, `schema.typeObjectsByName["${typeObject.name}"]`);
|
|
@@ -729,14 +711,20 @@ const protectiveFactory = {
|
|
|
729
711
|
const fieldObject = new FieldObject(args);
|
|
730
712
|
return withOnlyDefinedGets(fieldObject, `schema.typeObjectsByName["${fieldObject.holderType}"].fieldObjectsByName["${fieldObject.name}"]`);
|
|
731
713
|
},
|
|
732
|
-
makeFieldObjectsById:
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
type
|
|
738
|
-
|
|
739
|
-
|
|
714
|
+
makeFieldObjectsById: _ref3 => {
|
|
715
|
+
let {
|
|
716
|
+
type,
|
|
717
|
+
fieldObjects
|
|
718
|
+
} = _ref3;
|
|
719
|
+
return withOnlyDefinedGets(external_lodash_default().keyBy(fieldObjects, x => x.id), `schema.typeObjectsByName["${type}"].fieldObjectsById`);
|
|
720
|
+
},
|
|
721
|
+
makeFieldObjectsByName: _ref4 => {
|
|
722
|
+
let {
|
|
723
|
+
type,
|
|
724
|
+
fieldObjects
|
|
725
|
+
} = _ref4;
|
|
726
|
+
return withOnlyDefinedGets(external_lodash_default().keyBy(fieldObjects, x => x.name), `schema.typeObjectsByName["${type}"].fieldObjectsByName`);
|
|
727
|
+
}
|
|
740
728
|
};
|
|
741
729
|
module.exports = __webpack_exports__;
|
|
742
730
|
/******/ })()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/schema",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.6",
|
|
4
4
|
"description": "utils for working with fibery schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"browser": "./index.js",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"private": false,
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"lodash": "^4.17.21",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"memoize-one": "^6.0.0",
|
|
16
|
+
"pluralize": "^8.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@babel/core": "7.
|
|
20
|
-
"babel-jest": "27.5.1",
|
|
21
|
-
"babel-loader": "8.2.5",
|
|
19
|
+
"@babel/core": "7.20.5",
|
|
22
20
|
"@fibery/babel-preset": "7.2.0",
|
|
23
21
|
"@fibery/eslint-config": "8.2.0",
|
|
24
22
|
"@fibery/helpers": "1.0.2",
|
|
23
|
+
"babel-jest": "27.5.1",
|
|
24
|
+
"babel-loader": "9.1.0",
|
|
25
25
|
"jest": "27.5.1",
|
|
26
26
|
"jest-junit": "13.0.0",
|
|
27
27
|
"webpack": "5.74.0",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "BABEL_ENV=production webpack",
|
|
32
32
|
"test": "node scripts/test.js",
|
|
33
|
-
"test:ci": "yarn test --
|
|
33
|
+
"test:ci": "yarn test --reporters=default --reporters=jest-junit",
|
|
34
|
+
"test:coverage": "yarn test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/schema --reporters=default --reporters=jest-junit",
|
|
34
35
|
"lint": "eslint ."
|
|
35
36
|
},
|
|
36
37
|
"jest": {
|
package/types.d.ts
CHANGED