@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/rljson.d.ts
CHANGED
|
@@ -1,172 +1,47 @@
|
|
|
1
|
-
import { Json
|
|
1
|
+
import { Json } from '@rljson/json';
|
|
2
|
+
import { BuffetsTable } from './content/buffet.ts';
|
|
3
|
+
import { CakesTable } from './content/cake.ts';
|
|
4
|
+
import { CollectionsTable } from './content/collection.ts';
|
|
5
|
+
import { IdSetsTable } from './content/id-set.ts';
|
|
6
|
+
import { PropertiesTable } from './content/properties.ts';
|
|
7
|
+
import { ContentType, Ref, TableName } from './typedefs.ts';
|
|
8
|
+
export declare const reservedFieldNames: string[];
|
|
9
|
+
export declare const reservedTableNames: string[];
|
|
2
10
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type Ref = string;
|
|
6
|
-
/**
|
|
7
|
-
* An `id` is a *user defined* name or identifier of an item.
|
|
8
|
-
* It exists in parallel with the auto generated `_hash`.
|
|
9
|
-
*/
|
|
10
|
-
export type ItemId = string;
|
|
11
|
-
/**
|
|
12
|
-
* A table id reference to a table. The table ids are used as keys in the top
|
|
13
|
-
* level structure of an Rljson data object.
|
|
14
|
-
*/
|
|
15
|
-
export type TableName = ItemId;
|
|
16
|
-
/**
|
|
17
|
-
* Types of tables that can be stored in an Rljson object
|
|
18
|
-
*
|
|
19
|
-
* - `buffets` Tables containing buffets
|
|
20
|
-
* - `cakes` Tables containing cakes
|
|
21
|
-
* - `collections` Tables containing collections
|
|
22
|
-
* - `ids` Tables containing item ids
|
|
23
|
-
* - `properties` Tables containing item properties
|
|
24
|
-
*/
|
|
25
|
-
export type ContentType = 'buffet' | 'cake' | 'collection' | 'ids' | 'properties';
|
|
26
|
-
/** A table in the rljson format */
|
|
27
|
-
export interface RljsonTable<Data extends Json, Type extends ContentType> extends Json {
|
|
28
|
-
/** The data rows of the table */
|
|
29
|
-
_data: Data[];
|
|
30
|
-
/** The type of the table */
|
|
31
|
-
_type: Type;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* A reference to a properties row in a properties table
|
|
35
|
-
*/
|
|
36
|
-
export type PropertiesRef = Ref;
|
|
37
|
-
/**
|
|
38
|
-
* A table containing item properties
|
|
39
|
-
*/
|
|
40
|
-
export type PropertiesTable = RljsonTable<Json, 'properties'>;
|
|
41
|
-
/**
|
|
42
|
-
* An IdSetRef is a hash pointing to an Ids
|
|
43
|
-
*/
|
|
44
|
-
export type IdSetRef = Ref;
|
|
45
|
-
/**
|
|
46
|
-
* An Ids manages list of item ids
|
|
47
|
-
*/
|
|
48
|
-
export interface IdSet extends Json {
|
|
49
|
-
/**
|
|
50
|
-
* The hash of another item id list which is extended by this one.
|
|
51
|
-
* Must be empty or null, when the list is the root.
|
|
52
|
-
*/
|
|
53
|
-
base: IdSetRef | null;
|
|
54
|
-
/**
|
|
55
|
-
* The item ids added to base
|
|
56
|
-
*/
|
|
57
|
-
add: ItemId[];
|
|
58
|
-
/**
|
|
59
|
-
* The item ids removed from base
|
|
60
|
-
*/
|
|
61
|
-
remove: ItemId[];
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A table containing item ids
|
|
65
|
-
*/
|
|
66
|
-
export type IdSetsTable = RljsonTable<IdSet, 'ids'>;
|
|
67
|
-
/**
|
|
68
|
-
* A CollectionRef is a hash pointing to a collection
|
|
69
|
-
*/
|
|
70
|
-
export type CollectionRef = Ref;
|
|
71
|
-
/**
|
|
72
|
-
* A collection assigns properties to item ids
|
|
11
|
+
* One of the supported Rljson table types
|
|
73
12
|
*/
|
|
74
|
-
export
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
base: CollectionRef | null;
|
|
79
|
-
/**
|
|
80
|
-
* The table containing the item set of this collection
|
|
81
|
-
*/
|
|
82
|
-
idSetsTable: TableName;
|
|
83
|
-
/**
|
|
84
|
-
* A reference to the ids of the items the collection is based on
|
|
85
|
-
*/
|
|
86
|
-
idSet: IdSetRef;
|
|
87
|
-
/**
|
|
88
|
-
* The table containing the properties assigned to the items of this collection
|
|
89
|
-
*/
|
|
90
|
-
properties: TableName;
|
|
91
|
-
/**
|
|
92
|
-
* Assign properties to each item of the collection.
|
|
93
|
-
*/
|
|
94
|
-
assign: Record<ItemId, PropertiesRef>;
|
|
13
|
+
export type TableType = BuffetsTable | PropertiesTable<any> | CollectionsTable | IdSetsTable | CakesTable;
|
|
14
|
+
/** The rljson data format */
|
|
15
|
+
export interface Rljson extends Json {
|
|
16
|
+
[tableId: TableName]: TableType;
|
|
95
17
|
}
|
|
96
18
|
/**
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
export type CollectionsTable = RljsonTable<Collection, 'collection'>;
|
|
100
|
-
/**
|
|
101
|
-
* A `CakeLayerId` assigns an id or name to a cake layer
|
|
102
|
-
*/
|
|
103
|
-
export type CakeLayerId = ItemId;
|
|
104
|
-
/**
|
|
105
|
-
* A `CakeLayerIds` is a set of cake layer ids / cake layer names
|
|
106
|
-
*/
|
|
107
|
-
export type CakeLayerIds = IdSet;
|
|
108
|
-
/**
|
|
109
|
-
* A cake is a collection of layers.
|
|
110
|
-
*
|
|
111
|
-
* A layer is a collection of items.
|
|
112
|
-
* All layers of a cake refer to the same items.
|
|
19
|
+
* Rljson set with private fields
|
|
113
20
|
*/
|
|
114
|
-
export
|
|
115
|
-
/**
|
|
116
|
-
* The table containing the item ids of the cake
|
|
117
|
-
*/
|
|
118
|
-
itemIdsTable: TableName;
|
|
21
|
+
export type RljsonPrivate = {
|
|
119
22
|
/**
|
|
120
|
-
*
|
|
23
|
+
* Contains id sets used accross the Rljson object
|
|
121
24
|
*/
|
|
122
|
-
|
|
25
|
+
_idSets: IdSetsTable;
|
|
123
26
|
/**
|
|
124
|
-
*
|
|
27
|
+
* Used by validation. If external references are not present,
|
|
28
|
+
* validation does not throw an error.
|
|
125
29
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
*/
|
|
137
|
-
export type CakesTable = RljsonTable<Cake, 'cake'>;
|
|
138
|
-
/**
|
|
139
|
-
* A buffet id is a name or id of a buffet
|
|
140
|
-
*/
|
|
141
|
-
export type BuffetId = ItemId;
|
|
142
|
-
/**
|
|
143
|
-
* A buffet is a collection of arbitrary but related items, e.g. cakes,
|
|
144
|
-
* collections, or items.
|
|
145
|
-
*/
|
|
146
|
-
export interface Buffet extends Json {
|
|
147
|
-
/**
|
|
148
|
-
* The items of the buffet
|
|
149
|
-
*/
|
|
150
|
-
items: Array<{
|
|
151
|
-
table: TableName;
|
|
152
|
-
ref: Ref;
|
|
153
|
-
[key: string]: JsonValue;
|
|
154
|
-
}>;
|
|
30
|
+
_externalRefs: Ref[];
|
|
31
|
+
};
|
|
32
|
+
/** An example rljson object */
|
|
33
|
+
export declare const exampleRljson: () => Rljson;
|
|
34
|
+
/** A table in the rljson format */
|
|
35
|
+
export interface RljsonTable<Data extends Json, Type extends ContentType> extends Json {
|
|
36
|
+
/** The data rows of the table */
|
|
37
|
+
_data: Data[];
|
|
38
|
+
/** The type of the table. If not set, the type is "properties" */
|
|
39
|
+
_type: Type;
|
|
155
40
|
}
|
|
156
41
|
/**
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* One of the supported Rljson table types
|
|
42
|
+
* Iterates over all tables of an Rljson object.
|
|
43
|
+
* Skips private members starting with _
|
|
44
|
+
* @param rljson - The Rljson object to iterate
|
|
45
|
+
* @param callback - The callback to call for each table
|
|
162
46
|
*/
|
|
163
|
-
export
|
|
164
|
-
/** The rljson data format */
|
|
165
|
-
export interface Rljson extends Json {
|
|
166
|
-
[tableId: TableName]: TableType | string;
|
|
167
|
-
}
|
|
168
|
-
export declare const exampleRljson: () => Rljson;
|
|
169
|
-
export declare const exampleBinary: () => Rljson;
|
|
170
|
-
export declare const exampleRljsonEmpty: () => Rljson;
|
|
171
|
-
export declare const exampleRljsonWithErrors: () => Rljson;
|
|
172
|
-
export declare const exampleRljsonWithMultipleRows: () => Rljson;
|
|
47
|
+
export declare const iterateTables: (rljson: Rljson, callback: (tableName: string, table: TableType) => void) => void;
|