@theholocron/cloudflare-client 1.58.0-alpha.1 → 1.58.0-alpha.11

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/dist/index.d.mts CHANGED
@@ -1,6 +1,8 @@
1
1
  import "@theholocron/http-client";
2
2
  import { ErrorSink, Logger } from "@theholocron/observability/core";
3
+ /** Options for `createCloudflareClient`. */
3
4
  interface CloudflareClientOptions {
5
+ /** A Cloudflare API token, sent as a bearer token. */
4
6
  token: string;
5
7
  /** Override base URL for testing. Defaults to https://api.cloudflare.com/client/v4 */
6
8
  baseUrl?: string;
@@ -15,110 +17,190 @@ interface CloudflareClientOptions {
15
17
  /** Milliseconds before the first retry; each later one waits three times as long. Defaults to 300. */
16
18
  retryDelayMs?: number;
17
19
  }
20
+ /** The `{ success, errors, result }` envelope Cloudflare wraps every JSON response in. */
18
21
  interface CfEnvelope<T> {
22
+ /** Whether Cloudflare reports the call as successful. */
19
23
  success: boolean;
24
+ /** The errors Cloudflare reports, empty on success. */
20
25
  errors: unknown[];
26
+ /** The payload of the call. */
21
27
  result: T;
22
28
  }
29
+ /** The DNS record types the client accepts. */
23
30
  type CfDnsRecordType = "A" | "AAAA" | "CNAME" | "TXT" | "MX" | "NS" | "SRV" | "CAA";
31
+ /** A DNS record in a Cloudflare zone. */
24
32
  interface CfDnsRecord {
33
+ /** The record's identifier. */
25
34
  id: string;
35
+ /** The record type. */
26
36
  type: CfDnsRecordType;
37
+ /** The record's name (hostname). */
27
38
  name: string;
39
+ /** The record's content, such as an IP address or target hostname. */
28
40
  content: string;
41
+ /** The time to live in seconds; `1` means automatic. */
29
42
  ttl: number;
43
+ /** Whether traffic goes through Cloudflare's proxy. */
30
44
  proxied: boolean;
31
45
  }
46
+ /** The fields for creating or updating a DNS record. */
32
47
  interface CfDnsRecordInput {
48
+ /** The record type. */
33
49
  type: CfDnsRecordType;
50
+ /** The record's name (hostname). */
34
51
  name: string;
52
+ /** The record's content, such as an IP address or target hostname. */
35
53
  content: string;
54
+ /** The time to live in seconds. When creating, defaults to `1` (automatic). */
36
55
  ttl?: number;
56
+ /** Whether to proxy traffic through Cloudflare. When creating, defaults to `false`. */
37
57
  proxied?: boolean;
38
58
  }
59
+ /** How a Pages environment variable is stored: as plain text or as an encrypted secret. */
39
60
  type CfPagesEnvVarType = "plain_text" | "secret_text";
61
+ /** An environment variable on a Pages project. */
40
62
  interface CfPagesEnvVar {
63
+ /** The variable's value. */
41
64
  value: string;
65
+ /** Whether the variable is plain text or a secret. */
42
66
  type: CfPagesEnvVarType;
43
67
  }
68
+ /** The configuration of one Pages deployment environment. */
44
69
  interface CfPagesEnvConfig {
70
+ /** The environment variables, keyed by name. */
45
71
  env_vars: Record<string, CfPagesEnvVar>;
46
72
  }
73
+ /** A Cloudflare Pages project. */
47
74
  interface CfPagesProject {
75
+ /** The project's identifier. */
48
76
  id: string;
77
+ /** The project's name. */
49
78
  name: string;
79
+ /** The project's `pages.dev` subdomain. */
50
80
  subdomain: string;
81
+ /** The domains the project is served on. */
51
82
  domains: string[];
83
+ /** The branch that deploys to production. */
52
84
  production_branch: string;
85
+ /** The per-environment deployment configuration. */
53
86
  deployment_configs: {
87
+ /** The configuration used for preview deployments. */
54
88
  preview: CfPagesEnvConfig;
89
+ /** The configuration used for production deployments. */
55
90
  production: CfPagesEnvConfig;
56
91
  };
57
92
  }
93
+ /** The fields for creating a Pages project. */
58
94
  interface CfPagesProjectInput {
95
+ /** The project's name. */
59
96
  name: string;
97
+ /** The branch that deploys to production. */
60
98
  production_branch: string;
61
99
  }
100
+ /** One stage of a Pages deployment. */
62
101
  interface CfPagesDeploymentStage {
102
+ /** The stage's name. */
63
103
  name: string;
104
+ /** The stage's status. */
64
105
  status: "idle" | "active" | "canceled" | "success" | "failure";
65
106
  }
107
+ /** A custom domain attached to a Pages project. */
66
108
  interface CfPagesDomain {
109
+ /** The domain's identifier. */
67
110
  id: string;
111
+ /** The domain's hostname. */
68
112
  name: string;
113
+ /** The domain's verification and certificate status. */
69
114
  status: "active" | "pending" | "blocked" | "error" | "moved" | "pending_tls";
70
115
  }
116
+ /** A deployment of a Pages project. */
71
117
  interface CfPagesDeployment {
118
+ /** The deployment's identifier. */
72
119
  id: string;
120
+ /** The URL the deployment is served at. */
73
121
  url: string;
122
+ /** The environment the deployment belongs to. */
74
123
  environment: "preview" | "production";
124
+ /** What triggered the deployment. */
75
125
  deployment_trigger: {
126
+ /** The kind of trigger. */
76
127
  type: string;
128
+ /** Details of the commit that triggered the deployment. */
77
129
  metadata: {
130
+ /** The branch that was deployed. */
78
131
  branch: string;
132
+ /** The commit that was deployed. */
79
133
  commit_hash: string;
80
134
  };
81
135
  };
136
+ /** The deployment's most recent stage. */
82
137
  latest_stage: CfPagesDeploymentStage;
138
+ /** When the deployment was created, as an ISO 8601 string. */
83
139
  created_on: string;
84
140
  }
141
+ /** A Cloudflare zone (a domain on the account). */
85
142
  interface CfZone {
143
+ /** The zone's identifier. */
86
144
  id: string;
145
+ /** The zone's domain name. */
87
146
  name: string;
147
+ /** The zone's status, as Cloudflare reports it. */
88
148
  status: string;
89
149
  }
150
+ /** A Cloudflare Tunnel. */
90
151
  interface CfTunnel {
152
+ /** The tunnel's identifier. */
91
153
  id: string;
154
+ /** The tunnel's name. */
92
155
  name: string;
93
156
  }
157
+ /** One ingress rule of a tunnel's configuration. */
94
158
  interface CfIngressRule {
159
+ /** The hostname the rule matches; omitted for the catch-all rule. */
95
160
  hostname?: string;
161
+ /** The origin service requests are sent to. */
96
162
  service: string;
163
+ /** The path the rule matches, when it is limited to one. */
97
164
  path?: string;
98
165
  }
166
+ /** A tunnel's configuration. */
99
167
  interface CfTunnelConfig {
168
+ /** The ingress rules, evaluated in order. */
100
169
  ingress: CfIngressRule[];
101
170
  }
171
+ /** The result of verifying the API token in use. */
102
172
  interface CfTokenVerification {
173
+ /** The token's identifier. */
103
174
  id: string;
175
+ /** Whether the token is active, disabled or expired. */
104
176
  status: "active" | "disabled" | "expired";
105
177
  }
178
+ /** A route that sends matching requests to a Worker. */
106
179
  interface CfWorkerRoute {
180
+ /** The route's identifier. */
107
181
  id: string;
182
+ /** The URL pattern the route matches. */
108
183
  pattern: string;
184
+ /** The name of the Worker script, or `null` when the route is bound to none. */
109
185
  script: string | null;
110
186
  }
111
187
  /** https://developers.cloudflare.com/api/operations/worker-script-put-encrypted-secret-binding */
112
188
  interface CfWorkerSecret {
189
+ /** The secret's name. */
113
190
  name: string;
191
+ /** The binding type, always `"secret_text"`. */
114
192
  type: "secret_text";
115
193
  }
116
194
  /** https://developers.cloudflare.com/api/operations/worker-script-list-workers */
117
195
  interface CfWorkerScript {
196
+ /** The script's name. */
118
197
  id: string;
198
+ /** When the script was created, as an ISO 8601 string. */
119
199
  created_on?: string;
200
+ /** When the script was last modified, as an ISO 8601 string. */
120
201
  modified_on?: string;
121
202
  }
203
+ /** Creates a Cloudflare API client with `dns`, `pages`, `zones`, `tunnels`, `tokens` and `workers` groups. */
122
204
  export declare function createCloudflareClient(opts: CloudflareClientOptions): {
123
205
  dns: {
124
206
  list: (zoneId: string, query?: {
@@ -177,5 +259,6 @@ export declare function createCloudflareClient(opts: CloudflareClientOptions): {
177
259
  deleteSecret: (accountId: string, scriptName: string, name: string) => Promise<void>;
178
260
  };
179
261
  };
262
+ /** The client returned by `createCloudflareClient`. */
180
263
  export type CloudflareClient = ReturnType<typeof createCloudflareClient>;
181
264
  export type { CfDnsRecord, CfDnsRecordInput, CfDnsRecordType, CfEnvelope, CfIngressRule, CfPagesDeployment, CfPagesDeploymentStage, CfPagesDomain, CfPagesEnvConfig, CfPagesEnvVar, CfPagesEnvVarType, CfPagesProject, CfPagesProjectInput, CfTokenVerification, CfTunnel, CfTunnelConfig, CfWorkerRoute, CfWorkerScript, CfWorkerSecret, CfZone, CloudflareClientOptions };
package/dist/index.mjs CHANGED
@@ -145,6 +145,7 @@ function zones(rest) {
145
145
  }) };
146
146
  }
147
147
  // src/index.ts
148
+ /** Creates a Cloudflare API client with `dns`, `pages`, `zones`, `tunnels`, `tokens` and `workers` groups. */
148
149
  function createCloudflareClient(opts) {
149
150
  const rest = createCloudflareRestClient(opts);
150
151
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/cloudflare-client",
3
- "version": "1.58.0-alpha.1",
3
+ "version": "1.58.0-alpha.11",
4
4
  "description": "A TypeScript client for the Cloudflare API",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -32,23 +32,23 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@theholocron/http-client": "^1.58.0-alpha.1",
36
- "@theholocron/observability": "^0.6.1-alpha.1"
35
+ "@theholocron/http-client": "^1.58.0-alpha.11",
36
+ "@theholocron/observability": "^0.7.0-alpha.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26",
40
40
  "@vitest/coverage-v8": "^5.0.5",
41
- "@vitest/eslint-plugin": "^1.6.27",
42
- "eslint": "^10.8.1",
43
- "eslint-plugin-n": "^18.3.0",
44
- "globals": "^17.11.0",
45
- "tsdown": "^0.23.3",
41
+ "@vitest/eslint-plugin": "^1.6.28",
42
+ "eslint": "^10.14.0",
43
+ "eslint-plugin-n": "^18.5.0",
44
+ "globals": "^17.14.0",
45
+ "tsdown": "^0.23.4",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^5.0.5",
48
- "@theholocron/eslint-config": "^8.9.0-alpha.3",
49
- "@theholocron/vitest-config": "^8.9.0-alpha.3",
50
- "@theholocron/tsdown-config": "^8.9.0-alpha.3",
51
- "@theholocron/tsconfig": "^8.9.0-alpha.3"
48
+ "@theholocron/eslint-config": "^8.9.0-alpha.8",
49
+ "@theholocron/tsconfig": "^8.9.0-alpha.8",
50
+ "@theholocron/vitest-config": "^8.9.0-alpha.8",
51
+ "@theholocron/tsdown-config": "^8.9.0-alpha.8"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22.0.0"
@@ -57,10 +57,10 @@
57
57
  "access": "public"
58
58
  },
59
59
  "scripts": {
60
- "delivery.build": "tsdown && node ../scripts/check-bundle-size.mjs",
61
- "sourceQuality.staticAnalysis": "eslint .",
60
+ "build": "tsdown && node ../scripts/check-bundle-size.mjs",
61
+ "lint:code": "eslint .",
62
+ "test:unit": "vitest run --coverage",
62
63
  "test:watch": "vitest",
63
- "verification.typeSafety": "tsc --noEmit",
64
- "verification.unitTests": "vitest run"
64
+ "typecheck": "tsc --noEmit"
65
65
  }
66
66
  }