@effect/platform-cloudflare 0.0.0-stage → 4.1.3

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.
Files changed (237) hide show
  1. package/AGENTS.md +434 -0
  2. package/CLAUDE.md +434 -0
  3. package/LICENSE +21 -0
  4. package/README.md +505 -2
  5. package/ai-docs/README.md +44 -0
  6. package/ai-docs/package.json +36 -0
  7. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  8. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
  9. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  10. package/ai-docs/src/01_effect/01_basics/index.md +7 -0
  11. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  12. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  13. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  14. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  15. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  16. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  17. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  18. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  19. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  20. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  21. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  22. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  23. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  24. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  25. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  26. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  27. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  28. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  29. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  30. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  31. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  32. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  33. package/ai-docs/src/03_stream/30_encoding.ts +163 -0
  34. package/ai-docs/src/03_stream/index.md +4 -0
  35. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  36. package/ai-docs/src/04_integration/index.md +5 -0
  37. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  38. package/ai-docs/src/05_batching/index.md +3 -0
  39. package/ai-docs/src/06_schedule/10_schedules.ts +111 -0
  40. package/ai-docs/src/06_schedule/index.md +3 -0
  41. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  42. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  43. package/ai-docs/src/07_datetime/index.md +5 -0
  44. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  45. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  46. package/ai-docs/src/08_observability/index.md +7 -0
  47. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  48. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  49. package/ai-docs/src/09_testing/index.md +1 -0
  50. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  51. package/ai-docs/src/10_predicate/index.md +9 -0
  52. package/ai-docs/src/40_sql/10_basics.ts +175 -0
  53. package/ai-docs/src/40_sql/index.md +6 -0
  54. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  55. package/ai-docs/src/50_http-client/index.md +3 -0
  56. package/ai-docs/src/51_http-server/10_basics.ts +118 -0
  57. package/ai-docs/src/51_http-server/20_testing.ts +100 -0
  58. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  59. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  60. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  61. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
  62. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
  63. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  64. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
  65. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
  66. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
  67. package/ai-docs/src/51_http-server/index.md +3 -0
  68. package/ai-docs/src/52_graphql/10_basics.ts +117 -0
  69. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  70. package/ai-docs/src/52_graphql/30_batching.ts +118 -0
  71. package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
  72. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  73. package/ai-docs/src/52_graphql/index.md +6 -0
  74. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  75. package/ai-docs/src/60_child-process/index.md +3 -0
  76. package/ai-docs/src/70_cli/10_basics.ts +162 -0
  77. package/ai-docs/src/70_cli/index.md +5 -0
  78. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  79. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  80. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  81. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  82. package/ai-docs/src/71_ai/index.md +5 -0
  83. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  84. package/ai-docs/src/80_cluster/index.md +4 -0
  85. package/ai-docs/src/index.md +10 -0
  86. package/ai-docs/tsconfig.json +28 -0
  87. package/dist/AlchemyCloudflareCluster.d.ts +134 -0
  88. package/dist/AlchemyCloudflareCluster.d.ts.map +1 -0
  89. package/dist/AlchemyCloudflareCluster.js +111 -0
  90. package/dist/AlchemyCloudflareCluster.js.map +1 -0
  91. package/dist/CloudflareCluster.d.ts +196 -0
  92. package/dist/CloudflareCluster.d.ts.map +1 -0
  93. package/dist/CloudflareCluster.js +533 -0
  94. package/dist/CloudflareCluster.js.map +1 -0
  95. package/dist/CloudflareDurableObjectPrograms.d.ts +279 -0
  96. package/dist/CloudflareDurableObjectPrograms.d.ts.map +1 -0
  97. package/dist/CloudflareDurableObjectPrograms.js +295 -0
  98. package/dist/CloudflareDurableObjectPrograms.js.map +1 -0
  99. package/dist/CloudflareDurableObjects.d.ts +149 -0
  100. package/dist/CloudflareDurableObjects.d.ts.map +1 -0
  101. package/dist/CloudflareDurableObjects.js +337 -0
  102. package/dist/CloudflareDurableObjects.js.map +1 -0
  103. package/dist/CloudflarePersistedQueue.d.ts +36 -0
  104. package/dist/CloudflarePersistedQueue.d.ts.map +1 -0
  105. package/dist/CloudflarePersistedQueue.js +122 -0
  106. package/dist/CloudflarePersistedQueue.js.map +1 -0
  107. package/dist/CloudflareWorkflowEngine.d.ts +72 -0
  108. package/dist/CloudflareWorkflowEngine.d.ts.map +1 -0
  109. package/dist/CloudflareWorkflowEngine.js +187 -0
  110. package/dist/CloudflareWorkflowEngine.js.map +1 -0
  111. package/dist/index.d.ts +29 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +33 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/internal/alchemyCluster.d.ts +2 -0
  116. package/dist/internal/alchemyCluster.d.ts.map +1 -0
  117. package/dist/internal/alchemyCluster.js +75 -0
  118. package/dist/internal/alchemyCluster.js.map +1 -0
  119. package/dist/internal/boundedMap.d.ts +3 -0
  120. package/dist/internal/boundedMap.d.ts.map +1 -0
  121. package/dist/internal/boundedMap.js +15 -0
  122. package/dist/internal/boundedMap.js.map +1 -0
  123. package/dist/internal/cluster.d.ts +57 -0
  124. package/dist/internal/cluster.d.ts.map +1 -0
  125. package/dist/internal/cluster.js +2 -0
  126. package/dist/internal/cluster.js.map +1 -0
  127. package/dist/internal/clusterName.d.ts +2 -0
  128. package/dist/internal/clusterName.d.ts.map +1 -0
  129. package/dist/internal/clusterName.js +16 -0
  130. package/dist/internal/clusterName.js.map +1 -0
  131. package/dist/internal/entityKeepAlive.d.ts +2 -0
  132. package/dist/internal/entityKeepAlive.d.ts.map +1 -0
  133. package/dist/internal/entityKeepAlive.js +73 -0
  134. package/dist/internal/entityKeepAlive.js.map +1 -0
  135. package/dist/internal/entityMailbox.d.ts +2 -0
  136. package/dist/internal/entityMailbox.d.ts.map +1 -0
  137. package/dist/internal/entityMailbox.js +160 -0
  138. package/dist/internal/entityMailbox.js.map +1 -0
  139. package/dist/internal/entityRegistry.d.ts +16 -0
  140. package/dist/internal/entityRegistry.d.ts.map +1 -0
  141. package/dist/internal/entityRegistry.js +22 -0
  142. package/dist/internal/entityRegistry.js.map +1 -0
  143. package/dist/internal/entityReply.d.ts +2 -0
  144. package/dist/internal/entityReply.d.ts.map +1 -0
  145. package/dist/internal/entityReply.js +35 -0
  146. package/dist/internal/entityReply.js.map +1 -0
  147. package/dist/internal/entityRuntime.d.ts +2 -0
  148. package/dist/internal/entityRuntime.d.ts.map +1 -0
  149. package/dist/internal/entityRuntime.js +823 -0
  150. package/dist/internal/entityRuntime.js.map +1 -0
  151. package/dist/internal/entitySql.d.ts +2 -0
  152. package/dist/internal/entitySql.d.ts.map +1 -0
  153. package/dist/internal/entitySql.js +29 -0
  154. package/dist/internal/entitySql.js.map +1 -0
  155. package/dist/internal/entityStorage.d.ts +2 -0
  156. package/dist/internal/entityStorage.d.ts.map +1 -0
  157. package/dist/internal/entityStorage.js +98 -0
  158. package/dist/internal/entityStorage.js.map +1 -0
  159. package/dist/internal/entityWire.d.ts +2 -0
  160. package/dist/internal/entityWire.d.ts.map +1 -0
  161. package/dist/internal/entityWire.js +146 -0
  162. package/dist/internal/entityWire.js.map +1 -0
  163. package/dist/internal/queueRuntime.d.ts +2 -0
  164. package/dist/internal/queueRuntime.d.ts.map +1 -0
  165. package/dist/internal/queueRuntime.js +88 -0
  166. package/dist/internal/queueRuntime.js.map +1 -0
  167. package/dist/internal/queueStorage.d.ts +2 -0
  168. package/dist/internal/queueStorage.d.ts.map +1 -0
  169. package/dist/internal/queueStorage.js +129 -0
  170. package/dist/internal/queueStorage.js.map +1 -0
  171. package/dist/internal/registry.d.ts +10 -0
  172. package/dist/internal/registry.d.ts.map +1 -0
  173. package/dist/internal/registry.js +24 -0
  174. package/dist/internal/registry.js.map +1 -0
  175. package/dist/internal/singletonRegistry.d.ts +2 -0
  176. package/dist/internal/singletonRegistry.d.ts.map +1 -0
  177. package/dist/internal/singletonRegistry.js +9 -0
  178. package/dist/internal/singletonRegistry.js.map +1 -0
  179. package/dist/internal/singletonRuntime.d.ts +2 -0
  180. package/dist/internal/singletonRuntime.d.ts.map +1 -0
  181. package/dist/internal/singletonRuntime.js +42 -0
  182. package/dist/internal/singletonRuntime.js.map +1 -0
  183. package/dist/internal/singletonStorage.d.ts +2 -0
  184. package/dist/internal/singletonStorage.d.ts.map +1 -0
  185. package/dist/internal/singletonStorage.js +34 -0
  186. package/dist/internal/singletonStorage.js.map +1 -0
  187. package/dist/internal/transport.d.ts +2 -0
  188. package/dist/internal/transport.d.ts.map +1 -0
  189. package/dist/internal/transport.js +49 -0
  190. package/dist/internal/transport.js.map +1 -0
  191. package/dist/internal/workflowRegistry.d.ts +2 -0
  192. package/dist/internal/workflowRegistry.d.ts.map +1 -0
  193. package/dist/internal/workflowRegistry.js +29 -0
  194. package/dist/internal/workflowRegistry.js.map +1 -0
  195. package/dist/internal/workflowRuntime.d.ts +2 -0
  196. package/dist/internal/workflowRuntime.d.ts.map +1 -0
  197. package/dist/internal/workflowRuntime.js +322 -0
  198. package/dist/internal/workflowRuntime.js.map +1 -0
  199. package/dist/internal/workflowStorage.d.ts +2 -0
  200. package/dist/internal/workflowStorage.d.ts.map +1 -0
  201. package/dist/internal/workflowStorage.js +113 -0
  202. package/dist/internal/workflowStorage.js.map +1 -0
  203. package/dist/internal/workflowWire.d.ts +2 -0
  204. package/dist/internal/workflowWire.d.ts.map +1 -0
  205. package/dist/internal/workflowWire.js +52 -0
  206. package/dist/internal/workflowWire.js.map +1 -0
  207. package/package.json +74 -3
  208. package/src/AlchemyCloudflareCluster.ts +200 -0
  209. package/src/CloudflareCluster.ts +704 -0
  210. package/src/CloudflareDurableObjectPrograms.ts +543 -0
  211. package/src/CloudflareDurableObjects.ts +430 -0
  212. package/src/CloudflarePersistedQueue.ts +189 -0
  213. package/src/CloudflareWorkflowEngine.ts +220 -0
  214. package/src/index.ts +38 -0
  215. package/src/internal/alchemyCluster.ts +120 -0
  216. package/src/internal/boundedMap.ts +15 -0
  217. package/src/internal/cluster.ts +57 -0
  218. package/src/internal/clusterName.ts +19 -0
  219. package/src/internal/entityKeepAlive.ts +121 -0
  220. package/src/internal/entityMailbox.ts +324 -0
  221. package/src/internal/entityRegistry.ts +46 -0
  222. package/src/internal/entityReply.ts +54 -0
  223. package/src/internal/entityRuntime.ts +1318 -0
  224. package/src/internal/entitySql.ts +60 -0
  225. package/src/internal/entityStorage.ts +168 -0
  226. package/src/internal/entityWire.ts +204 -0
  227. package/src/internal/queueRuntime.ts +174 -0
  228. package/src/internal/queueStorage.ts +255 -0
  229. package/src/internal/registry.ts +31 -0
  230. package/src/internal/singletonRegistry.ts +21 -0
  231. package/src/internal/singletonRuntime.ts +88 -0
  232. package/src/internal/singletonStorage.ts +64 -0
  233. package/src/internal/transport.ts +67 -0
  234. package/src/internal/workflowRegistry.ts +78 -0
  235. package/src/internal/workflowRuntime.ts +443 -0
  236. package/src/internal/workflowStorage.ts +234 -0
  237. package/src/internal/workflowWire.ts +123 -0
@@ -0,0 +1,279 @@
1
+ /**
2
+ * Class-independent Durable Object programs behind the Cloudflare cluster
3
+ * integration.
4
+ *
5
+ * The bundled classes in `CloudflareDurableObjects` bind these behaviors to
6
+ * `cloudflare:workers` base classes for the Wrangler path. A framework that
7
+ * creates its own Durable Object classes (for example the Alchemy integration
8
+ * in `AlchemyCloudflareCluster`) runs these programs instead and forwards its
9
+ * class methods to the returned handles.
10
+ *
11
+ * @stability experimental
12
+ * @since 4.1.3
13
+ */
14
+ import type { DurableObjectStorage } from "@cloudflare/workers-types";
15
+ import * as Effect from "effect/Effect";
16
+ /**
17
+ * The native Durable Object capabilities a cluster program is built from.
18
+ *
19
+ * **Details**
20
+ *
21
+ * A `DurableObjectState` from `cloudflare:workers` satisfies this shape
22
+ * directly, so pass it as is. The program only reads the object name, opens
23
+ * SQLite storage, resolves same-Worker class exports, and extends the current
24
+ * event with `waitUntil`.
25
+ *
26
+ * @stability experimental
27
+ * @category models
28
+ * @since 4.1.3
29
+ */
30
+ export interface DurableObjectProgramState {
31
+ readonly id: {
32
+ readonly name?: string | undefined;
33
+ };
34
+ readonly storage: DurableObjectStorage;
35
+ readonly exports: object;
36
+ readonly waitUntil: (promise: Promise<unknown>) => void;
37
+ }
38
+ /**
39
+ * Delivery options accepted by the cluster entity transport program.
40
+ *
41
+ * @stability experimental
42
+ * @category models
43
+ * @since 4.1.3
44
+ */
45
+ export interface EntityDeliveryOptions {
46
+ readonly deliverAt?: number | undefined;
47
+ readonly primaryKey?: string | null | undefined;
48
+ readonly replyTo?: string | undefined;
49
+ }
50
+ /**
51
+ * Result returned by the cluster entity transport program.
52
+ *
53
+ * @stability experimental
54
+ * @category models
55
+ * @since 4.1.3
56
+ */
57
+ export type EntityInvokeResult = {
58
+ readonly _tag: "Success";
59
+ readonly requestId: string;
60
+ readonly replies: ReadonlyArray<string>;
61
+ } | {
62
+ readonly _tag: "MailboxFull";
63
+ } | {
64
+ readonly _tag: "EncodedMessageTooLarge";
65
+ } | {
66
+ readonly _tag: "AskDeduplicatedToTell";
67
+ };
68
+ /**
69
+ * Effect-valued program for one cluster entity Durable Object instance.
70
+ *
71
+ * **Gotchas**
72
+ *
73
+ * All program methods must keep their error channel `never`: Alchemy encodes
74
+ * typed failures as envelopes, but the native namespace transport expects
75
+ * plain results and rejected defects.
76
+ *
77
+ * @stability experimental
78
+ * @category models
79
+ * @since 4.1.3
80
+ */
81
+ export type ClusterEntityProgram = {
82
+ readonly alarm: () => Effect.Effect<void>;
83
+ readonly hold: () => Effect.Effect<void>;
84
+ readonly invoke: (envelopeText: string, discard: boolean, delivery?: EntityDeliveryOptions) => Effect.Effect<EntityInvokeResult>;
85
+ readonly acknowledge: (requestId: string, replyId: string) => Effect.Effect<ReadonlyArray<string>>;
86
+ readonly interrupt: (storageRequestId: string, clientRequestId?: string) => Effect.Effect<void>;
87
+ readonly reset: (requestId: string) => Effect.Effect<void>;
88
+ readonly deliverReply: (requestId: string, reply: string) => Effect.Effect<boolean>;
89
+ };
90
+ /**
91
+ * Creates the program behind one cluster entity Durable Object.
92
+ *
93
+ * **When to use**
94
+ *
95
+ * Use when a framework creates the native Durable Object class itself and
96
+ * needs the entity mailbox, alarm, and same-Worker RPC behavior without
97
+ * extending the bundled `ClusterEntity` class.
98
+ *
99
+ * **Details**
100
+ *
101
+ * Run the returned Effect once per Durable Object activation, after the
102
+ * Worker application (the entity handler registrations) is initialized. It
103
+ * ensures the mailbox tables and re-arms the single alarm from the earliest
104
+ * pending `deliver_at`, or the keep-alive heartbeat when that alarm is
105
+ * missing, before returning the handler object. The host class must be
106
+ * exported from the Worker entry as `ClusterEntity`; keep-alive and reply
107
+ * delivery resolve that export through `state.exports`.
108
+ *
109
+ * @stability experimental
110
+ * @category constructors
111
+ * @since 4.1.3
112
+ */
113
+ export declare const makeClusterEntityProgram: (state: DurableObjectProgramState) => Effect.Effect<ClusterEntityProgram, never, never>;
114
+ /**
115
+ * Execution options accepted by the workflow program's `run`.
116
+ *
117
+ * @stability experimental
118
+ * @category models
119
+ * @since 4.1.3
120
+ */
121
+ export interface ClusterWorkflowRunOptions {
122
+ readonly discard: boolean;
123
+ readonly parent?: {
124
+ readonly workflowName: string;
125
+ readonly executionId: string;
126
+ } | undefined;
127
+ }
128
+ /**
129
+ * How a workflow resume was requested. `"explicit"` (the default) always
130
+ * replays the execution; `"automatic"`, used for a child's completion wake,
131
+ * leaves an execution suspended by `Workflow.SuspendOnFailure` parked until
132
+ * an explicit resume.
133
+ *
134
+ * @stability experimental
135
+ * @category models
136
+ * @since 4.1.3
137
+ */
138
+ export type ClusterWorkflowWakeMode = "explicit" | "automatic";
139
+ /**
140
+ * Effect-valued program for one workflow execution Durable Object.
141
+ *
142
+ * @stability experimental
143
+ * @category models
144
+ * @since 4.1.3
145
+ */
146
+ export type ClusterWorkflowProgram = {
147
+ readonly run: (payload: string, options: ClusterWorkflowRunOptions) => Effect.Effect<string>;
148
+ readonly poll: () => Effect.Effect<string | undefined>;
149
+ readonly resume: (mode?: ClusterWorkflowWakeMode) => Effect.Effect<void>;
150
+ readonly interrupt: () => Effect.Effect<void>;
151
+ readonly interruptUnsafe: () => Effect.Effect<void>;
152
+ readonly deferredDone: (name: string, exit: string) => Effect.Effect<void>;
153
+ readonly scheduleClock: (name: string, deferredName: string, wakeUp: number) => Effect.Effect<void>;
154
+ readonly alarm: () => Effect.Effect<void>;
155
+ };
156
+ /**
157
+ * Creates the program behind one workflow execution Durable Object.
158
+ *
159
+ * **When to use**
160
+ *
161
+ * Use when a framework creates the native Durable Object class itself and
162
+ * needs the Effect Workflow journal, alarm, and same-Worker RPC behavior
163
+ * without extending the bundled `ClusterWorkflow` class.
164
+ *
165
+ * **Details**
166
+ *
167
+ * Run the returned Effect once per Durable Object activation, after the
168
+ * Worker application (the workflow handler registrations) is initialized. It
169
+ * ensures the workflow tables and re-arms the single alarm from the earliest
170
+ * pending clock before returning the handler object. The host class must be
171
+ * exported from the Worker entry as `ClusterWorkflow`; child and parent
172
+ * workflow delivery resolves that export through `state.exports`.
173
+ *
174
+ * @stability experimental
175
+ * @category constructors
176
+ * @since 4.1.3
177
+ */
178
+ export declare const makeClusterWorkflowProgram: (state: DurableObjectProgramState) => Effect.Effect<ClusterWorkflowProgram, never, never>;
179
+ /**
180
+ * Item leased from the durable queue program.
181
+ *
182
+ * @stability experimental
183
+ * @category models
184
+ * @since 4.1.3
185
+ */
186
+ export interface DurableQueueItem {
187
+ readonly id: string;
188
+ readonly element: string;
189
+ readonly attempts: number;
190
+ }
191
+ /**
192
+ * Effect-valued program for one durable queue Durable Object.
193
+ *
194
+ * @stability experimental
195
+ * @category models
196
+ * @since 4.1.3
197
+ */
198
+ export type ClusterDurableQueueProgram = {
199
+ readonly offer: (id: string, element: string, delayMillis?: number, deduplicate?: "untilExecuted" | "untilRemoved") => Effect.Effect<void>;
200
+ readonly take: (takerId: string, maxAttempts: number, leaseMillis: number) => Effect.Effect<DurableQueueItem>;
201
+ readonly cancelTake: (takerId: string) => Effect.Effect<void>;
202
+ readonly complete: (id: string, takerId: string) => Effect.Effect<void>;
203
+ readonly fail: (id: string, lastFailure: string, takerId: string, terminal?: boolean, retryDelayMillis?: number) => Effect.Effect<void>;
204
+ readonly release: (id: string, takerId: string) => Effect.Effect<void>;
205
+ readonly extend: (id: string, leaseMillis: number, takerId: string) => Effect.Effect<void>;
206
+ readonly alarm: () => Effect.Effect<void>;
207
+ };
208
+ /**
209
+ * Creates the program behind one durable queue Durable Object.
210
+ *
211
+ * **When to use**
212
+ *
213
+ * Use when a framework creates the native Durable Object class itself and
214
+ * needs the queue persistence, leasing, and alarm behavior without extending
215
+ * the bundled `ClusterDurableQueue` class.
216
+ *
217
+ * **Details**
218
+ *
219
+ * Run the returned Effect once per Durable Object activation. It ensures the
220
+ * queue table and re-arms the single alarm from the earliest pending lease
221
+ * expiry before returning the handler object.
222
+ *
223
+ * @stability experimental
224
+ * @category constructors
225
+ * @since 4.1.3
226
+ */
227
+ export declare const makeClusterDurableQueueProgram: (state: DurableObjectProgramState) => Effect.Effect<ClusterDurableQueueProgram, never, never>;
228
+ /**
229
+ * Effect-valued program for one cluster singleton Durable Object.
230
+ *
231
+ * @stability experimental
232
+ * @category models
233
+ * @since 4.1.3
234
+ */
235
+ export type ClusterSingletonProgram = {
236
+ readonly wake: () => Effect.Effect<SingletonWakeResult>;
237
+ readonly alarm: () => Effect.Effect<void>;
238
+ };
239
+ /**
240
+ * How one singleton wake ended.
241
+ *
242
+ * **Details**
243
+ *
244
+ * A failed singleton run resolves `wake()` with a `Failure` instead of
245
+ * rejecting it, so a rejected `wake()` always means the call itself failed in
246
+ * transit and is safe to retry. Retrying a failed run would rerun user code.
247
+ *
248
+ * @stability experimental
249
+ * @category models
250
+ * @since 4.1.3
251
+ */
252
+ export type SingletonWakeResult = {
253
+ readonly _tag: "Success";
254
+ } | {
255
+ readonly _tag: "Failure";
256
+ readonly message: string;
257
+ };
258
+ /**
259
+ * Creates the program behind one cluster singleton Durable Object.
260
+ *
261
+ * **When to use**
262
+ *
263
+ * Use when a framework creates the native Durable Object class itself and
264
+ * needs the singleton wake and watchdog behavior without extending the
265
+ * bundled `ClusterSingleton` class.
266
+ *
267
+ * **Details**
268
+ *
269
+ * Run the returned Effect once per Durable Object activation, after the
270
+ * Worker application (the singleton registrations) is initialized. It ensures
271
+ * the singleton state table and re-arms the watchdog alarm for a wake
272
+ * interrupted by isolate loss before returning the handler object.
273
+ *
274
+ * @stability experimental
275
+ * @category constructors
276
+ * @since 4.1.3
277
+ */
278
+ export declare const makeClusterSingletonProgram: (state: DurableObjectProgramState) => Effect.Effect<ClusterSingletonProgram, never, never>;
279
+ //# sourceMappingURL=CloudflareDurableObjectPrograms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareDurableObjectPrograms.d.ts","sourceRoot":"","sources":["../src/CloudflareDurableObjectPrograms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAQrE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAqBvC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACnD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAA;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CA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AA;AAI1D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,4FA8DtC,CAAA"}
@@ -0,0 +1,295 @@
1
+ import * as Cause from "effect/Cause";
2
+ import * as Clock from "effect/Clock";
3
+ import * as ClusterMetrics from "effect/cluster/ClusterMetrics";
4
+ import * as EntityAddress from "effect/cluster/EntityAddress";
5
+ import * as EntityId from "effect/cluster/EntityId";
6
+ import * as EntityType from "effect/cluster/EntityType";
7
+ import * as ShardId from "effect/cluster/ShardId";
8
+ import * as Effect from "effect/Effect";
9
+ import { decodeName, encodeName } from "./internal/clusterName.js";
10
+ import { makeEntityKeepAlive } from "./internal/entityKeepAlive.js";
11
+ import { keepAliveHeartbeatMillis } from "./internal/entityRegistry.js";
12
+ import { makeEntityManager } from "./internal/entityRuntime.js";
13
+ import { armAlarm, earliestDeliverAt, ensureEntityStorage, loadEntityState, rememberEntityName } from "./internal/entityStorage.js";
14
+ import { makeQueueRuntime } from "./internal/queueRuntime.js";
15
+ import { earliestLeaseExpiry } from "./internal/queueStorage.js";
16
+ import { getSingletonRegistration } from "./internal/singletonRegistry.js";
17
+ import { makeSingletonRuntime } from "./internal/singletonRuntime.js";
18
+ import { ensureSingletonStorage, loadSingletonState, rememberSingletonName } from "./internal/singletonStorage.js";
19
+ import { makeWorkflowRuntime } from "./internal/workflowRuntime.js";
20
+ import { earliestClockWakeUp, ensureWorkflowStorage, loadExecution } from "./internal/workflowStorage.js";
21
+ const exportedNamespace = (state, className) => state.exports[className];
22
+ /**
23
+ * Creates the program behind one cluster entity Durable Object.
24
+ *
25
+ * **When to use**
26
+ *
27
+ * Use when a framework creates the native Durable Object class itself and
28
+ * needs the entity mailbox, alarm, and same-Worker RPC behavior without
29
+ * extending the bundled `ClusterEntity` class.
30
+ *
31
+ * **Details**
32
+ *
33
+ * Run the returned Effect once per Durable Object activation, after the
34
+ * Worker application (the entity handler registrations) is initialized. It
35
+ * ensures the mailbox tables and re-arms the single alarm from the earliest
36
+ * pending `deliver_at`, or the keep-alive heartbeat when that alarm is
37
+ * missing, before returning the handler object. The host class must be
38
+ * exported from the Worker entry as `ClusterEntity`; keep-alive and reply
39
+ * delivery resolve that export through `state.exports`.
40
+ *
41
+ * @stability experimental
42
+ * @category constructors
43
+ * @since 4.1.3
44
+ */
45
+ export const makeClusterEntityProgram = /*#__PURE__*/Effect.fnUntraced(function* (state) {
46
+ const sql = state.storage.sql;
47
+ ensureEntityStorage(sql);
48
+ const stored = loadEntityState(sql);
49
+ // An alarm wake may carry no `id.name`; fall back to the name stored by an
50
+ // earlier activation, so heartbeat and `deliverAt` alarms still run.
51
+ const entityName = state.id.name ?? stored.name ?? "";
52
+ const name = decodeName(entityName);
53
+ if (name === undefined) {
54
+ return yield* Effect.die(new Error("ClusterEntity requires a canonical entity Durable Object name"));
55
+ }
56
+ // Written only when it changes, so a repeat activation costs no write.
57
+ if (entityName !== stored.name) rememberEntityName(sql, entityName);
58
+ const keepAlive = makeEntityKeepAlive({
59
+ startHold: () => {
60
+ const namespace = exportedNamespace(state, "ClusterEntity");
61
+ if (namespace === undefined) {
62
+ return Promise.reject(new Error("CloudflareCluster: ClusterEntity export is unavailable for keep-alive"));
63
+ }
64
+ return namespace.getByName(entityName).hold();
65
+ },
66
+ wanted: stored.keepAlive,
67
+ persist: wanted => manager.saveKeepAlive(wanted),
68
+ retryCapMillis: () => keepAliveHeartbeatMillis(name.type)
69
+ });
70
+ const manager = makeEntityManager({
71
+ storage: state.storage,
72
+ address: EntityAddress.make({
73
+ shardId: ShardId.make("default", 1),
74
+ entityType: EntityType.make(name.type),
75
+ entityId: EntityId.make(name.id)
76
+ }),
77
+ entityName,
78
+ keepAlive,
79
+ waitUntil: effect => state.waitUntil(Effect.runPromise(effect)),
80
+ getNamespace: () => exportedNamespace(state, "ClusterEntity")
81
+ });
82
+ // A stored keep-alive flag arms the heartbeat too. That repairs the chain
83
+ // after Cloudflare dropped an alarm whose retries all failed, or after a
84
+ // crash between the flag write and `setAlarm`. Arming at `now` on every
85
+ // activation would fire one wasted alarm per wake.
86
+ const deliverAt = earliestDeliverAt(sql);
87
+ const alarmAt = stored.keepAlive ? Math.min(deliverAt ?? Infinity, Date.now() + keepAliveHeartbeatMillis(name.type)) : deliverAt;
88
+ if (alarmAt !== undefined) {
89
+ yield* armAlarm(state.storage, alarmAt);
90
+ }
91
+ const program = {
92
+ alarm: () => manager.alarm,
93
+ hold: () => keepAlive.await,
94
+ invoke: (envelopeText, discard, delivery) => manager.invoke(envelopeText, discard, delivery),
95
+ acknowledge: manager.acknowledge,
96
+ interrupt: manager.interrupt,
97
+ reset: manager.reset,
98
+ deliverReply: manager.deliverReply
99
+ };
100
+ return program;
101
+ });
102
+ /**
103
+ * Creates the program behind one workflow execution Durable Object.
104
+ *
105
+ * **When to use**
106
+ *
107
+ * Use when a framework creates the native Durable Object class itself and
108
+ * needs the Effect Workflow journal, alarm, and same-Worker RPC behavior
109
+ * without extending the bundled `ClusterWorkflow` class.
110
+ *
111
+ * **Details**
112
+ *
113
+ * Run the returned Effect once per Durable Object activation, after the
114
+ * Worker application (the workflow handler registrations) is initialized. It
115
+ * ensures the workflow tables and re-arms the single alarm from the earliest
116
+ * pending clock before returning the handler object. The host class must be
117
+ * exported from the Worker entry as `ClusterWorkflow`; child and parent
118
+ * workflow delivery resolves that export through `state.exports`.
119
+ *
120
+ * @stability experimental
121
+ * @category constructors
122
+ * @since 4.1.3
123
+ */
124
+ export const makeClusterWorkflowProgram = /*#__PURE__*/Effect.fnUntraced(function* (state) {
125
+ const clock = yield* Clock.Clock;
126
+ const sql = state.storage.sql;
127
+ ensureWorkflowStorage(sql);
128
+ let name;
129
+ if (state.id.name !== undefined) {
130
+ if (decodeName(state.id.name) === undefined) {
131
+ return yield* Effect.die(new Error("ClusterWorkflow requires a canonical workflow Durable Object name"));
132
+ }
133
+ name = state.id.name;
134
+ } else {
135
+ // An alarm wake carries no `id.name`; recover it from the stored
136
+ // execution so due clocks still fire after eviction.
137
+ const stored = loadExecution(sql);
138
+ name = stored === undefined ? undefined : encodeName(stored.workflowName, stored.executionId);
139
+ }
140
+ let runtime;
141
+ const getRuntime = () => {
142
+ if (runtime !== undefined) return runtime;
143
+ if (name === undefined) {
144
+ throw new Error("ClusterWorkflow requires a canonical workflow Durable Object name");
145
+ }
146
+ runtime = makeWorkflowRuntime({
147
+ name,
148
+ sql,
149
+ alarm: state.storage,
150
+ now: () => clock.currentTimeMillisUnsafe(),
151
+ waitUntil: promise => state.waitUntil(promise),
152
+ getStub: stubName => {
153
+ const namespace = exportedNamespace(state, "ClusterWorkflow");
154
+ if (namespace === undefined) {
155
+ throw new Error("CloudflareCluster: ClusterWorkflow export is unavailable for workflow delivery");
156
+ }
157
+ return namespace.getByName(stubName);
158
+ }
159
+ });
160
+ return runtime;
161
+ };
162
+ const wakeUp = earliestClockWakeUp(sql);
163
+ if (wakeUp !== undefined) {
164
+ yield* armAlarm(state.storage, wakeUp);
165
+ }
166
+ const program = {
167
+ run: (payload, options) => Effect.promise(() => getRuntime().run(payload, options)),
168
+ poll: () => Effect.promise(() => getRuntime().poll()),
169
+ resume: mode => Effect.promise(() => getRuntime().resume(mode)),
170
+ interrupt: () => Effect.promise(() => getRuntime().interrupt()),
171
+ interruptUnsafe: () => Effect.promise(() => getRuntime().interruptUnsafe()),
172
+ deferredDone: (deferredName, exit) => Effect.promise(() => getRuntime().deferredDone(deferredName, exit)),
173
+ scheduleClock: (clockName, deferredName, wakeAt) => Effect.promise(() => getRuntime().scheduleClock(clockName, deferredName, wakeAt)),
174
+ // No stored execution means no clock could have armed this alarm.
175
+ alarm: () => name === undefined ? Effect.void : Effect.promise(() => getRuntime().runAlarm())
176
+ };
177
+ return program;
178
+ });
179
+ /**
180
+ * Creates the program behind one durable queue Durable Object.
181
+ *
182
+ * **When to use**
183
+ *
184
+ * Use when a framework creates the native Durable Object class itself and
185
+ * needs the queue persistence, leasing, and alarm behavior without extending
186
+ * the bundled `ClusterDurableQueue` class.
187
+ *
188
+ * **Details**
189
+ *
190
+ * Run the returned Effect once per Durable Object activation. It ensures the
191
+ * queue table and re-arms the single alarm from the earliest pending lease
192
+ * expiry before returning the handler object.
193
+ *
194
+ * @stability experimental
195
+ * @category constructors
196
+ * @since 4.1.3
197
+ */
198
+ export const makeClusterDurableQueueProgram = /*#__PURE__*/Effect.fnUntraced(function* (state) {
199
+ const clock = yield* Clock.Clock;
200
+ if (state.id.name !== undefined && decodeName(state.id.name) === undefined) {
201
+ return yield* Effect.die(new Error("ClusterDurableQueue requires a canonical queue Durable Object name"));
202
+ }
203
+ const runtime = makeQueueRuntime({
204
+ sql: state.storage.sql,
205
+ alarm: state.storage,
206
+ now: () => clock.currentTimeMillisUnsafe()
207
+ });
208
+ const expiry = earliestLeaseExpiry(state.storage.sql);
209
+ if (expiry !== undefined) {
210
+ yield* armAlarm(state.storage, expiry);
211
+ }
212
+ const program = {
213
+ offer: (id, element, delayMillis, deduplicate) => Effect.promise(() => runtime.offer(id, element, delayMillis, deduplicate)),
214
+ take: (takerId, maxAttempts, leaseMillis) => Effect.promise(() => runtime.take(takerId, maxAttempts, leaseMillis)),
215
+ cancelTake: takerId => Effect.promise(() => runtime.cancelTake(takerId)),
216
+ complete: (id, takerId) => Effect.promise(() => runtime.complete(id, takerId)),
217
+ fail: (id, lastFailure, takerId, terminal, retryDelayMillis) => Effect.promise(() => runtime.fail(id, lastFailure, takerId, terminal, retryDelayMillis)),
218
+ release: (id, takerId) => Effect.promise(() => runtime.release(id, takerId)),
219
+ extend: (id, leaseMillis, takerId) => Effect.promise(() => runtime.extend(id, leaseMillis, takerId)),
220
+ alarm: () => Effect.promise(() => runtime.runAlarm())
221
+ };
222
+ return program;
223
+ });
224
+ const wakeSuccess = {
225
+ _tag: "Success"
226
+ };
227
+ /**
228
+ * Creates the program behind one cluster singleton Durable Object.
229
+ *
230
+ * **When to use**
231
+ *
232
+ * Use when a framework creates the native Durable Object class itself and
233
+ * needs the singleton wake and watchdog behavior without extending the
234
+ * bundled `ClusterSingleton` class.
235
+ *
236
+ * **Details**
237
+ *
238
+ * Run the returned Effect once per Durable Object activation, after the
239
+ * Worker application (the singleton registrations) is initialized. It ensures
240
+ * the singleton state table and re-arms the watchdog alarm for a wake
241
+ * interrupted by isolate loss before returning the handler object.
242
+ *
243
+ * @stability experimental
244
+ * @category constructors
245
+ * @since 4.1.3
246
+ */
247
+ export const makeClusterSingletonProgram = /*#__PURE__*/Effect.fnUntraced(function* (state) {
248
+ const clock = yield* Clock.Clock;
249
+ const sql = state.storage.sql;
250
+ ensureSingletonStorage(sql);
251
+ if (state.id.name !== undefined) {
252
+ if (!state.id.name.startsWith("Singleton/")) {
253
+ return yield* Effect.die(new Error("ClusterSingleton requires a Singleton/<name> Durable Object name"));
254
+ }
255
+ rememberSingletonName(sql, state.id.name);
256
+ }
257
+ const stored = loadSingletonState(sql);
258
+ const name = state.id.name ?? stored.name;
259
+ let runtime;
260
+ const getRuntime = () => {
261
+ if (runtime !== undefined) return runtime;
262
+ if (name === undefined) {
263
+ throw new Error("ClusterSingleton requires a Singleton/<name> Durable Object name");
264
+ }
265
+ const singletonName = name.slice("Singleton/".length);
266
+ const registration = getSingletonRegistration(singletonName);
267
+ if (registration === undefined) {
268
+ throw new Error(`CloudflareCluster: no singleton registered under the name "${singletonName}"`);
269
+ }
270
+ const run = Effect.sync(() => {
271
+ ClusterMetrics.singletons.modifyUnsafe(BigInt(1), registration.context);
272
+ }).pipe(Effect.andThen(registration.run), Effect.scoped, Effect.ensuring(Effect.sync(() => {
273
+ ClusterMetrics.singletons.modifyUnsafe(BigInt(-1), registration.context);
274
+ })), Effect.provideContext(registration.context), Effect.orDie);
275
+ runtime = makeSingletonRuntime({
276
+ sql,
277
+ alarm: state.storage,
278
+ now: () => clock.currentTimeMillisUnsafe(),
279
+ run
280
+ });
281
+ return runtime;
282
+ };
283
+ if (stored.wakeAt !== undefined) {
284
+ yield* armAlarm(state.storage, stored.wakeAt);
285
+ }
286
+ const program = {
287
+ wake: () => Effect.promise(() => getRuntime().wake()).pipe(Effect.as(wakeSuccess), Effect.catchCause(cause => Effect.as(Effect.logError("Singleton run failed", cause), {
288
+ _tag: "Failure",
289
+ message: Cause.pretty(cause)
290
+ }))),
291
+ alarm: () => Effect.suspend(() => loadSingletonState(sql).wakeAt === undefined ? Effect.void : Effect.promise(() => getRuntime().runAlarm()))
292
+ };
293
+ return program;
294
+ });
295
+ //# sourceMappingURL=CloudflareDurableObjectPrograms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareDurableObjectPrograms.js","names":[],"sources":["../src/CloudflareDurableObjectPrograms.ts"],"sourcesContent":[null],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,cAAc,MAAM,+BAA+B;AAC/D,OAAO,KAAK,aAAa,MAAM,8BAA8B;AAC7D,OAAO,KAAK,QAAQ,MAAM,yBAAyB;AACnD,OAAO,KAAK,UAAU,MAAM,2BAA2B;AACvD,OAAO,KAAK,OAAO,MAAM,wBAAwB;AACjD,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,UAAU,EAAE,UAAU,QAAQ,2BAA2B;AAClE,SAAS,mBAAmB,QAAQ,+BAA+B;AACnE,SAAS,wBAAwB,QAAQ,8BAA8B;AACvE,SAAS,iBAAiB,QAAQ,6BAA6B;AAC/D,SACE,QAAQ,EACR,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,QACb,6BAA6B;AACpC,SAAS,gBAAgB,QAAQ,4BAA4B;AAC7D,SAAS,mBAAmB,QAAQ,4BAA4B;AAChE,SAAS,wBAAwB,QAAQ,iCAAiC;AAC1E,SAAS,oBAAoB,QAAQ,gCAAgC;AACrE,SAAS,sBAAsB,EAAE,kBAAkB,EAAE,qBAAqB,QAAQ,gCAAgC;AAElH,SAAS,mBAAmB,QAAQ,+BAA+B;AACnE,SAAS,mBAAmB,EAAE,qBAAqB,EAAE,aAAa,QAAQ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