@netlify/spark-ui 1.31.0-alpha.5 → 1.31.0-alpha.6

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 (37) hide show
  1. package/README.md +3 -4
  2. package/dist/components/preact/DropZone/DropZone.d.ts +23 -97
  3. package/dist/drop-core/analytics.d.ts +4 -15
  4. package/dist/drop-core/authedApi.d.ts +9 -22
  5. package/dist/drop-core/authedDropClient.d.ts +13 -55
  6. package/dist/drop-core/authedDropClient.js +5 -18
  7. package/dist/drop-core/buildClient.d.ts +19 -53
  8. package/dist/drop-core/buildClient.js +27 -40
  9. package/dist/drop-core/buildStash.d.ts +6 -20
  10. package/dist/drop-core/client.d.ts +1 -1
  11. package/dist/drop-core/constants.d.ts +1 -21
  12. package/dist/drop-core/deploy.d.ts +5 -17
  13. package/dist/drop-core/detectBuild.d.ts +8 -26
  14. package/dist/drop-core/errors.d.ts +8 -27
  15. package/dist/drop-core/fileTypes.d.ts +4 -14
  16. package/dist/drop-core/readFiles.d.ts +5 -11
  17. package/dist/drop-core/types.d.ts +2 -4
  18. package/dist/drop-core/zip.d.ts +7 -30
  19. package/package.json +1 -1
  20. package/packages/components/preact/DropZone/DropZone.tsx +27 -121
  21. package/packages/components/preact/DropZone/useDropDeploy.ts +27 -60
  22. package/packages/drop-core/analytics.ts +4 -15
  23. package/packages/drop-core/authedApi.ts +9 -22
  24. package/packages/drop-core/authedDropClient.ts +13 -55
  25. package/packages/drop-core/buildClient.test.ts +19 -4
  26. package/packages/drop-core/buildClient.ts +21 -63
  27. package/packages/drop-core/buildStash.ts +9 -25
  28. package/packages/drop-core/client.ts +6 -10
  29. package/packages/drop-core/constants.ts +7 -21
  30. package/packages/drop-core/deploy.ts +6 -22
  31. package/packages/drop-core/detectBuild.ts +15 -50
  32. package/packages/drop-core/errors.test.ts +3 -1
  33. package/packages/drop-core/errors.ts +9 -30
  34. package/packages/drop-core/fileTypes.ts +5 -19
  35. package/packages/drop-core/readFiles.ts +5 -12
  36. package/packages/drop-core/types.ts +2 -4
  37. package/packages/drop-core/zip.ts +7 -30
package/README.md CHANGED
@@ -147,13 +147,13 @@ This repo includes a [Claude Code](https://claude.ai/code) skill for generating
147
147
 
148
148
  The skill is available automatically. Run:
149
149
 
150
- ```text
150
+ ```
151
151
  /project:landing-page <describe the page you want>
152
152
  ```
153
153
 
154
154
  For example:
155
155
 
156
- ```text
156
+ ```
157
157
  /project:landing-page A landing page for a new enterprise hosting product with a hero, feature cards, and a pricing comparison
158
158
  ```
159
159
 
@@ -185,7 +185,7 @@ When you’re ready to validate your component changes in a deploy preview, you
185
185
  >
186
186
  > Reach out to #internal-permissions in Slack
187
187
 
188
- ### Steps to Publish an Alpha Release
188
+ ### Steps to Publish an Alpha Release:
189
189
 
190
190
  1. **Make sure you're logged into npm locally**
191
191
 
@@ -206,7 +206,6 @@ When you’re ready to validate your component changes in a deploy preview, you
206
206
  ```
207
207
 
208
208
  1. **Install the updated package:**
209
-
210
209
  ```bash
211
210
  npm install
212
211
  ```
@@ -10,29 +10,17 @@ interface Props {
10
10
  client?: DropClient;
11
11
  /** Build the "claim this site" URL from the assigned site name (subdomain). */
12
12
  claimUrl?: (siteName: string) => string;
13
- /**
14
- * Where an authenticated static deploy sends the visitor — the site already
15
- * lives in their account, so there is no claim step. Defaults to the new
16
- * site's project overview on app.netlify.com.
17
- */
13
+ /** Destination after an authenticated static deploy (no claim step). Default: the project overview. */
18
14
  siteDashboardUrl?: (siteName: string) => string;
19
15
  /**
20
- * The signup hand-off for a build-required drop that can't be built here (no
21
- * session, or no build wiring). The drop is stashed on this origin first, so
22
- * a flow that returns the visitor to this page deploys it automatically —
23
- * see `resumeStashedBuilds`. Defaults to the app signup page with
24
- * `next=/drop`.
16
+ * Signup hand-off for a build drop with no session. The drop is stashed on
17
+ * this origin first — return the visitor here and it deploys automatically.
25
18
  */
26
19
  buildSignupUrl?: string;
27
20
  /**
28
- * Mint a short-lived bearer token for direct api.netlify.com uploads — pass it
29
- * to switch on the whole authenticated path for logged-in visitors: static
30
- * drops deploy straight into their account (then `siteDashboardUrl`), and
31
- * build-required drops build in place instead of being handed off to the app.
32
- * On netlify.com this reads `GET /access-control/generate-access-control-token`.
33
- * Resolving `null` means "no session": static drops fall back to the anonymous
34
- * claim flow; build drops are stashed and handed to `buildSignupUrl`.
35
- * See [Logged-in visitors](#logged-in-visitors).
21
+ * Mint the upload bearer — passing this switches on the whole authenticated
22
+ * path. `null` means "no session": static drops fall back to the anonymous
23
+ * claim flow; build drops stash and hand off. See the docs' Logged-in visitors.
36
24
  */
37
25
  getUploadToken?: () => Promise<string | null>;
38
26
  /**
@@ -40,111 +28,49 @@ interface Props {
40
28
  * Takes precedence over `getUploadToken` for the build path.
41
29
  */
42
30
  buildClient?: BuildClient;
43
- /**
44
- * Inject a custom authenticated `DropClient` for static drops (tests, staging,
45
- * a different account flow). Takes precedence over `getUploadToken` for the
46
- * static path. Distinct from `client`, which is the anonymous fallback.
47
- */
31
+ /** Custom authenticated static-drop client; wins over `getUploadToken`. (`client` is the anonymous fallback.) */
48
32
  authenticatedDropClient?: DropClient;
49
- /**
50
- * API root for the authenticated paths' JSON calls, which go through your
51
- * access-control rewrite so the session cookie authorizes them. Defaults to
52
- * `/access-control/bb-api/api/v1`. (Uploads always go direct to
53
- * `api.netlify.com` — the proxy can't carry bodies that large.)
54
- */
33
+ /** Root for the session-cookie JSON calls, via your access-control rewrite. Uploads always go direct. */
55
34
  proxyBase?: string;
56
35
  /** Create the visitor's new project in this account. Omit for their default account. */
57
36
  accountSlug?: string;
58
- /**
59
- * Where an enqueued build sends the visitor. Defaults to the new site's
60
- * project overview, same as a static deploy; `build.deployId` is available for
61
- * consumers who want the deploy-log page instead.
62
- */
37
+ /** Destination after a build is enqueued. Default: the project overview (`build.deployId` for the logs page). */
63
38
  buildDeployUrl?: (build: DeployedBuild) => string;
64
39
  /**
65
- * Poll until the build finishes before handing off, instead of redirecting as
66
- * soon as it's enqueued. The trade-off: waiting means a failing build surfaces
67
- * its own error message here (via `onError` and the overlay) rather than the
68
- * visitor discovering it on the deploy page — at the cost of holding them on a
69
- * spinner for the length of the build, which is minutes. Off by default.
40
+ * Hold the visitor until the build finishes (off by default — builds take
41
+ * minutes). On is the only way a failing build's own message reaches `onError`.
70
42
  */
71
43
  waitForBuild?: boolean;
72
- /**
73
- * Called when a build-required drop is detected, instead of building it or
74
- * redirecting. Use it to own the hand-off yourself (custom routing, persisting
75
- * the drop, gating on auth). When set, the component neither builds nor
76
- * redirects. The static drop path is unaffected either way.
77
- */
44
+ /** Take over build-required drops entirely — when set, the component neither builds nor redirects. */
78
45
  onBuildRequired?: (info: BuildDetection) => void;
79
46
  /**
80
- * Called instead of the `buildSignupUrl` redirect when a build-required drop
81
- * can't be built here (no session). By this point the drop has been stashed
82
- * on this origin (`stashed` says whether that succeeded) — own the hand-off
83
- * however fits your auth flow, e.g. open a signup popup that keeps the
84
- * visitor on the page. Once they're back authenticated, a remount of the
85
- * zone deploys the stash automatically.
47
+ * Own the signup hand-off instead of the `buildSignupUrl` redirect (e.g. an
48
+ * auth popup). The drop is already stashed; a remount while authenticated
49
+ * deploys it.
86
50
  */
87
51
  onBuildSignupHandoff?: (info: {
88
52
  stashed: boolean;
89
53
  detection: BuildDetection;
90
54
  }) => void;
91
- /**
92
- * Deploy a previously stashed build drop automatically when the zone mounts
93
- * with an authenticated visitor (default `true`). The stash is written when a
94
- * logged-out build drop is handed to signup; see
95
- * [Signup hand-off and auto-resume](#signup-hand-off-and-auto-resume).
96
- */
55
+ /** Auto-deploy a stashed build drop on mount when authenticated (default true). */
97
56
  resumeStashedBuilds?: boolean;
98
57
  /** Called once the deploy is live. */
99
58
  onDeploy?: (result: DeployedSite) => void;
100
- /**
101
- * Called once a build-required drop has been zipped, uploaded and enqueued —
102
- * before the redirect to `buildDeployUrl`. The site exists at this point but
103
- * won't serve content until the build finishes.
104
- */
59
+ /** Called once a build is enqueued, before the `buildDeployUrl` redirect. */
105
60
  onBuildDeploy?: (build: DeployedBuild) => void;
106
- /**
107
- * Called when a deploy fails, with a humanized `message` (ready to show a
108
- * user — the same copy the built-in overlay uses) and the raw `reason`. Pair
109
- * this with `showStatus={false}` to render your own error UI.
110
- */
61
+ /** Deploy failures: humanized `message` (the overlay's copy) + raw `reason`. Pair with showStatus={false}. */
111
62
  onError?: (error: DeployError) => void;
112
63
  /**
113
- * Render the built-in status overlay (drag tint, spinner, progress bar, error).
114
- * Set to `false` to suppress it entirely and keep your children visible, then
115
- * drive your own feedback from the `data-state` attribute on the root element.
116
- * Note: in this mode you're responsible for surfacing errors yourself — use
117
- * `onError` to get the message.
64
+ * Render the built-in overlay. `false` keeps children visible — drive your
65
+ * own feedback from `data-state`, and surface errors yourself via `onError`.
118
66
  */
119
67
  showStatus?: boolean;
120
68
  /**
121
- * Analytics hook. Called at each tracked moment with an event name and
122
- * properties. Stays provider-agnostic — wire it to Segment/Amplitude/GA in the
123
- * consuming app, e.g. `onTrack={(name, props) => new Analytics().track(name, props)}`.
124
- * Emitted events (all include `dropzone_id` when `analyticsId` is set):
125
- * - `dropzone_files_dropped` — files dropped via drag ({ method: 'drag', file_count, file_types })
126
- * - `dropzone_browse_opened` — file picker opened ({ method: 'keyboard' | 'click' })
127
- * - `dropzone_build_required` — drop needs a build (built here, or handed off) ({ method, reason, file_count, file_types })
128
- * - `dropzone_deploy_succeeded` — static deploy went live ({ method, site_name, file_count, authenticated, auth_fallback?, file_types })
129
- * - `dropzone_build_deploy_succeeded` — build enqueued for a logged-in visitor ({ method, reason, site_name, file_count, framework?, file_types })
130
- * - `dropzone_deploy_failed` — deploy or build errored out ({ method, reason, file_count?, file_types })
131
- *
132
- * `authenticated` says whether the deploy landed in the visitor's account;
133
- * `auth_fallback: true` is sent only when an authenticated attempt bounced
134
- * (stale auth hint) and the drop completed anonymously — omitted otherwise.
135
- * `file_types` is the sorted, de-duplicated list of MIME types in the
136
- * selection, with `application/octet-stream` standing in wherever the browser
137
- * reports none (a dragged folder, an `.exe`). It is omitted when the browser
138
- * exposes no files at all. Note `dropzone_files_dropped` only fires for drag —
139
- * a file-picker selection reports its types on the outcome events, as
140
- * `dropzone_browse_opened` fires before any file exists.
69
+ * Provider-agnostic analytics hook. Event names and payload shapes live in
70
+ * DROPZONE_EVENTS / DropZoneEventProperties (drop-core/analytics.ts).
141
71
  */
142
72
  onTrack?: TrackFn;
143
- /**
144
- * Stable identifier for this instance, attached to every tracked event as
145
- * `dropzone_id`. Set it when a page renders more than one Drop Zone so the
146
- * events can be told apart in Amplitude.
147
- */
73
+ /** Stamped on every event as `dropzone_id` — set when a page has more than one zone. */
148
74
  analyticsId?: string;
149
75
  className?: string;
150
76
  }
@@ -1,17 +1,10 @@
1
1
  import { BuildReason } from './detectBuild';
2
- /**
3
- * The Drop Zone's analytics contract — the canonical event names and property
4
- * shapes, exported so no consumer (this package's own component, a host site's
5
- * GTM wiring, or another Netlify surface implementing its own Drop UI over
6
- * drop-core) ever hand-writes the strings.
7
- */
2
+ /** The analytics contract: canonical event names + property shapes, so no consumer hand-writes them. */
8
3
  /** How the files reached the zone — carried on every drop-initiated event as `method`. */
9
4
  export type DropMethod = 'drag' | 'browse';
10
5
  /**
11
- * Canonical Drop Zone lifecycle events. The values are the wire names:
12
- * analytics history in Amplitude/Segment keys off these exact strings, so
13
- * renaming a value silently forks every funnel built on it — treat them as
14
- * append-only.
6
+ * The wire names. Amplitude/Segment history keys off these exact strings —
7
+ * append-only, never rename.
15
8
  */
16
9
  export declare const DROPZONE_EVENTS: {
17
10
  /** Files arrived via drag — the picker path reports its files on outcome events instead. */
@@ -99,9 +92,5 @@ export interface DropZoneEventProperties {
99
92
  dropzone_project_stashed: ProjectStashedProps;
100
93
  dropzone_resumed: ResumedProps;
101
94
  }
102
- /**
103
- * Provider-agnostic analytics sink. Deliberately loose (string, not the event
104
- * union): hosts forward these to Segment/GA/GTM and often pipe their own
105
- * events through the same function.
106
- */
95
+ /** Provider-agnostic sink — loose on purpose, since hosts pipe their own events through it too. */
107
96
  export type TrackFn = (event: string, properties?: Record<string, unknown>) => void;
@@ -1,20 +1,13 @@
1
1
  import { BuildSite } from './types';
2
2
  /**
3
- * The transport both authenticated clients share: JSON calls ride the
4
- * consumer's access-control rewrite on the session cookie, so nothing
5
- * credential-shaped lives in the browser and nothing can expire mid-deploy.
6
- * (Uploads are the exception — the proxy's Lambda caps request bodies at
7
- * ~6MB — and each client handles its own, bearer-authorized.)
3
+ * Transport shared by both authenticated clients: JSON rides the consumer's
4
+ * access-control rewrite on the session cookie. Uploads are each client's own
5
+ * (bearer-direct — the proxy can't carry them).
8
6
  */
9
7
  /**
10
- * Create a site in the visitor's account via `POST {proxyBase}/sites` (scoped
11
- * to `accountSlug` when given, else the user's default account), attributed
12
- * `created_via: 'drop'`.
13
- *
14
- * A logged-out visitor 401s here, before anything is created — the one
15
- * pre-mutation point where callers may still safely fall back to an anonymous
16
- * flow, which is why it maps to `NotAuthenticatedError`. Any other failure is
17
- * a `SiteCreateError` carrying the status.
8
+ * `POST {proxyBase}/sites`, attributed `created_via: 'drop'`. A logged-out
9
+ * visitor 401s here, before anything is created — the one point an anonymous
10
+ * fallback is still safe, hence NotAuthenticatedError.
18
11
  */
19
12
  export declare function createSiteInAccount(proxyBase: string, accountSlug?: string): Promise<BuildSite>;
20
13
  /** How a watched deploy ended. `errorMessage` is the API's own explanation, when it gave one. */
@@ -27,15 +20,9 @@ export type SettledDeploy = {
27
20
  outcome: 'timed-out';
28
21
  };
29
22
  /**
30
- * Poll `GET {proxyBase}/deploys/{deployId}` on the session cookie until the
31
- * deploy settles, and report how. Purely mechanical on purpose: each caller
32
- * maps the outcome onto its own error vocabulary (the drop client throws plain
33
- * errors `humanizeDropError` understands; the build client throws
34
- * `BuildFailedError`/`BuildTimeoutError`), so that knowledge stays next to the
35
- * class it belongs to.
36
- *
37
- * A non-ok poll response is skipped, not fatal — a transient proxy hiccup
38
- * shouldn't kill a deploy that is still progressing.
23
+ * Polls the deploy on the session cookie and reports the terminal outcome —
24
+ * callers map it onto their own error vocabulary. Non-ok reads are skipped,
25
+ * not fatal: a proxy hiccup shouldn't kill a progressing deploy.
39
26
  */
40
27
  export declare function pollDeployUntilSettled(options: {
41
28
  proxyBase: string;
@@ -1,27 +1,13 @@
1
1
  import { DropClient } from './client';
2
2
  import { Digest, DropResponse } from './types';
3
3
  export interface AuthenticatedDropClientConfig {
4
- /**
5
- * Base for JSON API calls, routed through the consumer's access-control
6
- * rewrite so the session cookie authenticates them. On netlify.com that
7
- * rewrite is `/access-control/*` → the app's access-control function, which
8
- * makes `/access-control/bb-api/api/v1` the API root (the default here).
9
- */
4
+ /** Root for session-cookie JSON calls, via the consumer's access-control rewrite. */
10
5
  proxyBase?: string;
11
- /**
12
- * Direct API base for the file uploads. The proxy above runs in a Lambda with
13
- * a ~6MB request body limit, so file PUTs go straight to `api.netlify.com`
14
- * (whose `/api/*` CORS policy allows any origin).
15
- */
6
+ /** Direct base for file PUTs — the proxy's ~6MB Lambda body limit can't carry uploads. */
16
7
  apiBase?: string;
17
8
  /**
18
- * Mint a bearer token for those direct uploads. On netlify.com this is
19
- * `GET /access-control/generate-access-control-token`, whose
20
- * `accessControlToken` the API decrypts back into the user's access token.
21
- * Resolving `null` means "no session" and surfaces as `NotAuthenticatedError`.
22
- *
23
- * Called repeatedly, not once: the token issued to a non-app origin lives
24
- * only 30 seconds, which a multi-file upload routinely outlasts.
9
+ * Mint the upload bearer; `null` means "no session". Called repeatedly —
10
+ * non-app origins get 30-second tokens, which an upload queue outlasts.
25
11
  */
26
12
  getUploadToken: () => Promise<string | null>;
27
13
  /** Create the site in this account. Omit to use the user's default account. */
@@ -32,25 +18,10 @@ export interface AuthenticatedDropClientConfig {
32
18
  timeoutMs?: number;
33
19
  }
34
20
  /**
35
- * Authenticated drop client for logged-in visitors. Unlike `AnonymousDropClient`
36
- * — which creates an account-less site the visitor must later claim — this
37
- * deploys straight into the visitor's account via the sites/deploys API,
38
- * mirroring what app.netlify.com does for a logged-in drag-and-drop deploy.
39
- * There is no claim step, so the caller should hand off to the site's dashboard
40
- * page rather than the claim page.
41
- *
42
- * Requests split across two hosts by necessity. JSON calls (create the site,
43
- * create the deploy, poll it) go through the consumer's access-control proxy on
44
- * the session cookie — no token involved, and nothing that can expire mid-deploy.
45
- * File uploads can't: the proxy caps bodies at ~6MB, so they go direct to
46
- * `api.netlify.com` with a bearer, re-minted as it ages (see `TOKEN_REUSE_MS`).
47
- *
48
- * Error-mapping invariant: only pre-mutation failures — a null upload token at
49
- * the gate, or a 401/403 creating the site — throw `NotAuthenticatedError`,
50
- * which is the signal the drop flow may safely retry anonymously. Once the site
51
- * exists, any auth failure throws a plain error instead: falling back at that
52
- * point would strand an empty site in the account *and* deploy a duplicate
53
- * anonymously.
21
+ * Deploys a static drop straight into a logged-in visitor's account — no claim
22
+ * step. JSON rides the cookie proxy; file PUTs go direct on a re-minted bearer.
23
+ * Invariant: NotAuthenticatedError only pre-mutation — after the site exists, a
24
+ * fallback would strand an empty site and deploy a duplicate.
54
25
  */
55
26
  export declare class AuthenticatedDropClient implements DropClient {
56
27
  private proxyBase;
@@ -67,27 +38,14 @@ export declare class AuthenticatedDropClient implements DropClient {
67
38
  */
68
39
  getToken(): Promise<string>;
69
40
  /**
70
- * A token young enough to authorize an upload, minting a new one once the
71
- * cached one nears its 30s expiry. A mint failure here is a plain `Error`,
72
- * never `NotAuthenticatedError` — the site exists by now (class doc).
41
+ * A token younger than its 30s expiry. Mint failures here are plain Errors,
42
+ * never NotAuthenticatedError — the site exists by now (class doc).
73
43
  */
74
44
  private freshToken;
75
- /**
76
- * Two proxied calls: create the site in the visitor's account, then the
77
- * deploy on it. Mapped into the anonymous `DropResponse` shape so
78
- * `deployFiles` runs unchanged over either client.
79
- */
45
+ /** Site + deploy via the proxy, mapped into `DropResponse` so `deployFiles` runs unchanged. */
80
46
  createDeploy(files: Digest, _token: string): Promise<DropResponse>;
81
- /**
82
- * Direct to `api.netlify.com` on a freshly-aged bearer — the threaded `token`
83
- * is ignored because an upload queue easily outlives the 30 seconds it was
84
- * minted with. PUT (not POST) so paths with "&" etc. work.
85
- */
47
+ /** Direct on a fresh bearer (the threaded one has expired). PUT so paths with "&" work. */
86
48
  uploadFile(deployId: string, path: string, content: ArrayBuffer, _token: string): Promise<void>;
87
- /**
88
- * Poll the deploy through the proxy until it settles: resolve on `ready`,
89
- * throw on `error`/`rejected`, throw on timeout. On the session cookie rather
90
- * than a bearer, so a deploy taking minutes can't outlive its own credentials.
91
- */
49
+ /** Polls on the session cookie, so a slow deploy can't outlive its own credentials. */
92
50
  waitUntilReady(deploy: DropResponse, _token: string): Promise<void>;
93
51
  }
@@ -33,9 +33,8 @@ class B {
33
33
  return this.cachedToken = { value: e, mintedAt: Date.now() }, e;
34
34
  }
35
35
  /**
36
- * A token young enough to authorize an upload, minting a new one once the
37
- * cached one nears its 30s expiry. A mint failure here is a plain `Error`,
38
- * never `NotAuthenticatedError` — the site exists by now (class doc).
36
+ * A token younger than its 30s expiry. Mint failures here are plain Errors,
37
+ * never NotAuthenticatedError — the site exists by now (class doc).
39
38
  */
40
39
  async freshToken() {
41
40
  const e = Date.now();
@@ -45,11 +44,7 @@ class B {
45
44
  if (!t) throw new Error("could not renew the upload token");
46
45
  return this.cachedToken = { value: t, mintedAt: e }, t;
47
46
  }
48
- /**
49
- * Two proxied calls: create the site in the visitor's account, then the
50
- * deploy on it. Mapped into the anonymous `DropResponse` shape so
51
- * `deployFiles` runs unchanged over either client.
52
- */
47
+ /** Site + deploy via the proxy, mapped into `DropResponse` so `deployFiles` runs unchanged. */
53
48
  async createDeploy(e, t) {
54
49
  const o = await p(this.proxyBase, this.accountSlug), s = await fetch(`${this.proxyBase}/sites/${o.id}/deploys`, {
55
50
  method: "POST",
@@ -66,11 +61,7 @@ class B {
66
61
  required: n.required ?? []
67
62
  };
68
63
  }
69
- /**
70
- * Direct to `api.netlify.com` on a freshly-aged bearer — the threaded `token`
71
- * is ignored because an upload queue easily outlives the 30 seconds it was
72
- * minted with. PUT (not POST) so paths with "&" etc. work.
73
- */
64
+ /** Direct on a fresh bearer (the threaded one has expired). PUT so paths with "&" work. */
74
65
  async uploadFile(e, t, o, s) {
75
66
  const n = await this.freshToken(), r = await fetch(`${this.apiBase}/deploys/${e}/files${t}`, {
76
67
  method: "PUT",
@@ -79,11 +70,7 @@ class B {
79
70
  });
80
71
  if (!r.ok) throw l(`upload ${t}`, r.status);
81
72
  }
82
- /**
83
- * Poll the deploy through the proxy until it settles: resolve on `ready`,
84
- * throw on `error`/`rejected`, throw on timeout. On the session cookie rather
85
- * than a bearer, so a deploy taking minutes can't outlive its own credentials.
86
- */
73
+ /** Polls on the session cookie, so a slow deploy can't outlive its own credentials. */
87
74
  async waitUntilReady(e, t) {
88
75
  const o = await h({
89
76
  proxyBase: this.proxyBase,
@@ -2,7 +2,6 @@ import { BuildSite } from './types';
2
2
  export type { BuildSite } from './types';
3
3
  /** The subset of a Netlify Build returned by `POST /sites/{id}/builds`. */
4
4
  export interface BuildResponse {
5
- /** build id */
6
5
  id: string;
7
6
  /** the deploy the build produces — present as soon as the build is enqueued */
8
7
  deploy_id?: string;
@@ -13,28 +12,14 @@ export interface BuildClient {
13
12
  waitUntilBuildReady(build: BuildResponse): Promise<void>;
14
13
  }
15
14
  export interface AuthenticatedBuildClientConfig {
16
- /**
17
- * Base for JSON API calls, routed through the consumer's access-control
18
- * rewrite so the session cookie authenticates them. On netlify.com that
19
- * rewrite is `/access-control/*` → the app's access-control function, which
20
- * makes `/access-control/bb-api/api/v1` the API root (the default here).
21
- */
15
+ /** Root for session-cookie JSON calls, via the consumer's access-control rewrite. */
22
16
  proxyBase?: string;
23
- /**
24
- * Direct API base for the zip upload. The proxy above runs in a Lambda with a
25
- * ~6MB request body limit, so the multipart POST has to go straight to
26
- * `api.netlify.com` (whose `/api/*` CORS policy allows any origin).
27
- */
17
+ /** Direct base for the zip upload — the proxy's ~6MB Lambda body limit can't carry it. */
28
18
  apiBase?: string;
29
19
  /**
30
- * Mint a bearer token for that direct upload. On netlify.com this is
31
- * `GET /access-control/generate-access-control-token`, whose
32
- * `accessControlToken` the API decrypts back into the user's access token.
33
- * Resolving `null` means "no session" and surfaces as `NotAuthenticatedError`.
34
- *
35
- * Note the token issued to a non-app origin lives only 30 seconds. It is
36
- * minted immediately before the upload, but a zip that takes longer than that
37
- * to transfer will still be rejected mid-flight — see `createBuildFromZip`.
20
+ * Mint the upload bearer; `null` means "no session". Non-app origins get
21
+ * 30-second tokens — a zip slower than that fails mid-flight (see
22
+ * `createBuildFromZip`).
38
23
  */
39
24
  getUploadToken: () => Promise<string | null>;
40
25
  /** Create the site in this account. Omit to use the user's default account. */
@@ -47,16 +32,9 @@ export interface AuthenticatedBuildClientConfig {
47
32
  timeoutMs?: number;
48
33
  }
49
34
  /**
50
- * Authenticated drop client for projects that need a build. Unlike
51
- * `AnonymousDropClient` — which creates an account-less static site and can only
52
- * upload pre-built files — this creates a real site in the user's account and
53
- * hands buildbot a source archive to build, mirroring what app.netlify.com does
54
- * for a drag-and-drop build.
55
- *
56
- * Requests split across two hosts by necessity: JSON calls go through the
57
- * consumer's access-control proxy (cookie session, no token handling in the
58
- * browser), while the zip upload goes direct to `api.netlify.com` with a
59
- * short-lived bearer token because the proxy can't carry a body that large.
35
+ * Builds a drop in a logged-in visitor's account: create the site, hand
36
+ * buildbot the source zip. JSON rides the cookie proxy; the zip goes direct
37
+ * with a bearer (the proxy can't carry it).
60
38
  */
61
39
  export declare class AuthenticatedBuildClient implements BuildClient {
62
40
  private proxyBase;
@@ -67,35 +45,23 @@ export declare class AuthenticatedBuildClient implements BuildClient {
67
45
  private pollIntervalMs;
68
46
  private timeoutMs;
69
47
  constructor({ proxyBase, apiBase, getUploadToken, accountSlug, title, pollIntervalMs, timeoutMs, }: AuthenticatedBuildClientConfig);
70
- /**
71
- * Create the site the build deploys into. A logged-out visitor fails here,
72
- * before anything is created — see `createSiteInAccount` for the error
73
- * mapping that makes the signup fallback safe.
74
- */
48
+ /** A logged-out visitor fails here, before anything is created (see `createSiteInAccount`). */
75
49
  createSite(): Promise<BuildSite>;
76
50
  /**
77
- * Upload the source archive and enqueue a build. Direct to `api.netlify.com`
78
- * (see the note on `apiBase`), authorized by a freshly minted bearer token.
79
- * `Content-Type` is left unset on purpose so the browser adds the multipart
80
- * boundary itself.
51
+ * One multipart request on a fresh 30s bearer — a slower zip fails mid-flight
52
+ * (the app origin gets 300s; raising ours is a platform-side change).
53
+ * Content-Type stays unset so the browser adds the multipart boundary.
81
54
  *
82
- * Known ceiling: this is one request on a 30s token, and re-minting can't
83
- * help once it is in flight. A zip that takes longer than that to upload will
84
- * fail — the app origin gets 300s for exactly this reason, and lifting the
85
- * limit for other origins is a platform-side change.
55
+ * Never NotAuthenticatedError, including for a 401: the site exists by the
56
+ * time this runs, so signalling "no session" would strand it and re-stash
57
+ * the drop for the next visit to strand another. `createSite` is the auth
58
+ * gate for this path.
86
59
  */
87
60
  createBuildFromZip(siteId: string, zip: File): Promise<BuildResponse>;
88
61
  /**
89
- * Poll the build's deploy until it settles, mirroring
90
- * `AnonymousDropClient.waitUntilReady` — resolve on `ready`, throw on
91
- * `error`/`rejected`, throw on timeout. A build that hasn't been given a
92
- * deploy id yet has nothing pollable, so it resolves immediately and the
93
- * caller falls back to the site page.
94
- *
95
- * Optional in the drop flow, and off by default: a build takes minutes, so
96
- * the useful hand-off is usually the project page rather than a spinner.
97
- * Polling rides the session cookie, so it cannot outlive its credentials the
98
- * way a 30s bearer would.
62
+ * Optional (a build takes minutes; the useful hand-off is the project page).
63
+ * Polls on the cookie, so it can't outlive its credentials; no deploy id yet
64
+ * means nothing pollable, so it resolves immediately.
99
65
  */
100
66
  waitUntilBuildReady(build: BuildResponse): Promise<void>;
101
67
  }