proto.io 0.0.173 → 0.0.175
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/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/storage/progres.d.ts +2 -2
- package/dist/adapters/storage/progres.js +3 -3
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +3 -3
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -2
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +75 -3
- package/dist/index.js +121 -261
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -263
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-Cpv1DoEI.d.ts → index-B9CWU0y7.d.ts} +32 -2
- package/dist/internals/index-B9CWU0y7.d.ts.map +1 -0
- package/dist/internals/{index-BZNPlw1L.mjs → index-BPbXumUi.mjs} +286 -44
- package/dist/internals/index-BPbXumUi.mjs.map +1 -0
- package/dist/internals/{index-BJnQhKf3.d.ts → index-BQqYdjaH.d.ts} +2 -2
- package/dist/internals/index-BQqYdjaH.d.ts.map +1 -0
- package/dist/internals/{index-lX-M76Tn.d.ts → index-BYZpj31o.d.ts} +1062 -33
- package/dist/internals/index-BYZpj31o.d.ts.map +1 -0
- package/dist/internals/{index-BYbMU-Ao.mjs → index-CTsc042s.mjs} +140 -2
- package/dist/internals/index-CTsc042s.mjs.map +1 -0
- package/dist/internals/{index-CIecB6mS.js → index-CvA0tbwx.js} +286 -44
- package/dist/internals/index-CvA0tbwx.js.map +1 -0
- package/dist/internals/{index-B1wqSio6.mjs → index-DHQhYGsJ.mjs} +2 -2
- package/dist/internals/{index-B1wqSio6.mjs.map → index-DHQhYGsJ.mjs.map} +1 -1
- package/dist/internals/{index-CVutVPmd.js → index-DXuW8UiB.js} +139 -1
- package/dist/internals/index-DXuW8UiB.js.map +1 -0
- package/dist/internals/{index-CzfsyXvb.js → index-Dc3V_Bzw.js} +2 -2
- package/dist/internals/{index-CzfsyXvb.js.map → index-Dc3V_Bzw.js.map} +1 -1
- package/dist/internals/{random-BCpwYpyw.mjs → random-BMQpRlGH.mjs} +3 -3
- package/dist/internals/{random-BCpwYpyw.mjs.map → random-BMQpRlGH.mjs.map} +1 -1
- package/dist/internals/{random-Dytum6Nh.js → random-DVOUDDGg.js} +3 -3
- package/dist/internals/{random-Dytum6Nh.js.map → random-DVOUDDGg.js.map} +1 -1
- package/package.json +1 -1
- package/dist/internals/index-BJnQhKf3.d.ts.map +0 -1
- package/dist/internals/index-BYbMU-Ao.mjs.map +0 -1
- package/dist/internals/index-BZNPlw1L.mjs.map +0 -1
- package/dist/internals/index-CIecB6mS.js.map +0 -1
- package/dist/internals/index-CVutVPmd.js.map +0 -1
- package/dist/internals/index-Cpv1DoEI.d.ts.map +0 -1
- package/dist/internals/index-lX-M76Tn.d.ts.map +0 -1
|
@@ -7,22 +7,6 @@ import _ from 'lodash';
|
|
|
7
7
|
import { Readable } from 'node:stream';
|
|
8
8
|
import { Socket } from 'socket.io-client';
|
|
9
9
|
|
|
10
|
-
type TNumber = number | Decimal | BigInt;
|
|
11
|
-
type TPrimitive = Date | string | TNumber | boolean | null | undefined;
|
|
12
|
-
type TDictionary = {
|
|
13
|
-
[x: string]: TSerializable;
|
|
14
|
-
};
|
|
15
|
-
type TSerializable = TDictionary | TSerializable[] | TPrimitive | TObject;
|
|
16
|
-
type SerializeOptions = {
|
|
17
|
-
space?: string | number;
|
|
18
|
-
objAttrs?: string[];
|
|
19
|
-
};
|
|
20
|
-
type DeserializeOptions = {
|
|
21
|
-
objAttrs?: string[];
|
|
22
|
-
};
|
|
23
|
-
declare const serialize: (x: TSerializable, options?: SerializeOptions) => string;
|
|
24
|
-
declare const deserialize: (buffer: string, options?: DeserializeOptions) => TSerializable;
|
|
25
|
-
|
|
26
10
|
type _Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
27
11
|
type _Lower = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
28
12
|
type _Upper = Uppercase<_Lower>;
|
|
@@ -44,33 +28,100 @@ declare class TUser extends TObject {
|
|
|
44
28
|
constructor(attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>));
|
|
45
29
|
}
|
|
46
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Class representing a Role.
|
|
33
|
+
* @extends TObject
|
|
34
|
+
*/
|
|
47
35
|
declare class TRole extends TObject {
|
|
48
36
|
constructor(attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>));
|
|
37
|
+
/**
|
|
38
|
+
* Get the name of the role.
|
|
39
|
+
* @return {string | undefined} The name of the role.
|
|
40
|
+
*/
|
|
49
41
|
get name(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get the users associated with the role.
|
|
44
|
+
* @return {TUser[]} The users associated with the role.
|
|
45
|
+
*/
|
|
50
46
|
get users(): TUser[];
|
|
47
|
+
/**
|
|
48
|
+
* Set the users associated with the role.
|
|
49
|
+
* @param {TUser[]} value - The users to associate with the role.
|
|
50
|
+
*/
|
|
51
51
|
set users(value: TUser[]);
|
|
52
|
+
/**
|
|
53
|
+
* Get the roles associated with the role.
|
|
54
|
+
* @return {TRole[]} The roles associated with the role.
|
|
55
|
+
*/
|
|
52
56
|
get roles(): TRole[];
|
|
57
|
+
/**
|
|
58
|
+
* Set the roles associated with the role.
|
|
59
|
+
* @param {TRole[]} value - The roles to associate with the role.
|
|
60
|
+
*/
|
|
53
61
|
set roles(value: TRole[]);
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Represents a stream of data that can be read.
|
|
66
|
+
* It can be either a ReadableStream or a Readable.
|
|
67
|
+
*/
|
|
56
68
|
type FileStream = ReadableStream | Readable;
|
|
69
|
+
/**
|
|
70
|
+
* Represents the data of a file.
|
|
71
|
+
* It can be a string, Blob, BinaryData, FileStream, or an object containing a base64 string.
|
|
72
|
+
*/
|
|
57
73
|
type FileData = string | Blob | BinaryData | FileStream | {
|
|
58
74
|
base64: string;
|
|
59
75
|
};
|
|
60
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Interface representing a file.
|
|
79
|
+
*/
|
|
61
80
|
interface TFile {
|
|
81
|
+
/**
|
|
82
|
+
* URL of the file.
|
|
83
|
+
*/
|
|
62
84
|
url: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Retrieves the file data.
|
|
87
|
+
* @param options - Optional extra options.
|
|
88
|
+
* @returns A FileStream containing the file data.
|
|
89
|
+
*/
|
|
63
90
|
fileData(options?: ExtraOptions<boolean>): FileStream;
|
|
91
|
+
/**
|
|
92
|
+
* Saves the file.
|
|
93
|
+
* @param options - Optional extra options including cascadeSave and uploadToken.
|
|
94
|
+
* @returns A promise that resolves to the current instance.
|
|
95
|
+
*/
|
|
64
96
|
save(options?: ExtraOptions<boolean> & {
|
|
65
97
|
cascadeSave?: boolean;
|
|
66
98
|
uploadToken?: string;
|
|
67
99
|
}): PromiseLike<this>;
|
|
68
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Class representing a file.
|
|
103
|
+
*/
|
|
69
104
|
declare class TFile extends TObject {
|
|
70
105
|
constructor(attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>));
|
|
106
|
+
/**
|
|
107
|
+
* Gets the filename of the file.
|
|
108
|
+
* @returns The filename.
|
|
109
|
+
*/
|
|
71
110
|
get filename(): string | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Gets the size of the file.
|
|
113
|
+
* @returns The size of the file.
|
|
114
|
+
*/
|
|
72
115
|
get size(): number | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Gets the type of the file.
|
|
118
|
+
* @returns The type of the file.
|
|
119
|
+
*/
|
|
73
120
|
get type(): string | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Gets the token of the file.
|
|
123
|
+
* @returns The token of the file.
|
|
124
|
+
*/
|
|
74
125
|
get token(): string | undefined;
|
|
75
126
|
}
|
|
76
127
|
|
|
@@ -170,105 +221,474 @@ type TQuerySelector = (TCoditionalQuerySelector & {
|
|
|
170
221
|
[x: string]: TFieldQuerySelector;
|
|
171
222
|
};
|
|
172
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Options for a query filter.
|
|
226
|
+
*/
|
|
173
227
|
interface TQueryFilterBaseOptions {
|
|
228
|
+
/**
|
|
229
|
+
* The filter(s) to apply to the query.
|
|
230
|
+
*/
|
|
174
231
|
filter?: TQuerySelector | TQuerySelector[];
|
|
175
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Sort option for a query.
|
|
235
|
+
*/
|
|
176
236
|
type TSortOption = {
|
|
237
|
+
/**
|
|
238
|
+
* The expression to sort by.
|
|
239
|
+
*/
|
|
177
240
|
expr: TExpression;
|
|
241
|
+
/**
|
|
242
|
+
* The order of sorting, 1 for ascending and -1 for descending.
|
|
243
|
+
*/
|
|
178
244
|
order: 1 | -1;
|
|
179
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Base options for a query.
|
|
248
|
+
*/
|
|
180
249
|
interface TQueryBaseOptions extends TQueryFilterBaseOptions {
|
|
250
|
+
/**
|
|
251
|
+
* The sorting options for the query.
|
|
252
|
+
*/
|
|
181
253
|
sort?: Record<string, 1 | -1> | TSortOption[];
|
|
254
|
+
/**
|
|
255
|
+
* The number of results to skip.
|
|
256
|
+
*/
|
|
182
257
|
skip?: number;
|
|
258
|
+
/**
|
|
259
|
+
* The limit on the number of results.
|
|
260
|
+
*/
|
|
183
261
|
limit?: number;
|
|
262
|
+
/**
|
|
263
|
+
* Nested query options for matching specific fields.
|
|
264
|
+
*/
|
|
184
265
|
matches?: Record<string, TQueryBaseOptions>;
|
|
185
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Base class for query filters.
|
|
269
|
+
*/
|
|
186
270
|
declare class TQueryFilterBase {
|
|
271
|
+
/**
|
|
272
|
+
* Applies a filter to the query.
|
|
273
|
+
* @param filter - The filter to apply.
|
|
274
|
+
* @returns The current instance for chaining.
|
|
275
|
+
*/
|
|
187
276
|
filter(filter: TQuerySelector): this;
|
|
277
|
+
/**
|
|
278
|
+
* Applies an equality filter to the query.
|
|
279
|
+
* @param key - The key to filter.
|
|
280
|
+
* @param value - The value to filter.
|
|
281
|
+
* @returns The current instance for chaining.
|
|
282
|
+
*/
|
|
188
283
|
equalTo<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
284
|
+
/**
|
|
285
|
+
* Applies a not equal filter to the query.
|
|
286
|
+
* @param key - The key to filter.
|
|
287
|
+
* @param value - The value to filter.
|
|
288
|
+
* @returns The current instance for chaining.
|
|
289
|
+
*/
|
|
189
290
|
notEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
291
|
+
/**
|
|
292
|
+
* Applies a less than filter to the query.
|
|
293
|
+
* @param key - The key to filter.
|
|
294
|
+
* @param value - The value to filter.
|
|
295
|
+
* @returns The current instance for chaining.
|
|
296
|
+
*/
|
|
190
297
|
lessThan<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
298
|
+
/**
|
|
299
|
+
* Applies a greater than filter to the query.
|
|
300
|
+
* @param key - The key to filter.
|
|
301
|
+
* @param value - The value to filter.
|
|
302
|
+
* @returns The current instance for chaining.
|
|
303
|
+
*/
|
|
191
304
|
greaterThan<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
305
|
+
/**
|
|
306
|
+
* Applies a less than or equal to filter to the query.
|
|
307
|
+
* @param key - The key to filter.
|
|
308
|
+
* @param value - The value to filter.
|
|
309
|
+
* @returns The current instance for chaining.
|
|
310
|
+
*/
|
|
192
311
|
lessThanOrEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
312
|
+
/**
|
|
313
|
+
* Applies a greater than or equal to filter to the query.
|
|
314
|
+
* @param key - The key to filter.
|
|
315
|
+
* @param value - The value to filter.
|
|
316
|
+
* @returns The current instance for chaining.
|
|
317
|
+
*/
|
|
193
318
|
greaterThanOrEqualTo<T extends string>(key: PathName<T>, value: TValue | undefined): this;
|
|
319
|
+
/**
|
|
320
|
+
* Applies a pattern filter to the query.
|
|
321
|
+
* @param key - The key to filter.
|
|
322
|
+
* @param value - The pattern to filter.
|
|
323
|
+
* @returns The current instance for chaining.
|
|
324
|
+
*/
|
|
194
325
|
pattern<T extends string>(key: PathName<T>, value: RegExp | string): this;
|
|
326
|
+
/**
|
|
327
|
+
* Applies a starts with filter to the query.
|
|
328
|
+
* @param key - The key to filter.
|
|
329
|
+
* @param value - The value to filter.
|
|
330
|
+
* @returns The current instance for chaining.
|
|
331
|
+
*/
|
|
195
332
|
startsWith<T extends string>(key: PathName<T>, value: string): this;
|
|
333
|
+
/**
|
|
334
|
+
* Applies an ends with filter to the query.
|
|
335
|
+
* @param key - The key to filter.
|
|
336
|
+
* @param value - The value to filter.
|
|
337
|
+
* @returns The current instance for chaining.
|
|
338
|
+
*/
|
|
196
339
|
endsWith<T extends string>(key: PathName<T>, value: string): this;
|
|
340
|
+
/**
|
|
341
|
+
* Applies a size filter to the query.
|
|
342
|
+
* @param key - The key to filter.
|
|
343
|
+
* @param value - The value to filter.
|
|
344
|
+
* @returns The current instance for chaining.
|
|
345
|
+
*/
|
|
197
346
|
size<T extends string>(key: PathName<T>, value: number): this;
|
|
347
|
+
/**
|
|
348
|
+
* Applies an empty filter to the query.
|
|
349
|
+
* @param key - The key to filter.
|
|
350
|
+
* @returns The current instance for chaining.
|
|
351
|
+
*/
|
|
198
352
|
empty<T extends string>(key: PathName<T>): this;
|
|
353
|
+
/**
|
|
354
|
+
* Applies a not empty filter to the query.
|
|
355
|
+
* @param key - The key to filter.
|
|
356
|
+
* @returns The current instance for chaining.
|
|
357
|
+
*/
|
|
199
358
|
notEmpty<T extends string>(key: PathName<T>): this;
|
|
359
|
+
/**
|
|
360
|
+
* Filters the query to include only documents where the specified key contains any of the specified values.
|
|
361
|
+
* @param key - The key to check for values.
|
|
362
|
+
* @param value - The array of values to check for.
|
|
363
|
+
* @returns The current instance for chaining.
|
|
364
|
+
*/
|
|
200
365
|
containsIn<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
366
|
+
/**
|
|
367
|
+
* Filters the query to exclude documents where the specified key contains any of the specified values.
|
|
368
|
+
* @param key - The key to check for values.
|
|
369
|
+
* @param value - The array of values to exclude.
|
|
370
|
+
* @returns The current instance for chaining.
|
|
371
|
+
*/
|
|
201
372
|
notContainsIn<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
373
|
+
/**
|
|
374
|
+
* Filters the query to include only documents where the specified key is a subset of the specified values.
|
|
375
|
+
* @param key - The key to check for subset.
|
|
376
|
+
* @param value - The array of values to check against.
|
|
377
|
+
* @returns The current instance for chaining.
|
|
378
|
+
*/
|
|
202
379
|
isSubset<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
380
|
+
/**
|
|
381
|
+
* Filters the query to include only documents where the specified key is a superset of the specified values.
|
|
382
|
+
* @param key - The key to check for superset.
|
|
383
|
+
* @param value - The array of values to check against.
|
|
384
|
+
* @returns The current instance for chaining.
|
|
385
|
+
*/
|
|
203
386
|
isSuperset<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
387
|
+
/**
|
|
388
|
+
* Filters the query to include only documents where the specified key is disjoint from the specified values.
|
|
389
|
+
* @param key - The key to check for disjoint.
|
|
390
|
+
* @param value - The array of values to check against.
|
|
391
|
+
* @returns The current instance for chaining.
|
|
392
|
+
*/
|
|
204
393
|
isDisjoint<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
394
|
+
/**
|
|
395
|
+
* Filters the query to include only documents where the specified key intersects with the specified values.
|
|
396
|
+
* @param key - The key to check for intersection.
|
|
397
|
+
* @param value - The array of values to check against.
|
|
398
|
+
* @returns The current instance for chaining.
|
|
399
|
+
*/
|
|
205
400
|
isIntersect<T extends string>(key: PathName<T>, value: TValue[]): this;
|
|
401
|
+
/**
|
|
402
|
+
* Filters the query to include only documents where every element of the specified key matches the provided callback query.
|
|
403
|
+
* @param key - The key to check for every element.
|
|
404
|
+
* @param callback - The callback query to apply to each element.
|
|
405
|
+
* @returns The current instance for chaining.
|
|
406
|
+
*/
|
|
206
407
|
every<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void): this;
|
|
408
|
+
/**
|
|
409
|
+
* Filters the query to include only documents where some elements of the specified key match the provided callback query.
|
|
410
|
+
* @param key - The key to check for some elements.
|
|
411
|
+
* @param callback - The callback query to apply to each element.
|
|
412
|
+
* @returns The current instance for chaining.
|
|
413
|
+
*/
|
|
207
414
|
some<T extends string>(key: PathName<T>, callback: (query: TQueryFilterBase) => void): this;
|
|
415
|
+
/**
|
|
416
|
+
* Filters the query to include only documents that match all of the provided callback queries.
|
|
417
|
+
* @param callbacks - The callback queries to apply.
|
|
418
|
+
* @returns The current instance for chaining.
|
|
419
|
+
*/
|
|
208
420
|
and(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
421
|
+
/**
|
|
422
|
+
* Filters the query to include only documents that match any of the provided callback queries.
|
|
423
|
+
* @param callbacks - The callback queries to apply.
|
|
424
|
+
* @returns The current instance for chaining.
|
|
425
|
+
*/
|
|
209
426
|
or(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
427
|
+
/**
|
|
428
|
+
* Filters the query to include only documents that do not match any of the provided callback queries.
|
|
429
|
+
* @param callbacks - The callback queries to apply.
|
|
430
|
+
* @returns The current instance for chaining.
|
|
431
|
+
*/
|
|
210
432
|
nor(...callbacks: _.Many<(query: TQueryFilterBase) => void>[]): this;
|
|
211
433
|
}
|
|
212
434
|
declare class TQueryBase extends TQueryFilterBase {
|
|
435
|
+
/**
|
|
436
|
+
* Sorts the query results.
|
|
437
|
+
* @param sort - The sorting criteria.
|
|
438
|
+
* @returns The current instance for chaining.
|
|
439
|
+
*/
|
|
213
440
|
sort<T extends Record<string, 1 | -1>>(sort: PathNameMap<T> | TSortOption[]): this;
|
|
441
|
+
/**
|
|
442
|
+
* Skips the specified number of results.
|
|
443
|
+
* @param skip - The number of results to skip.
|
|
444
|
+
* @returns The current instance for chaining.
|
|
445
|
+
*/
|
|
214
446
|
skip(skip: number): this;
|
|
447
|
+
/**
|
|
448
|
+
* Limits the number of results.
|
|
449
|
+
* @param limit - The maximum number of results to return.
|
|
450
|
+
* @returns The current instance for chaining.
|
|
451
|
+
*/
|
|
215
452
|
limit(limit: number): this;
|
|
453
|
+
/**
|
|
454
|
+
* Performs a nested query on a specific key.
|
|
455
|
+
* @param key - The key to match.
|
|
456
|
+
* @param callback - The callback function to execute.
|
|
457
|
+
* @returns The current instance for chaining.
|
|
458
|
+
*/
|
|
216
459
|
match<T extends string>(key: PathName<T>, callback: (query: TQueryBase) => void): this;
|
|
217
460
|
}
|
|
218
461
|
|
|
462
|
+
/**
|
|
463
|
+
* Options for a query.
|
|
464
|
+
*/
|
|
219
465
|
interface TQueryOptions extends TQueryBaseOptions {
|
|
466
|
+
/**
|
|
467
|
+
* Fields to include in the query.
|
|
468
|
+
*/
|
|
220
469
|
includes?: string[];
|
|
221
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Options for a random query.
|
|
473
|
+
*/
|
|
222
474
|
interface TQueryRandomOptions {
|
|
475
|
+
/**
|
|
476
|
+
* Field to use for weighting the random selection.
|
|
477
|
+
*/
|
|
223
478
|
weight?: string;
|
|
224
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* Abstract base class for queries.
|
|
482
|
+
*/
|
|
225
483
|
declare abstract class TQuery<T extends string, Ext, M extends boolean> extends TQueryBase {
|
|
484
|
+
/**
|
|
485
|
+
* Clones the query with optional new options.
|
|
486
|
+
* @param options - The new options for the query.
|
|
487
|
+
* @returns A new query instance.
|
|
488
|
+
*/
|
|
226
489
|
abstract clone(options?: TQueryOptions): TQuery<T, Ext, M>;
|
|
490
|
+
/**
|
|
491
|
+
* Explains the query execution plan.
|
|
492
|
+
* @param options - Extra options for the query.
|
|
493
|
+
* @returns A promise that resolves to the explanation.
|
|
494
|
+
*/
|
|
227
495
|
abstract explain(options?: ExtraOptions<M>): PromiseLike<any>;
|
|
496
|
+
/**
|
|
497
|
+
* Counts the number of results for the query.
|
|
498
|
+
* @param options - Extra options for the query.
|
|
499
|
+
* @returns A promise that resolves to the count.
|
|
500
|
+
*/
|
|
228
501
|
abstract count(options?: ExtraOptions<M>): PromiseLike<number>;
|
|
502
|
+
/**
|
|
503
|
+
* Finds the results for the query.
|
|
504
|
+
* @param options - Extra options for the query.
|
|
505
|
+
* @returns A stream of the results.
|
|
506
|
+
*/
|
|
229
507
|
abstract find(options?: ExtraOptions<M>): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;
|
|
508
|
+
/**
|
|
509
|
+
* Selects a random result for the query.
|
|
510
|
+
* @param opts - Options for the random selection.
|
|
511
|
+
* @param options - Extra options for the query.
|
|
512
|
+
* @returns A stream of the random result.
|
|
513
|
+
*/
|
|
230
514
|
abstract random(opts?: TQueryRandomOptions, options?: ExtraOptions<M>): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;
|
|
515
|
+
/**
|
|
516
|
+
* Finds non-reference results for the query.
|
|
517
|
+
* @param options - Extra options for the query.
|
|
518
|
+
* @returns A stream of the non-reference results.
|
|
519
|
+
*/
|
|
231
520
|
abstract nonrefs(options?: ExtraOptions<M>): ReturnType<typeof asyncStream<TObjectType<T, Ext>>>;
|
|
521
|
+
/**
|
|
522
|
+
* Inserts a new record.
|
|
523
|
+
* @param attrs - The attributes of the new record.
|
|
524
|
+
* @param options - Extra options for the query.
|
|
525
|
+
* @returns A promise that resolves to the inserted record.
|
|
526
|
+
*/
|
|
232
527
|
abstract insert(attrs: Record<string, TValue>, options?: ExtraOptions<M>): PromiseLike<TObjectType<T, Ext>>;
|
|
528
|
+
/**
|
|
529
|
+
* Inserts multiple new records.
|
|
530
|
+
* @param values - The attributes of the new records.
|
|
531
|
+
* @param options - Extra options for the query.
|
|
532
|
+
* @returns A promise that resolves to the number of inserted records.
|
|
533
|
+
*/
|
|
233
534
|
abstract insertMany(values: Record<string, TValue>[], options?: ExtraOptions<M>): PromiseLike<number>;
|
|
535
|
+
/**
|
|
536
|
+
* Updates a single record.
|
|
537
|
+
* @param update - The update operations.
|
|
538
|
+
* @param options - Extra options for the query.
|
|
539
|
+
* @returns A promise that resolves to the updated record or undefined.
|
|
540
|
+
*/
|
|
234
541
|
abstract updateOne(update: Record<string, TUpdateOp>, options?: ExtraOptions<M>): PromiseLike<TObjectType<T, Ext> | undefined>;
|
|
542
|
+
/**
|
|
543
|
+
* Updates multiple records.
|
|
544
|
+
* @param update - The update operations.
|
|
545
|
+
* @param options - Extra options for the query.
|
|
546
|
+
* @returns A promise that resolves to the number of updated records.
|
|
547
|
+
*/
|
|
235
548
|
abstract updateMany(update: Record<string, TUpdateOp>, options?: ExtraOptions<M>): PromiseLike<number>;
|
|
549
|
+
/**
|
|
550
|
+
* Upserts a single record.
|
|
551
|
+
* @param update - The update operations.
|
|
552
|
+
* @param setOnInsert - The attributes to set on insert.
|
|
553
|
+
* @param options - Extra options for the query.
|
|
554
|
+
* @returns A promise that resolves to the upserted record.
|
|
555
|
+
*/
|
|
236
556
|
abstract upsertOne(update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValue>, options?: ExtraOptions<M>): PromiseLike<TObjectType<T, Ext>>;
|
|
557
|
+
/**
|
|
558
|
+
* Upserts multiple records.
|
|
559
|
+
* @param update - The update operations.
|
|
560
|
+
* @param setOnInsert - The attributes to set on insert.
|
|
561
|
+
* @param options - Extra options for the query.
|
|
562
|
+
* @returns A promise that resolves to the number of upserted records.
|
|
563
|
+
*/
|
|
237
564
|
abstract upsertMany(update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValue>, options?: ExtraOptions<M>): PromiseLike<{
|
|
238
565
|
updated: number;
|
|
239
566
|
inserted: number;
|
|
240
567
|
}>;
|
|
568
|
+
/**
|
|
569
|
+
* Deletes a single record.
|
|
570
|
+
* @param options - Extra options for the query.
|
|
571
|
+
* @returns A promise that resolves to the deleted record or undefined.
|
|
572
|
+
*/
|
|
241
573
|
abstract deleteOne(options?: ExtraOptions<M>): PromiseLike<TObjectType<T, Ext> | undefined>;
|
|
574
|
+
/**
|
|
575
|
+
* Deletes multiple records.
|
|
576
|
+
* @param options - Extra options for the query.
|
|
577
|
+
* @returns A promise that resolves to the number of deleted records.
|
|
578
|
+
*/
|
|
242
579
|
abstract deleteMany(options?: ExtraOptions<M>): PromiseLike<number>;
|
|
580
|
+
/**
|
|
581
|
+
* Adds fields to include in the query.
|
|
582
|
+
* @param includes - The fields to include.
|
|
583
|
+
* @returns The query instance.
|
|
584
|
+
*/
|
|
243
585
|
includes<T extends string[]>(...includes: IncludePaths<T>): this;
|
|
586
|
+
/**
|
|
587
|
+
* Gets a record by its ID.
|
|
588
|
+
* @param id - The ID of the record.
|
|
589
|
+
* @param options - Extra options for the query.
|
|
590
|
+
* @returns A promise that resolves to the record or undefined.
|
|
591
|
+
*/
|
|
244
592
|
get(id: string, options?: ExtraOptions<M>): Promise<TObjectType<T, Ext> | undefined>;
|
|
593
|
+
/**
|
|
594
|
+
* Gets the first record.
|
|
595
|
+
* @param options - Extra options for the query.
|
|
596
|
+
* @returns A promise that resolves to the first record or undefined.
|
|
597
|
+
*/
|
|
245
598
|
first(options?: ExtraOptions<M>): Promise<TObjectType<T, Ext> | undefined>;
|
|
599
|
+
/**
|
|
600
|
+
* Gets a random record.
|
|
601
|
+
* @param opts - Options for the random selection.
|
|
602
|
+
* @param options - Extra options for the query.
|
|
603
|
+
* @returns A promise that resolves to the random record or undefined.
|
|
604
|
+
*/
|
|
246
605
|
randomOne(opts?: TQueryRandomOptions, options?: ExtraOptions<M>): Promise<TObjectType<T, Ext> | undefined>;
|
|
606
|
+
/**
|
|
607
|
+
* Checks if any records exist.
|
|
608
|
+
* @param options - Extra options for the query.
|
|
609
|
+
* @returns A promise that resolves to a boolean indicating if any records exist.
|
|
610
|
+
*/
|
|
247
611
|
exists(options?: ExtraOptions<M>): Promise<boolean>;
|
|
612
|
+
/**
|
|
613
|
+
* Iterates over each batch of records.
|
|
614
|
+
* @param callback - The callback to execute for each batch.
|
|
615
|
+
* @param options - Extra options for the query.
|
|
616
|
+
*/
|
|
248
617
|
eachBatch(callback: (batch: TObjectType<T, Ext>[]) => Awaitable<void>, options?: ExtraOptions<M> & {
|
|
249
618
|
batchSize?: number;
|
|
250
619
|
}): Promise<void>;
|
|
620
|
+
/**
|
|
621
|
+
* Iterates over each record.
|
|
622
|
+
* @param callback - The callback to execute for each record.
|
|
623
|
+
* @param options - Extra options for the query.
|
|
624
|
+
*/
|
|
251
625
|
each(callback: (object: TObjectType<T, Ext>) => Awaitable<void>, options?: ExtraOptions<M> & {
|
|
252
626
|
batchSize?: number;
|
|
253
627
|
}): Promise<void>;
|
|
254
628
|
}
|
|
255
629
|
|
|
630
|
+
type TNumber = number | Decimal | BigInt;
|
|
631
|
+
type TPrimitive = Date | string | TNumber | boolean | null | undefined;
|
|
632
|
+
type TDictionary = {
|
|
633
|
+
[x: string]: TSerializable;
|
|
634
|
+
};
|
|
635
|
+
type TSerializable = TDictionary | TSerializable[] | TPrimitive | TObject;
|
|
636
|
+
type SerializeOptions = {
|
|
637
|
+
space?: string | number;
|
|
638
|
+
objAttrs?: string[];
|
|
639
|
+
};
|
|
640
|
+
type DeserializeOptions = {
|
|
641
|
+
objAttrs?: string[];
|
|
642
|
+
};
|
|
643
|
+
declare const serialize: (x: TSerializable, options?: SerializeOptions) => string;
|
|
644
|
+
declare const deserialize: (buffer: string, options?: DeserializeOptions) => TSerializable;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* A callback function type.
|
|
648
|
+
* @param request - The request object.
|
|
649
|
+
* @returns An awaitable response.
|
|
650
|
+
*/
|
|
256
651
|
type Callback<T, R, E> = (request: ProtoService<E> & T) => Awaitable<R>;
|
|
652
|
+
/**
|
|
653
|
+
* A callback function type.
|
|
654
|
+
* @param request - The request object.
|
|
655
|
+
* @returns An awaitable response.
|
|
656
|
+
*/
|
|
257
657
|
type ProtoFunction<E> = Callback<{
|
|
258
658
|
params: TSerializable;
|
|
259
659
|
}, void | TSerializable, E>;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}, void, E>;
|
|
660
|
+
/**
|
|
661
|
+
* Validator options for proto functions.
|
|
662
|
+
*/
|
|
264
663
|
type Validator = {
|
|
664
|
+
/**
|
|
665
|
+
* Indicates if a user is required.
|
|
666
|
+
*/
|
|
265
667
|
requireUser?: boolean;
|
|
668
|
+
/**
|
|
669
|
+
* Indicates if a master user is required.
|
|
670
|
+
*/
|
|
266
671
|
requireMaster?: boolean;
|
|
672
|
+
/**
|
|
673
|
+
* Indicates if any user roles are required.
|
|
674
|
+
*/
|
|
267
675
|
requireAnyUserRoles?: string[];
|
|
676
|
+
/**
|
|
677
|
+
* Indicates if all user roles are required.
|
|
678
|
+
*/
|
|
268
679
|
requireAllUserRoles?: string[];
|
|
269
680
|
};
|
|
681
|
+
/**
|
|
682
|
+
* Options for configuring a proto function.
|
|
683
|
+
*/
|
|
270
684
|
type ProtoFunctionOptions<E> = {
|
|
685
|
+
/**
|
|
686
|
+
* The callback function for the proto function.
|
|
687
|
+
*/
|
|
271
688
|
callback: ProtoFunction<E>;
|
|
689
|
+
/**
|
|
690
|
+
* Optional validator for the proto function.
|
|
691
|
+
*/
|
|
272
692
|
validator?: Validator;
|
|
273
693
|
};
|
|
274
694
|
|
|
@@ -278,135 +698,489 @@ type Session = jwt.JwtPayload & {
|
|
|
278
698
|
loginedAt: Date;
|
|
279
699
|
};
|
|
280
700
|
|
|
701
|
+
/**
|
|
702
|
+
* The mode of the transaction.
|
|
703
|
+
*/
|
|
281
704
|
type TransactionMode = 'default' | 'committed' | 'repeatable' | 'serializable';
|
|
705
|
+
/**
|
|
706
|
+
* Options for configuring a transaction.
|
|
707
|
+
*/
|
|
282
708
|
type TransactionOptions = {
|
|
709
|
+
/**
|
|
710
|
+
* The mode of the transaction.
|
|
711
|
+
*/
|
|
283
712
|
mode?: TransactionMode;
|
|
713
|
+
/**
|
|
714
|
+
* The number of retries or a boolean indicating whether to retry.
|
|
715
|
+
*/
|
|
284
716
|
retry?: number | boolean;
|
|
285
717
|
};
|
|
718
|
+
/**
|
|
719
|
+
* Represents event data with additional metadata.
|
|
720
|
+
*/
|
|
286
721
|
type EventData = Record<string, _TValue> & {
|
|
722
|
+
/**
|
|
723
|
+
* The unique identifier for the event.
|
|
724
|
+
*/
|
|
287
725
|
_id: string;
|
|
726
|
+
/**
|
|
727
|
+
* The creation date of the event.
|
|
728
|
+
*/
|
|
288
729
|
_created_at: Date;
|
|
730
|
+
/**
|
|
731
|
+
* The read permissions for the event.
|
|
732
|
+
*/
|
|
289
733
|
_rperm: string[];
|
|
290
734
|
};
|
|
291
735
|
declare abstract class ProtoType<Ext> {
|
|
736
|
+
/**
|
|
737
|
+
* Retrieves the configuration.
|
|
738
|
+
* @param options - Optional settings for retrieving the configuration.
|
|
739
|
+
* @returns A promise that resolves to the configuration.
|
|
740
|
+
*/
|
|
292
741
|
abstract config(options?: {
|
|
293
742
|
master?: boolean;
|
|
294
743
|
}): Promise<Record<string, _TValue>>;
|
|
744
|
+
/**
|
|
745
|
+
* Retrieves the ACL of configuration.
|
|
746
|
+
* @param options - Settings for retrieving the ACL of configuration.
|
|
747
|
+
* @returns A promise that resolves to the ACL of configuration.
|
|
748
|
+
*/
|
|
295
749
|
abstract configAcl(options: {
|
|
296
750
|
master: true;
|
|
297
751
|
}): PromiseLike<Record<string, string[]>>;
|
|
752
|
+
/**
|
|
753
|
+
* Sets the configuration.
|
|
754
|
+
* @param values - The configuration values to set.
|
|
755
|
+
* @param options - Settings for setting the configuration.
|
|
756
|
+
* @returns A promise that resolves when the configuration is set.
|
|
757
|
+
*/
|
|
298
758
|
abstract setConfig(values: Record<string, _TValue>, options: {
|
|
299
759
|
master: true;
|
|
300
760
|
acl?: string[];
|
|
301
761
|
}): Promise<void>;
|
|
762
|
+
/**
|
|
763
|
+
* Runs a function.
|
|
764
|
+
* @param name - The name of the function to run.
|
|
765
|
+
* @param data - The data to pass to the function.
|
|
766
|
+
* @param options - Additional options for running the function.
|
|
767
|
+
* @returns A promise that resolves to the result of the function.
|
|
768
|
+
*/
|
|
302
769
|
abstract run(name: string, data?: TSerializable, options?: ExtraOptions<boolean>): Promise<void | TSerializable>;
|
|
770
|
+
/**
|
|
771
|
+
* Creates a query.
|
|
772
|
+
* @param className - The name of the class to query.
|
|
773
|
+
* @returns A query instance.
|
|
774
|
+
*/
|
|
303
775
|
abstract Query<T extends string>(className: T): TQuery<T, Ext, boolean>;
|
|
776
|
+
/**
|
|
777
|
+
* Creates a relation query.
|
|
778
|
+
* @param object - The object to create the relation for.
|
|
779
|
+
* @param key - The key of the relation.
|
|
780
|
+
* @returns A relation query instance.
|
|
781
|
+
*/
|
|
304
782
|
abstract Relation<T extends string>(object: TObject, key: PathName<T>): TQuery<string, Ext, boolean>;
|
|
783
|
+
/**
|
|
784
|
+
* Get all references to an object.
|
|
785
|
+
* @param object - The object to get references for.
|
|
786
|
+
* @param options - Additional options for getting references.
|
|
787
|
+
* @returns A stream of references.
|
|
788
|
+
*/
|
|
305
789
|
abstract refs(object: TObject, options?: ExtraOptions<boolean>): ReturnType<typeof asyncStream<TObjectType<string, Ext>>>;
|
|
790
|
+
/**
|
|
791
|
+
* Checks if the server is online.
|
|
792
|
+
* @returns A promise that resolves to a boolean indicating if the server is online.
|
|
793
|
+
*/
|
|
306
794
|
online(): Promise<boolean>;
|
|
795
|
+
/**
|
|
796
|
+
* Rebinds an object to the proto instance.
|
|
797
|
+
* @param object - The object to rebind.
|
|
798
|
+
* @returns The rebinded object.
|
|
799
|
+
*/
|
|
307
800
|
rebind<T extends TSerializable | undefined>(object: T): T;
|
|
801
|
+
/**
|
|
802
|
+
* Creates a new object.
|
|
803
|
+
* @param className - The name of the class to create.
|
|
804
|
+
* @param objectId - The ID of the object to create.
|
|
805
|
+
* @returns The created object.
|
|
806
|
+
*/
|
|
308
807
|
Object<T extends string>(className: T, objectId?: string): TObjectType<T, Ext>;
|
|
808
|
+
/**
|
|
809
|
+
* Creates a new file object.
|
|
810
|
+
* @param filename - The name of the file.
|
|
811
|
+
* @param data - The file data.
|
|
812
|
+
* @param type - The type of the file.
|
|
813
|
+
* @returns The created file object.
|
|
814
|
+
*/
|
|
309
815
|
File(filename: string, data: FileData, type?: string): TObjectType<"File", Ext>;
|
|
816
|
+
/**
|
|
817
|
+
* Notifies an event.
|
|
818
|
+
* @param data - The data to notify.
|
|
819
|
+
* @param options - Additional options for notifying the event.
|
|
820
|
+
*/
|
|
310
821
|
abstract notify(data: Record<string, _TValue> & {
|
|
311
822
|
_rperm?: string[];
|
|
312
823
|
}, options?: ExtraOptions<boolean>): Promise<void>;
|
|
824
|
+
/**
|
|
825
|
+
* Listens for events.
|
|
826
|
+
* @param callback - The callback to call when an event occurs.
|
|
827
|
+
* @returns An object with a remove function to stop listening.
|
|
828
|
+
*/
|
|
313
829
|
abstract listen(callback: (data: EventData) => void): {
|
|
314
830
|
remove: VoidFunction;
|
|
315
831
|
socket?: Socket;
|
|
316
832
|
};
|
|
317
833
|
}
|
|
318
834
|
interface ProtoType<Ext> {
|
|
835
|
+
/**
|
|
836
|
+
* Connects a request with optional attributes.
|
|
837
|
+
* @param req - The request to connect.
|
|
838
|
+
* @param attrs - Optional attributes or a function returning attributes.
|
|
839
|
+
* @returns The instance with the request and attributes.
|
|
840
|
+
*/
|
|
319
841
|
connect<R extends Request, T extends object>(req: R, attrs?: T | ((x: this & {
|
|
320
842
|
req: R;
|
|
321
843
|
}) => T)): this & {
|
|
322
844
|
req: R;
|
|
323
845
|
} & T;
|
|
846
|
+
/**
|
|
847
|
+
* Connects using a session token with optional attributes.
|
|
848
|
+
* @param token - The session token.
|
|
849
|
+
* @param attrs - Optional attributes or a function returning attributes.
|
|
850
|
+
* @returns A promise resolving to the instance with the session and attributes.
|
|
851
|
+
*/
|
|
324
852
|
connectWithSessionToken<T extends object>(token: string, attrs?: T | ((x: this & {
|
|
325
853
|
session?: Session;
|
|
326
854
|
}) => T)): Promise<this & {
|
|
327
855
|
session?: Session;
|
|
328
856
|
} & T>;
|
|
857
|
+
/**
|
|
858
|
+
* Sets the session token.
|
|
859
|
+
* @param token - The session token.
|
|
860
|
+
*/
|
|
329
861
|
setSessionToken(token?: string): void;
|
|
862
|
+
/**
|
|
863
|
+
* Retrieves the roles of a user.
|
|
864
|
+
* @param user - The user whose roles are to be retrieved.
|
|
865
|
+
* @returns A promise resolving to an array of roles.
|
|
866
|
+
*/
|
|
330
867
|
userRoles(user: TUser): Promise<TRole[]>;
|
|
868
|
+
/**
|
|
869
|
+
* Becomes a specified user.
|
|
870
|
+
* @param req - The request.
|
|
871
|
+
* @param user - The user to become.
|
|
872
|
+
* @param options - Optional cookie and JWT sign options.
|
|
873
|
+
* @returns A promise resolving to void.
|
|
874
|
+
*/
|
|
331
875
|
becomeUser(req: Request, user: TUser, options?: {
|
|
332
876
|
cookieOptions?: CookieOptions | undefined;
|
|
333
877
|
jwtSignOptions?: SignOptions | undefined;
|
|
334
878
|
}): Promise<void>;
|
|
879
|
+
/**
|
|
880
|
+
* Logs out a user.
|
|
881
|
+
* @param req - The request.
|
|
882
|
+
* @param options - Optional cookie and JWT sign options.
|
|
883
|
+
* @returns A promise resolving to void.
|
|
884
|
+
*/
|
|
335
885
|
logoutUser(req: Request, options?: {
|
|
336
886
|
cookieOptions?: CookieOptions | undefined;
|
|
337
887
|
jwtSignOptions?: SignOptions | undefined;
|
|
338
888
|
}): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Verifies a user's password.
|
|
891
|
+
* @param user - The user whose password is to be verified.
|
|
892
|
+
* @param password - The password to verify.
|
|
893
|
+
* @param options - Extra options.
|
|
894
|
+
* @returns A promise resolving to a boolean indicating if the password is correct.
|
|
895
|
+
*/
|
|
339
896
|
varifyPassword(user: TUser, password: string, options: ExtraOptions<true>): Promise<boolean>;
|
|
897
|
+
/**
|
|
898
|
+
* Sets a user's password.
|
|
899
|
+
* @param user - The user whose password is to be set.
|
|
900
|
+
* @param password - The new password.
|
|
901
|
+
* @param options - Extra options.
|
|
902
|
+
* @returns A promise resolving to void.
|
|
903
|
+
*/
|
|
340
904
|
setPassword(user: TUser, password: string, options: ExtraOptions<true>): Promise<void>;
|
|
905
|
+
/**
|
|
906
|
+
* Unsets a user's password.
|
|
907
|
+
* @param user - The user whose password is to be unset.
|
|
908
|
+
* @param options - Extra options.
|
|
909
|
+
* @returns A promise resolving to void.
|
|
910
|
+
*/
|
|
341
911
|
unsetPassword(user: TUser, options: ExtraOptions<true>): Promise<void>;
|
|
912
|
+
/**
|
|
913
|
+
* Defines a new function.
|
|
914
|
+
* @param name - The name of the function.
|
|
915
|
+
* @param callback - The function callback.
|
|
916
|
+
* @param options - Optional function options excluding the callback.
|
|
917
|
+
*/
|
|
342
918
|
define(name: string, callback: ProtoFunction<Ext>, options?: Omit<ProtoFunctionOptions<Ext>, 'callback'>): void;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
919
|
+
/**
|
|
920
|
+
* Locks a table for updates.
|
|
921
|
+
* @param className - The name of the class or an array of class names.
|
|
922
|
+
* @param update - Whether to lock for update.
|
|
923
|
+
*/
|
|
347
924
|
lockTable(className: string | string[], update: boolean): void;
|
|
925
|
+
/**
|
|
926
|
+
* Executes a callback within a transaction.
|
|
927
|
+
* @param callback - The callback to execute.
|
|
928
|
+
* @param options - Optional transaction options.
|
|
929
|
+
*/
|
|
348
930
|
withTransaction<T>(callback: (connection: ProtoType<Ext>) => PromiseLike<T>, options?: TransactionOptions): void;
|
|
931
|
+
/**
|
|
932
|
+
* Generates an upload token.
|
|
933
|
+
* @param options - Optional settings for the upload token.
|
|
934
|
+
* @returns The generated upload token.
|
|
935
|
+
*/
|
|
349
936
|
generateUploadToken(options?: {
|
|
350
937
|
maxUploadSize?: number;
|
|
351
938
|
}): string;
|
|
939
|
+
/**
|
|
940
|
+
* Signs a JWT.
|
|
941
|
+
* @param payload - The payload to sign.
|
|
942
|
+
* @param options - Options for signing the JWT.
|
|
943
|
+
* @returns The signed JWT.
|
|
944
|
+
*/
|
|
352
945
|
jwtSign(payload: any, options: jwt.SignOptions): string;
|
|
946
|
+
/**
|
|
947
|
+
* Verifies a JWT.
|
|
948
|
+
* @param token - The token to verify.
|
|
949
|
+
* @param options - Options for verifying the JWT.
|
|
950
|
+
* @returns The decoded JWT payload or undefined if verification fails.
|
|
951
|
+
*/
|
|
353
952
|
jwtVarify(token: string, options?: jwt.VerifyOptions): jwt.JwtPayload | undefined;
|
|
354
953
|
}
|
|
355
954
|
|
|
356
|
-
|
|
955
|
+
/**
|
|
956
|
+
* Represents additional options that can be passed to certain methods.
|
|
957
|
+
*/
|
|
357
958
|
type ExtraOptions<M extends boolean> = {
|
|
959
|
+
/**
|
|
960
|
+
* Indicates whether the master option is enabled.
|
|
961
|
+
*/
|
|
358
962
|
master?: M;
|
|
359
|
-
|
|
360
|
-
|
|
963
|
+
/**
|
|
964
|
+
* The session associated with the operation.
|
|
965
|
+
*/
|
|
361
966
|
session?: ProtoType<any>;
|
|
967
|
+
/**
|
|
968
|
+
* An AbortSignal object that can be used to abort the operation.
|
|
969
|
+
*/
|
|
362
970
|
abortSignal?: AbortSignal;
|
|
363
971
|
};
|
|
364
972
|
|
|
973
|
+
/**
|
|
974
|
+
* Interface representing a object.
|
|
975
|
+
*/
|
|
365
976
|
interface TObject {
|
|
977
|
+
/**
|
|
978
|
+
* Clones the object.
|
|
979
|
+
* @returns A clone of the object.
|
|
980
|
+
*/
|
|
366
981
|
clone(): TObject;
|
|
982
|
+
/**
|
|
983
|
+
* Gets a relation query for the specified key.
|
|
984
|
+
* @param key - The key of the relation.
|
|
985
|
+
* @returns A query object for the relation.
|
|
986
|
+
*/
|
|
367
987
|
relation<T extends string>(key: PathName<T>): TQuery<string, any, boolean>;
|
|
988
|
+
/**
|
|
989
|
+
* Fetches the object with the specified keys included.
|
|
990
|
+
* @param keys - The keys to include.
|
|
991
|
+
* @param options - Additional options for the fetch operation.
|
|
992
|
+
* @returns A promise that resolves to the fetched object.
|
|
993
|
+
*/
|
|
368
994
|
fetchWithInclude(keys: string[], options?: ExtraOptions<boolean>): PromiseLike<this>;
|
|
995
|
+
/**
|
|
996
|
+
* Saves the object.
|
|
997
|
+
* @param options - Additional options for the save operation.
|
|
998
|
+
* @returns A promise that resolves to the saved object.
|
|
999
|
+
*/
|
|
369
1000
|
save(options?: ExtraOptions<boolean> & {
|
|
370
1001
|
cascadeSave?: boolean;
|
|
371
1002
|
}): PromiseLike<this>;
|
|
1003
|
+
/**
|
|
1004
|
+
* Destroys the object.
|
|
1005
|
+
* @param options - Additional options for the destroy operation.
|
|
1006
|
+
* @returns A promise that resolves to the destroyed object.
|
|
1007
|
+
*/
|
|
372
1008
|
destroy(options?: ExtraOptions<boolean>): PromiseLike<this>;
|
|
373
1009
|
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Class representing a object.
|
|
1012
|
+
*/
|
|
374
1013
|
declare class TObject {
|
|
375
1014
|
static defaultReadonlyKeys: string[];
|
|
376
1015
|
static defaultKeys: string[];
|
|
377
1016
|
constructor(className: string, attributes?: Record<string, TValue> | ((self: TObject) => Record<string, TValue>));
|
|
1017
|
+
/**
|
|
1018
|
+
* Gets the class name of the object.
|
|
1019
|
+
*/
|
|
378
1020
|
get className(): string;
|
|
1021
|
+
/**
|
|
1022
|
+
* Gets the attributes of the object.
|
|
1023
|
+
*/
|
|
379
1024
|
get attributes(): Record<string, TValue>;
|
|
1025
|
+
/**
|
|
1026
|
+
* Gets the object ID.
|
|
1027
|
+
*/
|
|
380
1028
|
get objectId(): string | undefined;
|
|
1029
|
+
/**
|
|
1030
|
+
* Gets the creation date of the object.
|
|
1031
|
+
*/
|
|
381
1032
|
get createdAt(): Date | undefined;
|
|
1033
|
+
/**
|
|
1034
|
+
* Gets the last updated date of the object.
|
|
1035
|
+
*/
|
|
382
1036
|
get updatedAt(): Date | undefined;
|
|
1037
|
+
/**
|
|
1038
|
+
* Gets the version number of the object.
|
|
1039
|
+
*/
|
|
383
1040
|
get __v(): number;
|
|
1041
|
+
/**
|
|
1042
|
+
* Gets the sequence number of the object.
|
|
1043
|
+
*/
|
|
384
1044
|
get __i(): number;
|
|
1045
|
+
/**
|
|
1046
|
+
* Gets the expiration date of the object.
|
|
1047
|
+
*/
|
|
385
1048
|
get expiredAt(): Date | undefined;
|
|
1049
|
+
/**
|
|
1050
|
+
* Sets the expiration date of the object.
|
|
1051
|
+
* @param value - The expiration date.
|
|
1052
|
+
*/
|
|
386
1053
|
set expiredAt(value: Date | undefined);
|
|
1054
|
+
/**
|
|
1055
|
+
* Gets the access control list (ACL) of the object.
|
|
1056
|
+
* @returns The ACL of the object.
|
|
1057
|
+
*/
|
|
387
1058
|
acl(): TSchema.ACLs;
|
|
1059
|
+
/**
|
|
1060
|
+
* Sets the access control list (ACL) of the object.
|
|
1061
|
+
* @param value - The ACL to set.
|
|
1062
|
+
*/
|
|
388
1063
|
setAcl(value: Partial<TSchema.ACLs>): void;
|
|
1064
|
+
/**
|
|
1065
|
+
* Sets the read access control list (ACL) of the object.
|
|
1066
|
+
* @param value - The read ACL to set.
|
|
1067
|
+
*/
|
|
389
1068
|
setReadAcl(value: TSchema.ACL): void;
|
|
1069
|
+
/**
|
|
1070
|
+
* Sets the write access control list (ACL) of the object.
|
|
1071
|
+
* @param value - The write ACL to set.
|
|
1072
|
+
*/
|
|
390
1073
|
setWriteAcl(value: TSchema.ACL): void;
|
|
1074
|
+
/**
|
|
1075
|
+
* Gets the keys of the object's attributes and mutated attributes.
|
|
1076
|
+
* @returns An array of keys.
|
|
1077
|
+
*/
|
|
391
1078
|
keys(): string[];
|
|
1079
|
+
/**
|
|
1080
|
+
* Gets an iterator for the entries of the object's attributes.
|
|
1081
|
+
* @returns An iterator for the entries.
|
|
1082
|
+
*/
|
|
392
1083
|
entries(): Generator<[string, any], void, unknown>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Converts the object to a plain object.
|
|
1086
|
+
* @returns The plain object representation of the object.
|
|
1087
|
+
*/
|
|
393
1088
|
toObject(): _.Dictionary<_TValue>;
|
|
394
1089
|
private _value;
|
|
1090
|
+
/**
|
|
1091
|
+
* Get the value of the attribute.
|
|
1092
|
+
* @param key - The key of the attribute.
|
|
1093
|
+
* @returns The value of the attribute.
|
|
1094
|
+
*/
|
|
395
1095
|
get<T extends string>(key: PathName<T>): any;
|
|
1096
|
+
/**
|
|
1097
|
+
* Set the value of the attribute.
|
|
1098
|
+
* @param key - The key of the attribute.
|
|
1099
|
+
* @param value - The value to set.
|
|
1100
|
+
*/
|
|
396
1101
|
set<T extends string>(key: PathName<T>, value: TValue | undefined): void;
|
|
1102
|
+
/**
|
|
1103
|
+
* Is the object dirty.
|
|
1104
|
+
*/
|
|
397
1105
|
get isDirty(): boolean;
|
|
1106
|
+
/**
|
|
1107
|
+
* Increment the value of the attribute.
|
|
1108
|
+
* @param key - The key to increment.
|
|
1109
|
+
* @param value - The value to increment by.
|
|
1110
|
+
*/
|
|
398
1111
|
increment<T extends string>(key: PathName<T>, value: number): void;
|
|
1112
|
+
/**
|
|
1113
|
+
* Decrement the value of the attribute.
|
|
1114
|
+
* @param key - The key to decrement.
|
|
1115
|
+
* @param value - The value to decrement by.
|
|
1116
|
+
*/
|
|
399
1117
|
decrement<T extends string>(key: PathName<T>, value: number): void;
|
|
1118
|
+
/**
|
|
1119
|
+
* Multiplies the value of the specified attribute.
|
|
1120
|
+
* @param key - The key of the attribute to multiply.
|
|
1121
|
+
* @param value - The multiplier value.
|
|
1122
|
+
*/
|
|
400
1123
|
multiply<T extends string>(key: PathName<T>, value: number): void;
|
|
1124
|
+
/**
|
|
1125
|
+
* Divides the value of the specified attribute.
|
|
1126
|
+
* @param key - The key of the attribute to divide.
|
|
1127
|
+
* @param value - The divisor value.
|
|
1128
|
+
*/
|
|
401
1129
|
divide<T extends string>(key: PathName<T>, value: number): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Sets the value of the specified attribute to the maximum of the current value and the provided value.
|
|
1132
|
+
* @param key - The key of the attribute to compare.
|
|
1133
|
+
* @param value - The value to compare against.
|
|
1134
|
+
*/
|
|
402
1135
|
max<T extends string>(key: PathName<T>, value: TValue): void;
|
|
1136
|
+
/**
|
|
1137
|
+
* Sets the value of the specified attribute to the minimum of the current value and the provided value.
|
|
1138
|
+
* @param key - The key of the attribute to compare.
|
|
1139
|
+
* @param value - The value to compare against.
|
|
1140
|
+
*/
|
|
403
1141
|
min<T extends string>(key: PathName<T>, value: TValue): void;
|
|
1142
|
+
/**
|
|
1143
|
+
* Adds the specified values to the set of the specified attribute.
|
|
1144
|
+
* @param key - The key of the attribute.
|
|
1145
|
+
* @param values - The values to add to the set.
|
|
1146
|
+
*/
|
|
404
1147
|
addToSet<T extends string>(key: PathName<T>, values: TValue[]): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* Adds the values to the array of the attribute.
|
|
1150
|
+
* @param key - The key of the attribute.
|
|
1151
|
+
* @param values - The values to add.
|
|
1152
|
+
*/
|
|
405
1153
|
push<T extends string>(key: PathName<T>, values: TValue[]): void;
|
|
1154
|
+
/**
|
|
1155
|
+
* Removes the values from the array of the attribute.
|
|
1156
|
+
* @param key - The key of the attribute.
|
|
1157
|
+
* @param values - The values to remove.
|
|
1158
|
+
*/
|
|
406
1159
|
removeAll<T extends string>(key: PathName<T>, values: TValue[]): void;
|
|
1160
|
+
/**
|
|
1161
|
+
* Removes the first elements from the array of the attribute.
|
|
1162
|
+
* @param key - The key of the attribute.
|
|
1163
|
+
* @param count - The number of elements to remove. Defaults to 1.
|
|
1164
|
+
*/
|
|
407
1165
|
popFirst<T extends string>(key: PathName<T>, count?: number): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* Removes the last elements from the array of the attribute.
|
|
1168
|
+
* @param key - The key of the attribute.
|
|
1169
|
+
* @param count - The number of elements to remove. Defaults to 1.
|
|
1170
|
+
*/
|
|
408
1171
|
popLast<T extends string>(key: PathName<T>, count?: number): void;
|
|
1172
|
+
/**
|
|
1173
|
+
* Fetches the object data.
|
|
1174
|
+
* @param options - Additional options for the fetch operation.
|
|
1175
|
+
* @returns A promise that resolves to the fetched object.
|
|
1176
|
+
*/
|
|
409
1177
|
fetch(options?: ExtraOptions<boolean>): Promise<this>;
|
|
1178
|
+
/**
|
|
1179
|
+
* Fetches the object data if needed.
|
|
1180
|
+
* @param keys - The keys of the attributes to fetch.
|
|
1181
|
+
* @param options - Additional options for the fetch operation.
|
|
1182
|
+
* @returns A promise that resolves to the fetched object.
|
|
1183
|
+
*/
|
|
410
1184
|
fetchIfNeeded(keys: string[], options?: ExtraOptions<boolean>): Promise<this>;
|
|
411
1185
|
}
|
|
412
1186
|
|
|
@@ -425,79 +1199,256 @@ type ExactOneProp<T> = {
|
|
|
425
1199
|
}[keyof T];
|
|
426
1200
|
|
|
427
1201
|
declare namespace TSchema {
|
|
1202
|
+
/**
|
|
1203
|
+
* Access Control List represented as an array of strings.
|
|
1204
|
+
*/
|
|
428
1205
|
type ACL = string[];
|
|
1206
|
+
/**
|
|
1207
|
+
* Access Control Lists for read and update operations.
|
|
1208
|
+
*/
|
|
429
1209
|
type ACLs = {
|
|
1210
|
+
/**
|
|
1211
|
+
* ACL for read operation.
|
|
1212
|
+
*/
|
|
430
1213
|
read: TSchema.ACL;
|
|
1214
|
+
/**
|
|
1215
|
+
* ACL for update operation.
|
|
1216
|
+
*/
|
|
431
1217
|
update: TSchema.ACL;
|
|
432
1218
|
};
|
|
1219
|
+
/**
|
|
1220
|
+
* Primitive data types.
|
|
1221
|
+
*/
|
|
433
1222
|
type Primitive = 'boolean' | 'number' | 'decimal' | 'string' | 'date' | 'object' | 'array';
|
|
1223
|
+
/**
|
|
1224
|
+
* Primitive type with an optional default value.
|
|
1225
|
+
*/
|
|
434
1226
|
type PrimitiveType = Primitive | {
|
|
1227
|
+
/**
|
|
1228
|
+
* The type of the primitive.
|
|
1229
|
+
*/
|
|
435
1230
|
type: Primitive;
|
|
1231
|
+
/**
|
|
1232
|
+
* Optional default value.
|
|
1233
|
+
*/
|
|
436
1234
|
default?: _TValue;
|
|
437
1235
|
};
|
|
1236
|
+
/**
|
|
1237
|
+
* Vector type with a specified dimension and an optional default value.
|
|
1238
|
+
*/
|
|
438
1239
|
type VectorType = {
|
|
1240
|
+
/**
|
|
1241
|
+
* The type of the vector.
|
|
1242
|
+
*/
|
|
439
1243
|
type: 'vector';
|
|
1244
|
+
/**
|
|
1245
|
+
* The dimension of the vector.
|
|
1246
|
+
*/
|
|
440
1247
|
dimension: number;
|
|
1248
|
+
/**
|
|
1249
|
+
* Optional default value.
|
|
1250
|
+
*/
|
|
441
1251
|
default?: number[];
|
|
442
1252
|
};
|
|
1253
|
+
/**
|
|
1254
|
+
* Shape type with a specified shape.
|
|
1255
|
+
*/
|
|
443
1256
|
type ShapeType = {
|
|
1257
|
+
/**
|
|
1258
|
+
* The type of the shape.
|
|
1259
|
+
*/
|
|
444
1260
|
type: 'shape';
|
|
1261
|
+
/**
|
|
1262
|
+
* The shape definition.
|
|
1263
|
+
*/
|
|
445
1264
|
shape: Record<string, DataType>;
|
|
446
1265
|
};
|
|
447
|
-
|
|
1266
|
+
/**
|
|
1267
|
+
* Pointer type with a target.
|
|
1268
|
+
*/
|
|
448
1269
|
type PointerType = {
|
|
1270
|
+
/**
|
|
1271
|
+
* The type of the pointer.
|
|
1272
|
+
*/
|
|
449
1273
|
type: 'pointer';
|
|
1274
|
+
/**
|
|
1275
|
+
* The target class of the pointer.
|
|
1276
|
+
*/
|
|
450
1277
|
target: string;
|
|
451
1278
|
};
|
|
1279
|
+
/**
|
|
1280
|
+
* Relation type with a target and an optional foreign field.
|
|
1281
|
+
*/
|
|
452
1282
|
type RelationType = {
|
|
1283
|
+
/**
|
|
1284
|
+
* The type of the relation.
|
|
1285
|
+
*/
|
|
453
1286
|
type: 'relation';
|
|
1287
|
+
/**
|
|
1288
|
+
* The target class of the relation.
|
|
1289
|
+
*/
|
|
454
1290
|
target: string;
|
|
1291
|
+
/**
|
|
1292
|
+
* Optional foreign field.
|
|
1293
|
+
*/
|
|
455
1294
|
foreignField?: string;
|
|
456
1295
|
};
|
|
1296
|
+
/**
|
|
1297
|
+
* Data type which can be a primitive, vector, shape, pointer, or relation type.
|
|
1298
|
+
*/
|
|
457
1299
|
type DataType = PrimitiveType | VectorType | ShapeType | PointerType | RelationType;
|
|
1300
|
+
/**
|
|
1301
|
+
* Class Level Permissions.
|
|
1302
|
+
*/
|
|
458
1303
|
type CLPs = {
|
|
1304
|
+
/**
|
|
1305
|
+
* ACL for get operation.
|
|
1306
|
+
*/
|
|
459
1307
|
get?: TSchema.ACL;
|
|
1308
|
+
/**
|
|
1309
|
+
* ACL for find operation.
|
|
1310
|
+
*/
|
|
460
1311
|
find?: TSchema.ACL;
|
|
1312
|
+
/**
|
|
1313
|
+
* ACL for count operation.
|
|
1314
|
+
*/
|
|
461
1315
|
count?: TSchema.ACL;
|
|
1316
|
+
/**
|
|
1317
|
+
* ACL for create operation.
|
|
1318
|
+
*/
|
|
462
1319
|
create?: TSchema.ACL;
|
|
1320
|
+
/**
|
|
1321
|
+
* ACL for update operation.
|
|
1322
|
+
*/
|
|
463
1323
|
update?: TSchema.ACL;
|
|
1324
|
+
/**
|
|
1325
|
+
* ACL for delete operation.
|
|
1326
|
+
*/
|
|
464
1327
|
delete?: TSchema.ACL;
|
|
465
1328
|
};
|
|
1329
|
+
/**
|
|
1330
|
+
* Field Level Permissions.
|
|
1331
|
+
*/
|
|
466
1332
|
type FLPs = {
|
|
1333
|
+
/**
|
|
1334
|
+
* ACL for read operation.
|
|
1335
|
+
*/
|
|
467
1336
|
read?: TSchema.ACL;
|
|
1337
|
+
/**
|
|
1338
|
+
* ACL for create operation.
|
|
1339
|
+
*/
|
|
468
1340
|
create?: TSchema.ACL;
|
|
1341
|
+
/**
|
|
1342
|
+
* ACL for update operation.
|
|
1343
|
+
*/
|
|
469
1344
|
update?: TSchema.ACL;
|
|
470
1345
|
};
|
|
1346
|
+
/**
|
|
1347
|
+
* Indexes for the schema.
|
|
1348
|
+
*/
|
|
471
1349
|
type Indexes = {
|
|
1350
|
+
/**
|
|
1351
|
+
* Type of the index, default is 'basic'.
|
|
1352
|
+
*/
|
|
472
1353
|
type?: 'basic';
|
|
1354
|
+
/**
|
|
1355
|
+
* Keys for the index.
|
|
1356
|
+
*/
|
|
473
1357
|
keys: Record<string, 1 | -1>;
|
|
1358
|
+
/**
|
|
1359
|
+
* Whether the index is unique.
|
|
1360
|
+
*/
|
|
474
1361
|
unique?: boolean;
|
|
475
1362
|
} | {
|
|
1363
|
+
/**
|
|
1364
|
+
* Type of the index, must be 'vector'.
|
|
1365
|
+
*/
|
|
476
1366
|
type: 'vector';
|
|
1367
|
+
/**
|
|
1368
|
+
* Keys for the vector index.
|
|
1369
|
+
*/
|
|
477
1370
|
keys: string | string[];
|
|
1371
|
+
/**
|
|
1372
|
+
* Method for the vector index.
|
|
1373
|
+
*/
|
|
478
1374
|
method?: 'hnsw' | 'ivfflat';
|
|
479
1375
|
};
|
|
480
1376
|
}
|
|
481
1377
|
interface TSchema {
|
|
1378
|
+
/**
|
|
1379
|
+
* Fields of the schema, where each field is a data type.
|
|
1380
|
+
*/
|
|
482
1381
|
fields: Record<string, TSchema.DataType>;
|
|
1382
|
+
/**
|
|
1383
|
+
* Class level permissions for the schema.
|
|
1384
|
+
*/
|
|
483
1385
|
classLevelPermissions?: TSchema.CLPs;
|
|
1386
|
+
/**
|
|
1387
|
+
* Additional object permissions for the schema.
|
|
1388
|
+
*/
|
|
484
1389
|
additionalObjectPermissions?: TSchema.ACLs;
|
|
1390
|
+
/**
|
|
1391
|
+
* Field level permissions for the schema, where each field can have its own permissions.
|
|
1392
|
+
*/
|
|
485
1393
|
fieldLevelPermissions?: Record<string, TSchema.FLPs>;
|
|
1394
|
+
/**
|
|
1395
|
+
* Secure fields in the schema.
|
|
1396
|
+
*/
|
|
486
1397
|
secureFields?: string[];
|
|
1398
|
+
/**
|
|
1399
|
+
* Indexes for the schema.
|
|
1400
|
+
*/
|
|
487
1401
|
indexes?: TSchema.Indexes[];
|
|
488
1402
|
}
|
|
489
1403
|
|
|
1404
|
+
/**
|
|
1405
|
+
* Represents file information.
|
|
1406
|
+
*/
|
|
490
1407
|
type TFileInfo = {
|
|
1408
|
+
/**
|
|
1409
|
+
* The MIME type of the file.
|
|
1410
|
+
*/
|
|
491
1411
|
mimeType?: string;
|
|
1412
|
+
/**
|
|
1413
|
+
* The filename.
|
|
1414
|
+
*/
|
|
492
1415
|
filename?: string;
|
|
493
1416
|
};
|
|
1417
|
+
/**
|
|
1418
|
+
* Interface for file storage operations.
|
|
1419
|
+
*/
|
|
494
1420
|
interface TFileStorage {
|
|
1421
|
+
/**
|
|
1422
|
+
* The schema definition for the file storage.
|
|
1423
|
+
*/
|
|
495
1424
|
schema: Record<string, TSchema>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Creates a new file in the storage.
|
|
1427
|
+
* @param proto - The ProtoService instance.
|
|
1428
|
+
* @param stream - The binary data stream or async iterable of binary data.
|
|
1429
|
+
* @param info - The file information.
|
|
1430
|
+
* @param maxUploadSize - The maximum upload size.
|
|
1431
|
+
* @returns A promise that resolves to an object containing the file ID and size.
|
|
1432
|
+
*/
|
|
496
1433
|
create<E>(proto: ProtoService<E>, stream: BinaryData | AsyncIterable<BinaryData>, info: TFileInfo, maxUploadSize: number): PromiseLike<{
|
|
497
1434
|
_id: string;
|
|
498
1435
|
size: number;
|
|
499
1436
|
}>;
|
|
1437
|
+
/**
|
|
1438
|
+
* Destroys a file in the storage.
|
|
1439
|
+
* @param proto - The ProtoService instance.
|
|
1440
|
+
* @param id - The ID of the file to destroy.
|
|
1441
|
+
* @returns A promise that resolves when the file is destroyed.
|
|
1442
|
+
*/
|
|
500
1443
|
destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;
|
|
1444
|
+
/**
|
|
1445
|
+
* Retrieves file data from the storage.
|
|
1446
|
+
* @param proto - The ProtoService instance.
|
|
1447
|
+
* @param id - The ID of the file.
|
|
1448
|
+
* @param start - The optional start byte position.
|
|
1449
|
+
* @param end - The optional end byte position.
|
|
1450
|
+
* @returns An async iterable of binary data.
|
|
1451
|
+
*/
|
|
501
1452
|
fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number): AsyncIterable<BinaryData>;
|
|
502
1453
|
}
|
|
503
1454
|
|
|
@@ -608,36 +1559,118 @@ type PasswordHashOptions = {
|
|
|
608
1559
|
} & _PasswordHashOptions[K];
|
|
609
1560
|
}[keyof _PasswordHashOptions];
|
|
610
1561
|
|
|
1562
|
+
/**
|
|
1563
|
+
* Interface for publish-subscribe operations.
|
|
1564
|
+
*/
|
|
611
1565
|
interface TPubSub {
|
|
1566
|
+
/**
|
|
1567
|
+
* Subscribes to events.
|
|
1568
|
+
* @param callback - The callback function to handle the event data.
|
|
1569
|
+
* @returns A function to unsubscribe from the events.
|
|
1570
|
+
*/
|
|
612
1571
|
subscribe(callback: (payload: EventData) => void): VoidFunction;
|
|
1572
|
+
/**
|
|
1573
|
+
* Publishes an event.
|
|
1574
|
+
* @param payload - The event data to publish.
|
|
1575
|
+
* @returns A promise that resolves when the event is published.
|
|
1576
|
+
*/
|
|
613
1577
|
publish(payload: EventData): Awaitable<void>;
|
|
614
1578
|
}
|
|
615
1579
|
|
|
616
1580
|
type ProtoServiceOptions<Ext> = {
|
|
1581
|
+
/**
|
|
1582
|
+
* The endpoint for the service.
|
|
1583
|
+
*/
|
|
617
1584
|
endpoint: string;
|
|
1585
|
+
/**
|
|
1586
|
+
* The schema definitions for the service.
|
|
1587
|
+
*/
|
|
618
1588
|
schema: Record<string, TSchema>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Role resolver configuration.
|
|
1591
|
+
*/
|
|
619
1592
|
roleResolver?: {
|
|
1593
|
+
/**
|
|
1594
|
+
* Keys to inherit roles.
|
|
1595
|
+
*/
|
|
620
1596
|
inheritKeys?: string[];
|
|
1597
|
+
/**
|
|
1598
|
+
* Custom resolver function for roles.
|
|
1599
|
+
* @param user The user object.
|
|
1600
|
+
* @param defaultResolver The default resolver function.
|
|
1601
|
+
* @returns A promise that resolves to an array of roles.
|
|
1602
|
+
*/
|
|
621
1603
|
resolver?: (user: TUser, defaultResolver: () => PromiseLike<TRole[]>) => PromiseLike<TRole[]>;
|
|
622
1604
|
};
|
|
1605
|
+
/**
|
|
1606
|
+
* Storage configuration.
|
|
1607
|
+
*/
|
|
623
1608
|
storage: TStorage;
|
|
1609
|
+
/**
|
|
1610
|
+
* File storage configuration.
|
|
1611
|
+
*/
|
|
624
1612
|
fileStorage: TFileStorage;
|
|
1613
|
+
/**
|
|
1614
|
+
* Pub/Sub configuration.
|
|
1615
|
+
*/
|
|
625
1616
|
pubsub?: TPubSub;
|
|
1617
|
+
/**
|
|
1618
|
+
* Class extensions configuration.
|
|
1619
|
+
*/
|
|
626
1620
|
classExtends?: TExtensions<Ext>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Size of the object ID.
|
|
1623
|
+
*/
|
|
627
1624
|
objectIdSize?: number;
|
|
1625
|
+
/**
|
|
1626
|
+
* Maximum fetch limit.
|
|
1627
|
+
*/
|
|
628
1628
|
maxFetchLimit?: number;
|
|
1629
|
+
/**
|
|
1630
|
+
* Maximum upload size.
|
|
1631
|
+
*/
|
|
629
1632
|
maxUploadSize?: number;
|
|
1633
|
+
/**
|
|
1634
|
+
* Cookie options.
|
|
1635
|
+
*/
|
|
630
1636
|
cookieOptions?: CookieOptions;
|
|
1637
|
+
/**
|
|
1638
|
+
* JWT sign options.
|
|
1639
|
+
*/
|
|
631
1640
|
jwtSignOptions?: SignOptions;
|
|
1641
|
+
/**
|
|
1642
|
+
* JWT verify options.
|
|
1643
|
+
*/
|
|
632
1644
|
jwtVerifyOptions?: VerifyOptions;
|
|
1645
|
+
/**
|
|
1646
|
+
* JWT upload sign options.
|
|
1647
|
+
*/
|
|
633
1648
|
jwtUploadSignOptions?: SignOptions;
|
|
1649
|
+
/**
|
|
1650
|
+
* JWT upload verify options.
|
|
1651
|
+
*/
|
|
634
1652
|
jwtUploadVerifyOptions?: VerifyOptions;
|
|
1653
|
+
/**
|
|
1654
|
+
* Password hash options.
|
|
1655
|
+
*/
|
|
635
1656
|
passwordHashOptions?: PasswordHashOptions;
|
|
636
1657
|
};
|
|
637
1658
|
type ProtoServiceKeyOptions = {
|
|
1659
|
+
/**
|
|
1660
|
+
* JWT token for the service.
|
|
1661
|
+
*/
|
|
638
1662
|
jwtToken: string;
|
|
1663
|
+
/**
|
|
1664
|
+
* Master users configuration.
|
|
1665
|
+
*/
|
|
639
1666
|
masterUsers?: {
|
|
1667
|
+
/**
|
|
1668
|
+
* Username of the master user.
|
|
1669
|
+
*/
|
|
640
1670
|
user: string;
|
|
1671
|
+
/**
|
|
1672
|
+
* Password of the master user.
|
|
1673
|
+
*/
|
|
641
1674
|
pass: string;
|
|
642
1675
|
}[];
|
|
643
1676
|
};
|
|
@@ -710,10 +1743,6 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
710
1743
|
}): Promise<void>;
|
|
711
1744
|
run(name: string, params?: TSerializable, options?: ExtraOptions<boolean>): Promise<void | TSerializable>;
|
|
712
1745
|
define(name: string, callback: ProtoFunction<Ext>, options?: Omit<ProtoFunctionOptions<Ext>, 'callback'>): void;
|
|
713
|
-
beforeSave<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;
|
|
714
|
-
afterSave<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;
|
|
715
|
-
beforeDelete<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;
|
|
716
|
-
afterDelete<T extends string>(name: T, callback: ProtoTrigger<T, Ext>): void;
|
|
717
1746
|
lockTable(className: string | string[], update: boolean): Promise<void>;
|
|
718
1747
|
withTransaction<T>(callback: (connection: ProtoService<Ext>) => PromiseLike<T>, options?: TransactionOptions): PromiseLike<T>;
|
|
719
1748
|
generateUploadToken(options?: {
|
|
@@ -733,4 +1762,4 @@ declare class ProtoService<Ext = any> extends ProtoType<Ext> {
|
|
|
733
1762
|
}
|
|
734
1763
|
|
|
735
1764
|
export { type TPubSub as A, type TFileInfo as B, type DeserializeOptions as D, type ExtraOptions as E, type FindOptions as F, type InsertOptions as I, ProtoService as P, QuerySelector as Q, type RelationOptions as R, type SerializeOptions as S, TSchema as T, type _TValue as _, type ProtoServiceOptions as a, type ProtoServiceKeyOptions as b, type TFileStorage as c, type TSerializable as d, deserialize as e, type TExtensions as f, TQuery as g, TObject as h, TUser as i, TRole as j, TFile as k, ProtoType as l, type PathName as m, type TObjectType as n, type EventData as o, type DecodedQuery as p, type DecodedSortOption as q, type TValue as r, serialize as s, type FindOneOptions as t, type TUpdateOp as u, FieldSelectorExpression as v, QueryExpression as w, type TStorage as x, type TransactionOptions as y, type TQueryRandomOptions as z };
|
|
736
|
-
//# sourceMappingURL=index-
|
|
1765
|
+
//# sourceMappingURL=index-BYZpj31o.d.ts.map
|