effect-cf 0.46.0 → 0.47.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 +16 -0
- package/README.md +2 -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/DurableObjectRpcWebSocket.mjs +20 -7
- 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/RpcWebSocketClient.d.mts +30 -0
- package/dist/RpcWebSocketClient.mjs +19 -0
- package/dist/Vectorize.d.mts +17 -18
- package/dist/WebTransport.d.mts +0 -1
- package/dist/WebTransport.mjs +31 -0
- package/dist/WorkersAi.d.mts +0 -1
- package/dist/WorkflowBinding.d.mts +14 -15
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/package.json +6 -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/DurableObjectRpcWebSocket.ts +25 -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/RpcWebSocketClient.ts +45 -0
- package/src/Vectorize.ts +11 -29
- package/src/WebTransport.ts +2 -4
- package/src/WorkersAi.ts +2 -17
- package/src/WorkflowBinding.ts +14 -26
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -34,9 +34,10 @@ import { Hyperdrive_exports } from "./Hyperdrive.mjs";
|
|
|
34
34
|
import { Images_exports } from "./Images.mjs";
|
|
35
35
|
import { Kv_exports } from "./Kv.mjs";
|
|
36
36
|
import { R2_exports } from "./R2.mjs";
|
|
37
|
+
import { RpcWebSocketClient_exports } from "./RpcWebSocketClient.mjs";
|
|
37
38
|
import { Vectorize_exports } from "./Vectorize.mjs";
|
|
38
39
|
import { WebTransport_exports } from "./WebTransport.mjs";
|
|
39
40
|
import { WorkflowBinding_exports } from "./WorkflowBinding.mjs";
|
|
40
41
|
import { WorkflowDefinition_exports } from "./WorkflowDefinition.mjs";
|
|
41
42
|
import { Workflow_exports } from "./Workflow.mjs";
|
|
42
|
-
export { AiGateway_exports as AiGateway, AnalyticsEngine_exports as AnalyticsEngine, Artifacts_exports as Artifacts, Binding_exports as Binding, BrowserRendering_exports as BrowserRendering, Cache_exports as Cache, CloudflareOtlp_exports as CloudflareOtlp, CloudflareTracer_exports as CloudflareTracer, ContainerNamespace_exports as ContainerNamespace, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Email_exports as Email, Environment_exports as Environment, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, RpcTargets_exports as RpcTargets, RpcTracing_exports as RpcTracing, ServiceBinding_exports as ServiceBinding, Vectorize_exports as Vectorize, WebTransport_exports as WebTransport, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, WorkersAi_exports as WorkersAi, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
|
|
43
|
+
export { AiGateway_exports as AiGateway, AnalyticsEngine_exports as AnalyticsEngine, Artifacts_exports as Artifacts, Binding_exports as Binding, BrowserRendering_exports as BrowserRendering, Cache_exports as Cache, CloudflareOtlp_exports as CloudflareOtlp, CloudflareTracer_exports as CloudflareTracer, ContainerNamespace_exports as ContainerNamespace, D1_exports as D1, DurableObject_exports as DurableObject, DurableObjectAlarm_exports as DurableObjectAlarm, DurableObjectDefinition_exports as DurableObjectDefinition, DurableObjectNamespace_exports as DurableObjectNamespace, DurableObjectRpcWebSocket_exports as DurableObjectRpcWebSocket, DurableObjectSqlite_exports as DurableObjectSqlite, DurableObjectState_exports as DurableObjectState, DurableObjectStorage_exports as DurableObjectStorage, DurableObjectWebSocket_exports as DurableObjectWebSocket, Email_exports as Email, Environment_exports as Environment, Hyperdrive_exports as Hyperdrive, Images_exports as Images, Kv_exports as Kv, Queue_exports as Queue, QueueBinding_exports as QueueBinding, QueueDefinition_exports as QueueDefinition, R2_exports as R2, Rpc_exports as Rpc, RpcDefinition_exports as RpcDefinition, RpcTargets_exports as RpcTargets, RpcTracing_exports as RpcTracing, RpcWebSocketClient_exports as RpcWebSocketClient, ServiceBinding_exports as ServiceBinding, Vectorize_exports as Vectorize, WebTransport_exports as WebTransport, Worker_exports as Worker, WorkerConfig, WorkerDefinition_exports as WorkerDefinition, WorkerEnvironment, WorkersAi_exports as WorkersAi, Workflow_exports as Workflow, WorkflowBinding_exports as WorkflowBinding, WorkflowDefinition_exports as WorkflowDefinition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-cf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Effect-native primitives for Cloudflare Workers and bindings.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
"import": "./dist/Vitest.mjs",
|
|
58
58
|
"default": "./dist/Vitest.mjs"
|
|
59
59
|
},
|
|
60
|
+
"./rpc-websocket-client": {
|
|
61
|
+
"types": "./dist/RpcWebSocketClient.d.mts",
|
|
62
|
+
"import": "./dist/RpcWebSocketClient.mjs",
|
|
63
|
+
"default": "./dist/RpcWebSocketClient.mjs"
|
|
64
|
+
},
|
|
60
65
|
"./package.json": "./package.json"
|
|
61
66
|
},
|
|
62
67
|
"publishConfig": {
|
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 {
|
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 =
|
|
9
|
+
export type CacheRequest = RequestInfo | URL;
|
|
16
10
|
|
|
17
|
-
export type CacheQueryOptions =
|
|
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<
|
|
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<
|
|
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:
|
|
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:
|
|
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:
|
|
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));
|
|
@@ -148,6 +148,7 @@ interface LegacyAttachmentMetadata {
|
|
|
148
148
|
readonly version: 1;
|
|
149
149
|
readonly clientId: number;
|
|
150
150
|
readonly hasPendingRequests: boolean;
|
|
151
|
+
readonly serialization?: string | undefined;
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
interface PersistedPendingBatch {
|
|
@@ -170,6 +171,7 @@ interface ResumableAttachmentMetadata {
|
|
|
170
171
|
readonly hasPendingRequests: boolean;
|
|
171
172
|
readonly hasNonResumableRequests: boolean;
|
|
172
173
|
readonly subscriptions: ReadonlyArray<PersistedSubscription>;
|
|
174
|
+
readonly serialization?: string | undefined;
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
type AttachmentMetadata = LegacyAttachmentMetadata | ResumableAttachmentMetadata;
|
|
@@ -200,6 +202,7 @@ const ResumableAttachmentMetadataSchema = Schema.Struct({
|
|
|
200
202
|
hasPendingRequests: Schema.Boolean,
|
|
201
203
|
hasNonResumableRequests: Schema.Boolean,
|
|
202
204
|
subscriptions: Schema.Array(PersistedSubscriptionSchema),
|
|
205
|
+
serialization: Schema.optionalKey(Schema.String),
|
|
203
206
|
});
|
|
204
207
|
|
|
205
208
|
const decodeResumableAttachment = Schema.decodeUnknownOption(ResumableAttachmentMetadataSchema);
|
|
@@ -279,6 +282,7 @@ export const layer = (
|
|
|
279
282
|
version: legacyAttachmentVersion,
|
|
280
283
|
clientId: id,
|
|
281
284
|
hasPendingRequests: false,
|
|
285
|
+
serialization: serialization.contentType,
|
|
282
286
|
};
|
|
283
287
|
|
|
284
288
|
writeAttachment(socket.raw, attachmentKey, created);
|
|
@@ -392,6 +396,7 @@ export const layer = (
|
|
|
392
396
|
version: legacyAttachmentVersion,
|
|
393
397
|
clientId: connection.id,
|
|
394
398
|
hasPendingRequests: connection.requestIds.size > 0,
|
|
399
|
+
serialization: serialization.contentType,
|
|
395
400
|
});
|
|
396
401
|
|
|
397
402
|
return;
|
|
@@ -407,6 +412,7 @@ export const layer = (
|
|
|
407
412
|
hasPendingRequests: connection.requestIds.size > 0,
|
|
408
413
|
hasNonResumableRequests: connection.nonResumableRequestIds.size > 0,
|
|
409
414
|
subscriptions,
|
|
415
|
+
serialization: serialization.contentType,
|
|
410
416
|
});
|
|
411
417
|
},
|
|
412
418
|
catch: (cause) => new DurableWebSocketAttachmentError({ operation: "serialize", cause }),
|
|
@@ -589,6 +595,14 @@ export const layer = (
|
|
|
589
595
|
|
|
590
596
|
const metadata = attachment.metadata;
|
|
591
597
|
|
|
598
|
+
if (
|
|
599
|
+
metadata.serialization !== undefined &&
|
|
600
|
+
metadata.serialization !== serialization.contentType
|
|
601
|
+
) {
|
|
602
|
+
yield* resetSocket(socket);
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
|
|
592
606
|
if (metadata.version === legacyAttachmentVersion) {
|
|
593
607
|
if (metadata.hasPendingRequests) {
|
|
594
608
|
yield* resetSocket(socket);
|
|
@@ -1036,7 +1050,11 @@ export const layer = (
|
|
|
1036
1050
|
: send(connection, RpcMessage.ResponseDefectEncoded(encodeDefect(cause)));
|
|
1037
1051
|
}),
|
|
1038
1052
|
),
|
|
1039
|
-
close:
|
|
1053
|
+
close: (socket) =>
|
|
1054
|
+
Effect.gen(function* () {
|
|
1055
|
+
resetSockets.add(socket.raw);
|
|
1056
|
+
yield* socket.close(1000).pipe(Effect.ignore);
|
|
1057
|
+
}).pipe(Effect.ensuring(unregister(socket)), Effect.uninterruptible),
|
|
1040
1058
|
error: resetSocket,
|
|
1041
1059
|
checkpoint,
|
|
1042
1060
|
});
|
|
@@ -1102,13 +1120,17 @@ const readAttachment = (socket: WebSocket, key: string): AttachmentRead => {
|
|
|
1102
1120
|
const hasPendingRequests = Predicate.hasProperty(metadata, "hasPendingRequests")
|
|
1103
1121
|
? metadata.hasPendingRequests
|
|
1104
1122
|
: false;
|
|
1123
|
+
const serialization = Predicate.hasProperty(metadata, "serialization")
|
|
1124
|
+
? metadata.serialization
|
|
1125
|
+
: undefined;
|
|
1105
1126
|
|
|
1106
1127
|
if (
|
|
1107
1128
|
(!Predicate.hasProperty(metadata, "version") || metadata.version === legacyAttachmentVersion) &&
|
|
1108
1129
|
Predicate.hasProperty(metadata, "clientId") &&
|
|
1109
1130
|
Predicate.isNumber(metadata.clientId) &&
|
|
1110
1131
|
isClientId(metadata.clientId) &&
|
|
1111
|
-
Predicate.isBoolean(hasPendingRequests)
|
|
1132
|
+
Predicate.isBoolean(hasPendingRequests) &&
|
|
1133
|
+
(serialization === undefined || Predicate.isString(serialization))
|
|
1112
1134
|
) {
|
|
1113
1135
|
return {
|
|
1114
1136
|
_tag: "Valid",
|
|
@@ -1116,6 +1138,7 @@ const readAttachment = (socket: WebSocket, key: string): AttachmentRead => {
|
|
|
1116
1138
|
version: legacyAttachmentVersion,
|
|
1117
1139
|
clientId: metadata.clientId,
|
|
1118
1140
|
hasPendingRequests,
|
|
1141
|
+
serialization,
|
|
1119
1142
|
},
|
|
1120
1143
|
};
|
|
1121
1144
|
}
|
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 =
|
|
107
|
-
export type EmailAttachment =
|
|
108
|
-
export type
|
|
109
|
-
export type
|
|
110
|
-
export type EmailBinding =
|
|
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
|
|
59
|
-
export type
|
|
60
|
-
export type ImageDrawOptions =
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
63
|
-
export type
|
|
64
|
-
export type
|
|
65
|
-
export type
|
|
66
|
-
export type
|
|
67
|
-
export type
|
|
68
|
-
export type
|
|
69
|
-
export type
|
|
70
|
-
export type
|
|
71
|
-
export type
|
|
72
|
-
export type
|
|
73
|
-
export type
|
|
74
|
-
export type TextOptions =
|
|
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> |
|
|
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:
|
|
87
|
+
readonly raw: ImageTransformationResult;
|
|
111
88
|
readonly response: (
|
|
112
89
|
options?: ImageTransformationResponseOptions,
|
|
113
|
-
) => Effect.Effect<
|
|
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:
|
|
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<
|
|
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
|
-
|
|
153
|
-
|
|
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<
|
|
141
|
+
) => Effect.Effect<ImageTransformer, ImagesOperationError>;
|
|
168
142
|
readonly text: (
|
|
169
143
|
content: string,
|
|
170
144
|
options: TextOptions,
|
|
171
|
-
) => Effect.Effect<
|
|
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 &
|
|
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:
|
|
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:
|
|
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 =
|
|
35
|
-
export type KvListOptions<Metadata = unknown> =
|
|
30
|
+
export type KvPutOptions = KVNamespacePutOptions;
|
|
31
|
+
export type KvListOptions<Metadata = unknown> = KVNamespaceListOptions & {
|
|
36
32
|
readonly metadataSchema?: S.Codec<Metadata, unknown>;
|
|
37
33
|
};
|
|
38
34
|
|
package/src/QueueBinding.ts
CHANGED
|
@@ -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
|
|
20
|
-
export type
|
|
21
|
-
export type QueueSendBatchOptions =
|
|
22
|
-
export type QueueSendBatchResponse =
|
|
23
|
-
export type
|
|
24
|
-
export type
|
|
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<
|
|
27
|
-
Partial<Pick<
|
|
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
|
|