@rljson/rljson 0.0.56 → 0.0.60
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/dist/content/cake.d.ts +9 -0
- package/dist/content/components.d.ts +3 -2
- package/dist/content/layer.d.ts +6 -0
- package/dist/edit/edit.d.ts +29 -0
- package/dist/edit/route.d.ts +13 -0
- package/dist/example/bakery-example.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/rljson.d.ts +2 -1
- package/dist/rljson.js +587 -488
- package/dist/src/example.ts +5 -1
- package/dist/tools/time-id.d.ts +1 -0
- package/dist/typedefs.d.ts +1 -1
- package/package.json +17 -24
package/dist/rljson.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
1
|
import { hip, hsh } from "@rljson/hash";
|
|
5
|
-
import { exampleJsonObject, jsonValueTypes,
|
|
2
|
+
import { exampleJsonObject, jsonValueTypes, jsonValueMatchesType, jsonValueType } from "@rljson/json";
|
|
3
|
+
import { nanoid } from "nanoid";
|
|
4
|
+
// @license
|
|
5
|
+
class Route {
|
|
6
|
+
constructor(segments) {
|
|
7
|
+
this.segments = segments;
|
|
8
|
+
}
|
|
9
|
+
static fromFlat(route) {
|
|
10
|
+
return new Route(route.split("/").filter(Boolean));
|
|
11
|
+
}
|
|
12
|
+
segment(index) {
|
|
13
|
+
if (index === void 0) {
|
|
14
|
+
return this.segments[this.segments.length - 1];
|
|
15
|
+
}
|
|
16
|
+
return this.segments[index];
|
|
17
|
+
}
|
|
18
|
+
deeper(steps) {
|
|
19
|
+
if (steps === void 0) {
|
|
20
|
+
return new Route(this.segments.slice(1, this.segments.length));
|
|
21
|
+
} else {
|
|
22
|
+
if (steps < 1) {
|
|
23
|
+
throw new Error("Steps must be greater than 0");
|
|
24
|
+
}
|
|
25
|
+
if (steps >= this.segments.length) {
|
|
26
|
+
throw new Error("Cannot go deeper than the root");
|
|
27
|
+
}
|
|
28
|
+
return new Route(this.segments.slice(steps, this.segments.length));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
get isRoot() {
|
|
32
|
+
return this.segments.length === 1;
|
|
33
|
+
}
|
|
34
|
+
get flat() {
|
|
35
|
+
return "/" + this.segments.join("/");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
6
38
|
// @license
|
|
7
39
|
const bakeryExample = () => {
|
|
8
40
|
const nutritionalValues = hip({
|
|
@@ -35,6 +67,12 @@ const bakeryExample = () => {
|
|
|
35
67
|
amountUnit: "g",
|
|
36
68
|
nutritionalValuesRef: nutritionalValues._data[0]._hash,
|
|
37
69
|
_hash: ""
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "flourB",
|
|
73
|
+
amountUnit: "g",
|
|
74
|
+
nutritionalValuesRef: nutritionalValues._data[1]._hash,
|
|
75
|
+
_hash: ""
|
|
38
76
|
}
|
|
39
77
|
],
|
|
40
78
|
_hash: ""
|
|
@@ -125,6 +163,26 @@ const bakeryExample = () => {
|
|
|
125
163
|
}
|
|
126
164
|
]
|
|
127
165
|
});
|
|
166
|
+
const ingredientsEdits = hip({
|
|
167
|
+
_type: "edits",
|
|
168
|
+
_data: [
|
|
169
|
+
{
|
|
170
|
+
timeId: "de72:1759123957292",
|
|
171
|
+
ingredientsRef: ingredients._data[0]._hash,
|
|
172
|
+
route: Route.fromFlat("/ingredients/").flat,
|
|
173
|
+
origin: "H45H",
|
|
174
|
+
previous: []
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
timeId: "a8e0:1759123987505",
|
|
178
|
+
ingredientsRef: ingredients._data[1]._hash,
|
|
179
|
+
route: Route.fromFlat("/ingredients/").flat,
|
|
180
|
+
origin: "H45H",
|
|
181
|
+
previous: ["de72:1759123957292"]
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
_hash: ""
|
|
185
|
+
});
|
|
128
186
|
const result = {
|
|
129
187
|
buffets,
|
|
130
188
|
cakes,
|
|
@@ -134,17 +192,46 @@ const bakeryExample = () => {
|
|
|
134
192
|
recipes,
|
|
135
193
|
recipeIngredients,
|
|
136
194
|
ingredients,
|
|
137
|
-
nutritionalValues
|
|
195
|
+
nutritionalValues,
|
|
196
|
+
ingredientsEdits
|
|
138
197
|
};
|
|
139
198
|
return result;
|
|
140
199
|
};
|
|
141
200
|
// @license
|
|
142
201
|
const exampleBuffetsTable = () => bakeryExample().buffets;
|
|
143
202
|
// @license
|
|
203
|
+
const createCakeTableCfg = (cakeKey) => ({
|
|
204
|
+
key: cakeKey,
|
|
205
|
+
type: "cakes",
|
|
206
|
+
columns: [
|
|
207
|
+
{ key: "sliceIdsTable", type: "string" },
|
|
208
|
+
{ key: "sliceIdsRow", type: "string" },
|
|
209
|
+
{ key: "layers", type: "jsonArray" },
|
|
210
|
+
{ key: "id", type: "string" }
|
|
211
|
+
],
|
|
212
|
+
isHead: false,
|
|
213
|
+
isRoot: false,
|
|
214
|
+
isShared: true
|
|
215
|
+
});
|
|
144
216
|
const exampleCakesTable = () => bakeryExample().cakes;
|
|
145
217
|
// @license
|
|
146
218
|
const exampleComponentsTable = () => bakeryExample().nutritionalValues;
|
|
147
219
|
// @license
|
|
220
|
+
const createLayerTableCfg = (layerKey) => ({
|
|
221
|
+
key: layerKey,
|
|
222
|
+
type: "layers",
|
|
223
|
+
columns: [
|
|
224
|
+
{ key: "base", type: "string" },
|
|
225
|
+
{ key: "sliceIdsTable", type: "string" },
|
|
226
|
+
{ key: "sliceIdsTableRow", type: "string" },
|
|
227
|
+
{ key: "componentsTable", type: "string" },
|
|
228
|
+
{ key: "add", type: "jsonArray" },
|
|
229
|
+
{ key: "remove", type: "jsonArray" }
|
|
230
|
+
],
|
|
231
|
+
isHead: false,
|
|
232
|
+
isRoot: false,
|
|
233
|
+
isShared: true
|
|
234
|
+
});
|
|
148
235
|
const exampleLayersTable = () => bakeryExample().recipeLayers;
|
|
149
236
|
// @license
|
|
150
237
|
const exampleRevision = () => ({
|
|
@@ -157,360 +244,121 @@ const exampleRevision = () => ({
|
|
|
157
244
|
// @license
|
|
158
245
|
const exampleSliceIdsTable = () => bakeryExample().slices;
|
|
159
246
|
// @license
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
{ a: true, b: true }
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
singleRow: () => {
|
|
181
|
-
const tableCfgs = hip({
|
|
182
|
-
_hash: "",
|
|
183
|
-
_type: "tableCfgs",
|
|
184
|
-
_data: [
|
|
185
|
-
{
|
|
186
|
-
version: 0,
|
|
187
|
-
_hash: "",
|
|
188
|
-
key: "table",
|
|
189
|
-
type: "components",
|
|
190
|
-
isHead: false,
|
|
191
|
-
isRoot: false,
|
|
192
|
-
isShared: true,
|
|
193
|
-
columns: [
|
|
194
|
-
{
|
|
195
|
-
key: "int",
|
|
196
|
-
type: "number"
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
key: "double",
|
|
200
|
-
type: "number"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
key: "string",
|
|
204
|
-
type: "string"
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
key: "boolean",
|
|
208
|
-
type: "boolean"
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
key: "null",
|
|
212
|
-
type: "string"
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
key: "jsonArray",
|
|
216
|
-
type: "jsonArray"
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
key: "json",
|
|
220
|
-
type: "json"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
key: "jsonValue",
|
|
224
|
-
type: "jsonValue"
|
|
225
|
-
}
|
|
247
|
+
class Example {
|
|
248
|
+
static ok = {
|
|
249
|
+
bakery: () => bakeryExample(),
|
|
250
|
+
empty: () => {
|
|
251
|
+
return {};
|
|
252
|
+
},
|
|
253
|
+
binary: () => {
|
|
254
|
+
return {
|
|
255
|
+
table: {
|
|
256
|
+
_type: "components",
|
|
257
|
+
_data: [
|
|
258
|
+
{ a: false, b: false },
|
|
259
|
+
{ a: false, b: true },
|
|
260
|
+
{ a: true, b: false },
|
|
261
|
+
{ a: true, b: true }
|
|
226
262
|
]
|
|
227
263
|
}
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
tableCfgs
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
_type: "components",
|
|
235
|
-
_data: [exampleJsonObject()],
|
|
236
|
-
_hash: ""
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
return result;
|
|
240
|
-
},
|
|
241
|
-
multipleRows: () => {
|
|
242
|
-
return {
|
|
243
|
-
table: {
|
|
244
|
-
_type: "components",
|
|
245
|
-
_data: [
|
|
246
|
-
{
|
|
247
|
-
string: "str0",
|
|
248
|
-
boolean: true,
|
|
249
|
-
number: 1,
|
|
250
|
-
array: [1, "str0", true, { a: { b: "c" } }],
|
|
251
|
-
object: { a: { b: "c" } }
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
string: "str1",
|
|
255
|
-
boolean: true,
|
|
256
|
-
number: 1,
|
|
257
|
-
array: [1, "str1", true, { a: { b: "c" } }],
|
|
258
|
-
object: { a: { b: "c" } }
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
string: "str2",
|
|
262
|
-
boolean: false,
|
|
263
|
-
number: 1,
|
|
264
|
-
array: [1, "str1", true, { a: { b: "c" } }],
|
|
265
|
-
object: { d: { e: "f" } }
|
|
266
|
-
}
|
|
267
|
-
]
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
},
|
|
271
|
-
singleRef: () => {
|
|
272
|
-
return {
|
|
273
|
-
tableA: {
|
|
274
|
-
_type: "components",
|
|
275
|
-
_data: [
|
|
276
|
-
{
|
|
277
|
-
keyA0: "a0"
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
keyA1: "a1"
|
|
281
|
-
}
|
|
282
|
-
]
|
|
283
|
-
},
|
|
284
|
-
tableB: {
|
|
285
|
-
_type: "components",
|
|
286
|
-
_data: [
|
|
287
|
-
{
|
|
288
|
-
tableARef: "KFQrf4mEz0UPmUaFHwH4T6"
|
|
289
|
-
}
|
|
290
|
-
]
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
},
|
|
294
|
-
singleSliceIdRef: () => {
|
|
295
|
-
return {
|
|
296
|
-
exampleSliceId: {
|
|
297
|
-
_type: "sliceIds",
|
|
298
|
-
_data: [
|
|
299
|
-
{
|
|
300
|
-
add: ["id0", "id1"]
|
|
301
|
-
}
|
|
302
|
-
]
|
|
303
|
-
},
|
|
304
|
-
exampleComponent: {
|
|
305
|
-
_type: "components",
|
|
306
|
-
_data: [
|
|
307
|
-
{
|
|
308
|
-
exampleSliceId: "id0"
|
|
309
|
-
}
|
|
310
|
-
]
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
},
|
|
314
|
-
multiSliceIdRef: () => {
|
|
315
|
-
return {
|
|
316
|
-
exampleSliceId: {
|
|
317
|
-
_type: "sliceIds",
|
|
318
|
-
_data: [
|
|
319
|
-
{
|
|
320
|
-
add: ["id0", "id1"]
|
|
321
|
-
}
|
|
322
|
-
]
|
|
323
|
-
},
|
|
324
|
-
exampleComponent: {
|
|
325
|
-
_type: "components",
|
|
326
|
-
_data: [
|
|
327
|
-
{
|
|
328
|
-
exampleSliceId: ["id0", "id1"]
|
|
329
|
-
}
|
|
330
|
-
]
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
},
|
|
334
|
-
singleNamedRef: () => {
|
|
335
|
-
return {
|
|
336
|
-
tableA: {
|
|
337
|
-
_type: "components",
|
|
338
|
-
_data: [
|
|
339
|
-
{
|
|
340
|
-
keyA0: "a0"
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
keyA1: "a1"
|
|
344
|
-
}
|
|
345
|
-
]
|
|
346
|
-
},
|
|
347
|
-
tableB: {
|
|
348
|
-
_type: "components",
|
|
349
|
-
_data: [
|
|
350
|
-
{
|
|
351
|
-
namedRef: { component: "tableA", ref: "KFQrf4mEz0UPmUaFHwH4T6" }
|
|
352
|
-
}
|
|
353
|
-
]
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
},
|
|
357
|
-
multiRef: () => {
|
|
358
|
-
return {
|
|
359
|
-
tableA: {
|
|
360
|
-
_type: "components",
|
|
361
|
-
_data: [
|
|
362
|
-
{
|
|
363
|
-
keyA0: "a0"
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
keyA1: "a1"
|
|
367
|
-
}
|
|
368
|
-
]
|
|
369
|
-
},
|
|
370
|
-
tableB: {
|
|
371
|
-
_type: "components",
|
|
372
|
-
_data: [
|
|
373
|
-
{
|
|
374
|
-
tableARef: ["KFQrf4mEz0UPmUaFHwH4T6", "YPw-pxhqaUOWRFGramr4B1"]
|
|
375
|
-
}
|
|
376
|
-
]
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
},
|
|
380
|
-
multiMixedRef: () => {
|
|
381
|
-
return {
|
|
382
|
-
tableA: {
|
|
383
|
-
_type: "components",
|
|
384
|
-
_data: [
|
|
385
|
-
{
|
|
386
|
-
keyA0: "a0"
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
keyA1: "a1"
|
|
390
|
-
}
|
|
391
|
-
]
|
|
392
|
-
},
|
|
393
|
-
tableB: {
|
|
394
|
-
_type: "components",
|
|
395
|
-
_data: [
|
|
396
|
-
{
|
|
397
|
-
keyB0: "b0"
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
keyB1: "b1"
|
|
401
|
-
}
|
|
402
|
-
]
|
|
403
|
-
},
|
|
404
|
-
tableC: {
|
|
405
|
-
_type: "components",
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
singleRow: () => {
|
|
267
|
+
const tableCfgs = hip({
|
|
268
|
+
_hash: "",
|
|
269
|
+
_type: "tableCfgs",
|
|
406
270
|
_data: [
|
|
407
271
|
{
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
272
|
+
version: 0,
|
|
273
|
+
_hash: "",
|
|
274
|
+
key: "table",
|
|
275
|
+
type: "components",
|
|
276
|
+
isHead: false,
|
|
277
|
+
isRoot: false,
|
|
278
|
+
isShared: true,
|
|
279
|
+
columns: [
|
|
280
|
+
{
|
|
281
|
+
key: "_hash",
|
|
282
|
+
type: "string"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
key: "int",
|
|
286
|
+
type: "number"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
key: "double",
|
|
290
|
+
type: "number"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: "string",
|
|
294
|
+
type: "string"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: "boolean",
|
|
298
|
+
type: "boolean"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
key: "null",
|
|
302
|
+
type: "string"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: "jsonArray",
|
|
306
|
+
type: "jsonArray"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
key: "json",
|
|
310
|
+
type: "json"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: "jsonValue",
|
|
314
|
+
type: "jsonValue"
|
|
315
|
+
}
|
|
411
316
|
]
|
|
412
317
|
}
|
|
413
318
|
]
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
add: ["id0", "id1"]
|
|
319
|
+
});
|
|
320
|
+
const result = {
|
|
321
|
+
tableCfgs,
|
|
322
|
+
table: {
|
|
323
|
+
_tableCfg: tableCfgs._data[0]._hash,
|
|
324
|
+
_type: "components",
|
|
325
|
+
_data: [hip(exampleJsonObject())],
|
|
326
|
+
_hash: ""
|
|
423
327
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
const abLayer1 = hip({
|
|
442
|
-
base: abLayer0._hash,
|
|
443
|
-
sliceIdsTable: "sliceIds",
|
|
444
|
-
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
445
|
-
componentsTable: "components",
|
|
446
|
-
add: {
|
|
447
|
-
id0: component0._hash,
|
|
448
|
-
id1: component1._hash
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
const abLayers = hip({
|
|
452
|
-
_type: "layers",
|
|
453
|
-
_data: [abLayer0, abLayer1]
|
|
454
|
-
});
|
|
455
|
-
const cake = hip({
|
|
456
|
-
sliceIdsTable: "sliceIds",
|
|
457
|
-
sliceIdsRow: sliceIds._data[0]._hash,
|
|
458
|
-
layers: {
|
|
459
|
-
abLayers: abLayer1._hash
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
const cakes = hip({
|
|
463
|
-
_type: "cakes",
|
|
464
|
-
_data: [cake]
|
|
465
|
-
});
|
|
466
|
-
const buffets = hip({
|
|
467
|
-
_type: "buffets",
|
|
468
|
-
_data: [
|
|
469
|
-
{
|
|
470
|
-
items: [
|
|
328
|
+
};
|
|
329
|
+
return result;
|
|
330
|
+
},
|
|
331
|
+
multipleRows: () => {
|
|
332
|
+
return {
|
|
333
|
+
table: {
|
|
334
|
+
_type: "components",
|
|
335
|
+
_data: [
|
|
336
|
+
{
|
|
337
|
+
string: "str0",
|
|
338
|
+
boolean: true,
|
|
339
|
+
number: 1,
|
|
340
|
+
array: [1, "str0", true, { a: { b: "c" } }],
|
|
341
|
+
object: { a: { b: "c" } }
|
|
342
|
+
},
|
|
471
343
|
{
|
|
472
|
-
|
|
473
|
-
|
|
344
|
+
string: "str1",
|
|
345
|
+
boolean: true,
|
|
346
|
+
number: 1,
|
|
347
|
+
array: [1, "str1", true, { a: { b: "c" } }],
|
|
348
|
+
object: { a: { b: "c" } }
|
|
474
349
|
},
|
|
475
350
|
{
|
|
476
|
-
|
|
477
|
-
|
|
351
|
+
string: "str2",
|
|
352
|
+
boolean: false,
|
|
353
|
+
number: 1,
|
|
354
|
+
array: [1, "str1", true, { a: { b: "c" } }],
|
|
355
|
+
object: { d: { e: "f" } }
|
|
478
356
|
}
|
|
479
357
|
]
|
|
480
358
|
}
|
|
481
|
-
]
|
|
482
|
-
});
|
|
483
|
-
return {
|
|
484
|
-
sliceIds,
|
|
485
|
-
components,
|
|
486
|
-
abLayers,
|
|
487
|
-
cakes,
|
|
488
|
-
buffets
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
__publicField(_Example, "broken", {
|
|
493
|
-
base: {
|
|
494
|
-
brokenTableKey: () => {
|
|
495
|
-
return {
|
|
496
|
-
brok$en: {
|
|
497
|
-
_data: []
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
},
|
|
501
|
-
missingData: () => {
|
|
502
|
-
return {
|
|
503
|
-
table: {}
|
|
504
|
-
};
|
|
505
|
-
},
|
|
506
|
-
dataNotBeingAnArray: () => {
|
|
507
|
-
return {
|
|
508
|
-
table: {
|
|
509
|
-
_data: {}
|
|
510
|
-
}
|
|
511
359
|
};
|
|
512
360
|
},
|
|
513
|
-
|
|
361
|
+
singleRef: () => {
|
|
514
362
|
return {
|
|
515
363
|
tableA: {
|
|
516
364
|
_type: "components",
|
|
@@ -527,38 +375,53 @@ __publicField(_Example, "broken", {
|
|
|
527
375
|
_type: "components",
|
|
528
376
|
_data: [
|
|
529
377
|
{
|
|
530
|
-
tableARef: "
|
|
531
|
-
// MISSINGREF does not exist in tableA
|
|
378
|
+
tableARef: "KFQrf4mEz0UPmUaFHwH4T6"
|
|
532
379
|
}
|
|
533
380
|
]
|
|
534
381
|
}
|
|
535
382
|
};
|
|
536
383
|
},
|
|
537
|
-
|
|
384
|
+
singleSliceIdRef: () => {
|
|
538
385
|
return {
|
|
539
|
-
|
|
386
|
+
exampleSliceId: {
|
|
387
|
+
_type: "sliceIds",
|
|
388
|
+
_data: [
|
|
389
|
+
{
|
|
390
|
+
add: ["id0", "id1"]
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
},
|
|
394
|
+
exampleComponent: {
|
|
540
395
|
_type: "components",
|
|
541
396
|
_data: [
|
|
542
397
|
{
|
|
543
|
-
|
|
544
|
-
}
|
|
398
|
+
exampleSliceId: "id0"
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
},
|
|
404
|
+
multiSliceIdRef: () => {
|
|
405
|
+
return {
|
|
406
|
+
exampleSliceId: {
|
|
407
|
+
_type: "sliceIds",
|
|
408
|
+
_data: [
|
|
545
409
|
{
|
|
546
|
-
|
|
410
|
+
add: ["id0", "id1"]
|
|
547
411
|
}
|
|
548
412
|
]
|
|
549
413
|
},
|
|
550
|
-
|
|
414
|
+
exampleComponent: {
|
|
551
415
|
_type: "components",
|
|
552
416
|
_data: [
|
|
553
417
|
{
|
|
554
|
-
|
|
555
|
-
// MISSINGREF does not exist in tableA
|
|
418
|
+
exampleSliceId: ["id0", "id1"]
|
|
556
419
|
}
|
|
557
420
|
]
|
|
558
421
|
}
|
|
559
422
|
};
|
|
560
423
|
},
|
|
561
|
-
|
|
424
|
+
singleNamedRef: () => {
|
|
562
425
|
return {
|
|
563
426
|
tableA: {
|
|
564
427
|
_type: "components",
|
|
@@ -575,157 +438,384 @@ __publicField(_Example, "broken", {
|
|
|
575
438
|
_type: "components",
|
|
576
439
|
_data: [
|
|
577
440
|
{
|
|
578
|
-
|
|
441
|
+
namedRef: { component: "tableA", ref: "KFQrf4mEz0UPmUaFHwH4T6" }
|
|
579
442
|
}
|
|
580
443
|
]
|
|
581
444
|
}
|
|
582
445
|
};
|
|
583
446
|
},
|
|
584
|
-
|
|
447
|
+
multiRef: () => {
|
|
585
448
|
return {
|
|
449
|
+
tableA: {
|
|
450
|
+
_type: "components",
|
|
451
|
+
_data: [
|
|
452
|
+
{
|
|
453
|
+
keyA0: "a0"
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
keyA1: "a1"
|
|
457
|
+
}
|
|
458
|
+
]
|
|
459
|
+
},
|
|
586
460
|
tableB: {
|
|
587
461
|
_type: "components",
|
|
588
462
|
_data: [
|
|
589
463
|
{
|
|
590
|
-
tableARef: "
|
|
591
|
-
// tableA is missing
|
|
464
|
+
tableARef: ["KFQrf4mEz0UPmUaFHwH4T6", "YPw-pxhqaUOWRFGramr4B1"]
|
|
592
465
|
}
|
|
593
466
|
]
|
|
594
467
|
}
|
|
595
468
|
};
|
|
596
469
|
},
|
|
597
|
-
|
|
470
|
+
multiMixedRef: () => {
|
|
598
471
|
return {
|
|
599
|
-
|
|
600
|
-
_type: "
|
|
472
|
+
tableA: {
|
|
473
|
+
_type: "components",
|
|
601
474
|
_data: [
|
|
602
475
|
{
|
|
603
|
-
|
|
476
|
+
keyA0: "a0"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
keyA1: "a1"
|
|
604
480
|
}
|
|
605
481
|
]
|
|
606
482
|
},
|
|
607
|
-
|
|
483
|
+
tableB: {
|
|
608
484
|
_type: "components",
|
|
609
485
|
_data: [
|
|
610
486
|
{
|
|
611
|
-
|
|
487
|
+
keyB0: "b0"
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
keyB1: "b1"
|
|
612
491
|
}
|
|
613
492
|
]
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
},
|
|
617
|
-
missingSliceIdTable: () => {
|
|
618
|
-
return {
|
|
619
|
-
exampleComponent: {
|
|
493
|
+
},
|
|
494
|
+
tableC: {
|
|
620
495
|
_type: "components",
|
|
621
496
|
_data: [
|
|
622
497
|
{
|
|
623
|
-
|
|
498
|
+
tableRef: [
|
|
499
|
+
{ component: "tableA", ref: "KFQrf4mEz0UPmUaFHwH4T6" },
|
|
500
|
+
{ component: "tableB", ref: "dXhIygNwNMVPEqFbsFJkn6" }
|
|
501
|
+
]
|
|
624
502
|
}
|
|
625
503
|
]
|
|
626
504
|
}
|
|
627
505
|
};
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
updateExistingHashes: true,
|
|
638
|
-
throwOnWrongHashes: false
|
|
506
|
+
},
|
|
507
|
+
complete: () => {
|
|
508
|
+
const sliceIds = hip({
|
|
509
|
+
_type: "sliceIds",
|
|
510
|
+
_data: [
|
|
511
|
+
{
|
|
512
|
+
add: ["id0", "id1"]
|
|
513
|
+
}
|
|
514
|
+
]
|
|
639
515
|
});
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
missingBase: () => {
|
|
644
|
-
const result = _Example.ok.complete();
|
|
645
|
-
const layer1 = result.abLayers._data[1];
|
|
646
|
-
layer1.base = "MISSING";
|
|
647
|
-
return hip(result, {
|
|
648
|
-
updateExistingHashes: true,
|
|
649
|
-
throwOnWrongHashes: false
|
|
516
|
+
const components = hip({
|
|
517
|
+
_type: "components",
|
|
518
|
+
_data: [{ a: "0" }, { a: "1" }]
|
|
650
519
|
});
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
520
|
+
const component0 = components._data[0];
|
|
521
|
+
const component1 = components._data[1];
|
|
522
|
+
const abLayer0 = hip({
|
|
523
|
+
sliceIdsTable: "sliceIds",
|
|
524
|
+
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
525
|
+
componentsTable: "components",
|
|
526
|
+
add: {
|
|
527
|
+
id0: component0._hash,
|
|
528
|
+
id1: component1._hash
|
|
529
|
+
}
|
|
659
530
|
});
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return hip(result, {
|
|
670
|
-
updateExistingHashes: true,
|
|
671
|
-
throwOnWrongHashes: false
|
|
531
|
+
const abLayer1 = hip({
|
|
532
|
+
base: abLayer0._hash,
|
|
533
|
+
sliceIdsTable: "sliceIds",
|
|
534
|
+
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
535
|
+
componentsTable: "components",
|
|
536
|
+
add: {
|
|
537
|
+
id0: component0._hash,
|
|
538
|
+
id1: component1._hash
|
|
539
|
+
}
|
|
672
540
|
});
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
missingSliceIdSet: () => {
|
|
677
|
-
const result = _Example.ok.complete();
|
|
678
|
-
result.cakes._data[0].sliceIdsRow = "MISSING";
|
|
679
|
-
hip(result.cakes, {
|
|
680
|
-
updateExistingHashes: true,
|
|
681
|
-
throwOnWrongHashes: false
|
|
541
|
+
const abLayers = hip({
|
|
542
|
+
_type: "layers",
|
|
543
|
+
_data: [abLayer0, abLayer1]
|
|
682
544
|
});
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
545
|
+
const cake = hip({
|
|
546
|
+
sliceIdsTable: "sliceIds",
|
|
547
|
+
sliceIdsRow: sliceIds._data[0]._hash,
|
|
548
|
+
layers: {
|
|
549
|
+
abLayers: abLayer1._hash
|
|
550
|
+
}
|
|
687
551
|
});
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
const result = _Example.ok.complete();
|
|
692
|
-
result.cakes._data[0].layers = { MISSING: "HASH" };
|
|
693
|
-
hip(result.cakes, {
|
|
694
|
-
updateExistingHashes: true,
|
|
695
|
-
throwOnWrongHashes: false
|
|
552
|
+
const cakes = hip({
|
|
553
|
+
_type: "cakes",
|
|
554
|
+
_data: [cake]
|
|
696
555
|
});
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
556
|
+
const buffets = hip({
|
|
557
|
+
_type: "buffets",
|
|
558
|
+
_data: [
|
|
559
|
+
{
|
|
560
|
+
items: [
|
|
561
|
+
{
|
|
562
|
+
table: "cakes",
|
|
563
|
+
ref: cakes._data[0]._hash
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
table: "abLayers",
|
|
567
|
+
ref: abLayer0._hash
|
|
568
|
+
}
|
|
569
|
+
]
|
|
570
|
+
}
|
|
571
|
+
]
|
|
705
572
|
});
|
|
706
|
-
return
|
|
573
|
+
return {
|
|
574
|
+
sliceIds,
|
|
575
|
+
components,
|
|
576
|
+
abLayers,
|
|
577
|
+
cakes,
|
|
578
|
+
buffets
|
|
579
|
+
};
|
|
707
580
|
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
581
|
+
};
|
|
582
|
+
static broken = {
|
|
583
|
+
base: {
|
|
584
|
+
brokenTableKey: () => {
|
|
585
|
+
return {
|
|
586
|
+
brok$en: {
|
|
587
|
+
_data: []
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
},
|
|
591
|
+
missingData: () => {
|
|
592
|
+
return {
|
|
593
|
+
table: {}
|
|
594
|
+
};
|
|
595
|
+
},
|
|
596
|
+
dataNotBeingAnArray: () => {
|
|
597
|
+
return {
|
|
598
|
+
table: {
|
|
599
|
+
_data: {}
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
},
|
|
603
|
+
missingRef: () => {
|
|
604
|
+
return {
|
|
605
|
+
tableA: {
|
|
606
|
+
_type: "components",
|
|
607
|
+
_data: [
|
|
608
|
+
{
|
|
609
|
+
keyA0: "a0"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
keyA1: "a1"
|
|
613
|
+
}
|
|
614
|
+
]
|
|
615
|
+
},
|
|
616
|
+
tableB: {
|
|
617
|
+
_type: "components",
|
|
618
|
+
_data: [
|
|
619
|
+
{
|
|
620
|
+
tableARef: "MISSINGREF"
|
|
621
|
+
// MISSINGREF does not exist in tableA
|
|
622
|
+
}
|
|
623
|
+
]
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
},
|
|
627
|
+
missingNamedRef: () => {
|
|
628
|
+
return {
|
|
629
|
+
tableA: {
|
|
630
|
+
_type: "components",
|
|
631
|
+
_data: [
|
|
632
|
+
{
|
|
633
|
+
keyA0: "a0"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
keyA1: "a1"
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
},
|
|
640
|
+
tableB: {
|
|
641
|
+
_type: "components",
|
|
642
|
+
_data: [
|
|
643
|
+
{
|
|
644
|
+
namedRef: { component: "tableA", ref: "MISSINGREF" }
|
|
645
|
+
// MISSINGREF does not exist in tableA
|
|
646
|
+
}
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
},
|
|
651
|
+
missingMultiRef: () => {
|
|
652
|
+
return {
|
|
653
|
+
tableA: {
|
|
654
|
+
_type: "components",
|
|
655
|
+
_data: [
|
|
656
|
+
{
|
|
657
|
+
keyA0: "a0"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
keyA1: "a1"
|
|
661
|
+
}
|
|
662
|
+
]
|
|
663
|
+
},
|
|
664
|
+
tableB: {
|
|
665
|
+
_type: "components",
|
|
666
|
+
_data: [
|
|
667
|
+
{
|
|
668
|
+
tableARef: ["KFQrf4mEz0UPmUaFHwH4T6", "MISSING"]
|
|
669
|
+
}
|
|
670
|
+
]
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
missingReferencedTable: () => {
|
|
675
|
+
return {
|
|
676
|
+
tableB: {
|
|
677
|
+
_type: "components",
|
|
678
|
+
_data: [
|
|
679
|
+
{
|
|
680
|
+
tableARef: "MISSINGREF"
|
|
681
|
+
// tableA is missing
|
|
682
|
+
}
|
|
683
|
+
]
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
missingSliceId: () => {
|
|
688
|
+
return {
|
|
689
|
+
exampleSliceId: {
|
|
690
|
+
_type: "sliceIds",
|
|
691
|
+
_data: [
|
|
692
|
+
{
|
|
693
|
+
add: ["id0", "id1"]
|
|
694
|
+
}
|
|
695
|
+
]
|
|
696
|
+
},
|
|
697
|
+
exampleComponent: {
|
|
698
|
+
_type: "components",
|
|
699
|
+
_data: [
|
|
700
|
+
{
|
|
701
|
+
exampleSliceId: "id2"
|
|
702
|
+
}
|
|
703
|
+
]
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
},
|
|
707
|
+
missingSliceIdTable: () => {
|
|
708
|
+
return {
|
|
709
|
+
exampleComponent: {
|
|
710
|
+
_type: "components",
|
|
711
|
+
_data: [
|
|
712
|
+
{
|
|
713
|
+
exampleSliceId: "id0"
|
|
714
|
+
}
|
|
715
|
+
]
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
}
|
|
717
719
|
},
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
720
|
+
tableCfg: {
|
|
721
|
+
wrongType: () => {
|
|
722
|
+
const result = Example.ok.singleRow();
|
|
723
|
+
const columns = result.tableCfgs._data[0].columns;
|
|
724
|
+
const intColumn = columns.find((c) => c.key === "int");
|
|
725
|
+
intColumn.type = "numberBroken";
|
|
726
|
+
return hip(result, {
|
|
727
|
+
updateExistingHashes: true,
|
|
728
|
+
throwOnWrongHashes: false
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
layers: {
|
|
733
|
+
missingBase: () => {
|
|
734
|
+
const result = Example.ok.complete();
|
|
735
|
+
const layer1 = result.abLayers._data[1];
|
|
736
|
+
layer1.base = "MISSING";
|
|
737
|
+
return hip(result, {
|
|
738
|
+
updateExistingHashes: true,
|
|
739
|
+
throwOnWrongHashes: false
|
|
740
|
+
});
|
|
741
|
+
},
|
|
742
|
+
missingSliceIdSet: () => {
|
|
743
|
+
const result = Example.ok.complete();
|
|
744
|
+
const layer1 = result.abLayers._data[1];
|
|
745
|
+
layer1.sliceIdsTableRow = "MISSING1";
|
|
746
|
+
return hip(result, {
|
|
747
|
+
updateExistingHashes: true,
|
|
748
|
+
throwOnWrongHashes: false
|
|
749
|
+
});
|
|
750
|
+
},
|
|
751
|
+
missingAssignedComponentTable: () => {
|
|
752
|
+
const result = Example.ok.complete();
|
|
753
|
+
delete result.components;
|
|
754
|
+
return result;
|
|
755
|
+
},
|
|
756
|
+
missingAssignedComponent: () => {
|
|
757
|
+
const result = Example.ok.complete();
|
|
758
|
+
result.components._data.splice(1, 2);
|
|
759
|
+
return hip(result, {
|
|
760
|
+
updateExistingHashes: true,
|
|
761
|
+
throwOnWrongHashes: false
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
cakes: {
|
|
766
|
+
missingSliceIdSet: () => {
|
|
767
|
+
const result = Example.ok.complete();
|
|
768
|
+
result.cakes._data[0].sliceIdsRow = "MISSING";
|
|
769
|
+
hip(result.cakes, {
|
|
770
|
+
updateExistingHashes: true,
|
|
771
|
+
throwOnWrongHashes: false
|
|
772
|
+
});
|
|
773
|
+
result.buffets._data[0].items[0].ref = result.cakes._data[0]._hash;
|
|
774
|
+
hip(result.buffets, {
|
|
775
|
+
updateExistingHashes: true,
|
|
776
|
+
throwOnWrongHashes: false
|
|
777
|
+
});
|
|
778
|
+
return result;
|
|
779
|
+
},
|
|
780
|
+
missingLayersTable: () => {
|
|
781
|
+
const result = Example.ok.complete();
|
|
782
|
+
result.cakes._data[0].layers = { MISSING: "HASH" };
|
|
783
|
+
hip(result.cakes, {
|
|
784
|
+
updateExistingHashes: true,
|
|
785
|
+
throwOnWrongHashes: false
|
|
786
|
+
});
|
|
787
|
+
return result;
|
|
788
|
+
},
|
|
789
|
+
missingCakeLayer: () => {
|
|
790
|
+
const result = Example.ok.complete();
|
|
791
|
+
result.cakes._data[0].layers["abLayers"] = "MISSING0";
|
|
792
|
+
hip(result.cakes, {
|
|
793
|
+
updateExistingHashes: true,
|
|
794
|
+
throwOnWrongHashes: false
|
|
795
|
+
});
|
|
796
|
+
return result;
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
buffets: {
|
|
800
|
+
missingTable: () => {
|
|
801
|
+
const result = Example.ok.complete();
|
|
802
|
+
const buffet = result.buffets._data[0];
|
|
803
|
+
buffet.items[0].table = "MISSING0";
|
|
804
|
+
buffet.items[1].table = "MISSING1";
|
|
805
|
+
hip(result, { updateExistingHashes: true, throwOnWrongHashes: false });
|
|
806
|
+
return result;
|
|
807
|
+
},
|
|
808
|
+
missingItems: () => {
|
|
809
|
+
const result = Example.ok.complete();
|
|
810
|
+
const buffet = result.buffets._data[0];
|
|
811
|
+
buffet.items[0].ref = "MISSING0";
|
|
812
|
+
buffet.items[1].ref = "MISSING1";
|
|
813
|
+
hip(result, { updateExistingHashes: true, throwOnWrongHashes: false });
|
|
814
|
+
return result;
|
|
815
|
+
}
|
|
725
816
|
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
let Example = _Example;
|
|
817
|
+
};
|
|
818
|
+
}
|
|
729
819
|
// @license
|
|
730
820
|
const throwOnInvalidTableCfg = (tableCfg) => {
|
|
731
821
|
if (tableCfg.columns.length < 2) {
|
|
@@ -771,10 +861,12 @@ const validateRljsonAgainstTableCfg = (rows, tableCfg) => {
|
|
|
771
861
|
if (value === void 0 || value === null) {
|
|
772
862
|
continue;
|
|
773
863
|
}
|
|
774
|
-
const
|
|
775
|
-
if (
|
|
864
|
+
const typesMatched = jsonValueMatchesType(row[columnKey], expectedType);
|
|
865
|
+
if (!typesMatched) {
|
|
776
866
|
errors.push(
|
|
777
|
-
`Column "${columnKey}" in row ${i} of "${tableKey}" has type "${
|
|
867
|
+
`Column "${columnKey}" in row ${i} of "${tableKey}" has type "${jsonValueType(
|
|
868
|
+
row[columnKey]
|
|
869
|
+
)}", but expected "${expectedType}"`
|
|
778
870
|
);
|
|
779
871
|
}
|
|
780
872
|
}
|
|
@@ -804,8 +896,8 @@ const addColumnsToTableCfg = (tableCfg, columns) => {
|
|
|
804
896
|
const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
|
|
805
897
|
const exampleTableCfg = (tableCfg = void 0) => {
|
|
806
898
|
return {
|
|
807
|
-
key:
|
|
808
|
-
columns:
|
|
899
|
+
key: tableCfg?.key ?? "table",
|
|
900
|
+
columns: tableCfg?.columns ?? [
|
|
809
901
|
{
|
|
810
902
|
key: "_hash",
|
|
811
903
|
type: "string"
|
|
@@ -819,13 +911,15 @@ const exampleTableCfg = (tableCfg = void 0) => {
|
|
|
819
911
|
type: "number"
|
|
820
912
|
}
|
|
821
913
|
],
|
|
822
|
-
type:
|
|
914
|
+
type: tableCfg?.type ?? "components",
|
|
823
915
|
isHead: true,
|
|
824
916
|
isRoot: true,
|
|
825
917
|
isShared: false
|
|
826
918
|
};
|
|
827
919
|
};
|
|
828
920
|
// @license
|
|
921
|
+
const exampleEditsTable = () => bakeryExample().ingredientsEdits;
|
|
922
|
+
// @license
|
|
829
923
|
const reservedFieldNames = ["_data"];
|
|
830
924
|
const reservedTableKeys = [
|
|
831
925
|
"_hash",
|
|
@@ -880,6 +974,10 @@ const removeDuplicates = (rljson) => {
|
|
|
880
974
|
return hip(result, { throwOnWrongHashes: false });
|
|
881
975
|
};
|
|
882
976
|
// @license
|
|
977
|
+
const timeId = () => {
|
|
978
|
+
return nanoid(4) + ":" + Date.now();
|
|
979
|
+
};
|
|
980
|
+
// @license
|
|
883
981
|
const contentTypes = [
|
|
884
982
|
"buffets",
|
|
885
983
|
"cakes",
|
|
@@ -887,7 +985,8 @@ const contentTypes = [
|
|
|
887
985
|
"sliceIds",
|
|
888
986
|
"components",
|
|
889
987
|
"revisions",
|
|
890
|
-
"tableCfgs"
|
|
988
|
+
"tableCfgs",
|
|
989
|
+
"edits"
|
|
891
990
|
];
|
|
892
991
|
const exampleTypedefs = () => {
|
|
893
992
|
return {
|
|
@@ -922,9 +1021,7 @@ const rljsonIndexed = (rljson) => {
|
|
|
922
1021
|
};
|
|
923
1022
|
// @license
|
|
924
1023
|
class BaseValidator {
|
|
925
|
-
|
|
926
|
-
__publicField(this, "name", "base");
|
|
927
|
-
}
|
|
1024
|
+
name = "base";
|
|
928
1025
|
async validate(rljson) {
|
|
929
1026
|
return this.validateSync(rljson);
|
|
930
1027
|
}
|
|
@@ -937,18 +1034,13 @@ class BaseValidator {
|
|
|
937
1034
|
}
|
|
938
1035
|
class _BaseValidator {
|
|
939
1036
|
constructor(rljson) {
|
|
940
|
-
__publicField(this, "errors", { hasErrors: false });
|
|
941
|
-
// ######################
|
|
942
|
-
// Private
|
|
943
|
-
// ######################
|
|
944
|
-
__publicField(this, "tableKeys");
|
|
945
|
-
__publicField(this, "rljsonIndexed");
|
|
946
1037
|
this.rljson = rljson;
|
|
947
1038
|
this.tableKeys = Object.keys(this.rljson).filter(
|
|
948
1039
|
(table) => !table.startsWith("_")
|
|
949
1040
|
);
|
|
950
1041
|
this.rljsonIndexed = rljsonIndexed(rljson);
|
|
951
1042
|
}
|
|
1043
|
+
errors = { hasErrors: false };
|
|
952
1044
|
get hasErrors() {
|
|
953
1045
|
return Object.keys(this.errors).length > 1;
|
|
954
1046
|
}
|
|
@@ -994,6 +1086,11 @@ class _BaseValidator {
|
|
|
994
1086
|
this.errors.hasErrors = this.hasErrors;
|
|
995
1087
|
return this.errors;
|
|
996
1088
|
}
|
|
1089
|
+
// ######################
|
|
1090
|
+
// Private
|
|
1091
|
+
// ######################
|
|
1092
|
+
tableKeys;
|
|
1093
|
+
rljsonIndexed;
|
|
997
1094
|
_tableKeysNotLowerCamelCase() {
|
|
998
1095
|
const invalidTableKeys = [];
|
|
999
1096
|
for (const tableKey of this.tableKeys) {
|
|
@@ -1038,7 +1135,7 @@ class _BaseValidator {
|
|
|
1038
1135
|
continue;
|
|
1039
1136
|
}
|
|
1040
1137
|
if (!BaseValidator.isValidFieldName(columnName)) {
|
|
1041
|
-
invalidColumnNames[tableKey]
|
|
1138
|
+
invalidColumnNames[tableKey] ??= [];
|
|
1042
1139
|
invalidColumnNames[tableKey].push(columnName);
|
|
1043
1140
|
hadErrors = true;
|
|
1044
1141
|
}
|
|
@@ -1405,10 +1502,9 @@ class _BaseValidator {
|
|
|
1405
1502
|
continue;
|
|
1406
1503
|
}
|
|
1407
1504
|
const targetSliceIdsTable = this.rljson[key];
|
|
1408
|
-
const targetSliceIds2 = targetSliceIdsTable._data.flatMap(
|
|
1409
|
-
...d.add,
|
|
1410
|
-
|
|
1411
|
-
]);
|
|
1505
|
+
const targetSliceIds2 = targetSliceIdsTable._data.flatMap(
|
|
1506
|
+
(d) => [...d.add, ...d.remove ?? []]
|
|
1507
|
+
);
|
|
1412
1508
|
if (targetSliceIds2.indexOf(targetSliceId) === -1) {
|
|
1413
1509
|
missingSliceIdRefs.push({
|
|
1414
1510
|
sourceTable: tableKey,
|
|
@@ -1744,12 +1840,6 @@ class _BaseValidator {
|
|
|
1744
1840
|
const isValidFieldName = (fieldName) => BaseValidator.isValidFieldName(fieldName);
|
|
1745
1841
|
// @license
|
|
1746
1842
|
class Validate {
|
|
1747
|
-
constructor() {
|
|
1748
|
-
// ######################
|
|
1749
|
-
// Private
|
|
1750
|
-
// ######################
|
|
1751
|
-
__publicField(this, "_validators", []);
|
|
1752
|
-
}
|
|
1753
1843
|
addValidator(validator) {
|
|
1754
1844
|
this._validators.push(validator);
|
|
1755
1845
|
}
|
|
@@ -1778,17 +1868,25 @@ class Validate {
|
|
|
1778
1868
|
return acc;
|
|
1779
1869
|
}, {});
|
|
1780
1870
|
}
|
|
1871
|
+
// ######################
|
|
1872
|
+
// Private
|
|
1873
|
+
// ######################
|
|
1874
|
+
_validators = [];
|
|
1781
1875
|
}
|
|
1782
1876
|
export {
|
|
1783
1877
|
BaseValidator,
|
|
1784
1878
|
Example,
|
|
1879
|
+
Route,
|
|
1785
1880
|
Validate,
|
|
1786
1881
|
addColumnsToTableCfg,
|
|
1787
1882
|
bakeryExample,
|
|
1788
1883
|
contentTypes,
|
|
1884
|
+
createCakeTableCfg,
|
|
1885
|
+
createLayerTableCfg,
|
|
1789
1886
|
exampleBuffetsTable,
|
|
1790
1887
|
exampleCakesTable,
|
|
1791
1888
|
exampleComponentsTable,
|
|
1889
|
+
exampleEditsTable,
|
|
1792
1890
|
exampleLayersTable,
|
|
1793
1891
|
exampleRevision,
|
|
1794
1892
|
exampleRljson,
|
|
@@ -1803,5 +1901,6 @@ export {
|
|
|
1803
1901
|
reservedFieldNames,
|
|
1804
1902
|
reservedTableKeys,
|
|
1805
1903
|
throwOnInvalidTableCfg,
|
|
1904
|
+
timeId,
|
|
1806
1905
|
validateRljsonAgainstTableCfg
|
|
1807
1906
|
};
|