Skip to content

Email attachment builder: typed-array helper + worker test#988

Open
guybedford wants to merge 1 commit intomainfrom
feat/email-typed-array-attachment-builder
Open

Email attachment builder: typed-array helper + worker test#988
guybedford wants to merge 1 commit intomainfrom
feat/email-typed-array-attachment-builder

Conversation

@guybedford
Copy link
Copy Markdown
Collaborator

This adopts the ts-gen typed-array builder cleanups in the regenerated worker/src/email.rs. The dictionary helpers for EmailAttachment.content now expose a generic *_with_typed_array<T: ::js_sys::TypedArray> shape, plus the keyword-safe type_ getter, the deduped set_disposition, and trimmed JSDoc output.

// before
EmailAttachment::new_attachment_with_js_value(content: &Object, filename: &str, r#type: &str)
// after
EmailAttachment::new_attachment_with_typed_array<T: ::js_sys::TypedArray>(
    content: &T,
    filename: &str,
    r#type: &str,
)

The submodule bump pulls in the ts-gen changes from wasm-bindgen/ts-gen#15.

A new end-to-end worker test exercises the regenerated builder against the live email binding:

  • test/src/send_email.rs adds a structured-with-attachment scenario that builds a Uint8Array, constructs the attachment via EmailAttachment::new_attachment_with_typed_array, and attaches it to the structured SendEmailBuilder.
  • test/tests/send_email.spec.ts adds a matching vitest case.

Tests

  • cargo +stable check -p worker-sandbox --target wasm32-unknown-unknown
  • Existing send_email vitest cases still pass; new typed-array scenario added.

Remaining follow-ups

These belong upstream in ts-gen, but are worth listing here so the workers-rs side is regenerated when they land:

  • Strip undefined/void arms in the union LUB so contentId?: string | undefined becomes Option<String> and the dead set_content_id_with_undefined setter overload disappears.
  • Make the Returns: JSDoc rendering JSDoc-aware (backtick the braced {T}, leave prose untouched).

Adopts the ts-gen typed-array builder cleanups in the regenerated\n`worker/src/email.rs`. The dictionary helpers for `EmailAttachment.content`\nnow expose a generic `*_with_typed_array<T: ::js_sys::TypedArray>` shape so\ncallers can pass any `Uint8Array`/`Int32Array`/etc. directly, plus the\nkeyword-safe `type_` getter, the deduped `set_disposition`, and trimmed JSDoc\noutput.

Adds an end-to-end worker test that exercises the new builder via the email\nbinding:

- `test/src/send_email.rs` registers a `structured-with-attachment`\n  scenario that builds a `Uint8Array`, calls\n  `EmailAttachment::new_attachment_with_typed_array`, and attaches it to\n  the structured `SendEmailBuilder`.\n- `test/tests/send_email.spec.ts` adds a matching vitest case.

Refs wasm-bindgen/ts-gen#15.

Verified with `cargo +stable check -p worker-sandbox --target wasm32-unknown-unknown`.
@guybedford guybedford mentioned this pull request Apr 30, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 30, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing feat/email-typed-array-attachment-builder (f83f5e8) with main (7ad7139)

Open in CodSpeed

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.

1 participant