alchemy 2.0.0-beta.22 → 2.0.0-beta.23
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/bin/alchemy.js +3 -3
- package/bin/alchemy.js.map +1 -1
- package/bin/commands/logs.ts +1 -1
- package/bin/commands/tail.ts +1 -1
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +25 -21
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/HttpServer.d.ts.map +1 -1
- package/lib/AWS/Lambda/HttpServer.js +3 -1
- package/lib/AWS/Lambda/HttpServer.js.map +1 -1
- package/lib/Cloudflare/Container/Container.d.ts +55 -2
- package/lib/Cloudflare/Container/Container.d.ts.map +1 -1
- package/lib/Cloudflare/Container/Container.js +55 -2
- package/lib/Cloudflare/Container/Container.js.map +1 -1
- package/lib/Cloudflare/D1/D1Export.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Export.js.map +1 -1
- package/lib/Cloudflare/D1/D1SqlFile.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1SqlFile.js.map +1 -1
- package/lib/Cloudflare/Queue/Queue.d.ts +34 -4
- package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/Queue.js +34 -4
- package/lib/Cloudflare/Queue/Queue.js.map +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.d.ts +33 -0
- package/lib/Cloudflare/Queue/QueueBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Queue/QueueBinding.js +33 -0
- package/lib/Cloudflare/Queue/QueueBinding.js.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +103 -6
- package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js +103 -6
- package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts +94 -0
- package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +94 -0
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Platform.js +1 -1
- package/lib/Platform.js.map +1 -1
- package/package.json +1 -1
- package/src/AWS/Lambda/Function.ts +30 -24
- package/src/AWS/Lambda/HttpServer.ts +3 -1
- package/src/Cloudflare/Container/Container.ts +55 -2
- package/src/Cloudflare/D1/D1Export.ts +1 -5
- package/src/Cloudflare/D1/D1SqlFile.ts +1 -3
- package/src/Cloudflare/Queue/Queue.ts +34 -4
- package/src/Cloudflare/Queue/QueueBinding.ts +33 -0
- package/src/Cloudflare/Workers/DurableObjectNamespace.ts +103 -6
- package/src/Cloudflare/Workers/Workflow.ts +94 -0
- package/src/Platform.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Workflow.js","sourceRoot":"","sources":["../../../src/Cloudflare/Workers/Workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,uCAAuC,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAuB,MAAM,aAAa,CAAC;AAG7E,MAAM,cAAc,GAAmB,qBAAqB,CAAC;AAE7D,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,OAAO,E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AM,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;QACtB,MAAM,EAAE,CAAC,CAAC,MAAgB;QAC1B,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK;KACf,CAAC,CAAC,EACH,MAAM,CAAC,KAAK,CACb;IACH,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACpE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACtE,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;CAC7E,CAAC,CAAC"}
|
package/lib/Platform.js
CHANGED
|
@@ -95,7 +95,7 @@ export const Platform = (type, hooks, methods) => {
|
|
|
95
95
|
.onCreate?.(resource, props)
|
|
96
96
|
.pipe(Effect.map(() => resource)) ??
|
|
97
97
|
Effect.succeed(resource))), executionContext);
|
|
98
|
-
yield* impl.pipe(Effect.flatMap((impl) => impl
|
|
98
|
+
yield* impl.pipe(Effect.flatMap((impl) => impl?.fetch
|
|
99
99
|
? (executionContext.serve?.(impl.fetch) ??
|
|
100
100
|
Effect.die("No serve handler"))
|
|
101
101
|
: Effect.void), Effect.provide(Layer.provideMerge(Layer.mergeAll(Layer.succeed(Platform.Platform, executionContext), Layer.succeed(PlatformContext, executionContext), Layer.succeed(ExecutionContext, executionContext), Layer.succeed(resource.Self, instance), Layer.succeed(Platform.Self, instance), Layer.succeed(Self, instance)), Layer.succeedContext(outerServices))));
|
package/lib/Plat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AC;SACH,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE;QACpD,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE;QACxC,GAAG,OAAO;KACX,CAAQ,CAAC;IACV,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ import { Platform, type Main, type PlatformProps } from "../../Platform.ts";
|
|
|
23
23
|
import type { LogLine, LogsInput } from "../../Provider.ts";
|
|
24
24
|
import * as Provider from "../../Provider.ts";
|
|
25
25
|
import { Resource, type ResourceBinding } from "../../Resource.ts";
|
|
26
|
+
import { Self } from "../../Self.ts";
|
|
26
27
|
import * as Serverless from "../../Serverless/index.ts";
|
|
27
28
|
import { Stack } from "../../Stack.ts";
|
|
28
29
|
import { createInternalTags, createTagsList, hasTags } from "../../Tags.ts";
|
|
@@ -617,7 +618,6 @@ export const FunctionProvider = () =>
|
|
|
617
618
|
cwd,
|
|
618
619
|
external: [
|
|
619
620
|
/^@aws-sdk\//,
|
|
620
|
-
/^@smithy\//,
|
|
621
621
|
...((props.build?.input?.external as string[]) ?? []),
|
|
622
622
|
],
|
|
623
623
|
platform: "node",
|
|
@@ -627,8 +627,9 @@ export const FunctionProvider = () =>
|
|
|
627
627
|
...props.build?.output,
|
|
628
628
|
format: "esm",
|
|
629
629
|
sourcemap: rolldownSourcemap,
|
|
630
|
-
minify: props.build?.output?.minify ??
|
|
630
|
+
minify: props.build?.output?.minify ?? false,
|
|
631
631
|
entryFileNames: "index.js",
|
|
632
|
+
codeSplitting: props.build?.output?.codeSplitting ?? false,
|
|
632
633
|
},
|
|
633
634
|
);
|
|
634
635
|
});
|
|
@@ -639,30 +640,34 @@ export const FunctionProvider = () =>
|
|
|
639
640
|
realMain,
|
|
640
641
|
virtualEntryPlugin(
|
|
641
642
|
(importPath) => `
|
|
642
|
-
import {
|
|
643
|
+
import { layer as nodeServicesLayer } from "@effect/platform-node/NodeServices";
|
|
643
644
|
import { Stack } from "alchemy/Stack";
|
|
644
645
|
import * as Config from "effect/Config";
|
|
645
646
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
646
647
|
import * as Credentials from "@distilled.cloud/aws/Credentials";
|
|
647
648
|
import * as Effect from "effect/Effect";
|
|
648
|
-
import
|
|
649
|
+
import { layer as fetchHttpClientLayer } from "effect/unstable/http/FetchHttpClient";
|
|
649
650
|
import * as Layer from "effect/Layer";
|
|
650
651
|
import * as Logger from "effect/Logger";
|
|
651
652
|
import * as Region from "@distilled.cloud/aws/Region";
|
|
652
653
|
import * as Context from "effect/Context";
|
|
653
654
|
import { MinimumLogLevel } from "effect/References";
|
|
654
655
|
|
|
655
|
-
import
|
|
656
|
+
import entry from "${importPath}";
|
|
657
|
+
|
|
658
|
+
const tag = Context.Service("${Self.key}")
|
|
659
|
+
const layer =
|
|
660
|
+
typeof entry?.build === "function"
|
|
661
|
+
? entry
|
|
662
|
+
: Layer.effect(tag, typeof entry?.asEffect === "function" ? entry.asEffect() : entry);
|
|
656
663
|
|
|
657
664
|
const platform = Layer.mergeAll(
|
|
658
|
-
|
|
659
|
-
|
|
665
|
+
nodeServicesLayer,
|
|
666
|
+
fetchHttpClientLayer,
|
|
660
667
|
// TODO(sam): wire this up to telemetry more directly
|
|
661
668
|
Logger.layer([Logger.consolePretty()]),
|
|
662
669
|
);
|
|
663
670
|
|
|
664
|
-
const tag = Context.Service("${FunctionTypeId}<${id}>")
|
|
665
|
-
|
|
666
671
|
const stack = Layer.effect(
|
|
667
672
|
Stack,
|
|
668
673
|
Effect.all([
|
|
@@ -679,7 +684,8 @@ const stack = Layer.effect(
|
|
|
679
684
|
);
|
|
680
685
|
|
|
681
686
|
const handlerEffect = tag.asEffect().pipe(
|
|
682
|
-
Effect.flatMap(func => func.ExecutionContext.exports
|
|
687
|
+
Effect.flatMap(func => func.ExecutionContext.exports),
|
|
688
|
+
Effect.flatMap(exports => exports.handler),
|
|
683
689
|
Effect.provide(
|
|
684
690
|
layer.pipe(
|
|
685
691
|
Layer.provideMerge(stack),
|
|
@@ -714,23 +720,23 @@ export default await Effect.runPromise(handlerEffect)
|
|
|
714
720
|
? new TextEncoder().encode(mainFile.content)
|
|
715
721
|
: mainFile.content;
|
|
716
722
|
|
|
717
|
-
const
|
|
718
|
-
uploadSourceMap && (sourcemap === true || sourcemap === "hidden")
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
+
const includeSourceMaps =
|
|
724
|
+
uploadSourceMap && (sourcemap === true || sourcemap === "hidden");
|
|
725
|
+
|
|
726
|
+
const extraFiles = bundleOutput.files
|
|
727
|
+
.slice(1)
|
|
728
|
+
.filter(
|
|
729
|
+
(f: Bundle.BundleFile) =>
|
|
730
|
+
includeSourceMaps || !f.path.endsWith(".map"),
|
|
731
|
+
)
|
|
732
|
+
.map((f: Bundle.BundleFile) => ({
|
|
733
|
+
path: f.path,
|
|
734
|
+
content: f.content,
|
|
735
|
+
}));
|
|
723
736
|
|
|
724
737
|
const archive = yield* zipCode(
|
|
725
738
|
code,
|
|
726
|
-
|
|
727
|
-
? [
|
|
728
|
-
{
|
|
729
|
-
path: sourceMapFile.path,
|
|
730
|
-
content: sourceMapFile.content,
|
|
731
|
-
},
|
|
732
|
-
]
|
|
733
|
-
: undefined,
|
|
739
|
+
extraFiles.length > 0 ? extraFiles : undefined,
|
|
734
740
|
);
|
|
735
741
|
return {
|
|
736
742
|
archive,
|
|
@@ -19,7 +19,9 @@ export const makeFunctionHttpHandler = <Req>(handler: Http.HttpEffect<Req>) => {
|
|
|
19
19
|
const safeHandler = Http.safeHttpEffect(handler);
|
|
20
20
|
return (event: any) => {
|
|
21
21
|
if (isFunctionURLEvent(event)) {
|
|
22
|
-
const
|
|
22
|
+
const webRequest = toWebRequest(event);
|
|
23
|
+
const request = HttpServerRequest.fromWeb(webRequest).modify({
|
|
24
|
+
url: webRequest.url,
|
|
23
25
|
remoteAddress: Option.some(event.requestContext.http.sourceIp),
|
|
24
26
|
});
|
|
25
27
|
return safeHandler.pipe(
|
|
@@ -118,8 +118,10 @@ export type Container = {
|
|
|
118
118
|
* @section Configuration
|
|
119
119
|
* The props object accepts `main` (entrypoint file), `instanceType`
|
|
120
120
|
* (compute size), `runtime` (`"bun"` or `"node"`), and
|
|
121
|
-
* `observability` settings. Use `Stack.useSync` to
|
|
122
|
-
*
|
|
121
|
+
* `observability` settings. Use `Stack.useSync` to read the
|
|
122
|
+
* surrounding stack at declaration time and pick a beefier
|
|
123
|
+
* `instanceType` in prod while keeping the cheap `dev` instance for
|
|
124
|
+
* preview environments.
|
|
123
125
|
*
|
|
124
126
|
* @example Stage-dependent configuration
|
|
125
127
|
* ```typescript
|
|
@@ -133,6 +135,57 @@ export type Container = {
|
|
|
133
135
|
* ) {}
|
|
134
136
|
* ```
|
|
135
137
|
*
|
|
138
|
+
* @section Stack-level wiring
|
|
139
|
+
* The `.make()` `export default` is the side-effect that registers
|
|
140
|
+
* the container's runtime. It must be reachable from your
|
|
141
|
+
* `alchemy.run.ts` so the bundler emits the runtime entrypoint.
|
|
142
|
+
* Provide it on the Stack's generator with `Effect.provide`.
|
|
143
|
+
*
|
|
144
|
+
* @example Wiring SandboxLive into the Stack
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // alchemy.run.ts
|
|
147
|
+
* import SandboxLive from "./src/Sandbox.runtime.ts";
|
|
148
|
+
*
|
|
149
|
+
* export default Alchemy.Stack(
|
|
150
|
+
* "MyApp",
|
|
151
|
+
* { providers: Cloudflare.providers(), state: Cloudflare.state() },
|
|
152
|
+
* Effect.gen(function* () {
|
|
153
|
+
* const worker = yield* Worker;
|
|
154
|
+
* return { url: worker.url };
|
|
155
|
+
* }).pipe(Effect.provide(SandboxLive)),
|
|
156
|
+
* );
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @section Calling from a Durable Object
|
|
160
|
+
* Use `Cloudflare.Container.bind(Sandbox)` in the **outer** init
|
|
161
|
+
* phase of a Durable Object — only the class is imported, so the
|
|
162
|
+
* DO bundle stays tiny. Then `Cloudflare.start(sandbox)` in the
|
|
163
|
+
* **inner** per-instance phase ensures the container is running
|
|
164
|
+
* and gives you a typed handle that exposes every method declared
|
|
165
|
+
* on the container's shape **plus** a `getTcpPort` helper.
|
|
166
|
+
*
|
|
167
|
+
* @example Binding and starting a container from a DO
|
|
168
|
+
* ```typescript
|
|
169
|
+
* export default class Agent extends Cloudflare.DurableObjectNamespace<Agent>()(
|
|
170
|
+
* "Agents",
|
|
171
|
+
* Effect.gen(function* () {
|
|
172
|
+
* // OUTER (init): only the class is referenced — the runtime
|
|
173
|
+
* // implementation in `Sandbox.runtime.ts` is tree-shaken out
|
|
174
|
+
* // of this DO's bundle.
|
|
175
|
+
* const sandbox = yield* Cloudflare.Container.bind(Sandbox);
|
|
176
|
+
*
|
|
177
|
+
* return Effect.gen(function* () {
|
|
178
|
+
* // INNER (per-instance): start the container and expose RPC.
|
|
179
|
+
* const container = yield* Cloudflare.start(sandbox);
|
|
180
|
+
*
|
|
181
|
+
* return {
|
|
182
|
+
* exec: (cmd: string) => container.exec(cmd),
|
|
183
|
+
* };
|
|
184
|
+
* });
|
|
185
|
+
* }),
|
|
186
|
+
* ) {}
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
136
189
|
* @section Starting from a Durable Object
|
|
137
190
|
* Use `Cloudflare.Container.bind` in the outer init phase to bind
|
|
138
191
|
* the container class, then `Cloudflare.start` in the inner
|
|
@@ -35,11 +35,7 @@ export const exportD1Database = (
|
|
|
35
35
|
|
|
36
36
|
const poll = (
|
|
37
37
|
currentBookmark?: string,
|
|
38
|
-
): Effect.Effect<
|
|
39
|
-
ExportD1DatabaseResult,
|
|
40
|
-
d1.ExportDatabaseError,
|
|
41
|
-
never
|
|
42
|
-
> =>
|
|
38
|
+
): Effect.Effect<ExportD1DatabaseResult, d1.ExportDatabaseError, never> =>
|
|
43
39
|
Effect.gen(function* () {
|
|
44
40
|
const data = yield* exportDb({
|
|
45
41
|
accountId: options.accountId,
|
|
@@ -29,9 +29,7 @@ export const listSqlFiles = (directory: string) =>
|
|
|
29
29
|
return a.localeCompare(b);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
return yield* Effect.all(
|
|
33
|
-
sqlFiles.map((id) => readSqlFile(directory, id)),
|
|
34
|
-
);
|
|
32
|
+
return yield* Effect.all(sqlFiles.map((id) => readSqlFile(directory, id)));
|
|
35
33
|
});
|
|
36
34
|
|
|
37
35
|
/**
|
|
@@ -49,12 +49,42 @@ export type Queue = Resource<
|
|
|
49
49
|
* ```
|
|
50
50
|
*
|
|
51
51
|
* @section Binding to a Worker
|
|
52
|
+
* In an Effect-style Worker, use `Cloudflare.QueueBinding.bind` in
|
|
53
|
+
* the init phase and provide `Cloudflare.QueueBindingLive` in the
|
|
54
|
+
* runtime layer. The returned `QueueSender` exposes `send` and
|
|
55
|
+
* `sendBatch`.
|
|
56
|
+
*
|
|
52
57
|
* @example Sending messages from a Worker
|
|
53
58
|
* ```typescript
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
59
|
+
* import * as Cloudflare from "alchemy/Cloudflare";
|
|
60
|
+
* import * as Effect from "effect/Effect";
|
|
61
|
+
* import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
|
|
62
|
+
* import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
|
63
|
+
*
|
|
64
|
+
* export const Queue = Cloudflare.Queue("Queue");
|
|
65
|
+
*
|
|
66
|
+
* export default Cloudflare.Worker(
|
|
67
|
+
* "Worker",
|
|
68
|
+
* { main: import.meta.path },
|
|
69
|
+
* Effect.gen(function* () {
|
|
70
|
+
* const queue = yield* Cloudflare.QueueBinding.bind(Queue);
|
|
71
|
+
*
|
|
72
|
+
* return {
|
|
73
|
+
* fetch: Effect.gen(function* () {
|
|
74
|
+
* const request = yield* HttpServerRequest;
|
|
75
|
+
* if (request.url === "/queue/send" && request.method === "POST") {
|
|
76
|
+
* const text = yield* request.text;
|
|
77
|
+
* yield* queue.send({ text, sentAt: Date.now() }).pipe(Effect.orDie);
|
|
78
|
+
* return yield* HttpServerResponse.json(
|
|
79
|
+
* { sent: { text } },
|
|
80
|
+
* { status: 202 },
|
|
81
|
+
* );
|
|
82
|
+
* }
|
|
83
|
+
* return HttpServerResponse.text("Not Found", { status: 404 });
|
|
84
|
+
* }),
|
|
85
|
+
* };
|
|
86
|
+
* }).pipe(Effect.provide(Cloudflare.QueueBindingLive)),
|
|
87
|
+
* );
|
|
58
88
|
* ```
|
|
59
89
|
*/
|
|
60
90
|
export const Queue = Resource<Queue>("Cloudflare.Queue")({
|
|
@@ -26,6 +26,39 @@ export class QueueSendError extends Data.TaggedError("QueueSendError")<{
|
|
|
26
26
|
cause?: unknown;
|
|
27
27
|
}> {}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Binding service that turns a {@link Queue} resource into a typed
|
|
31
|
+
* {@link QueueSender} you can call from a Worker's runtime Effect.
|
|
32
|
+
*
|
|
33
|
+
* @section Sending Messages
|
|
34
|
+
* Bind the queue in the Worker's init phase, then use `send` for
|
|
35
|
+
* single messages or `sendBatch` for many messages in one call.
|
|
36
|
+
* Messages can be any JSON-serializable value.
|
|
37
|
+
*
|
|
38
|
+
* @example Producer route
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const queue = yield* Cloudflare.QueueBinding.bind(Queue);
|
|
41
|
+
*
|
|
42
|
+
* return {
|
|
43
|
+
* fetch: Effect.gen(function* () {
|
|
44
|
+
* yield* queue.send({ text: "hi", sentAt: Date.now() });
|
|
45
|
+
* return HttpServerResponse.empty({ status: 202 });
|
|
46
|
+
* }),
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example Sending a batch
|
|
51
|
+
* ```typescript
|
|
52
|
+
* yield* queue.sendBatch([
|
|
53
|
+
* { body: { event: "click", id: 1 } },
|
|
54
|
+
* { body: { event: "click", id: 2 } },
|
|
55
|
+
* { body: "raw text", contentType: "text" },
|
|
56
|
+
* ]);
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Provide {@link QueueBindingLive} in the worker's runtime layer to
|
|
60
|
+
* resolve the underlying Cloudflare queue at request time.
|
|
61
|
+
*/
|
|
29
62
|
export class QueueBinding extends Binding.Service<
|
|
30
63
|
QueueBinding,
|
|
31
64
|
(queue: Queue) => Effect.Effect<QueueSender>
|
|
@@ -301,6 +301,51 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
301
301
|
* };
|
|
302
302
|
* ```
|
|
303
303
|
*
|
|
304
|
+
* @section Returning Streams from RPC
|
|
305
|
+
* RPC methods can return an Effect `Stream` and the caller will see
|
|
306
|
+
* the chunks as they're produced. Combine with `Stream.schedule` to
|
|
307
|
+
* pace emission, or with `Stream.fromQueue` to bridge an inbound
|
|
308
|
+
* subscription.
|
|
309
|
+
*
|
|
310
|
+
* @example Streaming sequential numbers
|
|
311
|
+
* ```typescript
|
|
312
|
+
* import * as Schedule from "effect/Schedule";
|
|
313
|
+
* import * as Stream from "effect/Stream";
|
|
314
|
+
*
|
|
315
|
+
* return {
|
|
316
|
+
* tick: (n: number) =>
|
|
317
|
+
* Stream.iterate(0, (i) => i + 1).pipe(
|
|
318
|
+
* Stream.take(n),
|
|
319
|
+
* Stream.schedule(Schedule.spaced("100 millis")),
|
|
320
|
+
* ),
|
|
321
|
+
* };
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @example Forwarding the stream as a chunked HTTP response
|
|
325
|
+
* ```typescript
|
|
326
|
+
* // in a Worker fetch handler
|
|
327
|
+
* const counter = counters.getByName("tick");
|
|
328
|
+
* const stream = counter.tick(5).pipe(
|
|
329
|
+
* Stream.map((i) => `${i}\n`),
|
|
330
|
+
* Stream.encodeText,
|
|
331
|
+
* );
|
|
332
|
+
* return HttpServerResponse.stream(stream, {
|
|
333
|
+
* headers: { "content-type": "text/plain" },
|
|
334
|
+
* });
|
|
335
|
+
* ```
|
|
336
|
+
*
|
|
337
|
+
* @section Worker → DO HTTP forwarding
|
|
338
|
+
* In addition to RPC methods, the typed stub exposes a `fetch`
|
|
339
|
+
* method that forwards an `HttpServerRequest` straight to the DO.
|
|
340
|
+
* The DO's own `fetch` Effect produces the response — useful for
|
|
341
|
+
* WebSocket upgrades and other request-shaped interactions.
|
|
342
|
+
*
|
|
343
|
+
* @example Forwarding an HTTP request to a DO
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const room = rooms.getByName(roomId);
|
|
346
|
+
* return yield* room.fetch(request);
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
304
349
|
* @section Accessing Instance State
|
|
305
350
|
* Each Durable Object instance has its own transactional key-value
|
|
306
351
|
* storage via `Cloudflare.DurableObjectState`. Use `storage.get` and
|
|
@@ -356,14 +401,66 @@ export class DurableObjectNamespaceScope extends Context.Service<
|
|
|
356
401
|
* ```
|
|
357
402
|
*
|
|
358
403
|
* @example Recovering sessions after hibernation
|
|
404
|
+
* Place the rehydration loop **inside the inner `Effect.gen`** so
|
|
405
|
+
* it runs every time the DO instance is reconstructed (including
|
|
406
|
+
* after Cloudflare wakes the DO from hibernation).
|
|
407
|
+
*
|
|
359
408
|
* ```typescript
|
|
360
|
-
*
|
|
361
|
-
*
|
|
409
|
+
* return Effect.gen(function* () {
|
|
410
|
+
* const state = yield* Cloudflare.DurableObjectState;
|
|
411
|
+
* const sessions = new Map<string, Cloudflare.DurableWebSocket>();
|
|
412
|
+
*
|
|
413
|
+
* // Rehydrate the in-memory session map after hibernation.
|
|
414
|
+
* for (const socket of yield* state.getWebSockets()) {
|
|
415
|
+
* const data = socket.deserializeAttachment<{ id: string }>();
|
|
416
|
+
* if (data) sessions.set(data.id, socket);
|
|
417
|
+
* }
|
|
362
418
|
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
419
|
+
* return {
|
|
420
|
+
* fetch: Effect.gen(function* () {
|
|
421
|
+
* const [response, socket] = yield* Cloudflare.upgrade();
|
|
422
|
+
* const id = crypto.randomUUID();
|
|
423
|
+
* socket.serializeAttachment({ id });
|
|
424
|
+
* sessions.set(id, socket);
|
|
425
|
+
* return response;
|
|
426
|
+
* }),
|
|
427
|
+
* webSocketMessage: Effect.fnUntraced(function* (socket, message) {
|
|
428
|
+
* const text =
|
|
429
|
+
* typeof message === "string" ? message : new TextDecoder().decode(message);
|
|
430
|
+
* for (const peer of sessions.values()) {
|
|
431
|
+
* yield* peer.send(text);
|
|
432
|
+
* }
|
|
433
|
+
* }),
|
|
434
|
+
* };
|
|
435
|
+
* });
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @section Scheduled Alarms
|
|
439
|
+
* Each Durable Object can have a single alarm timestamp. Alchemy
|
|
440
|
+
* layers a small SQLite-backed scheduler on top via
|
|
441
|
+
* `Cloudflare.scheduleEvent` and `Cloudflare.processScheduledEvents`,
|
|
442
|
+
* so you can register many named events with arbitrary payloads and
|
|
443
|
+
* fire them from a single `alarm` handler.
|
|
444
|
+
*
|
|
445
|
+
* @example Scheduling and processing events
|
|
446
|
+
* ```typescript
|
|
447
|
+
* // schedule from a request or message handler
|
|
448
|
+
* yield* Cloudflare.scheduleEvent(
|
|
449
|
+
* "reminder-1",
|
|
450
|
+
* new Date(Date.now() + 60_000),
|
|
451
|
+
* { message: "your meeting starts in a minute" },
|
|
452
|
+
* );
|
|
453
|
+
*
|
|
454
|
+
* return {
|
|
455
|
+
* alarm: () =>
|
|
456
|
+
* Effect.gen(function* () {
|
|
457
|
+
* const fired = yield* Cloudflare.processScheduledEvents;
|
|
458
|
+
* for (const event of fired) {
|
|
459
|
+
* const payload = event.payload as { message: string };
|
|
460
|
+
* // dispatch / broadcast / persist...
|
|
461
|
+
* }
|
|
462
|
+
* }),
|
|
463
|
+
* };
|
|
367
464
|
* ```
|
|
368
465
|
*
|
|
369
466
|
* @section Using from a Worker
|
|
@@ -248,6 +248,36 @@ export class WorkflowScope extends Context.Service<
|
|
|
248
248
|
* yield* Cloudflare.sleep("cooldown", "30 seconds");
|
|
249
249
|
* ```
|
|
250
250
|
*
|
|
251
|
+
* @example Accessing env bindings inside a step
|
|
252
|
+
* `Cloudflare.WorkerEnvironment` is the same service available
|
|
253
|
+
* inside a Worker — it gives you typed access to env bindings (KV,
|
|
254
|
+
* R2, etc.) from inside a workflow body. Wrap any side-effecting
|
|
255
|
+
* call in `task` so the result is persisted across replays.
|
|
256
|
+
*
|
|
257
|
+
* ```typescript
|
|
258
|
+
* Effect.gen(function* () {
|
|
259
|
+
* const env = yield* Cloudflare.WorkerEnvironment;
|
|
260
|
+
* const event = yield* Cloudflare.WorkflowEvent;
|
|
261
|
+
* const { roomId, message } = event.payload as {
|
|
262
|
+
* roomId: string;
|
|
263
|
+
* message: string;
|
|
264
|
+
* };
|
|
265
|
+
*
|
|
266
|
+
* const stored = yield* Cloudflare.task(
|
|
267
|
+
* "kv-roundtrip",
|
|
268
|
+
* Effect.tryPromise({
|
|
269
|
+
* try: async () => {
|
|
270
|
+
* await env.KV.put(`workflow:${roomId}`, message);
|
|
271
|
+
* return await env.KV.get(`workflow:${roomId}`);
|
|
272
|
+
* },
|
|
273
|
+
* catch: (cause) =>
|
|
274
|
+
* cause instanceof Error ? cause : new Error(String(cause)),
|
|
275
|
+
* }).pipe(Effect.orDie),
|
|
276
|
+
* );
|
|
277
|
+
* return stored;
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
251
281
|
* @section Starting and Monitoring Instances
|
|
252
282
|
* @example Creating an instance from a Worker
|
|
253
283
|
* ```typescript
|
|
@@ -261,6 +291,70 @@ export class WorkflowScope extends Context.Service<
|
|
|
261
291
|
* const handle = yield* workflow.get(instanceId);
|
|
262
292
|
* const status = yield* handle.status();
|
|
263
293
|
* ```
|
|
294
|
+
*
|
|
295
|
+
* @section Triggering from a Worker
|
|
296
|
+
* Wire the workflow into HTTP routes so callers can fire instances
|
|
297
|
+
* and poll for completion.
|
|
298
|
+
*
|
|
299
|
+
* @example Workflow start + status routes
|
|
300
|
+
* ```typescript
|
|
301
|
+
* // src/worker.ts
|
|
302
|
+
* const notifier = yield* MyWorkflow;
|
|
303
|
+
*
|
|
304
|
+
* return {
|
|
305
|
+
* fetch: Effect.gen(function* () {
|
|
306
|
+
* const request = yield* HttpServerRequest;
|
|
307
|
+
*
|
|
308
|
+
* if (request.url.startsWith("/workflow/start/")) {
|
|
309
|
+
* const id = request.url.split("/").pop()!;
|
|
310
|
+
* const instance = yield* notifier.create({ id });
|
|
311
|
+
* return HttpServerResponse.json({ instanceId: instance.id });
|
|
312
|
+
* }
|
|
313
|
+
*
|
|
314
|
+
* if (request.url.startsWith("/workflow/status/")) {
|
|
315
|
+
* const id = request.url.split("/").pop()!;
|
|
316
|
+
* const instance = yield* notifier.get(id);
|
|
317
|
+
* return HttpServerResponse.json(yield* instance.status());
|
|
318
|
+
* }
|
|
319
|
+
*
|
|
320
|
+
* return HttpServerResponse.text("Not Found", { status: 404 });
|
|
321
|
+
* }),
|
|
322
|
+
* };
|
|
323
|
+
* ```
|
|
324
|
+
*
|
|
325
|
+
* @section Testing Workflows
|
|
326
|
+
* Workflows run asynchronously, so tests start an instance and
|
|
327
|
+
* poll until it reaches a terminal status. A simple recipe with
|
|
328
|
+
* `alchemy/Test/Bun`:
|
|
329
|
+
*
|
|
330
|
+
* @example Polling for workflow completion
|
|
331
|
+
* ```typescript
|
|
332
|
+
* test(
|
|
333
|
+
* "workflow completes",
|
|
334
|
+
* Effect.gen(function* () {
|
|
335
|
+
* const { url } = yield* stack;
|
|
336
|
+
*
|
|
337
|
+
* const start = yield* HttpClient.post(`${url}/workflow/start/x`);
|
|
338
|
+
* const { instanceId } = (yield* start.json) as { instanceId: string };
|
|
339
|
+
*
|
|
340
|
+
* let status: { status: string } | undefined;
|
|
341
|
+
* const deadline = Date.now() + 60_000;
|
|
342
|
+
* while (Date.now() < deadline) {
|
|
343
|
+
* const res = yield* HttpClient.get(
|
|
344
|
+
* `${url}/workflow/status/${instanceId}`,
|
|
345
|
+
* );
|
|
346
|
+
* status = (yield* res.json) as { status: string };
|
|
347
|
+
* if (status.status === "complete" || status.status === "errored") {
|
|
348
|
+
* break;
|
|
349
|
+
* }
|
|
350
|
+
* yield* Effect.sleep("2 seconds");
|
|
351
|
+
* }
|
|
352
|
+
*
|
|
353
|
+
* expect(status?.status).toBe("complete");
|
|
354
|
+
* }),
|
|
355
|
+
* { timeout: 120_000 },
|
|
356
|
+
* );
|
|
357
|
+
* ```
|
|
264
358
|
*/
|
|
265
359
|
export const Workflow: WorkflowClass = taggedFunction(WorkflowScope, ((
|
|
266
360
|
...args: [] | [name: string, impl: Effect.Effect<WorkflowBody>]
|