W-23516605: Split Node binding into focused modules#130
Merged
Conversation
Behavior-preserving extraction of src/index.ts to improve readability and expose pure logic for unit testing. No behavior changes; public export surface and the existing integration suite are unchanged. - errors.ts: DataWeaveError / DataWeaveScriptError. - reader.ts: createChunkReader — the pure sync/async iterable → pull-based byte reader used by runTransform. - stream.ts: streamFromNative — the pure callback→async-generator bridge, deduplicating the producer/consumer/backpressure block previously copied between runStreaming and runTransform. The native call is injected so the bridge is testable without the addon. - dataweave.ts: the DataWeave class and module-level singleton API; methods reduced to wiring over the extracted helpers. libPath is now readonly. - index.ts: thin barrel re-exporting the same public names (main = dist/index.js consumers unaffected). All modules carry TSDoc. Verified: tsc clean, 35 unit tests pass, 14 integration tests pass against the real native library. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
andres-rad
approved these changes
Jul 20, 2026
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.
What
Behavior-preserving refactor of the
@dataweave/nativeNode.js binding (native-lib/node), tracked by W-23516605. Splits the monolithicsrc/index.tsinto focused modules to improve readability and expose pure logic for unit testing.No behavior changes. The public export surface and the existing integration suite are unchanged. This unblocks the follow-up unit-testing story
(W-23516608).
Changes
src/errors.tsDataWeaveError/DataWeaveScriptErrorsrc/reader.tscreateChunkReader— the pure sync/async iterable → pull-based byte reader used byrunTransformsrc/stream.tsstreamFromNative— the pure callback→async-generator bridge, deduplicating the producer/consumer/backpressure block previously copied betweenrunStreamingandrunTransform; the native call issrc/dataweave.tsDataWeaveclass + module-level singleton API; methods reduced to wiring over the extracted helpers (libPathis nowreadonly)src/index.tsmain = dist/index.jsconsumers unaffected) — 292 → 11 linesAll extracted modules carry TSDoc.
Testing
tsc --noEmitcleannpm run test:unit→ 35 passednpm run test:integration→ 14 passed against the real native library (behavior-preservation proof — exercisesrun,runStreaming, andrunTransformover both sync and async iterables)Follow-ups
reader/stream/errorsmodules (depends on this PR)🤖 Generated with Claude Code
Once it's up and merged, ping me and I'll start W-23516608 (the unit tests for the extracted modules) off a freshly-synced master.