@wxn0brp/vql-client 0.2.8 → 0.2.10

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 wxn0brP
3
+ Copyright (c) 2026 wxn0brP
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -9,6 +9,12 @@ Supports:
9
9
  - Fully typed with TypeScript
10
10
  - Custom transport layers and lifecycle hooks
11
11
 
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @wxn0brp/vql-client
16
+ ```
17
+
12
18
  ## DOCS
13
19
 
14
20
  [API Reference](https://wxn0brp.github.io/VQL-client/)
@@ -32,9 +38,7 @@ const result = await fetchVQL("db1 user! s._id = xyz");
32
38
  </script>
33
39
  ```
34
40
 
35
- ## Usage
36
-
37
- ### `fetchVQL<T = any>(query: string | object, vars?: Object, hookContext?: Object): Promise<T>`
41
+ ### `fetchVQL<T = any>(query: string | object, vars?: Object, hookContext?: Object, fetchOptions?: FetchOptions): Promise<T>`
38
42
 
39
43
  Executes a VQL query and returns the result (unwrapped from `{ result }`, unless an error is present).
40
44
 
@@ -82,10 +86,16 @@ Returns:
82
86
  }
83
87
  ```
84
88
 
89
+ ## About Releases
90
+
91
+ Some releases may not have associated source code commits (e.g., `0.2.8`, `0.2.7`). These releases contain type definition updates only.
92
+
93
+ The `vql.d.ts` file is not maintained in this repository. During the release process, it is fetched (via `curl`) from the main project repository and included in the published package. If only the external type definitions change, a new version is published without modifying this repository’s source code.
94
+
85
95
  ## License
86
96
 
87
- MIT wxn0brP
97
+ MIT. See [LICENSE](./LICENSE)
88
98
 
89
99
  ## Contributing
90
100
 
91
- Contributions are welcome!
101
+ Contributions are welcome!
package/dist/vql.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export interface Data {
2
+ [key: string]: any;
3
+ }
1
4
  export type KeysMatching<T, V, C = V> = {
2
5
  [K in keyof T]-?: T[K] extends C ? K : never;
3
6
  }[keyof T];
@@ -22,10 +25,10 @@ export type ComparisonOperators<T = any> = {
22
25
  number,
23
26
  number
24
27
  ], number>;
25
- $in?: DeepPartial<T> & {
28
+ $in?: {
26
29
  [K in keyof T]?: T[K] extends any[] ? T[K] : T[K][];
27
30
  };
28
- $nin?: DeepPartial<T> & {
31
+ $nin?: {
29
32
  [K in keyof T]?: T[K] extends any[] ? T[K] : T[K][];
30
33
  };
31
34
  $idGt?: NestedValue<T, string | number, string | number>;
@@ -38,8 +41,12 @@ export type TypeAndExistenceOperators<T = any> = {
38
41
  $type?: NestedValue<T, JSPrimitiveType, any>;
39
42
  };
40
43
  export type ArrayOperators<T = any> = {
41
- $arrinc?: DeepPartial<T>;
42
- $arrincall?: DeepPartial<T>;
44
+ $arrinc?: {
45
+ [K in keyof T]?: T[K] extends any[] ? T[K][number][] : T[K][];
46
+ };
47
+ $arrincall?: {
48
+ [K in keyof T]?: T[K] extends any[] ? T[K][number][] : T[K][];
49
+ };
43
50
  $size?: NestedValue<T, number>;
44
51
  };
45
52
  export type StringOperators<T = any> = {
@@ -80,8 +87,42 @@ export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
80
87
  export type UpdaterFunc<T = any> = (data: T, context: VContext) => boolean;
81
88
  export type Search<T = any> = SearchOptions<T> | SearchFunc<T>;
82
89
  export type Updater<T = any> = UpdaterArg<T> | UpdaterArg<T>[] | UpdaterFunc<T>;
83
- export interface Data {
84
- [key: string]: any;
90
+ export interface UpdateOneOrAdd<T> {
91
+ add_arg?: Arg<T>;
92
+ id_gen?: boolean;
93
+ context?: VContext;
94
+ }
95
+ export interface VQuery_Control {
96
+ }
97
+ export interface VQuery<T = Data> {
98
+ collection?: string;
99
+ search?: Search<T>;
100
+ context?: VContext;
101
+ dbFindOpts?: DbFindOpts<T>;
102
+ findOpts?: FindOpts<T>;
103
+ data?: Arg<T>;
104
+ id_gen?: boolean;
105
+ add_arg?: Arg<T>;
106
+ updater?: Updater<T>;
107
+ control?: VQuery_Control;
108
+ }
109
+ declare namespace VQueryT {
110
+ type QueryBase<T = Data> = Required<Pick<VQuery<T>, "collection" | "search">> & Pick<VQuery<T>, "control">;
111
+ type Add<T = Data> = Required<Pick<VQuery<T>, "data" | "collection">> & Pick<VQuery<T>, "id_gen" | "control">;
112
+ type Find<T = Data> = Omit<QueryBase, "search"> & Pick<VQuery<T>, "search"> & Pick<VQuery<T>, "findOpts" | "dbFindOpts" | "context">;
113
+ type FindOne<T = Data> = QueryBase & Pick<VQuery<T>, "findOpts" | "context">;
114
+ type Update<T = Data> = QueryBase & Required<Pick<VQuery<T>, "updater">> & Pick<VQuery<T>, "context">;
115
+ type Remove<T = Data> = QueryBase & Pick<VQuery<T>, "context">;
116
+ type UpdateOneOrAdd<T = Data> = QueryBase & Update & Pick<VQuery<T>, "add_arg" | "id_gen">;
117
+ type ToggleOne<T = Data> = QueryBase & Pick<VQuery<T>, "data" | "context">;
118
+ interface UpdateOneOrAddResult<T> {
119
+ data: T;
120
+ type: "added" | "updated";
121
+ }
122
+ interface ToggleOneResult<T> {
123
+ data: T;
124
+ type: "added" | "removed";
125
+ }
85
126
  }
86
127
  export interface DbFindOpts<T = any> {
87
128
  reverse?: boolean;
@@ -95,40 +136,44 @@ export interface FindOpts<T = any> {
95
136
  exclude?: KeysMatching<T, any>[];
96
137
  transform?: Function;
97
138
  }
98
- declare class CollectionManager<D = Data> {
99
- private db;
100
- private collection;
139
+ declare class Collection<D = Data> {
140
+ db: ValtheraCompatible;
141
+ collection: string;
101
142
  constructor(db: ValtheraCompatible, collection: string);
102
- add(data: Arg<D>, id_gen?: boolean): Promise<D>;
143
+ add(data: Arg<D>, id_gen: false): Promise<D>;
144
+ add(data: Arg<D>, id_gen?: true): Promise<D & {
145
+ _id: string;
146
+ }>;
103
147
  find(search?: Search<D>, options?: DbFindOpts<D>, findOpts?: FindOpts<D>, context?: VContext): Promise<D[]>;
104
148
  findOne(search?: Search<D>, findOpts?: FindOpts<D>, context?: VContext): Promise<D>;
105
- update(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<boolean>;
106
- updateOne(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<boolean>;
107
- remove(search: Search<D>, context?: VContext): Promise<boolean>;
108
- removeOne(search: Search<D>, context?: VContext): Promise<boolean>;
109
- updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<boolean>;
110
- toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<boolean>;
149
+ update(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<D[]>;
150
+ updateOne(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<D | null>;
151
+ remove(search: Search<D>, context?: VContext): Promise<D[]>;
152
+ removeOne(search: Search<D>, context?: VContext): Promise<D | null>;
153
+ updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<VQueryT.UpdateOneOrAddResult<D>>;
154
+ toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<VQueryT.ToggleOneResult<D>>;
111
155
  }
112
156
  export interface ValtheraCompatible {
113
- c(collection: string): CollectionManager;
157
+ c<T = Data>(collection: string): Collection<T>;
114
158
  getCollections(): Promise<string[]>;
115
159
  ensureCollection(collection: string): Promise<boolean>;
116
160
  issetCollection(collection: string): Promise<boolean>;
117
- add<T = Data>(collection: string, data: Arg<T>, id_gen?: boolean): Promise<T>;
118
- find<T = Data>(collection: string, search?: Search<T>, options?: DbFindOpts<T>, findOpts?: FindOpts<T>, context?: VContext): Promise<T[]>;
119
- findOne<T = Data>(collection: string, search?: Search<T>, findOpts?: FindOpts<T>, context?: VContext): Promise<T | null>;
120
- update<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, context?: VContext): Promise<boolean>;
121
- updateOne<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, context?: VContext): Promise<boolean>;
122
- remove<T = Data>(collection: string, search: Search<T>, context?: VContext): Promise<boolean>;
123
- removeOne<T = Data>(collection: string, search: Search<T>, context?: VContext): Promise<boolean>;
161
+ add<T = Data>(query: VQueryT.Add<T>): Promise<T>;
162
+ find<T = Data>(query: VQueryT.Find<T>): Promise<T[]>;
163
+ findOne<T = Data>(query: VQueryT.FindOne<T>): Promise<T | null>;
164
+ update<T = Data>(query: VQueryT.Update<T>): Promise<T[]>;
165
+ updateOne<T = Data>(query: VQueryT.Update<T>): Promise<T | null>;
166
+ remove<T = Data>(query: VQueryT.Remove<T>): Promise<T[]>;
167
+ removeOne<T = Data>(query: VQueryT.Remove<T>): Promise<T | null>;
124
168
  removeCollection(collection: string): Promise<boolean>;
125
- updateOneOrAdd<T = Data>(collection: string, search: Search<T>, updater: Updater<T>, opts?: UpdateOneOrAdd<T>): Promise<boolean>;
126
- toggleOne<T = Data>(collection: string, search: Search<T>, data?: Arg<T>, context?: VContext): Promise<boolean>;
169
+ updateOneOrAdd<T = Data>(query: VQueryT.UpdateOneOrAdd<T>): Promise<VQueryT.UpdateOneOrAddResult<T>>;
170
+ toggleOne<T = Data>(query: VQueryT.ToggleOne<T>): Promise<VQueryT.ToggleOneResult<T>>;
127
171
  }
128
- export interface UpdateOneOrAdd<T> {
129
- add_arg?: Arg<T>;
130
- id_gen?: boolean;
131
- context?: VContext;
172
+ export interface VQuery_Control {
173
+ dir?: {
174
+ lastFileNum?: number;
175
+ sortedFiles?: string[];
176
+ };
132
177
  }
133
178
  declare namespace RelationTypes {
134
179
  type Path = [
@@ -148,7 +193,7 @@ declare namespace RelationTypes {
148
193
  fk?: string;
149
194
  as?: string;
150
195
  select?: string[];
151
- findOpts?: DbFindOpts;
196
+ dbFindOpts?: DbFindOpts;
152
197
  type?: "1" | "11" | "1n" | "nm";
153
198
  relations?: Relation;
154
199
  through?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/vql-client",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "VQL Client",
@@ -26,8 +26,8 @@
26
26
  "license": "MIT",
27
27
  "type": "module",
28
28
  "devDependencies": {
29
- "esbuild": "*",
30
- "typescript": "*"
29
+ "esbuild": "^0.28",
30
+ "typescript": "^6"
31
31
  },
32
32
  "files": [
33
33
  "dist"