proto.io 0.0.173 → 0.0.174

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