effect-cf 0.34.0 → 0.36.0
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/CHANGELOG.md +16 -0
- package/dist/ComputerWorkspace.d.mts +11 -3
- package/dist/ComputerWorkspace.mjs +31 -9
- package/dist/DurableObjectState-CpgAmFqo.d.mts +244 -0
- package/dist/{DurableObjectState-De4ZojhY.mjs → DurableObjectState-DCh4PZMN.mjs} +50 -76
- package/dist/Mcp.d.mts +122 -0
- package/dist/Mcp.mjs +270 -0
- package/dist/Vitest.d.mts +2 -2
- package/dist/Vitest.mjs +8 -10
- package/dist/{DurableObjectState-CrEunfQ-.d.mts → Worker-Dl6_Pijl.d.mts} +35 -269
- package/dist/Worker-XsGJsCJX.mjs +885 -0
- package/dist/WorkerContext-Yobnfw-K.mjs +60 -0
- package/dist/{WorkflowBinding-BumVQTuW.d.mts → WorkflowBinding-CvJT9hB5.d.mts} +1 -1
- package/dist/index.d.mts +13 -4
- package/dist/index.mjs +151 -1002
- package/package.json +12 -1
- package/src/AnalyticsEngine.ts +8 -1
- package/src/CloudflareOtlp.ts +6 -3
- package/src/ComputerWorkspace.ts +53 -26
- package/src/DurableObject.ts +8 -9
- package/src/DurableObjectNamespace.ts +33 -5
- package/src/DurableObjectRpcWebSocket.ts +2 -27
- package/src/DurableObjectState.ts +18 -20
- package/src/DurableObjectStorage.ts +53 -35
- package/src/DurableObjectWebSocket.ts +23 -41
- package/src/Mcp.ts +531 -0
- package/src/RpcDefinition.ts +5 -15
- package/src/ServiceBinding.ts +37 -5
- package/src/Vitest.ts +18 -15
- package/src/Worker.ts +107 -54
- package/src/WorkersAi.ts +21 -14
- package/src/Workflow.ts +45 -49
- package/src/internal/NativeCallback.ts +55 -0
- package/src/internal/WorkerContext.ts +5 -3
|
@@ -1,189 +1,7 @@
|
|
|
1
1
|
import { c as WorkerEnvironment, n as BindingService, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
|
|
2
|
-
import { Cause, Context,
|
|
2
|
+
import { Cause, Context, Effect, Layer, Predicate, Schema, Scope, Tracer } from "effect";
|
|
3
3
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
4
4
|
import { RpcStub, RpcTarget, WorkerEntrypoint } from "cloudflare:workers";
|
|
5
|
-
declare namespace DurableObjectStorage_d_exports {
|
|
6
|
-
export { DurableObjectStorage, DurableObjectTransaction, SchemaBackedSyncKvStorage, SqlCursor, SqlStorage, SqlStorageValue, StorageOperationError, SyncKvDefinition, SyncKvStorage, fromDurableObjectStorage };
|
|
7
|
-
}
|
|
8
|
-
type SqlStorageValue = globalThis.SqlStorageValue;
|
|
9
|
-
declare const StorageOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
10
|
-
readonly _tag: "StorageOperationError";
|
|
11
|
-
} & Readonly<A>;
|
|
12
|
-
declare class StorageOperationError extends StorageOperationError_base<{
|
|
13
|
-
readonly operation: string;
|
|
14
|
-
readonly cause: unknown;
|
|
15
|
-
}> {
|
|
16
|
-
get message(): string;
|
|
17
|
-
}
|
|
18
|
-
type StorageEffect<A> = Effect.Effect<A, StorageOperationError>;
|
|
19
|
-
interface SqlCursor<T extends Record<string, SqlStorageValue>> {
|
|
20
|
-
next(): StorageEffect<{
|
|
21
|
-
done?: false;
|
|
22
|
-
value: T;
|
|
23
|
-
} | {
|
|
24
|
-
done: true;
|
|
25
|
-
value?: never;
|
|
26
|
-
}>;
|
|
27
|
-
toArray(): StorageEffect<Array<T>>;
|
|
28
|
-
one(): StorageEffect<T>;
|
|
29
|
-
raw<U extends Array<SqlStorageValue>>(): StorageEffect<IterableIterator<U>>;
|
|
30
|
-
readonly columnNames: Array<string>;
|
|
31
|
-
readonly rowsRead: StorageEffect<number>;
|
|
32
|
-
readonly rowsWritten: StorageEffect<number>;
|
|
33
|
-
}
|
|
34
|
-
interface SqlStorage {
|
|
35
|
-
exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: Array<SqlStorageValue>): StorageEffect<SqlCursor<T>>;
|
|
36
|
-
readonly databaseSize: number;
|
|
37
|
-
}
|
|
38
|
-
interface SyncKvDefinition<Key, Value, EncodedValue> {
|
|
39
|
-
readonly key: Schema.Codec<Key, string>;
|
|
40
|
-
readonly value: Schema.Codec<Value, EncodedValue>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Sync KV wrapper that transparently encodes keys/values through Effect Schema.
|
|
44
|
-
*/
|
|
45
|
-
interface SchemaBackedSyncKvStorage<Key, Value> {
|
|
46
|
-
get(key: Key): Effect.Effect<Option.Option<Value>, unknown>;
|
|
47
|
-
put(key: Key, value: Value): Effect.Effect<void, unknown>;
|
|
48
|
-
delete(key: Key): Effect.Effect<boolean, unknown>;
|
|
49
|
-
list(options?: globalThis.SyncKvListOptions): Effect.Effect<Array<[Key, Value]>, unknown>;
|
|
50
|
-
}
|
|
51
|
-
interface SyncKvStorage {
|
|
52
|
-
get<T = unknown>(key: string): StorageEffect<T | undefined>;
|
|
53
|
-
put<T>(key: string, value: T): StorageEffect<void>;
|
|
54
|
-
delete(key: string): StorageEffect<boolean>;
|
|
55
|
-
list<T = unknown>(options?: globalThis.SyncKvListOptions): StorageEffect<Array<[string, T]>>;
|
|
56
|
-
schema<Key, Value, EncodedValue>(definition: SyncKvDefinition<Key, Value, EncodedValue>): SchemaBackedSyncKvStorage<Key, Value>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Effect wrapper around Cloudflare transaction callbacks.
|
|
60
|
-
*/
|
|
61
|
-
interface DurableObjectTransaction {
|
|
62
|
-
get<T = unknown>(key: string, options?: globalThis.DurableObjectGetOptions): StorageEffect<T | undefined>;
|
|
63
|
-
get<T = unknown>(keys: Array<string>, options?: globalThis.DurableObjectGetOptions): StorageEffect<Map<string, T>>;
|
|
64
|
-
list<T = unknown>(options?: globalThis.DurableObjectListOptions): StorageEffect<Map<string, T>>;
|
|
65
|
-
put<T>(key: string, value: T, options?: globalThis.DurableObjectPutOptions): StorageEffect<void>;
|
|
66
|
-
put<T>(entries: Record<string, T>, options?: globalThis.DurableObjectPutOptions): StorageEffect<void>;
|
|
67
|
-
delete(key: string, options?: globalThis.DurableObjectPutOptions): StorageEffect<boolean>;
|
|
68
|
-
delete(keys: Array<string>, options?: globalThis.DurableObjectPutOptions): StorageEffect<number>;
|
|
69
|
-
rollback(): StorageEffect<void>;
|
|
70
|
-
getAlarm(options?: globalThis.DurableObjectGetAlarmOptions): StorageEffect<number | null>;
|
|
71
|
-
setAlarm(scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
72
|
-
setAlarmAfter(delay: Duration.Input, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
73
|
-
deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
74
|
-
}
|
|
75
|
-
interface DurableObjectStorage {
|
|
76
|
-
get<T = unknown>(key: string, options?: globalThis.DurableObjectGetOptions): StorageEffect<T | undefined>;
|
|
77
|
-
put<T>(key: string, value: T, options?: globalThis.DurableObjectPutOptions): StorageEffect<void>;
|
|
78
|
-
delete(key: string, options?: globalThis.DurableObjectPutOptions): StorageEffect<boolean>;
|
|
79
|
-
/**
|
|
80
|
-
* Deletes all stored data. On compatibility dates before 2026-02-24, Cloudflare
|
|
81
|
-
* documents that active alarms must be deleted separately with `deleteAlarm()`.
|
|
82
|
-
*/
|
|
83
|
-
deleteAll(options?: globalThis.DurableObjectPutOptions): StorageEffect<void>;
|
|
84
|
-
getAlarm(options?: globalThis.DurableObjectGetAlarmOptions): StorageEffect<number | null>;
|
|
85
|
-
setAlarm(scheduledTime: number | Date, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
86
|
-
setAlarmAfter(delay: Duration.Input, options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
87
|
-
deleteAlarm(options?: globalThis.DurableObjectSetAlarmOptions): StorageEffect<void>;
|
|
88
|
-
/**
|
|
89
|
-
* SQLite-backed Durable Object storage only.
|
|
90
|
-
*
|
|
91
|
-
* The callback Effect must complete synchronously. If it requires asynchronous
|
|
92
|
-
* work, use `transaction` instead so Cloudflare can run the async transaction
|
|
93
|
-
* callback under the platform's transaction contract.
|
|
94
|
-
*/
|
|
95
|
-
transactionSync<A, E, R>(closure: () => Effect.Effect<A, E, R>): Effect.Effect<A, E | StorageOperationError, R>;
|
|
96
|
-
/**
|
|
97
|
-
* Runs an async transaction and exposes a typed transaction wrapper.
|
|
98
|
-
*/
|
|
99
|
-
transaction<A, E, R>(closure: (txn: DurableObjectTransaction) => Effect.Effect<A, E, R>): Effect.Effect<A, E | StorageOperationError, R>;
|
|
100
|
-
/** Flushes pending writes to disk. */
|
|
101
|
-
sync(): StorageEffect<void>;
|
|
102
|
-
/** Requires SQLite-backed Durable Object storage. */
|
|
103
|
-
getCurrentBookmark(): StorageEffect<string>;
|
|
104
|
-
/** Requires SQLite-backed Durable Object storage. */
|
|
105
|
-
onNextSessionRestoreBookmark(bookmark: string): StorageEffect<string>;
|
|
106
|
-
readonly sql: SqlStorage;
|
|
107
|
-
readonly kv: SyncKvStorage;
|
|
108
|
-
}
|
|
109
|
-
declare const fromDurableObjectStorage: (storage: globalThis.DurableObjectStorage) => DurableObjectStorage;
|
|
110
|
-
declare namespace DurableObjectWebSocket_d_exports {
|
|
111
|
-
export { AcceptUpgradeOptions, AcceptedUpgrade, AttachmentInvalidPolicy, AttachmentRehydrateOptions, DurableWebSocket, DurableWebSocketAttachment, DurableWebSocketAttachmentError, DurableWebSocketCloseError, DurableWebSocketHandlers, DurableWebSocketSendData, DurableWebSocketSendError, RehydratedDurableWebSocket, acceptUpgrade, attachment, fromWebSocket, handlers };
|
|
112
|
-
}
|
|
113
|
-
type DurableWebSocketSendData = string | ArrayBuffer | ArrayBufferView;
|
|
114
|
-
declare const DurableWebSocketSendError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
115
|
-
readonly _tag: "DurableWebSocketSendError";
|
|
116
|
-
} & Readonly<A>;
|
|
117
|
-
declare class DurableWebSocketSendError extends DurableWebSocketSendError_base<{
|
|
118
|
-
readonly cause: unknown;
|
|
119
|
-
}> {
|
|
120
|
-
get message(): string;
|
|
121
|
-
}
|
|
122
|
-
declare const DurableWebSocketCloseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
123
|
-
readonly _tag: "DurableWebSocketCloseError";
|
|
124
|
-
} & Readonly<A>;
|
|
125
|
-
declare class DurableWebSocketCloseError extends DurableWebSocketCloseError_base<{
|
|
126
|
-
readonly cause: unknown;
|
|
127
|
-
}> {
|
|
128
|
-
get message(): string;
|
|
129
|
-
}
|
|
130
|
-
declare const DurableWebSocketAttachmentError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
131
|
-
readonly _tag: "DurableWebSocketAttachmentError";
|
|
132
|
-
} & Readonly<A>;
|
|
133
|
-
/** Error raised when serializing or deserializing a websocket attachment fails. */
|
|
134
|
-
declare class DurableWebSocketAttachmentError extends DurableWebSocketAttachmentError_base<{
|
|
135
|
-
readonly operation: "serialize" | "deserialize";
|
|
136
|
-
readonly cause: unknown;
|
|
137
|
-
}> {
|
|
138
|
-
get message(): string;
|
|
139
|
-
}
|
|
140
|
-
interface DurableWebSocket<Attachment = unknown> {
|
|
141
|
-
readonly raw: WebSocket;
|
|
142
|
-
send(data: DurableWebSocketSendData): Effect.Effect<void, DurableWebSocketSendError>;
|
|
143
|
-
close(code?: number, reason?: string): Effect.Effect<void, DurableWebSocketCloseError>;
|
|
144
|
-
/** Serializes hibernation attachment metadata onto the socket. */
|
|
145
|
-
serializeAttachment<A = Attachment>(value: A): Effect.Effect<void, DurableWebSocketAttachmentError>;
|
|
146
|
-
/** Deserializes hibernation attachment metadata from the socket. */
|
|
147
|
-
readonly deserializeAttachment: Effect.Effect<unknown, DurableWebSocketAttachmentError>;
|
|
148
|
-
}
|
|
149
|
-
declare const fromWebSocket: <Attachment = unknown>(raw: WebSocket) => DurableWebSocket<Attachment>;
|
|
150
|
-
interface AcceptUpgradeOptions<Attachment = unknown> {
|
|
151
|
-
readonly tags?: ReadonlyArray<string> | undefined;
|
|
152
|
-
/** Optional attachment serialized onto the server socket. */
|
|
153
|
-
readonly attachment?: Attachment | undefined;
|
|
154
|
-
}
|
|
155
|
-
interface AcceptedUpgrade<Attachment = unknown> {
|
|
156
|
-
readonly client: WebSocket;
|
|
157
|
-
readonly server: DurableWebSocket<Attachment>;
|
|
158
|
-
readonly response: Response;
|
|
159
|
-
}
|
|
160
|
-
declare const acceptUpgrade: <Attachment = unknown>(options?: AcceptUpgradeOptions<Attachment> | undefined) => Effect.Effect<AcceptedUpgrade<Attachment>, DurableWebSocketAttachmentError, DurableObjectState>;
|
|
161
|
-
type AttachmentInvalidPolicy = "ignore" | "ignore-and-close" | "fail";
|
|
162
|
-
interface AttachmentRehydrateOptions {
|
|
163
|
-
readonly tag?: string | undefined;
|
|
164
|
-
readonly onInvalid?: AttachmentInvalidPolicy | undefined;
|
|
165
|
-
}
|
|
166
|
-
interface RehydratedDurableWebSocket<Attachment> {
|
|
167
|
-
readonly socket: DurableWebSocket<Attachment>;
|
|
168
|
-
readonly attachment: Attachment;
|
|
169
|
-
}
|
|
170
|
-
interface DurableWebSocketAttachment<Attachment, Encoded> {
|
|
171
|
-
serialize(socket: DurableWebSocket<unknown>, value: Attachment): Effect.Effect<void, DurableWebSocketAttachmentError>;
|
|
172
|
-
deserialize(socket: DurableWebSocket<unknown>): Effect.Effect<Option.Option<Attachment>, DurableWebSocketAttachmentError>;
|
|
173
|
-
rehydrate(options?: AttachmentRehydrateOptions): Effect.Effect<Array<RehydratedDurableWebSocket<Attachment>>, DurableWebSocketAttachmentError, DurableObjectState>;
|
|
174
|
-
readonly schema: Schema.Codec<Attachment, Encoded, never, never>;
|
|
175
|
-
}
|
|
176
|
-
declare const attachment: <const AttachmentSchema extends Schema.Codec<any, any, never, never>>(schema: AttachmentSchema) => DurableWebSocketAttachment<Schema.Schema.Type<AttachmentSchema>, Schema.Codec.Encoded<AttachmentSchema>>;
|
|
177
|
-
interface DurableWebSocketHandlers<R = never, E = unknown> {
|
|
178
|
-
readonly message?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect<void, E, R>;
|
|
179
|
-
readonly close?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, E, R>;
|
|
180
|
-
readonly error?: (socket: DurableWebSocket, cause: unknown) => Effect.Effect<void, E, R>;
|
|
181
|
-
}
|
|
182
|
-
declare const handlers: <R = never, E = unknown>(options: DurableWebSocketHandlers<R, E>) => {
|
|
183
|
-
webSocketMessage: ((socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect<void, E, R>) | undefined;
|
|
184
|
-
webSocketClose: ((socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, E, R>) | undefined;
|
|
185
|
-
webSocketError: ((socket: DurableWebSocket, cause: unknown) => Effect.Effect<void, E, R>) | undefined;
|
|
186
|
-
};
|
|
187
5
|
declare namespace Rpc_d_exports {
|
|
188
6
|
export { DisposableValue, MethodArgs, MethodKey, MethodReturn, Provider, Result$1 as Result, RpcStub, RpcTarget, Serializable, Stub, Stubable, Stubify, dispose, isDisposable, resolve, scoped };
|
|
189
7
|
}
|
|
@@ -274,8 +92,9 @@ declare const isWireError: (error: WireValue) => error is WireError;
|
|
|
274
92
|
*/
|
|
275
93
|
declare const encodeWireError: (error: WireValue) => WireValue;
|
|
276
94
|
declare const decodeWireError: (cause: WireValue) => WireValue;
|
|
95
|
+
declare const reservedMethodNameValues: readonly ["constructor", "fetch", "connect", "alarm", "webSocketMessage", "webSocketClose", "webSocketError", "then", "dup", "dispose", "serialize", "deserialize"];
|
|
277
96
|
declare const reservedMethodNames: Set<string>;
|
|
278
|
-
type ReservedMethodName$3 =
|
|
97
|
+
type ReservedMethodName$3 = (typeof reservedMethodNameValues)[number];
|
|
279
98
|
type ServiceFreeSchema$1 = Schema.Codec<any, any, never, never>;
|
|
280
99
|
interface Method$2<Args extends ReadonlyArray<ServiceFreeSchema$1> = ReadonlyArray<ServiceFreeSchema$1>, Success extends ServiceFreeSchema$1 = ServiceFreeSchema$1> {
|
|
281
100
|
readonly args: Args;
|
|
@@ -516,9 +335,9 @@ type ApiOrDefinition<Api extends object, Definition> = [Api] extends [never] ? A
|
|
|
516
335
|
/**
|
|
517
336
|
* Binding metadata used to create an Effect service from a Worker binding.
|
|
518
337
|
*/
|
|
519
|
-
interface ServiceBindingDefinition<Definition$
|
|
338
|
+
interface ServiceBindingDefinition<Definition$7 extends Definition.Any | undefined = undefined> {
|
|
520
339
|
readonly binding: string;
|
|
521
|
-
readonly definition?: Definition$
|
|
340
|
+
readonly definition?: Definition$7;
|
|
522
341
|
/** Append live trace context only when the receiver also enables rpcTracing. */
|
|
523
342
|
readonly rpcTracing?: boolean;
|
|
524
343
|
}
|
|
@@ -554,7 +373,7 @@ type ServiceMethodCloudflareReturn<Api, Method extends keyof Api> = AsyncMethodC
|
|
|
554
373
|
type ServiceCall<R, Api> = <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
555
374
|
type DefinitionDirectMethods<R, Definition$4 extends Definition.Any> = { readonly [Method in Definition$3.MethodNames<Definition$4>]: (...args: Method$2.Args<Definition$4["methods"][Method]>) => Effect.Effect<Method$2.Success<Definition$4["methods"][Method]>, ServiceBindingRpcError, R>; };
|
|
556
375
|
type DirectMethods<R, Definition$13> = Definition$13 extends Definition.Any ? DefinitionDirectMethods<R, Definition$13> : {};
|
|
557
|
-
type ServiceBindingEffectClient<Api extends object, Definition$
|
|
376
|
+
type ServiceBindingEffectClient<Api extends object, Definition$8 extends Definition.Any | undefined = undefined> = DirectMethods<never, Definition$8> & {
|
|
558
377
|
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError>;
|
|
559
378
|
/**
|
|
560
379
|
* Invokes a Worker RPC method and returns Cloudflare's raw RPC result.
|
|
@@ -581,27 +400,27 @@ type ServiceBindingEffectClient<Api extends object, Definition$7 extends Definit
|
|
|
581
400
|
* Use this for RPC methods that return Cloudflare RPC resources or other
|
|
582
401
|
* disposable objects whose lifetime should be tied to an Effect scope.
|
|
583
402
|
*/
|
|
584
|
-
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>,
|
|
403
|
+
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, ServiceBindingRpcError, Scope.Scope>;
|
|
585
404
|
};
|
|
586
|
-
type ServiceBindingStaticClient<R, Api extends object, Definition$
|
|
405
|
+
type ServiceBindingStaticClient<R, Api extends object, Definition$5 extends Definition.Any | undefined = undefined> = DirectMethods<R, Definition$5> & {
|
|
587
406
|
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError, R>;
|
|
588
407
|
readonly rpc: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodCloudflareReturn<Api, Method>, ServiceBindingRpcError, R>;
|
|
589
408
|
readonly call: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
590
|
-
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>,
|
|
409
|
+
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, ServiceBindingRpcError, Scope.Scope | R>;
|
|
591
410
|
};
|
|
592
411
|
type ServiceBindingValue = Schema.Schema.Type<typeof Schema.Unknown>;
|
|
593
412
|
declare const isServiceBindingClient: <Api extends object>(value: ServiceBindingValue) => value is ServiceBindingClient<Api>;
|
|
594
|
-
declare const makeClient: <Api extends object, const Definition$
|
|
595
|
-
declare const layer: <Self, Api extends object, const Definition$
|
|
596
|
-
declare const Service: <Self, Api extends object = never>() => <Id extends string, const Definition$
|
|
413
|
+
declare const makeClient: <Api extends object, const Definition$10 extends Definition.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition$10>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition$10>);
|
|
414
|
+
declare const layer: <Self, Api extends object, const Definition$11 extends Definition.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition$11>>, definition: ServiceBindingDefinition<Definition$11>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
415
|
+
declare const Service: <Self, Api extends object = never>() => <Id extends string, const Definition$6 extends Definition.Any | undefined = undefined>(id: Id, definition: ServiceBindingDefinition<Definition$6>) => BindingService<Self, Id, ServiceBindingEffectClient<ApiOrDefinition<Api, Definition$6>, Definition$6>> & DirectMethods<Self, Definition$6> & {
|
|
597
416
|
readonly [TypeId]: typeof TypeId;
|
|
598
|
-
readonly definition: ServiceBindingDefinition<Definition$
|
|
417
|
+
readonly definition: ServiceBindingDefinition<Definition$6>;
|
|
599
418
|
readonly fetch: (input: URL | RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined) => Effect.Effect<Response, ServiceBindingFetchError, Self>;
|
|
600
|
-
readonly rpc: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$
|
|
601
|
-
readonly call: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$
|
|
602
|
-
readonly scopedCall: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$
|
|
419
|
+
readonly rpc: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$6>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition$6>, Method>) => Effect.Effect<Result$1<AsyncMethodSuccess<ApiOrDefinition<Api, Definition$6>, Method>>, ServiceBindingRpcError, Self>;
|
|
420
|
+
readonly call: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$6>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition$6>, Method>) => Effect.Effect<AsyncMethodSuccess<ApiOrDefinition<Api, Definition$6>, Method>, ServiceBindingRpcError, Self>;
|
|
421
|
+
readonly scopedCall: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition$6>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition$6>, Method>) => Effect.Effect<Awaited<AsyncMethodSuccess<ApiOrDefinition<Api, Definition$6>, Method>>, ServiceBindingRpcError, Self | Scope.Scope>;
|
|
603
422
|
};
|
|
604
|
-
declare const makeDirectMethods: <R, Api, Definition$
|
|
423
|
+
declare const makeDirectMethods: <R, Api, Definition$9 extends Definition.Any | undefined>(rpcDefinition: Definition$9 | undefined, call: ServiceCall<R, Api>) => DirectMethods<R, Definition$9>;
|
|
605
424
|
declare namespace WorkerDefinition_d_exports {
|
|
606
425
|
export { Api, Definition, HandlerEffect, Handlers, LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options, ReservedMethodName$1 as ReservedMethodName, ServerApi$1 as ServerApi, ServiceFreeSchema, Tag, TagClass, Worker, implement, make$1 as make, method };
|
|
607
426
|
}
|
|
@@ -750,10 +569,12 @@ interface WorkerOptions<RRuntime, REvent = never, EventLayerError = never, Rpc e
|
|
|
750
569
|
/**
|
|
751
570
|
* Layer provided around each Cloudflare event handled by this Worker.
|
|
752
571
|
*
|
|
753
|
-
* The layer is built inside the event's Effect scope
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
572
|
+
* The layer is built inside the event's Effect scope. For fetch handlers that
|
|
573
|
+
* return an Effect `HttpServerResponse` stream, its scope remains open until
|
|
574
|
+
* the response body finishes or is canceled. Native `Response` values pass
|
|
575
|
+
* through unchanged, so their body streams do not carry this scoped-lifetime
|
|
576
|
+
* guarantee. Fetch, queue, and RPC handlers schedule a best-effort telemetry
|
|
577
|
+
* flush capped at two seconds.
|
|
757
578
|
*/
|
|
758
579
|
readonly eventLayer?: Layer.Layer<REvent, EventLayerError, WorkerBaseContext<RRuntime>>;
|
|
759
580
|
readonly fetch?: Effect.Effect<WorkerFetchSuccess, unknown, WorkerFetchContext<RRuntime | REvent>>;
|
|
@@ -794,8 +615,10 @@ interface FetchHandler<Env extends WorkerEnv = WorkerEnv> {
|
|
|
794
615
|
readonly fetch: (request: Request, env: Env, ctx: globalThis.ExecutionContext) => Promise<Response>;
|
|
795
616
|
}
|
|
796
617
|
/**
|
|
797
|
-
*
|
|
798
|
-
*
|
|
618
|
+
* Cloudflare creates a new `WorkerEntrypoint` instance for each native
|
|
619
|
+
* invocation, so this base layer is not shared across invocations. Its managed
|
|
620
|
+
* runtime has no deterministic disposal point in this adapter; use
|
|
621
|
+
* `eventLayer` for resources whose finalizers must run with an event.
|
|
799
622
|
*/
|
|
800
623
|
declare function make<ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, fetch: WorkerHandler<ROut>): WorkerClass<Record<never, never>, ROut>;
|
|
801
624
|
declare function make<ROut, LayerError, REvent, EventLayerError = never, const Rpc extends WorkerRpc<ROut | REvent> = Record<never, never>>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: WorkerOptionsWithEventLayer<ROut, REvent, EventLayerError, Rpc>): WorkerClass<Rpc, ROut | REvent>;
|
|
@@ -804,72 +627,15 @@ declare function make<ROut, LayerError, REvent extends never = never, EventLayer
|
|
|
804
627
|
* Creates an `ExportedHandler`-compatible `{ fetch }` object backed by
|
|
805
628
|
* {@link make}.
|
|
806
629
|
*
|
|
807
|
-
* The Effect runtime is cached per `env` identity, so the
|
|
808
|
-
* once
|
|
809
|
-
*
|
|
810
|
-
*
|
|
811
|
-
*
|
|
812
|
-
*
|
|
630
|
+
* The Effect runtime is cached per `env` identity, so the base layer builds
|
|
631
|
+
* once for that cached handler. Request handlers and `eventLayer` receive fresh
|
|
632
|
+
* `ExecutionContext` and `WorkerContext` services. A service constructed by the
|
|
633
|
+
* cached base layer from either context instead captures the first request's
|
|
634
|
+
* value, so construct invocation-bound services in `eventLayer`. Cloudflare
|
|
635
|
+
* provides no isolate shutdown hook, so cached base-layer finalizers are not
|
|
636
|
+
* guaranteed to run.
|
|
813
637
|
*/
|
|
814
638
|
declare function makeFetchHandler<ROut, LayerError, REvent, EventLayerError = never, Env extends WorkerEnv = WorkerEnv>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: FetchWorkerOptionsWithEventLayer<ROut, REvent, EventLayerError>): FetchHandler<Env>;
|
|
815
639
|
declare function makeFetchHandler<ROut, LayerError, REvent extends never = never, EventLayerError = never, Env extends WorkerEnv = WorkerEnv>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: FetchWorkerOptions<ROut, REvent, EventLayerError>): FetchHandler<Env>;
|
|
816
|
-
declare namespace DurableObjectState_d_exports {
|
|
817
|
-
export { DurableObjectState, DurableObjectStateService, fromDurableObjectState };
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Effect-friendly wrapper around Cloudflare `DurableObjectState`.
|
|
821
|
-
*/
|
|
822
|
-
interface DurableObjectStateService {
|
|
823
|
-
readonly raw: globalThis.DurableObjectState;
|
|
824
|
-
readonly id: globalThis.DurableObjectId;
|
|
825
|
-
readonly storage: DurableObjectStorage;
|
|
826
|
-
waitUntil(promise: Promise<unknown>): Effect.Effect<void>;
|
|
827
|
-
/**
|
|
828
|
-
* Runs a background Effect via Cloudflare's `waitUntil` with the caller's
|
|
829
|
-
* Effect context, mirroring `WorkerContext.waitUntil` failure modes:
|
|
830
|
-
* `"observe"` (default) logs or routes failures to `onFailure`, while
|
|
831
|
-
* `"propagate"` also rejects the native `waitUntil` promise.
|
|
832
|
-
*/
|
|
833
|
-
waitUntil<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: WorkerContextWaitUntilOptions<E, R2>): Effect.Effect<void, never, R | R2>;
|
|
834
|
-
/**
|
|
835
|
-
* Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate.
|
|
836
|
-
*
|
|
837
|
-
* Cloudflare resets a Durable Object if the callback throws/rejects, or if the
|
|
838
|
-
* callback exceeds the platform timeout (currently documented as 30 seconds).
|
|
839
|
-
* This safe default resolves the callback with the Effect `Exit` for typed
|
|
840
|
-
* Effect failures and resumes that `Exit` afterward, so typed failures remain
|
|
841
|
-
* ordinary Effect failures instead of resetting the Durable Object. Defects
|
|
842
|
-
* and interruptions still reject the callback.
|
|
843
|
-
*/
|
|
844
|
-
blockConcurrencyWhile<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
845
|
-
/**
|
|
846
|
-
* Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate and lets
|
|
847
|
-
* Effect failures reject the callback.
|
|
848
|
-
*
|
|
849
|
-
* Use this only when Cloudflare's reset-on-throw behavior is intentional. The
|
|
850
|
-
* platform also resets the Durable Object if the callback exceeds the
|
|
851
|
-
* documented timeout (currently 30 seconds).
|
|
852
|
-
*/
|
|
853
|
-
blockConcurrencyWhileOrReset<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
854
|
-
acceptWebSocket(ws: DurableWebSocket, tags?: Array<string>): Effect.Effect<void>;
|
|
855
|
-
getWebSockets(tag?: string): Effect.Effect<Array<DurableWebSocket>>;
|
|
856
|
-
setWebSocketAutoResponse(pair?: WebSocketRequestResponsePair): Effect.Effect<void>;
|
|
857
|
-
getWebSocketAutoResponse: Effect.Effect<WebSocketRequestResponsePair | null>;
|
|
858
|
-
getWebSocketAutoResponseTimestamp(ws: DurableWebSocket): Effect.Effect<Date | null>;
|
|
859
|
-
setHibernatableWebSocketEventTimeout(timeoutMs?: number): Effect.Effect<void>;
|
|
860
|
-
getHibernatableWebSocketEventTimeout: Effect.Effect<number | null>;
|
|
861
|
-
getTags(ws: DurableWebSocket): Effect.Effect<Array<string>>;
|
|
862
|
-
/**
|
|
863
|
-
* Forcibly resets the Durable Object. Cloudflare logs an uncaught Error using
|
|
864
|
-
* the optional reason, and the method is not available in `wrangler dev` local
|
|
865
|
-
* development according to the Durable Object State docs. Set
|
|
866
|
-
* `retryAlarm: false` to prevent the current alarm invocation from retrying;
|
|
867
|
-
* this option has no effect outside an alarm handler.
|
|
868
|
-
*/
|
|
869
|
-
abort(reason?: string, options?: globalThis.DurableObjectAbortOptions): Effect.Effect<void>;
|
|
870
|
-
}
|
|
871
|
-
declare const DurableObjectState_base: Context.ServiceClass<DurableObjectState, "effect-cf/DurableObjectState", DurableObjectStateService>;
|
|
872
|
-
declare class DurableObjectState extends DurableObjectState_base {}
|
|
873
|
-
declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService;
|
|
874
640
|
//#endregion
|
|
875
|
-
export {
|
|
641
|
+
export { Provider as C, ServiceFreeSchema$1 as S, QueueBinding_d_exports as _, Worker_d_exports as a, ReservedMethodName$3 as b, AsyncMethodArgs as c, AsyncMethodSuccess as d, ReceiverOptions as f, QueueDefinition_d_exports as g, Queue_d_exports as h, WorkerContextWaitUntilOptions as i, AsyncMethodCloudflareReturn as l, RpcTracing_d_exports as m, NativeRequest as n, WorkerDefinition_d_exports as o, RpcInvocationInfo as p, WorkerContext as r, ServiceBinding_d_exports as s, ExecutionContext as t, AsyncMethodKey as u, Definition$3 as v, Rpc_d_exports as w, RpcDefinition_d_exports as x, Method$2 as y };
|