@forinda/kickjs 8.2.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/{adapter-BxXGuLnW.d.mts → adapter-ByxWutTw.d.mts} +3 -3
  2. package/dist/{adapter-BxXGuLnW.d.mts.map → adapter-ByxWutTw.d.mts.map} +1 -1
  3. package/dist/{app-module-DoM8RNZ9.d.mts → app-module--bC2V1yw.d.mts} +18 -2
  4. package/dist/{app-module-DoM8RNZ9.d.mts.map → app-module--bC2V1yw.d.mts.map} +1 -1
  5. package/dist/{spa-BBwrECcF.d.mts → application-NBph8Ahc.d.mts} +598 -69
  6. package/dist/application-NBph8Ahc.d.mts.map +1 -0
  7. package/dist/application-OZSYZy2Z.mjs +12 -0
  8. package/dist/application-OZSYZy2Z.mjs.map +1 -0
  9. package/dist/{bootstrap-YxZ7Xitb.mjs → bootstrap-BQrXS6L1.mjs} +3 -3
  10. package/dist/{bootstrap-YxZ7Xitb.mjs.map → bootstrap-BQrXS6L1.mjs.map} +1 -1
  11. package/dist/{client-ip-B6kKJLEJ.mjs → client-ip-D5ZBfP_C.mjs} +2 -2
  12. package/dist/{client-ip-B6kKJLEJ.mjs.map → client-ip-D5ZBfP_C.mjs.map} +1 -1
  13. package/dist/config/index.mjs +2 -2
  14. package/dist/{config-Bwgvk__k.mjs → config-DlAZU1Dm.mjs} +3 -3
  15. package/dist/{config-Bwgvk__k.mjs.map → config-DlAZU1Dm.mjs.map} +1 -1
  16. package/dist/{container-BnkQIDQF.mjs → container-DzwyumEo.mjs} +3 -3
  17. package/dist/{container-BnkQIDQF.mjs.map → container-DzwyumEo.mjs.map} +1 -1
  18. package/dist/{context-GJc8Pf2d.mjs → context-3SqXUyOr.mjs} +3 -3
  19. package/dist/{context-GJc8Pf2d.mjs.map → context-3SqXUyOr.mjs.map} +1 -1
  20. package/dist/{context-errors-Bm1GxsOQ.mjs → context-errors-CpTVAtA_.mjs} +2 -2
  21. package/dist/{context-errors-Bm1GxsOQ.mjs.map → context-errors-CpTVAtA_.mjs.map} +1 -1
  22. package/dist/{contributor-runner-CzL4-aIt.mjs → contributor-runner-CX6InEzw.mjs} +3 -3
  23. package/dist/{contributor-runner-CzL4-aIt.mjs.map → contributor-runner-CX6InEzw.mjs.map} +1 -1
  24. package/dist/core/adapter.d.mts +1 -1
  25. package/dist/core/adapter.mjs +1 -1
  26. package/dist/core/app-module.d.mts +1 -1
  27. package/dist/core/app-module.mjs +1 -1
  28. package/dist/core/cache.mjs +1 -1
  29. package/dist/core/container.mjs +2 -2
  30. package/dist/core/cron.mjs +2 -2
  31. package/dist/core/decorators.mjs +2 -2
  32. package/dist/core/errors.mjs +1 -1
  33. package/dist/core/interfaces.mjs +1 -1
  34. package/dist/core/logger.mjs +1 -1
  35. package/dist/core/path.mjs +1 -1
  36. package/dist/core/plugin.d.mts +1 -1
  37. package/dist/core/plugin.mjs +1 -1
  38. package/dist/core/reactivity.mjs +1 -1
  39. package/dist/{core-w7s4ntck.mjs → core-CsxP6Jec.mjs} +3 -3
  40. package/dist/{core-w7s4ntck.mjs.map → core-CsxP6Jec.mjs.map} +1 -1
  41. package/dist/{csrf-BjmtOJZs.mjs → csrf-BdKFFh14.mjs} +3 -3
  42. package/dist/{csrf-BjmtOJZs.mjs.map → csrf-BdKFFh14.mjs.map} +1 -1
  43. package/dist/{csrf-COqPWlMd.d.mts → csrf-DDwUOF45.d.mts} +2 -2
  44. package/dist/{csrf-COqPWlMd.d.mts.map → csrf-DDwUOF45.d.mts.map} +1 -1
  45. package/dist/{decorate-CpBbxrvT.mjs → decorate-BGm37ho8.mjs} +1 -1
  46. package/dist/{define-adapter-whaSQuNs.mjs → define-adapter-CpUxOgQ-.mjs} +2 -2
  47. package/dist/{define-adapter-whaSQuNs.mjs.map → define-adapter-CpUxOgQ-.mjs.map} +1 -1
  48. package/dist/{disposables-lWieeJLG.mjs → disposables-Pouc1-v2.mjs} +2 -2
  49. package/dist/{disposables-lWieeJLG.mjs.map → disposables-Pouc1-v2.mjs.map} +1 -1
  50. package/dist/{env-Bd6akCGH.mjs → env-BYseGI8D.mjs} +3 -3
  51. package/dist/{env-Bd6akCGH.mjs.map → env-BYseGI8D.mjs.map} +1 -1
  52. package/dist/{error-handler-DMUz6X18.d.mts → error-handler-BtTYsKLV.d.mts} +2 -2
  53. package/dist/{error-handler-DMUz6X18.d.mts.map → error-handler-BtTYsKLV.d.mts.map} +1 -1
  54. package/dist/{handler-gK6lNZKW.mjs → handler-s-wYH8Kk.mjs} +3 -3
  55. package/dist/{handler-gK6lNZKW.mjs.map → handler-s-wYH8Kk.mjs.map} +1 -1
  56. package/dist/http/application.d.mts +1 -1
  57. package/dist/http/application.mjs +2 -2
  58. package/dist/http/bootstrap.d.mts +1 -1
  59. package/dist/http/bootstrap.mjs +2 -2
  60. package/dist/http/context.d.mts +2 -2
  61. package/dist/http/context.mjs +2 -2
  62. package/dist/http/middleware/cors.mjs +1 -1
  63. package/dist/http/middleware/csrf.d.mts +1 -1
  64. package/dist/http/middleware/csrf.mjs +2 -2
  65. package/dist/http/middleware/error-handler.d.mts +1 -1
  66. package/dist/http/middleware/error-handler.mjs +2 -2
  67. package/dist/http/middleware/helmet.mjs +1 -1
  68. package/dist/http/middleware/rate-limit.d.mts +1 -1
  69. package/dist/http/middleware/rate-limit.mjs +2 -2
  70. package/dist/http/middleware/request-id.mjs +1 -1
  71. package/dist/http/middleware/request-logger.mjs +2 -2
  72. package/dist/http/middleware/session.mjs +2 -2
  73. package/dist/http/middleware/spa.d.mts +1 -1
  74. package/dist/http/middleware/spa.mjs +2 -2
  75. package/dist/http/middleware/upload.d.mts +1 -1
  76. package/dist/http/middleware/upload.mjs +2 -2
  77. package/dist/http/middleware/validate.mjs +1 -1
  78. package/dist/http/middleware/views.d.mts +1 -1
  79. package/dist/http/middleware/views.mjs +2 -2
  80. package/dist/http/query/index.mjs +2 -2
  81. package/dist/http/router-builder.d.mts +1 -1
  82. package/dist/http/router-builder.mjs +2 -2
  83. package/dist/http/runtimes/fastify.d.mts +1 -1
  84. package/dist/http/runtimes/fastify.mjs +2 -2
  85. package/dist/http/runtimes/h3-web.d.mts +1 -1
  86. package/dist/http/runtimes/h3-web.mjs +2 -2
  87. package/dist/http/runtimes/h3.d.mts +1 -1
  88. package/dist/http/runtimes/h3.mjs +2 -2
  89. package/dist/index.d.mts +14 -16
  90. package/dist/index.mjs +2 -2
  91. package/dist/{kv-stores-Bp4_RP-e.mjs → kv-stores-DClxfUzF.mjs} +3 -3
  92. package/dist/{kv-stores-Bp4_RP-e.mjs.map → kv-stores-DClxfUzF.mjs.map} +1 -1
  93. package/dist/{kv-stores-sjVe0MqN.d.mts → kv-stores-DR4ZHDht.d.mts} +4 -4
  94. package/dist/{kv-stores-sjVe0MqN.d.mts.map → kv-stores-DR4ZHDht.d.mts.map} +1 -1
  95. package/dist/{metadata-DRRQ0p_l.mjs → metadata-DvU1KnZD.mjs} +2 -2
  96. package/dist/{metadata-DRRQ0p_l.mjs.map → metadata-DvU1KnZD.mjs.map} +1 -1
  97. package/dist/{module-registry-C7yEmbZ8.mjs → module-registry-sxthbE3E.mjs} +2 -2
  98. package/dist/{module-registry-C7yEmbZ8.mjs.map → module-registry-sxthbE3E.mjs.map} +1 -1
  99. package/dist/{query-BSp_RIR0.mjs → query-BsOSNlUY.mjs} +2 -2
  100. package/dist/{query-BSp_RIR0.mjs.map → query-BsOSNlUY.mjs.map} +1 -1
  101. package/dist/{rate-limit-CzFoSCzS.d.mts → rate-limit-D5FHbYKG.d.mts} +2 -2
  102. package/dist/{rate-limit-CzFoSCzS.d.mts.map → rate-limit-D5FHbYKG.d.mts.map} +1 -1
  103. package/dist/{respond-BygP3p23.mjs → respond-Bqj4ktsY.mjs} +2 -2
  104. package/dist/{respond-BygP3p23.mjs.map → respond-Bqj4ktsY.mjs.map} +1 -1
  105. package/dist/{route-flag-GzEeUmws.d.mts → route-flag-BMlwj3Nk.d.mts} +22 -6
  106. package/dist/route-flag-BMlwj3Nk.d.mts.map +1 -0
  107. package/dist/route-flag-BsEtXxzP.mjs +12 -0
  108. package/dist/route-flag-BsEtXxzP.mjs.map +1 -0
  109. package/dist/{route-policy-D5lQltyg.mjs → route-policy-TDd9n2Q-.mjs} +2 -2
  110. package/dist/{route-policy-D5lQltyg.mjs.map → route-policy-TDd9n2Q-.mjs.map} +1 -1
  111. package/dist/router-builder-CfSWFOxm.mjs +12 -0
  112. package/dist/router-builder-CfSWFOxm.mjs.map +1 -0
  113. package/dist/{router-builder-eLpJYyrb.d.mts → router-builder-DZxYbs5I.d.mts} +9 -2
  114. package/dist/router-builder-DZxYbs5I.d.mts.map +1 -0
  115. package/dist/{runtime-B3fCMmZW.mjs → runtime-Cn74iFYv.mjs} +3 -3
  116. package/dist/{runtime-B3fCMmZW.mjs.map → runtime-Cn74iFYv.mjs.map} +1 -1
  117. package/dist/{upload-yKvKdRWG.d.mts → upload-BjA0m0ov.d.mts} +2 -2
  118. package/dist/{upload-yKvKdRWG.d.mts.map → upload-BjA0m0ov.d.mts.map} +1 -1
  119. package/dist/{upload-config-CP5v2Fh-.mjs → upload-config-dNLJaVlD.mjs} +2 -2
  120. package/dist/{upload-config-CP5v2Fh-.mjs.map → upload-config-dNLJaVlD.mjs.map} +1 -1
  121. package/dist/web.d.mts +3 -3
  122. package/dist/web.mjs +2 -2
  123. package/dist/web.mjs.map +1 -1
  124. package/package.json +1 -1
  125. package/dist/application-NjKJPm9r.d.mts +0 -495
  126. package/dist/application-NjKJPm9r.d.mts.map +0 -1
  127. package/dist/application-blu78Mlf.mjs +0 -12
  128. package/dist/application-blu78Mlf.mjs.map +0 -1
  129. package/dist/bootstrap-Sjn3hPqw.d.mts +0 -27
  130. package/dist/bootstrap-Sjn3hPqw.d.mts.map +0 -1
  131. package/dist/route-flag-GzEeUmws.d.mts.map +0 -1
  132. package/dist/route-flag-vuWGpI1V.mjs +0 -12
  133. package/dist/route-flag-vuWGpI1V.mjs.map +0 -1
  134. package/dist/router-builder-HeSJZ2QG.mjs +0 -12
  135. package/dist/router-builder-HeSJZ2QG.mjs.map +0 -1
  136. package/dist/router-builder-eLpJYyrb.d.mts.map +0 -1
  137. package/dist/spa-BBwrECcF.d.mts.map +0 -1
@@ -1,23 +1,22 @@
1
1
 
2
2
  import { s as InjectionToken, t as Container } from "./container-Dpvd66Yt.mjs";
3
3
  import "./index-Btz1W0X5.mjs";
4
- import { u as RouteFlags } from "./route-flag-GzEeUmws.mjs";
5
- import { C as MetaValue, c as ContextDecorator, h as DepValue, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module-DoM8RNZ9.mjs";
6
- import { A as AdapterFactory, E as RequestContext, f as HttpRuntime, h as RouteEntry, nt as ModuleFactory } from "./adapter-BxXGuLnW.mjs";
7
- import "./application-NjKJPm9r.mjs";
8
- import "./bootstrap-Sjn3hPqw.mjs";
9
- import "./cors-CsibNTQ6.mjs";
10
- import "./csrf-COqPWlMd.mjs";
11
- import "./error-handler-DMUz6X18.mjs";
12
- import "./helmet-C2QEU6S-.mjs";
13
- import "./rate-limit-CzFoSCzS.mjs";
4
+ import { p as RouteFlags, s as RouteFlagDeclarations } from "./route-flag-BMlwj3Nk.mjs";
5
+ import { C as MetaValue, c as ContextDecorator, h as DepValue, m as ContributorRegistrations, r as AppModuleEntry, u as ContextDecoratorSpec, x as ContextMetaKey } from "./app-module--bC2V1yw.mjs";
6
+ import { A as AdapterFactory, E as RequestContext, b as RuntimeCapabilities, f as HttpRuntime, h as RouteEntry, lt as KickPlugin, nt as ModuleFactory, r as AppAdapter, s as ActiveRuntime, ut as ModuleRegistry, x as RuntimeResponse } from "./adapter-ByxWutTw.mjs";
7
+ import { l as Reply } from "./kv-stores-DR4ZHDht.mjs";
8
+ import { t as BuildRoutesOptions } from "./router-builder-DZxYbs5I.mjs";
14
9
  import "./request-id-CVzJ1uHD.mjs";
15
- import "./session-BHgRyfqZ.mjs";
16
- import { l as Reply } from "./kv-stores-sjVe0MqN.mjs";
17
- import { t as BuildRoutesOptions } from "./router-builder-eLpJYyrb.mjs";
18
10
  import "./validate-DMYpUnrf.mjs";
19
- import "./upload-yKvKdRWG.mjs";
20
- import { Express, NextFunction, Request, Response, Router } from "express";
11
+ import "./error-handler-BtTYsKLV.mjs";
12
+ import "./csrf-DDwUOF45.mjs";
13
+ import "./helmet-C2QEU6S-.mjs";
14
+ import "./cors-CsibNTQ6.mjs";
15
+ import "./rate-limit-D5FHbYKG.mjs";
16
+ import "./session-BHgRyfqZ.mjs";
17
+ import "./upload-BjA0m0ov.mjs";
18
+ import http from "node:http";
19
+ import { Express, NextFunction, Request, RequestHandler, Response, Router } from "express";
21
20
  import { AsyncLocalStorage } from "node:async_hooks";
22
21
  //#region src/core/disposables.d.ts
23
22
  /**
@@ -414,62 +413,28 @@ declare function bindRoutePolicy<T extends object>(handler: T, receive: (table:
414
413
  /** Hand the table to a middleware if it declared the slot. */
415
414
  declare function offerRoutePolicy(handler: unknown, table: RoutePolicyTable): void;
416
415
  //#endregion
417
- //#region src/http/health-module.d.ts
418
- /** One adapter's answer to `onHealthCheck()`. */
419
- interface HealthCheckResult {
420
- name: string;
421
- status: 'up' | 'down';
422
- }
416
+ //#region src/http/bootstrap.d.ts
423
417
  /**
424
- * What the health routes need from the running Application.
418
+ * Bootstrap a KickJS application.
425
419
  *
426
- * A controller cannot reach `Application` internals, and should not: this is
427
- * the whole surface the endpoints depend on, so a replacement module can
428
- * satisfy it without knowing anything else.
429
- */
430
- interface HealthProbe {
431
- /** True once shutdown has begun and traffic should drain away. */
432
- isDraining(): boolean;
433
- /** Aggregated `onHealthCheck()` results from every adapter that has one. */
434
- checks(): Promise<HealthCheckResult[]>;
435
- }
436
- declare const HEALTH_PROBE: InjectionToken<HealthProbe>;
437
- declare class HealthController {
438
- private readonly probe;
439
- constructor(probe: HealthProbe);
440
- /** Liveness: is the process up and not shutting down. */
441
- live(): Reply<200, {
442
- status: string;
443
- uptime: number;
444
- }> | Reply<503, {
445
- status: string;
446
- uptime: number;
447
- }>;
448
- /** Readiness: is every adapter's dependency answering. */
449
- ready(): Promise<Reply<200 | 503, {
450
- status: string;
451
- checks: HealthCheckResult[];
452
- }>>;
453
- }
454
- /**
455
- * `GET /health/live` and `GET /health/ready`, mounted at the root.
420
+ * Creates the Express app, registers modules and adapters, and starts
421
+ * the HTTP server. In dev mode (`kick dev`), the Vite plugin manages
422
+ * the server and HMR — source changes are picked up instantly without
423
+ * losing database connections or WebSocket state.
456
424
  *
457
- * A `defineModule` factory like any other module — the framework's own routes
458
- * should be declared the way it asks adopters to declare theirs, not through a
459
- * shape only the framework can produce.
425
+ * @returns The {@link Application} instance.
460
426
  *
461
- * Registered automatically unless the app passes `health: false` or supplies a
462
- * module of its own.
463
- */
464
- declare const healthModule: ModuleFactory<Record<string, unknown>, {
465
- register(container: Container): void;
466
- routes(): {
467
- path: string;
468
- controller: typeof HealthController;
469
- version: false;
470
- prefix: false;
471
- };
472
- }>;
427
+ * @example
428
+ * ```ts
429
+ * // src/index.ts
430
+ * import 'reflect-metadata'
431
+ * import { bootstrap } from '@forinda/kickjs'
432
+ * import { modules } from './modules'
433
+ *
434
+ * export const app = await bootstrap({ modules })
435
+ * ```
436
+ */
437
+ declare function bootstrap(options: ApplicationOptions): Promise<Application>;
473
438
  //#endregion
474
439
  //#region src/http/cluster.d.ts
475
440
  interface ClusterOptions {
@@ -864,5 +829,569 @@ declare function resolveClientDir(clientDir: string, cwd?: string, entry?: strin
864
829
  */
865
830
  declare const SpaAdapter: AdapterFactory<SpaAdapterOptions, unknown>;
866
831
  //#endregion
867
- export { KickErrorInit as $, AssetKeyPair as A, MountSortItem as B, HealthCheckResult as C, RoutePolicyTable as D, healthModule as E, stripExt as F, MissingContributorError as G, ContributorCycleError as H, DuplicateMountNameError as I, CircuitBreakerState as J, CircuitBreaker as K, MissingMountDepError as L, GroupAssetKeysOptions as M, GroupAssetKeysResult as N, bindRoutePolicy as O, groupAssetKeys as P, KickError as Q, MountCycleError as R, HEALTH_PROBE as S, HealthProbe as T, DuplicateContributorError as U, mountSort as V, MissingContextValueError as W, CircuitOpenError as X, CircuitBreakerStats as Y, FormatKickErrorOptions as Z, expressRuntime as _, ViewAdapterOptions as a, ClusterOptions as b, TraceContextOptions as c, requestScopeMiddleware as d, formatKickError as et, RequestStore as f, buildRoutes as g, requestStore as h, ViewAdapter as i, AssetKeyStrategy as j, offerRoutePolicy as k, parseTraceparent as l, getRequestValue as m, SpaAdapterOptions as n, disposeAll as nt, TRACEPARENT_HEADER as o, getRequestStore as p, CircuitBreakerOptions as q, resolveClientDir as r, registerDisposable as rt, TraceContext as s, SpaAdapter as t, Disposable as tt, traceContext as u, materializeRouter as v, HealthController as w, isClusterPrimary as x, defineHttpContextDecorator as y, MountKind as z };
868
- //# sourceMappingURL=spa-BBwrECcF.d.mts.map
832
+ //#region src/http/health-module.d.ts
833
+ /** One adapter's answer to `onHealthCheck()`. */
834
+ interface HealthCheckResult {
835
+ name: string;
836
+ status: 'up' | 'down';
837
+ }
838
+ /**
839
+ * What the health routes need from the running Application.
840
+ *
841
+ * A controller cannot reach `Application` internals, and should not: this is
842
+ * the whole surface the endpoints depend on, so a replacement module can
843
+ * satisfy it without knowing anything else.
844
+ */
845
+ interface HealthProbe {
846
+ /** True once shutdown has begun and traffic should drain away. */
847
+ isDraining(): boolean;
848
+ /** Aggregated `onHealthCheck()` results from every adapter that has one. */
849
+ checks(): Promise<HealthCheckResult[]>;
850
+ }
851
+ declare const HEALTH_PROBE: InjectionToken<HealthProbe>;
852
+ /** Config for {@link healthModule}. */
853
+ interface HealthModuleConfig {
854
+ /**
855
+ * Route flags to put on `GET /health/live` and `GET /health/ready`.
856
+ *
857
+ * The framework names no flags, so it cannot decide these probes are
858
+ * "public" on your behalf — the name is yours, and every consumer that
859
+ * already reads it (an auth contributor's `skipWhen`, a guard's
860
+ * `exemptWhen`, `SwaggerAdapter({ publicFlag })`) then covers health with no
861
+ * further wiring:
862
+ *
863
+ * ```ts
864
+ * bootstrap({ health: { flags: ['auth.public'] } })
865
+ * ```
866
+ *
867
+ * This replaces exempting `/health/live` and `/health/ready` by pathname,
868
+ * which silently stops matching if the probe paths ever move.
869
+ */
870
+ flags?: RouteFlagDeclarations;
871
+ }
872
+ declare class HealthController {
873
+ private readonly probe;
874
+ constructor(probe: HealthProbe);
875
+ /** Liveness: is the process up and not shutting down. */
876
+ live(): Reply<200, {
877
+ status: string;
878
+ uptime: number;
879
+ }> | Reply<503, {
880
+ status: string;
881
+ uptime: number;
882
+ }>;
883
+ /** Readiness: is every adapter's dependency answering. */
884
+ ready(): Promise<Reply<200 | 503, {
885
+ status: string;
886
+ checks: HealthCheckResult[];
887
+ }>>;
888
+ }
889
+ /**
890
+ * `GET /health/live` and `GET /health/ready`, mounted at the root.
891
+ *
892
+ * A `defineModule` factory like any other module — the framework's own routes
893
+ * should be declared the way it asks adopters to declare theirs, not through a
894
+ * shape only the framework can produce.
895
+ *
896
+ * Registered automatically unless the app passes `health: false` or supplies a
897
+ * module of its own. Pass `health: { flags: [...] }` to `bootstrap()` to flag
898
+ * both probes — see {@link HealthModuleConfig}.
899
+ */
900
+ declare const healthModule: ModuleFactory<HealthModuleConfig, unknown>;
901
+ //#endregion
902
+ //#region src/http/application.d.ts
903
+ /**
904
+ * A middleware entry in the declarative pipeline.
905
+ * Can be a bare handler or an object with path scoping.
906
+ */
907
+ type MiddlewareEntry = RequestHandler | {
908
+ path: string;
909
+ handler: RequestHandler;
910
+ };
911
+ /** Options for {@link Application.shutdown}. */
912
+ interface ShutdownOptions {
913
+ /**
914
+ * Close the HTTP server and drain in-flight requests. Default `true`.
915
+ *
916
+ * Set `false` for a dev HMR rebuild, where the server is shared across
917
+ * reloads — adapters, plugins, and disposables are still torn down, which is
918
+ * the part a reload needs.
919
+ */
920
+ closeServer?: boolean;
921
+ }
922
+ interface ApplicationOptions {
923
+ /**
924
+ * Feature modules to load. Accepts both class form
925
+ * (`SomeModule extends AppModule`, instantiated via `new`) and
926
+ * instance form (output of {@link defineModule}'s factory call,
927
+ * e.g. `TasksModule({ scope: 'admin' })`) — the loader discriminates
928
+ * and either `new`-s the class or uses the instance directly.
929
+ *
930
+ * Static path — for conditional / dynamic registration, use the
931
+ * {@link ApplicationOptions.setup} callback instead.
932
+ */
933
+ modules: AppModuleEntry[];
934
+ /**
935
+ * Imperative module registration callback. Receives a
936
+ * {@link ModuleRegistry} you call `.mount(module)` on to register
937
+ * modules conditionally — based on env flags, runtime config, a
938
+ * tenant list, etc. Runs after every plugin's `setup()` hook and
939
+ * after the static `modules: [...]` array is collected.
940
+ *
941
+ * @example
942
+ * ```ts
943
+ * bootstrap({
944
+ * modules: [HelloModule()],
945
+ * setup(registry) {
946
+ * if (env.ENABLE_ADMIN) registry.mount(AdminModule())
947
+ * },
948
+ * })
949
+ * ```
950
+ */
951
+ setup?(registry: ModuleRegistry): void;
952
+ /** Adapters that hook into the lifecycle (DB, Redis, Swagger, etc.) */
953
+ adapters?: AppAdapter[];
954
+ /** Server port (falls back to PORT env var, then 3000) */
955
+ port?: number;
956
+ /** Global API prefix (default: '/api'). Pass `''` to mount at the root. */
957
+ apiPrefix?: string;
958
+ /**
959
+ * Default API version (default: 1) — routes become /{prefix}/v{version}/{path}.
960
+ *
961
+ * `false` opts out of URL versioning: routes mount at /{prefix}/{path}.
962
+ * A module can still version itself by setting `version` on its
963
+ * `ModuleRoutes` — the per-mount value always wins over this default, in
964
+ * either direction.
965
+ */
966
+ defaultVersion?: number | false;
967
+ /**
968
+ * Global middleware pipeline. Declared in order.
969
+ * Replaces the hardcoded middleware stack — you control exactly what runs.
970
+ *
971
+ * @example
972
+ * ```ts
973
+ * bootstrap({
974
+ * modules,
975
+ * middlewares: [
976
+ * helmet(),
977
+ * cors(),
978
+ * compression(),
979
+ * morgan('dev'),
980
+ * express.json({ limit: '1mb' }),
981
+ * ],
982
+ * })
983
+ * ```
984
+ *
985
+ * If omitted, a sensible default is applied:
986
+ * requestId(), express.json({ limit: '100kb' })
987
+ */
988
+ middlewares?: MiddlewareEntry[];
989
+ /** Plugins that bundle modules, adapters, middleware, and DI bindings */
990
+ plugins?: KickPlugin[];
991
+ /**
992
+ * Global Context Contributors (#107) that apply to every route in the
993
+ * application. Merge into the per-route pipeline at the `'global'`
994
+ * precedence level — they lose to module, adapter, class, and method
995
+ * contributors with the same key, providing app-wide defaults that any
996
+ * narrower scope can override.
997
+ *
998
+ * @example
999
+ * ```ts
1000
+ * const StartedAt = defineContextDecorator({
1001
+ * key: 'requestStartedAt',
1002
+ * resolve: () => Date.now(),
1003
+ * })
1004
+ *
1005
+ * bootstrap({
1006
+ * modules,
1007
+ * contributors: [StartedAt.registration],
1008
+ * })
1009
+ * ```
1010
+ */
1011
+ contributors?: ContributorRegistrations;
1012
+ /**
1013
+ * Backing store strategy for {@link RequestContext} `set/get` and the
1014
+ * Context Contributor pipeline (#107).
1015
+ *
1016
+ * - `'auto'` (default) — Application mounts {@link requestScopeMiddleware}
1017
+ * automatically before any user middleware. If the user-supplied
1018
+ * `middleware` list already includes `requestScopeMiddleware()`,
1019
+ * detection skips the auto-mount so adopters can control its position.
1020
+ * - `'manual'` — Application never mounts the wrapper. The Context
1021
+ * Contributor pipeline still runs on every route — the runner is
1022
+ * inserted by `router-builder` regardless of ALS state. What
1023
+ * degrades without an ALS frame is the *backing store*:
1024
+ * REQUEST-scoped DI throws (no `requestStore.getStore()` to read
1025
+ * from) and `RequestContext.set/get` throws. Use `'manual'` only when you
1026
+ * genuinely intend to wrap requests in your own ALS frame (rare —
1027
+ * multi-tenant adapters used to do this; post-Phase 3 they share
1028
+ * the framework's frame instead).
1029
+ */
1030
+ contextStore?: 'auto' | 'manual';
1031
+ /**
1032
+ * Controls whether KickJS registers process-level handlers at bootstrap.
1033
+ *
1034
+ * - `'auto'` (default) — register `uncaughtException` /
1035
+ * `unhandledRejection` loggers AND `SIGINT` / `SIGTERM` →
1036
+ * `app.shutdown()` → `process.exit(0)`.
1037
+ * - `'errors-only'` — register the error loggers; skip the signal
1038
+ * handlers. Use this when you have your own shutdown choreographer
1039
+ * (OpenTelemetry SDK, Sentry, custom orchestrator) that calls
1040
+ * `app.shutdown()` itself and you don't want two listeners racing
1041
+ * to call `process.exit`.
1042
+ * - `'manual'` — skip everything. Adopter is responsible for both
1043
+ * error logging and signal-driven shutdown.
1044
+ *
1045
+ * Background: many observability SDKs install their own SIGTERM
1046
+ * handler to flush spans/metrics before the process exits. Two
1047
+ * separate handlers calling `process.exit(0)` race each other and
1048
+ * can truncate the in-flight flush. Setting this to `'errors-only'`
1049
+ * or `'manual'` lets the SDK own the lifecycle while still letting
1050
+ * KickJS surface uncaught exceptions / rejections via the logger.
1051
+ *
1052
+ * The dev mode auto-detect (`__kickjs_httpServer` set by the Vite
1053
+ * plugin) suppresses signal registration regardless of this option,
1054
+ * since Vite owns the lifecycle in development.
1055
+ */
1056
+ processHooks?: 'auto' | 'errors-only' | 'manual';
1057
+ /**
1058
+ * The HTTP engine driver. Defaults to {@link expressRuntime} — Express stays
1059
+ * the zero-config default, so existing apps are unaffected.
1060
+ *
1061
+ * Any `HttpRuntime` is accepted — pass `fastifyRuntime()` (from
1062
+ * `@forinda/kickjs/fastify`) or a custom engine driver. Defaults to
1063
+ * {@link expressRuntime}. The engine-native escape hatches
1064
+ * (`getRuntimeApp()`, `AdapterContext.app`) follow the active runtime via the
1065
+ * registry (`ActiveRuntime`, spec §4.3b) — Express by default, or the augmented
1066
+ * engine once the `kick/runtime` typegen output is present.
1067
+ */
1068
+ /**
1069
+ * Mount the built-in `GET /health/live` and `GET /health/ready`.
1070
+ *
1071
+ * On by default. Set `false` to take them over completely — supply your own
1072
+ * module at `/health` and nothing collides. The built-in is registered last,
1073
+ * so an app module claiming the same path already wins without this.
1074
+ *
1075
+ * They mount as an ordinary module, which means they sit inside the
1076
+ * middleware chain: whatever guards the rest of the app guards these too.
1077
+ * Pass `{ flags: [...] }` to put your own route flags on both probes — the
1078
+ * way to make them reachable unauthenticated without exempting a pathname
1079
+ * that can move:
1080
+ *
1081
+ * ```ts
1082
+ * bootstrap({ health: { flags: ['auth.public'] } })
1083
+ * ```
1084
+ */
1085
+ health?: boolean | HealthModuleConfig;
1086
+ runtime?: HttpRuntime;
1087
+ /** Express `trust proxy` setting */
1088
+ trustProxy?: boolean | number | string | ((ip: string, hopIndex: number) => boolean);
1089
+ /** Maximum JSON body size (only used when middleware is not provided) */
1090
+ jsonLimit?: string | number;
1091
+ /**
1092
+ * Print the route table on startup. Default: `false`. Set to `true`
1093
+ * to log a per-controller summary (method counts + mount paths) once
1094
+ * the app has mounted. Emitted at `info` level, so it is still subject
1095
+ * to `LOG_LEVEL` filtering (visible at the default `info`; hidden at
1096
+ * `warn`/`error`/`silent`).
1097
+ */
1098
+ logRouteTable?: boolean;
1099
+ /**
1100
+ * @deprecated Use {@link ApplicationOptions.logRouteTable}. Kept as an
1101
+ * alias for back-compat; `logRouteTable` wins when both are set.
1102
+ */
1103
+ logRoutesTable?: boolean;
1104
+ /**
1105
+ * Maximum time (ms) to wait for graceful shutdown before forcing exit.
1106
+ * Default: 30000 (30 seconds). Set to 0 to disable forced exit.
1107
+ */
1108
+ shutdownTimeout?: number;
1109
+ /**
1110
+ * Enable cluster mode for multi-core utilization.
1111
+ *
1112
+ * When enabled, the primary process forks worker processes that share the
1113
+ * same port via Node's built-in `cluster` module (OS load balancing).
1114
+ *
1115
+ * - `true` — use all available CPU cores
1116
+ * - `{ workers: N }` — use exactly N workers
1117
+ *
1118
+ * Workers are auto-restarted on crash. SIGTERM/SIGINT on the primary is
1119
+ * forwarded to all workers.
1120
+ *
1121
+ * @example
1122
+ * ```ts
1123
+ * bootstrap({ modules, cluster: true })
1124
+ * bootstrap({ modules, cluster: { workers: 4 } })
1125
+ * ```
1126
+ */
1127
+ cluster?: boolean | {
1128
+ workers?: number;
1129
+ };
1130
+ /**
1131
+ * Custom 404 handler for unmatched routes. When omitted, the built-in
1132
+ * handler returns `{ message: 'Not Found' }` with status 404.
1133
+ *
1134
+ * Connect-**shaped**, not Express-**semantic** — see {@link onError} for the
1135
+ * per-runtime table. The same two caveats apply: `next()` is inert on
1136
+ * Fastify and h3, and Express-only request members (`req.originalUrl`,
1137
+ * `req.path`, `req.ip`) are `undefined` there, so read `req.url`.
1138
+ *
1139
+ * @example
1140
+ * ```ts
1141
+ * bootstrap({
1142
+ * modules,
1143
+ * onNotFound: (req, res) => {
1144
+ * // `req.originalUrl` is Express-only — use `req.url` for portability.
1145
+ * res.status(404).json({ error: 'Route not found', path: req.url })
1146
+ * },
1147
+ * })
1148
+ * ```
1149
+ */
1150
+ onNotFound?: (req: any, res: RuntimeResponse, next: (err?: unknown) => void) => void;
1151
+ /**
1152
+ * Custom global error handler, receiving `(err, req, res, next)`. When
1153
+ * omitted, the built-in handler formats ZodError, HttpException, and
1154
+ * unexpected errors.
1155
+ *
1156
+ * The shape is connect-style, but it is NOT "the standard Express error
1157
+ * handler" on every engine — what you actually receive differs, and the
1158
+ * differences bite:
1159
+ *
1160
+ * | | `req` | `res` | `next` |
1161
+ * | --- | --- | --- | --- |
1162
+ * | Express | native `Request` | native `Response` | real `next` |
1163
+ * | Fastify | `request.raw` | reply driver | **no-op** |
1164
+ * | h3 | `event.node.req` | response driver | no-op (or dev fall-through) |
1165
+ *
1166
+ * Two consequences worth knowing before you write one:
1167
+ *
1168
+ * - **`next(err)` does nothing on Fastify and h3.** It is a no-op function
1169
+ * there, so delegating to the default handler silently drops the error.
1170
+ * Send a response yourself rather than passing it on.
1171
+ * - **Express-only request members are `undefined` elsewhere.**
1172
+ * `req.originalUrl`, `req.path`, and `req.ip` do not exist on the raw node
1173
+ * request — use `req.url` and the `x-forwarded-*` headers, or reach for
1174
+ * `ctx.ip` in a contributor / guard where a `RequestContext` is available.
1175
+ *
1176
+ * `res` is typed {@link RuntimeResponse} because that is what every engine
1177
+ * genuinely provides: `status`, `json`, `send`, `setHeader`, `render`,
1178
+ * `writeHead`, `end`. Express's own `Response` satisfies it.
1179
+ *
1180
+ * @example
1181
+ * ```ts
1182
+ * bootstrap({
1183
+ * modules,
1184
+ * onError: (err, req, res) => {
1185
+ * logger.error(err, `${req.method} ${req.url}`) // not `originalUrl`
1186
+ * res.status(err.status ?? 500).json({ error: err.message })
1187
+ * },
1188
+ * })
1189
+ * ```
1190
+ */
1191
+ onError?: (err: any, req: any, res: RuntimeResponse, next: (err?: unknown) => void) => void;
1192
+ /**
1193
+ * Security defaults applied automatically unless opted out.
1194
+ *
1195
+ * When not specified, secure defaults are applied:
1196
+ * - Helmet security headers are auto-injected
1197
+ * - JSON body limit defaults to 1MB
1198
+ *
1199
+ * @example
1200
+ * ```ts
1201
+ * bootstrap({
1202
+ * modules,
1203
+ * security: {
1204
+ * helmet: false, // disable auto-helmet
1205
+ * },
1206
+ * })
1207
+ * ```
1208
+ */
1209
+ security?: {
1210
+ /** Auto-inject helmet security headers. Default: true */
1211
+ helmet?: boolean;
1212
+ };
1213
+ }
1214
+ declare class Application {
1215
+ private readonly options;
1216
+ private app;
1217
+ /** The HTTP engine driver. Defaults to {@link expressRuntime}. */
1218
+ private readonly runtime;
1219
+ private container;
1220
+ private httpServer;
1221
+ private readonly adapters;
1222
+ /**
1223
+ * Flags of every mounted route, for middleware that runs before routing and
1224
+ * therefore cannot read `ctx.route` (the connect-style rate limiter). Handed
1225
+ * to middleware that declares the slot — see `core/route-policy.ts`.
1226
+ */
1227
+ private readonly routePolicy;
1228
+ private readonly plugins;
1229
+ /**
1230
+ * Snapshot of every module-level Context Contributor registration
1231
+ * captured during `setup()`. The registrations themselves are
1232
+ * frozen by `defineContextDecorator`, so storing references is
1233
+ * safe — they outlive the module instances they came from.
1234
+ *
1235
+ * Used by {@link getContributors} so DevTools and adopter tooling
1236
+ * can render the module-level contributors alongside the adapter /
1237
+ * plugin / global ones. Populated once per `setup()` call; cleared
1238
+ * at the start of each invocation so a re-setup (test harnesses,
1239
+ * dev-server restarts) doesn't accumulate stale entries.
1240
+ */
1241
+ private _moduleContributors;
1242
+ /** Number of HTTP requests currently being processed */
1243
+ private _inFlightRequests;
1244
+ /** Whether the application is draining (shutting down gracefully) */
1245
+ private _draining;
1246
+ /** Whether shutdown has already been initiated (prevents double-shutdown) */
1247
+ private _shutdownInitiated;
1248
+ /** Resolvers waiting for in-flight requests to reach zero */
1249
+ private _drainResolvers;
1250
+ constructor(options: ApplicationOptions);
1251
+ /** Whether the application is currently draining in-flight requests */
1252
+ get isDraining(): boolean;
1253
+ /** Number of HTTP requests currently being processed */
1254
+ get inFlightRequests(): number;
1255
+ /** Get the DI container instance */
1256
+ getContainer(): Container;
1257
+ /**
1258
+ * Express request handler — delegates to the internal Express app.
1259
+ *
1260
+ * Used by the Vite dev-server plugin to route requests through KickJS:
1261
+ * ```ts
1262
+ * const mod = await ssrLoadModule('virtual:kickjs/app')
1263
+ * mod.app.handle(req, res, next)
1264
+ * ```
1265
+ *
1266
+ * Also works as a standard Node.js request handler for production:
1267
+ * ```ts
1268
+ * http.createServer(app.handle.bind(app))
1269
+ * ```
1270
+ */
1271
+ handle(req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void): void;
1272
+ /**
1273
+ * Full setup pipeline:
1274
+ * 1. Adapter beforeMount hooks (early routes — e.g. docs UI)
1275
+ * 2. Adapter middleware (phase: beforeGlobal)
1276
+ * 3. Global middleware (user-declared or defaults)
1277
+ * 4. Adapter middleware (phase: afterGlobal)
1278
+ * 5. Module registration + DI bootstrap (the built-in health module mounts
1279
+ * here with everything else — it is NOT an early route)
1280
+ * 6. Adapter middleware (phase: beforeRoutes)
1281
+ * 7. Module route mounting
1282
+ * 8. Adapter middleware (phase: afterRoutes)
1283
+ * 9. Adapter beforeStart hooks
1284
+ * 10. Error handlers (notFound + global)
1285
+ */
1286
+ /** Build the adapter context object (shared across all hooks) */
1287
+ private adapterCtx;
1288
+ /**
1289
+ * The engine-agnostic HTTP surface handed to adapters as `ctx.http`. Each
1290
+ * call routes through the active runtime over the current `this.app`, so an
1291
+ * adapter written against this works under any runtime.
1292
+ */
1293
+ private adapterHttp;
1294
+ /** Call an adapter hook, awaiting async hooks and catching errors */
1295
+ private callHook;
1296
+ setup(): Promise<void>;
1297
+ /** Register modules and DI without starting the HTTP server (used by kick tinker) */
1298
+ registerOnly(): Promise<void>;
1299
+ /**
1300
+ * Start the HTTP server.
1301
+ *
1302
+ * In **dev mode** (Vite plugin active): reuses `globalThis.__kickjs_httpServer`
1303
+ * created by Vite. Adapters (WsAdapter, Socket.IO, etc.) receive the real
1304
+ * `http.Server` through `afterStart({ server })` — zero adapter changes needed.
1305
+ *
1306
+ * In **production**: creates its own `http.Server` and binds to the port.
1307
+ */
1308
+ start(): Promise<void>;
1309
+ /** HMR rebuild: swap Express handler without restarting the server */
1310
+ rebuild(): Promise<void>;
1311
+ /**
1312
+ * Graceful shutdown with request draining.
1313
+ *
1314
+ * 1. Stops accepting new connections (server.close())
1315
+ * 2. Waits for in-flight requests to complete (up to shutdownTimeout)
1316
+ * 3. Calls adapter.shutdown() for all registered adapters
1317
+ * 4. Force-closes after timeout
1318
+ *
1319
+ * Safe to call multiple times — subsequent calls return the same promise.
1320
+ */
1321
+ shutdown(options?: ShutdownOptions): Promise<void>;
1322
+ /**
1323
+ * The engine-native app instance, typed from the active runtime
1324
+ * ({@link ActiveRuntime} — Express by default). Prefer this over
1325
+ * {@link getExpressApp}; under a non-Express runtime the type follows the
1326
+ * augmented registry.
1327
+ */
1328
+ getRuntimeApp(): ActiveRuntime['app'];
1329
+ /**
1330
+ * The active HTTP runtime's identity + capabilities — `name` is `'express'`
1331
+ * (default), `'fastify'`, or `'h3'`; `capabilities` reports what the engine
1332
+ * supports (render / uploads / connectMiddleware / nativeBodyParsing).
1333
+ * Surfaced by DevTools and the VS Code extension so tooling can show which
1334
+ * engine the app is running on. Cheap, side-effect free.
1335
+ */
1336
+ getActiveRuntime(): {
1337
+ name: string;
1338
+ capabilities: RuntimeCapabilities;
1339
+ };
1340
+ /** @deprecated Use {@link getRuntimeApp}. Returns the engine-native app. */
1341
+ getExpressApp(): Express;
1342
+ /** Get registered adapters — used by DevToolsAdapter for peer discovery */
1343
+ getAdapters(): AppAdapter[];
1344
+ /**
1345
+ * Get registered plugins — used by DevToolsAdapter for topology
1346
+ * introspection (architecture.md §23). Read-only; returns the
1347
+ * already-sorted plugin list (post-`dependsOn` topo-sort).
1348
+ */
1349
+ getPlugins(): readonly KickPlugin[];
1350
+ /**
1351
+ * Snapshot of every Context Contributor reachable from this app —
1352
+ * walks **four** registration sites: adapters, plugins, modules,
1353
+ * and the bootstrap `contributors` option. The devtools Topology
1354
+ * tab consumes this for the Contributors panel; tests + adopters
1355
+ * can call it for diagnostics.
1356
+ *
1357
+ * Per-route (method/class-decorator) registrations are NOT included
1358
+ * here — they live on the route registry rather than on any of
1359
+ * the four collection sites this method walks. A future RPC will
1360
+ * surface them separately.
1361
+ *
1362
+ * Result shape stays minimal — `{ key, source, label, dependsOn }`
1363
+ * — so we don't leak `resolve` closures or other internal fields.
1364
+ * `source` matches the five-level precedence union from
1365
+ * `ContributorSource` (minus `'method'` / `'class'` which require
1366
+ * the per-route walk noted above).
1367
+ */
1368
+ getContributors(): ReadonlyArray<{
1369
+ key: string;
1370
+ source: 'module' | 'adapter' | 'plugin' | 'global';
1371
+ label: string;
1372
+ dependsOn: readonly string[];
1373
+ }>;
1374
+ getHttpServer(): http.Server | null;
1375
+ /**
1376
+ * Decide whether {@link Application} should auto-mount the
1377
+ * {@link requestScopeMiddleware} ALS wrapper.
1378
+ *
1379
+ * Returns `false` when:
1380
+ * - `contextStore: 'manual'` was set (caller manages ALS frames), or
1381
+ * - the user-supplied `middleware` list already includes a
1382
+ * `requestScopeMiddleware()` (detected via the symbol marker stamped
1383
+ * in `middleware/request-scope.ts`).
1384
+ *
1385
+ * Otherwise `true` — preserves the historical default of "always wrap
1386
+ * requests in an ALS frame" so existing apps see no behavior change.
1387
+ */
1388
+ private shouldAutoMountRequestScope;
1389
+ private collectAdapterMiddleware;
1390
+ private mountMiddlewareList;
1391
+ private mountMiddlewareEntry;
1392
+ /** Middleware that tracks in-flight requests for graceful draining */
1393
+ private requestTrackingMiddleware;
1394
+ }
1395
+ //#endregion
1396
+ export { CircuitBreakerOptions as $, ClusterOptions as A, groupAssetKeys as B, getRequestStore as C, expressRuntime as D, buildRoutes as E, offerRoutePolicy as F, MountKind as G, DuplicateMountNameError as H, AssetKeyPair as I, ContributorCycleError as J, MountSortItem as K, AssetKeyStrategy as L, bootstrap as M, RoutePolicyTable as N, materializeRouter as O, bindRoutePolicy as P, CircuitBreaker as Q, GroupAssetKeysOptions as R, RequestStore as S, requestStore as T, MissingMountDepError as U, stripExt as V, MountCycleError as W, MissingContextValueError as X, DuplicateContributorError as Y, MissingContributorError as Z, TraceContext as _, HEALTH_PROBE as a, KickErrorInit as at, traceContext as b, HealthModuleConfig as c, disposeAll as ct, SpaAdapter as d, CircuitBreakerState as et, SpaAdapterOptions as f, TRACEPARENT_HEADER as g, ViewAdapterOptions as h, ShutdownOptions as i, KickError as it, isClusterPrimary as j, defineHttpContextDecorator as k, HealthProbe as l, registerDisposable as lt, ViewAdapter as m, ApplicationOptions as n, CircuitOpenError as nt, HealthCheckResult as o, formatKickError as ot, resolveClientDir as p, mountSort as q, MiddlewareEntry as r, FormatKickErrorOptions as rt, HealthController as s, Disposable as st, Application as t, CircuitBreakerStats as tt, healthModule as u, TraceContextOptions as v, getRequestValue as w, requestScopeMiddleware as x, parseTraceparent as y, GroupAssetKeysResult as z };
1397
+ //# sourceMappingURL=application-NBph8Ahc.d.mts.map