effect-cf 0.45.0 → 0.46.1
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 +12 -0
- package/dist/AiGateway.d.mts +7 -8
- package/dist/AnalyticsEngine.d.mts +5 -6
- package/dist/Artifacts.d.mts +24 -25
- package/dist/Cache.d.mts +11 -12
- package/dist/DurableObject.d.mts +2 -1
- package/dist/DurableObject.mjs +2 -2
- package/dist/Email.d.mts +7 -8
- package/dist/Images.d.mts +53 -54
- package/dist/Kv.d.mts +0 -1
- package/dist/QueueBinding.d.mts +11 -12
- package/dist/R2.d.mts +14 -15
- package/dist/Vectorize.d.mts +17 -18
- package/dist/WebTransport.d.mts +0 -1
- package/dist/WebTransport.mjs +31 -0
- package/dist/Worker.d.mts +2 -1
- package/dist/Worker.mjs +2 -2
- package/dist/WorkersAi.d.mts +0 -1
- package/dist/Workflow.d.mts +8 -3
- package/dist/Workflow.mjs +8 -2
- package/dist/WorkflowBinding.d.mts +14 -15
- package/dist/internal/Runtime.d.mts +20 -0
- package/dist/internal/Runtime.mjs +15 -3
- package/package.json +1 -1
- package/src/AiGateway.ts +2 -3
- package/src/AnalyticsEngine.ts +2 -6
- package/src/Artifacts.ts +8 -16
- package/src/Cache.ts +7 -13
- package/src/DurableObject.ts +3 -2
- package/src/Email.ts +5 -11
- package/src/Images.ts +31 -60
- package/src/Kv.ts +2 -6
- package/src/QueueBinding.ts +8 -17
- package/src/R2.ts +29 -49
- package/src/Vectorize.ts +11 -29
- package/src/WebTransport.ts +2 -4
- package/src/Worker.ts +3 -2
- package/src/WorkersAi.ts +2 -17
- package/src/Workflow.ts +26 -2
- package/src/WorkflowBinding.ts +14 -26
- package/src/internal/Runtime.ts +54 -3
package/dist/QueueBinding.d.mts
CHANGED
|
@@ -4,17 +4,16 @@ import { ServiceFreeSchema } from "./RpcDefinition.mjs";
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as S from "effect/Schema";
|
|
6
6
|
import * as Predicate from "effect/Predicate";
|
|
7
|
-
import { MessageSendRequest, Queue, QueueMetrics, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse } from "@cloudflare/workers-types";
|
|
8
7
|
import { Context } from "effect";
|
|
9
8
|
declare namespace QueueBinding_d_exports {
|
|
10
|
-
export { MessageSendRequest
|
|
9
|
+
export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer, makeClient };
|
|
11
10
|
}
|
|
12
|
-
type
|
|
13
|
-
type
|
|
14
|
-
type QueueSendBatchOptions
|
|
15
|
-
type QueueSendBatchResponse
|
|
16
|
-
type
|
|
17
|
-
type
|
|
11
|
+
type MessageSendRequest<Body> = globalThis.MessageSendRequest<Body>;
|
|
12
|
+
type QueueMetrics = globalThis.QueueMetrics;
|
|
13
|
+
type QueueSendBatchOptions = globalThis.QueueSendBatchOptions;
|
|
14
|
+
type QueueSendBatchResponse = globalThis.QueueSendBatchResponse;
|
|
15
|
+
type QueueSendOptions = globalThis.QueueSendOptions;
|
|
16
|
+
type QueueSendResponse = globalThis.QueueSendResponse;
|
|
18
17
|
type QueueProducer<Body> = Pick<Queue<Body>, "send"> & Partial<Pick<Queue<Body>, "sendBatch" | "metrics">>;
|
|
19
18
|
type QueueCandidate = Parameters<typeof Predicate.isUnknown>[0];
|
|
20
19
|
interface QueueBindingDefinition<Message extends ServiceFreeSchema> {
|
|
@@ -22,9 +21,9 @@ interface QueueBindingDefinition<Message extends ServiceFreeSchema> {
|
|
|
22
21
|
readonly message: Message;
|
|
23
22
|
}
|
|
24
23
|
interface QueueBindingClient<Message extends ServiceFreeSchema> {
|
|
25
|
-
readonly send: (message: S.Schema.Type<Message>, options?: QueueSendOptions
|
|
26
|
-
readonly sendBatch: (messages: Iterable<MessageSendRequest
|
|
27
|
-
readonly metrics: () => Effect.Effect<QueueMetrics
|
|
24
|
+
readonly send: (message: S.Schema.Type<Message>, options?: QueueSendOptions) => Effect.Effect<void, QueueOperationError | S.SchemaError>;
|
|
25
|
+
readonly sendBatch: (messages: Iterable<MessageSendRequest<S.Schema.Type<Message>>>, options?: QueueSendBatchOptions) => Effect.Effect<void, QueueOperationError | S.SchemaError>;
|
|
26
|
+
readonly metrics: () => Effect.Effect<QueueMetrics, QueueOperationError>;
|
|
28
27
|
readonly rawUnsafe: Effect.Effect<QueueProducer<S.Codec.Encoded<Message>>>;
|
|
29
28
|
}
|
|
30
29
|
declare const QueueOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
@@ -40,4 +39,4 @@ declare const isQueue: <Body>(value: QueueCandidate) => value is QueueProducer<B
|
|
|
40
39
|
declare const makeClient: <Message extends ServiceFreeSchema>(definition: QueueBindingDefinition<Message>) => ((queue: QueueProducer<S.Codec.Encoded<Message>>) => QueueBindingClient<Message>);
|
|
41
40
|
declare const layer: <Self, Message extends ServiceFreeSchema>(tag: Context.Service<Self, QueueBindingClient<Message>>, definition: QueueBindingDefinition<Message>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
42
41
|
//#endregion
|
|
43
|
-
export { MessageSendRequest
|
|
42
|
+
export { MessageSendRequest, QueueBindingClient, QueueBindingDefinition, QueueBinding_d_exports, QueueMetrics, QueueOperationError, QueueProducer, QueueSendBatchOptions, QueueSendBatchResponse, QueueSendOptions, QueueSendResponse, isQueue, layer, makeClient };
|
package/dist/R2.d.mts
CHANGED
|
@@ -4,10 +4,9 @@ import * as Context$1 from "effect/Context";
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Schema$1 from "effect/Schema";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
|
-
import { R2Bucket, R2Conditional, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUpload, R2Object, R2ObjectBody, R2Objects, R2PutOptions, R2UploadPartOptions, R2UploadedPart } from "@cloudflare/workers-types";
|
|
8
7
|
import { Layer } from "effect";
|
|
9
8
|
declare namespace R2_d_exports {
|
|
10
|
-
export { BindingNotFoundError, BindingValidationError, LayerOptions, R2Client, R2Definition, R2GetOptions
|
|
9
|
+
export { BindingNotFoundError, BindingValidationError, LayerOptions, R2Client, R2Definition, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUploadClient, R2ObjectBodyClient, R2Operation, R2OperationError, R2PutOptions, R2PutValue, R2Service, R2UploadPartOptions, R2UploadPartValue, Tag, TagClass, isR2Bucket, layer, make, makeClient };
|
|
11
10
|
}
|
|
12
11
|
type R2Operation = "head" | "get" | "put" | "delete" | "list" | "createMultipartUpload" | "resumeMultipartUpload" | "uploadPart" | "abortMultipartUpload" | "completeMultipartUpload" | "arrayBuffer" | "bytes" | "text" | "json" | "blob";
|
|
13
12
|
declare const R2OperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
@@ -23,11 +22,11 @@ declare class R2OperationError extends R2OperationError_base<{
|
|
|
23
22
|
interface R2Definition {
|
|
24
23
|
readonly binding: string;
|
|
25
24
|
}
|
|
26
|
-
type R2GetOptions
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type R2UploadPartOptions
|
|
25
|
+
type R2GetOptions = globalThis.R2GetOptions;
|
|
26
|
+
type R2ListOptions = globalThis.R2ListOptions;
|
|
27
|
+
type R2MultipartOptions = globalThis.R2MultipartOptions;
|
|
28
|
+
type R2PutOptions = globalThis.R2PutOptions;
|
|
29
|
+
type R2UploadPartOptions = globalThis.R2UploadPartOptions;
|
|
31
30
|
type R2PutValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob;
|
|
32
31
|
type R2UploadPartValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | Blob;
|
|
33
32
|
interface R2ObjectBodyClient extends Omit<R2ObjectBody, "arrayBuffer" | "blob" | "bytes" | "json" | "text"> {
|
|
@@ -42,28 +41,28 @@ interface R2MultipartUploadClient {
|
|
|
42
41
|
readonly raw: R2MultipartUpload;
|
|
43
42
|
readonly key: string;
|
|
44
43
|
readonly uploadId: string;
|
|
45
|
-
readonly uploadPart: (partNumber: number, value: R2UploadPartValue, options?: R2UploadPartOptions
|
|
44
|
+
readonly uploadPart: (partNumber: number, value: R2UploadPartValue, options?: R2UploadPartOptions) => Effect.Effect<R2UploadedPart, R2OperationError>;
|
|
46
45
|
readonly abort: Effect.Effect<void, R2OperationError>;
|
|
47
46
|
readonly complete: (uploadedParts: ReadonlyArray<R2UploadedPart>) => Effect.Effect<R2Object, R2OperationError>;
|
|
48
47
|
}
|
|
49
48
|
interface R2Client {
|
|
50
49
|
readonly head: (key: string) => Effect.Effect<Option.Option<R2Object>, R2OperationError>;
|
|
51
50
|
readonly get: {
|
|
52
|
-
(key: string, options: R2GetOptions
|
|
51
|
+
(key: string, options: R2GetOptions & {
|
|
53
52
|
readonly onlyIf: R2Conditional | Headers;
|
|
54
53
|
}): Effect.Effect<Option.Option<R2ObjectBodyClient | R2Object>, R2OperationError>;
|
|
55
|
-
(key: string, options?: R2GetOptions
|
|
54
|
+
(key: string, options?: R2GetOptions): Effect.Effect<Option.Option<R2ObjectBodyClient>, R2OperationError>;
|
|
56
55
|
};
|
|
57
56
|
readonly put: {
|
|
58
|
-
(key: string, value: R2PutValue, options: R2PutOptions
|
|
57
|
+
(key: string, value: R2PutValue, options: R2PutOptions & {
|
|
59
58
|
readonly onlyIf: R2Conditional | Headers;
|
|
60
59
|
}): Effect.Effect<Option.Option<R2Object>, R2OperationError>;
|
|
61
|
-
(key: string, value: R2PutValue, options?: R2PutOptions
|
|
60
|
+
(key: string, value: R2PutValue, options?: R2PutOptions): Effect.Effect<R2Object, R2OperationError>;
|
|
62
61
|
};
|
|
63
|
-
readonly createMultipartUpload: (key: string, options?: R2MultipartOptions
|
|
62
|
+
readonly createMultipartUpload: (key: string, options?: R2MultipartOptions) => Effect.Effect<R2MultipartUploadClient, R2OperationError>;
|
|
64
63
|
readonly resumeMultipartUpload: (key: string, uploadId: string) => Effect.Effect<R2MultipartUploadClient, R2OperationError>;
|
|
65
64
|
readonly delete: (keys: string | ReadonlyArray<string>) => Effect.Effect<void, R2OperationError>;
|
|
66
|
-
readonly list: (options?: R2ListOptions
|
|
65
|
+
readonly list: (options?: R2ListOptions) => Effect.Effect<R2Objects, R2OperationError>;
|
|
67
66
|
readonly rawUnsafe: Effect.Effect<R2Bucket>;
|
|
68
67
|
readonly definition: R2Definition;
|
|
69
68
|
}
|
|
@@ -87,4 +86,4 @@ declare const layer: <Self>(tag: Context$1.Service<Self, R2Client>, definition:
|
|
|
87
86
|
declare const make: <Id extends string>(id: Id) => TagClass<R2Service<Id>, Id>;
|
|
88
87
|
declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
|
|
89
88
|
//#endregion
|
|
90
|
-
export { type BindingNotFoundError, type BindingValidationError, LayerOptions, R2Client, R2Definition, R2GetOptions
|
|
89
|
+
export { type BindingNotFoundError, type BindingValidationError, LayerOptions, R2Client, R2Definition, R2GetOptions, R2ListOptions, R2MultipartOptions, R2MultipartUploadClient, R2ObjectBodyClient, R2Operation, R2OperationError, R2PutOptions, R2PutValue, R2Service, R2UploadPartOptions, R2UploadPartValue, R2_d_exports, Tag, TagClass, isR2Bucket, layer, make, makeClient };
|
package/dist/Vectorize.d.mts
CHANGED
|
@@ -3,10 +3,9 @@ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
|
|
|
3
3
|
import * as Context$1 from "effect/Context";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Schema$1 from "effect/Schema";
|
|
6
|
-
import { Vectorize, VectorizeAsyncMutation, VectorizeIndex, VectorizeIndexDetails, VectorizeIndexInfo, VectorizeMatch, VectorizeMatches, VectorizeQueryOptions, VectorizeVector, VectorizeVectorMetadata, VectorizeVectorMetadataFilter, VectorizeVectorMetadataValue, VectorizeVectorMutation } from "@cloudflare/workers-types";
|
|
7
6
|
import { Layer } from "effect";
|
|
8
7
|
declare namespace Vectorize_d_exports {
|
|
9
|
-
export { BindingNotFoundError, BindingValidationError, LayerOptions, Tag, TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails
|
|
8
|
+
export { BindingNotFoundError, BindingValidationError, LayerOptions, Tag, TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails, VectorizeIndexInfo, VectorizeMatch, VectorizeMatches, VectorizeMutation, VectorizeOperation, VectorizeOperationError, VectorizeQueryOptions, VectorizeService, VectorizeValues, VectorizeVector, VectorizeVectorMetadata, VectorizeVectorMetadataFilter, VectorizeVectorMetadataValue, isVectorizeBinding, layer, make, makeClient };
|
|
10
9
|
}
|
|
11
10
|
type VectorizeOperation = "describe" | "query" | "queryById" | "insert" | "upsert" | "deleteByIds" | "getByIds";
|
|
12
11
|
declare const VectorizeOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
@@ -23,26 +22,26 @@ interface VectorizeDefinition {
|
|
|
23
22
|
readonly binding: string;
|
|
24
23
|
}
|
|
25
24
|
type VectorizeBinding = Vectorize | VectorizeIndex;
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type VectorizeQueryOptions
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
25
|
+
type VectorizeIndexDetails = globalThis.VectorizeIndexDetails;
|
|
26
|
+
type VectorizeIndexInfo = globalThis.VectorizeIndexInfo;
|
|
27
|
+
type VectorizeMatch = globalThis.VectorizeMatch;
|
|
28
|
+
type VectorizeMatches = globalThis.VectorizeMatches;
|
|
29
|
+
type VectorizeQueryOptions = globalThis.VectorizeQueryOptions;
|
|
30
|
+
type VectorizeVector = globalThis.VectorizeVector;
|
|
31
|
+
type VectorizeVectorMetadata = globalThis.VectorizeVectorMetadata;
|
|
32
|
+
type VectorizeVectorMetadataFilter = globalThis.VectorizeVectorMetadataFilter;
|
|
33
|
+
type VectorizeVectorMetadataValue = globalThis.VectorizeVectorMetadataValue;
|
|
35
34
|
type VectorizeMutation = VectorizeAsyncMutation | VectorizeVectorMutation;
|
|
36
35
|
type VectorizeValues = Float32Array | Float64Array | ReadonlyArray<number>;
|
|
37
36
|
interface VectorizeClient {
|
|
38
|
-
readonly describe: Effect.Effect<VectorizeIndexInfo
|
|
39
|
-
readonly query: (vector: VectorizeValues, options?: VectorizeQueryOptions
|
|
40
|
-
readonly queryById: (vectorId: string, options?: VectorizeQueryOptions
|
|
41
|
-
readonly insert: (vectors: ReadonlyArray<VectorizeVector
|
|
42
|
-
readonly upsert: (vectors: ReadonlyArray<VectorizeVector
|
|
37
|
+
readonly describe: Effect.Effect<VectorizeIndexInfo | VectorizeIndexDetails, VectorizeOperationError>;
|
|
38
|
+
readonly query: (vector: VectorizeValues, options?: VectorizeQueryOptions) => Effect.Effect<VectorizeMatches, VectorizeOperationError>;
|
|
39
|
+
readonly queryById: (vectorId: string, options?: VectorizeQueryOptions) => Effect.Effect<VectorizeMatches, VectorizeOperationError>;
|
|
40
|
+
readonly insert: (vectors: ReadonlyArray<VectorizeVector>) => Effect.Effect<VectorizeMutation, VectorizeOperationError>;
|
|
41
|
+
readonly upsert: (vectors: ReadonlyArray<VectorizeVector>) => Effect.Effect<VectorizeMutation, VectorizeOperationError>;
|
|
43
42
|
readonly deleteByIds: (ids: ReadonlyArray<string>) => Effect.Effect<VectorizeMutation, VectorizeOperationError>;
|
|
44
43
|
readonly delete: (ids: ReadonlyArray<string>) => Effect.Effect<VectorizeMutation, VectorizeOperationError>;
|
|
45
|
-
readonly getByIds: (ids: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<VectorizeVector
|
|
44
|
+
readonly getByIds: (ids: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<VectorizeVector>, VectorizeOperationError>;
|
|
46
45
|
readonly rawUnsafe: Effect.Effect<VectorizeBinding>;
|
|
47
46
|
readonly definition: VectorizeDefinition;
|
|
48
47
|
}
|
|
@@ -66,4 +65,4 @@ declare const layer: <Self>(tag: Context$1.Service<Self, VectorizeClient>, defin
|
|
|
66
65
|
declare const make: <Id extends string>(id: Id) => TagClass<VectorizeService<Id>, Id>;
|
|
67
66
|
declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
|
|
68
67
|
//#endregion
|
|
69
|
-
export { type BindingNotFoundError, type BindingValidationError, LayerOptions, Tag, TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails
|
|
68
|
+
export { type BindingNotFoundError, type BindingValidationError, LayerOptions, Tag, TagClass, VectorizeBinding, VectorizeClient, VectorizeDefinition, VectorizeIndexDetails, VectorizeIndexInfo, VectorizeMatch, VectorizeMatches, VectorizeMutation, VectorizeOperation, VectorizeOperationError, VectorizeQueryOptions, VectorizeService, VectorizeValues, VectorizeVector, VectorizeVectorMetadata, VectorizeVectorMetadataFilter, VectorizeVectorMetadataValue, Vectorize_d_exports, isVectorizeBinding, layer, make, makeClient };
|
package/dist/WebTransport.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as S from "effect/Schema";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
|
-
import { Request } from "@cloudflare/workers-types";
|
|
5
4
|
declare namespace WebTransport_d_exports {
|
|
6
5
|
export { Capabilities, InboundTransport, WebTransportCapability, WebTransportUnsupportedError, capabilities, inboundSessionsUnsupported, inboundTransport, isHttp3 };
|
|
7
6
|
}
|
package/dist/WebTransport.mjs
CHANGED
|
@@ -6,6 +6,37 @@ import * as Predicate from "effect/Predicate";
|
|
|
6
6
|
import "effect/Option";
|
|
7
7
|
import * as Result from "effect/Result";
|
|
8
8
|
//#region src/WebTransport.ts
|
|
9
|
+
/**
|
|
10
|
+
* Truthful WebTransport / HTTP/3 boundary for Cloudflare Workers.
|
|
11
|
+
*
|
|
12
|
+
* What Cloudflare supports today (verified against primary sources, August
|
|
13
|
+
* 2026):
|
|
14
|
+
*
|
|
15
|
+
* - Inbound HTTP/3 is a zone-level setting. Cloudflare's edge terminates the
|
|
16
|
+
* QUIC connection and invokes the Worker with an ordinary `fetch` Request;
|
|
17
|
+
* the inbound protocol is surfaced only as metadata on `request.cf`
|
|
18
|
+
* ({@link inboundTransport}).
|
|
19
|
+
* - There is no runtime API for inbound WebTransport sessions — nothing
|
|
20
|
+
* analogous to `WebSocketPair`. workerd contains no QUIC/HTTP-3 stack, and
|
|
21
|
+
* the maintainers state WebTransport support "is not currently on our
|
|
22
|
+
* priority list" (cloudflare/workerd#6451, discussion #6454).
|
|
23
|
+
* - There is no outbound WebTransport/QUIC/UDP client capability either;
|
|
24
|
+
* `cloudflare:sockets` `connect()` is TCP-only, and
|
|
25
|
+
* `@cloudflare/workers-types` contains no WebTransport types.
|
|
26
|
+
* - Workers and Durable Objects can accept inbound WebSocket connections;
|
|
27
|
+
* Durable Objects additionally support hibernation (`acceptWebSocket`,
|
|
28
|
+
* `webSocketMessage`, `webSocketClose`).
|
|
29
|
+
*
|
|
30
|
+
* Consequently a browser's WebTransport session can never reach Worker code:
|
|
31
|
+
* clients should attempt WebTransport only against origins that actually
|
|
32
|
+
* speak it, and fall back to WebSockets for Cloudflare-hosted endpoints (see
|
|
33
|
+
* the `effect-webtransport` package's `Fallback` module). This module gives
|
|
34
|
+
* that reality a typed shape: {@link capabilities} feature-detects what the
|
|
35
|
+
* current runtime provides, {@link inboundSessionsUnsupported} is the
|
|
36
|
+
* explicit typed boundary for the missing inbound API, and
|
|
37
|
+
* {@link inboundTransport} decodes the HTTP/3-relevant request metadata that
|
|
38
|
+
* the edge does provide.
|
|
39
|
+
*/
|
|
9
40
|
var WebTransport_exports = /* @__PURE__ */ __exportAll({
|
|
10
41
|
InboundTransport: () => InboundTransport,
|
|
11
42
|
WebTransportUnsupportedError: () => WebTransportUnsupportedError,
|
package/dist/Worker.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
|
|
|
3
3
|
import { ReservedMethodName as ReservedMethodName$1 } from "./RpcDefinition.mjs";
|
|
4
4
|
import { QueueHandler } from "./Queue.mjs";
|
|
5
5
|
import { ReceiverOptions, RpcInvocationInfo } from "./RpcTracing.mjs";
|
|
6
|
+
import { RunOptions as RunOptions$1 } from "./internal/Runtime.mjs";
|
|
6
7
|
import { Api, Definition, HandlerEffect, Handlers, LayerOptions, Method, Methods, NativeSchema, NoReservedMethods, Options, RpcSchema, ServerApi, ServiceFreeSchema, Tag, TagClass, implement, method, native } from "./WorkerDefinition.mjs";
|
|
7
8
|
import { ServiceBindingFetchError, ServiceBindingRpcError, ServiceCall, ServiceRpc, ServiceScopedCall } from "./ServiceBinding.mjs";
|
|
8
9
|
import * as Context$1 from "effect/Context";
|
|
@@ -46,7 +47,7 @@ type WorkerRpcContext<ROut> = WorkerBaseContext<ROut> | Scope.Scope;
|
|
|
46
47
|
declare const RunSymbol: unique symbol;
|
|
47
48
|
declare const FetchSymbol: unique symbol;
|
|
48
49
|
/** Metadata available before an event effect or its event layer starts. */
|
|
49
|
-
interface RunOptions {
|
|
50
|
+
interface RunOptions extends RunOptions$1 {
|
|
50
51
|
readonly event?: "fetch" | "rpc" | "queue";
|
|
51
52
|
readonly rpc?: RpcInvocationInfo;
|
|
52
53
|
}
|
package/dist/Worker.mjs
CHANGED
|
@@ -102,8 +102,8 @@ function make(layer, optionsOrFetch) {
|
|
|
102
102
|
const eventLayer = runOptions.event === "fetch" ? void 0 : options.eventLayer;
|
|
103
103
|
const parent = runOptions.rpc?.parent;
|
|
104
104
|
const parentSpan = parent === void 0 ? void 0 : Tracer.externalSpan(parent);
|
|
105
|
-
if (eventLayer === void 0) return runEventPromise(this.runtime, effect, void 0, parentSpan);
|
|
106
|
-
return runEventPromise(this.runtime, effect, eventLayer, parentSpan);
|
|
105
|
+
if (eventLayer === void 0) return runEventPromise(this.runtime, effect, void 0, parentSpan, runOptions.onFailure);
|
|
106
|
+
return runEventPromise(this.runtime, effect, eventLayer, parentSpan, runOptions.onFailure);
|
|
107
107
|
}
|
|
108
108
|
fetch(request) {
|
|
109
109
|
return this[FetchSymbol](request);
|
package/dist/WorkersAi.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
|
|
|
3
3
|
import * as Context$1 from "effect/Context";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as S from "effect/Schema";
|
|
6
|
-
import { Ai, AiAsyncBatchResponse, AiGateway, AiModelListType, AiModels, AiModelsSearchObject, AiModelsSearchParams, AiOptions, AiTextEmbeddingsInput, Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input } from "@cloudflare/workers-types";
|
|
7
6
|
import { Layer } from "effect";
|
|
8
7
|
declare namespace WorkersAi_d_exports {
|
|
9
8
|
export { BindingNotFoundError, BindingValidationError, LayerOptions, Tag, TagClass, WorkersAiAsyncBatchResponse, WorkersAiBinding, WorkersAiClient, WorkersAiDefinition, WorkersAiEmbeddingInput, WorkersAiEmbeddingResponse, WorkersAiModelsSearchObject, WorkersAiModelsSearchParams, WorkersAiOperationError, WorkersAiOptions, WorkersAiService, embeddingResponse, isWorkersAiBinding, layer, make, makeClient };
|
package/dist/Workflow.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WorkerEnv, WorkerEnvironment } from "./Environment.mjs";
|
|
2
2
|
import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
|
|
3
|
+
import { RunOptions as RunOptions$1 } from "./internal/Runtime.mjs";
|
|
3
4
|
import { ExecutionContext, WorkerContext } from "./Worker.mjs";
|
|
4
5
|
import { WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowOperationError } from "./WorkflowBinding.mjs";
|
|
5
6
|
import { Definition as Definition$1, Handler as Handler$1, LayerOptions as LayerOptions$1, Options as Options$1, Tag, TagClass, implement } from "./WorkflowDefinition.mjs";
|
|
@@ -10,7 +11,7 @@ import * as Cause$1 from "effect/Cause";
|
|
|
10
11
|
import { WorkflowEntrypoint, WorkflowEvent, WorkflowSleepDuration, WorkflowStep, WorkflowStepConfig, WorkflowStepContext, WorkflowStepEvent, WorkflowTimeoutDuration } from "cloudflare:workers";
|
|
11
12
|
import { Scope } from "effect";
|
|
12
13
|
declare namespace Workflow_d_exports {
|
|
13
|
-
export { BindingNotFoundError, BindingValidationError, Definition, Handler, LayerOptions, Options, Tag, TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowOperationError, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, WorkflowStepService, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
14
|
+
export { BindingNotFoundError, BindingValidationError, Definition, Handler, LayerOptions, Options, RunOptions, RunSymbol, Tag, TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowOperationError, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, WorkflowStepService, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
14
15
|
}
|
|
15
16
|
interface WorkflowEventService<Payload = unknown> {
|
|
16
17
|
readonly raw: WorkflowEvent<unknown>;
|
|
@@ -60,12 +61,16 @@ declare class WorkflowStep$1 extends WorkflowStep_base {}
|
|
|
60
61
|
declare const WorkflowStepContext_base: Context$1.ServiceClass<WorkflowStepContext$1, "effect-cf/WorkflowStepContext", WorkflowStepContext>;
|
|
61
62
|
declare class WorkflowStepContext$1 extends WorkflowStepContext_base {}
|
|
62
63
|
type RuntimeContext<ROut> = ExecutionContext | WorkerContext | WorkerEnvironment | ROut;
|
|
64
|
+
/** Override to instrument the whole workflow run, then call super[RunSymbol]. */
|
|
65
|
+
declare const RunSymbol: unique symbol;
|
|
66
|
+
interface RunOptions extends RunOptions$1 {}
|
|
63
67
|
type WorkflowRunContext<ROut> = RuntimeContext<ROut> | WorkflowEvent$1 | WorkflowStep$1 | Scope.Scope;
|
|
64
68
|
type WorkflowHandler<ROut, Payload = unknown, Result = unknown> = (payload: Payload) => Effect.Effect<Result, unknown, WorkflowRunContext<ROut>>;
|
|
65
69
|
interface WorkflowOptions<ROut, Payload = unknown, Result = unknown> {
|
|
66
70
|
readonly run: WorkflowHandler<ROut, Payload, Result>;
|
|
67
71
|
}
|
|
68
|
-
type WorkflowClass<Payload, Result,
|
|
72
|
+
type WorkflowClass<Payload, Result, ROut> = new (ctx: globalThis.ExecutionContext, env: WorkerEnv) => WorkflowEntrypoint<WorkerEnv, Payload> & {
|
|
73
|
+
[RunSymbol]<A, E>(effect: Effect.Effect<A, E, RuntimeContext<ROut> | Scope.Scope>, options?: RunOptions): Promise<A>;
|
|
69
74
|
run(event: Readonly<WorkflowEvent<Payload>>, step: WorkflowStep): Promise<Result>;
|
|
70
75
|
};
|
|
71
76
|
declare const make: <ROut, LayerError, Payload = unknown, Result = unknown>(layer: Layer$1.Layer<ROut, LayerError, ExecutionContext | WorkerContext | WorkerEnvironment>, options: WorkflowOptions<ROut, Payload, Result>) => WorkflowClass<Payload, Result, ROut>;
|
|
@@ -84,4 +89,4 @@ type LayerOptions = LayerOptions$1;
|
|
|
84
89
|
type Handler<ROut, Self extends Definition$1.Any> = Handler$1<ROut, Self>;
|
|
85
90
|
type Options<ROut, Self extends Definition$1.Any> = Options$1<ROut, Self>;
|
|
86
91
|
//#endregion
|
|
87
|
-
export { type BindingNotFoundError, type BindingValidationError, Definition, Handler, LayerOptions, Options, Tag, type TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, type WorkflowInstance, type WorkflowInstanceCreateBatchOptions, type WorkflowInstanceCreateOptions, type WorkflowOperationError, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, WorkflowStepService, Workflow_d_exports, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
92
|
+
export { type BindingNotFoundError, type BindingValidationError, Definition, Handler, LayerOptions, Options, RunOptions, RunSymbol, Tag, type TagClass, WorkflowClass, WorkflowEvent$1 as WorkflowEvent, WorkflowEventService, WorkflowHandler, type WorkflowInstance, type WorkflowInstanceCreateBatchOptions, type WorkflowInstanceCreateOptions, type WorkflowOperationError, WorkflowOptions, WorkflowRunContext, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, WorkflowStepService, Workflow_d_exports, implement, make, sleep, sleepUntil, step, waitForEvent };
|
package/dist/Workflow.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { WorkflowEntrypoint } from "cloudflare:workers";
|
|
|
17
17
|
import { NonRetryableError } from "cloudflare:workflows";
|
|
18
18
|
//#region src/Workflow.ts
|
|
19
19
|
var Workflow_exports = /* @__PURE__ */ __exportAll({
|
|
20
|
+
RunSymbol: () => RunSymbol,
|
|
20
21
|
Tag: () => Tag,
|
|
21
22
|
WorkflowEvent: () => WorkflowEvent$1,
|
|
22
23
|
WorkflowStep: () => WorkflowStep$1,
|
|
@@ -116,6 +117,8 @@ const fromWorkflowStep = (step) => ({
|
|
|
116
117
|
})
|
|
117
118
|
})
|
|
118
119
|
});
|
|
120
|
+
/** Override to instrument the whole workflow run, then call super[RunSymbol]. */
|
|
121
|
+
const RunSymbol = Symbol.for("effect-cf/Workflow/run");
|
|
119
122
|
const make = (layer, options) => {
|
|
120
123
|
class EffectWorkflow extends WorkflowEntrypoint {
|
|
121
124
|
runtime;
|
|
@@ -125,7 +128,10 @@ const make = (layer, options) => {
|
|
|
125
128
|
}
|
|
126
129
|
run(event, step) {
|
|
127
130
|
const workflowServices = Layer.mergeAll(Layer.succeed(WorkflowEvent$1, fromWorkflowEvent(event)), Layer.succeed(WorkflowStep$1, fromWorkflowStep(step)));
|
|
128
|
-
return
|
|
131
|
+
return this[RunSymbol](options.run(event.payload).pipe(Effect.provide(workflowServices, { local: true })));
|
|
132
|
+
}
|
|
133
|
+
[RunSymbol](effect, runOptions = {}) {
|
|
134
|
+
return runEventPromise(this.runtime, effect, void 0, void 0, runOptions.onFailure);
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
137
|
return assumeEntrypointClass(EffectWorkflow);
|
|
@@ -135,4 +141,4 @@ const sleep = (name, duration) => Effect.flatMap(WorkflowStep$1, (workflowStep)
|
|
|
135
141
|
const sleepUntil = (name, timestamp) => Effect.flatMap(WorkflowStep$1, (workflowStep) => workflowStep.sleepUntil(name, timestamp));
|
|
136
142
|
const waitForEvent = (name, options) => Effect.flatMap(WorkflowStep$1, (workflowStep) => workflowStep.waitForEvent(name, options));
|
|
137
143
|
//#endregion
|
|
138
|
-
export { Tag, WorkflowEvent$1 as WorkflowEvent, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, Workflow_exports, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
144
|
+
export { RunSymbol, Tag, WorkflowEvent$1 as WorkflowEvent, WorkflowStep$1 as WorkflowStep, WorkflowStepContext$1 as WorkflowStepContext, WorkflowStepError, WorkflowStepNonRetryableError, Workflow_exports, implement, make, sleep, sleepUntil, step, waitForEvent };
|
|
@@ -4,18 +4,17 @@ import { ServiceFreeSchema } from "./RpcDefinition.mjs";
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as S from "effect/Schema";
|
|
6
6
|
import * as Option from "effect/Option";
|
|
7
|
-
import { InstanceStatus, Workflow, WorkflowInstance, WorkflowInstanceCreateOptions, WorkflowInstanceLocationHint, WorkflowInstanceRestartOptions, WorkflowInstanceTerminateOptions } from "@cloudflare/workers-types";
|
|
8
7
|
import { Context } from "effect";
|
|
9
8
|
declare namespace WorkflowBinding_d_exports {
|
|
10
|
-
export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance
|
|
9
|
+
export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceLocationHint, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowInstanceTerminateOptions, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer, makeClient };
|
|
11
10
|
}
|
|
12
|
-
type WorkflowInstanceCreateOptions
|
|
11
|
+
type WorkflowInstanceCreateOptions<Payload> = Omit<globalThis.WorkflowInstanceCreateOptions<Payload>, "params">;
|
|
13
12
|
type WorkflowInstanceCreateBatchOptions<Payload, EncodedPayload = unknown> = ReadonlyArray<{
|
|
14
13
|
readonly payload: Payload;
|
|
15
|
-
} & WorkflowInstanceCreateOptions
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
type
|
|
14
|
+
} & WorkflowInstanceCreateOptions<EncodedPayload>>;
|
|
15
|
+
type WorkflowInstanceLocationHint = globalThis.WorkflowInstanceLocationHint;
|
|
16
|
+
type WorkflowInstanceRestartOptions = globalThis.WorkflowInstanceRestartOptions;
|
|
17
|
+
type WorkflowInstanceTerminateOptions = globalThis.WorkflowInstanceTerminateOptions;
|
|
19
18
|
type WorkflowInstanceStatusName = InstanceStatus["status"];
|
|
20
19
|
interface WorkflowInstanceStatus<Result> {
|
|
21
20
|
readonly status: WorkflowInstanceStatusName;
|
|
@@ -25,13 +24,13 @@ interface WorkflowInstanceStatus<Result> {
|
|
|
25
24
|
readonly message: string;
|
|
26
25
|
}>;
|
|
27
26
|
}
|
|
28
|
-
interface WorkflowInstance
|
|
29
|
-
readonly raw: WorkflowInstance;
|
|
27
|
+
interface WorkflowInstance<Result> {
|
|
28
|
+
readonly raw: globalThis.WorkflowInstance;
|
|
30
29
|
readonly id: string;
|
|
31
30
|
readonly pause: Effect.Effect<void, WorkflowOperationError>;
|
|
32
31
|
readonly resume: Effect.Effect<void, WorkflowOperationError>;
|
|
33
|
-
readonly terminate: (options?: WorkflowInstanceTerminateOptions
|
|
34
|
-
readonly restart: (options?: WorkflowInstanceRestartOptions
|
|
32
|
+
readonly terminate: (options?: WorkflowInstanceTerminateOptions) => Effect.Effect<void, WorkflowOperationError>;
|
|
33
|
+
readonly restart: (options?: WorkflowInstanceRestartOptions) => Effect.Effect<void, WorkflowOperationError>;
|
|
35
34
|
readonly delete: Effect.Effect<void, WorkflowOperationError>;
|
|
36
35
|
readonly status: Effect.Effect<WorkflowInstanceStatus<Result>, WorkflowOperationError | WorkflowResultDecodeError>;
|
|
37
36
|
readonly sendEvent: (event: WorkflowInstanceEvent) => Effect.Effect<void, WorkflowOperationError>;
|
|
@@ -46,9 +45,9 @@ interface WorkflowBindingDefinition<Payload extends ServiceFreeSchema, Result ex
|
|
|
46
45
|
readonly result: Result;
|
|
47
46
|
}
|
|
48
47
|
interface WorkflowBindingClient<Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema> {
|
|
49
|
-
readonly create: (payload: S.Schema.Type<Payload>, options?: WorkflowInstanceCreateOptions
|
|
50
|
-
readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions<S.Schema.Type<Payload>, S.Codec.Encoded<Payload>>) => Effect.Effect<ReadonlyArray<WorkflowInstance
|
|
51
|
-
readonly get: (instanceId: string) => Effect.Effect<WorkflowInstance
|
|
48
|
+
readonly create: (payload: S.Schema.Type<Payload>, options?: WorkflowInstanceCreateOptions<S.Codec.Encoded<Payload>>) => Effect.Effect<WorkflowInstance<S.Schema.Type<Result>>, WorkflowOperationError | S.SchemaError>;
|
|
49
|
+
readonly createBatch: (batch: WorkflowInstanceCreateBatchOptions<S.Schema.Type<Payload>, S.Codec.Encoded<Payload>>) => Effect.Effect<ReadonlyArray<WorkflowInstance<S.Schema.Type<Result>>>, WorkflowOperationError | S.SchemaError>;
|
|
50
|
+
readonly get: (instanceId: string) => Effect.Effect<WorkflowInstance<S.Schema.Type<Result>>, WorkflowOperationError>;
|
|
52
51
|
readonly rawUnsafe: Effect.Effect<Workflow<S.Codec.Encoded<Payload>>>;
|
|
53
52
|
}
|
|
54
53
|
declare const WorkflowOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
@@ -76,4 +75,4 @@ declare const isWorkflow: <Payload>(value: WorkflowBindingValue) => value is Wor
|
|
|
76
75
|
declare const makeClient: <Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema>(definition: WorkflowBindingDefinition<Payload, Result>) => ((workflow: Workflow<S.Codec.Encoded<Payload>>) => WorkflowBindingClient<Payload, Result>);
|
|
77
76
|
declare const layer: <Self, Payload extends ServiceFreeSchema, Result extends ServiceFreeSchema>(tag: Context.Service<Self, WorkflowBindingClient<Payload, Result>>, definition: WorkflowBindingDefinition<Payload, Result>) => import("effect/Layer").Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
|
|
78
77
|
//#endregion
|
|
79
|
-
export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowBinding_d_exports, WorkflowInstance
|
|
78
|
+
export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowBinding_d_exports, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceLocationHint, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowInstanceTerminateOptions, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer, makeClient };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "../Environment.mjs";
|
|
2
|
+
import "effect/Effect";
|
|
3
|
+
import "effect/Layer";
|
|
4
|
+
import * as Cause$1 from "effect/Cause";
|
|
5
|
+
import "effect/ManagedRuntime";
|
|
6
|
+
import { Scope } from "effect";
|
|
7
|
+
//#region src/internal/Runtime.d.ts
|
|
8
|
+
interface RunOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Observes a failed event's complete cause, including interruption, after its
|
|
11
|
+
* scope closes and before the native Promise rejects. Also observes runtime
|
|
12
|
+
* acquisition failures. Called once per failed invocation, never on success.
|
|
13
|
+
* Returned Promises are awaited; throws and rejections are ignored. The
|
|
14
|
+
* observer must settle and cannot use resources from the closed event scope.
|
|
15
|
+
* Reporting, filtering and privacy remain the caller's responsibility.
|
|
16
|
+
*/
|
|
17
|
+
readonly onFailure?: (cause: Cause$1.Cause<unknown>) => void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { RunOptions };
|
|
@@ -4,8 +4,20 @@ import { provideEntrypointServices } from "./Entrypoint.mjs";
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
6
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
7
|
+
import * as Cause from "effect/Cause";
|
|
7
8
|
import * as ManagedRuntime from "effect/ManagedRuntime";
|
|
8
9
|
//#region src/internal/Runtime.ts
|
|
10
|
+
const runPromise = (runtime, effect, onFailure) => {
|
|
11
|
+
if (onFailure === void 0) return runtime.runPromise(effect);
|
|
12
|
+
return runtime.runPromiseExit(effect).then(async (exit) => {
|
|
13
|
+
if (exit._tag === "Success") return exit.value;
|
|
14
|
+
const rejection = Cause.squash(exit.cause);
|
|
15
|
+
try {
|
|
16
|
+
await onFailure(exit.cause);
|
|
17
|
+
} catch {}
|
|
18
|
+
throw rejection;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
9
21
|
/**
|
|
10
22
|
* Assembles the shared `ManagedRuntime` used by the Cloudflare entrypoint
|
|
11
23
|
* classes (Worker, Durable Object, Workflow).
|
|
@@ -20,13 +32,13 @@ const makeEntrypointRuntime = (layer, env, services) => {
|
|
|
20
32
|
return ManagedRuntime.make(provideEntrypointServices(layer, entrypointServices));
|
|
21
33
|
};
|
|
22
34
|
function runEventPromise(...args) {
|
|
23
|
-
const [runtime, effect, eventLayer, parent] = args;
|
|
35
|
+
const [runtime, effect, eventLayer, parent, onFailure] = args;
|
|
24
36
|
if (eventLayer === void 0) {
|
|
25
37
|
const event = Effect.scoped(withScope(effect));
|
|
26
|
-
return
|
|
38
|
+
return runPromise(runtime, parent === void 0 ? event : Effect.withParentSpan(event, parent), onFailure);
|
|
27
39
|
}
|
|
28
40
|
const event = Effect.scoped(withScope(effect.pipe(Effect.provide(eventLayer, { local: true }))));
|
|
29
|
-
return
|
|
41
|
+
return runPromise(runtime, parent === void 0 ? event : Effect.withParentSpan(event, parent), onFailure);
|
|
30
42
|
}
|
|
31
43
|
//#endregion
|
|
32
44
|
export { makeEntrypointRuntime, runEventPromise };
|
package/package.json
CHANGED
package/src/AiGateway.ts
CHANGED
|
@@ -3,7 +3,6 @@ import * as Data from "effect/Data";
|
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as S from "effect/Schema";
|
|
5
5
|
import type { Layer } from "effect";
|
|
6
|
-
import type { AiGateway as CloudflareAiGateway } from "@cloudflare/workers-types";
|
|
7
6
|
|
|
8
7
|
import * as Binding from "./Binding";
|
|
9
8
|
import type { WorkerEnvironment } from "./Environment";
|
|
@@ -30,14 +29,14 @@ export interface AiGatewayDefinition {
|
|
|
30
29
|
readonly accountId?: string;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export type AiGatewayBinding =
|
|
32
|
+
export type AiGatewayBinding = AiGateway;
|
|
34
33
|
type AiGatewayRunData = Parameters<AiGatewayBinding["run"]>[0];
|
|
35
34
|
export type AiGatewayPatchLog = Parameters<AiGatewayBinding["patchLog"]>[1];
|
|
36
35
|
export type AiGatewayLog = Awaited<ReturnType<AiGatewayBinding["getLog"]>>;
|
|
37
36
|
export type AiGatewayProvider = NonNullable<Parameters<AiGatewayBinding["getUrl"]>[0]>;
|
|
38
37
|
export type AiGatewayUniversalRequest = Exclude<AiGatewayRunData, ReadonlyArray<unknown>>;
|
|
39
38
|
export type AiGatewayHeaders = NonNullable<AiGatewayUniversalRequest["headers"]>;
|
|
40
|
-
export type AiGatewayRunOptions = Parameters<
|
|
39
|
+
export type AiGatewayRunOptions = Parameters<AiGatewayBinding["run"]>[1];
|
|
41
40
|
type AiGatewayBindingCandidate = Parameters<typeof isWorkersAiBinding>[0];
|
|
42
41
|
|
|
43
42
|
const AiGatewayMetadata = S.Record(S.String, S.Union([S.String, S.Number, S.Boolean, S.Null]));
|
package/src/AnalyticsEngine.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnalyticsEngineDataPoint as CloudflareAnalyticsEngineDataPoint,
|
|
3
|
-
AnalyticsEngineDataset as CloudflareAnalyticsEngineDataset,
|
|
4
|
-
} from "@cloudflare/workers-types";
|
|
5
1
|
import * as Config from "effect/Config";
|
|
6
2
|
import * as Context from "effect/Context";
|
|
7
3
|
import * as Data from "effect/Data";
|
|
@@ -107,8 +103,8 @@ export interface AnalyticsEngineDefinition {
|
|
|
107
103
|
readonly binding: string;
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
export type AnalyticsEngineBinding =
|
|
111
|
-
export type AnalyticsEngineDataPoint =
|
|
106
|
+
export type AnalyticsEngineBinding = AnalyticsEngineDataset;
|
|
107
|
+
export type AnalyticsEngineDataPoint = globalThis.AnalyticsEngineDataPoint;
|
|
112
108
|
export type AnalyticsEngineFieldValue = ArrayBuffer | string | null;
|
|
113
109
|
export type AnalyticsEngineWriteError =
|
|
114
110
|
| AnalyticsEngineOperationError
|
package/src/Artifacts.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ArtifactsCreateRepoResult as CloudflareArtifactsCreateRepoResult,
|
|
3
|
-
ArtifactsCreateTokenResult as CloudflareArtifactsCreateTokenResult,
|
|
4
|
-
ArtifactsErrorCode as CloudflareArtifactsErrorCode,
|
|
5
|
-
ArtifactsRepoInfo as CloudflareArtifactsRepoInfo,
|
|
6
|
-
ArtifactsTokenInfo as CloudflareArtifactsTokenInfo,
|
|
7
|
-
ArtifactsTokenListResult as CloudflareArtifactsTokenListResult,
|
|
8
|
-
} from "@cloudflare/workers-types";
|
|
9
1
|
import * as Context from "effect/Context";
|
|
10
2
|
import * as Data from "effect/Data";
|
|
11
3
|
import * as Effect from "effect/Effect";
|
|
@@ -56,7 +48,7 @@ export const artifactsErrorCodes = [
|
|
|
56
48
|
"UPSTREAM_UNAVAILABLE",
|
|
57
49
|
"MEMORY_LIMIT",
|
|
58
50
|
"INTERNAL_ERROR",
|
|
59
|
-
] as const satisfies ReadonlyArray<
|
|
51
|
+
] as const satisfies ReadonlyArray<ArtifactsErrorCode>;
|
|
60
52
|
|
|
61
53
|
export const artifactsErrorNumericCodes = {
|
|
62
54
|
ALREADY_EXISTS: 10201,
|
|
@@ -71,9 +63,9 @@ export const artifactsErrorNumericCodes = {
|
|
|
71
63
|
UPSTREAM_UNAVAILABLE: 10401,
|
|
72
64
|
MEMORY_LIMIT: 10402,
|
|
73
65
|
INTERNAL_ERROR: 10400,
|
|
74
|
-
} as const satisfies Readonly<Record<
|
|
66
|
+
} as const satisfies Readonly<Record<ArtifactsErrorCode, number>>;
|
|
75
67
|
|
|
76
|
-
export type ArtifactsErrorCode =
|
|
68
|
+
export type ArtifactsErrorCode = globalThis.ArtifactsErrorCode;
|
|
77
69
|
|
|
78
70
|
export class ArtifactsOperationError extends Data.TaggedError("ArtifactsOperationError")<{
|
|
79
71
|
readonly binding: string;
|
|
@@ -105,9 +97,9 @@ export type ArtifactsTokenState = "active" | "expired" | "revoked";
|
|
|
105
97
|
|
|
106
98
|
export type ArtifactsRepoStatus = "ready" | "importing" | "forking";
|
|
107
99
|
|
|
108
|
-
export type ArtifactsRepoInfo =
|
|
100
|
+
export type ArtifactsRepoInfo = globalThis.ArtifactsRepoInfo;
|
|
109
101
|
|
|
110
|
-
export type ArtifactsCreateRepoResult = Readonly<
|
|
102
|
+
export type ArtifactsCreateRepoResult = Readonly<globalThis.ArtifactsCreateRepoResult>;
|
|
111
103
|
|
|
112
104
|
export interface ArtifactsRepoListEntry extends ArtifactsRepoInfo {
|
|
113
105
|
readonly status: ArtifactsRepoStatus;
|
|
@@ -120,13 +112,13 @@ export interface ArtifactsRepoListResult {
|
|
|
120
112
|
}
|
|
121
113
|
|
|
122
114
|
/** Result of creating a repository token. */
|
|
123
|
-
export type ArtifactsCreateTokenResult =
|
|
115
|
+
export type ArtifactsCreateTokenResult = globalThis.ArtifactsCreateTokenResult;
|
|
124
116
|
|
|
125
117
|
/** Repository token metadata, excluding its plaintext secret. */
|
|
126
|
-
export type ArtifactsTokenInfo =
|
|
118
|
+
export type ArtifactsTokenInfo = globalThis.ArtifactsTokenInfo;
|
|
127
119
|
|
|
128
120
|
/** Repository token list result. */
|
|
129
|
-
export type ArtifactsTokenListResult =
|
|
121
|
+
export type ArtifactsTokenListResult = globalThis.ArtifactsTokenListResult;
|
|
130
122
|
|
|
131
123
|
/** Identity recorded for a Git commit author or committer. */
|
|
132
124
|
export interface ArtifactsCommitIdentity {
|