@wxn0brp/vql-client 0.2.8 → 0.2.9

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];
@@ -80,8 +83,40 @@ export type SearchFunc<T = any> = (data: T, context: VContext) => boolean;
80
83
  export type UpdaterFunc<T = any> = (data: T, context: VContext) => boolean;
81
84
  export type Search<T = any> = SearchOptions<T> | SearchFunc<T>;
82
85
  export type Updater<T = any> = UpdaterArg<T> | UpdaterArg<T>[] | UpdaterFunc<T>;
83
- export interface Data {
84
- [key: string]: any;
86
+ export interface UpdateOneOrAdd<T> {
87
+ add_arg?: Arg<T>;
88
+ id_gen?: boolean;
89
+ context?: VContext;
90
+ }
91
+ export interface VQuery_Control {
92
+ }
93
+ export interface VQuery<T = Data> {
94
+ collection?: string;
95
+ search?: Search<T>;
96
+ context?: VContext;
97
+ dbFindOpts?: DbFindOpts<T>;
98
+ findOpts?: FindOpts<T>;
99
+ data?: Arg<T>;
100
+ id_gen?: boolean;
101
+ add_arg?: Arg<T>;
102
+ updater?: Updater<T>;
103
+ control?: VQuery_Control;
104
+ }
105
+ export type QueryBase<T = Data> = Required<Pick<VQuery<T>, "collection" | "search">> & Pick<VQuery<T>, "control">;
106
+ export type AddQuery<T = Data> = Required<Pick<VQuery<T>, "data" | "collection">> & Pick<VQuery<T>, "id_gen" | "control">;
107
+ export type FindQuery<T = Data> = Omit<QueryBase, "search"> & Pick<VQuery<T>, "search"> & Pick<VQuery<T>, "findOpts" | "dbFindOpts" | "context">;
108
+ export type FindOneQuery<T = Data> = QueryBase & Pick<VQuery<T>, "findOpts" | "context">;
109
+ export type UpdateQuery<T = Data> = QueryBase & Required<Pick<VQuery<T>, "updater">> & Pick<VQuery<T>, "context">;
110
+ export type RemoveQuery<T = Data> = QueryBase & Pick<VQuery<T>, "context">;
111
+ export type UpdateOneOrAddQuery<T = Data> = QueryBase & UpdateQuery & Pick<VQuery<T>, "add_arg" | "id_gen">;
112
+ export type ToggleOneQuery<T = Data> = QueryBase & Pick<VQuery<T>, "data" | "context">;
113
+ export interface UpdateOneOrAddResult<T> {
114
+ data: T;
115
+ type: "added" | "updated";
116
+ }
117
+ export interface ToggleOneResult<T> {
118
+ data: T;
119
+ type: "added" | "removed";
85
120
  }
86
121
  export interface DbFindOpts<T = any> {
87
122
  reverse?: boolean;
@@ -95,40 +130,44 @@ export interface FindOpts<T = any> {
95
130
  exclude?: KeysMatching<T, any>[];
96
131
  transform?: Function;
97
132
  }
98
- declare class CollectionManager<D = Data> {
99
- private db;
100
- private collection;
133
+ declare class Collection<D = Data> {
134
+ db: ValtheraCompatible;
135
+ collection: string;
101
136
  constructor(db: ValtheraCompatible, collection: string);
102
- add(data: Arg<D>, id_gen?: boolean): Promise<D>;
137
+ add(data: Arg<D>, id_gen: false): Promise<D>;
138
+ add(data: Arg<D>, id_gen?: true): Promise<D & {
139
+ _id: string;
140
+ }>;
103
141
  find(search?: Search<D>, options?: DbFindOpts<D>, findOpts?: FindOpts<D>, context?: VContext): Promise<D[]>;
104
142
  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>;
143
+ update(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<D[]>;
144
+ updateOne(search: Search<D>, updater: Updater<D>, context?: VContext): Promise<D | null>;
145
+ remove(search: Search<D>, context?: VContext): Promise<D[]>;
146
+ removeOne(search: Search<D>, context?: VContext): Promise<D | null>;
147
+ updateOneOrAdd(search: Search<D>, updater: Updater<D>, { add_arg, context, id_gen }?: UpdateOneOrAdd<D>): Promise<UpdateOneOrAddResult<D>>;
148
+ toggleOne(search: Search<D>, data?: Arg<D>, context?: VContext): Promise<ToggleOneResult<D>>;
111
149
  }
112
150
  export interface ValtheraCompatible {
113
- c(collection: string): CollectionManager;
151
+ c<T = Data>(collection: string): Collection<T>;
114
152
  getCollections(): Promise<string[]>;
115
153
  ensureCollection(collection: string): Promise<boolean>;
116
154
  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>;
155
+ add<T = Data>(query: AddQuery<T>): Promise<T>;
156
+ find<T = Data>(query: FindQuery<T>): Promise<T[]>;
157
+ findOne<T = Data>(query: FindOneQuery<T>): Promise<T | null>;
158
+ update<T = Data>(query: UpdateQuery<T>): Promise<T[]>;
159
+ updateOne<T = Data>(query: UpdateQuery<T>): Promise<T | null>;
160
+ remove<T = Data>(query: RemoveQuery<T>): Promise<T[]>;
161
+ removeOne<T = Data>(query: RemoveQuery<T>): Promise<T | null>;
124
162
  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>;
163
+ updateOneOrAdd<T = Data>(query: UpdateOneOrAddQuery<T>): Promise<UpdateOneOrAddResult<T>>;
164
+ toggleOne<T = Data>(query: ToggleOneQuery<T>): Promise<ToggleOneResult<T>>;
127
165
  }
128
- export interface UpdateOneOrAdd<T> {
129
- add_arg?: Arg<T>;
130
- id_gen?: boolean;
131
- context?: VContext;
166
+ export interface VQuery_Control {
167
+ dir?: {
168
+ lastFileNum?: number;
169
+ sortedFiles?: string[];
170
+ };
132
171
  }
133
172
  declare namespace RelationTypes {
134
173
  type Path = [
@@ -148,7 +187,7 @@ declare namespace RelationTypes {
148
187
  fk?: string;
149
188
  as?: string;
150
189
  select?: string[];
151
- findOpts?: DbFindOpts;
190
+ dbFindOpts?: DbFindOpts;
152
191
  type?: "1" | "11" | "1n" | "nm";
153
192
  relations?: Relation;
154
193
  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.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "VQL Client",