@distilled.cloud/cloudflare 0.19.0 → 0.19.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 (51) hide show
  1. package/lib/schemas.d.ts +7 -8
  2. package/lib/schemas.d.ts.map +1 -1
  3. package/lib/schemas.js +9 -12
  4. package/lib/schemas.js.map +1 -1
  5. package/lib/services/custom-pages.d.ts +40 -13
  6. package/lib/services/custom-pages.d.ts.map +1 -1
  7. package/lib/services/custom-pages.js +68 -15
  8. package/lib/services/custom-pages.js.map +1 -1
  9. package/lib/services/firewall.d.ts +66 -23
  10. package/lib/services/firewall.d.ts.map +1 -1
  11. package/lib/services/firewall.js +120 -26
  12. package/lib/services/firewall.js.map +1 -1
  13. package/lib/services/intel.d.ts +2 -0
  14. package/lib/services/intel.d.ts.map +1 -1
  15. package/lib/services/intel.js +2 -0
  16. package/lib/services/intel.js.map +1 -1
  17. package/lib/services/logpush.d.ts +157 -64
  18. package/lib/services/logpush.d.ts.map +1 -1
  19. package/lib/services/logpush.js +292 -63
  20. package/lib/services/logpush.js.map +1 -1
  21. package/lib/services/r2.d.ts +29 -2
  22. package/lib/services/r2.d.ts.map +1 -1
  23. package/lib/services/r2.js +20 -6
  24. package/lib/services/r2.js.map +1 -1
  25. package/lib/services/rulesets.d.ts +200 -65
  26. package/lib/services/rulesets.d.ts.map +1 -1
  27. package/lib/services/rulesets.js +371 -75
  28. package/lib/services/rulesets.js.map +1 -1
  29. package/lib/services/security-center.d.ts +66 -19
  30. package/lib/services/security-center.d.ts.map +1 -1
  31. package/lib/services/security-center.js +128 -22
  32. package/lib/services/security-center.js.map +1 -1
  33. package/lib/services/waiting-rooms.d.ts +14 -3
  34. package/lib/services/waiting-rooms.d.ts.map +1 -1
  35. package/lib/services/waiting-rooms.js +25 -7
  36. package/lib/services/waiting-rooms.js.map +1 -1
  37. package/lib/services/zero-trust.d.ts +579 -204
  38. package/lib/services/zero-trust.d.ts.map +1 -1
  39. package/lib/services/zero-trust.js +1159 -268
  40. package/lib/services/zero-trust.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/schemas.ts +19 -17
  43. package/src/services/custom-pages.ts +170 -66
  44. package/src/services/firewall.ts +300 -121
  45. package/src/services/intel.ts +4 -0
  46. package/src/services/logpush.ts +798 -372
  47. package/src/services/r2.ts +66 -9
  48. package/src/services/rulesets.ts +3991 -3426
  49. package/src/services/security-center.ts +247 -63
  50. package/src/services/waiting-rooms.ts +49 -11
  51. package/src/services/zero-trust.ts +4097 -2417
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/cloudflare",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
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.19.0"
66
+ "@distilled.cloud/core": "0.19.1"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@effect/platform-node": ">=4.0.0-beta.60 || >=4.0.0",
package/src/schemas.ts CHANGED
@@ -1,19 +1,35 @@
1
1
  /**
2
2
  * Common schemas for Cloudflare API types.
3
3
  *
4
- * Includes file upload schemas for multipart form-data operations.
4
+ * Cloudflare-specific schemas live here. The cloud-agnostic raw-binary HTTP
5
+ * body schemas (`BinaryBodySchema`, `BinaryStreamResponseSchema`,
6
+ * `Uint8ArraySchema`, etc.) live in `@distilled.cloud/core/schemas` and are
7
+ * re-exported below for convenience.
5
8
  */
6
9
 
7
10
  import * as Schema from "effect/Schema";
11
+ import { BlobSchema } from "@distilled.cloud/core/schemas";
12
+
13
+ export {
14
+ ArrayBufferSchema,
15
+ BinaryBodySchema,
16
+ BinaryStreamResponseSchema,
17
+ BlobSchema,
18
+ ReadableStreamSchema,
19
+ StreamSchema,
20
+ Uint8ArraySchema,
21
+ type BinaryBody,
22
+ } from "@distilled.cloud/core/schemas";
8
23
 
9
24
  // =============================================================================
10
- // File Upload Schemas
25
+ // File Upload Schemas (multipart form-data)
11
26
  // =============================================================================
12
27
 
13
28
  /**
14
29
  * Schema for File objects (browser File API).
15
30
  *
16
- * Used for multipart form-data file uploads.
31
+ * Used for multipart form-data file uploads (e.g. Workers script bundles,
32
+ * Pages assets, brand-protection submissions).
17
33
  */
18
34
  export const FileSchema = Schema.declare(
19
35
  (input): input is File =>
@@ -24,20 +40,6 @@ export const FileSchema = Schema.declare(
24
40
  },
25
41
  );
26
42
 
27
- /**
28
- * Schema for Blob objects.
29
- *
30
- * Used for binary data uploads.
31
- */
32
- export const BlobSchema = Schema.declare(
33
- (input): input is Blob =>
34
- typeof Blob !== "undefined" && input instanceof Blob,
35
- {
36
- identifier: "Blob",
37
- description: "A Blob object for upload",
38
- },
39
- );
40
-
41
43
  /**
42
44
  * Schema for uploadable content (File or Blob).
43
45
  *
@@ -16,7 +16,22 @@ import { type DefaultErrors } from "../errors.ts";
16
16
  // CustomPage
17
17
  // =============================================================================
18
18
 
19
- export interface GetCustomPageRequest {
19
+ const GetCustomPageBaseFields = {
20
+ identifier: Schema.Literals([
21
+ "1000_errors",
22
+ "500_errors",
23
+ "basic_challenge",
24
+ "country_challenge",
25
+ "ip_block",
26
+ "managed_challenge",
27
+ "ratelimit_block",
28
+ "under_attack",
29
+ "waf_block",
30
+ "waf_challenge",
31
+ ]).pipe(T.HttpPath("identifier")),
32
+ } as const;
33
+
34
+ interface GetCustomPageBaseRequest {
20
35
  identifier:
21
36
  | "1000_errors"
22
37
  | "500_errors"
@@ -30,25 +45,37 @@ export interface GetCustomPageRequest {
30
45
  | "waf_challenge";
31
46
  }
32
47
 
33
- export const GetCustomPageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
34
- identifier: Schema.Literals([
35
- "1000_errors",
36
- "500_errors",
37
- "basic_challenge",
38
- "country_challenge",
39
- "ip_block",
40
- "managed_challenge",
41
- "ratelimit_block",
42
- "under_attack",
43
- "waf_block",
44
- "waf_challenge",
45
- ]).pipe(T.HttpPath("identifier")),
46
- }).pipe(
47
- T.Http({
48
- method: "GET",
49
- path: "/{accountOrZone}/{accountOrZoneId}/custom_pages/{identifier}",
50
- }),
51
- ) as unknown as Schema.Schema<GetCustomPageRequest>;
48
+ export interface GetCustomPageForAccountRequest extends GetCustomPageBaseRequest {
49
+ /** Path param: The Account ID to use for this endpoint. */
50
+ accountId: string;
51
+ }
52
+
53
+ export interface GetCustomPageForZoneRequest extends GetCustomPageBaseRequest {
54
+ /** Path param: The Zone ID to use for this endpoint. */
55
+ zoneId: string;
56
+ }
57
+
58
+ export const GetCustomPageForAccountRequest =
59
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
60
+ accountId: Schema.String.pipe(T.HttpPath("account_id")),
61
+ ...GetCustomPageBaseFields,
62
+ }).pipe(
63
+ T.Http({
64
+ method: "GET",
65
+ path: "/accounts/{account_id}/custom_pages/{identifier}",
66
+ }),
67
+ ) as unknown as Schema.Schema<GetCustomPageForAccountRequest>;
68
+
69
+ export const GetCustomPageForZoneRequest =
70
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
71
+ zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
72
+ ...GetCustomPageBaseFields,
73
+ }).pipe(
74
+ T.Http({
75
+ method: "GET",
76
+ path: "/zones/{zone_id}/custom_pages/{identifier}",
77
+ }),
78
+ ) as unknown as Schema.Schema<GetCustomPageForZoneRequest>;
52
79
 
53
80
  export interface GetCustomPageResponse {
54
81
  id?: string | null;
@@ -95,27 +122,57 @@ export const GetCustomPageResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
95
122
 
96
123
  export type GetCustomPageError = DefaultErrors;
97
124
 
98
- export const getCustomPage: API.OperationMethod<
99
- GetCustomPageRequest,
125
+ export const getCustomPageForAccount: API.OperationMethod<
126
+ GetCustomPageForAccountRequest,
100
127
  GetCustomPageResponse,
101
128
  GetCustomPageError,
102
129
  Credentials | HttpClient.HttpClient
103
130
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
104
- input: GetCustomPageRequest,
131
+ input: GetCustomPageForAccountRequest,
105
132
  output: GetCustomPageResponse,
106
133
  errors: [],
107
134
  }));
108
135
 
109
- export interface ListCustomPagesRequest {}
136
+ export const getCustomPageForZone: API.OperationMethod<
137
+ GetCustomPageForZoneRequest,
138
+ GetCustomPageResponse,
139
+ GetCustomPageError,
140
+ Credentials | HttpClient.HttpClient
141
+ > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
142
+ input: GetCustomPageForZoneRequest,
143
+ output: GetCustomPageResponse,
144
+ errors: [],
145
+ }));
110
146
 
111
- export const ListCustomPagesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct(
112
- {},
113
- ).pipe(
114
- T.Http({
115
- method: "GET",
116
- path: "/{accountOrZone}/{accountOrZoneId}/custom_pages",
117
- }),
118
- ) as unknown as Schema.Schema<ListCustomPagesRequest>;
147
+ const ListCustomPagesBaseFields = {} as const;
148
+
149
+ interface ListCustomPagesBaseRequest {}
150
+
151
+ export interface ListCustomPagesForAccountRequest extends ListCustomPagesBaseRequest {
152
+ /** Path param: The Account ID to use for this endpoint. */
153
+ accountId: string;
154
+ }
155
+
156
+ export interface ListCustomPagesForZoneRequest extends ListCustomPagesBaseRequest {
157
+ /** Path param: The Zone ID to use for this endpoint. */
158
+ zoneId: string;
159
+ }
160
+
161
+ export const ListCustomPagesForAccountRequest =
162
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
163
+ accountId: Schema.String.pipe(T.HttpPath("account_id")),
164
+ ...ListCustomPagesBaseFields,
165
+ }).pipe(
166
+ T.Http({ method: "GET", path: "/accounts/{account_id}/custom_pages" }),
167
+ ) as unknown as Schema.Schema<ListCustomPagesForAccountRequest>;
168
+
169
+ export const ListCustomPagesForZoneRequest =
170
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
171
+ zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
172
+ ...ListCustomPagesBaseFields,
173
+ }).pipe(
174
+ T.Http({ method: "GET", path: "/zones/{zone_id}/custom_pages" }),
175
+ ) as unknown as Schema.Schema<ListCustomPagesForZoneRequest>;
119
176
 
120
177
  export interface ListCustomPagesResponse {
121
178
  result: {
@@ -170,13 +227,28 @@ export const ListCustomPagesResponse =
170
227
 
171
228
  export type ListCustomPagesError = DefaultErrors;
172
229
 
173
- export const listCustomPages: API.PaginatedOperationMethod<
174
- ListCustomPagesRequest,
230
+ export const listCustomPagesForAccount: API.PaginatedOperationMethod<
231
+ ListCustomPagesForAccountRequest,
232
+ ListCustomPagesResponse,
233
+ ListCustomPagesError,
234
+ Credentials | HttpClient.HttpClient
235
+ > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
236
+ input: ListCustomPagesForAccountRequest,
237
+ output: ListCustomPagesResponse,
238
+ errors: [],
239
+ pagination: {
240
+ mode: "single",
241
+ items: "result",
242
+ } as const,
243
+ }));
244
+
245
+ export const listCustomPagesForZone: API.PaginatedOperationMethod<
246
+ ListCustomPagesForZoneRequest,
175
247
  ListCustomPagesResponse,
176
248
  ListCustomPagesError,
177
249
  Credentials | HttpClient.HttpClient
178
250
  > = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
179
- input: ListCustomPagesRequest,
251
+ input: ListCustomPagesForZoneRequest,
180
252
  output: ListCustomPagesResponse,
181
253
  errors: [],
182
254
  pagination: {
@@ -185,7 +257,24 @@ export const listCustomPages: API.PaginatedOperationMethod<
185
257
  } as const,
186
258
  }));
187
259
 
188
- export interface PutCustomPageRequest {
260
+ const PutCustomPageBaseFields = {
261
+ identifier: Schema.Literals([
262
+ "1000_errors",
263
+ "500_errors",
264
+ "basic_challenge",
265
+ "country_challenge",
266
+ "ip_block",
267
+ "managed_challenge",
268
+ "ratelimit_block",
269
+ "under_attack",
270
+ "waf_block",
271
+ "waf_challenge",
272
+ ]).pipe(T.HttpPath("identifier")),
273
+ state: Schema.Literals(["default", "customized"]),
274
+ url: Schema.String,
275
+ } as const;
276
+
277
+ interface PutCustomPageBaseRequest {
189
278
  identifier:
190
279
  | "1000_errors"
191
280
  | "500_errors"
@@ -197,39 +286,43 @@ export interface PutCustomPageRequest {
197
286
  | "under_attack"
198
287
  | "waf_block"
199
288
  | "waf_challenge";
200
- /** Path param: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. */
201
- accountId?: string;
202
- /** Path param: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. */
203
- zoneId?: string;
204
289
  /** Body param: The custom page state. */
205
290
  state: "default" | "customized";
206
291
  /** Body param: The URL associated with the custom page. */
207
292
  url: string;
208
293
  }
209
294
 
210
- export const PutCustomPageRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
211
- identifier: Schema.Literals([
212
- "1000_errors",
213
- "500_errors",
214
- "basic_challenge",
215
- "country_challenge",
216
- "ip_block",
217
- "managed_challenge",
218
- "ratelimit_block",
219
- "under_attack",
220
- "waf_block",
221
- "waf_challenge",
222
- ]).pipe(T.HttpPath("identifier")),
223
- accountId: Schema.String.pipe(T.HttpPath("account_id")),
224
- zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
225
- state: Schema.Literals(["default", "customized"]),
226
- url: Schema.String,
227
- }).pipe(
228
- T.Http({
229
- method: "PUT",
230
- path: "/{accountOrZone}/{accountOrZoneId}/custom_pages/{identifier}",
231
- }),
232
- ) as unknown as Schema.Schema<PutCustomPageRequest>;
295
+ export interface PutCustomPageForAccountRequest extends PutCustomPageBaseRequest {
296
+ /** Path param: The Account ID to use for this endpoint. */
297
+ accountId: string;
298
+ }
299
+
300
+ export interface PutCustomPageForZoneRequest extends PutCustomPageBaseRequest {
301
+ /** Path param: The Zone ID to use for this endpoint. */
302
+ zoneId: string;
303
+ }
304
+
305
+ export const PutCustomPageForAccountRequest =
306
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
307
+ accountId: Schema.String.pipe(T.HttpPath("account_id")),
308
+ ...PutCustomPageBaseFields,
309
+ }).pipe(
310
+ T.Http({
311
+ method: "PUT",
312
+ path: "/accounts/{account_id}/custom_pages/{identifier}",
313
+ }),
314
+ ) as unknown as Schema.Schema<PutCustomPageForAccountRequest>;
315
+
316
+ export const PutCustomPageForZoneRequest =
317
+ /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
318
+ zoneId: Schema.String.pipe(T.HttpPath("zone_id")),
319
+ ...PutCustomPageBaseFields,
320
+ }).pipe(
321
+ T.Http({
322
+ method: "PUT",
323
+ path: "/zones/{zone_id}/custom_pages/{identifier}",
324
+ }),
325
+ ) as unknown as Schema.Schema<PutCustomPageForZoneRequest>;
233
326
 
234
327
  export interface PutCustomPageResponse {
235
328
  id?: string | null;
@@ -276,13 +369,24 @@ export const PutCustomPageResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
276
369
 
277
370
  export type PutCustomPageError = DefaultErrors;
278
371
 
279
- export const putCustomPage: API.OperationMethod<
280
- PutCustomPageRequest,
372
+ export const putCustomPageForAccount: API.OperationMethod<
373
+ PutCustomPageForAccountRequest,
374
+ PutCustomPageResponse,
375
+ PutCustomPageError,
376
+ Credentials | HttpClient.HttpClient
377
+ > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
378
+ input: PutCustomPageForAccountRequest,
379
+ output: PutCustomPageResponse,
380
+ errors: [],
381
+ }));
382
+
383
+ export const putCustomPageForZone: API.OperationMethod<
384
+ PutCustomPageForZoneRequest,
281
385
  PutCustomPageResponse,
282
386
  PutCustomPageError,
283
387
  Credentials | HttpClient.HttpClient
284
388
  > = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
285
- input: PutCustomPageRequest,
389
+ input: PutCustomPageForZoneRequest,
286
390
  output: PutCustomPageResponse,
287
391
  errors: [],
288
392
  }));