@rljson/rljson 0.0.50 → 0.0.52
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 +84 -36
- package/dist/README.architecture.md +84 -36
- package/dist/content/buffet.d.ts +1 -1
- package/dist/content/cake.d.ts +2 -6
- package/dist/content/components.d.ts +15 -0
- package/dist/content/layer.d.ts +15 -8
- package/dist/content/revision.d.ts +2 -2
- package/dist/content/slice-ids.d.ts +1 -1
- package/dist/content/table-cfg.d.ts +2 -1
- package/dist/example/bakery-example.d.ts +7 -7
- package/dist/example.d.ts +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/rljson.d.ts +6 -4
- package/dist/rljson.js +122 -106
- package/dist/src/example.ts +46 -35
- package/dist/typedefs.d.ts +2 -2
- package/dist/validate/base-validator.d.ts +2 -2
- package/package.json +23 -31
- package/dist/content/ingredients.d.ts +0 -15
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Json } from '@rljson/json';
|
|
2
2
|
import { BuffetsTable } from '../content/buffet.ts';
|
|
3
3
|
import { CakesTable } from '../content/cake.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { ComponentsTable } from '../content/components.ts';
|
|
5
5
|
import { LayersTable } from '../content/layer.ts';
|
|
6
6
|
import { SliceIdsTable } from '../content/slice-ids.ts';
|
|
7
7
|
import { Rljson } from '../rljson.ts';
|
|
@@ -11,11 +11,11 @@ export interface Ingredient extends Json {
|
|
|
11
11
|
amountUnit: 'g' | 'ml';
|
|
12
12
|
nutritionalValuesRef: Ref;
|
|
13
13
|
}
|
|
14
|
-
export interface
|
|
14
|
+
export interface RecipIngredient extends Json {
|
|
15
15
|
ingredientsRef: string;
|
|
16
16
|
quantity: number;
|
|
17
17
|
}
|
|
18
|
-
export type IngredientsTypeTable =
|
|
18
|
+
export type IngredientsTypeTable = ComponentsTable<Ingredient>;
|
|
19
19
|
export interface NutritionalValues extends Json {
|
|
20
20
|
energy: number;
|
|
21
21
|
fat: number;
|
|
@@ -26,10 +26,10 @@ export interface Bakery extends Rljson {
|
|
|
26
26
|
buffets: BuffetsTable;
|
|
27
27
|
cakes: CakesTable;
|
|
28
28
|
slices: SliceIdsTable;
|
|
29
|
-
layers: LayersTable;
|
|
30
29
|
recipes: LayersTable;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
recipeLayers: LayersTable;
|
|
31
|
+
recipeIngredients: ComponentsTable<RecipIngredient>;
|
|
32
|
+
ingredients: ComponentsTable<Ingredient>;
|
|
33
|
+
nutritionalValues: ComponentsTable<NutritionalValues>;
|
|
34
34
|
}
|
|
35
35
|
export declare const bakeryExample: () => Bakery;
|
package/dist/example.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare class Example {
|
|
|
27
27
|
layers: {
|
|
28
28
|
missingBase: () => Rljson;
|
|
29
29
|
missingSliceIdSet: () => Rljson;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
missingAssignedComponentTable: () => Rljson;
|
|
31
|
+
missingAssignedComponent: () => Rljson;
|
|
32
32
|
};
|
|
33
33
|
cakes: {
|
|
34
34
|
missingSliceIdSet: () => Rljson;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export * from './content/buffet.ts';
|
|
2
2
|
export * from './content/cake.ts';
|
|
3
|
-
export * from './content/
|
|
3
|
+
export * from './content/components.ts';
|
|
4
4
|
export * from './content/layer.ts';
|
|
5
5
|
export * from './content/revision.ts';
|
|
6
6
|
export * from './content/slice-ids.ts';
|
|
7
7
|
export * from './content/table-cfg.ts';
|
|
8
8
|
export * from './example.ts';
|
|
9
9
|
export * from './example/bakery-example.ts';
|
|
10
|
-
export * from './rljson-indexed.ts';
|
|
11
10
|
export * from './rljson.ts';
|
|
12
11
|
export * from './typedefs.ts';
|
|
13
12
|
export * from './validate/base-validator.ts';
|
package/dist/rljson.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Json } from '@rljson/json';
|
|
2
2
|
import { BuffetsTable } from './content/buffet.ts';
|
|
3
3
|
import { CakesTable } from './content/cake.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { ComponentsTable } from './content/components.ts';
|
|
5
5
|
import { LayersTable } from './content/layer.ts';
|
|
6
6
|
import { RevisionsTable } from './content/revision.ts';
|
|
7
7
|
import { SliceIdsTable } from './content/slice-ids.ts';
|
|
8
8
|
import { TableCfgRef, TablesCfgTable } from './content/table-cfg.ts';
|
|
9
|
-
import { Ref, TableKey } from './typedefs.ts';
|
|
9
|
+
import { ContentType, Ref, TableKey } from './typedefs.ts';
|
|
10
10
|
export declare const reservedFieldNames: string[];
|
|
11
11
|
export declare const reservedTableKeys: string[];
|
|
12
12
|
/**
|
|
13
13
|
* One of the supported Rljson table types
|
|
14
14
|
*/
|
|
15
|
-
export type TableType = BuffetsTable |
|
|
15
|
+
export type TableType = BuffetsTable | ComponentsTable<any> | LayersTable | SliceIdsTable | CakesTable | RevisionsTable | TablesCfgTable;
|
|
16
16
|
/** The rljson data format */
|
|
17
17
|
export interface Rljson extends Json {
|
|
18
18
|
[tableId: TableKey]: TableType;
|
|
@@ -45,11 +45,13 @@ export type RljsonPrivate = {
|
|
|
45
45
|
/** An example rljson object */
|
|
46
46
|
export declare const exampleRljson: () => Rljson;
|
|
47
47
|
/** A table in the rljson format */
|
|
48
|
-
export interface RljsonTable<Data extends Json> extends Json {
|
|
48
|
+
export interface RljsonTable<Data extends Json, T extends ContentType> extends Json {
|
|
49
49
|
/** The data rows of the table */
|
|
50
50
|
_data: Data[];
|
|
51
51
|
/** The columns configuration of the table */
|
|
52
52
|
_tableCfg?: TableCfgRef;
|
|
53
|
+
/** The type of the table. Must match the one in table cfg table */
|
|
54
|
+
_type: T;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Iterates over all tables of an Rljson object.
|
package/dist/rljson.js
CHANGED
|
@@ -6,6 +6,7 @@ import { exampleJsonObject, jsonValueTypes, jsonValueType, jsonValueMatchesType
|
|
|
6
6
|
// @license
|
|
7
7
|
const bakeryExample = () => {
|
|
8
8
|
const nutritionalValues = hip({
|
|
9
|
+
_type: "components",
|
|
9
10
|
_data: [
|
|
10
11
|
{
|
|
11
12
|
id: "flour",
|
|
@@ -27,6 +28,7 @@ const bakeryExample = () => {
|
|
|
27
28
|
_hash: ""
|
|
28
29
|
});
|
|
29
30
|
const ingredients = hip({
|
|
31
|
+
_type: "components",
|
|
30
32
|
_data: [
|
|
31
33
|
{
|
|
32
34
|
id: "flour",
|
|
@@ -38,6 +40,7 @@ const bakeryExample = () => {
|
|
|
38
40
|
_hash: ""
|
|
39
41
|
});
|
|
40
42
|
const recipeIngredients = hip({
|
|
43
|
+
_type: "components",
|
|
41
44
|
_data: [
|
|
42
45
|
{
|
|
43
46
|
id: "flour",
|
|
@@ -49,6 +52,7 @@ const bakeryExample = () => {
|
|
|
49
52
|
_hash: ""
|
|
50
53
|
});
|
|
51
54
|
const slices = hip({
|
|
55
|
+
_type: "sliceIds",
|
|
52
56
|
_data: [
|
|
53
57
|
{
|
|
54
58
|
add: ["slice0", "slice1"],
|
|
@@ -57,6 +61,7 @@ const bakeryExample = () => {
|
|
|
57
61
|
]
|
|
58
62
|
});
|
|
59
63
|
const ingredientTypes = hip({
|
|
64
|
+
_type: "sliceIds",
|
|
60
65
|
_data: [
|
|
61
66
|
{
|
|
62
67
|
add: ["flour"],
|
|
@@ -65,26 +70,28 @@ const bakeryExample = () => {
|
|
|
65
70
|
]
|
|
66
71
|
});
|
|
67
72
|
const recipes = hip({
|
|
73
|
+
_type: "layers",
|
|
68
74
|
_data: [
|
|
69
75
|
{
|
|
70
76
|
id: "tastyCake",
|
|
71
|
-
|
|
77
|
+
componentsTable: "recipeIngredients",
|
|
72
78
|
sliceIdsTable: "ingredientTypes",
|
|
73
79
|
sliceIdsTableRow: ingredientTypes._data[0]._hash,
|
|
74
|
-
|
|
80
|
+
add: {
|
|
75
81
|
flour: recipeIngredients._data[0]._hash
|
|
76
82
|
},
|
|
77
83
|
_hash: ""
|
|
78
84
|
}
|
|
79
85
|
]
|
|
80
86
|
});
|
|
81
|
-
const
|
|
87
|
+
const recipeLayers = hip({
|
|
88
|
+
_type: "layers",
|
|
82
89
|
_data: [
|
|
83
90
|
{
|
|
84
|
-
|
|
91
|
+
componentsTable: "recipes",
|
|
85
92
|
sliceIdsTable: "slices",
|
|
86
93
|
sliceIdsTableRow: slices._data[0]._hash,
|
|
87
|
-
|
|
94
|
+
add: {
|
|
88
95
|
slice0: recipes._data[0]._hash,
|
|
89
96
|
slice1: recipes._data[0]._hash
|
|
90
97
|
}
|
|
@@ -92,19 +99,20 @@ const bakeryExample = () => {
|
|
|
92
99
|
]
|
|
93
100
|
});
|
|
94
101
|
const cakes = hip({
|
|
102
|
+
_type: "cakes",
|
|
95
103
|
_data: [
|
|
96
104
|
{
|
|
97
105
|
id: "cake1",
|
|
98
106
|
sliceIdsTable: "slices",
|
|
99
107
|
sliceIdsRow: slices._data[0]._hash,
|
|
100
|
-
layersTable: "layers",
|
|
101
108
|
layers: {
|
|
102
|
-
|
|
109
|
+
recipeLayers: recipeLayers._data[0]._hash
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
]
|
|
106
113
|
});
|
|
107
114
|
const buffets = hip({
|
|
115
|
+
_type: "buffets",
|
|
108
116
|
_data: [
|
|
109
117
|
{
|
|
110
118
|
id: "salesCounter",
|
|
@@ -122,7 +130,7 @@ const bakeryExample = () => {
|
|
|
122
130
|
cakes,
|
|
123
131
|
slices,
|
|
124
132
|
ingredientTypes,
|
|
125
|
-
|
|
133
|
+
recipeLayers,
|
|
126
134
|
recipes,
|
|
127
135
|
recipeIngredients,
|
|
128
136
|
ingredients,
|
|
@@ -135,9 +143,9 @@ const exampleBuffetsTable = () => bakeryExample().buffets;
|
|
|
135
143
|
// @license
|
|
136
144
|
const exampleCakesTable = () => bakeryExample().cakes;
|
|
137
145
|
// @license
|
|
138
|
-
const
|
|
146
|
+
const exampleComponentsTable = () => bakeryExample().nutritionalValues;
|
|
139
147
|
// @license
|
|
140
|
-
const exampleLayersTable = () => bakeryExample().
|
|
148
|
+
const exampleLayersTable = () => bakeryExample().recipeLayers;
|
|
141
149
|
// @license
|
|
142
150
|
const exampleRevision = () => ({
|
|
143
151
|
table: "nutritionalValues",
|
|
@@ -159,6 +167,7 @@ __publicField(_Example, "ok", {
|
|
|
159
167
|
binary: () => {
|
|
160
168
|
return {
|
|
161
169
|
table: {
|
|
170
|
+
_type: "components",
|
|
162
171
|
_data: [
|
|
163
172
|
{ a: false, b: false },
|
|
164
173
|
{ a: false, b: true },
|
|
@@ -171,12 +180,13 @@ __publicField(_Example, "ok", {
|
|
|
171
180
|
singleRow: () => {
|
|
172
181
|
const tableCfgs = hip({
|
|
173
182
|
_hash: "",
|
|
183
|
+
_type: "tableCfgs",
|
|
174
184
|
_data: [
|
|
175
185
|
{
|
|
176
186
|
version: 0,
|
|
177
187
|
_hash: "",
|
|
178
188
|
key: "table",
|
|
179
|
-
type: "
|
|
189
|
+
type: "components",
|
|
180
190
|
isHead: false,
|
|
181
191
|
isRoot: false,
|
|
182
192
|
isShared: true,
|
|
@@ -221,6 +231,7 @@ __publicField(_Example, "ok", {
|
|
|
221
231
|
tableCfgs,
|
|
222
232
|
table: {
|
|
223
233
|
_tableCfg: tableCfgs._data[0]._hash,
|
|
234
|
+
_type: "components",
|
|
224
235
|
_data: [exampleJsonObject()],
|
|
225
236
|
_hash: ""
|
|
226
237
|
}
|
|
@@ -230,6 +241,7 @@ __publicField(_Example, "ok", {
|
|
|
230
241
|
multipleRows: () => {
|
|
231
242
|
return {
|
|
232
243
|
table: {
|
|
244
|
+
_type: "components",
|
|
233
245
|
_data: [
|
|
234
246
|
{
|
|
235
247
|
string: "str0",
|
|
@@ -259,6 +271,7 @@ __publicField(_Example, "ok", {
|
|
|
259
271
|
singleRef: () => {
|
|
260
272
|
return {
|
|
261
273
|
tableA: {
|
|
274
|
+
_type: "components",
|
|
262
275
|
_data: [
|
|
263
276
|
{
|
|
264
277
|
keyA0: "a0"
|
|
@@ -269,6 +282,7 @@ __publicField(_Example, "ok", {
|
|
|
269
282
|
]
|
|
270
283
|
},
|
|
271
284
|
tableB: {
|
|
285
|
+
_type: "components",
|
|
272
286
|
_data: [
|
|
273
287
|
{
|
|
274
288
|
tableARef: "KFQrf4mEz0UPmUaFHwH4T6"
|
|
@@ -279,52 +293,55 @@ __publicField(_Example, "ok", {
|
|
|
279
293
|
},
|
|
280
294
|
complete: () => {
|
|
281
295
|
const sliceIds = hip({
|
|
296
|
+
_type: "sliceIds",
|
|
282
297
|
_data: [
|
|
283
298
|
{
|
|
284
299
|
add: ["id0", "id1"]
|
|
285
300
|
}
|
|
286
301
|
]
|
|
287
302
|
});
|
|
288
|
-
const
|
|
303
|
+
const components = hip({
|
|
304
|
+
_type: "components",
|
|
289
305
|
_data: [{ a: "0" }, { a: "1" }]
|
|
290
306
|
});
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
const
|
|
307
|
+
const component0 = components._data[0];
|
|
308
|
+
const component1 = components._data[1];
|
|
309
|
+
const abLayer0 = hip({
|
|
294
310
|
sliceIdsTable: "sliceIds",
|
|
295
311
|
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
id0:
|
|
299
|
-
id1:
|
|
312
|
+
componentsTable: "components",
|
|
313
|
+
add: {
|
|
314
|
+
id0: component0._hash,
|
|
315
|
+
id1: component1._hash
|
|
300
316
|
}
|
|
301
317
|
});
|
|
302
|
-
const
|
|
303
|
-
base:
|
|
318
|
+
const abLayer1 = hip({
|
|
319
|
+
base: abLayer0._hash,
|
|
304
320
|
sliceIdsTable: "sliceIds",
|
|
305
321
|
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
id0:
|
|
309
|
-
id1:
|
|
322
|
+
componentsTable: "components",
|
|
323
|
+
add: {
|
|
324
|
+
id0: component0._hash,
|
|
325
|
+
id1: component1._hash
|
|
310
326
|
}
|
|
311
327
|
});
|
|
312
|
-
const
|
|
313
|
-
|
|
328
|
+
const abLayers = hip({
|
|
329
|
+
_type: "layers",
|
|
330
|
+
_data: [abLayer0, abLayer1]
|
|
314
331
|
});
|
|
315
332
|
const cake = hip({
|
|
316
333
|
sliceIdsTable: "sliceIds",
|
|
317
334
|
sliceIdsRow: sliceIds._data[0]._hash,
|
|
318
|
-
layersTable: "layers",
|
|
319
335
|
layers: {
|
|
320
|
-
|
|
321
|
-
layer1: layer1._hash
|
|
336
|
+
abLayers: abLayer1._hash
|
|
322
337
|
}
|
|
323
338
|
});
|
|
324
339
|
const cakes = hip({
|
|
340
|
+
_type: "cakes",
|
|
325
341
|
_data: [cake]
|
|
326
342
|
});
|
|
327
343
|
const buffets = hip({
|
|
344
|
+
_type: "buffets",
|
|
328
345
|
_data: [
|
|
329
346
|
{
|
|
330
347
|
items: [
|
|
@@ -333,8 +350,8 @@ __publicField(_Example, "ok", {
|
|
|
333
350
|
ref: cakes._data[0]._hash
|
|
334
351
|
},
|
|
335
352
|
{
|
|
336
|
-
table: "
|
|
337
|
-
ref:
|
|
353
|
+
table: "abLayers",
|
|
354
|
+
ref: abLayer0._hash
|
|
338
355
|
}
|
|
339
356
|
]
|
|
340
357
|
}
|
|
@@ -342,8 +359,8 @@ __publicField(_Example, "ok", {
|
|
|
342
359
|
});
|
|
343
360
|
return {
|
|
344
361
|
sliceIds,
|
|
345
|
-
|
|
346
|
-
|
|
362
|
+
components,
|
|
363
|
+
abLayers,
|
|
347
364
|
cakes,
|
|
348
365
|
buffets
|
|
349
366
|
};
|
|
@@ -373,6 +390,7 @@ __publicField(_Example, "broken", {
|
|
|
373
390
|
missingRef: () => {
|
|
374
391
|
return {
|
|
375
392
|
tableA: {
|
|
393
|
+
_type: "components",
|
|
376
394
|
_data: [
|
|
377
395
|
{
|
|
378
396
|
keyA0: "a0"
|
|
@@ -383,6 +401,7 @@ __publicField(_Example, "broken", {
|
|
|
383
401
|
]
|
|
384
402
|
},
|
|
385
403
|
tableB: {
|
|
404
|
+
_type: "components",
|
|
386
405
|
_data: [
|
|
387
406
|
{
|
|
388
407
|
tableARef: "MISSINGREF"
|
|
@@ -395,6 +414,7 @@ __publicField(_Example, "broken", {
|
|
|
395
414
|
missingReferencedTable: () => {
|
|
396
415
|
return {
|
|
397
416
|
tableB: {
|
|
417
|
+
_type: "components",
|
|
398
418
|
_data: [
|
|
399
419
|
{
|
|
400
420
|
tableARef: "MISSINGREF"
|
|
@@ -420,7 +440,7 @@ __publicField(_Example, "broken", {
|
|
|
420
440
|
layers: {
|
|
421
441
|
missingBase: () => {
|
|
422
442
|
const result = _Example.ok.complete();
|
|
423
|
-
const layer1 = result.
|
|
443
|
+
const layer1 = result.abLayers._data[1];
|
|
424
444
|
layer1.base = "MISSING";
|
|
425
445
|
return hip(result, {
|
|
426
446
|
updateExistingHashes: true,
|
|
@@ -429,21 +449,21 @@ __publicField(_Example, "broken", {
|
|
|
429
449
|
},
|
|
430
450
|
missingSliceIdSet: () => {
|
|
431
451
|
const result = _Example.ok.complete();
|
|
432
|
-
const layer1 = result.
|
|
452
|
+
const layer1 = result.abLayers._data[1];
|
|
433
453
|
layer1.sliceIdsTableRow = "MISSING1";
|
|
434
454
|
return hip(result, {
|
|
435
455
|
updateExistingHashes: true,
|
|
436
456
|
throwOnWrongHashes: false
|
|
437
457
|
});
|
|
438
458
|
},
|
|
439
|
-
|
|
459
|
+
missingAssignedComponentTable: () => {
|
|
440
460
|
const result = _Example.ok.complete();
|
|
441
|
-
delete result.
|
|
461
|
+
delete result.components;
|
|
442
462
|
return result;
|
|
443
463
|
},
|
|
444
|
-
|
|
464
|
+
missingAssignedComponent: () => {
|
|
445
465
|
const result = _Example.ok.complete();
|
|
446
|
-
result.
|
|
466
|
+
result.components._data.splice(1, 2);
|
|
447
467
|
return hip(result, {
|
|
448
468
|
updateExistingHashes: true,
|
|
449
469
|
throwOnWrongHashes: false
|
|
@@ -467,7 +487,7 @@ __publicField(_Example, "broken", {
|
|
|
467
487
|
},
|
|
468
488
|
missingLayersTable: () => {
|
|
469
489
|
const result = _Example.ok.complete();
|
|
470
|
-
result.cakes._data[0].
|
|
490
|
+
result.cakes._data[0].layers = { MISSING: "HASH" };
|
|
471
491
|
hip(result.cakes, {
|
|
472
492
|
updateExistingHashes: true,
|
|
473
493
|
throwOnWrongHashes: false
|
|
@@ -476,8 +496,7 @@ __publicField(_Example, "broken", {
|
|
|
476
496
|
},
|
|
477
497
|
missingCakeLayer: () => {
|
|
478
498
|
const result = _Example.ok.complete();
|
|
479
|
-
result.cakes._data[0].layers["
|
|
480
|
-
result.cakes._data[0].layers["layer1"] = "MISSING1";
|
|
499
|
+
result.cakes._data[0].layers["abLayers"] = "MISSING0";
|
|
481
500
|
hip(result.cakes, {
|
|
482
501
|
updateExistingHashes: true,
|
|
483
502
|
throwOnWrongHashes: false
|
|
@@ -598,36 +617,13 @@ const exampleTableCfg = (tableCfg = void 0) => {
|
|
|
598
617
|
type: "number"
|
|
599
618
|
}
|
|
600
619
|
],
|
|
601
|
-
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "
|
|
620
|
+
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "components",
|
|
602
621
|
isHead: true,
|
|
603
622
|
isRoot: true,
|
|
604
623
|
isShared: false
|
|
605
624
|
};
|
|
606
625
|
};
|
|
607
626
|
// @license
|
|
608
|
-
const rljsonIndexed = (rljson) => {
|
|
609
|
-
const result = {};
|
|
610
|
-
for (const key in rljson) {
|
|
611
|
-
const slice = rljson[key];
|
|
612
|
-
if (typeof slice != "object") {
|
|
613
|
-
result[key] = slice;
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
const dataIndexed = {};
|
|
617
|
-
result[key] = { ...slice };
|
|
618
|
-
if (!Array.isArray(slice._data)) {
|
|
619
|
-
continue;
|
|
620
|
-
}
|
|
621
|
-
for (const row of slice._data) {
|
|
622
|
-
const hashedRow = row._hash ? row : hsh(row);
|
|
623
|
-
const hash = hashedRow._hash;
|
|
624
|
-
dataIndexed[hash] = hashedRow;
|
|
625
|
-
}
|
|
626
|
-
result[key]._data = dataIndexed;
|
|
627
|
-
}
|
|
628
|
-
return result;
|
|
629
|
-
};
|
|
630
|
-
// @license
|
|
631
627
|
const reservedFieldNames = ["_data"];
|
|
632
628
|
const reservedTableKeys = [
|
|
633
629
|
"_hash",
|
|
@@ -673,7 +669,9 @@ const contentTypes = [
|
|
|
673
669
|
"cakes",
|
|
674
670
|
"layers",
|
|
675
671
|
"sliceIds",
|
|
676
|
-
"
|
|
672
|
+
"components",
|
|
673
|
+
"revisions",
|
|
674
|
+
"tableCfgs"
|
|
677
675
|
];
|
|
678
676
|
const exampleTypedefs = () => {
|
|
679
677
|
return {
|
|
@@ -684,6 +682,29 @@ const exampleTypedefs = () => {
|
|
|
684
682
|
};
|
|
685
683
|
};
|
|
686
684
|
// @license
|
|
685
|
+
const rljsonIndexed = (rljson) => {
|
|
686
|
+
const result = {};
|
|
687
|
+
for (const key in rljson) {
|
|
688
|
+
const slice = rljson[key];
|
|
689
|
+
if (typeof slice != "object") {
|
|
690
|
+
result[key] = slice;
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
const dataIndexed = {};
|
|
694
|
+
result[key] = { ...slice };
|
|
695
|
+
if (!Array.isArray(slice._data)) {
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
for (const row of slice._data) {
|
|
699
|
+
const hashedRow = row._hash ? row : hsh(row);
|
|
700
|
+
const hash = hashedRow._hash;
|
|
701
|
+
dataIndexed[hash] = hashedRow;
|
|
702
|
+
}
|
|
703
|
+
result[key]._data = dataIndexed;
|
|
704
|
+
}
|
|
705
|
+
return result;
|
|
706
|
+
};
|
|
707
|
+
// @license
|
|
687
708
|
class BaseValidator {
|
|
688
709
|
constructor() {
|
|
689
710
|
__publicField(this, "name", "base");
|
|
@@ -738,7 +759,7 @@ class _BaseValidator {
|
|
|
738
759
|
() => this._layerBasesNotFound(),
|
|
739
760
|
() => this._layerSliceIdsTableNotFound(),
|
|
740
761
|
() => this._layerSliceIdsRowNotFound(),
|
|
741
|
-
() => this.
|
|
762
|
+
() => this._layerComponentAssignmentsNotFound(),
|
|
742
763
|
() => this._layerAssignmentsDoNotMatchSliceIds(),
|
|
743
764
|
// Check cakes
|
|
744
765
|
() => this._cakeSliceIdsTableNotFound(),
|
|
@@ -1171,7 +1192,6 @@ class _BaseValidator {
|
|
|
1171
1192
|
};
|
|
1172
1193
|
}
|
|
1173
1194
|
}
|
|
1174
|
-
/* v8 ignore start */
|
|
1175
1195
|
_layerSliceIdsTableNotFound() {
|
|
1176
1196
|
const brokenLayers = [];
|
|
1177
1197
|
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
@@ -1224,8 +1244,8 @@ class _BaseValidator {
|
|
|
1224
1244
|
};
|
|
1225
1245
|
}
|
|
1226
1246
|
}
|
|
1227
|
-
|
|
1228
|
-
const
|
|
1247
|
+
_layerComponentAssignmentsNotFound() {
|
|
1248
|
+
const missingComponentTables = [];
|
|
1229
1249
|
const brokenAssignments = [];
|
|
1230
1250
|
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1231
1251
|
if (table._type !== "layers") {
|
|
@@ -1233,43 +1253,43 @@ class _BaseValidator {
|
|
|
1233
1253
|
}
|
|
1234
1254
|
const layersTable = table;
|
|
1235
1255
|
for (const layer of layersTable._data) {
|
|
1236
|
-
const
|
|
1237
|
-
const
|
|
1238
|
-
if (!
|
|
1239
|
-
|
|
1256
|
+
const componentTableKey = layer.componentsTable;
|
|
1257
|
+
const componentsTable = this.rljsonIndexed[componentTableKey];
|
|
1258
|
+
if (!componentsTable) {
|
|
1259
|
+
missingComponentTables.push({
|
|
1240
1260
|
brokenLayer: layer._hash,
|
|
1241
1261
|
layersTable: tableKey,
|
|
1242
|
-
|
|
1262
|
+
missingComponentTable: componentTableKey
|
|
1243
1263
|
});
|
|
1244
1264
|
continue;
|
|
1245
1265
|
}
|
|
1246
|
-
const assignments = layer.
|
|
1266
|
+
const assignments = layer.add;
|
|
1247
1267
|
for (const sliceId in assignments) {
|
|
1248
1268
|
if (sliceId.startsWith("_")) {
|
|
1249
1269
|
continue;
|
|
1250
1270
|
}
|
|
1251
|
-
const
|
|
1252
|
-
if (!
|
|
1271
|
+
const componentHash = assignments[sliceId];
|
|
1272
|
+
if (!componentsTable._data[componentHash]) {
|
|
1253
1273
|
brokenAssignments.push({
|
|
1254
1274
|
layersTable: tableKey,
|
|
1255
1275
|
brokenLayer: layer._hash,
|
|
1256
|
-
|
|
1276
|
+
referencedComponentTable: componentTableKey,
|
|
1257
1277
|
brokenAssignment: sliceId,
|
|
1258
|
-
|
|
1278
|
+
missingComponent: componentHash
|
|
1259
1279
|
});
|
|
1260
1280
|
}
|
|
1261
1281
|
}
|
|
1262
1282
|
}
|
|
1263
1283
|
});
|
|
1264
|
-
if (
|
|
1265
|
-
this.errors.
|
|
1266
|
-
error: "Layer
|
|
1267
|
-
layers:
|
|
1284
|
+
if (missingComponentTables.length > 0) {
|
|
1285
|
+
this.errors.layerComponentTablesNotFound = {
|
|
1286
|
+
error: "Layer component tables do not exist",
|
|
1287
|
+
layers: missingComponentTables
|
|
1268
1288
|
};
|
|
1269
1289
|
}
|
|
1270
1290
|
if (brokenAssignments.length > 0) {
|
|
1271
|
-
this.errors.
|
|
1272
|
-
error: "Layer
|
|
1291
|
+
this.errors.layerComponentAssignmentsNotFound = {
|
|
1292
|
+
error: "Layer component assignments are broken",
|
|
1273
1293
|
brokenAssignments
|
|
1274
1294
|
};
|
|
1275
1295
|
}
|
|
@@ -1285,7 +1305,7 @@ class _BaseValidator {
|
|
|
1285
1305
|
const sliceIdsTable = this.rljsonIndexed[layer.sliceIdsTable];
|
|
1286
1306
|
const sliceIdsRow = sliceIdsTable._data[layer.sliceIdsTableRow];
|
|
1287
1307
|
const sliceIds = sliceIdsRow.add;
|
|
1288
|
-
const sliceIdsInLayer = Object.keys(layer.
|
|
1308
|
+
const sliceIdsInLayer = Object.keys(layer.add);
|
|
1289
1309
|
const unassignedSliceIds = [];
|
|
1290
1310
|
for (const expectedSliceId of sliceIds) {
|
|
1291
1311
|
if (sliceIdsInLayer.indexOf(expectedSliceId) === -1) {
|
|
@@ -1370,27 +1390,25 @@ class _BaseValidator {
|
|
|
1370
1390
|
}
|
|
1371
1391
|
const cakesTable = table;
|
|
1372
1392
|
for (const cake of cakesTable._data) {
|
|
1373
|
-
const layersTableKey
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
if (layerKey.startsWith("_")) {
|
|
1393
|
+
for (const layersTableKey in cake.layers) {
|
|
1394
|
+
if (layersTableKey.startsWith("_")) {
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
const layersTable = this.rljsonIndexed[layersTableKey];
|
|
1398
|
+
if (!layersTable) {
|
|
1399
|
+
missingLayerTables.push({
|
|
1400
|
+
cakeTable: tableKey,
|
|
1401
|
+
brokenCake: cake._hash,
|
|
1402
|
+
missingLayersTable: layersTableKey
|
|
1403
|
+
});
|
|
1385
1404
|
continue;
|
|
1386
1405
|
}
|
|
1387
|
-
const layerRef = cake.layers[
|
|
1406
|
+
const layerRef = cake.layers[layersTableKey];
|
|
1388
1407
|
const layer = layersTable._data[layerRef];
|
|
1389
1408
|
if (!layer) {
|
|
1390
1409
|
missingCakeLayers.push({
|
|
1391
1410
|
cakeTable: tableKey,
|
|
1392
1411
|
brokenCake: cake._hash,
|
|
1393
|
-
brokenLayerName: layerKey,
|
|
1394
1412
|
layersTable: layersTableKey,
|
|
1395
1413
|
missingLayer: layerRef
|
|
1396
1414
|
});
|
|
@@ -1457,7 +1475,6 @@ class _BaseValidator {
|
|
|
1457
1475
|
};
|
|
1458
1476
|
}
|
|
1459
1477
|
}
|
|
1460
|
-
/* v8 ignore end */
|
|
1461
1478
|
}
|
|
1462
1479
|
const isValidFieldName = (fieldName) => BaseValidator.isValidFieldName(fieldName);
|
|
1463
1480
|
// @license
|
|
@@ -1506,7 +1523,7 @@ export {
|
|
|
1506
1523
|
contentTypes,
|
|
1507
1524
|
exampleBuffetsTable,
|
|
1508
1525
|
exampleCakesTable,
|
|
1509
|
-
|
|
1526
|
+
exampleComponentsTable,
|
|
1510
1527
|
exampleLayersTable,
|
|
1511
1528
|
exampleRevision,
|
|
1512
1529
|
exampleRljson,
|
|
@@ -1519,7 +1536,6 @@ export {
|
|
|
1519
1536
|
iterateTablesSync,
|
|
1520
1537
|
reservedFieldNames,
|
|
1521
1538
|
reservedTableKeys,
|
|
1522
|
-
rljsonIndexed,
|
|
1523
1539
|
throwOnInvalidTableCfg,
|
|
1524
1540
|
validateRljsonAgainstTableCfg
|
|
1525
1541
|
};
|