svelte-effect-runtime 1.3.2 → 1.4.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-DkW4e4dD.js → client-vV6UAwoP.js} +3 -3
- package/dist/chunks/client-vV6UAwoP.js.map +1 -0
- package/dist/chunks/{effect-CL8GJs8A.js → effect-Cx8OzrcW.js} +3 -3
- package/dist/chunks/{effect-CL8GJs8A.js.map → effect-Cx8OzrcW.js.map} +1 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +1 -1
- package/dist/chunks/{markup-BpSHnnYD.js → markup-BMn2sQOB.js} +3 -1
- package/dist/chunks/{markup-BpSHnnYD.js.map → markup-BMn2sQOB.js.map} +1 -1
- package/dist/chunks/{preprocess-CtLrnJcK.js → preprocess-CGKEA3Py.js} +13 -8
- package/dist/chunks/preprocess-CGKEA3Py.js.map +1 -0
- package/dist/chunks/{server-CQcF2W3T.js → server-7YVuxUNk.js} +53 -2
- package/dist/chunks/server-7YVuxUNk.js.map +1 -0
- package/dist/chunks/v3-D0c0MKPf.js +1 -0
- package/dist/chunks/v4-MMhHmzIG.js +1 -0
- package/dist/chunks/{vite-DqjXRZd4.js → vite-C8ujN78r.js} +14 -5
- package/dist/chunks/vite-C8ujN78r.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/effect.js +1 -1
- package/dist/internal/markup.js +1 -1
- package/dist/internal/remote-client.js +3 -3
- package/dist/internal/remote-client.js.map +1 -1
- package/dist/internal/remote-shared.d.ts +134 -1
- package/dist/internal/remote-shared.js +64 -0
- package/dist/internal/remote-shared.js.map +1 -1
- package/dist/internal/transform.d.ts +7 -0
- package/dist/internal/transform.js +172 -15
- package/dist/internal/transform.js.map +1 -1
- package/dist/language-server.js +1 -1
- package/dist/mod.d.ts +21 -0
- package/dist/mod.js +2 -2
- package/dist/preprocess.d.ts +5 -0
- package/dist/preprocess.js +7 -2
- package/dist/preprocess.js.map +1 -1
- package/dist/root-node.js +4 -4
- package/dist/root-node.js.map +1 -1
- package/dist/server.d.ts +25 -0
- package/dist/server.js +26 -1
- package/dist/server.js.map +1 -1
- package/dist/v3/client.d.ts +24 -0
- package/dist/v3/mod.d.ts +24 -0
- package/dist/v3/server.d.ts +106 -0
- package/dist/v4/effect.js +1 -1
- package/dist/v4/mod.d.ts +24 -0
- package/dist/v4/mod.js +2 -2
- package/dist/v4/preprocess.d.ts +4 -0
- package/dist/v4/preprocess.js +6 -2
- package/dist/v4/preprocess.js.map +1 -1
- package/dist/v4/root-node.js +2 -2
- package/dist/v4/server.d.ts +196 -0
- package/dist/v4/server.js +50 -1
- package/dist/v4/server.js.map +1 -1
- package/dist/v4/vite.js +1 -1
- package/dist/vite.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/client-DkW4e4dD.js.map +0 -1
- package/dist/chunks/preprocess-CtLrnJcK.js.map +0 -1
- package/dist/chunks/server-CQcF2W3T.js.map +0 -1
- package/dist/chunks/v3-p8V3Drpp.js +0 -1
- package/dist/chunks/v4-DIhYCbb_.js +0 -1
- package/dist/chunks/vite-DqjXRZd4.js.map +0 -1
package/dist/v3/client.d.ts
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { Effect, Exit, Layer, ManagedRuntime } from "effect";
|
|
2
2
|
import { type RemoteFailure } from "../internal/remote-shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal runtime abstraction the client adapters rely on. Implemented by the
|
|
5
|
+
* Effect `ManagedRuntime` returned from {@link ClientRuntime.make}, but
|
|
6
|
+
* callers may substitute their own object conforming to this shape.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
9
|
+
*/
|
|
3
10
|
export interface EffectRuntime<R = unknown> {
|
|
11
|
+
/**
|
|
12
|
+
* Execute an Effect and receive a cancellation token. The optional `onExit`
|
|
13
|
+
* callback fires with the final `Exit` value once the fiber completes.
|
|
14
|
+
*/
|
|
4
15
|
runCallback<A, E, R2>(effect: Effect.Effect<A, E, R2>, options?: {
|
|
5
16
|
onExit?: (exit: Exit.Exit<A, E>) => void;
|
|
6
17
|
}): () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Execute an Effect and return a Promise that resolves with the success
|
|
20
|
+
* value or rejects with the propagated failure.
|
|
21
|
+
*/
|
|
7
22
|
runPromise<A, E, R2>(effect: Effect.Effect<A, E, R2>): Promise<A>;
|
|
23
|
+
/**
|
|
24
|
+
* Tear down the runtime and release any resources held by its root scope.
|
|
25
|
+
*/
|
|
8
26
|
dispose(): Promise<void>;
|
|
9
27
|
}
|
|
10
28
|
export type { FormError, FormIssue, RemoteDomainError, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "../internal/remote-shared.js";
|
|
29
|
+
/**
|
|
30
|
+
* Alias for {@link EffectRuntime} exposed as a stable service name used by
|
|
31
|
+
* generated code and documentation.
|
|
32
|
+
*
|
|
33
|
+
* @see https://ser.barekey.dev/content/reference/client-runtime
|
|
34
|
+
*/
|
|
11
35
|
export interface ClientRuntimeService extends EffectRuntime<unknown> {
|
|
12
36
|
}
|
|
13
37
|
type RuntimeSeedLayer<R> = Layer.Layer<R, never, R>;
|
package/dist/v3/mod.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v3 public entrypoint for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* Exposes the stable client runtime, lifecycle helpers, and shared remote
|
|
5
|
+
* error / result types. Import from `svelte-effect-runtime/v3` to pin against
|
|
6
|
+
* the v3 runtime explicitly; the package default entry (`mod.ts`) re-exports
|
|
7
|
+
* everything here.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {
|
|
12
|
+
* ClientRuntime,
|
|
13
|
+
* run_component_effect,
|
|
14
|
+
* } from "svelte-effect-runtime/v3";
|
|
15
|
+
* import { Effect } from "effect";
|
|
16
|
+
*
|
|
17
|
+
* const runtime = ClientRuntime.make();
|
|
18
|
+
* run_component_effect(runtime, Effect.log("hi from v3"));
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see https://ser.barekey.dev/
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
1
25
|
export type { EffectPreprocessOptions } from "./preprocess.js";
|
|
2
26
|
export type { ClientRuntimeService, EffectRuntime, FormError, FormIssue, RemoteDomainError, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./client.js";
|
|
3
27
|
export { ClientRuntime, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native, } from "./client.js";
|
package/dist/v3/server.d.ts
CHANGED
|
@@ -4,21 +4,43 @@ import { Effect, Layer, ManagedRuntime, Schema } from "effect";
|
|
|
4
4
|
import type { Context } from "effect";
|
|
5
5
|
import { type FormError } from "../internal/remote-shared.js";
|
|
6
6
|
type EffectSchema = Schema.Schema.Any;
|
|
7
|
+
/**
|
|
8
|
+
* Single entry in a {@link Transport} table. Describes how to encode a value
|
|
9
|
+
* of type `T` to a wire payload and decode it back.
|
|
10
|
+
*
|
|
11
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
12
|
+
*/
|
|
7
13
|
export interface Transporter<T = unknown, U = {
|
|
8
14
|
value: unknown;
|
|
9
15
|
}> {
|
|
16
|
+
/** Restore the original value from the wire payload. */
|
|
10
17
|
decode: (data: U) => T;
|
|
18
|
+
/**
|
|
19
|
+
* Encode the value to a wire payload, or return `false` when this transporter
|
|
20
|
+
* does not apply to the supplied value.
|
|
21
|
+
*/
|
|
11
22
|
encode: (value: T) => false | U;
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Named collection of {@link Transporter}s, passed to devalue so custom types
|
|
26
|
+
* survive the client/server round-trip.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
29
|
+
*/
|
|
13
30
|
export type Transport = Record<string, Transporter>;
|
|
31
|
+
/** Alias for SvelteKit's native remote-form input shape. */
|
|
14
32
|
export type RemoteFormInput = SvelteKitRemoteFormInput;
|
|
33
|
+
/** SvelteKit's native `query` function signature, re-exported for typing. */
|
|
15
34
|
export type RemoteQueryFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
35
|
+
/** SvelteKit's native `command` shape, re-exported for typing. */
|
|
16
36
|
export type RemoteCommand<Input, Output> = ((arg: OptionalArgument<Input>) => Promise<Output> & {
|
|
17
37
|
updates(...updates: Array<unknown>): Promise<Output>;
|
|
18
38
|
}) & {
|
|
19
39
|
readonly pending: number;
|
|
20
40
|
};
|
|
41
|
+
/** SvelteKit's native `prerender` function signature, re-exported for typing. */
|
|
21
42
|
export type RemotePrerenderFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
43
|
+
/** SvelteKit's native `form` shape, re-exported for typing. */
|
|
22
44
|
export type RemoteForm<Input extends RemoteFormInput | void, Output> = SvelteKitRemoteForm<Input, Output>;
|
|
23
45
|
type RuntimeOperator = (self: Layer.Layer<unknown, unknown, unknown>) => Layer.Layer<unknown, unknown, unknown>;
|
|
24
46
|
type RuntimeSeedLayer<Requirements> = Layer.Layer<Requirements, never, Requirements>;
|
|
@@ -33,24 +55,70 @@ type SchemaOutput<SchemaType extends EffectSchema> = Schema.Schema.Type<SchemaTy
|
|
|
33
55
|
type FieldHelpers<FormShape, SchemaType> = FormShape extends Record<string, unknown> ? {
|
|
34
56
|
[Key in keyof FormShape as Key extends string ? Key : never]: (message: string) => Effect.Effect<never, FormError<SchemaType>, never>;
|
|
35
57
|
} : Record<PropertyKey, never>;
|
|
58
|
+
/**
|
|
59
|
+
* Proxy passed into `Form` handlers for reporting validation issues. Call
|
|
60
|
+
* `invalid.form(message)` for a top-level issue, or `invalid.<field>(message)`
|
|
61
|
+
* to attach the issue to a specific field declared in the schema.
|
|
62
|
+
*
|
|
63
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
64
|
+
*/
|
|
36
65
|
export type Invalid<SchemaType = unknown> = {
|
|
66
|
+
/** Attach a top-level form issue with the supplied message. */
|
|
37
67
|
form: (message: string) => Effect.Effect<never, FormError<SchemaType>, never>;
|
|
38
68
|
} & FieldHelpers<SchemaType extends EffectSchema ? SchemaOutput<SchemaType> : unknown, SchemaType>;
|
|
69
|
+
/**
|
|
70
|
+
* Shape of an Effect-returning remote `query`. Callable with the validated
|
|
71
|
+
* input; exposes the underlying SvelteKit function via `native`.
|
|
72
|
+
*
|
|
73
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
74
|
+
*/
|
|
39
75
|
export type EffectQueryFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect.Effect<Output, import("../internal/remote-shared.js").RemoteFailure<Error>, never>) & {
|
|
76
|
+
/** Underlying SvelteKit `query` function, for fallback direct usage. */
|
|
40
77
|
native: RemoteQueryFunction<Input, Output>;
|
|
41
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Shape of an Effect-returning remote `command`. Callable with the validated
|
|
81
|
+
* input; exposes the underlying SvelteKit command via `native` and tracks
|
|
82
|
+
* in-flight submissions through `pending`.
|
|
83
|
+
*
|
|
84
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
85
|
+
*/
|
|
42
86
|
export type EffectCommand<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect.Effect<Output, import("../internal/remote-shared.js").RemoteFailure<Error>, never>) & {
|
|
87
|
+
/** Underlying SvelteKit `command` function, for fallback direct usage. */
|
|
43
88
|
native: RemoteCommand<Input, Output>;
|
|
89
|
+
/** Count of currently in-flight invocations of this command. */
|
|
44
90
|
readonly pending: number;
|
|
45
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Shape of an Effect-returning remote `prerender` function. Callable with the
|
|
94
|
+
* validated input; exposes the underlying SvelteKit function via `native`.
|
|
95
|
+
*
|
|
96
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
97
|
+
*/
|
|
46
98
|
export type EffectPrerenderFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect.Effect<Output, import("../internal/remote-shared.js").RemoteFailure<Error>, never>) & {
|
|
99
|
+
/** Underlying SvelteKit `prerender` function, for fallback direct usage. */
|
|
47
100
|
native: RemotePrerenderFunction<Input, Output>;
|
|
48
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Shape of an Effect-returning remote `form`. Usable anywhere the native
|
|
104
|
+
* SvelteKit form is; additionally exposes `submit(data)` to run the form
|
|
105
|
+
* program as an Effect, and `for(...)` to clone the binding for a given
|
|
106
|
+
* input.
|
|
107
|
+
*
|
|
108
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
109
|
+
*/
|
|
49
110
|
export type EffectForm<Input extends RemoteFormInput | void, Output, Error = never> = RemoteForm<Input, Output> & {
|
|
111
|
+
/** Underlying SvelteKit `form` object, for fallback direct usage. */
|
|
50
112
|
native: RemoteForm<Input, Output>;
|
|
113
|
+
/** Submit the form programmatically and receive the result as an Effect. */
|
|
51
114
|
submit(data: OptionalArgument<Input>): Effect.Effect<Output, import("../internal/remote-shared.js").RemoteFailure<Error>, never>;
|
|
115
|
+
/** Clone the form binding for a specific value - mirrors `RemoteForm.for`. */
|
|
52
116
|
for: RemoteForm<Input, Output>["for"] extends (...args: infer Args) => infer Result ? (...args: Args) => EffectForm<Input, Output, Error> : never;
|
|
53
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* Type of the SvelteKit `RequestEvent` exposed through the {@link RequestEvent}
|
|
120
|
+
* Effect service.
|
|
121
|
+
*/
|
|
54
122
|
export type RequestEventService = ReturnType<typeof get_native_request_event>;
|
|
55
123
|
/**
|
|
56
124
|
* Effect `Context.Tag` for the current SvelteKit `RequestEvent`.
|
|
@@ -100,10 +168,20 @@ export declare function normalize_remote_helper_error(error: unknown): unknown;
|
|
|
100
168
|
* @see https://ser.barekey.dev/content/reference/transport
|
|
101
169
|
*/
|
|
102
170
|
export declare function create_effect_transport<const Schemas extends Record<string, EffectSchema>>(schemas: Schemas): Transport;
|
|
171
|
+
/**
|
|
172
|
+
* Overload set for the {@link Query} factory. Supports no-arg, `"unchecked"`,
|
|
173
|
+
* and Effect.Schema-validated definitions, plus `Query.batch(...)`.
|
|
174
|
+
*
|
|
175
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
176
|
+
*/
|
|
103
177
|
export interface EffectQueryFactory {
|
|
178
|
+
/** Define a void-input query. */
|
|
104
179
|
<Output, ErrorType, Requirements>(fn: () => Effect.Effect<Output, ErrorType, Requirements>): EffectQueryFunction<void, Output, ErrorType>;
|
|
180
|
+
/** Define a query that bypasses schema validation. */
|
|
105
181
|
<Input, Output, ErrorType, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>): EffectQueryFunction<Input, Output, ErrorType>;
|
|
182
|
+
/** Define a query whose input is validated by an Effect.Schema. */
|
|
106
183
|
<SchemaType extends EffectSchema, Output, ErrorType, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect.Effect<Output, ErrorType, Requirements>): EffectQueryFunction<SchemaInput<SchemaType>, Output, ErrorType>;
|
|
184
|
+
/** Define a batched query - mirrors SvelteKit's `query.batch`. */
|
|
107
185
|
batch: typeof query_batch_factory;
|
|
108
186
|
}
|
|
109
187
|
type RemotePrerenderInputsGenerator<Input> = (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
|
|
@@ -114,9 +192,18 @@ declare function query_batch_factory(validate_or_fn: unknown, maybe_fn?: unknown
|
|
|
114
192
|
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
115
193
|
*/
|
|
116
194
|
export declare const Query: EffectQueryFactory;
|
|
195
|
+
/**
|
|
196
|
+
* Overload set for the {@link Command} factory. Supports no-arg,
|
|
197
|
+
* `"unchecked"`, and Effect.Schema-validated definitions.
|
|
198
|
+
*
|
|
199
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
200
|
+
*/
|
|
117
201
|
export interface EffectCommandFactory {
|
|
202
|
+
/** Define a void-input command. */
|
|
118
203
|
<Output, ErrorType, Requirements>(fn: () => Effect.Effect<Output, ErrorType, Requirements>): EffectCommand<void, Output, ErrorType>;
|
|
204
|
+
/** Define a command that bypasses schema validation. */
|
|
119
205
|
<Input, Output, ErrorType, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>): EffectCommand<Input, Output, ErrorType>;
|
|
206
|
+
/** Define a command whose input is validated by an Effect.Schema. */
|
|
120
207
|
<SchemaType extends EffectSchema, Output, ErrorType, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect.Effect<Output, ErrorType, Requirements>): EffectCommand<SchemaInput<SchemaType>, Output, ErrorType>;
|
|
121
208
|
}
|
|
122
209
|
/**
|
|
@@ -126,12 +213,21 @@ export interface EffectCommandFactory {
|
|
|
126
213
|
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
127
214
|
*/
|
|
128
215
|
export declare const Command: EffectCommandFactory;
|
|
216
|
+
/**
|
|
217
|
+
* Overload set for the {@link Form} factory. Supports no-arg, `"unchecked"`,
|
|
218
|
+
* and Effect.Schema-validated form handlers.
|
|
219
|
+
*
|
|
220
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
221
|
+
*/
|
|
129
222
|
export interface EffectFormFactory {
|
|
223
|
+
/** Define a form handler with no input data. */
|
|
130
224
|
<Output, ErrorType, Requirements>(fn: () => Effect.Effect<Output, ErrorType, Requirements>): EffectForm<void, Output, ErrorType>;
|
|
225
|
+
/** Define a form handler that bypasses schema validation. */
|
|
131
226
|
<Input extends RemoteFormInput, Output, ErrorType, Requirements>(validate: "unchecked", fn: (args: {
|
|
132
227
|
data: Input;
|
|
133
228
|
invalid: Invalid;
|
|
134
229
|
}) => Effect.Effect<Output, ErrorType | FormError, Requirements>): EffectForm<Input, Output, ErrorType>;
|
|
230
|
+
/** Define a form handler whose submitted data is validated by a schema. */
|
|
135
231
|
<SchemaType extends EffectSchema, Output, ErrorType, Requirements>(validate: SchemaType, fn: (args: {
|
|
136
232
|
data: SchemaOutput<SchemaType>;
|
|
137
233
|
invalid: Invalid<SchemaType>;
|
|
@@ -144,15 +240,25 @@ export interface EffectFormFactory {
|
|
|
144
240
|
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
145
241
|
*/
|
|
146
242
|
export declare const Form: EffectFormFactory;
|
|
243
|
+
/**
|
|
244
|
+
* Overload set for the {@link Prerender} factory. Accepts the same three
|
|
245
|
+
* validation flavours as the other factories, plus a SvelteKit `options` bag
|
|
246
|
+
* with `inputs` / `dynamic` flags.
|
|
247
|
+
*
|
|
248
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
249
|
+
*/
|
|
147
250
|
export interface EffectPrerenderFactory {
|
|
251
|
+
/** Define a void-input prerender function. */
|
|
148
252
|
<Output, ErrorType, Requirements>(fn: () => Effect.Effect<Output, ErrorType, Requirements>, options?: {
|
|
149
253
|
inputs?: RemotePrerenderInputsGenerator<void>;
|
|
150
254
|
dynamic?: boolean;
|
|
151
255
|
}): EffectPrerenderFunction<void, Output, ErrorType>;
|
|
256
|
+
/** Define a prerender function that bypasses schema validation. */
|
|
152
257
|
<Input, Output, ErrorType, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, ErrorType, Requirements>, options?: {
|
|
153
258
|
inputs?: RemotePrerenderInputsGenerator<Input>;
|
|
154
259
|
dynamic?: boolean;
|
|
155
260
|
}): EffectPrerenderFunction<Input, Output, ErrorType>;
|
|
261
|
+
/** Define a prerender function whose input is validated by a schema. */
|
|
156
262
|
<SchemaType extends EffectSchema, Output, ErrorType, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect.Effect<Output, ErrorType, Requirements>, options?: {
|
|
157
263
|
inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;
|
|
158
264
|
dynamic?: boolean;
|
package/dist/v4/effect.js
CHANGED
package/dist/v4/mod.d.ts
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v4 public entrypoint for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* Targets Effect v4 (beta) while sharing the underlying client helpers with
|
|
5
|
+
* v3. Importing from `svelte-effect-runtime/v4` opts into the v4 preprocess /
|
|
6
|
+
* Vite pipeline and the v4-flavoured server helpers exposed through the
|
|
7
|
+
* `/v4/_server` subpath.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {
|
|
12
|
+
* ClientRuntime,
|
|
13
|
+
* run_component_effect,
|
|
14
|
+
* } from "svelte-effect-runtime/v4";
|
|
15
|
+
* import { Effect } from "effect";
|
|
16
|
+
*
|
|
17
|
+
* const runtime = ClientRuntime.make();
|
|
18
|
+
* run_component_effect(runtime, Effect.log("hi from v4"));
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @see https://ser.barekey.dev/
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
1
25
|
export type { EffectPreprocessOptions } from "./preprocess.js";
|
|
2
26
|
export type { ClientRuntimeService, EffectRuntime, FormError, FormIssue, RemoteDomainError, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./client.js";
|
|
3
27
|
export { ClientRuntime, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native, } from "./client.js";
|
package/dist/v4/mod.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-
|
|
2
|
-
import "../chunks/v4-
|
|
1
|
+
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-vV6UAwoP.js";
|
|
2
|
+
import "../chunks/v4-MMhHmzIG.js";
|
|
3
3
|
export { ClientRuntime, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
|
package/dist/v4/preprocess.d.ts
CHANGED
|
@@ -28,3 +28,7 @@ export declare function with_v4_effect_preprocess_options(options?: EffectPrepro
|
|
|
28
28
|
* @see https://ser.barekey.dev/content/reference/preprocess
|
|
29
29
|
*/
|
|
30
30
|
export declare function effect_preprocess(options?: EffectPreprocessOptions): PreprocessorGroup;
|
|
31
|
+
/**
|
|
32
|
+
* Backwards-compatible camelCase alias retained for older downstream imports.
|
|
33
|
+
*/
|
|
34
|
+
export declare const effectPreprocess: typeof effect_preprocess;
|
package/dist/v4/preprocess.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as effect_preprocess$1 } from "../chunks/preprocess-
|
|
1
|
+
import { t as effect_preprocess$1 } from "../chunks/preprocess-CGKEA3Py.js";
|
|
2
2
|
//#region v4/preprocess.ts
|
|
3
3
|
const V4_RUNTIME_MODULE_ID = "svelte-effect-runtime/v4";
|
|
4
4
|
/**
|
|
@@ -22,7 +22,11 @@ function with_v4_effect_preprocess_options(options = {}) {
|
|
|
22
22
|
function effect_preprocess(options = {}) {
|
|
23
23
|
return effect_preprocess$1(with_v4_effect_preprocess_options(options));
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Backwards-compatible camelCase alias retained for older downstream imports.
|
|
27
|
+
*/
|
|
28
|
+
const effectPreprocess = effect_preprocess;
|
|
25
29
|
//#endregion
|
|
26
|
-
export { V4_RUNTIME_MODULE_ID, effect_preprocess, with_v4_effect_preprocess_options };
|
|
30
|
+
export { V4_RUNTIME_MODULE_ID, effectPreprocess, effect_preprocess, with_v4_effect_preprocess_options };
|
|
27
31
|
|
|
28
32
|
//# sourceMappingURL=preprocess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../../modules/svelte-effect-runtime/v4/preprocess.ts"],"sourcesContent":["/**\n * v4-specific preprocess entrypoints and helpers.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/v4/preprocess\";\n *\n * const preprocess = effect_preprocess();\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\nexport const V4_RUNTIME_MODULE_ID = \"svelte-effect-runtime/v4\";\n\n/**\n * Apply the default v4 runtime module id to a preprocess options bag.\n *\n * @internal Internal — do not use.\n */\nexport function with_v4_effect_preprocess_options(\n options: EffectPreprocessOptions = {},\n): EffectPreprocessOptions {\n return {\n ...options,\n runtimeModuleId: options.runtimeModuleId ?? V4_RUNTIME_MODULE_ID,\n };\n}\n\n/**\n * Low-level Svelte preprocessor for the v4 runtime entry.\n *\n * Advanced entry point used by tooling and custom build setups.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options: EffectPreprocessOptions = {},\n): PreprocessorGroup {\n return create_effect_preprocess(with_v4_effect_preprocess_options(options));\n}\n"],"mappings":";;AAoBA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,kCACd,UAAmC,EAAE,EACZ;AACzB,QAAO;EACL,GAAG;EACH,iBAAiB,QAAQ,mBAAA;EAC1B;;;;;;;;;AAUH,SAAgB,kBACd,UAAmC,EAAE,EAClB;AACnB,QAAOA,oBAAyB,kCAAkC,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../../modules/svelte-effect-runtime/v4/preprocess.ts"],"sourcesContent":["/**\n * v4-specific preprocess entrypoints and helpers.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/v4/preprocess\";\n *\n * const preprocess = effect_preprocess();\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\nexport const V4_RUNTIME_MODULE_ID = \"svelte-effect-runtime/v4\";\n\n/**\n * Apply the default v4 runtime module id to a preprocess options bag.\n *\n * @internal Internal — do not use.\n */\nexport function with_v4_effect_preprocess_options(\n options: EffectPreprocessOptions = {},\n): EffectPreprocessOptions {\n return {\n ...options,\n runtimeModuleId: options.runtimeModuleId ?? V4_RUNTIME_MODULE_ID,\n };\n}\n\n/**\n * Low-level Svelte preprocessor for the v4 runtime entry.\n *\n * Advanced entry point used by tooling and custom build setups.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options: EffectPreprocessOptions = {},\n): PreprocessorGroup {\n return create_effect_preprocess(with_v4_effect_preprocess_options(options));\n}\n\n/**\n * Backwards-compatible camelCase alias retained for older downstream imports.\n */\nexport const effectPreprocess = effect_preprocess;\n"],"mappings":";;AAoBA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,kCACd,UAAmC,EAAE,EACZ;AACzB,QAAO;EACL,GAAG;EACH,iBAAiB,QAAQ,mBAAA;EAC1B;;;;;;;;;AAUH,SAAgB,kBACd,UAAmC,EAAE,EAClB;AACnB,QAAOA,oBAAyB,kCAAkC,QAAQ,CAAC;;;;;AAM7E,MAAa,mBAAmB"}
|
package/dist/v4/root-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-
|
|
2
|
-
import "../chunks/v4-
|
|
1
|
+
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-vV6UAwoP.js";
|
|
2
|
+
import "../chunks/v4-MMhHmzIG.js";
|
|
3
3
|
import { effect } from "./effect.js";
|
|
4
4
|
export { ClientRuntime, effect, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
|
package/dist/v4/server.d.ts
CHANGED
|
@@ -1,24 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v4 server-side entrypoint for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* Provides Effect v4-flavoured remote-function helpers and the updated
|
|
5
|
+
* `ServerRuntime` builder whose `RuntimeOperator` signature accepts the
|
|
6
|
+
* v4-style `Layer.provide(...)` operator. Usually consumed indirectly: the
|
|
7
|
+
* Vite plugin rewrites `svelte-effect-runtime/v4` imports inside `.remote.ts`
|
|
8
|
+
* to resolve here at build time.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Query, ServerRuntime } from "svelte-effect-runtime/v4/_server";
|
|
13
|
+
* import { Effect, Layer, Schema } from "effect";
|
|
14
|
+
*
|
|
15
|
+
* ServerRuntime.make(Layer.provide(MyServiceLayer));
|
|
16
|
+
*
|
|
17
|
+
* export const hello = Query(Schema.String, (name) =>
|
|
18
|
+
* Effect.succeed(`hello ${name}`)
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
1
26
|
import type { RemoteForm as SvelteKitRemoteForm, RemoteFormInput as SvelteKitRemoteFormInput } from "@sveltejs/kit";
|
|
2
27
|
import type { getRequestEvent as get_native_request_event } from "$app/server";
|
|
3
28
|
import type { Effect as Effect_type, Layer as Layer_type } from "effect";
|
|
4
29
|
import * as base_server from "../v3/server.js";
|
|
5
30
|
import type { FormError, RemoteFailure } from "../internal/remote-shared.js";
|
|
6
31
|
import { type EffectContextKey, type EffectSchemaLike } from "../internal/effect-compat.js";
|
|
32
|
+
/**
|
|
33
|
+
* Single entry in a {@link Transport} table. Describes how to encode a value
|
|
34
|
+
* to a wire payload and decode it back.
|
|
35
|
+
*
|
|
36
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
37
|
+
*/
|
|
7
38
|
export interface Transporter<T = unknown, U = {
|
|
8
39
|
value: unknown;
|
|
9
40
|
}> {
|
|
41
|
+
/** Restore the original value from the wire payload. */
|
|
10
42
|
decode: (data: U) => T;
|
|
43
|
+
/**
|
|
44
|
+
* Encode the value to a wire payload, or return `false` when this transporter
|
|
45
|
+
* does not apply to the supplied value.
|
|
46
|
+
*/
|
|
11
47
|
encode: (value: T) => false | U;
|
|
12
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Named collection of {@link Transporter}s used by devalue to round-trip
|
|
51
|
+
* custom types across the client/server boundary.
|
|
52
|
+
*
|
|
53
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
54
|
+
*/
|
|
13
55
|
export type Transport = Record<string, Transporter>;
|
|
56
|
+
/** Alias for SvelteKit's native remote-form input shape. */
|
|
14
57
|
export type RemoteFormInput = SvelteKitRemoteFormInput;
|
|
58
|
+
/** SvelteKit's native `query` function signature, re-exported for typing. */
|
|
15
59
|
export type RemoteQueryFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
60
|
+
/** SvelteKit's native `command` shape, re-exported for typing. */
|
|
16
61
|
export type RemoteCommand<Input, Output> = ((arg: OptionalArgument<Input>) => Promise<Output> & {
|
|
17
62
|
updates(...updates: Array<unknown>): Promise<Output>;
|
|
18
63
|
}) & {
|
|
19
64
|
readonly pending: number;
|
|
20
65
|
};
|
|
66
|
+
/** SvelteKit's native `prerender` function signature, re-exported for typing. */
|
|
21
67
|
export type RemotePrerenderFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
68
|
+
/** SvelteKit's native `form` shape, re-exported for typing. */
|
|
22
69
|
export type RemoteForm<Input extends RemoteFormInput | void, Output> = SvelteKitRemoteForm<Input, Output>;
|
|
23
70
|
type OptionalArgument<Input> = undefined extends Input ? Input | void : Input;
|
|
24
71
|
type RuntimeOperator = (self: Layer_type.Layer<unknown, unknown, unknown>) => Layer_type.Layer<unknown, unknown, unknown>;
|
|
@@ -37,61 +84,161 @@ type SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends {
|
|
|
37
84
|
type FieldHelpers<FormShape, SchemaType> = FormShape extends Record<string, unknown> ? {
|
|
38
85
|
[Key in keyof FormShape as Key extends string ? Key : never]: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
39
86
|
} : Record<PropertyKey, never>;
|
|
87
|
+
/**
|
|
88
|
+
* Proxy passed into v4 `Form` handlers for reporting validation issues. Call
|
|
89
|
+
* `invalid.form(message)` for a top-level issue, or `invalid.<field>(message)`
|
|
90
|
+
* to attach the issue to a specific field.
|
|
91
|
+
*
|
|
92
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
93
|
+
*/
|
|
40
94
|
export type Invalid<SchemaType = unknown> = {
|
|
95
|
+
/** Attach a top-level form issue with the supplied message. */
|
|
41
96
|
form: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
42
97
|
} & FieldHelpers<SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown, SchemaType>;
|
|
98
|
+
/**
|
|
99
|
+
* v4 shape of an Effect-returning remote `query`. Exposes the underlying
|
|
100
|
+
* SvelteKit function via `native`.
|
|
101
|
+
*
|
|
102
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
103
|
+
*/
|
|
43
104
|
export type EffectQueryFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
105
|
+
/** Underlying SvelteKit `query` function, for fallback direct usage. */
|
|
44
106
|
native: RemoteQueryFunction<Input, Output>;
|
|
45
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* v4 shape of an Effect-returning remote `command`. Tracks in-flight
|
|
110
|
+
* submissions via `pending`.
|
|
111
|
+
*
|
|
112
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
113
|
+
*/
|
|
46
114
|
export type EffectCommand<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
115
|
+
/** Underlying SvelteKit `command` function, for fallback direct usage. */
|
|
47
116
|
native: RemoteCommand<Input, Output>;
|
|
117
|
+
/** Count of currently in-flight invocations of this command. */
|
|
48
118
|
readonly pending: number;
|
|
49
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* v4 shape of an Effect-returning remote `prerender` function.
|
|
122
|
+
*
|
|
123
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
124
|
+
*/
|
|
50
125
|
export type EffectPrerenderFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
126
|
+
/** Underlying SvelteKit `prerender` function, for fallback direct usage. */
|
|
51
127
|
native: RemotePrerenderFunction<Input, Output>;
|
|
52
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* v4 shape of an Effect-returning remote `form`. Adds `submit(data)` and
|
|
131
|
+
* `for(...)` on top of the underlying SvelteKit form.
|
|
132
|
+
*
|
|
133
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
134
|
+
*/
|
|
53
135
|
export type EffectForm<Input extends RemoteFormInput | void, Output, Error = never> = RemoteForm<Input, Output> & {
|
|
136
|
+
/** Underlying SvelteKit `form` object, for fallback direct usage. */
|
|
54
137
|
native: RemoteForm<Input, Output>;
|
|
138
|
+
/** Submit the form programmatically and receive the result as an Effect. */
|
|
55
139
|
submit(data: OptionalArgument<Input>): Effect_type.Effect<Output, RemoteFailure<Error>, never>;
|
|
140
|
+
/** Clone the form binding for a specific value - mirrors `RemoteForm.for`. */
|
|
56
141
|
for: RemoteForm<Input, Output>["for"] extends (...args: infer Args) => infer Result ? (...args: Args) => EffectForm<Input, Output, Error> & Result : never;
|
|
57
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* v4 type of the SvelteKit `RequestEvent` exposed through the
|
|
145
|
+
* {@link RequestEvent} Effect service.
|
|
146
|
+
*/
|
|
58
147
|
export type RequestEventService = ReturnType<typeof get_native_request_event>;
|
|
148
|
+
/**
|
|
149
|
+
* Builder shape returned by {@link ServerRuntime} in the v4 runtime. Accepts
|
|
150
|
+
* v4-style `Layer` operators and installs a singleton `ManagedRuntime`.
|
|
151
|
+
*
|
|
152
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
153
|
+
*/
|
|
59
154
|
export interface ServerRuntimeSeed {
|
|
155
|
+
/** Compose operators into a Layer without installing a runtime. */
|
|
60
156
|
pipe(): Layer_type.Layer<never>;
|
|
157
|
+
/** Compose operators into a Layer without installing a runtime. */
|
|
61
158
|
pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): FinalRuntimeLayer<Ops>;
|
|
159
|
+
/** Build and install the singleton server runtime. */
|
|
62
160
|
make(): void;
|
|
161
|
+
/** Build and install the singleton server runtime. */
|
|
63
162
|
make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): void;
|
|
64
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Subset of `ManagedRuntime` surface used by generated v4 server wrappers.
|
|
166
|
+
*
|
|
167
|
+
* @internal Internal - do not use.
|
|
168
|
+
*/
|
|
65
169
|
export interface EffectManagedRuntime {
|
|
170
|
+
/** Execute an Effect and resolve with its raw `Exit`. */
|
|
66
171
|
runPromiseExit<A, E, R>(effect: Effect_type.Effect<A, E, R>): Promise<unknown>;
|
|
172
|
+
/** Tear down the runtime and release its root scope. */
|
|
67
173
|
dispose(): Promise<void>;
|
|
68
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Signature of `Query.batch` in the v4 runtime - kept loosely typed because
|
|
177
|
+
* the v4 server-side implementation delegates to the v3 batch factory.
|
|
178
|
+
*
|
|
179
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
180
|
+
*/
|
|
69
181
|
export interface EffectQueryBatchFactory {
|
|
182
|
+
/** Build a batched query from validator + handler arguments. */
|
|
70
183
|
(...args: Array<unknown>): unknown;
|
|
71
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* v4 overload set for the {@link Query} factory. Mirrors
|
|
187
|
+
* {@link import("../v3/server.js").EffectQueryFactory} using v4 schema-like
|
|
188
|
+
* inference.
|
|
189
|
+
*
|
|
190
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
191
|
+
*/
|
|
72
192
|
export interface EffectQueryFactory {
|
|
193
|
+
/** Define a void-input query. */
|
|
73
194
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<void, Output, Error>;
|
|
195
|
+
/** Define a query that bypasses schema validation. */
|
|
74
196
|
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<Input, Output, Error>;
|
|
197
|
+
/** Define a query whose input is validated by an Effect.Schema. */
|
|
75
198
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
199
|
+
/** Define a batched query - mirrors SvelteKit's `query.batch`. */
|
|
76
200
|
batch: EffectQueryBatchFactory;
|
|
77
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* v4 overload set for the {@link Command} factory.
|
|
204
|
+
*
|
|
205
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
206
|
+
*/
|
|
78
207
|
export interface EffectCommandFactory {
|
|
208
|
+
/** Define a void-input command. */
|
|
79
209
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<void, Output, Error>;
|
|
210
|
+
/** Define a command that bypasses schema validation. */
|
|
80
211
|
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<Input, Output, Error>;
|
|
212
|
+
/** Define a command whose input is validated by an Effect.Schema. */
|
|
81
213
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<SchemaInput<SchemaType>, Output, Error>;
|
|
82
214
|
}
|
|
83
215
|
type RemotePrerenderInputsGenerator<Input> = (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
|
|
216
|
+
/**
|
|
217
|
+
* v4 overload set for the {@link Form} factory.
|
|
218
|
+
*
|
|
219
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
220
|
+
*/
|
|
84
221
|
export interface EffectFormFactory {
|
|
222
|
+
/** Define a form handler with no input data. */
|
|
85
223
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectForm<void, Output, Error>;
|
|
224
|
+
/** Define a form handler that bypasses schema validation. */
|
|
86
225
|
<Input extends RemoteFormInput, Output, Error, Requirements>(validate: "unchecked", fn: (args: {
|
|
87
226
|
data: Input;
|
|
88
227
|
invalid: Invalid;
|
|
89
228
|
}) => Effect_type.Effect<Output, Error | FormError, Requirements>): EffectForm<Input, Output, Error>;
|
|
229
|
+
/** Define a form handler whose submitted data is validated by a schema. */
|
|
90
230
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (args: {
|
|
91
231
|
data: SchemaOutput<SchemaType>;
|
|
92
232
|
invalid: Invalid<SchemaType>;
|
|
93
233
|
}) => Effect_type.Effect<Output, Error | FormError<SchemaType>, Requirements>): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;
|
|
94
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* v4 overload set for the {@link Prerender} factory. Supports the same three
|
|
237
|
+
* validation flavours as the other factories plus a SvelteKit `options` bag
|
|
238
|
+
* with `inputs` / `dynamic` flags.
|
|
239
|
+
*
|
|
240
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
241
|
+
*/
|
|
95
242
|
export interface EffectPrerenderFactory {
|
|
96
243
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>, options?: {
|
|
97
244
|
inputs?: RemotePrerenderInputsGenerator<void>;
|
|
@@ -106,13 +253,62 @@ export interface EffectPrerenderFactory {
|
|
|
106
253
|
dynamic?: boolean;
|
|
107
254
|
}): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
108
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* v4 flavour of {@link import("../v3/server.js").Query} - define a read-only
|
|
258
|
+
* remote function returning an Effect.
|
|
259
|
+
*
|
|
260
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
261
|
+
*/
|
|
109
262
|
export declare const Query: EffectQueryFactory;
|
|
263
|
+
/**
|
|
264
|
+
* v4 flavour of {@link import("../v3/server.js").Command} - define a
|
|
265
|
+
* write-oriented remote function returning an Effect.
|
|
266
|
+
*
|
|
267
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
268
|
+
*/
|
|
110
269
|
export declare const Command: EffectCommandFactory;
|
|
270
|
+
/**
|
|
271
|
+
* v4 flavour of {@link import("../v3/server.js").Form} - define a remote form
|
|
272
|
+
* handler that maps submitted data into an Effect program.
|
|
273
|
+
*
|
|
274
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
275
|
+
*/
|
|
111
276
|
export declare const Form: EffectFormFactory;
|
|
277
|
+
/**
|
|
278
|
+
* v4 flavour of {@link import("../v3/server.js").Prerender} - define a
|
|
279
|
+
* prerenderable remote function backed by an Effect program.
|
|
280
|
+
*
|
|
281
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
282
|
+
*/
|
|
112
283
|
export declare const Prerender: EffectPrerenderFactory;
|
|
284
|
+
/**
|
|
285
|
+
* v4 Effect `Context.Tag` for the current SvelteKit `RequestEvent`. Shaped
|
|
286
|
+
* like an `Effect` so handlers can `yield* RequestEvent` directly.
|
|
287
|
+
*
|
|
288
|
+
* @see https://ser.barekey.dev/content/runtimes/server
|
|
289
|
+
*/
|
|
113
290
|
export declare const RequestEvent: EffectContextKey<RequestEventService, RequestEventService> & Effect_type.Effect<RequestEventService, never, RequestEventService>;
|
|
291
|
+
/**
|
|
292
|
+
* v4 server-side runtime builder. Equivalent to the v3 builder but typed
|
|
293
|
+
* against the v4 `Layer` operator signature.
|
|
294
|
+
*
|
|
295
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
296
|
+
*/
|
|
114
297
|
export declare const ServerRuntime: ServerRuntimeSeed;
|
|
298
|
+
/**
|
|
299
|
+
* Build a devalue transport table from Effect schemas so remote payloads can
|
|
300
|
+
* round-trip custom data across the client/server boundary.
|
|
301
|
+
*
|
|
302
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
303
|
+
*/
|
|
115
304
|
export declare const create_effect_transport: typeof base_server.create_effect_transport;
|
|
305
|
+
/**
|
|
306
|
+
* Resolve the active v4 server runtime, lazily creating a default empty
|
|
307
|
+
* runtime when none has been registered.
|
|
308
|
+
*
|
|
309
|
+
* @internal Internal - do not use.
|
|
310
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
311
|
+
*/
|
|
116
312
|
export declare const get_server_runtime_or_throw: () => EffectManagedRuntime;
|
|
117
313
|
/**
|
|
118
314
|
* Remap low-level request-store crashes into a clearer setup error when remote
|