@rljson/rljson 0.0.31 → 0.0.32
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/README.architecture.md +119 -54
- package/dist/README.architecture.md +119 -54
- package/dist/content/buffet.d.ts +6 -6
- package/dist/content/cake.d.ts +17 -16
- package/dist/content/ingredients.d.ts +16 -0
- package/dist/content/layer.d.ts +44 -0
- package/dist/content/slice-ids.d.ts +32 -0
- package/dist/content/table-cfg.d.ts +1 -1
- package/dist/example/bakery-example.d.ts +10 -10
- package/dist/example.d.ts +7 -7
- package/dist/index.d.ts +3 -3
- package/dist/rljson.d.ts +6 -6
- package/dist/rljson.js +208 -208
- package/dist/src/example.ts +59 -59
- package/dist/typedefs.d.ts +7 -7
- package/dist/validate/base-validator.d.ts +9 -9
- package/package.json +7 -7
- package/dist/content/collection.d.ts +0 -44
- package/dist/content/id-set.d.ts +0 -33
- package/dist/content/properties.d.ts +0 -16
package/dist/rljson.js
CHANGED
|
@@ -6,7 +6,7 @@ import { exampleJsonObject, jsonValueTypes, jsonValueMatchesType } from "@rljson
|
|
|
6
6
|
// @license
|
|
7
7
|
const bakeryExample = () => {
|
|
8
8
|
const nutritionalValues = hip({
|
|
9
|
-
_type: "
|
|
9
|
+
_type: "ingredients",
|
|
10
10
|
_data: [
|
|
11
11
|
{
|
|
12
12
|
energy: 364,
|
|
@@ -19,7 +19,7 @@ const bakeryExample = () => {
|
|
|
19
19
|
_hash: ""
|
|
20
20
|
});
|
|
21
21
|
const ingredients = hip({
|
|
22
|
-
_type: "
|
|
22
|
+
_type: "ingredients",
|
|
23
23
|
_data: [
|
|
24
24
|
{
|
|
25
25
|
name: "flour",
|
|
@@ -31,7 +31,7 @@ const bakeryExample = () => {
|
|
|
31
31
|
_hash: ""
|
|
32
32
|
});
|
|
33
33
|
const recipeIngredients = hip({
|
|
34
|
-
_type: "
|
|
34
|
+
_type: "ingredients",
|
|
35
35
|
_data: [
|
|
36
36
|
{
|
|
37
37
|
ingredientsRef: ingredients._data[0]._hash,
|
|
@@ -42,10 +42,10 @@ const bakeryExample = () => {
|
|
|
42
42
|
_hash: ""
|
|
43
43
|
});
|
|
44
44
|
const recipes = hip({
|
|
45
|
-
_type: "
|
|
45
|
+
_type: "layers",
|
|
46
46
|
_data: [
|
|
47
47
|
{
|
|
48
|
-
|
|
48
|
+
ingredientsTable: "recipeIngredients",
|
|
49
49
|
assign: {
|
|
50
50
|
flour: recipeIngredients._data[0]._hash
|
|
51
51
|
},
|
|
@@ -54,10 +54,10 @@ const bakeryExample = () => {
|
|
|
54
54
|
]
|
|
55
55
|
});
|
|
56
56
|
const layers = hip({
|
|
57
|
-
_type: "
|
|
57
|
+
_type: "layers",
|
|
58
58
|
_data: [
|
|
59
59
|
{
|
|
60
|
-
|
|
60
|
+
ingredientsTable: "recipes",
|
|
61
61
|
assign: {
|
|
62
62
|
slice0: recipes._data[0]._hash,
|
|
63
63
|
slice1: recipes._data[0]._hash
|
|
@@ -66,7 +66,7 @@ const bakeryExample = () => {
|
|
|
66
66
|
]
|
|
67
67
|
});
|
|
68
68
|
const slices = hip({
|
|
69
|
-
_type: "
|
|
69
|
+
_type: "sliceIds",
|
|
70
70
|
_data: [
|
|
71
71
|
{
|
|
72
72
|
add: ["slice0", "slice1"],
|
|
@@ -80,9 +80,9 @@ const bakeryExample = () => {
|
|
|
80
80
|
_type: "cakes",
|
|
81
81
|
_data: [
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
sliceIdsTable: "slices",
|
|
84
84
|
idSet: slices._data[0]._hash,
|
|
85
|
-
|
|
85
|
+
layersTable: "layers",
|
|
86
86
|
layers: {
|
|
87
87
|
flour: layers._data[0]._hash
|
|
88
88
|
},
|
|
@@ -120,11 +120,11 @@ const exampleBuffetsTable = () => bakeryExample().buffets;
|
|
|
120
120
|
// @license
|
|
121
121
|
const exampleCakesTable = () => bakeryExample().cakes;
|
|
122
122
|
// @license
|
|
123
|
-
const
|
|
123
|
+
const exampleIngredientsTable = () => bakeryExample().nutritionalValues;
|
|
124
124
|
// @license
|
|
125
|
-
const
|
|
125
|
+
const exampleLayersTable = () => bakeryExample().layers;
|
|
126
126
|
// @license
|
|
127
|
-
const
|
|
127
|
+
const exampleSliceIdsTable = () => bakeryExample().slices;
|
|
128
128
|
// @license
|
|
129
129
|
const _Example = class _Example {
|
|
130
130
|
};
|
|
@@ -136,7 +136,7 @@ __publicField(_Example, "ok", {
|
|
|
136
136
|
binary: () => {
|
|
137
137
|
return {
|
|
138
138
|
table: {
|
|
139
|
-
_type: "
|
|
139
|
+
_type: "ingredients",
|
|
140
140
|
_data: [
|
|
141
141
|
{ a: false, b: false },
|
|
142
142
|
{ a: false, b: true },
|
|
@@ -149,13 +149,13 @@ __publicField(_Example, "ok", {
|
|
|
149
149
|
singleRow: () => {
|
|
150
150
|
const tableCfgs = hip({
|
|
151
151
|
_hash: "",
|
|
152
|
-
_type: "
|
|
152
|
+
_type: "ingredients",
|
|
153
153
|
_data: [
|
|
154
154
|
{
|
|
155
155
|
version: 0,
|
|
156
156
|
_hash: "",
|
|
157
157
|
key: "table",
|
|
158
|
-
type: "
|
|
158
|
+
type: "ingredients",
|
|
159
159
|
columns: {
|
|
160
160
|
int: {
|
|
161
161
|
key: "int",
|
|
@@ -196,7 +196,7 @@ __publicField(_Example, "ok", {
|
|
|
196
196
|
const result = {
|
|
197
197
|
tableCfgs,
|
|
198
198
|
table: {
|
|
199
|
-
_type: "
|
|
199
|
+
_type: "ingredients",
|
|
200
200
|
_tableCfg: tableCfgs._data[0]._hash,
|
|
201
201
|
_data: [exampleJsonObject()],
|
|
202
202
|
_hash: ""
|
|
@@ -207,7 +207,7 @@ __publicField(_Example, "ok", {
|
|
|
207
207
|
multipleRows: () => {
|
|
208
208
|
return {
|
|
209
209
|
table: {
|
|
210
|
-
_type: "
|
|
210
|
+
_type: "ingredients",
|
|
211
211
|
_data: [
|
|
212
212
|
{
|
|
213
213
|
string: "str0",
|
|
@@ -237,7 +237,7 @@ __publicField(_Example, "ok", {
|
|
|
237
237
|
singleRef: () => {
|
|
238
238
|
return {
|
|
239
239
|
tableA: {
|
|
240
|
-
_type: "
|
|
240
|
+
_type: "ingredients",
|
|
241
241
|
_data: [
|
|
242
242
|
{
|
|
243
243
|
keyA0: "a0"
|
|
@@ -248,7 +248,7 @@ __publicField(_Example, "ok", {
|
|
|
248
248
|
]
|
|
249
249
|
},
|
|
250
250
|
tableB: {
|
|
251
|
-
_type: "
|
|
251
|
+
_type: "ingredients",
|
|
252
252
|
_data: [
|
|
253
253
|
{
|
|
254
254
|
tableARef: "KFQrf4mEz0UPmUaFHwH4T6"
|
|
@@ -258,47 +258,47 @@ __publicField(_Example, "ok", {
|
|
|
258
258
|
};
|
|
259
259
|
},
|
|
260
260
|
complete: () => {
|
|
261
|
-
const
|
|
262
|
-
_type: "
|
|
261
|
+
const sliceIds = hip({
|
|
262
|
+
_type: "sliceIds",
|
|
263
263
|
_data: [
|
|
264
264
|
{
|
|
265
265
|
add: ["id0", "id1"]
|
|
266
266
|
}
|
|
267
267
|
]
|
|
268
268
|
});
|
|
269
|
-
const
|
|
270
|
-
_type: "
|
|
269
|
+
const ingredients = hip({
|
|
270
|
+
_type: "ingredients",
|
|
271
271
|
_data: [{ a: "0" }, { a: "1" }]
|
|
272
272
|
});
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
|
|
273
|
+
const ingredient0 = ingredients._data[0];
|
|
274
|
+
const ingredient1 = ingredients._data[1];
|
|
275
|
+
const layer0 = hip({
|
|
276
|
+
sliceIdsTable: "sliceIds",
|
|
277
277
|
idSet: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
278
|
-
|
|
278
|
+
ingredientsTable: "ingredients",
|
|
279
279
|
assign: {}
|
|
280
280
|
});
|
|
281
|
-
const
|
|
282
|
-
base:
|
|
283
|
-
|
|
281
|
+
const layer1 = hip({
|
|
282
|
+
base: layer0._hash,
|
|
283
|
+
sliceIdsTable: "sliceIds",
|
|
284
284
|
idSet: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
285
|
-
|
|
285
|
+
ingredientsTable: "ingredients",
|
|
286
286
|
assign: {
|
|
287
|
-
id0:
|
|
288
|
-
id1:
|
|
287
|
+
id0: ingredient0._hash,
|
|
288
|
+
id1: ingredient1._hash
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
|
-
const
|
|
292
|
-
_type: "
|
|
293
|
-
_data: [
|
|
291
|
+
const layers = hip({
|
|
292
|
+
_type: "layers",
|
|
293
|
+
_data: [layer0, layer1]
|
|
294
294
|
});
|
|
295
295
|
const cake = hip({
|
|
296
|
-
|
|
297
|
-
idSet:
|
|
298
|
-
|
|
296
|
+
sliceIdsTable: "sliceIds",
|
|
297
|
+
idSet: sliceIds._data[0]._hash,
|
|
298
|
+
layersTable: "layers",
|
|
299
299
|
layers: {
|
|
300
|
-
layer0:
|
|
301
|
-
layer1:
|
|
300
|
+
layer0: layer0._hash,
|
|
301
|
+
layer1: layer1._hash
|
|
302
302
|
}
|
|
303
303
|
});
|
|
304
304
|
const cakes = hip({
|
|
@@ -315,17 +315,17 @@ __publicField(_Example, "ok", {
|
|
|
315
315
|
ref: cakes._data[0]._hash
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
|
-
table: "
|
|
319
|
-
ref:
|
|
318
|
+
table: "layers",
|
|
319
|
+
ref: layer0._hash
|
|
320
320
|
}
|
|
321
321
|
]
|
|
322
322
|
}
|
|
323
323
|
]
|
|
324
324
|
});
|
|
325
325
|
return {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
sliceIds,
|
|
327
|
+
ingredients,
|
|
328
|
+
layers,
|
|
329
329
|
cakes,
|
|
330
330
|
buffets
|
|
331
331
|
};
|
|
@@ -336,7 +336,7 @@ __publicField(_Example, "broken", {
|
|
|
336
336
|
brokenTableKey: () => {
|
|
337
337
|
return {
|
|
338
338
|
brok$en: {
|
|
339
|
-
_type: "
|
|
339
|
+
_type: "ingredients",
|
|
340
340
|
_data: []
|
|
341
341
|
}
|
|
342
342
|
};
|
|
@@ -344,14 +344,14 @@ __publicField(_Example, "broken", {
|
|
|
344
344
|
missingData: () => {
|
|
345
345
|
return {
|
|
346
346
|
table: {
|
|
347
|
-
_type: "
|
|
347
|
+
_type: "ingredients"
|
|
348
348
|
}
|
|
349
349
|
};
|
|
350
350
|
},
|
|
351
351
|
dataNotBeingAnArray: () => {
|
|
352
352
|
return {
|
|
353
353
|
table: {
|
|
354
|
-
_type: "
|
|
354
|
+
_type: "ingredients",
|
|
355
355
|
_data: {}
|
|
356
356
|
}
|
|
357
357
|
};
|
|
@@ -359,7 +359,7 @@ __publicField(_Example, "broken", {
|
|
|
359
359
|
missingRef: () => {
|
|
360
360
|
return {
|
|
361
361
|
tableA: {
|
|
362
|
-
_type: "
|
|
362
|
+
_type: "ingredients",
|
|
363
363
|
_data: [
|
|
364
364
|
{
|
|
365
365
|
keyA0: "a0"
|
|
@@ -370,7 +370,7 @@ __publicField(_Example, "broken", {
|
|
|
370
370
|
]
|
|
371
371
|
},
|
|
372
372
|
tableB: {
|
|
373
|
-
_type: "
|
|
373
|
+
_type: "ingredients",
|
|
374
374
|
_data: [
|
|
375
375
|
{
|
|
376
376
|
tableARef: "MISSINGREF"
|
|
@@ -383,7 +383,7 @@ __publicField(_Example, "broken", {
|
|
|
383
383
|
missingReferencedTable: () => {
|
|
384
384
|
return {
|
|
385
385
|
tableB: {
|
|
386
|
-
_type: "
|
|
386
|
+
_type: "ingredients",
|
|
387
387
|
_data: [
|
|
388
388
|
{
|
|
389
389
|
tableARef: "MISSINGREF"
|
|
@@ -402,44 +402,44 @@ __publicField(_Example, "broken", {
|
|
|
402
402
|
return hip(result, true, false);
|
|
403
403
|
}
|
|
404
404
|
},
|
|
405
|
-
|
|
405
|
+
layers: {
|
|
406
406
|
missingBase: () => {
|
|
407
407
|
const result = _Example.ok.complete();
|
|
408
|
-
const
|
|
409
|
-
|
|
408
|
+
const layer1 = result.layers._data[1];
|
|
409
|
+
layer1.base = "MISSING";
|
|
410
410
|
return hip(result, true, false);
|
|
411
411
|
},
|
|
412
|
-
|
|
412
|
+
missingSliceIdSet: () => {
|
|
413
413
|
const result = _Example.ok.complete();
|
|
414
|
-
const
|
|
415
|
-
|
|
414
|
+
const layer1 = result.layers._data[1];
|
|
415
|
+
layer1.idSet = "MISSING1";
|
|
416
416
|
return hip(result, true, false);
|
|
417
417
|
},
|
|
418
|
-
|
|
418
|
+
missingAssignedIngredientTable: () => {
|
|
419
419
|
const result = _Example.ok.complete();
|
|
420
|
-
delete result.
|
|
420
|
+
delete result.ingredients;
|
|
421
421
|
return result;
|
|
422
422
|
},
|
|
423
|
-
|
|
423
|
+
missingAssignedIngredient: () => {
|
|
424
424
|
const result = _Example.ok.complete();
|
|
425
|
-
result.
|
|
425
|
+
result.ingredients._data.splice(1, 2);
|
|
426
426
|
return hip(result, true, false);
|
|
427
427
|
}
|
|
428
428
|
},
|
|
429
429
|
cakes: {
|
|
430
|
-
|
|
430
|
+
missingSliceIdSet: () => {
|
|
431
431
|
const result = _Example.ok.complete();
|
|
432
432
|
result.cakes._data[0].idSet = "MISSING";
|
|
433
433
|
hip(result.cakes, true, false);
|
|
434
434
|
return result;
|
|
435
435
|
},
|
|
436
|
-
|
|
436
|
+
missingLayersTable: () => {
|
|
437
437
|
const result = _Example.ok.complete();
|
|
438
|
-
result.cakes._data[0].
|
|
438
|
+
result.cakes._data[0].layersTable = "MISSING";
|
|
439
439
|
hip(result.cakes, true, false);
|
|
440
440
|
return result;
|
|
441
441
|
},
|
|
442
|
-
|
|
442
|
+
missingCakeLayer: () => {
|
|
443
443
|
const result = _Example.ok.complete();
|
|
444
444
|
result.cakes._data[0].layers["layer0"] = "MISSING0";
|
|
445
445
|
result.cakes._data[0].layers["layer1"] = "MISSING1";
|
|
@@ -483,24 +483,24 @@ const exampleTableCfg = (tableCfg = void 0) => {
|
|
|
483
483
|
type: "number"
|
|
484
484
|
}
|
|
485
485
|
},
|
|
486
|
-
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "
|
|
486
|
+
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "ingredients"
|
|
487
487
|
};
|
|
488
488
|
};
|
|
489
489
|
// @license
|
|
490
490
|
const rljsonIndexed = (rljson) => {
|
|
491
491
|
const result = {};
|
|
492
492
|
for (const key in rljson) {
|
|
493
|
-
const
|
|
494
|
-
if (typeof
|
|
495
|
-
result[key] =
|
|
493
|
+
const slice = rljson[key];
|
|
494
|
+
if (typeof slice != "object") {
|
|
495
|
+
result[key] = slice;
|
|
496
496
|
continue;
|
|
497
497
|
}
|
|
498
498
|
const dataIndexed = {};
|
|
499
|
-
result[key] = { ...
|
|
500
|
-
if (!Array.isArray(
|
|
499
|
+
result[key] = { ...slice };
|
|
500
|
+
if (!Array.isArray(slice._data)) {
|
|
501
501
|
continue;
|
|
502
502
|
}
|
|
503
|
-
for (const row of
|
|
503
|
+
for (const row of slice._data) {
|
|
504
504
|
const hashedRow = row._hash ? row : hsh(row);
|
|
505
505
|
const hash = hashedRow._hash;
|
|
506
506
|
dataIndexed[hash] = hashedRow;
|
|
@@ -511,7 +511,7 @@ const rljsonIndexed = (rljson) => {
|
|
|
511
511
|
};
|
|
512
512
|
// @license
|
|
513
513
|
const reservedFieldNames = ["_type", "_data"];
|
|
514
|
-
const reservedTableKeys = ["_hash", "
|
|
514
|
+
const reservedTableKeys = ["_hash", "sliceIds", "tableCfgs"];
|
|
515
515
|
const exampleRljson = () => Example.ok.singleRow();
|
|
516
516
|
const iterateTables = (rljson, callback) => {
|
|
517
517
|
for (const tableKey in rljson) {
|
|
@@ -526,16 +526,16 @@ const iterateTables = (rljson, callback) => {
|
|
|
526
526
|
const contentTypes = [
|
|
527
527
|
"buffets",
|
|
528
528
|
"cakes",
|
|
529
|
-
"
|
|
530
|
-
"
|
|
531
|
-
"
|
|
529
|
+
"layers",
|
|
530
|
+
"sliceIds",
|
|
531
|
+
"ingredients"
|
|
532
532
|
];
|
|
533
533
|
const exampleTypedefs = () => {
|
|
534
534
|
return {
|
|
535
535
|
ref: "ref",
|
|
536
|
-
|
|
536
|
+
sliceId: "sliceId",
|
|
537
537
|
tableKey: "tableKey",
|
|
538
|
-
contentType: "
|
|
538
|
+
contentType: "layers"
|
|
539
539
|
};
|
|
540
540
|
};
|
|
541
541
|
// @license
|
|
@@ -589,15 +589,15 @@ class _BaseValidator {
|
|
|
589
589
|
() => this._tableTypesDoNotMatch(),
|
|
590
590
|
// Check references
|
|
591
591
|
() => this._refsNotFound(),
|
|
592
|
-
// Check
|
|
593
|
-
() => this.
|
|
594
|
-
() => this.
|
|
595
|
-
() => this.
|
|
596
|
-
() => this.
|
|
592
|
+
// Check layers
|
|
593
|
+
() => this._layerBasesNotFound(),
|
|
594
|
+
() => this._layerSliceIdsTableNotFound(),
|
|
595
|
+
() => this._layerSliceIdsNotFound(),
|
|
596
|
+
() => this._layerIngredientAssignmentsNotFound(),
|
|
597
597
|
// Check cakes
|
|
598
|
-
() => this.
|
|
599
|
-
() => this.
|
|
600
|
-
() => this.
|
|
598
|
+
() => this._cakeSliceIdsTableNotFound(),
|
|
599
|
+
() => this._cakeSliceIdsNotFound(),
|
|
600
|
+
() => this._cakeLayerTablesNotFound(),
|
|
601
601
|
// Check buffets
|
|
602
602
|
() => this._buffetReferencedTableNotFound()
|
|
603
603
|
];
|
|
@@ -976,147 +976,147 @@ class _BaseValidator {
|
|
|
976
976
|
};
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
|
|
980
|
-
const
|
|
979
|
+
_layerBasesNotFound() {
|
|
980
|
+
const brokenLayers = [];
|
|
981
981
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
982
|
-
if (table._type !== "
|
|
982
|
+
if (table._type !== "layers") {
|
|
983
983
|
return;
|
|
984
984
|
}
|
|
985
|
-
const
|
|
986
|
-
const
|
|
987
|
-
for (const
|
|
988
|
-
const baseRef =
|
|
985
|
+
const layersIndexed = this.rljsonIndexed[tableKey];
|
|
986
|
+
const layersTable = table;
|
|
987
|
+
for (const layer of layersTable._data) {
|
|
988
|
+
const baseRef = layer.base;
|
|
989
989
|
if (!baseRef) {
|
|
990
990
|
continue;
|
|
991
991
|
}
|
|
992
|
-
const
|
|
993
|
-
if (!
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
992
|
+
const baseLayer = layersIndexed._data[baseRef];
|
|
993
|
+
if (!baseLayer) {
|
|
994
|
+
brokenLayers.push({
|
|
995
|
+
layersTable: tableKey,
|
|
996
|
+
brokenLayer: layer._hash,
|
|
997
|
+
missingBaseLayer: baseRef
|
|
998
998
|
});
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
});
|
|
1002
|
-
if (
|
|
1003
|
-
this.errors.
|
|
1004
|
-
error: "Base
|
|
1005
|
-
|
|
1002
|
+
if (brokenLayers.length > 0) {
|
|
1003
|
+
this.errors.layerBasesNotFound = {
|
|
1004
|
+
error: "Base layers are missing",
|
|
1005
|
+
brokenLayers
|
|
1006
1006
|
};
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
|
-
|
|
1010
|
-
const
|
|
1009
|
+
_layerSliceIdsTableNotFound() {
|
|
1010
|
+
const brokenLayers = [];
|
|
1011
1011
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1012
|
-
if (table._type !== "
|
|
1012
|
+
if (table._type !== "layers") {
|
|
1013
1013
|
return;
|
|
1014
1014
|
}
|
|
1015
|
-
const
|
|
1016
|
-
for (const
|
|
1017
|
-
const
|
|
1018
|
-
if (!
|
|
1015
|
+
const layersTable = table;
|
|
1016
|
+
for (const layer of layersTable._data) {
|
|
1017
|
+
const sliceIds = layer.sliceIdsTable;
|
|
1018
|
+
if (!sliceIds) {
|
|
1019
1019
|
continue;
|
|
1020
1020
|
}
|
|
1021
|
-
const
|
|
1022
|
-
if (!
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1021
|
+
const sliceIdsTable = this.rljsonIndexed[sliceIds];
|
|
1022
|
+
if (!sliceIdsTable) {
|
|
1023
|
+
brokenLayers.push({
|
|
1024
|
+
layersTable: tableKey,
|
|
1025
|
+
layerHash: layer._hash,
|
|
1026
|
+
missingSliceIdsTable: sliceIds
|
|
1027
1027
|
});
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
|
1030
1030
|
});
|
|
1031
|
-
if (
|
|
1032
|
-
this.errors.
|
|
1031
|
+
if (brokenLayers.length > 0) {
|
|
1032
|
+
this.errors.layerSliceIdsTableNotFound = {
|
|
1033
1033
|
error: "Id sets tables are missing",
|
|
1034
|
-
|
|
1034
|
+
brokenLayers
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
1037
|
}
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1038
|
+
_layerSliceIdsNotFound() {
|
|
1039
|
+
const brokenLayers = [];
|
|
1040
1040
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1041
|
-
if (table._type !== "
|
|
1041
|
+
if (table._type !== "layers") {
|
|
1042
1042
|
return;
|
|
1043
1043
|
}
|
|
1044
|
-
const
|
|
1045
|
-
for (const
|
|
1046
|
-
const idSetRef =
|
|
1044
|
+
const layersTable = table;
|
|
1045
|
+
for (const layer of layersTable._data) {
|
|
1046
|
+
const idSetRef = layer.idSet;
|
|
1047
1047
|
if (!idSetRef) {
|
|
1048
1048
|
continue;
|
|
1049
1049
|
}
|
|
1050
|
-
const
|
|
1051
|
-
const
|
|
1052
|
-
const idSet =
|
|
1050
|
+
const sliceIds = layer.sliceIdsTable;
|
|
1051
|
+
const sliceIdsTable = this.rljsonIndexed[sliceIds];
|
|
1052
|
+
const idSet = sliceIdsTable._data[idSetRef];
|
|
1053
1053
|
if (!idSet) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1054
|
+
brokenLayers.push({
|
|
1055
|
+
layersTable: tableKey,
|
|
1056
|
+
layerHash: layer._hash,
|
|
1057
|
+
missingSliceIds: idSetRef
|
|
1058
1058
|
});
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
});
|
|
1062
|
-
if (
|
|
1063
|
-
this.errors.
|
|
1064
|
-
error: "Id sets of
|
|
1065
|
-
|
|
1062
|
+
if (brokenLayers.length > 0) {
|
|
1063
|
+
this.errors.layerSliceIdsNotFound = {
|
|
1064
|
+
error: "Id sets of layers are missing",
|
|
1065
|
+
brokenLayers
|
|
1066
1066
|
};
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
|
-
|
|
1070
|
-
const
|
|
1069
|
+
_layerIngredientAssignmentsNotFound() {
|
|
1070
|
+
const missingIngredientTables = [];
|
|
1071
1071
|
const brokenAssignments = [];
|
|
1072
1072
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1073
|
-
if (table._type !== "
|
|
1073
|
+
if (table._type !== "layers") {
|
|
1074
1074
|
return;
|
|
1075
1075
|
}
|
|
1076
|
-
const
|
|
1077
|
-
for (const
|
|
1078
|
-
const
|
|
1079
|
-
const
|
|
1080
|
-
if (!
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1076
|
+
const layersTable = table;
|
|
1077
|
+
for (const layer of layersTable._data) {
|
|
1078
|
+
const ingredientTableKey = layer.ingredientsTable;
|
|
1079
|
+
const ingredientsTable = this.rljsonIndexed[ingredientTableKey];
|
|
1080
|
+
if (!ingredientsTable) {
|
|
1081
|
+
missingIngredientTables.push({
|
|
1082
|
+
brokenLayer: layer._hash,
|
|
1083
|
+
layersTable: tableKey,
|
|
1084
|
+
missingIngredientTable: ingredientTableKey
|
|
1085
1085
|
});
|
|
1086
1086
|
continue;
|
|
1087
1087
|
}
|
|
1088
|
-
const assignments =
|
|
1089
|
-
for (const
|
|
1090
|
-
if (
|
|
1088
|
+
const assignments = layer.assign;
|
|
1089
|
+
for (const sliceId in assignments) {
|
|
1090
|
+
if (sliceId.startsWith("_")) {
|
|
1091
1091
|
continue;
|
|
1092
1092
|
}
|
|
1093
|
-
const
|
|
1094
|
-
if (!
|
|
1093
|
+
const ingredientHash = assignments[sliceId];
|
|
1094
|
+
if (!ingredientsTable._data[ingredientHash]) {
|
|
1095
1095
|
brokenAssignments.push({
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
brokenAssignment:
|
|
1100
|
-
|
|
1096
|
+
layersTable: tableKey,
|
|
1097
|
+
brokenLayer: layer._hash,
|
|
1098
|
+
referencedIngredientTable: ingredientTableKey,
|
|
1099
|
+
brokenAssignment: sliceId,
|
|
1100
|
+
missingIngredient: ingredientHash
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
1105
|
});
|
|
1106
|
-
if (
|
|
1107
|
-
this.errors.
|
|
1108
|
-
error: "
|
|
1109
|
-
|
|
1106
|
+
if (missingIngredientTables.length > 0) {
|
|
1107
|
+
this.errors.layerIngredientTablesNotFound = {
|
|
1108
|
+
error: "Layer ingredient tables do not exist",
|
|
1109
|
+
layers: missingIngredientTables
|
|
1110
1110
|
};
|
|
1111
1111
|
}
|
|
1112
1112
|
if (brokenAssignments.length > 0) {
|
|
1113
|
-
this.errors.
|
|
1114
|
-
error: "
|
|
1113
|
+
this.errors.layerIngredientAssignmentsNotFound = {
|
|
1114
|
+
error: "Layer ingredient assignments are broken",
|
|
1115
1115
|
brokenAssignments
|
|
1116
1116
|
};
|
|
1117
1117
|
}
|
|
1118
1118
|
}
|
|
1119
|
-
|
|
1119
|
+
_cakeSliceIdsTableNotFound() {
|
|
1120
1120
|
const brokenCakes = [];
|
|
1121
1121
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1122
1122
|
if (table._type !== "cakes") {
|
|
@@ -1124,28 +1124,28 @@ class _BaseValidator {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
const cakesTable = table;
|
|
1126
1126
|
for (const cake of cakesTable._data) {
|
|
1127
|
-
const
|
|
1128
|
-
if (!
|
|
1127
|
+
const sliceIdsRef = cake.sliceIdsTable;
|
|
1128
|
+
if (!sliceIdsRef) {
|
|
1129
1129
|
continue;
|
|
1130
1130
|
}
|
|
1131
|
-
const
|
|
1132
|
-
if (!
|
|
1131
|
+
const sliceIds = this.rljsonIndexed[sliceIdsRef];
|
|
1132
|
+
if (!sliceIds) {
|
|
1133
1133
|
brokenCakes.push({
|
|
1134
1134
|
cakeTable: tableKey,
|
|
1135
1135
|
brokenCake: cake._hash,
|
|
1136
|
-
|
|
1136
|
+
missingSliceIds: sliceIdsRef
|
|
1137
1137
|
});
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
});
|
|
1141
1141
|
if (brokenCakes.length > 0) {
|
|
1142
|
-
this.errors.
|
|
1142
|
+
this.errors.cakeSliceIdsTableNotFound = {
|
|
1143
1143
|
error: "Id sets tables referenced by cakes are missing",
|
|
1144
1144
|
brokenCakes
|
|
1145
1145
|
};
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
|
-
|
|
1148
|
+
_cakeSliceIdsNotFound() {
|
|
1149
1149
|
const brokenCakes = [];
|
|
1150
1150
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1151
1151
|
if (table._type !== "cakes") {
|
|
@@ -1157,72 +1157,72 @@ class _BaseValidator {
|
|
|
1157
1157
|
if (!idSetRef) {
|
|
1158
1158
|
continue;
|
|
1159
1159
|
}
|
|
1160
|
-
const
|
|
1161
|
-
const
|
|
1162
|
-
const idSet =
|
|
1160
|
+
const sliceIdsRef = cake.sliceIdsTable;
|
|
1161
|
+
const sliceIds = this.rljsonIndexed[sliceIdsRef];
|
|
1162
|
+
const idSet = sliceIds._data[idSetRef];
|
|
1163
1163
|
if (!idSet) {
|
|
1164
1164
|
brokenCakes.push({
|
|
1165
1165
|
cakeTable: tableKey,
|
|
1166
1166
|
brokenCake: cake._hash,
|
|
1167
|
-
|
|
1167
|
+
missingSliceIds: idSetRef
|
|
1168
1168
|
});
|
|
1169
1169
|
}
|
|
1170
1170
|
}
|
|
1171
1171
|
});
|
|
1172
1172
|
if (brokenCakes.length > 0) {
|
|
1173
|
-
this.errors.
|
|
1173
|
+
this.errors.cakeSliceIdsNotFound = {
|
|
1174
1174
|
error: "Id sets of cakes are missing",
|
|
1175
1175
|
brokenCakes
|
|
1176
1176
|
};
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
const
|
|
1179
|
+
_cakeLayerTablesNotFound() {
|
|
1180
|
+
const missingLayerTables = [];
|
|
1181
|
+
const missingCakeLayers = [];
|
|
1182
1182
|
iterateTables(this.rljson, (tableKey, table) => {
|
|
1183
1183
|
if (table._type !== "cakes") {
|
|
1184
1184
|
return;
|
|
1185
1185
|
}
|
|
1186
1186
|
const cakesTable = table;
|
|
1187
1187
|
for (const cake of cakesTable._data) {
|
|
1188
|
-
const
|
|
1189
|
-
const
|
|
1190
|
-
if (!
|
|
1191
|
-
|
|
1188
|
+
const layersTableKey = cake.layersTable;
|
|
1189
|
+
const layersTable = this.rljsonIndexed[layersTableKey];
|
|
1190
|
+
if (!layersTable) {
|
|
1191
|
+
missingLayerTables.push({
|
|
1192
1192
|
cakeTable: tableKey,
|
|
1193
1193
|
brokenCake: cake._hash,
|
|
1194
|
-
|
|
1194
|
+
missingLayersTable: layersTableKey
|
|
1195
1195
|
});
|
|
1196
1196
|
continue;
|
|
1197
1197
|
}
|
|
1198
|
-
for (const
|
|
1199
|
-
if (
|
|
1198
|
+
for (const layerKey in cake.layers) {
|
|
1199
|
+
if (layerKey.startsWith("_")) {
|
|
1200
1200
|
continue;
|
|
1201
1201
|
}
|
|
1202
|
-
const
|
|
1203
|
-
const
|
|
1204
|
-
if (!
|
|
1205
|
-
|
|
1202
|
+
const layerRef = cake.layers[layerKey];
|
|
1203
|
+
const layer = layersTable._data[layerRef];
|
|
1204
|
+
if (!layer) {
|
|
1205
|
+
missingCakeLayers.push({
|
|
1206
1206
|
cakeTable: tableKey,
|
|
1207
1207
|
brokenCake: cake._hash,
|
|
1208
|
-
brokenLayerName:
|
|
1209
|
-
|
|
1210
|
-
|
|
1208
|
+
brokenLayerName: layerKey,
|
|
1209
|
+
layersTable: layersTableKey,
|
|
1210
|
+
missingLayer: layerRef
|
|
1211
1211
|
});
|
|
1212
1212
|
}
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
1215
|
});
|
|
1216
|
-
if (
|
|
1217
|
-
this.errors.
|
|
1218
|
-
error: "
|
|
1219
|
-
brokenCakes:
|
|
1216
|
+
if (missingLayerTables.length > 0) {
|
|
1217
|
+
this.errors.cakeLayerTablesNotFound = {
|
|
1218
|
+
error: "Layer tables of cakes are missing",
|
|
1219
|
+
brokenCakes: missingLayerTables
|
|
1220
1220
|
};
|
|
1221
1221
|
}
|
|
1222
|
-
if (
|
|
1223
|
-
this.errors.
|
|
1224
|
-
error: "Layer
|
|
1225
|
-
brokenCakes:
|
|
1222
|
+
if (missingCakeLayers.length > 0) {
|
|
1223
|
+
this.errors.cakeLayersNotFound = {
|
|
1224
|
+
error: "Layer layers of cakes are missing",
|
|
1225
|
+
brokenCakes: missingCakeLayers
|
|
1226
1226
|
};
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
@@ -1319,10 +1319,10 @@ export {
|
|
|
1319
1319
|
contentTypes,
|
|
1320
1320
|
exampleBuffetsTable,
|
|
1321
1321
|
exampleCakesTable,
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
examplePropertiesTable,
|
|
1322
|
+
exampleIngredientsTable,
|
|
1323
|
+
exampleLayersTable,
|
|
1325
1324
|
exampleRljson,
|
|
1325
|
+
exampleSliceIdsTable,
|
|
1326
1326
|
exampleTableCfg,
|
|
1327
1327
|
exampleTableCfgTable,
|
|
1328
1328
|
exampleTypedefs,
|