@theholocron/holocron-plugin-vercel 5.0.0-alpha.462 → 5.0.0-alpha.463

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
@@ -48,6 +48,14 @@ export declare class VercelDeployment implements Deployment {
48
48
  /** Fetches a deployment by id; the record's branch is the deployment's Git commit ref, or `null` when it has none. */
49
49
  getDeployment(deploymentId: string): Promise<DeploymentRecord>;
50
50
  deployFunction(projectId: string, config: DeployFunctionConfig): Promise<DeployFunctionResult>;
51
+ /**
52
+ * The project's preview deployments tagged for `branch` (the `<repo>-pr-<number>` alias a file deploy puts in its
53
+ * `meta.holocronPreview`), found by reading the project's deployments page by page and matching the tag here, so
54
+ * only this project's deployments are ever candidates. A production or staging deployment is never one.
55
+ */
56
+ listPreviewDeployments(projectId: string, branch: string): Promise<DeploymentRecord[]>;
57
+ /** Deletes the deployments by id; one already gone (404) is not counted and is not an error. */
58
+ deletePreviewDeployments(_projectId: string, deploymentIds: string[]): Promise<number>;
51
59
  /**
52
60
  * Idempotent — matches `Deployment.ensureCustomDomain`'s contract
53
61
  * (never break on re-runs, per CLAUDE.md's probe-then-act standard).
package/dist/index.mjs CHANGED
@@ -27,6 +27,10 @@ const tokens = [{
27
27
  expect: EXPECTED
28
28
  }];
29
29
  // src/capabilities/deployment.ts
30
+ /** The `meta` key a file deploy tags a preview with: the pull request it belongs to, as `<repo>-pr-<number>`. */
31
+ const PREVIEW_META_KEY = "holocronPreview";
32
+ /** How many pages of a project's deployments a cleanup reads (100 to a page) before it stops looking. */
33
+ const MAX_LIST_PAGES = 20;
30
34
  /** The `deployment` capability for Vercel: projects, environment variables, deployments, functions and custom domains. */
31
35
  var VercelDeployment = class {
32
36
  client;
@@ -97,7 +101,8 @@ var VercelDeployment = class {
97
101
  })),
98
102
  framework: null,
99
103
  ...installCommandOf(config.files),
100
- target: config.target
104
+ target: config.target,
105
+ ...config.meta ? { meta: config.meta } : {}
101
106
  });
102
107
  return {
103
108
  deploymentId: raw.id,
@@ -105,6 +110,43 @@ var VercelDeployment = class {
105
110
  };
106
111
  }
107
112
  /**
113
+ * The project's preview deployments tagged for `branch` (the `<repo>-pr-<number>` alias a file deploy puts in its
114
+ * `meta.holocronPreview`), found by reading the project's deployments page by page and matching the tag here, so
115
+ * only this project's deployments are ever candidates. A production or staging deployment is never one.
116
+ */
117
+ async listPreviewDeployments(projectId, branch) {
118
+ const found = [];
119
+ let until;
120
+ for (let page = 0; page < MAX_LIST_PAGES; page++) {
121
+ const { deployments, pagination } = await this.client().deployments.list({
122
+ projectId,
123
+ ...until !== void 0 ? { until } : {}
124
+ });
125
+ for (const raw of deployments) {
126
+ if (raw.target || raw.meta?.[PREVIEW_META_KEY] !== branch) continue;
127
+ found.push({
128
+ ...mapDeployment(raw, raw.meta?.githubCommitRef ?? null),
129
+ ...raw.createdAt ? { createdAt: new Date(raw.createdAt).toISOString() } : {}
130
+ });
131
+ }
132
+ const next = pagination?.next;
133
+ if (!next) break;
134
+ until = next;
135
+ }
136
+ return found;
137
+ }
138
+ /** Deletes the deployments by id; one already gone (404) is not counted and is not an error. */
139
+ async deletePreviewDeployments(_projectId, deploymentIds) {
140
+ let deleted = 0;
141
+ for (const id of deploymentIds) try {
142
+ await this.client().deployments.remove(id);
143
+ deleted++;
144
+ } catch (err) {
145
+ if (!(err instanceof ProviderApiError && err.status === 404)) throw err;
146
+ }
147
+ return deleted;
148
+ }
149
+ /**
108
150
  * Idempotent — matches `Deployment.ensureCustomDomain`'s contract
109
151
  * (never break on re-runs, per CLAUDE.md's probe-then-act standard).
110
152
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-vercel",
3
- "version": "5.0.0-alpha.462",
3
+ "version": "5.0.0-alpha.463",
4
4
  "description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
5
5
  "keywords": [
6
6
  "deployment",
@@ -40,19 +40,19 @@
40
40
  "tsx": "4.23.15",
41
41
  "typescript": "^5.9.3",
42
42
  "vitest": "^5.1.0",
43
- "@theholocron/cli": "5.0.0-alpha.462",
44
- "@theholocron/http-client": "^1.58.0-alpha.37",
45
- "@theholocron/misc-utils": "^1.17.0-alpha.4",
46
43
  "@theholocron/tsconfig": "^8.9.0-alpha.18",
47
- "@theholocron/tsdown-config": "^8.9.0-alpha.18",
48
- "@theholocron/vercel-client": "^1.58.0-alpha.37",
49
44
  "@theholocron/eslint-config": "^8.9.0-alpha.18",
45
+ "@theholocron/misc-utils": "^1.17.0-alpha.4",
46
+ "@theholocron/http-client": "^1.58.0-alpha.38",
47
+ "@theholocron/vercel-client": "^1.58.0-alpha.38",
48
+ "@theholocron/tsdown-config": "^8.9.0-alpha.18",
49
+ "@theholocron/cli": "5.0.0-alpha.463",
50
50
  "@theholocron/vitest-config": "^8.9.0-alpha.18"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@theholocron/misc-utils": "^1.16.0",
54
54
  "@theholocron/vercel-client": "^1.43.1",
55
- "@theholocron/cli": "5.0.0-alpha.462"
55
+ "@theholocron/cli": "5.0.0-alpha.463"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@theholocron/vercel-client": {}