@wxn0brp/vql 0.3.11 → 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.
@@ -1,4 +1,4 @@
1
- import type { ValtheraCompatible } from "@wxn0brp/db";
1
+ import { ValtheraCompatible } from "@wxn0brp/db-core";
2
2
  type ResolverFn<TArgs extends any[] = any[], TReturn = any> = (...args: TArgs) => Promise<TReturn>;
3
3
  export interface ValtheraResolverMeta {
4
4
  type: "valthera" | "api" | "wrapper" | (string & {});
@@ -1,5 +1,5 @@
1
- import CollectionManager from "@wxn0brp/db/helpers/CollectionManager.js";
2
- import updateFindObject from "@wxn0brp/db/utils/updateFindObject.js";
1
+ import CollectionManager from "@wxn0brp/db-core/helpers/CollectionManager";
2
+ import updateFindObject from "@wxn0brp/db-core/utils/updateFindObject";
3
3
  export function createValtheraAdapter(resolver, extendedFind = false) {
4
4
  const safe = (fn) => {
5
5
  if (!fn)
@@ -4,6 +4,7 @@ type ContextFn = (req: FFRequest) => Promise<any> | any;
4
4
  interface FF_VQL_Options {
5
5
  path?: string;
6
6
  getUser?: ContextFn;
7
+ dev?: boolean;
7
8
  }
8
9
  export declare function FF_VQL(app: FalconFrame, processor: VQLProcessor, options?: FF_VQL_Options): void;
9
10
  export {};
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { Relation, ValtheraCompatible } from "@wxn0brp/db";
1
+ import { Relation, ValtheraCompatible } from "@wxn0brp/db-core";
2
2
  import { GateWarden } from "@wxn0brp/gate-warden";
3
3
  import { VQLConfig } from "./config.js";
4
4
  import { VQL, VQLError, VqlQueryRaw } from "./types/vql.js";
@@ -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, user: any): Promise<T | VQLError>;
12
+ execute<T = any>(queryRaw: VqlQueryRaw<T>, user: any): Promise<T | VQLError>;
13
13
  }
package/dist/processor.js CHANGED
@@ -1,10 +1,10 @@
1
- import { Relation } from "@wxn0brp/db";
1
+ import { Relation } from "@wxn0brp/db-core";
2
2
  import { VQLConfig } from "./config.js";
3
3
  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 { executeSheet } from "./sheet/index.js";
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 = executeSheet(queryRaw, this.preDefinedSheets);
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/schema.json CHANGED
@@ -1 +1 @@
1
- {"anyOf":[{"$ref":"#/definitions/VQLRefRequired"},{"allOf":[{"$ref":"#/definitions/VQLRequest"},{"$ref":"#/definitions/VQLRef"}]},{"allOf":[{"$ref":"#/definitions/RelationQuery"},{"$ref":"#/definitions/VQLRef"}]},{"allOf":[{"$ref":"#/definitions/DeepPartial<VQLRequest&VQLRef>"},{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]},{"allOf":[{"$ref":"#/definitions/DeepPartial<RelationQuery&VQLRef>"},{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]}],"definitions":{"VQLRefRequired":{"allOf":[{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]},"VQLRef":{"type":"object","properties":{"ref":{"type":"string"},"var":{"type":"object","additionalProperties":{}}}},"Required<Pick<VQLRef,\"ref\">>":{"type":"object","properties":{"ref":{"type":"string"}},"required":["ref"]},"VQLRequest":{"type":"object","properties":{"db":{"type":"string"},"d":{"$ref":"#/definitions/VQLQueryData"}},"required":["d","db"]},"VQLQueryData":{"anyOf":[{"type":"object","properties":{"find":{"$ref":"#/definitions/VQLFind"}},"required":["find"]},{"type":"object","properties":{"findOne":{"$ref":"#/definitions/VQLFindOne"}},"required":["findOne"]},{"type":"object","properties":{"f":{"$ref":"#/definitions/VQLFindOne"}},"required":["f"]},{"type":"object","properties":{"add":{"$ref":"#/definitions/VQLAdd"}},"required":["add"]},{"type":"object","properties":{"update":{"$ref":"#/definitions/VQLUpdate"}},"required":["update"]},{"type":"object","properties":{"updateOne":{"$ref":"#/definitions/VQLUpdateOne"}},"required":["updateOne"]},{"type":"object","properties":{"remove":{"$ref":"#/definitions/VQLRemove"}},"required":["remove"]},{"type":"object","properties":{"removeOne":{"$ref":"#/definitions/VQLRemoveOne"}},"required":["removeOne"]},{"type":"object","properties":{"updateOneOrAdd":{"$ref":"#/definitions/VQLUpdateOneOrAdd"}},"required":["updateOneOrAdd"]},{"type":"object","properties":{"removeCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["removeCollection"]},{"type":"object","properties":{"checkCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["checkCollection"]},{"type":"object","properties":{"issetCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["issetCollection"]},{"type":"object","properties":{"getCollections":{"type":"object","properties":{}}},"required":["getCollections"]}]},"VQLFind":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"limit":{"type":"number"},"fields":{"$ref":"#/definitions/VQLFields"},"select":{"$ref":"#/definitions/VQLFields"},"relations":{"$ref":"#/definitions/VQLRelations"},"options":{"$ref":"#/definitions/DbFindOpts"},"searchOpts":{"$ref":"#/definitions/FindOpts"}},"required":["collection"]},"Search<any>":{"anyOf":[{"$ref":"#/definitions/SearchOptions","description":"SearchOptions can be either a function or an object with predefined operators."},{"type":"object"}]},"SearchOptions":{"description":"SearchOptions can be either a function or an object with predefined operators.","allOf":[{"description":"Logical Operators","type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/SearchOptions"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/SearchOptions"}},"$not":{"$ref":"#/definitions/SearchOptions","description":"Negates a single condition.\nCan include any other operator as its value."}}},{"description":"Comparison Operators","type":"object","properties":{"$gt":{"$ref":"#/definitions/Record<string,number>"},"$lt":{"$ref":"#/definitions/Record<string,number>"},"$gte":{"$ref":"#/definitions/Record<string,number>"},"$lte":{"$ref":"#/definitions/Record<string,number>"},"$in":{"$ref":"#/definitions/Record<string,any[]>"},"$nin":{"$ref":"#/definitions/Record<string,any[]>"},"$between":{"$ref":"#/definitions/Record<string,[number,number]>"}}},{"description":"Type and Existence Operators","type":"object","properties":{"$exists":{"$ref":"#/definitions/Record<string,boolean>"},"$type":{"$ref":"#/definitions/Record<string,string>"}}},{"description":"Array Operators","type":"object","properties":{"$arrinc":{"$ref":"#/definitions/Record<string,any[]>"},"$arrincall":{"$ref":"#/definitions/Record<string,any[]>"},"$size":{"$ref":"#/definitions/Record<string,number>"}}},{"description":"String Operators","type":"object","properties":{"$regex":{"$ref":"#/definitions/Record<string,RegExp>"},"$startsWith":{"$ref":"#/definitions/Record<string,string>"},"$endsWith":{"$ref":"#/definitions/Record<string,string>"}}},{"description":"Other Operators","type":"object","properties":{"$subset":{"$ref":"#/definitions/Record<string,any>"}}},{"$ref":"#/definitions/Arg"}]},"Record<string,number>":{"type":"object"},"Record<string,any[]>":{"type":"object"},"Record<string,[number,number]>":{"type":"object"},"Record<string,boolean>":{"type":"object"},"Record<string,string>":{"type":"object"},"Record<string,RegExp>":{"type":"object"},"Record<string,any>":{"type":"object"},"Arg":{"type":"object","additionalProperties":{},"properties":{"_id":{"type":"string"}}},"VQLFields":{"anyOf":[{"type":"array","items":{"type":"string"}},{"$ref":"#/definitions/Record<string,number|boolean>"}]},"Record<string,number|boolean>":{"type":"object"},"VQLRelations":{"type":"object"},"DbFindOpts":{"type":"object","properties":{"reverse":{"type":"boolean"},"max":{"type":"number"}}},"FindOpts":{"type":"object","properties":{"select":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"type":"string"}},"transform":{"$ref":"#/definitions/Function"}}},"Function":{"type":"object","properties":{"prototype":{},"length":{"type":"number"},"arguments":{},"caller":{"$ref":"#/definitions/Function"},"name":{"type":"string"}},"required":["arguments","caller","length","name","prototype"]},"VQLFindOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"fields":{"$ref":"#/definitions/VQLFields"},"select":{"$ref":"#/definitions/VQLFields"},"relations":{"$ref":"#/definitions/VQLRelations"},"searchOpts":{"$ref":"#/definitions/FindOpts"}},"required":["collection","search"]},"VQLAdd":{"type":"object","properties":{"collection":{"type":"string"},"data":{"$ref":"#/definitions/Arg"},"id_gen":{"type":"boolean"}},"required":["collection","data"]},"VQLUpdate":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"}},"required":["collection","search","updater"]},"UpdaterArg":{"allOf":[{"description":"Arrays","type":"object","properties":{"$push":{},"$pushset":{"description":"Pushes items into an array and removes duplicates"},"$pull":{},"$pullall":{}}},{"description":"Objects","type":"object","properties":{"$merge":{}}},{"description":"Values","type":"object","properties":{"$set":{},"$inc":{},"$dec":{},"$unset":{},"$rename":{}}},{"type":"object","additionalProperties":{}}]},"VQLUpdateOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"}},"required":["collection","search","updater"]},"VQLRemove":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"}},"required":["collection","search"]},"VQLRemoveOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"}},"required":["collection","search"]},"VQLUpdateOneOrAdd":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"},"add_arg":{"$ref":"#/definitions/Arg"},"id_gen":{"type":"boolean"}},"required":["collection","search","updater"]},"VQLCollectionOperation":{"type":"object","properties":{"collection":{"type":"string"}},"required":["collection"]},"RelationQuery":{"type":"object","properties":{"r":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":2,"maxItems":2},"search":{"$ref":"#/definitions/Search<any>"},"relations":{"$ref":"#/definitions/RelationTypes.Relation"},"many":{"type":"boolean"},"options":{"$ref":"#/definitions/DbFindOpts"},"select":{"type":"array","items":{"type":"array","items":{"type":"string"}}}},"required":["path","relations","search"]}},"required":["r"]},"RelationTypes.Relation":{"type":"object","additionalProperties":{"$ref":"#/definitions/RelationTypes.RelationConfig"}},"RelationTypes.RelationConfig":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":2,"maxItems":2},"pk":{"type":"string"},"fk":{"type":"string"},"as":{"type":"string"},"select":{"type":"array","items":{"type":"string"}},"findOpts":{"$ref":"#/definitions/DbFindOpts"},"type":{"enum":["1","11","1n","nm"],"type":"string"},"relations":{"$ref":"#/definitions/RelationTypes.Relation"},"through":{"type":"object","properties":{"table":{"type":"string"},"db":{"type":"string"},"pk":{"type":"string"},"fk":{"type":"string"}},"required":["fk","pk","table"]}},"required":["path"]},"DeepPartial<VQLRequest&VQLRef>":{"type":"object","properties":{"db":{"type":"string"},"d":{"$ref":"#/definitions/DeepPartial<VQLQueryData>"},"ref":{"type":"string"},"var":{"$ref":"#/definitions/DeepPartial<{[k:string]:any;}>"}}},"DeepPartial<VQLQueryData>":{"anyOf":[{"$ref":"#/definitions/DeepPartial<{find:VQLFind;}>"},{"$ref":"#/definitions/DeepPartial<{findOne:VQLFindOne;}>"},{"$ref":"#/definitions/DeepPartial<{f:VQLFindOne;}>"},{"$ref":"#/definitions/DeepPartial<{add:VQLAdd;}>"},{"$ref":"#/definitions/DeepPartial<{update:VQLUpdate;}>"},{"$ref":"#/definitions/DeepPartial<{updateOne:VQLUpdateOne;}>"},{"$ref":"#/definitions/DeepPartial<{remove:VQLRemove;}>"},{"$ref":"#/definitions/DeepPartial<{removeOne:VQLRemoveOne;}>"},{"$ref":"#/definitions/DeepPartial<{updateOneOrAdd:VQLUpdateOneOrAdd;}>"},{"$ref":"#/definitions/DeepPartial<{removeCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{checkCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{issetCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{getCollections:{};}>"}]},"DeepPartial<{find:VQLFind;}>":{"type":"object","properties":{"find":{"$ref":"#/definitions/DeepPartial<VQLFind>"}}},"DeepPartial<VQLFind>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"limit":{"type":"number"},"fields":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"select":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"relations":{"$ref":"#/definitions/DeepPartial<VQLRelations>"},"options":{"$ref":"#/definitions/DeepPartial<DbFindOpts>"},"searchOpts":{"$ref":"#/definitions/DeepPartial<FindOpts>"}}},"DeepPartial<Search<any>>":{"anyOf":[{"$ref":"#/definitions/DeepPartial<SearchOptions>"},{"$ref":"#/definitions/DeepPartial<SearchFunc<any>>"}]},"DeepPartial<SearchOptions>":{"type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$not":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1","description":"Negates a single condition.\nCan include any other operator as its value."},"$gt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$gte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$in":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$nin":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$between":{"$ref":"#/definitions/DeepPartial<Record<string,[number,number]>>"},"$exists":{"$ref":"#/definitions/DeepPartial<Record<string,boolean>>"},"$type":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$arrinc":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$arrincall":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$size":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$regex":{"$ref":"#/definitions/DeepPartial<Record<string,RegExp>>"},"$startsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$endsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$subset":{"$ref":"#/definitions/DeepPartial<Record<string,any>>"},"_id":{"type":"string"}}},"DeepPartial<SearchOptions>_1":{"type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$not":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1","description":"Negates a single condition.\nCan include any other operator as its value."},"$gt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$gte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$in":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$nin":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$between":{"$ref":"#/definitions/DeepPartial<Record<string,[number,number]>>"},"$exists":{"$ref":"#/definitions/DeepPartial<Record<string,boolean>>"},"$type":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$arrinc":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$arrincall":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$size":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$regex":{"$ref":"#/definitions/DeepPartial<Record<string,RegExp>>"},"$startsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$endsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$subset":{"$ref":"#/definitions/DeepPartial<Record<string,any>>"},"_id":{"type":"string"}}},"DeepPartial<Record<string,number>>":{"type":"object"},"DeepPartial<Record<string,any[]>>":{"type":"object"},"DeepPartial<Record<string,[number,number]>>":{"type":"object"},"DeepPartial<Record<string,boolean>>":{"type":"object"},"DeepPartial<Record<string,string>>":{"type":"object"},"DeepPartial<Record<string,RegExp>>":{"type":"object"},"DeepPartial<Record<string,any>>":{"type":"object"},"DeepPartial<SearchFunc<any>>":{"type":"object"},"DeepPartial<VQLFields>":{"anyOf":[{"type":"array","items":{"type":"string"}},{"$ref":"#/definitions/DeepPartial<Record<string,number|boolean>>"}]},"DeepPartial<Record<string,number|boolean>>":{"type":"object"},"DeepPartial<VQLRelations>":{"type":"object"},"DeepPartial<DbFindOpts>":{"type":"object","properties":{"reverse":{"type":"boolean"},"max":{"type":"number"}}},"DeepPartial<FindOpts>":{"type":"object","properties":{"select":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"type":"string"}},"transform":{"$ref":"#/definitions/DeepPartial<Function>"}}},"DeepPartial<Function>":{"type":"object","properties":{"apply":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,argArray?:any)=>any>"},"call":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>"},"bind":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>_1"},"toString":{"$ref":"#/definitions/DeepPartial<()=>string>"},"prototype":{},"length":{"type":"number"},"arguments":{},"caller":{"$ref":"#/definitions/DeepPartial<Function>"},"name":{"type":"string"},"__@hasInstance@75":{"$ref":"#/definitions/DeepPartial<(value:any)=>boolean>"}}},"DeepPartial<(this:Function,thisArg:any,argArray?:any)=>any>":{"type":"object"},"DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>":{"type":"object"},"DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>_1":{"type":"object"},"DeepPartial<()=>string>":{"type":"object"},"DeepPartial<(value:any)=>boolean>":{"type":"object"},"DeepPartial<{findOne:VQLFindOne;}>":{"type":"object","properties":{"findOne":{"$ref":"#/definitions/DeepPartial<VQLFindOne>"}}},"DeepPartial<VQLFindOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"fields":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"select":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"relations":{"$ref":"#/definitions/DeepPartial<VQLRelations>"},"searchOpts":{"$ref":"#/definitions/DeepPartial<FindOpts>"}}},"DeepPartial<{f:VQLFindOne;}>":{"type":"object","properties":{"f":{"$ref":"#/definitions/DeepPartial<VQLFindOne>"}}},"DeepPartial<{add:VQLAdd;}>":{"type":"object","properties":{"add":{"$ref":"#/definitions/DeepPartial<VQLAdd>"}}},"DeepPartial<VQLAdd>":{"type":"object","properties":{"collection":{"type":"string"},"data":{"$ref":"#/definitions/DeepPartial<Arg>"},"id_gen":{"type":"boolean"}}},"DeepPartial<Arg>":{"type":"object","properties":{"_id":{"type":"string"}}},"DeepPartial<{update:VQLUpdate;}>":{"type":"object","properties":{"update":{"$ref":"#/definitions/DeepPartial<VQLUpdate>"}}},"DeepPartial<VQLUpdate>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"}}},"DeepPartial<UpdaterArg>":{"type":"object","properties":{"$push":{},"$pushset":{"description":"Pushes items into an array and removes duplicates"},"$pull":{},"$pullall":{},"$merge":{},"$set":{},"$inc":{},"$dec":{},"$unset":{},"$rename":{}}},"DeepPartial<{updateOne:VQLUpdateOne;}>":{"type":"object","properties":{"updateOne":{"$ref":"#/definitions/DeepPartial<VQLUpdateOne>"}}},"DeepPartial<VQLUpdateOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"}}},"DeepPartial<{remove:VQLRemove;}>":{"type":"object","properties":{"remove":{"$ref":"#/definitions/DeepPartial<VQLRemove>"}}},"DeepPartial<VQLRemove>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"}}},"DeepPartial<{removeOne:VQLRemoveOne;}>":{"type":"object","properties":{"removeOne":{"$ref":"#/definitions/DeepPartial<VQLRemoveOne>"}}},"DeepPartial<VQLRemoveOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"}}},"DeepPartial<{updateOneOrAdd:VQLUpdateOneOrAdd;}>":{"type":"object","properties":{"updateOneOrAdd":{"$ref":"#/definitions/DeepPartial<VQLUpdateOneOrAdd>"}}},"DeepPartial<VQLUpdateOneOrAdd>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"},"add_arg":{"$ref":"#/definitions/DeepPartial<Arg>"},"id_gen":{"type":"boolean"}}},"DeepPartial<{removeCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"removeCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<VQLCollectionOperation>":{"type":"object","properties":{"collection":{"type":"string"}}},"DeepPartial<{checkCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"checkCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<{issetCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"issetCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<{getCollections:{};}>":{"type":"object","properties":{"getCollections":{"$ref":"#/definitions/DeepPartial<{}>"}}},"DeepPartial<{}>":{"type":"object"},"DeepPartial<{[k:string]:any;}>":{"type":"object"},"DeepPartial<RelationQuery&VQLRef>":{"type":"object","properties":{"r":{"$ref":"#/definitions/DeepPartial<{path:RelationTypes.Path;search:Search<any>;relations:RelationTypes.Relation;many?:boolean;options?:DbFindOpts;select?:RelationTypes.FieldPath[];}>"},"ref":{"type":"string"},"var":{"$ref":"#/definitions/DeepPartial<{[k:string]:any;}>"}}},"DeepPartial<{path:RelationTypes.Path;search:Search<any>;relations:RelationTypes.Relation;many?:boolean;options?:DbFindOpts;select?:RelationTypes.FieldPath[];}>":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":0,"maxItems":2},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"relations":{"$ref":"#/definitions/DeepPartial<RelationTypes.Relation>"},"many":{"type":"boolean"},"options":{"$ref":"#/definitions/DeepPartial<DbFindOpts>"},"select":{"type":"array","items":{"type":"array","items":{"type":"string"}}}}},"DeepPartial<RelationTypes.Relation>":{"type":"object"}},"$schema":"http://json-schema.org/draft-07/schema#"}
1
+ {"anyOf":[{"$ref":"#/definitions/VQLRefRequired"},{"allOf":[{"$ref":"#/definitions/VQLRequest"},{"$ref":"#/definitions/VQLRef"}]},{"allOf":[{"$ref":"#/definitions/RelationQuery"},{"$ref":"#/definitions/VQLRef"}]},{"allOf":[{"$ref":"#/definitions/DeepPartial<VQLRequest&VQLRef>"},{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]},{"allOf":[{"$ref":"#/definitions/DeepPartial<RelationQuery&VQLRef>"},{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]}],"definitions":{"VQLRefRequired":{"allOf":[{"$ref":"#/definitions/VQLRef"},{"$ref":"#/definitions/Required<Pick<VQLRef,\"ref\">>"}]},"VQLRef":{"type":"object","properties":{"ref":{"type":"string"},"var":{"type":"object","additionalProperties":{}}}},"Required<Pick<VQLRef,\"ref\">>":{"type":"object","properties":{"ref":{"type":"string"}},"required":["ref"]},"VQLRequest":{"type":"object","properties":{"db":{"type":"string"},"d":{"$ref":"#/definitions/VQLQueryData"}},"required":["d","db"]},"VQLQueryData":{"anyOf":[{"type":"object","properties":{"find":{"$ref":"#/definitions/VQLFind"}},"required":["find"]},{"type":"object","properties":{"findOne":{"$ref":"#/definitions/VQLFindOne"}},"required":["findOne"]},{"type":"object","properties":{"f":{"$ref":"#/definitions/VQLFindOne"}},"required":["f"]},{"type":"object","properties":{"add":{"$ref":"#/definitions/VQLAdd"}},"required":["add"]},{"type":"object","properties":{"update":{"$ref":"#/definitions/VQLUpdate"}},"required":["update"]},{"type":"object","properties":{"updateOne":{"$ref":"#/definitions/VQLUpdateOne"}},"required":["updateOne"]},{"type":"object","properties":{"remove":{"$ref":"#/definitions/VQLRemove"}},"required":["remove"]},{"type":"object","properties":{"removeOne":{"$ref":"#/definitions/VQLRemoveOne"}},"required":["removeOne"]},{"type":"object","properties":{"updateOneOrAdd":{"$ref":"#/definitions/VQLUpdateOneOrAdd"}},"required":["updateOneOrAdd"]},{"type":"object","properties":{"removeCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["removeCollection"]},{"type":"object","properties":{"checkCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["checkCollection"]},{"type":"object","properties":{"issetCollection":{"$ref":"#/definitions/VQLCollectionOperation"}},"required":["issetCollection"]},{"type":"object","properties":{"getCollections":{"type":"object","properties":{}}},"required":["getCollections"]}]},"VQLFind":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"limit":{"type":"number"},"fields":{"$ref":"#/definitions/VQLFields"},"select":{"$ref":"#/definitions/VQLFields"},"relations":{"$ref":"#/definitions/VQLRelations"},"options":{"$ref":"#/definitions/DbFindOpts"},"searchOpts":{"$ref":"#/definitions/FindOpts"}},"required":["collection"]},"Search<any>":{"anyOf":[{"$ref":"#/definitions/SearchOptions","description":"SearchOptions can be either a function or an object with predefined operators."},{"type":"object"}]},"SearchOptions":{"description":"SearchOptions can be either a function or an object with predefined operators.","allOf":[{"description":"Logical Operators","type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/SearchOptions"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/SearchOptions"}},"$not":{"$ref":"#/definitions/SearchOptions","description":"Negates a single condition.\nCan include any other operator as its value."}}},{"description":"Comparison Operators","type":"object","properties":{"$gt":{"$ref":"#/definitions/Record<string,number>"},"$lt":{"$ref":"#/definitions/Record<string,number>"},"$gte":{"$ref":"#/definitions/Record<string,number>"},"$lte":{"$ref":"#/definitions/Record<string,number>"},"$in":{"$ref":"#/definitions/Record<string,any[]>"},"$nin":{"$ref":"#/definitions/Record<string,any[]>"},"$between":{"$ref":"#/definitions/Record<string,[number,number]>"}}},{"description":"Type and Existence Operators","type":"object","properties":{"$exists":{"$ref":"#/definitions/Record<string,boolean>"},"$type":{"$ref":"#/definitions/Record<string,string>"}}},{"description":"Array Operators","type":"object","properties":{"$arrinc":{"$ref":"#/definitions/Record<string,any[]>"},"$arrincall":{"$ref":"#/definitions/Record<string,any[]>"},"$size":{"$ref":"#/definitions/Record<string,number>"}}},{"description":"String Operators","type":"object","properties":{"$regex":{"$ref":"#/definitions/Record<string,RegExp>"},"$startsWith":{"$ref":"#/definitions/Record<string,string>"},"$endsWith":{"$ref":"#/definitions/Record<string,string>"}}},{"description":"Other Operators","type":"object","properties":{"$subset":{"$ref":"#/definitions/Record<string,any>"}}},{"$ref":"#/definitions/Arg"}]},"Record<string,number>":{"type":"object"},"Record<string,any[]>":{"type":"object"},"Record<string,[number,number]>":{"type":"object"},"Record<string,boolean>":{"type":"object"},"Record<string,string>":{"type":"object"},"Record<string,RegExp>":{"type":"object"},"Record<string,any>":{"type":"object"},"Arg":{"type":"object","additionalProperties":{},"properties":{"_id":{"type":"string"}}},"VQLFields":{"anyOf":[{"type":"array","items":{"type":"string"}},{"$ref":"#/definitions/Record<string,number|boolean>"}]},"Record<string,number|boolean>":{"type":"object"},"VQLRelations":{"type":"object"},"DbFindOpts":{"type":"object","properties":{"reverse":{"type":"boolean"},"max":{"type":"number"},"offset":{"type":"number"},"sortBy":{"type":"string"},"sortAsc":{"type":"boolean"}}},"FindOpts":{"type":"object","properties":{"select":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"type":"string"}},"transform":{"$ref":"#/definitions/Function"}}},"Function":{"type":"object","properties":{"prototype":{},"length":{"type":"number"},"arguments":{},"caller":{"$ref":"#/definitions/Function"},"name":{"type":"string"}},"required":["arguments","caller","length","name","prototype"]},"VQLFindOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"fields":{"$ref":"#/definitions/VQLFields"},"select":{"$ref":"#/definitions/VQLFields"},"relations":{"$ref":"#/definitions/VQLRelations"},"searchOpts":{"$ref":"#/definitions/FindOpts"}},"required":["collection","search"]},"VQLAdd":{"type":"object","properties":{"collection":{"type":"string"},"data":{"$ref":"#/definitions/Arg"},"id_gen":{"type":"boolean"}},"required":["collection","data"]},"VQLUpdate":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"}},"required":["collection","search","updater"]},"UpdaterArg":{"allOf":[{"description":"Arrays","type":"object","properties":{"$push":{},"$pushset":{"description":"Pushes items into an array and removes duplicates"},"$pull":{},"$pullall":{}}},{"description":"Objects","type":"object","properties":{"$merge":{}}},{"description":"Values","type":"object","properties":{"$set":{},"$inc":{},"$dec":{},"$unset":{},"$rename":{}}},{"type":"object","additionalProperties":{}}]},"VQLUpdateOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"}},"required":["collection","search","updater"]},"VQLRemove":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"}},"required":["collection","search"]},"VQLRemoveOne":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"}},"required":["collection","search"]},"VQLUpdateOneOrAdd":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/Search<any>"},"updater":{"$ref":"#/definitions/UpdaterArg"},"add_arg":{"$ref":"#/definitions/Arg"},"id_gen":{"type":"boolean"}},"required":["collection","search","updater"]},"VQLCollectionOperation":{"type":"object","properties":{"collection":{"type":"string"}},"required":["collection"]},"RelationQuery":{"type":"object","properties":{"r":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":2,"maxItems":2},"search":{"$ref":"#/definitions/Search<any>"},"relations":{"$ref":"#/definitions/RelationTypes.Relation"},"many":{"type":"boolean"},"options":{"$ref":"#/definitions/DbFindOpts"},"select":{"type":"array","items":{"type":"array","items":{"type":"string"}}}},"required":["path","relations","search"]}},"required":["r"]},"RelationTypes.Relation":{"type":"object","additionalProperties":{"$ref":"#/definitions/RelationTypes.RelationConfig"}},"RelationTypes.RelationConfig":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":2,"maxItems":2},"pk":{"type":"string"},"fk":{"type":"string"},"as":{"type":"string"},"select":{"type":"array","items":{"type":"string"}},"findOpts":{"$ref":"#/definitions/DbFindOpts"},"type":{"enum":["1","11","1n","nm"],"type":"string"},"relations":{"$ref":"#/definitions/RelationTypes.Relation"},"through":{"type":"object","properties":{"table":{"type":"string"},"db":{"type":"string"},"pk":{"type":"string"},"fk":{"type":"string"}},"required":["fk","pk","table"]}},"required":["path"]},"DeepPartial<VQLRequest&VQLRef>":{"type":"object","properties":{"db":{"type":"string"},"d":{"$ref":"#/definitions/DeepPartial<VQLQueryData>"},"ref":{"type":"string"},"var":{"$ref":"#/definitions/DeepPartial<{[k:string]:any;}>"}}},"DeepPartial<VQLQueryData>":{"anyOf":[{"$ref":"#/definitions/DeepPartial<{find:VQLFind;}>"},{"$ref":"#/definitions/DeepPartial<{findOne:VQLFindOne;}>"},{"$ref":"#/definitions/DeepPartial<{f:VQLFindOne;}>"},{"$ref":"#/definitions/DeepPartial<{add:VQLAdd;}>"},{"$ref":"#/definitions/DeepPartial<{update:VQLUpdate;}>"},{"$ref":"#/definitions/DeepPartial<{updateOne:VQLUpdateOne;}>"},{"$ref":"#/definitions/DeepPartial<{remove:VQLRemove;}>"},{"$ref":"#/definitions/DeepPartial<{removeOne:VQLRemoveOne;}>"},{"$ref":"#/definitions/DeepPartial<{updateOneOrAdd:VQLUpdateOneOrAdd;}>"},{"$ref":"#/definitions/DeepPartial<{removeCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{checkCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{issetCollection:VQLCollectionOperation;}>"},{"$ref":"#/definitions/DeepPartial<{getCollections:{};}>"}]},"DeepPartial<{find:VQLFind;}>":{"type":"object","properties":{"find":{"$ref":"#/definitions/DeepPartial<VQLFind>"}}},"DeepPartial<VQLFind>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"limit":{"type":"number"},"fields":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"select":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"relations":{"$ref":"#/definitions/DeepPartial<VQLRelations>"},"options":{"$ref":"#/definitions/DeepPartial<DbFindOpts>"},"searchOpts":{"$ref":"#/definitions/DeepPartial<FindOpts>"}}},"DeepPartial<Search<any>>":{"anyOf":[{"$ref":"#/definitions/DeepPartial<SearchOptions>"},{"$ref":"#/definitions/DeepPartial<SearchFunc<any>>"}]},"DeepPartial<SearchOptions>":{"type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$not":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1","description":"Negates a single condition.\nCan include any other operator as its value."},"$gt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$gte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$in":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$nin":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$between":{"$ref":"#/definitions/DeepPartial<Record<string,[number,number]>>"},"$exists":{"$ref":"#/definitions/DeepPartial<Record<string,boolean>>"},"$type":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$arrinc":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$arrincall":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$size":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$regex":{"$ref":"#/definitions/DeepPartial<Record<string,RegExp>>"},"$startsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$endsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$subset":{"$ref":"#/definitions/DeepPartial<Record<string,any>>"},"_id":{"type":"string"}}},"DeepPartial<SearchOptions>_1":{"type":"object","properties":{"$and":{"description":"Recursively applies multiple conditions, all of which must evaluate to true.\nCan include other operators such as $gt, $exists, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$or":{"description":"Recursively applies multiple conditions, at least one of which must evaluate to true.\nCan include other operators such as $lt, $type, or nested $and/$or conditions.","type":"array","items":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1"}},"$not":{"$ref":"#/definitions/DeepPartial<SearchOptions>_1","description":"Negates a single condition.\nCan include any other operator as its value."},"$gt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lt":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$gte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$lte":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$in":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$nin":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$between":{"$ref":"#/definitions/DeepPartial<Record<string,[number,number]>>"},"$exists":{"$ref":"#/definitions/DeepPartial<Record<string,boolean>>"},"$type":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$arrinc":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$arrincall":{"$ref":"#/definitions/DeepPartial<Record<string,any[]>>"},"$size":{"$ref":"#/definitions/DeepPartial<Record<string,number>>"},"$regex":{"$ref":"#/definitions/DeepPartial<Record<string,RegExp>>"},"$startsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$endsWith":{"$ref":"#/definitions/DeepPartial<Record<string,string>>"},"$subset":{"$ref":"#/definitions/DeepPartial<Record<string,any>>"},"_id":{"type":"string"}}},"DeepPartial<Record<string,number>>":{"type":"object"},"DeepPartial<Record<string,any[]>>":{"type":"object"},"DeepPartial<Record<string,[number,number]>>":{"type":"object"},"DeepPartial<Record<string,boolean>>":{"type":"object"},"DeepPartial<Record<string,string>>":{"type":"object"},"DeepPartial<Record<string,RegExp>>":{"type":"object"},"DeepPartial<Record<string,any>>":{"type":"object"},"DeepPartial<SearchFunc<any>>":{"type":"object"},"DeepPartial<VQLFields>":{"anyOf":[{"type":"array","items":{"type":"string"}},{"$ref":"#/definitions/DeepPartial<Record<string,number|boolean>>"}]},"DeepPartial<Record<string,number|boolean>>":{"type":"object"},"DeepPartial<VQLRelations>":{"type":"object"},"DeepPartial<DbFindOpts>":{"type":"object","properties":{"reverse":{"type":"boolean"},"max":{"type":"number"},"offset":{"type":"number"},"sortBy":{"type":"string"},"sortAsc":{"type":"boolean"}}},"DeepPartial<FindOpts>":{"type":"object","properties":{"select":{"type":"array","items":{"type":"string"}},"exclude":{"type":"array","items":{"type":"string"}},"transform":{"$ref":"#/definitions/DeepPartial<Function>"}}},"DeepPartial<Function>":{"type":"object","properties":{"apply":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,argArray?:any)=>any>"},"call":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>"},"bind":{"$ref":"#/definitions/DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>_1"},"toString":{"$ref":"#/definitions/DeepPartial<()=>string>"},"prototype":{},"length":{"type":"number"},"arguments":{},"caller":{"$ref":"#/definitions/DeepPartial<Function>"},"name":{"type":"string"},"__@hasInstance@73":{"$ref":"#/definitions/DeepPartial<(value:any)=>boolean>"}}},"DeepPartial<(this:Function,thisArg:any,argArray?:any)=>any>":{"type":"object"},"DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>":{"type":"object"},"DeepPartial<(this:Function,thisArg:any,...argArray:any[])=>any>_1":{"type":"object"},"DeepPartial<()=>string>":{"type":"object"},"DeepPartial<(value:any)=>boolean>":{"type":"object"},"DeepPartial<{findOne:VQLFindOne;}>":{"type":"object","properties":{"findOne":{"$ref":"#/definitions/DeepPartial<VQLFindOne>"}}},"DeepPartial<VQLFindOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"fields":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"select":{"$ref":"#/definitions/DeepPartial<VQLFields>"},"relations":{"$ref":"#/definitions/DeepPartial<VQLRelations>"},"searchOpts":{"$ref":"#/definitions/DeepPartial<FindOpts>"}}},"DeepPartial<{f:VQLFindOne;}>":{"type":"object","properties":{"f":{"$ref":"#/definitions/DeepPartial<VQLFindOne>"}}},"DeepPartial<{add:VQLAdd;}>":{"type":"object","properties":{"add":{"$ref":"#/definitions/DeepPartial<VQLAdd>"}}},"DeepPartial<VQLAdd>":{"type":"object","properties":{"collection":{"type":"string"},"data":{"$ref":"#/definitions/DeepPartial<Arg>"},"id_gen":{"type":"boolean"}}},"DeepPartial<Arg>":{"type":"object","properties":{"_id":{"type":"string"}}},"DeepPartial<{update:VQLUpdate;}>":{"type":"object","properties":{"update":{"$ref":"#/definitions/DeepPartial<VQLUpdate>"}}},"DeepPartial<VQLUpdate>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"}}},"DeepPartial<UpdaterArg>":{"type":"object","properties":{"$push":{},"$pushset":{"description":"Pushes items into an array and removes duplicates"},"$pull":{},"$pullall":{},"$merge":{},"$set":{},"$inc":{},"$dec":{},"$unset":{},"$rename":{}}},"DeepPartial<{updateOne:VQLUpdateOne;}>":{"type":"object","properties":{"updateOne":{"$ref":"#/definitions/DeepPartial<VQLUpdateOne>"}}},"DeepPartial<VQLUpdateOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"}}},"DeepPartial<{remove:VQLRemove;}>":{"type":"object","properties":{"remove":{"$ref":"#/definitions/DeepPartial<VQLRemove>"}}},"DeepPartial<VQLRemove>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"}}},"DeepPartial<{removeOne:VQLRemoveOne;}>":{"type":"object","properties":{"removeOne":{"$ref":"#/definitions/DeepPartial<VQLRemoveOne>"}}},"DeepPartial<VQLRemoveOne>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"}}},"DeepPartial<{updateOneOrAdd:VQLUpdateOneOrAdd;}>":{"type":"object","properties":{"updateOneOrAdd":{"$ref":"#/definitions/DeepPartial<VQLUpdateOneOrAdd>"}}},"DeepPartial<VQLUpdateOneOrAdd>":{"type":"object","properties":{"collection":{"type":"string"},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"updater":{"$ref":"#/definitions/DeepPartial<UpdaterArg>"},"add_arg":{"$ref":"#/definitions/DeepPartial<Arg>"},"id_gen":{"type":"boolean"}}},"DeepPartial<{removeCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"removeCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<VQLCollectionOperation>":{"type":"object","properties":{"collection":{"type":"string"}}},"DeepPartial<{checkCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"checkCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<{issetCollection:VQLCollectionOperation;}>":{"type":"object","properties":{"issetCollection":{"$ref":"#/definitions/DeepPartial<VQLCollectionOperation>"}}},"DeepPartial<{getCollections:{};}>":{"type":"object","properties":{"getCollections":{"$ref":"#/definitions/DeepPartial<{}>"}}},"DeepPartial<{}>":{"type":"object"},"DeepPartial<{[k:string]:any;}>":{"type":"object"},"DeepPartial<RelationQuery&VQLRef>":{"type":"object","properties":{"r":{"$ref":"#/definitions/DeepPartial<{path:RelationTypes.Path;search:Search<any>;relations:RelationTypes.Relation;many?:boolean;options?:DbFindOpts;select?:RelationTypes.FieldPath[];}>"},"ref":{"type":"string"},"var":{"$ref":"#/definitions/DeepPartial<{[k:string]:any;}>"}}},"DeepPartial<{path:RelationTypes.Path;search:Search<any>;relations:RelationTypes.Relation;many?:boolean;options?:DbFindOpts;select?:RelationTypes.FieldPath[];}>":{"type":"object","properties":{"path":{"type":"array","items":[{"type":"string"},{"type":"string"}],"minItems":0,"maxItems":2},"search":{"$ref":"#/definitions/DeepPartial<Search<any>>"},"relations":{"$ref":"#/definitions/DeepPartial<RelationTypes.Relation>"},"many":{"type":"boolean"},"options":{"$ref":"#/definitions/DeepPartial<DbFindOpts>"},"select":{"type":"array","items":{"type":"array","items":{"type":"string"}}}}},"DeepPartial<RelationTypes.Relation>":{"type":"object"}},"$schema":"http://json-schema.org/draft-07/schema#"}
@@ -1,2 +1,2 @@
1
1
  import { VQL, VQLR } from "../types/vql.js";
2
- export declare function executeSheet(query: VQLR, preDefinedSheets: Map<string, VQL>): VQL;
2
+ export declare function executeSheetAndReplaceVars(query: VQLR, preDefinedSheets: Map<string, VQL>, user: any): VQL;
@@ -46,7 +46,7 @@ function replaceVariables(obj, variables) {
46
46
  }
47
47
  return obj;
48
48
  }
49
- export function executeSheet(query, preDefinedSheets) {
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
- if ("var" in query) {
60
- query = replaceVariables(query, query.var);
61
- delete query.var;
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
  }
@@ -1,40 +1,40 @@
1
1
  import { RelationTypes } from "@wxn0brp/db";
2
- import { Arg, Search } from "@wxn0brp/db/types/arg.js";
3
- import { DbFindOpts, FindOpts } from "@wxn0brp/db/types/options.js";
4
- import { UpdaterArg } from "@wxn0brp/db/types/updater.js";
5
- export type VQLQuery = {
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;
2
+ import { Search, Arg } from "@wxn0brp/db-core/types/arg";
3
+ import { DbFindOpts, FindOpts } from "@wxn0brp/db-core/types/options";
4
+ import { UpdaterArg } from "@wxn0brp/db-core/types/updater";
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> & VQLRefRequired) | VQLRefRequired;
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.3.11",
3
+ "version": "0.4.2",
4
4
  "main": "dist/index.js",
5
5
  "author": "wxn0brP",
6
6
  "license": "MIT",
@@ -15,29 +15,29 @@
15
15
  "dist"
16
16
  ],
17
17
  "peerDependencies": {
18
- "@wxn0brp/db": ">=0.8.2",
19
- "@wxn0brp/falcon-frame": ">=0.0.6"
18
+ "@wxn0brp/db-core": ">=0.0.1 <0.1.0",
19
+ "@wxn0brp/falcon-frame": ">=0.0.18"
20
20
  },
21
21
  "peerDependenciesMeta": {
22
22
  "@wxn0brp/falcon-frame": {
23
23
  "optional": true
24
24
  },
25
- "@wxn0brp/db": {
25
+ "@wxn0brp/db-core": {
26
26
  "optional": false
27
27
  }
28
28
  },
29
29
  "devDependencies": {
30
- "@types/node": "^22.15.30",
31
- "@wxn0brp/db": "^0.8.2",
32
- "@wxn0brp/falcon-frame": "0.0.6",
33
- "dotenv": "^16.5.0",
30
+ "@types/node": "^24.0.13",
31
+ "@wxn0brp/db": "^0.20.1",
32
+ "@wxn0brp/falcon-frame": "0.0.18",
33
+ "dotenv": "^17.2.0",
34
34
  "source-map-support": "^0.5.21",
35
35
  "tsc-alias": "^1.8.10",
36
36
  "typescript": "^5.7.3",
37
37
  "typescript-json-schema": "^0.65.1"
38
38
  },
39
39
  "dependencies": {
40
- "@wxn0brp/gate-warden": "^0.1.0",
40
+ "@wxn0brp/gate-warden": ">=0.3.0",
41
41
  "@wxn0brp/lucerna-log": "^0.1.1",
42
42
  "ajv": "^8.17.1",
43
43
  "ajv-formats": "^3.0.1",
package/dist/vql.d.ts DELETED
@@ -1,337 +0,0 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- export interface Data {
4
- [key: string]: any;
5
- }
6
- export interface Context {
7
- [key: string]: any;
8
- }
9
- export type Id = string;
10
- /** Logical Operators */
11
- export type LogicalOperators = {
12
- /**
13
- * Recursively applies multiple conditions, all of which must evaluate to true.
14
- * Can include other operators such as $gt, $exists, or nested $and/$or conditions.
15
- */
16
- $and?: Array<SearchOptions>;
17
- /**
18
- * Recursively applies multiple conditions, at least one of which must evaluate to true.
19
- * Can include other operators such as $lt, $type, or nested $and/$or conditions.
20
- */
21
- $or?: Array<SearchOptions>;
22
- /**
23
- * Negates a single condition.
24
- * Can include any other operator as its value.
25
- */
26
- $not?: SearchOptions;
27
- };
28
- /** Comparison Operators */
29
- export type ComparisonOperators = {
30
- $gt?: Record<string, number>;
31
- $lt?: Record<string, number>;
32
- $gte?: Record<string, number>;
33
- $lte?: Record<string, number>;
34
- $in?: Record<string, any[]>;
35
- $nin?: Record<string, any[]>;
36
- $between?: Record<string, [
37
- number,
38
- number
39
- ]>;
40
- };
41
- /** Type and Existence Operators */
42
- export type TypeAndExistenceOperators = {
43
- $exists?: Record<string, boolean>;
44
- $type?: Record<string, string>;
45
- };
46
- /** Array Operators */
47
- export type ArrayOperators = {
48
- $arrinc?: Record<string, any[]>;
49
- $arrincall?: Record<string, any[]>;
50
- $size?: Record<string, number>;
51
- };
52
- /** String Operators */
53
- export type StringOperators = {
54
- $regex?: Record<string, RegExp>;
55
- $startsWith?: Record<string, string>;
56
- $endsWith?: Record<string, string>;
57
- };
58
- /** Other Operators */
59
- export type OtherOperators = {
60
- $subset?: Record<string, any>;
61
- };
62
- /** Predefined Search Operators */
63
- export type PredefinedSearchOperators = LogicalOperators & ComparisonOperators & TypeAndExistenceOperators & ArrayOperators & StringOperators & OtherOperators;
64
- /**
65
- * SearchOptions can be either a function or an object with predefined operators.
66
- */
67
- export type SearchOptions = PredefinedSearchOperators & Arg;
68
- /**
69
- * Predefined type for updating data.
70
- */
71
- /** Arrays */
72
- export type ArrayUpdater = {
73
- $push?: any;
74
- /** Pushes items into an array and removes duplicates */
75
- $pushset?: any;
76
- $pull?: any;
77
- $pullall?: any;
78
- };
79
- /** Objects */
80
- export type ObjectUpdater = {
81
- $merge?: any;
82
- };
83
- /** Values */
84
- export type ValueUpdater = {
85
- $set?: any;
86
- $inc?: any;
87
- $dec?: any;
88
- $unset?: any;
89
- $rename?: any;
90
- };
91
- export type UpdaterArg = ArrayUpdater & ObjectUpdater & ValueUpdater & {
92
- [key: string]: any;
93
- };
94
- export interface Arg {
95
- _id?: Id;
96
- [key: string]: any;
97
- }
98
- export type SearchFunc<T = any> = (data: T, context: Context) => boolean;
99
- export type UpdaterFunc<T = any> = (data: T, context: Context) => boolean;
100
- export type Search<T = any> = SearchOptions | SearchFunc<T>;
101
- export type Updater<T = any> = UpdaterArg | UpdaterArg[] | UpdaterFunc<T>;
102
- export interface DbFindOpts {
103
- reverse?: boolean;
104
- max?: number;
105
- }
106
- export interface FindOpts {
107
- select?: string[];
108
- exclude?: string[];
109
- transform?: Function;
110
- }
111
- export interface Transaction {
112
- type: "update" | "updateOne" | "updateOneOrAdd" | "remove" | "removeOne";
113
- search: Search;
114
- updater?: Updater;
115
- addArg?: Arg;
116
- idGen?: boolean;
117
- context?: Context;
118
- }
119
- export interface ValtheraCompatible {
120
- c(collection: string): CollectionManager;
121
- getCollections(): Promise<string[]>;
122
- checkCollection(collection: string): Promise<boolean>;
123
- issetCollection(collection: string): Promise<boolean>;
124
- add<T = Data>(collection: string, data: Arg, id_gen?: boolean): Promise<T>;
125
- find<T = Data>(collection: string, search: Search, context?: Context, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
126
- findOne<T = Data>(collection: string, search: Search, context?: Context, findOpts?: FindOpts): Promise<T | null>;
127
- findStream<T = Data>(collection: string, search: Search, context?: Context, findOpts?: FindOpts, limit?: number): Promise<AsyncGenerator<T>>;
128
- update(collection: string, search: Search, updater: Updater, context?: Context): Promise<boolean>;
129
- updateOne(collection: string, search: Search, updater: Updater, context?: Context): Promise<boolean>;
130
- remove(collection: string, search: Search, context?: Context): Promise<boolean>;
131
- removeOne(collection: string, search: Search, context?: Context): Promise<boolean>;
132
- removeCollection(collection: string): Promise<boolean>;
133
- transaction(collection: string, transaction: Transaction[]): Promise<boolean>;
134
- updateOneOrAdd(collection: string, search: Search, updater: Updater, add_arg?: Arg, context?: Context, id_gen?: boolean): Promise<boolean>;
135
- }
136
- declare class CollectionManager {
137
- private db;
138
- private collection;
139
- constructor(db: ValtheraCompatible, collection: string);
140
- /**
141
- * Add data to a database.
142
- */
143
- add<T = Data>(data: Arg, id_gen?: boolean): Promise<T>;
144
- /**
145
- * Find data in a database.
146
- */
147
- find<T = Data>(search: Search, context?: Context, options?: DbFindOpts, findOpts?: FindOpts): Promise<T[]>;
148
- /**
149
- * Find one data entry in a database.
150
- */
151
- findOne<T = Data>(search: Search, context?: Context, findOpts?: FindOpts): Promise<T>;
152
- /**
153
- * Find data in a database as a stream.
154
- */
155
- findStream<T = Data>(search: Search, context?: Context, findOpts?: FindOpts, limit?: number): AsyncGenerator<T>;
156
- /**
157
- * Update data in a database.
158
- */
159
- update(search: Search, updater: Updater, context?: Context): Promise<boolean>;
160
- /**
161
- * Update one data entry in a database.
162
- */
163
- updateOne(search: Search, updater: Updater, context?: Context): Promise<boolean>;
164
- /**
165
- * Remove data from a database.
166
- */
167
- remove(search: Search, context?: Context): Promise<boolean>;
168
- /**
169
- * Remove one data entry from a database.
170
- */
171
- removeOne(search: Search, context?: Context): Promise<boolean>;
172
- /**
173
- * Asynchronously updates one entry in a database or adds a new one if it doesn't exist.
174
- */
175
- updateOneOrAdd(search: Search, updater: Updater, add_arg?: Arg, context?: Context, id_gen?: boolean): Promise<boolean>;
176
- }
177
- declare namespace RelationTypes {
178
- type Path = [
179
- string,
180
- string
181
- ];
182
- type FieldPath = string[];
183
- interface DBS {
184
- [key: string]: ValtheraCompatible;
185
- }
186
- interface Relation {
187
- [key: string]: RelationConfig;
188
- }
189
- interface RelationConfig {
190
- path: Path;
191
- pk?: string;
192
- fk?: string;
193
- as?: string;
194
- select?: string[];
195
- findOpts?: DbFindOpts;
196
- type?: "1" | "11" | "1n" | "nm";
197
- relations?: Relation;
198
- through?: {
199
- table: string;
200
- db?: string;
201
- pk: string;
202
- fk: string;
203
- };
204
- }
205
- }
206
- export type VQLQuery = {
207
- find: VQLFind;
208
- findOne: VQLFindOne;
209
- f: VQLFindOne;
210
- add: VQLAdd;
211
- update: VQLUpdate;
212
- updateOne: VQLUpdateOne;
213
- remove: VQLRemove;
214
- removeOne: VQLRemoveOne;
215
- updateOneOrAdd: VQLUpdateOneOrAdd;
216
- removeCollection: VQLCollectionOperation;
217
- checkCollection: VQLCollectionOperation;
218
- issetCollection: VQLCollectionOperation;
219
- getCollections: {};
220
- };
221
- export type VQLQueryData = {
222
- find: VQLFind;
223
- } | {
224
- findOne: VQLFindOne;
225
- } | {
226
- f: VQLFindOne;
227
- } | {
228
- add: VQLAdd;
229
- } | {
230
- update: VQLUpdate;
231
- } | {
232
- updateOne: VQLUpdateOne;
233
- } | {
234
- remove: VQLRemove;
235
- } | {
236
- removeOne: VQLRemoveOne;
237
- } | {
238
- updateOneOrAdd: VQLUpdateOneOrAdd;
239
- } | {
240
- removeCollection: VQLCollectionOperation;
241
- } | {
242
- checkCollection: VQLCollectionOperation;
243
- } | {
244
- issetCollection: VQLCollectionOperation;
245
- } | {
246
- getCollections: {};
247
- };
248
- export interface VQLRequest {
249
- db: string;
250
- d: VQLQueryData;
251
- }
252
- export interface VQLFind {
253
- collection: string;
254
- search?: Search;
255
- limit?: number;
256
- fields?: VQLFields;
257
- select?: VQLFields;
258
- relations?: VQLRelations;
259
- options?: DbFindOpts;
260
- searchOpts?: FindOpts;
261
- }
262
- export interface VQLFindOne {
263
- collection: string;
264
- search: Search;
265
- fields?: VQLFields;
266
- select?: VQLFields;
267
- relations?: VQLRelations;
268
- searchOpts?: FindOpts;
269
- }
270
- export interface VQLAdd {
271
- collection: string;
272
- data: Arg;
273
- id_gen?: boolean;
274
- }
275
- export interface VQLUpdate {
276
- collection: string;
277
- search: Search;
278
- updater: UpdaterArg;
279
- }
280
- export interface VQLUpdateOne {
281
- collection: string;
282
- search: Search;
283
- updater: UpdaterArg;
284
- }
285
- export interface VQLRemove {
286
- collection: string;
287
- search: Search;
288
- }
289
- export interface VQLRemoveOne {
290
- collection: string;
291
- search: Search;
292
- }
293
- export interface VQLUpdateOneOrAdd {
294
- collection: string;
295
- search: Search;
296
- updater: UpdaterArg;
297
- add_arg?: Arg;
298
- id_gen?: boolean;
299
- }
300
- export interface VQLCollectionOperation {
301
- collection: string;
302
- }
303
- export type VQLFields = Record<string, boolean | number> | string[];
304
- export type VQLRelations = Record<string, VQLFind | VQLFindOne>;
305
- export interface RelationQuery {
306
- r: {
307
- path: RelationTypes.Path;
308
- search: Search;
309
- relations: RelationTypes.Relation;
310
- many?: boolean;
311
- options?: DbFindOpts;
312
- select?: RelationTypes.FieldPath[];
313
- };
314
- }
315
- export interface VQLRef {
316
- ref?: string;
317
- var?: {
318
- [k: string]: any;
319
- };
320
- }
321
- export type VQLRefRequired = VQLRef & Required<Pick<VQLRef, "ref">>;
322
- export type DeepPartial<T> = {
323
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
324
- };
325
- export type VQL = (VQLRequest | RelationQuery) & VQLRef;
326
- export type VQLR = VQL | (DeepPartial<VQL> & VQLRefRequired) | VQLRefRequired;
327
- export interface VQLError {
328
- err: true;
329
- msg: string;
330
- c: number;
331
- why?: string;
332
- }
333
- export type VqlQueryRaw = VQLR | string | {
334
- query: string;
335
- } & VQLRef;
336
-
337
- export {};