@wxn0brp/vql 0.6.1 → 0.6.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/dist/apiAbstract.d.ts +15 -0
- package/dist/apiAbstract.js +36 -2
- package/dist/cpu/relation.js +2 -3
- package/dist/cpu/utils.d.ts +0 -1
- package/dist/cpu/utils.js +3 -17
- package/package.json +6 -6
package/dist/apiAbstract.d.ts
CHANGED
|
@@ -43,4 +43,19 @@ export interface ValtheraResolver {
|
|
|
43
43
|
removeCollection?: ResolverFn<[collection: string], boolean>;
|
|
44
44
|
}
|
|
45
45
|
export declare function createValtheraAdapter(resolver: ValtheraResolver, extendedFind?: boolean): ValtheraCompatible;
|
|
46
|
+
export type Operation = "add" | "find" | "findOne" | "update" | "updateOne" | "updateOneOrAdd" | "remove" | "removeOne" | "removeCollection";
|
|
47
|
+
export declare class AdapterBuilder {
|
|
48
|
+
private handlers;
|
|
49
|
+
private collections;
|
|
50
|
+
register(op: "add", collection: string, fn: ResolverFn<[collection: string, data: any, id_gen?: boolean], any>): any;
|
|
51
|
+
register(op: "find", collection: string, fn: ResolverFn<[collection: string, search: any, context?: any, options?: any, findOpts?: any], any[]>): any;
|
|
52
|
+
register(op: "findOne", collection: string, fn: ResolverFn<[collection: string, search: any, context?: any, findOpts?: any], any | null>): any;
|
|
53
|
+
register(op: "update", collection: string, fn: ResolverFn<[collection: string, search: any, updater: any], boolean>): any;
|
|
54
|
+
register(op: "updateOne", collection: string, fn: ResolverFn<[collection: string, search: any, updater: any], boolean>): any;
|
|
55
|
+
register(op: "updateOneOrAdd", collection: string, fn: ResolverFn<[collection: string, search: any, updater: any, add_arg?: any, context?: any, id_gen?: boolean], boolean>): any;
|
|
56
|
+
register(op: "remove", collection: string, fn: ResolverFn<[collection: string, search: any], boolean>): any;
|
|
57
|
+
register(op: "removeOne", collection: string, fn: ResolverFn<[collection: string, search: any], boolean>): any;
|
|
58
|
+
register(op: "removeCollection", collection: string, fn: ResolverFn<[collection: string], boolean>): any;
|
|
59
|
+
getAdapter(extendedFind?: boolean): ValtheraCompatible;
|
|
60
|
+
}
|
|
46
61
|
export {};
|
package/dist/apiAbstract.js
CHANGED
|
@@ -22,8 +22,6 @@ export function createValtheraAdapter(resolver, extendedFind = false) {
|
|
|
22
22
|
remove: (col, search) => safe(resolver.remove)(col, search),
|
|
23
23
|
removeOne: (col, search) => safe(resolver.removeOne)(col, search),
|
|
24
24
|
removeCollection: (col) => safe(resolver.removeCollection)(col),
|
|
25
|
-
findStream: null,
|
|
26
|
-
transaction: null,
|
|
27
25
|
};
|
|
28
26
|
adapter.c = (collection) => new CollectionManager(adapter, collection);
|
|
29
27
|
if (extendedFind) {
|
|
@@ -45,3 +43,39 @@ export function createValtheraAdapter(resolver, extendedFind = false) {
|
|
|
45
43
|
}
|
|
46
44
|
return adapter;
|
|
47
45
|
}
|
|
46
|
+
export class AdapterBuilder {
|
|
47
|
+
handlers = new Map();
|
|
48
|
+
collections = new Set();
|
|
49
|
+
register(op, collection, fn) {
|
|
50
|
+
this.handlers.set(`${op}:${collection}`, fn);
|
|
51
|
+
this.collections.add(collection);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
getAdapter(extendedFind = true) {
|
|
55
|
+
const resolve = async (op, col, ...args) => {
|
|
56
|
+
const handler = this.handlers.get(`${op}:${col}`) || this.handlers.get(`${op}:*`) || null;
|
|
57
|
+
if (!handler)
|
|
58
|
+
throw new Error(`Unimplemented method: ${op}:${col}`);
|
|
59
|
+
return handler(...args);
|
|
60
|
+
};
|
|
61
|
+
const adapter = createValtheraAdapter({
|
|
62
|
+
getCollections: async () => Array.from(this.collections),
|
|
63
|
+
issetCollection: async (col) => this.collections.has(col),
|
|
64
|
+
ensureCollection: async (col) => {
|
|
65
|
+
if (!this.collections.has(col))
|
|
66
|
+
this.collections.add(col);
|
|
67
|
+
return true;
|
|
68
|
+
},
|
|
69
|
+
add: (col, data, id_gen) => resolve("add", col, data, id_gen),
|
|
70
|
+
find: (col, search, context, options, findOpts) => resolve("find", col, search, context, options, findOpts),
|
|
71
|
+
findOne: (col, search, context, findOpts) => resolve("findOne", col, search, context, findOpts),
|
|
72
|
+
update: (col, search, up) => resolve("update", col, search, up),
|
|
73
|
+
updateOne: (col, search, up) => resolve("updateOne", col, search, up),
|
|
74
|
+
updateOneOrAdd: (col, search, up, add_data, ctx, id_gen) => resolve("updateOneOrAdd", col, search, up, add_data, ctx, id_gen),
|
|
75
|
+
remove: (col, search) => resolve("remove", col, search),
|
|
76
|
+
removeOne: (col, search) => resolve("removeOne", col, search),
|
|
77
|
+
removeCollection: (col) => resolve("removeCollection", col),
|
|
78
|
+
}, extendedFind);
|
|
79
|
+
return adapter;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/cpu/relation.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { checkRelationPermission } from "../permissions/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { parseSelect } from "./utils.js";
|
|
3
3
|
function standardizeRelationRequest(config, req) {
|
|
4
|
-
|
|
5
|
-
req.select = parseSelect(config, select);
|
|
4
|
+
req.select = parseSelect(config, req.select);
|
|
6
5
|
}
|
|
7
6
|
function checkDBsExist(cpu, req) {
|
|
8
7
|
const db = req.path[0];
|
package/dist/cpu/utils.d.ts
CHANGED
package/dist/cpu/utils.js
CHANGED
|
@@ -4,27 +4,13 @@ export function parseSelect(config, select) {
|
|
|
4
4
|
return undefined;
|
|
5
5
|
return select;
|
|
6
6
|
}
|
|
7
|
-
else {
|
|
7
|
+
else if (typeof select === "object") {
|
|
8
8
|
const keys = Object.keys(select);
|
|
9
9
|
if (!config.strictSelect && keys.length === 0)
|
|
10
10
|
return undefined;
|
|
11
11
|
return keys.filter(k => !!select[k]);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (Array.isArray(obj))
|
|
16
|
-
return obj;
|
|
17
|
-
let result = [];
|
|
18
|
-
function walk(o, path = []) {
|
|
19
|
-
if (o !== null && typeof o === "object") {
|
|
20
|
-
for (const k of Object.keys(o)) {
|
|
21
|
-
walk(o[k], [...path, k]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
result.push(path);
|
|
26
|
-
}
|
|
13
|
+
else {
|
|
14
|
+
return config.strictSelect ? [] : undefined;
|
|
27
15
|
}
|
|
28
|
-
walk(obj);
|
|
29
|
-
return result;
|
|
30
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/vql",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"author": "wxn0brP",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^24.
|
|
34
|
+
"@types/node": "^24.3.0",
|
|
35
35
|
"@wxn0brp/db": "^0.30.0",
|
|
36
|
-
"@wxn0brp/falcon-frame": "0.0.
|
|
36
|
+
"@wxn0brp/falcon-frame": "0.0.21",
|
|
37
37
|
"@wxn0brp/gate-warden": "^0.4.0",
|
|
38
|
-
"esbuild": "^0.25.
|
|
38
|
+
"esbuild": "^0.25.9",
|
|
39
39
|
"tsc-alias": "^1.8.10",
|
|
40
|
-
"typescript": "^5.
|
|
40
|
+
"typescript": "^5.9.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@wxn0brp/lucerna-log": "^0.
|
|
43
|
+
"@wxn0brp/lucerna-log": "^0.2.0"
|
|
44
44
|
},
|
|
45
45
|
"exports": {
|
|
46
46
|
".": {
|