Skip to content

Chunked JS surface — types, codegen spec, chunkPlan - #32

Merged
dmurphy5 merged 1 commit into
dylan/v9-3-configurefrom
dylan/v9-4-chunked-spec
Sep 3, 2026
Merged

Chunked JS surface — types, codegen spec, chunkPlan#32
dmurphy5 merged 1 commit into
dylan/v9-3-configurefrom
dylan/v9-4-chunked-spec

Conversation

@dmurphy5

@dmurphy5 dmurphy5 commented Aug 24, 2026

Copy link
Copy Markdown

This PR adds the TypeScript surface for chunked uploads. It contains no engine code.

The new API is startUpload with type: 'chunked'. The options are:

  • id — the upload id. The consumer supplies it. It is required.
  • path — the file to send.
  • parts — a list of parts. Each part has a URL, headers, and a byte range.
  • accept — rules that say which HTTP responses are a success. Each rule is a status code and optional body text. These rules replace acceptStatus in all upload types, so the library has one shape.
  • expiresAt — the time when the library must stop the upload. It is required.

The library validates the parts. The first part must start at byte 0. Each next part must start where the last part ends.

The PR adds two functions. chunkPlan is a pure function: give it a file size, and it returns the byte ranges for the parts. A property test sweeps every size at a reduced scale. removeUpload releases a stopped upload's file and records.

Codegen cannot model the raw/chunked union. Thus the native side gets a separate startChunkedUpload entry point. The public startUpload stays one function and routes on options.type.

The native functions are stubs on both platforms. They return E_NOT_IMPLEMENTED. Thus this PR compiles and passes CI alone. The engine PRs above this one replace the stubs.

The PR also turns on noUncheckedIndexedAccess. Diana type-checks the shipped .ts files with that setting, so the library must catch those breaks first.

🤖 Generated with Claude Code

@dmurphy5
dmurphy5 marked this pull request as ready for review August 25, 2026 17:24
@dmurphy5 dmurphy5 changed the title v9 4/7: chunked JS surface — types, codegen spec, chunkPlan Chunked JS surface — types, codegen spec, chunkPlan Aug 25, 2026
@dmurphy5
dmurphy5 force-pushed the dylan/v9-4-chunked-spec branch from c3aab42 to 6d72a23 Compare August 25, 2026 17:36
@dmurphy5
dmurphy5 marked this pull request as draft August 25, 2026 17:38
@dmurphy5
dmurphy5 force-pushed the dylan/v9-4-chunked-spec branch 2 times, most recently from 1ad28fb to a41621c Compare August 27, 2026 19:46
@dmurphy5
dmurphy5 marked this pull request as ready for review August 27, 2026 19:51
Per docs/design/chunked-uploads.md. ChunkedUploadOptions (consumer-authored
parts, required expiresAt), accept rules replacing acceptStatus on all
uploads, errorKind 'expired', removeUpload, and chunkPlan — the deterministic
greedy split the consumer calls so the create POST's part count and the parts
array derive from one result. startUpload becomes a discriminated union and
validates chunked input before crossing the bridge; codegen gets a separate
startChunkedUpload entry point because it cannot model the union.

No native implementation yet — the stack is runtime-complete at its tip.

Native entry points for startChunkedUpload/removeUpload are stubs that reject
with E_NOT_IMPLEMENTED so this change compiles on both platforms on its own;
the Android and iOS engine changes replace them.

noUncheckedIndexedAccess is on: Diana type-checks this package's shipped .ts
under its own stricter config, so the library catches those breaks first.

Final review fixes:
- validateChunkedOptions now requires the parts to tile the file from byte 0
  (sorted ascending, no gaps or overlaps), and each part to carry a non-empty
  url and plain-object headers — all rejected before the bridge.
- startUpload JSDoc scopes idempotency: identical parts reconcile at any time;
  differing parts are a recreate, rejected while the upload is running.
- removeUpload JSDoc covers the raw-upload case (cancels, no terminal event).
- Tests for gap/overlap/out-of-order/nonzero-first-start/empty-url/bad-headers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dmurphy5
dmurphy5 force-pushed the dylan/v9-4-chunked-spec branch from a41621c to 29ac8f7 Compare August 28, 2026 16:49
@dmurphy5
dmurphy5 merged commit 931c1bc into dylan/v9-3-configure Sep 3, 2026
3 checks passed
dmurphy5 added a commit that referenced this pull request Sep 3, 2026
This PR moves the merged chunked-upload work onto master. It replaces
#39, which conflicted.

The stacked PRs #32#35 were reviewed and merged, but their stack was
rooted on `dylan/v9-3-configure`, so their four squash commits landed on
that branch and not on master. This branch carries those same four
commits, cherry-picked onto the current master. The tree at the tip is
byte-identical to the merged stack. There are no new changes, and there
are no conflicts: the branch is a fast-forward of master.

- Chunked JS surface — types, codegen spec, chunkPlan (#32)
- Android chunked-upload engine (#33)
- iOS chunked-upload engine (#34)
- Global cap, example app, docs, v9.0.0 (#35)

Prefer "Rebase and merge", so the four commits keep their identities on
master. After the merge, master is v9.0.0 and gets the `v9.0.0` tag.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@dmurphy5
dmurphy5 deleted the dylan/v9-4-chunked-spec branch September 3, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants