@sveltejs/kit 3.0.0-next.21 → 3.0.0-next.22
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/package.json +1 -1
- package/src/core/sync/write_types/index.js +1 -3
- package/src/exports/hooks/public.d.ts +1 -2
- package/src/exports/hooks/sequence.js +1 -1
- package/src/exports/internal/server/event.js +1 -1
- package/src/exports/public.d.ts +196 -2
- package/src/exports/vite/dev/index.js +1 -2
- package/src/exports/vite/index.js +2 -2
- package/src/runtime/app/server/public.d.ts +0 -200
- package/src/runtime/app/server/remote/query.js +1 -1
- package/src/runtime/app/server/remote/shared.js +1 -1
- package/src/runtime/server/cookie.js +2 -2
- package/src/runtime/server/data/index.js +1 -1
- package/src/runtime/server/endpoint.js +3 -3
- package/src/runtime/server/errors.js +2 -2
- package/src/runtime/server/fetch.js +1 -1
- package/src/runtime/server/page/actions.js +1 -2
- package/src/runtime/server/page/data_serializer.js +2 -2
- package/src/runtime/server/page/index.js +1 -2
- package/src/runtime/server/page/load_data.js +3 -3
- package/src/runtime/server/page/render.js +1 -1
- package/src/runtime/server/page/respond_with_error.js +1 -1
- package/src/runtime/server/remote-functions.js +1 -2
- package/src/runtime/server/respond.js +2 -2
- package/src/runtime/server/utils.js +1 -1
- package/src/types/internal.d.ts +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +198 -202
- package/types/index.d.ts.map +3 -5
package/package.json
CHANGED
|
@@ -354,9 +354,7 @@ function update_types(config, routes, route, root, to_delete = new Set()) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
if (route.leaf?.server || route.layout?.server || route.endpoint) {
|
|
357
|
-
exports.push(
|
|
358
|
-
"export type RequestEvent = import('$app/server').RequestEvent<RouteParams, RouteId>;"
|
|
359
|
-
);
|
|
357
|
+
exports.push('export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;');
|
|
360
358
|
}
|
|
361
359
|
|
|
362
360
|
const output = [imports.join('\n'), declarations.join('\n'), exports.join('\n')]
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { NavigationEvent } from '@sveltejs/kit';
|
|
3
|
-
import { RequestEvent } from '$app/server';
|
|
2
|
+
import { NavigationEvent, RequestEvent } from '@sveltejs/kit';
|
|
4
3
|
import { MaybePromise } from 'types';
|
|
5
4
|
|
|
6
5
|
export * from './index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RequestEvent } from '
|
|
1
|
+
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
2
2
|
/** @import { RequestStore } from 'types' */
|
|
3
3
|
/** @import { AsyncLocalStorage } from 'node:async_hooks' */
|
|
4
4
|
import { IN_WEBCONTAINER } from '../../../constants.js';
|
package/src/exports/public.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '../types/private.js';
|
|
15
15
|
import { BuildData, SSRNodeLoader, SSRRoute, ValidatedConfig } from 'types';
|
|
16
16
|
import { Plugin } from 'vite';
|
|
17
|
-
import { RequestEvent } from '$app/server';
|
|
18
17
|
import { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
19
18
|
import { ParamMatcher } from '@sveltejs/kit/params';
|
|
20
19
|
|
|
@@ -257,6 +256,80 @@ export interface Builder {
|
|
|
257
256
|
compress: (directory: string) => Promise<string[]>;
|
|
258
257
|
}
|
|
259
258
|
|
|
259
|
+
export interface Cookies {
|
|
260
|
+
/**
|
|
261
|
+
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
262
|
+
* @param name the name of the cookie
|
|
263
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
264
|
+
*/
|
|
265
|
+
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
269
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
270
|
+
*/
|
|
271
|
+
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request.
|
|
275
|
+
*
|
|
276
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
277
|
+
*
|
|
278
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
279
|
+
* @param name the name of the cookie
|
|
280
|
+
* @param value the cookie value
|
|
281
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
282
|
+
*/
|
|
283
|
+
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
287
|
+
*
|
|
288
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
289
|
+
*
|
|
290
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
291
|
+
* @param name the name of the cookie
|
|
292
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
293
|
+
*/
|
|
294
|
+
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
298
|
+
*
|
|
299
|
+
* ```js
|
|
300
|
+
* import { getRequestEvent } from '$app/server';
|
|
301
|
+
*
|
|
302
|
+
* export async function GET() {
|
|
303
|
+
* const { cookies } = getRequestEvent();
|
|
304
|
+
*
|
|
305
|
+
* const response = await fetch('...');
|
|
306
|
+
*
|
|
307
|
+
* for (const str of response.headers.getSetCookie()) {
|
|
308
|
+
* const { name, value, ...options } = cookies.parse(str);
|
|
309
|
+
* cookies.set(name, value, { ...options, path: '/' });
|
|
310
|
+
* }
|
|
311
|
+
*
|
|
312
|
+
* // ...
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
|
|
317
|
+
*/
|
|
318
|
+
parse: typeof import('cookie').parseSetCookie;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
322
|
+
*
|
|
323
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
324
|
+
*
|
|
325
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
326
|
+
* @param name the name of the cookie
|
|
327
|
+
* @param value the cookie value
|
|
328
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
329
|
+
*/
|
|
330
|
+
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
331
|
+
}
|
|
332
|
+
|
|
260
333
|
/**
|
|
261
334
|
* A collection of functions that influence the environment during dev, build and prerendering
|
|
262
335
|
*/
|
|
@@ -326,7 +399,7 @@ export interface LoadEvent<
|
|
|
326
399
|
*
|
|
327
400
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
328
401
|
*
|
|
329
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit
|
|
402
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API in a server-only `load` function instead.
|
|
330
403
|
*
|
|
331
404
|
* `setHeaders` has no effect when a `load` function runs in the browser.
|
|
332
405
|
*/
|
|
@@ -428,6 +501,127 @@ export interface NavigationEvent<
|
|
|
428
501
|
url: URL;
|
|
429
502
|
}
|
|
430
503
|
|
|
504
|
+
export interface RequestEvent<
|
|
505
|
+
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
506
|
+
RouteId extends AppRouteId | null = AppRouteId | null
|
|
507
|
+
> {
|
|
508
|
+
/**
|
|
509
|
+
* Get or set cookies related to the current request
|
|
510
|
+
*/
|
|
511
|
+
readonly cookies: Cookies;
|
|
512
|
+
/**
|
|
513
|
+
* `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
|
|
514
|
+
*
|
|
515
|
+
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
516
|
+
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
517
|
+
* - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
|
|
518
|
+
* - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
|
|
519
|
+
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
520
|
+
*
|
|
521
|
+
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
522
|
+
*/
|
|
523
|
+
readonly fetch: typeof fetch;
|
|
524
|
+
/**
|
|
525
|
+
* The client's IP address, set by the adapter.
|
|
526
|
+
*/
|
|
527
|
+
readonly getClientAddress: () => string;
|
|
528
|
+
/**
|
|
529
|
+
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
530
|
+
*/
|
|
531
|
+
readonly locals: App.Locals;
|
|
532
|
+
/**
|
|
533
|
+
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
534
|
+
*
|
|
535
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
536
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
537
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
538
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
539
|
+
*/
|
|
540
|
+
readonly params: Params;
|
|
541
|
+
/**
|
|
542
|
+
* Additional data made available through the adapter.
|
|
543
|
+
*/
|
|
544
|
+
readonly platform: Readonly<App.Platform> | undefined;
|
|
545
|
+
/**
|
|
546
|
+
* The original request object.
|
|
547
|
+
*/
|
|
548
|
+
readonly request: Request;
|
|
549
|
+
/**
|
|
550
|
+
* Info about the current route.
|
|
551
|
+
*/
|
|
552
|
+
readonly route: {
|
|
553
|
+
/**
|
|
554
|
+
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
555
|
+
*
|
|
556
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
557
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
558
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
559
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
560
|
+
*/
|
|
561
|
+
id: RouteId;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:
|
|
565
|
+
*
|
|
566
|
+
* ```js
|
|
567
|
+
* /// file: src/routes/blog/+page.js
|
|
568
|
+
* export async function load({ fetch, setHeaders }) {
|
|
569
|
+
* const url = `https://cms.example.com/articles.json`;
|
|
570
|
+
* const response = await fetch(url);
|
|
571
|
+
*
|
|
572
|
+
* setHeaders({
|
|
573
|
+
* age: response.headers.get('age'),
|
|
574
|
+
* 'cache-control': response.headers.get('cache-control')
|
|
575
|
+
* });
|
|
576
|
+
*
|
|
577
|
+
* return response.json();
|
|
578
|
+
* }
|
|
579
|
+
* ```
|
|
580
|
+
*
|
|
581
|
+
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
582
|
+
*
|
|
583
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.
|
|
584
|
+
*/
|
|
585
|
+
readonly setHeaders: (headers: Record<string, string>) => void;
|
|
586
|
+
/**
|
|
587
|
+
* The requested URL.
|
|
588
|
+
*
|
|
589
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
590
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
591
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
592
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
593
|
+
*/
|
|
594
|
+
readonly url: URL;
|
|
595
|
+
/**
|
|
596
|
+
* `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
|
|
597
|
+
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
598
|
+
*/
|
|
599
|
+
readonly isDataRequest: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
602
|
+
*/
|
|
603
|
+
readonly isSubRequest: boolean;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
607
|
+
* @since 2.31.0
|
|
608
|
+
*/
|
|
609
|
+
readonly tracing: {
|
|
610
|
+
/** Whether tracing is enabled. */
|
|
611
|
+
enabled: boolean;
|
|
612
|
+
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
613
|
+
root: Span;
|
|
614
|
+
/** The span associated with the current `handle` hook, `load` function, or form action. */
|
|
615
|
+
current: Span;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
620
|
+
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
621
|
+
*/
|
|
622
|
+
readonly isRemoteRequest: boolean;
|
|
623
|
+
}
|
|
624
|
+
|
|
431
625
|
/**
|
|
432
626
|
* 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.
|
|
433
627
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/** @import { SSRManifest } from '@sveltejs/kit' */
|
|
2
|
-
/** @import { RequestEvent } from '$app/server' */
|
|
1
|
+
/** @import { RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
3
2
|
/** @import { EnvironmentModuleNode, ErrorPayload, ResolvedConfig, ViteDevServer } from 'vite' */
|
|
4
3
|
/** @import { ManifestData, PrerenderOption, RemoteChunk, ServerModule, SSRNode, UniversalNode, ValidatedConfig } from 'types' */
|
|
5
4
|
import process from 'node:process';
|
|
@@ -635,7 +635,7 @@ function kit({ svelte_config }) {
|
|
|
635
635
|
|
|
636
636
|
const unsupported_plugins = vite_config.plugins.filter((plugin) => plugin.transformIndexHtml);
|
|
637
637
|
if (unsupported_plugins.length) {
|
|
638
|
-
const verbose = vite_config.logLevel === 'info';
|
|
638
|
+
const verbose = vite_config.logLevel === 'info' || vite_config.logLevel === undefined;
|
|
639
639
|
const log = logger({ verbose });
|
|
640
640
|
|
|
641
641
|
const list = unsupported_plugins
|
|
@@ -1689,7 +1689,7 @@ function kit({ svelte_config }) {
|
|
|
1689
1689
|
fs.rmSync(out, { force: true, recursive: true });
|
|
1690
1690
|
fs.mkdirSync(out, { recursive: true });
|
|
1691
1691
|
|
|
1692
|
-
const verbose = builder.config.logLevel === 'info';
|
|
1692
|
+
const verbose = builder.config.logLevel === 'info' || builder.config.logLevel === undefined;
|
|
1693
1693
|
const log = logger({ verbose });
|
|
1694
1694
|
|
|
1695
1695
|
let ssr_build = await builder.build(builder.environments.ssr);
|
|
@@ -1,201 +1 @@
|
|
|
1
|
-
import { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
2
|
-
|
|
3
1
|
export * from './index.js';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
6
|
-
type Span = import('@opentelemetry/api').Span;
|
|
7
|
-
|
|
8
|
-
export interface Cookies {
|
|
9
|
-
/**
|
|
10
|
-
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
11
|
-
* @param name the name of the cookie
|
|
12
|
-
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
13
|
-
*/
|
|
14
|
-
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
18
|
-
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
19
|
-
*/
|
|
20
|
-
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request.
|
|
24
|
-
*
|
|
25
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
26
|
-
*
|
|
27
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
28
|
-
* @param name the name of the cookie
|
|
29
|
-
* @param value the cookie value
|
|
30
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
31
|
-
*/
|
|
32
|
-
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
36
|
-
*
|
|
37
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
38
|
-
*
|
|
39
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
40
|
-
* @param name the name of the cookie
|
|
41
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
42
|
-
*/
|
|
43
|
-
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
47
|
-
*
|
|
48
|
-
* ```js
|
|
49
|
-
* import { getRequestEvent } from '$app/server';
|
|
50
|
-
*
|
|
51
|
-
* export async function GET() {
|
|
52
|
-
* const { cookies } = getRequestEvent();
|
|
53
|
-
*
|
|
54
|
-
* const response = await fetch('...');
|
|
55
|
-
*
|
|
56
|
-
* for (const str of response.headers.getSetCookie()) {
|
|
57
|
-
* const { name, value, ...options } = cookies.parse(str);
|
|
58
|
-
* cookies.set(name, value, { ...options, path: '/' });
|
|
59
|
-
* }
|
|
60
|
-
*
|
|
61
|
-
* // ...
|
|
62
|
-
* }
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
|
|
66
|
-
*/
|
|
67
|
-
parse: typeof import('cookie').parseSetCookie;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
71
|
-
*
|
|
72
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
73
|
-
*
|
|
74
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
75
|
-
* @param name the name of the cookie
|
|
76
|
-
* @param value the cookie value
|
|
77
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
78
|
-
*/
|
|
79
|
-
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface RequestEvent<
|
|
83
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
84
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
85
|
-
> {
|
|
86
|
-
/**
|
|
87
|
-
* Get or set cookies related to the current request
|
|
88
|
-
*/
|
|
89
|
-
readonly cookies: Cookies;
|
|
90
|
-
/**
|
|
91
|
-
* `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
|
|
92
|
-
*
|
|
93
|
-
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
94
|
-
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
95
|
-
* - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
|
|
96
|
-
* - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
|
|
97
|
-
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
98
|
-
*
|
|
99
|
-
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
100
|
-
*/
|
|
101
|
-
readonly fetch: typeof fetch;
|
|
102
|
-
/**
|
|
103
|
-
* The client's IP address, set by the adapter.
|
|
104
|
-
*/
|
|
105
|
-
readonly getClientAddress: () => string;
|
|
106
|
-
/**
|
|
107
|
-
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
108
|
-
*/
|
|
109
|
-
readonly locals: App.Locals;
|
|
110
|
-
/**
|
|
111
|
-
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
112
|
-
*
|
|
113
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
114
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
115
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
116
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
117
|
-
*/
|
|
118
|
-
readonly params: Params;
|
|
119
|
-
/**
|
|
120
|
-
* Additional data made available through the adapter.
|
|
121
|
-
*/
|
|
122
|
-
readonly platform: Readonly<App.Platform> | undefined;
|
|
123
|
-
/**
|
|
124
|
-
* The original request object.
|
|
125
|
-
*/
|
|
126
|
-
readonly request: Request;
|
|
127
|
-
/**
|
|
128
|
-
* Info about the current route.
|
|
129
|
-
*/
|
|
130
|
-
readonly route: {
|
|
131
|
-
/**
|
|
132
|
-
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
133
|
-
*
|
|
134
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
135
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
136
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
137
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
138
|
-
*/
|
|
139
|
-
id: RouteId;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:
|
|
143
|
-
*
|
|
144
|
-
* ```js
|
|
145
|
-
* /// file: src/routes/blog/+page.js
|
|
146
|
-
* export async function load({ fetch, setHeaders }) {
|
|
147
|
-
* const url = `https://cms.example.com/articles.json`;
|
|
148
|
-
* const response = await fetch(url);
|
|
149
|
-
*
|
|
150
|
-
* setHeaders({
|
|
151
|
-
* age: response.headers.get('age'),
|
|
152
|
-
* 'cache-control': response.headers.get('cache-control')
|
|
153
|
-
* });
|
|
154
|
-
*
|
|
155
|
-
* return response.json();
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
|
-
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
160
|
-
*
|
|
161
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/$app-server#Cookies) API instead.
|
|
162
|
-
*/
|
|
163
|
-
readonly setHeaders: (headers: Record<string, string>) => void;
|
|
164
|
-
/**
|
|
165
|
-
* The requested URL.
|
|
166
|
-
*
|
|
167
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
168
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
169
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
170
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
171
|
-
*/
|
|
172
|
-
readonly url: URL;
|
|
173
|
-
/**
|
|
174
|
-
* `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
|
|
175
|
-
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
176
|
-
*/
|
|
177
|
-
readonly isDataRequest: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
180
|
-
*/
|
|
181
|
-
readonly isSubRequest: boolean;
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
185
|
-
* @since 2.31.0
|
|
186
|
-
*/
|
|
187
|
-
readonly tracing: {
|
|
188
|
-
/** Whether tracing is enabled. */
|
|
189
|
-
enabled: boolean;
|
|
190
|
-
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
191
|
-
root: Span;
|
|
192
|
-
/** The span associated with the current `handle` hook, `load` function, or form action. */
|
|
193
|
-
current: Span;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
198
|
-
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
199
|
-
*/
|
|
200
|
-
readonly isRemoteRequest: boolean;
|
|
201
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { RemoteLiveQuery, RemoteLiveQueryFunction, RemoteQuery, RemoteQueryFunction } from '@sveltejs/kit/remote' */
|
|
2
|
-
/** @import { RequestEvent } from '
|
|
2
|
+
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
3
3
|
/** @import { RemoteInternals, MaybePromise, RequestState, RemoteQueryLiveInternals, RemoteQueryBatchInternals, RemoteQueryInternals, RemoteLiveQueryUserFunctionReturnType } from 'types' */
|
|
4
4
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
5
5
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RequestEvent } from '
|
|
1
|
+
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
2
2
|
/** @import { MaybePromise, RequestState, RemoteInternals, RequestStore, RemoteLiveQueryUserFunctionReturnType } from 'types' */
|
|
3
3
|
import { error } from '@sveltejs/kit';
|
|
4
4
|
import { ValidationError } from '@sveltejs/kit/internal';
|
|
@@ -76,11 +76,11 @@ export function get_cookies(request, url) {
|
|
|
76
76
|
secure: !__SVELTEKIT_DEV__ && !(url.hostname === 'localhost' && url.protocol === 'http:')
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
/** @type {import('
|
|
79
|
+
/** @type {import('@sveltejs/kit').Cookies} */
|
|
80
80
|
const cookies = {
|
|
81
81
|
// The JSDoc param annotations appearing below for get, set and delete
|
|
82
82
|
// are necessary to expose the `cookie` library types to
|
|
83
|
-
// typescript users. `@type {import('
|
|
83
|
+
// typescript users. `@type {import('@sveltejs/kit').Cookies}` above is not
|
|
84
84
|
// sufficient to do so.
|
|
85
85
|
|
|
86
86
|
get(name, opts) {
|
|
@@ -10,7 +10,7 @@ import { text_encoder } from '../../utils.js';
|
|
|
10
10
|
import { with_version_header } from '../utils.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @param {import('
|
|
13
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
14
14
|
* @param {import('types').RequestState} state
|
|
15
15
|
* @param {import('types').SSRRoute} route
|
|
16
16
|
* @param {import('types').SSROptions} options
|
|
@@ -5,7 +5,7 @@ import { negotiate } from '../../utils/http.js';
|
|
|
5
5
|
import { method_not_allowed } from './utils.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param {import('
|
|
8
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
9
9
|
* @param {import('types').RequestState} state
|
|
10
10
|
* @param {import('types').SSREndpoint} mod
|
|
11
11
|
* @returns {Promise<Response>}
|
|
@@ -42,7 +42,7 @@ export async function render_endpoint(event, state, mod) {
|
|
|
42
42
|
|
|
43
43
|
try {
|
|
44
44
|
const response = await with_request_store({ event, state }, () =>
|
|
45
|
-
handler(/** @type {import('
|
|
45
|
+
handler(/** @type {import('@sveltejs/kit').RequestEvent<Record<string, any>>} */ (event))
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
if (!(response instanceof Response)) {
|
|
@@ -89,7 +89,7 @@ export async function render_endpoint(event, state, mod) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* @param {import('
|
|
92
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
93
93
|
*/
|
|
94
94
|
export function is_endpoint_request(event) {
|
|
95
95
|
const { method, headers } = event.request;
|
|
@@ -12,7 +12,7 @@ import { fix_stack_trace } from './internal.js';
|
|
|
12
12
|
import { escape_html } from '../../utils/escape.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {import('
|
|
15
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
16
16
|
* @param {import('types').RequestState} state
|
|
17
17
|
* @param {import('types').SSROptions} options
|
|
18
18
|
* @param {unknown} error
|
|
@@ -37,7 +37,7 @@ export async function handle_fatal_error(event, state, options, error) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* @param {import('
|
|
40
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
41
41
|
* @param {import('types').RequestState} state
|
|
42
42
|
* @param {import('types').SSROptions} options
|
|
43
43
|
* @param {any} error
|
|
@@ -8,7 +8,7 @@ import { fork_state_for_subrequest } from './state.js';
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @param {{
|
|
11
|
-
* event: import('
|
|
11
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
12
12
|
* options: import('types').SSROptions;
|
|
13
13
|
* manifest: import('@sveltejs/kit').SSRManifest;
|
|
14
14
|
* state: import('types').RequestState;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/** @import { Actions } from '@sveltejs/kit' */
|
|
2
|
-
/** @import { RequestEvent } from '$app/server' */
|
|
1
|
+
/** @import { RequestEvent, Actions } from '@sveltejs/kit' */
|
|
3
2
|
/** @import { ActionResult } from '$app/forms' */
|
|
4
3
|
/** @import { SSROptions, SSRNode, ServerNode } from 'types' */
|
|
5
4
|
import { DEV } from 'esm-env';
|
|
@@ -8,7 +8,7 @@ import { encoders } from '#app/internal/transport';
|
|
|
8
8
|
/**
|
|
9
9
|
* If the serialized data contains promises, `chunks` will be an
|
|
10
10
|
* async iterable containing their resolutions
|
|
11
|
-
* @param {import('
|
|
11
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
12
12
|
* @param {import('types').RequestState} state
|
|
13
13
|
* @param {import('types').SSROptions} options
|
|
14
14
|
* @returns {import('./types.js').ServerDataSerializer}
|
|
@@ -125,7 +125,7 @@ export function server_data_serializer(event, state, options) {
|
|
|
125
125
|
/**
|
|
126
126
|
* If the serialized data contains promises, `chunks` will be an
|
|
127
127
|
* async iterable containing their resolutions
|
|
128
|
-
* @param {import('
|
|
128
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
129
129
|
* @param {import('types').RequestState} state
|
|
130
130
|
* @param {import('types').SSROptions} options
|
|
131
131
|
* @returns {import('./types.js').ServerDataSerializerJson}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @import { Component } from 'svelte' */
|
|
2
|
-
/** @import { SSRManifest } from '@sveltejs/kit' */
|
|
3
|
-
/** @import { RequestEvent } from '$app/server' */
|
|
2
|
+
/** @import { RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
4
3
|
/** @import { ActionResult } from '$app/forms' */
|
|
5
4
|
/** @import { PageNodeIndexes, RequestState, RequiredResolveOptions, ServerDataNode, SSRNode, SSROptions } from 'types' */
|
|
6
5
|
import { text } from '@sveltejs/kit';
|
|
@@ -10,7 +10,7 @@ import { get_node_type } from '../utils.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* Calls the user's server `load` function.
|
|
12
12
|
* @param {{
|
|
13
|
-
* event: import('
|
|
13
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
14
14
|
* state: import('types').RequestState;
|
|
15
15
|
* node: import('types').SSRNode | undefined;
|
|
16
16
|
* parent: () => Promise<Record<string, any>>;
|
|
@@ -191,7 +191,7 @@ export async function load_server_data({ event, state, node, parent }) {
|
|
|
191
191
|
/**
|
|
192
192
|
* Calls the user's `load` function.
|
|
193
193
|
* @param {{
|
|
194
|
-
* event: import('
|
|
194
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
195
195
|
* state: import('types').RequestState;
|
|
196
196
|
* fetched: import('./types.js').Fetched[];
|
|
197
197
|
* node: import('types').SSRNode | undefined;
|
|
@@ -256,7 +256,7 @@ export async function load_data({
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
|
-
* @param {Pick<import('
|
|
259
|
+
* @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event
|
|
260
260
|
* @param {import('types').PrerenderOptions | undefined} prerendering
|
|
261
261
|
* @param {import('./types.js').Fetched[]} fetched
|
|
262
262
|
* @param {boolean} csr
|
|
@@ -40,7 +40,7 @@ import { has_custom_transporters, uneval } from '#app/internal/transport';
|
|
|
40
40
|
* page_config: { ssr: boolean; csr: boolean };
|
|
41
41
|
* status: number;
|
|
42
42
|
* error: App.Error | null;
|
|
43
|
-
* event: import('
|
|
43
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
44
44
|
* state: import('types').RequestState;
|
|
45
45
|
* resolve_opts: import('types').RequiredResolveOptions;
|
|
46
46
|
* action_result?: import('$app/forms').ActionResult;
|
|
@@ -12,7 +12,7 @@ import { server_data_serializer } from './data_serializer.js';
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @param {{
|
|
15
|
-
* event: import('
|
|
15
|
+
* event: import('@sveltejs/kit').RequestEvent;
|
|
16
16
|
* state: import('types').RequestState;
|
|
17
17
|
* options: import('types').SSROptions;
|
|
18
18
|
* manifest: import('@sveltejs/kit').SSRManifest;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/** @import { SSRManifest } from '@sveltejs/kit' */
|
|
1
|
+
/** @import { RequestEvent, SSRManifest } from '@sveltejs/kit' */
|
|
2
2
|
/** @import { RemoteForm } from '@sveltejs/kit/remote' */
|
|
3
|
-
/** @import { RequestEvent } from '$app/server' */
|
|
4
3
|
/** @import { ActionResult } from '$app/forms' */
|
|
5
4
|
/** @import { RemoteFormInternals, RemoteFunctionData, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */
|
|
6
5
|
|
|
@@ -183,7 +183,7 @@ export async function internal_respond(request, options, manifest, state) {
|
|
|
183
183
|
url
|
|
184
184
|
);
|
|
185
185
|
|
|
186
|
-
/** @type {import('
|
|
186
|
+
/** @type {import('@sveltejs/kit').RequestEvent} */
|
|
187
187
|
const event = {
|
|
188
188
|
cookies,
|
|
189
189
|
// @ts-expect-error `fetch` needs to be created after the `event` itself
|
|
@@ -574,7 +574,7 @@ export async function internal_respond(request, options, manifest, state) {
|
|
|
574
574
|
}
|
|
575
575
|
|
|
576
576
|
/**
|
|
577
|
-
* @param {import('
|
|
577
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
578
578
|
* @param {PageNodes | undefined} page_nodes
|
|
579
579
|
* @param {import('@sveltejs/kit/hooks').ResolveOptions} [opts]
|
|
580
580
|
*/
|
|
@@ -59,7 +59,7 @@ export function with_version_header(response) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* @param {import('
|
|
62
|
+
* @param {import('@sveltejs/kit').RequestEvent} event
|
|
63
63
|
* @param {Error & { path: string }} error
|
|
64
64
|
*/
|
|
65
65
|
export function clarify_devalue_error(event, error) {
|
package/src/types/internal.d.ts
CHANGED
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
Server,
|
|
7
7
|
ServerInitOptions,
|
|
8
8
|
Actions,
|
|
9
|
+
RequestEvent,
|
|
9
10
|
SSRManifest,
|
|
10
11
|
Emulator
|
|
11
12
|
} from '@sveltejs/kit';
|
|
12
13
|
import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '@sveltejs/kit/remote';
|
|
13
14
|
import { Config } from '@sveltejs/kit/vite';
|
|
14
|
-
import { RequestEvent } from '$app/server';
|
|
15
15
|
import {
|
|
16
16
|
ClientInit,
|
|
17
17
|
Handle,
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
declare module '@sveltejs/kit' {
|
|
5
5
|
import type { Plugin } from 'vite';
|
|
6
|
-
import type { RequestEvent } from '$app/server';
|
|
7
6
|
import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
8
7
|
import type { Config } from '@sveltejs/kit/vite';
|
|
9
8
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
@@ -242,6 +241,80 @@ declare module '@sveltejs/kit' {
|
|
|
242
241
|
compress: (directory: string) => Promise<string[]>;
|
|
243
242
|
}
|
|
244
243
|
|
|
244
|
+
export interface Cookies {
|
|
245
|
+
/**
|
|
246
|
+
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
247
|
+
* @param name the name of the cookie
|
|
248
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
249
|
+
*/
|
|
250
|
+
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
254
|
+
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
255
|
+
*/
|
|
256
|
+
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request.
|
|
260
|
+
*
|
|
261
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
262
|
+
*
|
|
263
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
264
|
+
* @param name the name of the cookie
|
|
265
|
+
* @param value the cookie value
|
|
266
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
267
|
+
*/
|
|
268
|
+
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
272
|
+
*
|
|
273
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
274
|
+
*
|
|
275
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
276
|
+
* @param name the name of the cookie
|
|
277
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
278
|
+
*/
|
|
279
|
+
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
283
|
+
*
|
|
284
|
+
* ```js
|
|
285
|
+
* import { getRequestEvent } from '$app/server';
|
|
286
|
+
*
|
|
287
|
+
* export async function GET() {
|
|
288
|
+
* const { cookies } = getRequestEvent();
|
|
289
|
+
*
|
|
290
|
+
* const response = await fetch('...');
|
|
291
|
+
*
|
|
292
|
+
* for (const str of response.headers.getSetCookie()) {
|
|
293
|
+
* const { name, value, ...options } = cookies.parse(str);
|
|
294
|
+
* cookies.set(name, value, { ...options, path: '/' });
|
|
295
|
+
* }
|
|
296
|
+
*
|
|
297
|
+
* // ...
|
|
298
|
+
* }
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
|
|
302
|
+
*/
|
|
303
|
+
parse: typeof import('cookie').parseSetCookie;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
307
|
+
*
|
|
308
|
+
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
309
|
+
*
|
|
310
|
+
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
311
|
+
* @param name the name of the cookie
|
|
312
|
+
* @param value the cookie value
|
|
313
|
+
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
314
|
+
*/
|
|
315
|
+
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
316
|
+
}
|
|
317
|
+
|
|
245
318
|
/**
|
|
246
319
|
* A collection of functions that influence the environment during dev, build and prerendering
|
|
247
320
|
*/
|
|
@@ -311,7 +384,7 @@ declare module '@sveltejs/kit' {
|
|
|
311
384
|
*
|
|
312
385
|
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
313
386
|
*
|
|
314
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit
|
|
387
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API in a server-only `load` function instead.
|
|
315
388
|
*
|
|
316
389
|
* `setHeaders` has no effect when a `load` function runs in the browser.
|
|
317
390
|
*/
|
|
@@ -413,6 +486,127 @@ declare module '@sveltejs/kit' {
|
|
|
413
486
|
url: URL;
|
|
414
487
|
}
|
|
415
488
|
|
|
489
|
+
export interface RequestEvent<
|
|
490
|
+
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
491
|
+
RouteId extends AppRouteId | null = AppRouteId | null
|
|
492
|
+
> {
|
|
493
|
+
/**
|
|
494
|
+
* Get or set cookies related to the current request
|
|
495
|
+
*/
|
|
496
|
+
readonly cookies: Cookies;
|
|
497
|
+
/**
|
|
498
|
+
* `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
|
|
499
|
+
*
|
|
500
|
+
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
501
|
+
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
502
|
+
* - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
|
|
503
|
+
* - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
|
|
504
|
+
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
505
|
+
*
|
|
506
|
+
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
507
|
+
*/
|
|
508
|
+
readonly fetch: typeof fetch;
|
|
509
|
+
/**
|
|
510
|
+
* The client's IP address, set by the adapter.
|
|
511
|
+
*/
|
|
512
|
+
readonly getClientAddress: () => string;
|
|
513
|
+
/**
|
|
514
|
+
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
515
|
+
*/
|
|
516
|
+
readonly locals: App.Locals;
|
|
517
|
+
/**
|
|
518
|
+
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
519
|
+
*
|
|
520
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
521
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
522
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
523
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
524
|
+
*/
|
|
525
|
+
readonly params: Params;
|
|
526
|
+
/**
|
|
527
|
+
* Additional data made available through the adapter.
|
|
528
|
+
*/
|
|
529
|
+
readonly platform: Readonly<App.Platform> | undefined;
|
|
530
|
+
/**
|
|
531
|
+
* The original request object.
|
|
532
|
+
*/
|
|
533
|
+
readonly request: Request;
|
|
534
|
+
/**
|
|
535
|
+
* Info about the current route.
|
|
536
|
+
*/
|
|
537
|
+
readonly route: {
|
|
538
|
+
/**
|
|
539
|
+
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
540
|
+
*
|
|
541
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
542
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
543
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
544
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
545
|
+
*/
|
|
546
|
+
id: RouteId;
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:
|
|
550
|
+
*
|
|
551
|
+
* ```js
|
|
552
|
+
* /// file: src/routes/blog/+page.js
|
|
553
|
+
* export async function load({ fetch, setHeaders }) {
|
|
554
|
+
* const url = `https://cms.example.com/articles.json`;
|
|
555
|
+
* const response = await fetch(url);
|
|
556
|
+
*
|
|
557
|
+
* setHeaders({
|
|
558
|
+
* age: response.headers.get('age'),
|
|
559
|
+
* 'cache-control': response.headers.get('cache-control')
|
|
560
|
+
* });
|
|
561
|
+
*
|
|
562
|
+
* return response.json();
|
|
563
|
+
* }
|
|
564
|
+
* ```
|
|
565
|
+
*
|
|
566
|
+
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
567
|
+
*
|
|
568
|
+
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/@sveltejs-kit#Cookies) API instead.
|
|
569
|
+
*/
|
|
570
|
+
readonly setHeaders: (headers: Record<string, string>) => void;
|
|
571
|
+
/**
|
|
572
|
+
* The requested URL.
|
|
573
|
+
*
|
|
574
|
+
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
575
|
+
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
576
|
+
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
577
|
+
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
578
|
+
*/
|
|
579
|
+
readonly url: URL;
|
|
580
|
+
/**
|
|
581
|
+
* `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
|
|
582
|
+
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
583
|
+
*/
|
|
584
|
+
readonly isDataRequest: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
587
|
+
*/
|
|
588
|
+
readonly isSubRequest: boolean;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
592
|
+
* @since 2.31.0
|
|
593
|
+
*/
|
|
594
|
+
readonly tracing: {
|
|
595
|
+
/** Whether tracing is enabled. */
|
|
596
|
+
enabled: boolean;
|
|
597
|
+
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
598
|
+
root: Span;
|
|
599
|
+
/** The span associated with the current `handle` hook, `load` function, or form action. */
|
|
600
|
+
current: Span;
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
605
|
+
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
606
|
+
*/
|
|
607
|
+
readonly isRemoteRequest: boolean;
|
|
608
|
+
}
|
|
609
|
+
|
|
416
610
|
/**
|
|
417
611
|
* 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.
|
|
418
612
|
*
|
|
@@ -942,8 +1136,7 @@ declare module '@sveltejs/kit/env' {
|
|
|
942
1136
|
|
|
943
1137
|
declare module '@sveltejs/kit/hooks' {
|
|
944
1138
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
945
|
-
import type { NavigationEvent } from '@sveltejs/kit';
|
|
946
|
-
import type { RequestEvent } from '$app/server';
|
|
1139
|
+
import type { NavigationEvent, RequestEvent } from '@sveltejs/kit';
|
|
947
1140
|
/**
|
|
948
1141
|
* The [`handle`](https://svelte.dev/docs/kit/hooks#handle) hook runs every time the SvelteKit server receives a [request](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Request) and
|
|
949
1142
|
* determines the [response](https://svelte.dev/docs/kit/web-standards#Fetch-APIs-Response).
|
|
@@ -3221,206 +3414,9 @@ declare module '$app/paths' {
|
|
|
3221
3414
|
}
|
|
3222
3415
|
|
|
3223
3416
|
declare module '$app/server' {
|
|
3224
|
-
import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams } from '$app/types';
|
|
3225
3417
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3418
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
3226
3419
|
import type { RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction, RemoteLiveQueryFunction, QueryRequestedResult, LiveQueryRequestedResult } from '@sveltejs/kit/remote';
|
|
3227
|
-
// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
|
|
3228
|
-
type Span = import('@opentelemetry/api').Span;
|
|
3229
|
-
|
|
3230
|
-
export interface Cookies {
|
|
3231
|
-
/**
|
|
3232
|
-
* Gets a cookie that was previously set with `cookies.set`, or from the request headers.
|
|
3233
|
-
* @param name the name of the cookie
|
|
3234
|
-
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
3235
|
-
*/
|
|
3236
|
-
get: (name: string, opts?: import('cookie').ParseOptions) => string | undefined;
|
|
3237
|
-
|
|
3238
|
-
/**
|
|
3239
|
-
* Gets all cookies that were previously set with `cookies.set`, or from the request headers.
|
|
3240
|
-
* @param opts the options, passed directly to `cookie.parseCookie`. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookieparsecookiestr-options)
|
|
3241
|
-
*/
|
|
3242
|
-
getAll: (opts?: import('cookie').ParseOptions) => Array<{ name: string; value: string }>;
|
|
3243
|
-
|
|
3244
|
-
/**
|
|
3245
|
-
* Sets a cookie. This will add a `set-cookie` header to the response, but also make the cookie available via `cookies.get` or `cookies.getAll` during the current request.
|
|
3246
|
-
*
|
|
3247
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
3248
|
-
*
|
|
3249
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
3250
|
-
* @param name the name of the cookie
|
|
3251
|
-
* @param value the cookie value
|
|
3252
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
3253
|
-
*/
|
|
3254
|
-
set: (name: string, value: string, opts: import('cookie').SerializeOptions) => void;
|
|
3255
|
-
|
|
3256
|
-
/**
|
|
3257
|
-
* Deletes a cookie by setting its value to an empty string and setting the expiry date in the past.
|
|
3258
|
-
*
|
|
3259
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
3260
|
-
*
|
|
3261
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
3262
|
-
* @param name the name of the cookie
|
|
3263
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
3264
|
-
*/
|
|
3265
|
-
delete: (name: string, opts: import('cookie').SerializeOptions) => void;
|
|
3266
|
-
|
|
3267
|
-
/**
|
|
3268
|
-
* Parses a single `Set-Cookie` header. This allows you to apply cookies received from an external source:
|
|
3269
|
-
*
|
|
3270
|
-
* ```js
|
|
3271
|
-
* import { getRequestEvent } from '$app/server';
|
|
3272
|
-
*
|
|
3273
|
-
* export async function GET() {
|
|
3274
|
-
* const { cookies } = getRequestEvent();
|
|
3275
|
-
*
|
|
3276
|
-
* const response = await fetch('...');
|
|
3277
|
-
*
|
|
3278
|
-
* for (const str of response.headers.getSetCookie()) {
|
|
3279
|
-
* const { name, value, ...options } = cookies.parse(str);
|
|
3280
|
-
* cookies.set(name, value, { ...options, path: '/' });
|
|
3281
|
-
* }
|
|
3282
|
-
*
|
|
3283
|
-
* // ...
|
|
3284
|
-
* }
|
|
3285
|
-
* ```
|
|
3286
|
-
*
|
|
3287
|
-
* Note the use of `headers.getSetCookie()`, which returns an array of cookie headers, _not_ `headers.get('set-cookie')` which returns a single comma-separated string.
|
|
3288
|
-
*/
|
|
3289
|
-
parse: typeof import('cookie').parseSetCookie;
|
|
3290
|
-
|
|
3291
|
-
/**
|
|
3292
|
-
* Serialize a cookie name-value pair into a `Set-Cookie` header string, but don't apply it to the response.
|
|
3293
|
-
*
|
|
3294
|
-
* The `httpOnly` is `true` by default, as is `secure`, except during development, when it defaults to `false`. These must be explicitly disabled if you want cookies to be readable by client-side JavaScript and/or transmitted over HTTP.
|
|
3295
|
-
*
|
|
3296
|
-
* The `path` option is `'/'` by default. You can use relative paths, or set `path: ''` to make the cookie only available on the current path and its children.
|
|
3297
|
-
* @param name the name of the cookie
|
|
3298
|
-
* @param value the cookie value
|
|
3299
|
-
* @param opts the options passed to `cookie.stringifySetCookie` with the SvelteKit defaults described above. See documentation [here](https://github.com/jshttp/cookie?tab=readme-ov-file#cookiestringifysetcookiesetcookieobj-options)
|
|
3300
|
-
*/
|
|
3301
|
-
serialize: (name: string, value: string, opts: import('cookie').SerializeOptions) => string;
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
export interface RequestEvent<
|
|
3305
|
-
Params extends AppLayoutParams<'/'> = AppLayoutParams<'/'>,
|
|
3306
|
-
RouteId extends AppRouteId | null = AppRouteId | null
|
|
3307
|
-
> {
|
|
3308
|
-
/**
|
|
3309
|
-
* Get or set cookies related to the current request
|
|
3310
|
-
*/
|
|
3311
|
-
readonly cookies: Cookies;
|
|
3312
|
-
/**
|
|
3313
|
-
* `fetch` is equivalent to the [native `fetch` web API](https://developer.mozilla.org/en-US/docs/Web/API/fetch), with a few additional features:
|
|
3314
|
-
*
|
|
3315
|
-
* - It can be used to make credentialed requests on the server, as it inherits the `cookie` and `authorization` headers for the page request.
|
|
3316
|
-
* - It can make relative requests on the server (ordinarily, `fetch` requires a URL with an origin when used in a server context).
|
|
3317
|
-
* - Internal requests (e.g. for `+server.js` routes) go directly to the handler function when running on the server, without the overhead of an HTTP call.
|
|
3318
|
-
* - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#handle)
|
|
3319
|
-
* - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
|
|
3320
|
-
*
|
|
3321
|
-
* You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
|
|
3322
|
-
*/
|
|
3323
|
-
readonly fetch: typeof fetch;
|
|
3324
|
-
/**
|
|
3325
|
-
* The client's IP address, set by the adapter.
|
|
3326
|
-
*/
|
|
3327
|
-
readonly getClientAddress: () => string;
|
|
3328
|
-
/**
|
|
3329
|
-
* Contains custom data that was added to the request within the [`server handle hook`](https://svelte.dev/docs/kit/hooks#handle).
|
|
3330
|
-
*/
|
|
3331
|
-
readonly locals: App.Locals;
|
|
3332
|
-
/**
|
|
3333
|
-
* The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
|
|
3334
|
-
*
|
|
3335
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
3336
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
3337
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
3338
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
3339
|
-
*/
|
|
3340
|
-
readonly params: Params;
|
|
3341
|
-
/**
|
|
3342
|
-
* Additional data made available through the adapter.
|
|
3343
|
-
*/
|
|
3344
|
-
readonly platform: Readonly<App.Platform> | undefined;
|
|
3345
|
-
/**
|
|
3346
|
-
* The original request object.
|
|
3347
|
-
*/
|
|
3348
|
-
readonly request: Request;
|
|
3349
|
-
/**
|
|
3350
|
-
* Info about the current route.
|
|
3351
|
-
*/
|
|
3352
|
-
readonly route: {
|
|
3353
|
-
/**
|
|
3354
|
-
* The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`. It is `null` when no route is matched.
|
|
3355
|
-
*
|
|
3356
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
3357
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
3358
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
3359
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
3360
|
-
*/
|
|
3361
|
-
id: RouteId;
|
|
3362
|
-
};
|
|
3363
|
-
/**
|
|
3364
|
-
* If you need to set headers for the response, you can do so using the this method. This is useful if you want the page to be cached, for example:
|
|
3365
|
-
*
|
|
3366
|
-
* ```js
|
|
3367
|
-
* /// file: src/routes/blog/+page.js
|
|
3368
|
-
* export async function load({ fetch, setHeaders }) {
|
|
3369
|
-
* const url = `https://cms.example.com/articles.json`;
|
|
3370
|
-
* const response = await fetch(url);
|
|
3371
|
-
*
|
|
3372
|
-
* setHeaders({
|
|
3373
|
-
* age: response.headers.get('age'),
|
|
3374
|
-
* 'cache-control': response.headers.get('cache-control')
|
|
3375
|
-
* });
|
|
3376
|
-
*
|
|
3377
|
-
* return response.json();
|
|
3378
|
-
* }
|
|
3379
|
-
* ```
|
|
3380
|
-
*
|
|
3381
|
-
* Setting the same header multiple times (even in separate `load` functions) is an error — you can only set a given header once.
|
|
3382
|
-
*
|
|
3383
|
-
* You cannot add a `set-cookie` header with `setHeaders` — use the [`cookies`](https://svelte.dev/docs/kit/$app-server#Cookies) API instead.
|
|
3384
|
-
*/
|
|
3385
|
-
readonly setHeaders: (headers: Record<string, string>) => void;
|
|
3386
|
-
/**
|
|
3387
|
-
* The requested URL.
|
|
3388
|
-
*
|
|
3389
|
-
* Inside `query` functions (including `query.batch` and `query.live`), accessing this property throws an error.
|
|
3390
|
-
* Pass values from the page as arguments to the query instead. Inside `form` and `command` functions it relates to the page
|
|
3391
|
-
* the remote function was called from, _not_ the URL of the endpoint SvelteKit creates for the remote function. Never use it
|
|
3392
|
-
* to determine whether or not a user is authorized to access certain data, as these values are part of the request which could be manipulated.
|
|
3393
|
-
*/
|
|
3394
|
-
readonly url: URL;
|
|
3395
|
-
/**
|
|
3396
|
-
* `true` if the request comes from the client asking for `+page/layout.server.js` data. The `url` property will be stripped of the internal information
|
|
3397
|
-
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
3398
|
-
*/
|
|
3399
|
-
readonly isDataRequest: boolean;
|
|
3400
|
-
/**
|
|
3401
|
-
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
3402
|
-
*/
|
|
3403
|
-
readonly isSubRequest: boolean;
|
|
3404
|
-
|
|
3405
|
-
/**
|
|
3406
|
-
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
3407
|
-
* @since 2.31.0
|
|
3408
|
-
*/
|
|
3409
|
-
readonly tracing: {
|
|
3410
|
-
/** Whether tracing is enabled. */
|
|
3411
|
-
enabled: boolean;
|
|
3412
|
-
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
3413
|
-
root: Span;
|
|
3414
|
-
/** The span associated with the current `handle` hook, `load` function, or form action. */
|
|
3415
|
-
current: Span;
|
|
3416
|
-
};
|
|
3417
|
-
|
|
3418
|
-
/**
|
|
3419
|
-
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
3420
|
-
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
3421
|
-
*/
|
|
3422
|
-
readonly isRemoteRequest: boolean;
|
|
3423
|
-
}
|
|
3424
3420
|
/**
|
|
3425
3421
|
* Read the contents of an imported asset from the filesystem
|
|
3426
3422
|
* @example
|
package/types/index.d.ts.map
CHANGED
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
"ActionFailure",
|
|
12
12
|
"UnpackValidationError",
|
|
13
13
|
"Builder",
|
|
14
|
+
"Cookies",
|
|
14
15
|
"Emulator",
|
|
15
16
|
"Load",
|
|
16
17
|
"LoadEvent",
|
|
17
18
|
"NavigationEvent",
|
|
19
|
+
"RequestEvent",
|
|
18
20
|
"RequestHandler",
|
|
19
21
|
"RouteDefinition",
|
|
20
22
|
"Server",
|
|
@@ -176,8 +178,6 @@
|
|
|
176
178
|
"match",
|
|
177
179
|
"StripSearchOrHash",
|
|
178
180
|
"ResolveArgs",
|
|
179
|
-
"Cookies",
|
|
180
|
-
"RequestEvent",
|
|
181
181
|
"read",
|
|
182
182
|
"getRequestEvent",
|
|
183
183
|
"RemoteLiveQueryUserFunctionReturnType",
|
|
@@ -215,7 +215,6 @@
|
|
|
215
215
|
"../src/runtime/client/snapshots.js",
|
|
216
216
|
"../src/runtime/app/paths/client.js",
|
|
217
217
|
"../src/runtime/app/paths/types.d.ts",
|
|
218
|
-
"../src/runtime/app/server/public.d.ts",
|
|
219
218
|
"../src/runtime/app/server/index.js",
|
|
220
219
|
"../src/exports/internal/server/event.js",
|
|
221
220
|
"../src/runtime/app/service-worker/index.js",
|
|
@@ -250,9 +249,8 @@
|
|
|
250
249
|
null,
|
|
251
250
|
null,
|
|
252
251
|
null,
|
|
253
|
-
null,
|
|
254
252
|
null
|
|
255
253
|
],
|
|
256
|
-
"mappings": "
|
|
254
|
+
"mappings": ";;;;;;;;;MAsBKA,IAAIA;;;;;kBAKQC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA+CZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;MAQrBC,aAAaA;;;;;OAKJC,YAAYA;;kBAETC,aAAaA;;;;;;MAMzBC,qBAAqBA;;;;;;;;;;;kBAWTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkJPC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6EPC,QAAQA;;;;;;;;;;;;aAYbC,IAAIA;;;;;;;;;;;;kBAYCC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAyHTC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;kBAuBfC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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