@decaf-ts/db-decorators 0.4.30 → 0.4.32

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 (153) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +0 -0
  3. package/dist/db-decorators.js +2 -0
  4. package/dist/{db-decorators.bundle.min.js.LICENSE.txt → db-decorators.js.LICENSE.txt} +0 -0
  5. package/dist/esm/db-decorators.js +2 -0
  6. package/dist/esm/{db-decorators.bundle.min.esm.js.LICENSE.txt → db-decorators.js.LICENSE.txt} +0 -0
  7. package/{lib/esm → dist/types}/identity/decorators.d.ts +0 -0
  8. package/{lib/esm → dist/types}/identity/index.d.ts +0 -0
  9. package/{lib/esm → dist/types}/identity/utils.d.ts +0 -0
  10. package/{lib/esm → dist/types}/index.d.ts +0 -0
  11. package/{lib/esm → dist/types}/interfaces/BulkCrudOperator.d.ts +0 -0
  12. package/{lib/esm → dist/types}/interfaces/Contextual.d.ts +0 -0
  13. package/{lib/esm → dist/types}/interfaces/CrudOperator.d.ts +0 -0
  14. package/{lib/esm → dist/types}/interfaces/IRepository.d.ts +0 -0
  15. package/{lib/esm → dist/types}/interfaces/index.d.ts +0 -0
  16. package/{lib/esm → dist/types}/model/constants.d.ts +0 -0
  17. package/{lib/esm → dist/types}/model/decorators.d.ts +0 -0
  18. package/{lib/esm → dist/types}/model/index.d.ts +0 -0
  19. package/{lib/esm → dist/types}/model/model.d.ts +0 -0
  20. package/{lib/esm → dist/types}/model/validation.d.ts +0 -0
  21. package/{lib/esm → dist/types}/operations/Operations.d.ts +0 -0
  22. package/{lib/esm → dist/types}/operations/OperationsRegistry.d.ts +0 -0
  23. package/{lib/esm → dist/types}/operations/constants.d.ts +0 -0
  24. package/{lib/esm → dist/types}/operations/decorators.d.ts +0 -0
  25. package/{lib/esm → dist/types}/operations/index.d.ts +0 -0
  26. package/{lib/esm → dist/types}/operations/types.d.ts +0 -0
  27. package/{lib/esm → dist/types}/repository/BaseRepository.d.ts +0 -0
  28. package/{lib/esm → dist/types}/repository/Context.d.ts +0 -0
  29. package/{lib/esm → dist/types}/repository/DataCache.d.ts +0 -0
  30. package/{lib/esm → dist/types}/repository/Repository.d.ts +0 -0
  31. package/{lib/esm → dist/types}/repository/errors.d.ts +0 -0
  32. package/{lib/esm → dist/types}/repository/index.d.ts +0 -0
  33. package/{lib/esm → dist/types}/repository/utils.d.ts +0 -0
  34. package/{lib/esm → dist/types}/repository/wrappers.d.ts +0 -0
  35. package/{lib/esm → dist/types}/validation/constants.d.ts +0 -0
  36. package/{lib/esm → dist/types}/validation/decorators.d.ts +0 -0
  37. package/{lib/esm → dist/types}/validation/index.d.ts +0 -0
  38. package/{lib/esm → dist/types}/validation/validation.d.ts +1 -1
  39. package/{lib/esm → dist/types}/validation/validators/ReadOnlyValidator.d.ts +0 -0
  40. package/{lib/esm → dist/types}/validation/validators/TimestampValidator.d.ts +0 -0
  41. package/{lib/esm → dist/types}/validation/validators/UpdateValidator.d.ts +0 -0
  42. package/{lib/esm → dist/types}/validation/validators/index.d.ts +0 -0
  43. package/lib/esm/identity/decorators.js +0 -0
  44. package/lib/esm/identity/index.js +0 -0
  45. package/lib/esm/identity/utils.js +0 -0
  46. package/lib/esm/index.js +0 -0
  47. package/lib/esm/interfaces/BulkCrudOperator.js +0 -0
  48. package/lib/esm/interfaces/Contextual.js +0 -0
  49. package/lib/esm/interfaces/CrudOperator.js +0 -0
  50. package/lib/esm/interfaces/IRepository.js +0 -0
  51. package/lib/esm/interfaces/index.js +0 -0
  52. package/lib/esm/model/constants.js +0 -0
  53. package/lib/esm/model/decorators.js +0 -0
  54. package/lib/esm/model/index.js +0 -0
  55. package/lib/esm/model/model.js +0 -0
  56. package/lib/esm/model/validation.js +0 -0
  57. package/lib/esm/operations/Operations.js +0 -0
  58. package/lib/esm/operations/OperationsRegistry.js +0 -0
  59. package/lib/esm/operations/constants.js +0 -0
  60. package/lib/esm/operations/decorators.js +0 -0
  61. package/lib/esm/operations/index.js +0 -0
  62. package/lib/esm/operations/types.js +0 -0
  63. package/lib/esm/repository/BaseRepository.js +0 -0
  64. package/lib/esm/repository/Context.js +0 -0
  65. package/lib/esm/repository/DataCache.js +0 -0
  66. package/lib/esm/repository/Repository.js +0 -0
  67. package/lib/esm/repository/errors.js +0 -0
  68. package/lib/esm/repository/index.js +0 -0
  69. package/lib/esm/repository/utils.js +0 -0
  70. package/lib/esm/repository/wrappers.js +0 -0
  71. package/lib/esm/validation/constants.js +0 -0
  72. package/lib/esm/validation/decorators.js +0 -0
  73. package/lib/esm/validation/index.js +0 -0
  74. package/lib/esm/validation/validation.js +1 -1
  75. package/lib/esm/validation/validators/ReadOnlyValidator.js +0 -0
  76. package/lib/esm/validation/validators/TimestampValidator.js +0 -0
  77. package/lib/esm/validation/validators/UpdateValidator.js +20 -0
  78. package/lib/esm/validation/validators/index.js +5 -0
  79. package/lib/identity/decorators.cjs +2 -0
  80. package/lib/identity/index.cjs +2 -0
  81. package/lib/identity/utils.cjs +2 -0
  82. package/lib/index.cjs +2 -0
  83. package/lib/interfaces/BulkCrudOperator.cjs +2 -0
  84. package/lib/interfaces/Contextual.cjs +2 -0
  85. package/lib/interfaces/CrudOperator.cjs +2 -0
  86. package/lib/interfaces/IRepository.cjs +2 -0
  87. package/lib/interfaces/index.cjs +2 -0
  88. package/lib/model/constants.cjs +2 -0
  89. package/lib/model/decorators.cjs +2 -0
  90. package/lib/model/index.cjs +2 -0
  91. package/lib/model/model.cjs +2 -0
  92. package/lib/model/validation.cjs +2 -0
  93. package/lib/operations/Operations.cjs +2 -0
  94. package/lib/operations/OperationsRegistry.cjs +2 -0
  95. package/lib/operations/constants.cjs +2 -0
  96. package/lib/operations/decorators.cjs +2 -0
  97. package/lib/operations/index.cjs +2 -0
  98. package/lib/operations/types.cjs +2 -0
  99. package/lib/repository/BaseRepository.cjs +2 -0
  100. package/lib/repository/Context.cjs +2 -0
  101. package/lib/repository/DataCache.cjs +2 -0
  102. package/lib/repository/Repository.cjs +2 -0
  103. package/lib/repository/errors.cjs +2 -0
  104. package/lib/repository/index.cjs +2 -0
  105. package/lib/repository/utils.cjs +2 -0
  106. package/lib/repository/wrappers.cjs +2 -0
  107. package/lib/validation/constants.cjs +2 -0
  108. package/lib/validation/decorators.cjs +2 -0
  109. package/lib/validation/index.cjs +2 -0
  110. package/lib/validation/validation.cjs +2 -0
  111. package/lib/validation/validators/ReadOnlyValidator.cjs +2 -0
  112. package/lib/validation/validators/TimestampValidator.cjs +2 -0
  113. package/lib/validation/validators/UpdateValidator.cjs +2 -0
  114. package/lib/validation/validators/index.cjs +2 -0
  115. package/package.json +27 -16
  116. package/dist/db-decorators.bundle.min.js +0 -2
  117. package/dist/esm/db-decorators.bundle.min.esm.js +0 -2
  118. package/lib/identity/decorators.d.ts +0 -1
  119. package/lib/identity/index.d.ts +0 -2
  120. package/lib/identity/utils.d.ts +0 -34
  121. package/lib/index.d.ts +0 -33
  122. package/lib/interfaces/BulkCrudOperator.d.ts +0 -7
  123. package/lib/interfaces/Contextual.d.ts +0 -6
  124. package/lib/interfaces/CrudOperator.d.ts +0 -42
  125. package/lib/interfaces/IRepository.d.ts +0 -11
  126. package/lib/interfaces/index.d.ts +0 -4
  127. package/lib/model/constants.d.ts +0 -37
  128. package/lib/model/decorators.d.ts +0 -50
  129. package/lib/model/index.d.ts +0 -4
  130. package/lib/model/model.d.ts +0 -112
  131. package/lib/model/validation.d.ts +0 -14
  132. package/lib/operations/Operations.d.ts +0 -19
  133. package/lib/operations/OperationsRegistry.d.ts +0 -34
  134. package/lib/operations/constants.d.ts +0 -24
  135. package/lib/operations/decorators.d.ts +0 -193
  136. package/lib/operations/index.d.ts +0 -5
  137. package/lib/operations/types.d.ts +0 -29
  138. package/lib/repository/BaseRepository.d.ts +0 -36
  139. package/lib/repository/Context.d.ts +0 -17
  140. package/lib/repository/DataCache.d.ts +0 -9
  141. package/lib/repository/Repository.d.ts +0 -10
  142. package/lib/repository/errors.d.ts +0 -69
  143. package/lib/repository/index.d.ts +0 -7
  144. package/lib/repository/utils.d.ts +0 -62
  145. package/lib/repository/wrappers.d.ts +0 -38
  146. package/lib/validation/constants.d.ts +0 -30
  147. package/lib/validation/decorators.d.ts +0 -58
  148. package/lib/validation/index.d.ts +0 -4
  149. package/lib/validation/validation.d.ts +0 -41
  150. package/lib/validation/validators/ReadOnlyValidator.d.ts +0 -23
  151. package/lib/validation/validators/TimestampValidator.d.ts +0 -14
  152. package/lib/validation/validators/UpdateValidator.d.ts +0 -23
  153. package/lib/validation/validators/index.d.ts +0 -3
@@ -1,34 +0,0 @@
1
- import { OperationHandler } from "./types";
2
- import { OperationKeys } from "./constants";
3
- import { IRepository } from "../interfaces/IRepository";
4
- import { Model } from "@decaf-ts/decorator-validation";
5
- /**
6
- * @summary Holds the registered operation handlers
7
- *
8
- * @class OperationsRegistry
9
- * @implements IRegistry<OperationHandler<any>>
10
- *
11
- * @see OperationHandler
12
- *
13
- * @category Operations
14
- */
15
- export declare class OperationsRegistry {
16
- private readonly cache;
17
- /**
18
- * @summary retrieves an {@link OperationHandler} if it exists
19
- * @param {string} target
20
- * @param {string} propKey
21
- * @param {string} operation
22
- * @param accum
23
- * @return {OperationHandler | undefined}
24
- */
25
- get<T extends Model, V extends IRepository<T>, Y>(target: string | Record<string, any>, propKey: string, operation: string, accum?: OperationHandler<T, V, Y>[]): OperationHandler<T, V, Y>[] | undefined;
26
- /**
27
- * @summary Registers an {@link OperationHandler}
28
- * @param {OperationHandler} handler
29
- * @param {string} operation
30
- * @param {{}} target
31
- * @param {string | symbol} propKey
32
- */
33
- register<T extends Model, V extends IRepository<T>, Y>(handler: OperationHandler<T, V, Y>, operation: OperationKeys, target: T, propKey: string | symbol): void;
34
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * @summary Set of constants to define db CRUD operations and their equivalent 'on' and 'after' phases
3
- * @const OperationKeys
4
- *
5
- * @memberOf module:db-decorators.Operations
6
- */
7
- export declare enum OperationKeys {
8
- REFLECT = "decaf.model.db.operations.",
9
- CREATE = "create",
10
- READ = "read",
11
- UPDATE = "update",
12
- DELETE = "delete",
13
- ON = "on.",
14
- AFTER = "after."
15
- }
16
- export type CrudOperations = OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE;
17
- /**
18
- * @summary Maps out groups of CRUD operations for easier mapping of decorators
19
- *
20
- * @constant DBOperations
21
- *
22
- * @memberOf module:db-decorators.Operations
23
- */
24
- export declare const DBOperations: Record<string, CrudOperations[]>;
@@ -1,193 +0,0 @@
1
- import { IdOperationHandler, OperationHandler, StandardOperationHandler, UpdateOperationHandler } from "./types";
2
- import { OperationKeys } from "./constants";
3
- /**
4
- * @summary Defines a behaviour to set on the defined {@link DBOperations.CREATE_UPDATE}
5
- *
6
- * @param {OnOperationHandler<any>} handler The method called upon the operation
7
- * @param data
8
- * @param {any[]} [args] Arguments that will be passed in order to the handler method
9
- *
10
- * @see on
11
- *
12
- * @function onCreateUpdate
13
- *
14
- * @category Decorators
15
- */
16
- export declare function onCreateUpdate<T>(handler: StandardOperationHandler<any, any, T, any> | UpdateOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
17
- /**
18
- * @summary Defines a behaviour to set on the defined {@link DBOperations.UPDATE}
19
- *
20
- * @param {OnOperationHandler<any>} handler The method called upon the operation
21
- * @param data
22
- * @param {any[]} [args] Arguments that will be passed in order to the handler method
23
- *
24
- * @see on
25
- *
26
- * @function onUpdate
27
- *
28
- * @category Decorators
29
- */
30
- export declare function onUpdate<T>(handler: UpdateOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
31
- /**
32
- * @summary Defines a behaviour to set on the defined {@link DBOperations.CREATE}
33
- *
34
- * @param {OnOperationHandler<any>} handler The method called upon the operation
35
- * @param data
36
- *
37
- * @see on
38
- *
39
- * @function onCreate
40
- *
41
- * @category Decorators
42
- */
43
- export declare function onCreate<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
44
- /**
45
- * @summary Defines a behaviour to set on the defined {@link DBOperations.READ}
46
- *
47
- * @param {OnOperationHandler<any>} handler The method called upon the operation
48
- * @param data
49
- *
50
- * @see on
51
- *
52
- * @function onRead
53
- *
54
- * @category Decorators
55
- */
56
- export declare function onRead<T>(handler: IdOperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
57
- /**
58
- * @summary Defines a behaviour to set on the defined {@link DBOperations.DELETE}
59
- *
60
- * @param {OnOperationHandler<any>} handler The method called upon the operation
61
- * @param data
62
- *
63
- * @see on
64
- *
65
- * @function onDelete
66
- *
67
- * @category Decorators
68
- */
69
- export declare function onDelete<T>(handler: OperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
70
- /**
71
- * @summary Defines a behaviour to set on the defined {@link DBOperations.DELETE}
72
- *
73
- * @param {OnOperationHandler<any>} handler The method called upon the operation
74
- * @param data
75
- *
76
- * @see on
77
- *
78
- * @function onAny
79
- *
80
- * @category Decorators
81
- */
82
- export declare function onAny<T>(handler: OperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
83
- /**
84
- * @summary Defines a behaviour to set on the defined {@link DBOperations}
85
- *
86
- * @param {OperationKeys[] | DBOperations} op One of {@link DBOperations}
87
- * @param {OnOperationHandler<any>} handler The method called upon the operation
88
- * @param data
89
- *
90
- * ex: handler(...args, ...props.map(p => target[p]))
91
- *
92
- * @function on
93
- *
94
- * @category Decorators
95
- */
96
- export declare function on<T>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
97
- /**
98
- * @summary Defines a behaviour to set after the defined {@link DBOperations.CREATE_UPDATE}
99
- *
100
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
101
- * @param data
102
- *
103
- * @see after
104
- *
105
- * @function afterCreateUpdate
106
- *
107
- * @category Decorators
108
- */
109
- export declare function afterCreateUpdate<T>(handler: StandardOperationHandler<any, any, T, any> | UpdateOperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
110
- /**
111
- * @summary Defines a behaviour to set after the defined {@link DBOperations.UPDATE}
112
- *
113
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
114
- * @param data
115
- *
116
- * @see after
117
- *
118
- * @function afterUpdate
119
- *
120
- * @category Decorators
121
- */
122
- export declare function afterUpdate<T>(handler: UpdateOperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
123
- /**
124
- * @summary Defines a behaviour to set after the defined {@link DBOperations.CREATE}
125
- *
126
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
127
- * @param data
128
- *
129
- * @see after
130
- *
131
- * @function afterCreate
132
- *
133
- * @category Decorators
134
- */
135
- export declare function afterCreate<T>(handler: StandardOperationHandler<any, any, T, any>, data: T): (target: object, propertyKey?: any) => void;
136
- /**
137
- * @summary Defines a behaviour to set after the defined {@link DBOperations.READ}
138
- *
139
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
140
- * @param data
141
- * @param {any[]} [args] Arguments that will be passed in order to the handler method
142
- *
143
- * @see after
144
- *
145
- * @function afterRead
146
- *
147
- * @category Decorators
148
- */
149
- export declare function afterRead<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
150
- /**
151
- * @summary Defines a behaviour to set after the defined {@link DBOperations.DELETE}
152
- *
153
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
154
- * @param data
155
- * @param {any[]} [args] Arguments that will be passed in order to the handler method
156
- *
157
- * @see after
158
- *
159
- * @function afterDelete
160
- *
161
- * @category Decorators
162
- */
163
- export declare function afterDelete<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
164
- /**
165
- * @summary Defines a behaviour to set after the defined {@link DBOperations.DELETE}
166
- *
167
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
168
- * @param data
169
- * @param {any[]} [args] Arguments that will be passed in order to the handler method
170
- *
171
- * @see after
172
- *
173
- * @function afterAny
174
- *
175
- * @category Decorators
176
- */
177
- export declare function afterAny<T>(handler: StandardOperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
178
- /**
179
- * @summary Defines a behaviour to set on the defined {@link DBOperations}
180
- *
181
- * @param {OperationKeys[] | DBOperations} op One of {@link DBOperations}
182
- * @param {AfterOperationHandler<any>} handler The method called upon the operation
183
- *
184
- * ex: handler(...args, ...props.map(p => target[p]))
185
- *
186
- * @param data
187
- * @param args
188
- * @function after
189
- *
190
- * @category Decorators
191
- */
192
- export declare function after<T>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, data?: T): (target: object, propertyKey?: any) => void;
193
- export declare function operation<T>(baseOp: OperationKeys.ON | OperationKeys.AFTER, operation: OperationKeys[] | undefined, handler: OperationHandler<any, any, T, any>, dataToAdd?: T): (target: object, propertyKey?: any) => void;
@@ -1,5 +0,0 @@
1
- export * from "./constants";
2
- export * from "./decorators";
3
- export * from "./Operations";
4
- export * from "./OperationsRegistry";
5
- export * from "./types";
@@ -1,29 +0,0 @@
1
- import { OperationKeys } from "./constants";
2
- import { IRepository } from "../interfaces/IRepository";
3
- import { Model } from "@decaf-ts/decorator-validation";
4
- import { Context } from "../repository/Context";
5
- export type OperationMetadata<V> = {
6
- operation: OperationKeys;
7
- handler: string;
8
- metadata?: V;
9
- };
10
- /**
11
- * @typedef OperationHandler
12
- * @memberOf db-decorators.operations
13
- */
14
- export type OperationHandler<M extends Model, R extends IRepository<M>, V, C extends Context<M> = Context<M>> = StandardOperationHandler<M, R, V, C> | UpdateOperationHandler<M, R, V, C> | IdOperationHandler<M, R, V, C>;
15
- /**
16
- * @typedef OnOperationHandler
17
- * @memberOf db-decorators.operations
18
- */
19
- export type StandardOperationHandler<M extends Model, R extends IRepository<M>, V, C extends Context<M> = Context<M>> = (this: R, context: C, metadata: V, key: any, model: M) => Promise<void> | void;
20
- /**
21
- * @typedef IdOperationHandler
22
- * @memberOf db-decorators.operations
23
- */
24
- export type IdOperationHandler<M extends Model, R extends IRepository<M>, V, C extends Context<M> = Context<M>> = (this: R, context: C, decorator: V, key: any, id: string) => Promise<void> | void;
25
- /**
26
- * @typedef AfterOperationHandler
27
- * @memberOf db-decorators.operations
28
- */
29
- export type UpdateOperationHandler<M extends Model, R extends IRepository<M>, V, C extends Context<M> = Context<M>> = (this: R, context: C, decorator: V, key: any, model: M, oldModel: M) => Promise<void> | void;
@@ -1,36 +0,0 @@
1
- import { IRepository } from "../interfaces/IRepository";
2
- import { Constructor, Model } from "@decaf-ts/decorator-validation";
3
- import { Context } from "./Context";
4
- export declare abstract class BaseRepository<M extends Model> implements IRepository<M> {
5
- private readonly _class;
6
- private _pk;
7
- get class(): Constructor<M>;
8
- get pk(): string;
9
- protected constructor(clazz?: Constructor<M>);
10
- abstract create(model: M, ...args: any[]): Promise<M>;
11
- createAll(models: M[], ...args: any[]): Promise<M[]>;
12
- protected createPrefix(model: M, ...args: any[]): Promise<any[]>;
13
- protected createSuffix(model: M, context: Context<M>): Promise<M>;
14
- protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
15
- protected createAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
16
- abstract read(key: string | number, ...args: any[]): Promise<M>;
17
- readAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
18
- protected readSuffix(model: M, context: Context<M>): Promise<M>;
19
- protected readPrefix(key: string, ...args: any[]): Promise<any[]>;
20
- protected readAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
21
- protected readAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
22
- abstract update(model: M, ...args: any[]): Promise<M>;
23
- updateAll(models: M[], ...args: any): Promise<M[]>;
24
- protected updateSuffix(model: M, context: Context<M>): Promise<M>;
25
- protected updatePrefix(model: M, ...args: any[]): Promise<any[]>;
26
- protected updateAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
27
- protected updateAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
28
- abstract delete(key: string | number, ...args: any[]): Promise<M>;
29
- deleteAll(keys: string[] | number[], ...args: any[]): Promise<M[]>;
30
- protected deleteSuffix(model: M, context: Context<M>): Promise<M>;
31
- protected deletePrefix(key: any, ...args: any[]): Promise<any[]>;
32
- protected deleteAllPrefix(keys: string[] | number[], ...args: any[]): Promise<any[]>;
33
- protected deleteAllSuffix(models: M[], context: Context<M>): Promise<M[]>;
34
- protected merge(oldModel: M, model: M): M;
35
- toString(): string;
36
- }
@@ -1,17 +0,0 @@
1
- import { DataCache } from "./DataCache";
2
- import { ContextArgs } from "./utils";
3
- import { Contextual } from "../interfaces/Contextual";
4
- import { OperationKeys } from "../operations/constants";
5
- import { Constructor, Model } from "@decaf-ts/decorator-validation";
6
- export declare class Context<M extends Model> extends DataCache {
7
- protected operation: OperationKeys;
8
- protected model?: Constructor<M> | undefined;
9
- protected parent?: Context<any> | undefined;
10
- protected constructor(operation: OperationKeys, model?: Constructor<M> | undefined, parent?: Context<any> | undefined);
11
- get timestamp(): Date;
12
- get(key: string): Promise<any>;
13
- pop(key: string): Promise<any>;
14
- child<N extends Model>(operation: OperationKeys, model?: Constructor<N>): Context<N>;
15
- static from<M extends Model, C extends Context<M>>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, ...args: any[]): Promise<C>;
16
- static args<M extends Model>(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE, model: Constructor<M>, args: any[], contextual?: Contextual<M>): Promise<ContextArgs<M>>;
17
- }
@@ -1,9 +0,0 @@
1
- export declare class DataCache {
2
- protected cache: Record<string, any>;
3
- get(key: string): Promise<any>;
4
- push(key: string, value: any): Promise<void>;
5
- put(key: string, value: any): Promise<void>;
6
- pop(key: string): Promise<any>;
7
- filter(filter: string | RegExp): Promise<any[]>;
8
- purge(key?: string): Promise<void>;
9
- }
@@ -1,10 +0,0 @@
1
- import { BaseRepository } from "./BaseRepository";
2
- import { Constructor, Model } from "@decaf-ts/decorator-validation";
3
- export declare abstract class Repository<M extends Model> extends BaseRepository<M> {
4
- protected constructor(clazz?: Constructor<M>);
5
- protected createPrefix(model: M, ...args: any[]): Promise<[M, ...any[]]>;
6
- protected createAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
7
- protected updatePrefix(model: M, ...args: any[]): Promise<[M, ...args: any[]]>;
8
- protected updateAllPrefix(models: M[], ...args: any[]): Promise<any[]>;
9
- static key(key: string): string;
10
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * @summary Base Error
3
- *
4
- * @param {string} msg the error message
5
- *
6
- * @class BaseDLTError
7
- * @extends Error
8
- */
9
- export declare abstract class BaseError extends Error {
10
- protected constructor(name: string, msg: string | Error);
11
- }
12
- /**
13
- * @summary Represents a failure in the Model details
14
- *
15
- * @param {string} msg the error message
16
- *
17
- * @class ValidationError
18
- * @extends BaseError
19
- */
20
- export declare class ValidationError extends BaseError {
21
- constructor(msg: string | Error);
22
- }
23
- /**
24
- * @summary Represents an internal failure (should mean an error in code)
25
- *
26
- * @param {string} msg the error message
27
- *
28
- * @class InternalError
29
- * @extends BaseError
30
- */
31
- export declare class InternalError extends BaseError {
32
- constructor(msg: string | Error);
33
- }
34
- /**
35
- * @summary Represents a failure in the Model de/serialization
36
- *
37
- * @param {string} msg the error message
38
- *
39
- * @class SerializationError
40
- * @extends BaseError
41
- *
42
- */
43
- export declare class SerializationError extends BaseError {
44
- constructor(msg: string | Error);
45
- }
46
- /**
47
- * @summary Represents a failure in finding a model
48
- *
49
- * @param {string} msg the error message
50
- *
51
- * @class NotFoundError
52
- * @extends BaseError
53
- *
54
- */
55
- export declare class NotFoundError extends BaseError {
56
- constructor(msg: string | Error);
57
- }
58
- /**
59
- * @summary Represents a conflict in the storage
60
- *
61
- * @param {string} msg the error message
62
- *
63
- * @class ConflictError
64
- * @extends BaseError
65
- *
66
- */
67
- export declare class ConflictError extends BaseError {
68
- constructor(msg: string | Error);
69
- }
@@ -1,7 +0,0 @@
1
- export * from "./BaseRepository";
2
- export * from "./Context";
3
- export * from "./DataCache";
4
- export * from "./errors";
5
- export * from "./Repository";
6
- export * from "./utils";
7
- export * from "./wrappers";
@@ -1,62 +0,0 @@
1
- import { IRepository } from "../interfaces/IRepository";
2
- import { DecoratorMetadata } from "@decaf-ts/reflection";
3
- import { Constructor, Model } from "@decaf-ts/decorator-validation";
4
- import { Context } from "./Context";
5
- export type ContextArgs<M extends Model> = {
6
- context: Context<M>;
7
- args: any[];
8
- };
9
- /**
10
- * @summary retrieves the arguments for the handler
11
- * @param {any} dec the decorator
12
- * @param {string} prop the property name
13
- * @param {{}} m the model
14
- * @param {{}} [accum] accumulator used for internal recursiveness
15
- *
16
- * @function getHandlerArgs
17
- * @memberOf module:db-decorators.Repository
18
- */
19
- export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any>, accum?: Record<string, {
20
- args: string[];
21
- }>) => Record<string, {
22
- args: string[];
23
- }> | void;
24
- /**
25
- *
26
- * @param {IRepository<T>} repo
27
- * @param context
28
- * @param {T} model
29
- * @param operation
30
- * @param prefix
31
- *
32
- * @param oldModel
33
- * @function enforceDBPropertyDecoratorsAsync
34
- *
35
- * @memberOf db-decorators.utils
36
- */
37
- export declare function enforceDBDecorators<M extends Model, Y extends IRepository<M>, V>(repo: Y, context: Context<M>, model: M, operation: string, prefix: string, oldModel?: M): Promise<void>;
38
- /**
39
- * Specific for DB Decorators
40
- * @param {T} model
41
- * @param {string} operation CRUD {@link OperationKeys}
42
- * @param {string} [extraPrefix]
43
- *
44
- * @function getDbPropertyDecorators
45
- *
46
- * @memberOf db-decorators.utils
47
- */
48
- export declare function getDbDecorators<T extends Model>(model: T, operation: string, extraPrefix?: string): Record<string, DecoratorMetadata[]> | undefined;
49
- /**
50
- * @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
51
- * @param model
52
- * @param accum
53
- * @param prefixes
54
- *
55
- * @function getAllPropertyDecoratorsRecursive
56
- * @memberOf module:db-decorators.Repository
57
- */
58
- export declare const getAllPropertyDecoratorsRecursive: <T extends Model>(model: T, accum: {
59
- [indexer: string]: any[];
60
- } | undefined, ...prefixes: string[]) => {
61
- [indexer: string]: any[];
62
- } | undefined;
@@ -1,38 +0,0 @@
1
- /**
2
- * @summary Util method to change a method of an object prefixing it with another
3
- * @param {any} obj The Base Object
4
- * @param {Function} after The original method
5
- * @param {Function} prefix The Prefix method. The output will be used as arguments in the original method
6
- * @param {string} [afterName] When the after function anme cannot be extracted, pass it here
7
- *
8
- * @function prefixMethod
9
- *
10
- * @memberOf module:db-decorators.Repository
11
- */
12
- export declare function prefixMethod(obj: any, after: (...args: any[]) => any, prefix: (...args: any[]) => any, afterName?: string): void;
13
- /**
14
- * @summary Util method to change a method of an object suffixing it with another
15
- * @param {any} obj The Base Object
16
- * @param {Function} before The original method
17
- * @param {Function} suffix The Prefix method. The output will be used as arguments in the original method
18
- * @param {string} [beforeName] When the after function anme cannot be extracted, pass it here
19
- *
20
- * @function suffixMethod
21
- *
22
- * @memberOf module:db-decorators.Repository
23
- */
24
- export declare function suffixMethod(obj: any, before: (...args: any[]) => any, suffix: (...args: any[]) => any, beforeName?: string): void;
25
- /**
26
- * @summary Util method to wrap a method of an object with additional logic
27
- *
28
- * @param {any} obj The Base Object
29
- * @param {Function} before the method to be prefixed
30
- * @param {Function} method the method to be wrapped
31
- * @param {Function} after The method to be suffixed
32
- * @param {string} [methodName] When the after function anme cannot be extracted, pass it here
33
- *
34
- * @function wrapMethodWithContext
35
- *
36
- * @memberOf module:db-decorators.Repository
37
- */
38
- export declare function wrapMethodWithContext(obj: any, before: (...args: any[]) => any, method: (...args: any[]) => any, after: (...args: any[]) => any, methodName?: string): void;
@@ -1,30 +0,0 @@
1
- /**
2
- * @summary holds the default error messages
3
- * @const DEFAULT_ERROR_MESSAGES
4
- *
5
- * @memberOf module:db-decorators.Model
6
- */
7
- export declare const DEFAULT_ERROR_MESSAGES: {
8
- ID: {
9
- INVALID: string;
10
- REQUIRED: string;
11
- };
12
- READONLY: {
13
- INVALID: string;
14
- };
15
- TIMESTAMP: {
16
- REQUIRED: string;
17
- DATE: string;
18
- INVALID: string;
19
- };
20
- };
21
- /**
22
- * @summary Update reflection keys
23
- * @const UpdateValidationKeys
24
- * @memberOf module:db-decorators.Operations
25
- */
26
- export declare const UpdateValidationKeys: {
27
- REFLECT: string;
28
- TIMESTAMP: string;
29
- READONLY: string;
30
- };
@@ -1,58 +0,0 @@
1
- import { Model } from "@decaf-ts/decorator-validation";
2
- import { OperationKeys } from "../operations/constants";
3
- import { IRepository } from "../interfaces/IRepository";
4
- import { Context } from "../repository/Context";
5
- /**
6
- * Marks the property as readonly.
7
- *
8
- * @param {string} [message] the error message. Defaults to {@link DEFAULT_ERROR_MESSAGES.READONLY.INVALID}
9
- *
10
- * @decorator readonly
11
- *
12
- * @category Decorators
13
- */
14
- export declare function readonly(message?: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
15
- export declare function timestampHandler<M extends Model, V extends IRepository<M>, Y = any>(this: V, context: Context<M>, data: Y, key: string, model: M): Promise<void>;
16
- /**
17
- * Marks the property as timestamp.
18
- * Makes it {@link required}
19
- * Makes it a {@link date}
20
- *
21
- * Date Format:
22
- *
23
- * <pre>
24
- * Using similar formatting as Moment.js, Class DateTimeFormatter (Java), and Class SimpleDateFormat (Java),
25
- * I implemented a comprehensive solution formatDate(date, patternStr) where the code is easy to read and modify.
26
- * You can display date, time, AM/PM, etc.
27
- *
28
- * Date and Time Patterns
29
- * yy = 2-digit year; yyyy = full year
30
- * M = digit month; MM = 2-digit month; MMM = short month name; MMMM = full month name
31
- * EEEE = full weekday name; EEE = short weekday name
32
- * d = digit day; dd = 2-digit day
33
- * h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
34
- * m = minutes; mm = 2-digit minutes; aaa = AM/PM
35
- * s = seconds; ss = 2-digit seconds
36
- * S = miliseconds
37
- * </pre>
38
- *
39
- * @param {string[]} operation The {@link DBOperations} to act on. Defaults to {@link DBOperations.CREATE_UPDATE}
40
- * @param {string} [format] The TimeStamp format. defaults to {@link DEFAULT_TIMESTAMP_FORMAT}
41
- * @param {{new: UpdateValidator}} [validator] defaults to {@link TimestampValidator}
42
- *
43
- * @decorator timestamp
44
- *
45
- * @category Decorators
46
- */
47
- export declare function timestamp(operation?: OperationKeys[], format?: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
48
- export declare function serializeOnCreateUpdate<T extends Model, V extends IRepository<T>, Y = any>(this: V, data: Y, key: string, model: T, oldModel: T): Promise<void>;
49
- export declare function serializeAfterAll<T extends Model, V extends IRepository<T>, Y = any>(this: V, data: Y, key: string, model: T): Promise<void>;
50
- /**
51
- * @summary Serialize Decorator
52
- * @description properties decorated will the serialized before stored in the db
53
- *
54
- * @function serialize
55
- *
56
- * @memberOf module:wallet-db.Decorators
57
- */
58
- export declare function serialize(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
@@ -1,4 +0,0 @@
1
- export * from "./validators";
2
- export * from "./constants";
3
- export * from "./decorators";
4
- export * from "./validation";