@distilled.cloud/cloudflare 0.26.1 → 0.27.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 (45) hide show
  1. package/lib/client/api.d.ts.map +1 -1
  2. package/lib/client/api.js +15 -7
  3. package/lib/client/api.js.map +1 -1
  4. package/lib/services/ai-gateway.d.ts +7 -1
  5. package/lib/services/ai-gateway.d.ts.map +1 -1
  6. package/lib/services/ai-gateway.js +3 -1
  7. package/lib/services/ai-gateway.js.map +1 -1
  8. package/lib/services/aisearch.d.ts +7 -1
  9. package/lib/services/aisearch.d.ts.map +1 -1
  10. package/lib/services/aisearch.js +6 -0
  11. package/lib/services/aisearch.js.map +1 -1
  12. package/lib/services/api-gateway.d.ts +1 -1
  13. package/lib/services/api-gateway.d.ts.map +1 -1
  14. package/lib/services/api-gateway.js +1 -1
  15. package/lib/services/api-gateway.js.map +1 -1
  16. package/lib/services/cache.d.ts +7 -1
  17. package/lib/services/cache.d.ts.map +1 -1
  18. package/lib/services/cache.js +6 -1
  19. package/lib/services/cache.js.map +1 -1
  20. package/lib/services/iam.d.ts +7 -1
  21. package/lib/services/iam.d.ts.map +1 -1
  22. package/lib/services/iam.js +6 -1
  23. package/lib/services/iam.js.map +1 -1
  24. package/lib/services/r2.d.ts +7 -1
  25. package/lib/services/r2.d.ts.map +1 -1
  26. package/lib/services/r2.js +13 -1
  27. package/lib/services/r2.js.map +1 -1
  28. package/lib/services/workers.d.ts +7 -1
  29. package/lib/services/workers.d.ts.map +1 -1
  30. package/lib/services/workers.js +6 -1
  31. package/lib/services/workers.js.map +1 -1
  32. package/lib/services/zero-trust.d.ts +9 -3
  33. package/lib/services/zero-trust.d.ts.map +1 -1
  34. package/lib/services/zero-trust.js +8 -6
  35. package/lib/services/zero-trust.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/client/api.ts +15 -8
  38. package/src/services/ai-gateway.ts +13 -2
  39. package/src/services/aisearch.ts +10 -0
  40. package/src/services/api-gateway.ts +2 -2
  41. package/src/services/cache.ts +11 -2
  42. package/src/services/iam.ts +13 -2
  43. package/src/services/r2.ts +20 -2
  44. package/src/services/workers.ts +11 -2
  45. package/src/services/zero-trust.ts +23 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/cloudflare",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -64,7 +64,7 @@
64
64
  "specs:update": "git -C specs/cloudflare-typescript fetch && git -C specs/cloudflare-typescript checkout main && git -C specs/cloudflare-typescript pull"
65
65
  },
66
66
  "dependencies": {
67
- "@distilled.cloud/core": "0.26.1"
67
+ "@distilled.cloud/core": "0.27.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@effect/platform-node": ">=4.0.0-beta.66 || >=4.0.0",
package/src/client/api.ts CHANGED
@@ -112,14 +112,21 @@ const GLOBAL_ERROR_CODE_MAP: Record<
112
112
  // globally keeps tests for unknown-resource cases off UnknownCloudflareError.
113
113
  7003: (message) => new InvalidRoute({ code: 7003, message }),
114
114
  // 1000: dual-use code. Cloudflare uses it for several unrelated conditions,
115
- // but the "Request timeout" variant is unambiguous from the message and is
116
- // a transient, retryable failure. Map only that variant to GatewayTimeout
117
- // (retryable + server error); fall back to UnknownCloudflareError for
118
- // anything else carried under code 1000 to preserve existing behavior.
119
- 1000: (message) =>
120
- /\btimeout\b/i.test(message)
121
- ? new GatewayTimeout({ message })
122
- : new UnknownCloudflareError({ code: 1000, message }),
115
+ // each unambiguous from the message and each a transient, retryable server
116
+ // failure:
117
+ // - "Request timeout" -> GatewayTimeout
118
+ // - "Internal Server Error" -> InternalServerError
119
+ // Fall back to UnknownCloudflareError for anything else carried under code
120
+ // 1000 to preserve existing behavior.
121
+ 1000: (message) => {
122
+ if (/\btimeout\b/i.test(message)) {
123
+ return new GatewayTimeout({ message });
124
+ }
125
+ if (/internal (server )?error/i.test(message)) {
126
+ return new InternalServerError({ message });
127
+ }
128
+ return new UnknownCloudflareError({ code: 1000, message });
129
+ },
123
130
  };
124
131
 
125
132
  /**
@@ -16,6 +16,14 @@ import { type DefaultErrors } from "../errors.ts";
16
16
  // Errors
17
17
  // =============================================================================
18
18
 
19
+ export class AiGatewaySpendingLimitDeprecated extends T.applyErrorMatchers(
20
+ Schema.TaggedErrorClass<AiGatewaySpendingLimitDeprecated>()(
21
+ "AiGatewaySpendingLimitDeprecated",
22
+ { code: Schema.Number, message: Schema.String },
23
+ ),
24
+ [{ message: { includes: "spending limits are deprecated" } }],
25
+ ) {}
26
+
19
27
  export class DatasetNameAlreadyExists extends T.applyErrorMatchers(
20
28
  Schema.TaggedErrorClass<DatasetNameAlreadyExists>()(
21
29
  "DatasetNameAlreadyExists",
@@ -4265,7 +4273,10 @@ export const CreateBillingSpendingLimitResponse =
4265
4273
  Schema.Unknown.pipe(T.ResponsePath("result")),
4266
4274
  ) as unknown as Schema.Schema<CreateBillingSpendingLimitResponse>;
4267
4275
 
4268
- export type CreateBillingSpendingLimitError = DefaultErrors | NoManualTopup;
4276
+ export type CreateBillingSpendingLimitError =
4277
+ | DefaultErrors
4278
+ | NoManualTopup
4279
+ | AiGatewaySpendingLimitDeprecated;
4269
4280
 
4270
4281
  export const createBillingSpendingLimit: API.OperationMethod<
4271
4282
  CreateBillingSpendingLimitRequest,
@@ -4275,7 +4286,7 @@ export const createBillingSpendingLimit: API.OperationMethod<
4275
4286
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
4276
4287
  input: CreateBillingSpendingLimitRequest,
4277
4288
  output: CreateBillingSpendingLimitResponse,
4278
- errors: [NoManualTopup],
4289
+ errors: [NoManualTopup, AiGatewaySpendingLimitDeprecated],
4279
4290
  }));
4280
4291
 
4281
4292
  export interface DeleteBillingSpendingLimitRequest {
@@ -60,6 +60,14 @@ export class InvalidTokenCredentials extends T.applyErrorMatchers(
60
60
  [{ code: 7012 }, { status: 400, message: { includes: "invalid_token" } }],
61
61
  ) {}
62
62
 
63
+ export class MissingSitemap extends T.applyErrorMatchers(
64
+ Schema.TaggedErrorClass<MissingSitemap>()("MissingSitemap", {
65
+ code: Schema.Number,
66
+ message: Schema.String,
67
+ }),
68
+ [{ status: 400, message: { includes: "missing_sitemap" } }],
69
+ ) {}
70
+
63
71
  export class NamespaceAlreadyExists extends T.applyErrorMatchers(
64
72
  Schema.TaggedErrorClass<NamespaceAlreadyExists>()("NamespaceAlreadyExists", {
65
73
  code: Schema.Number,
@@ -10505,6 +10513,7 @@ export type CreateNamespaceInstanceError =
10505
10513
  | InstanceAlreadyExists
10506
10514
  | InvalidTokenCredentials
10507
10515
  | WebCrawlerDomainNotOwned
10516
+ | MissingSitemap
10508
10517
  | Forbidden;
10509
10518
 
10510
10519
  export const createNamespaceInstance: API.OperationMethod<
@@ -10523,6 +10532,7 @@ export const createNamespaceInstance: API.OperationMethod<
10523
10532
  InstanceAlreadyExists,
10524
10533
  InvalidTokenCredentials,
10525
10534
  WebCrawlerDomainNotOwned,
10535
+ MissingSitemap,
10526
10536
  Forbidden,
10527
10537
  ],
10528
10538
  }));
@@ -5135,7 +5135,7 @@ export const ListUserSchemasResponse =
5135
5135
  }).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" })),
5136
5136
  ) as unknown as Schema.Schema<ListUserSchemasResponse>;
5137
5137
 
5138
- export type ListUserSchemasError = DefaultErrors | Forbidden;
5138
+ export type ListUserSchemasError = DefaultErrors | ZonePurged | Forbidden;
5139
5139
 
5140
5140
  export const listUserSchemas: API.PaginatedOperationMethod<
5141
5141
  ListUserSchemasRequest,
@@ -5145,7 +5145,7 @@ export const listUserSchemas: API.PaginatedOperationMethod<
5145
5145
  > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
5146
5146
  input: ListUserSchemasRequest,
5147
5147
  output: ListUserSchemasResponse,
5148
- errors: [Forbidden],
5148
+ errors: [ZonePurged, Forbidden],
5149
5149
  pagination: {
5150
5150
  mode: "page",
5151
5151
  inputToken: "page",
@@ -43,6 +43,14 @@ export class SettingUnavailableForPlan extends T.applyErrorMatchers(
43
43
  ],
44
44
  ) {}
45
45
 
46
+ export class Unauthorized extends T.applyErrorMatchers(
47
+ Schema.TaggedErrorClass<Unauthorized>()("Unauthorized", {
48
+ code: Schema.Number,
49
+ message: Schema.String,
50
+ }),
51
+ [{ status: 401 }],
52
+ ) {}
53
+
46
54
  export class VariantsNotConfigured extends T.applyErrorMatchers(
47
55
  Schema.TaggedErrorClass<VariantsNotConfigured>()("VariantsNotConfigured", {
48
56
  code: Schema.Number,
@@ -1022,7 +1030,8 @@ export const GetRegionalTieredCacheResponse =
1022
1030
  export type GetRegionalTieredCacheError =
1023
1031
  | DefaultErrors
1024
1032
  | SettingUnavailableForPlan
1025
- | Forbidden;
1033
+ | Forbidden
1034
+ | Unauthorized;
1026
1035
 
1027
1036
  export const getRegionalTieredCache: API.OperationMethod<
1028
1037
  GetRegionalTieredCacheRequest,
@@ -1032,7 +1041,7 @@ export const getRegionalTieredCache: API.OperationMethod<
1032
1041
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
1033
1042
  input: GetRegionalTieredCacheRequest,
1034
1043
  output: GetRegionalTieredCacheResponse,
1035
- errors: [SettingUnavailableForPlan, Forbidden],
1044
+ errors: [SettingUnavailableForPlan, Forbidden, Unauthorized],
1036
1045
  }));
1037
1046
 
1038
1047
  export interface PatchRegionalTieredCacheRequest {
@@ -32,6 +32,14 @@ export class InvalidMember extends T.applyErrorMatchers(
32
32
  [{ code: 400 }],
33
33
  ) {}
34
34
 
35
+ export class PolicyValidationFailed extends T.applyErrorMatchers(
36
+ Schema.TaggedErrorClass<PolicyValidationFailed>()("PolicyValidationFailed", {
37
+ code: Schema.Number,
38
+ message: Schema.String,
39
+ }),
40
+ [{ status: 400, message: { includes: "Policy validation failed" } }],
41
+ ) {}
42
+
35
43
  export class ResourceGroupNotFound extends T.applyErrorMatchers(
36
44
  Schema.TaggedErrorClass<ResourceGroupNotFound>()("ResourceGroupNotFound", {
37
45
  code: Schema.Number,
@@ -3247,7 +3255,10 @@ export const ListUserGroupMembersResponse =
3247
3255
  }).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" })),
3248
3256
  ) as unknown as Schema.Schema<ListUserGroupMembersResponse>;
3249
3257
 
3250
- export type ListUserGroupMembersError = DefaultErrors | UserGroupNotFound;
3258
+ export type ListUserGroupMembersError =
3259
+ | DefaultErrors
3260
+ | UserGroupNotFound
3261
+ | PolicyValidationFailed;
3251
3262
 
3252
3263
  export const listUserGroupMembers: API.PaginatedOperationMethod<
3253
3264
  ListUserGroupMembersRequest,
@@ -3257,7 +3268,7 @@ export const listUserGroupMembers: API.PaginatedOperationMethod<
3257
3268
  > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
3258
3269
  input: ListUserGroupMembersRequest,
3259
3270
  output: ListUserGroupMembersResponse,
3260
- errors: [UserGroupNotFound],
3271
+ errors: [UserGroupNotFound, PolicyValidationFailed],
3261
3272
  pagination: {
3262
3273
  mode: "page",
3263
3274
  inputToken: "page",
@@ -141,6 +141,14 @@ export class NoSuchBucket extends T.applyErrorMatchers(
141
141
  [{ code: 10006 }],
142
142
  ) {}
143
143
 
144
+ export class NoSuchKey extends T.applyErrorMatchers(
145
+ Schema.TaggedErrorClass<NoSuchKey>()("NoSuchKey", {
146
+ code: Schema.Number,
147
+ message: Schema.String,
148
+ }),
149
+ [{ status: 404, message: { includes: "specified key does not exist" } }],
150
+ ) {}
151
+
144
152
  export class QueueNotFound extends T.applyErrorMatchers(
145
153
  Schema.TaggedErrorClass<QueueNotFound>()("QueueNotFound", {
146
154
  code: Schema.Number,
@@ -3475,7 +3483,10 @@ export type GetObjectError =
3475
3483
  | DefaultErrors
3476
3484
  | NoSuchBucket
3477
3485
  | InvalidRoute
3478
- | NoRoute;
3486
+ | NoRoute
3487
+ | NoSuchKey
3488
+ | NoSuchBucket
3489
+ | InvalidRoute;
3479
3490
 
3480
3491
  export const getObject: API.OperationMethod<
3481
3492
  GetObjectRequest,
@@ -3485,7 +3496,14 @@ export const getObject: API.OperationMethod<
3485
3496
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
3486
3497
  input: GetObjectRequest,
3487
3498
  output: GetObjectResponse,
3488
- errors: [NoSuchBucket, InvalidRoute, NoRoute],
3499
+ errors: [
3500
+ NoSuchBucket,
3501
+ InvalidRoute,
3502
+ NoRoute,
3503
+ NoSuchKey,
3504
+ NoSuchBucket,
3505
+ InvalidRoute,
3506
+ ],
3489
3507
  }));
3490
3508
 
3491
3509
  export interface ListObjectsRequest {
@@ -202,6 +202,14 @@ export class VersionNotFound extends T.applyErrorMatchers(
202
202
  [{ code: 100146 }],
203
203
  ) {}
204
204
 
205
+ export class WorkerHasNoVersions extends T.applyErrorMatchers(
206
+ Schema.TaggedErrorClass<WorkerHasNoVersions>()("WorkerHasNoVersions", {
207
+ code: Schema.Number,
208
+ message: Schema.String,
209
+ }),
210
+ [{ status: 404, message: { includes: "has no versions" } }],
211
+ ) {}
212
+
205
213
  export class WorkerNotFound extends T.applyErrorMatchers(
206
214
  Schema.TaggedErrorClass<WorkerNotFound>()("WorkerNotFound", {
207
215
  code: Schema.Number,
@@ -16864,7 +16872,8 @@ export const GetScriptScriptAndVersionSettingResponse =
16864
16872
 
16865
16873
  export type GetScriptScriptAndVersionSettingError =
16866
16874
  | DefaultErrors
16867
- | WorkerNotFound;
16875
+ | WorkerNotFound
16876
+ | WorkerHasNoVersions;
16868
16877
 
16869
16878
  export const getScriptScriptAndVersionSetting: API.OperationMethod<
16870
16879
  GetScriptScriptAndVersionSettingRequest,
@@ -16874,7 +16883,7 @@ export const getScriptScriptAndVersionSetting: API.OperationMethod<
16874
16883
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
16875
16884
  input: GetScriptScriptAndVersionSettingRequest,
16876
16885
  output: GetScriptScriptAndVersionSettingResponse,
16877
- errors: [WorkerNotFound],
16886
+ errors: [WorkerNotFound, WorkerHasNoVersions],
16878
16887
  }));
16879
16888
 
16880
16889
  export interface PatchScriptScriptAndVersionSettingRequest {
@@ -78,6 +78,14 @@ export class AccessIdentityProviderNotFound extends T.applyErrorMatchers(
78
78
  [{ code: 12135 }],
79
79
  ) {}
80
80
 
81
+ export class AccessReferenceNotFound extends T.applyErrorMatchers(
82
+ Schema.TaggedErrorClass<AccessReferenceNotFound>()(
83
+ "AccessReferenceNotFound",
84
+ { code: Schema.Number, message: Schema.String },
85
+ ),
86
+ [{ status: 400, message: { includes: "not found" } }],
87
+ ) {}
88
+
81
89
  export class AccessServiceTokenNotFound extends T.applyErrorMatchers(
82
90
  Schema.TaggedErrorClass<AccessServiceTokenNotFound>()(
83
91
  "AccessServiceTokenNotFound",
@@ -32000,7 +32008,9 @@ export const ListAccessApplicationsResponse =
32000
32008
  }).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" })),
32001
32009
  ) as unknown as Schema.Schema<ListAccessApplicationsResponse>;
32002
32010
 
32003
- export type ListAccessApplicationsError = DefaultErrors;
32011
+ export type ListAccessApplicationsError =
32012
+ | DefaultErrors
32013
+ | AccessReferenceNotFound;
32004
32014
 
32005
32015
  export const listAccessApplicationsForAccount: API.PaginatedOperationMethod<
32006
32016
  ListAccessApplicationsForAccountRequest,
@@ -32010,7 +32020,7 @@ export const listAccessApplicationsForAccount: API.PaginatedOperationMethod<
32010
32020
  > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
32011
32021
  input: ListAccessApplicationsForAccountRequest,
32012
32022
  output: ListAccessApplicationsResponse,
32013
- errors: [],
32023
+ errors: [AccessReferenceNotFound],
32014
32024
  pagination: {
32015
32025
  mode: "page",
32016
32026
  inputToken: "page",
@@ -32028,7 +32038,7 @@ export const listAccessApplicationsForZone: API.PaginatedOperationMethod<
32028
32038
  > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
32029
32039
  input: ListAccessApplicationsForZoneRequest,
32030
32040
  output: ListAccessApplicationsResponse,
32031
- errors: [],
32041
+ errors: [AccessReferenceNotFound],
32032
32042
  pagination: {
32033
32043
  mode: "page",
32034
32044
  inputToken: "page",
@@ -48098,7 +48108,9 @@ export const CreateAccessApplicationResponse =
48098
48108
  ]).pipe(T.ResponsePath("result")),
48099
48109
  ) as unknown as Schema.Schema<CreateAccessApplicationResponse>;
48100
48110
 
48101
- export type CreateAccessApplicationError = DefaultErrors;
48111
+ export type CreateAccessApplicationError =
48112
+ | DefaultErrors
48113
+ | AccessReferenceNotFound;
48102
48114
 
48103
48115
  export const createAccessApplicationForAccount: API.OperationMethod<
48104
48116
  CreateAccessApplicationForAccountRequest,
@@ -48108,7 +48120,7 @@ export const createAccessApplicationForAccount: API.OperationMethod<
48108
48120
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
48109
48121
  input: CreateAccessApplicationForAccountRequest,
48110
48122
  output: CreateAccessApplicationResponse,
48111
- errors: [],
48123
+ errors: [AccessReferenceNotFound],
48112
48124
  }));
48113
48125
 
48114
48126
  export const createAccessApplicationForZone: API.OperationMethod<
@@ -48119,7 +48131,7 @@ export const createAccessApplicationForZone: API.OperationMethod<
48119
48131
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
48120
48132
  input: CreateAccessApplicationForZoneRequest,
48121
48133
  output: CreateAccessApplicationResponse,
48122
- errors: [],
48134
+ errors: [AccessReferenceNotFound],
48123
48135
  }));
48124
48136
 
48125
48137
  const UpdateAccessApplicationBaseFields = {
@@ -64187,7 +64199,9 @@ export const UpdateAccessApplicationResponse =
64187
64199
  ]).pipe(T.ResponsePath("result")),
64188
64200
  ) as unknown as Schema.Schema<UpdateAccessApplicationResponse>;
64189
64201
 
64190
- export type UpdateAccessApplicationError = DefaultErrors;
64202
+ export type UpdateAccessApplicationError =
64203
+ | DefaultErrors
64204
+ | AccessReferenceNotFound;
64191
64205
 
64192
64206
  export const updateAccessApplicationForAccount: API.OperationMethod<
64193
64207
  UpdateAccessApplicationForAccountRequest,
@@ -64197,7 +64211,7 @@ export const updateAccessApplicationForAccount: API.OperationMethod<
64197
64211
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
64198
64212
  input: UpdateAccessApplicationForAccountRequest,
64199
64213
  output: UpdateAccessApplicationResponse,
64200
- errors: [],
64214
+ errors: [AccessReferenceNotFound],
64201
64215
  }));
64202
64216
 
64203
64217
  export const updateAccessApplicationForZone: API.OperationMethod<
@@ -64208,7 +64222,7 @@ export const updateAccessApplicationForZone: API.OperationMethod<
64208
64222
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
64209
64223
  input: UpdateAccessApplicationForZoneRequest,
64210
64224
  output: UpdateAccessApplicationResponse,
64211
- errors: [],
64225
+ errors: [AccessReferenceNotFound],
64212
64226
  }));
64213
64227
 
64214
64228
  const DeleteAccessApplicationBaseFields = {