Commit 8790769
Add TypeScript submodule support for SpacetimeDB modules (#5486)
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:
- [x] root module can import another module and mount it with a
namespace under its schema
- [x] root module and submodule can have the same function and table
names without conflicting
- [x] ctx.db.lib.lib_table is readable/writable inside root module
reducer
- [x] ctx.db.lib.lib_table is readable/writable inside root module
procedure withTx block
- [x] library_reducer(ctx.as.lib) is callable inside root module reducer
Client
- [x] Client can subscribe to lib.library_table
- [x] Client can subscribe to lib.library_view
- [x] Client can call lib/library_reducer
- [x] Client can call lib/library_procedure
- [x] Client can subscribe to lib.sublib.sublib_table
- [x] Client can subscribe to lib.sublib.sublib_view
- [x] Client can call lib/sublib/sublib_reducer
- [x] Client can call lib/sublib/sublib_procedure
CLI
- [x] CLI can subscribe to lib.library_table
- [x] CLI can subscribe to lib.library_view
- [x] CLI can call lib/library_reducer
- [x] CLI can call lib/library_procedure
- [x] CLI can subscribe to lib.sublib.sublib_table
- [x] CLI can subscribe to lib.sublib.sublib_view
- [x] CLI can call lib/sublib/sublib_reducer
- [x] CLI can call lib/sublib/sublib_procedure
Migration
- [x] Module migrates without issue from having a submodule to not
having a submodule
- [x] Module migrates without issue from not having a submodule to
having a submodule
- [x] 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)
- [x] 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
- [x] Module loads fine from commit log
- [x] Module snapshot is created without issue
- [x] Module loads fine from snapshot
---------
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>1 parent 8e5510b commit 8790769
90 files changed
Lines changed: 6403 additions & 1312 deletions
File tree
- .github/workflows
- crates
- bench/src
- bindings-cpp/include/spacetimedb/internal/autogen
- bindings-csharp/Runtime/Internal/Autogen
- bindings-typescript
- src
- lib
- autogen
- sdk
- server
- tests
- cli/src
- subcommands
- codegen
- examples
- src
- tests
- core/src
- client
- host
- v8
- syscall
- wasm_common
- wasmtime
- subscription
- datastore/src
- locking_tx_datastore
- engine/src
- expr/src
- lib/src/db/raw_def
- sats/src
- schema
- src
- auto_migrate
- def
- validate
- snapshots
- tests
- sql-parser/src
- ast
- parser
- table/src
- testing
- src
- tests
- docs/docs/00200-core-concepts/00100-databases
- modules/module-test-ts/src
- tools/ci/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
531 | 538 | | |
532 | 539 | | |
533 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
Lines changed: 11 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 16 | | |
24 | 17 | | |
25 | | - | |
26 | | - | |
| 18 | + | |
27 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
28 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
226 | 247 | | |
227 | 248 | | |
228 | 249 | | |
| |||
335 | 356 | | |
336 | 357 | | |
337 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
338 | 395 | | |
339 | 396 | | |
340 | 397 | | |
| |||
879 | 936 | | |
880 | 937 | | |
881 | 938 | | |
882 | | - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
883 | 943 | | |
884 | 944 | | |
885 | 945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
101 | 107 | | |
102 | 108 | | |
103 | 109 | | |
| |||
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| 122 | + | |
116 | 123 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
| 207 | + | |
205 | 208 | | |
206 | 209 | | |
207 | 210 | | |
| |||
266 | 269 | | |
267 | 270 | | |
268 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
269 | 278 | | |
270 | 279 | | |
271 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
272 | 285 | | |
273 | 286 | | |
274 | 287 | | |
| |||
0 commit comments