@midwayjs/core 3.5.4-beta.2 → 3.6.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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/dist/baseFramework.d.ts +7 -2
  3. package/dist/baseFramework.js +27 -9
  4. package/dist/common/applicationManager.d.ts +1 -1
  5. package/dist/common/applicationManager.js +1 -1
  6. package/dist/common/dataListener.js +1 -1
  7. package/dist/common/dataSourceManager.js +7 -7
  8. package/dist/common/fileDetector.js +6 -5
  9. package/dist/common/filterManager.js +1 -1
  10. package/dist/common/guardManager.d.ts +6 -0
  11. package/dist/common/guardManager.js +49 -0
  12. package/dist/common/middlewareManager.d.ts +2 -2
  13. package/dist/common/webGenerator.d.ts +2 -1
  14. package/dist/common/webGenerator.js +12 -3
  15. package/dist/config/config.default.d.ts +2 -11
  16. package/dist/config/config.default.js +2 -2
  17. package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
  18. package/dist/{common/constants.js → constants.js} +18 -2
  19. package/dist/context/container.d.ts +1 -1
  20. package/dist/context/container.js +16 -14
  21. package/dist/context/definitionRegistry.d.ts +1 -1
  22. package/dist/context/definitionRegistry.js +1 -1
  23. package/dist/context/managedResolverFactory.d.ts +1 -4
  24. package/dist/context/managedResolverFactory.js +6 -6
  25. package/dist/context/providerWrapper.d.ts +1 -1
  26. package/dist/context/providerWrapper.js +1 -1
  27. package/dist/context/requestContainer.js +3 -3
  28. package/dist/decorator/common/aspect.d.ts +20 -0
  29. package/dist/decorator/common/aspect.js +22 -0
  30. package/dist/decorator/common/autoload.d.ts +2 -0
  31. package/dist/decorator/common/autoload.js +13 -0
  32. package/dist/decorator/common/configuration.d.ts +24 -0
  33. package/dist/decorator/common/configuration.js +11 -0
  34. package/dist/decorator/common/filter.d.ts +6 -0
  35. package/dist/decorator/common/filter.js +31 -0
  36. package/dist/decorator/common/framework.d.ts +8 -0
  37. package/dist/decorator/common/framework.js +41 -0
  38. package/dist/decorator/common/guard.d.ts +4 -0
  39. package/dist/decorator/common/guard.js +30 -0
  40. package/dist/decorator/common/inject.d.ts +3 -0
  41. package/dist/decorator/common/inject.js +11 -0
  42. package/dist/decorator/common/middleware.d.ts +2 -0
  43. package/dist/decorator/common/middleware.js +12 -0
  44. package/dist/decorator/common/objectDef.d.ts +7 -0
  45. package/dist/decorator/common/objectDef.js +25 -0
  46. package/dist/decorator/common/pipeline.d.ts +3 -0
  47. package/dist/decorator/common/pipeline.js +12 -0
  48. package/dist/decorator/common/provide.d.ts +3 -0
  49. package/dist/decorator/common/provide.js +11 -0
  50. package/dist/decorator/constant.d.ts +55 -0
  51. package/dist/decorator/constant.js +86 -0
  52. package/dist/decorator/decoratorManager.d.ts +301 -0
  53. package/dist/decorator/decoratorManager.js +709 -0
  54. package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
  55. package/dist/decorator/faas/serverlessTrigger.js +29 -0
  56. package/dist/decorator/index.d.ts +31 -0
  57. package/dist/decorator/index.js +55 -0
  58. package/dist/decorator/interface.d.ts +238 -0
  59. package/dist/decorator/interface.js +67 -0
  60. package/dist/decorator/microservice/consumer.d.ts +5 -0
  61. package/dist/decorator/microservice/consumer.js +17 -0
  62. package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
  63. package/dist/decorator/microservice/kafkaListener.js +13 -0
  64. package/dist/decorator/microservice/provider.d.ts +16 -0
  65. package/dist/decorator/microservice/provider.js +47 -0
  66. package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
  67. package/dist/decorator/microservice/rabbitmqListener.js +13 -0
  68. package/dist/decorator/rpc/hsf.d.ts +12 -0
  69. package/dist/decorator/rpc/hsf.js +18 -0
  70. package/dist/decorator/task/queue.d.ts +2 -0
  71. package/dist/decorator/task/queue.js +17 -0
  72. package/dist/decorator/task/schedule.d.ts +21 -0
  73. package/dist/decorator/task/schedule.js +14 -0
  74. package/dist/decorator/task/task.d.ts +2 -0
  75. package/dist/decorator/task/task.js +18 -0
  76. package/dist/decorator/task/taskLocal.d.ts +2 -0
  77. package/dist/decorator/task/taskLocal.js +17 -0
  78. package/dist/decorator/web/controller.d.ts +20 -0
  79. package/dist/decorator/web/controller.js +18 -0
  80. package/dist/decorator/web/paramMapping.d.ts +31 -0
  81. package/dist/decorator/web/paramMapping.js +50 -0
  82. package/dist/decorator/web/requestMapping.d.ts +132 -0
  83. package/dist/decorator/web/requestMapping.js +83 -0
  84. package/dist/decorator/web/response.d.ts +9 -0
  85. package/dist/decorator/web/response.js +65 -0
  86. package/dist/decorator/ws/webSocketController.d.ts +10 -0
  87. package/dist/decorator/ws/webSocketController.js +20 -0
  88. package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
  89. package/dist/decorator/ws/webSocketEvent.js +87 -0
  90. package/dist/definitions/functionDefinition.d.ts +1 -1
  91. package/dist/definitions/functionDefinition.js +1 -1
  92. package/dist/definitions/objectCreator.d.ts +1 -1
  93. package/dist/definitions/objectCreator.js +7 -7
  94. package/dist/definitions/objectDefinition.d.ts +1 -1
  95. package/dist/definitions/objectDefinition.js +1 -1
  96. package/dist/definitions/properties.d.ts +1 -1
  97. package/dist/error/framework.d.ts +5 -1
  98. package/dist/error/framework.js +9 -2
  99. package/dist/functional/configuration.d.ts +1 -1
  100. package/dist/index.d.ts +18 -15
  101. package/dist/index.js +40 -27
  102. package/dist/interface.d.ts +52 -18
  103. package/dist/interface.js +1 -17
  104. package/dist/service/aspectService.d.ts +1 -1
  105. package/dist/service/aspectService.js +3 -2
  106. package/dist/service/configService.js +3 -2
  107. package/dist/service/decoratorService.js +1 -1
  108. package/dist/service/environmentService.js +1 -1
  109. package/dist/service/frameworkService.d.ts +1 -1
  110. package/dist/service/frameworkService.js +3 -3
  111. package/dist/service/informationService.js +1 -1
  112. package/dist/service/lifeCycleService.js +1 -1
  113. package/dist/service/loggerService.js +1 -1
  114. package/dist/service/middlewareService.js +3 -2
  115. package/dist/service/mockService.js +1 -1
  116. package/dist/service/pipelineService.d.ts +1 -1
  117. package/dist/service/pipelineService.js +1 -1
  118. package/dist/service/slsFunctionService.d.ts +1 -1
  119. package/dist/service/slsFunctionService.js +1 -1
  120. package/dist/service/webRouterService.d.ts +9 -1
  121. package/dist/service/webRouterService.js +6 -3
  122. package/dist/setup.d.ts +3 -3
  123. package/dist/setup.js +1 -1
  124. package/dist/util/camelCase.d.ts +3 -0
  125. package/dist/util/camelCase.js +88 -0
  126. package/dist/util/contextUtil.js +2 -2
  127. package/dist/util/extend.js +3 -3
  128. package/dist/util/flatted.d.ts +7 -0
  129. package/dist/util/flatted.js +91 -0
  130. package/dist/util/format.d.ts +25 -0
  131. package/dist/util/format.js +38 -0
  132. package/dist/util/fs.d.ts +5 -0
  133. package/dist/util/fs.js +15 -0
  134. package/dist/util/httpclient.d.ts +1 -0
  135. package/dist/util/index.d.ts +26 -0
  136. package/dist/util/index.js +80 -1
  137. package/dist/util/pathFileUtil.d.ts +6 -3
  138. package/dist/util/pathFileUtil.js +28 -22
  139. package/dist/util/retry.js +2 -2
  140. package/dist/util/types.d.ts +35 -0
  141. package/dist/util/types.js +121 -0
  142. package/dist/util/uuid.d.ts +5 -0
  143. package/dist/util/uuid.js +64 -0
  144. package/dist/util/webRouterParam.js +1 -1
  145. package/package.json +8 -11
@@ -0,0 +1,301 @@
1
+ import 'reflect-metadata';
2
+ import { GroupModeType, IModuleStore, ObjectDefinitionOptions, ObjectIdentifier, TagPropsMetadata } from './interface';
3
+ export declare const PRELOAD_MODULE_KEY = "INJECTION_PRELOAD_MODULE_KEY";
4
+ export declare const INJECT_CLASS_KEY_PREFIX = "INJECTION_CLASS_META_DATA";
5
+ export declare class DecoratorManager extends Map implements IModuleStore {
6
+ /**
7
+ * the key for meta data store in class
8
+ */
9
+ injectClassKeyPrefix: string;
10
+ /**
11
+ * the key for method meta data store in class
12
+ */
13
+ injectClassMethodKeyPrefix: string;
14
+ /**
15
+ * the key for method meta data store in method
16
+ */
17
+ injectMethodKeyPrefix: string;
18
+ container: IModuleStore;
19
+ saveModule(key: any, module: any): any;
20
+ listModule(key: any): any;
21
+ resetModule(key: any): void;
22
+ bindContainer(container: IModuleStore): void;
23
+ static getDecoratorClassKey(decoratorNameKey: ObjectIdentifier): string;
24
+ static removeDecoratorClassKeySuffix(decoratorNameKey: ObjectIdentifier): string;
25
+ static getDecoratorMethodKey(decoratorNameKey: ObjectIdentifier): string;
26
+ static getDecoratorClsExtendedKey(decoratorNameKey: ObjectIdentifier): string;
27
+ static getDecoratorClsMethodPrefix(decoratorNameKey: ObjectIdentifier): string;
28
+ static getDecoratorClsMethodKey(decoratorNameKey: ObjectIdentifier, methodKey: ObjectIdentifier): string;
29
+ static getDecoratorMethod(decoratorNameKey: ObjectIdentifier, methodKey: ObjectIdentifier): string;
30
+ static saveMetadata(metaKey: string, target: any, dataKey: string, data: any): void;
31
+ static attachMetadata(metaKey: string, target: any, dataKey: string, data: any, groupBy?: string, groupMode?: GroupModeType): void;
32
+ static getMetadata(metaKey: string, target: any, dataKey?: string): any;
33
+ /**
34
+ * save meta data to class or property
35
+ * @param decoratorNameKey the alias name for decorator
36
+ * @param data the data you want to store
37
+ * @param target target class
38
+ * @param propertyName
39
+ */
40
+ saveMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName?: any): void;
41
+ /**
42
+ * attach data to class or property
43
+ * @param decoratorNameKey
44
+ * @param data
45
+ * @param target
46
+ * @param propertyName
47
+ * @param groupBy
48
+ */
49
+ attachMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName?: string, groupBy?: string, groupMode?: GroupModeType): void;
50
+ /**
51
+ * get single data from class or property
52
+ * @param decoratorNameKey
53
+ * @param target
54
+ * @param propertyName
55
+ */
56
+ getMetadata(decoratorNameKey: ObjectIdentifier, target: any, propertyName?: any): any;
57
+ /**
58
+ * save property data to class
59
+ * @param decoratorNameKey
60
+ * @param data
61
+ * @param target
62
+ * @param propertyName
63
+ */
64
+ savePropertyDataToClass(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any): void;
65
+ /**
66
+ * attach property data to class
67
+ * @param decoratorNameKey
68
+ * @param data
69
+ * @param target
70
+ * @param propertyName
71
+ * @param groupBy
72
+ */
73
+ attachPropertyDataToClass(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any, groupBy?: string): void;
74
+ /**
75
+ * get property data from class
76
+ * @param decoratorNameKey
77
+ * @param target
78
+ * @param propertyName
79
+ */
80
+ getPropertyDataFromClass(decoratorNameKey: ObjectIdentifier, target: any, propertyName: any): any;
81
+ /**
82
+ * list property data from class
83
+ * @param decoratorNameKey
84
+ * @param target
85
+ */
86
+ listPropertyDataFromClass(decoratorNameKey: ObjectIdentifier, target: any): any[];
87
+ }
88
+ /**
89
+ * save data to class
90
+ * @param decoratorNameKey
91
+ * @param data
92
+ * @param target
93
+ * @param mergeIfExist
94
+ */
95
+ export declare function saveClassMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, mergeIfExist?: boolean): void;
96
+ /**
97
+ * attach data to class
98
+ * @param decoratorNameKey
99
+ * @param data
100
+ * @param target
101
+ * @param groupBy
102
+ */
103
+ export declare function attachClassMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, groupBy?: string, groupMode?: GroupModeType): void;
104
+ /**
105
+ * get data from class and proto
106
+ * @param decoratorNameKey
107
+ * @param target
108
+ * @param propertyName
109
+ * @param useCache
110
+ */
111
+ export declare function getClassExtendedMetadata<T = any>(decoratorNameKey: ObjectIdentifier, target: any, propertyName?: string, useCache?: boolean): T;
112
+ /**
113
+ * get data from class
114
+ * @param decoratorNameKey
115
+ * @param target
116
+ */
117
+ export declare function getClassMetadata<T = any>(decoratorNameKey: ObjectIdentifier, target: any): T;
118
+ /**
119
+ * save property data to class
120
+ * @param decoratorNameKey
121
+ * @param data
122
+ * @param target
123
+ * @param propertyName
124
+ */
125
+ export declare function savePropertyDataToClass(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any): void;
126
+ /**
127
+ * attach property data to class
128
+ * @param decoratorNameKey
129
+ * @param data
130
+ * @param target
131
+ * @param propertyName
132
+ * @param groupBy
133
+ */
134
+ export declare function attachPropertyDataToClass(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any, groupBy?: string): void;
135
+ /**
136
+ * get property data from class
137
+ * @param decoratorNameKey
138
+ * @param target
139
+ * @param propertyName
140
+ */
141
+ export declare function getPropertyDataFromClass<T = any>(decoratorNameKey: ObjectIdentifier, target: any, propertyName: any): T;
142
+ /**
143
+ * list property data from class
144
+ * @param decoratorNameKey
145
+ * @param target
146
+ */
147
+ export declare function listPropertyDataFromClass(decoratorNameKey: ObjectIdentifier, target: any): any[];
148
+ /**
149
+ * save property data
150
+ * @param decoratorNameKey
151
+ * @param data
152
+ * @param target
153
+ * @param propertyName
154
+ */
155
+ export declare function savePropertyMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any): void;
156
+ /**
157
+ * attach property data
158
+ * @param decoratorNameKey
159
+ * @param data
160
+ * @param target
161
+ * @param propertyName
162
+ */
163
+ export declare function attachPropertyMetadata(decoratorNameKey: ObjectIdentifier, data: any, target: any, propertyName: any): void;
164
+ /**
165
+ * get property data
166
+ * @param decoratorNameKey
167
+ * @param target
168
+ * @param propertyName
169
+ */
170
+ export declare function getPropertyMetadata<T = any>(decoratorNameKey: ObjectIdentifier, target: any, propertyName: any): T;
171
+ /**
172
+ * save preload module by target
173
+ * @param target
174
+ */
175
+ export declare function savePreloadModule(target: any): any;
176
+ /**
177
+ * list preload module
178
+ */
179
+ export declare function listPreloadModule(): any[];
180
+ /**
181
+ * save module to inner map
182
+ * @param decoratorNameKey
183
+ * @param target
184
+ */
185
+ export declare function saveModule(decoratorNameKey: ObjectIdentifier, target: any): any;
186
+ export declare function bindContainer(container: any): void;
187
+ export declare function clearBindContainer(): any;
188
+ /**
189
+ * list module from decorator key
190
+ * @param decoratorNameKey
191
+ * @param filter
192
+ */
193
+ export declare function listModule(decoratorNameKey: ObjectIdentifier, filter?: (module: any) => boolean): any[];
194
+ /**
195
+ * reset module
196
+ * @param decoratorNameKey
197
+ */
198
+ export declare function resetModule(decoratorNameKey: ObjectIdentifier): void;
199
+ /**
200
+ * clear all module
201
+ */
202
+ export declare function clearAllModule(): void;
203
+ export interface TSDesignType {
204
+ name: string;
205
+ originDesign: any;
206
+ isBaseType: boolean;
207
+ }
208
+ /**
209
+ * save property inject args
210
+ * @param opts 参数
211
+ */
212
+ export declare function savePropertyInject(opts: {
213
+ identifier: ObjectIdentifier;
214
+ target: any;
215
+ targetKey: string;
216
+ args?: any;
217
+ }): void;
218
+ /**
219
+ * get property inject args
220
+ * @param target
221
+ * @param useCache
222
+ */
223
+ export declare function getPropertyInject(target: any, useCache?: boolean): {
224
+ [methodName: string]: TagPropsMetadata;
225
+ };
226
+ /**
227
+ * save class object definition
228
+ * @param target class
229
+ * @param props property data
230
+ */
231
+ export declare function saveObjectDefinition(target: any, props?: {}): any;
232
+ /**
233
+ * get class object definition from metadata
234
+ * @param target
235
+ */
236
+ export declare function getObjectDefinition(target: any): ObjectDefinitionOptions;
237
+ /**
238
+ * class provider id
239
+ * @param identifier id
240
+ * @param target class
241
+ */
242
+ export declare function saveProviderId(identifier: ObjectIdentifier, target: any): any;
243
+ /**
244
+ * get provider id from module
245
+ * @param module
246
+ */
247
+ export declare function getProviderId(module: any): string;
248
+ export declare function getProviderName(module: any): string;
249
+ /**
250
+ * get provider uuid from module
251
+ * @param module
252
+ */
253
+ export declare function getProviderUUId(module: any): string;
254
+ /**
255
+ * use @Provide decorator or not
256
+ * @param target class
257
+ */
258
+ export declare function isProvide(target: any): boolean;
259
+ export declare enum BaseType {
260
+ Boolean = "boolean",
261
+ Number = "number",
262
+ String = "string"
263
+ }
264
+ /**
265
+ * get parameters type by reflect-metadata
266
+ */
267
+ export declare function getMethodParamTypes(target: any, methodName: string | symbol): any;
268
+ /**
269
+ * get property(method) type from metadata
270
+ * @param target
271
+ * @param methodName
272
+ */
273
+ export declare function getPropertyType(target: any, methodName: string | symbol): TSDesignType;
274
+ /**
275
+ * get method return type from metadata
276
+ * @param target
277
+ * @param methodName
278
+ */
279
+ export declare function getMethodReturnTypes(target: any, methodName: string | symbol): any;
280
+ /**
281
+ * create a custom property inject
282
+ * @param decoratorKey
283
+ * @param metadata
284
+ * @param impl default true, configuration need decoratorService.registerMethodHandler
285
+ */
286
+ export declare function createCustomPropertyDecorator(decoratorKey: string, metadata: any, impl?: boolean): PropertyDecorator;
287
+ /**
288
+ *
289
+ * @param decoratorKey
290
+ * @param metadata
291
+ * @param impl default true, configuration need decoratorService.registerMethodHandler
292
+ */
293
+ export declare function createCustomMethodDecorator(decoratorKey: string, metadata: any, impl?: boolean): MethodDecorator;
294
+ /**
295
+ *
296
+ * @param decoratorKey
297
+ * @param metadata
298
+ * @param impl default true, configuration need decoratorService.registerMethodHandler
299
+ */
300
+ export declare function createCustomParamDecorator(decoratorKey: string, metadata: any, impl?: boolean): ParameterDecorator;
301
+ //# sourceMappingURL=decoratorManager.d.ts.map