@rljson/rljson 0.0.83 → 0.0.84

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.
@@ -504,7 +504,8 @@ objects:
504
504
  - **References**: All `*Ref` columns must point to existing rows
505
505
  - **Trees**: No cycles, all child hashes must resolve, correct node types
506
506
  - **Layers**: Component and SliceId tables must exist
507
- - **Cakes**: Layer tables must exist and share the same slice structure
507
+ - **Cakes**: Layer tables and layers must exist, and every layer must use the
508
+ slice ids table and row of its cake
508
509
  - **Buffets**: Referenced items must exist in their declared tables
509
510
 
510
511
  The `BaseValidator` provides an extensible validator framework — multiple
@@ -504,7 +504,8 @@ objects:
504
504
  - **References**: All `*Ref` columns must point to existing rows
505
505
  - **Trees**: No cycles, all child hashes must resolve, correct node types
506
506
  - **Layers**: Component and SliceId tables must exist
507
- - **Cakes**: Layer tables must exist and share the same slice structure
507
+ - **Cakes**: Layer tables and layers must exist, and every layer must use the
508
+ slice ids table and row of its cake
508
509
  - **Buffets**: Referenced items must exist in their declared tables
509
510
 
510
511
  The `BaseValidator` provides an extensible validator framework — multiple
package/dist/example.d.ts CHANGED
@@ -47,6 +47,7 @@ export declare class Example {
47
47
  missingSliceIdSet: () => Rljson;
48
48
  missingLayersTable: () => Rljson;
49
49
  missingCakeLayer: () => Rljson;
50
+ layerWithOtherSliceIds: () => Rljson;
50
51
  };
51
52
  buffets: {
52
53
  missingTable: () => Rljson;
package/dist/rljson.js CHANGED
@@ -1435,6 +1435,30 @@ var Example = class Example {
1435
1435
  throwOnWrongHashes: false
1436
1436
  });
1437
1437
  return result;
1438
+ },
1439
+ layerWithOtherSliceIds: () => {
1440
+ const result = Example.ok.complete();
1441
+ result.sliceIds._data.push({ add: [
1442
+ "id0",
1443
+ "id1",
1444
+ "id2"
1445
+ ] });
1446
+ hip(result.sliceIds, {
1447
+ updateExistingHashes: true,
1448
+ throwOnWrongHashes: false
1449
+ });
1450
+ const cake = result.cakes._data[0];
1451
+ cake.sliceIdsRow = result.sliceIds._data[1]._hash;
1452
+ hip(result.cakes, {
1453
+ updateExistingHashes: true,
1454
+ throwOnWrongHashes: false
1455
+ });
1456
+ result.buffets._data[0].items[0].ref = cake._hash;
1457
+ hip(result.buffets, {
1458
+ updateExistingHashes: true,
1459
+ throwOnWrongHashes: false
1460
+ });
1461
+ return result;
1438
1462
  }
1439
1463
  },
1440
1464
  buffets: {
@@ -2273,6 +2297,7 @@ var _BaseValidator = class {
2273
2297
  () => this._cakeSliceIdsTableNotFound(),
2274
2298
  () => this._cakeSliceIdsNotFound(),
2275
2299
  () => this._cakeLayerTablesNotFound(),
2300
+ () => this._cakeLayerSliceIdsDoNotMatch(),
2276
2301
  () => this._buffetReferencedTableNotFound()
2277
2302
  ];
2278
2303
  for (const step of steps) {
@@ -2808,6 +2833,33 @@ var _BaseValidator = class {
2808
2833
  brokenCakes: missingCakeLayers
2809
2834
  };
2810
2835
  }
2836
+ _cakeLayerSliceIdsDoNotMatch() {
2837
+ const brokenCakes = [];
2838
+ iterateTablesSync(this.rljson, (tableKey, table) => {
2839
+ if (table._type !== "cakes") return;
2840
+ const cakesTable = table;
2841
+ for (const cake of cakesTable._data) for (const layersTableKey in cake.layers) {
2842
+ if (layersTableKey.startsWith("_")) continue;
2843
+ const layersTable = this.rljsonIndexed[layersTableKey];
2844
+ const layerRef = cake.layers[layersTableKey];
2845
+ const layer = layersTable._data[layerRef];
2846
+ if (layer.sliceIdsTable !== cake.sliceIdsTable || layer.sliceIdsTableRow !== cake.sliceIdsRow) brokenCakes.push({
2847
+ cakeTable: tableKey,
2848
+ brokenCake: cake._hash,
2849
+ layersTable: layersTableKey,
2850
+ brokenLayer: layerRef,
2851
+ cakeSliceIdsTable: cake.sliceIdsTable,
2852
+ cakeSliceIdsRow: cake.sliceIdsRow,
2853
+ layerSliceIdsTable: layer.sliceIdsTable,
2854
+ layerSliceIdsRow: layer.sliceIdsTableRow
2855
+ });
2856
+ }
2857
+ });
2858
+ if (brokenCakes.length > 0) this.errors.cakeLayerSliceIdsDoNotMatch = {
2859
+ error: "Layers of cakes do not use the slice ids of the cake",
2860
+ brokenCakes
2861
+ };
2862
+ }
2811
2863
  _buffetReferencedTableNotFound() {
2812
2864
  const missingTables = [];
2813
2865
  const missingItems = [];
@@ -1,2 +1,2 @@
1
1
  /** The version of the `@rljson/rljson` package. */
2
- export declare const rljsonVersion = "0.0.83";
2
+ export declare const rljsonVersion = "0.0.84";
@@ -17,7 +17,6 @@ import { exampleTreesTable, TreesTable } from './content/tree.ts';
17
17
  import { bakeryExample } from './example/bakery-example.ts';
18
18
  import { Rljson } from './rljson.ts';
19
19
 
20
-
21
20
  export class Example {
22
21
  static readonly ok = {
23
22
  bakery: (): Rljson => bakeryExample(),
@@ -890,6 +889,32 @@ export class Example {
890
889
  });
891
890
  return result;
892
891
  },
892
+
893
+ layerWithOtherSliceIds: (): Rljson => {
894
+ const result = Example.ok.complete();
895
+
896
+ // Let the cake use another row of slice ids than its layers
897
+ result.sliceIds._data.push({ add: ['id0', 'id1', 'id2'] });
898
+ hip(result.sliceIds, {
899
+ updateExistingHashes: true,
900
+ throwOnWrongHashes: false,
901
+ });
902
+
903
+ const cake = result.cakes._data[0];
904
+ cake.sliceIdsRow = result.sliceIds._data[1]._hash;
905
+ hip(result.cakes, {
906
+ updateExistingHashes: true,
907
+ throwOnWrongHashes: false,
908
+ });
909
+
910
+ // Let the buffet refer to the changed cake
911
+ result.buffets._data[0].items[0].ref = cake._hash;
912
+ hip(result.buffets, {
913
+ updateExistingHashes: true,
914
+ throwOnWrongHashes: false,
915
+ });
916
+ return result;
917
+ },
893
918
  },
894
919
 
895
920
  buffets: {
@@ -32,6 +32,7 @@ export interface BaseErrors extends Errors {
32
32
  cakeSliceIdsNotFound?: Json;
33
33
  cakeLayerTablesNotFound?: Json;
34
34
  cakeLayersNotFound?: Json;
35
+ cakeLayerSliceIdsDoNotMatch?: Json;
35
36
  buffetReferencedTablesNotFound?: Json;
36
37
  buffetReferencedItemsNotFound?: Json;
37
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.83",
3
+ "version": "0.0.84",
4
4
  "packageManager": "pnpm@11.10.0+sha512.0b7f8b98060031904c017e3a41eb187a16d40eeb829b95c4f8cb03681761fc4ab53dd219115b9b447f4dce1a05a214764461e7d3703392a9f32f9511ce8c86c8",
5
5
  "description": "The RLJSON data format specification",
6
6
  "homepage": "https://github.com/rljson/rljson",