@sveltejs/kit 2.48.7 → 2.48.8
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/exports/index.js +46 -1
- package/src/exports/internal/index.js +16 -0
- package/src/exports/public.d.ts +11 -13
- package/src/runtime/app/server/remote/form.js +60 -76
- package/src/runtime/client/remote-functions/form.svelte.js +6 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +47 -17
- package/types/index.d.ts.map +4 -2
package/package.json
CHANGED
package/src/exports/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
2
|
+
|
|
3
|
+
import { HttpError, Redirect, ActionFailure, ValidationError } from './internal/index.js';
|
|
2
4
|
import { BROWSER, DEV } from 'esm-env';
|
|
3
5
|
import {
|
|
4
6
|
add_data_suffix,
|
|
@@ -215,6 +217,49 @@ export function isActionFailure(e) {
|
|
|
215
217
|
return e instanceof ActionFailure;
|
|
216
218
|
}
|
|
217
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Use this to throw a validation error to imperatively fail form validation.
|
|
222
|
+
* Can be used in combination with `issue` passed to form actions to create field-specific issues.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { invalid } from '@sveltejs/kit';
|
|
227
|
+
* import { form } from '$app/server';
|
|
228
|
+
* import { tryLogin } from '$lib/server/auth';
|
|
229
|
+
* import * as v from 'valibot';
|
|
230
|
+
*
|
|
231
|
+
* export const login = form(
|
|
232
|
+
* v.object({ name: v.string(), _password: v.string() }),
|
|
233
|
+
* async ({ name, _password }) => {
|
|
234
|
+
* const success = tryLogin(name, _password);
|
|
235
|
+
* if (!success) {
|
|
236
|
+
* invalid('Incorrect username or password');
|
|
237
|
+
* }
|
|
238
|
+
*
|
|
239
|
+
* // ...
|
|
240
|
+
* }
|
|
241
|
+
* );
|
|
242
|
+
* ```
|
|
243
|
+
* @param {...(StandardSchemaV1.Issue | string)} issues
|
|
244
|
+
* @returns {never}
|
|
245
|
+
* @since 2.47.3
|
|
246
|
+
*/
|
|
247
|
+
export function invalid(...issues) {
|
|
248
|
+
throw new ValidationError(
|
|
249
|
+
issues.map((issue) => (typeof issue === 'string' ? { message: issue } : issue))
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Checks whether this is an validation error thrown by {@link invalid}.
|
|
255
|
+
* @param {unknown} e The object to check.
|
|
256
|
+
* @return {e is import('./public.js').ActionFailure}
|
|
257
|
+
* @since 2.47.3
|
|
258
|
+
*/
|
|
259
|
+
export function isValidationError(e) {
|
|
260
|
+
return e instanceof ValidationError;
|
|
261
|
+
}
|
|
262
|
+
|
|
218
263
|
/**
|
|
219
264
|
* Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.
|
|
220
265
|
* Returns the normalized URL as well as a method for adding the potential suffix back
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
2
|
+
|
|
1
3
|
export class HttpError {
|
|
2
4
|
/**
|
|
3
5
|
* @param {number} status
|
|
@@ -62,4 +64,18 @@ export class ActionFailure {
|
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Error thrown when form validation fails imperatively
|
|
69
|
+
*/
|
|
70
|
+
export class ValidationError extends Error {
|
|
71
|
+
/**
|
|
72
|
+
* @param {StandardSchemaV1.Issue[]} issues
|
|
73
|
+
*/
|
|
74
|
+
constructor(issues) {
|
|
75
|
+
super('Validation failed');
|
|
76
|
+
this.name = 'ValidationError';
|
|
77
|
+
this.issues = issues;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
65
81
|
export { init_remote_functions } from './remote-functions.js';
|
package/src/exports/public.d.ts
CHANGED
|
@@ -1992,10 +1992,13 @@ type ExtractId<Input> = Input extends { id: infer Id }
|
|
|
1992
1992
|
: string | number;
|
|
1993
1993
|
|
|
1994
1994
|
/**
|
|
1995
|
-
*
|
|
1996
|
-
*
|
|
1995
|
+
* A function and proxy object used to imperatively create validation errors in form handlers.
|
|
1996
|
+
*
|
|
1997
|
+
* Access properties to create field-specific issues: `issue.fieldName('message')`.
|
|
1998
|
+
* The type structure mirrors the input data structure for type-safe field access.
|
|
1999
|
+
* Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.
|
|
1997
2000
|
*/
|
|
1998
|
-
type InvalidField<T> =
|
|
2001
|
+
export type InvalidField<T> =
|
|
1999
2002
|
WillRecurseIndefinitely<T> extends true
|
|
2000
2003
|
? Record<string | number, any>
|
|
2001
2004
|
: NonNullable<T> extends string | number | boolean | File
|
|
@@ -2011,15 +2014,12 @@ type InvalidField<T> =
|
|
|
2011
2014
|
: Record<string, never>;
|
|
2012
2015
|
|
|
2013
2016
|
/**
|
|
2014
|
-
* A
|
|
2015
|
-
*
|
|
2016
|
-
* Call `invalid(issue1, issue2, ...issueN)` to throw a validation error.
|
|
2017
|
-
* If an issue is a `string`, it applies to the form as a whole (and will show up in `fields.allIssues()`)
|
|
2018
|
-
* Access properties to create field-specific issues: `invalid.fieldName('message')`.
|
|
2019
|
-
* The type structure mirrors the input data structure for type-safe field access.
|
|
2017
|
+
* A validation error thrown by `invalid`.
|
|
2020
2018
|
*/
|
|
2021
|
-
export
|
|
2022
|
-
|
|
2019
|
+
export interface ValidationError {
|
|
2020
|
+
/** The validation issues */
|
|
2021
|
+
issues: StandardSchemaV1.Issue[];
|
|
2022
|
+
}
|
|
2023
2023
|
|
|
2024
2024
|
/**
|
|
2025
2025
|
* The return value of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
@@ -2067,8 +2067,6 @@ export type RemoteForm<Input extends RemoteFormInput | void, Output> = {
|
|
|
2067
2067
|
includeUntouched?: boolean;
|
|
2068
2068
|
/** Set this to `true` to only run the `preflight` validation. */
|
|
2069
2069
|
preflightOnly?: boolean;
|
|
2070
|
-
/** Perform validation as if the form was submitted by the given button. */
|
|
2071
|
-
submitter?: HTMLButtonElement | HTMLInputElement;
|
|
2072
2070
|
}): Promise<void>;
|
|
2073
2071
|
/** The result of the form submission */
|
|
2074
2072
|
get result(): Output | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { RemoteFormInput, RemoteForm } from '@sveltejs/kit' */
|
|
1
|
+
/** @import { RemoteFormInput, RemoteForm, InvalidField } from '@sveltejs/kit' */
|
|
2
2
|
/** @import { InternalRemoteFormIssue, MaybePromise, RemoteInfo } from 'types' */
|
|
3
3
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
4
4
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
flatten_issues
|
|
14
14
|
} from '../../../form-utils.js';
|
|
15
15
|
import { get_cache, run_remote_function } from './shared.js';
|
|
16
|
+
import { ValidationError } from '@sveltejs/kit/internal';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Creates a form object that can be spread onto a `<form>` element.
|
|
@@ -21,7 +22,7 @@ import { get_cache, run_remote_function } from './shared.js';
|
|
|
21
22
|
*
|
|
22
23
|
* @template Output
|
|
23
24
|
* @overload
|
|
24
|
-
* @param {(
|
|
25
|
+
* @param {() => MaybePromise<Output>} fn
|
|
25
26
|
* @returns {RemoteForm<void, Output>}
|
|
26
27
|
* @since 2.27
|
|
27
28
|
*/
|
|
@@ -34,7 +35,7 @@ import { get_cache, run_remote_function } from './shared.js';
|
|
|
34
35
|
* @template Output
|
|
35
36
|
* @overload
|
|
36
37
|
* @param {'unchecked'} validate
|
|
37
|
-
* @param {(data: Input,
|
|
38
|
+
* @param {(data: Input, issue: InvalidField<Input>) => MaybePromise<Output>} fn
|
|
38
39
|
* @returns {RemoteForm<Input, Output>}
|
|
39
40
|
* @since 2.27
|
|
40
41
|
*/
|
|
@@ -47,7 +48,7 @@ import { get_cache, run_remote_function } from './shared.js';
|
|
|
47
48
|
* @template Output
|
|
48
49
|
* @overload
|
|
49
50
|
* @param {Schema} validate
|
|
50
|
-
* @param {(data: StandardSchemaV1.InferOutput<Schema>,
|
|
51
|
+
* @param {(data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>} fn
|
|
51
52
|
* @returns {RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>}
|
|
52
53
|
* @since 2.27
|
|
53
54
|
*/
|
|
@@ -55,7 +56,7 @@ import { get_cache, run_remote_function } from './shared.js';
|
|
|
55
56
|
* @template {RemoteFormInput} Input
|
|
56
57
|
* @template Output
|
|
57
58
|
* @param {any} validate_or_fn
|
|
58
|
-
* @param {(
|
|
59
|
+
* @param {(data_or_issue: any, issue?: any) => MaybePromise<Output>} [maybe_fn]
|
|
59
60
|
* @returns {RemoteForm<Input, Output>}
|
|
60
61
|
* @since 2.27
|
|
61
62
|
*/
|
|
@@ -165,7 +166,7 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
165
166
|
|
|
166
167
|
state.refreshes ??= {};
|
|
167
168
|
|
|
168
|
-
const
|
|
169
|
+
const issue = create_issues();
|
|
169
170
|
|
|
170
171
|
try {
|
|
171
172
|
output.result = await run_remote_function(
|
|
@@ -174,7 +175,7 @@ export function form(validate_or_fn, maybe_fn) {
|
|
|
174
175
|
true,
|
|
175
176
|
data,
|
|
176
177
|
(d) => d,
|
|
177
|
-
(data) => (!maybe_fn ? fn(
|
|
178
|
+
(data) => (!maybe_fn ? fn() : fn(data, issue))
|
|
178
179
|
);
|
|
179
180
|
} catch (e) {
|
|
180
181
|
if (e instanceof ValidationError) {
|
|
@@ -328,89 +329,72 @@ function handle_issues(output, issues, is_remote_request, form_data) {
|
|
|
328
329
|
|
|
329
330
|
/**
|
|
330
331
|
* Creates an invalid function that can be used to imperatively mark form fields as invalid
|
|
331
|
-
* @returns {
|
|
332
|
+
* @returns {InvalidField<any>}
|
|
332
333
|
*/
|
|
333
|
-
function
|
|
334
|
-
/**
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
334
|
+
function create_issues() {
|
|
335
|
+
return /** @type {InvalidField<any>} */ (
|
|
336
|
+
new Proxy(
|
|
337
|
+
/** @param {string} message */
|
|
338
|
+
(message) => {
|
|
339
|
+
// TODO 3.0 remove
|
|
340
|
+
if (typeof message !== 'string') {
|
|
341
|
+
throw new Error(
|
|
342
|
+
'`invalid` should now be imported from `@sveltejs/kit` to throw validation issues. ' +
|
|
343
|
+
"The second parameter provided to the form function (renamed to `issue`) is still used to construct issues, e.g. `invalid(issue.field('message'))`. " +
|
|
344
|
+
'For more info see https://github.com/sveltejs/kit/pulls/14768'
|
|
345
|
+
);
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
return
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return /** @type {import('@sveltejs/kit').Invalid} */ (
|
|
354
|
-
new Proxy(invalid, {
|
|
355
|
-
get(target, prop) {
|
|
356
|
-
if (typeof prop === 'symbol') return /** @type {any} */ (target)[prop];
|
|
348
|
+
return create_issue(message);
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
get(target, prop) {
|
|
352
|
+
if (typeof prop === 'symbol') return /** @type {any} */ (target)[prop];
|
|
357
353
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
* @param {(string | number)[]} path
|
|
361
|
-
* @returns {StandardSchemaV1.Issue}
|
|
362
|
-
*/
|
|
363
|
-
const create_issue = (message, path = []) => ({
|
|
364
|
-
message,
|
|
365
|
-
path
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
return create_issue_proxy(prop, create_issue, []);
|
|
354
|
+
return create_issue_proxy(prop, []);
|
|
355
|
+
}
|
|
369
356
|
}
|
|
370
|
-
|
|
357
|
+
)
|
|
371
358
|
);
|
|
372
|
-
}
|
|
373
359
|
|
|
374
|
-
/**
|
|
375
|
-
* Error thrown when form validation fails imperatively
|
|
376
|
-
*/
|
|
377
|
-
class ValidationError extends Error {
|
|
378
360
|
/**
|
|
379
|
-
* @param {
|
|
361
|
+
* @param {string} message
|
|
362
|
+
* @param {(string | number)[]} path
|
|
363
|
+
* @returns {StandardSchemaV1.Issue}
|
|
380
364
|
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
365
|
+
function create_issue(message, path = []) {
|
|
366
|
+
return {
|
|
367
|
+
message,
|
|
368
|
+
path
|
|
369
|
+
};
|
|
385
370
|
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Creates a proxy that builds up a path and returns a function to create an issue
|
|
390
|
-
* @param {string | number} key
|
|
391
|
-
* @param {(message: string, path: (string | number)[]) => StandardSchemaV1.Issue} create_issue
|
|
392
|
-
* @param {(string | number)[]} path
|
|
393
|
-
*/
|
|
394
|
-
function create_issue_proxy(key, create_issue, path) {
|
|
395
|
-
const new_path = [...path, key];
|
|
396
371
|
|
|
397
372
|
/**
|
|
398
|
-
*
|
|
399
|
-
* @
|
|
373
|
+
* Creates a proxy that builds up a path and returns a function to create an issue
|
|
374
|
+
* @param {string | number} key
|
|
375
|
+
* @param {(string | number)[]} path
|
|
400
376
|
*/
|
|
401
|
-
|
|
377
|
+
function create_issue_proxy(key, path) {
|
|
378
|
+
const new_path = [...path, key];
|
|
402
379
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
380
|
+
/**
|
|
381
|
+
* @param {string} message
|
|
382
|
+
* @returns {StandardSchemaV1.Issue}
|
|
383
|
+
*/
|
|
384
|
+
const issue_func = (message) => create_issue(message, new_path);
|
|
406
385
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
386
|
+
return new Proxy(issue_func, {
|
|
387
|
+
get(target, prop) {
|
|
388
|
+
if (typeof prop === 'symbol') return /** @type {any} */ (target)[prop];
|
|
411
389
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
390
|
+
// Handle array access like invalid.items[0]
|
|
391
|
+
if (/^\d+$/.test(prop)) {
|
|
392
|
+
return create_issue_proxy(parseInt(prop, 10), new_path);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Handle property access like invalid.field.nested
|
|
396
|
+
return create_issue_proxy(prop, new_path);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
}
|
|
416
400
|
}
|
|
@@ -522,7 +522,7 @@ export function form(id) {
|
|
|
522
522
|
},
|
|
523
523
|
validate: {
|
|
524
524
|
/** @type {RemoteForm<any, any>['validate']} */
|
|
525
|
-
value: async ({ includeUntouched = false, preflightOnly = false
|
|
525
|
+
value: async ({ includeUntouched = false, preflightOnly = false } = {}) => {
|
|
526
526
|
if (!element) return;
|
|
527
527
|
|
|
528
528
|
const id = ++validate_id;
|
|
@@ -530,7 +530,11 @@ export function form(id) {
|
|
|
530
530
|
// wait a tick in case the user is calling validate() right after set() which takes time to propagate
|
|
531
531
|
await tick();
|
|
532
532
|
|
|
533
|
-
const
|
|
533
|
+
const default_submitter = /** @type {HTMLElement | undefined} */ (
|
|
534
|
+
element.querySelector('button:not([type]), [type="submit"]')
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
const form_data = new FormData(element, default_submitter);
|
|
534
538
|
|
|
535
539
|
/** @type {InternalRemoteFormIssue[]} */
|
|
536
540
|
let array = [];
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1968,10 +1968,13 @@ declare module '@sveltejs/kit' {
|
|
|
1968
1968
|
: string | number;
|
|
1969
1969
|
|
|
1970
1970
|
/**
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
1971
|
+
* A function and proxy object used to imperatively create validation errors in form handlers.
|
|
1972
|
+
*
|
|
1973
|
+
* Access properties to create field-specific issues: `issue.fieldName('message')`.
|
|
1974
|
+
* The type structure mirrors the input data structure for type-safe field access.
|
|
1975
|
+
* Call `invalid(issue.foo(...), issue.nested.bar(...))` to throw a validation error.
|
|
1973
1976
|
*/
|
|
1974
|
-
type InvalidField<T> =
|
|
1977
|
+
export type InvalidField<T> =
|
|
1975
1978
|
WillRecurseIndefinitely<T> extends true
|
|
1976
1979
|
? Record<string | number, any>
|
|
1977
1980
|
: NonNullable<T> extends string | number | boolean | File
|
|
@@ -1987,15 +1990,12 @@ declare module '@sveltejs/kit' {
|
|
|
1987
1990
|
: Record<string, never>;
|
|
1988
1991
|
|
|
1989
1992
|
/**
|
|
1990
|
-
* A
|
|
1991
|
-
*
|
|
1992
|
-
* Call `invalid(issue1, issue2, ...issueN)` to throw a validation error.
|
|
1993
|
-
* If an issue is a `string`, it applies to the form as a whole (and will show up in `fields.allIssues()`)
|
|
1994
|
-
* Access properties to create field-specific issues: `invalid.fieldName('message')`.
|
|
1995
|
-
* The type structure mirrors the input data structure for type-safe field access.
|
|
1993
|
+
* A validation error thrown by `invalid`.
|
|
1996
1994
|
*/
|
|
1997
|
-
export
|
|
1998
|
-
|
|
1995
|
+
export interface ValidationError {
|
|
1996
|
+
/** The validation issues */
|
|
1997
|
+
issues: StandardSchemaV1.Issue[];
|
|
1998
|
+
}
|
|
1999
1999
|
|
|
2000
2000
|
/**
|
|
2001
2001
|
* The return value of a remote `form` function. See [Remote functions](https://svelte.dev/docs/kit/remote-functions#form) for full documentation.
|
|
@@ -2043,8 +2043,6 @@ declare module '@sveltejs/kit' {
|
|
|
2043
2043
|
includeUntouched?: boolean;
|
|
2044
2044
|
/** Set this to `true` to only run the `preflight` validation. */
|
|
2045
2045
|
preflightOnly?: boolean;
|
|
2046
|
-
/** Perform validation as if the form was submitted by the given button. */
|
|
2047
|
-
submitter?: HTMLButtonElement | HTMLInputElement;
|
|
2048
2046
|
}): Promise<void>;
|
|
2049
2047
|
/** The result of the form submission */
|
|
2050
2048
|
get result(): Output | undefined;
|
|
@@ -2702,6 +2700,38 @@ declare module '@sveltejs/kit' {
|
|
|
2702
2700
|
* @param e The object to check.
|
|
2703
2701
|
* */
|
|
2704
2702
|
export function isActionFailure(e: unknown): e is ActionFailure;
|
|
2703
|
+
/**
|
|
2704
|
+
* Use this to throw a validation error to imperatively fail form validation.
|
|
2705
|
+
* Can be used in combination with `issue` passed to form actions to create field-specific issues.
|
|
2706
|
+
*
|
|
2707
|
+
* @example
|
|
2708
|
+
* ```ts
|
|
2709
|
+
* import { invalid } from '@sveltejs/kit';
|
|
2710
|
+
* import { form } from '$app/server';
|
|
2711
|
+
* import { tryLogin } from '$lib/server/auth';
|
|
2712
|
+
* import * as v from 'valibot';
|
|
2713
|
+
*
|
|
2714
|
+
* export const login = form(
|
|
2715
|
+
* v.object({ name: v.string(), _password: v.string() }),
|
|
2716
|
+
* async ({ name, _password }) => {
|
|
2717
|
+
* const success = tryLogin(name, _password);
|
|
2718
|
+
* if (!success) {
|
|
2719
|
+
* invalid('Incorrect username or password');
|
|
2720
|
+
* }
|
|
2721
|
+
*
|
|
2722
|
+
* // ...
|
|
2723
|
+
* }
|
|
2724
|
+
* );
|
|
2725
|
+
* ```
|
|
2726
|
+
* @since 2.47.3
|
|
2727
|
+
*/
|
|
2728
|
+
export function invalid(...issues: (StandardSchemaV1.Issue | string)[]): never;
|
|
2729
|
+
/**
|
|
2730
|
+
* Checks whether this is an validation error thrown by {@link invalid}.
|
|
2731
|
+
* @param e The object to check.
|
|
2732
|
+
* @since 2.47.3
|
|
2733
|
+
*/
|
|
2734
|
+
export function isValidationError(e: unknown): e is ActionFailure;
|
|
2705
2735
|
/**
|
|
2706
2736
|
* Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.
|
|
2707
2737
|
* Returns the normalized URL as well as a method for adding the potential suffix back
|
|
@@ -3134,7 +3164,7 @@ declare module '$app/paths' {
|
|
|
3134
3164
|
}
|
|
3135
3165
|
|
|
3136
3166
|
declare module '$app/server' {
|
|
3137
|
-
import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, RemotePrerenderFunction, RemoteQueryFunction } from '@sveltejs/kit';
|
|
3167
|
+
import type { RequestEvent, RemoteCommand, RemoteForm, RemoteFormInput, InvalidField, RemotePrerenderFunction, RemoteQueryFunction } from '@sveltejs/kit';
|
|
3138
3168
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3139
3169
|
/**
|
|
3140
3170
|
* Read the contents of an imported asset from the filesystem
|
|
@@ -3188,7 +3218,7 @@ declare module '$app/server' {
|
|
|
3188
3218
|
*
|
|
3189
3219
|
* @since 2.27
|
|
3190
3220
|
*/
|
|
3191
|
-
export function form<Output>(fn: (
|
|
3221
|
+
export function form<Output>(fn: () => MaybePromise<Output>): RemoteForm<void, Output>;
|
|
3192
3222
|
/**
|
|
3193
3223
|
* Creates a form object that can be spread onto a `<form>` element.
|
|
3194
3224
|
*
|
|
@@ -3196,7 +3226,7 @@ declare module '$app/server' {
|
|
|
3196
3226
|
*
|
|
3197
3227
|
* @since 2.27
|
|
3198
3228
|
*/
|
|
3199
|
-
export function form<Input extends RemoteFormInput, Output>(validate: "unchecked", fn: (data: Input,
|
|
3229
|
+
export function form<Input extends RemoteFormInput, Output>(validate: "unchecked", fn: (data: Input, issue: InvalidField<Input>) => MaybePromise<Output>): RemoteForm<Input, Output>;
|
|
3200
3230
|
/**
|
|
3201
3231
|
* Creates a form object that can be spread onto a `<form>` element.
|
|
3202
3232
|
*
|
|
@@ -3204,7 +3234,7 @@ declare module '$app/server' {
|
|
|
3204
3234
|
*
|
|
3205
3235
|
* @since 2.27
|
|
3206
3236
|
*/
|
|
3207
|
-
export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>,
|
|
3237
|
+
export function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => MaybePromise<Output>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
3208
3238
|
/**
|
|
3209
3239
|
* Creates a remote prerender function. When called from the browser, the function will be invoked on the server via a `fetch` call.
|
|
3210
3240
|
*
|
package/types/index.d.ts.map
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"RemoteFormIssue",
|
|
76
76
|
"ExtractId",
|
|
77
77
|
"InvalidField",
|
|
78
|
-
"
|
|
78
|
+
"ValidationError",
|
|
79
79
|
"RemoteForm",
|
|
80
80
|
"RemoteCommand",
|
|
81
81
|
"RemoteResource",
|
|
@@ -128,6 +128,8 @@
|
|
|
128
128
|
"json",
|
|
129
129
|
"text",
|
|
130
130
|
"isActionFailure",
|
|
131
|
+
"invalid",
|
|
132
|
+
"isValidationError",
|
|
131
133
|
"normalizeUrl",
|
|
132
134
|
"VERSION",
|
|
133
135
|
"sequence",
|
|
@@ -213,6 +215,6 @@
|
|
|
213
215
|
null,
|
|
214
216
|
null
|
|
215
217
|
],
|
|
216
|
-
"mappings": ";;;;;;;;MA+BKA,IAAIA;;;;;kBAKQC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;MAQrBC,aAAaA;;;;;OAKJC,YAAYA;;kBAETC,aAAaA;;;;;;MAMzBC,qBAAqBA;;;;;;;;;;;kBAWTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8IPC,MAAMA;;;;;;;;;;;kBAWNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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