lakutata 2.0.54 → 2.0.56

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 (118) hide show
  1. package/com/cacher.cjs +1 -1
  2. package/com/cacher.d.ts +1 -1
  3. package/com/cacher.mjs +1 -1
  4. package/com/docker.d.ts +1 -1
  5. package/com/entrypoint.cjs +29 -11
  6. package/com/entrypoint.d.ts +11 -182
  7. package/com/entrypoint.mjs +12 -0
  8. package/decorator/asst.d.ts +1 -1
  9. package/decorator/ctrl.cjs +15 -5
  10. package/decorator/ctrl.d.ts +112 -10
  11. package/decorator/ctrl.mjs +11 -1
  12. package/decorator/di.d.ts +2 -2
  13. package/decorator/dto.d.ts +3 -3
  14. package/decorator/orm.d.ts +1 -1
  15. package/helper.cjs +13 -11
  16. package/helper.d.ts +1 -1
  17. package/helper.mjs +3 -1
  18. package/lakutata.cjs +18 -6
  19. package/lakutata.d.ts +7 -8
  20. package/lakutata.mjs +12 -0
  21. package/orm.d.ts +1 -1
  22. package/package.json +1 -1
  23. package/src/components/cacher/Cacher.cjs +1 -1
  24. package/src/components/cacher/Cacher.mjs +1 -1
  25. package/src/components/cacher/adapters/CreateFileCacheAdapter.cjs +1 -1
  26. package/src/components/cacher/adapters/CreateFileCacheAdapter.mjs +1 -1
  27. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.cjs +2 -2
  28. package/src/components/cacher/adapters/CreateMemcacheCacheAdapter.mjs +2 -2
  29. package/src/components/cacher/adapters/CreateMongoCacheAdapter.cjs +2 -2
  30. package/src/components/cacher/adapters/CreateMongoCacheAdapter.mjs +2 -2
  31. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.cjs +2 -2
  32. package/src/components/cacher/adapters/CreateMysqlCacheAdapter.mjs +2 -2
  33. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.cjs +2 -2
  34. package/src/components/cacher/adapters/CreatePostgresCacheAdapter.mjs +2 -2
  35. package/src/components/cacher/adapters/CreateRedisCacheAdapter.cjs +2 -2
  36. package/src/components/cacher/adapters/CreateRedisCacheAdapter.mjs +2 -2
  37. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.cjs +2 -2
  38. package/src/components/cacher/adapters/CreateSqliteCacheAdapter.mjs +2 -2
  39. package/src/components/entrypoint/Entrypoint.cjs +1074 -973
  40. package/src/components/entrypoint/Entrypoint.mjs +884 -781
  41. package/src/components/entrypoint/exceptions/AccessDenyException.cjs +35 -0
  42. package/src/components/entrypoint/exceptions/AccessDenyException.mjs +29 -0
  43. package/src/components/entrypoint/exceptions/DuplicateActionNameException.cjs +34 -0
  44. package/src/components/entrypoint/exceptions/DuplicateActionNameException.mjs +28 -0
  45. package/src/components/entrypoint/lib/AccessControl.cjs +247 -0
  46. package/src/components/entrypoint/lib/AccessControl.mjs +241 -0
  47. package/src/components/entrypoint/lib/AccessControlRule.cjs +163 -0
  48. package/src/components/entrypoint/lib/AccessControlRule.mjs +157 -0
  49. package/src/decorators/ctrl/CLIAction.cjs +17 -10
  50. package/src/decorators/ctrl/CLIAction.mjs +17 -10
  51. package/src/decorators/ctrl/HTTPAction.cjs +18 -11
  52. package/src/decorators/ctrl/HTTPAction.mjs +16 -9
  53. package/src/decorators/ctrl/ServiceAction.cjs +15 -8
  54. package/src/decorators/ctrl/ServiceAction.mjs +16 -9
  55. package/src/decorators/ctrl/http/DELETE.cjs +13 -3
  56. package/src/decorators/ctrl/http/DELETE.mjs +13 -3
  57. package/src/decorators/ctrl/http/GET.cjs +13 -3
  58. package/src/decorators/ctrl/http/GET.mjs +13 -3
  59. package/src/decorators/ctrl/http/HEAD.cjs +13 -3
  60. package/src/decorators/ctrl/http/HEAD.mjs +13 -3
  61. package/src/decorators/ctrl/http/OPTIONS.cjs +13 -3
  62. package/src/decorators/ctrl/http/OPTIONS.mjs +13 -3
  63. package/src/decorators/ctrl/http/PATCH.cjs +13 -3
  64. package/src/decorators/ctrl/http/PATCH.mjs +13 -3
  65. package/src/decorators/ctrl/http/POST.cjs +13 -3
  66. package/src/decorators/ctrl/http/POST.mjs +13 -3
  67. package/src/decorators/ctrl/http/PUT.cjs +13 -3
  68. package/src/decorators/ctrl/http/PUT.mjs +13 -3
  69. package/src/lib/base/internal/ActionOptions.cjs +79 -0
  70. package/src/lib/base/internal/ActionOptions.mjs +73 -0
  71. package/src/lib/base/internal/ControllerEntrypoint.cjs +625 -53
  72. package/src/lib/base/internal/ControllerEntrypoint.mjs +640 -68
  73. package/src/lib/base/internal/GetActionDTOAndOptions.cjs +89 -0
  74. package/src/lib/base/internal/GetActionDTOAndOptions.mjs +83 -0
  75. package/src/lib/base/internal/StringifyPattern.cjs +69 -0
  76. package/src/lib/base/internal/StringifyPattern.mjs +63 -0
  77. package/src/lib/core/Application.cjs +29 -17
  78. package/src/lib/core/Application.mjs +33 -21
  79. package/src/lib/helpers/MD5.cjs +1 -1
  80. package/src/lib/helpers/MD5.mjs +1 -1
  81. package/src/lib/helpers/SHA1.cjs +1 -1
  82. package/src/lib/helpers/SHA1.mjs +1 -1
  83. package/src/lib/helpers/SHA256.cjs +1 -1
  84. package/src/lib/helpers/SHA256.mjs +1 -1
  85. package/src/lib/helpers/SortArray.cjs +18 -201
  86. package/src/lib/helpers/SortArray.mjs +17 -200
  87. package/vendor/Package.19.cjs +85 -90
  88. package/vendor/Package.19.mjs +1 -1
  89. package/vendor/Package.3.cjs +1 -1
  90. package/vendor/Package.3.mjs +1 -1
  91. package/vendor/Package.610.cjs +85 -103
  92. package/vendor/Package.610.mjs +80 -98
  93. package/vendor/Package.611.cjs +100 -121
  94. package/vendor/Package.611.mjs +97 -120
  95. package/vendor/Package.612.cjs +196 -0
  96. package/vendor/Package.612.mjs +180 -0
  97. package/vendor/Package.64.cjs +140 -4118
  98. package/vendor/Package.64.mjs +140 -4126
  99. package/vendor/Package.65.cjs +4142 -692
  100. package/vendor/Package.65.mjs +4151 -689
  101. package/vendor/Package.66.cjs +571 -535
  102. package/vendor/Package.66.mjs +586 -528
  103. package/vendor/Package.67.cjs +633 -96
  104. package/vendor/Package.67.mjs +619 -94
  105. package/vendor/Package.68.cjs +96 -294
  106. package/vendor/Package.68.mjs +95 -295
  107. package/vendor/Package.69.cjs +297 -113
  108. package/vendor/Package.69.mjs +285 -97
  109. package/vendor/TypeDef.10.d.ts +13 -2
  110. package/vendor/TypeDef.11.d.ts +6 -5
  111. package/vendor/TypeDef.12.d.ts +104 -4
  112. package/vendor/TypeDef.13.d.ts +315 -62
  113. package/vendor/TypeDef.3.d.ts +2 -2
  114. package/vendor/TypeDef.5.d.ts +1 -1
  115. package/vendor/TypeDef.7.d.ts +19 -10
  116. package/vendor/TypeDef.8.d.ts +2 -20
  117. package/vendor/TypeDef.9.d.ts +5 -2
  118. package/vendor/TypeDef.14.d.ts +0 -72
@@ -1,107 +1,360 @@
1
- import { k as OrderByCondition } from './TypeDef.4.js';
1
+ import { P as Provider, B as BaseObject, I as IBaseObjectConstructor, a as Container, M as Module, C as Component } from './TypeDef.3.js';
2
+ import { D as DTO, J as JSONSchema, F as FunctionSchema } from './TypeDef.5.js';
3
+ import { A as ActionPattern, I as IPatRun } from './TypeDef.10.js';
4
+ import { IncomingMessage, ServerResponse } from 'node:http';
5
+ import { E as Exception } from './TypeDef.7.js';
2
6
 
3
7
  /**
4
- * Describes all index options.
8
+ * Context types
5
9
  */
6
- interface IndexOptions {
10
+ declare enum ContextType {
11
+ CLI = "CLI",
12
+ HTTP = "HTTP",
13
+ SERVICE = "SERVICE"
14
+ }
15
+ type ContextParams<T extends {} = {}> = T & Record<string, any>;
16
+ /**
17
+ * Base context class
18
+ */
19
+ declare class BaseContext<T extends Record<string, any> = {}> extends DTO {
20
+ readonly type: ContextType;
21
+ data: ActionPattern<T>;
22
+ constructor(params: ContextParams);
23
+ }
24
+
25
+ declare class CLIContext<T extends Record<string, any> = {}> extends BaseContext<T> {
26
+ readonly type: ContextType;
27
+ command: string;
28
+ constructor(params: ContextParams<{
29
+ readonly command: string;
30
+ readonly data: Record<string, any>;
31
+ }>);
32
+ }
33
+
34
+ declare class HTTPContext<T extends Record<string, any> = {}> extends BaseContext<T> {
35
+ readonly type: ContextType;
36
+ readonly route: string;
37
+ readonly method: string;
38
+ readonly request: IncomingMessage;
39
+ readonly response: ServerResponse;
40
+ constructor(params: ContextParams<{
41
+ readonly route: string;
42
+ readonly method: string;
43
+ readonly request: IncomingMessage;
44
+ readonly response: ServerResponse;
45
+ readonly data: Record<string, any>;
46
+ }>);
47
+ }
48
+
49
+ declare class ServiceContext<T extends Record<string, any> = {}> extends BaseContext<T> {
50
+ readonly type: ContextType;
51
+ input: ActionPattern<T>;
52
+ constructor(params: ContextParams<{
53
+ readonly data: ActionPattern;
54
+ }>);
55
+ }
56
+
57
+ /**
58
+ * For action decorator
59
+ */
60
+ type ControllerProperty<ClassPrototype extends Controller> = Exclude<keyof ClassPrototype, keyof Controller>;
61
+ /**
62
+ * Controller base class
63
+ */
64
+ declare class Controller extends Provider {
7
65
  /**
8
- * Indicates if this composite index must be unique or not.
66
+ * Context, possible be cli context, http context or service context
67
+ * @protected
9
68
  */
10
- unique?: boolean;
69
+ protected readonly context: CLIContext | HTTPContext | ServiceContext;
70
+ }
71
+
72
+ type AccessControlRuleHandler<T extends BaseContext<Record<string, any>>> = (context: T, input?: ActionPattern<any>) => Promise<boolean>;
73
+ declare abstract class AccessControlRule<T extends BaseContext<Record<string, any>> = BaseContext<Record<string, any>>> extends BaseObject {
74
+ protected readonly context: T;
75
+ protected readonly input: ActionPattern<any>;
76
+ protected readonly actions: HTTPActionInfo[] | ServiceActionInfo[] | CLIActionInfo[];
77
+ protected readonly targetAction: HTTPActionInfo | ServiceActionInfo | CLIActionInfo;
78
+ abstract get supportContextTypes(): ContextType[];
11
79
  /**
12
- * The SPATIAL modifier indexes the entire column and does not allow indexed columns to contain NULL values.
13
- * Works only in MySQL and PostgreSQL.
80
+ * Rule handler
14
81
  */
15
- spatial?: boolean;
82
+ abstract rule(): Promise<boolean>;
83
+ }
84
+
85
+ type ActionPatternMap = Map<ActionPattern, ActionDetails>;
86
+ type ActionDetails<ClassPrototype extends Controller = Controller, DTOConstructor extends typeof DTO = typeof DTO> = {
87
+ pattern: ActionPattern;
88
+ constructor: IBaseObjectConstructor<ClassPrototype>;
89
+ method: string | number | symbol;
90
+ dtoConstructor: DTOConstructor;
91
+ jsonSchema: JSONSchema;
92
+ getActionInfo: () => ActionInfo;
93
+ } & ActionInfo;
94
+ type ActionInfo = {
95
+ id: string;
96
+ acl: boolean;
97
+ action: string;
98
+ name: string;
99
+ description: string;
100
+ groups: string[];
101
+ rule?: AccessControlRuleHandler<any>;
102
+ };
103
+
104
+ type PatternManagerOptions = {
105
+ globMatch?: boolean;
106
+ };
107
+ declare class PatternManager implements IPatRun {
108
+ #private;
109
+ constructor(options?: PatternManagerOptions);
16
110
  /**
17
- * The FULLTEXT modifier indexes the entire column and does not allow prefixing.
18
- * Works only in MySQL.
111
+ * Register a pattern, and the object that will be returned if an input matches.
112
+ * Both keys and values are considered to be strings.
113
+ * Other types are converted to strings.
114
+ * @param pattern
115
+ * @param obj
19
116
  */
20
- fulltext?: boolean;
117
+ add(pattern: Record<string, any>, obj: any): this;
21
118
  /**
22
- * NULL_FILTERED indexes are particularly useful for indexing sparse columns, where most rows contain a NULL value.
23
- * In these cases, the NULL_FILTERED index can be considerably smaller and more efficient to maintain than
24
- * a normal index that includes NULL values.
25
- *
26
- * Works only in Spanner.
119
+ * Remove this pattern, and it's object, from the matcher.
120
+ * @param pattern
27
121
  */
28
- nullFiltered?: boolean;
122
+ remove(pattern: Record<string, any>): this;
29
123
  /**
30
- * Fulltext parser.
31
- * Works only in MySQL.
124
+ * Return the unique match for this subject, or null if not found.
125
+ * The properties of the subject are matched against the patterns previously added, and the most specifc pattern wins.
126
+ * Unknown properties in the subject are ignored.
127
+ * You can optionally provide a second boolean parameter, exact. If true, then all properties of the subject must match.
128
+ *
129
+ * If the optional third boolean parameter collect is true, then find returns an array of all sub matches
130
+ * (i.e. run find on each element of the power set of the subject pattern elements, and collate in breadth first order).
131
+ * Thus, {a:1,b:2} will generate {a:1},{b:2},{a:1,b:2} searches.
132
+ * If exact is true, only increasing sub patterns in lexicographical order are chosen.
133
+ * Thus, {a:1,b:2} will generate {a:1},{a:1,b:2}, omitting {b:2}. (You probably want to set exact to false!).
134
+ * @param subject
135
+ * @param exact
32
136
  */
33
- parser?: string;
137
+ find(subject: Record<string, any>, exact?: boolean): any;
34
138
  /**
35
- * Index filter condition.
139
+ * Return the list of registered patterns that contain this partial pattern.
140
+ * You can use wildcards for property values.
141
+ * Omitted values are not equivalent to a wildcard of "*", you must specify each property explicitly.
142
+ * @param partialPattern
36
143
  */
37
- where?: string;
144
+ list(partialPattern?: Record<string, any> | undefined): {
145
+ match: Record<string, any>;
146
+ data: any;
147
+ }[];
38
148
  /**
39
- * If true, the index only references documents with the specified field.
40
- * These indexes use less space but behave differently in some situations (particularly sorts).
41
- * This option is only supported for mongodb database.
149
+ * Generate a string representation of the decision tree for debugging.
42
150
  */
43
- sparse?: boolean;
151
+ toJSON(): string;
152
+ }
153
+
154
+ declare class AccessControl extends BaseObject {
155
+ protected readonly runtimeContainer: Container;
156
+ protected readonly actions: HTTPActionInfo[] | ServiceActionInfo[] | CLIActionInfo[];
157
+ protected readonly target: HTTPActionInfo | ServiceActionInfo | CLIActionInfo;
158
+ protected readonly context: CLIContext | HTTPContext | ServiceContext;
159
+ protected readonly input: Record<string, any>;
160
+ protected readonly allowCallback: () => void;
161
+ protected readonly denyCallback: (error?: Error | Exception) => void;
162
+ protected readonly rules: (IBaseObjectConstructor<AccessControlRule> | AccessControlRuleHandler<any>)[];
163
+ protected readonly accessControlRuleConstructorDTO: FunctionSchema<typeof AccessControlRule>;
44
164
  /**
45
- * Builds the index in the background so that building an index an does not block other database activities.
46
- * This option is only supported for mongodb database.
165
+ * Initializer
166
+ * @protected
47
167
  */
48
- background?: boolean;
168
+ protected init(): Promise<void>;
49
169
  /**
50
- * Create the index using the CONCURRENTLY modifier
51
- * Works only in postgres.
170
+ * Match rules
171
+ * @protected
52
172
  */
53
- concurrent?: boolean;
173
+ protected match(): Promise<boolean>;
54
174
  /**
55
- * Specifies a time to live, in seconds.
56
- * This option is only supported for mongodb database.
175
+ * Run access control and return result
176
+ * @param rules
177
+ * @param runtimeContainer
178
+ * @param context
179
+ * @param input
180
+ * @param details
181
+ * @param getActionsCallback
57
182
  */
58
- expireAfterSeconds?: number;
183
+ static run(rules: IBaseObjectConstructor<AccessControlRule>[], runtimeContainer: Container, context: CLIContext | HTTPContext | ServiceContext, input: Record<string, any>, details: ActionDetails, getActionsCallback: (type: ContextType) => BaseActionInfo[]): Promise<[boolean, Error | Exception]>;
59
184
  }
60
185
 
186
+ type CLIEntrypoint = (module: Module, cliMap: CLIMap, handler: CLIEntrypointHandler, registerDestroy: EntrypointDestroyerRegistrar) => void;
187
+ type HTTPEntrypoint = (module: Module, routeMap: HTTPRouteMap, handler: HTTPEntrypointHandler, registerDestroy: EntrypointDestroyerRegistrar) => void;
188
+ type ServiceEntrypoint = (module: Module, handler: ServiceEntrypointHandler, registerDestroy: EntrypointDestroyerRegistrar) => void;
189
+ type CLIMap = Map<string, JSONSchema>;
190
+ type HTTPRouteMap<HTTPMethods = string> = Map<string, Set<HTTPMethods>>;
191
+ type CLIEntrypointHandler<T = unknown> = (context: CLIContext, abortController?: AbortController) => Promise<T>;
192
+ type HTTPEntrypointHandler<T = unknown> = (context: HTTPContext, abortController?: AbortController) => Promise<T>;
193
+ type ServiceEntrypointHandler<T = unknown> = (context: ServiceContext, abortController?: AbortController) => Promise<T>;
194
+ type EntrypointDestroyer = () => void | Promise<void>;
195
+ type EntrypointDestroyerRegistrar = (destroyer: EntrypointDestroyer) => void;
196
+ type EntrypointOptions = {
197
+ rules?: IBaseObjectConstructor<AccessControlRule>[];
198
+ controllers: IBaseObjectConstructor<Controller>[];
199
+ cli?: CLIEntrypoint | CLIEntrypoint[];
200
+ http?: HTTPEntrypoint | HTTPEntrypoint[];
201
+ service?: ServiceEntrypoint | ServiceEntrypoint[];
202
+ };
203
+ interface BaseActionInfo {
204
+ readonly id: string;
205
+ readonly acl: boolean;
206
+ readonly name: string;
207
+ readonly groups: string[];
208
+ readonly controller: string;
209
+ readonly method: string;
210
+ readonly jsonSchema: JSONSchema;
211
+ }
212
+ interface HTTPActionInfo extends BaseActionInfo {
213
+ readonly route: string;
214
+ }
215
+ interface ServiceActionInfo extends BaseActionInfo {
216
+ readonly pattern: ActionPattern;
217
+ }
218
+ interface CLIActionInfo extends BaseActionInfo {
219
+ readonly command: string;
220
+ }
221
+ /**
222
+ * Build cli entrypoint
223
+ * @param entrypoint
224
+ * @constructor
225
+ */
226
+ declare const BuildCLIEntrypoint: (entrypoint: CLIEntrypoint) => CLIEntrypoint;
227
+ /**
228
+ * Build http entrypoint
229
+ * @param entrypoint
230
+ * @constructor
231
+ */
232
+ declare const BuildHTTPEntrypoint: (entrypoint: HTTPEntrypoint) => HTTPEntrypoint;
233
+ /**
234
+ * Build service entrypoint
235
+ * @param entrypoint
236
+ * @constructor
237
+ */
238
+ declare const BuildServiceEntrypoint: (entrypoint: ServiceEntrypoint) => ServiceEntrypoint;
239
+ /**
240
+ * Build entrypoints options for Entrypoint component
241
+ * @param options
242
+ * @constructor
243
+ */
244
+ declare const BuildEntrypoints: (options: EntrypointOptions) => EntrypointOptions;
61
245
  /**
62
- * Describes all entity's options.
246
+ * Entrypoint Component
63
247
  */
64
- interface EntityOptions {
248
+ declare class Entrypoint extends Component {
249
+ protected readonly CLIActionPatternMap: ActionPatternMap;
250
+ protected readonly HTTPActionPatternMap: ActionPatternMap;
251
+ protected readonly ServiceActionPatternMap: ActionPatternMap;
252
+ protected readonly CLIActionPatternManager: PatternManager;
253
+ protected readonly HTTPActionPatternManager: PatternManager;
254
+ protected readonly ServiceActionPatternManager: PatternManager;
255
+ protected readonly entrypointDestroyers: EntrypointDestroyer[];
256
+ protected readonly httpActionInfoMap: Map<string, HTTPActionInfo>;
257
+ protected readonly serviceActionInfoMap: Map<string, ServiceActionInfo>;
258
+ protected readonly cliActionInfoMap: Map<string, CLIActionInfo>;
259
+ protected readonly accessControl: IBaseObjectConstructor<AccessControl>;
260
+ protected readonly controllers: IBaseObjectConstructor<Controller>[];
261
+ protected readonly rules: IBaseObjectConstructor<AccessControlRule>[];
262
+ protected readonly cli?: CLIEntrypoint | CLIEntrypoint[];
263
+ protected readonly http?: HTTPEntrypoint | HTTPEntrypoint[];
264
+ protected readonly service?: ServiceEntrypoint | ServiceEntrypoint[];
265
+ /**
266
+ * Initializer
267
+ * @protected
268
+ */
269
+ protected init(): Promise<void>;
270
+ /**
271
+ * Http action info getter
272
+ * @constructor
273
+ */
274
+ get HTTP_ACTIONS(): HTTPActionInfo[];
275
+ /**
276
+ * Service action info getter
277
+ * @constructor
278
+ */
279
+ get SERVICE_ACTIONS(): ServiceActionInfo[];
280
+ /**
281
+ * Cli action info getter
282
+ * @constructor
283
+ */
284
+ get CLI_ACTIONS(): CLIActionInfo[];
285
+ /**
286
+ * Destroyer
287
+ * @protected
288
+ */
289
+ protected destroy(): Promise<void>;
290
+ /**
291
+ * Find duplicate action names
292
+ * @protected
293
+ * @param actionInfoMap
294
+ */
295
+ protected findDuplicateActionNames(actionInfoMap: Map<string, BaseActionInfo>): string[];
65
296
  /**
66
- * Table name.
67
- * If not specified then naming strategy will generate table name from entity name.
297
+ * Run access control
298
+ * @param rules
299
+ * @param runtimeContainer
300
+ * @param context
301
+ * @param input
302
+ * @param details
303
+ * @protected
68
304
  */
69
- name?: string;
305
+ protected runAccessControl(rules: IBaseObjectConstructor<AccessControlRule>[], runtimeContainer: Container, context: CLIContext | HTTPContext | ServiceContext, input: Record<string, any>, details: ActionDetails): Promise<void>;
70
306
  /**
71
- * Specifies a default order by used for queries from this table when no explicit order by is specified.
307
+ * Run controller's method and return its result (without AbortController)
308
+ * @param details
309
+ * @param context
310
+ * @param dtoConstructor
311
+ * @protected
72
312
  */
73
- orderBy?: OrderByCondition | ((object: any) => OrderByCondition | any);
313
+ protected runControllerMethodWithoutAbortController<DTOConstructor extends typeof DTO = typeof DTO>(details: ActionDetails, context: CLIContext | HTTPContext | ServiceContext, dtoConstructor: DTOConstructor): Promise<unknown>;
74
314
  /**
75
- * Table's database engine type (like "InnoDB", "MyISAM", etc).
76
- * It is used only during table creation.
77
- * If you update this value and table is already created, it will not change table's engine type.
78
- * Note that not all databases support this option.
315
+ * Run controller's method and return its result (with AbortController)
316
+ * @param details
317
+ * @param context
318
+ * @param dtoConstructor
319
+ * @param abortController
320
+ * @protected
79
321
  */
80
- engine?: string;
322
+ protected runControllerMethodWithAbortController<DTOConstructor extends typeof DTO = typeof DTO>(details: ActionDetails, context: CLIContext | HTTPContext | ServiceContext, dtoConstructor: DTOConstructor, abortController: AbortController): Promise<unknown>;
81
323
  /**
82
- * Database name. Used in Mysql and Sql Server.
324
+ * Run controller's method and return its result
325
+ * @param details
326
+ * @param context
327
+ * @param dtoConstructor
328
+ * @param abortController
329
+ * @protected
83
330
  */
84
- database?: string;
331
+ protected runControllerMethod<DTOConstructor extends typeof DTO = typeof DTO>(details: ActionDetails, context: CLIContext | HTTPContext | ServiceContext, dtoConstructor: DTOConstructor, abortController?: AbortController): Promise<unknown>;
85
332
  /**
86
- * Schema name. Used in Postgres and Sql Server.
333
+ * Register
334
+ * @param eps
335
+ * @param registerFunc
336
+ * @protected
87
337
  */
88
- schema?: string;
338
+ protected register<T>(eps: any | any[] | undefined, registerFunc: (entrypoint: T) => void): void;
89
339
  /**
90
- * Indicates if schema synchronization is enabled or disabled for this entity.
91
- * If it will be set to false then schema sync will and migrations ignore this entity.
92
- * By default schema synchronization is enabled for all entities.
340
+ * Register CLI entrypoint
341
+ * @param entrypoint
342
+ * @protected
93
343
  */
94
- synchronize?: boolean;
344
+ protected registerCLIEntrypoint(entrypoint: CLIEntrypoint): void;
95
345
  /**
96
- * If set to 'true' this option disables Sqlite's default behaviour of secretly creating
97
- * an integer primary key column named 'rowid' on table creation.
98
- * @see https://www.sqlite.org/withoutrowid.html.
346
+ * Register http entrypoint
347
+ * @param entrypoint
348
+ * @protected
99
349
  */
100
- withoutRowid?: boolean;
350
+ protected registerHTTPEntrypoint(entrypoint: HTTPEntrypoint): void;
101
351
  /**
102
- * Table comment. Not supported by all database types.
352
+ * Register service entrypoint
353
+ * @param entrypoint
354
+ * @protected
103
355
  */
104
- comment?: string;
356
+ protected registerServiceEntrypoint(entrypoint: ServiceEntrypoint): void;
105
357
  }
106
358
 
107
- export type { EntityOptions as E, IndexOptions as I };
359
+ export { BuildCLIEntrypoint as k, BuildHTTPEntrypoint as l, BuildServiceEntrypoint as m, BuildEntrypoints as n, Entrypoint as o, ContextType as p, BaseContext as q, CLIContext as r, HTTPContext as s, ServiceContext as t, Controller as v, AccessControlRule as w };
360
+ export type { AccessControlRuleHandler as A, BaseActionInfo as B, CLIEntrypoint as C, EntrypointDestroyer as E, HTTPEntrypoint as H, ServiceEntrypoint as S, CLIMap as a, HTTPRouteMap as b, CLIEntrypointHandler as c, HTTPEntrypointHandler as d, ServiceEntrypointHandler as e, EntrypointDestroyerRegistrar as f, EntrypointOptions as g, HTTPActionInfo as h, ServiceActionInfo as i, CLIActionInfo as j, ControllerProperty as u };
@@ -979,5 +979,5 @@ declare class Container {
979
979
  destroy(): Promise<void>;
980
980
  }
981
981
 
982
- export { BaseObject as B, Component as C, Module as M, OverridableNamedObjectOptions as O, Provider as P, ModuleOptions as a, ModuleConfigLoader as b, LoadObjectOptions as c, Container as g, LoadAnonymousObjectOptions as h, LoadNamedObjectOptions as i, ModuleLoadObjectsOptions as j, OverridableObjectOptions as k };
983
- export type { EventAndListener as E, IBaseObjectConstructor as I, LifetimeType as L, ConstructorOptions as d, event as e, ListenerFn as f };
982
+ export { BaseObject as B, Component as C, Module as M, OverridableNamedObjectOptions as O, Provider as P, Container as a, ModuleOptions as b, ModuleConfigLoader as c, LoadObjectOptions as d, LoadAnonymousObjectOptions as h, LoadNamedObjectOptions as i, ModuleLoadObjectsOptions as j, OverridableObjectOptions as k };
983
+ export type { EventAndListener as E, IBaseObjectConstructor as I, LifetimeType as L, ConstructorOptions as e, event as f, ListenerFn as g };
@@ -4137,4 +4137,4 @@ declare class DTO extends DataValidator {
4137
4137
  }
4138
4138
 
4139
4139
  export { DTO as D };
4140
- export type { JSONSchema as J, Schema$1 as S };
4140
+ export type { FunctionSchema as F, JSONSchema as J, Schema$1 as S };
@@ -1,12 +1,21 @@
1
- interface IPatRun {
2
- add(pattern: Record<string, any>, obj: any): void;
3
- remove(pattern: Record<string, any>): void;
4
- find(subject: Record<string, any>, exact?: boolean): any;
5
- list(partialPattern?: Record<string, any>): {
6
- match: Record<string, any>;
7
- data: any;
8
- }[];
9
- toJSON(): string;
1
+ /**
2
+ * 异常抽象类
3
+ */
4
+ declare abstract class Exception extends Error {
5
+ abstract errno: number | string;
6
+ readonly appId: string;
7
+ readonly appName: string;
8
+ readonly errMsg: string;
9
+ readonly err: string;
10
+ constructor(template: string, data: unknown[] | Record<string, any>);
11
+ constructor(message: string);
12
+ constructor(error: Error);
13
+ constructor();
14
+ /**
15
+ * 获取错误名称
16
+ * @returns {string}
17
+ */
18
+ get name(): string;
10
19
  }
11
20
 
12
- export type { IPatRun as I };
21
+ export { Exception as E };
@@ -1,21 +1,3 @@
1
- /**
2
- * 异常抽象类
3
- */
4
- declare abstract class Exception extends Error {
5
- abstract errno: number | string;
6
- readonly appId: string;
7
- readonly appName: string;
8
- readonly errMsg: string;
9
- readonly err: string;
10
- constructor(template: string, data: unknown[] | Record<string, any>);
11
- constructor(message: string);
12
- constructor(error: Error);
13
- constructor();
14
- /**
15
- * 获取错误名称
16
- * @returns {string}
17
- */
18
- get name(): string;
19
- }
1
+ type MethodDecorator<ClassPrototype, Method, Property = string | symbol> = (target: ClassPrototype, propertyKey: Property, descriptor: TypedPropertyDescriptor<Method>) => TypedPropertyDescriptor<Method> | void;
20
2
 
21
- export { Exception as E };
3
+ export type { MethodDecorator as M };
@@ -1,3 +1,6 @@
1
- type ActionPattern<T extends Record<string, any> = {}> = Record<string, any> & T;
1
+ interface IConstructor<T = any> {
2
+ new (...args: any[]): T;
3
+ [prop: string]: any;
4
+ }
2
5
 
3
- export type { ActionPattern as A };
6
+ export type { IConstructor as I };
@@ -1,72 +0,0 @@
1
- import { P as Provider } from './TypeDef.3.js';
2
- import { D as DTO } from './TypeDef.5.js';
3
- import { A as ActionPattern } from './TypeDef.9.js';
4
- import { IncomingMessage, ServerResponse } from 'node:http';
5
-
6
- /**
7
- * Context types
8
- */
9
- declare enum ContextType {
10
- CLI = "CLI",
11
- HTTP = "HTTP",
12
- SERVICE = "SERVICE"
13
- }
14
- type ContextParams<T extends {} = {}> = T & Record<string, any>;
15
- /**
16
- * Base context class
17
- */
18
- declare class BaseContext<T extends Record<string, any> = {}> extends DTO {
19
- readonly type: ContextType;
20
- data: ActionPattern<T>;
21
- constructor(params: ContextParams);
22
- }
23
-
24
- declare class CLIContext<T extends Record<string, any> = {}> extends BaseContext<T> {
25
- readonly type: ContextType;
26
- command: string;
27
- constructor(params: ContextParams<{
28
- readonly command: string;
29
- readonly data: Record<string, any>;
30
- }>);
31
- }
32
-
33
- declare class HTTPContext<T extends Record<string, any> = {}> extends BaseContext<T> {
34
- readonly type: ContextType;
35
- readonly route: string;
36
- readonly method: string;
37
- readonly request: IncomingMessage;
38
- readonly response: ServerResponse;
39
- constructor(params: ContextParams<{
40
- readonly route: string;
41
- readonly method: string;
42
- readonly request: IncomingMessage;
43
- readonly response: ServerResponse;
44
- readonly data: Record<string, any>;
45
- }>);
46
- }
47
-
48
- declare class ServiceContext<T extends Record<string, any> = {}> extends BaseContext<T> {
49
- readonly type: ContextType;
50
- input: ActionPattern<T>;
51
- constructor(params: ContextParams<{
52
- readonly data: ActionPattern;
53
- }>);
54
- }
55
-
56
- /**
57
- * For action decorator
58
- */
59
- type ControllerProperty<ClassPrototype extends Controller> = Exclude<keyof ClassPrototype, keyof Controller>;
60
- /**
61
- * Controller base class
62
- */
63
- declare class Controller extends Provider {
64
- /**
65
- * Context, possible be cli context, http context or service context
66
- * @protected
67
- */
68
- protected readonly context: CLIContext | HTTPContext | ServiceContext;
69
- }
70
-
71
- export { BaseContext as B, Controller as C, HTTPContext as H, ServiceContext as S, CLIContext as a, ContextType as b };
72
- export type { ControllerProperty as c };