forked from tobySolutions/svelte-kit-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
159 lines (149 loc) · 4.97 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import { Adapter } from '@sveltejs/kit';
import './ambient.js';
export default function plugin(config?: Config): Adapter;
export interface ServerlessConfig {
/**
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
* @default Same as the build environment
*/
runtime?: `nodejs${number}.x`;
/**
* To which regions to deploy the app. A list of regions.
* More info: https://vercel.com/docs/concepts/edge-network/regions
*/
regions?: string[];
/**
* Maximum execution duration (in seconds) that will be allowed for the Serverless Function.
* Serverless only.
*/
maxDuration?: number;
/**
* Amount of memory (RAM in MB) that will be allocated to the Serverless Function.
* Serverless only.
*/
memory?: number;
/**
* If `true`, this route will always be deployed as its own separate function
*/
split?: boolean;
/**
* [Incremental Static Regeneration](https://vercel.com/docs/concepts/incremental-static-regeneration/overview) configuration.
* Serverless only.
*/
isr?:
| {
/**
* Expiration time (in seconds) before the cached asset will be re-generated by invoking the Serverless Function. Setting the value to `false` means it will never expire.
*/
expiration: number | false;
/**
* Random token that can be provided in the URL to bypass the cached version of the asset, by requesting the asset
* with a __prerender_bypass=<token> cookie.
*
* Making a `GET` or `HEAD` request with `x-prerender-revalidate: <token>` will force the asset to be re-validated.
*/
bypassToken?: string;
/**
* List of query string parameter names that will be cached independently. If an empty array, query values are not considered for caching. If undefined each unique query value is cached independently
*/
allowQuery?: string[] | undefined;
}
| false;
}
type ImageFormat = 'image/avif' | 'image/webp';
type RemotePattern = {
protocol?: 'http' | 'https';
hostname: string;
port?: string;
pathname?: string;
};
type ImagesConfig = {
sizes: number[];
domains: string[];
remotePatterns?: RemotePattern[];
minimumCacheTTL?: number; // seconds
formats?: ImageFormat[];
dangerouslyAllowSVG?: boolean;
contentSecurityPolicy?: string;
contentDispositionType?: string;
};
export interface EdgeConfig {
/**
* Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
*/
runtime?: 'edge';
/**
* To which regions to deploy the app. A list of regions or `'all'`.
* More info: https://vercel.com/docs/concepts/edge-network/regions
*/
regions?: string[] | 'all';
/**
* List of packages that should not be bundled into the Edge Function.
* Edge only.
*/
external?: string[];
/**
* If `true`, this route will always be deployed as its own separate function
*/
split?: boolean;
}
export type Config = (EdgeConfig | ServerlessConfig) & {
/**
* https://vercel.com/docs/build-output-api/v3/configuration#images
*/
images?: ImagesConfig;
};
// we copy the RequestContext interface from `@vercel/edge` because that package can't co-exist with `@types/node`.
// see https://github.com/sveltejs/kit/pull/9280#issuecomment-1452110035
/**
* An extension to the standard `Request` object that is passed to every Edge Function.
*
* @example
* ```ts
* import type { RequestContext } from '@vercel/edge';
*
* export default async function handler(request: Request, ctx: RequestContext): Promise<Response> {
* // ctx is the RequestContext
* }
* ```
*/
export interface RequestContext {
/**
* A method that can be used to keep the function running after a response has been sent.
* This is useful when you have an async task that you want to keep running even after the
* response has been sent and the request has ended.
*
* @example
*
* <caption>Sending an internal error to an error tracking service</caption>
*
* ```ts
* import type { RequestContext } from '@vercel/edge';
*
* export async function handleRequest(request: Request, ctx: RequestContext): Promise<Response> {
* try {
* return await myFunctionThatReturnsResponse();
* } catch (e) {
* ctx.waitUntil((async () => {
* // report this error to your error tracking service
* await fetch('https://my-error-tracking-service.com', {
* method: 'POST',
* body: JSON.stringify({
* stack: e.stack,
* message: e.message,
* name: e.name,
* url: request.url,
* }),
* });
* })());
* return new Response('Internal Server Error', { status: 500 });
* }
* }
* ```
*/
waitUntil(
/**
* A promise that will be kept alive until it resolves or rejects.
*/ promise: Promise<unknown>
): void;
}