svelte-effect-runtime 1.6.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/client-BeOE81fW.js +577 -0
- package/.dist/chunks/client-BeOE81fW.js.map +1 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
- package/.dist/chunks/transform-BtlxgJrg.js +836 -0
- package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
- package/.dist/detect.d.ts +34 -0
- package/.dist/detect.js +56 -0
- package/.dist/detect.js.map +1 -0
- package/.dist/dispatcher/deps.d.ts +14 -0
- package/.dist/dispatcher/fibers.d.ts +52 -0
- package/.dist/dispatcher/index.d.ts +138 -0
- package/.dist/dispatcher/types.d.ts +63 -0
- package/.dist/dispatcher.d.ts +2 -0
- package/.dist/dispatcher.js +2 -0
- package/.dist/error.d.ts +77 -0
- package/.dist/generators.d.ts +16 -0
- package/.dist/internal/descriptors.d.ts +17 -0
- package/.dist/internal/generators.d.ts +6 -0
- package/.dist/internal/generators.js +5 -0
- package/.dist/internal/remote-client.d.ts +6 -0
- package/.dist/internal/remote-client.js +2 -0
- package/.dist/internal/remote-server.d.ts +6 -0
- package/.dist/internal/remote-server.js +2 -0
- package/.dist/markup/promise.d.ts +15 -0
- package/.dist/markup/promise.js +26 -0
- package/.dist/markup/promise.js.map +1 -0
- package/.dist/markup/run.d.ts +12 -0
- package/.dist/markup/run.js +21 -0
- package/.dist/markup/run.js.map +1 -0
- package/.dist/markup/transform/apply.d.ts +6 -0
- package/.dist/markup/transform/classify.d.ts +15 -0
- package/.dist/markup/transform/constants.d.ts +5 -0
- package/.dist/markup/transform/emit.d.ts +12 -0
- package/.dist/markup/transform/expressions.d.ts +39 -0
- package/.dist/markup/transform/index.d.ts +19 -0
- package/.dist/markup/transform/scan.d.ts +8 -0
- package/.dist/markup/transform/types.d.ts +64 -0
- package/.dist/markup/transform.d.ts +1 -0
- package/.dist/markup/transform.js +2 -0
- package/.dist/markup/value.d.ts +20 -0
- package/.dist/markup/value.js +32 -0
- package/.dist/markup/value.js.map +1 -0
- package/.dist/mod.d.ts +186 -0
- package/.dist/mod.js +190 -0
- package/.dist/mod.js.map +1 -0
- package/.dist/preprocess/ast.d.ts +51 -0
- package/.dist/preprocess/imports.d.ts +22 -0
- package/.dist/preprocess/index.d.ts +21 -0
- package/.dist/preprocess/lower.d.ts +12 -0
- package/.dist/preprocess/runtime-block.d.ts +8 -0
- package/.dist/preprocess/source.d.ts +29 -0
- package/.dist/preprocess/types.d.ts +70 -0
- package/.dist/preprocess.d.ts +2 -0
- package/.dist/preprocess.js +3 -0
- package/.dist/remote/client/command.d.ts +17 -0
- package/.dist/remote/client/effect.d.ts +15 -0
- package/.dist/remote/client/failures.d.ts +57 -0
- package/.dist/remote/client/form-data.d.ts +8 -0
- package/.dist/remote/client/form-enhance.d.ts +9 -0
- package/.dist/remote/client/form-transport.d.ts +20 -0
- package/.dist/remote/client/form.d.ts +21 -0
- package/.dist/remote/client/index.d.ts +4 -0
- package/.dist/remote/client/query-result.d.ts +14 -0
- package/.dist/remote/client/query.d.ts +57 -0
- package/.dist/remote/client/responses.d.ts +28 -0
- package/.dist/remote/client/types.d.ts +83 -0
- package/.dist/remote/client/utils.d.ts +11 -0
- package/.dist/remote/client.d.ts +2 -0
- package/.dist/remote/client.js +2 -0
- package/.dist/remote/server.d.ts +66 -0
- package/.dist/remote/server.js +104 -0
- package/.dist/remote/server.js.map +1 -0
- package/.dist/remote/shared.d.ts +202 -0
- package/.dist/remote/shared.js +161 -0
- package/.dist/remote/shared.js.map +1 -0
- package/.dist/runtime/preprocess.d.ts +38 -0
- package/.dist/runtime/preprocess.js +54 -0
- package/.dist/runtime/preprocess.js.map +1 -0
- package/.dist/server/effects.d.ts +49 -0
- package/.dist/server/factories.d.ts +97 -0
- package/.dist/server/index.d.ts +3 -0
- package/.dist/server/invalid.d.ts +9 -0
- package/.dist/server/runtime.d.ts +66 -0
- package/.dist/server/schema.d.ts +42 -0
- package/.dist/server/types.d.ts +271 -0
- package/.dist/server/wrappers.d.ts +45 -0
- package/.dist/server.d.ts +2 -0
- package/.dist/server.js +527 -0
- package/.dist/server.js.map +1 -0
- package/.dist/vite.d.ts +42 -0
- package/.dist/vite.js +118 -0
- package/.dist/vite.js.map +1 -0
- package/README.md +2 -0
- package/package.json +66 -101
- package/dist/chunks/client-vV6UAwoP.js +0 -199
- package/dist/chunks/client-vV6UAwoP.js.map +0 -1
- package/dist/chunks/effect-Crj3S8Cg.js +0 -51
- package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
- package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
- package/dist/chunks/markup-CkPUZIJt.js +0 -13390
- package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
- package/dist/chunks/preprocess-BFePqOC6.js +0 -49
- package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
- package/dist/chunks/server-Dea1CJuY.js +0 -704
- package/dist/chunks/server-Dea1CJuY.js.map +0 -1
- package/dist/chunks/v3-D0c0MKPf.js +0 -1
- package/dist/chunks/v4-MMhHmzIG.js +0 -1
- package/dist/chunks/vite-BlUTKv2u.js +0 -152
- package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -2
- package/dist/effect.d.ts +0 -1
- package/dist/effect.js +0 -2
- package/dist/internal/app-server-shim.d.ts +0 -8
- package/dist/internal/effect-compat.d.ts +0 -21
- package/dist/internal/markup.d.ts +0 -11
- package/dist/internal/markup.js +0 -2
- package/dist/internal/remote-client.d.ts +0 -36
- package/dist/internal/remote-client.js +0 -527
- package/dist/internal/remote-client.js.map +0 -1
- package/dist/internal/remote-shared.d.ts +0 -186
- package/dist/internal/remote-shared.js +0 -122
- package/dist/internal/remote-shared.js.map +0 -1
- package/dist/internal/transform.d.ts +0 -18
- package/dist/internal/transform.js +0 -418
- package/dist/internal/transform.js.map +0 -1
- package/dist/language-server.d.ts +0 -9
- package/dist/language-server.js +0 -4
- package/dist/mod.d.ts +0 -22
- package/dist/mod.js +0 -3
- package/dist/preprocess.d.ts +0 -29
- package/dist/preprocess.js +0 -20
- package/dist/preprocess.js.map +0 -1
- package/dist/root-node.d.ts +0 -1
- package/dist/root-node.js +0 -63
- package/dist/root-node.js.map +0 -1
- package/dist/server.d.ts +0 -81
- package/dist/server.js +0 -85
- package/dist/server.js.map +0 -1
- package/dist/v3/client.d.ts +0 -117
- package/dist/v3/effect.d.ts +0 -17
- package/dist/v3/mod.d.ts +0 -27
- package/dist/v3/preprocess.d.ts +0 -28
- package/dist/v3/root-node.d.ts +0 -59
- package/dist/v3/server.d.ts +0 -297
- package/dist/v3/vite.d.ts +0 -46
- package/dist/v4/client.d.ts +0 -2
- package/dist/v4/effect.d.ts +0 -24
- package/dist/v4/effect.js +0 -19
- package/dist/v4/effect.js.map +0 -1
- package/dist/v4/mod.d.ts +0 -27
- package/dist/v4/mod.js +0 -3
- package/dist/v4/preprocess.d.ts +0 -34
- package/dist/v4/preprocess.js +0 -32
- package/dist/v4/preprocess.js.map +0 -1
- package/dist/v4/root-node.d.ts +0 -59
- package/dist/v4/root-node.js +0 -4
- package/dist/v4/server.d.ts +0 -340
- package/dist/v4/server.js +0 -71
- package/dist/v4/server.js.map +0 -1
- package/dist/v4/vite.d.ts +0 -34
- package/dist/v4/vite.js +0 -31
- package/dist/v4/vite.js.map +0 -1
- package/dist/vite.d.ts +0 -31
- package/dist/vite.js +0 -24
- package/dist/vite.js.map +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { RemoteFailure } from "../shared.js";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
type RemoteResourceEffect<Output> = Effect.Effect<Output, RemoteFailure<unknown>> & {
|
|
4
|
+
readonly current: Output | undefined;
|
|
5
|
+
readonly error: unknown;
|
|
6
|
+
readonly loading: boolean;
|
|
7
|
+
readonly ready: boolean;
|
|
8
|
+
};
|
|
9
|
+
type RemoteQueryEffect<Output> = RemoteResourceEffect<Output> & {
|
|
10
|
+
readonly refresh: () => Effect.Effect<void, unknown, never>;
|
|
11
|
+
readonly set: (value: Output) => void;
|
|
12
|
+
readonly withOverride: (update: (current: Output) => Output) => unknown;
|
|
13
|
+
};
|
|
14
|
+
type RemoteLiveQueryEffect<Output> = RemoteResourceEffect<Output> & AsyncIterable<Output> & {
|
|
15
|
+
readonly connected: boolean;
|
|
16
|
+
readonly done: boolean;
|
|
17
|
+
readonly reconnect: () => Effect.Effect<void, unknown, never>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates a remote query adapter. The returned function takes input and
|
|
21
|
+
* returns an `Effect` that executes SvelteKit's native query function.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const getUser = create_remote_query_adapter(nativeQuery, (value) => value);
|
|
26
|
+
* const user = yield* getUser({ id: 1 });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @since 2.0.0
|
|
30
|
+
* @param native_factory - SvelteKit's native query function or a legacy
|
|
31
|
+
* response factory used by tests.
|
|
32
|
+
* @param decode_payload - Function to decode the response payload.
|
|
33
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
34
|
+
* @returns A function returning an Effect of the response.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function create_remote_query_adapter<Input, Output>(native_factory: unknown, decode_payload: (value: unknown) => unknown, _base?: string): (input: Input) => RemoteQueryEffect<Output>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a remote live query adapter. The returned function takes input and
|
|
40
|
+
* returns an `Effect` that awaits the first live value while preserving live
|
|
41
|
+
* stream state and reconnect controls.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
|
|
46
|
+
* const time = yield* getTime();
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @since 2.0.0
|
|
50
|
+
* @param native_factory - SvelteKit's native live query function.
|
|
51
|
+
* @param decode_payload - Function to decode the initial response payload.
|
|
52
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
53
|
+
* @returns A function returning an Effect-backed live query resource.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export declare function create_remote_live_query_adapter<Input, Output>(native_factory: unknown, decode_payload: (value: unknown) => unknown, _base?: string): (input: Input) => RemoteLiveQueryEffect<Output>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RemoteFailure } from "../shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a failed fetch response into the runtime failure model.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const failure = await decode_response_failure(response);
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @since 2.0.0
|
|
11
|
+
* @param response - Failed fetch response returned by the remote endpoint.
|
|
12
|
+
* @returns Remote failure represented by the response.
|
|
13
|
+
*/
|
|
14
|
+
export declare function decode_response_failure(response: Response): Promise<RemoteFailure<unknown>>;
|
|
15
|
+
/**
|
|
16
|
+
* Decodes either a raw value or `Response` returned by a native remote helper.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const output = await decode_response_or_value(result, decode_payload);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
* @param value - Native result value or fetch response.
|
|
25
|
+
* @param decode_payload - Function used to decode successful payloads.
|
|
26
|
+
* @returns Decoded successful output.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decode_response_or_value<Output>(value: unknown, decode_payload: (value: unknown) => unknown): Promise<Output>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { RemoteForm, RemoteFormInput } from "@sveltejs/kit";
|
|
2
|
+
import type { RemoteFailure } from "../shared.js";
|
|
3
|
+
import type { Effect } from "effect";
|
|
4
|
+
/**
|
|
5
|
+
* Represents a pending operation counter that remote command adapters
|
|
6
|
+
* use to track in-flight requests.
|
|
7
|
+
*
|
|
8
|
+
* @since 2.0.0
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export interface Pending {
|
|
12
|
+
/** Current count of in-flight requests. */
|
|
13
|
+
value: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Native callable method shape used when reflecting SvelteKit remote helpers.
|
|
17
|
+
*
|
|
18
|
+
* @since 2.0.0
|
|
19
|
+
*/
|
|
20
|
+
export type NativeMethod = (...args: unknown[]) => unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Property bag shape used for native SvelteKit form objects.
|
|
23
|
+
*
|
|
24
|
+
* @since 2.0.0
|
|
25
|
+
*/
|
|
26
|
+
export type NativeFormRecord = Record<PropertyKey, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Represents the form submit handle passed into an Effect-aware enhanced
|
|
29
|
+
* remote form callback.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* form.enhance(({ submit }) =>
|
|
34
|
+
* Effect.gen(function* () {
|
|
35
|
+
* yield* submit().updates();
|
|
36
|
+
* })
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @since 2.0.0
|
|
41
|
+
*/
|
|
42
|
+
export type EffectRemoteFormSubmit = Effect.Effect<unknown, RemoteFailure<unknown>> & {
|
|
43
|
+
updates: (...updates: unknown[]) => Effect.Effect<unknown, RemoteFailure<unknown>>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Represents the callback payload passed to an Effect-aware remote form
|
|
47
|
+
* enhancement callback.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* form.enhance(({ data, submit }) =>
|
|
52
|
+
* Effect.gen(function* () {
|
|
53
|
+
* console.log(data);
|
|
54
|
+
* yield* submit();
|
|
55
|
+
* })
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @since 2.0.0
|
|
60
|
+
*/
|
|
61
|
+
export type EffectRemoteFormEnhanceOptions<Input extends RemoteFormInput | void> = Omit<Parameters<RemoteForm<Input, unknown>["enhance"]>[0] extends (options: infer Options) => unknown ? Options : never, "submit"> & {
|
|
62
|
+
submit: () => EffectRemoteFormSubmit;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Represents a SvelteKit remote form whose submission, validation, and
|
|
66
|
+
* enhancement hooks expose Effect-returning APIs.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const form = create_remote_form_adapter(nativeForm, (value) => value);
|
|
71
|
+
*
|
|
72
|
+
* yield* form.preflight(schema).validate();
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @since 2.0.0
|
|
76
|
+
*/
|
|
77
|
+
export type EffectRemoteForm<Input extends RemoteFormInput | void, Output> = ((input: Input) => Effect.Effect<Output, RemoteFailure<unknown>>) & Omit<RemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
|
|
78
|
+
enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<RemoteForm<Input, Output>["enhance"]>;
|
|
79
|
+
for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): Omit<EffectRemoteForm<Input, Output>, "for">;
|
|
80
|
+
preflight(schema: unknown): EffectRemoteForm<Input, Output>;
|
|
81
|
+
submit(input: Input): Effect.Effect<Output, RemoteFailure<unknown>>;
|
|
82
|
+
validate(options?: Parameters<RemoteForm<Input, Output>["validate"]>[0]): Effect.Effect<void, RemoteFailure<unknown>>;
|
|
83
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { copy_property_descriptors } from "../../internal/descriptors.js";
|
|
2
|
+
import type { NativeMethod } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Checks whether a value has a callable method property.
|
|
5
|
+
*
|
|
6
|
+
* @since 2.0.0
|
|
7
|
+
* @param value - Value to inspect.
|
|
8
|
+
* @param key - Method key to look up.
|
|
9
|
+
* @returns Whether the value has a function at `key`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function has_method<K extends PropertyKey>(value: unknown, key: K): value is Record<K, NativeMethod>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter, } from "./client/index.js";
|
|
2
|
+
export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormSubmit, Pending, } from "./client/index.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-BeOE81fW.js";
|
|
2
|
+
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Cause, Effect } from "effect";
|
|
2
|
+
import type { FormIssue } from "./shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runs a user-supplied Effect program through a ManagedRuntime, maps its
|
|
5
|
+
* exit into the shape expected by SvelteKit, and returns the result or
|
|
6
|
+
* throws a SvelteKit-compatible error.
|
|
7
|
+
*
|
|
8
|
+
* @since 2.0.0
|
|
9
|
+
* @param effect - The Effect program to execute.
|
|
10
|
+
* @param runtime - The server-side ManagedRuntime.
|
|
11
|
+
* @param invalid - SvelteKit's `invalid` helper (bound per-request).
|
|
12
|
+
* @param error - SvelteKit's `error` helper.
|
|
13
|
+
* @returns A Promise that resolves with the effect's success value.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function run_remote_effect<A>(effect: Effect.Effect<A, unknown, unknown>, runtime: {
|
|
17
|
+
runPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;
|
|
18
|
+
}, invalid: (status: number, body: unknown) => never, error: (status: number, body: unknown) => never): Promise<A>;
|
|
19
|
+
/**
|
|
20
|
+
* Encodes an Effect Cause into a string that the client-side adapter can
|
|
21
|
+
* decode back into a typed `RemoteFailure`.
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
* @param cause - The Effect Cause from a failed execution.
|
|
25
|
+
* @returns A devalue-encoded string representing the serialised failure.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function encode_remote_failure(cause: Cause.Cause<unknown>): string;
|
|
29
|
+
/**
|
|
30
|
+
* Throws a SvelteKit `invalid` response from a {@link FormError}, calling
|
|
31
|
+
* through to the request-scoped `invalid` helper.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* throw_form_error(
|
|
36
|
+
* [{ message: "Name is required", path: ["name"] }],
|
|
37
|
+
* invalid,
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @since 2.0.0
|
|
42
|
+
* @param issues - The list of form validation issues.
|
|
43
|
+
* @param invalid - SvelteKit's `invalid` helper bound to the current request.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export declare function throw_form_error(issues: readonly FormIssue[], invalid: (status: number, body: unknown) => never): never;
|
|
47
|
+
/**
|
|
48
|
+
* Remaps low-level SvelteKit errors (e.g. "Cannot use ___ outside a route")
|
|
49
|
+
* into clear, actionable messages.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* try {
|
|
54
|
+
* return native_query(handler);
|
|
55
|
+
* } catch (err) {
|
|
56
|
+
* throw normalize_remote_helper_error(err, "Query");
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @since 2.0.0
|
|
61
|
+
* @param err - The error thrown by SvelteKit's native functions.
|
|
62
|
+
* @param helper_name - Name of the helper that triggered the error.
|
|
63
|
+
* @returns A more descriptive error.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export declare function normalize_remote_helper_error(err: unknown, helper_name: string): Error;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { create_serialized_remote_failure_envelope } from "./shared.js";
|
|
2
|
+
import { Cause, Effect, Exit } from "effect";
|
|
3
|
+
import { stringify } from "devalue";
|
|
4
|
+
//#region src/remote/server.ts
|
|
5
|
+
/**
|
|
6
|
+
* Runs a user-supplied Effect program through a ManagedRuntime, maps its
|
|
7
|
+
* exit into the shape expected by SvelteKit, and returns the result or
|
|
8
|
+
* throws a SvelteKit-compatible error.
|
|
9
|
+
*
|
|
10
|
+
* @since 2.0.0
|
|
11
|
+
* @param effect - The Effect program to execute.
|
|
12
|
+
* @param runtime - The server-side ManagedRuntime.
|
|
13
|
+
* @param invalid - SvelteKit's `invalid` helper (bound per-request).
|
|
14
|
+
* @param error - SvelteKit's `error` helper.
|
|
15
|
+
* @returns A Promise that resolves with the effect's success value.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
async function run_remote_effect(effect, runtime, invalid, error) {
|
|
19
|
+
const exit = await runtime.runPromise(Effect.exit(effect));
|
|
20
|
+
if (Exit.isSuccess(exit)) return exit.value;
|
|
21
|
+
handle_failure(exit.cause, invalid, error);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Inspects the Effect Cause for failures and either throws a form
|
|
25
|
+
* validation error (via SvelteKit's `invalid`) or encodes the error
|
|
26
|
+
* and throws it via SvelteKit's `error`.
|
|
27
|
+
*/
|
|
28
|
+
function handle_failure(cause, invalid, error) {
|
|
29
|
+
const reasons = cause.reasons;
|
|
30
|
+
for (const reason of reasons) if (Cause.isFailReason(reason)) {
|
|
31
|
+
const failure = reason.error;
|
|
32
|
+
if (typeof failure === "object" && failure !== null && failure._tag === "FormError") invalid(400, { issues: failure.issues ?? [] });
|
|
33
|
+
}
|
|
34
|
+
error(500, create_serialized_remote_failure_envelope(encode_remote_failure(cause)));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Encodes an Effect Cause into a string that the client-side adapter can
|
|
38
|
+
* decode back into a typed `RemoteFailure`.
|
|
39
|
+
*
|
|
40
|
+
* @since 2.0.0
|
|
41
|
+
* @param cause - The Effect Cause from a failed execution.
|
|
42
|
+
* @returns A devalue-encoded string representing the serialised failure.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
function encode_remote_failure(cause) {
|
|
46
|
+
const reasons = cause.reasons;
|
|
47
|
+
for (const reason of reasons) if (Cause.isFailReason(reason)) {
|
|
48
|
+
const failure = reason.error;
|
|
49
|
+
if (typeof failure === "object" && failure !== null) try {
|
|
50
|
+
return stringify(failure);
|
|
51
|
+
} catch {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return stringify({ message: "Unknown error" });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Throws a SvelteKit `invalid` response from a {@link FormError}, calling
|
|
59
|
+
* through to the request-scoped `invalid` helper.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* throw_form_error(
|
|
64
|
+
* [{ message: "Name is required", path: ["name"] }],
|
|
65
|
+
* invalid,
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @since 2.0.0
|
|
70
|
+
* @param issues - The list of form validation issues.
|
|
71
|
+
* @param invalid - SvelteKit's `invalid` helper bound to the current request.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
function throw_form_error(issues, invalid) {
|
|
75
|
+
invalid(400, { issues });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Remaps low-level SvelteKit errors (e.g. "Cannot use ___ outside a route")
|
|
79
|
+
* into clear, actionable messages.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* try {
|
|
84
|
+
* return native_query(handler);
|
|
85
|
+
* } catch (err) {
|
|
86
|
+
* throw normalize_remote_helper_error(err, "Query");
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @since 2.0.0
|
|
91
|
+
* @param err - The error thrown by SvelteKit's native functions.
|
|
92
|
+
* @param helper_name - Name of the helper that triggered the error.
|
|
93
|
+
* @returns A more descriptive error.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
function normalize_remote_helper_error(err, helper_name) {
|
|
97
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
98
|
+
if (message.includes("Cannot use") || message.includes("outside a route")) return /* @__PURE__ */ new Error(`${helper_name} was called outside a .remote.ts file. Ensure the file is named \`*.remote.ts\` and is located in a route directory.`);
|
|
99
|
+
return err instanceof Error ? err : new Error(message);
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n effect: Effect.Effect<A, unknown, unknown>,\n runtime: {\n runPromise: (\n e: Effect.Effect<unknown, unknown, unknown>,\n ) => Promise<unknown>;\n },\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): Promise<A> {\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n ) as Exit.Exit<A, unknown>;\n\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n handle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n cause: Cause.Cause<unknown>,\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): never {\n const reasons =\n (cause as unknown as { reasons: Array<{ _tag: string; error?: unknown }> })\n .reasons;\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (\n typeof failure === \"object\" &&\n failure !== null &&\n (failure as Record<string, unknown>)._tag === \"FormError\"\n ) {\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\n [];\n invalid(400, { issues });\n }\n }\n }\n\n const encoded = encode_remote_failure(cause);\n const envelope = create_serialized_remote_failure_envelope(encoded);\n\n error(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n const reasons =\n (cause as unknown as { reasons: Array<{ _tag: string; error?: unknown }> })\n .reasons;\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (typeof failure === \"object\" && failure !== null) {\n try {\n return stringify(failure);\n } catch {\n continue;\n }\n }\n }\n }\n\n return stringify({ message: \"Unknown error\" });\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(\n issues: readonly FormIssue[],\n invalid: (status: number, body: unknown) => never,\n): never {\n invalid(400, { issues });\n}\n\n/**\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\n * into clear, actionable messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(\n err: unknown,\n helper_name: string,\n): Error {\n const message = err instanceof Error ? err.message : String(err);\n\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\n return new Error(\n `${helper_name} was called outside a .remote.ts file. ` +\n `Ensure the file is named \\`*.remote.ts\\` and is located in a route directory.`,\n );\n }\n\n return err instanceof Error ? err : new Error(message);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,eAAsB,kBACpB,QACA,SAKA,SACA,OACY;CACZ,MAAM,OAA8B,MAAM,QAAQ,WAChD,OAAO,KAAK,OAAO,CACpB;AAED,KAAI,KAAK,UAAU,KAAK,CACtB,QAAO,KAAK;AAGd,gBAAe,KAAK,OAAO,SAAS,MAAM;;;;;;;AAQ5C,SAAS,eACP,OACA,SACA,OACO;CACP,MAAM,UACH,MACE;AAEL,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;EACvC,MAAM,UAAU,OAAO;AACvB,MACE,OAAO,YAAY,YACnB,YAAY,QACX,QAAoC,SAAS,YAI9C,SAAQ,KAAK,EAAE,QAFC,QAA8C,UAC5D,EAAE,EACmB,CAAC;;AAQ9B,OAAM,KAFW,0CADD,sBAAsB,MAAM,CACuB,CAE/C;;;;;;;;;;;AAYtB,SAAgB,sBAAsB,OAAqC;CACzE,MAAM,UACH,MACE;AAEL,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;EACvC,MAAM,UAAU,OAAO;AACvB,MAAI,OAAO,YAAY,YAAY,YAAY,KAC7C,KAAI;AACF,UAAO,UAAU,QAAQ;UACnB;AACN;;;AAMR,QAAO,UAAU,EAAE,SAAS,iBAAiB,CAAC;;;;;;;;;;;;;;;;;;;AAoBhD,SAAgB,iBACd,QACA,SACO;AACP,SAAQ,KAAK,EAAE,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;AAsB1B,SAAgB,8BACd,KACA,aACO;CACP,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAEhE,KAAI,QAAQ,SAAS,aAAa,IAAI,QAAQ,SAAS,kBAAkB,CACvE,wBAAO,IAAI,MACT,GAAG,YAAY,sHAEhB;AAGH,QAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,QAAQ"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types, markers, and constructors used by both the client-side remote
|
|
3
|
+
* adapters and the server-side handler runtime. These types define the error
|
|
4
|
+
* protocol that flows across the network boundary.
|
|
5
|
+
*
|
|
6
|
+
* @since 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Well-known marker injected into every serialised remote-failure envelope
|
|
10
|
+
* so the client can reliably distinguish runtime errors from domain values.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.0.0
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
16
|
+
/**
|
|
17
|
+
* Well-known symbol used to attach a payload decoder to a remote function
|
|
18
|
+
* so the client's transport layer can decode domain error types.
|
|
19
|
+
*
|
|
20
|
+
* @since 2.0.0
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const REMOTE_ERROR_DECODER: unique symbol;
|
|
24
|
+
/** Form validation helpers and types. */
|
|
25
|
+
/**
|
|
26
|
+
* A single field-level or form-level validation issue reported by a
|
|
27
|
+
* {@link Form} handler.
|
|
28
|
+
*
|
|
29
|
+
* @since 2.0.0
|
|
30
|
+
*/
|
|
31
|
+
export interface FormIssue {
|
|
32
|
+
/** Human-readable validation message. */
|
|
33
|
+
message: string;
|
|
34
|
+
/** Path to the offending field as an array of string-or-number keys. */
|
|
35
|
+
path: (string | number)[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error subtype thrown by {@link Form} handlers to signal validation
|
|
39
|
+
* failures. The `issues` array is forwarded to SvelteKit's `invalid()`
|
|
40
|
+
* helper on the server and surfaced as `FormError` on the client.
|
|
41
|
+
*
|
|
42
|
+
* @since 2.0.0
|
|
43
|
+
*/
|
|
44
|
+
export interface FormError<SchemaType = unknown> {
|
|
45
|
+
readonly _tag: "FormError";
|
|
46
|
+
readonly issues: readonly FormIssue[];
|
|
47
|
+
/** Phantom type slot for the schema this error was derived from. */
|
|
48
|
+
readonly _schema?: SchemaType;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a {@link FormError} holding the given issues.
|
|
52
|
+
*
|
|
53
|
+
* @since 2.0.0
|
|
54
|
+
* @param issues - The validation issues to attach.
|
|
55
|
+
* @returns A FormError with the `_tag` set and no schema reference.
|
|
56
|
+
*/
|
|
57
|
+
export declare function create_form_error(issues: readonly FormIssue[]): FormError;
|
|
58
|
+
/**
|
|
59
|
+
* Type guard that narrows an unknown value to a {@link FormError}.
|
|
60
|
+
*
|
|
61
|
+
* @since 2.0.0
|
|
62
|
+
* @param value - The value to check.
|
|
63
|
+
* @returns `true` when the value is a FormError.
|
|
64
|
+
*/
|
|
65
|
+
export declare function is_form_error(value: unknown): value is FormError;
|
|
66
|
+
/** Remote error types shared by client and server helpers. */
|
|
67
|
+
/**
|
|
68
|
+
* Union of all wire-level error shapes that a remote function can
|
|
69
|
+
* surface on its error channel.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const result = yield* myQuery();
|
|
74
|
+
* // error channel is RemoteFailure<DomainError>
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @since 2.0.0
|
|
78
|
+
*/
|
|
79
|
+
export type RemoteFailure<ErrorType> = ErrorType | RemoteValidationError | RemoteHttpError | RemoteTransportError;
|
|
80
|
+
/**
|
|
81
|
+
* Validation errors that originate from a server-side {@link Form}
|
|
82
|
+
* handler calling `invalid()` (SvelteKit's `fail`).
|
|
83
|
+
*
|
|
84
|
+
* @since 2.0.0
|
|
85
|
+
*/
|
|
86
|
+
export interface RemoteValidationError {
|
|
87
|
+
readonly _tag: "RemoteValidationError";
|
|
88
|
+
readonly issues?: readonly FormIssue[];
|
|
89
|
+
readonly body?: unknown;
|
|
90
|
+
readonly status: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* HTTP-level errors with a status code and optional response body. Raised
|
|
94
|
+
* when the server explicitly calls SvelteKit's `error(status, body)`.
|
|
95
|
+
*
|
|
96
|
+
* @since 2.0.0
|
|
97
|
+
*/
|
|
98
|
+
export interface RemoteHttpError {
|
|
99
|
+
readonly _tag: "RemoteHttpError";
|
|
100
|
+
readonly status: number;
|
|
101
|
+
readonly body?: unknown;
|
|
102
|
+
readonly cause?: unknown;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Transport-level errors raised by the client adapter when the network
|
|
106
|
+
* request fails or the response cannot be decoded.
|
|
107
|
+
*
|
|
108
|
+
* @since 2.0.0
|
|
109
|
+
*/
|
|
110
|
+
export interface RemoteTransportError {
|
|
111
|
+
readonly _tag: "RemoteTransportError";
|
|
112
|
+
readonly cause?: unknown;
|
|
113
|
+
readonly body?: unknown;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Wire format for an encoded remote failure. The server wraps domain
|
|
117
|
+
* errors in this envelope before serialising them with devalue.
|
|
118
|
+
*
|
|
119
|
+
* @since 2.0.0
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export interface SerializedRemoteFailureEnvelope {
|
|
123
|
+
readonly __svelte_effect_remote__: true;
|
|
124
|
+
readonly encoded: string;
|
|
125
|
+
}
|
|
126
|
+
/** Constructors for structured remote error values. */
|
|
127
|
+
/**
|
|
128
|
+
* Creates a {@link RemoteValidationError} from a list of form issues.
|
|
129
|
+
*
|
|
130
|
+
* @since 2.0.0
|
|
131
|
+
* @param issues - The validation issues reported by the server handler.
|
|
132
|
+
* @param body - Optional response body returned alongside the error.
|
|
133
|
+
* @param status - HTTP status code (defaults to 400).
|
|
134
|
+
* @returns A remote-validation error shape.
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
export declare function create_remote_validation_error(issues: readonly FormIssue[], body?: unknown, status?: number): RemoteValidationError;
|
|
138
|
+
/**
|
|
139
|
+
* Creates a {@link RemoteHttpError} for a given HTTP status.
|
|
140
|
+
*
|
|
141
|
+
* @since 2.0.0
|
|
142
|
+
* @param status - The HTTP status code.
|
|
143
|
+
* @param body - Optional response body.
|
|
144
|
+
* @param cause - Optional underlying cause.
|
|
145
|
+
* @returns A remote HTTP error shape.
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export declare function create_remote_http_error(status: number, body?: unknown, cause?: unknown): RemoteHttpError;
|
|
149
|
+
/**
|
|
150
|
+
* Creates a {@link RemoteTransportError} for network or decode failures.
|
|
151
|
+
*
|
|
152
|
+
* @since 2.0.0
|
|
153
|
+
* @param cause - The underlying error that caused the transport failure.
|
|
154
|
+
* @param body - Optional response body if one was received.
|
|
155
|
+
* @returns A remote transport error shape.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
export declare function create_remote_transport_error(cause: unknown, body?: unknown): RemoteTransportError;
|
|
159
|
+
/**
|
|
160
|
+
* Wraps a devalue-encoded error string inside a
|
|
161
|
+
* {@link SerializedRemoteFailureEnvelope}.
|
|
162
|
+
*
|
|
163
|
+
* @since 2.0.0
|
|
164
|
+
* @param encoded - The devalue-encoded error value.
|
|
165
|
+
* @returns The wire-format envelope.
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
export declare function create_serialized_remote_failure_envelope(encoded: string): SerializedRemoteFailureEnvelope;
|
|
169
|
+
/** Type guards for structured remote error values. */
|
|
170
|
+
/**
|
|
171
|
+
* Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.
|
|
172
|
+
*
|
|
173
|
+
* @since 2.0.0
|
|
174
|
+
* @param value - The value to check.
|
|
175
|
+
* @returns `true` when the value is a serialised failure envelope.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
export declare function is_serialized_remote_failure_envelope(value: unknown): value is SerializedRemoteFailureEnvelope;
|
|
179
|
+
/**
|
|
180
|
+
* Checks whether a value is a {@link RemoteValidationError}.
|
|
181
|
+
*
|
|
182
|
+
* @since 2.0.0
|
|
183
|
+
* @param value - The value to check.
|
|
184
|
+
* @returns `true` when the value is a remote validation error.
|
|
185
|
+
*/
|
|
186
|
+
export declare function is_remote_validation_error(value: unknown): value is RemoteValidationError;
|
|
187
|
+
/**
|
|
188
|
+
* Checks whether a value is a {@link RemoteHttpError}.
|
|
189
|
+
*
|
|
190
|
+
* @since 2.0.0
|
|
191
|
+
* @param value - The value to check.
|
|
192
|
+
* @returns `true` when the value is a remote HTTP error.
|
|
193
|
+
*/
|
|
194
|
+
export declare function is_remote_http_error(value: unknown): value is RemoteHttpError;
|
|
195
|
+
/**
|
|
196
|
+
* Checks whether a value is a {@link RemoteTransportError}.
|
|
197
|
+
*
|
|
198
|
+
* @since 2.0.0
|
|
199
|
+
* @param value - The value to check.
|
|
200
|
+
* @returns `true` when the value is a remote transport error.
|
|
201
|
+
*/
|
|
202
|
+
export declare function is_remote_transport_error(value: unknown): value is RemoteTransportError;
|