π It's happening! π
We've got a big one for you today! We've been burning the midnight oil to bring you the cream of the SpacetimeDB crop. We are updating and improving our APIs and interfaces across the board in an effort to stabilize and polish them up for a final release!
SpacetimeDB is getting closer and closer to a final 1.0 release and this is a huge milestone on that journey. These new APIs will allow us to implement some amazing new features and vastly improve the user experience of using SpacetimeDB across multiple languages and clients.
Module API
The module API has had it's most major overhaul since the announcement of SpacetimeDB. We're reducing the amount of globals and enforcing accessing the database via a ReducerContext.
Rust
#[reducer]
pub fn add(ctx: &ReducerContext, name: String) {
println!("Inserting {}", name);
ctx.db.person().insert(Person { name });
} Note
CHECK IT OUT! The
#[spacetimedb(reducer)]macro has been simplified to just#[reducer]!
C#
[SpacetimeDB.Reducer]
public static void Add(ReducerContext ctx, string name)
{
Log.Info($"Inserting {name}");
ctx.Db.Person.Insert(new Person { Name = name });
} SDK API
The SDKs now share almost exactly the same API as you use to access your data inside your module.
let ctx = DbConnection.builder()
.with_url("https://testnet.spacetimedb.com")
.with_module_name("bitcraft")
.build();
...
for person in ctx.db.person().iter() {
println!("Hey, {}", person.name);
} C#
var conn = DbConnection.Builder()
.WithUri("https://testnet.spacetimedb.com")
.WithModuleName("bitcraft")
.Build();
...
foreach (var person in ctx.Db.Person.Iter())
{
Log.Info($"Hello, {person.Name}!");
} Now you can write your client code with the same patterns as your server code!
Migration Guide
Check out our full migration guide to update your code for v0.12 available in the docs section of our website.
CLI updates ποΈ
We've updated a lot of the args to the CLI to be more clear and consistent. If something gives you an errors, check --help to see if it's changed.
Some of the important changes:
spacetime local clear(to delete all local server data) is now calledspacetime server clearspacetime build --skip_clippy/-Sis now more explicitly--skip-println-checksspacetime logs database 10is nowspacetime logs database -n 10spacetime publishandspacetime generatenow accept a--build-optionsparam, e.g.spacetime publish --build-options="--debug --skip-println-checks"
Small clarity changes:
- All
--anon-identityparameters have been renamed to--anonymous spacetime energy statusis nowspacetime energy balancefor clarityspacetime publish --clear-databasehas been renamed tospacetime publish --delete-datafor clarityspacetime subscribe -nnow has a longform option--num-updatesspacetime publish|generate --wasm-file->spacetime publish|generate --bin-path
What's Changed (It's... uhh a lot)
- Fix flaky subscription smoketests by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1536
- core: Start system table ids at 1 by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1544
- Remove support for the
updatereducer by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1557 - Get rid of python SDK by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1561
- client-api: Remove publisher address by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1564
- Minor NFC improvements to C# Roslyn codegen by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1562
- SATS: Flatten
AlgebraicType, getting rid ofBuiltinTypeby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1559 - Updating the change date in anticipation of the anniversary by @cloutiertyler in https://github.com/clockworklabs/SpacetimeDB/pull/1574
- Update README.md by @cloutiertyler in https://github.com/clockworklabs/SpacetimeDB/pull/1575
- Make
schemacrate publishable by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1569 Typespace::is_nominal_normal_formby @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1549- Add lib::db::{column_ordering, raw_def::v9} by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1542
- Change ResolveRefs to return a Result rather than an Option by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1565
- Add support for
I256andU256by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1477 - core: Use
Programinstead of(Hash, Box<[u8]>)by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1558 - Bump version to 0.12.0 by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1578
- Fix iu BSATN implementations in C# by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1582
- C#: disable verbose test output in console by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1570
- Add helpers and change
CollectAllErrorsto be more composable by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1586 - Preliminary Identifier validation by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1584
- Allow empty
ColListby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1588 - [CI] Do not use branch names when publishing container images by @kurtismullins in https://github.com/clockworklabs/SpacetimeDB/pull/1583
- Verify Unity compatibility in the shared C# codegen by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1576
- Fix builds for MacOS amd64 platform by @kurtismullins in https://github.com/clockworklabs/SpacetimeDB/pull/1598
- [WASM ABI 1.0] Change
ColIdfromu32tou16by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1597 - [WASM ABI 1.0]
__call_reducer__receives Identity & Address by value by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1607 - [WASM ABI 1.0] impl
__call_reducer__usingbytes_source_readby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1609 - Placate some clippy errors in
snapshotby @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1611 - fix: Always remember to release a read only tx by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1613
- NFC: enforce style for C# locally and on CI by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1567
- Make
ScheduleAtspecial +Typespace::is_valid_for_client_code_generationby @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1590 - Dedup schedueler queue by @Shubham8287 in https://github.com/clockworklabs/SpacetimeDB/pull/1587
- Updated docker internal port to 3000 by @jdetter in https://github.com/clockworklabs/SpacetimeDB/pull/1626
- Add volatile_nonatomic_schedule_immediate by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1612
- NFC: use record for BigInt equality and hash by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1633
- smoketests: Test unauthorized publish without -c by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1632
- [WASM ABI 1.0] impl
__call_reducer__&__describe_module__usingbytes_sink_writeby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1615 - ABI v9 validation code by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1572
- Fix ptr mutability of some new C# FFIs by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1645
- WASM ABI: implement
row_iter_bsatn_advance&row_iter_bsatn_closeby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1622 - WASM ABI:
get_table_id->table_id_from_nameby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1634 - WASM ABI: add
datastore_table_row_countby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1636 - [WASM ABI 1.0] Fix
bytes_source_readby @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1646 - Add backwards-compatible validation for RawModuleDefV8. by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1606
- Allow converting new ModuleDef to old TableSchema by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1630
- Fix flaky smoketest due to race condition in subscribe by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1656
- Update SQL AST in accordance with the SQL spec by @mamcx in https://github.com/clockworklabs/SpacetimeDB/pull/1623
- WASM ABI:
iter_start->datastore_table_scan_bsatnby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1637 - WASM ABI:
delete_by_rel->datastore_delete_all_by_eq_bsatnby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1638 - Add edition to .rustfmt.toml by @gefjon in https://github.com/clockworklabs/SpacetimeDB/pull/1663
- bindings-csharp: pass
address_1by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1621 - C#: split table codegen logic from type codegen logic by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1573
- WASM ABI:
insert->datastore_insert_bsatn& impl new semantics by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1639 - WASM ABI: implement console ABIs by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1664
- C# module benchmarks by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1679
- Auto-generate C# ModuleDef bindings from Rust by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1680
- Impl macro rework by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1314
- commitlog: Make commit module public, and allow access to header fields by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1685
- C#: hide ReadGenFields from the public API by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1690
- Fix table codegen wrt table names by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1689
- Switched table names to singular by @cloutiertyler in https://github.com/clockworklabs/SpacetimeDB/pull/1684
- Add spacetimedb_primitives::col_list::ColSet by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1691
- Add schema::type_for_generate, update validation to use it by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1661
- Automatic migration planning by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1658
- Bump bytemuck by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1686
- WASM ABI: add
datastore_btree_scan_bsatn&index_id_from_nameby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1699 - Fix heisenbug by using petgraph by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1712
- NFC: enforce more C# code style + enable it in Visual Studio by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1687
- snapshot: pub access to snapshot file + object repo by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1709
- CI - Discord PR merge notification includes status of
Internal testscheck by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1713 - feat: sql type checking and logical plan by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1708
- Switch Rust codegen to use new ModuleDef by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1675
- Stopwatch and reducer rng by @SteveBoytsun in https://github.com/clockworklabs/SpacetimeDB/pull/1681
- WASM ABI: add
datastore_delete_by_btree_scan_bsatnby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1704 - Fixes showing server errors on
cli sqlcalls by @mamcx in https://github.com/clockworklabs/SpacetimeDB/pull/1720 - CI - Discord post will ping a particular role if CI check was not successful by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1715
- CLI - Remove admin
energysubcommands by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1695 - CLI - Print out config path when saving by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1673
- CLI - Fix helptext for
spacetime sqlby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1667 - Remove reserved identifiers by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1724
- cli: Remove dbg! by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1722
- CLI - Remove unused
tracelog.rsby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1693 - [C#] [NFC] Reuse attribute classes from runtime by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1718
- Logging API by @SteveBoytsun in https://github.com/clockworklabs/SpacetimeDB/pull/1714
- Fix C# CI by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1734
- perf: Use type ids for type checking by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1725
- Commitlog offset index by @Shubham8287 in https://github.com/clockworklabs/SpacetimeDB/pull/1671
- CLI - Remove project-specific config files by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1665
- smoketests: Allow to skip tests requiring dotnet by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1726
- CLI - Exit when config is malformed by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1669
- CLI - Unify copies of the confirmation/
--forcelogic by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1740 - feat: Type check DML by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1727
- snapshot: More
Snapshotaccessors by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1721 - Downlevel some info messages by @Shubham8287 in https://github.com/clockworklabs/SpacetimeDB/pull/1739
- Update TableSchema & system tables to resemble ABI V9 by @kazimuth in https://github.com/clockworklabs/SpacetimeDB/pull/1697
- Fix btree_scan by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1748
- Name the iterator type returned from btree_scan by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1749
- Jeremie/cs module by @lcodes in https://github.com/clockworklabs/SpacetimeDB/pull/1719
- WASM ABI: Strip leading underscore from syscall names by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1705
- Minor attribute cleanups for C# module by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1753
- Add C# diagnostics support by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1688
- Make our sats<->serde translation compatible with RON by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1738
- client-api: Fix publish error reporting by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1750
- Rust module API rework by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1660
- Tighten package sources in C# smoketests by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1735
- CLI - Change default server back to
localby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1745 - CLI -
publishandgeneratetake a--build-optionsparam by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1742 - CLI -
local clear->server clearby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1759 - CLI -
--anon-identity->--anonymousby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1751 - Fix C# visibility check by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1765
- Rework Rust SDK for new API by @gefjon in https://github.com/clockworklabs/SpacetimeDB/pull/1692
- [C#] Fix table view names and duplicate table registration by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1757
- CLI -
--force->--yes/-yby @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1752 - Remove the
expandoption on thedescriberoute by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1755 - Rename unstable_abi to unstable by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1767
- refactor: Intern names in relation expressions by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1754
- CLI stabilization by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1741
- [C#] Remove .Query support by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1772
- feat: Integrate type checking into current query code by @joshua-spacetime in https://github.com/clockworklabs/SpacetimeDB/pull/1756
client-api: make someBAD_REQUESTintoNOT_FOUNDby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1768- [C#] Mark experimental API by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1769
- Generic and optimized WebSocket API by @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1761
- Replace iter_by_col_eq in UniqueColumn impl by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1771
- CLI -
spacetime generatealways deletes stale files by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1774 - [C#] Migrate bench-cs to the new API by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1758
- Filter out deps that only is added to keccack on arm that broke local testing by @mamcx in https://github.com/clockworklabs/SpacetimeDB/pull/1711
- Ensure C# autogen bindings are up-to-date by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1780
- [C#] [Reducers] Implement new context fields, enum-based kinds, validation by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1729
- Remove abi functions that are no longer needed by @coolreader18 in https://github.com/clockworklabs/SpacetimeDB/pull/1777
- [bindings-csharp] Upgrade WASI SDK & enable for ARM64 by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1775
- commitlog: Return commit info by @kim in https://github.com/clockworklabs/SpacetimeDB/pull/1778
- More obsolete cleanup by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1782
- Fix
RowSizeHint::index_to_rangeby @Centril in https://github.com/clockworklabs/SpacetimeDB/pull/1785 - CLI - Fix identity removal helptext by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1784
- Implemented TypeScript SDK proposal codegen by @cloutiertyler in https://github.com/clockworklabs/SpacetimeDB/pull/1776
- Fix a rustfmt issue that occurs during rust client code generation by @jdetter in https://github.com/clockworklabs/SpacetimeDB/pull/1793
- [C#] [NFC] Some tweaks to the diagnostic tests by @RReverser in https://github.com/clockworklabs/SpacetimeDB/pull/1792
- CLI - Remove the always-save-config behavior by @bfops in https://github.com/clockworklabs/SpacetimeDB/pull/1799
- Small fixes to TypeScript codegen by @cloutiertyler in https://github.com/clockworklabs/SpacetimeDB/pull/1800
- c# client generate by @lcodes in https://github.com/clockworklabs/SpacetimeDB/pull/1707
Full Changelog: https://github.com/clockworklabs/SpacetimeDB/compare/v0.11.1-beta...v0.12.0-beta
