@rljson/db 0.0.3
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/LICENSE +21 -0
- package/README.architecture.md +1 -0
- package/README.blog.md +3 -0
- package/README.contributors.md +242 -0
- package/README.md +18 -0
- package/README.public.md +7 -0
- package/README.trouble.md +36 -0
- package/dist/README.architecture.md +1 -0
- package/dist/README.blog.md +3 -0
- package/dist/README.contributors.md +242 -0
- package/dist/README.md +18 -0
- package/dist/README.public.md +7 -0
- package/dist/README.trouble.md +36 -0
- package/dist/core.d.ts +37 -0
- package/dist/db.d.ts +22 -0
- package/dist/db.js +99 -0
- package/dist/example.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/src/example.ts +36 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rljson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Architecture
|
package/README.blog.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<!--
|
|
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
|
+
-->
|
|
8
|
+
|
|
9
|
+
# Contributors Guide
|
|
10
|
+
|
|
11
|
+
- [Install](#install)
|
|
12
|
+
- [Check out](#check-out)
|
|
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)
|
|
18
|
+
- [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
|
+
- [Workflow](#workflow)
|
|
24
|
+
- [Checkout main](#checkout-main)
|
|
25
|
+
- [Create a branch](#create-a-branch)
|
|
26
|
+
- [Commit](#commit)
|
|
27
|
+
- [Update dependencies](#update-dependencies)
|
|
28
|
+
- [Increase version](#increase-version)
|
|
29
|
+
- [Create a pull request](#create-a-pull-request)
|
|
30
|
+
- [Wait until PR is merged](#wait-until-pr-is-merged)
|
|
31
|
+
- [Delete feature branch](#delete-feature-branch)
|
|
32
|
+
- [Publish to NPM](#publish-to-npm)
|
|
33
|
+
- [Troubleshooting](#troubleshooting)
|
|
34
|
+
- [Checkout README.trouble.md](#checkout-readmetroublemd)
|
|
35
|
+
- [File issues on GitHub](#file-issues-on-github)
|
|
36
|
+
|
|
37
|
+
<!-- ........................................................................-->
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
### Check out
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir db
|
|
45
|
+
cd db
|
|
46
|
+
git clone https://github.com/rljson/db.git
|
|
47
|
+
cd db
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Install pnpm
|
|
51
|
+
|
|
52
|
+
Windows:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
corepack enable pnpm
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Mac:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
sudo corepack enable pnpm
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Install dependencies
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Install Vscode extensions
|
|
71
|
+
|
|
72
|
+
Open this project in `vscode`.
|
|
73
|
+
|
|
74
|
+
Press `Cmd+Shift+P`.
|
|
75
|
+
|
|
76
|
+
Type `Extensions: Show Recommended Extensions` and press `Enter`.
|
|
77
|
+
|
|
78
|
+
The recommended extensions will be shown.
|
|
79
|
+
|
|
80
|
+
Make sure, all recommended extensions are shown.
|
|
81
|
+
|
|
82
|
+
### Uninstall Jest and Jasmine
|
|
83
|
+
|
|
84
|
+
Jest or Jasmine extensions conflict with the `Vitest` extension used for this
|
|
85
|
+
project.
|
|
86
|
+
|
|
87
|
+
Uninstall them, if you have installed them.
|
|
88
|
+
|
|
89
|
+
### Install GitHub CLI
|
|
90
|
+
|
|
91
|
+
Install GitHub CLI on Mac
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
brew install gh
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Login
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
gh auth login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- ........................................................................-->
|
|
104
|
+
|
|
105
|
+
## Develop
|
|
106
|
+
|
|
107
|
+
### Read architecture doc
|
|
108
|
+
|
|
109
|
+
Read [README.architecture.md](./README.architecture.md) to get an overview
|
|
110
|
+
of the package's architecture.
|
|
111
|
+
|
|
112
|
+
### Debug
|
|
113
|
+
|
|
114
|
+
In Vscode: At the `left side bar` click on the `Test tube` icon to open the `Test explorer`.
|
|
115
|
+
|
|
116
|
+
At the `top`, click on the `refresh` icon to show update the tests.
|
|
117
|
+
|
|
118
|
+
Open a test file (`*.spec.ts`)
|
|
119
|
+
|
|
120
|
+
Set a breakpoint.
|
|
121
|
+
|
|
122
|
+
Press `alt` and click on the play button left beside the test.
|
|
123
|
+
|
|
124
|
+
Execution should stop at the breakpoint.
|
|
125
|
+
|
|
126
|
+
### Update goldens
|
|
127
|
+
|
|
128
|
+
In various tests we are creating golden files, that are reference files that
|
|
129
|
+
are compared against the files created in the tests.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pnpm updateGoldens
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Test and Build
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pnpm test &&\
|
|
139
|
+
pnpm build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
<!-- ........................................................................-->
|
|
143
|
+
|
|
144
|
+
## Workflow
|
|
145
|
+
|
|
146
|
+
### Checkout main
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
git checkout main && \
|
|
150
|
+
git fetch && \
|
|
151
|
+
git pull
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Create a branch
|
|
155
|
+
|
|
156
|
+
Please replace `Commit Message` in the next command by your commit message.
|
|
157
|
+
It will also used for branch name and pull request
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export MESSAGE="Add readRow" && \
|
|
161
|
+
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
162
|
+
git checkout -b $BRANCH
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Commit
|
|
166
|
+
|
|
167
|
+
Develop your feature
|
|
168
|
+
|
|
169
|
+
Commit your changes
|
|
170
|
+
|
|
171
|
+
If you only have one thing, execute
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
git add . && git commit -m "$MESSAGE"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Update dependencies
|
|
178
|
+
|
|
179
|
+
We aim to work with the latest versions of our dependencies.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pnpm update --latest &&\
|
|
183
|
+
git commit -m"Update dependencies"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Increase version
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pnpm version patch --no-git-tag-version && \
|
|
190
|
+
git commit -am"Increase version"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Create a pull request
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
git push -u origin $BRANCH && \
|
|
197
|
+
gh pr create --base main --title "$MESSAGE" --body "" && \
|
|
198
|
+
gh pr merge --auto --squash
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Wait until PR is merged
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
|
|
205
|
+
echo "Wait until PR is closed ..." && \
|
|
206
|
+
until gh pr view --json closed | jq -e '.closed == true' >/dev/null; do
|
|
207
|
+
sleep 2 >/dev/null;
|
|
208
|
+
done;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Delete feature branch
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
git fetch && git checkout main && \
|
|
215
|
+
git reset --soft origin/main && \
|
|
216
|
+
git stash -m"PR Aftermath" && \
|
|
217
|
+
git pull && \
|
|
218
|
+
git branch -d $BRANCH
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Publish to NPM
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm publish --access public && \
|
|
225
|
+
git tag $(npm pkg get version | tr -d '\\"')
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
<!-- ........................................................................-->
|
|
229
|
+
|
|
230
|
+
## Troubleshooting
|
|
231
|
+
|
|
232
|
+
### Checkout README.trouble.md
|
|
233
|
+
|
|
234
|
+
Checkout [./README.trouble.md](./README.trouble.md)
|
|
235
|
+
|
|
236
|
+
### File issues on GitHub
|
|
237
|
+
|
|
238
|
+
Visit <https://github.com/rljson/db/issues>
|
|
239
|
+
|
|
240
|
+
Check if there is already an issue for your problem.
|
|
241
|
+
|
|
242
|
+
If no, report the issue.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @rljson/db
|
|
2
|
+
|
|
3
|
+
A high level interface to read and write RLJSON data from and into a database
|
|
4
|
+
|
|
5
|
+
## Users
|
|
6
|
+
|
|
7
|
+
| File | Purpose |
|
|
8
|
+
| ------------------------------------ | --------------------------- |
|
|
9
|
+
| [README.public.md](README.public.md) | Install and use the package |
|
|
10
|
+
|
|
11
|
+
## Contributors
|
|
12
|
+
|
|
13
|
+
| File | Purpose |
|
|
14
|
+
| ------------------------------------------------ | ----------------------------- |
|
|
15
|
+
| [README.contributors.md](README.contributors.md) | Run, debug, build and publish |
|
|
16
|
+
| [README.architecture.md](README.architecture.md) | Software architecture guide |
|
|
17
|
+
| [README.trouble.md](README.trouble.md) | Errors & solutions |
|
|
18
|
+
| [README.blog.md](README.blog.md) | Blog |
|
package/README.public.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
# Trouble shooting
|
|
6
|
+
|
|
7
|
+
## Table of contents <!-- omit in toc -->
|
|
8
|
+
|
|
9
|
+
- [Vscode Windows: Debugging is not working](#vscode-windows-debugging-is-not-working)
|
|
10
|
+
- [GitHub actions: Cannot find module @rollup/rollup-linux-x64-gnu](#github-actions-cannot-find-module-rolluprollup-linux-x64-gnu)
|
|
11
|
+
|
|
12
|
+
## Vscode Windows: Debugging is not working
|
|
13
|
+
|
|
14
|
+
Date: 2025-03-08
|
|
15
|
+
|
|
16
|
+
⚠️ IMPORTANT: On Windows, please check out the repo on drive C. There is a bug
|
|
17
|
+
in the VS Code Vitest extension (v1.14.4), which prevents test debugging from
|
|
18
|
+
working: <https://github.com/vitest-dev/vscode/issues/548> Please check from
|
|
19
|
+
time to time if the issue has been fixed and remove this note once it is
|
|
20
|
+
resolved.
|
|
21
|
+
|
|
22
|
+
## GitHub actions: Cannot find module @rollup/rollup-linux-x64-gnu
|
|
23
|
+
|
|
24
|
+
⚠️ Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to
|
|
25
|
+
optional dependencies (<https://github.com/npm/cli/issues/4828>). Please try `npm
|
|
26
|
+
i` again after removing both package-lock.json and node_modules directory.
|
|
27
|
+
|
|
28
|
+
Solution:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
rm -rf node_modules
|
|
32
|
+
rm package-lock.json
|
|
33
|
+
npm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then push `package-lock.yaml` again
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Architecture
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<!--
|
|
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
|
+
-->
|
|
8
|
+
|
|
9
|
+
# Contributors Guide
|
|
10
|
+
|
|
11
|
+
- [Install](#install)
|
|
12
|
+
- [Check out](#check-out)
|
|
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)
|
|
18
|
+
- [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
|
+
- [Workflow](#workflow)
|
|
24
|
+
- [Checkout main](#checkout-main)
|
|
25
|
+
- [Create a branch](#create-a-branch)
|
|
26
|
+
- [Commit](#commit)
|
|
27
|
+
- [Update dependencies](#update-dependencies)
|
|
28
|
+
- [Increase version](#increase-version)
|
|
29
|
+
- [Create a pull request](#create-a-pull-request)
|
|
30
|
+
- [Wait until PR is merged](#wait-until-pr-is-merged)
|
|
31
|
+
- [Delete feature branch](#delete-feature-branch)
|
|
32
|
+
- [Publish to NPM](#publish-to-npm)
|
|
33
|
+
- [Troubleshooting](#troubleshooting)
|
|
34
|
+
- [Checkout README.trouble.md](#checkout-readmetroublemd)
|
|
35
|
+
- [File issues on GitHub](#file-issues-on-github)
|
|
36
|
+
|
|
37
|
+
<!-- ........................................................................-->
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
### Check out
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir db
|
|
45
|
+
cd db
|
|
46
|
+
git clone https://github.com/rljson/db.git
|
|
47
|
+
cd db
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Install pnpm
|
|
51
|
+
|
|
52
|
+
Windows:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
corepack enable pnpm
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Mac:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
sudo corepack enable pnpm
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Install dependencies
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Install Vscode extensions
|
|
71
|
+
|
|
72
|
+
Open this project in `vscode`.
|
|
73
|
+
|
|
74
|
+
Press `Cmd+Shift+P`.
|
|
75
|
+
|
|
76
|
+
Type `Extensions: Show Recommended Extensions` and press `Enter`.
|
|
77
|
+
|
|
78
|
+
The recommended extensions will be shown.
|
|
79
|
+
|
|
80
|
+
Make sure, all recommended extensions are shown.
|
|
81
|
+
|
|
82
|
+
### Uninstall Jest and Jasmine
|
|
83
|
+
|
|
84
|
+
Jest or Jasmine extensions conflict with the `Vitest` extension used for this
|
|
85
|
+
project.
|
|
86
|
+
|
|
87
|
+
Uninstall them, if you have installed them.
|
|
88
|
+
|
|
89
|
+
### Install GitHub CLI
|
|
90
|
+
|
|
91
|
+
Install GitHub CLI on Mac
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
brew install gh
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Login
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
gh auth login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
<!-- ........................................................................-->
|
|
104
|
+
|
|
105
|
+
## Develop
|
|
106
|
+
|
|
107
|
+
### Read architecture doc
|
|
108
|
+
|
|
109
|
+
Read [README.architecture.md](./README.architecture.md) to get an overview
|
|
110
|
+
of the package's architecture.
|
|
111
|
+
|
|
112
|
+
### Debug
|
|
113
|
+
|
|
114
|
+
In Vscode: At the `left side bar` click on the `Test tube` icon to open the `Test explorer`.
|
|
115
|
+
|
|
116
|
+
At the `top`, click on the `refresh` icon to show update the tests.
|
|
117
|
+
|
|
118
|
+
Open a test file (`*.spec.ts`)
|
|
119
|
+
|
|
120
|
+
Set a breakpoint.
|
|
121
|
+
|
|
122
|
+
Press `alt` and click on the play button left beside the test.
|
|
123
|
+
|
|
124
|
+
Execution should stop at the breakpoint.
|
|
125
|
+
|
|
126
|
+
### Update goldens
|
|
127
|
+
|
|
128
|
+
In various tests we are creating golden files, that are reference files that
|
|
129
|
+
are compared against the files created in the tests.
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pnpm updateGoldens
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Test and Build
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pnpm test &&\
|
|
139
|
+
pnpm build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
<!-- ........................................................................-->
|
|
143
|
+
|
|
144
|
+
## Workflow
|
|
145
|
+
|
|
146
|
+
### Checkout main
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
git checkout main && \
|
|
150
|
+
git fetch && \
|
|
151
|
+
git pull
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Create a branch
|
|
155
|
+
|
|
156
|
+
Please replace `Commit Message` in the next command by your commit message.
|
|
157
|
+
It will also used for branch name and pull request
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
export MESSAGE="Add readRow" && \
|
|
161
|
+
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
162
|
+
git checkout -b $BRANCH
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Commit
|
|
166
|
+
|
|
167
|
+
Develop your feature
|
|
168
|
+
|
|
169
|
+
Commit your changes
|
|
170
|
+
|
|
171
|
+
If you only have one thing, execute
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
git add . && git commit -m "$MESSAGE"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Update dependencies
|
|
178
|
+
|
|
179
|
+
We aim to work with the latest versions of our dependencies.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pnpm update --latest &&\
|
|
183
|
+
git commit -m"Update dependencies"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Increase version
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pnpm version patch --no-git-tag-version && \
|
|
190
|
+
git commit -am"Increase version"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Create a pull request
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
git push -u origin $BRANCH && \
|
|
197
|
+
gh pr create --base main --title "$MESSAGE" --body "" && \
|
|
198
|
+
gh pr merge --auto --squash
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Wait until PR is merged
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
|
|
205
|
+
echo "Wait until PR is closed ..." && \
|
|
206
|
+
until gh pr view --json closed | jq -e '.closed == true' >/dev/null; do
|
|
207
|
+
sleep 2 >/dev/null;
|
|
208
|
+
done;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Delete feature branch
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
git fetch && git checkout main && \
|
|
215
|
+
git reset --soft origin/main && \
|
|
216
|
+
git stash -m"PR Aftermath" && \
|
|
217
|
+
git pull && \
|
|
218
|
+
git branch -d $BRANCH
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Publish to NPM
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npm publish --access public && \
|
|
225
|
+
git tag $(npm pkg get version | tr -d '\\"')
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
<!-- ........................................................................-->
|
|
229
|
+
|
|
230
|
+
## Troubleshooting
|
|
231
|
+
|
|
232
|
+
### Checkout README.trouble.md
|
|
233
|
+
|
|
234
|
+
Checkout [./README.trouble.md](./README.trouble.md)
|
|
235
|
+
|
|
236
|
+
### File issues on GitHub
|
|
237
|
+
|
|
238
|
+
Visit <https://github.com/rljson/db/issues>
|
|
239
|
+
|
|
240
|
+
Check if there is already an issue for your problem.
|
|
241
|
+
|
|
242
|
+
If no, report the issue.
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @rljson/db
|
|
2
|
+
|
|
3
|
+
A high level interface to read and write RLJSON data from and into a database
|
|
4
|
+
|
|
5
|
+
## Users
|
|
6
|
+
|
|
7
|
+
| File | Purpose |
|
|
8
|
+
| ------------------------------------ | --------------------------- |
|
|
9
|
+
| [README.public.md](README.public.md) | Install and use the package |
|
|
10
|
+
|
|
11
|
+
## Contributors
|
|
12
|
+
|
|
13
|
+
| File | Purpose |
|
|
14
|
+
| ------------------------------------------------ | ----------------------------- |
|
|
15
|
+
| [README.contributors.md](README.contributors.md) | Run, debug, build and publish |
|
|
16
|
+
| [README.architecture.md](README.architecture.md) | Software architecture guide |
|
|
17
|
+
| [README.trouble.md](README.trouble.md) | Errors & solutions |
|
|
18
|
+
| [README.blog.md](README.blog.md) | Blog |
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
# Trouble shooting
|
|
6
|
+
|
|
7
|
+
## Table of contents <!-- omit in toc -->
|
|
8
|
+
|
|
9
|
+
- [Vscode Windows: Debugging is not working](#vscode-windows-debugging-is-not-working)
|
|
10
|
+
- [GitHub actions: Cannot find module @rollup/rollup-linux-x64-gnu](#github-actions-cannot-find-module-rolluprollup-linux-x64-gnu)
|
|
11
|
+
|
|
12
|
+
## Vscode Windows: Debugging is not working
|
|
13
|
+
|
|
14
|
+
Date: 2025-03-08
|
|
15
|
+
|
|
16
|
+
⚠️ IMPORTANT: On Windows, please check out the repo on drive C. There is a bug
|
|
17
|
+
in the VS Code Vitest extension (v1.14.4), which prevents test debugging from
|
|
18
|
+
working: <https://github.com/vitest-dev/vscode/issues/548> Please check from
|
|
19
|
+
time to time if the issue has been fixed and remove this note once it is
|
|
20
|
+
resolved.
|
|
21
|
+
|
|
22
|
+
## GitHub actions: Cannot find module @rollup/rollup-linux-x64-gnu
|
|
23
|
+
|
|
24
|
+
⚠️ Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to
|
|
25
|
+
optional dependencies (<https://github.com/npm/cli/issues/4828>). Please try `npm
|
|
26
|
+
i` again after removing both package-lock.json and node_modules directory.
|
|
27
|
+
|
|
28
|
+
Solution:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
rm -rf node_modules
|
|
32
|
+
rm package-lock.json
|
|
33
|
+
npm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Then push `package-lock.yaml` again
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Io } from '@rljson/io';
|
|
2
|
+
import { JsonValue } from '@rljson/json';
|
|
3
|
+
import { ContentType, Rljson } from '@rljson/rljson';
|
|
4
|
+
/** Implements core functionalities like importing data, setting tables */
|
|
5
|
+
export declare class Core {
|
|
6
|
+
private readonly _io;
|
|
7
|
+
constructor(_io: Io);
|
|
8
|
+
static example: () => Promise<Core>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a table
|
|
11
|
+
* @param name The name of the table.
|
|
12
|
+
* @param type The type of the table.
|
|
13
|
+
*/
|
|
14
|
+
createTable(name: string, type: ContentType): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a dump of the database
|
|
17
|
+
*/
|
|
18
|
+
dump(): Promise<Rljson>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns a dump of a table.
|
|
21
|
+
* @returns a dump of a table.
|
|
22
|
+
* @throws when table name does not exist
|
|
23
|
+
*/
|
|
24
|
+
dumpTable(name: string): Promise<Rljson>;
|
|
25
|
+
/**
|
|
26
|
+
* Imports data into the memory.
|
|
27
|
+
* @throws {Error} If the data is invalid.
|
|
28
|
+
*/
|
|
29
|
+
import(data: Rljson): Promise<void>;
|
|
30
|
+
tables(): Promise<string[]>;
|
|
31
|
+
hasTable(table: string): Promise<boolean>;
|
|
32
|
+
/** Reads a specific row from a database table */
|
|
33
|
+
readRow(table: string, rowHash: string): Promise<Rljson>;
|
|
34
|
+
readRows(table: string, where: {
|
|
35
|
+
[column: string]: JsonValue;
|
|
36
|
+
}): Promise<Rljson>;
|
|
37
|
+
}
|
package/dist/db.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Io } from '@rljson/io';
|
|
2
|
+
import { Core } from './core.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Access Rljson data
|
|
5
|
+
*/
|
|
6
|
+
export declare class Db {
|
|
7
|
+
private readonly _io;
|
|
8
|
+
/**
|
|
9
|
+
* Constructor
|
|
10
|
+
* @param _io - The Io instance used to read and write data
|
|
11
|
+
*/
|
|
12
|
+
constructor(_io: Io);
|
|
13
|
+
/**
|
|
14
|
+
* Core functionalities like importing data, setting and getting tables
|
|
15
|
+
*/
|
|
16
|
+
readonly core: Core;
|
|
17
|
+
/**
|
|
18
|
+
* Example
|
|
19
|
+
* @returns A new Db instance for test purposes
|
|
20
|
+
*/
|
|
21
|
+
static example: () => Promise<Db>;
|
|
22
|
+
}
|
package/dist/db.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { IoMem } from "@rljson/io";
|
|
5
|
+
import { validate } from "@rljson/validate";
|
|
6
|
+
// @license
|
|
7
|
+
const _Core = class _Core {
|
|
8
|
+
// ...........................................................................
|
|
9
|
+
constructor(_io) {
|
|
10
|
+
this._io = _io;
|
|
11
|
+
}
|
|
12
|
+
// ...........................................................................
|
|
13
|
+
/**
|
|
14
|
+
* Creates a table
|
|
15
|
+
* @param name The name of the table.
|
|
16
|
+
* @param type The type of the table.
|
|
17
|
+
*/
|
|
18
|
+
async createTable(name, type) {
|
|
19
|
+
return this._io.createTable({ name, type });
|
|
20
|
+
}
|
|
21
|
+
// ...........................................................................
|
|
22
|
+
/**
|
|
23
|
+
* Returns a dump of the database
|
|
24
|
+
*/
|
|
25
|
+
dump() {
|
|
26
|
+
return this._io.dump();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns a dump of a table.
|
|
30
|
+
* @returns a dump of a table.
|
|
31
|
+
* @throws when table name does not exist
|
|
32
|
+
*/
|
|
33
|
+
dumpTable(name) {
|
|
34
|
+
return this._io.dumpTable({ name });
|
|
35
|
+
}
|
|
36
|
+
// ...........................................................................
|
|
37
|
+
/**
|
|
38
|
+
* Imports data into the memory.
|
|
39
|
+
* @throws {Error} If the data is invalid.
|
|
40
|
+
*/
|
|
41
|
+
async import(data) {
|
|
42
|
+
const result = validate(data);
|
|
43
|
+
if (result.hasErrors) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
"The imported rljson data is not valid:\n" + JSON.stringify(result, null, 2)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
await this._io.write({ data });
|
|
49
|
+
}
|
|
50
|
+
// ...........................................................................
|
|
51
|
+
async tables() {
|
|
52
|
+
return this._io.tables();
|
|
53
|
+
}
|
|
54
|
+
// ...........................................................................
|
|
55
|
+
async hasTable(table) {
|
|
56
|
+
const tables = await this._io.tables();
|
|
57
|
+
return tables.includes(table);
|
|
58
|
+
}
|
|
59
|
+
// ...........................................................................
|
|
60
|
+
/** Reads a specific row from a database table */
|
|
61
|
+
readRow(table, rowHash) {
|
|
62
|
+
return this._io.readRow({ table, rowHash });
|
|
63
|
+
}
|
|
64
|
+
// ...........................................................................
|
|
65
|
+
readRows(table, where) {
|
|
66
|
+
return this._io.readRows({ table, where });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
__publicField(_Core, "example", async () => {
|
|
70
|
+
return new _Core(IoMem.example());
|
|
71
|
+
});
|
|
72
|
+
let Core = _Core;
|
|
73
|
+
// @license
|
|
74
|
+
const _Db = class _Db {
|
|
75
|
+
/**
|
|
76
|
+
* Constructor
|
|
77
|
+
* @param _io - The Io instance used to read and write data
|
|
78
|
+
*/
|
|
79
|
+
constructor(_io) {
|
|
80
|
+
/**
|
|
81
|
+
* Core functionalities like importing data, setting and getting tables
|
|
82
|
+
*/
|
|
83
|
+
__publicField(this, "core");
|
|
84
|
+
this._io = _io;
|
|
85
|
+
this.core = new Core(this._io);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Example
|
|
90
|
+
* @returns A new Db instance for test purposes
|
|
91
|
+
*/
|
|
92
|
+
__publicField(_Db, "example", async () => {
|
|
93
|
+
const io = new IoMem();
|
|
94
|
+
return new _Db(io);
|
|
95
|
+
});
|
|
96
|
+
let Db = _Db;
|
|
97
|
+
export {
|
|
98
|
+
Db as RljsonDb
|
|
99
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Db as RljsonDb } from './db.ts';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IoMem } from '@rljson/io';
|
|
2
|
+
import { exampleRljson } from '@rljson/rljson';
|
|
3
|
+
|
|
4
|
+
import { Db } from './db.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The example function demonstrates how the package works
|
|
8
|
+
* ⚠️ Run »pnpm updateGoldens« to update the golden files
|
|
9
|
+
*/
|
|
10
|
+
export const example = async () => {
|
|
11
|
+
const l = console.log;
|
|
12
|
+
|
|
13
|
+
l('Create an io instane');
|
|
14
|
+
const io = new IoMem();
|
|
15
|
+
|
|
16
|
+
l('Create an example instance');
|
|
17
|
+
const db = new Db(io);
|
|
18
|
+
|
|
19
|
+
l('Create the tables');
|
|
20
|
+
await db.core.createTable('table', 'properties');
|
|
21
|
+
|
|
22
|
+
l('Import Rljson');
|
|
23
|
+
await db.core.import(exampleRljson());
|
|
24
|
+
|
|
25
|
+
l('Get the tables');
|
|
26
|
+
const tables = await db.core.tables();
|
|
27
|
+
l(tables.join(', '));
|
|
28
|
+
|
|
29
|
+
l('Dump the database');
|
|
30
|
+
const dump = await db.core.dump();
|
|
31
|
+
l(JSON.stringify(dump, null, 2));
|
|
32
|
+
|
|
33
|
+
l('Dump a single table');
|
|
34
|
+
const tableDump = await db.core.dumpTable('table');
|
|
35
|
+
l(JSON.stringify(tableDump, null, 2));
|
|
36
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rljson/db",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"packageManager": "pnpm@10.6.3+sha512.bb45e34d50a9a76e858a95837301bfb6bd6d35aea2c5d52094fa497a467c43f5c440103ce2511e9e0a2f89c3d6071baac3358fc68ac6fb75e2ceb3d2736065e6",
|
|
5
|
+
"description": "A high level interface to read and write RLJSON data from and into a database",
|
|
6
|
+
"homepage": "https://github.com/rljson/db",
|
|
7
|
+
"bugs": "https://github.com/rljson/db/issues",
|
|
8
|
+
"private": false,
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22.14.0"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/rljson/db.git"
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/db.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npx vite build && tsc && cp README* dist && mkdir dist/src && cp src/example.ts dist/src",
|
|
25
|
+
"test": "npx vitest run --coverage && npm run lint",
|
|
26
|
+
"prebuild": "npm run test",
|
|
27
|
+
"prepublishOnly": "npm run build && npm run test",
|
|
28
|
+
"lint": "npx eslint",
|
|
29
|
+
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.13.10",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
|
34
|
+
"@typescript-eslint/parser": "^8.26.1",
|
|
35
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
36
|
+
"cross-env": "^7.0.3",
|
|
37
|
+
"eslint": "^9.22.0",
|
|
38
|
+
"eslint-plugin-jsdoc": "^50.6.6",
|
|
39
|
+
"eslint-plugin-tsdoc": "^0.4.0",
|
|
40
|
+
"globals": "^16.0.0",
|
|
41
|
+
"jsdoc": "^4.0.4",
|
|
42
|
+
"read-pkg": "^9.0.1",
|
|
43
|
+
"typescript": "~5.8.2",
|
|
44
|
+
"typescript-eslint": "^8.26.1",
|
|
45
|
+
"vite": "^6.2.1",
|
|
46
|
+
"vite-node": "^3.0.8",
|
|
47
|
+
"vite-plugin-dts": "^4.5.3",
|
|
48
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
49
|
+
"vitest": "^3.0.8",
|
|
50
|
+
"vitest-dom": "^0.1.1"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@rljson/hash": "^0.0.10",
|
|
54
|
+
"@rljson/io": "^0.0.7",
|
|
55
|
+
"@rljson/json": "^0.0.9",
|
|
56
|
+
"@rljson/rljson": "^0.0.11",
|
|
57
|
+
"@rljson/validate": "^0.0.6"
|
|
58
|
+
},
|
|
59
|
+
"pnpm": {
|
|
60
|
+
"onlyBuiltDependencies": [
|
|
61
|
+
"esbuild"
|
|
62
|
+
],
|
|
63
|
+
"overrides": {}
|
|
64
|
+
}
|
|
65
|
+
}
|