Skip to content

Add TypeScript submodule support for SpacetimeDB modules#5486

Open
aasoni wants to merge 1 commit into
masterfrom
alessandro/ts-submodules
Open

Add TypeScript submodule support for SpacetimeDB modules#5486
aasoni wants to merge 1 commit into
masterfrom
alessandro/ts-submodules

Conversation

@aasoni

@aasoni aasoni commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Add TypeScript submodule support for SpacetimeDB modules

Description of Changes

  • TypeScript server SDK: runtime API for module mounting (submodules), including namespaced dispatch, ctx.as helpers for cross-namespace calls, and HTTP handler delegation
  • TypeScript client codegen: namespace-aware table/reducer/procedure exports and query builder for submodule tables and views
  • Migrations: auto-migrate support for submodule tables, views, and indexes; AddConstraint step added alongside NamespacedIdentifier-based migration steps
  • CLI: namespace support for spacetime call and spacetime sql
  • C++/C# bindings: autogenerated RawSubmoduleV10 types
  • module-test-ts: submodule integration test (lib_submodule)

API and ABI breaking changes

Adds a submodule field to ModuleDef. Older modules will be publishable to new servers, but new modules that have submodules will not be publishable to old servers.

Expected complexity level and risk

5

Testing

Beyond the rust tests defined in this PR, the following tests were done on the full PR sequence once the entire namespace feature was implemented for typescript:
Feature Test Checklist

Module:

  • root module can import another module and mount it with a namespace under its schema
  • root module and submodule can have the same function and table names without conflicting
  • ctx.db.lib.lib_table is readable/writable inside root module reducer
  • ctx.db.lib.lib_table is readable/writable inside root module procedure withTx block
  • library_reducer(ctx.as.lib) is callable inside root module reducer

Client

  • Client can subscribe to lib.library_table
  • Client can subscribe to lib.library_view
  • Client can call lib/library_reducer
  • Client can call lib/library_procedure
  • Client can subscribe to lib.sublib.sublib_table
  • Client can subscribe to lib.sublib.sublib_view
  • Client can call lib/sublib/sublib_reducer
  • Client can call lib/sublib/sublib_procedure

CLI

  • CLI can subscribe to lib.library_table
  • CLI can subscribe to lib.library_view
  • CLI can call lib/library_reducer
  • CLI can call lib/library_procedure
  • CLI can subscribe to lib.sublib.sublib_table
  • CLI can subscribe to lib.sublib.sublib_view
  • CLI can call lib/sublib/sublib_reducer
  • CLI can call lib/sublib/sublib_procedure

Migration

  • Module migrates without issue from having a submodule to not having a submodule
  • Module migrates without issue from not having a submodule to having a submodule
  • Module migrates without issue when having a submodule and root module change occurs (change reducer signature, add table, add column with default, change reducer function body, change index)
  • Module migrates without issue when having a submodule and a submodule change occurs (change reducer signature, add table, add column with default, change reducer function body, change index)

Commit Log

  • Module loads fine from commit log
  • Module snapshot is created without issue
  • Module loads fine from snapshot

@aasoni aasoni force-pushed the alessandro/ts-submodules branch 2 times, most recently from b40398d to f8668e8 Compare July 6, 2026 12:47
- TypeScript server SDK: runtime API for module mounting (submodules),
  including namespaced dispatch, ctx.as helpers for cross-namespace calls,
  and HTTP handler delegation
- TypeScript client codegen: namespace-aware table/reducer/procedure
  exports and query builder for submodule tables and views
- Migrations: auto-migrate support for submodule tables, views, and
  indexes; AddConstraint step added alongside NamespacedIdentifier-based
  migration steps
- CLI: namespace support for `spacetime call` and `spacetime sql`
- C++/C# bindings: autogenerated RawSubmoduleV10 types
- module-test-ts: submodule integration test (lib_submodule)
@aasoni aasoni force-pushed the alessandro/ts-submodules branch from d58d474 to 690b424 Compare July 8, 2026 13:06
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