@velajs/vela 0.9.0 → 1.0.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 (41) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/application.d.ts +12 -0
  3. package/dist/application.js +22 -0
  4. package/dist/constants.d.ts +29 -26
  5. package/dist/constants.js +26 -29
  6. package/dist/http/middleware-consumer.d.ts +11 -10
  7. package/dist/http/middleware-consumer.js +10 -11
  8. package/dist/http/route.manager.js +1 -6
  9. package/dist/index.d.ts +4 -4
  10. package/dist/index.js +2 -2
  11. package/dist/openapi/decorators.d.ts +15 -1
  12. package/dist/openapi/decorators.js +24 -0
  13. package/dist/openapi/document.js +99 -18
  14. package/dist/openapi/index.d.ts +3 -2
  15. package/dist/openapi/index.js +2 -1
  16. package/dist/openapi/scalar-ui.d.ts +1 -0
  17. package/dist/openapi/scalar-ui.js +18 -0
  18. package/dist/openapi/types.d.ts +18 -0
  19. package/dist/pipeline/component.manager.d.ts +1 -0
  20. package/dist/pipeline/component.manager.js +10 -34
  21. package/dist/registry/metadata.registry.d.ts +2 -2
  22. package/dist/registry/metadata.registry.js +13 -6
  23. package/dist/schedule/cron-matcher.d.ts +2 -0
  24. package/dist/schedule/cron-matcher.js +62 -0
  25. package/dist/schedule/index.d.ts +4 -3
  26. package/dist/schedule/index.js +2 -2
  27. package/dist/schedule/schedule.module.d.ts +2 -6
  28. package/dist/schedule/schedule.module.js +4 -42
  29. package/dist/schedule/schedule.tokens.d.ts +0 -3
  30. package/dist/schedule/schedule.tokens.js +0 -2
  31. package/dist/schedule/schedule.types.d.ts +0 -3
  32. package/dist/schedule-node/index.d.ts +2 -0
  33. package/dist/schedule-node/index.js +2 -0
  34. package/dist/schedule-node/schedule-node.module.d.ts +4 -0
  35. package/dist/schedule-node/schedule-node.module.js +18 -0
  36. package/dist/{schedule → schedule-node}/schedule.executor.d.ts +2 -5
  37. package/dist/schedule-node/schedule.executor.js +91 -0
  38. package/dist/services/logger.d.ts +9 -8
  39. package/dist/services/logger.js +14 -15
  40. package/package.json +5 -1
  41. package/dist/schedule/schedule.executor.js +0 -169
@@ -79,7 +79,25 @@ export interface ApiDocMetadata {
79
79
  deprecated?: boolean;
80
80
  tags?: string[];
81
81
  }
82
+ export interface ApiResponseOptions {
83
+ description: string;
84
+ /** Zod schema, DTO class (from createZodDto), or raw JSON Schema. */
85
+ schema?: unknown;
86
+ }
87
+ export interface ApiResponseEntry extends ApiResponseOptions {
88
+ status: number | string;
89
+ }
82
90
  export interface CreateOpenApiDocumentOptions {
83
91
  info?: Partial<OpenApiInfo>;
84
92
  globalPrefix?: string;
85
93
  }
94
+ export interface MountOpenApiOptions {
95
+ /** Pre-built OpenAPI document to serve. */
96
+ document: OpenApiDocument;
97
+ /** Path for the JSON endpoint. Default `/docs.json`. */
98
+ path?: string;
99
+ /** Opt-in UI renderer. Only `scalar` is bundled today. */
100
+ ui?: 'scalar';
101
+ /** Path the UI is served at when `ui` is set. Default `/docs`. */
102
+ uiPath?: string;
103
+ }
@@ -8,6 +8,7 @@ export declare class ComponentManager {
8
8
  static registerController<T extends ComponentType>(type: T, controller: Constructor, ...components: ComponentTypeMap[T][]): void;
9
9
  static registerHandler<T extends ComponentType>(type: T, controller: Constructor, handlerName: string | symbol, ...components: ComponentTypeMap[T][]): void;
10
10
  static getComponents<T extends ComponentType>(type: T, controller: Constructor, handlerName: string | symbol): ComponentTypeMap[T][];
11
+ private static resolveAll;
11
12
  static resolveMiddleware(items: MiddlewareType[]): NestMiddleware[];
12
13
  static resolveGuards(items: GuardType[]): CanActivate[];
13
14
  static resolvePipes(items: PipeType[]): PipeTransform[];
@@ -19,16 +19,14 @@ export class ComponentManager {
19
19
  }
20
20
  }
21
21
  static registerHandler(type, controller, handlerName, ...components) {
22
- const handlerKey = `${controller.name}:${String(handlerName)}`;
23
22
  for (const component of components){
24
- MetadataRegistry.registerHandler(type, handlerKey, component);
23
+ MetadataRegistry.registerHandler(type, controller, handlerName, component);
25
24
  }
26
25
  }
27
26
  // 3-level resolution: global → controller → handler
28
27
  static getComponents(type, controller, handlerName) {
29
- const handlerKey = `${controller.name}:${String(handlerName)}`;
30
28
  const controllerComponents = MetadataRegistry.getController(type, controller);
31
- const handlerComponents = MetadataRegistry.getHandler(type, handlerKey);
29
+ const handlerComponents = MetadataRegistry.getHandler(type, controller, handlerName);
32
30
  return [
33
31
  ...MetadataRegistry.getGlobal(type),
34
32
  ...controllerComponents,
@@ -36,45 +34,23 @@ export class ComponentManager {
36
34
  ];
37
35
  }
38
36
  // Type-specific resolvers
37
+ static resolveAll(items, methodKey) {
38
+ return items.map((item)=>isObject(item) && methodKey in item ? item : this.container.resolve(item));
39
+ }
39
40
  static resolveMiddleware(items) {
40
- return items.map((item)=>{
41
- if (isObject(item) && 'use' in item) {
42
- return item;
43
- }
44
- return this.container.resolve(item);
45
- });
41
+ return this.resolveAll(items, 'use');
46
42
  }
47
43
  static resolveGuards(items) {
48
- return items.map((item)=>{
49
- if (isObject(item) && 'canActivate' in item) {
50
- return item;
51
- }
52
- return this.container.resolve(item);
53
- });
44
+ return this.resolveAll(items, 'canActivate');
54
45
  }
55
46
  static resolvePipes(items) {
56
- return items.map((item)=>{
57
- if (isObject(item) && 'transform' in item) {
58
- return item;
59
- }
60
- return this.container.resolve(item);
61
- });
47
+ return this.resolveAll(items, 'transform');
62
48
  }
63
49
  static resolveInterceptors(items) {
64
- return items.map((item)=>{
65
- if (isObject(item) && 'intercept' in item) {
66
- return item;
67
- }
68
- return this.container.resolve(item);
69
- });
50
+ return this.resolveAll(items, 'intercept');
70
51
  }
71
52
  static resolveFilters(items) {
72
- return items.map((item)=>{
73
- if (isObject(item) && 'catch' in item) {
74
- return item;
75
- }
76
- return this.container.resolve(item);
77
- });
53
+ return this.resolveAll(items, 'catch');
78
54
  }
79
55
  // Pipe execution
80
56
  static async executePipes(value, metadata, pipes) {
@@ -36,8 +36,8 @@ export declare class MetadataRegistry {
36
36
  static getGlobal<T extends ComponentType>(type: T): Set<ComponentTypeMap[T]>;
37
37
  static registerController<T extends ComponentType>(type: T, controller: Constructor, component: ComponentTypeMap[T]): void;
38
38
  static getController<T extends ComponentType>(type: T, controller: Constructor): ComponentTypeMap[T][];
39
- static registerHandler<T extends ComponentType>(type: T, handlerKey: string, component: ComponentTypeMap[T]): void;
40
- static getHandler<T extends ComponentType>(type: T, handlerKey: string): ComponentTypeMap[T][];
39
+ static registerHandler<T extends ComponentType>(type: T, controller: Constructor, methodName: string | symbol, component: ComponentTypeMap[T]): void;
40
+ static getHandler<T extends ComponentType>(type: T, controller: Constructor, methodName: string | symbol): ComponentTypeMap[T][];
41
41
  static markInjectable(target: object): void;
42
42
  static hasInjectable(target: object): boolean;
43
43
  static setScope(target: object, scope: Scope): void;
@@ -146,16 +146,23 @@ export class MetadataRegistry {
146
146
  const typeMap = this.controller.get(type);
147
147
  return typeMap.get(controller) || [];
148
148
  }
149
- static registerHandler(type, handlerKey, component) {
149
+ static registerHandler(type, controller, methodName, component) {
150
150
  const typeMap = this.handler.get(type);
151
- if (!typeMap.has(handlerKey)) {
152
- typeMap.set(handlerKey, []);
151
+ let methodMap = typeMap.get(controller);
152
+ if (!methodMap) {
153
+ methodMap = new Map();
154
+ typeMap.set(controller, methodMap);
153
155
  }
154
- typeMap.get(handlerKey).push(component);
156
+ let components = methodMap.get(methodName);
157
+ if (!components) {
158
+ components = [];
159
+ methodMap.set(methodName, components);
160
+ }
161
+ components.push(component);
155
162
  }
156
- static getHandler(type, handlerKey) {
163
+ static getHandler(type, controller, methodName) {
157
164
  const typeMap = this.handler.get(type);
158
- return typeMap.get(handlerKey) || [];
165
+ return typeMap.get(controller)?.get(methodName) ?? [];
159
166
  }
160
167
  // DI metadata
161
168
  static markInjectable(target) {
@@ -0,0 +1,2 @@
1
+ export type CronMatcher = (date: Date) => boolean;
2
+ export declare function parseCron(expression: string): CronMatcher | null;
@@ -0,0 +1,62 @@
1
+ export function parseCron(expression) {
2
+ const fields = expression.trim().split(/\s+/);
3
+ if (fields.length !== 5) return null;
4
+ const [minuteField, hourField, dayField, monthField, weekdayField] = fields;
5
+ const minute = parseField(minuteField, 0, 59);
6
+ const hour = parseField(hourField, 0, 23);
7
+ const day = parseField(dayField, 1, 31);
8
+ const month = parseField(monthField, 1, 12);
9
+ const weekday = parseField(weekdayField, 0, 7);
10
+ if (!minute || !hour || !day || !month || !weekday) return null;
11
+ return (date)=>minute(date.getMinutes()) && hour(date.getHours()) && day(date.getDate()) && month(date.getMonth() + 1) && weekday(date.getDay());
12
+ }
13
+ function parseField(field, min, max) {
14
+ const segments = field.split(',');
15
+ const predicates = [];
16
+ for (const rawSegment of segments){
17
+ const segment = rawSegment.trim();
18
+ if (!segment) return null;
19
+ const stepParts = segment.split('/');
20
+ if (stepParts.length > 2) return null;
21
+ const step = stepParts.length === 2 ? Number(stepParts[1]) : 1;
22
+ if (!Number.isInteger(step) || step <= 0) return null;
23
+ const range = parseRange(stepParts[0], min, max);
24
+ if (!range) return null;
25
+ predicates.push((value)=>{
26
+ if (value < range.start || value > range.end) return false;
27
+ return (value - range.start) % step === 0;
28
+ });
29
+ }
30
+ return (value)=>predicates.some((p)=>p(value));
31
+ }
32
+ function parseRange(segment, min, max) {
33
+ if (segment === '*') return {
34
+ start: min,
35
+ end: max
36
+ };
37
+ const bounds = segment.split('-');
38
+ if (bounds.length === 1) {
39
+ const value = parseCronNumber(bounds[0], min, max);
40
+ if (value === null) return null;
41
+ return {
42
+ start: value,
43
+ end: value
44
+ };
45
+ }
46
+ if (bounds.length !== 2) return null;
47
+ const start = parseCronNumber(bounds[0], min, max);
48
+ const end = parseCronNumber(bounds[1], min, max);
49
+ if (start === null || end === null || start > end) return null;
50
+ return {
51
+ start,
52
+ end
53
+ };
54
+ }
55
+ function parseCronNumber(raw, min, max) {
56
+ const value = Number(raw);
57
+ if (!Number.isInteger(value)) return null;
58
+ // Cron allows 0 and 7 as Sunday.
59
+ const normalized = max === 7 && value === 7 ? 0 : value;
60
+ if (normalized < min || normalized > max) return null;
61
+ return normalized;
62
+ }
@@ -1,7 +1,8 @@
1
1
  export { ScheduleModule } from './schedule.module';
2
2
  export { ScheduleRegistry } from './schedule.registry';
3
3
  export type { RegisteredCronJob, RegisteredIntervalJob } from './schedule.registry';
4
- export { ScheduleExecutor } from './schedule.executor';
5
4
  export { Cron, Interval } from './schedule.decorators';
6
- export { SCHEDULE_MODULE_OPTIONS, CRON_METADATA, INTERVAL_METADATA } from './schedule.tokens';
7
- export type { CronMetadata, IntervalMetadata, ScheduleModuleOptions } from './schedule.types';
5
+ export { CRON_METADATA, INTERVAL_METADATA } from './schedule.tokens';
6
+ export type { CronMetadata, IntervalMetadata } from './schedule.types';
7
+ export { parseCron } from './cron-matcher';
8
+ export type { CronMatcher } from './cron-matcher';
@@ -1,5 +1,5 @@
1
1
  export { ScheduleModule } from "./schedule.module.js";
2
2
  export { ScheduleRegistry } from "./schedule.registry.js";
3
- export { ScheduleExecutor } from "./schedule.executor.js";
4
3
  export { Cron, Interval } from "./schedule.decorators.js";
5
- export { SCHEDULE_MODULE_OPTIONS, CRON_METADATA, INTERVAL_METADATA } from "./schedule.tokens.js";
4
+ export { CRON_METADATA, INTERVAL_METADATA } from "./schedule.tokens.js";
5
+ export { parseCron } from "./cron-matcher.js";
@@ -1,8 +1,4 @@
1
- import type { AsyncModuleOptions, DynamicModule } from '../module/types';
2
- import type { ScheduleModuleOptions } from './schedule.types';
1
+ import type { DynamicModule } from '../module/types';
3
2
  export declare class ScheduleModule {
4
- static forRoot(options?: ScheduleModuleOptions): DynamicModule;
5
- static forRootAsync(options: AsyncModuleOptions<ScheduleModuleOptions> & {
6
- enableTimers?: boolean;
7
- }): DynamicModule;
3
+ static forRoot(): DynamicModule;
8
4
  }
@@ -1,53 +1,15 @@
1
- import { ScheduleExecutor } from "./schedule.executor.js";
2
1
  import { ScheduleRegistry } from "./schedule.registry.js";
3
- import { SCHEDULE_MODULE_OPTIONS } from "./schedule.tokens.js";
4
2
  export class ScheduleModule {
5
- static forRoot(options = {}) {
6
- const { enableTimers = false } = options;
3
+ static forRoot() {
7
4
  const providers = [
8
- {
9
- provide: SCHEDULE_MODULE_OPTIONS,
10
- useValue: options
11
- },
12
5
  ScheduleRegistry
13
6
  ];
14
- const exports = [
15
- SCHEDULE_MODULE_OPTIONS,
16
- ScheduleRegistry
17
- ];
18
- if (enableTimers) {
19
- providers.push(ScheduleExecutor);
20
- exports.push(ScheduleExecutor);
21
- }
22
- return {
23
- module: ScheduleModule,
24
- providers,
25
- exports
26
- };
27
- }
28
- static forRootAsync(options) {
29
- const { enableTimers = false } = options;
30
- const providers = [
31
- {
32
- provide: SCHEDULE_MODULE_OPTIONS,
33
- useFactory: options.useFactory,
34
- inject: options.inject ?? []
35
- },
36
- ScheduleRegistry
37
- ];
38
- const exports = [
39
- SCHEDULE_MODULE_OPTIONS,
40
- ScheduleRegistry
41
- ];
42
- if (enableTimers) {
43
- providers.push(ScheduleExecutor);
44
- exports.push(ScheduleExecutor);
45
- }
46
7
  return {
47
8
  module: ScheduleModule,
48
- imports: options.imports ?? [],
49
9
  providers,
50
- exports
10
+ exports: [
11
+ ScheduleRegistry
12
+ ]
51
13
  };
52
14
  }
53
15
  }
@@ -1,5 +1,2 @@
1
- import { InjectionToken } from '../container/types';
2
- import type { ScheduleModuleOptions } from './schedule.types';
3
- export declare const SCHEDULE_MODULE_OPTIONS: InjectionToken<ScheduleModuleOptions>;
4
1
  export declare const CRON_METADATA = "vela:cron";
5
2
  export declare const INTERVAL_METADATA = "vela:interval";
@@ -1,4 +1,2 @@
1
- import { InjectionToken } from "../container/types.js";
2
- export const SCHEDULE_MODULE_OPTIONS = new InjectionToken('SCHEDULE_MODULE_OPTIONS');
3
1
  export const CRON_METADATA = 'vela:cron';
4
2
  export const INTERVAL_METADATA = 'vela:interval';
@@ -6,6 +6,3 @@ export interface IntervalMetadata {
6
6
  ms: number;
7
7
  methodName: string;
8
8
  }
9
- export interface ScheduleModuleOptions {
10
- enableTimers?: boolean;
11
- }
@@ -0,0 +1,2 @@
1
+ export { ScheduleNodeModule } from './schedule-node.module';
2
+ export { ScheduleExecutor } from './schedule.executor';
@@ -0,0 +1,2 @@
1
+ export { ScheduleNodeModule } from "./schedule-node.module.js";
2
+ export { ScheduleExecutor } from "./schedule.executor.js";
@@ -0,0 +1,4 @@
1
+ import type { DynamicModule } from '../module/types';
2
+ export declare class ScheduleNodeModule {
3
+ static forRoot(): DynamicModule;
4
+ }
@@ -0,0 +1,18 @@
1
+ import { ScheduleRegistry } from "../schedule/schedule.registry.js";
2
+ import { ScheduleExecutor } from "./schedule.executor.js";
3
+ export class ScheduleNodeModule {
4
+ static forRoot() {
5
+ const providers = [
6
+ ScheduleRegistry,
7
+ ScheduleExecutor
8
+ ];
9
+ return {
10
+ module: ScheduleNodeModule,
11
+ providers,
12
+ exports: [
13
+ ScheduleRegistry,
14
+ ScheduleExecutor
15
+ ]
16
+ };
17
+ }
18
+ }
@@ -1,5 +1,5 @@
1
1
  import type { OnApplicationBootstrap, OnModuleDestroy } from '../lifecycle/index';
2
- import { ScheduleRegistry } from './schedule.registry';
2
+ import { ScheduleRegistry } from '../schedule/schedule.registry';
3
3
  export declare class ScheduleExecutor implements OnApplicationBootstrap, OnModuleDestroy {
4
4
  private registry;
5
5
  private intervalTimers;
@@ -12,9 +12,6 @@ export declare class ScheduleExecutor implements OnApplicationBootstrap, OnModul
12
12
  private scheduleInterval;
13
13
  private scheduleCron;
14
14
  private invoke;
15
- private getCronMatcher;
16
- private parseField;
17
- private parseRange;
18
- private parseCronNumber;
15
+ private getMatcher;
19
16
  onModuleDestroy(): void;
20
17
  }
@@ -0,0 +1,91 @@
1
+ function _ts_decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function _ts_metadata(k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ }
10
+ import { Injectable } from "../container/index.js";
11
+ import { parseCron } from "../schedule/cron-matcher.js";
12
+ import { ScheduleRegistry } from "../schedule/schedule.registry.js";
13
+ export class ScheduleExecutor {
14
+ registry;
15
+ intervalTimers = [];
16
+ cronTimers = [];
17
+ cronMatcherCache = new Map();
18
+ lastCronMinute = new Map();
19
+ running = true;
20
+ constructor(registry){
21
+ this.registry = registry;
22
+ }
23
+ onApplicationBootstrap() {
24
+ if (typeof setInterval !== 'function') {
25
+ throw new Error('@velajs/vela/schedule-node requires Node or Bun. Use a platform cron adapter on edge runtimes (e.g. CloudflareApplication.scheduled).');
26
+ }
27
+ for (const job of this.registry.getIntervalJobs()){
28
+ this.scheduleInterval(job.instance, job.methodName, job.ms);
29
+ }
30
+ const cronJobs = this.registry.getCronJobs();
31
+ for(let i = 0; i < cronJobs.length; i++){
32
+ const job = cronJobs[i];
33
+ this.scheduleCron(job.instance, job.methodName, job.expression, i);
34
+ }
35
+ }
36
+ scheduleInterval(instance, methodName, ms) {
37
+ if (!this.running) return;
38
+ const timer = setInterval(()=>{
39
+ void this.invoke(instance, methodName);
40
+ }, ms);
41
+ this.intervalTimers.push(timer);
42
+ }
43
+ scheduleCron(instance, methodName, expression, index) {
44
+ if (!this.running) return;
45
+ const matcher = this.getMatcher(expression);
46
+ if (!matcher) return;
47
+ const jobKey = `${index}:${methodName}:${expression}`;
48
+ const timer = setInterval(()=>{
49
+ const now = new Date();
50
+ const minuteKey = Math.floor(now.getTime() / 60_000);
51
+ if (this.lastCronMinute.get(jobKey) === minuteKey) return;
52
+ if (!matcher(now)) return;
53
+ this.lastCronMinute.set(jobKey, minuteKey);
54
+ void this.invoke(instance, methodName);
55
+ }, 1000);
56
+ this.cronTimers.push(timer);
57
+ }
58
+ async invoke(instance, methodName) {
59
+ try {
60
+ const method = instance[methodName];
61
+ if (typeof method === 'function') {
62
+ await method.call(instance);
63
+ }
64
+ } catch {
65
+ // Swallow errors so the scheduler keeps running
66
+ }
67
+ }
68
+ getMatcher(expression) {
69
+ if (this.cronMatcherCache.has(expression)) {
70
+ return this.cronMatcherCache.get(expression) ?? null;
71
+ }
72
+ const matcher = parseCron(expression);
73
+ this.cronMatcherCache.set(expression, matcher);
74
+ return matcher;
75
+ }
76
+ onModuleDestroy() {
77
+ this.running = false;
78
+ for (const timer of this.intervalTimers)clearInterval(timer);
79
+ for (const timer of this.cronTimers)clearInterval(timer);
80
+ this.intervalTimers = [];
81
+ this.cronTimers = [];
82
+ this.lastCronMinute.clear();
83
+ }
84
+ }
85
+ ScheduleExecutor = _ts_decorate([
86
+ Injectable(),
87
+ _ts_metadata("design:type", Function),
88
+ _ts_metadata("design:paramtypes", [
89
+ typeof ScheduleRegistry === "undefined" ? Object : ScheduleRegistry
90
+ ])
91
+ ], ScheduleExecutor);
@@ -1,11 +1,12 @@
1
- export declare enum LogLevel {
2
- VERBOSE = 0,
3
- DEBUG = 1,
4
- LOG = 2,
5
- WARN = 3,
6
- ERROR = 4,
7
- SILENT = 5
8
- }
1
+ export declare const LogLevel: {
2
+ readonly VERBOSE: 0;
3
+ readonly DEBUG: 1;
4
+ readonly LOG: 2;
5
+ readonly WARN: 3;
6
+ readonly ERROR: 4;
7
+ readonly SILENT: 5;
8
+ };
9
+ export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
9
10
  export interface LoggerService {
10
11
  log(message: unknown, ...optionalParams: unknown[]): void;
11
12
  error(message: unknown, ...optionalParams: unknown[]): void;
@@ -8,15 +8,14 @@ function _ts_metadata(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  }
10
10
  import { Injectable } from "../container/decorators.js";
11
- export var LogLevel = /*#__PURE__*/ function(LogLevel) {
12
- LogLevel[LogLevel["VERBOSE"] = 0] = "VERBOSE";
13
- LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
14
- LogLevel[LogLevel["LOG"] = 2] = "LOG";
15
- LogLevel[LogLevel["WARN"] = 3] = "WARN";
16
- LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
17
- LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
18
- return LogLevel;
19
- }({});
11
+ export const LogLevel = {
12
+ VERBOSE: 0,
13
+ DEBUG: 1,
14
+ LOG: 2,
15
+ WARN: 3,
16
+ ERROR: 4,
17
+ SILENT: 5
18
+ };
20
19
  const defaultWriter = (level, line, ...rest)=>{
21
20
  if (level === 'ERROR') return console.error(line, ...rest);
22
21
  if (level === 'WARN') return console.warn(line, ...rest);
@@ -35,7 +34,7 @@ function formatValue(v) {
35
34
  }
36
35
  }
37
36
  export class Logger {
38
- static level = 2;
37
+ static level = LogLevel.LOG;
39
38
  static globalLogger;
40
39
  static globalContextProviders = [];
41
40
  static globalWriter = defaultWriter;
@@ -90,19 +89,19 @@ export class Logger {
90
89
  return child;
91
90
  }
92
91
  log(message, ...optionalParams) {
93
- this.emit('LOG', 2, message, optionalParams);
92
+ this.emit('LOG', LogLevel.LOG, message, optionalParams);
94
93
  }
95
94
  error(message, ...optionalParams) {
96
- this.emit('ERROR', 4, message, optionalParams);
95
+ this.emit('ERROR', LogLevel.ERROR, message, optionalParams);
97
96
  }
98
97
  warn(message, ...optionalParams) {
99
- this.emit('WARN', 3, message, optionalParams);
98
+ this.emit('WARN', LogLevel.WARN, message, optionalParams);
100
99
  }
101
100
  debug(message, ...optionalParams) {
102
- this.emit('DEBUG', 1, message, optionalParams);
101
+ this.emit('DEBUG', LogLevel.DEBUG, message, optionalParams);
103
102
  }
104
103
  verbose(message, ...optionalParams) {
105
- this.emit('VERBOSE', 0, message, optionalParams);
104
+ this.emit('VERBOSE', LogLevel.VERBOSE, message, optionalParams);
106
105
  }
107
106
  emit(levelName, levelValue, message, rest) {
108
107
  if (Logger.level > levelValue) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velajs/vela",
3
- "version": "0.9.0",
3
+ "version": "1.0.0",
4
4
  "description": "NestJS-compatible framework for edge runtimes, powered by Hono",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,6 +13,10 @@
13
13
  "./streaming": {
14
14
  "types": "./dist/streaming/index.d.ts",
15
15
  "import": "./dist/streaming/index.js"
16
+ },
17
+ "./schedule-node": {
18
+ "types": "./dist/schedule-node/index.d.ts",
19
+ "import": "./dist/schedule-node/index.js"
16
20
  }
17
21
  },
18
22
  "files": [