You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(fs-http)!: remove DOM coupling from download/preview (0.3.0)
Closes#59. fs-http should be HTTP transport, not browser download
UX. The previous downloadRequest/previewRequest methods constructed
Blobs, created `<a>` elements, dispatched clicks, and managed object
URL lifecycles — coupling that bled into every consumer's tests as
fragile global stubs (vi.stubGlobal of `Blob`/`document`/`window.URL`),
exposed to vitest 4's class-mock requirement and oxfmt's arrow-function
collapse. Three territories independently rediscovered the mitigation.
Reshape both methods to pure transport: `(endpoint, options?) →
Promise<AxiosResponse<Blob>>`. The DOM-side download dance moves to
`@script-development/fs-helpers` ≥ 0.1.2 as `triggerDownload(blob,
filename)`. Object-URL lifecycle for previews is now the consumer's
concern (one `URL.createObjectURL` line, plus revocation on cleanup).
BREAKING CHANGES (fs-http 0.2.0 → 0.3.0):
- downloadRequest(endpoint, documentName, type?) → AxiosResponse
becomes downloadRequest(endpoint, options?) → AxiosResponse<Blob>.
- previewRequest(endpoint) → string (object URL)
becomes previewRequest(endpoint, options?) → AxiosResponse<Blob>.
- Removed HEADERS_TO_TYPE map (one-entry OOXML lookup, did not earn
its place in transport-layer code; consumers can supply their own
if needed).
Cascade workspace bumps to keep the lock coherent:
- fs-helpers 0.1.1 → 0.1.2 (additive: triggerDownload export +
happy-dom devDep).
- fs-adapter-store 0.1.5 → 0.1.6 (peer range widened to include
^0.3.0 — not a behavior change; doesn't depend on download/preview).
- fs-loading 0.1.1 → 0.1.2 (same widening; same rationale).
Out of scope (separate dispositions):
- streamRequest's `document.cookie` XSRF read remains. It's the only
remaining DOM touch in fs-http; cleanup would require either a
required `xsrfHeader` option or a cookie-reader middleware shipped
alongside, both bigger migrations than #59 covers.
- Consumer territory upgrades. Land this PR after #60, then run a
post-publish migration campaign across kendo, ublgenie, emmie,
entreezuil, and BIO (5 download/preview call sites in production
code; ~50 in test mocks).
Verified locally:
- 19 test files / 430 tests pass (was 18/430; +2 fs-helpers, -2 net
fs-http after dropping obsolete DOM-orchestration tests).
- 100% coverage maintained on fs-http and fs-helpers.
- mutation: fs-http 97.30% (up from 95.74%; less surface to mutate),
fs-helpers 100% (including the new dom-download.ts).
- All 8 CI gates locally green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/http/CHANGELOG.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,39 @@
1
1
# @script-development/fs-http
2
2
3
+
## 0.3.0 — 2026-04-30
4
+
5
+
### Breaking Changes
6
+
7
+
-**`downloadRequest` no longer touches the DOM.** Signature changes from `(endpoint, documentName, type?) → Promise<AxiosResponse>` to `(endpoint, options?) → Promise<AxiosResponse<Blob>>`. The browser download dance (`Blob` construction, `<a>` element, `link.click`, object URL lifecycle) moves to consumer code. Use `triggerDownload(blob, filename)` from `@script-development/fs-helpers` ≥ 0.1.2 to reproduce the prior behavior in one call.
8
+
-**`previewRequest` no longer touches the DOM.** Signature changes from `(endpoint) → Promise<string>` (object URL) to `(endpoint, options?) → Promise<AxiosResponse<Blob>>` (response with the raw Blob). Consumers manage object-URL lifecycle: `URL.createObjectURL(response.data)` to render and `URL.revokeObjectURL(...)` on cleanup.
9
+
-**Removed:**`HEADERS_TO_TYPE` map (was used internally to resolve OOXML to xlsx). Consumers that need MIME mapping can supply their own table; the prior table was a one-entry lookup that did not earn its place in transport-layer code.
10
+
11
+
### Why
12
+
13
+
`fs-http` should be HTTP transport. Coupling to `Blob`, `document.createElement`, and `URL.createObjectURL`/`revokeObjectURL` made every consumer's tests responsible for stubbing browser globals — fragile under formatters (oxfmt collapsed `function () { return obj }` into arrow-functions, breaking constructor-mock patterns across kendo and ublgenie in April 2026), exposed to vitest 4's class-mock requirement, and a coupling smell between library and test environment. Closes [#59](https://github.com/script-development/fs-packages/issues/59).
0 commit comments