@distilled.cloud/cloudflare 0.7.2 → 0.7.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/cloudflare",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -63,7 +63,7 @@
63
63
  "specs:update": "git -C specs/cloudflare-typescript fetch && git -C specs/cloudflare-typescript checkout main && git -C specs/cloudflare-typescript pull"
64
64
  },
65
65
  "dependencies": {
66
- "@distilled.cloud/core": "0.7.2",
66
+ "@distilled.cloud/core": "0.7.4",
67
67
  "effect": "4.0.0-beta.38"
68
68
  },
69
69
  "devDependencies": {
package/src/client/api.ts CHANGED
@@ -55,18 +55,20 @@ const GLOBAL_ERROR_CODE_MAP: Record<number, (message: string) => unknown> = {
55
55
  */
56
56
  function httpStatusError(status: number, body?: string): unknown {
57
57
  const ErrorClass = HTTP_STATUS_MAP[status as keyof typeof HTTP_STATUS_MAP];
58
+ const message = body ?? String(status);
58
59
  if (ErrorClass) {
59
- return new ErrorClass({ message: body ?? String(status) });
60
+ return new ErrorClass({ message });
60
61
  }
61
62
  // For unmapped 5xx codes (e.g., Cloudflare-specific 520-530), use
62
63
  // InternalServerError so they get ServerError + Retryable categories
63
64
  if (status >= 500) {
64
- return new InternalServerError({ message: body ?? String(status) });
65
+ return new InternalServerError({ message });
65
66
  }
66
67
  return new CloudflareHttpError({
67
68
  status,
68
69
  statusText: String(status),
69
70
  body,
71
+ message,
70
72
  });
71
73
  }
72
74
 
@@ -181,17 +183,17 @@ const matchError = (
181
183
  errorBody !== null &&
182
184
  "_nonJsonError" in errorBody;
183
185
  if (isNonJsonError) {
186
+ const message = String((errorBody as any).body);
184
187
  // For 5xx errors, return a properly categorized error so retries work
185
188
  if (status >= 500) {
186
- return Effect.fail(
187
- httpStatusError(status, String((errorBody as any).body)),
188
- );
189
+ return Effect.fail(httpStatusError(status, message));
189
190
  }
190
191
  return Effect.fail(
191
192
  new CloudflareHttpError({
192
193
  status,
193
194
  statusText: String(status),
194
- body: String((errorBody as any).body),
195
+ body: message,
196
+ message,
195
197
  }),
196
198
  );
197
199
  }
@@ -234,6 +236,7 @@ const matchError = (
234
236
  status,
235
237
  statusText: String(status),
236
238
  body: bodyStr,
239
+ message: bodyStr,
237
240
  }),
238
241
  );
239
242
  }
@@ -304,13 +307,13 @@ const matchError = (
304
307
  */
305
308
  class CloudflareDecodeError extends CloudflareHttpError {
306
309
  constructor(props: { body: unknown; cause: unknown }) {
310
+ const message =
311
+ typeof props.body === "string" ? props.body : JSON.stringify(props.body);
307
312
  super({
308
313
  status: 200,
309
314
  statusText: "Schema decode failed",
310
- body:
311
- typeof props.body === "string"
312
- ? props.body
313
- : JSON.stringify(props.body),
315
+ body: message,
316
+ message,
314
317
  });
315
318
  }
316
319
  }
package/src/errors.ts CHANGED
@@ -52,6 +52,7 @@ export class CloudflareHttpError extends Schema.TaggedErrorClass<CloudflareHttpE
52
52
  {
53
53
  status: Schema.Number,
54
54
  statusText: Schema.String,
55
+ message: Schema.String,
55
56
  body: Schema.optional(Schema.String),
56
57
  },
57
58
  ) {}
@@ -72,7 +72,7 @@ export interface GetContainerApplicationResponse {
72
72
  schedulingPolicy: "moon" | "gpu" | "regional" | "fill_metals" | "default";
73
73
  instances: number;
74
74
  maxInstances: number;
75
- constraints: { tier?: number | null };
75
+ constraints?: { tier?: number | null } | null;
76
76
  affinities?: { colocation?: "datacenter" | null } | null;
77
77
  configuration: {
78
78
  image: string;
@@ -151,9 +151,14 @@ export const GetContainerApplicationResponse =
151
151
  ]),
152
152
  instances: Schema.Number,
153
153
  maxInstances: Schema.Number,
154
- constraints: Schema.Struct({
155
- tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
156
- }),
154
+ constraints: Schema.optional(
155
+ Schema.Union([
156
+ Schema.Struct({
157
+ tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
158
+ }),
159
+ Schema.Null,
160
+ ]),
161
+ ),
157
162
  affinities: Schema.optional(
158
163
  Schema.Union([
159
164
  Schema.Struct({
@@ -449,7 +454,7 @@ export type ListContainerApplicationsResponse = {
449
454
  schedulingPolicy: "moon" | "gpu" | "regional" | "fill_metals" | "default";
450
455
  instances: number;
451
456
  maxInstances: number;
452
- constraints: { tier?: number | null };
457
+ constraints?: { tier?: number | null } | null;
453
458
  affinities?: { colocation?: "datacenter" | null } | null;
454
459
  configuration: {
455
460
  image: string;
@@ -529,9 +534,14 @@ export const ListContainerApplicationsResponse =
529
534
  ]),
530
535
  instances: Schema.Number,
531
536
  maxInstances: Schema.Number,
532
- constraints: Schema.Struct({
533
- tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
534
- }),
537
+ constraints: Schema.optional(
538
+ Schema.Union([
539
+ Schema.Struct({
540
+ tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
541
+ }),
542
+ Schema.Null,
543
+ ]),
544
+ ),
535
545
  affinities: Schema.optional(
536
546
  Schema.Union([
537
547
  Schema.Struct({
@@ -1060,7 +1070,7 @@ export interface CreateContainerApplicationResponse {
1060
1070
  schedulingPolicy: "moon" | "gpu" | "regional" | "fill_metals" | "default";
1061
1071
  instances: number;
1062
1072
  maxInstances: number;
1063
- constraints: { tier?: number | null };
1073
+ constraints?: { tier?: number | null } | null;
1064
1074
  affinities?: { colocation?: "datacenter" | null } | null;
1065
1075
  configuration: {
1066
1076
  image: string;
@@ -1139,9 +1149,14 @@ export const CreateContainerApplicationResponse =
1139
1149
  ]),
1140
1150
  instances: Schema.Number,
1141
1151
  maxInstances: Schema.Number,
1142
- constraints: Schema.Struct({
1143
- tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
1144
- }),
1152
+ constraints: Schema.optional(
1153
+ Schema.Union([
1154
+ Schema.Struct({
1155
+ tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
1156
+ }),
1157
+ Schema.Null,
1158
+ ]),
1159
+ ),
1145
1160
  affinities: Schema.optional(
1146
1161
  Schema.Union([
1147
1162
  Schema.Struct({
@@ -1739,7 +1754,7 @@ export interface UpdateContainerApplicationResponse {
1739
1754
  schedulingPolicy: "moon" | "gpu" | "regional" | "fill_metals" | "default";
1740
1755
  instances: number;
1741
1756
  maxInstances: number;
1742
- constraints: { tier?: number | null };
1757
+ constraints?: { tier?: number | null } | null;
1743
1758
  affinities?: { colocation?: "datacenter" | null } | null;
1744
1759
  configuration: {
1745
1760
  image: string;
@@ -1818,9 +1833,14 @@ export const UpdateContainerApplicationResponse =
1818
1833
  ]),
1819
1834
  instances: Schema.Number,
1820
1835
  maxInstances: Schema.Number,
1821
- constraints: Schema.Struct({
1822
- tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
1823
- }),
1836
+ constraints: Schema.optional(
1837
+ Schema.Union([
1838
+ Schema.Struct({
1839
+ tier: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
1840
+ }),
1841
+ Schema.Null,
1842
+ ]),
1843
+ ),
1824
1844
  affinities: Schema.optional(
1825
1845
  Schema.Union([
1826
1846
  Schema.Struct({
@@ -6893,6 +6893,7 @@ export interface PutScriptRequest {
6893
6893
  | { service: string; environment?: string; namespace?: string }[]
6894
6894
  | null;
6895
6895
  usageModel?: "standard" | "bundled" | "unbound";
6896
+ containers?: { className: string }[];
6896
6897
  };
6897
6898
  /** Body param: An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.<br/ */
6898
6899
  files?: (File | Blob)[];
@@ -7373,6 +7374,13 @@ export const PutScriptRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
7373
7374
  usageModel: Schema.optional(
7374
7375
  Schema.Literals(["standard", "bundled", "unbound"]),
7375
7376
  ),
7377
+ containers: Schema.optional(
7378
+ Schema.Array(
7379
+ Schema.Struct({
7380
+ className: Schema.String,
7381
+ }).pipe(Schema.encodeKeys({ className: "class_name" })),
7382
+ ),
7383
+ ),
7376
7384
  }).pipe(
7377
7385
  Schema.encodeKeys({
7378
7386
  assets: "assets",
@@ -7391,6 +7399,7 @@ export const PutScriptRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
7391
7399
  tags: "tags",
7392
7400
  tailConsumers: "tail_consumers",
7393
7401
  usageModel: "usage_model",
7402
+ containers: "containers",
7394
7403
  }),
7395
7404
  ),
7396
7405
  files: Schema.optional(