@rljson/db 0.0.3 → 0.0.6

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.
@@ -1,242 +1,32 @@
1
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.
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
- - [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)
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
- - [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.
13
+ - [Tools](#tools)
14
+ - [Superheros](#superheros)
79
15
 
80
- Make sure, all recommended extensions are shown.
16
+ ## Prepare
81
17
 
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
- ```
18
+ Read [prepare.md](doc/workflows/prepare.md)
102
19
 
103
20
  <!-- ........................................................................-->
104
21
 
105
22
  ## Develop
106
23
 
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)
24
+ Read [develop.md](doc/workflows/develop.md)
235
25
 
236
- ### File issues on GitHub
26
+ ## Tools
237
27
 
238
- Visit <https://github.com/rljson/db/issues>
28
+ Read [tools.md](doc/workflows/tools.md)
239
29
 
240
- Check if there is already an issue for your problem.
30
+ ## Superheros
241
31
 
242
- If no, report the issue.
32
+ Read [super-hero.md](doc/workflows/super-hero.md)
@@ -1,242 +1,32 @@
1
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.
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
- - [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)
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
- - [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.
13
+ - [Tools](#tools)
14
+ - [Superheros](#superheros)
79
15
 
80
- Make sure, all recommended extensions are shown.
16
+ ## Prepare
81
17
 
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
- ```
18
+ Read [prepare.md](doc/workflows/prepare.md)
102
19
 
103
20
  <!-- ........................................................................-->
104
21
 
105
22
  ## Develop
106
23
 
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)
24
+ Read [develop.md](doc/workflows/develop.md)
235
25
 
236
- ### File issues on GitHub
26
+ ## Tools
237
27
 
238
- Visit <https://github.com/rljson/db/issues>
28
+ Read [tools.md](doc/workflows/tools.md)
239
29
 
240
- Check if there is already an issue for your problem.
30
+ ## Superheros
241
31
 
242
- If no, report the issue.
32
+ Read [super-hero.md](doc/workflows/super-hero.md)
@@ -0,0 +1,41 @@
1
+ import { Json, JsonH, JsonValueH } from '@rljson/json';
2
+ import { CakesTable, ComponentsTable, LayersTable, Rljson, SliceIdsTable, TablesCfgTable } from '@rljson/rljson';
3
+ export interface CarsExample extends Rljson {
4
+ carSliceId: SliceIdsTable;
5
+ carGeneral: ComponentsTable<CarGeneral>;
6
+ carTechnical: ComponentsTable<Json>;
7
+ carColor: ComponentsTable<Json>;
8
+ carDimensions: ComponentsTable<CarDimension>;
9
+ carGeneralLayer: LayersTable;
10
+ carTechnicalLayer: LayersTable;
11
+ carColorLayer: LayersTable;
12
+ carCake: CakesTable;
13
+ wheelSliceId: SliceIdsTable;
14
+ wheelBrand: ComponentsTable<Json>;
15
+ wheelDimension: ComponentsTable<Json>;
16
+ wheelBrandLayer: LayersTable;
17
+ wheelDimensionLayer: LayersTable;
18
+ wheelCake: CakesTable;
19
+ tableCfgs: TablesCfgTable;
20
+ }
21
+ export interface CarGeneral extends JsonH {
22
+ brand: string;
23
+ type: string;
24
+ doors: number;
25
+ energyConsumption: number;
26
+ units: JsonValueH;
27
+ serviceIntervals: number[];
28
+ isElectric: boolean;
29
+ }
30
+ export interface CarDimension extends JsonH {
31
+ height: number;
32
+ width: number;
33
+ length: number;
34
+ }
35
+ export interface CarTechnical extends JsonH {
36
+ engine: string;
37
+ transmission: string;
38
+ gears: number;
39
+ carDimensionsRef: string;
40
+ }
41
+ export declare const carsExample: () => CarsExample;
package/dist/core.d.ts CHANGED
@@ -1,17 +1,26 @@
1
1
  import { Io } from '@rljson/io';
2
2
  import { JsonValue } from '@rljson/json';
3
- import { ContentType, Rljson } from '@rljson/rljson';
3
+ import { ContentType, Rljson, TableCfg } from '@rljson/rljson';
4
4
  /** Implements core functionalities like importing data, setting tables */
5
5
  export declare class Core {
6
6
  private readonly _io;
7
7
  constructor(_io: Io);
8
8
  static example: () => Promise<Core>;
9
+ /**
10
+ * Creates a table and an insertHistory for the table
11
+ * @param tableCfg TableCfg of table to create
12
+ */
13
+ createTableWithInsertHistory(tableCfg: TableCfg): Promise<void>;
9
14
  /**
10
15
  * Creates a table
11
- * @param name The name of the table.
12
- * @param type The type of the table.
16
+ * @param tableCfg TableCfg of table to create
17
+ */
18
+ createTable(tableCfg: TableCfg): Promise<void>;
19
+ /**
20
+ * Creates an insertHistory table for a given table
21
+ * @param tableCfg TableCfg of table
13
22
  */
14
- createTable(name: string, type: ContentType): Promise<void>;
23
+ createInsertHistory(tableCfg: TableCfg): Promise<void>;
15
24
  /**
16
25
  * Returns a dump of the database
17
26
  */
@@ -21,14 +30,17 @@ export declare class Core {
21
30
  * @returns a dump of a table.
22
31
  * @throws when table name does not exist
23
32
  */
24
- dumpTable(name: string): Promise<Rljson>;
33
+ dumpTable(table: string): Promise<Rljson>;
25
34
  /**
26
35
  * Imports data into the memory.
36
+ * @param data - The rljson data to import.
27
37
  * @throws {Error} If the data is invalid.
28
38
  */
29
39
  import(data: Rljson): Promise<void>;
30
- tables(): Promise<string[]>;
40
+ tables(): Promise<Rljson>;
31
41
  hasTable(table: string): Promise<boolean>;
42
+ contentType(table: string): Promise<ContentType>;
43
+ tableCfg(table: string): Promise<TableCfg>;
32
44
  /** Reads a specific row from a database table */
33
45
  readRow(table: string, rowHash: string): Promise<Rljson>;
34
46
  readRows(table: string, where: {