@sveltejs/kit 1.0.0-next.47 → 1.0.0-next.472
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/README.md +12 -9
- package/package.json +93 -64
- package/scripts/special-types/$env+dynamic+private.md +8 -0
- package/scripts/special-types/$env+dynamic+public.md +8 -0
- package/scripts/special-types/$env+static+private.md +19 -0
- package/scripts/special-types/$env+static+public.md +7 -0
- package/scripts/special-types/$lib.md +1 -0
- package/src/cli.js +112 -0
- package/src/constants.js +7 -0
- package/src/core/adapt/builder.js +207 -0
- package/src/core/adapt/index.js +31 -0
- package/src/core/config/default-error.html +56 -0
- package/src/core/config/index.js +105 -0
- package/src/core/config/options.js +492 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/env.js +121 -0
- package/src/core/generate_manifest/index.js +92 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +431 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +472 -0
- package/src/core/sync/create_manifest_data/types.d.ts +37 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +33 -0
- package/src/core/sync/write_ambient.js +53 -0
- package/src/core/sync/write_client_manifest.js +94 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +91 -0
- package/src/core/sync/write_tsconfig.js +195 -0
- package/src/core/sync/write_types/index.js +673 -0
- package/src/core/utils.js +70 -0
- package/src/exports/hooks/index.js +1 -0
- package/src/exports/hooks/sequence.js +44 -0
- package/src/exports/index.js +54 -0
- package/src/exports/node/index.js +145 -0
- package/src/exports/node/polyfills.js +41 -0
- package/src/exports/vite/build/build_server.js +357 -0
- package/src/exports/vite/build/build_service_worker.js +90 -0
- package/src/exports/vite/build/utils.js +162 -0
- package/src/exports/vite/dev/index.js +554 -0
- package/src/exports/vite/index.js +591 -0
- package/src/exports/vite/preview/index.js +186 -0
- package/src/exports/vite/types.d.ts +3 -0
- package/src/exports/vite/utils.js +361 -0
- package/src/runtime/app/env.js +1 -0
- package/src/runtime/app/environment.js +11 -0
- package/src/runtime/app/forms.js +65 -0
- package/src/runtime/app/navigation.js +23 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +102 -0
- package/src/runtime/client/ambient.d.ts +24 -0
- package/src/runtime/client/client.js +1558 -0
- package/src/runtime/client/fetcher.js +107 -0
- package/src/runtime/client/parse.js +60 -0
- package/src/runtime/client/singletons.js +21 -0
- package/src/runtime/client/start.js +37 -0
- package/src/runtime/client/types.d.ts +87 -0
- package/src/runtime/client/utils.js +159 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/control.js +100 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +6 -0
- package/src/runtime/env-public.js +6 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/cookie.js +76 -0
- package/src/runtime/server/data/index.js +146 -0
- package/src/runtime/server/endpoint.js +66 -0
- package/src/runtime/server/index.js +339 -0
- package/src/runtime/server/page/actions.js +225 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +249 -0
- package/src/runtime/server/page/fetch.js +286 -0
- package/src/runtime/server/page/index.js +308 -0
- package/src/runtime/server/page/load_data.js +124 -0
- package/src/runtime/server/page/render.js +359 -0
- package/src/runtime/server/page/respond_with_error.js +92 -0
- package/src/runtime/server/page/serialize_data.js +87 -0
- package/src/runtime/server/page/types.d.ts +41 -0
- package/src/runtime/server/utils.js +220 -0
- package/src/utils/array.js +9 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +46 -0
- package/src/utils/filesystem.js +108 -0
- package/src/utils/functions.js +16 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +117 -0
- package/src/utils/url.js +142 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +404 -0
- package/types/index.d.ts +396 -0
- package/types/internal.d.ts +377 -0
- package/types/private.d.ts +210 -0
- package/CHANGELOG.md +0 -463
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -44
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -22
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -773
- package/assets/runtime/paths.js +0 -12
- package/dist/chunks/index.js +0 -3517
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -530
- package/dist/chunks/index5.js +0 -763
- package/dist/chunks/index6.js +0 -322
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -553
- package/dist/ssr.js +0 -2581
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="vite/client" />
|
|
3
|
+
|
|
4
|
+
import './ambient.js';
|
|
5
|
+
|
|
6
|
+
import { CompileOptions } from 'svelte/types/compiler/interfaces';
|
|
7
|
+
import {
|
|
8
|
+
AdapterEntry,
|
|
9
|
+
CspDirectives,
|
|
10
|
+
Logger,
|
|
11
|
+
MaybePromise,
|
|
12
|
+
Prerendered,
|
|
13
|
+
PrerenderOnErrorValue,
|
|
14
|
+
RequestOptions,
|
|
15
|
+
RouteDefinition,
|
|
16
|
+
TrailingSlash
|
|
17
|
+
} from './private.js';
|
|
18
|
+
import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js';
|
|
19
|
+
import { HttpError, Redirect, ValidationError } from '../src/runtime/control.js';
|
|
20
|
+
|
|
21
|
+
export { PrerenderOption } from './private.js';
|
|
22
|
+
|
|
23
|
+
export interface Adapter {
|
|
24
|
+
name: string;
|
|
25
|
+
adapt(builder: Builder): MaybePromise<void>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type AwaitedProperties<input extends Record<string, any> | void> = input extends void
|
|
29
|
+
? undefined // needs to be undefined, because void will break intellisense
|
|
30
|
+
: input extends Record<string, any>
|
|
31
|
+
? {
|
|
32
|
+
[key in keyof input]: Awaited<input[key]>;
|
|
33
|
+
}
|
|
34
|
+
: {} extends input // handles the any case
|
|
35
|
+
? input
|
|
36
|
+
: unknown;
|
|
37
|
+
|
|
38
|
+
export type AwaitedActions<T extends Record<string, (...args: any) => any>> = {
|
|
39
|
+
[Key in keyof T]: UnpackValidationError<Awaited<ReturnType<T[Key]>>>;
|
|
40
|
+
}[keyof T];
|
|
41
|
+
|
|
42
|
+
type UnpackValidationError<T> = T extends ValidationError<infer X> ? X : T;
|
|
43
|
+
|
|
44
|
+
export interface Builder {
|
|
45
|
+
log: Logger;
|
|
46
|
+
rimraf(dir: string): void;
|
|
47
|
+
mkdirp(dir: string): void;
|
|
48
|
+
|
|
49
|
+
config: ValidatedConfig;
|
|
50
|
+
prerendered: Prerendered;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create entry points that map to individual functions
|
|
54
|
+
* @param fn A function that groups a set of routes into an entry point
|
|
55
|
+
*/
|
|
56
|
+
createEntries(fn: (route: RouteDefinition) => AdapterEntry): Promise<void>;
|
|
57
|
+
|
|
58
|
+
generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
|
|
59
|
+
|
|
60
|
+
getBuildDirectory(name: string): string;
|
|
61
|
+
getClientDirectory(): string;
|
|
62
|
+
getServerDirectory(): string;
|
|
63
|
+
getStaticDirectory(): string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param dest the destination folder to which files should be copied
|
|
67
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
68
|
+
*/
|
|
69
|
+
writeClient(dest: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* @param dest
|
|
72
|
+
*/
|
|
73
|
+
writePrerendered(
|
|
74
|
+
dest: string,
|
|
75
|
+
opts?: {
|
|
76
|
+
fallback?: string;
|
|
77
|
+
}
|
|
78
|
+
): string[];
|
|
79
|
+
/**
|
|
80
|
+
* @param dest the destination folder to which files should be copied
|
|
81
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
82
|
+
*/
|
|
83
|
+
writeServer(dest: string): string[];
|
|
84
|
+
/**
|
|
85
|
+
* @param from the source file or folder
|
|
86
|
+
* @param to the destination file or folder
|
|
87
|
+
* @param opts.filter a function to determine whether a file or folder should be copied
|
|
88
|
+
* @param opts.replace a map of strings to replace
|
|
89
|
+
* @returns an array of paths corresponding to the files that have been created by the copy
|
|
90
|
+
*/
|
|
91
|
+
copy(
|
|
92
|
+
from: string,
|
|
93
|
+
to: string,
|
|
94
|
+
opts?: {
|
|
95
|
+
filter?: (basename: string) => boolean;
|
|
96
|
+
replace?: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
): string[];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {string} directory Path to the directory containing the files to be compressed
|
|
102
|
+
*/
|
|
103
|
+
compress(directory: string): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface Config {
|
|
107
|
+
compilerOptions?: CompileOptions;
|
|
108
|
+
extensions?: string[];
|
|
109
|
+
kit?: KitConfig;
|
|
110
|
+
package?: {
|
|
111
|
+
source?: string;
|
|
112
|
+
dir?: string;
|
|
113
|
+
emitTypes?: boolean;
|
|
114
|
+
exports?: (filepath: string) => boolean;
|
|
115
|
+
files?: (filepath: string) => boolean;
|
|
116
|
+
};
|
|
117
|
+
preprocess?: any;
|
|
118
|
+
[key: string]: any;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface Cookies {
|
|
122
|
+
/**
|
|
123
|
+
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
124
|
+
*/
|
|
125
|
+
get(name: string, opts?: import('cookie').CookieParseOptions): string | undefined;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Sets a cookie. This will add a `set-cookie` header to the response, but also make
|
|
129
|
+
* the cookie available via `cookies.get` during the current request.
|
|
130
|
+
*
|
|
131
|
+
* The `httpOnly` and `secure` options are `true` by default, and must be explicitly
|
|
132
|
+
* disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP
|
|
133
|
+
*/
|
|
134
|
+
set(name: string, value: string, opts?: import('cookie').CookieSerializeOptions): void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
138
|
+
*/
|
|
139
|
+
delete(name: string): void;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface KitConfig {
|
|
143
|
+
adapter?: Adapter;
|
|
144
|
+
alias?: Record<string, string>;
|
|
145
|
+
appDir?: string;
|
|
146
|
+
csp?: {
|
|
147
|
+
mode?: 'hash' | 'nonce' | 'auto';
|
|
148
|
+
directives?: CspDirectives;
|
|
149
|
+
reportOnly?: CspDirectives;
|
|
150
|
+
};
|
|
151
|
+
csrf?: {
|
|
152
|
+
checkOrigin?: boolean;
|
|
153
|
+
};
|
|
154
|
+
env?: {
|
|
155
|
+
dir?: string;
|
|
156
|
+
publicPrefix?: string;
|
|
157
|
+
};
|
|
158
|
+
moduleExtensions?: string[];
|
|
159
|
+
files?: {
|
|
160
|
+
assets?: string;
|
|
161
|
+
hooks?: string;
|
|
162
|
+
lib?: string;
|
|
163
|
+
params?: string;
|
|
164
|
+
routes?: string;
|
|
165
|
+
serviceWorker?: string;
|
|
166
|
+
appTemplate?: string;
|
|
167
|
+
errorTemplate?: string;
|
|
168
|
+
};
|
|
169
|
+
inlineStyleThreshold?: number;
|
|
170
|
+
outDir?: string;
|
|
171
|
+
paths?: {
|
|
172
|
+
assets?: string;
|
|
173
|
+
base?: string;
|
|
174
|
+
};
|
|
175
|
+
prerender?: {
|
|
176
|
+
concurrency?: number;
|
|
177
|
+
crawl?: boolean;
|
|
178
|
+
default?: boolean;
|
|
179
|
+
enabled?: boolean;
|
|
180
|
+
entries?: Array<'*' | `/${string}`>;
|
|
181
|
+
onError?: PrerenderOnErrorValue;
|
|
182
|
+
origin?: string;
|
|
183
|
+
};
|
|
184
|
+
serviceWorker?: {
|
|
185
|
+
register?: boolean;
|
|
186
|
+
files?: (filepath: string) => boolean;
|
|
187
|
+
};
|
|
188
|
+
trailingSlash?: TrailingSlash;
|
|
189
|
+
version?: {
|
|
190
|
+
name?: string;
|
|
191
|
+
pollInterval?: number;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface Handle {
|
|
196
|
+
(input: {
|
|
197
|
+
event: RequestEvent;
|
|
198
|
+
resolve(event: RequestEvent, opts?: ResolveOptions): MaybePromise<Response>;
|
|
199
|
+
}): MaybePromise<Response>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface HandleError {
|
|
203
|
+
(input: { error: Error & { frame?: string }; event: RequestEvent }): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface HandleFetch {
|
|
207
|
+
(input: { event: RequestEvent; request: Request; fetch: typeof fetch }): MaybePromise<Response>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The generic form of `PageLoad` and `LayoutLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
212
|
+
* rather than using `Load` directly.
|
|
213
|
+
*/
|
|
214
|
+
export interface Load<
|
|
215
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
216
|
+
InputData extends Record<string, unknown> | null = Record<string, any> | null,
|
|
217
|
+
ParentData extends Record<string, unknown> = Record<string, any>,
|
|
218
|
+
OutputData extends Record<string, unknown> | void = Record<string, any> | void
|
|
219
|
+
> {
|
|
220
|
+
(event: LoadEvent<Params, InputData, ParentData>): MaybePromise<OutputData>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface LoadEvent<
|
|
224
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
225
|
+
Data extends Record<string, unknown> | null = Record<string, any> | null,
|
|
226
|
+
ParentData extends Record<string, unknown> = Record<string, any>
|
|
227
|
+
> {
|
|
228
|
+
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
229
|
+
params: Params;
|
|
230
|
+
data: Data;
|
|
231
|
+
routeId: string | null;
|
|
232
|
+
setHeaders: (headers: Record<string, string>) => void;
|
|
233
|
+
url: URL;
|
|
234
|
+
parent: () => Promise<ParentData>;
|
|
235
|
+
depends: (...deps: string[]) => void;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface NavigationTarget {
|
|
239
|
+
params: Record<string, string> | null;
|
|
240
|
+
routeId: string | null;
|
|
241
|
+
url: URL;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export type NavigationType = 'load' | 'unload' | 'link' | 'goto' | 'popstate';
|
|
245
|
+
|
|
246
|
+
export interface Navigation {
|
|
247
|
+
from: NavigationTarget | null;
|
|
248
|
+
to: NavigationTarget | null;
|
|
249
|
+
type: NavigationType;
|
|
250
|
+
delta?: number;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface Page<Params extends Record<string, string> = Record<string, string>> {
|
|
254
|
+
url: URL;
|
|
255
|
+
params: Params;
|
|
256
|
+
routeId: string | null;
|
|
257
|
+
status: number;
|
|
258
|
+
error: HttpError | Error | null;
|
|
259
|
+
data: App.PageData & Record<string, any>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface ParamMatcher {
|
|
263
|
+
(param: string): boolean;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface RequestEvent<
|
|
267
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
268
|
+
> {
|
|
269
|
+
cookies: Cookies;
|
|
270
|
+
getClientAddress: () => string;
|
|
271
|
+
locals: App.Locals;
|
|
272
|
+
params: Params;
|
|
273
|
+
platform: Readonly<App.Platform>;
|
|
274
|
+
request: Request;
|
|
275
|
+
routeId: string | null;
|
|
276
|
+
setHeaders: (headers: Record<string, string>) => void;
|
|
277
|
+
url: URL;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A `(event: RequestEvent) => Response` function exported from a `+server.js` file that corresponds to an HTTP verb (`GET`, `PUT`, `PATCH`, etc) and handles requests with that method.
|
|
282
|
+
*
|
|
283
|
+
* It receives `Params` as the first generic argument, which you can skip by using [generated types](/docs/types#generated-types) instead.
|
|
284
|
+
*/
|
|
285
|
+
export interface RequestHandler<
|
|
286
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>
|
|
287
|
+
> {
|
|
288
|
+
(event: RequestEvent<Params>): MaybePromise<Response>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface ResolveOptions {
|
|
292
|
+
transformPageChunk?: (input: { html: string; done: boolean }) => MaybePromise<string | undefined>;
|
|
293
|
+
filterSerializedResponseHeaders?: (name: string, value: string) => boolean;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export class Server {
|
|
297
|
+
constructor(manifest: SSRManifest);
|
|
298
|
+
init(options: ServerInitOptions): Promise<void>;
|
|
299
|
+
respond(request: Request, options: RequestOptions): Promise<Response>;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface ServerInitOptions {
|
|
303
|
+
env: Record<string, string>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface SSRManifest {
|
|
307
|
+
appDir: string;
|
|
308
|
+
assets: Set<string>;
|
|
309
|
+
mimeTypes: Record<string, string>;
|
|
310
|
+
|
|
311
|
+
/** private fields */
|
|
312
|
+
_: {
|
|
313
|
+
entry: {
|
|
314
|
+
file: string;
|
|
315
|
+
imports: string[];
|
|
316
|
+
stylesheets: string[];
|
|
317
|
+
};
|
|
318
|
+
nodes: SSRNodeLoader[];
|
|
319
|
+
routes: SSRRoute[];
|
|
320
|
+
matchers: () => Promise<Record<string, ParamMatcher>>;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The generic form of `PageServerLoad` and `LayoutServerLoad`. You should import those from `./$types` (see [generated types](https://kit.svelte.dev/docs/types#generated-types))
|
|
326
|
+
* rather than using `ServerLoad` directly.
|
|
327
|
+
*/
|
|
328
|
+
export interface ServerLoad<
|
|
329
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
330
|
+
ParentData extends Record<string, any> = Record<string, any>,
|
|
331
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
332
|
+
> {
|
|
333
|
+
(event: ServerLoadEvent<Params, ParentData>): MaybePromise<OutputData>;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface ServerLoadEvent<
|
|
337
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
338
|
+
ParentData extends Record<string, any> = Record<string, any>
|
|
339
|
+
> extends RequestEvent<Params> {
|
|
340
|
+
parent: () => Promise<ParentData>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface Action<
|
|
344
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
345
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
346
|
+
> {
|
|
347
|
+
(event: RequestEvent<Params>): MaybePromise<OutputData>;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export type Actions<
|
|
351
|
+
Params extends Partial<Record<string, string>> = Partial<Record<string, string>>,
|
|
352
|
+
OutputData extends Record<string, any> | void = Record<string, any> | void
|
|
353
|
+
> = Record<string, Action<Params, OutputData>>;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* When calling a form action via fetch, the response will be one of these shapes.
|
|
357
|
+
*/
|
|
358
|
+
export type ActionResult<
|
|
359
|
+
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
360
|
+
Invalid extends Record<string, unknown> | undefined = Record<string, any>
|
|
361
|
+
> =
|
|
362
|
+
| { type: 'success'; status: number; data?: Success }
|
|
363
|
+
| { type: 'invalid'; status: number; data?: Invalid }
|
|
364
|
+
| { type: 'redirect'; status: number; location: string }
|
|
365
|
+
| { type: 'error'; error: any };
|
|
366
|
+
|
|
367
|
+
// TODO figure out how to just re-export from '../src/index/index.js' without
|
|
368
|
+
// breaking the site
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Creates an `HttpError` object with an HTTP status code and an optional message.
|
|
372
|
+
* This object, if thrown during request handling, will cause SvelteKit to
|
|
373
|
+
* return an error response without invoking `handleError`
|
|
374
|
+
* @param {number} status
|
|
375
|
+
* @param {string | undefined} [message]
|
|
376
|
+
*/
|
|
377
|
+
export function error(status: number, message?: string | undefined): HttpError;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Creates a `Redirect` object. If thrown during request handling, SvelteKit will
|
|
381
|
+
* return a redirect response.
|
|
382
|
+
*/
|
|
383
|
+
export function redirect(status: number, location: string): Redirect;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Generates a JSON `Response` object from the supplied data.
|
|
387
|
+
*/
|
|
388
|
+
export function json(data: any, init?: ResponseInit): Response;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Generates a `ValidationError` object.
|
|
392
|
+
*/
|
|
393
|
+
export function invalid<T extends Record<string, unknown> | undefined>(
|
|
394
|
+
status: number,
|
|
395
|
+
data?: T
|
|
396
|
+
): ValidationError<T>;
|