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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # effect-cf
2
2
 
3
+ ## 0.47.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#190](https://github.com/danieljvdm/effect-cf/pull/190) [`a3ae008`](https://github.com/danieljvdm/effect-cf/commit/a3ae008af959d08eec649042edc9309982354a0d) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Add `RpcWebSocketClient.layer` and the browser-safe `effect-cf/rpc-websocket-client` entrypoint. Provide a typed client service and its WebSocket connection for an application or session without requiring callers to wrap client construction in `Effect.scoped`. The layer closes the connection when its lifetime ends.
8
+
9
+ Persist the RPC serializer's content type in Durable Object WebSocket attachments and reset restored connections whose saved content type differs from the server's, preventing incompatible frames from reaching RPC handlers after a deployment. Existing attachments without serializer metadata remain supported.
10
+
11
+ Acknowledge WebSocket close events and ignore late messages on closed connections so client scope cleanup completes the close handshake.
12
+
13
+ ## 0.46.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#188](https://github.com/danieljvdm/effect-cf/pull/188) [`731938e`](https://github.com/danieljvdm/effect-cf/commit/731938ec635355c769f451b6153f8eb806ad98c1) Thanks [@limwa](https://github.com/limwa)! - Fix declaration portability by referencing consumer-provided Cloudflare Workers globals instead of importing `@cloudflare/workers-types`.
18
+
3
19
  ## 0.46.0
4
20
 
5
21
  ### Minor Changes
package/README.md CHANGED
@@ -10,6 +10,8 @@ The repository tests against workerd `1.20260825.1` and `@cloudflare/workers-typ
10
10
 
11
11
  See the [runtime performance guide](https://github.com/danieljvdm/effect-cf/blob/main/docs/runtime-performance.md) for measured alarm batching and telemetry configuration guidance.
12
12
 
13
+ For typed WebSocket RPC clients whose connection lifetime is owned by an Effect layer, see the [WebSocket RPC guide](https://github.com/danieljvdm/effect-cf/blob/main/docs/websocket-rpc.md).
14
+
13
15
  ## Worker
14
16
 
15
17
  ```ts
@@ -3,7 +3,6 @@ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
3
  import { WorkersAiBinding, isWorkersAiBinding } from "./WorkersAi.mjs";
4
4
  import * as Context$1 from "effect/Context";
5
5
  import * as Effect from "effect/Effect";
6
- import { AiGateway } from "@cloudflare/workers-types";
7
6
  import { Layer } from "effect";
8
7
  declare namespace AiGateway_d_exports {
9
8
  export { AiGatewayBinding, AiGatewayClient, AiGatewayDefinition, AiGatewayFetchOptions, AiGatewayHeaders, AiGatewayLog, AiGatewayOperationError, AiGatewayPatchLog, AiGatewayProvider, AiGatewayRunOptions, AiGatewayService, AiGatewayUniversalRequest, BindingNotFoundError, BindingValidationError, LayerOptions, Tag, TagClass, isAiGatewayBinding, layer, make, makeClient, makeClientFromAi, makeHttpClient };
@@ -30,7 +29,7 @@ type AiGatewayLog = Awaited<ReturnType<AiGatewayBinding["getLog"]>>;
30
29
  type AiGatewayProvider = NonNullable<Parameters<AiGatewayBinding["getUrl"]>[0]>;
31
30
  type AiGatewayUniversalRequest = Exclude<AiGatewayRunData, ReadonlyArray<unknown>>;
32
31
  type AiGatewayHeaders = NonNullable<AiGatewayUniversalRequest["headers"]>;
33
- type AiGatewayRunOptions = Parameters<AiGateway["run"]>[1];
32
+ type AiGatewayRunOptions = Parameters<AiGatewayBinding["run"]>[1];
34
33
  type AiGatewayBindingCandidate = Parameters<typeof isWorkersAiBinding>[0];
35
34
  interface AiGatewayFetchOptions {
36
35
  readonly provider?: AiGatewayProvider;
@@ -64,15 +63,15 @@ interface TagClass<Self, Id extends string> extends Context$1.ServiceClass<Self,
64
63
  declare const isAiGatewayBinding: (value: AiGatewayBindingCandidate) => value is WorkersAiBinding;
65
64
  declare const makeClient: (definition: AiGatewayDefinition, gateway: AiGatewayBinding) => {
66
65
  definition: AiGatewayDefinition;
67
- run: (data: import("@cloudflare/workers-types").AIGatewayUniversalRequest | readonly import("@cloudflare/workers-types").AIGatewayUniversalRequest[], options?: {
68
- gateway?: import("@cloudflare/workers-types").UniversalGatewayOptions;
66
+ run: (data: AIGatewayUniversalRequest | readonly AIGatewayUniversalRequest[], options?: {
67
+ gateway?: UniversalGatewayOptions;
69
68
  extraHeaders?: object;
70
- signal?: import("@cloudflare/workers-types").AbortSignal;
71
- } | undefined) => Effect.Effect<import("@cloudflare/workers-types").Response, AiGatewayOperationError, never>;
69
+ signal?: AbortSignal;
70
+ } | undefined) => Effect.Effect<Response, AiGatewayOperationError, never>;
72
71
  getUrl: (provider?: string | undefined) => Effect.Effect<string, AiGatewayOperationError, never>;
73
72
  fetch: (options: AiGatewayFetchOptions) => Effect.Effect<Response, AiGatewayOperationError, never>;
74
- patchLog: (logId: string, data: import("@cloudflare/workers-types").AiGatewayPatchLog) => Effect.Effect<void, AiGatewayOperationError, never>;
75
- getLog: (logId: string) => Effect.Effect<import("@cloudflare/workers-types").AiGatewayLog, AiGatewayOperationError, never>;
73
+ patchLog: (logId: string, data: globalThis.AiGatewayPatchLog) => Effect.Effect<void, AiGatewayOperationError, never>;
74
+ getLog: (logId: string) => Effect.Effect<globalThis.AiGatewayLog, AiGatewayOperationError, never>;
76
75
  rawUnsafe: Effect.Effect<AiGateway, never, never>;
77
76
  };
78
77
  declare const makeClientFromAi: (definition: AiGatewayDefinition, ai: WorkersAiBinding) => AiGatewayClient;
@@ -7,11 +7,10 @@ import * as Layer$1 from "effect/Layer";
7
7
  import * as Config$1 from "effect/Config";
8
8
  import * as Option from "effect/Option";
9
9
  import * as HttpClient from "effect/unstable/http/HttpClient";
10
- import { AnalyticsEngineDataPoint, AnalyticsEngineDataset } from "@cloudflare/workers-types";
11
10
  import { Redacted } from "effect";
12
11
  import { Headers, HttpClientResponse } from "effect/unstable/http";
13
12
  declare namespace AnalyticsEngine_d_exports {
14
- export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint$1 as AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, BindingNotFoundError, BindingValidationError, LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag, TagClass, isAnalyticsEngineDataset, layer, layerFetch, layerFetchConfig, make, makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
13
+ export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, BindingNotFoundError, BindingValidationError, LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag, TagClass, isAnalyticsEngineDataset, layer, layerFetch, layerFetchConfig, make, makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
15
14
  }
16
15
  declare const writeLimits: {
17
16
  readonly maxBlobs: 20;
@@ -74,7 +73,7 @@ interface AnalyticsEngineDefinition {
74
73
  readonly binding: string;
75
74
  }
76
75
  type AnalyticsEngineBinding = AnalyticsEngineDataset;
77
- type AnalyticsEngineDataPoint$1 = AnalyticsEngineDataPoint;
76
+ type AnalyticsEngineDataPoint = globalThis.AnalyticsEngineDataPoint;
78
77
  type AnalyticsEngineFieldValue = ArrayBuffer | string | null;
79
78
  type AnalyticsEngineWriteError = AnalyticsEngineOperationError | AnalyticsEngineWriteValidationError;
80
79
  type AnalyticsEngineInvalidWritePolicy = "error" | "drop";
@@ -104,8 +103,8 @@ interface AnalyticsEngineQueryOptions {
104
103
  readonly headers?: Headers.Input;
105
104
  }
106
105
  interface AnalyticsEngineClient {
107
- readonly writeDataPoint: (dataPoint?: AnalyticsEngineDataPoint$1, options?: AnalyticsEngineWriteOptions) => Effect.Effect<void, AnalyticsEngineWriteError>;
108
- readonly writeDataPoints: (dataPoints: ReadonlyArray<AnalyticsEngineDataPoint$1>, options?: AnalyticsEngineWriteOptions) => Effect.Effect<void, AnalyticsEngineWriteError>;
106
+ readonly writeDataPoint: (dataPoint?: AnalyticsEngineDataPoint, options?: AnalyticsEngineWriteOptions) => Effect.Effect<void, AnalyticsEngineWriteError>;
107
+ readonly writeDataPoints: (dataPoints: ReadonlyArray<AnalyticsEngineDataPoint>, options?: AnalyticsEngineWriteOptions) => Effect.Effect<void, AnalyticsEngineWriteError>;
109
108
  readonly rawUnsafe: Effect.Effect<AnalyticsEngineBinding>;
110
109
  readonly definition: AnalyticsEngineDefinition;
111
110
  }
@@ -168,4 +167,4 @@ declare const makeQuery: <Id extends string>(id: Id) => QueryTagClass<AnalyticsE
168
167
  declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
169
168
  declare const QueryTag: <Self>() => <Id extends string>(id: Id) => QueryTagClass<Self, Id>;
170
169
  //#endregion
171
- export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint$1 as AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, AnalyticsEngine_d_exports, type BindingNotFoundError, type BindingValidationError, LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag, TagClass, isAnalyticsEngineDataset, layer, layerFetch, layerFetchConfig, make, makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
170
+ export { AnalyticsEngineBinding, AnalyticsEngineClient, AnalyticsEngineDataPoint, AnalyticsEngineDataPointSchema, AnalyticsEngineDefinition, AnalyticsEngineFieldValue, AnalyticsEngineFieldValueSchema, AnalyticsEngineInvalidWritePolicy, AnalyticsEngineOperationError, AnalyticsEngineQueryClient, AnalyticsEngineQueryColumn, AnalyticsEngineQueryDefinition, AnalyticsEngineQueryError, AnalyticsEngineQueryOptions, AnalyticsEngineQueryResult, AnalyticsEngineQueryRow, AnalyticsEngineQueryService, AnalyticsEngineService, AnalyticsEngineWriteError, AnalyticsEngineWriteOptions, AnalyticsEngineWritePolicy, AnalyticsEngineWriteValidationError, AnalyticsEngineWriteViolation, AnalyticsEngine_d_exports, type BindingNotFoundError, type BindingValidationError, LayerOptions, QueryConfigOptions, QueryTag, QueryTagClass, Tag, TagClass, isAnalyticsEngineDataset, layer, layerFetch, layerFetchConfig, make, makeClient, makeQuery, makeQueryClient, queryConfig, queryLayer, queryLayerConfig, writeLimits };
@@ -2,10 +2,9 @@ import { WorkerEnvironment } from "./Environment.mjs";
2
2
  import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
3
  import * as Context$1 from "effect/Context";
4
4
  import * as Effect from "effect/Effect";
5
- import { ArtifactsCreateRepoResult, ArtifactsCreateTokenResult, ArtifactsErrorCode, ArtifactsRepoInfo, ArtifactsTokenInfo, ArtifactsTokenListResult } from "@cloudflare/workers-types";
6
5
  import { Layer } from "effect";
7
6
  declare namespace Artifacts_d_exports {
8
- export { ArtifactsBinding, ArtifactsClient, ArtifactsCommit, ArtifactsCommitIdentity, ArtifactsCreateOptions, ArtifactsCreateRepoResult$1 as ArtifactsCreateRepoResult, ArtifactsCreateTokenResult$1 as ArtifactsCreateTokenResult, ArtifactsDefinition, ArtifactsErrorCode$1 as ArtifactsErrorCode, ArtifactsForkOptions, ArtifactsImportParams, ArtifactsImportSource, ArtifactsImportTarget, ArtifactsImportTargetOptions, ArtifactsListOptions, ArtifactsLogOptions, ArtifactsLogResult, ArtifactsOperation, ArtifactsOperationError, ArtifactsRepoBinding, ArtifactsRepoClient, ArtifactsRepoInfo$1 as ArtifactsRepoInfo, ArtifactsRepoListEntry, ArtifactsRepoListResult, ArtifactsRepoStatus, ArtifactsService, ArtifactsTokenInfo$1 as ArtifactsTokenInfo, ArtifactsTokenListResult$1 as ArtifactsTokenListResult, ArtifactsTokenScope, ArtifactsTokenState, ArtifactsTree, BindingNotFoundError, BindingValidationError, Cursor, LayerOptions, RepoName, Tag, TagClass, artifactsErrorCodes, artifactsErrorNumericCodes, isArtifactsBinding, isArtifactsRepoBinding, layer, make, makeClient };
7
+ export { ArtifactsBinding, ArtifactsClient, ArtifactsCommit, ArtifactsCommitIdentity, ArtifactsCreateOptions, ArtifactsCreateRepoResult, ArtifactsCreateTokenResult, ArtifactsDefinition, ArtifactsErrorCode, ArtifactsForkOptions, ArtifactsImportParams, ArtifactsImportSource, ArtifactsImportTarget, ArtifactsImportTargetOptions, ArtifactsListOptions, ArtifactsLogOptions, ArtifactsLogResult, ArtifactsOperation, ArtifactsOperationError, ArtifactsRepoBinding, ArtifactsRepoClient, ArtifactsRepoInfo, ArtifactsRepoListEntry, ArtifactsRepoListResult, ArtifactsRepoStatus, ArtifactsService, ArtifactsTokenInfo, ArtifactsTokenListResult, ArtifactsTokenScope, ArtifactsTokenState, ArtifactsTree, BindingNotFoundError, BindingValidationError, Cursor, LayerOptions, RepoName, Tag, TagClass, artifactsErrorCodes, artifactsErrorNumericCodes, isArtifactsBinding, isArtifactsRepoBinding, layer, make, makeClient };
9
8
  }
10
9
  type ArtifactsOperation = "createClient" | "create" | "get" | "import" | "list" | "delete" | "createToken" | "listTokens" | "getToken" | "revokeToken" | "fork" | "info" | "log" | "readCommit" | "readTree" | "cli";
11
10
  declare const artifactsErrorCodes: readonly ["ALREADY_EXISTS", "NOT_FOUND", "IMPORT_IN_PROGRESS", "FORK_IN_PROGRESS", "INVALID_INPUT", "INVALID_REPO_NAME", "INVALID_TTL", "INVALID_URL", "REMOTE_AUTH_REQUIRED", "UPSTREAM_UNAVAILABLE", "MEMORY_LIMIT", "INTERNAL_ERROR"];
@@ -23,7 +22,7 @@ declare const artifactsErrorNumericCodes: {
23
22
  readonly MEMORY_LIMIT: 10402;
24
23
  readonly INTERNAL_ERROR: 10400;
25
24
  };
26
- type ArtifactsErrorCode$1 = ArtifactsErrorCode;
25
+ type ArtifactsErrorCode = globalThis.ArtifactsErrorCode;
27
26
  declare const ArtifactsOperationError_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 & {
28
27
  readonly _tag: "ArtifactsOperationError";
29
28
  } & Readonly<A>;
@@ -31,7 +30,7 @@ declare class ArtifactsOperationError extends ArtifactsOperationError_base<{
31
30
  readonly binding: string;
32
31
  readonly operation: ArtifactsOperation;
33
32
  readonly cause: unknown;
34
- readonly code?: ArtifactsErrorCode$1 | (string & {});
33
+ readonly code?: ArtifactsErrorCode | (string & {});
35
34
  readonly numericCode?: number;
36
35
  }> {
37
36
  get message(): string;
@@ -46,9 +45,9 @@ type ArtifactsTokenScope = "read" | "write";
46
45
  /** Lifecycle state of a repository token. */
47
46
  type ArtifactsTokenState = "active" | "expired" | "revoked";
48
47
  type ArtifactsRepoStatus = "ready" | "importing" | "forking";
49
- type ArtifactsRepoInfo$1 = ArtifactsRepoInfo;
50
- type ArtifactsCreateRepoResult$1 = Readonly<ArtifactsCreateRepoResult>;
51
- interface ArtifactsRepoListEntry extends ArtifactsRepoInfo$1 {
48
+ type ArtifactsRepoInfo = globalThis.ArtifactsRepoInfo;
49
+ type ArtifactsCreateRepoResult = Readonly<globalThis.ArtifactsCreateRepoResult>;
50
+ interface ArtifactsRepoListEntry extends ArtifactsRepoInfo {
52
51
  readonly status: ArtifactsRepoStatus;
53
52
  }
54
53
  interface ArtifactsRepoListResult {
@@ -57,11 +56,11 @@ interface ArtifactsRepoListResult {
57
56
  readonly cursor?: Cursor;
58
57
  }
59
58
  /** Result of creating a repository token. */
60
- type ArtifactsCreateTokenResult$1 = ArtifactsCreateTokenResult;
59
+ type ArtifactsCreateTokenResult = globalThis.ArtifactsCreateTokenResult;
61
60
  /** Repository token metadata, excluding its plaintext secret. */
62
- type ArtifactsTokenInfo$1 = ArtifactsTokenInfo;
61
+ type ArtifactsTokenInfo = globalThis.ArtifactsTokenInfo;
63
62
  /** Repository token list result. */
64
- type ArtifactsTokenListResult$1 = ArtifactsTokenListResult;
63
+ type ArtifactsTokenListResult = globalThis.ArtifactsTokenListResult;
65
64
  /** Identity recorded for a Git commit author or committer. */
66
65
  interface ArtifactsCommitIdentity {
67
66
  readonly name: string;
@@ -126,7 +125,7 @@ interface ArtifactsLogOptions {
126
125
  readonly limit?: number;
127
126
  readonly offset?: number;
128
127
  }
129
- interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo$1> {
128
+ interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
130
129
  /**
131
130
  * Read repository metadata.
132
131
  *
@@ -134,49 +133,49 @@ interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo$1> {
134
133
  * through this method. It is optional solely for compatibility with older
135
134
  * local handles that expose metadata as data properties.
136
135
  */
137
- readonly info?: () => Promise<ArtifactsRepoInfo$1>;
136
+ readonly info?: () => Promise<ArtifactsRepoInfo>;
138
137
  /**
139
138
  * Create a Git token for the repository.
140
139
  *
141
140
  * Scope defaults to `"write"`. TTL is measured in seconds, defaults to
142
141
  * 86,400, and must be between 60 and 31,536,000.
143
142
  */
144
- readonly createToken: (scope?: ArtifactsTokenScope, ttl?: number) => Promise<ArtifactsCreateTokenResult$1>;
145
- readonly listTokens: () => Promise<ArtifactsTokenListResult$1>;
143
+ readonly createToken: (scope?: ArtifactsTokenScope, ttl?: number) => Promise<ArtifactsCreateTokenResult>;
144
+ readonly listTokens: () => Promise<ArtifactsTokenListResult>;
146
145
  readonly revokeToken: (tokenOrId: string) => Promise<boolean>;
147
- readonly fork: (name: RepoName, options?: ArtifactsForkOptions) => Promise<ArtifactsCreateRepoResult$1>;
146
+ readonly fork: (name: RepoName, options?: ArtifactsForkOptions) => Promise<ArtifactsCreateRepoResult>;
148
147
  readonly log: (options?: ArtifactsLogOptions) => Promise<ArtifactsLogResult>;
149
148
  readonly readCommit: (hash: string) => Promise<ArtifactsCommit>;
150
149
  readonly readTree: (hash: string) => Promise<ArtifactsTree>;
151
150
  }
152
151
  interface ArtifactsBinding {
153
- readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Promise<ArtifactsCreateRepoResult$1>;
152
+ readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Promise<ArtifactsCreateRepoResult>;
154
153
  readonly get: (name: RepoName) => Promise<ArtifactsRepoBinding>;
155
- readonly import: (params: ArtifactsImportParams) => Promise<ArtifactsCreateRepoResult$1>;
154
+ readonly import: (params: ArtifactsImportParams) => Promise<ArtifactsCreateRepoResult>;
156
155
  readonly list: (options?: ArtifactsListOptions) => Promise<ArtifactsRepoListResult>;
157
156
  readonly delete: (name: RepoName) => Promise<boolean>;
158
157
  }
159
- interface ArtifactsRepoClient extends ArtifactsRepoInfo$1 {
160
- readonly info: () => Effect.Effect<ArtifactsRepoInfo$1, ArtifactsOperationError>;
158
+ interface ArtifactsRepoClient extends ArtifactsRepoInfo {
159
+ readonly info: () => Effect.Effect<ArtifactsRepoInfo, ArtifactsOperationError>;
161
160
  /**
162
161
  * Create a Git token for the repository.
163
162
  *
164
163
  * Scope defaults to `"write"`. TTL is measured in seconds, defaults to
165
164
  * 86,400, and must be between 60 and 31,536,000.
166
165
  */
167
- readonly createToken: (scope?: ArtifactsTokenScope, ttl?: number) => Effect.Effect<ArtifactsCreateTokenResult$1, ArtifactsOperationError>;
168
- readonly listTokens: Effect.Effect<ArtifactsTokenListResult$1, ArtifactsOperationError>;
166
+ readonly createToken: (scope?: ArtifactsTokenScope, ttl?: number) => Effect.Effect<ArtifactsCreateTokenResult, ArtifactsOperationError>;
167
+ readonly listTokens: Effect.Effect<ArtifactsTokenListResult, ArtifactsOperationError>;
169
168
  readonly revokeToken: (tokenOrId: string) => Effect.Effect<boolean, ArtifactsOperationError>;
170
- readonly fork: (name: RepoName, options?: ArtifactsForkOptions) => Effect.Effect<ArtifactsCreateRepoResult$1, ArtifactsOperationError>;
169
+ readonly fork: (name: RepoName, options?: ArtifactsForkOptions) => Effect.Effect<ArtifactsCreateRepoResult, ArtifactsOperationError>;
171
170
  readonly log: (options?: ArtifactsLogOptions) => Effect.Effect<ArtifactsLogResult, ArtifactsOperationError>;
172
171
  readonly readCommit: (hash: string) => Effect.Effect<ArtifactsCommit, ArtifactsOperationError>;
173
172
  readonly readTree: (hash: string) => Effect.Effect<ArtifactsTree, ArtifactsOperationError>;
174
173
  readonly raw: ArtifactsRepoBinding;
175
174
  }
176
175
  interface ArtifactsClient {
177
- readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Effect.Effect<ArtifactsCreateRepoResult$1, ArtifactsOperationError>;
176
+ readonly create: (name: RepoName, options?: ArtifactsCreateOptions) => Effect.Effect<ArtifactsCreateRepoResult, ArtifactsOperationError>;
178
177
  readonly get: (name: RepoName) => Effect.Effect<ArtifactsRepoClient, ArtifactsOperationError>;
179
- readonly import: (params: ArtifactsImportParams) => Effect.Effect<ArtifactsCreateRepoResult$1, ArtifactsOperationError>;
178
+ readonly import: (params: ArtifactsImportParams) => Effect.Effect<ArtifactsCreateRepoResult, ArtifactsOperationError>;
180
179
  readonly list: (options?: ArtifactsListOptions) => Effect.Effect<ArtifactsRepoListResult, ArtifactsOperationError>;
181
180
  readonly delete: (name: RepoName) => Effect.Effect<boolean, ArtifactsOperationError>;
182
181
  readonly rawUnsafe: Effect.Effect<ArtifactsBinding>;
@@ -202,4 +201,4 @@ declare const layer: <Self>(tag: Context$1.Service<Self, ArtifactsClient>, defin
202
201
  declare const make: <Id extends string>(id: Id) => TagClass<ArtifactsService<Id>, Id>;
203
202
  declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
204
203
  //#endregion
205
- export { ArtifactsBinding, ArtifactsClient, ArtifactsCommit, ArtifactsCommitIdentity, ArtifactsCreateOptions, ArtifactsCreateRepoResult$1 as ArtifactsCreateRepoResult, ArtifactsCreateTokenResult$1 as ArtifactsCreateTokenResult, ArtifactsDefinition, ArtifactsErrorCode$1 as ArtifactsErrorCode, ArtifactsForkOptions, ArtifactsImportParams, ArtifactsImportSource, ArtifactsImportTarget, ArtifactsImportTargetOptions, ArtifactsListOptions, ArtifactsLogOptions, ArtifactsLogResult, ArtifactsOperation, ArtifactsOperationError, ArtifactsRepoBinding, ArtifactsRepoClient, ArtifactsRepoInfo$1 as ArtifactsRepoInfo, ArtifactsRepoListEntry, ArtifactsRepoListResult, ArtifactsRepoStatus, ArtifactsService, ArtifactsTokenInfo$1 as ArtifactsTokenInfo, ArtifactsTokenListResult$1 as ArtifactsTokenListResult, ArtifactsTokenScope, ArtifactsTokenState, ArtifactsTree, Artifacts_d_exports, type BindingNotFoundError, type BindingValidationError, Cursor, LayerOptions, RepoName, Tag, TagClass, artifactsErrorCodes, artifactsErrorNumericCodes, isArtifactsBinding, isArtifactsRepoBinding, layer, make, makeClient };
204
+ export { ArtifactsBinding, ArtifactsClient, ArtifactsCommit, ArtifactsCommitIdentity, ArtifactsCreateOptions, ArtifactsCreateRepoResult, ArtifactsCreateTokenResult, ArtifactsDefinition, ArtifactsErrorCode, ArtifactsForkOptions, ArtifactsImportParams, ArtifactsImportSource, ArtifactsImportTarget, ArtifactsImportTargetOptions, ArtifactsListOptions, ArtifactsLogOptions, ArtifactsLogResult, ArtifactsOperation, ArtifactsOperationError, ArtifactsRepoBinding, ArtifactsRepoClient, ArtifactsRepoInfo, ArtifactsRepoListEntry, ArtifactsRepoListResult, ArtifactsRepoStatus, ArtifactsService, ArtifactsTokenInfo, ArtifactsTokenListResult, ArtifactsTokenScope, ArtifactsTokenState, ArtifactsTree, Artifacts_d_exports, type BindingNotFoundError, type BindingValidationError, Cursor, LayerOptions, RepoName, Tag, TagClass, artifactsErrorCodes, artifactsErrorNumericCodes, isArtifactsBinding, isArtifactsRepoBinding, layer, make, makeClient };
package/dist/Cache.d.mts CHANGED
@@ -2,12 +2,11 @@ import * as Context from "effect/Context";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import * as Option from "effect/Option";
5
- import { Cache, CacheQueryOptions, CacheStorage, RequestInfo } from "@cloudflare/workers-types";
6
5
  declare namespace Cache_d_exports {
7
- export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions$1 as CacheQueryOptions, CacheRequest, CacheStorage$1 as CacheStorage, CacheStorageClient, layer, layerFrom, makeCacheClient, makeClient };
6
+ export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions, CacheRequest, CacheStorage, CacheStorageClient, layer, layerFrom, makeCacheClient, makeClient };
8
7
  }
9
8
  type CacheRequest = RequestInfo | URL;
10
- type CacheQueryOptions$1 = CacheQueryOptions;
9
+ type CacheQueryOptions = globalThis.CacheQueryOptions;
11
10
  type CacheOperation = "open" | "match" | "put" | "delete";
12
11
  declare const CacheOperationError_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 & {
13
12
  readonly _tag: "CacheOperationError";
@@ -21,21 +20,21 @@ declare class CacheOperationError extends CacheOperationError_base<{
21
20
  }
22
21
  interface CacheClient {
23
22
  readonly name: string;
24
- readonly match: (request: CacheRequest, options?: CacheQueryOptions$1) => Effect.Effect<Option.Option<Response>, CacheOperationError>;
23
+ readonly match: (request: CacheRequest, options?: CacheQueryOptions) => Effect.Effect<Option.Option<Response>, CacheOperationError>;
25
24
  readonly put: (request: CacheRequest, response: Response) => Effect.Effect<void, CacheOperationError>;
26
- readonly delete: (request: CacheRequest, options?: CacheQueryOptions$1) => Effect.Effect<boolean, CacheOperationError>;
25
+ readonly delete: (request: CacheRequest, options?: CacheQueryOptions) => Effect.Effect<boolean, CacheOperationError>;
27
26
  readonly rawUnsafe: Effect.Effect<Cache>;
28
27
  }
29
28
  interface CacheStorageClient {
30
29
  readonly default: CacheClient;
31
30
  readonly open: (name: string) => Effect.Effect<CacheClient, CacheOperationError>;
32
- readonly rawUnsafe: Effect.Effect<CacheStorage>;
31
+ readonly rawUnsafe: Effect.Effect<globalThis.CacheStorage>;
33
32
  }
34
- declare const CacheStorage_base: Context.ServiceClass<CacheStorage$1, "effect-cf/CacheStorage", CacheStorageClient>;
35
- declare class CacheStorage$1 extends CacheStorage_base {}
33
+ declare const CacheStorage_base: Context.ServiceClass<CacheStorage, "effect-cf/CacheStorage", CacheStorageClient>;
34
+ declare class CacheStorage extends CacheStorage_base {}
36
35
  declare const makeCacheClient: (cache: Cache, name?: string) => CacheClient;
37
- declare const makeClient: (storage: CacheStorage) => CacheStorageClient;
38
- declare const layerFrom: (storage: CacheStorage) => Layer.Layer<CacheStorage$1>;
39
- declare const layer: Layer.Layer<CacheStorage$1>;
36
+ declare const makeClient: (storage: globalThis.CacheStorage) => CacheStorageClient;
37
+ declare const layerFrom: (storage: globalThis.CacheStorage) => Layer.Layer<CacheStorage>;
38
+ declare const layer: Layer.Layer<CacheStorage>;
40
39
  //#endregion
41
- export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions$1 as CacheQueryOptions, CacheRequest, CacheStorage$1 as CacheStorage, CacheStorageClient, Cache_d_exports, layer, layerFrom, makeCacheClient, makeClient };
40
+ export { CacheClient, CacheOperation, CacheOperationError, CacheQueryOptions, CacheRequest, CacheStorage, CacheStorageClient, Cache_d_exports, layer, layerFrom, makeCacheClient, makeClient };
@@ -40,7 +40,8 @@ const ResumableAttachmentMetadataSchema = Schema.Struct({
40
40
  clientId: Schema.Finite,
41
41
  hasPendingRequests: Schema.Boolean,
42
42
  hasNonResumableRequests: Schema.Boolean,
43
- subscriptions: Schema.Array(PersistedSubscriptionSchema)
43
+ subscriptions: Schema.Array(PersistedSubscriptionSchema),
44
+ serialization: Schema.optionalKey(Schema.String)
44
45
  });
45
46
  const decodeResumableAttachment = Schema.decodeUnknownOption(ResumableAttachmentMetadataSchema);
46
47
  var DurableObjectRpcWebSocket = class extends Context.Service()("effect-cf/DurableObjectRpcWebSocket") {};
@@ -83,7 +84,8 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
83
84
  const created = {
84
85
  version: legacyAttachmentVersion,
85
86
  clientId: id,
86
- hasPendingRequests: false
87
+ hasPendingRequests: false,
88
+ serialization: serialization.contentType
87
89
  };
88
90
  writeAttachment(socket.raw, attachmentKey, created);
89
91
  return created;
@@ -143,7 +145,8 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
143
145
  writeAttachment(connection.socket.raw, attachmentKey, {
144
146
  version: legacyAttachmentVersion,
145
147
  clientId: connection.id,
146
- hasPendingRequests: connection.requestIds.size > 0
148
+ hasPendingRequests: connection.requestIds.size > 0,
149
+ serialization: serialization.contentType
147
150
  });
148
151
  return;
149
152
  }
@@ -153,7 +156,8 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
153
156
  clientId: connection.id,
154
157
  hasPendingRequests: connection.requestIds.size > 0,
155
158
  hasNonResumableRequests: connection.nonResumableRequestIds.size > 0,
156
- subscriptions
159
+ subscriptions,
160
+ serialization: serialization.contentType
157
161
  });
158
162
  },
159
163
  catch: (cause) => new DurableWebSocketAttachmentError({
@@ -249,6 +253,10 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
249
253
  continue;
250
254
  }
251
255
  const metadata = attachment.metadata;
256
+ if (metadata.serialization !== void 0 && metadata.serialization !== serialization.contentType) {
257
+ yield* resetSocket(socket);
258
+ continue;
259
+ }
252
260
  if (metadata.version === legacyAttachmentVersion) {
253
261
  if (metadata.hasPendingRequests) yield* resetSocket(socket);
254
262
  else if (connectionsById.has(metadata.clientId)) yield* resetSocket(socket);
@@ -476,7 +484,10 @@ const layer = (options = {}) => Layer.effectContext(Effect.gen(function* () {
476
484
  const connection = register(socket);
477
485
  return Predicate.isTagged(cause, "MaxBufferSizeExceeded") ? Effect.ignore(connection.socket.close(1009, String(cause))) : send(connection, RpcMessage.ResponseDefectEncoded(encodeDefect(cause)));
478
486
  })),
479
- close: unregister,
487
+ close: (socket) => Effect.gen(function* () {
488
+ resetSockets.add(socket.raw);
489
+ yield* socket.close(1e3).pipe(Effect.ignore);
490
+ }).pipe(Effect.ensuring(unregister(socket)), Effect.uninterruptible),
480
491
  error: resetSocket,
481
492
  checkpoint
482
493
  });
@@ -506,12 +517,14 @@ const readAttachment = (socket, key) => {
506
517
  } : { _tag: "Invalid" };
507
518
  }
508
519
  const hasPendingRequests = Predicate.hasProperty(metadata, "hasPendingRequests") ? metadata.hasPendingRequests : false;
509
- if ((!Predicate.hasProperty(metadata, "version") || metadata.version === legacyAttachmentVersion) && Predicate.hasProperty(metadata, "clientId") && Predicate.isNumber(metadata.clientId) && isClientId(metadata.clientId) && Predicate.isBoolean(hasPendingRequests)) return {
520
+ const serialization = Predicate.hasProperty(metadata, "serialization") ? metadata.serialization : void 0;
521
+ if ((!Predicate.hasProperty(metadata, "version") || metadata.version === legacyAttachmentVersion) && Predicate.hasProperty(metadata, "clientId") && Predicate.isNumber(metadata.clientId) && isClientId(metadata.clientId) && Predicate.isBoolean(hasPendingRequests) && (serialization === void 0 || Predicate.isString(serialization))) return {
510
522
  _tag: "Valid",
511
523
  metadata: {
512
524
  version: legacyAttachmentVersion,
513
525
  clientId: metadata.clientId,
514
- hasPendingRequests
526
+ hasPendingRequests,
527
+ serialization
515
528
  }
516
529
  };
517
530
  return { _tag: "Invalid" };
package/dist/Email.d.mts CHANGED
@@ -2,10 +2,9 @@ import { WorkerEnvironment } from "./Environment.mjs";
2
2
  import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
3
  import * as Context$1 from "effect/Context";
4
4
  import * as Effect from "effect/Effect";
5
- import { EmailAddress, EmailAttachment, EmailSendResult, SendEmail } from "@cloudflare/workers-types";
6
5
  import { Layer } from "effect";
7
6
  declare namespace Email_d_exports {
8
- export { BindingNotFoundError, BindingValidationError, EmailAddress$1 as EmailAddress, EmailAttachment$1 as EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult$1 as EmailSendResult, EmailService, EmailValidationError, EmailViolation, LayerOptions, Tag, TagClass, emailErrorCodes, isEmailBinding, layer, make, makeClient, sendLimits, validateMessage };
7
+ export { BindingNotFoundError, BindingValidationError, EmailAddress, EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult, EmailService, EmailValidationError, EmailViolation, LayerOptions, Tag, TagClass, emailErrorCodes, isEmailBinding, layer, make, makeClient, sendLimits, validateMessage };
9
8
  }
10
9
  declare const sendLimits: {
11
10
  readonly maxRecipients: 50;
@@ -63,18 +62,18 @@ declare class EmailValidationError extends EmailValidationError_base<{
63
62
  interface EmailDefinition {
64
63
  readonly binding: string;
65
64
  }
66
- type EmailAddress$1 = EmailAddress;
67
- type EmailAttachment$1 = EmailAttachment;
65
+ type EmailAddress = globalThis.EmailAddress;
66
+ type EmailAttachment = globalThis.EmailAttachment;
67
+ type EmailSendResult = globalThis.EmailSendResult;
68
68
  type EmailMessageBuilder = Parameters<SendEmail["send"]>[0];
69
- type EmailSendResult$1 = EmailSendResult;
70
69
  type EmailBinding = SendEmail;
71
- type EmailRecipients = string | EmailAddress$1 | ReadonlyArray<string | EmailAddress$1>;
70
+ type EmailRecipients = string | EmailAddress | ReadonlyArray<string | EmailAddress>;
72
71
  type EmailSendError = EmailOperationError | EmailValidationError;
73
72
  interface EmailSendOptions {
74
73
  readonly validate?: boolean;
75
74
  }
76
75
  interface EmailClient {
77
- readonly send: (message: EmailMessageBuilder) => Effect.Effect<EmailSendResult$1, EmailSendError>;
76
+ readonly send: (message: EmailMessageBuilder) => Effect.Effect<EmailSendResult, EmailSendError>;
78
77
  readonly rawUnsafe: Effect.Effect<EmailBinding>;
79
78
  readonly definition: EmailDefinition;
80
79
  }
@@ -104,4 +103,4 @@ declare const layer: <Self>(tag: Context$1.Service<Self, EmailClient>, definitio
104
103
  declare const make: <Id extends string>(id: Id) => TagClass<EmailService<Id>, Id>;
105
104
  declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
106
105
  //#endregion
107
- export { type BindingNotFoundError, type BindingValidationError, EmailAddress$1 as EmailAddress, EmailAttachment$1 as EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult$1 as EmailSendResult, EmailService, EmailValidationError, EmailViolation, Email_d_exports, LayerOptions, Tag, TagClass, emailErrorCodes, isEmailBinding, layer, make, makeClient, sendLimits, validateMessage };
106
+ export { type BindingNotFoundError, type BindingValidationError, EmailAddress, EmailAttachment, EmailBinding, EmailClient, EmailDefinition, EmailErrorCode, EmailMessageBuilder, EmailOperationError, EmailRecipients, EmailSendError, EmailSendOptions, EmailSendResult, EmailService, EmailValidationError, EmailViolation, Email_d_exports, LayerOptions, Tag, TagClass, emailErrorCodes, isEmailBinding, layer, make, makeClient, sendLimits, validateMessage };