@fragno-dev/pi-fragment 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.
- package/LICENSE.md +16 -0
- package/README.md +107 -0
- package/bin/run.js +72 -0
- package/dist/browser/client/react.d.ts +264 -0
- package/dist/browser/client/react.d.ts.map +1 -0
- package/dist/browser/client/react.js +84 -0
- package/dist/browser/client/react.js.map +1 -0
- package/dist/browser/client/solid.d.ts +266 -0
- package/dist/browser/client/solid.d.ts.map +1 -0
- package/dist/browser/client/solid.js +122 -0
- package/dist/browser/client/solid.js.map +1 -0
- package/dist/browser/client/svelte.d.ts +261 -0
- package/dist/browser/client/svelte.d.ts.map +1 -0
- package/dist/browser/client/svelte.js +126 -0
- package/dist/browser/client/svelte.js.map +1 -0
- package/dist/browser/client/vanilla.d.ts +238 -0
- package/dist/browser/client/vanilla.d.ts.map +1 -0
- package/dist/browser/client/vanilla.js +11 -0
- package/dist/browser/client/vanilla.js.map +1 -0
- package/dist/browser/client/vue.d.ts +264 -0
- package/dist/browser/client/vue.d.ts.map +1 -0
- package/dist/browser/client/vue.js +125 -0
- package/dist/browser/client/vue.js.map +1 -0
- package/dist/browser/client-Bk-J98pf.d.ts +679 -0
- package/dist/browser/client-Bk-J98pf.d.ts.map +1 -0
- package/dist/browser/factory-DKoO_lRA.js +2470 -0
- package/dist/browser/factory-DKoO_lRA.js.map +1 -0
- package/dist/browser/index.d.ts +776 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +3 -0
- package/dist/cli/cli.d.ts +1 -0
- package/dist/cli/cli.js +10 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/config.d.ts +13 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +64 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/http/client.js +95 -0
- package/dist/cli/http/client.js.map +1 -0
- package/dist/cli/mod.d.ts +62 -0
- package/dist/cli/mod.d.ts.map +1 -0
- package/dist/cli/mod.js +644 -0
- package/dist/cli/mod.js.map +1 -0
- package/dist/cli/render/index.d.ts +23 -0
- package/dist/cli/render/index.d.ts.map +1 -0
- package/dist/cli/render/index.js +37 -0
- package/dist/cli/render/index.js.map +1 -0
- package/dist/node/index.d.ts +10 -0
- package/dist/node/index.js +9 -0
- package/dist/node/pi/clients.d.ts +240 -0
- package/dist/node/pi/clients.d.ts.map +1 -0
- package/dist/node/pi/clients.js +18 -0
- package/dist/node/pi/clients.js.map +1 -0
- package/dist/node/pi/constants.d.ts +9 -0
- package/dist/node/pi/constants.d.ts.map +1 -0
- package/dist/node/pi/constants.js +22 -0
- package/dist/node/pi/constants.js.map +1 -0
- package/dist/node/pi/definition.d.ts +13 -0
- package/dist/node/pi/definition.d.ts.map +1 -0
- package/dist/node/pi/definition.js +10 -0
- package/dist/node/pi/definition.js.map +1 -0
- package/dist/node/pi/dsl.d.ts +24 -0
- package/dist/node/pi/dsl.d.ts.map +1 -0
- package/dist/node/pi/dsl.js +57 -0
- package/dist/node/pi/dsl.js.map +1 -0
- package/dist/node/pi/factory.d.ts +220 -0
- package/dist/node/pi/factory.d.ts.map +1 -0
- package/dist/node/pi/factory.js +12 -0
- package/dist/node/pi/factory.js.map +1 -0
- package/dist/node/pi/mappers.js +47 -0
- package/dist/node/pi/mappers.js.map +1 -0
- package/dist/node/pi/route-schemas.js +112 -0
- package/dist/node/pi/route-schemas.js.map +1 -0
- package/dist/node/pi/types.d.ts +67 -0
- package/dist/node/pi/types.d.ts.map +1 -0
- package/dist/node/pi/workflow.d.ts +31 -0
- package/dist/node/pi/workflow.d.ts.map +1 -0
- package/dist/node/pi/workflow.js +242 -0
- package/dist/node/pi/workflow.js.map +1 -0
- package/dist/node/routes.d.ts +217 -0
- package/dist/node/routes.d.ts.map +1 -0
- package/dist/node/routes.js +328 -0
- package/dist/node/routes.js.map +1 -0
- package/dist/node/schema.js +12 -0
- package/dist/node/schema.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
+
|
|
3
|
+
//#region ../fragno/dist/api/internal/path.d.ts
|
|
4
|
+
//#region src/api/internal/path.d.ts
|
|
5
|
+
type SplitPath<T extends string> = T extends `${infer First}/${infer Rest}` ? First extends "" ? SplitPath<Rest> : [First, ...SplitPath<Rest>] : T extends "" ? [] : [T];
|
|
6
|
+
type ExtractParam<T extends string> = T extends `:${infer Name}` ? Name : T extends `**:${infer Name}` ? Name : T extends "**" ? "**" : never;
|
|
7
|
+
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;
|
|
8
|
+
/**
|
|
9
|
+
* Type helper to extract path parameters from a const string path
|
|
10
|
+
*
|
|
11
|
+
* Supports:
|
|
12
|
+
* - Regular paths: "/path" -> never
|
|
13
|
+
* - Named parameters: "/path/:name" -> "name"
|
|
14
|
+
* - Wildcard paths: "/path/foo/**" -> "**"
|
|
15
|
+
* - Named wildcard paths: "/path/foo/**:name" -> "name"
|
|
16
|
+
* - String (narrows): string -> never
|
|
17
|
+
*/
|
|
18
|
+
type ExtractPathParams<T extends string, ValueType = string> = ExtractParamsFromSegments<SplitPath<T>> extends never ? Record<string, never> : Record<ExtractParamsFromSegments<SplitPath<T>>, ValueType>;
|
|
19
|
+
/**
|
|
20
|
+
* Same as @see ExtractPathParams, but returns `Record<string, ValueType>` when a string is
|
|
21
|
+
* passed in.
|
|
22
|
+
*/
|
|
23
|
+
type ExtractPathParamsOrWiden<T extends string, ValueType = string> = string extends T ? Record<string, ValueType> : ExtractPathParams<T, ValueType>;
|
|
24
|
+
/**
|
|
25
|
+
* Same as @see ExtractPathParamsOrWiden, but returns `undefined` when no path parameters in the
|
|
26
|
+
* const.
|
|
27
|
+
*/
|
|
28
|
+
type MaybeExtractPathParamsOrWiden<T extends string, ValueType = string> = HasPathParams<T> extends true ? ExtractPathParamsOrWiden<T, ValueType> : undefined;
|
|
29
|
+
type ExtractPathParamNames<T extends string> = ExtractParamsFromSegments<SplitPath<T>>;
|
|
30
|
+
type HasPathParams<T extends string> = ExtractPathParamNames<T> extends never ? false : true;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a query parameters type where the specified keys are hints (optional)
|
|
33
|
+
* and additional string keys are also allowed.
|
|
34
|
+
*
|
|
35
|
+
* This allows for flexible query parameter typing where:
|
|
36
|
+
* - All hinted parameters are optional
|
|
37
|
+
* - Additional parameters beyond the hints are allowed
|
|
38
|
+
* - Values can be of any specified type (defaults to string)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* type MyQuery = QueryParamsHint<"page" | "limit", string>;
|
|
43
|
+
* // Allows: { page?: string, limit?: string, [key: string]: string }
|
|
44
|
+
*
|
|
45
|
+
* const query1: MyQuery = {}; // Valid - no params required
|
|
46
|
+
* const query2: MyQuery = { page: "1" }; // Valid - hinted param
|
|
47
|
+
* const query3: MyQuery = { page: "1", sort: "asc" }; // Valid - additional param
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
type QueryParamsHint<TQueryParameters extends string, ValueType = string> = Partial<Record<TQueryParameters, ValueType>> & Record<string, ValueType | undefined>; //#endregion
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../fragno/dist/util/types-util.d.ts
|
|
53
|
+
//#region src/util/types-util.d.ts
|
|
54
|
+
type InferOr<T, U> = T extends NonNullable<StandardSchemaV1> ? StandardSchemaV1.InferOutput<T> : T extends undefined ? U : U;
|
|
55
|
+
type InferOrUnknown<T> = InferOr<T, unknown>; //#endregion
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region ../fragno/dist/api/mutable-request-state.d.ts
|
|
58
|
+
//#region src/api/mutable-request-state.d.ts
|
|
59
|
+
/**
|
|
60
|
+
* Holds mutable request state that can be modified by middleware and consumed by handlers.
|
|
61
|
+
*
|
|
62
|
+
* This class provides a structural way for middleware to modify request data:
|
|
63
|
+
* - Path parameters can be modified
|
|
64
|
+
* - Query/search parameters can be modified
|
|
65
|
+
* - Request body can be overridden
|
|
66
|
+
* - Request headers can be modified
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // In middleware
|
|
71
|
+
* const state = new MutableRequestState({
|
|
72
|
+
* pathParams: { id: "123" },
|
|
73
|
+
* searchParams: new URLSearchParams("?role=user"),
|
|
74
|
+
* body: { name: "John" },
|
|
75
|
+
* headers: new Headers()
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Modify query parameters
|
|
79
|
+
* state.searchParams.set("role", "admin");
|
|
80
|
+
*
|
|
81
|
+
* // Override body
|
|
82
|
+
* state.setBody({ name: "Jane" });
|
|
83
|
+
*
|
|
84
|
+
* // Modify headers
|
|
85
|
+
* state.headers.set("X-Custom", "value");
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare class MutableRequestState {
|
|
89
|
+
#private;
|
|
90
|
+
constructor(config: {
|
|
91
|
+
pathParams: Record<string, string>;
|
|
92
|
+
searchParams: URLSearchParams;
|
|
93
|
+
body: RequestBodyType;
|
|
94
|
+
headers: Headers;
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Path parameters extracted from the route.
|
|
98
|
+
* Can be modified directly (e.g., `state.pathParams.id = "456"`).
|
|
99
|
+
*/
|
|
100
|
+
get pathParams(): Record<string, string>;
|
|
101
|
+
/**
|
|
102
|
+
* URLSearchParams for query parameters.
|
|
103
|
+
* Can be modified using URLSearchParams API (e.g., `state.searchParams.set("key", "value")`).
|
|
104
|
+
*/
|
|
105
|
+
get searchParams(): URLSearchParams;
|
|
106
|
+
/**
|
|
107
|
+
* Request headers.
|
|
108
|
+
* Can be modified using Headers API (e.g., `state.headers.set("X-Custom", "value")`).
|
|
109
|
+
*/
|
|
110
|
+
get headers(): Headers;
|
|
111
|
+
/**
|
|
112
|
+
* Get the current body value.
|
|
113
|
+
* Returns the override if set, otherwise the initial body.
|
|
114
|
+
*/
|
|
115
|
+
get body(): RequestBodyType;
|
|
116
|
+
/**
|
|
117
|
+
* Override the request body.
|
|
118
|
+
* This allows middleware to replace the body that will be seen by the handler.
|
|
119
|
+
*
|
|
120
|
+
* @param body - The new body value
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* // In middleware
|
|
125
|
+
* state.setBody({ modifiedField: "new value" });
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
setBody(body: RequestBodyType): void;
|
|
129
|
+
/**
|
|
130
|
+
* Check if the body has been overridden by middleware.
|
|
131
|
+
*/
|
|
132
|
+
get hasBodyOverride(): boolean;
|
|
133
|
+
} //#endregion
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region ../fragno/dist/api/request-input-context.d.ts
|
|
136
|
+
//#region src/api/request-input-context.d.ts
|
|
137
|
+
type RequestBodyType = unknown | FormData | Blob | ReadableStream<Uint8Array> | null | undefined;
|
|
138
|
+
declare class RequestInputContext<TPath extends string = string, TInputSchema extends StandardSchemaV1 | undefined = undefined> {
|
|
139
|
+
#private;
|
|
140
|
+
constructor(config: {
|
|
141
|
+
path: TPath;
|
|
142
|
+
method: string;
|
|
143
|
+
pathParams: ExtractPathParams<TPath>;
|
|
144
|
+
searchParams: URLSearchParams;
|
|
145
|
+
parsedBody: RequestBodyType;
|
|
146
|
+
rawBody?: string;
|
|
147
|
+
headers: Headers;
|
|
148
|
+
request?: Request;
|
|
149
|
+
inputSchema?: TInputSchema;
|
|
150
|
+
shouldValidateInput?: boolean;
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Create a RequestContext from a Request object for server-side handling
|
|
154
|
+
*/
|
|
155
|
+
static fromRequest<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
156
|
+
request: Request;
|
|
157
|
+
method: string;
|
|
158
|
+
path: TPath;
|
|
159
|
+
pathParams: ExtractPathParams<TPath>;
|
|
160
|
+
inputSchema?: TInputSchema;
|
|
161
|
+
shouldValidateInput?: boolean;
|
|
162
|
+
state: MutableRequestState;
|
|
163
|
+
rawBody?: string;
|
|
164
|
+
}): Promise<RequestInputContext<TPath, TInputSchema>>;
|
|
165
|
+
/**
|
|
166
|
+
* Create a RequestContext for server-side rendering contexts (no Request object)
|
|
167
|
+
*/
|
|
168
|
+
static fromSSRContext<TPath extends string, TInputSchema extends StandardSchemaV1 | undefined = undefined>(config: {
|
|
169
|
+
method: "GET";
|
|
170
|
+
path: TPath;
|
|
171
|
+
pathParams: ExtractPathParams<TPath>;
|
|
172
|
+
searchParams?: URLSearchParams;
|
|
173
|
+
headers?: Headers;
|
|
174
|
+
} | {
|
|
175
|
+
method: Exclude<HTTPMethod, "GET">;
|
|
176
|
+
path: TPath;
|
|
177
|
+
pathParams: ExtractPathParams<TPath>;
|
|
178
|
+
searchParams?: URLSearchParams;
|
|
179
|
+
headers?: Headers;
|
|
180
|
+
body: RequestBodyType;
|
|
181
|
+
inputSchema?: TInputSchema;
|
|
182
|
+
}): RequestInputContext<TPath, TInputSchema>;
|
|
183
|
+
/**
|
|
184
|
+
* The HTTP method as string (e.g., `GET`, `POST`)
|
|
185
|
+
*/
|
|
186
|
+
get method(): string;
|
|
187
|
+
/**
|
|
188
|
+
* The matched route path (e.g., `/users/:id`)
|
|
189
|
+
* @remarks `string`
|
|
190
|
+
*/
|
|
191
|
+
get path(): TPath;
|
|
192
|
+
/**
|
|
193
|
+
* Extracted path parameters as object (e.g., `{ id: '123' }`)
|
|
194
|
+
* @remarks `Record<string, string>`
|
|
195
|
+
*/
|
|
196
|
+
get pathParams(): ExtractPathParams<TPath>;
|
|
197
|
+
/**
|
|
198
|
+
* [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) object for query parameters
|
|
199
|
+
* @remarks `URLSearchParams`
|
|
200
|
+
*/
|
|
201
|
+
get query(): URLSearchParams;
|
|
202
|
+
/**
|
|
203
|
+
* [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object for request headers
|
|
204
|
+
* @remarks `Headers`
|
|
205
|
+
*/
|
|
206
|
+
get headers(): Headers;
|
|
207
|
+
get rawBody(): string | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Access the request body as FormData.
|
|
210
|
+
*
|
|
211
|
+
* Use this method when handling file uploads or multipart form submissions.
|
|
212
|
+
* The request must have been sent with Content-Type: multipart/form-data.
|
|
213
|
+
*
|
|
214
|
+
* @throws Error if the request body is not FormData
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* defineRoute({
|
|
219
|
+
* method: "POST",
|
|
220
|
+
* path: "/upload",
|
|
221
|
+
* async handler(ctx, res) {
|
|
222
|
+
* const formData = ctx.formData();
|
|
223
|
+
* const file = formData.get("file") as File;
|
|
224
|
+
* const description = formData.get("description") as string;
|
|
225
|
+
* // ... process file
|
|
226
|
+
* }
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
formData(): FormData;
|
|
231
|
+
/**
|
|
232
|
+
* Check if the request body is FormData.
|
|
233
|
+
*
|
|
234
|
+
* Useful for routes that accept both JSON and FormData payloads.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* defineRoute({
|
|
239
|
+
* method: "POST",
|
|
240
|
+
* path: "/upload",
|
|
241
|
+
* async handler(ctx, res) {
|
|
242
|
+
* if (ctx.isFormData()) {
|
|
243
|
+
* const formData = ctx.formData();
|
|
244
|
+
* // handle file upload
|
|
245
|
+
* } else {
|
|
246
|
+
* const json = await ctx.input.valid();
|
|
247
|
+
* // handle JSON payload
|
|
248
|
+
* }
|
|
249
|
+
* }
|
|
250
|
+
* });
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
isFormData(): boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Access the request body as a ReadableStream (application/octet-stream).
|
|
256
|
+
*
|
|
257
|
+
* @throws Error if the request body is not a ReadableStream
|
|
258
|
+
*/
|
|
259
|
+
bodyStream(): ReadableStream<Uint8Array>;
|
|
260
|
+
/**
|
|
261
|
+
* Check if the request body is a ReadableStream.
|
|
262
|
+
*/
|
|
263
|
+
isBodyStream(): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Input validation context (only if inputSchema is defined)
|
|
266
|
+
* @remarks `InputContext`
|
|
267
|
+
*/
|
|
268
|
+
get input(): TInputSchema extends undefined ? undefined : {
|
|
269
|
+
schema: TInputSchema;
|
|
270
|
+
valid: () => Promise<TInputSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TInputSchema> : unknown>;
|
|
271
|
+
};
|
|
272
|
+
} //#endregion
|
|
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; //#endregion
|
|
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(): void;
|
|
339
|
+
} //#endregion
|
|
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
|
+
declare abstract class OutputContext<const TOutput, const TErrorCode extends string> {
|
|
349
|
+
/**
|
|
350
|
+
* Creates an error response.
|
|
351
|
+
*
|
|
352
|
+
* Shortcut for `throw new FragnoApiError(...)`
|
|
353
|
+
*/
|
|
354
|
+
error: ({
|
|
355
|
+
message,
|
|
356
|
+
code
|
|
357
|
+
}: {
|
|
358
|
+
message: string;
|
|
359
|
+
code: TErrorCode;
|
|
360
|
+
}, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
|
|
361
|
+
empty: (initOrStatus?: ResponseInit<ContentlessStatusCode> | ContentlessStatusCode, headers?: HeadersInit) => Response;
|
|
362
|
+
json: (object: TOutput, initOrStatus?: ResponseInit | StatusCode, headers?: HeadersInit) => Response;
|
|
363
|
+
jsonStream: (cb: (stream: ResponseStream<TOutput>) => void | Promise<void>, {
|
|
364
|
+
onError,
|
|
365
|
+
headers
|
|
366
|
+
}?: {
|
|
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);
|
|
374
|
+
} //#endregion
|
|
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
|
+
/**
|
|
388
|
+
* Public configuration for Fragno fragments on the client side.
|
|
389
|
+
*/
|
|
390
|
+
interface FragnoPublicClientConfig {
|
|
391
|
+
mountRoute?: string;
|
|
392
|
+
baseUrl?: string;
|
|
393
|
+
fetcherConfig?: FetcherConfig;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Shared configuration for fragment routes.
|
|
397
|
+
*/
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region ../fragno/dist/api/api.d.ts
|
|
400
|
+
//#region src/api/api.d.ts
|
|
401
|
+
type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
402
|
+
type NonGetHTTPMethod = Exclude<HTTPMethod, "GET">;
|
|
403
|
+
interface RequestThisContext {}
|
|
404
|
+
/**
|
|
405
|
+
* Content types that can be accepted by a route.
|
|
406
|
+
*
|
|
407
|
+
* - `"application/json"` (default): JSON request body, validated against inputSchema
|
|
408
|
+
* - `"multipart/form-data"`: FormData request body (file uploads), no schema validation
|
|
409
|
+
*/
|
|
410
|
+
type RouteContentType = "application/json" | "multipart/form-data" | "application/octet-stream";
|
|
411
|
+
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> {
|
|
412
|
+
method: TMethod;
|
|
413
|
+
path: TPath;
|
|
414
|
+
/**
|
|
415
|
+
* The expected content type for this route's request body.
|
|
416
|
+
*
|
|
417
|
+
* - `"application/json"` (default): Expects JSON body, will be validated against inputSchema
|
|
418
|
+
* - `"multipart/form-data"`: Expects FormData body (for file uploads), use `ctx.formData()` in handler
|
|
419
|
+
*
|
|
420
|
+
* The server will reject requests with mismatched Content-Type headers.
|
|
421
|
+
*
|
|
422
|
+
* @default "application/json"
|
|
423
|
+
*/
|
|
424
|
+
contentType?: RouteContentType;
|
|
425
|
+
inputSchema?: TInputSchema;
|
|
426
|
+
outputSchema?: TOutputSchema;
|
|
427
|
+
errorCodes?: readonly TErrorCode[];
|
|
428
|
+
queryParameters?: readonly TQueryParameters[];
|
|
429
|
+
handler(this: TThisContext, inputCtx: RequestInputContext<TPath, TInputSchema>, outputCtx: RequestOutputContext<TOutputSchema, TErrorCode>): Promise<Response>;
|
|
430
|
+
}
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region ../fragno/dist/client/client-error.d.ts
|
|
433
|
+
//#region src/client/client-error.d.ts
|
|
434
|
+
type FragnoErrorOptions = {
|
|
435
|
+
cause?: Error | unknown;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* Base error class for all Fragno client errors.
|
|
439
|
+
*/
|
|
440
|
+
declare abstract class FragnoClientError<TCode extends string = string> extends Error {
|
|
441
|
+
#private;
|
|
442
|
+
constructor(message: string, code: TCode, options?: FragnoErrorOptions);
|
|
443
|
+
get code(): TCode | (string & {});
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.d.ts
|
|
447
|
+
type AllKeys<T> = T extends any ? keyof T : never;
|
|
448
|
+
type Primitive = boolean | number | string;
|
|
449
|
+
type ReadonlyIfObject<Value> = Value extends undefined ? Value : Value extends ((...args: any) => any) ? Value : Value extends Primitive ? Value : Value extends object ? Readonly<Value> : Value;
|
|
450
|
+
/**
|
|
451
|
+
* Store object.
|
|
452
|
+
*/
|
|
453
|
+
interface ReadableAtom<Value = any> {
|
|
454
|
+
/**
|
|
455
|
+
* Get store value.
|
|
456
|
+
*
|
|
457
|
+
* In contrast with {@link ReadableAtom#value} this value will be always
|
|
458
|
+
* initialized even if store had no listeners.
|
|
459
|
+
*
|
|
460
|
+
* ```js
|
|
461
|
+
* $store.get()
|
|
462
|
+
* ```
|
|
463
|
+
*
|
|
464
|
+
* @returns Store value.
|
|
465
|
+
*/
|
|
466
|
+
get(): Value;
|
|
467
|
+
/**
|
|
468
|
+
* Listeners count.
|
|
469
|
+
*/
|
|
470
|
+
readonly lc: number;
|
|
471
|
+
/**
|
|
472
|
+
* Subscribe to store changes.
|
|
473
|
+
*
|
|
474
|
+
* In contrast with {@link Store#subscribe} it do not call listener
|
|
475
|
+
* immediately.
|
|
476
|
+
*
|
|
477
|
+
* @param listener Callback with store value and old value.
|
|
478
|
+
* @returns Function to remove listener.
|
|
479
|
+
*/
|
|
480
|
+
listen(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value>) => void): () => void;
|
|
481
|
+
/**
|
|
482
|
+
* Low-level method to notify listeners about changes in the store.
|
|
483
|
+
*
|
|
484
|
+
* Can cause unexpected behaviour when combined with frontend frameworks
|
|
485
|
+
* that perform equality checks for values, such as React.
|
|
486
|
+
*/
|
|
487
|
+
notify(oldValue?: ReadonlyIfObject<Value>): void;
|
|
488
|
+
/**
|
|
489
|
+
* Unbind all listeners.
|
|
490
|
+
*/
|
|
491
|
+
off(): void;
|
|
492
|
+
/**
|
|
493
|
+
* Subscribe to store changes and call listener immediately.
|
|
494
|
+
*
|
|
495
|
+
* ```
|
|
496
|
+
* import { $router } from '../store'
|
|
497
|
+
*
|
|
498
|
+
* $router.subscribe(page => {
|
|
499
|
+
* console.log(page)
|
|
500
|
+
* })
|
|
501
|
+
* ```
|
|
502
|
+
*
|
|
503
|
+
* @param listener Callback with store value and old value.
|
|
504
|
+
* @returns Function to remove listener.
|
|
505
|
+
*/
|
|
506
|
+
subscribe(listener: (value: ReadonlyIfObject<Value>, oldValue?: ReadonlyIfObject<Value>) => void): () => void;
|
|
507
|
+
/**
|
|
508
|
+
* Low-level method to read store’s value without calling `onStart`.
|
|
509
|
+
*
|
|
510
|
+
* Try to use only {@link ReadableAtom#get}.
|
|
511
|
+
* Without subscribers, value can be undefined.
|
|
512
|
+
*/
|
|
513
|
+
readonly value: undefined | Value;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Store with a way to manually change the value.
|
|
517
|
+
*/
|
|
518
|
+
interface WritableAtom<Value = any> extends ReadableAtom<Value> {
|
|
519
|
+
/**
|
|
520
|
+
* Change store value.
|
|
521
|
+
*
|
|
522
|
+
* ```js
|
|
523
|
+
* $router.set({ path: location.pathname, page: parse(location.pathname) })
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* @param newValue New store value.
|
|
527
|
+
*/
|
|
528
|
+
set(newValue: Value): void;
|
|
529
|
+
}
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/map/index.d.ts
|
|
532
|
+
type KeyofBase = keyof any;
|
|
533
|
+
type Get<T, K extends KeyofBase> = Extract<T, { [K1 in K]: any }>[K];
|
|
534
|
+
type HasIndexSignature<T> = string extends keyof T ? true : false;
|
|
535
|
+
type ValueWithUndefinedForIndexSignatures<Value, Key extends keyof Value> = HasIndexSignature<Value> extends true ? undefined | Value[Key] : Value[Key];
|
|
536
|
+
interface MapStore<Value extends object = any> extends WritableAtom<Value> {
|
|
537
|
+
/**
|
|
538
|
+
* Subscribe to store changes.
|
|
539
|
+
*
|
|
540
|
+
* In contrast with {@link Store#subscribe} it do not call listener
|
|
541
|
+
* immediately.
|
|
542
|
+
*
|
|
543
|
+
* @param listener Callback with store value and old value.
|
|
544
|
+
* @param changedKey Key that was changed. Will present only if `setKey`
|
|
545
|
+
* has been used to change a store.
|
|
546
|
+
* @returns Function to remove listener.
|
|
547
|
+
*/
|
|
548
|
+
listen(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value>, changedKey: AllKeys<Value>) => void): () => void;
|
|
549
|
+
/**
|
|
550
|
+
* Low-level method to notify listeners about changes in the store.
|
|
551
|
+
*
|
|
552
|
+
* Can cause unexpected behaviour when combined with frontend frameworks
|
|
553
|
+
* that perform equality checks for values, such as React.
|
|
554
|
+
*/
|
|
555
|
+
notify(oldValue?: ReadonlyIfObject<Value>, changedKey?: AllKeys<Value>): void;
|
|
556
|
+
/**
|
|
557
|
+
* Change store value.
|
|
558
|
+
*
|
|
559
|
+
* ```js
|
|
560
|
+
* $settings.set({ theme: 'dark' })
|
|
561
|
+
* ```
|
|
562
|
+
*
|
|
563
|
+
* Operation is atomic, subscribers will be notified once with the new value.
|
|
564
|
+
* `changedKey` will be undefined
|
|
565
|
+
*
|
|
566
|
+
* @param newValue New store value.
|
|
567
|
+
*/
|
|
568
|
+
set(newValue: Value): void;
|
|
569
|
+
/**
|
|
570
|
+
* Change key in store value.
|
|
571
|
+
*
|
|
572
|
+
* ```js
|
|
573
|
+
* $settings.setKey('theme', 'dark')
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* To delete key set `undefined`.
|
|
577
|
+
*
|
|
578
|
+
* ```js
|
|
579
|
+
* $settings.setKey('theme', undefined)
|
|
580
|
+
* ```
|
|
581
|
+
*
|
|
582
|
+
* @param key The key name.
|
|
583
|
+
* @param value New value.
|
|
584
|
+
*/
|
|
585
|
+
setKey<Key extends AllKeys<Value>>(key: Key, value: Get<Value, Key> | ValueWithUndefinedForIndexSignatures<Value, Key>): void;
|
|
586
|
+
/**
|
|
587
|
+
* Subscribe to store changes and call listener immediately.
|
|
588
|
+
*
|
|
589
|
+
* ```
|
|
590
|
+
* import { $router } from '../store'
|
|
591
|
+
*
|
|
592
|
+
* $router.subscribe(page => {
|
|
593
|
+
* console.log(page)
|
|
594
|
+
* })
|
|
595
|
+
* ```
|
|
596
|
+
*
|
|
597
|
+
* @param listener Callback with store value and old value.
|
|
598
|
+
* @param changedKey Key that was changed. Will present only
|
|
599
|
+
* if `setKey` has been used to change a store.
|
|
600
|
+
* @returns Function to remove listener.
|
|
601
|
+
*/
|
|
602
|
+
subscribe(listener: (value: ReadonlyIfObject<Value>, oldValue: ReadonlyIfObject<Value> | undefined, changedKey: AllKeys<Value> | undefined) => void): () => void;
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region ../../node_modules/.pnpm/@nanostores+query@0.3.4_nanostores@1.1.0/node_modules/@nanostores/query/dist/factory.d.ts
|
|
606
|
+
type Key = string;
|
|
607
|
+
type FetcherValue<T = any, E = Error> = {
|
|
608
|
+
data?: T;
|
|
609
|
+
error?: E;
|
|
610
|
+
loading: boolean;
|
|
611
|
+
promise?: Promise<T>;
|
|
612
|
+
};
|
|
613
|
+
type LazyFetchValue<T = any, E = any> = {
|
|
614
|
+
data: T;
|
|
615
|
+
} | {
|
|
616
|
+
error: E;
|
|
617
|
+
};
|
|
618
|
+
type FetcherStore<T = any, E = any> = MapStore<FetcherValue<T, E>> & {
|
|
619
|
+
_: Symbol;
|
|
620
|
+
key?: Key;
|
|
621
|
+
invalidate: (...args: any[]) => void;
|
|
622
|
+
revalidate: (...args: any[]) => void;
|
|
623
|
+
mutate: (data?: T) => void;
|
|
624
|
+
fetch: () => Promise<LazyFetchValue<T, E>>;
|
|
625
|
+
};
|
|
626
|
+
type MutateCb<Data, Result = unknown> = Data extends void ? () => Promise<Result> : (data: Data) => Promise<Result>;
|
|
627
|
+
type MutatorStore<Data = void, Result = unknown, E = Error> = MapStore<{
|
|
628
|
+
mutate: MutateCb<Data, Result>;
|
|
629
|
+
data?: Result;
|
|
630
|
+
loading?: boolean;
|
|
631
|
+
error?: E;
|
|
632
|
+
}> & {
|
|
633
|
+
mutate: MutateCb<Data, Result>;
|
|
634
|
+
};
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region ../fragno/dist/client/client.d.ts
|
|
637
|
+
//#region src/client/client.d.ts
|
|
638
|
+
/**
|
|
639
|
+
* Symbols used to identify hook types
|
|
640
|
+
*/
|
|
641
|
+
declare const GET_HOOK_SYMBOL: unique symbol;
|
|
642
|
+
declare const MUTATOR_HOOK_SYMBOL: unique symbol;
|
|
643
|
+
type FragnoClientHookData<TMethod extends HTTPMethod, TPath extends string, TOutputSchema extends StandardSchemaV1, TErrorCode extends string, TQueryParameters extends string> = {
|
|
644
|
+
route: FragnoRouteConfig<TMethod, TPath, StandardSchemaV1 | undefined, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
645
|
+
query(args?: {
|
|
646
|
+
path?: MaybeExtractPathParamsOrWiden<TPath, string>;
|
|
647
|
+
query?: Record<TQueryParameters, string | undefined>;
|
|
648
|
+
}): Promise<StandardSchemaV1.InferOutput<TOutputSchema>>;
|
|
649
|
+
store(args?: {
|
|
650
|
+
path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
|
|
651
|
+
query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
|
|
652
|
+
}): FetcherStore<StandardSchemaV1.InferOutput<TOutputSchema>, FragnoClientError<TErrorCode>>;
|
|
653
|
+
[GET_HOOK_SYMBOL]: true;
|
|
654
|
+
} & {
|
|
655
|
+
readonly _outputSchema?: TOutputSchema;
|
|
656
|
+
};
|
|
657
|
+
type FragnoClientMutatorData<TMethod extends NonGetHTTPMethod, TPath extends string, TInputSchema extends StandardSchemaV1 | undefined, TOutputSchema extends StandardSchemaV1 | undefined, TErrorCode extends string, TQueryParameters extends string> = {
|
|
658
|
+
route: FragnoRouteConfig<TMethod, TPath, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters>;
|
|
659
|
+
mutateQuery(args?: {
|
|
660
|
+
body?: InferOr<TInputSchema, undefined>;
|
|
661
|
+
path?: MaybeExtractPathParamsOrWiden<TPath, string>;
|
|
662
|
+
query?: Record<TQueryParameters, string | undefined>;
|
|
663
|
+
}): Promise<InferOr<TOutputSchema, undefined>>;
|
|
664
|
+
mutatorStore: MutatorStore<{
|
|
665
|
+
body?: InferOr<TInputSchema, undefined>;
|
|
666
|
+
path?: MaybeExtractPathParamsOrWiden<TPath, string | ReadableAtom<string>>;
|
|
667
|
+
query?: Record<TQueryParameters, string | undefined | ReadableAtom<string | undefined>>;
|
|
668
|
+
}, InferOr<TOutputSchema, undefined>, FragnoClientError<TErrorCode>>;
|
|
669
|
+
[MUTATOR_HOOK_SYMBOL]: true;
|
|
670
|
+
} & {
|
|
671
|
+
readonly _inputSchema?: TInputSchema;
|
|
672
|
+
readonly _outputSchema?: TOutputSchema;
|
|
673
|
+
};
|
|
674
|
+
/**
|
|
675
|
+
* @internal
|
|
676
|
+
*/
|
|
677
|
+
//#endregion
|
|
678
|
+
export { FragnoClientError 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 };
|
|
679
|
+
//# sourceMappingURL=client-Bk-J98pf.d.ts.map
|