Skip to content

feat: writable WASM sources (Phase C2) #216

Description

@adnaan

Context

This is the final item from the progressive complexity plan. WASM sources currently implement Source (read-only). Extending them to implement WritableSource would let users build fully custom CRUD backends in TinyGo.

Progressive complexity tiers:

Task Description

Extend internal/wasm/source.go (WasmSource) to implement the WritableSource interface:

type WritableSource interface {
    Source
    WriteItem(ctx context.Context, action string, data map[string]interface{}) error
    IsReadonly() bool
}

The WASM module would need to export a WriteItem(action, data) function (or similar) that tinkerdown calls for Add/Update/Delete operations. The TinyGo WASM SDK would need a corresponding update.

Implementation notes

  • WasmSource already has IsReadonly() (returns true) — change to check if the module exports a write function
  • Add WriteItem that calls the WASM module's exported write function
  • Update the wasm-source template (cmd/tinkerdown/commands/templates/wasm-source/) to show a writable example
  • Update docs/sources/wasm.md

Files to modify

  • internal/wasm/source.go — implement WritableSource
  • cmd/tinkerdown/commands/templates/wasm-source/ — update template
  • docs/sources/wasm.md — document writable WASM

From the progressive complexity plan (Phase C2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3-lowLow: extended features, operational docsfollow-upFollow-up task from PR review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions