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/src/Cache.ts CHANGED
@@ -1,9 +1,3 @@
1
- import type {
2
- Cache as CloudflareCache,
3
- CacheQueryOptions as CloudflareCacheQueryOptions,
4
- CacheStorage as CloudflareCacheStorage,
5
- RequestInfo as CloudflareRequestInfo,
6
- } from "@cloudflare/workers-types";
7
1
  import * as Context from "effect/Context";
8
2
  import * as Data from "effect/Data";
9
3
  import * as Effect from "effect/Effect";
@@ -12,9 +6,9 @@ import * as Option from "effect/Option";
12
6
 
13
7
  import * as ErrorMessage from "./internal/ErrorMessage";
14
8
 
15
- export type CacheRequest = CloudflareRequestInfo | URL;
9
+ export type CacheRequest = RequestInfo | URL;
16
10
 
17
- export type CacheQueryOptions = CloudflareCacheQueryOptions;
11
+ export type CacheQueryOptions = globalThis.CacheQueryOptions;
18
12
 
19
13
  export type CacheOperation = "open" | "match" | "put" | "delete";
20
14
 
@@ -42,13 +36,13 @@ export interface CacheClient {
42
36
  request: CacheRequest,
43
37
  options?: CacheQueryOptions,
44
38
  ) => Effect.Effect<boolean, CacheOperationError>;
45
- readonly rawUnsafe: Effect.Effect<CloudflareCache>;
39
+ readonly rawUnsafe: Effect.Effect<Cache>;
46
40
  }
47
41
 
48
42
  export interface CacheStorageClient {
49
43
  readonly default: CacheClient;
50
44
  readonly open: (name: string) => Effect.Effect<CacheClient, CacheOperationError>;
51
- readonly rawUnsafe: Effect.Effect<CloudflareCacheStorage>;
45
+ readonly rawUnsafe: Effect.Effect<globalThis.CacheStorage>;
52
46
  }
53
47
 
54
48
  export class CacheStorage extends Context.Service<CacheStorage, CacheStorageClient>()(
@@ -72,7 +66,7 @@ const spanOptions = (cache: string, operation: CacheOperation) => ({
72
66
  attributes: { cache, operation },
73
67
  });
74
68
 
75
- export const makeCacheClient = (cache: CloudflareCache, name = "default"): CacheClient => ({
69
+ export const makeCacheClient = (cache: Cache, name = "default"): CacheClient => ({
76
70
  name,
77
71
  match: Effect.fn(
78
72
  "Cache.match",
@@ -97,7 +91,7 @@ export const makeCacheClient = (cache: CloudflareCache, name = "default"): Cache
97
91
  rawUnsafe: Effect.succeed(cache),
98
92
  });
99
93
 
100
- export const makeClient = (storage: CloudflareCacheStorage): CacheStorageClient => ({
94
+ export const makeClient = (storage: globalThis.CacheStorage): CacheStorageClient => ({
101
95
  default: makeCacheClient(storage.default),
102
96
  open: (name) =>
103
97
  tryCachePromise(name, "open", () => storage.open(name)).pipe(
@@ -107,7 +101,7 @@ export const makeClient = (storage: CloudflareCacheStorage): CacheStorageClient
107
101
  rawUnsafe: Effect.succeed(storage),
108
102
  });
109
103
 
110
- export const layerFrom = (storage: CloudflareCacheStorage): Layer.Layer<CacheStorage> =>
104
+ export const layerFrom = (storage: globalThis.CacheStorage): Layer.Layer<CacheStorage> =>
111
105
  Layer.succeed(CacheStorage, makeClient(storage));
112
106
 
113
107
  export const layer: Layer.Layer<CacheStorage> = Layer.sync(CacheStorage, () => makeClient(caches));
@@ -43,7 +43,7 @@ type HandlerContext<ROut> = RuntimeContext<ROut> | Scope.Scope;
43
43
 
44
44
  type FetchContext<ROut> = HandlerContext<ROut> | NativeRequest;
45
45
  /** Metadata available before an event effect or its event layer starts. */
46
- export interface RunOptions {
46
+ export interface RunOptions extends Runtime.RunOptions {
47
47
  readonly eventLayer?: boolean;
48
48
  readonly event?:
49
49
  | "fetch"
@@ -331,6 +331,7 @@ export function make<
331
331
  effect as Effect.Effect<A, E, HandlerContext<ROut | RAlarm>>,
332
332
  undefined,
333
333
  parentSpan,
334
+ runOptions.onFailure,
334
335
  );
335
336
  }
336
337
 
@@ -341,7 +342,7 @@ export function make<
341
342
  REvent,
342
343
  EventLayerError,
343
344
  LayerError
344
- >(this.runtime, effect, eventLayer, parentSpan);
345
+ >(this.runtime, effect, eventLayer, parentSpan, runOptions.onFailure);
345
346
  }
346
347
 
347
348
  fetch(request: Request): Promise<Response> {
package/src/Email.ts CHANGED
@@ -1,9 +1,3 @@
1
- import type {
2
- EmailAddress as CloudflareEmailAddress,
3
- EmailAttachment as CloudflareEmailAttachment,
4
- EmailSendResult as CloudflareEmailSendResult,
5
- SendEmail as CloudflareSendEmail,
6
- } from "@cloudflare/workers-types";
7
1
  import * as Context from "effect/Context";
8
2
  import * as Data from "effect/Data";
9
3
  import * as Effect from "effect/Effect";
@@ -103,11 +97,11 @@ export interface EmailDefinition {
103
97
  readonly binding: string;
104
98
  }
105
99
 
106
- export type EmailAddress = CloudflareEmailAddress;
107
- export type EmailAttachment = CloudflareEmailAttachment;
108
- export type EmailMessageBuilder = Parameters<CloudflareSendEmail["send"]>[0];
109
- export type EmailSendResult = CloudflareEmailSendResult;
110
- export type EmailBinding = CloudflareSendEmail;
100
+ export type EmailAddress = globalThis.EmailAddress;
101
+ export type EmailAttachment = globalThis.EmailAttachment;
102
+ export type EmailSendResult = globalThis.EmailSendResult;
103
+ export type EmailMessageBuilder = Parameters<SendEmail["send"]>[0];
104
+ export type EmailBinding = SendEmail;
111
105
  export type EmailRecipients = string | EmailAddress | ReadonlyArray<string | EmailAddress>;
112
106
  export type EmailSendError = EmailOperationError | EmailValidationError;
113
107
  type EmailFieldCandidate = Parameters<typeof Predicate.isUnknown>[0];
package/src/Images.ts CHANGED
@@ -1,26 +1,3 @@
1
- import type {
2
- HostedImagesBinding as CloudflareHostedImagesBinding,
3
- ImageDirectUploadOptions as CloudflareImageDirectUploadOptions,
4
- ImageDirectUploadResult as CloudflareImageDirectUploadResult,
5
- ImageDrawOptions as CloudflareImageDrawOptions,
6
- ImageHandle as CloudflareImageHandle,
7
- ImageInfoResponse as CloudflareImageInfoResponse,
8
- ImageInputOptions as CloudflareImageInputOptions,
9
- ImageList as CloudflareImageList,
10
- ImageListOptions as CloudflareImageListOptions,
11
- ImageMetadata as CloudflareImageMetadata,
12
- ImageOutputOptions as CloudflareImageOutputOptions,
13
- ImageSignedUrlOptions as CloudflareImageSignedUrlOptions,
14
- ImageTransform as CloudflareImageTransform,
15
- ImageTransformationOutputOptions as CloudflareImageTransformationOutputOptions,
16
- ImageTransformationResponseOptions as CloudflareImageTransformationResponseOptions,
17
- ImageTransformationResult as CloudflareImageTransformationResult,
18
- ImageTransformer as CloudflareImageTransformer,
19
- ImageUpdateOptions as CloudflareImageUpdateOptions,
20
- ImageUploadOptions as CloudflareImageUploadOptions,
21
- Response as CloudflareResponse,
22
- TextOptions as CloudflareTextOptions,
23
- } from "@cloudflare/workers-types";
24
1
  import * as Context from "effect/Context";
25
2
  import * as Data from "effect/Data";
26
3
  import * as Effect from "effect/Effect";
@@ -55,28 +32,28 @@ export interface ImagesDefinition {
55
32
  readonly binding: string;
56
33
  }
57
34
 
58
- export type ImageInfoResponse = CloudflareImageInfoResponse;
59
- export type ImageTransform = CloudflareImageTransform;
60
- export type ImageDrawOptions = CloudflareImageDrawOptions;
61
- export type ImageInputOptions = CloudflareImageInputOptions;
62
- export type ImageOutputOptions = CloudflareImageOutputOptions;
63
- export type ImageTransformationOutputOptions = CloudflareImageTransformationOutputOptions;
64
- export type ImageTransformationResponseOptions = CloudflareImageTransformationResponseOptions;
65
- export type ImageTransformationResult = CloudflareImageTransformationResult;
66
- export type ImageUploadOptions = CloudflareImageUploadOptions;
67
- export type ImageUpdateOptions = CloudflareImageUpdateOptions;
68
- export type ImageListOptions = CloudflareImageListOptions;
69
- export type ImageList = CloudflareImageList;
70
- export type ImageMetadata = CloudflareImageMetadata;
71
- export type ImageSignedUrlOptions = CloudflareImageSignedUrlOptions;
72
- export type ImageDirectUploadOptions = CloudflareImageDirectUploadOptions;
73
- export type ImageDirectUploadResult = CloudflareImageDirectUploadResult;
74
- export type TextOptions = CloudflareTextOptions;
35
+ export type ImageDirectUploadOptions = globalThis.ImageDirectUploadOptions;
36
+ export type ImageDirectUploadResult = globalThis.ImageDirectUploadResult;
37
+ export type ImageDrawOptions = globalThis.ImageDrawOptions;
38
+ export type ImageInfoResponse = globalThis.ImageInfoResponse;
39
+ export type ImageInputOptions = globalThis.ImageInputOptions;
40
+ export type ImageList = globalThis.ImageList;
41
+ export type ImageListOptions = globalThis.ImageListOptions;
42
+ export type ImageMetadata = globalThis.ImageMetadata;
43
+ export type ImageOutputOptions = globalThis.ImageOutputOptions;
44
+ export type ImageSignedUrlOptions = globalThis.ImageSignedUrlOptions;
45
+ export type ImageTransform = globalThis.ImageTransform;
46
+ export type ImageTransformationOutputOptions = globalThis.ImageTransformationOutputOptions;
47
+ export type ImageTransformationResponseOptions = globalThis.ImageTransformationResponseOptions;
48
+ export type ImageTransformationResult = globalThis.ImageTransformationResult;
49
+ export type ImageUpdateOptions = globalThis.ImageUpdateOptions;
50
+ export type ImageUploadOptions = globalThis.ImageUploadOptions;
51
+ export type TextOptions = globalThis.TextOptions;
75
52
  export type ImageInputValue = ReadableStream<Uint8Array> | ArrayBuffer;
76
53
  export type ImageUploadValue = ReadableStream<Uint8Array> | ArrayBuffer;
77
54
 
78
55
  export interface DrawStepOptions {
79
- readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
56
+ readonly image: ReadableStream<Uint8Array> | ImageTransformer;
80
57
  readonly options?: ImageDrawOptions;
81
58
  }
82
59
 
@@ -107,10 +84,10 @@ export type ProcessOptions =
107
84
  };
108
85
 
109
86
  export interface ImagesTransformationResultClient {
110
- readonly raw: CloudflareImageTransformationResult;
87
+ readonly raw: ImageTransformationResult;
111
88
  readonly response: (
112
89
  options?: ImageTransformationResponseOptions,
113
- ) => Effect.Effect<CloudflareResponse, ImagesOperationError>;
90
+ ) => Effect.Effect<Response, ImagesOperationError>;
114
91
  readonly contentType: Effect.Effect<string, ImagesOperationError>;
115
92
  readonly image: (
116
93
  options?: ImageTransformationOutputOptions,
@@ -118,7 +95,7 @@ export interface ImagesTransformationResultClient {
118
95
  }
119
96
 
120
97
  export interface ImageHandleClient {
121
- readonly raw: CloudflareImageHandle;
98
+ readonly raw: ImageHandle;
122
99
  readonly details: Effect.Effect<Option.Option<ImageMetadata>, ImagesOperationError>;
123
100
  readonly bytes: Effect.Effect<Option.Option<ReadableStream<Uint8Array>>, ImagesOperationError>;
124
101
  readonly signedUrl: (
@@ -140,7 +117,7 @@ export interface HostedImagesClient {
140
117
  readonly createDirectUpload: (
141
118
  options?: ImageDirectUploadOptions,
142
119
  ) => Effect.Effect<ImageDirectUploadResult, ImagesOperationError>;
143
- readonly rawUnsafe: Effect.Effect<CloudflareHostedImagesBinding>;
120
+ readonly rawUnsafe: Effect.Effect<HostedImagesBinding>;
144
121
  }
145
122
 
146
123
  export interface ImagesRuntimeBinding {
@@ -148,12 +125,9 @@ export interface ImagesRuntimeBinding {
148
125
  image: ImageInputValue,
149
126
  options?: ImageInputOptions,
150
127
  ) => Promise<ImageInfoResponse>;
151
- readonly input: (
152
- image: ImageInputValue,
153
- options?: ImageInputOptions,
154
- ) => CloudflareImageTransformer;
155
- readonly text?: (content: string, options: TextOptions) => CloudflareImageTransformer;
156
- readonly hosted?: CloudflareHostedImagesBinding;
128
+ readonly input: (image: ImageInputValue, options?: ImageInputOptions) => ImageTransformer;
129
+ readonly text?: (content: string, options: TextOptions) => ImageTransformer;
130
+ readonly hosted?: HostedImagesBinding;
157
131
  }
158
132
 
159
133
  export interface ImagesClient {
@@ -164,11 +138,11 @@ export interface ImagesClient {
164
138
  readonly input: (
165
139
  image: ImageInputValue,
166
140
  options?: ImageInputOptions,
167
- ) => Effect.Effect<CloudflareImageTransformer, ImagesOperationError>;
141
+ ) => Effect.Effect<ImageTransformer, ImagesOperationError>;
168
142
  readonly text: (
169
143
  content: string,
170
144
  options: TextOptions,
171
- ) => Effect.Effect<CloudflareImageTransformer, ImagesOperationError>;
145
+ ) => Effect.Effect<ImageTransformer, ImagesOperationError>;
172
146
  readonly process: (
173
147
  steps: Steps,
174
148
  options: ProcessOptions,
@@ -257,7 +231,7 @@ const hasFunction = <Candidate>(value: Candidate, key: string): boolean =>
257
231
 
258
232
  const isHostedImagesBinding = <Candidate>(
259
233
  value: Candidate,
260
- ): value is Candidate & CloudflareHostedImagesBinding =>
234
+ ): value is Candidate & HostedImagesBinding =>
261
235
  hasFunction(value, "image") &&
262
236
  hasFunction(value, "upload") &&
263
237
  hasFunction(value, "list") &&
@@ -270,7 +244,7 @@ export const isImagesBinding = <Candidate>(
270
244
 
271
245
  const wrapResult = (
272
246
  binding: string,
273
- result: CloudflareImageTransformationResult,
247
+ result: ImageTransformationResult,
274
248
  ): ImagesTransformationResultClient => ({
275
249
  raw: result,
276
250
  response: (options) => tryImagesSync(binding, "response", () => result.response(options)),
@@ -278,7 +252,7 @@ const wrapResult = (
278
252
  image: (options) => tryImagesSync(binding, "image", () => result.image(options)),
279
253
  });
280
254
 
281
- const wrapHandle = (binding: string, handle: CloudflareImageHandle): ImageHandleClient => ({
255
+ const wrapHandle = (binding: string, handle: ImageHandle): ImageHandleClient => ({
282
256
  raw: handle,
283
257
  details: tryImagesPromise(binding, "details", () => handle.details()).pipe(
284
258
  Effect.map(maybe),
@@ -299,10 +273,7 @@ const wrapHandle = (binding: string, handle: CloudflareImageHandle): ImageHandle
299
273
  ),
300
274
  });
301
275
 
302
- const wrapHosted = (
303
- binding: string,
304
- hosted: CloudflareHostedImagesBinding,
305
- ): HostedImagesClient => ({
276
+ const wrapHosted = (binding: string, hosted: HostedImagesBinding): HostedImagesClient => ({
306
277
  image: (imageId) => wrapHandle(binding, hosted.image(imageId)),
307
278
  upload: Effect.fn("Images.upload")((image: ImageUploadValue, options?: ImageUploadOptions) =>
308
279
  tryImagesPromise(binding, "upload", () => hosted.upload(image, options)),
package/src/Kv.ts CHANGED
@@ -1,7 +1,3 @@
1
- import type {
2
- KVNamespaceListOptions as CloudflareKVNamespaceListOptions,
3
- KVNamespacePutOptions as CloudflareKVNamespacePutOptions,
4
- } from "@cloudflare/workers-types";
5
1
  import * as Context from "effect/Context";
6
2
  import * as Data from "effect/Data";
7
3
  import * as Effect from "effect/Effect";
@@ -31,8 +27,8 @@ export class KvOperationError extends Data.TaggedError("KvOperationError")<{
31
27
  }
32
28
  }
33
29
 
34
- export type KvPutOptions = CloudflareKVNamespacePutOptions;
35
- export type KvListOptions<Metadata = unknown> = CloudflareKVNamespaceListOptions & {
30
+ export type KvPutOptions = KVNamespacePutOptions;
31
+ export type KvListOptions<Metadata = unknown> = KVNamespaceListOptions & {
36
32
  readonly metadataSchema?: S.Codec<Metadata, unknown>;
37
33
  };
38
34
 
@@ -1,12 +1,3 @@
1
- import type {
2
- MessageSendRequest as CloudflareMessageSendRequest,
3
- Queue as CloudflareQueue,
4
- QueueMetrics as CloudflareQueueMetrics,
5
- QueueSendBatchOptions as CloudflareQueueSendBatchOptions,
6
- QueueSendBatchResponse as CloudflareQueueSendBatchResponse,
7
- QueueSendOptions as CloudflareQueueSendOptions,
8
- QueueSendResponse as CloudflareQueueSendResponse,
9
- } from "@cloudflare/workers-types";
10
1
  import * as Data from "effect/Data";
11
2
  import * as Effect from "effect/Effect";
12
3
  import * as Predicate from "effect/Predicate";
@@ -16,15 +7,15 @@ import type { Context } from "effect";
16
7
  import * as Binding from "./Binding";
17
8
  import type * as RpcDefinition from "./RpcDefinition";
18
9
 
19
- export type QueueSendOptions = CloudflareQueueSendOptions;
20
- export type QueueSendResponse = CloudflareQueueSendResponse;
21
- export type QueueSendBatchOptions = CloudflareQueueSendBatchOptions;
22
- export type QueueSendBatchResponse = CloudflareQueueSendBatchResponse;
23
- export type QueueMetrics = CloudflareQueueMetrics;
24
- export type MessageSendRequest<Body> = CloudflareMessageSendRequest<Body>;
10
+ export type MessageSendRequest<Body> = globalThis.MessageSendRequest<Body>;
11
+ export type QueueMetrics = globalThis.QueueMetrics;
12
+ export type QueueSendBatchOptions = globalThis.QueueSendBatchOptions;
13
+ export type QueueSendBatchResponse = globalThis.QueueSendBatchResponse;
14
+ export type QueueSendOptions = globalThis.QueueSendOptions;
15
+ export type QueueSendResponse = globalThis.QueueSendResponse;
25
16
 
26
- export type QueueProducer<Body> = Pick<CloudflareQueue<Body>, "send"> &
27
- Partial<Pick<CloudflareQueue<Body>, "sendBatch" | "metrics">>;
17
+ export type QueueProducer<Body> = Pick<Queue<Body>, "send"> &
18
+ Partial<Pick<Queue<Body>, "sendBatch" | "metrics">>;
28
19
 
29
20
  const expectedQueueProducer = "Queue producer binding with send(); optional sendBatch()/metrics()";
30
21
 
package/src/R2.ts CHANGED
@@ -1,17 +1,3 @@
1
- import type {
2
- R2Bucket as CloudflareR2Bucket,
3
- R2Conditional as CloudflareR2Conditional,
4
- R2GetOptions as CloudflareR2GetOptions,
5
- R2ListOptions as CloudflareR2ListOptions,
6
- R2MultipartOptions as CloudflareR2MultipartOptions,
7
- R2MultipartUpload as CloudflareR2MultipartUpload,
8
- R2Object as CloudflareR2Object,
9
- R2ObjectBody as CloudflareR2ObjectBody,
10
- R2Objects as CloudflareR2Objects,
11
- R2PutOptions as CloudflareR2PutOptions,
12
- R2UploadPartOptions as CloudflareR2UploadPartOptions,
13
- R2UploadedPart as CloudflareR2UploadedPart,
14
- } from "@cloudflare/workers-types";
15
1
  import * as Context from "effect/Context";
16
2
  import * as Data from "effect/Data";
17
3
  import * as Effect from "effect/Effect";
@@ -60,19 +46,19 @@ export interface R2Definition {
60
46
  readonly binding: string;
61
47
  }
62
48
 
63
- export type R2GetOptions = CloudflareR2GetOptions;
64
- export type R2PutOptions = CloudflareR2PutOptions;
65
- export type R2ListOptions = CloudflareR2ListOptions;
66
- export type R2MultipartOptions = CloudflareR2MultipartOptions;
67
- export type R2UploadPartOptions = CloudflareR2UploadPartOptions;
49
+ export type R2GetOptions = globalThis.R2GetOptions;
50
+ export type R2ListOptions = globalThis.R2ListOptions;
51
+ export type R2MultipartOptions = globalThis.R2MultipartOptions;
52
+ export type R2PutOptions = globalThis.R2PutOptions;
53
+ export type R2UploadPartOptions = globalThis.R2UploadPartOptions;
68
54
  export type R2PutValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob;
69
55
  export type R2UploadPartValue = ReadableStream | ArrayBuffer | ArrayBufferView | string | Blob;
70
56
 
71
57
  export interface R2ObjectBodyClient extends Omit<
72
- CloudflareR2ObjectBody,
58
+ R2ObjectBody,
73
59
  "arrayBuffer" | "blob" | "bytes" | "json" | "text"
74
60
  > {
75
- readonly raw: CloudflareR2ObjectBody;
61
+ readonly raw: R2ObjectBody;
76
62
  readonly arrayBuffer: Effect.Effect<ArrayBuffer, R2OperationError>;
77
63
  readonly bytes: Effect.Effect<Uint8Array, R2OperationError>;
78
64
  readonly text: Effect.Effect<string, R2OperationError>;
@@ -81,29 +67,27 @@ export interface R2ObjectBodyClient extends Omit<
81
67
  }
82
68
 
83
69
  export interface R2MultipartUploadClient {
84
- readonly raw: CloudflareR2MultipartUpload;
70
+ readonly raw: R2MultipartUpload;
85
71
  readonly key: string;
86
72
  readonly uploadId: string;
87
73
  readonly uploadPart: (
88
74
  partNumber: number,
89
75
  value: R2UploadPartValue,
90
76
  options?: R2UploadPartOptions,
91
- ) => Effect.Effect<CloudflareR2UploadedPart, R2OperationError>;
77
+ ) => Effect.Effect<R2UploadedPart, R2OperationError>;
92
78
  readonly abort: Effect.Effect<void, R2OperationError>;
93
79
  readonly complete: (
94
- uploadedParts: ReadonlyArray<CloudflareR2UploadedPart>,
95
- ) => Effect.Effect<CloudflareR2Object, R2OperationError>;
80
+ uploadedParts: ReadonlyArray<R2UploadedPart>,
81
+ ) => Effect.Effect<R2Object, R2OperationError>;
96
82
  }
97
83
 
98
84
  export interface R2Client {
99
- readonly head: (
100
- key: string,
101
- ) => Effect.Effect<Option.Option<CloudflareR2Object>, R2OperationError>;
85
+ readonly head: (key: string) => Effect.Effect<Option.Option<R2Object>, R2OperationError>;
102
86
  readonly get: {
103
87
  (
104
88
  key: string,
105
- options: R2GetOptions & { readonly onlyIf: CloudflareR2Conditional | Headers },
106
- ): Effect.Effect<Option.Option<R2ObjectBodyClient | CloudflareR2Object>, R2OperationError>;
89
+ options: R2GetOptions & { readonly onlyIf: R2Conditional | Headers },
90
+ ): Effect.Effect<Option.Option<R2ObjectBodyClient | R2Object>, R2OperationError>;
107
91
  (
108
92
  key: string,
109
93
  options?: R2GetOptions,
@@ -113,13 +97,13 @@ export interface R2Client {
113
97
  (
114
98
  key: string,
115
99
  value: R2PutValue,
116
- options: R2PutOptions & { readonly onlyIf: CloudflareR2Conditional | Headers },
117
- ): Effect.Effect<Option.Option<CloudflareR2Object>, R2OperationError>;
100
+ options: R2PutOptions & { readonly onlyIf: R2Conditional | Headers },
101
+ ): Effect.Effect<Option.Option<R2Object>, R2OperationError>;
118
102
  (
119
103
  key: string,
120
104
  value: R2PutValue,
121
105
  options?: R2PutOptions,
122
- ): Effect.Effect<CloudflareR2Object, R2OperationError>;
106
+ ): Effect.Effect<R2Object, R2OperationError>;
123
107
  };
124
108
  readonly createMultipartUpload: (
125
109
  key: string,
@@ -130,8 +114,8 @@ export interface R2Client {
130
114
  uploadId: string,
131
115
  ) => Effect.Effect<R2MultipartUploadClient, R2OperationError>;
132
116
  readonly delete: (keys: string | ReadonlyArray<string>) => Effect.Effect<void, R2OperationError>;
133
- readonly list: (options?: R2ListOptions) => Effect.Effect<CloudflareR2Objects, R2OperationError>;
134
- readonly rawUnsafe: Effect.Effect<CloudflareR2Bucket>;
117
+ readonly list: (options?: R2ListOptions) => Effect.Effect<R2Objects, R2OperationError>;
118
+ readonly rawUnsafe: Effect.Effect<R2Bucket>;
135
119
  readonly definition: R2Definition;
136
120
  }
137
121
 
@@ -189,9 +173,7 @@ const spanOptions = (binding: string, operation: R2Operation) => ({
189
173
  attributes: { binding, operation },
190
174
  });
191
175
 
192
- const isR2ObjectBody = (
193
- value: CloudflareR2ObjectBody | CloudflareR2Object,
194
- ): value is CloudflareR2ObjectBody =>
176
+ const isR2ObjectBody = (value: R2ObjectBody | R2Object): value is R2ObjectBody =>
195
177
  "body" in value &&
196
178
  Predicate.isFunction(value.arrayBuffer) &&
197
179
  Predicate.isFunction(value.bytes) &&
@@ -199,7 +181,7 @@ const isR2ObjectBody = (
199
181
  Predicate.isFunction(value.json) &&
200
182
  Predicate.isFunction(value.blob);
201
183
 
202
- const wrapObjectBody = (binding: string, object: CloudflareR2ObjectBody): R2ObjectBodyClient => ({
184
+ const wrapObjectBody = (binding: string, object: R2ObjectBody): R2ObjectBodyClient => ({
203
185
  key: object.key,
204
186
  version: object.version,
205
187
  size: object.size,
@@ -238,8 +220,8 @@ const wrapObjectBody = (binding: string, object: CloudflareR2ObjectBody): R2Obje
238
220
 
239
221
  const wrapGetResult = (
240
222
  binding: string,
241
- object: CloudflareR2ObjectBody | CloudflareR2Object | null,
242
- ): R2ObjectBodyClient | CloudflareR2Object | null => {
223
+ object: R2ObjectBody | R2Object | null,
224
+ ): R2ObjectBodyClient | R2Object | null => {
243
225
  if (object === null || !isR2ObjectBody(object)) {
244
226
  return object;
245
227
  }
@@ -250,7 +232,7 @@ const wrapGetResult = (
250
232
  type R2BindingValue = Schema.Schema.Type<typeof Schema.Unknown>;
251
233
 
252
234
  const R2BucketSchema = Schema.declare(
253
- (value: R2BindingValue): value is CloudflareR2Bucket =>
235
+ (value: R2BindingValue): value is R2Bucket =>
254
236
  Predicate.hasProperty(value, "head") &&
255
237
  Predicate.isFunction(value.head) &&
256
238
  Predicate.hasProperty(value, "get") &&
@@ -268,13 +250,11 @@ const R2BucketSchema = Schema.declare(
268
250
  );
269
251
  const decodeR2Bucket = Schema.decodeUnknownOption(R2BucketSchema);
270
252
 
271
- export const isR2Bucket = (value: R2BindingValue): value is CloudflareR2Bucket =>
253
+ export const isR2Bucket = (value: R2BindingValue): value is R2Bucket =>
272
254
  Option.isSome(decodeR2Bucket(value));
273
255
 
274
- export const makeClient = (
275
- definition: R2Definition,
276
- ): ((bucket: CloudflareR2Bucket) => R2Client) => {
277
- const wrapUpload = (upload: CloudflareR2MultipartUpload): R2MultipartUploadClient => ({
256
+ export const makeClient = (definition: R2Definition): ((bucket: R2Bucket) => R2Client) => {
257
+ const wrapUpload = (upload: R2MultipartUpload): R2MultipartUploadClient => ({
278
258
  raw: upload,
279
259
  key: upload.key,
280
260
  uploadId: upload.uploadId,
@@ -295,7 +275,7 @@ export const makeClient = (
295
275
  complete: Effect.fn(
296
276
  "R2.completeMultipartUpload",
297
277
  spanOptions(definition.binding, "completeMultipartUpload"),
298
- )((uploadedParts: ReadonlyArray<CloudflareR2UploadedPart>) =>
278
+ )((uploadedParts: ReadonlyArray<R2UploadedPart>) =>
299
279
  tryR2Promise(definition.binding, "completeMultipartUpload", () =>
300
280
  upload.complete([...uploadedParts]),
301
281
  ),
@@ -332,7 +312,7 @@ export const makeClient = (
332
312
  tryR2Promise(definition.binding, "put", () => bucket.put(key, value, options)).pipe(
333
313
  Effect.map((object) => {
334
314
  if (object === null) {
335
- return Option.none<CloudflareR2Object>();
315
+ return Option.none<R2Object>();
336
316
  }
337
317
 
338
318
  if (options !== undefined && "onlyIf" in options) {
package/src/Vectorize.ts CHANGED
@@ -5,22 +5,6 @@ import * as Option from "effect/Option";
5
5
  import * as Predicate from "effect/Predicate";
6
6
  import * as Schema from "effect/Schema";
7
7
  import type { Layer } from "effect";
8
- import type {
9
- Vectorize as CloudflareVectorize,
10
- VectorizeAsyncMutation as CloudflareVectorizeAsyncMutation,
11
- VectorizeIndex as CloudflareVectorizeIndex,
12
- VectorizeIndexDetails as CloudflareVectorizeIndexDetails,
13
- VectorizeIndexInfo as CloudflareVectorizeIndexInfo,
14
- VectorizeMatch as CloudflareVectorizeMatch,
15
- VectorizeMatches as CloudflareVectorizeMatches,
16
- VectorizeQueryOptions as CloudflareVectorizeQueryOptions,
17
- VectorizeVector as CloudflareVectorizeVector,
18
- VectorizeVectorMetadata as CloudflareVectorizeVectorMetadata,
19
- VectorizeVectorMetadataFilter as CloudflareVectorizeVectorMetadataFilter,
20
- VectorizeVectorMetadataValue as CloudflareVectorizeVectorMetadataValue,
21
- VectorizeVectorMutation as CloudflareVectorizeVectorMutation,
22
- } from "@cloudflare/workers-types";
23
-
24
8
  import * as Binding from "./Binding";
25
9
  import type { WorkerEnvironment } from "./Environment";
26
10
  import * as ErrorMessage from "./internal/ErrorMessage";
@@ -53,19 +37,17 @@ export interface VectorizeDefinition {
53
37
  readonly binding: string;
54
38
  }
55
39
 
56
- export type VectorizeBinding = CloudflareVectorize | CloudflareVectorizeIndex;
57
- export type VectorizeVector = CloudflareVectorizeVector;
58
- export type VectorizeVectorMetadata = CloudflareVectorizeVectorMetadata;
59
- export type VectorizeVectorMetadataValue = CloudflareVectorizeVectorMetadataValue;
60
- export type VectorizeVectorMetadataFilter = CloudflareVectorizeVectorMetadataFilter;
61
- export type VectorizeQueryOptions = CloudflareVectorizeQueryOptions;
62
- export type VectorizeMatches = CloudflareVectorizeMatches;
63
- export type VectorizeMatch = CloudflareVectorizeMatch;
64
- export type VectorizeIndexInfo = CloudflareVectorizeIndexInfo;
65
- export type VectorizeIndexDetails = CloudflareVectorizeIndexDetails;
66
- export type VectorizeMutation =
67
- | CloudflareVectorizeAsyncMutation
68
- | CloudflareVectorizeVectorMutation;
40
+ export type VectorizeBinding = Vectorize | VectorizeIndex;
41
+ export type VectorizeIndexDetails = globalThis.VectorizeIndexDetails;
42
+ export type VectorizeIndexInfo = globalThis.VectorizeIndexInfo;
43
+ export type VectorizeMatch = globalThis.VectorizeMatch;
44
+ export type VectorizeMatches = globalThis.VectorizeMatches;
45
+ export type VectorizeQueryOptions = globalThis.VectorizeQueryOptions;
46
+ export type VectorizeVector = globalThis.VectorizeVector;
47
+ export type VectorizeVectorMetadata = globalThis.VectorizeVectorMetadata;
48
+ export type VectorizeVectorMetadataFilter = globalThis.VectorizeVectorMetadataFilter;
49
+ export type VectorizeVectorMetadataValue = globalThis.VectorizeVectorMetadataValue;
50
+ export type VectorizeMutation = VectorizeAsyncMutation | VectorizeVectorMutation;
69
51
  export type VectorizeValues = Float32Array | Float64Array | ReadonlyArray<number>;
70
52
 
71
53
  interface VectorizeRuntimeBinding {
@@ -29,7 +29,6 @@
29
29
  * {@link inboundTransport} decodes the HTTP/3-relevant request metadata that
30
30
  * the edge does provide.
31
31
  */
32
- import type { Request as CloudflareRequest } from "@cloudflare/workers-types";
33
32
  import * as Data from "effect/Data";
34
33
  import * as Effect from "effect/Effect";
35
34
  import * as Option from "effect/Option";
@@ -61,9 +60,8 @@ const decodeInboundTransport = S.decodeUnknownResult(InboundTransport);
61
60
  * dev` or when a Worker invokes another Worker directly) or does not match
62
61
  * the expected shape.
63
62
  */
64
- export const inboundTransport = (
65
- request: Pick<CloudflareRequest, "cf">,
66
- ): Option.Option<InboundTransport> => Result.getSuccess(decodeInboundTransport(request.cf));
63
+ export const inboundTransport = (request: Pick<Request, "cf">): Option.Option<InboundTransport> =>
64
+ Result.getSuccess(decodeInboundTransport(request.cf));
67
65
 
68
66
  export const isHttp3 = (transport: InboundTransport): boolean =>
69
67
  transport.clientQuicRtt !== undefined || transport.httpProtocol === "HTTP/3";
package/src/Worker.ts CHANGED
@@ -108,7 +108,7 @@ export const RunSymbol = Symbol.for("effect-cf/Worker/run");
108
108
  const FetchSymbol = Symbol.for("effect-cf/Worker/fetch");
109
109
 
110
110
  /** Metadata available before an event effect or its event layer starts. */
111
- export interface RunOptions {
111
+ export interface RunOptions extends Runtime.RunOptions {
112
112
  readonly event?: "fetch" | "rpc" | "queue";
113
113
  readonly rpc?: RpcInvocationInfo;
114
114
  }
@@ -438,6 +438,7 @@ export function make<
438
438
  effect as Effect.Effect<A, E, RuntimeContext<ROut> | Scope.Scope>,
439
439
  undefined,
440
440
  parentSpan,
441
+ runOptions.onFailure,
441
442
  );
442
443
  }
443
444
 
@@ -448,7 +449,7 @@ export function make<
448
449
  REvent,
449
450
  EventLayerError,
450
451
  LayerError
451
- >(this.runtime, effect, eventLayer, parentSpan);
452
+ >(this.runtime, effect, eventLayer, parentSpan, runOptions.onFailure);
452
453
  }
453
454
 
454
455
  fetch(request: Request): Promise<Response> {