@forinda/kickjs 5.17.0 → 5.18.0-alpha.1
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/dist/adapter-D_uzU-QA.d.mts +2121 -0
- package/dist/adapter-D_uzU-QA.d.mts.map +1 -0
- package/dist/{context-decorator-DDZ30BIW.d.mts → app-module-CuAS6hJC.d.mts} +184 -4
- package/dist/app-module-CuAS6hJC.d.mts.map +1 -0
- package/dist/application-DwTrT9cq.mjs +12 -0
- package/dist/application-DwTrT9cq.mjs.map +1 -0
- package/dist/{application-CAnpDQ8d.d.mts → application-pbx53JnX.d.mts} +31 -5
- package/dist/application-pbx53JnX.d.mts.map +1 -0
- package/dist/{bootstrap-CHmCh_cE.mjs → bootstrap-BaqYQe4i.mjs} +3 -3
- package/dist/{bootstrap-CHmCh_cE.mjs.map → bootstrap-BaqYQe4i.mjs.map} +1 -1
- package/dist/{bootstrap-8DDzBjhx.d.mts → bootstrap-DzfBj6Ja.d.mts} +2 -2
- package/dist/{bootstrap-8DDzBjhx.d.mts.map → bootstrap-DzfBj6Ja.d.mts.map} +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-BvyPboRZ.mjs → config-okfM1SlN.mjs} +3 -3
- package/dist/{config-BvyPboRZ.mjs.map → config-okfM1SlN.mjs.map} +1 -1
- package/dist/{container-CPz0l8-b.mjs → container-B0BU5TY4.mjs} +3 -3
- package/dist/{container-CPz0l8-b.mjs.map → container-B0BU5TY4.mjs.map} +1 -1
- package/dist/context-DGsCYQRP.mjs +12 -0
- package/dist/context-DGsCYQRP.mjs.map +1 -0
- package/dist/core/adapter.d.mts +1 -1
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.d.mts +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +2 -2
- package/dist/core/errors.mjs.map +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.mjs +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/{core-C_gfh7JQ.mjs → core-BV0AxVuK.mjs} +3 -3
- package/dist/{core-C_gfh7JQ.mjs.map → core-BV0AxVuK.mjs.map} +1 -1
- package/dist/{env-LIrKUSAJ.mjs → env-wT1GSzGW.mjs} +3 -3
- package/dist/{env-LIrKUSAJ.mjs.map → env-wT1GSzGW.mjs.map} +1 -1
- package/dist/{errors-CRCTjEUK.d.mts → errors-n0H96eEz.d.mts} +3 -1
- package/dist/errors-n0H96eEz.d.mts.map +1 -0
- package/dist/http/application.d.mts +1 -1
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +2 -2
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.mjs +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +1 -1
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.mjs +1 -1
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.d.mts +2 -2
- package/dist/http/middleware/upload.mjs +3 -3
- package/dist/http/middleware/upload.mjs.map +1 -1
- package/dist/http/middleware/validate.mjs +2 -2
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +2 -2
- package/dist/http/router-builder.mjs +2 -2
- package/dist/http/router-builder.mjs.map +1 -1
- package/dist/http/runtimes/fastify.d.mts +66 -0
- package/dist/http/runtimes/fastify.d.mts.map +1 -0
- package/dist/http/runtimes/fastify.mjs +13 -0
- package/dist/http/runtimes/fastify.mjs.map +1 -0
- package/dist/http/runtimes/h3.d.mts +29 -0
- package/dist/http/runtimes/h3.d.mts.map +1 -0
- package/dist/http/runtimes/h3.mjs +12 -0
- package/dist/http/runtimes/h3.mjs.map +1 -0
- package/dist/index.d.mts +11 -16
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{metadata-D8hSFaux.mjs → metadata-B069pGq2.mjs} +2 -2
- package/dist/{metadata-D8hSFaux.mjs.map → metadata-B069pGq2.mjs.map} +1 -1
- package/dist/{query-NhwucLHS.mjs → query-CimrAth7.mjs} +2 -2
- package/dist/{query-NhwucLHS.mjs.map → query-CimrAth7.mjs.map} +1 -1
- package/dist/request-scope-DiBal5Ln.mjs +12 -0
- package/dist/request-scope-DiBal5Ln.mjs.map +1 -0
- package/dist/router-builder-Bh3qSiDz.d.mts +39 -0
- package/dist/router-builder-Bh3qSiDz.d.mts.map +1 -0
- package/dist/{spa-IRFC2eMN.d.mts → spa-BdvZFXJz.d.mts} +3 -2
- package/dist/spa-BdvZFXJz.d.mts.map +1 -0
- package/dist/{upload-D6edAELH.d.mts → upload-Bc_rBRtE.d.mts} +37 -2
- package/dist/upload-Bc_rBRtE.d.mts.map +1 -0
- package/dist/{views-DkllbVB3.d.mts → views-DcTVDiOh.d.mts} +31 -7
- package/dist/views-DcTVDiOh.d.mts.map +1 -0
- package/package.json +35 -1
- package/dist/adapter-CkpcZwzZ.d.mts +0 -407
- package/dist/adapter-CkpcZwzZ.d.mts.map +0 -1
- package/dist/app-module-BTzb-Vd6.d.mts +0 -92
- package/dist/app-module-BTzb-Vd6.d.mts.map +0 -1
- package/dist/application-CAnpDQ8d.d.mts.map +0 -1
- package/dist/application-CRmMytW1.mjs +0 -12
- package/dist/application-CRmMytW1.mjs.map +0 -1
- package/dist/context-C6e-S0uc.mjs +0 -12
- package/dist/context-C6e-S0uc.mjs.map +0 -1
- package/dist/context-DV7RjM9F.d.mts +0 -445
- package/dist/context-DV7RjM9F.d.mts.map +0 -1
- package/dist/context-decorator-DDZ30BIW.d.mts.map +0 -1
- package/dist/errors-CRCTjEUK.d.mts.map +0 -1
- package/dist/execution-context-B4cfhivz.d.mts +0 -98
- package/dist/execution-context-B4cfhivz.d.mts.map +0 -1
- package/dist/index-frSEHiL_.d.mts +0 -796
- package/dist/index-frSEHiL_.d.mts.map +0 -1
- package/dist/plugin-BQCn6zyj.d.mts +0 -260
- package/dist/plugin-BQCn6zyj.d.mts.map +0 -1
- package/dist/router-builder-oQpcQMWl.d.mts +0 -31
- package/dist/router-builder-oQpcQMWl.d.mts.map +0 -1
- package/dist/spa-IRFC2eMN.d.mts.map +0 -1
- package/dist/upload-D6edAELH.d.mts.map +0 -1
- package/dist/views-DkllbVB3.d.mts.map +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import { J as SourcedRegistration, m as RouteEntry } from "./adapter-D_uzU-QA.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/http/router-builder.d.ts
|
|
5
|
+
/** @internal — set by Application.setup() before each `mod.routes()` call. */
|
|
6
|
+
declare function _setExternalContributorSources(sources: readonly SourcedRegistration[]): void;
|
|
7
|
+
interface BuildRoutesOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Extra contributors to merge into the per-route pipeline at their declared
|
|
10
|
+
* precedence levels. Pass explicitly when calling buildRouteTable/buildRoutes
|
|
11
|
+
* outside the Application route-mount loop (typically in tests). When omitted,
|
|
12
|
+
* falls back to the slot set by Application.setup().
|
|
13
|
+
*/
|
|
14
|
+
externalSources?: readonly SourcedRegistration[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Turn a controller class decorated with @Get, @Post, etc. into a plain-data
|
|
18
|
+
* {@link RouteEntry}[] — the engine-neutral route table an {@link HttpRuntime}
|
|
19
|
+
* materializes (see `docs/http/spec-http-runtimes.md`, Avenue B).
|
|
20
|
+
*
|
|
21
|
+
* What used to be per-handler Express `(req, res, next)` closures is now
|
|
22
|
+
* captured as data: `middlewares` keep their `(ctx, next)` shape, the contributor
|
|
23
|
+
* pipeline is pre-built into a `contributorRunner` closure, validation / upload
|
|
24
|
+
* stay as metadata, and the terminal `handler` resolves the controller per-request
|
|
25
|
+
* (to respect DI scoping) and invokes it. The runtime owns how these get wrapped
|
|
26
|
+
* onto its engine.
|
|
27
|
+
*
|
|
28
|
+
* Routes use only the method-level decorator paths (e.g. @Get('/me') → '/me').
|
|
29
|
+
* The @Controller path is NOT baked in — it is metadata for Swagger/introspection.
|
|
30
|
+
* The module's routes().path is the single source of truth for the mount prefix,
|
|
31
|
+
* which avoids path doubling when both the module and controller specify the path.
|
|
32
|
+
*
|
|
33
|
+
* The contributor pipeline is built here, so a cycle or missing `dependsOn`
|
|
34
|
+
* throws at table-build time (boot) rather than on first request.
|
|
35
|
+
*/
|
|
36
|
+
declare function buildRouteTable(controllerClass: any, options?: BuildRoutesOptions): RouteEntry[];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { _setExternalContributorSources as n, buildRouteTable as r, BuildRoutesOptions as t };
|
|
39
|
+
//# sourceMappingURL=router-builder-Bh3qSiDz.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-builder-Bh3qSiDz.d.mts","names":[],"sources":["../src/http/router-builder.ts"],"mappings":";;;;;iBAgCgB,8BAAA,CAA+B,OAAuC,WAArB,mBAAmB;AAAA,UAInE,kBAAA;;;AAJqE;AAItF;;;EAOE,eAAA,YAA2B,mBAAmB;AAAA;AAuBhD;;;;;;;;;AAGa;;;;;;;;;;;AAHb,iBAAgB,eAAA,CACd,eAAA,OACA,OAAA,GAAS,kBAAA,GACR,UAAU"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { r as AppAdapter, t as AdapterContext } from "./adapter-
|
|
2
|
+
import { r as AppAdapter, t as AdapterContext } from "./adapter-D_uzU-QA.mjs";
|
|
3
|
+
|
|
3
4
|
//#region src/http/middleware/spa.d.ts
|
|
4
5
|
interface SpaAdapterOptions {
|
|
5
6
|
/**
|
|
@@ -98,4 +99,4 @@ declare class SpaAdapter implements AppAdapter {
|
|
|
98
99
|
}
|
|
99
100
|
//#endregion
|
|
100
101
|
export { SpaAdapterOptions as n, SpaAdapter as t };
|
|
101
|
-
//# sourceMappingURL=spa-
|
|
102
|
+
//# sourceMappingURL=spa-BdvZFXJz.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spa-BdvZFXJz.d.mts","names":[],"sources":["../src/http/middleware/spa.ts"],"mappings":";;;;UAMiB,iBAAA;;AAAjB;;;;;;;;;;AAiDmB;AAkCnB;EArEE,SAAA;;;;;;;;;;;EAYA,SAAA;EA0DA;;;;;;;;;EA/CA,OAAA;EAiEA;;;;EA3DA,YAAA;EAoGc;;;;EA9Fd,iBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkCW,UAAA,YAAsB,UAAA;EAAA,QASb,OAAA;EARpB,IAAA;EAAA,QACQ,SAAA;EAAA,QACA,WAAA;EAAA,QACA,YAAA;EAAA,QACA,YAAA;EAAA,QACA,iBAAA;EAAA,QACA,SAAA;EAER,WAAA,CAAoB,OAAA,GAAS,iBAAA;EAU7B,WAAA;IAAc;EAAA,GAAO,cAAA;EAyCrB,WAAA;IAAc;EAAA,GAAO,cAAA;AAAA"}
|
|
@@ -15,6 +15,41 @@ import { Options } from "multer";
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
declare function resolveMimeTypes(types: string[]): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Build a runtime-agnostic `(mimetype, filename) => boolean` file-type filter
|
|
20
|
+
* from `allowedTypes` (a predicate, or a list of extensions / MIME types /
|
|
21
|
+
* wildcards). Returned by both the multer middleware (Express) and the
|
|
22
|
+
* Fastify / h3 multipart paths so the accept/reject rule stays identical
|
|
23
|
+
* across engines. No `allowedTypes` → accept everything.
|
|
24
|
+
*/
|
|
25
|
+
declare function buildFileTypeFilter(allowedTypes: BaseUploadOptions['allowedTypes'], customMimeMap?: Record<string, string>): (mimetype: string, filename: string) => boolean;
|
|
26
|
+
/** A multer-shaped uploaded file — what `ctx.file` / `ctx.files` expose. */
|
|
27
|
+
interface UploadedFileLike {
|
|
28
|
+
fieldname: string;
|
|
29
|
+
originalname: string;
|
|
30
|
+
encoding: string;
|
|
31
|
+
mimetype: string;
|
|
32
|
+
size: number;
|
|
33
|
+
buffer: Buffer;
|
|
34
|
+
}
|
|
35
|
+
/** A buffered multipart file part, as the runtime hands it to {@link applyUploadConfig}. */
|
|
36
|
+
interface RawUploadPart {
|
|
37
|
+
fieldname: string;
|
|
38
|
+
filename: string;
|
|
39
|
+
mimetype: string;
|
|
40
|
+
buffer: Buffer;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Apply a `@FileUpload` config to already-buffered multipart parts and return
|
|
44
|
+
* the multer-shaped `file` / `files` for `ctx`. Enforces the field name, type
|
|
45
|
+
* filter, per-file size limit, and (array mode) max count — throwing
|
|
46
|
+
* `HttpException` on a violation, mirroring the Express/multer error path.
|
|
47
|
+
* Used by the Fastify and h3 runtimes; Express keeps using multer directly.
|
|
48
|
+
*/
|
|
49
|
+
declare function applyUploadConfig(parts: RawUploadPart[], config: FileUploadConfig): {
|
|
50
|
+
file?: UploadedFileLike;
|
|
51
|
+
files?: UploadedFileLike[];
|
|
52
|
+
};
|
|
18
53
|
/**
|
|
19
54
|
* Upload options for the middleware.
|
|
20
55
|
* Extends BaseUploadOptions from core (shared with @FileUpload decorator)
|
|
@@ -75,5 +110,5 @@ declare const upload: {
|
|
|
75
110
|
none: typeof none;
|
|
76
111
|
};
|
|
77
112
|
//#endregion
|
|
78
|
-
export {
|
|
79
|
-
//# sourceMappingURL=upload-
|
|
113
|
+
export { buildFileTypeFilter as a, resolveMimeTypes as c, applyUploadConfig as i, upload as l, UploadOptions as n, buildUploadMiddleware as o, UploadedFileLike as r, cleanupFiles as s, RawUploadPart as t };
|
|
114
|
+
//# sourceMappingURL=upload-Bc_rBRtE.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-Bc_rBRtE.d.mts","names":[],"sources":["../src/http/middleware/upload.ts"],"mappings":";;;;;;;;;AAsGA;;;;AAAgD;AAchD;;iBAdgB,gBAAA,CAAiB,KAAe;;;;;;;;iBAchC,mBAAA,CACd,YAAA,EAAc,iBAAA,kBACd,aAAA,GAAgB,MAAM,oBACpB,QAAA,UAAkB,QAAA;AAAgB;AAAA,UAYrB,gBAAA;EACf,SAAA;EACA,YAAA;EACA,QAAA;EACA,QAAA;EACA,IAAA;EACA,MAAA,EAAQ,MAAM;AAAA;;UAIC,aAAA;EACf,SAAA;EACA,QAAA;EACA,QAAA;EACA,MAAA,EAAQ,MAAM;AAAA;;;;;;;;iBAYA,iBAAA,CACd,KAAA,EAAO,aAAA,IACP,MAAA,EAAQ,gBAAA;EACL,IAAA,GAAO,gBAAA;EAAkB,KAAA,GAAQ,gBAAA;AAAA;;;;;;UAyCrB,aAAA,SAAsB,iBAAiB;EAzCF;EA2CpD,OAAA,GAAU,OAAA;EA7CV;EA+CA,IAAA;AAAA;;;;;;AA7CoD;AAyCtD;;;;;;iBA8CS,MAAA,CAAO,SAAA,UAAmB,OAAA,GAAS,aAAA,GAAqB,cAAc;;;AA1CzE;iBAkDG,KAAA,CAAM,SAAA,UAAmB,QAAA,WAAe,OAAA,GAAS,aAAA,GAAqB,cAAc;;;;iBAQpF,IAAA,CAAK,OAAA,GAAS,aAAA,GAAqB,cAAc;;;;;AAhBqB;AAAA;;;;;;;;;iBAmC/D,YAAA,KAAY,GAAA,EACb,OAAA,EAAO,GAAA,EAAO,QAAA,EAAQ,IAAA,EAAQ,YAAA;AA5BgD;AAAA;;;;AAAA,iBA2D7E,qBAAA,CAAsB,MAAA,EAAQ,gBAAA,GAAmB,cAAc;;cAmBlE,MAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NextFunction, Request, Response } from "express";
|
|
2
|
+
import { f as DepValue, o as ContextDecorator, s as ContextDecoratorSpec, v as MetaValue } from "./app-module-CuAS6hJC.mjs";
|
|
3
|
+
import { P as AdapterFactory, T as RequestContext, f as HttpRuntime, m as RouteEntry } from "./adapter-D_uzU-QA.mjs";
|
|
4
|
+
import { t as BuildRoutesOptions } from "./router-builder-Bh3qSiDz.mjs";
|
|
5
|
+
import { Express, NextFunction, Request, Response, Router } from "express";
|
|
7
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
7
|
|
|
9
8
|
//#region src/http/cluster.d.ts
|
|
@@ -57,6 +56,31 @@ interface DefineHttpContextDecoratorFn {
|
|
|
57
56
|
}
|
|
58
57
|
declare const defineHttpContextDecorator: DefineHttpContextDecoratorFn;
|
|
59
58
|
//#endregion
|
|
59
|
+
//#region src/http/runtimes/express.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Materialize a controller's {@link RouteEntry}[] onto a fresh `express.Router`.
|
|
62
|
+
* Reproduces the legacy handler ordering precisely: validation → upload →
|
|
63
|
+
* `(ctx, next)` middleware → contributor runner → terminal handler. Each step
|
|
64
|
+
* constructs its own `RequestContext` over the same `req`/`res` — request-scoped
|
|
65
|
+
* state lives in the AsyncLocalStorage store, not on the ctx instance, so the
|
|
66
|
+
* per-step instances share state exactly as before.
|
|
67
|
+
*/
|
|
68
|
+
declare function materializeRouter(entries: RouteEntry[]): Router;
|
|
69
|
+
/**
|
|
70
|
+
* Build an Express Router from a controller class decorated with @Get, @Post,
|
|
71
|
+
* etc. The public, back-compatible entry point: a thin shim over
|
|
72
|
+
* {@link buildRouteTable} + {@link materializeRouter}. Returns an
|
|
73
|
+
* `express.Router` exactly as before — modules pass it to `app.use(path, router)`.
|
|
74
|
+
*
|
|
75
|
+
* @see buildRouteTable for the engine-neutral route-table form.
|
|
76
|
+
*/
|
|
77
|
+
declare function buildRoutes(controllerClass: any, options?: BuildRoutesOptions): Router;
|
|
78
|
+
/**
|
|
79
|
+
* The default HTTP runtime. Express stays a peer dependency of `@forinda/kickjs`;
|
|
80
|
+
* apps that pass no `runtime` get this and behave exactly as before.
|
|
81
|
+
*/
|
|
82
|
+
declare function expressRuntime(): HttpRuntime<Express>;
|
|
83
|
+
//#endregion
|
|
60
84
|
//#region src/http/request-store.d.ts
|
|
61
85
|
/** Per-request storage for REQUEST-scoped DI and request context propagation */
|
|
62
86
|
interface RequestStore {
|
|
@@ -245,5 +269,5 @@ interface ViewAdapterOptions {
|
|
|
245
269
|
*/
|
|
246
270
|
declare const ViewAdapter: AdapterFactory<ViewAdapterOptions, unknown>;
|
|
247
271
|
//#endregion
|
|
248
|
-
export { TraceContextOptions as a, requestScopeMiddleware as c, getRequestValue as d, requestStore as f,
|
|
249
|
-
//# sourceMappingURL=views-
|
|
272
|
+
export { ClusterOptions as _, TraceContextOptions as a, requestScopeMiddleware as c, getRequestValue as d, requestStore as f, defineHttpContextDecorator as g, materializeRouter as h, TraceContext as i, RequestStore as l, expressRuntime as m, ViewAdapterOptions as n, parseTraceparent as o, buildRoutes as p, TRACEPARENT_HEADER as r, traceContext as s, ViewAdapter as t, getRequestStore as u, isClusterPrimary as v };
|
|
273
|
+
//# sourceMappingURL=views-DcTVDiOh.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views-DcTVDiOh.d.mts","names":[],"sources":["../src/http/cluster.ts","../src/http/define-http-context-decorator.ts","../src/http/runtimes/express.ts","../src/http/request-store.ts","../src/http/middleware/request-scope.ts","../src/http/middleware/trace-context.ts","../src/http/middleware/views.ts"],"mappings":";;;;;;;;UAOiB,cAAA;;EAEf,OAAA;;EAEA,uBAAA;;EAEA,YAAA;;EAEA,WAAA;;EAEA,aAAA;AAAA;;iBAIc,gBAAA;;;;;;;;UCuDC,oCAAA,WAA+C,MAAA;EAAA,6BACjC,MAAA,SAAe,QAAA,IAAY,MAAA,iBACtD,IAAA,EAAM,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,cAAA,IACnC,gBAAA,CAAiB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,cAAA;AAAA;;;;;;UAQd,4BAAA;EAAA,6BAGH,MAAA,SAAe,QAAA,IAAY,MAAA,2BAC3B,MAAA,oBAA0B,MAAA,iBAEpC,IAAA,EAAM,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,cAAA,IACnC,gBAAA,CAAiB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,cAAA;EAPd;;;;;;;;;;;;;;;EAwBf,UAAA,WAAqB,MAAA,sBAA4B,oCAAA,CAAqC,CAAA;AAAA;AAAA,cAW3E,0BAAA,EAA4B,4BAQR;;;;;;;;;;;iBC5FjB,iBAAA,CAAkB,OAAA,EAAS,UAAA,KAAe,MAAM;;;;;;;;;iBA8DhD,WAAA,CAAY,eAAA,OAAsB,OAAA,GAAS,kBAAA,GAA0B,MAAM;AF7F3F;;;;AAAA,iBEqGgB,cAAA,IAAkB,WAAW,CAAC,OAAA;;;;UCxG7B,YAAA;;EAEf,SAAA;;;;;;EAMA,SAAA,EAAW,GAAA;;;;;;;;;;AHLb;;;;;;;;;;AAUe;EGgBb,MAAA,EAAQ,GAAG;AAAA;;cAIA,YAAA,EAAY,iBAAA,CAAA,YAAA;AHhBO;;;;AAAA,iBGsBhB,eAAA,IAAmB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoC/B,eAAA,mBAAkC,GAAA,EAAK,CAAA,GAAI,SAAA,CAAU,CAAA;;;;;;;;;;;iBCvCrD,sBAAA,KAAsB,GAAA,EACnB,OAAA,EAAO,IAAA,EAAQ,QAAA,EAAQ,IAAA,EAAQ,YAAA;;;;;;;cCjCrC,kBAAA;AAAA,UAKI,mBAAA;;;;;EAKf,iBAAiB;AAAA;;;;UAMF,YAAA;;EAEf,OAAA;;EAEA,OAAA;ELrBe;EKuBf,YAAA;;EAEA,KAAA;AAAA;;;;;iBAqBc,gBAAA,CAAiB,MAAA,WAAiB,YAAY;ALpC/C;AAIf;;;;AAAgC;;;;ACuDhC;;;;;;;;;;;;AD3De,iBK8EC,YAAA,CAAa,OAAA,GAAS,mBAAA,IAAwB,GAAA,EAC/C,OAAA,EAAO,GAAA,EAAO,QAAA,EAAQ,IAAA,EAAQ,YAAA;;;UC3F5B,kBAAA;;;;;;;;;;;;;;;EAef,MAAA;;EAGA,GAAA;;EAGA,QAAA;;EAGA,MAAA;AAAA;;;;;;;;;ANZa;AAIf;;;;AAAgC;;;;ACuDhC;;;;;;;;;;;;cKfa,WAAA,EAAW,cAAA,CAAA,kBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0-alpha.1",
|
|
4
4
|
"description": "A production-grade, decorator-driven Node.js framework built on Express 5 and TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -89,6 +89,14 @@
|
|
|
89
89
|
"./config": {
|
|
90
90
|
"import": "./dist/config/index.mjs",
|
|
91
91
|
"types": "./dist/config/index.d.mts"
|
|
92
|
+
},
|
|
93
|
+
"./fastify": {
|
|
94
|
+
"import": "./dist/http/runtimes/fastify.mjs",
|
|
95
|
+
"types": "./dist/http/runtimes/fastify.d.mts"
|
|
96
|
+
},
|
|
97
|
+
"./h3": {
|
|
98
|
+
"import": "./dist/http/runtimes/h3.mjs",
|
|
99
|
+
"types": "./dist/http/runtimes/h3.d.mts"
|
|
92
100
|
}
|
|
93
101
|
},
|
|
94
102
|
"files": [
|
|
@@ -101,28 +109,54 @@
|
|
|
101
109
|
"@forinda/kickjs-schema": "0.1.2"
|
|
102
110
|
},
|
|
103
111
|
"peerDependencies": {
|
|
112
|
+
"@fastify/middie": "^9.0.0",
|
|
113
|
+
"@fastify/multipart": "^9.0.0",
|
|
104
114
|
"dotenv": "^17.0.0",
|
|
105
115
|
"express": "^5.1.0",
|
|
116
|
+
"fastify": "^5.0.0",
|
|
117
|
+
"h3": "^1.0.0",
|
|
106
118
|
"multer": "^2.0.0",
|
|
119
|
+
"serve-static": "^1.15.0 || ^2.0.0",
|
|
107
120
|
"zod": "^4.0.0"
|
|
108
121
|
},
|
|
109
122
|
"peerDependenciesMeta": {
|
|
123
|
+
"@fastify/middie": {
|
|
124
|
+
"optional": true
|
|
125
|
+
},
|
|
126
|
+
"@fastify/multipart": {
|
|
127
|
+
"optional": true
|
|
128
|
+
},
|
|
110
129
|
"dotenv": {
|
|
111
130
|
"optional": true
|
|
112
131
|
},
|
|
132
|
+
"h3": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"fastify": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
113
138
|
"multer": {
|
|
114
139
|
"optional": true
|
|
115
140
|
},
|
|
141
|
+
"serve-static": {
|
|
142
|
+
"optional": true
|
|
143
|
+
},
|
|
116
144
|
"zod": {
|
|
117
145
|
"optional": true
|
|
118
146
|
}
|
|
119
147
|
},
|
|
120
148
|
"devDependencies": {
|
|
149
|
+
"@fastify/middie": "^9.3.2",
|
|
150
|
+
"@fastify/multipart": "^9.0.0",
|
|
121
151
|
"@swc/core": "^1.15.40",
|
|
122
152
|
"@types/express": "^5.0.6",
|
|
123
153
|
"@types/multer": "^2.1.0",
|
|
124
154
|
"@types/node": "^25.9.2",
|
|
155
|
+
"@types/serve-static": "^1.15.7",
|
|
156
|
+
"fastify": "^5.8.5",
|
|
157
|
+
"h3": "1.15.11",
|
|
125
158
|
"multer": "^2.1.1",
|
|
159
|
+
"serve-static": "^2.2.0",
|
|
126
160
|
"typescript": "^6.0.3",
|
|
127
161
|
"vite": "^8.0.16",
|
|
128
162
|
"vitest": "^4.1.8",
|
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { i as Constructor, o as MaybePromise } from "./interfaces-DbTyKGdS.mjs";
|
|
3
|
-
import { t as Container } from "./container-TWOUyR_0.mjs";
|
|
4
|
-
import { s as ContributorRegistrations } from "./context-decorator-DDZ30BIW.mjs";
|
|
5
|
-
import http from "node:http";
|
|
6
|
-
import { ErrorRequestHandler, Express, RequestHandler } from "express";
|
|
7
|
-
|
|
8
|
-
//#region src/core/introspect.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* Per-primitive introspection snapshot — the JSON shape an adapter or
|
|
11
|
-
* plugin's optional `introspect()` hook returns for DevTools.
|
|
12
|
-
*
|
|
13
|
-
* Lives in `@forinda/kickjs` (not `@forinda/kickjs-devtools-kit`) so
|
|
14
|
-
* adopters can type their `introspect()` return without taking on a
|
|
15
|
-
* dep on the kit just to satisfy the contract. The kit's own
|
|
16
|
-
* `IntrospectionSnapshot` type is structurally identical and continues
|
|
17
|
-
* to be the canonical doc location for DevTools-side consumers; the
|
|
18
|
-
* two stay in lockstep — if a field is added on one side it MUST be
|
|
19
|
-
* added on the other (covered by the type-equivalence test in the
|
|
20
|
-
* devtools-kit package).
|
|
21
|
-
*
|
|
22
|
-
* Cheap-by-default principle: `state` and `metrics` should be O(1) to
|
|
23
|
-
* compute (counters, flags, recent samples). Anything that requires a
|
|
24
|
-
* DB round trip or a full DI graph walk belongs behind a separate
|
|
25
|
-
* explicit RPC — DevTools polls topology aggressively.
|
|
26
|
-
*/
|
|
27
|
-
interface IntrospectionSnapshot {
|
|
28
|
-
/**
|
|
29
|
-
* Wire-protocol version this snapshot conforms to. The kit ships a
|
|
30
|
-
* `PROTOCOL_VERSION` constant typed as the literal `1`; we mirror
|
|
31
|
-
* that literal here so structural parity is enforced both ways —
|
|
32
|
-
* an adopter who writes `protocolVersion: 1` satisfies both this
|
|
33
|
-
* type and the kit's `IntrospectionSnapshot`. Bumping is a
|
|
34
|
-
* coordinated kit + framework release; widen this literal in
|
|
35
|
-
* lockstep.
|
|
36
|
-
*/
|
|
37
|
-
protocolVersion: 1;
|
|
38
|
-
/** Stable identity matching the `name` from `definePlugin` / `defineAdapter`. */
|
|
39
|
-
name: string;
|
|
40
|
-
/** Discriminator for what kind of primitive this is. */
|
|
41
|
-
kind: IntrospectionKind;
|
|
42
|
-
/** Optional version string from the plugin / adapter metadata. */
|
|
43
|
-
version?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Reactive state surface — JSON-serialisable snapshot. Keep small
|
|
46
|
-
* (under a few KB) so polling stays cheap.
|
|
47
|
-
*/
|
|
48
|
-
state?: Record<string, unknown>;
|
|
49
|
-
/** DI tokens this primitive registers (`provides`) or consumes (`requires`). */
|
|
50
|
-
tokens?: {
|
|
51
|
-
provides: readonly string[];
|
|
52
|
-
requires: readonly string[];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Per-instance counters — active connections, in-flight jobs, cached
|
|
56
|
-
* items, etc. Numbers only so the DevTools panel can chart trends.
|
|
57
|
-
*/
|
|
58
|
-
metrics?: Record<string, number>;
|
|
59
|
-
/** Self-reported memory footprint estimate, in bytes. Optional. */
|
|
60
|
-
memoryBytes?: number;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* What kind of primitive an introspection snapshot describes. Matches
|
|
64
|
-
* the kit's `IntrospectionKind` and the routing the topology aggregator
|
|
65
|
-
* does when bucketing adapters vs plugins vs middleware vs contributor
|
|
66
|
-
* primitives.
|
|
67
|
-
*/
|
|
68
|
-
type IntrospectionKind = 'plugin' | 'adapter' | 'middleware' | 'contributor';
|
|
69
|
-
/**
|
|
70
|
-
* Convenience function signature for adopter-side helpers that return
|
|
71
|
-
* a complete snapshot. Used by the optional `introspect?()` hook on
|
|
72
|
-
* `AppAdapter` and `KickPlugin`.
|
|
73
|
-
*/
|
|
74
|
-
type IntrospectFn = () => IntrospectionSnapshot | Promise<IntrospectionSnapshot>;
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/core/augmentation.d.ts
|
|
77
|
-
/**
|
|
78
|
-
* Augmentation registry — runtime no-op + the canonical
|
|
79
|
-
* `KickJsPluginRegistry` interface that `kick typegen` augments.
|
|
80
|
-
*
|
|
81
|
-
* See `architecture.md` §21.2.1 (typegen for `dependsOn`) and §21.3.3
|
|
82
|
-
* (standardized augmentation registry) for the design rationale.
|
|
83
|
-
*
|
|
84
|
-
* @module @forinda/kickjs/core/augmentation
|
|
85
|
-
*/
|
|
86
|
-
/**
|
|
87
|
-
* Marker interface that lists every plugin/adapter in the project. The
|
|
88
|
-
* keys are the literal `name` field passed to `defineAdapter` /
|
|
89
|
-
* `definePlugin` (or declared on a `class implements AppAdapter`); the
|
|
90
|
-
* values are the kind tag (`'plugin' | 'adapter'`).
|
|
91
|
-
*
|
|
92
|
-
* The framework ships this empty. `kick typegen` augments it from
|
|
93
|
-
* source so `keyof KickJsPluginRegistry` resolves to a string-literal
|
|
94
|
-
* union of every name in scope — and therefore so do `dependsOn`
|
|
95
|
-
* declarations on plugins/adapters.
|
|
96
|
-
*/
|
|
97
|
-
interface KickJsPluginRegistry {}
|
|
98
|
-
/**
|
|
99
|
-
* Resolves to a string-literal union of every registered plugin/adapter
|
|
100
|
-
* name when the project's typegen has populated `KickJsPluginRegistry`,
|
|
101
|
-
* or to `string` when the registry is empty (no typegen pass yet).
|
|
102
|
-
*
|
|
103
|
-
* Falling back to `string` keeps fresh projects compiling — the typegen
|
|
104
|
-
* narrowing is a progressive enhancement, not a hard prerequisite.
|
|
105
|
-
*/
|
|
106
|
-
type KickJsPluginName = keyof KickJsPluginRegistry extends never ? string : keyof KickJsPluginRegistry & string;
|
|
107
|
-
/**
|
|
108
|
-
* Metadata attached to a `defineAugmentation` call. The fields are
|
|
109
|
-
* documentation-only — `kick typegen` surfaces them in the generated
|
|
110
|
-
* `.kickjs/types/augmentations.d.ts` so adopters can browse every
|
|
111
|
-
* augmentable interface from one place.
|
|
112
|
-
*
|
|
113
|
-
* `description` and `example` may both be multi-line — typegen preserves
|
|
114
|
-
* line breaks when rendering them as JSDoc. There is no upper limit on
|
|
115
|
-
* the example size; entire shape definitions or worked snippets are fine.
|
|
116
|
-
*/
|
|
117
|
-
interface AugmentationMeta {
|
|
118
|
-
/**
|
|
119
|
-
* Free-form description of what the augmentation customises. May be
|
|
120
|
-
* multi-line — newlines are preserved in the generated JSDoc.
|
|
121
|
-
*/
|
|
122
|
-
description?: string;
|
|
123
|
-
/**
|
|
124
|
-
* TS snippet showing a typical shape. May be multi-line; rendered
|
|
125
|
-
* inside a fenced code block in the generated catalogue. Use this
|
|
126
|
-
* for anything from `'{ foo: string }'` up to a full interface body
|
|
127
|
-
* — typegen no longer flattens newlines.
|
|
128
|
-
*/
|
|
129
|
-
example?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Advertise an augmentable interface so `kick typegen` can list it in
|
|
133
|
-
* `.kickjs/types/augmentations.d.ts` for project-wide discovery.
|
|
134
|
-
*
|
|
135
|
-
* **This function is a runtime AND type-level no-op.** It does NOT
|
|
136
|
-
* augment the interface for TypeScript. The actual augmentation is
|
|
137
|
-
* the `declare module` block — `defineAugmentation` only adds an
|
|
138
|
-
* entry to the typegen catalogue so other contributors / adopters
|
|
139
|
-
* can find the interface and know its expected shape.
|
|
140
|
-
*
|
|
141
|
-
* Both calls are needed:
|
|
142
|
-
*
|
|
143
|
-
* ```ts
|
|
144
|
-
* import { defineAugmentation } from '@forinda/kickjs'
|
|
145
|
-
*
|
|
146
|
-
* // (1) The actual TS augmentation — what `ctx.get('tenant')` reads.
|
|
147
|
-
* declare module '@forinda/kickjs' {
|
|
148
|
-
* interface ContextMeta {
|
|
149
|
-
* tenant: { id: string; name: string }
|
|
150
|
-
* }
|
|
151
|
-
* }
|
|
152
|
-
*
|
|
153
|
-
* // (2) Catalogue entry — what `kick typegen` lists in
|
|
154
|
-
* // `.kickjs/types/augmentations.d.ts` for browseability.
|
|
155
|
-
* defineAugmentation('ContextMeta', {
|
|
156
|
-
* description: 'Tenant resolved from x-tenant-id by TenantAdapter',
|
|
157
|
-
* example: `{
|
|
158
|
-
* tenant: {
|
|
159
|
-
* id: string
|
|
160
|
-
* name: string
|
|
161
|
-
* plan: 'free' | 'pro' | 'enterprise'
|
|
162
|
-
* featureFlags: Record<string, boolean>
|
|
163
|
-
* }
|
|
164
|
-
* }`,
|
|
165
|
-
* })
|
|
166
|
-
* ```
|
|
167
|
-
*
|
|
168
|
-
* Skip `defineAugmentation` if you don't care about the catalogue — the
|
|
169
|
-
* `declare module` block alone is enough for runtime + type behaviour.
|
|
170
|
-
*
|
|
171
|
-
* @deprecated Low value in practice: it does nothing at runtime or at
|
|
172
|
-
* the type level — the `declare module` block alone gives you the
|
|
173
|
-
* augmentation, and the generated `.kickjs/types/kick__augmentations.d.ts`
|
|
174
|
-
* catalogue it feeds is documentation-only. Prefer a plain
|
|
175
|
-
* `declare module '@forinda/kickjs' { ... }` block and (optionally) a
|
|
176
|
-
* JSDoc comment on your own interface. `defineAugmentation` and the
|
|
177
|
-
* `kick/augmentations` typegen plugin will be removed in a future major.
|
|
178
|
-
*/
|
|
179
|
-
declare function defineAugmentation(name: string, meta?: AugmentationMeta): void;
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/core/adapter.d.ts
|
|
182
|
-
/**
|
|
183
|
-
* Where in the middleware pipeline an adapter's middleware should be inserted.
|
|
184
|
-
*
|
|
185
|
-
* - `beforeGlobal` — runs **before** any user-defined global middleware.
|
|
186
|
-
* Suitable for transport-level concerns (request tagging, low-level
|
|
187
|
-
* request rewriting). Fires on every request.
|
|
188
|
-
* - `afterGlobal` — runs **after** global middleware, **before** module
|
|
189
|
-
* routes are matched. Default for most adapter middleware (auth pre-checks,
|
|
190
|
-
* tenant resolution, body shaping). Fires on every request.
|
|
191
|
-
* - `beforeRoutes` — runs just before module routes are mounted. Functionally
|
|
192
|
-
* equivalent to `afterGlobal` for most cases; the explicit phase exists so
|
|
193
|
-
* adapters that *must* sit at the very end of the pre-route stack can
|
|
194
|
-
* declare intent. Fires on every request.
|
|
195
|
-
* - `afterRoutes` — sits **after** module routes but **before** error
|
|
196
|
-
* handlers. **Fires only on fall-through** — when no route matched (404
|
|
197
|
-
* path) or a route handler called `next()` without ending the response.
|
|
198
|
-
* Controllers that respond with `ctx.json(...)` end the chain and skip
|
|
199
|
-
* this phase, so it is *not* a "post-response" hook. For per-response
|
|
200
|
-
* work (logging, metrics) use `res.on('finish', ...)` from inside an
|
|
201
|
-
* earlier-phase middleware instead.
|
|
202
|
-
*/
|
|
203
|
-
type MiddlewarePhase = 'beforeGlobal' | 'afterGlobal' | 'beforeRoutes' | 'afterRoutes';
|
|
204
|
-
/**
|
|
205
|
-
* Path scope for an {@link AdapterMiddleware} entry. Mirrors what
|
|
206
|
-
* Express's `app.use(path, handler)` accepts so adapters get the full
|
|
207
|
-
* range without learning a new mini-language:
|
|
208
|
-
*
|
|
209
|
-
* - A `string` prefix — `'/api'` matches `/api`, `/api/v1`, `/api/v1/x`.
|
|
210
|
-
* - A `RegExp` — `/^\/api\/v\d+/` matches `/api/v1`, `/api/v42`.
|
|
211
|
-
* - An array of either — `['/api', '/admin']` matches either prefix;
|
|
212
|
-
* `['/api', /^\/internal\//]` mixes shapes.
|
|
213
|
-
*
|
|
214
|
-
* Omit to apply the middleware unconditionally (Express `app.use(handler)`).
|
|
215
|
-
*/
|
|
216
|
-
type MiddlewarePath = string | RegExp | ReadonlyArray<string | RegExp>;
|
|
217
|
-
/** A middleware entry contributed by an adapter */
|
|
218
|
-
interface AdapterMiddleware {
|
|
219
|
-
/**
|
|
220
|
-
* Express handler: either a `RequestHandler` (`(req, res, next) => …`)
|
|
221
|
-
* or an `ErrorRequestHandler` (`(err, req, res, next) => …`).
|
|
222
|
-
* Express dispatches based on arity, so the same field accepts both
|
|
223
|
-
* without a discriminant.
|
|
224
|
-
*/
|
|
225
|
-
handler: RequestHandler | ErrorRequestHandler;
|
|
226
|
-
/** Which phase to insert into (default: 'afterGlobal') */
|
|
227
|
-
phase?: MiddlewarePhase;
|
|
228
|
-
/**
|
|
229
|
-
* Optional path scope. See {@link MiddlewarePath} for the accepted
|
|
230
|
-
* shapes (string prefix, RegExp, or an array mixing both). Omit to
|
|
231
|
-
* apply the middleware to every request that reaches this phase.
|
|
232
|
-
*/
|
|
233
|
-
path?: MiddlewarePath;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Context passed to adapter lifecycle hooks.
|
|
237
|
-
* Populated by the Application — provides access to the Express app,
|
|
238
|
-
* DI container, http.Server, and environment info without requiring
|
|
239
|
-
* external type imports. Cast `app` or `server` if you need specific types.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* beforeMount({ app, container }: AdapterContext) {
|
|
244
|
-
* app.use(myMiddleware())
|
|
245
|
-
* }
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
interface AdapterContext {
|
|
249
|
-
/** Express application instance — fully typed */
|
|
250
|
-
app: Express;
|
|
251
|
-
/** DI container */
|
|
252
|
-
container: Container;
|
|
253
|
-
/** Node.js http.Server — only available in afterStart */
|
|
254
|
-
server?: http.Server;
|
|
255
|
-
/** Current NODE_ENV value (default: 'development') */
|
|
256
|
-
env: string;
|
|
257
|
-
/** true when NODE_ENV === 'production' */
|
|
258
|
-
isProduction: boolean;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Adapters plug into the Application lifecycle.
|
|
262
|
-
* Implement this to add WebSocket, database, rate limiting, docs, etc.
|
|
263
|
-
*
|
|
264
|
-
* All hooks receive an `AdapterContext` populated by the framework.
|
|
265
|
-
* No external type imports needed — the context is fully typed from KickJS internals.
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* ```ts
|
|
269
|
-
* import type { AppAdapter, AdapterContext } from '@forinda/kickjs/adapter'
|
|
270
|
-
*
|
|
271
|
-
* class SentryAdapter implements AppAdapter {
|
|
272
|
-
* name = 'SentryAdapter'
|
|
273
|
-
*
|
|
274
|
-
* beforeMount({ app, container }: AdapterContext) {
|
|
275
|
-
* app.use(Sentry.expressRequestHandler())
|
|
276
|
-
* }
|
|
277
|
-
*
|
|
278
|
-
* afterStart({ server }: AdapterContext) {
|
|
279
|
-
* // server is the http.Server — available after listen()
|
|
280
|
-
* }
|
|
281
|
-
*
|
|
282
|
-
* async shutdown() {
|
|
283
|
-
* await Sentry.close(2000)
|
|
284
|
-
* }
|
|
285
|
-
* }
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
interface AppAdapter {
|
|
289
|
-
/**
|
|
290
|
-
* Human-readable name for logging and `dependsOn` resolution.
|
|
291
|
-
* Required when the adapter (or any other in the same set) declares
|
|
292
|
-
* `dependsOn` — sort errors will reference adapters by name.
|
|
293
|
-
*/
|
|
294
|
-
name?: string;
|
|
295
|
-
/**
|
|
296
|
-
* Other adapter names that must mount before this one. The framework
|
|
297
|
-
* topologically sorts adapters at boot — cycles or unknown names throw
|
|
298
|
-
* via `MountCycleError` / `MissingMountDepError` so bad configurations
|
|
299
|
-
* fail boot rather than corrupt live traffic.
|
|
300
|
-
*
|
|
301
|
-
* Common pattern: `TenantAdapter` populates `req.tenant` and
|
|
302
|
-
* `AuthAdapter` reads it for tenant-scoped RBAC, so AuthAdapter
|
|
303
|
-
* declares `dependsOn = ['TenantAdapter']`. Adapters without
|
|
304
|
-
* `dependsOn` retain their declaration order.
|
|
305
|
-
*
|
|
306
|
-
* @example
|
|
307
|
-
* ```ts
|
|
308
|
-
* class AuthAdapter implements AppAdapter {
|
|
309
|
-
* name = 'AuthAdapter'
|
|
310
|
-
* dependsOn = ['TenantAdapter']
|
|
311
|
-
* }
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
dependsOn?: readonly KickJsPluginName[];
|
|
315
|
-
/**
|
|
316
|
-
* Return middleware entries to be inserted into the pipeline.
|
|
317
|
-
* The `phase` controls ordering relative to global middleware and routes.
|
|
318
|
-
*/
|
|
319
|
-
middleware?(): AdapterMiddleware[];
|
|
320
|
-
/**
|
|
321
|
-
* Return Context Contributors (#107) that apply to every route in the
|
|
322
|
-
* application. Adapter-level contributors merge into the per-route
|
|
323
|
-
* pipeline at the `'adapter'` precedence level — they win over global
|
|
324
|
-
* contributors but lose to module, class, and method decorators.
|
|
325
|
-
*
|
|
326
|
-
* Useful for cross-cutting concerns: an auth adapter contributing
|
|
327
|
-
* `user`, a multi-tenant adapter contributing `tenant`, etc. Optional.
|
|
328
|
-
*/
|
|
329
|
-
contributors?(): ContributorRegistrations;
|
|
330
|
-
/**
|
|
331
|
-
* Called before global middleware — register early routes (docs UI, health).
|
|
332
|
-
* May return a Promise — async rejections are caught and logged.
|
|
333
|
-
*/
|
|
334
|
-
beforeMount?(ctx: AdapterContext): void | Promise<void>;
|
|
335
|
-
/**
|
|
336
|
-
* Called for each module route that gets mounted.
|
|
337
|
-
* Use this to collect route metadata (e.g. for OpenAPI spec generation).
|
|
338
|
-
*/
|
|
339
|
-
onRouteMount?(controllerClass: Constructor, mountPath: string): void;
|
|
340
|
-
/**
|
|
341
|
-
* Called after modules are registered and the DI container is bootstrapped,
|
|
342
|
-
* before the HTTP server starts listening. **This is the correct hook for
|
|
343
|
-
* adapters that register DI bindings, resolve services, or otherwise prepare
|
|
344
|
-
* container-side state** (e.g. `container.registerInstance(MAILER, ...)`).
|
|
345
|
-
*
|
|
346
|
-
* `beforeStart` runs inside `app.setup()`, which means it also fires under
|
|
347
|
-
* `createTestApp` — adapters using this hook work in unit tests without
|
|
348
|
-
* needing a live HTTP server. See {@link afterStart} for the contrast.
|
|
349
|
-
*
|
|
350
|
-
* May return a Promise — async rejections are caught and logged.
|
|
351
|
-
*/
|
|
352
|
-
beforeStart?(ctx: AdapterContext): void | Promise<void>;
|
|
353
|
-
/**
|
|
354
|
-
* Called after the HTTP server is listening — `ctx.server` is the live
|
|
355
|
-
* `http.Server`. **Use this hook only for work that genuinely needs a
|
|
356
|
-
* listening server**: attaching Socket.IO / WS upgrades, reading the bound
|
|
357
|
-
* port via `server.address()`, dispatching to the local server over HTTP,
|
|
358
|
-
* etc.
|
|
359
|
-
*
|
|
360
|
-
* `afterStart` does NOT fire under `createTestApp`, since tests call
|
|
361
|
-
* `app.setup()` and never `app.start()`. If your adapter only registers DI
|
|
362
|
-
* bindings or resolves services, use {@link beforeStart} — that hook runs
|
|
363
|
-
* in both production (`start()`) and tests (`setup()`).
|
|
364
|
-
*
|
|
365
|
-
* May return a Promise — async rejections are caught and logged.
|
|
366
|
-
*/
|
|
367
|
-
afterStart?(ctx: AdapterContext): void | Promise<void>;
|
|
368
|
-
/**
|
|
369
|
-
* Called by the /health/ready endpoint. Return the health status of your adapter's
|
|
370
|
-
* backing service (database, Redis, queue, etc.).
|
|
371
|
-
*/
|
|
372
|
-
onHealthCheck?(): Promise<{
|
|
373
|
-
name: string;
|
|
374
|
-
status: 'up' | 'down';
|
|
375
|
-
}>;
|
|
376
|
-
/** Called on shutdown — clean up connections */
|
|
377
|
-
shutdown?(): MaybePromise;
|
|
378
|
-
/**
|
|
379
|
-
* Optional DevTools introspection hook (architecture.md §23). Returns
|
|
380
|
-
* a snapshot describing this adapter's current state, metrics, and DI
|
|
381
|
-
* tokens. DevTools awaits the result, so async work is fine — but keep
|
|
382
|
-
* the implementation cheap (counters + flags, no DB round trips) since
|
|
383
|
-
* the topology endpoint polls on a short interval.
|
|
384
|
-
*
|
|
385
|
-
* The return type lives in `@forinda/kickjs` itself ({@link IntrospectionSnapshot})
|
|
386
|
-
* so adopters can author `introspect()` without importing the kit just
|
|
387
|
-
* to satisfy the contract. The kit's own `IntrospectionSnapshot` type
|
|
388
|
-
* stays structurally identical; either import works.
|
|
389
|
-
*/
|
|
390
|
-
introspect?(): IntrospectionSnapshot | Promise<IntrospectionSnapshot>;
|
|
391
|
-
/**
|
|
392
|
-
* Optional DevTools tabs this adapter contributes (architecture.md §23).
|
|
393
|
-
* Returns an array of `DevtoolsTabDescriptor` shapes — typically one
|
|
394
|
-
* entry per adapter-owned panel (iframe / launch / html view).
|
|
395
|
-
*
|
|
396
|
-
* Same untyped-at-this-layer convention as {@link introspect}: adapter
|
|
397
|
-
* authors import `defineDevtoolsTab` (or the bare type) from
|
|
398
|
-
* `@forinda/kickjs-devtools-kit` so `@forinda/kickjs` doesn't take on
|
|
399
|
-
* a runtime dep on the kit.
|
|
400
|
-
*/
|
|
401
|
-
devtoolsTabs?(): readonly unknown[];
|
|
402
|
-
}
|
|
403
|
-
/** Constructor type for AppAdapter classes */
|
|
404
|
-
type AppAdapterClass = new () => AppAdapter;
|
|
405
|
-
//#endregion
|
|
406
|
-
export { MiddlewarePath as a, KickJsPluginName as c, IntrospectFn as d, IntrospectionKind as f, AppAdapterClass as i, KickJsPluginRegistry as l, AdapterMiddleware as n, MiddlewarePhase as o, IntrospectionSnapshot as p, AppAdapter as r, AugmentationMeta as s, AdapterContext as t, defineAugmentation as u };
|
|
407
|
-
//# sourceMappingURL=adapter-CkpcZwzZ.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-CkpcZwzZ.d.mts","names":[],"sources":["../src/core/introspect.ts","../src/core/augmentation.ts","../src/core/adapter.ts"],"mappings":";;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;UAAiB,qBAAA;EAgBf;;;;;;;;;EANA,eAAA;EAoBW;EAlBX,IAAA;EA2B2B;EAzB3B,IAAA,EAAM,iBAAA;EAyBqB;EAvB3B,OAAA;EA8BU;;;;EAzBV,KAAA,GAAQ,MAAA;EAyB+C;EAvBvD,MAAA;IAAW,QAAA;IAA6B,QAAA;EAAA;EAuBuB;;AAAqB;;EAlBpF,OAAA,GAAU,MAAA;;EAEV,WAAA;AAAA;;;AC3BmC;AAUrC;;;KD0BY,iBAAA;ACxBkB;AAY9B;;;;AAZ8B,KD+BlB,YAAA,SAAqB,qBAAA,GAAwB,OAAA,CAAQ,qBAAA;;;;;;;;;;AA9CjE;;;;;;;;;;;;;UCGiB,oBAAA;;;;;;;;AD2BJ;KCjBD,gBAAA,SAAyB,oBAAA,gCAE3B,oBAAoB;;;;ADwBD;AAO7B;;;;;;UCnBiB,gBAAA;EDmB+C;;;;ECd9D,WAAA;EDcoF;;;;AC3CtF;;EAoCE,OAAO;AAAA;AApC4B;AAUrC;;;;AAE8B;AAY9B;;;;AAYS;AAmDT;;;;;;;;AAAwE;;;;AC/ExE;;;;AAA2B;AAc3B;;;;;;;;;;;;AAA4E;AAG5E;;;;;;;ADzBqC,iBAuFrB,kBAAA,CAAmB,IAAA,UAAc,IAAA,GAAO,gBAAgB;;;AD1FxE;;;;;;;;;;;;;;;;;;;;;AAAA,KEWY,eAAA;AFmBC;AASb;;;;AAA6B;AAO7B;;;;;;AAhBa,KELD,cAAA,YAA0B,MAAA,GAAS,aAAA,UAAuB,MAAA;;UAGrD,iBAAA;EFkBwC;;;AAA6B;;;EEXpF,OAAA,EAAS,cAAA,GAAiB,mBAAA;EDhCX;ECkCf,KAAA,GAAQ,eAAA;;;ADlC2B;AAUrC;;EC8BE,IAAA,GAAO,cAAA;AAAA;AD5BqB;AAY9B;;;;AAYS;AAmDT;;;;;;;AA3E8B,UC4Cb,cAAA;ED+BuD;EC7BtE,GAAA,EAAK,OAAA;;EAEL,SAAA,EAAW,SAAA;EApDD;EAsDV,MAAA,GAAS,IAAA,CAAK,MAAA;;EAEd,GAAA;EAxDyB;EA0DzB,YAAA;AAAA;;;;;;;;;;;AA5C0E;AAG5E;;;;;;;;;;;;;;;;;UAwEiB,UAAA;EAzCA;;;;;EA+Cf,IAAA;EAzCoB;;;;;;;;;;;;AAIR;AA+Bd;;;;;;EA2BE,SAAA,YAAqB,gBAAA;EAuBqB;;;;EAjB1C,UAAA,KAAe,iBAAA;EAqD0B;;;;;;;;;EA1CzC,YAAA,KAAiB,wBAAA;EAjBI;;;;EAuBrB,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;EAA1C;;;;EAMA,YAAA,EAAc,eAAA,EAAiB,WAAA,EAAa,SAAA;EAAb;;;;;;;;;;;;EAc/B,WAAA,EAAa,GAAA,EAAK,cAAA,UAAwB,OAAA;EAsBd;;;;;;;;;;AA6BhB;AAId;;;EAvCE,UAAA,EAAY,GAAA,EAAK,cAAA,UAAwB,OAAA;EAuCO;;;;EAjChD,aAAA,KAAkB,OAAA;IAAU,IAAA;IAAc,MAAA;EAAA;;EAG1C,QAAA,KAAa,YAAA;;;;;;;;;;;;;EAcb,UAAA,KAAe,qBAAA,GAAwB,OAAA,CAAQ,qBAAA;;;;;;;;;;;EAY/C,YAAA;AAAA;;KAIU,eAAA,aAA4B,UAAU"}
|