v0.18.0
Structural-cleanup minor. Thinner ChunkyManager, namespaced config,
deduplicated request validation, generic Echo channel, removed dead
flags. The runtime behaviour is the same — see UPGRADE.md
for the config & API migration details.
Added
BatchTrackercontract (NETipar\Chunky\Contracts\BatchTracker) with two implementations (DatabaseBatchTracker,FilesystemBatchTracker). The Database implementation runs the increment helpers in a transaction withlockForUpdate(), eliminating the read-modify-write race that the old in-managermarkUploadCompleted/Failedhad. Hidden behind the samechunky.trackerconfig switch.ContextRegistrysupport class holds the validation-rules + save-callback registry.ChunkyManagerdelegates the publicregister()/simple()/context()helpers to it for back-compat, but the registry can also be resolved directly from the container.ValidMetadatavalidation rule caps per-value length (default 1KB), total serialized size (default 16KB), and disallows non-scalar values. Wired up in the baselineInitiateUploadRequestrules.AbstractInitiateUploadRequestholds the shared baseline rules;InitiateUploadRequestandInitiateBatchUploadRequestare now thin subclasses that just apply context-specific rules. Adding a new constraint touches one place instead of two.- Generic
EchoChannel<EventMap>interface (packages/core/src/echo.ts) lets typed Echo wrappers narrow event payloads instead of falling back toany. UploadError.cancelledflag lets the caller distinguish "user explicitly cancelled" from "transport/server failure" without parsing the message.UploadError.causeis now typed asUploadHttpError | Errorinstead ofunknown.BatchStatus::Cancelledenum case (the v0.19 batch-cancel API will use it; carved out now to keep the enum forward-compatible).tsconfig.base.jsonat the repo root, extended by every package'stsconfig.jsonandtsconfig.build.json. Removes the 4-way copy-paste of compiler options.
Changed (breaking)
- Config keys reshaped into 8 namespaces (
chunks,storage,lifecycle,limits,locking,idempotency,cache,broadcasting). See UPGRADE.md for the full mapping. Republish the config or hand-edit per the migration table. ChunkyManagerconstructor takes four arguments now —(ChunkHandler, UploadTracker, BatchTracker, ContextRegistry). Container-bound callers are unaffected.ChunkHandler::assemble()acceptsUploadMetadatainstead of(string $uploadId, string $fileName, int $totalChunks). Handlers get access tofileSizefor the disk-space + integrity checks landed in v0.17.2; custom implementations need to update the signature.- Removed
chunky.idempotency.enabledflag — idempotency is always on (always was, really; the flag had no realistic use case). - Removed
chunky.skip_local_disk_guardflag — the boot-time guard now keys offchunky.locking.driverdirectly. Set the driver tocachefor cloud disks. - Removed
chunky.broadcasting.user_channelflag — the user channel is registered whenever an event has a non-nulluserId. No flag needed. TrackerDriverenum is now actively used in the service provider, the config validator, and every place that previously magic-strungconfig('chunky.tracker') === 'database'. Adding a new driver is now a single enum case + match arm.pause()aborts the in-flight chunk POST inChunkUploader. The previous flag-only pause raced withcancel()— a paused chunk would complete naturally before the cancel registered. The catch path skips the error event when bothabortedandisPausedare set, so the resume can pick up cleanly.- Echo
listenForUser/listenForUploadEvents/listenForBatchCompleteunsubscribe only the events the caller registered. The old implementation calledstopListeningfor every event in the channel, which would detach a sibling consumer (two components on the same channel) on cleanup.
Documentation
- UPGRADE.md has a full v0.17 → v0.18 section with the config mapping table, constructor changes, handler signature change, removed flags, and
BatchStatus::Cancellednotice.
npm packages
- All packages bumped to
0.18.0(frontend changes —EchoChannel<EventMap>,UploadError.cancelled, pause/cancel race fix,tsconfig.base.jsonextraction).