effect-cf 0.22.0 → 0.23.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 +8 -0
- package/README.md +26 -2
- package/dist/index.d.mts +929 -897
- package/dist/index.mjs +91 -52
- package/package.json +1 -1
- package/src/ContainerNamespace.ts +172 -33
- package/src/DurableObjectState.ts +61 -34
- package/src/internal/WorkerContext.ts +29 -19
package/dist/index.d.mts
CHANGED
|
@@ -719,1029 +719,1061 @@ declare const handlers: <R = never, E = unknown>(options: DurableWebSocketHandle
|
|
|
719
719
|
webSocketClose: ((socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, E, R>) | undefined;
|
|
720
720
|
webSocketError: ((socket: DurableWebSocket, error: unknown) => Effect.Effect<void, E, R>) | undefined;
|
|
721
721
|
};
|
|
722
|
-
declare namespace
|
|
723
|
-
export {
|
|
722
|
+
declare namespace Rpc_d_exports {
|
|
723
|
+
export { DisposableValue, MethodArgs, MethodKey, MethodReturn, Provider, Result$1 as Result, RpcStub, RpcTarget, Serializable, Stub, Stubable, Stubify, dispose, isDisposable, resolve, scoped };
|
|
724
724
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate and lets
|
|
750
|
-
* Effect failures reject the callback.
|
|
751
|
-
*
|
|
752
|
-
* Use this only when Cloudflare's reset-on-throw behavior is intentional. The
|
|
753
|
-
* platform also resets the Durable Object if the callback exceeds the
|
|
754
|
-
* documented timeout (currently 30 seconds).
|
|
755
|
-
*/
|
|
756
|
-
blockConcurrencyWhileOrReset<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
757
|
-
/** Accepts a websocket connection for hibernation-capable Durable Objects. */
|
|
758
|
-
acceptWebSocket(ws: DurableWebSocket, tags?: Array<string>): Effect.Effect<void>;
|
|
759
|
-
/** Lists active sockets, optionally filtered by tag. */
|
|
760
|
-
getWebSockets(tag?: string): Effect.Effect<Array<DurableWebSocket>>;
|
|
761
|
-
/** Configures automatic request/response handling for sockets. */
|
|
762
|
-
setWebSocketAutoResponse(pair?: WebSocketRequestResponsePair): Effect.Effect<void>;
|
|
763
|
-
/** Gets the configured websocket auto-response pair. */
|
|
764
|
-
getWebSocketAutoResponse: Effect.Effect<WebSocketRequestResponsePair | null>;
|
|
765
|
-
/** Timestamp of the last automatic websocket response for a socket. */
|
|
766
|
-
getWebSocketAutoResponseTimestamp(ws: DurableWebSocket): Effect.Effect<Date | null>;
|
|
767
|
-
/** Sets the timeout for hibernatable websocket events. */
|
|
768
|
-
setHibernatableWebSocketEventTimeout(timeoutMs?: number): Effect.Effect<void>;
|
|
769
|
-
/** Gets the timeout for hibernatable websocket events. */
|
|
770
|
-
getHibernatableWebSocketEventTimeout: Effect.Effect<number | null>;
|
|
771
|
-
/** Reads tags attached to a websocket. */
|
|
772
|
-
getTags(ws: DurableWebSocket): Effect.Effect<Array<string>>;
|
|
773
|
-
/**
|
|
774
|
-
* Forcibly resets the Durable Object. Cloudflare logs an uncaught Error using
|
|
775
|
-
* the optional reason, and the method is not available in `wrangler dev` local
|
|
776
|
-
* development according to the Durable Object State docs.
|
|
777
|
-
*/
|
|
778
|
-
abort(reason?: string): Effect.Effect<void>;
|
|
725
|
+
type Stubable = Rpc.Stubable;
|
|
726
|
+
type Stub<T extends Stubable> = Rpc.Stub<T>;
|
|
727
|
+
type Provider<T extends object, Reserved extends string = never> = Rpc.Provider<T, Reserved>;
|
|
728
|
+
type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
|
|
729
|
+
type Serializable<T> = BaseType | Map<T extends Map<infer Key, unknown> ? Serializable<Key> : never, T extends Map<unknown, infer Value> ? Serializable<Value> : never> | Set<T extends Set<infer Value> ? Serializable<Value> : never> | ReadonlyArray<T extends ReadonlyArray<infer Value> ? Serializable<Value> : never> | { [Key in keyof T]: Key extends number | string ? Serializable<T[Key]> : never; } | Stub<Stubable> | Stubable;
|
|
730
|
+
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer Key, infer Value> ? Map<Stubify<Key>, Stubify<Value>> : T extends Set<infer Value> ? Set<Stubify<Value>> : T extends Array<infer Value> ? Array<Stubify<Value>> : T extends ReadonlyArray<infer Value> ? ReadonlyArray<Stubify<Value>> : T extends BaseType ? T : T extends {
|
|
731
|
+
[key: string | number]: unknown;
|
|
732
|
+
} ? { [Key in keyof T]: Stubify<T[Key]>; } : T;
|
|
733
|
+
type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
|
|
734
|
+
type MaybeDisposable<T> = T extends object ? Disposable : unknown;
|
|
735
|
+
type Result$1<T> = T extends Stubable ? Promise<Stub<T>> & Provider<T> : T extends Serializable<T> ? Promise<Stubify<T> & MaybeDisposable<T>> & MaybeProvider<T> : never;
|
|
736
|
+
type MethodKey<Api> = { [Key in keyof Api]-?: Key extends string ? Api[Key] extends ((...args: Array<any>) => unknown) ? Key : never : never; }[keyof Api];
|
|
737
|
+
type MethodArgs<Api, Method extends keyof Api> = Api[Method] extends ((...args: infer Args) => unknown) ? Args : never;
|
|
738
|
+
type MethodReturn<Api, Method extends keyof Api> = Api[Method] extends ((...args: Array<any>) => infer Return) ? Return : never;
|
|
739
|
+
type DisposableValue = {
|
|
740
|
+
[Symbol.dispose](): void;
|
|
741
|
+
};
|
|
742
|
+
declare const isDisposable: (value: unknown) => value is DisposableValue;
|
|
743
|
+
declare const dispose: (value: unknown) => Effect.Effect<void>;
|
|
744
|
+
declare const resolve: <A>(value: A) => Effect.Effect<Awaited<A>, unknown>;
|
|
745
|
+
declare const scoped: <A>(value: A) => Effect.Effect<Awaited<A>, unknown, Scope.Scope>;
|
|
746
|
+
declare namespace RpcDefinition_d_exports {
|
|
747
|
+
export { Definition$7 as Definition, Method$3 as Method, Methods$2 as Methods, NoReservedMethods$2 as NoReservedMethods, ReservedMethodName$5 as ReservedMethodName, RpcArgumentCountError, RpcArgumentDecodeError, RpcArgumentEncodeError, RpcReservedMethodNameError, RpcSuccessDecodeError, RpcSuccessEncodeError, ServiceFreeSchema$2 as ServiceFreeSchema, WireError, assertNoReservedMethods, decodeArgs, decodeSuccess, decodeWireError, encodeArgs, encodeSuccess, encodeWireError, isWireError, make$13 as make, method$2 as method, reservedMethodNames };
|
|
779
748
|
}
|
|
780
|
-
declare const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService;
|
|
789
|
-
declare namespace CloudflareOtlp_d_exports {
|
|
790
|
-
export { DurableObjectLayerOptions, LayerOptions$13 as LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer$12 as layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
|
|
749
|
+
declare const RpcReservedMethodNameError_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 & {
|
|
750
|
+
readonly _tag: "RpcReservedMethodNameError";
|
|
751
|
+
} & Readonly<A>;
|
|
752
|
+
declare class RpcReservedMethodNameError extends RpcReservedMethodNameError_base<{
|
|
753
|
+
readonly definition: string;
|
|
754
|
+
readonly method: string;
|
|
755
|
+
}> {
|
|
756
|
+
get message(): string;
|
|
791
757
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
* `serviceName`/`serviceVersion` win over matching explicit `attributes`, and
|
|
801
|
-
* explicit attributes win over `OTEL_SERVICE_NAME`, `OTEL_SERVICE_VERSION`, and
|
|
802
|
-
* `OTEL_RESOURCE_ATTRIBUTES`. Omit an option to let operators set it from the
|
|
803
|
-
* environment.
|
|
804
|
-
*/
|
|
805
|
-
interface ResourceOptions {
|
|
806
|
-
/** Explicit service name. Takes precedence over OTEL environment variables. */
|
|
807
|
-
readonly serviceName?: string;
|
|
808
|
-
/** Explicit service version. Takes precedence over OTEL environment variables. */
|
|
809
|
-
readonly serviceVersion?: string;
|
|
810
|
-
/** Additional resource attributes attached to exported telemetry. */
|
|
811
|
-
readonly attributes?: Record<string, unknown>;
|
|
758
|
+
declare const RpcArgumentCountError_base: Schema.Class<RpcArgumentCountError, Schema.TaggedStruct<"RpcArgumentCountError", {
|
|
759
|
+
readonly definition: Schema.String;
|
|
760
|
+
readonly method: Schema.String;
|
|
761
|
+
readonly expected: Schema.Number;
|
|
762
|
+
readonly actual: Schema.Number;
|
|
763
|
+
}>, import("effect/Cause").YieldableError>;
|
|
764
|
+
declare class RpcArgumentCountError extends RpcArgumentCountError_base {
|
|
765
|
+
get message(): string;
|
|
812
766
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
*/
|
|
821
|
-
readonly signals?: ReadonlyArray<Signal>;
|
|
822
|
-
/** OTLP payload serialization. Defaults to protobuf. */
|
|
823
|
-
readonly serialization?: Serialization;
|
|
824
|
-
/** Resource metadata forwarded to Effect's OTLP resource resolver. */
|
|
825
|
-
readonly resource?: ResourceOptions;
|
|
826
|
-
/**
|
|
827
|
-
* Explicit headers for every selected signal.
|
|
828
|
-
*
|
|
829
|
-
* When omitted, Effect reads `OTEL_EXPORTER_OTLP_HEADERS` and the
|
|
830
|
-
* signal-specific `OTEL_EXPORTER_OTLP_*_HEADERS` variables.
|
|
831
|
-
*/
|
|
832
|
-
readonly headers?: Headers$1.Input;
|
|
833
|
-
/** Exclude log records emitted for spans when exporting logs. */
|
|
834
|
-
readonly loggerExcludeLogSpans?: boolean;
|
|
835
|
-
/** Merge the OTLP logger with existing loggers instead of replacing them. */
|
|
836
|
-
readonly loggerMergeWithExisting?: boolean;
|
|
837
|
-
/** Custom trace context lookup used by the Effect OTLP tracer. */
|
|
838
|
-
readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
|
|
767
|
+
declare const RpcArgumentDecodeError_base: Schema.Class<RpcArgumentDecodeError, Schema.TaggedStruct<"RpcArgumentDecodeError", {
|
|
768
|
+
readonly definition: Schema.String;
|
|
769
|
+
readonly method: Schema.String;
|
|
770
|
+
readonly cause: Schema.Defect;
|
|
771
|
+
}>, import("effect/Cause").YieldableError>;
|
|
772
|
+
declare class RpcArgumentDecodeError extends RpcArgumentDecodeError_base {
|
|
773
|
+
get message(): string;
|
|
839
774
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
775
|
+
declare const RpcArgumentEncodeError_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 & {
|
|
776
|
+
readonly _tag: "RpcArgumentEncodeError";
|
|
777
|
+
} & Readonly<A>;
|
|
778
|
+
declare class RpcArgumentEncodeError extends RpcArgumentEncodeError_base<{
|
|
779
|
+
readonly definition: string;
|
|
780
|
+
readonly method: string;
|
|
781
|
+
readonly cause: unknown;
|
|
782
|
+
}> {
|
|
783
|
+
get message(): string;
|
|
844
784
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
readonly includeObjectId?: boolean;
|
|
785
|
+
declare const RpcSuccessDecodeError_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 & {
|
|
786
|
+
readonly _tag: "RpcSuccessDecodeError";
|
|
787
|
+
} & Readonly<A>;
|
|
788
|
+
declare class RpcSuccessDecodeError extends RpcSuccessDecodeError_base<{
|
|
789
|
+
readonly definition: string;
|
|
790
|
+
readonly method: string;
|
|
791
|
+
readonly cause: unknown;
|
|
792
|
+
}> {
|
|
793
|
+
get message(): string;
|
|
855
794
|
}
|
|
795
|
+
declare const RpcSuccessEncodeError_base: Schema.Class<RpcSuccessEncodeError, Schema.TaggedStruct<"RpcSuccessEncodeError", {
|
|
796
|
+
readonly definition: Schema.String;
|
|
797
|
+
readonly method: Schema.String;
|
|
798
|
+
readonly cause: Schema.Defect;
|
|
799
|
+
}>, import("effect/Cause").YieldableError>;
|
|
800
|
+
declare class RpcSuccessEncodeError extends RpcSuccessEncodeError_base {
|
|
801
|
+
get message(): string;
|
|
802
|
+
}
|
|
803
|
+
/** Errors raised server-side that must survive the Cloudflare RPC wire. */
|
|
804
|
+
type WireError = RpcArgumentCountError | RpcArgumentDecodeError | RpcSuccessEncodeError;
|
|
805
|
+
declare const isWireError: (error: unknown) => error is WireError;
|
|
856
806
|
/**
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
* Standard OpenTelemetry environment variables are resolved by Effect's OTLP
|
|
860
|
-
* layers. In Cloudflare Workers and Durable Objects, the current `env` object is
|
|
861
|
-
* installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
|
|
862
|
-
* Effect `ConfigProvider` remains the fallback.
|
|
863
|
-
*
|
|
864
|
-
* The layer provides {@link OtlpExporter.Flusher} for draining buffered
|
|
865
|
-
* telemetry before the isolate freezes.
|
|
866
|
-
*/
|
|
867
|
-
declare const layer$12: (options?: LayerOptions$13) => Layer.Layer<OtlpExporter.Flusher>;
|
|
868
|
-
/** Base OTLP telemetry layer forced to JSON serialization. */
|
|
869
|
-
declare const layerJson: (options?: Omit<LayerOptions$13, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
870
|
-
/** Base OTLP telemetry layer forced to protobuf serialization. */
|
|
871
|
-
declare const layerProtobuf: (options?: Omit<LayerOptions$13, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
872
|
-
/**
|
|
873
|
-
* OTLP layer with Cloudflare Worker resource attributes.
|
|
874
|
-
*
|
|
875
|
-
* Provide this layer at runtime scope for long-lived metrics aggregation, or at
|
|
876
|
-
* handler scope when traces/logs should flush as the Cloudflare event finishes.
|
|
877
|
-
*/
|
|
878
|
-
declare const layerWorker: (options?: WorkerLayerOptions) => Layer.Layer<OtlpExporter.Flusher>;
|
|
879
|
-
/**
|
|
880
|
-
* OTLP layer with Cloudflare Durable Object resource attributes.
|
|
881
|
-
*
|
|
882
|
-
* The layer reads {@link DurableObjectState} so it can optionally include the
|
|
883
|
-
* Durable Object id. Prefer leaving `includeObjectId` disabled unless the
|
|
884
|
-
* backend can tolerate high-cardinality resource attributes.
|
|
807
|
+
* Encodes package RPC errors into a plain `Error` envelope so their tags
|
|
808
|
+
* survive Cloudflare RPC serialization, which drops custom error properties.
|
|
885
809
|
*/
|
|
886
|
-
declare const
|
|
887
|
-
|
|
888
|
-
|
|
810
|
+
declare const encodeWireError: (error: unknown) => unknown;
|
|
811
|
+
/** Restores package RPC errors from the {@link encodeWireError} envelope. */
|
|
812
|
+
declare const decodeWireError: (cause: unknown) => unknown;
|
|
813
|
+
declare const reservedMethodNames: Set<string>;
|
|
814
|
+
type ReservedMethodName$5 = "constructor" | "fetch" | "connect" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError" | "then" | "dup" | "dispose" | "serialize" | "deserialize";
|
|
815
|
+
type ServiceFreeSchema$2 = Schema.Codec<any, any, never, never>;
|
|
816
|
+
interface Method$3<Args extends ReadonlyArray<ServiceFreeSchema$2> = ReadonlyArray<ServiceFreeSchema$2>, Success extends ServiceFreeSchema$2 = ServiceFreeSchema$2> {
|
|
817
|
+
readonly args: Args;
|
|
818
|
+
readonly success: Success;
|
|
889
819
|
}
|
|
890
|
-
|
|
891
|
-
type
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
820
|
+
declare namespace Method$3 {
|
|
821
|
+
export type Any = Method$3<ReadonlyArray<ServiceFreeSchema$2>, ServiceFreeSchema$2>;
|
|
822
|
+
type ArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$2>> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends ReadonlyArray<ServiceFreeSchema$2>] ? [Schema.Schema.Type<Head>, ...ArgsFromSchemas<Tail>] : Array<Schema.Schema.Type<Args[number]>>;
|
|
823
|
+
/** Method schemas cross the wire through their canonical JSON codec. */
|
|
824
|
+
type EncodedArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$2>> = { [Index in keyof Args]: Schema.Json; };
|
|
825
|
+
export type Args<Self extends Any> = ArgsFromSchemas<Self["args"]>;
|
|
826
|
+
export type EncodedArgs<Self extends Any> = EncodedArgsFromSchemas<Self["args"]>;
|
|
827
|
+
export type Success<Self extends Any> = Schema.Schema.Type<Self["success"]>;
|
|
828
|
+
export type EncodedSuccess<Self extends Any> = Schema.Json;
|
|
829
|
+
export {};
|
|
898
830
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
readonly
|
|
903
|
-
readonly
|
|
831
|
+
type Methods$2 = Record<string, Method$3.Any>;
|
|
832
|
+
type NoReservedMethods$2<MethodsShape extends Methods$2, Reserved extends string = ReservedMethodName$5> = Extract<keyof MethodsShape, Reserved> extends never ? MethodsShape : never;
|
|
833
|
+
interface Definition$7<Id extends string = string, MethodsShape extends Methods$2 = Methods$2> {
|
|
834
|
+
readonly id: Id;
|
|
835
|
+
readonly methods: MethodsShape;
|
|
904
836
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
readonly
|
|
908
|
-
|
|
909
|
-
|
|
837
|
+
declare namespace Definition$7 {
|
|
838
|
+
type Any = Definition$7<string, Methods$2>;
|
|
839
|
+
type ServerApi<Self extends Any> = { readonly [Key in keyof Self["methods"]]: (...args: Method$3.Args<Self["methods"][Key]>) => Promise<Method$3.Success<Self["methods"][Key]>>; };
|
|
840
|
+
type Api<Self extends Any, Reserved extends string = never> = Provider<ServerApi<Self>, Reserved>;
|
|
841
|
+
type MethodNames<Self extends Any> = Extract<keyof Self["methods"], string>;
|
|
910
842
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
readonly
|
|
914
|
-
|
|
915
|
-
|
|
843
|
+
declare const assertNoReservedMethods: (target: string, methods: Record<string, unknown>, reserved: ReadonlySet<string>) => void;
|
|
844
|
+
declare function method$2<Success extends ServiceFreeSchema$2>(definition: {
|
|
845
|
+
readonly success: Success;
|
|
846
|
+
}): Method$3<readonly [], Success>;
|
|
847
|
+
declare function method$2<const Args extends ReadonlyArray<ServiceFreeSchema$2>, Success extends ServiceFreeSchema$2>(definition: {
|
|
848
|
+
readonly args: Args;
|
|
849
|
+
readonly success: Success;
|
|
850
|
+
}): Method$3<Args, Success>;
|
|
851
|
+
declare const decodeArgs: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, args: readonly unknown[]) => Effect.Effect<Self["methods"][MethodName]["args"] extends (infer T) ? T extends Self["methods"][MethodName]["args"] ? T extends readonly [] ? [] : T extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ... /*elided*/ any] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<T[number]>[] : never : never, RpcArgumentCountError | RpcArgumentDecodeError, never>;
|
|
852
|
+
declare const encodeArgs: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, args: Self["methods"][MethodName]["args"] extends (infer T) ? T extends Self["methods"][MethodName]["args"] ? T extends readonly [] ? [] : T extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ... /*elided*/ any] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<T[number]>[] : never : never) => Effect.Effect<Self["methods"][MethodName]["args"] extends (infer T_1 extends readonly ServiceFreeSchema$2[]) ? { [Index in keyof T_1]: Schema.Json; } : never, RpcArgumentCountError | RpcArgumentEncodeError, never>;
|
|
853
|
+
declare const encodeSuccess: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, value: Method$3.Success<Self["methods"][MethodName]>) => Effect.Effect<Method$3.EncodedSuccess<Self["methods"][MethodName]>, RpcSuccessEncodeError>;
|
|
854
|
+
declare const decodeSuccess: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, value: unknown) => Effect.Effect<Method$3.Success<Self["methods"][MethodName]>, RpcSuccessDecodeError>;
|
|
855
|
+
declare const make$13: <Id extends string, const MethodsShape extends Methods$2>(id: Id, methods: MethodsShape) => Definition$7<Id, MethodsShape>;
|
|
856
|
+
declare namespace QueueBinding_d_exports {
|
|
857
|
+
export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$12 as layer, makeClient$9 as makeClient };
|
|
916
858
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
/**
|
|
928
|
-
|
|
929
|
-
*
|
|
930
|
-
* This is structural so using Container bindings does not make
|
|
931
|
-
* `@cloudflare/containers` a runtime dependency of effect-cf.
|
|
932
|
-
*/
|
|
933
|
-
interface ContainerStub {
|
|
934
|
-
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
935
|
-
getState(): Promise<ContainerState>;
|
|
936
|
-
start(options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions): Promise<void>;
|
|
937
|
-
startAndWaitForPorts(options?: ContainerStartAndWaitForPortsOptions): Promise<void>;
|
|
938
|
-
stop(signal?: ContainerSignal): Promise<void>;
|
|
939
|
-
destroy(): Promise<void>;
|
|
859
|
+
type QueueSendOptions = CloudflareQueueSendOptions;
|
|
860
|
+
type QueueSendResponse = CloudflareQueueSendResponse;
|
|
861
|
+
type QueueSendBatchOptions = CloudflareQueueSendBatchOptions;
|
|
862
|
+
type QueueSendBatchResponse = CloudflareQueueSendBatchResponse;
|
|
863
|
+
type QueueMetrics = CloudflareQueueMetrics;
|
|
864
|
+
type MessageSendRequest<Body> = CloudflareMessageSendRequest<Body>;
|
|
865
|
+
type QueueProducer<Body> = Pick<CloudflareQueue<Body>, "send"> & Partial<Pick<CloudflareQueue<Body>, "sendBatch" | "metrics">>;
|
|
866
|
+
interface QueueBindingDefinition<Message extends ServiceFreeSchema$2> {
|
|
867
|
+
/** Binding name as configured in `wrangler.jsonc`. */
|
|
868
|
+
readonly binding: string;
|
|
869
|
+
/** Codec used to encode messages before sending them to Cloudflare Queues. */
|
|
870
|
+
readonly message: Message;
|
|
940
871
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
872
|
+
interface QueueBindingClient<Message extends ServiceFreeSchema$2> {
|
|
873
|
+
readonly send: (message: Schema.Schema.Type<Message>, options?: QueueSendOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError>;
|
|
874
|
+
readonly sendBatch: (messages: Iterable<MessageSendRequest<Schema.Schema.Type<Message>>>, options?: QueueSendBatchOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError>;
|
|
875
|
+
readonly metrics: () => Effect.Effect<QueueMetrics, QueueOperationError>;
|
|
876
|
+
readonly rawUnsafe: Effect.Effect<CloudflareQueue<Schema.Codec.Encoded<Message>>>;
|
|
944
877
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
878
|
+
declare const QueueOperationError_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 & {
|
|
879
|
+
readonly _tag: "QueueOperationError";
|
|
880
|
+
} & Readonly<A>;
|
|
881
|
+
declare class QueueOperationError extends QueueOperationError_base<{
|
|
882
|
+
readonly binding: string;
|
|
883
|
+
readonly operation: string;
|
|
884
|
+
readonly cause: unknown;
|
|
885
|
+
readonly message: string;
|
|
886
|
+
}> {}
|
|
887
|
+
declare const isQueue: <Body>(value: unknown) => value is QueueProducer<Body>;
|
|
888
|
+
declare const makeClient$9: <Message extends ServiceFreeSchema$2>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<Schema.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
|
|
889
|
+
declare const layer$12: <Self, Message extends ServiceFreeSchema$2>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
890
|
+
declare namespace QueueDefinition_d_exports {
|
|
891
|
+
export { Definition$6 as Definition, Handler$3 as Handler, LayerOptions$13 as LayerOptions, Options$5 as Options, Queue$1 as Queue, Tag$12 as Tag, TagClass$11 as TagClass, implement$5 as implement, make$12 as make };
|
|
892
|
+
}
|
|
893
|
+
interface Definition$6<Id extends string = string, Message extends ServiceFreeSchema$2 = ServiceFreeSchema$2> {
|
|
894
|
+
readonly id: Id;
|
|
895
|
+
readonly message: Message;
|
|
896
|
+
}
|
|
897
|
+
declare namespace Definition$6 {
|
|
898
|
+
type Any = Definition$6<string, ServiceFreeSchema$2>;
|
|
899
|
+
}
|
|
900
|
+
type Handler$3<ROut, Self extends Definition$6.Any> = (batch: QueueBatch<Schema.Schema.Type<Self["message"]>>) => Effect.Effect<void, unknown, ExecutionContext | WorkerContext | WorkerEnvironment | Scope.Scope | ROut>;
|
|
901
|
+
interface Options$5<ROut, Self extends Definition$6.Any> extends Omit<WorkerOptions<ROut, Record<never, never>>, "queue" | "rpc"> {
|
|
902
|
+
readonly queue: Handler$3<ROut, Self>;
|
|
903
|
+
readonly rpc?: never;
|
|
904
|
+
}
|
|
905
|
+
type LayerOptions$13 = {
|
|
948
906
|
readonly binding: string;
|
|
907
|
+
};
|
|
908
|
+
interface TagClass$11<Self, Id extends string, Message extends ServiceFreeSchema$2> extends Context.ServiceClass<Self, `effect-cf/Queue/${Id}`, QueueBindingClient<Message>> {
|
|
909
|
+
readonly id: Id;
|
|
910
|
+
readonly message: Message;
|
|
911
|
+
readonly make: <ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: Options$5<ROut, Definition$6<Id, Message>>) => WorkerClass<Record<never, never>, ROut>;
|
|
912
|
+
readonly layer: (options: LayerOptions$13) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
913
|
+
readonly send: (message: Schema.Schema.Type<Message>, options?: QueueSendOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError, Self>;
|
|
914
|
+
readonly sendBatch: (messages: Iterable<MessageSendRequest<Schema.Schema.Type<Message>>>, options?: QueueSendBatchOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError, Self>;
|
|
915
|
+
readonly metrics: () => Effect.Effect<QueueMetrics, QueueOperationError, Self>;
|
|
916
|
+
readonly rawUnsafe: Effect.Effect<globalThis.Queue<Schema.Codec.Encoded<Message>>, never, Self>;
|
|
917
|
+
}
|
|
918
|
+
declare const make$12: <Id extends string, Message extends ServiceFreeSchema$2>(id: Id, definition: {
|
|
919
|
+
readonly message: Message;
|
|
920
|
+
}) => TagClass$11<Definition$6<Id, Message>, Id, Message>;
|
|
921
|
+
declare const Tag$12: <Self>() => <Id extends string, Message extends ServiceFreeSchema$2>(id: Id, definition: {
|
|
922
|
+
readonly message: Message;
|
|
923
|
+
}) => TagClass$11<Self, Id, Message>;
|
|
924
|
+
declare const Queue$1: typeof Tag$12;
|
|
925
|
+
declare const implement$5: <ROut, const Self extends Definition$6.Any>(_definition: Self, handler: Handler$3<ROut, Self>) => Handler$3<ROut, Self>;
|
|
926
|
+
declare namespace Queue_d_exports {
|
|
927
|
+
export { Definition$5 as Definition, Handler$2 as Handler, LayerOptions$12 as LayerOptions, Options$4 as Options, QueueBatch, QueueHandler, QueueMessage, QueueMessageDecodeError, QueueOptions, Tag$11 as Tag, TagClass$10 as TagClass, decodeBatch, fromMessage, fromMessageBatch, implement$4 as implement };
|
|
928
|
+
}
|
|
929
|
+
interface QueueMessage<Body> {
|
|
930
|
+
readonly raw: globalThis.Message<unknown>;
|
|
931
|
+
readonly id: string;
|
|
932
|
+
readonly timestamp: Date;
|
|
933
|
+
readonly body: Body;
|
|
934
|
+
readonly attempts: number;
|
|
935
|
+
readonly ack: Effect.Effect<void>;
|
|
936
|
+
readonly retry: (options?: globalThis.QueueRetryOptions) => Effect.Effect<void>;
|
|
937
|
+
}
|
|
938
|
+
interface QueueBatch<Body> {
|
|
939
|
+
readonly raw: globalThis.MessageBatch<unknown>;
|
|
940
|
+
readonly messages: ReadonlyArray<QueueMessage<Body>>;
|
|
941
|
+
readonly queue: string;
|
|
942
|
+
readonly metadata: globalThis.MessageBatchMetadata;
|
|
943
|
+
readonly ackAll: Effect.Effect<void>;
|
|
944
|
+
readonly retryAll: (options?: globalThis.QueueRetryOptions) => Effect.Effect<void>;
|
|
949
945
|
}
|
|
950
|
-
declare const
|
|
951
|
-
readonly _tag: "
|
|
946
|
+
declare const QueueMessageDecodeError_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 & {
|
|
947
|
+
readonly _tag: "QueueMessageDecodeError";
|
|
952
948
|
} & Readonly<A>;
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
readonly
|
|
956
|
-
readonly
|
|
957
|
-
readonly operation: string;
|
|
949
|
+
declare class QueueMessageDecodeError extends QueueMessageDecodeError_base<{
|
|
950
|
+
readonly queue: string;
|
|
951
|
+
readonly messageId: string;
|
|
952
|
+
readonly index: number;
|
|
958
953
|
readonly cause: unknown;
|
|
959
954
|
}> {
|
|
960
955
|
get message(): string;
|
|
961
956
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
readonly
|
|
967
|
-
readonly start: (options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions) => Effect.Effect<void, ContainerOperationError>;
|
|
968
|
-
readonly startAndWaitForPorts: (options?: ContainerStartAndWaitForPortsOptions) => Effect.Effect<void, ContainerOperationError>;
|
|
969
|
-
readonly stop: (signal?: ContainerSignal) => Effect.Effect<void, ContainerOperationError>;
|
|
970
|
-
readonly destroy: Effect.Effect<void, ContainerOperationError>;
|
|
971
|
-
}
|
|
972
|
-
/** Effect client for a Container namespace binding. */
|
|
973
|
-
interface ContainerNamespaceClient {
|
|
974
|
-
readonly definition: ContainerNamespaceDefinition;
|
|
975
|
-
readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<ContainerInstanceClient, ContainerOperationError>;
|
|
976
|
-
readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => ContainerInstanceClient;
|
|
977
|
-
readonly rawUnsafe: Effect.Effect<ContainerNamespaceResource>;
|
|
957
|
+
type RuntimeContext$2<ROut> = ExecutionContext | WorkerContext | WorkerEnvironment | ROut;
|
|
958
|
+
type QueueHandlerContext<ROut> = RuntimeContext$2<ROut> | Scope.Scope;
|
|
959
|
+
type QueueHandler<ROut, Body = unknown> = (batch: QueueBatch<Body>) => Effect.Effect<void, unknown, QueueHandlerContext<ROut>>;
|
|
960
|
+
interface QueueOptions<ROut, Body = unknown> {
|
|
961
|
+
readonly queue: QueueHandler<ROut, Body>;
|
|
978
962
|
}
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
readonly destroy: Effect.Effect<void, ContainerOperationError, R>;
|
|
988
|
-
readonly rawUnsafe: Effect.Effect<ContainerStub, ContainerOperationError, R>;
|
|
989
|
-
};
|
|
990
|
-
readonly rawUnsafe: Effect.Effect<ContainerNamespaceResource, never, R>;
|
|
991
|
-
};
|
|
992
|
-
type LayerOptions$12 = {
|
|
993
|
-
readonly binding: string;
|
|
963
|
+
declare const fromMessage: <Body>(message: globalThis.Message<unknown>, body: Body) => {
|
|
964
|
+
raw: Message<unknown>;
|
|
965
|
+
id: string;
|
|
966
|
+
timestamp: Date;
|
|
967
|
+
body: Body;
|
|
968
|
+
attempts: number;
|
|
969
|
+
ack: Effect.Effect<void, never, never>;
|
|
970
|
+
retry: (options?: globalThis.QueueRetryOptions) => Effect.Effect<void, never, never>;
|
|
994
971
|
};
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
declare const makeClient$9: (definition: ContainerNamespaceDefinition) => (namespace: ContainerNamespaceResource) => ContainerNamespaceClient;
|
|
1001
|
-
declare const layer$11: <Self>(tag: Context.Service<Self, ContainerNamespaceClient>, definition: ContainerNamespaceDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1002
|
-
declare const make$13: <Id extends string>(id: Id) => TagClass$11<ContainerNamespaceService<Id>, Id>;
|
|
1003
|
-
declare const ContainerNamespaceServiceTypeId: unique symbol;
|
|
1004
|
-
/** Nominal service marker for Container namespaces created with {@link make}. */
|
|
1005
|
-
interface ContainerNamespaceService<Id extends string> {
|
|
1006
|
-
readonly [ContainerNamespaceServiceTypeId]: {
|
|
1007
|
-
readonly id: Id;
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
/** Creates a typed Effect service for a Cloudflare Container namespace. */
|
|
1011
|
-
declare const Tag$12: <Self>() => <Id extends string>(id: Id) => TagClass$11<Self, Id>;
|
|
1012
|
-
declare const ContainerNamespace: typeof Tag$12;
|
|
1013
|
-
declare namespace D1_d_exports {
|
|
1014
|
-
export { D1Definition, D1Service, D1SqlLayerOptions, Service$1 as Service, TypeId$2 as TypeId, make$12 as make };
|
|
972
|
+
declare const fromMessageBatch: <Body>(batch: globalThis.MessageBatch<unknown>, messages: ReadonlyArray<QueueMessage<Body>>) => QueueBatch<Body>;
|
|
973
|
+
declare const decodeBatch: <Body>(batch: globalThis.MessageBatch<unknown>, decodeBody: (body: unknown) => Effect.Effect<Body, unknown>) => Effect.Effect<QueueBatch<Body>, QueueMessageDecodeError>;
|
|
974
|
+
type Definition$5<Id extends string = string, Message extends Definition$6.Any["message"] = Definition$6.Any["message"]> = Definition$6<Id, Message>;
|
|
975
|
+
declare namespace Definition$5 {
|
|
976
|
+
type Any = Definition$6.Any;
|
|
1015
977
|
}
|
|
1016
|
-
|
|
1017
|
-
type
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
978
|
+
type LayerOptions$12 = LayerOptions$13;
|
|
979
|
+
type TagClass$10<Self, Id extends string, Message extends Definition$6.Any["message"]> = TagClass$11<Self, Id, Message>;
|
|
980
|
+
declare const Tag$11: <Self>() => <Id extends string, Message extends Definition$6.Any["message"]>(id: Id, definition: {
|
|
981
|
+
readonly message: Message;
|
|
982
|
+
}) => TagClass$10<Self, Id, Message>;
|
|
983
|
+
declare const implement$4: typeof implement$5;
|
|
984
|
+
type Handler$2<ROut, Self extends Definition$6.Any> = Handler$3<ROut, Self>;
|
|
985
|
+
type Options$4<ROut, Self extends Definition$6.Any> = Options$5<ROut, Self>;
|
|
986
|
+
//#endregion
|
|
987
|
+
//#region src/internal/RpcInvocation.d.ts
|
|
988
|
+
type AnyArgs = Array<any>;
|
|
989
|
+
type AsyncMethodKey<Api> = { [Key in keyof Api]-?: Key extends string ? Api[Key] extends ((...args: AnyArgs) => Promise<unknown>) ? Key : never : never; }[keyof Api];
|
|
990
|
+
type AsyncMethodArgs<Api, Method extends keyof Api> = Api[Method] extends ((...args: infer Args) => Promise<unknown>) ? Args : never;
|
|
991
|
+
type AsyncMethodSuccess<Api, Method extends keyof Api> = Api[Method] extends ((...args: AnyArgs) => Promise<infer A>) ? A : never;
|
|
992
|
+
type AsyncMethodCloudflareReturn<Api, Method extends keyof Api> = Result$1<AsyncMethodSuccess<Api, Method>>;
|
|
993
|
+
declare namespace ServiceBinding_d_exports {
|
|
994
|
+
export { Service$1 as Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer$11 as layer, makeClient$8 as makeClient, makeDirectMethods$1 as makeDirectMethods };
|
|
1022
995
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
interface
|
|
1028
|
-
|
|
1029
|
-
readonly id: Id;
|
|
1030
|
-
};
|
|
996
|
+
declare const TypeId$2: "effect-cf/ServiceBinding";
|
|
997
|
+
/**
|
|
998
|
+
* Minimum shape for a Cloudflare service binding.
|
|
999
|
+
*/
|
|
1000
|
+
interface ServiceFetcher {
|
|
1001
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
1031
1002
|
}
|
|
1003
|
+
type RpcClient$1<Api> = { readonly [Key in keyof Api as Key extends string ? Api[Key] extends ((...args: Array<any>) => unknown) ? Key : never : never]: Api[Key]; };
|
|
1004
|
+
type ReservedMethodName$4 = ReservedMethodName$3 | "fetch";
|
|
1032
1005
|
/**
|
|
1033
|
-
*
|
|
1006
|
+
* Native Cloudflare service object including optional RPC methods.
|
|
1034
1007
|
*/
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer<D1Client.D1Client | SqlClient.SqlClient, Config.ConfigError | BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1039
|
-
};
|
|
1008
|
+
type ServiceBindingClient<Api extends object> = ServiceFetcher & RpcClient$1<Provider<Api, ReservedMethodName$4>>;
|
|
1009
|
+
type ApiFromDefinition<Definition> = Definition extends Definition$4.Any ? ServerApi$2<Definition> : never;
|
|
1010
|
+
type ApiOrDefinition<Api extends object, Definition> = [Api] extends [never] ? ApiFromDefinition<Definition> : Api;
|
|
1040
1011
|
/**
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
* The returned service exposes the raw `D1Database` binding and `sqlLayer(...)`
|
|
1044
|
-
* for providing `effect/unstable/sql` via `@effect/sql-d1`.
|
|
1045
|
-
*
|
|
1046
|
-
* @example
|
|
1047
|
-
* ```ts
|
|
1048
|
-
* class TodoDatabase extends D1.Service<TodoDatabase>()("TodoDatabase", {
|
|
1049
|
-
* binding: "TODO_DB",
|
|
1050
|
-
* }) {}
|
|
1051
|
-
*
|
|
1052
|
-
* const SqlLive = TodoDatabase.sqlLayer();
|
|
1053
|
-
* ```
|
|
1012
|
+
* Binding metadata used to create an Effect service from a Worker binding.
|
|
1054
1013
|
*/
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
declare namespace Rpc_d_exports {
|
|
1061
|
-
export { DisposableValue, MethodArgs, MethodKey, MethodReturn, Provider, Result$1 as Result, RpcStub, RpcTarget, Serializable, Stub, Stubable, Stubify, dispose, isDisposable, resolve, scoped };
|
|
1062
|
-
}
|
|
1063
|
-
type Stubable = Rpc.Stubable;
|
|
1064
|
-
type Stub<T extends Stubable> = Rpc.Stub<T>;
|
|
1065
|
-
type Provider<T extends object, Reserved extends string = never> = Rpc.Provider<T, Reserved>;
|
|
1066
|
-
type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
|
|
1067
|
-
type Serializable<T> = BaseType | Map<T extends Map<infer Key, unknown> ? Serializable<Key> : never, T extends Map<unknown, infer Value> ? Serializable<Value> : never> | Set<T extends Set<infer Value> ? Serializable<Value> : never> | ReadonlyArray<T extends ReadonlyArray<infer Value> ? Serializable<Value> : never> | { [Key in keyof T]: Key extends number | string ? Serializable<T[Key]> : never; } | Stub<Stubable> | Stubable;
|
|
1068
|
-
type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer Key, infer Value> ? Map<Stubify<Key>, Stubify<Value>> : T extends Set<infer Value> ? Set<Stubify<Value>> : T extends Array<infer Value> ? Array<Stubify<Value>> : T extends ReadonlyArray<infer Value> ? ReadonlyArray<Stubify<Value>> : T extends BaseType ? T : T extends {
|
|
1069
|
-
[key: string | number]: unknown;
|
|
1070
|
-
} ? { [Key in keyof T]: Stubify<T[Key]>; } : T;
|
|
1071
|
-
type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
|
|
1072
|
-
type MaybeDisposable<T> = T extends object ? Disposable : unknown;
|
|
1073
|
-
type Result$1<T> = T extends Stubable ? Promise<Stub<T>> & Provider<T> : T extends Serializable<T> ? Promise<Stubify<T> & MaybeDisposable<T>> & MaybeProvider<T> : never;
|
|
1074
|
-
type MethodKey<Api> = { [Key in keyof Api]-?: Key extends string ? Api[Key] extends ((...args: Array<any>) => unknown) ? Key : never : never; }[keyof Api];
|
|
1075
|
-
type MethodArgs<Api, Method extends keyof Api> = Api[Method] extends ((...args: infer Args) => unknown) ? Args : never;
|
|
1076
|
-
type MethodReturn<Api, Method extends keyof Api> = Api[Method] extends ((...args: Array<any>) => infer Return) ? Return : never;
|
|
1077
|
-
type DisposableValue = {
|
|
1078
|
-
[Symbol.dispose](): void;
|
|
1079
|
-
};
|
|
1080
|
-
declare const isDisposable: (value: unknown) => value is DisposableValue;
|
|
1081
|
-
declare const dispose: (value: unknown) => Effect.Effect<void>;
|
|
1082
|
-
declare const resolve: <A>(value: A) => Effect.Effect<Awaited<A>, unknown>;
|
|
1083
|
-
declare const scoped: <A>(value: A) => Effect.Effect<Awaited<A>, unknown, Scope.Scope>;
|
|
1084
|
-
declare namespace RpcDefinition_d_exports {
|
|
1085
|
-
export { Definition$7 as Definition, Method$3 as Method, Methods$2 as Methods, NoReservedMethods$2 as NoReservedMethods, ReservedMethodName$5 as ReservedMethodName, RpcArgumentCountError, RpcArgumentDecodeError, RpcArgumentEncodeError, RpcReservedMethodNameError, RpcSuccessDecodeError, RpcSuccessEncodeError, ServiceFreeSchema$2 as ServiceFreeSchema, WireError, assertNoReservedMethods, decodeArgs, decodeSuccess, decodeWireError, encodeArgs, encodeSuccess, encodeWireError, isWireError, make$11 as make, method$2 as method, reservedMethodNames };
|
|
1086
|
-
}
|
|
1087
|
-
declare const RpcReservedMethodNameError_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 & {
|
|
1088
|
-
readonly _tag: "RpcReservedMethodNameError";
|
|
1089
|
-
} & Readonly<A>;
|
|
1090
|
-
declare class RpcReservedMethodNameError extends RpcReservedMethodNameError_base<{
|
|
1091
|
-
readonly definition: string;
|
|
1092
|
-
readonly method: string;
|
|
1093
|
-
}> {
|
|
1094
|
-
get message(): string;
|
|
1095
|
-
}
|
|
1096
|
-
declare const RpcArgumentCountError_base: Schema.Class<RpcArgumentCountError, Schema.TaggedStruct<"RpcArgumentCountError", {
|
|
1097
|
-
readonly definition: Schema.String;
|
|
1098
|
-
readonly method: Schema.String;
|
|
1099
|
-
readonly expected: Schema.Number;
|
|
1100
|
-
readonly actual: Schema.Number;
|
|
1101
|
-
}>, import("effect/Cause").YieldableError>;
|
|
1102
|
-
declare class RpcArgumentCountError extends RpcArgumentCountError_base {
|
|
1103
|
-
get message(): string;
|
|
1104
|
-
}
|
|
1105
|
-
declare const RpcArgumentDecodeError_base: Schema.Class<RpcArgumentDecodeError, Schema.TaggedStruct<"RpcArgumentDecodeError", {
|
|
1106
|
-
readonly definition: Schema.String;
|
|
1107
|
-
readonly method: Schema.String;
|
|
1108
|
-
readonly cause: Schema.Defect;
|
|
1109
|
-
}>, import("effect/Cause").YieldableError>;
|
|
1110
|
-
declare class RpcArgumentDecodeError extends RpcArgumentDecodeError_base {
|
|
1111
|
-
get message(): string;
|
|
1014
|
+
interface ServiceBindingDefinition<Definition extends Definition$4.Any | undefined = undefined> {
|
|
1015
|
+
/** Binding name as configured in `wrangler.jsonc`. */
|
|
1016
|
+
readonly binding: string;
|
|
1017
|
+
/** Optional RPC schema used for argument/result encoding. */
|
|
1018
|
+
readonly definition?: Definition;
|
|
1112
1019
|
}
|
|
1113
|
-
declare const
|
|
1114
|
-
readonly _tag: "
|
|
1020
|
+
declare const ServiceBindingFetchError_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 & {
|
|
1021
|
+
readonly _tag: "ServiceBindingFetchError";
|
|
1115
1022
|
} & Readonly<A>;
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1023
|
+
/**
|
|
1024
|
+
* Failure raised when calling `fetch` on a service binding.
|
|
1025
|
+
*/
|
|
1026
|
+
declare class ServiceBindingFetchError extends ServiceBindingFetchError_base<{
|
|
1027
|
+
readonly binding: string;
|
|
1119
1028
|
readonly cause: unknown;
|
|
1120
1029
|
}> {
|
|
1121
1030
|
get message(): string;
|
|
1122
1031
|
}
|
|
1123
|
-
declare const
|
|
1124
|
-
readonly _tag: "
|
|
1032
|
+
declare const ServiceBindingRpcError_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 & {
|
|
1033
|
+
readonly _tag: "ServiceBindingRpcError";
|
|
1125
1034
|
} & Readonly<A>;
|
|
1126
|
-
|
|
1127
|
-
|
|
1035
|
+
/**
|
|
1036
|
+
* Failure raised when invoking an RPC method on a service binding.
|
|
1037
|
+
*/
|
|
1038
|
+
declare class ServiceBindingRpcError extends ServiceBindingRpcError_base<{
|
|
1039
|
+
readonly binding: string;
|
|
1128
1040
|
readonly method: string;
|
|
1129
1041
|
readonly cause: unknown;
|
|
1130
1042
|
}> {
|
|
1131
1043
|
get message(): string;
|
|
1132
1044
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
|
|
1143
|
-
|
|
1045
|
+
type ServiceMethodKey<Api> = AsyncMethodKey<Api>;
|
|
1046
|
+
type ServiceMethodArgs<Api, Method extends keyof Api> = AsyncMethodArgs<Api, Method>;
|
|
1047
|
+
type ServiceMethodSuccess<Api, Method extends keyof Api> = AsyncMethodSuccess<Api, Method>;
|
|
1048
|
+
type ServiceMethodCloudflareReturn<Api, Method extends keyof Api> = AsyncMethodCloudflareReturn<Api, Method>;
|
|
1049
|
+
type ServiceCall<R, Api> = <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
1050
|
+
type DefinitionDirectMethods<R, Definition extends Definition$4.Any> = { readonly [Method in Definition$7.MethodNames<Definition>]: (...args: Method$3.Args<Definition["methods"][Method]>) => Effect.Effect<Method$3.Success<Definition["methods"][Method]>, ServiceBindingRpcError, R>; };
|
|
1051
|
+
type DirectMethods$1<R, Definition> = Definition extends Definition$4.Any ? DefinitionDirectMethods<R, Definition> : {};
|
|
1052
|
+
type ServiceBindingEffectClient<Api extends object, Definition extends Definition$4.Any | undefined = undefined> = DirectMethods$1<never, Definition> & {
|
|
1053
|
+
/**
|
|
1054
|
+
* Forwards an HTTP request to the bound Worker service.
|
|
1055
|
+
*
|
|
1056
|
+
* Use this when the service binding is acting as an HTTP origin rather than a
|
|
1057
|
+
* Cloudflare RPC target.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```ts
|
|
1061
|
+
* import { Effect } from "effect";
|
|
1062
|
+
*
|
|
1063
|
+
* const program = Effect.gen(function* () {
|
|
1064
|
+
* const api = yield* ApiWorker;
|
|
1065
|
+
* return yield* api.fetch(new Request("https://internal.example/users"));
|
|
1066
|
+
* });
|
|
1067
|
+
* ```
|
|
1068
|
+
*/
|
|
1069
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Invokes a Worker RPC method and returns Cloudflare's raw RPC result.
|
|
1072
|
+
*
|
|
1073
|
+
* This preserves Cloudflare RPC behavior such as promise-like pipelining and
|
|
1074
|
+
* transferable / disposable result objects. It does not resolve the returned
|
|
1075
|
+
* promise-like value and it does not decode definition-backed success schemas.
|
|
1076
|
+
*
|
|
1077
|
+
* Most application code should use {@link call} instead.
|
|
1078
|
+
*
|
|
1079
|
+
* @example
|
|
1080
|
+
* ```ts
|
|
1081
|
+
* import { Effect } from "effect";
|
|
1082
|
+
*
|
|
1083
|
+
* const program = Effect.gen(function* () {
|
|
1084
|
+
* const counter = yield* CounterService;
|
|
1085
|
+
*
|
|
1086
|
+
* const result = yield* counter.rpc("increment", 41);
|
|
1087
|
+
* const value = yield* Effect.promise(() => result);
|
|
1088
|
+
*
|
|
1089
|
+
* return value;
|
|
1090
|
+
* });
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
readonly rpc: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodCloudflareReturn<Api, Method>, ServiceBindingRpcError>;
|
|
1094
|
+
/**
|
|
1095
|
+
* Invokes a Worker RPC method, resolves Cloudflare's RPC result, and decodes
|
|
1096
|
+
* the success value when the binding was created from a definition.
|
|
1097
|
+
*
|
|
1098
|
+
* This is the normal choice when application code wants the final typed value.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* import { Effect } from "effect";
|
|
1103
|
+
*
|
|
1104
|
+
* const program = Effect.gen(function* () {
|
|
1105
|
+
* const counter = yield* CounterService;
|
|
1106
|
+
* const value = yield* counter.call("increment", 41);
|
|
1107
|
+
*
|
|
1108
|
+
* return value;
|
|
1109
|
+
* });
|
|
1110
|
+
* ```
|
|
1111
|
+
*/
|
|
1112
|
+
readonly call: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Invokes a Worker RPC method in the current `Scope`, resolves Cloudflare's RPC
|
|
1115
|
+
* result, decodes definition-backed success values, and disposes the resolved
|
|
1116
|
+
* result when the scope closes if it implements `Symbol.dispose`.
|
|
1117
|
+
*
|
|
1118
|
+
* Use this for RPC methods that return Cloudflare RPC resources or other
|
|
1119
|
+
* disposable objects whose lifetime should be tied to an Effect scope.
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```ts
|
|
1123
|
+
* import { Effect } from "effect";
|
|
1124
|
+
*
|
|
1125
|
+
* const program = Effect.scoped(
|
|
1126
|
+
* Effect.gen(function* () {
|
|
1127
|
+
* const files = yield* FileService;
|
|
1128
|
+
* const handle = yield* files.scopedCall("open", "report.csv");
|
|
1129
|
+
*
|
|
1130
|
+
* return yield* handle.read();
|
|
1131
|
+
* }),
|
|
1132
|
+
* );
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, unknown, Scope.Scope>;
|
|
1136
|
+
};
|
|
1137
|
+
type ServiceBindingStaticClient<R, Api extends object, Definition extends Definition$4.Any | undefined = undefined> = DirectMethods$1<R, Definition> & {
|
|
1138
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError, R>;
|
|
1139
|
+
readonly rpc: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodCloudflareReturn<Api, Method>, ServiceBindingRpcError, R>;
|
|
1140
|
+
readonly call: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
1141
|
+
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, unknown, Scope.Scope | R>;
|
|
1142
|
+
};
|
|
1143
|
+
declare const isServiceBindingClient: <Api extends object>(value: unknown) => value is ServiceBindingClient<Api>;
|
|
1144
|
+
declare const makeClient$8: <Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition>);
|
|
1145
|
+
declare const layer$11: <Self, Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition>>, definition: ServiceBindingDefinition<Definition>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1144
1146
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
+
* Creates a typed Effect service for a Worker service binding.
|
|
1148
|
+
*
|
|
1149
|
+
* Returned value includes:
|
|
1150
|
+
* - a Context tag for dependency injection
|
|
1151
|
+
* - `fetch(...)` for raw HTTP forwarding
|
|
1152
|
+
* - `rpc(...)` for raw Cloudflare RPC results
|
|
1153
|
+
* - `call(...)` for resolved and decoded RPC results
|
|
1154
|
+
* - `scopedCall(...)` for scoped and decoded disposable RPC results
|
|
1155
|
+
* - direct RPC methods when `definition` is provided
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```ts
|
|
1159
|
+
* const Counter = WorkerDefinition.make("Counter", {
|
|
1160
|
+
* increment: WorkerDefinition.method({
|
|
1161
|
+
* args: [Schema.Number],
|
|
1162
|
+
* success: Schema.Number,
|
|
1163
|
+
* }),
|
|
1164
|
+
* });
|
|
1165
|
+
*
|
|
1166
|
+
* const CounterLive = Counter.layer({ binding: "COUNTER" });
|
|
1167
|
+
*
|
|
1168
|
+
* const program = Effect.gen(function* () {
|
|
1169
|
+
* const counter = yield* Counter;
|
|
1170
|
+
* const next = yield* counter.increment(1);
|
|
1171
|
+
* return next;
|
|
1172
|
+
* });
|
|
1173
|
+
* ```
|
|
1147
1174
|
*/
|
|
1148
|
-
declare const
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1175
|
+
declare const Service$1: <Self, Api extends object = never>() => <Id extends string, const Definition extends Definition$4.Any | undefined = undefined>(id: Id, definition: ServiceBindingDefinition<Definition>) => BindingService<Self, Id, ServiceBindingEffectClient<ApiOrDefinition<Api, Definition>, Definition>> & DirectMethods$1<Self, Definition> & {
|
|
1176
|
+
readonly [TypeId$2]: typeof TypeId$2;
|
|
1177
|
+
readonly definition: ServiceBindingDefinition<Definition>;
|
|
1178
|
+
readonly fetch: (input: URL | RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined) => Effect.Effect<Response, ServiceBindingFetchError, Self>;
|
|
1179
|
+
readonly rpc: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<Result$1<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>>, ServiceBindingRpcError, Self>;
|
|
1180
|
+
readonly call: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>, ServiceBindingRpcError, Self>;
|
|
1181
|
+
readonly scopedCall: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<Awaited<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>>, unknown, Self | Scope.Scope>;
|
|
1182
|
+
};
|
|
1183
|
+
declare const makeDirectMethods$1: <R, Api, Definition extends Definition$4.Any | undefined>(rpcDefinition: Definition | undefined, call: ServiceCall<R, Api>) => DirectMethods$1<R, Definition>;
|
|
1184
|
+
declare namespace WorkerDefinition_d_exports {
|
|
1185
|
+
export { Api$1 as Api, Definition$4 as Definition, HandlerEffect$1 as HandlerEffect, Handlers$1 as Handlers, LayerOptions$11 as LayerOptions, Method$2 as Method, Methods$1 as Methods, NoReservedMethods$1 as NoReservedMethods, Options$3 as Options, ReservedMethodName$3 as ReservedMethodName, ServerApi$2 as ServerApi, ServiceFreeSchema$1 as ServiceFreeSchema, Tag$10 as Tag, TagClass$9 as TagClass, Worker, implement$3 as implement, make$11 as make, method$1 as method };
|
|
1186
|
+
}
|
|
1187
|
+
type ServiceFreeSchema$1 = Schema.Codec<any, any, never, never>;
|
|
1188
|
+
interface Method$2<Args extends ReadonlyArray<ServiceFreeSchema$1> = ReadonlyArray<ServiceFreeSchema$1>, Success extends ServiceFreeSchema$1 = ServiceFreeSchema$1> {
|
|
1155
1189
|
readonly args: Args;
|
|
1156
1190
|
readonly success: Success;
|
|
1157
1191
|
}
|
|
1158
|
-
declare namespace Method$
|
|
1159
|
-
export type Any = Method$
|
|
1160
|
-
type ArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$
|
|
1192
|
+
declare namespace Method$2 {
|
|
1193
|
+
export type Any = Method$2<ReadonlyArray<ServiceFreeSchema$1>, ServiceFreeSchema$1>;
|
|
1194
|
+
type ArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$1>> = Args extends readonly [] ? [] : Args extends readonly [infer Head extends ServiceFreeSchema$1, ...infer Tail extends ReadonlyArray<ServiceFreeSchema$1>] ? [Schema.Schema.Type<Head>, ...ArgsFromSchemas<Tail>] : Array<Schema.Schema.Type<Args[number]>>;
|
|
1161
1195
|
/** Method schemas cross the wire through their canonical JSON codec. */
|
|
1162
|
-
type EncodedArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$
|
|
1196
|
+
type EncodedArgsFromSchemas<Args extends ReadonlyArray<ServiceFreeSchema$1>> = { [Index in keyof Args]: Schema.Json; };
|
|
1163
1197
|
export type Args<Self extends Any> = ArgsFromSchemas<Self["args"]>;
|
|
1164
1198
|
export type EncodedArgs<Self extends Any> = EncodedArgsFromSchemas<Self["args"]>;
|
|
1165
1199
|
export type Success<Self extends Any> = Schema.Schema.Type<Self["success"]>;
|
|
1166
1200
|
export type EncodedSuccess<Self extends Any> = Schema.Json;
|
|
1167
1201
|
export {};
|
|
1168
1202
|
}
|
|
1169
|
-
type Methods$
|
|
1170
|
-
|
|
1171
|
-
|
|
1203
|
+
type Methods$1 = Record<string, Method$2.Any>;
|
|
1204
|
+
/**
|
|
1205
|
+
* RPC contract for a Worker service.
|
|
1206
|
+
*
|
|
1207
|
+
* Create with {@link make} and reuse to type both worker implementations and
|
|
1208
|
+
* service bindings in other workers.
|
|
1209
|
+
*/
|
|
1210
|
+
interface Definition$4<Id extends string = string, MethodsShape extends Methods$1 = Methods$1> {
|
|
1172
1211
|
readonly id: Id;
|
|
1173
1212
|
readonly methods: MethodsShape;
|
|
1174
1213
|
}
|
|
1175
|
-
declare namespace Definition$
|
|
1176
|
-
type Any = Definition$
|
|
1177
|
-
type ServerApi<Self extends Any> = { readonly [Key in keyof Self["methods"]]: (...args: Method$3.Args<Self["methods"][Key]>) => Promise<Method$3.Success<Self["methods"][Key]>>; };
|
|
1178
|
-
type Api<Self extends Any, Reserved extends string = never> = Provider<ServerApi<Self>, Reserved>;
|
|
1179
|
-
type MethodNames<Self extends Any> = Extract<keyof Self["methods"], string>;
|
|
1180
|
-
}
|
|
1181
|
-
declare const assertNoReservedMethods: (target: string, methods: Record<string, unknown>, reserved: ReadonlySet<string>) => void;
|
|
1182
|
-
declare function method$2<Success extends ServiceFreeSchema$2>(definition: {
|
|
1183
|
-
readonly success: Success;
|
|
1184
|
-
}): Method$3<readonly [], Success>;
|
|
1185
|
-
declare function method$2<const Args extends ReadonlyArray<ServiceFreeSchema$2>, Success extends ServiceFreeSchema$2>(definition: {
|
|
1186
|
-
readonly args: Args;
|
|
1187
|
-
readonly success: Success;
|
|
1188
|
-
}): Method$3<Args, Success>;
|
|
1189
|
-
declare const decodeArgs: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, args: readonly unknown[]) => Effect.Effect<Self["methods"][MethodName]["args"] extends (infer T) ? T extends Self["methods"][MethodName]["args"] ? T extends readonly [] ? [] : T extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ... /*elided*/ any] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<T[number]>[] : never : never, RpcArgumentCountError | RpcArgumentDecodeError, never>;
|
|
1190
|
-
declare const encodeArgs: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, args: Self["methods"][MethodName]["args"] extends (infer T) ? T extends Self["methods"][MethodName]["args"] ? T extends readonly [] ? [] : T extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ...Tail extends readonly [] ? [] : Tail extends readonly [infer Head extends ServiceFreeSchema$2, ...infer Tail extends readonly ServiceFreeSchema$2[]] ? [Schema.Schema.Type<Head>, ... /*elided*/ any] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<Tail[number]>[]] : Schema.Schema.Type<T[number]>[] : never : never) => Effect.Effect<Self["methods"][MethodName]["args"] extends (infer T_1 extends readonly ServiceFreeSchema$2[]) ? { [Index in keyof T_1]: Schema.Json; } : never, RpcArgumentCountError | RpcArgumentEncodeError, never>;
|
|
1191
|
-
declare const encodeSuccess: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, value: Method$3.Success<Self["methods"][MethodName]>) => Effect.Effect<Method$3.EncodedSuccess<Self["methods"][MethodName]>, RpcSuccessEncodeError>;
|
|
1192
|
-
declare const decodeSuccess: <const Self extends Definition$7.Any, MethodName extends Definition$7.MethodNames<Self>>(definition: Self, methodName: MethodName, value: unknown) => Effect.Effect<Method$3.Success<Self["methods"][MethodName]>, RpcSuccessDecodeError>;
|
|
1193
|
-
declare const make$11: <Id extends string, const MethodsShape extends Methods$2>(id: Id, methods: MethodsShape) => Definition$7<Id, MethodsShape>;
|
|
1194
|
-
declare namespace QueueBinding_d_exports {
|
|
1195
|
-
export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$10 as layer, makeClient$8 as makeClient };
|
|
1196
|
-
}
|
|
1197
|
-
type QueueSendOptions = CloudflareQueueSendOptions;
|
|
1198
|
-
type QueueSendResponse = CloudflareQueueSendResponse;
|
|
1199
|
-
type QueueSendBatchOptions = CloudflareQueueSendBatchOptions;
|
|
1200
|
-
type QueueSendBatchResponse = CloudflareQueueSendBatchResponse;
|
|
1201
|
-
type QueueMetrics = CloudflareQueueMetrics;
|
|
1202
|
-
type MessageSendRequest<Body> = CloudflareMessageSendRequest<Body>;
|
|
1203
|
-
type QueueProducer<Body> = Pick<CloudflareQueue<Body>, "send"> & Partial<Pick<CloudflareQueue<Body>, "sendBatch" | "metrics">>;
|
|
1204
|
-
interface QueueBindingDefinition<Message extends ServiceFreeSchema$2> {
|
|
1205
|
-
/** Binding name as configured in `wrangler.jsonc`. */
|
|
1206
|
-
readonly binding: string;
|
|
1207
|
-
/** Codec used to encode messages before sending them to Cloudflare Queues. */
|
|
1208
|
-
readonly message: Message;
|
|
1209
|
-
}
|
|
1210
|
-
interface QueueBindingClient<Message extends ServiceFreeSchema$2> {
|
|
1211
|
-
readonly send: (message: Schema.Schema.Type<Message>, options?: QueueSendOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError>;
|
|
1212
|
-
readonly sendBatch: (messages: Iterable<MessageSendRequest<Schema.Schema.Type<Message>>>, options?: QueueSendBatchOptions) => Effect.Effect<void, QueueOperationError | Schema.SchemaError>;
|
|
1213
|
-
readonly metrics: () => Effect.Effect<QueueMetrics, QueueOperationError>;
|
|
1214
|
-
readonly rawUnsafe: Effect.Effect<CloudflareQueue<Schema.Codec.Encoded<Message>>>;
|
|
1215
|
-
}
|
|
1216
|
-
declare const QueueOperationError_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 & {
|
|
1217
|
-
readonly _tag: "QueueOperationError";
|
|
1218
|
-
} & Readonly<A>;
|
|
1219
|
-
declare class QueueOperationError extends QueueOperationError_base<{
|
|
1220
|
-
readonly binding: string;
|
|
1221
|
-
readonly operation: string;
|
|
1222
|
-
readonly cause: unknown;
|
|
1223
|
-
readonly message: string;
|
|
1224
|
-
}> {}
|
|
1225
|
-
declare const isQueue: <Body>(value: unknown) => value is QueueProducer<Body>;
|
|
1226
|
-
declare const makeClient$8: <Message extends ServiceFreeSchema$2>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<Schema.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
|
|
1227
|
-
declare const layer$10: <Self, Message extends ServiceFreeSchema$2>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1228
|
-
declare namespace QueueDefinition_d_exports {
|
|
1229
|
-
export { Definition$6 as Definition, Handler$3 as Handler, LayerOptions$11 as LayerOptions, Options$5 as Options, Queue$1 as Queue, Tag$11 as Tag, TagClass$10 as TagClass, implement$5 as implement, make$10 as make };
|
|
1230
|
-
}
|
|
1231
|
-
interface Definition$6<Id extends string = string, Message extends ServiceFreeSchema$2 = ServiceFreeSchema$2> {
|
|
1232
|
-
readonly id: Id;
|
|
1233
|
-
readonly message: Message;
|
|
1234
|
-
}
|
|
1235
|
-
declare namespace Definition$6 {
|
|
1236
|
-
type Any = Definition$6<string, ServiceFreeSchema$2>;
|
|
1214
|
+
declare namespace Definition$4 {
|
|
1215
|
+
type Any = Definition$4<string, Methods$1>;
|
|
1237
1216
|
}
|
|
1238
|
-
type
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1217
|
+
type ReservedMethodName$3 = ReservedMethodName$2;
|
|
1218
|
+
type NoReservedMethods$1<MethodsShape extends Methods$1> = Extract<keyof MethodsShape, ReservedMethodName$3> extends never ? MethodsShape : never;
|
|
1219
|
+
/**
|
|
1220
|
+
* Promise-based client API derived from a {@link Definition}.
|
|
1221
|
+
*/
|
|
1222
|
+
type ServerApi$2<Self extends Definition$4.Any> = { readonly [Key in keyof Self["methods"]]: (...args: Method$2.Args<Self["methods"][Key]>) => Promise<Method$2.Success<Self["methods"][Key]>>; };
|
|
1223
|
+
type Api$1<Self extends Definition$4.Any> = Provider<ServerApi$2<Self>, ReservedMethodName$3>;
|
|
1224
|
+
/**
|
|
1225
|
+
* Effect handlers for each RPC method in a worker definition.
|
|
1226
|
+
*/
|
|
1227
|
+
type Handlers$1<ROut, Self extends Definition$4.Any> = { readonly [Key in keyof Self["methods"]]: (...args: Method$2.Args<Self["methods"][Key]>) => WorkerRpcHandler<ROut, Method$2.Success<Self["methods"][Key]>>; };
|
|
1228
|
+
/**
|
|
1229
|
+
* Worker constructor options for a specific RPC definition.
|
|
1230
|
+
*/
|
|
1231
|
+
interface Options$3<ROut, Self extends Definition$4.Any, REvent = never, EventLayerError = never> extends Omit<WorkerOptions<ROut, REvent, EventLayerError, Handlers$1<ROut | REvent, Self>>, "rpc"> {
|
|
1232
|
+
readonly rpc: Handlers$1<ROut | REvent, Self>;
|
|
1242
1233
|
}
|
|
1243
1234
|
type LayerOptions$11 = {
|
|
1244
1235
|
readonly binding: string;
|
|
1245
1236
|
};
|
|
1246
|
-
|
|
1237
|
+
type TagClass$9<Self, Id extends string, MethodsShape extends Methods$1> = Context.ServiceClass<Self, Id, ServiceBindingEffectClient<Api$1<Definition$4<Id, MethodsShape>>, Definition$4<Id, MethodsShape>>> & ServiceBindingStaticClient<Self, Api$1<Definition$4<Id, MethodsShape>>, Definition$4<Id, MethodsShape>> & {
|
|
1247
1238
|
readonly id: Id;
|
|
1248
|
-
readonly
|
|
1249
|
-
readonly make: <ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: Options$
|
|
1239
|
+
readonly methods: MethodsShape;
|
|
1240
|
+
readonly make: <ROut, LayerError, REvent = never, EventLayerError = never>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: Options$3<ROut, Definition$4<Id, MethodsShape>, REvent, EventLayerError>) => WorkerClass<Handlers$1<ROut | REvent, Definition$4<Id, MethodsShape>>, ROut | REvent>;
|
|
1250
1241
|
readonly layer: (options: LayerOptions$11) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
})
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
declare
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
readonly raw: globalThis.MessageBatch<unknown>;
|
|
1278
|
-
readonly messages: ReadonlyArray<QueueMessage<Body>>;
|
|
1279
|
-
readonly queue: string;
|
|
1280
|
-
readonly metadata: globalThis.MessageBatchMetadata;
|
|
1281
|
-
readonly ackAll: Effect.Effect<void>;
|
|
1282
|
-
readonly retryAll: (options?: globalThis.QueueRetryOptions) => Effect.Effect<void>;
|
|
1283
|
-
}
|
|
1284
|
-
declare const QueueMessageDecodeError_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 & {
|
|
1285
|
-
readonly _tag: "QueueMessageDecodeError";
|
|
1286
|
-
} & Readonly<A>;
|
|
1287
|
-
declare class QueueMessageDecodeError extends QueueMessageDecodeError_base<{
|
|
1288
|
-
readonly queue: string;
|
|
1289
|
-
readonly messageId: string;
|
|
1290
|
-
readonly index: number;
|
|
1291
|
-
readonly cause: unknown;
|
|
1292
|
-
}> {
|
|
1293
|
-
get message(): string;
|
|
1242
|
+
};
|
|
1243
|
+
/**
|
|
1244
|
+
* Defines a single RPC method schema in a worker definition.
|
|
1245
|
+
*/
|
|
1246
|
+
declare const method$1: {
|
|
1247
|
+
<Success extends ServiceFreeSchema$1>(definition: {
|
|
1248
|
+
readonly success: Success;
|
|
1249
|
+
}): Method$2<readonly [], Success>;
|
|
1250
|
+
<const Args extends ReadonlyArray<ServiceFreeSchema$1>, Success extends ServiceFreeSchema$1>(definition: {
|
|
1251
|
+
readonly args: Args;
|
|
1252
|
+
readonly success: Success;
|
|
1253
|
+
}): Method$2<Args, Success>;
|
|
1254
|
+
};
|
|
1255
|
+
declare const make$11: <Id extends string, const MethodsShape extends Methods$1>(id: Id, methods: MethodsShape & NoReservedMethods$1<MethodsShape>) => TagClass$9<Definition$4<Id, MethodsShape>, Id, MethodsShape>;
|
|
1256
|
+
declare const Tag$10: <Self>() => <Id extends string, const MethodsShape extends Methods$1>(id: Id, methods: MethodsShape & NoReservedMethods$1<MethodsShape>) => TagClass$9<Self, Id, MethodsShape>;
|
|
1257
|
+
declare const Worker: typeof Tag$10;
|
|
1258
|
+
/**
|
|
1259
|
+
* Helper for implementing handlers with the exact method shape of a definition.
|
|
1260
|
+
*/
|
|
1261
|
+
declare const implement$3: <ROut, const Self extends Definition$4.Any>(_definition: Self, handlers: Handlers$1<ROut, Self>) => Handlers$1<ROut, Self>;
|
|
1262
|
+
/**
|
|
1263
|
+
* Convenience alias for a single worker RPC handler Effect.
|
|
1264
|
+
*/
|
|
1265
|
+
type HandlerEffect$1<ROut, Self extends Definition$4.Any, Key extends keyof Self["methods"]> = WorkerRpcHandler<ROut, Method$2.Success<Self["methods"][Key]>>;
|
|
1266
|
+
declare namespace Worker_d_exports {
|
|
1267
|
+
export { Api$1 as Api, Definition$4 as Definition, ExecutionContext, FetchHandler, FetchWorkerOptions, HandlerEffect$1 as HandlerEffect, Handlers$1 as Handlers, LayerOptions$11 as LayerOptions, Method$2 as Method, Methods$1 as Methods, NativeRequest, NoReservedMethods$1 as NoReservedMethods, Options$3 as Options, ReservedMethodName$2 as ReservedMethodName, RpcHandlers$1 as RpcHandlers, ServerApi$2 as ServerApi, ServiceFreeSchema$1 as ServiceFreeSchema, Tag$10 as Tag, TagClass$9 as TagClass, WorkerClass, WorkerContext, WorkerContextService, WorkerContextWaitUntilOptions, WorkerFetchSuccess, WorkerHandler, WorkerOptions, WorkerRpc, WorkerRpcHandler, WorkerRpcShape, implement$3 as implement, isWebSocketUpgrade, make$10 as make, makeFetchHandler, method$1 as method };
|
|
1294
1268
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1269
|
+
declare const ExecutionContext_base: Context.ServiceClass<ExecutionContext, "effect-cf/ExecutionContext", globalThis.ExecutionContext<unknown>>;
|
|
1270
|
+
/**
|
|
1271
|
+
* Access to Cloudflare's native `ExecutionContext`.
|
|
1272
|
+
*/
|
|
1273
|
+
declare class ExecutionContext extends ExecutionContext_base {}
|
|
1274
|
+
/**
|
|
1275
|
+
* Options for {@link WorkerContextService.waitUntil}.
|
|
1276
|
+
*/
|
|
1277
|
+
interface WorkerContextWaitUntilOptions<E, R> {
|
|
1278
|
+
/**
|
|
1279
|
+
* Failure mode for the background effect: `"observe"` (default) logs or
|
|
1280
|
+
* routes the failure to `onFailure`, while `"propagate"` also rejects the
|
|
1281
|
+
* native `waitUntil` promise.
|
|
1282
|
+
*/
|
|
1283
|
+
readonly mode?: "observe" | "propagate";
|
|
1284
|
+
/** Custom failure handler for the background effect. */
|
|
1285
|
+
readonly onFailure?: (cause: Cause.Cause<E>) => Effect.Effect<void, never, R>;
|
|
1300
1286
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
};
|
|
1310
|
-
declare const fromMessageBatch: <Body>(batch: globalThis.MessageBatch<unknown>, messages: ReadonlyArray<QueueMessage<Body>>) => QueueBatch<Body>;
|
|
1311
|
-
declare const decodeBatch: <Body>(batch: globalThis.MessageBatch<unknown>, decodeBody: (body: unknown) => Effect.Effect<Body, unknown>) => Effect.Effect<QueueBatch<Body>, QueueMessageDecodeError>;
|
|
1312
|
-
type Definition$5<Id extends string = string, Message extends Definition$6.Any["message"] = Definition$6.Any["message"]> = Definition$6<Id, Message>;
|
|
1313
|
-
declare namespace Definition$5 {
|
|
1314
|
-
type Any = Definition$6.Any;
|
|
1287
|
+
/**
|
|
1288
|
+
* Effect wrapper around `ExecutionContext` background APIs.
|
|
1289
|
+
*/
|
|
1290
|
+
interface WorkerContextService {
|
|
1291
|
+
readonly raw: globalThis.ExecutionContext;
|
|
1292
|
+
waitUntil<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: WorkerContextWaitUntilOptions<E, R2>): Effect.Effect<void, never, R | R2>;
|
|
1293
|
+
waitUntilPropagating<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: Omit<WorkerContextWaitUntilOptions<E, R2>, "mode">): Effect.Effect<void, never, R | R2>;
|
|
1294
|
+
readonly passThroughOnException: Effect.Effect<void>;
|
|
1315
1295
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1296
|
+
declare const WorkerContext_base: Context.ServiceClass<WorkerContext, "effect-cf/WorkerContext", WorkerContextService>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Service used inside handlers to schedule background work via `waitUntil`.
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
* ```ts
|
|
1302
|
+
* const handler = Effect.gen(function* () {
|
|
1303
|
+
* const ctx = yield* Worker.WorkerContext;
|
|
1304
|
+
* yield* ctx.waitUntil(Effect.log("flush analytics"));
|
|
1305
|
+
* return new Response("ok");
|
|
1306
|
+
* });
|
|
1307
|
+
* ```
|
|
1308
|
+
*/
|
|
1309
|
+
declare class WorkerContext extends WorkerContext_base {}
|
|
1310
|
+
declare const NativeRequest_base: Context.ServiceClass<NativeRequest, "effect-cf/NativeRequest", Request<unknown, CfProperties<unknown>>>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Access to the incoming `Request` currently handled by a worker or Durable Object fetch.
|
|
1313
|
+
*/
|
|
1314
|
+
declare class NativeRequest extends NativeRequest_base {}
|
|
1315
|
+
/**
|
|
1316
|
+
* Returns `true` when the request is a websocket upgrade request.
|
|
1317
|
+
*/
|
|
1318
|
+
declare const isWebSocketUpgrade: (request: Request) => boolean;
|
|
1319
|
+
type ReservedMethodName$2 = ReservedMethodName$5 | "fetch" | "connect" | "queue" | "scheduled" | "tail" | "tailStream" | "test" | "trace" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError";
|
|
1320
|
+
type WorkerBaseContext<ROut> = ExecutionContext | WorkerContext | WorkerEnvironment | ROut;
|
|
1321
|
+
type WorkerFetchContext<ROut> = WorkerBaseContext<ROut> | NativeRequest | HttpServerRequest.HttpServerRequest | Scope.Scope;
|
|
1322
|
+
type WorkerRpcContext<ROut> = WorkerBaseContext<ROut> | Scope.Scope;
|
|
1323
|
+
/**
|
|
1324
|
+
* Successful result of a worker fetch handler: either a native `Response`
|
|
1325
|
+
* (returned to Cloudflare untouched) or an Effect `HttpServerResponse`
|
|
1326
|
+
* (rendered through the Effect HTTP pipeline).
|
|
1327
|
+
*/
|
|
1328
|
+
type WorkerFetchSuccess = Response | HttpServerResponse.HttpServerResponse;
|
|
1329
|
+
/**
|
|
1330
|
+
* Effect type for `fetch` handlers executed by {@link make}.
|
|
1331
|
+
*/
|
|
1332
|
+
type WorkerHandler<ROut, A = WorkerFetchSuccess> = Effect.Effect<A, unknown, WorkerFetchContext<ROut>>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Effect type for worker RPC handlers.
|
|
1335
|
+
*/
|
|
1336
|
+
type WorkerRpcHandler<ROut, A = unknown> = Effect.Effect<A, unknown, WorkerRpcContext<ROut>>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Shape of worker RPC handlers passed to {@link make}.
|
|
1339
|
+
*/
|
|
1340
|
+
type WorkerRpc<ROut> = Record<string, (...args: Array<any>) => WorkerRpcHandler<ROut>>;
|
|
1341
|
+
type WorkerRpcShape<Rpc extends WorkerRpc<ROut>, ROut> = { readonly [Key in keyof Rpc]: Rpc[Key] extends ((...args: infer Args) => Effect.Effect<infer A, unknown, WorkerRpcContext<ROut>>) ? (...args: Args) => Promise<A> : never; };
|
|
1342
|
+
type RpcHandlers$1<ROut, Api> = { readonly [Key in keyof Api as Key extends keyof WorkerEntrypoint ? never : Key extends string ? Key extends ReservedMethodName$2 ? never : [Api[Key]] extends [never] ? never : Api[Key] extends ((...args: Array<any>) => Promise<unknown>) ? Key : never : never]: Api[Key] extends ((...args: infer Args) => Promise<infer A>) ? (...args: Args) => WorkerRpcHandler<ROut, A> : never; };
|
|
1343
|
+
/**
|
|
1344
|
+
* Options for creating a worker class with Effect handlers.
|
|
1345
|
+
*/
|
|
1346
|
+
interface WorkerOptions<RRuntime, REvent = never, EventLayerError = never, Rpc extends WorkerRpc<RRuntime | REvent> = Record<never, never>> {
|
|
1347
|
+
/**
|
|
1348
|
+
* Layer provided around each Cloudflare event handled by this Worker.
|
|
1349
|
+
*
|
|
1350
|
+
* The layer is built inside the event's Effect scope and finalized when the
|
|
1351
|
+
* event effect completes. Use this for event-scoped resources such as OTLP
|
|
1352
|
+
* trace/log exporters that should flush at event completion.
|
|
1353
|
+
*/
|
|
1354
|
+
readonly eventLayer?: Layer.Layer<REvent, EventLayerError, WorkerBaseContext<RRuntime>>;
|
|
1355
|
+
/** Main request handler. */
|
|
1356
|
+
readonly fetch?: Effect.Effect<WorkerFetchSuccess, unknown, WorkerFetchContext<RRuntime | REvent>>;
|
|
1357
|
+
/** Queue consumer handler invoked per message batch. */
|
|
1358
|
+
readonly queue?: QueueHandler<RRuntime | REvent>;
|
|
1359
|
+
/** Optional RPC methods exposed as class instance methods. */
|
|
1360
|
+
readonly rpc?: Rpc;
|
|
1333
1361
|
}
|
|
1334
|
-
|
|
1362
|
+
type FetchWorkerOptions<RRuntime, REvent = never, EventLayerError = never> = Omit<WorkerOptions<RRuntime, REvent, EventLayerError, Record<never, never>>, "rpc"> & {
|
|
1363
|
+
readonly rpc?: never;
|
|
1364
|
+
};
|
|
1335
1365
|
/**
|
|
1336
|
-
*
|
|
1366
|
+
* Cloudflare `WorkerEntrypoint` constructor produced by {@link make}.
|
|
1337
1367
|
*/
|
|
1338
|
-
|
|
1339
|
-
fetch(
|
|
1368
|
+
type WorkerClass<Rpc extends WorkerRpc<ROut>, ROut> = new (ctx: globalThis.ExecutionContext, env: WorkerEnv) => WorkerEntrypoint<WorkerEnv> & {
|
|
1369
|
+
fetch(request: Request): Promise<Response>;
|
|
1370
|
+
queue(batch: globalThis.MessageBatch): Promise<void>;
|
|
1371
|
+
} & WorkerRpcShape<Rpc, ROut>;
|
|
1372
|
+
/**
|
|
1373
|
+
* `ExportedHandler`-compatible fetch object produced by {@link makeFetchHandler}.
|
|
1374
|
+
*/
|
|
1375
|
+
interface FetchHandler<Env extends WorkerEnv = WorkerEnv> {
|
|
1376
|
+
readonly fetch: (request: Request, env: Env, ctx: globalThis.ExecutionContext) => Promise<Response>;
|
|
1340
1377
|
}
|
|
1341
|
-
type RpcClient$1<Api> = { readonly [Key in keyof Api as Key extends string ? Api[Key] extends ((...args: Array<any>) => unknown) ? Key : never : never]: Api[Key]; };
|
|
1342
|
-
type ReservedMethodName$4 = ReservedMethodName$3 | "fetch";
|
|
1343
1378
|
/**
|
|
1344
|
-
*
|
|
1379
|
+
* Creates a Cloudflare worker class backed by a single managed Effect runtime.
|
|
1380
|
+
*
|
|
1381
|
+
* The runtime layer is built when Cloudflare constructs the class and reused
|
|
1382
|
+
* for every event the instance handles. Layer finalizers do not run when the
|
|
1383
|
+
* isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
|
|
1384
|
+
* for resources that must be finalized per event.
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* export default Worker.make(Layer.empty, {
|
|
1389
|
+
* fetch: Effect.succeed(new Response("ok")),
|
|
1390
|
+
* });
|
|
1391
|
+
* ```
|
|
1345
1392
|
*/
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
type ApiOrDefinition<Api extends object, Definition> = [Api] extends [never] ? ApiFromDefinition<Definition> : Api;
|
|
1393
|
+
declare function make$10<ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, fetch: WorkerHandler<ROut>): WorkerClass<Record<never, never>, ROut>;
|
|
1394
|
+
declare function make$10<ROut, LayerError, REvent = never, EventLayerError = never, const Rpc extends WorkerRpc<ROut | REvent> = Record<never, never>>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: WorkerOptions<ROut, REvent, EventLayerError, Rpc>): WorkerClass<Rpc, ROut | REvent>;
|
|
1349
1395
|
/**
|
|
1350
|
-
*
|
|
1396
|
+
* Creates an `ExportedHandler`-compatible `{ fetch }` object backed by
|
|
1397
|
+
* {@link make}.
|
|
1398
|
+
*
|
|
1399
|
+
* The Effect runtime is cached per `env` identity, so the user layer builds
|
|
1400
|
+
* once per isolate instead of once per request. `ExecutionContext`-backed
|
|
1401
|
+
* services (`Worker.ExecutionContext`, `Worker.WorkerContext`) are still
|
|
1402
|
+
* provided fresh for every request. Layer finalizers do not run when the
|
|
1403
|
+
* isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
|
|
1404
|
+
* for resources that must be finalized per event.
|
|
1351
1405
|
*/
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
/** Optional RPC schema used for argument/result encoding. */
|
|
1356
|
-
readonly definition?: Definition;
|
|
1406
|
+
declare const makeFetchHandler: <ROut, LayerError, REvent = never, EventLayerError = never, Env extends WorkerEnv = WorkerEnv>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: FetchWorkerOptions<ROut, REvent, EventLayerError>) => FetchHandler<Env>;
|
|
1407
|
+
declare namespace DurableObjectState_d_exports {
|
|
1408
|
+
export { DurableObjectState, DurableObjectStateService, fromDurableObjectState };
|
|
1357
1409
|
}
|
|
1358
|
-
declare const ServiceBindingFetchError_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 & {
|
|
1359
|
-
readonly _tag: "ServiceBindingFetchError";
|
|
1360
|
-
} & Readonly<A>;
|
|
1361
1410
|
/**
|
|
1362
|
-
*
|
|
1411
|
+
* Effect-friendly wrapper around Cloudflare `DurableObjectState`.
|
|
1363
1412
|
*/
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
readonly
|
|
1367
|
-
|
|
1368
|
-
|
|
1413
|
+
interface DurableObjectStateService {
|
|
1414
|
+
/** Underlying Cloudflare state instance. */
|
|
1415
|
+
readonly raw: globalThis.DurableObjectState;
|
|
1416
|
+
/** Durable Object id for the current instance. */
|
|
1417
|
+
readonly id: globalThis.DurableObjectId;
|
|
1418
|
+
/** Wrapped storage API. */
|
|
1419
|
+
readonly storage: DurableObjectStorage;
|
|
1420
|
+
/** Registers background work with Cloudflare's lifecycle. */
|
|
1421
|
+
waitUntil(promise: Promise<unknown>): Effect.Effect<void>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Runs a background Effect via Cloudflare's `waitUntil` with the caller's
|
|
1424
|
+
* Effect context, mirroring `WorkerContext.waitUntil` failure modes:
|
|
1425
|
+
* `"observe"` (default) logs or routes failures to `onFailure`, while
|
|
1426
|
+
* `"propagate"` also rejects the native `waitUntil` promise.
|
|
1427
|
+
*/
|
|
1428
|
+
waitUntil<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: WorkerContextWaitUntilOptions<E, R2>): Effect.Effect<void, never, R | R2>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate.
|
|
1431
|
+
*
|
|
1432
|
+
* Cloudflare resets a Durable Object if the callback throws/rejects, or if the
|
|
1433
|
+
* callback exceeds the platform timeout (currently documented as 30 seconds).
|
|
1434
|
+
* This safe default resolves the callback with the Effect `Exit` for typed
|
|
1435
|
+
* Effect failures and resumes that `Exit` afterward, so typed failures remain
|
|
1436
|
+
* ordinary Effect failures instead of resetting the Durable Object. Defects
|
|
1437
|
+
* and interruptions still reject the callback.
|
|
1438
|
+
*/
|
|
1439
|
+
blockConcurrencyWhile<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
1440
|
+
/**
|
|
1441
|
+
* Runs an Effect inside Cloudflare's `blockConcurrencyWhile` gate and lets
|
|
1442
|
+
* Effect failures reject the callback.
|
|
1443
|
+
*
|
|
1444
|
+
* Use this only when Cloudflare's reset-on-throw behavior is intentional. The
|
|
1445
|
+
* platform also resets the Durable Object if the callback exceeds the
|
|
1446
|
+
* documented timeout (currently 30 seconds).
|
|
1447
|
+
*/
|
|
1448
|
+
blockConcurrencyWhileOrReset<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
1449
|
+
/** Accepts a websocket connection for hibernation-capable Durable Objects. */
|
|
1450
|
+
acceptWebSocket(ws: DurableWebSocket, tags?: Array<string>): Effect.Effect<void>;
|
|
1451
|
+
/** Lists active sockets, optionally filtered by tag. */
|
|
1452
|
+
getWebSockets(tag?: string): Effect.Effect<Array<DurableWebSocket>>;
|
|
1453
|
+
/** Configures automatic request/response handling for sockets. */
|
|
1454
|
+
setWebSocketAutoResponse(pair?: WebSocketRequestResponsePair): Effect.Effect<void>;
|
|
1455
|
+
/** Gets the configured websocket auto-response pair. */
|
|
1456
|
+
getWebSocketAutoResponse: Effect.Effect<WebSocketRequestResponsePair | null>;
|
|
1457
|
+
/** Timestamp of the last automatic websocket response for a socket. */
|
|
1458
|
+
getWebSocketAutoResponseTimestamp(ws: DurableWebSocket): Effect.Effect<Date | null>;
|
|
1459
|
+
/** Sets the timeout for hibernatable websocket events. */
|
|
1460
|
+
setHibernatableWebSocketEventTimeout(timeoutMs?: number): Effect.Effect<void>;
|
|
1461
|
+
/** Gets the timeout for hibernatable websocket events. */
|
|
1462
|
+
getHibernatableWebSocketEventTimeout: Effect.Effect<number | null>;
|
|
1463
|
+
/** Reads tags attached to a websocket. */
|
|
1464
|
+
getTags(ws: DurableWebSocket): Effect.Effect<Array<string>>;
|
|
1465
|
+
/**
|
|
1466
|
+
* Forcibly resets the Durable Object. Cloudflare logs an uncaught Error using
|
|
1467
|
+
* the optional reason, and the method is not available in `wrangler dev` local
|
|
1468
|
+
* development according to the Durable Object State docs.
|
|
1469
|
+
*/
|
|
1470
|
+
abort(reason?: string): Effect.Effect<void>;
|
|
1471
|
+
}
|
|
1472
|
+
declare const DurableObjectState_base: Context.ServiceClass<DurableObjectState, "effect-cf/DurableObjectState", DurableObjectStateService>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Context tag for accessing the current Durable Object state service.
|
|
1475
|
+
*/
|
|
1476
|
+
declare class DurableObjectState extends DurableObjectState_base {}
|
|
1477
|
+
/**
|
|
1478
|
+
* Wraps a native Cloudflare `DurableObjectState` as a {@link DurableObjectStateService}.
|
|
1479
|
+
*/
|
|
1480
|
+
declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService;
|
|
1481
|
+
declare namespace CloudflareOtlp_d_exports {
|
|
1482
|
+
export { DurableObjectLayerOptions, LayerOptions$10 as LayerOptions, ResourceOptions, Serialization, Signal, WorkerLayerOptions, layer$10 as layer, layerDurableObject, layerJson, layerProtobuf, layerWorker };
|
|
1369
1483
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1484
|
+
/** Telemetry signal groups supported by the Cloudflare OTLP layers. */
|
|
1485
|
+
type Signal = "logs" | "traces" | "metrics";
|
|
1486
|
+
/** OTLP payload serialization used by the Effect OTLP exporters. */
|
|
1487
|
+
type Serialization = "json" | "protobuf";
|
|
1373
1488
|
/**
|
|
1374
|
-
*
|
|
1489
|
+
* Resource metadata shared by Worker and Durable Object OTLP layers.
|
|
1490
|
+
*
|
|
1491
|
+
* Precedence follows Effect's `OtlpResource.fromConfig`: explicit
|
|
1492
|
+
* `serviceName`/`serviceVersion` win over matching explicit `attributes`, and
|
|
1493
|
+
* explicit attributes win over `OTEL_SERVICE_NAME`, `OTEL_SERVICE_VERSION`, and
|
|
1494
|
+
* `OTEL_RESOURCE_ATTRIBUTES`. Omit an option to let operators set it from the
|
|
1495
|
+
* environment.
|
|
1375
1496
|
*/
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
readonly
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1497
|
+
interface ResourceOptions {
|
|
1498
|
+
/** Explicit service name. Takes precedence over OTEL environment variables. */
|
|
1499
|
+
readonly serviceName?: string;
|
|
1500
|
+
/** Explicit service version. Takes precedence over OTEL environment variables. */
|
|
1501
|
+
readonly serviceVersion?: string;
|
|
1502
|
+
/** Additional resource attributes attached to exported telemetry. */
|
|
1503
|
+
readonly attributes?: Record<string, unknown>;
|
|
1382
1504
|
}
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
type ServiceMethodSuccess<Api, Method extends keyof Api> = AsyncMethodSuccess<Api, Method>;
|
|
1386
|
-
type ServiceMethodCloudflareReturn<Api, Method extends keyof Api> = AsyncMethodCloudflareReturn<Api, Method>;
|
|
1387
|
-
type ServiceCall<R, Api> = <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
1388
|
-
type DefinitionDirectMethods<R, Definition extends Definition$4.Any> = { readonly [Method in Definition$7.MethodNames<Definition>]: (...args: Method$3.Args<Definition["methods"][Method]>) => Effect.Effect<Method$3.Success<Definition["methods"][Method]>, ServiceBindingRpcError, R>; };
|
|
1389
|
-
type DirectMethods$1<R, Definition> = Definition extends Definition$4.Any ? DefinitionDirectMethods<R, Definition> : {};
|
|
1390
|
-
type ServiceBindingEffectClient<Api extends object, Definition extends Definition$4.Any | undefined = undefined> = DirectMethods$1<never, Definition> & {
|
|
1391
|
-
/**
|
|
1392
|
-
* Forwards an HTTP request to the bound Worker service.
|
|
1393
|
-
*
|
|
1394
|
-
* Use this when the service binding is acting as an HTTP origin rather than a
|
|
1395
|
-
* Cloudflare RPC target.
|
|
1396
|
-
*
|
|
1397
|
-
* @example
|
|
1398
|
-
* ```ts
|
|
1399
|
-
* import { Effect } from "effect";
|
|
1400
|
-
*
|
|
1401
|
-
* const program = Effect.gen(function* () {
|
|
1402
|
-
* const api = yield* ApiWorker;
|
|
1403
|
-
* return yield* api.fetch(new Request("https://internal.example/users"));
|
|
1404
|
-
* });
|
|
1405
|
-
* ```
|
|
1406
|
-
*/
|
|
1407
|
-
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError>;
|
|
1505
|
+
/** Options shared by all Cloudflare OTLP telemetry layers. */
|
|
1506
|
+
interface LayerOptions$10 {
|
|
1408
1507
|
/**
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
* This preserves Cloudflare RPC behavior such as promise-like pipelining and
|
|
1412
|
-
* transferable / disposable result objects. It does not resolve the returned
|
|
1413
|
-
* promise-like value and it does not decode definition-backed success schemas.
|
|
1414
|
-
*
|
|
1415
|
-
* Most application code should use {@link call} instead.
|
|
1416
|
-
*
|
|
1417
|
-
* @example
|
|
1418
|
-
* ```ts
|
|
1419
|
-
* import { Effect } from "effect";
|
|
1420
|
-
*
|
|
1421
|
-
* const program = Effect.gen(function* () {
|
|
1422
|
-
* const counter = yield* CounterService;
|
|
1423
|
-
*
|
|
1424
|
-
* const result = yield* counter.rpc("increment", 41);
|
|
1425
|
-
* const value = yield* Effect.promise(() => result);
|
|
1508
|
+
* Telemetry signals to export. Defaults to logs, traces, and metrics.
|
|
1426
1509
|
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
* ```
|
|
1510
|
+
* Each selected signal is still controlled by standard OTEL exporter config,
|
|
1511
|
+
* such as `OTEL_TRACES_EXPORTER=otlp`.
|
|
1430
1512
|
*/
|
|
1431
|
-
readonly
|
|
1513
|
+
readonly signals?: ReadonlyArray<Signal>;
|
|
1514
|
+
/** OTLP payload serialization. Defaults to protobuf. */
|
|
1515
|
+
readonly serialization?: Serialization;
|
|
1516
|
+
/** Resource metadata forwarded to Effect's OTLP resource resolver. */
|
|
1517
|
+
readonly resource?: ResourceOptions;
|
|
1432
1518
|
/**
|
|
1433
|
-
*
|
|
1434
|
-
* the success value when the binding was created from a definition.
|
|
1435
|
-
*
|
|
1436
|
-
* This is the normal choice when application code wants the final typed value.
|
|
1437
|
-
*
|
|
1438
|
-
* @example
|
|
1439
|
-
* ```ts
|
|
1440
|
-
* import { Effect } from "effect";
|
|
1441
|
-
*
|
|
1442
|
-
* const program = Effect.gen(function* () {
|
|
1443
|
-
* const counter = yield* CounterService;
|
|
1444
|
-
* const value = yield* counter.call("increment", 41);
|
|
1519
|
+
* Explicit headers for every selected signal.
|
|
1445
1520
|
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
* ```
|
|
1521
|
+
* When omitted, Effect reads `OTEL_EXPORTER_OTLP_HEADERS` and the
|
|
1522
|
+
* signal-specific `OTEL_EXPORTER_OTLP_*_HEADERS` variables.
|
|
1449
1523
|
*/
|
|
1450
|
-
readonly
|
|
1524
|
+
readonly headers?: Headers$1.Input;
|
|
1525
|
+
/** Exclude log records emitted for spans when exporting logs. */
|
|
1526
|
+
readonly loggerExcludeLogSpans?: boolean;
|
|
1527
|
+
/** Merge the OTLP logger with existing loggers instead of replacing them. */
|
|
1528
|
+
readonly loggerMergeWithExisting?: boolean;
|
|
1529
|
+
/** Custom trace context lookup used by the Effect OTLP tracer. */
|
|
1530
|
+
readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
|
|
1531
|
+
}
|
|
1532
|
+
/** Resource metadata specific to Cloudflare Workers. */
|
|
1533
|
+
interface WorkerLayerOptions extends LayerOptions$10 {
|
|
1534
|
+
/** Cloudflare Worker name to attach as `cloudflare.worker.name`. */
|
|
1535
|
+
readonly workerName?: string;
|
|
1536
|
+
}
|
|
1537
|
+
/** Resource metadata specific to Cloudflare Durable Objects. */
|
|
1538
|
+
interface DurableObjectLayerOptions extends LayerOptions$10 {
|
|
1539
|
+
/** Durable Object class name to attach as `cloudflare.durable_object.class`. */
|
|
1540
|
+
readonly className?: string;
|
|
1451
1541
|
/**
|
|
1452
|
-
*
|
|
1453
|
-
* result, decodes definition-backed success values, and disposes the resolved
|
|
1454
|
-
* result when the scope closes if it implements `Symbol.dispose`.
|
|
1455
|
-
*
|
|
1456
|
-
* Use this for RPC methods that return Cloudflare RPC resources or other
|
|
1457
|
-
* disposable objects whose lifetime should be tied to an Effect scope.
|
|
1458
|
-
*
|
|
1459
|
-
* @example
|
|
1460
|
-
* ```ts
|
|
1461
|
-
* import { Effect } from "effect";
|
|
1462
|
-
*
|
|
1463
|
-
* const program = Effect.scoped(
|
|
1464
|
-
* Effect.gen(function* () {
|
|
1465
|
-
* const files = yield* FileService;
|
|
1466
|
-
* const handle = yield* files.scopedCall("open", "report.csv");
|
|
1542
|
+
* Include the Durable Object id as `cloudflare.durable_object.id`.
|
|
1467
1543
|
*
|
|
1468
|
-
*
|
|
1469
|
-
* }),
|
|
1470
|
-
* );
|
|
1471
|
-
* ```
|
|
1544
|
+
* This is disabled by default because object ids can be high-cardinality.
|
|
1472
1545
|
*/
|
|
1473
|
-
readonly
|
|
1474
|
-
}
|
|
1475
|
-
type ServiceBindingStaticClient<R, Api extends object, Definition extends Definition$4.Any | undefined = undefined> = DirectMethods$1<R, Definition> & {
|
|
1476
|
-
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<globalThis.Response, ServiceBindingFetchError, R>;
|
|
1477
|
-
readonly rpc: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodCloudflareReturn<Api, Method>, ServiceBindingRpcError, R>;
|
|
1478
|
-
readonly call: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<ServiceMethodSuccess<Api, Method>, ServiceBindingRpcError, R>;
|
|
1479
|
-
readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, unknown, Scope.Scope | R>;
|
|
1480
|
-
};
|
|
1481
|
-
declare const isServiceBindingClient: <Api extends object>(value: unknown) => value is ServiceBindingClient<Api>;
|
|
1482
|
-
declare const makeClient$7: <Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition>);
|
|
1483
|
-
declare const layer$9: <Self, Api extends object, const Definition extends Definition$4.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition>>, definition: ServiceBindingDefinition<Definition>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1546
|
+
readonly includeObjectId?: boolean;
|
|
1547
|
+
}
|
|
1484
1548
|
/**
|
|
1485
|
-
*
|
|
1549
|
+
* Base OTLP telemetry layer for Cloudflare-compatible runtimes.
|
|
1486
1550
|
*
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
*
|
|
1490
|
-
*
|
|
1491
|
-
* - `call(...)` for resolved and decoded RPC results
|
|
1492
|
-
* - `scopedCall(...)` for scoped and decoded disposable RPC results
|
|
1493
|
-
* - direct RPC methods when `definition` is provided
|
|
1551
|
+
* Standard OpenTelemetry environment variables are resolved by Effect's OTLP
|
|
1552
|
+
* layers. In Cloudflare Workers and Durable Objects, the current `env` object is
|
|
1553
|
+
* installed as the primary `ConfigProvider`; outside Cloudflare, the ambient
|
|
1554
|
+
* Effect `ConfigProvider` remains the fallback.
|
|
1494
1555
|
*
|
|
1495
|
-
* @
|
|
1496
|
-
*
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1556
|
+
* The layer provides {@link OtlpExporter.Flusher} for draining buffered
|
|
1557
|
+
* telemetry before the isolate freezes.
|
|
1558
|
+
*/
|
|
1559
|
+
declare const layer$10: (options?: LayerOptions$10) => Layer.Layer<OtlpExporter.Flusher>;
|
|
1560
|
+
/** Base OTLP telemetry layer forced to JSON serialization. */
|
|
1561
|
+
declare const layerJson: (options?: Omit<LayerOptions$10, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
1562
|
+
/** Base OTLP telemetry layer forced to protobuf serialization. */
|
|
1563
|
+
declare const layerProtobuf: (options?: Omit<LayerOptions$10, "serialization">) => Layer.Layer<OtlpExporter.Flusher>;
|
|
1564
|
+
/**
|
|
1565
|
+
* OTLP layer with Cloudflare Worker resource attributes.
|
|
1503
1566
|
*
|
|
1504
|
-
*
|
|
1567
|
+
* Provide this layer at runtime scope for long-lived metrics aggregation, or at
|
|
1568
|
+
* handler scope when traces/logs should flush as the Cloudflare event finishes.
|
|
1569
|
+
*/
|
|
1570
|
+
declare const layerWorker: (options?: WorkerLayerOptions) => Layer.Layer<OtlpExporter.Flusher>;
|
|
1571
|
+
/**
|
|
1572
|
+
* OTLP layer with Cloudflare Durable Object resource attributes.
|
|
1505
1573
|
*
|
|
1506
|
-
*
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
* return next;
|
|
1510
|
-
* });
|
|
1511
|
-
* ```
|
|
1574
|
+
* The layer reads {@link DurableObjectState} so it can optionally include the
|
|
1575
|
+
* Durable Object id. Prefer leaving `includeObjectId` disabled unless the
|
|
1576
|
+
* backend can tolerate high-cardinality resource attributes.
|
|
1512
1577
|
*/
|
|
1513
|
-
declare const
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
readonly fetch: (input: URL | RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined) => Effect.Effect<Response, ServiceBindingFetchError, Self>;
|
|
1517
|
-
readonly rpc: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<Result$1<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>>, ServiceBindingRpcError, Self>;
|
|
1518
|
-
readonly call: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>, ServiceBindingRpcError, Self>;
|
|
1519
|
-
readonly scopedCall: <Method extends ServiceMethodKey<ApiOrDefinition<Api, Definition>>>(method: Method, ...args: AsyncMethodArgs<ApiOrDefinition<Api, Definition>, Method>) => Effect.Effect<Awaited<AsyncMethodSuccess<ApiOrDefinition<Api, Definition>, Method>>, unknown, Self | Scope.Scope>;
|
|
1520
|
-
};
|
|
1521
|
-
declare const makeDirectMethods$1: <R, Api, Definition extends Definition$4.Any | undefined>(rpcDefinition: Definition | undefined, call: ServiceCall<R, Api>) => DirectMethods$1<R, Definition>;
|
|
1522
|
-
declare namespace WorkerDefinition_d_exports {
|
|
1523
|
-
export { Api$1 as Api, Definition$4 as Definition, HandlerEffect$1 as HandlerEffect, Handlers$1 as Handlers, LayerOptions$9 as LayerOptions, Method$2 as Method, Methods$1 as Methods, NoReservedMethods$1 as NoReservedMethods, Options$3 as Options, ReservedMethodName$3 as ReservedMethodName, ServerApi$2 as ServerApi, ServiceFreeSchema$1 as ServiceFreeSchema, Tag$9 as Tag, TagClass$8 as TagClass, Worker, implement$3 as implement, make$9 as make, method$1 as method };
|
|
1578
|
+
declare const layerDurableObject: (options?: DurableObjectLayerOptions) => Layer.Layer<OtlpExporter.Flusher, never, DurableObjectState>;
|
|
1579
|
+
declare namespace ContainerNamespace_d_exports {
|
|
1580
|
+
export { ContainerInstanceClient, ContainerNamespace, ContainerNamespaceClient, ContainerNamespaceDefinition, ContainerNamespaceResource, ContainerNamespaceService, ContainerNamespaceStaticClient, ContainerOperationError, ContainerReadinessOptions, ContainerSignal, ContainerStartAndWaitForPortsOptions, ContainerStartOptions, ContainerState, ContainerStopSignal, ContainerStub, ContainerStubOf, ContainerWaitOptions, LayerOptions$9 as LayerOptions, Tag$9 as Tag, TagClass$8 as TagClass, isContainerNamespaceResource, layer$9 as layer, make$9 as make, makeClient$7 as makeClient };
|
|
1524
1581
|
}
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1582
|
+
/** Named signal accepted by Cloudflare Container instances. */
|
|
1583
|
+
type ContainerSignal = "SIGKILL" | "SIGINT" | "SIGTERM";
|
|
1584
|
+
/** Named or numeric signal accepted by Container `stop()`. */
|
|
1585
|
+
type ContainerStopSignal = ContainerSignal | number;
|
|
1586
|
+
/** Per-instance Container startup configuration. */
|
|
1587
|
+
interface ContainerStartOptions {
|
|
1588
|
+
readonly envVars?: Record<string, string>;
|
|
1589
|
+
readonly entrypoint?: Array<string>;
|
|
1590
|
+
readonly enableInternet?: boolean;
|
|
1591
|
+
readonly labels?: Record<string, string>;
|
|
1529
1592
|
}
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
export type Args<Self extends Any> = ArgsFromSchemas<Self["args"]>;
|
|
1536
|
-
export type EncodedArgs<Self extends Any> = EncodedArgsFromSchemas<Self["args"]>;
|
|
1537
|
-
export type Success<Self extends Any> = Schema.Schema.Type<Self["success"]>;
|
|
1538
|
-
export type EncodedSuccess<Self extends Any> = Schema.Json;
|
|
1539
|
-
export {};
|
|
1593
|
+
/** Serializable retry settings used while starting a Container. */
|
|
1594
|
+
interface ContainerWaitOptions {
|
|
1595
|
+
readonly portToCheck: number;
|
|
1596
|
+
readonly retries?: number;
|
|
1597
|
+
readonly waitInterval?: number;
|
|
1540
1598
|
}
|
|
1541
|
-
|
|
1599
|
+
/** Serializable timeout settings used while waiting for Container ports. */
|
|
1600
|
+
interface ContainerReadinessOptions {
|
|
1601
|
+
readonly instanceGetTimeoutMS?: number;
|
|
1602
|
+
readonly portReadyTimeoutMS?: number;
|
|
1603
|
+
readonly waitInterval?: number;
|
|
1604
|
+
}
|
|
1605
|
+
/** Options for starting a Container and waiting for its ports. */
|
|
1606
|
+
interface ContainerStartAndWaitForPortsOptions {
|
|
1607
|
+
readonly startOptions?: ContainerStartOptions;
|
|
1608
|
+
readonly ports?: number | Array<number>;
|
|
1609
|
+
readonly cancellationOptions?: ContainerReadinessOptions;
|
|
1610
|
+
}
|
|
1611
|
+
/** Serializable state reported by a Cloudflare Container instance. */
|
|
1612
|
+
declare const ContainerState: Schema.Union<readonly [Schema.Struct<{
|
|
1613
|
+
readonly lastChange: Schema.Finite;
|
|
1614
|
+
readonly status: Schema.Literals<readonly ["running", "stopping", "stopped", "healthy"]>;
|
|
1615
|
+
}>, Schema.Struct<{
|
|
1616
|
+
readonly lastChange: Schema.Finite;
|
|
1617
|
+
readonly status: Schema.Literal<"stopped_with_code">;
|
|
1618
|
+
readonly exitCode: Schema.optionalKey<Schema.Int>;
|
|
1619
|
+
}>]>;
|
|
1620
|
+
type ContainerState = typeof ContainerState.Type;
|
|
1542
1621
|
/**
|
|
1543
|
-
*
|
|
1622
|
+
* Native Container stub shape exposed by a Container namespace binding.
|
|
1544
1623
|
*
|
|
1545
|
-
*
|
|
1546
|
-
*
|
|
1624
|
+
* This is structural so using Container bindings does not make
|
|
1625
|
+
* `@cloudflare/containers` a runtime dependency of effect-cf.
|
|
1547
1626
|
*/
|
|
1548
|
-
interface
|
|
1549
|
-
|
|
1550
|
-
|
|
1627
|
+
interface ContainerStub {
|
|
1628
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
1629
|
+
getState(): Promise<ContainerState>;
|
|
1630
|
+
start(options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions): Promise<void>;
|
|
1631
|
+
startAndWaitForPorts(options?: ContainerStartAndWaitForPortsOptions): Promise<void>;
|
|
1632
|
+
waitForPort(options: ContainerWaitOptions): Promise<number>;
|
|
1633
|
+
stop(signal?: ContainerStopSignal): Promise<void>;
|
|
1634
|
+
destroy(): Promise<void>;
|
|
1635
|
+
setAllowedHosts(hosts: Array<string>): Promise<void>;
|
|
1636
|
+
setDeniedHosts(hosts: Array<string>): Promise<void>;
|
|
1637
|
+
allowHost(hostname: string): Promise<void>;
|
|
1638
|
+
denyHost(hostname: string): Promise<void>;
|
|
1639
|
+
removeAllowedHost(hostname: string): Promise<void>;
|
|
1640
|
+
removeDeniedHost(hostname: string): Promise<void>;
|
|
1551
1641
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1642
|
+
/** Native Container namespace binding shape. */
|
|
1643
|
+
interface ContainerNamespaceResource {
|
|
1644
|
+
getByName(name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions): ContainerStub;
|
|
1554
1645
|
}
|
|
1555
|
-
type
|
|
1556
|
-
type
|
|
1557
|
-
/**
|
|
1558
|
-
|
|
1559
|
-
*/
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
readonly
|
|
1646
|
+
/** Exact native stub type produced by a Container namespace binding. */
|
|
1647
|
+
type ContainerStubOf<Namespace extends ContainerNamespaceResource> = ReturnType<Namespace["getByName"]>;
|
|
1648
|
+
/** Container namespace binding metadata. */
|
|
1649
|
+
interface ContainerNamespaceDefinition {
|
|
1650
|
+
/** Binding name as configured in `wrangler.jsonc`. */
|
|
1651
|
+
readonly binding: string;
|
|
1652
|
+
}
|
|
1653
|
+
declare const ContainerOperationError_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 & {
|
|
1654
|
+
readonly _tag: "ContainerOperationError";
|
|
1655
|
+
} & Readonly<A>;
|
|
1656
|
+
/** Failure raised when invoking a named Container operation. */
|
|
1657
|
+
declare class ContainerOperationError extends ContainerOperationError_base<{
|
|
1658
|
+
readonly binding: string;
|
|
1659
|
+
readonly instance: string;
|
|
1660
|
+
readonly operation: string;
|
|
1661
|
+
readonly cause: unknown;
|
|
1662
|
+
}> {
|
|
1663
|
+
get message(): string;
|
|
1664
|
+
}
|
|
1665
|
+
/** Effect-wrapped client for one named Container instance. */
|
|
1666
|
+
interface ContainerInstanceClient<Stub extends ContainerStub = ContainerStub> {
|
|
1667
|
+
readonly rawUnsafe: Effect.Effect<Stub, ContainerOperationError>;
|
|
1668
|
+
readonly state: Effect.Effect<ContainerState, ContainerOperationError>;
|
|
1669
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<Response, ContainerOperationError>;
|
|
1670
|
+
readonly start: (options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions) => Effect.Effect<void, ContainerOperationError>;
|
|
1671
|
+
readonly startAndWaitForPorts: (options?: ContainerStartAndWaitForPortsOptions) => Effect.Effect<void, ContainerOperationError>;
|
|
1672
|
+
readonly waitForPort: (options: ContainerWaitOptions) => Effect.Effect<number, ContainerOperationError>;
|
|
1673
|
+
readonly stop: (signal?: ContainerStopSignal) => Effect.Effect<void, ContainerOperationError>;
|
|
1674
|
+
readonly destroy: Effect.Effect<void, ContainerOperationError>;
|
|
1675
|
+
readonly setAllowedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError>;
|
|
1676
|
+
readonly setDeniedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError>;
|
|
1677
|
+
readonly allowHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
|
|
1678
|
+
readonly denyHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
|
|
1679
|
+
readonly removeAllowedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
|
|
1680
|
+
readonly removeDeniedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError>;
|
|
1681
|
+
}
|
|
1682
|
+
/** Effect client for a Container namespace binding. */
|
|
1683
|
+
interface ContainerNamespaceClient<Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> {
|
|
1684
|
+
readonly definition: ContainerNamespaceDefinition;
|
|
1685
|
+
readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<ContainerInstanceClient<ContainerStubOf<Namespace>>, ContainerOperationError>;
|
|
1686
|
+
readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => ContainerInstanceClient<ContainerStubOf<Namespace>>;
|
|
1687
|
+
readonly rawUnsafe: Effect.Effect<Namespace>;
|
|
1571
1688
|
}
|
|
1689
|
+
type ContainerNamespaceStaticClient<R, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> = {
|
|
1690
|
+
readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<ContainerInstanceClient<ContainerStubOf<Namespace>>, ContainerOperationError, R>;
|
|
1691
|
+
readonly byName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => {
|
|
1692
|
+
readonly state: Effect.Effect<ContainerState, ContainerOperationError, R>;
|
|
1693
|
+
readonly fetch: (input: RequestInfo | URL, init?: RequestInit) => Effect.Effect<Response, ContainerOperationError, R>;
|
|
1694
|
+
readonly start: (options?: ContainerStartOptions, waitOptions?: ContainerWaitOptions) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1695
|
+
readonly startAndWaitForPorts: (options?: ContainerStartAndWaitForPortsOptions) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1696
|
+
readonly waitForPort: (options: ContainerWaitOptions) => Effect.Effect<number, ContainerOperationError, R>;
|
|
1697
|
+
readonly stop: (signal?: ContainerStopSignal) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1698
|
+
readonly destroy: Effect.Effect<void, ContainerOperationError, R>;
|
|
1699
|
+
readonly setAllowedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1700
|
+
readonly setDeniedHosts: (hosts: ReadonlyArray<string>) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1701
|
+
readonly allowHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1702
|
+
readonly denyHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1703
|
+
readonly removeAllowedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1704
|
+
readonly removeDeniedHost: (hostname: string) => Effect.Effect<void, ContainerOperationError, R>;
|
|
1705
|
+
readonly rawUnsafe: Effect.Effect<ContainerStubOf<Namespace>, ContainerOperationError, R>;
|
|
1706
|
+
};
|
|
1707
|
+
readonly rawUnsafe: Effect.Effect<Namespace, never, R>;
|
|
1708
|
+
};
|
|
1572
1709
|
type LayerOptions$9 = {
|
|
1573
1710
|
readonly binding: string;
|
|
1574
1711
|
};
|
|
1575
|
-
|
|
1712
|
+
interface TagClass$8<Self, Id extends string, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource> extends Context.ServiceClass<Self, `effect-cf/Container/${Id}`, ContainerNamespaceClient<Namespace>>, ContainerNamespaceStaticClient<Self, Namespace> {
|
|
1576
1713
|
readonly id: Id;
|
|
1577
|
-
readonly methods: MethodsShape;
|
|
1578
|
-
readonly make: <ROut, LayerError, REvent = never, EventLayerError = never>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: Options$3<ROut, Definition$4<Id, MethodsShape>, REvent, EventLayerError>) => WorkerClass<Handlers$1<ROut | REvent, Definition$4<Id, MethodsShape>>, ROut | REvent>;
|
|
1579
1714
|
readonly layer: (options: LayerOptions$9) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1580
|
-
};
|
|
1581
|
-
/**
|
|
1582
|
-
* Defines a single RPC method schema in a worker definition.
|
|
1583
|
-
*/
|
|
1584
|
-
declare const method$1: {
|
|
1585
|
-
<Success extends ServiceFreeSchema$1>(definition: {
|
|
1586
|
-
readonly success: Success;
|
|
1587
|
-
}): Method$2<readonly [], Success>;
|
|
1588
|
-
<const Args extends ReadonlyArray<ServiceFreeSchema$1>, Success extends ServiceFreeSchema$1>(definition: {
|
|
1589
|
-
readonly args: Args;
|
|
1590
|
-
readonly success: Success;
|
|
1591
|
-
}): Method$2<Args, Success>;
|
|
1592
|
-
};
|
|
1593
|
-
declare const make$9: <Id extends string, const MethodsShape extends Methods$1>(id: Id, methods: MethodsShape & NoReservedMethods$1<MethodsShape>) => TagClass$8<Definition$4<Id, MethodsShape>, Id, MethodsShape>;
|
|
1594
|
-
declare const Tag$9: <Self>() => <Id extends string, const MethodsShape extends Methods$1>(id: Id, methods: MethodsShape & NoReservedMethods$1<MethodsShape>) => TagClass$8<Self, Id, MethodsShape>;
|
|
1595
|
-
declare const Worker: typeof Tag$9;
|
|
1596
|
-
/**
|
|
1597
|
-
* Helper for implementing handlers with the exact method shape of a definition.
|
|
1598
|
-
*/
|
|
1599
|
-
declare const implement$3: <ROut, const Self extends Definition$4.Any>(_definition: Self, handlers: Handlers$1<ROut, Self>) => Handlers$1<ROut, Self>;
|
|
1600
|
-
/**
|
|
1601
|
-
* Convenience alias for a single worker RPC handler Effect.
|
|
1602
|
-
*/
|
|
1603
|
-
type HandlerEffect$1<ROut, Self extends Definition$4.Any, Key extends keyof Self["methods"]> = WorkerRpcHandler<ROut, Method$2.Success<Self["methods"][Key]>>;
|
|
1604
|
-
declare namespace Worker_d_exports {
|
|
1605
|
-
export { Api$1 as Api, Definition$4 as Definition, ExecutionContext, FetchHandler, FetchWorkerOptions, HandlerEffect$1 as HandlerEffect, Handlers$1 as Handlers, LayerOptions$9 as LayerOptions, Method$2 as Method, Methods$1 as Methods, NativeRequest, NoReservedMethods$1 as NoReservedMethods, Options$3 as Options, ReservedMethodName$2 as ReservedMethodName, RpcHandlers$1 as RpcHandlers, ServerApi$2 as ServerApi, ServiceFreeSchema$1 as ServiceFreeSchema, Tag$9 as Tag, TagClass$8 as TagClass, WorkerClass, WorkerContext, WorkerContextService, WorkerContextWaitUntilOptions, WorkerFetchSuccess, WorkerHandler, WorkerOptions, WorkerRpc, WorkerRpcHandler, WorkerRpcShape, implement$3 as implement, isWebSocketUpgrade, make$8 as make, makeFetchHandler, method$1 as method };
|
|
1606
1715
|
}
|
|
1607
|
-
declare const
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
declare
|
|
1612
|
-
/**
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
* Failure mode for the background effect: `"observe"` (default) logs or
|
|
1618
|
-
* routes the failure to `onFailure`, while `"propagate"` also rejects the
|
|
1619
|
-
* native `waitUntil` promise.
|
|
1620
|
-
*/
|
|
1621
|
-
readonly mode?: "observe" | "propagate";
|
|
1622
|
-
/** Custom failure handler for the background effect. */
|
|
1623
|
-
readonly onFailure?: (cause: Cause.Cause<E>) => Effect.Effect<void, never, R>;
|
|
1716
|
+
declare const isContainerNamespaceResource: (value: unknown) => value is ContainerNamespaceResource;
|
|
1717
|
+
declare const makeClient$7: (definition: ContainerNamespaceDefinition) => <Namespace extends ContainerNamespaceResource>(namespace: Namespace) => ContainerNamespaceClient<Namespace>;
|
|
1718
|
+
declare const layer$9: <Self, Namespace extends ContainerNamespaceResource>(tag: Context.Service<Self, ContainerNamespaceClient<Namespace>>, definition: ContainerNamespaceDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1719
|
+
declare const make$9: <Id extends string>(id: Id) => TagClass$8<ContainerNamespaceService<Id>, Id, ContainerNamespaceResource>;
|
|
1720
|
+
declare const ContainerNamespaceServiceTypeId: unique symbol;
|
|
1721
|
+
/** Nominal service marker for Container namespaces created with {@link make}. */
|
|
1722
|
+
interface ContainerNamespaceService<Id extends string> {
|
|
1723
|
+
readonly [ContainerNamespaceServiceTypeId]: {
|
|
1724
|
+
readonly id: Id;
|
|
1725
|
+
};
|
|
1624
1726
|
}
|
|
1625
|
-
/**
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
waitUntil<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: WorkerContextWaitUntilOptions<E, R2>): Effect.Effect<void, never, R | R2>;
|
|
1631
|
-
waitUntilPropagating<A, E, R, R2 = never>(effect: Effect.Effect<A, E, R>, options?: Omit<WorkerContextWaitUntilOptions<E, R2>, "mode">): Effect.Effect<void, never, R | R2>;
|
|
1632
|
-
readonly passThroughOnException: Effect.Effect<void>;
|
|
1727
|
+
/** Creates a typed Effect service for a Cloudflare Container namespace. */
|
|
1728
|
+
declare const Tag$9: <Self, Namespace extends ContainerNamespaceResource = ContainerNamespaceResource>() => <Id extends string>(id: Id) => TagClass$8<Self, Id, Namespace>;
|
|
1729
|
+
declare const ContainerNamespace: typeof Tag$9;
|
|
1730
|
+
declare namespace D1_d_exports {
|
|
1731
|
+
export { D1Definition, D1Service, D1SqlLayerOptions, Service, TypeId$1 as TypeId, make$8 as make };
|
|
1633
1732
|
}
|
|
1634
|
-
declare const
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
/**
|
|
1650
|
-
* Access to the incoming `Request` currently handled by a worker or Durable Object fetch.
|
|
1651
|
-
*/
|
|
1652
|
-
declare class NativeRequest extends NativeRequest_base {}
|
|
1653
|
-
/**
|
|
1654
|
-
* Returns `true` when the request is a websocket upgrade request.
|
|
1655
|
-
*/
|
|
1656
|
-
declare const isWebSocketUpgrade: (request: Request) => boolean;
|
|
1657
|
-
type ReservedMethodName$2 = ReservedMethodName$5 | "fetch" | "connect" | "queue" | "scheduled" | "tail" | "tailStream" | "test" | "trace" | "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError";
|
|
1658
|
-
type WorkerBaseContext<ROut> = ExecutionContext | WorkerContext | WorkerEnvironment | ROut;
|
|
1659
|
-
type WorkerFetchContext<ROut> = WorkerBaseContext<ROut> | NativeRequest | HttpServerRequest.HttpServerRequest | Scope.Scope;
|
|
1660
|
-
type WorkerRpcContext<ROut> = WorkerBaseContext<ROut> | Scope.Scope;
|
|
1661
|
-
/**
|
|
1662
|
-
* Successful result of a worker fetch handler: either a native `Response`
|
|
1663
|
-
* (returned to Cloudflare untouched) or an Effect `HttpServerResponse`
|
|
1664
|
-
* (rendered through the Effect HTTP pipeline).
|
|
1665
|
-
*/
|
|
1666
|
-
type WorkerFetchSuccess = Response | HttpServerResponse.HttpServerResponse;
|
|
1667
|
-
/**
|
|
1668
|
-
* Effect type for `fetch` handlers executed by {@link make}.
|
|
1669
|
-
*/
|
|
1670
|
-
type WorkerHandler<ROut, A = WorkerFetchSuccess> = Effect.Effect<A, unknown, WorkerFetchContext<ROut>>;
|
|
1671
|
-
/**
|
|
1672
|
-
* Effect type for worker RPC handlers.
|
|
1673
|
-
*/
|
|
1674
|
-
type WorkerRpcHandler<ROut, A = unknown> = Effect.Effect<A, unknown, WorkerRpcContext<ROut>>;
|
|
1675
|
-
/**
|
|
1676
|
-
* Shape of worker RPC handlers passed to {@link make}.
|
|
1677
|
-
*/
|
|
1678
|
-
type WorkerRpc<ROut> = Record<string, (...args: Array<any>) => WorkerRpcHandler<ROut>>;
|
|
1679
|
-
type WorkerRpcShape<Rpc extends WorkerRpc<ROut>, ROut> = { readonly [Key in keyof Rpc]: Rpc[Key] extends ((...args: infer Args) => Effect.Effect<infer A, unknown, WorkerRpcContext<ROut>>) ? (...args: Args) => Promise<A> : never; };
|
|
1680
|
-
type RpcHandlers$1<ROut, Api> = { readonly [Key in keyof Api as Key extends keyof WorkerEntrypoint ? never : Key extends string ? Key extends ReservedMethodName$2 ? never : [Api[Key]] extends [never] ? never : Api[Key] extends ((...args: Array<any>) => Promise<unknown>) ? Key : never : never]: Api[Key] extends ((...args: infer Args) => Promise<infer A>) ? (...args: Args) => WorkerRpcHandler<ROut, A> : never; };
|
|
1681
|
-
/**
|
|
1682
|
-
* Options for creating a worker class with Effect handlers.
|
|
1683
|
-
*/
|
|
1684
|
-
interface WorkerOptions<RRuntime, REvent = never, EventLayerError = never, Rpc extends WorkerRpc<RRuntime | REvent> = Record<never, never>> {
|
|
1685
|
-
/**
|
|
1686
|
-
* Layer provided around each Cloudflare event handled by this Worker.
|
|
1687
|
-
*
|
|
1688
|
-
* The layer is built inside the event's Effect scope and finalized when the
|
|
1689
|
-
* event effect completes. Use this for event-scoped resources such as OTLP
|
|
1690
|
-
* trace/log exporters that should flush at event completion.
|
|
1691
|
-
*/
|
|
1692
|
-
readonly eventLayer?: Layer.Layer<REvent, EventLayerError, WorkerBaseContext<RRuntime>>;
|
|
1693
|
-
/** Main request handler. */
|
|
1694
|
-
readonly fetch?: Effect.Effect<WorkerFetchSuccess, unknown, WorkerFetchContext<RRuntime | REvent>>;
|
|
1695
|
-
/** Queue consumer handler invoked per message batch. */
|
|
1696
|
-
readonly queue?: QueueHandler<RRuntime | REvent>;
|
|
1697
|
-
/** Optional RPC methods exposed as class instance methods. */
|
|
1698
|
-
readonly rpc?: Rpc;
|
|
1733
|
+
declare const TypeId$1: "~effect-cf/D1";
|
|
1734
|
+
type TypeId$1 = typeof TypeId$1;
|
|
1735
|
+
/** Typed D1 binding definition. */
|
|
1736
|
+
interface D1Definition {
|
|
1737
|
+
/** Binding name as configured in `wrangler.jsonc`. */
|
|
1738
|
+
readonly binding: string;
|
|
1739
|
+
}
|
|
1740
|
+
/** Options forwarded to `@effect/sql-d1` when building a SQL client layer. */
|
|
1741
|
+
type D1SqlLayerOptions = Omit<D1Client.D1ClientConfig, "db">;
|
|
1742
|
+
declare const D1ServiceTypeId: unique symbol;
|
|
1743
|
+
/** Nominal service marker for D1 services created with {@link make}. */
|
|
1744
|
+
interface D1Service<Id extends string> {
|
|
1745
|
+
readonly [D1ServiceTypeId]: {
|
|
1746
|
+
readonly id: Id;
|
|
1747
|
+
};
|
|
1699
1748
|
}
|
|
1700
|
-
type FetchWorkerOptions<RRuntime, REvent = never, EventLayerError = never> = Omit<WorkerOptions<RRuntime, REvent, EventLayerError, Record<never, never>>, "rpc"> & {
|
|
1701
|
-
readonly rpc?: never;
|
|
1702
|
-
};
|
|
1703
|
-
/**
|
|
1704
|
-
* Cloudflare `WorkerEntrypoint` constructor produced by {@link make}.
|
|
1705
|
-
*/
|
|
1706
|
-
type WorkerClass<Rpc extends WorkerRpc<ROut>, ROut> = new (ctx: globalThis.ExecutionContext, env: WorkerEnv) => WorkerEntrypoint<WorkerEnv> & {
|
|
1707
|
-
fetch(request: Request): Promise<Response>;
|
|
1708
|
-
queue(batch: globalThis.MessageBatch): Promise<void>;
|
|
1709
|
-
} & WorkerRpcShape<Rpc, ROut>;
|
|
1710
1749
|
/**
|
|
1711
|
-
*
|
|
1750
|
+
* Creates a typed D1 service tag plus Effect helpers.
|
|
1712
1751
|
*/
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1752
|
+
declare const make$8: <Id extends string>(id: Id, definition: D1Definition) => BindingService<D1Service<Id>, Id, D1Database> & {
|
|
1753
|
+
"~effect-cf/D1": "~effect-cf/D1";
|
|
1754
|
+
definition: D1Definition;
|
|
1755
|
+
sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer<D1Client.D1Client | SqlClient.SqlClient, Config.ConfigError | BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1756
|
+
};
|
|
1716
1757
|
/**
|
|
1717
|
-
*
|
|
1758
|
+
* Builds a D1 service around a Cloudflare D1 database binding.
|
|
1718
1759
|
*
|
|
1719
|
-
* The
|
|
1720
|
-
* for
|
|
1721
|
-
* isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
|
|
1722
|
-
* for resources that must be finalized per event.
|
|
1760
|
+
* The returned service exposes the raw `D1Database` binding and `sqlLayer(...)`
|
|
1761
|
+
* for providing `effect/unstable/sql` via `@effect/sql-d1`.
|
|
1723
1762
|
*
|
|
1724
1763
|
* @example
|
|
1725
1764
|
* ```ts
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
* })
|
|
1729
|
-
* ```
|
|
1730
|
-
*/
|
|
1731
|
-
declare function make$8<ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, fetch: WorkerHandler<ROut>): WorkerClass<Record<never, never>, ROut>;
|
|
1732
|
-
declare function make$8<ROut, LayerError, REvent = never, EventLayerError = never, const Rpc extends WorkerRpc<ROut | REvent> = Record<never, never>>(layer: Layer.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: WorkerOptions<ROut, REvent, EventLayerError, Rpc>): WorkerClass<Rpc, ROut | REvent>;
|
|
1733
|
-
/**
|
|
1734
|
-
* Creates an `ExportedHandler`-compatible `{ fetch }` object backed by
|
|
1735
|
-
* {@link make}.
|
|
1765
|
+
* class TodoDatabase extends D1.Service<TodoDatabase>()("TodoDatabase", {
|
|
1766
|
+
* binding: "TODO_DB",
|
|
1767
|
+
* }) {}
|
|
1736
1768
|
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1739
|
-
* services (`Worker.ExecutionContext`, `Worker.WorkerContext`) are still
|
|
1740
|
-
* provided fresh for every request. Layer finalizers do not run when the
|
|
1741
|
-
* isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
|
|
1742
|
-
* for resources that must be finalized per event.
|
|
1769
|
+
* const SqlLive = TodoDatabase.sqlLayer();
|
|
1770
|
+
* ```
|
|
1743
1771
|
*/
|
|
1744
|
-
declare const
|
|
1772
|
+
declare const Service: <Self>() => <Id extends string>(id: Id, definition: D1Definition) => BindingService<Self, Id, D1Database> & {
|
|
1773
|
+
"~effect-cf/D1": "~effect-cf/D1";
|
|
1774
|
+
definition: D1Definition;
|
|
1775
|
+
sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer<D1Client.D1Client | SqlClient.SqlClient, Config.ConfigError | BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1776
|
+
};
|
|
1745
1777
|
declare namespace DurableObjectNamespace_d_exports {
|
|
1746
1778
|
export { DurableObjectFetchError, DurableObjectNamespaceBindingDefinition, DurableObjectNamespaceClient, DurableObjectNamespaceDefinition, DurableObjectNamespaceEffectClient, DurableObjectNamespaceStaticClient, DurableObjectRpcError, DurableObjectStubClient, isDurableObjectNamespaceClient, layer$8 as layer, makeClient$6 as makeClient, makeDirectMethods };
|
|
1747
1779
|
}
|