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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {RaitonCommand, RaitonBuilder} from "../core";
|
|
1
|
+
import {RaitonCommand, RaitonBuilder} from "../core/index.ts";
|
|
2
2
|
import {Logger} from "@protorians/logger";
|
|
3
|
-
import type {BuildCommandOptionsInterface} from "../types";
|
|
3
|
+
import type {BuildCommandOptionsInterface} from "../types/index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export default class ArtifactCommand extends RaitonCommand {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {RaitonCommand, RaitonBuilder} from "../core";
|
|
1
|
+
import {RaitonCommand, RaitonBuilder} from "../core/index.ts";
|
|
2
2
|
import {LBadge, Logger} from "@protorians/logger";
|
|
3
|
-
import type {BuildCommandOptionsInterface} from "../types";
|
|
3
|
+
import type {BuildCommandOptionsInterface} from "../types/index.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export default class BuildCommand extends RaitonCommand {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="deno" />
|
|
2
|
-
import {Raiton, RaitonCommand} from "../core";
|
|
2
|
+
import {Raiton, RaitonCommand} from "../core/index.ts";
|
|
3
3
|
import {ChildProcess, ChildProcessWithoutNullStreams} from 'node:child_process';
|
|
4
4
|
import {Logger} from "@protorians/logger";
|
|
5
|
-
import {EventMessageEnum} from "../framework";
|
|
6
|
-
import {CliTools} from "../bin/cli-tools";
|
|
7
|
-
import path from "node:path";
|
|
5
|
+
import {EventMessageEnum} from "../framework/index.ts";
|
|
6
|
+
import {CliTools} from "../bin/cli-tools.ts";
|
|
8
7
|
|
|
9
8
|
export default class DevelopCommand extends RaitonCommand {
|
|
10
9
|
public readonly name: string = 'develop';
|
|
@@ -32,7 +31,7 @@ export default class DevelopCommand extends RaitonCommand {
|
|
|
32
31
|
protected async run(): Promise<void> {
|
|
33
32
|
// Logger.info('Workdir', this.workdir);
|
|
34
33
|
|
|
35
|
-
const entryPoint =
|
|
34
|
+
const entryPoint = CliTools.cliEntry(this.appdir);
|
|
36
35
|
this.child = CliTools.spawn(entryPoint, ['build', '-d'], {
|
|
37
36
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
38
37
|
cwd: this.workdir
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="deno" />
|
|
2
|
-
import {RaitonBuilder, RaitonCommand} from "../core";
|
|
2
|
+
import {RaitonBuilder, RaitonCommand} from "../core/index.ts";
|
|
3
3
|
import {ChildProcess} from 'node:child_process';
|
|
4
4
|
import {LBadge, Logger} from "@protorians/logger";
|
|
5
|
-
import {StartCommandOptionsInterface} from "../types";
|
|
5
|
+
import {StartCommandOptionsInterface} from "../types/index.ts";
|
|
6
6
|
|
|
7
7
|
export default class StartCommand extends RaitonCommand {
|
|
8
8
|
public readonly name: string = 'start';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {Security, bodyParserPlugin} from "../framework/plugins";
|
|
2
|
-
import {PluginScope} from './plugins/scope'
|
|
3
|
-
import {RequestContext} from './context'
|
|
4
|
-
import {ApplicationConfigInterface, ApplicationInterface} from "../types/application";
|
|
5
|
-
import {HttpException, HttpMethod, ThrowableResponse, RaitonResponses, HttpStatus} from "../framework";
|
|
6
|
-
import {RouteHandlerCallable} from "../types";
|
|
1
|
+
import {Security, bodyParserPlugin} from "../framework/plugins/index.ts";
|
|
2
|
+
import {PluginScope} from './plugins/scope.ts'
|
|
3
|
+
import {RequestContext} from './context.ts'
|
|
4
|
+
import {ApplicationConfigInterface, ApplicationInterface} from "../types/application.ts";
|
|
5
|
+
import {HttpException, HttpMethod, ThrowableResponse, RaitonResponses, HttpStatus} from "../framework/index.ts";
|
|
6
|
+
import {RouteHandlerCallable} from "../types/index.ts";
|
|
7
7
|
import {Logger} from "@protorians/logger";
|
|
8
|
-
import {RaitonConfig} from "./config";
|
|
9
|
-
import {Artifacts} from "../framework/artifacts";
|
|
10
|
-
import {Injection} from "./injection";
|
|
11
|
-
import {HttpsConfigInterface, resolveHttpsConfig} from "../framework/utilities/https.util";
|
|
8
|
+
import {RaitonConfig} from "./config/index.ts";
|
|
9
|
+
import {Artifacts} from "../framework/artifacts.ts";
|
|
10
|
+
import {Injection} from "./injection/index.ts";
|
|
11
|
+
import {HttpsConfigInterface, resolveHttpsConfig} from "../framework/utilities/https.util.ts";
|
|
12
12
|
|
|
13
13
|
export class Application implements ApplicationInterface {
|
|
14
14
|
private root: PluginScope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./artifact";
|
|
1
|
+
export * from "./artifact.ts";
|
package/source/core/builder.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {RaitonConfig} from "./config";
|
|
1
|
+
import {RaitonConfig} from "./config/index.ts";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {RaitonDirectories} from "./directories";
|
|
3
|
+
import {RaitonDirectories} from "./directories.ts";
|
|
4
4
|
import fs, {WatchEventType} from "node:fs";
|
|
5
|
-
import type {BuilderConfigInterface, BuilderInterface, ThreadInterface,} from "../types";
|
|
6
|
-
import {RaitonThread} from "./thread";
|
|
7
|
-
import {Raiton} from "./raiton";
|
|
8
|
-
import {ControllerBuilder} from "./controller";
|
|
5
|
+
import type {BuilderConfigInterface, BuilderInterface, ThreadInterface,} from "../types/index.ts";
|
|
6
|
+
import {RaitonThread} from "./thread.ts";
|
|
7
|
+
import {Raiton} from "./raiton.ts";
|
|
8
|
+
import {ControllerBuilder} from "./controller/index.ts";
|
|
9
9
|
import {watch} from "fs";
|
|
10
10
|
import {LBadge, Logger} from "@protorians/logger";
|
|
11
|
-
import {Throwable} from "../framework/exceptions";
|
|
12
|
-
import {Artifacts, HMR_CHANNELS, HmrChannel} from "../framework/artifacts";
|
|
11
|
+
import {Throwable} from "../framework/exceptions/index.ts";
|
|
12
|
+
import {Artifacts, HMR_CHANNELS, HmrChannel} from "../framework/artifacts.ts";
|
|
13
13
|
import {build} from "esbuild";
|
|
14
14
|
import {execSync, spawn, spawnSync} from "node:child_process";
|
|
15
|
+
import {isNodeUsed} from "../bin/constants.ts";
|
|
15
16
|
|
|
16
17
|
export class RaitonBuilder implements BuilderInterface {
|
|
17
18
|
protected _source: string | null = null;
|
|
@@ -55,6 +56,14 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
55
56
|
const classification = Artifacts.classify(filename)
|
|
56
57
|
if (!classification) return
|
|
57
58
|
|
|
59
|
+
// Sur Node, le rechargement d'artefacts TypeScript en mémoire n'est pas
|
|
60
|
+
// possible (import() natif des fichiers .ts). On bascule alors sur le
|
|
61
|
+
// redémarrage de processus via IPC RESTART géré par la commande `develop`.
|
|
62
|
+
if (isNodeUsed) {
|
|
63
|
+
Raiton.thread?.restart()
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
const payload = {
|
|
59
68
|
filename,
|
|
60
69
|
timestamp: Date.now(),
|
|
@@ -102,7 +111,7 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
102
111
|
|
|
103
112
|
|
|
104
113
|
this._bootstrapper = path.join(this._source, RaitonDirectories.bootstrapFile)
|
|
105
|
-
this._bootstrapperFile = path.join(RaitonDirectories.server(
|
|
114
|
+
this._bootstrapperFile = path.join(RaitonDirectories.server(this.workdir), RaitonDirectories.compiledBootstrapFile)
|
|
106
115
|
|
|
107
116
|
return this;
|
|
108
117
|
|
|
@@ -118,6 +127,7 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
118
127
|
this.listenHmrMiddleware()
|
|
119
128
|
this.listenHmrHook()
|
|
120
129
|
this.listenHmrMcp()
|
|
130
|
+
this.listenHmrScheduler()
|
|
121
131
|
this.watching();
|
|
122
132
|
}
|
|
123
133
|
|
|
@@ -190,6 +200,17 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
190
200
|
)
|
|
191
201
|
}
|
|
192
202
|
|
|
203
|
+
protected listenHmrScheduler(): void {
|
|
204
|
+
Raiton.signals.listen(
|
|
205
|
+
'hmr:scheduler',
|
|
206
|
+
async ({filename, version, timestamp}) => {
|
|
207
|
+
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
|
|
208
|
+
Artifacts.reloadScheduler(imported, filename)
|
|
209
|
+
Logger.log(LBadge.debug('HMR'), `[scheduler] ${path.relative(this.workdir, filename)}`)
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
193
214
|
protected async build(thread: ThreadInterface): Promise<this> {
|
|
194
215
|
if (!this._source) throw new Error('Application source not found');
|
|
195
216
|
if (!this._out) throw new Error('Application output not found');
|
|
@@ -198,24 +219,69 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
198
219
|
|
|
199
220
|
const source = path.relative(this.workdir, this._source)
|
|
200
221
|
const output = path.relative(this.workdir, this._out)
|
|
201
|
-
const tsconfig = 'tsconfig.json'
|
|
202
|
-
// const tsconfig = path.join(path.relative(this._source, this.workdir), 'tsconfig.json')
|
|
203
222
|
|
|
204
223
|
Logger.log(LBadge.notice('Building'), 'application');
|
|
205
224
|
Logger.log(LBadge.info('Source'), source);
|
|
206
225
|
Logger.log(LBadge.info('Output'), output);
|
|
207
226
|
|
|
208
|
-
|
|
227
|
+
await this.typecheck()
|
|
228
|
+
await this.compile()
|
|
229
|
+
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
protected async typecheck(): Promise<this> {
|
|
234
|
+
const tsconfigPath = path.join(this.workdir, 'tsconfig.json')
|
|
235
|
+
if (!fs.existsSync(tsconfigPath)) return this
|
|
236
|
+
|
|
237
|
+
try {
|
|
238
|
+
execSync(`cd ${this.workdir} && npx tsc -p tsconfig.json --noEmit`, {stdio: 'inherit'})
|
|
239
|
+
} catch (e: any) {
|
|
240
|
+
Logger.warn('TypeScript check reported errors', e?.message ?? e)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
protected async compile(): Promise<this> {
|
|
247
|
+
if (!this._source) throw new Error('Application source not found');
|
|
248
|
+
if (!this._out) throw new Error('Application output not found');
|
|
249
|
+
if (!this.bootstrapper) throw new Error('Bootstrapper not found')
|
|
250
|
+
|
|
251
|
+
const outfile = this.bootstrapperFile
|
|
252
|
+
if (!outfile) throw new Error('Bootstrapper file not found')
|
|
253
|
+
|
|
254
|
+
await build({
|
|
255
|
+
entryPoints: [this.bootstrapper],
|
|
256
|
+
bundle: true,
|
|
257
|
+
platform: 'node',
|
|
258
|
+
format: 'esm',
|
|
259
|
+
target: 'node20',
|
|
260
|
+
outfile,
|
|
261
|
+
sourcemap: true,
|
|
262
|
+
packages: 'external',
|
|
263
|
+
external: ['@protorians/*', 'argon2', 'bcrypt'],
|
|
264
|
+
})
|
|
209
265
|
|
|
210
266
|
return this;
|
|
211
267
|
}
|
|
212
268
|
|
|
213
269
|
public async boot(): Promise<any> {
|
|
214
270
|
if (!this.bootstrapper) throw new Error('Bootstrapper not found')
|
|
215
|
-
if (!fs.existsSync(this.bootstrapper))
|
|
216
|
-
throw new Error(`Bootstrapper file "${this.bootstrapper}" does not exists`)
|
|
217
271
|
|
|
218
|
-
|
|
272
|
+
let entry = this.bootstrapper
|
|
273
|
+
|
|
274
|
+
if (isNodeUsed) {
|
|
275
|
+
const compiled = this.bootstrapperFile
|
|
276
|
+
if (!compiled) throw new Error('Bootstrapper file not found')
|
|
277
|
+
if (!fs.existsSync(compiled)) await this.compile()
|
|
278
|
+
entry = compiled
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (!fs.existsSync(entry))
|
|
282
|
+
throw new Error(`Bootstrapper file "${entry}" does not exists`)
|
|
283
|
+
|
|
284
|
+
const bootstrapper = await import(entry);
|
|
219
285
|
if (!('default' in bootstrapper))
|
|
220
286
|
throw new Error('Bootstrapper not supported! Please export to "default"')
|
|
221
287
|
|
package/source/core/commands.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Command} from "commander";
|
|
2
|
-
import {RaitonCommand} from "./command";
|
|
2
|
+
import {RaitonCommand} from "./command.ts";
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import {Logger} from "@protorians/logger";
|
|
@@ -17,28 +17,38 @@ export class RaitonCommands {
|
|
|
17
17
|
|
|
18
18
|
public async harvest(): Promise<void> {
|
|
19
19
|
const dir = path.join(this.appdir, 'commands');
|
|
20
|
-
|
|
21
|
-
if (!fs.existsSync(dir)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
if (fs.existsSync(dir)) {
|
|
22
|
+
const files = fs.readdirSync(dir);
|
|
23
|
+
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
if (file.startsWith('~')) continue;
|
|
26
|
+
if (file.endsWith('.d.ts')) continue;
|
|
27
|
+
if (!file.includes('.command.')) continue;
|
|
28
|
+
|
|
29
|
+
const filepath = path.join(dir, file);
|
|
30
|
+
const mod = await import(filepath);
|
|
31
|
+
|
|
32
|
+
const capability = new mod.default(this.cli, this.workdir, this.appdir)
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
if (file.startsWith('~')) continue;
|
|
29
|
-
if (file.endsWith('.d.ts')) continue;
|
|
30
|
-
if (!file.includes('.command.')) continue;
|
|
34
|
+
if (!(capability instanceof RaitonCommand)) continue;
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
capability.register();
|
|
37
|
+
this.stack.add(capability);
|
|
38
|
+
}
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const {RaitonCommandsRegistry} = await import("../bin/commands.registry.ts");
|
|
44
|
+
|
|
45
|
+
for (const constructor of RaitonCommandsRegistry) {
|
|
46
|
+
const capability = new constructor(this.cli, this.workdir, this.appdir)
|
|
36
47
|
|
|
37
48
|
if (!(capability instanceof RaitonCommand)) continue;
|
|
38
49
|
|
|
39
50
|
capability.register();
|
|
40
51
|
this.stack.add(capability);
|
|
41
52
|
}
|
|
42
|
-
|
|
43
53
|
}
|
|
44
54
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import {ConfigurableInterface} from "../../types";
|
|
3
|
+
import {ConfigurableInterface} from "../../types/index.ts";
|
|
4
4
|
import {Logger} from "@protorians/logger";
|
|
5
|
-
import {Raiton} from "../raiton";
|
|
5
|
+
import {Raiton} from "../raiton.ts";
|
|
6
6
|
|
|
7
7
|
export class RaitonConfig {
|
|
8
8
|
static readonly current: Map<keyof ConfigurableInterface, ConfigurableInterface[keyof ConfigurableInterface]> = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ConfigurableInterface} from "../../types/config";
|
|
2
|
-
import {JsonUtil} from "../../framework/utilities";
|
|
1
|
+
import {ConfigurableInterface} from "../../types/config.ts";
|
|
2
|
+
import {JsonUtil} from "../../framework/utilities/index.ts";
|
|
3
3
|
|
|
4
4
|
export async function defineConfig(config?: ConfigurableInterface) {
|
|
5
5
|
const workdir = process.cwd();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./config"
|
|
2
|
-
export * from "./define"
|
|
1
|
+
export * from "./config.ts"
|
|
2
|
+
export * from "./define.ts"
|
package/source/core/context.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import {BuilderHMRDeclarationInterface} from "../../types";
|
|
2
|
+
import {BuilderHMRDeclarationInterface} from "../../types/index.ts";
|
|
3
3
|
import {LBadge, Logger} from "@protorians/logger";
|
|
4
|
-
import {compileController} from "./compiler";
|
|
5
|
-
import {compileSocket} from "../socket/builder";
|
|
6
|
-
import {compileMcp} from "../mcp/builder";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
4
|
+
import {compileController} from "./compiler.ts";
|
|
5
|
+
import {compileSocket} from "../socket/builder.ts";
|
|
6
|
+
import {compileMcp} from "../mcp/builder.ts";
|
|
7
|
+
import {compileScheduler} from "../scheduler/builder.ts";
|
|
8
|
+
import {RaitonThread} from "../thread.ts";
|
|
9
|
+
import {Injection} from "../injection/index.ts";
|
|
10
|
+
import {isControllerArtifact, isSocketArtifact, isMcpArtifact, isSchedulerArtifact} from "../../framework/index.ts";
|
|
11
|
+
import {Artifacts} from "../../framework/artifacts.ts";
|
|
11
12
|
import path from "node:path";
|
|
12
|
-
import {ControllerRouteTracker} from "./tracker";
|
|
13
|
+
import {ControllerRouteTracker} from "./tracker.ts";
|
|
13
14
|
|
|
14
15
|
export class ControllerBuilder {
|
|
15
16
|
|
|
@@ -51,8 +52,9 @@ export class ControllerBuilder {
|
|
|
51
52
|
const isController = isControllerArtifact(filename);
|
|
52
53
|
const isSocket = isSocketArtifact(filename);
|
|
53
54
|
const isMcp = isMcpArtifact(filename);
|
|
55
|
+
const isScheduler = isSchedulerArtifact(filename);
|
|
54
56
|
|
|
55
|
-
if (!isController && !isSocket && !isMcp)
|
|
57
|
+
if (!isController && !isSocket && !isMcp && !isScheduler)
|
|
56
58
|
return undefined;
|
|
57
59
|
|
|
58
60
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
|
|
@@ -72,6 +74,10 @@ export class ControllerBuilder {
|
|
|
72
74
|
return compileMcp(artifact) as any;
|
|
73
75
|
}
|
|
74
76
|
|
|
77
|
+
if (isScheduler) {
|
|
78
|
+
return compileScheduler(artifact) as any;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
const compilated = compileController(artifact, RaitonThread.current.application);
|
|
76
82
|
return compilated;
|
|
77
83
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {ApplicationInterface} from "../../types/application";
|
|
2
|
-
import {getControllerMetadata} from "
|
|
3
|
-
import {createHandler} from "../router";
|
|
4
|
-
import {Injection} from "../injection";
|
|
5
|
-
import {ControllerMetaInterface} from "../../types";
|
|
6
|
-
import {ControllerRouteTracker} from "./tracker";
|
|
1
|
+
import {ApplicationInterface} from "../../types/application.ts";
|
|
2
|
+
import {getControllerMetadata} from "../index.ts";
|
|
3
|
+
import {createHandler} from "../router/index.ts";
|
|
4
|
+
import {Injection} from "../injection/index.ts";
|
|
5
|
+
import {ControllerMetaInterface} from "../../types/index.ts";
|
|
6
|
+
import {ControllerRouteTracker} from "./tracker.ts";
|
|
7
7
|
|
|
8
8
|
export function compileController(
|
|
9
9
|
ControllerClass: any,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./metadata"
|
|
2
|
-
export * from "./compiler"
|
|
3
|
-
export * from "./builder"
|
|
4
|
-
export * from "./tracker"
|
|
1
|
+
export * from "./metadata.ts"
|
|
2
|
+
export * from "./compiler.ts"
|
|
3
|
+
export * from "./builder.ts"
|
|
4
|
+
export * from "./tracker.ts"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {ControllerMetaInterface} from "../../types";
|
|
2
|
-
import {METADATA_KEYS} from "../../framework";
|
|
1
|
+
import {ControllerMetaInterface} from "../../types/index.ts";
|
|
2
|
+
import {METADATA_KEYS} from "../../framework/index.ts";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
|
|
5
5
|
export function getControllerMetadata(target: any): ControllerMetaInterface {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {RaitonConfig} from "./config";
|
|
3
|
-
import {Raiton} from "./raiton";
|
|
2
|
+
import {RaitonConfig} from "./config/index.ts";
|
|
3
|
+
import {Raiton} from "./raiton.ts";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class RaitonDirectories {
|
|
7
7
|
public static readonly index = `.${Raiton.identifier}`;
|
|
8
8
|
public static readonly bootstrapFile = 'main.ts';
|
|
9
|
+
public static readonly compiledBootstrapFile = 'main.mjs';
|
|
9
10
|
// public static readonly bootstrapFile = 'main.js';
|
|
10
11
|
|
|
11
12
|
public static caches(workdir: string): string {
|
package/source/core/guards.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './raiton';
|
|
1
|
+
export * from './raiton.ts';
|
package/source/core/hooks.ts
CHANGED
package/source/core/index.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export * from "./config";
|
|
2
|
-
export * from "./process.util";
|
|
3
|
-
export * from "./builder";
|
|
4
|
-
export * from "./bytes.util";
|
|
5
|
-
export * from "./commands";
|
|
6
|
-
export * from "./command";
|
|
7
|
-
export * from "./directories";
|
|
8
|
-
export * from "./raiton";
|
|
9
|
-
export * from "./thread";
|
|
10
|
-
export * from "./application";
|
|
11
|
-
export * from "./controller";
|
|
12
|
-
export * from "./socket";
|
|
13
|
-
export * from "./mcp";
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./
|
|
1
|
+
export * from "./config/index.ts";
|
|
2
|
+
export * from "./process.util.ts";
|
|
3
|
+
export * from "./builder.ts";
|
|
4
|
+
export * from "./bytes.util.ts";
|
|
5
|
+
export * from "./commands.ts";
|
|
6
|
+
export * from "./command.ts";
|
|
7
|
+
export * from "./directories.ts";
|
|
8
|
+
export * from "./raiton.ts";
|
|
9
|
+
export * from "./thread.ts";
|
|
10
|
+
export * from "./application.ts";
|
|
11
|
+
export * from "./controller/index.ts";
|
|
12
|
+
export * from "./socket/index.ts";
|
|
13
|
+
export * from "./mcp/index.ts";
|
|
14
|
+
export * from "./scheduler/index.ts";
|
|
15
|
+
export * from "./plugins/index.ts";
|
|
16
|
+
export * from "./middleware/index.ts";
|
|
17
|
+
export * from "./router/index.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './injection';
|
|
1
|
+
export * from './injection.ts';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import type {ConstructorType, ContainerDefinitionInterface} from "../../types";
|
|
2
|
+
import type {ConstructorType, ContainerDefinitionInterface} from "../../types/index.ts";
|
|
3
3
|
import {LifetimeEnum, TextUtility} from "@protorians/core";
|
|
4
4
|
import {Logger} from "@protorians/logger";
|
|
5
|
-
import {METADATA_KEYS} from "../../framework/constants";
|
|
6
|
-
import {Throwable} from "../../framework/exceptions";
|
|
5
|
+
import {METADATA_KEYS} from "../../framework/constants/index.ts";
|
|
6
|
+
import {Throwable} from "../../framework/exceptions/index.ts";
|
|
7
7
|
|
|
8
8
|
const camelCase = TextUtility.camelCase;
|
|
9
9
|
|
|
@@ -154,7 +154,10 @@ export class Injection {
|
|
|
154
154
|
static get<T>(name: string, scope?: Symbol): T | undefined {
|
|
155
155
|
const name_ = this.normalizeName(name);
|
|
156
156
|
const cls = this._classes.get(name_);
|
|
157
|
-
if (!cls)
|
|
157
|
+
if (!cls) {
|
|
158
|
+
Logger.trace(`Dependency ${name_} not registered`, name);
|
|
159
|
+
throw new Throwable(`Dependency ${name_} not registered`);
|
|
160
|
+
}
|
|
158
161
|
|
|
159
162
|
const effectiveScope = scope || cls.scope || this.defaultScope;
|
|
160
163
|
if (this._resolutionStack.includes(name_)) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {registerMcpServer, unregisterMcpServer, getMcpServerMetadata} from "./metadata";
|
|
2
|
-
import {Injection} from "../injection";
|
|
3
|
-
import {McpServerRegistrationInterface} from "../../types";
|
|
4
|
-
import {McpRouteTracker} from "./tracker";
|
|
5
|
-
import {RaitonThread} from "../thread";
|
|
6
|
-
import {HttpMethod} from "../../framework/enums";
|
|
7
|
-
import {mcpHandleGet, mcpHandlePost, isMcpJsonRpc, SESSION_HEADER} from "../../framework/mcp/streamable-http";
|
|
8
|
-
import type {ContextInterface} from "../../types/core";
|
|
1
|
+
import {registerMcpServer, unregisterMcpServer, getMcpServerMetadata} from "./metadata.ts";
|
|
2
|
+
import {Injection} from "../injection/index.ts";
|
|
3
|
+
import {McpServerRegistrationInterface} from "../../types/index.ts";
|
|
4
|
+
import {McpRouteTracker} from "./tracker.ts";
|
|
5
|
+
import {RaitonThread} from "../thread.ts";
|
|
6
|
+
import {HttpMethod} from "../../framework/enums/index.ts";
|
|
7
|
+
import {mcpHandleGet, mcpHandlePost, isMcpJsonRpc, SESSION_HEADER} from "../../framework/mcp/streamable-http.ts";
|
|
8
|
+
import type {ContextInterface} from "../../types/core.ts";
|
|
9
9
|
|
|
10
10
|
export function compileMcp(McpServerClass: any): McpServerRegistrationInterface | undefined {
|
|
11
11
|
const metadata = getMcpServerMetadata(McpServerClass.prototype || McpServerClass)
|
package/source/core/mcp/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./metadata"
|
|
2
|
-
export * from "./builder"
|
|
3
|
-
export * from "./tracker"
|
|
1
|
+
export * from "./metadata.ts"
|
|
2
|
+
export * from "./builder.ts"
|
|
3
|
+
export * from "./tracker.ts"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {McpServerMetaInterface, McpServerRegistrationInterface} from "../../types";
|
|
2
|
-
import {METADATA_KEYS} from "../../framework/constants";
|
|
1
|
+
import {McpServerMetaInterface, McpServerRegistrationInterface} from "../../types/index.ts";
|
|
2
|
+
import {METADATA_KEYS} from "../../framework/constants/index.ts";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
|
|
5
5
|
const registry = new Map<string, McpServerRegistrationInterface>();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {MiddlewareType} from '../../types'
|
|
2
|
-
import {Throwable} from "../../framework/exceptions";
|
|
1
|
+
import {MiddlewareType} from '../../types/index.ts'
|
|
2
|
+
import {Throwable} from "../../framework/exceptions/index.ts";
|
|
3
3
|
|
|
4
4
|
export function middlewareCompose(middlewares: MiddlewareType[]) {
|
|
5
5
|
return function (request: any) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./compose"
|
|
2
|
-
export * from "./pipeline"
|
|
1
|
+
export * from "./compose.ts"
|
|
2
|
+
export * from "./pipeline.ts"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MiddlewareType } from '../../types'
|
|
2
|
-
import { middlewareCompose } from '
|
|
1
|
+
import { MiddlewareType } from '../../types/index.ts'
|
|
2
|
+
import { middlewareCompose } from '../index.ts'
|
|
3
3
|
|
|
4
4
|
export class MiddlewarePipeline {
|
|
5
5
|
private stack: MiddlewareType[] = []
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./scope"
|
|
2
|
-
export * from "./plugin"
|
|
1
|
+
export * from "./scope.ts"
|
|
2
|
+
export * from "./plugin.ts"
|