@decaf-ts/for-nest 0.1.23 → 0.2.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 (166) hide show
  1. package/README.md +1 -1
  2. package/dist/for-nest.cjs +1 -1
  3. package/dist/for-nest.cjs.map +1 -1
  4. package/dist/for-nest.js +1 -1
  5. package/dist/for-nest.js.map +1 -1
  6. package/lib/constants.cjs +2 -1
  7. package/lib/constants.d.ts +8 -0
  8. package/lib/constants.js.map +1 -1
  9. package/lib/controllers.cjs +67 -0
  10. package/lib/controllers.d.ts +20 -0
  11. package/lib/controllers.js.map +1 -0
  12. package/lib/core-module.cjs +57 -28
  13. package/lib/core-module.d.ts +4 -4
  14. package/lib/core-module.js.map +1 -1
  15. package/lib/decaf-model/DecafModelModule.cjs +54 -49
  16. package/lib/decaf-model/DecafModelModule.d.ts +8 -6
  17. package/lib/decaf-model/DecafModelModule.js.map +1 -1
  18. package/lib/decaf-model/FromModelController.cjs +97 -48
  19. package/lib/decaf-model/FromModelController.d.ts +2 -2
  20. package/lib/decaf-model/FromModelController.js.map +1 -1
  21. package/lib/decaf-model/decorators/DecafBody.cjs +1 -1
  22. package/lib/decaf-model/decorators/DecafParams.cjs +23 -8
  23. package/lib/decaf-model/decorators/DecafParams.d.ts +1 -0
  24. package/lib/decaf-model/decorators/DecafParams.js.map +1 -1
  25. package/lib/decaf-model/types.cjs +0 -12
  26. package/lib/decaf-model/types.d.ts +3 -14
  27. package/lib/decaf-model/types.js.map +1 -1
  28. package/lib/decaf-model/utils.cjs +1 -1
  29. package/lib/decaf-model/utils.d.ts +3 -2
  30. package/lib/decaf-model/utils.js.map +1 -1
  31. package/lib/decoration.cjs +53 -33
  32. package/lib/decoration.js.map +1 -1
  33. package/lib/esm/constants.d.ts +8 -0
  34. package/lib/esm/constants.js +1 -0
  35. package/lib/esm/constants.js.map +1 -1
  36. package/lib/esm/controllers.d.ts +20 -0
  37. package/lib/esm/controllers.js +62 -0
  38. package/lib/esm/controllers.js.map +1 -0
  39. package/lib/esm/core-module.d.ts +4 -4
  40. package/lib/esm/core-module.js +57 -28
  41. package/lib/esm/core-module.js.map +1 -1
  42. package/lib/esm/decaf-model/DecafModelModule.d.ts +8 -6
  43. package/lib/esm/decaf-model/DecafModelModule.js +53 -48
  44. package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
  45. package/lib/esm/decaf-model/FromModelController.d.ts +2 -2
  46. package/lib/esm/decaf-model/FromModelController.js +100 -51
  47. package/lib/esm/decaf-model/FromModelController.js.map +1 -1
  48. package/lib/esm/decaf-model/decorators/DecafBody.js +1 -1
  49. package/lib/esm/decaf-model/decorators/DecafParams.d.ts +1 -0
  50. package/lib/esm/decaf-model/decorators/DecafParams.js +22 -8
  51. package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -1
  52. package/lib/esm/decaf-model/types.d.ts +3 -14
  53. package/lib/esm/decaf-model/types.js +1 -10
  54. package/lib/esm/decaf-model/types.js.map +1 -1
  55. package/lib/esm/decaf-model/utils.d.ts +3 -2
  56. package/lib/esm/decaf-model/utils.js +1 -1
  57. package/lib/esm/decaf-model/utils.js.map +1 -1
  58. package/lib/esm/decoration.js +45 -25
  59. package/lib/esm/decoration.js.map +1 -1
  60. package/lib/esm/factory/openapi/DtoBuilder.d.ts +15 -0
  61. package/lib/esm/factory/openapi/DtoBuilder.js +88 -0
  62. package/lib/esm/factory/openapi/DtoBuilder.js.map +1 -0
  63. package/lib/esm/factory/openapi/index.d.ts +1 -0
  64. package/lib/esm/factory/openapi/index.js +1 -0
  65. package/lib/esm/factory/openapi/index.js.map +1 -1
  66. package/lib/esm/index.d.ts +8 -6
  67. package/lib/esm/index.js +8 -6
  68. package/lib/esm/index.js.map +1 -1
  69. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.d.ts +8 -4
  70. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js +38 -6
  71. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js.map +1 -1
  72. package/lib/esm/interceptors/context.d.ts +6 -0
  73. package/lib/esm/interceptors/context.js +12 -0
  74. package/lib/esm/interceptors/context.js.map +1 -0
  75. package/lib/esm/module.js +9 -7
  76. package/lib/esm/module.js.map +1 -1
  77. package/lib/esm/overrides/Adapter.d.ts +10 -0
  78. package/lib/esm/overrides/Adapter.js +2 -0
  79. package/lib/esm/overrides/Adapter.js.map +1 -0
  80. package/lib/esm/overrides/constants.d.ts +21 -0
  81. package/lib/esm/overrides/constants.js +22 -0
  82. package/lib/esm/overrides/constants.js.map +1 -0
  83. package/lib/esm/overrides/decoration.d.ts +30 -0
  84. package/lib/esm/overrides/decoration.js +111 -0
  85. package/lib/esm/overrides/decoration.js.map +1 -0
  86. package/lib/esm/overrides/helpers.d.ts +11 -0
  87. package/lib/esm/overrides/helpers.js +136 -0
  88. package/lib/esm/overrides/helpers.js.map +1 -0
  89. package/lib/esm/overrides/index.d.ts +4 -0
  90. package/lib/esm/overrides/index.js +5 -0
  91. package/lib/esm/overrides/index.js.map +1 -0
  92. package/lib/esm/overrides/overrides.d.ts +1 -0
  93. package/lib/esm/overrides/overrides.js +13 -0
  94. package/lib/esm/overrides/overrides.js.map +1 -0
  95. package/lib/esm/request/DecafAuthHandler.d.ts +10 -0
  96. package/lib/esm/request/DecafAuthHandler.js +37 -0
  97. package/lib/esm/request/DecafAuthHandler.js.map +1 -0
  98. package/lib/esm/request/DecafHandlerExecutor.js +1 -1
  99. package/lib/esm/request/DecafHandlerExecutor.js.map +1 -1
  100. package/lib/esm/request/DecafRequestContext.d.ts +5 -4
  101. package/lib/esm/request/DecafRequestContext.js +7 -7
  102. package/lib/esm/request/DecafRequestContext.js.map +1 -1
  103. package/lib/esm/request/RamRequestTransformer.d.ts +5 -0
  104. package/lib/esm/request/RamRequestTransformer.js +25 -0
  105. package/lib/esm/request/RamRequestTransformer.js.map +1 -0
  106. package/lib/esm/request/index.d.ts +2 -0
  107. package/lib/esm/request/index.js +2 -0
  108. package/lib/esm/request/index.js.map +1 -1
  109. package/lib/esm/types.d.ts +13 -5
  110. package/lib/factory/openapi/DtoBuilder.cjs +91 -0
  111. package/lib/factory/openapi/DtoBuilder.d.ts +15 -0
  112. package/lib/factory/openapi/DtoBuilder.js.map +1 -0
  113. package/lib/factory/openapi/index.cjs +1 -0
  114. package/lib/factory/openapi/index.d.ts +1 -0
  115. package/lib/factory/openapi/index.js.map +1 -1
  116. package/lib/index.cjs +8 -6
  117. package/lib/index.d.ts +8 -6
  118. package/lib/index.js.map +1 -1
  119. package/lib/interceptors/DecafRequestHandlerInterceptor.cjs +37 -5
  120. package/lib/interceptors/DecafRequestHandlerInterceptor.d.ts +8 -4
  121. package/lib/interceptors/DecafRequestHandlerInterceptor.js.map +1 -1
  122. package/lib/interceptors/context.cjs +17 -0
  123. package/lib/interceptors/context.d.ts +6 -0
  124. package/lib/interceptors/context.js.map +1 -0
  125. package/lib/module.cjs +9 -7
  126. package/lib/module.js.map +1 -1
  127. package/lib/overrides/Adapter.cjs +4 -0
  128. package/lib/overrides/Adapter.d.ts +10 -0
  129. package/lib/overrides/Adapter.js.map +1 -0
  130. package/lib/overrides/constants.cjs +25 -0
  131. package/lib/overrides/constants.d.ts +21 -0
  132. package/lib/overrides/constants.js.map +1 -0
  133. package/lib/overrides/decoration.cjs +120 -0
  134. package/lib/overrides/decoration.d.ts +30 -0
  135. package/lib/overrides/decoration.js.map +1 -0
  136. package/lib/overrides/helpers.cjs +146 -0
  137. package/lib/overrides/helpers.d.ts +11 -0
  138. package/lib/overrides/helpers.js.map +1 -0
  139. package/lib/overrides/index.cjs +21 -0
  140. package/lib/overrides/index.d.ts +4 -0
  141. package/lib/overrides/index.js.map +1 -0
  142. package/lib/overrides/overrides.cjs +15 -0
  143. package/lib/overrides/overrides.d.ts +1 -0
  144. package/lib/overrides/overrides.js.map +1 -0
  145. package/lib/request/DecafAuthHandler.cjs +42 -0
  146. package/lib/request/DecafAuthHandler.d.ts +10 -0
  147. package/lib/request/DecafAuthHandler.js.map +1 -0
  148. package/lib/request/DecafHandlerExecutor.cjs +1 -1
  149. package/lib/request/DecafHandlerExecutor.js.map +1 -1
  150. package/lib/request/DecafRequestContext.cjs +7 -7
  151. package/lib/request/DecafRequestContext.d.ts +5 -4
  152. package/lib/request/DecafRequestContext.js.map +1 -1
  153. package/lib/request/RamRequestTransformer.cjs +28 -0
  154. package/lib/request/RamRequestTransformer.d.ts +5 -0
  155. package/lib/request/RamRequestTransformer.js.map +1 -0
  156. package/lib/request/index.cjs +2 -0
  157. package/lib/request/index.d.ts +2 -0
  158. package/lib/request/index.js.map +1 -1
  159. package/lib/types.d.ts +13 -5
  160. package/package.json +9 -1
  161. package/lib/esm/factory/context.d.ts +0 -0
  162. package/lib/esm/factory/context.js +0 -2
  163. package/lib/esm/factory/context.js.map +0 -1
  164. package/lib/factory/context.cjs +0 -2
  165. package/lib/factory/context.d.ts +0 -0
  166. package/lib/factory/context.js.map +0 -1
@@ -1,9 +1,10 @@
1
- import { Controller, type DecoratorBundle } from "./types";
1
+ import { type DecoratorBundle } from "./types";
2
2
  import { type DecafParamProps, HttpVerbs } from "./decorators";
3
3
  import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
4
4
  import { Model } from "@decaf-ts/decorator-validation";
5
+ import { DecafModelController } from "../controllers";
5
6
  export declare function getApiDecorators(methodName: string, routePath: string, httpVerb: HttpVerbs, includeQueryParams?: boolean): DecoratorBundle;
6
7
  export declare function applyApiDecorators(target: any, methodName: string, descriptor: PropertyDescriptor, decorators: DecoratorBundle): void;
7
8
  export declare function resolvePersistenceMethod<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, methodName: string, ...args: any[]): any;
8
- export declare function createRouteHandler<T>(methodName: string): (this: Controller, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
9
+ export declare function createRouteHandler<T>(methodName: string): (this: DecafModelController<any>, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
9
10
  export declare function defineRouteMethod(ControllerClass: new (...args: any[]) => any, methodName: string, handler: (...args: any[]) => any): PropertyDescriptor | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/decaf-model/utils.ts"],"names":[],"mappings":";;AAuCA,4CAgDC;AAED,gDASC;AAED,4DAiBC;AAED,gDA0BC;AAED,8CAkBC;AArKD,2CAAuC;AAGvC,6CAMyB;AACzB,uDAKsB;AACtB,yCAKwB;AAExB,kDAAyD;AAEzD,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAY,EAAE;IACxD,OAAO,SAAS;SACb,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAChC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAY,EAAoB,EAAE,CAAC,CAAC;IACxD,IAAI;IACJ,WAAW,EAAE,GAAG,IAAI,0BAA0B;IAC9C,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,MAAM;CACb,CAAC,CAAC;AAEH,SAAgB,gBAAgB,CAC9B,UAAkB,EAClB,SAAiB,EACjB,QAAmB,EACnB,qBAA8B,KAAK;IAEnC,MAAM,gBAAgB,GAAG,IAAA,2BAAmB,EAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAErE,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAC9B,IAAI,QAAQ,KAAK,KAAK,IAAI,kBAAkB,EAAE,CAAC;QAC7C,kBAAkB,CAAC,IAAI,CACrB,IAAA,kBAAQ,EAAC;YACP,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,qBAAc;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M,EAAE,CAAC;YAChB,GAAG,CAAC,KAAK,CAAC,iBAAiB,UAAU,UAAU,EAAE,CAAC,CAAC,CAAC;YACpD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAC/B,eAA4C,EAC5C,UAAkB,EAClB,OAAgC;IAEhC,MAAM,CAAC,cAAc,CACnB,eAAe,CAAC,SAAS,IAAI,eAAe,EAC5C,UAAU,EACV;QACE,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,KAAK;KAChB,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,wBAAwB,CACpC,eAAe,CAAC,SAAS,IAAI,eAAe,EAC5C,UAAU,CACX,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@ const common_1 = require("@nestjs/common");
5
5
  const decoration_1 = require("@decaf-ts/decoration");
6
6
  const decorator_validation_1 = require("@decaf-ts/decorator-validation");
7
7
  const core_1 = require("@decaf-ts/core");
8
- const swagger_1 = require("@nestjs/swagger");
8
+ const decoration_2 = require("./overrides/decoration.cjs");
9
9
  decoration_1.Decoration.for(injectable_decorators_1.InjectablesKeys.INJECTABLE)
10
10
  .extend({
11
11
  decorator: function nestInjectable(category, cfg) {
@@ -33,75 +33,95 @@ decoration_1.Decoration.for(injectable_decorators_1.InjectablesKeys.INJECT)
33
33
  })
34
34
  .apply();
35
35
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.REQUIRED)
36
- .extend((0, swagger_1.ApiProperty)({
36
+ .extend((0, decoration_2.ApiProperty)({
37
37
  required: true,
38
38
  }))
39
39
  .apply();
40
40
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MAX)
41
41
  .extend({
42
42
  decorator: function maxDec(max) {
43
- return (0, swagger_1.ApiProperty)({ maximum: max });
43
+ return (0, decoration_2.ApiProperty)({ maximum: max });
44
44
  },
45
45
  })
46
46
  .apply();
47
47
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MIN)
48
48
  .extend({
49
49
  decorator: function minDec(min) {
50
- return (0, swagger_1.ApiProperty)({ minimum: min });
50
+ return (0, decoration_2.ApiProperty)({ minimum: min });
51
51
  },
52
52
  })
53
53
  .apply();
54
54
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MAX_LENGTH)
55
55
  .extend({
56
56
  decorator: function maxLengthDec(max) {
57
- return (0, swagger_1.ApiProperty)({ maxLength: max });
57
+ return (0, decoration_2.ApiProperty)({ maxLength: max });
58
58
  },
59
59
  })
60
60
  .apply();
61
61
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MIN_LENGTH)
62
62
  .extend({
63
63
  decorator: function minLengthDec(min) {
64
- return (0, swagger_1.ApiProperty)({ minLength: min });
64
+ return (0, decoration_2.ApiProperty)({ minLength: min });
65
65
  },
66
66
  })
67
67
  .apply();
68
- //
69
- // Decoration.for(ValidationKeys.TYPE)
70
- // .extend({
71
- // decorator: function typeDec(type: (string | (() => string))[] | string | (() => string)) {
72
- // return ApiProperty({ type: type as any });
73
- // },
74
- // })
75
- // .apply();
76
- //
77
- // Decoration.for(ValidationKeys.DATE)
78
- // .extend({
79
- // decorator: function dateDec() {
80
- // return ApiProperty({ type: Date });
81
- // },
82
- // })
83
- // .apply();
84
- decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.LIST)
68
+ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.TYPE)
85
69
  .extend({
86
- decorator: function listDec(clazz) {
87
- const c = Array.isArray(clazz) ? clazz[0] : clazz;
88
- return (0, swagger_1.ApiProperty)({ type: [c] });
70
+ decorator: function typeDec(type) {
71
+ return (target, prop) => {
72
+ type = Array.isArray(type) ? type[0] : type;
73
+ if (typeof type === "function" && !type.name)
74
+ type = type();
75
+ return (0, decoration_2.ApiProperty)({ type: type })(target, prop);
76
+ };
89
77
  },
90
78
  })
91
79
  .apply();
92
80
  //
93
- // Decoration.for(ValidationKeys.OPTION)
81
+ // Decoration.for(ValidationKeys.LIST)
94
82
  // .extend({
95
- // decorator: function optionDec(options: string[] | Record<string, any>) {
96
- // const opts = Array.isArray(options) ? options : Object.values(options);
97
- // return ApiProperty({ enum: opts });
83
+ // decorator: function listDec(
84
+ // clazz:
85
+ // | Constructor
86
+ // | (() => Constructor)
87
+ // | (Constructor | (() => Constructor))[],
88
+ // // eslint-disable-next-line @typescript-eslint/no-unused-vars
89
+ // collection: "Array" | "Set" = "Array"
90
+ // ) {
91
+ // return (target: object, prop: any) => {
92
+ // clazz = Array.isArray(clazz) ? clazz[0] : clazz;
93
+ // if (typeof clazz === "function" && !clazz.name)
94
+ // clazz = (clazz as () => Constructor)();
95
+ // return ApiProperty({ type: [clazz as any] })(target, prop);
96
+ // };
98
97
  // },
99
98
  // })
100
99
  // .apply();
100
+ // //
101
+ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.DATE)
102
+ .extend({
103
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
104
+ decorator: function dateDec(format) {
105
+ return (0, decoration_2.ApiProperty)({
106
+ type: String,
107
+ format: "date-time",
108
+ // example: parseDate(format, new Date()),
109
+ });
110
+ },
111
+ })
112
+ .apply();
113
+ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.ENUM)
114
+ .extend({
115
+ decorator: function optionDec(options) {
116
+ const opts = Array.isArray(options) ? options : Object.values(options);
117
+ return (0, decoration_2.ApiProperty)({ enum: opts });
118
+ },
119
+ })
120
+ .apply();
101
121
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.PATTERN)
102
122
  .extend({
103
123
  decorator: function patternDec(pat) {
104
- return (0, swagger_1.ApiProperty)({
124
+ return (0, decoration_2.ApiProperty)({
105
125
  pattern: typeof pat === "string" ? pat : pat.source,
106
126
  });
107
127
  },
@@ -110,7 +130,7 @@ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.PATTERN)
110
130
  decoration_1.Decoration.for(core_1.PersistenceKeys.COLUMN)
111
131
  .extend({
112
132
  decorator: function columnDec(name) {
113
- return (0, swagger_1.ApiProperty)({
133
+ return (0, decoration_2.ApiProperty)({
114
134
  name: name,
115
135
  });
116
136
  },
@@ -119,7 +139,7 @@ decoration_1.Decoration.for(core_1.PersistenceKeys.COLUMN)
119
139
  decoration_1.Decoration.for(decoration_1.DecorationKeys.DESCRIPTION)
120
140
  .extend({
121
141
  decorator: function descriptionDec(description) {
122
- return (0, swagger_1.ApiProperty)({
142
+ return (0, decoration_2.ApiProperty)({
123
143
  description: description,
124
144
  });
125
145
  },
@@ -1 +1 @@
1
- {"version":3,"file":"decoration.js","sourceRoot":"","sources":["../src/decoration.ts"],"names":[],"mappings":";;AAAA,2EAKyC;AACzC,2CAA2D;AAC3D,qDAA+E;AAC/E,yEAAgE;AAChE,yCAAiD;AACjD,6CAA8C;AAE9C,uBAAU,CAAC,GAAG,CAAC,uCAAe,CAAC,UAAU,CAAC;KACvC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,cAAc,CAChC,QAA8B,EAC9B,GAAsB;QAEtB,GAAG;YACD,GAAG;gBACH,CAAC,OAAO,QAAQ,KAAK,QAAQ;oBAC3B,CAAC,CAAC,MAAM,CAAC,MAAM,CACX,QAA4B,EAC5B,gDAAwB,CACzB;oBACH,CAAC,CAAC,gDAAwB,CAAC,CAAC;QAChC,OAAO,IAAA,mBAAU,EAAC;YAChB,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,cAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAK,CAAC,OAAO;YACpD,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;SAC1C,CAAC,CAAC;IACL,CAAC;CACF,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,uBAAU,CAAC,GAAG,CAAC,uCAAe,CAAC,MAAM,CAAC;KACnC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,UAAU,CAC5B,QAAuC;IACvC,6DAA6D;IAC7D,GAAkB;QAElB,OAAO,SAAS,eAAe,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DECAF_MODULE_OPTIONS = "DecafModuleOptions";
2
4
  export declare const DECAF_ADAPTER_ID = "DecafAdapter";
3
5
  export declare const DECAF_ROUTE = "DecafRoute";
@@ -6,3 +8,9 @@ export declare const DECAF_ADAPTER_OPTIONS: unique symbol;
6
8
  export declare const AUTH_HANDLER: unique symbol;
7
9
  export declare const AUTH_META_KEY = "auth:meta";
8
10
  export declare const AuthRole = "AuthRole";
11
+ export declare const DECAF_CONTEXT_KEY: unique symbol;
12
+ export type DecafServerFlags<LOG extends Logger = Logger> = AdapterFlags<LOG> & {
13
+ headers: Record<string, any>;
14
+ overrides: Record<string, any>;
15
+ };
16
+ export type DecafServerContext = Context<DecafServerFlags>;
@@ -6,4 +6,5 @@ export const DECAF_ADAPTER_OPTIONS = Symbol("DecafAdapterForOptions");
6
6
  export const AUTH_HANDLER = Symbol("AUTH_HANDLER");
7
7
  export const AUTH_META_KEY = "auth:meta";
8
8
  export const AuthRole = "AuthRole";
9
+ export const DECAF_CONTEXT_KEY = Symbol("decaf:context");
9
10
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAEnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Context, ContextOf, ContextualizedArgs, FlagsOf, MaybeContextualArg, MethodOrOperation, ModelService, Repo, Service } from "@decaf-ts/core";
2
+ import { DecafServerContext } from "./constants";
3
+ import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
4
+ import { DecafRequestContext } from "./request/DecafRequestContext";
5
+ export declare abstract class DecafController<CONTEXT extends DecafServerContext> extends Service<CONTEXT> {
6
+ protected readonly clientContext: DecafRequestContext;
7
+ protected constructor(clientContext: DecafRequestContext, name: string);
8
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD): ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>;
9
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: false, overrides?: Partial<FlagsOf<CONTEXT>>): ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>;
10
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<CONTEXT, ARGS>, operation: METHOD, allowCreate: true, overrides?: Partial<FlagsOf<CONTEXT>>): Promise<ContextualizedArgs<CONTEXT, ARGS, METHOD extends string ? true : false>>;
11
+ }
12
+ export declare abstract class DecafModelController<M extends Model<boolean>, C extends DecafServerContext = DecafServerContext> extends DecafController<C> {
13
+ private _persistence?;
14
+ abstract get class(): ModelConstructor<M>;
15
+ persistence(ctx?: Context<any>): Repo<M> | ModelService<M>;
16
+ protected constructor(clientContext: DecafRequestContext, name: string);
17
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<any, ARGS>, operation: METHOD): ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>;
18
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<ReturnType<this["persistence"]>>, ARGS>, operation: METHOD, allowCreate: false): ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>;
19
+ protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<ContextOf<ReturnType<this["persistence"]>>, ARGS>, operation: METHOD, allowCreate: true): Promise<ContextualizedArgs<ContextOf<ReturnType<this["persistence"]>>, ARGS, METHOD extends string ? true : false>>;
20
+ }
@@ -0,0 +1,62 @@
1
+ import { ContextualLoggedClass, ModelService, Repository, Service, } from "@decaf-ts/core";
2
+ export class DecafController extends Service {
3
+ constructor(clientContext, name) {
4
+ super(name);
5
+ this.clientContext = clientContext;
6
+ }
7
+ logCtx(args, operation, allowCreate = false, overrides) {
8
+ const ctx = this.clientContext.ctx;
9
+ args = args.filter((e) => typeof e !== "undefined");
10
+ return ContextualLoggedClass.logCtx.call(this, operation, overrides || {}, allowCreate, ...[...args, ctx]);
11
+ }
12
+ }
13
+ export class DecafModelController extends DecafController {
14
+ persistence(ctx) {
15
+ if (!this._persistence)
16
+ try {
17
+ this._persistence = ModelService.getService(this.class);
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ }
20
+ catch (e) {
21
+ this._persistence = Repository.forModel(this.class);
22
+ }
23
+ return ctx
24
+ ? this._persistence instanceof Repository
25
+ ? this._persistence.override(ctx.toOverrides())
26
+ : this._persistence.for(ctx.toOverrides())
27
+ : this._persistence;
28
+ }
29
+ constructor(clientContext, name) {
30
+ super(clientContext, name);
31
+ }
32
+ logCtx(args, operation, allowCreate = false) {
33
+ // TODO get nestJS context
34
+ const ctx = this.clientContext.ctx;
35
+ let overrides = {};
36
+ try {
37
+ overrides = ctx.get("overrides");
38
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
+ }
40
+ catch (e) {
41
+ // do nothing
42
+ }
43
+ const persistence = this.persistence(ctx);
44
+ let contextual = undefined;
45
+ if (persistence instanceof ModelService)
46
+ contextual = persistence.repo["adapter"];
47
+ else if (persistence instanceof Repository)
48
+ contextual = persistence["adapter"];
49
+ else if (persistence.context) {
50
+ contextual = persistence;
51
+ }
52
+ let ctxArgs;
53
+ if (!allowCreate) {
54
+ ctxArgs = contextual["logCtx"](args, operation, false, overrides);
55
+ return ctxArgs;
56
+ }
57
+ return contextual["logCtx"](args, operation, true, overrides).then((ctxArgs) => {
58
+ return ctxArgs;
59
+ });
60
+ }
61
+ }
62
+ //# sourceMappingURL=controllers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controllers.js","sourceRoot":"","sources":["../../src/controllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,qBAAqB,EAIrB,YAAY,EAEZ,UAAU,EACV,OAAO,GACR,MAAM,gBAAgB,CAAC;AAMxB,MAAM,OAAgB,eAEpB,SAAQ,OAAgB;IACxB,YACqB,aAAkC,EACrD,IAAY;QAEZ,KAAK,CAAC,IAAI,CAAC,CAAC;QAHO,kBAAa,GAA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E,SAAiB,EACjB,cAAuB,KAAK;QAc5B,0BAA0B;QAE1B,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QACnC,IAAI,SAAS,GAAwB,EAAE,CAAC;QACxC,IAAI,CAAC;YACH,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACjC,6DAA6D;QAC/D,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,aAAa;QACf,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,UAAU,GAA2B,SAAS,CAAC;QACnD,IAAI,WAAW,YAAY,YAAY;YACrC,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACtC,IAAI,WAAW,YAAY,UAAU;YACxC,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;aACjC,IAAK,WAA0C,CAAC,OAAO,EAAE,CAAC;YAC7D,UAAU,GAAG,WAAW,CAAC;QAC3B,CAAC;QAED,IAAI,OAAgC,CAAC;QAErC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,GAAK,UAA0C,CAAC,QAAQ,CAAS,CACtE,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,CACV,CAAC;YAEF,OAAO,OAAc,CAAC;QACxB,CAAC;QAED,OACI,UAA0C,CAAC,QAAQ,CAAS,CAC5D,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,SAAS,CAEZ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACjB,OAAO,OAAO,CAAC;QACjB,CAAC,CAAQ,CAAC;IACZ,CAAC;CACF"}
@@ -1,17 +1,17 @@
1
1
  import { DynamicModule, OnApplicationShutdown } from "@nestjs/common";
2
2
  import { ModuleRef } from "@nestjs/core";
3
3
  import type { DecafModuleOptions } from "./types";
4
- import { Adapter } from "@decaf-ts/core";
4
+ import { Adapter, PersistenceService } from "@decaf-ts/core";
5
5
  import { Logger } from "@decaf-ts/logging";
6
6
  export declare class DecafCoreModule<CONF, ADAPTER extends Adapter<CONF, any, any, any>> implements OnApplicationShutdown {
7
7
  private readonly options;
8
8
  private readonly moduleRef;
9
9
  private static _logger;
10
- private static _adapterInstance;
10
+ private static _persistence?;
11
+ protected static get persistence(): PersistenceService<any>;
11
12
  protected static get log(): Logger;
12
13
  constructor(options: DecafModuleOptions<CONF, ADAPTER>, moduleRef: ModuleRef);
13
- static createAdapter(options: DecafModuleOptions): Promise<Adapter<any, any, any, any>>;
14
- static getAdapterInstance(): Adapter<any, any, any, any> | null;
14
+ static bootPersistence(options: DecafModuleOptions): Promise<Adapter<any, any, any, any>[]>;
15
15
  static forRoot(options: DecafModuleOptions): DynamicModule;
16
16
  onApplicationShutdown(): Promise<void>;
17
17
  }
@@ -14,10 +14,17 @@ var DecafCoreModule_1;
14
14
  import { Global, Inject, Module, Scope, } from "@nestjs/common";
15
15
  import { ModuleRef } from "@nestjs/core";
16
16
  import { DECAF_ADAPTER_ID, DECAF_MODULE_OPTIONS } from "./constants.js";
17
+ import { Adapter, PersistenceService } from "@decaf-ts/core";
17
18
  import { Logging } from "@decaf-ts/logging";
19
+ import { InternalError } from "@decaf-ts/db-decorators";
20
+ import { RequestToContextTransformer, requestToContextTransformer, } from "./interceptors/context.js";
18
21
  let DecafCoreModule = class DecafCoreModule {
19
22
  static { DecafCoreModule_1 = this; }
20
- static { this._adapterInstance = null; }
23
+ static get persistence() {
24
+ if (!this._persistence)
25
+ throw new InternalError("Persistence service not initialized");
26
+ return this._persistence;
27
+ }
21
28
  static get log() {
22
29
  if (!this._logger)
23
30
  this._logger = Logging.for(DecafCoreModule_1);
@@ -27,24 +34,46 @@ let DecafCoreModule = class DecafCoreModule {
27
34
  this.options = options;
28
35
  this.moduleRef = moduleRef;
29
36
  }
30
- static async createAdapter(options) {
31
- if (!this._adapterInstance) {
32
- const log = this.log.for(this.createAdapter);
33
- log.info("Creating adapter instance...");
34
- this._adapterInstance = new options.adapter(options.conf, options.alias);
35
- try {
36
- await this._adapterInstance.initialize();
37
+ static async bootPersistence(options) {
38
+ const log = this.log.for(this.bootPersistence);
39
+ if (!this._persistence) {
40
+ const trimmed = options.conf.map(([contr, cfg, ...args]) => {
41
+ const possible = args.pop();
42
+ if (!possible)
43
+ return [contr, cfg];
44
+ return [contr, cfg, ...args];
45
+ });
46
+ this._persistence = new PersistenceService();
47
+ await this._persistence.boot(trimmed);
48
+ const clients = this._persistence.client;
49
+ for (let i = 0; i < clients.length; i++) {
50
+ const c = options.conf[i];
51
+ let [, , transformer] = c;
52
+ if (!transformer) {
53
+ const contr = Adapter.transformerFor(clients[i].flavour);
54
+ if (!contr)
55
+ throw new InternalError(`No transformer found for flavour ${clients[i].flavour}. you should either @requestToContextTransformer or provide a transformer in the config`);
56
+ transformer =
57
+ contr instanceof RequestToContextTransformer ? contr : new contr();
58
+ }
59
+ requestToContextTransformer(clients[i].flavour)(transformer);
37
60
  }
38
- catch (e) {
39
- log.error(`Failed to initialized adapter`);
40
- throw e;
41
- }
42
- log.info("Adapter instance created successfully!");
61
+ log.info("persistence layer created successfully!");
43
62
  }
44
- return this._adapterInstance;
45
- }
46
- static getAdapterInstance() {
47
- return this._adapterInstance;
63
+ return this.persistence.client;
64
+ //
65
+ // if (!this._adapterInstance) {
66
+ // log.info("Creating adapter instance...");
67
+ // this._adapterInstance = new options.adapter(options.conf, options.alias);
68
+ // try {
69
+ // await this._adapterInstance.initialize();
70
+ // } catch (e: unknown) {
71
+ // log.error(`Failed to initialized adapter`);
72
+ // throw e;
73
+ // }
74
+ // log.info("Adapter instance created successfully!");
75
+ // }
76
+ // return this.persistence;
48
77
  }
49
78
  static forRoot(options) {
50
79
  const typeOrmModuleOptions = {
@@ -53,7 +82,7 @@ let DecafCoreModule = class DecafCoreModule {
53
82
  };
54
83
  const adapter = {
55
84
  useFactory: async (opts) => {
56
- return DecafCoreModule_1.createAdapter(opts);
85
+ return DecafCoreModule_1.bootPersistence(opts);
57
86
  },
58
87
  provide: DECAF_ADAPTER_ID,
59
88
  durable: true,
@@ -70,17 +99,17 @@ let DecafCoreModule = class DecafCoreModule {
70
99
  }
71
100
  async onApplicationShutdown() {
72
101
  const log = DecafCoreModule_1.log.for(this.onApplicationShutdown);
73
- const adapter = this.moduleRef.get(DECAF_ADAPTER_ID);
74
- try {
75
- if (adapter) {
76
- log.info("Shutting down");
77
- await adapter.shutdown();
78
- DecafCoreModule_1._adapterInstance = null;
102
+ const adapters = this.moduleRef.get(DECAF_ADAPTER_ID);
103
+ for (const adapter of adapters)
104
+ try {
105
+ if (adapter) {
106
+ log.info(`Shutting down ${adapter.toString()}`);
107
+ await adapter.shutdown();
108
+ }
109
+ }
110
+ catch (e) {
111
+ log.error(`Failed to shutdown application`, e);
79
112
  }
80
- }
81
- catch (e) {
82
- log.error(`Failed to shutdown application`, e);
83
- }
84
113
  }
85
114
  };
86
115
  DecafCoreModule = DecafCoreModule_1 = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"core-module.js","sourceRoot":"","sources":["../../src/core-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAEL,MAAM,EACN,MAAM,EACN,MAAM,EAEN,KAAK,GACN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,uBAAoB;AAGrE,OAAO,EAAU,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI7C,IAAM,eAAe,GAArB,MAAM,eAAe;;aAIX,qBAAgB,GAAuC,IAAI,AAA3C,CAA4C;IAEjE,MAAM,KAAK,GAAG;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAe,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAEmB,OAA0C,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3B"}
@@ -1,7 +1,9 @@
1
- import { DynamicModule } from "@nestjs/common";
1
+ import { DynamicModule, Provider } from "@nestjs/common";
2
2
  import { DecafModuleOptions } from "../types";
3
- export declare class DecafModelModule {
4
- private static readonly log;
5
- private static createModelServices;
6
- static forRoot(flavour: string, options?: Partial<DecafModuleOptions>): DynamicModule;
7
- }
3
+ import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
4
+ export declare function getModuleFor(flavour: string): {
5
+ new (): {};
6
+ readonly log: import("@decaf-ts/logging").Logger;
7
+ createModelServices<T extends Model<boolean>>(models: ModelConstructor<T>[]): Provider[];
8
+ forRoot(flavour: string, options?: Partial<DecafModuleOptions>): DynamicModule;
9
+ };
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- var DecafModelModule_1;
8
7
  import { Module } from "@nestjs/common";
9
8
  import { Adapter, ModelService } from "@decaf-ts/core";
10
9
  import { Logging } from "@decaf-ts/logging";
@@ -13,53 +12,59 @@ import { DecafRequestHandlerInterceptor } from "./../interceptors/index.js";
13
12
  import { APP_INTERCEPTOR } from "@nestjs/core";
14
13
  import { DecafHandlerExecutor, DecafRequestContext } from "./../request/index.js";
15
14
  import { DECAF_HANDLERS } from "./../constants.js";
16
- let DecafModelModule = class DecafModelModule {
17
- static { DecafModelModule_1 = this; }
18
- static { this.log = Logging.for(DecafModelModule_1.name); }
19
- static createModelServices(models) {
20
- return models.map((model) => ({
21
- provide: `${model.name}Service`,
22
- useFactory: () => ModelService.forModel(model),
23
- }));
24
- }
25
- static forRoot(flavour, options = {}) {
26
- const log = this.log.for(this.forRoot);
27
- log.info(`Generating controllers for flavour...`);
28
- const trackedModels = Adapter.models(flavour);
29
- let modelServices = [];
30
- if (options.autoServices) {
31
- log.info("Auto-services enabled. Initializing service generation.");
32
- modelServices = this.createModelServices(trackedModels);
33
- log.info(`Auto-services completed. ${modelServices.length} services initialized.`);
15
+ export function getModuleFor(flavour) {
16
+ var DecafModelModule_1;
17
+ let DecafModelModule = class DecafModelModule {
18
+ static { DecafModelModule_1 = this; }
19
+ static { this.log = Logging.for(DecafModelModule_1.name).for(flavour); }
20
+ static createModelServices(models) {
21
+ return models.map((model) => ({
22
+ provide: `${model.name}Service`,
23
+ useFactory: () => ModelService.forModel(model),
24
+ }));
34
25
  }
35
- const controllers = trackedModels.map(FromModelController.create);
36
- log.info(`Generated ${controllers.length} controllers`);
37
- return {
38
- module: DecafModelModule_1,
39
- controllers,
40
- providers: [
41
- {
42
- provide: DECAF_HANDLERS,
43
- useFactory: () => {
44
- return (options.handlers?.map((H) => {
45
- log.info(`Registered request handler: ${H.name}`);
46
- return new H();
47
- }) ?? []);
26
+ static forRoot(flavour, options = {}) {
27
+ const log = this.log.for(this.forRoot);
28
+ log.info(`Generating controllers for flavour...`);
29
+ const trackedModels = Adapter.models(flavour);
30
+ let modelServices = [];
31
+ if (options.autoServices) {
32
+ log.info("Auto-services enabled. Initializing service generation.");
33
+ modelServices = this.createModelServices(trackedModels);
34
+ log.info(`Auto-services completed. ${modelServices.length} services initialized.`);
35
+ }
36
+ const controllers = trackedModels.map(FromModelController.create);
37
+ log.info(`Generated ${controllers.length} controllers`);
38
+ return {
39
+ module: DecafModelModule_1,
40
+ controllers,
41
+ providers: [
42
+ {
43
+ provide: DECAF_HANDLERS,
44
+ useFactory: () => {
45
+ return (options.handlers?.map((H) => {
46
+ log.info(`Registered request handler: ${H.name}`);
47
+ return new H();
48
+ }) ?? []);
49
+ },
48
50
  },
49
- },
50
- DecafRequestContext,
51
- DecafHandlerExecutor,
52
- {
53
- provide: APP_INTERCEPTOR,
54
- useClass: DecafRequestHandlerInterceptor,
55
- },
56
- ...modelServices,
57
- ],
58
- };
59
- }
60
- };
61
- DecafModelModule = DecafModelModule_1 = __decorate([
62
- Module({})
63
- ], DecafModelModule);
64
- export { DecafModelModule };
51
+ DecafRequestContext,
52
+ DecafHandlerExecutor,
53
+ {
54
+ provide: APP_INTERCEPTOR,
55
+ useClass: DecafRequestHandlerInterceptor,
56
+ },
57
+ ...modelServices,
58
+ ],
59
+ };
60
+ }
61
+ };
62
+ DecafModelModule = DecafModelModule_1 = __decorate([
63
+ Module({})
64
+ ], DecafModelModule);
65
+ Object.assign(DecafModelModule, "name", {
66
+ value: `DecafModule${flavour}`,
67
+ });
68
+ return DecafModelModule;
69
+ }
65
70
  //# sourceMappingURL=DecafModelModule.js.map