@velajs/vela 1.0.0 → 1.1.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 (71) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +36 -2
  3. package/dist/cache/cache.decorators.d.ts +2 -2
  4. package/dist/cache/cache.module.d.ts +1 -1
  5. package/dist/cache/cache.module.js +1 -1
  6. package/dist/constants.d.ts +8 -8
  7. package/dist/constants.js +8 -8
  8. package/dist/container/container.js +2 -2
  9. package/dist/container/decorators.js +8 -11
  10. package/dist/container/types.d.ts +1 -0
  11. package/dist/errors/http-exception.d.ts +21 -20
  12. package/dist/errors/http-exception.js +6 -6
  13. package/dist/event-emitter/event-emitter.decorators.js +2 -3
  14. package/dist/event-emitter/event-emitter.subscriber.js +2 -1
  15. package/dist/factory.d.ts +0 -1
  16. package/dist/factory.js +2 -32
  17. package/dist/fetch/fetch.module.d.ts +2 -2
  18. package/dist/fetch/fetch.module.js +2 -2
  19. package/dist/health/health.service.js +6 -2
  20. package/dist/http/decorators.d.ts +6 -5
  21. package/dist/http/decorators.js +28 -76
  22. package/dist/http/execution-context.d.ts +4 -0
  23. package/dist/http/execution-context.js +15 -0
  24. package/dist/http/index.d.ts +2 -2
  25. package/dist/http/index.js +1 -1
  26. package/dist/http/route.manager.d.ts +1 -2
  27. package/dist/http/route.manager.js +19 -25
  28. package/dist/http/types.d.ts +0 -1
  29. package/dist/index.d.ts +2 -8
  30. package/dist/index.js +6 -11
  31. package/dist/internal.d.ts +11 -0
  32. package/dist/internal.js +13 -0
  33. package/dist/metadata.js +6 -15
  34. package/dist/module/decorators.d.ts +1 -3
  35. package/dist/module/decorators.js +8 -20
  36. package/dist/module/graph.d.ts +10 -0
  37. package/dist/module/graph.js +35 -0
  38. package/dist/module/index.d.ts +2 -0
  39. package/dist/module/index.js +1 -0
  40. package/dist/{http/middleware-consumer.d.ts → module/middleware.d.ts} +4 -14
  41. package/dist/{http/middleware-consumer.js → module/middleware.js} +0 -12
  42. package/dist/module/module-loader.d.ts +1 -1
  43. package/dist/module/module-loader.js +17 -13
  44. package/dist/module/types.d.ts +1 -29
  45. package/dist/openapi/decorators.js +15 -10
  46. package/dist/openapi/document.js +7 -42
  47. package/dist/pipeline/app-providers.d.ts +10 -0
  48. package/dist/pipeline/app-providers.js +43 -0
  49. package/dist/pipeline/decorators.d.ts +5 -5
  50. package/dist/pipeline/decorators.js +1 -9
  51. package/dist/pipeline/reflector.d.ts +8 -24
  52. package/dist/pipeline/reflector.js +10 -55
  53. package/dist/registry/index.d.ts +1 -1
  54. package/dist/registry/metadata.registry.d.ts +18 -13
  55. package/dist/registry/metadata.registry.js +133 -159
  56. package/dist/registry/paths.d.ts +3 -0
  57. package/dist/registry/paths.js +15 -0
  58. package/dist/registry/types.d.ts +24 -14
  59. package/dist/registry/types.js +0 -1
  60. package/dist/registry/util.d.ts +3 -0
  61. package/dist/registry/util.js +8 -0
  62. package/dist/schedule/schedule.decorators.js +3 -6
  63. package/dist/schedule/schedule.registry.js +3 -2
  64. package/dist/throttler/throttler.decorators.d.ts +2 -2
  65. package/package.json +5 -9
  66. package/dist/testing/index.d.ts +0 -2
  67. package/dist/testing/index.js +0 -2
  68. package/dist/testing/testing.builder.d.ts +0 -29
  69. package/dist/testing/testing.builder.js +0 -148
  70. package/dist/testing/testing.module.d.ts +0 -9
  71. package/dist/testing/testing.module.js +0 -15
@@ -1,108 +1,69 @@
1
+ import { getOrCreate, getOrCreateArray, getOrCreateMap } from "./util.js";
2
+ function emptyComponentStore() {
3
+ return {
4
+ middleware: new Set(),
5
+ guard: new Set(),
6
+ pipe: new Set(),
7
+ interceptor: new Set(),
8
+ filter: new Set()
9
+ };
10
+ }
11
+ function emptyComponentByOwner() {
12
+ return {
13
+ middleware: new Map(),
14
+ guard: new Map(),
15
+ pipe: new Map(),
16
+ interceptor: new Map(),
17
+ filter: new Map()
18
+ };
19
+ }
1
20
  export class MetadataRegistry {
21
+ // Decoration metadata (set at import time, persists across clear()).
2
22
  static routes = new Map();
3
23
  static controllers = new Map();
4
24
  static controllerOptions = new Map();
5
25
  static modules = new Map();
6
26
  static parameters = new Map();
7
- // 3-level component hierarchy
8
- static global = new Map([
9
- [
10
- 'middleware',
11
- new Set()
12
- ],
13
- [
14
- 'guard',
15
- new Set()
16
- ],
17
- [
18
- 'pipe',
19
- new Set()
20
- ],
21
- [
22
- 'interceptor',
23
- new Set()
24
- ],
25
- [
26
- 'filter',
27
- new Set()
28
- ]
29
- ]);
30
- static controller = new Map([
31
- [
32
- 'middleware',
33
- new Map()
34
- ],
35
- [
36
- 'guard',
37
- new Map()
38
- ],
39
- [
40
- 'pipe',
41
- new Map()
42
- ],
43
- [
44
- 'interceptor',
45
- new Map()
46
- ],
47
- [
48
- 'filter',
49
- new Map()
50
- ]
51
- ]);
52
- static handler = new Map([
53
- [
54
- 'middleware',
55
- new Map()
56
- ],
57
- [
58
- 'guard',
59
- new Map()
60
- ],
61
- [
62
- 'pipe',
63
- new Map()
64
- ],
65
- [
66
- 'interceptor',
67
- new Map()
68
- ],
69
- [
70
- 'filter',
71
- new Map()
72
- ]
73
- ]);
74
- // DI metadata
75
27
  static injectables = new Set();
76
28
  static scopes = new Map();
77
29
  static injectTokens = new Map();
78
- // HTTP handler metadata
79
30
  static handlerHttpMeta = new Map();
80
- // Exception filter types
81
31
  static catchTypes = new Map();
82
- // Route versions
83
32
  static routeVersions = new Map();
84
- // Custom metadata (SetMetadata)
85
- static customClassMeta = new Map();
86
- static customHandlerMeta = new Map();
33
+ // Free-form key→value class & handler meta. Backs:
34
+ // - @SetMetadata (custom user keys)
35
+ // - feature decorators (@Cron, @OnEvent, @ApiDoc, …)
36
+ // - the SWC shim (Reflect.metadata's design:* keys)
37
+ // - external Reflect.defineMetadata / Reflect.getMetadata calls.
38
+ static classMeta = new Map();
39
+ static handlerMeta = new Map();
40
+ // Component decoration (set by @UseGuards/@UsePipes/etc. at decoration time).
41
+ static controllerComponents = emptyComponentByOwner();
42
+ static handlerComponents = {
43
+ middleware: new Map(),
44
+ guard: new Map(),
45
+ pipe: new Map(),
46
+ interceptor: new Map(),
47
+ filter: new Map()
48
+ };
49
+ // Global components — app-time state (cleared by clear()).
50
+ static globalComponents = emptyComponentStore();
87
51
  // Routes
88
52
  static getRoutes(controller) {
89
- return this.routes.get(controller) || [];
53
+ return this.routes.get(controller) ?? [];
90
54
  }
91
55
  static addRoute(controller, route) {
92
- if (!this.routes.has(controller)) {
93
- this.routes.set(controller, []);
94
- }
95
- this.routes.get(controller).push(route);
56
+ getOrCreateArray(this.routes, controller).push(route);
96
57
  }
97
58
  // Controllers
98
59
  static getControllerPath(controller) {
99
- return this.controllers.get(controller) || '';
60
+ return this.controllers.get(controller) ?? '';
100
61
  }
101
62
  static setControllerPath(controller, path) {
102
63
  this.controllers.set(controller, path);
103
64
  }
104
65
  static getControllerOptions(controller) {
105
- return this.controllerOptions.get(controller) || {};
66
+ return this.controllerOptions.get(controller) ?? {};
106
67
  }
107
68
  static setControllerOptions(controller, options) {
108
69
  this.controllerOptions.set(controller, options);
@@ -116,53 +77,37 @@ export class MetadataRegistry {
116
77
  }
117
78
  // Parameters
118
79
  static getParameters(controller) {
119
- return this.parameters.get(controller) || new Map();
80
+ return this.parameters.get(controller) ?? new Map();
120
81
  }
121
82
  static addParameter(controller, methodName, param) {
122
- if (!this.parameters.has(controller)) {
123
- this.parameters.set(controller, new Map());
124
- }
125
- const methodParams = this.parameters.get(controller);
126
- if (!methodParams.has(methodName)) {
127
- methodParams.set(methodName, []);
128
- }
129
- methodParams.get(methodName).push(param);
83
+ const methodMap = getOrCreateMap(this.parameters, controller);
84
+ getOrCreateArray(methodMap, methodName).push(param);
130
85
  }
131
- // Component registration — 3 levels
86
+ // Component registration — global
132
87
  static registerGlobal(type, component) {
133
- this.global.get(type).add(component);
88
+ this.globalComponents[type].add(component);
134
89
  }
135
90
  static getGlobal(type) {
136
- return this.global.get(type);
91
+ return this.globalComponents[type];
137
92
  }
93
+ // Component registration — controller-level
138
94
  static registerController(type, controller, component) {
139
- const typeMap = this.controller.get(type);
140
- if (!typeMap.has(controller)) {
141
- typeMap.set(controller, []);
142
- }
143
- typeMap.get(controller).push(component);
95
+ const map = this.controllerComponents[type];
96
+ getOrCreateArray(map, controller).push(component);
144
97
  }
145
98
  static getController(type, controller) {
146
- const typeMap = this.controller.get(type);
147
- return typeMap.get(controller) || [];
99
+ const map = this.controllerComponents[type];
100
+ return map.get(controller) ?? [];
148
101
  }
102
+ // Component registration — handler-level
149
103
  static registerHandler(type, controller, methodName, component) {
150
- const typeMap = this.handler.get(type);
151
- let methodMap = typeMap.get(controller);
152
- if (!methodMap) {
153
- methodMap = new Map();
154
- typeMap.set(controller, methodMap);
155
- }
156
- let components = methodMap.get(methodName);
157
- if (!components) {
158
- components = [];
159
- methodMap.set(methodName, components);
160
- }
161
- components.push(component);
104
+ const map = this.handlerComponents[type];
105
+ const methodMap = getOrCreateMap(map, controller);
106
+ getOrCreateArray(methodMap, methodName).push(component);
162
107
  }
163
108
  static getHandler(type, controller, methodName) {
164
- const typeMap = this.handler.get(type);
165
- return typeMap.get(controller)?.get(methodName) ?? [];
109
+ const map = this.handlerComponents[type];
110
+ return map.get(controller)?.get(methodName) ?? [];
166
111
  }
167
112
  // DI metadata
168
113
  static markInjectable(target) {
@@ -185,12 +130,8 @@ export class MetadataRegistry {
185
130
  }
186
131
  // HTTP handler metadata
187
132
  static setHandlerHttpMeta(controller, method, meta) {
188
- if (!this.handlerHttpMeta.has(controller)) {
189
- this.handlerHttpMeta.set(controller, new Map());
190
- }
191
- const methodMap = this.handlerHttpMeta.get(controller);
133
+ const methodMap = getOrCreateMap(this.handlerHttpMeta, controller);
192
134
  const existing = methodMap.get(method) ?? {};
193
- // Append-merge responseHeaders
194
135
  const merged = {
195
136
  ...existing,
196
137
  ...meta
@@ -218,79 +159,112 @@ export class MetadataRegistry {
218
159
  }
219
160
  // Route versions
220
161
  static setRouteVersion(controller, method, version) {
221
- if (!this.routeVersions.has(controller)) {
222
- this.routeVersions.set(controller, new Map());
223
- }
224
- this.routeVersions.get(controller).set(method, version);
162
+ getOrCreateMap(this.routeVersions, controller).set(method, version);
225
163
  }
226
164
  static getRouteVersion(controller, method) {
227
165
  return this.routeVersions.get(controller)?.get(method);
228
166
  }
229
- // Custom metadata (SetMetadata)
167
+ // Custom class/handler metadata. One slot per (target, key) for class-level,
168
+ // (target, handler, key) for handler-level. The same slots back @SetMetadata,
169
+ // every feature decorator (@Cron, @OnEvent, @ApiDoc, …), the SWC shim, and
170
+ // external Reflect.defineMetadata calls — one model, one source of truth.
230
171
  static setCustomClassMeta(target, key, value) {
231
- if (!this.customClassMeta.has(target)) {
232
- this.customClassMeta.set(target, new Map());
233
- }
234
- this.customClassMeta.get(target).set(key, value);
172
+ getOrCreate(this.classMeta, target, ()=>new Map()).set(key, value);
235
173
  }
236
174
  static getCustomClassMeta(target, key) {
237
- return this.customClassMeta.get(target)?.get(key);
175
+ return this.classMeta.get(target)?.get(key);
238
176
  }
239
177
  static getCustomClassMetaAll(target) {
240
- return this.customClassMeta.get(target);
178
+ return this.classMeta.get(target);
241
179
  }
242
180
  static setCustomHandlerMeta(target, handler, key, value) {
243
- if (!this.customHandlerMeta.has(target)) {
244
- this.customHandlerMeta.set(target, new Map());
245
- }
246
- const handlerMap = this.customHandlerMeta.get(target);
247
- if (!handlerMap.has(handler)) {
248
- handlerMap.set(handler, new Map());
249
- }
250
- handlerMap.get(handler).set(key, value);
181
+ const byHandler = getOrCreate(this.handlerMeta, target, ()=>new Map());
182
+ getOrCreate(byHandler, handler, ()=>new Map()).set(key, value);
251
183
  }
252
184
  static getCustomHandlerMeta(target, handler, key) {
253
- return this.customHandlerMeta.get(target)?.get(handler)?.get(key);
185
+ return this.handlerMeta.get(target)?.get(handler)?.get(key);
254
186
  }
255
187
  static getCustomHandlerMetaAll(target, handler) {
256
- return this.customHandlerMeta.get(target)?.get(handler);
188
+ return this.handlerMeta.get(target)?.get(handler);
189
+ }
190
+ // Append helpers — for stackable metadata like @Cron / @Interval / @OnEvent / @ApiResponse.
191
+ static appendCustomClassMeta(target, key, item) {
192
+ const list = this.getCustomClassMeta(target, key) ?? [];
193
+ list.push(item);
194
+ this.setCustomClassMeta(target, key, list);
195
+ }
196
+ static appendCustomHandlerMeta(target, handler, key, item) {
197
+ const list = this.getCustomHandlerMeta(target, handler, key) ?? [];
198
+ list.push(item);
199
+ this.setCustomHandlerMeta(target, handler, key, list);
200
+ }
201
+ // Reflect-style API — same storage as the typed setters above. Lets external
202
+ // code (and the SWC shim's Reflect.metadata polyfill) write/read uniformly.
203
+ static setReflectMetadata(target, key, value, propertyKey) {
204
+ if (propertyKey !== undefined) {
205
+ this.setCustomHandlerMeta(target, propertyKey, key, value);
206
+ } else {
207
+ this.setCustomClassMeta(target, key, value);
208
+ }
209
+ }
210
+ static getReflectMetadata(target, key, propertyKey) {
211
+ if (propertyKey !== undefined) {
212
+ return this.getCustomHandlerMeta(target, propertyKey, key);
213
+ }
214
+ return this.getCustomClassMeta(target, key);
215
+ }
216
+ // SWC-emitted design:paramtypes — class-level for constructors, handler-level for methods.
217
+ static getParamTypes(target, propertyKey) {
218
+ return this.getReflectMetadata(target, 'design:paramtypes', propertyKey);
257
219
  }
258
220
  // Propagate all controller-level components from one class to another.
259
- // Used by ModuleLoader to apply module-level decorators to every controller.
260
221
  static propagateControllerComponents(from, to) {
261
- for (const [, typeMap] of this.controller.entries()){
262
- const components = typeMap.get(from);
222
+ for (const type of [
223
+ 'middleware',
224
+ 'guard',
225
+ 'pipe',
226
+ 'interceptor',
227
+ 'filter'
228
+ ]){
229
+ const map = this.controllerComponents[type];
230
+ const components = map.get(from);
263
231
  if (components && components.length > 0) {
264
- if (!typeMap.has(to)) {
265
- typeMap.set(to, []);
266
- }
267
- typeMap.get(to).push(...components);
232
+ const target = getOrCreateArray(map, to);
233
+ target.push(...components);
268
234
  }
269
235
  }
270
236
  }
271
- // Clear all (for testing)
237
+ // Clear app-time state. Decoration metadata persists — once a class is
238
+ // decorated, that fact is permanent for the lifetime of the process.
272
239
  static clear() {
240
+ this.globalComponents = emptyComponentStore();
241
+ }
242
+ // Full reset, including decoration metadata. Used in framework-internal scenarios.
243
+ static reset() {
273
244
  this.routes.clear();
274
245
  this.controllers.clear();
275
246
  this.controllerOptions.clear();
276
247
  this.modules.clear();
277
248
  this.parameters.clear();
278
- for (const set of this.global.values()){
279
- set.clear();
280
- }
281
- for (const map of this.controller.values()){
282
- map.clear();
283
- }
284
- for (const map of this.handler.values()){
285
- map.clear();
286
- }
287
249
  this.injectables.clear();
288
250
  this.scopes.clear();
289
251
  this.injectTokens.clear();
290
252
  this.handlerHttpMeta.clear();
291
253
  this.catchTypes.clear();
292
254
  this.routeVersions.clear();
293
- this.customClassMeta.clear();
294
- this.customHandlerMeta.clear();
255
+ this.classMeta.clear();
256
+ this.handlerMeta.clear();
257
+ for (const type of [
258
+ 'middleware',
259
+ 'guard',
260
+ 'pipe',
261
+ 'interceptor',
262
+ 'filter'
263
+ ]){
264
+ this.controllerComponents[type].clear();
265
+ this.handlerComponents[type].clear();
266
+ }
267
+ this.globalComponents = emptyComponentStore();
268
+ // reflectMeta is a WeakMap — entries die with their targets.
295
269
  }
296
270
  }
@@ -0,0 +1,3 @@
1
+ export declare function normalizePath(path: string): string;
2
+ export declare function joinPaths(prefix: string, path: string): string;
3
+ export declare function toOpenApiPath(path: string): string;
@@ -0,0 +1,15 @@
1
+ // Single home for path manipulation. Used by route building, openapi docs,
2
+ // and decorator metadata.
3
+ export function normalizePath(path) {
4
+ if (!path) return path;
5
+ return path.startsWith('/') ? path : `/${path}`;
6
+ }
7
+ export function joinPaths(prefix, path) {
8
+ const cleanPrefix = prefix.endsWith('/') ? prefix.slice(0, -1) : prefix;
9
+ const cleanPath = path && !path.startsWith('/') ? `/${path}` : path;
10
+ return `${cleanPrefix}${cleanPath}` || '/';
11
+ }
12
+ // Convert ':id' Hono syntax to '{id}' OpenAPI syntax.
13
+ export function toOpenApiPath(path) {
14
+ return path.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, '{$1}');
15
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Context } from 'hono';
2
2
  import type { CanActivate, ExceptionFilter, NestInterceptor, NestMiddleware, PipeTransform } from '../pipeline/types';
3
- export type Type<T = any> = new (...args: any[]) => T;
4
- export type Constructor = Function;
3
+ import type { Constructor, ForwardRef, InjectionToken, ProviderOptions, Token, Type } from '../container/types';
4
+ export type { Constructor, ForwardRef, InjectionToken, ProviderOptions, Token, Type };
5
5
  export type ComponentType = 'middleware' | 'guard' | 'pipe' | 'interceptor' | 'filter';
6
6
  export type MiddlewareType = Type<NestMiddleware> | NestMiddleware;
7
7
  export type GuardType = Type<CanActivate> | CanActivate;
@@ -37,21 +37,31 @@ export interface HttpHandlerMeta {
37
37
  statusCode: number;
38
38
  };
39
39
  }
40
+ export type ModuleImport = Type | DynamicModule | ForwardRef;
41
+ export interface AsyncModuleOptions<T = unknown> {
42
+ imports?: ModuleImport[];
43
+ useFactory: (...args: any[]) => T | Promise<T>;
44
+ inject?: Token[];
45
+ }
46
+ export interface DynamicModule {
47
+ module: Type;
48
+ imports?: ModuleImport[];
49
+ providers?: Array<Type | ProviderOptions>;
50
+ controllers?: Type[];
51
+ exports?: Array<Type | InjectionToken>;
52
+ global?: boolean;
53
+ }
40
54
  export interface ModuleOptions {
41
- imports?: unknown[];
42
55
  providers?: Array<Type | ProviderOptions>;
43
56
  controllers?: Type[];
44
- exports?: Array<Type | InjectionTokenLike>;
57
+ imports?: ModuleImport[];
58
+ exports?: Array<Type | InjectionToken>;
45
59
  isGlobal?: boolean;
46
60
  }
47
- export interface InjectionTokenLike {
48
- toString(): string;
49
- }
50
- export interface ProviderOptions<T = unknown> {
51
- token?: unknown;
52
- scope?: string;
53
- useValue?: T;
54
- useFactory?: (...args: unknown[]) => T | Promise<T>;
55
- inject?: unknown[];
56
- useExisting?: unknown;
61
+ export interface ModuleMetadata {
62
+ providers: Array<Type | ProviderOptions>;
63
+ controllers: Type[];
64
+ imports: ModuleImport[];
65
+ exports: Array<Type | InjectionToken>;
66
+ isGlobal: boolean;
57
67
  }
@@ -1,2 +1 @@
1
- // Forward-compatible with ProviderOptions
2
1
  export { };
@@ -0,0 +1,3 @@
1
+ export declare function getOrCreate<K, V>(map: Map<K, V>, key: K, factory: () => V): V;
2
+ export declare const getOrCreateMap: <K, NK, NV>(map: Map<K, Map<NK, NV>>, key: K) => Map<NK, NV>;
3
+ export declare const getOrCreateArray: <K, V>(map: Map<K, V[]>, key: K) => V[];
@@ -0,0 +1,8 @@
1
+ // Single map.get + optional set. Replaces `map.has(key) || map.set(key, …); map.get(key)!` patterns.
2
+ export function getOrCreate(map, key, factory) {
3
+ let v = map.get(key);
4
+ if (v === undefined) map.set(key, v = factory());
5
+ return v;
6
+ }
7
+ export const getOrCreateMap = (map, key)=>getOrCreate(map, key, ()=>new Map());
8
+ export const getOrCreateArray = (map, key)=>getOrCreate(map, key, ()=>[]);
@@ -1,21 +1,18 @@
1
+ import { MetadataRegistry } from "../registry/metadata.registry.js";
1
2
  import { CRON_METADATA, INTERVAL_METADATA } from "./schedule.tokens.js";
2
3
  export function Cron(expression) {
3
4
  return (target, propertyKey)=>{
4
- const existing = Reflect.getMetadata(CRON_METADATA, target.constructor) ?? [];
5
- existing.push({
5
+ MetadataRegistry.appendCustomClassMeta(target.constructor, CRON_METADATA, {
6
6
  expression,
7
7
  methodName: String(propertyKey)
8
8
  });
9
- Reflect.defineMetadata(CRON_METADATA, existing, target.constructor);
10
9
  };
11
10
  }
12
11
  export function Interval(ms) {
13
12
  return (target, propertyKey)=>{
14
- const existing = Reflect.getMetadata(INTERVAL_METADATA, target.constructor) ?? [];
15
- existing.push({
13
+ MetadataRegistry.appendCustomClassMeta(target.constructor, INTERVAL_METADATA, {
16
14
  ms,
17
15
  methodName: String(propertyKey)
18
16
  });
19
- Reflect.defineMetadata(INTERVAL_METADATA, existing, target.constructor);
20
17
  };
21
18
  }
@@ -14,6 +14,7 @@ function _ts_param(paramIndex, decorator) {
14
14
  }
15
15
  import { Injectable, Inject } from "../container/index.js";
16
16
  import { Container } from "../container/container.js";
17
+ import { MetadataRegistry } from "../registry/metadata.registry.js";
17
18
  import { CRON_METADATA, INTERVAL_METADATA } from "./schedule.tokens.js";
18
19
  export class ScheduleRegistry {
19
20
  container;
@@ -26,8 +27,8 @@ export class ScheduleRegistry {
26
27
  const tokens = this.container.getTokens();
27
28
  for (const token of tokens){
28
29
  if (typeof token !== 'function') continue;
29
- const cronMeta = Reflect.getMetadata(CRON_METADATA, token);
30
- const intervalMeta = Reflect.getMetadata(INTERVAL_METADATA, token);
30
+ const cronMeta = MetadataRegistry.getCustomClassMeta(token, CRON_METADATA);
31
+ const intervalMeta = MetadataRegistry.getCustomClassMeta(token, INTERVAL_METADATA);
31
32
  if (!cronMeta && !intervalMeta) continue;
32
33
  let instance;
33
34
  try {
@@ -1,3 +1,3 @@
1
1
  import type { ThrottleConfig } from './throttler.types';
2
- export declare const Throttle: (config: ThrottleConfig) => (target: Function | object, propertyKey?: string | symbol) => void;
3
- export declare const SkipThrottle: () => (target: Function | object, propertyKey?: string | symbol) => void;
2
+ export declare const Throttle: (config: ThrottleConfig) => (target: object, propertyKey?: string | symbol) => void;
3
+ export declare const SkipThrottle: () => (target: object, propertyKey?: string | symbol) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/vela",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "NestJS-compatible framework for edge runtimes, powered by Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,6 +10,10 @@
10
10
  "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js"
12
12
  },
13
+ "./internal": {
14
+ "types": "./dist/internal.d.ts",
15
+ "import": "./dist/internal.js"
16
+ },
13
17
  "./streaming": {
14
18
  "types": "./dist/streaming/index.d.ts",
15
19
  "import": "./dist/streaming/index.js"
@@ -56,14 +60,6 @@
56
60
  "dependencies": {
57
61
  "hono": "^4"
58
62
  },
59
- "peerDependencies": {
60
- "@velajs/crud": ">=0.1.0"
61
- },
62
- "peerDependenciesMeta": {
63
- "@velajs/crud": {
64
- "optional": true
65
- }
66
- },
67
63
  "devDependencies": {
68
64
  "@swc/cli": "^0.8.0",
69
65
  "@swc/core": "^1.15.11",
@@ -1,2 +0,0 @@
1
- export { Test, TestingModuleBuilder, OverrideBy } from './testing.builder';
2
- export { TestingModule } from './testing.module';
@@ -1,2 +0,0 @@
1
- export { Test, TestingModuleBuilder, OverrideBy } from "./testing.builder.js";
2
- export { TestingModule } from "./testing.module.js";
@@ -1,29 +0,0 @@
1
- import type { Token, Type } from '../container/types';
2
- import type { ModuleOptions } from '../module/types';
3
- import { TestingModule } from './testing.module';
4
- export declare class OverrideBy {
5
- private readonly builder;
6
- private readonly token;
7
- constructor(builder: TestingModuleBuilder, token: Token);
8
- useValue(value: unknown): TestingModuleBuilder;
9
- useClass(cls: Type): TestingModuleBuilder;
10
- useFactory(options: {
11
- factory: (...args: unknown[]) => unknown;
12
- inject?: Token[];
13
- }): TestingModuleBuilder;
14
- }
15
- export declare class TestingModuleBuilder {
16
- private readonly metadata;
17
- private overrides;
18
- constructor(metadata: ModuleOptions);
19
- overrideProvider(token: Token): OverrideBy;
20
- overrideGuard(guard: Type): OverrideBy;
21
- overridePipe(pipe: Type): OverrideBy;
22
- overrideInterceptor(interceptor: Type): OverrideBy;
23
- overrideFilter(filter: Type): OverrideBy;
24
- private addOverride;
25
- compile(): Promise<TestingModule>;
26
- }
27
- export declare class Test {
28
- static createTestingModule(metadata: ModuleOptions): TestingModuleBuilder;
29
- }