@rljson/io 0.0.5 → 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.
- package/README.contributors.md +10 -5
- package/dist/README.contributors.md +10 -5
- package/dist/example.d.ts +1 -4
- package/dist/io-mem.d.ts +39 -0
- package/dist/io.d.ts +4 -0
- package/dist/src/example.ts +35 -5
- package/package.json +1 -1
package/README.contributors.md
CHANGED
|
@@ -122,7 +122,7 @@ Please replace `Commit Message` in the next command by your commit message.
|
|
|
122
122
|
It will also used for branch name and pull request
|
|
123
123
|
|
|
124
124
|
```bash
|
|
125
|
-
export MESSAGE="
|
|
125
|
+
export MESSAGE="Add IoMem and dump table" && \
|
|
126
126
|
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
127
127
|
git checkout -b $BRANCH
|
|
128
128
|
```
|
|
@@ -163,6 +163,8 @@ Develop your feature
|
|
|
163
163
|
|
|
164
164
|
Commit your changes
|
|
165
165
|
|
|
166
|
+
If you only have one thing, execute
|
|
167
|
+
|
|
166
168
|
```bash
|
|
167
169
|
git commit -am"$MESSAGE"
|
|
168
170
|
```
|
|
@@ -188,7 +190,8 @@ git commit -am"Increase version"
|
|
|
188
190
|
```bash
|
|
189
191
|
git push -u origin $BRANCH && \
|
|
190
192
|
gh pr create --base main --title "$MESSAGE" --body "" && \
|
|
191
|
-
gh pr merge --auto --squash
|
|
193
|
+
gh pr merge --auto --squash && \
|
|
194
|
+
|
|
192
195
|
```
|
|
193
196
|
|
|
194
197
|
### Wait until PR is merged
|
|
@@ -196,11 +199,13 @@ gh pr merge --auto --squash
|
|
|
196
199
|
Get the PR URL with the following command
|
|
197
200
|
|
|
198
201
|
```bash
|
|
199
|
-
gh pr view --json 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;
|
|
200
207
|
```
|
|
201
208
|
|
|
202
|
-
Visit it
|
|
203
|
-
|
|
204
209
|
### Delete feature branch
|
|
205
210
|
|
|
206
211
|
```bash
|
|
@@ -122,7 +122,7 @@ Please replace `Commit Message` in the next command by your commit message.
|
|
|
122
122
|
It will also used for branch name and pull request
|
|
123
123
|
|
|
124
124
|
```bash
|
|
125
|
-
export MESSAGE="
|
|
125
|
+
export MESSAGE="Add IoMem and dump table" && \
|
|
126
126
|
export BRANCH=`echo "$MESSAGE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_]/_/g'` &&\
|
|
127
127
|
git checkout -b $BRANCH
|
|
128
128
|
```
|
|
@@ -163,6 +163,8 @@ Develop your feature
|
|
|
163
163
|
|
|
164
164
|
Commit your changes
|
|
165
165
|
|
|
166
|
+
If you only have one thing, execute
|
|
167
|
+
|
|
166
168
|
```bash
|
|
167
169
|
git commit -am"$MESSAGE"
|
|
168
170
|
```
|
|
@@ -188,7 +190,8 @@ git commit -am"Increase version"
|
|
|
188
190
|
```bash
|
|
189
191
|
git push -u origin $BRANCH && \
|
|
190
192
|
gh pr create --base main --title "$MESSAGE" --body "" && \
|
|
191
|
-
gh pr merge --auto --squash
|
|
193
|
+
gh pr merge --auto --squash && \
|
|
194
|
+
|
|
192
195
|
```
|
|
193
196
|
|
|
194
197
|
### Wait until PR is merged
|
|
@@ -196,11 +199,13 @@ gh pr merge --auto --squash
|
|
|
196
199
|
Get the PR URL with the following command
|
|
197
200
|
|
|
198
201
|
```bash
|
|
199
|
-
gh pr view --json 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;
|
|
200
207
|
```
|
|
201
208
|
|
|
202
|
-
Visit it
|
|
203
|
-
|
|
204
209
|
### Delete feature branch
|
|
205
210
|
|
|
206
211
|
```bash
|
package/dist/example.d.ts
CHANGED
package/dist/io-mem.d.ts
ADDED
|
@@ -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
|
@@ -5,6 +5,10 @@ export interface Io {
|
|
|
5
5
|
isReady(): Promise<void>;
|
|
6
6
|
/** Returns the complete db content as Rljson */
|
|
7
7
|
dump(): Promise<Rljson>;
|
|
8
|
+
/** Returns the dump of a complete table */
|
|
9
|
+
dumpTable(request: {
|
|
10
|
+
name: string;
|
|
11
|
+
}): Promise<Rljson>;
|
|
8
12
|
/** Creates a table with a given type */
|
|
9
13
|
createTable(request: {
|
|
10
14
|
name: string;
|
package/dist/src/example.ts
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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();
|