@samet-it/be-db-common 1.1.2 → 1.1.4

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.
@@ -4,18 +4,26 @@ import type { DefDims, Portion, View } from "@samet-it/be-base-common";
4
4
  import type { QueryAny, QueryRegular } from "@leyyo/query";
5
5
  import type { CacheConnectionLike, CacheChannelLike } from "@samet-it/be-cache-common";
6
6
  import type { KeyValue, StrKey } from "@leyyo/common";
7
- /**
8
- * Urn delimiter literals (options)
9
- * */
10
- export type UrnDelimiter = ',' | '|' | ';' | '/';
11
7
  /**
12
8
  * DB repository interface
9
+ *
10
+ * Generics:
11
+ * - 0-`CONN`: db connection {@link DbConnectionBase}
12
+ * - 1-`OPT`: db execution options {@link DbExecOpt}
13
+ * - 2-`ENT`: entity {@link Entity}
14
+ * - 3-`ID`: id type {@link KeyValue}
15
+ * - 4-`URN`: urn interface {@link UrnDocLike}
16
+ * - 5-`VIEW`: view interface for presentation layer {@link View}
17
+ * - 6-`PAIR`: pair interface for presentation layer {@link Pair}
18
+ * - 7-`PORTION`: portion interface for presentation layer {@link Portion}
19
+ * - 8-`KEYS`: keys to autocomplete, def: keys of {@link Entity}
20
+ * - 9-`DIMS`: dimensions for presentation layer {@link DefDims}
13
21
  * */
14
- export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt, ID extends KeyValue, ENTITY extends Entity<ID>, URN extends UrnDocLike, KEYS extends string, DIMS extends DefDims, PAIR extends Pair<ID>, VIEW extends View<ID>, PORTION extends Portion<ID>> {
22
+ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt, ENT extends Entity<ID>, ID extends KeyValue, URN extends UrnDocLike, VIEW extends View<ID>, PAIR extends Pair<ID>, PORTION extends Portion<ID>, KEYS extends string, DIMS extends DefDims> {
15
23
  /**
16
24
  * Props on repository
17
25
  * */
18
- get props(): Readonly<DbRepoProps<CONN, ID, ENTITY>>;
26
+ get props(): Readonly<DbRepoProps<CONN, ENT, ID>>;
19
27
  /**
20
28
  * Casts current instance to given type
21
29
  * */
@@ -42,7 +50,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
42
50
  * @return {Promise<Entity?>} - document
43
51
  * @async
44
52
  * */
45
- get(key: KeyValue, opt?: OPT | string): Promise<ENTITY | undefined>;
53
+ get(key: KeyValue, opt?: OPT | string): Promise<ENT | undefined>;
46
54
  /**
47
55
  * Get document by primary key
48
56
  *
@@ -52,7 +60,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
52
60
  * @return {Promise<Entity?>} - document
53
61
  * @async
54
62
  * */
55
- getByPrimary(key: string, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
63
+ getByPrimary(key: string, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
56
64
  /**
57
65
  * Get document by primary key without cache
58
66
  *
@@ -62,7 +70,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
62
70
  * @return {Promise<Entity?>} - document
63
71
  * @async
64
72
  * */
65
- $getByPrimary(key: string, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
73
+ $getByPrimary(key: string, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
66
74
  /**
67
75
  * Get document by secondary key
68
76
  *
@@ -72,7 +80,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
72
80
  * @return {Promise<Entity?>} - document
73
81
  * @async
74
82
  * */
75
- getBySecondary(key: KeyValue, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
83
+ getBySecondary(key: KeyValue, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
76
84
  /**
77
85
  * Get document by secondary key without cache
78
86
  *
@@ -82,7 +90,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
82
90
  * @return {Promise<Entity?>} - document
83
91
  * @async
84
92
  * */
85
- $getBySecondary(key: KeyValue, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENTITY | undefined>;
93
+ $getBySecondary(key: KeyValue, opt?: OPT | string, ignoreCheck?: boolean): Promise<ENT | undefined>;
86
94
  /**
87
95
  * Document exists by key (primary or secondary)
88
96
  *
@@ -141,7 +149,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
141
149
  * @return {Promise<Array<Entity>>} - documents
142
150
  * @async
143
151
  * */
144
- list(keys: Array<KeyValue>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
152
+ list(keys: Array<KeyValue>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
145
153
  /**
146
154
  * List documents by primary keys
147
155
  *
@@ -151,7 +159,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
151
159
  * @return {Promise<Array<Entity>>} - documents
152
160
  * @async
153
161
  * */
154
- $listByPrimary(keys: string[], opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
162
+ $listByPrimary(keys: string[], opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
155
163
  /**
156
164
  * List documents by secondary keys
157
165
  *
@@ -161,7 +169,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
161
169
  * @return {Promise<Array<Entity>>} - documents
162
170
  * @async
163
171
  * */
164
- $listBySecondary(keys: Array<KeyValue>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENTITY>>;
172
+ $listBySecondary(keys: Array<KeyValue>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<ENT>>;
165
173
  /**
166
174
  * Filter documents
167
175
  *
@@ -170,8 +178,16 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
170
178
  * @return {Promise<Array<Entity>>} - documents
171
179
  * @async
172
180
  * */
173
- filter<R = ENTITY, K2 extends string = StrKey<R>>(query: QueryAny<K2 | KEYS | StrKey<ENTITY>>, opt?: OPT | string): Promise<Array<R>>;
174
- $filter<R = ENTITY, K2 extends string = StrKey<R>>(query: QueryRegular<K2 | KEYS | StrKey<ENTITY>>, opt?: OPT | string): Promise<Array<R>>;
181
+ filter<R = ENT, K2 extends string = StrKey<R>>(query: QueryAny<K2 | KEYS | StrKey<ENT>>, opt?: OPT | string): Promise<Array<R>>;
182
+ /**
183
+ * Filter documents
184
+ *
185
+ * @param {QueryAny} query - query object
186
+ * @param {(opt?: OPT|string)?} opt - option or query name
187
+ * @return {Promise<Array<Entity>>} - documents
188
+ * @async
189
+ * */
190
+ $filter<R = ENT, K2 extends string = StrKey<R>>(query: QueryRegular<K2 | KEYS | StrKey<ENT>>, opt?: OPT | string): Promise<Array<R>>;
175
191
  /**
176
192
  * Insert document
177
193
  *
@@ -180,7 +196,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
180
196
  * @param {boolean?} ignoreCheck - ignores to check input
181
197
  * @async
182
198
  * */
183
- insert(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
199
+ insert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
184
200
  /**
185
201
  * Inserts document
186
202
  *
@@ -189,7 +205,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
189
205
  * @param {boolean?} ignoreCheck - ignores to check input
190
206
  * @async
191
207
  * */
192
- inserts(docs: Array<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<string>>;
208
+ inserts(docs: Array<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<Array<string>>;
193
209
  /**
194
210
  * Insert document
195
211
  *
@@ -198,7 +214,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
198
214
  * @param {boolean?} ignoreCheck - ignores to check input
199
215
  * @async
200
216
  * */
201
- $insert(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
217
+ $insert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
202
218
  /**
203
219
  * Replace document
204
220
  *
@@ -207,7 +223,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
207
223
  * @param {boolean?} ignoreCheck - ignores to check input
208
224
  * @async
209
225
  * */
210
- replace(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
226
+ replace(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
211
227
  /**
212
228
  * Replace document
213
229
  *
@@ -216,7 +232,25 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
216
232
  * @param {boolean?} ignoreCheck - ignores to check input
217
233
  * @async
218
234
  * */
219
- $replace(doc: ENTITY, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
235
+ $replace(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
236
+ /**
237
+ * Upsert document
238
+ *
239
+ * @param {Entity} doc - document
240
+ * @param {(opt?: OPT|string)?} opt - option or query name
241
+ * @param {boolean?} ignoreCheck - ignores to check input
242
+ * @async
243
+ * */
244
+ upsert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
245
+ /**
246
+ * Upsert document
247
+ *
248
+ * @param {Entity} doc - document
249
+ * @param {(opt?: OPT|string)?} opt - option or query name
250
+ * @param {boolean?} ignoreCheck - ignores to check input
251
+ * @async
252
+ * */
253
+ $upsert(doc: ENT, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
220
254
  /**
221
255
  * Update document by key (primary or secondary)
222
256
  *
@@ -227,7 +261,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
227
261
  * @return {Promise<string>}
228
262
  * @async
229
263
  * */
230
- update(key: KeyValue, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
264
+ update(key: KeyValue, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
231
265
  /**
232
266
  * Update document by primary key
233
267
  *
@@ -238,7 +272,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
238
272
  * @return {Promise<string>}
239
273
  * @async
240
274
  * */
241
- updateByPrimary(key: string, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
275
+ updateByPrimary(key: string, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
242
276
  /**
243
277
  * Update document by primary key
244
278
  *
@@ -249,7 +283,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
249
283
  * @return {Promise<string>}
250
284
  * @async
251
285
  * */
252
- $updateByPrimary(key: string, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
286
+ $updateByPrimary(key: string, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
253
287
  /**
254
288
  * Update document by secondary key
255
289
  *
@@ -260,7 +294,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
260
294
  * @return {Promise<string>}
261
295
  * @async
262
296
  * */
263
- updateBySecondary(key: KeyValue, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
297
+ updateBySecondary(key: KeyValue, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
264
298
  /**
265
299
  * Update document by secondary key
266
300
  *
@@ -271,7 +305,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
271
305
  * @return {Promise<string>}
272
306
  * @async
273
307
  * */
274
- $updateBySecondary(key: KeyValue, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
308
+ $updateBySecondary(key: KeyValue, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
275
309
  /**
276
310
  * Set document with partial data by key (primary or secondary)
277
311
  *
@@ -282,7 +316,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
282
316
  * @return {Promise<string>}
283
317
  * @async
284
318
  * */
285
- set(key: KeyValue, doc: Partial<ENTITY>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
319
+ set(key: KeyValue, doc: Partial<ENT>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
286
320
  /**
287
321
  * Unset document for given fields
288
322
  *
@@ -293,7 +327,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
293
327
  * @return {Promise<string>}
294
328
  * @async
295
329
  * */
296
- unset(key: KeyValue, fields: Array<keyof ENTITY | string>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
330
+ unset(key: KeyValue, fields: Array<keyof ENT | KEYS | string>, opt?: OPT | string, ignoreCheck?: boolean): Promise<string>;
297
331
  /**
298
332
  * Remove document (hard delete) by key (primary or secondary)
299
333
  *
@@ -385,15 +419,21 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
385
419
  /**
386
420
  * Convert a document to a dim
387
421
  *
422
+ * Generics
423
+ * - 0-`R`: dim interface {@link IdDocLike}
424
+ *
388
425
  * @param {Entity} doc - document object
389
426
  * @param {string?} dim - dimension, default: `def`
390
427
  * @return {Promise<IdDocLike>} - dim object
391
428
  * @async
392
429
  * */
393
- $toDim<R extends IdDocLike<ID>>(doc: ENTITY, dim?: DIMS): Promise<R>;
430
+ $toDim<R extends IdDocLike<ID>>(doc: ENT, dim?: DIMS): Promise<R>;
394
431
  /**
395
432
  * Get dim by key (primary or secondary)
396
433
  *
434
+ * Generics
435
+ * - 0-`R`: dim interface {@link IdDocLike}
436
+ *
397
437
  * @param {KeyValue} key - primary or secondary key
398
438
  * @param {string?} dim - dimension, default: `def`
399
439
  * @return {Promise<IdDocLike>} - dim object
@@ -403,6 +443,9 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
403
443
  /**
404
444
  * List dims by keys (primary or secondary)
405
445
  *
446
+ * Generics
447
+ * - 0-`R`: dim interface {@link IdDocLike}
448
+ *
406
449
  * @param {Array<string>} keys - primary or secondary keys
407
450
  * @param {string?} dim - dimension, default: `def`
408
451
  * @param {boolean?} ignoreCheck - ignores to check input
@@ -416,7 +459,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
416
459
  * @return {Promise<Pair>} - pair object
417
460
  * @async
418
461
  * */
419
- $toPair(doc: ENTITY): Promise<PAIR>;
462
+ $toPair(doc: ENT): Promise<PAIR>;
420
463
  /**
421
464
  * Get pair by key (primary or secondary)
422
465
  *
@@ -440,7 +483,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
440
483
  * @return {Promise<View>} - view object
441
484
  * @async
442
485
  * */
443
- $toView(doc: ENTITY): Promise<VIEW>;
486
+ $toView(doc: ENT): Promise<VIEW>;
444
487
  /**
445
488
  * Get view by key (primary or secondary)
446
489
  *
@@ -464,7 +507,7 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
464
507
  * @return {Promise<Portion>} - portion object
465
508
  * @async
466
509
  * */
467
- $toPortion(doc: ENTITY): Promise<PORTION>;
510
+ $toPortion(doc: ENT): Promise<PORTION>;
468
511
  /**
469
512
  * Get portion by key (primary or secondary)
470
513
  *
@@ -484,14 +527,18 @@ export interface DbRepoLike<CONN extends DbConnectionBase, OPT extends DbExecOpt
484
527
  }
485
528
  /**
486
529
  * DB repository option
530
+ *
531
+ * Generics:
532
+ * - 0-`ENT`: entity {@link Entity}
533
+ * - 1-`ID`: id type {@link KeyValue}
487
534
  * */
488
- export interface DbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> {
535
+ export interface DbRepoOpt<ENT extends Entity<ID>, ID extends KeyValue> {
489
536
  /**
490
537
  * Cache repository
491
538
  *
492
539
  * @type {CacheChannelLike}
493
540
  * */
494
- cache?: CacheChannelLike<CacheConnectionLike, ID, ENTITY>;
541
+ cache?: CacheChannelLike<CacheConnectionLike, ENT, ID>;
495
542
  /**
496
543
  * Model version
497
544
  *
@@ -603,6 +650,50 @@ export interface DbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> {
603
650
  * @default false
604
651
  * */
605
652
  useRevision?: boolean;
653
+ /**
654
+ * Check insert commands
655
+ * - if yes, it insert works
656
+ * - if no, it insert raises
657
+ *
658
+ * Commands: `insert`, `upsert`
659
+ *
660
+ * @fields `_rev`
661
+ * @default false
662
+ * */
663
+ noInsert?: boolean;
664
+ /**
665
+ * Check update commands
666
+ * - if yes, it update works
667
+ * - if no, it update raises
668
+ *
669
+ * Commands: `update`, `set`, `unset`, `upsert`
670
+ *
671
+ * @fields `_rev`
672
+ * @default false
673
+ * */
674
+ noUpdate?: boolean;
675
+ /**
676
+ * Check trash commands
677
+ * - if yes, it trash works
678
+ * - if no, it trash raises
679
+ *
680
+ * Commands: `trash`
681
+ *
682
+ * @fields `_rev`
683
+ * @default false
684
+ * */
685
+ noTrash?: boolean;
686
+ /**
687
+ * Check remove commands (delete)
688
+ * - if yes, it remove works
689
+ * - if no, it remove raises
690
+ *
691
+ * Commands: `remove`
692
+ *
693
+ * @fields `_rev`
694
+ * @default false
695
+ * */
696
+ noRemove?: boolean;
606
697
  /**
607
698
  * Manages `alpha` or `slug` case, to power auto suggest
608
699
  * - if yes, it builds `_alpha`
@@ -613,7 +704,7 @@ export interface DbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> {
613
704
  * @param {Entity} doc
614
705
  * @async
615
706
  * */
616
- alphaFn?: DbRepoExtensionLambda<ID, ENTITY>;
707
+ alphaFn?: DbRepoExtensionLambda<ENT, ID>;
617
708
  /**
618
709
  * Manages `search` case, to power search
619
710
  * - if yes, it builds `_search`
@@ -624,7 +715,7 @@ export interface DbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> {
624
715
  * @param {Entity} doc
625
716
  * @async
626
717
  * */
627
- searchFn?: DbRepoExtensionLambda<ID, ENTITY>;
718
+ searchFn?: DbRepoExtensionLambda<ENT, ID>;
628
719
  /**
629
720
  * Manages `irregular` case, to store irregular field which is not in model
630
721
  * - if yes, it builds `_irregular`
@@ -635,24 +726,29 @@ export interface DbRepoOpt<ID extends KeyValue, ENTITY extends Entity<ID>> {
635
726
  * @param {Entity} doc
636
727
  * @async
637
728
  * */
638
- irregularFn?: DbRepoExtensionLambda<ID, ENTITY>;
729
+ irregularFn?: DbRepoExtensionLambda<ENT, ID>;
639
730
  /**
640
731
  * Field list which can not be set (update/replace)
641
732
  *
642
733
  * @type {Array<string>}
643
734
  * */
644
- forbiddenSet?: Array<keyof ENTITY>;
735
+ forbiddenSet?: Array<keyof ENT>;
645
736
  /**
646
737
  * Field list which can not be unset (clear,delete)
647
738
  *
648
739
  * @type {Array<string>}
649
740
  * */
650
- forbiddenUnset?: Array<keyof ENTITY>;
741
+ forbiddenUnset?: Array<keyof ENT>;
651
742
  }
652
743
  /**
653
744
  * DB repository props
745
+ *
746
+ * Generics:
747
+ * - 0-`CONN`: db connection {@link DbConnectionBase}
748
+ * - 1-`ENT`: entity {@link Entity}
749
+ * - 2-`ID`: id type {@link KeyValue}
654
750
  * */
655
- export interface DbRepoProps<CONN extends DbConnectionBase, ID extends KeyValue, ENTITY extends Entity<ID>> extends DbRepoOpt<ID, ENTITY> {
751
+ export interface DbRepoProps<CONN extends DbConnectionBase, ENT extends Entity<ID>, ID extends KeyValue> extends DbRepoOpt<ENT, ID> {
656
752
  /**
657
753
  * DB connection
658
754
  *
@@ -680,6 +776,9 @@ export interface DbRepoProps<CONN extends DbConnectionBase, ID extends KeyValue,
680
776
  }
681
777
  /**
682
778
  * DB keys result
779
+ *
780
+ * Generics:
781
+ * - 0-`ID`: id type {@link KeyValue}
683
782
  * */
684
783
  export interface DbCheckKeysResult<ID extends KeyValue> {
685
784
  ids: Array<ID>;
@@ -688,7 +787,13 @@ export interface DbCheckKeysResult<ID extends KeyValue> {
688
787
  }
689
788
  /**
690
789
  * Response model during key is being checked
691
- * @tuple
790
+ *
791
+ * Tuple
792
+ * - 0: urn or id value
793
+ * - 1: field name as _urn or id
794
+ *
795
+ * Generics:
796
+ * - 0-`ID`: id type {@link KeyValue}
692
797
  *
693
798
  * Options
694
799
  * - if primary(urn) => `[value (string), '_urn'];
@@ -698,6 +803,9 @@ export type DbCheckKeysTuple<ID extends KeyValue> = [string, '_urn'] | [ID, 'id'
698
803
  /**
699
804
  * DB `$toUrnTuple` lambda
700
805
  *
806
+ * Generics:
807
+ * - 0-`URN`: urn interface {@link UrnDocLike}
808
+ *
701
809
  * @see {@link DbRepoLike#$toUrnTuple}
702
810
  * @method
703
811
  *
@@ -708,13 +816,19 @@ export type DbRepoToUrnTuple<URN extends UrnDocLike = UrnDocLike> = (urnRec: URN
708
816
  /**
709
817
  * DB `toDim` lambda
710
818
  *
819
+ * Generics:
820
+ * - 0-`R`: dimension interface
821
+ * - 1-`ENT`: entity {@link Entity}
822
+ * - 2-`ID`: id type {@link KeyValue}
823
+ * - 3-`DIMS`: dimensions for presentation layer {@link DefDims}
824
+ *
711
825
  * @see {@link DbRepoLike#$toDim}
712
826
  * @method
713
827
  *
714
828
  * @param {Entity} doc - document
715
829
  * @param {DefDims} dim - dimension
716
830
  * */
717
- export type DbRepoToDim<R, ID extends KeyValue, ENTITY extends Entity<ID>, DIMS extends DefDims = DefDims> = (doc: ENTITY, dim: DIMS | undefined) => Promise<R>;
831
+ export type DbRepoToDim<R, ENT extends Entity<ID>, ID extends KeyValue, DIMS extends DefDims = DefDims> = (doc: ENT, dim: DIMS | undefined) => Promise<R>;
718
832
  /**
719
833
  * Default model which contains keys
720
834
  * */
@@ -741,7 +855,15 @@ export interface DbIdLike {
741
855
  /**
742
856
  * Lambda to handle several extensions, ie: search, ...
743
857
  *
858
+ * Generics:
859
+ * - 0-`ENT`: entity {@link Entity}
860
+ * - 1-`ID`: id type {@link KeyValue}
861
+ *
744
862
  * @param {Entity} doc - document
745
863
  * @async
746
864
  * */
747
- export type DbRepoExtensionLambda<ID extends KeyValue, ENTITY extends Entity<ID>> = (doc: ENTITY) => Promise<void>;
865
+ export type DbRepoExtensionLambda<ENT extends Entity<ID>, ID extends KeyValue> = (doc: ENT) => Promise<void>;
866
+ /**
867
+ * Urn delimiter literals (options)
868
+ * */
869
+ export type UrnDelimiter = ',' | '|' | ';' | '/';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samet-it/be-db-common",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Backend DB Common",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,9 +64,9 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@leyyo/query": "^1.2.2",
67
- "@leyyo/common": "^1.2.1",
67
+ "@leyyo/common": "^1.2.3",
68
68
  "@leyyo/type": "^1.1.1",
69
- "@samet-it/be-base-common": "^1.1.1",
70
- "@samet-it/be-cache-common": "^1.1.1"
69
+ "@samet-it/be-base-common": "^1.1.3",
70
+ "@samet-it/be-cache-common": "^1.1.3"
71
71
  }
72
72
  }