@forinda/kickjs 6.5.0 → 6.5.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-CEt1MEdF.d.mts → adapter-CbMq-NBf.d.mts} +25 -381
- package/dist/adapter-CbMq-NBf.d.mts.map +1 -0
- package/dist/{app-module-BSpHKlhE.d.mts → app-module-DtoySG6l.d.mts} +6 -5
- package/dist/app-module-DtoySG6l.d.mts.map +1 -0
- package/dist/application-Cl0JlmNY.mjs +12 -0
- package/dist/application-Cl0JlmNY.mjs.map +1 -0
- package/dist/{application-Bzdzl5wP.d.mts → application-zlzYGgKD.d.mts} +6 -6
- package/dist/application-zlzYGgKD.d.mts.map +1 -0
- package/dist/{bootstrap-C1VGQQVF.mjs → bootstrap-DzyWLYpU.mjs} +3 -3
- package/dist/{bootstrap-C1VGQQVF.mjs.map → bootstrap-DzyWLYpU.mjs.map} +1 -1
- package/dist/{bootstrap-DYexY169.d.mts → bootstrap-Nzgi7K2d.d.mts} +2 -3
- package/dist/bootstrap-Nzgi7K2d.d.mts.map +1 -0
- package/dist/{cache-CwZzIH0D.d.mts → cache-C0qL0NSD.d.mts} +2 -1
- package/dist/cache-C0qL0NSD.d.mts.map +1 -0
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-BeIZJBXA.mjs → config-CwFPFwsN.mjs} +3 -3
- package/dist/{config-BeIZJBXA.mjs.map → config-CwFPFwsN.mjs.map} +1 -1
- package/dist/{container-iED1swkd.d.mts → container-BW_MlgLj.d.mts} +3 -2
- package/dist/container-BW_MlgLj.d.mts.map +1 -0
- package/dist/{container-CBaL5lus.mjs → container-C7kmdVwh.mjs} +3 -3
- package/dist/{container-CBaL5lus.mjs.map → container-C7kmdVwh.mjs.map} +1 -1
- package/dist/{context-BS5o1IuU.mjs → context-DQaUwwQM.mjs} +3 -3
- package/dist/{context-BS5o1IuU.mjs.map → context-DQaUwwQM.mjs.map} +1 -1
- package/dist/{context-errors-CwD27Vbj.mjs → context-errors-97x9siRx.mjs} +2 -2
- package/dist/{context-errors-CwD27Vbj.mjs.map → context-errors-97x9siRx.mjs.map} +1 -1
- 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.d.mts +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/container.d.mts +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.d.mts +1 -1
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +1 -1
- package/dist/core/interfaces.d.mts +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.d.mts +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/core-CLmwVWlw.mjs +12 -0
- package/dist/core-CLmwVWlw.mjs.map +1 -0
- package/dist/{cors-C4aSCD3J.d.mts → cors-BuDU9CpA.d.mts} +1 -2
- package/dist/cors-BuDU9CpA.d.mts.map +1 -0
- package/dist/cron-DOOtTY4q.d.mts.map +1 -1
- package/dist/{csrf-DNh_7aOk.mjs → csrf-BsrsObK-.mjs} +2 -2
- package/dist/{csrf-DNh_7aOk.mjs.map → csrf-BsrsObK-.mjs.map} +1 -1
- package/dist/{csrf-7nUXGTuz.d.mts → csrf-vR23CJas.d.mts} +1 -2
- package/dist/csrf-vR23CJas.d.mts.map +1 -0
- package/dist/{decorators-wEJBqXHg.d.mts → decorators-Bks7cgBJ.d.mts} +12 -7
- package/dist/decorators-Bks7cgBJ.d.mts.map +1 -0
- package/dist/{disposables-mnjJuaVx.mjs → disposables-D46xX96x.mjs} +2 -2
- package/dist/{disposables-mnjJuaVx.mjs.map → disposables-D46xX96x.mjs.map} +1 -1
- package/dist/env-Biq_60jq.mjs +13 -0
- package/dist/{env-Dgtjncd5.mjs.map → env-Biq_60jq.mjs.map} +1 -1
- package/dist/{error-handler-DR01K_rI.d.mts → error-handler-Cr6Yt9as.d.mts} +1 -2
- package/dist/error-handler-Cr6Yt9as.d.mts.map +1 -0
- package/dist/{errors-n0H96eEz.d.mts → errors-By6UueCm.d.mts} +18 -9
- package/dist/errors-By6UueCm.d.mts.map +1 -0
- package/dist/{handler-UvmjQGYc.mjs → handler-Ci1NMv-9.mjs} +3 -3
- package/dist/{handler-UvmjQGYc.mjs.map → handler-Ci1NMv-9.mjs.map} +1 -1
- package/dist/{helmet-CKzZzeNl.d.mts → helmet-CFQUTVig.d.mts} +1 -2
- package/dist/helmet-CFQUTVig.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.d.mts +1 -1
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.d.mts +1 -1
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/error-handler.d.mts +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.d.mts +1 -1
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.d.mts +1 -1
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/request-id.d.mts +1 -1
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.d.mts +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.d.mts +1 -1
- package/dist/http/middleware/session.mjs +2 -2
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/spa.mjs.map +1 -1
- package/dist/http/middleware/upload.d.mts +1 -1
- package/dist/http/middleware/upload.mjs +2 -2
- package/dist/http/middleware/upload.mjs.map +1 -1
- package/dist/http/middleware/validate.d.mts +1 -1
- package/dist/http/middleware/validate.mjs +1 -1
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -3
- package/dist/http/query/index.d.mts +1 -1
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +1 -1
- package/dist/http/router-builder.mjs +2 -3
- package/dist/http/runtimes/fastify.d.mts +1 -2
- package/dist/http/runtimes/fastify.d.mts.map +1 -1
- package/dist/http/runtimes/fastify.mjs +3 -3
- package/dist/http/runtimes/fastify.mjs.map +1 -1
- package/dist/http/runtimes/h3-web.d.mts +1 -2
- package/dist/http/runtimes/h3-web.d.mts.map +1 -1
- package/dist/http/runtimes/h3-web.mjs +2 -2
- package/dist/http/runtimes/h3.d.mts +1 -2
- package/dist/http/runtimes/h3.d.mts.map +1 -1
- package/dist/http/runtimes/h3.mjs +2 -2
- package/dist/{index-BtWJ9SLP.d.mts → index-BfT5KZ-M.d.mts} +2 -2
- package/dist/index-BfT5KZ-M.d.mts.map +1 -0
- package/dist/{index-D98NLfS5.d.mts → index-M6TF75MS.d.mts} +2 -3
- package/dist/index-M6TF75MS.d.mts.map +1 -0
- package/dist/index.d.mts +26 -26
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{interfaces-CayXPOAf.d.mts → interfaces-BTTBdkvG.d.mts} +3 -2
- package/dist/interfaces-BTTBdkvG.d.mts.map +1 -0
- package/dist/{kv-stores-O8HUSwpv.mjs → kv-stores-BLJdf3Fn.mjs} +2 -2
- package/dist/{kv-stores-O8HUSwpv.mjs.map → kv-stores-BLJdf3Fn.mjs.map} +1 -1
- package/dist/{kv-stores-duYHIEr1.d.mts → kv-stores-CHowq8VP.d.mts} +5 -6
- package/dist/kv-stores-CHowq8VP.d.mts.map +1 -0
- package/dist/logger-DA43DvNY.d.mts.map +1 -1
- package/dist/{metadata-CUDfhy4e.mjs → metadata-DUBbuHqY.mjs} +2 -2
- package/dist/{metadata-CUDfhy4e.mjs.map → metadata-DUBbuHqY.mjs.map} +1 -1
- package/dist/{module-registry-Mv5FqVlq.mjs → module-registry-aIt66if2.mjs} +2 -2
- package/dist/{module-registry-Mv5FqVlq.mjs.map → module-registry-aIt66if2.mjs.map} +1 -1
- package/dist/path-BVA9MfN1.d.mts.map +1 -1
- package/dist/query-CXN52dzy.mjs +12 -0
- package/dist/{query-gMAVXzx2.mjs.map → query-CXN52dzy.mjs.map} +1 -1
- package/dist/{rate-limit-oLL5EPUf.d.mts → rate-limit-Dme747JJ.d.mts} +1 -2
- package/dist/rate-limit-Dme747JJ.d.mts.map +1 -0
- package/dist/{reactivity-XL0fFDvG.d.mts → reactivity-BkMNA0kp.d.mts} +2 -2
- package/dist/reactivity-BkMNA0kp.d.mts.map +1 -0
- package/dist/{reply-BMBvs-FB.mjs → reply-C1ljl6xS.mjs} +3 -3
- package/dist/{reply-BMBvs-FB.mjs.map → reply-C1ljl6xS.mjs.map} +1 -1
- package/dist/{request-id-IDobbxU-.d.mts → request-id-CVzJ1uHD.d.mts} +1 -2
- package/dist/request-id-CVzJ1uHD.d.mts.map +1 -0
- package/dist/{request-logger-DZVW6VNI.d.mts → request-logger-BU4ulKLp.d.mts} +1 -2
- package/dist/request-logger-BU4ulKLp.d.mts.map +1 -0
- package/dist/router-builder-BbgVXuy3.mjs +12 -0
- package/dist/router-builder-BbgVXuy3.mjs.map +1 -0
- package/dist/{router-builder-GWgxoOdC.d.mts → router-builder-CMGhEBU2.d.mts} +2 -3
- package/dist/router-builder-CMGhEBU2.d.mts.map +1 -0
- package/dist/{session-DSRA-PUX.d.mts → session-z9iewOXA.d.mts} +1 -2
- package/dist/session-z9iewOXA.d.mts.map +1 -0
- package/dist/{spa-DWzSWAzx.d.mts → spa-DsRUrm69.d.mts} +4 -9
- package/dist/spa-DsRUrm69.d.mts.map +1 -0
- package/dist/{upload-CIZc803m.d.mts → upload-XVTyQcNN.d.mts} +3 -3
- package/dist/upload-XVTyQcNN.d.mts.map +1 -0
- package/dist/{upload-config-CFfHvoHF.mjs → upload-config-Dd_QvlpC.mjs} +2 -2
- package/dist/{upload-config-CFfHvoHF.mjs.map → upload-config-Dd_QvlpC.mjs.map} +1 -1
- package/dist/{validate-DoZDOhCi.d.mts → validate-DMYpUnrf.d.mts} +1 -2
- package/dist/validate-DMYpUnrf.d.mts.map +1 -0
- package/dist/views-Dj6XFaca.mjs +12 -0
- package/dist/views-Dj6XFaca.mjs.map +1 -0
- package/dist/views-DsfBT1fR.d.mts +659 -0
- package/dist/views-DsfBT1fR.d.mts.map +1 -0
- package/dist/web.d.mts +4 -5
- package/dist/web.d.mts.map +1 -1
- package/dist/web.mjs +2 -2
- package/dist/web.mjs.map +1 -1
- package/package.json +10 -10
- package/dist/adapter-CEt1MEdF.d.mts.map +0 -1
- package/dist/app-module-BSpHKlhE.d.mts.map +0 -1
- package/dist/application-Bzdzl5wP.d.mts.map +0 -1
- package/dist/application-C-r79XqD.mjs +0 -12
- package/dist/application-C-r79XqD.mjs.map +0 -1
- package/dist/bootstrap-DYexY169.d.mts.map +0 -1
- package/dist/cache-CwZzIH0D.d.mts.map +0 -1
- package/dist/container-iED1swkd.d.mts.map +0 -1
- package/dist/contributor-runner-Cu13cDQp.mjs +0 -12
- package/dist/contributor-runner-Cu13cDQp.mjs.map +0 -1
- package/dist/core-TDR0XGzO.mjs +0 -12
- package/dist/core-TDR0XGzO.mjs.map +0 -1
- package/dist/cors-C4aSCD3J.d.mts.map +0 -1
- package/dist/csrf-7nUXGTuz.d.mts.map +0 -1
- package/dist/decorators-wEJBqXHg.d.mts.map +0 -1
- package/dist/env-Dgtjncd5.mjs +0 -13
- package/dist/error-handler-DR01K_rI.d.mts.map +0 -1
- package/dist/errors-n0H96eEz.d.mts.map +0 -1
- package/dist/helmet-CKzZzeNl.d.mts.map +0 -1
- package/dist/http/middleware/views.mjs.map +0 -1
- package/dist/http/router-builder.mjs.map +0 -1
- package/dist/index-BtWJ9SLP.d.mts.map +0 -1
- package/dist/index-D98NLfS5.d.mts.map +0 -1
- package/dist/interfaces-CayXPOAf.d.mts.map +0 -1
- package/dist/kv-stores-duYHIEr1.d.mts.map +0 -1
- package/dist/query-gMAVXzx2.mjs +0 -12
- package/dist/rate-limit-oLL5EPUf.d.mts.map +0 -1
- package/dist/reactivity-XL0fFDvG.d.mts.map +0 -1
- package/dist/request-id-IDobbxU-.d.mts.map +0 -1
- package/dist/request-logger-DZVW6VNI.d.mts.map +0 -1
- package/dist/rolldown-runtime-CuwksmWW.mjs +0 -11
- package/dist/router-builder-GWgxoOdC.d.mts.map +0 -1
- package/dist/session-DSRA-PUX.d.mts.map +0 -1
- package/dist/spa-DWzSWAzx.d.mts.map +0 -1
- package/dist/upload-CIZc803m.d.mts.map +0 -1
- package/dist/validate-DoZDOhCi.d.mts.map +0 -1
- package/dist/views-Kp8Z3AO1.d.mts +0 -275
- package/dist/views-Kp8Z3AO1.d.mts.map +0 -1
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
|
|
2
|
+
import "./index-M6TF75MS.mjs";
|
|
3
|
+
import { f as DepValue, o as ContextDecorator, s as ContextDecoratorSpec, v as MetaValue } from "./app-module-DtoySG6l.mjs";
|
|
4
|
+
import { T as RequestContext, f as HttpRuntime, k as AdapterFactory, m as RouteEntry } from "./adapter-CbMq-NBf.mjs";
|
|
5
|
+
import "./application-zlzYGgKD.mjs";
|
|
6
|
+
import "./bootstrap-Nzgi7K2d.mjs";
|
|
7
|
+
import "./cors-BuDU9CpA.mjs";
|
|
8
|
+
import "./csrf-vR23CJas.mjs";
|
|
9
|
+
import "./error-handler-Cr6Yt9as.mjs";
|
|
10
|
+
import "./helmet-CFQUTVig.mjs";
|
|
11
|
+
import "./rate-limit-Dme747JJ.mjs";
|
|
12
|
+
import "./request-id-CVzJ1uHD.mjs";
|
|
13
|
+
import "./request-logger-BU4ulKLp.mjs";
|
|
14
|
+
import "./session-z9iewOXA.mjs";
|
|
15
|
+
import "./spa-DsRUrm69.mjs";
|
|
16
|
+
import "./upload-XVTyQcNN.mjs";
|
|
17
|
+
import "./validate-DMYpUnrf.mjs";
|
|
18
|
+
import "./kv-stores-CHowq8VP.mjs";
|
|
19
|
+
import { t as BuildRoutesOptions } from "./router-builder-CMGhEBU2.mjs";
|
|
20
|
+
import { Express, NextFunction, Request, Response, Router } from "express";
|
|
21
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
22
|
+
//#region src/core/disposables.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* Registry for framework-owned resources that hold timers or other handles
|
|
25
|
+
* outside the adapter/plugin lifecycle — e.g. the in-memory session and
|
|
26
|
+
* rate-limit stores' cleanup intervals. `Application.shutdown()` drains it so
|
|
27
|
+
* startup and shutdown stay symmetric even for resources created lazily by
|
|
28
|
+
* middleware factories.
|
|
29
|
+
*
|
|
30
|
+
* Intervals are `.unref()`'d so they never wedge process exit — this registry
|
|
31
|
+
* exists for IN-PROCESS teardown (test suites, HMR, multi-app hosts) where
|
|
32
|
+
* each un-disposed store would otherwise leak a live interval + backing Map
|
|
33
|
+
* per app instance.
|
|
34
|
+
*/
|
|
35
|
+
type Disposable = () => void | Promise<void>;
|
|
36
|
+
/** Register a cleanup callback. Returns an unregister function. */
|
|
37
|
+
declare function registerDisposable(fn: Disposable): () => void;
|
|
38
|
+
/** Run and clear all registered disposables. Errors are swallowed per-entry. */
|
|
39
|
+
declare function disposeAll(): Promise<void>;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/kick-error.d.ts
|
|
42
|
+
/**
|
|
43
|
+
* Structured framework error with code, cause, and actionable fix hint.
|
|
44
|
+
*
|
|
45
|
+
* The goal is "the developer who hits this knows what to do next." A
|
|
46
|
+
* cryptic `Error('No binding found for: UserService')` becomes a
|
|
47
|
+
* multi-line explanation pointing at the likely cause, the exact code
|
|
48
|
+
* change to apply, and a docs link.
|
|
49
|
+
*
|
|
50
|
+
* `.message` carries the full multi-line plain-text body so Node's
|
|
51
|
+
* default `Error.toString()` and unhandled-exception printing still
|
|
52
|
+
* surface the helpful version. Call {@link formatKickError} to render a
|
|
53
|
+
* colorized version for terminals.
|
|
54
|
+
*
|
|
55
|
+
* Per-error factories live in `kick-errors.ts` — those are the public
|
|
56
|
+
* entry points framework code uses. `KickError` is exported so adopters
|
|
57
|
+
* can build their own structured errors using the same shape.
|
|
58
|
+
*/
|
|
59
|
+
interface KickErrorInit {
|
|
60
|
+
/** Short stable identifier (e.g. `KICK001`, `NO_PROVIDER`). */
|
|
61
|
+
code: string;
|
|
62
|
+
/** One-line headline. */
|
|
63
|
+
summary: string;
|
|
64
|
+
/** Multi-line explanation of why this happened. */
|
|
65
|
+
cause?: string;
|
|
66
|
+
/** Multi-line actionable fix — show exact code if possible. */
|
|
67
|
+
fix?: string;
|
|
68
|
+
/** Absolute URL to the docs page that covers this error. */
|
|
69
|
+
docsUrl?: string;
|
|
70
|
+
/** Arbitrary structured fields for log consumers / debug tooling. */
|
|
71
|
+
context?: Record<string, unknown>;
|
|
72
|
+
}
|
|
73
|
+
declare class KickError extends Error {
|
|
74
|
+
readonly code: string;
|
|
75
|
+
readonly summary: string;
|
|
76
|
+
readonly cause?: string;
|
|
77
|
+
readonly fix?: string;
|
|
78
|
+
readonly docsUrl?: string;
|
|
79
|
+
readonly context?: Record<string, unknown>;
|
|
80
|
+
constructor(init: KickErrorInit);
|
|
81
|
+
}
|
|
82
|
+
interface FormatKickErrorOptions {
|
|
83
|
+
/**
|
|
84
|
+
* Render ANSI colour codes. Defaults to TTY detection (`NO_COLOR` /
|
|
85
|
+
* `FORCE_COLOR` env vars honoured). Pass `false` for log files,
|
|
86
|
+
* structured loggers, or HTTP response bodies.
|
|
87
|
+
*/
|
|
88
|
+
color?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Render a {@link KickErrorInit} (or {@link KickError} instance) into a
|
|
92
|
+
* multi-line human-readable string. Identical layout regardless of
|
|
93
|
+
* colour — the colour flag only toggles ANSI codes.
|
|
94
|
+
*/
|
|
95
|
+
declare function formatKickError(err: KickErrorInit | KickError, options?: FormatKickErrorOptions): string;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/core/circuit-breaker.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* Circuit Breaker pattern for external service calls.
|
|
100
|
+
*
|
|
101
|
+
* Protects your application from cascading failures when downstream
|
|
102
|
+
* services are unhealthy by short-circuiting requests after a
|
|
103
|
+
* configurable failure threshold.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const breaker = new CircuitBreaker('payment-api', {
|
|
108
|
+
* failureThreshold: 5,
|
|
109
|
+
* resetTimeout: 30_000,
|
|
110
|
+
* })
|
|
111
|
+
*
|
|
112
|
+
* const result = await breaker.execute(() => fetch('https://payment.example.com/charge'))
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
type CircuitBreakerState = 'closed' | 'open' | 'half_open';
|
|
116
|
+
interface CircuitBreakerOptions {
|
|
117
|
+
/** Number of consecutive failures before the circuit opens. */
|
|
118
|
+
failureThreshold: number;
|
|
119
|
+
/** Milliseconds to wait before transitioning from OPEN to HALF_OPEN. */
|
|
120
|
+
resetTimeout: number;
|
|
121
|
+
/** Max requests allowed in HALF_OPEN state before deciding (default 1). */
|
|
122
|
+
halfOpenMax?: number;
|
|
123
|
+
}
|
|
124
|
+
interface CircuitBreakerStats {
|
|
125
|
+
failures: number;
|
|
126
|
+
successes: number;
|
|
127
|
+
state: CircuitBreakerState;
|
|
128
|
+
lastFailure?: Date;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Error thrown when the circuit is open and calls are being rejected.
|
|
132
|
+
*/
|
|
133
|
+
declare class CircuitOpenError extends Error {
|
|
134
|
+
readonly breakerName: string;
|
|
135
|
+
constructor(breakerName: string);
|
|
136
|
+
}
|
|
137
|
+
declare class CircuitBreaker {
|
|
138
|
+
readonly name: string;
|
|
139
|
+
private state;
|
|
140
|
+
private failures;
|
|
141
|
+
private successes;
|
|
142
|
+
private halfOpenAttempts;
|
|
143
|
+
private lastFailure?;
|
|
144
|
+
private openedAt?;
|
|
145
|
+
private readonly failureThreshold;
|
|
146
|
+
private readonly resetTimeout;
|
|
147
|
+
private readonly halfOpenMax;
|
|
148
|
+
constructor(name: string, options: CircuitBreakerOptions);
|
|
149
|
+
/**
|
|
150
|
+
* Execute an async function through the circuit breaker.
|
|
151
|
+
* Throws `CircuitOpenError` if the circuit is open.
|
|
152
|
+
*/
|
|
153
|
+
execute<T>(fn: () => Promise<T>): Promise<T>;
|
|
154
|
+
/** Returns the current circuit state. */
|
|
155
|
+
getState(): CircuitBreakerState;
|
|
156
|
+
/** Returns current statistics. */
|
|
157
|
+
getStats(): CircuitBreakerStats;
|
|
158
|
+
/** Manually reset the circuit breaker to CLOSED state. */
|
|
159
|
+
reset(): void;
|
|
160
|
+
private onSuccess;
|
|
161
|
+
private onFailure;
|
|
162
|
+
private maybeTransitionToHalfOpen;
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/core/context-errors.d.ts
|
|
166
|
+
/**
|
|
167
|
+
* Errors thrown by the Context Contributor pipeline.
|
|
168
|
+
*
|
|
169
|
+
* `MissingContributorError`, `ContributorCycleError`, and
|
|
170
|
+
* `DuplicateContributorError` are startup-time errors raised during
|
|
171
|
+
* pipeline build (topo-sort + validation), not per-request — a
|
|
172
|
+
* misconfigured app fails to boot rather than fails a request. Per the
|
|
173
|
+
* locked design in `architecture.md` §20.4, the pipeline is validated
|
|
174
|
+
* once when each route is mounted and the resolved order is cached on
|
|
175
|
+
* the route.
|
|
176
|
+
*
|
|
177
|
+
* `MissingContextValueError` is the one request-time error here: it is
|
|
178
|
+
* raised by `ctx.require(key)` when a value a handler declared it needs
|
|
179
|
+
* is absent. See its doc comment for why that case can't be caught at
|
|
180
|
+
* startup today.
|
|
181
|
+
*/
|
|
182
|
+
/**
|
|
183
|
+
* A contributor declared `dependsOn: ['<key>']` but no other contributor
|
|
184
|
+
* (at any precedence level) produces that key for the same route.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```text
|
|
188
|
+
* MissingContributorError: Missing context contributor 'tenant' required by 'project' on route GET /projects/:id
|
|
189
|
+
* declared at src/contributors/load-project.ts:42:18
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare class MissingContributorError extends Error {
|
|
193
|
+
readonly key: string;
|
|
194
|
+
readonly dependent: string;
|
|
195
|
+
readonly route?: string;
|
|
196
|
+
readonly dependentDefinedAt?: string;
|
|
197
|
+
constructor(key: string, dependent: string, route?: string, dependentDefinedAt?: string);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* `ctx.require(key)` found no value under `key` in the per-request
|
|
201
|
+
* metadata store.
|
|
202
|
+
*
|
|
203
|
+
* Thrown at request time, by design. `ctx.get(key)` returns
|
|
204
|
+
* `T | undefined` for every key, so the usual workaround is a
|
|
205
|
+
* non-null assertion — `ctx.get('tenant')!` — which compiles whether or
|
|
206
|
+
* not the route actually carries the contributor that produces it. On
|
|
207
|
+
* an authorization value that is the worst possible thing to leave
|
|
208
|
+
* untypeable: dropping the decorator produces no diagnostic anywhere,
|
|
209
|
+
* and the handler reads `undefined` as though it were a real value.
|
|
210
|
+
*
|
|
211
|
+
* `ctx.require()` converts that silent hole into a loud, named failure
|
|
212
|
+
* that points at the missing contributor.
|
|
213
|
+
*
|
|
214
|
+
* A handler typed with a generated route type (`Ctx<KickRoutes…>`) also
|
|
215
|
+
* gets compile-time narrowing, so a dropped decorator fails `tsc` rather
|
|
216
|
+
* than reaching this error at all. This error remains the backstop for
|
|
217
|
+
* routes typegen couldn't prove (module/adapter/bootstrap registrations),
|
|
218
|
+
* handlers typed as plain `RequestContext`, and contributors that ran but
|
|
219
|
+
* resolved to `undefined`. See `architecture.md` §20.14.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```text
|
|
223
|
+
* MissingContextValueError: No context value for 'tenantPerm' on GET /projects/:id
|
|
224
|
+
* Nothing wrote this key before the handler ran. Either the contributor
|
|
225
|
+
* that produces it isn't applied to this route, or it ran and resolved
|
|
226
|
+
* to undefined (check `optional: true` contributors).
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare class MissingContextValueError extends Error {
|
|
230
|
+
readonly key: string;
|
|
231
|
+
readonly route?: string;
|
|
232
|
+
constructor(key: string, route?: string);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Topo-sort detected a cycle in `dependsOn` declarations. The `cycle` field
|
|
236
|
+
* lists the keys in the order they form the loop, with the first key
|
|
237
|
+
* repeated at the end so the path reads naturally.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```text
|
|
241
|
+
* ContributorCycleError: Cycle in context contributors on route GET /projects/:id: tenant → project → tenant
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
declare class ContributorCycleError extends Error {
|
|
245
|
+
readonly cycle: readonly string[];
|
|
246
|
+
readonly route?: string;
|
|
247
|
+
constructor(cycle: readonly string[], route?: string);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Two contributors at the same precedence level both produce the same key
|
|
251
|
+
* for the same route. Precedence resolution (method > class > module >
|
|
252
|
+
* adapter > global, per architecture.md §20.4) silently drops
|
|
253
|
+
* lower-precedence duplicates; this error fires only when ties occur
|
|
254
|
+
* within a single level — e.g., two method-level decorators declaring
|
|
255
|
+
* `key: 'tenant'`.
|
|
256
|
+
*
|
|
257
|
+
* `sources` is best-effort identifying labels for each conflicting
|
|
258
|
+
* registration (typically the decorator's call site or registering
|
|
259
|
+
* module/adapter name).
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```text
|
|
263
|
+
* DuplicateContributorError: Duplicate context contributor for key 'tenant' at the same precedence level. Sources: LoadTenantFromHeader, LoadTenantFromSubdomain
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
declare class DuplicateContributorError extends Error {
|
|
267
|
+
readonly key: string;
|
|
268
|
+
readonly sources: readonly string[];
|
|
269
|
+
constructor(key: string, sources: readonly string[]);
|
|
270
|
+
}
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/core/mount-sort.d.ts
|
|
273
|
+
/**
|
|
274
|
+
* Topological sort for plugins and adapters with `dependsOn` declarations.
|
|
275
|
+
*
|
|
276
|
+
* Mirrors the algorithm used by the Context Contributor pipeline
|
|
277
|
+
* (`contributor-pipeline.ts:topoSort`) but operates on a name-keyed
|
|
278
|
+
* `MountSortItem` shape rather than a `ContributorRegistration`. Kept
|
|
279
|
+
* standalone instead of factored generic so that:
|
|
280
|
+
*
|
|
281
|
+
* 1. The contributor pipeline doesn't need refactoring (risk reduction).
|
|
282
|
+
* 2. The error classes can carry plugin/adapter-specific diagnostic
|
|
283
|
+
* fields (`kind`, `dependent`) without bending the contributor types.
|
|
284
|
+
*/
|
|
285
|
+
/**
|
|
286
|
+
* A plugin or adapter that participates in dependency-ordered mounting.
|
|
287
|
+
* Both `KickPlugin` and `AppAdapter` satisfy this shape via their `name`
|
|
288
|
+
* and `dependsOn` fields.
|
|
289
|
+
*/
|
|
290
|
+
interface MountSortItem {
|
|
291
|
+
/** Unique mount name within the plugin/adapter set being sorted. */
|
|
292
|
+
name: string;
|
|
293
|
+
/**
|
|
294
|
+
* Other plugin/adapter names that must mount before this one. Cycles
|
|
295
|
+
* and missing names fail at boot — same fail-fast contract as the
|
|
296
|
+
* Context Contributor pipeline (architecture.md §20.4).
|
|
297
|
+
*/
|
|
298
|
+
dependsOn?: readonly string[];
|
|
299
|
+
}
|
|
300
|
+
/** What kind of mount set the sort is operating on — surfaces in error messages. */
|
|
301
|
+
type MountKind = 'plugin' | 'adapter';
|
|
302
|
+
/**
|
|
303
|
+
* Two items in the same mount set declared the same `name`. Plugin/adapter
|
|
304
|
+
* names must be unique so `dependsOn` references resolve unambiguously.
|
|
305
|
+
*/
|
|
306
|
+
declare class DuplicateMountNameError extends Error {
|
|
307
|
+
readonly kind: MountKind;
|
|
308
|
+
readonly mountName: string;
|
|
309
|
+
constructor(kind: MountKind, mountName: string);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* A `dependsOn` entry references a plugin/adapter that isn't in the
|
|
313
|
+
* current set. The dependency might not be installed, might be misspelled,
|
|
314
|
+
* or might live in a different mount set (plugin referencing an adapter,
|
|
315
|
+
* or vice versa — they sort independently).
|
|
316
|
+
*/
|
|
317
|
+
declare class MissingMountDepError extends Error {
|
|
318
|
+
readonly kind: MountKind;
|
|
319
|
+
readonly missing: string;
|
|
320
|
+
readonly dependent: string;
|
|
321
|
+
constructor(kind: MountKind, missing: string, dependent: string);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* The `dependsOn` declarations form a cycle. Boot fails so the cycle
|
|
325
|
+
* can't poison live traffic. The `cycle` field reports one path through
|
|
326
|
+
* the offending nodes for diagnostics — formatted `A → B → C → A`.
|
|
327
|
+
*/
|
|
328
|
+
declare class MountCycleError extends Error {
|
|
329
|
+
readonly kind: MountKind;
|
|
330
|
+
readonly cycle: readonly string[];
|
|
331
|
+
constructor(kind: MountKind, cycle: readonly string[]);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Topologically sort `items` so every item with `dependsOn: ['X']` mounts
|
|
335
|
+
* after `X`. Items without `dependsOn` keep their input order via Kahn's
|
|
336
|
+
* algorithm with a FIFO queue seeded in input order — preserves the
|
|
337
|
+
* historical "plugins/adapters mount in declaration order" behaviour for
|
|
338
|
+
* any set that doesn't use `dependsOn`.
|
|
339
|
+
*
|
|
340
|
+
* @param items - mountable items, e.g. plugins or adapters
|
|
341
|
+
* @param kind - 'plugin' | 'adapter', used in error messages
|
|
342
|
+
* @returns a new array in valid mount order
|
|
343
|
+
* @throws {DuplicateMountNameError} two items share a name
|
|
344
|
+
* @throws {MissingMountDepError} a `dependsOn` references an unknown name
|
|
345
|
+
* @throws {MountCycleError} the dep graph contains a cycle
|
|
346
|
+
*/
|
|
347
|
+
declare function mountSort<T extends MountSortItem>(items: readonly T[], kind: MountKind): T[];
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/core/asset-keys.d.ts
|
|
350
|
+
type AssetKeyStrategy = 'auto' | 'strip' | 'with-extension';
|
|
351
|
+
interface AssetKeyPair {
|
|
352
|
+
/** Source-relative path the file was discovered at. */
|
|
353
|
+
rel: string;
|
|
354
|
+
/** Final logical key for the manifest, including the namespace prefix. */
|
|
355
|
+
key: string;
|
|
356
|
+
}
|
|
357
|
+
interface GroupAssetKeysOptions {
|
|
358
|
+
/**
|
|
359
|
+
* Strategy applied to this namespace. Default `'auto'`.
|
|
360
|
+
*
|
|
361
|
+
* Adopters override per-namespace via `assetMap.<ns>.keys` in
|
|
362
|
+
* kick.config.ts when they want uniform behaviour (e.g. always
|
|
363
|
+
* include the extension regardless of collisions).
|
|
364
|
+
*/
|
|
365
|
+
strategy?: AssetKeyStrategy;
|
|
366
|
+
}
|
|
367
|
+
interface GroupAssetKeysResult {
|
|
368
|
+
pairs: AssetKeyPair[];
|
|
369
|
+
/**
|
|
370
|
+
* Number of collision groups resolved by keeping extensions.
|
|
371
|
+
* Surfaces as an informational log ("auto-resolved N collisions")
|
|
372
|
+
* so adopters know whether they're relying on auto-mode or not.
|
|
373
|
+
* Always 0 for `'strip'` (overwrites) and `'with-extension'`
|
|
374
|
+
* (extensions always preserved, no collision possible).
|
|
375
|
+
*/
|
|
376
|
+
collisionGroupsResolved: number;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Compute final manifest keys for a namespace's discovered paths,
|
|
380
|
+
* given the chosen strategy. Pure function — no fs / config / globals
|
|
381
|
+
* involved.
|
|
382
|
+
*
|
|
383
|
+
* @param namespace assetMap key — e.g. `'mails'`, `'pages'`.
|
|
384
|
+
* @param paths source-relative file paths (POSIX separators) discovered
|
|
385
|
+
* under the namespace's `src` directory.
|
|
386
|
+
* @param opts grouping options.
|
|
387
|
+
*/
|
|
388
|
+
declare function groupAssetKeys(namespace: string, paths: readonly string[], opts?: GroupAssetKeysOptions): GroupAssetKeysResult;
|
|
389
|
+
/** Strip the final extension from a path. `'mails/welcome.ejs'` → `'mails/welcome'`. */
|
|
390
|
+
declare function stripExt(path: string): string;
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/http/cluster.d.ts
|
|
393
|
+
interface ClusterOptions {
|
|
394
|
+
/** Number of worker processes (default: os.cpus().length) */
|
|
395
|
+
workers?: number;
|
|
396
|
+
/** Delay before forcefully killing a worker during shutdown (ms), default: 5000 */
|
|
397
|
+
gracefulShutdownTimeout?: number;
|
|
398
|
+
/** Delay between worker restarts (ms), default: 1000 */
|
|
399
|
+
restartDelay?: number;
|
|
400
|
+
/** Max failures in restartWindow before refusing to restart, default: 5 */
|
|
401
|
+
maxFailures?: number;
|
|
402
|
+
/** Time window for counting failures (ms), default: 30000 */
|
|
403
|
+
restartWindow?: number;
|
|
404
|
+
}
|
|
405
|
+
/** Returns true if the current process is the cluster primary */
|
|
406
|
+
declare function isClusterPrimary(): boolean;
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region src/http/define-http-context-decorator.d.ts
|
|
409
|
+
/**
|
|
410
|
+
* Curried form returned by {@link DefineHttpContextDecoratorFn.withParams}.
|
|
411
|
+
* Spell only the per-call params shape `P`; `K` and `D` are inferred
|
|
412
|
+
* from the spec, and `Ctx` is locked to `RequestContext`.
|
|
413
|
+
*/
|
|
414
|
+
interface DefineHttpContextDecoratorWithParams<P extends Record<string, unknown>> {
|
|
415
|
+
<K extends string, D extends Record<string, DepValue> = Record<string, never>>(spec: ContextDecoratorSpec<K, D, P, RequestContext>): ContextDecorator<K, D, P, RequestContext>;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Public shape of {@link defineHttpContextDecorator} — the positional
|
|
419
|
+
* call signature plus the curried `.withParams<P>()` helper that fixes
|
|
420
|
+
* partial-inference for the parameterised case.
|
|
421
|
+
*/
|
|
422
|
+
interface DefineHttpContextDecoratorFn {
|
|
423
|
+
<K extends string, D extends Record<string, DepValue> = Record<string, never>, P extends Record<string, unknown> = Record<string, never>>(spec: ContextDecoratorSpec<K, D, P, RequestContext>): ContextDecorator<K, D, P, RequestContext>;
|
|
424
|
+
/**
|
|
425
|
+
* Curried entry point. Spell only `P`; `K` and `D` infer from the
|
|
426
|
+
* spec. `Ctx` is locked to `RequestContext`.
|
|
427
|
+
*
|
|
428
|
+
* ```ts
|
|
429
|
+
* const LoadTenant = defineHttpContextDecorator.withParams<{
|
|
430
|
+
* source: 'header' | 'subdomain'
|
|
431
|
+
* }>()({
|
|
432
|
+
* key: 'tenant',
|
|
433
|
+
* deps: { repo: TENANT_REPO }, // D inferred
|
|
434
|
+
* paramDefaults: { source: 'header' },
|
|
435
|
+
* resolve: (ctx, { repo }, params) => repo.findFor(ctx, params),
|
|
436
|
+
* })
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
withParams<P extends Record<string, unknown>>(): DefineHttpContextDecoratorWithParams<P>;
|
|
440
|
+
}
|
|
441
|
+
declare const defineHttpContextDecorator: DefineHttpContextDecoratorFn;
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/http/runtimes/express.d.ts
|
|
444
|
+
/**
|
|
445
|
+
* Materialize a controller's {@link RouteEntry}[] onto a fresh `express.Router`.
|
|
446
|
+
* Reproduces the legacy handler ordering precisely: validation → upload →
|
|
447
|
+
* `(ctx, next)` middleware → contributor runner → terminal handler. Each step
|
|
448
|
+
* constructs its own `RequestContext` over the same `req`/`res` — request-scoped
|
|
449
|
+
* state lives in the AsyncLocalStorage store, not on the ctx instance, so the
|
|
450
|
+
* per-step instances share state exactly as before.
|
|
451
|
+
*/
|
|
452
|
+
declare function materializeRouter(entries: RouteEntry[]): Router;
|
|
453
|
+
/**
|
|
454
|
+
* Build an Express Router from a controller class decorated with @Get, @Post,
|
|
455
|
+
* etc. The public, back-compatible entry point: a thin shim over
|
|
456
|
+
* {@link buildRouteTable} + {@link materializeRouter}. Returns an
|
|
457
|
+
* `express.Router` exactly as before — modules pass it to `app.use(path, router)`.
|
|
458
|
+
*
|
|
459
|
+
* @see buildRouteTable for the engine-neutral route-table form.
|
|
460
|
+
*/
|
|
461
|
+
declare function buildRoutes(controllerClass: any, options?: BuildRoutesOptions): Router;
|
|
462
|
+
/**
|
|
463
|
+
* The default HTTP runtime. Express stays a peer dependency of `@forinda/kickjs`;
|
|
464
|
+
* apps that pass no `runtime` get this and behave exactly as before.
|
|
465
|
+
*/
|
|
466
|
+
declare function expressRuntime(): HttpRuntime<Express>;
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/http/request-store.d.ts
|
|
469
|
+
/** Per-request storage for REQUEST-scoped DI and request context propagation */
|
|
470
|
+
interface RequestStore {
|
|
471
|
+
/** Unique request identifier */
|
|
472
|
+
requestId: string;
|
|
473
|
+
/**
|
|
474
|
+
* Per-request singleton cache for REQUEST-scoped services. Keys are
|
|
475
|
+
* heterogeneous (class constructors, `InjectionToken` objects, raw
|
|
476
|
+
* strings), so the map type stays `Map<any, any>`.
|
|
477
|
+
*/
|
|
478
|
+
instances: Map<any, any>;
|
|
479
|
+
/**
|
|
480
|
+
* Per-request key/value bag. Canonical backing store for
|
|
481
|
+
* `RequestContext.set/get` and the Context Contributor pipeline (#107)
|
|
482
|
+
* since Phase 3. Anything written here is visible to every concrete
|
|
483
|
+
* execution context constructed for the same request, regardless of
|
|
484
|
+
* which middleware/contributor wrote it.
|
|
485
|
+
*
|
|
486
|
+
* Keys are constrained to `string` per the locked decision in
|
|
487
|
+
* `architecture.md` §20.12 (#4); the value type is `unknown` because
|
|
488
|
+
* the concrete shape at each key is determined by the consumer's
|
|
489
|
+
* `ContextMeta` augmentation, not by the store itself.
|
|
490
|
+
*
|
|
491
|
+
* Prefer the {@link getRequestValue} helper over reaching into this
|
|
492
|
+
* map directly — it threads the augmented `ContextMeta` shape through
|
|
493
|
+
* `MetaValue<K>` so consumers get typed reads without an `as` cast.
|
|
494
|
+
* Writes should flow through `ctx.set(key, value)` or a Context
|
|
495
|
+
* Contributor's return value — see the `setRequestValue` note below
|
|
496
|
+
* for why this package intentionally does NOT ship a service-level
|
|
497
|
+
* write helper.
|
|
498
|
+
*/
|
|
499
|
+
values: Map<string, unknown>;
|
|
500
|
+
/** Set once {@link disposeRequestStore} has run — guards double-dispose. */
|
|
501
|
+
disposed?: boolean;
|
|
502
|
+
}
|
|
503
|
+
/** AsyncLocalStorage instance shared across the framework */
|
|
504
|
+
declare const requestStore: AsyncLocalStorage<RequestStore>;
|
|
505
|
+
/**
|
|
506
|
+
* Get the current request store. Throws if called outside a request context.
|
|
507
|
+
* Used by the Container to resolve REQUEST-scoped dependencies.
|
|
508
|
+
*/
|
|
509
|
+
declare function getRequestStore(): RequestStore;
|
|
510
|
+
/**
|
|
511
|
+
* Read a per-request `ContextMeta`-keyed value from outside a controller
|
|
512
|
+
* (services, repositories, anywhere with no `ctx` reference). Returns
|
|
513
|
+
* the augmented type for the key — `MetaValue<K>` — so consumers get the
|
|
514
|
+
* same static safety as `ctx.get(key)` without holding the context.
|
|
515
|
+
*
|
|
516
|
+
* Returns `undefined` outside an active request frame (background jobs,
|
|
517
|
+
* startup code, tests without `requestScopeMiddleware()`) — the helper
|
|
518
|
+
* is intentionally null-tolerant so calling it from a service that
|
|
519
|
+
* runs in both request and non-request paths doesn't throw.
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* declare module '@forinda/kickjs' {
|
|
524
|
+
* interface ContextMeta { tenant: { id: string; name: string } }
|
|
525
|
+
* }
|
|
526
|
+
*
|
|
527
|
+
* @Service()
|
|
528
|
+
* class AuditService {
|
|
529
|
+
* log(action: string) {
|
|
530
|
+
* const tenant = getRequestValue('tenant') // typed: { id; name } | undefined
|
|
531
|
+
* db.audit.insert({ action, tenantId: tenant?.id })
|
|
532
|
+
* }
|
|
533
|
+
* }
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
declare function getRequestValue<K extends string>(key: K): MetaValue<K> | undefined;
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/http/middleware/request-scope.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* Wraps each request in an AsyncLocalStorage context.
|
|
541
|
+
* Enables REQUEST-scoped DI and automatic requestId propagation to logs.
|
|
542
|
+
*
|
|
543
|
+
* Should be mounted early in the middleware pipeline (before route handlers).
|
|
544
|
+
* `Application` mounts this automatically unless `contextStore: 'manual'` is set
|
|
545
|
+
* or the user already includes one in their middleware list.
|
|
546
|
+
*/
|
|
547
|
+
declare function requestScopeMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/http/middleware/trace-context.d.ts
|
|
550
|
+
/**
|
|
551
|
+
* W3C Trace Context header name.
|
|
552
|
+
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
553
|
+
*/
|
|
554
|
+
declare const TRACEPARENT_HEADER = "traceparent";
|
|
555
|
+
interface TraceContextOptions {
|
|
556
|
+
/**
|
|
557
|
+
* When true, respond with a `traceresponse` header containing the trace ID.
|
|
558
|
+
* Useful for debugging. Default: false.
|
|
559
|
+
*/
|
|
560
|
+
propagateResponse?: boolean;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Parsed W3C trace context fields.
|
|
564
|
+
*/
|
|
565
|
+
interface TraceContext {
|
|
566
|
+
/** W3C traceparent version (usually '00') */
|
|
567
|
+
version: string;
|
|
568
|
+
/** 32-hex-char distributed trace ID */
|
|
569
|
+
traceId: string;
|
|
570
|
+
/** 16-hex-char parent span ID */
|
|
571
|
+
parentSpanId: string;
|
|
572
|
+
/** 2-hex-char trace flags */
|
|
573
|
+
flags: string;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Parse a W3C traceparent header value.
|
|
577
|
+
* Returns null if the format is invalid.
|
|
578
|
+
*/
|
|
579
|
+
declare function parseTraceparent(header: string): TraceContext | null;
|
|
580
|
+
/**
|
|
581
|
+
* Middleware that extracts W3C `traceparent` header and stores trace context
|
|
582
|
+
* in the request's AsyncLocalStorage store.
|
|
583
|
+
*
|
|
584
|
+
* If no valid `traceparent` header is present, a new traceId is generated
|
|
585
|
+
* so that every request always has a trace ID available for correlation.
|
|
586
|
+
*
|
|
587
|
+
* Must be mounted **after** `requestScopeMiddleware()` (which creates the store).
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```ts
|
|
591
|
+
* bootstrap({
|
|
592
|
+
* middleware: [
|
|
593
|
+
* requestScopeMiddleware(),
|
|
594
|
+
* traceContext(), // extracts or generates traceId
|
|
595
|
+
* requestLogger(),
|
|
596
|
+
* express.json(),
|
|
597
|
+
* ],
|
|
598
|
+
* })
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
declare function traceContext(options?: TraceContextOptions): (req: Request, res: Response, next: NextFunction) => void;
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/http/middleware/views.d.ts
|
|
604
|
+
interface ViewAdapterOptions {
|
|
605
|
+
/**
|
|
606
|
+
* Template engine — pass the engine module or a render function.
|
|
607
|
+
* Supported engines: ejs, pug, handlebars, nunjucks, or any
|
|
608
|
+
* Express-compatible engine with a __express property.
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```ts
|
|
612
|
+
* import ejs from 'ejs'
|
|
613
|
+
* ViewAdapter({ engine: ejs, ext: 'ejs' })
|
|
614
|
+
*
|
|
615
|
+
* import pug from 'pug'
|
|
616
|
+
* ViewAdapter({ engine: pug, ext: 'pug' })
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
engine: any;
|
|
620
|
+
/** File extension for templates (e.g., 'ejs', 'pug', 'hbs') */
|
|
621
|
+
ext: string;
|
|
622
|
+
/** Directory containing template files (default: 'src/views') */
|
|
623
|
+
viewsDir?: string;
|
|
624
|
+
/** Default layout template (optional — depends on engine) */
|
|
625
|
+
layout?: string;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* View/template adapter — pluggable template engine support for KickJS.
|
|
629
|
+
*
|
|
630
|
+
* Registers an Express view engine and sets the views directory.
|
|
631
|
+
* Use `ctx.render()` in controllers to render templates.
|
|
632
|
+
*
|
|
633
|
+
* Migrated to the `defineAdapter()` factory in v4 — call without `new`.
|
|
634
|
+
* The pre-v4 `new ViewAdapter({...})` form is gone; see
|
|
635
|
+
* `docs/guide/migration-v3-to-v4.md` for the rename.
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```ts
|
|
639
|
+
* import ejs from 'ejs'
|
|
640
|
+
* import { ViewAdapter } from '@forinda/kickjs'
|
|
641
|
+
*
|
|
642
|
+
* bootstrap({
|
|
643
|
+
* modules,
|
|
644
|
+
* adapters: [
|
|
645
|
+
* ViewAdapter({ engine: ejs, ext: 'ejs', viewsDir: 'src/views' }),
|
|
646
|
+
* ],
|
|
647
|
+
* })
|
|
648
|
+
*
|
|
649
|
+
* // In a controller:
|
|
650
|
+
* @Get('/dashboard')
|
|
651
|
+
* async dashboard(ctx: RequestContext) {
|
|
652
|
+
* ctx.render('dashboard', { user: currentUser, title: 'Dashboard' })
|
|
653
|
+
* }
|
|
654
|
+
* ```
|
|
655
|
+
*/
|
|
656
|
+
declare const ViewAdapter: AdapterFactory<ViewAdapterOptions, unknown>;
|
|
657
|
+
//#endregion
|
|
658
|
+
export { mountSort as A, FormatKickErrorOptions as B, groupAssetKeys as C, MountCycleError as D, MissingMountDepError as E, CircuitBreaker as F, disposeAll as G, KickErrorInit as H, CircuitBreakerOptions as I, registerDisposable as K, CircuitBreakerState as L, DuplicateContributorError as M, MissingContextValueError as N, MountKind as O, MissingContributorError as P, CircuitBreakerStats as R, GroupAssetKeysResult as S, DuplicateMountNameError as T, formatKickError as U, KickError as V, Disposable as W, ClusterOptions as _, TraceContextOptions as a, AssetKeyStrategy as b, requestScopeMiddleware as c, getRequestValue as d, requestStore as f, defineHttpContextDecorator as g, materializeRouter as h, TraceContext as i, ContributorCycleError as j, MountSortItem as k, 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, stripExt as w, GroupAssetKeysOptions as x, AssetKeyPair as y, CircuitOpenError as z };
|
|
659
|
+
//# sourceMappingURL=views-DsfBT1fR.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views-DsfBT1fR.d.mts","names":[],"sources":["../src/core/disposables.ts","../src/core/kick-error.ts","../src/core/circuit-breaker.ts","../src/core/context-errors.ts","../src/core/mount-sort.ts","../src/core/asset-keys.ts","../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":"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"}
|
package/dist/web.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { x as MiddlewareHandler } from "./decorators-
|
|
3
|
-
import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-
|
|
4
|
-
import { D as SseHandler, b as RuntimeResponse, m as RouteEntry } from "./adapter-
|
|
5
|
-
import { a as KvSessionStoreOptions, c as InferHandlerResponse, d as isReply, f as reply, i as KvSessionStore, l as Reply, n as KvRateLimitStore, o as RateLimitGuardOptions, r as KvRateLimitStoreOptions, s as rateLimitGuard, t as KvLike } from "./kv-stores-
|
|
6
|
-
|
|
2
|
+
import { x as MiddlewareHandler } from "./decorators-Bks7cgBJ.mjs";
|
|
3
|
+
import { d as ContributorRegistrations, r as AppModuleEntry } from "./app-module-DtoySG6l.mjs";
|
|
4
|
+
import { D as SseHandler, b as RuntimeResponse, m as RouteEntry } from "./adapter-CbMq-NBf.mjs";
|
|
5
|
+
import { a as KvSessionStoreOptions, c as InferHandlerResponse, d as isReply, f as reply, i as KvSessionStore, l as Reply, n as KvRateLimitStore, o as RateLimitGuardOptions, r as KvRateLimitStoreOptions, s as rateLimitGuard, t as KvLike } from "./kv-stores-CHowq8VP.mjs";
|
|
7
6
|
//#region src/http/web/driver.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Presents a web `Request` as the express-shaped `req` object that
|