@decaf-ts/db-decorators 0.6.20 → 0.7.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.
Files changed (130) hide show
  1. package/README.md +1 -1
  2. package/dist/db-decorators.cjs +1 -1
  3. package/dist/db-decorators.cjs.map +1 -1
  4. package/dist/db-decorators.js +1 -1
  5. package/dist/db-decorators.js.map +1 -1
  6. package/lib/esm/identity/decorators.d.ts +1 -1
  7. package/lib/esm/identity/decorators.js +8 -4
  8. package/lib/esm/identity/decorators.js.map +1 -1
  9. package/lib/esm/identity/index.d.ts +0 -1
  10. package/lib/esm/identity/index.js +0 -1
  11. package/lib/esm/identity/index.js.map +1 -1
  12. package/lib/esm/index.d.ts +3 -1
  13. package/lib/esm/index.js +5 -1
  14. package/lib/esm/index.js.map +1 -1
  15. package/lib/esm/model/constants.js +1 -1
  16. package/lib/esm/model/constants.js.map +1 -1
  17. package/lib/esm/model/decorators.d.ts +3 -3
  18. package/lib/esm/model/decorators.js +9 -11
  19. package/lib/esm/model/decorators.js.map +1 -1
  20. package/lib/esm/model/index.d.ts +0 -2
  21. package/lib/esm/model/index.js +0 -2
  22. package/lib/esm/model/index.js.map +1 -1
  23. package/lib/esm/model/validation.d.ts +7 -7
  24. package/lib/esm/model/validation.js +52 -56
  25. package/lib/esm/model/validation.js.map +1 -1
  26. package/lib/esm/operations/constants.d.ts +11 -0
  27. package/lib/esm/operations/constants.js +12 -0
  28. package/lib/esm/operations/constants.js.map +1 -1
  29. package/lib/esm/operations/decorators.js +4 -6
  30. package/lib/esm/operations/decorators.js.map +1 -1
  31. package/lib/esm/overrides/Metadata.d.ts +50 -0
  32. package/lib/esm/overrides/Metadata.js +2 -0
  33. package/lib/esm/overrides/Metadata.js.map +1 -0
  34. package/lib/esm/overrides/Model.d.ts +65 -0
  35. package/lib/esm/overrides/Model.js +2 -0
  36. package/lib/esm/overrides/Model.js.map +1 -0
  37. package/lib/esm/overrides/index.d.ts +3 -0
  38. package/lib/esm/overrides/index.js +4 -0
  39. package/lib/esm/overrides/index.js.map +1 -0
  40. package/lib/esm/overrides/overrides.js +102 -0
  41. package/lib/esm/overrides/overrides.js.map +1 -0
  42. package/lib/esm/repository/BaseRepository.d.ts +3 -1
  43. package/lib/esm/repository/BaseRepository.js +6 -4
  44. package/lib/esm/repository/BaseRepository.js.map +1 -1
  45. package/lib/esm/repository/Context.d.ts +2 -1
  46. package/lib/esm/repository/Context.js.map +1 -1
  47. package/lib/esm/repository/Repository.d.ts +2 -9
  48. package/lib/esm/repository/Repository.js +0 -11
  49. package/lib/esm/repository/Repository.js.map +1 -1
  50. package/lib/esm/repository/types.d.ts +2 -1
  51. package/lib/esm/repository/utils.d.ts +2 -16
  52. package/lib/esm/repository/utils.js +96 -77
  53. package/lib/esm/repository/utils.js.map +1 -1
  54. package/lib/esm/validation/decorators.d.ts +1 -1
  55. package/lib/esm/validation/decorators.js +13 -8
  56. package/lib/esm/validation/decorators.js.map +1 -1
  57. package/lib/esm/validation/validators/ReadOnlyValidator.js +1 -1
  58. package/lib/esm/validation/validators/ReadOnlyValidator.js.map +1 -1
  59. package/lib/identity/decorators.cjs +7 -3
  60. package/lib/identity/decorators.d.ts +1 -1
  61. package/lib/identity/decorators.js.map +1 -1
  62. package/lib/identity/index.cjs +0 -1
  63. package/lib/identity/index.d.ts +0 -1
  64. package/lib/identity/index.js.map +1 -1
  65. package/lib/index.cjs +6 -2
  66. package/lib/index.d.ts +3 -1
  67. package/lib/index.js.map +1 -1
  68. package/lib/model/constants.cjs +1 -1
  69. package/lib/model/constants.js.map +1 -1
  70. package/lib/model/decorators.cjs +10 -12
  71. package/lib/model/decorators.d.ts +3 -3
  72. package/lib/model/decorators.js.map +1 -1
  73. package/lib/model/index.cjs +0 -2
  74. package/lib/model/index.d.ts +0 -2
  75. package/lib/model/index.js.map +1 -1
  76. package/lib/model/validation.cjs +51 -55
  77. package/lib/model/validation.d.ts +7 -7
  78. package/lib/model/validation.js.map +1 -1
  79. package/lib/operations/constants.cjs +13 -1
  80. package/lib/operations/constants.d.ts +11 -0
  81. package/lib/operations/constants.js.map +1 -1
  82. package/lib/operations/decorators.cjs +3 -5
  83. package/lib/operations/decorators.js.map +1 -1
  84. package/lib/overrides/Metadata.cjs +3 -0
  85. package/lib/overrides/Metadata.d.ts +50 -0
  86. package/lib/overrides/Metadata.js.map +1 -0
  87. package/lib/overrides/Model.cjs +4 -0
  88. package/lib/overrides/Model.d.ts +65 -0
  89. package/lib/overrides/Model.js.map +1 -0
  90. package/lib/overrides/index.cjs +20 -0
  91. package/lib/overrides/index.d.ts +3 -0
  92. package/lib/overrides/index.js.map +1 -0
  93. package/lib/overrides/overrides.cjs +104 -0
  94. package/lib/overrides/overrides.js.map +1 -0
  95. package/lib/repository/BaseRepository.cjs +6 -4
  96. package/lib/repository/BaseRepository.d.ts +3 -1
  97. package/lib/repository/BaseRepository.js.map +1 -1
  98. package/lib/repository/Context.d.ts +2 -1
  99. package/lib/repository/Context.js.map +1 -1
  100. package/lib/repository/Repository.cjs +0 -11
  101. package/lib/repository/Repository.d.ts +2 -9
  102. package/lib/repository/Repository.js.map +1 -1
  103. package/lib/repository/types.d.ts +2 -1
  104. package/lib/repository/utils.cjs +96 -78
  105. package/lib/repository/utils.d.ts +2 -16
  106. package/lib/repository/utils.js.map +1 -1
  107. package/lib/validation/decorators.cjs +16 -11
  108. package/lib/validation/decorators.d.ts +1 -1
  109. package/lib/validation/decorators.js.map +1 -1
  110. package/lib/validation/validators/ReadOnlyValidator.cjs +2 -2
  111. package/lib/validation/validators/ReadOnlyValidator.js.map +1 -1
  112. package/package.json +5 -6
  113. package/lib/esm/identity/utils.d.ts +0 -47
  114. package/lib/esm/identity/utils.js +0 -75
  115. package/lib/esm/identity/utils.js.map +0 -1
  116. package/lib/esm/model/overrides.js +0 -33
  117. package/lib/esm/model/overrides.js.map +0 -1
  118. package/lib/esm/model/utils.d.ts +0 -45
  119. package/lib/esm/model/utils.js +0 -71
  120. package/lib/esm/model/utils.js.map +0 -1
  121. package/lib/identity/utils.cjs +0 -79
  122. package/lib/identity/utils.d.ts +0 -47
  123. package/lib/identity/utils.js.map +0 -1
  124. package/lib/model/overrides.cjs +0 -35
  125. package/lib/model/overrides.js.map +0 -1
  126. package/lib/model/utils.cjs +0 -75
  127. package/lib/model/utils.d.ts +0 -45
  128. package/lib/model/utils.js.map +0 -1
  129. /package/lib/esm/{model → overrides}/overrides.d.ts +0 -0
  130. /package/lib/{model → overrides}/overrides.d.ts +0 -0
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllPropertyDecoratorsRecursive = exports.getHandlerArgs = void 0;
3
+ exports.getHandlerArgs = void 0;
4
4
  exports.enforceDBDecorators = enforceDBDecorators;
5
5
  exports.getDbDecorators = getDbDecorators;
6
6
  const constants_1 = require("./../operations/constants.cjs");
7
- const reflection_1 = require("@decaf-ts/reflection");
8
7
  const errors_1 = require("./errors.cjs");
9
- const decorator_validation_1 = require("@decaf-ts/decorator-validation");
10
8
  const decorators_1 = require("./../operations/decorators.cjs");
9
+ const decoration_1 = require("@decaf-ts/decoration");
11
10
  /**
12
11
  * @summary retrieves the arguments for the handler
13
12
  * @param {any} dec the decorator
@@ -87,88 +86,107 @@ async function enforceDBDecorators(repo, context, model, operation, prefix, oldM
87
86
  * @memberOf db-decorators.utils
88
87
  */
89
88
  function getDbDecorators(model, operation, extraPrefix) {
90
- const decorators = reflection_1.Reflection.getAllPropertyDecorators(model,
91
- // undefined,
92
- constants_1.OperationKeys.REFLECT + (extraPrefix ? extraPrefix : ""));
89
+ const prefix = extraPrefix?.replace(/[.]$/, "");
90
+ const decorators = decoration_1.Metadata.get(model.constructor, constants_1.ModelOperations.OPERATIONS);
93
91
  if (!decorators)
94
92
  return;
95
93
  return Object.keys(decorators).reduce((accum, decorator) => {
96
- const dec = decorators[decorator].filter((d) => d.key === operation);
97
- if (dec && dec.length) {
94
+ const obj = prefix
95
+ ? decorators[decorator][prefix] || {}
96
+ : decorators[decorator];
97
+ const dec = Object.keys(obj).filter((d) => d === operation);
98
+ const decs = [];
99
+ for (const d of dec)
100
+ decs.push({ key: d, props: obj[d] });
101
+ if (decs && decs.length) {
98
102
  if (!accum)
99
103
  accum = {};
100
- accum[decorator] = dec;
104
+ accum[decorator] = decs;
101
105
  }
102
106
  return accum;
103
107
  }, undefined);
104
108
  }
105
- /**
106
- * @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
107
- * @param model
108
- * @param accum
109
- * @param prefixes
110
- *
111
- * @function getAllPropertyDecoratorsRecursive
112
- * @memberOf module:db-decorators.Repository
113
- */
114
- const getAllPropertyDecoratorsRecursive = function (model, accum, ...prefixes) {
115
- const accumulator = accum || {};
116
- const mergeDecorators = function (decs) {
117
- const pushOrSquash = (key, ...values) => {
118
- values.forEach((val) => {
119
- let match;
120
- if (!(match = accumulator[key].find((e) => e.key === val.key)) ||
121
- match.props.operation !== val.props.operation) {
122
- accumulator[key].push(val);
123
- return;
124
- }
125
- if (val.key === decorator_validation_1.ModelKeys.TYPE)
126
- return;
127
- const { handlers, operation } = val.props;
128
- if (!operation ||
129
- !operation.match(new RegExp(`^(:?${constants_1.OperationKeys.ON}|${constants_1.OperationKeys.AFTER})(:?${constants_1.OperationKeys.CREATE}|${constants_1.OperationKeys.READ}|${constants_1.OperationKeys.UPDATE}|${constants_1.OperationKeys.DELETE})$`))) {
130
- accumulator[key].push(val);
131
- return;
132
- }
133
- const accumHandlers = match.props.handlers;
134
- Object.entries(handlers).forEach(([clazz, handlerDef]) => {
135
- if (!(clazz in accumHandlers)) {
136
- accumHandlers[clazz] = handlerDef;
137
- return;
138
- }
139
- Object.entries(handlerDef).forEach(([handlerProp, handler]) => {
140
- if (!(handlerProp in accumHandlers[clazz])) {
141
- accumHandlers[clazz][handlerProp] = handler;
142
- return;
143
- }
144
- Object.entries(handler).forEach(([handlerKey, argsObj]) => {
145
- if (!(handlerKey in accumHandlers[clazz][handlerProp])) {
146
- accumHandlers[clazz][handlerProp][handlerKey] = argsObj;
147
- return;
148
- }
149
- console.warn(`Skipping handler registration for ${clazz} under prop ${handlerProp} because handler is the same`);
150
- });
151
- });
152
- });
153
- });
154
- };
155
- Object.entries(decs).forEach(([key, value]) => {
156
- accumulator[key] = accumulator[key] || [];
157
- pushOrSquash(key, ...value);
158
- });
159
- };
160
- const decs = reflection_1.Reflection.getAllPropertyDecorators(model, ...prefixes);
161
- if (decs)
162
- mergeDecorators(decs);
163
- if (Object.getPrototypeOf(model) === Object.prototype)
164
- return accumulator;
165
- // const name = model.constructor.name;
166
- const proto = Object.getPrototypeOf(model);
167
- if (!proto)
168
- return accumulator;
169
- // if (proto.constructor && proto.constructor.name === name)
170
- // proto = Object.getPrototypeOf(proto)
171
- return (0, exports.getAllPropertyDecoratorsRecursive)(proto, accumulator, ...prefixes);
172
- };
173
- exports.getAllPropertyDecoratorsRecursive = getAllPropertyDecoratorsRecursive;
109
+ // /**
110
+ // * @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
111
+ // * @param model
112
+ // * @param accum
113
+ // * @param prefixes
114
+ // *
115
+ // * @function getAllPropertyDecoratorsRecursive
116
+ // * @memberOf module:db-decorators.Repository
117
+ // */
118
+ // export const getAllPropertyDecoratorsRecursive = function <T extends Model>(
119
+ // model: T,
120
+ // accum: { [indexer: string]: any[] } | undefined,
121
+ // ...prefixes: string[]
122
+ // ): { [indexer: string]: any[] } | undefined {
123
+ // const accumulator = accum || {};
124
+ // const mergeDecorators = function (decs: { [indexer: string]: any[] }) {
125
+ // const pushOrSquash = (key: string, ...values: any[]) => {
126
+ // values.forEach((val) => {
127
+ // let match: any;
128
+ // if (
129
+ // !(match = accumulator[key].find((e) => e.key === val.key)) ||
130
+ // match.props.operation !== val.props.operation
131
+ // ) {
132
+ // accumulator[key].push(val);
133
+ // return;
134
+ // }
135
+ // if (val.key === ModelKeys.TYPE) return;
136
+ // const { handlers, operation } = val.props;
137
+ // if (
138
+ // !operation ||
139
+ // !operation.match(
140
+ // new RegExp(
141
+ // `^(:?${OperationKeys.ON}|${OperationKeys.AFTER})(:?${OperationKeys.CREATE}|${OperationKeys.READ}|${OperationKeys.UPDATE}|${OperationKeys.DELETE})$`
142
+ // )
143
+ // )
144
+ // ) {
145
+ // accumulator[key].push(val);
146
+ // return;
147
+ // }
148
+ // const accumHandlers = match.props.handlers;
149
+ // Object.entries(handlers).forEach(([clazz, handlerDef]) => {
150
+ // if (!(clazz in accumHandlers)) {
151
+ // accumHandlers[clazz] = handlerDef;
152
+ // return;
153
+ // }
154
+ // Object.entries(handlerDef as object).forEach(
155
+ // ([handlerProp, handler]) => {
156
+ // if (!(handlerProp in accumHandlers[clazz])) {
157
+ // accumHandlers[clazz][handlerProp] = handler;
158
+ // return;
159
+ // }
160
+ // Object.entries(handler as object).forEach(
161
+ // ([handlerKey, argsObj]) => {
162
+ // if (!(handlerKey in accumHandlers[clazz][handlerProp])) {
163
+ // accumHandlers[clazz][handlerProp][handlerKey] = argsObj;
164
+ // return;
165
+ // }
166
+ // console.warn(
167
+ // `Skipping handler registration for ${clazz} under prop ${handlerProp} because handler is the same`
168
+ // );
169
+ // }
170
+ // );
171
+ // }
172
+ // );
173
+ // });
174
+ // });
175
+ // };
176
+ // Object.entries(decs).forEach(([key, value]) => {
177
+ // accumulator[key] = accumulator[key] || [];
178
+ // pushOrSquash(key, ...value);
179
+ // });
180
+ // };
181
+ // const decs: { [indexer: string]: any[] } | undefined =
182
+ // Reflection.getAllPropertyDecorators(model, ...prefixes);
183
+ // if (decs) mergeDecorators(decs);
184
+ // if (Object.getPrototypeOf(model) === Object.prototype) return accumulator;
185
+ // // const name = model.constructor.name;
186
+ // const proto = Object.getPrototypeOf(model);
187
+ // if (!proto) return accumulator;
188
+ // // if (proto.constructor && proto.constructor.name === name)
189
+ // // proto = Object.getPrototypeOf(proto)
190
+ // return getAllPropertyDecoratorsRecursive(proto, accumulator, ...prefixes);
191
+ // };
174
192
  //# sourceMappingURL=utils.js.map
@@ -1,8 +1,8 @@
1
1
  import { IRepository } from "../interfaces/IRepository";
2
- import { DecoratorMetadata } from "@decaf-ts/reflection";
3
- import { Constructor, Model } from "@decaf-ts/decorator-validation";
2
+ import { Model } from "@decaf-ts/decorator-validation";
4
3
  import { Context } from "./Context";
5
4
  import { RepositoryFlags } from "./types";
5
+ import { Constructor } from "@decaf-ts/decoration";
6
6
  /**
7
7
  * @description Context arguments for repository operations.
8
8
  * @summary Represents the context and arguments for repository operations.
@@ -58,17 +58,3 @@ export declare function enforceDBDecorators<M extends Model<true | false>, R ext
58
58
  * @memberOf db-decorators.utils
59
59
  */
60
60
  export declare function getDbDecorators<T extends Model>(model: T, operation: string, extraPrefix?: string): Record<string, DecoratorMetadata[]> | undefined;
61
- /**
62
- * @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
63
- * @param model
64
- * @param accum
65
- * @param prefixes
66
- *
67
- * @function getAllPropertyDecoratorsRecursive
68
- * @memberOf module:db-decorators.Repository
69
- */
70
- export declare const getAllPropertyDecoratorsRecursive: <T extends Model>(model: T, accum: {
71
- [indexer: string]: any[];
72
- } | undefined, ...prefixes: string[]) => {
73
- [indexer: string]: any[];
74
- } | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/repository/utils.ts"],"names":[],"mappings":";;;AA4EA,kDA+CC;AAYD,0CAuBC;AA7JD,6DAAwD;AACxD,qDAAqE;AACrE,yCAAyC;AACzC,yEAA+E;AAG/E,+DAIkC;AAsBlC;;;;;;;;;GASG;AACI,MAAM,cAAc,GAAG,UAC5B,GAAQ,EACR,IAAY,EACZ,CAAmB,EACnB,KAA0C;IAE1C,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;IAChC,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,sBAAa,CAAC,iCAAiC,CAAC,CAAC;IACtE,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IAEp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kBAAkB;AAClB,qBAAqB;AACrB,KAAK;AACL,iDAAiD;AACjD,+CAA+C;AAC/C,MAAM;AACN,+EAA+E;AAC/E,cAAc;AACd,qDAAqD;AACrD,0BAA0B;AAC1B,gDAAgD;AAChD,qCAAqC;AACrC,4EAA4E;AAC5E,gEAAgE;AAChE,kCAAkC;AAClC,0BAA0B;AAC1B,eAAe;AACf,0EAA0E;AAC1E,0DAA0D;AAC1D,cAAc;AACd,wCAAwC;AACxC,oBAAoB;AACpB,YAAY;AAEZ,kDAAkD;AAElD,qDAAqD;AAErD,eAAe;AACf,0BAA0B;AAC1B,8BAA8B;AAC9B,0BAA0B;AAC1B,oKAAoK;AACpK,gBAAgB;AAChB,cAAc;AACd,cAAc;AACd,wCAAwC;AACxC,oBAAoB;AACpB,YAAY;AAEZ,sDAAsD;AAEtD,sEAAsE;AACtE,6CAA6C;AAC7C,iDAAiD;AACjD,sBAAsB;AACtB,cAAc;AAEd,0DAA0D;AAC1D,4CAA4C;AAC5C,8DAA8D;AAC9D,+DAA+D;AAC/D,0BAA0B;AAC1B,kBAAkB;AAElB,2DAA2D;AAC3D,+CAA+C;AAC/C,8EAA8E;AAC9E,+EAA+E;AAC/E,8BAA8B;AAC9B,sBAAsB;AACtB,kCAAkC;AAClC,yHAAyH;AACzH,uBAAuB;AACvB,oBAAoB;AACpB,mBAAmB;AACnB,gBAAgB;AAChB,eAAe;AACf,cAAc;AACd,YAAY;AACZ,SAAS;AAET,uDAAuD;AACvD,mDAAmD;AACnD,qCAAqC;AACrC,UAAU;AACV,OAAO;AAEP,2DAA2D;AAC3D,+DAA+D;AAC/D,qCAAqC;AAErC,+EAA+E;AAE/E,4CAA4C;AAC5C,gDAAgD;AAChD,oCAAoC;AACpC,iEAAiE;AACjE,gDAAgD;AAChD,+EAA+E;AAC/E,KAAK"}
@@ -13,8 +13,7 @@ const constants_2 = require("./constants.cjs");
13
13
  const constants_3 = require("./../operations/constants.cjs");
14
14
  const decorators_1 = require("./../operations/decorators.cjs");
15
15
  const errors_1 = require("./../repository/errors.cjs");
16
- const reflection_1 = require("@decaf-ts/reflection");
17
- const repository_1 = require("./../repository/index.cjs");
16
+ const decoration_1 = require("@decaf-ts/decoration");
18
17
  /**
19
18
  * @description Prevents a property from being modified after initial creation.
20
19
  * @summary Marks the property as readonly, causing validation errors if attempts are made to modify it during updates.
@@ -24,11 +23,17 @@ const repository_1 = require("./../repository/index.cjs");
24
23
  * @category Property Decorators
25
24
  */
26
25
  function readonly(message = constants_2.DEFAULT_ERROR_MESSAGES.READONLY.INVALID) {
27
- const key = decorator_validation_1.Validation.updateKey(constants_1.DBKeys.READONLY);
28
- return decorator_validation_1.Decoration.for(key)
29
- .define((0, decorator_validation_1.propMetadata)(key, {
26
+ const key = constants_1.DBKeys.READONLY;
27
+ const meta = {
30
28
  message: message,
31
- }))
29
+ description: `defines the attribute as readOnly`,
30
+ async: false,
31
+ };
32
+ return decoration_1.Decoration.for(key)
33
+ .define({
34
+ decorator: decorator_validation_1.innerValidationDecorator,
35
+ args: [readonly, key, meta],
36
+ })
32
37
  .apply();
33
38
  }
34
39
  /**
@@ -102,21 +107,21 @@ function timestamp(operation = constants_3.DBOperations.CREATE_UPDATE, format =
102
107
  const decorators = [
103
108
  (0, decorator_validation_1.date)(format, constants_2.DEFAULT_ERROR_MESSAGES.TIMESTAMP.DATE),
104
109
  (0, decorator_validation_1.required)(constants_2.DEFAULT_ERROR_MESSAGES.TIMESTAMP.REQUIRED),
105
- (0, decorator_validation_1.propMetadata)(decorator_validation_1.Validation.key(constants_1.DBKeys.TIMESTAMP), {
110
+ (0, decoration_1.propMetadata)(decorator_validation_1.Validation.key(constants_1.DBKeys.TIMESTAMP), {
106
111
  operation: operation,
107
112
  format: format,
108
113
  }),
109
114
  (0, decorators_1.on)(operation, timestampHandler),
110
115
  ];
111
116
  if (operation.indexOf(constants_3.OperationKeys.UPDATE) !== -1)
112
- decorators.push((0, decorator_validation_1.propMetadata)(key, {
117
+ decorators.push((0, decoration_1.propMetadata)(key, {
113
118
  message: constants_2.DEFAULT_ERROR_MESSAGES.TIMESTAMP.INVALID,
114
119
  }));
115
120
  else
116
121
  decorators.push(readonly());
117
- return (0, reflection_1.apply)(...decorators);
122
+ return (0, decoration_1.apply)(...decorators);
118
123
  }
119
- return decorator_validation_1.Decoration.for(key)
124
+ return decoration_1.Decoration.for(key)
120
125
  .define({
121
126
  decorator: ts,
122
127
  args: [operation, format],
@@ -204,6 +209,6 @@ async function serializeAfterAll(context, data, key, model) {
204
209
  * M->>C: Return model with deserialized property
205
210
  */
206
211
  function serialize() {
207
- return (0, reflection_1.apply)((0, decorators_1.onCreateUpdate)(serializeOnCreateUpdate), (0, decorators_1.after)(constants_3.DBOperations.ALL, serializeAfterAll), (0, decorator_validation_1.type)([String.name, Object.name]), (0, reflection_1.metadata)(repository_1.Repository.key(constants_1.DBKeys.SERIALIZE), {}));
212
+ return (0, decoration_1.apply)((0, decorators_1.onCreateUpdate)(serializeOnCreateUpdate), (0, decorators_1.after)(constants_3.DBOperations.ALL, serializeAfterAll), (0, decorator_validation_1.type)([String, Object]), (0, decoration_1.metadata)(constants_1.DBKeys.SERIALIZE, {}));
208
213
  }
209
214
  //# sourceMappingURL=decorators.js.map
@@ -136,4 +136,4 @@ export declare function serializeAfterAll<M extends Model, R extends IRepository
136
136
  * S->>M: Parse JSON back to object
137
137
  * M->>C: Return model with deserialized property
138
138
  */
139
- export declare function serialize(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
139
+ export declare function serialize(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor | number) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/validation/decorators.ts"],"names":[],"mappings":";;AA6BA,4BAWC;AAiBD,4CAQC;AAiDD,8BA+BC;AAiBD,0DAgBC;AAiBD,8CAiBC;AA6BD,8BAOC;AAxPD,4BAAsB;AACtB,yEAQwC;AACxC,wDAAsE;AACtE,+CA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K,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAC5F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,SAAS;IACvB,OAAO,IAAA,kBAAK,EACV,IAAA,2BAAc,EAAC,uBAAuB,CAAC,EACvC,IAAA,kBAAK,EAAC,wBAAY,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAC1C,IAAA,2BAAI,EAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtB,IAAA,qBAAQ,EAAC,kBAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAC/B,CAAC;AACJ,CAAC"}
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ReadOnlyValidator = void 0;
13
13
  const decorator_validation_1 = require("@decaf-ts/decorator-validation");
14
14
  const constants_1 = require("./../constants.cjs");
15
- const reflection_1 = require("@decaf-ts/reflection");
15
+ const decorator_validation_2 = require("@decaf-ts/decorator-validation");
16
16
  /**
17
17
  * @description A validator that ensures properties marked as readonly cannot be modified during updates.
18
18
  * @summary Validator for the {@link readonly} decorator that checks if a value has been changed during an update operation. It compares the new value with the old value and returns an error message if they are not equal.
@@ -65,7 +65,7 @@ let ReadOnlyValidator = class ReadOnlyValidator extends decorator_validation_1.V
65
65
  updateHasErrors(value, oldValue, message) {
66
66
  if (value === undefined)
67
67
  return;
68
- return (0, reflection_1.isEqual)(value, oldValue)
68
+ return (0, decorator_validation_2.isEqual)(value, oldValue)
69
69
  ? undefined
70
70
  : this.getMessage(message || this.message);
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyValidator.js","sourceRoot":"","sources":["../../../src/validation/validators/ReadOnlyValidator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yEAAsE;AACtE,kDAA4E;AAC5E,qDAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEI,IAAM,iBAAiB,GA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Q,CAAC;YAC7B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AApCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,gCAAS,EAAC,gCAAoB,CAAC,QAAQ,CAAC;;GAC5B,iBAAiB,CAoC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/db-decorators",
3
- "version": "0.6.20",
3
+ "version": "0.7.1",
4
4
  "description": "Agnostic database decorators and repository",
5
5
  "type": "module",
6
6
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "lint": "eslint .",
28
28
  "lint-fix": "eslint --fix .",
29
29
  "prepare-pr": "npm run lint-fix && npm run build:prod && npm run coverage && npm run docs",
30
- "prepare-release": "npm run lint-fix && npm run build:prod && npm run coverage",
30
+ "prepare-release": "npm run lint-fix && npm run build:prod && npm run coverage && npm run docs",
31
31
  "release": "./bin/tag-release.sh",
32
32
  "clean-publish": "npx clean-publish",
33
33
  "drawings": "for FILE in workdocs/drawings/*.drawio; do echo \"converting $FILE to image...\" && docker run --rm -v $(pwd):/data rlespinasse/drawio-export --format png $FILE; done && cp -rf workdocs/drawings/export/* workdocs/resources/",
@@ -74,13 +74,12 @@
74
74
  },
75
75
  "homepage": "https://github.com/decaf-ts/db-decorators#readme",
76
76
  "devDependencies": {
77
- "@decaf-ts/utils": "latest",
78
- "@decaf-ts/logging": "latest"
77
+ "@decaf-ts/logging": "latest",
78
+ "@decaf-ts/utils": "latest"
79
79
  },
80
80
  "dependencies": {
81
81
  "@decaf-ts/decoration": "latest",
82
82
  "@decaf-ts/decorator-validation": "latest",
83
- "@decaf-ts/injectable-decorators": "latest",
84
- "@decaf-ts/reflection": "latest"
83
+ "@decaf-ts/injectable-decorators": "latest"
85
84
  }
86
85
  }
@@ -1,47 +0,0 @@
1
- import { Model } from "@decaf-ts/decorator-validation";
2
- /**
3
- * @description Finds the primary key attribute for a model
4
- * @summary Searches in all the properties in the object for an {@link id} decorated property and returns the property key and metadata
5
- * @param {Model} model - The model object to search for primary key
6
- * @return {Object} An object containing the id property name and its metadata
7
- * @function findPrimaryKey
8
- * @mermaid
9
- * sequenceDiagram
10
- * participant Caller
11
- * participant findPrimaryKey
12
- * participant getAllPropertyDecoratorsRecursive
13
- *
14
- * Caller->>findPrimaryKey: model
15
- * findPrimaryKey->>getAllPropertyDecoratorsRecursive: get decorators
16
- * getAllPropertyDecoratorsRecursive-->>findPrimaryKey: decorators
17
- * findPrimaryKey->>findPrimaryKey: filter ID decorators
18
- * findPrimaryKey->>findPrimaryKey: validate single ID property
19
- * findPrimaryKey-->>Caller: {id, props}
20
- * @memberOf module:db-decorators
21
- */
22
- export declare function findPrimaryKey<M extends Model>(model: M): {
23
- id: keyof M;
24
- props: any;
25
- };
26
- /**
27
- * @description Retrieves the primary key value from a model
28
- * @summary Searches for the ID-decorated property in the model and returns its value
29
- * @param {Model} model - The model object to extract the ID from
30
- * @param {boolean} [returnEmpty=false] - Whether to return undefined if no ID value is found
31
- * @return {string | number | bigint} The primary key value
32
- * @function findModelId
33
- * @mermaid
34
- * sequenceDiagram
35
- * participant Caller
36
- * participant findModelId
37
- * participant findPrimaryKey
38
- *
39
- * Caller->>findModelId: model, returnEmpty
40
- * findModelId->>findPrimaryKey: model
41
- * findPrimaryKey-->>findModelId: {id, props}
42
- * findModelId->>findModelId: extract model[id]
43
- * findModelId->>findModelId: validate ID exists if required
44
- * findModelId-->>Caller: ID value
45
- * @memberOf module:db-decorators
46
- */
47
- export declare function findModelId<M extends Model>(model: M, returnEmpty?: boolean): string | number | bigint;
@@ -1,75 +0,0 @@
1
- import { DBKeys } from "./../model/constants.js";
2
- import { getAllPropertyDecoratorsRecursive } from "./../repository/utils.js";
3
- import { ModelKeys, sf } from "@decaf-ts/decorator-validation";
4
- import { InternalError } from "./../repository/errors.js";
5
- /**
6
- * @description Finds the primary key attribute for a model
7
- * @summary Searches in all the properties in the object for an {@link id} decorated property and returns the property key and metadata
8
- * @param {Model} model - The model object to search for primary key
9
- * @return {Object} An object containing the id property name and its metadata
10
- * @function findPrimaryKey
11
- * @mermaid
12
- * sequenceDiagram
13
- * participant Caller
14
- * participant findPrimaryKey
15
- * participant getAllPropertyDecoratorsRecursive
16
- *
17
- * Caller->>findPrimaryKey: model
18
- * findPrimaryKey->>getAllPropertyDecoratorsRecursive: get decorators
19
- * getAllPropertyDecoratorsRecursive-->>findPrimaryKey: decorators
20
- * findPrimaryKey->>findPrimaryKey: filter ID decorators
21
- * findPrimaryKey->>findPrimaryKey: validate single ID property
22
- * findPrimaryKey-->>Caller: {id, props}
23
- * @memberOf module:db-decorators
24
- */
25
- export function findPrimaryKey(model) {
26
- const decorators = getAllPropertyDecoratorsRecursive(model, undefined, DBKeys.REFLECT + DBKeys.ID);
27
- const idDecorators = Object.entries(decorators).reduce((accum, [prop, decs]) => {
28
- const filtered = decs.filter((d) => d.key !== ModelKeys.TYPE);
29
- if (filtered && filtered.length) {
30
- accum[prop] = accum[prop] || [];
31
- accum[prop].push(...filtered);
32
- }
33
- return accum;
34
- }, {});
35
- if (!idDecorators || !Object.keys(idDecorators).length)
36
- throw new InternalError("Could not find ID decorated Property");
37
- if (Object.keys(idDecorators).length > 1)
38
- throw new InternalError(sf(Object.keys(idDecorators).join(", ")));
39
- const idProp = Object.keys(idDecorators)[0];
40
- if (!idProp)
41
- throw new InternalError("Could not find ID decorated Property");
42
- return {
43
- id: idProp,
44
- props: idDecorators[idProp][0].props,
45
- };
46
- }
47
- /**
48
- * @description Retrieves the primary key value from a model
49
- * @summary Searches for the ID-decorated property in the model and returns its value
50
- * @param {Model} model - The model object to extract the ID from
51
- * @param {boolean} [returnEmpty=false] - Whether to return undefined if no ID value is found
52
- * @return {string | number | bigint} The primary key value
53
- * @function findModelId
54
- * @mermaid
55
- * sequenceDiagram
56
- * participant Caller
57
- * participant findModelId
58
- * participant findPrimaryKey
59
- *
60
- * Caller->>findModelId: model, returnEmpty
61
- * findModelId->>findPrimaryKey: model
62
- * findPrimaryKey-->>findModelId: {id, props}
63
- * findModelId->>findModelId: extract model[id]
64
- * findModelId->>findModelId: validate ID exists if required
65
- * findModelId-->>Caller: ID value
66
- * @memberOf module:db-decorators
67
- */
68
- export function findModelId(model, returnEmpty = false) {
69
- const idProp = findPrimaryKey(model).id;
70
- const modelId = model[idProp];
71
- if (typeof modelId === "undefined" && !returnEmpty)
72
- throw new InternalError(`No value for the Id is defined under the property ${idProp}`);
73
- return modelId;
74
- }
75
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/identity/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAA2B;AAC5C,OAAO,EAAE,iCAAiC,EAAE,iCAA4B;AACxE,OAAO,EAAS,SAAS,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,kCAA6B;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,cAAc,CAAkB,KAAQ;IACtD,MAAM,UAAU,GAAG,iCAAiC,CAClD,KAAK,EACL,SAAS,EACT,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,EAAE,CAC3B,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,UAAoB,CAAC,CAAC,MAAM,CAC9D,CAAC,KAAmC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACpD,MAAM,QAAQ,GAAI,IAA0B,CAAC,MAAM,CACjD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,IAAI,CAChC,CAAC;QACF,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC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"./validation.js";
3
- /**
4
- * @description Validates the model and checks for errors
5
- * @summary Validates the current model state and optionally compares with a previous version
6
- * @template M - Type extending Model
7
- * @param {M|any} [previousVersion] - Optional previous version of the model for comparison
8
- * @param {...any[]} exclusions - Properties to exclude from validation
9
- * @return {ModelErrorDefinition|undefined} Error definition if validation fails, undefined otherwise
10
- * @function hasErrors
11
- * @memberOf module:db-decorators
12
- */
13
- Model.prototype.hasErrors = function (previousVersion, ...exclusions) {
14
- if (previousVersion && !(previousVersion instanceof Model)) {
15
- exclusions.unshift(previousVersion);
16
- previousVersion = undefined;
17
- }
18
- const async = this.isAsync();
19
- const errs = validate(this, async, ...exclusions);
20
- if (async) {
21
- return Promise.resolve(errs).then((resolvedErrs) => {
22
- if (resolvedErrs || !previousVersion) {
23
- return resolvedErrs;
24
- }
25
- return validateCompare(previousVersion, this, async, ...exclusions);
26
- });
27
- }
28
- if (errs || !previousVersion)
29
- return errs;
30
- // @ts-expect-error Overriding Model prototype method with dynamic conditional return type.
31
- return validateCompare(previousVersion, this, async, ...exclusions);
32
- };
33
- //# sourceMappingURL=overrides.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../../src/model/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,QAAQ,GACT,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,wBAAqB;AAE/C;;;;;;;;;GASG;AACH,KAAK,CAAC,SAAS,CAAC,SAAS,GAAG,UAE1B,eAAyB,EACzB,GAAG,UAAiB;IAEpB,IAAI,eAAe,IAAI,CAAC,CAAC,eAAe,YAAY,KAAK,CAAC,EAAE,CAAC;QAC3D,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACpC,eAAe,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;IAElD,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE;YACjD,IAAI,YAAY,IAAI,CAAC,eAAe,EAAE,CAAC;gBACrC,OAAO,YAAY,CAAC;YACtB,CAAC;YACD,OAAO,eAAe,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;QACtE,CAAC,CAAQ,CAAC;IACZ,CAAC;IAED,IAAI,IAAI,IAAI,CAAC,eAAe;QAAE,OAAO,IAAW,CAAC;IAEjD,2FAA2F;IAC3F,OAAO,eAAe,CAAC,eAAe,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;AACtE,CAAC,CAAC"}
@@ -1,45 +0,0 @@
1
- import { Model } from "@decaf-ts/decorator-validation";
2
- /**
3
- * @description Checks if a model is marked as transient
4
- * @summary Determines whether a model class has been decorated with the transient decorator
5
- * @template M - Type extending Model
6
- * @param {M} model - The model instance to check
7
- * @return {boolean} True if the model is transient, false otherwise
8
- * @function isTransient
9
- * @memberOf module:db-decorators
10
- */
11
- export declare function isTransient<M extends Model>(model: M): boolean;
12
- /**
13
- * @description Separates transient properties from a model
14
- * @summary Extracts properties marked as transient into a separate object
15
- * @template M - Type extending Model
16
- * @param {M} model - The model instance to process
17
- * @return {Object} Object containing the model without transient properties and a separate transient object
18
- * @property {M} model - The model with transient properties removed
19
- * @property {Record<string, any>} [transient] - Object containing the transient properties
20
- * @function modelToTransient
21
- * @memberOf module:db-decorators
22
- * @mermaid
23
- * sequenceDiagram
24
- * participant Caller
25
- * participant modelToTransient
26
- * participant isTransient
27
- * participant getAllPropertyDecoratorsRecursive
28
- *
29
- * Caller->>modelToTransient: model
30
- * modelToTransient->>isTransient: check if model is transient
31
- * isTransient-->>modelToTransient: transient status
32
- * alt model is not transient
33
- * modelToTransient-->>Caller: {model}
34
- * else model is transient
35
- * modelToTransient->>getAllPropertyDecoratorsRecursive: get transient properties
36
- * getAllPropertyDecoratorsRecursive-->>modelToTransient: property decorators
37
- * modelToTransient->>modelToTransient: separate properties
38
- * modelToTransient->>Model.build: rebuild model without transient props
39
- * modelToTransient-->>Caller: {model, transient}
40
- * end
41
- */
42
- export declare function modelToTransient<M extends Model>(model: M): {
43
- model: M;
44
- transient?: Record<string, any>;
45
- };