@fragno-dev/core 0.0.5 → 0.0.7
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/.turbo/turbo-build.log +47 -55
- package/.turbo/turbo-test.log +297 -0
- package/CHANGELOG.md +15 -0
- package/dist/api/api.d.ts +1 -1
- package/dist/api/api.js +1 -1
- package/dist/{api-CBDGZiLC.d.ts → api-CAPyac52.d.ts} +3 -3
- package/dist/api-CAPyac52.d.ts.map +1 -0
- package/dist/{api-DgHfYjq2.js → api-DuzjjCT4.js} +2 -2
- package/dist/{api-DgHfYjq2.js.map → api-DuzjjCT4.js.map} +1 -1
- package/dist/client/client.d.ts +2 -2
- package/dist/client/client.js +4 -4
- package/dist/client/client.svelte.d.ts +14 -14
- package/dist/client/client.svelte.d.ts.map +1 -1
- package/dist/client/client.svelte.js +4 -4
- package/dist/client/react.d.ts +12 -12
- package/dist/client/react.d.ts.map +1 -1
- package/dist/client/react.js +6 -8
- package/dist/client/react.js.map +1 -1
- package/dist/client/solid.d.ts +45 -0
- package/dist/client/solid.d.ts.map +1 -0
- package/dist/client/solid.js +110 -0
- package/dist/client/solid.js.map +1 -0
- package/dist/client/vanilla.d.ts +21 -21
- package/dist/client/vanilla.d.ts.map +1 -1
- package/dist/client/vanilla.js +4 -4
- package/dist/client/vue.d.ts +14 -14
- package/dist/client/vue.d.ts.map +1 -1
- package/dist/client/vue.js +4 -4
- package/dist/{client-Cf53QR-z.js → client-C_Oc8hpD.js} +7 -10
- package/dist/{client-Cf53QR-z.js.map → client-C_Oc8hpD.js.map} +1 -1
- package/dist/client-DdpPMlXL.d.ts +338 -0
- package/dist/client-DdpPMlXL.d.ts.map +1 -0
- package/dist/integrations/react-ssr.js +1 -1
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +44 -6
- package/dist/mod.js.map +1 -1
- package/dist/{route-Bp6eByhz.js → route-Dq62lXqB.js} +6 -6
- package/dist/route-Dq62lXqB.js.map +1 -0
- package/dist/{ssr-B9TeIF01.js → ssr-BAhbA_3q.js} +2 -2
- package/dist/{ssr-B9TeIF01.js.map → ssr-BAhbA_3q.js.map} +1 -1
- package/package.json +21 -22
- package/src/api/fragment.ts +90 -13
- package/src/api/request-middleware.test.ts +3 -3
- package/src/api/request-output-context.ts +3 -3
- package/src/api/route.ts +1 -8
- package/src/client/client-error.test.ts +17 -1
- package/src/client/solid.test.ts +840 -0
- package/src/client/solid.ts +261 -0
- package/tsdown.config.ts +1 -0
- package/vitest.config.ts +10 -7
- package/dist/api-CBDGZiLC.d.ts.map +0 -1
- package/dist/client-XFdAy-IQ.d.ts +0 -287
- package/dist/client-XFdAy-IQ.d.ts.map +0 -1
- package/dist/integrations/astro.d.ts +0 -18
- package/dist/integrations/astro.d.ts.map +0 -1
- package/dist/integrations/astro.js +0 -16
- package/dist/integrations/astro.js.map +0 -1
- package/dist/integrations/next-js.d.ts +0 -15
- package/dist/integrations/next-js.d.ts.map +0 -1
- package/dist/integrations/next-js.js +0 -17
- package/dist/integrations/next-js.js.map +0 -1
- package/dist/integrations/svelte-kit.d.ts +0 -21
- package/dist/integrations/svelte-kit.d.ts.map +0 -1
- package/dist/integrations/svelte-kit.js +0 -18
- package/dist/integrations/svelte-kit.js.map +0 -1
- package/dist/route-Bp6eByhz.js.map +0 -1
- package/src/integrations/astro.ts +0 -17
- package/src/integrations/next-js.ts +0 -31
- package/src/integrations/svelte-kit.ts +0 -41
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { c as OutputContext, d as RequestBodyType, l as InferOr, m as MaybeExtractPathParamsOrWiden, n as HTTPMethod, r as NonGetHTTPMethod, t as FragnoRouteConfig, u as StatusCode } from "./api-CAPyac52.js";
|
|
2
|
+
import { ReadableAtom, Store } from "nanostores";
|
|
3
|
+
import { FetcherStore, MutatorStore } from "@nanostores/query";
|
|
4
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
|
+
|
|
6
|
+
//#region src/api/route.d.ts
|
|
7
|
+
type AnyFragnoRouteConfig = FragnoRouteConfig<HTTPMethod, string, any, any, any, any>;
|
|
8
|
+
interface RouteFactoryContext<TConfig, TDeps, TServices> {
|
|
9
|
+
config: TConfig;
|
|
10
|
+
deps: TDeps;
|
|
11
|
+
services: TServices;
|
|
12
|
+
}
|
|
13
|
+
type RouteFactory<TConfig, TDeps, TServices, TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> = (context: RouteFactoryContext<TConfig, TDeps, TServices>) => TRoutes$1;
|
|
14
|
+
type AnyRouteOrFactory = AnyFragnoRouteConfig | RouteFactory<any, any, any, any>;
|
|
15
|
+
type FlattenRouteFactories<T$1 extends readonly AnyRouteOrFactory[]> = T$1 extends readonly [infer First, ...infer Rest extends readonly AnyRouteOrFactory[]] ? First extends RouteFactory<any, any, any, infer TRoutes> ? [...TRoutes, ...FlattenRouteFactories<Rest>] : [First, ...FlattenRouteFactories<Rest>] : [];
|
|
16
|
+
declare function defineRoute<const TMethod$1 extends HTTPMethod, const TPath$1 extends string, const TOutputSchema extends StandardSchemaV1 | undefined, const TErrorCode extends string = string, const TQueryParameters extends string = string>(config: FragnoRouteConfig<TMethod$1, TPath$1, undefined, TOutputSchema, TErrorCode, TQueryParameters> & {
|
|
17
|
+
inputSchema?: undefined;
|
|
18
|
+
}): FragnoRouteConfig<TMethod$1, TPath$1, undefined, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
19
|
+
declare function defineRoute<const TMethod$1 extends HTTPMethod, const TPath$1 extends string, const TInputSchema extends StandardSchemaV1, const TOutputSchema extends StandardSchemaV1 | undefined, const TErrorCode extends string = string, const TQueryParameters extends string = string>(config: FragnoRouteConfig<TMethod$1, TPath$1, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters> & {
|
|
20
|
+
inputSchema: TInputSchema;
|
|
21
|
+
}): FragnoRouteConfig<TMethod$1, TPath$1, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
22
|
+
declare function defineRoutes<TConfig = {}, TDeps = {}, TServices = {}>(): {
|
|
23
|
+
create: <const TRoutes extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]>(fn: (context: RouteFactoryContext<TConfig, TDeps, TServices>) => TRoutes) => RouteFactory<TConfig, TDeps, TServices, TRoutes>;
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/api/request-middleware.d.ts
|
|
27
|
+
type FragnoMiddlewareCallback<TRoutes$1 extends readonly AnyFragnoRouteConfig[], TDeps, TServices extends Record<string, unknown>> = (inputContext: RequestMiddlewareInputContext<TRoutes$1>, outputContext: RequestMiddlewareOutputContext<TDeps, TServices>) => Promise<Response | undefined> | Response | undefined;
|
|
28
|
+
interface RequestMiddlewareOptions {
|
|
29
|
+
path: string;
|
|
30
|
+
method: HTTPMethod;
|
|
31
|
+
pathParams?: Record<string, string>;
|
|
32
|
+
searchParams: URLSearchParams;
|
|
33
|
+
body: RequestBodyType;
|
|
34
|
+
request: Request;
|
|
35
|
+
}
|
|
36
|
+
declare class RequestMiddlewareOutputContext<const TDeps, const TServices extends Record<string, unknown>> extends OutputContext<unknown, string> {
|
|
37
|
+
#private;
|
|
38
|
+
constructor(deps: TDeps, services: TServices);
|
|
39
|
+
get deps(): TDeps;
|
|
40
|
+
get services(): TServices;
|
|
41
|
+
}
|
|
42
|
+
declare class RequestMiddlewareInputContext<const TRoutes$1 extends readonly AnyFragnoRouteConfig[]> {
|
|
43
|
+
#private;
|
|
44
|
+
constructor(routes: TRoutes$1, options: RequestMiddlewareOptions);
|
|
45
|
+
get path(): string;
|
|
46
|
+
get method(): HTTPMethod;
|
|
47
|
+
get pathParams(): Record<string, string>;
|
|
48
|
+
get queryParams(): URLSearchParams;
|
|
49
|
+
get inputSchema(): StandardSchemaV1 | undefined;
|
|
50
|
+
get outputSchema(): StandardSchemaV1 | undefined;
|
|
51
|
+
ifMatchesRoute: <const TMethod extends HTTPMethod, const TPath extends ExtractRoutePath<TRoutes$1>, const TRoute extends ExtractRouteByPath<TRoutes$1, TPath, TMethod> = ExtractRouteByPath<TRoutes$1, TPath, TMethod>>(method: TMethod, path: TPath, handler: (...args: Parameters<TRoute["handler"]>) => Promise<Response | undefined | void> | Response | undefined | void) => Promise<Response | undefined>;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/api/fragment.d.ts
|
|
55
|
+
interface FragnoPublicConfig {
|
|
56
|
+
mountRoute?: string;
|
|
57
|
+
}
|
|
58
|
+
interface FragnoPublicClientConfig {
|
|
59
|
+
mountRoute?: string;
|
|
60
|
+
baseUrl?: string;
|
|
61
|
+
}
|
|
62
|
+
type AstroHandlers = {
|
|
63
|
+
ALL: (req: Request) => Promise<Response>;
|
|
64
|
+
};
|
|
65
|
+
type ReactRouterHandlers = {
|
|
66
|
+
loader: (args: {
|
|
67
|
+
request: Request;
|
|
68
|
+
}) => Promise<Response>;
|
|
69
|
+
action: (args: {
|
|
70
|
+
request: Request;
|
|
71
|
+
}) => Promise<Response>;
|
|
72
|
+
};
|
|
73
|
+
type SolidStartHandlers = {
|
|
74
|
+
GET: (args: {
|
|
75
|
+
request: Request;
|
|
76
|
+
}) => Promise<Response>;
|
|
77
|
+
POST: (args: {
|
|
78
|
+
request: Request;
|
|
79
|
+
}) => Promise<Response>;
|
|
80
|
+
PUT: (args: {
|
|
81
|
+
request: Request;
|
|
82
|
+
}) => Promise<Response>;
|
|
83
|
+
DELETE: (args: {
|
|
84
|
+
request: Request;
|
|
85
|
+
}) => Promise<Response>;
|
|
86
|
+
PATCH: (args: {
|
|
87
|
+
request: Request;
|
|
88
|
+
}) => Promise<Response>;
|
|
89
|
+
HEAD: (args: {
|
|
90
|
+
request: Request;
|
|
91
|
+
}) => Promise<Response>;
|
|
92
|
+
OPTIONS: (args: {
|
|
93
|
+
request: Request;
|
|
94
|
+
}) => Promise<Response>;
|
|
95
|
+
};
|
|
96
|
+
type StandardHandlers = {
|
|
97
|
+
GET: (req: Request) => Promise<Response>;
|
|
98
|
+
POST: (req: Request) => Promise<Response>;
|
|
99
|
+
PUT: (req: Request) => Promise<Response>;
|
|
100
|
+
DELETE: (req: Request) => Promise<Response>;
|
|
101
|
+
PATCH: (req: Request) => Promise<Response>;
|
|
102
|
+
HEAD: (req: Request) => Promise<Response>;
|
|
103
|
+
OPTIONS: (req: Request) => Promise<Response>;
|
|
104
|
+
};
|
|
105
|
+
type HandlersByFramework = {
|
|
106
|
+
astro: AstroHandlers;
|
|
107
|
+
"react-router": ReactRouterHandlers;
|
|
108
|
+
"next-js": StandardHandlers;
|
|
109
|
+
"svelte-kit": StandardHandlers;
|
|
110
|
+
"solid-start": SolidStartHandlers;
|
|
111
|
+
};
|
|
112
|
+
type FullstackFrameworks = keyof HandlersByFramework;
|
|
113
|
+
interface FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRouteConfig[] = [], TDeps = {}, TServices extends Record<string, unknown> = Record<string, unknown>> {
|
|
114
|
+
config: FragnoFragmentSharedConfig<TRoutes$1>;
|
|
115
|
+
deps: TDeps;
|
|
116
|
+
services: TServices;
|
|
117
|
+
handlersFor: <T extends FullstackFrameworks>(framework: T) => HandlersByFramework[T];
|
|
118
|
+
handler: (req: Request) => Promise<Response>;
|
|
119
|
+
mountRoute: string;
|
|
120
|
+
withMiddleware: (handler: FragnoMiddlewareCallback<TRoutes$1, TDeps, TServices>) => FragnoInstantiatedFragment<TRoutes$1, TDeps, TServices>;
|
|
121
|
+
}
|
|
122
|
+
interface FragnoFragmentSharedConfig<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> {
|
|
123
|
+
name: string;
|
|
124
|
+
routes: TRoutes$1;
|
|
125
|
+
}
|
|
126
|
+
interface FragmentDefinition<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {
|
|
127
|
+
name: string;
|
|
128
|
+
dependencies?: (config: TConfig) => TDeps;
|
|
129
|
+
services?: (config: TConfig, deps: TDeps) => TServices;
|
|
130
|
+
}
|
|
131
|
+
declare class FragmentBuilder<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {
|
|
132
|
+
#private;
|
|
133
|
+
constructor(definition: FragmentDefinition<TConfig, TDeps, TServices>);
|
|
134
|
+
get definition(): FragmentDefinition<TConfig, TDeps, TServices>;
|
|
135
|
+
withDependencies<TNewDeps>(fn: (config: TConfig) => TNewDeps): FragmentBuilder<TConfig, TNewDeps, TServices>;
|
|
136
|
+
withServices<TNewServices extends Record<string, unknown>>(fn: (config: TConfig, deps: TDeps) => TNewServices): FragmentBuilder<TConfig, TDeps, TNewServices>;
|
|
137
|
+
}
|
|
138
|
+
declare function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig>;
|
|
139
|
+
declare function createFragment<TConfig, TDeps, TServices extends Record<string, unknown>, const TRoutesOrFactories extends readonly AnyRouteOrFactory[]>(fragmentDefinition: FragmentBuilder<TConfig, TDeps, TServices>, config: TConfig, routesOrFactories: TRoutesOrFactories, fragnoConfig?: FragnoPublicConfig): FragnoInstantiatedFragment<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices>;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/client/client-error.d.ts
|
|
142
|
+
type FragnoErrorOptions = {
|
|
143
|
+
cause?: Error | unknown;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Base error class for all Fragno client errors.
|
|
147
|
+
*/
|
|
148
|
+
declare abstract class FragnoClientError<TCode extends string = string> extends Error {
|
|
149
|
+
#private;
|
|
150
|
+
constructor(message: string, code: TCode, options?: FragnoErrorOptions);
|
|
151
|
+
get code(): TCode | (string & {});
|
|
152
|
+
}
|
|
153
|
+
declare class FragnoClientFetchError extends FragnoClientError<"NO_BODY" | "NETWORK_ERROR" | "ABORT_ERROR"> {
|
|
154
|
+
constructor(message: string, code: "NO_BODY" | "NETWORK_ERROR" | "ABORT_ERROR", options?: FragnoErrorOptions);
|
|
155
|
+
static fromUnknownFetchError(error: unknown): FragnoClientFetchError;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Error thrown when a network request fails (e.g., no internet connection, DNS failure).
|
|
159
|
+
*/
|
|
160
|
+
declare class FragnoClientFetchNetworkError extends FragnoClientFetchError {
|
|
161
|
+
constructor(message?: string, options?: FragnoErrorOptions);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Error thrown when a request is aborted (e.g., user cancels request, timeout).
|
|
165
|
+
*/
|
|
166
|
+
declare class FragnoClientFetchAbortError extends FragnoClientFetchError {
|
|
167
|
+
constructor(message?: string, options?: FragnoErrorOptions);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Error thrown when the API result is unexpected, e.g. no json is returned.
|
|
171
|
+
*/
|
|
172
|
+
declare class FragnoClientUnknownApiError extends FragnoClientError<"UNKNOWN_API_ERROR"> {
|
|
173
|
+
#private;
|
|
174
|
+
constructor(message: string | undefined, status: StatusCode, options?: FragnoErrorOptions);
|
|
175
|
+
get status(): StatusCode;
|
|
176
|
+
}
|
|
177
|
+
declare class FragnoClientApiError<TErrorCode extends string = string> extends FragnoClientError<TErrorCode> {
|
|
178
|
+
#private;
|
|
179
|
+
constructor({
|
|
180
|
+
message,
|
|
181
|
+
code
|
|
182
|
+
}: {
|
|
183
|
+
message: string;
|
|
184
|
+
code: TErrorCode;
|
|
185
|
+
}, status: StatusCode, options?: FragnoErrorOptions);
|
|
186
|
+
get status(): StatusCode;
|
|
187
|
+
/**
|
|
188
|
+
* The error code returned by the API.
|
|
189
|
+
*
|
|
190
|
+
* The type is `TErrorCode` (the set of known error codes for this route), but may also be a string
|
|
191
|
+
* for forward compatibility with future error codes.
|
|
192
|
+
*/
|
|
193
|
+
get code(): TErrorCode | (string & {});
|
|
194
|
+
static fromResponse<TErrorCode extends string = string>(response: Response): Promise<FragnoClientApiError<TErrorCode> | FragnoClientUnknownApiError>;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/client/client.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* Symbols used to identify hook types
|
|
200
|
+
*/
|
|
201
|
+
declare const GET_HOOK_SYMBOL: unique symbol;
|
|
202
|
+
declare const MUTATOR_HOOK_SYMBOL: unique symbol;
|
|
203
|
+
declare const STORE_SYMBOL: unique symbol;
|
|
204
|
+
/**
|
|
205
|
+
* Extract only GET routes from a library config's routes array
|
|
206
|
+
*/
|
|
207
|
+
type ExtractGetRoutes<T$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> = { [K in keyof T$1]: T$1[K] extends FragnoRouteConfig<infer Method, infer Path, infer Input, infer Output, infer ErrorCode, infer QueryParams> ? Method extends "GET" ? FragnoRouteConfig<Method, Path, Input, Output, ErrorCode, QueryParams> : never : never }[number][];
|
|
208
|
+
/**
|
|
209
|
+
* Extract the path from a route configuration for a given method
|
|
210
|
+
*/
|
|
211
|
+
type ExtractRoutePath<T$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[], TExpectedMethod extends HTTPMethod = HTTPMethod> = { [K in keyof T$1]: T$1[K] extends FragnoRouteConfig<infer Method, infer Path, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string> ? Method extends TExpectedMethod ? Path : never : never }[number];
|
|
212
|
+
type ExtractGetRoutePaths<T$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> = ExtractRoutePath<T$1, "GET">;
|
|
213
|
+
type ExtractNonGetRoutePaths<T$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> = ExtractRoutePath<T$1, NonGetHTTPMethod>;
|
|
214
|
+
/**
|
|
215
|
+
* Extract the route configuration type(s) for a given path from a routes array.
|
|
216
|
+
* Optionally narrow by HTTP method via the third type parameter.
|
|
217
|
+
*
|
|
218
|
+
* Defaults to extracting all methods for the matching path, producing a union
|
|
219
|
+
* if multiple methods exist for the same path.
|
|
220
|
+
*/
|
|
221
|
+
type ExtractRouteByPath<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[], TPath$1 extends string, TMethod$1 extends HTTPMethod = HTTPMethod> = { [K in keyof TRoutes$1]: TRoutes$1[K] extends FragnoRouteConfig<infer M, TPath$1, infer Input, infer Output, infer ErrorCode, infer QueryParams> ? M extends TMethod$1 ? FragnoRouteConfig<M, TPath$1, Input, Output, ErrorCode, QueryParams> : never : never }[number];
|
|
222
|
+
/**
|
|
223
|
+
* Extract the output schema type for a specific route path from a routes array
|
|
224
|
+
*/
|
|
225
|
+
type ExtractOutputSchemaForPath<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined>[], TPath$1 extends string> = { [K in keyof TRoutes$1]: TRoutes$1[K] extends FragnoRouteConfig<infer Method, TPath$1, StandardSchemaV1 | undefined, infer Output> ? Method extends "GET" ? Output : never : never }[number];
|
|
226
|
+
/**
|
|
227
|
+
* Check if a path exists as a GET route in the routes array
|
|
228
|
+
*/
|
|
229
|
+
type IsValidGetRoutePath<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[], TPath$1 extends string> = TPath$1 extends ExtractGetRoutePaths<TRoutes$1> ? true : false;
|
|
230
|
+
/**
|
|
231
|
+
* Utility type to ensure only valid GET route paths can be used
|
|
232
|
+
*/
|
|
233
|
+
type ValidateGetRoutePath<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[], TPath$1 extends string> = TPath$1 extends ExtractGetRoutePaths<TRoutes$1> ? TPath$1 : `Error: Path '${TPath$1}' is not a valid GET route. Available GET routes: ${ExtractGetRoutePaths<TRoutes$1>}`;
|
|
234
|
+
/**
|
|
235
|
+
* Helper type to check if a routes array has any GET routes
|
|
236
|
+
*/
|
|
237
|
+
type HasGetRoutes<T$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> = ExtractGetRoutePaths<T$1> extends never ? false : true;
|
|
238
|
+
type ObjectContainingStoreField<T$1 extends object> = T$1 extends Store ? T$1 : { [K in keyof T$1]: T$1[K] extends Store ? { [P in K]: T$1[P] } & Partial<Omit<T$1, K>> : never }[keyof T$1] extends never ? never : T$1;
|
|
239
|
+
type FragnoStoreData<T$1 extends object> = {
|
|
240
|
+
obj: T$1;
|
|
241
|
+
[STORE_SYMBOL]: true;
|
|
242
|
+
};
|
|
243
|
+
type FragnoClientHookData<TMethod$1 extends HTTPMethod, TPath$1 extends string, TOutputSchema extends StandardSchemaV1, TErrorCode extends string, TQueryParameters extends string> = {
|
|
244
|
+
route: FragnoRouteConfig<TMethod$1, TPath$1, StandardSchemaV1 | undefined, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
245
|
+
query(args?: {
|
|
246
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string>;
|
|
247
|
+
query?: Record<TQueryParameters, string>;
|
|
248
|
+
}): Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;
|
|
249
|
+
store(args?: {
|
|
250
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>>;
|
|
251
|
+
query?: Record<TQueryParameters, string | ReadableAtom<string>>;
|
|
252
|
+
}): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema>, FragnoClientError<TErrorCode>>;
|
|
253
|
+
[GET_HOOK_SYMBOL]: true;
|
|
254
|
+
} & {
|
|
255
|
+
readonly _outputSchema?: TOutputSchema;
|
|
256
|
+
};
|
|
257
|
+
type FragnoClientMutatorData<TMethod$1 extends NonGetHTTPMethod, TPath$1 extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string, TQueryParameters extends string> = {
|
|
258
|
+
route: FragnoRouteConfig<TMethod$1, TPath$1, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
259
|
+
mutateQuery(args?: {
|
|
260
|
+
body?: InferOr<TInputSchema, undefined>;
|
|
261
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string>;
|
|
262
|
+
query?: Record<TQueryParameters, string>;
|
|
263
|
+
}): Promise<InferOr<TOutputSchema, undefined>>;
|
|
264
|
+
mutatorStore: MutatorStore<{
|
|
265
|
+
body?: InferOr<TInputSchema, undefined>;
|
|
266
|
+
path?: MaybeExtractPathParamsOrWiden<TPath$1, string | ReadableAtom<string>>;
|
|
267
|
+
query?: Record<TQueryParameters, string | ReadableAtom<string>>;
|
|
268
|
+
}, InferOr<TOutputSchema, undefined>, FragnoClientError<TErrorCode>>;
|
|
269
|
+
[MUTATOR_HOOK_SYMBOL]: true;
|
|
270
|
+
} & {
|
|
271
|
+
readonly _inputSchema?: TInputSchema;
|
|
272
|
+
readonly _outputSchema?: TOutputSchema;
|
|
273
|
+
};
|
|
274
|
+
declare function buildUrl<TPath$1 extends string>(config: {
|
|
275
|
+
baseUrl?: string;
|
|
276
|
+
mountRoute: string;
|
|
277
|
+
path: TPath$1;
|
|
278
|
+
}, params: {
|
|
279
|
+
pathParams?: Record<string, string | ReadableAtom<string>>;
|
|
280
|
+
queryParams?: Record<string, string | ReadableAtom<string>>;
|
|
281
|
+
}): string;
|
|
282
|
+
/**
|
|
283
|
+
* This method returns an array, which can be passed directly to nanostores.
|
|
284
|
+
*
|
|
285
|
+
* The returned array is always: path, pathParams (In order they appear in the path), queryParams (In alphabetical order)
|
|
286
|
+
* Missing pathParams are replaced with "<missing>".
|
|
287
|
+
* @param path
|
|
288
|
+
* @param params
|
|
289
|
+
* @returns
|
|
290
|
+
*/
|
|
291
|
+
declare function getCacheKey<TMethod$1 extends HTTPMethod, TPath$1 extends string>(method: TMethod$1, path: TPath$1, params?: {
|
|
292
|
+
pathParams?: Record<string, string | ReadableAtom<string>>;
|
|
293
|
+
queryParams?: Record<string, string | ReadableAtom<string>>;
|
|
294
|
+
}): (string | ReadableAtom<string>)[];
|
|
295
|
+
declare function isGetHook<TPath$1 extends string, TOutputSchema extends StandardSchemaV1, TErrorCode extends string, TQueryParameters extends string>(hook: unknown): hook is FragnoClientHookData<"GET", TPath$1, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
296
|
+
declare function isMutatorHook<TMethod$1 extends NonGetHTTPMethod, TPath$1 extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string, TQueryParameters extends string>(hook: unknown): hook is FragnoClientMutatorData<TMethod$1, TPath$1, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
297
|
+
declare function isStore<TStore extends Store>(obj: unknown): obj is FragnoStoreData<TStore>;
|
|
298
|
+
type OnErrorRetryFn = (opts: {
|
|
299
|
+
error: unknown;
|
|
300
|
+
key: string;
|
|
301
|
+
retryCount: number;
|
|
302
|
+
}) => number | undefined;
|
|
303
|
+
type CreateHookOptions = {
|
|
304
|
+
/**
|
|
305
|
+
* A function that will be called when an error occurs. Implements an exponential backoff strategy
|
|
306
|
+
* when left undefined. When null, retries will be disabled. The number returned (> 0) by the
|
|
307
|
+
* callback will determine in how many ms to retry next.
|
|
308
|
+
*/
|
|
309
|
+
onErrorRetry?: OnErrorRetryFn | null;
|
|
310
|
+
};
|
|
311
|
+
type OnInvalidateFn<TPath$1 extends string> = (invalidate: <TInnerPath extends string>(method: HTTPMethod, path: TInnerPath, params: {
|
|
312
|
+
pathParams?: MaybeExtractPathParamsOrWiden<TInnerPath, string>;
|
|
313
|
+
queryParams?: Record<string, string>;
|
|
314
|
+
}) => void, params: {
|
|
315
|
+
pathParams: MaybeExtractPathParamsOrWiden<TPath$1, string>;
|
|
316
|
+
queryParams?: Record<string, string>;
|
|
317
|
+
}) => void;
|
|
318
|
+
type CacheLine = {
|
|
319
|
+
data: unknown;
|
|
320
|
+
error: unknown;
|
|
321
|
+
retryCount: number;
|
|
322
|
+
created: number;
|
|
323
|
+
expires: number;
|
|
324
|
+
};
|
|
325
|
+
declare class ClientBuilder<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[], TFragmentConfig extends FragnoFragmentSharedConfig<TRoutes$1>> {
|
|
326
|
+
#private;
|
|
327
|
+
constructor(publicConfig: FragnoPublicClientConfig, fragmentConfig: TFragmentConfig);
|
|
328
|
+
get cacheEntries(): Readonly<Record<string, CacheLine>>;
|
|
329
|
+
createStore<const T extends object>(obj: T): FragnoStoreData<T>;
|
|
330
|
+
createHook<TPath extends ExtractGetRoutePaths<TFragmentConfig["routes"]>>(path: ValidateGetRoutePath<TFragmentConfig["routes"], TPath>, options?: CreateHookOptions): FragnoClientHookData<"GET", TPath, NonNullable<ExtractRouteByPath<TFragmentConfig["routes"], TPath>["outputSchema"]>, NonNullable<ExtractRouteByPath<TFragmentConfig["routes"], TPath>["errorCodes"]>[number], NonNullable<ExtractRouteByPath<TFragmentConfig["routes"], TPath>["queryParameters"]>[number]>;
|
|
331
|
+
createMutator<TPath extends ExtractNonGetRoutePaths<TFragmentConfig["routes"]>>(method: NonGetHTTPMethod, path: TPath, onInvalidate?: OnInvalidateFn<TPath>): FragnoClientMutatorData<NonGetHTTPMethod,
|
|
332
|
+
// TODO: This can be any Method, but should be related to TPath
|
|
333
|
+
TPath, ExtractRouteByPath<TFragmentConfig["routes"], TPath>["inputSchema"], ExtractRouteByPath<TFragmentConfig["routes"], TPath>["outputSchema"], NonNullable<ExtractRouteByPath<TFragmentConfig["routes"], TPath>["errorCodes"]>[number], NonNullable<ExtractRouteByPath<TFragmentConfig["routes"], TPath>["queryParameters"]>[number]>;
|
|
334
|
+
}
|
|
335
|
+
declare function createClientBuilder<TConfig, TDeps, TServices extends Record<string, unknown>, const TRoutesOrFactories extends readonly AnyRouteOrFactory[]>(fragmentDefinition: FragmentBuilder<TConfig, TDeps, TServices>, publicConfig: FragnoPublicClientConfig, routesOrFactories: TRoutesOrFactories): ClientBuilder<FlattenRouteFactories<TRoutesOrFactories>, FragnoFragmentSharedConfig<FlattenRouteFactories<TRoutesOrFactories>>>;
|
|
336
|
+
//#endregion
|
|
337
|
+
export { FragmentBuilder as A, RouteFactoryContext as B, FragnoClientApiError as C, FragnoClientFetchNetworkError as D, FragnoClientFetchError as E, createFragment as F, defineRoutes as H, defineFragment as I, AnyRouteOrFactory as L, FragnoInstantiatedFragment as M, FragnoPublicClientConfig as N, FragnoClientUnknownApiError as O, FragnoPublicConfig as P, FlattenRouteFactories as R, isStore as S, FragnoClientFetchAbortError as T, defineRoute as V, buildUrl as _, ExtractGetRoutes as a, isGetHook as b, ExtractRouteByPath as c, FragnoClientMutatorData as d, FragnoStoreData as f, ValidateGetRoutePath as g, ObjectContainingStoreField as h, ExtractGetRoutePaths as i, FragnoFragmentSharedConfig as j, FragnoErrorOptions as k, ExtractRoutePath as l, IsValidGetRoutePath as m, ClientBuilder as n, ExtractNonGetRoutePaths as o, HasGetRoutes as p, CreateHookOptions as r, ExtractOutputSchemaForPath as s, CacheLine as t, FragnoClientHookData as u, createClientBuilder as v, FragnoClientError as w, isMutatorHook as x, getCacheKey as y, RouteFactory as z };
|
|
338
|
+
//# sourceMappingURL=client-DdpPMlXL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-DdpPMlXL.d.ts","names":[],"sources":["../src/api/route.ts","../src/api/request-middleware.ts","../src/api/fragment.ts","../src/client/client-error.ts","../src/client/client.ts"],"sourcesContent":[],"mappings":";;;;;;KAIY,oBAAA,GAAuB,kBAAkB;UAEpC;UACP;QACF;EAJI,QAAA,EAKA,SALA;AAEZ;AACU,K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BN,EE28Be,KF38Bf,EE28BsB,SF38BtB,CAAA,EAAA,YAAA,EE48BhB,wBF58BgB,EAAA,iBAAA,EE68BX,kBF78BW,CAAA,EE88B7B,aF98B6B,CE+8B9B,qBF/8B8B,CE+8BR,kBF/8BQ,CAAA,EEg9B9B,0BFh9B8B,CEg9BH,qBFh9BG,CEg9BmB,kBFh9BnB,CAAA,CAAA,CAAA"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FragnoRouteConfig } from "./api-
|
|
2
|
-
import {
|
|
1
|
+
import { t as FragnoRouteConfig } from "./api-CAPyac52.js";
|
|
2
|
+
import { A as FragmentBuilder, B as RouteFactoryContext, F as createFragment, H as defineRoutes, I as defineFragment, L as AnyRouteOrFactory, M as FragnoInstantiatedFragment, N as FragnoPublicClientConfig, P as FragnoPublicConfig, R as FlattenRouteFactories, V as defineRoute, j as FragnoFragmentSharedConfig, z as RouteFactory } from "./client-DdpPMlXL.js";
|
|
3
3
|
export { type AnyRouteOrFactory, type FlattenRouteFactories, FragmentBuilder, type FragnoFragmentSharedConfig, type FragnoInstantiatedFragment, type FragnoPublicClientConfig, type FragnoPublicConfig, type FragnoRouteConfig, type RouteFactory, type RouteFactoryContext, createFragment, defineFragment, defineRoute, defineRoutes };
|
package/dist/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FragnoApiError } from "./api-
|
|
2
|
-
import {
|
|
1
|
+
import { n as FragnoApiError } from "./api-DuzjjCT4.js";
|
|
2
|
+
import { a as RequestOutputContext, i as OutputContext, n as defineRoutes, o as RequestInputContext, r as resolveRouteFactories, s as getMountRoute, t as defineRoute } from "./route-Dq62lXqB.js";
|
|
3
3
|
import { addRoute, createRouter, findRoute } from "rou3";
|
|
4
4
|
|
|
5
5
|
//#region src/api/request-middleware.ts
|
|
@@ -47,15 +47,13 @@ var RequestMiddlewareInputContext = class {
|
|
|
47
47
|
}
|
|
48
48
|
ifMatchesRoute = async (method, path, handler) => {
|
|
49
49
|
if (this.path !== path || this.method !== method) return;
|
|
50
|
-
|
|
50
|
+
return handler(await RequestInputContext.fromRequest({
|
|
51
51
|
request: this.#options.request,
|
|
52
52
|
method: this.#options.method,
|
|
53
53
|
path,
|
|
54
54
|
pathParams: this.pathParams,
|
|
55
55
|
inputSchema: this.#route.inputSchema
|
|
56
|
-
});
|
|
57
|
-
const outputContext = new RequestOutputContext(this.#route.outputSchema);
|
|
58
|
-
return handler(inputContext, outputContext);
|
|
56
|
+
}), new RequestOutputContext(this.#route.outputSchema));
|
|
59
57
|
};
|
|
60
58
|
};
|
|
61
59
|
|
|
@@ -114,6 +112,46 @@ function createFragment(fragmentDefinition, config, routesOrFactories, fragnoCon
|
|
|
114
112
|
middlewareHandler = handler;
|
|
115
113
|
return fragment;
|
|
116
114
|
},
|
|
115
|
+
handlersFor: (framework) => {
|
|
116
|
+
const handler = fragment.handler;
|
|
117
|
+
if (framework === "h3" || framework === "nuxt") throw new Error(`To get handlers for h3, use the 'fromWebHandler' utility function:
|
|
118
|
+
import { fromWebHandler } from "h3";
|
|
119
|
+
export default fromWebHandler(myFragment().handler);`);
|
|
120
|
+
return {
|
|
121
|
+
astro: { ALL: handler },
|
|
122
|
+
"react-router": {
|
|
123
|
+
loader: ({ request }) => handler(request),
|
|
124
|
+
action: ({ request }) => handler(request)
|
|
125
|
+
},
|
|
126
|
+
"next-js": {
|
|
127
|
+
GET: handler,
|
|
128
|
+
POST: handler,
|
|
129
|
+
PUT: handler,
|
|
130
|
+
DELETE: handler,
|
|
131
|
+
PATCH: handler,
|
|
132
|
+
HEAD: handler,
|
|
133
|
+
OPTIONS: handler
|
|
134
|
+
},
|
|
135
|
+
"svelte-kit": {
|
|
136
|
+
GET: handler,
|
|
137
|
+
POST: handler,
|
|
138
|
+
PUT: handler,
|
|
139
|
+
DELETE: handler,
|
|
140
|
+
PATCH: handler,
|
|
141
|
+
HEAD: handler,
|
|
142
|
+
OPTIONS: handler
|
|
143
|
+
},
|
|
144
|
+
"solid-start": {
|
|
145
|
+
GET: ({ request }) => handler(request),
|
|
146
|
+
POST: ({ request }) => handler(request),
|
|
147
|
+
PUT: ({ request }) => handler(request),
|
|
148
|
+
DELETE: ({ request }) => handler(request),
|
|
149
|
+
PATCH: ({ request }) => handler(request),
|
|
150
|
+
HEAD: ({ request }) => handler(request),
|
|
151
|
+
OPTIONS: ({ request }) => handler(request)
|
|
152
|
+
}
|
|
153
|
+
}[framework];
|
|
154
|
+
},
|
|
117
155
|
handler: async (req) => {
|
|
118
156
|
const pathname = new URL(req.url).pathname;
|
|
119
157
|
const matchRoute = pathname.startsWith(mountRoute) ? pathname.slice(mountRoute.length) : null;
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":["#deps","#services","#options","#route","route","#definition","middlewareHandler:\n | FragnoMiddlewareCallback<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices>\n | undefined","fragment: FragnoInstantiatedFragment<\n FlattenRouteFactories<TRoutesOrFactories>,\n TDeps,\n TServices\n >"],"sources":["../src/api/request-middleware.ts","../src/api/fragment.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ExtractRouteByPath, ExtractRoutePath } from \"../client/client\";\nimport type { HTTPMethod } from \"./api\";\nimport type { ExtractPathParams } from \"./internal/path\";\nimport type { RequestBodyType } from \"./request-input-context\";\nimport type { AnyFragnoRouteConfig } from \"./route\";\nimport { RequestInputContext } from \"./request-input-context\";\nimport { OutputContext, RequestOutputContext } from \"./request-output-context\";\n\nexport type FragnoMiddlewareCallback<\n TRoutes extends readonly AnyFragnoRouteConfig[],\n TDeps,\n TServices extends Record<string, unknown>,\n> = (\n inputContext: RequestMiddlewareInputContext<TRoutes>,\n outputContext: RequestMiddlewareOutputContext<TDeps, TServices>,\n) => Promise<Response | undefined> | Response | undefined;\n\nexport interface RequestMiddlewareOptions {\n path: string;\n method: HTTPMethod;\n pathParams?: Record<string, string>;\n searchParams: URLSearchParams;\n body: RequestBodyType;\n request: Request;\n}\n\nexport class RequestMiddlewareOutputContext<\n const TDeps,\n const TServices extends Record<string, unknown>,\n> extends OutputContext<unknown, string> {\n readonly #deps: TDeps;\n readonly #services: TServices;\n\n constructor(deps: TDeps, services: TServices) {\n super();\n this.#deps = deps;\n this.#services = services;\n }\n\n get deps(): TDeps {\n return this.#deps;\n }\n\n get services(): TServices {\n return this.#services;\n }\n}\n\nexport class RequestMiddlewareInputContext<const TRoutes extends readonly AnyFragnoRouteConfig[]> {\n readonly #options: RequestMiddlewareOptions;\n readonly #route: TRoutes[number];\n\n constructor(routes: TRoutes, options: RequestMiddlewareOptions) {\n this.#options = options;\n\n const route = routes.find(\n (route) => route.path === options.path && route.method === options.method,\n );\n\n if (!route) {\n throw new Error(`Route not found: ${options.path} ${options.method}`);\n }\n\n this.#route = route;\n }\n\n get path(): string {\n return this.#options.path;\n }\n\n get method(): HTTPMethod {\n return this.#options.method;\n }\n\n get pathParams(): Record<string, string> {\n return this.#options.pathParams ?? {};\n }\n\n get queryParams(): URLSearchParams {\n return this.#options.searchParams;\n }\n\n get inputSchema(): StandardSchemaV1 | undefined {\n return this.#route.inputSchema;\n }\n\n get outputSchema(): StandardSchemaV1 | undefined {\n return this.#route.outputSchema;\n }\n\n // Defined as a field so that `this` reference stays in tact when destructuring\n ifMatchesRoute = async <\n const TMethod extends HTTPMethod,\n const TPath extends ExtractRoutePath<TRoutes>,\n const TRoute extends ExtractRouteByPath<TRoutes, TPath, TMethod> = ExtractRouteByPath<\n TRoutes,\n TPath,\n TMethod\n >,\n >(\n method: TMethod,\n path: TPath,\n handler: (\n ...args: Parameters<TRoute[\"handler\"]>\n ) => Promise<Response | undefined | void> | Response | undefined | void,\n ): Promise<Response | undefined> => {\n if (this.path !== path || this.method !== method) {\n return undefined;\n }\n\n // TODO(Wilco): We should support reading/modifying headers here.\n const inputContext = await RequestInputContext.fromRequest({\n request: this.#options.request,\n method: this.#options.method,\n path: path,\n pathParams: this.pathParams as ExtractPathParams<TPath>,\n inputSchema: this.#route.inputSchema,\n });\n\n const outputContext = new RequestOutputContext(this.#route.outputSchema);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (handler as any)(inputContext, outputContext);\n };\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { type FragnoRouteConfig, type HTTPMethod } from \"./api\";\nimport { FragnoApiError } from \"./error\";\nimport { getMountRoute } from \"./internal/route\";\nimport { addRoute, createRouter, findRoute } from \"rou3\";\nimport { RequestInputContext } from \"./request-input-context\";\nimport type { ExtractPathParams } from \"./internal/path\";\nimport { RequestOutputContext } from \"./request-output-context\";\nimport {\n type EmptyObject,\n type AnyFragnoRouteConfig,\n type AnyRouteOrFactory,\n type FlattenRouteFactories,\n resolveRouteFactories,\n} from \"./route\";\nimport {\n RequestMiddlewareInputContext,\n RequestMiddlewareOutputContext,\n type FragnoMiddlewareCallback,\n} from \"./request-middleware\";\n\nexport interface FragnoPublicConfig {\n mountRoute?: string;\n}\n\nexport interface FragnoPublicClientConfig {\n mountRoute?: string;\n baseUrl?: string;\n}\n\nexport interface FragnoInstantiatedFragment<\n TRoutes extends readonly AnyFragnoRouteConfig[] = [],\n TDeps = EmptyObject,\n TServices extends Record<string, unknown> = Record<string, unknown>,\n> {\n config: FragnoFragmentSharedConfig<TRoutes>;\n deps: TDeps;\n services: TServices;\n handler: (req: Request) => Promise<Response>;\n mountRoute: string;\n withMiddleware: (\n handler: FragnoMiddlewareCallback<TRoutes, TDeps, TServices>,\n ) => FragnoInstantiatedFragment<TRoutes, TDeps, TServices>;\n}\n\nexport interface FragnoFragmentSharedConfig<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> {\n name: string;\n routes: TRoutes;\n}\n\nexport type AnyFragnoFragmentSharedConfig = FragnoFragmentSharedConfig<\n readonly AnyFragnoRouteConfig[]\n>;\n\ninterface FragmentDefinition<\n TConfig,\n TDeps = EmptyObject,\n TServices extends Record<string, unknown> = EmptyObject,\n> {\n name: string;\n dependencies?: (config: TConfig) => TDeps;\n services?: (config: TConfig, deps: TDeps) => TServices;\n}\n\nexport class FragmentBuilder<\n TConfig,\n TDeps = EmptyObject,\n TServices extends Record<string, unknown> = EmptyObject,\n> {\n #definition: FragmentDefinition<TConfig, TDeps, TServices>;\n\n constructor(definition: FragmentDefinition<TConfig, TDeps, TServices>) {\n this.#definition = definition;\n }\n\n get definition() {\n return this.#definition;\n }\n\n withDependencies<TNewDeps>(\n fn: (config: TConfig) => TNewDeps,\n ): FragmentBuilder<TConfig, TNewDeps, TServices> {\n return new FragmentBuilder<TConfig, TNewDeps, TServices>({\n ...this.#definition,\n dependencies: fn,\n } as FragmentDefinition<TConfig, TNewDeps, TServices>);\n }\n\n withServices<TNewServices extends Record<string, unknown>>(\n fn: (config: TConfig, deps: TDeps) => TNewServices,\n ): FragmentBuilder<TConfig, TDeps, TNewServices> {\n return new FragmentBuilder<TConfig, TDeps, TNewServices>({\n ...this.#definition,\n services: fn,\n } as FragmentDefinition<TConfig, TDeps, TNewServices>);\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig> {\n return new FragmentBuilder({\n name,\n });\n}\n\nexport function createFragment<\n TConfig,\n TDeps,\n TServices extends Record<string, unknown>,\n const TRoutesOrFactories extends readonly AnyRouteOrFactory[],\n>(\n fragmentDefinition: FragmentBuilder<TConfig, TDeps, TServices>,\n config: TConfig,\n routesOrFactories: TRoutesOrFactories,\n fragnoConfig: FragnoPublicConfig = {},\n): FragnoInstantiatedFragment<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices> {\n const definition = fragmentDefinition.definition;\n\n const dependencies = definition.dependencies ? definition.dependencies(config) : ({} as TDeps);\n const services = definition.services\n ? definition.services(config, dependencies)\n : ({} as TServices);\n\n const context = { config, deps: dependencies, services };\n const routes = resolveRouteFactories(context, routesOrFactories);\n\n const mountRoute = getMountRoute({\n name: definition.name,\n mountRoute: fragnoConfig.mountRoute,\n });\n\n const router =\n createRouter<\n FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >\n >();\n\n let middlewareHandler:\n | FragnoMiddlewareCallback<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices>\n | undefined;\n\n for (const routeConfig of routes) {\n addRoute(router, routeConfig.method.toUpperCase(), routeConfig.path, routeConfig);\n }\n\n const fragment: FragnoInstantiatedFragment<\n FlattenRouteFactories<TRoutesOrFactories>,\n TDeps,\n TServices\n > = {\n mountRoute,\n config: {\n name: definition.name,\n routes,\n },\n services,\n deps: dependencies,\n withMiddleware: (handler) => {\n if (middlewareHandler) {\n throw new Error(\"Middleware already set\");\n }\n\n middlewareHandler = handler;\n\n return fragment;\n },\n handler: async (req: Request) => {\n const url = new URL(req.url);\n const pathname = url.pathname;\n\n const matchRoute = pathname.startsWith(mountRoute) ? pathname.slice(mountRoute.length) : null;\n\n if (matchRoute === null) {\n return Response.json(\n {\n error:\n `Fragno: Route for '${definition.name}' not found. Is the fragment mounted on the right route? ` +\n `Expecting: '${mountRoute}'.`,\n code: \"ROUTE_NOT_FOUND\",\n },\n { status: 404 },\n );\n }\n\n const route = findRoute(router, req.method, matchRoute);\n\n if (!route) {\n return Response.json(\n { error: `Fragno: Route for '${definition.name}' not found`, code: \"ROUTE_NOT_FOUND\" },\n { status: 404 },\n );\n }\n\n const { handler, inputSchema, outputSchema, path } = route.data;\n\n const outputContext = new RequestOutputContext(outputSchema);\n\n if (middlewareHandler) {\n const middlewareInputContext = new RequestMiddlewareInputContext(routes, {\n method: req.method as HTTPMethod,\n path,\n pathParams: route.params,\n searchParams: new URL(req.url).searchParams,\n body: req.body,\n request: req,\n });\n\n const middlewareOutputContext = new RequestMiddlewareOutputContext(dependencies, services);\n\n try {\n const middlewareResult = await middlewareHandler(\n middlewareInputContext,\n middlewareOutputContext,\n );\n if (middlewareResult !== undefined) {\n return middlewareResult;\n }\n } catch (error) {\n console.error(\"Error in middleware\", error);\n\n if (error instanceof FragnoApiError) {\n // TODO: If a validation error occurs in middleware (when calling `await input.valid()`)\n // the processing is short-circuited and a potential `catch` block around the call\n // to `input.valid()` in the actual handler will not be executed.\n return error.toResponse();\n }\n\n return Response.json(\n { error: \"Internal server error\", code: \"INTERNAL_SERVER_ERROR\" },\n { status: 500 },\n );\n }\n }\n\n const inputContext = await RequestInputContext.fromRequest({\n request: req,\n method: req.method,\n path,\n pathParams: (route.params ?? {}) as ExtractPathParams<typeof path>,\n inputSchema,\n });\n\n try {\n const result = await handler(inputContext, outputContext);\n return result;\n } catch (error) {\n console.error(\"Error in handler\", error);\n\n if (error instanceof FragnoApiError) {\n return error.toResponse();\n }\n\n return Response.json(\n { error: \"Internal server error\", code: \"INTERNAL_SERVER_ERROR\" },\n { status: 500 },\n );\n }\n },\n };\n\n return fragment;\n}\n"],"mappings":";;;;;AA2BA,IAAa,iCAAb,cAGU,cAA+B;CACvC,CAASA;CACT,CAASC;CAET,YAAY,MAAa,UAAqB;AAC5C,SAAO;AACP,QAAKD,OAAQ;AACb,QAAKC,WAAY;;CAGnB,IAAI,OAAc;AAChB,SAAO,MAAKD;;CAGd,IAAI,WAAsB;AACxB,SAAO,MAAKC;;;AAIhB,IAAa,gCAAb,MAAkG;CAChG,CAASC;CACT,CAASC;CAET,YAAY,QAAiB,SAAmC;AAC9D,QAAKD,UAAW;EAEhB,MAAM,QAAQ,OAAO,MAClB,YAAUE,QAAM,SAAS,QAAQ,QAAQA,QAAM,WAAW,QAAQ,OACpE;AAED,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,oBAAoB,QAAQ,KAAK,GAAG,QAAQ,SAAS;AAGvE,QAAKD,QAAS;;CAGhB,IAAI,OAAe;AACjB,SAAO,MAAKD,QAAS;;CAGvB,IAAI,SA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F,OAAO;AACd,aAAQ,MAAM,uBAAuB,MAAM;AAE3C,SAAI,iBAAiB,eAInB,QAAO,MAAM,YAAY;AAG3B,YAAO,SAAS,KACd;MAAE,OAAO;MAAyB,MAAM;MAAyB,EACjE,EAAE,QAAQ,KAAK,CAChB;;;GAIL,MAAM,eAAe,MAAM,oBAAoB,YAAY;IACzD,SAAS;IACT,QAAQ,IAAI;IACZ;IACA,YAAa,MAAM,UAAU,EAAE;IAC/B;IACD,CAAC;AAEF,OAAI;AAEF,WADe,MAAM,QAAQ,cAAc,cAAc;YAElD,OAAO;AACd,YAAQ,MAAM,oBAAoB,MAAM;AAExC,QAAI,iBAAiB,eACnB,QAAO,MAAM,YAAY;AAG3B,WAAO,SAAS,KACd;KAAE,OAAO;KAAyB,MAAM;KAAyB,EACjE,EAAE,QAAQ,KAAK,CAChB;;;EAGN;AAED,QAAO"}
|
|
1
|
+
{"version":3,"file":"mod.js","names":["#deps","#services","#options","#route","route","#definition","middlewareHandler:\n | FragnoMiddlewareCallback<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices>\n | undefined","fragment: FragnoInstantiatedFragment<\n FlattenRouteFactories<TRoutesOrFactories>,\n TDeps,\n TServices\n >"],"sources":["../src/api/request-middleware.ts","../src/api/fragment.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { ExtractRouteByPath, ExtractRoutePath } from \"../client/client\";\nimport type { HTTPMethod } from \"./api\";\nimport type { ExtractPathParams } from \"./internal/path\";\nimport type { RequestBodyType } from \"./request-input-context\";\nimport type { AnyFragnoRouteConfig } from \"./route\";\nimport { RequestInputContext } from \"./request-input-context\";\nimport { OutputContext, RequestOutputContext } from \"./request-output-context\";\n\nexport type FragnoMiddlewareCallback<\n TRoutes extends readonly AnyFragnoRouteConfig[],\n TDeps,\n TServices extends Record<string, unknown>,\n> = (\n inputContext: RequestMiddlewareInputContext<TRoutes>,\n outputContext: RequestMiddlewareOutputContext<TDeps, TServices>,\n) => Promise<Response | undefined> | Response | undefined;\n\nexport interface RequestMiddlewareOptions {\n path: string;\n method: HTTPMethod;\n pathParams?: Record<string, string>;\n searchParams: URLSearchParams;\n body: RequestBodyType;\n request: Request;\n}\n\nexport class RequestMiddlewareOutputContext<\n const TDeps,\n const TServices extends Record<string, unknown>,\n> extends OutputContext<unknown, string> {\n readonly #deps: TDeps;\n readonly #services: TServices;\n\n constructor(deps: TDeps, services: TServices) {\n super();\n this.#deps = deps;\n this.#services = services;\n }\n\n get deps(): TDeps {\n return this.#deps;\n }\n\n get services(): TServices {\n return this.#services;\n }\n}\n\nexport class RequestMiddlewareInputContext<const TRoutes extends readonly AnyFragnoRouteConfig[]> {\n readonly #options: RequestMiddlewareOptions;\n readonly #route: TRoutes[number];\n\n constructor(routes: TRoutes, options: RequestMiddlewareOptions) {\n this.#options = options;\n\n const route = routes.find(\n (route) => route.path === options.path && route.method === options.method,\n );\n\n if (!route) {\n throw new Error(`Route not found: ${options.path} ${options.method}`);\n }\n\n this.#route = route;\n }\n\n get path(): string {\n return this.#options.path;\n }\n\n get method(): HTTPMethod {\n return this.#options.method;\n }\n\n get pathParams(): Record<string, string> {\n return this.#options.pathParams ?? {};\n }\n\n get queryParams(): URLSearchParams {\n return this.#options.searchParams;\n }\n\n get inputSchema(): StandardSchemaV1 | undefined {\n return this.#route.inputSchema;\n }\n\n get outputSchema(): StandardSchemaV1 | undefined {\n return this.#route.outputSchema;\n }\n\n // Defined as a field so that `this` reference stays in tact when destructuring\n ifMatchesRoute = async <\n const TMethod extends HTTPMethod,\n const TPath extends ExtractRoutePath<TRoutes>,\n const TRoute extends ExtractRouteByPath<TRoutes, TPath, TMethod> = ExtractRouteByPath<\n TRoutes,\n TPath,\n TMethod\n >,\n >(\n method: TMethod,\n path: TPath,\n handler: (\n ...args: Parameters<TRoute[\"handler\"]>\n ) => Promise<Response | undefined | void> | Response | undefined | void,\n ): Promise<Response | undefined> => {\n if (this.path !== path || this.method !== method) {\n return undefined;\n }\n\n // TODO(Wilco): We should support reading/modifying headers here.\n const inputContext = await RequestInputContext.fromRequest({\n request: this.#options.request,\n method: this.#options.method,\n path: path,\n pathParams: this.pathParams as ExtractPathParams<TPath>,\n inputSchema: this.#route.inputSchema,\n });\n\n const outputContext = new RequestOutputContext(this.#route.outputSchema);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (handler as any)(inputContext, outputContext);\n };\n}\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { type FragnoRouteConfig, type HTTPMethod } from \"./api\";\nimport { FragnoApiError } from \"./error\";\nimport { getMountRoute } from \"./internal/route\";\nimport { addRoute, createRouter, findRoute } from \"rou3\";\nimport { RequestInputContext } from \"./request-input-context\";\nimport type { ExtractPathParams } from \"./internal/path\";\nimport { RequestOutputContext } from \"./request-output-context\";\nimport {\n type AnyFragnoRouteConfig,\n type AnyRouteOrFactory,\n type FlattenRouteFactories,\n resolveRouteFactories,\n} from \"./route\";\nimport {\n RequestMiddlewareInputContext,\n RequestMiddlewareOutputContext,\n type FragnoMiddlewareCallback,\n} from \"./request-middleware\";\n\nexport interface FragnoPublicConfig {\n mountRoute?: string;\n}\n\nexport interface FragnoPublicClientConfig {\n mountRoute?: string;\n baseUrl?: string;\n}\n\ntype AstroHandlers = {\n ALL: (req: Request) => Promise<Response>;\n};\n\ntype ReactRouterHandlers = {\n loader: (args: { request: Request }) => Promise<Response>;\n action: (args: { request: Request }) => Promise<Response>;\n};\n\ntype SolidStartHandlers = {\n GET: (args: { request: Request }) => Promise<Response>;\n POST: (args: { request: Request }) => Promise<Response>;\n PUT: (args: { request: Request }) => Promise<Response>;\n DELETE: (args: { request: Request }) => Promise<Response>;\n PATCH: (args: { request: Request }) => Promise<Response>;\n HEAD: (args: { request: Request }) => Promise<Response>;\n OPTIONS: (args: { request: Request }) => Promise<Response>;\n};\n\ntype StandardHandlers = {\n GET: (req: Request) => Promise<Response>;\n POST: (req: Request) => Promise<Response>;\n PUT: (req: Request) => Promise<Response>;\n DELETE: (req: Request) => Promise<Response>;\n PATCH: (req: Request) => Promise<Response>;\n HEAD: (req: Request) => Promise<Response>;\n OPTIONS: (req: Request) => Promise<Response>;\n};\n\ntype HandlersByFramework = {\n astro: AstroHandlers;\n \"react-router\": ReactRouterHandlers;\n \"next-js\": StandardHandlers;\n \"svelte-kit\": StandardHandlers;\n \"solid-start\": SolidStartHandlers;\n};\n\ntype FullstackFrameworks = keyof HandlersByFramework;\n\nexport interface FragnoInstantiatedFragment<\n TRoutes extends readonly AnyFragnoRouteConfig[] = [],\n TDeps = {},\n TServices extends Record<string, unknown> = Record<string, unknown>,\n> {\n config: FragnoFragmentSharedConfig<TRoutes>;\n deps: TDeps;\n services: TServices;\n handlersFor: <T extends FullstackFrameworks>(framework: T) => HandlersByFramework[T];\n handler: (req: Request) => Promise<Response>;\n mountRoute: string;\n withMiddleware: (\n handler: FragnoMiddlewareCallback<TRoutes, TDeps, TServices>,\n ) => FragnoInstantiatedFragment<TRoutes, TDeps, TServices>;\n}\n\nexport interface FragnoFragmentSharedConfig<\n TRoutes extends readonly FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >[],\n> {\n name: string;\n routes: TRoutes;\n}\n\nexport type AnyFragnoFragmentSharedConfig = FragnoFragmentSharedConfig<\n readonly AnyFragnoRouteConfig[]\n>;\n\ninterface FragmentDefinition<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {\n name: string;\n dependencies?: (config: TConfig) => TDeps;\n services?: (config: TConfig, deps: TDeps) => TServices;\n}\n\nexport class FragmentBuilder<TConfig, TDeps = {}, TServices extends Record<string, unknown> = {}> {\n #definition: FragmentDefinition<TConfig, TDeps, TServices>;\n\n constructor(definition: FragmentDefinition<TConfig, TDeps, TServices>) {\n this.#definition = definition;\n }\n\n get definition() {\n return this.#definition;\n }\n\n withDependencies<TNewDeps>(\n fn: (config: TConfig) => TNewDeps,\n ): FragmentBuilder<TConfig, TNewDeps, TServices> {\n return new FragmentBuilder<TConfig, TNewDeps, TServices>({\n ...this.#definition,\n dependencies: fn,\n } as FragmentDefinition<TConfig, TNewDeps, TServices>);\n }\n\n withServices<TNewServices extends Record<string, unknown>>(\n fn: (config: TConfig, deps: TDeps) => TNewServices,\n ): FragmentBuilder<TConfig, TDeps, TNewServices> {\n return new FragmentBuilder<TConfig, TDeps, TNewServices>({\n ...this.#definition,\n services: fn,\n } as FragmentDefinition<TConfig, TDeps, TNewServices>);\n }\n}\n\nexport function defineFragment<TConfig = {}>(name: string): FragmentBuilder<TConfig> {\n return new FragmentBuilder({\n name,\n });\n}\n\nexport function createFragment<\n TConfig,\n TDeps,\n TServices extends Record<string, unknown>,\n const TRoutesOrFactories extends readonly AnyRouteOrFactory[],\n>(\n fragmentDefinition: FragmentBuilder<TConfig, TDeps, TServices>,\n config: TConfig,\n routesOrFactories: TRoutesOrFactories,\n fragnoConfig: FragnoPublicConfig = {},\n): FragnoInstantiatedFragment<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices> {\n const definition = fragmentDefinition.definition;\n\n const dependencies = definition.dependencies ? definition.dependencies(config) : ({} as TDeps);\n const services = definition.services\n ? definition.services(config, dependencies)\n : ({} as TServices);\n\n const context = { config, deps: dependencies, services };\n const routes = resolveRouteFactories(context, routesOrFactories);\n\n const mountRoute = getMountRoute({\n name: definition.name,\n mountRoute: fragnoConfig.mountRoute,\n });\n\n const router =\n createRouter<\n FragnoRouteConfig<\n HTTPMethod,\n string,\n StandardSchemaV1 | undefined,\n StandardSchemaV1 | undefined,\n string,\n string\n >\n >();\n\n let middlewareHandler:\n | FragnoMiddlewareCallback<FlattenRouteFactories<TRoutesOrFactories>, TDeps, TServices>\n | undefined;\n\n for (const routeConfig of routes) {\n addRoute(router, routeConfig.method.toUpperCase(), routeConfig.path, routeConfig);\n }\n\n const fragment: FragnoInstantiatedFragment<\n FlattenRouteFactories<TRoutesOrFactories>,\n TDeps,\n TServices\n > = {\n mountRoute,\n config: {\n name: definition.name,\n routes,\n },\n services,\n deps: dependencies,\n withMiddleware: (handler) => {\n if (middlewareHandler) {\n throw new Error(\"Middleware already set\");\n }\n\n middlewareHandler = handler;\n\n return fragment;\n },\n handlersFor: <T extends FullstackFrameworks>(framework: T): HandlersByFramework[T] => {\n const handler = fragment.handler;\n\n // LLMs hallucinate these values sometimes, solution isn't obvious so we throw this error\n // @ts-expect-error TS2367\n if (framework === \"h3\" || framework === \"nuxt\") {\n throw new Error(`To get handlers for h3, use the 'fromWebHandler' utility function:\n import { fromWebHandler } from \"h3\";\n export default fromWebHandler(myFragment().handler);`);\n }\n const allHandlers = {\n astro: { ALL: handler },\n \"react-router\": {\n loader: ({ request }: { request: Request }) => handler(request),\n action: ({ request }: { request: Request }) => handler(request),\n },\n \"next-js\": {\n GET: handler,\n POST: handler,\n PUT: handler,\n DELETE: handler,\n PATCH: handler,\n HEAD: handler,\n OPTIONS: handler,\n },\n \"svelte-kit\": {\n GET: handler,\n POST: handler,\n PUT: handler,\n DELETE: handler,\n PATCH: handler,\n HEAD: handler,\n OPTIONS: handler,\n },\n \"solid-start\": {\n GET: ({ request }: { request: Request }) => handler(request),\n POST: ({ request }: { request: Request }) => handler(request),\n PUT: ({ request }: { request: Request }) => handler(request),\n DELETE: ({ request }: { request: Request }) => handler(request),\n PATCH: ({ request }: { request: Request }) => handler(request),\n HEAD: ({ request }: { request: Request }) => handler(request),\n OPTIONS: ({ request }: { request: Request }) => handler(request),\n },\n } satisfies HandlersByFramework;\n\n return allHandlers[framework];\n },\n handler: async (req: Request) => {\n const url = new URL(req.url);\n const pathname = url.pathname;\n\n const matchRoute = pathname.startsWith(mountRoute) ? pathname.slice(mountRoute.length) : null;\n\n if (matchRoute === null) {\n return Response.json(\n {\n error:\n `Fragno: Route for '${definition.name}' not found. Is the fragment mounted on the right route? ` +\n `Expecting: '${mountRoute}'.`,\n code: \"ROUTE_NOT_FOUND\",\n },\n { status: 404 },\n );\n }\n\n const route = findRoute(router, req.method, matchRoute);\n\n if (!route) {\n return Response.json(\n { error: `Fragno: Route for '${definition.name}' not found`, code: \"ROUTE_NOT_FOUND\" },\n { status: 404 },\n );\n }\n\n const { handler, inputSchema, outputSchema, path } = route.data;\n\n const outputContext = new RequestOutputContext(outputSchema);\n\n if (middlewareHandler) {\n const middlewareInputContext = new RequestMiddlewareInputContext(routes, {\n method: req.method as HTTPMethod,\n path,\n pathParams: route.params,\n searchParams: new URL(req.url).searchParams,\n body: req.body,\n request: req,\n });\n\n const middlewareOutputContext = new RequestMiddlewareOutputContext(dependencies, services);\n\n try {\n const middlewareResult = await middlewareHandler(\n middlewareInputContext,\n middlewareOutputContext,\n );\n if (middlewareResult !== undefined) {\n return middlewareResult;\n }\n } catch (error) {\n console.error(\"Error in middleware\", error);\n\n if (error instanceof FragnoApiError) {\n // TODO: If a validation error occurs in middleware (when calling `await input.valid()`)\n // the processing is short-circuited and a potential `catch` block around the call\n // to `input.valid()` in the actual handler will not be executed.\n return error.toResponse();\n }\n\n return Response.json(\n { error: \"Internal server error\", code: \"INTERNAL_SERVER_ERROR\" },\n { status: 500 },\n );\n }\n }\n\n const inputContext = await RequestInputContext.fromRequest({\n request: req,\n method: req.method,\n path,\n pathParams: (route.params ?? {}) as ExtractPathParams<typeof path>,\n inputSchema,\n });\n\n try {\n const result = await handler(inputContext, outputContext);\n return result;\n } catch (error) {\n console.error(\"Error in handler\", error);\n\n if (error instanceof FragnoApiError) {\n return error.toResponse();\n }\n\n return Response.json(\n { error: \"Internal server error\", code: \"INTERNAL_SERVER_ERROR\" },\n { status: 500 },\n );\n }\n },\n };\n\n return fragment;\n}\n"],"mappings":";;;;;AA2BA,IAAa,iCAAb,cAGU,cAA+B;CACvC,CAASA;CACT,CAASC;CAET,YAAY,MAAa,UAAqB;AAC5C,SAAO;AACP,QAAKD,OAAQ;AACb,QAAKC,WAAY;;CAGnB,IAAI,OAAc;AAChB,SAAO,MAAKD;;CAGd,IAAI,WAAsB;AACxB,SAAO,MAAKC;;;AAI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,KAAK,CAChB;;;GAIL,MAAM,eAAe,MAAM,oBAAoB,YAAY;IACzD,SAAS;IACT,QAAQ,IAAI;IACZ;IACA,YAAa,MAAM,UAAU,EAAE;IAC/B;IACD,CAAC;AAEF,OAAI;AAEF,WADe,MAAM,QAAQ,cAAc,cAAc;YAElD,OAAO;AACd,YAAQ,MAAM,oBAAoB,MAAM;AAExC,QAAI,iBAAiB,eACnB,QAAO,MAAM,YAAY;AAG3B,WAAO,SAAS,KACd;KAAE,OAAO;KAAyB,MAAM;KAAyB,EACjE,EAAE,QAAQ,KAAK,CAChB;;;EAGN;AAED,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FragnoApiValidationError } from "./api-
|
|
1
|
+
import { r as FragnoApiValidationError } from "./api-DuzjjCT4.js";
|
|
2
2
|
|
|
3
3
|
//#region src/api/internal/route.ts
|
|
4
4
|
function getMountRoute(opts) {
|
|
@@ -216,14 +216,14 @@ var OutputContext = class {
|
|
|
216
216
|
*/
|
|
217
217
|
error({ message, code }, initOrStatus, headers) {
|
|
218
218
|
if (typeof initOrStatus === "undefined") return Response.json({
|
|
219
|
-
|
|
219
|
+
message,
|
|
220
220
|
code
|
|
221
221
|
}, {
|
|
222
222
|
status: 500,
|
|
223
223
|
headers
|
|
224
224
|
});
|
|
225
225
|
if (typeof initOrStatus === "number") return Response.json({
|
|
226
|
-
|
|
226
|
+
message,
|
|
227
227
|
code
|
|
228
228
|
}, {
|
|
229
229
|
status: initOrStatus,
|
|
@@ -231,7 +231,7 @@ var OutputContext = class {
|
|
|
231
231
|
});
|
|
232
232
|
const mergedHeaders = mergeHeaders(initOrStatus.headers, headers);
|
|
233
233
|
return Response.json({
|
|
234
|
-
|
|
234
|
+
message,
|
|
235
235
|
code
|
|
236
236
|
}, {
|
|
237
237
|
status: initOrStatus.status,
|
|
@@ -327,5 +327,5 @@ function defineRoutes() {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
//#endregion
|
|
330
|
-
export {
|
|
331
|
-
//# sourceMappingURL=route-
|
|
330
|
+
export { RequestOutputContext as a, OutputContext as i, defineRoutes as n, RequestInputContext as o, resolveRouteFactories as r, getMountRoute as s, defineRoute as t };
|
|
331
|
+
//# sourceMappingURL=route-Dq62lXqB.js.map
|