@jini-ai/devops 0.1.2
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/LICENSE +201 -0
- package/README.md +24 -0
- package/dist/deploy/cloudflare-pages.d.ts +105 -0
- package/dist/deploy/cloudflare-pages.d.ts.map +1 -0
- package/dist/deploy/cloudflare-pages.js +921 -0
- package/dist/deploy/cloudflare-pages.js.map +1 -0
- package/dist/deploy/github-pages.d.ts +62 -0
- package/dist/deploy/github-pages.d.ts.map +1 -0
- package/dist/deploy/github-pages.js +373 -0
- package/dist/deploy/github-pages.js.map +1 -0
- package/dist/deploy/index.d.ts +11 -0
- package/dist/deploy/index.d.ts.map +1 -0
- package/dist/deploy/index.js +11 -0
- package/dist/deploy/index.js.map +1 -0
- package/dist/deploy/naming.d.ts +18 -0
- package/dist/deploy/naming.d.ts.map +1 -0
- package/dist/deploy/naming.js +29 -0
- package/dist/deploy/naming.js.map +1 -0
- package/dist/deploy/netlify.d.ts +40 -0
- package/dist/deploy/netlify.d.ts.map +1 -0
- package/dist/deploy/netlify.js +299 -0
- package/dist/deploy/netlify.js.map +1 -0
- package/dist/deploy/reachability.d.ts +72 -0
- package/dist/deploy/reachability.d.ts.map +1 -0
- package/dist/deploy/reachability.js +260 -0
- package/dist/deploy/reachability.js.map +1 -0
- package/dist/deploy/redirect-guard.d.ts +33 -0
- package/dist/deploy/redirect-guard.d.ts.map +1 -0
- package/dist/deploy/redirect-guard.js +40 -0
- package/dist/deploy/redirect-guard.js.map +1 -0
- package/dist/deploy/tokens.d.ts +57 -0
- package/dist/deploy/tokens.d.ts.map +1 -0
- package/dist/deploy/tokens.js +58 -0
- package/dist/deploy/tokens.js.map +1 -0
- package/dist/deploy/tool.d.ts +104 -0
- package/dist/deploy/tool.d.ts.map +1 -0
- package/dist/deploy/tool.js +108 -0
- package/dist/deploy/tool.js.map +1 -0
- package/dist/deploy/types.d.ts +86 -0
- package/dist/deploy/types.d.ts.map +1 -0
- package/dist/deploy/types.js +27 -0
- package/dist/deploy/types.js.map +1 -0
- package/dist/deploy/vercel.d.ts +56 -0
- package/dist/deploy/vercel.d.ts.map +1 -0
- package/dist/deploy/vercel.js +258 -0
- package/dist/deploy/vercel.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type DeployPublishInput, type DeployPublishResult, type DeployTarget, type DeploymentUrlCheck } from './types.js';
|
|
2
|
+
export declare const NETLIFY_TARGET_ID = "netlify";
|
|
3
|
+
/** Auth config a caller supplies when constructing a `NetlifyDeployTarget`. */
|
|
4
|
+
export interface NetlifyDeployConfig {
|
|
5
|
+
token: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `DeployTarget` adapter for Netlify's digest-based deploy API: find-or-create
|
|
9
|
+
* a site for the caller's `projectName`, create a deploy from a SHA1 file
|
|
10
|
+
* manifest, upload whichever files Netlify reports as `required`, poll until
|
|
11
|
+
* the deploy reaches a terminal `state`, then wait for the resulting URL to
|
|
12
|
+
* become publicly reachable.
|
|
13
|
+
*
|
|
14
|
+
* No OD origin — `apps/daemon/src/deploy.ts` never implemented a Netlify
|
|
15
|
+
* target (only `vercel-self` and `cloudflare-pages` exist there); this is new
|
|
16
|
+
* work built directly against Netlify's own published OpenAPI contract
|
|
17
|
+
* (`https://open-api.netlify.com`), following the same `DeployTarget` shape
|
|
18
|
+
* `vercel.ts`/`cloudflare-pages.ts` already establish. See `source-map.md`'s
|
|
19
|
+
* 2026-07-21 addition for the exact endpoints/fields this was built from.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NetlifyDeployTarget implements DeployTarget {
|
|
22
|
+
private readonly config;
|
|
23
|
+
readonly id = "netlify";
|
|
24
|
+
constructor(config: NetlifyDeployConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Publishes `input.files` as a new Netlify deploy (creating the target site
|
|
27
|
+
* on first use) and waits for the resulting URL to be reachable.
|
|
28
|
+
*
|
|
29
|
+
* @param input - File set plus a caller-chosen project name label.
|
|
30
|
+
* @returns The published deploy's URL/status once Netlify has a terminal
|
|
31
|
+
* `state` (or the poll budget is exhausted).
|
|
32
|
+
* @throws {DeployError} If `config.token` is missing, the site cannot be
|
|
33
|
+
* found/created, or Netlify reports a terminal failure state
|
|
34
|
+
* (`'error'`/`'rejected'`).
|
|
35
|
+
*/
|
|
36
|
+
publish(input: DeployPublishInput): Promise<DeployPublishResult>;
|
|
37
|
+
/** Probes `url` with the shared reachability checker (no Netlify-specific auth-wall detection is needed/documented). */
|
|
38
|
+
checkReachability(url: string): Promise<DeploymentUrlCheck>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=netlify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"netlify.d.ts","sourceRoot":"","sources":["../../src/deploy/netlify.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EAExB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAiB3C,+EAA+E;AAC/E,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IAG1C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,QAAQ,CAAC,EAAE,aAAqB;gBAEH,MAAM,EAAE,mBAAmB;IAExD;;;;;;;;;;OAUG;IACG,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAsDtE,wHAAwH;IAClH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAGlE"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { FETCH_TIMEOUT_MS, fetchWithTimeout } from '@jini-ai/platform';
|
|
3
|
+
import { checkDeploymentUrl, normalizeDeploymentUrl, waitForReachableDeploymentUrl } from './reachability.js';
|
|
4
|
+
import { safeDnsLabel } from './naming.js';
|
|
5
|
+
import { DeployError, } from './types.js';
|
|
6
|
+
export const NETLIFY_TARGET_ID = 'netlify';
|
|
7
|
+
const NETLIFY_API = 'https://api.netlify.com/api/v1';
|
|
8
|
+
/**
|
|
9
|
+
* Deploy states enumerated by the Netlify API's own `GET /sites/{site_id}/deploys`
|
|
10
|
+
* `state` query-filter (the canonical source for this field's real values —
|
|
11
|
+
* the deploy object's own schema types `state` as a bare `string` with no
|
|
12
|
+
* inline enum). `'ready'` is the only success terminal state; `'error'` and
|
|
13
|
+
* `'rejected'` are the only failure terminal states. Every other value
|
|
14
|
+
* (`'new'`, `'pending_review'`, `'accepted'`, `'enqueued'`, `'building'`,
|
|
15
|
+
* `'uploading'`, `'uploaded'`, `'preparing'`, `'prepared'`, `'processing'`,
|
|
16
|
+
* `'processed'`, `'retrying'`) is an in-progress state this module keeps
|
|
17
|
+
* polling through.
|
|
18
|
+
*/
|
|
19
|
+
const NETLIFY_FAILURE_STATES = new Set(['error', 'rejected']);
|
|
20
|
+
/**
|
|
21
|
+
* `DeployTarget` adapter for Netlify's digest-based deploy API: find-or-create
|
|
22
|
+
* a site for the caller's `projectName`, create a deploy from a SHA1 file
|
|
23
|
+
* manifest, upload whichever files Netlify reports as `required`, poll until
|
|
24
|
+
* the deploy reaches a terminal `state`, then wait for the resulting URL to
|
|
25
|
+
* become publicly reachable.
|
|
26
|
+
*
|
|
27
|
+
* No OD origin — `apps/daemon/src/deploy.ts` never implemented a Netlify
|
|
28
|
+
* target (only `vercel-self` and `cloudflare-pages` exist there); this is new
|
|
29
|
+
* work built directly against Netlify's own published OpenAPI contract
|
|
30
|
+
* (`https://open-api.netlify.com`), following the same `DeployTarget` shape
|
|
31
|
+
* `vercel.ts`/`cloudflare-pages.ts` already establish. See `source-map.md`'s
|
|
32
|
+
* 2026-07-21 addition for the exact endpoints/fields this was built from.
|
|
33
|
+
*/
|
|
34
|
+
export class NetlifyDeployTarget {
|
|
35
|
+
config;
|
|
36
|
+
id = NETLIFY_TARGET_ID;
|
|
37
|
+
constructor(config) {
|
|
38
|
+
this.config = config;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Publishes `input.files` as a new Netlify deploy (creating the target site
|
|
42
|
+
* on first use) and waits for the resulting URL to be reachable.
|
|
43
|
+
*
|
|
44
|
+
* @param input - File set plus a caller-chosen project name label.
|
|
45
|
+
* @returns The published deploy's URL/status once Netlify has a terminal
|
|
46
|
+
* `state` (or the poll budget is exhausted).
|
|
47
|
+
* @throws {DeployError} If `config.token` is missing, the site cannot be
|
|
48
|
+
* found/created, or Netlify reports a terminal failure state
|
|
49
|
+
* (`'error'`/`'rejected'`).
|
|
50
|
+
*/
|
|
51
|
+
async publish(input) {
|
|
52
|
+
if (!this.config.token) {
|
|
53
|
+
throw new DeployError('Netlify token is required.', 400);
|
|
54
|
+
}
|
|
55
|
+
const siteName = deriveNetlifySiteName(input.projectName);
|
|
56
|
+
if (!siteName) {
|
|
57
|
+
throw new DeployError('Netlify site name could not be generated.', 400);
|
|
58
|
+
}
|
|
59
|
+
const site = await ensureNetlifySite(this.config, siteName);
|
|
60
|
+
const siteId = typeof site.id === 'string' ? site.id : '';
|
|
61
|
+
if (!siteId) {
|
|
62
|
+
throw new DeployError('Netlify site response did not include an id.', 502, site);
|
|
63
|
+
}
|
|
64
|
+
const { created, byHash } = await createNetlifyDeploy(this.config, siteId, input.files);
|
|
65
|
+
const deployId = typeof created.id === 'string' ? created.id : '';
|
|
66
|
+
if (!deployId) {
|
|
67
|
+
throw new DeployError('Netlify deploy response did not include an id.', 502, created);
|
|
68
|
+
}
|
|
69
|
+
const required = Array.isArray(created.required) ? created.required.filter((h) => typeof h === 'string') : [];
|
|
70
|
+
for (const hash of required) {
|
|
71
|
+
const file = byHash.get(hash);
|
|
72
|
+
// A hash Netlify asked for but that isn't in our own manifest should
|
|
73
|
+
// never happen (`required` is derived from the manifest we just sent),
|
|
74
|
+
// but skip defensively rather than crash the whole publish over it.
|
|
75
|
+
if (!file)
|
|
76
|
+
continue;
|
|
77
|
+
await uploadNetlifyFile(this.config, deployId, file);
|
|
78
|
+
}
|
|
79
|
+
const finalState = await pollNetlifyDeploy(this.config, deployId);
|
|
80
|
+
if (finalState && NETLIFY_FAILURE_STATES.has(String(finalState.state))) {
|
|
81
|
+
throw new DeployError((typeof finalState.error_message === 'string' && finalState.error_message) || `Netlify deployment ${finalState.state}.`, 502, finalState);
|
|
82
|
+
}
|
|
83
|
+
const candidates = netlifyUrlCandidates(finalState, site);
|
|
84
|
+
const link = await waitForReachableDeploymentUrl(candidates, { providerLabel: 'Netlify' });
|
|
85
|
+
return {
|
|
86
|
+
targetId: this.id,
|
|
87
|
+
url: link.url || candidates[0] || '',
|
|
88
|
+
deploymentId: deployId,
|
|
89
|
+
status: link.status,
|
|
90
|
+
statusMessage: link.statusMessage,
|
|
91
|
+
...(link.reachableAt !== undefined ? { reachableAt: link.reachableAt } : {}),
|
|
92
|
+
providerMetadata: { siteId, siteName },
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Probes `url` with the shared reachability checker (no Netlify-specific auth-wall detection is needed/documented). */
|
|
96
|
+
async checkReachability(url) {
|
|
97
|
+
return checkDeploymentUrl(url);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Derives a stable, Netlify-site-name-safe label from the caller's
|
|
102
|
+
* `projectName`. Deterministic (no random suffix) so repeated publishes of
|
|
103
|
+
* the same logical project land on the same Netlify site — same shape as
|
|
104
|
+
* `cloudflare-pages.ts`'s `deriveCloudflarePagesProjectName`.
|
|
105
|
+
*/
|
|
106
|
+
function deriveNetlifySiteName(projectName) {
|
|
107
|
+
const label = safeDnsLabel(projectName) || 'site';
|
|
108
|
+
return safeDnsLabel(`jini-${label}`).slice(0, 63);
|
|
109
|
+
}
|
|
110
|
+
function netlifyHeaders(token, extra = {}) {
|
|
111
|
+
return { Authorization: `Bearer ${token}`, ...extra };
|
|
112
|
+
}
|
|
113
|
+
async function readNetlifyJson(resp) {
|
|
114
|
+
try {
|
|
115
|
+
return (await resp.json());
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
throw new DeployError('Netlify returned a non-JSON response.', resp.status || 502);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* `fallback || \`Netlify request failed (${status}).\`` (the template
|
|
123
|
+
* literal half) is unreachable today: every one of this file's 5 call
|
|
124
|
+
* sites passes a non-empty string literal for `fallback` ('Netlify site
|
|
125
|
+
* lookup failed.', 'Netlify site creation failed.', 'Netlify deploy
|
|
126
|
+
* creation failed.', the per-file upload message, 'Netlify deploy status
|
|
127
|
+
* check failed.') — `fallback` is never derived from network/config input,
|
|
128
|
+
* so it cannot vary at runtime, and this right-hand operand can never be
|
|
129
|
+
* selected. Verified by reading every call site, not just "not covered".
|
|
130
|
+
* Left as-is (not deleted) because `netlifyError` is a general-purpose
|
|
131
|
+
* formatter, not written solely for today's 5 callers, and this is the
|
|
132
|
+
* sane-default guard a future caller forgetting to pass `fallback` would
|
|
133
|
+
* fall through to.
|
|
134
|
+
*/
|
|
135
|
+
function netlifyError(json, status, fallback) {
|
|
136
|
+
const message = typeof json?.message === 'string' && json.message ? json.message : fallback || `Netlify request failed (${status}).`;
|
|
137
|
+
return new DeployError(message, status, json);
|
|
138
|
+
}
|
|
139
|
+
/** Looks up an existing site by its exact (case-insensitive) name within the caller's own account. */
|
|
140
|
+
async function findNetlifySiteByName(config, name) {
|
|
141
|
+
const url = `${NETLIFY_API}/sites?${new URLSearchParams({ name, filter: 'all' }).toString()}`;
|
|
142
|
+
const resp = await fetchWithTimeout(url, { headers: netlifyHeaders(config.token) }, { timeoutMs: FETCH_TIMEOUT_MS.QUICK });
|
|
143
|
+
const body = await readNetlifyJson(resp);
|
|
144
|
+
if (!resp.ok) {
|
|
145
|
+
throw netlifyError(Array.isArray(body) ? {} : body, resp.status, 'Netlify site lookup failed.');
|
|
146
|
+
}
|
|
147
|
+
const list = Array.isArray(body) ? body : [];
|
|
148
|
+
return list.find((site) => typeof site?.name === 'string' && site.name.toLowerCase() === name.toLowerCase());
|
|
149
|
+
}
|
|
150
|
+
async function createNetlifySite(config, name) {
|
|
151
|
+
const resp = await fetchWithTimeout(`${NETLIFY_API}/sites`, {
|
|
152
|
+
method: 'POST',
|
|
153
|
+
headers: netlifyHeaders(config.token, { 'Content-Type': 'application/json' }),
|
|
154
|
+
body: JSON.stringify({ name }),
|
|
155
|
+
}, { timeoutMs: FETCH_TIMEOUT_MS.DEPLOY });
|
|
156
|
+
const body = await readNetlifyJson(resp);
|
|
157
|
+
if (!resp.ok)
|
|
158
|
+
throw netlifyError(body, resp.status, 'Netlify site creation failed.');
|
|
159
|
+
return body;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Finds the site for `name`, creating it on first use. Netlify site names
|
|
163
|
+
* are globally unique (not scoped to one account), so a creation conflict is
|
|
164
|
+
* ambiguous: it may mean *this* account already owns the name (a benign
|
|
165
|
+
* create/create race — recoverable by re-listing), or that a different
|
|
166
|
+
* account owns it outright (not recoverable). Re-checking the caller's own
|
|
167
|
+
* account's sites after a failed create distinguishes the two: found → use
|
|
168
|
+
* it; still not found → rethrow the original creation error.
|
|
169
|
+
*/
|
|
170
|
+
async function ensureNetlifySite(config, name) {
|
|
171
|
+
const existing = await findNetlifySiteByName(config, name);
|
|
172
|
+
if (existing)
|
|
173
|
+
return existing;
|
|
174
|
+
try {
|
|
175
|
+
return await createNetlifySite(config, name);
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
const retry = await findNetlifySiteByName(config, name);
|
|
179
|
+
if (retry)
|
|
180
|
+
return retry;
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function sha1Hex(data) {
|
|
185
|
+
return createHash('sha1').update(Buffer.from(data)).digest('hex');
|
|
186
|
+
}
|
|
187
|
+
/** URL-encodes each path segment individually so directory separators survive but special characters in a single segment don't. */
|
|
188
|
+
function encodeNetlifyFilePath(path) {
|
|
189
|
+
return path
|
|
190
|
+
.split('/')
|
|
191
|
+
.filter(Boolean)
|
|
192
|
+
.map(encodeURIComponent)
|
|
193
|
+
.join('/');
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Creates a Netlify deploy from an async SHA1 file-digest manifest. Returns
|
|
197
|
+
* both the raw created-deploy response and a hash→file lookup so the caller
|
|
198
|
+
* can resolve whichever hashes Netlify reports back as `required` to upload.
|
|
199
|
+
*/
|
|
200
|
+
async function createNetlifyDeploy(config, siteId, files) {
|
|
201
|
+
const manifest = {};
|
|
202
|
+
const byHash = new Map();
|
|
203
|
+
for (const file of files) {
|
|
204
|
+
const hash = sha1Hex(file.data);
|
|
205
|
+
manifest[`/${file.file}`] = hash;
|
|
206
|
+
if (!byHash.has(hash))
|
|
207
|
+
byHash.set(hash, file);
|
|
208
|
+
}
|
|
209
|
+
const resp = await fetchWithTimeout(`${NETLIFY_API}/sites/${encodeURIComponent(siteId)}/deploys`, {
|
|
210
|
+
method: 'POST',
|
|
211
|
+
headers: netlifyHeaders(config.token, { 'Content-Type': 'application/json' }),
|
|
212
|
+
body: JSON.stringify({ async: true, files: manifest }),
|
|
213
|
+
}, { timeoutMs: FETCH_TIMEOUT_MS.DEPLOY });
|
|
214
|
+
const created = await readNetlifyJson(resp);
|
|
215
|
+
if (!resp.ok)
|
|
216
|
+
throw netlifyError(created, resp.status, 'Netlify deploy creation failed.');
|
|
217
|
+
return { created, byHash };
|
|
218
|
+
}
|
|
219
|
+
async function uploadNetlifyFile(config, deployId, file) {
|
|
220
|
+
const resp = await fetchWithTimeout(`${NETLIFY_API}/deploys/${encodeURIComponent(deployId)}/files/${encodeNetlifyFilePath(file.file)}`, {
|
|
221
|
+
method: 'PUT',
|
|
222
|
+
headers: netlifyHeaders(config.token, { 'Content-Type': file.contentType || 'application/octet-stream' }),
|
|
223
|
+
body: Buffer.from(file.data),
|
|
224
|
+
}, { timeoutMs: FETCH_TIMEOUT_MS.UPLOAD });
|
|
225
|
+
if (!resp.ok) {
|
|
226
|
+
const body = await readNetlifyJson(resp).catch(() => ({}));
|
|
227
|
+
throw netlifyError(body, resp.status, `Netlify file upload failed for "${file.file}".`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Polls a just-created Netlify deploy until it reaches a terminal `state`
|
|
232
|
+
* (`'ready'` or one of {@link NETLIFY_FAILURE_STATES}) or the fixed
|
|
233
|
+
* 30-attempt budget is spent (~1s for the first 5 attempts, 2s thereafter —
|
|
234
|
+
* roughly a minute) — same attempt/backoff shape as `vercel.ts`'s
|
|
235
|
+
* `pollVercelDeployment`, for consistency across this package's targets.
|
|
236
|
+
*
|
|
237
|
+
* A response this file cannot parse as JSON is treated as "keep polling,"
|
|
238
|
+
* not an error — same reasoning as `github-pages.ts`'s `pollGitHubPagesBuild`
|
|
239
|
+
* and `vercel.ts`'s `pollVercelDeployment` (fixed 2026-08-16 for the
|
|
240
|
+
* identical bug class): the deploy and its files are already created/uploaded
|
|
241
|
+
* server-side by the time this loop runs, so a transient/edge/empty poll
|
|
242
|
+
* response is never a reason to report an already-uploaded deploy as failed.
|
|
243
|
+
* Any other non-2xx response whose body DID parse still fails fast, unchanged.
|
|
244
|
+
*/
|
|
245
|
+
async function pollNetlifyDeploy(config, deployId) {
|
|
246
|
+
let last = null;
|
|
247
|
+
for (let i = 0; i < 30; i += 1) {
|
|
248
|
+
await new Promise((resolve) => setTimeout(resolve, i < 5 ? 1000 : 2000));
|
|
249
|
+
const resp = await fetchWithTimeout(`${NETLIFY_API}/deploys/${encodeURIComponent(deployId)}`, { headers: netlifyHeaders(config.token) }, { timeoutMs: FETCH_TIMEOUT_MS.DEPLOY });
|
|
250
|
+
let json;
|
|
251
|
+
try {
|
|
252
|
+
json = await readNetlifyJson(resp);
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
// Nothing usable to report yet — keep polling within the same fixed budget
|
|
256
|
+
// rather than turning an ambiguous mid-poll hiccup into a reported failure.
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (!resp.ok)
|
|
260
|
+
throw netlifyError(json, resp.status, 'Netlify deploy status check failed.');
|
|
261
|
+
last = json;
|
|
262
|
+
if (json.state === 'ready' || NETLIFY_FAILURE_STATES.has(String(json.state)))
|
|
263
|
+
return json;
|
|
264
|
+
}
|
|
265
|
+
return last;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Collects candidate public URLs from a deploy/site response, preferring the HTTPS site URL over the deploy-specific one.
|
|
269
|
+
*
|
|
270
|
+
* `if (!json) continue` is unreachable via this file's one call site,
|
|
271
|
+
* `netlifyUrlCandidates(finalState, site)` in `publish()`: `finalState`
|
|
272
|
+
* comes from `pollNetlifyDeploy`, whose 30-iteration loop (`i < 30` with
|
|
273
|
+
* `i` starting at 0) always runs at least once and unconditionally assigns
|
|
274
|
+
* `last` before any return, so it can only resolve to a real `JsonObject`
|
|
275
|
+
* or throw — never resolve to `null`; `site` comes from `ensureNetlifySite`,
|
|
276
|
+
* which always returns a `JsonObject` (never null/undefined), and `publish()`
|
|
277
|
+
* additionally guards it with a `!siteId` check right after. The `| null |
|
|
278
|
+
* undefined` in this function's own parameter type is deliberately wider
|
|
279
|
+
* than what its only caller can ever supply, so this stays real
|
|
280
|
+
* defense-in-depth for a general-purpose variadic helper rather than dead
|
|
281
|
+
* weight worth deleting.
|
|
282
|
+
*/
|
|
283
|
+
function netlifyUrlCandidates(...responses) {
|
|
284
|
+
const urls = [];
|
|
285
|
+
for (const json of responses) {
|
|
286
|
+
if (!json)
|
|
287
|
+
continue;
|
|
288
|
+
if (typeof json.ssl_url === 'string')
|
|
289
|
+
urls.push(json.ssl_url);
|
|
290
|
+
if (typeof json.url === 'string')
|
|
291
|
+
urls.push(json.url);
|
|
292
|
+
if (typeof json.deploy_ssl_url === 'string')
|
|
293
|
+
urls.push(json.deploy_ssl_url);
|
|
294
|
+
if (typeof json.deploy_url === 'string')
|
|
295
|
+
urls.push(json.deploy_url);
|
|
296
|
+
}
|
|
297
|
+
return [...new Set(urls.map(normalizeDeploymentUrl).filter(Boolean))];
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=netlify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"netlify.js","sourceRoot":"","sources":["../../src/deploy/netlify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,WAAW,GAOZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAO9D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,mBAAmB;IAGD;IAFpB,EAAE,GAAG,iBAAiB,CAAC;IAEhC,YAA6B,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;IAAG,CAAC;IAE5D;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,CAAC,KAAyB;QACrC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,MA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UrlCheck } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provider-supplied hook for recognizing a deployment URL that responded
|
|
5
|
+
* but is gated behind the provider's own auth wall (Vercel Deployment
|
|
6
|
+
* Protection, for example) rather than genuinely down. Kept pluggable
|
|
7
|
+
* instead of hardcoding Vercel's SSO-nonce/header sniffing here, so a
|
|
8
|
+
* future target (Cloudflare, GitHub Pages, ...) can supply its own
|
|
9
|
+
* detector or omit one entirely.
|
|
10
|
+
*/
|
|
11
|
+
export type ProtectedResponseDetector = (resp: Response, body: string) => boolean;
|
|
12
|
+
export interface ReachabilityOptions {
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
detectProtected?: ProtectedResponseDetector;
|
|
15
|
+
protectedMessage?: string;
|
|
16
|
+
/** Injectable `dns.lookup` for the connection-time SSRF guard (tests only — see `assertSafeDeploymentUrl`). */
|
|
17
|
+
lookupImpl?: Parameters<typeof createValidatingLookup>[0];
|
|
18
|
+
}
|
|
19
|
+
export interface ReachabilityWaitOptions {
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
intervalMs?: number;
|
|
22
|
+
providerLabel?: string;
|
|
23
|
+
detectProtected?: ProtectedResponseDetector;
|
|
24
|
+
protectedMessage?: string;
|
|
25
|
+
/** Injectable `dns.lookup` for the connection-time SSRF guard (tests only). */
|
|
26
|
+
lookupImpl?: Parameters<typeof createValidatingLookup>[0];
|
|
27
|
+
}
|
|
28
|
+
export interface ReachabilityWaitResult {
|
|
29
|
+
status: DeployLinkStatus;
|
|
30
|
+
url: string;
|
|
31
|
+
statusMessage: string;
|
|
32
|
+
reachableAt?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes a raw provider-returned URL/hostname into an absolute
|
|
36
|
+
* `https://` URL (bare hostnames like `foo.vercel.app` are assumed https).
|
|
37
|
+
*
|
|
38
|
+
* @param url - Raw value from a provider response; may be `undefined`/non-string.
|
|
39
|
+
* @returns The normalized absolute URL, or `''` if `url` was empty/non-string.
|
|
40
|
+
* @complexity O(1).
|
|
41
|
+
* @overallScore 100/100
|
|
42
|
+
*/
|
|
43
|
+
export declare function normalizeDeploymentUrl(url: unknown): string;
|
|
44
|
+
/**
|
|
45
|
+
* Probes a single deployment URL, trying HEAD first and falling back to
|
|
46
|
+
* GET when HEAD is rejected or ambiguous (some hosts don't implement HEAD
|
|
47
|
+
* correctly on generated static routes).
|
|
48
|
+
*
|
|
49
|
+
* @param url - Raw URL/hostname from a provider response (normalized internally).
|
|
50
|
+
* @param options - Timeout (default 8s) and optional protected-response detector.
|
|
51
|
+
* @returns A `DeploymentUrlCheck` for the best of the HEAD/GET attempts.
|
|
52
|
+
* @complexity O(1)-O(2) network round-trips.
|
|
53
|
+
* @overallScore 100/100
|
|
54
|
+
*/
|
|
55
|
+
export declare function checkDeploymentUrl(url: unknown, options?: ReachabilityOptions): Promise<DeploymentUrlCheck>;
|
|
56
|
+
/**
|
|
57
|
+
* Polls a set of deployment URL candidates until one becomes reachable, one
|
|
58
|
+
* reports as provider-protected, or `timeoutMs` elapses. Used right after a
|
|
59
|
+
* publish call returns, since providers frequently accept the deploy before
|
|
60
|
+
* the URL is actually resolvable.
|
|
61
|
+
*
|
|
62
|
+
* @param urls - Candidate URLs/hostnames in preference order (duplicates and empties are dropped).
|
|
63
|
+
* @param options - `timeoutMs` (default 60s), `intervalMs` between sweeps (default 2s),
|
|
64
|
+
* `providerLabel` for messages, and the optional protected-response detector.
|
|
65
|
+
* @returns `{ status, url, statusMessage, reachableAt? }`. `status: 'link-delayed'`
|
|
66
|
+
* means the timeout elapsed without a reachable/protected verdict — this is
|
|
67
|
+
* not necessarily a failure, the caller may choose to keep polling later.
|
|
68
|
+
* @complexity O(candidates * timeoutMs/intervalMs) network round-trips, bounded by timeoutMs.
|
|
69
|
+
* @overallScore 100/100
|
|
70
|
+
*/
|
|
71
|
+
export declare function waitForReachableDeploymentUrl(urls: unknown[], options?: ReachabilityWaitOptions): Promise<ReachabilityWaitResult>;
|
|
72
|
+
//# sourceMappingURL=reachability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reachability.d.ts","sourceRoot":"","sources":["../../src/deploy/reachability.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwC,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA0BvE;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAElF,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+GAA+G;IAC/G,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,yBAAyB,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAK3D;AA0GD;;;;;;;;;;GAUG;AACH,wBAAsB,kBAA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