effect-cf 0.40.0 → 0.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/AiGateway.d.mts +86 -0
  3. package/dist/AiGateway.mjs +178 -0
  4. package/dist/AnalyticsEngine.d.mts +170 -0
  5. package/dist/AnalyticsEngine.mjs +275 -0
  6. package/dist/{Artifacts-B3r3RuTB.d.mts → Artifacts.d.mts} +8 -5
  7. package/dist/{Artifacts-CBxWGeZB.mjs → Artifacts.mjs} +9 -5
  8. package/dist/Binding.d.mts +45 -0
  9. package/dist/{Binding-C82jRhdr.mjs → Binding.mjs} +8 -4
  10. package/dist/BrowserRendering.d.mts +85 -0
  11. package/dist/BrowserRendering.mjs +81 -0
  12. package/dist/Cache.d.mts +40 -0
  13. package/dist/Cache.mjs +51 -0
  14. package/dist/CloudflareOtlp.d.mts +95 -0
  15. package/dist/CloudflareOtlp.mjs +125 -0
  16. package/dist/CloudflareTracer.d.mts +20 -0
  17. package/dist/CloudflareTracer.mjs +69 -0
  18. package/dist/ComputerArtifacts.d.mts +2 -2
  19. package/dist/ComputerArtifacts.mjs +3 -2
  20. package/dist/ComputerWorkspace.d.mts +36 -31
  21. package/dist/ComputerWorkspace.mjs +8 -3
  22. package/dist/ComputerWorkspaceHost.d.mts +1 -1
  23. package/dist/ComputerWorkspaceHost.mjs +1 -1
  24. package/dist/{ContainerNamespace-DbLaeFhN.d.mts → ContainerNamespace.d.mts} +16 -12
  25. package/dist/ContainerNamespace.mjs +165 -0
  26. package/dist/D1.d.mts +33 -0
  27. package/dist/D1.mjs +32 -0
  28. package/dist/DurableObject.d.mts +103 -0
  29. package/dist/DurableObject.mjs +77 -0
  30. package/dist/DurableObjectAlarm.d.mts +187 -0
  31. package/dist/DurableObjectAlarm.mjs +344 -0
  32. package/dist/DurableObjectDefinition.d.mts +87 -0
  33. package/dist/DurableObjectDefinition.mjs +125 -0
  34. package/dist/DurableObjectNamespace.d.mts +154 -0
  35. package/dist/DurableObjectNamespace.mjs +144 -0
  36. package/dist/DurableObjectRpcWebSocket.d.mts +112 -0
  37. package/dist/DurableObjectRpcWebSocket.mjs +547 -0
  38. package/dist/DurableObjectSqlite.d.mts +11 -0
  39. package/dist/DurableObjectSqlite.mjs +16 -0
  40. package/dist/DurableObjectState.d.mts +65 -0
  41. package/dist/DurableObjectState.mjs +47 -0
  42. package/dist/DurableObjectStorage.d.mts +112 -0
  43. package/dist/{DurableObjectState-DLL0YgBd.mjs → DurableObjectStorage.mjs} +19 -157
  44. package/dist/DurableObjectWebSocket.d.mts +83 -0
  45. package/dist/DurableObjectWebSocket.mjs +120 -0
  46. package/dist/Email.d.mts +106 -0
  47. package/dist/Email.mjs +247 -0
  48. package/dist/Environment.d.mts +59 -0
  49. package/dist/{ErrorMessage-Byx2OgNd.mjs → Environment.mjs} +7 -18
  50. package/dist/{Hyperdrive-HrwFlZ6x.d.mts → Hyperdrive.d.mts} +8 -5
  51. package/dist/Hyperdrive.mjs +32 -0
  52. package/dist/HyperdrivePg.d.mts +4 -3
  53. package/dist/HyperdrivePg.mjs +3 -1
  54. package/dist/Images.d.mts +191 -0
  55. package/dist/Images.mjs +112 -0
  56. package/dist/Kv.d.mts +84 -0
  57. package/dist/Kv.mjs +132 -0
  58. package/dist/Mcp.d.mts +5 -3
  59. package/dist/Mcp.mjs +13 -4
  60. package/dist/Queue.d.mts +68 -0
  61. package/dist/Queue.mjs +54 -0
  62. package/dist/QueueBinding.d.mts +42 -0
  63. package/dist/QueueBinding.mjs +69 -0
  64. package/dist/QueueDefinition.d.mts +48 -0
  65. package/dist/QueueDefinition.mjs +63 -0
  66. package/dist/R2.d.mts +89 -0
  67. package/dist/R2.mjs +117 -0
  68. package/dist/Rpc.d.mts +29 -0
  69. package/dist/Rpc.mjs +28 -0
  70. package/dist/RpcDefinition.d.mts +116 -0
  71. package/dist/RpcDefinition.mjs +184 -0
  72. package/dist/RpcTracing.d.mts +52 -0
  73. package/dist/RpcTracing.mjs +77 -0
  74. package/dist/Sandbox.d.mts +10 -5
  75. package/dist/Sandbox.mjs +9 -3
  76. package/dist/ServiceBinding.d.mts +112 -0
  77. package/dist/ServiceBinding.mjs +145 -0
  78. package/dist/Vectorize.d.mts +68 -0
  79. package/dist/Vectorize.mjs +76 -0
  80. package/dist/Vitest.d.mts +6 -4
  81. package/dist/Vitest.mjs +8 -4
  82. package/dist/WebTransport.d.mts +66 -0
  83. package/dist/WebTransport.mjs +63 -0
  84. package/dist/Worker.d.mts +139 -0
  85. package/dist/Worker.mjs +141 -0
  86. package/dist/WorkerDefinition.d.mts +100 -0
  87. package/dist/WorkerDefinition.mjs +103 -0
  88. package/dist/WorkersAi.d.mts +84 -0
  89. package/dist/WorkersAi.mjs +84 -0
  90. package/dist/Workflow.d.mts +91 -0
  91. package/dist/Workflow.mjs +139 -0
  92. package/dist/{WorkflowBinding-DtVykUCz.d.mts → WorkflowBinding.d.mts} +14 -10
  93. package/dist/WorkflowBinding.mjs +100 -0
  94. package/dist/WorkflowDefinition.d.mts +51 -0
  95. package/dist/WorkflowDefinition.mjs +69 -0
  96. package/dist/{rolldown-runtime-D7D4PA-g.mjs → _virtual/_rolldown/runtime.mjs} +1 -1
  97. package/dist/index.d.mts +40 -1839
  98. package/dist/index.mjs +40 -3161
  99. package/dist/{ComputerWorkspaceHostRegistry-CY5Fv4Ng.mjs → internal/ComputerWorkspaceHostRegistry.mjs} +1 -1
  100. package/dist/internal/Entrypoint.mjs +37 -0
  101. package/dist/internal/ErrorMessage.mjs +17 -0
  102. package/dist/internal/NativeCallback.mjs +33 -0
  103. package/dist/internal/RpcInvocation.d.mts +13 -0
  104. package/dist/internal/RpcInvocation.mjs +34 -0
  105. package/dist/internal/Runtime.mjs +31 -0
  106. package/dist/internal/Telemetry.mjs +20 -0
  107. package/dist/{WorkerContext-Yobnfw-K.mjs → internal/WorkerContext.mjs} +4 -31
  108. package/package.json +1 -1
  109. package/src/AiGateway.ts +5 -1
  110. package/src/AnalyticsEngine.ts +14 -19
  111. package/src/Artifacts.ts +6 -1
  112. package/src/Binding.ts +5 -1
  113. package/src/BrowserRendering.ts +5 -1
  114. package/src/Cache.ts +5 -1
  115. package/src/CloudflareOtlp.ts +12 -10
  116. package/src/CloudflareTracer.ts +7 -1
  117. package/src/ComputerArtifacts.ts +2 -1
  118. package/src/ComputerWorkspace.ts +7 -1
  119. package/src/ContainerNamespace.ts +6 -1
  120. package/src/D1.ts +4 -1
  121. package/src/DurableObject.ts +4 -1
  122. package/src/DurableObjectAlarm.ts +10 -12
  123. package/src/DurableObjectDefinition.ts +3 -1
  124. package/src/DurableObjectNamespace.ts +4 -1
  125. package/src/DurableObjectRpcWebSocket.ts +7 -1
  126. package/src/DurableObjectSqlite.ts +2 -1
  127. package/src/DurableObjectState.ts +4 -1
  128. package/src/DurableObjectStorage.ts +11 -13
  129. package/src/DurableObjectWebSocket.ts +5 -1
  130. package/src/Email.ts +5 -1
  131. package/src/Environment.ts +6 -1
  132. package/src/Hyperdrive.ts +4 -1
  133. package/src/HyperdrivePg.ts +3 -1
  134. package/src/Images.ts +7 -1
  135. package/src/Kv.ts +7 -1
  136. package/src/Mcp.ts +13 -13
  137. package/src/Queue.ts +3 -1
  138. package/src/QueueBinding.ts +5 -1
  139. package/src/QueueDefinition.ts +4 -1
  140. package/src/R2.ts +7 -1
  141. package/src/Rpc.ts +4 -1
  142. package/src/RpcDefinition.ts +4 -1
  143. package/src/RpcTracing.ts +9 -1
  144. package/src/Sandbox.ts +7 -1
  145. package/src/ServiceBinding.ts +6 -1
  146. package/src/Vectorize.ts +7 -1
  147. package/src/Vitest.ts +5 -1
  148. package/src/WebTransport.ts +6 -1
  149. package/src/Worker.ts +10 -16
  150. package/src/WorkerDefinition.ts +3 -1
  151. package/src/WorkersAi.ts +7 -1
  152. package/src/Workflow.ts +8 -11
  153. package/src/WorkflowBinding.ts +6 -1
  154. package/src/WorkflowDefinition.ts +4 -1
  155. package/src/internal/Entrypoint.ts +3 -1
  156. package/src/internal/ErrorMessage.ts +1 -1
  157. package/src/internal/NativeCallback.ts +3 -1
  158. package/src/internal/RpcInvocation.ts +5 -1
  159. package/src/internal/Runtime.ts +5 -1
  160. package/src/internal/Telemetry.ts +4 -3
  161. package/src/internal/WorkerContext.ts +3 -1
  162. package/dist/Binding-DKcLrQCM.d.mts +0 -94
  163. package/dist/DurableObjectState-DJ0K-zyd.d.mts +0 -244
  164. package/dist/Worker-XsGJsCJX.mjs +0 -885
  165. package/dist/Worker-gV4mDqIs.d.mts +0 -641
package/dist/Email.mjs ADDED
@@ -0,0 +1,247 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { layer as layer$1 } from "./Binding.mjs";
3
+ import { causeMessage, violationsMessage } from "./internal/ErrorMessage.mjs";
4
+ import * as Context from "effect/Context";
5
+ import * as Data from "effect/Data";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Predicate from "effect/Predicate";
8
+ //#region src/Email.ts
9
+ var Email_exports = /* @__PURE__ */ __exportAll({
10
+ EmailOperationError: () => EmailOperationError,
11
+ EmailValidationError: () => EmailValidationError,
12
+ Tag: () => Tag,
13
+ emailErrorCodes: () => emailErrorCodes,
14
+ isEmailBinding: () => isEmailBinding,
15
+ layer: () => layer,
16
+ make: () => make,
17
+ makeClient: () => makeClient,
18
+ sendLimits: () => sendLimits,
19
+ validateMessage: () => validateMessage
20
+ });
21
+ const expectedSendEmailBinding = "Send Email binding with send()";
22
+ const textEncoder = new TextEncoder();
23
+ const sendLimits = {
24
+ maxRecipients: 50,
25
+ maxAttachments: 32,
26
+ maxMessageBytes: 5242880,
27
+ maxHeaderNameBytes: 100,
28
+ maxHeaderValueBytes: 2048,
29
+ maxHeadersBytes: 16384,
30
+ maxAllowlistHeaders: 20
31
+ };
32
+ /**
33
+ * Error codes reported by Cloudflare Email Sending.
34
+ *
35
+ * Surfaced on {@link EmailOperationError} `code` on a best-effort basis: the
36
+ * runtime attaches them as a non-standard `code` property on thrown errors,
37
+ * which may be missing depending on the runtime or dev-time proxying
38
+ * (miniflare remote bindings serialize errors and can strip it).
39
+ */
40
+ const emailErrorCodes = [
41
+ "E_VALIDATION_ERROR",
42
+ "E_FIELD_MISSING",
43
+ "E_TOO_MANY_RECIPIENTS",
44
+ "E_TOO_MANY_ATTACHMENTS",
45
+ "E_SENDER_NOT_VERIFIED",
46
+ "E_RECIPIENT_NOT_ALLOWED",
47
+ "E_RECIPIENT_SUPPRESSED",
48
+ "E_SENDER_DOMAIN_NOT_AVAILABLE",
49
+ "E_CONTENT_TOO_LARGE",
50
+ "E_DELIVERY_FAILED",
51
+ "E_RATE_LIMIT_EXCEEDED",
52
+ "E_DAILY_LIMIT_EXCEEDED",
53
+ "E_INTERNAL_SERVER_ERROR",
54
+ "E_HEADER_NOT_ALLOWED",
55
+ "E_HEADER_USE_API_FIELD",
56
+ "E_HEADER_VALUE_INVALID",
57
+ "E_HEADER_VALUE_TOO_LONG",
58
+ "E_HEADER_NAME_INVALID",
59
+ "E_HEADERS_TOO_LARGE",
60
+ "E_HEADERS_TOO_MANY"
61
+ ];
62
+ var EmailOperationError = class extends Data.TaggedError("EmailOperationError") {
63
+ get message() {
64
+ const code = this.code === void 0 ? "" : ` (${this.code})`;
65
+ return `Email ${this.operation} failed for binding "${this.binding}"${code}: ${causeMessage(this.cause)}`;
66
+ }
67
+ };
68
+ var EmailValidationError = class extends Data.TaggedError("EmailValidationError") {
69
+ get message() {
70
+ return `Email ${this.operation} for binding "${this.binding}" failed validation: ${violationsMessage(this.violations)}`;
71
+ }
72
+ };
73
+ /**
74
+ * Best-effort extraction of the Cloudflare error `code` from a thrown error.
75
+ * Returns `undefined` when the property is absent — e.g. when a dev-time
76
+ * proxy such as a miniflare remote binding (`"remote": true`) serializes the
77
+ * error and strips non-standard properties.
78
+ */
79
+ const emailErrorCode = (cause) => {
80
+ if (!Predicate.isObject(cause)) return;
81
+ const code = Predicate.hasProperty(cause, "code") ? cause.code : void 0;
82
+ return Predicate.isString(code) ? code : void 0;
83
+ };
84
+ const emailError = (binding, operation, cause) => new EmailOperationError({
85
+ binding,
86
+ operation,
87
+ cause,
88
+ code: emailErrorCode(cause)
89
+ });
90
+ const emailValidationError = (binding, operation, violations) => new EmailValidationError({
91
+ binding,
92
+ operation,
93
+ violations
94
+ });
95
+ const tryEmailPromise = (binding, operation, evaluate) => Effect.tryPromise({
96
+ try: evaluate,
97
+ catch: (cause) => emailError(binding, operation, cause)
98
+ });
99
+ const byteLength = (value) => textEncoder.encode(value).byteLength;
100
+ const limitViolation = (path, label, actual, limit) => ({
101
+ path,
102
+ message: `${label} exceeds Cloudflare Email Sending limit`,
103
+ actual,
104
+ limit
105
+ });
106
+ const addressList = (value) => {
107
+ if (value === void 0) return [];
108
+ return Array.isArray(value) ? value : [value];
109
+ };
110
+ const addressViolations = (path, value) => {
111
+ if (Predicate.isString(value)) return value.includes("@") ? [] : [{
112
+ path,
113
+ message: "Email address must contain an @ symbol"
114
+ }];
115
+ if (!Predicate.isObject(value)) return [{
116
+ path,
117
+ message: "Email address must be a string or { name, email } object"
118
+ }];
119
+ const email = Predicate.hasProperty(value, "email") ? value.email : void 0;
120
+ if (!Predicate.isString(email) || !email.includes("@")) return [{
121
+ path: `${path}.email`,
122
+ message: "Email address must contain an @ symbol"
123
+ }];
124
+ return [];
125
+ };
126
+ const recipientViolations = (field, value) => addressList(value).flatMap((address, index) => addressViolations(`${field}[${index}]`, address));
127
+ const attachmentViolations = (attachments) => {
128
+ const violations = [];
129
+ if (attachments.length > sendLimits.maxAttachments) violations.push(limitViolation("attachments", "attachments", attachments.length, sendLimits.maxAttachments));
130
+ for (let index = 0; index < attachments.length; index++) {
131
+ const attachment = attachments[index];
132
+ const path = `attachments[${index}]`;
133
+ if (!Predicate.isObject(attachment)) {
134
+ violations.push({
135
+ path,
136
+ message: "Attachment must be an object"
137
+ });
138
+ continue;
139
+ }
140
+ if (!Predicate.isString(attachment.filename) || attachment.filename === "") violations.push({
141
+ path: `${path}.filename`,
142
+ message: "Attachment filename is required"
143
+ });
144
+ if (!Predicate.isString(attachment.type) || attachment.type === "") violations.push({
145
+ path: `${path}.type`,
146
+ message: "Attachment MIME type is required"
147
+ });
148
+ if (attachment.content === void 0 || attachment.content === null) violations.push({
149
+ path: `${path}.content`,
150
+ message: "Attachment content is required"
151
+ });
152
+ if (attachment.disposition === "inline" && !Predicate.isString(attachment.contentId)) violations.push({
153
+ path: `${path}.contentId`,
154
+ message: "Inline attachments require a contentId"
155
+ });
156
+ }
157
+ return violations;
158
+ };
159
+ const headerViolations = (headers) => {
160
+ const violations = [];
161
+ const entries = Object.entries(headers);
162
+ let totalBytes = 0;
163
+ let allowlistHeaders = 0;
164
+ for (const [name, value] of entries) {
165
+ const path = `headers["${name}"]`;
166
+ const nameBytes = byteLength(name);
167
+ if (nameBytes > sendLimits.maxHeaderNameBytes) violations.push(limitViolation(path, "header name bytes", nameBytes, sendLimits.maxHeaderNameBytes));
168
+ if (!Predicate.isString(value)) {
169
+ violations.push({
170
+ path,
171
+ message: "Header value must be a string"
172
+ });
173
+ continue;
174
+ }
175
+ const valueBytes = byteLength(value);
176
+ if (valueBytes > sendLimits.maxHeaderValueBytes) violations.push(limitViolation(path, "header value bytes", valueBytes, sendLimits.maxHeaderValueBytes));
177
+ totalBytes += nameBytes + valueBytes;
178
+ if (!name.toLowerCase().startsWith("x-")) allowlistHeaders += 1;
179
+ }
180
+ if (totalBytes > sendLimits.maxHeadersBytes) violations.push(limitViolation("headers", "header bytes", totalBytes, sendLimits.maxHeadersBytes));
181
+ if (allowlistHeaders > sendLimits.maxAllowlistHeaders) violations.push(limitViolation("headers", "allowlisted custom headers", allowlistHeaders, sendLimits.maxAllowlistHeaders));
182
+ return violations;
183
+ };
184
+ /**
185
+ * Validates a structured message against documented Cloudflare Email Sending
186
+ * limits and returns every violation found. Total message size is not checked
187
+ * because the encoded MIME size is only known once Cloudflare composes it.
188
+ */
189
+ const validateMessage = (message) => {
190
+ const violations = [];
191
+ const fields = message;
192
+ if (fields.from === void 0) violations.push({
193
+ path: "from",
194
+ message: "A from address is required"
195
+ });
196
+ else violations.push(...addressViolations("from", fields.from));
197
+ if (fields.replyTo !== void 0) violations.push(...addressViolations("replyTo", fields.replyTo));
198
+ if (!Predicate.isString(fields.subject) || fields.subject === "") violations.push({
199
+ path: "subject",
200
+ message: "A subject is required"
201
+ });
202
+ if (!Predicate.isString(fields.text) && !Predicate.isString(fields.html)) violations.push({
203
+ path: "$",
204
+ message: "A message requires either text or html content"
205
+ });
206
+ const recipients = addressList(fields.to).length + addressList(fields.cc).length + addressList(fields.bcc).length;
207
+ if (recipients === 0) violations.push({
208
+ path: "$",
209
+ message: "A message requires at least one to, cc, or bcc address"
210
+ });
211
+ if (recipients > sendLimits.maxRecipients) violations.push(limitViolation("$", "combined to, cc, and bcc addresses", recipients, sendLimits.maxRecipients));
212
+ violations.push(...recipientViolations("to", fields.to));
213
+ violations.push(...recipientViolations("cc", fields.cc));
214
+ violations.push(...recipientViolations("bcc", fields.bcc));
215
+ if (fields.attachments !== void 0) violations.push(...attachmentViolations(fields.attachments));
216
+ if (fields.headers !== void 0) violations.push(...headerViolations(fields.headers));
217
+ return violations;
218
+ };
219
+ const validateSendInput = (binding, operation, message) => {
220
+ const violations = validateMessage(message);
221
+ return violations.length > 0 ? Effect.fail(emailValidationError(binding, operation, violations)) : Effect.succeed(message);
222
+ };
223
+ const isEmailBinding = (value) => Predicate.hasProperty(value, "send") && Predicate.isFunction(value.send);
224
+ const makeClient = (definition, options) => (email) => {
225
+ const runtime = email;
226
+ const validate = options?.validate ?? true;
227
+ return {
228
+ definition,
229
+ send: Effect.fn("Email.send")(function* (message) {
230
+ if (validate) yield* validateSendInput(definition.binding, "send", message);
231
+ return yield* tryEmailPromise(definition.binding, "send", () => runtime.send(message));
232
+ }),
233
+ rawUnsafe: Effect.succeed(email)
234
+ };
235
+ };
236
+ const layer = (tag, definition) => layer$1(tag, definition.binding, isEmailBinding, makeClient(definition, definition.send), { expected: expectedSendEmailBinding });
237
+ const make = (id) => Tag()(id);
238
+ const Tag = () => (id) => {
239
+ const tag = Context.Service()(id);
240
+ const makeLayer = (definition) => layer(tag, definition);
241
+ return Object.assign(tag, {
242
+ id,
243
+ layer: makeLayer
244
+ });
245
+ };
246
+ //#endregion
247
+ export { EmailOperationError, EmailValidationError, Email_exports, Tag, emailErrorCodes, isEmailBinding, layer, make, makeClient, sendLimits, validateMessage };
@@ -0,0 +1,59 @@
1
+ import * as Context$1 from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Config$1 from "effect/Config";
4
+ import * as ConfigProvider from "effect/ConfigProvider";
5
+ import { Layer } from "effect";
6
+ declare namespace Environment_d_exports {
7
+ export { WorkerConfig, WorkerEnv, WorkerEnvironment };
8
+ }
9
+ type WorkerEnv = Cloudflare.Env;
10
+ declare const WorkerEnvironment_base: Context$1.ServiceClass<WorkerEnvironment, "effect-cf/WorkerEnvironment", Cloudflare.Env>;
11
+ /**
12
+ * Context service for reading worker bindings from the current `env` object.
13
+ */
14
+ declare class WorkerEnvironment extends WorkerEnvironment_base {}
15
+ type ScalarConfigValue = string | number | boolean;
16
+ type ScalarConfigKey = Extract<{ readonly [Key in keyof Cloudflare.Env]-?: NonNullable<Cloudflare.Env[Key]> extends ScalarConfigValue ? Key : never; }[keyof Cloudflare.Env], string>;
17
+ declare namespace WorkerConfig {
18
+ type Scalar = ScalarConfigValue;
19
+ type Key = ScalarConfigKey;
20
+ /** Read a scalar Cloudflare var or secret as a string. */
21
+ const string: <const Name extends Key>(name: Name) => Config$1.Config<string>;
22
+ /** Read a scalar Cloudflare secret as a redacted string. */
23
+ const redacted: <const Name extends Key>(name: Name) => Config$1.Config<import("effect/Redacted").Redacted<string>>;
24
+ /** Read a scalar Cloudflare var or secret as a number. */
25
+ const number: <const Name extends Key>(name: Name) => Config$1.Config<number>;
26
+ /** Read a scalar Cloudflare var or secret as an integer. */
27
+ const integer: <const Name extends Key>(name: Name) => Config$1.Config<number>;
28
+ /** Read a scalar Cloudflare var or secret as a boolean. */
29
+ const boolean: <const Name extends Key>(name: Name) => Config$1.Config<boolean>;
30
+ interface ProviderOptions {
31
+ /**
32
+ * Keep empty-string env values as explicit `""` config values.
33
+ *
34
+ * By default (absent or `false`), empty strings are treated as missing
35
+ * config, matching `ConfigProvider.fromEnvRecord`.
36
+ */
37
+ readonly preserveEmptyStrings?: boolean;
38
+ }
39
+ /**
40
+ * Build a `ConfigProvider` from a Cloudflare worker `env` object.
41
+ *
42
+ * Scalar vars and secrets use Effect's environment-record semantics;
43
+ * Cloudflare binding objects are ignored.
44
+ *
45
+ * Empty-string values are treated as missing config by default; pass
46
+ * `{ preserveEmptyStrings: true }` to keep them as explicit values.
47
+ */
48
+ const providerFromEnv: (env: WorkerEnv, options?: ProviderOptions) => ConfigProvider.ConfigProvider;
49
+ const providerWith: (makeProvider: (env: WorkerEnv) => ConfigProvider.ConfigProvider) => Effect.Effect<ConfigProvider.ConfigProvider, never, WorkerEnvironment>;
50
+ const provider: Effect.Effect<ConfigProvider.ConfigProvider, never, WorkerEnvironment>;
51
+ /**
52
+ * Replace the active Effect `ConfigProvider` with one backed by the current
53
+ * Cloudflare worker `env` object.
54
+ */
55
+ const providerLayer: Layer.Layer<never, never, WorkerEnvironment>;
56
+ const layerWith: (makeProvider: (env: WorkerEnv) => ConfigProvider.ConfigProvider) => Layer.Layer<never, never, WorkerEnvironment>;
57
+ }
58
+ //#endregion
59
+ export { Environment_d_exports, WorkerConfig, WorkerEnv, WorkerEnvironment };
@@ -1,5 +1,9 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Config, ConfigProvider, Context, Effect, Predicate } from "effect";
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Predicate from "effect/Predicate";
5
+ import * as Config from "effect/Config";
6
+ import * as ConfigProvider from "effect/ConfigProvider";
3
7
  //#region src/Environment.ts
4
8
  var Environment_exports = /* @__PURE__ */ __exportAll({
5
9
  WorkerConfig: () => WorkerConfig,
@@ -27,19 +31,4 @@ let WorkerConfig;
27
31
  _WorkerConfig.layerWith = (makeProvider) => ConfigProvider.layer(providerWith(makeProvider));
28
32
  })(WorkerConfig || (WorkerConfig = {}));
29
33
  //#endregion
30
- //#region src/internal/ErrorMessage.ts
31
- /**
32
- * Renders the most useful human-readable description of an unknown `cause`
33
- * for use in tagged error `message` getters.
34
- */
35
- const causeMessage = (cause) => {
36
- if (Predicate.hasProperty(cause, "message") && Predicate.isString(cause.message) && cause.message.length > 0) return cause.message;
37
- try {
38
- return String(cause);
39
- } catch {
40
- return "unknown cause";
41
- }
42
- };
43
- const violationsMessage = (violations) => violations.map((violation) => `${violation.path}: ${violation.message}`).join("; ");
44
- //#endregion
45
- export { WorkerEnvironment as a, WorkerConfig as i, violationsMessage as n, Environment_exports as r, causeMessage as t };
34
+ export { Environment_exports, WorkerConfig, WorkerEnvironment };
@@ -1,5 +1,8 @@
1
- import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
2
- import { Context, Effect, Layer } from "effect";
1
+ import { WorkerEnvironment } from "./Environment.mjs";
2
+ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
+ import * as Context$1 from "effect/Context";
4
+ import * as Effect from "effect/Effect";
5
+ import { Layer } from "effect";
3
6
  declare namespace Hyperdrive_d_exports {
4
7
  export { HyperdriveClient, HyperdriveDefinition, HyperdriveService, LayerOptions, Tag, TagClass, isHyperdrive, layer, make, makeClient };
5
8
  }
@@ -20,14 +23,14 @@ interface HyperdriveService<Id extends string> {
20
23
  type LayerOptions = {
21
24
  readonly binding: string;
22
25
  };
23
- interface TagClass<Self, Id extends string> extends Context.ServiceClass<Self, Id, HyperdriveClient> {
26
+ interface TagClass<Self, Id extends string> extends Context$1.ServiceClass<Self, Id, HyperdriveClient> {
24
27
  readonly id: Id;
25
28
  readonly layer: (options: LayerOptions) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
26
29
  }
27
30
  declare const isHyperdrive: <Candidate>(value: Candidate) => value is Candidate & Hyperdrive;
28
31
  declare const makeClient: (definition: HyperdriveDefinition) => (hyperdrive: Hyperdrive) => HyperdriveClient;
29
- declare const layer: <Self>(tag: Context.Service<Self, HyperdriveClient>, definition: HyperdriveDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
32
+ declare const layer: <Self>(tag: Context$1.Service<Self, HyperdriveClient>, definition: HyperdriveDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
30
33
  declare const make: <Id extends string>(id: Id) => TagClass<HyperdriveService<Id>, Id>;
31
34
  declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
32
35
  //#endregion
33
- export { LayerOptions as n, TagClass as r, Hyperdrive_d_exports as t };
36
+ export { HyperdriveClient, HyperdriveDefinition, HyperdriveService, Hyperdrive_d_exports, LayerOptions, Tag, TagClass, isHyperdrive, layer, make, makeClient };
@@ -0,0 +1,32 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { layer as layer$1 } from "./Binding.mjs";
3
+ import * as Context from "effect/Context";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Predicate from "effect/Predicate";
6
+ //#region src/Hyperdrive.ts
7
+ var Hyperdrive_exports = /* @__PURE__ */ __exportAll({
8
+ Tag: () => Tag,
9
+ isHyperdrive: () => isHyperdrive,
10
+ layer: () => layer,
11
+ make: () => make,
12
+ makeClient: () => makeClient
13
+ });
14
+ const expectedHyperdrive = "Hyperdrive binding with connectionString";
15
+ const isHyperdrive = (value) => Predicate.hasProperty(value, "connectionString") && Predicate.isString(value.connectionString);
16
+ const makeClient = (definition) => (hyperdrive) => ({
17
+ definition,
18
+ connectionString: hyperdrive.connectionString,
19
+ rawUnsafe: Effect.succeed(hyperdrive)
20
+ });
21
+ const layer = (tag, definition) => layer$1(tag, definition.binding, isHyperdrive, makeClient(definition), { expected: expectedHyperdrive });
22
+ const make = (id) => Tag()(id);
23
+ const Tag = () => (id) => {
24
+ const tag = Context.Service()(id);
25
+ const makeLayer = (definition) => layer(tag, definition);
26
+ return Object.assign(tag, {
27
+ id,
28
+ layer: makeLayer
29
+ });
30
+ };
31
+ //#endregion
32
+ export { Hyperdrive_exports, Tag, isHyperdrive, layer, make, makeClient };
@@ -1,6 +1,7 @@
1
- import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
2
- import { n as LayerOptions, r as TagClass } from "./Hyperdrive-HrwFlZ6x.mjs";
3
- import { Layer } from "effect";
1
+ import { WorkerEnvironment } from "./Environment.mjs";
2
+ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
+ import { LayerOptions, TagClass } from "./Hyperdrive.mjs";
4
+ import * as Layer from "effect/Layer";
4
5
  import { PgClient } from "@effect/sql-pg";
5
6
  import { SqlClient, SqlError } from "effect/unstable/sql";
6
7
  //#region src/HyperdrivePg.d.ts
@@ -1,5 +1,7 @@
1
- import { Effect, Layer, Redacted } from "effect";
1
+ import * as Effect from "effect/Effect";
2
+ import * as Layer from "effect/Layer";
2
3
  import { PgClient } from "@effect/sql-pg";
4
+ import * as Redacted from "effect/Redacted";
3
5
  //#region src/HyperdrivePg.ts
4
6
  const layer = (tag, binding, options) => PgClient.layerFrom(Effect.flatMap(tag, (hyperdrive) => PgClient.makeClient({
5
7
  ...options,
@@ -0,0 +1,191 @@
1
+ import { WorkerEnvironment } from "./Environment.mjs";
2
+ import { BindingNotFoundError, BindingValidationError } from "./Binding.mjs";
3
+ import * as Context$1 from "effect/Context";
4
+ import * as Data from "effect/Data";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Option from "effect/Option";
7
+ import { Layer } from "effect";
8
+ declare namespace Images_d_exports {
9
+ export { DrawStepOptions, HostedImagesClient, ImageDirectUploadOptions, ImageDirectUploadResult, ImageDrawOptions, ImageHandleClient, ImageInfoResponse, ImageInputOptions, ImageInputValue, ImageList, ImageListOptions, ImageMetadata, ImageOutputOptions, ImageSignedUrlOptions, ImageTransform, ImageTransformationOutputOptions, ImageTransformationResponseOptions, ImageTransformationResult, ImageUpdateOptions, ImageUploadOptions, ImageUploadValue, ImagesClient, ImagesDefinition, ImagesOperationError, ImagesRuntimeBinding, ImagesService, ImagesTransformationResultClient, LayerOptions, ProcessOptions, Step, Steps, Tag, TagClass, TextOptions, TypeId, draw, empty, isImagesBinding, layer, make, makeClient, transform };
10
+ }
11
+ declare const TypeId: "~effect-cf/Images/Steps";
12
+ type TypeId = typeof TypeId;
13
+ declare const ImagesOperationError_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 & {
14
+ readonly _tag: "ImagesOperationError";
15
+ } & Readonly<A>;
16
+ declare class ImagesOperationError extends ImagesOperationError_base<{
17
+ readonly binding: string;
18
+ readonly operation: string;
19
+ readonly cause: unknown;
20
+ }> {
21
+ get message(): string;
22
+ }
23
+ interface ImagesDefinition {
24
+ readonly binding: string;
25
+ }
26
+ type ImageInfoResponse = CloudflareImageInfoResponse;
27
+ type ImageTransform = CloudflareImageTransform;
28
+ type ImageDrawOptions = CloudflareImageDrawOptions;
29
+ type ImageInputOptions = CloudflareImageInputOptions;
30
+ type ImageOutputOptions = CloudflareImageOutputOptions;
31
+ type ImageTransformationOutputOptions = CloudflareImageTransformationOutputOptions;
32
+ type ImageTransformationResponseOptions = CloudflareImageTransformationResponseOptions;
33
+ type ImageTransformationResult = CloudflareImageTransformationResult;
34
+ type ImageUploadOptions = CloudflareImageUploadOptions;
35
+ type ImageUpdateOptions = CloudflareImageUpdateOptions;
36
+ type ImageListOptions = CloudflareImageListOptions;
37
+ type ImageList = CloudflareImageList;
38
+ type ImageMetadata = CloudflareImageMetadata;
39
+ type ImageSignedUrlOptions = CloudflareImageSignedUrlOptions;
40
+ type ImageDirectUploadOptions = CloudflareImageDirectUploadOptions;
41
+ type ImageDirectUploadResult = CloudflareImageDirectUploadResult;
42
+ type TextOptions = CloudflareTextOptions;
43
+ type ImageInputValue = ReadableStream<Uint8Array> | ArrayBuffer;
44
+ type ImageUploadValue = ReadableStream<Uint8Array> | ArrayBuffer;
45
+ interface DrawStepOptions {
46
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
47
+ readonly options?: ImageDrawOptions;
48
+ }
49
+ type Step = Data.TaggedEnum<{
50
+ readonly Transform: {
51
+ readonly transform: ImageTransform;
52
+ };
53
+ readonly Draw: DrawStepOptions;
54
+ }>;
55
+ declare const Step: {
56
+ readonly $is: <Tag extends "Draw" | "Transform">(tag: Tag) => (u: unknown) => u is Extract<{
57
+ readonly _tag: "Draw";
58
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
59
+ readonly options?: ImageDrawOptions;
60
+ }, {
61
+ readonly _tag: Tag;
62
+ }> | Extract<{
63
+ readonly _tag: "Transform";
64
+ readonly transform: ImageTransform;
65
+ }, {
66
+ readonly _tag: Tag;
67
+ }>;
68
+ readonly $match: {
69
+ <Cases extends { readonly [Tag in "Draw" | "Transform"]: (args: Extract<{
70
+ readonly _tag: "Draw";
71
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
72
+ readonly options?: ImageDrawOptions;
73
+ } | {
74
+ readonly _tag: "Transform";
75
+ readonly transform: ImageTransform;
76
+ }, {
77
+ readonly _tag: Tag;
78
+ }>) => any; }>(cases: Cases): (value: {
79
+ readonly _tag: "Draw";
80
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
81
+ readonly options?: ImageDrawOptions;
82
+ } | {
83
+ readonly _tag: "Transform";
84
+ readonly transform: ImageTransform;
85
+ }) => import("effect/Unify").Unify<ReturnType<Cases["Draw" | "Transform"]>>;
86
+ <Cases extends { readonly [Tag in "Draw" | "Transform"]: (args: Extract<{
87
+ readonly _tag: "Draw";
88
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
89
+ readonly options?: ImageDrawOptions;
90
+ } | {
91
+ readonly _tag: "Transform";
92
+ readonly transform: ImageTransform;
93
+ }, {
94
+ readonly _tag: Tag;
95
+ }>) => any; }>(value: {
96
+ readonly _tag: "Draw";
97
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
98
+ readonly options?: ImageDrawOptions;
99
+ } | {
100
+ readonly _tag: "Transform";
101
+ readonly transform: ImageTransform;
102
+ }, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Draw" | "Transform"]>>;
103
+ };
104
+ readonly Draw: Data.TaggedEnum.ConstructorFrom<{
105
+ readonly _tag: "Draw";
106
+ readonly image: ReadableStream<Uint8Array> | CloudflareImageTransformer;
107
+ readonly options?: ImageDrawOptions;
108
+ }, "_tag">;
109
+ readonly Transform: Data.TaggedEnum.ConstructorFrom<{
110
+ readonly _tag: "Transform";
111
+ readonly transform: ImageTransform;
112
+ }, "_tag">;
113
+ };
114
+ interface Steps {
115
+ readonly [TypeId]: typeof TypeId;
116
+ readonly steps: ReadonlyArray<Step>;
117
+ }
118
+ type ProcessOptions = {
119
+ readonly stream: ImageInputValue;
120
+ readonly inputOptions?: ImageInputOptions;
121
+ readonly outputOptions: ImageOutputOptions;
122
+ } | {
123
+ readonly text: string;
124
+ readonly textOptions: TextOptions;
125
+ readonly outputOptions: ImageOutputOptions;
126
+ };
127
+ interface ImagesTransformationResultClient {
128
+ readonly raw: CloudflareImageTransformationResult;
129
+ readonly response: (options?: ImageTransformationResponseOptions) => Effect.Effect<CloudflareResponse, ImagesOperationError>;
130
+ readonly contentType: Effect.Effect<string, ImagesOperationError>;
131
+ readonly image: (options?: ImageTransformationOutputOptions) => Effect.Effect<ReadableStream<Uint8Array>, ImagesOperationError>;
132
+ }
133
+ interface ImageHandleClient {
134
+ readonly raw: CloudflareImageHandle;
135
+ readonly details: Effect.Effect<Option.Option<ImageMetadata>, ImagesOperationError>;
136
+ readonly bytes: Effect.Effect<Option.Option<ReadableStream<Uint8Array>>, ImagesOperationError>;
137
+ readonly signedUrl: (options: ImageSignedUrlOptions) => Effect.Effect<string, ImagesOperationError>;
138
+ readonly update: (options: ImageUpdateOptions) => Effect.Effect<ImageMetadata, ImagesOperationError>;
139
+ readonly delete: Effect.Effect<boolean, ImagesOperationError>;
140
+ }
141
+ interface HostedImagesClient {
142
+ readonly image: (imageId: string) => ImageHandleClient;
143
+ readonly upload: (image: ImageUploadValue, options?: ImageUploadOptions) => Effect.Effect<ImageMetadata, ImagesOperationError>;
144
+ readonly list: (options?: ImageListOptions) => Effect.Effect<ImageList, ImagesOperationError>;
145
+ readonly createDirectUpload: (options?: ImageDirectUploadOptions) => Effect.Effect<ImageDirectUploadResult, ImagesOperationError>;
146
+ readonly rawUnsafe: Effect.Effect<CloudflareHostedImagesBinding>;
147
+ }
148
+ interface ImagesRuntimeBinding {
149
+ readonly info: (image: ImageInputValue, options?: ImageInputOptions) => Promise<ImageInfoResponse>;
150
+ readonly input: (image: ImageInputValue, options?: ImageInputOptions) => CloudflareImageTransformer;
151
+ readonly text?: (content: string, options: TextOptions) => CloudflareImageTransformer;
152
+ readonly hosted?: CloudflareHostedImagesBinding;
153
+ }
154
+ interface ImagesClient {
155
+ readonly info: (image: ImageInputValue, options?: ImageInputOptions) => Effect.Effect<ImageInfoResponse, ImagesOperationError>;
156
+ readonly input: (image: ImageInputValue, options?: ImageInputOptions) => Effect.Effect<CloudflareImageTransformer, ImagesOperationError>;
157
+ readonly text: (content: string, options: TextOptions) => Effect.Effect<CloudflareImageTransformer, ImagesOperationError>;
158
+ readonly process: (steps: Steps, options: ProcessOptions) => Effect.Effect<ImagesTransformationResultClient, ImagesOperationError>;
159
+ readonly hosted: Option.Option<HostedImagesClient>;
160
+ readonly rawUnsafe: Effect.Effect<ImagesRuntimeBinding>;
161
+ readonly definition: ImagesDefinition;
162
+ }
163
+ declare const ImagesServiceTypeId: unique symbol;
164
+ interface ImagesService<Id extends string> {
165
+ readonly [ImagesServiceTypeId]: {
166
+ readonly id: Id;
167
+ };
168
+ }
169
+ type LayerOptions = {
170
+ readonly binding: string;
171
+ };
172
+ interface TagClass<Self, Id extends string> extends Context$1.ServiceClass<Self, Id, ImagesClient> {
173
+ readonly id: Id;
174
+ readonly layer: (options: LayerOptions) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
175
+ }
176
+ declare const empty: Steps;
177
+ declare const transform: {
178
+ (transform: ImageTransform): (steps: Steps) => Steps;
179
+ (steps: Steps, transform: ImageTransform): Steps;
180
+ };
181
+ declare const draw: {
182
+ (draw: DrawStepOptions): (steps: Steps) => Steps;
183
+ (steps: Steps, draw: DrawStepOptions): Steps;
184
+ };
185
+ declare const isImagesBinding: <Candidate>(value: Candidate) => value is Candidate & ImagesRuntimeBinding;
186
+ declare const makeClient: (definition: ImagesDefinition) => (images: ImagesRuntimeBinding) => ImagesClient;
187
+ declare const layer: <Self>(tag: Context$1.Service<Self, ImagesClient>, definition: ImagesDefinition) => Layer.Layer<Self, BindingNotFoundError | BindingValidationError, WorkerEnvironment>;
188
+ declare const make: <Id extends string>(id: Id) => TagClass<ImagesService<Id>, Id>;
189
+ declare const Tag: <Self>() => <Id extends string>(id: Id) => TagClass<Self, Id>;
190
+ //#endregion
191
+ export { DrawStepOptions, HostedImagesClient, ImageDirectUploadOptions, ImageDirectUploadResult, ImageDrawOptions, ImageHandleClient, ImageInfoResponse, ImageInputOptions, ImageInputValue, ImageList, ImageListOptions, ImageMetadata, ImageOutputOptions, ImageSignedUrlOptions, ImageTransform, ImageTransformationOutputOptions, ImageTransformationResponseOptions, ImageTransformationResult, ImageUpdateOptions, ImageUploadOptions, ImageUploadValue, ImagesClient, ImagesDefinition, ImagesOperationError, ImagesRuntimeBinding, ImagesService, ImagesTransformationResultClient, Images_d_exports, LayerOptions, ProcessOptions, Step, Steps, Tag, TagClass, TextOptions, TypeId, draw, empty, isImagesBinding, layer, make, makeClient, transform };