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
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as ProtoClient } from './internals/index-Cpv1DoEI.js';
2
- export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Cpv1DoEI.js';
1
+ import { P as ProtoClient } from './internals/index-uwXdnxqN.js';
2
+ export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-uwXdnxqN.js';
3
3
  export { Decimal } from 'decimal.js';
4
- export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-lX-M76Tn.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-CE5tdYK8.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'socket.io-client';
7
7
  import '@socket.io/component-emitter';
package/dist/client.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./internals/index-CIecB6mS.js');
5
+ var index = require('./internals/index-S_gTMQBh.js');
6
6
  var Decimal = require('decimal.js');
7
- require('./internals/index-CVutVPmd.js');
7
+ require('./internals/index-DXuW8UiB.js');
8
8
  require('lodash');
9
9
  require('./internals/private-CSB1Ep4g.js');
10
10
  require('@o2ter/utils-js');
package/dist/client.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { c as ProtoClient } from './internals/index-BZNPlw1L.mjs';
2
- export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-BZNPlw1L.mjs';
1
+ import { c as ProtoClient } from './internals/index-R0gbIGc-.mjs';
2
+ export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-R0gbIGc-.mjs';
3
3
  export { Decimal } from 'decimal.js';
4
- import './internals/index-BYbMU-Ao.mjs';
4
+ import './internals/index--ifyu-GL.mjs';
5
5
  import 'lodash';
6
6
  import './internals/private-BUpLAMZi.mjs';
7
7
  import '@o2ter/utils-js';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as socket_io from 'socket.io';
2
2
  import { Router } from 'express';
3
3
  import { Server } from '@o2ter/server-js';
4
- import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-lX-M76Tn.js';
5
- export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-lX-M76Tn.js';
4
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-CE5tdYK8.js';
5
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-CE5tdYK8.js';
6
6
  import Decimal from 'decimal.js';
7
7
  export { Decimal } from 'decimal.js';
8
- export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Cpv1DoEI.js';
8
+ export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-uwXdnxqN.js';
9
9
  import '@o2ter/utils-js';
10
10
  import 'jsonwebtoken';
11
11
  import 'lodash';
@@ -13,57 +13,129 @@ import 'node:stream';
13
13
  import 'socket.io-client';
14
14
  import '@socket.io/component-emitter';
15
15
 
16
+ /**
17
+ * Schema definition utility functions.
18
+ */
16
19
  declare const schema: ((x: Record<string, TSchema>) => Record<string, TSchema>) & {
20
+ /**
21
+ * Defines a boolean schema.
22
+ * @param defaultValue - The default value for the boolean.
23
+ * @returns The boolean schema.
24
+ */
17
25
  boolean: (defaultValue?: boolean) => {
18
26
  readonly type: "boolean";
19
27
  readonly default: boolean | undefined;
20
28
  };
29
+ /**
30
+ * Defines a number schema.
31
+ * @param defaultValue - The default value for the number.
32
+ * @returns The number schema.
33
+ */
21
34
  number: (defaultValue?: number) => {
22
35
  readonly type: "number";
23
36
  readonly default: number | undefined;
24
37
  };
38
+ /**
39
+ * Defines a decimal schema.
40
+ * @param defaultValue - The default value for the decimal.
41
+ * @returns The decimal schema.
42
+ */
25
43
  decimal: (defaultValue?: Decimal) => {
26
44
  readonly type: "decimal";
27
45
  readonly default: Decimal | undefined;
28
46
  };
47
+ /**
48
+ * Defines a string schema.
49
+ * @param defaultValue - The default value for the string.
50
+ * @returns The string schema.
51
+ */
29
52
  string: (defaultValue?: string) => {
30
53
  readonly type: "string";
31
54
  readonly default: string | undefined;
32
55
  };
56
+ /**
57
+ * Defines a date schema.
58
+ * @param defaultValue - The default value for the date.
59
+ * @returns The date schema.
60
+ */
33
61
  date: (defaultValue?: Date) => {
34
62
  readonly type: "date";
35
63
  readonly default: Date | undefined;
36
64
  };
65
+ /**
66
+ * Defines an object schema.
67
+ * @param defaultValue - The default value for the object.
68
+ * @returns The object schema.
69
+ */
37
70
  object: <T extends Record<string, _TValue>>(defaultValue?: T) => {
38
71
  readonly type: "object";
39
72
  readonly default: T | undefined;
40
73
  };
74
+ /**
75
+ * Defines an array schema.
76
+ * @param defaultValue - The default value for the array.
77
+ * @returns The array schema.
78
+ */
41
79
  array: <T extends _TValue[]>(defaultValue?: T) => {
42
80
  readonly type: "array";
43
81
  readonly default: T | undefined;
44
82
  };
83
+ /**
84
+ * Defines a vector schema.
85
+ * @param dimension - The dimension of the vector.
86
+ * @param defaultValue - The default value for the vector.
87
+ * @returns The vector schema.
88
+ */
45
89
  vector: (dimension: number, defaultValue?: number[]) => {
46
90
  readonly type: "vector";
47
91
  readonly dimension: number;
48
92
  readonly default: number[] | undefined;
49
93
  };
94
+ /**
95
+ * Defines a shape schema.
96
+ * @param shape - The shape definition.
97
+ * @returns The shape schema.
98
+ */
50
99
  shape: (shape: Record<string, TSchema.DataType>) => {
51
100
  readonly type: "shape";
52
101
  readonly shape: Record<string, TSchema.DataType>;
53
102
  };
103
+ /**
104
+ * Defines a pointer schema.
105
+ * @param target - The target of the pointer.
106
+ * @returns The pointer schema.
107
+ */
54
108
  pointer: (target: string) => {
55
109
  readonly type: "pointer";
56
110
  readonly target: string;
57
111
  };
112
+ /**
113
+ * Defines a relation schema.
114
+ * @param target - The target of the relation.
115
+ * @param foreignField - The foreign field of the relation.
116
+ * @returns The relation schema.
117
+ */
58
118
  relation: (target: string, foreignField?: string) => {
59
119
  readonly type: "relation";
60
120
  readonly target: string;
61
121
  readonly foreignField: string | undefined;
62
122
  };
63
123
  };
124
+ /**
125
+ * Creates a ProtoRoute.
126
+ * @param options - The options for the ProtoRoute.
127
+ * @returns A promise that resolves to a Router.
128
+ */
64
129
  declare const ProtoRoute: <E>(options: {
65
130
  proto: ProtoService<E> | (ProtoServiceOptions<E> & ProtoServiceKeyOptions);
66
131
  }) => Promise<Router>;
132
+ /**
133
+ * Registers a ProtoSocket.
134
+ * @param proto - The ProtoService instance.
135
+ * @param server - The server instance.
136
+ * @param endpoint - The optional endpoint.
137
+ * @returns The socket.io instance.
138
+ */
67
139
  declare const registerProtoSocket: <E>(proto: ProtoService<E>, server: Server, endpoint?: string) => socket_io.Server<socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, any> | socket_io.Namespace<socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, any>;
68
140
 
69
141
  export { ProtoRoute, ProtoService, ProtoRoute as default, registerProtoSocket, schema };
package/dist/index.js CHANGED
@@ -4,18 +4,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _ = require('lodash');
6
6
  var serverJs = require('@o2ter/server-js');
7
- var random = require('./internals/random-Dytum6Nh.js');
7
+ var random = require('./internals/random-DVOUDDGg.js');
8
8
  var _private = require('./internals/private-CSB1Ep4g.js');
9
9
  var utilsJs = require('@o2ter/utils-js');
10
- var index = require('./internals/index-CIecB6mS.js');
11
- var index$1 = require('./internals/index-CVutVPmd.js');
10
+ var index = require('./internals/index-S_gTMQBh.js');
11
+ var index$1 = require('./internals/index-DXuW8UiB.js');
12
12
  var jwt = require('jsonwebtoken');
13
13
  var node_buffer = require('node:buffer');
14
14
  var node_stream = require('node:stream');
15
15
  var node_crypto = require('node:crypto');
16
16
  var util = require('util');
17
17
  var cryptoJs = require('@o2ter/crypto-js');
18
- var index$2 = require('./internals/index-CzfsyXvb.js');
18
+ var index$2 = require('./internals/index-Dc3V_Bzw.js');
19
19
  var queryType = require('query-types');
20
20
  var busboy = require('busboy');
21
21
  var Decimal = require('decimal.js');
@@ -412,7 +412,12 @@ class _ProtoQuery extends index.TQuery {
412
412
  if (!result)
413
413
  throw Error('Unable to insert document');
414
414
  if (_.isFunction(afterSave)) {
415
- await afterSave(proxy(Object.setPrototypeOf({ object: result, context }, options?.session ?? this._proto)));
415
+ try {
416
+ await afterSave(proxy(Object.setPrototypeOf({ object: result.clone(), context }, options?.session ?? this._proto)));
417
+ }
418
+ catch (e) {
419
+ console.error(e);
420
+ }
416
421
  }
417
422
  return result;
418
423
  }
@@ -440,7 +445,14 @@ class _ProtoQuery extends index.TQuery {
440
445
  matches: this[_private.PVK].options.matches,
441
446
  }, _.map(objects, x => _.fromPairs([...x._set_entries()])));
442
447
  if (_.isFunction(afterSave)) {
443
- await Promise.all(_.map(objects, object => afterSave(proxy(Object.setPrototypeOf({ object, context }, options?.session ?? this._proto)))));
448
+ await Promise.all(_.map(objects, async (object) => {
449
+ try {
450
+ await afterSave(proxy(Object.setPrototypeOf({ object: object.clone(), context }, options?.session ?? this._proto)));
451
+ }
452
+ catch (e) {
453
+ console.error(e);
454
+ }
455
+ }));
444
456
  }
445
457
  return objects.length;
446
458
  }
@@ -465,7 +477,12 @@ class _ProtoQuery extends index.TQuery {
465
477
  }
466
478
  const result = this._objectMethods(await this._dispatcher(options).updateOne(this._queryOptions, update));
467
479
  if (result && _.isFunction(afterSave)) {
468
- await afterSave(proxy(Object.setPrototypeOf({ object: result, context }, options?.session ?? this._proto)));
480
+ try {
481
+ await afterSave(proxy(Object.setPrototypeOf({ object: result.clone(), context }, options?.session ?? this._proto)));
482
+ }
483
+ catch (e) {
484
+ console.error(e);
485
+ }
469
486
  }
470
487
  return result;
471
488
  }
@@ -487,11 +504,18 @@ class _ProtoQuery extends index.TQuery {
487
504
  filter: { _id: { $in: _.map(objects, x => x.objectId) } },
488
505
  }, update);
489
506
  }
490
- const updated = await Promise.all(_.map(objects, x => this._dispatcher(options).updateOne({
507
+ const updated = _.compact(await Promise.all(_.map(objects, x => this._dispatcher(options).updateOne({
491
508
  ...this._queryOptions,
492
509
  filter: { _id: { $eq: x.objectId } },
493
- }, update)));
494
- await Promise.all(_.map(updated, object => afterSave(proxy(Object.setPrototypeOf({ object, context }, options?.session ?? this._proto)))));
510
+ }, update))));
511
+ await Promise.all(_.map(updated, async (object) => {
512
+ try {
513
+ await afterSave(proxy(Object.setPrototypeOf({ object: object.clone(), context }, options?.session ?? this._proto)));
514
+ }
515
+ catch (e) {
516
+ console.error(e);
517
+ }
518
+ }));
495
519
  return updated.length;
496
520
  }
497
521
  return this._dispatcher(options).updateMany(this._queryOptions, update);
@@ -530,7 +554,12 @@ class _ProtoQuery extends index.TQuery {
530
554
  if (!result)
531
555
  throw Error('Unable to upsert document');
532
556
  if (_.isFunction(afterSave)) {
533
- await afterSave(proxy(Object.setPrototypeOf({ object: result, context }, options?.session ?? this._proto)));
557
+ try {
558
+ await afterSave(proxy(Object.setPrototypeOf({ object: result.clone(), context }, options?.session ?? this._proto)));
559
+ }
560
+ catch (e) {
561
+ console.error(e);
562
+ }
534
563
  }
535
564
  return result;
536
565
  }
@@ -553,7 +582,12 @@ class _ProtoQuery extends index.TQuery {
553
582
  if (!result)
554
583
  throw Error('Unable to insert document');
555
584
  if (_.isFunction(afterSave)) {
556
- await afterSave(proxy(Object.setPrototypeOf({ object: result, context }, options?.session ?? this._proto)));
585
+ try {
586
+ await afterSave(proxy(Object.setPrototypeOf({ object: result.clone(), context }, options?.session ?? this._proto)));
587
+ }
588
+ catch (e) {
589
+ console.error(e);
590
+ }
557
591
  }
558
592
  return { updated: 0, inserted: 1 };
559
593
  }
@@ -566,11 +600,18 @@ class _ProtoQuery extends index.TQuery {
566
600
  }, update),
567
601
  };
568
602
  }
569
- const updated = await Promise.all(_.map(objects, x => this._dispatcher(options).updateOne({
603
+ const updated = _.compact(await Promise.all(_.map(objects, x => this._dispatcher(options).updateOne({
570
604
  ...this._queryOptions,
571
605
  filter: { _id: { $eq: x.objectId } },
572
- }, update)));
573
- await Promise.all(_.map(updated, object => afterSave(proxy(Object.setPrototypeOf({ object, context }, options?.session ?? this._proto)))));
606
+ }, update))));
607
+ await Promise.all(_.map(updated, async (object) => {
608
+ try {
609
+ await afterSave(proxy(Object.setPrototypeOf({ object: object.clone(), context }, options?.session ?? this._proto)));
610
+ }
611
+ catch (e) {
612
+ console.error(e);
613
+ }
614
+ }));
574
615
  return { updated: updated.length, inserted: 0 };
575
616
  }
576
617
  return this._dispatcher(options).upsertMany(this._queryOptions, update, setOnInsert);
@@ -595,7 +636,12 @@ class _ProtoQuery extends index.TQuery {
595
636
  result = this._objectMethods(await this._dispatcher(options).deleteOne(this._queryOptions));
596
637
  }
597
638
  if (result && _.isFunction(afterDelete)) {
598
- await afterDelete(proxy(Object.setPrototypeOf({ object: result, context }, options?.session ?? this._proto)));
639
+ try {
640
+ await afterDelete(proxy(Object.setPrototypeOf({ object: result.clone(), context }, options?.session ?? this._proto)));
641
+ }
642
+ catch (e) {
643
+ console.error(e);
644
+ }
599
645
  }
600
646
  return result;
601
647
  }
@@ -616,7 +662,14 @@ class _ProtoQuery extends index.TQuery {
616
662
  filter: { _id: { $in: _.map(objects, x => x.objectId) } },
617
663
  });
618
664
  if (_.isFunction(afterDelete)) {
619
- await Promise.all(_.map(objects, object => afterDelete(proxy(Object.setPrototypeOf({ object, context }, options?.session ?? this._proto)))));
665
+ await Promise.all(_.map(objects, async (object) => {
666
+ try {
667
+ await afterDelete(proxy(Object.setPrototypeOf({ object: object.clone(), context }, options?.session ?? this._proto)));
668
+ }
669
+ catch (e) {
670
+ console.error(e);
671
+ }
672
+ }));
620
673
  }
621
674
  return objects.length;
622
675
  }
@@ -2379,19 +2432,84 @@ var configRoute = (router, proto) => {
2379
2432
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2380
2433
  // THE SOFTWARE.
2381
2434
  //
2435
+ /**
2436
+ * Schema definition utility functions.
2437
+ */
2382
2438
  const schema = _.assign((x) => x, {
2439
+ /**
2440
+ * Defines a boolean schema.
2441
+ * @param defaultValue - The default value for the boolean.
2442
+ * @returns The boolean schema.
2443
+ */
2383
2444
  boolean: (defaultValue) => ({ type: 'boolean', default: defaultValue }),
2445
+ /**
2446
+ * Defines a number schema.
2447
+ * @param defaultValue - The default value for the number.
2448
+ * @returns The number schema.
2449
+ */
2384
2450
  number: (defaultValue) => ({ type: 'number', default: defaultValue }),
2451
+ /**
2452
+ * Defines a decimal schema.
2453
+ * @param defaultValue - The default value for the decimal.
2454
+ * @returns The decimal schema.
2455
+ */
2385
2456
  decimal: (defaultValue) => ({ type: 'decimal', default: defaultValue }),
2457
+ /**
2458
+ * Defines a string schema.
2459
+ * @param defaultValue - The default value for the string.
2460
+ * @returns The string schema.
2461
+ */
2386
2462
  string: (defaultValue) => ({ type: 'string', default: defaultValue }),
2463
+ /**
2464
+ * Defines a date schema.
2465
+ * @param defaultValue - The default value for the date.
2466
+ * @returns The date schema.
2467
+ */
2387
2468
  date: (defaultValue) => ({ type: 'date', default: defaultValue }),
2469
+ /**
2470
+ * Defines an object schema.
2471
+ * @param defaultValue - The default value for the object.
2472
+ * @returns The object schema.
2473
+ */
2388
2474
  object: (defaultValue) => ({ type: 'object', default: defaultValue }),
2475
+ /**
2476
+ * Defines an array schema.
2477
+ * @param defaultValue - The default value for the array.
2478
+ * @returns The array schema.
2479
+ */
2389
2480
  array: (defaultValue) => ({ type: 'array', default: defaultValue }),
2481
+ /**
2482
+ * Defines a vector schema.
2483
+ * @param dimension - The dimension of the vector.
2484
+ * @param defaultValue - The default value for the vector.
2485
+ * @returns The vector schema.
2486
+ */
2390
2487
  vector: (dimension, defaultValue) => ({ type: 'vector', dimension, default: defaultValue }),
2488
+ /**
2489
+ * Defines a shape schema.
2490
+ * @param shape - The shape definition.
2491
+ * @returns The shape schema.
2492
+ */
2391
2493
  shape: (shape) => ({ type: 'shape', shape }),
2494
+ /**
2495
+ * Defines a pointer schema.
2496
+ * @param target - The target of the pointer.
2497
+ * @returns The pointer schema.
2498
+ */
2392
2499
  pointer: (target) => ({ type: 'pointer', target }),
2500
+ /**
2501
+ * Defines a relation schema.
2502
+ * @param target - The target of the relation.
2503
+ * @param foreignField - The foreign field of the relation.
2504
+ * @returns The relation schema.
2505
+ */
2393
2506
  relation: (target, foreignField) => ({ type: 'relation', target, foreignField }),
2394
2507
  });
2508
+ /**
2509
+ * Creates a ProtoRoute.
2510
+ * @param options - The options for the ProtoRoute.
2511
+ * @returns A promise that resolves to a Router.
2512
+ */
2395
2513
  const ProtoRoute = async (options) => {
2396
2514
  const proto = options.proto instanceof ProtoService ? options.proto : new ProtoService(options.proto);
2397
2515
  await proto[_private.PVK].prepare();
@@ -2414,6 +2532,13 @@ const ProtoRoute = async (options) => {
2414
2532
  configRoute(router, proto);
2415
2533
  return router;
2416
2534
  };
2535
+ /**
2536
+ * Registers a ProtoSocket.
2537
+ * @param proto - The ProtoService instance.
2538
+ * @param server - The server instance.
2539
+ * @param endpoint - The optional endpoint.
2540
+ * @returns The socket.io instance.
2541
+ */
2417
2542
  const registerProtoSocket = (proto, server, endpoint) => {
2418
2543
  const io = endpoint ? server.socket().of(endpoint) : server.socket();
2419
2544
  io.on('connection', async (socket) => {