@distilled.cloud/cloudflare 0.12.4 → 0.12.6
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/lib/client/api.d.ts.map +1 -1
- package/lib/client/api.js +23 -1
- package/lib/client/api.js.map +1 -1
- package/lib/services/workers.d.ts +44 -0
- package/lib/services/workers.d.ts.map +1 -1
- package/lib/services/workers.js +55 -0
- package/lib/services/workers.js.map +1 -1
- package/package.json +2 -2
- package/src/client/api.ts +25 -0
- package/src/services/workers.ts +66 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/cloudflare",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
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.12.
|
|
66
|
+
"@distilled.cloud/core": "0.12.6",
|
|
67
67
|
"effect": "4.0.0-beta.48"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
package/src/client/api.ts
CHANGED
|
@@ -24,9 +24,11 @@ import {
|
|
|
24
24
|
import { getPath, type RequestParts } from "@distilled.cloud/core/traits";
|
|
25
25
|
import {
|
|
26
26
|
CloudflareHttpError,
|
|
27
|
+
Forbidden,
|
|
27
28
|
HTTP_STATUS_MAP,
|
|
28
29
|
InternalServerError,
|
|
29
30
|
TooManyRequests,
|
|
31
|
+
Unauthorized,
|
|
30
32
|
UnknownCloudflareError,
|
|
31
33
|
} from "../errors.ts";
|
|
32
34
|
import { Credentials, formatHeaders } from "../credentials.ts";
|
|
@@ -43,6 +45,20 @@ import { type ErrorMatcher, getErrorMatchers } from "../traits.ts";
|
|
|
43
45
|
const GLOBAL_ERROR_CODE_MAP: Record<number, (message: string) => unknown> = {
|
|
44
46
|
// "Please wait and consider throttling your request speed"
|
|
45
47
|
971: (message) => new TooManyRequests({ message }),
|
|
48
|
+
// Authentication-related error codes — surfaced regardless of HTTP status
|
|
49
|
+
// (Cloudflare frequently returns these inside a 400 envelope rather than 401).
|
|
50
|
+
// 6003: Invalid request headers (e.g. missing/invalid auth headers)
|
|
51
|
+
6003: (message) => new Unauthorized({ message }),
|
|
52
|
+
// 9103: Unknown X-Auth-Key
|
|
53
|
+
9103: (message) => new Unauthorized({ message }),
|
|
54
|
+
// 9106: X-Auth-Key header missing
|
|
55
|
+
9106: (message) => new Unauthorized({ message }),
|
|
56
|
+
// 9109: Unauthorized to access requested resource / Max auth failures reached
|
|
57
|
+
9109: (message) => new Unauthorized({ message }),
|
|
58
|
+
// 10000: Authentication error / Authentication failed
|
|
59
|
+
10000: (message) => new Unauthorized({ message }),
|
|
60
|
+
// 10001: Method not allowed for token (authorization, not authentication)
|
|
61
|
+
10001: (message) => new Forbidden({ message }),
|
|
46
62
|
};
|
|
47
63
|
|
|
48
64
|
/**
|
|
@@ -292,6 +308,15 @@ const matchError = (
|
|
|
292
308
|
return Effect.fail(GLOBAL_ERROR_CODE_MAP[errorCode](errorMessage));
|
|
293
309
|
}
|
|
294
310
|
|
|
311
|
+
// Heuristic fallback:
|
|
312
|
+
// Map by HTTP status as a last resort (e.g. envelope with status 401/403).
|
|
313
|
+
if (status === 401) {
|
|
314
|
+
return Effect.fail(new Unauthorized({ message: errorMessage }));
|
|
315
|
+
}
|
|
316
|
+
if (status === 403) {
|
|
317
|
+
return Effect.fail(new Forbidden({ message: errorMessage }));
|
|
318
|
+
}
|
|
319
|
+
|
|
295
320
|
// No match — return unknown Cloudflare error
|
|
296
321
|
return Effect.fail(
|
|
297
322
|
new UnknownCloudflareError({
|
package/src/services/workers.ts
CHANGED
|
@@ -1011,6 +1011,7 @@ export interface GetBetaWorkerVersionResponse {
|
|
|
1011
1011
|
}
|
|
1012
1012
|
| { name: string; part: string; type: "wasm_module" }
|
|
1013
1013
|
| { name: string; type: "worker_loader" }
|
|
1014
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
1014
1015
|
)[]
|
|
1015
1016
|
| null;
|
|
1016
1017
|
/** Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. */
|
|
@@ -1420,6 +1421,11 @@ export const GetBetaWorkerVersionResponse =
|
|
|
1420
1421
|
name: Schema.String,
|
|
1421
1422
|
type: Schema.Literal("worker_loader"),
|
|
1422
1423
|
}),
|
|
1424
|
+
Schema.Struct({
|
|
1425
|
+
name: Schema.String,
|
|
1426
|
+
type: Schema.Literal("artifacts"),
|
|
1427
|
+
namespace: Schema.String,
|
|
1428
|
+
}),
|
|
1423
1429
|
]),
|
|
1424
1430
|
),
|
|
1425
1431
|
Schema.Null,
|
|
@@ -1740,6 +1746,7 @@ export interface ListBetaWorkerVersionsResponse {
|
|
|
1740
1746
|
}
|
|
1741
1747
|
| { name: string; part: string; type: "wasm_module" }
|
|
1742
1748
|
| { name: string; type: "worker_loader" }
|
|
1749
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
1743
1750
|
)[]
|
|
1744
1751
|
| null;
|
|
1745
1752
|
compatibilityDate?: string | null;
|
|
@@ -2158,6 +2165,11 @@ export const ListBetaWorkerVersionsResponse =
|
|
|
2158
2165
|
name: Schema.String,
|
|
2159
2166
|
type: Schema.Literal("worker_loader"),
|
|
2160
2167
|
}),
|
|
2168
|
+
Schema.Struct({
|
|
2169
|
+
name: Schema.String,
|
|
2170
|
+
type: Schema.Literal("artifacts"),
|
|
2171
|
+
namespace: Schema.String,
|
|
2172
|
+
}),
|
|
2161
2173
|
]),
|
|
2162
2174
|
),
|
|
2163
2175
|
Schema.Null,
|
|
@@ -2476,6 +2488,7 @@ export interface CreateBetaWorkerVersionRequest {
|
|
|
2476
2488
|
}
|
|
2477
2489
|
| { name: string; part: string; type: "wasm_module" }
|
|
2478
2490
|
| { name: string; type: "worker_loader" }
|
|
2491
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
2479
2492
|
)[];
|
|
2480
2493
|
/** Body param: Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. */
|
|
2481
2494
|
compatibilityDate?: string;
|
|
@@ -2831,6 +2844,11 @@ export const CreateBetaWorkerVersionRequest =
|
|
|
2831
2844
|
name: Schema.String,
|
|
2832
2845
|
type: Schema.Literal("worker_loader"),
|
|
2833
2846
|
}),
|
|
2847
|
+
Schema.Struct({
|
|
2848
|
+
name: Schema.String,
|
|
2849
|
+
type: Schema.Literal("artifacts"),
|
|
2850
|
+
namespace: Schema.String,
|
|
2851
|
+
}),
|
|
2834
2852
|
]),
|
|
2835
2853
|
),
|
|
2836
2854
|
),
|
|
@@ -3103,6 +3121,7 @@ export interface CreateBetaWorkerVersionResponse {
|
|
|
3103
3121
|
}
|
|
3104
3122
|
| { name: string; part: string; type: "wasm_module" }
|
|
3105
3123
|
| { name: string; type: "worker_loader" }
|
|
3124
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
3106
3125
|
)[]
|
|
3107
3126
|
| null;
|
|
3108
3127
|
/** Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. */
|
|
@@ -3512,6 +3531,11 @@ export const CreateBetaWorkerVersionResponse =
|
|
|
3512
3531
|
name: Schema.String,
|
|
3513
3532
|
type: Schema.Literal("worker_loader"),
|
|
3514
3533
|
}),
|
|
3534
|
+
Schema.Struct({
|
|
3535
|
+
name: Schema.String,
|
|
3536
|
+
type: Schema.Literal("artifacts"),
|
|
3537
|
+
namespace: Schema.String,
|
|
3538
|
+
}),
|
|
3515
3539
|
]),
|
|
3516
3540
|
),
|
|
3517
3541
|
Schema.Null,
|
|
@@ -6554,6 +6578,7 @@ export interface PutScriptRequest {
|
|
|
6554
6578
|
}
|
|
6555
6579
|
| { name: string; part: string; type: "wasm_module" }
|
|
6556
6580
|
| { name: string; type: "worker_loader" }
|
|
6581
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
6557
6582
|
)[];
|
|
6558
6583
|
bodyPart?: string;
|
|
6559
6584
|
compatibilityDate?: string;
|
|
@@ -6921,6 +6946,11 @@ export const PutScriptRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
|
|
|
6921
6946
|
name: Schema.String,
|
|
6922
6947
|
type: Schema.Literal("worker_loader"),
|
|
6923
6948
|
}),
|
|
6949
|
+
Schema.Struct({
|
|
6950
|
+
name: Schema.String,
|
|
6951
|
+
type: Schema.Literal("artifacts"),
|
|
6952
|
+
namespace: Schema.String,
|
|
6953
|
+
}),
|
|
6924
6954
|
]),
|
|
6925
6955
|
),
|
|
6926
6956
|
),
|
|
@@ -9567,6 +9597,7 @@ export interface GetScriptScriptAndVersionSettingResponse {
|
|
|
9567
9597
|
}
|
|
9568
9598
|
| { name: string; part: string; type: "wasm_module" }
|
|
9569
9599
|
| { name: string; type: "worker_loader" }
|
|
9600
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
9570
9601
|
)[]
|
|
9571
9602
|
| null;
|
|
9572
9603
|
/** Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. */
|
|
@@ -9892,6 +9923,11 @@ export const GetScriptScriptAndVersionSettingResponse =
|
|
|
9892
9923
|
name: Schema.String,
|
|
9893
9924
|
type: Schema.Literal("worker_loader"),
|
|
9894
9925
|
}),
|
|
9926
|
+
Schema.Struct({
|
|
9927
|
+
name: Schema.String,
|
|
9928
|
+
type: Schema.Literal("artifacts"),
|
|
9929
|
+
namespace: Schema.String,
|
|
9930
|
+
}),
|
|
9895
9931
|
]),
|
|
9896
9932
|
),
|
|
9897
9933
|
Schema.Null,
|
|
@@ -10105,6 +10141,7 @@ export interface PatchScriptScriptAndVersionSettingRequest {
|
|
|
10105
10141
|
}
|
|
10106
10142
|
| { name: string; part: string; type: "wasm_module" }
|
|
10107
10143
|
| { name: string; type: "worker_loader" }
|
|
10144
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
10108
10145
|
)[];
|
|
10109
10146
|
compatibilityDate?: string;
|
|
10110
10147
|
compatibilityFlags?: string[];
|
|
@@ -10434,6 +10471,11 @@ export const PatchScriptScriptAndVersionSettingRequest =
|
|
|
10434
10471
|
name: Schema.String,
|
|
10435
10472
|
type: Schema.Literal("worker_loader"),
|
|
10436
10473
|
}),
|
|
10474
|
+
Schema.Struct({
|
|
10475
|
+
name: Schema.String,
|
|
10476
|
+
type: Schema.Literal("artifacts"),
|
|
10477
|
+
namespace: Schema.String,
|
|
10478
|
+
}),
|
|
10437
10479
|
]),
|
|
10438
10480
|
),
|
|
10439
10481
|
),
|
|
@@ -10735,6 +10777,7 @@ export interface PatchScriptScriptAndVersionSettingResponse {
|
|
|
10735
10777
|
}
|
|
10736
10778
|
| { name: string; part: string; type: "wasm_module" }
|
|
10737
10779
|
| { name: string; type: "worker_loader" }
|
|
10780
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
10738
10781
|
)[]
|
|
10739
10782
|
| null;
|
|
10740
10783
|
/** Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. */
|
|
@@ -11060,6 +11103,11 @@ export const PatchScriptScriptAndVersionSettingResponse =
|
|
|
11060
11103
|
name: Schema.String,
|
|
11061
11104
|
type: Schema.Literal("worker_loader"),
|
|
11062
11105
|
}),
|
|
11106
|
+
Schema.Struct({
|
|
11107
|
+
name: Schema.String,
|
|
11108
|
+
type: Schema.Literal("artifacts"),
|
|
11109
|
+
namespace: Schema.String,
|
|
11110
|
+
}),
|
|
11063
11111
|
]),
|
|
11064
11112
|
),
|
|
11065
11113
|
Schema.Null,
|
|
@@ -12351,6 +12399,7 @@ export interface GetScriptVersionResponse {
|
|
|
12351
12399
|
}
|
|
12352
12400
|
| { name: string; part: string; type: "wasm_module" }
|
|
12353
12401
|
| { name: string; type: "worker_loader" }
|
|
12402
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
12354
12403
|
)[]
|
|
12355
12404
|
| null;
|
|
12356
12405
|
script?: {
|
|
@@ -12688,6 +12737,11 @@ export const GetScriptVersionResponse =
|
|
|
12688
12737
|
name: Schema.String,
|
|
12689
12738
|
type: Schema.Literal("worker_loader"),
|
|
12690
12739
|
}),
|
|
12740
|
+
Schema.Struct({
|
|
12741
|
+
name: Schema.String,
|
|
12742
|
+
type: Schema.Literal("artifacts"),
|
|
12743
|
+
namespace: Schema.String,
|
|
12744
|
+
}),
|
|
12691
12745
|
]),
|
|
12692
12746
|
),
|
|
12693
12747
|
Schema.Null,
|
|
@@ -13098,6 +13152,7 @@ export interface CreateScriptVersionRequest {
|
|
|
13098
13152
|
}
|
|
13099
13153
|
| { name: string; part: string; type: "wasm_module" }
|
|
13100
13154
|
| { name: string; type: "worker_loader" }
|
|
13155
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
13101
13156
|
)[];
|
|
13102
13157
|
compatibilityDate?: string;
|
|
13103
13158
|
compatibilityFlags?: string[];
|
|
@@ -13390,6 +13445,11 @@ export const CreateScriptVersionRequest =
|
|
|
13390
13445
|
name: Schema.String,
|
|
13391
13446
|
type: Schema.Literal("worker_loader"),
|
|
13392
13447
|
}),
|
|
13448
|
+
Schema.Struct({
|
|
13449
|
+
name: Schema.String,
|
|
13450
|
+
type: Schema.Literal("artifacts"),
|
|
13451
|
+
namespace: Schema.String,
|
|
13452
|
+
}),
|
|
13393
13453
|
]),
|
|
13394
13454
|
),
|
|
13395
13455
|
),
|
|
@@ -13519,6 +13579,7 @@ export interface CreateScriptVersionResponse {
|
|
|
13519
13579
|
}
|
|
13520
13580
|
| { name: string; part: string; type: "wasm_module" }
|
|
13521
13581
|
| { name: string; type: "worker_loader" }
|
|
13582
|
+
| { name: string; type: "artifacts"; namespace: string }
|
|
13522
13583
|
)[]
|
|
13523
13584
|
| null;
|
|
13524
13585
|
script?: {
|
|
@@ -13858,6 +13919,11 @@ export const CreateScriptVersionResponse =
|
|
|
13858
13919
|
name: Schema.String,
|
|
13859
13920
|
type: Schema.Literal("worker_loader"),
|
|
13860
13921
|
}),
|
|
13922
|
+
Schema.Struct({
|
|
13923
|
+
name: Schema.String,
|
|
13924
|
+
type: Schema.Literal("artifacts"),
|
|
13925
|
+
namespace: Schema.String,
|
|
13926
|
+
}),
|
|
13861
13927
|
]),
|
|
13862
13928
|
),
|
|
13863
13929
|
Schema.Null,
|