@fragno-dev/api-fragment 0.0.0-stage → 0.0.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 (79) hide show
  1. package/LICENSE.md +16 -0
  2. package/README.md +249 -2
  3. package/dist/browser/client/client-3ZV9sw3i.js +2580 -0
  4. package/dist/browser/client/client-3ZV9sw3i.js.map +1 -0
  5. package/dist/browser/client/client-DPjmoaJQ.d.ts +711 -0
  6. package/dist/browser/client/client-DPjmoaJQ.d.ts.map +1 -0
  7. package/dist/browser/client/client.d.ts +1645 -0
  8. package/dist/browser/client/client.d.ts.map +1 -0
  9. package/dist/browser/client/client.js +2 -0
  10. package/dist/browser/client/react.d.ts +1665 -0
  11. package/dist/browser/client/react.d.ts.map +1 -0
  12. package/dist/browser/client/react.js +194 -0
  13. package/dist/browser/client/react.js.map +1 -0
  14. package/dist/browser/client/solid.d.ts +1668 -0
  15. package/dist/browser/client/solid.d.ts.map +1 -0
  16. package/dist/browser/client/solid.js +129 -0
  17. package/dist/browser/client/solid.js.map +1 -0
  18. package/dist/browser/client/svelte.d.ts +1668 -0
  19. package/dist/browser/client/svelte.d.ts.map +1 -0
  20. package/dist/browser/client/svelte.js +131 -0
  21. package/dist/browser/client/svelte.js.map +1 -0
  22. package/dist/browser/client/vanilla.d.ts +1695 -0
  23. package/dist/browser/client/vanilla.d.ts.map +1 -0
  24. package/dist/browser/client/vanilla.js +159 -0
  25. package/dist/browser/client/vanilla.js.map +1 -0
  26. package/dist/browser/client/vue.d.ts +1668 -0
  27. package/dist/browser/client/vue.d.ts.map +1 -0
  28. package/dist/browser/client/vue.js +127 -0
  29. package/dist/browser/client/vue.js.map +1 -0
  30. package/dist/browser/client-D4NnY-zV.d.ts +713 -0
  31. package/dist/browser/client-D4NnY-zV.d.ts.map +1 -0
  32. package/dist/browser/client-DQE0c7GI.d.ts +711 -0
  33. package/dist/browser/client-DQE0c7GI.d.ts.map +1 -0
  34. package/dist/browser/index.d.ts +3130 -0
  35. package/dist/browser/index.d.ts.map +1 -0
  36. package/dist/browser/index.js +2 -0
  37. package/dist/browser/src-BrYPVbAN.js +2404 -0
  38. package/dist/browser/src-BrYPVbAN.js.map +1 -0
  39. package/dist/browser/src-t-4wp9-f.js +2400 -0
  40. package/dist/browser/src-t-4wp9-f.js.map +1 -0
  41. package/dist/node/api-types.d.ts +731 -0
  42. package/dist/node/api-types.d.ts.map +1 -0
  43. package/dist/node/api-types.js +281 -0
  44. package/dist/node/api-types.js.map +1 -0
  45. package/dist/node/crypto.d.ts +6 -0
  46. package/dist/node/crypto.d.ts.map +1 -0
  47. package/dist/node/crypto.js +103 -0
  48. package/dist/node/crypto.js.map +1 -0
  49. package/dist/node/definition.d.ts +638 -0
  50. package/dist/node/definition.d.ts.map +1 -0
  51. package/dist/node/definition.js +315 -0
  52. package/dist/node/definition.js.map +1 -0
  53. package/dist/node/oauth.js +124 -0
  54. package/dist/node/oauth.js.map +1 -0
  55. package/dist/node/routes.d.ts +1585 -0
  56. package/dist/node/routes.d.ts.map +1 -0
  57. package/dist/node/routes.js +1100 -0
  58. package/dist/node/routes.js.map +1 -0
  59. package/dist/node/schema.d.ts +99 -0
  60. package/dist/node/schema.d.ts.map +1 -0
  61. package/dist/node/schema.js +16 -0
  62. package/dist/node/schema.js.map +1 -0
  63. package/dist/node/server.d.ts +1585 -0
  64. package/dist/node/server.d.ts.map +1 -0
  65. package/dist/node/server.js +12 -0
  66. package/dist/node/server.js.map +1 -0
  67. package/dist/node/services.d.ts +10 -0
  68. package/dist/node/services.d.ts.map +1 -0
  69. package/dist/node/services.js +304 -0
  70. package/dist/node/services.js.map +1 -0
  71. package/dist/node/webhooks/auth.d.ts +133 -0
  72. package/dist/node/webhooks/auth.d.ts.map +1 -0
  73. package/dist/node/webhooks/auth.js +268 -0
  74. package/dist/node/webhooks/auth.js.map +1 -0
  75. package/dist/node/webhooks/verification.d.ts +102 -0
  76. package/dist/node/webhooks/verification.d.ts.map +1 -0
  77. package/dist/node/webhooks/verification.js +119 -0
  78. package/dist/node/webhooks/verification.js.map +1 -0
  79. package/package.json +136 -3
@@ -0,0 +1,711 @@
1
+ import { StandardSchemaV1 } from "@standard-schema/spec";
2
+ //#region ../fragno/dist/api/internal/path.d.ts
3
+ //#region src/api/internal/path.d.ts
4
+ type SplitPath<T extends string> = T extends `${infer First}/${infer Rest}` ? First extends "" ? SplitPath<Rest> : [First, ...SplitPath<Rest>] : T extends "" ? [] : [T];
5
+ type ExtractParam<T extends string> = T extends `:${infer Name}` ? Name : T extends `**:${infer Name}` ? Name : T extends "**" ? "**" : never;
6
+ type ExtractParamsFromSegments<T extends readonly string[]> = T extends readonly [infer First, ...infer Rest] ? First extends string ? Rest extends readonly string[] ? ExtractParam<First> | ExtractParamsFromSegments<Rest> : ExtractParam<First> : never : never;
7
+ /**
8
+ * Type helper to extract path parameters from a const string path
9
+ *
10
+ * Supports:
11
+ * - Regular paths: "/path" -> never
12
+ * - Named parameters: "/path/:name" -> "name"
13
+ * - Wildcard paths: "/path/foo/**" -> "**"
14
+ * - Named wildcard paths: "/path/foo/**:name" -> "name"
15
+ * - String (narrows): string -> never
16
+ */
17
+ type ExtractPathParams<T extends string, ValueType = string> = ExtractParamsFromSegments<SplitPath<T>> extends never ? Record<string, never> : Record<ExtractParamsFromSegments<SplitPath<T>>, ValueType>;
18
+ /**
19
+ * Same as @see ExtractPathParams, but returns `Record<string, ValueType>` when a string is
20
+ * passed in.
21
+ */
22
+ type ExtractPathParamsOrWiden<T extends string, ValueType = string> = string extends T ? Record<string, ValueType> : ExtractPathParams<T, ValueType>;
23
+ /**
24
+ * Same as @see ExtractPathParamsOrWiden, but returns `undefined` when no path parameters in the
25
+ * const.
26
+ */
27
+ type MaybeExtractPathParamsOrWiden<T extends string, ValueType = string> = HasPathParams<T> extends true ? ExtractPathParamsOrWiden<T, ValueType> : undefined;
28
+ type ExtractPathParamNames<T extends string> = ExtractParamsFromSegments<SplitPath<T>>;
29
+ type HasPathParams<T extends string> = ExtractPathParamNames<T> extends never ? false : true;
30
+ /**
31
+ * Creates a query parameters type where the specified keys are hints (optional)
32
+ * and additional string keys are also allowed.
33
+ *
34
+ * This allows for flexible query parameter typing where:
35
+ * - All hinted parameters are optional
36
+ * - Additional parameters beyond the hints are allowed
37
+ * - Values can be of any specified type (defaults to string)
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * type MyQuery = QueryParamsHint<"page" | "limit", string>;
42
+ * // Allows: { page?: string, limit?: string, [key: string]: string }
43
+ *
44
+ * const query1: MyQuery = {}; // Valid - no params required
45
+ * const query2: MyQuery = { page: "1" }; // Valid - hinted param
46
+ * const query3: MyQuery = { page: "1", sort: "asc" }; // Valid - additional param
47
+ * ```
48
+ */
49
+ type QueryParamsHint<TQueryParameters extends string, ValueType = string> = Partial<Record<TQueryParameters, ValueType>> & Record<string, ValueType | undefined>;
50
+ //#endregion
51
+ //#region ../fragno/dist/util/types-util.d.ts
52
+ //#region src/util/types-util.d.ts
53
+ type InferOr<T, U> = T extends NonNullable<StandardSchemaV1> ? StandardSchemaV1.InferOutput<T> : T extends undefined ? U : U;
54
+ type InferOrUnknown<T> = InferOr<T, unknown>;
55
+ //#endregion
56
+ //#region ../fragno/dist/api/mutable-request-state.d.ts
57
+ //#region src/api/mutable-request-state.d.ts
58
+ /**
59
+ * Holds mutable request state that can be modified by middleware and consumed by handlers.
60
+ *
61
+ * This class provides a structural way for middleware to modify request data:
62
+ * - Path parameters can be modified
63
+ * - Query/search parameters can be modified
64
+ * - Request body can be overridden
65
+ * - Request headers can be modified
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * // In middleware
70
+ * const state = new MutableRequestState({
71
+ * pathParams: { id: "123" },
72
+ * searchParams: new URLSearchParams("?role=user"),
73
+ * body: { name: "John" },
74
+ * headers: new Headers()
75
+ * });
76
+ *
77
+ * // Modify query parameters
78
+ * state.searchParams.set("role", "admin");
79
+ *
80
+ * // Override body
81
+ * state.setBody({ name: "Jane" });
82
+ *
83
+ * // Modify headers
84
+ * state.headers.set("X-Custom", "value");
85
+ * ```
86
+ */
87
+ declare class MutableRequestState {
88
+ #private;
89
+ constructor(config: {
90
+ pathParams: Record<string, string>;
91
+ searchParams: URLSearchParams;
92
+ body: unknown;
93
+ headers: Headers;
94
+ });
95
+ /**
96
+ * Path parameters extracted from the route.
97
+ * Can be modified directly (e.g., `state.pathParams.id = "456"`).
98
+ */
99
+ get pathParams(): Record<string, string>;
100
+ /**
101
+ * URLSearchParams for query parameters.
102
+ * Can be modified using URLSearchParams API (e.g., `state.searchParams.set("key", "value")`).
103
+ */
104
+ get searchParams(): URLSearchParams;
105
+ /**
106
+ * Request headers.
107
+ * Can be modified using Headers API (e.g., `state.headers.set("X-Custom", "value")`).
108
+ */
109
+ get headers(): Headers;
110
+ /**
111
+ * Get the current body value.
112
+ * Returns the override if set, otherwise the initial body.
113
+ */
114
+ get body(): unknown;
115
+ /**
116
+ * Override the request body.
117
+ * This allows middleware to replace the body that will be seen by the handler.
118
+ *
119
+ * @param body - The new body value
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * // In middleware
124
+ * state.setBody({ modifiedField: "new value" });
125
+ * ```
126
+ */
127
+ setBody(body: unknown): void;
128
+ /**
129
+ * Check if the body has been overridden by middleware.
130
+ */
131
+ get hasBodyOverride(): boolean;
132
+ }
133
+ //#endregion
134
+ //#region ../fragno/dist/api/request-input-context.d.ts
135
+ //#region src/api/request-input-context.d.ts
136
+ type ValidatedInputContext<TInputSchema extends StandardSchemaV1 | undefined> = TInputSchema extends undefined ? undefined : {
137
+ schema: TInputSchema;
138
+ valid: () => Promise<TInputSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInputSchema> : unknown>;
139
+ };
140
+ declare class RequestInputContext<TPath extends string = string, TInputSchema extends StandardSchemaV1 | undefined = undefined> {
141
+ #private;
142
+ constructor(config: {
143
+ path: TPath;
144
+ method: string;
145
+ pathParams: ExtractPathParams<TPath>;
146
+ searchParams: URLSearchParams;
147
+ parsedBody: unknown;
148
+ rawBody?: string;
149
+ headers: Headers;
150
+ request?: Request;
151
+ inputSchema?: TInputSchema;
152
+ shouldValidateInput?: boolean;
153
+ });
154
+ /**
155
+ * Create a RequestContext from a Request object for server-side handling
156
+ */
157
+ static fromRequest<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
158
+ request: Request;
159
+ method: string;
160
+ path: TPath;
161
+ pathParams: ExtractPathParams<TPath>;
162
+ inputSchema?: TInputSchema;
163
+ shouldValidateInput?: boolean;
164
+ state: MutableRequestState;
165
+ rawBody?: string;
166
+ }): Promise<RequestInputContext<TPath, TInputSchema>>;
167
+ /**
168
+ * Create a RequestContext for server-side rendering contexts (no Request object)
169
+ */
170
+ static fromSSRContext<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
171
+ method: "GET";
172
+ path: TPath;
173
+ pathParams: ExtractPathParams<TPath>;
174
+ searchParams?: URLSearchParams;
175
+ headers?: Headers;
176
+ } | {
177
+ method: Exclude<HTTPMethod, "GET">;
178
+ path: TPath;
179
+ pathParams: ExtractPathParams<TPath>;
180
+ searchParams?: URLSearchParams;
181
+ headers?: Headers;
182
+ body: unknown;
183
+ inputSchema?: TInputSchema;
184
+ }): RequestInputContext<TPath, TInputSchema>;
185
+ /**
186
+ * The HTTP method as string (e.g., `GET`, `POST`)
187
+ */
188
+ get method(): string;
189
+ /**
190
+ * The matched route path (e.g., `/users/:id`)
191
+ * @remarks `string`
192
+ */
193
+ get path(): TPath;
194
+ /**
195
+ * Extracted path parameters as object (e.g., `{ id: '123' }`)
196
+ * @remarks `Record<string, string>`
197
+ */
198
+ get pathParams(): ExtractPathParams<TPath>;
199
+ /**
200
+ * [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object for query parameters
201
+ * @remarks `URLSearchParams`
202
+ */
203
+ get query(): URLSearchParams;
204
+ /**
205
+ * [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object for request headers
206
+ * @remarks `Headers`
207
+ */
208
+ get headers(): Headers;
209
+ get rawBody(): string | undefined;
210
+ get request(): Request | undefined;
211
+ /**
212
+ * Access the request body as FormData.
213
+ *
214
+ * Use this method when handling file uploads or multipart form submissions.
215
+ * The request must have been sent with Content-Type: multipart/form-data.
216
+ *
217
+ * @throws Error if the request body is not FormData
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * defineRoute({
222
+ * method: "POST",
223
+ * path: "/upload",
224
+ * async handler(ctx, res) {
225
+ * const formData = ctx.formData();
226
+ * const file = formData.get("file") as File;
227
+ * const description = formData.get("description") as string;
228
+ * // ... process file
229
+ * }
230
+ * });
231
+ * ```
232
+ */
233
+ formData(): FormData;
234
+ /**
235
+ * Check if the request body is FormData.
236
+ *
237
+ * Useful for routes that accept both JSON and FormData payloads.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * defineRoute({
242
+ * method: "POST",
243
+ * path: "/upload",
244
+ * async handler(ctx, res) {
245
+ * if (ctx.isFormData()) {
246
+ * const formData = ctx.formData();
247
+ * // handle file upload
248
+ * } else {
249
+ * const json = await ctx.input.valid();
250
+ * // handle JSON payload
251
+ * }
252
+ * }
253
+ * });
254
+ * ```
255
+ */
256
+ isFormData(): boolean;
257
+ /**
258
+ * Access the request body as a ReadableStream (application/octet-stream).
259
+ *
260
+ * @throws Error if the request body is not a ReadableStream
261
+ */
262
+ bodyStream(): ReadableStream<Uint8Array>;
263
+ /**
264
+ * Check if the request body is a ReadableStream.
265
+ */
266
+ isBodyStream(): boolean;
267
+ /**
268
+ * Input validation context (only if inputSchema is defined)
269
+ * @remarks `InputContext`
270
+ */
271
+ get input(): ValidatedInputContext<TInputSchema>;
272
+ }
273
+ //#endregion
274
+ //#region ../fragno/dist/http/http-status.d.ts
275
+ //#region src/http/http-status.d.ts
276
+ /**
277
+ * @module
278
+ * HTTP Status utility.
279
+ *
280
+ * Modified from honojs/hono
281
+ * Original source: https://github.com/honojs/hono/blob/0e3db674ad3f40be215a55a18062dd8e387ce525/src/utils/http-status.ts
282
+ * License: MIT
283
+ * Date obtained: August 28 2025
284
+ * Copyright (c) 2021-present Yusuke Wada and Hono contributors
285
+ *
286
+ */
287
+ type InfoStatusCode = 100 | 101 | 102 | 103;
288
+ type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
289
+ type DeprecatedStatusCode = 305 | 306;
290
+ type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
291
+ type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
292
+ type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
293
+ /**
294
+ * If you want to use an unofficial status, use `UnofficialStatusCode`.
295
+ */
296
+ type StatusCode = InfoStatusCode | SuccessStatusCode | RedirectStatusCode | ClientErrorStatusCode | ServerErrorStatusCode;
297
+ type ContentlessStatusCode = 101 | 204 | 205 | 304;
298
+ //#endregion
299
+ //#region ../fragno/dist/api/internal/response-stream.d.ts
300
+ //#region src/api/internal/response-stream.d.ts
301
+ /**
302
+ * @module
303
+ * Stream utility.
304
+ *
305
+ * Modified from honojs/hono
306
+ * Original source: https://github.com/honojs/hono/blob/0e3db674ad3f40be215a55a18062dd8e387ce525/src/utils/stream.ts
307
+ * License: MIT
308
+ * Date obtained: August 28 2025
309
+ * Copyright (c) 2021-present Yusuke Wada and Hono contributors
310
+ */
311
+ type Error$1<Message extends string> = {
312
+ __errorMessage: Message;
313
+ };
314
+ declare class ResponseStream<TArray> {
315
+ #private;
316
+ /**
317
+ * Whether the stream has been aborted.
318
+ */
319
+ get aborted(): boolean;
320
+ /**
321
+ * Whether the stream has been closed normally.
322
+ */
323
+ get closed(): boolean;
324
+ /**
325
+ * The readable stream that the response is piped to.
326
+ */
327
+ get responseReadable(): ReadableStream;
328
+ constructor(writable: WritableStream, readable: ReadableStream);
329
+ writeRaw(input: Uint8Array | string): Promise<void>;
330
+ write(input: TArray extends (infer U)[] ? U : Error$1<"To use a streaming response, outputSchema must be an array.">): Promise<void>;
331
+ sleep(ms: number): Promise<unknown>;
332
+ close(): Promise<void>;
333
+ onAbort(listener: () => void | Promise<void>): void;
334
+ /**
335
+ * Abort the stream.
336
+ * You can call this method when stream is aborted by external event.
337
+ */
338
+ abort(): Promise<void>;
339
+ }
340
+ //#endregion
341
+ //#region ../fragno/dist/api/request-output-context.d.ts
342
+ //#region src/api/request-output-context.d.ts
343
+ interface ResponseInit<T extends StatusCode = StatusCode> {
344
+ headers?: HeadersInit;
345
+ status?: T;
346
+ statusText?: string;
347
+ }
348
+ type JsonStreamCallbackRunner = (callback: () => void | Promise<void>) => void | Promise<void>;
349
+ type OutputContextOptions = {
350
+ runJsonStreamCallback?: JsonStreamCallbackRunner;
351
+ };
352
+ declare abstract class OutputContext<const TOutput, const TErrorCode extends string> {
353
+ #private;
354
+ constructor(options?: OutputContextOptions);
355
+ /**
356
+ * Creates an error response.
357
+ *
358
+ * Shortcut for `throw new FragnoApiError(...)`
359
+ */
360
+ error: ({ message, code }: {
361
+ message: string;
362
+ code: TErrorCode;
363
+ }, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
364
+ empty: (initOrStatus?: ResponseInit<ContentlessStatusCode> | ContentlessStatusCode, headers?: HeadersInit) => Response;
365
+ json: (object: TOutput, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
366
+ jsonStream: (cb: (stream: ResponseStream<TOutput>) => void | Promise<void>, { onError, headers }?: {
367
+ onError?: (error: Error, stream: ResponseStream<TOutput>) => void | Promise<void>;
368
+ headers?: HeadersInit;
369
+ }) => Response;
370
+ }
371
+ declare class RequestOutputContext<const TOutputSchema extends StandardSchemaV1 | undefined = undefined, const TErrorCode extends string = string> extends OutputContext<InferOrUnknown<TOutputSchema>, TErrorCode> {
372
+ #private;
373
+ constructor(outputSchema?: TOutputSchema, options?: OutputContextOptions);
374
+ }
375
+ //#endregion
376
+ //#region ../fragno/dist/api/shared-types.d.ts
377
+ /**
378
+ * Configuration for custom fetch behavior in client-side fragments.
379
+ */
380
+ type FetcherConfig = {
381
+ type: "options";
382
+ options: RequestInit;
383
+ } | {
384
+ type: "function";
385
+ fetcher: typeof fetch;
386
+ /**
387
+ * Use this fetcher even when `window` is undefined.
388
+ * By default, server-side clients call route handlers directly for SSR.
389
+ */
390
+ useOnServer?: boolean;
391
+ };
392
+ /**
393
+ * Public configuration for Fragno fragments on the client side.
394
+ */
395
+ interface FragnoPublicClientConfig {
396
+ mountRoute?: string;
397
+ baseUrl?: string;
398
+ fetcherConfig?: FetcherConfig;
399
+ }
400
+ //#endregion
401
+ //#region ../fragno/dist/api/api.d.ts
402
+ //#region src/api/api.d.ts
403
+ type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
404
+ type NonGetHTTPMethod = Exclude<HTTPMethod, "GET">;
405
+ interface RequestThisContext {}
406
+ /**
407
+ * Content types that can be accepted by a route.
408
+ *
409
+ * - `"application/json"` (default): JSON request body, validated against inputSchema
410
+ * - `"multipart/form-data"`: FormData request body (file uploads), no schema validation
411
+ */
412
+ type RouteContentType = "application/json" | "multipart/form-data" | "application/octet-stream";
413
+ interface FragnoRouteConfig<TMethod extends HTTPMethod, TPath extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string = string, TQueryParameters extends string = string, TThisContext extends RequestThisContext = RequestThisContext> {
414
+ method: TMethod;
415
+ path: TPath;
416
+ /**
417
+ * The expected content type for this route's request body.
418
+ *
419
+ * - `"application/json"` (default): Expects JSON body, will be validated against inputSchema
420
+ * - `"multipart/form-data"`: Expects FormData body (for file uploads), use `ctx.formData()` in handler
421
+ *
422
+ * The server will reject requests with mismatched Content-Type headers.
423
+ *
424
+ * @default "application/json"
425
+ */
426
+ contentType?: RouteContentType;
427
+ inputSchema?: TInputSchema;
428
+ outputSchema?: TOutputSchema;
429
+ errorCodes?: readonly TErrorCode[];
430
+ queryParameters?: readonly TQueryParameters[];
431
+ handler(this: TThisContext, inputCtx: RequestInputContext<TPath, TInputSchema>, outputCtx: RequestOutputContext<TOutputSchema, TErrorCode>): Promise<Response>;
432
+ }
433
+ //#endregion
434
+ //#region ../fragno/dist/client/client-error.d.ts
435
+ //#region src/client/client-error.d.ts
436
+ type FragnoErrorOptions = {
437
+ cause?: unknown;
438
+ };
439
+ /**
440
+ * Base error class for all Fragno client errors.
441
+ */
442
+ declare abstract class FragnoClientError<TCode extends string = string> extends Error {
443
+ #private;
444
+ constructor(message: string, code: TCode, options?: FragnoErrorOptions);
445
+ get code(): TCode | (string & {});
446
+ }
447
+ declare class FragnoClientFetchError extends FragnoClientError<"NO_BODY" | "NETWORK_ERROR" | "ABORT_ERROR"> {
448
+ constructor(message: string, code: "NO_BODY" | "NETWORK_ERROR" | "ABORT_ERROR", options?: FragnoErrorOptions);
449
+ static fromUnknownFetchError(error: unknown): FragnoClientFetchError;
450
+ }
451
+ /**
452
+ * Error thrown when the API result is unexpected, e.g. no json is returned.
453
+ */
454
+ declare class FragnoClientUnknownApiError extends FragnoClientError<"UNKNOWN_API_ERROR"> {
455
+ #private;
456
+ constructor(message: string | undefined, status: StatusCode, options?: FragnoErrorOptions);
457
+ get status(): StatusCode;
458
+ }
459
+ declare class FragnoClientApiError<TErrorCode extends string = string> extends FragnoClientError<TErrorCode> {
460
+ #private;
461
+ constructor({ message, code }: {
462
+ message: string;
463
+ code: TErrorCode;
464
+ }, status: StatusCode, options?: FragnoErrorOptions);
465
+ get status(): StatusCode;
466
+ /**
467
+ * The error code returned by the API.
468
+ *
469
+ * The type is `TErrorCode` (the set of known error codes for this route), but may also be a string
470
+ * for forward compatibility with future error codes.
471
+ */
472
+ get code(): TErrorCode | (string & {});
473
+ static fromResponse<TErrorCode extends string = string>(response: Response): Promise<FragnoClientApiError<TErrorCode> | FragnoClientUnknownApiError>;
474
+ }
475
+ type FragnoClientRequestError<TErrorCode extends string = string> = FragnoClientApiError<TErrorCode> | FragnoClientFetchError | FragnoClientUnknownApiError;
476
+ //#endregion
477
+ //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/atom/index.d.ts
478
+ type AllKeys<T> = T extends any ? keyof T : never;
479
+ type Primitive = boolean | number | string;
480
+ type ReadonlyIfObject<Value> = Value extends undefined ? Value : Value extends ((...args: any) => any) ? Value : Value extends Primitive ? Value : Value extends object ? Readonly<Value> : Value;
481
+ /**
482
+ * Store object.
483
+ */
484
+ interface ReadableAtom<Value = any> {
485
+ /**
486
+ * Get store value.
487
+ *
488
+ * In contrast with {@link ReadableAtom#value} this value will be always
489
+ * initialized even if store had no listeners.
490
+ *
491
+ * ```js
492
+ * $store.get()
493
+ * ```
494
+ *
495
+ * @returns Store value.
496
+ */
497
+ get(): Value;
498
+ /**
499
+ * Low-level attribute to read store’s initial value.
500
+ */
501
+ readonly init: undefined | Value;
502
+ /**
503
+ * Listeners count.
504
+ */
505
+ readonly lc: number;
506
+ /**
507
+ * Subscribe to store changes.
508
+ *
509
+ * In contrast with {@link Store#subscribe} it do not call listener
510
+ * immediately.
511
+ *
512
+ * @param listener Callback with store value and old value.
513
+ * @returns Function to remove listener.
514
+ */
515
+ listen(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value>) => void): () => void;
516
+ /**
517
+ * Low-level method to notify listeners about changes in the store.
518
+ *
519
+ * Can cause unexpected behaviour when combined with frontend frameworks
520
+ * that perform equality checks for values, such as React.
521
+ */
522
+ notify(oldValue?: ReadonlyIfObject<Value>): void;
523
+ /**
524
+ * Unbind all listeners.
525
+ */
526
+ off(): void;
527
+ /**
528
+ * Subscribe to store changes and call listener immediately.
529
+ *
530
+ * ```
531
+ * import { $router } from '../store'
532
+ *
533
+ * $router.subscribe(page => {
534
+ * console.log(page)
535
+ * })
536
+ * ```
537
+ *
538
+ * @param listener Callback with store value and old value.
539
+ * @returns Function to remove listener.
540
+ */
541
+ subscribe(listener: (value: ReadonlyIfObject<Value>, oldValue?: ReadonlyIfObject<Value>) => void): () => void;
542
+ /**
543
+ * Low-level method to read store’s value without calling `onStart`.
544
+ *
545
+ * Try to use only {@link ReadableAtom#get}.
546
+ * Without subscribers, value can be undefined.
547
+ */
548
+ readonly value: undefined | Value;
549
+ }
550
+ /**
551
+ * Store with a way to manually change the value.
552
+ */
553
+ interface WritableAtom<Value = any> extends ReadableAtom<Value> {
554
+ /**
555
+ * Change store value.
556
+ *
557
+ * ```js
558
+ * $router.set({ path: location.pathname, page: parse(location.pathname) })
559
+ * ```
560
+ *
561
+ * @param newValue New store value.
562
+ */
563
+ set(newValue: Value): void;
564
+ }
565
+ //#endregion
566
+ //#region ../../node_modules/.pnpm/nanostores@1.3.0/node_modules/nanostores/map/index.d.ts
567
+ type KeyofBase = keyof any;
568
+ type Get<T, K extends KeyofBase> = Extract<T, { [K1 in K]: any; }>[K];
569
+ type HasIndexSignature<T> = string extends keyof T ? true : false;
570
+ type ValueWithUndefinedForIndexSignatures<Value, Key extends keyof Value> = HasIndexSignature<Value> extends true ? undefined | Value[Key] : Value[Key];
571
+ interface MapStore<Value extends object = any> extends WritableAtom<Value> {
572
+ /**
573
+ * Subscribe to store changes.
574
+ *
575
+ * In contrast with {@link Store#subscribe} it do not call listener
576
+ * immediately.
577
+ *
578
+ * @param listener Callback with store value and old value.
579
+ * @param changedKey Key that was changed. Will present only if `setKey`
580
+ * has been used to change a store.
581
+ * @returns Function to remove listener.
582
+ */
583
+ listen(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value>, changedKey: AllKeys<Value>) => void): () => void;
584
+ /**
585
+ * Low-level method to notify listeners about changes in the store.
586
+ *
587
+ * Can cause unexpected behaviour when combined with frontend frameworks
588
+ * that perform equality checks for values, such as React.
589
+ */
590
+ notify(oldValue?: ReadonlyIfObject<Value>, changedKey?: AllKeys<Value>): void;
591
+ /**
592
+ * Change store value.
593
+ *
594
+ * ```js
595
+ * $settings.set({ theme: 'dark' })
596
+ * ```
597
+ *
598
+ * Operation is atomic, subscribers will be notified once with the new value.
599
+ * `changedKey` will be undefined
600
+ *
601
+ * @param newValue New store value.
602
+ */
603
+ set(newValue: Value): void;
604
+ /**
605
+ * Change key in store value.
606
+ *
607
+ * ```js
608
+ * $settings.setKey('theme', 'dark')
609
+ * ```
610
+ *
611
+ * To delete key set `undefined`.
612
+ *
613
+ * ```js
614
+ * $settings.setKey('theme', undefined)
615
+ * ```
616
+ *
617
+ * @param key The key name.
618
+ * @param value New value.
619
+ */
620
+ setKey<Key extends AllKeys<Value>>(key: Key, value: Get<Value, Key> | ValueWithUndefinedForIndexSignatures<Value, Key>): void;
621
+ /**
622
+ * Subscribe to store changes and call listener immediately.
623
+ *
624
+ * ```
625
+ * import { $router } from '../store'
626
+ *
627
+ * $router.subscribe(page => {
628
+ * console.log(page)
629
+ * })
630
+ * ```
631
+ *
632
+ * @param listener Callback with store value and old value.
633
+ * @param changedKey Key that was changed. Will present only
634
+ * if `setKey` has been used to change a store.
635
+ * @returns Function to remove listener.
636
+ */
637
+ subscribe(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value> | undefined, changedKey: AllKeys<Value> | undefined) => void): () => void;
638
+ }
639
+ //#endregion
640
+ //#region ../../node_modules/.pnpm/@nanostores+query@0.3.4_nanostores@1.3.0/node_modules/@nanostores/query/dist/factory.d.ts
641
+ type Key = string;
642
+ type FetcherValue<T = any, E = Error> = {
643
+ data?: T;
644
+ error?: E;
645
+ loading: boolean;
646
+ promise?: Promise<T>;
647
+ };
648
+ type LazyFetchValue<T = any, E = any> = {
649
+ data: T;
650
+ } | {
651
+ error: E;
652
+ };
653
+ type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>> & {
654
+ _: Symbol;
655
+ key?: Key;
656
+ invalidate: (...args: any[]) => void;
657
+ revalidate: (...args: any[]) => void;
658
+ mutate: (data?: T) => void;
659
+ fetch: () => Promise<LazyFetchValue<T, E>>;
660
+ };
661
+ type MutateCb<Data, Result = unknown> = Data extends void ? () => Promise<Result> : (data: Data) => Promise<Result>;
662
+ type MutatorStore<Data = void, Result = unknown, E = Error> = MapStore<{
663
+ mutate: MutateCb<Data, Result>;
664
+ data?: Result;
665
+ loading?: boolean;
666
+ error?: E;
667
+ }> & {
668
+ mutate: MutateCb<Data, Result>;
669
+ };
670
+ //#endregion
671
+ //#region ../fragno/dist/client/client.d.ts
672
+ //#region src/client/client.d.ts
673
+ /**
674
+ * Symbols used to identify hook types
675
+ */
676
+ declare const GET_HOOK_SYMBOL: unique symbol;
677
+ declare const MUTATOR_HOOK_SYMBOL: unique symbol;
678
+ type FragnoClientHookData<TMethod extends HTTPMethod, TPath extends string, TOutputSchema extends StandardSchemaV1, TErrorCode extends string, TQueryParameters extends string> = {
679
+ route: FragnoRouteConfig<TMethod, TPath, StandardSchemaV1 | undefined, TOutputSchema, TErrorCode, TQueryParameters>;
680
+ query(args?: {
681
+ path?: MaybeExtractPathParamsOrWiden<TPath>;
682
+ query?: Record<TQueryParameters, string | undefined>;
683
+ }): Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;
684
+ store(args?: {
685
+ path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
686
+ query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
687
+ }): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema>, FragnoClientRequestError<TErrorCode>>;
688
+ [GET_HOOK_SYMBOL]: true;
689
+ } & {
690
+ readonly _outputSchema?: TOutputSchema;
691
+ };
692
+ type FragnoClientMutatorData<TMethod extends NonGetHTTPMethod, TPath extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string, TQueryParameters extends string> = {
693
+ route: FragnoRouteConfig<TMethod, TPath, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
694
+ mutateQuery(args?: {
695
+ body?: InferOr<TInputSchema, undefined>;
696
+ path?: MaybeExtractPathParamsOrWiden<TPath>;
697
+ query?: Record<TQueryParameters, string | undefined>;
698
+ }): Promise<InferOr<TOutputSchema, undefined>>;
699
+ mutatorStore: MutatorStore<{
700
+ body?: InferOr<TInputSchema, undefined>;
701
+ path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
702
+ query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
703
+ }, InferOr<TOutputSchema, undefined>, FragnoClientRequestError<TErrorCode>>;
704
+ [MUTATOR_HOOK_SYMBOL]: true;
705
+ } & {
706
+ readonly _inputSchema?: TInputSchema;
707
+ readonly _outputSchema?: TOutputSchema;
708
+ };
709
+ //#endregion
710
+ export { FragnoClientRequestError as a, InferOr as c, MaybeExtractPathParamsOrWiden as d, QueryParamsHint as f, ReadableAtom as i, ExtractPathParamsOrWiden as l, FragnoClientMutatorData as n, NonGetHTTPMethod as o, FetcherValue as r, FragnoPublicClientConfig as s, FragnoClientHookData as t, HasPathParams as u };
711
+ //# sourceMappingURL=client-DQE0c7GI.d.ts.map