@wxn0brp/vql 0.4.0 → 0.4.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/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/package.json +2 -3
- package/dist/vql.d.ts +0 -326
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wxn0brp/vql",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
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",
|
package/dist/vql.d.ts
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
-
|
|
3
|
-
export type Id = string;
|
|
4
|
-
/** Logical Operators */
|
|
5
|
-
export type LogicalOperators = {
|
|
6
|
-
/**
|
|
7
|
-
* Recursively applies multiple conditions, all of which must evaluate to true.
|
|
8
|
-
* Can include other operators such as $gt, $exists, or nested $and/$or conditions.
|
|
9
|
-
*/
|
|
10
|
-
$and?: Array<SearchOptions>;
|
|
11
|
-
/**
|
|
12
|
-
* Recursively applies multiple conditions, at least one of which must evaluate to true.
|
|
13
|
-
* Can include other operators such as $lt, $type, or nested $and/$or conditions.
|
|
14
|
-
*/
|
|
15
|
-
$or?: Array<SearchOptions>;
|
|
16
|
-
/**
|
|
17
|
-
* Negates a single condition.
|
|
18
|
-
* Can include any other operator as its value.
|
|
19
|
-
*/
|
|
20
|
-
$not?: SearchOptions;
|
|
21
|
-
};
|
|
22
|
-
/** Comparison Operators */
|
|
23
|
-
export type ComparisonOperators = {
|
|
24
|
-
$gt?: Record<string, number>;
|
|
25
|
-
$lt?: Record<string, number>;
|
|
26
|
-
$gte?: Record<string, number>;
|
|
27
|
-
$lte?: Record<string, number>;
|
|
28
|
-
$in?: Record<string, any[]>;
|
|
29
|
-
$nin?: Record<string, any[]>;
|
|
30
|
-
$between?: Record<string, [
|
|
31
|
-
number,
|
|
32
|
-
number
|
|
33
|
-
]>;
|
|
34
|
-
};
|
|
35
|
-
/** Type and Existence Operators */
|
|
36
|
-
export type TypeAndExistenceOperators = {
|
|
37
|
-
$exists?: Record<string, boolean>;
|
|
38
|
-
$type?: Record<string, string>;
|
|
39
|
-
};
|
|
40
|
-
/** Array Operators */
|
|
41
|
-
export type ArrayOperators = {
|
|
42
|
-
$arrinc?: Record<string, any[]>;
|
|
43
|
-
$arrincall?: Record<string, any[]>;
|
|
44
|
-
$size?: Record<string, number>;
|
|
45
|
-
};
|
|
46
|
-
/** String Operators */
|
|
47
|
-
export type StringOperators = {
|
|
48
|
-
$regex?: Record<string, RegExp>;
|
|
49
|
-
$startsWith?: Record<string, string>;
|
|
50
|
-
$endsWith?: Record<string, string>;
|
|
51
|
-
};
|
|
52
|
-
/** Other Operators */
|
|
53
|
-
export type OtherOperators = {
|
|
54
|
-
$subset?: Record<string, any>;
|
|
55
|
-
};
|
|
56
|
-
/** Predefined Search Operators */
|
|
57
|
-
export type PredefinedSearchOperators = LogicalOperators & ComparisonOperators & TypeAndExistenceOperators & ArrayOperators & StringOperators & OtherOperators;
|
|
58
|
-
/**
|
|
59
|
-
* SearchOptions can be either a function or an object with predefined operators.
|
|
60
|
-
*/
|
|
61
|
-
export type SearchOptions = PredefinedSearchOperators & Arg;
|
|
62
|
-
export interface VContext {
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Predefined type for updating data.
|
|
67
|
-
*/
|
|
68
|
-
/** Arrays */
|
|
69
|
-
export type ArrayUpdater = {
|
|
70
|
-
$push?: any;
|
|
71
|
-
/** Pushes items into an array and removes duplicates */
|
|
72
|
-
$pushset?: any;
|
|
73
|
-
$pull?: any;
|
|
74
|
-
$pullall?: any;
|
|
75
|
-
};
|
|
76
|
-
/** Objects */
|
|
77
|
-
export type ObjectUpdater = {
|
|
78
|
-
$merge?: any;
|
|
79
|
-
};
|
|
80
|
-
/** Values */
|
|
81
|
-
export type ValueUpdater = {
|
|
82
|
-
$set?: any;
|
|
83
|
-
$inc?: any;
|
|
84
|
-
$dec?: any;
|
|
85
|
-
$unset?: any;
|
|
86
|
-
$rename?: any;
|
|
87
|
-
};
|
|
88
|
-
export type UpdaterArg = ArrayUpdater & ObjectUpdater & ValueUpdater & {
|
|
89
|
-
[key: string]: any;
|
|
90
|
-
};
|
|
91
|
-
export interface Arg {
|
|
92
|
-
_id?: Id;
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
}
|
|
95
|
-
export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
|
|
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 Data {
|
|
100
|
-
[key: string]: any;
|
|
101
|
-
}
|
|
102
|
-
export interface DbFindOpts {
|
|
103
|
-
reverse?: boolean;
|
|
104
|
-
max?: number;
|
|
105
|
-
offset?: number;
|
|
106
|
-
sortBy?: string;
|
|
107
|
-
sortAsc?: boolean;
|
|
108
|
-
}
|
|
109
|
-
export interface FindOpts {
|
|
110
|
-
select?: string[];
|
|
111
|
-
exclude?: string[];
|
|
112
|
-
transform?: Function;
|
|
113
|
-
}
|
|
114
|
-
declare class CollectionManager {
|
|
115
|
-
private db;
|
|
116
|
-
private collection;
|
|
117
|
-
constructor(db: ValtheraCompatible, collection: string);
|
|
118
|
-
/**
|
|
119
|
-
* Add data to a database.
|
|
120
|
-
*/
|
|
121
|
-
add<T = Data>(data: Arg, id_gen?: boolean): Promise<T>;
|
|
122
|
-
/**
|
|
123
|
-
* Find data in a database.
|
|
124
|
-
*/
|
|
125
|
-
find<T = Data>(search: Search, context?: VContext, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
|
|
126
|
-
/**
|
|
127
|
-
* Find one data entry in a database.
|
|
128
|
-
*/
|
|
129
|
-
findOne<T = Data>(search: Search, context?: VContext, findOpts?: FindOpts): Promise<T>;
|
|
130
|
-
/**
|
|
131
|
-
* Update data in a database.
|
|
132
|
-
*/
|
|
133
|
-
update(search: Search, updater: Updater, context?: VContext): Promise<boolean>;
|
|
134
|
-
/**
|
|
135
|
-
* Update one data entry in a database.
|
|
136
|
-
*/
|
|
137
|
-
updateOne(search: Search, updater: Updater, context?: VContext): Promise<boolean>;
|
|
138
|
-
/**
|
|
139
|
-
* Remove data from a database.
|
|
140
|
-
*/
|
|
141
|
-
remove(search: Search, context?: VContext): Promise<boolean>;
|
|
142
|
-
/**
|
|
143
|
-
* Remove one data entry from a database.
|
|
144
|
-
*/
|
|
145
|
-
removeOne(search: Search, context?: VContext): Promise<boolean>;
|
|
146
|
-
/**
|
|
147
|
-
* Asynchronously updates one entry in a database or adds a new one if it doesn't exist.
|
|
148
|
-
*/
|
|
149
|
-
updateOneOrAdd(search: Search, updater: Updater, add_arg?: Arg, context?: VContext, id_gen?: boolean): Promise<boolean>;
|
|
150
|
-
}
|
|
151
|
-
export interface ValtheraCompatible {
|
|
152
|
-
c(collection: string): CollectionManager;
|
|
153
|
-
getCollections(): Promise<string[]>;
|
|
154
|
-
checkCollection(collection: string): Promise<boolean>;
|
|
155
|
-
issetCollection(collection: string): Promise<boolean>;
|
|
156
|
-
add<T = Data>(collection: string, data: Arg, id_gen?: boolean): Promise<T>;
|
|
157
|
-
find<T = Data>(collection: string, search: Search, context?: VContext, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
|
|
158
|
-
findOne<T = Data>(collection: string, search: Search, context?: VContext, findOpts?: FindOpts): Promise<T | null>;
|
|
159
|
-
update(collection: string, search: Search, updater: Updater, context?: VContext): Promise<boolean>;
|
|
160
|
-
updateOne(collection: string, search: Search, updater: Updater, context?: VContext): Promise<boolean>;
|
|
161
|
-
remove(collection: string, search: Search, context?: VContext): Promise<boolean>;
|
|
162
|
-
removeOne(collection: string, search: Search, context?: VContext): Promise<boolean>;
|
|
163
|
-
removeCollection(collection: string): Promise<boolean>;
|
|
164
|
-
updateOneOrAdd(collection: string, search: Search, updater: Updater, add_arg?: Arg, context?: VContext, id_gen?: boolean): Promise<boolean>;
|
|
165
|
-
}
|
|
166
|
-
declare namespace RelationTypes {
|
|
167
|
-
type Path = [
|
|
168
|
-
string,
|
|
169
|
-
string
|
|
170
|
-
];
|
|
171
|
-
type FieldPath = string[];
|
|
172
|
-
interface DBS {
|
|
173
|
-
[key: string]: ValtheraCompatible;
|
|
174
|
-
}
|
|
175
|
-
interface Relation {
|
|
176
|
-
[key: string]: RelationConfig;
|
|
177
|
-
}
|
|
178
|
-
interface RelationConfig {
|
|
179
|
-
path: Path;
|
|
180
|
-
pk?: string;
|
|
181
|
-
fk?: string;
|
|
182
|
-
as?: string;
|
|
183
|
-
select?: string[];
|
|
184
|
-
findOpts?: DbFindOpts;
|
|
185
|
-
type?: "1" | "11" | "1n" | "nm";
|
|
186
|
-
relations?: Relation;
|
|
187
|
-
through?: {
|
|
188
|
-
table: string;
|
|
189
|
-
db?: string;
|
|
190
|
-
pk: string;
|
|
191
|
-
fk: string;
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
export type VQLQuery = {
|
|
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;
|
|
205
|
-
removeCollection: VQLCollectionOperation;
|
|
206
|
-
checkCollection: VQLCollectionOperation;
|
|
207
|
-
issetCollection: VQLCollectionOperation;
|
|
208
|
-
getCollections: {};
|
|
209
|
-
};
|
|
210
|
-
export type VQLQueryData = {
|
|
211
|
-
find: VQLFind;
|
|
212
|
-
} | {
|
|
213
|
-
findOne: VQLFindOne;
|
|
214
|
-
} | {
|
|
215
|
-
f: VQLFindOne;
|
|
216
|
-
} | {
|
|
217
|
-
add: VQLAdd;
|
|
218
|
-
} | {
|
|
219
|
-
update: VQLUpdate;
|
|
220
|
-
} | {
|
|
221
|
-
updateOne: VQLUpdateOne;
|
|
222
|
-
} | {
|
|
223
|
-
remove: VQLRemove;
|
|
224
|
-
} | {
|
|
225
|
-
removeOne: VQLRemoveOne;
|
|
226
|
-
} | {
|
|
227
|
-
updateOneOrAdd: VQLUpdateOneOrAdd;
|
|
228
|
-
} | {
|
|
229
|
-
removeCollection: VQLCollectionOperation;
|
|
230
|
-
} | {
|
|
231
|
-
checkCollection: VQLCollectionOperation;
|
|
232
|
-
} | {
|
|
233
|
-
issetCollection: VQLCollectionOperation;
|
|
234
|
-
} | {
|
|
235
|
-
getCollections: {};
|
|
236
|
-
};
|
|
237
|
-
export interface VQLRequest {
|
|
238
|
-
db: string;
|
|
239
|
-
d: VQLQueryData;
|
|
240
|
-
}
|
|
241
|
-
export interface VQLFind {
|
|
242
|
-
collection: string;
|
|
243
|
-
search?: Search;
|
|
244
|
-
limit?: number;
|
|
245
|
-
fields?: VQLFields;
|
|
246
|
-
select?: VQLFields;
|
|
247
|
-
relations?: VQLRelations;
|
|
248
|
-
options?: DbFindOpts;
|
|
249
|
-
searchOpts?: FindOpts;
|
|
250
|
-
}
|
|
251
|
-
export interface VQLFindOne {
|
|
252
|
-
collection: string;
|
|
253
|
-
search: Search;
|
|
254
|
-
fields?: VQLFields;
|
|
255
|
-
select?: VQLFields;
|
|
256
|
-
relations?: VQLRelations;
|
|
257
|
-
searchOpts?: FindOpts;
|
|
258
|
-
}
|
|
259
|
-
export interface VQLAdd {
|
|
260
|
-
collection: string;
|
|
261
|
-
data: Arg;
|
|
262
|
-
id_gen?: boolean;
|
|
263
|
-
}
|
|
264
|
-
export interface VQLUpdate {
|
|
265
|
-
collection: string;
|
|
266
|
-
search: Search;
|
|
267
|
-
updater: UpdaterArg;
|
|
268
|
-
}
|
|
269
|
-
export interface VQLUpdateOne {
|
|
270
|
-
collection: string;
|
|
271
|
-
search: Search;
|
|
272
|
-
updater: UpdaterArg;
|
|
273
|
-
}
|
|
274
|
-
export interface VQLRemove {
|
|
275
|
-
collection: string;
|
|
276
|
-
search: Search;
|
|
277
|
-
}
|
|
278
|
-
export interface VQLRemoveOne {
|
|
279
|
-
collection: string;
|
|
280
|
-
search: Search;
|
|
281
|
-
}
|
|
282
|
-
export interface VQLUpdateOneOrAdd {
|
|
283
|
-
collection: string;
|
|
284
|
-
search: Search;
|
|
285
|
-
updater: UpdaterArg;
|
|
286
|
-
add_arg?: Arg;
|
|
287
|
-
id_gen?: boolean;
|
|
288
|
-
}
|
|
289
|
-
export interface VQLCollectionOperation {
|
|
290
|
-
collection: string;
|
|
291
|
-
}
|
|
292
|
-
export type VQLFields = Record<string, boolean | number> | string[];
|
|
293
|
-
export type VQLRelations = Record<string, VQLFind | VQLFindOne>;
|
|
294
|
-
export interface RelationQuery {
|
|
295
|
-
r: {
|
|
296
|
-
path: RelationTypes.Path;
|
|
297
|
-
search: Search;
|
|
298
|
-
relations: RelationTypes.Relation;
|
|
299
|
-
many?: boolean;
|
|
300
|
-
options?: DbFindOpts;
|
|
301
|
-
select?: RelationTypes.FieldPath[];
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
export interface VQLRef {
|
|
305
|
-
ref?: string;
|
|
306
|
-
var?: {
|
|
307
|
-
[k: string]: any;
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
export type VQLRefRequired = VQLRef & Required<Pick<VQLRef, "ref">>;
|
|
311
|
-
export type DeepPartial<T> = {
|
|
312
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
313
|
-
};
|
|
314
|
-
export type VQL = (VQLRequest | RelationQuery) & VQLRef;
|
|
315
|
-
export type VQLR = VQL | (DeepPartial<VQL> & VQLRefRequired) | VQLRefRequired;
|
|
316
|
-
export interface VQLError {
|
|
317
|
-
err: true;
|
|
318
|
-
msg: string;
|
|
319
|
-
c: number;
|
|
320
|
-
why?: string;
|
|
321
|
-
}
|
|
322
|
-
export type VqlQueryRaw = VQLR | string | {
|
|
323
|
-
query: string;
|
|
324
|
-
} & VQLRef;
|
|
325
|
-
|
|
326
|
-
export {};
|