Skip to content

Add pkg/transform: public library for running transforms - #224

Merged
ashmanto merged 1 commit into
masterfrom
feat/public-lib
Apr 27, 2026
Merged

Add pkg/transform: public library for running transforms#224
ashmanto merged 1 commit into
masterfrom
feat/public-lib

Conversation

@ashmanto

Copy link
Copy Markdown
Contributor

Exposes Run(ctx, source, entities, opts) which compiles TS/JS via esbuild,
executes transform_entities() in goja with the same host functions and JS
helpers the production hub registers, and returns entities + captured logs.

Self-contained — no dependency on internal/* — so external consumers can
import it without pulling in CLI internals. The existing mim transform test
command continues to use internal/transform/ unchanged.

Notable details:

  • esbuild Transform output has top-level import/export stripped before handing to goja, since goja treats them as reserved-word syntax errors.
  • import * as dh from "datahub-tslib" namespace aliases are resolved by emitting a shim object that binds every host fn + helper as a property.
  • Result.Logs/Entities are always non-nil so JSON marshals to [] not null for downstream JS consumers.
  • ctx cancellation and Options.Timeout both interrupt long-running scripts via engine.Interrupt

Exposes Run(ctx, source, entities, opts) which compiles TS/JS via esbuild,
  executes transform_entities() in goja with the same host functions and JS
  helpers the production hub registers, and returns entities + captured logs.

  Self-contained — no dependency on internal/* — so external consumers can
  import it without pulling in CLI internals. The existing mim transform test
  command continues to use internal/transform/ unchanged.

  Notable details:
  - esbuild Transform output has top-level import/export stripped before
    handing to goja, since goja treats them as reserved-word syntax errors.
  - `import * as dh from "datahub-tslib"` namespace aliases are resolved by
    emitting a shim object that binds every host fn + helper as a property.
  - Result.Logs/Entities are always non-nil so JSON marshals to `[]` not
    `null` for downstream JS consumers.
  - ctx cancellation and Options.Timeout both interrupt long-running scripts
    via engine.Interrupt
@ashmanto
ashmanto merged commit cc13ba9 into master Apr 27, 2026
2 checks passed
@ashmanto
ashmanto deleted the feat/public-lib branch April 27, 2026 07:26
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