Skip to content

W-23516605: Split Node binding into focused modules#130

Merged
mlischetti merged 1 commit into
masterfrom
W-23516605-refactor-node-binding
Jul 20, 2026
Merged

W-23516605: Split Node binding into focused modules#130
mlischetti merged 1 commit into
masterfrom
W-23516605-refactor-node-binding

Conversation

@mlischetti

Copy link
Copy Markdown
Contributor

What

Behavior-preserving refactor of the @dataweave/native Node.js binding (native-lib/node), tracked by W-23516605. Splits the monolithic
src/index.ts into 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

File Contents
src/errors.ts DataWeaveError / DataWeaveScriptError
src/reader.ts createChunkReader — the pure sync/async iterable → pull-based byte reader used by runTransform
src/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
src/dataweave.ts the DataWeave class + module-level singleton API; methods reduced to wiring over the extracted helpers (libPath is now readonly)
src/index.ts thin barrel re-exporting the same public names (main = dist/index.js consumers unaffected) — 292 → 11 lines

All extracted modules carry TSDoc.

Testing

  • tsc --noEmit clean
  • npm run test:unit35 passed
  • npm run test:integration14 passed against the real native library (behavior-preservation proof — exercises run, runStreaming, and runTransform over both sync and async iterables)

Follow-ups

  • W-23516608 — unit tests for the extracted reader / stream / errors modules (depends on this PR)
  • Group B (integration) and Group C (TCK) remain.

🤖 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.

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>
@mlischetti
mlischetti requested a review from a team as a code owner July 20, 2026 18:59
@mlischetti
mlischetti merged commit 2560a16 into master Jul 20, 2026
3 checks passed
@mlischetti
mlischetti deleted the W-23516605-refactor-node-binding branch July 20, 2026 19:14
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