Files
madbase/.trae/documents/plan_20260312_055221.md

1.6 KiB

I will implement the Deno runtime compatibility plan as described in WASI_DENO.md.

Plan:

  1. Database Migration:

    • Create a new migration 20260312000003_add_function_runtime.sql.

    • Add runtime column to functions.functions table (TEXT, DEFAULT 'wasm').

    • Update existing functions to have runtime = 'wasm'.

  2. Update Dependencies:

    • Add deno_core to functions/Cargo.toml.

    • Note: I will start with deno_core to avoid potential build OOM issues with the full deno_runtime. I will implement a minimal JS runtime capable of executing scripts and returning results.

  3. Update Data Models:

    • Modify Function struct in functions/src/models.rs to include the runtime field.

    • Update DeployRequest struct in functions/src/models.rs to accept an optional runtime field.

  4. Implement Deno Runtime:

    • Create functions/src/deno_runtime.rs.

    • Implement DenoRuntime struct using deno_core::JsRuntime.

    • Implement execute method that initializes the runtime, executes the provided code, and captures output.

  5. Update Handlers:

    • Modify deploy_function in functions/src/handlers.rs to handle the runtime field.

    • Modify invoke_function in functions/src/handlers.rs to switch between WasmRuntime and DenoRuntime based on the function's runtime column.

  6. Integration Testing:

    • Update tests/integration/functions.test.ts to include a test case for deploying and invoking a JavaScript/TypeScript function.
  7. Verification:

    • Run cargo build to ensure dependencies compile.

    • Run npm test functions.test.ts to verify functionality.