@rljson/rljson 0.0.65 → 0.0.67

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.
@@ -16,7 +16,6 @@ import { ColumnCfg, TablesCfgTable } from './content/table-cfg.ts';
16
16
  import { bakeryExample } from './example/bakery-example.ts';
17
17
  import { Rljson } from './rljson.ts';
18
18
 
19
-
20
19
  export class Example {
21
20
  static readonly ok = {
22
21
  bakery: (): Rljson => bakeryExample(),
@@ -158,26 +157,178 @@ export class Example {
158
157
  },
159
158
 
160
159
  singleRef: (): Rljson => {
160
+ const tableCfgs = hip<TablesCfgTable>({
161
+ _type: 'tableCfgs',
162
+ _data: [
163
+ {
164
+ key: 'tableA',
165
+ type: 'components',
166
+ isHead: false,
167
+ isRoot: false,
168
+ isShared: true,
169
+ columns: [
170
+ {
171
+ key: '_hash',
172
+ type: 'string',
173
+ titleLong: 'Hash',
174
+ titleShort: 'Hash',
175
+ },
176
+ {
177
+ key: 'propertyA',
178
+ type: 'string',
179
+ titleLong: 'Key',
180
+ titleShort: 'Key',
181
+ },
182
+ ],
183
+ _hash: '',
184
+ },
185
+ {
186
+ key: 'tableB',
187
+ type: 'components',
188
+ isHead: false,
189
+ isRoot: false,
190
+ isShared: true,
191
+ columns: [
192
+ {
193
+ key: '_hash',
194
+ type: 'string',
195
+ titleLong: 'Hash',
196
+ titleShort: 'Hash',
197
+ },
198
+ {
199
+ key: 'propertyAFromTableA',
200
+ type: 'string',
201
+ titleLong: 'Table A Reference',
202
+ titleShort: 'TableARef',
203
+ ref: {
204
+ tableKey: 'tableA',
205
+ columnKey: 'propertyA',
206
+ },
207
+ },
208
+ ],
209
+ _hash: '',
210
+ },
211
+ ],
212
+ } as TablesCfgTable);
213
+
214
+ const tableA = hip<ComponentsTable<Json>>({
215
+ _type: 'components',
216
+ _tableCfg: tableCfgs._data[0]._hash as string,
217
+ _data: [
218
+ {
219
+ propertyA: 'a0',
220
+ },
221
+ {
222
+ propertyA: 'a1',
223
+ },
224
+ ],
225
+ _hash: '',
226
+ });
227
+
228
+ const tableB = hip<ComponentsTable<Json>>({
229
+ _type: 'components',
230
+ _tableCfg: tableCfgs._data[1]._hash as string,
231
+ _data: [
232
+ {
233
+ propertyAFromTableA: tableA._data[0]._hash as string,
234
+ },
235
+ ],
236
+ _hash: '',
237
+ });
238
+
161
239
  return {
162
- tableA: {
163
- _type: 'components',
164
- _data: [
165
- {
166
- keyA0: 'a0',
167
- },
168
- {
169
- keyA1: 'a1',
170
- },
171
- ],
172
- },
173
- tableB: {
174
- _type: 'components',
175
- _data: [
176
- {
177
- tableARef: 'KFQrf4mEz0UPmUaFHwH4T6',
178
- },
179
- ],
180
- },
240
+ tableCfgs,
241
+ tableA,
242
+ tableB,
243
+ };
244
+ },
245
+ multiRef: (): Rljson => {
246
+ const tableCfgs = hip<TablesCfgTable>({
247
+ _type: 'tableCfgs',
248
+ _data: [
249
+ {
250
+ key: 'tableA',
251
+ type: 'components',
252
+ isHead: false,
253
+ isRoot: false,
254
+ isShared: true,
255
+ columns: [
256
+ {
257
+ key: '_hash',
258
+ type: 'string',
259
+ titleLong: 'Hash',
260
+ titleShort: 'Hash',
261
+ },
262
+ {
263
+ key: 'propertyA',
264
+ type: 'string',
265
+ titleLong: 'Key',
266
+ titleShort: 'Key',
267
+ },
268
+ ],
269
+ _hash: '',
270
+ },
271
+ {
272
+ key: 'tableB',
273
+ type: 'components',
274
+ isHead: false,
275
+ isRoot: false,
276
+ isShared: true,
277
+ columns: [
278
+ {
279
+ key: '_hash',
280
+ type: 'string',
281
+ titleLong: 'Hash',
282
+ titleShort: 'Hash',
283
+ },
284
+ {
285
+ key: 'propertyAFromTableA',
286
+ type: 'jsonValue',
287
+ titleLong: 'Table A Reference',
288
+ titleShort: 'TableARef',
289
+ ref: {
290
+ tableKey: 'tableA',
291
+ columnKey: 'propertyA',
292
+ },
293
+ },
294
+ ],
295
+ _hash: '',
296
+ },
297
+ ],
298
+ } as TablesCfgTable);
299
+
300
+ const tableA = hip<ComponentsTable<Json>>({
301
+ _type: 'components',
302
+ _tableCfg: tableCfgs._data[0]._hash as string,
303
+ _data: [
304
+ {
305
+ propertyA: 'a0',
306
+ },
307
+ {
308
+ propertyA: 'a1',
309
+ },
310
+ ],
311
+ _hash: '',
312
+ });
313
+
314
+ const tableB = hip<ComponentsTable<Json>>({
315
+ _type: 'components',
316
+ _tableCfg: tableCfgs._data[1]._hash as string,
317
+ _data: [
318
+ {
319
+ propertyAFromTableA: [
320
+ tableA._data[0]._hash,
321
+ tableA._data[1]._hash,
322
+ ] as string[],
323
+ },
324
+ ],
325
+ _hash: '',
326
+ });
327
+
328
+ return {
329
+ tableCfgs,
330
+ tableA,
331
+ tableB,
181
332
  };
182
333
  },
183
334
  singleSliceIdRef: (): Rljson => {
@@ -220,90 +371,6 @@ export class Example {
220
371
  } as ComponentsTable<Json>,
221
372
  };
222
373
  },
223
- singleNamedRef: (): 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
- namedRef: { component: 'tableA', ref: 'KFQrf4mEz0UPmUaFHwH4T6' },
241
- },
242
- ],
243
- },
244
- };
245
- },
246
- multiRef: (): 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
- tableARef: ['KFQrf4mEz0UPmUaFHwH4T6', 'YPw-pxhqaUOWRFGramr4B1'],
264
- },
265
- ],
266
- },
267
- };
268
- },
269
- multiMixedRef: (): Rljson => {
270
- return {
271
- tableA: {
272
- _type: 'components',
273
- _data: [
274
- {
275
- keyA0: 'a0',
276
- },
277
- {
278
- keyA1: 'a1',
279
- },
280
- ],
281
- },
282
- tableB: {
283
- _type: 'components',
284
- _data: [
285
- {
286
- keyB0: 'b0',
287
- },
288
- {
289
- keyB1: 'b1',
290
- },
291
- ],
292
- },
293
- tableC: {
294
- _type: 'components',
295
- _data: [
296
- {
297
- tableRef: [
298
- { component: 'tableA', ref: 'KFQrf4mEz0UPmUaFHwH4T6' },
299
- { component: 'tableB', ref: 'dXhIygNwNMVPEqFbsFJkn6' },
300
- ],
301
- },
302
- ],
303
- },
304
- };
305
- },
306
-
307
374
  complete: (): Rljson => {
308
375
  const sliceIds = hip<SliceIdsTable>({
309
376
  _type: 'sliceIds',
@@ -413,87 +480,226 @@ export class Example {
413
480
  },
414
481
 
415
482
  missingRef: (): Rljson => {
416
- return {
417
- tableA: {
418
- _type: 'components',
419
- _data: [
420
- {
421
- keyA0: 'a0',
422
- },
423
- {
424
- keyA1: 'a1',
425
- },
426
- ],
427
- },
428
- tableB: {
429
- _type: 'components',
430
- _data: [
431
- {
432
- tableARef: 'MISSINGREF', // MISSINGREF does not exist in tableA
433
- },
434
- ],
435
- },
436
- };
437
- },
483
+ const tableCfgs = hip<TablesCfgTable>({
484
+ _type: 'tableCfgs',
485
+ _data: [
486
+ {
487
+ key: 'tableA',
488
+ type: 'components',
489
+ isHead: false,
490
+ isRoot: false,
491
+ isShared: true,
492
+ columns: [
493
+ {
494
+ key: '_hash',
495
+ type: 'string',
496
+ titleLong: 'Hash',
497
+ titleShort: 'Hash',
498
+ },
499
+ {
500
+ key: 'propertyA',
501
+ type: 'string',
502
+ titleLong: 'Key',
503
+ titleShort: 'Key',
504
+ },
505
+ ],
506
+ _hash: '',
507
+ },
508
+ {
509
+ key: 'tableB',
510
+ type: 'components',
511
+ isHead: false,
512
+ isRoot: false,
513
+ isShared: true,
514
+ columns: [
515
+ {
516
+ key: '_hash',
517
+ type: 'string',
518
+ titleLong: 'Hash',
519
+ titleShort: 'Hash',
520
+ },
521
+ {
522
+ key: 'propertyAFromTableA',
523
+ type: 'jsonValue',
524
+ titleLong: 'Table A Reference',
525
+ titleShort: 'TableARef',
526
+ ref: {
527
+ tableKey: 'tableA',
528
+ columnKey: 'propertyA',
529
+ },
530
+ },
531
+ ],
532
+ _hash: '',
533
+ },
534
+ ],
535
+ } as TablesCfgTable);
536
+
537
+ const tableA = hip<ComponentsTable<Json>>({
538
+ _type: 'components',
539
+ _tableCfg: tableCfgs._data[0]._hash as string,
540
+ _data: [
541
+ {
542
+ propertyA: 'a0',
543
+ },
544
+ {
545
+ propertyA: 'a1',
546
+ },
547
+ ],
548
+ _hash: '',
549
+ });
550
+
551
+ const tableB = hip<ComponentsTable<Json>>({
552
+ _type: 'components',
553
+ _tableCfg: tableCfgs._data[1]._hash as string,
554
+ _data: [
555
+ {
556
+ propertyAFromTableA: 'MISSINGREF', // Missing reference
557
+ },
558
+ ],
559
+ _hash: '',
560
+ });
438
561
 
439
- missingNamedRef: (): Rljson => {
440
562
  return {
441
- tableA: {
442
- _type: 'components',
443
- _data: [
444
- {
445
- keyA0: 'a0',
446
- },
447
- {
448
- keyA1: 'a1',
449
- },
450
- ],
451
- },
452
- tableB: {
453
- _type: 'components',
454
- _data: [
455
- {
456
- namedRef: { component: 'tableA', ref: 'MISSINGREF' }, // MISSINGREF does not exist in tableA
457
- },
458
- ],
459
- },
563
+ tableCfgs,
564
+ tableA,
565
+ tableB,
460
566
  };
461
567
  },
462
568
 
463
569
  missingMultiRef: (): Rljson => {
570
+ const tableCfgs = hip<TablesCfgTable>({
571
+ _type: 'tableCfgs',
572
+ _data: [
573
+ {
574
+ key: 'tableA',
575
+ type: 'components',
576
+ isHead: false,
577
+ isRoot: false,
578
+ isShared: true,
579
+ columns: [
580
+ {
581
+ key: '_hash',
582
+ type: 'string',
583
+ titleLong: 'Hash',
584
+ titleShort: 'Hash',
585
+ },
586
+ {
587
+ key: 'propertyA',
588
+ type: 'string',
589
+ titleLong: 'Key',
590
+ titleShort: 'Key',
591
+ },
592
+ ],
593
+ _hash: '',
594
+ },
595
+ {
596
+ key: 'tableB',
597
+ type: 'components',
598
+ isHead: false,
599
+ isRoot: false,
600
+ isShared: true,
601
+ columns: [
602
+ {
603
+ key: '_hash',
604
+ type: 'string',
605
+ titleLong: 'Hash',
606
+ titleShort: 'Hash',
607
+ },
608
+ {
609
+ key: 'propertyAFromTableA',
610
+ type: 'jsonValue',
611
+ titleLong: 'Table A Reference',
612
+ titleShort: 'TableARef',
613
+ ref: {
614
+ tableKey: 'tableA',
615
+ columnKey: 'propertyA',
616
+ },
617
+ },
618
+ ],
619
+ _hash: '',
620
+ },
621
+ ],
622
+ } as TablesCfgTable);
623
+
624
+ const tableA = hip<ComponentsTable<Json>>({
625
+ _type: 'components',
626
+ _tableCfg: tableCfgs._data[0]._hash as string,
627
+ _data: [
628
+ {
629
+ propertyA: 'a0',
630
+ },
631
+ {
632
+ propertyA: 'a1',
633
+ },
634
+ ],
635
+ _hash: '',
636
+ });
637
+
638
+ const tableB = hip<ComponentsTable<Json>>({
639
+ _type: 'components',
640
+ _tableCfg: tableCfgs._data[1]._hash as string,
641
+ _data: [
642
+ {
643
+ propertyAFromTableA: [tableA._data[0]._hash, 'MISSINGREF'], // Missing reference
644
+ },
645
+ ],
646
+ _hash: '',
647
+ });
648
+
464
649
  return {
465
- tableA: {
466
- _type: 'components',
467
- _data: [
468
- {
469
- keyA0: 'a0',
470
- },
471
- {
472
- keyA1: 'a1',
473
- },
474
- ],
475
- },
476
- tableB: {
477
- _type: 'components',
478
- _data: [
479
- {
480
- tableARef: ['KFQrf4mEz0UPmUaFHwH4T6', 'MISSING'],
481
- },
482
- ],
483
- },
650
+ tableCfgs,
651
+ tableA,
652
+ tableB,
484
653
  };
485
654
  },
486
655
 
487
656
  missingReferencedTable: (): Rljson => {
657
+ const tableCfgs = hip<TablesCfgTable>({
658
+ _type: 'tableCfgs',
659
+ _data: [
660
+ {
661
+ key: 'tableB',
662
+ type: 'components',
663
+ isHead: false,
664
+ isRoot: false,
665
+ isShared: true,
666
+ columns: [
667
+ {
668
+ key: '_hash',
669
+ type: 'string',
670
+ titleLong: 'Hash',
671
+ titleShort: 'Hash',
672
+ },
673
+ {
674
+ key: 'propertyAFromTableA',
675
+ type: 'jsonValue',
676
+ titleLong: 'Table A Reference',
677
+ titleShort: 'TableARef',
678
+ ref: {
679
+ tableKey: 'tableA', // Referenced table missing
680
+ columnKey: 'propertyA',
681
+ },
682
+ },
683
+ ],
684
+ _hash: '',
685
+ },
686
+ ],
687
+ } as TablesCfgTable);
688
+
689
+ const tableB = hip<ComponentsTable<Json>>({
690
+ _type: 'components',
691
+ _tableCfg: tableCfgs._data[0]._hash as string,
692
+ _data: [
693
+ {
694
+ propertyAFromTableA: 'MISSINGREF', // Missing reference
695
+ },
696
+ ],
697
+ _hash: '',
698
+ });
699
+
488
700
  return {
489
- tableB: {
490
- _type: 'components',
491
- _data: [
492
- {
493
- tableARef: 'MISSINGREF', // tableA is missing
494
- },
495
- ],
496
- },
701
+ tableCfgs,
702
+ tableB,
497
703
  };
498
704
  },
499
705
 
@@ -26,7 +26,7 @@ export type ColumnKey = JsonKey;
26
26
  * - `ids` Tables containing slice ids
27
27
  * - `components` Tables containing slice components
28
28
  */
29
- export declare const contentTypes: readonly ["buffets", "cakes", "layers", "sliceIds", "components", "revisions", "tableCfgs", "history"];
29
+ export declare const contentTypes: readonly ["buffets", "cakes", "layers", "sliceIds", "components", "revisions", "tableCfgs", "insertHistory"];
30
30
  export type ContentType = (typeof contentTypes)[number];
31
31
  /**
32
32
  * An example object using the typedefs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
4
4
  "description": "The RLJSON data format specification",
5
5
  "homepage": "https://github.com/rljson/rljson",
6
6
  "bugs": "https://github.com/rljson/rljson/issues",
@@ -20,24 +20,24 @@
20
20
  ],
21
21
  "type": "module",
22
22
  "devDependencies": {
23
- "@types/node": "^24.9.1",
24
- "@typescript-eslint/eslint-plugin": "^8.46.2",
25
- "@typescript-eslint/parser": "^8.46.2",
26
- "@vitest/coverage-v8": "^4.0.1",
23
+ "@types/node": "^24.10.0",
24
+ "@typescript-eslint/eslint-plugin": "^8.46.3",
25
+ "@typescript-eslint/parser": "^8.46.3",
26
+ "@vitest/coverage-v8": "^4.0.7",
27
27
  "cross-env": "^10.1.0",
28
- "eslint": "^9.38.0",
29
- "eslint-plugin-jsdoc": "^61.1.5",
28
+ "eslint": "^9.39.1",
29
+ "eslint-plugin-jsdoc": "^61.1.12",
30
30
  "eslint-plugin-tsdoc": "^0.4.0",
31
- "globals": "^16.4.0",
31
+ "globals": "^16.5.0",
32
32
  "jsdoc": "^4.0.5",
33
33
  "read-pkg": "^9.0.1",
34
34
  "typescript": "~5.9.3",
35
- "typescript-eslint": "^8.46.2",
36
- "vite": "^7.1.12",
35
+ "typescript-eslint": "^8.46.3",
36
+ "vite": "^7.2.0",
37
37
  "vite-node": "^3.2.4",
38
38
  "vite-plugin-dts": "^4.5.4",
39
39
  "vite-tsconfig-paths": "^5.1.4",
40
- "vitest": "^4.0.1",
40
+ "vitest": "^4.0.7",
41
41
  "vitest-dom": "^0.1.1"
42
42
  },
43
43
  "dependencies": {
@@ -1,24 +0,0 @@
1
- import { TableCfg } from '../content/table-cfg.ts';
2
- import { RljsonTable } from '../rljson.ts';
3
- import { RouteRef } from '../route/route.ts';
4
- import { Ref } from '../typedefs.ts';
5
- export type HistoryTimeId = string;
6
- export type HistoryRow<Str extends string> = {
7
- [key in Str as `${Uncapitalize<string & key>}Ref`]: string;
8
- } & {
9
- timeId: HistoryTimeId;
10
- route: RouteRef;
11
- origin?: Ref;
12
- previous?: HistoryTimeId[];
13
- };
14
- export type History<Str extends string> = RljsonTable<HistoryRow<Str>, 'history'>;
15
- /**
16
- * Creates a TableCfg for a History table for the given table configuration
17
- * @param tableCfg - The table configuration to create the History table for
18
- * @returns The TableCfg for the History table
19
- */
20
- export declare const createHistoryTableCfg: (tableCfg: TableCfg) => TableCfg;
21
- /**
22
- * Provides an example history table for test purposes
23
- */
24
- export declare const exampleHistoryTable: () => History<any>;