@wxn0brp/vql 0.6.1 → 0.6.2
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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/vql",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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
|
".": {
|