From 8d065aee9fb6cdee67fc94743043c17d2688a80e Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Tue, 25 Nov 2025 22:39:13 -0600 Subject: [PATCH 1/4] Upgrade to version 1.10.0 --- Cargo.lock | 240 +++++++++--------- Cargo.toml | 66 ++--- LICENSE.txt | 4 +- .../BSATN.Codegen/BSATN.Codegen.csproj | 2 +- .../BSATN.Runtime/BSATN.Runtime.csproj | 2 +- crates/bindings-csharp/Codegen/Codegen.csproj | 2 +- crates/bindings-csharp/Runtime/Runtime.csproj | 2 +- crates/bindings-typescript/package.json | 2 +- .../project/typescript/package._json | 2 +- .../basic-c-sharp/server/StdbModule.csproj | 2 +- .../templates/basic-rust/client/Cargo.toml | 2 +- .../templates/basic-rust/server/Cargo.toml | 2 +- .../server-csharp/StdbModule.csproj | 2 +- licenses/BSL.txt | 4 +- sdks/csharp/SpacetimeDB.ClientSDK.csproj | 6 +- .../quickstart-chat/server/StdbModule.csproj | 2 +- .../regression-tests/server/StdbModule.csproj | 2 +- sdks/csharp/package.json | 2 +- 18 files changed, 173 insertions(+), 173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f8cdfe56eb..41fe10311bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -443,7 +443,7 @@ name = "benchmarks-module" version = "0.1.0" dependencies = [ "anyhow", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -1082,7 +1082,7 @@ dependencies = [ [[package]] name = "connect_disconnect_client" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "spacetimedb-sdk", @@ -3496,7 +3496,7 @@ name = "keynote-benchmarks" version = "0.1.0" dependencies = [ "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -3876,7 +3876,7 @@ version = "0.0.0" dependencies = [ "anyhow", "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -4969,7 +4969,7 @@ name = "perf-test-module" version = "0.1.0" dependencies = [ "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -5338,12 +5338,12 @@ dependencies = [ [[package]] name = "procedure-client" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "env_logger 0.10.2", "serde_json", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-sdk", "test-counter", ] @@ -5533,7 +5533,7 @@ name = "quickstart-chat-module" version = "0.1.0" dependencies = [ "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -6633,7 +6633,7 @@ dependencies = [ "anyhow", "log", "paste", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -6643,7 +6643,7 @@ dependencies = [ "anyhow", "log", "paste", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -6653,12 +6653,12 @@ dependencies = [ "anyhow", "log", "paste", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] name = "sdk-unreal-test-harness" -version = "1.9.0" +version = "1.10.0" dependencies = [ "serial_test", "spacetimedb-testing", @@ -7092,7 +7092,7 @@ name = "spacetime-module" version = "0.1.0" dependencies = [ "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -7115,7 +7115,7 @@ dependencies = [ [[package]] name = "spacetimedb" -version = "1.9.0" +version = "1.10.0" dependencies = [ "bytemuck", "bytes", @@ -7127,28 +7127,28 @@ dependencies = [ "rand 0.8.5", "scoped-tls", "serde_json", - "spacetimedb-bindings-macro 1.9.0", - "spacetimedb-bindings-sys 1.9.0", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", + "spacetimedb-bindings-macro 1.10.0", + "spacetimedb-bindings-sys 1.10.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", "trybuild", ] [[package]] name = "spacetimedb-auth" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "serde", "serde_json", "serde_with", "spacetimedb-jsonwebtoken", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", ] [[package]] name = "spacetimedb-bench" -version = "1.9.0" +version = "1.10.0" dependencies = [ "ahash 0.8.12", "anyhow", @@ -7178,11 +7178,11 @@ dependencies = [ "spacetimedb-data-structures", "spacetimedb-datastore", "spacetimedb-execution", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-query", - "spacetimedb-sats 1.9.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-standalone", "spacetimedb-table", @@ -7211,13 +7211,13 @@ dependencies = [ [[package]] name = "spacetimedb-bindings-macro" -version = "1.9.0" +version = "1.10.0" dependencies = [ "heck 0.4.1", "humantime", "proc-macro2", "quote", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "syn 2.0.107", ] @@ -7232,14 +7232,14 @@ dependencies = [ [[package]] name = "spacetimedb-bindings-sys" -version = "1.9.0" +version = "1.10.0" dependencies = [ - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", ] [[package]] name = "spacetimedb-cli" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "base64 0.21.7", @@ -7283,9 +7283,9 @@ dependencies = [ "spacetimedb-data-structures", "spacetimedb-fs-utils", "spacetimedb-jsonwebtoken", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-schema", "syntect", "tabled", @@ -7310,7 +7310,7 @@ dependencies = [ [[package]] name = "spacetimedb-client-api" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "async-stream", @@ -7347,7 +7347,7 @@ dependencies = [ "spacetimedb-data-structures", "spacetimedb-datastore", "spacetimedb-jsonwebtoken", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", "spacetimedb-schema", "tempfile", @@ -7365,7 +7365,7 @@ dependencies = [ [[package]] name = "spacetimedb-client-api-messages" -version = "1.9.0" +version = "1.10.0" dependencies = [ "bytes", "bytestring", @@ -7379,16 +7379,16 @@ dependencies = [ "serde_json", "serde_with", "smallvec", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "strum", "thiserror 1.0.69", ] [[package]] name = "spacetimedb-codegen" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "convert_case 0.6.0", @@ -7397,15 +7397,15 @@ dependencies = [ "itertools 0.12.1", "regex", "spacetimedb-data-structures", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-schema", "spacetimedb-testing", ] [[package]] name = "spacetimedb-commitlog" -version = "1.9.0" +version = "1.10.0" dependencies = [ "async-stream", "bitflags 2.10.0", @@ -7426,8 +7426,8 @@ dependencies = [ "spacetimedb-commitlog", "spacetimedb-fs-utils", "spacetimedb-paths", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "tempfile", "thiserror 1.0.69", "tokio", @@ -7438,7 +7438,7 @@ dependencies = [ [[package]] name = "spacetimedb-core" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "arrayvec", @@ -7520,14 +7520,14 @@ dependencies = [ "spacetimedb-fs-utils", "spacetimedb-jsonwebtoken", "spacetimedb-jwks", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-memory-usage", "spacetimedb-metrics", "spacetimedb-paths", "spacetimedb-physical-plan", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-query", - "spacetimedb-sats 1.9.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-snapshot", "spacetimedb-subscription", @@ -7562,7 +7562,7 @@ dependencies = [ [[package]] name = "spacetimedb-data-structures" -version = "1.9.0" +version = "1.10.0" dependencies = [ "ahash 0.8.12", "crossbeam-queue", @@ -7576,7 +7576,7 @@ dependencies = [ [[package]] name = "spacetimedb-datastore" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "bytes", @@ -7596,11 +7596,11 @@ dependencies = [ "spacetimedb-data-structures", "spacetimedb-durability", "spacetimedb-execution", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-metrics", "spacetimedb-paths", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-snapshot", "spacetimedb-table", @@ -7611,7 +7611,7 @@ dependencies = [ [[package]] name = "spacetimedb-durability" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "itertools 0.12.1", @@ -7619,7 +7619,7 @@ dependencies = [ "scopeguard", "spacetimedb-commitlog", "spacetimedb-paths", - "spacetimedb-sats 1.9.0", + "spacetimedb-sats 1.10.0", "tempfile", "thiserror 1.0.69", "tokio", @@ -7628,22 +7628,22 @@ dependencies = [ [[package]] name = "spacetimedb-execution" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "itertools 0.12.1", "spacetimedb-expr", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-physical-plan", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-sql-parser", "spacetimedb-table", ] [[package]] name = "spacetimedb-expr" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "bigdecimal", @@ -7651,10 +7651,10 @@ dependencies = [ "derive_more 0.99.20", "ethnum", "pretty_assertions", - "spacetimedb 1.9.0", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb 1.10.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-sql-parser", "thiserror 1.0.69", @@ -7662,7 +7662,7 @@ dependencies = [ [[package]] name = "spacetimedb-fs-utils" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "hex", @@ -7724,7 +7724,7 @@ dependencies = [ [[package]] name = "spacetimedb-lib" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "bitflags 2.10.0", @@ -7743,17 +7743,17 @@ dependencies = [ "ron", "serde", "serde_json", - "spacetimedb-bindings-macro 1.9.0", + "spacetimedb-bindings-macro 1.10.0", "spacetimedb-memory-usage", "spacetimedb-metrics", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "thiserror 1.0.69", ] [[package]] name = "spacetimedb-memory-usage" -version = "1.9.0" +version = "1.10.0" dependencies = [ "decorum", "ethnum", @@ -7763,7 +7763,7 @@ dependencies = [ [[package]] name = "spacetimedb-metrics" -version = "1.9.0" +version = "1.10.0" dependencies = [ "arrayvec", "itertools 0.12.1", @@ -7773,7 +7773,7 @@ dependencies = [ [[package]] name = "spacetimedb-paths" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "chrono", @@ -7789,7 +7789,7 @@ dependencies = [ [[package]] name = "spacetimedb-pg" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "async-trait", @@ -7800,22 +7800,22 @@ dependencies = [ "pgwire", "spacetimedb-client-api", "spacetimedb-client-api-messages", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "thiserror 1.0.69", "tokio", ] [[package]] name = "spacetimedb-physical-plan" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "derive_more 0.99.20", "either", "pretty_assertions", "spacetimedb-expr", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-schema", "spacetimedb-sql-parser", "spacetimedb-table", @@ -7835,7 +7835,7 @@ dependencies = [ [[package]] name = "spacetimedb-primitives" -version = "1.9.0" +version = "1.10.0" dependencies = [ "bitflags 2.10.0", "either", @@ -7848,7 +7848,7 @@ dependencies = [ [[package]] name = "spacetimedb-query" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "itertools 0.12.1", @@ -7856,9 +7856,9 @@ dependencies = [ "spacetimedb-client-api-messages", "spacetimedb-execution", "spacetimedb-expr", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-physical-plan", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-sql-parser", "spacetimedb-table", ] @@ -7891,7 +7891,7 @@ dependencies = [ [[package]] name = "spacetimedb-sats" -version = "1.9.0" +version = "1.10.0" dependencies = [ "ahash 0.8.12", "anyhow", @@ -7916,16 +7916,16 @@ dependencies = [ "serde_json", "sha3", "smallvec", - "spacetimedb-bindings-macro 1.9.0", + "spacetimedb-bindings-macro 1.10.0", "spacetimedb-memory-usage", "spacetimedb-metrics", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "thiserror 1.0.69", ] [[package]] name = "spacetimedb-schema" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "derive_more 0.99.20", @@ -7941,9 +7941,9 @@ dependencies = [ "serial_test", "smallvec", "spacetimedb-data-structures", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-sql-parser", "spacetimedb-testing", "termcolor", @@ -7954,7 +7954,7 @@ dependencies = [ [[package]] name = "spacetimedb-sdk" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anymap", "base64 0.21.7", @@ -7973,9 +7973,9 @@ dependencies = [ "rand 0.9.2", "spacetimedb-client-api-messages", "spacetimedb-data-structures", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-metrics", - "spacetimedb-sats 1.9.0", + "spacetimedb-sats 1.10.0", "spacetimedb-testing", "thiserror 1.0.69", "tokio", @@ -7984,7 +7984,7 @@ dependencies = [ [[package]] name = "spacetimedb-snapshot" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "blake3", @@ -8001,10 +8001,10 @@ dependencies = [ "spacetimedb-datastore", "spacetimedb-durability", "spacetimedb-fs-utils", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-table", "tempfile", @@ -8017,17 +8017,17 @@ dependencies = [ [[package]] name = "spacetimedb-sql-parser" -version = "1.9.0" +version = "1.10.0" dependencies = [ "derive_more 0.99.20", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "sqlparser", "thiserror 1.0.69", ] [[package]] name = "spacetimedb-standalone" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "async-trait", @@ -8051,7 +8051,7 @@ dependencies = [ "spacetimedb-client-api-messages", "spacetimedb-core", "spacetimedb-datastore", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", "spacetimedb-pg", "spacetimedb-schema", @@ -8068,20 +8068,20 @@ dependencies = [ [[package]] name = "spacetimedb-subscription" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "spacetimedb-execution", "spacetimedb-expr", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-physical-plan", - "spacetimedb-primitives 1.9.0", + "spacetimedb-primitives 1.10.0", "spacetimedb-query", ] [[package]] name = "spacetimedb-table" -version = "1.9.0" +version = "1.10.0" dependencies = [ "ahash 0.8.12", "blake3", @@ -8097,17 +8097,17 @@ dependencies = [ "rand 0.9.2", "smallvec", "spacetimedb-data-structures", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-memory-usage", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "thiserror 1.0.69", ] [[package]] name = "spacetimedb-testing" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "bytes", @@ -8124,7 +8124,7 @@ dependencies = [ "spacetimedb-client-api", "spacetimedb-core", "spacetimedb-data-structures", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-paths", "spacetimedb-schema", "spacetimedb-standalone", @@ -8135,7 +8135,7 @@ dependencies = [ [[package]] name = "spacetimedb-update" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "bytes", @@ -8160,7 +8160,7 @@ dependencies = [ [[package]] name = "spacetimedb-vm" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "arrayvec", @@ -8170,9 +8170,9 @@ dependencies = [ "smallvec", "spacetimedb-data-structures", "spacetimedb-execution", - "spacetimedb-lib 1.9.0", - "spacetimedb-primitives 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-primitives 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-schema", "spacetimedb-table", "tempfile", @@ -8254,7 +8254,7 @@ dependencies = [ [[package]] name = "sqltest" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "async-trait", @@ -8273,8 +8273,8 @@ dependencies = [ "rust_decimal", "spacetimedb-core", "spacetimedb-datastore", - "spacetimedb-lib 1.9.0", - "spacetimedb-sats 1.9.0", + "spacetimedb-lib 1.10.0", + "spacetimedb-sats 1.10.0", "spacetimedb-vm", "sqllogictest", "sqllogictest-engines", @@ -8654,7 +8654,7 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "test-client" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "env_logger 0.10.2", @@ -8666,7 +8666,7 @@ dependencies = [ [[package]] name = "test-counter" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "spacetimedb-data-structures", @@ -9394,7 +9394,7 @@ version = "0.1.0" dependencies = [ "anyhow", "log", - "spacetimedb 1.9.0", + "spacetimedb 1.10.0", ] [[package]] @@ -9605,11 +9605,11 @@ dependencies = [ [[package]] name = "view-client" -version = "1.9.0" +version = "1.10.0" dependencies = [ "anyhow", "env_logger 0.10.2", - "spacetimedb-lib 1.9.0", + "spacetimedb-lib 1.10.0", "spacetimedb-sdk", "test-counter", ] diff --git a/Cargo.toml b/Cargo.toml index 5e3a3eb63c6..af0a9917c1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,44 +96,44 @@ inherits = "release" debug = true [workspace.package] -version = "1.9.0" +version = "1.10.0" edition = "2021" # update rust-toolchain.toml too! rust-version = "1.90.0" [workspace.dependencies] -spacetimedb = { path = "crates/bindings", version = "=1.9.0" } -spacetimedb-auth = { path = "crates/auth", version = "=1.9.0" } -spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "=1.9.0" } -spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "=1.9.0" } -spacetimedb-cli = { path = "crates/cli", version = "=1.9.0" } -spacetimedb-client-api = { path = "crates/client-api", version = "=1.9.0" } -spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "=1.9.0" } -spacetimedb-codegen = { path = "crates/codegen", version = "=1.9.0" } -spacetimedb-commitlog = { path = "crates/commitlog", version = "=1.9.0" } -spacetimedb-core = { path = "crates/core", version = "=1.9.0" } -spacetimedb-data-structures = { path = "crates/data-structures", version = "=1.9.0" } -spacetimedb-datastore = { path = "crates/datastore", version = "=1.9.0" } -spacetimedb-durability = { path = "crates/durability", version = "=1.9.0" } -spacetimedb-execution = { path = "crates/execution", version = "=1.9.0" } -spacetimedb-expr = { path = "crates/expr", version = "=1.9.0" } -spacetimedb-lib = { path = "crates/lib", default-features = false, version = "=1.9.0" } -spacetimedb-memory-usage = { path = "crates/memory-usage", version = "=1.9.0", default-features = false } -spacetimedb-metrics = { path = "crates/metrics", version = "=1.9.0" } -spacetimedb-paths = { path = "crates/paths", version = "=1.9.0" } -spacetimedb-pg = { path = "crates/pg", version = "=1.9.0" } -spacetimedb-physical-plan = { path = "crates/physical-plan", version = "=1.9.0" } -spacetimedb-primitives = { path = "crates/primitives", version = "=1.9.0" } -spacetimedb-query = { path = "crates/query", version = "=1.9.0" } -spacetimedb-sats = { path = "crates/sats", version = "=1.9.0" } -spacetimedb-schema = { path = "crates/schema", version = "=1.9.0" } -spacetimedb-standalone = { path = "crates/standalone", version = "=1.9.0" } -spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=1.9.0" } -spacetimedb-table = { path = "crates/table", version = "=1.9.0" } -spacetimedb-vm = { path = "crates/vm", version = "=1.9.0" } -spacetimedb-fs-utils = { path = "crates/fs-utils", version = "=1.9.0" } -spacetimedb-snapshot = { path = "crates/snapshot", version = "=1.9.0" } -spacetimedb-subscription = { path = "crates/subscription", version = "=1.9.0" } +spacetimedb = { path = "crates/bindings", version = "=1.10.0" } +spacetimedb-auth = { path = "crates/auth", version = "=1.10.0" } +spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "=1.10.0" } +spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "=1.10.0" } +spacetimedb-cli = { path = "crates/cli", version = "=1.10.0" } +spacetimedb-client-api = { path = "crates/client-api", version = "=1.10.0" } +spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "=1.10.0" } +spacetimedb-codegen = { path = "crates/codegen", version = "=1.10.0" } +spacetimedb-commitlog = { path = "crates/commitlog", version = "=1.10.0" } +spacetimedb-core = { path = "crates/core", version = "=1.10.0" } +spacetimedb-data-structures = { path = "crates/data-structures", version = "=1.10.0" } +spacetimedb-datastore = { path = "crates/datastore", version = "=1.10.0" } +spacetimedb-durability = { path = "crates/durability", version = "=1.10.0" } +spacetimedb-execution = { path = "crates/execution", version = "=1.10.0" } +spacetimedb-expr = { path = "crates/expr", version = "=1.10.0" } +spacetimedb-lib = { path = "crates/lib", default-features = false, version = "=1.10.0" } +spacetimedb-memory-usage = { path = "crates/memory-usage", version = "=1.10.0", default-features = false } +spacetimedb-metrics = { path = "crates/metrics", version = "=1.10.0" } +spacetimedb-paths = { path = "crates/paths", version = "=1.10.0" } +spacetimedb-pg = { path = "crates/pg", version = "=1.10.0" } +spacetimedb-physical-plan = { path = "crates/physical-plan", version = "=1.10.0" } +spacetimedb-primitives = { path = "crates/primitives", version = "=1.10.0" } +spacetimedb-query = { path = "crates/query", version = "=1.10.0" } +spacetimedb-sats = { path = "crates/sats", version = "=1.10.0" } +spacetimedb-schema = { path = "crates/schema", version = "=1.10.0" } +spacetimedb-standalone = { path = "crates/standalone", version = "=1.10.0" } +spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=1.10.0" } +spacetimedb-table = { path = "crates/table", version = "=1.10.0" } +spacetimedb-vm = { path = "crates/vm", version = "=1.10.0" } +spacetimedb-fs-utils = { path = "crates/fs-utils", version = "=1.10.0" } +spacetimedb-snapshot = { path = "crates/snapshot", version = "=1.10.0" } +spacetimedb-subscription = { path = "crates/subscription", version = "=1.10.0" } # Prevent `ahash` from pulling in `getrandom` by disabling default features. # Modules use `getrandom02` and we need to prevent an incompatible version diff --git a/LICENSE.txt b/LICENSE.txt index 0c2732e24a3..25ca9eeb60f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -5,7 +5,7 @@ Business Source License 1.1 Parameters Licensor: Clockwork Laboratories, Inc. -Licensed Work: SpacetimeDB 1.9.0 +Licensed Work: SpacetimeDB 1.10.0 The Licensed Work is (c) 2023 Clockwork Laboratories, Inc. @@ -21,7 +21,7 @@ Additional Use Grant: You may make use of the Licensed Work provided your Licensed Work by creating tables whose schemas are controlled by such third parties. -Change Date: 2030-11-20 +Change Date: 2030-11-25 Change License: GNU Affero General Public License v3.0 with a linking exception diff --git a/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj b/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj index 2157c723aef..20eeab1ac19 100644 --- a/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj +++ b/crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj @@ -2,7 +2,7 @@ SpacetimeDB.BSATN.Codegen - 1.9.0 + 1.10.0 SpacetimeDB BSATN Codegen The SpacetimeDB BSATN Codegen implements the Roslyn incremental generators for BSATN serialization/deserialization in C#. diff --git a/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj b/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj index ae7680b99bd..3007b2cb4cf 100644 --- a/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj +++ b/crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj @@ -2,7 +2,7 @@ SpacetimeDB.BSATN.Runtime - 1.9.0 + 1.10.0 SpacetimeDB BSATN Runtime The SpacetimeDB BSATN Runtime implements APIs for BSATN serialization/deserialization in C#. true diff --git a/crates/bindings-csharp/Codegen/Codegen.csproj b/crates/bindings-csharp/Codegen/Codegen.csproj index 30e15115f23..4f481e8ebb5 100644 --- a/crates/bindings-csharp/Codegen/Codegen.csproj +++ b/crates/bindings-csharp/Codegen/Codegen.csproj @@ -2,7 +2,7 @@ SpacetimeDB.Codegen - 1.9.0 + 1.10.0 SpacetimeDB Module Codegen The SpacetimeDB Codegen implements the Roslyn incremental generators for writing SpacetimeDB modules in C#. diff --git a/crates/bindings-csharp/Runtime/Runtime.csproj b/crates/bindings-csharp/Runtime/Runtime.csproj index 9ee3b3e542e..aa56abb5c63 100644 --- a/crates/bindings-csharp/Runtime/Runtime.csproj +++ b/crates/bindings-csharp/Runtime/Runtime.csproj @@ -2,7 +2,7 @@ SpacetimeDB.Runtime - 1.9.0 + 1.10.0 SpacetimeDB Module Runtime The SpacetimeDB Runtime implements the database runtime bindings for writing SpacetimeDB modules in C#. diff --git a/crates/bindings-typescript/package.json b/crates/bindings-typescript/package.json index 06bf169fcaf..88886aa933f 100644 --- a/crates/bindings-typescript/package.json +++ b/crates/bindings-typescript/package.json @@ -1,6 +1,6 @@ { "name": "spacetimedb", - "version": "1.9.0", + "version": "1.10.0", "description": "API and ABI bindings for the SpacetimeDB TypeScript module library", "homepage": "https://github.com/clockworklabs/SpacetimeDB#readme", "bugs": { diff --git a/crates/cli/src/subcommands/project/typescript/package._json b/crates/cli/src/subcommands/project/typescript/package._json index 2ab52d6a89b..9421a37ec9c 100644 --- a/crates/cli/src/subcommands/project/typescript/package._json +++ b/crates/cli/src/subcommands/project/typescript/package._json @@ -10,6 +10,6 @@ "author": "", "license": "ISC", "dependencies": { - "spacetimedb": "1.9.*" + "spacetimedb": "1.10.*" } } \ No newline at end of file diff --git a/crates/cli/templates/basic-c-sharp/server/StdbModule.csproj b/crates/cli/templates/basic-c-sharp/server/StdbModule.csproj index e36d30360ec..4b5f0ce1de2 100644 --- a/crates/cli/templates/basic-c-sharp/server/StdbModule.csproj +++ b/crates/cli/templates/basic-c-sharp/server/StdbModule.csproj @@ -8,7 +8,7 @@ - + diff --git a/crates/cli/templates/basic-rust/client/Cargo.toml b/crates/cli/templates/basic-rust/client/Cargo.toml index 71d43c3c131..57091142b3b 100644 --- a/crates/cli/templates/basic-rust/client/Cargo.toml +++ b/crates/cli/templates/basic-rust/client/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -spacetimedb-sdk = "1.9.*" +spacetimedb-sdk = "1.10.*" diff --git a/crates/cli/templates/basic-rust/server/Cargo.toml b/crates/cli/templates/basic-rust/server/Cargo.toml index d90955c6d37..6f6874bf4ed 100644 --- a/crates/cli/templates/basic-rust/server/Cargo.toml +++ b/crates/cli/templates/basic-rust/server/Cargo.toml @@ -9,5 +9,5 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -spacetimedb = "1.9.*" +spacetimedb = "1.10.*" log = "0.4" diff --git a/demo/Blackholio/server-csharp/StdbModule.csproj b/demo/Blackholio/server-csharp/StdbModule.csproj index 9308e3399f6..8bf86e69b70 100644 --- a/demo/Blackholio/server-csharp/StdbModule.csproj +++ b/demo/Blackholio/server-csharp/StdbModule.csproj @@ -13,7 +13,7 @@ - + diff --git a/licenses/BSL.txt b/licenses/BSL.txt index 7d842785e2a..dc749528c64 100644 --- a/licenses/BSL.txt +++ b/licenses/BSL.txt @@ -5,7 +5,7 @@ Business Source License 1.1 Parameters Licensor: Clockwork Laboratories, Inc. -Licensed Work: SpacetimeDB 1.9.0 +Licensed Work: SpacetimeDB 1.10.0 The Licensed Work is (c) 2023 Clockwork Laboratories, Inc. @@ -21,7 +21,7 @@ Additional Use Grant: You may make use of the Licensed Work provided your Licensed Work by creating tables whose schemas are controlled by such third parties. -Change Date: 2030-11-20 +Change Date: 2030-11-25 Change License: GNU Affero General Public License v3.0 with a linking exception diff --git a/sdks/csharp/SpacetimeDB.ClientSDK.csproj b/sdks/csharp/SpacetimeDB.ClientSDK.csproj index 69f36aa3cdc..10febed2255 100644 --- a/sdks/csharp/SpacetimeDB.ClientSDK.csproj +++ b/sdks/csharp/SpacetimeDB.ClientSDK.csproj @@ -16,8 +16,8 @@ logo.png README.md https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk - 1.9.0 - 1.9.0 + 1.10.0 + 1.10.0 $(DefaultItemExcludes);*~/** packages @@ -25,7 +25,7 @@ - + diff --git a/sdks/csharp/examples~/quickstart-chat/server/StdbModule.csproj b/sdks/csharp/examples~/quickstart-chat/server/StdbModule.csproj index 8602a71980a..f3db06ba6f8 100644 --- a/sdks/csharp/examples~/quickstart-chat/server/StdbModule.csproj +++ b/sdks/csharp/examples~/quickstart-chat/server/StdbModule.csproj @@ -14,7 +14,7 @@ - + diff --git a/sdks/csharp/examples~/regression-tests/server/StdbModule.csproj b/sdks/csharp/examples~/regression-tests/server/StdbModule.csproj index e36d30360ec..4b5f0ce1de2 100644 --- a/sdks/csharp/examples~/regression-tests/server/StdbModule.csproj +++ b/sdks/csharp/examples~/regression-tests/server/StdbModule.csproj @@ -8,7 +8,7 @@ - + diff --git a/sdks/csharp/package.json b/sdks/csharp/package.json index fbfcf52a6a6..513a8b26d69 100644 --- a/sdks/csharp/package.json +++ b/sdks/csharp/package.json @@ -1,7 +1,7 @@ { "name": "com.clockworklabs.spacetimedbsdk", "displayName": "SpacetimeDB SDK", - "version": "1.9.0", + "version": "1.10.0", "description": "The SpacetimeDB Client SDK is a software development kit (SDK) designed to interact with and manipulate SpacetimeDB modules..", "keywords": [], "author": { From b6abd32bdd4feadebd1c33d5d53976cae8a3b038 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Tue, 25 Nov 2025 23:29:11 -0600 Subject: [PATCH 2/4] Update snapshot --- crates/codegen/tests/snapshots/codegen__codegen_typescript.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap index 1c93ee342a7..dc5b79c1417 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -529,7 +529,7 @@ const proceduresSchema = __procedures( const REMOTE_MODULE = { versionInfo: { - cliVersion: "1.9.0" as const, + cliVersion: "1.10.0" as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, From 6fa2accda7a6234e964a2c9561151258ca8f1fd6 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Wed, 26 Nov 2025 06:08:43 +0000 Subject: [PATCH 3/4] Regenerated bindings --- .../identity_connected_reducer.ts | 65 +++- .../identity_disconnected_reducer.ts | 65 +++- .../src/module_bindings/index.ts | 323 +++++++++++++----- .../src/module_bindings/message_table.ts | 84 ++++- .../src/module_bindings/message_type.ts | 80 ++++- .../module_bindings/send_message_reducer.ts | 69 +++- .../src/module_bindings/set_name_reducer.ts | 67 +++- .../src/module_bindings/user_table.ts | 117 ++++++- .../src/module_bindings/user_type.ts | 82 ++++- 9 files changed, 805 insertions(+), 147 deletions(-) diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts index 2ca99c88fea..c5f335a93ad 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts @@ -4,10 +4,65 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default {}; +export type IdentityConnected = {}; +let _cached_IdentityConnected_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const IdentityConnected = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_IdentityConnected_type_value) + return _cached_IdentityConnected_type_value; + _cached_IdentityConnected_type_value = __AlgebraicTypeValue.Product({ + elements: [], + }); + _cached_IdentityConnected_type_value.value.elements.push(); + return _cached_IdentityConnected_type_value; + }, + + serialize(writer: __BinaryWriter, value: IdentityConnected): void { + __AlgebraicTypeValue.serializeValue( + writer, + IdentityConnected.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): IdentityConnected { + return __AlgebraicTypeValue.deserializeValue( + reader, + IdentityConnected.getTypeScriptAlgebraicType() + ); + }, +}; + +export default IdentityConnected; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts index 2ca99c88fea..1d2c3901076 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts @@ -4,10 +4,65 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default {}; +export type IdentityDisconnected = {}; +let _cached_IdentityDisconnected_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const IdentityDisconnected = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_IdentityDisconnected_type_value) + return _cached_IdentityDisconnected_type_value; + _cached_IdentityDisconnected_type_value = __AlgebraicTypeValue.Product({ + elements: [], + }); + _cached_IdentityDisconnected_type_value.value.elements.push(); + return _cached_IdentityDisconnected_type_value; + }, + + serialize(writer: __BinaryWriter, value: IdentityDisconnected): void { + __AlgebraicTypeValue.serializeValue( + writer, + IdentityDisconnected.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): IdentityDisconnected { + return __AlgebraicTypeValue.deserializeValue( + reader, + IdentityDisconnected.getTypeScriptAlgebraicType() + ); + }, +}; + +export default IdentityDisconnected; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts index 4d99d5c2a96..d124d37a6d3 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts @@ -1,134 +1,279 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.9.0 (commit ed2a18cff7c996f28bd3b6ae0223ceb564fc2a58). +// This was generated using spacetimedb cli version 1.7.0 (commit 02c67d121b0d08478eaf3512f479e7a326d39940). /* eslint-disable */ /* tslint:disable */ import { + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, DbConnectionBuilder as __DbConnectionBuilder, DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TypeBuilder as __TypeBuilder, - convertToAccessorMap as __convertToAccessorMap, - procedureSchema as __procedureSchema, - procedures as __procedures, - reducerSchema as __reducerSchema, - reducers as __reducers, - schema as __schema, - t as __t, - table as __table, - type AlgebraicTypeType as __AlgebraicTypeType, - type DbConnectionConfig as __DbConnectionConfig, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, type ErrorContextInterface as __ErrorContextInterface, type Event as __Event, type EventContextInterface as __EventContextInterface, - type Infer as __Infer, type ReducerEventContextInterface as __ReducerEventContextInterface, - type RemoteModule as __RemoteModule, type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; // Import and reexport all reducer arg types -import IdentityConnected from './identity_connected_reducer'; +import { IdentityConnected } from './identity_connected_reducer.ts'; export { IdentityConnected }; -import IdentityDisconnected from './identity_disconnected_reducer'; +import { IdentityDisconnected } from './identity_disconnected_reducer.ts'; export { IdentityDisconnected }; -import SendMessage from './send_message_reducer'; +import { SendMessage } from './send_message_reducer.ts'; export { SendMessage }; -import SetName from './set_name_reducer'; +import { SetName } from './set_name_reducer.ts'; export { SetName }; -// Import and reexport all procedure arg types - // Import and reexport all table handle types -import MessageRow from './message_table'; -export { MessageRow }; -import UserRow from './user_table'; -export { UserRow }; +import { MessageTableHandle } from './message_table.ts'; +export { MessageTableHandle }; +import { UserTableHandle } from './user_table.ts'; +export { UserTableHandle }; // Import and reexport all types -import Message from './message_type'; +import { Message } from './message_type.ts'; export { Message }; -import User from './user_type'; +import { User } from './user_type.ts'; export { User }; -const tablesSchema = __schema( - __table( - { - name: 'message', - indexes: [], - constraints: [], +const REMOTE_MODULE = { + tables: { + message: { + tableName: 'message' as const, + rowType: Message.getTypeScriptAlgebraicType(), + }, + user: { + tableName: 'user' as const, + rowType: User.getTypeScriptAlgebraicType(), + primaryKey: 'identity', + primaryKeyInfo: { + colName: 'identity', + colType: ( + User.getTypeScriptAlgebraicType() as __AlgebraicTypeVariants.Product + ).value.elements[0].algebraicType, + }, + }, + }, + reducers: { + identity_connected: { + reducerName: 'identity_connected', + argsType: IdentityConnected.getTypeScriptAlgebraicType(), + }, + identity_disconnected: { + reducerName: 'identity_disconnected', + argsType: IdentityDisconnected.getTypeScriptAlgebraicType(), + }, + send_message: { + reducerName: 'send_message', + argsType: SendMessage.getTypeScriptAlgebraicType(), }, - MessageRow - ), - __table( - { - name: 'user', - indexes: [ - { name: 'identity', algorithm: 'btree', columns: ['identity'] }, - ], - constraints: [ - { - name: 'user_identity_key', - constraint: 'unique', - columns: ['identity'], - }, - ], + set_name: { + reducerName: 'set_name', + argsType: SetName.getTypeScriptAlgebraicType(), }, - UserRow - ) -); + }, + versionInfo: { + cliVersion: '1.7.0', + }, + // Constructors which are used by the DbConnectionImpl to + // extract type information from the generated RemoteModule. + // + // NOTE: This is not strictly necessary for `eventContextConstructor` because + // all we do is build a TypeScript object which we could have done inside the + // SDK, but if in the future we wanted to create a class this would be + // necessary because classes have methods, so we'll keep it. + eventContextConstructor: ( + imp: __DbConnectionImpl, + event: __Event + ) => { + return { + ...(imp as DbConnection), + event, + }; + }, + dbViewConstructor: (imp: __DbConnectionImpl) => { + return new RemoteTables(imp); + }, + reducersConstructor: ( + imp: __DbConnectionImpl, + setReducerFlags: SetReducerFlags + ) => { + return new RemoteReducers(imp, setReducerFlags); + }, + setReducerFlagsConstructor: () => { + return new SetReducerFlags(); + }, +}; -const reducersSchema = __reducers( - __reducerSchema('send_message', SendMessage), - __reducerSchema('set_name', SetName) -); +// A type representing all the possible variants of a reducer. +export type Reducer = + | never + | { name: 'IdentityConnected'; args: IdentityConnected } + | { name: 'IdentityDisconnected'; args: IdentityDisconnected } + | { name: 'SendMessage'; args: SendMessage } + | { name: 'SetName'; args: SetName }; -const proceduresSchema = __procedures(); +export class RemoteReducers { + constructor( + private connection: __DbConnectionImpl, + private setCallReducerFlags: SetReducerFlags + ) {} -const REMOTE_MODULE = { - versionInfo: { - cliVersion: '1.9.0' as const, - }, - tables: tablesSchema.schemaType.tables, - reducers: reducersSchema.reducersType.reducers, - ...proceduresSchema, -} satisfies __RemoteModule< - typeof tablesSchema.schemaType, - typeof reducersSchema.reducersType, - typeof proceduresSchema ->; + onIdentityConnected(callback: (ctx: ReducerEventContext) => void) { + this.connection.onReducer('identity_connected', callback); + } -export const tables = __convertToAccessorMap(tablesSchema.schemaType.tables); -export const reducers = __convertToAccessorMap( - reducersSchema.reducersType.reducers -); + removeOnIdentityConnected(callback: (ctx: ReducerEventContext) => void) { + this.connection.offReducer('identity_connected', callback); + } -export type EventContext = __EventContextInterface; -export type ReducerEventContext = __ReducerEventContextInterface< - typeof REMOTE_MODULE ->; -export type SubscriptionEventContext = __SubscriptionEventContextInterface< - typeof REMOTE_MODULE ->; -export type ErrorContext = __ErrorContextInterface; + onIdentityDisconnected(callback: (ctx: ReducerEventContext) => void) { + this.connection.onReducer('identity_disconnected', callback); + } -export class SubscriptionBuilder extends __SubscriptionBuilderImpl< - typeof REMOTE_MODULE -> {} + removeOnIdentityDisconnected(callback: (ctx: ReducerEventContext) => void) { + this.connection.offReducer('identity_disconnected', callback); + } + + sendMessage(text: string) { + const __args = { text }; + let __writer = new __BinaryWriter(1024); + SendMessage.serialize(__writer, __args); + let __argsBuffer = __writer.getBuffer(); + this.connection.callReducer( + 'send_message', + __argsBuffer, + this.setCallReducerFlags.sendMessageFlags + ); + } + + onSendMessage(callback: (ctx: ReducerEventContext, text: string) => void) { + this.connection.onReducer('send_message', callback); + } -export class DbConnectionBuilder extends __DbConnectionBuilder {} + removeOnSendMessage( + callback: (ctx: ReducerEventContext, text: string) => void + ) { + this.connection.offReducer('send_message', callback); + } + + setName(name: string) { + const __args = { name }; + let __writer = new __BinaryWriter(1024); + SetName.serialize(__writer, __args); + let __argsBuffer = __writer.getBuffer(); + this.connection.callReducer( + 'set_name', + __argsBuffer, + this.setCallReducerFlags.setNameFlags + ); + } + + onSetName(callback: (ctx: ReducerEventContext, name: string) => void) { + this.connection.onReducer('set_name', callback); + } + + removeOnSetName(callback: (ctx: ReducerEventContext, name: string) => void) { + this.connection.offReducer('set_name', callback); + } +} + +export class SetReducerFlags { + sendMessageFlags: __CallReducerFlags = 'FullUpdate'; + sendMessage(flags: __CallReducerFlags) { + this.sendMessageFlags = flags; + } + + setNameFlags: __CallReducerFlags = 'FullUpdate'; + setName(flags: __CallReducerFlags) { + this.setNameFlags = flags; + } +} + +export class RemoteTables { + constructor(private connection: __DbConnectionImpl) {} + + get message(): MessageTableHandle<'message'> { + // clientCache is a private property + return new MessageTableHandle( + ( + this.connection as unknown as { clientCache: __ClientCache } + ).clientCache.getOrCreateTable(REMOTE_MODULE.tables.message) + ); + } -export class DbConnection extends __DbConnectionImpl { - static builder = (): DbConnectionBuilder => { - return new DbConnectionBuilder( - REMOTE_MODULE, - (config: __DbConnectionConfig) => - new DbConnection(config) + get user(): UserTableHandle<'user'> { + // clientCache is a private property + return new UserTableHandle( + ( + this.connection as unknown as { clientCache: __ClientCache } + ).clientCache.getOrCreateTable(REMOTE_MODULE.tables.user) ); + } +} + +export class SubscriptionBuilder extends __SubscriptionBuilderImpl< + RemoteTables, + RemoteReducers, + SetReducerFlags +> {} + +export class DbConnection extends __DbConnectionImpl< + RemoteTables, + RemoteReducers, + SetReducerFlags +> { + static builder = (): __DbConnectionBuilder< + DbConnection, + ErrorContext, + SubscriptionEventContext + > => { + return new __DbConnectionBuilder< + DbConnection, + ErrorContext, + SubscriptionEventContext + >(REMOTE_MODULE, (imp: __DbConnectionImpl) => imp as DbConnection); }; subscriptionBuilder = (): SubscriptionBuilder => { return new SubscriptionBuilder(this); }; } + +export type EventContext = __EventContextInterface< + RemoteTables, + RemoteReducers, + SetReducerFlags, + Reducer +>; +export type ReducerEventContext = __ReducerEventContextInterface< + RemoteTables, + RemoteReducers, + SetReducerFlags, + Reducer +>; +export type SubscriptionEventContext = __SubscriptionEventContextInterface< + RemoteTables, + RemoteReducers, + SetReducerFlags +>; +export type ErrorContext = __ErrorContextInterface< + RemoteTables, + RemoteReducers, + SetReducerFlags +>; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts index 87044c64df4..26b0bc1e34a 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts @@ -4,14 +4,80 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; +import { Message } from './message_type'; +import { + type EventContext, + type Reducer, + RemoteReducers, + RemoteTables, +} from '.'; +declare type __keep = [EventContext, Reducer, RemoteReducers, RemoteTables]; + +/** + * Table handle for the table `message`. + * + * Obtain a handle from the [`message`] property on [`RemoteTables`], + * like `ctx.db.message`. + * + * Users are encouraged not to explicitly reference this type, + * but to directly chain method calls, + * like `ctx.db.message.on_insert(...)`. + */ +export class MessageTableHandle + implements __TableHandle +{ + // phantom type to track the table name + readonly tableName!: TableName; + tableCache: __TableCache; + + constructor(tableCache: __TableCache) { + this.tableCache = tableCache; + } + + count(): number { + return this.tableCache.count(); + } + + iter(): Iterable { + return this.tableCache.iter(); + } + + onInsert = (cb: (ctx: EventContext, row: Message) => void) => { + return this.tableCache.onInsert(cb); + }; + + removeOnInsert = (cb: (ctx: EventContext, row: Message) => void) => { + return this.tableCache.removeOnInsert(cb); + }; + + onDelete = (cb: (ctx: EventContext, row: Message) => void) => { + return this.tableCache.onDelete(cb); + }; -export default __t.row({ - sender: __t.identity(), - sent: __t.timestamp(), - text: __t.string(), -}); + removeOnDelete = (cb: (ctx: EventContext, row: Message) => void) => { + return this.tableCache.removeOnDelete(cb); + }; +} diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts index c15fedf0f6a..e4080eced64 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts @@ -4,14 +4,76 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default __t.object('Message', { - sender: __t.identity(), - sent: __t.timestamp(), - text: __t.string(), -}); +export type Message = { + sender: __Identity; + sent: __Timestamp; + text: string; +}; +let _cached_Message_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const Message = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_Message_type_value) return _cached_Message_type_value; + _cached_Message_type_value = __AlgebraicTypeValue.Product({ elements: [] }); + _cached_Message_type_value.value.elements.push( + { + name: 'sender', + algebraicType: __AlgebraicTypeValue.createIdentityType(), + }, + { + name: 'sent', + algebraicType: __AlgebraicTypeValue.createTimestampType(), + }, + { name: 'text', algebraicType: __AlgebraicTypeValue.String } + ); + return _cached_Message_type_value; + }, + + serialize(writer: __BinaryWriter, value: Message): void { + __AlgebraicTypeValue.serializeValue( + writer, + Message.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): Message { + return __AlgebraicTypeValue.deserializeValue( + reader, + Message.getTypeScriptAlgebraicType() + ); + }, +}; + +export default Message; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts index 4aeb65a0ae9..e30d08b732e 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts @@ -4,12 +4,69 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default { - text: __t.string(), +export type SendMessage = { + text: string; }; +let _cached_SendMessage_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const SendMessage = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_SendMessage_type_value) return _cached_SendMessage_type_value; + _cached_SendMessage_type_value = __AlgebraicTypeValue.Product({ + elements: [], + }); + _cached_SendMessage_type_value.value.elements.push({ + name: 'text', + algebraicType: __AlgebraicTypeValue.String, + }); + return _cached_SendMessage_type_value; + }, + + serialize(writer: __BinaryWriter, value: SendMessage): void { + __AlgebraicTypeValue.serializeValue( + writer, + SendMessage.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): SendMessage { + return __AlgebraicTypeValue.deserializeValue( + reader, + SendMessage.getTypeScriptAlgebraicType() + ); + }, +}; + +export default SendMessage; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts index 85081559c7d..e571226e6be 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts @@ -4,12 +4,67 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default { - name: __t.string(), +export type SetName = { + name: string; }; +let _cached_SetName_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const SetName = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_SetName_type_value) return _cached_SetName_type_value; + _cached_SetName_type_value = __AlgebraicTypeValue.Product({ elements: [] }); + _cached_SetName_type_value.value.elements.push({ + name: 'name', + algebraicType: __AlgebraicTypeValue.String, + }); + return _cached_SetName_type_value; + }, + + serialize(writer: __BinaryWriter, value: SetName): void { + __AlgebraicTypeValue.serializeValue( + writer, + SetName.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): SetName { + return __AlgebraicTypeValue.deserializeValue( + reader, + SetName.getTypeScriptAlgebraicType() + ); + }, +}; + +export default SetName; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts index 93e32698c03..85687a99eff 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts @@ -4,14 +4,113 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; +import { User } from './user_type'; +import { + type EventContext, + type Reducer, + RemoteReducers, + RemoteTables, +} from '.'; +declare type __keep = [EventContext, Reducer, RemoteReducers, RemoteTables]; + +/** + * Table handle for the table `user`. + * + * Obtain a handle from the [`user`] property on [`RemoteTables`], + * like `ctx.db.user`. + * + * Users are encouraged not to explicitly reference this type, + * but to directly chain method calls, + * like `ctx.db.user.on_insert(...)`. + */ +export class UserTableHandle + implements __TableHandle +{ + // phantom type to track the table name + readonly tableName!: TableName; + tableCache: __TableCache; + + constructor(tableCache: __TableCache) { + this.tableCache = tableCache; + } + + count(): number { + return this.tableCache.count(); + } + + iter(): Iterable { + return this.tableCache.iter(); + } + /** + * Access to the `identity` unique index on the table `user`, + * which allows point queries on the field of the same name + * via the [`UserIdentityUnique.find`] method. + * + * Users are encouraged not to explicitly reference this type, + * but to directly chain method calls, + * like `ctx.db.user.identity().find(...)`. + * + * Get a handle on the `identity` unique index on the table `user`. + */ + identity = { + // Find the subscribed row whose `identity` column value is equal to `col_val`, + // if such a row is present in the client cache. + find: (col_val: __Identity): User | undefined => { + for (let row of this.tableCache.iter()) { + if (__deepEqual(row.identity, col_val)) { + return row; + } + } + }, + }; + + onInsert = (cb: (ctx: EventContext, row: User) => void) => { + return this.tableCache.onInsert(cb); + }; + + removeOnInsert = (cb: (ctx: EventContext, row: User) => void) => { + return this.tableCache.removeOnInsert(cb); + }; + + onDelete = (cb: (ctx: EventContext, row: User) => void) => { + return this.tableCache.onDelete(cb); + }; + + removeOnDelete = (cb: (ctx: EventContext, row: User) => void) => { + return this.tableCache.removeOnDelete(cb); + }; + + // Updates are only defined for tables with primary keys. + onUpdate = (cb: (ctx: EventContext, oldRow: User, newRow: User) => void) => { + return this.tableCache.onUpdate(cb); + }; -export default __t.row({ - identity: __t.identity().primaryKey(), - name: __t.option(__t.string()), - online: __t.bool(), -}); + removeOnUpdate = ( + cb: (ctx: EventContext, onRow: User, newRow: User) => void + ) => { + return this.tableCache.removeOnUpdate(cb); + }; +} diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts index 89123cb9ad8..974cc8d48e6 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts @@ -4,14 +4,78 @@ /* eslint-disable */ /* tslint:disable */ import { - TypeBuilder as __TypeBuilder, - t as __t, - type AlgebraicTypeType as __AlgebraicTypeType, - type Infer as __Infer, + AlgebraicType as __AlgebraicTypeValue, + BinaryReader as __BinaryReader, + BinaryWriter as __BinaryWriter, + ClientCache as __ClientCache, + ConnectionId as __ConnectionId, + DbConnectionBuilder as __DbConnectionBuilder, + DbConnectionImpl as __DbConnectionImpl, + Identity as __Identity, + SubscriptionBuilderImpl as __SubscriptionBuilderImpl, + TableCache as __TableCache, + TimeDuration as __TimeDuration, + Timestamp as __Timestamp, + deepEqual as __deepEqual, + type AlgebraicType as __AlgebraicTypeType, + type AlgebraicTypeVariants as __AlgebraicTypeVariants, + type CallReducerFlags as __CallReducerFlags, + type ErrorContextInterface as __ErrorContextInterface, + type Event as __Event, + type EventContextInterface as __EventContextInterface, + type ReducerEventContextInterface as __ReducerEventContextInterface, + type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, + type TableHandle as __TableHandle, } from 'spacetimedb'; -export default __t.object('User', { - identity: __t.identity(), - name: __t.option(__t.string()), - online: __t.bool(), -}); +export type User = { + identity: __Identity; + name: string | undefined; + online: boolean; +}; +let _cached_User_type_value: __AlgebraicTypeType | null = null; + +/** + * An object for generated helper functions. + */ +export const User = { + /** + * A function which returns this type represented as an AlgebraicType. + * This function is derived from the AlgebraicType used to generate this type. + */ + getTypeScriptAlgebraicType(): __AlgebraicTypeType { + if (_cached_User_type_value) return _cached_User_type_value; + _cached_User_type_value = __AlgebraicTypeValue.Product({ elements: [] }); + _cached_User_type_value.value.elements.push( + { + name: 'identity', + algebraicType: __AlgebraicTypeValue.createIdentityType(), + }, + { + name: 'name', + algebraicType: __AlgebraicTypeValue.createOptionType( + __AlgebraicTypeValue.String + ), + }, + { name: 'online', algebraicType: __AlgebraicTypeValue.Bool } + ); + return _cached_User_type_value; + }, + + serialize(writer: __BinaryWriter, value: User): void { + __AlgebraicTypeValue.serializeValue( + writer, + User.getTypeScriptAlgebraicType(), + value + ); + }, + + deserialize(reader: __BinaryReader): User { + return __AlgebraicTypeValue.deserializeValue( + reader, + User.getTypeScriptAlgebraicType() + ); + }, +}; + +export default User; From 77378d31d86c56cdd7b999105187ed6e3d37ee73 Mon Sep 17 00:00:00 2001 From: John Detter <4099508+jdetter@users.noreply.github.com> Date: Wed, 26 Nov 2025 06:17:44 +0000 Subject: [PATCH 4/4] Use correct version --- .../identity_connected_reducer.ts | 65 +--- .../identity_disconnected_reducer.ts | 65 +--- .../src/module_bindings/index.ts | 323 +++++------------- .../src/module_bindings/message_table.ts | 84 +---- .../src/module_bindings/message_type.ts | 80 +---- .../module_bindings/send_message_reducer.ts | 69 +--- .../src/module_bindings/set_name_reducer.ts | 67 +--- .../src/module_bindings/user_table.ts | 117 +------ .../src/module_bindings/user_type.ts | 82 +---- 9 files changed, 147 insertions(+), 805 deletions(-) diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts index c5f335a93ad..2ca99c88fea 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts @@ -4,65 +4,10 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type IdentityConnected = {}; -let _cached_IdentityConnected_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const IdentityConnected = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_IdentityConnected_type_value) - return _cached_IdentityConnected_type_value; - _cached_IdentityConnected_type_value = __AlgebraicTypeValue.Product({ - elements: [], - }); - _cached_IdentityConnected_type_value.value.elements.push(); - return _cached_IdentityConnected_type_value; - }, - - serialize(writer: __BinaryWriter, value: IdentityConnected): void { - __AlgebraicTypeValue.serializeValue( - writer, - IdentityConnected.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): IdentityConnected { - return __AlgebraicTypeValue.deserializeValue( - reader, - IdentityConnected.getTypeScriptAlgebraicType() - ); - }, -}; - -export default IdentityConnected; +export default {}; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts index 1d2c3901076..2ca99c88fea 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts @@ -4,65 +4,10 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type IdentityDisconnected = {}; -let _cached_IdentityDisconnected_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const IdentityDisconnected = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_IdentityDisconnected_type_value) - return _cached_IdentityDisconnected_type_value; - _cached_IdentityDisconnected_type_value = __AlgebraicTypeValue.Product({ - elements: [], - }); - _cached_IdentityDisconnected_type_value.value.elements.push(); - return _cached_IdentityDisconnected_type_value; - }, - - serialize(writer: __BinaryWriter, value: IdentityDisconnected): void { - __AlgebraicTypeValue.serializeValue( - writer, - IdentityDisconnected.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): IdentityDisconnected { - return __AlgebraicTypeValue.deserializeValue( - reader, - IdentityDisconnected.getTypeScriptAlgebraicType() - ); - }, -}; - -export default IdentityDisconnected; +export default {}; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts index d124d37a6d3..664379e52ef 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts @@ -1,279 +1,134 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.7.0 (commit 02c67d121b0d08478eaf3512f479e7a326d39940). +// This was generated using spacetimedb cli version 1.10.0 (commit b6abd32bdd4feadebd1c33d5d53976cae8a3b038). /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, DbConnectionBuilder as __DbConnectionBuilder, DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, + TypeBuilder as __TypeBuilder, + convertToAccessorMap as __convertToAccessorMap, + procedureSchema as __procedureSchema, + procedures as __procedures, + reducerSchema as __reducerSchema, + reducers as __reducers, + schema as __schema, + t as __t, + table as __table, + type AlgebraicTypeType as __AlgebraicTypeType, + type DbConnectionConfig as __DbConnectionConfig, type ErrorContextInterface as __ErrorContextInterface, type Event as __Event, type EventContextInterface as __EventContextInterface, + type Infer as __Infer, type ReducerEventContextInterface as __ReducerEventContextInterface, + type RemoteModule as __RemoteModule, type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, } from 'spacetimedb'; // Import and reexport all reducer arg types -import { IdentityConnected } from './identity_connected_reducer.ts'; +import IdentityConnected from './identity_connected_reducer'; export { IdentityConnected }; -import { IdentityDisconnected } from './identity_disconnected_reducer.ts'; +import IdentityDisconnected from './identity_disconnected_reducer'; export { IdentityDisconnected }; -import { SendMessage } from './send_message_reducer.ts'; +import SendMessage from './send_message_reducer'; export { SendMessage }; -import { SetName } from './set_name_reducer.ts'; +import SetName from './set_name_reducer'; export { SetName }; +// Import and reexport all procedure arg types + // Import and reexport all table handle types -import { MessageTableHandle } from './message_table.ts'; -export { MessageTableHandle }; -import { UserTableHandle } from './user_table.ts'; -export { UserTableHandle }; +import MessageRow from './message_table'; +export { MessageRow }; +import UserRow from './user_table'; +export { UserRow }; // Import and reexport all types -import { Message } from './message_type.ts'; +import Message from './message_type'; export { Message }; -import { User } from './user_type.ts'; +import User from './user_type'; export { User }; -const REMOTE_MODULE = { - tables: { - message: { - tableName: 'message' as const, - rowType: Message.getTypeScriptAlgebraicType(), - }, - user: { - tableName: 'user' as const, - rowType: User.getTypeScriptAlgebraicType(), - primaryKey: 'identity', - primaryKeyInfo: { - colName: 'identity', - colType: ( - User.getTypeScriptAlgebraicType() as __AlgebraicTypeVariants.Product - ).value.elements[0].algebraicType, - }, - }, - }, - reducers: { - identity_connected: { - reducerName: 'identity_connected', - argsType: IdentityConnected.getTypeScriptAlgebraicType(), - }, - identity_disconnected: { - reducerName: 'identity_disconnected', - argsType: IdentityDisconnected.getTypeScriptAlgebraicType(), - }, - send_message: { - reducerName: 'send_message', - argsType: SendMessage.getTypeScriptAlgebraicType(), +const tablesSchema = __schema( + __table( + { + name: 'message', + indexes: [], + constraints: [], }, - set_name: { - reducerName: 'set_name', - argsType: SetName.getTypeScriptAlgebraicType(), + MessageRow + ), + __table( + { + name: 'user', + indexes: [ + { name: 'identity', algorithm: 'btree', columns: ['identity'] }, + ], + constraints: [ + { + name: 'user_identity_key', + constraint: 'unique', + columns: ['identity'], + }, + ], }, - }, - versionInfo: { - cliVersion: '1.7.0', - }, - // Constructors which are used by the DbConnectionImpl to - // extract type information from the generated RemoteModule. - // - // NOTE: This is not strictly necessary for `eventContextConstructor` because - // all we do is build a TypeScript object which we could have done inside the - // SDK, but if in the future we wanted to create a class this would be - // necessary because classes have methods, so we'll keep it. - eventContextConstructor: ( - imp: __DbConnectionImpl, - event: __Event - ) => { - return { - ...(imp as DbConnection), - event, - }; - }, - dbViewConstructor: (imp: __DbConnectionImpl) => { - return new RemoteTables(imp); - }, - reducersConstructor: ( - imp: __DbConnectionImpl, - setReducerFlags: SetReducerFlags - ) => { - return new RemoteReducers(imp, setReducerFlags); - }, - setReducerFlagsConstructor: () => { - return new SetReducerFlags(); - }, -}; - -// A type representing all the possible variants of a reducer. -export type Reducer = - | never - | { name: 'IdentityConnected'; args: IdentityConnected } - | { name: 'IdentityDisconnected'; args: IdentityDisconnected } - | { name: 'SendMessage'; args: SendMessage } - | { name: 'SetName'; args: SetName }; - -export class RemoteReducers { - constructor( - private connection: __DbConnectionImpl, - private setCallReducerFlags: SetReducerFlags - ) {} - - onIdentityConnected(callback: (ctx: ReducerEventContext) => void) { - this.connection.onReducer('identity_connected', callback); - } - - removeOnIdentityConnected(callback: (ctx: ReducerEventContext) => void) { - this.connection.offReducer('identity_connected', callback); - } - - onIdentityDisconnected(callback: (ctx: ReducerEventContext) => void) { - this.connection.onReducer('identity_disconnected', callback); - } - - removeOnIdentityDisconnected(callback: (ctx: ReducerEventContext) => void) { - this.connection.offReducer('identity_disconnected', callback); - } - - sendMessage(text: string) { - const __args = { text }; - let __writer = new __BinaryWriter(1024); - SendMessage.serialize(__writer, __args); - let __argsBuffer = __writer.getBuffer(); - this.connection.callReducer( - 'send_message', - __argsBuffer, - this.setCallReducerFlags.sendMessageFlags - ); - } - - onSendMessage(callback: (ctx: ReducerEventContext, text: string) => void) { - this.connection.onReducer('send_message', callback); - } - - removeOnSendMessage( - callback: (ctx: ReducerEventContext, text: string) => void - ) { - this.connection.offReducer('send_message', callback); - } - - setName(name: string) { - const __args = { name }; - let __writer = new __BinaryWriter(1024); - SetName.serialize(__writer, __args); - let __argsBuffer = __writer.getBuffer(); - this.connection.callReducer( - 'set_name', - __argsBuffer, - this.setCallReducerFlags.setNameFlags - ); - } - - onSetName(callback: (ctx: ReducerEventContext, name: string) => void) { - this.connection.onReducer('set_name', callback); - } + UserRow + ) +); - removeOnSetName(callback: (ctx: ReducerEventContext, name: string) => void) { - this.connection.offReducer('set_name', callback); - } -} +const reducersSchema = __reducers( + __reducerSchema('send_message', SendMessage), + __reducerSchema('set_name', SetName) +); -export class SetReducerFlags { - sendMessageFlags: __CallReducerFlags = 'FullUpdate'; - sendMessage(flags: __CallReducerFlags) { - this.sendMessageFlags = flags; - } +const proceduresSchema = __procedures(); - setNameFlags: __CallReducerFlags = 'FullUpdate'; - setName(flags: __CallReducerFlags) { - this.setNameFlags = flags; - } -} - -export class RemoteTables { - constructor(private connection: __DbConnectionImpl) {} +const REMOTE_MODULE = { + versionInfo: { + cliVersion: '1.10.0' as const, + }, + tables: tablesSchema.schemaType.tables, + reducers: reducersSchema.reducersType.reducers, + ...proceduresSchema, +} satisfies __RemoteModule< + typeof tablesSchema.schemaType, + typeof reducersSchema.reducersType, + typeof proceduresSchema +>; - get message(): MessageTableHandle<'message'> { - // clientCache is a private property - return new MessageTableHandle( - ( - this.connection as unknown as { clientCache: __ClientCache } - ).clientCache.getOrCreateTable(REMOTE_MODULE.tables.message) - ); - } +export const tables = __convertToAccessorMap(tablesSchema.schemaType.tables); +export const reducers = __convertToAccessorMap( + reducersSchema.reducersType.reducers +); - get user(): UserTableHandle<'user'> { - // clientCache is a private property - return new UserTableHandle( - ( - this.connection as unknown as { clientCache: __ClientCache } - ).clientCache.getOrCreateTable(REMOTE_MODULE.tables.user) - ); - } -} +export type EventContext = __EventContextInterface; +export type ReducerEventContext = __ReducerEventContextInterface< + typeof REMOTE_MODULE +>; +export type SubscriptionEventContext = __SubscriptionEventContextInterface< + typeof REMOTE_MODULE +>; +export type ErrorContext = __ErrorContextInterface; export class SubscriptionBuilder extends __SubscriptionBuilderImpl< - RemoteTables, - RemoteReducers, - SetReducerFlags + typeof REMOTE_MODULE > {} -export class DbConnection extends __DbConnectionImpl< - RemoteTables, - RemoteReducers, - SetReducerFlags -> { - static builder = (): __DbConnectionBuilder< - DbConnection, - ErrorContext, - SubscriptionEventContext - > => { - return new __DbConnectionBuilder< - DbConnection, - ErrorContext, - SubscriptionEventContext - >(REMOTE_MODULE, (imp: __DbConnectionImpl) => imp as DbConnection); +export class DbConnectionBuilder extends __DbConnectionBuilder {} + +export class DbConnection extends __DbConnectionImpl { + static builder = (): DbConnectionBuilder => { + return new DbConnectionBuilder( + REMOTE_MODULE, + (config: __DbConnectionConfig) => + new DbConnection(config) + ); }; subscriptionBuilder = (): SubscriptionBuilder => { return new SubscriptionBuilder(this); }; } - -export type EventContext = __EventContextInterface< - RemoteTables, - RemoteReducers, - SetReducerFlags, - Reducer ->; -export type ReducerEventContext = __ReducerEventContextInterface< - RemoteTables, - RemoteReducers, - SetReducerFlags, - Reducer ->; -export type SubscriptionEventContext = __SubscriptionEventContextInterface< - RemoteTables, - RemoteReducers, - SetReducerFlags ->; -export type ErrorContext = __ErrorContextInterface< - RemoteTables, - RemoteReducers, - SetReducerFlags ->; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts index 26b0bc1e34a..87044c64df4 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_table.ts @@ -4,80 +4,14 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -import { Message } from './message_type'; -import { - type EventContext, - type Reducer, - RemoteReducers, - RemoteTables, -} from '.'; -declare type __keep = [EventContext, Reducer, RemoteReducers, RemoteTables]; - -/** - * Table handle for the table `message`. - * - * Obtain a handle from the [`message`] property on [`RemoteTables`], - * like `ctx.db.message`. - * - * Users are encouraged not to explicitly reference this type, - * but to directly chain method calls, - * like `ctx.db.message.on_insert(...)`. - */ -export class MessageTableHandle - implements __TableHandle -{ - // phantom type to track the table name - readonly tableName!: TableName; - tableCache: __TableCache; - - constructor(tableCache: __TableCache) { - this.tableCache = tableCache; - } - - count(): number { - return this.tableCache.count(); - } - - iter(): Iterable { - return this.tableCache.iter(); - } - - onInsert = (cb: (ctx: EventContext, row: Message) => void) => { - return this.tableCache.onInsert(cb); - }; - - removeOnInsert = (cb: (ctx: EventContext, row: Message) => void) => { - return this.tableCache.removeOnInsert(cb); - }; - - onDelete = (cb: (ctx: EventContext, row: Message) => void) => { - return this.tableCache.onDelete(cb); - }; - removeOnDelete = (cb: (ctx: EventContext, row: Message) => void) => { - return this.tableCache.removeOnDelete(cb); - }; -} +export default __t.row({ + sender: __t.identity(), + sent: __t.timestamp(), + text: __t.string(), +}); diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts index e4080eced64..c15fedf0f6a 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/message_type.ts @@ -4,76 +4,14 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type Message = { - sender: __Identity; - sent: __Timestamp; - text: string; -}; -let _cached_Message_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const Message = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_Message_type_value) return _cached_Message_type_value; - _cached_Message_type_value = __AlgebraicTypeValue.Product({ elements: [] }); - _cached_Message_type_value.value.elements.push( - { - name: 'sender', - algebraicType: __AlgebraicTypeValue.createIdentityType(), - }, - { - name: 'sent', - algebraicType: __AlgebraicTypeValue.createTimestampType(), - }, - { name: 'text', algebraicType: __AlgebraicTypeValue.String } - ); - return _cached_Message_type_value; - }, - - serialize(writer: __BinaryWriter, value: Message): void { - __AlgebraicTypeValue.serializeValue( - writer, - Message.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): Message { - return __AlgebraicTypeValue.deserializeValue( - reader, - Message.getTypeScriptAlgebraicType() - ); - }, -}; - -export default Message; +export default __t.object('Message', { + sender: __t.identity(), + sent: __t.timestamp(), + text: __t.string(), +}); diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts index e30d08b732e..4aeb65a0ae9 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/send_message_reducer.ts @@ -4,69 +4,12 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type SendMessage = { - text: string; +export default { + text: __t.string(), }; -let _cached_SendMessage_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const SendMessage = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_SendMessage_type_value) return _cached_SendMessage_type_value; - _cached_SendMessage_type_value = __AlgebraicTypeValue.Product({ - elements: [], - }); - _cached_SendMessage_type_value.value.elements.push({ - name: 'text', - algebraicType: __AlgebraicTypeValue.String, - }); - return _cached_SendMessage_type_value; - }, - - serialize(writer: __BinaryWriter, value: SendMessage): void { - __AlgebraicTypeValue.serializeValue( - writer, - SendMessage.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): SendMessage { - return __AlgebraicTypeValue.deserializeValue( - reader, - SendMessage.getTypeScriptAlgebraicType() - ); - }, -}; - -export default SendMessage; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts index e571226e6be..85081559c7d 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/set_name_reducer.ts @@ -4,67 +4,12 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type SetName = { - name: string; +export default { + name: __t.string(), }; -let _cached_SetName_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const SetName = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_SetName_type_value) return _cached_SetName_type_value; - _cached_SetName_type_value = __AlgebraicTypeValue.Product({ elements: [] }); - _cached_SetName_type_value.value.elements.push({ - name: 'name', - algebraicType: __AlgebraicTypeValue.String, - }); - return _cached_SetName_type_value; - }, - - serialize(writer: __BinaryWriter, value: SetName): void { - __AlgebraicTypeValue.serializeValue( - writer, - SetName.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): SetName { - return __AlgebraicTypeValue.deserializeValue( - reader, - SetName.getTypeScriptAlgebraicType() - ); - }, -}; - -export default SetName; diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts index 85687a99eff..93e32698c03 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_table.ts @@ -4,113 +4,14 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -import { User } from './user_type'; -import { - type EventContext, - type Reducer, - RemoteReducers, - RemoteTables, -} from '.'; -declare type __keep = [EventContext, Reducer, RemoteReducers, RemoteTables]; - -/** - * Table handle for the table `user`. - * - * Obtain a handle from the [`user`] property on [`RemoteTables`], - * like `ctx.db.user`. - * - * Users are encouraged not to explicitly reference this type, - * but to directly chain method calls, - * like `ctx.db.user.on_insert(...)`. - */ -export class UserTableHandle - implements __TableHandle -{ - // phantom type to track the table name - readonly tableName!: TableName; - tableCache: __TableCache; - - constructor(tableCache: __TableCache) { - this.tableCache = tableCache; - } - - count(): number { - return this.tableCache.count(); - } - - iter(): Iterable { - return this.tableCache.iter(); - } - /** - * Access to the `identity` unique index on the table `user`, - * which allows point queries on the field of the same name - * via the [`UserIdentityUnique.find`] method. - * - * Users are encouraged not to explicitly reference this type, - * but to directly chain method calls, - * like `ctx.db.user.identity().find(...)`. - * - * Get a handle on the `identity` unique index on the table `user`. - */ - identity = { - // Find the subscribed row whose `identity` column value is equal to `col_val`, - // if such a row is present in the client cache. - find: (col_val: __Identity): User | undefined => { - for (let row of this.tableCache.iter()) { - if (__deepEqual(row.identity, col_val)) { - return row; - } - } - }, - }; - - onInsert = (cb: (ctx: EventContext, row: User) => void) => { - return this.tableCache.onInsert(cb); - }; - - removeOnInsert = (cb: (ctx: EventContext, row: User) => void) => { - return this.tableCache.removeOnInsert(cb); - }; - - onDelete = (cb: (ctx: EventContext, row: User) => void) => { - return this.tableCache.onDelete(cb); - }; - - removeOnDelete = (cb: (ctx: EventContext, row: User) => void) => { - return this.tableCache.removeOnDelete(cb); - }; - - // Updates are only defined for tables with primary keys. - onUpdate = (cb: (ctx: EventContext, oldRow: User, newRow: User) => void) => { - return this.tableCache.onUpdate(cb); - }; - removeOnUpdate = ( - cb: (ctx: EventContext, onRow: User, newRow: User) => void - ) => { - return this.tableCache.removeOnUpdate(cb); - }; -} +export default __t.row({ + identity: __t.identity().primaryKey(), + name: __t.option(__t.string()), + online: __t.bool(), +}); diff --git a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts index 974cc8d48e6..89123cb9ad8 100644 --- a/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts +++ b/crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/user_type.ts @@ -4,78 +4,14 @@ /* eslint-disable */ /* tslint:disable */ import { - AlgebraicType as __AlgebraicTypeValue, - BinaryReader as __BinaryReader, - BinaryWriter as __BinaryWriter, - ClientCache as __ClientCache, - ConnectionId as __ConnectionId, - DbConnectionBuilder as __DbConnectionBuilder, - DbConnectionImpl as __DbConnectionImpl, - Identity as __Identity, - SubscriptionBuilderImpl as __SubscriptionBuilderImpl, - TableCache as __TableCache, - TimeDuration as __TimeDuration, - Timestamp as __Timestamp, - deepEqual as __deepEqual, - type AlgebraicType as __AlgebraicTypeType, - type AlgebraicTypeVariants as __AlgebraicTypeVariants, - type CallReducerFlags as __CallReducerFlags, - type ErrorContextInterface as __ErrorContextInterface, - type Event as __Event, - type EventContextInterface as __EventContextInterface, - type ReducerEventContextInterface as __ReducerEventContextInterface, - type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, - type TableHandle as __TableHandle, + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, } from 'spacetimedb'; -export type User = { - identity: __Identity; - name: string | undefined; - online: boolean; -}; -let _cached_User_type_value: __AlgebraicTypeType | null = null; - -/** - * An object for generated helper functions. - */ -export const User = { - /** - * A function which returns this type represented as an AlgebraicType. - * This function is derived from the AlgebraicType used to generate this type. - */ - getTypeScriptAlgebraicType(): __AlgebraicTypeType { - if (_cached_User_type_value) return _cached_User_type_value; - _cached_User_type_value = __AlgebraicTypeValue.Product({ elements: [] }); - _cached_User_type_value.value.elements.push( - { - name: 'identity', - algebraicType: __AlgebraicTypeValue.createIdentityType(), - }, - { - name: 'name', - algebraicType: __AlgebraicTypeValue.createOptionType( - __AlgebraicTypeValue.String - ), - }, - { name: 'online', algebraicType: __AlgebraicTypeValue.Bool } - ); - return _cached_User_type_value; - }, - - serialize(writer: __BinaryWriter, value: User): void { - __AlgebraicTypeValue.serializeValue( - writer, - User.getTypeScriptAlgebraicType(), - value - ); - }, - - deserialize(reader: __BinaryReader): User { - return __AlgebraicTypeValue.deserializeValue( - reader, - User.getTypeScriptAlgebraicType() - ); - }, -}; - -export default User; +export default __t.object('User', { + identity: __t.identity(), + name: __t.option(__t.string()), + online: __t.bool(), +});