@rljson/rljson 0.0.10 → 0.0.12
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 +29 -2
- package/dist/index.d.ts +7 -0
- package/dist/rljson.d.ts +17 -162
- package/dist/rljson.js +223 -35
- package/dist/src/example.ts +140 -8
- package/dist/typedefs.d.ts +30 -0
- package/package.json +4 -4
package/README.contributors.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
7
|
-->
|
|
8
8
|
|
|
9
9
|
# Contributors Guide
|
|
10
10
|
|
|
11
11
|
- [Install](#install)
|
|
12
|
-
- [
|
|
12
|
+
- [Checkout](#checkout)
|
|
13
13
|
- [Install pnpm](#install-pnpm)
|
|
14
14
|
- [Install dependencies](#install-dependencies)
|
|
15
15
|
- [Install Vscode extensions](#install-vscode-extensions)
|
|
@@ -20,13 +20,16 @@
|
|
|
20
20
|
- [Debug](#debug)
|
|
21
21
|
- [Update goldens](#update-goldens)
|
|
22
22
|
- [Test and Build](#test-and-build)
|
|
23
|
+
- [Rename classes](#rename-classes)
|
|
23
24
|
- [Workflow](#workflow)
|
|
25
|
+
- [Set a PR title](#set-a-pr-title)
|
|
24
26
|
- [Checkout main](#checkout-main)
|
|
25
|
-
- [Create a branch](#create-a-branch)
|
|
26
|
-
- [Commit](#commit)
|
|
27
|
+
- [Create a feature branch](#create-a-feature-branch)
|
|
27
28
|
- [Update dependencies](#update-dependencies)
|
|
29
|
+
- [Debug and develop](#debug-and-develop)
|
|
30
|
+
- [Commit](#commit)
|
|
28
31
|
- [Increase version](#increase-version)
|
|
29
|
-
- [
|
|
32
|
+
- [Build](#build)
|
|
30
33
|
- [Create a pull request](#create-a-pull-request)
|
|
31
34
|
- [Wait until PR is merged](#wait-until-pr-is-merged)
|
|
32
35
|
- [Delete feature branch](#delete-feature-branch)
|
|
@@ -39,13 +42,13 @@
|
|
|
39
42
|
|
|
40
43
|
## Install
|
|
41
44
|
|
|
42
|
-
###
|
|
45
|
+
### Checkout
|
|
43
46
|
|
|
44
47
|
```bash
|
|
45
48
|
mkdir rljson
|
|
46
49
|
cd rljson
|
|
47
50
|
git clone https://github.com/rljson/rljson.git
|
|
48
|
-
cd
|
|
51
|
+
cd rljson
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
### Install pnpm
|
|
@@ -136,102 +139,156 @@ pnpm updateGoldens
|
|
|
136
139
|
### Test and Build
|
|
137
140
|
|
|
138
141
|
```bash
|
|
139
|
-
pnpm test
|
|
142
|
+
pnpm test
|
|
140
143
|
pnpm build
|
|
141
144
|
```
|
|
142
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
|
+
|
|
143
194
|
<!-- ........................................................................-->
|
|
144
195
|
|
|
145
196
|
## Workflow
|
|
146
197
|
|
|
198
|
+
### Set a PR title
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
export PR_TITLE="PR Title"
|
|
202
|
+
```
|
|
203
|
+
|
|
147
204
|
### Checkout main
|
|
148
205
|
|
|
149
206
|
```bash
|
|
150
|
-
git checkout main
|
|
151
|
-
git fetch
|
|
207
|
+
git checkout main
|
|
208
|
+
git fetch
|
|
152
209
|
git pull
|
|
153
210
|
```
|
|
154
211
|
|
|
155
|
-
### Create a branch
|
|
156
|
-
|
|
157
|
-
Please replace `Commit Message` in the next command by your commit message.
|
|
158
|
-
It will also used for branch name and pull request
|
|
212
|
+
### Create a feature branch
|
|
159
213
|
|
|
160
214
|
```bash
|
|
161
|
-
export
|
|
162
|
-
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
215
|
+
export BRANCH=`echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'`
|
|
163
216
|
git checkout -b $BRANCH
|
|
164
217
|
```
|
|
165
218
|
|
|
166
|
-
###
|
|
167
|
-
|
|
168
|
-
Develop your feature
|
|
169
|
-
|
|
170
|
-
Commit your changes
|
|
171
|
-
|
|
172
|
-
If you only have one thing, execute
|
|
219
|
+
### Update dependencies
|
|
173
220
|
|
|
174
221
|
```bash
|
|
175
|
-
|
|
222
|
+
pnpm update --latest
|
|
223
|
+
git commit -am"Update dependencies"
|
|
176
224
|
```
|
|
177
225
|
|
|
178
|
-
###
|
|
226
|
+
### Debug and develop
|
|
227
|
+
|
|
228
|
+
Debug and develop
|
|
229
|
+
|
|
230
|
+
### Commit
|
|
179
231
|
|
|
180
|
-
|
|
232
|
+
If you only have one thing changed, execute
|
|
181
233
|
|
|
182
234
|
```bash
|
|
183
|
-
|
|
184
|
-
git commit -m"Update dependencies"
|
|
235
|
+
git add . && git commit -m "$PR_TITLE"
|
|
185
236
|
```
|
|
186
237
|
|
|
187
238
|
### Increase version
|
|
188
239
|
|
|
189
240
|
```bash
|
|
190
|
-
pnpm version patch --no-git-tag-version
|
|
241
|
+
pnpm version patch --no-git-tag-version
|
|
191
242
|
git commit -am"Increase version"
|
|
192
243
|
```
|
|
193
244
|
|
|
194
|
-
###
|
|
195
|
-
|
|
196
|
-
Use your ID or this git command to push the branch
|
|
245
|
+
### Build
|
|
197
246
|
|
|
198
247
|
```bash
|
|
199
|
-
|
|
248
|
+
npm run build
|
|
200
249
|
```
|
|
201
250
|
|
|
202
251
|
### Create a pull request
|
|
203
252
|
|
|
204
253
|
```bash
|
|
205
|
-
|
|
254
|
+
git push -u origin $BRANCH
|
|
255
|
+
gh pr create --base main --title "$PR_TITLE" --body ""
|
|
206
256
|
gh pr merge --auto --squash
|
|
207
257
|
```
|
|
208
258
|
|
|
209
259
|
### Wait until PR is merged
|
|
210
260
|
|
|
211
|
-
Get the PR URL with the following command
|
|
212
|
-
|
|
213
261
|
```bash
|
|
214
262
|
echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
|
|
215
|
-
echo "
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
|
219
276
|
```
|
|
220
277
|
|
|
221
278
|
### Delete feature branch
|
|
222
279
|
|
|
223
280
|
```bash
|
|
224
|
-
git fetch && git checkout main
|
|
225
|
-
git reset --soft origin/main
|
|
226
|
-
git stash -m"PR Aftermath"
|
|
227
|
-
git pull
|
|
281
|
+
git fetch && git checkout main
|
|
282
|
+
git reset --soft origin/main
|
|
283
|
+
git stash -m"PR Aftermath"
|
|
284
|
+
git pull
|
|
228
285
|
git branch -d $BRANCH
|
|
229
286
|
```
|
|
230
287
|
|
|
231
288
|
### Publish to NPM
|
|
232
289
|
|
|
233
290
|
```bash
|
|
234
|
-
npm publish --access public
|
|
291
|
+
npm publish --access public
|
|
235
292
|
git tag $(npm pkg get version | tr -d '\\"')
|
|
236
293
|
```
|
|
237
294
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
7
|
-->
|
|
8
8
|
|
|
9
9
|
# Contributors Guide
|
|
10
10
|
|
|
11
11
|
- [Install](#install)
|
|
12
|
-
- [
|
|
12
|
+
- [Checkout](#checkout)
|
|
13
13
|
- [Install pnpm](#install-pnpm)
|
|
14
14
|
- [Install dependencies](#install-dependencies)
|
|
15
15
|
- [Install Vscode extensions](#install-vscode-extensions)
|
|
@@ -20,13 +20,16 @@
|
|
|
20
20
|
- [Debug](#debug)
|
|
21
21
|
- [Update goldens](#update-goldens)
|
|
22
22
|
- [Test and Build](#test-and-build)
|
|
23
|
+
- [Rename classes](#rename-classes)
|
|
23
24
|
- [Workflow](#workflow)
|
|
25
|
+
- [Set a PR title](#set-a-pr-title)
|
|
24
26
|
- [Checkout main](#checkout-main)
|
|
25
|
-
- [Create a branch](#create-a-branch)
|
|
26
|
-
- [Commit](#commit)
|
|
27
|
+
- [Create a feature branch](#create-a-feature-branch)
|
|
27
28
|
- [Update dependencies](#update-dependencies)
|
|
29
|
+
- [Debug and develop](#debug-and-develop)
|
|
30
|
+
- [Commit](#commit)
|
|
28
31
|
- [Increase version](#increase-version)
|
|
29
|
-
- [
|
|
32
|
+
- [Build](#build)
|
|
30
33
|
- [Create a pull request](#create-a-pull-request)
|
|
31
34
|
- [Wait until PR is merged](#wait-until-pr-is-merged)
|
|
32
35
|
- [Delete feature branch](#delete-feature-branch)
|
|
@@ -39,13 +42,13 @@
|
|
|
39
42
|
|
|
40
43
|
## Install
|
|
41
44
|
|
|
42
|
-
###
|
|
45
|
+
### Checkout
|
|
43
46
|
|
|
44
47
|
```bash
|
|
45
48
|
mkdir rljson
|
|
46
49
|
cd rljson
|
|
47
50
|
git clone https://github.com/rljson/rljson.git
|
|
48
|
-
cd
|
|
51
|
+
cd rljson
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
### Install pnpm
|
|
@@ -136,102 +139,156 @@ pnpm updateGoldens
|
|
|
136
139
|
### Test and Build
|
|
137
140
|
|
|
138
141
|
```bash
|
|
139
|
-
pnpm test
|
|
142
|
+
pnpm test
|
|
140
143
|
pnpm build
|
|
141
144
|
```
|
|
142
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
|
+
|
|
143
194
|
<!-- ........................................................................-->
|
|
144
195
|
|
|
145
196
|
## Workflow
|
|
146
197
|
|
|
198
|
+
### Set a PR title
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
export PR_TITLE="PR Title"
|
|
202
|
+
```
|
|
203
|
+
|
|
147
204
|
### Checkout main
|
|
148
205
|
|
|
149
206
|
```bash
|
|
150
|
-
git checkout main
|
|
151
|
-
git fetch
|
|
207
|
+
git checkout main
|
|
208
|
+
git fetch
|
|
152
209
|
git pull
|
|
153
210
|
```
|
|
154
211
|
|
|
155
|
-
### Create a branch
|
|
156
|
-
|
|
157
|
-
Please replace `Commit Message` in the next command by your commit message.
|
|
158
|
-
It will also used for branch name and pull request
|
|
212
|
+
### Create a feature branch
|
|
159
213
|
|
|
160
214
|
```bash
|
|
161
|
-
export
|
|
162
|
-
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
215
|
+
export BRANCH=`echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'`
|
|
163
216
|
git checkout -b $BRANCH
|
|
164
217
|
```
|
|
165
218
|
|
|
166
|
-
###
|
|
167
|
-
|
|
168
|
-
Develop your feature
|
|
169
|
-
|
|
170
|
-
Commit your changes
|
|
171
|
-
|
|
172
|
-
If you only have one thing, execute
|
|
219
|
+
### Update dependencies
|
|
173
220
|
|
|
174
221
|
```bash
|
|
175
|
-
|
|
222
|
+
pnpm update --latest
|
|
223
|
+
git commit -am"Update dependencies"
|
|
176
224
|
```
|
|
177
225
|
|
|
178
|
-
###
|
|
226
|
+
### Debug and develop
|
|
227
|
+
|
|
228
|
+
Debug and develop
|
|
229
|
+
|
|
230
|
+
### Commit
|
|
179
231
|
|
|
180
|
-
|
|
232
|
+
If you only have one thing changed, execute
|
|
181
233
|
|
|
182
234
|
```bash
|
|
183
|
-
|
|
184
|
-
git commit -m"Update dependencies"
|
|
235
|
+
git add . && git commit -m "$PR_TITLE"
|
|
185
236
|
```
|
|
186
237
|
|
|
187
238
|
### Increase version
|
|
188
239
|
|
|
189
240
|
```bash
|
|
190
|
-
pnpm version patch --no-git-tag-version
|
|
241
|
+
pnpm version patch --no-git-tag-version
|
|
191
242
|
git commit -am"Increase version"
|
|
192
243
|
```
|
|
193
244
|
|
|
194
|
-
###
|
|
195
|
-
|
|
196
|
-
Use your ID or this git command to push the branch
|
|
245
|
+
### Build
|
|
197
246
|
|
|
198
247
|
```bash
|
|
199
|
-
|
|
248
|
+
npm run build
|
|
200
249
|
```
|
|
201
250
|
|
|
202
251
|
### Create a pull request
|
|
203
252
|
|
|
204
253
|
```bash
|
|
205
|
-
|
|
254
|
+
git push -u origin $BRANCH
|
|
255
|
+
gh pr create --base main --title "$PR_TITLE" --body ""
|
|
206
256
|
gh pr merge --auto --squash
|
|
207
257
|
```
|
|
208
258
|
|
|
209
259
|
### Wait until PR is merged
|
|
210
260
|
|
|
211
|
-
Get the PR URL with the following command
|
|
212
|
-
|
|
213
261
|
```bash
|
|
214
262
|
echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
|
|
215
|
-
echo "
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
|
219
276
|
```
|
|
220
277
|
|
|
221
278
|
### Delete feature branch
|
|
222
279
|
|
|
223
280
|
```bash
|
|
224
|
-
git fetch && git checkout main
|
|
225
|
-
git reset --soft origin/main
|
|
226
|
-
git stash -m"PR Aftermath"
|
|
227
|
-
git pull
|
|
281
|
+
git fetch && git checkout main
|
|
282
|
+
git reset --soft origin/main
|
|
283
|
+
git stash -m"PR Aftermath"
|
|
284
|
+
git pull
|
|
228
285
|
git branch -d $BRANCH
|
|
229
286
|
```
|
|
230
287
|
|
|
231
288
|
### Publish to NPM
|
|
232
289
|
|
|
233
290
|
```bash
|
|
234
|
-
npm publish --access public
|
|
291
|
+
npm publish --access public
|
|
235
292
|
git tag $(npm pkg get version | tr -d '\\"')
|
|
236
293
|
```
|
|
237
294
|
|
package/dist/example.d.ts
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
+
import { Rljson } from './rljson.ts';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Provides Rljson examples
|
|
3
4
|
*/
|
|
4
|
-
export declare
|
|
5
|
+
export declare class Example {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the Rljson bakery example
|
|
8
|
+
*/
|
|
9
|
+
static bakery(): Rljson;
|
|
10
|
+
/**
|
|
11
|
+
* Returns an Rljson object with one row containing all JSON types
|
|
12
|
+
*/
|
|
13
|
+
static withAllJsonTypes(): Rljson;
|
|
14
|
+
/**
|
|
15
|
+
* Returns an empty Rljson object
|
|
16
|
+
*/
|
|
17
|
+
static empty(): Rljson;
|
|
18
|
+
/**
|
|
19
|
+
* Returns an Rljson with a table containing all combinations of true and
|
|
20
|
+
* false. This is useful for testing search operators.
|
|
21
|
+
*/
|
|
22
|
+
static binary(): Rljson;
|
|
23
|
+
/**
|
|
24
|
+
* An more complex example containing an table with multiple rows
|
|
25
|
+
*/
|
|
26
|
+
static multiRow(): Rljson;
|
|
27
|
+
/**
|
|
28
|
+
* Returns an Rljson object with a broken table name
|
|
29
|
+
*/
|
|
30
|
+
static withBrokenTableName(): Rljson;
|
|
31
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
+
export * from './content/buffet.ts';
|
|
2
|
+
export * from './content/cake.ts';
|
|
3
|
+
export * from './content/collection.ts';
|
|
4
|
+
export * from './content/id-set.ts';
|
|
5
|
+
export * from './content/properties.ts';
|
|
6
|
+
export * from './example.ts';
|
|
1
7
|
export * from './rljson.ts';
|
|
8
|
+
export * from './typedefs.ts';
|
package/dist/rljson.d.ts
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
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, 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
|
|
11
|
+
* One of the supported Rljson table types
|
|
24
12
|
*/
|
|
25
|
-
export type
|
|
13
|
+
export type TableType = BuffetsTable | PropertiesTable<any> | CollectionsTable | IdSetsTable | CakesTable;
|
|
14
|
+
/** The rljson data format */
|
|
15
|
+
export type Rljson = {
|
|
16
|
+
[tableId: TableName]: TableType;
|
|
17
|
+
};
|
|
18
|
+
/** An example rljson object */
|
|
19
|
+
export declare const exampleRljson: () => Rljson;
|
|
26
20
|
/** A table in the rljson format */
|
|
27
21
|
export interface RljsonTable<Data extends Json, Type extends ContentType> extends Json {
|
|
28
22
|
/** The data rows of the table */
|
|
@@ -30,142 +24,3 @@ export interface RljsonTable<Data extends Json, Type extends ContentType> extend
|
|
|
30
24
|
/** The type of the table */
|
|
31
25
|
_type: Type;
|
|
32
26
|
}
|
|
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
|
|
73
|
-
*/
|
|
74
|
-
export interface Collection extends Json {
|
|
75
|
-
/**
|
|
76
|
-
* `base` an optional base collection that is extended by this collection
|
|
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>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* A table containing collections
|
|
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.
|
|
113
|
-
*/
|
|
114
|
-
export interface Cake extends Json {
|
|
115
|
-
/**
|
|
116
|
-
* The table containing the item ids of the cake
|
|
117
|
-
*/
|
|
118
|
-
itemIdsTable: TableName;
|
|
119
|
-
/**
|
|
120
|
-
* All layers of a cake share the same item ids.
|
|
121
|
-
*/
|
|
122
|
-
itemIds: IdSetRef;
|
|
123
|
-
/**
|
|
124
|
-
* The table containing the layers of this cake
|
|
125
|
-
*/
|
|
126
|
-
layersTable: TableName;
|
|
127
|
-
/**
|
|
128
|
-
* Assigns a collection to each layer of the cake.
|
|
129
|
-
*/
|
|
130
|
-
layers: {
|
|
131
|
-
[layerId: CakeLayerId]: CollectionRef;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* A table containing cakes
|
|
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
|
-
}>;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* A table containing buffets
|
|
158
|
-
*/
|
|
159
|
-
export type BuffetsTable = RljsonTable<Buffet, 'buffet'>;
|
|
160
|
-
/**
|
|
161
|
-
* One of the supported Rljson table types
|
|
162
|
-
*/
|
|
163
|
-
export type TableType = BuffetsTable | PropertiesTable | CollectionsTable | IdSetsTable | CakesTable;
|
|
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 exampleRljsonEmpty: () => Rljson;
|
|
170
|
-
export declare const exampleRljsonWithErrors: () => Rljson;
|
|
171
|
-
export declare const exampleRljsonWithMultipleRows: () => Rljson;
|
package/dist/rljson.js
CHANGED
|
@@ -1,49 +1,237 @@
|
|
|
1
1
|
import { exampleJsonObject } from "@rljson/json";
|
|
2
2
|
// @license
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
_type: "
|
|
6
|
-
_data: [exampleJsonObject()]
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
const exampleRljsonEmpty = () => ({});
|
|
10
|
-
const exampleRljsonWithErrors = () => ({
|
|
11
|
-
brok$en: {
|
|
12
|
-
_type: "properties",
|
|
13
|
-
_data: []
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const exampleRljsonWithMultipleRows = () => ({
|
|
17
|
-
table: {
|
|
18
|
-
_type: "properties",
|
|
3
|
+
const bakeryExample = {
|
|
4
|
+
buffets: {
|
|
5
|
+
_type: "buffets",
|
|
19
6
|
_data: [
|
|
7
|
+
// Counter
|
|
20
8
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
items: [
|
|
10
|
+
// Angle pie
|
|
11
|
+
{
|
|
12
|
+
table: "cakes",
|
|
13
|
+
ref: "ap"
|
|
14
|
+
},
|
|
15
|
+
// Cumb cake
|
|
16
|
+
{
|
|
17
|
+
table: "cakes",
|
|
18
|
+
ref: "cc"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
26
21
|
},
|
|
22
|
+
// Fridge
|
|
27
23
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
id: "fridge",
|
|
25
|
+
items: [
|
|
26
|
+
// Black forest cake
|
|
27
|
+
{
|
|
28
|
+
table: "cakes",
|
|
29
|
+
ref: "bfc"
|
|
30
|
+
},
|
|
31
|
+
// Lemon cheese cake
|
|
32
|
+
{
|
|
33
|
+
table: "cakes",
|
|
34
|
+
ref: "lcc"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
cakes: {
|
|
41
|
+
_type: "cakes",
|
|
42
|
+
_data: []
|
|
43
|
+
},
|
|
44
|
+
layers: {
|
|
45
|
+
_type: "collections",
|
|
46
|
+
_data: []
|
|
47
|
+
},
|
|
48
|
+
sliceIds: {
|
|
49
|
+
_type: "idSets",
|
|
50
|
+
_data: [
|
|
34
51
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
base: null,
|
|
53
|
+
add: [
|
|
54
|
+
"slice0",
|
|
55
|
+
"slice1",
|
|
56
|
+
"slice2",
|
|
57
|
+
"slice3",
|
|
58
|
+
"slice4",
|
|
59
|
+
"slice5",
|
|
60
|
+
"slice6",
|
|
61
|
+
"slice7",
|
|
62
|
+
"slice8",
|
|
63
|
+
"slice9",
|
|
64
|
+
"slice10",
|
|
65
|
+
"slice11"
|
|
66
|
+
],
|
|
67
|
+
remove: []
|
|
40
68
|
}
|
|
41
69
|
]
|
|
70
|
+
},
|
|
71
|
+
nutritiveValues: {
|
|
72
|
+
_type: "properties",
|
|
73
|
+
_data: []
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// @license
|
|
77
|
+
const exampleBuffetsTable = bakeryExample.buffets;
|
|
78
|
+
// @license
|
|
79
|
+
const exampleCakesTable = Object.freeze(bakeryExample.cakes);
|
|
80
|
+
// @license
|
|
81
|
+
const exampleCollectionsTable = Object.freeze(
|
|
82
|
+
bakeryExample.layers
|
|
83
|
+
);
|
|
84
|
+
// @license
|
|
85
|
+
const exampleIdSetsTable = Object.freeze(bakeryExample.sliceIds);
|
|
86
|
+
// @license
|
|
87
|
+
const examplePropertiesTable = Object.freeze(bakeryExample.nutritiveValues);
|
|
88
|
+
// @license
|
|
89
|
+
class Example {
|
|
90
|
+
/**
|
|
91
|
+
* Returns the Rljson bakery example
|
|
92
|
+
*/
|
|
93
|
+
static bakery() {
|
|
94
|
+
return {
|
|
95
|
+
// A bakery is a collection of buffets
|
|
96
|
+
bakery: {
|
|
97
|
+
name: "Bakery",
|
|
98
|
+
_type: "buffets",
|
|
99
|
+
_data: [
|
|
100
|
+
// Counter
|
|
101
|
+
{
|
|
102
|
+
id: "counter",
|
|
103
|
+
items: [
|
|
104
|
+
// Angle pie
|
|
105
|
+
{
|
|
106
|
+
table: "cakes",
|
|
107
|
+
ref: "ap"
|
|
108
|
+
},
|
|
109
|
+
// Cumb cake
|
|
110
|
+
{
|
|
111
|
+
table: "cakes",
|
|
112
|
+
ref: "cc"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
// Fridge
|
|
117
|
+
{
|
|
118
|
+
id: "fridge",
|
|
119
|
+
items: [
|
|
120
|
+
// Black forest
|
|
121
|
+
{
|
|
122
|
+
table: "cakes",
|
|
123
|
+
ref: "bf"
|
|
124
|
+
},
|
|
125
|
+
// Lemon cheese cake
|
|
126
|
+
{
|
|
127
|
+
table: "cakes",
|
|
128
|
+
ref: "cc"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Returns an Rljson object with one row containing all JSON types
|
|
138
|
+
*/
|
|
139
|
+
static withAllJsonTypes() {
|
|
140
|
+
return {
|
|
141
|
+
table: {
|
|
142
|
+
_type: "properties",
|
|
143
|
+
_data: [exampleJsonObject()]
|
|
144
|
+
}
|
|
145
|
+
};
|
|
42
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Returns an empty Rljson object
|
|
149
|
+
*/
|
|
150
|
+
static empty() {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns an Rljson with a table containing all combinations of true and
|
|
155
|
+
* false. This is useful for testing search operators.
|
|
156
|
+
*/
|
|
157
|
+
static binary() {
|
|
158
|
+
return {
|
|
159
|
+
table: {
|
|
160
|
+
_type: "properties",
|
|
161
|
+
_data: [
|
|
162
|
+
{ a: false, b: false },
|
|
163
|
+
{ a: false, b: true },
|
|
164
|
+
{ a: true, b: false },
|
|
165
|
+
{ a: true, b: true }
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* An more complex example containing an table with multiple rows
|
|
172
|
+
*/
|
|
173
|
+
static multiRow() {
|
|
174
|
+
return {
|
|
175
|
+
table: {
|
|
176
|
+
_type: "properties",
|
|
177
|
+
_data: [
|
|
178
|
+
{
|
|
179
|
+
string: "str0",
|
|
180
|
+
boolean: true,
|
|
181
|
+
number: 1,
|
|
182
|
+
array: [1, "str0", true, { a: { b: "c" } }],
|
|
183
|
+
object: { a: { b: "c" } }
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
string: "str1",
|
|
187
|
+
boolean: true,
|
|
188
|
+
number: 1,
|
|
189
|
+
array: [1, "str1", true, { a: { b: "c" } }],
|
|
190
|
+
object: { a: { b: "c" } }
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
string: "str2",
|
|
194
|
+
boolean: false,
|
|
195
|
+
number: 1,
|
|
196
|
+
array: [1, "str1", true, { a: { b: "c" } }],
|
|
197
|
+
object: { d: { e: "f" } }
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns an Rljson object with a broken table name
|
|
205
|
+
*/
|
|
206
|
+
static withBrokenTableName() {
|
|
207
|
+
return {
|
|
208
|
+
brok$en: {
|
|
209
|
+
_type: "properties",
|
|
210
|
+
_data: []
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// @license
|
|
216
|
+
const reservedFieldNames = ["_type", "_data"];
|
|
217
|
+
const reservedTableNames = ["_hash", "_tables", "_columns"];
|
|
218
|
+
const exampleRljson = () => Example.withAllJsonTypes();
|
|
219
|
+
// @license
|
|
220
|
+
const exampleTypedefs = Object.freeze({
|
|
221
|
+
ref: "ref",
|
|
222
|
+
itemId: "itemId",
|
|
223
|
+
tableName: "tableName",
|
|
224
|
+
contentType: "collections"
|
|
43
225
|
});
|
|
44
226
|
export {
|
|
227
|
+
Example,
|
|
228
|
+
exampleBuffetsTable,
|
|
229
|
+
exampleCakesTable,
|
|
230
|
+
exampleCollectionsTable,
|
|
231
|
+
exampleIdSetsTable,
|
|
232
|
+
examplePropertiesTable,
|
|
45
233
|
exampleRljson,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
234
|
+
exampleTypedefs,
|
|
235
|
+
reservedFieldNames,
|
|
236
|
+
reservedTableNames
|
|
49
237
|
};
|
package/dist/src/example.ts
CHANGED
|
@@ -4,15 +4,147 @@
|
|
|
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 {
|
|
7
|
+
import { exampleJsonObject } from '@rljson/json';
|
|
8
|
+
|
|
9
|
+
import { BuffetsTable } from './content/buffet.ts';
|
|
10
|
+
import { Rljson } from './rljson.ts';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* Provides Rljson examples
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
export class Example {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the Rljson bakery example
|
|
18
|
+
*/
|
|
19
|
+
static bakery(): Rljson {
|
|
20
|
+
return {
|
|
21
|
+
// A bakery is a collection of buffets
|
|
22
|
+
bakery: {
|
|
23
|
+
name: 'Bakery',
|
|
24
|
+
_type: 'buffets',
|
|
25
|
+
_data: [
|
|
26
|
+
// Counter
|
|
27
|
+
{
|
|
28
|
+
id: 'counter',
|
|
29
|
+
items: [
|
|
30
|
+
// Angle pie
|
|
31
|
+
{
|
|
32
|
+
table: 'cakes',
|
|
33
|
+
ref: 'ap',
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// Cumb cake
|
|
37
|
+
{
|
|
38
|
+
table: 'cakes',
|
|
39
|
+
ref: 'cc',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// Fridge
|
|
45
|
+
{
|
|
46
|
+
id: 'fridge',
|
|
47
|
+
items: [
|
|
48
|
+
// Black forest
|
|
49
|
+
{
|
|
50
|
+
table: 'cakes',
|
|
51
|
+
ref: 'bf',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Lemon cheese cake
|
|
55
|
+
{
|
|
56
|
+
table: 'cakes',
|
|
57
|
+
ref: 'cc',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
} as BuffetsTable,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns an Rljson object with one row containing all JSON types
|
|
68
|
+
*/
|
|
69
|
+
static withAllJsonTypes(): Rljson {
|
|
70
|
+
return {
|
|
71
|
+
table: {
|
|
72
|
+
_type: 'properties',
|
|
73
|
+
_data: [exampleJsonObject()],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns an empty Rljson object
|
|
80
|
+
*/
|
|
81
|
+
static empty(): Rljson {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns an Rljson with a table containing all combinations of true and
|
|
87
|
+
* false. This is useful for testing search operators.
|
|
88
|
+
*/
|
|
89
|
+
static binary(): Rljson {
|
|
90
|
+
return {
|
|
91
|
+
table: {
|
|
92
|
+
_type: 'properties',
|
|
93
|
+
_data: [
|
|
94
|
+
{ a: false, b: false },
|
|
95
|
+
{ a: false, b: true },
|
|
96
|
+
{ a: true, b: false },
|
|
97
|
+
{ a: true, b: true },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* An more complex example containing an table with multiple rows
|
|
105
|
+
*/
|
|
106
|
+
static multiRow(): Rljson {
|
|
107
|
+
return {
|
|
108
|
+
table: {
|
|
109
|
+
_type: 'properties',
|
|
110
|
+
_data: [
|
|
111
|
+
{
|
|
112
|
+
string: 'str0',
|
|
113
|
+
boolean: true,
|
|
114
|
+
number: 1,
|
|
115
|
+
array: [1, 'str0', true, { a: { b: 'c' } }],
|
|
116
|
+
object: { a: { b: 'c' } },
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
string: 'str1',
|
|
121
|
+
boolean: true,
|
|
122
|
+
number: 1,
|
|
123
|
+
array: [1, 'str1', true, { a: { b: 'c' } }],
|
|
124
|
+
object: { a: { b: 'c' } },
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
{
|
|
128
|
+
string: 'str2',
|
|
129
|
+
boolean: false,
|
|
130
|
+
number: 1,
|
|
131
|
+
array: [1, 'str1', true, { a: { b: 'c' } }],
|
|
132
|
+
object: { d: { e: 'f' } },
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
15
138
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Returns an Rljson object with a broken table name
|
|
141
|
+
*/
|
|
142
|
+
static withBrokenTableName(): Rljson {
|
|
143
|
+
return {
|
|
144
|
+
brok$en: {
|
|
145
|
+
_type: 'properties',
|
|
146
|
+
_data: [],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
export declare const exampleTypedefs: {
|
|
26
|
+
ref: Ref;
|
|
27
|
+
itemId: ItemId;
|
|
28
|
+
tableName: TableName;
|
|
29
|
+
contentType: ContentType;
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/rljson",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"packageManager": "pnpm@10.6.2",
|
|
5
5
|
"description": "The RLJSON data format specification",
|
|
6
6
|
"homepage": "https://github.com/rljson/rljson",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"read-pkg": "^9.0.1",
|
|
43
43
|
"typescript": "~5.8.2",
|
|
44
44
|
"typescript-eslint": "^8.26.1",
|
|
45
|
-
"vite": "^6.2.
|
|
45
|
+
"vite": "^6.2.2",
|
|
46
46
|
"vite-node": "^3.0.8",
|
|
47
47
|
"vite-plugin-dts": "^4.5.3",
|
|
48
48
|
"vite-tsconfig-paths": "^5.1.4",
|
|
@@ -50,8 +50,8 @@
|
|
|
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.11",
|
|
54
|
+
"@rljson/json": "^0.0.13"
|
|
55
55
|
},
|
|
56
56
|
"pnpm": {
|
|
57
57
|
"onlyBuiltDependencies": [
|