@rljson/rljson 0.0.14 → 0.0.15

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 CHANGED
@@ -10,16 +10,21 @@ export declare class Example {
10
10
  complete: () => Rljson;
11
11
  };
12
12
  static readonly broken: {
13
- brokenTableName: () => {
14
- brok$en: {
15
- _type: string;
16
- _data: never[];
13
+ base: {
14
+ brokenTableName: () => {
15
+ brok$en: {
16
+ _type: string;
17
+ _data: never[];
18
+ };
17
19
  };
20
+ missingData: () => Rljson;
21
+ dataNotBeingAnArray: () => Rljson;
22
+ missingRef: () => Rljson;
23
+ missingReferencedTable: () => Rljson;
24
+ };
25
+ tableCfg: {
26
+ wrongType: () => import('@rljson/hash').Hashed<Rljson>;
18
27
  };
19
- missingData: () => Rljson;
20
- dataNotBeingAnArray: () => Rljson;
21
- missingRef: () => Rljson;
22
- missingReferencedTable: () => Rljson;
23
28
  collections: {
24
29
  missingBase: () => Rljson;
25
30
  missingIdSet: () => Rljson;
package/dist/rljson.d.ts CHANGED
@@ -4,6 +4,7 @@ import { CakesTable } from './content/cake.ts';
4
4
  import { CollectionsTable } from './content/collection.ts';
5
5
  import { IdSetsTable } from './content/id-set.ts';
6
6
  import { PropertiesTable } from './content/properties.ts';
7
+ import { TableCfgRef, TablesCfgTable } from './content/table-cfg.ts';
7
8
  import { ContentType, Ref, TableName } from './typedefs.ts';
8
9
  export declare const reservedFieldNames: string[];
9
10
  export declare const reservedTableNames: string[];
@@ -19,15 +20,26 @@ export interface Rljson extends Json {
19
20
  * Rljson set with private fields
20
21
  */
21
22
  export type RljsonPrivate = {
23
+ /**
24
+ * The hash of the Rljson object
25
+ */
26
+ _hash: string;
22
27
  /**
23
28
  * Contains id sets used accross the Rljson object
24
29
  */
25
- _idSets: IdSetsTable;
30
+ _idSet?: IdSetsTable;
31
+ /**
32
+ * References that are not part of the Rljson object
33
+ */
34
+ _externalRefs?: Ref[];
35
+ /**
36
+ * Referenced tables that are not part of the Rljson object
37
+ */
38
+ _externalTables?: Ref[];
26
39
  /**
27
- * Used by validation. If external references are not present,
28
- * validation does not throw an error.
40
+ * Column configurations used accross the Rljson object
29
41
  */
30
- _externalRefs: Ref[];
42
+ _tableCfgs?: TablesCfgTable;
31
43
  };
32
44
  /** An example rljson object */
33
45
  export declare const exampleRljson: () => Rljson;
@@ -37,6 +49,8 @@ export interface RljsonTable<Data extends Json, Type extends ContentType> extend
37
49
  _data: Data[];
38
50
  /** The type of the table. If not set, the type is "properties" */
39
51
  _type: Type;
52
+ /** The columns configuration of the table */
53
+ _tableCfg?: TableCfgRef;
40
54
  }
41
55
  /**
42
56
  * Iterates over all tables of an Rljson object.
package/dist/rljson.js CHANGED
@@ -5,96 +5,89 @@ import { hip, hsh } from "@rljson/hash";
5
5
  import { exampleJsonObject } from "@rljson/json";
6
6
  // @license
7
7
  const bakeryExample = () => {
8
- return {
9
- // Every rljson object has a list of id-sets other objects can refer to
8
+ const result = {
10
9
  _idSets: {
11
10
  _type: "idSets",
12
11
  _data: [
13
12
  {
14
13
  add: ["slice0", "slice1"],
15
- _hash: "KAwCRFD4mdx8b1bzxBb2_O"
14
+ _hash: "Ko990SJfgPJvNGxC63CRf7"
16
15
  }
17
- ]
16
+ ],
17
+ _hash: "NiojsJvZ7iEU7WeMWttzyJ"
18
18
  },
19
- // A bakery offers a variety of buffets containing different pastries
20
19
  buffets: {
21
20
  _type: "buffets",
22
21
  _data: [
23
22
  {
24
- items: [{ table: "cakes", ref: "fw8IrV05Z1ZekPXTdUdmt8" }]
23
+ items: [
24
+ {
25
+ table: "cakes",
26
+ ref: "KdLv3zTftqKKUeqYrTtO2r"
27
+ }
28
+ ]
25
29
  }
26
30
  ]
27
31
  },
28
- // A cake is a collection of layers, i.e. a base, a filling and a topping.
29
- // Each layer of the cake has the same slice structure.
30
32
  cakes: {
31
33
  _type: "cakes",
32
34
  _data: [
33
35
  {
34
- idSet: "KAwCRFD4mdx8b1bzxBb2_O",
36
+ idSet: "Ko990SJfgPJvNGxC63CRf7",
35
37
  collections: "layers",
36
38
  layers: {
37
- _hash: "50ZHxZ8KeUYJ3NC7ax5CbR"
39
+ _hash: "RBNvo1WzZ4oRRq0W9-hknp"
38
40
  },
39
- _hash: "gMqFPTkYU66L32jDYZiZ79"
41
+ _hash: "KdLv3zTftqKKUeqYrTtO2r"
40
42
  }
41
- ],
42
- _hash: "fw8IrV05Z1ZekPXTdUdmt8"
43
+ ]
43
44
  },
44
- // Cakes are cut into slices. The cake layers are shared among the slices.
45
45
  slices: {
46
46
  _type: "idSets",
47
47
  _data: [
48
48
  {
49
49
  add: ["slice0", "slice1"],
50
- remove: []
50
+ remove: [],
51
+ _hash: "wyYfK5E4ArrMKQ_zvi2-EE"
51
52
  }
52
- ]
53
+ ],
54
+ _hash: "Qt6FzyzwHdEdYC3fKUXaAm"
53
55
  },
54
- // A layer is a collection of ingredients described by a recipe
55
56
  layers: {
56
57
  _type: "collections",
57
58
  _data: [
58
59
  {
59
60
  properties: "recipes",
60
61
  assign: {
61
- slice0: "VXUW79JrkOAG_pQ-75ahH5",
62
- slice1: "VXUW79JrkOAG_pQ-75ahH5",
63
- _hash: "Di4uG3-DHSq3_ArFu0V68m"
64
- },
65
- _hash: "IIg0e-6Qr73s7sNZe0RhKs"
62
+ slice0: "uRTo_Jmt9lOA09e2QnwB9W",
63
+ slice1: "uRTo_Jmt9lOA09e2QnwB9W"
64
+ }
66
65
  }
67
- ],
68
- _hash: "e3utfEf_VS1-ljAMgqesua"
66
+ ]
69
67
  },
70
- // Recipes are sets of ingredients
71
68
  recipes: {
72
69
  _type: "collections",
73
70
  _data: [
74
71
  {
75
72
  properties: "recipeIngredients",
76
73
  assign: {
77
- flour: "mqLl7Q44V1t2MotJvaVRM_",
78
- _hash: "UImWlyWZTSGhNAMC1JUzF1"
74
+ flour: "RCA4yzQe6mYOqquoLijKop"
79
75
  },
80
- _hash: "G1YV_P8-_vTxtkXXHJeNBI"
76
+ _hash: "uRTo_Jmt9lOA09e2QnwB9W"
81
77
  }
82
- ],
83
- _hash: "r3lw7VsnywyasRmtynZqIt"
78
+ ]
84
79
  },
85
- // A recipe ingredient combines an ingredient type with a quantity
86
80
  recipeIngredients: {
87
81
  _type: "properties",
88
82
  _data: [
89
83
  {
90
- ingredientTypesRef: "WOfnFT1svec3iJ6x",
84
+ ingredientsRef: "CdSJV-WOfnFT1svec3iJ6x",
91
85
  quantity: 500,
92
- _hash: "mqLl7Q44V1t2MotJvaVRM_"
86
+ _hash: "RCA4yzQe6mYOqquoLijKop"
93
87
  }
94
88
  ],
95
- _hash: "J7GJEjCRXLNfdAHARg_fzx"
89
+ _hash: "R6dJq4ZJ3QDa9Bz8QJDhNq"
96
90
  },
97
- // A table describing basic properties of ingredients
98
91
  ingredients: {
99
92
  _type: "properties",
100
93
  _data: [
@@ -107,7 +100,6 @@ const bakeryExample = () => {
107
100
  ],
108
101
  _hash: "FgJeTM0NcZvXwFcU-PD8Jf"
109
102
  },
110
- // A table with nutritive values of ingredients
111
103
  nutritiveValues: {
112
104
  _type: "properties",
113
105
  _data: [
@@ -122,6 +114,7 @@ const bakeryExample = () => {
122
114
  _hash: "7k4OqQtk71w3yVGMoA9F6p"
123
115
  }
124
116
  };
117
+ return result;
125
118
  };
126
119
  // @license
127
120
  const exampleBuffetsTable = () => bakeryExample().buffets;
@@ -155,12 +148,77 @@ __publicField(_Example, "ok", {
155
148
  };
156
149
  },
157
150
  singleRow: () => {
158
- return {
151
+ const tableCfgs = {
152
+ _hash: "",
153
+ _type: "properties",
154
+ _data: [
155
+ {
156
+ _hash: "R-rCQ4YwYYJAp6uAo6S_6n",
157
+ name: "Single Row Table",
158
+ jsonKey: "table",
159
+ columns: {
160
+ int: {
161
+ jsonKey: "int",
162
+ type: "number",
163
+ name: "Integer",
164
+ nameShort: "Int"
165
+ },
166
+ double: {
167
+ jsonKey: "double",
168
+ type: "number",
169
+ name: "Double",
170
+ nameShort: "Dbl"
171
+ },
172
+ string: {
173
+ jsonKey: "string",
174
+ type: "string",
175
+ name: "String",
176
+ nameShort: "Str"
177
+ },
178
+ boolean: {
179
+ jsonKey: "boolean",
180
+ type: "boolean",
181
+ name: "Boolean",
182
+ nameShort: "Bool"
183
+ },
184
+ null: {
185
+ jsonKey: "null",
186
+ type: "null",
187
+ name: "null",
188
+ nameShort: "null"
189
+ },
190
+ jsonArray: {
191
+ jsonKey: "jsonArray",
192
+ type: "jsonArray",
193
+ name: "Json Array",
194
+ nameShort: "Jarray"
195
+ },
196
+ json: {
197
+ jsonKey: "json",
198
+ type: "json",
199
+ name: "Json",
200
+ nameShort: "Json"
201
+ },
202
+ jsonValue: {
203
+ jsonKey: "jsonValue",
204
+ type: "jsonValue",
205
+ name: "Json Value",
206
+ nameShort: "Jval"
207
+ }
208
+ }
209
+ }
210
+ ]
211
+ };
212
+ const result = {
213
+ _tableCfgs: tableCfgs,
159
214
  table: {
160
215
  _type: "properties",
161
- _data: [exampleJsonObject()]
216
+ _tableCfg: "R-rCQ4YwYYJAp6uAo6S_6n",
217
+ _data: [exampleJsonObject()],
218
+ _hash: ""
162
219
  }
163
220
  };
221
+ return result;
164
222
  },
165
223
  multipleRows: () => {
166
224
  return {
@@ -289,65 +347,75 @@ __publicField(_Example, "ok", {
289
347
  }
290
348
  });
291
349
  __publicField(_Example, "broken", {
292
- brokenTableName: () => {
293
- return {
294
- brok$en: {
295
- _type: "properties",
296
- _data: []
297
- }
298
- };
299
- },
300
- missingData: () => {
301
- return {
302
- table: {
303
- _type: "properties"
304
- }
305
- };
306
- },
307
- dataNotBeingAnArray: () => {
308
- return {
309
- table: {
310
- _type: "properties",
311
- _data: {}
312
- }
313
- };
314
- },
315
- missingRef: () => {
316
- return {
317
- tableA: {
318
- _type: "properties",
319
- _data: [
320
- {
321
- keyA0: "a0"
322
- },
323
- {
324
- keyA1: "a1"
325
- }
326
- ]
327
- },
328
- tableB: {
329
- _type: "properties",
330
- _data: [
331
- {
332
- tableARef: "MISSINGREF"
333
- // MISSINGREF does not exist in tableA
334
- }
335
- ]
336
- }
337
- };
350
+ base: {
351
+ brokenTableName: () => {
352
+ return {
353
+ brok$en: {
354
+ _type: "properties",
355
+ _data: []
356
+ }
357
+ };
358
+ },
359
+ missingData: () => {
360
+ return {
361
+ table: {
362
+ _type: "properties"
363
+ }
364
+ };
365
+ },
366
+ dataNotBeingAnArray: () => {
367
+ return {
368
+ table: {
369
+ _type: "properties",
370
+ _data: {}
371
+ }
372
+ };
373
+ },
374
+ missingRef: () => {
375
+ return {
376
+ tableA: {
377
+ _type: "properties",
378
+ _data: [
379
+ {
380
+ keyA0: "a0"
381
+ },
382
+ {
383
+ keyA1: "a1"
384
+ }
385
+ ]
386
+ },
387
+ tableB: {
388
+ _type: "properties",
389
+ _data: [
390
+ {
391
+ tableARef: "MISSINGREF"
392
+ // MISSINGREF does not exist in tableA
393
+ }
394
+ ]
395
+ }
396
+ };
397
+ },
398
+ missingReferencedTable: () => {
399
+ return {
400
+ tableB: {
401
+ _type: "properties",
402
+ _data: [
403
+ {
404
+ tableARef: "MISSINGREF"
405
+ // tableA is missing
406
+ }
407
+ ]
408
+ }
409
+ };
410
+ }
338
411
  },
339
- missingReferencedTable: () => {
340
- return {
341
- tableB: {
342
- _type: "properties",
343
- _data: [
344
- {
345
- tableARef: "MISSINGREF"
346
- // tableA is missing
347
- }
348
- ]
349
- }
350
- };
412
+ tableCfg: {
413
+ wrongType: () => {
414
+ const result = _Example.ok.singleRow();
415
+ const tableCfg = result._tableCfgs._data[0];
416
+ tableCfg.columns["int"].type = "numberBroken";
417
+ return hip(result, true, false);
418
+ }
351
419
  },
352
420
  collections: {
353
421
  missingBase: () => {
@@ -7,6 +7,7 @@
7
7
  import { hip } from '@rljson/hash';
8
8
  import { exampleJsonObject } from '@rljson/json';
9
9
 
10
+ import { TablesCfgTable } from './content/table-cfg.ts';
10
11
  import { bakeryExample } from './example/bakery-example.ts';
11
12
  import { Rljson } from './rljson.ts';
12
13
 
@@ -33,12 +34,78 @@ export class Example {
33
34
  },
34
35
 
35
36
  singleRow: (): Rljson => {
36
- return {
37
+ const tableCfgs: TablesCfgTable = {
38
+ _hash: '',
39
+ _type: 'properties',
40
+ _data: [
41
+ {
42
+ _hash: 'R-rCQ4YwYYJAp6uAo6S_6n',
43
+ name: 'Single Row Table',
44
+ jsonKey: 'table',
45
+ columns: {
46
+ int: {
47
+ jsonKey: 'int',
48
+ type: 'number',
49
+ name: 'Integer',
50
+ nameShort: 'Int',
51
+ },
52
+ double: {
53
+ jsonKey: 'double',
54
+ type: 'number',
55
+ name: 'Double',
56
+ nameShort: 'Dbl',
57
+ },
58
+ string: {
59
+ jsonKey: 'string',
60
+ type: 'string',
61
+ name: 'String',
62
+ nameShort: 'Str',
63
+ },
64
+ boolean: {
65
+ jsonKey: 'boolean',
66
+ type: 'boolean',
67
+ name: 'Boolean',
68
+ nameShort: 'Bool',
69
+ },
70
+ null: {
71
+ jsonKey: 'null',
72
+ type: 'null',
73
+ name: 'null',
74
+ nameShort: 'null',
75
+ },
76
+ jsonArray: {
77
+ jsonKey: 'jsonArray',
78
+ type: 'jsonArray',
79
+ name: 'Json Array',
80
+ nameShort: 'Jarray',
81
+ },
82
+ json: {
83
+ jsonKey: 'json',
84
+ type: 'json',
85
+ name: 'Json',
86
+ nameShort: 'Json',
87
+ },
88
+ jsonValue: {
89
+ jsonKey: 'jsonValue',
90
+ type: 'jsonValue',
91
+ name: 'Json Value',
92
+ nameShort: 'Jval',
93
+ },
94
+ },
95
+ },
96
+ ],
97
+ };
98
+
99
+ const result: Rljson = {
100
+ _tableCfgs: tableCfgs,
37
101
  table: {
38
102
  _type: 'properties',
103
+ _tableCfg: 'R-rCQ4YwYYJAp6uAo6S_6n',
39
104
  _data: [exampleJsonObject()],
105
+ _hash: '',
40
106
  },
41
107
  };
108
+ return result as Rljson;
42
109
  },
43
110
 
44
111
  multipleRows: (): Rljson => {
@@ -177,67 +244,78 @@ export class Example {
177
244
  };
178
245
 
179
246
  static readonly broken = {
180
- brokenTableName: () => {
181
- return {
182
- brok$en: {
183
- _type: 'properties',
184
- _data: [],
185
- },
186
- };
187
- },
247
+ base: {
248
+ brokenTableName: () => {
249
+ return {
250
+ brok$en: {
251
+ _type: 'properties',
252
+ _data: [],
253
+ },
254
+ };
255
+ },
188
256
 
189
- missingData: () => {
190
- return {
191
- table: {
192
- _type: 'properties',
193
- },
194
- } as unknown as Rljson;
195
- },
257
+ missingData: () => {
258
+ return {
259
+ table: {
260
+ _type: 'properties',
261
+ },
262
+ } as unknown as Rljson;
263
+ },
196
264
 
197
- dataNotBeingAnArray: () => {
198
- return {
199
- table: {
200
- _type: 'properties',
201
- _data: {},
202
- },
203
- } as unknown as Rljson;
204
- },
265
+ dataNotBeingAnArray: () => {
266
+ return {
267
+ table: {
268
+ _type: 'properties',
269
+ _data: {},
270
+ },
271
+ } as unknown as Rljson;
272
+ },
205
273
 
206
- missingRef: (): Rljson => {
207
- return {
208
- tableA: {
209
- _type: 'properties',
210
- _data: [
211
- {
212
- keyA0: 'a0',
213
- },
214
- {
215
- keyA1: 'a1',
216
- },
217
- ],
218
- },
219
- tableB: {
220
- _type: 'properties',
221
- _data: [
222
- {
223
- tableARef: 'MISSINGREF', // MISSINGREF does not exist in tableA
224
- },
225
- ],
226
- },
227
- };
274
+ missingRef: (): Rljson => {
275
+ return {
276
+ tableA: {
277
+ _type: 'properties',
278
+ _data: [
279
+ {
280
+ keyA0: 'a0',
281
+ },
282
+ {
283
+ keyA1: 'a1',
284
+ },
285
+ ],
286
+ },
287
+ tableB: {
288
+ _type: 'properties',
289
+ _data: [
290
+ {
291
+ tableARef: 'MISSINGREF', // MISSINGREF does not exist in tableA
292
+ },
293
+ ],
294
+ },
295
+ };
296
+ },
297
+
298
+ missingReferencedTable: (): Rljson => {
299
+ return {
300
+ tableB: {
301
+ _type: 'properties',
302
+ _data: [
303
+ {
304
+ tableARef: 'MISSINGREF', // tableA is missing
305
+ },
306
+ ],
307
+ },
308
+ };
309
+ },
228
310
  },
229
311
 
230
- missingReferencedTable: (): Rljson => {
231
- return {
232
- tableB: {
233
- _type: 'properties',
234
- _data: [
235
- {
236
- tableARef: 'MISSINGREF', // tableA is missing
237
- },
238
- ],
239
- },
240
- };
312
+ tableCfg: {
313
+ wrongType: () => {
314
+ const result = Example.ok.singleRow();
315
+ const tableCfg = result._tableCfgs._data[0];
316
+ tableCfg.columns['int'].type = 'numberBroken'; // Break one of the types
317
+ return hip(result, true, false);
318
+ },
241
319
  },
242
320
 
243
321
  collections: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "packageManager": "pnpm@10.6.3",
5
5
  "description": "The RLJSON data format specification",
6
6
  "homepage": "https://github.com/rljson/rljson",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@rljson/hash": "^0.0.12",
54
- "@rljson/json": "^0.0.15"
54
+ "@rljson/json": "^0.0.18"
55
55
  },
56
56
  "pnpm": {
57
57
  "onlyBuiltDependencies": [