@elsikora/nestjs-crud-automator 2.3.0 → 2.4.0

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 (56) hide show
  1. package/README.md +20 -2
  2. package/dist/cjs/class/api/route-runtime.class.js +1 -1
  3. package/dist/cjs/class/api/route-runtime.class.js.map +1 -1
  4. package/dist/cjs/decorator/api/function/create.decorator.js +9 -0
  5. package/dist/cjs/decorator/api/function/create.decorator.js.map +1 -1
  6. package/dist/cjs/decorator/api/function/delete.decorator.js +9 -0
  7. package/dist/cjs/decorator/api/function/delete.decorator.js.map +1 -1
  8. package/dist/cjs/decorator/api/function/get/decorator.js +9 -0
  9. package/dist/cjs/decorator/api/function/get/decorator.js.map +1 -1
  10. package/dist/cjs/decorator/api/function/get/list.decorator.js +9 -0
  11. package/dist/cjs/decorator/api/function/get/list.decorator.js.map +1 -1
  12. package/dist/cjs/decorator/api/function/get/many.decorator.js +9 -0
  13. package/dist/cjs/decorator/api/function/get/many.decorator.js.map +1 -1
  14. package/dist/cjs/decorator/api/function/update.decorator.js +9 -0
  15. package/dist/cjs/decorator/api/function/update.decorator.js.map +1 -1
  16. package/dist/cjs/decorator/api/service/decorator.js +35 -8
  17. package/dist/cjs/decorator/api/service/decorator.js.map +1 -1
  18. package/dist/cjs/type/decorator/api/service/function/index.d.ts +2 -0
  19. package/dist/cjs/type/decorator/api/service/function/map.type.d.ts +5 -0
  20. package/dist/cjs/type/decorator/api/service/function/properties.type.d.ts +6 -0
  21. package/dist/cjs/type/decorator/api/service/index.d.ts +1 -0
  22. package/dist/cjs/type/decorator/api/service/properties.type.d.ts +2 -0
  23. package/dist/cjs/utility/api/controller/get-list/transform/filter.utility.d.ts +4 -1
  24. package/dist/cjs/utility/api/controller/get-list/transform/filter.utility.js +10 -6
  25. package/dist/cjs/utility/api/controller/get-list/transform/filter.utility.js.map +1 -1
  26. package/dist/cjs/utility/api/function-transaction.utility.d.ts +4 -2
  27. package/dist/cjs/utility/api/function-transaction.utility.js +13 -3
  28. package/dist/cjs/utility/api/function-transaction.utility.js.map +1 -1
  29. package/dist/esm/class/api/route-runtime.class.js +1 -1
  30. package/dist/esm/class/api/route-runtime.class.js.map +1 -1
  31. package/dist/esm/decorator/api/function/create.decorator.js +9 -0
  32. package/dist/esm/decorator/api/function/create.decorator.js.map +1 -1
  33. package/dist/esm/decorator/api/function/delete.decorator.js +9 -0
  34. package/dist/esm/decorator/api/function/delete.decorator.js.map +1 -1
  35. package/dist/esm/decorator/api/function/get/decorator.js +9 -0
  36. package/dist/esm/decorator/api/function/get/decorator.js.map +1 -1
  37. package/dist/esm/decorator/api/function/get/list.decorator.js +9 -0
  38. package/dist/esm/decorator/api/function/get/list.decorator.js.map +1 -1
  39. package/dist/esm/decorator/api/function/get/many.decorator.js +9 -0
  40. package/dist/esm/decorator/api/function/get/many.decorator.js.map +1 -1
  41. package/dist/esm/decorator/api/function/update.decorator.js +9 -0
  42. package/dist/esm/decorator/api/function/update.decorator.js.map +1 -1
  43. package/dist/esm/decorator/api/service/decorator.js +35 -8
  44. package/dist/esm/decorator/api/service/decorator.js.map +1 -1
  45. package/dist/esm/type/decorator/api/service/function/index.d.ts +2 -0
  46. package/dist/esm/type/decorator/api/service/function/map.type.d.ts +5 -0
  47. package/dist/esm/type/decorator/api/service/function/properties.type.d.ts +6 -0
  48. package/dist/esm/type/decorator/api/service/index.d.ts +1 -0
  49. package/dist/esm/type/decorator/api/service/properties.type.d.ts +2 -0
  50. package/dist/esm/utility/api/controller/get-list/transform/filter.utility.d.ts +4 -1
  51. package/dist/esm/utility/api/controller/get-list/transform/filter.utility.js +10 -6
  52. package/dist/esm/utility/api/controller/get-list/transform/filter.utility.js.map +1 -1
  53. package/dist/esm/utility/api/function-transaction.utility.d.ts +4 -2
  54. package/dist/esm/utility/api/function-transaction.utility.js +13 -3
  55. package/dist/esm/utility/api/function-transaction.utility.js.map +1 -1
  56. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { ApiServiceBase } from '../../../class/api/service-base.class.js';
1
2
  import '../../../class/api/function/context-storage.class.js';
2
3
  import '../../../class/api/subscriber/executor.class.js';
3
4
  import '../../../enum/decorator/api/action.enum.js';
@@ -36,7 +37,7 @@ import { ApiFunction } from '../function/decorator.js';
36
37
  * @see {@link https://elsikora.com/docs/nestjs-crud-automator/core-concepts/services | Core Concepts - Services}
37
38
  */
38
39
  function ApiService(properties) {
39
- const { entity } = properties;
40
+ const { entity, functions } = properties;
40
41
  // eslint-disable-next-line @elsikora/typescript/no-explicit-any
41
42
  return function (target) {
42
43
  const originalConstructor = target;
@@ -46,7 +47,7 @@ function ApiService(properties) {
46
47
  constructor(..._arguments) {
47
48
  // eslint-disable-next-line @elsikora/typescript/no-unsafe-argument
48
49
  super(..._arguments);
49
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET_LIST)) {
50
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.GET_LIST)) {
50
51
  Object.defineProperty(this, EApiFunctionType.GET_LIST, {
51
52
  // eslint-disable-next-line @elsikora/typescript/naming-convention
52
53
  configurable: true,
@@ -55,6 +56,7 @@ function ApiService(properties) {
55
56
  value: async function (properties) {
56
57
  const apiFunctionDecorator = ApiFunction({
57
58
  entity,
59
+ transaction: functions?.[EApiFunctionType.GET_LIST]?.transaction,
58
60
  type: EApiFunctionType.GET_LIST,
59
61
  });
60
62
  const descriptor = {
@@ -74,7 +76,7 @@ function ApiService(properties) {
74
76
  writable: true,
75
77
  });
76
78
  }
77
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET)) {
79
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.GET)) {
78
80
  Object.defineProperty(this, EApiFunctionType.GET, {
79
81
  // eslint-disable-next-line @elsikora/typescript/naming-convention
80
82
  configurable: true,
@@ -83,6 +85,7 @@ function ApiService(properties) {
83
85
  value: async function (properties) {
84
86
  const apiFunctionDecorator = ApiFunction({
85
87
  entity,
88
+ transaction: functions?.[EApiFunctionType.GET]?.transaction,
86
89
  type: EApiFunctionType.GET,
87
90
  });
88
91
  const descriptor = {
@@ -102,7 +105,7 @@ function ApiService(properties) {
102
105
  writable: true,
103
106
  });
104
107
  }
105
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.GET_MANY)) {
108
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.GET_MANY)) {
106
109
  Object.defineProperty(this, EApiFunctionType.GET_MANY, {
107
110
  // eslint-disable-next-line @elsikora/typescript/naming-convention
108
111
  configurable: true,
@@ -111,6 +114,7 @@ function ApiService(properties) {
111
114
  value: async function (properties) {
112
115
  const apiFunctionDecorator = ApiFunction({
113
116
  entity,
117
+ transaction: functions?.[EApiFunctionType.GET_MANY]?.transaction,
114
118
  type: EApiFunctionType.GET_MANY,
115
119
  });
116
120
  const descriptor = {
@@ -130,7 +134,7 @@ function ApiService(properties) {
130
134
  writable: true,
131
135
  });
132
136
  }
133
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.CREATE)) {
137
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.CREATE)) {
134
138
  Object.defineProperty(this, EApiFunctionType.CREATE, {
135
139
  // eslint-disable-next-line @elsikora/typescript/naming-convention
136
140
  configurable: true,
@@ -139,6 +143,7 @@ function ApiService(properties) {
139
143
  value: async function (properties) {
140
144
  const apiFunctionDecorator = ApiFunction({
141
145
  entity,
146
+ transaction: functions?.[EApiFunctionType.CREATE]?.transaction,
142
147
  type: EApiFunctionType.CREATE,
143
148
  });
144
149
  const descriptor = {
@@ -158,7 +163,7 @@ function ApiService(properties) {
158
163
  writable: true,
159
164
  });
160
165
  }
161
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.UPDATE)) {
166
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.UPDATE)) {
162
167
  Object.defineProperty(this, EApiFunctionType.UPDATE, {
163
168
  // eslint-disable-next-line @elsikora/typescript/naming-convention
164
169
  configurable: true,
@@ -167,6 +172,7 @@ function ApiService(properties) {
167
172
  value: async function (criteria, properties) {
168
173
  const apiFunctionDecorator = ApiFunction({
169
174
  entity,
175
+ transaction: functions?.[EApiFunctionType.UPDATE]?.transaction,
170
176
  type: EApiFunctionType.UPDATE,
171
177
  });
172
178
  const descriptor = {
@@ -186,7 +192,7 @@ function ApiService(properties) {
186
192
  writable: true,
187
193
  });
188
194
  }
189
- if (!Object.prototype.hasOwnProperty.call(this, EApiFunctionType.DELETE)) {
195
+ if (ApiServiceShouldDefineFunction(this, originalConstructor.prototype, EApiFunctionType.DELETE)) {
190
196
  Object.defineProperty(this, EApiFunctionType.DELETE, {
191
197
  // eslint-disable-next-line @elsikora/typescript/naming-convention
192
198
  configurable: true,
@@ -195,6 +201,7 @@ function ApiService(properties) {
195
201
  value: async function (criteria) {
196
202
  const apiFunctionDecorator = ApiFunction({
197
203
  entity,
204
+ transaction: functions?.[EApiFunctionType.DELETE]?.transaction,
198
205
  type: EApiFunctionType.DELETE,
199
206
  });
200
207
  const descriptor = {
@@ -208,7 +215,7 @@ function ApiService(properties) {
208
215
  writable: true,
209
216
  };
210
217
  const decoratedDescriptor = apiFunctionDecorator(this, EApiFunctionType.DELETE, descriptor);
211
- return decoratedDescriptor.value.call(this, criteria);
218
+ await decoratedDescriptor.value.call(this, criteria);
212
219
  },
213
220
  // eslint-disable-next-line @elsikora/typescript/naming-convention
214
221
  writable: true,
@@ -220,6 +227,26 @@ function ApiService(properties) {
220
227
  return ExtendedClass;
221
228
  };
222
229
  }
230
+ /**
231
+ * Checks whether ApiService should define a generated function on the instance.
232
+ * @param {unknown} instance - Service instance after constructor field initializers ran.
233
+ * @param {unknown} prototype - Original service prototype.
234
+ * @param {EApiFunctionType} functionName - Generated function name.
235
+ * @returns {boolean} True when no direct implementation exists.
236
+ */
237
+ function ApiServiceShouldDefineFunction(instance, prototype, functionName) {
238
+ if (Object.prototype.hasOwnProperty.call(instance, functionName)) {
239
+ return false;
240
+ }
241
+ let currentPrototype = typeof prototype === "object" && prototype !== null ? prototype : null;
242
+ while (currentPrototype && currentPrototype !== Object.prototype) {
243
+ if (Object.prototype.hasOwnProperty.call(currentPrototype, functionName)) {
244
+ return currentPrototype === ApiServiceBase.prototype;
245
+ }
246
+ currentPrototype = Object.getPrototypeOf(currentPrototype);
247
+ }
248
+ return true;
249
+ }
223
250
 
224
251
  export { ApiService };
225
252
  //# sourceMappingURL=decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorator.js","sources":["../../../../../../src/decorator/api/service/decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;AAOG;AACG,SAAU,UAAU,CAA2B,UAAoC,EAAA;AACxF,IAAA,MAAM,EAAE,MAAM,EAAE,GAA6B,UAAU;;AAGvD,IAAA,OAAO,UAAuE,MAAiB,EAAA;QAC9F,MAAM,mBAAmB,GAAc,MAAM;;AAG7C,QAAA,MAAM,aAAa,GAAmE,cAAc,mBAAmB,CAAA;;AAEtH,YAAA,WAAA,CAAY,GAAG,UAAsB,EAAA;;AAEpC,gBAAA,KAAK,CAAC,GAAG,UAAU,CAAC;AAEpB,gBAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE;oBAC3E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,QAAQ,EAAE;;AAEtD,wBAAA,YAAY,EAAE,IAAI;;AAElB,wBAAA,UAAU,EAAE,IAAI;wBAChB,KAAK,EAAE,gBAAgB,UAA4C,EAAA;4BAClE,MAAM,oBAAoB,GAAmG,WAAW,CAAC;gCACxI,MAAM;gCACN,IAAI,EAAE,gBAAgB,CAAC,QAAQ;AAC/B,6BAAA,CAAC;AAEF,4BAAA,MAAM,UAAU,GAQZ;;AAEH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CAAC;wBAC3L,CAAC;;AAED,wBAAA,QAAQ,EAAE,IAAI;AACd,qBAAA,CAAC;gBACH;AAEA,gBAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE;oBACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE;;AAEpD,wBAAA,YAAY,EAAE,IAAI;;AAElB,wBAAA,UAAU,EAAE,IAAI;wBAChB,KAAK,EAAE,gBAAgB,QAAuC,EAAA;4BAC7D,MAAM,oBAAoB,GAAkG,WAAW,CAAC;gCACvI,MAAM;gCACN,IAAI,EAAE,gBAAgB,CAAC,MAAM;AAC7B,6BAAA,CAAC;AAEF,4BAAA,MAAM,UAAU,GAQZ;;AAEH,gCAAA,YAAY,EAAE,IAAI;;AAElB,gCAAA,UAAU,EAAE,IAAI;;AAEhB,gCAAA,KAAK,EAAE,MAAM,MAAM;;AAEnB,gCAAA,QAAQ,EAAE,IAAI;6BACd;AAED,4BAAA,MAAM,mBAAmB,GAAuB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC;4BAE/G,OAAQ,mBAAmB,CAAC,KAAmF,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC;wBACrI,CAAC;;AAED,wBAAA,QAAQ,EAAE,IAAI;AACd,qBAAA,CAAC;gBACH;YACD;SACA;AAED,QAAA,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,mBAAmB,CAAC;AAEzD,QAAA,OAAO,aAA0B;AAClC,IAAA,CAAC;AACF;;;;"}
1
+ {"version":3,"file":"decorator.js","sources":["../../../../../../src/decorator/api/service/decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;;;;;;AAOG;AACG,SAAU,UAAU,CAA2B,UAAoC,EAAA;AACxF,IAAA,MAAM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C,SAAS,EAAE;AACjE,QAAA,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EAAE;AACzE,YAAA,OAAO,gBAAgB,KAAK,cAAc,CAAC,SAAS;QACrD;AAEA,QAAA,gBAAgB,GAAG,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAkB;IAC5E;AAEA,IAAA,OAAO,IAAI;AACZ;;;;"}
@@ -0,0 +1,2 @@
1
+ export { type TApiServiceFunctionPropertiesMap } from './map.type';
2
+ export { type TApiServiceFunctionProperties } from './properties.type';
@@ -0,0 +1,5 @@
1
+ import { EApiFunctionType } from '../../../../../enum/decorator/api';
2
+ import { TApiServiceFunctionProperties } from './properties.type';
3
+ export type TApiServiceFunctionPropertiesMap = {
4
+ [EApiFunctionType.CUSTOM]?: never;
5
+ } & Partial<Record<Exclude<EApiFunctionType, EApiFunctionType.CUSTOM>, TApiServiceFunctionProperties>>;
@@ -0,0 +1,6 @@
1
+ import { EApiFunctionTransactionMode } from '../../../../../enum/decorator/api';
2
+ export type TApiServiceFunctionProperties = {
3
+ transaction: {
4
+ mode: EApiFunctionTransactionMode;
5
+ };
6
+ };
@@ -1,2 +1,3 @@
1
+ export type * from './function';
1
2
  export { type TApiServiceKeys } from './keys.type';
2
3
  export { type TApiServiceProperties } from './properties.type';
@@ -1,3 +1,5 @@
1
+ import { TApiServiceFunctionPropertiesMap } from './function';
1
2
  export type TApiServiceProperties<E> = {
2
3
  entity: new () => E;
4
+ functions?: TApiServiceFunctionPropertiesMap;
3
5
  };
@@ -1,4 +1,6 @@
1
1
  import { IApiEntity } from '../../../../../interface/entity';
2
+ import { Type } from '@nestjs/common';
3
+ import { IAuthGuard } from '@nestjs/passport';
2
4
  import { FindOptionsWhere } from '../../../../../../node_modules/typeorm/index';
3
5
  /**
4
6
  * Transforms query parameters into TypeORM FindOptionsWhere filter objects.
@@ -6,7 +8,8 @@ import { FindOptionsWhere } from '../../../../../../node_modules/typeorm/index';
6
8
  * Handles special cases for relation properties.
7
9
  * @param {Record<string, unknown>} query - The query parameters from the HTTP request
8
10
  * @param {IApiEntity<E>} entityMetadata - The entity metadata containing column information
11
+ * @param {Type<IAuthGuard>} currentGuard - Optional guard used to mirror generated query DTO visibility.
9
12
  * @returns {FindOptionsWhere<E>} The TypeORM filter object for the query
10
13
  * @template E - The entity type
11
14
  */
12
- export declare function ApiControllerGetListTransformFilter<E>(query: Record<string, unknown>, entityMetadata: IApiEntity<E>): FindOptionsWhere<E>;
15
+ export declare function ApiControllerGetListTransformFilter<E>(query: Record<string, unknown>, entityMetadata: IApiEntity<E>, currentGuard?: Type<IAuthGuard>): FindOptionsWhere<E>;
@@ -7,7 +7,7 @@ import '../../../../../enum/decorator/api/controller/relation-reference-shape.en
7
7
  import '../../../../../enum/decorator/api/controller/request/target.enum.js';
8
8
  import '../../../../../enum/decorator/api/controller/request/transformer-type.enum.js';
9
9
  import '../../../../../enum/decorator/api/controller/response-target.enum.js';
10
- import '../../../../../enum/decorator/api/dto-type.enum.js';
10
+ import { EApiDtoType } from '../../../../../enum/decorator/api/dto-type.enum.js';
11
11
  import '../../../../../enum/decorator/api/function-transaction-mode.enum.js';
12
12
  import '../../../../../enum/decorator/api/function-type.enum.js';
13
13
  import '../../../../../enum/decorator/api/on-type.enum.js';
@@ -17,7 +17,8 @@ import '../../../../../enum/decorator/api/property/date/type.enum.js';
17
17
  import { EApiPropertyDescribeType } from '../../../../../enum/decorator/api/property/desribe-type.enum.js';
18
18
  import '../../../../../enum/decorator/api/property/number-type.enum.js';
19
19
  import '../../../../../enum/decorator/api/property/string-type.enum.js';
20
- import '../../../../../enum/decorator/api/route-type.enum.js';
20
+ import { EApiRouteType } from '../../../../../enum/decorator/api/route-type.enum.js';
21
+ import { DtoIsPropertyShouldBeMarked } from '../../../../dto/is/property/should-be-marked.utility.js';
21
22
  import { GenerateEntityInformation } from '../../../../generate-entity-information.utility.js';
22
23
  import { ApiControllerGetListTransformOperation } from './operation.utility.js';
23
24
 
@@ -27,10 +28,11 @@ import { ApiControllerGetListTransformOperation } from './operation.utility.js';
27
28
  * Handles special cases for relation properties.
28
29
  * @param {Record<string, unknown>} query - The query parameters from the HTTP request
29
30
  * @param {IApiEntity<E>} entityMetadata - The entity metadata containing column information
31
+ * @param {Type<IAuthGuard>} currentGuard - Optional guard used to mirror generated query DTO visibility.
30
32
  * @returns {FindOptionsWhere<E>} The TypeORM filter object for the query
31
33
  * @template E - The entity type
32
34
  */
33
- function ApiControllerGetListTransformFilter(query, entityMetadata) {
35
+ function ApiControllerGetListTransformFilter(query, entityMetadata, currentGuard) {
34
36
  const filter = {};
35
37
  const filterRecord = filter;
36
38
  for (const fullKey of Object.keys(query)) {
@@ -49,7 +51,7 @@ function ApiControllerGetListTransformFilter(query, entityMetadata) {
49
51
  if (path.length === 1) {
50
52
  const column = entityMetadata.columns.find((column) => column.name == key);
51
53
  const columnMetadata = column?.metadata?.[PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_KEY];
52
- if (!columnMetadata || columnMetadata.type === EApiPropertyDescribeType.RELATION)
54
+ if (!column || !columnMetadata || !DtoIsPropertyShouldBeMarked(EApiRouteType.GET_LIST, EApiDtoType.QUERY, key, columnMetadata, column.isPrimary, currentGuard) || columnMetadata.type === EApiPropertyDescribeType.RELATION)
53
55
  continue;
54
56
  filterRecord[key] = ApiControllerGetListTransformOperation(operation, value);
55
57
  }
@@ -62,7 +64,7 @@ function ApiControllerGetListTransformFilter(query, entityMetadata) {
62
64
  continue;
63
65
  const relationColumn = entityMetadata.columns.find((column) => column.name == relationName);
64
66
  const relationMetadata = relationColumn?.metadata?.[PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_KEY];
65
- if (relationMetadata?.type !== EApiPropertyDescribeType.RELATION || !relationColumn?.relation?.target)
67
+ if (!relationColumn || relationMetadata?.type !== EApiPropertyDescribeType.RELATION || !relationColumn.relation?.target || !DtoIsPropertyShouldBeMarked(EApiRouteType.GET_LIST, EApiDtoType.QUERY, relationName, relationMetadata, relationColumn.isPrimary, currentGuard))
66
68
  continue;
67
69
  let relationEntityMetadata;
68
70
  try {
@@ -73,7 +75,9 @@ function ApiControllerGetListTransformFilter(query, entityMetadata) {
73
75
  }
74
76
  const nestedColumn = relationEntityMetadata.columns.find((column) => column.name == nestedPropertyName);
75
77
  const nestedColumnMetadata = nestedColumn?.metadata?.[PROPERTY_DESCRIBE_DECORATOR_API_CONSTANT.METADATA_KEY];
76
- if (!nestedColumnMetadata || nestedColumnMetadata.type === EApiPropertyDescribeType.RELATION || nestedColumnMetadata.type === EApiPropertyDescribeType.OBJECT)
78
+ if (!nestedColumn || !nestedColumnMetadata || nestedColumnMetadata.type === EApiPropertyDescribeType.RELATION || nestedColumnMetadata.type === EApiPropertyDescribeType.OBJECT)
79
+ continue;
80
+ if (!nestedColumn.isPrimary && !DtoIsPropertyShouldBeMarked(EApiRouteType.GET_LIST, EApiDtoType.QUERY, nestedPropertyName, nestedColumnMetadata, nestedColumn.isPrimary, currentGuard))
77
81
  continue;
78
82
  const relationFilter = (filterRecord[relationName] ?? {});
79
83
  relationFilter[nestedPropertyName] = ApiControllerGetListTransformOperation(operation, value);
@@ -1 +1 @@
1
- {"version":3,"file":"filter.utility.js","sources":["../../../../../../../../src/utility/api/controller/get-list/transform/filter.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;AAQG;AACG,SAAU,mCAAmC,CAAI,KAA8B,EAAE,cAA6B,EAAA;IACnH,MAAM,MAAM,GAAwB,EAAE;IACtC,MAAM,YAAY,GAA4B,MAAM;IAEpD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACzC,QAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE;AAE5B,QAAA,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAkB,OAAO,CAAC,K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AC,IAAI,IAAI,YAAY,CAAC;gBACjJ,MAAM,gBAAgB,GAA+C,cAAc,EAAE,QAAQ,GAAG,wCAAwC,CAAC,YAAY,CAA+C;AAEpM,gBAAA,IAAI,gBAAgB,EAAE,IAAI,KAAK,wBAAwB,CAAC,QAAQ,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM;oBAAE;AAEvG,gBAAA,IAAI,sBAA2C;AAE/C,gBAAA,IAAI;oBACH,sBAAsB,GAAG,yBAAyB,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACnF;AAAE,gBAAA,MAAM;oBACP;gBACD;AAEA,gBAAA,MAAM,YAAY,GAA0C,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAiC,KAAK,MAAM,CAAC,IAAI,IAAI,kBAAkB,CAAC;gBACzK,MAAM,oBAAoB,GAA+C,YAAY,EAAE,QAAQ,GAAG,wCAAwC,CAAC,YAAY,CAA+C;AAEtM,gBAAA,IAAI,CAAC,oBAAoB,IAAI,oBAAoB,CAAC,IAAI,KAAK,wBAAwB,CAAC,QAAQ,IAAI,oBAAoB,CAAC,IAAI,KAAK,wBAAwB,CAAC,MAAM;oBAAE;gBAE/J,MAAM,cAAc,IAA6B,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE,CAA4B;gBAE7G,cAAc,CAAC,kBAAkB,CAAC,GAAG,sCAAsC,CAAC,SAAS,EAAE,KAAK,CAAC;AAE7F,gBAAA,YAAY,CAAC,YAAY,CAAC,GAAG,cAAc;YAC5C;QACD;IACD;AAEA,IAAA,OAAO,MAAM;AACd;;;;"}
1
+ {"version":3,"file":"filter.utility.js","sources":["../../../../../../../../src/utility/api/controller/get-list/transform/filter.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;AASG;SACa,mCAAmC,CAAI,KAA8B,EAAE,cAA6B,EAAE,YAA+B,EAAA;IACpJ,MAAM,MAAM,GA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,CAAC,IAAI,KAAK,wBAAwB,CAAC,QAAQ,IAAI,oBAAoB,CAAC,IAAI,KAAK,wBAAwB,CAAC,MAAM;oBAAE;gBAEhL,IAAI,CAAC,YAAY,CAAC,SAAS,IAAI,CAAC,2BAA2B,CAAC,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC;oBAAE;gBAExL,MAAM,cAAc,IAA6B,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE,CAA4B;gBAE7G,cAAc,CAAC,kBAAkB,CAAC,GAAG,sCAAsC,CAAC,SAAS,EAAE,KAAK,CAAC;AAE7F,gBAAA,YAAY,CAAC,YAAY,CAAC,GAAG,cAAc;YAC5C;QACD;IACD;AAEA,IAAA,OAAO,MAAM;AACd;;;;"}
@@ -9,12 +9,14 @@ import { EApiFunctionTransactionMode } from '../../enum/decorator/api';
9
9
  * @param {(eventManager: EntityManager | undefined) => Promise<R>} options.callback - Function body to run with the resolved transaction manager.
10
10
  * @param {new (...arguments_: Array<unknown>) => E} options.entity - Entity constructor associated with the function.
11
11
  * @param {EApiFunctionTransactionMode} options.mode - Transaction mode to enforce.
12
- * @param {Repository<E>} options.repository - Repository used to open new transactions when required.
12
+ * @param {(eventManager: EntityManager | undefined, error: Error) => Promise<void>} [options.onPreflightError] - Error hook for transaction mode conflicts before the function body starts.
13
+ * @param {Repository<E>} [options.repository] - Repository used to open new transactions when required.
13
14
  * @returns {Promise<R>} Callback result.
14
15
  */
15
16
  export declare function ApiFunctionExecuteWithTransaction<E extends IApiBaseEntity, R>(options: {
16
17
  callback: (eventManager: EntityManager | undefined) => Promise<R>;
17
18
  entity: new (...arguments_: Array<unknown>) => E;
18
19
  mode: EApiFunctionTransactionMode;
19
- repository: Repository<E>;
20
+ onPreflightError?: (eventManager: EntityManager | undefined, error: Error) => Promise<void>;
21
+ repository?: Repository<E>;
20
22
  }): Promise<R>;
@@ -28,19 +28,29 @@ import { ErrorException } from '../error/exception.utility.js';
28
28
  * @param {(eventManager: EntityManager | undefined) => Promise<R>} options.callback - Function body to run with the resolved transaction manager.
29
29
  * @param {new (...arguments_: Array<unknown>) => E} options.entity - Entity constructor associated with the function.
30
30
  * @param {EApiFunctionTransactionMode} options.mode - Transaction mode to enforce.
31
- * @param {Repository<E>} options.repository - Repository used to open new transactions when required.
31
+ * @param {(eventManager: EntityManager | undefined, error: Error) => Promise<void>} [options.onPreflightError] - Error hook for transaction mode conflicts before the function body starts.
32
+ * @param {Repository<E>} [options.repository] - Repository used to open new transactions when required.
32
33
  * @returns {Promise<R>} Callback result.
33
34
  */
34
35
  async function ApiFunctionExecuteWithTransaction(options) {
35
36
  const activeEventManager = ApiFunctionContextStorage.get()?.eventManager;
36
37
  if (options.mode === EApiFunctionTransactionMode.NONE && activeEventManager) {
37
- throw ErrorException("ApiFunction transaction mode NONE cannot run inside an active transaction");
38
+ const error = ErrorException("ApiFunction transaction mode NONE cannot run inside an active transaction");
39
+ await options.onPreflightError?.(activeEventManager, error);
40
+ throw error;
38
41
  }
39
42
  if (options.mode === EApiFunctionTransactionMode.MANDATORY && !activeEventManager) {
40
- throw ErrorException("ApiFunction transaction mode MANDATORY requires an active transaction");
43
+ const error = ErrorException("ApiFunction transaction mode MANDATORY requires an active transaction");
44
+ await options.onPreflightError?.(undefined, error);
45
+ throw error;
41
46
  }
42
47
  const eventManager = options.mode === EApiFunctionTransactionMode.NONE ? undefined : activeEventManager;
43
48
  if (options.mode === EApiFunctionTransactionMode.REQUIRED && !eventManager) {
49
+ if (!options.repository) {
50
+ const error = ErrorException("Repository is not available in this context");
51
+ await options.onPreflightError?.(undefined, error);
52
+ throw error;
53
+ }
44
54
  return await options.repository.manager.transaction(async (transactionManager) => await ApiFunctionTransactionScope.runWithEntityManager(transactionManager, async () => await options.callback(transactionManager)));
45
55
  }
46
56
  return await options.callback(eventManager);
@@ -1 +1 @@
1
- {"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;AAUG;AACI,eAAe,iCAAiC,CAA8B,OAA8L,EAAA;IAClR,MAAM,kBAAkB,GAA8B,yBAAyB,CAAC,GAAG,EAAK,EAAE,YAAY;IAEtG,IAAI,OAAO,CAAC,IAAI,KAAK,2BAA2B,CAAC,IAAI,IAAI,kBAAkB,EAAE;AAC5E,QAAA,MAAM,cAAc,CAAC,2EAA2E,CAAC;IAClG;IAEA,IAAI,OAAO,CAAC,IAAI,KAAK,2BAA2B,CAAC,SAAS,IAAI,CAAC,kBAAkB,EAAE;AAClF,QAAA,MAAM,cAAc,CAAC,uEAAuE,CAAC;IAC9F;AAEA,IAAA,MAAM,YAAY,GAA8B,OAAO,CAAC,IAAI,KAAK,2BAA2B,CAAC,IAAI,GAAG,SAAS,GAAG,kBAAkB;IAElI,IAAI,OAAO,CAAC,IAAI,KAAK,2BAA2B,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE;AAC3E,QAAA,OAAO,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,kBAAiC,KAAiB,MAAM,2BAA2B,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,YAAwB,MAAM,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC7P;AAEA,IAAA,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;AAC5C;;;;"}
1
+ {"version":3,"file":"function-transaction.utility.js","sources":["../../../../../src/utility/api/function-transaction.utility.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;AAWG;AACI,eAAe,iCAAiC,CAA8B,OAA4R,EAAA;IAChX,MAAM,kBAAkB,GAA8B,yBAAyB,CAAC,GAAG,EAAK,EAAE,YAAY;IAEtG,IAAI,OAAO,CAA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"description": "A library for automating the creation of CRUD operations in NestJS.",
5
5
  "keywords": [
6
6
  "NestJS",