sumba 2.37.0 → 2.38.1

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/index.js CHANGED
@@ -27,20 +27,58 @@ async function factory (pkgName) {
27
27
  */
28
28
  constructor () {
29
29
  super(pkgName, me.app)
30
+
31
+ /**
32
+ * Configuration object
33
+ * @type {Sumba.TConfig}
34
+ */
30
35
  this.config = config
36
+
37
+ /**
38
+ * Secure guards containers
39
+ * @type {Array}
40
+ */
31
41
  this.secureGuards = []
42
+
43
+ /**
44
+ * Action guards container
45
+ * @type {Array}
46
+ */
32
47
  this.actionGuards = []
48
+
49
+ /**
50
+ * Query guards container
51
+ * @type {Array}
52
+ */
33
53
  this.queryGuards = []
54
+
55
+ /**
56
+ * Attribute guards container
57
+ * @type {Array}
58
+ */
34
59
  this.attribGuards = []
35
- this.secureGuards = []
60
+
61
+ /**
62
+ * Anonymous guards container
63
+ * @type {Array}
64
+ */
36
65
  this.anonymousGuards = []
37
66
 
67
+ /**
68
+ * Download directory path for storing exported files.
69
+ * @type {string}
70
+ */
71
+ this.downloadDir = null
72
+
73
+ /**
74
+ * Unsafe user fields that should not be exposed or returned in API responses.
75
+ * @type {string[]}
76
+ */
38
77
  this.unsafeUserFields = ['password']
39
78
  }
40
79
 
41
80
  /**
42
- * Plugin initialization method. This method is called by the {@link https://ardhi.github.io/bajo|Bajo framework} during plugin initialization.
43
- *
81
+ * Plugin initialization method
44
82
  * @async
45
83
  * @method
46
84
  */
@@ -54,8 +92,7 @@ async function factory (pkgName) {
54
92
  }
55
93
 
56
94
  /**
57
- * Plugin start method. This method is called by the {@link https://ardhi.github.io/bajo|Bajo framework} during plugin start.
58
- *
95
+ * Plugin start method
59
96
  * @async
60
97
  * @method
61
98
  */
@@ -74,10 +111,9 @@ async function factory (pkgName) {
74
111
 
75
112
  /**
76
113
  * Populate route guards at start
77
- *
78
114
  * @async
79
115
  * @method
80
- * @param {array} [sites] - List of sites to populate route guards for. If not provided, it will fetch all active sites.
116
+ * @param {array} [sites] - List of sites to populate route guards for. If not provided, it will fetch all active sites
81
117
  */
82
118
  populateRouteGuards = async (sites) => {
83
119
  const { isString, get, difference } = this.app.lib._
@@ -159,12 +195,11 @@ async function factory (pkgName) {
159
195
 
160
196
  /**
161
197
  * Get authentication setting based on type and source
162
- *
163
198
  * @method
164
- * @private
165
- * @param {string} type - The type of authentication setting to retrieve. If not provided, it will use parent setting.
166
- * @param {string} [source] - The source of the authentication setting. If not provided, it will use the default setting.
167
- * @returns {object} - The authentication setting object.
199
+ * @internal
200
+ * @param {string} [type] - The type of authentication setting to retrieve. If not provided, it will use parent setting
201
+ * @param {string} [source] - The source of the authentication setting. If not provided, it will use the default setting
202
+ * @returns {object} - The authentication setting object
168
203
  */
169
204
  _getAuthSetting = (type, source) => {
170
205
  const { defaultsDeep } = this.app.lib.aneka
@@ -180,13 +215,12 @@ async function factory (pkgName) {
180
215
 
181
216
  /**
182
217
  * Get authentication token based on type, request, and source
183
- *
184
218
  * @method
185
- * @private
186
- * @param {string} type - The type of authentication setting.
187
- * @param {object} req - The request object.
188
- * @param {string} [source] - The source of the authentication setting. If not provided, it will use the default setting.
189
- * @returns {string|boolean} - The token if found, otherwise false.
219
+ * @internal
220
+ * @param {string} type - The type of authentication setting
221
+ * @param {object} req - The request object
222
+ * @param {string} [source] - The source of the authentication setting. If not provided, it will use the default setting
223
+ * @returns {string|boolean} - The token if found, otherwise false
190
224
  */
191
225
  _getAuthToken = (type, req, source) => {
192
226
  const { isEmpty } = this.app.lib._
@@ -204,16 +238,14 @@ async function factory (pkgName) {
204
238
 
205
239
  /**
206
240
  * Build admin menu based on locals and request.
207
- *
208
- * - If multi-site is enabled, it will include the cross-site menu with options to manage all sites and site settings.
209
- * - If caching is enabled, it will include the cache storage menu in the appropriate section.
241
+ * - If multi-site is enabled, it will include the cross-site menu with options to manage all sites and site settings
242
+ * - If caching is enabled, it will include the cache storage menu in the appropriate section
210
243
  * - Session management menu is also included in the appropriate section.
211
- *
212
244
  * @async
213
245
  * @method
214
- * @param {object} locals - The locals object.
215
- * @param {object} req - The request object.
216
- * @returns {array} - The admin menu items.
246
+ * @param {object} locals - The locals object
247
+ * @param {object} req - The request object
248
+ * @returns {array} - The admin menu items
217
249
  */
218
250
  adminMenu = async (locals, req) => {
219
251
  if (!this.app.waibuAdmin) return
@@ -284,11 +316,10 @@ async function factory (pkgName) {
284
316
 
285
317
  /**
286
318
  * Create JWT from user record
287
- *
288
319
  * @async
289
320
  * @method
290
- * @param {object} rec - The user record object.
291
- * @returns {Promise<object>} - The JWT token and its expiration date.
321
+ * @param {object} rec - The user record object
322
+ * @returns {Promise<object>} The JWT token and its expiration date
292
323
  */
293
324
  createJwtFromUserRecord = async (rec) => {
294
325
  const { importPkg } = this.app.bajo
@@ -311,14 +342,13 @@ async function factory (pkgName) {
311
342
 
312
343
  /**
313
344
  * Verify user session
314
- *
315
345
  * @async
316
346
  * @method
317
- * @param {object} req - The request object.
318
- * @param {object} reply - The reply object.
319
- * @param {string} source - The source of the authentication setting.
320
- * @param {object} payload - The payload object.
321
- * @returns {boolean} - True if the session is valid, otherwise false.
347
+ * @param {object} req - The request object
348
+ * @param {object} reply - The reply object
349
+ * @param {string} source - The source of the authentication setting
350
+ * @param {object} payload - The payload object
351
+ * @returns {boolean} - True if the session is valid, otherwise false
322
352
  */
323
353
  verifySession = async (req, reply, source, payload) => {
324
354
  const { routePath } = this.app.waibu
@@ -336,14 +366,13 @@ async function factory (pkgName) {
336
366
 
337
367
  /**
338
368
  * Verify API key
339
- *
340
369
  * @async
341
370
  * @method
342
- * @param {object} req - The request object.
343
- * @param {object} reply - The reply object.
344
- * @param {string} source - The source of the authentication setting.
345
- * @param {object} payload - The payload object.
346
- * @returns {boolean} - True if the API key is valid, otherwise false.
371
+ * @param {object} req - The request object
372
+ * @param {object} reply - The reply object
373
+ * @param {string} source - The source of the authentication setting
374
+ * @param {object} payload - The payload object
375
+ * @returns {boolean} - True if the API key is valid, otherwise false
347
376
  */
348
377
  verifyApiKey = async (req, reply, source, payload) => {
349
378
  const { merge, camelCase } = this.app.lib._
@@ -362,14 +391,13 @@ async function factory (pkgName) {
362
391
 
363
392
  /**
364
393
  * Verify basic authentication
365
- *
366
394
  * @async
367
395
  * @method
368
- * @param {object} req - The request object.
369
- * @param {object} reply - The reply object.
370
- * @param {string} source - The source of the authentication setting.
371
- * @param {object} payload - The payload object.
372
- * @returns {boolean|string} - True if the basic authentication is valid, otherwise false or an error message.
396
+ * @param {object} req - The request object
397
+ * @param {object} reply - The reply object
398
+ * @param {string} source - The source of the authentication setting
399
+ * @param {object} payload - The payload object
400
+ * @returns {boolean|string} - True if the basic authentication is valid, otherwise false or an error message
373
401
  */
374
402
  verifyBasic = async (req, reply, source, payload) => {
375
403
  const { isEmpty, merge } = this.app.lib._
@@ -410,14 +438,13 @@ async function factory (pkgName) {
410
438
 
411
439
  /**
412
440
  * Verify JWT authentication
413
- *
414
441
  * @async
415
442
  * @method
416
- * @param {object} req - The request object.
417
- * @param {object} reply - The reply object.
418
- * @param {string} source - The source of the authentication setting.
419
- * @param {object} payload - The payload object.
420
- * @returns {boolean} - True if the JWT authentication is valid, otherwise false.
443
+ * @param {object} req - The request object
444
+ * @param {object} reply - The reply object
445
+ * @param {string} source - The source of the authentication setting
446
+ * @param {object} payload - The payload object
447
+ * @returns {boolean} - True if the JWT authentication is valid, otherwise false
421
448
  */
422
449
  verifyJwt = async (req, reply, source, payload) => {
423
450
  const { importPkg } = this.app.bajo
@@ -448,11 +475,10 @@ async function factory (pkgName) {
448
475
 
449
476
  /**
450
477
  * Check route guard
451
- *
452
478
  * @method
453
- * @param {Array} guards - The array of guard objects.
454
- * @param {Array} paths - The array of paths to check.
455
- * @returns {string|undefined} - The matched path or undefined if no match is found.
479
+ * @param {Array} guards - The array of guard object
480
+ * @param {Array} paths - The array of paths to check
481
+ * @returns {string|undefined} - The matched path or undefined if no match is found
456
482
  */
457
483
  checkRouteGuard = (guards, paths) => {
458
484
  const { outmatch } = this.app.lib
@@ -463,13 +489,12 @@ async function factory (pkgName) {
463
489
 
464
490
  /**
465
491
  * Sign out user and redirect to the specified URL
466
- *
467
492
  * @async
468
493
  * @method
469
- * @param {object} options - The options object.
470
- * @param {object} options.req - The request object.
471
- * @param {object} options.reply - The reply object.
472
- * @param {string} [options.reason] - The reason for signing out.
494
+ * @param {object} options - The options object
495
+ * @param {object} options.req - The request object
496
+ * @param {object} options.reply - The reply object
497
+ * @param {string} [options.reason] - The reason for signing out
473
498
  */
474
499
  signout = async (options = {}) => {
475
500
  const { req, reply, reason } = options
@@ -487,13 +512,12 @@ async function factory (pkgName) {
487
512
 
488
513
  /**
489
514
  * Sign in user and redirect to the specified URL
490
- *
491
515
  * @async
492
516
  * @method
493
- * @param {object} options - The options object.
494
- * @param {object} options.req - The request object.
495
- * @param {object} options.reply - The reply object.
496
- * @param {object} options.user - The user object.
517
+ * @param {object} options - The options object
518
+ * @param {object} options.req - The request object
519
+ * @param {object} options.reply - The reply object
520
+ * @param {object} options.user - The user object
497
521
  */
498
522
  signin = async (options = {}) => {
499
523
  const { req, reply, user } = options
@@ -517,8 +541,8 @@ async function factory (pkgName) {
517
541
  * Generate a random password based on the configuration settings
518
542
  *
519
543
  * @method
520
- * @param {object} req - The request object.
521
- * @returns {string} - The generated password.
544
+ * @param {object} req - The request object
545
+ * @returns {string} - The generated password
522
546
  */
523
547
  generatePassword = (req = {}) => {
524
548
  const { get } = this.app.lib._
@@ -557,8 +581,8 @@ async function factory (pkgName) {
557
581
  *
558
582
  * @async
559
583
  * @method
560
- * @param {string|number} id - The user ID.
561
- * @returns {Promise<string>} - A promise that resolves to the API key.
584
+ * @param {string|number} id - The user ID
585
+ * @returns {Promise<string>} - A promise that resolves to the API key
562
586
  */
563
587
  getApiKeyFromUserId = async id => {
564
588
  const options = { forceNoHidden: true, noHook: true, noCache: true, attachment: true, mimeType: true }
@@ -571,7 +595,7 @@ async function factory (pkgName) {
571
595
  *
572
596
  * @async
573
597
  * @method
574
- * @returns {Promise<Array<{ value: string|number, text: string }>>} - A promise that resolves to an array of country values and names.
598
+ * @returns {Promise<Array<{ value: string|number, text: string }>>} - A promise that resolves to an array of country values and names
575
599
  */
576
600
  getCountriesValues = async () => {
577
601
  const { getModel } = this.app.dobo
@@ -582,14 +606,13 @@ async function factory (pkgName) {
582
606
 
583
607
  /**
584
608
  * Method to send mail through Masohi Messaging System. It is a thin wrapper
585
- * for {@link https://github.com/ardhi/masohi-mail|masohi-mail} send method.
586
- *
587
- * If both masohiMail and waibu are not loaded, nothing is delivered.
609
+ * for {@link https://github.com/ardhi/masohi-mail|masohi-mail} send method
588
610
  *
611
+ * If both masohiMail and waibu are not loaded, nothing is delivered
589
612
  * @method
590
613
  * @async
591
614
  * @param {(string|Array)} tpl - Mail's template to use. If a string is given, the same template will be used for html & plaintext versions. Otherwise, the first template will be used for html mail, and the second one is for it's plaintext version
592
- * @param {Object} [params={}] - {@link https://github.com/ardhi/masohi-mail|masohi-mail}'s params object.
615
+ * @param {Object} [params={}] - {@link https://github.com/ardhi/masohi-mail|masohi-mail}'s params object
593
616
  */
594
617
  sendMail = async (tpl, { payload = {}, conn, source, options = {} } = {}) => {
595
618
  if (!this.app.masohiMail || !this.app.waibu) return
@@ -614,12 +637,11 @@ async function factory (pkgName) {
614
637
  }
615
638
 
616
639
  /**
617
- * Reset token by generating a new salt and hashing it twice to create a new token.
618
- *
640
+ * Reset token by generating a new salt and hashing it twice to create a new token
619
641
  * @async
620
642
  * @method
621
- * @param {string} [text] - Optional text to use as the salt. If not provided, a new salt will be generated.
622
- * @returns {Promise<{ salt: string, token: string }>} - A promise that resolves to an object containing the salt and token.
643
+ * @param {string} [text] - Optional text to use as the salt. If not provided, a new salt will be generated
644
+ * @returns {Promise<{ salt: string, token: string }>} - A promise that resolves to an object containing the salt and token
623
645
  */
624
646
  resetToken = async (text) => {
625
647
  const { generateId } = this.app.lib.aneka
@@ -629,12 +651,11 @@ async function factory (pkgName) {
629
651
  }
630
652
 
631
653
  /**
632
- * Generate a password validation rule based on the configuration settings.
633
- *
654
+ * Generate a password validation rule based on the configuration settings
634
655
  * @async
635
656
  * @method
636
- * @param {object} req - The request object.
637
- * @returns {object} - The Joi password validation rule.
657
+ * @param {object} req - The request object
658
+ * @returns {object} - The Joi password validation rule
638
659
  */
639
660
  passwordRule = async (req = {}) => {
640
661
  const { get } = this.app.lib._
@@ -657,12 +678,11 @@ async function factory (pkgName) {
657
678
  }
658
679
 
659
680
  /**
660
- * Hash the given item using the specified algorithm from the configuration.
661
- *
681
+ * Hash the given item using the specified algorithm from the configuration
662
682
  * @async
663
683
  * @method
664
- * @param {*} item - The item to be hashed.
665
- * @returns {Promise<string>} - A promise that resolves to the hashed value.
684
+ * @param {*} item - The item to be hashed
685
+ * @returns {Promise<string>} - A promise that resolves to the hashed value
666
686
  */
667
687
  hash = async (item) => {
668
688
  const { hash } = this.app.bajoExtra
@@ -671,13 +691,12 @@ async function factory (pkgName) {
671
691
  }
672
692
 
673
693
  /**
674
- * Fetch guards of the specified type from the database.
675
- *
694
+ * Fetch guards of the specified type from the database
676
695
  * @async
677
696
  * @method
678
697
  * @private
679
- * @param {string} type - The type of guards to fetch. Available types are 'Action', 'Attrib', 'Query', 'Secure', and 'Anonymous'.
680
- * @returns {Promise<Array>} - A promise that resolves to an array of guards.
698
+ * @param {string} type - The type of guards to fetch. Available types are 'Action', 'Attrib', 'Query', 'Secure', and 'Anonymous'
699
+ * @returns {Promise<Array>} - A promise that resolves to an array of guards
681
700
  */
682
701
  _fetchGuards = async (type) => {
683
702
  const { getModel } = this.app.dobo
@@ -691,12 +710,11 @@ async function factory (pkgName) {
691
710
  }
692
711
 
693
712
  /**
694
- * Process and order the guards based on their path and weight.
695
- *
713
+ * Process and order the guards based on their path and weight
696
714
  * @method
697
715
  * @private
698
- * @param {Array} inputs - The array of guard inputs.
699
- * @returns {Array} - The processed and ordered array of guards.
716
+ * @param {Array} inputs - The array of guard inputs
717
+ * @returns {Array} - The processed and ordered array of guards
700
718
  */
701
719
  _getGuards = (inputs = []) => {
702
720
  const { routePath } = this.app.waibu
@@ -721,12 +739,11 @@ async function factory (pkgName) {
721
739
  }
722
740
 
723
741
  /**
724
- * Get anonymous guards, optionally reloading them from the database.
725
- *
742
+ * Get anonymous guards, optionally reloading them from the database
726
743
  * @async
727
744
  * @method
728
- * @param {boolean} [reread] - Whether to reload the guards from the database.
729
- * @returns {Promise<Array>} - A promise that resolves to an array of anonymous guards.
745
+ * @param {boolean} [reread] - Whether to reload the guards from the database
746
+ * @returns {Promise<Array>} - A promise that resolves to an array of anonymous guards
730
747
  */
731
748
  getAnonymousGuards = async (reread) => {
732
749
  if (!reread) return this.anonymousGuards
@@ -736,12 +753,11 @@ async function factory (pkgName) {
736
753
  }
737
754
 
738
755
  /**
739
- * Get secure guards, optionally reloading them from the database.
740
- *
756
+ * Get secure guards, optionally reloading them from the database
741
757
  * @async
742
758
  * @method
743
- * @param {boolean} [reread] - Whether to reload the guards from the database.
744
- * @returns {Promise<Array>} - A promise that resolves to an array of secure guards.
759
+ * @param {boolean} [reread] - Whether to reload the guards from the database
760
+ * @returns {Promise<Array>} - A promise that resolves to an array of secure guards
745
761
  */
746
762
  getSecureGuards = async (reread) => {
747
763
  if (!reread) return this.secureGuards
@@ -751,12 +767,11 @@ async function factory (pkgName) {
751
767
  }
752
768
 
753
769
  /**
754
- * Get query guards, optionally reloading them from the database.
755
- *
770
+ * Get query guards, optionally reloading them from the database
756
771
  * @async
757
772
  * @method
758
- * @param {boolean} [reread] - Whether to reload the guards from the database.
759
- * @returns {Promise<Array>} - A promise that resolves to an array of query guards.
773
+ * @param {boolean} [reread] - Whether to reload the guards from the database
774
+ * @returns {Promise<Array>} - A promise that resolves to an array of query guards
760
775
  */
761
776
  getQueryGuards = async (reread) => {
762
777
  if (!reread) return this.queryGuards
@@ -766,12 +781,11 @@ async function factory (pkgName) {
766
781
  }
767
782
 
768
783
  /**
769
- * Get action guards, optionally reloading them from the database.
770
- *
784
+ * Get action guards, optionally reloading them from the database
771
785
  * @async
772
786
  * @method
773
- * @param {boolean} [reread] - Whether to reload the guards from the database.
774
- * @returns {Promise<Array>} - A promise that resolves to an array of action guards.
787
+ * @param {boolean} [reread] - Whether to reload the guards from the database
788
+ * @returns {Promise<Array>} - A promise that resolves to an array of action guards
775
789
  */
776
790
  getActionGuards = async (reread) => {
777
791
  if (!reread) return this.actionGuards
@@ -781,12 +795,11 @@ async function factory (pkgName) {
781
795
  }
782
796
 
783
797
  /**
784
- * Get attribute guards, optionally reloading them from the database.
785
- *
798
+ * Get attribute guards, optionally reloading them from the database
786
799
  * @async
787
800
  * @method
788
- * @param {boolean} [reread] - Whether to reload the guards from the database.
789
- * @returns {Promise<Array>} - A promise that resolves to an array of attribute guards.
801
+ * @param {boolean} [reread] - Whether to reload the guards from the database
802
+ * @returns {Promise<Array>} - A promise that resolves to an array of attribute guards
790
803
  */
791
804
  getAttribGuards = async (reread) => {
792
805
  if (!reread) return this.attribGuards
@@ -796,11 +809,10 @@ async function factory (pkgName) {
796
809
  }
797
810
 
798
811
  /**
799
- * Get all loaded model names, optionally returning them as value-text pairs.
800
- *
812
+ * Get all loaded model names, optionally returning them as value-text pairs
801
813
  * @method
802
- * @param {boolean} [asValue] - Whether to return the model names as value-text pairs.
803
- * @returns {Array} - An array of model names or value-text pairs.
814
+ * @param {boolean} [asValue] - Whether to return the model names as value-text pairs
815
+ * @returns {Array} - An array of model names or value-text pairs
804
816
  */
805
817
  getModelNames = (asValue) => {
806
818
  const values = this.app.dobo.models.map(item => item.name).sort()
@@ -808,11 +820,10 @@ async function factory (pkgName) {
808
820
  }
809
821
 
810
822
  /**
811
- * Gather all paths to check for a request.
812
- *
823
+ * Gather all paths to check for a request
813
824
  * @method
814
- * @param {Object} req - The request object.
815
- * @returns {Array} - An array of paths to check.
825
+ * @param {Object} req - The request object
826
+ * @returns {Array} - An array of paths to check
816
827
  */
817
828
  pathsToCheck = (req) => {
818
829
  const { isSet } = this.app.lib.aneka
@@ -822,13 +833,12 @@ async function factory (pkgName) {
822
833
  }
823
834
 
824
835
  /**
825
- * Check and set the iconset for a request.
826
- *
836
+ * Check and set the iconset for a request
827
837
  * @async
828
838
  * @method
829
- * @param {Object} req - The request object.
830
- * @param {Object} reply - The reply object.
831
- * @returns {Promise<void>} - A promise that resolves when the iconset is checked and set.
839
+ * @param {Object} req - The request object
840
+ * @param {Object} reply - The reply object
841
+ * @returns {Promise<void>} A promise that resolves when the iconset is checked and set
832
842
  */
833
843
  checkIconset = async (req, reply) => {
834
844
  const { get, isString } = this.app.lib._
@@ -843,13 +853,12 @@ async function factory (pkgName) {
843
853
  }
844
854
 
845
855
  /**
846
- * Check and set the theme for a request.
847
- *
856
+ * Check and set the theme for a request
848
857
  * @async
849
858
  * @method
850
- * @param {Object} req - The request object.
851
- * @param {Object} reply - The reply object.
852
- * @returns {Promise<void>} - A promise that resolves when the theme is checked and set.
859
+ * @param {Object} req - The request object
860
+ * @param {Object} reply - The reply object
861
+ * @returns {Promise<void>} A promise that resolves when the theme is checked and set
853
862
  */
854
863
  checkTheme = async (req, reply) => {
855
864
  const { get, isString } = this.app.lib._
@@ -864,13 +873,12 @@ async function factory (pkgName) {
864
873
  }
865
874
 
866
875
  /**
867
- * Check and set the team for a request.
868
- *
876
+ * Check and set the team for a request
869
877
  * @async
870
878
  * @method
871
- * @param {Object} req - The request object.
872
- * @param {Object} reply - The reply object.
873
- * @returns {Promise<void>} - A promise that resolves when the team is checked and set.
879
+ * @param {Object} req - The request object
880
+ * @param {Object} reply - The reply object
881
+ * @returns {Promise<void>} A promise that resolves when the team is checked and set
874
882
  */
875
883
  checkTeam = async (req, reply) => {
876
884
  const { includes } = this.app.lib.aneka
@@ -895,14 +903,13 @@ async function factory (pkgName) {
895
903
  }
896
904
 
897
905
  /**
898
- * Check and set the user for a request.
899
- *
906
+ * Check and set the user for a request
900
907
  * @async
901
908
  * @method
902
- * @param {Object} req - The request object.
903
- * @param {Object} reply - The reply object.
904
- * @param {Object} source - The source object.
905
- * @returns {Promise<boolean|void>} - A promise that resolves to a boolean indicating the result of the check or void.
909
+ * @param {Object} req - The request object
910
+ * @param {Object} reply - The reply object
911
+ * @param {Object} source - The source object
912
+ * @returns {Promise<boolean|void>} A promise that resolves to a boolean indicating the result of the check or void
906
913
  */
907
914
  checkUser = async (req, reply, source) => {
908
915
  const { merge, isEmpty, camelCase, get } = this.app.lib._
@@ -965,13 +972,12 @@ async function factory (pkgName) {
965
972
  }
966
973
 
967
974
  /**
968
- * Check and set the Cross-site settings for a request.
969
- *
975
+ * Check and set the Cross-site settings for a request
970
976
  * @async
971
977
  * @method
972
- * @param {Object} req - The request object.
973
- * @param {Object} reply - The reply object.
974
- * @returns {Promise<void>} - A promise that resolves when the XSite is checked and set.
978
+ * @param {Object} req - The request object
979
+ * @param {Object} reply - The reply object
980
+ * @returns {Promise<void>} A promise that resolves when the XSite is checked and set
975
981
  */
976
982
  checkXSite = async (req, reply) => {
977
983
  const { get } = this.app.lib._
@@ -982,12 +988,11 @@ async function factory (pkgName) {
982
988
  }
983
989
 
984
990
  /**
985
- * Check the route for a request.
986
- *
991
+ * Check the route for a request
987
992
  * @async
988
993
  * @method
989
- * @param {Object} req - The request object.
990
- * @returns {Promise<void>} - A promise that resolves when the route is checked.
994
+ * @param {Object} req - The request object
995
+ * @returns {Promise<void>} A promise that resolves when the route is checked
991
996
  */
992
997
  checkRoute = async (req) => {
993
998
  const { routePath } = this.app.waibu
@@ -1000,12 +1005,11 @@ async function factory (pkgName) {
1000
1005
  }
1001
1006
 
1002
1007
  /**
1003
- * Parse namespace settings for a request.
1004
- *
1008
+ * Parse namespace settings for a request
1005
1009
  * @method
1006
- * @param {string} ns - The namespace.
1007
- * @param {Object} setting - The setting object.
1008
- * @param {Array} items - The items to parse.
1010
+ * @param {string} ns - The namespace
1011
+ * @param {Object} setting - The setting object
1012
+ * @param {Array} items - The items to parse
1009
1013
  */
1010
1014
  parseNsSettings = (ns, setting, items) => {
1011
1015
  const { trim, set, isPlainObject, isArray, isEmpty, find } = this.app.lib._
@@ -1035,12 +1039,11 @@ async function factory (pkgName) {
1035
1039
  }
1036
1040
 
1037
1041
  /**
1038
- * Get all fixtures for the specified alias, replacing any occurrences of '{alias}' in the fixture data with the provided alias.
1039
- *
1042
+ * Get all fixtures for the specified alias, replacing any occurrences of '{alias}' in the fixture data with the provided alias
1040
1043
  * @async
1041
1044
  * @method
1042
- * @param {string} [alias] - The alias for the fixtures.
1043
- * @returns {Promise<object>} - A promise that resolves to the fixtures data.
1045
+ * @param {string} [alias] - The alias for the fixtures
1046
+ * @returns {Promise<object>} A promise that resolves to the fixtures data
1044
1047
  */
1045
1048
  getAllFixtures = async (alias) => {
1046
1049
  const { readConfig } = this.app.bajo
@@ -1096,13 +1099,12 @@ async function factory (pkgName) {
1096
1099
 
1097
1100
  /**
1098
1101
  * Create references for the specified site using the provided data, options, and verbosity settings.
1099
- *
1100
1102
  * @async
1101
1103
  * @method
1102
- * @param {object} site - The site object for which to create references.
1103
- * @param {object} data - The data object containing fixtures for the site.
1104
- * @param {object} options - Options to pass to the createRecord method.
1105
- * @param {boolean} verbose - Whether to log verbose output.
1104
+ * @param {object} site - The site object for which to create references
1105
+ * @param {object} data - The data object containing fixtures for the site
1106
+ * @param {object} options - Options to pass to the createRecord method
1107
+ * @param {boolean} verbose - Whether to log verbose output
1106
1108
  */
1107
1109
  createRefs = async (site, data, options, verbose) => {
1108
1110
  const { isString } = this.app.lib._
@@ -1128,12 +1130,11 @@ async function factory (pkgName) {
1128
1130
 
1129
1131
  /**
1130
1132
  * Create a new site with the specified alias and optional hostname, using fixtures for initial data.
1131
- *
1132
1133
  * @async
1133
1134
  * @method
1134
- * @param {string} alias - The alias for the new site.
1135
- * @param {string} [hostname] - The hostname for the new site.
1136
- * @param {boolean} [verbose=false] - Whether to log verbose output.
1135
+ * @param {string} alias - The alias for the new site
1136
+ * @param {string} [hostname] - The hostname for the new site
1137
+ * @param {boolean} [verbose=false] - Whether to log verbose output
1137
1138
  */
1138
1139
  createNewSite = async (alias, hostname, verbose) => {
1139
1140
  const { isEmpty } = this.app.lib._
@@ -1166,12 +1167,11 @@ async function factory (pkgName) {
1166
1167
 
1167
1168
  /**
1168
1169
  * Remove references for the specified site using the provided options and verbosity settings.
1169
- *
1170
1170
  * @async
1171
1171
  * @method
1172
- * @param {object} site - The site object for which to remove references.
1173
- * @param {object} options - Options to pass to the removeRecord method.
1174
- * @param {boolean} verbose - Whether to log verbose output.
1172
+ * @param {object} site - The site object for which to remove references
1173
+ * @param {object} options - Options to pass to the removeRecord method
1174
+ * @param {boolean} verbose - Whether to log verbose output
1175
1175
  */
1176
1176
  removeRefs = async (site, options, verbose) => {
1177
1177
  const { orderBy } = this.app.lib._
@@ -1195,11 +1195,10 @@ async function factory (pkgName) {
1195
1195
 
1196
1196
  /**
1197
1197
  * Remove a site with the specified alias, along with its references, using the provided verbosity settings.
1198
- *
1199
1198
  * @async
1200
1199
  * @method
1201
- * @param {string} alias - The alias of the site to remove.
1202
- * @param {boolean} [verbose=false] - Whether to log verbose output.
1200
+ * @param {string} alias - The alias of the site to remove
1201
+ * @param {boolean} [verbose=false] - Whether to log verbose output
1203
1202
  */
1204
1203
  removeSite = async (alias, verbose) => {
1205
1204
  const { isEmpty } = this.app.lib._
@@ -1221,12 +1220,11 @@ async function factory (pkgName) {
1221
1220
 
1222
1221
  /**
1223
1222
  * Get site information based on the provided input, which can be either a hostname or an ID. If multi-site is enabled, it will fetch the site based on the hostname or ID; otherwise, it will return the default site.
1224
- *
1225
1223
  * @async
1226
1224
  * @method
1227
- * @param {string|number} input - The input value, which can be either a hostname or an ID.
1228
- * @param {boolean} [byId=false] - Whether to fetch the site by ID.
1229
- * @returns {object} The site information.
1225
+ * @param {string|number} input - The input value, which can be either a hostname or an ID
1226
+ * @param {boolean} [byId=false] - Whether to fetch the site by ID
1227
+ * @returns {object} The site information
1230
1228
  */
1231
1229
  getSite = async (input, byId = false) => {
1232
1230
  const { omit } = this.app.lib._
@@ -1298,12 +1296,12 @@ async function factory (pkgName) {
1298
1296
  }
1299
1297
 
1300
1298
  /**
1301
- * Merge team information into the user object.
1299
+ * Merge team information into the user object
1302
1300
  *
1303
1301
  * @async
1304
1302
  * @method
1305
- * @param {object} user - The user object to merge team information into.
1306
- * @param {object} req - The request object.
1303
+ * @param {object} user - The user object to merge team information into
1304
+ * @param {object} req - The request object
1307
1305
  */
1308
1306
  mergeTeam = async (user, req) => {
1309
1307
  const { map, pick } = this.app.lib._
@@ -1344,12 +1342,11 @@ async function factory (pkgName) {
1344
1342
 
1345
1343
  /**
1346
1344
  * Get a user by their ID.
1347
- *
1348
1345
  * @async
1349
1346
  * @method
1350
- * @param {string|number} id - The ID of the user to retrieve.
1351
- * @param {object} req - The request object.
1352
- * @returns {object|null} The user object if found, otherwise null.
1347
+ * @param {string|number} id - The ID of the user to retrieve
1348
+ * @param {object} req - The request object
1349
+ * @returns {object|null} The user object if found, otherwise null
1353
1350
  */
1354
1351
  getUserById = async (id, req) => {
1355
1352
  const { getModel } = this.app.dobo
@@ -1371,12 +1368,11 @@ async function factory (pkgName) {
1371
1368
 
1372
1369
  /**
1373
1370
  * Get a user by their token.
1374
- *
1375
1371
  * @async
1376
1372
  * @method
1377
- * @param {string} token - The token of the user to retrieve.
1378
- * @param {object} req - The request object.
1379
- * @returns {object|null} The user object if found, otherwise null.
1373
+ * @param {string} token - The token of the user to retrieve
1374
+ * @param {object} req - The request object
1375
+ * @returns {object|null} The user object if found, otherwise null
1380
1376
  */
1381
1377
  getUserByToken = async (token, req) => {
1382
1378
  const { getModel } = this.app.dobo
@@ -1415,11 +1411,10 @@ async function factory (pkgName) {
1415
1411
 
1416
1412
  /**
1417
1413
  * Clear the cache for a specific site.
1418
- *
1419
1414
  * @async
1420
1415
  * @method
1421
- * @param {string|number} id - The ID of the site.
1422
- * @param {object} result - The result object containing site data.
1416
+ * @param {string|number} id - The ID of the site
1417
+ * @param {object} result - The result object containing site data
1423
1418
  */
1424
1419
  clearCacheSite = async (id, result) => {
1425
1420
  if (!this.app.bajoCache) return
@@ -1432,11 +1427,10 @@ async function factory (pkgName) {
1432
1427
 
1433
1428
  /**
1434
1429
  * Clear the cache for a specific user.
1435
- *
1436
1430
  * @async
1437
1431
  * @method
1438
- * @param {string|number} id - The ID of the user.
1439
- * @param {object} result - The result object containing user data.
1432
+ * @param {string|number} id - The ID of the user
1433
+ * @param {object} result - The result object containing user data
1440
1434
  */
1441
1435
  clearCacheUser = async (id, result) => {
1442
1436
  if (!this.app.bajoCache) return
@@ -1449,13 +1443,12 @@ async function factory (pkgName) {
1449
1443
 
1450
1444
  /**
1451
1445
  * Filter model data based on settings.
1452
- *
1453
1446
  * @method
1454
- * @param {object} opts - The options object.
1455
- * @param {object} opts.model - The model object.
1456
- * @param {string} opts.field - The field to filter.
1457
- * @param {object} [opts.options={}] - Additional options.
1458
- * @returns {object} The filtered results and operation values.
1447
+ * @param {object} opts - The options object
1448
+ * @param {object} opts.model - The model object
1449
+ * @param {string} opts.field - The field to filter
1450
+ * @param {object} [opts.options={}] - Additional options
1451
+ * @returns {object} The filtered results and operation values
1459
1452
  */
1460
1453
  filterModelFromSetting = (opts = {}) => {
1461
1454
  const { model, field, options = {} } = opts
@@ -1486,14 +1479,13 @@ async function factory (pkgName) {
1486
1479
 
1487
1480
  /**
1488
1481
  * Apply query guards to the provided query.
1489
- *
1490
1482
  * @async
1491
1483
  * @method
1492
- * @param {object} [opts={}] - The options object.
1493
- * @param {object} opts.model - The model object.
1494
- * @param {object} [opts.q={}] - The query object.
1495
- * @param {array} [opts.teamIds=[]] - The team IDs.
1496
- * @param {object} [opts.options={}] - Additional options.
1484
+ * @param {object} [opts={}] - The options object
1485
+ * @param {object} opts.model - The model object
1486
+ * @param {object} [opts.q={}] - The query object
1487
+ * @param {array} [opts.teamIds=[]] - The team IDs
1488
+ * @param {object} [opts.options={}] - Additional options
1497
1489
  */
1498
1490
  runQueryGuard = async (opts = {}) => {
1499
1491
  const { model, q = {}, teamIds = [], options = {} } = opts
@@ -1539,13 +1531,12 @@ async function factory (pkgName) {
1539
1531
 
1540
1532
  /**
1541
1533
  * Apply attribute guards to the provided model.
1542
- *
1543
1534
  * @async
1544
1535
  * @method
1545
- * @param {object} [opts={}] - The options object.
1546
- * @param {object} opts.model - The model object.
1547
- * @param {array} [opts.teamIds=[]] - The team IDs.
1548
- * @param {object} [opts.options={}] - Additional options.
1536
+ * @param {object} [opts={}] - The options object
1537
+ * @param {object} opts.model - The model object
1538
+ * @param {array} [opts.teamIds=[]] - The team IDs
1539
+ * @param {object} [opts.options={}] - Additional options
1549
1540
  */
1550
1541
  runAttribGuard = async (opts = {}) => {
1551
1542
  const { model, teamIds = [], options = {} } = opts
@@ -1569,10 +1560,9 @@ async function factory (pkgName) {
1569
1560
 
1570
1561
  /**
1571
1562
  * Get the team IDs and aliases for the user in the request.
1572
- *
1573
1563
  * @method
1574
- * @param {object} req - The request object.
1575
- * @returns {object} An object containing the team IDs and aliases.
1564
+ * @param {object} req - The request object
1565
+ * @returns {object} An object containing the team IDs and aliases
1576
1566
  */
1577
1567
  getTeamIdsAndAliases = (req) => {
1578
1568
  const { get } = this.app.lib._
@@ -1584,13 +1574,12 @@ async function factory (pkgName) {
1584
1574
 
1585
1575
  /**
1586
1576
  * Rebuild the filter for the provided model.
1587
- *
1588
1577
  * @async
1589
1578
  * @method
1590
- * @param {object} model - The model object.
1591
- * @param {object} [filter={}] - The filter object.
1592
- * @param {object} [options={}] - Additional options.
1593
- * @returns {Promise<object>} The rebuilt filter.
1579
+ * @param {object} model - The model object
1580
+ * @param {object} [filter={}] - The filter object
1581
+ * @param {object} [options={}] - Additional options
1582
+ * @returns {Promise<object>} The rebuilt filter
1594
1583
  */
1595
1584
  rebuildFilter = async (model, filter = {}, options = {}) => {
1596
1585
  const { isEmpty, get, keys } = this.app.lib._
@@ -1661,13 +1650,12 @@ async function factory (pkgName) {
1661
1650
 
1662
1651
  /**
1663
1652
  * Apply query hook to the provided model.
1664
- *
1665
1653
  * @async
1666
1654
  * @method
1667
- * @param {object} model - The model object.
1668
- * @param {string|number} id - The ID of the model.
1669
- * @param {object} options - Additional options.
1670
- * @returns {object} The result of the model hook.
1655
+ * @param {object} model - The model object
1656
+ * @param {string|number} id - The ID of the model
1657
+ * @param {object} options - Additional options
1658
+ * @returns {object} The result of the model hook
1671
1659
  */
1672
1660
  applyQueryHook = async (model, id, options = {}) => {
1673
1661
  const { isEmpty } = this.app.lib._
@@ -1684,13 +1672,12 @@ async function factory (pkgName) {
1684
1672
 
1685
1673
  /**
1686
1674
  * Apply action hook to the provided model.
1687
- *
1688
1675
  * @async
1689
1676
  * @method
1690
- * @param {object} [opts={}] - The options object.
1691
- * @param {object} opts.model - The model object.
1692
- * @param {array} [opts.teamIds=[]] - The team IDs.
1693
- * @param {object} [opts.options={}] - Additional options.
1677
+ * @param {object} [opts={}] - The options object
1678
+ * @param {object} opts.model - The model object
1679
+ * @param {array} [opts.teamIds=[]] - The team IDs
1680
+ * @param {object} [opts.options={}] - Additional options
1694
1681
  */
1695
1682
  applyActionHook = async (opts = {}) => {
1696
1683
  const { model, options = {} } = opts
@@ -1712,13 +1699,12 @@ async function factory (pkgName) {
1712
1699
 
1713
1700
  /**
1714
1701
  * Check if the specified action is allowed for the given model and request. It retrieves the action guards, filters them based on the site ID, model name, and team IDs, and checks if the action is included in the allowed values. If any guard denies the action, it returns false; otherwise, it returns true.
1715
- *
1716
1702
  * @async
1717
1703
  * @method
1718
- * @param {string} action - The action to check. Available actions are: 'READ', 'CREATE', 'UPDATE', 'REMOVE' and 'EXPORT'.
1719
- * @param {object} model - The model object.
1720
- * @param {object} req - The request object.
1721
- * @returns {Promise<boolean>} - Returns true if the action is allowed, otherwise false.
1704
+ * @param {string} action - The action to check. Available actions are: 'READ', 'CREATE', 'UPDATE', 'REMOVE' and 'EXPORT'
1705
+ * @param {object} model - The model object
1706
+ * @param {object} req - The request object
1707
+ * @returns {Promise<boolean>} - Returns true if the action is allowed, otherwise false
1722
1708
  */
1723
1709
  isActionAllowed = async (action, model, req) => {
1724
1710
  const { includes } = this.app.lib.aneka