Conversation
This was referenced May 26, 2026
This was referenced May 26, 2026
lib/terminate_generated.ts is walked from the same shared terminate-upload-with-retry procedure the Go, C#, and Python clients emit. The retry decisions stay in protocol_generated.ts (tusPlanRetryAfterError and friends); the new module owns only the loop, with the DELETE transport and the wait timer passed in as host closures. terminate() delegates with its public signature and DetailedError behavior unchanged; the handwritten recursive retry is deleted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The _performUpload/_handleUploadResponse mutual recursion now emits from the shared statement-IR walker as lib/upload_chunks_generated.ts: the loop settles each response exchange (offset resync, accepted-bytes emissions, completion exit), checks abort at the test-pinned points, and PATCHes the next chunk through the host byte-source transport. Retry scheduling stays the handwritten _retryOrEmitError start() re-entry; errors leave the generated loop untouched on their way there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
_retryOrEmitError's decision pass (abort guard, retryable narrowing, the two-phase retry plan with the onShouldRetry policy round, attempt/offset bookkeeping, schedule-or-emit) now emits from the shared statement-IR walker into lib/retry_scheduling_generated.ts. The retry decisions stay imported from protocol_generated.ts; the upload keeps only the state and timer closures (setTimeout into _retryTimeout, cleared by the abort plan), and the full start() re-entry semantics are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
_prepareAndStartUpload/_startSingleUpload/_createUpload/_resumeUpload's orchestration (fingerprint, source open, size derivation, the parallel branch point, the abort reset, resume-or-create dispatch, the creation and resume flows with their settlement/emission/storage order, and the chunk-loop entries) now emits from the shared statement-IR walker into lib/upload_lifecycle_generated.ts. The request/response decisions stay imported from protocol_generated.ts; the upload keeps only the host seams (the per-attempt creation/HEAD transports, the settlements over the generated plans, and the state closures). The 1-line _performUpload/_handleUploadResponse wrappers collapsed into the generated flows' uploadChunks entries; start()'s floating catch and validation stay the handwritten wrapper on purpose (the no-await floating-promise semantics and non-Error normalization are host idioms). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
This is the first generated island for the API2-owned TUS protocol SDK generator. It lets the API2 generator rewrite and compare protocol constants and checked examples before expanding into more client behavior, while keeping this PR as experimental Draft work.
Experimental Status
Experimental work: this PR is part of an exploratory contract/generated docs and SDK effort, and is intentionally kept as a Draft while the approach is validated.
What
lib/options.tswith generated-region markers.createTusUploadandpatchTusUploadsteps against tus-js-client behavior.scenario.upload.headersinto TUS upload options when present, keeping the header facts contract-owned.onShouldRetrydecision instead of observing unrelated global timers from other specs.api2-devdock-tus-custom-request-headersexample that uses the publicheadersoption and request hooks to prove custom headers are sent onPOSTandPATCH.api2-devdock-tus-request-id-headersexample that enablesaddRequestIdfrom scenario JSON and observes generatedX-Request-IDvalues onPOSTandPATCHthrough public request hooks.api2-devdock-tus-upload-body-headersexample that reads expectedPOSTandPATCHupload body headers from scenario JSON and observes them through public request hooks.api2-devdock-tus-deferred-length-uploadexample that reads the generated scenario, enablesuploadLengthDeferred, and observes generatedUpload-Defer-Length/Upload-Lengthheader constants onPOST/PATCH.api2-devdock-tus-request-lifecycle-hooksexample that reads expected lifecycle methods/status codes from scenario JSON and observesonBeforeRequest/onAfterResponsethrough public request hooks.api2-devdock-tus-relative-location-resolutionexample that reads a TUS conformance scenario, uses a contract-backed HTTP stack, and proves publicUploadresolves a relativeLocationresponse to the expected absolute upload URL.api2-devdock-tus-override-patch-methodexample that reads a TUS conformance scenario and proves publicUploadsends the effectivePOSTrequest withX-HTTP-Method-Override: PATCH.api2-devdock-tus-node-path-input-sourceexample that reads a TUS conformance scenario and proves publicUploadcan upload a Node path-reference input source.Readablerequest bodies, count bytes, and emit progress so Node path-reference examples exercise the same body class as the real Node HTTP stack.api2-devdock-tus-start-option-validationexample that reads a TUS conformance scenario and proves publicUploadrejects conflictingparallelUploads/uploadUrloptions before any HTTP request is made.inputOptionEntriescan become public tus-jsUploadoptions without hardcoding each example's rule.api2-devdock-tus-detailed-errorexample that reads TUS conformance scenarios and proves publicUploadreportsDetailedErrorinstances for both response errors and request errors with request context, response context when present, and causing errors when present.api2-devdock-tus-resume-uploadexample so a stricter scenario can prove file-backed URL storage via public resume APIs, capturing the persisted key prefix, remaining storage entries, and backend kind from runtime behavior.api2-devdock-tus-abort-uploadexample that reads TUS conformance scenarios and proves publicUpload.abort(...)behavior for aborting an active create request and aborting an active patch request before terminating the stored upload.request-abortevent capture, runtime fingerprint setup, and contract-owned abort execution actions.api2-devdock-tus-retry-state-transitionsexample that reads contract-owned retry decisions/schedules and proves publiconShouldRetryplus timer behavior through the offset-recovery flow.api2-devdock-tus-protocol-version-selectionexample and generic absent/exact-header checks in the shared conformance HTTP stack, proving draft-05 create/chunked and draft-03 resume protocol selection from API2 scenario facts.api2-devdock-tus-parallel-upload-concatexample that reads the contract-owned parallel concat conformance scenario and proves publicUploadcreates two partial uploads, sends the expected byte slices, concatenates them with the expected finalUpload-Concat, and reports the normalized meaningful progress/chunk-complete event sequence.Verification
npm run build-transpilenpm run lint-codeapi2/bin/cli.ts contracts sdks --no-motd --target tus --platform typescript --sdk-root ../tus-js-client --compare-existingnpm run test-nodenpm run test-node -- --seed=09053node --check examples/api2-devdock-shared/scenario.jsnode --check examples/api2-devdock-tus-custom-request-headers/main.jsnode --check examples/api2-devdock-tus-request-id-headers/main.jsnode --check examples/api2-devdock-tus-upload-body-headers/main.jsnode --check examples/api2-devdock-tus-deferred-length-upload/main.jsnode --check examples/api2-devdock-tus-relative-location-resolution/main.jsnode --check examples/api2-devdock-tus-override-patch-method/main.jsnode --check examples/api2-devdock-tus-node-path-input-source/main.jsnode --check examples/api2-devdock-tus-start-option-validation/main.jsnode --check examples/api2-devdock-tus-detailed-error/main.jsnode --check examples/api2-devdock-tus-resume-upload/main.jsnode --check examples/api2-devdock-tus-abort-upload/main.jsnode --check examples/api2-devdock-tus-retry-state-transitions/main.jsnode --check examples/api2-devdock-tus-protocol-version-selection/main.jsnode --check examples/api2-devdock-tus-parallel-upload-concat/main.jsapi2-devdock-tus-node-path-input-sourceapi2-devdock-tus-start-option-validationapi2-devdock-tus-detailed-errorscenariosapi2-devdock-tus-abort-uploadscenariosapi2-devdock-tus-retry-state-transitionsapi2-devdock-tus-protocol-version-selectionscenariosapi2-devdock-tus-parallel-upload-concatcore/bin/devdock.ts exec tstrun system/sdk_examples/typescript-tus-transloadit-assembly-upload.test.ts -vv --max-time-per-test 900Companion PRs (tus org only)