effect-cf 0.27.0 → 0.28.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/dist/{Artifacts-DcoXcRP5.d.mts → Artifacts-DnHQA-Ax.d.mts} +42 -25
- package/dist/{Artifacts-BhWrdyqX.mjs → Artifacts-rq3hUKQE.mjs} +46 -30
- package/dist/{Binding-COCtoJXa.d.mts → Binding-xJJJPmiD.d.mts} +6 -5
- package/dist/ComputerArtifacts.d.mts +1 -1
- package/dist/ComputerArtifacts.mjs +9 -9
- package/dist/ComputerWorkspace.d.mts +5 -5
- package/dist/ComputerWorkspace.mjs +107 -75
- package/dist/ComputerWorkspaceHost.d.mts +1 -1
- package/dist/ComputerWorkspaceHost.mjs +18 -16
- package/dist/{DurableObjectState-biHrHwrh.d.mts → DurableObjectState-B3uFY1eM.d.mts} +85 -62
- package/dist/{DurableObjectState-Dux8KfjG.mjs → DurableObjectState-BjkK2kwH.mjs} +3 -3
- package/dist/{ErrorMessage-_lg53p3W.mjs → ErrorMessage-BM0K-Nik.mjs} +1 -4
- package/dist/{Hyperdrive-6p59yyVk.d.mts → Hyperdrive-z-9fFz15.d.mts} +2 -2
- package/dist/HyperdrivePg.d.mts +2 -2
- package/dist/Vitest.d.mts +6 -5
- package/dist/Vitest.mjs +2 -2
- package/dist/{WorkflowBinding-zlRPCXVf.d.mts → WorkflowBinding-wZ-yGHow.d.mts} +5 -10
- package/dist/index.d.mts +82 -60
- package/dist/index.mjs +268 -170
- package/package.json +1 -1
- package/src/AiGateway.ts +62 -7
- package/src/AnalyticsEngine.ts +17 -13
- package/src/Artifacts.ts +111 -47
- package/src/Binding.ts +34 -23
- package/src/BrowserRendering.ts +72 -33
- package/src/CloudflareOtlp.ts +8 -5
- package/src/ComputerArtifacts.ts +17 -9
- package/src/ComputerWorkspace.ts +202 -98
- package/src/ComputerWorkspaceHost.ts +55 -27
- package/src/ContainerNamespace.ts +8 -9
- package/src/D1.ts +8 -14
- package/src/DurableObject.ts +27 -11
- package/src/DurableObjectAlarm.ts +17 -5
- package/src/DurableObjectDefinition.ts +89 -72
- package/src/DurableObjectNamespace.ts +26 -12
- package/src/DurableObjectRpcWebSocket.ts +9 -10
- package/src/DurableObjectState.ts +1 -0
- package/src/DurableObjectStorage.ts +5 -2
- package/src/DurableObjectWebSocket.ts +4 -1
- package/src/Email.ts +26 -25
- package/src/Hyperdrive.ts +4 -10
- package/src/Images.ts +12 -14
- package/src/Kv.ts +15 -17
- package/src/Queue.ts +2 -1
- package/src/QueueBinding.ts +7 -12
- package/src/QueueDefinition.ts +7 -2
- package/src/R2.ts +33 -24
- package/src/Rpc.ts +15 -21
- package/src/RpcDefinition.ts +33 -38
- package/src/ServiceBinding.ts +26 -8
- package/src/Vectorize.ts +45 -18
- package/src/Vitest.ts +9 -3
- package/src/WebTransport.ts +11 -5
- package/src/Worker.ts +91 -21
- package/src/WorkerDefinition.ts +143 -63
- package/src/WorkersAi.ts +50 -28
- package/src/Workflow.ts +66 -13
- package/src/WorkflowBinding.ts +18 -25
- package/src/WorkflowDefinition.ts +4 -2
- package/src/internal/Entrypoint.ts +29 -13
- package/src/internal/ErrorMessage.ts +7 -6
- package/src/internal/RpcInvocation.ts +34 -11
- package/src/internal/Runtime.ts +33 -22
- package/src/internal/WorkerContext.ts +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as WorkerEnvironment, i as WorkerConfig, n as violationsMessage, r as Environment_exports, t as causeMessage } from "./ErrorMessage-
|
|
3
|
-
import { a as layer$19, i as Service$2, n as Artifacts_exports, r as Binding_exports } from "./Artifacts-
|
|
4
|
-
import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-
|
|
5
|
-
import { Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
|
|
2
|
+
import { a as WorkerEnvironment, i as WorkerConfig, n as violationsMessage, r as Environment_exports, t as causeMessage } from "./ErrorMessage-BM0K-Nik.mjs";
|
|
3
|
+
import { a as layer$19, i as Service$2, n as Artifacts_exports, r as Binding_exports } from "./Artifacts-rq3hUKQE.mjs";
|
|
4
|
+
import { a as DurableObjectWebSocket_exports, i as fromExecutionContext, n as DurableObjectState_exports, o as fromWebSocket, r as fromDurableObjectState, s as DurableObjectStorage_exports, t as DurableObjectState } from "./DurableObjectState-BjkK2kwH.mjs";
|
|
5
|
+
import { Cause, Clock, Config, ConfigProvider, Context, Data, DateTime, Duration, Effect, Exit, Function as Function$1, Layer, ManagedRuntime, Option, Predicate, Queue, Result, Schema } from "effect";
|
|
6
6
|
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
7
7
|
import { OtlpExporter, OtlpLogger, OtlpMetrics, OtlpSerialization, OtlpTracer } from "effect/unstable/observability";
|
|
8
8
|
import { D1Client } from "@effect/sql-d1";
|
|
@@ -11,6 +11,7 @@ import * as RpcMessage from "effect/unstable/rpc/RpcMessage";
|
|
|
11
11
|
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
|
|
12
12
|
import * as RpcServer from "effect/unstable/rpc/RpcServer";
|
|
13
13
|
import { SqliteClient } from "@effect/sql-sqlite-do";
|
|
14
|
+
import { NonRetryableError } from "cloudflare:workflows";
|
|
14
15
|
//#region src/WorkersAi.ts
|
|
15
16
|
var WorkersAi_exports = /* @__PURE__ */ __exportAll({
|
|
16
17
|
Tag: () => Tag$16,
|
|
@@ -28,6 +29,7 @@ var WorkersAiOperationError = class extends Data.TaggedError("WorkersAiOperation
|
|
|
28
29
|
return `Workers AI ${this.operation} failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
|
|
29
30
|
}
|
|
30
31
|
};
|
|
32
|
+
const embeddingDimensionsKey = "shape";
|
|
31
33
|
const workersAiError = (binding, operation, cause) => new WorkersAiOperationError({
|
|
32
34
|
binding,
|
|
33
35
|
operation,
|
|
@@ -41,19 +43,31 @@ const tryWorkersAiSync = (binding, operation, evaluate) => Effect.try({
|
|
|
41
43
|
try: evaluate,
|
|
42
44
|
catch: (cause) => workersAiError(binding, operation, cause)
|
|
43
45
|
});
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
+
const WorkersAiBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "run") && Predicate.isFunction(value.run) && Predicate.hasProperty(value, "gateway") && Predicate.isFunction(value.gateway) && Predicate.hasProperty(value, "models") && Predicate.isFunction(value.models));
|
|
47
|
+
const decodeWorkersAiBinding = Schema.decodeUnknownOption(WorkersAiBindingSchema);
|
|
48
|
+
const isWorkersAiBinding = (value) => Option.isSome(decodeWorkersAiBinding(value));
|
|
46
49
|
const embeddingResponse = (value) => ({
|
|
47
50
|
data: value.data ?? [],
|
|
48
|
-
|
|
51
|
+
[embeddingDimensionsKey]: value[embeddingDimensionsKey] ?? []
|
|
49
52
|
});
|
|
53
|
+
const decodeEmbeddingResponse = Schema.decodeUnknownOption(Schema.Struct({
|
|
54
|
+
data: Schema.optional(Schema.Array(Schema.Array(Schema.Number))),
|
|
55
|
+
[embeddingDimensionsKey]: Schema.optional(Schema.Array(Schema.Number))
|
|
56
|
+
}));
|
|
50
57
|
const makeClient$15 = (definition) => (ai) => {
|
|
51
|
-
const run = Effect.fn("WorkersAi.run")((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () =>
|
|
58
|
+
const run = Effect.fn("WorkersAi.run")((model, input, options) => tryWorkersAiPromise(definition.binding, "run", () => {
|
|
59
|
+
return ai.run(model, input, options);
|
|
60
|
+
}));
|
|
52
61
|
return {
|
|
53
62
|
definition,
|
|
54
63
|
aiGatewayLogId: tryWorkersAiSync(definition.binding, "aiGatewayLogId", () => ai.aiGatewayLogId),
|
|
55
64
|
run,
|
|
56
|
-
runEmbedding: Effect.fn("WorkersAi.runEmbedding")((model, input, options) =>
|
|
65
|
+
runEmbedding: Effect.fn("WorkersAi.runEmbedding")((model, input, options) => {
|
|
66
|
+
return run(model, input, options).pipe(Effect.map((response) => Option.match(decodeEmbeddingResponse(response), {
|
|
67
|
+
onNone: () => embeddingResponse({}),
|
|
68
|
+
onSome: embeddingResponse
|
|
69
|
+
})));
|
|
70
|
+
}),
|
|
57
71
|
models: Effect.fn("WorkersAi.models")((params) => tryWorkersAiPromise(definition.binding, "models", () => ai.models(params))),
|
|
58
72
|
gateway: (gatewayId) => tryWorkersAiSync(definition.binding, "gateway", () => ai.gateway(gatewayId)),
|
|
59
73
|
rawUnsafe: Effect.succeed(ai)
|
|
@@ -88,6 +102,49 @@ var AiGatewayOperationError = class extends Data.TaggedError("AiGatewayOperation
|
|
|
88
102
|
return `AI Gateway ${this.operation} failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
|
|
89
103
|
}
|
|
90
104
|
};
|
|
105
|
+
const AiGatewayMetadata = Schema.Record(Schema.String, Schema.Union([
|
|
106
|
+
Schema.String,
|
|
107
|
+
Schema.Number,
|
|
108
|
+
Schema.Boolean,
|
|
109
|
+
Schema.Null
|
|
110
|
+
]));
|
|
111
|
+
const AiGatewayHttpMetadata = Schema.Union([AiGatewayMetadata, Schema.fromJsonString(AiGatewayMetadata)]);
|
|
112
|
+
const AiGatewayLogResponse = Schema.Struct({
|
|
113
|
+
success: Schema.Literal(true),
|
|
114
|
+
result: Schema.Struct({
|
|
115
|
+
id: Schema.String,
|
|
116
|
+
provider: Schema.String,
|
|
117
|
+
model: Schema.String,
|
|
118
|
+
model_type: Schema.optional(Schema.String),
|
|
119
|
+
path: Schema.String,
|
|
120
|
+
duration: Schema.Number,
|
|
121
|
+
request_type: Schema.optional(Schema.String),
|
|
122
|
+
request_content_type: Schema.optional(Schema.String),
|
|
123
|
+
status_code: Schema.Number,
|
|
124
|
+
response_content_type: Schema.optional(Schema.String),
|
|
125
|
+
success: Schema.Boolean,
|
|
126
|
+
cached: Schema.Boolean,
|
|
127
|
+
tokens_in: Schema.optional(Schema.Number),
|
|
128
|
+
tokens_out: Schema.optional(Schema.Number),
|
|
129
|
+
metadata: Schema.optional(AiGatewayHttpMetadata),
|
|
130
|
+
step: Schema.optional(Schema.Number),
|
|
131
|
+
cost: Schema.optional(Schema.Number),
|
|
132
|
+
custom_cost: Schema.optional(Schema.Boolean),
|
|
133
|
+
request_size: Schema.Number,
|
|
134
|
+
request_head: Schema.optional(Schema.String),
|
|
135
|
+
request_head_complete: Schema.Boolean,
|
|
136
|
+
response_size: Schema.Number,
|
|
137
|
+
response_head: Schema.optional(Schema.String),
|
|
138
|
+
response_head_complete: Schema.Boolean,
|
|
139
|
+
created_at: Schema.DateFromString
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
const AiGatewayPatchLogResponse = Schema.Struct({
|
|
143
|
+
success: Schema.Literal(true),
|
|
144
|
+
result: Schema.Unknown
|
|
145
|
+
});
|
|
146
|
+
const decodeAiGatewayLogResponse = Schema.decodeUnknownPromise(AiGatewayLogResponse);
|
|
147
|
+
const decodeAiGatewayPatchLogResponse = Schema.decodeUnknownPromise(AiGatewayPatchLogResponse);
|
|
91
148
|
const aiGatewayError = (binding, operation, cause) => new AiGatewayOperationError({
|
|
92
149
|
binding,
|
|
93
150
|
operation,
|
|
@@ -108,6 +165,9 @@ const providerUrl = (baseUrl, path = "") => {
|
|
|
108
165
|
return normalizedPath === "" ? url : new URL(normalizedPath, url);
|
|
109
166
|
};
|
|
110
167
|
const gatewayUrl = (definition) => `https://gateway.ai.cloudflare.com/v1/${definition.accountId}/${definition.gatewayId}/`;
|
|
168
|
+
const ensureSuccessfulResponse = (response) => {
|
|
169
|
+
if (!response.ok) throw new Error(`AI Gateway HTTP request failed with status ${response.status}`);
|
|
170
|
+
};
|
|
111
171
|
const isAiGatewayBinding = (value) => isWorkersAiBinding(value);
|
|
112
172
|
const makeClient$14 = (definition, gateway) => ({
|
|
113
173
|
definition,
|
|
@@ -165,14 +225,20 @@ const makeHttpClient = (definition, request = fetch) => {
|
|
|
165
225
|
...options.init,
|
|
166
226
|
signal: mergeAbortSignals(options.init?.signal, signal)
|
|
167
227
|
}))))),
|
|
168
|
-
patchLog: Effect.fn("AiGateway.patchLog")((logId, data) => tryAiGatewayPromise(binding, "patchLog", (signal) =>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
228
|
+
patchLog: Effect.fn("AiGateway.patchLog")((logId, data) => tryAiGatewayPromise(binding, "patchLog", async (signal) => {
|
|
229
|
+
const response = await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, {
|
|
230
|
+
method: "PATCH",
|
|
231
|
+
body: JSON.stringify(data),
|
|
232
|
+
headers: { "content-type": "application/json" },
|
|
233
|
+
signal
|
|
234
|
+
});
|
|
235
|
+
ensureSuccessfulResponse(response);
|
|
236
|
+
await decodeAiGatewayPatchLogResponse(await response.json());
|
|
237
|
+
})),
|
|
174
238
|
getLog: Effect.fn("AiGateway.getLog")((logId) => tryAiGatewayPromise(binding, "getLog", async (signal) => {
|
|
175
|
-
|
|
239
|
+
const response = await request(providerUrl(gatewayUrl(definition), `logs/${logId}`).href, { signal });
|
|
240
|
+
ensureSuccessfulResponse(response);
|
|
241
|
+
return (await decodeAiGatewayLogResponse(await response.json())).result;
|
|
176
242
|
})),
|
|
177
243
|
rawUnsafe: Effect.fail(aiGatewayError(binding, "rawUnsafe", /* @__PURE__ */ new TypeError("HTTP AI Gateway clients have no raw binding")))
|
|
178
244
|
};
|
|
@@ -281,7 +347,7 @@ const fieldPath = (prefix, field) => prefix === "" ? field : `${prefix}.${field}
|
|
|
281
347
|
const indexedPath = (prefix, field, index) => `${fieldPath(prefix, field)}[${index}]`;
|
|
282
348
|
const byteLength$1 = (value) => {
|
|
283
349
|
if (value === null) return 0;
|
|
284
|
-
return
|
|
350
|
+
return Predicate.isString(value) ? textEncoder$1.encode(value).byteLength : value.byteLength;
|
|
285
351
|
};
|
|
286
352
|
const lengthViolation = (path, label, actual, limit) => ({
|
|
287
353
|
path,
|
|
@@ -308,11 +374,13 @@ const schemaViolation = (pathPrefix, cause) => ({
|
|
|
308
374
|
path: pathPrefix === "" ? "$" : pathPrefix,
|
|
309
375
|
message: cause.message
|
|
310
376
|
});
|
|
311
|
-
const toAnalyticsEngineDataPoint = (dataPoint) =>
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
377
|
+
const toAnalyticsEngineDataPoint = (dataPoint) => {
|
|
378
|
+
const result = {};
|
|
379
|
+
if (dataPoint.indexes !== void 0) result.indexes = [...dataPoint.indexes];
|
|
380
|
+
if (dataPoint.doubles !== void 0) result.doubles = [...dataPoint.doubles];
|
|
381
|
+
if (dataPoint.blobs !== void 0) result.blobs = [...dataPoint.blobs];
|
|
382
|
+
return result;
|
|
383
|
+
};
|
|
316
384
|
const validateDataPoint = (binding, operation, dataPoint, pathPrefix = "") => Effect.gen(function* () {
|
|
317
385
|
const decoded = yield* decodeDataPoint(dataPoint).pipe(Effect.mapError((cause) => analyticsEngineWriteValidationError(binding, operation, [schemaViolation(pathPrefix, cause)], cause)));
|
|
318
386
|
const validated = toAnalyticsEngineDataPoint(decoded);
|
|
@@ -387,10 +455,7 @@ const makeQueryClientWith = (definition, httpClient) => {
|
|
|
387
455
|
};
|
|
388
456
|
};
|
|
389
457
|
const makeQueryClient = (definition) => Effect.map(HttpClient.HttpClient, (httpClient) => makeQueryClientWith(definition, httpClient));
|
|
390
|
-
const isAnalyticsEngineDataset = (value) =>
|
|
391
|
-
if (typeof value !== "object" || value === null) return false;
|
|
392
|
-
return typeof Reflect.get(value, "writeDataPoint") === "function";
|
|
393
|
-
};
|
|
458
|
+
const isAnalyticsEngineDataset = (value) => Predicate.hasProperty(value, "writeDataPoint") && Predicate.isFunction(value.writeDataPoint);
|
|
394
459
|
const makeClient$13 = (definition, defaults) => (dataset) => {
|
|
395
460
|
return {
|
|
396
461
|
definition,
|
|
@@ -482,9 +547,18 @@ const wrapPage = (binding, page) => ({
|
|
|
482
547
|
goto: (url, options) => page.goto === void 0 ? missingMethod(binding, "goto") : tryBrowserRenderingPromise(binding, "goto", () => page.goto(url, options)),
|
|
483
548
|
setContent: (html, options) => page.setContent === void 0 ? missingMethod(binding, "setContent") : tryBrowserRenderingPromise(binding, "setContent", () => page.setContent(html, options)),
|
|
484
549
|
content: page.content === void 0 ? missingMethod(binding, "content") : tryBrowserRenderingPromise(binding, "content", () => page.content()),
|
|
485
|
-
screenshot: (options) =>
|
|
486
|
-
|
|
487
|
-
|
|
550
|
+
screenshot: (options) => {
|
|
551
|
+
const screenshot = page.screenshot?.bind(page);
|
|
552
|
+
return screenshot === void 0 ? missingMethod(binding, "screenshot") : tryBrowserRenderingPromise(binding, "screenshot", () => screenshot(options));
|
|
553
|
+
},
|
|
554
|
+
pdf: (options) => {
|
|
555
|
+
const pdf = page.pdf?.bind(page);
|
|
556
|
+
return pdf === void 0 ? missingMethod(binding, "pdf") : tryBrowserRenderingPromise(binding, "pdf", () => pdf(options));
|
|
557
|
+
},
|
|
558
|
+
evaluate: (pageFunction, ...args) => {
|
|
559
|
+
const evaluate = page.evaluate?.bind(page);
|
|
560
|
+
return evaluate === void 0 ? missingMethod(binding, "evaluate") : tryBrowserRenderingPromise(binding, "evaluate", () => evaluate(pageFunction, ...args));
|
|
561
|
+
},
|
|
488
562
|
close: (options) => page.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closePage", () => page.close(options))
|
|
489
563
|
});
|
|
490
564
|
const wrapBrowser = (binding, browser) => ({
|
|
@@ -494,7 +568,7 @@ const wrapBrowser = (binding, browser) => ({
|
|
|
494
568
|
close: browser.close === void 0 ? Effect.void : tryBrowserRenderingPromise(binding, "closeBrowser", () => browser.close()),
|
|
495
569
|
disconnect: browser.disconnect === void 0 ? Effect.void : tryBrowserRenderingSync(binding, "disconnect", () => browser.disconnect())
|
|
496
570
|
});
|
|
497
|
-
const isBrowserRenderingBinding = (value) => (
|
|
571
|
+
const isBrowserRenderingBinding = (value) => Predicate.isObjectOrArray(value) || Predicate.isFunction(value);
|
|
498
572
|
const makeClient$12 = (definition) => (binding) => ({
|
|
499
573
|
definition,
|
|
500
574
|
launchWith: (launch, options) => tryBrowserRenderingPromise(definition.binding, "launch", () => launch(binding, options)).pipe(Effect.map((browser) => wrapBrowser(definition.binding, browser)), Effect.withSpan("BrowserRendering.launchWith")),
|
|
@@ -768,7 +842,7 @@ const makeInstanceClient = (definition, instance, stub) => {
|
|
|
768
842
|
removeDeniedHost: hostnameOperation("removeDeniedHost")
|
|
769
843
|
};
|
|
770
844
|
};
|
|
771
|
-
const isContainerNamespaceResource = (value) =>
|
|
845
|
+
const isContainerNamespaceResource = (value) => Predicate.hasProperty(value, "getByName") && Predicate.isFunction(value.getByName);
|
|
772
846
|
const makeClient$10 = (definition) => (namespace) => {
|
|
773
847
|
const getByName = (name, options) => Effect.try({
|
|
774
848
|
try: () => makeInstanceClient(definition, name, namespace.getByName(name, options)),
|
|
@@ -805,7 +879,7 @@ const makeClient$10 = (definition) => (namespace) => {
|
|
|
805
879
|
rawUnsafe: Effect.succeed(namespace)
|
|
806
880
|
};
|
|
807
881
|
};
|
|
808
|
-
const layer$12 = (tag, definition) => layer$19(tag, definition.binding, isContainerNamespaceResource, makeClient$10(definition), { expected: expectedContainerNamespace });
|
|
882
|
+
const layer$12 = (tag, definition) => layer$19(tag, definition.binding, (value) => isContainerNamespaceResource(value), makeClient$10(definition), { expected: expectedContainerNamespace });
|
|
809
883
|
const make$14 = (id) => Tag$12()(id);
|
|
810
884
|
/** Creates a typed Effect service for a Cloudflare Container namespace. */
|
|
811
885
|
const Tag$12 = () => (id) => {
|
|
@@ -848,11 +922,7 @@ var D1_exports = /* @__PURE__ */ __exportAll({
|
|
|
848
922
|
});
|
|
849
923
|
const TypeId$2 = "~effect-cf/D1";
|
|
850
924
|
const expectedD1Database = "D1 database binding with prepare(), batch(), and exec()";
|
|
851
|
-
const isD1Database = (value) =>
|
|
852
|
-
if (typeof value !== "object" || value === null) return false;
|
|
853
|
-
const resource = value;
|
|
854
|
-
return typeof resource.prepare === "function" && typeof resource.batch === "function" && typeof resource.exec === "function";
|
|
855
|
-
};
|
|
925
|
+
const isD1Database = (value) => Predicate.hasProperty(value, "prepare") && Predicate.isFunction(value.prepare) && Predicate.hasProperty(value, "batch") && Predicate.isFunction(value.batch) && Predicate.hasProperty(value, "exec") && Predicate.isFunction(value.exec);
|
|
856
926
|
/**
|
|
857
927
|
* Creates a typed D1 service tag plus Effect helpers.
|
|
858
928
|
*/
|
|
@@ -906,10 +976,7 @@ const tryQueuePromise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
|
906
976
|
message: `Cloudflare queue binding "${binding}" operation "${operation}" failed`
|
|
907
977
|
})
|
|
908
978
|
});
|
|
909
|
-
const isQueue = (value) =>
|
|
910
|
-
if (typeof value !== "object" || value === null) return false;
|
|
911
|
-
return typeof value.send === "function";
|
|
912
|
-
};
|
|
979
|
+
const isQueue = (value) => Predicate.hasProperty(value, "send") && Predicate.isFunction(value.send);
|
|
913
980
|
const makeClient$9 = (definition) => {
|
|
914
981
|
const encodeMessage = Schema.encodeEffect(definition.message);
|
|
915
982
|
return (queue) => ({
|
|
@@ -1142,7 +1209,7 @@ const encodeWireError = (error) => {
|
|
|
1142
1209
|
const decodeWireError = (cause) => {
|
|
1143
1210
|
if (!(cause instanceof Error)) return cause;
|
|
1144
1211
|
try {
|
|
1145
|
-
const parsed = JSON.parse(cause.message);
|
|
1212
|
+
const parsed = Schema.decodeUnknownSync(Schema.Unknown)(JSON.parse(cause.message));
|
|
1146
1213
|
if (!Predicate.hasProperty(parsed, wireErrorKey)) return cause;
|
|
1147
1214
|
return Schema.decodeUnknownSync(WireErrorSchema)(parsed[wireErrorKey]);
|
|
1148
1215
|
} catch {
|
|
@@ -1235,6 +1302,10 @@ const make$11 = (id, methods) => {
|
|
|
1235
1302
|
};
|
|
1236
1303
|
//#endregion
|
|
1237
1304
|
//#region src/internal/Entrypoint.ts
|
|
1305
|
+
const invokeEntrypointRpcMethod = (self, method, args, run, onExit) => {
|
|
1306
|
+
const handler = Effect.suspend(() => method(...args)).pipe(Effect.mapError(encodeWireError));
|
|
1307
|
+
return run(self, onExit === void 0 ? handler : handler.pipe(Effect.onExit(() => onExit(self))));
|
|
1308
|
+
};
|
|
1238
1309
|
const provideEntrypointServices = (layer, services) => layer.pipe(Layer.provideMerge(services));
|
|
1239
1310
|
const defineEntrypointRpcMethods = (target, prototype, rpc, reservedMethodNames, run, onExit) => {
|
|
1240
1311
|
const methods = rpc ?? {};
|
|
@@ -1242,12 +1313,13 @@ const defineEntrypointRpcMethods = (target, prototype, rpc, reservedMethodNames,
|
|
|
1242
1313
|
for (const [key, method] of Object.entries(methods)) Object.defineProperty(prototype, key, {
|
|
1243
1314
|
enumerable: true,
|
|
1244
1315
|
value(...args) {
|
|
1245
|
-
|
|
1246
|
-
return run(this, onExit === void 0 ? handler : handler.pipe(Effect.onExit(() => onExit(this))));
|
|
1316
|
+
return invokeEntrypointRpcMethod(this, method, args, run, onExit);
|
|
1247
1317
|
}
|
|
1248
1318
|
});
|
|
1249
1319
|
};
|
|
1250
|
-
const assumeEntrypointClass = (entrypoint) =>
|
|
1320
|
+
const assumeEntrypointClass = (entrypoint) => {
|
|
1321
|
+
return entrypoint;
|
|
1322
|
+
};
|
|
1251
1323
|
//#endregion
|
|
1252
1324
|
//#region src/internal/Runtime.ts
|
|
1253
1325
|
/**
|
|
@@ -1263,18 +1335,11 @@ const makeEntrypointRuntime = (layer, env, services) => {
|
|
|
1263
1335
|
const entrypointServices = Layer.mergeAll(services, ConfigProvider.layer(WorkerConfig.providerFromEnv(env)), Layer.succeed(WorkerEnvironment, env));
|
|
1264
1336
|
return ManagedRuntime.make(provideEntrypointServices(layer, entrypointServices));
|
|
1265
1337
|
};
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
* `REvent` requirement satisfied by the event layer; TypeScript cannot reduce
|
|
1272
|
-
* `Exclude<...>` over the generic union.
|
|
1273
|
-
*/
|
|
1274
|
-
const runEventPromise = (runtime, effect, eventLayer) => {
|
|
1275
|
-
const withEventLayer = eventLayer === void 0 ? effect : effect.pipe(Effect.provide(eventLayer, { local: true }));
|
|
1276
|
-
return runtime.runPromise(Effect.scoped(withEventLayer));
|
|
1277
|
-
};
|
|
1338
|
+
function runEventPromise(...args) {
|
|
1339
|
+
const [runtime, effect, eventLayer] = args;
|
|
1340
|
+
if (eventLayer === void 0) return runtime.runPromise(Effect.scoped(effect));
|
|
1341
|
+
return runtime.runPromise(Effect.scoped(effect.pipe(Effect.provide(eventLayer, { local: true }))));
|
|
1342
|
+
}
|
|
1278
1343
|
//#endregion
|
|
1279
1344
|
//#region src/internal/Telemetry.ts
|
|
1280
1345
|
const logFlushFailure = Effect.logError("Telemetry flush failed").pipe(Effect.ignoreCause);
|
|
@@ -1297,25 +1362,30 @@ var Rpc_exports = /* @__PURE__ */ __exportAll({
|
|
|
1297
1362
|
resolve: () => resolve,
|
|
1298
1363
|
scoped: () => scoped
|
|
1299
1364
|
});
|
|
1300
|
-
const isDisposable = (value) => (
|
|
1365
|
+
const isDisposable = (value) => Predicate.hasProperty(value, Symbol.dispose) && Predicate.isFunction(value[Symbol.dispose]);
|
|
1301
1366
|
const dispose = (value) => Effect.sync(() => {
|
|
1302
1367
|
if (isDisposable(value)) value[Symbol.dispose]();
|
|
1303
1368
|
});
|
|
1304
|
-
const resolve = (value) => isPromiseLike(value) ? Effect.tryPromise({
|
|
1305
|
-
try: () => value,
|
|
1369
|
+
const resolve = (value) => Predicate.isPromiseLike(value) ? Effect.tryPromise({
|
|
1370
|
+
try: () => Promise.resolve(value),
|
|
1306
1371
|
catch: (cause) => decodeWireError(cause)
|
|
1307
|
-
}) : Effect.sync(() =>
|
|
1372
|
+
}) : Effect.sync(() => {
|
|
1373
|
+
return value;
|
|
1374
|
+
});
|
|
1308
1375
|
const scoped = (value) => Effect.acquireRelease(resolve(value), (resolved) => dispose(resolved));
|
|
1309
|
-
const isPromiseLike = (value) => (typeof value === "object" || typeof value === "function") && value !== null && "then" in value && typeof value.then === "function";
|
|
1310
1376
|
//#endregion
|
|
1311
1377
|
//#region src/internal/RpcInvocation.ts
|
|
1312
|
-
const
|
|
1378
|
+
const invokeWithReceiver = (value, receiver, args) => {
|
|
1379
|
+
return Function.prototype.apply.call(value, receiver, args);
|
|
1380
|
+
};
|
|
1313
1381
|
const lookupRpcMethod = (target, method, makeError) => Effect.try({
|
|
1314
1382
|
try: () => {
|
|
1315
|
-
if (!
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1318
|
-
|
|
1383
|
+
if (!Predicate.isObjectKeyword(target)) throw new TypeError(`RPC target is not object-like`);
|
|
1384
|
+
const receiver = target;
|
|
1385
|
+
const value = receiver[method];
|
|
1386
|
+
if (!Predicate.isFunction(value)) throw new TypeError(`RPC method "${String(method)}" is not callable`);
|
|
1387
|
+
const callable = value;
|
|
1388
|
+
return (...args) => invokeWithReceiver(callable, receiver, args);
|
|
1319
1389
|
},
|
|
1320
1390
|
catch: makeError
|
|
1321
1391
|
});
|
|
@@ -1355,7 +1425,9 @@ var ServiceBindingRpcError = class extends Data.TaggedError("ServiceBindingRpcEr
|
|
|
1355
1425
|
return `Service binding "${this.binding}" RPC method "${this.method}" failed: ${causeMessage(this.cause)}`;
|
|
1356
1426
|
}
|
|
1357
1427
|
};
|
|
1358
|
-
const
|
|
1428
|
+
const ServiceBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "fetch") && Predicate.isFunction(value.fetch));
|
|
1429
|
+
const decodeServiceBinding = Schema.decodeUnknownOption(ServiceBindingSchema);
|
|
1430
|
+
const isServiceBindingClient = (value) => Option.isSome(decodeServiceBinding(value));
|
|
1359
1431
|
const makeClient$8 = (definition) => {
|
|
1360
1432
|
return (service) => {
|
|
1361
1433
|
const fetch = Effect.fn("ServiceBinding.fetch")(function* (input, init) {
|
|
@@ -1468,7 +1540,10 @@ const Service = () => (id, definition) => {
|
|
|
1468
1540
|
};
|
|
1469
1541
|
const makeDirectMethods$1 = (rpcDefinition, call) => {
|
|
1470
1542
|
const methods = {};
|
|
1471
|
-
if (rpcDefinition !== void 0)
|
|
1543
|
+
if (rpcDefinition !== void 0) {
|
|
1544
|
+
const invoke = call;
|
|
1545
|
+
for (const methodName of Object.keys(rpcDefinition.methods)) methods[methodName] = (...args) => invoke(methodName, ...args);
|
|
1546
|
+
}
|
|
1472
1547
|
return methods;
|
|
1473
1548
|
};
|
|
1474
1549
|
//#endregion
|
|
@@ -1496,6 +1571,9 @@ const reservedMethodNames$3 = /* @__PURE__ */ new Set([
|
|
|
1496
1571
|
"webSocketClose",
|
|
1497
1572
|
"webSocketError"
|
|
1498
1573
|
]);
|
|
1574
|
+
const assumeTagClass = (value) => {
|
|
1575
|
+
return value;
|
|
1576
|
+
};
|
|
1499
1577
|
/**
|
|
1500
1578
|
* Defines a single RPC method schema in a worker definition.
|
|
1501
1579
|
*/
|
|
@@ -1516,10 +1594,14 @@ const method$1 = method$2;
|
|
|
1516
1594
|
const makeDefinition$3 = (id, methods) => {
|
|
1517
1595
|
assertNoReservedMethods("Worker", methods, reservedMethodNames$3);
|
|
1518
1596
|
const definition = make$11(id, methods);
|
|
1519
|
-
return Object.assign(definition, { make: (layer, options) =>
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1597
|
+
return Object.assign(definition, { make: (layer, options) => {
|
|
1598
|
+
const workerOptions = {
|
|
1599
|
+
...options,
|
|
1600
|
+
rpc: wrapHandlers$1(definition, options.rpc)
|
|
1601
|
+
};
|
|
1602
|
+
if (workerOptions.eventLayer === void 0) return make$9(layer, workerOptions);
|
|
1603
|
+
return make$9(layer, workerOptions);
|
|
1604
|
+
} });
|
|
1523
1605
|
};
|
|
1524
1606
|
const make$10 = (id, methods) => Tag$9()(id, methods);
|
|
1525
1607
|
const Tag$9 = () => (id, methods) => {
|
|
@@ -1543,7 +1625,7 @@ const Tag$9 = () => (id, methods) => {
|
|
|
1543
1625
|
return yield* (yield* tag).scopedCall(method, ...args);
|
|
1544
1626
|
});
|
|
1545
1627
|
const directMethods = makeDirectMethods$1(definition, call);
|
|
1546
|
-
return Object.assign(tag, directMethods, {
|
|
1628
|
+
return assumeTagClass(Object.assign(tag, directMethods, {
|
|
1547
1629
|
id: definition.id,
|
|
1548
1630
|
methods: definition.methods,
|
|
1549
1631
|
make: definition.make,
|
|
@@ -1552,11 +1634,11 @@ const Tag$9 = () => (id, methods) => {
|
|
|
1552
1634
|
rpc,
|
|
1553
1635
|
call,
|
|
1554
1636
|
scopedCall
|
|
1555
|
-
});
|
|
1637
|
+
}));
|
|
1556
1638
|
};
|
|
1557
1639
|
const Worker = Tag$9;
|
|
1558
1640
|
const wrapHandlers$1 = (definition, handlers) => {
|
|
1559
|
-
const wrapped =
|
|
1641
|
+
const wrapped = Object.create(null);
|
|
1560
1642
|
for (const key of Object.keys(definition.methods)) {
|
|
1561
1643
|
const handler = handlers[key];
|
|
1562
1644
|
wrapped[key] = (...args) => Effect.gen(function* () {
|
|
@@ -1666,8 +1748,10 @@ function make$9(layer, optionsOrFetch) {
|
|
|
1666
1748
|
super(ctx, env);
|
|
1667
1749
|
this.runtime = makeEntrypointRuntime(layer, env, Layer.mergeAll(Layer.succeed(ExecutionContext, ctx), Layer.succeed(WorkerContext, fromExecutionContext(ctx))));
|
|
1668
1750
|
}
|
|
1669
|
-
[RunSymbol$1](effect
|
|
1670
|
-
|
|
1751
|
+
[RunSymbol$1](effect) {
|
|
1752
|
+
const eventLayer = options.eventLayer;
|
|
1753
|
+
if (eventLayer === void 0) return runEventPromise(this.runtime, effect);
|
|
1754
|
+
return runEventPromise(this.runtime, effect, eventLayer);
|
|
1671
1755
|
}
|
|
1672
1756
|
fetch(request) {
|
|
1673
1757
|
return this[FetchSymbol](request);
|
|
@@ -1689,19 +1773,8 @@ function make$9(layer, optionsOrFetch) {
|
|
|
1689
1773
|
defineEntrypointRpcMethods("Worker", EffectWorker.prototype, options.rpc, reservedMethodNames$2, (self, effect) => self[RunSymbol$1](effect), () => scheduleTelemetryFlush$1);
|
|
1690
1774
|
return assumeEntrypointClass(EffectWorker);
|
|
1691
1775
|
}
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
* {@link make}.
|
|
1695
|
-
*
|
|
1696
|
-
* The Effect runtime is cached per `env` identity, so the user layer builds
|
|
1697
|
-
* once per isolate instead of once per request. `ExecutionContext`-backed
|
|
1698
|
-
* services (`Worker.ExecutionContext`, `Worker.WorkerContext`) are still
|
|
1699
|
-
* provided fresh for every request. Layer finalizers do not run when the
|
|
1700
|
-
* isolate is evicted; Cloudflare provides no shutdown hook. Use `eventLayer`
|
|
1701
|
-
* for resources that must be finalized per event.
|
|
1702
|
-
*/
|
|
1703
|
-
const makeFetchHandler = (layer, options) => {
|
|
1704
|
-
const WorkerClass = make$9(layer, options);
|
|
1776
|
+
function makeFetchHandler(layer, options) {
|
|
1777
|
+
const WorkerClass = options.eventLayer === void 0 ? make$9(layer, options) : make$9(layer, options);
|
|
1705
1778
|
const instances = /* @__PURE__ */ new WeakMap();
|
|
1706
1779
|
return { fetch: (request, env, ctx) => {
|
|
1707
1780
|
let instance = instances.get(env);
|
|
@@ -1711,7 +1784,7 @@ const makeFetchHandler = (layer, options) => {
|
|
|
1711
1784
|
}
|
|
1712
1785
|
return instance[FetchSymbol](request, ctx);
|
|
1713
1786
|
} };
|
|
1714
|
-
}
|
|
1787
|
+
}
|
|
1715
1788
|
//#endregion
|
|
1716
1789
|
//#region src/DurableObjectNamespace.ts
|
|
1717
1790
|
var DurableObjectNamespace_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1739,8 +1812,8 @@ var DurableObjectFetchError = class extends Data.TaggedError("DurableObjectFetch
|
|
|
1739
1812
|
return `Durable Object fetch failed for binding "${this.binding}": ${causeMessage(this.cause)}`;
|
|
1740
1813
|
}
|
|
1741
1814
|
};
|
|
1742
|
-
const hasFunction$
|
|
1743
|
-
const isDurableObjectNamespaceClient = (value) =>
|
|
1815
|
+
const hasFunction$1 = (value, key) => Predicate.hasProperty(value, key) && Predicate.isFunction(value[key]);
|
|
1816
|
+
const isDurableObjectNamespaceClient = (value) => hasFunction$1(value, "getByName") && hasFunction$1(value, "get") && hasFunction$1(value, "idFromName") && hasFunction$1(value, "idFromString") && hasFunction$1(value, "newUniqueId") && hasFunction$1(value, "jurisdiction");
|
|
1744
1817
|
const makeClient$7 = (definition) => {
|
|
1745
1818
|
return (namespace) => {
|
|
1746
1819
|
const newUniqueId = (options) => Effect.sync(() => namespace.newUniqueId(options));
|
|
@@ -1852,10 +1925,9 @@ const reservedMethodNames$1 = /* @__PURE__ */ new Set([
|
|
|
1852
1925
|
"webSocketClose",
|
|
1853
1926
|
"webSocketError"
|
|
1854
1927
|
]);
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
const method = method$2;
|
|
1928
|
+
function method(definition) {
|
|
1929
|
+
return method$2(definition);
|
|
1930
|
+
}
|
|
1859
1931
|
/**
|
|
1860
1932
|
* Creates a Durable Object RPC definition plus implementation/binding helpers.
|
|
1861
1933
|
*
|
|
@@ -1908,14 +1980,17 @@ const Tag$8 = () => (id, methods) => {
|
|
|
1908
1980
|
const fetch = Effect.fn("DurableObject.fetch")(function* (stub, input, init) {
|
|
1909
1981
|
return yield* (yield* tag).fetch(stub, input, init);
|
|
1910
1982
|
});
|
|
1911
|
-
const rpc = Effect.fn("DurableObject.rpc")(function* (stub,
|
|
1912
|
-
|
|
1983
|
+
const rpc = Effect.fn("DurableObject.rpc")(function* (stub, methodName, ...args) {
|
|
1984
|
+
const invokeRpc = (yield* tag).rpc;
|
|
1985
|
+
return yield* invokeRpc(stub, methodName, ...args);
|
|
1913
1986
|
});
|
|
1914
|
-
const call = Effect.fn("DurableObject.call")(function* (stub,
|
|
1915
|
-
|
|
1987
|
+
const call = Effect.fn("DurableObject.call")(function* (stub, methodName, ...args) {
|
|
1988
|
+
const invokeCall = (yield* tag).call;
|
|
1989
|
+
return yield* invokeCall(stub, methodName, ...args);
|
|
1916
1990
|
});
|
|
1917
|
-
const scopedCall = Effect.fn("DurableObject.scopedCall")(function* (stub,
|
|
1918
|
-
|
|
1991
|
+
const scopedCall = Effect.fn("DurableObject.scopedCall")(function* (stub, methodName, ...args) {
|
|
1992
|
+
const invokeScopedCall = (yield* tag).scopedCall;
|
|
1993
|
+
return yield* invokeScopedCall(stub, methodName, ...args);
|
|
1919
1994
|
});
|
|
1920
1995
|
const rawUnsafe = Effect.fnUntraced(function* () {
|
|
1921
1996
|
return yield* (yield* tag).rawUnsafe;
|
|
@@ -1946,7 +2021,7 @@ const Tag$8 = () => (id, methods) => {
|
|
|
1946
2021
|
};
|
|
1947
2022
|
const DurableObject$1 = Tag$8;
|
|
1948
2023
|
const wrapHandlers = (definition, handlers) => {
|
|
1949
|
-
const wrapped =
|
|
2024
|
+
const wrapped = Object.create(Object.prototype);
|
|
1950
2025
|
for (const key of Object.keys(definition.methods)) {
|
|
1951
2026
|
const handler = handlers[key];
|
|
1952
2027
|
wrapped[key] = (...args) => Effect.gen(function* () {
|
|
@@ -1993,7 +2068,9 @@ const make$7 = (layer, options = {}) => {
|
|
|
1993
2068
|
if (initialize !== void 0) state.waitUntil(this[RunSymbol](initialize, { eventLayer: false }));
|
|
1994
2069
|
}
|
|
1995
2070
|
[RunSymbol](effect, runOptions = {}) {
|
|
1996
|
-
|
|
2071
|
+
const eventLayer = runOptions.eventLayer === false ? void 0 : options.eventLayer;
|
|
2072
|
+
if (eventLayer === void 0) return runEventPromise(this.runtime, effect);
|
|
2073
|
+
return runEventPromise(this.runtime, effect, eventLayer);
|
|
1997
2074
|
}
|
|
1998
2075
|
fetch(request) {
|
|
1999
2076
|
const fetchHandler = options.fetch;
|
|
@@ -2015,8 +2092,8 @@ const make$7 = (layer, options = {}) => {
|
|
|
2015
2092
|
webSocketClose(socket, code, reason, wasClean) {
|
|
2016
2093
|
if (options.webSocketClose !== void 0) return this[RunSymbol](options.webSocketClose(fromWebSocket(socket), code, reason, wasClean));
|
|
2017
2094
|
}
|
|
2018
|
-
webSocketError(socket,
|
|
2019
|
-
if (options.webSocketError !== void 0) return this[RunSymbol](options.webSocketError(fromWebSocket(socket),
|
|
2095
|
+
webSocketError(socket, cause) {
|
|
2096
|
+
if (options.webSocketError !== void 0) return this[RunSymbol](options.webSocketError(fromWebSocket(socket), cause));
|
|
2020
2097
|
}
|
|
2021
2098
|
}
|
|
2022
2099
|
defineEntrypointRpcMethods("Durable Object", EffectDurableObject.prototype, options.rpc, reservedMethodNames, (self, effect) => self[RunSymbol](effect), () => scheduleTelemetryFlush);
|
|
@@ -2152,12 +2229,12 @@ const toFailureRescheduleMillis = (input) => Effect.try({
|
|
|
2152
2229
|
catch: (cause) => new InvalidProcessDueAlarmsOptionsError({ cause })
|
|
2153
2230
|
});
|
|
2154
2231
|
const getFailureRetryDelay = (options) => toFailureRescheduleMillis(options?.retryFailedAfter ?? DEFAULT_PROCESS_DUE_ALARMS_FAILURE_RESCHEDULE_AFTER);
|
|
2155
|
-
const getFailureActionMode = (action) =>
|
|
2156
|
-
const getFailureActionRetryDelay = (action) =>
|
|
2232
|
+
const getFailureActionMode = (action) => Predicate.isString(action) ? action : action.mode;
|
|
2233
|
+
const getFailureActionRetryDelay = (action) => Predicate.isString(action) || action.mode !== "retry" ? void 0 : action.retryFailedAfter;
|
|
2157
2234
|
const processDue = (handle, options = {}) => Effect.gen(function* () {
|
|
2158
2235
|
return yield* (yield* DurableObjectAlarm).processDueAlarms(handle, options);
|
|
2159
2236
|
});
|
|
2160
|
-
const isAlarmDefinitionConfig = (definition) =>
|
|
2237
|
+
const isAlarmDefinitionConfig = (definition) => Predicate.isObject(definition) && "payload" in definition;
|
|
2161
2238
|
const getAlarmDefinitionSchema = (definition) => isAlarmDefinitionConfig(definition) ? definition.payload : definition;
|
|
2162
2239
|
const getAlarmDefinitionFailureAction = (definition) => {
|
|
2163
2240
|
if (definition === void 0 || !isAlarmDefinitionConfig(definition)) return;
|
|
@@ -2470,21 +2547,21 @@ const layer$8 = (options = {}) => Layer.effectContext(Effect.gen(function* () {
|
|
|
2470
2547
|
return Predicate.isTagged(cause, "MaxBufferSizeExceeded") ? Effect.ignore(connection.socket.close(1009, String(cause))) : send(connection, RpcMessage.ResponseDefectEncoded(cause));
|
|
2471
2548
|
})),
|
|
2472
2549
|
close: unregister,
|
|
2473
|
-
error: (socket,
|
|
2474
|
-
yield* Effect.logDebug("Durable Object RPC websocket error",
|
|
2550
|
+
error: (socket, cause) => Effect.gen(function* () {
|
|
2551
|
+
yield* Effect.logDebug("Durable Object RPC websocket error", cause);
|
|
2475
2552
|
yield* unregister(socket);
|
|
2476
2553
|
})
|
|
2477
2554
|
});
|
|
2478
2555
|
return Context.mergeAll(Context.make(RpcServer.Protocol, protocol), Context.make(DurableObjectRpcWebSocket, service));
|
|
2479
2556
|
}));
|
|
2480
|
-
const normalizeMessage = (message) =>
|
|
2557
|
+
const normalizeMessage = (message) => Predicate.isString(message) ? message : new Uint8Array(message);
|
|
2481
2558
|
const readAttachment = (socket, key) => {
|
|
2482
2559
|
const value = socket.deserializeAttachment();
|
|
2483
|
-
if (value
|
|
2560
|
+
if (Predicate.isObjectOrArray(value) && Predicate.hasProperty(value, key) && Predicate.isNumber(value[key])) return value[key];
|
|
2484
2561
|
};
|
|
2485
2562
|
const writeAttachment = (socket, key, clientId) => {
|
|
2486
2563
|
const current = socket.deserializeAttachment();
|
|
2487
|
-
const attachment =
|
|
2564
|
+
const attachment = Predicate.isObject(current) ? current : {};
|
|
2488
2565
|
socket.serializeAttachment({
|
|
2489
2566
|
...attachment,
|
|
2490
2567
|
[key]: clientId
|
|
@@ -2590,9 +2667,9 @@ var EmailValidationError = class extends Data.TaggedError("EmailValidationError"
|
|
|
2590
2667
|
* error and strips non-standard properties.
|
|
2591
2668
|
*/
|
|
2592
2669
|
const emailErrorCode = (cause) => {
|
|
2593
|
-
if (
|
|
2594
|
-
const code =
|
|
2595
|
-
return
|
|
2670
|
+
if (!Predicate.isObject(cause)) return;
|
|
2671
|
+
const code = Predicate.hasProperty(cause, "code") ? cause.code : void 0;
|
|
2672
|
+
return Predicate.isString(code) ? code : void 0;
|
|
2596
2673
|
};
|
|
2597
2674
|
const emailError = (binding, operation, cause) => new EmailOperationError({
|
|
2598
2675
|
binding,
|
|
@@ -2621,16 +2698,16 @@ const addressList = (value) => {
|
|
|
2621
2698
|
return Array.isArray(value) ? value : [value];
|
|
2622
2699
|
};
|
|
2623
2700
|
const addressViolations = (path, value) => {
|
|
2624
|
-
if (
|
|
2701
|
+
if (Predicate.isString(value)) return value.includes("@") ? [] : [{
|
|
2625
2702
|
path,
|
|
2626
2703
|
message: "Email address must contain an @ symbol"
|
|
2627
2704
|
}];
|
|
2628
|
-
if (
|
|
2705
|
+
if (!Predicate.isObject(value)) return [{
|
|
2629
2706
|
path,
|
|
2630
2707
|
message: "Email address must be a string or { name, email } object"
|
|
2631
2708
|
}];
|
|
2632
|
-
const email =
|
|
2633
|
-
if (
|
|
2709
|
+
const email = Predicate.hasProperty(value, "email") ? value.email : void 0;
|
|
2710
|
+
if (!Predicate.isString(email) || !email.includes("@")) return [{
|
|
2634
2711
|
path: `${path}.email`,
|
|
2635
2712
|
message: "Email address must contain an @ symbol"
|
|
2636
2713
|
}];
|
|
@@ -2643,18 +2720,18 @@ const attachmentViolations = (attachments) => {
|
|
|
2643
2720
|
for (let index = 0; index < attachments.length; index++) {
|
|
2644
2721
|
const attachment = attachments[index];
|
|
2645
2722
|
const path = `attachments[${index}]`;
|
|
2646
|
-
if (
|
|
2723
|
+
if (!Predicate.isObject(attachment)) {
|
|
2647
2724
|
violations.push({
|
|
2648
2725
|
path,
|
|
2649
2726
|
message: "Attachment must be an object"
|
|
2650
2727
|
});
|
|
2651
2728
|
continue;
|
|
2652
2729
|
}
|
|
2653
|
-
if (
|
|
2730
|
+
if (!Predicate.isString(attachment.filename) || attachment.filename === "") violations.push({
|
|
2654
2731
|
path: `${path}.filename`,
|
|
2655
2732
|
message: "Attachment filename is required"
|
|
2656
2733
|
});
|
|
2657
|
-
if (
|
|
2734
|
+
if (!Predicate.isString(attachment.type) || attachment.type === "") violations.push({
|
|
2658
2735
|
path: `${path}.type`,
|
|
2659
2736
|
message: "Attachment MIME type is required"
|
|
2660
2737
|
});
|
|
@@ -2662,7 +2739,7 @@ const attachmentViolations = (attachments) => {
|
|
|
2662
2739
|
path: `${path}.content`,
|
|
2663
2740
|
message: "Attachment content is required"
|
|
2664
2741
|
});
|
|
2665
|
-
if (attachment.disposition === "inline" &&
|
|
2742
|
+
if (attachment.disposition === "inline" && !Predicate.isString(attachment.contentId)) violations.push({
|
|
2666
2743
|
path: `${path}.contentId`,
|
|
2667
2744
|
message: "Inline attachments require a contentId"
|
|
2668
2745
|
});
|
|
@@ -2678,7 +2755,7 @@ const headerViolations = (headers) => {
|
|
|
2678
2755
|
const path = `headers["${name}"]`;
|
|
2679
2756
|
const nameBytes = byteLength(name);
|
|
2680
2757
|
if (nameBytes > sendLimits.maxHeaderNameBytes) violations.push(limitViolation(path, "header name bytes", nameBytes, sendLimits.maxHeaderNameBytes));
|
|
2681
|
-
if (
|
|
2758
|
+
if (!Predicate.isString(value)) {
|
|
2682
2759
|
violations.push({
|
|
2683
2760
|
path,
|
|
2684
2761
|
message: "Header value must be a string"
|
|
@@ -2708,11 +2785,11 @@ const validateMessage = (message) => {
|
|
|
2708
2785
|
});
|
|
2709
2786
|
else violations.push(...addressViolations("from", fields.from));
|
|
2710
2787
|
if (fields.replyTo !== void 0) violations.push(...addressViolations("replyTo", fields.replyTo));
|
|
2711
|
-
if (
|
|
2788
|
+
if (!Predicate.isString(fields.subject) || fields.subject === "") violations.push({
|
|
2712
2789
|
path: "subject",
|
|
2713
2790
|
message: "A subject is required"
|
|
2714
2791
|
});
|
|
2715
|
-
if (
|
|
2792
|
+
if (!Predicate.isString(fields.text) && !Predicate.isString(fields.html)) violations.push({
|
|
2716
2793
|
path: "$",
|
|
2717
2794
|
message: "A message requires either text or html content"
|
|
2718
2795
|
});
|
|
@@ -2733,10 +2810,7 @@ const validateSendInput = (binding, operation, message) => {
|
|
|
2733
2810
|
const violations = validateMessage(message);
|
|
2734
2811
|
return violations.length > 0 ? Effect.fail(emailValidationError(binding, operation, violations)) : Effect.succeed(message);
|
|
2735
2812
|
};
|
|
2736
|
-
const isEmailBinding = (value) =>
|
|
2737
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2738
|
-
return typeof value.send === "function";
|
|
2739
|
-
};
|
|
2813
|
+
const isEmailBinding = (value) => Predicate.hasProperty(value, "send") && Predicate.isFunction(value.send);
|
|
2740
2814
|
const makeClient$6 = (definition, options) => (email) => {
|
|
2741
2815
|
const runtime = email;
|
|
2742
2816
|
const validate = options?.validate ?? true;
|
|
@@ -2769,10 +2843,7 @@ var Hyperdrive_exports = /* @__PURE__ */ __exportAll({
|
|
|
2769
2843
|
makeClient: () => makeClient$5
|
|
2770
2844
|
});
|
|
2771
2845
|
const expectedHyperdrive = "Hyperdrive binding with connectionString";
|
|
2772
|
-
const isHyperdrive = (value) =>
|
|
2773
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2774
|
-
return typeof value.connectionString === "string";
|
|
2775
|
-
};
|
|
2846
|
+
const isHyperdrive = (value) => Predicate.hasProperty(value, "connectionString") && Predicate.isString(value.connectionString);
|
|
2776
2847
|
const makeClient$5 = (definition) => (hyperdrive) => ({
|
|
2777
2848
|
definition,
|
|
2778
2849
|
connectionString: hyperdrive.connectionString,
|
|
@@ -2817,8 +2888,8 @@ const makeSteps = (steps) => ({
|
|
|
2817
2888
|
});
|
|
2818
2889
|
/** Empty Images transformation pipeline. */
|
|
2819
2890
|
const empty = makeSteps([]);
|
|
2820
|
-
const transform = Function.dual(2, (steps, transformValue) => makeSteps([...steps.steps, Step.Transform({ transform: transformValue })]));
|
|
2821
|
-
const draw = Function.dual(2, (steps, drawValue) => makeSteps([...steps.steps, Step.Draw(drawValue)]));
|
|
2891
|
+
const transform = Function$1.dual(2, (steps, transformValue) => makeSteps([...steps.steps, Step.Transform({ transform: transformValue })]));
|
|
2892
|
+
const draw = Function$1.dual(2, (steps, drawValue) => makeSteps([...steps.steps, Step.Draw(drawValue)]));
|
|
2822
2893
|
const imagesError = (binding, operation, cause) => new ImagesOperationError({
|
|
2823
2894
|
binding,
|
|
2824
2895
|
operation,
|
|
@@ -2833,9 +2904,9 @@ const tryImagesSync = (binding, operation, evaluate) => Effect.try({
|
|
|
2833
2904
|
catch: (cause) => imagesError(binding, operation, cause)
|
|
2834
2905
|
});
|
|
2835
2906
|
const maybe = (value) => value === null ? Option.none() : Option.some(value);
|
|
2836
|
-
const hasFunction
|
|
2837
|
-
const isHostedImagesBinding = (value) =>
|
|
2838
|
-
const isImagesBinding = (value) =>
|
|
2907
|
+
const hasFunction = (value, key) => Predicate.hasProperty(value, key) && Predicate.isFunction(value[key]);
|
|
2908
|
+
const isHostedImagesBinding = (value) => hasFunction(value, "image") && hasFunction(value, "upload") && hasFunction(value, "list");
|
|
2909
|
+
const isImagesBinding = (value) => hasFunction(value, "info") && hasFunction(value, "input");
|
|
2839
2910
|
const wrapResult = (binding, result) => ({
|
|
2840
2911
|
raw: result,
|
|
2841
2912
|
response: tryImagesSync(binding, "response", () => result.response()),
|
|
@@ -2910,11 +2981,7 @@ const tryKvPromise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
|
2910
2981
|
try: evaluate,
|
|
2911
2982
|
catch: (cause) => kvError(binding, operation, cause)
|
|
2912
2983
|
});
|
|
2913
|
-
const isKvNamespace = (value) =>
|
|
2914
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2915
|
-
const resource = value;
|
|
2916
|
-
return typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.delete === "function" && typeof resource.getWithMetadata === "function" && typeof resource.list === "function";
|
|
2917
|
-
};
|
|
2984
|
+
const isKvNamespace = (value) => Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get) && Predicate.hasProperty(value, "put") && Predicate.isFunction(value.put) && Predicate.hasProperty(value, "delete") && Predicate.isFunction(value.delete) && Predicate.hasProperty(value, "getWithMetadata") && Predicate.isFunction(value.getWithMetadata) && Predicate.hasProperty(value, "list") && Predicate.isFunction(value.list);
|
|
2918
2985
|
const makeClient$3 = (definition) => {
|
|
2919
2986
|
const encodeKey = Schema.encodeEffect(definition.key);
|
|
2920
2987
|
const decodeKey = Schema.decodeUnknownEffect(definition.key);
|
|
@@ -3046,7 +3113,7 @@ const spanOptions$1 = (binding, operation) => ({ attributes: {
|
|
|
3046
3113
|
binding,
|
|
3047
3114
|
operation
|
|
3048
3115
|
} });
|
|
3049
|
-
const isR2ObjectBody = (value) => "body" in value &&
|
|
3116
|
+
const isR2ObjectBody = (value) => "body" in value && Predicate.isFunction(value.arrayBuffer) && Predicate.isFunction(value.bytes) && Predicate.isFunction(value.text) && Predicate.isFunction(value.json) && Predicate.isFunction(value.blob);
|
|
3050
3117
|
const wrapObjectBody = (binding, object) => ({
|
|
3051
3118
|
key: object.key,
|
|
3052
3119
|
version: object.version,
|
|
@@ -3076,11 +3143,9 @@ const wrapGetResult = (binding, object) => {
|
|
|
3076
3143
|
if (object === null || !isR2ObjectBody(object)) return object;
|
|
3077
3144
|
return wrapObjectBody(binding, object);
|
|
3078
3145
|
};
|
|
3079
|
-
const
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
return typeof resource.head === "function" && typeof resource.get === "function" && typeof resource.put === "function" && typeof resource.createMultipartUpload === "function" && typeof resource.resumeMultipartUpload === "function" && typeof resource.delete === "function" && typeof resource.list === "function";
|
|
3083
|
-
};
|
|
3146
|
+
const R2BucketSchema = Schema.declare((value) => Predicate.hasProperty(value, "head") && Predicate.isFunction(value.head) && Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get) && Predicate.hasProperty(value, "put") && Predicate.isFunction(value.put) && Predicate.hasProperty(value, "createMultipartUpload") && Predicate.isFunction(value.createMultipartUpload) && Predicate.hasProperty(value, "resumeMultipartUpload") && Predicate.isFunction(value.resumeMultipartUpload) && Predicate.hasProperty(value, "delete") && Predicate.isFunction(value.delete) && Predicate.hasProperty(value, "list") && Predicate.isFunction(value.list));
|
|
3147
|
+
const decodeR2Bucket = Schema.decodeUnknownOption(R2BucketSchema);
|
|
3148
|
+
const isR2Bucket = (value) => Option.isSome(decodeR2Bucket(value));
|
|
3084
3149
|
const makeClient$2 = (definition) => {
|
|
3085
3150
|
const wrapUpload = (upload) => ({
|
|
3086
3151
|
raw: upload,
|
|
@@ -3104,7 +3169,7 @@ const makeClient$2 = (definition) => {
|
|
|
3104
3169
|
createMultipartUpload: Effect.fn("R2.createMultipartUpload", spanOptions$1(definition.binding, "createMultipartUpload"))((key, options) => tryR2Promise(definition.binding, "createMultipartUpload", () => bucket.createMultipartUpload(key, options)).pipe(Effect.map(wrapUpload))),
|
|
3105
3170
|
resumeMultipartUpload: Effect.fn("R2.resumeMultipartUpload", spanOptions$1(definition.binding, "resumeMultipartUpload"))((key, uploadId) => tryR2Sync(definition.binding, "resumeMultipartUpload", () => wrapUpload(bucket.resumeMultipartUpload(key, uploadId)))),
|
|
3106
3171
|
delete: Effect.fn("R2.delete", spanOptions$1(definition.binding, "delete"))((keys) => {
|
|
3107
|
-
const nativeKeys =
|
|
3172
|
+
const nativeKeys = Predicate.isString(keys) ? keys : [...keys];
|
|
3108
3173
|
return tryR2Promise(definition.binding, "delete", () => bucket.delete(nativeKeys));
|
|
3109
3174
|
}),
|
|
3110
3175
|
list: Effect.fn("R2.list", spanOptions$1(definition.binding, "list"))((options) => tryR2Promise(definition.binding, "list", () => bucket.list(options))),
|
|
@@ -3152,16 +3217,25 @@ const spanOptions = (binding, operation) => ({ attributes: {
|
|
|
3152
3217
|
binding,
|
|
3153
3218
|
operation
|
|
3154
3219
|
} });
|
|
3155
|
-
const
|
|
3156
|
-
|
|
3220
|
+
const invokeVectorizeMethod = (method, receiver, args) => {
|
|
3221
|
+
return Function.prototype.apply.call(method, receiver, args);
|
|
3222
|
+
};
|
|
3223
|
+
const VectorizeBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "describe") && Predicate.isFunction(value.describe) && Predicate.hasProperty(value, "query") && Predicate.isFunction(value.query) && Predicate.hasProperty(value, "insert") && Predicate.isFunction(value.insert) && Predicate.hasProperty(value, "upsert") && Predicate.isFunction(value.upsert) && Predicate.hasProperty(value, "deleteByIds") && Predicate.isFunction(value.deleteByIds) && Predicate.hasProperty(value, "getByIds") && Predicate.isFunction(value.getByIds));
|
|
3224
|
+
const decodeVectorizeBinding = Schema.decodeUnknownOption(VectorizeBindingSchema);
|
|
3225
|
+
const isVectorizeBinding = (value) => Option.isSome(decodeVectorizeBinding(value));
|
|
3157
3226
|
const makeClient$1 = (definition) => (index) => {
|
|
3158
3227
|
const runtime = index;
|
|
3159
3228
|
const deleteByIds = Effect.fn("Vectorize.deleteByIds", spanOptions(definition.binding, "deleteByIds"))((ids) => tryVectorizePromise(definition.binding, "deleteByIds", () => runtime.deleteByIds([...ids])));
|
|
3160
3229
|
return {
|
|
3161
3230
|
definition,
|
|
3162
3231
|
describe: tryVectorizePromise(definition.binding, "describe", () => runtime.describe()).pipe(Effect.withSpan("Vectorize.describe", spanOptions(definition.binding, "describe"))),
|
|
3163
|
-
query: Effect.fn("Vectorize.query", spanOptions(definition.binding, "query"))((vector, options) => tryVectorizePromise(definition.binding, "query", () =>
|
|
3164
|
-
|
|
3232
|
+
query: Effect.fn("Vectorize.query", spanOptions(definition.binding, "query"))((vector, options) => tryVectorizePromise(definition.binding, "query", () => {
|
|
3233
|
+
return runtime.query(vector, options);
|
|
3234
|
+
})),
|
|
3235
|
+
queryById: Effect.fn("Vectorize.queryById", spanOptions(definition.binding, "queryById"))((vectorId, options) => runtime.queryById !== void 0 ? tryVectorizePromise(definition.binding, "queryById", () => {
|
|
3236
|
+
const queryById = runtime.queryById;
|
|
3237
|
+
return queryById === void 0 ? Promise.reject(/* @__PURE__ */ new TypeError("Vectorize binding does not expose queryById()")) : invokeVectorizeMethod(queryById, runtime, [vectorId, options]);
|
|
3238
|
+
}) : Effect.fail(vectorizeError(definition.binding, "queryById", /* @__PURE__ */ new TypeError("Vectorize binding does not expose queryById()")))),
|
|
3165
3239
|
insert: Effect.fn("Vectorize.insert", spanOptions(definition.binding, "insert"))((vectors) => tryVectorizePromise(definition.binding, "insert", () => runtime.insert([...vectors]))),
|
|
3166
3240
|
upsert: Effect.fn("Vectorize.upsert", spanOptions(definition.binding, "upsert"))((vectors) => tryVectorizePromise(definition.binding, "upsert", () => runtime.upsert([...vectors]))),
|
|
3167
3241
|
deleteByIds,
|
|
@@ -3226,10 +3300,13 @@ const inboundTransport = (request) => Result.getSuccess(decodeInboundTransport(r
|
|
|
3226
3300
|
*/
|
|
3227
3301
|
const isHttp3 = (transport) => transport.clientQuicRtt !== void 0 || transport.httpProtocol === "HTTP/3";
|
|
3228
3302
|
/** Feature-detects the WebTransport capabilities of the current runtime. */
|
|
3229
|
-
const capabilities = Effect.sync(() =>
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3303
|
+
const capabilities = Effect.sync(() => {
|
|
3304
|
+
const runtime = globalThis;
|
|
3305
|
+
return {
|
|
3306
|
+
inboundSessions: false,
|
|
3307
|
+
outboundSessions: Predicate.hasProperty(runtime, "WebTransport") && Predicate.isFunction(runtime["WebTransport"])
|
|
3308
|
+
};
|
|
3309
|
+
});
|
|
3233
3310
|
/** Raised when a WebTransport capability is unavailable in this runtime. */
|
|
3234
3311
|
var WebTransportUnsupportedError = class extends Data.TaggedError("WebTransportUnsupportedError") {
|
|
3235
3312
|
get message() {
|
|
@@ -3274,11 +3351,9 @@ const tryWorkflowPromise = (binding, operation, evaluate) => Effect.tryPromise({
|
|
|
3274
3351
|
try: evaluate,
|
|
3275
3352
|
catch: (cause) => workflowError(binding, operation, cause)
|
|
3276
3353
|
});
|
|
3277
|
-
const
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
return typeof resource.create === "function" && typeof resource.createBatch === "function" && typeof resource.get === "function";
|
|
3281
|
-
};
|
|
3354
|
+
const WorkflowBindingSchema = Schema.declare((value) => Predicate.hasProperty(value, "create") && Predicate.isFunction(value.create) && Predicate.hasProperty(value, "createBatch") && Predicate.isFunction(value.createBatch) && Predicate.hasProperty(value, "get") && Predicate.isFunction(value.get));
|
|
3355
|
+
const decodeWorkflowBinding = Schema.decodeUnknownOption(WorkflowBindingSchema);
|
|
3356
|
+
const isWorkflow = (value) => Option.isSome(decodeWorkflowBinding(value));
|
|
3282
3357
|
const makeClient = (definition) => {
|
|
3283
3358
|
const encodePayload = Schema.encodeEffect(definition.payload);
|
|
3284
3359
|
const decodeResult = Schema.decodeUnknownEffect(definition.result);
|
|
@@ -3411,6 +3486,7 @@ var Workflow_exports = /* @__PURE__ */ __exportAll({
|
|
|
3411
3486
|
WorkflowStep: () => WorkflowStep$1,
|
|
3412
3487
|
WorkflowStepContext: () => WorkflowStepContext$1,
|
|
3413
3488
|
WorkflowStepError: () => WorkflowStepError,
|
|
3489
|
+
WorkflowStepNonRetryableError: () => WorkflowStepNonRetryableError,
|
|
3414
3490
|
implement: () => implement,
|
|
3415
3491
|
make: () => make,
|
|
3416
3492
|
sleep: () => sleep,
|
|
@@ -3426,6 +3502,17 @@ var WorkflowStepError = class extends Data.TaggedError("WorkflowStepError") {
|
|
|
3426
3502
|
return `Workflow ${this.operation} failed${step}: ${causeMessage(this.cause)}`;
|
|
3427
3503
|
}
|
|
3428
3504
|
};
|
|
3505
|
+
/**
|
|
3506
|
+
* Typed step failure that Cloudflare must treat as terminal instead of retrying.
|
|
3507
|
+
*
|
|
3508
|
+
* The workflow boundary converts this value into Cloudflare's native
|
|
3509
|
+
* `NonRetryableError` while preserving the original cause and its message.
|
|
3510
|
+
*/
|
|
3511
|
+
var WorkflowStepNonRetryableError = class extends Data.TaggedError("WorkflowStepNonRetryableError") {
|
|
3512
|
+
get message() {
|
|
3513
|
+
return `Workflow step failed without retry: ${causeMessage(this.cause)}`;
|
|
3514
|
+
}
|
|
3515
|
+
};
|
|
3429
3516
|
var WorkflowStep$1 = class extends Context.Service()("effect-cf/WorkflowStep") {};
|
|
3430
3517
|
var WorkflowStepContext$1 = class extends Context.Service()("effect-cf/WorkflowStepContext") {};
|
|
3431
3518
|
const fromWorkflowEvent = (event) => ({
|
|
@@ -3435,11 +3522,20 @@ const fromWorkflowEvent = (event) => ({
|
|
|
3435
3522
|
instanceId: event.instanceId,
|
|
3436
3523
|
workflowName: event.workflowName
|
|
3437
3524
|
});
|
|
3525
|
+
const toCloudflareNonRetryableError = (error) => {
|
|
3526
|
+
const cloudflareError = new NonRetryableError(error.message);
|
|
3527
|
+
cloudflareError.cause = error.cause;
|
|
3528
|
+
return cloudflareError;
|
|
3529
|
+
};
|
|
3530
|
+
const exposeCloudflareNonRetryableError = (effect) => Effect.catchCause(effect, (cause) => {
|
|
3531
|
+
const error = Cause.findErrorOption(cause);
|
|
3532
|
+
return Option.isSome(error) && error.value instanceof WorkflowStepNonRetryableError ? Effect.die(toCloudflareNonRetryableError(error.value)) : Effect.failCause(cause);
|
|
3533
|
+
});
|
|
3438
3534
|
const fromWorkflowStep = (step, runPromise) => ({
|
|
3439
3535
|
raw: step,
|
|
3440
3536
|
do: (name, effect, config) => Effect.context().pipe(Effect.flatMap((context) => Effect.tryPromise({
|
|
3441
3537
|
try: () => {
|
|
3442
|
-
const run = (stepContext) => runPromise(Effect.scoped(Effect.provideService(Effect.provideContext(effect, context), WorkflowStepContext$1, stepContext)));
|
|
3538
|
+
const run = (stepContext) => runPromise(exposeCloudflareNonRetryableError(Effect.scoped(Effect.provideService(Effect.provideContext(effect, context), WorkflowStepContext$1, stepContext))));
|
|
3443
3539
|
const rawStep = step;
|
|
3444
3540
|
return config === void 0 ? rawStep.do(name, run) : rawStep.do(name, config, run);
|
|
3445
3541
|
},
|
|
@@ -3466,7 +3562,9 @@ const fromWorkflowStep = (step, runPromise) => ({
|
|
|
3466
3562
|
})
|
|
3467
3563
|
}),
|
|
3468
3564
|
waitForEvent: (name, options) => Effect.tryPromise({
|
|
3469
|
-
try: () =>
|
|
3565
|
+
try: () => {
|
|
3566
|
+
return step.waitForEvent(name, options);
|
|
3567
|
+
},
|
|
3470
3568
|
catch: (cause) => new WorkflowStepError({
|
|
3471
3569
|
step: name,
|
|
3472
3570
|
operation: "waitForEvent",
|