raiton 6.6.0-beta.14 → 6.8.1-beta.17
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.
- package/CHANGELOG.md +30 -0
- package/README.md +16 -9
- package/build/bin/index.mjs +9150 -3911
- package/deno.json +4 -1
- package/docs/contributors/README.md +1 -0
- package/docs/contributors/core/README.md +8 -0
- package/docs/contributors/core/scheduler.md +113 -0
- package/docs/contributors/framework/README.md +2 -0
- package/docs/contributors/framework/cache/README.md +55 -0
- package/docs/contributors/framework/cache/cache.md +86 -0
- package/docs/contributors/framework/cache/etag.md +82 -0
- package/docs/contributors/framework/decorators/README.md +5 -0
- package/docs/contributors/framework/decorators/scheduler.md +83 -0
- package/docs/contributors/framework/runtime.md +13 -3
- package/docs/user-guide/README.md +9 -5
- package/docs/user-guide/cache.md +79 -0
- package/docs/user-guide/cli.md +35 -3
- package/docs/user-guide/decorators/README.md +3 -0
- package/docs/user-guide/decorators/cache.md +79 -0
- package/docs/user-guide/decorators/mcp.md +2 -2
- package/docs/user-guide/decorators/scheduler.md +75 -0
- package/docs/user-guide/mcp.md +2 -2
- package/docs/user-guide/runtime.md +2 -1
- package/docs/user-guide/scheduler.md +229 -0
- package/package.json +9 -4
- package/source/bin/bootstrapper.ts +4 -4
- package/source/bin/cli-tools.ts +27 -3
- package/source/bin/cli.ts +2 -2
- package/source/bin/commands.registry.ts +17 -0
- package/source/bin/constants.ts +1 -0
- package/source/bin/index.ts +2 -2
- package/source/commands/artifact.command.ts +2 -2
- package/source/commands/build.command.ts +2 -2
- package/source/commands/develop.command.ts +4 -5
- package/source/commands/grafts.command.ts +1 -1
- package/source/commands/start.command.ts +2 -2
- package/source/core/application.ts +10 -10
- package/source/core/artifacts/artifact.ts +1 -1
- package/source/core/artifacts/index.ts +1 -1
- package/source/core/builder.ts +81 -15
- package/source/core/bytes.util.ts +1 -1
- package/source/core/commands.ts +24 -14
- package/source/core/config/config.ts +2 -2
- package/source/core/config/define.ts +2 -2
- package/source/core/config/index.ts +2 -2
- package/source/core/context.ts +1 -1
- package/source/core/controller/builder.ts +16 -10
- package/source/core/controller/compiler.ts +6 -6
- package/source/core/controller/index.ts +4 -4
- package/source/core/controller/metadata.ts +2 -2
- package/source/core/controller/tracker.ts +1 -1
- package/source/core/directories.ts +3 -2
- package/source/core/guards.ts +1 -1
- package/source/core/helpers/index.ts +1 -1
- package/source/core/hooks.ts +1 -1
- package/source/core/index.ts +17 -16
- package/source/core/injection/index.ts +1 -1
- package/source/core/injection/injection.ts +7 -4
- package/source/core/mcp/builder.ts +8 -8
- package/source/core/mcp/index.ts +3 -3
- package/source/core/mcp/metadata.ts +2 -2
- package/source/core/mcp/tracker.ts +1 -1
- package/source/core/middleware/compose.ts +2 -2
- package/source/core/middleware/index.ts +2 -2
- package/source/core/middleware/pipeline.ts +2 -2
- package/source/core/plugins/index.ts +2 -2
- package/source/core/plugins/plugin.ts +1 -1
- package/source/core/plugins/scope.ts +4 -4
- package/source/core/raiton.ts +1 -1
- package/source/core/router/handler.ts +30 -6
- package/source/core/router/handler.utils.ts +3 -3
- package/source/core/router/index.ts +4 -4
- package/source/core/router/matcher.ts +1 -1
- package/source/core/router/route.ts +1 -1
- package/source/core/router/router.ts +4 -4
- package/source/core/scheduler/builder.ts +25 -0
- package/source/core/scheduler/cron.ts +400 -0
- package/source/core/scheduler/duration.ts +42 -0
- package/source/core/scheduler/index.ts +6 -0
- package/source/core/scheduler/manager.ts +542 -0
- package/source/core/scheduler/metadata.ts +53 -0
- package/source/core/scheduler/queue/backend.ts +142 -0
- package/source/core/scheduler/queue/index.ts +3 -0
- package/source/core/scheduler/queue/rabbitmq.backend.ts +124 -0
- package/source/core/scheduler/queue/redis.backend.ts +144 -0
- package/source/core/server.ts +1 -1
- package/source/core/socket/builder.ts +2 -2
- package/source/core/socket/index.ts +2 -2
- package/source/core/socket/metadata.ts +2 -2
- package/source/core/thread.ts +55 -22
- package/source/framework/artifacts.ts +32 -5
- package/source/framework/cache/cache.decorator.ts +35 -0
- package/source/framework/cache/cache.ts +197 -0
- package/source/framework/cache/etag.ts +174 -0
- package/source/framework/cache/index.ts +4 -0
- package/source/framework/cache/types.ts +111 -0
- package/source/framework/constants/decorators.constant.ts +4 -0
- package/source/framework/constants/index.ts +2 -2
- package/source/framework/decorators/access-guard.decorator.ts +2 -2
- package/source/framework/decorators/api-response.decorator.ts +1 -1
- package/source/framework/decorators/api.decorator.ts +1 -1
- package/source/framework/decorators/controllable.decorator.ts +3 -3
- package/source/framework/decorators/csrf-guard.decorator.ts +4 -4
- package/source/framework/decorators/csrf-token.decorator.ts +1 -1
- package/source/framework/decorators/guard.decorator.ts +4 -4
- package/source/framework/decorators/health-check.decorator.ts +3 -3
- package/source/framework/decorators/index.ts +15 -14
- package/source/framework/decorators/injection.decorator.ts +3 -3
- package/source/framework/decorators/mcp.decorator.ts +4 -4
- package/source/framework/decorators/middleware.decorator.ts +2 -2
- package/source/framework/decorators/parametrable.decorator.ts +2 -2
- package/source/framework/decorators/routable.decorator.ts +3 -3
- package/source/framework/decorators/route-interaction.decorator.ts +4 -4
- package/source/framework/decorators/scheduler.decorator.ts +139 -0
- package/source/framework/decorators/socket.decorator.ts +3 -3
- package/source/framework/encryption.ts +2 -2
- package/source/framework/enums/index.ts +9 -8
- package/source/framework/enums/runtime.enum.ts +1 -2
- package/source/framework/enums/scheduler.enum.ts +23 -0
- package/source/framework/env.ts +2 -2
- package/source/framework/exceptions/http-exception.ts +3 -3
- package/source/framework/exceptions/index.ts +2 -2
- package/source/framework/health-check.ts +4 -4
- package/source/framework/index.ts +18 -17
- package/source/framework/mcp/handler.ts +3 -3
- package/source/framework/mcp/index.ts +3 -3
- package/source/framework/mcp/protocol.ts +1 -1
- package/source/framework/mcp/streamable-http.ts +3 -3
- package/source/framework/parameter-bag.ts +2 -2
- package/source/framework/plugins/body-parser.plugin.ts +3 -3
- package/source/framework/plugins/index.ts +4 -4
- package/source/framework/plugins/mcp.plugin.ts +5 -5
- package/source/framework/plugins/openapi.plugin.ts +4 -4
- package/source/framework/plugins/security/body-limit.ts +3 -3
- package/source/framework/plugins/security/cors.ts +2 -2
- package/source/framework/plugins/security/csrf.ts +6 -6
- package/source/framework/plugins/security/headers.ts +2 -2
- package/source/framework/plugins/security/index.ts +6 -6
- package/source/framework/plugins/security/method-guard.ts +3 -3
- package/source/framework/plugins/security/rate-limit.ts +3 -3
- package/source/framework/repositories.ts +1 -1
- package/source/framework/responses/error.ts +2 -2
- package/source/framework/responses/helpers.ts +3 -3
- package/source/framework/responses/http-throwable.ts +3 -3
- package/source/framework/responses/http.ts +3 -3
- package/source/framework/responses/index.ts +4 -4
- package/source/framework/runtime/bun/server.ts +5 -5
- package/source/framework/runtime/deno/server.ts +156 -96
- package/source/framework/runtime/index.ts +11 -17
- package/source/framework/runtime/node/reply.ts +1 -1
- package/source/framework/runtime/node/request.ts +2 -2
- package/source/framework/runtime/node/server.ts +3 -3
- package/source/framework/runtime/web/server.ts +2 -2
- package/source/framework/services.ts +1 -1
- package/source/framework/utilities/artifact.util.ts +4 -0
- package/source/framework/utilities/csrf.util.ts +1 -1
- package/source/framework/utilities/index.ts +10 -10
- package/source/framework/utilities/openapi.utils.ts +7 -7
- package/source/framework/utilities/utilities.util.ts +1 -1
- package/source/types/application.ts +2 -2
- package/source/types/builder.ts +1 -1
- package/source/types/config.ts +1 -1
- package/source/types/controller.ts +3 -3
- package/source/types/core.ts +1 -1
- package/source/types/csrf.ts +1 -1
- package/source/types/guard.ts +1 -1
- package/source/types/http-responses.ts +1 -1
- package/source/types/index.ts +27 -26
- package/source/types/injection.ts +1 -1
- package/source/types/middleware.ts +1 -1
- package/source/types/plugin.ts +1 -1
- package/source/types/raiton.ts +2 -1
- package/source/types/responses.ts +2 -2
- package/source/types/router.ts +2 -2
- package/source/types/runtime.ts +3 -5
- package/source/types/scheduler.ts +180 -0
- package/source/types/thread.ts +4 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type {ConstructorType} from "./contruct.ts";
|
|
2
|
+
|
|
3
|
+
export type TaskTriggerType = 'cron' | 'interval' | 'timeout' | 'task';
|
|
4
|
+
|
|
5
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'timed-out';
|
|
6
|
+
|
|
7
|
+
export type TaskPriority = 'lowest' | 'low' | 'normal' | 'high' | 'highest';
|
|
8
|
+
|
|
9
|
+
export type ScheduleInterval = number | string;
|
|
10
|
+
|
|
11
|
+
export type TaskRetryDelay = number | ((attempt: number) => number);
|
|
12
|
+
|
|
13
|
+
export interface TaskOptionsInterface {
|
|
14
|
+
name?: string;
|
|
15
|
+
queue?: string;
|
|
16
|
+
timezone?: string;
|
|
17
|
+
singleton?: boolean;
|
|
18
|
+
concurrency?: number;
|
|
19
|
+
retries?: number;
|
|
20
|
+
retryDelay?: TaskRetryDelay;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
catchUp?: boolean;
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
consume?: boolean;
|
|
25
|
+
immediate?: boolean;
|
|
26
|
+
priority?: TaskPriority;
|
|
27
|
+
data?: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CronOptionsInterface extends TaskOptionsInterface {
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IntervalOptionsInterface extends TaskOptionsInterface {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TimeoutOptionsInterface extends TaskOptionsInterface {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TaskDeclarationInterface extends TaskOptionsInterface {
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface JobMetaInterface {
|
|
43
|
+
propertyKey: string;
|
|
44
|
+
name: string;
|
|
45
|
+
type: TaskTriggerType;
|
|
46
|
+
cron?: string;
|
|
47
|
+
interval?: number;
|
|
48
|
+
delay?: number;
|
|
49
|
+
queue?: string;
|
|
50
|
+
options: TaskOptionsInterface;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SchedulerMetaInterface {
|
|
54
|
+
name: string;
|
|
55
|
+
queue: string;
|
|
56
|
+
timezone?: string;
|
|
57
|
+
jobs: JobMetaInterface[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface SchedulerOptionsInterface {
|
|
61
|
+
name?: string;
|
|
62
|
+
queue?: string;
|
|
63
|
+
timezone?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface SchedulerRegistrationInterface {
|
|
67
|
+
name: string;
|
|
68
|
+
queue: string;
|
|
69
|
+
construct: ConstructorType;
|
|
70
|
+
metadata: SchedulerMetaInterface;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface TaskContextInterface<T = any> {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
queue?: string;
|
|
77
|
+
payload?: T;
|
|
78
|
+
data?: any;
|
|
79
|
+
trigger: TaskTriggerType;
|
|
80
|
+
attempt: number;
|
|
81
|
+
scheduledAt: Date;
|
|
82
|
+
startedAt: Date;
|
|
83
|
+
scheduler: SchedulerControlInterface;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface TaskInvocationInterface {
|
|
87
|
+
id: string;
|
|
88
|
+
name: string;
|
|
89
|
+
queue?: string;
|
|
90
|
+
payload?: any;
|
|
91
|
+
data?: any;
|
|
92
|
+
trigger: TaskTriggerType;
|
|
93
|
+
attempt: number;
|
|
94
|
+
priority?: TaskPriority;
|
|
95
|
+
delay?: number;
|
|
96
|
+
scheduledAt: Date;
|
|
97
|
+
scheduleAt?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface QueueMessageInterface<T = any> {
|
|
101
|
+
id: string;
|
|
102
|
+
queue: string;
|
|
103
|
+
payload: T;
|
|
104
|
+
attempts: number;
|
|
105
|
+
enqueuedAt: number;
|
|
106
|
+
availableAt: number;
|
|
107
|
+
receipt?: any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface QueueDequeueOptionsInterface {
|
|
111
|
+
blockMs?: number;
|
|
112
|
+
count?: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface QueueBackendInterface {
|
|
116
|
+
readonly name: string;
|
|
117
|
+
|
|
118
|
+
connect(): Promise<void>;
|
|
119
|
+
|
|
120
|
+
disconnect(): Promise<void>;
|
|
121
|
+
|
|
122
|
+
enqueue(queue: string, message: QueueMessageInterface): Promise<string>;
|
|
123
|
+
|
|
124
|
+
dequeue(queue: string, options?: QueueDequeueOptionsInterface): Promise<QueueMessageInterface[]>;
|
|
125
|
+
|
|
126
|
+
acknowledge(queue: string, receipt: any): Promise<void>;
|
|
127
|
+
|
|
128
|
+
reject(queue: string, receipt: any, requeue?: boolean): Promise<void>;
|
|
129
|
+
|
|
130
|
+
length(queue: string): Promise<number>;
|
|
131
|
+
|
|
132
|
+
purge(queue: string): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface SchedulerConfigInterface {
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
timezone: string;
|
|
138
|
+
maxConcurrentJobs: number;
|
|
139
|
+
defaultQueue: string;
|
|
140
|
+
backend?: QueueBackendInterface;
|
|
141
|
+
backends?: Record<string, QueueBackendInterface>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ScheduledJobInfoInterface {
|
|
145
|
+
name: string;
|
|
146
|
+
type: TaskTriggerType;
|
|
147
|
+
queue: string;
|
|
148
|
+
nextRun?: Date;
|
|
149
|
+
lastRun?: Date;
|
|
150
|
+
lastError?: any;
|
|
151
|
+
running: number;
|
|
152
|
+
runCount: number;
|
|
153
|
+
failCount: number;
|
|
154
|
+
paused: boolean;
|
|
155
|
+
enabled: boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface SchedulerControlInterface {
|
|
159
|
+
enqueue(name: string, payload?: any, options?: Partial<TaskInvocationInterface>): Promise<TaskInvocationInterface>;
|
|
160
|
+
|
|
161
|
+
dispatch(name: string, payload?: any, options?: Partial<TaskInvocationInterface>): Promise<any>;
|
|
162
|
+
|
|
163
|
+
trigger(name: string, payload?: any, options?: Partial<TaskInvocationInterface>): Promise<any>;
|
|
164
|
+
|
|
165
|
+
pause(name: string): void;
|
|
166
|
+
|
|
167
|
+
resume(name: string): void;
|
|
168
|
+
|
|
169
|
+
cancel(name: string): boolean;
|
|
170
|
+
|
|
171
|
+
getJobs(): ScheduledJobInfoInterface[];
|
|
172
|
+
|
|
173
|
+
getJob(name: string): ScheduledJobInfoInterface | undefined;
|
|
174
|
+
|
|
175
|
+
has(name: string): boolean;
|
|
176
|
+
|
|
177
|
+
start(): Promise<void>;
|
|
178
|
+
|
|
179
|
+
stop(): Promise<void>;
|
|
180
|
+
}
|
package/source/types/thread.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {BuilderInterface} from "./builder";
|
|
2
|
-
import {RuntimeAdapterInterface, RuntimeServerInterface} from "./runtime";
|
|
3
|
-
import {ApplicationInterface} from "./application";
|
|
4
|
-
import {RuntimeType} from "../framework/enums/runtime.enum";
|
|
1
|
+
import {BuilderInterface} from "./builder.ts";
|
|
2
|
+
import {RuntimeAdapterInterface, RuntimeServerInterface} from "./runtime.ts";
|
|
3
|
+
import {ApplicationInterface} from "./application.ts";
|
|
4
|
+
import {RuntimeType} from "../framework/enums/runtime.enum.ts";
|
|
5
5
|
|
|
6
6
|
export interface ThreadSetupOptionsInterface {
|
|
7
7
|
application: ApplicationInterface;
|