effect-cf 0.25.3 → 0.27.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.
@@ -0,0 +1,8 @@
1
+ //#region src/internal/ComputerWorkspaceHostRegistry.ts
2
+ const hosts = /* @__PURE__ */ new WeakMap();
3
+ const register = (state, host) => {
4
+ hosts.set(state, host);
5
+ };
6
+ const lookup = (state) => hosts.get(state);
7
+ //#endregion
8
+ export { register as n, lookup as t };
@@ -1,51 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Cause, Config, ConfigProvider, Context, Data, Effect, Exit, Option, Predicate, Result, Schema } from "effect";
3
- //#region src/Environment.ts
4
- var Environment_exports = /* @__PURE__ */ __exportAll({
5
- WorkerConfig: () => WorkerConfig,
6
- WorkerEnvironment: () => WorkerEnvironment
7
- });
8
- /**
9
- * Context service for reading worker bindings from the current `env` object.
10
- */
11
- var WorkerEnvironment = class extends Context.Service()("effect-cf/WorkerEnvironment") {};
12
- let WorkerConfig;
13
- (function(_WorkerConfig) {
14
- _WorkerConfig.string = (name) => Config.string(name);
15
- _WorkerConfig.redacted = (name) => Config.redacted(name);
16
- _WorkerConfig.number = (name) => Config.number(name);
17
- _WorkerConfig.integer = (name) => Config.int(name);
18
- _WorkerConfig.boolean = (name) => Config.boolean(name);
19
- const providerFromEnv = _WorkerConfig.providerFromEnv = (env, options) => {
20
- const record = {};
21
- for (const [key, value] of Object.entries(env)) if (Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) record[key] = String(value);
22
- return ConfigProvider.fromEnvRecord(record, options);
23
- };
24
- const providerWith = _WorkerConfig.providerWith = (makeProvider) => Effect.map(WorkerEnvironment, makeProvider);
25
- const provider = _WorkerConfig.provider = providerWith(providerFromEnv);
26
- _WorkerConfig.providerLayer = ConfigProvider.layer(provider);
27
- _WorkerConfig.layerWith = (makeProvider) => ConfigProvider.layer(providerWith(makeProvider));
28
- })(WorkerConfig || (WorkerConfig = {}));
29
- //#endregion
30
- //#region src/internal/ErrorMessage.ts
31
- /**
32
- * Renders the most useful human-readable description of an unknown `cause`
33
- * for use in tagged error `message` getters.
34
- */
35
- const causeMessage = (cause) => {
36
- if (typeof cause === "object" && cause !== null) {
37
- const message = Reflect.get(cause, "message");
38
- if (typeof message === "string" && message.length > 0) return message;
39
- }
40
- try {
41
- return String(cause);
42
- } catch {
43
- return "unknown cause";
44
- }
45
- };
46
- /** Renders a violation list as a single `path: message; ...` line. */
47
- const violationsMessage = (violations) => violations.map((violation) => `${violation.path}: ${violation.message}`).join("; ");
48
- //#endregion
2
+ import { t as causeMessage } from "./ErrorMessage-_lg53p3W.mjs";
3
+ import { Cause, Context, Data, Effect, Exit, Option, Result, Schema } from "effect";
49
4
  //#region src/DurableObjectStorage.ts
50
5
  var DurableObjectStorage_exports = /* @__PURE__ */ __exportAll({
51
6
  StorageOperationError: () => StorageOperationError,
@@ -385,4 +340,4 @@ const runPromiseExitPreservingTypedFailures = async (context, effect) => {
385
340
  return exit;
386
341
  };
387
342
  //#endregion
388
- export { DurableObjectWebSocket_exports as a, causeMessage as c, WorkerConfig as d, WorkerEnvironment as f, fromExecutionContext as i, violationsMessage as l, DurableObjectState_exports as n, fromWebSocket as o, fromDurableObjectState as r, DurableObjectStorage_exports as s, DurableObjectState as t, Environment_exports as u };
343
+ export { DurableObjectWebSocket_exports as a, fromExecutionContext as i, DurableObjectState_exports as n, fromWebSocket as o, fromDurableObjectState as r, DurableObjectStorage_exports as s, DurableObjectState as t };
@@ -379,7 +379,7 @@ declare const encodeSuccess: <const Self extends Definition$3.Any, MethodName ex
379
379
  declare const decodeSuccess: <const Self extends Definition$3.Any, MethodName extends Definition$3.MethodNames<Self>>(definition: Self, methodName: MethodName, value: unknown) => Effect.Effect<Method$2.Success<Self["methods"][MethodName]>, RpcSuccessDecodeError>;
380
380
  declare const make$3: <Id extends string, const MethodsShape extends Methods$1>(id: Id, methods: MethodsShape) => Definition$3<Id, MethodsShape>;
381
381
  declare namespace QueueBinding_d_exports {
382
- export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$2 as layer, makeClient$2 as makeClient };
382
+ export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer$1 as layer, makeClient$1 as makeClient };
383
383
  }
384
384
  type QueueSendOptions = CloudflareQueueSendOptions;
385
385
  type QueueSendResponse = CloudflareQueueSendResponse;
@@ -410,8 +410,8 @@ declare class QueueOperationError extends QueueOperationError_base<{
410
410
  readonly message: string;
411
411
  }> {}
412
412
  declare const isQueue: <Body>(value: unknown) => value is QueueProducer<Body>;
413
- declare const makeClient$2: <Message extends ServiceFreeSchema$1>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<Schema.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
414
- declare const layer$2: <Self, Message extends ServiceFreeSchema$1>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
413
+ declare const makeClient$1: <Message extends ServiceFreeSchema$1>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<Schema.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
414
+ declare const layer$1: <Self, Message extends ServiceFreeSchema$1>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
415
415
  declare namespace QueueDefinition_d_exports {
416
416
  export { Definition$2 as Definition, Handler$1 as Handler, LayerOptions$2 as LayerOptions, Options$2 as Options, Queue$1 as Queue, Tag$2 as Tag, TagClass$2 as TagClass, implement$2 as implement, make$2 as make };
417
417
  }
@@ -516,7 +516,7 @@ type AsyncMethodArgs<Api, Method extends keyof Api> = Api[Method] extends ((...a
516
516
  type AsyncMethodSuccess<Api, Method extends keyof Api> = Api[Method] extends ((...args: AnyArgs) => Promise<infer A>) ? A : never;
517
517
  type AsyncMethodCloudflareReturn<Api, Method extends keyof Api> = Result$1<AsyncMethodSuccess<Api, Method>>;
518
518
  declare namespace ServiceBinding_d_exports {
519
- export { Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer$1 as layer, makeClient$1 as makeClient, makeDirectMethods };
519
+ export { Service, ServiceBindingClient, ServiceBindingDefinition, ServiceBindingEffectClient, ServiceBindingFetchError, ServiceBindingRpcError, ServiceBindingStaticClient, ServiceFetcher, isServiceBindingClient, layer, makeClient, makeDirectMethods };
520
520
  }
521
521
  declare const TypeId: "effect-cf/ServiceBinding";
522
522
  /**
@@ -666,8 +666,8 @@ type ServiceBindingStaticClient<R, Api extends object, Definition$7 extends Defi
666
666
  readonly scopedCall: <Method extends ServiceMethodKey<Api>>(method: Method, ...args: ServiceMethodArgs<Api, Method>) => Effect.Effect<Awaited<ServiceMethodSuccess<Api, Method>>, unknown, Scope.Scope | R>;
667
667
  };
668
668
  declare const isServiceBindingClient: <Api extends object>(value: unknown) => value is ServiceBindingClient<Api>;
669
- declare const makeClient$1: <Api extends object, const Definition$8 extends Definition.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition$8>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition$8>);
670
- declare const layer$1: <Self, Api extends object, const Definition$12 extends Definition.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition$12>>, definition: ServiceBindingDefinition<Definition$12>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
669
+ declare const makeClient: <Api extends object, const Definition$8 extends Definition.Any | undefined = undefined>(definition: ServiceBindingDefinition<Definition$8>) => ((service: ServiceBindingClient<Api>) => ServiceBindingEffectClient<Api, Definition$8>);
670
+ declare const layer: <Self, Api extends object, const Definition$12 extends Definition.Any | undefined = undefined>(tag: Context.Service<Self, ServiceBindingEffectClient<Api, Definition$12>>, definition: ServiceBindingDefinition<Definition$12>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
671
671
  /**
672
672
  * Creates a typed Effect service for a Worker service binding.
673
673
  *
@@ -1008,79 +1008,5 @@ declare class DurableObjectState extends DurableObjectState_base {}
1008
1008
  * Wraps a native Cloudflare `DurableObjectState` as a {@link DurableObjectStateService}.
1009
1009
  */
1010
1010
  declare const fromDurableObjectState: (state: globalThis.DurableObjectState) => DurableObjectStateService;
1011
- declare namespace WorkflowBinding_d_exports {
1012
- export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer, makeClient };
1013
- }
1014
- type WorkflowInstanceCreateOptions<Payload> = Omit<CloudflareWorkflowInstanceCreateOptions<Payload>, "params">;
1015
- type WorkflowInstanceCreateBatchOptions<Payload, EncodedPayload = unknown> = ReadonlyArray<{
1016
- readonly payload: Payload;
1017
- } & WorkflowInstanceCreateOptions<EncodedPayload>>;
1018
- interface WorkflowInstanceRestartOptions {
1019
- readonly from?: {
1020
- readonly name?: string;
1021
- readonly count?: number;
1022
- readonly type?: string;
1023
- };
1024
- }
1025
- type WorkflowInstanceStatusName = CloudflareInstanceStatus["status"];
1026
- interface WorkflowInstanceStatus<Result> {
1027
- readonly status: WorkflowInstanceStatusName;
1028
- readonly output: Option.Option<Result>;
1029
- readonly error: Option.Option<{
1030
- readonly name: string;
1031
- readonly message: string;
1032
- }>;
1033
- }
1034
- interface WorkflowInstance<Result> {
1035
- readonly raw: CloudflareWorkflowInstance;
1036
- readonly id: string;
1037
- readonly pause: Effect.Effect<void, WorkflowOperationError>;
1038
- readonly resume: Effect.Effect<void, WorkflowOperationError>;
1039
- readonly terminate: Effect.Effect<void, WorkflowOperationError>;
1040
- readonly restart: (options?: WorkflowInstanceRestartOptions) => Effect.Effect<void, WorkflowOperationError>;
1041
- readonly status: Effect.Effect<WorkflowInstanceStatus<Result>, WorkflowOperationError | WorkflowResultDecodeError>;
1042
- readonly sendEvent: (event: WorkflowInstanceEvent) => Effect.Effect<void, WorkflowOperationError>;
1043
- }
1044
- interface WorkflowInstanceEvent {
1045
- readonly type: string;
1046
- readonly payload: unknown;
1047
- }
1048
- interface WorkflowBindingDefinition<Payload extends ServiceFreeSchema$1, Result extends ServiceFreeSchema$1> {
1049
- /** Binding name as configured in `wrangler.jsonc`. */
1050
- readonly binding: string;
1051
- /** Codec used to encode payloads passed to `Workflow.create`. */
1052
- readonly payload: Payload;
1053
- /** Codec used to decode completed workflow status output. */
1054
- readonly result: Result;
1055
- }
1056
- interface WorkflowBindingClient<Payload extends ServiceFreeSchema$1, Result extends ServiceFreeSchema$1> {
1057
- readonly create: (payload: Schema.Schema.Type<Payload>, options?: WorkflowInstanceCreateOptions<Schema.Codec.Encoded<Payload>>) => Effect.Effect<WorkflowInstance<Schema.Schema.Type<Result>>, WorkflowOperationError | Schema.SchemaError>;
1058
- readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions<Schema.Schema.Type<Payload>, Schema.Codec.Encoded<Payload>>) => Effect.Effect<ReadonlyArray<WorkflowInstance<Schema.Schema.Type<Result>>>, WorkflowOperationError | Schema.SchemaError>;
1059
- readonly get: (instanceId: string) => Effect.Effect<WorkflowInstance<Schema.Schema.Type<Result>>, WorkflowOperationError>;
1060
- readonly rawUnsafe: Effect.Effect<CloudflareWorkflow<Schema.Codec.Encoded<Payload>>>;
1061
- }
1062
- declare const WorkflowOperationError_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 & {
1063
- readonly _tag: "WorkflowOperationError";
1064
- } & Readonly<A>;
1065
- declare class WorkflowOperationError extends WorkflowOperationError_base<{
1066
- readonly binding: string;
1067
- readonly operation: string;
1068
- readonly cause: unknown;
1069
- }> {
1070
- get message(): string;
1071
- }
1072
- declare const WorkflowResultDecodeError_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 & {
1073
- readonly _tag: "WorkflowResultDecodeError";
1074
- } & Readonly<A>;
1075
- declare class WorkflowResultDecodeError extends WorkflowResultDecodeError_base<{
1076
- readonly binding: string;
1077
- readonly instanceId: string;
1078
- readonly cause: unknown;
1079
- }> {
1080
- get message(): string;
1081
- }
1082
- declare const isWorkflow: <Payload>(value: unknown) => value is CloudflareWorkflow<Payload>;
1083
- declare const makeClient: <Payload extends ServiceFreeSchema$1, Result extends ServiceFreeSchema$1>(definition: WorkflowBindingDefinition<Payload, Result>) => ((workflow: CloudflareWorkflow<Schema.Codec.Encoded<Payload>>) => WorkflowBindingClient<Payload, Result>);
1084
- declare const layer: <Self, Payload extends ServiceFreeSchema$1, Result extends ServiceFreeSchema$1>(tag: Context.Service<Self, WorkflowBindingClient<Payload, Result>>, definition: WorkflowBindingDefinition<Payload, Result>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
1085
1011
  //#endregion
1086
- export { Rpc_d_exports as A, QueueBinding_d_exports as C, RpcDefinition_d_exports as D, ReservedMethodName$3 as E, DurableWebSocket as M, DurableObjectStorage_d_exports as N, ServiceFreeSchema$1 as O, StorageOperationError as P, QueueDefinition_d_exports as S, Method$2 as T, AsyncMethodArgs as _, WorkflowInstanceCreateOptions as a, AsyncMethodSuccess as b, DurableObjectState as c, ExecutionContext as d, NativeRequest as f, ServiceBinding_d_exports as g, WorkerDefinition_d_exports as h, WorkflowInstanceCreateBatchOptions as i, DurableObjectWebSocket_d_exports as j, Provider as k, DurableObjectStateService as l, Worker_d_exports as m, WorkflowBinding_d_exports as n, WorkflowInstanceStatusName as o, WorkerContext as p, WorkflowInstance as r, WorkflowOperationError as s, WorkflowBindingClient as t, DurableObjectState_d_exports as u, AsyncMethodCloudflareReturn as v, Definition$3 as w, Queue_d_exports as x, AsyncMethodKey as y };
1012
+ export { Rpc_d_exports as C, StorageOperationError as D, DurableObjectStorage_d_exports as E, Provider as S, DurableWebSocket as T, Definition$3 as _, NativeRequest as a, RpcDefinition_d_exports as b, WorkerDefinition_d_exports as c, AsyncMethodCloudflareReturn as d, AsyncMethodKey as f, QueueBinding_d_exports as g, QueueDefinition_d_exports as h, ExecutionContext as i, ServiceBinding_d_exports as l, Queue_d_exports as m, DurableObjectStateService as n, WorkerContext as o, AsyncMethodSuccess as p, DurableObjectState_d_exports as r, Worker_d_exports as s, DurableObjectState as t, AsyncMethodArgs as u, Method$2 as v, DurableObjectWebSocket_d_exports as w, ServiceFreeSchema$1 as x, ReservedMethodName$3 as y };
@@ -0,0 +1,49 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { Config, ConfigProvider, Context, Effect, Predicate } from "effect";
3
+ //#region src/Environment.ts
4
+ var Environment_exports = /* @__PURE__ */ __exportAll({
5
+ WorkerConfig: () => WorkerConfig,
6
+ WorkerEnvironment: () => WorkerEnvironment
7
+ });
8
+ /**
9
+ * Context service for reading worker bindings from the current `env` object.
10
+ */
11
+ var WorkerEnvironment = class extends Context.Service()("effect-cf/WorkerEnvironment") {};
12
+ let WorkerConfig;
13
+ (function(_WorkerConfig) {
14
+ _WorkerConfig.string = (name) => Config.string(name);
15
+ _WorkerConfig.redacted = (name) => Config.redacted(name);
16
+ _WorkerConfig.number = (name) => Config.number(name);
17
+ _WorkerConfig.integer = (name) => Config.int(name);
18
+ _WorkerConfig.boolean = (name) => Config.boolean(name);
19
+ const providerFromEnv = _WorkerConfig.providerFromEnv = (env, options) => {
20
+ const record = {};
21
+ for (const [key, value] of Object.entries(env)) if (Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) record[key] = String(value);
22
+ return ConfigProvider.fromEnvRecord(record, options);
23
+ };
24
+ const providerWith = _WorkerConfig.providerWith = (makeProvider) => Effect.map(WorkerEnvironment, makeProvider);
25
+ const provider = _WorkerConfig.provider = providerWith(providerFromEnv);
26
+ _WorkerConfig.providerLayer = ConfigProvider.layer(provider);
27
+ _WorkerConfig.layerWith = (makeProvider) => ConfigProvider.layer(providerWith(makeProvider));
28
+ })(WorkerConfig || (WorkerConfig = {}));
29
+ //#endregion
30
+ //#region src/internal/ErrorMessage.ts
31
+ /**
32
+ * Renders the most useful human-readable description of an unknown `cause`
33
+ * for use in tagged error `message` getters.
34
+ */
35
+ const causeMessage = (cause) => {
36
+ if (typeof cause === "object" && cause !== null) {
37
+ const message = Reflect.get(cause, "message");
38
+ if (typeof message === "string" && message.length > 0) return message;
39
+ }
40
+ try {
41
+ return String(cause);
42
+ } catch {
43
+ return "unknown cause";
44
+ }
45
+ };
46
+ /** Renders a violation list as a single `path: message; ...` line. */
47
+ const violationsMessage = (violations) => violations.map((violation) => `${violation.path}: ${violation.message}`).join("; ");
48
+ //#endregion
49
+ export { WorkerEnvironment as a, WorkerConfig as i, violationsMessage as n, Environment_exports as r, causeMessage as t };
package/dist/Vitest.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { c as WorkerEnvironment, s as WorkerEnv } from "./Binding-COCtoJXa.mjs";
2
- import { c as DurableObjectState, l as DurableObjectStateService, o as WorkflowInstanceStatusName } from "./WorkflowBinding-D5iWzCUa.mjs";
2
+ import { n as DurableObjectStateService, t as DurableObjectState } from "./DurableObjectState-biHrHwrh.mjs";
3
+ import { o as WorkflowInstanceStatusName } from "./WorkflowBinding-zlRPCXVf.mjs";
3
4
  import { Effect, Layer } from "effect";
4
5
  import { DurableObject } from "cloudflare:workers";
5
6
  import { adminSecretsStore as adminSecretsStore$1, getQueueResult, introspectWorkflow as introspectWorkflow$1, introspectWorkflowInstance as introspectWorkflowInstance$1 } from "cloudflare:test";
package/dist/Vitest.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { d as WorkerConfig, f as WorkerEnvironment, r as fromDurableObjectState, t as DurableObjectState } from "./DurableObjectState-CEh0DVw7.mjs";
1
+ import { a as WorkerEnvironment, i as WorkerConfig } from "./ErrorMessage-_lg53p3W.mjs";
2
+ import { r as fromDurableObjectState, t as DurableObjectState } from "./DurableObjectState-Dux8KfjG.mjs";
2
3
  import { ConfigProvider, Effect, Exit, Layer } from "effect";
3
4
  import { env } from "cloudflare:workers";
4
5
  import { abortAllDurableObjects as abortAllDurableObjects$1, adminSecretsStore as adminSecretsStore$1, applyD1Migrations as applyD1Migrations$1, createExecutionContext, createMessageBatch, createPagesEventContext, createScheduledController, evictAllDurableObjects as evictAllDurableObjects$1, evictDurableObject as evictDurableObject$1, getQueueResult, introspectWorkflow as introspectWorkflow$1, introspectWorkflowInstance as introspectWorkflowInstance$1, listDurableObjectIds as listDurableObjectIds$1, reset as reset$1, runDurableObjectAlarm as runDurableObjectAlarm$1, runInDurableObject as runInDurableObject$1, waitOnExecutionContext } from "cloudflare:test";
@@ -0,0 +1,79 @@
1
+ import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
2
+ import { x as ServiceFreeSchema } from "./DurableObjectState-biHrHwrh.mjs";
3
+ import { Context, Effect, Option, Schema } from "effect";
4
+ declare namespace WorkflowBinding_d_exports {
5
+ export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer, makeClient };
6
+ }
7
+ type WorkflowInstanceCreateOptions<Payload> = Omit<CloudflareWorkflowInstanceCreateOptions<Payload>, "params">;
8
+ type WorkflowInstanceCreateBatchOptions<Payload, EncodedPayload = unknown> = ReadonlyArray<{
9
+ readonly payload: Payload;
10
+ } & WorkflowInstanceCreateOptions<EncodedPayload>>;
11
+ interface WorkflowInstanceRestartOptions {
12
+ readonly from?: {
13
+ readonly name?: string;
14
+ readonly count?: number;
15
+ readonly type?: string;
16
+ };
17
+ }
18
+ type WorkflowInstanceStatusName = CloudflareInstanceStatus["status"];
19
+ interface WorkflowInstanceStatus<Result> {
20
+ readonly status: WorkflowInstanceStatusName;
21
+ readonly output: Option.Option<Result>;
22
+ readonly error: Option.Option<{
23
+ readonly name: string;
24
+ readonly message: string;
25
+ }>;
26
+ }
27
+ interface WorkflowInstance<Result> {
28
+ readonly raw: CloudflareWorkflowInstance;
29
+ readonly id: string;
30
+ readonly pause: Effect.Effect<void, WorkflowOperationError>;
31
+ readonly resume: Effect.Effect<void, WorkflowOperationError>;
32
+ readonly terminate: Effect.Effect<void, WorkflowOperationError>;
33
+ readonly restart: (options?: WorkflowInstanceRestartOptions) => Effect.Effect<void, WorkflowOperationError>;
34
+ readonly status: Effect.Effect<WorkflowInstanceStatus<Result>, WorkflowOperationError | WorkflowResultDecodeError>;
35
+ readonly sendEvent: (event: WorkflowInstanceEvent) => Effect.Effect<void, WorkflowOperationError>;
36
+ }
37
+ interface WorkflowInstanceEvent {
38
+ readonly type: string;
39
+ readonly payload: unknown;
40
+ }
41
+ interface WorkflowBindingDefinition<Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema> {
42
+ /** Binding name as configured in `wrangler.jsonc`. */
43
+ readonly binding: string;
44
+ /** Codec used to encode payloads passed to `Workflow.create`. */
45
+ readonly payload: Payload;
46
+ /** Codec used to decode completed workflow status output. */
47
+ readonly result: Result;
48
+ }
49
+ interface WorkflowBindingClient<Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema> {
50
+ readonly create: (payload: Schema.Schema.Type<Payload>, options?: WorkflowInstanceCreateOptions<Schema.Codec.Encoded<Payload>>) => Effect.Effect<WorkflowInstance<Schema.Schema.Type<Result>>, WorkflowOperationError | Schema.SchemaError>;
51
+ readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions<Schema.Schema.Type<Payload>, Schema.Codec.Encoded<Payload>>) => Effect.Effect<ReadonlyArray<WorkflowInstance<Schema.Schema.Type<Result>>>, WorkflowOperationError | Schema.SchemaError>;
52
+ readonly get: (instanceId: string) => Effect.Effect<WorkflowInstance<Schema.Schema.Type<Result>>, WorkflowOperationError>;
53
+ readonly rawUnsafe: Effect.Effect<CloudflareWorkflow<Schema.Codec.Encoded<Payload>>>;
54
+ }
55
+ declare const WorkflowOperationError_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 & {
56
+ readonly _tag: "WorkflowOperationError";
57
+ } & Readonly<A>;
58
+ declare class WorkflowOperationError extends WorkflowOperationError_base<{
59
+ readonly binding: string;
60
+ readonly operation: string;
61
+ readonly cause: unknown;
62
+ }> {
63
+ get message(): string;
64
+ }
65
+ declare const WorkflowResultDecodeError_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 & {
66
+ readonly _tag: "WorkflowResultDecodeError";
67
+ } & Readonly<A>;
68
+ declare class WorkflowResultDecodeError extends WorkflowResultDecodeError_base<{
69
+ readonly binding: string;
70
+ readonly instanceId: string;
71
+ readonly cause: unknown;
72
+ }> {
73
+ get message(): string;
74
+ }
75
+ declare const isWorkflow: <Payload>(value: unknown) => value is CloudflareWorkflow<Payload>;
76
+ declare const makeClient: <Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema>(definition: WorkflowBindingDefinition<Payload, Result>) => ((workflow: CloudflareWorkflow<Schema.Codec.Encoded<Payload>>) => WorkflowBindingClient<Payload, Result>);
77
+ declare const layer: <Self, Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema>(tag: Context.Service<Self, WorkflowBindingClient<Payload, Result>>, definition: WorkflowBindingDefinition<Payload, Result>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
78
+ //#endregion
79
+ export { WorkflowInstanceCreateOptions as a, WorkflowInstanceCreateBatchOptions as i, WorkflowBinding_d_exports as n, WorkflowInstanceStatusName as o, WorkflowInstance as r, WorkflowOperationError as s, WorkflowBindingClient as t };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { a as Environment_d_exports, c as WorkerEnvironment, i as Binding_d_exports, n as BindingService, o as WorkerConfig, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-COCtoJXa.mjs";
2
+ import { l as Artifacts_d_exports } from "./Artifacts-DcoXcRP5.mjs";
3
+ import { C as Rpc_d_exports, D as StorageOperationError, E as DurableObjectStorage_d_exports, S as Provider, T as DurableWebSocket, _ as Definition$4, a as NativeRequest, b as RpcDefinition_d_exports, c as WorkerDefinition_d_exports, d as AsyncMethodCloudflareReturn, f as AsyncMethodKey, g as QueueBinding_d_exports, h as QueueDefinition_d_exports, i as ExecutionContext, l as ServiceBinding_d_exports, m as Queue_d_exports, o as WorkerContext, p as AsyncMethodSuccess, r as DurableObjectState_d_exports, s as Worker_d_exports, t as DurableObjectState, u as AsyncMethodArgs, v as Method$2, w as DurableObjectWebSocket_d_exports, x as ServiceFreeSchema$1, y as ReservedMethodName$2 } from "./DurableObjectState-biHrHwrh.mjs";
2
4
  import { t as Hyperdrive_d_exports } from "./Hyperdrive-6p59yyVk.mjs";
3
- import { A as Rpc_d_exports, C as QueueBinding_d_exports, D as RpcDefinition_d_exports, E as ReservedMethodName$2, M as DurableWebSocket, N as DurableObjectStorage_d_exports, O as ServiceFreeSchema$1, P as StorageOperationError, S as QueueDefinition_d_exports, T as Method$2, _ as AsyncMethodArgs, a as WorkflowInstanceCreateOptions, b as AsyncMethodSuccess, c as DurableObjectState, d as ExecutionContext, f as NativeRequest, g as ServiceBinding_d_exports, h as WorkerDefinition_d_exports, i as WorkflowInstanceCreateBatchOptions, j as DurableObjectWebSocket_d_exports, k as Provider, m as Worker_d_exports, n as WorkflowBinding_d_exports, p as WorkerContext, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient, u as DurableObjectState_d_exports, v as AsyncMethodCloudflareReturn, w as Definition$4, x as Queue_d_exports, y as AsyncMethodKey } from "./WorkflowBinding-D5iWzCUa.mjs";
5
+ import { a as WorkflowInstanceCreateOptions, i as WorkflowInstanceCreateBatchOptions, n as WorkflowBinding_d_exports, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient } from "./WorkflowBinding-zlRPCXVf.mjs";
4
6
  import { Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
5
7
  import { Headers as Headers$1, HttpClient, HttpClientResponse } from "effect/unstable/http";
6
8
  import { OtlpExporter } from "effect/unstable/observability";
@@ -2040,6 +2042,82 @@ declare const makeClient: (definition: VectorizeDefinition) => (index: Vectorize
2040
2042
  declare const layer: <Self>(tag: Context.Service<Self, VectorizeClient>, definition: VectorizeDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
2041
2043
  declare const make$2: <Id extends string>(id: Id) => TagClass$2<VectorizeService<Id>, Id>;
2042
2044
  declare const Tag$3: <Self>() => <Id extends string>(id: Id) => TagClass$2<Self, Id>;
2045
+ declare namespace WebTransport_d_exports {
2046
+ export { Capabilities, InboundTransport, WebTransportCapability, WebTransportUnsupportedError, capabilities, inboundSessionsUnsupported, inboundTransport, isHttp3 };
2047
+ }
2048
+ declare const InboundTransport_base: Schema.Class<InboundTransport, Schema.Struct<{
2049
+ /** The HTTP protocol the client used, e.g. `"HTTP/2"` or `"HTTP/3"`. */
2050
+ readonly httpProtocol: Schema.String;
2051
+ /** Client round-trip time; only present for QUIC (HTTP/3) connections. */
2052
+ readonly clientQuicRtt: Schema.optional<Schema.Number>;
2053
+ /** Client round-trip time; only present for TCP (HTTP/1.x, HTTP/2) connections. */
2054
+ readonly clientTcpRtt: Schema.optional<Schema.Number>;
2055
+ }>, {}>;
2056
+ /**
2057
+ * Metadata Cloudflare's edge reports about the inbound client connection.
2058
+ *
2059
+ * `httpProtocol` and `clientTcpRtt` are declared in
2060
+ * `@cloudflare/workers-types`; `clientQuicRtt` is documented by Cloudflare
2061
+ * ("only present when the client connected over QUIC (HTTP/3)") but not yet
2062
+ * present in the published types, so it is decoded from the open
2063
+ * `Record<string, unknown>` side of `request.cf`.
2064
+ */
2065
+ declare class InboundTransport extends InboundTransport_base {}
2066
+ /**
2067
+ * Decodes the inbound transport metadata from `request.cf`.
2068
+ *
2069
+ * Returns `None` when the metadata is absent (for example in local `wrangler
2070
+ * dev` or when a Worker invokes another Worker directly) or does not match
2071
+ * the expected shape.
2072
+ */
2073
+ declare const inboundTransport: (request: Pick<CloudflareRequest, "cf">) => Option.Option<InboundTransport>;
2074
+ /**
2075
+ * Returns `true` when the client reached Cloudflare's edge over QUIC
2076
+ * (HTTP/3). Prefers the documented QUIC signal (`clientQuicRtt` is only
2077
+ * present for QUIC connections) and falls back to the `httpProtocol` string.
2078
+ *
2079
+ * Note this describes the browser→edge hop only: the edge always terminates
2080
+ * QUIC, and the Worker still handles an ordinary `fetch` Request.
2081
+ */
2082
+ declare const isHttp3: (transport: InboundTransport) => boolean;
2083
+ /** WebTransport-related capabilities of the current Workers runtime. */
2084
+ interface Capabilities {
2085
+ /**
2086
+ * Whether Worker code can accept inbound WebTransport sessions. Typed as
2087
+ * literally `false`: no such runtime API exists (cloudflare/workerd#6451),
2088
+ * so this can only change through a breaking, deliberate update when
2089
+ * Cloudflare ships one.
2090
+ */
2091
+ readonly inboundSessions: false;
2092
+ /**
2093
+ * Whether the runtime exposes a client `WebTransport` constructor global.
2094
+ * Feature-detected at runtime; `false` in workerd today, which has no
2095
+ * QUIC stack.
2096
+ */
2097
+ readonly outboundSessions: boolean;
2098
+ }
2099
+ /** Feature-detects the WebTransport capabilities of the current runtime. */
2100
+ declare const capabilities: Effect.Effect<Capabilities>;
2101
+ /** WebTransport capability missing from the current Workers runtime. */
2102
+ type WebTransportCapability = "inbound-sessions" | "outbound-sessions";
2103
+ declare const WebTransportUnsupportedError_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 & {
2104
+ readonly _tag: "WebTransportUnsupportedError";
2105
+ } & Readonly<A>;
2106
+ /** Raised when a WebTransport capability is unavailable in this runtime. */
2107
+ declare class WebTransportUnsupportedError extends WebTransportUnsupportedError_base<{
2108
+ readonly capability: WebTransportCapability;
2109
+ }> {
2110
+ get message(): string;
2111
+ }
2112
+ /**
2113
+ * The explicit typed boundary for inbound WebTransport sessions.
2114
+ *
2115
+ * Always fails with {@link WebTransportUnsupportedError} today. Route the
2116
+ * code path that would accept a session through this effect so the
2117
+ * limitation is visible in the type system and greppable when Cloudflare
2118
+ * ships a real API.
2119
+ */
2120
+ declare const inboundSessionsUnsupported: Effect.Effect<never, WebTransportUnsupportedError>;
2043
2121
  declare namespace WorkflowDefinition_d_exports {
2044
2122
  export { Definition$1 as Definition, Handler$1 as Handler, LayerOptions$1 as LayerOptions, Options$1 as Options, Tag$2 as Tag, TagClass$1 as TagClass, Workflow, implement$1 as implement, make$1 as make };
2045
2123
  }
@@ -2147,4 +2225,4 @@ declare const implement: typeof implement$1;
2147
2225
  type Handler<ROut, Self extends Definition$1.Any> = Handler$1<ROut, Self>;
2148
2226
  type Options<ROut, Self extends Definition$1.Any> = Options$1<ROut, Self>;
2149
2227
  //#endregion
2150
- export { AiGateway_d_exports as AiGateway, AnalyticsEngine_d_exports as AnalyticsEngine, Binding_d_exports as Binding, BrowserRendering_d_exports as BrowserRendering, Cache_d_exports as Cache, CloudflareOtlp_d_exports as CloudflareOtlp, ContainerNamespace_d_exports as ContainerNamespace, D1_d_exports as D1, DurableObject_d_exports as DurableObject, DurableObjectAlarm_d_exports as DurableObjectAlarm, DurableObjectDefinition_d_exports as DurableObjectDefinition, DurableObjectNamespace_d_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_d_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_d_exports as DurableObjectSqlite, DurableObjectState_d_exports as DurableObjectState, DurableObjectStorage_d_exports as DurableObjectStorage, DurableObjectWebSocket_d_exports as DurableObjectWebSocket, Email_d_exports as Email, Environment_d_exports as Environment, Hyperdrive_d_exports as Hyperdrive, Images_d_exports as Images, Kv_d_exports as Kv, Queue_d_exports as Queue, QueueBinding_d_exports as QueueBinding, QueueDefinition_d_exports as QueueDefinition, R2_d_exports as R2, Rpc_d_exports as Rpc, RpcDefinition_d_exports as RpcDefinition, ServiceBinding_d_exports as ServiceBinding, Vectorize_d_exports as Vectorize, Worker_d_exports as Worker, WorkerConfig, WorkerDefinition_d_exports as WorkerDefinition, type WorkerEnv, WorkerEnvironment, WorkersAi_d_exports as WorkersAi, Workflow_d_exports as Workflow, WorkflowBinding_d_exports as WorkflowBinding, WorkflowDefinition_d_exports as WorkflowDefinition };
2228
+ export { AiGateway_d_exports as AiGateway, AnalyticsEngine_d_exports as AnalyticsEngine, Artifacts_d_exports as Artifacts, Binding_d_exports as Binding, BrowserRendering_d_exports as BrowserRendering, Cache_d_exports as Cache, CloudflareOtlp_d_exports as CloudflareOtlp, ContainerNamespace_d_exports as ContainerNamespace, D1_d_exports as D1, DurableObject_d_exports as DurableObject, DurableObjectAlarm_d_exports as DurableObjectAlarm, DurableObjectDefinition_d_exports as DurableObjectDefinition, DurableObjectNamespace_d_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_d_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_d_exports as DurableObjectSqlite, DurableObjectState_d_exports as DurableObjectState, DurableObjectStorage_d_exports as DurableObjectStorage, DurableObjectWebSocket_d_exports as DurableObjectWebSocket, Email_d_exports as Email, Environment_d_exports as Environment, Hyperdrive_d_exports as Hyperdrive, Images_d_exports as Images, Kv_d_exports as Kv, Queue_d_exports as Queue, QueueBinding_d_exports as QueueBinding, QueueDefinition_d_exports as QueueDefinition, R2_d_exports as R2, Rpc_d_exports as Rpc, RpcDefinition_d_exports as RpcDefinition, ServiceBinding_d_exports as ServiceBinding, Vectorize_d_exports as Vectorize, WebTransport_d_exports as WebTransport, Worker_d_exports as Worker, WorkerConfig, WorkerDefinition_d_exports as WorkerDefinition, type WorkerEnv, WorkerEnvironment, WorkersAi_d_exports as WorkersAi, Workflow_d_exports as Workflow, WorkflowBinding_d_exports as WorkflowBinding, WorkflowDefinition_d_exports as WorkflowDefinition };