effect-cf 0.39.1 → 0.40.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 +10 -0
- package/README.md +9 -1
- package/dist/index.d.mts +221 -182
- package/dist/index.mjs +472 -434
- package/package.json +1 -1
- package/src/DurableObject.ts +118 -28
- package/src/DurableObjectAlarm.ts +175 -40
- package/src/DurableObjectDefinition.ts +19 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# effect-cf
|
|
2
2
|
|
|
3
|
+
## 0.40.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#146](https://github.com/danieljvdm/effect-cf/pull/146) [`376c9cc`](https://github.com/danieljvdm/effect-cf/commit/376c9ccb16c7ee6a3d6ac2c6f8d6c91ad0b237fc) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Add schema-bound scheduling, cancellation, and transactions through `DurableObjectAlarm.Tag`. Register the service's complete `handlers(...)` implementation in a Durable Object's `alarms:` option, then yield the service to schedule work. Missing registration or handlers fail typechecking. Scheduling checks tag/payload pairs and schema-encodes payloads before storage.
|
|
8
|
+
|
|
9
|
+
Durable Object entrypoints provide registered alarm services to application layers and handlers. The raw scheduler is provided automatically and remains available for dynamic tags; existing explicit layers and handler-only `define(...)` calls remain supported.
|
|
10
|
+
|
|
11
|
+
Unknown stored alarm tags now report `StoredAlarmDecodeError` and follow the delivery failure policy instead of being silently acknowledged. Applications intentionally retiring tags can handle them through `onFailure`.
|
|
12
|
+
|
|
3
13
|
## 0.39.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -45,10 +45,18 @@ const greeting = Effect.gen(function* () {
|
|
|
45
45
|
|
|
46
46
|
Declare `SETTINGS` in `wrangler.jsonc` and pass `SettingsLive` to `Worker.make`. Other bindings use the same tag/layer pattern.
|
|
47
47
|
|
|
48
|
-
The [
|
|
48
|
+
The [document outbox example](https://github.com/danieljvdm/effect-cf/tree/main/examples/outbox) saves document revisions and their delivery alarms atomically, then archives them to R2 outside the transaction.
|
|
49
49
|
|
|
50
50
|
For atomic application writes and alarm changes, see the [alarm transaction example](tests/fixtures/alarm-transaction-consumer.ts) and [API contract](src/DurableObjectAlarm.ts).
|
|
51
51
|
|
|
52
|
+
Define a typed alarm service with `class Alarms extends DurableObjectAlarm.Tag<Alarms>()("Alarms", { ...schemas }) {}`. Pass `Alarms.handlers({ ...implementations })` to the DO's `alarms:` option, then `yield* Alarms` to schedule or cancel alarms and open transactions. All declared handlers are required. The registration provides the service to application layers, initialization, and event handlers; declaring schemas alone does not provide a scheduler.
|
|
53
|
+
|
|
54
|
+
Scheduling accepts decoded payloads, encodes them with the declared schema, and checks that the result is JSON before storage. Transaction callbacks expose the same typed mutations and retain the raw scheduler's rollback and callback-lifetime rules.
|
|
55
|
+
|
|
56
|
+
`DurableObject.make` and tagged definitions' `.make` still provide the raw `DurableObjectAlarm` service automatically for dynamic tags and JSON payloads. `DurableObjectAlarm.define({ ... }).handlers(...)` remains a handler-only helper for raw scheduling. No alarm tables or native alarms are created until the scheduler is used. Outside these entrypoints, provide the raw scheduler layer explicitly. A typed registration exposes `layer` and `run` for custom runtimes and tests; custom runtimes must install both.
|
|
57
|
+
|
|
58
|
+
Unknown stored tags produce `StoredAlarmDecodeError` and follow the configured delivery failure policy rather than being acknowledged silently. Use the raw scheduler's `cancelAlarm` to remove retired tags, including repeating alarms.
|
|
59
|
+
|
|
52
60
|
## Cloudflare Observability traces
|
|
53
61
|
|
|
54
62
|
`CloudflareTracer.layer` sends existing `Effect.withSpan` and named `Effect.fn`
|
package/dist/index.d.mts
CHANGED
|
@@ -568,6 +568,183 @@ declare const Service: <Self>() => <Id extends string>(id: Id, definition: D1Def
|
|
|
568
568
|
definition: D1Definition;
|
|
569
569
|
sqlLayer: (options?: D1SqlLayerOptions) => Layer.Layer<D1Client.D1Client | SqlClient.SqlClient, Config.ConfigError | BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
570
570
|
};
|
|
571
|
+
declare namespace DurableObjectAlarm_d_exports {
|
|
572
|
+
export { AlarmDefinitionConfig, AlarmDefinitionEntry, AlarmDefinitionPayload, AlarmDefinitions, AlarmFailurePolicy, AlarmPayload, AlarmPayloadSchema, AlarmRef, AlarmRegistration, AlarmRetryPolicy, AlarmScheduler, AlarmService, AlarmTagClass, AlarmTransaction, DefinedAlarmEvent, DefinedAlarmHandlers, DefinedAlarmScheduler, DefinedAlarmTransaction, DefinedScheduleAlarmInput, DurableObjectAlarm, DurableObjectAlarmError, DurableObjectAlarmEvent, InvalidAlarmPayloadError, InvalidAlarmRefError, InvalidProcessDueAlarmsOptionsError, InvalidRepeatEveryError, ProcessDueAlarmsFailure, ProcessDueAlarmsFailureAction, ProcessDueAlarmsHandler, ProcessDueAlarmsMode, ProcessDueAlarmsOptions, ProcessDueAlarmsResult, ScheduleAlarmInput, StoredAlarmDecodeError, Tag$8 as Tag, define, processDue };
|
|
573
|
+
}
|
|
574
|
+
type AlarmPayload = Schema.Json;
|
|
575
|
+
declare const InvalidAlarmRefError_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 & {
|
|
576
|
+
readonly _tag: "InvalidAlarmRefError";
|
|
577
|
+
} & Readonly<A>;
|
|
578
|
+
declare class InvalidAlarmRefError extends InvalidAlarmRefError_base<{
|
|
579
|
+
readonly cause: unknown;
|
|
580
|
+
}> {
|
|
581
|
+
get message(): string;
|
|
582
|
+
}
|
|
583
|
+
declare const InvalidAlarmPayloadError_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 & {
|
|
584
|
+
readonly _tag: "InvalidAlarmPayloadError";
|
|
585
|
+
} & Readonly<A>;
|
|
586
|
+
declare class InvalidAlarmPayloadError extends InvalidAlarmPayloadError_base<{
|
|
587
|
+
readonly cause: unknown;
|
|
588
|
+
}> {
|
|
589
|
+
get message(): string;
|
|
590
|
+
}
|
|
591
|
+
declare const InvalidRepeatEveryError_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 & {
|
|
592
|
+
readonly _tag: "InvalidRepeatEveryError";
|
|
593
|
+
} & Readonly<A>;
|
|
594
|
+
declare class InvalidRepeatEveryError extends InvalidRepeatEveryError_base<{
|
|
595
|
+
readonly cause: unknown;
|
|
596
|
+
}> {
|
|
597
|
+
get message(): string;
|
|
598
|
+
}
|
|
599
|
+
declare const InvalidProcessDueAlarmsOptionsError_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 & {
|
|
600
|
+
readonly _tag: "InvalidProcessDueAlarmsOptionsError";
|
|
601
|
+
} & Readonly<A>;
|
|
602
|
+
declare class InvalidProcessDueAlarmsOptionsError extends InvalidProcessDueAlarmsOptionsError_base<{
|
|
603
|
+
readonly cause: unknown;
|
|
604
|
+
}> {
|
|
605
|
+
get message(): string;
|
|
606
|
+
}
|
|
607
|
+
declare const StoredAlarmDecodeError_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 & {
|
|
608
|
+
readonly _tag: "StoredAlarmDecodeError";
|
|
609
|
+
} & Readonly<A>;
|
|
610
|
+
declare class StoredAlarmDecodeError extends StoredAlarmDecodeError_base<{
|
|
611
|
+
readonly cause: unknown;
|
|
612
|
+
readonly storageId: string;
|
|
613
|
+
}> {
|
|
614
|
+
get message(): string;
|
|
615
|
+
}
|
|
616
|
+
type DurableObjectAlarmError = InvalidAlarmPayloadError | InvalidAlarmRefError | InvalidProcessDueAlarmsOptionsError | InvalidRepeatEveryError | StorageOperationError | StoredAlarmDecodeError;
|
|
617
|
+
declare const DurableObjectAlarmEvent: Schema.TaggedUnion<{
|
|
618
|
+
readonly AlarmDue: Schema.TaggedStruct<"AlarmDue", {
|
|
619
|
+
readonly id: Schema.NonEmptyString;
|
|
620
|
+
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
621
|
+
/** Persisted due time, which can differ from the invocation time during retries. */
|
|
622
|
+
readonly scheduledAt: Schema.DateTimeUtc;
|
|
623
|
+
readonly tag: Schema.NonEmptyString;
|
|
624
|
+
}>;
|
|
625
|
+
}>;
|
|
626
|
+
type DurableObjectAlarmEvent = typeof DurableObjectAlarmEvent.Type;
|
|
627
|
+
type AlarmRef<Tag extends string = string> = {
|
|
628
|
+
readonly id: string;
|
|
629
|
+
readonly tag: Tag;
|
|
630
|
+
};
|
|
631
|
+
/** Reusing `{tag, id}` replaces an alarm. Repeats run after success, never as fixed-cadence catch-up. */
|
|
632
|
+
type ScheduleAlarmInput<Tag extends string = string> = AlarmRef<Tag> & {
|
|
633
|
+
readonly payload: AlarmPayload;
|
|
634
|
+
readonly repeatEvery?: Duration.Input;
|
|
635
|
+
readonly runAt: DateTime.Utc;
|
|
636
|
+
};
|
|
637
|
+
type ProcessDueAlarmsMode = "isolated" | "ordered";
|
|
638
|
+
interface ProcessDueAlarmsFailure {
|
|
639
|
+
readonly cause: unknown;
|
|
640
|
+
readonly event?: DurableObjectAlarmEvent;
|
|
641
|
+
readonly id: string;
|
|
642
|
+
readonly storageId: string;
|
|
643
|
+
readonly tag: string;
|
|
644
|
+
}
|
|
645
|
+
interface ProcessDueAlarmsResult {
|
|
646
|
+
readonly failed: readonly ProcessDueAlarmsFailure[];
|
|
647
|
+
readonly handled: readonly DurableObjectAlarmEvent[];
|
|
648
|
+
}
|
|
649
|
+
type ProcessDueAlarmsFailureAction = "ordered" | "retry" | "skip-and-advance-repeat" | {
|
|
650
|
+
readonly mode: "ordered";
|
|
651
|
+
} | {
|
|
652
|
+
readonly mode: "retry";
|
|
653
|
+
readonly retryFailedAfter?: Duration.Input;
|
|
654
|
+
} | {
|
|
655
|
+
readonly mode: "skip-and-advance-repeat";
|
|
656
|
+
};
|
|
657
|
+
interface ProcessDueAlarmsOptions<OnFailureR = never, OnFailureE = never> {
|
|
658
|
+
readonly limit?: number;
|
|
659
|
+
/** `isolated` retries only the failed row; `ordered` stops before later rows. */
|
|
660
|
+
readonly mode?: ProcessDueAlarmsMode;
|
|
661
|
+
readonly onFailure?: (failure: ProcessDueAlarmsFailure) => Effect.Effect<ProcessDueAlarmsFailureAction | void, OnFailureE, OnFailureR>;
|
|
662
|
+
readonly retryFailedAfter?: Duration.Input;
|
|
663
|
+
}
|
|
664
|
+
type ProcessDueAlarmsHandler<R = never, E = never> = (event: DurableObjectAlarmEvent) => Effect.Effect<void, E, R>;
|
|
665
|
+
/**
|
|
666
|
+
* Alarm mutations owned by one transaction callback. Run them in the callback's
|
|
667
|
+
* fiber; forked work and use after the callback ends fail with StorageOperationError.
|
|
668
|
+
*/
|
|
669
|
+
type AlarmTransaction = Pick<AlarmScheduler, "scheduleAlarm" | "cancelAlarm">;
|
|
670
|
+
/** Own `storage.setAlarm()` exclusively: a Durable Object has one platform alarm timestamp. */
|
|
671
|
+
type AlarmScheduler = {
|
|
672
|
+
/**
|
|
673
|
+
* Commits local application storage and logical alarms in one native SQLite
|
|
674
|
+
* Durable Object transaction, reconciling the native alarm before commit.
|
|
675
|
+
* Use the supplied mutations, not standalone alarm methods or nested transactions.
|
|
676
|
+
* SqlClient queries must use this same Durable Object's storage.
|
|
677
|
+
*
|
|
678
|
+
* Failure, defects and interruption before commit roll back. A lost reply or
|
|
679
|
+
* interruption after commit does not undo committed state. Keep RPC and other
|
|
680
|
+
* external effects outside; atomically pre-arm a later wake before fallible work.
|
|
681
|
+
* Cloudflare's native retries are bounded; composition does not remove the
|
|
682
|
+
* pre-arm requirement or promise infinite retry liveness.
|
|
683
|
+
*/
|
|
684
|
+
readonly transaction: <A, E, R>(closure: (alarms: AlarmTransaction) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StorageOperationError, R>;
|
|
685
|
+
readonly cancelAlarm: (input: AlarmRef) => Effect.Effect<void, InvalidAlarmRefError | StorageOperationError>;
|
|
686
|
+
/** Acknowledge after handling. Conditional writes preserve handler replacements; alarms are at-least-once. */
|
|
687
|
+
readonly processDueAlarms: <R = never, E = never, OnFailureR = never, OnFailureE = never>(handle: ProcessDueAlarmsHandler<R, E>, options?: ProcessDueAlarmsOptions<OnFailureR, OnFailureE>) => Effect.Effect<ProcessDueAlarmsResult, E | OnFailureE | DurableObjectAlarmError, R | OnFailureR>;
|
|
688
|
+
/** A failed platform setAlarm rolls back the logical schedule in the same transaction. */
|
|
689
|
+
readonly scheduleAlarm: (input: ScheduleAlarmInput) => Effect.Effect<void, InvalidAlarmPayloadError | InvalidAlarmRefError | InvalidRepeatEveryError | StorageOperationError>;
|
|
690
|
+
};
|
|
691
|
+
declare const processDue: <R = never, E = never, OnFailureR = never, OnFailureE = never>(handle: ProcessDueAlarmsHandler<R, E>, options?: ProcessDueAlarmsOptions<OnFailureR, OnFailureE>) => Effect.Effect<ProcessDueAlarmsResult, E | OnFailureE | DurableObjectAlarmError, OnFailureR | R | DurableObjectAlarm>;
|
|
692
|
+
type AlarmPayloadSchema = Schema.Codec<any, any, never, never>;
|
|
693
|
+
type AlarmFailurePolicy = "ordered" | "retry" | "skip-and-advance-repeat";
|
|
694
|
+
interface AlarmRetryPolicy {
|
|
695
|
+
readonly initialDelay?: Duration.Input;
|
|
696
|
+
}
|
|
697
|
+
interface AlarmDefinitionConfig<Payload extends AlarmPayloadSchema = AlarmPayloadSchema> {
|
|
698
|
+
readonly failure?: AlarmFailurePolicy;
|
|
699
|
+
readonly payload: Payload;
|
|
700
|
+
readonly retry?: AlarmRetryPolicy;
|
|
701
|
+
}
|
|
702
|
+
type AlarmDefinitionEntry = AlarmDefinitionConfig | AlarmPayloadSchema;
|
|
703
|
+
type AlarmDefinitions = Readonly<Record<string, AlarmDefinitionEntry>>;
|
|
704
|
+
type AlarmDefinitionSchema<Definition> = Definition extends AlarmDefinitionConfig<infer Payload> ? Payload : Definition;
|
|
705
|
+
type AlarmDefinitionPayload<Definition> = AlarmDefinitionSchema<Definition> extends Schema.Codec<infer A, any, never, never> ? A : never;
|
|
706
|
+
type DefinedAlarmEvent<Tag extends string, Payload> = Omit<DurableObjectAlarmEvent, "payload" | "tag"> & {
|
|
707
|
+
readonly payload: Payload;
|
|
708
|
+
readonly tag: Tag;
|
|
709
|
+
};
|
|
710
|
+
type DefinedAlarmHandlers<Definitions extends AlarmDefinitions, R = never, E = never> = { readonly [Tag in keyof Definitions & string]: (event: DefinedAlarmEvent<Tag$8, AlarmDefinitionPayload<Definitions[Tag$8]>>) => Effect.Effect<void, E, R>; };
|
|
711
|
+
/** A discriminated union keeps each tag paired with its decoded payload type. */
|
|
712
|
+
type DefinedScheduleAlarmInput<Definitions extends AlarmDefinitions> = { readonly [Tag in keyof Definitions & string]: Omit<ScheduleAlarmInput<Tag$8>, "payload"> & {
|
|
713
|
+
readonly payload: AlarmDefinitionPayload<Definitions[Tag$8]>;
|
|
714
|
+
}; }[keyof Definitions & string];
|
|
715
|
+
interface DefinedAlarmTransaction<Definitions extends AlarmDefinitions> {
|
|
716
|
+
readonly scheduleAlarm: (input: DefinedScheduleAlarmInput<Definitions>) => ReturnType<AlarmScheduler["scheduleAlarm"]>;
|
|
717
|
+
readonly cancelAlarm: (input: AlarmRef<keyof Definitions & string>) => ReturnType<AlarmScheduler["cancelAlarm"]>;
|
|
718
|
+
}
|
|
719
|
+
declare const TypedAlarmSchedulerTypeId: unique symbol;
|
|
720
|
+
/** Identifies service requirements whose scheduler needs a registered dispatcher. */
|
|
721
|
+
interface AlarmService {
|
|
722
|
+
readonly Service: {
|
|
723
|
+
readonly [TypedAlarmSchedulerTypeId]: typeof TypedAlarmSchedulerTypeId;
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
interface DefinedAlarmScheduler<Definitions extends AlarmDefinitions> extends DefinedAlarmTransaction<Definitions> {
|
|
727
|
+
readonly [TypedAlarmSchedulerTypeId]: typeof TypedAlarmSchedulerTypeId;
|
|
728
|
+
readonly transaction: <A, E, R>(closure: (alarms: DefinedAlarmTransaction<Definitions>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StorageOperationError, R>;
|
|
729
|
+
}
|
|
730
|
+
/** Registers a dispatcher and the service authorized to schedule its alarms. */
|
|
731
|
+
interface AlarmRegistration<Self, R = never, E = never> {
|
|
732
|
+
readonly layer: Layer.Layer<Self, never, DurableObjectAlarm>;
|
|
733
|
+
readonly run: Effect.Effect<ProcessDueAlarmsResult, E | DurableObjectAlarmError, R | DurableObjectAlarm>;
|
|
734
|
+
}
|
|
735
|
+
interface AlarmTagClass<Self, Id extends string, Definitions extends AlarmDefinitions> extends Context.ServiceClass<Self, Id, DefinedAlarmScheduler<Definitions>> {
|
|
736
|
+
readonly handlers: <R = never, E = never>(handlers: DefinedAlarmHandlers<Definitions, R, E>, options?: ProcessDueAlarmsOptions<R, E>) => AlarmRegistration<Self, R, E>;
|
|
737
|
+
}
|
|
738
|
+
/** Handler-only definitions for applications using the raw scheduler. Prefer Tag for typed scheduling. */
|
|
739
|
+
declare const define: <const Definitions extends AlarmDefinitions>(definitions: Definitions) => {
|
|
740
|
+
handlers: <R = never, E = never>(handlers: DefinedAlarmHandlers<Definitions, R, E>, options?: ProcessDueAlarmsOptions<R, E> | undefined) => Effect.Effect<ProcessDueAlarmsResult, E | DurableObjectAlarmError, R | DurableObjectAlarm>;
|
|
741
|
+
};
|
|
742
|
+
/** The typed scheduler becomes available when its handlers are registered on a Durable Object. */
|
|
743
|
+
declare const Tag$8: <Self>() => <const Id extends string, const Definitions extends AlarmDefinitions>(id: Id, definitions: Definitions) => AlarmTagClass<Self, Id, Definitions>;
|
|
744
|
+
declare const DurableObjectAlarm_base: Context.ServiceClass<DurableObjectAlarm, "effect-cf/DurableObjectAlarm", AlarmScheduler>;
|
|
745
|
+
declare class DurableObjectAlarm extends DurableObjectAlarm_base {
|
|
746
|
+
static readonly layer: Layer.Layer<DurableObjectAlarm, never, DurableObjectState>;
|
|
747
|
+
}
|
|
571
748
|
declare namespace DurableObjectNamespace_d_exports {
|
|
572
749
|
export { DurableObjectFetchError, DurableObjectNamespaceBindingDefinition, DurableObjectNamespaceClient, DurableObjectNamespaceDefinition, DurableObjectNamespaceEffectClient, DurableObjectNamespaceStaticClient, DurableObjectRpcError, DurableObjectStubClient, isDurableObjectNamespaceClient, layer$7 as layer, makeClient$5 as makeClient, makeDirectMethods };
|
|
573
750
|
}
|
|
@@ -712,7 +889,7 @@ declare const makeDirectMethods: <R, Api extends object, Definition extends Defi
|
|
|
712
889
|
readonly getByName: (name: string, options?: globalThis.DurableObjectNamespaceGetDurableObjectOptions) => Effect.Effect<DurableObjectStubClient<Api>, never, R>;
|
|
713
890
|
}) => DirectMethods<R, Api, Definition>;
|
|
714
891
|
declare namespace DurableObjectDefinition_d_exports {
|
|
715
|
-
export { Api, Definition$3 as Definition, DurableObject$1 as DurableObject, HandlerEffect, Handlers, LayerOptions$8 as LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options$2 as Options, ReservedMethodName, ServerApi, ServiceFreeSchema, Tag$
|
|
892
|
+
export { Api, Definition$3 as Definition, DurableObject$1 as DurableObject, HandlerEffect, Handlers, LayerOptions$8 as LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options$2 as Options, ReservedMethodName, ServerApi, ServiceFreeSchema, Tag$7 as Tag, TagClass$7 as TagClass, implement$2 as implement, make$7 as make, method };
|
|
716
893
|
}
|
|
717
894
|
type ServiceFreeSchema = Schema.Codec<any, any, never, never>;
|
|
718
895
|
interface Method$1<Args extends ReadonlyArray<ServiceFreeSchema> = ReadonlyArray<ServiceFreeSchema>, Success extends ServiceFreeSchema = ServiceFreeSchema> {
|
|
@@ -754,9 +931,9 @@ type Handlers<ROut, Self extends Definition$3.Any> = { readonly [Key in keyof Se
|
|
|
754
931
|
/**
|
|
755
932
|
* Durable Object constructor options for a specific RPC definition.
|
|
756
933
|
*/
|
|
757
|
-
|
|
758
|
-
readonly rpc: Handlers<ROut | REvent
|
|
759
|
-
}
|
|
934
|
+
type Options$2<ROut, Self extends Definition$3.Any, REvent = never, EventLayerError = never, RAlarm = never> = DurableObjectOptions<ROut, REvent, EventLayerError, Handlers<NoInfer<ROut> | REvent | NoInfer<RAlarm>, Self>, RAlarm> & {
|
|
935
|
+
readonly rpc: Handlers<NoInfer<ROut> | REvent | NoInfer<RAlarm>, Self>;
|
|
936
|
+
};
|
|
760
937
|
type LayerOptions$8 = {
|
|
761
938
|
readonly binding: string;
|
|
762
939
|
readonly rpcTracing?: boolean;
|
|
@@ -764,7 +941,7 @@ type LayerOptions$8 = {
|
|
|
764
941
|
type TagClass$7<Self, Id extends string, MethodDefinitions extends Methods> = Context.ServiceClass<Self, `effect-cf/DurableObject/${Id}`, DurableObjectNamespaceEffectClient<Api<Definition$3<Id, MethodDefinitions>>, Definition$3<Id, MethodDefinitions>>> & DurableObjectNamespaceStaticClient<Self, Api<Definition$3<Id, MethodDefinitions>>, Definition$3<Id, MethodDefinitions>> & {
|
|
765
942
|
readonly id: Id;
|
|
766
943
|
readonly methods: MethodDefinitions;
|
|
767
|
-
readonly make: <ROut, LayerError, REvent = never, EventLayerError = never>(layer: Layer.Layer<ROut, LayerError,
|
|
944
|
+
readonly make: <ROut, LayerError, REvent = never, EventLayerError = never, RAlarm = never>(layer: Layer.Layer<ROut, LayerError, RuntimeContext$1<NoInfer<RAlarm>>>, options: Options$2<ROut, Definition$3<Id, MethodDefinitions>, REvent, EventLayerError, RAlarm>) => DurableObjectClass<Handlers<ROut | REvent | RAlarm, Definition$3<Id, MethodDefinitions>>, ROut | REvent | RAlarm>;
|
|
768
945
|
readonly layer: (options: LayerOptions$8) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
769
946
|
};
|
|
770
947
|
/**
|
|
@@ -778,8 +955,8 @@ declare function method<const Args extends ReadonlyArray<ServiceFreeSchema>, Suc
|
|
|
778
955
|
readonly success: Success;
|
|
779
956
|
}): Method$1<Args, Success>;
|
|
780
957
|
declare const make$7: <Id extends string, const MethodDefinitions extends Methods>(id: Id, methods: MethodDefinitions & NoReservedMethods<MethodDefinitions>) => TagClass$7<Definition$3<Id, MethodDefinitions>, Id, MethodDefinitions>;
|
|
781
|
-
declare const Tag$
|
|
782
|
-
declare const DurableObject$1: typeof Tag$
|
|
958
|
+
declare const Tag$7: <Self>() => <Id extends string, const MethodDefinitions extends Methods>(id: Id, methods: MethodDefinitions & NoReservedMethods<MethodDefinitions>) => TagClass$7<Self, Id, MethodDefinitions>;
|
|
959
|
+
declare const DurableObject$1: typeof Tag$7;
|
|
783
960
|
/**
|
|
784
961
|
* Helper for implementing handlers with the exact method shape of a definition.
|
|
785
962
|
*/
|
|
@@ -789,9 +966,9 @@ declare const implement$2: <ROut, const Self extends Definition$3.Any>(_definiti
|
|
|
789
966
|
*/
|
|
790
967
|
type HandlerEffect<ROut, Self extends Definition$3.Any, Key extends keyof Self["methods"]> = DurableObjectHandler<ROut, Method$1.Success<Self["methods"][Key]>>;
|
|
791
968
|
declare namespace DurableObject_d_exports {
|
|
792
|
-
export { Api, Definition$3 as Definition, DurableObjectClass, DurableObjectHandler, DurableObjectOptions, DurableObjectRpc, DurableObjectRpcApi, DurableObjectRpcApi as DurableObjectRpcShape, HandlerEffect, Handlers, LayerOptions$8 as LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options$2 as Options, ReservedMethodName, RpcHandlers, RunOptions, RunSymbol, ServerApi, ServiceFreeSchema, Tag$
|
|
969
|
+
export { Api, Definition$3 as Definition, DurableObjectClass, DurableObjectHandler, DurableObjectOptions, DurableObjectRpc, DurableObjectRpcApi, DurableObjectRpcApi as DurableObjectRpcShape, HandlerEffect, Handlers, LayerOptions$8 as LayerOptions, Method$1 as Method, Methods, NoReservedMethods, Options$2 as Options, ReservedMethodName, RpcHandlers, RunOptions, RunSymbol, RuntimeContext$1 as RuntimeContext, ServerApi, ServiceFreeSchema, Tag$7 as Tag, TagClass$7 as TagClass, implement$2 as implement, make$6 as make, method };
|
|
793
970
|
}
|
|
794
|
-
type RuntimeContext$1<ROut> = DurableObjectState | WorkerEnvironment | ROut;
|
|
971
|
+
type RuntimeContext$1<ROut> = DurableObjectState | DurableObjectAlarm | WorkerEnvironment | ROut;
|
|
795
972
|
type HandlerContext<ROut> = RuntimeContext$1<ROut> | Scope.Scope;
|
|
796
973
|
type FetchContext<ROut> = HandlerContext<ROut> | NativeRequest;
|
|
797
974
|
/** Metadata available before an event effect or its event layer starts. */
|
|
@@ -812,7 +989,7 @@ type DurableObjectHandler<ROut, A = unknown> = Effect.Effect<A, unknown, Handler
|
|
|
812
989
|
type DurableObjectRpc<ROut> = Record<string, (...args: Array<any>) => DurableObjectHandler<ROut>>;
|
|
813
990
|
type DurableObjectRpcApi<Rpc extends DurableObjectRpc<ROut>, ROut> = { readonly [Key in keyof Rpc]: Rpc[Key] extends ((...args: infer Args) => Effect.Effect<infer A, unknown, HandlerContext<ROut>>) ? (...args: Args) => Promise<A> : never; };
|
|
814
991
|
type RpcHandlers<ROut, Api> = { readonly [Key in keyof Api as Key extends keyof DurableObject<WorkerEnv> ? never : Key extends string ? [Api[Key]] extends [never] ? never : Api[Key] extends ((...args: Array<any>) => Promise<any>) ? Key : never : never]: Api[Key] extends ((...args: infer Args) => Promise<infer A>) ? (...args: Args) => DurableObjectHandler<ROut, A> : never; };
|
|
815
|
-
interface
|
|
992
|
+
interface DurableObjectOptionsBase<RRuntime, REvent = never, EventLayerError = never, Rpc extends DurableObjectRpc<RRuntime | REvent | RAlarm> = Record<never, never>, RAlarm = never> {
|
|
816
993
|
/**
|
|
817
994
|
* Layer provided around each Cloudflare event handled by this Durable Object.
|
|
818
995
|
*
|
|
@@ -820,7 +997,7 @@ interface DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never
|
|
|
820
997
|
* event effect completes. It is not applied to `initialize`, which is an
|
|
821
998
|
* instance-load lifecycle hook rather than a platform event.
|
|
822
999
|
*/
|
|
823
|
-
readonly eventLayer?: Layer.Layer<REvent, EventLayerError,
|
|
1000
|
+
readonly eventLayer?: Layer.Layer<REvent, EventLayerError, RuntimeContext$1<NoInfer<RRuntime | RAlarm>>>;
|
|
824
1001
|
/**
|
|
825
1002
|
* Effect run when Cloudflare loads this Durable Object instance into memory.
|
|
826
1003
|
*
|
|
@@ -829,7 +1006,7 @@ interface DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never
|
|
|
829
1006
|
* the same Durable Object id again after eviction or restart; use Durable
|
|
830
1007
|
* Object storage if work must happen only once per id.
|
|
831
1008
|
*/
|
|
832
|
-
readonly initialize?: Effect.Effect<void, unknown, HandlerContext<RRuntime
|
|
1009
|
+
readonly initialize?: Effect.Effect<void, unknown, HandlerContext<NoInfer<RRuntime | RAlarm>>>;
|
|
833
1010
|
/**
|
|
834
1011
|
* Optional RPC methods exposed as Durable Object instance methods.
|
|
835
1012
|
*
|
|
@@ -841,8 +1018,9 @@ interface DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never
|
|
|
841
1018
|
readonly rpc?: Rpc;
|
|
842
1019
|
/** Accept live native trace metadata. The client must also enable rpcTracing. */
|
|
843
1020
|
readonly rpcTracing?: ReceiverOptions;
|
|
844
|
-
readonly fetch?: Effect.Effect<Response, unknown, FetchContext<RRuntime | REvent
|
|
845
|
-
|
|
1021
|
+
readonly fetch?: Effect.Effect<Response, unknown, FetchContext<NoInfer<RRuntime | REvent | RAlarm>>>;
|
|
1022
|
+
/** Register handlers to provide their typed scheduler to application layers and all DO events. */
|
|
1023
|
+
readonly alarms?: Effect.Effect<unknown, unknown, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>> | AlarmRegistration<RAlarm, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>, unknown>;
|
|
846
1024
|
/**
|
|
847
1025
|
* Optional raw alarm handler.
|
|
848
1026
|
*
|
|
@@ -851,11 +1029,18 @@ interface DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never
|
|
|
851
1029
|
* scheduled flush silently settles within two seconds even if the exporter
|
|
852
1030
|
* does not.
|
|
853
1031
|
*/
|
|
854
|
-
readonly alarm?: (alarmInfo?: globalThis.AlarmInvocationInfo) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent
|
|
855
|
-
readonly webSocketMessage?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent
|
|
856
|
-
readonly webSocketClose?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent
|
|
857
|
-
readonly webSocketError?: (socket: DurableWebSocket, cause: unknown) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent
|
|
858
|
-
}
|
|
1032
|
+
readonly alarm?: (alarmInfo?: globalThis.AlarmInvocationInfo) => Effect.Effect<void, unknown, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>>;
|
|
1033
|
+
readonly webSocketMessage?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect<void, unknown, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>>;
|
|
1034
|
+
readonly webSocketClose?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, unknown, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>>;
|
|
1035
|
+
readonly webSocketError?: (socket: DurableWebSocket, cause: unknown) => Effect.Effect<void, unknown, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>>;
|
|
1036
|
+
}
|
|
1037
|
+
type CheckAlarmRegistration<RProvided, RAlarm> = [Exclude<Extract<NoInfer<RProvided>, AlarmService>, NoInfer<RAlarm>>] extends [never] ? unknown : never;
|
|
1038
|
+
/** A declared event or alarm service must have its corresponding provider. */
|
|
1039
|
+
type DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never, Rpc extends DurableObjectRpc<RRuntime | REvent | RAlarm> = Record<never, never>, RAlarm = never> = DurableObjectOptionsBase<RRuntime, REvent, EventLayerError, Rpc, RAlarm> & CheckAlarmRegistration<RRuntime | REvent, RAlarm> & ([Exclude<REvent, RuntimeContext$1<RRuntime | RAlarm> | Scope.Scope>] extends [never] ? unknown : {
|
|
1040
|
+
readonly eventLayer: Layer.Layer<REvent, EventLayerError, RuntimeContext$1<NoInfer<RRuntime | RAlarm>>>;
|
|
1041
|
+
}) & ([RAlarm] extends [never] ? unknown : {
|
|
1042
|
+
readonly alarms: AlarmRegistration<RAlarm, HandlerContext<NoInfer<RRuntime> | REvent | NoInfer<RAlarm>>, unknown>;
|
|
1043
|
+
});
|
|
859
1044
|
/**
|
|
860
1045
|
* Cloudflare `DurableObject` constructor produced by {@link make}.
|
|
861
1046
|
*/
|
|
@@ -868,154 +1053,8 @@ type DurableObjectClass<Rpc extends DurableObjectRpc<ROut>, ROut> = new (state:
|
|
|
868
1053
|
* that layer are not guaranteed to run. Put resources that require timely
|
|
869
1054
|
* release in `eventLayer`, whose scope closes after each handled event.
|
|
870
1055
|
*/
|
|
871
|
-
declare
|
|
872
|
-
declare
|
|
873
|
-
export { AlarmDefinitionConfig, AlarmDefinitionEntry, AlarmDefinitionPayload, AlarmDefinitions, AlarmFailurePolicy, AlarmPayload, AlarmPayloadSchema, AlarmRef, AlarmRetryPolicy, AlarmScheduler, AlarmTransaction, DefinedAlarmEvent, DefinedAlarmHandlers, DurableObjectAlarm, DurableObjectAlarmError, DurableObjectAlarmEvent, InvalidAlarmPayloadError, InvalidAlarmRefError, InvalidProcessDueAlarmsOptionsError, InvalidRepeatEveryError, ProcessDueAlarmsFailure, ProcessDueAlarmsFailureAction, ProcessDueAlarmsHandler, ProcessDueAlarmsMode, ProcessDueAlarmsOptions, ProcessDueAlarmsResult, ScheduleAlarmInput, StoredAlarmDecodeError, define, processDue };
|
|
874
|
-
}
|
|
875
|
-
type AlarmPayload = Schema.Json;
|
|
876
|
-
declare const InvalidAlarmRefError_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 & {
|
|
877
|
-
readonly _tag: "InvalidAlarmRefError";
|
|
878
|
-
} & Readonly<A>;
|
|
879
|
-
declare class InvalidAlarmRefError extends InvalidAlarmRefError_base<{
|
|
880
|
-
readonly cause: unknown;
|
|
881
|
-
}> {
|
|
882
|
-
get message(): string;
|
|
883
|
-
}
|
|
884
|
-
declare const InvalidAlarmPayloadError_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 & {
|
|
885
|
-
readonly _tag: "InvalidAlarmPayloadError";
|
|
886
|
-
} & Readonly<A>;
|
|
887
|
-
declare class InvalidAlarmPayloadError extends InvalidAlarmPayloadError_base<{
|
|
888
|
-
readonly cause: unknown;
|
|
889
|
-
}> {
|
|
890
|
-
get message(): string;
|
|
891
|
-
}
|
|
892
|
-
declare const InvalidRepeatEveryError_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 & {
|
|
893
|
-
readonly _tag: "InvalidRepeatEveryError";
|
|
894
|
-
} & Readonly<A>;
|
|
895
|
-
declare class InvalidRepeatEveryError extends InvalidRepeatEveryError_base<{
|
|
896
|
-
readonly cause: unknown;
|
|
897
|
-
}> {
|
|
898
|
-
get message(): string;
|
|
899
|
-
}
|
|
900
|
-
declare const InvalidProcessDueAlarmsOptionsError_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 & {
|
|
901
|
-
readonly _tag: "InvalidProcessDueAlarmsOptionsError";
|
|
902
|
-
} & Readonly<A>;
|
|
903
|
-
declare class InvalidProcessDueAlarmsOptionsError extends InvalidProcessDueAlarmsOptionsError_base<{
|
|
904
|
-
readonly cause: unknown;
|
|
905
|
-
}> {
|
|
906
|
-
get message(): string;
|
|
907
|
-
}
|
|
908
|
-
declare const StoredAlarmDecodeError_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 & {
|
|
909
|
-
readonly _tag: "StoredAlarmDecodeError";
|
|
910
|
-
} & Readonly<A>;
|
|
911
|
-
declare class StoredAlarmDecodeError extends StoredAlarmDecodeError_base<{
|
|
912
|
-
readonly cause: unknown;
|
|
913
|
-
readonly storageId: string;
|
|
914
|
-
}> {
|
|
915
|
-
get message(): string;
|
|
916
|
-
}
|
|
917
|
-
type DurableObjectAlarmError = InvalidAlarmPayloadError | InvalidAlarmRefError | InvalidProcessDueAlarmsOptionsError | InvalidRepeatEveryError | StorageOperationError | StoredAlarmDecodeError;
|
|
918
|
-
declare const DurableObjectAlarmEvent: Schema.TaggedUnion<{
|
|
919
|
-
readonly AlarmDue: Schema.TaggedStruct<"AlarmDue", {
|
|
920
|
-
readonly id: Schema.NonEmptyString;
|
|
921
|
-
readonly payload: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
922
|
-
/** Persisted due time, which can differ from the invocation time during retries. */
|
|
923
|
-
readonly scheduledAt: Schema.DateTimeUtc;
|
|
924
|
-
readonly tag: Schema.NonEmptyString;
|
|
925
|
-
}>;
|
|
926
|
-
}>;
|
|
927
|
-
type DurableObjectAlarmEvent = typeof DurableObjectAlarmEvent.Type;
|
|
928
|
-
type AlarmRef<Tag extends string = string> = {
|
|
929
|
-
readonly id: string;
|
|
930
|
-
readonly tag: Tag;
|
|
931
|
-
};
|
|
932
|
-
/** Reusing `{tag, id}` replaces an alarm. Repeats run after success, never as fixed-cadence catch-up. */
|
|
933
|
-
type ScheduleAlarmInput<Tag extends string = string> = AlarmRef<Tag> & {
|
|
934
|
-
readonly payload: AlarmPayload;
|
|
935
|
-
readonly repeatEvery?: Duration.Input;
|
|
936
|
-
readonly runAt: DateTime.Utc;
|
|
937
|
-
};
|
|
938
|
-
type ProcessDueAlarmsMode = "isolated" | "ordered";
|
|
939
|
-
interface ProcessDueAlarmsFailure {
|
|
940
|
-
readonly cause: unknown;
|
|
941
|
-
readonly event?: DurableObjectAlarmEvent;
|
|
942
|
-
readonly id: string;
|
|
943
|
-
readonly storageId: string;
|
|
944
|
-
readonly tag: string;
|
|
945
|
-
}
|
|
946
|
-
interface ProcessDueAlarmsResult {
|
|
947
|
-
readonly failed: readonly ProcessDueAlarmsFailure[];
|
|
948
|
-
readonly handled: readonly DurableObjectAlarmEvent[];
|
|
949
|
-
}
|
|
950
|
-
type ProcessDueAlarmsFailureAction = "ordered" | "retry" | "skip-and-advance-repeat" | {
|
|
951
|
-
readonly mode: "ordered";
|
|
952
|
-
} | {
|
|
953
|
-
readonly mode: "retry";
|
|
954
|
-
readonly retryFailedAfter?: Duration.Input;
|
|
955
|
-
} | {
|
|
956
|
-
readonly mode: "skip-and-advance-repeat";
|
|
957
|
-
};
|
|
958
|
-
interface ProcessDueAlarmsOptions<OnFailureR = never, OnFailureE = never> {
|
|
959
|
-
readonly limit?: number;
|
|
960
|
-
/** `isolated` retries only the failed row; `ordered` stops before later rows. */
|
|
961
|
-
readonly mode?: ProcessDueAlarmsMode;
|
|
962
|
-
readonly onFailure?: (failure: ProcessDueAlarmsFailure) => Effect.Effect<ProcessDueAlarmsFailureAction | void, OnFailureE, OnFailureR>;
|
|
963
|
-
readonly retryFailedAfter?: Duration.Input;
|
|
964
|
-
}
|
|
965
|
-
type ProcessDueAlarmsHandler<R = never, E = never> = (event: DurableObjectAlarmEvent) => Effect.Effect<void, E, R>;
|
|
966
|
-
/**
|
|
967
|
-
* Alarm mutations owned by one transaction callback. Run them in the callback's
|
|
968
|
-
* fiber; forked work and use after the callback ends fail with StorageOperationError.
|
|
969
|
-
*/
|
|
970
|
-
type AlarmTransaction = Pick<AlarmScheduler, "scheduleAlarm" | "cancelAlarm">;
|
|
971
|
-
/** Own `storage.setAlarm()` exclusively: a Durable Object has one platform alarm timestamp. */
|
|
972
|
-
type AlarmScheduler = {
|
|
973
|
-
/**
|
|
974
|
-
* Commits local application storage and logical alarms in one native SQLite
|
|
975
|
-
* Durable Object transaction, reconciling the native alarm before commit.
|
|
976
|
-
* Use the supplied mutations, not standalone alarm methods or nested transactions.
|
|
977
|
-
* SqlClient queries must use this same Durable Object's storage.
|
|
978
|
-
*
|
|
979
|
-
* Failure, defects and interruption before commit roll back. A lost reply or
|
|
980
|
-
* interruption after commit does not undo committed state. Keep RPC and other
|
|
981
|
-
* external effects outside; atomically pre-arm a later wake before fallible work.
|
|
982
|
-
* Cloudflare's native retries are bounded; composition does not remove the
|
|
983
|
-
* pre-arm requirement or promise infinite retry liveness.
|
|
984
|
-
*/
|
|
985
|
-
readonly transaction: <A, E, R>(closure: (alarms: AlarmTransaction) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | StorageOperationError, R>;
|
|
986
|
-
readonly cancelAlarm: (input: AlarmRef) => Effect.Effect<void, InvalidAlarmRefError | StorageOperationError>;
|
|
987
|
-
/** Acknowledge after handling. Conditional writes preserve handler replacements; alarms are at-least-once. */
|
|
988
|
-
readonly processDueAlarms: <R = never, E = never, OnFailureR = never, OnFailureE = never>(handle: ProcessDueAlarmsHandler<R, E>, options?: ProcessDueAlarmsOptions<OnFailureR, OnFailureE>) => Effect.Effect<ProcessDueAlarmsResult, E | OnFailureE | DurableObjectAlarmError, R | OnFailureR>;
|
|
989
|
-
/** A failed platform setAlarm rolls back the logical schedule in the same transaction. */
|
|
990
|
-
readonly scheduleAlarm: (input: ScheduleAlarmInput) => Effect.Effect<void, InvalidAlarmPayloadError | InvalidAlarmRefError | InvalidRepeatEveryError | StorageOperationError>;
|
|
991
|
-
};
|
|
992
|
-
declare const processDue: <R = never, E = never, OnFailureR = never, OnFailureE = never>(handle: ProcessDueAlarmsHandler<R, E>, options?: ProcessDueAlarmsOptions<OnFailureR, OnFailureE>) => Effect.Effect<ProcessDueAlarmsResult, E | OnFailureE | DurableObjectAlarmError, OnFailureR | R | DurableObjectAlarm>;
|
|
993
|
-
type AlarmPayloadSchema = Schema.Codec<any, any, never, never>;
|
|
994
|
-
type AlarmFailurePolicy = "ordered" | "retry" | "skip-and-advance-repeat";
|
|
995
|
-
interface AlarmRetryPolicy {
|
|
996
|
-
readonly initialDelay?: Duration.Input;
|
|
997
|
-
}
|
|
998
|
-
interface AlarmDefinitionConfig<Payload extends AlarmPayloadSchema = AlarmPayloadSchema> {
|
|
999
|
-
readonly failure?: AlarmFailurePolicy;
|
|
1000
|
-
readonly payload: Payload;
|
|
1001
|
-
readonly retry?: AlarmRetryPolicy;
|
|
1002
|
-
}
|
|
1003
|
-
type AlarmDefinitionEntry = AlarmDefinitionConfig | AlarmPayloadSchema;
|
|
1004
|
-
type AlarmDefinitions = Readonly<Record<string, AlarmDefinitionEntry>>;
|
|
1005
|
-
type AlarmDefinitionSchema<Definition> = Definition extends AlarmDefinitionConfig<infer Payload> ? Payload : Definition;
|
|
1006
|
-
type AlarmDefinitionPayload<Definition> = AlarmDefinitionSchema<Definition> extends Schema.Codec<infer A, any, never, never> ? A : never;
|
|
1007
|
-
type DefinedAlarmEvent<Tag extends string, Payload> = Omit<DurableObjectAlarmEvent, "payload" | "tag"> & {
|
|
1008
|
-
readonly payload: Payload;
|
|
1009
|
-
readonly tag: Tag;
|
|
1010
|
-
};
|
|
1011
|
-
type DefinedAlarmHandlers<Definitions extends AlarmDefinitions, R = never, E = never> = { readonly [Tag in keyof Definitions & string]: (event: DefinedAlarmEvent<Tag, AlarmDefinitionPayload<Definitions[Tag]>>) => Effect.Effect<void, E, R>; };
|
|
1012
|
-
declare const define: <const Definitions extends AlarmDefinitions>(definitions: Definitions) => {
|
|
1013
|
-
handlers: <R = never, E = never>(handlers: DefinedAlarmHandlers<Definitions, R, E>, options?: ProcessDueAlarmsOptions<R, E>) => Effect.Effect<ProcessDueAlarmsResult, E | DurableObjectAlarmError, R | DurableObjectAlarm>;
|
|
1014
|
-
};
|
|
1015
|
-
declare const DurableObjectAlarm_base: Context.ServiceClass<DurableObjectAlarm, "effect-cf/DurableObjectAlarm", AlarmScheduler>;
|
|
1016
|
-
declare class DurableObjectAlarm extends DurableObjectAlarm_base {
|
|
1017
|
-
static readonly layer: Layer.Layer<DurableObjectAlarm, never, DurableObjectState>;
|
|
1018
|
-
}
|
|
1056
|
+
declare function make$6<ROut, LayerError>(layer: Layer.Layer<ROut, LayerError, RuntimeContext$1<never>> & CheckAlarmRegistration<ROut, never>): DurableObjectClass<Record<never, never>, ROut>;
|
|
1057
|
+
declare function make$6<ROut, LayerError, REvent = never, EventLayerError = never, const Rpc extends DurableObjectRpc<NoInfer<ROut> | REvent | NoInfer<RAlarm>> = Record<never, never>, RAlarm = never>(layer: Layer.Layer<ROut, LayerError, RuntimeContext$1<NoInfer<RAlarm>>>, options: DurableObjectOptions<ROut, REvent, EventLayerError, Rpc, RAlarm>): DurableObjectClass<Rpc, ROut | REvent | RAlarm>;
|
|
1019
1058
|
declare namespace DurableObjectRpcWebSocket_d_exports {
|
|
1020
1059
|
export { DurableObjectRpcWebSocket, DurableObjectRpcWebSocketService, HeartbeatPolicy, LayerOptions$7 as LayerOptions, NativeWebSocketMessage, ResumableStreamDeclaration, RpcWebSocketAttachment, layer$6 as layer, resumableStream };
|
|
1021
1060
|
}
|
|
@@ -1122,7 +1161,7 @@ declare namespace DurableObjectSqlite_d_exports {
|
|
|
1122
1161
|
type SqliteLayerOptions = Omit<SqliteClient.SqliteClientConfig, "db" | "storage">;
|
|
1123
1162
|
declare const layer$5: (options?: SqliteLayerOptions) => Layer.Layer<SqliteClient.SqliteClient | SqlClient.SqlClient, never, DurableObjectState>;
|
|
1124
1163
|
declare namespace Email_d_exports {
|
|
1125
|
-
export { EmailAddress, EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult, EmailService, EmailValidationError, EmailViolation, LayerOptions$6 as LayerOptions, Tag$
|
|
1164
|
+
export { EmailAddress, EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult, EmailService, EmailValidationError, EmailViolation, LayerOptions$6 as LayerOptions, Tag$6 as Tag, TagClass$6 as TagClass, emailErrorCodes, isEmailBinding, layer$4 as layer, make$5 as make, makeClient$4 as makeClient, sendLimits, validateMessage };
|
|
1126
1165
|
}
|
|
1127
1166
|
declare const sendLimits: {
|
|
1128
1167
|
readonly maxRecipients: 50;
|
|
@@ -1219,9 +1258,9 @@ declare const isEmailBinding: <Candidate>(value: Candidate) => value is Candidat
|
|
|
1219
1258
|
declare const makeClient$4: (definition: EmailDefinition, options?: EmailSendOptions) => (email: EmailBinding) => EmailClient;
|
|
1220
1259
|
declare const layer$4: <Self>(tag: Context.Service<Self, EmailClient>, definition: LayerOptions$6) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1221
1260
|
declare const make$5: <Id extends string>(id: Id) => TagClass$6<EmailService<Id>, Id>;
|
|
1222
|
-
declare const Tag$
|
|
1261
|
+
declare const Tag$6: <Self>() => <Id extends string>(id: Id) => TagClass$6<Self, Id>;
|
|
1223
1262
|
declare namespace Images_d_exports {
|
|
1224
|
-
export { DrawStepOptions, HostedImagesClient, ImageDirectUploadOptions, ImageDirectUploadResult, ImageDrawOptions, ImageHandleClient, ImageInfoResponse, ImageInputOptions, ImageInputValue, ImageList, ImageListOptions, ImageMetadata, ImageOutputOptions, ImageSignedUrlOptions, ImageTransform, ImageTransformationOutputOptions, ImageTransformationResponseOptions, ImageTransformationResult, ImageUpdateOptions, ImageUploadOptions, ImageUploadValue, ImagesClient, ImagesDefinition, ImagesOperationError, ImagesRuntimeBinding, ImagesService, ImagesTransformationResultClient, LayerOptions$5 as LayerOptions, ProcessOptions, Step, Steps, Tag$
|
|
1263
|
+
export { DrawStepOptions, HostedImagesClient, ImageDirectUploadOptions, ImageDirectUploadResult, ImageDrawOptions, ImageHandleClient, ImageInfoResponse, ImageInputOptions, ImageInputValue, ImageList, ImageListOptions, ImageMetadata, ImageOutputOptions, ImageSignedUrlOptions, ImageTransform, ImageTransformationOutputOptions, ImageTransformationResponseOptions, ImageTransformationResult, ImageUpdateOptions, ImageUploadOptions, ImageUploadValue, ImagesClient, ImagesDefinition, ImagesOperationError, ImagesRuntimeBinding, ImagesService, ImagesTransformationResultClient, LayerOptions$5 as LayerOptions, ProcessOptions, Step, Steps, Tag$5 as Tag, TagClass$5 as TagClass, TextOptions, TypeId, draw, empty, isImagesBinding, layer$3 as layer, make$4 as make, makeClient$3 as makeClient, transform };
|
|
1225
1264
|
}
|
|
1226
1265
|
declare const TypeId: "~effect-cf/Images/Steps";
|
|
1227
1266
|
type TypeId = typeof TypeId;
|
|
@@ -1401,9 +1440,9 @@ declare const isImagesBinding: <Candidate>(value: Candidate) => value is Candida
|
|
|
1401
1440
|
declare const makeClient$3: (definition: ImagesDefinition) => (images: ImagesRuntimeBinding) => ImagesClient;
|
|
1402
1441
|
declare const layer$3: <Self>(tag: Context.Service<Self, ImagesClient>, definition: ImagesDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1403
1442
|
declare const make$4: <Id extends string>(id: Id) => TagClass$5<ImagesService<Id>, Id>;
|
|
1404
|
-
declare const Tag$
|
|
1443
|
+
declare const Tag$5: <Self>() => <Id extends string>(id: Id) => TagClass$5<Self, Id>;
|
|
1405
1444
|
declare namespace Kv_d_exports {
|
|
1406
|
-
export { Definition$2 as Definition, KvClient, KvDefinition, KvListKey, KvListOptions, KvListResult, KvOperation, KvOperationError, KvPutOptions, KvWithMetadata, LayerOptions$4 as LayerOptions, Tag$
|
|
1445
|
+
export { Definition$2 as Definition, KvClient, KvDefinition, KvListKey, KvListOptions, KvListResult, KvOperation, KvOperationError, KvPutOptions, KvWithMetadata, LayerOptions$4 as LayerOptions, Tag$4 as Tag, TagClass$4 as TagClass, isKvNamespace, layer$2 as layer, makeClient$2 as makeClient };
|
|
1407
1446
|
}
|
|
1408
1447
|
type KvOperation = "put" | "get" | "getWithMetadata" | "list" | "delete";
|
|
1409
1448
|
declare const KvOperationError_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 & {
|
|
@@ -1473,12 +1512,12 @@ interface TagClass$4<Self, Id extends string, Key, Value, EncodedValue> extends
|
|
|
1473
1512
|
declare const isKvNamespace: <Candidate>(value: Candidate) => value is Candidate & KVNamespace;
|
|
1474
1513
|
declare const makeClient$2: <Key, Value, EncodedValue>(definition: KvDefinition<Key, Value, EncodedValue>) => ((kv: KVNamespace) => KvClient<Key, Value, EncodedValue>);
|
|
1475
1514
|
declare const layer$2: <Self, Key, Value, EncodedValue>(tag: Context.Service<Self, KvClient<Key, Value, EncodedValue>>, definition: KvDefinition<Key, Value, EncodedValue>) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1476
|
-
declare const Tag$
|
|
1515
|
+
declare const Tag$4: <Self>() => <Id extends string, Key, Value, EncodedValue>(id: Id, definition: {
|
|
1477
1516
|
readonly key: Schema.Codec<Key, string>;
|
|
1478
1517
|
readonly value: Schema.Codec<Value, EncodedValue>;
|
|
1479
1518
|
}) => TagClass$4<Self, Id, Key, Value, EncodedValue>;
|
|
1480
1519
|
declare namespace R2_d_exports {
|
|
1481
|
-
export { LayerOptions$3 as LayerOptions, R2Client, R2Definition, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUploadClient, R2ObjectBodyClient, R2Operation, R2OperationError, R2PutOptions, R2PutValue, R2Service, R2UploadPartOptions, R2UploadPartValue, Tag$
|
|
1520
|
+
export { LayerOptions$3 as LayerOptions, R2Client, R2Definition, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUploadClient, R2ObjectBodyClient, R2Operation, R2OperationError, R2PutOptions, R2PutValue, R2Service, R2UploadPartOptions, R2UploadPartValue, Tag$3 as Tag, TagClass$3 as TagClass, isR2Bucket, layer$1 as layer, make$3 as make, makeClient$1 as makeClient };
|
|
1482
1521
|
}
|
|
1483
1522
|
type R2Operation = "head" | "get" | "put" | "delete" | "list" | "createMultipartUpload" | "resumeMultipartUpload" | "uploadPart" | "abortMultipartUpload" | "completeMultipartUpload" | "arrayBuffer" | "bytes" | "text" | "json" | "blob";
|
|
1484
1523
|
declare const R2OperationError_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 & {
|
|
@@ -1556,9 +1595,9 @@ declare const isR2Bucket: (value: R2BindingValue) => value is CloudflareR2Bucket
|
|
|
1556
1595
|
declare const makeClient$1: (definition: R2Definition) => ((bucket: CloudflareR2Bucket) => R2Client);
|
|
1557
1596
|
declare const layer$1: <Self>(tag: Context.Service<Self, R2Client>, definition: R2Definition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1558
1597
|
declare const make$3: <Id extends string>(id: Id) => TagClass$3<R2Service<Id>, Id>;
|
|
1559
|
-
declare const Tag$
|
|
1598
|
+
declare const Tag$3: <Self>() => <Id extends string>(id: Id) => TagClass$3<Self, Id>;
|
|
1560
1599
|
declare namespace Vectorize_d_exports {
|
|
1561
|
-
export { LayerOptions$2 as LayerOptions, Tag$
|
|
1600
|
+
export { LayerOptions$2 as LayerOptions, Tag$2 as Tag, TagClass$2 as TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails, VectorizeIndexInfo, VectorizeMatch, VectorizeMatches, VectorizeMutation, VectorizeOperation, VectorizeOperationError, VectorizeQueryOptions, VectorizeService, VectorizeValues, VectorizeVector, VectorizeVectorMetadata, VectorizeVectorMetadataFilter, VectorizeVectorMetadataValue, isVectorizeBinding, layer, make$2 as make, makeClient };
|
|
1562
1601
|
}
|
|
1563
1602
|
type VectorizeOperation = "describe" | "query" | "queryById" | "insert" | "upsert" | "deleteByIds" | "getByIds";
|
|
1564
1603
|
declare const VectorizeOperationError_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 & {
|
|
@@ -1616,7 +1655,7 @@ declare const isVectorizeBinding: (value: VectorizeBindingValue) => value is Vec
|
|
|
1616
1655
|
declare const makeClient: (definition: VectorizeDefinition) => (index: VectorizeBinding) => VectorizeClient;
|
|
1617
1656
|
declare const layer: <Self>(tag: Context.Service<Self, VectorizeClient>, definition: VectorizeDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
1618
1657
|
declare const make$2: <Id extends string>(id: Id) => TagClass$2<VectorizeService<Id>, Id>;
|
|
1619
|
-
declare const Tag$
|
|
1658
|
+
declare const Tag$2: <Self>() => <Id extends string>(id: Id) => TagClass$2<Self, Id>;
|
|
1620
1659
|
declare namespace WebTransport_d_exports {
|
|
1621
1660
|
export { Capabilities, InboundTransport, WebTransportCapability, WebTransportUnsupportedError, capabilities, inboundSessionsUnsupported, inboundTransport, isHttp3 };
|
|
1622
1661
|
}
|
|
@@ -1679,7 +1718,7 @@ declare class WebTransportUnsupportedError extends WebTransportUnsupportedError_
|
|
|
1679
1718
|
*/
|
|
1680
1719
|
declare const inboundSessionsUnsupported: Effect.Effect<never, WebTransportUnsupportedError>;
|
|
1681
1720
|
declare namespace WorkflowDefinition_d_exports {
|
|
1682
|
-
export { Definition$1 as Definition, Handler$1 as Handler, LayerOptions$1 as LayerOptions, Options$1 as Options, Tag$
|
|
1721
|
+
export { Definition$1 as Definition, Handler$1 as Handler, LayerOptions$1 as LayerOptions, Options$1 as Options, Tag$1 as Tag, TagClass$1 as TagClass, Workflow, implement$1 as implement, make$1 as make };
|
|
1683
1722
|
}
|
|
1684
1723
|
interface Definition$1<Id extends string = string, Payload extends ServiceFreeSchema$1 = ServiceFreeSchema$1, Result extends ServiceFreeSchema$1 = ServiceFreeSchema$1> {
|
|
1685
1724
|
readonly id: Id;
|
|
@@ -1711,14 +1750,14 @@ declare const make$1: <Id extends string, Payload extends ServiceFreeSchema$1, R
|
|
|
1711
1750
|
readonly payload: Payload;
|
|
1712
1751
|
readonly result: Result;
|
|
1713
1752
|
}) => TagClass$1<Definition$1<Id, Payload, Result>, Id, Payload, Result>;
|
|
1714
|
-
declare const Tag$
|
|
1753
|
+
declare const Tag$1: <Self>() => <Id extends string, Payload extends ServiceFreeSchema$1, Result extends ServiceFreeSchema$1>(id: Id, definition: {
|
|
1715
1754
|
readonly payload: Payload;
|
|
1716
1755
|
readonly result: Result;
|
|
1717
1756
|
}) => TagClass$1<Self, Id, Payload, Result>;
|
|
1718
|
-
declare const Workflow: typeof Tag$
|
|
1757
|
+
declare const Workflow: typeof Tag$1;
|
|
1719
1758
|
declare const implement$1: <ROut, const Self extends Definition$1.Any>(_definition: Self, handler: Handler$1<ROut, Self>) => Handler$1<ROut, Self>;
|
|
1720
1759
|
declare namespace Workflow_d_exports {
|
|
1721
|
-
export { Definition, Handler, LayerOptions, Options, Tag
|
|
1760
|
+
export { Definition, Handler, LayerOptions, Options, Tag, TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, WorkflowStepService, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
1722
1761
|
}
|
|
1723
1762
|
interface WorkflowEventService<Payload = unknown> {
|
|
1724
1763
|
readonly raw: WorkflowEvent<unknown>;
|
|
@@ -1790,7 +1829,7 @@ declare namespace Definition {
|
|
|
1790
1829
|
}
|
|
1791
1830
|
type LayerOptions = LayerOptions$1;
|
|
1792
1831
|
type TagClass<Self, Id extends string, Payload extends Definition$1.Any["payload"], Result extends Definition$1.Any["result"]> = TagClass$1<Self, Id, Payload, Result>;
|
|
1793
|
-
declare const Tag
|
|
1832
|
+
declare const Tag: <Self>() => <Id extends string, Payload extends Definition$1.Any["payload"], Result extends Definition$1.Any["result"]>(id: Id, definition: {
|
|
1794
1833
|
readonly payload: Payload;
|
|
1795
1834
|
readonly result: Result;
|
|
1796
1835
|
}) => TagClass<Self, Id, Payload, Result>;
|