@wxn0brp/vql 0.4.0 → 0.4.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/falconFrame.d.ts +1 -0
- package/dist/falconFrame.js +12 -0
- package/dist/processor.d.ts +1 -1
- package/dist/processor.js +2 -2
- package/dist/sheet/index.d.ts +1 -1
- package/dist/sheet/index.js +11 -5
- package/dist/types/vql.d.ts +49 -49
- package/dist/vql.d.ts +119 -122
- package/package.json +2 -3
package/dist/falconFrame.d.ts
CHANGED
package/dist/falconFrame.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseStringQuery } from "./cpu/string/index.js";
|
|
1
2
|
export function FF_VQL(app, processor, options = {}) {
|
|
2
3
|
const path = options.path || "/VQL";
|
|
3
4
|
const getContext = options.getUser || (() => ({}));
|
|
@@ -14,4 +15,15 @@ export function FF_VQL(app, processor, options = {}) {
|
|
|
14
15
|
return { err: true, msg: e.message };
|
|
15
16
|
}
|
|
16
17
|
});
|
|
18
|
+
if (options.dev) {
|
|
19
|
+
app.get(path + "-query", (req, res) => {
|
|
20
|
+
try {
|
|
21
|
+
return res.json(parseStringQuery(req.query?.query || ""));
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
res.status(500);
|
|
25
|
+
return { err: true, msg: e.message };
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
17
29
|
}
|
package/dist/processor.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare class VQLProcessor<GW = any> {
|
|
|
9
9
|
relation: Relation;
|
|
10
10
|
preDefinedSheets: Map<string, VQL>;
|
|
11
11
|
constructor(dbInstances: Record<string, ValtheraCompatible>, gw?: GateWarden<GW>, config?: VQLConfig);
|
|
12
|
-
execute<T = any>(queryRaw: VqlQueryRaw
|
|
12
|
+
execute<T = any>(queryRaw: VqlQueryRaw<T>, user: any): Promise<T | VQLError>;
|
|
13
13
|
}
|
package/dist/processor.js
CHANGED
|
@@ -4,7 +4,7 @@ import { executeRelation } from "./cpu/relation.js";
|
|
|
4
4
|
import { executeQuery } from "./cpu/request.js";
|
|
5
5
|
import { parseStringQuery } from "./cpu/string/index.js";
|
|
6
6
|
import logger from "./logger.js";
|
|
7
|
-
import {
|
|
7
|
+
import { executeSheetAndReplaceVars } from "./sheet/index.js";
|
|
8
8
|
import { validateRaw, validateVql } from "./valid.js";
|
|
9
9
|
export class VQLProcessor {
|
|
10
10
|
dbInstances;
|
|
@@ -48,7 +48,7 @@ export class VQLProcessor {
|
|
|
48
48
|
logger.warn("Raw validation failed:", validateRawResult);
|
|
49
49
|
return validateRawResult;
|
|
50
50
|
}
|
|
51
|
-
const query =
|
|
51
|
+
const query = executeSheetAndReplaceVars(queryRaw, this.preDefinedSheets, user);
|
|
52
52
|
logger.debug("Executed sheet (expanded query):", query);
|
|
53
53
|
const validateVqlResult = validateVql(this.config, query);
|
|
54
54
|
if (validateVqlResult !== true) {
|
package/dist/sheet/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { VQL, VQLR } from "../types/vql.js";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function executeSheetAndReplaceVars(query: VQLR, preDefinedSheets: Map<string, VQL>, user: any): VQL;
|
package/dist/sheet/index.js
CHANGED
|
@@ -46,7 +46,7 @@ function replaceVariables(obj, variables) {
|
|
|
46
46
|
}
|
|
47
47
|
return obj;
|
|
48
48
|
}
|
|
49
|
-
export function
|
|
49
|
+
export function executeSheetAndReplaceVars(query, preDefinedSheets, user) {
|
|
50
50
|
if ("ref" in query) {
|
|
51
51
|
if (preDefinedSheets.has(query.ref)) {
|
|
52
52
|
const ref = preDefinedSheets.get(query.ref);
|
|
@@ -56,9 +56,15 @@ export function executeSheet(query, preDefinedSheets) {
|
|
|
56
56
|
}
|
|
57
57
|
delete query.ref;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
query.var = {
|
|
60
|
+
_me: user?.id || user?._id || user,
|
|
61
|
+
_now: Date.now(),
|
|
62
|
+
_nowShort: Math.floor(Date.now() / 1000),
|
|
63
|
+
__now: Date.now().toString(),
|
|
64
|
+
__nowShort: Math.floor(Date.now() / 1000).toString(),
|
|
65
|
+
...(query.var || {})
|
|
66
|
+
};
|
|
67
|
+
query = replaceVariables(query, query.var);
|
|
68
|
+
delete query.var;
|
|
63
69
|
return query;
|
|
64
70
|
}
|
package/dist/types/vql.d.ts
CHANGED
|
@@ -2,39 +2,39 @@ import { RelationTypes } from "@wxn0brp/db";
|
|
|
2
2
|
import { Search, Arg } from "@wxn0brp/db-core/types/arg";
|
|
3
3
|
import { DbFindOpts, FindOpts } from "@wxn0brp/db-core/types/options";
|
|
4
4
|
import { UpdaterArg } from "@wxn0brp/db-core/types/updater";
|
|
5
|
-
export
|
|
6
|
-
find: VQLFind
|
|
7
|
-
findOne: VQLFindOne
|
|
8
|
-
f: VQLFindOne
|
|
9
|
-
add: VQLAdd
|
|
10
|
-
update: VQLUpdate
|
|
11
|
-
updateOne: VQLUpdateOne
|
|
12
|
-
remove: VQLRemove
|
|
13
|
-
removeOne: VQLRemoveOne
|
|
14
|
-
updateOneOrAdd: VQLUpdateOneOrAdd
|
|
5
|
+
export interface VQLQuery<T = any> {
|
|
6
|
+
find: VQLFind<T>;
|
|
7
|
+
findOne: VQLFindOne<T>;
|
|
8
|
+
f: VQLFindOne<T>;
|
|
9
|
+
add: VQLAdd<T>;
|
|
10
|
+
update: VQLUpdate<T>;
|
|
11
|
+
updateOne: VQLUpdateOne<T>;
|
|
12
|
+
remove: VQLRemove<T>;
|
|
13
|
+
removeOne: VQLRemoveOne<T>;
|
|
14
|
+
updateOneOrAdd: VQLUpdateOneOrAdd<T>;
|
|
15
15
|
removeCollection: VQLCollectionOperation;
|
|
16
16
|
checkCollection: VQLCollectionOperation;
|
|
17
17
|
issetCollection: VQLCollectionOperation;
|
|
18
18
|
getCollections: {};
|
|
19
|
-
}
|
|
20
|
-
export type VQLQueryData = {
|
|
21
|
-
find: VQLFind
|
|
19
|
+
}
|
|
20
|
+
export type VQLQueryData<T = any> = {
|
|
21
|
+
find: VQLFind<T>;
|
|
22
22
|
} | {
|
|
23
|
-
findOne: VQLFindOne
|
|
23
|
+
findOne: VQLFindOne<T>;
|
|
24
24
|
} | {
|
|
25
|
-
f: VQLFindOne
|
|
25
|
+
f: VQLFindOne<T>;
|
|
26
26
|
} | {
|
|
27
|
-
add: VQLAdd
|
|
27
|
+
add: VQLAdd<T>;
|
|
28
28
|
} | {
|
|
29
|
-
update: VQLUpdate
|
|
29
|
+
update: VQLUpdate<T>;
|
|
30
30
|
} | {
|
|
31
|
-
updateOne: VQLUpdateOne
|
|
31
|
+
updateOne: VQLUpdateOne<T>;
|
|
32
32
|
} | {
|
|
33
|
-
remove: VQLRemove
|
|
33
|
+
remove: VQLRemove<T>;
|
|
34
34
|
} | {
|
|
35
|
-
removeOne: VQLRemoveOne
|
|
35
|
+
removeOne: VQLRemoveOne<T>;
|
|
36
36
|
} | {
|
|
37
|
-
updateOneOrAdd: VQLUpdateOneOrAdd
|
|
37
|
+
updateOneOrAdd: VQLUpdateOneOrAdd<T>;
|
|
38
38
|
} | {
|
|
39
39
|
removeCollection: VQLCollectionOperation;
|
|
40
40
|
} | {
|
|
@@ -44,56 +44,56 @@ export type VQLQueryData = {
|
|
|
44
44
|
} | {
|
|
45
45
|
getCollections: {};
|
|
46
46
|
};
|
|
47
|
-
export interface VQLRequest {
|
|
47
|
+
export interface VQLRequest<T = any> {
|
|
48
48
|
db: string;
|
|
49
|
-
d: VQLQueryData
|
|
49
|
+
d: VQLQueryData<T>;
|
|
50
50
|
}
|
|
51
|
-
export interface VQLFind {
|
|
51
|
+
export interface VQLFind<T = any> {
|
|
52
52
|
collection: string;
|
|
53
|
-
search?: Search
|
|
53
|
+
search?: Search<T>;
|
|
54
54
|
limit?: number;
|
|
55
55
|
fields?: VQLFields;
|
|
56
56
|
select?: VQLFields;
|
|
57
57
|
relations?: VQLRelations;
|
|
58
|
-
options?: DbFindOpts
|
|
59
|
-
searchOpts?: FindOpts
|
|
58
|
+
options?: DbFindOpts<T>;
|
|
59
|
+
searchOpts?: FindOpts<T>;
|
|
60
60
|
}
|
|
61
|
-
export interface VQLFindOne {
|
|
61
|
+
export interface VQLFindOne<T = any> {
|
|
62
62
|
collection: string;
|
|
63
|
-
search: Search
|
|
63
|
+
search: Search<T>;
|
|
64
64
|
fields?: VQLFields;
|
|
65
65
|
select?: VQLFields;
|
|
66
66
|
relations?: VQLRelations;
|
|
67
|
-
searchOpts?: FindOpts
|
|
67
|
+
searchOpts?: FindOpts<T>;
|
|
68
68
|
}
|
|
69
|
-
export interface VQLAdd {
|
|
69
|
+
export interface VQLAdd<T = any> {
|
|
70
70
|
collection: string;
|
|
71
|
-
data: Arg
|
|
71
|
+
data: Arg<T>;
|
|
72
72
|
id_gen?: boolean;
|
|
73
73
|
}
|
|
74
|
-
export interface VQLUpdate {
|
|
74
|
+
export interface VQLUpdate<T = any> {
|
|
75
75
|
collection: string;
|
|
76
|
-
search: Search
|
|
77
|
-
updater: UpdaterArg
|
|
76
|
+
search: Search<T>;
|
|
77
|
+
updater: UpdaterArg<T>;
|
|
78
78
|
}
|
|
79
|
-
export interface VQLUpdateOne {
|
|
79
|
+
export interface VQLUpdateOne<T = any> {
|
|
80
80
|
collection: string;
|
|
81
|
-
search: Search
|
|
82
|
-
updater: UpdaterArg
|
|
81
|
+
search: Search<T>;
|
|
82
|
+
updater: UpdaterArg<T>;
|
|
83
83
|
}
|
|
84
|
-
export interface VQLRemove {
|
|
84
|
+
export interface VQLRemove<T = any> {
|
|
85
85
|
collection: string;
|
|
86
|
-
search: Search
|
|
86
|
+
search: Search<T>;
|
|
87
87
|
}
|
|
88
|
-
export interface VQLRemoveOne {
|
|
88
|
+
export interface VQLRemoveOne<T = any> {
|
|
89
89
|
collection: string;
|
|
90
|
-
search: Search
|
|
90
|
+
search: Search<T>;
|
|
91
91
|
}
|
|
92
|
-
export interface VQLUpdateOneOrAdd {
|
|
92
|
+
export interface VQLUpdateOneOrAdd<T = any> {
|
|
93
93
|
collection: string;
|
|
94
|
-
search: Search
|
|
95
|
-
updater: UpdaterArg
|
|
96
|
-
add_arg?: Arg
|
|
94
|
+
search: Search<T>;
|
|
95
|
+
updater: UpdaterArg<T>;
|
|
96
|
+
add_arg?: Arg<T>;
|
|
97
97
|
id_gen?: boolean;
|
|
98
98
|
}
|
|
99
99
|
export interface VQLCollectionOperation {
|
|
@@ -121,15 +121,15 @@ type VQLRefRequired = VQLRef & Required<Pick<VQLRef, "ref">>;
|
|
|
121
121
|
type DeepPartial<T> = {
|
|
122
122
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
123
123
|
};
|
|
124
|
-
export type VQL = (VQLRequest | RelationQuery) & VQLRef;
|
|
125
|
-
export type VQLR = VQL | (DeepPartial<VQL
|
|
124
|
+
export type VQL<T = any> = (VQLRequest<T> | RelationQuery) & VQLRef;
|
|
125
|
+
export type VQLR<T = any> = VQL<T> | (DeepPartial<VQL<T>> & VQLRefRequired) | VQLRefRequired;
|
|
126
126
|
export interface VQLError {
|
|
127
127
|
err: true;
|
|
128
128
|
msg: string;
|
|
129
129
|
c: number;
|
|
130
130
|
why?: string;
|
|
131
131
|
}
|
|
132
|
-
export type VqlQueryRaw = VQLR | string | {
|
|
132
|
+
export type VqlQueryRaw<T = any> = VQLR<T> | string | {
|
|
133
133
|
query: string;
|
|
134
134
|
} & VQLRef;
|
|
135
135
|
export {};
|
package/dist/vql.d.ts
CHANGED
|
@@ -1,114 +1,111 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface Data {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface VContext {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export type KeysMatching<T, V, C = V> = {
|
|
10
|
+
[K in keyof T]-?: T[K] extends C ? K : never;
|
|
11
|
+
}[keyof T];
|
|
12
|
+
export type PartialOfType<T, V, C = V> = Partial<Record<KeysMatching<T, V, C>, V>>;
|
|
13
|
+
export type PartialPickMatching<T, V, C = V> = Partial<Pick<T, KeysMatching<T, V, C>>>;
|
|
4
14
|
/** Logical Operators */
|
|
5
|
-
export type LogicalOperators = {
|
|
15
|
+
export type LogicalOperators<T = any> = {
|
|
6
16
|
/**
|
|
7
17
|
* Recursively applies multiple conditions, all of which must evaluate to true.
|
|
8
18
|
* Can include other operators such as $gt, $exists, or nested $and/$or conditions.
|
|
9
19
|
*/
|
|
10
|
-
$and?: Array<SearchOptions
|
|
20
|
+
$and?: Array<SearchOptions<T>>;
|
|
11
21
|
/**
|
|
12
22
|
* Recursively applies multiple conditions, at least one of which must evaluate to true.
|
|
13
23
|
* Can include other operators such as $lt, $type, or nested $and/$or conditions.
|
|
14
24
|
*/
|
|
15
|
-
$or?: Array<SearchOptions
|
|
25
|
+
$or?: Array<SearchOptions<T>>;
|
|
16
26
|
/**
|
|
17
27
|
* Negates a single condition.
|
|
18
28
|
* Can include any other operator as its value.
|
|
19
29
|
*/
|
|
20
|
-
$not?: SearchOptions
|
|
30
|
+
$not?: SearchOptions<T>;
|
|
21
31
|
};
|
|
22
32
|
/** Comparison Operators */
|
|
23
|
-
export type ComparisonOperators = {
|
|
24
|
-
$gt?:
|
|
25
|
-
$lt?:
|
|
26
|
-
$gte?:
|
|
27
|
-
$lte?:
|
|
28
|
-
$
|
|
29
|
-
$nin?: Record<string, any[]>;
|
|
30
|
-
$between?: Record<string, [
|
|
33
|
+
export type ComparisonOperators<T = any> = {
|
|
34
|
+
$gt?: PartialOfType<T, number>;
|
|
35
|
+
$lt?: PartialOfType<T, number>;
|
|
36
|
+
$gte?: PartialOfType<T, number>;
|
|
37
|
+
$lte?: PartialOfType<T, number>;
|
|
38
|
+
$between?: PartialOfType<T, [
|
|
31
39
|
number,
|
|
32
40
|
number
|
|
33
|
-
]>;
|
|
41
|
+
], number>;
|
|
42
|
+
$in?: Partial<Record<keyof T, T[keyof T][]>>;
|
|
43
|
+
$nin?: Partial<Record<keyof T, T[keyof T][]>>;
|
|
34
44
|
};
|
|
35
45
|
/** Type and Existence Operators */
|
|
36
|
-
export type TypeAndExistenceOperators = {
|
|
37
|
-
$exists?:
|
|
38
|
-
$type?:
|
|
46
|
+
export type TypeAndExistenceOperators<T = any> = {
|
|
47
|
+
$exists?: PartialOfType<T, boolean, any>;
|
|
48
|
+
$type?: PartialOfType<T, string>;
|
|
39
49
|
};
|
|
40
50
|
/** Array Operators */
|
|
41
|
-
export type ArrayOperators = {
|
|
42
|
-
$arrinc?:
|
|
43
|
-
$arrincall?:
|
|
44
|
-
$size?:
|
|
51
|
+
export type ArrayOperators<T = any> = {
|
|
52
|
+
$arrinc?: PartialPickMatching<T, any[]>;
|
|
53
|
+
$arrincall?: PartialPickMatching<T, any[]>;
|
|
54
|
+
$size?: PartialOfType<T, number>;
|
|
45
55
|
};
|
|
46
56
|
/** String Operators */
|
|
47
|
-
export type StringOperators = {
|
|
48
|
-
$regex?:
|
|
49
|
-
$startsWith?:
|
|
50
|
-
$endsWith?:
|
|
57
|
+
export type StringOperators<T = any> = {
|
|
58
|
+
$regex?: PartialOfType<T, RegExp, string>;
|
|
59
|
+
$startsWith?: PartialOfType<T, string>;
|
|
60
|
+
$endsWith?: PartialOfType<T, string>;
|
|
51
61
|
};
|
|
52
62
|
/** Other Operators */
|
|
53
|
-
export type OtherOperators = {
|
|
54
|
-
$subset?: Record<
|
|
63
|
+
export type OtherOperators<T = any> = {
|
|
64
|
+
$subset?: Partial<Record<keyof T, T[keyof T]>>;
|
|
55
65
|
};
|
|
56
66
|
/** Predefined Search Operators */
|
|
57
|
-
export type PredefinedSearchOperators = LogicalOperators & ComparisonOperators & TypeAndExistenceOperators & ArrayOperators & StringOperators & OtherOperators
|
|
67
|
+
export type PredefinedSearchOperators<T = any> = LogicalOperators<T> & ComparisonOperators<T> & TypeAndExistenceOperators<T> & ArrayOperators<T> & StringOperators<T> & OtherOperators<T>;
|
|
58
68
|
/**
|
|
59
69
|
* SearchOptions can be either a function or an object with predefined operators.
|
|
60
70
|
*/
|
|
61
|
-
export type SearchOptions = PredefinedSearchOperators & Arg
|
|
62
|
-
export interface VContext {
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Predefined type for updating data.
|
|
67
|
-
*/
|
|
71
|
+
export type SearchOptions<T = any> = PredefinedSearchOperators<T> & Arg<T>;
|
|
68
72
|
/** Arrays */
|
|
69
|
-
export type ArrayUpdater = {
|
|
70
|
-
$push?: any
|
|
73
|
+
export type ArrayUpdater<T = any> = {
|
|
74
|
+
$push?: PartialOfType<T, any>;
|
|
71
75
|
/** Pushes items into an array and removes duplicates */
|
|
72
|
-
$pushset?: any
|
|
73
|
-
$pull?: any
|
|
74
|
-
$pullall?: any
|
|
76
|
+
$pushset?: PartialOfType<T, any>;
|
|
77
|
+
$pull?: PartialOfType<T, any>;
|
|
78
|
+
$pullall?: PartialOfType<T, any>;
|
|
75
79
|
};
|
|
76
80
|
/** Objects */
|
|
77
|
-
export type ObjectUpdater = {
|
|
78
|
-
$merge?: any
|
|
81
|
+
export type ObjectUpdater<T = any> = {
|
|
82
|
+
$merge?: PartialOfType<T, any[]>;
|
|
79
83
|
};
|
|
80
84
|
/** Values */
|
|
81
|
-
export type ValueUpdater = {
|
|
82
|
-
$
|
|
83
|
-
$
|
|
84
|
-
$
|
|
85
|
-
$
|
|
86
|
-
$rename?: any;
|
|
87
|
-
};
|
|
88
|
-
export type UpdaterArg = ArrayUpdater & ObjectUpdater & ValueUpdater & {
|
|
89
|
-
[key: string]: any;
|
|
85
|
+
export type ValueUpdater<T = any> = {
|
|
86
|
+
$inc?: PartialOfType<T, number>;
|
|
87
|
+
$dec?: PartialOfType<T, number>;
|
|
88
|
+
$unset?: PartialOfType<T, any>;
|
|
89
|
+
$rename?: PartialOfType<T, any>;
|
|
90
90
|
};
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
[
|
|
94
|
-
}
|
|
91
|
+
export type UpdaterArg<T = any> = ArrayUpdater<T> & ObjectUpdater<T> & ValueUpdater<T> & Arg<T>;
|
|
92
|
+
export type Arg<T = any> = {
|
|
93
|
+
[K in keyof T]?: any;
|
|
94
|
+
} & Record<string, any>;
|
|
95
95
|
export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
|
|
96
96
|
export type UpdaterFunc<T = any> = (data: T, context: VContext) => boolean;
|
|
97
|
-
export type Search<T = any> = SearchOptions | SearchFunc<T>;
|
|
98
|
-
export type Updater<T = any> = UpdaterArg | UpdaterArg[] | UpdaterFunc<T>;
|
|
99
|
-
export interface
|
|
100
|
-
[key: string]: any;
|
|
101
|
-
}
|
|
102
|
-
export interface DbFindOpts {
|
|
97
|
+
export type Search<T = any> = SearchOptions<T> | SearchFunc<T>;
|
|
98
|
+
export type Updater<T = any> = UpdaterArg<T> | UpdaterArg<T>[] | UpdaterFunc<T>;
|
|
99
|
+
export interface DbFindOpts<T = any> {
|
|
103
100
|
reverse?: boolean;
|
|
104
101
|
max?: number;
|
|
105
102
|
offset?: number;
|
|
106
|
-
sortBy?:
|
|
103
|
+
sortBy?: KeysMatching<T, any>;
|
|
107
104
|
sortAsc?: boolean;
|
|
108
105
|
}
|
|
109
|
-
export interface FindOpts {
|
|
110
|
-
select?:
|
|
111
|
-
exclude?:
|
|
106
|
+
export interface FindOpts<T = any> {
|
|
107
|
+
select?: KeysMatching<T, any>[];
|
|
108
|
+
exclude?: KeysMatching<T, any>[];
|
|
112
109
|
transform?: Function;
|
|
113
110
|
}
|
|
114
111
|
declare class CollectionManager {
|
|
@@ -153,15 +150,15 @@ export interface ValtheraCompatible {
|
|
|
153
150
|
getCollections(): Promise<string[]>;
|
|
154
151
|
checkCollection(collection: string): Promise<boolean>;
|
|
155
152
|
issetCollection(collection: string): Promise<boolean>;
|
|
156
|
-
add<T = Data>(collection: string, data: Arg
|
|
157
|
-
find<T = Data>(collection: string, search: Search
|
|
158
|
-
findOne<T = Data>(collection: string, search: Search
|
|
159
|
-
update(collection: string, search: Search
|
|
160
|
-
updateOne(collection: string, search: Search
|
|
161
|
-
remove(collection: string, search: Search
|
|
162
|
-
removeOne(collection: string, search: Search
|
|
153
|
+
add<T = Data>(collection: string, data: Arg<T>, id_gen?: boolean): Promise<T>;
|
|
154
|
+
find<T = Data>(collection: string, search: Search<T>, context?: VContext, options?: DbFindOpts<T>, findOpts?: FindOpts<T>): Promise<T[]>;
|
|
155
|
+
findOne<T = Data>(collection: string, search: Search<T>, context?: VContext, findOpts?: FindOpts<T>): Promise<T | null>;
|
|
156
|
+
update<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, context?: VContext): Promise<boolean>;
|
|
157
|
+
updateOne<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, context?: VContext): Promise<boolean>;
|
|
158
|
+
remove<T = Data>(collection: string, search: Search<T>, context?: VContext): Promise<boolean>;
|
|
159
|
+
removeOne<T = Data>(collection: string, search: Search<T>, context?: VContext): Promise<boolean>;
|
|
163
160
|
removeCollection(collection: string): Promise<boolean>;
|
|
164
|
-
updateOneOrAdd(collection: string, search: Search
|
|
161
|
+
updateOneOrAdd<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, add_arg?: Arg<T>, context?: VContext, id_gen?: boolean): Promise<boolean>;
|
|
165
162
|
}
|
|
166
163
|
declare namespace RelationTypes {
|
|
167
164
|
type Path = [
|
|
@@ -192,39 +189,39 @@ declare namespace RelationTypes {
|
|
|
192
189
|
};
|
|
193
190
|
}
|
|
194
191
|
}
|
|
195
|
-
export
|
|
196
|
-
find: VQLFind
|
|
197
|
-
findOne: VQLFindOne
|
|
198
|
-
f: VQLFindOne
|
|
199
|
-
add: VQLAdd
|
|
200
|
-
update: VQLUpdate
|
|
201
|
-
updateOne: VQLUpdateOne
|
|
202
|
-
remove: VQLRemove
|
|
203
|
-
removeOne: VQLRemoveOne
|
|
204
|
-
updateOneOrAdd: VQLUpdateOneOrAdd
|
|
192
|
+
export interface VQLQuery<T = any> {
|
|
193
|
+
find: VQLFind<T>;
|
|
194
|
+
findOne: VQLFindOne<T>;
|
|
195
|
+
f: VQLFindOne<T>;
|
|
196
|
+
add: VQLAdd<T>;
|
|
197
|
+
update: VQLUpdate<T>;
|
|
198
|
+
updateOne: VQLUpdateOne<T>;
|
|
199
|
+
remove: VQLRemove<T>;
|
|
200
|
+
removeOne: VQLRemoveOne<T>;
|
|
201
|
+
updateOneOrAdd: VQLUpdateOneOrAdd<T>;
|
|
205
202
|
removeCollection: VQLCollectionOperation;
|
|
206
203
|
checkCollection: VQLCollectionOperation;
|
|
207
204
|
issetCollection: VQLCollectionOperation;
|
|
208
205
|
getCollections: {};
|
|
209
|
-
}
|
|
210
|
-
export type VQLQueryData = {
|
|
211
|
-
find: VQLFind
|
|
206
|
+
}
|
|
207
|
+
export type VQLQueryData<T = any> = {
|
|
208
|
+
find: VQLFind<T>;
|
|
212
209
|
} | {
|
|
213
|
-
findOne: VQLFindOne
|
|
210
|
+
findOne: VQLFindOne<T>;
|
|
214
211
|
} | {
|
|
215
|
-
f: VQLFindOne
|
|
212
|
+
f: VQLFindOne<T>;
|
|
216
213
|
} | {
|
|
217
|
-
add: VQLAdd
|
|
214
|
+
add: VQLAdd<T>;
|
|
218
215
|
} | {
|
|
219
|
-
update: VQLUpdate
|
|
216
|
+
update: VQLUpdate<T>;
|
|
220
217
|
} | {
|
|
221
|
-
updateOne: VQLUpdateOne
|
|
218
|
+
updateOne: VQLUpdateOne<T>;
|
|
222
219
|
} | {
|
|
223
|
-
remove: VQLRemove
|
|
220
|
+
remove: VQLRemove<T>;
|
|
224
221
|
} | {
|
|
225
|
-
removeOne: VQLRemoveOne
|
|
222
|
+
removeOne: VQLRemoveOne<T>;
|
|
226
223
|
} | {
|
|
227
|
-
updateOneOrAdd: VQLUpdateOneOrAdd
|
|
224
|
+
updateOneOrAdd: VQLUpdateOneOrAdd<T>;
|
|
228
225
|
} | {
|
|
229
226
|
removeCollection: VQLCollectionOperation;
|
|
230
227
|
} | {
|
|
@@ -234,56 +231,56 @@ export type VQLQueryData = {
|
|
|
234
231
|
} | {
|
|
235
232
|
getCollections: {};
|
|
236
233
|
};
|
|
237
|
-
export interface VQLRequest {
|
|
234
|
+
export interface VQLRequest<T = any> {
|
|
238
235
|
db: string;
|
|
239
|
-
d: VQLQueryData
|
|
236
|
+
d: VQLQueryData<T>;
|
|
240
237
|
}
|
|
241
|
-
export interface VQLFind {
|
|
238
|
+
export interface VQLFind<T = any> {
|
|
242
239
|
collection: string;
|
|
243
|
-
search?: Search
|
|
240
|
+
search?: Search<T>;
|
|
244
241
|
limit?: number;
|
|
245
242
|
fields?: VQLFields;
|
|
246
243
|
select?: VQLFields;
|
|
247
244
|
relations?: VQLRelations;
|
|
248
|
-
options?: DbFindOpts
|
|
249
|
-
searchOpts?: FindOpts
|
|
245
|
+
options?: DbFindOpts<T>;
|
|
246
|
+
searchOpts?: FindOpts<T>;
|
|
250
247
|
}
|
|
251
|
-
export interface VQLFindOne {
|
|
248
|
+
export interface VQLFindOne<T = any> {
|
|
252
249
|
collection: string;
|
|
253
|
-
search: Search
|
|
250
|
+
search: Search<T>;
|
|
254
251
|
fields?: VQLFields;
|
|
255
252
|
select?: VQLFields;
|
|
256
253
|
relations?: VQLRelations;
|
|
257
|
-
searchOpts?: FindOpts
|
|
254
|
+
searchOpts?: FindOpts<T>;
|
|
258
255
|
}
|
|
259
|
-
export interface VQLAdd {
|
|
256
|
+
export interface VQLAdd<T = any> {
|
|
260
257
|
collection: string;
|
|
261
|
-
data: Arg
|
|
258
|
+
data: Arg<T>;
|
|
262
259
|
id_gen?: boolean;
|
|
263
260
|
}
|
|
264
|
-
export interface VQLUpdate {
|
|
261
|
+
export interface VQLUpdate<T = any> {
|
|
265
262
|
collection: string;
|
|
266
|
-
search: Search
|
|
267
|
-
updater: UpdaterArg
|
|
263
|
+
search: Search<T>;
|
|
264
|
+
updater: UpdaterArg<T>;
|
|
268
265
|
}
|
|
269
|
-
export interface VQLUpdateOne {
|
|
266
|
+
export interface VQLUpdateOne<T = any> {
|
|
270
267
|
collection: string;
|
|
271
|
-
search: Search
|
|
272
|
-
updater: UpdaterArg
|
|
268
|
+
search: Search<T>;
|
|
269
|
+
updater: UpdaterArg<T>;
|
|
273
270
|
}
|
|
274
|
-
export interface VQLRemove {
|
|
271
|
+
export interface VQLRemove<T = any> {
|
|
275
272
|
collection: string;
|
|
276
|
-
search: Search
|
|
273
|
+
search: Search<T>;
|
|
277
274
|
}
|
|
278
|
-
export interface VQLRemoveOne {
|
|
275
|
+
export interface VQLRemoveOne<T = any> {
|
|
279
276
|
collection: string;
|
|
280
|
-
search: Search
|
|
277
|
+
search: Search<T>;
|
|
281
278
|
}
|
|
282
|
-
export interface VQLUpdateOneOrAdd {
|
|
279
|
+
export interface VQLUpdateOneOrAdd<T = any> {
|
|
283
280
|
collection: string;
|
|
284
|
-
search: Search
|
|
285
|
-
updater: UpdaterArg
|
|
286
|
-
add_arg?: Arg
|
|
281
|
+
search: Search<T>;
|
|
282
|
+
updater: UpdaterArg<T>;
|
|
283
|
+
add_arg?: Arg<T>;
|
|
287
284
|
id_gen?: boolean;
|
|
288
285
|
}
|
|
289
286
|
export interface VQLCollectionOperation {
|
|
@@ -311,15 +308,15 @@ export type VQLRefRequired = VQLRef & Required<Pick<VQLRef, "ref">>;
|
|
|
311
308
|
export type DeepPartial<T> = {
|
|
312
309
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
313
310
|
};
|
|
314
|
-
export type VQL = (VQLRequest | RelationQuery) & VQLRef;
|
|
315
|
-
export type VQLR = VQL | (DeepPartial<VQL
|
|
311
|
+
export type VQL<T = any> = (VQLRequest<T> | RelationQuery) & VQLRef;
|
|
312
|
+
export type VQLR<T = any> = VQL<T> | (DeepPartial<VQL<T>> & VQLRefRequired) | VQLRefRequired;
|
|
316
313
|
export interface VQLError {
|
|
317
314
|
err: true;
|
|
318
315
|
msg: string;
|
|
319
316
|
c: number;
|
|
320
317
|
why?: string;
|
|
321
318
|
}
|
|
322
|
-
export type VqlQueryRaw = VQLR | string | {
|
|
319
|
+
export type VqlQueryRaw<T = any> = VQLR<T> | string | {
|
|
323
320
|
query: string;
|
|
324
321
|
} & VQLRef;
|
|
325
322
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/vql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"author": "wxn0brP",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@wxn0brp/db-core": ">=0.0.1 <0.1.0",
|
|
19
|
-
"@wxn0brp/falcon-frame": ">=0.0.
|
|
19
|
+
"@wxn0brp/falcon-frame": ">=0.0.18"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"@wxn0brp/falcon-frame": {
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"typescript-json-schema": "^0.65.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@wxn0brp/db-core": "^0.0.2",
|
|
41
40
|
"@wxn0brp/gate-warden": ">=0.3.0",
|
|
42
41
|
"@wxn0brp/lucerna-log": "^0.1.1",
|
|
43
42
|
"ajv": "^8.17.1",
|