@rljson/rljson 0.0.11 → 0.0.14
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.contributors.md +106 -49
- package/dist/README.contributors.md +106 -49
- package/dist/example.d.ts +39 -4
- package/dist/index.d.ts +8 -0
- package/dist/rljson-indexed.d.ts +19 -0
- package/dist/rljson.d.ts +35 -160
- package/dist/rljson.js +464 -50
- package/dist/src/example.ts +314 -12
- package/dist/typedefs.d.ts +33 -0
- package/package.json +9 -9
package/dist/src/example.ts
CHANGED
|
@@ -4,15 +4,317 @@
|
|
|
4
4
|
// Use of this source code is governed by terms that can be
|
|
5
5
|
// found in the LICENSE file in the root of this package.
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
7
|
+
import { hip } from '@rljson/hash';
|
|
8
|
+
import { exampleJsonObject } from '@rljson/json';
|
|
9
|
+
|
|
10
|
+
import { bakeryExample } from './example/bakery-example.ts';
|
|
11
|
+
import { Rljson } from './rljson.ts';
|
|
12
|
+
|
|
13
|
+
export class Example {
|
|
14
|
+
static readonly ok = {
|
|
15
|
+
bakery: (): Rljson => bakeryExample(),
|
|
16
|
+
|
|
17
|
+
empty: (): Rljson => {
|
|
18
|
+
return {};
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
binary: (): Rljson => {
|
|
22
|
+
return {
|
|
23
|
+
table: {
|
|
24
|
+
_type: 'properties',
|
|
25
|
+
_data: [
|
|
26
|
+
{ a: false, b: false },
|
|
27
|
+
{ a: false, b: true },
|
|
28
|
+
{ a: true, b: false },
|
|
29
|
+
{ a: true, b: true },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
singleRow: (): Rljson => {
|
|
36
|
+
return {
|
|
37
|
+
table: {
|
|
38
|
+
_type: 'properties',
|
|
39
|
+
_data: [exampleJsonObject()],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
multipleRows: (): Rljson => {
|
|
45
|
+
return {
|
|
46
|
+
table: {
|
|
47
|
+
_type: 'properties',
|
|
48
|
+
_data: [
|
|
49
|
+
{
|
|
50
|
+
string: 'str0',
|
|
51
|
+
boolean: true,
|
|
52
|
+
number: 1,
|
|
53
|
+
array: [1, 'str0', true, { a: { b: 'c' } }],
|
|
54
|
+
object: { a: { b: 'c' } },
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
string: 'str1',
|
|
59
|
+
boolean: true,
|
|
60
|
+
number: 1,
|
|
61
|
+
array: [1, 'str1', true, { a: { b: 'c' } }],
|
|
62
|
+
object: { a: { b: 'c' } },
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
string: 'str2',
|
|
67
|
+
boolean: false,
|
|
68
|
+
number: 1,
|
|
69
|
+
array: [1, 'str1', true, { a: { b: 'c' } }],
|
|
70
|
+
object: { d: { e: 'f' } },
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
singleRef: (): Rljson => {
|
|
78
|
+
return {
|
|
79
|
+
tableA: {
|
|
80
|
+
_type: 'properties',
|
|
81
|
+
_data: [
|
|
82
|
+
{
|
|
83
|
+
keyA0: 'a0',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
keyA1: 'a1',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
tableB: {
|
|
91
|
+
_type: 'properties',
|
|
92
|
+
_data: [
|
|
93
|
+
{
|
|
94
|
+
tableARef: 'KFQrf4mEz0UPmUaFHwH4T6',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
complete: (): Rljson => {
|
|
101
|
+
return {
|
|
102
|
+
_idSets: {
|
|
103
|
+
_type: 'idSets',
|
|
104
|
+
|
|
105
|
+
_data: [
|
|
106
|
+
{
|
|
107
|
+
add: ['id0', 'id1'],
|
|
108
|
+
_hash: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
properties: {
|
|
114
|
+
_type: 'properties',
|
|
115
|
+
_data: [
|
|
116
|
+
{ a: '0', _hash: 'AFhW-fMzdCiz6bUZscp1Lf' },
|
|
117
|
+
{ a: '1', _hash: 'mv6w8rID8lQxLsje1EHQMY' },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
collections: {
|
|
122
|
+
_type: 'collections',
|
|
123
|
+
_data: [
|
|
124
|
+
{
|
|
125
|
+
idSet: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
126
|
+
properties: 'properties',
|
|
127
|
+
_hash: 'sxv2NCM6UNOcX-i9FhOs5W',
|
|
128
|
+
assign: {},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
base: 'sxv2NCM6UNOcX-i9FhOs5W',
|
|
132
|
+
idSet: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
133
|
+
properties: 'properties',
|
|
134
|
+
assign: {
|
|
135
|
+
id0: 'AFhW-fMzdCiz6bUZscp1Lf',
|
|
136
|
+
id1: 'mv6w8rID8lQxLsje1EHQMY',
|
|
137
|
+
},
|
|
138
|
+
_hash: 'QB2JC6X_-rUAoixuldzWP-',
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
cakes: {
|
|
144
|
+
_type: 'cakes',
|
|
145
|
+
_data: [
|
|
146
|
+
{
|
|
147
|
+
idSet: 'MgHRBYSrhpyl4rvsOmAWcQ',
|
|
148
|
+
collections: 'collections',
|
|
149
|
+
layers: {
|
|
150
|
+
layer0: 'sxv2NCM6UNOcX-i9FhOs5W',
|
|
151
|
+
layer1: 'QB2JC6X_-rUAoixuldzWP-',
|
|
152
|
+
},
|
|
153
|
+
_hash: 'QlTVJL3uoXO1L_fw2evLPe',
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
buffets: {
|
|
159
|
+
_type: 'buffets',
|
|
160
|
+
_data: [
|
|
161
|
+
{
|
|
162
|
+
items: [
|
|
163
|
+
{
|
|
164
|
+
table: 'cakes',
|
|
165
|
+
ref: 'QlTVJL3uoXO1L_fw2evLPe',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
table: 'collections',
|
|
169
|
+
ref: 'QB2JC6X_-rUAoixuldzWP-',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
static readonly broken = {
|
|
180
|
+
brokenTableName: () => {
|
|
181
|
+
return {
|
|
182
|
+
brok$en: {
|
|
183
|
+
_type: 'properties',
|
|
184
|
+
_data: [],
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
missingData: () => {
|
|
190
|
+
return {
|
|
191
|
+
table: {
|
|
192
|
+
_type: 'properties',
|
|
193
|
+
},
|
|
194
|
+
} as unknown as Rljson;
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
dataNotBeingAnArray: () => {
|
|
198
|
+
return {
|
|
199
|
+
table: {
|
|
200
|
+
_type: 'properties',
|
|
201
|
+
_data: {},
|
|
202
|
+
},
|
|
203
|
+
} as unknown as Rljson;
|
|
204
|
+
},
|
|
205
|
+
|
|
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
|
+
};
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
missingReferencedTable: (): Rljson => {
|
|
231
|
+
return {
|
|
232
|
+
tableB: {
|
|
233
|
+
_type: 'properties',
|
|
234
|
+
_data: [
|
|
235
|
+
{
|
|
236
|
+
tableARef: 'MISSINGREF', // tableA is missing
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
collections: {
|
|
244
|
+
missingBase: (): Rljson => {
|
|
245
|
+
const result = Example.ok.complete();
|
|
246
|
+
const collection1 = result.collections._data[1];
|
|
247
|
+
collection1.base = 'MISSING'; // Missing base
|
|
248
|
+
|
|
249
|
+
// Recalculate hashes
|
|
250
|
+
return hip(result, true, false);
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
missingIdSet: (): Rljson => {
|
|
254
|
+
const result = Example.ok.complete();
|
|
255
|
+
const collection1 = result.collections._data[1];
|
|
256
|
+
|
|
257
|
+
collection1.idSet = 'MISSING1';
|
|
258
|
+
|
|
259
|
+
// Recalculate hashes
|
|
260
|
+
return hip(result, true, false);
|
|
261
|
+
},
|
|
262
|
+
|
|
263
|
+
missingAssignedPropertyTable: (): Rljson => {
|
|
264
|
+
const result = Example.ok.complete();
|
|
265
|
+
delete result.properties; // Remove properties table
|
|
266
|
+
return result;
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
missingAssignedProperty: (): Rljson => {
|
|
270
|
+
const result = Example.ok.complete();
|
|
271
|
+
result.properties._data.splice(1, 2); // Remove an property that is assigne
|
|
272
|
+
return result;
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
cakes: {
|
|
277
|
+
missingIdSet: (): Rljson => {
|
|
278
|
+
const result = Example.ok.complete();
|
|
279
|
+
result.cakes._data[0].idSet = 'MISSING'; // Missing ID set
|
|
280
|
+
hip(result.cakes, true, false);
|
|
281
|
+
return result;
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
missingCollectionsTable: (): Rljson => {
|
|
285
|
+
const result = Example.ok.complete();
|
|
286
|
+
result.cakes._data[0].collections = 'MISSING'; // Missing collections table
|
|
287
|
+
hip(result.cakes, true, false);
|
|
288
|
+
return result;
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
missingLayerCollection: (): Rljson => {
|
|
292
|
+
const result = Example.ok.complete();
|
|
293
|
+
result.cakes._data[0].layers['layer0'] = 'MISSING0';
|
|
294
|
+
result.cakes._data[0].layers['layer1'] = 'MISSING1';
|
|
295
|
+
hip(result.cakes, true, false);
|
|
296
|
+
return result;
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
buffets: {
|
|
301
|
+
missingTable: (): Rljson => {
|
|
302
|
+
const result = Example.ok.complete();
|
|
303
|
+
const buffet = result.buffets._data[0];
|
|
304
|
+
buffet.items[0].table = 'MISSING0';
|
|
305
|
+
buffet.items[1].table = 'MISSING1';
|
|
306
|
+
hip(buffet, true, false);
|
|
307
|
+
return result;
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
missingItems: (): Rljson => {
|
|
311
|
+
const result = Example.ok.complete();
|
|
312
|
+
const buffet = result.buffets._data[0];
|
|
313
|
+
buffet.items[0].ref = 'MISSING0';
|
|
314
|
+
buffet.items[1].ref = 'MISSING1';
|
|
315
|
+
hip(buffet, true, false);
|
|
316
|
+
return result;
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ref is a hash that references to another element
|
|
3
|
+
*/
|
|
4
|
+
export type Ref = string;
|
|
5
|
+
/**
|
|
6
|
+
* An `id` is a *user defined* name or identifier of an item.
|
|
7
|
+
* It exists in parallel with the auto generated `_hash`.
|
|
8
|
+
*/
|
|
9
|
+
export type ItemId = string;
|
|
10
|
+
/**
|
|
11
|
+
* A table id reference to a table. The table ids are used as keys in the top
|
|
12
|
+
* level structure of an Rljson data object.
|
|
13
|
+
*/
|
|
14
|
+
export type TableName = ItemId;
|
|
15
|
+
/**
|
|
16
|
+
* Types of tables that can be stored in an Rljson object
|
|
17
|
+
*
|
|
18
|
+
* - `buffets` Tables containing buffets
|
|
19
|
+
* - `cakes` Tables containing cakes
|
|
20
|
+
* - `collections` Tables containing collections
|
|
21
|
+
* - `ids` Tables containing item ids
|
|
22
|
+
* - `properties` Tables containing item properties
|
|
23
|
+
*/
|
|
24
|
+
export type ContentType = 'buffets' | 'cakes' | 'collections' | 'idSets' | 'properties';
|
|
25
|
+
/**
|
|
26
|
+
* An example object using the typedefs
|
|
27
|
+
*/
|
|
28
|
+
export declare const exampleTypedefs: () => {
|
|
29
|
+
ref: Ref;
|
|
30
|
+
itemId: ItemId;
|
|
31
|
+
tableName: TableName;
|
|
32
|
+
contentType: ContentType;
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"packageManager": "pnpm@10.6.
|
|
3
|
+
"version": "0.0.14",
|
|
4
|
+
"packageManager": "pnpm@10.6.3",
|
|
5
5
|
"description": "The RLJSON data format specification",
|
|
6
6
|
"homepage": "https://github.com/rljson/rljson",
|
|
7
7
|
"bugs": "https://github.com/rljson/rljson/issues",
|
|
@@ -32,26 +32,26 @@
|
|
|
32
32
|
"@types/node": "^22.13.10",
|
|
33
33
|
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
34
34
|
"@typescript-eslint/parser": "^8.26.1",
|
|
35
|
-
"@vitest/coverage-v8": "^3.0.
|
|
35
|
+
"@vitest/coverage-v8": "^3.0.9",
|
|
36
36
|
"cross-env": "^7.0.3",
|
|
37
37
|
"eslint": "^9.22.0",
|
|
38
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
38
|
+
"eslint-plugin-jsdoc": "^50.6.8",
|
|
39
39
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
40
40
|
"globals": "^16.0.0",
|
|
41
41
|
"jsdoc": "^4.0.4",
|
|
42
42
|
"read-pkg": "^9.0.1",
|
|
43
43
|
"typescript": "~5.8.2",
|
|
44
44
|
"typescript-eslint": "^8.26.1",
|
|
45
|
-
"vite": "^6.2.
|
|
46
|
-
"vite-node": "^3.0.
|
|
45
|
+
"vite": "^6.2.2",
|
|
46
|
+
"vite-node": "^3.0.9",
|
|
47
47
|
"vite-plugin-dts": "^4.5.3",
|
|
48
48
|
"vite-tsconfig-paths": "^5.1.4",
|
|
49
|
-
"vitest": "^3.0.
|
|
49
|
+
"vitest": "^3.0.9",
|
|
50
50
|
"vitest-dom": "^0.1.1"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@rljson/hash": "^0.0.
|
|
54
|
-
"@rljson/json": "^0.0.
|
|
53
|
+
"@rljson/hash": "^0.0.12",
|
|
54
|
+
"@rljson/json": "^0.0.15"
|
|
55
55
|
},
|
|
56
56
|
"pnpm": {
|
|
57
57
|
"onlyBuiltDependencies": [
|