@barqjs/start 0.0.0-stage → 0.2.0-next.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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +817 -2
  3. package/dist/client-BsyxVCyu.js +1554 -0
  4. package/dist/client-BsyxVCyu.js.map +1 -0
  5. package/dist/client-DidH0F2e.d.ts +450 -0
  6. package/dist/client-DidH0F2e.d.ts.map +1 -0
  7. package/dist/client.d.ts +25 -0
  8. package/dist/client.js +4 -0
  9. package/dist/env-Bhk_aIkx.d.ts +47 -0
  10. package/dist/env-Bhk_aIkx.d.ts.map +1 -0
  11. package/dist/env.d.ts +2 -0
  12. package/dist/env.js +43 -0
  13. package/dist/env.js.map +1 -0
  14. package/dist/index-B4o7eyCr.d.ts +925 -0
  15. package/dist/index-B4o7eyCr.d.ts.map +1 -0
  16. package/dist/index.d.ts +18 -0
  17. package/dist/index.js +6 -0
  18. package/dist/middleware-B-tI8QHQ.d.ts +574 -0
  19. package/dist/middleware-B-tI8QHQ.d.ts.map +1 -0
  20. package/dist/middleware.d.ts +2 -0
  21. package/dist/middleware.js +281 -0
  22. package/dist/middleware.js.map +1 -0
  23. package/dist/prerender.d.ts +118 -0
  24. package/dist/prerender.d.ts.map +1 -0
  25. package/dist/prerender.js +289 -0
  26. package/dist/prerender.js.map +1 -0
  27. package/dist/protocol.d.ts +56 -0
  28. package/dist/protocol.d.ts.map +1 -0
  29. package/dist/protocol.js +25 -0
  30. package/dist/protocol.js.map +1 -0
  31. package/dist/serve.d.ts +144 -0
  32. package/dist/serve.d.ts.map +1 -0
  33. package/dist/serve.js +221 -0
  34. package/dist/serve.js.map +1 -0
  35. package/dist/server-DG6jb_NA.js +1253 -0
  36. package/dist/server-DG6jb_NA.js.map +1 -0
  37. package/dist/server.d.ts +159 -0
  38. package/dist/server.d.ts.map +1 -0
  39. package/dist/server.js +1 -0
  40. package/dist/src-odXG7kLA.js +1151 -0
  41. package/dist/src-odXG7kLA.js.map +1 -0
  42. package/dist/static-fn-CXjJi-It.js +122 -0
  43. package/dist/static-fn-CXjJi-It.js.map +1 -0
  44. package/package.json +106 -4
  45. package/src/client.ts +698 -0
  46. package/src/context.ts +699 -0
  47. package/src/cookies.ts +229 -0
  48. package/src/env.ts +86 -0
  49. package/src/fn-error.ts +121 -0
  50. package/src/frames-client.ts +1220 -0
  51. package/src/frames-server.ts +464 -0
  52. package/src/frames.ts +285 -0
  53. package/src/index.ts +740 -0
  54. package/src/live-client.ts +50 -0
  55. package/src/live-server.ts +292 -0
  56. package/src/middleware.ts +994 -0
  57. package/src/prerender.ts +477 -0
  58. package/src/protocol.ts +61 -0
  59. package/src/rate-limit.ts +202 -0
  60. package/src/serve.ts +153 -0
  61. package/src/server.ts +1026 -0
  62. package/src/session.ts +449 -0
  63. package/src/start-instance.ts +147 -0
  64. package/src/static-fn.ts +181 -0
  65. package/src/static.ts +302 -0
  66. package/src/stubs.ts +32 -0
  67. package/src/timing.ts +29 -0
  68. package/src/wire-types.ts +138 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B4o7eyCr.d.ts","names":["AnySerializationAdapter"],"sources":["../src/cookies.ts","../src/session.ts","../src/start-instance.ts","../src/context.ts","../src/rate-limit.ts","../src/timing.ts","../src/wire-types.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2BiB;WACN;WACA,UAAU;WACV;;WAEA;;WAEA;WACA;WACA;WACA;WACA;;;;;;;WAOA,UAAU;;;;;;;;;;;iBA0CL,aAAa,oCAAoC;;;;;;;iBAmCjD,gBAAgB,cAAc,eAAe,UAAS;;;;;;;;;;iBAwGtD,iBAAiB,cAAc,UAAS;;KCpM5C,cAAc;UAET,QAAQ,UAAU,cAAc;;WAEtC;;WAEA;WACA,MAAM,QAAQ;;UAGR,eAAe,UAAU,cAAc;WAC7C;;WAEA;WACA,MAAM,QAAQ;;EAEvB,OACE,OAAO,QAAQ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18 @@
1
+ /**
2
+ * Server functions — the builder, and the two stubs the compiler emits.
3
+ *
4
+ * A server function is written once and reachable from both sides. The compiler
5
+ * decides which side a module is being compiled for and replaces the handler
6
+ * with the matching stub: `serverRpc` on the server, where the body runs, and
7
+ * `clientRpc` on the client, where it becomes a fetch. That decision is a
8
+ * compile-time one and is never taken at runtime, so the body cannot reach a
9
+ * client bundle by being unreachable-but-present.
10
+ *
11
+ * Nothing in this file is safe to call from a browser bundle except
12
+ * `clientRpc`. `./server` is where the request handler lives.
13
+ */
14
+ import { $ as ServerFnThrown, A as clientRpc, C as ServerFnArgs, D as ServerFnMethod, E as ServerFnMeta, F as live, H as FRAME_APPLIED_EVENT, J as STATIC_PREFIX, L as LiveIterable, N as isServerFn, O as Streamed, Q as ServerFnIssue, R as LiveStatus, S as ServerFn, T as ServerFnInputAnswer, U as Slot, V as BindingSlot, W as isFrame, X as staticUrl, Y as staticFunctionMiddleware, Z as ServerFnError, _ as RpcNotFound, a as DATA_SUFFIX, b as SERVER_FN, c as RPC_CALLER, d as RPC_PREFIX, et as UNKNOWN_HEADER, h as RpcControl, i as ChainStep, l as RPC_CONTEXT, n as BUILD_HEADER, o as LIVE_SUFFIX, p as RPC_STREAM, s as PAYLOAD_PARAM, t as AnyServerFn, u as RPC_CONTROL, v as RpcRedirect, w as ServerFnCallOptions } from "./client-DidH0F2e.js";
15
+ import { $ as runMiddleware, A as RequestMiddleware, B as ValidationError, C as NextOptions, D as OwnReplaced, E as OpenContext, F as StandardInput, G as WithClient, H as ValidatorInput, I as StandardOutput, J as applyValidator, K as WithServer, L as StandardSchema, M as RequestMiddlewareFn, N as RequestMiddlewareNext, O as Plain, P as RequestMiddlewareStart, Q as isInputError, R as StandardSchemaLike, S as NOT_FOUND, T as NoContribution, U as ValidatorReplaced, V as Validator, W as WithChain, X as flattenMiddleware, Y as createMiddleware, Z as isBuiltMiddleware, _ as MiddlewareContext, a as ClientReplaced, b as MiddlewareOptions, c as ContributionOf, d as Empty, et as runRequestMiddleware, f as FreshMiddleware, g as Middleware, h as Merged, i as ClientMiddlewareContext, j as RequestMiddlewareContext, k as REDIRECT, m as InputError, n as Carries, o as ContributedBy, p as FromNext, q as WithValidator, r as ChainContribution, s as Contribution, t as BuiltMiddleware, tt as toValidator, u as DataAt, v as MiddlewareFn, w as NextResult, x as MiddlewareState, y as MiddlewareNext, z as UncheckedInputError } from "./middleware-B-tI8QHQ.js";
16
+ import { a as createServerOnlyFn, i as createIsomorphicFn, n as IsomorphicFn, r as createClientOnlyFn, t as IsomorphicBuilder } from "./env-Bhk_aIkx.js";
17
+ import { $ as getRequestHeaders, A as RateLimitCount, At as Session, B as appendResponseHeader, Bt as CookieOptions, C as InputProblem, Ct as Register, D as WireProblem, Dt as clearStart, E as Strictness, Et as StartOptions, F as rateLimit, Ft as getSession, G as deleteCookie, H as clearResponseHeaders, Ht as parseCookies, I as DevStylesheets, It as sealSession, J as getCookie, K as devStylesheets, L as ForwardedForTrust, Lt as unsealSession, M as RateLimitStore, Mt as SessionData, N as byIP, Nt as SessionManager, O as ServerTiming, Ot as createStart, P as memoryStore, Pt as clearSession, Q as getRequestHeader, R as RequestContext, Rt as updateSession, S as Crossable, St as GlobalRequestContext, T as StrictOn, Tt as StartInstance, U as collectRequestCss, Ut as serializeCookie, V as applyResponseDraft, Vt as deleteCookieLine, W as createResponseDraft, X as getGlobalStartContext, Y as getCookies, Z as getRequest, _ as createSerializationAdapter, _t as setResponseStatus, a as FreshServerFn, at as getResponseHeaders, b as middlewareOf, bt as FunctionContextOf, c as HandlerData, ct as invalidateFrames, d as SerializationAdapter, dt as peekResponseDraft, et as getRequestHost, f as ServerFnBuilder, ft as removeResponseHeader, g as checkInput, gt as setResponseHeaders, h as Validates, ht as setResponseHeader, i as FnWithValidator, it as getResponseHeader, j as RateLimitOptions, jt as SessionConfig, k as serverTiming, kt as startOptions, l as InputCheck, lt as markResponseSent, m as ServerFnState, mt as setRequestMiddlewareContext, n as CallerInput, nt as getRequestProtocol, o as HandlerContext, ot as getResponseStatus, p as ServerFnOptions, pt as setCookie, q as draftedStatus, r as FnWithChain, rt as getRequestUrl, s as HandlerContextOf, st as installCssSink, t as AnySerializationAdapter, tt as getRequestIP, u as ResultCheck, ut as peekRequest, v as createServerFn, vt as takeSendContext, w as ResultProblem, wt as RequestContextOf, x as serverRpc, xt as GlobalFunctionContext, y as json, yt as withRequest, z as ResponseDraft, zt as useSession } from "./index-B4o7eyCr.js";
18
+ export { type AnySerializationAdapter, type AnyServerFn, BUILD_HEADER, type BindingSlot, type BuiltMiddleware, CallerInput, type Carries, type ChainContribution, type ChainStep, type ClientMiddlewareContext, type ClientReplaced, type ContributedBy, type Contribution, type ContributionOf, type CookieOptions, type Crossable, DATA_SUFFIX, type DataAt, type DevStylesheets, type Empty, FRAME_APPLIED_EVENT, FnWithChain, FnWithValidator, type ForwardedForTrust, type FreshMiddleware, FreshServerFn, type FromNext, type FunctionContextOf, type GlobalFunctionContext, type GlobalRequestContext, HandlerContext, HandlerContextOf, HandlerData, InputCheck, InputError, type InputProblem, type IsomorphicBuilder, type IsomorphicFn, LIVE_SUFFIX, type LiveIterable, type LiveStatus, type Merged, type Middleware, type MiddlewareContext, type MiddlewareFn, type MiddlewareNext, type MiddlewareOptions, type MiddlewareState, NOT_FOUND, type NextOptions, type NextResult, type NoContribution, type OpenContext, type OwnReplaced, PAYLOAD_PARAM, type Plain, REDIRECT, RPC_CALLER, RPC_CONTEXT, RPC_CONTROL, RPC_PREFIX, RPC_STREAM, type RateLimitCount, type RateLimitOptions, type RateLimitStore, type Register, type RequestContext, type RequestContextOf, type RequestMiddleware, type RequestMiddlewareContext, type RequestMiddlewareFn, type RequestMiddlewareNext, type RequestMiddlewareStart, type ResponseDraft, ResultCheck, type ResultProblem, type RpcControl, RpcNotFound, RpcRedirect, SERVER_FN, STATIC_PREFIX, type SerializationAdapter, type ServerFn, type ServerFnArgs, ServerFnBuilder, type ServerFnCallOptions, ServerFnError, type ServerFnInputAnswer, type ServerFnIssue, type ServerFnMeta, type ServerFnMethod, ServerFnOptions, ServerFnState, type ServerFnThrown, type ServerTiming, type Session, type SessionConfig, type SessionData, type SessionManager, type Slot, type StandardInput, type StandardOutput, type StandardSchema, type StandardSchemaLike, type StartInstance, type StartOptions, type Streamed, type StrictOn, type Strictness, UNKNOWN_HEADER, UncheckedInputError, Validates, ValidationError, type Validator, type ValidatorInput, type ValidatorReplaced, type WireProblem, type WithChain, type WithClient, type WithServer, type WithValidator, appendResponseHeader, applyResponseDraft, applyValidator, byIP, checkInput, clearResponseHeaders, clearSession, clearStart, clientRpc, collectRequestCss, createClientOnlyFn, createIsomorphicFn, createMiddleware, createResponseDraft, createSerializationAdapter, createServerFn, createServerOnlyFn, createStart, deleteCookie, deleteCookieLine, devStylesheets, draftedStatus, flattenMiddleware, getCookie, getCookies, getGlobalStartContext, getRequest, getRequestHeader, getRequestHeaders, getRequestHost, getRequestIP, getRequestProtocol, getRequestUrl, getResponseHeader, getResponseHeaders, getResponseStatus, getSession, installCssSink, invalidateFrames, isBuiltMiddleware, isFrame, isInputError, isServerFn, json, live, markResponseSent, memoryStore, middlewareOf, parseCookies, peekRequest, peekResponseDraft, rateLimit, removeResponseHeader, runMiddleware, runRequestMiddleware, sealSession, serializeCookie, serverRpc, serverTiming, setCookie, setRequestMiddlewareContext, setResponseHeader, setResponseHeaders, setResponseStatus, startOptions, staticFunctionMiddleware, staticUrl, takeSendContext, toValidator, unsealSession, updateSession, useSession, withRequest };
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { $ as parseCookies, A as getRequestHeaders, C as devStylesheets, D as getGlobalStartContext, E as getCookies, F as getResponseHeader, G as setCookie, H as peekRequest, I as getResponseHeaders, J as setResponseHeaders, K as setRequestMiddlewareContext, L as getResponseStatus, M as getRequestIP, N as getRequestProtocol, O as getRequest, P as getRequestUrl, Q as deleteCookieLine, R as installCssSink, S as deleteCookie, T as getCookie, U as peekResponseDraft, V as markResponseSent, W as removeResponseHeader, X as takeSendContext, Y as setResponseStatus, Z as withRequest, _ as appendResponseHeader, a as middlewareOf, b as collectRequestCss, c as clearSession, d as unsealSession, et as serializeCookie, f as updateSession, g as rateLimit, h as memoryStore, i as json, j as getRequestHost, k as getRequestHeader, l as getSession, m as byIP, n as createSerializationAdapter, o as serverRpc, p as useSession, q as setResponseHeader, r as createServerFn, s as serverTiming, t as checkInput, u as sealSession, v as applyResponseDraft, w as draftedStatus, x as createResponseDraft, y as clearResponseHeaders, z as invalidateFrames } from "./src-odXG7kLA.js";
2
+ import { C as live, E as startOptions, J as UNKNOWN_HEADER, M as FRAME_APPLIED_EVENT, T as createStart, V as isFrame, a as PAYLOAD_PARAM, c as RPC_CONTROL, d as RPC_STREAM, h as SERVER_FN, i as LIVE_SUFFIX, l as RPC_PREFIX, m as RpcRedirect, o as RPC_CALLER, p as RpcNotFound, q as ServerFnError, r as DATA_SUFFIX, s as RPC_CONTEXT, t as BUILD_HEADER, v as clientRpc, w as clearStart, x as isServerFn } from "./client-BsyxVCyu.js";
3
+ import { InputError, NOT_FOUND, REDIRECT, UncheckedInputError, ValidationError, applyValidator, createMiddleware, flattenMiddleware, isBuiltMiddleware, isInputError, runMiddleware, runRequestMiddleware, toValidator } from "./middleware.js";
4
+ import { i as staticUrl, r as staticFunctionMiddleware, t as STATIC_PREFIX } from "./static-fn-CXjJi-It.js";
5
+ import { createClientOnlyFn, createIsomorphicFn, createServerOnlyFn } from "./env.js";
6
+ export { BUILD_HEADER, DATA_SUFFIX, FRAME_APPLIED_EVENT, InputError, LIVE_SUFFIX, NOT_FOUND, PAYLOAD_PARAM, REDIRECT, RPC_CALLER, RPC_CONTEXT, RPC_CONTROL, RPC_PREFIX, RPC_STREAM, RpcNotFound, RpcRedirect, SERVER_FN, STATIC_PREFIX, ServerFnError, UNKNOWN_HEADER, UncheckedInputError, ValidationError, appendResponseHeader, applyResponseDraft, applyValidator, byIP, checkInput, clearResponseHeaders, clearSession, clearStart, clientRpc, collectRequestCss, createClientOnlyFn, createIsomorphicFn, createMiddleware, createResponseDraft, createSerializationAdapter, createServerFn, createServerOnlyFn, createStart, deleteCookie, deleteCookieLine, devStylesheets, draftedStatus, flattenMiddleware, getCookie, getCookies, getGlobalStartContext, getRequest, getRequestHeader, getRequestHeaders, getRequestHost, getRequestIP, getRequestProtocol, getRequestUrl, getResponseHeader, getResponseHeaders, getResponseStatus, getSession, installCssSink, invalidateFrames, isBuiltMiddleware, isFrame, isInputError, isServerFn, json, live, markResponseSent, memoryStore, middlewareOf, parseCookies, peekRequest, peekResponseDraft, rateLimit, removeResponseHeader, runMiddleware, runRequestMiddleware, sealSession, serializeCookie, serverRpc, serverTiming, setCookie, setRequestMiddlewareContext, setResponseHeader, setResponseHeaders, setResponseStatus, startOptions, staticFunctionMiddleware, staticUrl, takeSendContext, toValidator, unsealSession, updateSession, useSession, withRequest };
@@ -0,0 +1,574 @@
1
+ /**
2
+ * Middleware, and the input validation it composes.
3
+ *
4
+ * ITS OWN MODULE FOR ONE REASON: `client.ts` needs it. A middleware's client
5
+ * half runs in the browser, so the runner has to be reachable from the client
6
+ * stub — and `index.ts` re-exports `context.ts`, which reaches
7
+ * `node:async_hooks`. Importing the index from `client.ts` is the leak
8
+ * `DEFAULT_CLIENT_SOURCE` exists to avoid, and it is not theoretical: the same
9
+ * import through a route's `middleware` once left a fully server-rendered page
10
+ * on which nothing was interactive.
11
+ *
12
+ * Nothing here imports anything of barq's, for that reason.
13
+ */
14
+ /**
15
+ * A validator in the Standard Schema shape, which zod, valibot and arktype all
16
+ * implement. Taking the interface rather than a library keeps the dependency
17
+ * out and lets an application bring its own.
18
+ */
19
+ interface StandardSchema<In = unknown, Out = In> {
20
+ "~standard": {
21
+ version: 1;
22
+ vendor: string;
23
+ validate: (value: unknown) => {
24
+ value: Out;
25
+ } | {
26
+ issues: ReadonlyArray<unknown>;
27
+ } | Promise<{
28
+ value: Out;
29
+ } | {
30
+ issues: ReadonlyArray<unknown>;
31
+ }>;
32
+ /** The spec's type carrier: what the schema takes and what it produces. */
33
+ readonly types?: {
34
+ readonly input: In;
35
+ readonly output: Out;
36
+ };
37
+ };
38
+ }
39
+ /** Anything with a Standard Schema validator on it, which is all a schema is read for. */
40
+ interface StandardSchemaLike {
41
+ readonly "~standard": {
42
+ readonly validate: (value: unknown) => unknown;
43
+ };
44
+ }
45
+ /** What a caller hands a schema: its declared input, or anything when it declares none. */
46
+ type StandardInput<Schema> = [SchemaTypes<Schema>] extends [{
47
+ readonly input: infer In;
48
+ }] ? In : unknown;
49
+ /** What a schema produces: its declared output, or what its `validate` succeeds with. */
50
+ type StandardOutput<Schema> = [SchemaTypes<Schema>] extends [{
51
+ readonly output: infer Out;
52
+ }] ? Out : Schema extends {
53
+ readonly "~standard": {
54
+ readonly validate: (value: unknown) => infer Result;
55
+ };
56
+ } ? Succeeded<Awaited<Result>> : unknown;
57
+ /** The spec's optional `types`, read by key: a schema without it shares no member to match on. */
58
+ type SchemaTypes<Schema> = Schema extends {
59
+ readonly "~standard": infer Spec;
60
+ } ? "types" extends keyof Spec ? NonNullable<Spec["types" & keyof Spec]> : undefined : undefined;
61
+ type Succeeded<Result> = Result extends {
62
+ readonly value: infer Out;
63
+ } ? Out : never;
64
+ /**
65
+ * `'unchecked'` is the only way to open the input channel without a schema, and
66
+ * it has to be typed out.
67
+ *
68
+ * The default is the opposite: a server function declared with no validator
69
+ * rejects ANY argument off the wire with a 400. Every system surveyed except
70
+ * SvelteKit passes raw deserialized input straight into the handler, and the
71
+ * cost of not doing so is one word.
72
+ */
73
+ type Validator<T> = StandardSchema<unknown, T> | "unchecked";
74
+ /**
75
+ * What `.validator()` and `.inputValidator()` accept: a Standard Schema, a
76
+ * function that returns the validated value or throws, or an object with a
77
+ * `parse` that does. TanStack's three, probed in that order, since a zod schema
78
+ * is both the first and the third and the first reports issues without
79
+ * throwing.
80
+ */
81
+ type ValidatorInput<T> = Validator<T> | ((input: unknown) => T | Promise<T>) | {
82
+ readonly parse: (input: unknown) => T | Promise<T>;
83
+ };
84
+ /** Any accepted validator, as the one shape the runner applies. */
85
+ declare function toValidator<T>(input: ValidatorInput<T>): Validator<T>;
86
+ declare const INPUT_ERROR: unique symbol;
87
+ /**
88
+ * The caller's input was not acceptable — a 400 rather than a 500, whichever way
89
+ * it failed. One base so the handler cannot answer one of them correctly and
90
+ * turn the other into a server error, which is exactly what shipped first here.
91
+ */
92
+ declare class InputError extends Error {
93
+ /**
94
+ * A brand, read by {@link isInputError}, because `instanceof` answers for one
95
+ * copy of this module: a host's request handler would read a refusal the
96
+ * bundle's validator threw as a server error and answer 500.
97
+ */
98
+ readonly [INPUT_ERROR]: true;
99
+ }
100
+ /** Whether a thrown value is the caller's fault, whichever copy of this module threw it. */
101
+ declare function isInputError(error: unknown): error is InputError;
102
+ declare class ValidationError extends InputError {
103
+ readonly issues: ReadonlyArray<unknown>;
104
+ constructor(issues: ReadonlyArray<unknown>);
105
+ }
106
+ /** Thrown when a call arrives for a function that declared no validator. */
107
+ declare class UncheckedInputError extends InputError {
108
+ constructor();
109
+ }
110
+ /** The empty contribution: what a step that adds nothing adds. */
111
+ type Empty = object;
112
+ /**
113
+ * A context the types know some of. A key no typed step declared still reads,
114
+ * as `unknown`: an untyped closure may have put it there.
115
+ */
116
+ type OpenContext<Known extends object> = Known & Record<string, unknown>;
117
+ declare const NEXT: unique symbol;
118
+ /**
119
+ * What `next()` resolves to, as far as the types can see.
120
+ *
121
+ * At runtime it is whatever the rest of the chain answered. The type carries
122
+ * what this call contributed, so a middleware's context is read off the
123
+ * `return next({ context })` it ends with rather than declared a second time.
124
+ */
125
+ interface NextResult<Context extends object = Empty, Sent extends object = Empty> {
126
+ readonly [NEXT]: {
127
+ readonly context: Context;
128
+ readonly sent: Sent;
129
+ };
130
+ }
131
+ /** What a middleware may hand `next`. */
132
+ interface NextOptions<Context extends object = Empty, Sent extends object = Empty> {
133
+ /**
134
+ * MERGED into what every step below is handed, the handler included. This is
135
+ * how a middleware that authenticates hands the session down without a
136
+ * module-level store.
137
+ */
138
+ readonly context?: Context;
139
+ /**
140
+ * Context the OTHER side is given.
141
+ *
142
+ * From a server half it travels back on the response, so a middleware that
143
+ * resolved a session can tell the browser who it decided the user is without
144
+ * a second round trip. From a client half it travels to the server, where it
145
+ * arrives as `clientContext`: untrusted input, never `context`.
146
+ *
147
+ * It is SERIALIZED, so it carries what the value codec carries and nothing
148
+ * else. A `context` holding a database handle is fine; a `sendContext`
149
+ * holding one is a value the other side cannot be given.
150
+ */
151
+ readonly sendContext?: Sent;
152
+ /**
153
+ * Request headers for the fetch, from a CLIENT half: an `Authorization` a
154
+ * middleware holds the token for, a trace id.
155
+ *
156
+ * A later step's value for a name replaces an earlier one's, and the call's
157
+ * own `headers` replace both. A server half has no request to add to, so
158
+ * there it does nothing; its response headers are `setResponseHeader`'s.
159
+ */
160
+ readonly headers?: HeadersInit;
161
+ /**
162
+ * The `fetch` the call goes out through, from a CLIENT half: a retry, a
163
+ * tracer, a test double. A later step's replaces an earlier one's, and the
164
+ * call's own `fetch` option replaces both.
165
+ */
166
+ readonly fetch?: typeof fetch;
167
+ }
168
+ /**
169
+ * What a middleware calls to run the rest of the chain. `next()` with no
170
+ * argument runs it unchanged.
171
+ */
172
+ type MiddlewareNext = <Context extends object = Empty, Sent extends object = Empty>(options?: NextOptions<Context, Sent>) => Promise<NextResult<NoInfer<Context>, NoInfer<Sent>>>;
173
+ /**
174
+ * A middleware runs before the handler and decides whether there is going to be
175
+ * one. Rejecting is `throw new Response(...)`, which the request handler returns
176
+ * as it stands.
177
+ *
178
+ * Per FUNCTION, not per route. Every framework in the survey documents the same
179
+ * hole instead of closing it — Next.js: "A page-level authentication check does
180
+ * not extend to the Server Actions defined within it… the Server Action is a
181
+ * separate entry point." A middleware attached here cannot be escaped by
182
+ * reaching the function from somewhere else, because there is nowhere else.
183
+ *
184
+ * `Context` is what a bare closure promises to add, and it is checked against
185
+ * what it passes to `next`: `Middleware<{ user: string }>` that ends in
186
+ * `next()` is a type error. A built middleware needs no annotation, since its
187
+ * context is read off its body.
188
+ */
189
+ type Middleware<Context extends object = Empty> = Empty extends Context ? (next: MiddlewareNext) => Promise<unknown> : (next: MiddlewareNext) => Promise<NextResult<Context>>;
190
+ /**
191
+ * What a middleware contributes to everything after it, at the type level.
192
+ * Nothing here exists at runtime.
193
+ */
194
+ interface Contribution {
195
+ /** Added to the server `context` of every later step and of the handler. */
196
+ readonly context: object;
197
+ /** What its server halves send back to the caller. */
198
+ readonly sent: object;
199
+ /** What its client halves add to the client `context`. */
200
+ readonly clientContext: object;
201
+ /** What the first validator in the chain is handed: the caller's `data`. */
202
+ readonly input: unknown;
203
+ /** What the last validator in the chain produced: every later step's `data`. */
204
+ readonly output: unknown;
205
+ readonly validates: boolean;
206
+ }
207
+ interface NoContribution extends Contribution {
208
+ readonly context: Empty;
209
+ readonly sent: Empty;
210
+ readonly clientContext: Empty;
211
+ readonly input: undefined;
212
+ readonly output: undefined;
213
+ readonly validates: false;
214
+ }
215
+ /** `first`, then `second`: in the order the chain runs them. */
216
+ interface Merged<First extends Contribution, Second extends Contribution> extends Contribution {
217
+ readonly context: First["context"] & Second["context"];
218
+ readonly sent: First["sent"] & Second["sent"];
219
+ readonly clientContext: First["clientContext"] & Second["clientContext"];
220
+ readonly input: First["validates"] extends true ? First["input"] : Second["input"];
221
+ readonly output: Second["validates"] extends true ? Second["output"] : First["output"];
222
+ readonly validates: First["validates"] extends true ? true : Second["validates"];
223
+ }
224
+ /** What one `next(...)` call contributed, from the result it resolved to. */
225
+ type FromNext<Result> = Result extends NextResult<infer Context, infer Sent> ? {
226
+ readonly context: Plain<Context>;
227
+ readonly sent: Plain<Sent>;
228
+ } : never;
229
+ /** The same keys as one object, so a hover shows the context rather than how it was built. */
230
+ type Plain<Value> = { [Key in keyof Value]: Value[Key]; };
231
+ /**
232
+ * What a body contributed, from everything it can return. A branch that
233
+ * answers without calling `next` contributes nothing, and the handler never
234
+ * runs on it, so it is left out rather than widening the rest to nothing.
235
+ */
236
+ type ContributedBy<Result> = [FromNext<Result>] extends [never] ? {
237
+ readonly context: Empty;
238
+ readonly sent: Empty;
239
+ } : FromNext<Result>;
240
+ declare const CONTRIBUTES: unique symbol;
241
+ /**
242
+ * The type-level record a built middleware carries.
243
+ *
244
+ * A METHOD and optional, so it exists in no value and compares bivariantly:
245
+ * one builder implementation serves every state, and what is read back is
246
+ * exact because it is read with `infer`.
247
+ */
248
+ interface Carries<Types extends Contribution> {
249
+ [CONTRIBUTES]?(types: Types): void;
250
+ }
251
+ /** What a middleware contributes, whichever way it was written. */
252
+ type ContributionOf<Step> = Step extends Carries<infer Types> ? Types : Step extends ((next: never) => Promise<infer Result>) ? Merged<NoContribution, NoContribution & Omit<ContributedBy<Result>, never>> extends (infer Out) ? Out extends Contribution ? Out : NoContribution : NoContribution : NoContribution;
253
+ /** What a whole chain contributes, steps in the order they run. */
254
+ type ChainContribution<Chain> = Chain extends readonly [infer Head, ...infer Rest] ? Merged<ContributionOf<Head>, ChainContribution<Rest>> : Chain extends readonly [] ? NoContribution : Chain extends readonly (infer Step)[] ? ContributionOf<Step> : NoContribution;
255
+ /** Where a built middleware is: the chain it declared, and what it adds itself. */
256
+ interface MiddlewareState {
257
+ readonly chain: Contribution;
258
+ readonly own: Contribution;
259
+ }
260
+ interface FreshMiddleware extends MiddlewareState {
261
+ readonly chain: NoContribution;
262
+ readonly own: NoContribution;
263
+ }
264
+ interface WithChain<State extends MiddlewareState, Chain> extends MiddlewareState {
265
+ readonly chain: ChainContribution<Chain>;
266
+ readonly own: State["own"];
267
+ }
268
+ interface OwnReplaced<Own extends Contribution, Context extends object, Sent extends object> extends Contribution {
269
+ readonly context: Context;
270
+ readonly sent: Sent;
271
+ readonly clientContext: Own["clientContext"];
272
+ readonly input: Own["input"];
273
+ readonly output: Own["output"];
274
+ readonly validates: Own["validates"];
275
+ }
276
+ interface WithServer<State extends MiddlewareState, Result> extends MiddlewareState {
277
+ readonly chain: State["chain"];
278
+ readonly own: OwnReplaced<State["own"], ContributedBy<Awaited<Result>>["context"], ContributedBy<Awaited<Result>>["sent"]>;
279
+ }
280
+ interface ClientReplaced<Own extends Contribution, ClientContext extends object> extends Contribution {
281
+ readonly context: Own["context"];
282
+ readonly sent: Own["sent"];
283
+ readonly clientContext: ClientContext;
284
+ readonly input: Own["input"];
285
+ readonly output: Own["output"];
286
+ readonly validates: Own["validates"];
287
+ }
288
+ interface WithClient<State extends MiddlewareState, Result> extends MiddlewareState {
289
+ readonly chain: State["chain"];
290
+ readonly own: ClientReplaced<State["own"], ContributedBy<Awaited<Result>>["context"]>;
291
+ }
292
+ interface ValidatorReplaced<Own extends Contribution, In, Out> extends Contribution {
293
+ readonly context: Own["context"];
294
+ readonly sent: Own["sent"];
295
+ readonly clientContext: Own["clientContext"];
296
+ readonly input: In;
297
+ readonly output: Out;
298
+ readonly validates: true;
299
+ }
300
+ interface WithValidator<State extends MiddlewareState, In, Out> extends MiddlewareState {
301
+ readonly chain: State["chain"];
302
+ readonly own: ValidatorReplaced<State["own"], In, Out>;
303
+ }
304
+ /** What a built middleware contributes: its chain, then itself. */
305
+ type ContributionOfState<State extends MiddlewareState> = Merged<State["chain"], State["own"]>;
306
+ /** The `data` a step is handed: what the nearest validator above it produced. */
307
+ type DataAt<State extends MiddlewareState> = State["own"]["validates"] extends true ? State["own"]["output"] : State["chain"]["validates"] extends true ? State["chain"]["output"] : unknown;
308
+ /**
309
+ * What a built middleware's server half is handed.
310
+ *
311
+ * The OBJECT shape, where a bare `Middleware` closure takes `next` positionally.
312
+ * Both are supported and neither is deprecated: the closure is what a
313
+ * one-line guard writes, and this is what a middleware with a validator, a
314
+ * client half or a `sendContext` needs.
315
+ */
316
+ interface MiddlewareContext<Data = unknown, Context extends object = Empty> {
317
+ readonly next: MiddlewareNext;
318
+ /**
319
+ * The input, as THIS middleware's validator left it.
320
+ *
321
+ * Validators compose along the chain: each one is handed what the one before
322
+ * it returned, and the function's own runs last. That is TanStack's pipeline
323
+ * (`createServerFn.ts:271-274`) and it is what lets a middleware normalise an
324
+ * argument every function under it then receives already normalised.
325
+ */
326
+ readonly data: Data;
327
+ /** What the middlewares outside this one contributed. */
328
+ readonly context: OpenContext<Context>;
329
+ /**
330
+ * What the client halves sent with `next({ sendContext })`, as it came off
331
+ * the wire.
332
+ *
333
+ * UNTRUSTED, and kept apart from `context` for that reason: a caller writes
334
+ * the request body by hand as readily as the stub does, so this is input to
335
+ * check and never a fact to act on. Everything read from `context` was put
336
+ * there by a server step; a value from here joins it only when a server half
337
+ * passes it on with `next({ context })`. Untyped for the same reason: a type
338
+ * here would be a claim about what a stranger sent.
339
+ *
340
+ * Empty in a client half, and for a call made in-process.
341
+ */
342
+ readonly clientContext: Readonly<Record<string, unknown>>;
343
+ readonly signal: AbortSignal;
344
+ /**
345
+ * The request, when this middleware is running for one: as a request
346
+ * middleware, global or on a route. Absent around a server function's own
347
+ * chain, where `getRequest()` is the way to it.
348
+ */
349
+ readonly request?: Request;
350
+ /** The request's path, with any base stripped. Present with `request`. */
351
+ readonly pathname?: string;
352
+ /** What the request is for. Present with `request`. */
353
+ readonly handlerType?: "router" | "serverFn";
354
+ /**
355
+ * The server function this chain is running around, by its id. Absent for a
356
+ * request middleware, and the id is empty for a function that is not mounted.
357
+ */
358
+ readonly serverFnMeta?: {
359
+ readonly id: string;
360
+ };
361
+ /** The method the server function answers. Absent for a request middleware. */
362
+ readonly method?: "GET" | "POST";
363
+ }
364
+ /**
365
+ * What a client half is handed: the caller's raw `data`, since validators run
366
+ * on the server, and a `context` holding what the client halves before it
367
+ * added and, once `next()` has resolved, what the server sent back.
368
+ */
369
+ interface ClientMiddlewareContext<Context extends object = Empty, Sent extends object = Empty> extends MiddlewareContext<unknown, Context & Partial<Sent>> {}
370
+ /** Any server or client half, as the runner calls it. */
371
+ type MiddlewareFn = (context: MiddlewareContext) => unknown;
372
+ /** What a request middleware calls to run the rest of the request. */
373
+ type RequestMiddlewareNext = <Context extends object = Empty>(options?: {
374
+ readonly context?: Context;
375
+ }) => Promise<(Response & NextResult<NoInfer<Context>>) | undefined>;
376
+ /**
377
+ * What a request middleware is handed: the request is always there.
378
+ *
379
+ * `next()` resolves to the response, or `undefined` from a route handler that
380
+ * declined, so the page render answers instead.
381
+ */
382
+ interface RequestMiddlewareContext<Context extends object = Empty> {
383
+ readonly next: RequestMiddlewareNext;
384
+ readonly data: undefined;
385
+ readonly context: OpenContext<Context>;
386
+ readonly clientContext: Readonly<Record<string, unknown>>;
387
+ readonly signal: AbortSignal;
388
+ readonly request: Request;
389
+ readonly pathname: string;
390
+ readonly handlerType: "router" | "serverFn";
391
+ }
392
+ type RequestMiddlewareFn = (context: RequestMiddlewareContext) => unknown;
393
+ /** What a built middleware carries, and what the runner reads off it. */
394
+ interface MiddlewareOptions {
395
+ /**
396
+ * TanStack's two kinds. `"request"` runs for a server request and is handed
397
+ * it; `"function"` runs around a server function and may have a client half.
398
+ * One builder makes both and the runner asks only where a middleware was
399
+ * listed, so the kind decides the TYPES of what `.server` is handed.
400
+ */
401
+ readonly type?: "request" | "function";
402
+ readonly middleware?: readonly Middleware[];
403
+ readonly validator?: Validator<unknown>;
404
+ readonly server?: MiddlewareFn;
405
+ readonly client?: MiddlewareFn;
406
+ }
407
+ /**
408
+ * A middleware with more than a body: a chain of its own, an input validator,
409
+ * and separate halves for the two sides.
410
+ *
411
+ * IT IS STILL A FUNCTION. `Middleware` is a callable and the route-action
412
+ * verifier compares chains with `===`, so making this an object — which is what
413
+ * TanStack's is — would have broken both at once: a route's `middleware: [m]`
414
+ * would no longer typecheck, and every existing bare closure would need
415
+ * wrapping. A callable object is neither: it runs where a closure ran, it
416
+ * compares by identity as a closure did, and `options` is there for the runner
417
+ * that wants more.
418
+ *
419
+ * What each step adds is TYPED: a `.server` that ends in
420
+ * `next({ context: { user } })` hands `user` to every function that lists this
421
+ * middleware, typed as the body wrote it.
422
+ */
423
+ type BuiltMiddleware<State extends MiddlewareState = MiddlewareState> = Middleware & Carries<ContributionOfState<State>> & {
424
+ readonly options: MiddlewareOptions;
425
+ /** Middlewares that run BEFORE this one, flattened into the chain that uses it. */
426
+ middleware<const Chain extends readonly Middleware[]>(chain: Chain): BuiltMiddleware<WithChain<State, Chain>>;
427
+ /**
428
+ * Validates and narrows the input every step after this one is handed. The
429
+ * schema form is tried first: an arktype type is callable as well, and read
430
+ * as a function its declared input would be lost.
431
+ */
432
+ validator<Schema extends StandardSchemaLike>(schema: Schema): BuiltMiddleware<WithValidator<State, StandardInput<Schema>, StandardOutput<Schema>>>;
433
+ validator<In, Out>(validate: (input: In) => Out): BuiltMiddleware<WithValidator<State, In, Awaited<Out>>>;
434
+ validator<In, Out>(schema: {
435
+ readonly parse: (input: In) => Out;
436
+ }): BuiltMiddleware<WithValidator<State, In, Awaited<Out>>>;
437
+ validator(unchecked: "unchecked"): BuiltMiddleware<WithValidator<State, unknown, unknown>>;
438
+ /** `validator` under the name TanStack's release candidates used. */
439
+ inputValidator<Schema extends StandardSchemaLike>(schema: Schema): BuiltMiddleware<WithValidator<State, StandardInput<Schema>, StandardOutput<Schema>>>;
440
+ inputValidator<In, Out>(validate: (input: In) => Out): BuiltMiddleware<WithValidator<State, In, Awaited<Out>>>;
441
+ inputValidator<In, Out>(schema: {
442
+ readonly parse: (input: In) => Out;
443
+ }): BuiltMiddleware<WithValidator<State, In, Awaited<Out>>>;
444
+ inputValidator(unchecked: "unchecked"): BuiltMiddleware<WithValidator<State, unknown, unknown>>;
445
+ /** The half that runs on the server, where the handler is. */
446
+ server<Result>(fn: (context: MiddlewareContext<DataAt<State>, State["chain"]["context"]>) => Result): BuiltMiddleware<WithServer<State, Result>>;
447
+ /**
448
+ * The half that runs in the BROWSER, around the fetch.
449
+ *
450
+ * `next({ sendContext })` from here is what travels to the server half as
451
+ * `clientContext`. The compiler carries this into the client stub and leaves
452
+ * the server half behind, so a middleware may hold both without either
453
+ * reaching the wrong bundle.
454
+ */
455
+ client<Result>(fn: (context: ClientMiddlewareContext<State["chain"]["clientContext"], State["chain"]["sent"]>) => Result): BuiltMiddleware<WithClient<State, Result>>;
456
+ };
457
+ /**
458
+ * The two brands a thrown redirect and a thrown `notFound()` carry.
459
+ *
460
+ * DECLARED TWICE ON PURPOSE. The classes live in `@barqjs/router`, which this
461
+ * package must not import: the dependency runs router -> start and start is an
462
+ * OPTIONAL peer of it, so an import here would be a cycle and would break the
463
+ * router for anyone using it without server functions. `Symbol.for` is the
464
+ * global registry, so both declarations name the same symbol with no edge
465
+ * between the packages — `SERVER_FN` in `client.ts` already works this way. The other
466
+ * declaration is `REDIRECT` / `NOT_FOUND` in `packages/router/src/errors.ts`,
467
+ * and `server.test.ts` checks the two agree.
468
+ */
469
+ declare const REDIRECT: unique symbol;
470
+ declare const NOT_FOUND: unique symbol;
471
+ /** Whether a middleware was built by {@link createMiddleware}. */
472
+ declare function isBuiltMiddleware(value: Middleware): value is BuiltMiddleware;
473
+ /**
474
+ * Author a middleware that is more than one closure.
475
+ *
476
+ * `createMiddleware().server(async ({ next, context }) => next({ context: … }))`
477
+ * is the ordinary shape, and it is what a bare closure already did. What the
478
+ * builder adds is the three things a closure has nowhere to put: a chain of its
479
+ * own, an input validator, and a client half.
480
+ *
481
+ * EACH CALL RETURNS A NEW MIDDLEWARE, and the exported one is the last. That
482
+ * matters because the verifier compares by identity: a builder that mutated and
483
+ * returned itself would make every intermediate the same object as the final
484
+ * one, which is harmless, and one that shared its options object across
485
+ * branches — which TanStack's does — would make two middlewares built from one
486
+ * base overwrite each other. Neither is a risk worth carrying for an allocation.
487
+ */
488
+ declare function createMiddleware(options: MiddlewareOptions & {
489
+ readonly type: "request";
490
+ }): RequestMiddleware<FreshMiddleware>;
491
+ declare function createMiddleware(options?: MiddlewareOptions): BuiltMiddleware<FreshMiddleware>;
492
+ /**
493
+ * A middleware built with `type: "request"`: a chain of its own and a server
494
+ * body that is always handed the request. It is a {@link BuiltMiddleware}
495
+ * underneath, so it goes wherever a `Middleware` does, and what its body passes
496
+ * to `next({ context })` is typed into everything after it.
497
+ */
498
+ type RequestMiddleware<State extends MiddlewareState = MiddlewareState> = Middleware & Carries<ContributionOfState<State>> & {
499
+ readonly options: MiddlewareOptions;
500
+ middleware<const Chain extends readonly Middleware[]>(chain: Chain): RequestMiddleware<WithChain<State, Chain>>;
501
+ server<Result>(fn: (context: RequestMiddlewareContext<State["chain"]["context"]>) => Result): RequestMiddleware<WithServer<State, NonNullable<Awaited<Result>>>>;
502
+ };
503
+ /** Where a request middleware chain is running. */
504
+ interface RequestMiddlewareStart {
505
+ readonly request: Request;
506
+ readonly pathname: string;
507
+ readonly handlerType: "router" | "serverFn";
508
+ /** What the chain has produced so far; mutated as it unwinds inward. */
509
+ readonly context: Record<string, unknown>;
510
+ }
511
+ /**
512
+ * Run a chain of request middleware around `run`.
513
+ *
514
+ * `next()` resolves to whatever is inside: the response, or `undefined` from a
515
+ * route handler that declined. A middleware answers with what it returns, so
516
+ * one that returns `next()` passes the answer through and one that returns a
517
+ * `Response` of its own replaces it.
518
+ */
519
+ declare function runRequestMiddleware<T>(chain: readonly Middleware[], start: RequestMiddlewareStart, run: () => Promise<T>): Promise<T>;
520
+ /**
521
+ * The chain a middleware list really is: every nested chain spliced in ahead of
522
+ * the middleware that declared it, each step once.
523
+ *
524
+ * Depth-first and parents-first, which is TanStack's `flattenMiddlewares` and
525
+ * the only order that means anything — a middleware declares a chain because it
526
+ * DEPENDS on it, so those steps have to have run by the time it does.
527
+ *
528
+ * Deduplicated by IDENTITY, so two middlewares that both depend on
529
+ * `requireSession` do not authenticate twice. That is also what keeps the
530
+ * route-action verifier honest: it asks whether a function's flattened chain
531
+ * contains the route's steps, and a step reached through a nest counts.
532
+ */
533
+ declare function flattenMiddleware(chain: readonly Middleware[], depth?: number): readonly Middleware[];
534
+ /** One validator, applied. `"unchecked"` and absence both pass the value through. */
535
+ declare function applyValidator(validator: Validator<unknown> | undefined, raw: unknown): Promise<unknown>;
536
+ /**
537
+ * Run a flattened chain, then the innermost work.
538
+ *
539
+ * ONE RUNNER FOR BOTH SIDES, and `half` is which of a built middleware's two
540
+ * bodies to call. A bare closure has neither and is invoked positionally, which
541
+ * is what it has always been — so a chain may mix the two spellings and the
542
+ * order is the order it was written in.
543
+ *
544
+ * A middleware that declares no half for THIS side is skipped rather than
545
+ * refused: a `.server(...)`-only middleware is transparent in the browser, and
546
+ * a `.client(...)`-only one is transparent on the server. That is what makes
547
+ * one exported middleware usable from a route and a server function alike.
548
+ */
549
+ declare function runMiddleware(chain: readonly Middleware[], half: "server" | "client", start: {
550
+ readonly data: unknown;
551
+ readonly signal: AbortSignal;
552
+ /** What the chain has produced so far; mutated as the chain unwinds inward. */
553
+ readonly context: Record<string, unknown>;
554
+ /** What the client halves sent, on the server. Never merged into `context`. */
555
+ readonly clientContext?: Record<string, unknown>;
556
+ /** What travels back to the caller. */
557
+ readonly sendContext: Record<string, unknown>;
558
+ /** Where a client half's `next({ headers })` collects. Absent on the server. */
559
+ readonly headers?: Headers;
560
+ /** Where a client half's `next({ fetch })` lands. Absent on the server. */
561
+ readonly fetch?: {
562
+ current: typeof fetch | undefined;
563
+ };
564
+ /** The function the chain is running around. */
565
+ readonly meta?: {
566
+ readonly id: string;
567
+ };
568
+ /** The method that function answers. */
569
+ readonly method?: "GET" | "POST";
570
+ /** The innermost work: the handler on the server, the fetch on the client. */
571
+ readonly run: (data: unknown) => Promise<unknown>;
572
+ }): Promise<unknown>;
573
+ export { runMiddleware as $, RequestMiddleware as A, ValidationError as B, NextOptions as C, OwnReplaced as D, OpenContext as E, StandardInput as F, WithClient as G, ValidatorInput as H, StandardOutput as I, applyValidator as J, WithServer as K, StandardSchema as L, RequestMiddlewareFn as M, RequestMiddlewareNext as N, Plain as O, RequestMiddlewareStart as P, isInputError as Q, StandardSchemaLike as R, NOT_FOUND as S, NoContribution as T, ValidatorReplaced as U, Validator as V, WithChain as W, flattenMiddleware as X, createMiddleware as Y, isBuiltMiddleware as Z, MiddlewareContext as _, ClientReplaced as a, MiddlewareOptions as b, ContributionOf as c, Empty as d, runRequestMiddleware as et, FreshMiddleware as f, Middleware as g, Merged as h, ClientMiddlewareContext as i, RequestMiddlewareContext as j, REDIRECT as k, ContributionOfState as l, InputError as m, Carries as n, ContributedBy as o, FromNext as p, WithValidator as q, ChainContribution as r, Contribution as s, BuiltMiddleware as t, toValidator as tt, DataAt as u, MiddlewareFn as v, NextResult as w, MiddlewareState as x, MiddlewareNext as y, UncheckedInputError as z };
574
+ //# sourceMappingURL=middleware-B-tI8QHQ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware-B-tI8QHQ.d.ts","names":[],"sources":["../src/middleware.ts"],"mappings":";;;;;;;;;;;;;;;;;;UAmBiB,eAAe,cAAc,MAAM;EAClD;IACE;IACA;IACA,WACE;MAEI,OAAO;;MACP,QAAQ;QACV;MAAU,OAAO;;MAAU,QAAQ;;;aAE9B;eAAmB,OAAO;eAAa,QAAQ;;;;;UAK3C;WACN;aAAwB,WAAW;;;;KAIlC,cAAc,WAAW,YAAY;WAA6B,aAAa;KACvF;;KAIQ,eAAe,WAAW,YAAY;WAA6B,cAAc;KACzF,MACA;WAA0B;aAAwB,WAAW,yBAAyB;;IACpF,UAAU,QAAQ;;KAInB,YAAY,UAAU;WAA0B,mBAAmB;0BAC9C,OACpB,YAAY,qBAAqB;KAIlC,UAAU,UAAU;WAA0B,aAAa;IAAQ;;;;;;;;;;KAW5D,UAAU,KAAK,wBAAwB;;;;;;;;KASvC,eAAe,KACvB,UAAU,OACR,mBAAmB,IAAI,QAAQ;WACtB,QAAQ,mBAAmB,IAAI,QAAQ;;;iBAGtC,YAAY,GAAG,OAAO,eAAe,KAAK,UAAU;cA2B9D;;;;;;cAOO,mBAAmB;;;;;;YAMpB;;;iBAII,aAAa,iBAAiB,SAAS;cAQ1C,wBAAwB;WAC1B,QAAQ;EACjB,YAAY,QAAQ;;;cAWT,4BAA4B;EACvC;;;KAUU;;;;;KAMA,YAAY,wBAAwB,QAAQ;cAE1C;;;;;;;;UASG,WAAW,yBAAyB,OAAO,sBAAsB;YACtE;aAAkB,SAAS;aAAk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B,cACtC,OAAO,QACN,kBAAkB,UAAU,OAAO;EACtC,OAAO,QACL,KAAK,SAAS,yBAAyB,+BAA+B,SACrE,kBAAkB,WAAW,OAAO,YAAY,QAAQ;;;UAI9C;WACN,SAAS;WACT;WACA;;WAEA,SAAS;;;;;;;;;;iBAWE,qBAAqB,GACzC,gBAAgB,cAChB,OAAO,wBACP,WAAW,QAAQ,KAClB,QAAQ;;;;;;;;;;;;;;iBAuDK,kBAAkB,gBAAgB,cAAc,0BAAqB;;iBAuB/D,eACpB,WAAW,gCACX,eACC;;;;;;;;;;;;;;iBAoBmB,cACpB,gBAAgB,cAChB,2BACA;WACW;WACA,QAAQ;;WAER,SAAS;;WAET,gBAAgB;;WAEhB,aAAa;;WAEb,UAAU;;WAEV;IAAU,gBAAgB;;;WAE1B;aAAkB;;;WAElB;;WAEA,MAAM,kBAAkB;IAElC"}
@@ -0,0 +1,2 @@
1
+ import { $ as runMiddleware, A as RequestMiddleware, B as ValidationError, C as NextOptions, D as OwnReplaced, E as OpenContext, F as StandardInput, G as WithClient, H as ValidatorInput, I as StandardOutput, J as applyValidator, K as WithServer, L as StandardSchema, M as RequestMiddlewareFn, N as RequestMiddlewareNext, O as Plain, P as RequestMiddlewareStart, Q as isInputError, R as StandardSchemaLike, S as NOT_FOUND, T as NoContribution, U as ValidatorReplaced, V as Validator, W as WithChain, X as flattenMiddleware, Y as createMiddleware, Z as isBuiltMiddleware, _ as MiddlewareContext, a as ClientReplaced, b as MiddlewareOptions, c as ContributionOf, d as Empty, et as runRequestMiddleware, f as FreshMiddleware, g as Middleware, h as Merged, i as ClientMiddlewareContext, j as RequestMiddlewareContext, k as REDIRECT, l as ContributionOfState, m as InputError, n as Carries, o as ContributedBy, p as FromNext, q as WithValidator, r as ChainContribution, s as Contribution, t as BuiltMiddleware, tt as toValidator, u as DataAt, v as MiddlewareFn, w as NextResult, x as MiddlewareState, y as MiddlewareNext, z as UncheckedInputError } from "./middleware-B-tI8QHQ.js";
2
+ export { BuiltMiddleware, Carries, ChainContribution, ClientMiddlewareContext, ClientReplaced, ContributedBy, Contribution, ContributionOf, ContributionOfState, DataAt, Empty, FreshMiddleware, FromNext, InputError, Merged, Middleware, MiddlewareContext, MiddlewareFn, MiddlewareNext, MiddlewareOptions, MiddlewareState, NOT_FOUND, NextOptions, NextResult, NoContribution, OpenContext, OwnReplaced, Plain, REDIRECT, RequestMiddleware, RequestMiddlewareContext, RequestMiddlewareFn, RequestMiddlewareNext, RequestMiddlewareStart, StandardInput, StandardOutput, StandardSchema, StandardSchemaLike, UncheckedInputError, ValidationError, Validator, ValidatorInput, ValidatorReplaced, WithChain, WithClient, WithServer, WithValidator, applyValidator, createMiddleware, flattenMiddleware, isBuiltMiddleware, isInputError, runMiddleware, runRequestMiddleware, toValidator };