@rljson/rljson 0.0.31 → 0.0.32
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/README.architecture.md +119 -54
- package/dist/README.architecture.md +119 -54
- package/dist/content/buffet.d.ts +6 -6
- package/dist/content/cake.d.ts +17 -16
- package/dist/content/ingredients.d.ts +16 -0
- package/dist/content/layer.d.ts +44 -0
- package/dist/content/slice-ids.d.ts +32 -0
- package/dist/content/table-cfg.d.ts +1 -1
- package/dist/example/bakery-example.d.ts +10 -10
- package/dist/example.d.ts +7 -7
- package/dist/index.d.ts +3 -3
- package/dist/rljson.d.ts +6 -6
- package/dist/rljson.js +208 -208
- package/dist/src/example.ts +59 -59
- package/dist/typedefs.d.ts +7 -7
- package/dist/validate/base-validator.d.ts +9 -9
- package/package.json +7 -7
- package/dist/content/collection.d.ts +0 -44
- package/dist/content/id-set.d.ts +0 -33
- package/dist/content/properties.d.ts +0 -16
package/README.architecture.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2025 Rljson
|
|
4
|
+
|
|
5
|
+
Use of this source code is governed by terms that can be
|
|
6
|
+
found in the LICENSE file in the root of this package.
|
|
7
|
+
-->
|
|
8
|
+
|
|
1
9
|
# Rljson Architecture
|
|
2
10
|
|
|
3
11
|
This document describes the architecture of the Rljson format.
|
|
@@ -21,9 +29,9 @@ This document describes the architecture of the Rljson format.
|
|
|
21
29
|
- [Hashes](#hashes)
|
|
22
30
|
- [Linking Tables Using References](#linking-tables-using-references)
|
|
23
31
|
- [Data Types](#data-types)
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
32
|
+
- [Ingredients](#ingredients)
|
|
33
|
+
- [SliceIds](#sliceids)
|
|
34
|
+
- [Layer](#layer)
|
|
27
35
|
- [Cake](#cake)
|
|
28
36
|
- [Buffet](#buffet)
|
|
29
37
|
|
|
@@ -91,7 +99,7 @@ containing the table rows and a `_type` property describing the table type:
|
|
|
91
99
|
```json
|
|
92
100
|
{
|
|
93
101
|
"table0": {
|
|
94
|
-
"_type": "
|
|
102
|
+
"_type": "ingredients",
|
|
95
103
|
"_data": []
|
|
96
104
|
}
|
|
97
105
|
}
|
|
@@ -129,7 +137,7 @@ Rljson uses hashes to identify and reference data. Using the `hash-in-place`
|
|
|
129
137
|
const jsonWithHashes = hip({
|
|
130
138
|
a: {
|
|
131
139
|
_data: [{ a: 10 }],
|
|
132
|
-
_type: '
|
|
140
|
+
_type: 'ingredients',
|
|
133
141
|
},
|
|
134
142
|
});
|
|
135
143
|
```
|
|
@@ -147,7 +155,7 @@ This results in:
|
|
|
147
155
|
}
|
|
148
156
|
],
|
|
149
157
|
"_hash": "FfCIOVQsrK1g5o5_G-AxP4",
|
|
150
|
-
"_type": "
|
|
158
|
+
"_type": "ingredients"
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
```
|
|
@@ -161,7 +169,7 @@ table `b` references table `a` using `aRef`:
|
|
|
161
169
|
{
|
|
162
170
|
"b": {
|
|
163
171
|
"_data": [{ "aRef": "LeFJOCQVgToOfbUuKJQ-GO" }],
|
|
164
|
-
"_type": "
|
|
172
|
+
"_type": "ingredients"
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
```
|
|
@@ -173,96 +181,153 @@ This reference structure enables automated denormalization of JSON data.
|
|
|
173
181
|
Rljson provides several core data structures and table types to manage and
|
|
174
182
|
synchronize large datasets.
|
|
175
183
|
|
|
176
|
-
###
|
|
184
|
+
### Ingredients
|
|
177
185
|
|
|
178
|
-
`
|
|
179
|
-
key-value pairs
|
|
186
|
+
`Ingredients` are the fundamental data concept. An `IngredientsTable` contains
|
|
187
|
+
key-value pairs assigning values to ingredient names.
|
|
180
188
|
|
|
181
189
|
```json
|
|
182
190
|
{
|
|
183
|
-
"
|
|
184
|
-
"_type": "
|
|
191
|
+
"ingredients": {
|
|
192
|
+
"_type": "ingredients",
|
|
193
|
+
"_data": [
|
|
194
|
+
{
|
|
195
|
+
"name": "flour",
|
|
196
|
+
"amountUnit": "g",
|
|
197
|
+
"nutritionalValuesRef": "gZXFSlrl5QAs5hOVsq5sWB"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
"nutritionalValues": {
|
|
203
|
+
"_type": "ingredients",
|
|
185
204
|
"_data": [
|
|
186
|
-
{
|
|
187
|
-
|
|
205
|
+
{
|
|
206
|
+
"energy": 364,
|
|
207
|
+
"fat": 0.98,
|
|
208
|
+
"protein": 10.33,
|
|
209
|
+
"carbohydrates": 76.31,
|
|
210
|
+
"_hash": "gZXFSlrl5QAs5hOVsq5sWB"
|
|
211
|
+
}
|
|
188
212
|
]
|
|
189
213
|
}
|
|
190
214
|
}
|
|
191
215
|
```
|
|
192
216
|
|
|
193
|
-
###
|
|
217
|
+
### SliceIds
|
|
194
218
|
|
|
195
|
-
For efficient management of large
|
|
196
|
-
|
|
197
|
-
following `
|
|
219
|
+
For efficient management of large layers, slice IDs are separated from their
|
|
220
|
+
ingredients. This allows fetching IDs first and retrieving details later. The
|
|
221
|
+
following `SliceIds` define a set of three slice IDs:
|
|
198
222
|
|
|
199
223
|
```json
|
|
200
224
|
{
|
|
201
|
-
"
|
|
202
|
-
|
|
225
|
+
"slices": {
|
|
226
|
+
"_type": "sliceIds",
|
|
227
|
+
"_data": [
|
|
228
|
+
{
|
|
229
|
+
"add": ["slice0", "slice1"],
|
|
230
|
+
"remove": [],
|
|
231
|
+
"_hash": "wyYfK5E4ArrMKQ_zvi2-EE"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
203
235
|
}
|
|
204
236
|
```
|
|
205
237
|
|
|
206
|
-
Derived `
|
|
238
|
+
Derived `SliceIds` can be created by modifying an existing set:
|
|
207
239
|
|
|
208
240
|
```json
|
|
209
241
|
{
|
|
210
|
-
"
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
242
|
+
"slices": {
|
|
243
|
+
"_type": "sliceIds",
|
|
244
|
+
"_data": [
|
|
245
|
+
{
|
|
246
|
+
"add": ["slice0", "slice1"],
|
|
247
|
+
"remove": [],
|
|
248
|
+
"_hash": "wyYfK5E4ArrMKQ_zvi2-EE"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"base": "wyYfK5E4ArrMKQ_zvi2-EE",
|
|
252
|
+
"add": ["slice2"],
|
|
253
|
+
"remove": []
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
214
257
|
}
|
|
215
258
|
```
|
|
216
259
|
|
|
217
|
-
###
|
|
260
|
+
### Layer
|
|
218
261
|
|
|
219
|
-
|
|
220
|
-
properties:
|
|
262
|
+
Cake layers assign ingredients to slices.
|
|
221
263
|
|
|
222
264
|
```json
|
|
223
265
|
{
|
|
224
|
-
"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
266
|
+
"layers": {
|
|
267
|
+
"_type": "layers",
|
|
268
|
+
"_data": [
|
|
269
|
+
{
|
|
270
|
+
"ingredientsTable": "recipes",
|
|
271
|
+
"assign": {
|
|
272
|
+
"slice0": "H8KK9vMjOxxQr_G_9XeDM-",
|
|
273
|
+
"slice1": "H8KK9vMjOxxQr_G_9XeDM-"
|
|
274
|
+
},
|
|
275
|
+
"_hash": "rrFBguLFLhXjrDqAxJx1p-"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
232
279
|
}
|
|
233
280
|
```
|
|
234
281
|
|
|
235
282
|
### Cake
|
|
236
283
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
- All layers share the same item IDs (slice structure).
|
|
241
|
-
- Each layer assigns different properties to the same items.
|
|
284
|
+
A `Cake` consists of layers of slices.
|
|
285
|
+
All layers share the same slice structure, i.e. the same slice ids.
|
|
286
|
+
Each layer assigns different ingredients to slices.
|
|
242
287
|
|
|
243
288
|
```json
|
|
244
289
|
{
|
|
245
|
-
"
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
290
|
+
"cakes": {
|
|
291
|
+
"_type": "cakes",
|
|
292
|
+
"_data": [
|
|
293
|
+
{
|
|
294
|
+
"sliceIdsTable": "slices",
|
|
295
|
+
"idSet": "wyYfK5E4ArrMKQ_zvi2-EE",
|
|
296
|
+
"layersTable": "layers",
|
|
297
|
+
"layers": {
|
|
298
|
+
"flour": "rrFBguLFLhXjrDqAxJx1p-",
|
|
299
|
+
"_hash": "JSoUx1N6lso-18vkzG63Pm"
|
|
300
|
+
},
|
|
301
|
+
"_hash": "bOlQ1lPpZEYB00F14nGvOP"
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
"_hash": "hsL7dD0mFDqmT2i-1fx_1a"
|
|
252
305
|
}
|
|
253
306
|
}
|
|
254
307
|
```
|
|
255
308
|
|
|
256
309
|
### Buffet
|
|
257
310
|
|
|
258
|
-
A `Buffet` is a heterogeneous collection of different but related items,
|
|
259
|
-
cakes,
|
|
311
|
+
A `Buffet` is a heterogeneous collection of different but related items,
|
|
312
|
+
such as cakes, layers, or ingredients:
|
|
260
313
|
|
|
261
314
|
```json
|
|
262
315
|
{
|
|
263
|
-
"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
316
|
+
"buffets": {
|
|
317
|
+
"_type": "buffets",
|
|
318
|
+
"_data": [
|
|
319
|
+
{
|
|
320
|
+
"items": [
|
|
321
|
+
{
|
|
322
|
+
"table": "cakes",
|
|
323
|
+
"ref": "bOlQ1lPpZEYB00F14nGvOP",
|
|
324
|
+
"_hash": "ma47UGAZbu5Ql5yXWFHLAT"
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"_hash": "jPv5bXjs3XVOLRbQvoWcjw"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"_hash": "FYK9ItHMDCe2CnD_TGRs8_"
|
|
331
|
+
}
|
|
267
332
|
}
|
|
268
333
|
```
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@license
|
|
3
|
+
Copyright (c) 2025 Rljson
|
|
4
|
+
|
|
5
|
+
Use of this source code is governed by terms that can be
|
|
6
|
+
found in the LICENSE file in the root of this package.
|
|
7
|
+
-->
|
|
8
|
+
|
|
1
9
|
# Rljson Architecture
|
|
2
10
|
|
|
3
11
|
This document describes the architecture of the Rljson format.
|
|
@@ -21,9 +29,9 @@ This document describes the architecture of the Rljson format.
|
|
|
21
29
|
- [Hashes](#hashes)
|
|
22
30
|
- [Linking Tables Using References](#linking-tables-using-references)
|
|
23
31
|
- [Data Types](#data-types)
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
32
|
+
- [Ingredients](#ingredients)
|
|
33
|
+
- [SliceIds](#sliceids)
|
|
34
|
+
- [Layer](#layer)
|
|
27
35
|
- [Cake](#cake)
|
|
28
36
|
- [Buffet](#buffet)
|
|
29
37
|
|
|
@@ -91,7 +99,7 @@ containing the table rows and a `_type` property describing the table type:
|
|
|
91
99
|
```json
|
|
92
100
|
{
|
|
93
101
|
"table0": {
|
|
94
|
-
"_type": "
|
|
102
|
+
"_type": "ingredients",
|
|
95
103
|
"_data": []
|
|
96
104
|
}
|
|
97
105
|
}
|
|
@@ -129,7 +137,7 @@ Rljson uses hashes to identify and reference data. Using the `hash-in-place`
|
|
|
129
137
|
const jsonWithHashes = hip({
|
|
130
138
|
a: {
|
|
131
139
|
_data: [{ a: 10 }],
|
|
132
|
-
_type: '
|
|
140
|
+
_type: 'ingredients',
|
|
133
141
|
},
|
|
134
142
|
});
|
|
135
143
|
```
|
|
@@ -147,7 +155,7 @@ This results in:
|
|
|
147
155
|
}
|
|
148
156
|
],
|
|
149
157
|
"_hash": "FfCIOVQsrK1g5o5_G-AxP4",
|
|
150
|
-
"_type": "
|
|
158
|
+
"_type": "ingredients"
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
```
|
|
@@ -161,7 +169,7 @@ table `b` references table `a` using `aRef`:
|
|
|
161
169
|
{
|
|
162
170
|
"b": {
|
|
163
171
|
"_data": [{ "aRef": "LeFJOCQVgToOfbUuKJQ-GO" }],
|
|
164
|
-
"_type": "
|
|
172
|
+
"_type": "ingredients"
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
```
|
|
@@ -173,96 +181,153 @@ This reference structure enables automated denormalization of JSON data.
|
|
|
173
181
|
Rljson provides several core data structures and table types to manage and
|
|
174
182
|
synchronize large datasets.
|
|
175
183
|
|
|
176
|
-
###
|
|
184
|
+
### Ingredients
|
|
177
185
|
|
|
178
|
-
`
|
|
179
|
-
key-value pairs
|
|
186
|
+
`Ingredients` are the fundamental data concept. An `IngredientsTable` contains
|
|
187
|
+
key-value pairs assigning values to ingredient names.
|
|
180
188
|
|
|
181
189
|
```json
|
|
182
190
|
{
|
|
183
|
-
"
|
|
184
|
-
"_type": "
|
|
191
|
+
"ingredients": {
|
|
192
|
+
"_type": "ingredients",
|
|
193
|
+
"_data": [
|
|
194
|
+
{
|
|
195
|
+
"name": "flour",
|
|
196
|
+
"amountUnit": "g",
|
|
197
|
+
"nutritionalValuesRef": "gZXFSlrl5QAs5hOVsq5sWB"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
"nutritionalValues": {
|
|
203
|
+
"_type": "ingredients",
|
|
185
204
|
"_data": [
|
|
186
|
-
{
|
|
187
|
-
|
|
205
|
+
{
|
|
206
|
+
"energy": 364,
|
|
207
|
+
"fat": 0.98,
|
|
208
|
+
"protein": 10.33,
|
|
209
|
+
"carbohydrates": 76.31,
|
|
210
|
+
"_hash": "gZXFSlrl5QAs5hOVsq5sWB"
|
|
211
|
+
}
|
|
188
212
|
]
|
|
189
213
|
}
|
|
190
214
|
}
|
|
191
215
|
```
|
|
192
216
|
|
|
193
|
-
###
|
|
217
|
+
### SliceIds
|
|
194
218
|
|
|
195
|
-
For efficient management of large
|
|
196
|
-
|
|
197
|
-
following `
|
|
219
|
+
For efficient management of large layers, slice IDs are separated from their
|
|
220
|
+
ingredients. This allows fetching IDs first and retrieving details later. The
|
|
221
|
+
following `SliceIds` define a set of three slice IDs:
|
|
198
222
|
|
|
199
223
|
```json
|
|
200
224
|
{
|
|
201
|
-
"
|
|
202
|
-
|
|
225
|
+
"slices": {
|
|
226
|
+
"_type": "sliceIds",
|
|
227
|
+
"_data": [
|
|
228
|
+
{
|
|
229
|
+
"add": ["slice0", "slice1"],
|
|
230
|
+
"remove": [],
|
|
231
|
+
"_hash": "wyYfK5E4ArrMKQ_zvi2-EE"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
203
235
|
}
|
|
204
236
|
```
|
|
205
237
|
|
|
206
|
-
Derived `
|
|
238
|
+
Derived `SliceIds` can be created by modifying an existing set:
|
|
207
239
|
|
|
208
240
|
```json
|
|
209
241
|
{
|
|
210
|
-
"
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
242
|
+
"slices": {
|
|
243
|
+
"_type": "sliceIds",
|
|
244
|
+
"_data": [
|
|
245
|
+
{
|
|
246
|
+
"add": ["slice0", "slice1"],
|
|
247
|
+
"remove": [],
|
|
248
|
+
"_hash": "wyYfK5E4ArrMKQ_zvi2-EE"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"base": "wyYfK5E4ArrMKQ_zvi2-EE",
|
|
252
|
+
"add": ["slice2"],
|
|
253
|
+
"remove": []
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
214
257
|
}
|
|
215
258
|
```
|
|
216
259
|
|
|
217
|
-
###
|
|
260
|
+
### Layer
|
|
218
261
|
|
|
219
|
-
|
|
220
|
-
properties:
|
|
262
|
+
Cake layers assign ingredients to slices.
|
|
221
263
|
|
|
222
264
|
```json
|
|
223
265
|
{
|
|
224
|
-
"
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
266
|
+
"layers": {
|
|
267
|
+
"_type": "layers",
|
|
268
|
+
"_data": [
|
|
269
|
+
{
|
|
270
|
+
"ingredientsTable": "recipes",
|
|
271
|
+
"assign": {
|
|
272
|
+
"slice0": "H8KK9vMjOxxQr_G_9XeDM-",
|
|
273
|
+
"slice1": "H8KK9vMjOxxQr_G_9XeDM-"
|
|
274
|
+
},
|
|
275
|
+
"_hash": "rrFBguLFLhXjrDqAxJx1p-"
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
232
279
|
}
|
|
233
280
|
```
|
|
234
281
|
|
|
235
282
|
### Cake
|
|
236
283
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
- All layers share the same item IDs (slice structure).
|
|
241
|
-
- Each layer assigns different properties to the same items.
|
|
284
|
+
A `Cake` consists of layers of slices.
|
|
285
|
+
All layers share the same slice structure, i.e. the same slice ids.
|
|
286
|
+
Each layer assigns different ingredients to slices.
|
|
242
287
|
|
|
243
288
|
```json
|
|
244
289
|
{
|
|
245
|
-
"
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
290
|
+
"cakes": {
|
|
291
|
+
"_type": "cakes",
|
|
292
|
+
"_data": [
|
|
293
|
+
{
|
|
294
|
+
"sliceIdsTable": "slices",
|
|
295
|
+
"idSet": "wyYfK5E4ArrMKQ_zvi2-EE",
|
|
296
|
+
"layersTable": "layers",
|
|
297
|
+
"layers": {
|
|
298
|
+
"flour": "rrFBguLFLhXjrDqAxJx1p-",
|
|
299
|
+
"_hash": "JSoUx1N6lso-18vkzG63Pm"
|
|
300
|
+
},
|
|
301
|
+
"_hash": "bOlQ1lPpZEYB00F14nGvOP"
|
|
302
|
+
}
|
|
303
|
+
],
|
|
304
|
+
"_hash": "hsL7dD0mFDqmT2i-1fx_1a"
|
|
252
305
|
}
|
|
253
306
|
}
|
|
254
307
|
```
|
|
255
308
|
|
|
256
309
|
### Buffet
|
|
257
310
|
|
|
258
|
-
A `Buffet` is a heterogeneous collection of different but related items,
|
|
259
|
-
cakes,
|
|
311
|
+
A `Buffet` is a heterogeneous collection of different but related items,
|
|
312
|
+
such as cakes, layers, or ingredients:
|
|
260
313
|
|
|
261
314
|
```json
|
|
262
315
|
{
|
|
263
|
-
"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
316
|
+
"buffets": {
|
|
317
|
+
"_type": "buffets",
|
|
318
|
+
"_data": [
|
|
319
|
+
{
|
|
320
|
+
"items": [
|
|
321
|
+
{
|
|
322
|
+
"table": "cakes",
|
|
323
|
+
"ref": "bOlQ1lPpZEYB00F14nGvOP",
|
|
324
|
+
"_hash": "ma47UGAZbu5Ql5yXWFHLAT"
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"_hash": "jPv5bXjs3XVOLRbQvoWcjw"
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"_hash": "FYK9ItHMDCe2CnD_TGRs8_"
|
|
331
|
+
}
|
|
267
332
|
}
|
|
268
333
|
```
|
package/dist/content/buffet.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { Json } from '@rljson/json';
|
|
2
2
|
import { RljsonTable } from '../rljson.ts';
|
|
3
|
-
import {
|
|
3
|
+
import { Ref, TableKey } from '../typedefs.ts';
|
|
4
4
|
/**
|
|
5
5
|
* A buffet id is a name or id of a buffet
|
|
6
6
|
*/
|
|
7
|
-
export type BuffetId =
|
|
7
|
+
export type BuffetId = string;
|
|
8
8
|
/**
|
|
9
9
|
* A buffet is a collection of arbitrary but related items, e.g. cakes,
|
|
10
|
-
*
|
|
10
|
+
* layers, or slices.
|
|
11
11
|
*/
|
|
12
12
|
export interface Buffet extends Json {
|
|
13
13
|
/**
|
|
14
|
-
* The
|
|
14
|
+
* The slices of the buffet
|
|
15
15
|
*/
|
|
16
16
|
items: Array<{
|
|
17
17
|
/**
|
|
18
|
-
* The table the
|
|
18
|
+
* The table the slice is taken from
|
|
19
19
|
*/
|
|
20
20
|
table: TableKey;
|
|
21
21
|
/**
|
|
22
|
-
* The hash of the
|
|
22
|
+
* The hash of the slice in the able
|
|
23
23
|
*/
|
|
24
24
|
ref: Ref;
|
|
25
25
|
}>;
|
package/dist/content/cake.d.ts
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { Json } from '@rljson/json';
|
|
2
2
|
import { RljsonTable } from '../rljson.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { TableKey } from '../typedefs.ts';
|
|
4
|
+
import { LayerRef } from './layer.ts';
|
|
5
|
+
import { SliceIdsRef } from './slice-ids.ts';
|
|
6
6
|
/**
|
|
7
7
|
* A `CakeLayerId` assigns an id or name to a cake layer
|
|
8
8
|
*/
|
|
9
|
-
export type CakeLayerId =
|
|
9
|
+
export type CakeLayerId = string;
|
|
10
10
|
/**
|
|
11
11
|
* A cake is a collection of layers.
|
|
12
12
|
*
|
|
13
|
-
* A layer is a collection of
|
|
14
|
-
* All layers of a cake refer to the same
|
|
13
|
+
* A layer is a collection of slices.
|
|
14
|
+
* All layers of a cake refer to the same slices.
|
|
15
15
|
*/
|
|
16
16
|
export interface Cake extends Json {
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
19
|
-
* must match these ids
|
|
18
|
+
* The slice ids of the layer. If present, the slice ids of the cake
|
|
19
|
+
* must match these slice ids of the layers.
|
|
20
|
+
* The slice ids can be found in the idSet table.
|
|
20
21
|
*/
|
|
21
|
-
idSet?:
|
|
22
|
+
idSet?: SliceIdsRef;
|
|
22
23
|
/**
|
|
23
|
-
* The table containing the
|
|
24
|
+
* The table containing the slice ids of the layer
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
sliceIdsTable?: TableKey;
|
|
26
27
|
/**
|
|
27
|
-
* The table containing the
|
|
28
|
+
* The table containing the slice layers defining the layers
|
|
28
29
|
*/
|
|
29
|
-
|
|
30
|
+
layersTable: TableKey;
|
|
30
31
|
/**
|
|
31
|
-
* Assigns a
|
|
32
|
+
* Assigns a layer to each layer of the cake.
|
|
32
33
|
*/
|
|
33
34
|
layers: {
|
|
34
|
-
[layerId: CakeLayerId]:
|
|
35
|
+
[layerId: CakeLayerId]: LayerRef;
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
@@ -39,6 +40,6 @@ export interface Cake extends Json {
|
|
|
39
40
|
*/
|
|
40
41
|
export type CakesTable = RljsonTable<Cake, 'cakes'>;
|
|
41
42
|
/**
|
|
42
|
-
* Provides an example
|
|
43
|
+
* Provides an example cakes table for test purposes
|
|
43
44
|
*/
|
|
44
45
|
export declare const exampleCakesTable: () => CakesTable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Json } from '@rljson/json';
|
|
2
|
+
import { NutritionalValues } from '../example/bakery-example.ts';
|
|
3
|
+
import { RljsonTable } from '../rljson.ts';
|
|
4
|
+
import { Ref } from '../typedefs.ts';
|
|
5
|
+
/**
|
|
6
|
+
* A reference to a ingredients row in a ingredients table
|
|
7
|
+
*/
|
|
8
|
+
export type IngredientsRef = Ref;
|
|
9
|
+
/**
|
|
10
|
+
* A table containing ingredients
|
|
11
|
+
*/
|
|
12
|
+
export type IngredientsTable<T extends Json> = RljsonTable<T, 'ingredients'>;
|
|
13
|
+
/**
|
|
14
|
+
* Provides an example ingredients table for test purposes
|
|
15
|
+
*/
|
|
16
|
+
export declare const exampleIngredientsTable: () => IngredientsTable<NutritionalValues>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Json } from '@rljson/json';
|
|
2
|
+
import { RljsonTable } from '../rljson.ts';
|
|
3
|
+
import { Ref, SliceId, TableKey } from '../typedefs.ts';
|
|
4
|
+
import { IngredientsRef } from './ingredients.ts';
|
|
5
|
+
import { SliceIdsRef } from './slice-ids.ts';
|
|
6
|
+
/**
|
|
7
|
+
* A LayerRef is a hash pointing to a layer
|
|
8
|
+
*/
|
|
9
|
+
export type LayerRef = Ref;
|
|
10
|
+
/**
|
|
11
|
+
* A layer assigns ingredients to item ids
|
|
12
|
+
*/
|
|
13
|
+
export interface Layer extends Json {
|
|
14
|
+
/**
|
|
15
|
+
* `base` an optional base layer that is extended by this layer
|
|
16
|
+
*/
|
|
17
|
+
base?: LayerRef;
|
|
18
|
+
/**
|
|
19
|
+
* The item ids of the layer. If present, the item ids in `assign`
|
|
20
|
+
* must match these ids. The item id sets can be found in the sliceIds table.
|
|
21
|
+
*/
|
|
22
|
+
idSet?: SliceIdsRef;
|
|
23
|
+
/**
|
|
24
|
+
* The table containing the item ids of the layer
|
|
25
|
+
*/
|
|
26
|
+
sliceIdsTable?: TableKey;
|
|
27
|
+
/**
|
|
28
|
+
* The table containing the ingredients that are assigned to the items
|
|
29
|
+
* with the assign property below
|
|
30
|
+
*/
|
|
31
|
+
ingredientsTable: TableKey;
|
|
32
|
+
/**
|
|
33
|
+
* Assign ingredients to each item of the layer.
|
|
34
|
+
*/
|
|
35
|
+
assign: Record<SliceId, IngredientsRef>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A table containing layers
|
|
39
|
+
*/
|
|
40
|
+
export type LayersTable = RljsonTable<Layer, 'layers'>;
|
|
41
|
+
/**
|
|
42
|
+
* Provides an example layersTable for test purposes
|
|
43
|
+
*/
|
|
44
|
+
export declare const exampleLayersTable: () => LayersTable;
|