# Tasks: enterprise-streams - **Change ID**: enterprise-streams - **Package**: `@suaveplan/streams` - **Date**: 2026-04-24 ## Prerequisites (must be published to Verdaccio first) - [x] `@suaveplan/error` - [x] `@suaveplan/types` ## Tasks ### 1. Scaffold package - [x] Create `universal/streams/streams/` directory tree per file layout in `proposal.md` - [x] Write `package.json` (name `@suaveplan/streams`, version `0.1.0`, `sideEffects: false`, correct workspace deps and catalog externals) - [x] Write `tsconfig.json` extending `@suaveplan/typescript-config/library.json` - [x] Write `vitest.config.ts` using `createTestConfig()` from `@suaveplan/testing/config` ### 2. Error codes (`src/error-codes.ts`) - [x] Define `StreamErrorCode` union type - [x] Call `defineCodes` to register all `STREAM.*` codes - [x] Export `registerStreamErrorCodes()` and `StreamError` ### 3. Types (`src/types/common.ts`) - [x] Define and export `ReadableOptions`, `TransformOptions`, `InstrumentOptions` - [x] Write `common.md` ### 4. Readable factories - [x] `fromArray` in `src/readable/from-array/` - [x] `fromAsyncGenerator` in `src/readable/from-generator/` - [x] `fromBytes` in `src/readable/from-bytes/` - [x] Each: `.ts`, `.md`, `.test.ts`, `index.ts` ### 5. Transform factories - [x] `mapStream`, `filterStream`, `flatMapStream`, `batchStream`, `tapStream`, `limitStream` in `src/transforms/` - [x] `encodeTextStream`, `decodeTextStream` in `src/transforms/text-codec/` - [x] `compressStream`, `decompressStream` (using `CompressionStream` / `DecompressionStream` WHATWG API) in `src/transforms/compress/` - [x] Each: `.ts`, `.md`, `.test.ts`, `index.ts`; `highWaterMark` and `AbortSignal` support ### 6. Sink utilities - [x] `toArray`, `toBytes`, `toString`, `forEach`, `toWritable` in `src/sinks/` - [x] Each: `.ts`, `.md`, `.test.ts`, `index.ts`; `AbortSignal` cancellation ### 7. Pipeline builder (`src/pipeline/pipeline-builder/`) - [x] Implement type-safe `PipelineBuilder` with `.pipe()`, `.collect()`, `.drain()`, `.forEach()` - [x] `fanOut` and `merge` in respective `src/pipeline/` subdirectories - [x] Each: `.ts`, `.md`, `.types.ts`, `.test.ts`, `index.ts` ### 8. Instrumentation (`src/instrument/instrument-transform/`) - [x] Implement `instrumentTransform` wrapping any named transform with OTel span + counters - [x] Write `.md`, `.types.ts`, `.test.ts`, `index.ts` ### 9. Node.js adapters (`src/node/node-adapters.ts`) - [x] `fromNodeReadable`, `toNodeReadable`, `fromNodeWritable` - [x] Guard with `typeof process !== 'undefined'` check; throw `StreamError` in browser contexts - [x] Write `node-adapters.md` and `node-adapters.test.ts` ### 10. OTel instrumentation - [x] Add spans, counters, histograms per `proposal.md` §4 ### 11. Tests - [x] Unit tests co-located (100% coverage target) - [x] `tests/integration.test.ts` — multi-stage pipelines including Node adapter - [x] `tests/property.test.ts` — fast-check properties per `proposal.md` §5 ### 12. Benchmarks (`src/__benchmarks__/streams.bench.ts`) - [x] Implement benchmark cases per `proposal.md` §6 ### 13. Docs - [x] Every `.ts` implementation file has a sibling `.md` - [x] Root `README.md` ### 14. Pre-publish gate - [x] `bunx turbo lint typecheck test --filter=@suaveplan/streams` green - [x] `bunx turbo test:coverage --filter=@suaveplan/streams` ≥ 100% on touched modules ### 15. Publish - [x] `bun scripts/publish.ts --package @suaveplan/streams` ### 16. Archive - [x] Fold spec delta into `openspec/specs/streams/spec.md` - [x] `mv openspec/changes/enterprise-streams openspec/archive/2026-04-24-enterprise-streams`