@forinda/kickjs 5.17.0 → 5.18.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-D_uzU-QA.d.mts +2121 -0
- package/dist/adapter-D_uzU-QA.d.mts.map +1 -0
- package/dist/{context-decorator-DDZ30BIW.d.mts → app-module-CuAS6hJC.d.mts} +184 -4
- package/dist/app-module-CuAS6hJC.d.mts.map +1 -0
- package/dist/application-DwTrT9cq.mjs +12 -0
- package/dist/application-DwTrT9cq.mjs.map +1 -0
- package/dist/{application-CAnpDQ8d.d.mts → application-pbx53JnX.d.mts} +31 -5
- package/dist/application-pbx53JnX.d.mts.map +1 -0
- package/dist/{bootstrap-CHmCh_cE.mjs → bootstrap-BaqYQe4i.mjs} +3 -3
- package/dist/{bootstrap-CHmCh_cE.mjs.map → bootstrap-BaqYQe4i.mjs.map} +1 -1
- package/dist/{bootstrap-8DDzBjhx.d.mts → bootstrap-DzfBj6Ja.d.mts} +2 -2
- package/dist/{bootstrap-8DDzBjhx.d.mts.map → bootstrap-DzfBj6Ja.d.mts.map} +1 -1
- package/dist/config/index.mjs +2 -2
- package/dist/{config-BvyPboRZ.mjs → config-okfM1SlN.mjs} +3 -3
- package/dist/{config-BvyPboRZ.mjs.map → config-okfM1SlN.mjs.map} +1 -1
- package/dist/{container-CPz0l8-b.mjs → container-B0BU5TY4.mjs} +3 -3
- package/dist/{container-CPz0l8-b.mjs.map → container-B0BU5TY4.mjs.map} +1 -1
- package/dist/context-DGsCYQRP.mjs +12 -0
- package/dist/context-DGsCYQRP.mjs.map +1 -0
- package/dist/core/adapter.d.mts +1 -1
- package/dist/core/adapter.mjs +1 -1
- package/dist/core/app-module.d.mts +1 -1
- package/dist/core/app-module.mjs +1 -1
- package/dist/core/cache.mjs +1 -1
- package/dist/core/container.mjs +2 -2
- package/dist/core/cron.mjs +2 -2
- package/dist/core/decorators.mjs +2 -2
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +2 -2
- package/dist/core/errors.mjs.map +1 -1
- package/dist/core/interfaces.mjs +1 -1
- package/dist/core/logger.mjs +1 -1
- package/dist/core/path.mjs +1 -1
- package/dist/core/plugin.d.mts +1 -1
- package/dist/core/plugin.mjs +1 -1
- package/dist/core/reactivity.mjs +1 -1
- package/dist/{core-C_gfh7JQ.mjs → core-BV0AxVuK.mjs} +3 -3
- package/dist/{core-C_gfh7JQ.mjs.map → core-BV0AxVuK.mjs.map} +1 -1
- package/dist/{env-LIrKUSAJ.mjs → env-wT1GSzGW.mjs} +3 -3
- package/dist/{env-LIrKUSAJ.mjs.map → env-wT1GSzGW.mjs.map} +1 -1
- package/dist/{errors-CRCTjEUK.d.mts → errors-n0H96eEz.d.mts} +3 -1
- package/dist/errors-n0H96eEz.d.mts.map +1 -0
- package/dist/http/application.d.mts +1 -1
- package/dist/http/application.mjs +2 -2
- package/dist/http/bootstrap.d.mts +1 -1
- package/dist/http/bootstrap.mjs +2 -2
- package/dist/http/context.d.mts +2 -2
- package/dist/http/context.mjs +2 -2
- package/dist/http/middleware/cors.mjs +1 -1
- package/dist/http/middleware/csrf.mjs +1 -1
- package/dist/http/middleware/error-handler.mjs +2 -2
- package/dist/http/middleware/helmet.mjs +1 -1
- package/dist/http/middleware/rate-limit.mjs +1 -1
- package/dist/http/middleware/request-id.mjs +1 -1
- package/dist/http/middleware/request-logger.mjs +2 -2
- package/dist/http/middleware/session.mjs +1 -1
- package/dist/http/middleware/spa.d.mts +1 -1
- package/dist/http/middleware/spa.mjs +2 -2
- package/dist/http/middleware/upload.d.mts +2 -2
- package/dist/http/middleware/upload.mjs +3 -3
- package/dist/http/middleware/upload.mjs.map +1 -1
- package/dist/http/middleware/validate.mjs +2 -2
- package/dist/http/middleware/views.d.mts +1 -1
- package/dist/http/middleware/views.mjs +2 -2
- package/dist/http/query/index.mjs +2 -2
- package/dist/http/router-builder.d.mts +2 -2
- package/dist/http/router-builder.mjs +2 -2
- package/dist/http/router-builder.mjs.map +1 -1
- package/dist/http/runtimes/fastify.d.mts +66 -0
- package/dist/http/runtimes/fastify.d.mts.map +1 -0
- package/dist/http/runtimes/fastify.mjs +13 -0
- package/dist/http/runtimes/fastify.mjs.map +1 -0
- package/dist/http/runtimes/h3.d.mts +29 -0
- package/dist/http/runtimes/h3.d.mts.map +1 -0
- package/dist/http/runtimes/h3.mjs +12 -0
- package/dist/http/runtimes/h3.mjs.map +1 -0
- package/dist/index.d.mts +11 -16
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{metadata-D8hSFaux.mjs → metadata-B069pGq2.mjs} +2 -2
- package/dist/{metadata-D8hSFaux.mjs.map → metadata-B069pGq2.mjs.map} +1 -1
- package/dist/{query-NhwucLHS.mjs → query-CimrAth7.mjs} +2 -2
- package/dist/{query-NhwucLHS.mjs.map → query-CimrAth7.mjs.map} +1 -1
- package/dist/request-scope-DiBal5Ln.mjs +12 -0
- package/dist/request-scope-DiBal5Ln.mjs.map +1 -0
- package/dist/router-builder-Bh3qSiDz.d.mts +39 -0
- package/dist/router-builder-Bh3qSiDz.d.mts.map +1 -0
- package/dist/{spa-IRFC2eMN.d.mts → spa-BdvZFXJz.d.mts} +3 -2
- package/dist/spa-BdvZFXJz.d.mts.map +1 -0
- package/dist/{upload-D6edAELH.d.mts → upload-Bc_rBRtE.d.mts} +37 -2
- package/dist/upload-Bc_rBRtE.d.mts.map +1 -0
- package/dist/{views-DkllbVB3.d.mts → views-DcTVDiOh.d.mts} +31 -7
- package/dist/views-DcTVDiOh.d.mts.map +1 -0
- package/package.json +35 -1
- package/dist/adapter-CkpcZwzZ.d.mts +0 -407
- package/dist/adapter-CkpcZwzZ.d.mts.map +0 -1
- package/dist/app-module-BTzb-Vd6.d.mts +0 -92
- package/dist/app-module-BTzb-Vd6.d.mts.map +0 -1
- package/dist/application-CAnpDQ8d.d.mts.map +0 -1
- package/dist/application-CRmMytW1.mjs +0 -12
- package/dist/application-CRmMytW1.mjs.map +0 -1
- package/dist/context-C6e-S0uc.mjs +0 -12
- package/dist/context-C6e-S0uc.mjs.map +0 -1
- package/dist/context-DV7RjM9F.d.mts +0 -445
- package/dist/context-DV7RjM9F.d.mts.map +0 -1
- package/dist/context-decorator-DDZ30BIW.d.mts.map +0 -1
- package/dist/errors-CRCTjEUK.d.mts.map +0 -1
- package/dist/execution-context-B4cfhivz.d.mts +0 -98
- package/dist/execution-context-B4cfhivz.d.mts.map +0 -1
- package/dist/index-frSEHiL_.d.mts +0 -796
- package/dist/index-frSEHiL_.d.mts.map +0 -1
- package/dist/plugin-BQCn6zyj.d.mts +0 -260
- package/dist/plugin-BQCn6zyj.d.mts.map +0 -1
- package/dist/router-builder-oQpcQMWl.d.mts +0 -31
- package/dist/router-builder-oQpcQMWl.d.mts.map +0 -1
- package/dist/spa-IRFC2eMN.d.mts.map +0 -1
- package/dist/upload-D6edAELH.d.mts.map +0 -1
- package/dist/views-DkllbVB3.d.mts.map +0 -1
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { i as MetaValue, r as ExecutionContext } from "./execution-context-B4cfhivz.mjs";
|
|
3
|
-
import { i as ProblemDetails } from "./errors-CRCTjEUK.mjs";
|
|
4
|
-
import { S as QueryFieldConfig, T as TypedParsedQuery, t as ParseQueryOptions } from "./index-BtWJ9SLP.mjs";
|
|
5
|
-
import { NextFunction, Request, Response } from "express";
|
|
6
|
-
|
|
7
|
-
//#region src/http/context.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Input shape for the typed problem-detail convenience methods on
|
|
10
|
-
* {@link ProblemSender} (`ctx.problem.notFound`, `.badRequest`, etc.) —
|
|
11
|
-
* RFC 9457 details minus the `status`, which each method pre-fills.
|
|
12
|
-
*/
|
|
13
|
-
type ProblemInput = Omit<ProblemDetails, 'status'>;
|
|
14
|
-
/**
|
|
15
|
-
* Callable response helper for RFC 9457 — Problem Details responses.
|
|
16
|
-
* Returned by `ctx.problem`. Invoke directly for a fully-specified
|
|
17
|
-
* payload, or use the named convenience methods to pre-fill `status` +
|
|
18
|
-
* `title` for the common codes.
|
|
19
|
-
*
|
|
20
|
-
* Each call sets `Content-Type: application/problem+json` and serializes
|
|
21
|
-
* the canonical shape (defaulting `type` to `about:blank` and `title` to
|
|
22
|
-
* the IANA reason phrase per RFC 9457 §3.1.1 / §3.1.4).
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* ctx.problem({
|
|
27
|
-
* type: 'https://api.example.com/problems/out-of-credit',
|
|
28
|
-
* status: 403,
|
|
29
|
-
* detail: 'Your balance is 30, but that costs 50.',
|
|
30
|
-
* balance: 30, // extension per §3.2
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* ctx.problem.notFound({ detail: 'User abc not found' })
|
|
34
|
-
* ctx.problem.validation(zodResult.error.issues)
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
interface ProblemSender {
|
|
38
|
-
(input: ProblemDetails): Response;
|
|
39
|
-
/** 400 Bad Request — RFC 9457. */
|
|
40
|
-
badRequest(input?: ProblemInput): Response;
|
|
41
|
-
/** 401 Unauthorized — RFC 9457. */
|
|
42
|
-
unauthorized(input?: ProblemInput): Response;
|
|
43
|
-
/** 403 Forbidden — RFC 9457. */
|
|
44
|
-
forbidden(input?: ProblemInput): Response;
|
|
45
|
-
/** 404 Not Found — RFC 9457. */
|
|
46
|
-
notFound(input?: ProblemInput): Response;
|
|
47
|
-
/** 409 Conflict — RFC 9457. */
|
|
48
|
-
conflict(input?: ProblemInput): Response;
|
|
49
|
-
/** 422 Unprocessable Entity — RFC 9457. */
|
|
50
|
-
unprocessable(input?: ProblemInput): Response;
|
|
51
|
-
/** 429 Too Many Requests — RFC 9457. */
|
|
52
|
-
tooManyRequests(input?: ProblemInput): Response;
|
|
53
|
-
/** 500 Internal Server Error — RFC 9457. */
|
|
54
|
-
internal(input?: ProblemInput): Response;
|
|
55
|
-
/**
|
|
56
|
-
* 422 with Zod issues serialized into the `errors` extension per
|
|
57
|
-
* RFC 9457 §3.2's array convention. Pass `error.issues` from a Zod
|
|
58
|
-
* `safeParse` failure or `error.issues` from a thrown ZodError.
|
|
59
|
-
*/
|
|
60
|
-
validation(issues: any[], input?: ProblemInput): Response;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Recursively marks every property of `T` as `readonly`. Preserves
|
|
64
|
-
* `Function`, `Date`, and `RegExp` unchanged, and converts `Map` / `Set`
|
|
65
|
-
* to `ReadonlyMap` / `ReadonlySet` so their mutating methods (`set`,
|
|
66
|
-
* `delete`, `add`, `clear`) are removed from the public surface.
|
|
67
|
-
* Tuples keep their positional element types — only their per-element
|
|
68
|
-
* mutability is locked.
|
|
69
|
-
*
|
|
70
|
-
* Exposed as a utility for adopters who want to opt into compile-time
|
|
71
|
-
* sealing of their own shapes. **No longer applied to
|
|
72
|
-
* `RequestContext.{body,params,query,headers,file,files}`** — that
|
|
73
|
-
* broke TS narrowing / discriminated-union drilldowns on typed request
|
|
74
|
-
* payloads. Runtime read-only enforcement now lives in
|
|
75
|
-
* {@link makeReadOnlyProxy} (dev-only Proxy that warns on writes,
|
|
76
|
-
* no-op in production).
|
|
77
|
-
*
|
|
78
|
-
* Type-only. No runtime cost. `DeepReadonly<any>` is `any` (TS
|
|
79
|
-
* distributes conditional types over `any`).
|
|
80
|
-
*/
|
|
81
|
-
type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends Date | RegExp ? T : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer V> ? ReadonlySet<DeepReadonly<V>> : T extends readonly (infer U)[] ? number extends T['length'] ? ReadonlyArray<DeepReadonly<U>> : { readonly [K in keyof T]: DeepReadonly<T[K]> } : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> } : T;
|
|
82
|
-
/**
|
|
83
|
-
* The shape of a single route entry in `KickRoutes`. Generated by
|
|
84
|
-
* `kick typegen` and consumed via the `Ctx<T>` helper. Each field is
|
|
85
|
-
* `unknown` by default and is filled in as the typegen learns more
|
|
86
|
-
* about the route (URL params from the path, body/query from validation
|
|
87
|
-
* schemas, etc.).
|
|
88
|
-
*/
|
|
89
|
-
interface RouteShape {
|
|
90
|
-
params?: unknown;
|
|
91
|
-
body?: unknown;
|
|
92
|
-
query?: unknown;
|
|
93
|
-
response?: unknown;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Unified request/response abstraction passed to every controller method.
|
|
97
|
-
* Shields handlers from raw Express objects and provides convenience methods.
|
|
98
|
-
*
|
|
99
|
-
* Implements {@link ExecutionContext} so the transport-agnostic Context
|
|
100
|
-
* Contributor pipeline (#107) can run against this concrete HTTP context
|
|
101
|
-
* the same way it will run against future WS / queue / cron contexts.
|
|
102
|
-
*/
|
|
103
|
-
declare class RequestContext<TBody = any, TParams = any, TQuery = any> implements ExecutionContext {
|
|
104
|
-
readonly req: Request;
|
|
105
|
-
readonly res: Response;
|
|
106
|
-
readonly next: NextFunction;
|
|
107
|
-
constructor(req: Request, res: Response, next: NextFunction);
|
|
108
|
-
/**
|
|
109
|
-
* Memo of the most recent {@link qs} call this request. The query
|
|
110
|
-
* object is immutable for a request's lifetime, so a repeat call with
|
|
111
|
-
* the same `(fieldConfig, options)` references returns the cached
|
|
112
|
-
* parse instead of re-walking the filter/sort strings.
|
|
113
|
-
*/
|
|
114
|
-
private _qsMemo?;
|
|
115
|
-
/**
|
|
116
|
-
* Read-side accessor for the per-request metadata map.
|
|
117
|
-
*
|
|
118
|
-
* Returns the AsyncLocalStorage map (`requestStore.getStore().values`)
|
|
119
|
-
* shared with the Context Contributor pipeline when an ALS frame is
|
|
120
|
-
* active. Returns `null` outside any frame — read-side callers
|
|
121
|
-
* (`ctx.get`, `ctx.user`, `ctx.tenantId`, `ctx.roles`) treat that as
|
|
122
|
-
* "no metadata" and fall through to their `req.*` defaults. Reads
|
|
123
|
-
* never throw because outside an ALS frame nobody could have written
|
|
124
|
-
* via `ctx.set` anyway, so an empty answer is the truthful one.
|
|
125
|
-
*/
|
|
126
|
-
private metadataReadOnly;
|
|
127
|
-
/**
|
|
128
|
-
* Write-side accessor for the per-request metadata map.
|
|
129
|
-
*
|
|
130
|
-
* Returns the same map as {@link metadataReadOnly} when an ALS frame
|
|
131
|
-
* is active. Throws otherwise — writing to a fallback map outside
|
|
132
|
-
* the ALS frame would silently lose data because other call sites
|
|
133
|
-
* (downstream contributors, request-logger, etc.) read from the
|
|
134
|
-
* canonical store and would never see it. Mount
|
|
135
|
-
* `requestScopeMiddleware()` (Application does this for you in
|
|
136
|
-
* `'auto'` mode) or wrap your test setup in
|
|
137
|
-
* `requestStore.run({...}, () => …)` to fix.
|
|
138
|
-
*/
|
|
139
|
-
private metadataForWrite;
|
|
140
|
-
/**
|
|
141
|
-
* Parsed request body. Wrapped in a dev-only Proxy that warns when
|
|
142
|
-
* adopters try to mutate Zod-validated payloads in place — compute
|
|
143
|
-
* new values and stash them via `ctx.set('key', value)` or a Context
|
|
144
|
-
* Contributor instead. Reach for `ctx.req.body` if you genuinely
|
|
145
|
-
* need the raw, mutable Express handle (rare).
|
|
146
|
-
*
|
|
147
|
-
* In production the Proxy is bypassed and `this.req.body` is
|
|
148
|
-
* returned as-is — no runtime cost on the hot path.
|
|
149
|
-
*/
|
|
150
|
-
get body(): TBody;
|
|
151
|
-
/** Path parameters parsed from the route — read-only, see {@link body}. */
|
|
152
|
-
get params(): TParams;
|
|
153
|
-
/** Parsed query string — read-only, see {@link body}. */
|
|
154
|
-
get query(): TQuery;
|
|
155
|
-
/** Inbound HTTP headers — read-only, see {@link body}. */
|
|
156
|
-
get headers(): Request['headers'];
|
|
157
|
-
get requestId(): string | undefined;
|
|
158
|
-
/**
|
|
159
|
-
* `AbortSignal` that fires when the underlying HTTP request is
|
|
160
|
-
* closed — either because the client disconnected before the
|
|
161
|
-
* response was sent, or because Node's socket-close event ran
|
|
162
|
-
* after a normal response. Multiple `RequestContext` wrappers for
|
|
163
|
-
* the same request (router-builder constructs one per
|
|
164
|
-
* middleware/contributor pipeline / main handler) share a single
|
|
165
|
-
* `AbortController` cached on the underlying `req` object, so the
|
|
166
|
-
* signal is stable across the request lifecycle.
|
|
167
|
-
*
|
|
168
|
-
* Thread it through anything that takes an `AbortSignal` so the
|
|
169
|
-
* work cancels as soon as the client gives up — e.g. a kickjs-db
|
|
170
|
-
* relational query:
|
|
171
|
-
*
|
|
172
|
-
* ```ts
|
|
173
|
-
* @Get('/:id/full')
|
|
174
|
-
* async show(ctx: RequestContext) {
|
|
175
|
-
* const row = await this.repo.findFullById(ctx.params.id, ctx.signal)
|
|
176
|
-
* if (!row) return ctx.notFound()
|
|
177
|
-
* ctx.json(row)
|
|
178
|
-
* }
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
* The repo passes `signal` to `db.query.<table>.findUnique({ signal })`;
|
|
182
|
-
* if the client disconnects mid-flight, the in-flight query rejects
|
|
183
|
-
* with `RelationalQueryCancelledError` instead of consuming the
|
|
184
|
-
* connection until completion.
|
|
185
|
-
*
|
|
186
|
-
* Implementation note — both `req.on('close')` and `res.on('close')`
|
|
187
|
-
* are wired so the signal aborts regardless of whether the close
|
|
188
|
-
* event lands on the request stream or the response stream first.
|
|
189
|
-
* Subsequent fires are no-ops (`AbortController.abort()` is
|
|
190
|
-
* idempotent).
|
|
191
|
-
*/
|
|
192
|
-
get signal(): AbortSignal;
|
|
193
|
-
/** Session data (requires session middleware) */
|
|
194
|
-
get session(): any;
|
|
195
|
-
/**
|
|
196
|
-
* The authenticated user set by AuthAdapter.
|
|
197
|
-
* Reads from the per-request metadata store first (`ctx.set('user', ...)`),
|
|
198
|
-
* then falls back to `req.user` (set directly by AuthAdapter middleware).
|
|
199
|
-
*
|
|
200
|
-
* Extend the `AuthUser` interface via module augmentation in `@forinda/kickjs-auth`
|
|
201
|
-
* to get full typing.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* ```ts
|
|
205
|
-
* @Get('/me')
|
|
206
|
-
* @Authenticated()
|
|
207
|
-
* getProfile(ctx: RequestContext) {
|
|
208
|
-
* const user = ctx.user
|
|
209
|
-
* if (!user) return ctx.notFound()
|
|
210
|
-
* return ctx.json({ user })
|
|
211
|
-
* }
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
get user(): MetaValue<'user', Record<string, any>> | undefined;
|
|
215
|
-
/**
|
|
216
|
-
* Tenant identifier for multi-tenant apps. Reads `user.tenantId` —
|
|
217
|
-
* populated either by `AuthAdapter.testMode({ tenantId })`, a tenant
|
|
218
|
-
* resolver middleware, or manually on the strategy's `mapPayload`.
|
|
219
|
-
*
|
|
220
|
-
* Augment `AuthUser` (or `ContextMeta['user']`) to widen the return
|
|
221
|
-
* type if your user shape guarantees a non-`string | undefined` id.
|
|
222
|
-
*/
|
|
223
|
-
get tenantId(): string | undefined;
|
|
224
|
-
/**
|
|
225
|
-
* Effective role list for the current user. Prefers `user.tenantRoles`
|
|
226
|
-
* (populated by `AuthAdapterOptions.roleResolver` under a tenant) and
|
|
227
|
-
* falls back to `user.roles`. Returns an empty array when the user is
|
|
228
|
-
* absent or the shape has neither field.
|
|
229
|
-
*/
|
|
230
|
-
get roles(): string[];
|
|
231
|
-
/**
|
|
232
|
-
* Parse the request query string into structured filters, sort, pagination, and search.
|
|
233
|
-
* Pass the result to an ORM query builder adapter (Drizzle, Prisma, Sequelize, etc.).
|
|
234
|
-
*
|
|
235
|
-
* Generic over the field config: when passed an inline literal (or
|
|
236
|
-
* `as const`), `filters[].field` and `sort[].field` are narrowed to
|
|
237
|
-
* the exact whitelisted field names. Pass nothing or a non-literal
|
|
238
|
-
* config and you get the loose `string` fallback.
|
|
239
|
-
*
|
|
240
|
-
* @param fieldConfig - Optional whitelist for filterable, sortable, and searchable fields
|
|
241
|
-
* @param options - Limits (`maxLimit`, `defaultLimit`, `maxSearchLength`) and an
|
|
242
|
-
* `onReject` hook. By default a rejected/over-broad field is logged via
|
|
243
|
-
* `console.warn` with the request id; pass an explicit `onReject` to override
|
|
244
|
-
* (e.g. throw to return a 400), or `onReject: () => {}` to silence.
|
|
245
|
-
*
|
|
246
|
-
* @example
|
|
247
|
-
* ```ts
|
|
248
|
-
* @Get('/')
|
|
249
|
-
* async list(ctx: RequestContext) {
|
|
250
|
-
* const parsed = ctx.qs({
|
|
251
|
-
* filterable: ['status', 'priority'],
|
|
252
|
-
* sortable: ['createdAt', 'title'],
|
|
253
|
-
* } as const)
|
|
254
|
-
* parsed.filters[0].field // typed as 'status' | 'priority'
|
|
255
|
-
* parsed.sort[0].field // typed as 'createdAt' | 'title'
|
|
256
|
-
* }
|
|
257
|
-
* ```
|
|
258
|
-
*/
|
|
259
|
-
qs<TConfig extends QueryFieldConfig | undefined = undefined>(fieldConfig?: TConfig, options?: ParseQueryOptions): TypedParsedQuery<TConfig>;
|
|
260
|
-
/**
|
|
261
|
-
* Single uploaded file (requires `@FileUpload({ mode: 'single' })`).
|
|
262
|
-
* Wrapped in a dev-only Proxy that warns on mutation — see {@link body}.
|
|
263
|
-
* File metadata is set by the upload middleware and shouldn't be
|
|
264
|
-
* mutated downstream.
|
|
265
|
-
*/
|
|
266
|
-
get file(): Express.Multer.File | undefined;
|
|
267
|
-
/**
|
|
268
|
-
* Array of uploaded files (requires `@FileUpload({ mode: 'array' })`).
|
|
269
|
-
* The array (and each entry in dev) is wrapped in a read-only Proxy
|
|
270
|
-
* that warns on `push`/`pop` and per-file mutation. Use
|
|
271
|
-
* `ctx.req.files` if you genuinely need the mutable Express handle.
|
|
272
|
-
*/
|
|
273
|
-
get files(): Express.Multer.File[] | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* Read a value from the per-request metadata store.
|
|
276
|
-
*
|
|
277
|
-
* When `ContextMeta` has been augmented with a matching key, the return
|
|
278
|
-
* type is inferred automatically. For ad-hoc keys, pass a generic:
|
|
279
|
-
* `ctx.get<MyType>('custom')`.
|
|
280
|
-
*/
|
|
281
|
-
get<K extends string>(key: K): MetaValue<K> | undefined;
|
|
282
|
-
/**
|
|
283
|
-
* Write a value to the per-request metadata store. Throws when no
|
|
284
|
-
* AsyncLocalStorage frame is active — see {@link metadataForWrite}
|
|
285
|
-
* for why a silent fallback is the wrong default.
|
|
286
|
-
*/
|
|
287
|
-
set<K extends string>(key: K, value: MetaValue<K>): void;
|
|
288
|
-
json(data: any, status?: number): Response<any, Record<string, any>>;
|
|
289
|
-
created(data: any): Response<any, Record<string, any>>;
|
|
290
|
-
noContent(): Response<any, Record<string, any>>;
|
|
291
|
-
/**
|
|
292
|
-
* @deprecated Prefer {@link ProblemSender.notFound | ctx.problem.notFound()},
|
|
293
|
-
* which emits an RFC 9457 — Problem Details response. This helper stays
|
|
294
|
-
* for backward compatibility and will not be removed.
|
|
295
|
-
*/
|
|
296
|
-
notFound(message?: string): Response<any, Record<string, any>>;
|
|
297
|
-
/**
|
|
298
|
-
* @deprecated Prefer {@link ProblemSender.badRequest | ctx.problem.badRequest()},
|
|
299
|
-
* which emits an RFC 9457 — Problem Details response. This helper stays
|
|
300
|
-
* for backward compatibility and will not be removed.
|
|
301
|
-
*/
|
|
302
|
-
badRequest(message: string): Response<any, Record<string, any>>;
|
|
303
|
-
/**
|
|
304
|
-
* RFC 9457 — Problem Details for HTTP APIs response helper.
|
|
305
|
-
* https://datatracker.ietf.org/doc/html/rfc9457
|
|
306
|
-
*
|
|
307
|
-
* `ctx.problem(...)` sends a canonical problem-detail response with
|
|
308
|
-
* `Content-Type: application/problem+json`. The convenience methods
|
|
309
|
-
* (`ctx.problem.notFound`, `.badRequest`, etc.) pre-fill `status` +
|
|
310
|
-
* `title` for the common codes.
|
|
311
|
-
*
|
|
312
|
-
* `type` defaults to `about:blank` (§3.1.1); `title` defaults to the
|
|
313
|
-
* IANA reason phrase for `status` (§3.1.4). Extension members per §3.2
|
|
314
|
-
* pass through unchanged.
|
|
315
|
-
*
|
|
316
|
-
* @example
|
|
317
|
-
* ```ts
|
|
318
|
-
* ctx.problem({
|
|
319
|
-
* type: 'https://api.example.com/problems/out-of-credit',
|
|
320
|
-
* status: 403,
|
|
321
|
-
* detail: 'Your balance is 30, but that costs 50.',
|
|
322
|
-
* instance: `/account/${ctx.user.id}/messages/${ctx.params.id}`,
|
|
323
|
-
* balance: 30,
|
|
324
|
-
* })
|
|
325
|
-
*
|
|
326
|
-
* ctx.problem.notFound({ detail: 'User abc not found' })
|
|
327
|
-
* ctx.problem.validation(zodResult.error.issues)
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* @see {@link ProblemException} for the exception-throwing equivalent
|
|
331
|
-
* (use it from services where `ctx` isn't in scope).
|
|
332
|
-
*/
|
|
333
|
-
get problem(): ProblemSender;
|
|
334
|
-
private sendProblem;
|
|
335
|
-
html(content: string, status?: number): Response<any, Record<string, any>>;
|
|
336
|
-
download(buffer: Buffer, filename: string, contentType?: string): Response<any, Record<string, any>>;
|
|
337
|
-
/**
|
|
338
|
-
* Render a template using the registered view engine (EJS, Pug, Handlebars, etc.).
|
|
339
|
-
* Requires a ViewAdapter to be configured in bootstrap().
|
|
340
|
-
*
|
|
341
|
-
* @param template - Template name (without extension, relative to viewsDir)
|
|
342
|
-
* @param data - Data to pass to the template
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
* ```ts
|
|
346
|
-
* ctx.render('dashboard', { user, title: 'Dashboard' })
|
|
347
|
-
* ctx.render('emails/welcome', { name: 'Alice' })
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
render(template: string, data?: Record<string, any>): void;
|
|
351
|
-
/**
|
|
352
|
-
* Parse query params and return a standardized paginated response.
|
|
353
|
-
* Calls `ctx.qs()` internally, then wraps your data with pagination meta.
|
|
354
|
-
*
|
|
355
|
-
* @param fetcher - Async function that receives ParsedQuery and returns `{ data, total }`
|
|
356
|
-
* @param fieldConfig - Optional whitelist for filterable, sortable, searchable fields
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* ```ts
|
|
360
|
-
* @Get('/')
|
|
361
|
-
* async list(ctx: RequestContext) {
|
|
362
|
-
* return ctx.paginate(
|
|
363
|
-
* async (parsed) => {
|
|
364
|
-
* const data = await db.select().from(users)
|
|
365
|
-
* .where(query.where).limit(parsed.pagination.limit)
|
|
366
|
-
* .offset(parsed.pagination.offset).all()
|
|
367
|
-
* const total = await db.select({ count: count() }).from(users).get()
|
|
368
|
-
* return { data, total: total?.count ?? 0 }
|
|
369
|
-
* },
|
|
370
|
-
* { filterable: ['name', 'role'], sortable: ['createdAt'] },
|
|
371
|
-
* )
|
|
372
|
-
* }
|
|
373
|
-
* ```
|
|
374
|
-
*/
|
|
375
|
-
paginate<T, TConfig extends QueryFieldConfig | undefined = undefined>(fetcher: (parsed: TypedParsedQuery<TConfig>) => Promise<{
|
|
376
|
-
data: T[];
|
|
377
|
-
total: number;
|
|
378
|
-
}>, fieldConfig?: TConfig): Promise<Response<any, Record<string, any>>>;
|
|
379
|
-
/**
|
|
380
|
-
* Start an SSE (Server-Sent Events) stream.
|
|
381
|
-
* Sets the correct headers and returns helpers to send events.
|
|
382
|
-
*
|
|
383
|
-
* @example
|
|
384
|
-
* ```ts
|
|
385
|
-
* @Get('/events')
|
|
386
|
-
* async stream(ctx: RequestContext) {
|
|
387
|
-
* const sse = ctx.sse()
|
|
388
|
-
*
|
|
389
|
-
* const interval = setInterval(() => {
|
|
390
|
-
* sse.send({ time: new Date().toISOString() }, 'tick')
|
|
391
|
-
* }, 1000)
|
|
392
|
-
*
|
|
393
|
-
* sse.onClose(() => clearInterval(interval))
|
|
394
|
-
* }
|
|
395
|
-
* ```
|
|
396
|
-
*/
|
|
397
|
-
sse(): {
|
|
398
|
-
/** Send an SSE event with optional event name and id */send: (data: any, event?: string, id?: string) => void; /** Send a comment (keeps connection alive) */
|
|
399
|
-
comment: (text: string) => void; /** Register a callback when the client disconnects */
|
|
400
|
-
onClose: (fn: () => void) => void; /** End the SSE stream */
|
|
401
|
-
close: () => void;
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Short alias for `RequestContext` parameterised by a route shape.
|
|
406
|
-
*
|
|
407
|
-
* Use with `kick typegen`'s generated `KickRoutes` namespace for
|
|
408
|
-
* fully-typed `ctx.params`, `ctx.body`, and `ctx.query`. Metadata
|
|
409
|
-
* typing (`ctx.get()`, `ctx.set()`, `ctx.user`) comes from
|
|
410
|
-
* `ContextMeta` augmentation and works on all `RequestContext` instances.
|
|
411
|
-
*
|
|
412
|
-
* @example
|
|
413
|
-
* ```ts
|
|
414
|
-
* @Get('/:id')
|
|
415
|
-
* getUser(ctx: Ctx<KickRoutes.UserController['getUser']>) {
|
|
416
|
-
* ctx.params.id // typed from RouteShape
|
|
417
|
-
* ctx.body // typed from RouteShape
|
|
418
|
-
* ctx.user // typed from ContextMeta
|
|
419
|
-
* ctx.get('tenant') // typed from ContextMeta
|
|
420
|
-
* }
|
|
421
|
-
* ```
|
|
422
|
-
*/
|
|
423
|
-
type Ctx<TRoute extends RouteShape = RouteShape> = RequestContext<TRoute extends {
|
|
424
|
-
body: infer B;
|
|
425
|
-
} ? B : any, TRoute extends {
|
|
426
|
-
params: infer P;
|
|
427
|
-
} ? P : any, TRoute extends {
|
|
428
|
-
query: infer Q;
|
|
429
|
-
} ? Q : any>;
|
|
430
|
-
/**
|
|
431
|
-
* Global ambient registry of typed routes, populated by `kick typegen`.
|
|
432
|
-
*
|
|
433
|
-
* Each interface inside `KickRoutes` corresponds to a controller class;
|
|
434
|
-
* each property is one route method on that controller. The values
|
|
435
|
-
* conform to `RouteShape`.
|
|
436
|
-
*
|
|
437
|
-
* Empty by default — declarations come from `.kickjs/types/routes.d.ts`
|
|
438
|
-
* generated alongside the rest of the typegen output.
|
|
439
|
-
*/
|
|
440
|
-
declare global {
|
|
441
|
-
namespace KickRoutes {}
|
|
442
|
-
} //# sourceMappingURL=context.d.ts.map
|
|
443
|
-
//#endregion
|
|
444
|
-
export { RouteShape as i, DeepReadonly as n, RequestContext as r, Ctx as t };
|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AEpC,gBAAA,EApCmD;EAAA,SA2CtD,QAAA,GAAQ,KAAA,GAAQ,IAAA,CAAK,cAAA,gBAAiC,gBAAA;EAvCtC;;;;EAAA,SA+ChB,YAAA,GAAY,KAAA,OAAW,KAAA,GAAS,IAAA,CAAK,cAAA,gBAAiC,gBAAA;AAAA;;;;;;;;;;;;iBA0BxD,gBAAA,CAAiB,KAAA,EAAO,cAAA,GAAiB,cAAc"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/core/execution-context.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Transport-agnostic execution context primitives.
|
|
5
|
-
*
|
|
6
|
-
* `ExecutionContext` is the minimal contract every transport-specific
|
|
7
|
-
* context object satisfies — `RequestContext` (HTTP) implements it today;
|
|
8
|
-
* `WsContext`, `QueueContext`, and `CronContext` will adopt it in V2.
|
|
9
|
-
*
|
|
10
|
-
* `ContextMeta` is the augmentable per-request key/type registry. Apps and
|
|
11
|
-
* plugins extend it via module augmentation to get type-safe `ctx.get/set`
|
|
12
|
-
* across the codebase. It lives in core/ (not http/) so non-HTTP transports
|
|
13
|
-
* share a single declaration site.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* declare module '@forinda/kickjs' {
|
|
18
|
-
* interface ContextMeta {
|
|
19
|
-
* user: { id: string; email: string }
|
|
20
|
-
* tenant: { id: string; name: string }
|
|
21
|
-
* }
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* function loadProject(ctx: ExecutionContext) {
|
|
25
|
-
* const user = ctx.get('user') // typed: { id: string; email: string } | undefined
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Augmentable per-request **value-type** registry.
|
|
31
|
-
*
|
|
32
|
-
* Extend via module augmentation to give `ctx.get()` / `ctx.set()` static
|
|
33
|
-
* type information for a given key. Unknown keys still resolve via an
|
|
34
|
-
* explicit generic: `ctx.get<MyType>('custom')`.
|
|
35
|
-
*
|
|
36
|
-
* ```ts
|
|
37
|
-
* declare module '@forinda/kickjs' {
|
|
38
|
-
* interface ContextMeta {
|
|
39
|
-
* tenant: { id: string; name: string }
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* Every key declared here is automatically a valid `dependsOn` key — see
|
|
45
|
-
* {@link ContextKeys} for the relationship.
|
|
46
|
-
*/
|
|
47
|
-
interface ContextMeta {}
|
|
48
|
-
/**
|
|
49
|
-
* Augmentable per-request **key** registry — the set of context keys a
|
|
50
|
-
* project's contributors populate, independent of whether each key has a
|
|
51
|
-
* declared value type in {@link ContextMeta}.
|
|
52
|
-
*
|
|
53
|
-
* This exists so `dependsOn` (and any other key-level typing) can be
|
|
54
|
-
* narrowed to real keys WITHOUT forcing every key to carry a value type.
|
|
55
|
-
* Before it, `dependsOn` was typed against `keyof ContextMeta` alone, so
|
|
56
|
-
* the moment a project augmented `ContextMeta` for *some* keys, any
|
|
57
|
-
* contributor that depended on a key you hadn't added to `ContextMeta`
|
|
58
|
-
* stopped compiling — even though that key was a perfectly valid
|
|
59
|
-
* contributor. Splitting the two registries removes that coupling:
|
|
60
|
-
*
|
|
61
|
-
* - Put a key in `ContextMeta` when you want `ctx.get(key)` typed.
|
|
62
|
-
* - Put a key in `ContextKeys` when it's a real contributor key but you
|
|
63
|
-
* don't need a value type for it (e.g. a marker, or a value you only
|
|
64
|
-
* ever read with an explicit generic).
|
|
65
|
-
*
|
|
66
|
-
* Keys from BOTH registries are accepted by `dependsOn`, so adding a
|
|
67
|
-
* value type via `ContextMeta` never breaks a `dependsOn` elsewhere.
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* declare module '@forinda/kickjs' {
|
|
71
|
-
* interface ContextKeys {
|
|
72
|
-
* session: true // value type irrelevant; the key just exists
|
|
73
|
-
* }
|
|
74
|
-
* }
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
interface ContextKeys {}
|
|
78
|
-
/** Resolve a {@link ContextMeta} value type, falling back to `Fallback` for unknown keys. */
|
|
79
|
-
type MetaValue<K extends string, Fallback = unknown> = K extends keyof ContextMeta ? ContextMeta[K] : Fallback;
|
|
80
|
-
/**
|
|
81
|
-
* Minimal transport-agnostic execution context.
|
|
82
|
-
*
|
|
83
|
-
* `RequestContext` (HTTP) implements this directly; future `WsContext`,
|
|
84
|
-
* `QueueContext`, and `CronContext` (V2) will too. The Context Contributor
|
|
85
|
-
* pipeline only depends on this interface — contributors authored against
|
|
86
|
-
* `ExecutionContext` work across every transport that adopts it.
|
|
87
|
-
*/
|
|
88
|
-
interface ExecutionContext {
|
|
89
|
-
/** Read a typed value from per-request metadata. */
|
|
90
|
-
get<K extends string>(key: K): MetaValue<K> | undefined;
|
|
91
|
-
/** Write a typed value into per-request metadata. */
|
|
92
|
-
set<K extends string>(key: K, value: MetaValue<K>): void;
|
|
93
|
-
/** Unique per-request identifier (HTTP: x-request-id; WS/queue/cron: transport-defined). */
|
|
94
|
-
readonly requestId: string | undefined;
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
97
|
-
export { MetaValue as i, ContextMeta as n, ExecutionContext as r, ContextKeys as t };
|
|
98
|
-
//# sourceMappingURL=execution-context-B4cfhivz.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution-context-B4cfhivz.d.mts","names":[],"sources":["../src/core/execution-context.ts"],"mappings":";;;AA8CA;;;;AAA4B;AAgC5B;;;;AAA4B;AAG5B;;;;;;;;;;;;;;;;;;AAEY;AAUZ;;;;;;;;;;;;;;UA/CiB,WAAA;;;;;;;;;;;AAqDG;;;;;;;;;;;;;;;;;;;UArBH,WAAA;;KAGL,SAAA,yCAAkD,CAAA,eAAgB,WAAA,GAC1E,WAAA,CAAY,CAAA,IACZ,QAAA;;;;;;;;;UAUa,gBAAA;;EAEf,GAAA,mBAAsB,GAAA,EAAK,CAAA,GAAI,SAAA,CAAU,CAAA;;EAEzC,GAAA,mBAAsB,GAAA,EAAK,CAAA,EAAG,KAAA,EAAO,SAAA,CAAU,CAAA;;WAEtC,SAAA;AAAA"}
|