@rljson/io 0.0.4 → 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,5 +1,9 @@
1
1
  <!--
2
-
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.
3
7
  -->
4
8
 
5
9
  # Contributors Guide
@@ -118,7 +122,7 @@ Please replace `Commit Message` in the next command by your commit message.
118
122
  It will also used for branch name and pull request
119
123
 
120
124
  ```bash
121
- export MESSAGE="Fix small things in README" && \
125
+ export MESSAGE="Add IoMem and dump table" && \
122
126
  export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
123
127
  git checkout -b $BRANCH
124
128
  ```
@@ -159,6 +163,8 @@ Develop your feature
159
163
 
160
164
  Commit your changes
161
165
 
166
+ If you only have one thing, execute
167
+
162
168
  ```bash
163
169
  git commit -am"$MESSAGE"
164
170
  ```
@@ -184,7 +190,8 @@ git commit -am"Increase version"
184
190
  ```bash
185
191
  git push -u origin $BRANCH && \
186
192
  gh pr create --base main --title "$MESSAGE" --body "" && \
187
- gh pr merge --auto --squash
193
+ gh pr merge --auto --squash && \
194
+
188
195
  ```
189
196
 
190
197
  ### Wait until PR is merged
@@ -192,11 +199,13 @@ gh pr merge --auto --squash
192
199
  Get the PR URL with the following command
193
200
 
194
201
  ```bash
195
- gh pr view --json url -q .url
202
+ echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
203
+ echo "Wait until PR is closed ..." && \
204
+ until gh pr view --json closed | jq -e '.closed == true' >/dev/null; do
205
+ sleep 2 >/dev/null;
206
+ done;
196
207
  ```
197
208
 
198
- Visit it
199
-
200
209
  ### Delete feature branch
201
210
 
202
211
  ```bash
@@ -1,5 +1,9 @@
1
1
  <!--
2
-
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.
3
7
  -->
4
8
 
5
9
  # Contributors Guide
@@ -118,7 +122,7 @@ Please replace `Commit Message` in the next command by your commit message.
118
122
  It will also used for branch name and pull request
119
123
 
120
124
  ```bash
121
- export MESSAGE="Fix small things in README" && \
125
+ export MESSAGE="Add IoMem and dump table" && \
122
126
  export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
123
127
  git checkout -b $BRANCH
124
128
  ```
@@ -159,6 +163,8 @@ Develop your feature
159
163
 
160
164
  Commit your changes
161
165
 
166
+ If you only have one thing, execute
167
+
162
168
  ```bash
163
169
  git commit -am"$MESSAGE"
164
170
  ```
@@ -184,7 +190,8 @@ git commit -am"Increase version"
184
190
  ```bash
185
191
  git push -u origin $BRANCH && \
186
192
  gh pr create --base main --title "$MESSAGE" --body "" && \
187
- gh pr merge --auto --squash
193
+ gh pr merge --auto --squash && \
194
+
188
195
  ```
189
196
 
190
197
  ### Wait until PR is merged
@@ -192,11 +199,13 @@ gh pr merge --auto --squash
192
199
  Get the PR URL with the following command
193
200
 
194
201
  ```bash
195
- gh pr view --json url -q .url
202
+ echo -e "\033[34m$(gh pr view --json url | jq -r '.url')\033[0m"
203
+ echo "Wait until PR is closed ..." && \
204
+ until gh pr view --json closed | jq -e '.closed == true' >/dev/null; do
205
+ sleep 2 >/dev/null;
206
+ done;
196
207
  ```
197
208
 
198
- Visit it
199
-
200
209
  ### Delete feature branch
201
210
 
202
211
  ```bash
package/dist/example.d.ts CHANGED
@@ -1,4 +1 @@
1
- /**
2
- * The example function demonstrates how the package works
3
- */
4
- export declare const example: () => void;
1
+ export declare const example: () => Promise<void>;
@@ -0,0 +1,39 @@
1
+ import { JsonValue } from '@rljson/json';
2
+ import { ContentType, Rljson } from '@rljson/rljson';
3
+ import { Io } from './io.ts';
4
+ /**
5
+ * In-Memory implementation of the Rljson Io interface.
6
+ */
7
+ export declare class IoMem implements Io {
8
+ static example: () => IoMem;
9
+ isReady(): Promise<void>;
10
+ dump(): Promise<Rljson>;
11
+ dumpTable(request: {
12
+ name: string;
13
+ }): Promise<Rljson>;
14
+ readRow(request: {
15
+ table: string;
16
+ rowHash: string;
17
+ }): Promise<Rljson>;
18
+ readRows(request: {
19
+ table: string;
20
+ where: {
21
+ [column: string]: JsonValue;
22
+ };
23
+ }): Promise<Rljson>;
24
+ write(request: {
25
+ data: Rljson;
26
+ }): Promise<void>;
27
+ createTable(request: {
28
+ name: string;
29
+ type: ContentType;
30
+ }): Promise<void>;
31
+ tables(): Promise<string[]>;
32
+ private _mem;
33
+ private _createTable;
34
+ private _readRow;
35
+ private _dump;
36
+ private _dumpTable;
37
+ private _write;
38
+ private _readRows;
39
+ }
package/dist/io.d.ts CHANGED
@@ -1,14 +1,21 @@
1
+ import { JsonValue } from '@rljson/json';
1
2
  import { ContentType, Rljson } from '@rljson/rljson';
2
3
  export interface Io {
3
4
  /** A promise resolving once the Io interface is ready */
4
5
  isReady(): Promise<void>;
5
6
  /** Returns the complete db content as Rljson */
6
7
  dump(): Promise<Rljson>;
8
+ /** Returns the dump of a complete table */
9
+ dumpTable(request: {
10
+ name: string;
11
+ }): Promise<Rljson>;
7
12
  /** Creates a table with a given type */
8
13
  createTable(request: {
9
14
  name: string;
10
15
  type: ContentType;
11
16
  }): Promise<void>;
17
+ /** Returns the available table names */
18
+ tables(): Promise<string[]>;
12
19
  /** Writes Rljson data in to the database */
13
20
  write(request: {
14
21
  data: Rljson;
@@ -18,5 +25,12 @@ export interface Io {
18
25
  table: string;
19
26
  rowHash: string;
20
27
  }): Promise<Rljson>;
28
+ /** Queries a list of rows */
29
+ readRows(request: {
30
+ table: string;
31
+ where: {
32
+ [column: string]: JsonValue;
33
+ };
34
+ }): Promise<Rljson>;
21
35
  }
22
36
  export declare const exampleIo = "Checkout @rljson/io-mem for an example implementation";
@@ -4,9 +4,39 @@
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
- /**
8
- * The example function demonstrates how the package works
9
- */
10
- export const example = () => {
11
- console.log('exampleIo');
7
+ import { hsh } from '@rljson/hash';
8
+ import { Rljson } from '@rljson/rljson';
9
+
10
+ import { IoMem } from './io-mem.ts';
11
+
12
+ // Run »pnpm updateGoldens« when you change this file
13
+ export const example = async () => {
14
+ const ioMem = new IoMem();
15
+
16
+ const row = { keyA2: 'a2' };
17
+ const rowWithHash = hsh(row);
18
+
19
+ // Create a table first
20
+ await ioMem.createTable({ name: 'tableA', type: 'properties' });
21
+
22
+ // Write data into the table
23
+ await ioMem.write({
24
+ data: {
25
+ tableA: {
26
+ _type: 'properties',
27
+ _data: [row],
28
+ },
29
+ },
30
+ });
31
+
32
+ // Read data from the table
33
+ const data: Rljson = await ioMem.readRow({
34
+ table: 'tableA',
35
+ rowHash: rowWithHash._hash,
36
+ });
37
+
38
+ // Print the return rljson data
39
+ console.log(JSON.stringify(data, null, 2));
12
40
  };
41
+
42
+ // example();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/io",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "packageManager": "pnpm@10.6.2",
5
5
  "description": "Low level interface for reading and writing RLJSON data",
6
6
  "homepage": "https://github.com/rljson/io",
@@ -14,7 +14,7 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/rljson/io.git"
16
16
  },
17
- "main": "dist/index.js",
17
+ "main": "dist/io.js",
18
18
  "types": "dist/index.d.ts",
19
19
  "files": [
20
20
  "dist"
@@ -39,6 +39,7 @@
39
39
  "eslint-plugin-tsdoc": "^0.4.0",
40
40
  "globals": "^16.0.0",
41
41
  "jsdoc": "^4.0.4",
42
+ "read-pkg": "^9.0.1",
42
43
  "typescript": "~5.8.2",
43
44
  "typescript-eslint": "^8.26.1",
44
45
  "vite": "^6.2.1",
@@ -55,9 +56,9 @@
55
56
  "overrides": {}
56
57
  },
57
58
  "dependencies": {
58
- "@rljson/hash": "^0.0.9",
59
- "@rljson/json": "^0.0.7",
59
+ "@rljson/hash": "^0.0.10",
60
+ "@rljson/json": "^0.0.8",
60
61
  "@rljson/rljson": "^0.0.7",
61
- "@rljson/validate": "^0.0.4"
62
+ "@rljson/validate": "^0.0.5"
62
63
  }
63
64
  }