@forinda/kickjs 3.2.0 → 4.1.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.
- package/README.md +13 -212
- package/dist/adapter-6Pp4kFdM.d.mts +296 -0
- package/dist/adapter-6Pp4kFdM.d.mts.map +1 -0
- package/dist/{app-module-ERR9jhow.d.mts → app-module-Blgz4Rti.d.mts} +4 -4
- package/dist/app-module-Blgz4Rti.d.mts.map +1 -0
- package/dist/application-Bepa-pFw.d.mts +302 -0
- package/dist/application-Bepa-pFw.d.mts.map +1 -0
- package/dist/{application-x8CXLOlv.mjs → application-DvmPMUgF.mjs} +28 -9
- package/dist/application-DvmPMUgF.mjs.map +1 -0
- package/dist/bootstrap-B4T3X2B6.d.mts +28 -0
- package/dist/bootstrap-B4T3X2B6.d.mts.map +1 -0
- package/dist/{bootstrap-CYnxozL_.mjs → bootstrap-THfr8phJ.mjs} +6 -6
- package/dist/{bootstrap-CYnxozL_.mjs.map → bootstrap-THfr8phJ.mjs.map} +1 -1
- package/dist/{cache-V91BNTIM.d.mts → cache-XrNWj1KQ.d.mts} +3 -3
- package/dist/{cache-V91BNTIM.d.mts.map → cache-XrNWj1KQ.d.mts.map} +1 -1
- package/dist/config/index.d.mts +1 -1
- package/dist/config/index.mjs +3 -3
- package/dist/{config-aWxKLk4A.mjs → config-BEjgF1fI.mjs} +4 -4
- package/dist/{config-aWxKLk4A.mjs.map → config-BEjgF1fI.mjs.map} +1 -1
- package/dist/{container-Dnk43k54.mjs → container-BYuMSnqW.mjs} +314 -9
- package/dist/container-BYuMSnqW.mjs.map +1 -0
- package/dist/{container-fIS1uLx-.d.mts → container-CnWDsxi-.d.mts} +9 -7
- package/dist/container-CnWDsxi-.d.mts.map +1 -0
- package/dist/{context-OktlOQBQ.mjs → context-CyQbqSz-.mjs} +33 -41
- package/dist/context-CyQbqSz-.mjs.map +1 -0
- package/dist/context-Ymvv-85x.d.mts +260 -0
- package/dist/context-Ymvv-85x.d.mts.map +1 -0
- package/dist/{context-decorator-GA8-hDLe.d.mts → context-decorator-DrPvQ9Ag.d.mts} +62 -12
- package/dist/context-decorator-DrPvQ9Ag.d.mts.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.d.mts +1 -1
- package/dist/core/cache.mjs +3 -3
- package/dist/core/cache.mjs.map +1 -1
- package/dist/core/container.d.mts +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.d.mts +1 -1
- package/dist/core/cron.mjs +3 -3
- package/dist/core/cron.mjs.map +1 -1
- package/dist/core/decorators.d.mts +2 -2
- package/dist/core/decorators.mjs +48 -16
- package/dist/core/decorators.mjs.map +1 -1
- 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 +35 -18
- package/dist/core/interfaces.mjs.map +1 -1
- package/dist/core/logger.d.mts +2 -2
- package/dist/core/logger.mjs +2 -4
- package/dist/core/logger.mjs.map +1 -1
- package/dist/core/path.d.mts +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-DANnH5-e.mjs → core-Dj3iVQ3t.mjs} +305 -8
- package/dist/core-Dj3iVQ3t.mjs.map +1 -0
- package/dist/cors-BfgqfLPd.d.mts +48 -0
- package/dist/cors-BfgqfLPd.d.mts.map +1 -0
- package/dist/{cron-CfsPdi7R.d.mts → cron-GNoYydfg.d.mts} +2 -2
- package/dist/cron-GNoYydfg.d.mts.map +1 -0
- package/dist/csrf-DiK9zept.d.mts +52 -0
- package/dist/csrf-DiK9zept.d.mts.map +1 -0
- package/dist/{decorators-H42oPg0m.d.mts → decorators-BMvaLliz.d.mts} +147 -12
- package/dist/decorators-BMvaLliz.d.mts.map +1 -0
- package/dist/{env-Cs8Wt8A_.mjs → env-DMqv56Bb.mjs} +3 -4
- package/dist/{env-Cs8Wt8A_.mjs.map → env-DMqv56Bb.mjs.map} +1 -1
- package/dist/error-handler-Xud_3Lah.d.mts +20 -0
- package/dist/error-handler-Xud_3Lah.d.mts.map +1 -0
- package/dist/{errors-D_CWI7Bl.d.mts → errors-uaHCeXRz.d.mts} +1 -1
- package/dist/{errors-D_CWI7Bl.d.mts.map → errors-uaHCeXRz.d.mts.map} +1 -1
- package/dist/{execution-context-Dl2CKqSo.d.mts → execution-context-DKnt61pY.d.mts} +1 -1
- package/dist/{execution-context-Dl2CKqSo.d.mts.map → execution-context-DKnt61pY.d.mts.map} +1 -1
- package/dist/helmet-CaMbjzBG.d.mts +41 -0
- package/dist/helmet-CaMbjzBG.d.mts.map +1 -0
- package/dist/http/application.d.mts +2 -293
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +2 -27
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +3 -251
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.d.mts +2 -47
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.d.mts +2 -51
- package/dist/http/middleware/csrf.mjs +2 -2
- package/dist/http/middleware/csrf.mjs.map +1 -1
- package/dist/http/middleware/error-handler.d.mts +2 -19
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.d.mts +2 -40
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.d.mts +2 -55
- package/dist/http/middleware/rate-limit.mjs +2 -2
- package/dist/http/middleware/rate-limit.mjs.map +1 -1
- package/dist/http/middleware/request-id.d.mts +2 -9
- package/dist/http/middleware/request-id.mjs +12 -3
- package/dist/http/middleware/request-id.mjs.map +1 -1
- package/dist/http/middleware/request-logger.d.mts +2 -31
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.d.mts +2 -69
- package/dist/http/middleware/session.mjs +1 -1
- package/dist/http/middleware/spa.d.mts +2 -100
- package/dist/http/middleware/spa.mjs +5 -5
- package/dist/http/middleware/spa.mjs.map +1 -1
- package/dist/http/middleware/upload.d.mts +2 -78
- package/dist/http/middleware/upload.mjs +1 -1
- package/dist/http/middleware/validate.d.mts +2 -22
- package/dist/http/middleware/validate.mjs +2 -2
- package/dist/http/middleware/views.d.mts +2 -61
- package/dist/http/middleware/views.mjs +16 -15
- package/dist/http/middleware/views.mjs.map +1 -1
- package/dist/http/query/index.d.mts +1 -1
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +2 -32
- package/dist/http/router-builder.mjs +10 -14
- package/dist/http/router-builder.mjs.map +1 -1
- package/dist/{index-RNK41JPE.d.mts → index-B9cyOQAe.d.mts} +1 -1
- package/dist/{index-RNK41JPE.d.mts.map → index-B9cyOQAe.d.mts.map} +1 -1
- package/dist/{index-Cf-MGrqT.d.mts → index-D-qhXg9M.d.mts} +3 -3
- package/dist/{index-Cf-MGrqT.d.mts.map → index-D-qhXg9M.d.mts.map} +1 -1
- package/dist/{index-BQM9pJrV.d.mts → index-Yhs9sTMW.d.mts} +241 -5
- package/dist/index-Yhs9sTMW.d.mts.map +1 -0
- package/dist/index.d.mts +34 -152
- package/dist/index.mjs +50 -14
- package/dist/index.mjs.map +1 -1
- package/dist/interfaces-B50n7dwl.d.mts +71 -0
- package/dist/{interfaces-CwcdqfNq.d.mts.map → interfaces-B50n7dwl.d.mts.map} +1 -1
- package/dist/{logger-GK8yT0BD.d.mts → logger-CLVRZf2N.d.mts} +2 -4
- package/dist/{logger-GK8yT0BD.d.mts.map → logger-CLVRZf2N.d.mts.map} +1 -1
- package/dist/{metadata-BFuoSEX6.mjs → metadata-BF1WDBOh.mjs} +2 -2
- package/dist/{metadata-BFuoSEX6.mjs.map → metadata-BF1WDBOh.mjs.map} +1 -1
- package/dist/{path-Bj3vZMUY.d.mts → path-Diviu6hv.d.mts} +1 -1
- package/dist/path-Diviu6hv.d.mts.map +1 -0
- package/dist/{plugin-3rKA0Loy.d.mts → plugin-DDjoN4XI.d.mts} +46 -8
- package/dist/plugin-DDjoN4XI.d.mts.map +1 -0
- package/dist/{query-BcYEjYyX.mjs → query-BrYRQMa5.mjs} +2 -2
- package/dist/{query-BcYEjYyX.mjs.map → query-BrYRQMa5.mjs.map} +1 -1
- package/dist/rate-limit-DUwoICtI.d.mts +56 -0
- package/dist/rate-limit-DUwoICtI.d.mts.map +1 -0
- package/dist/{reactivity-CczHu3R-.d.mts → reactivity-CfJceo4H.d.mts} +1 -1
- package/dist/{reactivity-CczHu3R-.d.mts.map → reactivity-CfJceo4H.d.mts.map} +1 -1
- package/dist/request-id-BgglvZHN.d.mts +19 -0
- package/dist/request-id-BgglvZHN.d.mts.map +1 -0
- package/dist/request-logger-CWHbAzTE.d.mts +32 -0
- package/dist/request-logger-CWHbAzTE.d.mts.map +1 -0
- package/dist/router-builder-zsX4Oq7c.d.mts +31 -0
- package/dist/router-builder-zsX4Oq7c.d.mts.map +1 -0
- package/dist/session-N0hActOO.d.mts +70 -0
- package/dist/session-N0hActOO.d.mts.map +1 -0
- package/dist/spa-CwIbdvPc.d.mts +101 -0
- package/dist/spa-CwIbdvPc.d.mts.map +1 -0
- package/dist/upload-BueOnnLw.d.mts +79 -0
- package/dist/upload-BueOnnLw.d.mts.map +1 -0
- package/dist/validate-HwAyWTwH.d.mts +23 -0
- package/dist/validate-HwAyWTwH.d.mts.map +1 -0
- package/dist/views-v05_dP1I.d.mts +181 -0
- package/dist/views-v05_dP1I.d.mts.map +1 -0
- package/package.json +6 -9
- package/dist/adapter-DLEHb0K6.d.mts +0 -151
- package/dist/adapter-DLEHb0K6.d.mts.map +0 -1
- package/dist/app-module-ERR9jhow.d.mts.map +0 -1
- package/dist/application-x8CXLOlv.mjs.map +0 -1
- package/dist/chunk-Bt-rz0Tp.mjs +0 -15
- package/dist/container-Dnk43k54.mjs.map +0 -1
- package/dist/container-fIS1uLx-.d.mts.map +0 -1
- package/dist/context-OktlOQBQ.mjs.map +0 -1
- package/dist/context-decorator-GA8-hDLe.d.mts.map +0 -1
- package/dist/core-DANnH5-e.mjs.map +0 -1
- package/dist/cron-CfsPdi7R.d.mts.map +0 -1
- package/dist/decorators-H42oPg0m.d.mts.map +0 -1
- package/dist/http/application.d.mts.map +0 -1
- package/dist/http/bootstrap.d.mts.map +0 -1
- package/dist/http/context.d.mts.map +0 -1
- package/dist/http/middleware/cors.d.mts.map +0 -1
- package/dist/http/middleware/csrf.d.mts.map +0 -1
- package/dist/http/middleware/error-handler.d.mts.map +0 -1
- package/dist/http/middleware/helmet.d.mts.map +0 -1
- package/dist/http/middleware/rate-limit.d.mts.map +0 -1
- package/dist/http/middleware/request-id.d.mts.map +0 -1
- package/dist/http/middleware/request-logger.d.mts.map +0 -1
- package/dist/http/middleware/session.d.mts.map +0 -1
- package/dist/http/middleware/spa.d.mts.map +0 -1
- package/dist/http/middleware/upload.d.mts.map +0 -1
- package/dist/http/middleware/validate.d.mts.map +0 -1
- package/dist/http/middleware/views.d.mts.map +0 -1
- package/dist/http/router-builder.d.mts.map +0 -1
- package/dist/index-BQM9pJrV.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/interfaces-CwcdqfNq.d.mts +0 -54
- package/dist/path-Bj3vZMUY.d.mts.map +0 -1
- package/dist/plugin-3rKA0Loy.d.mts.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
import { s as InjectionToken, t as Container } from "./container-
|
|
3
|
-
import { n as ExecutionContext } from "./execution-context-
|
|
4
|
-
import {
|
|
2
|
+
import { s as InjectionToken, t as Container } from "./container-CnWDsxi-.mjs";
|
|
3
|
+
import { n as ExecutionContext } from "./execution-context-DKnt61pY.mjs";
|
|
4
|
+
import { a as ContributorRegistration } from "./context-decorator-DrPvQ9Ag.mjs";
|
|
5
|
+
import { r as AppAdapter } from "./adapter-6Pp4kFdM.mjs";
|
|
6
|
+
import { t as KickPlugin } from "./plugin-DDjoN4XI.mjs";
|
|
5
7
|
//#region src/core/metadata.d.ts
|
|
6
8
|
/**
|
|
7
9
|
* Typed utilities for reflect-metadata operations.
|
|
@@ -271,5 +273,239 @@ interface RunContributorsOptions {
|
|
|
271
273
|
*/
|
|
272
274
|
declare function runContributors(options: RunContributorsOptions): Promise<void>;
|
|
273
275
|
//#endregion
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
//#region src/core/mount-sort.d.ts
|
|
277
|
+
/**
|
|
278
|
+
* Topological sort for plugins and adapters with `dependsOn` declarations.
|
|
279
|
+
*
|
|
280
|
+
* Mirrors the algorithm used by the Context Contributor pipeline
|
|
281
|
+
* (`contributor-pipeline.ts:topoSort`) but operates on a name-keyed
|
|
282
|
+
* `MountSortItem` shape rather than a `ContributorRegistration`. Kept
|
|
283
|
+
* standalone instead of factored generic so that:
|
|
284
|
+
*
|
|
285
|
+
* 1. The contributor pipeline doesn't need refactoring (risk reduction).
|
|
286
|
+
* 2. The error classes can carry plugin/adapter-specific diagnostic
|
|
287
|
+
* fields (`kind`, `dependent`) without bending the contributor types.
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* A plugin or adapter that participates in dependency-ordered mounting.
|
|
291
|
+
* Both `KickPlugin` and `AppAdapter` satisfy this shape via their `name`
|
|
292
|
+
* and `dependsOn` fields.
|
|
293
|
+
*/
|
|
294
|
+
interface MountSortItem {
|
|
295
|
+
/** Unique mount name within the plugin/adapter set being sorted. */
|
|
296
|
+
name: string;
|
|
297
|
+
/**
|
|
298
|
+
* Other plugin/adapter names that must mount before this one. Cycles
|
|
299
|
+
* and missing names fail at boot — same fail-fast contract as the
|
|
300
|
+
* Context Contributor pipeline (architecture.md §20.4).
|
|
301
|
+
*/
|
|
302
|
+
dependsOn?: readonly string[];
|
|
303
|
+
}
|
|
304
|
+
/** What kind of mount set the sort is operating on — surfaces in error messages. */
|
|
305
|
+
type MountKind = 'plugin' | 'adapter';
|
|
306
|
+
/**
|
|
307
|
+
* Two items in the same mount set declared the same `name`. Plugin/adapter
|
|
308
|
+
* names must be unique so `dependsOn` references resolve unambiguously.
|
|
309
|
+
*/
|
|
310
|
+
declare class DuplicateMountNameError extends Error {
|
|
311
|
+
readonly kind: MountKind;
|
|
312
|
+
readonly mountName: string;
|
|
313
|
+
constructor(kind: MountKind, mountName: string);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* A `dependsOn` entry references a plugin/adapter that isn't in the
|
|
317
|
+
* current set. The dependency might not be installed, might be misspelled,
|
|
318
|
+
* or might live in a different mount set (plugin referencing an adapter,
|
|
319
|
+
* or vice versa — they sort independently).
|
|
320
|
+
*/
|
|
321
|
+
declare class MissingMountDepError extends Error {
|
|
322
|
+
readonly kind: MountKind;
|
|
323
|
+
readonly missing: string;
|
|
324
|
+
readonly dependent: string;
|
|
325
|
+
constructor(kind: MountKind, missing: string, dependent: string);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The `dependsOn` declarations form a cycle. Boot fails so the cycle
|
|
329
|
+
* can't poison live traffic. The `cycle` field reports one path through
|
|
330
|
+
* the offending nodes for diagnostics — formatted `A → B → C → A`.
|
|
331
|
+
*/
|
|
332
|
+
declare class MountCycleError extends Error {
|
|
333
|
+
readonly kind: MountKind;
|
|
334
|
+
readonly cycle: readonly string[];
|
|
335
|
+
constructor(kind: MountKind, cycle: readonly string[]);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Topologically sort `items` so every item with `dependsOn: ['X']` mounts
|
|
339
|
+
* after `X`. Items without `dependsOn` keep their input order via Kahn's
|
|
340
|
+
* algorithm with a FIFO queue seeded in input order — preserves the
|
|
341
|
+
* historical "plugins/adapters mount in declaration order" behaviour for
|
|
342
|
+
* any set that doesn't use `dependsOn`.
|
|
343
|
+
*
|
|
344
|
+
* @param items - mountable items, e.g. plugins or adapters
|
|
345
|
+
* @param kind - 'plugin' | 'adapter', used in error messages
|
|
346
|
+
* @returns a new array in valid mount order
|
|
347
|
+
* @throws {DuplicateMountNameError} two items share a name
|
|
348
|
+
* @throws {MissingMountDepError} a `dependsOn` references an unknown name
|
|
349
|
+
* @throws {MountCycleError} the dep graph contains a cycle
|
|
350
|
+
*/
|
|
351
|
+
declare function mountSort<T extends MountSortItem>(items: readonly T[], kind: MountKind): T[];
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/core/define-plugin.d.ts
|
|
354
|
+
/**
|
|
355
|
+
* Options passed to {@link definePlugin}. Mirrors the spec in
|
|
356
|
+
* `architecture.md` §21.3.1 + §21.2.2 (Phase A "lite").
|
|
357
|
+
*/
|
|
358
|
+
interface DefinePluginOptions<TConfig> {
|
|
359
|
+
/** Stable identity used for logging, `dependsOn` lookups, and `.scoped()` namespacing. */
|
|
360
|
+
name: string;
|
|
361
|
+
/** Optional plugin version — surfaced to DevTools and `kick add` compatibility checks (Phase B). */
|
|
362
|
+
version?: string;
|
|
363
|
+
/**
|
|
364
|
+
* Peer-version ranges this plugin needs from the framework or other
|
|
365
|
+
* plugins. Recorded as metadata; runtime enforcement lands in §21.4.4.
|
|
366
|
+
*/
|
|
367
|
+
requires?: {
|
|
368
|
+
kickjs?: string;
|
|
369
|
+
};
|
|
370
|
+
/** Default config merged under any caller overrides. */
|
|
371
|
+
defaults?: Partial<TConfig>;
|
|
372
|
+
/** Builds the underlying {@link KickPlugin} from the resolved config. */
|
|
373
|
+
build(config: TConfig, ctx: BuildContext): Omit<KickPlugin, 'name'>;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Hook context handed to a plugin/adapter `build` function. `name` is the
|
|
377
|
+
* resolved instance name (the bare definition name for the bare call,
|
|
378
|
+
* or `${defName}:${scope}` for `.scoped()`). `scoped` is the discriminator
|
|
379
|
+
* authors use to namespace DI tokens or resource keys.
|
|
380
|
+
*/
|
|
381
|
+
interface BuildContext {
|
|
382
|
+
name: string;
|
|
383
|
+
scoped: boolean;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Async-config form of a plugin or adapter — `inject` lists DI tokens to
|
|
387
|
+
* resolve from the container, then `useFactory` produces the config.
|
|
388
|
+
*
|
|
389
|
+
* Plugins resolve this lazily inside `onReady`, so any module/adapter/
|
|
390
|
+
* middleware/contributor a plugin contributes via `build` is **not
|
|
391
|
+
* available** when `.async()` is used. Use the bare/`.scoped()` form for
|
|
392
|
+
* plugins that need to register modules or middleware.
|
|
393
|
+
*/
|
|
394
|
+
interface PluginAsyncOptions<TConfig> {
|
|
395
|
+
inject?: ReadonlyArray<unknown>;
|
|
396
|
+
useFactory(...deps: any[]): TConfig | Promise<TConfig>;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Factory returned by {@link definePlugin}. Callable form is the singleton
|
|
400
|
+
* (`AuthPlugin(config)`); `.scoped()` and `.async()` are the multi-instance
|
|
401
|
+
* and deferred-config forms.
|
|
402
|
+
*/
|
|
403
|
+
interface PluginFactory<TConfig> {
|
|
404
|
+
(config?: Partial<TConfig>): KickPlugin;
|
|
405
|
+
scoped(scopeName: string, config?: Partial<TConfig>): KickPlugin;
|
|
406
|
+
async(opts: PluginAsyncOptions<TConfig>): KickPlugin;
|
|
407
|
+
/** Read-only access to the original definition — useful for DevTools introspection. */
|
|
408
|
+
readonly definition: Readonly<DefinePluginOptions<TConfig>>;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Build a {@link KickPlugin} factory from a typed definition. See
|
|
412
|
+
* `architecture.md` §21.2.2 for the design rationale.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* const FlagsPlugin = definePlugin<FlagsConfig>({
|
|
417
|
+
* name: 'FlagsPlugin',
|
|
418
|
+
* defaults: { defaultTtl: 60_000 },
|
|
419
|
+
* build(config) {
|
|
420
|
+
* return {
|
|
421
|
+
* register(container) {
|
|
422
|
+
* container.registerInstance(FLAGS, makeProvider(config))
|
|
423
|
+
* },
|
|
424
|
+
* }
|
|
425
|
+
* },
|
|
426
|
+
* })
|
|
427
|
+
*
|
|
428
|
+
* bootstrap({ plugins: [FlagsPlugin({ provider: launchDarkly })] })
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
declare function definePlugin<TConfig = Record<string, unknown>>(options: DefinePluginOptions<TConfig>): PluginFactory<TConfig>;
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/core/define-adapter.d.ts
|
|
434
|
+
/**
|
|
435
|
+
* Options passed to {@link defineAdapter}. Mirrors {@link DefinePluginOptions}
|
|
436
|
+
* exactly — see `architecture.md` §21.3.4 for the definePlugin/defineAdapter
|
|
437
|
+
* symmetry rationale.
|
|
438
|
+
*
|
|
439
|
+
* The optional `TExtra` generic lets an adapter ship public methods
|
|
440
|
+
* beyond the standard {@link AppAdapter} contract — they're preserved
|
|
441
|
+
* on the returned adapter instance so external callers (tests, peer
|
|
442
|
+
* adapters) can invoke them directly. See `OtelAdapter.applyRedaction`
|
|
443
|
+
* for the canonical use case.
|
|
444
|
+
*/
|
|
445
|
+
interface DefineAdapterOptions<TConfig, TExtra = unknown> {
|
|
446
|
+
/**
|
|
447
|
+
* Stable identity used for logging, `dependsOn` lookups, and `.scoped()`
|
|
448
|
+
* namespacing. Required for adapters that participate in `dependsOn`
|
|
449
|
+
* sort — error messages reference adapters by name.
|
|
450
|
+
*/
|
|
451
|
+
name: string;
|
|
452
|
+
version?: string;
|
|
453
|
+
requires?: {
|
|
454
|
+
kickjs?: string;
|
|
455
|
+
};
|
|
456
|
+
defaults?: Partial<TConfig>;
|
|
457
|
+
build(config: TConfig, ctx: BuildContext): Omit<AppAdapter, 'name'> & TExtra;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Async-config form of an adapter. Identical shape to `PluginAsyncOptions`
|
|
461
|
+
* but resolved during `beforeStart` (the earliest async hook in
|
|
462
|
+
* `AppAdapter`) — meaning `middleware()` and `contributors()` from the inner
|
|
463
|
+
* adapter are **not** picked up. Use the bare/`.scoped()` form when you need
|
|
464
|
+
* those.
|
|
465
|
+
*/
|
|
466
|
+
interface AdapterAsyncOptions<TConfig> {
|
|
467
|
+
inject?: ReadonlyArray<unknown>;
|
|
468
|
+
useFactory(...deps: any[]): TConfig | Promise<TConfig>;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Factory returned by {@link defineAdapter}. Same surface as
|
|
472
|
+
* {@link PluginFactory} (call / `.scoped()` / `.async()`) so adopters learn
|
|
473
|
+
* one mental model for both primitives. Returned instances carry both
|
|
474
|
+
* the standard {@link AppAdapter} contract and any `TExtra` extension
|
|
475
|
+
* methods the `build` function exposed.
|
|
476
|
+
*/
|
|
477
|
+
interface AdapterFactory<TConfig, TExtra = unknown> {
|
|
478
|
+
(config?: Partial<TConfig>): AppAdapter & TExtra;
|
|
479
|
+
scoped(scopeName: string, config?: Partial<TConfig>): AppAdapter & TExtra;
|
|
480
|
+
async(opts: AdapterAsyncOptions<TConfig>): AppAdapter;
|
|
481
|
+
readonly definition: Readonly<DefineAdapterOptions<TConfig, TExtra>>;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Build an {@link AppAdapter} factory from a typed definition. See
|
|
485
|
+
* `architecture.md` §21.3.4 for migration guidance — most first-party
|
|
486
|
+
* adapter packages collapse to a single `defineAdapter()` call after this
|
|
487
|
+
* lands.
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* ```ts
|
|
491
|
+
* const TenantAdapter = defineAdapter<TenantConfig>({
|
|
492
|
+
* name: 'TenantAdapter',
|
|
493
|
+
* defaults: { strategy: 'header', required: true },
|
|
494
|
+
* build: (config) => ({
|
|
495
|
+
* middleware: () => [tenantResolverMiddleware(config)],
|
|
496
|
+
* beforeStart: ({ container }) => registerTenantFactory(container, config),
|
|
497
|
+
* }),
|
|
498
|
+
* })
|
|
499
|
+
*
|
|
500
|
+
* bootstrap({
|
|
501
|
+
* adapters: [
|
|
502
|
+
* TenantAdapter({ strategy: 'subdomain' }),
|
|
503
|
+
* TenantAdapter.scoped('shard-eu', { headerName: 'x-eu-tenant' }),
|
|
504
|
+
* ],
|
|
505
|
+
* })
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
declare function defineAdapter<TConfig = Record<string, unknown>, TExtra = unknown>(options: DefineAdapterOptions<TConfig, TExtra>): AdapterFactory<TConfig, TExtra>;
|
|
509
|
+
//#endregion
|
|
510
|
+
export { CircuitOpenError as A, setClassMeta as B, ContributorCycleError as C, CircuitBreakerOptions as D, CircuitBreaker as E, getMethodMeta as F, setInMetaRecord as H, getMethodMetaOrUndefined as I, hasClassMeta as L, getClassMetaOrUndefined as M, getMetaMap as N, CircuitBreakerState as O, getMetaRecord as P, pushClassMeta as R, buildPipeline as S, MissingContributorError as T, setMethodMeta as U, setInMetaMap as V, runContributors as _, BuildContext as a, ContributorSource as b, PluginFactory as c, MissingMountDepError as d, MountCycleError as f, RunContributorsOptions as g, mountSort as h, defineAdapter as i, getClassMeta as j, CircuitBreakerStats as k, definePlugin as l, MountSortItem as m, AdapterFactory as n, DefinePluginOptions as o, MountKind as p, DefineAdapterOptions as r, PluginAsyncOptions as s, AdapterAsyncOptions as t, DuplicateMountNameError as u, BuildPipelineOptions as v, DuplicateContributorError as w, SourcedRegistration as x, ContributorPipeline as y, pushMethodMeta as z };
|
|
511
|
+
//# sourceMappingURL=index-Yhs9sTMW.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Yhs9sTMW.d.mts","names":[],"sources":["../src/core/metadata.ts","../src/core/circuit-breaker.ts","../src/core/context-errors.ts","../src/core/contributor-pipeline.ts","../src/core/contributor-runner.ts","../src/core/mount-sort.ts","../src/core/define-plugin.ts","../src/core/define-adapter.ts"],"mappings":";;;;;;;;;;;;;;;;;;KAeK,OAAA,qBAA4B,cAAA;;iBAKjB,YAAA,GAAA,CAAgB,GAAA,EAAK,OAAA,EAAS,KAA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,IAAW,UAAA;EAAA,SAClC,UAAA,EAAY,QAAA,CAAS,oBAAA,CAAqB,OAAA,EAAS,MAAA;AAAA;;;;;;;;;;APb9D;;;;;;;;;;;;;;;;iBOgDgB,aAAA,WAAwB,MAAA,oCAAA,CACtC,OAAA,EAAS,oBAAA,CAAqB,OAAA,EAAS,MAAA,IACtC,cAAA,CAAe,OAAA,EAAS,MAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,153 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as METADATA, c as Scope, i as Constructor, l as ServiceOptions, n as BuilderOf, o as MaybePromise, r as ClassKind, s as PostConstructStatus, t as Buildable } from "./interfaces-
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as
|
|
6
|
-
import { n as ExecutionContext, r as MetaValue, t as ContextMeta } from "./execution-context-
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as MiddlewarePhase, i as AppAdapterClass, n as AdapterMiddleware, r as AppAdapter, t as AdapterContext } from "./adapter-
|
|
9
|
-
import { n as AppModuleClass, r as ModuleRoutes, t as AppModule } from "./app-module-
|
|
10
|
-
import { a as Cacheable, c as setCacheProvider, i as CacheProvider, n as CacheEvict, o as MemoryCacheProvider, r as CacheOptions, s as getCacheProvider } from "./cache-
|
|
11
|
-
import { i as getCronJobs, n as Cron, r as CronJobMeta, t as CRON_META } from "./cron-
|
|
12
|
-
import { i as ValidationError, n as HttpStatus, r as HttpStatusCode, t as HttpException } from "./errors-
|
|
13
|
-
import { a as
|
|
14
|
-
import { n as normalizePath, t as joinPaths } from "./path-
|
|
15
|
-
import { t as KickPlugin } from "./plugin-
|
|
16
|
-
import { a as isRef, c as toRefs, i as computed, l as unref, n as Ref, o as reactive, r as WatchOptions, s as ref, t as ComputedRef, u as watch } from "./reactivity-
|
|
17
|
-
import { C as
|
|
18
|
-
import {
|
|
19
|
-
import { bootstrap } from "./
|
|
20
|
-
import { _ as SortItem, a as parseSearchQuery, c as FILTER_OPERATORS, d as FilterOperator, f as PaginatedResponse, g as QueryFieldConfig, h as QueryBuilderAdapter, i as parseQuery, l as FieldsOf, m as ParsedQuery, n as parseFilters, o as parseSort, p as PaginationParams, r as parsePagination, t as buildQueryParams, u as FilterItem, y as TypedParsedQuery } from "./index-
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { validate } from "./
|
|
33
|
-
import {
|
|
34
|
-
import { buildRoutes
|
|
35
|
-
|
|
36
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
37
|
-
|
|
38
|
-
//#region src/http/cluster.d.ts
|
|
39
|
-
interface ClusterOptions {
|
|
40
|
-
/** Number of worker processes (default: os.cpus().length) */
|
|
41
|
-
workers?: number;
|
|
42
|
-
/** Delay before forcefully killing a worker during shutdown (ms), default: 5000 */
|
|
43
|
-
gracefulShutdownTimeout?: number;
|
|
44
|
-
/** Delay between worker restarts (ms), default: 1000 */
|
|
45
|
-
restartDelay?: number;
|
|
46
|
-
/** Max failures in restartWindow before refusing to restart, default: 5 */
|
|
47
|
-
maxFailures?: number;
|
|
48
|
-
/** Time window for counting failures (ms), default: 30000 */
|
|
49
|
-
restartWindow?: number;
|
|
50
|
-
}
|
|
51
|
-
/** Returns true if the current process is the cluster primary */
|
|
52
|
-
declare function isClusterPrimary(): boolean;
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/http/request-store.d.ts
|
|
55
|
-
/** Per-request storage for REQUEST-scoped DI and request context propagation */
|
|
56
|
-
interface RequestStore {
|
|
57
|
-
/** Unique request identifier */
|
|
58
|
-
requestId: string;
|
|
59
|
-
/**
|
|
60
|
-
* Per-request singleton cache for REQUEST-scoped services. Keys are
|
|
61
|
-
* heterogeneous (class constructors, `InjectionToken` objects, raw
|
|
62
|
-
* strings), so the map type stays `Map<any, any>`.
|
|
63
|
-
*/
|
|
64
|
-
instances: Map<any, any>;
|
|
65
|
-
/**
|
|
66
|
-
* Per-request key/value bag. Canonical backing store for
|
|
67
|
-
* `RequestContext.set/get` and the Context Contributor pipeline (#107)
|
|
68
|
-
* since Phase 3. Anything written here is visible to every concrete
|
|
69
|
-
* execution context constructed for the same request, regardless of
|
|
70
|
-
* which middleware/contributor wrote it.
|
|
71
|
-
*
|
|
72
|
-
* Keys are constrained to `string` per the locked decision in
|
|
73
|
-
* `architecture.md` §20.12 (#4); the value type is `unknown` because
|
|
74
|
-
* the concrete shape at each key is determined by the consumer's
|
|
75
|
-
* `ContextMeta` augmentation, not by the store itself.
|
|
76
|
-
*/
|
|
77
|
-
values: Map<string, unknown>;
|
|
78
|
-
}
|
|
79
|
-
/** AsyncLocalStorage instance shared across the framework */
|
|
80
|
-
declare const requestStore: AsyncLocalStorage<RequestStore>;
|
|
81
|
-
/**
|
|
82
|
-
* Get the current request store. Throws if called outside a request context.
|
|
83
|
-
* Used by the Container to resolve REQUEST-scoped dependencies.
|
|
84
|
-
*/
|
|
85
|
-
declare function getRequestStore(): RequestStore;
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/http/middleware/request-scope.d.ts
|
|
88
|
-
/**
|
|
89
|
-
* Wraps each request in an AsyncLocalStorage context.
|
|
90
|
-
* Enables REQUEST-scoped DI and automatic requestId propagation to logs.
|
|
91
|
-
*
|
|
92
|
-
* Should be mounted early in the middleware pipeline (before route handlers).
|
|
93
|
-
* `Application` mounts this automatically unless `contextStore: 'manual'` is set
|
|
94
|
-
* or the user already includes one in their middleware list.
|
|
95
|
-
*/
|
|
96
|
-
declare function requestScopeMiddleware(): (req: Request, _res: Response, next: NextFunction) => void;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/http/middleware/trace-context.d.ts
|
|
99
|
-
/**
|
|
100
|
-
* W3C Trace Context header name.
|
|
101
|
-
* @see https://www.w3.org/TR/trace-context/#traceparent-header
|
|
102
|
-
*/
|
|
103
|
-
declare const TRACEPARENT_HEADER = "traceparent";
|
|
104
|
-
interface TraceContextOptions {
|
|
105
|
-
/**
|
|
106
|
-
* When true, respond with a `traceresponse` header containing the trace ID.
|
|
107
|
-
* Useful for debugging. Default: false.
|
|
108
|
-
*/
|
|
109
|
-
propagateResponse?: boolean;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Parsed W3C trace context fields.
|
|
113
|
-
*/
|
|
114
|
-
interface TraceContext {
|
|
115
|
-
/** W3C traceparent version (usually '00') */
|
|
116
|
-
version: string;
|
|
117
|
-
/** 32-hex-char distributed trace ID */
|
|
118
|
-
traceId: string;
|
|
119
|
-
/** 16-hex-char parent span ID */
|
|
120
|
-
parentSpanId: string;
|
|
121
|
-
/** 2-hex-char trace flags */
|
|
122
|
-
flags: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Parse a W3C traceparent header value.
|
|
126
|
-
* Returns null if the format is invalid.
|
|
127
|
-
*/
|
|
128
|
-
declare function parseTraceparent(header: string): TraceContext | null;
|
|
129
|
-
/**
|
|
130
|
-
* Middleware that extracts W3C `traceparent` header and stores trace context
|
|
131
|
-
* in the request's AsyncLocalStorage store.
|
|
132
|
-
*
|
|
133
|
-
* If no valid `traceparent` header is present, a new traceId is generated
|
|
134
|
-
* so that every request always has a trace ID available for correlation.
|
|
135
|
-
*
|
|
136
|
-
* Must be mounted **after** `requestScopeMiddleware()` (which creates the store).
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* bootstrap({
|
|
141
|
-
* middleware: [
|
|
142
|
-
* requestScopeMiddleware(),
|
|
143
|
-
* traceContext(), // extracts or generates traceId
|
|
144
|
-
* requestLogger(),
|
|
145
|
-
* express.json(),
|
|
146
|
-
* ],
|
|
147
|
-
* })
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
declare function traceContext(options?: TraceContextOptions): (req: Request, res: Response, next: NextFunction) => void;
|
|
151
|
-
//#endregion
|
|
152
|
-
export { AdapterContext, AdapterMiddleware, ApiQueryParams, ApiQueryParamsConfig, ApiQueryParamsConfig as QueryParamsConfig, AppAdapter, AppAdapterClass, AppModule, AppModuleClass, Application, type ApplicationOptions, Autowired, BaseUploadOptions, BuildPipelineOptions, Buildable, Builder, BuilderOf, CRON_META, CacheEvict, CacheOptions, CacheProvider, Cacheable, CircuitBreaker, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStats, CircuitOpenError, ClassKind, type ClusterOptions, ColumnApiQueryParamsConfig, Component, ComputedRef, ConfigService, ConsoleLoggerProvider, Constructor, Container, ContainerChangeEvent, ContainerChangeListener, ContextDecorator, ContextDecoratorSpec, ContextMeta, ContributorCycleError, ContributorPipeline, ContributorRegistration, ContributorSource, Controller, type CorsOptions, Cron, CronJobMeta, type CsrfOptions, type Ctx, Delete, DuplicateContributorError, Env, EnvKey, ExecutionContext, FILTER_OPERATORS, type FieldsOf, FileTypeFilter, FileUpload, FileUploadConfig, type FilterItem, type FilterOperator, Get, type HelmetOptions, HttpException, HttpStatus, HttpStatusCode, INJECTION_TOKEN, Inject, Injectable, InjectionToken, KickJsRegistry, KickPlugin, Logger, LoggerProvider, METADATA, MaybePromise, MemoryCacheProvider, MetaValue, Middleware, type MiddlewareEntry, MiddlewareHandler, MiddlewarePhase, MissingContributorError, ModuleRoutes, type PaginatedResponse, type PaginationParams, type ParsedQuery, Patch, Post, PostConstruct, PostConstructStatus, Put, type QueryBuilderAdapter, type QueryFieldConfig, REQUEST_ID_HEADER, type RateLimitOptions, type RateLimitStore, Ref, Repository, RequestContext, type RequestLoggerOptions, type RequestStore, ResolvedDeps, RouteDefinition, type RouteShape, RunContributorsOptions, Scope, Service, ServiceOptions, type Session, type SessionData, type SessionOptions, type SessionStore, type SortItem, SourcedRegistration, SpaAdapter, type SpaAdapterOptions, TRACEPARENT_HEADER, type TraceContext, type TraceContextOptions, type TypedConfigService, type TypedParsedQuery, type UploadOptions, ValidationError, Value, ViewAdapter, type ViewAdapterOptions, WatchOptions, baseEnvSchema, bootstrap, buildPipeline, buildQueryParams, buildRoutes, buildUploadMiddleware, cleanupFiles, computed, cors, createConfigService, createLogger, createToken, csrf, defineContextDecorator, defineEnv, errorHandler, getCacheProvider, getClassMeta, getClassMetaOrUndefined, getControllerPath, getCronJobs, getEnv, getMetaMap, getMetaRecord, getMethodMeta, getMethodMetaOrUndefined, getRequestStore, hasClassMeta, helmet, isClusterPrimary, isInjectionToken, isRef, joinPaths, loadEnv, logger, normalizeApiQueryParamsConfig, normalizePath, notFoundHandler, parseFilters, parsePagination, parseQuery, parseSearchQuery, parseSort, parseTraceparent, pushClassMeta, pushMethodMeta, rateLimit, reactive, ref, reloadEnv, requestId, requestLogger, requestScopeMiddleware, requestStore, resetEnvCache, resolveMimeTypes, rootLogger, runContributors, session, setCacheProvider, setClassMeta, setInMetaMap, setInMetaRecord, setMethodMeta, toRefs, tokenName, traceContext, unref, upload, validate, watch };
|
|
153
|
-
//# sourceMappingURL=index.d.mts.map
|
|
2
|
+
import { a as METADATA, c as Scope, i as Constructor, l as ServiceOptions, n as BuilderOf, o as MaybePromise, r as ClassKind, s as PostConstructStatus, t as Buildable } from "./interfaces-B50n7dwl.mjs";
|
|
3
|
+
import { a as tokenName, c as createToken, i as KickJsRegistry, l as isInjectionToken, n as ContainerChangeEvent, o as INJECTION_TOKEN, r as ContainerChangeListener, s as InjectionToken, t as Container } from "./container-CnWDsxi-.mjs";
|
|
4
|
+
import { A as normalizeApiQueryParamsConfig, C as Post, D as RouteDefinition, E as Repository, F as assets, I as clearAssetCache, L as resolveAsset, M as ASSET_MANIFEST_VERSION, N as KickAssets, O as Service, P as UnknownAssetError, R as useAssets, S as Patch, T as Put, _ as Get, a as Autowired, b as Middleware, c as ColumnApiQueryParamsConfig, d as Delete, f as Env, g as FileUploadConfig, h as FileUpload, i as AssetKey, j as ASSETS, k as Value, l as Component, m as FileTypeFilter, n as ApiQueryParamsConfig, o as BaseUploadOptions, p as EnvKey, r as Asset, s as Builder, t as ApiQueryParams, u as Controller, v as Inject, w as PostConstruct, x as MiddlewareHandler, y as Injectable } from "./decorators-BMvaLliz.mjs";
|
|
5
|
+
import { a as baseEnvSchema, c as loadEnv, l as reloadEnv, n as TypedConfigService, o as defineEnv, r as createConfigService, s as getEnv, t as ConfigService, u as resetEnvCache } from "./index-D-qhXg9M.mjs";
|
|
6
|
+
import { n as ExecutionContext, r as MetaValue, t as ContextMeta } from "./execution-context-DKnt61pY.mjs";
|
|
7
|
+
import { a as ContributorRegistration, c as ResolvedDeps, i as ContextMetaKey, l as defineContextDecorator, n as ContextDecorator, o as ContributorRegistrations, r as ContextDecoratorSpec, s as DepValue, t as AnyContributorRegistration } from "./context-decorator-DrPvQ9Ag.mjs";
|
|
8
|
+
import { a as MiddlewarePhase, c as KickJsPluginRegistry, i as AppAdapterClass, l as defineAugmentation, n as AdapterMiddleware, o as AugmentationMeta, r as AppAdapter, s as KickJsPluginName, t as AdapterContext } from "./adapter-6Pp4kFdM.mjs";
|
|
9
|
+
import { n as AppModuleClass, r as ModuleRoutes, t as AppModule } from "./app-module-Blgz4Rti.mjs";
|
|
10
|
+
import { a as Cacheable, c as setCacheProvider, i as CacheProvider, n as CacheEvict, o as MemoryCacheProvider, r as CacheOptions, s as getCacheProvider } from "./cache-XrNWj1KQ.mjs";
|
|
11
|
+
import { i as getCronJobs, n as Cron, r as CronJobMeta, t as CRON_META } from "./cron-GNoYydfg.mjs";
|
|
12
|
+
import { i as ValidationError, n as HttpStatus, r as HttpStatusCode, t as HttpException } from "./errors-uaHCeXRz.mjs";
|
|
13
|
+
import { a as rootLogger, i as createLogger, n as Logger, r as LoggerProvider, t as ConsoleLoggerProvider } from "./logger-CLVRZf2N.mjs";
|
|
14
|
+
import { n as normalizePath, t as joinPaths } from "./path-Diviu6hv.mjs";
|
|
15
|
+
import { t as KickPlugin } from "./plugin-DDjoN4XI.mjs";
|
|
16
|
+
import { a as isRef, c as toRefs, i as computed, l as unref, n as Ref, o as reactive, r as WatchOptions, s as ref, t as ComputedRef, u as watch } from "./reactivity-CfJceo4H.mjs";
|
|
17
|
+
import { A as CircuitOpenError, B as setClassMeta, C as ContributorCycleError, D as CircuitBreakerOptions, E as CircuitBreaker, F as getMethodMeta, H as setInMetaRecord, I as getMethodMetaOrUndefined, L as hasClassMeta, M as getClassMetaOrUndefined, N as getMetaMap, O as CircuitBreakerState, P as getMetaRecord, R as pushClassMeta, S as buildPipeline, T as MissingContributorError, U as setMethodMeta, V as setInMetaMap, _ as runContributors, a as BuildContext, b as ContributorSource, c as PluginFactory, d as MissingMountDepError, f as MountCycleError, g as RunContributorsOptions, h as mountSort, i as defineAdapter, j as getClassMeta, k as CircuitBreakerStats, l as definePlugin, m as MountSortItem, n as AdapterFactory, o as DefinePluginOptions, p as MountKind, r as DefineAdapterOptions, s as PluginAsyncOptions, t as AdapterAsyncOptions, u as DuplicateMountNameError, v as BuildPipelineOptions, w as DuplicateContributorError, x as SourcedRegistration, y as ContributorPipeline, z as pushMethodMeta } from "./index-Yhs9sTMW.mjs";
|
|
18
|
+
import { n as ApplicationOptions, r as MiddlewareEntry, t as Application } from "./application-Bepa-pFw.mjs";
|
|
19
|
+
import { t as bootstrap } from "./bootstrap-B4T3X2B6.mjs";
|
|
20
|
+
import { _ as SortItem, a as parseSearchQuery, c as FILTER_OPERATORS, d as FilterOperator, f as PaginatedResponse, g as QueryFieldConfig, h as QueryBuilderAdapter, i as parseQuery, l as FieldsOf, m as ParsedQuery, n as parseFilters, o as parseSort, p as PaginationParams, r as parsePagination, t as buildQueryParams, u as FilterItem, y as TypedParsedQuery } from "./index-B9cyOQAe.mjs";
|
|
21
|
+
import { n as RequestContext, r as RouteShape, t as Ctx } from "./context-Ymvv-85x.mjs";
|
|
22
|
+
import { n as cors, t as CorsOptions } from "./cors-BfgqfLPd.mjs";
|
|
23
|
+
import { n as csrf, t as CsrfOptions } from "./csrf-DiK9zept.mjs";
|
|
24
|
+
import { n as notFoundHandler, t as errorHandler } from "./error-handler-Xud_3Lah.mjs";
|
|
25
|
+
import { n as helmet, t as HelmetOptions } from "./helmet-CaMbjzBG.mjs";
|
|
26
|
+
import { n as RateLimitStore, r as rateLimit, t as RateLimitOptions } from "./rate-limit-DUwoICtI.mjs";
|
|
27
|
+
import { n as requestId, t as REQUEST_ID_HEADER } from "./request-id-BgglvZHN.mjs";
|
|
28
|
+
import { n as requestLogger, t as RequestLoggerOptions } from "./request-logger-CWHbAzTE.mjs";
|
|
29
|
+
import { a as session, i as SessionStore, n as SessionData, r as SessionOptions, t as Session } from "./session-N0hActOO.mjs";
|
|
30
|
+
import { n as SpaAdapterOptions, t as SpaAdapter } from "./spa-CwIbdvPc.mjs";
|
|
31
|
+
import { a as upload, i as resolveMimeTypes, n as buildUploadMiddleware, r as cleanupFiles, t as UploadOptions } from "./upload-BueOnnLw.mjs";
|
|
32
|
+
import { n as validate } from "./validate-HwAyWTwH.mjs";
|
|
33
|
+
import { a as TraceContextOptions, c as requestScopeMiddleware, d as requestStore, f as defineHttpContextDecorator, i as TraceContext, l as RequestStore, m as isClusterPrimary, n as ViewAdapterOptions, o as parseTraceparent, p as ClusterOptions, r as TRACEPARENT_HEADER, s as traceContext, t as ViewAdapter, u as getRequestStore } from "./views-v05_dP1I.mjs";
|
|
34
|
+
import { r as buildRoutes } from "./router-builder-zsX4Oq7c.mjs";
|
|
35
|
+
export { ASSETS, ASSET_MANIFEST_VERSION, AdapterAsyncOptions, AdapterContext, AdapterFactory, AdapterMiddleware, AnyContributorRegistration, ApiQueryParams, ApiQueryParamsConfig, ApiQueryParamsConfig as QueryParamsConfig, AppAdapter, AppAdapterClass, AppModule, AppModuleClass, Application, ApplicationOptions, Asset, AssetKey, AugmentationMeta, Autowired, BaseUploadOptions, BuildContext, BuildPipelineOptions, Buildable, Builder, BuilderOf, CRON_META, CacheEvict, CacheOptions, CacheProvider, Cacheable, CircuitBreaker, CircuitBreakerOptions, CircuitBreakerState, CircuitBreakerStats, CircuitOpenError, ClassKind, ClusterOptions, ColumnApiQueryParamsConfig, Component, ComputedRef, ConfigService, ConsoleLoggerProvider, Constructor, Container, ContainerChangeEvent, ContainerChangeListener, ContextDecorator, ContextDecoratorSpec, ContextMeta, ContextMetaKey, ContributorCycleError, ContributorPipeline, ContributorRegistration, ContributorRegistrations, ContributorSource, Controller, CorsOptions, Cron, CronJobMeta, CsrfOptions, Ctx, DefineAdapterOptions, DefinePluginOptions, Delete, DepValue, DuplicateContributorError, DuplicateMountNameError, Env, EnvKey, ExecutionContext, FILTER_OPERATORS, FieldsOf, FileTypeFilter, FileUpload, FileUploadConfig, FilterItem, FilterOperator, Get, HelmetOptions, HttpException, HttpStatus, HttpStatusCode, INJECTION_TOKEN, Inject, Injectable, InjectionToken, KickAssets, KickJsPluginName, KickJsPluginRegistry, KickJsRegistry, KickPlugin, Logger, LoggerProvider, METADATA, MaybePromise, MemoryCacheProvider, MetaValue, Middleware, MiddlewareEntry, MiddlewareHandler, MiddlewarePhase, MissingContributorError, MissingMountDepError, ModuleRoutes, MountCycleError, MountKind, MountSortItem, PaginatedResponse, PaginationParams, ParsedQuery, Patch, PluginAsyncOptions, PluginFactory, Post, PostConstruct, PostConstructStatus, Put, QueryBuilderAdapter, QueryFieldConfig, REQUEST_ID_HEADER, RateLimitOptions, RateLimitStore, Ref, Repository, RequestContext, RequestLoggerOptions, RequestStore, ResolvedDeps, RouteDefinition, RouteShape, RunContributorsOptions, Scope, Service, ServiceOptions, Session, SessionData, SessionOptions, SessionStore, SortItem, SourcedRegistration, SpaAdapter, SpaAdapterOptions, TRACEPARENT_HEADER, TraceContext, TraceContextOptions, TypedConfigService, TypedParsedQuery, UnknownAssetError, UploadOptions, ValidationError, Value, ViewAdapter, ViewAdapterOptions, WatchOptions, assets, baseEnvSchema, bootstrap, buildPipeline, buildQueryParams, buildRoutes, buildUploadMiddleware, cleanupFiles, clearAssetCache, computed, cors, createConfigService, createLogger, createToken, csrf, defineAdapter, defineAugmentation, defineContextDecorator, defineEnv, defineHttpContextDecorator, definePlugin, errorHandler, getCacheProvider, getClassMeta, getClassMetaOrUndefined, getCronJobs, getEnv, getMetaMap, getMetaRecord, getMethodMeta, getMethodMetaOrUndefined, getRequestStore, hasClassMeta, helmet, isClusterPrimary, isInjectionToken, isRef, joinPaths, loadEnv, mountSort, normalizeApiQueryParamsConfig, normalizePath, notFoundHandler, parseFilters, parsePagination, parseQuery, parseSearchQuery, parseSort, parseTraceparent, pushClassMeta, pushMethodMeta, rateLimit, reactive, ref, reloadEnv, requestId, requestLogger, requestScopeMiddleware, requestStore, resetEnvCache, resolveAsset, resolveMimeTypes, rootLogger, runContributors, session, setCacheProvider, setClassMeta, setInMetaMap, setInMetaRecord, setMethodMeta, toRefs, tokenName, traceContext, unref, upload, useAssets, validate, watch };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs
|
|
2
|
+
* @forinda/kickjs v4.1.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,27 +8,27 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
import { a as UnknownAssetError, c as resolveAsset, d as createToken, f as isInjectionToken, i as ASSET_MANIFEST_VERSION, l as useAssets, n as tokenName, o as assets, r as ASSETS, s as clearAssetCache, t as Container, u as INJECTION_TOKEN } from "./container-BYuMSnqW.mjs";
|
|
11
12
|
import { METADATA, Scope } from "./core/interfaces.mjs";
|
|
12
|
-
import { ConsoleLoggerProvider, Logger, createLogger,
|
|
13
|
-
import { a as getMethodMeta, c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, i as getMetaRecord, l as pushMethodMeta, n as getClassMetaOrUndefined, o as getMethodMetaOrUndefined, p as setMethodMeta, r as getMetaMap, s as hasClassMeta, t as getClassMeta, u as setClassMeta } from "./metadata-
|
|
14
|
-
import {
|
|
15
|
-
import { ApiQueryParams, Autowired, Builder, Component, Controller, Delete, FileUpload, Get, Inject, Injectable, Middleware, Patch, Post, PostConstruct, Put, Repository, Service, Value, normalizeApiQueryParamsConfig } from "./core/decorators.mjs";
|
|
13
|
+
import { ConsoleLoggerProvider, Logger, createLogger, rootLogger } from "./core/logger.mjs";
|
|
14
|
+
import { a as getMethodMeta, c as pushClassMeta, d as setInMetaMap, f as setInMetaRecord, i as getMetaRecord, l as pushMethodMeta, n as getClassMetaOrUndefined, o as getMethodMetaOrUndefined, p as setMethodMeta, r as getMetaMap, s as hasClassMeta, t as getClassMeta, u as setClassMeta } from "./metadata-BF1WDBOh.mjs";
|
|
15
|
+
import { ApiQueryParams, Asset, Autowired, Builder, Component, Controller, Delete, FileUpload, Get, Inject, Injectable, Middleware, Patch, Post, PostConstruct, Put, Repository, Service, Value, normalizeApiQueryParamsConfig } from "./core/decorators.mjs";
|
|
16
16
|
import { CRON_META, Cron, getCronJobs } from "./core/cron.mjs";
|
|
17
17
|
import { CacheEvict, Cacheable, MemoryCacheProvider, getCacheProvider, setCacheProvider } from "./core/cache.mjs";
|
|
18
18
|
import { HttpException, HttpStatus } from "./core/errors.mjs";
|
|
19
19
|
import { joinPaths, normalizePath } from "./core/path.mjs";
|
|
20
|
-
import { a as
|
|
20
|
+
import { a as MissingMountDepError, c as runContributors, d as DuplicateContributorError, f as MissingContributorError, h as CircuitOpenError, i as DuplicateMountNameError, l as buildPipeline, m as CircuitBreaker, n as defineAdapter, o as MountCycleError, p as defineContextDecorator, r as definePlugin, s as mountSort, t as defineAugmentation, u as ContributorCycleError } from "./core-Dj3iVQ3t.mjs";
|
|
21
21
|
import { computed, isRef, reactive, ref, toRefs, unref, watch } from "./core/reactivity.mjs";
|
|
22
22
|
import { REQUEST_ID_HEADER, requestId } from "./http/middleware/request-id.mjs";
|
|
23
23
|
import { errorHandler, notFoundHandler } from "./http/middleware/error-handler.mjs";
|
|
24
|
-
import { n as getRequestStore, r as requestStore, t as RequestContext } from "./context-
|
|
25
|
-
import { n as requestScopeMiddleware, t as Application } from "./application-
|
|
26
|
-
import { a as parseSearchQuery, i as parseQuery, n as parseFilters, o as parseSort, r as parsePagination, s as FILTER_OPERATORS, t as buildQueryParams } from "./query-
|
|
24
|
+
import { n as getRequestStore, r as requestStore, t as RequestContext } from "./context-CyQbqSz-.mjs";
|
|
25
|
+
import { n as requestScopeMiddleware, t as Application } from "./application-DvmPMUgF.mjs";
|
|
26
|
+
import { a as parseSearchQuery, i as parseQuery, n as parseFilters, o as parseSort, r as parsePagination, s as FILTER_OPERATORS, t as buildQueryParams } from "./query-BrYRQMa5.mjs";
|
|
27
27
|
import { validate } from "./http/middleware/validate.mjs";
|
|
28
28
|
import { buildUploadMiddleware, cleanupFiles, resolveMimeTypes, upload } from "./http/middleware/upload.mjs";
|
|
29
|
-
import { buildRoutes
|
|
30
|
-
import { a as reloadEnv, i as loadEnv, n as defineEnv, o as resetEnvCache, r as getEnv, t as baseEnvSchema } from "./env-
|
|
31
|
-
import { n as isClusterPrimary, t as bootstrap } from "./bootstrap-
|
|
29
|
+
import { buildRoutes } from "./http/router-builder.mjs";
|
|
30
|
+
import { a as reloadEnv, i as loadEnv, n as defineEnv, o as resetEnvCache, r as getEnv, t as baseEnvSchema } from "./env-DMqv56Bb.mjs";
|
|
31
|
+
import { n as isClusterPrimary, t as bootstrap } from "./bootstrap-THfr8phJ.mjs";
|
|
32
32
|
import { csrf } from "./http/middleware/csrf.mjs";
|
|
33
33
|
import { requestLogger } from "./http/middleware/request-logger.mjs";
|
|
34
34
|
import { helmet } from "./http/middleware/helmet.mjs";
|
|
@@ -37,8 +37,44 @@ import { rateLimit } from "./http/middleware/rate-limit.mjs";
|
|
|
37
37
|
import { session } from "./http/middleware/session.mjs";
|
|
38
38
|
import { ViewAdapter } from "./http/middleware/views.mjs";
|
|
39
39
|
import { SpaAdapter } from "./http/middleware/spa.mjs";
|
|
40
|
-
import { n as createConfigService, t as ConfigService } from "./config-
|
|
40
|
+
import { n as createConfigService, t as ConfigService } from "./config-BEjgF1fI.mjs";
|
|
41
41
|
import crypto from "node:crypto";
|
|
42
|
+
//#region src/http/define-http-context-decorator.ts
|
|
43
|
+
/**
|
|
44
|
+
* HTTP-flavoured wrapper around {@link defineContextDecorator}.
|
|
45
|
+
*
|
|
46
|
+
* The core factory leaves `Ctx` defaulted to {@link ExecutionContext} so the
|
|
47
|
+
* Context Contributor pipeline stays transport-agnostic — future WebSocket,
|
|
48
|
+
* queue, and cron contexts share the same primitive. The cost is that the
|
|
49
|
+
* vast majority of contributors (which are HTTP) have to spell the third
|
|
50
|
+
* generic by hand to get `ctx.req` / `ctx.headers` typing:
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* defineContextDecorator<'tenant', Record<string, never>, RequestContext>({ ... })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* `defineHttpContextDecorator` removes that ceremony — the spec is typed
|
|
57
|
+
* against `RequestContext` from the start, so resolvers can read `ctx.req`,
|
|
58
|
+
* `ctx.headers`, `ctx.params`, etc. without a cast or generic dance:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { defineHttpContextDecorator } from '@forinda/kickjs'
|
|
62
|
+
*
|
|
63
|
+
* const LoadTenant = defineHttpContextDecorator({
|
|
64
|
+
* key: 'tenant',
|
|
65
|
+
* resolve: (ctx) => ({ id: ctx.req.headers['x-tenant-id'] as string }),
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Use {@link defineContextDecorator} directly when authoring contributors
|
|
70
|
+
* for non-HTTP transports or when you want to share one contributor across
|
|
71
|
+
* HTTP + WS + queue (the resolver then has to stick to the
|
|
72
|
+
* `ExecutionContext` surface — `ctx.get` / `ctx.set` / `ctx.requestId`).
|
|
73
|
+
*/
|
|
74
|
+
function defineHttpContextDecorator(spec) {
|
|
75
|
+
return defineContextDecorator(spec);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
42
78
|
//#region src/http/middleware/trace-context.ts
|
|
43
79
|
/**
|
|
44
80
|
* W3C Trace Context header name.
|
|
@@ -123,6 +159,6 @@ function traceContext(options = {}) {
|
|
|
123
159
|
};
|
|
124
160
|
}
|
|
125
161
|
//#endregion
|
|
126
|
-
export { ApiQueryParams, Application, Autowired, Builder, CRON_META, CacheEvict, Cacheable, CircuitBreaker, CircuitOpenError, Component, ConfigService, ConsoleLoggerProvider, Container, ContributorCycleError, Controller, Cron, Delete, DuplicateContributorError, FILTER_OPERATORS, FileUpload, Get, HttpException, HttpStatus, INJECTION_TOKEN, Inject, Injectable, Logger, METADATA, MemoryCacheProvider, Middleware, MissingContributorError, Patch, Post, PostConstruct, Put, REQUEST_ID_HEADER, Repository, RequestContext, Scope, Service, SpaAdapter, TRACEPARENT_HEADER, Value, ViewAdapter, baseEnvSchema, bootstrap, buildPipeline, buildQueryParams, buildRoutes, buildUploadMiddleware, cleanupFiles, computed, cors, createConfigService, createLogger, createToken, csrf, defineContextDecorator, defineEnv, errorHandler, getCacheProvider, getClassMeta, getClassMetaOrUndefined,
|
|
162
|
+
export { ASSETS, ASSET_MANIFEST_VERSION, ApiQueryParams, Application, Asset, Autowired, Builder, CRON_META, CacheEvict, Cacheable, CircuitBreaker, CircuitOpenError, Component, ConfigService, ConsoleLoggerProvider, Container, ContributorCycleError, Controller, Cron, Delete, DuplicateContributorError, DuplicateMountNameError, FILTER_OPERATORS, FileUpload, Get, HttpException, HttpStatus, INJECTION_TOKEN, Inject, Injectable, Logger, METADATA, MemoryCacheProvider, Middleware, MissingContributorError, MissingMountDepError, MountCycleError, Patch, Post, PostConstruct, Put, REQUEST_ID_HEADER, Repository, RequestContext, Scope, Service, SpaAdapter, TRACEPARENT_HEADER, UnknownAssetError, Value, ViewAdapter, assets, baseEnvSchema, bootstrap, buildPipeline, buildQueryParams, buildRoutes, buildUploadMiddleware, cleanupFiles, clearAssetCache, computed, cors, createConfigService, createLogger, createToken, csrf, defineAdapter, defineAugmentation, defineContextDecorator, defineEnv, defineHttpContextDecorator, definePlugin, errorHandler, getCacheProvider, getClassMeta, getClassMetaOrUndefined, getCronJobs, getEnv, getMetaMap, getMetaRecord, getMethodMeta, getMethodMetaOrUndefined, getRequestStore, hasClassMeta, helmet, isClusterPrimary, isInjectionToken, isRef, joinPaths, loadEnv, mountSort, normalizeApiQueryParamsConfig, normalizePath, notFoundHandler, parseFilters, parsePagination, parseQuery, parseSearchQuery, parseSort, parseTraceparent, pushClassMeta, pushMethodMeta, rateLimit, reactive, ref, reloadEnv, requestId, requestLogger, requestScopeMiddleware, requestStore, resetEnvCache, resolveAsset, resolveMimeTypes, rootLogger, runContributors, session, setCacheProvider, setClassMeta, setInMetaMap, setInMetaRecord, setMethodMeta, toRefs, tokenName, traceContext, unref, upload, useAssets, validate, watch };
|
|
127
163
|
|
|
128
164
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/http/middleware/trace-context.ts"],"sourcesContent":["import crypto from 'node:crypto'\nimport type { Request, Response, NextFunction } from 'express'\nimport { requestStore } from '../request-store'\n\n/**\n * W3C Trace Context header name.\n * @see https://www.w3.org/TR/trace-context/#traceparent-header\n */\nexport const TRACEPARENT_HEADER = 'traceparent'\n\n/** Regex for a valid W3C traceparent: {version}-{trace-id}-{parent-id}-{flags} */\nconst TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/\n\nexport interface TraceContextOptions {\n /**\n * When true, respond with a `traceresponse` header containing the trace ID.\n * Useful for debugging. Default: false.\n */\n propagateResponse?: boolean\n}\n\n/**\n * Parsed W3C trace context fields.\n */\nexport interface TraceContext {\n /** W3C traceparent version (usually '00') */\n version: string\n /** 32-hex-char distributed trace ID */\n traceId: string\n /** 16-hex-char parent span ID */\n parentSpanId: string\n /** 2-hex-char trace flags */\n flags: string\n}\n\n/**\n * Generate a random 32-hex-character trace ID.\n */\nfunction generateTraceId(): string {\n return crypto.randomBytes(16).toString('hex')\n}\n\n/**\n * Generate a random 16-hex-character span ID.\n */\nfunction generateSpanId(): string {\n return crypto.randomBytes(8).toString('hex')\n}\n\n/**\n * Parse a W3C traceparent header value.\n * Returns null if the format is invalid.\n */\nexport function parseTraceparent(header: string): TraceContext | null {\n const match = TRACEPARENT_RE.exec(header.trim().toLowerCase())\n if (!match) return null\n\n const version = match[1]\n const traceId = match[2]\n const parentSpanId = match[3]\n const flags = match[4]\n\n // W3C spec: version ff is invalid, all-zero trace-id and parent-id are invalid\n if (\n version === 'ff' ||\n traceId === '00000000000000000000000000000000' ||\n parentSpanId === '0000000000000000'\n ) {\n return null\n }\n\n return { version, traceId, parentSpanId, flags }\n}\n\n/**\n * Middleware that extracts W3C `traceparent` header and stores trace context\n * in the request's AsyncLocalStorage store.\n *\n * If no valid `traceparent` header is present, a new traceId is generated\n * so that every request always has a trace ID available for correlation.\n *\n * Must be mounted **after** `requestScopeMiddleware()` (which creates the store).\n *\n * @example\n * ```ts\n * bootstrap({\n * middleware: [\n * requestScopeMiddleware(),\n * traceContext(), // extracts or generates traceId\n * requestLogger(),\n * express.json(),\n * ],\n * })\n * ```\n */\nexport function traceContext(options: TraceContextOptions = {}) {\n return (req: Request, res: Response, next: NextFunction) => {\n const store = requestStore.getStore()\n\n const traceparentHeader = req.headers[TRACEPARENT_HEADER]\n const raw = Array.isArray(traceparentHeader) ? traceparentHeader[0] : traceparentHeader\n const parsed = raw ? parseTraceparent(raw) : null\n\n const traceId = parsed?.traceId ?? generateTraceId()\n const spanId = generateSpanId()\n\n // Attach to the request store so logger + downstream code can access it\n if (store) {\n store.values.set('traceId', traceId)\n store.values.set('spanId', spanId)\n if (parsed) {\n store.values.set('parentSpanId', parsed.parentSpanId)\n store.values.set('traceFlags', parsed.flags)\n store.values.set('traceVersion', parsed.version)\n }\n }\n\n // Also expose on req for convenience\n ;(req as any).traceId = traceId\n ;(req as any).spanId = spanId\n\n if (options.propagateResponse) {\n res.setHeader('traceresponse', traceId)\n }\n\n next()\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/http/define-http-context-decorator.ts","../src/http/middleware/trace-context.ts"],"sourcesContent":["/**\n * HTTP-flavoured wrapper around {@link defineContextDecorator}.\n *\n * The core factory leaves `Ctx` defaulted to {@link ExecutionContext} so the\n * Context Contributor pipeline stays transport-agnostic — future WebSocket,\n * queue, and cron contexts share the same primitive. The cost is that the\n * vast majority of contributors (which are HTTP) have to spell the third\n * generic by hand to get `ctx.req` / `ctx.headers` typing:\n *\n * ```ts\n * defineContextDecorator<'tenant', Record<string, never>, RequestContext>({ ... })\n * ```\n *\n * `defineHttpContextDecorator` removes that ceremony — the spec is typed\n * against `RequestContext` from the start, so resolvers can read `ctx.req`,\n * `ctx.headers`, `ctx.params`, etc. without a cast or generic dance:\n *\n * ```ts\n * import { defineHttpContextDecorator } from '@forinda/kickjs'\n *\n * const LoadTenant = defineHttpContextDecorator({\n * key: 'tenant',\n * resolve: (ctx) => ({ id: ctx.req.headers['x-tenant-id'] as string }),\n * })\n * ```\n *\n * Use {@link defineContextDecorator} directly when authoring contributors\n * for non-HTTP transports or when you want to share one contributor across\n * HTTP + WS + queue (the resolver then has to stick to the\n * `ExecutionContext` surface — `ctx.get` / `ctx.set` / `ctx.requestId`).\n */\n\nimport {\n defineContextDecorator,\n type ContextDecorator,\n type ContextDecoratorSpec,\n type DepValue,\n} from '../core/context-decorator'\nimport type { RequestContext } from './context'\n\nexport function defineHttpContextDecorator<\n K extends string,\n D extends Record<string, DepValue> = Record<string, never>,\n>(spec: ContextDecoratorSpec<K, D, RequestContext>): ContextDecorator<K, D, RequestContext> {\n return defineContextDecorator<K, D, RequestContext>(spec)\n}\n","import crypto from 'node:crypto'\nimport type { Request, Response, NextFunction } from 'express'\nimport { requestStore } from '../request-store'\n\n/**\n * W3C Trace Context header name.\n * @see https://www.w3.org/TR/trace-context/#traceparent-header\n */\nexport const TRACEPARENT_HEADER = 'traceparent'\n\n/** Regex for a valid W3C traceparent: {version}-{trace-id}-{parent-id}-{flags} */\nconst TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/\n\nexport interface TraceContextOptions {\n /**\n * When true, respond with a `traceresponse` header containing the trace ID.\n * Useful for debugging. Default: false.\n */\n propagateResponse?: boolean\n}\n\n/**\n * Parsed W3C trace context fields.\n */\nexport interface TraceContext {\n /** W3C traceparent version (usually '00') */\n version: string\n /** 32-hex-char distributed trace ID */\n traceId: string\n /** 16-hex-char parent span ID */\n parentSpanId: string\n /** 2-hex-char trace flags */\n flags: string\n}\n\n/**\n * Generate a random 32-hex-character trace ID.\n */\nfunction generateTraceId(): string {\n return crypto.randomBytes(16).toString('hex')\n}\n\n/**\n * Generate a random 16-hex-character span ID.\n */\nfunction generateSpanId(): string {\n return crypto.randomBytes(8).toString('hex')\n}\n\n/**\n * Parse a W3C traceparent header value.\n * Returns null if the format is invalid.\n */\nexport function parseTraceparent(header: string): TraceContext | null {\n const match = TRACEPARENT_RE.exec(header.trim().toLowerCase())\n if (!match) return null\n\n const version = match[1]\n const traceId = match[2]\n const parentSpanId = match[3]\n const flags = match[4]\n\n // W3C spec: version ff is invalid, all-zero trace-id and parent-id are invalid\n if (\n version === 'ff' ||\n traceId === '00000000000000000000000000000000' ||\n parentSpanId === '0000000000000000'\n ) {\n return null\n }\n\n return { version, traceId, parentSpanId, flags }\n}\n\n/**\n * Middleware that extracts W3C `traceparent` header and stores trace context\n * in the request's AsyncLocalStorage store.\n *\n * If no valid `traceparent` header is present, a new traceId is generated\n * so that every request always has a trace ID available for correlation.\n *\n * Must be mounted **after** `requestScopeMiddleware()` (which creates the store).\n *\n * @example\n * ```ts\n * bootstrap({\n * middleware: [\n * requestScopeMiddleware(),\n * traceContext(), // extracts or generates traceId\n * requestLogger(),\n * express.json(),\n * ],\n * })\n * ```\n */\nexport function traceContext(options: TraceContextOptions = {}) {\n return (req: Request, res: Response, next: NextFunction) => {\n const store = requestStore.getStore()\n\n const traceparentHeader = req.headers[TRACEPARENT_HEADER]\n const raw = Array.isArray(traceparentHeader) ? traceparentHeader[0] : traceparentHeader\n const parsed = raw ? parseTraceparent(raw) : null\n\n const traceId = parsed?.traceId ?? generateTraceId()\n const spanId = generateSpanId()\n\n // Attach to the request store so logger + downstream code can access it\n if (store) {\n store.values.set('traceId', traceId)\n store.values.set('spanId', spanId)\n if (parsed) {\n store.values.set('parentSpanId', parsed.parentSpanId)\n store.values.set('traceFlags', parsed.flags)\n store.values.set('traceVersion', parsed.version)\n }\n }\n\n // Also expose on req for convenience\n ;(req as any).traceId = traceId\n ;(req as any).spanId = spanId\n\n if (options.propagateResponse) {\n res.setHeader('traceresponse', traceId)\n }\n\n next()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,2BAGd,MAA0F;AAC1F,QAAO,uBAA6C,KAAK;;;;;;;;ACpC3D,MAAa,qBAAqB;;AAGlC,MAAM,iBAAiB;;;;AA2BvB,SAAS,kBAA0B;AACjC,QAAO,OAAO,YAAY,GAAG,CAAC,SAAS,MAAM;;;;;AAM/C,SAAS,iBAAyB;AAChC,QAAO,OAAO,YAAY,EAAE,CAAC,SAAS,MAAM;;;;;;AAO9C,SAAgB,iBAAiB,QAAqC;CACpE,MAAM,QAAQ,eAAe,KAAK,OAAO,MAAM,CAAC,aAAa,CAAC;AAC9D,KAAI,CAAC,MAAO,QAAO;CAEnB,MAAM,UAAU,MAAM;CACtB,MAAM,UAAU,MAAM;CACtB,MAAM,eAAe,MAAM;CAC3B,MAAM,QAAQ,MAAM;AAGpB,KACE,YAAY,QACZ,YAAY,sCACZ,iBAAiB,mBAEjB,QAAO;AAGT,QAAO;EAAE;EAAS;EAAS;EAAc;EAAO;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