@rljson/rljson 0.0.36 → 0.0.38
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 +5 -10
- package/dist/content/layer.d.ts +8 -10
- package/dist/index.d.ts +1 -0
- package/dist/rljson.d.ts +10 -1
- package/dist/rljson.js +72 -72
- package/dist/src/example.ts +21 -26
- package/package.json +1 -1
package/dist/content/cake.d.ts
CHANGED
|
@@ -19,16 +19,11 @@ export interface Cake extends Json {
|
|
|
19
19
|
* must match these slice ids of the layers.
|
|
20
20
|
* The slice ids can be found in the idSet table.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A row in table, that contains the slice ids of the layer
|
|
29
|
-
*/
|
|
30
|
-
row: SliceIdsRef;
|
|
31
|
-
};
|
|
22
|
+
sliceIdsTable: TableKey;
|
|
23
|
+
/**
|
|
24
|
+
* A row in table, that contains the slice ids of the layer
|
|
25
|
+
*/
|
|
26
|
+
sliceIdsRow: SliceIdsRef;
|
|
32
27
|
/**
|
|
33
28
|
* The table containing the slice layers defining the layers
|
|
34
29
|
*/
|
package/dist/content/layer.d.ts
CHANGED
|
@@ -15,16 +15,14 @@ export interface Layer extends Json {
|
|
|
15
15
|
* `base` an optional base layer that is extended by this layer
|
|
16
16
|
*/
|
|
17
17
|
base?: LayerRef;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
row: SliceIdsRef;
|
|
27
|
-
};
|
|
18
|
+
/**
|
|
19
|
+
* The table containing the item ids of the layer
|
|
20
|
+
*/
|
|
21
|
+
sliceIdsTable: TableKey;
|
|
22
|
+
/**
|
|
23
|
+
* A row in table, that contains the slice ids of the layer
|
|
24
|
+
*/
|
|
25
|
+
sliceIdsTableRow: SliceIdsRef;
|
|
28
26
|
/**
|
|
29
27
|
* The table containing the ingredients that are assigned to the items
|
|
30
28
|
* with the assign property below
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './content/buffet.ts';
|
|
|
2
2
|
export * from './content/cake.ts';
|
|
3
3
|
export * from './content/ingredients.ts';
|
|
4
4
|
export * from './content/layer.ts';
|
|
5
|
+
export * from './content/revision.ts';
|
|
5
6
|
export * from './content/slice-ids.ts';
|
|
6
7
|
export * from './content/table-cfg.ts';
|
|
7
8
|
export * from './example.ts';
|
package/dist/rljson.d.ts
CHANGED
|
@@ -59,4 +59,13 @@ export interface RljsonTable<Data extends Json, Type extends ContentType> extend
|
|
|
59
59
|
* @param rljson - The Rljson object to iterate
|
|
60
60
|
* @param callback - The callback to call for each table
|
|
61
61
|
*/
|
|
62
|
-
export declare const
|
|
62
|
+
export declare const iterateTablesSync: (rljson: Rljson, callback: (tableKey: string, table: TableType) => void) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Iterates over all tables of an Rljson object.
|
|
65
|
+
* Skips private members starting with _
|
|
66
|
+
* @param rljson - The Rljson object to iterate
|
|
67
|
+
* @param callback - The callback to call for each table
|
|
68
|
+
*
|
|
69
|
+
* Note: The callbacks are executed in parallel.
|
|
70
|
+
*/
|
|
71
|
+
export declare const iterateTables: (rljson: Rljson, callback: (tableKey: string, table: TableType) => Promise<void>) => Promise<void>;
|
package/dist/rljson.js
CHANGED
|
@@ -75,10 +75,8 @@ const bakeryExample = () => {
|
|
|
75
75
|
{
|
|
76
76
|
id: "tastyCake",
|
|
77
77
|
ingredientsTable: "recipeIngredients",
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
row: ingredientTypes._data[0]._hash
|
|
81
|
-
},
|
|
78
|
+
sliceIdsTable: "ingredientTypes",
|
|
79
|
+
sliceIdsTableRow: ingredientTypes._data[0]._hash,
|
|
82
80
|
assign: {
|
|
83
81
|
flour: recipeIngredients._data[0]._hash
|
|
84
82
|
},
|
|
@@ -91,10 +89,8 @@ const bakeryExample = () => {
|
|
|
91
89
|
_data: [
|
|
92
90
|
{
|
|
93
91
|
ingredientsTable: "recipes",
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
row: slices._data[0]._hash
|
|
97
|
-
},
|
|
92
|
+
sliceIdsTable: "slices",
|
|
93
|
+
sliceIdsTableRow: slices._data[0]._hash,
|
|
98
94
|
assign: {
|
|
99
95
|
slice0: recipes._data[0]._hash,
|
|
100
96
|
slice1: recipes._data[0]._hash
|
|
@@ -107,10 +103,8 @@ const bakeryExample = () => {
|
|
|
107
103
|
_data: [
|
|
108
104
|
{
|
|
109
105
|
id: "cake1",
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
row: slices._data[0]._hash
|
|
113
|
-
},
|
|
106
|
+
sliceIdsTable: "slices",
|
|
107
|
+
sliceIdsRow: slices._data[0]._hash,
|
|
114
108
|
layersTable: "layers",
|
|
115
109
|
layers: {
|
|
116
110
|
flour: layers._data[0]._hash
|
|
@@ -154,6 +148,14 @@ const exampleIngredientsTable = () => bakeryExample().nutritionalValues;
|
|
|
154
148
|
// @license
|
|
155
149
|
const exampleLayersTable = () => bakeryExample().layers;
|
|
156
150
|
// @license
|
|
151
|
+
const exampleRevision = () => ({
|
|
152
|
+
table: "nutritionalValues",
|
|
153
|
+
id: "flour",
|
|
154
|
+
predecessor: "gZXFSlrl5QAs5hOVsq5sWB",
|
|
155
|
+
successor: "IqeoWJjZQNlr-NVk2QT15B",
|
|
156
|
+
timestamp: 1743558427
|
|
157
|
+
});
|
|
158
|
+
// @license
|
|
157
159
|
const exampleSliceIdsTable = () => bakeryExample().slices;
|
|
158
160
|
// @license
|
|
159
161
|
const _Example = class _Example {
|
|
@@ -298,10 +300,8 @@ __publicField(_Example, "ok", {
|
|
|
298
300
|
const ingredient0 = ingredients._data[0];
|
|
299
301
|
const ingredient1 = ingredients._data[1];
|
|
300
302
|
const layer0 = hip({
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
row: "MgHRBYSrhpyl4rvsOmAWcQ"
|
|
304
|
-
},
|
|
303
|
+
sliceIdsTable: "sliceIds",
|
|
304
|
+
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
305
305
|
ingredientsTable: "ingredients",
|
|
306
306
|
assign: {
|
|
307
307
|
id0: ingredient0._hash,
|
|
@@ -310,10 +310,8 @@ __publicField(_Example, "ok", {
|
|
|
310
310
|
});
|
|
311
311
|
const layer1 = hip({
|
|
312
312
|
base: layer0._hash,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
row: "MgHRBYSrhpyl4rvsOmAWcQ"
|
|
316
|
-
},
|
|
313
|
+
sliceIdsTable: "sliceIds",
|
|
314
|
+
sliceIdsTableRow: "MgHRBYSrhpyl4rvsOmAWcQ",
|
|
317
315
|
ingredientsTable: "ingredients",
|
|
318
316
|
assign: {
|
|
319
317
|
id0: ingredient0._hash,
|
|
@@ -325,10 +323,8 @@ __publicField(_Example, "ok", {
|
|
|
325
323
|
_data: [layer0, layer1]
|
|
326
324
|
});
|
|
327
325
|
const cake = hip({
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
row: sliceIds._data[0]._hash
|
|
331
|
-
},
|
|
326
|
+
sliceIdsTable: "sliceIds",
|
|
327
|
+
sliceIdsRow: sliceIds._data[0]._hash,
|
|
332
328
|
layersTable: "layers",
|
|
333
329
|
layers: {
|
|
334
330
|
layer0: layer0._hash,
|
|
@@ -452,7 +448,7 @@ __publicField(_Example, "broken", {
|
|
|
452
448
|
missingSliceIdSet: () => {
|
|
453
449
|
const result = _Example.ok.complete();
|
|
454
450
|
const layer1 = result.layers._data[1];
|
|
455
|
-
layer1.
|
|
451
|
+
layer1.sliceIdsTableRow = "MISSING1";
|
|
456
452
|
return hip(result, {
|
|
457
453
|
updateExistingHashes: true,
|
|
458
454
|
throwOnWrongHashes: false
|
|
@@ -475,7 +471,7 @@ __publicField(_Example, "broken", {
|
|
|
475
471
|
cakes: {
|
|
476
472
|
missingSliceIdSet: () => {
|
|
477
473
|
const result = _Example.ok.complete();
|
|
478
|
-
result.cakes._data[0].
|
|
474
|
+
result.cakes._data[0].sliceIdsRow = "MISSING";
|
|
479
475
|
hip(result.cakes, {
|
|
480
476
|
updateExistingHashes: true,
|
|
481
477
|
throwOnWrongHashes: false
|
|
@@ -580,15 +576,36 @@ const reservedTableKeys = [
|
|
|
580
576
|
"revisions"
|
|
581
577
|
];
|
|
582
578
|
const exampleRljson = () => Example.ok.singleRow();
|
|
583
|
-
const
|
|
579
|
+
const _isTable = (value) => {
|
|
580
|
+
return !(typeof value !== "object" || !Array.isArray(value._data));
|
|
581
|
+
};
|
|
582
|
+
const iterateTablesSync = (rljson, callback) => {
|
|
584
583
|
for (const tableKey in rljson) {
|
|
585
584
|
const value = rljson[tableKey];
|
|
586
|
-
if (
|
|
585
|
+
if (!_isTable(value)) {
|
|
587
586
|
continue;
|
|
588
587
|
}
|
|
589
588
|
callback(tableKey, rljson[tableKey]);
|
|
590
589
|
}
|
|
591
590
|
};
|
|
591
|
+
const iterateTables = async (rljson, callback) => {
|
|
592
|
+
const array = [];
|
|
593
|
+
const errors = [];
|
|
594
|
+
for (const tableKey in rljson) {
|
|
595
|
+
const value = rljson[tableKey];
|
|
596
|
+
if (!_isTable(value)) {
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const promise = callback(tableKey, rljson[tableKey]).catch((error) => {
|
|
600
|
+
errors.push({ tableKey, error });
|
|
601
|
+
});
|
|
602
|
+
array.push(promise);
|
|
603
|
+
}
|
|
604
|
+
await Promise.all(array);
|
|
605
|
+
if (errors.length) {
|
|
606
|
+
throw errors;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
592
609
|
// @license
|
|
593
610
|
const contentTypes = [
|
|
594
611
|
"buffets",
|
|
@@ -833,7 +850,7 @@ class _BaseValidator {
|
|
|
833
850
|
_tableCfgNotFound() {
|
|
834
851
|
const tableCfgs = this.rljsonIndexed.tableCfgs;
|
|
835
852
|
const tableCfgNotFound = [];
|
|
836
|
-
|
|
853
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
837
854
|
const tableCfgRef = table._tableCfg;
|
|
838
855
|
if (!tableCfgRef) {
|
|
839
856
|
return;
|
|
@@ -858,7 +875,7 @@ class _BaseValidator {
|
|
|
858
875
|
_missingColumnConfigs() {
|
|
859
876
|
const tableCfgs = this.rljsonIndexed.tableCfgs;
|
|
860
877
|
const missingColumnConfigs = [];
|
|
861
|
-
|
|
878
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
862
879
|
const tableCfgRef = table._tableCfg;
|
|
863
880
|
if (!tableCfgRef) {
|
|
864
881
|
return;
|
|
@@ -897,7 +914,7 @@ class _BaseValidator {
|
|
|
897
914
|
_dataDoesNotMatchColumnConfig() {
|
|
898
915
|
const tableCfgs = this.rljsonIndexed.tableCfgs;
|
|
899
916
|
const brokenValues = [];
|
|
900
|
-
|
|
917
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
901
918
|
const tableCfgRef = table._tableCfg;
|
|
902
919
|
if (!tableCfgRef) {
|
|
903
920
|
return;
|
|
@@ -1074,7 +1091,7 @@ class _BaseValidator {
|
|
|
1074
1091
|
}
|
|
1075
1092
|
_refsNotFound() {
|
|
1076
1093
|
const missingRefs = [];
|
|
1077
|
-
|
|
1094
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1078
1095
|
const tableData = table._data;
|
|
1079
1096
|
for (const item of tableData) {
|
|
1080
1097
|
for (const key of Object.keys(item)) {
|
|
@@ -1118,7 +1135,7 @@ class _BaseValidator {
|
|
|
1118
1135
|
}
|
|
1119
1136
|
_layerBasesNotFound() {
|
|
1120
1137
|
const brokenLayers = [];
|
|
1121
|
-
|
|
1138
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1122
1139
|
if (table._type !== "layers") {
|
|
1123
1140
|
return;
|
|
1124
1141
|
}
|
|
@@ -1148,22 +1165,18 @@ class _BaseValidator {
|
|
|
1148
1165
|
}
|
|
1149
1166
|
_layerSliceIdsTableNotFound() {
|
|
1150
1167
|
const brokenLayers = [];
|
|
1151
|
-
|
|
1168
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1152
1169
|
if (table._type !== "layers") {
|
|
1153
1170
|
return;
|
|
1154
1171
|
}
|
|
1155
1172
|
const layersTable = table;
|
|
1156
1173
|
for (const layer of layersTable._data) {
|
|
1157
|
-
const
|
|
1158
|
-
if (!sliceIds) {
|
|
1159
|
-
continue;
|
|
1160
|
-
}
|
|
1161
|
-
const sliceIdsTable = this.rljsonIndexed[sliceIds.table];
|
|
1174
|
+
const sliceIdsTable = this.rljsonIndexed[layer.sliceIdsTable];
|
|
1162
1175
|
if (!sliceIdsTable) {
|
|
1163
1176
|
brokenLayers.push({
|
|
1164
1177
|
layersTable: tableKey,
|
|
1165
1178
|
layerHash: layer._hash,
|
|
1166
|
-
missingSliceIdsTable:
|
|
1179
|
+
missingSliceIdsTable: layer.sliceIdsTable
|
|
1167
1180
|
});
|
|
1168
1181
|
}
|
|
1169
1182
|
}
|
|
@@ -1177,24 +1190,20 @@ class _BaseValidator {
|
|
|
1177
1190
|
}
|
|
1178
1191
|
_layerSliceIdsRowNotFound() {
|
|
1179
1192
|
const brokenLayers = [];
|
|
1180
|
-
|
|
1193
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1181
1194
|
if (table._type !== "layers") {
|
|
1182
1195
|
return;
|
|
1183
1196
|
}
|
|
1184
1197
|
const layersTable = table;
|
|
1185
1198
|
for (const layer of layersTable._data) {
|
|
1186
|
-
const
|
|
1187
|
-
if (!sliceIds) {
|
|
1188
|
-
continue;
|
|
1189
|
-
}
|
|
1190
|
-
const sliceIdsTableName = sliceIds.table;
|
|
1199
|
+
const sliceIdsTableName = layer.sliceIdsTable;
|
|
1191
1200
|
const sliceIdsTable = this.rljsonIndexed[sliceIdsTableName];
|
|
1192
|
-
const idSet = sliceIdsTable._data[
|
|
1201
|
+
const idSet = sliceIdsTable._data[layer.sliceIdsTableRow];
|
|
1193
1202
|
if (!idSet) {
|
|
1194
1203
|
brokenLayers.push({
|
|
1195
1204
|
layersTable: tableKey,
|
|
1196
1205
|
layerHash: layer._hash,
|
|
1197
|
-
missingSliceIdsRow:
|
|
1206
|
+
missingSliceIdsRow: layer.sliceIdsTableRow
|
|
1198
1207
|
});
|
|
1199
1208
|
}
|
|
1200
1209
|
}
|
|
@@ -1209,7 +1218,7 @@ class _BaseValidator {
|
|
|
1209
1218
|
_layerIngredientAssignmentsNotFound() {
|
|
1210
1219
|
const missingIngredientTables = [];
|
|
1211
1220
|
const brokenAssignments = [];
|
|
1212
|
-
|
|
1221
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1213
1222
|
if (table._type !== "layers") {
|
|
1214
1223
|
return;
|
|
1215
1224
|
}
|
|
@@ -1258,17 +1267,14 @@ class _BaseValidator {
|
|
|
1258
1267
|
}
|
|
1259
1268
|
_layerAssignmentsDoNotMatchSliceIds() {
|
|
1260
1269
|
const layersWithMissingAssignments = [];
|
|
1261
|
-
|
|
1270
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1262
1271
|
if (table._type !== "layers") {
|
|
1263
1272
|
return;
|
|
1264
1273
|
}
|
|
1265
1274
|
const layersTable = table;
|
|
1266
1275
|
for (const layer of layersTable._data) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
}
|
|
1270
|
-
const sliceIdsTable = this.rljsonIndexed[layer.sliceIds.table];
|
|
1271
|
-
const sliceIdsRow = sliceIdsTable._data[layer.sliceIds.row];
|
|
1276
|
+
const sliceIdsTable = this.rljsonIndexed[layer.sliceIdsTable];
|
|
1277
|
+
const sliceIdsRow = sliceIdsTable._data[layer.sliceIdsTableRow];
|
|
1272
1278
|
const sliceIds = sliceIdsRow.add;
|
|
1273
1279
|
const sliceIdsInLayer = Object.keys(layer.assign);
|
|
1274
1280
|
const unassignedSliceIds = [];
|
|
@@ -1296,22 +1302,18 @@ class _BaseValidator {
|
|
|
1296
1302
|
}
|
|
1297
1303
|
_cakeSliceIdsTableNotFound() {
|
|
1298
1304
|
const brokenCakes = [];
|
|
1299
|
-
|
|
1305
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1300
1306
|
if (table._type !== "cakes") {
|
|
1301
1307
|
return;
|
|
1302
1308
|
}
|
|
1303
1309
|
const cakesTable = table;
|
|
1304
1310
|
for (const cake of cakesTable._data) {
|
|
1305
|
-
const
|
|
1306
|
-
if (!sliceIds) {
|
|
1307
|
-
continue;
|
|
1308
|
-
}
|
|
1309
|
-
const sliceIdsTable = this.rljsonIndexed[sliceIds.table];
|
|
1311
|
+
const sliceIdsTable = this.rljsonIndexed[cake.sliceIdsTable];
|
|
1310
1312
|
if (!sliceIdsTable) {
|
|
1311
1313
|
brokenCakes.push({
|
|
1312
1314
|
cakeTable: tableKey,
|
|
1313
1315
|
brokenCake: cake._hash,
|
|
1314
|
-
missingSliceIdsTable:
|
|
1316
|
+
missingSliceIdsTable: cake.sliceIdsTable
|
|
1315
1317
|
});
|
|
1316
1318
|
}
|
|
1317
1319
|
}
|
|
@@ -1325,24 +1327,20 @@ class _BaseValidator {
|
|
|
1325
1327
|
}
|
|
1326
1328
|
_cakeSliceIdsNotFound() {
|
|
1327
1329
|
const brokenCakes = [];
|
|
1328
|
-
|
|
1330
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1329
1331
|
if (table._type !== "cakes") {
|
|
1330
1332
|
return;
|
|
1331
1333
|
}
|
|
1332
1334
|
const cakesTable = table;
|
|
1333
1335
|
for (const cake of cakesTable._data) {
|
|
1334
|
-
const
|
|
1335
|
-
if (!sliceIds) {
|
|
1336
|
-
continue;
|
|
1337
|
-
}
|
|
1338
|
-
const sliceIdsTableName = cake.sliceIds.table;
|
|
1336
|
+
const sliceIdsTableName = cake.sliceIdsTable;
|
|
1339
1337
|
const sliceIdsTable = this.rljsonIndexed[sliceIdsTableName];
|
|
1340
|
-
const sliceIdValues = sliceIdsTable._data[
|
|
1338
|
+
const sliceIdValues = sliceIdsTable._data[cake.sliceIdsRow];
|
|
1341
1339
|
if (!sliceIdValues) {
|
|
1342
1340
|
brokenCakes.push({
|
|
1343
1341
|
cakeTable: tableKey,
|
|
1344
1342
|
brokenCake: cake._hash,
|
|
1345
|
-
missingSliceIdsRow:
|
|
1343
|
+
missingSliceIdsRow: cake.sliceIdsRow
|
|
1346
1344
|
});
|
|
1347
1345
|
}
|
|
1348
1346
|
}
|
|
@@ -1357,7 +1355,7 @@ class _BaseValidator {
|
|
|
1357
1355
|
_cakeLayerTablesNotFound() {
|
|
1358
1356
|
const missingLayerTables = [];
|
|
1359
1357
|
const missingCakeLayers = [];
|
|
1360
|
-
|
|
1358
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1361
1359
|
if (table._type !== "cakes") {
|
|
1362
1360
|
return;
|
|
1363
1361
|
}
|
|
@@ -1407,7 +1405,7 @@ class _BaseValidator {
|
|
|
1407
1405
|
_buffetReferencedTableNotFound() {
|
|
1408
1406
|
const missingTables = [];
|
|
1409
1407
|
const missingItems = [];
|
|
1410
|
-
|
|
1408
|
+
iterateTablesSync(this.rljson, (tableKey, table) => {
|
|
1411
1409
|
if (table._type !== "buffets") {
|
|
1412
1410
|
return;
|
|
1413
1411
|
}
|
|
@@ -1499,6 +1497,7 @@ export {
|
|
|
1499
1497
|
exampleCakesTable,
|
|
1500
1498
|
exampleIngredientsTable,
|
|
1501
1499
|
exampleLayersTable,
|
|
1500
|
+
exampleRevision,
|
|
1502
1501
|
exampleRljson,
|
|
1503
1502
|
exampleSliceIdsTable,
|
|
1504
1503
|
exampleTableCfg,
|
|
@@ -1506,6 +1505,7 @@ export {
|
|
|
1506
1505
|
exampleTypedefs,
|
|
1507
1506
|
isValidFieldName,
|
|
1508
1507
|
iterateTables,
|
|
1508
|
+
iterateTablesSync,
|
|
1509
1509
|
reservedFieldNames,
|
|
1510
1510
|
reservedTableKeys,
|
|
1511
1511
|
rljsonIndexed
|
package/dist/src/example.ts
CHANGED
|
@@ -39,7 +39,7 @@ export class Example {
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
singleRow: (): Rljson => {
|
|
42
|
-
const tableCfgs
|
|
42
|
+
const tableCfgs = hip<TablesCfgTable>({
|
|
43
43
|
_hash: '',
|
|
44
44
|
|
|
45
45
|
_type: 'ingredients',
|
|
@@ -151,7 +151,7 @@ export class Example {
|
|
|
151
151
|
};
|
|
152
152
|
},
|
|
153
153
|
complete: (): Rljson => {
|
|
154
|
-
const sliceIds
|
|
154
|
+
const sliceIds = hip<SliceIdsTable>({
|
|
155
155
|
_type: 'sliceIds',
|
|
156
156
|
_data: [
|
|
157
157
|
{
|
|
@@ -160,18 +160,16 @@ export class Example {
|
|
|
160
160
|
],
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
-
const ingredients
|
|
163
|
+
const ingredients = hip<IngredientsTable<any>>({
|
|
164
164
|
_type: 'ingredients',
|
|
165
165
|
_data: [{ a: '0' }, { a: '1' }],
|
|
166
166
|
});
|
|
167
167
|
const ingredient0 = ingredients._data[0];
|
|
168
168
|
const ingredient1 = ingredients._data[1];
|
|
169
169
|
|
|
170
|
-
const layer0
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
row: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
174
|
-
},
|
|
170
|
+
const layer0 = hip<Layer>({
|
|
171
|
+
sliceIdsTable: 'sliceIds',
|
|
172
|
+
sliceIdsTableRow: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
175
173
|
ingredientsTable: 'ingredients',
|
|
176
174
|
assign: {
|
|
177
175
|
id0: ingredient0._hash,
|
|
@@ -179,12 +177,10 @@ export class Example {
|
|
|
179
177
|
},
|
|
180
178
|
});
|
|
181
179
|
|
|
182
|
-
const layer1
|
|
180
|
+
const layer1 = hip<Layer>({
|
|
183
181
|
base: layer0._hash as string,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
row: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
187
|
-
},
|
|
182
|
+
sliceIdsTable: 'sliceIds',
|
|
183
|
+
sliceIdsTableRow: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
188
184
|
ingredientsTable: 'ingredients',
|
|
189
185
|
assign: {
|
|
190
186
|
id0: ingredient0._hash,
|
|
@@ -192,16 +188,14 @@ export class Example {
|
|
|
192
188
|
},
|
|
193
189
|
});
|
|
194
190
|
|
|
195
|
-
const layers
|
|
191
|
+
const layers = hip<LayersTable>({
|
|
196
192
|
_type: 'layers',
|
|
197
193
|
_data: [layer0, layer1],
|
|
198
194
|
} as LayersTable);
|
|
199
195
|
|
|
200
|
-
const cake
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
row: sliceIds._data[0]._hash as string,
|
|
204
|
-
},
|
|
196
|
+
const cake = hip<Cake>({
|
|
197
|
+
sliceIdsTable: 'sliceIds',
|
|
198
|
+
sliceIdsRow: sliceIds._data[0]._hash as string,
|
|
205
199
|
layersTable: 'layers',
|
|
206
200
|
layers: {
|
|
207
201
|
layer0: layer0._hash as string,
|
|
@@ -209,12 +203,12 @@ export class Example {
|
|
|
209
203
|
},
|
|
210
204
|
});
|
|
211
205
|
|
|
212
|
-
const cakes
|
|
206
|
+
const cakes = hip<CakesTable>({
|
|
213
207
|
_type: 'cakes',
|
|
214
208
|
_data: [cake],
|
|
215
209
|
});
|
|
216
210
|
|
|
217
|
-
const buffets
|
|
211
|
+
const buffets = hip<BuffetsTable>({
|
|
218
212
|
_type: 'buffets',
|
|
219
213
|
_data: [
|
|
220
214
|
{
|
|
@@ -335,9 +329,9 @@ export class Example {
|
|
|
335
329
|
|
|
336
330
|
missingSliceIdSet: (): Rljson => {
|
|
337
331
|
const result = Example.ok.complete();
|
|
338
|
-
const layer1 = result.layers._data[1];
|
|
332
|
+
const layer1 = (result.layers as LayersTable)._data[1];
|
|
339
333
|
|
|
340
|
-
layer1.
|
|
334
|
+
layer1.sliceIdsTableRow = 'MISSING1';
|
|
341
335
|
|
|
342
336
|
// Recalculate hashes
|
|
343
337
|
return hip(result, {
|
|
@@ -365,14 +359,15 @@ export class Example {
|
|
|
365
359
|
cakes: {
|
|
366
360
|
missingSliceIdSet: (): Rljson => {
|
|
367
361
|
const result = Example.ok.complete();
|
|
368
|
-
result.cakes._data[0].
|
|
362
|
+
(result.cakes as CakesTable)._data[0].sliceIdsRow = 'MISSING'; // Missing ID set
|
|
363
|
+
|
|
369
364
|
hip(result.cakes, {
|
|
370
365
|
updateExistingHashes: true,
|
|
371
366
|
throwOnWrongHashes: false,
|
|
372
367
|
});
|
|
373
368
|
|
|
374
|
-
result.buffets._data[0].items[0].ref = result.cakes
|
|
375
|
-
._hash as string; // Update buffet reference
|
|
369
|
+
(result.buffets as BuffetsTable)._data[0].items[0].ref = result.cakes
|
|
370
|
+
._data[0]._hash as string; // Update buffet reference
|
|
376
371
|
|
|
377
372
|
hip(result.buffets, {
|
|
378
373
|
updateExistingHashes: true,
|