@rljson/rljson 0.0.53 → 0.0.56
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/example.d.ts +9 -0
- package/dist/rljson.js +609 -350
- package/dist/src/example.ts +207 -1
- package/package.json +16 -8
package/dist/example.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export declare class Example {
|
|
|
7
7
|
singleRow: () => Rljson;
|
|
8
8
|
multipleRows: () => Rljson;
|
|
9
9
|
singleRef: () => Rljson;
|
|
10
|
+
singleSliceIdRef: () => Rljson;
|
|
11
|
+
multiSliceIdRef: () => Rljson;
|
|
12
|
+
singleNamedRef: () => Rljson;
|
|
13
|
+
multiRef: () => Rljson;
|
|
14
|
+
multiMixedRef: () => Rljson;
|
|
10
15
|
complete: () => Rljson;
|
|
11
16
|
};
|
|
12
17
|
static readonly broken: {
|
|
@@ -19,7 +24,11 @@ export declare class Example {
|
|
|
19
24
|
missingData: () => Rljson;
|
|
20
25
|
dataNotBeingAnArray: () => Rljson;
|
|
21
26
|
missingRef: () => Rljson;
|
|
27
|
+
missingNamedRef: () => Rljson;
|
|
28
|
+
missingMultiRef: () => Rljson;
|
|
22
29
|
missingReferencedTable: () => Rljson;
|
|
30
|
+
missingSliceId: () => Rljson;
|
|
31
|
+
missingSliceIdTable: () => Rljson;
|
|
23
32
|
};
|
|
24
33
|
tableCfg: {
|
|
25
34
|
wrongType: () => Rljson;
|
package/dist/rljson.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
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);
|
|
1
4
|
import { hip, hsh } from "@rljson/hash";
|
|
2
5
|
import { exampleJsonObject, jsonValueTypes, jsonValueType, jsonValueMatchesType } from "@rljson/json";
|
|
3
6
|
// @license
|
|
@@ -154,117 +157,408 @@ const exampleRevision = () => ({
|
|
|
154
157
|
// @license
|
|
155
158
|
const exampleSliceIdsTable = () => bakeryExample().slices;
|
|
156
159
|
// @license
|
|
157
|
-
class
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
const _Example = class _Example {
|
|
161
|
+
};
|
|
162
|
+
__publicField(_Example, "ok", {
|
|
163
|
+
bakery: () => bakeryExample(),
|
|
164
|
+
empty: () => {
|
|
165
|
+
return {};
|
|
166
|
+
},
|
|
167
|
+
binary: () => {
|
|
168
|
+
return {
|
|
169
|
+
table: {
|
|
170
|
+
_type: "components",
|
|
171
|
+
_data: [
|
|
172
|
+
{ a: false, b: false },
|
|
173
|
+
{ a: false, b: true },
|
|
174
|
+
{ a: true, b: false },
|
|
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
|
+
}
|
|
172
226
|
]
|
|
173
227
|
}
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
const result = {
|
|
231
|
+
tableCfgs,
|
|
232
|
+
table: {
|
|
233
|
+
_tableCfg: tableCfgs._data[0]._hash,
|
|
234
|
+
_type: "components",
|
|
235
|
+
_data: [exampleJsonObject()],
|
|
236
|
+
_hash: ""
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return result;
|
|
240
|
+
},
|
|
241
|
+
multipleRows: () => {
|
|
242
|
+
return {
|
|
243
|
+
table: {
|
|
244
|
+
_type: "components",
|
|
180
245
|
_data: [
|
|
181
246
|
{
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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",
|
|
406
|
+
_data: [
|
|
407
|
+
{
|
|
408
|
+
tableRef: [
|
|
409
|
+
{ component: "tableA", ref: "KFQrf4mEz0UPmUaFHwH4T6" },
|
|
410
|
+
{ component: "tableB", ref: "dXhIygNwNMVPEqFbsFJkn6" }
|
|
222
411
|
]
|
|
223
412
|
}
|
|
224
413
|
]
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
},
|
|
417
|
+
complete: () => {
|
|
418
|
+
const sliceIds = hip({
|
|
419
|
+
_type: "sliceIds",
|
|
420
|
+
_data: [
|
|
421
|
+
{
|
|
422
|
+
add: ["id0", "id1"]
|
|
423
|
+
}
|
|
424
|
+
]
|
|
425
|
+
});
|
|
426
|
+
const components = hip({
|
|
427
|
+
_type: "components",
|
|
428
|
+
_data: [{ a: "0" }, { a: "1" }]
|
|
429
|
+
});
|
|
430
|
+
const component0 = components._data[0];
|
|
431
|
+
const component1 = components._data[1];
|
|
432
|
+
const abLayer0 = hip({
|
|
433
|
+
sliceIdsTable: "sliceIds",
|
|
434
|
+
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
435
|
+
componentsTable: "components",
|
|
436
|
+
add: {
|
|
437
|
+
id0: component0._hash,
|
|
438
|
+
id1: component1._hash
|
|
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: [
|
|
471
|
+
{
|
|
472
|
+
table: "cakes",
|
|
473
|
+
ref: cakes._data[0]._hash
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
table: "abLayers",
|
|
477
|
+
ref: abLayer0._hash
|
|
478
|
+
}
|
|
479
|
+
]
|
|
480
|
+
}
|
|
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: []
|
|
233
498
|
}
|
|
234
499
|
};
|
|
235
|
-
return result;
|
|
236
500
|
},
|
|
237
|
-
|
|
501
|
+
missingData: () => {
|
|
502
|
+
return {
|
|
503
|
+
table: {}
|
|
504
|
+
};
|
|
505
|
+
},
|
|
506
|
+
dataNotBeingAnArray: () => {
|
|
238
507
|
return {
|
|
239
508
|
table: {
|
|
509
|
+
_data: {}
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
},
|
|
513
|
+
missingRef: () => {
|
|
514
|
+
return {
|
|
515
|
+
tableA: {
|
|
240
516
|
_type: "components",
|
|
241
517
|
_data: [
|
|
242
518
|
{
|
|
243
|
-
|
|
244
|
-
boolean: true,
|
|
245
|
-
number: 1,
|
|
246
|
-
array: [1, "str0", true, { a: { b: "c" } }],
|
|
247
|
-
object: { a: { b: "c" } }
|
|
519
|
+
keyA0: "a0"
|
|
248
520
|
},
|
|
249
521
|
{
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
522
|
+
keyA1: "a1"
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
},
|
|
526
|
+
tableB: {
|
|
527
|
+
_type: "components",
|
|
528
|
+
_data: [
|
|
529
|
+
{
|
|
530
|
+
tableARef: "MISSINGREF"
|
|
531
|
+
// MISSINGREF does not exist in tableA
|
|
532
|
+
}
|
|
533
|
+
]
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
},
|
|
537
|
+
missingNamedRef: () => {
|
|
538
|
+
return {
|
|
539
|
+
tableA: {
|
|
540
|
+
_type: "components",
|
|
541
|
+
_data: [
|
|
542
|
+
{
|
|
543
|
+
keyA0: "a0"
|
|
255
544
|
},
|
|
256
545
|
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
546
|
+
keyA1: "a1"
|
|
547
|
+
}
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
tableB: {
|
|
551
|
+
_type: "components",
|
|
552
|
+
_data: [
|
|
553
|
+
{
|
|
554
|
+
namedRef: { component: "tableA", ref: "MISSINGREF" }
|
|
555
|
+
// MISSINGREF does not exist in tableA
|
|
262
556
|
}
|
|
263
557
|
]
|
|
264
558
|
}
|
|
265
559
|
};
|
|
266
560
|
},
|
|
267
|
-
|
|
561
|
+
missingMultiRef: () => {
|
|
268
562
|
return {
|
|
269
563
|
tableA: {
|
|
270
564
|
_type: "components",
|
|
@@ -281,245 +575,157 @@ class Example {
|
|
|
281
575
|
_type: "components",
|
|
282
576
|
_data: [
|
|
283
577
|
{
|
|
284
|
-
tableARef: "KFQrf4mEz0UPmUaFHwH4T6"
|
|
578
|
+
tableARef: ["KFQrf4mEz0UPmUaFHwH4T6", "MISSING"]
|
|
285
579
|
}
|
|
286
580
|
]
|
|
287
581
|
}
|
|
288
582
|
};
|
|
289
583
|
},
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
_type: "components",
|
|
301
|
-
_data: [{ a: "0" }, { a: "1" }]
|
|
302
|
-
});
|
|
303
|
-
const component0 = components._data[0];
|
|
304
|
-
const component1 = components._data[1];
|
|
305
|
-
const abLayer0 = hip({
|
|
306
|
-
sliceIdsTable: "sliceIds",
|
|
307
|
-
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
308
|
-
componentsTable: "components",
|
|
309
|
-
add: {
|
|
310
|
-
id0: component0._hash,
|
|
311
|
-
id1: component1._hash
|
|
584
|
+
missingReferencedTable: () => {
|
|
585
|
+
return {
|
|
586
|
+
tableB: {
|
|
587
|
+
_type: "components",
|
|
588
|
+
_data: [
|
|
589
|
+
{
|
|
590
|
+
tableARef: "MISSINGREF"
|
|
591
|
+
// tableA is missing
|
|
592
|
+
}
|
|
593
|
+
]
|
|
312
594
|
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
595
|
+
};
|
|
596
|
+
},
|
|
597
|
+
missingSliceId: () => {
|
|
598
|
+
return {
|
|
599
|
+
exampleSliceId: {
|
|
600
|
+
_type: "sliceIds",
|
|
601
|
+
_data: [
|
|
602
|
+
{
|
|
603
|
+
add: ["id0", "id1"]
|
|
604
|
+
}
|
|
605
|
+
]
|
|
606
|
+
},
|
|
607
|
+
exampleComponent: {
|
|
608
|
+
_type: "components",
|
|
609
|
+
_data: [
|
|
610
|
+
{
|
|
611
|
+
exampleSliceId: "id2"
|
|
612
|
+
}
|
|
613
|
+
]
|
|
322
614
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
615
|
+
};
|
|
616
|
+
},
|
|
617
|
+
missingSliceIdTable: () => {
|
|
618
|
+
return {
|
|
619
|
+
exampleComponent: {
|
|
620
|
+
_type: "components",
|
|
621
|
+
_data: [
|
|
622
|
+
{
|
|
623
|
+
exampleSliceId: "id0"
|
|
624
|
+
}
|
|
625
|
+
]
|
|
333
626
|
}
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
tableCfg: {
|
|
631
|
+
wrongType: () => {
|
|
632
|
+
const result = _Example.ok.singleRow();
|
|
633
|
+
const columns = result.tableCfgs._data[0].columns;
|
|
634
|
+
const intColumn = columns.find((c) => c.key === "int");
|
|
635
|
+
intColumn.type = "numberBroken";
|
|
636
|
+
return hip(result, {
|
|
637
|
+
updateExistingHashes: true,
|
|
638
|
+
throwOnWrongHashes: false
|
|
334
639
|
});
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
640
|
+
}
|
|
641
|
+
},
|
|
642
|
+
layers: {
|
|
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
|
|
338
650
|
});
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
table: "abLayers",
|
|
350
|
-
ref: abLayer0._hash
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
}
|
|
354
|
-
]
|
|
651
|
+
},
|
|
652
|
+
missingSliceIdSet: () => {
|
|
653
|
+
const result = _Example.ok.complete();
|
|
654
|
+
const layer1 = result.abLayers._data[1];
|
|
655
|
+
layer1.sliceIdsTableRow = "MISSING1";
|
|
656
|
+
return hip(result, {
|
|
657
|
+
updateExistingHashes: true,
|
|
658
|
+
throwOnWrongHashes: false
|
|
355
659
|
});
|
|
356
|
-
return {
|
|
357
|
-
sliceIds,
|
|
358
|
-
components,
|
|
359
|
-
abLayers,
|
|
360
|
-
cakes,
|
|
361
|
-
buffets
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
static broken = {
|
|
366
|
-
base: {
|
|
367
|
-
brokenTableKey: () => {
|
|
368
|
-
return {
|
|
369
|
-
brok$en: {
|
|
370
|
-
_data: []
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
},
|
|
374
|
-
missingData: () => {
|
|
375
|
-
return {
|
|
376
|
-
table: {}
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
dataNotBeingAnArray: () => {
|
|
380
|
-
return {
|
|
381
|
-
table: {
|
|
382
|
-
_data: {}
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
},
|
|
386
|
-
missingRef: () => {
|
|
387
|
-
return {
|
|
388
|
-
tableA: {
|
|
389
|
-
_type: "components",
|
|
390
|
-
_data: [
|
|
391
|
-
{
|
|
392
|
-
keyA0: "a0"
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
keyA1: "a1"
|
|
396
|
-
}
|
|
397
|
-
]
|
|
398
|
-
},
|
|
399
|
-
tableB: {
|
|
400
|
-
_type: "components",
|
|
401
|
-
_data: [
|
|
402
|
-
{
|
|
403
|
-
tableARef: "MISSINGREF"
|
|
404
|
-
// MISSINGREF does not exist in tableA
|
|
405
|
-
}
|
|
406
|
-
]
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
},
|
|
410
|
-
missingReferencedTable: () => {
|
|
411
|
-
return {
|
|
412
|
-
tableB: {
|
|
413
|
-
_type: "components",
|
|
414
|
-
_data: [
|
|
415
|
-
{
|
|
416
|
-
tableARef: "MISSINGREF"
|
|
417
|
-
// tableA is missing
|
|
418
|
-
}
|
|
419
|
-
]
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
660
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const intColumn = columns.find((c) => c.key === "int");
|
|
429
|
-
intColumn.type = "numberBroken";
|
|
430
|
-
return hip(result, {
|
|
431
|
-
updateExistingHashes: true,
|
|
432
|
-
throwOnWrongHashes: false
|
|
433
|
-
});
|
|
434
|
-
}
|
|
661
|
+
missingAssignedComponentTable: () => {
|
|
662
|
+
const result = _Example.ok.complete();
|
|
663
|
+
delete result.components;
|
|
664
|
+
return result;
|
|
435
665
|
},
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
},
|
|
460
|
-
missingAssignedComponent: () => {
|
|
461
|
-
const result = Example.ok.complete();
|
|
462
|
-
result.components._data.splice(1, 2);
|
|
463
|
-
return hip(result, {
|
|
464
|
-
updateExistingHashes: true,
|
|
465
|
-
throwOnWrongHashes: false
|
|
466
|
-
});
|
|
467
|
-
}
|
|
666
|
+
missingAssignedComponent: () => {
|
|
667
|
+
const result = _Example.ok.complete();
|
|
668
|
+
result.components._data.splice(1, 2);
|
|
669
|
+
return hip(result, {
|
|
670
|
+
updateExistingHashes: true,
|
|
671
|
+
throwOnWrongHashes: false
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
cakes: {
|
|
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
|
|
682
|
+
});
|
|
683
|
+
result.buffets._data[0].items[0].ref = result.cakes._data[0]._hash;
|
|
684
|
+
hip(result.buffets, {
|
|
685
|
+
updateExistingHashes: true,
|
|
686
|
+
throwOnWrongHashes: false
|
|
687
|
+
});
|
|
688
|
+
return result;
|
|
468
689
|
},
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
result.buffets._data[0].items[0].ref = result.cakes._data[0]._hash;
|
|
478
|
-
hip(result.buffets, {
|
|
479
|
-
updateExistingHashes: true,
|
|
480
|
-
throwOnWrongHashes: false
|
|
481
|
-
});
|
|
482
|
-
return result;
|
|
483
|
-
},
|
|
484
|
-
missingLayersTable: () => {
|
|
485
|
-
const result = Example.ok.complete();
|
|
486
|
-
result.cakes._data[0].layers = { MISSING: "HASH" };
|
|
487
|
-
hip(result.cakes, {
|
|
488
|
-
updateExistingHashes: true,
|
|
489
|
-
throwOnWrongHashes: false
|
|
490
|
-
});
|
|
491
|
-
return result;
|
|
492
|
-
},
|
|
493
|
-
missingCakeLayer: () => {
|
|
494
|
-
const result = Example.ok.complete();
|
|
495
|
-
result.cakes._data[0].layers["abLayers"] = "MISSING0";
|
|
496
|
-
hip(result.cakes, {
|
|
497
|
-
updateExistingHashes: true,
|
|
498
|
-
throwOnWrongHashes: false
|
|
499
|
-
});
|
|
500
|
-
return result;
|
|
501
|
-
}
|
|
690
|
+
missingLayersTable: () => {
|
|
691
|
+
const result = _Example.ok.complete();
|
|
692
|
+
result.cakes._data[0].layers = { MISSING: "HASH" };
|
|
693
|
+
hip(result.cakes, {
|
|
694
|
+
updateExistingHashes: true,
|
|
695
|
+
throwOnWrongHashes: false
|
|
696
|
+
});
|
|
697
|
+
return result;
|
|
502
698
|
},
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
},
|
|
512
|
-
missingItems: () => {
|
|
513
|
-
const result = Example.ok.complete();
|
|
514
|
-
const buffet = result.buffets._data[0];
|
|
515
|
-
buffet.items[0].ref = "MISSING0";
|
|
516
|
-
buffet.items[1].ref = "MISSING1";
|
|
517
|
-
hip(result, { updateExistingHashes: true, throwOnWrongHashes: false });
|
|
518
|
-
return result;
|
|
519
|
-
}
|
|
699
|
+
missingCakeLayer: () => {
|
|
700
|
+
const result = _Example.ok.complete();
|
|
701
|
+
result.cakes._data[0].layers["abLayers"] = "MISSING0";
|
|
702
|
+
hip(result.cakes, {
|
|
703
|
+
updateExistingHashes: true,
|
|
704
|
+
throwOnWrongHashes: false
|
|
705
|
+
});
|
|
706
|
+
return result;
|
|
520
707
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
708
|
+
},
|
|
709
|
+
buffets: {
|
|
710
|
+
missingTable: () => {
|
|
711
|
+
const result = _Example.ok.complete();
|
|
712
|
+
const buffet = result.buffets._data[0];
|
|
713
|
+
buffet.items[0].table = "MISSING0";
|
|
714
|
+
buffet.items[1].table = "MISSING1";
|
|
715
|
+
hip(result, { updateExistingHashes: true, throwOnWrongHashes: false });
|
|
716
|
+
return result;
|
|
717
|
+
},
|
|
718
|
+
missingItems: () => {
|
|
719
|
+
const result = _Example.ok.complete();
|
|
720
|
+
const buffet = result.buffets._data[0];
|
|
721
|
+
buffet.items[0].ref = "MISSING0";
|
|
722
|
+
buffet.items[1].ref = "MISSING1";
|
|
723
|
+
hip(result, { updateExistingHashes: true, throwOnWrongHashes: false });
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
let Example = _Example;
|
|
523
729
|
// @license
|
|
524
730
|
const throwOnInvalidTableCfg = (tableCfg) => {
|
|
525
731
|
if (tableCfg.columns.length < 2) {
|
|
@@ -598,8 +804,8 @@ const addColumnsToTableCfg = (tableCfg, columns) => {
|
|
|
598
804
|
const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
|
|
599
805
|
const exampleTableCfg = (tableCfg = void 0) => {
|
|
600
806
|
return {
|
|
601
|
-
key: tableCfg
|
|
602
|
-
columns: tableCfg
|
|
807
|
+
key: (tableCfg == null ? void 0 : tableCfg.key) ?? "table",
|
|
808
|
+
columns: (tableCfg == null ? void 0 : tableCfg.columns) ?? [
|
|
603
809
|
{
|
|
604
810
|
key: "_hash",
|
|
605
811
|
type: "string"
|
|
@@ -613,7 +819,7 @@ const exampleTableCfg = (tableCfg = void 0) => {
|
|
|
613
819
|
type: "number"
|
|
614
820
|
}
|
|
615
821
|
],
|
|
616
|
-
type: tableCfg
|
|
822
|
+
type: (tableCfg == null ? void 0 : tableCfg.type) ?? "components",
|
|
617
823
|
isHead: true,
|
|
618
824
|
isRoot: true,
|
|
619
825
|
isShared: false
|
|
@@ -716,7 +922,9 @@ const rljsonIndexed = (rljson) => {
|
|
|
716
922
|
};
|
|
717
923
|
// @license
|
|
718
924
|
class BaseValidator {
|
|
719
|
-
|
|
925
|
+
constructor() {
|
|
926
|
+
__publicField(this, "name", "base");
|
|
927
|
+
}
|
|
720
928
|
async validate(rljson) {
|
|
721
929
|
return this.validateSync(rljson);
|
|
722
930
|
}
|
|
@@ -729,13 +937,18 @@ class BaseValidator {
|
|
|
729
937
|
}
|
|
730
938
|
class _BaseValidator {
|
|
731
939
|
constructor(rljson) {
|
|
940
|
+
__publicField(this, "errors", { hasErrors: false });
|
|
941
|
+
// ######################
|
|
942
|
+
// Private
|
|
943
|
+
// ######################
|
|
944
|
+
__publicField(this, "tableKeys");
|
|
945
|
+
__publicField(this, "rljsonIndexed");
|
|
732
946
|
this.rljson = rljson;
|
|
733
947
|
this.tableKeys = Object.keys(this.rljson).filter(
|
|
734
948
|
(table) => !table.startsWith("_")
|
|
735
949
|
);
|
|
736
950
|
this.rljsonIndexed = rljsonIndexed(rljson);
|
|
737
951
|
}
|
|
738
|
-
errors = { hasErrors: false };
|
|
739
952
|
get hasErrors() {
|
|
740
953
|
return Object.keys(this.errors).length > 1;
|
|
741
954
|
}
|
|
@@ -758,6 +971,7 @@ class _BaseValidator {
|
|
|
758
971
|
() => this._rootOrHeadTableHasNoIdColumn(),
|
|
759
972
|
// Check references
|
|
760
973
|
() => this._refsNotFound(),
|
|
974
|
+
() => this._sliceIdRefsNotFound(),
|
|
761
975
|
// Check layers
|
|
762
976
|
() => this._layerBasesNotFound(),
|
|
763
977
|
() => this._layerSliceIdsTableNotFound(),
|
|
@@ -780,11 +994,6 @@ class _BaseValidator {
|
|
|
780
994
|
this.errors.hasErrors = this.hasErrors;
|
|
781
995
|
return this.errors;
|
|
782
996
|
}
|
|
783
|
-
// ######################
|
|
784
|
-
// Private
|
|
785
|
-
// ######################
|
|
786
|
-
tableKeys;
|
|
787
|
-
rljsonIndexed;
|
|
788
997
|
_tableKeysNotLowerCamelCase() {
|
|
789
998
|
const invalidTableKeys = [];
|
|
790
999
|
for (const tableKey of this.tableKeys) {
|
|
@@ -829,7 +1038,7 @@ class _BaseValidator {
|
|
|
829
1038
|
continue;
|
|
830
1039
|
}
|
|
831
1040
|
if (!BaseValidator.isValidFieldName(columnName)) {
|
|
832
|
-
invalidColumnNames[tableKey]
|
|
1041
|
+
invalidColumnNames[tableKey] ?? (invalidColumnNames[tableKey] = []);
|
|
833
1042
|
invalidColumnNames[tableKey].push(columnName);
|
|
834
1043
|
hadErrors = true;
|
|
835
1044
|
}
|
|
@@ -1136,31 +1345,34 @@ class _BaseValidator {
|
|
|
1136
1345
|
for (const item of tableData) {
|
|
1137
1346
|
for (const key of Object.keys(item)) {
|
|
1138
1347
|
if (key.endsWith("Ref")) {
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1348
|
+
const targetItemRefs = Array.isArray(item[key]) ? item[key] : [item[key]];
|
|
1349
|
+
for (const targetItemRef of targetItemRefs) {
|
|
1350
|
+
const targetTableKey = typeof targetItemRef !== "string" ? targetItemRef.component : key.substring(0, key.length - 3);
|
|
1351
|
+
const targetItemHash = typeof targetItemRef !== "string" ? targetItemRef.ref : targetItemRef;
|
|
1352
|
+
const itemHash = item._hash;
|
|
1353
|
+
if (this.tableKeys.indexOf(targetTableKey) === -1) {
|
|
1354
|
+
missingRefs.push({
|
|
1355
|
+
error: `Target table "${targetTableKey}" not found.`,
|
|
1356
|
+
sourceTable: tableKey,
|
|
1357
|
+
sourceKey: key,
|
|
1358
|
+
sourceItemHash: itemHash,
|
|
1359
|
+
targetItemHash,
|
|
1360
|
+
targetTable: targetTableKey
|
|
1361
|
+
});
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
const targetTableIndexed = this.rljsonIndexed[targetTableKey];
|
|
1365
|
+
const referencedItem = targetTableIndexed._data[targetItemHash];
|
|
1366
|
+
if (referencedItem === void 0) {
|
|
1367
|
+
missingRefs.push({
|
|
1368
|
+
sourceTable: tableKey,
|
|
1369
|
+
sourceItemHash: itemHash,
|
|
1370
|
+
sourceKey: key,
|
|
1371
|
+
targetItemHash,
|
|
1372
|
+
targetTable: targetTableKey,
|
|
1373
|
+
error: `Table "${targetTableKey}" has no item with hash "${targetItemHash}"`
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1164
1376
|
}
|
|
1165
1377
|
}
|
|
1166
1378
|
}
|
|
@@ -1173,6 +1385,51 @@ class _BaseValidator {
|
|
|
1173
1385
|
};
|
|
1174
1386
|
}
|
|
1175
1387
|
}
|
|
1388
|
+
// ...........................................................................
|
|
1389
|
+
_sliceIdRefsNotFound() {
|
|
1390
|
+
const missingSliceIdRefs = [];
|
|
1391
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1392
|
+
const tableData = table._data;
|
|
1393
|
+
for (const item of tableData) {
|
|
1394
|
+
for (const key of Object.keys(item)) {
|
|
1395
|
+
if (key.endsWith("SliceId")) {
|
|
1396
|
+
const targetSliceIds = Array.isArray(item[key]) ? item[key] : [item[key]];
|
|
1397
|
+
for (const targetSliceId of targetSliceIds) {
|
|
1398
|
+
if (this.tableKeys.indexOf(key) === -1) {
|
|
1399
|
+
missingSliceIdRefs.push({
|
|
1400
|
+
sourceTable: tableKey,
|
|
1401
|
+
targetSliceId,
|
|
1402
|
+
targetTable: key,
|
|
1403
|
+
error: `Target table "${targetSliceId}" not found.`
|
|
1404
|
+
});
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
const targetSliceIdsTable = this.rljson[key];
|
|
1408
|
+
const targetSliceIds2 = targetSliceIdsTable._data.flatMap((d) => [
|
|
1409
|
+
...d.add,
|
|
1410
|
+
...d.remove ?? []
|
|
1411
|
+
]);
|
|
1412
|
+
if (targetSliceIds2.indexOf(targetSliceId) === -1) {
|
|
1413
|
+
missingSliceIdRefs.push({
|
|
1414
|
+
sourceTable: tableKey,
|
|
1415
|
+
targetSliceId,
|
|
1416
|
+
targetTable: key,
|
|
1417
|
+
error: `Table "${key}" has no sliceId "${targetSliceId}"`
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
if (missingSliceIdRefs.length > 0) {
|
|
1426
|
+
this.errors.refsNotFound = {
|
|
1427
|
+
error: "Broken references",
|
|
1428
|
+
missingRefs: missingSliceIdRefs
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
// ...........................................................................
|
|
1176
1433
|
_layerBasesNotFound() {
|
|
1177
1434
|
const brokenLayers = [];
|
|
1178
1435
|
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
@@ -1487,6 +1744,12 @@ class _BaseValidator {
|
|
|
1487
1744
|
const isValidFieldName = (fieldName) => BaseValidator.isValidFieldName(fieldName);
|
|
1488
1745
|
// @license
|
|
1489
1746
|
class Validate {
|
|
1747
|
+
constructor() {
|
|
1748
|
+
// ######################
|
|
1749
|
+
// Private
|
|
1750
|
+
// ######################
|
|
1751
|
+
__publicField(this, "_validators", []);
|
|
1752
|
+
}
|
|
1490
1753
|
addValidator(validator) {
|
|
1491
1754
|
this._validators.push(validator);
|
|
1492
1755
|
}
|
|
@@ -1515,10 +1778,6 @@ class Validate {
|
|
|
1515
1778
|
return acc;
|
|
1516
1779
|
}, {});
|
|
1517
1780
|
}
|
|
1518
|
-
// ######################
|
|
1519
|
-
// Private
|
|
1520
|
-
// ######################
|
|
1521
|
-
_validators = [];
|
|
1522
1781
|
}
|
|
1523
1782
|
export {
|
|
1524
1783
|
BaseValidator,
|
package/dist/src/example.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// found in the LICENSE file in the root of this package.
|
|
6
6
|
|
|
7
7
|
import { hip } from '@rljson/hash';
|
|
8
|
-
import { exampleJsonObject } from '@rljson/json';
|
|
8
|
+
import { exampleJsonObject, Json } from '@rljson/json';
|
|
9
9
|
|
|
10
10
|
import { BuffetsTable } from './content/buffet.ts';
|
|
11
11
|
import { Cake, CakesTable } from './content/cake.ts';
|
|
@@ -157,6 +157,130 @@ export class Example {
|
|
|
157
157
|
},
|
|
158
158
|
};
|
|
159
159
|
},
|
|
160
|
+
singleSliceIdRef: (): Rljson => {
|
|
161
|
+
return {
|
|
162
|
+
exampleSliceId: {
|
|
163
|
+
_type: 'sliceIds',
|
|
164
|
+
_data: [
|
|
165
|
+
{
|
|
166
|
+
add: ['id0', 'id1'],
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
} as SliceIdsTable,
|
|
170
|
+
exampleComponent: {
|
|
171
|
+
_type: 'components',
|
|
172
|
+
_data: [
|
|
173
|
+
{
|
|
174
|
+
exampleSliceId: 'id0',
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
} as ComponentsTable<Json>,
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
multiSliceIdRef: (): Rljson => {
|
|
181
|
+
return {
|
|
182
|
+
exampleSliceId: {
|
|
183
|
+
_type: 'sliceIds',
|
|
184
|
+
_data: [
|
|
185
|
+
{
|
|
186
|
+
add: ['id0', 'id1'],
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
} as SliceIdsTable,
|
|
190
|
+
exampleComponent: {
|
|
191
|
+
_type: 'components',
|
|
192
|
+
_data: [
|
|
193
|
+
{
|
|
194
|
+
exampleSliceId: ['id0', 'id1'],
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
} as ComponentsTable<Json>,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
singleNamedRef: (): Rljson => {
|
|
201
|
+
return {
|
|
202
|
+
tableA: {
|
|
203
|
+
_type: 'components',
|
|
204
|
+
_data: [
|
|
205
|
+
{
|
|
206
|
+
keyA0: 'a0',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
keyA1: 'a1',
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
tableB: {
|
|
214
|
+
_type: 'components',
|
|
215
|
+
_data: [
|
|
216
|
+
{
|
|
217
|
+
namedRef: { component: 'tableA', ref: 'KFQrf4mEz0UPmUaFHwH4T6' },
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
multiRef: (): Rljson => {
|
|
224
|
+
return {
|
|
225
|
+
tableA: {
|
|
226
|
+
_type: 'components',
|
|
227
|
+
_data: [
|
|
228
|
+
{
|
|
229
|
+
keyA0: 'a0',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
keyA1: 'a1',
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
tableB: {
|
|
237
|
+
_type: 'components',
|
|
238
|
+
_data: [
|
|
239
|
+
{
|
|
240
|
+
tableARef: ['KFQrf4mEz0UPmUaFHwH4T6', 'YPw-pxhqaUOWRFGramr4B1'],
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
multiMixedRef: (): Rljson => {
|
|
247
|
+
return {
|
|
248
|
+
tableA: {
|
|
249
|
+
_type: 'components',
|
|
250
|
+
_data: [
|
|
251
|
+
{
|
|
252
|
+
keyA0: 'a0',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
keyA1: 'a1',
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
tableB: {
|
|
260
|
+
_type: 'components',
|
|
261
|
+
_data: [
|
|
262
|
+
{
|
|
263
|
+
keyB0: 'b0',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
keyB1: 'b1',
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
tableC: {
|
|
271
|
+
_type: 'components',
|
|
272
|
+
_data: [
|
|
273
|
+
{
|
|
274
|
+
tableRef: [
|
|
275
|
+
{ component: 'tableA', ref: 'KFQrf4mEz0UPmUaFHwH4T6' },
|
|
276
|
+
{ component: 'tableB', ref: 'dXhIygNwNMVPEqFbsFJkn6' },
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
|
|
160
284
|
complete: (): Rljson => {
|
|
161
285
|
const sliceIds = hip<SliceIdsTable>({
|
|
162
286
|
_type: 'sliceIds',
|
|
@@ -289,6 +413,54 @@ export class Example {
|
|
|
289
413
|
};
|
|
290
414
|
},
|
|
291
415
|
|
|
416
|
+
missingNamedRef: (): Rljson => {
|
|
417
|
+
return {
|
|
418
|
+
tableA: {
|
|
419
|
+
_type: 'components',
|
|
420
|
+
_data: [
|
|
421
|
+
{
|
|
422
|
+
keyA0: 'a0',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
keyA1: 'a1',
|
|
426
|
+
},
|
|
427
|
+
],
|
|
428
|
+
},
|
|
429
|
+
tableB: {
|
|
430
|
+
_type: 'components',
|
|
431
|
+
_data: [
|
|
432
|
+
{
|
|
433
|
+
namedRef: { component: 'tableA', ref: 'MISSINGREF' }, // MISSINGREF does not exist in tableA
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
missingMultiRef: (): Rljson => {
|
|
441
|
+
return {
|
|
442
|
+
tableA: {
|
|
443
|
+
_type: 'components',
|
|
444
|
+
_data: [
|
|
445
|
+
{
|
|
446
|
+
keyA0: 'a0',
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
keyA1: 'a1',
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
},
|
|
453
|
+
tableB: {
|
|
454
|
+
_type: 'components',
|
|
455
|
+
_data: [
|
|
456
|
+
{
|
|
457
|
+
tableARef: ['KFQrf4mEz0UPmUaFHwH4T6', 'MISSING'],
|
|
458
|
+
},
|
|
459
|
+
],
|
|
460
|
+
},
|
|
461
|
+
};
|
|
462
|
+
},
|
|
463
|
+
|
|
292
464
|
missingReferencedTable: (): Rljson => {
|
|
293
465
|
return {
|
|
294
466
|
tableB: {
|
|
@@ -301,6 +473,40 @@ export class Example {
|
|
|
301
473
|
},
|
|
302
474
|
};
|
|
303
475
|
},
|
|
476
|
+
|
|
477
|
+
missingSliceId: (): Rljson => {
|
|
478
|
+
return {
|
|
479
|
+
exampleSliceId: {
|
|
480
|
+
_type: 'sliceIds',
|
|
481
|
+
_data: [
|
|
482
|
+
{
|
|
483
|
+
add: ['id0', 'id1'],
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
} as SliceIdsTable,
|
|
487
|
+
exampleComponent: {
|
|
488
|
+
_type: 'components',
|
|
489
|
+
_data: [
|
|
490
|
+
{
|
|
491
|
+
exampleSliceId: 'id2',
|
|
492
|
+
},
|
|
493
|
+
],
|
|
494
|
+
} as ComponentsTable<Json>,
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
|
|
498
|
+
missingSliceIdTable: (): Rljson => {
|
|
499
|
+
return {
|
|
500
|
+
exampleComponent: {
|
|
501
|
+
_type: 'components',
|
|
502
|
+
_data: [
|
|
503
|
+
{
|
|
504
|
+
exampleSliceId: 'id0',
|
|
505
|
+
},
|
|
506
|
+
],
|
|
507
|
+
} as ComponentsTable<Json>,
|
|
508
|
+
};
|
|
509
|
+
},
|
|
304
510
|
},
|
|
305
511
|
|
|
306
512
|
tableCfg: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56",
|
|
4
|
+
"packageManager": "pnpm@10.11.0",
|
|
4
5
|
"description": "The RLJSON data format specification",
|
|
5
6
|
"homepage": "https://github.com/rljson/rljson",
|
|
6
7
|
"bugs": "https://github.com/rljson/rljson/issues",
|
|
@@ -19,6 +20,14 @@
|
|
|
19
20
|
"dist"
|
|
20
21
|
],
|
|
21
22
|
"type": "module",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npx vite build && tsc && cp README* dist && mkdir dist/src && cp src/example.ts dist/src",
|
|
25
|
+
"test": "npx vitest run --coverage && npm run lint",
|
|
26
|
+
"prebuild": "npm run test",
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
28
|
+
"lint": "npx eslint",
|
|
29
|
+
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|
|
30
|
+
},
|
|
22
31
|
"devDependencies": {
|
|
23
32
|
"@types/node": "^24.4.0",
|
|
24
33
|
"@typescript-eslint/eslint-plugin": "^8.43.0",
|
|
@@ -44,11 +53,10 @@
|
|
|
44
53
|
"@rljson/hash": "^0.0.16",
|
|
45
54
|
"@rljson/json": "^0.0.21"
|
|
46
55
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|
|
56
|
+
"pnpm": {
|
|
57
|
+
"onlyBuiltDependencies": [
|
|
58
|
+
"esbuild"
|
|
59
|
+
],
|
|
60
|
+
"overrides": {}
|
|
53
61
|
}
|
|
54
|
-
}
|
|
62
|
+
}
|