@rljson/rljson 0.0.18 → 0.0.21

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.
@@ -8,302 +8,25 @@ found in the LICENSE file in the root of this package.
8
8
 
9
9
  # Contributors Guide
10
10
 
11
- - [Install](#install)
12
- - [Checkout](#checkout)
13
- - [Install pnpm](#install-pnpm)
14
- - [Install dependencies](#install-dependencies)
15
- - [Install Vscode extensions](#install-vscode-extensions)
16
- - [Uninstall Jest and Jasmine](#uninstall-jest-and-jasmine)
17
- - [Install GitHub CLI](#install-github-cli)
11
+ - [Prepare](#prepare)
18
12
  - [Develop](#develop)
19
- - [Read architecture doc](#read-architecture-doc)
20
- - [Debug](#debug)
21
- - [Update goldens](#update-goldens)
22
- - [Test and Build](#test-and-build)
23
- - [Rename classes](#rename-classes)
24
- - [Workflow](#workflow)
25
- - [Set a PR title](#set-a-pr-title)
26
- - [Checkout main](#checkout-main)
27
- - [Create a feature branch](#create-a-feature-branch)
28
- - [Update dependencies](#update-dependencies)
29
- - [Debug and develop](#debug-and-develop)
30
- - [Commit](#commit)
31
- - [Increase version](#increase-version)
32
- - [Build](#build)
33
- - [Create a pull request](#create-a-pull-request)
34
- - [Wait until PR is merged](#wait-until-pr-is-merged)
35
- - [Delete feature branch](#delete-feature-branch)
36
- - [Publish to NPM](#publish-to-npm)
37
- - [Troubleshooting](#troubleshooting)
38
- - [Checkout README.trouble.md](#checkout-readmetroublemd)
39
- - [File issues on GitHub](#file-issues-on-github)
13
+ - [Tools](#tools)
14
+ - [Superheros](#superheros)
40
15
 
41
- <!-- ........................................................................-->
42
-
43
- ## Install
44
-
45
- ### Checkout
46
-
47
- ```bash
48
- mkdir rljson
49
- cd rljson
50
- git clone https://github.com/rljson/rljson.git
51
- cd rljson
52
- ```
53
-
54
- ### Install pnpm
55
-
56
- Windows:
57
-
58
- ```bash
59
- corepack enable pnpm
60
- ```
61
-
62
- Mac:
63
-
64
- ```bash
65
- sudo corepack enable pnpm
66
- ```
67
-
68
- ### Install dependencies
69
-
70
- ```bash
71
- pnpm install
72
- ```
73
-
74
- ### Install Vscode extensions
75
-
76
- Open this project in `vscode`.
77
-
78
- Press `Cmd+Shift+P`.
79
-
80
- Type `Extensions: Show Recommended Extensions` and press `Enter`.
81
-
82
- The recommended extensions will be shown.
83
-
84
- Make sure, all recommended extensions are shown.
85
-
86
- ### Uninstall Jest and Jasmine
87
-
88
- Jest or Jasmine extensions conflict with the `Vitest` extension used for this
89
- project.
90
-
91
- Uninstall them, if you have installed them.
92
-
93
- ### Install GitHub CLI
94
-
95
- Install GitHub CLI on Mac
16
+ ## Prepare
96
17
 
97
- ```bash
98
- brew install gh
99
- ```
100
-
101
- Login
102
-
103
- ```bash
104
- gh auth login
105
- ```
18
+ Read [prepare.md](doc/workflows/prepare.md)
106
19
 
107
20
  <!-- ........................................................................-->
108
21
 
109
22
  ## Develop
110
23
 
111
- ### Read architecture doc
112
-
113
- Read [README.architecture.md](./README.architecture.md) to get an overview
114
- of the package's architecture.
115
-
116
- ### Debug
117
-
118
- In Vscode: At the `left side bar` click on the `Test tube` icon to open the `Test explorer`.
119
-
120
- At the `top`, click on the `refresh` icon to show update the tests.
121
-
122
- Open a test file (`*.spec.ts`)
123
-
124
- Set a breakpoint.
125
-
126
- Press `alt` and click on the play button left beside the test.
127
-
128
- Execution should stop at the breakpoint.
129
-
130
- ### Update goldens
131
-
132
- In various tests we are creating golden files, that are reference files that
133
- are compared against the files created in the tests.
134
-
135
- ```bash
136
- pnpm updateGoldens
137
- ```
138
-
139
- ### Test and Build
140
-
141
- ```bash
142
- pnpm test
143
- pnpm build
144
- ```
145
-
146
- ### Rename classes
147
-
148
- Replace `ClassA` by `ClassB` in the following script and run it:
149
-
150
- ```bash
151
- export CLASS_A="ColumnSelection"
152
- export CLASS_B="ColumnsConfig"
153
-
154
- to_snake_case() {
155
- echo "$1" | sed -E 's/([a-z0-9])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]'
156
- }
157
-
158
- to_lower_first() {
159
- first_char=$(echo "$1" | cut -c1 | tr '[:upper:]' '[:lower:]')
160
- rest_chars=$(echo "$1" | cut -c2-)
161
- echo "$first_char$rest_chars"
162
- }
163
-
164
- export LOWER_CLASS_A=$(to_lower_first "$CLASS_A")
165
- export LOWER_CLASS_B=$(to_lower_first "$CLASS_B")
166
- export SNAKE_CLASS_A=$(to_snake_case "$CLASS_A")
167
- export SNAKE_CLASS_B=$(to_snake_case "$CLASS_B")
168
-
169
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
170
- -exec sed -i '' "s/$CLASS_A/$CLASS_B/g" {} +
171
-
172
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
173
- -exec sed -i '' "s/$LOWER_CLASS_A/$LOWER_CLASS_B/g" {} +
174
-
175
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
176
- -exec sed -i '' "s/$SNAKE_CLASS_A/$SNAKE_CLASS_B/g" {} +
177
-
178
- find . -type f -not -path "*/node_modules/*" -not -path "*/.*" -name "*$SNAKE_CLASS_A*" \
179
- -exec bash -c 'mv "$1" "${1//'"$SNAKE_CLASS_A"'/'"$SNAKE_CLASS_B"'}"' _ {} \;
180
-
181
- rm -rf test/goldens
182
- pnpm updateGoldens
183
- ```
184
-
185
- Review the changes.
186
-
187
- Commit
188
-
189
- ```bash
190
- git stage .
191
- git commit -am"Rename $CLASS_A to $CLASS_B"
192
- ```
193
-
194
- <!-- ........................................................................-->
195
-
196
- ## Workflow
197
-
198
- ### Set a PR title
199
-
200
- ```bash
201
- export PR_TITLE="PR Title"
202
- ```
203
-
204
- ### Checkout main
205
-
206
- ```bash
207
- git checkout main
208
- git fetch
209
- git pull
210
- ```
211
-
212
- ### Create a feature branch
213
-
214
- ```bash
215
- export BRANCH=`echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'`
216
- git checkout -b $BRANCH
217
- ```
218
-
219
- ### Update dependencies
220
-
221
- ```bash
222
- pnpm update --latest
223
- git commit -am"Update dependencies"
224
- ```
225
-
226
- ### Debug and develop
227
-
228
- Debug and develop
229
-
230
- ### Commit
231
-
232
- If you only have one thing changed, execute
233
-
234
- ```bash
235
- git add . && git commit -m "$PR_TITLE"
236
- ```
237
-
238
- ### Increase version
239
-
240
- ```bash
241
- pnpm version patch --no-git-tag-version
242
- git commit -am"Increase version"
243
- ```
244
-
245
- ### Build
246
-
247
- ```bash
248
- npm run build
249
- ```
250
-
251
- ### Create a pull request
252
-
253
- ```bash
254
- git push -u origin $BRANCH
255
- gh pr create --base main --title "$PR_TITLE" --body ""
256
- gh pr merge --auto --squash
257
- ```
258
-
259
- ### Wait until PR is merged
260
-
261
- ```bash
262
- echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
263
- echo -e "\033[33mWait until PR is closed or merged ...\033[0m"
264
-
265
- while true; do
266
- STATUS=$(gh pr view --json state | jq -r '.state')
267
- if [ "$STATUS" = "CLOSED" ] || [ "$STATUS" = "MERGED" ]; then
268
- echo -e "\033[32mPR has been merged or closed.\033[0m"
269
- break
270
- elif [ "$STATUS" = "FAILED" ]; then
271
- echo -e "\033[31mError: PR has failed.\033[0m"
272
- break
273
- fi
274
- sleep 2
275
- done
276
- ```
277
-
278
- ### Delete feature branch
279
-
280
- ```bash
281
- git fetch && git checkout main
282
- git reset --soft origin/main
283
- git stash -m"PR Aftermath"
284
- git pull
285
- git branch -d $BRANCH
286
- ```
287
-
288
- ### Publish to NPM
289
-
290
- ```bash
291
- npm publish --access public
292
- git tag $(npm pkg get version | tr -d '\\"')
293
- ```
294
-
295
- <!-- ........................................................................-->
296
-
297
- ## Troubleshooting
298
-
299
- ### Checkout README.trouble.md
300
-
301
- Checkout [./README.trouble.md](./README.trouble.md)
24
+ Read [develop.md](doc/workflows/develop.md)
302
25
 
303
- ### File issues on GitHub
26
+ ## Tools
304
27
 
305
- Visit <https://github.com/rljson/rljson/issues>
28
+ Read [tools.md](doc/workflows/tools.md)
306
29
 
307
- Check if there is already an issue for your problem.
30
+ ## Superheros
308
31
 
309
- If no, report the issue.
32
+ Read [super-hero.md](doc/workflows/super-hero.md)
@@ -8,302 +8,25 @@ found in the LICENSE file in the root of this package.
8
8
 
9
9
  # Contributors Guide
10
10
 
11
- - [Install](#install)
12
- - [Checkout](#checkout)
13
- - [Install pnpm](#install-pnpm)
14
- - [Install dependencies](#install-dependencies)
15
- - [Install Vscode extensions](#install-vscode-extensions)
16
- - [Uninstall Jest and Jasmine](#uninstall-jest-and-jasmine)
17
- - [Install GitHub CLI](#install-github-cli)
11
+ - [Prepare](#prepare)
18
12
  - [Develop](#develop)
19
- - [Read architecture doc](#read-architecture-doc)
20
- - [Debug](#debug)
21
- - [Update goldens](#update-goldens)
22
- - [Test and Build](#test-and-build)
23
- - [Rename classes](#rename-classes)
24
- - [Workflow](#workflow)
25
- - [Set a PR title](#set-a-pr-title)
26
- - [Checkout main](#checkout-main)
27
- - [Create a feature branch](#create-a-feature-branch)
28
- - [Update dependencies](#update-dependencies)
29
- - [Debug and develop](#debug-and-develop)
30
- - [Commit](#commit)
31
- - [Increase version](#increase-version)
32
- - [Build](#build)
33
- - [Create a pull request](#create-a-pull-request)
34
- - [Wait until PR is merged](#wait-until-pr-is-merged)
35
- - [Delete feature branch](#delete-feature-branch)
36
- - [Publish to NPM](#publish-to-npm)
37
- - [Troubleshooting](#troubleshooting)
38
- - [Checkout README.trouble.md](#checkout-readmetroublemd)
39
- - [File issues on GitHub](#file-issues-on-github)
13
+ - [Tools](#tools)
14
+ - [Superheros](#superheros)
40
15
 
41
- <!-- ........................................................................-->
42
-
43
- ## Install
44
-
45
- ### Checkout
46
-
47
- ```bash
48
- mkdir rljson
49
- cd rljson
50
- git clone https://github.com/rljson/rljson.git
51
- cd rljson
52
- ```
53
-
54
- ### Install pnpm
55
-
56
- Windows:
57
-
58
- ```bash
59
- corepack enable pnpm
60
- ```
61
-
62
- Mac:
63
-
64
- ```bash
65
- sudo corepack enable pnpm
66
- ```
67
-
68
- ### Install dependencies
69
-
70
- ```bash
71
- pnpm install
72
- ```
73
-
74
- ### Install Vscode extensions
75
-
76
- Open this project in `vscode`.
77
-
78
- Press `Cmd+Shift+P`.
79
-
80
- Type `Extensions: Show Recommended Extensions` and press `Enter`.
81
-
82
- The recommended extensions will be shown.
83
-
84
- Make sure, all recommended extensions are shown.
85
-
86
- ### Uninstall Jest and Jasmine
87
-
88
- Jest or Jasmine extensions conflict with the `Vitest` extension used for this
89
- project.
90
-
91
- Uninstall them, if you have installed them.
92
-
93
- ### Install GitHub CLI
94
-
95
- Install GitHub CLI on Mac
16
+ ## Prepare
96
17
 
97
- ```bash
98
- brew install gh
99
- ```
100
-
101
- Login
102
-
103
- ```bash
104
- gh auth login
105
- ```
18
+ Read [prepare.md](doc/workflows/prepare.md)
106
19
 
107
20
  <!-- ........................................................................-->
108
21
 
109
22
  ## Develop
110
23
 
111
- ### Read architecture doc
112
-
113
- Read [README.architecture.md](./README.architecture.md) to get an overview
114
- of the package's architecture.
115
-
116
- ### Debug
117
-
118
- In Vscode: At the `left side bar` click on the `Test tube` icon to open the `Test explorer`.
119
-
120
- At the `top`, click on the `refresh` icon to show update the tests.
121
-
122
- Open a test file (`*.spec.ts`)
123
-
124
- Set a breakpoint.
125
-
126
- Press `alt` and click on the play button left beside the test.
127
-
128
- Execution should stop at the breakpoint.
129
-
130
- ### Update goldens
131
-
132
- In various tests we are creating golden files, that are reference files that
133
- are compared against the files created in the tests.
134
-
135
- ```bash
136
- pnpm updateGoldens
137
- ```
138
-
139
- ### Test and Build
140
-
141
- ```bash
142
- pnpm test
143
- pnpm build
144
- ```
145
-
146
- ### Rename classes
147
-
148
- Replace `ClassA` by `ClassB` in the following script and run it:
149
-
150
- ```bash
151
- export CLASS_A="ColumnSelection"
152
- export CLASS_B="ColumnsConfig"
153
-
154
- to_snake_case() {
155
- echo "$1" | sed -E 's/([a-z0-9])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]'
156
- }
157
-
158
- to_lower_first() {
159
- first_char=$(echo "$1" | cut -c1 | tr '[:upper:]' '[:lower:]')
160
- rest_chars=$(echo "$1" | cut -c2-)
161
- echo "$first_char$rest_chars"
162
- }
163
-
164
- export LOWER_CLASS_A=$(to_lower_first "$CLASS_A")
165
- export LOWER_CLASS_B=$(to_lower_first "$CLASS_B")
166
- export SNAKE_CLASS_A=$(to_snake_case "$CLASS_A")
167
- export SNAKE_CLASS_B=$(to_snake_case "$CLASS_B")
168
-
169
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
170
- -exec sed -i '' "s/$CLASS_A/$CLASS_B/g" {} +
171
-
172
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
173
- -exec sed -i '' "s/$LOWER_CLASS_A/$LOWER_CLASS_B/g" {} +
174
-
175
- find . -type f \( -name "*.ts" -o -name "*.md" -o -name "package.json" \) -not -path "./node_modules/*" \
176
- -exec sed -i '' "s/$SNAKE_CLASS_A/$SNAKE_CLASS_B/g" {} +
177
-
178
- find . -type f -not -path "*/node_modules/*" -not -path "*/.*" -name "*$SNAKE_CLASS_A*" \
179
- -exec bash -c 'mv "$1" "${1//'"$SNAKE_CLASS_A"'/'"$SNAKE_CLASS_B"'}"' _ {} \;
180
-
181
- rm -rf test/goldens
182
- pnpm updateGoldens
183
- ```
184
-
185
- Review the changes.
186
-
187
- Commit
188
-
189
- ```bash
190
- git stage .
191
- git commit -am"Rename $CLASS_A to $CLASS_B"
192
- ```
193
-
194
- <!-- ........................................................................-->
195
-
196
- ## Workflow
197
-
198
- ### Set a PR title
199
-
200
- ```bash
201
- export PR_TITLE="PR Title"
202
- ```
203
-
204
- ### Checkout main
205
-
206
- ```bash
207
- git checkout main
208
- git fetch
209
- git pull
210
- ```
211
-
212
- ### Create a feature branch
213
-
214
- ```bash
215
- export BRANCH=`echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'`
216
- git checkout -b $BRANCH
217
- ```
218
-
219
- ### Update dependencies
220
-
221
- ```bash
222
- pnpm update --latest
223
- git commit -am"Update dependencies"
224
- ```
225
-
226
- ### Debug and develop
227
-
228
- Debug and develop
229
-
230
- ### Commit
231
-
232
- If you only have one thing changed, execute
233
-
234
- ```bash
235
- git add . && git commit -m "$PR_TITLE"
236
- ```
237
-
238
- ### Increase version
239
-
240
- ```bash
241
- pnpm version patch --no-git-tag-version
242
- git commit -am"Increase version"
243
- ```
244
-
245
- ### Build
246
-
247
- ```bash
248
- npm run build
249
- ```
250
-
251
- ### Create a pull request
252
-
253
- ```bash
254
- git push -u origin $BRANCH
255
- gh pr create --base main --title "$PR_TITLE" --body ""
256
- gh pr merge --auto --squash
257
- ```
258
-
259
- ### Wait until PR is merged
260
-
261
- ```bash
262
- echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
263
- echo -e "\033[33mWait until PR is closed or merged ...\033[0m"
264
-
265
- while true; do
266
- STATUS=$(gh pr view --json state | jq -r '.state')
267
- if [ "$STATUS" = "CLOSED" ] || [ "$STATUS" = "MERGED" ]; then
268
- echo -e "\033[32mPR has been merged or closed.\033[0m"
269
- break
270
- elif [ "$STATUS" = "FAILED" ]; then
271
- echo -e "\033[31mError: PR has failed.\033[0m"
272
- break
273
- fi
274
- sleep 2
275
- done
276
- ```
277
-
278
- ### Delete feature branch
279
-
280
- ```bash
281
- git fetch && git checkout main
282
- git reset --soft origin/main
283
- git stash -m"PR Aftermath"
284
- git pull
285
- git branch -d $BRANCH
286
- ```
287
-
288
- ### Publish to NPM
289
-
290
- ```bash
291
- npm publish --access public
292
- git tag $(npm pkg get version | tr -d '\\"')
293
- ```
294
-
295
- <!-- ........................................................................-->
296
-
297
- ## Troubleshooting
298
-
299
- ### Checkout README.trouble.md
300
-
301
- Checkout [./README.trouble.md](./README.trouble.md)
24
+ Read [develop.md](doc/workflows/develop.md)
302
25
 
303
- ### File issues on GitHub
26
+ ## Tools
304
27
 
305
- Visit <https://github.com/rljson/rljson/issues>
28
+ Read [tools.md](doc/workflows/tools.md)
306
29
 
307
- Check if there is already an issue for your problem.
30
+ ## Superheros
308
31
 
309
- If no, report the issue.
32
+ Read [super-hero.md](doc/workflows/super-hero.md)
@@ -16,7 +16,7 @@ export type CakeLayerId = ItemId;
16
16
  export interface Cake extends Json {
17
17
  /**
18
18
  * The item ids of the collection. If present, the item ids in the layers
19
- * must match these ids. The item id sets can be found in the _idSets table.
19
+ * must match these ids. The item id sets can be found in the idSets table.
20
20
  */
21
21
  idSet?: IdSetRef;
22
22
  /**
@@ -17,7 +17,7 @@ export interface Collection extends Json {
17
17
  base?: CollectionRef;
18
18
  /**
19
19
  * The item ids of the collection. If presnet, the item ids in `assign`
20
- * must match these ids. The item id sets can be found in the _idSets table.
20
+ * must match these ids. The item id sets can be found in the idSets table.
21
21
  */
22
22
  idSet?: IdSetRef;
23
23
  /**
@@ -1,5 +1,5 @@
1
1
  import { Json } from '@rljson/json';
2
- import { NutritiveValues } from '../example/bakery-example.ts';
2
+ import { NutritionalValues } from '../example/bakery-example.ts';
3
3
  import { RljsonTable } from '../rljson.ts';
4
4
  import { Ref } from '../typedefs.ts';
5
5
  /**
@@ -13,4 +13,4 @@ export type PropertiesTable<T extends Json> = RljsonTable<T, 'properties'>;
13
13
  /**
14
14
  * Provides an example collectionsTable for test purposes
15
15
  */
16
- export declare const examplePropertiesTable: () => PropertiesTable<NutritiveValues>;
16
+ export declare const examplePropertiesTable: () => PropertiesTable<NutritionalValues>;
@@ -13,18 +13,14 @@ export interface ColumnCfg extends Json {
13
13
  * The jsonKey of the column used in data
14
14
  */
15
15
  jsonKey: JsonKey;
16
- /**
17
- * A short name of the column to be shown in the table header
18
- */
19
- nameShort: string;
20
- /**
21
- * A unshorted name to be shown in the tool tip
22
- */
23
- name: string;
24
16
  /**
25
17
  * Average number of characters in the column
26
18
  */
27
19
  avgChars?: number;
20
+ /**
21
+ * Maximum number of characters in the column
22
+ */
23
+ maxChars?: number;
28
24
  /**
29
25
  * The type of the column
30
26
  */
@@ -34,8 +30,13 @@ export interface ColumnCfg extends Json {
34
30
  * Describes the configuration of a table, i.e. table metadata and columns
35
31
  */
36
32
  export interface TableCfg extends Json {
37
- name: string;
33
+ /**
34
+ * Technical lower camel case json identifier of the table
35
+ */
38
36
  jsonKey: JsonKey;
37
+ /**
38
+ * A short description of the table
39
+ */
39
40
  columns: Record<JsonKey, ColumnCfg>;
40
41
  }
41
42
  /**
@@ -9,14 +9,14 @@ import { Ref } from '../typedefs.ts';
9
9
  export interface Ingredient extends Json {
10
10
  name: string;
11
11
  amountUnit: 'g' | 'ml';
12
- nutritiveValuesRef: Ref;
12
+ nutritionalValuesRef: Ref;
13
13
  }
14
14
  export interface RecipeIngredient extends Json {
15
15
  ingredientsRef: string;
16
16
  quantity: number;
17
17
  }
18
18
  export type IngredientsTypeTable = PropertiesTable<Ingredient>;
19
- export interface NutritiveValues extends Json {
19
+ export interface NutritionalValues extends Json {
20
20
  energy: number;
21
21
  fat: number;
22
22
  protein: number;
@@ -30,6 +30,6 @@ export interface Bakery extends Rljson {
30
30
  recipes: CollectionsTable;
31
31
  recipeIngredients: PropertiesTable<RecipeIngredient>;
32
32
  ingredients: PropertiesTable<Ingredient>;
33
- nutritiveValues: PropertiesTable<NutritiveValues>;
33
+ nutritionalValues: PropertiesTable<NutritionalValues>;
34
34
  }
35
35
  export declare const bakeryExample: () => Bakery;
package/dist/rljson.d.ts CHANGED
@@ -39,7 +39,7 @@ export type RljsonPrivate = {
39
39
  /**
40
40
  * Column configurations used accross the Rljson object
41
41
  */
42
- _tableCfgs?: TablesCfgTable;
42
+ tableCfgs?: TablesCfgTable;
43
43
  };
44
44
  /** An example rljson object */
45
45
  export declare const exampleRljson: () => Rljson;
package/dist/rljson.js CHANGED
@@ -5,114 +5,123 @@ import { hip, hsh } from "@rljson/hash";
5
5
  import { exampleJsonObject, jsonValueTypes, jsonValueMatchesType } from "@rljson/json";
6
6
  // @license
7
7
  const bakeryExample = () => {
8
- const result = {
9
- _idSets: {
10
- _type: "idSets",
11
- _data: [
12
- {
13
- add: ["slice0", "slice1"],
14
- _hash: "Ko990SJfgPJvNGxC63CRf7"
15
- }
16
- ],
17
- _hash: "NiojsJvZ7iEU7WeMWttzyJ"
18
- },
19
- buffets: {
20
- _type: "buffets",
21
- _data: [
22
- {
23
- items: [
24
- {
25
- table: "cakes",
26
- ref: "KdLv3zTftqKKUeqYrTtO2r"
27
- }
28
- ]
29
- }
30
- ]
31
- },
32
- cakes: {
33
- _type: "cakes",
34
- _data: [
35
- {
36
- idSet: "Ko990SJfgPJvNGxC63CRf7",
37
- collections: "layers",
38
- layers: {
39
- _hash: "RBNvo1WzZ4oRRq0W9-hknp"
40
- },
41
- _hash: "KdLv3zTftqKKUeqYrTtO2r"
42
- }
43
- ]
44
- },
45
- slices: {
46
- _type: "idSets",
47
- _data: [
48
- {
49
- add: ["slice0", "slice1"],
50
- remove: [],
51
- _hash: "wyYfK5E4ArrMKQ_zvi2-EE"
8
+ const nutritionalValues = hip({
9
+ _type: "properties",
10
+ _data: [
11
+ {
12
+ energy: 364,
13
+ fat: 0.98,
14
+ protein: 10.33,
15
+ carbohydrates: 76.31,
16
+ _hash: ""
17
+ }
18
+ ],
19
+ _hash: ""
20
+ });
21
+ const ingredients = hip({
22
+ _type: "properties",
23
+ _data: [
24
+ {
25
+ name: "flour",
26
+ amountUnit: "g",
27
+ nutritionalValuesRef: nutritionalValues._data[0]._hash,
28
+ _hash: ""
29
+ }
30
+ ],
31
+ _hash: ""
32
+ });
33
+ const recipeIngredients = hip({
34
+ _type: "properties",
35
+ _data: [
36
+ {
37
+ ingredientsRef: ingredients._data[0]._hash,
38
+ quantity: 500,
39
+ _hash: ""
40
+ }
41
+ ],
42
+ _hash: ""
43
+ });
44
+ const recipes = hip({
45
+ _type: "collections",
46
+ _data: [
47
+ {
48
+ properties: "recipeIngredients",
49
+ assign: {
50
+ flour: recipeIngredients._data[0]._hash
51
+ },
52
+ _hash: ""
53
+ }
54
+ ]
55
+ });
56
+ const layers = hip({
57
+ _type: "collections",
58
+ _data: [
59
+ {
60
+ properties: "recipes",
61
+ assign: {
62
+ slice0: recipes._data[0]._hash,
63
+ slice1: recipes._data[0]._hash
52
64
  }
53
- ],
54
- _hash: "Qt6FzyzwHdEdYC3fKUXaAm"
55
- },
56
- layers: {
57
- _type: "collections",
58
- _data: [
59
- {
60
- properties: "recipes",
61
- assign: {
62
- slice0: "uRTo_Jmt9lOA09e2QnwB9W",
63
- slice1: "uRTo_Jmt9lOA09e2QnwB9W"
65
+ }
66
+ ]
67
+ });
68
+ const slices = hip({
69
+ _type: "idSets",
70
+ _data: [
71
+ {
72
+ add: ["slice0", "slice1"],
73
+ remove: [],
74
+ _hash: ""
75
+ }
76
+ ],
77
+ _hash: ""
78
+ });
79
+ const idSets = hip({
80
+ _type: "idSets",
81
+ _data: [
82
+ {
83
+ add: ["slice0", "slice1"],
84
+ _hash: ""
85
+ }
86
+ ],
87
+ _hash: ""
88
+ });
89
+ const cakes = hip({
90
+ _type: "cakes",
91
+ _data: [
92
+ {
93
+ idSet: idSets._data[0]._hash,
94
+ collections: "layers",
95
+ layers: {
96
+ flour: layers._data[0]._hash
97
+ },
98
+ _hash: ""
99
+ }
100
+ ]
101
+ });
102
+ const buffets = hip({
103
+ _type: "buffets",
104
+ _data: [
105
+ {
106
+ items: [
107
+ {
108
+ table: "cakes",
109
+ ref: cakes._data[0]._hash
64
110
  }
65
- }
66
- ]
67
- },
68
- recipes: {
69
- _type: "collections",
70
- _data: [
71
- {
72
- properties: "recipeIngredients",
73
- assign: {
74
- flour: "RCA4yzQe6mYOqquoLijKop"
75
- },
76
- _hash: "uRTo_Jmt9lOA09e2QnwB9W"
77
- }
78
- ]
79
- },
80
- recipeIngredients: {
81
- _type: "properties",
82
- _data: [
83
- {
84
- ingredientsRef: "CdSJV-WOfnFT1svec3iJ6x",
85
- quantity: 500,
86
- _hash: "RCA4yzQe6mYOqquoLijKop"
87
- }
88
- ],
89
- _hash: "R6dJq4ZJ3QDa9Bz8QJDhNq"
90
- },
91
- ingredients: {
92
- _type: "properties",
93
- _data: [
94
- {
95
- name: "flour",
96
- amountUnit: "g",
97
- nutritiveValuesRef: "gZXFSlrl5QAs5hOVsq5sWB",
98
- _hash: "CdSJV-WOfnFT1svec3iJ6x"
99
- }
100
- ],
101
- _hash: "FgJeTM0NcZvXwFcU-PD8Jf"
102
- },
103
- nutritiveValues: {
104
- _type: "properties",
105
- _data: [
106
- {
107
- energy: 364,
108
- fat: 0.98,
109
- protein: 10.33,
110
- carbohydrates: 76.31,
111
- _hash: "gZXFSlrl5QAs5hOVsq5sWB"
112
- }
113
- ],
114
- _hash: "7k4OqQtk71w3yVGMoA9F6p"
115
- }
111
+ ]
112
+ }
113
+ ]
114
+ });
115
+ const result = {
116
+ idSets,
117
+ buffets,
118
+ cakes,
119
+ slices,
120
+ layers,
121
+ recipes,
122
+ recipeIngredients,
123
+ ingredients,
124
+ nutritionalValues
116
125
  };
117
126
  return result;
118
127
  };
@@ -125,7 +134,7 @@ const exampleCollectionsTable = () => bakeryExample().layers;
125
134
  // @license
126
135
  const exampleIdSetsTable = () => bakeryExample().slices;
127
136
  // @license
128
- const examplePropertiesTable = () => bakeryExample().nutritiveValues;
137
+ const examplePropertiesTable = () => bakeryExample().nutritionalValues;
129
138
  // @license
130
139
  const _Example = class _Example {
131
140
  };
@@ -210,7 +219,7 @@ __publicField(_Example, "ok", {
210
219
  ]
211
220
  };
212
221
  const result = {
213
- _tableCfgs: tableCfgs,
222
+ tableCfgs,
214
223
  table: {
215
224
  _type: "properties",
216
225
  _tableCfg: "R-rCQ4YwYYJAp6uAo6S_6n",
@@ -275,7 +284,7 @@ __publicField(_Example, "ok", {
275
284
  },
276
285
  complete: () => {
277
286
  return {
278
- _idSets: {
287
+ idSets: {
279
288
  _type: "idSets",
280
289
  _data: [
281
290
  {
@@ -412,7 +421,7 @@ __publicField(_Example, "broken", {
412
421
  tableCfg: {
413
422
  wrongType: () => {
414
423
  const result = _Example.ok.singleRow();
415
- const tableCfg = result._tableCfgs._data[0];
424
+ const tableCfg = result.tableCfgs._data[0];
416
425
  tableCfg.columns["int"].type = "numberBroken";
417
426
  return hip(result, true, false);
418
427
  }
@@ -483,7 +492,7 @@ __publicField(_Example, "broken", {
483
492
  });
484
493
  let Example = _Example;
485
494
  // @license
486
- const exampleTableCfgTable = () => Example.ok.singleRow()._tableCfgs;
495
+ const exampleTableCfgTable = () => Example.ok.singleRow().tableCfgs;
487
496
  // @license
488
497
  const rljsonIndexed = (rljson) => {
489
498
  const result = {};
@@ -571,8 +580,8 @@ class _BaseValidator {
571
580
  () => this._dataNotFound(),
572
581
  () => this._dataHasWrongType(),
573
582
  // Check table cfg
574
- () => this._tableCfgsReferencedTableNameNotFound(),
575
- () => this._tableCfgsHaveWrongType(),
583
+ () => this.tableCfgsReferencedTableNameNotFound(),
584
+ () => this.tableCfgsHaveWrongType(),
576
585
  () => this._tableCfgNotFound(),
577
586
  () => this._missingColumnConfigs(),
578
587
  () => this._dataDoesNotMatchColumnConfig(),
@@ -695,8 +704,8 @@ class _BaseValidator {
695
704
  }
696
705
  }
697
706
  // ...........................................................................
698
- _tableCfgsReferencedTableNameNotFound() {
699
- const tableCfgs = this.rljson._tableCfgs;
707
+ tableCfgsReferencedTableNameNotFound() {
708
+ const tableCfgs = this.rljson.tableCfgs;
700
709
  if (!tableCfgs) {
701
710
  return;
702
711
  }
@@ -712,14 +721,14 @@ class _BaseValidator {
712
721
  }
713
722
  if (brokenCfgs.length > 0) {
714
723
  this.errors.tableCfgsReferencedTableNameNotFound = {
715
- error: "Tables referenced in _tableCfgs not found",
724
+ error: "Tables referenced in tableCfgs not found",
716
725
  brokenCfgs
717
726
  };
718
727
  }
719
728
  }
720
729
  // ...........................................................................
721
- _tableCfgsHaveWrongType() {
722
- const tableCfgs = this.rljson._tableCfgs;
730
+ tableCfgsHaveWrongType() {
731
+ const tableCfgs = this.rljson.tableCfgs;
723
732
  if (!tableCfgs) {
724
733
  return;
725
734
  }
@@ -748,7 +757,7 @@ class _BaseValidator {
748
757
  }
749
758
  // ...........................................................................
750
759
  _tableCfgNotFound() {
751
- const tableCfgs = this.rljsonIndexed._tableCfgs;
760
+ const tableCfgs = this.rljsonIndexed.tableCfgs;
752
761
  const tableCfgNotFound = [];
753
762
  iterateTables(this.rljson, (tableName, table) => {
754
763
  const tableCfgRef = table._tableCfg;
@@ -773,7 +782,7 @@ class _BaseValidator {
773
782
  }
774
783
  // ...........................................................................
775
784
  _missingColumnConfigs() {
776
- const tableCfgs = this.rljsonIndexed._tableCfgs;
785
+ const tableCfgs = this.rljsonIndexed.tableCfgs;
777
786
  const missingColumnConfigs = [];
778
787
  iterateTables(this.rljson, (tableName, table) => {
779
788
  const tableCfgRef = table._tableCfg;
@@ -790,7 +799,8 @@ class _BaseValidator {
790
799
  (key) => processedColumnKeys.indexOf(key) === -1
791
800
  );
792
801
  for (const columnKey of newColumnKey) {
793
- if (!tableCfgData.columns[columnKey]) {
802
+ const columns = tableCfgData.columns;
803
+ if (!columns[columnKey]) {
794
804
  missingColumnConfigs.push({
795
805
  tableCfg: tableCfgRef,
796
806
  row: row._hash,
@@ -811,7 +821,7 @@ class _BaseValidator {
811
821
  }
812
822
  // ...........................................................................
813
823
  _dataDoesNotMatchColumnConfig() {
814
- const tableCfgs = this.rljsonIndexed._tableCfgs;
824
+ const tableCfgs = this.rljsonIndexed.tableCfgs;
815
825
  const brokenValues = [];
816
826
  iterateTables(this.rljson, (tableName, table) => {
817
827
  const tableCfgRef = table._tableCfg;
@@ -824,7 +834,8 @@ class _BaseValidator {
824
834
  (key) => !key.startsWith("_")
825
835
  );
826
836
  for (const columnKey of columnKeys) {
827
- const columnConfig = tableCfgData.columns[columnKey];
837
+ const columns = tableCfgData.columns;
838
+ const columnConfig = columns[columnKey];
828
839
  const value = row[columnKey];
829
840
  if (value == null || value == void 0) {
830
841
  continue;
@@ -946,7 +957,7 @@ class _BaseValidator {
946
957
  if (table._type !== "collections") {
947
958
  return;
948
959
  }
949
- const idSets = this.rljsonIndexed._idSets;
960
+ const idSets = this.rljsonIndexed.idSets;
950
961
  const collectionsTable = table;
951
962
  for (const collection of collectionsTable._data) {
952
963
  const idSetRef = collection.idSet;
@@ -1026,7 +1037,7 @@ class _BaseValidator {
1026
1037
  if (table._type !== "cakes") {
1027
1038
  return;
1028
1039
  }
1029
- const idSets = this.rljsonIndexed._idSets;
1040
+ const idSets = this.rljsonIndexed.idSets;
1030
1041
  const cakesTable = table;
1031
1042
  for (const cake of cakesTable._data) {
1032
1043
  const idSetRef = cake.idSet;
@@ -97,7 +97,7 @@ export class Example {
97
97
  };
98
98
 
99
99
  const result: Rljson = {
100
- _tableCfgs: tableCfgs,
100
+ tableCfgs: tableCfgs,
101
101
  table: {
102
102
  _type: 'properties',
103
103
  _tableCfg: 'R-rCQ4YwYYJAp6uAo6S_6n',
@@ -166,7 +166,7 @@ export class Example {
166
166
  },
167
167
  complete: (): Rljson => {
168
168
  return {
169
- _idSets: {
169
+ idSets: {
170
170
  _type: 'idSets',
171
171
 
172
172
  _data: [
@@ -312,7 +312,7 @@ export class Example {
312
312
  tableCfg: {
313
313
  wrongType: () => {
314
314
  const result = Example.ok.singleRow();
315
- const tableCfg = result._tableCfgs._data[0];
315
+ const tableCfg = result.tableCfgs._data[0];
316
316
  tableCfg.columns['int'].type = 'numberBroken'; // Break one of the types
317
317
  return hip(result, true, false);
318
318
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/rljson",
3
- "version": "0.0.18",
3
+ "version": "0.0.21",
4
4
  "packageManager": "pnpm@10.6.3",
5
5
  "description": "The RLJSON data format specification",
6
6
  "homepage": "https://github.com/rljson/rljson",
@@ -29,19 +29,19 @@
29
29
  "updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^22.13.10",
33
- "@typescript-eslint/eslint-plugin": "^8.26.1",
34
- "@typescript-eslint/parser": "^8.26.1",
32
+ "@types/node": "^22.13.11",
33
+ "@typescript-eslint/eslint-plugin": "^8.27.0",
34
+ "@typescript-eslint/parser": "^8.27.0",
35
35
  "@vitest/coverage-v8": "^3.0.9",
36
36
  "cross-env": "^7.0.3",
37
- "eslint": "^9.22.0",
37
+ "eslint": "^9.23.0",
38
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
- "typescript-eslint": "^8.26.1",
44
+ "typescript-eslint": "^8.27.0",
45
45
  "vite": "^6.2.2",
46
46
  "vite-node": "^3.0.9",
47
47
  "vite-plugin-dts": "^4.5.3",