effect-cf 0.33.0 → 0.34.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +31 -1079
  3. package/dist/{Artifacts-DnHQA-Ax.d.mts → Artifacts-B3r3RuTB.d.mts} +1 -48
  4. package/dist/{Artifacts-CSIk1Oml.mjs → Artifacts-CBxWGeZB.mjs} +2 -7
  5. package/dist/{Binding-pfilNJmP.mjs → Binding-C82jRhdr.mjs} +1 -2
  6. package/dist/{Binding-xJJJPmiD.d.mts → Binding-DKcLrQCM.d.mts} +0 -45
  7. package/dist/ComputerArtifacts.d.mts +1 -3
  8. package/dist/ComputerArtifacts.mjs +1 -2
  9. package/dist/ComputerWorkspace.d.mts +1 -10
  10. package/dist/ComputerWorkspace.mjs +1 -2
  11. package/dist/ComputerWorkspaceHost.d.mts +1 -9
  12. package/dist/{ContainerNamespace-CFjiLw8b.d.mts → ContainerNamespace-DbLaeFhN.d.mts} +1 -14
  13. package/dist/{DurableObjectState-BpRjz6-q.d.mts → DurableObjectState-CrEunfQ-.d.mts} +82 -252
  14. package/dist/{DurableObjectState-CVLLse69.mjs → DurableObjectState-De4ZojhY.mjs} +1 -39
  15. package/dist/{ErrorMessage-BM0K-Nik.mjs → ErrorMessage-Byx2OgNd.mjs} +0 -1
  16. package/dist/{Hyperdrive-z-9fFz15.d.mts → Hyperdrive-HrwFlZ6x.d.mts} +1 -4
  17. package/dist/HyperdrivePg.d.mts +2 -11
  18. package/dist/HyperdrivePg.mjs +0 -8
  19. package/dist/Sandbox.d.mts +2 -32
  20. package/dist/Sandbox.mjs +2 -11
  21. package/dist/Vitest.d.mts +3 -31
  22. package/dist/Vitest.mjs +2 -17
  23. package/dist/{WorkflowBinding-lBR4_-op.d.mts → WorkflowBinding-BumVQTuW.d.mts} +2 -5
  24. package/dist/index.d.mts +34 -480
  25. package/dist/index.mjs +174 -312
  26. package/package.json +1 -1
  27. package/src/AiGateway.ts +0 -6
  28. package/src/AnalyticsEngine.ts +0 -9
  29. package/src/Artifacts.ts +0 -47
  30. package/src/Binding.ts +0 -8
  31. package/src/BrowserRendering.ts +0 -4
  32. package/src/Cache.ts +0 -19
  33. package/src/CloudflareOtlp.ts +3 -39
  34. package/src/ComputerArtifacts.ts +0 -2
  35. package/src/ComputerWorkspace.ts +0 -9
  36. package/src/ComputerWorkspaceHost.ts +0 -8
  37. package/src/ContainerNamespace.ts +0 -13
  38. package/src/D1.ts +0 -22
  39. package/src/DurableObject.ts +45 -25
  40. package/src/DurableObjectAlarm.ts +6 -210
  41. package/src/DurableObjectDefinition.ts +8 -20
  42. package/src/DurableObjectNamespace.ts +57 -112
  43. package/src/DurableObjectRpcWebSocket.ts +3 -19
  44. package/src/DurableObjectSqlite.ts +0 -12
  45. package/src/DurableObjectState.ts +0 -18
  46. package/src/DurableObjectStorage.ts +2 -35
  47. package/src/DurableObjectWebSocket.ts +0 -31
  48. package/src/Email.ts +0 -12
  49. package/src/Environment.ts +0 -37
  50. package/src/Hyperdrive.ts +0 -3
  51. package/src/HyperdrivePg.ts +0 -9
  52. package/src/Images.ts +0 -5
  53. package/src/Kv.ts +0 -15
  54. package/src/QueueBinding.ts +0 -2
  55. package/src/R2.ts +0 -5
  56. package/src/RpcDefinition.ts +0 -2
  57. package/src/RpcTracing.ts +133 -0
  58. package/src/Sandbox.ts +0 -30
  59. package/src/ServiceBinding.ts +48 -125
  60. package/src/Vectorize.ts +0 -5
  61. package/src/Vitest.ts +0 -28
  62. package/src/WebTransport.ts +0 -15
  63. package/src/Worker.ts +36 -57
  64. package/src/WorkerDefinition.ts +5 -14
  65. package/src/WorkersAi.ts +0 -4
  66. package/src/Workflow.ts +0 -5
  67. package/src/WorkflowBinding.ts +0 -3
  68. package/src/index.ts +1 -0
  69. package/src/internal/Entrypoint.ts +23 -4
  70. package/src/internal/ErrorMessage.ts +0 -1
  71. package/src/internal/RpcInvocation.ts +18 -1
  72. package/src/internal/Runtime.ts +12 -7
  73. package/src/internal/WorkerContext.ts +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect-cf",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Effect-native primitives for Cloudflare Workers and bindings.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/AiGateway.ts CHANGED
@@ -8,7 +8,6 @@ import * as ErrorMessage from "./internal/ErrorMessage";
8
8
 
9
9
  const expectedAiGatewayBinding = "Workers AI binding with gateway()";
10
10
 
11
- /** Error raised when an AI Gateway operation fails. */
12
11
  export class AiGatewayOperationError extends Data.TaggedError("AiGatewayOperationError")<{
13
12
  readonly binding: string;
14
13
  readonly operation: string;
@@ -19,13 +18,9 @@ export class AiGatewayOperationError extends Data.TaggedError("AiGatewayOperatio
19
18
  }
20
19
  }
21
20
 
22
- /** Typed AI Gateway client definition. */
23
21
  export interface AiGatewayDefinition {
24
- /** Binding name as configured in `wrangler.jsonc`. */
25
22
  readonly binding: string;
26
- /** Gateway id/name passed to `env.AI.gateway(id)`. */
27
23
  readonly gatewayId: string;
28
- /** Optional account id used by the HTTP-only helper. */
29
24
  readonly accountId?: string;
30
25
  }
31
26
 
@@ -104,7 +99,6 @@ export interface AiGatewayClient {
104
99
 
105
100
  declare const AiGatewayServiceTypeId: unique symbol;
106
101
 
107
- /** Nominal service marker for AI Gateway services created with {@link make}. */
108
102
  export interface AiGatewayService<Id extends string> {
109
103
  readonly [AiGatewayServiceTypeId]: {
110
104
  readonly id: Id;
@@ -65,7 +65,6 @@ export const AnalyticsEngineDataPointSchema = S.Struct({
65
65
  const decodeQueryResponse = S.decodeUnknownEffect(queryResponseSchema);
66
66
  const decodeDataPoint = S.decodeUnknownEffect(AnalyticsEngineDataPointSchema);
67
67
 
68
- /** Error raised when an Analytics Engine operation fails. */
69
68
  export class AnalyticsEngineOperationError extends Data.TaggedError(
70
69
  "AnalyticsEngineOperationError",
71
70
  )<{
@@ -85,7 +84,6 @@ export interface AnalyticsEngineWriteViolation {
85
84
  readonly actual?: number;
86
85
  }
87
86
 
88
- /** Error raised when an Analytics Engine write input violates Cloudflare limits. */
89
87
  export class AnalyticsEngineWriteValidationError extends Data.TaggedError(
90
88
  "AnalyticsEngineWriteValidationError",
91
89
  )<{
@@ -99,7 +97,6 @@ export class AnalyticsEngineWriteValidationError extends Data.TaggedError(
99
97
  }
100
98
  }
101
99
 
102
- /** Error raised when an Analytics Engine SQL API query fails. */
103
100
  export class AnalyticsEngineQueryError extends Data.TaggedError("AnalyticsEngineQueryError")<{
104
101
  readonly operation: string;
105
102
  readonly accountId: string;
@@ -109,9 +106,7 @@ export class AnalyticsEngineQueryError extends Data.TaggedError("AnalyticsEngine
109
106
  readonly cause?: unknown;
110
107
  }> {}
111
108
 
112
- /** Typed Analytics Engine dataset binding definition. */
113
109
  export interface AnalyticsEngineDefinition {
114
- /** Binding name as configured in `wrangler.jsonc`. */
115
110
  readonly binding: string;
116
111
  }
117
112
 
@@ -142,11 +137,9 @@ export interface AnalyticsEngineQueryResult<Row = AnalyticsEngineQueryRow> {
142
137
  }
143
138
 
144
139
  export interface AnalyticsEngineQueryDefinition {
145
- /** Cloudflare account id that owns the Analytics Engine datasets. */
146
140
  readonly accountId: string;
147
141
  /** API token with Account Analytics Read permission. */
148
142
  readonly apiToken: Redacted.Redacted<string>;
149
- /** Base Cloudflare API URL. Defaults to `https://api.cloudflare.com/client/v4`. */
150
143
  readonly apiBaseUrl?: string | URL;
151
144
  }
152
145
 
@@ -202,14 +195,12 @@ export interface AnalyticsEngineQueryClient {
202
195
  declare const AnalyticsEngineServiceTypeId: unique symbol;
203
196
  declare const AnalyticsEngineQueryServiceTypeId: unique symbol;
204
197
 
205
- /** Nominal service marker for Analytics Engine services created with {@link make}. */
206
198
  export interface AnalyticsEngineService<Id extends string> {
207
199
  readonly [AnalyticsEngineServiceTypeId]: {
208
200
  readonly id: Id;
209
201
  };
210
202
  }
211
203
 
212
- /** Nominal service marker for Analytics Engine query services created with {@link makeQuery}. */
213
204
  export interface AnalyticsEngineQueryService<Id extends string> {
214
205
  readonly [AnalyticsEngineQueryServiceTypeId]: {
215
206
  readonly id: Id;
package/src/Artifacts.ts CHANGED
@@ -18,7 +18,6 @@ const expectedArtifactsBinding =
18
18
  const expectedArtifactsRepo =
19
19
  "Artifacts repo handle with createToken(), listTokens(), revokeToken(), fork(), log(), readCommit(), and readTree()";
20
20
 
21
- /** Artifacts operation represented by {@link ArtifactsOperationError}. */
22
21
  export type ArtifactsOperation =
23
22
  | "createClient"
24
23
  | "create"
@@ -37,7 +36,6 @@ export type ArtifactsOperation =
37
36
  | "readTree"
38
37
  | "cli";
39
38
 
40
- /** Documented string error codes returned by Cloudflare Artifacts. */
41
39
  export const artifactsErrorCodes = [
42
40
  "ALREADY_EXISTS",
43
41
  "NOT_FOUND",
@@ -53,7 +51,6 @@ export const artifactsErrorCodes = [
53
51
  "INTERNAL_ERROR",
54
52
  ] as const satisfies ReadonlyArray<CloudflareArtifactsErrorCode>;
55
53
 
56
- /** Documented numeric error codes returned by Cloudflare Artifacts. */
57
54
  export const artifactsErrorNumericCodes = {
58
55
  ALREADY_EXISTS: 10201,
59
56
  NOT_FOUND: 10200,
@@ -69,17 +66,13 @@ export const artifactsErrorNumericCodes = {
69
66
  INTERNAL_ERROR: 10400,
70
67
  } as const satisfies Readonly<Record<CloudflareArtifactsErrorCode, number>>;
71
68
 
72
- /** A documented Cloudflare Artifacts string error code. */
73
69
  export type ArtifactsErrorCode = CloudflareArtifactsErrorCode;
74
70
 
75
- /** Error raised when a Cloudflare Artifacts operation fails. */
76
71
  export class ArtifactsOperationError extends Data.TaggedError("ArtifactsOperationError")<{
77
72
  readonly binding: string;
78
73
  readonly operation: ArtifactsOperation;
79
74
  readonly cause: unknown;
80
- /** Cloudflare string error code, when retained by the runtime. */
81
75
  readonly code?: ArtifactsErrorCode | (string & {});
82
- /** Cloudflare REST-compatible numeric error code, when retained by the runtime. */
83
76
  readonly numericCode?: number;
84
77
  }> {
85
78
  override get message(): string {
@@ -89,16 +82,12 @@ export class ArtifactsOperationError extends Data.TaggedError("ArtifactsOperatio
89
82
  }
90
83
  }
91
84
 
92
- /** Typed Cloudflare Artifacts binding definition. */
93
85
  export interface ArtifactsDefinition {
94
- /** Binding name from an `artifacts` entry in `wrangler.jsonc`. */
95
86
  readonly binding: string;
96
87
  }
97
88
 
98
- /** Repository name containing alphanumeric characters, dots, hyphens, or underscores. */
99
89
  export type RepoName = string;
100
90
 
101
- /** Cursor used by repository list pagination. */
102
91
  export type Cursor = string;
103
92
 
104
93
  /** Scope granted to a repository token. */
@@ -107,21 +96,16 @@ export type ArtifactsTokenScope = "read" | "write";
107
96
  /** Lifecycle state of a repository token. */
108
97
  export type ArtifactsTokenState = "active" | "expired" | "revoked";
109
98
 
110
- /** Lifecycle state included with repositories returned by `list()`. */
111
99
  export type ArtifactsRepoStatus = "ready" | "importing" | "forking";
112
100
 
113
- /** Stable repository metadata returned by Cloudflare Artifacts. */
114
101
  export type ArtifactsRepoInfo = CloudflareArtifactsRepoInfo;
115
102
 
116
- /** Result of creating, importing, or forking a repository. */
117
103
  export type ArtifactsCreateRepoResult = Readonly<CloudflareArtifactsCreateRepoResult>;
118
104
 
119
- /** Repository metadata returned by `list()`. */
120
105
  export interface ArtifactsRepoListEntry extends ArtifactsRepoInfo {
121
106
  readonly status: ArtifactsRepoStatus;
122
107
  }
123
108
 
124
- /** Cursor-paginated repository list result. */
125
109
  export interface ArtifactsRepoListResult {
126
110
  readonly repos: ReadonlyArray<ArtifactsRepoListEntry>;
127
111
  readonly total: number;
@@ -151,13 +135,10 @@ export interface ArtifactsCommit {
151
135
  readonly author: ArtifactsCommitIdentity;
152
136
  readonly committer: ArtifactsCommitIdentity;
153
137
  readonly parents: ReadonlyArray<string>;
154
- /** Unix timestamp in seconds. */
155
138
  readonly authoredAt: number;
156
- /** Unix timestamp in seconds. */
157
139
  readonly committedAt: number;
158
140
  }
159
141
 
160
- /** Bare commit array returned by `log()`. */
161
142
  export type ArtifactsLogResult = ReadonlyArray<ArtifactsCommit>;
162
143
 
163
144
  /**
@@ -170,20 +151,14 @@ export interface ArtifactsTree<Field = unknown> {
170
151
  readonly [field: string]: Field;
171
152
  }
172
153
 
173
- /** Options for `Artifacts.create()`. */
174
154
  export interface ArtifactsCreateOptions {
175
- /** Prevent pushes to the repository. */
176
155
  readonly readOnly?: boolean;
177
156
  readonly description?: string;
178
- /** Initial default branch name. */
179
157
  readonly setDefaultBranch?: string;
180
158
  }
181
159
 
182
- /** Options for cursor-paginating `Artifacts.list()`. */
183
160
  export interface ArtifactsListOptions {
184
- /** Page size from 1 through 200. Defaults to 50. */
185
161
  readonly limit?: number;
186
- /** Cursor returned by a previous list result. */
187
162
  readonly cursor?: Cursor;
188
163
  }
189
164
 
@@ -191,47 +166,37 @@ export interface ArtifactsListOptions {
191
166
  export interface ArtifactsImportSource {
192
167
  /** Full HTTPS URL of the Git repository. */
193
168
  readonly url: string;
194
- /** Source branch. Defaults to the remote's default branch. */
195
169
  readonly branch?: string;
196
- /** Shallow clone depth. */
197
170
  readonly depth?: number;
198
171
  }
199
172
 
200
- /** Options for the target of `Artifacts.import()`. */
201
173
  export interface ArtifactsImportTargetOptions {
202
174
  readonly description?: string;
203
175
  readonly readOnly?: boolean;
204
176
  }
205
177
 
206
- /** Target repository used by `Artifacts.import()`. */
207
178
  export interface ArtifactsImportTarget {
208
179
  readonly name: RepoName;
209
180
  readonly opts?: ArtifactsImportTargetOptions;
210
181
  }
211
182
 
212
- /** Parameters for `Artifacts.import()`. */
213
183
  export interface ArtifactsImportParams {
214
184
  readonly source: ArtifactsImportSource;
215
185
  readonly target: ArtifactsImportTarget;
216
186
  }
217
187
 
218
- /** Options for `ArtifactsRepoClient.fork()`. */
219
188
  export interface ArtifactsForkOptions {
220
189
  readonly description?: string;
221
190
  readonly readOnly?: boolean;
222
- /** Only copy the default branch. Defaults to `true`. */
223
191
  readonly defaultBranchOnly?: boolean;
224
192
  }
225
193
 
226
- /** Options for `ArtifactsRepoClient.log()`. */
227
194
  export interface ArtifactsLogOptions {
228
- /** Branch, tag, or commit hash. */
229
195
  readonly ref?: string;
230
196
  readonly limit?: number;
231
197
  readonly offset?: number;
232
198
  }
233
199
 
234
- /** Runtime repository handle, including methods absent from current shipped Workers types. */
235
200
  export interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
236
201
  /**
237
202
  * Read repository metadata.
@@ -262,7 +227,6 @@ export interface ArtifactsRepoBinding extends Partial<ArtifactsRepoInfo> {
262
227
  readonly readTree: (hash: string) => Promise<ArtifactsTree>;
263
228
  }
264
229
 
265
- /** Cloudflare Artifacts namespace binding. */
266
230
  export interface ArtifactsBinding {
267
231
  readonly create: (
268
232
  name: RepoName,
@@ -274,14 +238,7 @@ export interface ArtifactsBinding {
274
238
  readonly delete: (name: RepoName) => Promise<boolean>;
275
239
  }
276
240
 
277
- /**
278
- * Effect wrapper around a repository handle returned by `Artifacts.get()`.
279
- *
280
- * The inherited metadata is the snapshot read while resolving the client.
281
- * Use `info()` to refresh it from the repository handle.
282
- */
283
241
  export interface ArtifactsRepoClient extends ArtifactsRepoInfo {
284
- /** Read and validate the repository's current metadata. */
285
242
  readonly info: () => Effect.Effect<ArtifactsRepoInfo, ArtifactsOperationError>;
286
243
  /**
287
244
  * Create a Git token for the repository.
@@ -307,7 +264,6 @@ export interface ArtifactsRepoClient extends ArtifactsRepoInfo {
307
264
  readonly raw: ArtifactsRepoBinding;
308
265
  }
309
266
 
310
- /** Effect wrapper around a Cloudflare Artifacts namespace binding. */
311
267
  export interface ArtifactsClient {
312
268
  readonly create: (
313
269
  name: RepoName,
@@ -327,7 +283,6 @@ export interface ArtifactsClient {
327
283
 
328
284
  declare const ArtifactsServiceTypeId: unique symbol;
329
285
 
330
- /** Nominal service marker for Artifacts services created with {@link make}. */
331
286
  export interface ArtifactsService<Id extends string> {
332
287
  readonly [ArtifactsServiceTypeId]: {
333
288
  readonly id: Id;
@@ -440,7 +395,6 @@ const readRepoInfo = (
440
395
  );
441
396
  };
442
397
 
443
- /** Tests whether a value exposes the complete documented Artifacts repo handle API. */
444
398
  export const isArtifactsRepoBinding = <Candidate>(
445
399
  value: Candidate,
446
400
  ): value is Candidate & ArtifactsRepoBinding =>
@@ -452,7 +406,6 @@ export const isArtifactsRepoBinding = <Candidate>(
452
406
  hasFunction(value, "readCommit") &&
453
407
  hasFunction(value, "readTree");
454
408
 
455
- /** Tests whether a value exposes the complete documented Artifacts namespace API. */
456
409
  export const isArtifactsBinding = <Candidate>(
457
410
  value: Candidate,
458
411
  ): value is Candidate & ArtifactsBinding =>
package/src/Binding.ts CHANGED
@@ -2,10 +2,8 @@ import { Context, Data, Effect, Layer, Predicate } from "effect";
2
2
 
3
3
  import { WorkerEnvironment, type WorkerEnv } from "./Environment";
4
4
 
5
- /** Internal type id marker used by binding helper services. */
6
5
  export const TypeId = "~effect-cf/Binding" as const;
7
6
 
8
- /** Internal type id marker used by binding helper services. */
9
7
  export type TypeId = typeof TypeId;
10
8
 
11
9
  /** Error raised when a configured binding does not exist on `env`. */
@@ -171,12 +169,6 @@ const getBinding = <Resource>(
171
169
  return resource;
172
170
  });
173
171
 
174
- /**
175
- * Creates a Context tag + layer for reading and validating a Cloudflare binding.
176
- *
177
- * The Context key is namespaced as `effect-cf/Binding/<id>`; `id` stays the
178
- * bare user-supplied identifier.
179
- */
180
172
  export interface BindingService<Self, Id extends string, Service> extends Context.ServiceClass<
181
173
  Self,
182
174
  `effect-cf/Binding/${Id}`,
@@ -6,7 +6,6 @@ import * as ErrorMessage from "./internal/ErrorMessage";
6
6
 
7
7
  const expectedBrowserRenderingBinding = "Browser Rendering binding resource";
8
8
 
9
- /** Error raised when a Browser Rendering operation fails. */
10
9
  export class BrowserRenderingOperationError extends Data.TaggedError(
11
10
  "BrowserRenderingOperationError",
12
11
  )<{
@@ -19,9 +18,7 @@ export class BrowserRenderingOperationError extends Data.TaggedError(
19
18
  }
20
19
  }
21
20
 
22
- /** Typed Browser Rendering binding definition. */
23
21
  export interface BrowserRenderingDefinition {
24
- /** Binding name as configured in `wrangler.jsonc`. */
25
22
  readonly binding: string;
26
23
  }
27
24
 
@@ -132,7 +129,6 @@ export interface BrowserRenderingClient<
132
129
 
133
130
  declare const BrowserRenderingServiceTypeId: unique symbol;
134
131
 
135
- /** Nominal service marker for Browser Rendering services created with {@link make}. */
136
132
  export interface BrowserRenderingService<Id extends string> {
137
133
  readonly [BrowserRenderingServiceTypeId]: {
138
134
  readonly id: Id;
package/src/Cache.ts CHANGED
@@ -8,16 +8,12 @@ import { Context, Data, Effect, Layer, Option } from "effect";
8
8
 
9
9
  import * as ErrorMessage from "./internal/ErrorMessage";
10
10
 
11
- /** Request key accepted by Cloudflare's Cache API. */
12
11
  export type CacheRequest = CloudflareRequestInfo | URL;
13
12
 
14
- /** Query options supported by Cloudflare's Cache API. */
15
13
  export type CacheQueryOptions = CloudflareCacheQueryOptions;
16
14
 
17
- /** Cache operation represented by {@link CacheOperationError}. */
18
15
  export type CacheOperation = "open" | "match" | "put" | "delete";
19
16
 
20
- /** Error raised when a Cloudflare Cache API operation fails. */
21
17
  export class CacheOperationError extends Data.TaggedError("CacheOperationError")<{
22
18
  readonly cache: string;
23
19
  readonly operation: CacheOperation;
@@ -28,40 +24,29 @@ export class CacheOperationError extends Data.TaggedError("CacheOperationError")
28
24
  }
29
25
  }
30
26
 
31
- /** Effect wrapper around one Cloudflare `Cache` instance. */
32
27
  export interface CacheClient {
33
- /** Cache name (`default` for `caches.default`). */
34
28
  readonly name: string;
35
- /** Finds a cached response, mapping cache misses to `Option.none()`. */
36
29
  readonly match: (
37
30
  request: CacheRequest,
38
31
  options?: CacheQueryOptions,
39
32
  ) => Effect.Effect<Option.Option<Response>, CacheOperationError>;
40
- /** Stores a response under the request key. */
41
33
  readonly put: (
42
34
  request: CacheRequest,
43
35
  response: Response,
44
36
  ) => Effect.Effect<void, CacheOperationError>;
45
- /** Deletes a cached response and reports whether it existed. */
46
37
  readonly delete: (
47
38
  request: CacheRequest,
48
39
  options?: CacheQueryOptions,
49
40
  ) => Effect.Effect<boolean, CacheOperationError>;
50
- /** Access to the native Cloudflare `Cache` instance. */
51
41
  readonly rawUnsafe: Effect.Effect<CloudflareCache>;
52
42
  }
53
43
 
54
- /** Effect wrapper around Cloudflare's global `caches` object. */
55
44
  export interface CacheStorageClient {
56
- /** Cloudflare's shared default cache. */
57
45
  readonly default: CacheClient;
58
- /** Opens a named cache. */
59
46
  readonly open: (name: string) => Effect.Effect<CacheClient, CacheOperationError>;
60
- /** Access to the native Cloudflare `CacheStorage` instance. */
61
47
  readonly rawUnsafe: Effect.Effect<CloudflareCacheStorage>;
62
48
  }
63
49
 
64
- /** Service for Cloudflare's global Cache API. */
65
50
  export class CacheStorage extends Context.Service<CacheStorage, CacheStorageClient>()(
66
51
  "effect-cf/CacheStorage",
67
52
  ) {}
@@ -83,7 +68,6 @@ const spanOptions = (cache: string, operation: CacheOperation) => ({
83
68
  attributes: { cache, operation },
84
69
  });
85
70
 
86
- /** Wraps a native Cloudflare `Cache` instance. */
87
71
  export const makeCacheClient = (cache: CloudflareCache, name = "default"): CacheClient => ({
88
72
  name,
89
73
  match: Effect.fn(
@@ -109,7 +93,6 @@ export const makeCacheClient = (cache: CloudflareCache, name = "default"): Cache
109
93
  rawUnsafe: Effect.succeed(cache),
110
94
  });
111
95
 
112
- /** Wraps a native Cloudflare `CacheStorage` instance. */
113
96
  export const makeClient = (storage: CloudflareCacheStorage): CacheStorageClient => ({
114
97
  default: makeCacheClient(storage.default),
115
98
  open: (name) =>
@@ -120,9 +103,7 @@ export const makeClient = (storage: CloudflareCacheStorage): CacheStorageClient
120
103
  rawUnsafe: Effect.succeed(storage),
121
104
  });
122
105
 
123
- /** Provides Cache API services from an explicit native `CacheStorage` instance. */
124
106
  export const layerFrom = (storage: CloudflareCacheStorage): Layer.Layer<CacheStorage> =>
125
107
  Layer.succeed(CacheStorage, makeClient(storage));
126
108
 
127
- /** Provides Cache API services from Cloudflare's global `caches` object. */
128
109
  export const layer: Layer.Layer<CacheStorage> = Layer.sync(CacheStorage, () => makeClient(caches));
@@ -1,28 +1,7 @@
1
1
  /**
2
- * OTLP telemetry layers for Cloudflare Workers and Durable Objects.
3
- *
4
- * Every layer exposes {@link OtlpExporter.Flusher}, which drains buffered
5
- * telemetry on demand. Cloudflare isolates can freeze before the periodic
6
- * export interval fires. Effect-backed Worker fetch handlers, Worker or
7
- * Durable Object native RPC handlers, and Durable Object alarm handlers
8
- * schedule this flusher automatically. These automatic flushes are capped at
9
- * two seconds and silently discard timeouts and failures so telemetry cannot
10
- * extend or fail the user event, or recursively log through an unhealthy
11
- * exporter.
12
- *
13
- * Other entrypoint lifecycles, including queue handlers, do not flush
14
- * automatically. Applications can flush explicitly or hand the flush to their
15
- * `waitUntil` mechanism, and own the timeout and failure policy at that call
16
- * site:
17
- *
18
- * ```ts
19
- * const flusher = yield* OtlpExporter.Flusher;
20
- *
21
- * yield* flusher.flush.pipe(
22
- * Effect.timeoutOption("2 seconds"),
23
- * Effect.ignoreCause,
24
- * );
25
- * ```
2
+ * Worker fetch/RPC and Durable Object alarm/RPC handlers schedule a best-effort
3
+ * flusher. It settles within two seconds; queues and other lifecycles must
4
+ * flush explicitly. Failures are ignored so telemetry cannot fail user events.
26
5
  */
27
6
  import { ConfigProvider, Effect, Layer, Option } from "effect";
28
7
  import type * as Tracer from "effect/Tracer";
@@ -76,32 +55,18 @@ export interface LayerOptions {
76
55
  readonly signals?: ReadonlyArray<Signal>;
77
56
  /** OTLP payload serialization. Defaults to protobuf. */
78
57
  readonly serialization?: Serialization;
79
- /** Resource metadata forwarded to Effect's OTLP resource resolver. */
80
58
  readonly resource?: ResourceOptions;
81
- /**
82
- * Explicit headers for every selected signal.
83
- *
84
- * When omitted, Effect reads `OTEL_EXPORTER_OTLP_HEADERS` and the
85
- * signal-specific `OTEL_EXPORTER_OTLP_*_HEADERS` variables.
86
- */
87
59
  readonly headers?: Headers.Input;
88
- /** Exclude log records emitted for spans when exporting logs. */
89
60
  readonly loggerExcludeLogSpans?: boolean;
90
- /** Merge the OTLP logger with existing loggers instead of replacing them. */
91
61
  readonly loggerMergeWithExisting?: boolean;
92
- /** Custom trace context lookup used by the Effect OTLP tracer. */
93
62
  readonly tracerContext?: <X>(primitive: Tracer.EffectPrimitive<X>, span: Tracer.AnySpan) => X;
94
63
  }
95
64
 
96
- /** Resource metadata specific to Cloudflare Workers. */
97
65
  export interface WorkerLayerOptions extends LayerOptions {
98
- /** Cloudflare Worker name to attach as `cloudflare.worker.name`. */
99
66
  readonly workerName?: string;
100
67
  }
101
68
 
102
- /** Resource metadata specific to Cloudflare Durable Objects. */
103
69
  export interface DurableObjectLayerOptions extends LayerOptions {
104
- /** Durable Object class name to attach as `cloudflare.durable_object.class`. */
105
70
  readonly className?: string;
106
71
  /**
107
72
  * Include the Durable Object id as `cloudflare.durable_object.id`.
@@ -154,7 +119,6 @@ const serializationLayer = (serialization: Serialization | undefined) =>
154
119
 
155
120
  type SignalLayer = ReturnType<typeof OtlpLogger.layerFromConfig>;
156
121
 
157
- /** Merges a non-empty signal layer list; callers handle the empty case. */
158
122
  const mergeSignalLayers = (layers: ReadonlyArray<SignalLayer>): SignalLayer => {
159
123
  let merged = layers[0]!;
160
124
 
@@ -35,7 +35,6 @@ export type ComputerArtifactsCliResult = Readonly<CloudflareComputerArtifactsCli
35
35
 
36
36
  /** Options used when wrapping a session-scoped Artifacts client. */
37
37
  export interface ComputerArtifactsClientOptions {
38
- /** Binding name attached to errors and tracing spans. Defaults to `ARTIFACTS`. */
39
38
  readonly binding?: string;
40
39
  }
41
40
 
@@ -136,7 +135,6 @@ const spanOptions = (
136
135
  operation: Artifacts.ArtifactsOperation,
137
136
  ) => ({ attributes: { binding, sessionId, operation } });
138
137
 
139
- /** Wraps an already-created upstream session client. */
140
138
  export const fromClient = (
141
139
  client: CloudflareComputerArtifactClient,
142
140
  options: ComputerArtifactsClientOptions = {},
@@ -128,7 +128,6 @@ export interface WorkspaceReadFile {
128
128
  ): Effect.Effect<ReadableStream<Uint8Array>, WorkspaceFsError>;
129
129
  }
130
130
 
131
- /** Complete Effect wrapper of `WorkspaceClient.fs`. */
132
131
  export interface ComputerWorkspaceFilesystem {
133
132
  readonly readFile: WorkspaceReadFile;
134
133
  readonly stat: (path: string) => Effect.Effect<WorkspaceEntryStat, WorkspaceFsError>;
@@ -173,7 +172,6 @@ export type WorkspaceGitDiffOptions = CloudflareGitDiffOptions;
173
172
  export type WorkspaceGitCommitOptions = CloudflareGitCommitOptions;
174
173
 
175
174
  export interface WorkspaceGitLogOptions extends Omit<CloudflareGitLogOptions, "depth"> {
176
- /** Preferred upstream name for the history bound. */
177
175
  readonly depth?: number;
178
176
  /** Consumer-port compatibility alias for `depth`. */
179
177
  readonly maxCount?: number;
@@ -235,7 +233,6 @@ export type WorkspaceExecOptions<Encoding extends WorkspaceExecEncoding = "utf8"
235
233
  "encoding" | "timeoutMs"
236
234
  > & {
237
235
  readonly encoding?: Encoding;
238
- /** Upstream runtime option name. */
239
236
  readonly timeoutMs?: number;
240
237
  /** Consumer-port compatibility alias for `timeoutMs`. */
241
238
  readonly timeoutMillis?: number;
@@ -334,7 +331,6 @@ export interface WorkspaceExecCollect {
334
331
  ): Effect.Effect<WorkspaceExecResult<"binary">, WorkspaceExecError>;
335
332
  }
336
333
 
337
- /** Complete Effect wrapper of `WorkspaceClient.runtime`. */
338
334
  export interface ComputerWorkspaceRuntime {
339
335
  readonly exec: WorkspaceExec;
340
336
  readonly execCollect: WorkspaceExecCollect;
@@ -349,7 +345,6 @@ export interface ComputerWorkspaceRuntime {
349
345
  ) => Effect.Effect<void, WorkspaceExecError>;
350
346
  }
351
347
 
352
- /** Effect wrapper over a configured local `Workspace.assets` client. */
353
348
  export interface ComputerWorkspaceAssets {
354
349
  readonly share: (
355
350
  path: string,
@@ -368,7 +363,6 @@ export type ComputerWorkspaceThink = {
368
363
  >;
369
364
  };
370
365
 
371
- /** Effect service over every client surface exposed by Cloudflare Computer. */
372
366
  export interface ComputerWorkspaceService {
373
367
  readonly fs: ComputerWorkspaceFilesystem;
374
368
  readonly git: ComputerWorkspaceGit;
@@ -377,7 +371,6 @@ export interface ComputerWorkspaceService {
377
371
  readonly assets: ComputerWorkspaceAssets | undefined;
378
372
  readonly think: ComputerWorkspaceThink | undefined;
379
373
 
380
- /** Flat filesystem aliases retained for mechanical consumer migration. */
381
374
  readonly readFile: WorkspaceReadFile;
382
375
  readonly stat: ComputerWorkspaceFilesystem["stat"];
383
376
  readonly lstat: ComputerWorkspaceFilesystem["lstat"];
@@ -395,7 +388,6 @@ export interface ComputerWorkspaceService {
395
388
  readonly chmod: ComputerWorkspaceFilesystem["chmod"];
396
389
  readonly symlink: ComputerWorkspaceFilesystem["symlink"];
397
390
 
398
- /** Flat runtime aliases retained for mechanical consumer migration. */
399
391
  readonly exec: WorkspaceExec;
400
392
  readonly execCollect: WorkspaceExecCollect;
401
393
  readonly getExec: WorkspaceGetExec;
@@ -1169,7 +1161,6 @@ export const fromWorkspaceClient = (
1169
1161
  };
1170
1162
  };
1171
1163
 
1172
- /** Effect service for the workspace owned by the enclosing Durable Object. */
1173
1164
  export class ComputerWorkspace extends Context.Service<
1174
1165
  ComputerWorkspace,
1175
1166
  ComputerWorkspaceService
@@ -47,7 +47,6 @@ export type {
47
47
  WorkspaceSpan,
48
48
  };
49
49
 
50
- /** The value of a `worker_loaders` binding. */
51
50
  export type DynamicWorkerLoader = WorkerShellLoader;
52
51
 
53
52
  /** Default author and committer identity for workspace Git operations. */
@@ -75,21 +74,14 @@ export interface ComputerWorkspaceShellOptions extends Omit<
75
74
  "source" | "loader" | "workspace" | "ctx" | "egress"
76
75
  > {
77
76
  readonly loader: DynamicWorkerLoader;
78
- /** Durable Object namespace binding that points back to the wrapped class. */
79
77
  readonly hostBinding: string;
80
- /** Current Durable Object id, normally `ctx.id.toString()`. */
81
78
  readonly hostId: string;
82
- /** Current Durable Object execution context, normally `ctx`. */
83
79
  readonly executionContext: unknown;
84
- /** Dynamic Worker egress policy. Defaults to `{ mode: "none" }`. */
85
80
  readonly egress?: WorkspaceEgressPolicy;
86
81
  }
87
82
 
88
- /** Configuration accepted by {@link withComputerWorkspace}. */
89
83
  export interface ComputerWorkspaceHostConfig {
90
- /** Native SQLite-backed Durable Object storage (`ctx.storage`). */
91
84
  readonly storage: globalThis.DurableObjectStorage | DurableObjectStorageLike;
92
- /** Stable workspace id used by mounts and as the default Artifacts session. */
93
85
  readonly sessionId?: string;
94
86
  readonly gitIdentity?: ComputerWorkspaceGitIdentity;
95
87
  /** Override the default `createGitClient()` factory. */