@theholocron/holocron-plugin-cloudflare 5.0.0-alpha.482 → 5.0.0-alpha.484

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,4 +1,4 @@
1
- import { AuthError, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordRequest, EnsuredTunnel, PluginToken, ResolveTokenInput, TunnelRoute, Tunnels, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, WikiProxyConfig, WorkerScriptState, Workers } from "@theholocron/cli";
1
+ import { AuthError, DeployScriptConfig, DeployScriptResult, Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRecord, DeploymentTarget, DeploymentTrigger, Dns, DnsRecord, DnsRecordRequest, EnsuredTunnel, PluginToken, ResolveTokenInput, TunnelRoute, Tunnels, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess, WikiProxyConfig, WorkerDeploymentState, WorkerScriptState, Workers } from "@theholocron/cli";
2
2
  import { CloudflareClient, CloudflareClient as CloudflareClient$1, CloudflareClientOptions, createCloudflareClient } from "@theholocron/cloudflare-client";
3
3
  /** Resolves the Cloudflare API token from `--token`, `HOLOCRON_CLOUDFLARE_TOKEN`, `CLOUDFLARE_API_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
4
4
  export declare const resolveToken: import("@theholocron/cli").TokenResolver;
@@ -37,6 +37,10 @@ export declare class CloudflareDeployment implements Deployment {
37
37
  listPreviewDeployments(projectId: string, branch: string): Promise<DeploymentRecord[]>;
38
38
  deletePreviewDeployments(projectId: string, deploymentIds: string[]): Promise<number>;
39
39
  ensureCustomDomain(projectId: string, hostname: string): Promise<DnsRecordRequest | null>;
40
+ /** The hostnames attached to the Pages project. Reads only. */
41
+ listDomains(projectId: string): Promise<string[]>;
42
+ /** The newest production deployment of the project, or null. Reads only. */
43
+ latestDeployment(projectId: string): Promise<DeploymentRecord | null>;
40
44
  private getProjectByName;
41
45
  }
42
46
  /** The Cloudflare implementation of the `dns` capability; finds a domain's zone by walking from the domain up to its apex. */
@@ -111,6 +115,9 @@ export declare class CloudflareWorkers implements Workers {
111
115
  * only, and asks Cloudflare for names, so no value is ever fetched.
112
116
  */
113
117
  inspectScript(name: string, host: string): Promise<WorkerScriptState>;
118
+ /** The newest deployment of the script, and whether it serves all traffic. Reads only. */
119
+ latestDeployment(script: string): Promise<WorkerDeploymentState | null>;
120
+ proxyScriptName(hostname: string): string;
114
121
  /** Idempotent create-or-update for one route pattern — shared by both public methods. */
115
122
  private upsertRoute;
116
123
  private resolveZone;
package/dist/index.mjs CHANGED
@@ -127,6 +127,19 @@ var CloudflareDeployment = class {
127
127
  await this.client().pages.addDomain(this.accountId, projectId, hostname);
128
128
  return null;
129
129
  }
130
+ /** The hostnames attached to the Pages project. Reads only. */
131
+ async listDomains(projectId) {
132
+ return (await this.client().pages.listDomains(this.accountId, projectId)).map((d) => d.name);
133
+ }
134
+ /** The newest production deployment of the project, or null. Reads only. */
135
+ async latestDeployment(projectId) {
136
+ const [newest] = (await this.client().pages.listDeployments(this.accountId, projectId)).filter((d) => d.environment === "production").sort((a, b) => b.created_on.localeCompare(a.created_on));
137
+ if (!newest) return null;
138
+ return {
139
+ ...mapDeployment(newest, projectId, newest.deployment_trigger.metadata.branch, "production"),
140
+ createdAt: newest.created_on
141
+ };
142
+ }
130
143
  async getProjectByName(name) {
131
144
  try {
132
145
  return mapProject(await this.client().pages.getProject(this.accountId, name));
@@ -363,6 +376,19 @@ var CloudflareWorkers = class {
363
376
  bindingNames: secrets.map((secret) => secret.name)
364
377
  };
365
378
  }
379
+ /** The newest deployment of the script, and whether it serves all traffic. Reads only. */
380
+ async latestDeployment(script) {
381
+ const [newest] = [...await this.client().workers.listDeployments(this.accountId, script)].sort((a, b) => b.created_on.localeCompare(a.created_on));
382
+ if (!newest) return null;
383
+ return {
384
+ id: newest.id,
385
+ createdAt: newest.created_on,
386
+ active: newest.versions.length > 0 && newest.versions.some((v) => v.percentage === 100)
387
+ };
388
+ }
389
+ proxyScriptName(hostname) {
390
+ return hostnameToScriptName(hostname);
391
+ }
366
392
  /** Idempotent create-or-update for one route pattern — shared by both public methods. */
367
393
  async upsertRoute(pattern, scriptName) {
368
394
  const hostname = pattern.split("/")[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-cloudflare",
3
- "version": "5.0.0-alpha.482",
3
+ "version": "5.0.0-alpha.484",
4
4
  "description": "Holocron plugin for Cloudflare. Implements the dns capability against Cloudflare's REST API — zone resolution, DNS record management.",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -44,20 +44,20 @@
44
44
  "tsx": "4.23.15",
45
45
  "typescript": "^5.9.3",
46
46
  "vitest": "^5.1.0",
47
- "@theholocron/cli": "5.0.0-alpha.482",
47
+ "@theholocron/cloudflare-client": "^1.58.0-alpha.42",
48
+ "@theholocron/cli": "5.0.0-alpha.484",
49
+ "@theholocron/http-client": "^1.58.0-alpha.42",
48
50
  "@theholocron/eslint-config": "^8.9.0-alpha.21",
49
- "@theholocron/cloudflare-client": "^1.58.0-alpha.41",
50
- "@theholocron/http-client": "^1.58.0-alpha.41",
51
- "@theholocron/kyber": "5.0.0-alpha.482",
51
+ "@theholocron/kyber": "5.0.0-alpha.484",
52
52
  "@theholocron/tsconfig": "^8.9.0-alpha.21",
53
- "@theholocron/misc-utils": "^1.17.0-alpha.5",
54
53
  "@theholocron/tsdown-config": "^8.9.0-alpha.21",
55
- "@theholocron/vitest-config": "^8.9.0-alpha.21"
54
+ "@theholocron/vitest-config": "^8.9.0-alpha.21",
55
+ "@theholocron/misc-utils": "^1.17.0-alpha.5"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@theholocron/cloudflare-client": "^1.53.1",
59
59
  "@theholocron/misc-utils": "^1.16.0",
60
- "@theholocron/cli": "5.0.0-alpha.482"
60
+ "@theholocron/cli": "5.0.0-alpha.484"
61
61
  },
62
62
  "peerDependenciesMeta": {
63
63
  "@theholocron/cloudflare-client": {}