@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.
- package/README.contributors.md +15 -225
- package/dist/README.contributors.md +15 -225
- package/dist/cars-example.d.ts +41 -0
- package/dist/core.d.ts +18 -6
- package/dist/db.d.ts +151 -3
- package/dist/db.js +2585 -42
- package/dist/notify.d.ts +39 -0
- package/dist/src/example.ts +9 -5
- package/package.json +31 -36
package/dist/notify.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InsertHistoryRow, Route } from '@rljson/rljson';
|
|
2
|
+
type NotifyCallback<N extends string> = (InsertHistoryRow: InsertHistoryRow<N>) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Notification system to manage callbacks for specific routes and notify them with edit protocol rows.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Notify {
|
|
7
|
+
private _callbacks;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Registers a callback for a specific route.
|
|
11
|
+
* @param route The route to register the callback for.
|
|
12
|
+
* @param callback The callback function to be invoked when a notification is sent.
|
|
13
|
+
*/
|
|
14
|
+
register(route: Route, callback: NotifyCallback<any>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Unregisters a callback for a specific route.
|
|
17
|
+
* @param route The route to unregister the callback from.
|
|
18
|
+
* @param callback The callback function to be removed.
|
|
19
|
+
*/
|
|
20
|
+
unregister(route: Route, callback: NotifyCallback<any>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Notifies all registered callbacks for a specific route with the provided edit protocol row.
|
|
23
|
+
* @param route The route to notify callbacks for.
|
|
24
|
+
* @param insertHistoryRow The edit protocol row to pass to the callbacks.
|
|
25
|
+
*/
|
|
26
|
+
notify<N extends string>(route: Route, insertHistoryRow: InsertHistoryRow<N>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the current map of registered callbacks.
|
|
29
|
+
* @returns A map where keys are route strings and values are arrays of callback functions.
|
|
30
|
+
*/
|
|
31
|
+
get callbacks(): Map<string, NotifyCallback<any>[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Retrieves the list of callbacks registered for a specific route.
|
|
34
|
+
* @param route The route to get callbacks for.
|
|
35
|
+
* @returns An array of callback functions registered for the specified route.
|
|
36
|
+
*/
|
|
37
|
+
getCallBacksForRoute(route: Route): NotifyCallback<any>[];
|
|
38
|
+
}
|
|
39
|
+
export {};
|
package/dist/src/example.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IoMem } from '@rljson/io';
|
|
2
|
-
import { exampleRljson } from '@rljson/rljson';
|
|
2
|
+
import { exampleRljson, exampleTableCfgTable } from '@rljson/rljson';
|
|
3
3
|
|
|
4
4
|
import { Db } from './db.ts';
|
|
5
5
|
|
|
@@ -11,20 +11,24 @@ export const example = async () => {
|
|
|
11
11
|
const l = console.log;
|
|
12
12
|
|
|
13
13
|
l('Create an io instane');
|
|
14
|
-
const io =
|
|
14
|
+
const io = await IoMem.example();
|
|
15
|
+
await io.init();
|
|
16
|
+
await io.isReady();
|
|
15
17
|
|
|
16
18
|
l('Create an example instance');
|
|
17
19
|
const db = new Db(io);
|
|
18
20
|
|
|
19
21
|
l('Create the tables');
|
|
20
|
-
|
|
22
|
+
const tableCfg = exampleTableCfgTable()._data[0];
|
|
23
|
+
await db.core.createTable(tableCfg);
|
|
21
24
|
|
|
22
25
|
l('Import Rljson');
|
|
23
|
-
|
|
26
|
+
const rljson = exampleRljson();
|
|
27
|
+
await db.core.import(rljson);
|
|
24
28
|
|
|
25
29
|
l('Get the tables');
|
|
26
30
|
const tables = await db.core.tables();
|
|
27
|
-
l(tables.join(', '));
|
|
31
|
+
l(Object.keys(tables).join(', '));
|
|
28
32
|
|
|
29
33
|
l('Dump the database');
|
|
30
34
|
const dump = await db.core.dump();
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/db",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"packageManager": "pnpm@10.6.3+sha512.bb45e34d50a9a76e858a95837301bfb6bd6d35aea2c5d52094fa497a467c43f5c440103ce2511e9e0a2f89c3d6071baac3358fc68ac6fb75e2ceb3d2736065e6",
|
|
3
|
+
"version": "0.0.6",
|
|
5
4
|
"description": "A high level interface to read and write RLJSON data from and into a database",
|
|
6
5
|
"homepage": "https://github.com/rljson/db",
|
|
7
6
|
"bugs": "https://github.com/rljson/db/issues",
|
|
@@ -20,46 +19,42 @@
|
|
|
20
19
|
"dist"
|
|
21
20
|
],
|
|
22
21
|
"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
22
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
35
|
-
"@vitest/coverage-v8": "^
|
|
36
|
-
"cross-env": "^
|
|
37
|
-
"eslint": "^9.
|
|
38
|
-
"eslint-plugin-jsdoc": "^
|
|
23
|
+
"@types/node": "^24.10.0",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
25
|
+
"@typescript-eslint/parser": "^8.46.3",
|
|
26
|
+
"@vitest/coverage-v8": "^4.0.7",
|
|
27
|
+
"cross-env": "^10.1.0",
|
|
28
|
+
"eslint": "^9.39.1",
|
|
29
|
+
"eslint-plugin-jsdoc": "^61.1.12",
|
|
39
30
|
"eslint-plugin-tsdoc": "^0.4.0",
|
|
40
|
-
"globals": "^16.
|
|
41
|
-
"jsdoc": "^4.0.
|
|
31
|
+
"globals": "^16.5.0",
|
|
32
|
+
"jsdoc": "^4.0.5",
|
|
42
33
|
"read-pkg": "^9.0.1",
|
|
43
|
-
"typescript": "~5.
|
|
44
|
-
"typescript-eslint": "^8.
|
|
45
|
-
"vite": "^
|
|
46
|
-
"vite-node": "^3.
|
|
47
|
-
"vite-plugin-dts": "^4.5.
|
|
34
|
+
"typescript": "~5.9.3",
|
|
35
|
+
"typescript-eslint": "^8.46.3",
|
|
36
|
+
"vite": "^7.2.0",
|
|
37
|
+
"vite-node": "^3.2.4",
|
|
38
|
+
"vite-plugin-dts": "^4.5.4",
|
|
48
39
|
"vite-tsconfig-paths": "^5.1.4",
|
|
49
|
-
"vitest": "^
|
|
40
|
+
"vitest": "^4.0.7",
|
|
50
41
|
"vitest-dom": "^0.1.1"
|
|
51
42
|
},
|
|
52
43
|
"dependencies": {
|
|
53
|
-
"@rljson/hash": "^0.0.
|
|
54
|
-
"@rljson/io": "^0.0.
|
|
55
|
-
"@rljson/json": "^0.0.
|
|
56
|
-
"@rljson/rljson": "^0.0.
|
|
57
|
-
"@rljson/validate": "^0.0.
|
|
44
|
+
"@rljson/hash": "^0.0.17",
|
|
45
|
+
"@rljson/io": "^0.0.53",
|
|
46
|
+
"@rljson/json": "^0.0.23",
|
|
47
|
+
"@rljson/rljson": "^0.0.67",
|
|
48
|
+
"@rljson/validate": "^0.0.11",
|
|
49
|
+
"filtrex": "^3.1.0",
|
|
50
|
+
"object-traversal": "^1.0.1",
|
|
51
|
+
"rxjs": "^7.8.2"
|
|
58
52
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "npx vite build && tsc && cp README* dist && mkdir dist/src && cp src/example.ts dist/src",
|
|
55
|
+
"test": "npx vitest run --coverage && npm run lint",
|
|
56
|
+
"prebuild": "npm run test",
|
|
57
|
+
"lint": "npx eslint",
|
|
58
|
+
"updateGoldens": "cross-env UPDATE_GOLDENS=true npm test"
|
|
64
59
|
}
|
|
65
|
-
}
|
|
60
|
+
}
|