From 5effb476ee2c339e218191f3deb72d4d8c1a76d3 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Sat, 24 Oct 2026 13:50:44 +0530 Subject: [PATCH 01/11] Resolve self-referential outbox signatures from the local module --- Cargo.lock | 1 + crates/bindings-macro/src/reducer.rs | 74 ++++++++++++++++++- crates/bindings-macro/src/table.rs | 37 ++++++++-- crates/bindings/Cargo.toml | 5 ++ crates/bindings/src/rt.rs | 68 ++++++++++++++--- crates/bindings/src/table.rs | 3 +- crates/bindings/tests/local_outbox.rs | 48 ++++++++++++ .../local_outbox_ui/wrong_argument_type.rs | 17 +++++ .../wrong_argument_type.stderr | 16 ++++ .../bindings/tests/pass/outbox_arg_columns.rs | 2 +- crates/bindings/tests/pass/outbox_local.rs | 23 ++++++ crates/bindings/tests/ui.rs | 6 ++ 12 files changed, 281 insertions(+), 19 deletions(-) create mode 100644 crates/bindings/tests/local_outbox.rs create mode 100644 crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs create mode 100644 crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr create mode 100644 crates/bindings/tests/pass/outbox_local.rs diff --git a/Cargo.lock b/Cargo.lock index 6fd6f4051fb..0c05e35e04f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8257,6 +8257,7 @@ dependencies = [ "spacetimedb-lib", "spacetimedb-primitives", "spacetimedb-query-builder", + "spacetimedb-schema", "spacetimedb-test-datastore", "trybuild", ] diff --git a/crates/bindings-macro/src/reducer.rs b/crates/bindings-macro/src/reducer.rs index 159e5acbfaf..14da8fab8f4 100644 --- a/crates/bindings-macro/src/reducer.rs +++ b/crates/bindings-macro/src/reducer.rs @@ -1,7 +1,8 @@ use crate::sym; use crate::util::{check_duplicate, check_duplicate_msg, ident_to_litstr, match_meta, native_test_utils_registration}; use proc_macro2::{Span, TokenStream}; -use quote::{quote, quote_spanned}; +use quote::{format_ident, quote, quote_spanned}; +use syn::ext::IdentExt; use syn::parse::Parser as _; use syn::spanned::Spanned; use syn::{FnArg, Ident, ItemFn, LitStr, PatType}; @@ -127,6 +128,7 @@ pub(crate) fn reducer_impl(args: ReducerArgs, original_function: &ItemFn) -> syn let explicit_name = args.name.as_ref(); let generate_explicit_names = generate_explicit_names_impl(&reducer_name.value(), func_name, explicit_name); + let outbox_typecheck = generate_local_outbox_typecheck(func_name, &typed_args); // Extract all function parameter names. let opt_arg_names = typed_args.iter().map(|arg| { @@ -197,9 +199,79 @@ pub(crate) fn reducer_impl(args: ReducerArgs, original_function: &ItemFn) -> syn } #generate_explicit_names + #outbox_typecheck }) } +fn generate_local_outbox_typecheck(func_name: &Ident, args: &[&PatType]) -> TokenStream { + let macro_name = format_ident!("__spacetimedb_typecheck_outbox_{}", func_name.unraw()); + let mut helpers = Vec::new(); + let mut checks = Vec::new(); + for arg in args.iter().skip(1) { + let syn::Pat::Ident(pattern) = arg.pat.as_ref() else { + checks.push(quote!(compile_error!( + "local outbox reducer parameters must have names" + ))); + continue; + }; + let param = pattern.ident.unraw(); + let ty = &arg.ty; + let lookup = format_ident!("{}_{}", macro_name, param); + let reject_duplicate = format_ident!("{}_reject_duplicate", lookup); + helpers.push(quote! { + #[doc(hidden)] + macro_rules! #reject_duplicate { + ($module:ident;) => {}; + ($module:ident; ($index:literal, $field:ident : $column_ty:ty as #param), $($rest:tt)*) => { + compile_error!(concat!("outbox has multiple columns matching reducer parameter `", stringify!(#param), "`")); + }; + ($module:ident; ($index:literal, $field:ident : $column_ty:ty as $other:ident), $($rest:tt)*) => { + $module::#reject_duplicate!($module; $($rest)*); + }; + } + #[doc(hidden)] + #[allow(unused_imports)] + pub(crate) use #reject_duplicate; + + #[doc(hidden)] + macro_rules! #lookup { + ($module:ident;) => {{ + compile_error!(concat!("outbox has no column matching reducer parameter `", stringify!(#param), "`")); + 0u16 + }}; + ($module:ident; ($index:literal, $field:ident : $column_ty:ty as #param), $($rest:tt)*) => {{ + #[allow(unused_imports)] + use $module::*; + let _ = |x: $column_ty| { let _: #ty = x; }; + $module::#reject_duplicate!($module; $($rest)*); + $index + }}; + ($module:ident; ($index:literal, $field:ident : $column_ty:ty as $other:ident), $($rest:tt)*) => { + $module::#lookup!($module; $($rest)*) + }; + } + #[doc(hidden)] + #[allow(unused_imports)] + pub(crate) use #lookup; + }); + checks.push(quote!(__outbox_receiver::#lookup!(__outbox_receiver; $($columns)*))); + } + quote! { + #(#helpers)* + #[doc(hidden)] + macro_rules! #macro_name { + ($module:path, { $($columns:tt)* }) => {{ + #[allow(unused_imports)] + use $module as __outbox_receiver; + &[#(#checks),*] + }}; + } + #[doc(hidden)] + #[allow(unused_imports)] + pub(crate) use #macro_name; + } +} + pub(crate) fn generate_explicit_names_impl( func_name: &str, func_handle: &Ident, diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index 88f5348b435..b6d20a6a8b1 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -51,6 +51,7 @@ struct ScheduledArg { struct OutboxArg { receiver_reducer: Path, + local: bool, } struct IndexArg { @@ -225,8 +226,15 @@ If you're migrating from SpacetimeDB 1.*, replace `name = {name_str_value:?}` wi impl OutboxArg { fn parse_meta(meta: ParseNestedMeta) -> syn::Result { let mut receiver_reducer = None; + let mut local = false; meta.parse_nested_meta(|meta| { + if meta.path.is_ident("local") { + check_duplicate_msg(&receiver_reducer, &meta, "can only specify one outbox receiver reducer")?; + receiver_reducer = Some(meta.value()?.parse()?); + local = true; + return Ok(()); + } check_duplicate_msg(&receiver_reducer, &meta, "can only specify one outbox receiver reducer")?; receiver_reducer = Some(meta.path); Ok(()) @@ -234,7 +242,10 @@ impl OutboxArg { let receiver_reducer = receiver_reducer .ok_or_else(|| meta.error("must specify outbox receiver reducer: outbox(receiver::reducer)"))?; - Ok(Self { receiver_reducer }) + Ok(Self { + receiver_reducer, + local, + }) } } @@ -1302,8 +1313,13 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R "outbox receiver reducer must be qualified, e.g. `outbox(receiver::reducer)`", )); } - let mut receiver_identity = receiver_module.clone(); - receiver_identity.segments.push(parse_quote!(Identity)); + let receiver_identity: Path = if outbox.local { + parse_quote!(spacetimedb::Identity) + } else { + let mut identity = receiver_module.clone(); + identity.segments.push(parse_quote!(Identity)); + identity + }; let mut receiver_outbox_typecheck = receiver_module.clone(); let reducer_ident = receiver_reducer .segments @@ -1344,12 +1360,23 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R (Some(outbox), Some((target_column, _))) => { let receiver_reducer = &outbox.receiver_reducer; let target_col = target_column.index; + let (remote_name, signature_hash) = if outbox.local { + ( + quote!(<#receiver_reducer as spacetimedb::rt::FnInfo>::NAME), + quote!(None), + ) + } else { + ( + quote!(<#receiver_reducer as spacetimedb::rt::RemoteReducer>::NAME), + quote!(Some(<#receiver_reducer as spacetimedb::rt::RemoteReducer>::SIGNATURE_HASH)), + ) + }; quote! { const OUTBOX: Option> = Some(spacetimedb::table::OutboxDesc { - remote_reducer_name: <#receiver_reducer as spacetimedb::rt::RemoteReducer>::NAME, + remote_reducer_name: #remote_name, arg_columns: #outbox_arg_columns, target_column: #target_col, - signature_hash: <#receiver_reducer as spacetimedb::rt::RemoteReducer>::SIGNATURE_HASH, + signature_hash: #signature_hash, }); } } diff --git a/crates/bindings/Cargo.toml b/crates/bindings/Cargo.toml index 6aeead3fb80..17f2a73743f 100644 --- a/crates/bindings/Cargo.toml +++ b/crates/bindings/Cargo.toml @@ -26,6 +26,7 @@ spacetimedb-lib.workspace = true spacetimedb-bindings-macro.workspace = true spacetimedb-primitives.workspace = true spacetimedb-query-builder.workspace = true +spacetimedb-schema.workspace = true anyhow.workspace = true bytemuck.workspace = true @@ -53,5 +54,9 @@ spacetimedb-lib = { path = "../lib", features = ["test"] } name = "test_utils" required-features = ["test-utils"] +[[test]] +name = "local_outbox" +required-features = ["test-utils"] + [lints] workspace = true diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 0d6073ee9f7..f61d3fbe2fc 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -6,7 +6,7 @@ use crate::{sys, AnonymousViewContext, IterBuf, ReducerContext, ReducerResult, S use spacetimedb_lib::bsatn::EncodeError; use spacetimedb_lib::db::raw_def::v10::{ CaseConversionPolicy, ExplicitNames as RawExplicitNames, RawEnvVarTypeV10, RawEnvironmentDeclarationV10, - RawModuleDefV10Builder, + RawModuleDefV10, RawModuleDefV10Builder, RawModuleDefV10Section, }; pub use spacetimedb_lib::db::raw_def::v9::Lifecycle as LifecycleReducer; use spacetimedb_lib::db::raw_def::v9::{RawIndexAlgorithm, TableType, ViewResultHeader}; @@ -859,14 +859,19 @@ pub fn register_table() { table.finish(); if let Some(outbox) = T::OUTBOX { + let signature_hash = if let Some(hash) = outbox.signature_hash { + spacetimedb_lib::Hash::from_hex(hash).expect("generated outbox signature hash must be valid hex") + } else { + module.local_outboxes.push((T::TABLE_NAME, outbox.remote_reducer_name)); + spacetimedb_lib::Hash::ZERO + }; module.inner.add_outbox( T::TABLE_NAME, outbox.remote_reducer_name, outbox.target_column, outbox.arg_columns.iter().copied().map(Into::into), None::<&str>, - spacetimedb_lib::Hash::from_hex(outbox.signature_hash) - .expect("generated outbox signature hash must be valid hex"), + signature_hash, ); } @@ -1182,11 +1187,57 @@ pub struct ModuleBuilder { /// The anonymous views of the module. views_anon: Vec, on_result_reducers: Vec<(&'static str, &'static str)>, + local_outboxes: Vec<(&'static str, &'static str)>, } // Not actually a mutex; because WASM is single-threaded this basically just turns into a refcell. static DESCRIBERS: Mutex>> = Mutex::new(Vec::new()); +impl ModuleBuilder { + fn finish_definition(&mut self) -> RawModuleDefV10 { + for (outbox_table, reducer) in self.on_result_reducers.drain(..) { + self.inner.set_outbox_on_result(outbox_table, reducer); + } + + let mut raw = std::mem::take(&mut self.inner).finish(); + if self.local_outboxes.is_empty() { + return raw; + } + + // A local reducer's signature is only known after names and types have been + // canonicalized. The temporary zero hashes are replaced before serialization. + let validated = spacetimedb_schema::def::ModuleDef::try_from(RawModuleDef::V10(raw.clone())) + .expect("unable to validate module with local outboxes"); + for &(table_name, reducer_source_name) in &self.local_outboxes { + let reducer = validated + .reducers() + .find(|reducer| reducer.accessor_name.as_ref() == reducer_source_name) + .unwrap_or_else(|| { + panic!("local outbox `{table_name}` references missing reducer `{reducer_source_name}`") + }); + let signature_hash = spacetimedb_schema::def::reducer_signature_hash( + &reducer.params(), + &reducer.ok_return_type, + &reducer.err_return_type, + validated.typespace(), + ); + let outbox = raw + .sections + .iter_mut() + .find_map(|section| match section { + RawModuleDefV10Section::Outboxes(outboxes) => outboxes + .iter_mut() + .find(|outbox| outbox.table_source_name.as_ref() == table_name), + _ => None, + }) + .expect("registered local outbox is missing from module definition"); + outbox.remote_reducer = reducer.name.clone().into(); + outbox.signature_hash = signature_hash; + } + raw + } +} + /// A reducer function takes in `(ReducerContext, Args)` /// and returns a result with a possible error message. pub type ReducerFn = fn(&ReducerContext, &[u8]) -> ReducerResult; @@ -1211,7 +1262,7 @@ static ANONYMOUS_VIEWS: OnceLock> = OnceLock::new(); #[cfg(feature = "test-utils")] #[doc(hidden)] pub fn module_def_for_tests() -> RawModuleDef { - RawModuleDef::V10(describe_module().inner.finish()) + RawModuleDef::V10(describe_module().finish_definition()) } fn describe_module() -> ModuleBuilder { @@ -1219,11 +1270,6 @@ fn describe_module() -> ModuleBuilder { for describer in &mut *DESCRIBERS.lock().unwrap() { describer(&mut module) } - - // Tables and reducers can register in either order, so link callbacks last. - for (outbox_table, reducer) in module.on_result_reducers.drain(..) { - module.inner.set_outbox_on_result(outbox_table, reducer); - } module } @@ -1244,10 +1290,10 @@ fn describe_module() -> ModuleBuilder { /// After initialization, the module cannot alter the schema. #[unsafe(no_mangle)] extern "C" fn __describe_module__(description: BytesSink) { - let module = describe_module(); + let mut module = describe_module(); // Serialize the module to bsatn. - let module_def = module.inner.finish(); + let module_def = module.finish_definition(); let module_def = RawModuleDef::V10(module_def); let bytes = bsatn::to_vec(&module_def).expect("unable to serialize typespace"); diff --git a/crates/bindings/src/table.rs b/crates/bindings/src/table.rs index ef9f516031a..8ce6dad8faa 100644 --- a/crates/bindings/src/table.rs +++ b/crates/bindings/src/table.rs @@ -554,7 +554,8 @@ pub struct OutboxDesc<'a> { /// Outbox column positions in remote reducer parameter order. pub arg_columns: &'a [u16], pub target_column: u16, - pub signature_hash: &'a str, + /// Generated bindings provide a hash; local reducers are resolved after module validation. + pub signature_hash: Option<&'a str>, } pub struct ScheduleDesc<'a> { diff --git a/crates/bindings/tests/local_outbox.rs b/crates/bindings/tests/local_outbox.rs new file mode 100644 index 00000000000..f71c784b711 --- /dev/null +++ b/crates/bindings/tests/local_outbox.rs @@ -0,0 +1,48 @@ +#![allow(non_snake_case)] + +use spacetimedb::spacetimedb_lib::RawModuleDef; + +#[spacetimedb::settings] +const CASE_CONVERSION_POLICY: spacetimedb::CaseConversionPolicy = spacetimedb::CaseConversionPolicy::None; + +#[spacetimedb::reducer] +pub fn receivePing(_: &spacetimedb::ReducerContext, messageBody: String) { + let _ = messageBody; +} + +#[spacetimedb::table(accessor = outboundPing, outbox(local = crate::receivePing))] +pub struct OutboundPing { + #[primary_key] + #[auto_inc] + id: u64, + #[target] + target: spacetimedb::Identity, + #[param(name = messageBody)] + payload: String, +} + +#[test] +fn local_outbox_hash_uses_the_canonical_reducer_signature() { + let RawModuleDef::V10(raw) = spacetimedb::test_utils::module_def() else { + panic!("expected V10 module definition"); + }; + assert_eq!(raw.case_conversion_policy(), spacetimedb::CaseConversionPolicy::None); + let outbox = &raw.outboxes().unwrap()[0]; + assert_eq!(outbox.remote_reducer.as_ref(), "receivePing"); + assert_eq!(outbox.arg_columns.len(), 1); + let actual_hash = outbox.signature_hash; + + let module = spacetimedb_schema::def::ModuleDef::try_from(RawModuleDef::V10(raw)).unwrap(); + let reducer = module.reducer_by_name("receivePing").unwrap().1; + assert_eq!( + reducer.params().elements[0].name.as_ref().unwrap().as_ref(), + "messageBody" + ); + let expected_hash = spacetimedb_schema::def::reducer_signature_hash( + &reducer.params(), + &reducer.ok_return_type, + &reducer.err_return_type, + module.typespace(), + ); + assert_eq!(actual_hash, expected_hash); +} diff --git a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs new file mode 100644 index 00000000000..574163639b6 --- /dev/null +++ b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs @@ -0,0 +1,17 @@ +#[spacetimedb::reducer] +pub fn receive_ping(_: &spacetimedb::ReducerContext, body: String) { + let _ = body; +} + +#[spacetimedb::table(accessor = wrong_argument_type, outbox(local = crate::receive_ping))] +pub struct WrongArgumentType { + #[primary_key] + #[auto_inc] + id: u64, + #[target] + target: spacetimedb::Identity, + #[param(name = body)] + payload: u64, +} + +fn main() {} diff --git a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr new file mode 100644 index 00000000000..6bf4aa66522 --- /dev/null +++ b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> tests/local_outbox_ui/wrong_argument_type.rs:1:1 + | +1 | #[spacetimedb::reducer] + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `u64` +2 | pub fn receive_ping(_: &spacetimedb::ReducerContext, body: String) { + | ------ expected due to this +... +6 | #[spacetimedb::table(accessor = wrong_argument_type, outbox(local = crate::receive_ping))] + | ------------------------------------------------------------------------------------------ in this attribute macro expansion + | + = note: this error originates in the macro `__outbox_receiver::__spacetimedb_typecheck_outbox_receive_ping_body` which comes from the expansion of the attribute macro `spacetimedb::table` (in Nightly builds, run with -Z macro-backtrace for more info) +help: try using a conversion method + | +1 | #[spacetimedb::reducer].to_string() + | ++++++++++++ diff --git a/crates/bindings/tests/pass/outbox_arg_columns.rs b/crates/bindings/tests/pass/outbox_arg_columns.rs index b899db39374..b3a958b22f9 100644 --- a/crates/bindings/tests/pass/outbox_arg_columns.rs +++ b/crates/bindings/tests/pass/outbox_arg_columns.rs @@ -76,7 +76,7 @@ fn main() { assert!(named_noop_outbox__TableHandle::OUTBOX.unwrap().arg_columns.is_empty()); assert_eq!( named_noop_outbox__TableHandle::OUTBOX.unwrap().signature_hash, - ::SIGNATURE_HASH + Some(::SIGNATURE_HASH) ); } diff --git a/crates/bindings/tests/pass/outbox_local.rs b/crates/bindings/tests/pass/outbox_local.rs new file mode 100644 index 00000000000..755c63cf22a --- /dev/null +++ b/crates/bindings/tests/pass/outbox_local.rs @@ -0,0 +1,23 @@ +#![allow(non_snake_case)] + +#[spacetimedb::settings] +const CASE_CONVERSION_POLICY: spacetimedb::CaseConversionPolicy = spacetimedb::CaseConversionPolicy::None; + +#[spacetimedb::reducer] +pub fn receivePing(_: &spacetimedb::ReducerContext, messageBody: String) {} + +#[spacetimedb::table(accessor = outboundPing, outbox(local = crate::receivePing))] +pub struct OutboundPing { + #[primary_key] + #[auto_inc] + id: u64, + #[target] + target: spacetimedb::Identity, + #[param(name = messageBody)] + payload: String, +} + +fn main() { + use spacetimedb::table::TableInternal; + assert_eq!(outboundPing__TableHandle::OUTBOX.unwrap().arg_columns, &[2]); +} diff --git a/crates/bindings/tests/ui.rs b/crates/bindings/tests/ui.rs index c13cfdfaeb2..674fffef3d5 100644 --- a/crates/bindings/tests/ui.rs +++ b/crates/bindings/tests/ui.rs @@ -4,3 +4,9 @@ fn ui() { t.compile_fail("tests/ui/*.rs"); t.pass("tests/pass/*.rs"); } + +#[test] +fn local_outbox_typecheck() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/local_outbox_ui/*.rs"); +} From d65d53db842a3183a6de65505991664b378c503e Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Sat, 24 Oct 2026 13:52:21 +0530 Subject: [PATCH 02/11] Test self-referential IDC delivery with no case conversion --- .../modules/idc-self-outbox/Cargo.toml | 11 ++++ .../modules/idc-self-outbox/src/lib.rs | 42 +++++++++++++ crates/smoketests/tests/cluster/idc.rs | 59 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 crates/smoketests/modules/idc-self-outbox/Cargo.toml create mode 100644 crates/smoketests/modules/idc-self-outbox/src/lib.rs diff --git a/crates/smoketests/modules/idc-self-outbox/Cargo.toml b/crates/smoketests/modules/idc-self-outbox/Cargo.toml new file mode 100644 index 00000000000..64585f10350 --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "smoketest-module-idc-self-outbox" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +spacetimedb.workspace = true diff --git a/crates/smoketests/modules/idc-self-outbox/src/lib.rs b/crates/smoketests/modules/idc-self-outbox/src/lib.rs new file mode 100644 index 00000000000..9b6983c3983 --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox/src/lib.rs @@ -0,0 +1,42 @@ +#![allow(non_snake_case)] + +use spacetimedb::Table; + +#[spacetimedb::settings] +const CASE_CONVERSION_POLICY: spacetimedb::CaseConversionPolicy = spacetimedb::CaseConversionPolicy::None; + +#[spacetimedb::table(accessor = delivered_ping, name = "delivered_ping")] +pub struct DeliveredPing { + #[primary_key] + #[auto_inc] + id: u64, + body: String, +} + +#[spacetimedb::reducer] +pub fn receivePing(ctx: &spacetimedb::ReducerContext, messageBody: String) { + ctx.db.delivered_ping().insert(DeliveredPing { + id: 0, + body: messageBody, + }); +} + +#[spacetimedb::table(accessor = outboundPing, name = "outbound_ping", outbox(local = crate::receivePing))] +pub struct OutboundPing { + #[primary_key] + #[auto_inc] + id: u64, + #[target] + target: spacetimedb::Identity, + #[param(name = messageBody)] + payload: String, +} + +#[spacetimedb::reducer] +pub fn enqueuePing(ctx: &spacetimedb::ReducerContext, target: spacetimedb::Identity, messageBody: String) { + ctx.db.outboundPing().insert(OutboundPing { + id: 0, + target, + payload: messageBody, + }); +} diff --git a/crates/smoketests/tests/cluster/idc.rs b/crates/smoketests/tests/cluster/idc.rs index 3b52cb12129..7e4ebe664d6 100644 --- a/crates/smoketests/tests/cluster/idc.rs +++ b/crates/smoketests/tests/cluster/idc.rs @@ -435,6 +435,65 @@ fn idc_outbox_uses_regenerated_bindings_after_argument_reordering() { suite.send_detailed_ping("after-update"); } +#[test] +fn idc_self_outbox_uses_none_case_policy() { + let mut test = Smoketest::builder().autopublish(false).build(); + let database = format!("idc-self-{}", random_string()); + let module_dir = test.project_dir.path().join("self_outbox"); + copy_module_fixture("idc-self-outbox", &module_dir).expect("failed to copy self-outbox fixture"); + patch_module_cargo_to_local_bindings(&module_dir).expect("failed to patch module Cargo.toml"); + + let output = test + .spacetime(&[ + "publish", + "--no-config", + "--server", + &test.server_url, + "--module-path", + module_dir.to_str().unwrap(), + "--yes=all", + &database, + ]) + .expect("failed to publish self-outbox module"); + let identity = parse_identity_from_publish_output(&output).expect("publish output should contain an identity"); + test.database_identity = Some(identity.clone()); + test.call( + "enqueuePing", + &[&serde_json::to_string(&identity).unwrap(), "\"self-message\""], + ) + .expect("failed to enqueue self-referential message"); + + let rows = |sql: &str| { + let output = test + .spacetime(&[ + "sql", + "--no-config", + "--server", + &test.server_url, + "--format", + "json", + &database, + sql, + ]) + .expect("failed to query self-outbox module"); + let result: serde_json::Value = serde_json::from_str(&output).expect("invalid SQL JSON output"); + result[0]["rows"].as_array().unwrap().clone() + }; + let deadline = Instant::now() + Duration::from_secs(20); + loop { + let delivered = rows("SELECT body FROM delivered_ping"); + let pending = rows("SELECT id FROM outbound_ping"); + if delivered == vec![serde_json::json!(["self-message"])] && pending.is_empty() { + break; + } + assert!( + Instant::now() < deadline, + "self IDC did not finish: delivered={delivered:?}, pending={pending:?}" + ); + std::thread::sleep(Duration::from_millis(100)); + } +} + #[test] fn idc_generated_receiver_types_are_scoped_by_dependency() { // The world outbox uses the Rust shortcut; the auth outbox uses a manual table. From 773bfb9f3ddd9fb02badacae5b35f1f93c689ac1 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Mon, 26 Oct 2026 01:20:22 +0530 Subject: [PATCH 03/11] Use receiver handle metadata for local and generated outboxes --- crates/bindings-macro/src/reducer.rs | 6 ++++ crates/bindings-macro/src/table.rs | 36 +++---------------- crates/bindings/src/rt.rs | 23 +++++++++++- .../tests/fixtures/idc_receiver/mod.rs | 2 ++ crates/bindings/tests/local_outbox.rs | 2 +- .../local_outbox_ui/wrong_argument_type.rs | 2 +- .../wrong_argument_type.stderr | 4 +-- crates/bindings/tests/pass/outbox_local.rs | 20 ++++++++++- crates/bindings/tests/ui/views.stderr | 3 +- crates/codegen/src/rust.rs | 1 + ...codegen__codegen_rust_module_bindings.snap | 14 ++++++++ ...shadowing__receiver_type_declarations.snap | 6 ++++ .../modules/idc-self-outbox/src/lib.rs | 2 +- 13 files changed, 81 insertions(+), 40 deletions(-) diff --git a/crates/bindings-macro/src/reducer.rs b/crates/bindings-macro/src/reducer.rs index 14da8fab8f4..93ccbcf6ca6 100644 --- a/crates/bindings-macro/src/reducer.rs +++ b/crates/bindings-macro/src/reducer.rs @@ -198,6 +198,12 @@ pub(crate) fn reducer_impl(args: ReducerArgs, original_function: &ItemFn) -> syn const INVOKE: Self::Invoke = #func_name::invoke; } + impl spacetimedb::rt::OutboxReceiver for #func_name { + type Identity = spacetimedb::Identity; + const NAME: &'static str = ::NAME; + const SIGNATURE_HASH: Option<&'static str> = None; + } + #generate_explicit_names #outbox_typecheck }) diff --git a/crates/bindings-macro/src/table.rs b/crates/bindings-macro/src/table.rs index b6d20a6a8b1..d70441711a0 100644 --- a/crates/bindings-macro/src/table.rs +++ b/crates/bindings-macro/src/table.rs @@ -51,7 +51,6 @@ struct ScheduledArg { struct OutboxArg { receiver_reducer: Path, - local: bool, } struct IndexArg { @@ -226,15 +225,8 @@ If you're migrating from SpacetimeDB 1.*, replace `name = {name_str_value:?}` wi impl OutboxArg { fn parse_meta(meta: ParseNestedMeta) -> syn::Result { let mut receiver_reducer = None; - let mut local = false; meta.parse_nested_meta(|meta| { - if meta.path.is_ident("local") { - check_duplicate_msg(&receiver_reducer, &meta, "can only specify one outbox receiver reducer")?; - receiver_reducer = Some(meta.value()?.parse()?); - local = true; - return Ok(()); - } check_duplicate_msg(&receiver_reducer, &meta, "can only specify one outbox receiver reducer")?; receiver_reducer = Some(meta.path); Ok(()) @@ -242,10 +234,7 @@ impl OutboxArg { let receiver_reducer = receiver_reducer .ok_or_else(|| meta.error("must specify outbox receiver reducer: outbox(receiver::reducer)"))?; - Ok(Self { - receiver_reducer, - local, - }) + Ok(Self { receiver_reducer }) } } @@ -1313,13 +1302,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R "outbox receiver reducer must be qualified, e.g. `outbox(receiver::reducer)`", )); } - let receiver_identity: Path = if outbox.local { - parse_quote!(spacetimedb::Identity) - } else { - let mut identity = receiver_module.clone(); - identity.segments.push(parse_quote!(Identity)); - identity - }; + let receiver_identity = quote!(<#receiver_reducer as spacetimedb::rt::OutboxReceiver>::Identity); let mut receiver_outbox_typecheck = receiver_module.clone(); let reducer_ident = receiver_reducer .segments @@ -1360,23 +1343,12 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R (Some(outbox), Some((target_column, _))) => { let receiver_reducer = &outbox.receiver_reducer; let target_col = target_column.index; - let (remote_name, signature_hash) = if outbox.local { - ( - quote!(<#receiver_reducer as spacetimedb::rt::FnInfo>::NAME), - quote!(None), - ) - } else { - ( - quote!(<#receiver_reducer as spacetimedb::rt::RemoteReducer>::NAME), - quote!(Some(<#receiver_reducer as spacetimedb::rt::RemoteReducer>::SIGNATURE_HASH)), - ) - }; quote! { const OUTBOX: Option> = Some(spacetimedb::table::OutboxDesc { - remote_reducer_name: #remote_name, + remote_reducer_name: <#receiver_reducer as spacetimedb::rt::OutboxReceiver>::NAME, arg_columns: #outbox_arg_columns, target_column: #target_col, - signature_hash: #signature_hash, + signature_hash: <#receiver_reducer as spacetimedb::rt::OutboxReceiver>::SIGNATURE_HASH, }); } } diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index f61d3fbe2fc..4587ebbdc87 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -189,6 +189,9 @@ pub trait FnInfo: ExplicitNames { /// therefore has no invocation function. It is used by module-side macros to /// typecheck calls into another database. pub trait RemoteReducer { + /// The destination identity type provided by the receiver bindings. + type Identity; + /// The reducer name in the remote module schema. const NAME: &'static str; @@ -202,6 +205,24 @@ pub trait RemoteReducer { type Args; } +/// Metadata used by outboxes targeting generated or source-defined reducer handles. +pub trait OutboxReceiver { + /// The destination identity type accepted by this receiver. + type Identity; + + /// The registered reducer name, or its source name when resolved locally. + const NAME: &'static str; + + /// A precomputed signature, or `None` to resolve it from the local module schema. + const SIGNATURE_HASH: Option<&'static str>; +} + +impl OutboxReceiver for T { + type Identity = T::Identity; + const NAME: &'static str = T::NAME; + const SIGNATURE_HASH: Option<&'static str> = Some(T::SIGNATURE_HASH); +} + pub trait Procedure<'de, A: Args<'de>, Ret: IntoProcedureResult> { fn invoke(&self, ctx: &mut ProcedureContext, args: A) -> Ret; } @@ -1227,7 +1248,7 @@ impl ModuleBuilder { .find_map(|section| match section { RawModuleDefV10Section::Outboxes(outboxes) => outboxes .iter_mut() - .find(|outbox| outbox.table_source_name.as_ref() == table_name), + .find(|outbox| outbox.table_name.as_ref() == table_name), _ => None, }) .expect("registered local outbox is missing from module definition"); diff --git a/crates/bindings/tests/fixtures/idc_receiver/mod.rs b/crates/bindings/tests/fixtures/idc_receiver/mod.rs index 0abe81e5639..70437d3f255 100644 --- a/crates/bindings/tests/fixtures/idc_receiver/mod.rs +++ b/crates/bindings/tests/fixtures/idc_receiver/mod.rs @@ -96,6 +96,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_receive_ping; pub struct receive_ping; impl spacetimedb::rt::RemoteReducer for receive_ping { + type Identity = Identity; const NAME: &'static str = "wire_ping"; const SIGNATURE_HASH: &'static str = "386957a94632958d5ae8343e258f3a6f9dce9d7dafc46831050894baa7a4e4e1"; type Args = ReceivePingArgs; @@ -121,6 +122,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_noop; pub struct noop; impl spacetimedb::rt::RemoteReducer for noop { + type Identity = Identity; const NAME: &'static str = "noop"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = NoopArgs; diff --git a/crates/bindings/tests/local_outbox.rs b/crates/bindings/tests/local_outbox.rs index f71c784b711..9a3e53f50e0 100644 --- a/crates/bindings/tests/local_outbox.rs +++ b/crates/bindings/tests/local_outbox.rs @@ -10,7 +10,7 @@ pub fn receivePing(_: &spacetimedb::ReducerContext, messageBody: String) { let _ = messageBody; } -#[spacetimedb::table(accessor = outboundPing, outbox(local = crate::receivePing))] +#[spacetimedb::table(accessor = outboundPing, outbox(crate::receivePing))] pub struct OutboundPing { #[primary_key] #[auto_inc] diff --git a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs index 574163639b6..dc7db048c66 100644 --- a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs +++ b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.rs @@ -3,7 +3,7 @@ pub fn receive_ping(_: &spacetimedb::ReducerContext, body: String) { let _ = body; } -#[spacetimedb::table(accessor = wrong_argument_type, outbox(local = crate::receive_ping))] +#[spacetimedb::table(accessor = wrong_argument_type, outbox(crate::receive_ping))] pub struct WrongArgumentType { #[primary_key] #[auto_inc] diff --git a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr index 6bf4aa66522..5c7364fa7a8 100644 --- a/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr +++ b/crates/bindings/tests/local_outbox_ui/wrong_argument_type.stderr @@ -6,8 +6,8 @@ error[E0308]: mismatched types 2 | pub fn receive_ping(_: &spacetimedb::ReducerContext, body: String) { | ------ expected due to this ... -6 | #[spacetimedb::table(accessor = wrong_argument_type, outbox(local = crate::receive_ping))] - | ------------------------------------------------------------------------------------------ in this attribute macro expansion +6 | #[spacetimedb::table(accessor = wrong_argument_type, outbox(crate::receive_ping))] + | ---------------------------------------------------------------------------------- in this attribute macro expansion | = note: this error originates in the macro `__outbox_receiver::__spacetimedb_typecheck_outbox_receive_ping_body` which comes from the expansion of the attribute macro `spacetimedb::table` (in Nightly builds, run with -Z macro-backtrace for more info) help: try using a conversion method diff --git a/crates/bindings/tests/pass/outbox_local.rs b/crates/bindings/tests/pass/outbox_local.rs index 755c63cf22a..28ddd575f3e 100644 --- a/crates/bindings/tests/pass/outbox_local.rs +++ b/crates/bindings/tests/pass/outbox_local.rs @@ -6,7 +6,7 @@ const CASE_CONVERSION_POLICY: spacetimedb::CaseConversionPolicy = spacetimedb::C #[spacetimedb::reducer] pub fn receivePing(_: &spacetimedb::ReducerContext, messageBody: String) {} -#[spacetimedb::table(accessor = outboundPing, outbox(local = crate::receivePing))] +#[spacetimedb::table(accessor = outboundPing, outbox(self::receivePing))] pub struct OutboundPing { #[primary_key] #[auto_inc] @@ -17,7 +17,25 @@ pub struct OutboundPing { payload: String, } +mod nested { + #[spacetimedb::table(accessor = outbound_nested, outbox(super::receivePing))] + pub struct OutboundNested { + #[primary_key] + #[auto_inc] + id: u64, + #[target] + target: spacetimedb::Identity, + #[param(name = messageBody)] + payload: String, + } +} + fn main() { use spacetimedb::table::TableInternal; assert_eq!(outboundPing__TableHandle::OUTBOX.unwrap().arg_columns, &[2]); + assert_eq!( + nested::outbound_nested__TableHandle::OUTBOX.unwrap().arg_columns, + &[2] + ); + assert_eq!(::SIGNATURE_HASH, None); } diff --git a/crates/bindings/tests/ui/views.stderr b/crates/bindings/tests/ui/views.stderr index 6282d2e00f5..f0813856d87 100644 --- a/crates/bindings/tests/ui/views.stderr +++ b/crates/bindings/tests/ui/views.stderr @@ -84,7 +84,8 @@ error[E0599]: no method named `iter` found for struct `test__ViewHandle` in the = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `iter`, perhaps you need to implement one of them: candidate #1: `bitflags::traits::Flags` - candidate #2: `spacetimedb::Table` + candidate #2: `petgraph::visit::traversal::Walker` + candidate #3: `spacetimedb::Table` error[E0599]: no method named `insert` found for struct `test__ViewHandle` in the current scope --> tests/ui/views.rs:24:25 diff --git a/crates/codegen/src/rust.rs b/crates/codegen/src/rust.rs index aac3c436137..c6f86d3fa7c 100644 --- a/crates/codegen/src/rust.rs +++ b/crates/codegen/src/rust.rs @@ -1550,6 +1550,7 @@ pub(crate) use {outbox_typecheck_macro}; pub struct {handle_name}; impl spacetimedb::rt::RemoteReducer for {handle_name} {{ + type Identity = Identity; const NAME: &'static str = {reducer_name}; const SIGNATURE_HASH: &'static str = {signature_hash}; type Args = {args_type}; diff --git a/crates/codegen/tests/snapshots/codegen__codegen_rust_module_bindings.snap b/crates/codegen/tests/snapshots/codegen__codegen_rust_module_bindings.snap index e68bfa5274b..a4fb5657830 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_rust_module_bindings.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_rust_module_bindings.snap @@ -159,6 +159,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_add; pub struct add; impl spacetimedb::rt::RemoteReducer for add { + type Identity = Identity; const NAME: &'static str = "add"; const SIGNATURE_HASH: &'static str = "99a35dc6bdb6cabe48f524346c1979dfe7e6259304f68fb48595ded5c0737c7f"; type Args = AddArgs; @@ -231,6 +232,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_add_player; pub struct add_player; impl spacetimedb::rt::RemoteReducer for add_player { + type Identity = Identity; const NAME: &'static str = "add_player"; const SIGNATURE_HASH: &'static str = "085a98d187205ddd5cb574208fc8f7aa6728c078ae72865f742a48751056824d"; type Args = AddPlayerArgs; @@ -303,6 +305,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_add_private; pub struct add_private; impl spacetimedb::rt::RemoteReducer for add_private { + type Identity = Identity; const NAME: &'static str = "add_private"; const SIGNATURE_HASH: &'static str = "085a98d187205ddd5cb574208fc8f7aa6728c078ae72865f742a48751056824d"; type Args = AddPrivateArgs; @@ -332,6 +335,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_assert_caller_identity_is_module_i pub struct assert_caller_identity_is_module_identity; impl spacetimedb::rt::RemoteReducer for assert_caller_identity_is_module_identity { + type Identity = Identity; const NAME: &'static str = "assert_caller_identity_is_module_identity"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = AssertCallerIdentityIsModuleIdentityArgs; @@ -404,6 +408,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_delete_player; pub struct delete_player; impl spacetimedb::rt::RemoteReducer for delete_player { + type Identity = Identity; const NAME: &'static str = "delete_player"; const SIGNATURE_HASH: &'static str = "f9843c43d6a007427a042049aa531419e42c5895ecfe92bf30bbd6f7389e9cb0"; type Args = DeletePlayerArgs; @@ -476,6 +481,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_delete_players_by_name; pub struct delete_players_by_name; impl spacetimedb::rt::RemoteReducer for delete_players_by_name { + type Identity = Identity; const NAME: &'static str = "delete_players_by_name"; const SIGNATURE_HASH: &'static str = "085a98d187205ddd5cb574208fc8f7aa6728c078ae72865f742a48751056824d"; type Args = DeletePlayersByNameArgs; @@ -592,6 +598,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_enqueue_idc; pub struct enqueue_idc; impl spacetimedb::rt::RemoteReducer for enqueue_idc { + type Identity = Identity; const NAME: &'static str = "enqueue_idc"; const SIGNATURE_HASH: &'static str = "4e5dd81c7af32db9b684ab7d5f7d5a5480ec3c22fdc091bfbc813e615cf98f4d"; type Args = EnqueueIdcArgs; @@ -708,6 +715,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_expect_environment; pub struct expect_environment; impl spacetimedb::rt::RemoteReducer for expect_environment { + type Identity = Identity; const NAME: &'static str = "expect_environment"; const SIGNATURE_HASH: &'static str = "92fae346d390625a393c5a4470e5ae4c4111b7d7323984087899d521938ab49b"; type Args = ExpectEnvironmentArgs; @@ -780,6 +788,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_list_over_age; pub struct list_over_age; impl spacetimedb::rt::RemoteReducer for list_over_age { + type Identity = Identity; const NAME: &'static str = "list_over_age"; const SIGNATURE_HASH: &'static str = "480a4dd20223acbee97594f8957ffae7757bd59f68b8e07a22b8900fb21e0cbd"; type Args = ListOverAgeArgs; @@ -809,6 +818,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_log_module_identity; pub struct log_module_identity; impl spacetimedb::rt::RemoteReducer for log_module_identity { + type Identity = Identity; const NAME: &'static str = "log_module_identity"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = LogModuleIdentityArgs; @@ -838,6 +848,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_query_private; pub struct query_private; impl spacetimedb::rt::RemoteReducer for query_private { + type Identity = Identity; const NAME: &'static str = "query_private"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = QueryPrivateArgs; @@ -867,6 +878,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_say_hello; pub struct say_hello; impl spacetimedb::rt::RemoteReducer for say_hello { + type Identity = Identity; const NAME: &'static str = "say_hello"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = SayHelloArgs; @@ -1071,6 +1083,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_test; pub struct test; impl spacetimedb::rt::RemoteReducer for test { + type Identity = Identity; const NAME: &'static str = "test"; const SIGNATURE_HASH: &'static str = "7c5f9ed84b96b24179d63afbe2e4e459cae4cb0b7076f237249d46ea295f698e"; type Args = TestArgs; @@ -1100,6 +1113,7 @@ pub(crate) use __spacetimedb_typecheck_outbox_test_btree_index_args; pub struct test_btree_index_args; impl spacetimedb::rt::RemoteReducer for test_btree_index_args { + type Identity = Identity; const NAME: &'static str = "test_btree_index_args"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = TestBtreeIndexArgsArgs; diff --git a/crates/codegen/tests/snapshots/outbox_builtin_shadowing__receiver_type_declarations.snap b/crates/codegen/tests/snapshots/outbox_builtin_shadowing__receiver_type_declarations.snap index 21ba22ad21a..591780aaea7 100644 --- a/crates/codegen/tests/snapshots/outbox_builtin_shadowing__receiver_type_declarations.snap +++ b/crates/codegen/tests/snapshots/outbox_builtin_shadowing__receiver_type_declarations.snap @@ -19,6 +19,7 @@ pub struct ReceiveArgs_ { } pub struct receive; impl spacetimedb::rt::RemoteReducer for receive { + type Identity = Identity; const NAME: &'static str = "receive"; const SIGNATURE_HASH: &'static str = "c0cb30752579ca4f11c7255a77df5f9294ed3ecdf3df710a4c41d086fb9b5ebc"; type Args = ReceiveArgs_; @@ -27,6 +28,7 @@ pub struct NoopArgs { } pub struct noop; impl spacetimedb::rt::RemoteReducer for noop { + type Identity = Identity; const NAME: &'static str = "noop"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = NoopArgs; @@ -35,6 +37,7 @@ pub struct NoopAccessorArgs { } pub struct noop_accessor; impl spacetimedb::rt::RemoteReducer for noop_accessor { + type Identity = Identity; const NAME: &'static str = "noop_accessor"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = NoopAccessorArgs; @@ -43,6 +46,7 @@ pub struct NoopNameArgs { } pub struct noop_name; impl spacetimedb::rt::RemoteReducer for noop_name { + type Identity = Identity; const NAME: &'static str = "noop_name"; const SIGNATURE_HASH: &'static str = "bc436888fd947d2bfd49ed6bddad31f0245c34fd42c85f9360fa0b477aa957fc"; type Args = NoopNameArgs; @@ -52,6 +56,7 @@ pub struct WithTargetArgs { } pub struct with_target; impl spacetimedb::rt::RemoteReducer for with_target { + type Identity = Identity; const NAME: &'static str = "with_target"; const SIGNATURE_HASH: &'static str = "4499ba5827d8178ca4effc177e66fc44ce1bb1fbd57637c69b8d855cb38a6005"; type Args = WithTargetArgs; @@ -61,6 +66,7 @@ pub struct WithMsgIdArgs { } pub struct with_msg_id; impl spacetimedb::rt::RemoteReducer for with_msg_id { + type Identity = Identity; const NAME: &'static str = "with_msg_id"; const SIGNATURE_HASH: &'static str = "1b2cd18acc204992e7e36c6605cce01df76ac351fc35007c6c3cd63ed1667144"; type Args = WithMsgIdArgs; diff --git a/crates/smoketests/modules/idc-self-outbox/src/lib.rs b/crates/smoketests/modules/idc-self-outbox/src/lib.rs index 9b6983c3983..5f7b9c97fae 100644 --- a/crates/smoketests/modules/idc-self-outbox/src/lib.rs +++ b/crates/smoketests/modules/idc-self-outbox/src/lib.rs @@ -21,7 +21,7 @@ pub fn receivePing(ctx: &spacetimedb::ReducerContext, messageBody: String) { }); } -#[spacetimedb::table(accessor = outboundPing, name = "outbound_ping", outbox(local = crate::receivePing))] +#[spacetimedb::table(accessor = outboundPing, name = "outbound_ping", outbox(crate::receivePing))] pub struct OutboundPing { #[primary_key] #[auto_inc] From a099ee4431e0f98d1b572fdde63c54302b958ead Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Mon, 26 Oct 2026 14:54:12 +0530 Subject: [PATCH 04/11] Fix formatting in local outbox compile test --- crates/bindings/tests/pass/outbox_local.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/bindings/tests/pass/outbox_local.rs b/crates/bindings/tests/pass/outbox_local.rs index 28ddd575f3e..eeafdba2d5a 100644 --- a/crates/bindings/tests/pass/outbox_local.rs +++ b/crates/bindings/tests/pass/outbox_local.rs @@ -33,9 +33,6 @@ mod nested { fn main() { use spacetimedb::table::TableInternal; assert_eq!(outboundPing__TableHandle::OUTBOX.unwrap().arg_columns, &[2]); - assert_eq!( - nested::outbound_nested__TableHandle::OUTBOX.unwrap().arg_columns, - &[2] - ); + assert_eq!(nested::outbound_nested__TableHandle::OUTBOX.unwrap().arg_columns, &[2]); assert_eq!(::SIGNATURE_HASH, None); } From b4b0775528a77097627f18422ffd84845d501e49 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Mon, 26 Oct 2026 19:09:29 +0530 Subject: [PATCH 05/11] remove schema dependency --- Cargo.lock | 1 + crates/bindings/Cargo.toml | 2 +- crates/bindings/src/rt.rs | 21 +--- crates/bindings/tests/receiver_signatures.rs | 100 ++++++++++++++++ crates/lib/Cargo.toml | 1 + crates/lib/src/db/mod.rs | 2 + crates/lib/src/db/names.rs | 47 ++++++++ crates/lib/src/db/reducer_signature.rs | 113 +++++++++++++++++++ crates/schema/src/def.rs | 76 +------------ crates/schema/src/def/validate/v10.rs | 23 +--- crates/schema/src/def/validate/v9.rs | 70 +----------- 11 files changed, 279 insertions(+), 177 deletions(-) create mode 100644 crates/bindings/tests/receiver_signatures.rs create mode 100644 crates/lib/src/db/names.rs create mode 100644 crates/lib/src/db/reducer_signature.rs diff --git a/Cargo.lock b/Cargo.lock index 0c05e35e04f..fa0f535cd67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8839,6 +8839,7 @@ version = "2.16.3" dependencies = [ "anyhow", "blake3", + "convert_case 0.6.0", "derive_more 0.99.20", "enum-map", "hex", diff --git a/crates/bindings/Cargo.toml b/crates/bindings/Cargo.toml index 17f2a73743f..abde9cdce26 100644 --- a/crates/bindings/Cargo.toml +++ b/crates/bindings/Cargo.toml @@ -26,7 +26,6 @@ spacetimedb-lib.workspace = true spacetimedb-bindings-macro.workspace = true spacetimedb-primitives.workspace = true spacetimedb-query-builder.workspace = true -spacetimedb-schema.workspace = true anyhow.workspace = true bytemuck.workspace = true @@ -46,6 +45,7 @@ spacetimedb-auth = { workspace = true, optional = true } spacetimedb-test-datastore = { workspace = true, optional = true } [dev-dependencies] +spacetimedb-schema.workspace = true insta.workspace = true trybuild.workspace = true spacetimedb-lib = { path = "../lib", features = ["test"] } diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 4587ebbdc87..7c83b619db5 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -1227,21 +1227,12 @@ impl ModuleBuilder { // A local reducer's signature is only known after names and types have been // canonicalized. The temporary zero hashes are replaced before serialization. - let validated = spacetimedb_schema::def::ModuleDef::try_from(RawModuleDef::V10(raw.clone())) - .expect("unable to validate module with local outboxes"); for &(table_name, reducer_source_name) in &self.local_outboxes { - let reducer = validated - .reducers() - .find(|reducer| reducer.accessor_name.as_ref() == reducer_source_name) - .unwrap_or_else(|| { - panic!("local outbox `{table_name}` references missing reducer `{reducer_source_name}`") - }); - let signature_hash = spacetimedb_schema::def::reducer_signature_hash( - &reducer.params(), - &reducer.ok_return_type, - &reducer.err_return_type, - validated.typespace(), - ); + let (reducer_name, signature_hash) = + spacetimedb_lib::db::reducer_signature::raw_reducer_signature(&raw, reducer_source_name) + .unwrap_or_else(|| { + panic!("local outbox `{table_name}` references missing reducer `{reducer_source_name}`") + }); let outbox = raw .sections .iter_mut() @@ -1252,7 +1243,7 @@ impl ModuleBuilder { _ => None, }) .expect("registered local outbox is missing from module definition"); - outbox.remote_reducer = reducer.name.clone().into(); + outbox.remote_reducer = reducer_name; outbox.signature_hash = signature_hash; } raw diff --git a/crates/bindings/tests/receiver_signatures.rs b/crates/bindings/tests/receiver_signatures.rs new file mode 100644 index 00000000000..4bf2b778d54 --- /dev/null +++ b/crates/bindings/tests/receiver_signatures.rs @@ -0,0 +1,100 @@ +use spacetimedb::spacetimedb_lib::db::raw_def::v10::{ + CaseConversionPolicy, ExplicitNames, RawModuleDefV10, RawModuleDefV10Builder, RawModuleDefV10Section, +}; +use spacetimedb::spacetimedb_lib::db::reducer_signature::raw_reducer_signature; +use spacetimedb::spacetimedb_lib::{bsatn, AlgebraicType, ProductType}; +use spacetimedb_schema::def::{reducer_signature_hash, ModuleDef}; + +fn receiver_module(policy: CaseConversionPolicy, explicit_name: bool, unrelated_type: bool) -> RawModuleDefV10 { + let mut builder = RawModuleDefV10Builder::new(); + builder.set_case_conversion_policy(policy); + if unrelated_type { + builder.add_algebraic_type( + [], + "Unused", + AlgebraicType::product([("Value", AlgebraicType::Bool)]), + true, + ); + } + let state = builder.add_algebraic_type([], "State", AlgebraicType::unit(), true); + let operation = builder.add_algebraic_type( + [], + "StateOp", + AlgebraicType::sum([ + ("SetState", AlgebraicType::Ref(state)), + ("ClearState", AlgebraicType::unit()), + ]), + true, + ); + builder.add_reducer( + "receivePing", + ProductType::from([ + ("MessageBody", AlgebraicType::String), + ("StateOps", AlgebraicType::array(AlgebraicType::Ref(operation))), + ]), + ); + if explicit_name { + let mut names = ExplicitNames::default(); + names.insert_function("receivePing", "PreviousWireName"); + names.insert_function("receivePing", "WirePing"); + builder.add_explicit_names(names); + } + let mut raw = builder.finish(); + for section in &mut raw.sections { + if let RawModuleDefV10Section::Typespace(typespace) = section { + typespace[state] = AlgebraicType::product([ + ("ItemID", AlgebraicType::U64), + ("OwnerIdentity", AlgebraicType::identity()), + ("Notes", AlgebraicType::option(AlgebraicType::String)), + ("Children", AlgebraicType::array(AlgebraicType::Ref(state))), + ]); + } + } + raw +} + +#[test] +fn raw_receiver_signatures_match_host_validation() { + for policy in [CaseConversionPolicy::None, CaseConversionPolicy::SnakeCase] { + for explicit_name in [false, true] { + let mut hashes = Vec::new(); + for unrelated_type in [false, true] { + let raw = receiver_module(policy, explicit_name, unrelated_type); + let before = bsatn::to_vec(&raw).unwrap(); + let (name, hash) = raw_reducer_signature(&raw, "receivePing").unwrap(); + assert_eq!(before, bsatn::to_vec(&raw).unwrap()); + let validated: ModuleDef = raw.try_into().unwrap(); + let reducer = validated + .reducers() + .find(|reducer| reducer.accessor_name.as_ref() == "receivePing") + .unwrap(); + assert_eq!(name.as_ref(), reducer.name.as_ref()); + assert_eq!( + hash, + reducer_signature_hash( + &reducer.params(), + &reducer.ok_return_type, + &reducer.err_return_type, + validated.typespace(), + ) + ); + hashes.push(hash); + } + assert_eq!(hashes[0], hashes[1]); + } + } +} + +#[test] +fn raw_receiver_signature_preserves_existing_wire_hash() { + let mut builder = RawModuleDefV10Builder::new(); + builder.add_reducer("receivePing", ProductType::from([("Body", AlgebraicType::String)])); + let raw = builder.finish(); + let (name, hash) = raw_reducer_signature(&raw, "receivePing").unwrap(); + assert_eq!(name.as_ref(), "receive_ping"); + assert_eq!( + hash.to_hex().to_string(), + "386957a94632958d5ae8343e258f3a6f9dce9d7dafc46831050894baa7a4e4e1" + ); + assert!(raw_reducer_signature(&raw, "missing").is_none()); +} diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index c4b3088d2ec..5a8f050bc5e 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -38,6 +38,7 @@ spacetimedb-memory-usage = { workspace = true, optional = true } spacetimedb-metrics = { workspace = true, optional = true } anyhow.workspace = true +convert_case.workspace = true derive_more.workspace = true hex.workspace = true serde = { workspace = true, optional = true } diff --git a/crates/lib/src/db/mod.rs b/crates/lib/src/db/mod.rs index e287f56f438..f330049b942 100644 --- a/crates/lib/src/db/mod.rs +++ b/crates/lib/src/db/mod.rs @@ -3,5 +3,7 @@ pub mod attr; pub mod auth; pub mod default_element_ordering; +pub mod names; pub mod raw_def; +pub mod reducer_signature; pub mod view; diff --git a/crates/lib/src/db/names.rs b/crates/lib/src/db/names.rs new file mode 100644 index 00000000000..d45fe2f9444 --- /dev/null +++ b/crates/lib/src/db/names.rs @@ -0,0 +1,47 @@ +use super::raw_def::v10::CaseConversionPolicy; +use crate::sats::Typespace; +use crate::AlgebraicType; +use convert_case::{Case, Casing}; + +/// Apply the module's case conversion policy to a source identifier. +pub fn canonical_name(name: &str, policy: CaseConversionPolicy) -> String { + match policy { + CaseConversionPolicy::None => name.to_owned(), + CaseConversionPolicy::SnakeCase => name.to_case(Case::Snake), + } +} + +/// Apply module naming rules to product fields and sum variants in a typespace. +pub fn canonicalize_typespace(policy: CaseConversionPolicy, typespace: &mut Typespace) { + for ty in &mut typespace.types { + canonicalize_type(policy, ty); + } +} + +fn canonicalize_type(policy: CaseConversionPolicy, ty: &mut AlgebraicType) { + if ty.is_special() { + return; + } + match ty { + AlgebraicType::Product(product) => { + for element in &mut product.elements { + if let Some(name) = &mut element.name { + *name = canonical_name(name.as_ref(), policy).into(); + } + canonicalize_type(policy, &mut element.algebraic_type); + } + } + AlgebraicType::Sum(sum) => { + for variant in &mut sum.variants { + if let Some(name) = &mut variant.name + && matches!(policy, CaseConversionPolicy::SnakeCase) + { + *name = name.to_string().to_case(Case::Camel).into(); + } + canonicalize_type(policy, &mut variant.algebraic_type); + } + } + AlgebraicType::Array(array) => canonicalize_type(policy, &mut array.elem_ty), + _ => {} + } +} diff --git a/crates/lib/src/db/reducer_signature.rs b/crates/lib/src/db/reducer_signature.rs new file mode 100644 index 00000000000..42935711400 --- /dev/null +++ b/crates/lib/src/db/reducer_signature.rs @@ -0,0 +1,113 @@ +use super::names::{canonical_name, canonicalize_typespace}; +use super::raw_def::v10::{ExplicitNameEntry, RawModuleDefV10}; +use crate::sats::{AlgebraicTypeRef, Typespace}; +use crate::{bsatn, hash_bytes, AlgebraicType, Hash, ProductType}; +use spacetimedb_sats::raw_identifier::RawIdentifier; +use std::collections::BTreeMap; + +const REDUCER_SIGNATURE_HASH_DOMAIN: &[u8] = b"spacetimedb:idc:reducer-signature:v1\0"; + +/// Computes the IDC signature hash from parameter names, order, types, and both return types. +/// +/// The encoding is the versioned domain prefix followed by BSATN +/// `(AlgebraicType::Product(params), ok_return_type, err_return_type, reducer_typespace)`, +/// hashed with Keccak-256. Reducer Typespace are a `Vec` in first-use order, +/// traversing parameters, then the success type, then the error type, kind of reducer local +/// typespace. +pub fn reducer_signature_hash( + params: &ProductType, + ok_return_type: &AlgebraicType, + err_return_type: &AlgebraicType, + typespace: &Typespace, +) -> Hash { + fn normalize( + ty: &mut AlgebraicType, + typespace: &Typespace, + refs: &mut BTreeMap, + reducer_typespace: &mut Typespace, + ) { + match ty { + AlgebraicType::Ref(original) => { + // Number reachable types in first-use order so unrelated types and + // their positions in the module's typespace do not affect the hash. + let local_idx = if let Some(local_idx) = refs.get(original) { + *local_idx + } else { + // Reserve the id before following references so recursive types + // can refer back to this definition while it is being copied. + let local_idx = reducer_typespace.add(AlgebraicType::unit()); + refs.insert(*original, local_idx); + let mut definition = typespace[*original].clone(); + normalize(&mut definition, typespace, refs, reducer_typespace); + reducer_typespace[local_idx] = definition; + local_idx + }; + *original = local_idx; + } + AlgebraicType::Product(product) => { + for field in &mut product.elements { + normalize(&mut field.algebraic_type, typespace, refs, reducer_typespace); + } + } + AlgebraicType::Sum(sum) => { + for variant in &mut sum.variants { + normalize(&mut variant.algebraic_type, typespace, refs, reducer_typespace); + } + } + AlgebraicType::Array(array) => normalize(&mut array.elem_ty, typespace, refs, reducer_typespace), + _ => {} + } + } + + let mut params = AlgebraicType::Product(params.clone()); + let mut ok_return_type = ok_return_type.clone(); + let mut err_return_type = err_return_type.clone(); + let mut refs = BTreeMap::new(); + let mut reducer_typespace = Typespace::default(); + for ty in [&mut params, &mut ok_return_type, &mut err_return_type] { + normalize(ty, typespace, &mut refs, &mut reducer_typespace); + } + let mut bytes = REDUCER_SIGNATURE_HASH_DOMAIN.to_vec(); + bsatn::to_writer( + &mut bytes, + &(params, ok_return_type, err_return_type, reducer_typespace.types), + ) + .expect("validated signature should serialize"); + hash_bytes(&bytes) +} + +/// Resolve a root reducer's canonical name and signature from its raw module metadata. +/// +/// The host still validates the complete module. This computes only the metadata +/// needed by module-side outbox references. +pub fn raw_reducer_signature(module: &RawModuleDefV10, source_name: &str) -> Option<(RawIdentifier, Hash)> { + let reducer = module + .reducers()? + .iter() + .find(|reducer| reducer.source_name.as_ref() == source_name)?; + let policy = module.case_conversion_policy(); + let name = module + .explicit_names() + .cloned() + .unwrap_or_default() + .into_entries() + .into_iter() + .rev() + .find_map(|entry| match entry { + ExplicitNameEntry::Function(mapping) if mapping.source_name == reducer.source_name => { + Some(mapping.canonical_name) + } + _ => None, + }) + .unwrap_or_else(|| canonical_name(source_name, policy).into()); + let mut params = reducer.params.clone(); + for parameter in &mut params.elements { + if let Some(name) = &mut parameter.name { + *name = canonical_name(name.as_ref(), policy).into(); + } + } + let mut typespace = module.typespace().cloned().unwrap_or_default(); + canonicalize_typespace(policy, &mut typespace); + let hash = reducer_signature_hash(¶ms, &reducer.ok_return_type, &reducer.err_return_type, &typespace); + Some((name, hash)) +} diff --git a/crates/schema/src/def.rs b/crates/schema/src/def.rs index 53732667c6f..774fbe521b2 100644 --- a/crates/schema/src/def.rs +++ b/crates/schema/src/def.rs @@ -46,12 +46,12 @@ use spacetimedb_lib::db::raw_def::v9::{ }; use spacetimedb_lib::db::view::{extract_view_return_product_type_ref, ViewKind}; use spacetimedb_lib::environment::EnvironmentSchema; -use spacetimedb_lib::{hash_bytes, Hash as SpacetimeHash, ProductType, RawModuleDef}; +use spacetimedb_lib::{Hash as SpacetimeHash, ProductType, RawModuleDef}; use spacetimedb_primitives::{ ColId, ColList, ColOrCols, ColSet, HttpHandlerId, ProcedureId, ReducerId, TableId, ViewFnPtr, }; use spacetimedb_sats::raw_identifier::RawIdentifier; -use spacetimedb_sats::{bsatn, AlgebraicType, AlgebraicTypeRef, AlgebraicValue, Typespace}; +use spacetimedb_sats::{AlgebraicType, AlgebraicTypeRef, AlgebraicValue, Typespace}; pub mod deserialize; pub mod error; @@ -2523,76 +2523,7 @@ fn canonical_params(mut params: ProductType, params_for_generate: &ProductTypeDe params } -const REDUCER_SIGNATURE_HASH_DOMAIN: &[u8] = b"spacetimedb:idc:reducer-signature:v1\0"; - -/// Computes the IDC signature hash from parameter names, order, types, and both return types. -/// -/// The encoding is the versioned domain prefix followed by BSATN -/// `(AlgebraicType::Product(params), ok_return_type, err_return_type, reducer_typespace)`, -/// hashed with Keccak-256. Reducer Typespace are a `Vec` in first-use order, -/// traversing parameters, then the success type, then the error type, kind of reducer local -/// typespace. -pub fn reducer_signature_hash( - params: &ProductType, - ok_return_type: &AlgebraicType, - err_return_type: &AlgebraicType, - typespace: &Typespace, -) -> spacetimedb_lib::Hash { - fn normalize( - ty: &mut AlgebraicType, - typespace: &Typespace, - refs: &mut BTreeMap, - reducer_typespace: &mut Typespace, - ) { - match ty { - AlgebraicType::Ref(original) => { - // Number reachable types in first-use order so unrelated types and - // their positions in the module's typespace do not affect the hash. - let local_idx = if let Some(local_idx) = refs.get(original) { - *local_idx - } else { - // Reserve the id before following references so recursive types - // can refer back to this definition while it is being copied. - let local_idx = reducer_typespace.add(AlgebraicType::unit()); - refs.insert(*original, local_idx); - let mut definition = typespace[*original].clone(); - normalize(&mut definition, typespace, refs, reducer_typespace); - reducer_typespace[local_idx] = definition; - local_idx - }; - *original = local_idx; - } - AlgebraicType::Product(product) => { - for field in &mut product.elements { - normalize(&mut field.algebraic_type, typespace, refs, reducer_typespace); - } - } - AlgebraicType::Sum(sum) => { - for variant in &mut sum.variants { - normalize(&mut variant.algebraic_type, typespace, refs, reducer_typespace); - } - } - AlgebraicType::Array(array) => normalize(&mut array.elem_ty, typespace, refs, reducer_typespace), - _ => {} - } - } - - let mut params = AlgebraicType::Product(params.clone()); - let mut ok_return_type = ok_return_type.clone(); - let mut err_return_type = err_return_type.clone(); - let mut refs = BTreeMap::new(); - let mut reducer_typespace = Typespace::default(); - for ty in [&mut params, &mut ok_return_type, &mut err_return_type] { - normalize(ty, typespace, &mut refs, &mut reducer_typespace); - } - let mut bytes = REDUCER_SIGNATURE_HASH_DOMAIN.to_vec(); - bsatn::to_writer( - &mut bytes, - &(params, ok_return_type, err_return_type, reducer_typespace.types), - ) - .expect("validated signature should serialize"); - hash_bytes(&bytes) -} +pub use spacetimedb_lib::db::reducer_signature::reducer_signature_hash; impl From for RawReducerDefV9 { fn from(val: ReducerDef) -> Self { @@ -2918,6 +2849,7 @@ mod tests { use proptest::prelude::*; use spacetimedb_data_structures::{expect_error_matching, map::HashCollectionExt as _}; use spacetimedb_lib::db::raw_def::v9::RawModuleDefV9Builder; + use spacetimedb_sats::bsatn; proptest! { #[test] diff --git a/crates/schema/src/def/validate/v10.rs b/crates/schema/src/def/validate/v10.rs index 154235cef5b..67e7360b47b 100644 --- a/crates/schema/src/def/validate/v10.rs +++ b/crates/schema/src/def/validate/v10.rs @@ -64,31 +64,14 @@ impl ExplicitNamesLookup { } } -/// Internal representation of case conversion policy, used during validation to determine how to -/// apply case conversion to names. -#[derive(Clone, Copy, Debug)] -pub(crate) enum ValidationCase { - None, - SnakeCase, - CamelCase, -} - -impl From for ValidationCase { - fn from(policy: CaseConversionPolicy) -> Self { - match policy { - CaseConversionPolicy::None => ValidationCase::None, - CaseConversionPolicy::SnakeCase => ValidationCase::SnakeCase, - _ => panic!("Unsupported case conversion policy: {:?}", policy), - } - } -} +pub(crate) use spacetimedb_lib::db::raw_def::v10::CaseConversionPolicy as ValidationCase; /// Validate a `RawModuleDefV10` and convert it into a `ModuleDef`, /// or return a stream of errors if the definition is invalid. pub fn validate(def: RawModuleDefV10) -> Result { let environment = validate_environment(&def); let mut typespace = def.typespace().cloned().unwrap_or_else(|| Typespace::EMPTY.clone()); let known_type_definitions = def.types().into_iter().flatten().map(|def| def.ty); - let case_policy = def.case_conversion_policy().into(); + let case_policy = def.case_conversion_policy(); let explicit_names = def .explicit_names() .cloned() @@ -106,7 +89,7 @@ pub fn validate(def: RawModuleDefV10) -> Result { // Original `typespace` needs to be preserved to be assign `accesor_name`s to columns. let typespace_with_accessor_names = typespace.clone(); // Apply case conversion to `typespace`. - CoreValidator::typespace_case_conversion(case_policy, &mut typespace); + spacetimedb_lib::db::names::canonicalize_typespace(case_policy, &mut typespace); let mut validator = ModuleValidatorV10 { core: CoreValidator { diff --git a/crates/schema/src/def/validate/v9.rs b/crates/schema/src/def/validate/v9.rs index 75e04f5ba49..3066e0d23e4 100644 --- a/crates/schema/src/def/validate/v9.rs +++ b/crates/schema/src/def/validate/v9.rs @@ -672,68 +672,6 @@ impl CoreValidator<'_> { Identifier::new(ident.into()).map_err(|error| ValidationError::IdentifierError { error }.into()) } - // Recursive function to change typenames in the typespace according to the case conversion - // policy. - pub(crate) fn typespace_case_conversion(case_policy: ValidationCase, typespace: &mut Typespace) { - let case_policy_for_enum_variants = if matches!(case_policy, ValidationCase::SnakeCase) { - ValidationCase::CamelCase - } else { - case_policy - }; - - for ty in &mut typespace.types { - Self::convert_algebraic_type(ty, case_policy, case_policy_for_enum_variants); - } - } - - // Recursively convert names in an AlgebraicType - fn convert_algebraic_type( - ty: &mut AlgebraicType, - case_policy: ValidationCase, - case_policy_for_enum_variants: ValidationCase, - ) { - if ty.is_special() { - return; - } - match ty { - AlgebraicType::Product(product) => { - for element in &mut product.elements.iter_mut() { - // Convert the element name if it exists - if let Some(name) = element.name() { - let new_name = convert(name.clone(), case_policy); - element.name = Some(new_name.into()); - } - // Recursively convert the element's type - Self::convert_algebraic_type( - &mut element.algebraic_type, - case_policy, - case_policy_for_enum_variants, - ); - } - } - AlgebraicType::Sum(sum) => { - for variant in &mut sum.variants.iter_mut() { - // Convert the variant name if it exists - if let Some(name) = variant.name() { - let new_name = convert(name.clone(), case_policy_for_enum_variants); - variant.name = Some(new_name.into()) - } - // Recursively convert the variant's type - Self::convert_algebraic_type( - &mut variant.algebraic_type, - case_policy, - case_policy_for_enum_variants, - ); - } - } - AlgebraicType::Array(array) => { - // Arrays contain a base type that might need conversion - Self::convert_algebraic_type(&mut array.elem_ty, case_policy, case_policy_for_enum_variants); - } - _ => {} - } - } - pub(crate) fn params_for_generate( &mut self, params: &ProductType, @@ -1515,13 +1453,7 @@ pub fn generate_unique_constraint_name( // Identifier::new(name).map_err(|error| ValidationError::IdentifierError { error }.into()) //} pub(crate) fn convert(identifier: RawIdentifier, policy: ValidationCase) -> String { - let identifier = identifier.to_string(); - - match policy { - ValidationCase::SnakeCase => identifier.to_case(Case::Snake), - ValidationCase::CamelCase => identifier.to_case(Case::Camel), - ValidationCase::None => identifier, - } + spacetimedb_lib::db::names::canonical_name(identifier.as_ref(), policy) } /// Check that every [`ScheduleDef`]'s `function_name` refers to a real reducer or procedure From f5a0e83ad18237ae3c21db8fdfa8a72c759e4410 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Mon, 26 Oct 2026 22:14:21 +0530 Subject: [PATCH 06/11] lint --- crates/bindings/tests/ui/views.stderr | 3 +- crates/smoketests/modules/Cargo.lock | 18 +++++++- .../modules/idc-self-outbox/src/lib.rs | 43 +++++++++++++++++-- crates/smoketests/tests/cluster/idc.rs | 12 ++++-- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/crates/bindings/tests/ui/views.stderr b/crates/bindings/tests/ui/views.stderr index f0813856d87..6282d2e00f5 100644 --- a/crates/bindings/tests/ui/views.stderr +++ b/crates/bindings/tests/ui/views.stderr @@ -84,8 +84,7 @@ error[E0599]: no method named `iter` found for struct `test__ViewHandle` in the = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `iter`, perhaps you need to implement one of them: candidate #1: `bitflags::traits::Flags` - candidate #2: `petgraph::visit::traversal::Walker` - candidate #3: `spacetimedb::Table` + candidate #2: `spacetimedb::Table` error[E0599]: no method named `insert` found for struct `test__ViewHandle` in the current scope --> tests/ui/views.rs:24:25 diff --git a/crates/smoketests/modules/Cargo.lock b/crates/smoketests/modules/Cargo.lock index ef8c15e5d30..ce9d2b6906a 100644 --- a/crates/smoketests/modules/Cargo.lock +++ b/crates/smoketests/modules/Cargo.lock @@ -122,6 +122,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -157,7 +166,7 @@ version = "0.99.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version", @@ -1245,6 +1254,7 @@ version = "2.16.3" dependencies = [ "anyhow", "blake3", + "convert_case 0.6.0", "derive_more", "hex", "spacetimedb-bindings-macro", @@ -1339,6 +1349,12 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + [[package]] name = "uuid" version = "1.20.0" diff --git a/crates/smoketests/modules/idc-self-outbox/src/lib.rs b/crates/smoketests/modules/idc-self-outbox/src/lib.rs index 5f7b9c97fae..c67179c8f49 100644 --- a/crates/smoketests/modules/idc-self-outbox/src/lib.rs +++ b/crates/smoketests/modules/idc-self-outbox/src/lib.rs @@ -5,16 +5,34 @@ use spacetimedb::Table; #[spacetimedb::settings] const CASE_CONVERSION_POLICY: spacetimedb::CaseConversionPolicy = spacetimedb::CaseConversionPolicy::None; +#[derive(spacetimedb::SpacetimeType)] +pub struct Message { + pub ItemID: u64, + pub operations: Vec, +} + +#[derive(spacetimedb::SpacetimeType)] +pub enum Operation { + SetState(State), + ClearState, +} + +#[derive(spacetimedb::SpacetimeType)] +pub struct State { + pub revision: u64, + pub displayName: Option, +} + #[spacetimedb::table(accessor = delivered_ping, name = "delivered_ping")] pub struct DeliveredPing { #[primary_key] #[auto_inc] id: u64, - body: String, + body: Message, } #[spacetimedb::reducer] -pub fn receivePing(ctx: &spacetimedb::ReducerContext, messageBody: String) { +pub fn receivePing(ctx: &spacetimedb::ReducerContext, messageBody: Message) { ctx.db.delivered_ping().insert(DeliveredPing { id: 0, body: messageBody, @@ -29,11 +47,28 @@ pub struct OutboundPing { #[target] target: spacetimedb::Identity, #[param(name = messageBody)] - payload: String, + payload: Message, +} + +#[spacetimedb::table(accessor = ping_results)] +pub struct PingResult { + #[primary_key] + id: u64, + body: Message, + error: Option, +} + +#[spacetimedb::reducer(name = "WirePingResult", on_result(self::outboundPing))] +pub fn onPingResult(ctx: &spacetimedb::ReducerContext, row: OutboundPing, result: Result<(), String>) { + ctx.db.ping_results().insert(PingResult { + id: row.id, + body: row.payload, + error: result.err(), + }); } #[spacetimedb::reducer] -pub fn enqueuePing(ctx: &spacetimedb::ReducerContext, target: spacetimedb::Identity, messageBody: String) { +pub fn enqueuePing(ctx: &spacetimedb::ReducerContext, target: spacetimedb::Identity, messageBody: Message) { ctx.db.outboundPing().insert(OutboundPing { id: 0, target, diff --git a/crates/smoketests/tests/cluster/idc.rs b/crates/smoketests/tests/cluster/idc.rs index 7e4ebe664d6..63385f734d8 100644 --- a/crates/smoketests/tests/cluster/idc.rs +++ b/crates/smoketests/tests/cluster/idc.rs @@ -457,9 +457,10 @@ fn idc_self_outbox_uses_none_case_policy() { .expect("failed to publish self-outbox module"); let identity = parse_identity_from_publish_output(&output).expect("publish output should contain an identity"); test.database_identity = Some(identity.clone()); + let message = serde_json::json!([42, [[0, [7, [0, "self-message"]]], [0, [8, [1, []]]], [1, []]]]); test.call( "enqueuePing", - &[&serde_json::to_string(&identity).unwrap(), "\"self-message\""], + &[&serde_json::to_string(&identity).unwrap(), &message.to_string()], ) .expect("failed to enqueue self-referential message"); @@ -481,14 +482,17 @@ fn idc_self_outbox_uses_none_case_policy() { }; let deadline = Instant::now() + Duration::from_secs(20); loop { - let delivered = rows("SELECT body FROM delivered_ping"); + let callbacks = rows("SELECT body, error FROM ping_results"); let pending = rows("SELECT id FROM outbound_ping"); - if delivered == vec![serde_json::json!(["self-message"])] && pending.is_empty() { + let delivered = rows("SELECT body FROM delivered_ping"); + if !callbacks.is_empty() && pending.is_empty() { + assert_eq!(delivered, vec![serde_json::json!([message])]); + assert_eq!(callbacks, vec![serde_json::json!([message, [1, []]])]); break; } assert!( Instant::now() < deadline, - "self IDC did not finish: delivered={delivered:?}, pending={pending:?}" + "self IDC did not finish: delivered={delivered:?}, callbacks={callbacks:?}, pending={pending:?}" ); std::thread::sleep(Duration::from_millis(100)); } From 19860033a0895869fcbed90e4ea1f697f77c2cfb Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Mon, 26 Oct 2026 22:39:50 +0530 Subject: [PATCH 07/11] snap --- crates/bindings/tests/snapshots/deps__duplicate_deps.snap | 6 +++++- .../snapshots/deps__spacetimedb_bindings_dependencies.snap | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/bindings/tests/snapshots/deps__duplicate_deps.snap b/crates/bindings/tests/snapshots/deps__duplicate_deps.snap index 4f2ea4cc313..1fd2ed93e3b 100644 --- a/crates/bindings/tests/snapshots/deps__duplicate_deps.snap +++ b/crates/bindings/tests/snapshots/deps__duplicate_deps.snap @@ -1,7 +1,11 @@ --- source: crates/bindings/tests/deps.rs -expression: cargo tree -p spacetimedb -e no-dev -d --depth 0 +expression: cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -d --depth 0 --- +convert_case v0.4.0 + +convert_case v0.6.0 + heck v0.4.1 heck v0.5.0 diff --git a/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap b/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap index e344e1fa4f2..0ec550bef02 100644 --- a/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap +++ b/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap @@ -1,9 +1,8 @@ --- source: crates/bindings/tests/deps.rs -assertion_line: 16 expression: "cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -f {lib}" --- -total crates: 72 +total crates: 74 spacetimedb ├── anyhow ├── bytemuck @@ -61,6 +60,8 @@ spacetimedb │ │ └── cc │ │ ├── find_msvc_tools │ │ └── shlex +│ ├── convert_case +│ │ └── unicode_segmentation │ ├── derive_more │ │ ├── convert_case │ │ ├── proc_macro2 (*) From 677f2aa8f692fa4fb496fb5c790a795f7c1c0d1b Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Tue, 27 Oct 2026 00:48:28 +0530 Subject: [PATCH 08/11] local outbox --- Cargo.lock | 1 - .../Autogen/RawLocalOutboxDefV10.g.cs | 49 +++++++ .../Autogen/RawModuleDefV10Section.g.cs | 3 +- crates/bindings/src/rt.rs | 65 +++------ crates/bindings/tests/local_outbox.rs | 14 +- crates/bindings/tests/receiver_signatures.rs | 134 ++++++++++++++++-- .../tests/snapshots/deps__duplicate_deps.snap | 4 - ...ps__spacetimedb_bindings_dependencies.snap | 4 +- crates/lib/Cargo.toml | 1 - crates/lib/src/db/mod.rs | 2 - crates/lib/src/db/raw_def/v10.rs | 99 +++++++++++-- crates/schema/src/def.rs | 16 ++- .../src/def}/reducer_signature.rs | 43 +----- crates/schema/src/def/validate.rs | 2 + .../db => schema/src/def/validate}/names.rs | 37 ++++- crates/schema/src/def/validate/v10.rs | 39 ++++- crates/schema/src/def/validate/v9.rs | 22 +-- crates/schema/src/error.rs | 5 + crates/smoketests/modules/Cargo.lock | 18 +-- 19 files changed, 391 insertions(+), 167 deletions(-) create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawLocalOutboxDefV10.g.cs rename crates/{lib/src/db => schema/src/def}/reducer_signature.rs (64%) rename crates/{lib/src/db => schema/src/def/validate}/names.rs (54%) diff --git a/Cargo.lock b/Cargo.lock index fa0f535cd67..0c05e35e04f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8839,7 +8839,6 @@ version = "2.16.3" dependencies = [ "anyhow", "blake3", - "convert_case 0.6.0", "derive_more 0.99.20", "enum-map", "hex", diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawLocalOutboxDefV10.g.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawLocalOutboxDefV10.g.cs new file mode 100644 index 00000000000..49093a40ad8 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawLocalOutboxDefV10.g.cs @@ -0,0 +1,49 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#nullable enable + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public sealed partial class RawLocalOutboxDefV10 + { + [DataMember(Name = "table_name")] + public string TableName; + [DataMember(Name = "reducer_source_name")] + public string ReducerSourceName; + [DataMember(Name = "target_column")] + public ushort TargetColumn; + [DataMember(Name = "arg_columns")] + public System.Collections.Generic.List ArgColumns; + [DataMember(Name = "on_result_reducer")] + public string? OnResultReducer; + + public RawLocalOutboxDefV10( + string TableName, + string ReducerSourceName, + ushort TargetColumn, + System.Collections.Generic.List ArgColumns, + string? OnResultReducer + ) + { + this.TableName = TableName; + this.ReducerSourceName = ReducerSourceName; + this.TargetColumn = TargetColumn; + this.ArgColumns = ArgColumns; + this.OnResultReducer = OnResultReducer; + } + + public RawLocalOutboxDefV10() + { + this.TableName = ""; + this.ReducerSourceName = ""; + this.ArgColumns = new(); + } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV10Section.g.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV10Section.g.cs index ebfc9e58849..1619bbcf491 100644 --- a/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV10Section.g.cs +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV10Section.g.cs @@ -27,6 +27,7 @@ public partial record RawModuleDefV10Section : SpacetimeDB.TaggedEnum<( System.Collections.Generic.List Environment, System.Collections.Generic.List Outboxes, System.Collections.Generic.List TableCachePolicies, - System.Collections.Generic.List Migrations + System.Collections.Generic.List Migrations, + System.Collections.Generic.List LocalOutboxes )>; } diff --git a/crates/bindings/src/rt.rs b/crates/bindings/src/rt.rs index 7c83b619db5..5925bf189a1 100644 --- a/crates/bindings/src/rt.rs +++ b/crates/bindings/src/rt.rs @@ -6,7 +6,7 @@ use crate::{sys, AnonymousViewContext, IterBuf, ReducerContext, ReducerResult, S use spacetimedb_lib::bsatn::EncodeError; use spacetimedb_lib::db::raw_def::v10::{ CaseConversionPolicy, ExplicitNames as RawExplicitNames, RawEnvVarTypeV10, RawEnvironmentDeclarationV10, - RawModuleDefV10, RawModuleDefV10Builder, RawModuleDefV10Section, + RawModuleDefV10, RawModuleDefV10Builder, }; pub use spacetimedb_lib::db::raw_def::v9::Lifecycle as LifecycleReducer; use spacetimedb_lib::db::raw_def::v9::{RawIndexAlgorithm, TableType, ViewResultHeader}; @@ -213,7 +213,7 @@ pub trait OutboxReceiver { /// The registered reducer name, or its source name when resolved locally. const NAME: &'static str; - /// A precomputed signature, or `None` to resolve it from the local module schema. + /// A precomputed remote signature, or `None` for host resolution of a local reducer. const SIGNATURE_HASH: Option<&'static str>; } @@ -880,20 +880,26 @@ pub fn register_table() { table.finish(); if let Some(outbox) = T::OUTBOX { - let signature_hash = if let Some(hash) = outbox.signature_hash { - spacetimedb_lib::Hash::from_hex(hash).expect("generated outbox signature hash must be valid hex") + if let Some(hash) = outbox.signature_hash { + module.inner.add_outbox( + T::TABLE_NAME, + outbox.remote_reducer_name, + outbox.target_column, + outbox.arg_columns.iter().copied().map(Into::into), + None::<&str>, + spacetimedb_lib::Hash::from_hex(hash).expect("generated outbox signature hash must be valid hex"), + ); } else { - module.local_outboxes.push((T::TABLE_NAME, outbox.remote_reducer_name)); - spacetimedb_lib::Hash::ZERO - }; - module.inner.add_outbox( - T::TABLE_NAME, - outbox.remote_reducer_name, - outbox.target_column, - outbox.arg_columns.iter().copied().map(Into::into), - None::<&str>, - signature_hash, - ); + // Only the source reference is exported. The host resolves names and + // computes the signature from its validated reducer definition. + module.inner.add_local_outbox( + T::TABLE_NAME, + outbox.remote_reducer_name, + outbox.target_column, + outbox.arg_columns.iter().copied().map(Into::into), + None::<&str>, + ); + } } module.inner.add_explicit_names(T::explicit_names()); @@ -1208,7 +1214,6 @@ pub struct ModuleBuilder { /// The anonymous views of the module. views_anon: Vec, on_result_reducers: Vec<(&'static str, &'static str)>, - local_outboxes: Vec<(&'static str, &'static str)>, } // Not actually a mutex; because WASM is single-threaded this basically just turns into a refcell. @@ -1220,33 +1225,7 @@ impl ModuleBuilder { self.inner.set_outbox_on_result(outbox_table, reducer); } - let mut raw = std::mem::take(&mut self.inner).finish(); - if self.local_outboxes.is_empty() { - return raw; - } - - // A local reducer's signature is only known after names and types have been - // canonicalized. The temporary zero hashes are replaced before serialization. - for &(table_name, reducer_source_name) in &self.local_outboxes { - let (reducer_name, signature_hash) = - spacetimedb_lib::db::reducer_signature::raw_reducer_signature(&raw, reducer_source_name) - .unwrap_or_else(|| { - panic!("local outbox `{table_name}` references missing reducer `{reducer_source_name}`") - }); - let outbox = raw - .sections - .iter_mut() - .find_map(|section| match section { - RawModuleDefV10Section::Outboxes(outboxes) => outboxes - .iter_mut() - .find(|outbox| outbox.table_name.as_ref() == table_name), - _ => None, - }) - .expect("registered local outbox is missing from module definition"); - outbox.remote_reducer = reducer_name; - outbox.signature_hash = signature_hash; - } - raw + std::mem::take(&mut self.inner).finish() } } diff --git a/crates/bindings/tests/local_outbox.rs b/crates/bindings/tests/local_outbox.rs index 9a3e53f50e0..3029bc9d77b 100644 --- a/crates/bindings/tests/local_outbox.rs +++ b/crates/bindings/tests/local_outbox.rs @@ -21,19 +21,24 @@ pub struct OutboundPing { payload: String, } +#[spacetimedb::reducer(on_result(self::outboundPing))] +pub fn on_ping_result(_: &spacetimedb::ReducerContext, _row: OutboundPing, _result: Result<(), String>) {} + #[test] fn local_outbox_hash_uses_the_canonical_reducer_signature() { let RawModuleDef::V10(raw) = spacetimedb::test_utils::module_def() else { panic!("expected V10 module definition"); }; assert_eq!(raw.case_conversion_policy(), spacetimedb::CaseConversionPolicy::None); - let outbox = &raw.outboxes().unwrap()[0]; - assert_eq!(outbox.remote_reducer.as_ref(), "receivePing"); + assert!(raw.outboxes().is_none()); + let outbox = &raw.local_outboxes().unwrap()[0]; + assert_eq!(outbox.reducer_source_name.as_ref(), "receivePing"); + assert_eq!(outbox.on_result_reducer.as_ref().unwrap().as_ref(), "on_ping_result"); assert_eq!(outbox.arg_columns.len(), 1); - let actual_hash = outbox.signature_hash; let module = spacetimedb_schema::def::ModuleDef::try_from(RawModuleDef::V10(raw)).unwrap(); let reducer = module.reducer_by_name("receivePing").unwrap().1; + let outbox = module.tables().find_map(|table| table.outbox.as_ref()).unwrap(); assert_eq!( reducer.params().elements[0].name.as_ref().unwrap().as_ref(), "messageBody" @@ -44,5 +49,6 @@ fn local_outbox_hash_uses_the_canonical_reducer_signature() { &reducer.err_return_type, module.typespace(), ); - assert_eq!(actual_hash, expected_hash); + assert_eq!(outbox.signature_hash, expected_hash); + assert_eq!(outbox.on_result_reducer.as_ref().unwrap().as_ref(), "on_ping_result"); } diff --git a/crates/bindings/tests/receiver_signatures.rs b/crates/bindings/tests/receiver_signatures.rs index 4bf2b778d54..830c509e7ae 100644 --- a/crates/bindings/tests/receiver_signatures.rs +++ b/crates/bindings/tests/receiver_signatures.rs @@ -1,8 +1,8 @@ use spacetimedb::spacetimedb_lib::db::raw_def::v10::{ CaseConversionPolicy, ExplicitNames, RawModuleDefV10, RawModuleDefV10Builder, RawModuleDefV10Section, }; -use spacetimedb::spacetimedb_lib::db::reducer_signature::raw_reducer_signature; -use spacetimedb::spacetimedb_lib::{bsatn, AlgebraicType, ProductType}; +use spacetimedb::spacetimedb_lib::db::raw_def::v9::direct; +use spacetimedb::spacetimedb_lib::{AlgebraicType, ProductType}; use spacetimedb_schema::def::{reducer_signature_hash, ModuleDef}; fn receiver_module(policy: CaseConversionPolicy, explicit_name: bool, unrelated_type: bool) -> RawModuleDefV10 { @@ -33,6 +33,21 @@ fn receiver_module(policy: CaseConversionPolicy, explicit_name: bool, unrelated_ ("StateOps", AlgebraicType::array(AlgebraicType::Ref(operation))), ]), ); + builder + .build_table_with_new_type( + "outboundPing", + ProductType::from([ + ("id", AlgebraicType::U64), + ("target", AlgebraicType::identity()), + ("MessageBody", AlgebraicType::String), + ("StateOps", AlgebraicType::array(AlgebraicType::Ref(operation))), + ]), + true, + ) + .with_auto_inc_primary_key(0) + .with_index_no_accessor_name(direct(0), "outbound_ping_id_idx") + .finish(); + builder.add_local_outbox("outboundPing", "receivePing", 1, [2.into(), 3.into()], None::<&str>); if explicit_name { let mut names = ExplicitNames::default(); names.insert_function("receivePing", "PreviousWireName"); @@ -54,23 +69,26 @@ fn receiver_module(policy: CaseConversionPolicy, explicit_name: bool, unrelated_ } #[test] -fn raw_receiver_signatures_match_host_validation() { +fn local_outbox_signatures_use_validated_reducers() { for policy in [CaseConversionPolicy::None, CaseConversionPolicy::SnakeCase] { for explicit_name in [false, true] { let mut hashes = Vec::new(); for unrelated_type in [false, true] { let raw = receiver_module(policy, explicit_name, unrelated_type); - let before = bsatn::to_vec(&raw).unwrap(); - let (name, hash) = raw_reducer_signature(&raw, "receivePing").unwrap(); - assert_eq!(before, bsatn::to_vec(&raw).unwrap()); + assert!(raw.outboxes().is_none()); + assert_eq!( + raw.local_outboxes().unwrap()[0].reducer_source_name.as_ref(), + "receivePing" + ); let validated: ModuleDef = raw.try_into().unwrap(); let reducer = validated .reducers() .find(|reducer| reducer.accessor_name.as_ref() == "receivePing") .unwrap(); - assert_eq!(name.as_ref(), reducer.name.as_ref()); + let outbox = validated.tables().find_map(|table| table.outbox.as_ref()).unwrap(); + assert_eq!(outbox.remote_reducer, reducer.name); assert_eq!( - hash, + outbox.signature_hash, reducer_signature_hash( &reducer.params(), &reducer.ok_return_type, @@ -78,7 +96,16 @@ fn raw_receiver_signatures_match_host_validation() { validated.typespace(), ) ); - hashes.push(hash); + hashes.push(outbox.signature_hash); + // Extracted schemas contain resolved remote-style metadata, so receiver + // codegen and a second validation do not need the source reference. + let exported: RawModuleDefV10 = validated.clone().into(); + assert!(exported.local_outboxes().is_none()); + let roundtrip: ModuleDef = exported.try_into().unwrap(); + assert_eq!( + roundtrip.tables().find_map(|table| table.outbox.as_ref()).unwrap(), + outbox + ); } assert_eq!(hashes[0], hashes[1]); } @@ -86,15 +113,92 @@ fn raw_receiver_signatures_match_host_validation() { } #[test] -fn raw_receiver_signature_preserves_existing_wire_hash() { +fn local_outbox_signature_preserves_existing_wire_hash() { let mut builder = RawModuleDefV10Builder::new(); builder.add_reducer("receivePing", ProductType::from([("Body", AlgebraicType::String)])); - let raw = builder.finish(); - let (name, hash) = raw_reducer_signature(&raw, "receivePing").unwrap(); - assert_eq!(name.as_ref(), "receive_ping"); + builder + .build_table_with_new_type( + "outboundPing", + ProductType::from([ + ("id", AlgebraicType::U64), + ("target", AlgebraicType::identity()), + ("Body", AlgebraicType::String), + ]), + true, + ) + .with_auto_inc_primary_key(0) + .with_index_no_accessor_name(direct(0), "outbound_ping_id_idx") + .finish(); + builder.add_local_outbox("outboundPing", "receivePing", 1, [2.into()], None::<&str>); + let module: ModuleDef = builder.finish().try_into().unwrap(); + let outbox = module.tables().find_map(|table| table.outbox.as_ref()).unwrap(); + assert_eq!(outbox.remote_reducer.as_ref(), "receive_ping"); assert_eq!( - hash.to_hex().to_string(), + outbox.signature_hash.to_hex().to_string(), "386957a94632958d5ae8343e258f3a6f9dce9d7dafc46831050894baa7a4e4e1" ); - assert!(raw_reducer_signature(&raw, "missing").is_none()); +} + +#[test] +fn local_outbox_requires_a_reducer_source_name() { + let mut raw = receiver_module(CaseConversionPolicy::SnakeCase, true, false); + for section in &mut raw.sections { + if let RawModuleDefV10Section::LocalOutboxes(outboxes) = section { + // An explicit canonical name is not a valid source reference. + outboxes[0].reducer_source_name = "WirePing".into(); + } + } + let errors = ModuleDef::try_from(raw).unwrap_err(); + assert!( + errors.to_string().contains("local receiver reducer WirePing"), + "{errors}" + ); +} + +#[test] +fn local_and_remote_outboxes_cannot_share_a_table() { + let mut raw = receiver_module(CaseConversionPolicy::None, false, false); + raw.sections.push(RawModuleDefV10Section::Outboxes(vec![ + spacetimedb::spacetimedb_lib::db::raw_def::v10::RawOutboxDefV10 { + table_name: "outboundPing".into(), + remote_reducer: "remote_ping".into(), + target_column: 1.into(), + arg_columns: vec![2.into(), 3.into()], + on_result_reducer: None, + signature_hash: spacetimedb::spacetimedb_lib::Hash::ZERO, + }, + ])); + let errors = ModuleDef::try_from(raw).unwrap_err(); + assert!(errors.to_string().contains("assigned in multiple outboxes"), "{errors}"); +} + +#[test] +fn local_outbox_receiver_follows_its_submodule_namespace() { + let child = receiver_module(CaseConversionPolicy::None, true, false); + let mut middle = RawModuleDefV10Builder::new(); + middle.add_submodule("innerMount", child); + let mut names = ExplicitNames::default(); + names.insert_namespace("innerMount", "InnerWire"); + middle.add_explicit_names(names); + let mut root = RawModuleDefV10Builder::new(); + root.add_submodule("outerLib", middle.finish()); + let mut module: ModuleDef = root.finish().try_into().unwrap(); + + for _ in 0..3 { + let child = &module.submodules()["outer_lib"].submodules()["InnerWire"]; + let outbox = child.tables().find_map(|table| table.outbox.as_ref()).unwrap(); + assert_eq!(outbox.remote_reducer.as_ref(), "outer_lib.InnerWire.WirePing"); + let reducer = module.reducer_by_name(&outbox.remote_reducer).unwrap().1; + assert_eq!( + outbox.signature_hash, + reducer_signature_hash( + &reducer.params(), + &reducer.ok_return_type, + &reducer.err_return_type, + child.typespace(), + ) + ); + let raw: RawModuleDefV10 = module.into(); + module = raw.try_into().unwrap(); + } } diff --git a/crates/bindings/tests/snapshots/deps__duplicate_deps.snap b/crates/bindings/tests/snapshots/deps__duplicate_deps.snap index 1fd2ed93e3b..b0cf8861b0a 100644 --- a/crates/bindings/tests/snapshots/deps__duplicate_deps.snap +++ b/crates/bindings/tests/snapshots/deps__duplicate_deps.snap @@ -2,10 +2,6 @@ source: crates/bindings/tests/deps.rs expression: cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -d --depth 0 --- -convert_case v0.4.0 - -convert_case v0.6.0 - heck v0.4.1 heck v0.5.0 diff --git a/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap b/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap index 0ec550bef02..dffa3abdfb1 100644 --- a/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap +++ b/crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap @@ -2,7 +2,7 @@ source: crates/bindings/tests/deps.rs expression: "cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -f {lib}" --- -total crates: 74 +total crates: 72 spacetimedb ├── anyhow ├── bytemuck @@ -60,8 +60,6 @@ spacetimedb │ │ └── cc │ │ ├── find_msvc_tools │ │ └── shlex -│ ├── convert_case -│ │ └── unicode_segmentation │ ├── derive_more │ │ ├── convert_case │ │ ├── proc_macro2 (*) diff --git a/crates/lib/Cargo.toml b/crates/lib/Cargo.toml index 5a8f050bc5e..c4b3088d2ec 100644 --- a/crates/lib/Cargo.toml +++ b/crates/lib/Cargo.toml @@ -38,7 +38,6 @@ spacetimedb-memory-usage = { workspace = true, optional = true } spacetimedb-metrics = { workspace = true, optional = true } anyhow.workspace = true -convert_case.workspace = true derive_more.workspace = true hex.workspace = true serde = { workspace = true, optional = true } diff --git a/crates/lib/src/db/mod.rs b/crates/lib/src/db/mod.rs index f330049b942..e287f56f438 100644 --- a/crates/lib/src/db/mod.rs +++ b/crates/lib/src/db/mod.rs @@ -3,7 +3,5 @@ pub mod attr; pub mod auth; pub mod default_element_ordering; -pub mod names; pub mod raw_def; -pub mod reducer_signature; pub mod view; diff --git a/crates/lib/src/db/raw_def/v10.rs b/crates/lib/src/db/raw_def/v10.rs index e26f010343a..066c925ce89 100644 --- a/crates/lib/src/db/raw_def/v10.rs +++ b/crates/lib/src/db/raw_def/v10.rs @@ -114,6 +114,9 @@ pub enum RawModuleDefV10Section { /// Migrations from old schema versions, keyed by that schema version's hash. Migrations(Vec), + + /// Outboxes whose receiver signature is resolved from this module's reducers by the host. + LocalOutboxes(Vec), } /// The furthest storage tier a table's pages and blobs may reside in. @@ -400,6 +403,26 @@ pub struct RawOutboxDefV10 { pub signature_hash: Hash, } +/// An outbox referencing a reducer defined in the same module. +/// +/// The host resolves the source name and computes the signature after validating +/// the module. The target column can still address another database running that module. +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] +#[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] +pub struct RawLocalOutboxDefV10 { + /// The source name of the outbox table. + pub table_name: RawIdentifier, + /// The source name of a reducer in the same module, before explicit naming or casing. + pub reducer_source_name: RawIdentifier, + /// Column containing the receiver database identity. + pub target_column: ColId, + /// Columns to encode in the local reducer's parameter order. + pub arg_columns: Vec, + /// Optional local reducer called with the delivery result. + pub on_result_reducer: Option, +} + /// A reducer definition. #[derive(Debug, Clone, SpacetimeType)] #[sats(crate = crate)] @@ -765,6 +788,14 @@ impl RawModuleDefV10 { .flatten() } + /// Get outboxes whose receiver signatures must be resolved by the host. + pub fn local_outboxes(&self) -> Option<&Vec> { + self.sections.iter().find_map(|s| match s { + RawModuleDefV10Section::LocalOutboxes(outboxes) => Some(outboxes), + _ => None, + }) + } + // Get the row-level security section, if present. pub fn row_level_security(&self) -> Option<&Vec> { self.sections.iter().find_map(|s| match s { @@ -1085,6 +1116,24 @@ impl RawModuleDefV10Builder { } } + fn local_outboxes_mut(&mut self) -> &mut Vec { + let idx = self + .module + .sections + .iter() + .position(|s| matches!(s, RawModuleDefV10Section::LocalOutboxes(_))) + .unwrap_or_else(|| { + self.module + .sections + .push(RawModuleDefV10Section::LocalOutboxes(Vec::new())); + self.module.sections.len() - 1 + }); + match &mut self.module.sections[idx] { + RawModuleDefV10Section::LocalOutboxes(outboxes) => outboxes, + _ => unreachable!("Just ensured LocalOutboxes section exists"), + } + } + /// Get mutable access to the environment section, creating it if missing. fn environment_mut(&mut self) -> &mut Vec { let idx = self @@ -1428,6 +1477,24 @@ impl RawModuleDefV10Builder { }); } + /// Register a local receiver without computing its signature in the module. + pub fn add_local_outbox( + &mut self, + table_name: impl Into, + reducer_source_name: impl Into, + target_column: impl Into, + arg_columns: impl IntoIterator, + on_result_reducer: Option>, + ) { + self.local_outboxes_mut().push(RawLocalOutboxDefV10 { + table_name: table_name.into(), + reducer_source_name: reducer_source_name.into(), + target_column: target_column.into(), + arg_columns: arg_columns.into_iter().collect(), + on_result_reducer: on_result_reducer.map(Into::into), + }); + } + pub fn set_outbox_on_result( &mut self, table_name: impl Into, @@ -1435,19 +1502,27 @@ impl RawModuleDefV10Builder { ) { let table_name = table_name.into(); let on_result_reducer = Some(on_result_reducer.into()); - if let Some(outbox) = self - .outboxes_mut() + let callback = self + .module + .sections .iter_mut() - .find(|outbox| outbox.table_name == table_name) - { - assert!( - outbox.on_result_reducer.is_none(), - "outbox table `{table_name}` has multiple on_result reducers" - ); - outbox.on_result_reducer = on_result_reducer; - } else { - panic!("on_result reducer references unknown outbox table `{table_name}`"); - } + .find_map(|section| match section { + RawModuleDefV10Section::Outboxes(outboxes) => outboxes + .iter_mut() + .find(|outbox| outbox.table_name == table_name) + .map(|outbox| &mut outbox.on_result_reducer), + RawModuleDefV10Section::LocalOutboxes(outboxes) => outboxes + .iter_mut() + .find(|outbox| outbox.table_name == table_name) + .map(|outbox| &mut outbox.on_result_reducer), + _ => None, + }) + .unwrap_or_else(|| panic!("on_result reducer references unknown outbox table `{table_name}`")); + assert!( + callback.is_none(), + "outbox table `{table_name}` has multiple on_result reducers" + ); + *callback = on_result_reducer; } pub fn add_submodule(&mut self, namespace: impl Into, module: RawModuleDefV10) { diff --git a/crates/schema/src/def.rs b/crates/schema/src/def.rs index 774fbe521b2..1158c7de535 100644 --- a/crates/schema/src/def.rs +++ b/crates/schema/src/def.rs @@ -15,7 +15,7 @@ //! After validation, a `ModuleDef` can be converted to the `*Schema` types in `crate::schema` for use in the database. //! (Eventually, we may unify these types...) -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::fmt::{self, Debug, Write}; use std::hash::Hash; @@ -125,6 +125,10 @@ pub struct ModuleDef { /// The tables of the module definition. tables: IdentifierMap, + /// Source names of outboxes whose receiver belongs to this module. Retained so + /// mounting a submodule can qualify local receivers without changing remote ones. + local_outbox_tables: BTreeSet, + /// The reducers of the module definition. /// Note: this is using IndexMap because reducer order is important /// and must be preserved for future calls to `__call_reducer__`. @@ -314,6 +318,11 @@ impl ModuleDef { self.accessor_path = accessor_path.clone(); for table in self.tables.values_mut() { table.namespace = path.clone(); + if self.local_outbox_tables.contains(table.accessor_name.as_raw()) + && let Some(outbox) = &mut table.outbox + { + outbox.remote_reducer = ReducerName::new(path.join(outbox.remote_reducer.local().clone())); + } for index in table.indexes.values_mut() { index.namespace = path.clone(); } @@ -1043,6 +1052,7 @@ impl From for RawModuleDefV9 { fn from(val: ModuleDef) -> Self { let ModuleDef { path: _, + local_outbox_tables: _, tables, views, reducers, @@ -1106,6 +1116,7 @@ impl From for RawModuleDefV10 { fn from(val: ModuleDef) -> Self { let ModuleDef { path: _, + local_outbox_tables: _, tables, views, reducers, @@ -2523,7 +2534,8 @@ fn canonical_params(mut params: ProductType, params_for_generate: &ProductTypeDe params } -pub use spacetimedb_lib::db::reducer_signature::reducer_signature_hash; +mod reducer_signature; +pub use reducer_signature::reducer_signature_hash; impl From for RawReducerDefV9 { fn from(val: ReducerDef) -> Self { diff --git a/crates/lib/src/db/reducer_signature.rs b/crates/schema/src/def/reducer_signature.rs similarity index 64% rename from crates/lib/src/db/reducer_signature.rs rename to crates/schema/src/def/reducer_signature.rs index 42935711400..0a383babd55 100644 --- a/crates/lib/src/db/reducer_signature.rs +++ b/crates/schema/src/def/reducer_signature.rs @@ -1,8 +1,5 @@ -use super::names::{canonical_name, canonicalize_typespace}; -use super::raw_def::v10::{ExplicitNameEntry, RawModuleDefV10}; -use crate::sats::{AlgebraicTypeRef, Typespace}; -use crate::{bsatn, hash_bytes, AlgebraicType, Hash, ProductType}; -use spacetimedb_sats::raw_identifier::RawIdentifier; +use spacetimedb_lib::{bsatn, hash_bytes, Hash}; +use spacetimedb_sats::{AlgebraicType, AlgebraicTypeRef, ProductType, Typespace}; use std::collections::BTreeMap; const REDUCER_SIGNATURE_HASH_DOMAIN: &[u8] = b"spacetimedb:idc:reducer-signature:v1\0"; @@ -75,39 +72,3 @@ pub fn reducer_signature_hash( .expect("validated signature should serialize"); hash_bytes(&bytes) } - -/// Resolve a root reducer's canonical name and signature from its raw module metadata. -/// -/// The host still validates the complete module. This computes only the metadata -/// needed by module-side outbox references. -pub fn raw_reducer_signature(module: &RawModuleDefV10, source_name: &str) -> Option<(RawIdentifier, Hash)> { - let reducer = module - .reducers()? - .iter() - .find(|reducer| reducer.source_name.as_ref() == source_name)?; - let policy = module.case_conversion_policy(); - let name = module - .explicit_names() - .cloned() - .unwrap_or_default() - .into_entries() - .into_iter() - .rev() - .find_map(|entry| match entry { - ExplicitNameEntry::Function(mapping) if mapping.source_name == reducer.source_name => { - Some(mapping.canonical_name) - } - _ => None, - }) - .unwrap_or_else(|| canonical_name(source_name, policy).into()); - let mut params = reducer.params.clone(); - for parameter in &mut params.elements { - if let Some(name) = &mut parameter.name { - *name = canonical_name(name.as_ref(), policy).into(); - } - } - let mut typespace = module.typespace().cloned().unwrap_or_default(); - canonicalize_typespace(policy, &mut typespace); - let hash = reducer_signature_hash(¶ms, &reducer.ok_return_type, &reducer.err_return_type, &typespace); - Some((name, hash)) -} diff --git a/crates/schema/src/def/validate.rs b/crates/schema/src/def/validate.rs index 44829a0e8b8..a1ee4393a3d 100644 --- a/crates/schema/src/def/validate.rs +++ b/crates/schema/src/def/validate.rs @@ -2,6 +2,8 @@ use crate::error::ValidationErrors; +mod names; + pub mod v10; pub mod v8; pub mod v9; diff --git a/crates/lib/src/db/names.rs b/crates/schema/src/def/validate/names.rs similarity index 54% rename from crates/lib/src/db/names.rs rename to crates/schema/src/def/validate/names.rs index d45fe2f9444..fc8d51ef597 100644 --- a/crates/lib/src/db/names.rs +++ b/crates/schema/src/def/validate/names.rs @@ -1,16 +1,47 @@ -use super::raw_def::v10::CaseConversionPolicy; -use crate::sats::Typespace; -use crate::AlgebraicType; use convert_case::{Case, Casing}; +use spacetimedb_lib::db::raw_def::v10::CaseConversionPolicy; +use spacetimedb_sats::raw_identifier::RawIdentifier; +use spacetimedb_sats::{AlgebraicType, ProductType, Typespace}; /// Apply the module's case conversion policy to a source identifier. pub fn canonical_name(name: &str, policy: CaseConversionPolicy) -> String { match policy { CaseConversionPolicy::None => name.to_owned(), CaseConversionPolicy::SnakeCase => name.to_case(Case::Snake), + _ => unreachable!("unsupported case conversion policy"), } } +/// Resolve a schema name, preserving an explicit override verbatim. +/// +/// Tables, functions, and namespaces use the same precedence rule. Applying case +/// conversion to an explicit name would change the registered name. +pub fn canonical_name_with_override( + source_name: &str, + explicit_name: Option<&RawIdentifier>, + policy: CaseConversionPolicy, +) -> RawIdentifier { + explicit_name + .cloned() + .unwrap_or_else(|| canonical_name(source_name, policy).into()) +} + +/// Resolve parameter names without changing their types or visiting inline field names. +/// +/// Keep missing names as `None` so validation can report its usual error with the +/// source location. Local outboxes hash the resulting validated reducer parameters. +pub fn canonical_parameter_names( + params: &ProductType, + policy: CaseConversionPolicy, +) -> impl Iterator> + '_ { + params.elements.iter().map(move |param| { + param + .name + .as_ref() + .map(|name| canonical_name(name.as_ref(), policy).into()) + }) +} + /// Apply module naming rules to product fields and sum variants in a typespace. pub fn canonicalize_typespace(policy: CaseConversionPolicy, typespace: &mut Typespace) { for ty in &mut typespace.types { diff --git a/crates/schema/src/def/validate/v10.rs b/crates/schema/src/def/validate/v10.rs index 67e7360b47b..0b828213f2e 100644 --- a/crates/schema/src/def/validate/v10.rs +++ b/crates/schema/src/def/validate/v10.rs @@ -10,7 +10,7 @@ use spacetimedb_primitives::ReducerId; use spacetimedb_sats::{AlgebraicType, Typespace, WithTypespace}; use crate::def::validate::v9::{ - check_function_names_are_unique, check_scheduled_functions_exist, convert, generate_schedule_name, + check_function_names_are_unique, check_scheduled_functions_exist, generate_schedule_name, generate_unique_constraint_name, identifier, CoreValidator, TableValidator, ViewValidator, }; use crate::def::*; @@ -89,7 +89,7 @@ pub fn validate(def: RawModuleDefV10) -> Result { // Original `typespace` needs to be preserved to be assign `accesor_name`s to columns. let typespace_with_accessor_names = typespace.clone(); // Apply case conversion to `typespace`. - spacetimedb_lib::db::names::canonicalize_typespace(case_policy, &mut typespace); + super::names::canonicalize_typespace(case_policy, &mut typespace); let mut validator = ModuleValidatorV10 { core: CoreValidator { @@ -205,6 +205,8 @@ pub fn validate(def: RawModuleDefV10) -> Result { .unwrap_or_else(|| Ok(Vec::new())); let raw_outboxes = def.outboxes().cloned().unwrap_or_default(); + let local_outboxes = def.local_outboxes().cloned().unwrap_or_default(); + let local_outbox_tables = local_outboxes.iter().map(|outbox| outbox.table_name.clone()).collect(); // Validate lifecycle reducers - they reference reducers by name let lifecycle_validations = reducers @@ -275,7 +277,7 @@ pub fn validate(def: RawModuleDefV10) -> Result { schedules, lifecycles, http_handlers_and_routes, - raw_outboxes, + mut raw_outboxes, )| { let (mut reducers, mut procedures, mut views) = check_function_names_are_unique(reducers, procedures, views)?; @@ -285,6 +287,30 @@ pub fn validate(def: RawModuleDefV10) -> Result { // Attach schedules to their respective tables attach_schedules_to_tables(&mut tables, schedules)?; + // Local references use the same canonical reducer and typespace as + // delivery. Modules do not need to repeat validation or emit a hash. + for local in local_outboxes { + let (name, reducer) = reducers + .iter() + .find(|(_, reducer)| reducer.accessor_name.as_ref() == local.reducer_source_name.as_ref()) + .ok_or_else(|| ValidationError::MissingLocalOutboxReducer { + table_name: local.table_name.clone(), + reducer_name: local.reducer_source_name.clone(), + })?; + raw_outboxes.push(RawOutboxDefV10 { + table_name: local.table_name, + remote_reducer: name.clone().into(), + target_column: local.target_column, + arg_columns: local.arg_columns, + on_result_reducer: local.on_result_reducer, + signature_hash: reducer_signature_hash( + &reducer.params(), + &reducer.ok_return_type, + &reducer.err_return_type, + validator.core.typespace, + ), + }); + } attach_outboxes_to_tables(&mut tables, &mut reducers, raw_outboxes, &mut validator.core)?; attach_cache_policies_to_tables(&mut tables, def.table_cache_policies())?; @@ -361,6 +387,7 @@ pub fn validate(def: RawModuleDefV10) -> Result { .collect_all_errors()?; let mut module_def = ModuleDef { + local_outbox_tables, // Set by `apply_namespace` below. path: NamespacePath::root(), accessor_path: NamespacePath::root(), @@ -414,10 +441,8 @@ fn resolve_namespace_ident( case_policy: ValidationCase, explicit_names: &ExplicitNamesLookup, ) -> Result { - let canonical = match explicit_names.namespaces.get(source) { - Some(canonical) => canonical.clone(), - None => convert(source.clone(), case_policy).into(), - }; + let canonical = + super::names::canonical_name_with_override(source.as_ref(), explicit_names.namespaces.get(source), case_policy); Identifier::new(canonical).map_err(|error| ValidationError::IdentifierError { error }.into()) } diff --git a/crates/schema/src/def/validate/v9.rs b/crates/schema/src/def/validate/v9.rs index 3066e0d23e4..3672f85171e 100644 --- a/crates/schema/src/def/validate/v9.rs +++ b/crates/schema/src/def/validate/v9.rs @@ -1,3 +1,4 @@ +use super::names::{canonical_name_with_override, canonical_parameter_names}; use crate::def::validate::v10::{ExplicitNamesLookup, ValidationCase}; use crate::def::*; use crate::error::{RawColumnName, ValidationError}; @@ -154,6 +155,7 @@ pub fn validate(def: RawModuleDefV9) -> Result { let typespace_for_generate = typespace_for_generate.finish(); let mut module_def = ModuleDef { + local_outbox_tables: Default::default(), // V9 has no submodules, so every def is at the root. path: NamespacePath::root(), accessor_path: NamespacePath::root(), @@ -633,11 +635,8 @@ impl CoreValidator<'_> { source: RawIdentifier, lookup: &HashMap, ) -> Result { - if let Some(canonical_name) = lookup.get(&source) { - Identifier::new(canonical_name.clone()).map_err(|error| ValidationError::IdentifierError { error }.into()) - } else { - self.resolve_identifier_with_case(source) - } + let canonical = canonical_name_with_override(source.as_ref(), lookup.get(&source), self.case_policy); + identifier(canonical) } pub(crate) fn resolve_table_ident(&self, source: RawIdentifier) -> Result { @@ -680,12 +679,13 @@ impl CoreValidator<'_> { params .elements .iter() + // Retain raw parameters for error locations and typespace references while + // resolving the names used by codegen and reducer signature hashing. + .zip(canonical_parameter_names(params, self.case_policy)) .enumerate() - .map(|(position, param)| { + .map(|(position, (param, canonical_name))| { let location = || make_type_location(position, param.name().cloned()); - let param_name = param - .name() - .cloned() + let param_name = canonical_name .ok_or_else(|| { ValidationError::ClientCodegenError { location: location(), @@ -693,7 +693,7 @@ impl CoreValidator<'_> { } .into() }) - .and_then(|s| self.resolve_identifier_with_case(s)); + .and_then(identifier); let ty_use = self.validate_for_type_use(location, ¶m.algebraic_type); (param_name, ty_use).combine_errors() }) @@ -1453,7 +1453,7 @@ pub fn generate_unique_constraint_name( // Identifier::new(name).map_err(|error| ValidationError::IdentifierError { error }.into()) //} pub(crate) fn convert(identifier: RawIdentifier, policy: ValidationCase) -> String { - spacetimedb_lib::db::names::canonical_name(identifier.as_ref(), policy) + super::names::canonical_name(identifier.as_ref(), policy) } /// Check that every [`ScheduleDef`]'s `function_name` refers to a real reducer or procedure diff --git a/crates/schema/src/error.rs b/crates/schema/src/error.rs index 4e7f673d5db..91deb269485 100644 --- a/crates/schema/src/error.rs +++ b/crates/schema/src/error.rs @@ -158,6 +158,11 @@ pub enum ValidationError { DuplicateOutbox { table: Identifier }, #[error("outbox table {} not found", table_name)] MissingOutboxTable { table_name: RawIdentifier }, + #[error("local receiver reducer {reducer_name} for outbox {table_name} does not exist")] + MissingLocalOutboxReducer { + table_name: RawIdentifier, + reducer_name: RawIdentifier, + }, #[error("on_result reducer {reducer_name} for outbox {table} does not exist")] MissingOutboxOnResult { table: Identifier, diff --git a/crates/smoketests/modules/Cargo.lock b/crates/smoketests/modules/Cargo.lock index ce9d2b6906a..ef8c15e5d30 100644 --- a/crates/smoketests/modules/Cargo.lock +++ b/crates/smoketests/modules/Cargo.lock @@ -122,15 +122,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "cpufeatures" version = "0.2.17" @@ -166,7 +157,7 @@ version = "0.99.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" dependencies = [ - "convert_case 0.4.0", + "convert_case", "proc-macro2", "quote", "rustc_version", @@ -1254,7 +1245,6 @@ version = "2.16.3" dependencies = [ "anyhow", "blake3", - "convert_case 0.6.0", "derive_more", "hex", "spacetimedb-bindings-macro", @@ -1349,12 +1339,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" -[[package]] -name = "unicode-segmentation" -version = "1.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" - [[package]] name = "uuid" version = "1.20.0" From fd3b5a9d8fd71b87177b41bf15ff0d140dd08a0a Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Sat, 28 Nov 2026 12:48:13 +0530 Subject: [PATCH 09/11] TypeScript Async IDC: local outboxes without receiver bindings A TypeScript module can now send to a reducer in its own module without generating receiver bindings for itself. The table declares `outbox: 'local'`, and the receiving reducer names it with `receiverFor`, as `onSchedule` and `onResult` name their tables. Declaring the link on the reducer avoids a type cycle between the table and a reducer that uses the schema containing it. When the schema is built, the receiver's parameters are mapped to columns by name or `.param({ name })` and checked by type. The module emits a `LocalOutboxes` entry with the reducer's source name, and the host resolves the canonical name and signature hash. The section is omitted from modules without a local outbox, so they still load on hosts that predate it. --- .../src/lib/autogen/types.ts | 12 ++ .../src/lib/remote_module.ts | 35 ++++- crates/bindings-typescript/src/lib/schema.ts | 6 + crates/bindings-typescript/src/lib/table.ts | 43 ++++-- .../src/lib/table_schema.ts | 25 ++- .../src/server/idc.test-d.ts | 39 +++++ .../src/server/reducers.ts | 19 +++ .../bindings-typescript/src/server/schema.ts | 79 +++++++++- .../tests/idc_local.test.ts | 144 ++++++++++++++++++ 9 files changed, 375 insertions(+), 27 deletions(-) create mode 100644 crates/bindings-typescript/tests/idc_local.test.ts diff --git a/crates/bindings-typescript/src/lib/autogen/types.ts b/crates/bindings-typescript/src/lib/autogen/types.ts index a85bb1b7644..937580397cf 100644 --- a/crates/bindings-typescript/src/lib/autogen/types.ts +++ b/crates/bindings-typescript/src/lib/autogen/types.ts @@ -336,6 +336,15 @@ export type RawLifeCycleReducerDefV10 = __Infer< typeof RawLifeCycleReducerDefV10 >; +export const RawLocalOutboxDefV10 = __t.object('RawLocalOutboxDefV10', { + tableName: __t.string(), + reducerSourceName: __t.string(), + targetColumn: __t.u16(), + argColumns: __t.array(__t.u16()), + onResultReducer: __t.option(__t.string()), +}); +export type RawLocalOutboxDefV10 = __Infer; + export const RawMigrationDefV10 = __t.object('RawMigrationDefV10', { schemaHash: __t.u256(), name: __t.string(), @@ -439,6 +448,9 @@ export const RawModuleDefV10Section = __t.enum('RawModuleDefV10Section', { get Migrations() { return __t.array(RawMigrationDefV10); }, + get LocalOutboxes() { + return __t.array(RawLocalOutboxDefV10); + }, }); export type RawModuleDefV10Section = __Infer; diff --git a/crates/bindings-typescript/src/lib/remote_module.ts b/crates/bindings-typescript/src/lib/remote_module.ts index 91da8e0bde8..935a5c9eaf7 100644 --- a/crates/bindings-typescript/src/lib/remote_module.ts +++ b/crates/bindings-typescript/src/lib/remote_module.ts @@ -1,4 +1,4 @@ -import type { OutboxMetadata } from './table_schema.ts'; +import type { RemoteOutboxMetadata } from './table_schema.ts'; import { table } from './table.ts'; import { IdentityBuilder, @@ -80,13 +80,12 @@ export function remoteModule< return { reducers: handles, identity, outbox }; } -/** Resolve receiver parameters by name, independently of sender column order. */ -export function makeOutbox( - receiver: RemoteReducer, +/** Check the columns every outbox needs, and return the target column index. */ +export function checkOutboxShape( row: RowBuilder, primaryKey: number[], scheduledOrEvent: boolean -): OutboxMetadata { +): number { const columns = Object.entries(row.row); if (scheduledOrEvent) throw new TypeError('Outbox tables cannot be scheduled or event tables'); @@ -113,7 +112,16 @@ export function makeOutbox( 'Outbox tables require exactly one identity().target() column' ); } - const argColumns = Object.entries(receiver.params).map(([name, type]) => { + return targets[0]; +} + +/** Map receiver parameters to outbox columns by name, in parameter order. */ +export function outboxArgColumns( + params: ElementsObj, + row: RowBuilder +): number[] { + const columns = Object.entries(row.row); + return Object.entries(params).map(([name, type]) => { const matches = columns.flatMap(([key, col], i) => (col.columnMetadata.paramName ?? key) === name ? [i] : [] ); @@ -132,15 +140,26 @@ export function makeOutbox( } return index; }); +} + +/** Resolve receiver parameters by name, independently of sender column order. */ +export function makeOutbox( + receiver: RemoteReducer, + row: RowBuilder, + primaryKey: number[], + scheduledOrEvent: boolean +): RemoteOutboxMetadata { + const targetColumn = checkOutboxShape(row, primaryKey, scheduledOrEvent); + const argColumns = outboxArgColumns(receiver.params, row); const module = receiverModules.get(receiver); - const target = columns[targets[0]][1].typeBuilder; + const target = row.row[Object.keys(row.row)[targetColumn]].typeBuilder; if (module === undefined || identityModules.get(target) !== module) { throw new TypeError( 'Outbox target must use the selected receiver module identity() builder' ); } return { - targetColumn: targets[0], + targetColumn, argColumns, remoteReducer: receiver.name, signatureHash: receiver.signatureHash, diff --git a/crates/bindings-typescript/src/lib/schema.ts b/crates/bindings-typescript/src/lib/schema.ts index 2e06cdcbedf..3b942cd146a 100644 --- a/crates/bindings-typescript/src/lib/schema.ts +++ b/crates/bindings-typescript/src/lib/schema.ts @@ -200,6 +200,7 @@ export class ModuleContext { rowLevelSecurity: [], schedules: [], outboxes: [], + localOutboxes: [], tableCachePolicies: [], procedures: [], views: [], @@ -243,6 +244,11 @@ export class ModuleContext { ); push(module.schedules && { tag: 'Schedules', value: module.schedules }); push(module.outboxes && { tag: 'Outboxes', value: module.outboxes }); + // Hosts that predate local outboxes cannot decode this section, so only + // modules that declare one send it. + if (module.localOutboxes.length > 0) { + push({ tag: 'LocalOutboxes', value: module.localOutboxes }); + } push({ tag: 'TableCachePolicies', value: module.tableCachePolicies }); push( module.lifeCycleReducers && { diff --git a/crates/bindings-typescript/src/lib/table.ts b/crates/bindings-typescript/src/lib/table.ts index 6d970b6a146..2360af2b4a4 100644 --- a/crates/bindings-typescript/src/lib/table.ts +++ b/crates/bindings-typescript/src/lib/table.ts @@ -1,5 +1,5 @@ import type { RemoteReducer } from './remote_module.ts'; -import { makeOutbox } from './remote_module.ts'; +import { checkOutboxShape, makeOutbox } from './remote_module.ts'; import type { ProcedureExport, ReducerExport, t } from '../server/index.ts'; import type { errors } from '../server/errors.ts'; import { @@ -23,7 +23,9 @@ import type { } from './indexes.ts'; import ScheduleAt from './schedule_at.ts'; import type { + LocalOutboxMetadata, OutboxMetadata, + RemoteOutboxMetadata, TableSchema, TableSchedule, } from './table_schema.ts'; @@ -219,12 +221,18 @@ export type TableOpts = { outbox?: undefined; }; -/** Options for an insert-only outbox using a generated receiver handle. */ +/** + * Options for an insert-only outbox. + * + * - `{ receiver }` sends to a generated receiver handle from another module. + * - `'local'` sends to a reducer in this module that names this table with + * `receiverFor`. The target can be any database running this module. + */ export type OutboxTableOpts = Omit< TableOpts, 'outbox' > & { - outbox: { receiver: RemoteReducer }; + outbox: { receiver: RemoteReducer } | 'local'; }; /** @@ -249,10 +257,15 @@ type OptsConstraints | OutboxTableOpts> = // Ordinary TableOpts annotations must keep their existing mutable table API. // OutboxTableOpts requires the discriminator, even when options are widened. -type OptsOutbox = Opts extends { - outbox: object; -} - ? OutboxMetadata +// Widened options that allow either kind still declare an outbox. +type OptsOutbox = Opts extends { outbox: infer Outbox } + ? [Outbox] extends [undefined] + ? undefined + : [Outbox] extends ['local'] + ? LocalOutboxMetadata + : [Outbox] extends [object] + ? RemoteOutboxMetadata + : OutboxMetadata : undefined; /** @@ -537,10 +550,18 @@ export function table< ? { scheduleAtCol, reducer: scheduled } : undefined; - const receiver = opts.outbox?.receiver; - const outbox = receiver - ? makeOutbox(receiver, row, pk, !!scheduled || isEvent) - : undefined; + const scheduledOrEvent = !!scheduled || isEvent; + let outbox: OutboxMetadata | undefined; + if (opts.outbox === 'local') { + // The receiving reducer is not known yet. Schema registration maps its + // parameters to columns once that reducer names this table. + outbox = { + local: true, + targetColumn: checkOutboxShape(row, pk, scheduledOrEvent), + }; + } else if (opts.outbox !== undefined) { + outbox = makeOutbox(opts.outbox.receiver, row, pk, scheduledOrEvent); + } return { outbox: outbox as OptsOutbox, diff --git a/crates/bindings-typescript/src/lib/table_schema.ts b/crates/bindings-typescript/src/lib/table_schema.ts index fb139e3e289..07883f3e24d 100644 --- a/crates/bindings-typescript/src/lib/table_schema.ts +++ b/crates/bindings-typescript/src/lib/table_schema.ts @@ -26,12 +26,33 @@ export type TableSchedule = { reducer: () => UntypedScheduledFunctionExport; }; -/** Outbox metadata before table and callback names are resolved. */ -export type OutboxMetadata = Omit< +/** Metadata for an outbox to a generated receiver handle, before table and callback names are resolved. */ +export type RemoteOutboxMetadata = Omit< RawOutboxDefV10, 'tableName' | 'onResultReducer' >; +/** + * Metadata for an outbox to a reducer in this module. + * + * The receiving reducer names the table with `receiverFor`. The host resolves + * the reducer and computes its signature, so the module sends no hash. + */ +export type LocalOutboxMetadata = { + readonly local: true; + readonly targetColumn: number; +}; + +/** Outbox metadata before table, receiver and callback names are resolved. */ +export type OutboxMetadata = RemoteOutboxMetadata | LocalOutboxMetadata; + +/** Whether outbox metadata is for a local receiver. */ +export function isLocalOutbox( + outbox: OutboxMetadata +): outbox is LocalOutboxMetadata { + return 'local' in outbox; +} + export type ScheduleTableForParams> = HasExactlyOneKnownKey extends true ? Params[keyof Params] extends RowBuilder< diff --git a/crates/bindings-typescript/src/server/idc.test-d.ts b/crates/bindings-typescript/src/server/idc.test-d.ts index 67db9e28805..1b66f4a8693 100644 --- a/crates/bindings-typescript/src/server/idc.test-d.ts +++ b/crates/bindings-typescript/src/server/idc.test-d.ts @@ -195,3 +195,42 @@ db.view( .where(row => row.world.eq(ctx.sender).or(row.admin.ne(ctx.sender))) .build() ); + +// A local outbox sends to a reducer in this module, which names it with receiverFor. +const localPing = table( + { outbox: 'local' }, + { + msgId: t.u64().primaryKey().autoInc(), + target: t.identity().target(), + note: t.string(), + } +); +const localDb = schema({ localPing, ordinary, outbox }); +localDb.reducer({ receiverFor: localPing }, { note: t.string() }, () => {}); +localDb.reducer( + // @ts-expect-error receiverFor requires a local outbox, not an ordinary table. + { receiverFor: ordinary }, + { note: t.string() }, + () => {} +); +localDb.reducer( + // @ts-expect-error receiverFor requires a local outbox, not a remote one. + { receiverFor: outbox }, + { note: t.string() }, + () => {} +); +localDb.reducer( + { onResult: localPing }, + { row: localPing.rowType, result: t.result(t.unit(), t.string()) }, + () => {} +); +localDb.reducer({ to: t.identity() }, (ctx, { to }) => { + ctx.db.localPing.insert({ msgId: 0n, target: to, note: 'hello' }); + ctx.db.localPing.msgId.find(1n); + // @ts-expect-error Local outboxes cannot be updated. + ctx.db.localPing.msgId.update({ msgId: 1n, target: to, note: 'hello' }); + // @ts-expect-error Local outbox rows cannot be deleted. + ctx.db.localPing.delete({ msgId: 1n, target: to, note: 'hello' }); + // @ts-expect-error Local outboxes cannot be cleared. + ctx.db.localPing.clear(); +}); diff --git a/crates/bindings-typescript/src/server/reducers.ts b/crates/bindings-typescript/src/server/reducers.ts index 9261c33f80e..f5cbccca5e9 100644 --- a/crates/bindings-typescript/src/server/reducers.ts +++ b/crates/bindings-typescript/src/server/reducers.ts @@ -5,6 +5,7 @@ import { type UntypedSchemaDef } from '../lib/schema.ts'; import { deepEqual } from '../lib/util.ts'; import { t } from '../lib/type_builders.ts'; import type { + LocalOutboxMetadata, OutboxMetadata, ScheduleTableForParams, UntypedTableSchema, @@ -28,6 +29,12 @@ export interface ReducerOpts { name: string; onSchedule?: ScheduleTableForParams; onResult?: UntypedTableSchema & { readonly outbox: OutboxMetadata }; + /** + * The local outbox table whose rows this reducer receives. The table must be + * declared with `outbox: 'local'`, and its columns must match this reducer's + * parameters by name or by `.param({ name })`. + */ + receiverFor?: UntypedTableSchema & { readonly outbox: LocalOutboxMetadata }; } export type ReducerOptsWithOptionalName = @@ -113,6 +120,18 @@ export function registerReducer( } } + if (opts?.receiverFor) { + if (lifecycle) { + throw new TypeError('A lifecycle reducer cannot receive from an outbox'); + } + // Resolved after all tables and exports are registered. + ctx.pendingLocalOutboxes.push({ + table: opts.receiverFor, + functionName: exportName, + params, + }); + } + if (params.typeName === undefined) { params.typeName = toPascalCase(exportName); } diff --git a/crates/bindings-typescript/src/server/schema.ts b/crates/bindings-typescript/src/server/schema.ts index 60b262a17f3..e6b89b1c68c 100644 --- a/crates/bindings-typescript/src/server/schema.ts +++ b/crates/bindings-typescript/src/server/schema.ts @@ -25,8 +25,18 @@ import { type TablesToSchema, type UntypedSchemaDef, } from '../lib/schema.ts'; -import type { UntypedTableSchema } from '../lib/table_schema.ts'; -import { TypeBuilder, type ColumnBuilder } from '../lib/type_builders.ts'; +import { + isLocalOutbox, + type LocalOutboxMetadata, + type UntypedTableSchema, +} from '../lib/table_schema.ts'; +import { outboxArgColumns } from '../lib/remote_module.ts'; +import { + TypeBuilder, + type ColumnBuilder, + type RowBuilder, + type RowObj, +} from '../lib/type_builders.ts'; import { hasOwn } from '../lib/util.ts'; import { Router, @@ -119,6 +129,14 @@ export class SchemaInner< table: UntypedTableSchema; functionName: string; }[] = []; + /** Local outbox tables in this schema, by source name. */ + localOutboxTables: Map = new Map(); + /** Reducers declared with `receiverFor`, resolved after registration. */ + pendingLocalOutboxes: { + table: UntypedTableSchema; + functionName: string; + params: RowBuilder; + }[] = []; pendingHttpRoutes: PendingHttpRoute[] = []; submoduleDispatchInfos: SubmoduleDispatchInfo[] = []; @@ -214,6 +232,52 @@ export class SchemaInner< } } + /** + * Map each `receiverFor` reducer's parameters to its local outbox's columns. + * The host resolves the reducer's canonical name and signature. + */ + resolveLocalOutboxes() { + const received = new Set(); + for (const { table, functionName, params } of this.pendingLocalOutboxes) { + const names = this.tableSourceNames.get(table); + if (names?.length !== 1) { + throw new TypeError( + 'receiverFor must reference an outbox registered exactly once in this schema' + ); + } + const tableName = names[0]; + if (!this.localOutboxTables.has(tableName)) { + throw new TypeError( + `receiverFor requires a table declared with outbox: 'local', but ${tableName} is not one` + ); + } + if (received.has(tableName)) { + throw new TypeError( + `Local outbox ${tableName} has more than one receiverFor reducer` + ); + } + received.add(tableName); + const outbox = table.outbox as LocalOutboxMetadata; + const columns = Object.fromEntries( + Object.entries(params.row).map(([name, col]) => [name, col.typeBuilder]) + ); + this.moduleDef.localOutboxes.push({ + tableName, + reducerSourceName: functionName, + targetColumn: outbox.targetColumn, + argColumns: outboxArgColumns(columns, table.rowType), + onResultReducer: undefined, + }); + } + for (const tableName of this.localOutboxTables.keys()) { + if (!received.has(tableName)) { + throw new TypeError( + `Local outbox ${tableName} needs a reducer declared with receiverFor: ${tableName}` + ); + } + } + } + resolveOutboxCallbacks() { for (const { table, functionName } of this.pendingOutboxCallbacks) { const names = this.tableSourceNames.get(table); @@ -222,9 +286,9 @@ export class SchemaInner< 'onResult must reference an outbox registered exactly once in this schema' ); } - const outbox = this.moduleDef.outboxes.find( - o => o.tableName === names[0] - ); + const outbox = + this.moduleDef.outboxes.find(o => o.tableName === names[0]) ?? + this.moduleDef.localOutboxes.find(o => o.tableName === names[0]); if (!outbox) throw new TypeError('onResult requires an outbox table'); if ( outbox.onResultReducer !== undefined && @@ -339,6 +403,7 @@ export class Schema implements ModuleDefaultExport { ignoreNonModuleExports: opts?.ignoreNonModuleExports ?? false, }); this.#ctx.resolveSchedules(); + this.#ctx.resolveLocalOutboxes(); this.#ctx.resolveOutboxCallbacks(); return this.#ctx.rawModuleDefV10(); } @@ -1009,7 +1074,9 @@ export function schema< tableSourceNames.push(tableDef.sourceName); } ctx.moduleDef.tables.push(tableDef); - if (table.outbox) { + if (table.outbox && isLocalOutbox(table.outbox)) { + ctx.localOutboxTables.set(tableDef.sourceName, table); + } else if (table.outbox) { ctx.moduleDef.outboxes.push({ ...table.outbox, tableName: tableDef.sourceName, diff --git a/crates/bindings-typescript/tests/idc_local.test.ts b/crates/bindings-typescript/tests/idc_local.test.ts new file mode 100644 index 00000000000..9bc8d01b5cb --- /dev/null +++ b/crates/bindings-typescript/tests/idc_local.test.ts @@ -0,0 +1,144 @@ +import { describe, expect, it } from 'vitest'; +import { table } from '../src/lib/table'; +import { t } from '../src/lib/type_builders'; +import { schema } from '../src/server/schema'; + +function localOutbox() { + return table( + { outbox: 'local' }, + { + msgId: t.u64().primaryKey().autoInc(), + payload: t.string().param({ name: 'body' }), + target: t.identity().target(), + count: t.u32(), + } + ); +} + +describe('local IDC outboxes', () => { + it('sends the receiver source name and maps parameters in reducer order', () => { + const outbox = localOutbox(); + const db = schema({ outbox }); + // The explicit canonical name does not change the source name the host resolves. + const receive = db.reducer( + { name: 'WireReceive', receiverFor: outbox }, + { count: t.u32(), body: t.string() }, + () => {} + ); + const onResult = db.reducer( + { onResult: outbox }, + { row: outbox.rowType, result: t.result(t.unit(), t.string()) }, + () => {} + ); + const raw = db.buildRawModuleDefV10({ receive, onResult }); + expect(raw.sections.find(s => s.tag === 'LocalOutboxes')?.value).toEqual([ + { + tableName: 'outbox', + reducerSourceName: 'receive', + targetColumn: 2, + argColumns: [3, 1], + onResultReducer: 'onResult', + }, + ]); + expect(raw.sections.find(s => s.tag === 'Outboxes')?.value).toEqual([]); + }); + + it('omits the local outbox section from modules without one', () => { + const raw = schema({ + ordinary: table({}, { id: t.u64().primaryKey() }), + }).buildRawModuleDefV10({}); + expect(raw.sections.some(s => s.tag === 'LocalOutboxes')).toBe(false); + }); + + it('supports receivers with no parameters', () => { + const outbox = table( + { outbox: 'local' }, + { + msgId: t.u64().primaryKey().autoInc(), + target: t.identity().target(), + } + ); + const db = schema({ outbox }); + const noop = db.reducer({ name: 'noop', receiverFor: outbox }, () => {}); + const raw = db.buildRawModuleDefV10({ noop }); + expect( + raw.sections.find(s => s.tag === 'LocalOutboxes')?.value[0].argColumns + ).toEqual([]); + }); + + it('requires exactly one receiver for each local outbox', () => { + const outbox = localOutbox(); + expect(() => schema({ outbox }).buildRawModuleDefV10({})).toThrow( + 'Local outbox outbox needs a reducer declared with receiverFor' + ); + + const db = schema({ outbox }); + const params = { body: t.string(), count: t.u32() }; + const first = db.reducer({ receiverFor: outbox }, params, () => {}); + const second = db.reducer({ receiverFor: outbox }, params, () => {}); + expect(() => db.buildRawModuleDefV10({ first, second })).toThrow( + 'more than one receiverFor reducer' + ); + }); + + it('rejects receiver parameters without a matching column', () => { + const outbox = localOutbox(); + const missing = schema({ outbox }); + const receive = missing.reducer( + { receiverFor: outbox }, + { body: t.string(), count: t.u32(), extra: t.bool() }, + () => {} + ); + expect(() => missing.buildRawModuleDefV10({ receive })).toThrow( + "exactly one column for receiver parameter 'extra'" + ); + + const wrongType = schema({ outbox }); + const typed = wrongType.reducer( + { receiverFor: outbox }, + { body: t.string(), count: t.u64() }, + () => {} + ); + expect(() => wrongType.buildRawModuleDefV10({ typed })).toThrow( + "Outbox column for 'count' has the wrong type" + ); + }); + + it('rejects a receiverFor table that is not a local outbox', () => { + const ordinary = table({}, { id: t.u64().primaryKey() }); + const db = schema({ ordinary }); + const receive = db.reducer( + // @ts-expect-error receiverFor requires a local outbox table. + { receiverFor: ordinary }, + { id: t.u64() }, + () => {} + ); + expect(() => db.buildRawModuleDefV10({ receive })).toThrow( + "receiverFor requires a table declared with outbox: 'local'" + ); + }); + + it('rejects a lifecycle receiver', () => { + const outbox = localOutbox(); + const db = schema({ outbox }); + const init = db.init({ name: 'init', receiverFor: outbox }, () => {}); + expect(() => db.buildRawModuleDefV10({ init })).toThrow( + 'A lifecycle reducer cannot receive from an outbox' + ); + }); + + it('checks the outbox shape when the table is declared', () => { + expect(() => + table( + { outbox: 'local' }, + { id: t.u64().primaryKey(), target: t.identity().target() } + ) + ).toThrow('u64 primary key with autoInc()'); + expect(() => + table( + { outbox: 'local' }, + { msgId: t.u64().primaryKey().autoInc(), target: t.identity() } + ) + ).toThrow('exactly one identity().target() column'); + }); +}); From 90a4bc8a07d63dcf9a5b8978cd225e265f13042b Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Fri, 27 Nov 2026 18:57:22 +0530 Subject: [PATCH 10/11] C# Async IDC: local outboxes without receiver bindings A C# outbox table can now call a reducer of its own module. Set Outbox to the class declaring the reducer and OutboxReducer to its name: [Table(Accessor = "PingOutbox", Outbox = typeof(Module), OutboxReducer = nameof(Module.ReceivePing))] [Outbox(typeof(Module), ReducerName = nameof(Module.ReceivePing))] declares the columns the same way it does for receiver bindings. The generator checks the columns against the reducer's parameters at compile time, as it does for generated receivers, and emits a RawLocalOutboxDefV10 with the reducer's source name and the argument columns in parameter order. The host resolves the name and computes the signature hash, so the module computes no hash. A local outbox's target column is a SpacetimeDB.Identity, and [OnResult] works as for remote outboxes. --- .../Codegen.Tests/fixtures/diag/Lib.cs | 63 + .../ExtraCompilationErrors.net10.verified.txt | 12 +- .../diag/snapshots/Module#FFI.verified.cs | 3267 ++++++++++++---- ...Module#LocalOutboxDiag.Receive.verified.cs | 16 + ...dule#TestLocalOutboxBadReducer.verified.cs | 119 + ...le#TestLocalOutboxColumnIssues.verified.cs | 119 + .../snapshots/Module.net10#FFI.verified.cs | 3392 +++++++++++++---- ....net10#LocalOutboxDiag.Receive.verified.cs | 23 + ...et10#TestLocalOutboxBadReducer.verified.cs | 119 + ...10#TestLocalOutboxColumnIssues.verified.cs | 119 + .../diag/snapshots/Module.net10.verified.txt | 198 +- .../diag/snapshots/Module.verified.txt | 198 +- .../Codegen.Tests/fixtures/server/Lib.cs | 67 + .../server/snapshots/Module#FFI.verified.cs | 931 ++++- ...tboxReducers.OnLocalPingResult.verified.cs | 25 + ...utboxReducers.ReceiveLocalPing.verified.cs | 19 + ...alOutboxReducers.SendLocalPing.verified.cs | 18 + .../Module#LocalPingGeneratedRow.verified.cs | 127 + .../snapshots/Module#LocalPingRow.verified.cs | 117 + .../snapshots/Module.net10#FFI.verified.cs | 956 ++++- ...tboxReducers.OnLocalPingResult.verified.cs | 26 + ...utboxReducers.ReceiveLocalPing.verified.cs | 26 + ...alOutboxReducers.SendLocalPing.verified.cs | 21 + ...le.net10#LocalPingGeneratedRow.verified.cs | 127 + .../Module.net10#LocalPingRow.verified.cs | 117 + .../Module.net10.wasm#FFI.verified.cs | 1133 +++++- ...tboxReducers.OnLocalPingResult.verified.cs | 73 + ...utboxReducers.ReceiveLocalPing.verified.cs | 67 + ...alOutboxReducers.SendLocalPing.verified.cs | 60 + ...t10.wasm#LocalPingGeneratedRow.verified.cs | 127 + ...Module.net10.wasm#LocalPingRow.verified.cs | 117 + crates/bindings-csharp/Codegen/Module.cs | 232 +- crates/bindings-csharp/Runtime/Attrs.cs | 18 +- .../Runtime/Internal/ModuleBuilder.cs | 12 + 34 files changed, 10525 insertions(+), 1536 deletions(-) create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#LocalOutboxDiag.Receive.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxBadReducer.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxColumnIssues.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#LocalOutboxDiag.Receive.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxBadReducer.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxColumnIssues.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.OnLocalPingResult.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.ReceiveLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.SendLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingGeneratedRow.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingRow.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.OnLocalPingResult.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.ReceiveLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.SendLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingGeneratedRow.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingRow.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.OnLocalPingResult.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.ReceiveLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.SendLocalPing.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingGeneratedRow.verified.cs create mode 100644 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingRow.verified.cs diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs index 5c5da44e4f2..8a5b2b4e3e6 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs @@ -851,6 +851,69 @@ public partial struct TestOutboxParamIssues public string? Extra; } +public static partial class LocalOutboxDiag +{ + [SpacetimeDB.Reducer] + public static void Receive(ReducerContext ctx, string name, int count) { } + + public static void NotAReducer(ReducerContext ctx, string name) { } +} + +// No such reducer; a method without [Reducer]; a lifecycle reducer; receiver bindings with +// OutboxReducer; OutboxReducer without Outbox. +[SpacetimeDB.Table( + Accessor = "LocalOutboxMissingReducer", + Outbox = typeof(LocalOutboxDiag), + OutboxReducer = "Missing" +)] +[SpacetimeDB.Table( + Accessor = "LocalOutboxNotAReducer", + Outbox = typeof(LocalOutboxDiag), + OutboxReducer = nameof(LocalOutboxDiag.NotAReducer) +)] +[SpacetimeDB.Table( + Accessor = "LocalOutboxLifecycle", + Outbox = typeof(OnResultIssues), + OutboxReducer = nameof(OnResultIssues.LifecycleResult) +)] +[SpacetimeDB.Table( + Accessor = "LocalOutboxWithBindings", + Outbox = typeof(OutboxDiag.Reducers.Remote), + OutboxReducer = "Remote" +)] +[SpacetimeDB.Table(Accessor = "LocalOutboxWithoutOutbox", OutboxReducer = "Receive")] +public partial struct TestLocalOutboxBadReducer +{ + [SpacetimeDB.PrimaryKey] + [SpacetimeDB.AutoInc] + public ulong MsgId; + + [SpacetimeDB.Target] + public Identity Target; + + public string Name; + public int Count; +} + +[SpacetimeDB.Table( + Accessor = "LocalOutboxColumnIssues", + Outbox = typeof(LocalOutboxDiag), + OutboxReducer = nameof(LocalOutboxDiag.Receive) +)] +public partial struct TestLocalOutboxColumnIssues +{ + [SpacetimeDB.PrimaryKey] + [SpacetimeDB.AutoInc] + public ulong MsgId; + + // A local outbox's target is a SpacetimeDB.Identity. + [SpacetimeDB.Target] + public OutboxDiag.Identity Target; + + // `count` is an int, and there's no column for `name`. + public uint Count; +} + [SpacetimeDB.Table] public partial struct TestOutboxAttributesWithoutOutbox { diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.net10.verified.txt b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.net10.verified.txt index b9e27966970..2af37f0ee95 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.net10.verified.txt +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.net10.verified.txt @@ -350,7 +350,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1214)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1412)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1428)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1626)]', Severity: Error, Descriptor: { Id: CS0121, @@ -373,7 +373,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1214)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1412)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1428)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.AssemblyDescriptor.Queries.TestDuplicateTableName() [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1626)]', Severity: Error, Descriptor: { Id: CS0121, @@ -396,7 +396,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1192)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1390)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1406)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1604)]', Severity: Error, Descriptor: { Id: CS0121, @@ -419,7 +419,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1192)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1390)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1406)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameCols.TestDuplicateTableNameCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1604)]', Severity: Error, Descriptor: { Id: CS0121, @@ -442,7 +442,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1202)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1400)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1416)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1614)]', Severity: Error, Descriptor: { Id: CS0121, @@ -465,7 +465,7 @@ public partial struct TestDefaultFieldValues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ } */ - Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1202)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1400)]', + Message: The call is ambiguous between the following methods or properties: 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1416)]' and 'SpacetimeDB.Generated.diag_4F830E2879BB50E3.TestDuplicateTableNameIxCols.TestDuplicateTableNameIxCols(SpacetimeDB.SqlTableName) [{ProjectDirectory}fixtures/diag/SpacetimeDB.Codegen/SpacetimeDB.Codegen.Module/FFI.cs(1614)]', Severity: Error, Descriptor: { Id: CS0121, diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#FFI.verified.cs index 411770b2840..03cb7aff1c4 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#FFI.verified.cs @@ -309,6 +309,349 @@ public readonly partial struct QueryBuilder ); } + public readonly struct LocalOutboxMissingReducerCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxMissingReducerCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxMissingReducerIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxMissingReducerIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() => + new( + "LocalOutboxMissingReducer", + new LocalOutboxMissingReducerCols("LocalOutboxMissingReducer"), + new LocalOutboxMissingReducerIxCols("LocalOutboxMissingReducer") + ); + } + + public readonly struct LocalOutboxNotAReducerCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxNotAReducerCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxNotAReducerIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxNotAReducerIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() => + new( + "LocalOutboxNotAReducer", + new LocalOutboxNotAReducerCols("LocalOutboxNotAReducer"), + new LocalOutboxNotAReducerIxCols("LocalOutboxNotAReducer") + ); + } + + public readonly struct LocalOutboxLifecycleCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxLifecycleCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxLifecycleIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxLifecycleIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() => + new( + "LocalOutboxLifecycle", + new LocalOutboxLifecycleCols("LocalOutboxLifecycle"), + new LocalOutboxLifecycleIxCols("LocalOutboxLifecycle") + ); + } + + public readonly struct LocalOutboxWithBindingsCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxWithBindingsCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxWithBindingsIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxWithBindingsIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() => + new( + "LocalOutboxWithBindings", + new LocalOutboxWithBindingsCols("LocalOutboxWithBindings"), + new LocalOutboxWithBindingsIxCols("LocalOutboxWithBindings") + ); + } + + public readonly struct LocalOutboxWithoutOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxWithoutOutboxCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxWithoutOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxWithoutOutboxIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() => + new( + "LocalOutboxWithoutOutbox", + new LocalOutboxWithoutOutboxCols("LocalOutboxWithoutOutbox"), + new LocalOutboxWithoutOutboxIxCols("LocalOutboxWithoutOutbox") + ); + } + + public readonly struct LocalOutboxColumnIssuesCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxColumnIssues, + OutboxDiag.Identity + > Target; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxColumnIssuesCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxColumnIssues, + OutboxDiag.Identity + >(tableName, "Target"); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxColumnIssuesIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxColumnIssuesIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() => + new( + "LocalOutboxColumnIssues", + new LocalOutboxColumnIssuesCols("LocalOutboxColumnIssues"), + new LocalOutboxColumnIssuesIxCols("LocalOutboxColumnIssues") + ); + } + public readonly struct TableAndOutboxCols { internal TableAndOutboxCols(string tableName) { } @@ -1439,6 +1782,18 @@ internal HandlerTxContext(Internal.TxContext inner) public sealed class Local : global::SpacetimeDB.LocalBase { + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEqualsParam OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEventAndScheduled OutboxEventAndScheduled => @@ -1515,7 +1870,7 @@ public static partial class AssemblyDescriptor public const string RootOnlyDeclarations = "row-level security filters, lifecycle reducer OnResultIssues.LifecycleResult (ClientConnected), lifecycle reducer Reducers.TestDuplicateReducerKind1 (Init), lifecycle reducer Reducers.TestDuplicateReducerKind2 (Init)"; public const string OutboxTables = ""; - public const int ReducerCount = 14; + public const int ReducerCount = 15; public const int ProcedureCount = 0; public const int HttpHandlerCount = 0; public const int ViewCount = 12; @@ -1648,6 +2003,18 @@ public Tables(global::SpacetimeDB.Internal.Local? db) __instanceId = global::SpacetimeDB.Internal.Module.GetInstanceId(db); } + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEqualsParam OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEventAndScheduled OutboxEventAndScheduled => @@ -1700,6 +2067,18 @@ public ReadOnlyTables(global::SpacetimeDB.Internal.LocalReadOnly? db) __instanceId = global::SpacetimeDB.Internal.Module.GetInstanceId(db); } + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEventAndScheduledReadOnly OutboxEventAndScheduled => @@ -1760,6 +2139,18 @@ public static class LocalTableExtensions { extension(global::SpacetimeDB.Local db) { + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEqualsParam OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.TableHandles.OutboxEventAndScheduled OutboxEventAndScheduled => @@ -1808,6 +2199,18 @@ public static class ReadOnlyTableExtensions { extension(global::SpacetimeDB.Internal.LocalReadOnly db) { + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEventAndScheduledReadOnly OutboxEventAndScheduled => @@ -2406,26 +2809,62 @@ public static partial class QueryTableExtensions } } - public readonly struct TableAndOutboxCols + public readonly struct LocalOutboxMissingReducerCols { - internal TableAndOutboxCols(global::SpacetimeDB.SqlTableName tableName) { } - } + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - public readonly struct TableAndOutboxIxCols + internal LocalOutboxMissingReducerCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxMissingReducerIxCols { - internal TableAndOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxMissingReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TableAndOutboxSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxMissingReducerSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TableAndOutboxSqlName(int contextInstance) + private static global::SpacetimeDB.SqlTableName LocalOutboxMissingReducerSqlName( + int contextInstance + ) { - var names = TableAndOutboxSqlNames; + var names = LocalOutboxMissingReducerSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2435,7 +2874,10 @@ public static partial class AssemblyDescriptor "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "TableAndOutbox"); + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalOutboxMissingReducer" + ); names[contextInstance] = resolvedName; return resolvedName; } @@ -2443,16 +2885,16 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxAndTable, - TableAndOutboxCols, - TableAndOutboxIxCols - > TableAndOutbox() + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() { - var tableName = TableAndOutboxSqlName(__instanceId); + var tableName = LocalOutboxMissingReducerSqlName(__instanceId); return new( tableName, - new TableAndOutboxCols(tableName), - new TableAndOutboxIxCols(tableName) + new LocalOutboxMissingReducerCols(tableName), + new LocalOutboxMissingReducerIxCols(tableName) ); } } @@ -2463,55 +2905,70 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxAndTable, - TableAndOutboxCols, - TableAndOutboxIxCols - > TableAndOutbox() => new AssemblyDescriptor.Queries(from).TableAndOutbox(); + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() => + new AssemblyDescriptor.Queries(from).LocalOutboxMissingReducer(); } } - public readonly struct TestOutboxAttributesWithoutOutboxCols + public readonly struct LocalOutboxNotAReducerCols { + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, - string - > Name; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal TestOutboxAttributesWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); Target = new global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity >(tableName, "Target"); - Name = new global::SpacetimeDB.Col( + Name = new global::SpacetimeDB.Col( tableName, "Name" ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); } } - public readonly struct TestOutboxAttributesWithoutOutboxIxCols + public readonly struct LocalOutboxNotAReducerIxCols { - internal TestOutboxAttributesWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) - { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestOutboxAttributesWithoutOutboxSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxNotAReducerSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestOutboxAttributesWithoutOutboxSqlName( + private static global::SpacetimeDB.SqlTableName LocalOutboxNotAReducerSqlName( int contextInstance ) { - var names = TestOutboxAttributesWithoutOutboxSqlNames; + var names = LocalOutboxNotAReducerSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2523,7 +2980,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "TestOutboxAttributesWithoutOutbox" + "LocalOutboxNotAReducer" ); names[contextInstance] = resolvedName; return resolvedName; @@ -2532,16 +2989,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxAttributesWithoutOutbox, - TestOutboxAttributesWithoutOutboxCols, - TestOutboxAttributesWithoutOutboxIxCols - > TestOutboxAttributesWithoutOutbox() + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() { - var tableName = TestOutboxAttributesWithoutOutboxSqlName(__instanceId); + var tableName = LocalOutboxNotAReducerSqlName(__instanceId); return new( tableName, - new TestOutboxAttributesWithoutOutboxCols(tableName), - new TestOutboxAttributesWithoutOutboxIxCols(tableName) + new LocalOutboxNotAReducerCols(tableName), + new LocalOutboxNotAReducerIxCols(tableName) ); } } @@ -2552,42 +3009,52 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxAttributesWithoutOutbox, - TestOutboxAttributesWithoutOutboxCols, - TestOutboxAttributesWithoutOutboxIxCols - > TestOutboxAttributesWithoutOutbox() => - new AssemblyDescriptor.Queries(from).TestOutboxAttributesWithoutOutbox(); + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() => + new AssemblyDescriptor.Queries(from).LocalOutboxNotAReducer(); } } - public readonly struct OutboxNotAReducerCols + public readonly struct LocalOutboxLifecycleCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxBadReceiver, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal OutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxLifecycleCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxBadReceiver, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); } } - public readonly struct OutboxNotAReducerIxCols + public readonly struct LocalOutboxLifecycleIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxLifecycleIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -2596,16 +3063,16 @@ internal OutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxNotAReducerSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxLifecycleSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxNotAReducerSqlName( + private static global::SpacetimeDB.SqlTableName LocalOutboxLifecycleSqlName( int contextInstance ) { - var names = OutboxNotAReducerSqlNames; + var names = LocalOutboxLifecycleSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2615,7 +3082,10 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNotAReducer"); + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalOutboxLifecycle" + ); names[contextInstance] = resolvedName; return resolvedName; } @@ -2623,16 +3093,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxBadReceiver, - OutboxNotAReducerCols, - OutboxNotAReducerIxCols - > OutboxNotAReducer() + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() { - var tableName = OutboxNotAReducerSqlName(__instanceId); + var tableName = LocalOutboxLifecycleSqlName(__instanceId); return new( tableName, - new OutboxNotAReducerCols(tableName), - new OutboxNotAReducerIxCols(tableName) + new LocalOutboxLifecycleCols(tableName), + new LocalOutboxLifecycleIxCols(tableName) ); } } @@ -2643,35 +3113,69 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxBadReceiver, - OutboxNotAReducerCols, - OutboxNotAReducerIxCols - > OutboxNotAReducer() => new AssemblyDescriptor.Queries(from).OutboxNotAReducer(); + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() => new AssemblyDescriptor.Queries(from).LocalOutboxLifecycle(); } } - public readonly struct OutboxEqualsParamCols + public readonly struct LocalOutboxWithBindingsCols { - internal OutboxEqualsParamCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxWithBindingsCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } } - public readonly struct OutboxEqualsParamIxCols + public readonly struct LocalOutboxWithBindingsIxCols { - internal OutboxEqualsParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxWithBindingsIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxEqualsParamSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxWithBindingsSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxEqualsParamSqlName( + private static global::SpacetimeDB.SqlTableName LocalOutboxWithBindingsSqlName( int contextInstance ) { - var names = OutboxEqualsParamSqlNames; + var names = LocalOutboxWithBindingsSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2681,7 +3185,10 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxEqualsParam"); + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalOutboxWithBindings" + ); names[contextInstance] = resolvedName; return resolvedName; } @@ -2689,16 +3196,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxEqualsParam, - OutboxEqualsParamCols, - OutboxEqualsParamIxCols - > OutboxEqualsParam() + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() { - var tableName = OutboxEqualsParamSqlName(__instanceId); + var tableName = LocalOutboxWithBindingsSqlName(__instanceId); return new( tableName, - new OutboxEqualsParamCols(tableName), - new OutboxEqualsParamIxCols(tableName) + new LocalOutboxWithBindingsCols(tableName), + new LocalOutboxWithBindingsIxCols(tableName) ); } } @@ -2709,64 +3216,52 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxEqualsParam, - OutboxEqualsParamCols, - OutboxEqualsParamIxCols - > OutboxEqualsParam() => new AssemblyDescriptor.Queries(from).OutboxEqualsParam(); + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() => + new AssemblyDescriptor.Queries(from).LocalOutboxWithBindings(); } } - public readonly struct OutboxEventAndScheduledCols + public readonly struct LocalOutboxWithoutOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - SpacetimeDB.ScheduleAt - > At; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal OutboxEventAndScheduledCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity >(tableName, "Target"); - At = new global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - SpacetimeDB.ScheduleAt - >(tableName, "At"); - Name = new global::SpacetimeDB.Col( + Name = new global::SpacetimeDB.Col( tableName, "Name" ); - Count = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, "Count" ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxEventAndScheduledIxCols + public readonly struct LocalOutboxWithoutOutboxIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxEventAndScheduledIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -2775,16 +3270,16 @@ internal OutboxEventAndScheduledIxCols(global::SpacetimeDB.SqlTableName tableNam public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxEventAndScheduledSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxWithoutOutboxSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxEventAndScheduledSqlName( + private static global::SpacetimeDB.SqlTableName LocalOutboxWithoutOutboxSqlName( int contextInstance ) { - var names = OutboxEventAndScheduledSqlNames; + var names = LocalOutboxWithoutOutboxSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2796,7 +3291,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "OutboxEventAndScheduled" + "LocalOutboxWithoutOutbox" ); names[contextInstance] = resolvedName; return resolvedName; @@ -2805,16 +3300,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxEventAndScheduled, - OutboxEventAndScheduledCols, - OutboxEventAndScheduledIxCols - > OutboxEventAndScheduled() + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() { - var tableName = OutboxEventAndScheduledSqlName(__instanceId); + var tableName = LocalOutboxWithoutOutboxSqlName(__instanceId); return new( tableName, - new OutboxEventAndScheduledCols(tableName), - new OutboxEventAndScheduledIxCols(tableName) + new LocalOutboxWithoutOutboxCols(tableName), + new LocalOutboxWithoutOutboxIxCols(tableName) ); } } @@ -2825,68 +3320,47 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxEventAndScheduled, - OutboxEventAndScheduledCols, - OutboxEventAndScheduledIxCols - > OutboxEventAndScheduled() => - new AssemblyDescriptor.Queries(from).OutboxEventAndScheduled(); + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() => + new AssemblyDescriptor.Queries(from).LocalOutboxWithoutOutbox(); } } - public readonly struct OutboxNoAutoIncCols + public readonly struct LocalOutboxColumnIssuesCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxColumnIssues, OutboxDiag.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + public readonly global::SpacetimeDB.Col Count; - internal OutboxNoAutoIncCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxColumnIssuesCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxColumnIssues, OutboxDiag.Identity >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - Count = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, "Count" ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxNoAutoIncIxCols + public readonly struct LocalOutboxColumnIssuesIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxNoAutoIncIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxColumnIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -2895,14 +3369,16 @@ internal OutboxNoAutoIncIxCols(global::SpacetimeDB.SqlTableName tableName) public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxNoAutoIncSqlNames => + private static global::SpacetimeDB.SqlTableName?[] LocalOutboxColumnIssuesSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxNoAutoIncSqlName(int contextInstance) + private static global::SpacetimeDB.SqlTableName LocalOutboxColumnIssuesSqlName( + int contextInstance + ) { - var names = OutboxNoAutoIncSqlNames; + var names = LocalOutboxColumnIssuesSqlNames; if (names[contextInstance] is { } name) { return name; @@ -2912,7 +3388,10 @@ public static partial class AssemblyDescriptor "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNoAutoInc"); + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalOutboxColumnIssues" + ); names[contextInstance] = resolvedName; return resolvedName; } @@ -2920,16 +3399,16 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoAutoIncCols, - OutboxNoAutoIncIxCols - > OutboxNoAutoInc() + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() { - var tableName = OutboxNoAutoIncSqlName(__instanceId); + var tableName = LocalOutboxColumnIssuesSqlName(__instanceId); return new( tableName, - new OutboxNoAutoIncCols(tableName), - new OutboxNoAutoIncIxCols(tableName) + new LocalOutboxColumnIssuesCols(tableName), + new LocalOutboxColumnIssuesIxCols(tableName) ); } } @@ -2940,83 +3419,34 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoAutoIncCols, - OutboxNoAutoIncIxCols - > OutboxNoAutoInc() => new AssemblyDescriptor.Queries(from).OutboxNoAutoInc(); + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() => + new AssemblyDescriptor.Queries(from).LocalOutboxColumnIssues(); } } - public readonly struct OutboxNoTargetCols + public readonly struct TableAndOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; - - internal OutboxNoTargetCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.Col( - tableName, - "MsgId" - ); - Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - Count = new global::SpacetimeDB.Col( - tableName, - "Count" - ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); - } + internal TableAndOutboxCols(global::SpacetimeDB.SqlTableName tableName) { } } - public readonly struct OutboxNoTargetIxCols + public readonly struct TableAndOutboxIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; - - internal OutboxNoTargetIxCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.IxCol( - tableName, - "MsgId" - ); - } + internal TableAndOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxNoTargetSqlNames => + private static global::SpacetimeDB.SqlTableName?[] TableAndOutboxSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxNoTargetSqlName(int contextInstance) + private static global::SpacetimeDB.SqlTableName TableAndOutboxSqlName(int contextInstance) { - var names = OutboxNoTargetSqlNames; + var names = TableAndOutboxSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3026,7 +3456,7 @@ public static partial class AssemblyDescriptor "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNoTarget"); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "TableAndOutbox"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3034,16 +3464,16 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoTargetCols, - OutboxNoTargetIxCols - > OutboxNoTarget() + global::TestOutboxAndTable, + TableAndOutboxCols, + TableAndOutboxIxCols + > TableAndOutbox() { - var tableName = OutboxNoTargetSqlName(__instanceId); + var tableName = TableAndOutboxSqlName(__instanceId); return new( tableName, - new OutboxNoTargetCols(tableName), - new OutboxNoTargetIxCols(tableName) + new TableAndOutboxCols(tableName), + new TableAndOutboxIxCols(tableName) ); } } @@ -3054,85 +3484,55 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoTargetCols, - OutboxNoTargetIxCols - > OutboxNoTarget() => new AssemblyDescriptor.Queries(from).OutboxNoTarget(); + global::TestOutboxAndTable, + TableAndOutboxCols, + TableAndOutboxIxCols + > TableAndOutbox() => new AssemblyDescriptor.Queries(from).TableAndOutbox(); } } - public readonly struct OutboxWrongTargetTypeCols + public readonly struct TestOutboxAttributesWithoutOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity + global::TestOutboxAttributesWithoutOutbox, + SpacetimeDB.Identity > Target; public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + global::TestOutboxAttributesWithoutOutbox, + string + > Name; - internal OutboxWrongTargetTypeCols(global::SpacetimeDB.SqlTableName tableName) + internal TestOutboxAttributesWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( - tableName, - "MsgId" - ); Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestOutboxAttributesWithoutOutbox, SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( tableName, "Name" ); - Count = new global::SpacetimeDB.Col( - tableName, - "Count" - ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxWrongTargetTypeIxCols + public readonly struct TestOutboxAttributesWithoutOutboxIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; - - internal OutboxWrongTargetTypeIxCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.IxCol( - tableName, - "MsgId" - ); - } + internal TestOutboxAttributesWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) + { } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxWrongTargetTypeSqlNames => + private static global::SpacetimeDB.SqlTableName?[] TestOutboxAttributesWithoutOutboxSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxWrongTargetTypeSqlName( + private static global::SpacetimeDB.SqlTableName TestOutboxAttributesWithoutOutboxSqlName( int contextInstance ) { - var names = OutboxWrongTargetTypeSqlNames; + var names = TestOutboxAttributesWithoutOutboxSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3144,7 +3544,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "OutboxWrongTargetType" + "TestOutboxAttributesWithoutOutbox" ); names[contextInstance] = resolvedName; return resolvedName; @@ -3153,16 +3553,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxWrongTargetTypeCols, - OutboxWrongTargetTypeIxCols - > OutboxWrongTargetType() + global::TestOutboxAttributesWithoutOutbox, + TestOutboxAttributesWithoutOutboxCols, + TestOutboxAttributesWithoutOutboxIxCols + > TestOutboxAttributesWithoutOutbox() { - var tableName = OutboxWrongTargetTypeSqlName(__instanceId); + var tableName = TestOutboxAttributesWithoutOutboxSqlName(__instanceId); return new( tableName, - new OutboxWrongTargetTypeCols(tableName), - new OutboxWrongTargetTypeIxCols(tableName) + new TestOutboxAttributesWithoutOutboxCols(tableName), + new TestOutboxAttributesWithoutOutboxIxCols(tableName) ); } } @@ -3173,62 +3573,42 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxWrongTargetTypeCols, - OutboxWrongTargetTypeIxCols - > OutboxWrongTargetType() => - new AssemblyDescriptor.Queries(from).OutboxWrongTargetType(); + global::TestOutboxAttributesWithoutOutbox, + TestOutboxAttributesWithoutOutboxCols, + TestOutboxAttributesWithoutOutboxIxCols + > TestOutboxAttributesWithoutOutbox() => + new AssemblyDescriptor.Queries(from).TestOutboxAttributesWithoutOutbox(); } } - public readonly struct OutboxParamIssuesCols + public readonly struct OutboxNotAReducerCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxParamIssues, + global::TestOutboxBadReceiver, OutboxDiag.Identity > Target; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Nickname; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Extra; - internal OutboxParamIssuesCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxParamIssues, + global::TestOutboxBadReceiver, OutboxDiag.Identity >(tableName, "Target"); - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - Nickname = new global::SpacetimeDB.Col( - tableName, - "Nickname" - ); - Count = new global::SpacetimeDB.Col( - tableName, - "Count" - ); - Extra = new global::SpacetimeDB.Col( - tableName, - "Extra" - ); } } - public readonly struct OutboxParamIssuesIxCols + public readonly struct OutboxNotAReducerIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxParamIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -3237,16 +3617,16 @@ internal OutboxParamIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxParamIssuesSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxNotAReducerSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxParamIssuesSqlName( + private static global::SpacetimeDB.SqlTableName OutboxNotAReducerSqlName( int contextInstance ) { - var names = OutboxParamIssuesSqlNames; + var names = OutboxNotAReducerSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3256,7 +3636,7 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxParamIssues"); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNotAReducer"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3264,16 +3644,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxParamIssues, - OutboxParamIssuesCols, - OutboxParamIssuesIxCols - > OutboxParamIssues() + global::TestOutboxBadReceiver, + OutboxNotAReducerCols, + OutboxNotAReducerIxCols + > OutboxNotAReducer() { - var tableName = OutboxParamIssuesSqlName(__instanceId); + var tableName = OutboxNotAReducerSqlName(__instanceId); return new( tableName, - new OutboxParamIssuesCols(tableName), - new OutboxParamIssuesIxCols(tableName) + new OutboxNotAReducerCols(tableName), + new OutboxNotAReducerIxCols(tableName) ); } } @@ -3284,35 +3664,35 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxParamIssues, - OutboxParamIssuesCols, - OutboxParamIssuesIxCols - > OutboxParamIssues() => new AssemblyDescriptor.Queries(from).OutboxParamIssues(); - } - } - - public readonly struct OutboxTargetParamCols + global::TestOutboxBadReceiver, + OutboxNotAReducerCols, + OutboxNotAReducerIxCols + > OutboxNotAReducer() => new AssemblyDescriptor.Queries(from).OutboxNotAReducer(); + } + } + + public readonly struct OutboxEqualsParamCols { - internal OutboxTargetParamCols(global::SpacetimeDB.SqlTableName tableName) { } + internal OutboxEqualsParamCols(global::SpacetimeDB.SqlTableName tableName) { } } - public readonly struct OutboxTargetParamIxCols + public readonly struct OutboxEqualsParamIxCols { - internal OutboxTargetParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } + internal OutboxEqualsParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxTargetParamSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxEqualsParamSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxTargetParamSqlName( + private static global::SpacetimeDB.SqlTableName OutboxEqualsParamSqlName( int contextInstance ) { - var names = OutboxTargetParamSqlNames; + var names = OutboxEqualsParamSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3322,7 +3702,7 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxTargetParam"); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxEqualsParam"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3330,16 +3710,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxTargetParam, - OutboxTargetParamCols, - OutboxTargetParamIxCols - > OutboxTargetParam() + global::TestOutboxEqualsParam, + OutboxEqualsParamCols, + OutboxEqualsParamIxCols + > OutboxEqualsParam() { - var tableName = OutboxTargetParamSqlName(__instanceId); + var tableName = OutboxEqualsParamSqlName(__instanceId); return new( tableName, - new OutboxTargetParamCols(tableName), - new OutboxTargetParamIxCols(tableName) + new OutboxEqualsParamCols(tableName), + new OutboxEqualsParamIxCols(tableName) ); } } @@ -3350,41 +3730,82 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxTargetParam, - OutboxTargetParamCols, - OutboxTargetParamIxCols - > OutboxTargetParam() => new AssemblyDescriptor.Queries(from).OutboxTargetParam(); + global::TestOutboxEqualsParam, + OutboxEqualsParamCols, + OutboxEqualsParamIxCols + > OutboxEqualsParam() => new AssemblyDescriptor.Queries(from).OutboxEqualsParam(); } } - public readonly struct OutboxWithFieldsCols + public readonly struct OutboxEventAndScheduledCols { - public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + OutboxDiag.Identity + > Target; + public readonly global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + SpacetimeDB.ScheduleAt + > At; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal OutboxWithFieldsCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxEventAndScheduledCols(global::SpacetimeDB.SqlTableName tableName) { - Name = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + OutboxDiag.Identity + >(tableName, "Target"); + At = new global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + SpacetimeDB.ScheduleAt + >(tableName, "At"); + Name = new global::SpacetimeDB.Col( tableName, "Name" ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" + ); } } - public readonly struct OutboxWithFieldsIxCols + public readonly struct OutboxEventAndScheduledIxCols { - internal OutboxWithFieldsIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal OutboxEventAndScheduledIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] OutboxWithFieldsSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxEventAndScheduledSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName OutboxWithFieldsSqlName(int contextInstance) + private static global::SpacetimeDB.SqlTableName OutboxEventAndScheduledSqlName( + int contextInstance + ) { - var names = OutboxWithFieldsSqlNames; + var names = OutboxEventAndScheduledSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3394,7 +3815,10 @@ public static partial class AssemblyDescriptor "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxWithFields"); + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "OutboxEventAndScheduled" + ); names[contextInstance] = resolvedName; return resolvedName; } @@ -3402,16 +3826,16 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxWithFields, - OutboxWithFieldsCols, - OutboxWithFieldsIxCols - > OutboxWithFields() + global::TestOutboxEventAndScheduled, + OutboxEventAndScheduledCols, + OutboxEventAndScheduledIxCols + > OutboxEventAndScheduled() { - var tableName = OutboxWithFieldsSqlName(__instanceId); + var tableName = OutboxEventAndScheduledSqlName(__instanceId); return new( tableName, - new OutboxWithFieldsCols(tableName), - new OutboxWithFieldsIxCols(tableName) + new OutboxEventAndScheduledCols(tableName), + new OutboxEventAndScheduledIxCols(tableName) ); } } @@ -3422,64 +3846,84 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxWithFields, - OutboxWithFieldsCols, - OutboxWithFieldsIxCols - > OutboxWithFields() => new AssemblyDescriptor.Queries(from).OutboxWithFields(); + global::TestOutboxEventAndScheduled, + OutboxEventAndScheduledCols, + OutboxEventAndScheduledIxCols + > OutboxEventAndScheduled() => + new AssemblyDescriptor.Queries(from).OutboxEventAndScheduled(); } } - public readonly struct TestScheduleWithoutPrimaryKeyCols + public readonly struct OutboxNoAutoIncCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithoutPrimaryKeyCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNoAutoIncCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithoutPrimaryKeyIxCols + public readonly struct OutboxNoAutoIncIxCols { - internal TestScheduleWithoutPrimaryKeyIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; + + internal OutboxNoAutoIncIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithoutPrimaryKeySqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxNoAutoIncSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestScheduleWithoutPrimaryKeySqlName( - int contextInstance - ) + private static global::SpacetimeDB.SqlTableName OutboxNoAutoIncSqlName(int contextInstance) { - var names = TestScheduleWithoutPrimaryKeySqlNames; + var names = OutboxNoAutoIncSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3489,10 +3933,7 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName( - instanceId, - "TestScheduleWithoutPrimaryKey" - ); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNoAutoInc"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3500,16 +3941,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutPrimaryKeyCols, - TestScheduleWithoutPrimaryKeyIxCols - > TestScheduleWithoutPrimaryKey() + global::TestOutboxKeyAndTargetIssues, + OutboxNoAutoIncCols, + OutboxNoAutoIncIxCols + > OutboxNoAutoInc() { - var tableName = TestScheduleWithoutPrimaryKeySqlName(__instanceId); + var tableName = OutboxNoAutoIncSqlName(__instanceId); return new( tableName, - new TestScheduleWithoutPrimaryKeyCols(tableName), - new TestScheduleWithoutPrimaryKeyIxCols(tableName) + new OutboxNoAutoIncCols(tableName), + new OutboxNoAutoIncIxCols(tableName) ); } } @@ -3520,75 +3961,83 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutPrimaryKeyCols, - TestScheduleWithoutPrimaryKeyIxCols - > TestScheduleWithoutPrimaryKey() => - new AssemblyDescriptor.Queries(from).TestScheduleWithoutPrimaryKey(); + global::TestOutboxKeyAndTargetIssues, + OutboxNoAutoIncCols, + OutboxNoAutoIncIxCols + > OutboxNoAutoInc() => new AssemblyDescriptor.Queries(from).OutboxNoAutoInc(); } } - public readonly struct TestScheduleWithWrongPrimaryKeyTypeCols + public readonly struct OutboxNoTargetCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithWrongPrimaryKeyTypeCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNoTargetCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithWrongPrimaryKeyTypeIxCols + public readonly struct OutboxNoTargetIxCols { - public readonly global::SpacetimeDB.IxCol IdWrongType; + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; - internal TestScheduleWithWrongPrimaryKeyTypeIxCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal OutboxNoTargetIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdWrongType" + "MsgId" ); } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithWrongPrimaryKeyTypeSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxNoTargetSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestScheduleWithWrongPrimaryKeyTypeSqlName( - int contextInstance - ) + private static global::SpacetimeDB.SqlTableName OutboxNoTargetSqlName(int contextInstance) { - var names = TestScheduleWithWrongPrimaryKeyTypeSqlNames; + var names = OutboxNoTargetSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3598,10 +4047,7 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName( - instanceId, - "TestScheduleWithWrongPrimaryKeyType" - ); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxNoTarget"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3609,16 +4055,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongPrimaryKeyTypeCols, - TestScheduleWithWrongPrimaryKeyTypeIxCols - > TestScheduleWithWrongPrimaryKeyType() + global::TestOutboxKeyAndTargetIssues, + OutboxNoTargetCols, + OutboxNoTargetIxCols + > OutboxNoTarget() { - var tableName = TestScheduleWithWrongPrimaryKeyTypeSqlName(__instanceId); + var tableName = OutboxNoTargetSqlName(__instanceId); return new( tableName, - new TestScheduleWithWrongPrimaryKeyTypeCols(tableName), - new TestScheduleWithWrongPrimaryKeyTypeIxCols(tableName) + new OutboxNoTargetCols(tableName), + new OutboxNoTargetIxCols(tableName) ); } } @@ -3629,73 +4075,85 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongPrimaryKeyTypeCols, - TestScheduleWithWrongPrimaryKeyTypeIxCols - > TestScheduleWithWrongPrimaryKeyType() => - new AssemblyDescriptor.Queries(from).TestScheduleWithWrongPrimaryKeyType(); + global::TestOutboxKeyAndTargetIssues, + OutboxNoTargetCols, + OutboxNoTargetIxCols + > OutboxNoTarget() => new AssemblyDescriptor.Queries(from).OutboxNoTarget(); } } - public readonly struct TestScheduleWithoutScheduleAtCols + public readonly struct OutboxWrongTargetTypeCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithoutScheduleAtCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxWrongTargetTypeCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithoutScheduleAtIxCols + public readonly struct OutboxWrongTargetTypeIxCols { - public readonly global::SpacetimeDB.IxCol IdCorrectType; + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; - internal TestScheduleWithoutScheduleAtIxCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxWrongTargetTypeIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdCorrectType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdCorrectType" + "MsgId" ); } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithoutScheduleAtSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxWrongTargetTypeSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestScheduleWithoutScheduleAtSqlName( + private static global::SpacetimeDB.SqlTableName OutboxWrongTargetTypeSqlName( int contextInstance ) { - var names = TestScheduleWithoutScheduleAtSqlNames; + var names = OutboxWrongTargetTypeSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3707,7 +4165,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "TestScheduleWithoutScheduleAt" + "OutboxWrongTargetType" ); names[contextInstance] = resolvedName; return resolvedName; @@ -3716,16 +4174,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutScheduleAtCols, - TestScheduleWithoutScheduleAtIxCols - > TestScheduleWithoutScheduleAt() + global::TestOutboxKeyAndTargetIssues, + OutboxWrongTargetTypeCols, + OutboxWrongTargetTypeIxCols + > OutboxWrongTargetType() { - var tableName = TestScheduleWithoutScheduleAtSqlName(__instanceId); + var tableName = OutboxWrongTargetTypeSqlName(__instanceId); return new( tableName, - new TestScheduleWithoutScheduleAtCols(tableName), - new TestScheduleWithoutScheduleAtIxCols(tableName) + new OutboxWrongTargetTypeCols(tableName), + new OutboxWrongTargetTypeIxCols(tableName) ); } } @@ -3736,75 +4194,80 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutScheduleAtCols, - TestScheduleWithoutScheduleAtIxCols - > TestScheduleWithoutScheduleAt() => - new AssemblyDescriptor.Queries(from).TestScheduleWithoutScheduleAt(); + global::TestOutboxKeyAndTargetIssues, + OutboxWrongTargetTypeCols, + OutboxWrongTargetTypeIxCols + > OutboxWrongTargetType() => + new AssemblyDescriptor.Queries(from).OutboxWrongTargetType(); } } - public readonly struct TestScheduleWithWrongScheduleAtTypeCols + public readonly struct OutboxParamIssuesCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; - public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxParamIssues, + OutboxDiag.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Nickname; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Extra; - internal TestScheduleWithWrongScheduleAtTypeCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxParamIssuesCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxParamIssues, + OutboxDiag.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Nickname = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Nickname" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + Extra = new global::SpacetimeDB.Col( + tableName, + "Extra" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithWrongScheduleAtTypeIxCols + public readonly struct OutboxParamIssuesIxCols { - public readonly global::SpacetimeDB.IxCol IdCorrectType; + public readonly global::SpacetimeDB.IxCol MsgId; - internal TestScheduleWithWrongScheduleAtTypeIxCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal OutboxParamIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdCorrectType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdCorrectType" + "MsgId" ); } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithWrongScheduleAtTypeSqlNames => + private static global::SpacetimeDB.SqlTableName?[] OutboxParamIssuesSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestScheduleWithWrongScheduleAtTypeSqlName( + private static global::SpacetimeDB.SqlTableName OutboxParamIssuesSqlName( int contextInstance ) { - var names = TestScheduleWithWrongScheduleAtTypeSqlNames; + var names = OutboxParamIssuesSqlNames; if (names[contextInstance] is { } name) { return name; @@ -3814,10 +4277,7 @@ int contextInstance "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" ); var resolvedName = names[instanceId] ??= - global::SpacetimeDB.Internal.Module.ResolveSqlName( - instanceId, - "TestScheduleWithWrongScheduleAtType" - ); + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxParamIssues"); names[contextInstance] = resolvedName; return resolvedName; } @@ -3825,16 +4285,16 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongScheduleAtTypeCols, - TestScheduleWithWrongScheduleAtTypeIxCols - > TestScheduleWithWrongScheduleAtType() + global::TestOutboxParamIssues, + OutboxParamIssuesCols, + OutboxParamIssuesIxCols + > OutboxParamIssues() { - var tableName = TestScheduleWithWrongScheduleAtTypeSqlName(__instanceId); + var tableName = OutboxParamIssuesSqlName(__instanceId); return new( tableName, - new TestScheduleWithWrongScheduleAtTypeCols(tableName), - new TestScheduleWithWrongScheduleAtTypeIxCols(tableName) + new OutboxParamIssuesCols(tableName), + new OutboxParamIssuesIxCols(tableName) ); } } @@ -3845,15 +4305,152 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongScheduleAtTypeCols, - TestScheduleWithWrongScheduleAtTypeIxCols - > TestScheduleWithWrongScheduleAtType() => - new AssemblyDescriptor.Queries(from).TestScheduleWithWrongScheduleAtType(); + global::TestOutboxParamIssues, + OutboxParamIssuesCols, + OutboxParamIssuesIxCols + > OutboxParamIssues() => new AssemblyDescriptor.Queries(from).OutboxParamIssues(); } } - public readonly struct TestScheduleWithMissingScheduleAtFieldCols + public readonly struct OutboxTargetParamCols + { + internal OutboxTargetParamCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public readonly struct OutboxTargetParamIxCols + { + internal OutboxTargetParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] OutboxTargetParamSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName OutboxTargetParamSqlName( + int contextInstance + ) + { + var names = OutboxTargetParamSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxTargetParam"); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestOutboxTargetParam, + OutboxTargetParamCols, + OutboxTargetParamIxCols + > OutboxTargetParam() + { + var tableName = OutboxTargetParamSqlName(__instanceId); + return new( + tableName, + new OutboxTargetParamCols(tableName), + new OutboxTargetParamIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestOutboxTargetParam, + OutboxTargetParamCols, + OutboxTargetParamIxCols + > OutboxTargetParam() => new AssemblyDescriptor.Queries(from).OutboxTargetParam(); + } + } + + public readonly struct OutboxWithFieldsCols + { + public readonly global::SpacetimeDB.Col Name; + + internal OutboxWithFieldsCols(global::SpacetimeDB.SqlTableName tableName) + { + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + } + } + + public readonly struct OutboxWithFieldsIxCols + { + internal OutboxWithFieldsIxCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] OutboxWithFieldsSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName OutboxWithFieldsSqlName(int contextInstance) + { + var names = OutboxWithFieldsSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "OutboxWithFields"); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestOutboxWithFields, + OutboxWithFieldsCols, + OutboxWithFieldsIxCols + > OutboxWithFields() + { + var tableName = OutboxWithFieldsSqlName(__instanceId); + return new( + tableName, + new OutboxWithFieldsCols(tableName), + new OutboxWithFieldsIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestOutboxWithFields, + OutboxWithFieldsCols, + OutboxWithFieldsIxCols + > OutboxWithFields() => new AssemblyDescriptor.Queries(from).OutboxWithFields(); + } + } + + public readonly struct TestScheduleWithoutPrimaryKeyCols { public readonly global::SpacetimeDB.Col IdWrongType; public readonly global::SpacetimeDB.Col IdCorrectType; @@ -3866,9 +4463,7 @@ public readonly struct TestScheduleWithMissingScheduleAtFieldCols SpacetimeDB.ScheduleAt > ScheduleAtCorrectType; - internal TestScheduleWithMissingScheduleAtFieldCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal TestScheduleWithoutPrimaryKeyCols(global::SpacetimeDB.SqlTableName tableName) { IdWrongType = new global::SpacetimeDB.Col( tableName, @@ -3889,25 +4484,23 @@ internal TestScheduleWithMissingScheduleAtFieldCols( } } - public readonly struct TestScheduleWithMissingScheduleAtFieldIxCols + public readonly struct TestScheduleWithoutPrimaryKeyIxCols { - internal TestScheduleWithMissingScheduleAtFieldIxCols( - global::SpacetimeDB.SqlTableName tableName - ) { } + internal TestScheduleWithoutPrimaryKeyIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithMissingScheduleAtFieldSqlNames => + private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithoutPrimaryKeySqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestScheduleWithMissingScheduleAtFieldSqlName( + private static global::SpacetimeDB.SqlTableName TestScheduleWithoutPrimaryKeySqlName( int contextInstance ) { - var names = TestScheduleWithMissingScheduleAtFieldSqlNames; + var names = TestScheduleWithoutPrimaryKeySqlNames; if (names[contextInstance] is { } name) { return name; @@ -3919,7 +4512,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "TestScheduleWithMissingScheduleAtField" + "TestScheduleWithoutPrimaryKey" ); names[contextInstance] = resolvedName; return resolvedName; @@ -3929,15 +4522,15 @@ public readonly partial struct Queries { public global::SpacetimeDB.Table< global::TestScheduleIssues, - TestScheduleWithMissingScheduleAtFieldCols, - TestScheduleWithMissingScheduleAtFieldIxCols - > TestScheduleWithMissingScheduleAtField() + TestScheduleWithoutPrimaryKeyCols, + TestScheduleWithoutPrimaryKeyIxCols + > TestScheduleWithoutPrimaryKey() { - var tableName = TestScheduleWithMissingScheduleAtFieldSqlName(__instanceId); + var tableName = TestScheduleWithoutPrimaryKeySqlName(__instanceId); return new( tableName, - new TestScheduleWithMissingScheduleAtFieldCols(tableName), - new TestScheduleWithMissingScheduleAtFieldIxCols(tableName) + new TestScheduleWithoutPrimaryKeyCols(tableName), + new TestScheduleWithoutPrimaryKeyIxCols(tableName) ); } } @@ -3949,62 +4542,74 @@ public static partial class QueryTableExtensions { public global::SpacetimeDB.Table< global::TestScheduleIssues, - TestScheduleWithMissingScheduleAtFieldCols, - TestScheduleWithMissingScheduleAtFieldIxCols - > TestScheduleWithMissingScheduleAtField() => - new AssemblyDescriptor.Queries(from).TestScheduleWithMissingScheduleAtField(); + TestScheduleWithoutPrimaryKeyCols, + TestScheduleWithoutPrimaryKeyIxCols + > TestScheduleWithoutPrimaryKey() => + new AssemblyDescriptor.Queries(from).TestScheduleWithoutPrimaryKey(); } } - public readonly struct TestUniqueNotEquatableCols + public readonly struct TestScheduleWithWrongPrimaryKeyTypeCols { - public readonly global::SpacetimeDB.Col UniqueField; + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; public readonly global::SpacetimeDB.Col< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - > PrimaryKeyField; + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; - internal TestUniqueNotEquatableCols(global::SpacetimeDB.SqlTableName tableName) + internal TestScheduleWithWrongPrimaryKeyTypeCols(global::SpacetimeDB.SqlTableName tableName) { - UniqueField = new global::SpacetimeDB.Col( + IdWrongType = new global::SpacetimeDB.Col( tableName, - "UniqueField" + "IdWrongType" ); - PrimaryKeyField = new global::SpacetimeDB.Col< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - >(tableName, "PrimaryKeyField"); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestUniqueNotEquatableIxCols + public readonly struct TestScheduleWithWrongPrimaryKeyTypeIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - > PrimaryKeyField; + public readonly global::SpacetimeDB.IxCol IdWrongType; - internal TestUniqueNotEquatableIxCols(global::SpacetimeDB.SqlTableName tableName) + internal TestScheduleWithWrongPrimaryKeyTypeIxCols( + global::SpacetimeDB.SqlTableName tableName + ) { - PrimaryKeyField = new global::SpacetimeDB.IxCol< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - >(tableName, "PrimaryKeyField"); + IdWrongType = new global::SpacetimeDB.IxCol( + tableName, + "IdWrongType" + ); } } public static partial class AssemblyDescriptor { - private static global::SpacetimeDB.SqlTableName?[] TestUniqueNotEquatableSqlNames => + private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithWrongPrimaryKeyTypeSqlNames => field ??= new global::SpacetimeDB.SqlTableName?[ global::SpacetimeDB.Internal.Module.InstanceCount ]; - private static global::SpacetimeDB.SqlTableName TestUniqueNotEquatableSqlName( + private static global::SpacetimeDB.SqlTableName TestScheduleWithWrongPrimaryKeyTypeSqlName( int contextInstance ) { - var names = TestUniqueNotEquatableSqlNames; + var names = TestScheduleWithWrongPrimaryKeyTypeSqlNames; if (names[contextInstance] is { } name) { return name; @@ -4016,7 +4621,7 @@ int contextInstance var resolvedName = names[instanceId] ??= global::SpacetimeDB.Internal.Module.ResolveSqlName( instanceId, - "TestUniqueNotEquatable" + "TestScheduleWithWrongPrimaryKeyType" ); names[contextInstance] = resolvedName; return resolvedName; @@ -4025,38 +4630,1076 @@ int contextInstance public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestUniqueNotEquatable, - TestUniqueNotEquatableCols, - TestUniqueNotEquatableIxCols - > TestUniqueNotEquatable() + global::TestScheduleIssues, + TestScheduleWithWrongPrimaryKeyTypeCols, + TestScheduleWithWrongPrimaryKeyTypeIxCols + > TestScheduleWithWrongPrimaryKeyType() { - var tableName = TestUniqueNotEquatableSqlName(__instanceId); + var tableName = TestScheduleWithWrongPrimaryKeyTypeSqlName(__instanceId); return new( tableName, - new TestUniqueNotEquatableCols(tableName), - new TestUniqueNotEquatableIxCols(tableName) + new TestScheduleWithWrongPrimaryKeyTypeCols(tableName), + new TestScheduleWithWrongPrimaryKeyTypeIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongPrimaryKeyTypeCols, + TestScheduleWithWrongPrimaryKeyTypeIxCols + > TestScheduleWithWrongPrimaryKeyType() => + new AssemblyDescriptor.Queries(from).TestScheduleWithWrongPrimaryKeyType(); + } + } + + public readonly struct TestScheduleWithoutScheduleAtCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithoutScheduleAtCols(global::SpacetimeDB.SqlTableName tableName) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithoutScheduleAtIxCols + { + public readonly global::SpacetimeDB.IxCol IdCorrectType; + + internal TestScheduleWithoutScheduleAtIxCols(global::SpacetimeDB.SqlTableName tableName) + { + IdCorrectType = new global::SpacetimeDB.IxCol( + tableName, + "IdCorrectType" + ); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithoutScheduleAtSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName TestScheduleWithoutScheduleAtSqlName( + int contextInstance + ) + { + var names = TestScheduleWithoutScheduleAtSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "TestScheduleWithoutScheduleAt" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithoutScheduleAtCols, + TestScheduleWithoutScheduleAtIxCols + > TestScheduleWithoutScheduleAt() + { + var tableName = TestScheduleWithoutScheduleAtSqlName(__instanceId); + return new( + tableName, + new TestScheduleWithoutScheduleAtCols(tableName), + new TestScheduleWithoutScheduleAtIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithoutScheduleAtCols, + TestScheduleWithoutScheduleAtIxCols + > TestScheduleWithoutScheduleAt() => + new AssemblyDescriptor.Queries(from).TestScheduleWithoutScheduleAt(); + } + } + + public readonly struct TestScheduleWithWrongScheduleAtTypeCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithWrongScheduleAtTypeCols(global::SpacetimeDB.SqlTableName tableName) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithWrongScheduleAtTypeIxCols + { + public readonly global::SpacetimeDB.IxCol IdCorrectType; + + internal TestScheduleWithWrongScheduleAtTypeIxCols( + global::SpacetimeDB.SqlTableName tableName + ) + { + IdCorrectType = new global::SpacetimeDB.IxCol( + tableName, + "IdCorrectType" + ); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithWrongScheduleAtTypeSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName TestScheduleWithWrongScheduleAtTypeSqlName( + int contextInstance + ) + { + var names = TestScheduleWithWrongScheduleAtTypeSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "TestScheduleWithWrongScheduleAtType" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongScheduleAtTypeCols, + TestScheduleWithWrongScheduleAtTypeIxCols + > TestScheduleWithWrongScheduleAtType() + { + var tableName = TestScheduleWithWrongScheduleAtTypeSqlName(__instanceId); + return new( + tableName, + new TestScheduleWithWrongScheduleAtTypeCols(tableName), + new TestScheduleWithWrongScheduleAtTypeIxCols(tableName) ); } } } - public static partial class QueryTableExtensions - { - extension(global::SpacetimeDB.QueryBuilder from) - { - public global::SpacetimeDB.Table< - global::TestUniqueNotEquatable, - TestUniqueNotEquatableCols, - TestUniqueNotEquatableIxCols - > TestUniqueNotEquatable() => - new AssemblyDescriptor.Queries(from).TestUniqueNotEquatable(); - } + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongScheduleAtTypeCols, + TestScheduleWithWrongScheduleAtTypeIxCols + > TestScheduleWithWrongScheduleAtType() => + new AssemblyDescriptor.Queries(from).TestScheduleWithWrongScheduleAtType(); + } + } + + public readonly struct TestScheduleWithMissingScheduleAtFieldCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithMissingScheduleAtFieldCols( + global::SpacetimeDB.SqlTableName tableName + ) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithMissingScheduleAtFieldIxCols + { + internal TestScheduleWithMissingScheduleAtFieldIxCols( + global::SpacetimeDB.SqlTableName tableName + ) { } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] TestScheduleWithMissingScheduleAtFieldSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName TestScheduleWithMissingScheduleAtFieldSqlName( + int contextInstance + ) + { + var names = TestScheduleWithMissingScheduleAtFieldSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "TestScheduleWithMissingScheduleAtField" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithMissingScheduleAtFieldCols, + TestScheduleWithMissingScheduleAtFieldIxCols + > TestScheduleWithMissingScheduleAtField() + { + var tableName = TestScheduleWithMissingScheduleAtFieldSqlName(__instanceId); + return new( + tableName, + new TestScheduleWithMissingScheduleAtFieldCols(tableName), + new TestScheduleWithMissingScheduleAtFieldIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithMissingScheduleAtFieldCols, + TestScheduleWithMissingScheduleAtFieldIxCols + > TestScheduleWithMissingScheduleAtField() => + new AssemblyDescriptor.Queries(from).TestScheduleWithMissingScheduleAtField(); + } + } + + public readonly struct TestUniqueNotEquatableCols + { + public readonly global::SpacetimeDB.Col UniqueField; + public readonly global::SpacetimeDB.Col< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + > PrimaryKeyField; + + internal TestUniqueNotEquatableCols(global::SpacetimeDB.SqlTableName tableName) + { + UniqueField = new global::SpacetimeDB.Col( + tableName, + "UniqueField" + ); + PrimaryKeyField = new global::SpacetimeDB.Col< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + >(tableName, "PrimaryKeyField"); + } + } + + public readonly struct TestUniqueNotEquatableIxCols + { + public readonly global::SpacetimeDB.IxCol< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + > PrimaryKeyField; + + internal TestUniqueNotEquatableIxCols(global::SpacetimeDB.SqlTableName tableName) + { + PrimaryKeyField = new global::SpacetimeDB.IxCol< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + >(tableName, "PrimaryKeyField"); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] TestUniqueNotEquatableSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName TestUniqueNotEquatableSqlName( + int contextInstance + ) + { + var names = TestUniqueNotEquatableSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "TestUniqueNotEquatable" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestUniqueNotEquatable, + TestUniqueNotEquatableCols, + TestUniqueNotEquatableIxCols + > TestUniqueNotEquatable() + { + var tableName = TestUniqueNotEquatableSqlName(__instanceId); + return new( + tableName, + new TestUniqueNotEquatableCols(tableName), + new TestUniqueNotEquatableIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestUniqueNotEquatable, + TestUniqueNotEquatableCols, + TestUniqueNotEquatableIxCols + > TestUniqueNotEquatable() => + new AssemblyDescriptor.Queries(from).TestUniqueNotEquatable(); + } + } +} +#endif + +namespace SpacetimeDB.Internal.TableHandles +{ + public readonly struct LocalOutboxColumnIssues + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + > + { + public static global::TestLocalOutboxColumnIssues ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxColumnIssues row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxColumnIssues.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxColumnIssues), + ProductTypeRef: (uint) + new global::TestLocalOutboxColumnIssues.BSATN() + .GetAlgebraicType(registrar) + .Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxColumnIssues_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoIter(); + + public global::TestLocalOutboxColumnIssues Insert( + global::TestLocalOutboxColumnIssues row + ) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.Delete(global::TestLocalOutboxColumnIssues row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxColumnIssues." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxColumnIssues can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxLifecycle + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + > + { + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxLifecycle), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxLifecycle_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoIter(); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxLifecycle." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxLifecycle can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxMissingReducer + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + > + { + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxMissingReducer), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxMissingReducer_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoIter(); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxMissingReducer." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxMissingReducer can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxNotAReducer + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + > + { + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxNotAReducer), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxNotAReducer_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoIter(); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxNotAReducer." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxNotAReducer can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxWithBindings + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + > + { + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxWithBindings), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxWithBindings_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoIter(); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxWithBindings." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxWithBindings can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxWithoutOutbox + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + > + { + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxWithoutOutbox), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxWithoutOutbox_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoIter(); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxWithoutOutbox." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxWithoutOutbox can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; } -} -#endif -namespace SpacetimeDB.Internal.TableHandles -{ public readonly struct OutboxEqualsParam : global::SpacetimeDB.Internal.ITableView { @@ -6951,6 +8594,192 @@ public static byte[] Invoke( namespace SpacetimeDB.Internal.ViewHandles { + public sealed class LocalOutboxColumnIssuesReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxColumnIssuesReadOnly() + : base("LocalOutboxColumnIssues") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly, + global::TestLocalOutboxColumnIssues, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxColumnIssues_MsgId_idx_btree") { } + + public global::TestLocalOutboxColumnIssues? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalOutboxLifecycleReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxLifecycleReadOnly() + : base("LocalOutboxLifecycle") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxLifecycle_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalOutboxMissingReducerReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxMissingReducerReadOnly() + : base("LocalOutboxMissingReducer") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxMissingReducer_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalOutboxNotAReducerReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxNotAReducerReadOnly() + : base("LocalOutboxNotAReducer") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxNotAReducer_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalOutboxWithBindingsReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxWithBindingsReadOnly() + : base("LocalOutboxWithBindings") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxWithBindings_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalOutboxWithoutOutboxReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxWithoutOutboxReadOnly() + : base("LocalOutboxWithoutOutbox") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalOutboxWithoutOutbox_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + public sealed class OutboxEqualsParamReadOnly : global::SpacetimeDB.Internal.ReadOnlyTableView { @@ -7582,6 +9411,18 @@ namespace SpacetimeDB.Internal { public sealed partial class LocalReadOnly { + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new(); public global::SpacetimeDB.Internal.ViewHandles.OutboxEventAndScheduledReadOnly OutboxEventAndScheduled => @@ -7814,6 +9655,38 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class Receive : SpacetimeDB.Internal.IReducer + { + private static readonly SpacetimeDB.BSATN.String nameRW = new(); + private static readonly SpacetimeDB.BSATN.I32 countRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(Receive), + Params: + [ + new("name", nameRW.GetAlgebraicType(registrar)), + new("count", countRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxDiag.Receive( + (SpacetimeDB.ReducerContext)ctx, + nameRW.Read(reader), + countRW.Read(reader) + ); + } + } + sealed class SecondResult : SpacetimeDB.Internal.IReducer { private static readonly TestOutboxBadReceiver.BSATN rowRW = new(); @@ -8087,6 +9960,7 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); @@ -8127,6 +10001,30 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder ["renamed_identity"] ); + builder.RegisterTable< + global::TestLocalOutboxColumnIssues, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxColumnIssues + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxLifecycle + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxMissingReducer + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxNotAReducer + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithBindings + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Internal.TableHandles.LocalOutboxWithoutOutbox + >(); builder.RegisterTable< global::TestOutboxEqualsParam, global::SpacetimeDB.Internal.TableHandles.OutboxEqualsParam @@ -8626,7 +10524,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - SecondResult.Invoke(reader, ctx); + Receive.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8664,7 +10562,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerKind1.Invoke(reader, ctx); + SecondResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8702,7 +10600,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerKind2.Invoke(reader, ctx); + TestDuplicateReducerKind1.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8740,7 +10638,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerName.Invoke(reader, ctx); + TestDuplicateReducerKind2.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8778,7 +10676,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestReducerReturnType.Invoke(reader, ctx); + TestDuplicateReducerName.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8816,7 +10714,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestReducerWithoutContext.Invoke(reader, ctx); + TestReducerReturnType.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8854,7 +10752,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - UnknownTable.Invoke(reader, ctx); + TestReducerWithoutContext.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -8875,6 +10773,44 @@ private static SpacetimeDB.Internal.Errno __call_reducer_13( SpacetimeDB.Internal.BytesSource args, SpacetimeDB.Internal.BytesSink error ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + UnknownTable.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_14( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error + ) { try { @@ -9596,6 +11532,17 @@ SpacetimeDB.Internal.BytesSink error args, error ), + 14 => __call_reducer_14( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error + ), _ => SpacetimeDB.Internal.Module.WriteReducerError( error, new System.ArgumentOutOfRangeException(nameof(id), id, "Unknown reducer id") diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#LocalOutboxDiag.Receive.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#LocalOutboxDiag.Receive.verified.cs new file mode 100644 index 00000000000..c73dac5a75c --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#LocalOutboxDiag.Receive.verified.cs @@ -0,0 +1,16 @@ +//HintName: LocalOutboxDiag.Receive.cs +// +#nullable enable + +partial class LocalOutboxDiag +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceive(string name, int count) + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new SpacetimeDB.BSATN.String().Write(writer, name); + new SpacetimeDB.BSATN.I32().Write(writer, count); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate(nameof(Receive), stream); + } +} // LocalOutboxDiag diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxBadReducer.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxBadReducer.verified.cs new file mode 100644 index 00000000000..9b50a6239c2 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxBadReducer.verified.cs @@ -0,0 +1,119 @@ +//HintName: TestLocalOutboxBadReducer.cs +// +#nullable enable + +partial struct TestLocalOutboxBadReducer + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Name = BSATN.NameRW.Read(reader); + Count = BSATN.CountRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.NameRW.Write(writer, Name); + BSATN.CountRW.Write(writer, Count); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"TestLocalOutboxBadReducer {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Name = {SpacetimeDB.BSATN.StringUtil.GenericToString(Name)}, Count = {SpacetimeDB.BSATN.StringUtil.GenericToString(Count)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.String NameRW = new(); + internal static readonly SpacetimeDB.BSATN.I32 CountRW = new(); + + public TestLocalOutboxBadReducer Read(System.IO.BinaryReader reader) + { + var ___result = new TestLocalOutboxBadReducer(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, TestLocalOutboxBadReducer value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Name", NameRW.GetAlgebraicType(registrar)), + new("Count", CountRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashName = Name == null ? 0 : Name.GetHashCode(); + var ___hashCount = Count.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashName ^ ___hashCount; + } + +#nullable enable + public bool Equals(TestLocalOutboxBadReducer that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqName = this.Name == null ? that.Name == null : this.Name.Equals(that.Name); + var ___eqCount = this.Count.Equals(that.Count); + return ___eqMsgId && ___eqTarget && ___eqName && ___eqCount; + } + + public override bool Equals(object? that) + { + return that is TestLocalOutboxBadReducer t && Equals(t); + } + + public static bool operator ==(TestLocalOutboxBadReducer this_, TestLocalOutboxBadReducer that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(TestLocalOutboxBadReducer this_, TestLocalOutboxBadReducer that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // TestLocalOutboxBadReducer diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxColumnIssues.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxColumnIssues.verified.cs new file mode 100644 index 00000000000..2437518b3de --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module#TestLocalOutboxColumnIssues.verified.cs @@ -0,0 +1,119 @@ +//HintName: TestLocalOutboxColumnIssues.cs +// +#nullable enable + +partial struct TestLocalOutboxColumnIssues + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Count = BSATN.CountRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.CountRW.Write(writer, Count); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"TestLocalOutboxColumnIssues {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Count = {SpacetimeDB.BSATN.StringUtil.GenericToString(Count)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly OutboxDiag.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 CountRW = new(); + + public TestLocalOutboxColumnIssues Read(System.IO.BinaryReader reader) + { + var ___result = new TestLocalOutboxColumnIssues(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, TestLocalOutboxColumnIssues value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Count", CountRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashCount = Count.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashCount; + } + +#nullable enable + public bool Equals(TestLocalOutboxColumnIssues that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqCount = this.Count.Equals(that.Count); + return ___eqMsgId && ___eqTarget && ___eqCount; + } + + public override bool Equals(object? that) + { + return that is TestLocalOutboxColumnIssues t && Equals(t); + } + + public static bool operator ==( + TestLocalOutboxColumnIssues this_, + TestLocalOutboxColumnIssues that + ) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=( + TestLocalOutboxColumnIssues this_, + TestLocalOutboxColumnIssues that + ) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // TestLocalOutboxColumnIssues diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#FFI.verified.cs index d566c333a86..06c4efa936a 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#FFI.verified.cs @@ -309,6 +309,349 @@ public readonly partial struct QueryBuilder ); } + public readonly struct LocalOutboxMissingReducerCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxMissingReducerCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxMissingReducerIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxMissingReducerIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() => + new( + "LocalOutboxMissingReducer", + new LocalOutboxMissingReducerCols("LocalOutboxMissingReducer"), + new LocalOutboxMissingReducerIxCols("LocalOutboxMissingReducer") + ); + } + + public readonly struct LocalOutboxNotAReducerCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxNotAReducerCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxNotAReducerIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxNotAReducerIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() => + new( + "LocalOutboxNotAReducer", + new LocalOutboxNotAReducerCols("LocalOutboxNotAReducer"), + new LocalOutboxNotAReducerIxCols("LocalOutboxNotAReducer") + ); + } + + public readonly struct LocalOutboxLifecycleCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxLifecycleCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxLifecycleIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxLifecycleIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() => + new( + "LocalOutboxLifecycle", + new LocalOutboxLifecycleCols("LocalOutboxLifecycle"), + new LocalOutboxLifecycleIxCols("LocalOutboxLifecycle") + ); + } + + public readonly struct LocalOutboxWithBindingsCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxWithBindingsCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxWithBindingsIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxWithBindingsIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() => + new( + "LocalOutboxWithBindings", + new LocalOutboxWithBindingsCols("LocalOutboxWithBindings"), + new LocalOutboxWithBindingsIxCols("LocalOutboxWithBindings") + ); + } + + public readonly struct LocalOutboxWithoutOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxWithoutOutboxCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxWithoutOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxWithoutOutboxIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() => + new( + "LocalOutboxWithoutOutbox", + new LocalOutboxWithoutOutboxCols("LocalOutboxWithoutOutbox"), + new LocalOutboxWithoutOutboxIxCols("LocalOutboxWithoutOutbox") + ); + } + + public readonly struct LocalOutboxColumnIssuesCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxColumnIssues, + OutboxDiag.Identity + > Target; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxColumnIssuesCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxColumnIssues, + OutboxDiag.Identity + >(tableName, "Target"); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } + } + + public readonly struct LocalOutboxColumnIssuesIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxColumnIssuesIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() => + new( + "LocalOutboxColumnIssues", + new LocalOutboxColumnIssuesCols("LocalOutboxColumnIssues"), + new LocalOutboxColumnIssuesIxCols("LocalOutboxColumnIssues") + ); + } + public readonly struct TableAndOutboxCols { internal TableAndOutboxCols(string tableName) { } @@ -1439,6 +1782,54 @@ internal HandlerTxContext(Internal.TxContext inner) public sealed class Local : global::SpacetimeDB.LocalBase { + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.OutboxEqualsParam OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1653,7 +2044,7 @@ public static partial class AssemblyDescriptor public const string RootOnlyDeclarations = "row-level security filters, lifecycle reducer OnResultIssues.LifecycleResult (ClientConnected), lifecycle reducer Reducers.TestDuplicateReducerKind1 (Init), lifecycle reducer Reducers.TestDuplicateReducerKind2 (Init)"; public const string OutboxTables = ""; - public const int ReducerCount = 14; + public const int ReducerCount = 15; public const int ProcedureCount = 0; public const int HttpHandlerCount = 0; public const int ViewCount = 12; @@ -1803,7 +2194,55 @@ public Tables(global::SpacetimeDB.Internal.Local? db) __owner = db; } - public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.OutboxEqualsParam OutboxEqualsParam => + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.OutboxEqualsParam OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( __owner, @@ -1990,6 +2429,54 @@ public ReadOnlyTables(global::SpacetimeDB.Internal.LocalReadOnly? db) __owner = db; } + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -2183,6 +2670,54 @@ public static class LocalTableExtensions { extension(global::SpacetimeDB.Local db) { + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxColumnIssues LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxLifecycle LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxMissingReducer LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxNotAReducer LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithBindings LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithoutOutbox LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.OutboxEqualsParam OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -2366,6 +2901,54 @@ public static class ReadOnlyTableExtensions { extension(global::SpacetimeDB.Internal.LocalReadOnly db) { + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -2963,14 +3546,48 @@ public static partial class QueryTableExtensions } } - public readonly struct TableAndOutboxCols + public readonly struct LocalOutboxMissingReducerCols { - internal TableAndOutboxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + + internal LocalOutboxMissingReducerCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + } } - public readonly struct TableAndOutboxIxCols + public readonly struct LocalOutboxMissingReducerIxCols { - internal TableAndOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxMissingReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor @@ -2978,19 +3595,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxAndTable, - TableAndOutboxCols, - TableAndOutboxIxCols - > TableAndOutbox() + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TableAndOutbox" + "LocalOutboxMissingReducer" ); return new( tableName, - new TableAndOutboxCols(tableName), - new TableAndOutboxIxCols(tableName) + new LocalOutboxMissingReducerCols(tableName), + new LocalOutboxMissingReducerIxCols(tableName) ); } } @@ -3001,41 +3618,56 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxAndTable, - TableAndOutboxCols, - TableAndOutboxIxCols - > TableAndOutbox() => new AssemblyDescriptor.Queries(from).TableAndOutbox(); + global::TestLocalOutboxBadReducer, + LocalOutboxMissingReducerCols, + LocalOutboxMissingReducerIxCols + > LocalOutboxMissingReducer() => + new AssemblyDescriptor.Queries(from).LocalOutboxMissingReducer(); } } - public readonly struct TestOutboxAttributesWithoutOutboxCols + public readonly struct LocalOutboxNotAReducerCols { + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, - string - > Name; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal TestOutboxAttributesWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); Target = new global::SpacetimeDB.Col< - global::TestOutboxAttributesWithoutOutbox, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity >(tableName, "Target"); - Name = new global::SpacetimeDB.Col( + Name = new global::SpacetimeDB.Col( tableName, "Name" ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); } } - public readonly struct TestOutboxAttributesWithoutOutboxIxCols + public readonly struct LocalOutboxNotAReducerIxCols { - internal TestOutboxAttributesWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) - { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalOutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor @@ -3043,19 +3675,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxAttributesWithoutOutbox, - TestOutboxAttributesWithoutOutboxCols, - TestOutboxAttributesWithoutOutboxIxCols - > TestOutboxAttributesWithoutOutbox() + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestOutboxAttributesWithoutOutbox" + "LocalOutboxNotAReducer" ); return new( tableName, - new TestOutboxAttributesWithoutOutboxCols(tableName), - new TestOutboxAttributesWithoutOutboxIxCols(tableName) + new LocalOutboxNotAReducerCols(tableName), + new LocalOutboxNotAReducerIxCols(tableName) ); } } @@ -3066,42 +3698,52 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxAttributesWithoutOutbox, - TestOutboxAttributesWithoutOutboxCols, - TestOutboxAttributesWithoutOutboxIxCols - > TestOutboxAttributesWithoutOutbox() => - new AssemblyDescriptor.Queries(from).TestOutboxAttributesWithoutOutbox(); + global::TestLocalOutboxBadReducer, + LocalOutboxNotAReducerCols, + LocalOutboxNotAReducerIxCols + > LocalOutboxNotAReducer() => + new AssemblyDescriptor.Queries(from).LocalOutboxNotAReducer(); } } - public readonly struct OutboxNotAReducerCols + public readonly struct LocalOutboxLifecycleCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxBadReceiver, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal OutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxLifecycleCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxBadReceiver, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); } } - public readonly struct OutboxNotAReducerIxCols + public readonly struct LocalOutboxLifecycleIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxLifecycleIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -3113,19 +3755,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxBadReceiver, - OutboxNotAReducerCols, - OutboxNotAReducerIxCols - > OutboxNotAReducer() + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxNotAReducer" + "LocalOutboxLifecycle" ); return new( tableName, - new OutboxNotAReducerCols(tableName), - new OutboxNotAReducerIxCols(tableName) + new LocalOutboxLifecycleCols(tableName), + new LocalOutboxLifecycleIxCols(tableName) ); } } @@ -3136,109 +3778,51 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxBadReceiver, - OutboxNotAReducerCols, - OutboxNotAReducerIxCols - > OutboxNotAReducer() => new AssemblyDescriptor.Queries(from).OutboxNotAReducer(); + global::TestLocalOutboxBadReducer, + LocalOutboxLifecycleCols, + LocalOutboxLifecycleIxCols + > LocalOutboxLifecycle() => new AssemblyDescriptor.Queries(from).LocalOutboxLifecycle(); } } - public readonly struct OutboxEqualsParamCols + public readonly struct LocalOutboxWithBindingsCols { - internal OutboxEqualsParamCols(global::SpacetimeDB.SqlTableName tableName) { } - } - - public readonly struct OutboxEqualsParamIxCols - { - internal OutboxEqualsParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } - } - - public static partial class AssemblyDescriptor - { - public readonly partial struct Queries - { - public global::SpacetimeDB.Table< - global::TestOutboxEqualsParam, - OutboxEqualsParamCols, - OutboxEqualsParamIxCols - > OutboxEqualsParam() - { - var tableName = __owner.ResolveTableName( - "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxEqualsParam" - ); - return new( - tableName, - new OutboxEqualsParamCols(tableName), - new OutboxEqualsParamIxCols(tableName) - ); - } - } - } - - public static partial class QueryTableExtensions - { - extension(global::SpacetimeDB.QueryBuilder from) - { - public global::SpacetimeDB.Table< - global::TestOutboxEqualsParam, - OutboxEqualsParamCols, - OutboxEqualsParamIxCols - > OutboxEqualsParam() => new AssemblyDescriptor.Queries(from).OutboxEqualsParam(); - } - } - - public readonly struct OutboxEventAndScheduledCols - { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - SpacetimeDB.ScheduleAt - > At; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal OutboxEventAndScheduledCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithBindingsCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - OutboxDiag.Identity + global::TestLocalOutboxBadReducer, + SpacetimeDB.Identity >(tableName, "Target"); - At = new global::SpacetimeDB.Col< - global::TestOutboxEventAndScheduled, - SpacetimeDB.ScheduleAt - >(tableName, "At"); - Name = new global::SpacetimeDB.Col( + Name = new global::SpacetimeDB.Col( tableName, "Name" ); - Count = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, "Count" ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxEventAndScheduledIxCols + public readonly struct LocalOutboxWithBindingsIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxEventAndScheduledIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithBindingsIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -3250,19 +3834,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxEventAndScheduled, - OutboxEventAndScheduledCols, - OutboxEventAndScheduledIxCols - > OutboxEventAndScheduled() + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxEventAndScheduled" + "LocalOutboxWithBindings" ); return new( tableName, - new OutboxEventAndScheduledCols(tableName), - new OutboxEventAndScheduledIxCols(tableName) + new LocalOutboxWithBindingsCols(tableName), + new LocalOutboxWithBindingsIxCols(tableName) ); } } @@ -3273,68 +3857,52 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxEventAndScheduled, - OutboxEventAndScheduledCols, - OutboxEventAndScheduledIxCols - > OutboxEventAndScheduled() => - new AssemblyDescriptor.Queries(from).OutboxEventAndScheduled(); + global::TestLocalOutboxBadReducer, + LocalOutboxWithBindingsCols, + LocalOutboxWithBindingsIxCols + > LocalOutboxWithBindings() => + new AssemblyDescriptor.Queries(from).LocalOutboxWithBindings(); } } - public readonly struct OutboxNoAutoIncCols + public readonly struct LocalOutboxWithoutOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - > Target; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; - internal OutboxNoAutoIncCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxBadReducer, SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( tableName, "Name" ); - Count = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, "Count" ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxNoAutoIncIxCols + public readonly struct LocalOutboxWithoutOutboxIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxNoAutoIncIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -3346,19 +3914,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoAutoIncCols, - OutboxNoAutoIncIxCols - > OutboxNoAutoInc() + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxNoAutoInc" + "LocalOutboxWithoutOutbox" ); return new( tableName, - new OutboxNoAutoIncCols(tableName), - new OutboxNoAutoIncIxCols(tableName) + new LocalOutboxWithoutOutboxCols(tableName), + new LocalOutboxWithoutOutboxIxCols(tableName) ); } } @@ -3369,67 +3937,47 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoAutoIncCols, - OutboxNoAutoIncIxCols - > OutboxNoAutoInc() => new AssemblyDescriptor.Queries(from).OutboxNoAutoInc(); + global::TestLocalOutboxBadReducer, + LocalOutboxWithoutOutboxCols, + LocalOutboxWithoutOutboxIxCols + > LocalOutboxWithoutOutbox() => + new AssemblyDescriptor.Queries(from).LocalOutboxWithoutOutbox(); } } - public readonly struct OutboxNoTargetCols + public readonly struct LocalOutboxColumnIssuesCols { - public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxColumnIssues, OutboxDiag.Identity > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; + public readonly global::SpacetimeDB.Col Count; - internal OutboxNoTargetCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxColumnIssuesCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, "MsgId" ); Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, + global::TestLocalOutboxColumnIssues, OutboxDiag.Identity >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - Count = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, "Count" ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); } } - public readonly struct OutboxNoTargetIxCols + public readonly struct LocalOutboxColumnIssuesIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; + public readonly global::SpacetimeDB.IxCol MsgId; - internal OutboxNoTargetIxCols(global::SpacetimeDB.SqlTableName tableName) + internal LocalOutboxColumnIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, "MsgId" ); @@ -3441,19 +3989,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoTargetCols, - OutboxNoTargetIxCols - > OutboxNoTarget() + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxNoTarget" + "LocalOutboxColumnIssues" ); return new( tableName, - new OutboxNoTargetCols(tableName), - new OutboxNoTargetIxCols(tableName) + new LocalOutboxColumnIssuesCols(tableName), + new LocalOutboxColumnIssuesIxCols(tableName) ); } } @@ -3464,71 +4012,22 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxNoTargetCols, - OutboxNoTargetIxCols - > OutboxNoTarget() => new AssemblyDescriptor.Queries(from).OutboxNoTarget(); + global::TestLocalOutboxColumnIssues, + LocalOutboxColumnIssuesCols, + LocalOutboxColumnIssuesIxCols + > LocalOutboxColumnIssues() => + new AssemblyDescriptor.Queries(from).LocalOutboxColumnIssues(); } } - public readonly struct OutboxWrongTargetTypeCols + public readonly struct TableAndOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - > Target; - public readonly global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - > WrongTarget; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Label; - - internal OutboxWrongTargetTypeCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.Col( - tableName, - "MsgId" - ); - Target = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - OutboxDiag.Identity - >(tableName, "Target"); - WrongTarget = new global::SpacetimeDB.Col< - global::TestOutboxKeyAndTargetIssues, - SpacetimeDB.Identity - >(tableName, "WrongTarget"); - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - Count = new global::SpacetimeDB.Col( - tableName, - "Count" - ); - Label = new global::SpacetimeDB.Col( - tableName, - "Label" - ); - } + internal TableAndOutboxCols(global::SpacetimeDB.SqlTableName tableName) { } } - public readonly struct OutboxWrongTargetTypeIxCols + public readonly struct TableAndOutboxIxCols { - public readonly global::SpacetimeDB.IxCol< - global::TestOutboxKeyAndTargetIssues, - ulong - > MsgId; - - internal OutboxWrongTargetTypeIxCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.IxCol( - tableName, - "MsgId" - ); - } + internal TableAndOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor @@ -3536,19 +4035,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxWrongTargetTypeCols, - OutboxWrongTargetTypeIxCols - > OutboxWrongTargetType() + global::TestOutboxAndTable, + TableAndOutboxCols, + TableAndOutboxIxCols + > TableAndOutbox() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxWrongTargetType" + "TableAndOutbox" ); return new( tableName, - new OutboxWrongTargetTypeCols(tableName), - new OutboxWrongTargetTypeIxCols(tableName) + new TableAndOutboxCols(tableName), + new TableAndOutboxIxCols(tableName) ); } } @@ -3559,66 +4058,41 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxKeyAndTargetIssues, - OutboxWrongTargetTypeCols, - OutboxWrongTargetTypeIxCols - > OutboxWrongTargetType() => - new AssemblyDescriptor.Queries(from).OutboxWrongTargetType(); + global::TestOutboxAndTable, + TableAndOutboxCols, + TableAndOutboxIxCols + > TableAndOutbox() => new AssemblyDescriptor.Queries(from).TableAndOutbox(); } } - public readonly struct OutboxParamIssuesCols + public readonly struct TestOutboxAttributesWithoutOutboxCols { - public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestOutboxParamIssues, - OutboxDiag.Identity + global::TestOutboxAttributesWithoutOutbox, + SpacetimeDB.Identity > Target; - public readonly global::SpacetimeDB.Col Name; - public readonly global::SpacetimeDB.Col Nickname; - public readonly global::SpacetimeDB.Col Count; - public readonly global::SpacetimeDB.Col Extra; + public readonly global::SpacetimeDB.Col< + global::TestOutboxAttributesWithoutOutbox, + string + > Name; - internal OutboxParamIssuesCols(global::SpacetimeDB.SqlTableName tableName) + internal TestOutboxAttributesWithoutOutboxCols(global::SpacetimeDB.SqlTableName tableName) { - MsgId = new global::SpacetimeDB.Col( - tableName, - "MsgId" - ); Target = new global::SpacetimeDB.Col< - global::TestOutboxParamIssues, - OutboxDiag.Identity + global::TestOutboxAttributesWithoutOutbox, + SpacetimeDB.Identity >(tableName, "Target"); - Name = new global::SpacetimeDB.Col( + Name = new global::SpacetimeDB.Col( tableName, "Name" ); - Nickname = new global::SpacetimeDB.Col( - tableName, - "Nickname" - ); - Count = new global::SpacetimeDB.Col( - tableName, - "Count" - ); - Extra = new global::SpacetimeDB.Col( - tableName, - "Extra" - ); } } - public readonly struct OutboxParamIssuesIxCols + public readonly struct TestOutboxAttributesWithoutOutboxIxCols { - public readonly global::SpacetimeDB.IxCol MsgId; - - internal OutboxParamIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) - { - MsgId = new global::SpacetimeDB.IxCol( - tableName, - "MsgId" - ); - } + internal TestOutboxAttributesWithoutOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) + { } } public static partial class AssemblyDescriptor @@ -3626,19 +4100,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxParamIssues, - OutboxParamIssuesCols, - OutboxParamIssuesIxCols - > OutboxParamIssues() + global::TestOutboxAttributesWithoutOutbox, + TestOutboxAttributesWithoutOutboxCols, + TestOutboxAttributesWithoutOutboxIxCols + > TestOutboxAttributesWithoutOutbox() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxParamIssues" + "TestOutboxAttributesWithoutOutbox" ); return new( tableName, - new OutboxParamIssuesCols(tableName), - new OutboxParamIssuesIxCols(tableName) + new TestOutboxAttributesWithoutOutboxCols(tableName), + new TestOutboxAttributesWithoutOutboxIxCols(tableName) ); } } @@ -3649,21 +4123,46 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxParamIssues, - OutboxParamIssuesCols, - OutboxParamIssuesIxCols - > OutboxParamIssues() => new AssemblyDescriptor.Queries(from).OutboxParamIssues(); + global::TestOutboxAttributesWithoutOutbox, + TestOutboxAttributesWithoutOutboxCols, + TestOutboxAttributesWithoutOutboxIxCols + > TestOutboxAttributesWithoutOutbox() => + new AssemblyDescriptor.Queries(from).TestOutboxAttributesWithoutOutbox(); } } - public readonly struct OutboxTargetParamCols + public readonly struct OutboxNotAReducerCols { - internal OutboxTargetParamCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestOutboxBadReceiver, + OutboxDiag.Identity + > Target; + + internal OutboxNotAReducerCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestOutboxBadReceiver, + OutboxDiag.Identity + >(tableName, "Target"); + } } - public readonly struct OutboxTargetParamIxCols + public readonly struct OutboxNotAReducerIxCols { - internal OutboxTargetParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal OutboxNotAReducerIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor @@ -3671,19 +4170,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxTargetParam, - OutboxTargetParamCols, - OutboxTargetParamIxCols - > OutboxTargetParam() + global::TestOutboxBadReceiver, + OutboxNotAReducerCols, + OutboxNotAReducerIxCols + > OutboxNotAReducer() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxTargetParam" + "OutboxNotAReducer" ); return new( tableName, - new OutboxTargetParamCols(tableName), - new OutboxTargetParamIxCols(tableName) + new OutboxNotAReducerCols(tableName), + new OutboxNotAReducerIxCols(tableName) ); } } @@ -3694,29 +4193,21 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxTargetParam, - OutboxTargetParamCols, - OutboxTargetParamIxCols - > OutboxTargetParam() => new AssemblyDescriptor.Queries(from).OutboxTargetParam(); + global::TestOutboxBadReceiver, + OutboxNotAReducerCols, + OutboxNotAReducerIxCols + > OutboxNotAReducer() => new AssemblyDescriptor.Queries(from).OutboxNotAReducer(); } } - public readonly struct OutboxWithFieldsCols + public readonly struct OutboxEqualsParamCols { - public readonly global::SpacetimeDB.Col Name; - - internal OutboxWithFieldsCols(global::SpacetimeDB.SqlTableName tableName) - { - Name = new global::SpacetimeDB.Col( - tableName, - "Name" - ); - } + internal OutboxEqualsParamCols(global::SpacetimeDB.SqlTableName tableName) { } } - public readonly struct OutboxWithFieldsIxCols + public readonly struct OutboxEqualsParamIxCols { - internal OutboxWithFieldsIxCols(global::SpacetimeDB.SqlTableName tableName) { } + internal OutboxEqualsParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor @@ -3724,19 +4215,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestOutboxWithFields, - OutboxWithFieldsCols, - OutboxWithFieldsIxCols - > OutboxWithFields() + global::TestOutboxEqualsParam, + OutboxEqualsParamCols, + OutboxEqualsParamIxCols + > OutboxEqualsParam() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "OutboxWithFields" + "OutboxEqualsParam" ); return new( tableName, - new OutboxWithFieldsCols(tableName), - new OutboxWithFieldsIxCols(tableName) + new OutboxEqualsParamCols(tableName), + new OutboxEqualsParamIxCols(tableName) ); } } @@ -3747,50 +4238,68 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestOutboxWithFields, - OutboxWithFieldsCols, - OutboxWithFieldsIxCols - > OutboxWithFields() => new AssemblyDescriptor.Queries(from).OutboxWithFields(); + global::TestOutboxEqualsParam, + OutboxEqualsParamCols, + OutboxEqualsParamIxCols + > OutboxEqualsParam() => new AssemblyDescriptor.Queries(from).OutboxEqualsParam(); } } - public readonly struct TestScheduleWithoutPrimaryKeyCols + public readonly struct OutboxEventAndScheduledCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxEventAndScheduled, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, + global::TestOutboxEventAndScheduled, SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + > At; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithoutPrimaryKeyCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxEventAndScheduledCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + OutboxDiag.Identity + >(tableName, "Target"); + At = new global::SpacetimeDB.Col< + global::TestOutboxEventAndScheduled, + SpacetimeDB.ScheduleAt + >(tableName, "At"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithoutPrimaryKeyIxCols + public readonly struct OutboxEventAndScheduledIxCols { - internal TestScheduleWithoutPrimaryKeyIxCols(global::SpacetimeDB.SqlTableName tableName) { } + public readonly global::SpacetimeDB.IxCol MsgId; + + internal OutboxEventAndScheduledIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } } public static partial class AssemblyDescriptor @@ -3798,19 +4307,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutPrimaryKeyCols, - TestScheduleWithoutPrimaryKeyIxCols - > TestScheduleWithoutPrimaryKey() + global::TestOutboxEventAndScheduled, + OutboxEventAndScheduledCols, + OutboxEventAndScheduledIxCols + > OutboxEventAndScheduled() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestScheduleWithoutPrimaryKey" + "OutboxEventAndScheduled" ); return new( tableName, - new TestScheduleWithoutPrimaryKeyCols(tableName), - new TestScheduleWithoutPrimaryKeyIxCols(tableName) + new OutboxEventAndScheduledCols(tableName), + new OutboxEventAndScheduledIxCols(tableName) ); } } @@ -3821,59 +4330,70 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutPrimaryKeyCols, - TestScheduleWithoutPrimaryKeyIxCols - > TestScheduleWithoutPrimaryKey() => - new AssemblyDescriptor.Queries(from).TestScheduleWithoutPrimaryKey(); + global::TestOutboxEventAndScheduled, + OutboxEventAndScheduledCols, + OutboxEventAndScheduledIxCols + > OutboxEventAndScheduled() => + new AssemblyDescriptor.Queries(from).OutboxEventAndScheduled(); } } - public readonly struct TestScheduleWithWrongPrimaryKeyTypeCols + public readonly struct OutboxNoAutoIncCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithWrongPrimaryKeyTypeCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNoAutoIncCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithWrongPrimaryKeyTypeIxCols + public readonly struct OutboxNoAutoIncIxCols { - public readonly global::SpacetimeDB.IxCol IdWrongType; + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; - internal TestScheduleWithWrongPrimaryKeyTypeIxCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal OutboxNoAutoIncIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdWrongType" + "MsgId" ); } } @@ -3883,19 +4403,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongPrimaryKeyTypeCols, - TestScheduleWithWrongPrimaryKeyTypeIxCols - > TestScheduleWithWrongPrimaryKeyType() + global::TestOutboxKeyAndTargetIssues, + OutboxNoAutoIncCols, + OutboxNoAutoIncIxCols + > OutboxNoAutoInc() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestScheduleWithWrongPrimaryKeyType" + "OutboxNoAutoInc" ); return new( tableName, - new TestScheduleWithWrongPrimaryKeyTypeCols(tableName), - new TestScheduleWithWrongPrimaryKeyTypeIxCols(tableName) + new OutboxNoAutoIncCols(tableName), + new OutboxNoAutoIncIxCols(tableName) ); } } @@ -3906,57 +4426,69 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongPrimaryKeyTypeCols, - TestScheduleWithWrongPrimaryKeyTypeIxCols - > TestScheduleWithWrongPrimaryKeyType() => - new AssemblyDescriptor.Queries(from).TestScheduleWithWrongPrimaryKeyType(); + global::TestOutboxKeyAndTargetIssues, + OutboxNoAutoIncCols, + OutboxNoAutoIncIxCols + > OutboxNoAutoInc() => new AssemblyDescriptor.Queries(from).OutboxNoAutoInc(); } } - public readonly struct TestScheduleWithoutScheduleAtCols + public readonly struct OutboxNoTargetCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithoutScheduleAtCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNoTargetCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithoutScheduleAtIxCols + public readonly struct OutboxNoTargetIxCols { - public readonly global::SpacetimeDB.IxCol IdCorrectType; + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; - internal TestScheduleWithoutScheduleAtIxCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxNoTargetIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdCorrectType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdCorrectType" + "MsgId" ); } } @@ -3966,19 +4498,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutScheduleAtCols, - TestScheduleWithoutScheduleAtIxCols - > TestScheduleWithoutScheduleAt() + global::TestOutboxKeyAndTargetIssues, + OutboxNoTargetCols, + OutboxNoTargetIxCols + > OutboxNoTarget() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestScheduleWithoutScheduleAt" + "OutboxNoTarget" ); return new( tableName, - new TestScheduleWithoutScheduleAtCols(tableName), - new TestScheduleWithoutScheduleAtIxCols(tableName) + new OutboxNoTargetCols(tableName), + new OutboxNoTargetIxCols(tableName) ); } } @@ -3989,59 +4521,69 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithoutScheduleAtCols, - TestScheduleWithoutScheduleAtIxCols - > TestScheduleWithoutScheduleAt() => - new AssemblyDescriptor.Queries(from).TestScheduleWithoutScheduleAt(); + global::TestOutboxKeyAndTargetIssues, + OutboxNoTargetCols, + OutboxNoTargetIxCols + > OutboxNoTarget() => new AssemblyDescriptor.Queries(from).OutboxNoTarget(); } } - public readonly struct TestScheduleWithWrongScheduleAtTypeCols + public readonly struct OutboxWrongTargetTypeCols { - public readonly global::SpacetimeDB.Col IdWrongType; - public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col MsgId; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - int - > ScheduleAtWrongType; + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + > Target; public readonly global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - > ScheduleAtCorrectType; + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + > WrongTarget; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Label; - internal TestScheduleWithWrongScheduleAtTypeCols(global::SpacetimeDB.SqlTableName tableName) + internal OutboxWrongTargetTypeCols(global::SpacetimeDB.SqlTableName tableName) { - IdWrongType = new global::SpacetimeDB.Col( + MsgId = new global::SpacetimeDB.Col( tableName, - "IdWrongType" + "MsgId" ); - IdCorrectType = new global::SpacetimeDB.Col( + Target = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + OutboxDiag.Identity + >(tableName, "Target"); + WrongTarget = new global::SpacetimeDB.Col< + global::TestOutboxKeyAndTargetIssues, + SpacetimeDB.Identity + >(tableName, "WrongTarget"); + Name = new global::SpacetimeDB.Col( tableName, - "IdCorrectType" + "Name" ); - ScheduleAtWrongType = new global::SpacetimeDB.Col( + Count = new global::SpacetimeDB.Col( tableName, - "ScheduleAtWrongType" + "Count" + ); + Label = new global::SpacetimeDB.Col( + tableName, + "Label" ); - ScheduleAtCorrectType = new global::SpacetimeDB.Col< - global::TestScheduleIssues, - SpacetimeDB.ScheduleAt - >(tableName, "ScheduleAtCorrectType"); } } - public readonly struct TestScheduleWithWrongScheduleAtTypeIxCols + public readonly struct OutboxWrongTargetTypeIxCols { - public readonly global::SpacetimeDB.IxCol IdCorrectType; + public readonly global::SpacetimeDB.IxCol< + global::TestOutboxKeyAndTargetIssues, + ulong + > MsgId; - internal TestScheduleWithWrongScheduleAtTypeIxCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal OutboxWrongTargetTypeIxCols(global::SpacetimeDB.SqlTableName tableName) { - IdCorrectType = new global::SpacetimeDB.IxCol( + MsgId = new global::SpacetimeDB.IxCol( tableName, - "IdCorrectType" + "MsgId" ); } } @@ -4051,19 +4593,19 @@ public static partial class AssemblyDescriptor public readonly partial struct Queries { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongScheduleAtTypeCols, - TestScheduleWithWrongScheduleAtTypeIxCols - > TestScheduleWithWrongScheduleAtType() + global::TestOutboxKeyAndTargetIssues, + OutboxWrongTargetTypeCols, + OutboxWrongTargetTypeIxCols + > OutboxWrongTargetType() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestScheduleWithWrongScheduleAtType" + "OutboxWrongTargetType" ); return new( tableName, - new TestScheduleWithWrongScheduleAtTypeCols(tableName), - new TestScheduleWithWrongScheduleAtTypeIxCols(tableName) + new OutboxWrongTargetTypeCols(tableName), + new OutboxWrongTargetTypeIxCols(tableName) ); } } @@ -4074,15 +4616,202 @@ public static partial class QueryTableExtensions extension(global::SpacetimeDB.QueryBuilder from) { public global::SpacetimeDB.Table< - global::TestScheduleIssues, - TestScheduleWithWrongScheduleAtTypeCols, - TestScheduleWithWrongScheduleAtTypeIxCols - > TestScheduleWithWrongScheduleAtType() => - new AssemblyDescriptor.Queries(from).TestScheduleWithWrongScheduleAtType(); + global::TestOutboxKeyAndTargetIssues, + OutboxWrongTargetTypeCols, + OutboxWrongTargetTypeIxCols + > OutboxWrongTargetType() => + new AssemblyDescriptor.Queries(from).OutboxWrongTargetType(); } } - public readonly struct TestScheduleWithMissingScheduleAtFieldCols + public readonly struct OutboxParamIssuesCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::TestOutboxParamIssues, + OutboxDiag.Identity + > Target; + public readonly global::SpacetimeDB.Col Name; + public readonly global::SpacetimeDB.Col Nickname; + public readonly global::SpacetimeDB.Col Count; + public readonly global::SpacetimeDB.Col Extra; + + internal OutboxParamIssuesCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::TestOutboxParamIssues, + OutboxDiag.Identity + >(tableName, "Target"); + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + Nickname = new global::SpacetimeDB.Col( + tableName, + "Nickname" + ); + Count = new global::SpacetimeDB.Col( + tableName, + "Count" + ); + Extra = new global::SpacetimeDB.Col( + tableName, + "Extra" + ); + } + } + + public readonly struct OutboxParamIssuesIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal OutboxParamIssuesIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestOutboxParamIssues, + OutboxParamIssuesCols, + OutboxParamIssuesIxCols + > OutboxParamIssues() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "OutboxParamIssues" + ); + return new( + tableName, + new OutboxParamIssuesCols(tableName), + new OutboxParamIssuesIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestOutboxParamIssues, + OutboxParamIssuesCols, + OutboxParamIssuesIxCols + > OutboxParamIssues() => new AssemblyDescriptor.Queries(from).OutboxParamIssues(); + } + } + + public readonly struct OutboxTargetParamCols + { + internal OutboxTargetParamCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public readonly struct OutboxTargetParamIxCols + { + internal OutboxTargetParamIxCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestOutboxTargetParam, + OutboxTargetParamCols, + OutboxTargetParamIxCols + > OutboxTargetParam() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "OutboxTargetParam" + ); + return new( + tableName, + new OutboxTargetParamCols(tableName), + new OutboxTargetParamIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestOutboxTargetParam, + OutboxTargetParamCols, + OutboxTargetParamIxCols + > OutboxTargetParam() => new AssemblyDescriptor.Queries(from).OutboxTargetParam(); + } + } + + public readonly struct OutboxWithFieldsCols + { + public readonly global::SpacetimeDB.Col Name; + + internal OutboxWithFieldsCols(global::SpacetimeDB.SqlTableName tableName) + { + Name = new global::SpacetimeDB.Col( + tableName, + "Name" + ); + } + } + + public readonly struct OutboxWithFieldsIxCols + { + internal OutboxWithFieldsIxCols(global::SpacetimeDB.SqlTableName tableName) { } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestOutboxWithFields, + OutboxWithFieldsCols, + OutboxWithFieldsIxCols + > OutboxWithFields() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "OutboxWithFields" + ); + return new( + tableName, + new OutboxWithFieldsCols(tableName), + new OutboxWithFieldsIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestOutboxWithFields, + OutboxWithFieldsCols, + OutboxWithFieldsIxCols + > OutboxWithFields() => new AssemblyDescriptor.Queries(from).OutboxWithFields(); + } + } + + public readonly struct TestScheduleWithoutPrimaryKeyCols { public readonly global::SpacetimeDB.Col IdWrongType; public readonly global::SpacetimeDB.Col IdCorrectType; @@ -4095,9 +4824,7 @@ public readonly struct TestScheduleWithMissingScheduleAtFieldCols SpacetimeDB.ScheduleAt > ScheduleAtCorrectType; - internal TestScheduleWithMissingScheduleAtFieldCols( - global::SpacetimeDB.SqlTableName tableName - ) + internal TestScheduleWithoutPrimaryKeyCols(global::SpacetimeDB.SqlTableName tableName) { IdWrongType = new global::SpacetimeDB.Col( tableName, @@ -4118,11 +4845,9 @@ internal TestScheduleWithMissingScheduleAtFieldCols( } } - public readonly struct TestScheduleWithMissingScheduleAtFieldIxCols + public readonly struct TestScheduleWithoutPrimaryKeyIxCols { - internal TestScheduleWithMissingScheduleAtFieldIxCols( - global::SpacetimeDB.SqlTableName tableName - ) { } + internal TestScheduleWithoutPrimaryKeyIxCols(global::SpacetimeDB.SqlTableName tableName) { } } public static partial class AssemblyDescriptor @@ -4131,18 +4856,18 @@ public readonly partial struct Queries { public global::SpacetimeDB.Table< global::TestScheduleIssues, - TestScheduleWithMissingScheduleAtFieldCols, - TestScheduleWithMissingScheduleAtFieldIxCols - > TestScheduleWithMissingScheduleAtField() + TestScheduleWithoutPrimaryKeyCols, + TestScheduleWithoutPrimaryKeyIxCols + > TestScheduleWithoutPrimaryKey() { var tableName = __owner.ResolveTableName( "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestScheduleWithMissingScheduleAtField" + "TestScheduleWithoutPrimaryKey" ); return new( tableName, - new TestScheduleWithMissingScheduleAtFieldCols(tableName), - new TestScheduleWithMissingScheduleAtFieldIxCols(tableName) + new TestScheduleWithoutPrimaryKeyCols(tableName), + new TestScheduleWithoutPrimaryKeyIxCols(tableName) ); } } @@ -4154,90 +4879,1068 @@ public static partial class QueryTableExtensions { public global::SpacetimeDB.Table< global::TestScheduleIssues, - TestScheduleWithMissingScheduleAtFieldCols, - TestScheduleWithMissingScheduleAtFieldIxCols - > TestScheduleWithMissingScheduleAtField() => - new AssemblyDescriptor.Queries(from).TestScheduleWithMissingScheduleAtField(); + TestScheduleWithoutPrimaryKeyCols, + TestScheduleWithoutPrimaryKeyIxCols + > TestScheduleWithoutPrimaryKey() => + new AssemblyDescriptor.Queries(from).TestScheduleWithoutPrimaryKey(); } } - public readonly struct TestUniqueNotEquatableCols + public readonly struct TestScheduleWithWrongPrimaryKeyTypeCols { - public readonly global::SpacetimeDB.Col UniqueField; + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; public readonly global::SpacetimeDB.Col< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - > PrimaryKeyField; + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithWrongPrimaryKeyTypeCols(global::SpacetimeDB.SqlTableName tableName) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithWrongPrimaryKeyTypeIxCols + { + public readonly global::SpacetimeDB.IxCol IdWrongType; + + internal TestScheduleWithWrongPrimaryKeyTypeIxCols( + global::SpacetimeDB.SqlTableName tableName + ) + { + IdWrongType = new global::SpacetimeDB.IxCol( + tableName, + "IdWrongType" + ); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongPrimaryKeyTypeCols, + TestScheduleWithWrongPrimaryKeyTypeIxCols + > TestScheduleWithWrongPrimaryKeyType() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "TestScheduleWithWrongPrimaryKeyType" + ); + return new( + tableName, + new TestScheduleWithWrongPrimaryKeyTypeCols(tableName), + new TestScheduleWithWrongPrimaryKeyTypeIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongPrimaryKeyTypeCols, + TestScheduleWithWrongPrimaryKeyTypeIxCols + > TestScheduleWithWrongPrimaryKeyType() => + new AssemblyDescriptor.Queries(from).TestScheduleWithWrongPrimaryKeyType(); + } + } + + public readonly struct TestScheduleWithoutScheduleAtCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithoutScheduleAtCols(global::SpacetimeDB.SqlTableName tableName) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithoutScheduleAtIxCols + { + public readonly global::SpacetimeDB.IxCol IdCorrectType; + + internal TestScheduleWithoutScheduleAtIxCols(global::SpacetimeDB.SqlTableName tableName) + { + IdCorrectType = new global::SpacetimeDB.IxCol( + tableName, + "IdCorrectType" + ); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithoutScheduleAtCols, + TestScheduleWithoutScheduleAtIxCols + > TestScheduleWithoutScheduleAt() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "TestScheduleWithoutScheduleAt" + ); + return new( + tableName, + new TestScheduleWithoutScheduleAtCols(tableName), + new TestScheduleWithoutScheduleAtIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithoutScheduleAtCols, + TestScheduleWithoutScheduleAtIxCols + > TestScheduleWithoutScheduleAt() => + new AssemblyDescriptor.Queries(from).TestScheduleWithoutScheduleAt(); + } + } + + public readonly struct TestScheduleWithWrongScheduleAtTypeCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithWrongScheduleAtTypeCols(global::SpacetimeDB.SqlTableName tableName) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithWrongScheduleAtTypeIxCols + { + public readonly global::SpacetimeDB.IxCol IdCorrectType; + + internal TestScheduleWithWrongScheduleAtTypeIxCols( + global::SpacetimeDB.SqlTableName tableName + ) + { + IdCorrectType = new global::SpacetimeDB.IxCol( + tableName, + "IdCorrectType" + ); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongScheduleAtTypeCols, + TestScheduleWithWrongScheduleAtTypeIxCols + > TestScheduleWithWrongScheduleAtType() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "TestScheduleWithWrongScheduleAtType" + ); + return new( + tableName, + new TestScheduleWithWrongScheduleAtTypeCols(tableName), + new TestScheduleWithWrongScheduleAtTypeIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithWrongScheduleAtTypeCols, + TestScheduleWithWrongScheduleAtTypeIxCols + > TestScheduleWithWrongScheduleAtType() => + new AssemblyDescriptor.Queries(from).TestScheduleWithWrongScheduleAtType(); + } + } + + public readonly struct TestScheduleWithMissingScheduleAtFieldCols + { + public readonly global::SpacetimeDB.Col IdWrongType; + public readonly global::SpacetimeDB.Col IdCorrectType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + int + > ScheduleAtWrongType; + public readonly global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + > ScheduleAtCorrectType; + + internal TestScheduleWithMissingScheduleAtFieldCols( + global::SpacetimeDB.SqlTableName tableName + ) + { + IdWrongType = new global::SpacetimeDB.Col( + tableName, + "IdWrongType" + ); + IdCorrectType = new global::SpacetimeDB.Col( + tableName, + "IdCorrectType" + ); + ScheduleAtWrongType = new global::SpacetimeDB.Col( + tableName, + "ScheduleAtWrongType" + ); + ScheduleAtCorrectType = new global::SpacetimeDB.Col< + global::TestScheduleIssues, + SpacetimeDB.ScheduleAt + >(tableName, "ScheduleAtCorrectType"); + } + } + + public readonly struct TestScheduleWithMissingScheduleAtFieldIxCols + { + internal TestScheduleWithMissingScheduleAtFieldIxCols( + global::SpacetimeDB.SqlTableName tableName + ) { } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithMissingScheduleAtFieldCols, + TestScheduleWithMissingScheduleAtFieldIxCols + > TestScheduleWithMissingScheduleAtField() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "TestScheduleWithMissingScheduleAtField" + ); + return new( + tableName, + new TestScheduleWithMissingScheduleAtFieldCols(tableName), + new TestScheduleWithMissingScheduleAtFieldIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestScheduleIssues, + TestScheduleWithMissingScheduleAtFieldCols, + TestScheduleWithMissingScheduleAtFieldIxCols + > TestScheduleWithMissingScheduleAtField() => + new AssemblyDescriptor.Queries(from).TestScheduleWithMissingScheduleAtField(); + } + } + + public readonly struct TestUniqueNotEquatableCols + { + public readonly global::SpacetimeDB.Col UniqueField; + public readonly global::SpacetimeDB.Col< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + > PrimaryKeyField; + + internal TestUniqueNotEquatableCols(global::SpacetimeDB.SqlTableName tableName) + { + UniqueField = new global::SpacetimeDB.Col( + tableName, + "UniqueField" + ); + PrimaryKeyField = new global::SpacetimeDB.Col< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + >(tableName, "PrimaryKeyField"); + } + } + + public readonly struct TestUniqueNotEquatableIxCols + { + public readonly global::SpacetimeDB.IxCol< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + > PrimaryKeyField; + + internal TestUniqueNotEquatableIxCols(global::SpacetimeDB.SqlTableName tableName) + { + PrimaryKeyField = new global::SpacetimeDB.IxCol< + global::TestUniqueNotEquatable, + TestEnumWithExplicitValues + >(tableName, "PrimaryKeyField"); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::TestUniqueNotEquatable, + TestUniqueNotEquatableCols, + TestUniqueNotEquatableIxCols + > TestUniqueNotEquatable() + { + var tableName = __owner.ResolveTableName( + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "TestUniqueNotEquatable" + ); + return new( + tableName, + new TestUniqueNotEquatableCols(tableName), + new TestUniqueNotEquatableIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::TestUniqueNotEquatable, + TestUniqueNotEquatableCols, + TestUniqueNotEquatableIxCols + > TestUniqueNotEquatable() => + new AssemblyDescriptor.Queries(from).TestUniqueNotEquatable(); + } + } +} +#endif + +namespace SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles +{ + public readonly struct LocalOutboxColumnIssues + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + > + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxColumnIssues(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxColumnIssues ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxColumnIssues row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxColumnIssues.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxColumnIssues), + ProductTypeRef: (uint) + new global::TestLocalOutboxColumnIssues.BSATN() + .GetAlgebraicType(registrar) + .Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxColumnIssues_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoIter(__access); + + public global::TestLocalOutboxColumnIssues Insert( + global::TestLocalOutboxColumnIssues row + ) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.Delete(global::TestLocalOutboxColumnIssues row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxColumnIssues." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxColumnIssues, + global::TestLocalOutboxColumnIssues + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxColumnIssues can't be cleared." + ); + + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxLifecycle + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + > + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxLifecycle(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxLifecycle), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxLifecycle_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoIter(__access); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxLifecycle." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxLifecycle, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxLifecycle can't be cleared." + ); + + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxMissingReducer + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + > + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxMissingReducer(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxMissingReducer), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxMissingReducer_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoIter(__access); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxMissingReducer." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxMissingReducer, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxMissingReducer can't be cleared." + ); + + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxNotAReducer + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + > + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxNotAReducer(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxNotAReducer), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxNotAReducer_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoIter(__access); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxNotAReducer." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxNotAReducer, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxNotAReducer can't be cleared." + ); + + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalOutboxWithBindings + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + > + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxWithBindings(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxWithBindings), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxWithBindings_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoIter(__access); - internal TestUniqueNotEquatableCols(global::SpacetimeDB.SqlTableName tableName) - { - UniqueField = new global::SpacetimeDB.Col( - tableName, - "UniqueField" + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxWithBindings." ); - PrimaryKeyField = new global::SpacetimeDB.Col< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - >(tableName, "PrimaryKeyField"); - } - } - public readonly struct TestUniqueNotEquatableIxCols - { - public readonly global::SpacetimeDB.IxCol< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - > PrimaryKeyField; + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithBindings, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxWithBindings can't be cleared." + ); - internal TestUniqueNotEquatableIxCols(global::SpacetimeDB.SqlTableName tableName) - { - PrimaryKeyField = new global::SpacetimeDB.IxCol< - global::TestUniqueNotEquatable, - TestEnumWithExplicitValues - >(tableName, "PrimaryKeyField"); - } + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; } - public static partial class AssemblyDescriptor + public readonly struct LocalOutboxWithoutOutbox + : global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + > { - public readonly partial struct Queries + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalOutboxWithoutOutbox(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::TestLocalOutboxBadReducer ReadGenFields( + System.IO.BinaryReader reader, + global::TestLocalOutboxBadReducer row + ) { - public global::SpacetimeDB.Table< - global::TestUniqueNotEquatable, - TestUniqueNotEquatableCols, - TestUniqueNotEquatableIxCols - > TestUniqueNotEquatable() + if (row.MsgId == default) { - var tableName = __owner.ResolveTableName( - "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", - "TestUniqueNotEquatable" - ); - return new( - tableName, - new TestUniqueNotEquatableCols(tableName), - new TestUniqueNotEquatableIxCols(tableName) - ); + row.MsgId = global::TestLocalOutboxBadReducer.BSATN.MsgIdRW.Read(reader); } + return row; } - } - public static partial class QueryTableExtensions - { - extension(global::SpacetimeDB.QueryBuilder from) - { - public global::SpacetimeDB.Table< - global::TestUniqueNotEquatable, - TestUniqueNotEquatableCols, - TestUniqueNotEquatableIxCols - > TestUniqueNotEquatable() => - new AssemblyDescriptor.Queries(from).TestUniqueNotEquatable(); - } + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalOutboxWithoutOutbox), + ProductTypeRef: (uint) + new global::TestLocalOutboxBadReducer.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalOutboxWithoutOutbox_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoIter(__access); + + public global::TestLocalOutboxBadReducer Insert(global::TestLocalOutboxBadReducer row) => + global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.Delete(global::TestLocalOutboxBadReducer row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalOutboxWithoutOutbox." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalOutboxWithoutOutbox, + global::TestLocalOutboxBadReducer + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalOutboxWithoutOutbox can't be cleared." + ); + + private global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; } -} -#endif -namespace SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles -{ public readonly struct OutboxEqualsParam : global::SpacetimeDB.Internal.ITableView { @@ -7192,65 +8895,253 @@ public static byte[] Invoke( } catch (System.Exception e) { - global::SpacetimeDB.Log.Error("Error in view 'view_def_no_iter': " + e); - throw; + global::SpacetimeDB.Log.Error("Error in view 'view_def_no_iter': " + e); + throw; + } + } +} + +sealed class view_def_returns_not_a_spacetime_typeViewDispatcher + : global::SpacetimeDB.Internal.IAnonymousView +{ + public SpacetimeDB.Internal.RawViewDefV10 MakeAnonymousViewDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new global::SpacetimeDB.Internal.RawViewDefV10( + SourceName: "view_def_returns_not_a_spacetime_type", + Index: 3, + IsPublic: true, + IsAnonymous: true, + Params: [], + ReturnType: new SpacetimeDB.BSATN.ValueOption< + NotSpacetimeType, + NotSpacetimeType.BSATN + >().GetAlgebraicType(registrar) + ); + + public static byte[] Invoke( + System.IO.BinaryReader reader, + global::SpacetimeDB.Internal.IAnonymousViewContext ctx + ) + { + try + { + var returnValue = Module.ViewDefReturnsNotASpacetimeType( + (SpacetimeDB.AnonymousViewContext)ctx + ); + var listSerializer = SpacetimeDB.BSATN.ValueOption< + NotSpacetimeType, + NotSpacetimeType.BSATN + >.GetListSerializer(); + var listValue = ModuleRegistration.ToListOrEmpty(returnValue); + var header = new global::SpacetimeDB.Internal.ViewResultHeader.RowData(default); + var headerRW = new global::SpacetimeDB.Internal.ViewResultHeader.BSATN(); + using var output = new System.IO.MemoryStream(); + using var writer = new System.IO.BinaryWriter(output); + headerRW.Write(writer, header); + listSerializer.Write(writer, listValue); + return output.ToArray(); + } + catch (System.Exception e) + { + global::SpacetimeDB.Log.Error( + "Error in view 'view_def_returns_not_a_spacetime_type': " + e + ); + throw; + } + } +} + +namespace SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles +{ + public sealed class LocalOutboxColumnIssuesReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxColumnIssuesReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly, + global::TestLocalOutboxColumnIssues, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxColumnIssues_MsgId_idx_btree") { } + + public global::TestLocalOutboxColumnIssues? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(__access); + } + + public sealed class LocalOutboxLifecycleReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxLifecycleReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxLifecycle_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(__access); + } + + public sealed class LocalOutboxMissingReducerReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxMissingReducerReadOnly( + global::SpacetimeDB.Internal.TableAccessor access + ) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxMissingReducer_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); } + + public MsgIdIndex MsgId => new(__access); } -} -sealed class view_def_returns_not_a_spacetime_typeViewDispatcher - : global::SpacetimeDB.Internal.IAnonymousView -{ - public SpacetimeDB.Internal.RawViewDefV10 MakeAnonymousViewDef( - SpacetimeDB.BSATN.ITypeRegistrar registrar - ) => - new global::SpacetimeDB.Internal.RawViewDefV10( - SourceName: "view_def_returns_not_a_spacetime_type", - Index: 3, - IsPublic: true, - IsAnonymous: true, - Params: [], - ReturnType: new SpacetimeDB.BSATN.ValueOption< - NotSpacetimeType, - NotSpacetimeType.BSATN - >().GetAlgebraicType(registrar) - ); + public sealed class LocalOutboxNotAReducerReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxNotAReducerReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } - public static byte[] Invoke( - System.IO.BinaryReader reader, - global::SpacetimeDB.Internal.IAnonymousViewContext ctx - ) + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxNotAReducer_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(__access); + } + + public sealed class LocalOutboxWithBindingsReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView { - try + internal LocalOutboxWithBindingsReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > { - var returnValue = Module.ViewDefReturnsNotASpacetimeType( - (SpacetimeDB.AnonymousViewContext)ctx - ); - var listSerializer = SpacetimeDB.BSATN.ValueOption< - NotSpacetimeType, - NotSpacetimeType.BSATN - >.GetListSerializer(); - var listValue = ModuleRegistration.ToListOrEmpty(returnValue); - var header = new global::SpacetimeDB.Internal.ViewResultHeader.RowData(default); - var headerRW = new global::SpacetimeDB.Internal.ViewResultHeader.BSATN(); - using var output = new System.IO.MemoryStream(); - using var writer = new System.IO.BinaryWriter(output); - headerRW.Write(writer, header); - listSerializer.Write(writer, listValue); - return output.ToArray(); + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxWithBindings_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); } - catch (System.Exception e) + + public MsgIdIndex MsgId => new(__access); + } + + public sealed class LocalOutboxWithoutOutboxReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalOutboxWithoutOutboxReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly, + global::TestLocalOutboxBadReducer, + ulong, + SpacetimeDB.BSATN.U64 + > { - global::SpacetimeDB.Log.Error( - "Error in view 'view_def_returns_not_a_spacetime_type': " + e - ); - throw; + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalOutboxWithoutOutbox_MsgId_idx_btree") { } + + public global::TestLocalOutboxBadReducer? Find(ulong key) => FindSingle(key); } + + public MsgIdIndex MsgId => new(__access); } -} -namespace SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles -{ public sealed class OutboxEqualsParamReadOnly : global::SpacetimeDB.Internal.ReadOnlyTableView { @@ -7900,6 +9791,54 @@ namespace SpacetimeDB.Internal { public sealed partial class LocalReadOnly { + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxColumnIssuesReadOnly LocalOutboxColumnIssues => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxColumnIssues" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxLifecycleReadOnly LocalOutboxLifecycle => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxLifecycle" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxMissingReducerReadOnly LocalOutboxMissingReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxMissingReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxNotAReducerReadOnly LocalOutboxNotAReducer => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxNotAReducer" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithBindingsReadOnly LocalOutboxWithBindings => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithBindings" + ) + ); + public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.LocalOutboxWithoutOutboxReadOnly LocalOutboxWithoutOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "diag, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalOutboxWithoutOutbox" + ) + ); public global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.ViewHandles.OutboxEqualsParamReadOnly OutboxEqualsParam => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -8265,6 +10204,38 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class Receive : SpacetimeDB.Internal.IReducer + { + private static readonly SpacetimeDB.BSATN.String nameRW = new(); + private static readonly SpacetimeDB.BSATN.I32 countRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(Receive), + Params: + [ + new("name", nameRW.GetAlgebraicType(registrar)), + new("count", countRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxDiag.Receive( + (SpacetimeDB.ReducerContext)ctx, + nameRW.Read(reader), + countRW.Read(reader) + ); + } + } + sealed class SecondResult : SpacetimeDB.Internal.IReducer { private static readonly TestOutboxBadReceiver.BSATN rowRW = new(); @@ -8538,6 +10509,7 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); @@ -8578,6 +10550,30 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder ["renamed_identity"] ); + builder.RegisterTable< + global::TestLocalOutboxColumnIssues, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxColumnIssues + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxLifecycle + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxMissingReducer + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxNotAReducer + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithBindings + >(); + builder.RegisterTable< + global::TestLocalOutboxBadReducer, + global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.LocalOutboxWithoutOutbox + >(); builder.RegisterTable< global::TestOutboxEqualsParam, global::SpacetimeDB.Generated.diag_4F830E2879BB50E3.TableHandles.OutboxEqualsParam @@ -9094,7 +11090,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_6( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - SecondResult.Invoke(reader, ctx); + Receive.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9134,7 +11130,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_7( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerKind1.Invoke(reader, ctx); + SecondResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9174,7 +11170,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_8( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerKind2.Invoke(reader, ctx); + TestDuplicateReducerKind1.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9214,7 +11210,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_9( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestDuplicateReducerName.Invoke(reader, ctx); + TestDuplicateReducerKind2.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9254,7 +11250,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_10( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestReducerReturnType.Invoke(reader, ctx); + TestDuplicateReducerName.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9294,7 +11290,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_11( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - TestReducerWithoutContext.Invoke(reader, ctx); + TestReducerReturnType.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9334,7 +11330,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_12( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - UnknownTable.Invoke(reader, ctx); + TestReducerWithoutContext.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -9356,6 +11352,46 @@ private static SpacetimeDB.Internal.Errno __call_reducer_13( SpacetimeDB.Internal.BytesSink error, int instanceId = 0 ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + UnknownTable.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_14( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) { try { @@ -10122,6 +12158,18 @@ internal static SpacetimeDB.Internal.Errno CallLocalReducer( error, instanceId ), + 14 => __call_reducer_14( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), _ => SpacetimeDB.Internal.Module.WriteReducerError( error, new System.ArgumentOutOfRangeException(nameof(id), id, "Unknown reducer id") diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#LocalOutboxDiag.Receive.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#LocalOutboxDiag.Receive.verified.cs new file mode 100644 index 00000000000..1e9f0afd33b --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#LocalOutboxDiag.Receive.verified.cs @@ -0,0 +1,23 @@ +//HintName: LocalOutboxDiag.Receive.cs +// +#nullable enable + +partial class LocalOutboxDiag +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceive(string name, int count) => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceive<__Context>( + __Context __context, + string name, + int count + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); +} // LocalOutboxDiag diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxBadReducer.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxBadReducer.verified.cs new file mode 100644 index 00000000000..9b50a6239c2 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxBadReducer.verified.cs @@ -0,0 +1,119 @@ +//HintName: TestLocalOutboxBadReducer.cs +// +#nullable enable + +partial struct TestLocalOutboxBadReducer + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Name = BSATN.NameRW.Read(reader); + Count = BSATN.CountRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.NameRW.Write(writer, Name); + BSATN.CountRW.Write(writer, Count); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"TestLocalOutboxBadReducer {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Name = {SpacetimeDB.BSATN.StringUtil.GenericToString(Name)}, Count = {SpacetimeDB.BSATN.StringUtil.GenericToString(Count)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.String NameRW = new(); + internal static readonly SpacetimeDB.BSATN.I32 CountRW = new(); + + public TestLocalOutboxBadReducer Read(System.IO.BinaryReader reader) + { + var ___result = new TestLocalOutboxBadReducer(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, TestLocalOutboxBadReducer value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Name", NameRW.GetAlgebraicType(registrar)), + new("Count", CountRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashName = Name == null ? 0 : Name.GetHashCode(); + var ___hashCount = Count.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashName ^ ___hashCount; + } + +#nullable enable + public bool Equals(TestLocalOutboxBadReducer that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqName = this.Name == null ? that.Name == null : this.Name.Equals(that.Name); + var ___eqCount = this.Count.Equals(that.Count); + return ___eqMsgId && ___eqTarget && ___eqName && ___eqCount; + } + + public override bool Equals(object? that) + { + return that is TestLocalOutboxBadReducer t && Equals(t); + } + + public static bool operator ==(TestLocalOutboxBadReducer this_, TestLocalOutboxBadReducer that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(TestLocalOutboxBadReducer this_, TestLocalOutboxBadReducer that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // TestLocalOutboxBadReducer diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxColumnIssues.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxColumnIssues.verified.cs new file mode 100644 index 00000000000..2437518b3de --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10#TestLocalOutboxColumnIssues.verified.cs @@ -0,0 +1,119 @@ +//HintName: TestLocalOutboxColumnIssues.cs +// +#nullable enable + +partial struct TestLocalOutboxColumnIssues + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Count = BSATN.CountRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.CountRW.Write(writer, Count); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"TestLocalOutboxColumnIssues {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Count = {SpacetimeDB.BSATN.StringUtil.GenericToString(Count)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly OutboxDiag.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 CountRW = new(); + + public TestLocalOutboxColumnIssues Read(System.IO.BinaryReader reader) + { + var ___result = new TestLocalOutboxColumnIssues(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, TestLocalOutboxColumnIssues value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Count", CountRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashCount = Count.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashCount; + } + +#nullable enable + public bool Equals(TestLocalOutboxColumnIssues that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqCount = this.Count.Equals(that.Count); + return ___eqMsgId && ___eqTarget && ___eqCount; + } + + public override bool Equals(object? that) + { + return that is TestLocalOutboxColumnIssues t && Equals(t); + } + + public static bool operator ==( + TestLocalOutboxColumnIssues this_, + TestLocalOutboxColumnIssues that + ) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=( + TestLocalOutboxColumnIssues this_, + TestLocalOutboxColumnIssues that + ) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // TestLocalOutboxColumnIssues diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10.verified.txt b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10.verified.txt index d138637a4dd..a35eb6a3975 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10.verified.txt +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.net10.verified.txt @@ -316,7 +316,7 @@ public partial struct TestScheduleIssues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxBadReceiver */ - Message: OutboxNotAReducer: Outbox type OutboxDiag.NotAReducer is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes., + Message: OutboxNotAReducer: Outbox type OutboxDiag.NotAReducer is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes, or set OutboxReducer to call a reducer of this module., Severity: Error, Descriptor: { Id: STDB0047, @@ -522,6 +522,198 @@ public partial struct TestOutboxParamIssues } }, {/* +// OutboxReducer; OutboxReducer without Outbox. +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxMissingReducer", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = "Missing" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxMissingReducer: LocalOutboxDiag has no [Reducer] method named Missing. Set Outbox to the class declaring the reducer, and OutboxReducer to nameof(that reducer)., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxNotAReducer", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.NotAReducer) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxNotAReducer: LocalOutboxDiag has no [Reducer] method named NotAReducer. Set Outbox to the class declaring the reducer, and OutboxReducer to nameof(that reducer)., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxLifecycle", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(OnResultIssues), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(OnResultIssues.LifecycleResult) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxLifecycle: LifecycleResult is a lifecycle reducer, so an outbox can't call it., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxWithBindings", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(OutboxDiag.Reducers.Remote), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = "Remote" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table(Accessor = "LocalOutboxWithoutOutbox", OutboxReducer = "Receive")] +*/ + Message: LocalOutboxWithBindings: Outbox type OutboxDiag.Reducers.Remote is a reducer from receiver bindings, so it can't take OutboxReducer. Remove OutboxReducer, or set Outbox to the class declaring Remote., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table(Accessor = "LocalOutboxWithoutOutbox", OutboxReducer = "Receive")] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +public partial struct TestLocalOutboxBadReducer +*/ + Message: LocalOutboxWithoutOutbox sets OutboxReducer without Outbox. Set Outbox to the class declaring Receive., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues.Target is the [Target] column, so it must have type SpacetimeDB.Identity, not OutboxDiag.Identity., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues has no column for parameter `name` of Receive. Add a column named like it, or mark one with [Param("name")]., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues.Count has type uint, but parameter `count` of Receive has type int., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* [SpacetimeDB.Target] public Identity Target; ^^^^^^ @@ -561,7 +753,7 @@ public partial struct TestOutboxParamIssues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxTargetParam { } */ - Message: [Outbox] can't name a column Target for parameter `target` of TakesTarget, because TestOutboxTargetParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., + Message: [Outbox] can't name a column Target for parameter `target` of takes_target, because TestOutboxTargetParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., Severity: Error, Descriptor: { Id: STDB0047, @@ -578,7 +770,7 @@ public partial struct TestOutboxTargetParam { } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxEqualsParam { } */ - Message: [Outbox] can't name a column Equals for parameter `equals` of TakesEquals, because TestOutboxEqualsParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., + Message: [Outbox] can't name a column Equals for parameter `equals` of takes_equals, because TestOutboxEqualsParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., Severity: Error, Descriptor: { Id: STDB0047, diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.verified.txt b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.verified.txt index d138637a4dd..a35eb6a3975 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.verified.txt +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/Module.verified.txt @@ -316,7 +316,7 @@ public partial struct TestScheduleIssues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxBadReceiver */ - Message: OutboxNotAReducer: Outbox type OutboxDiag.NotAReducer is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes., + Message: OutboxNotAReducer: Outbox type OutboxDiag.NotAReducer is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes, or set OutboxReducer to call a reducer of this module., Severity: Error, Descriptor: { Id: STDB0047, @@ -522,6 +522,198 @@ public partial struct TestOutboxParamIssues } }, {/* +// OutboxReducer; OutboxReducer without Outbox. +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxMissingReducer", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = "Missing" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxMissingReducer: LocalOutboxDiag has no [Reducer] method named Missing. Set Outbox to the class declaring the reducer, and OutboxReducer to nameof(that reducer)., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxNotAReducer", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.NotAReducer) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxNotAReducer: LocalOutboxDiag has no [Reducer] method named NotAReducer. Set Outbox to the class declaring the reducer, and OutboxReducer to nameof(that reducer)., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxLifecycle", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(OnResultIssues), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(OnResultIssues.LifecycleResult) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table( +*/ + Message: LocalOutboxLifecycle: LifecycleResult is a lifecycle reducer, so an outbox can't call it., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxWithBindings", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(OutboxDiag.Reducers.Remote), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = "Remote" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +[SpacetimeDB.Table(Accessor = "LocalOutboxWithoutOutbox", OutboxReducer = "Receive")] +*/ + Message: LocalOutboxWithBindings: Outbox type OutboxDiag.Reducers.Remote is a reducer from receiver bindings, so it can't take OutboxReducer. Remove OutboxReducer, or set Outbox to the class declaring Remote., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* +)] +[SpacetimeDB.Table(Accessor = "LocalOutboxWithoutOutbox", OutboxReducer = "Receive")] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +public partial struct TestLocalOutboxBadReducer +*/ + Message: LocalOutboxWithoutOutbox sets OutboxReducer without Outbox. Set Outbox to the class declaring Receive., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues.Target is the [Target] column, so it must have type SpacetimeDB.Identity, not OutboxDiag.Identity., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues has no column for parameter `name` of Receive. Add a column named like it, or mark one with [Param("name")]., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* + +[SpacetimeDB.Table( + ^^^^^^^^^^^^^^^^^^ + Accessor = "LocalOutboxColumnIssues", +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Outbox = typeof(LocalOutboxDiag), +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + OutboxReducer = nameof(LocalOutboxDiag.Receive) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +)] +^ +public partial struct TestLocalOutboxColumnIssues +*/ + Message: LocalOutboxColumnIssues.Count has type uint, but parameter `count` of Receive has type int., + Severity: Error, + Descriptor: { + Id: STDB0047, + Title: Invalid outbox table declaration, + MessageFormat: {0}, + Category: SpacetimeDB, + DefaultSeverity: Error, + IsEnabledByDefault: true + } + }, + {/* [SpacetimeDB.Target] public Identity Target; ^^^^^^ @@ -561,7 +753,7 @@ public partial struct TestOutboxParamIssues ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxTargetParam { } */ - Message: [Outbox] can't name a column Target for parameter `target` of TakesTarget, because TestOutboxTargetParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., + Message: [Outbox] can't name a column Target for parameter `target` of takes_target, because TestOutboxTargetParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., Severity: Error, Descriptor: { Id: STDB0047, @@ -578,7 +770,7 @@ public partial struct TestOutboxTargetParam { } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ public partial struct TestOutboxEqualsParam { } */ - Message: [Outbox] can't name a column Equals for parameter `equals` of TakesEquals, because TestOutboxEqualsParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., + Message: [Outbox] can't name a column Equals for parameter `equals` of takes_equals, because TestOutboxEqualsParam already uses that name. Declare the outbox table with [Table(Outbox = ...)] instead, and give the columns other names., Severity: Error, Descriptor: { Id: STDB0047, diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs index 840ee4206c9..1bd5243d857 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs @@ -455,3 +455,70 @@ public static void OnPingResult( Result result ) { } } + +// A local outbox calls a reducer of this module, so it needs no receiver bindings. +public static partial class LocalOutboxReducers +{ + // The outbox names the source name, ReceiveLocalPing, not the canonical one. + [SpacetimeDB.Reducer(Name = "AcceptLocalPing")] + public static void ReceiveLocalPing(ReducerContext ctx, string messageBody, uint attempt) { } + + [SpacetimeDB.Reducer] + public static void SendLocalPing(ReducerContext ctx) + { + ctx.Db.LocalPingOutbox.Insert( + new LocalPingRow + { + Target = ctx.Sender, + Attempt = 1, + Body = "ping", + } + ); + ctx.Db.LocalPingGenerated.Insert( + new LocalPingGeneratedRow + { + Target = ctx.Sender, + MessageBody = "ping", + Attempt = 1, + } + ); + } + + [SpacetimeDB.Reducer] + [SpacetimeDB.OnResult(typeof(LocalPingRow))] + public static void OnLocalPingResult( + ReducerContext ctx, + LocalPingRow row, + Result result + ) { } +} + +[SpacetimeDB.Table( + Accessor = "LocalPingOutbox", + Outbox = typeof(LocalOutboxReducers), + OutboxReducer = nameof(LocalOutboxReducers.ReceiveLocalPing) +)] +public partial struct LocalPingRow +{ + [SpacetimeDB.PrimaryKey] + [SpacetimeDB.AutoInc] + public ulong MsgId; + + [SpacetimeDB.Target] + public Identity Target; + + // Columns follow the reducer's parameter order on the wire, not their own. + // Matches `attempt` by its snake_case name. + public uint Attempt; + + [SpacetimeDB.Param("messageBody")] + public string Body; +} + +// [Outbox] declares MsgId, Target, MessageBody and Attempt. +[SpacetimeDB.Outbox( + typeof(LocalOutboxReducers), + ReducerName = nameof(LocalOutboxReducers.ReceiveLocalPing), + Accessor = "LocalPingGenerated" +)] +public partial struct LocalPingGeneratedRow { } diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs index b9f718b5df6..276cfdd22a4 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs @@ -248,6 +248,107 @@ public readonly partial struct QueryBuilder new("BTreeViews", new BTreeViewsCols("BTreeViews"), new BTreeViewsIxCols("BTreeViews")); } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => + new( + "LocalPingGenerated", + new LocalPingGeneratedCols("LocalPingGenerated"), + new LocalPingGeneratedIxCols("LocalPingGenerated") + ); + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => + new( + "LocalPingOutbox", + new LocalPingOutboxCols("LocalPingOutbox"), + new LocalPingOutboxIxCols("LocalPingOutbox") + ); + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -940,6 +1041,9 @@ public sealed class Local : global::SpacetimeDB.LocalBase internal global::SpacetimeDB.Internal.TableHandles.BTreeMultiColumn BTreeMultiColumn => new(); internal global::SpacetimeDB.Internal.TableHandles.BTreeViews BTreeViews => new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingGenerated LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingOutbox LocalPingOutbox => new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable1 MultiTable1 => new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable2 MultiTable2 => new(); public global::SpacetimeDB.Internal.TableHandles.PingLog PingLog => new(); @@ -986,8 +1090,9 @@ public static partial class AssemblyDescriptor public const string? CaseConversionPolicy = null; public const string RootOnlyDeclarations = "row-level security filters, environment variables, lifecycle reducer Timers.Init (Init)"; - public const string OutboxTables = "AdmitGenerated, AdmitOutbox, PingOutbox"; - public const int ReducerCount = 8; + public const string OutboxTables = + "AdmitGenerated, AdmitOutbox, LocalPingGenerated, LocalPingOutbox, PingOutbox"; + public const int ReducerCount = 11; public const int ProcedureCount = 0; public const int HttpHandlerCount = 0; public const int ViewCount = 2; @@ -1125,6 +1230,10 @@ public Tables(global::SpacetimeDB.Internal.Local? db) internal global::SpacetimeDB.Internal.TableHandles.BTreeMultiColumn BTreeMultiColumn => new(); internal global::SpacetimeDB.Internal.TableHandles.BTreeViews BTreeViews => new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingGenerated LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingOutbox LocalPingOutbox => + new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable1 MultiTable1 => new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable2 MultiTable2 => new(); public global::SpacetimeDB.Internal.TableHandles.PingLog PingLog => new(); @@ -1154,6 +1263,10 @@ public ReadOnlyTables(global::SpacetimeDB.Internal.LocalReadOnly? db) new(); internal global::SpacetimeDB.Internal.ViewHandles.BTreeViewsReadOnly BTreeViews => new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable1ReadOnly MultiTable1 => new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable2ReadOnly MultiTable2 => @@ -1190,6 +1303,10 @@ public static class LocalTableExtensions internal global::SpacetimeDB.Internal.TableHandles.BTreeMultiColumn BTreeMultiColumn => new(); internal global::SpacetimeDB.Internal.TableHandles.BTreeViews BTreeViews => new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingGenerated LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.TableHandles.LocalPingOutbox LocalPingOutbox => + new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable1 MultiTable1 => new(); public global::SpacetimeDB.Internal.TableHandles.MultiTable2 MultiTable2 => new(); public global::SpacetimeDB.Internal.TableHandles.PingLog PingLog => new(); @@ -1215,6 +1332,10 @@ public static class ReadOnlyTableExtensions new(); internal global::SpacetimeDB.Internal.ViewHandles.BTreeViewsReadOnly BTreeViews => new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable1ReadOnly MultiTable1 => new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable2ReadOnly MultiTable2 => @@ -1626,6 +1747,192 @@ public static partial class QueryTableExtensions } } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] LocalPingGeneratedSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName LocalPingGeneratedSqlName( + int contextInstance + ) + { + var names = LocalPingGeneratedSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalPingGenerated" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() + { + var tableName = LocalPingGeneratedSqlName(__instanceId); + return new( + tableName, + new LocalPingGeneratedCols(tableName), + new LocalPingGeneratedIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => new AssemblyDescriptor.Queries(from).LocalPingGenerated(); + } + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] LocalPingOutboxSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName LocalPingOutboxSqlName(int contextInstance) + { + var names = LocalPingOutboxSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "LocalPingOutbox"); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() + { + var tableName = LocalPingOutboxSqlName(__instanceId); + return new( + tableName, + new LocalPingOutboxCols(tableName), + new LocalPingOutboxIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => new AssemblyDescriptor.Queries(from).LocalPingOutbox(); + } + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -2996,17 +3303,17 @@ public ulong Delete(global::SpacetimeDB.Bound Faction) => internal FactionIndex Faction => new(); } - public readonly struct MultiTable1 - : global::SpacetimeDB.Internal.ITableView + public readonly struct LocalPingGenerated + : global::SpacetimeDB.Internal.ITableView { - public static global::MultiTableRow ReadGenFields( + public static global::LocalPingGeneratedRow ReadGenFields( System.IO.BinaryReader reader, - global::MultiTableRow row + global::LocalPingGeneratedRow row ) { - if (row.Foo == default) + if (row.MsgId == default) { - row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + row.MsgId = global::LocalPingGeneratedRow.BSATN.MsgIdRW.Read(reader); } return row; } @@ -3015,48 +3322,40 @@ public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( - SourceName: nameof(MultiTable1), + SourceName: nameof(LocalPingGenerated), ProductTypeRef: (uint) - new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, - PrimaryKey: [1], + new global::LocalPingGeneratedRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], Indexes: [ new( - SourceName: "MultiTable1_Foo_idx_btree", - AccessorName: "Foo", - Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) - ), - new( - SourceName: "MultiTable1_Name_idx_btree", - AccessorName: "Name", + SourceName: "LocalPingGenerated_MsgId_idx_btree", + AccessorName: "MsgId", Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) ), ], Constraints: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeUniqueConstraint(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeUniqueConstraint(0), ], Sequences: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeSequence(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeSequence(0), ], TableType: SpacetimeDB.Internal.TableType.User, - TableAccess: SpacetimeDB.Internal.TableAccess.Public, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, DefaultValues: [], IsEvent: false ); public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; - public static SpacetimeDB.TableCachePolicy CachePolicy => - SpacetimeDB.TableCachePolicy.RequiredOnDisk; - /// /// Returns the number of rows in this table. /// @@ -3064,31 +3363,234 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar /// It also takes into account modifications by the current transaction. /// public ulong Count => - global::SpacetimeDB.Internal.ITableView.DoCount(); + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoCount(); - public IEnumerable Iter() => - global::SpacetimeDB.Internal.ITableView.DoIter(); + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoIter(); - public global::MultiTableRow Insert(global::MultiTableRow row) => - global::SpacetimeDB.Internal.ITableView.DoInsert( - row + public global::LocalPingGeneratedRow Insert(global::LocalPingGeneratedRow row) => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoInsert(row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Delete(global::LocalPingGeneratedRow row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingGenerated." ); - public bool Delete(global::MultiTableRow row) => - global::SpacetimeDB.Internal.ITableView.DoDelete( - row + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingGenerated can't be cleared." ); - public ulong Clear() => - global::SpacetimeDB.Internal.ITableView.DoClear(); + private static global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } - public sealed class FooUniqueIndex - : global::SpacetimeDB.Internal.UniqueIndex< - MultiTable1, - global::MultiTableRow, - uint, - SpacetimeDB.BSATN.U32 - > + public readonly struct LocalPingOutbox + : global::SpacetimeDB.Internal.ITableView + { + public static global::LocalPingRow ReadGenFields( + System.IO.BinaryReader reader, + global::LocalPingRow row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::LocalPingRow.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalPingOutbox), + ProductTypeRef: (uint) + new global::LocalPingRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalPingOutbox_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter(); + + public global::LocalPingRow Insert(global::LocalPingRow row) => + global::SpacetimeDB.Internal.ITableView.DoInsert( + row + ); + + bool global::SpacetimeDB.Internal.ITableView.Delete( + global::LocalPingRow row + ) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingOutbox." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingOutbox can't be cleared." + ); + + private static global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly? __readOnly; + private global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly __ReadOnly => + __readOnly ??= new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct MultiTable1 + : global::SpacetimeDB.Internal.ITableView + { + public static global::MultiTableRow ReadGenFields( + System.IO.BinaryReader reader, + global::MultiTableRow row + ) + { + if (row.Foo == default) + { + row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(MultiTable1), + ProductTypeRef: (uint) + new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [1], + Indexes: + [ + new( + SourceName: "MultiTable1_Foo_idx_btree", + AccessorName: "Foo", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) + ), + new( + SourceName: "MultiTable1_Name_idx_btree", + AccessorName: "Name", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeUniqueConstraint(1), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeSequence(1), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Public, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + public static SpacetimeDB.TableCachePolicy CachePolicy => + SpacetimeDB.TableCachePolicy.RequiredOnDisk; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView.DoCount(); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter(); + + public global::MultiTableRow Insert(global::MultiTableRow row) => + global::SpacetimeDB.Internal.ITableView.DoInsert( + row + ); + + public bool Delete(global::MultiTableRow row) => + global::SpacetimeDB.Internal.ITableView.DoDelete( + row + ); + + public ulong Clear() => + global::SpacetimeDB.Internal.ITableView.DoClear(); + + public sealed class FooUniqueIndex + : global::SpacetimeDB.Internal.UniqueIndex< + MultiTable1, + global::MultiTableRow, + uint, + SpacetimeDB.BSATN.U32 + > { internal FooUniqueIndex() : base("MultiTable1_Foo_idx_btree") { } @@ -4305,6 +4807,68 @@ internal FactionIndex() internal FactionIndex Faction => new(); } + public sealed class LocalPingGeneratedReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalPingGeneratedReadOnly() + : base("LocalPingGenerated") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly, + global::LocalPingGeneratedRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalPingGenerated_MsgId_idx_btree") { } + + public global::LocalPingGeneratedRow? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + + public sealed class LocalPingOutboxReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalPingOutboxReadOnly() + : base("LocalPingOutbox") { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly, + global::LocalPingRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex() + : base("LocalPingOutbox_MsgId_idx_btree") { } + + public global::LocalPingRow? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(); + } + public sealed class MultiTable1ReadOnly : global::SpacetimeDB.Internal.ReadOnlyTableView { @@ -4626,6 +5190,10 @@ public sealed partial class LocalReadOnly internal global::SpacetimeDB.Internal.ViewHandles.BTreeMultiColumnReadOnly BTreeMultiColumn => new(); internal global::SpacetimeDB.Internal.ViewHandles.BTreeViewsReadOnly BTreeViews => new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new(); + public global::SpacetimeDB.Internal.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable1ReadOnly MultiTable1 => new(); public global::SpacetimeDB.Internal.ViewHandles.MultiTable2ReadOnly MultiTable2 => new(); public global::SpacetimeDB.Internal.ViewHandles.PingLogReadOnly PingLog => new(); @@ -4744,6 +5312,41 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class OnLocalPingResult : SpacetimeDB.Internal.IReducer + { + private static readonly LocalPingRow.BSATN rowRW = new(); + private static readonly SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + > resultRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(OnLocalPingResult), + Params: + [ + new("row", rowRW.GetAlgebraicType(registrar)), + new("result", resultRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.OnLocalPingResult( + (SpacetimeDB.ReducerContext)ctx, + rowRW.Read(reader), + resultRW.Read(reader) + ); + } + } + sealed class OnPingResult : SpacetimeDB.Internal.IReducer { private static readonly PingRow.BSATN rowRW = new(); @@ -4779,6 +5382,38 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class ReceiveLocalPing : SpacetimeDB.Internal.IReducer + { + private static readonly SpacetimeDB.BSATN.String messageBodyRW = new(); + private static readonly SpacetimeDB.BSATN.U32 attemptRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(ReceiveLocalPing), + Params: + [ + new("messageBody", messageBodyRW.GetAlgebraicType(registrar)), + new("attempt", attemptRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.ReceiveLocalPing( + (SpacetimeDB.ReducerContext)ctx, + messageBodyRW.Read(reader), + attemptRW.Read(reader) + ); + } + } + sealed class ScheduleImmediate : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN dataRW = new(); @@ -4802,6 +5437,27 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class SendLocalPing : SpacetimeDB.Internal.IReducer + { + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(SendLocalPing), + Params: [], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.SendLocalPing((SpacetimeDB.ReducerContext)ctx); + } + } + sealed class SendOutboxes : SpacetimeDB.Internal.IReducer { public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( @@ -4907,6 +5563,7 @@ internal static void RegisterModule(global::SpacetimeDB.Internal.ModuleBuilder b internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder) { + builder.RegisterExplicitFunctionName("ReceiveLocalPing", "AcceptLocalPing"); var __memoryStream = new MemoryStream(); var __writer = new BinaryWriter(__memoryStream); @@ -4914,8 +5571,11 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); @@ -4942,6 +5602,14 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder global::BTreeViews, global::SpacetimeDB.Internal.TableHandles.BTreeViews >(); + builder.RegisterTable< + global::LocalPingGeneratedRow, + global::SpacetimeDB.Internal.TableHandles.LocalPingGenerated + >(); + builder.RegisterTable< + global::LocalPingRow, + global::SpacetimeDB.Internal.TableHandles.LocalPingOutbox + >(); builder.RegisterTable< global::MultiTableRow, global::SpacetimeDB.Internal.TableHandles.MultiTable1 @@ -4997,6 +5665,24 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder ) ) ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingGenerated", + "ReceiveLocalPing", + 1, + [2, 3], + null + ) + ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingOutbox", + "ReceiveLocalPing", + 1, + [3, 2], + "OnLocalPingResult" + ) + ); builder.RegisterOutbox( new global::SpacetimeDB.Internal.RawOutboxDefV10( "PingOutbox", @@ -5202,7 +5888,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - OnPingResult.Invoke(reader, ctx); + OnLocalPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5240,7 +5926,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - ScheduleImmediate.Invoke(reader, ctx); + OnPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5278,7 +5964,7 @@ SpacetimeDB.Internal.BytesSink error ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - SendOutboxes.Invoke(reader, ctx); + ReceiveLocalPing.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5299,6 +5985,120 @@ private static SpacetimeDB.Internal.Errno __call_reducer_7( SpacetimeDB.Internal.BytesSource args, SpacetimeDB.Internal.BytesSink error ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + ScheduleImmediate.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_8( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendLocalPing.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_9( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendOutboxes.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_10( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error + ) { try { @@ -5583,6 +6383,39 @@ SpacetimeDB.Internal.BytesSink error args, error ), + 8 => __call_reducer_8( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error + ), + 9 => __call_reducer_9( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error + ), + 10 => __call_reducer_10( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error + ), _ => SpacetimeDB.Internal.Module.WriteReducerError( error, new System.ArgumentOutOfRangeException(nameof(id), id, "Unknown reducer id") diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.OnLocalPingResult.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.OnLocalPingResult.verified.cs new file mode 100644 index 00000000000..cbd12e6e50a --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.OnLocalPingResult.verified.cs @@ -0,0 +1,25 @@ +//HintName: LocalOutboxReducers.OnLocalPingResult.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateOnLocalPingResult( + LocalPingRow row, + SpacetimeDB.Result result + ) + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new LocalPingRow.BSATN().Write(writer, row); + new SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + >().Write(writer, result); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate( + nameof(OnLocalPingResult), + stream + ); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.ReceiveLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.ReceiveLocalPing.verified.cs new file mode 100644 index 00000000000..bb888ef5fea --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.ReceiveLocalPing.verified.cs @@ -0,0 +1,19 @@ +//HintName: LocalOutboxReducers.ReceiveLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceiveLocalPing( + string messageBody, + uint attempt + ) + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new SpacetimeDB.BSATN.String().Write(writer, messageBody); + new SpacetimeDB.BSATN.U32().Write(writer, attempt); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate("AcceptLocalPing", stream); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.SendLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.SendLocalPing.verified.cs new file mode 100644 index 00000000000..a99e4916282 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalOutboxReducers.SendLocalPing.verified.cs @@ -0,0 +1,18 @@ +//HintName: LocalOutboxReducers.SendLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateSendLocalPing() + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate( + nameof(SendLocalPing), + stream + ); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingGeneratedRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingGeneratedRow.verified.cs new file mode 100644 index 00000000000..7bc713e21c0 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingGeneratedRow.verified.cs @@ -0,0 +1,127 @@ +//HintName: LocalPingGeneratedRow.cs +// +#nullable enable + +partial struct LocalPingGeneratedRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ + public ulong MsgId; + public SpacetimeDB.Identity Target; + public string MessageBody; + public uint Attempt; + +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + MessageBody = BSATN.MessageBodyRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.MessageBodyRW.Write(writer, MessageBody); + BSATN.AttemptRW.Write(writer, Attempt); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingGeneratedRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, MessageBody = {SpacetimeDB.BSATN.StringUtil.GenericToString(MessageBody)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.String MessageBodyRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + + public LocalPingGeneratedRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingGeneratedRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingGeneratedRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("MessageBody", MessageBodyRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashMessageBody = MessageBody == null ? 0 : MessageBody.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashMessageBody ^ ___hashAttempt; + } + +#nullable enable + public bool Equals(LocalPingGeneratedRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqMessageBody = + this.MessageBody == null + ? that.MessageBody == null + : this.MessageBody.Equals(that.MessageBody); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + return ___eqMsgId && ___eqTarget && ___eqMessageBody && ___eqAttempt; + } + + public override bool Equals(object? that) + { + return that is LocalPingGeneratedRow t && Equals(t); + } + + public static bool operator ==(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingGeneratedRow diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingRow.verified.cs new file mode 100644 index 00000000000..d1fb61f01f1 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#LocalPingRow.verified.cs @@ -0,0 +1,117 @@ +//HintName: LocalPingRow.cs +// +#nullable enable + +partial struct LocalPingRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + Body = BSATN.BodyRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.AttemptRW.Write(writer, Attempt); + BSATN.BodyRW.Write(writer, Body); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)}, Body = {SpacetimeDB.BSATN.StringUtil.GenericToString(Body)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + internal static readonly SpacetimeDB.BSATN.String BodyRW = new(); + + public LocalPingRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType(_ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + new("Body", BodyRW.GetAlgebraicType(registrar)), + } + )); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + var ___hashBody = Body == null ? 0 : Body.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashAttempt ^ ___hashBody; + } + +#nullable enable + public bool Equals(LocalPingRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + var ___eqBody = this.Body == null ? that.Body == null : this.Body.Equals(that.Body); + return ___eqMsgId && ___eqTarget && ___eqAttempt && ___eqBody; + } + + public override bool Equals(object? that) + { + return that is LocalPingRow t && Equals(t); + } + + public static bool operator ==(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingRow diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs index c8a1d4fb15d..d3482bcfa54 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs @@ -248,6 +248,107 @@ public readonly partial struct QueryBuilder new("BTreeViews", new BTreeViewsCols("BTreeViews"), new BTreeViewsIxCols("BTreeViews")); } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => + new( + "LocalPingGenerated", + new LocalPingGeneratedCols("LocalPingGenerated"), + new LocalPingGeneratedIxCols("LocalPingGenerated") + ); + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => + new( + "LocalPingOutbox", + new LocalPingOutboxCols("LocalPingOutbox"), + new LocalPingOutboxIxCols("LocalPingOutbox") + ); + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -967,6 +1068,22 @@ public sealed class Local : global::SpacetimeDB.LocalBase "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1068,8 +1185,9 @@ public static partial class AssemblyDescriptor public const string? CaseConversionPolicy = null; public const string RootOnlyDeclarations = "row-level security filters, environment variables, lifecycle reducer Timers.Init (Init)"; - public const string OutboxTables = "AdmitGenerated, AdmitOutbox, PingOutbox"; - public const int ReducerCount = 8; + public const string OutboxTables = + "AdmitGenerated, AdmitOutbox, LocalPingGenerated, LocalPingOutbox, PingOutbox"; + public const int ReducerCount = 11; public const int ProcedureCount = 0; public const int HttpHandlerCount = 0; public const int ViewCount = 2; @@ -1251,6 +1369,22 @@ public Tables(global::SpacetimeDB.Internal.Local? db) "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1358,6 +1492,22 @@ public ReadOnlyTables(global::SpacetimeDB.Internal.LocalReadOnly? db) "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + __owner, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1471,6 +1621,22 @@ public static class LocalTableExtensions "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1574,6 +1740,22 @@ public static class ReadOnlyTableExtensions "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -1959,6 +2141,149 @@ public static partial class QueryTableExtensions } } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() + { + var tableName = __owner.ResolveTableName( + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ); + return new( + tableName, + new LocalPingGeneratedCols(tableName), + new LocalPingGeneratedIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => new AssemblyDescriptor.Queries(from).LocalPingGenerated(); + } + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public static partial class AssemblyDescriptor + { + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() + { + var tableName = __owner.ResolveTableName( + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ); + return new( + tableName, + new LocalPingOutboxCols(tableName), + new LocalPingOutboxIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => new AssemblyDescriptor.Queries(from).LocalPingOutbox(); + } + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -3211,22 +3536,22 @@ public ulong Delete(global::SpacetimeDB.Bound Faction) => internal FactionIndex Faction => new(__access); } - public readonly struct MultiTable1 - : global::SpacetimeDB.Internal.ITableView + public readonly struct LocalPingGenerated + : global::SpacetimeDB.Internal.ITableView { private readonly global::SpacetimeDB.Internal.TableAccessor __access; - internal MultiTable1(global::SpacetimeDB.Internal.TableAccessor access) => + internal LocalPingGenerated(global::SpacetimeDB.Internal.TableAccessor access) => __access = access; - public static global::MultiTableRow ReadGenFields( + public static global::LocalPingGeneratedRow ReadGenFields( System.IO.BinaryReader reader, - global::MultiTableRow row + global::LocalPingGeneratedRow row ) { - if (row.Foo == default) + if (row.MsgId == default) { - row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + row.MsgId = global::LocalPingGeneratedRow.BSATN.MsgIdRW.Read(reader); } return row; } @@ -3235,48 +3560,40 @@ public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( - SourceName: nameof(MultiTable1), + SourceName: nameof(LocalPingGenerated), ProductTypeRef: (uint) - new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, - PrimaryKey: [1], + new global::LocalPingGeneratedRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], Indexes: [ new( - SourceName: "MultiTable1_Foo_idx_btree", - AccessorName: "Foo", - Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) - ), - new( - SourceName: "MultiTable1_Name_idx_btree", - AccessorName: "Name", + SourceName: "LocalPingGenerated_MsgId_idx_btree", + AccessorName: "MsgId", Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) ), ], Constraints: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeUniqueConstraint(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeUniqueConstraint(0), ], Sequences: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeSequence(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeSequence(0), ], TableType: SpacetimeDB.Internal.TableType.User, - TableAccess: SpacetimeDB.Internal.TableAccess.Public, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, DefaultValues: [], IsEvent: false ); public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; - public static SpacetimeDB.TableCachePolicy CachePolicy => - SpacetimeDB.TableCachePolicy.RequiredOnDisk; - /// /// Returns the number of rows in this table. /// @@ -3284,13 +3601,226 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar /// It also takes into account modifications by the current transaction. /// public ulong Count => - global::SpacetimeDB.Internal.ITableView.DoCount( - __access + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoCount(__access); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoIter(__access); + + public global::LocalPingGeneratedRow Insert(global::LocalPingGeneratedRow row) => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoInsert(__access, row); + + bool global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Delete(global::LocalPingGeneratedRow row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingGenerated." ); - public IEnumerable Iter() => - global::SpacetimeDB.Internal.ITableView.DoIter( - __access + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingGenerated can't be cleared." + ); + + private global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalPingOutbox + : global::SpacetimeDB.Internal.ITableView + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal LocalPingOutbox(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::LocalPingRow ReadGenFields( + System.IO.BinaryReader reader, + global::LocalPingRow row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::LocalPingRow.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalPingOutbox), + ProductTypeRef: (uint) + new global::LocalPingRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalPingOutbox_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView.DoCount( + __access + ); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter( + __access + ); + + public global::LocalPingRow Insert(global::LocalPingRow row) => + global::SpacetimeDB.Internal.ITableView.DoInsert( + __access, + row + ); + + bool global::SpacetimeDB.Internal.ITableView.Delete( + global::LocalPingRow row + ) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingOutbox." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingOutbox can't be cleared." + ); + + private global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly __ReadOnly => + new(__access); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct MultiTable1 + : global::SpacetimeDB.Internal.ITableView + { + private readonly global::SpacetimeDB.Internal.TableAccessor __access; + + internal MultiTable1(global::SpacetimeDB.Internal.TableAccessor access) => + __access = access; + + public static global::MultiTableRow ReadGenFields( + System.IO.BinaryReader reader, + global::MultiTableRow row + ) + { + if (row.Foo == default) + { + row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(MultiTable1), + ProductTypeRef: (uint) + new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [1], + Indexes: + [ + new( + SourceName: "MultiTable1_Foo_idx_btree", + AccessorName: "Foo", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) + ), + new( + SourceName: "MultiTable1_Name_idx_btree", + AccessorName: "Name", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeUniqueConstraint(1), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeSequence(1), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Public, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + public static SpacetimeDB.TableCachePolicy CachePolicy => + SpacetimeDB.TableCachePolicy.RequiredOnDisk; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView.DoCount( + __access + ); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter( + __access ); public global::MultiTableRow Insert(global::MultiTableRow row) => @@ -4605,6 +5135,68 @@ internal FactionIndex(global::SpacetimeDB.Internal.TableAccessor accessor) internal FactionIndex Faction => new(__access); } + public sealed class LocalPingGeneratedReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalPingGeneratedReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly, + global::LocalPingGeneratedRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalPingGenerated_MsgId_idx_btree") { } + + public global::LocalPingGeneratedRow? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(__access); + } + + public sealed class LocalPingOutboxReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + internal LocalPingOutboxReadOnly(global::SpacetimeDB.Internal.TableAccessor access) + : base(access) { } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly, + global::LocalPingRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(global::SpacetimeDB.Internal.TableAccessor accessor) + : base(accessor, "LocalPingOutbox_MsgId_idx_btree") { } + + public global::LocalPingRow? Find(ulong key) => FindSingle(key); + } + + public MsgIdIndex MsgId => new(__access); + } + public sealed class MultiTable1ReadOnly : global::SpacetimeDB.Internal.ReadOnlyTableView { @@ -4954,6 +5546,22 @@ public sealed partial class LocalReadOnly "BTreeViews" ) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingGenerated" + ) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + new( + new global::SpacetimeDB.Internal.TableAccessor( + db, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + "LocalPingOutbox" + ) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => new( new global::SpacetimeDB.Internal.TableAccessor( @@ -5126,6 +5734,41 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class OnLocalPingResult : SpacetimeDB.Internal.IReducer + { + private static readonly LocalPingRow.BSATN rowRW = new(); + private static readonly SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + > resultRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(OnLocalPingResult), + Params: + [ + new("row", rowRW.GetAlgebraicType(registrar)), + new("result", resultRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.OnLocalPingResult( + (SpacetimeDB.ReducerContext)ctx, + rowRW.Read(reader), + resultRW.Read(reader) + ); + } + } + sealed class OnPingResult : SpacetimeDB.Internal.IReducer { private static readonly PingRow.BSATN rowRW = new(); @@ -5161,6 +5804,38 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class ReceiveLocalPing : SpacetimeDB.Internal.IReducer + { + private static readonly SpacetimeDB.BSATN.String messageBodyRW = new(); + private static readonly SpacetimeDB.BSATN.U32 attemptRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(ReceiveLocalPing), + Params: + [ + new("messageBody", messageBodyRW.GetAlgebraicType(registrar)), + new("attempt", attemptRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.ReceiveLocalPing( + (SpacetimeDB.ReducerContext)ctx, + messageBodyRW.Read(reader), + attemptRW.Read(reader) + ); + } + } + sealed class ScheduleImmediate : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN dataRW = new(); @@ -5184,6 +5859,27 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class SendLocalPing : SpacetimeDB.Internal.IReducer + { + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(SendLocalPing), + Params: [], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.SendLocalPing((SpacetimeDB.ReducerContext)ctx); + } + } + sealed class SendOutboxes : SpacetimeDB.Internal.IReducer { public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( @@ -5308,6 +6004,7 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder false ) ); + builder.RegisterExplicitFunctionName("ReceiveLocalPing", "AcceptLocalPing"); var __memoryStream = new MemoryStream(); var __writer = new BinaryWriter(__memoryStream); @@ -5315,8 +6012,11 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); @@ -5343,6 +6043,14 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder global::BTreeViews, global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.BTreeViews >(); + builder.RegisterTable< + global::LocalPingGeneratedRow, + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated + >(); + builder.RegisterTable< + global::LocalPingRow, + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox + >(); builder.RegisterTable< global::MultiTableRow, global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 @@ -5401,6 +6109,24 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder ) ) ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingGenerated", + "ReceiveLocalPing", + 1, + [2, 3], + null + ) + ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingOutbox", + "ReceiveLocalPing", + 1, + [3, 2], + "OnLocalPingResult" + ) + ); builder.RegisterOutbox( new global::SpacetimeDB.Internal.RawOutboxDefV10( "PingOutbox", @@ -5616,7 +6342,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_4( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - OnPingResult.Invoke(reader, ctx); + OnLocalPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5656,7 +6382,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_5( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - ScheduleImmediate.Invoke(reader, ctx); + OnPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5696,7 +6422,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_6( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - SendOutboxes.Invoke(reader, ctx); + ReceiveLocalPing.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -5718,6 +6444,126 @@ private static SpacetimeDB.Internal.Errno __call_reducer_7( SpacetimeDB.Internal.BytesSink error, int instanceId = 0 ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + ScheduleImmediate.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_8( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendLocalPing.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_9( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendOutboxes.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_10( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) { try { @@ -6018,6 +6864,42 @@ internal static SpacetimeDB.Internal.Errno CallLocalReducer( error, instanceId ), + 8 => __call_reducer_8( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), + 9 => __call_reducer_9( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), + 10 => __call_reducer_10( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), _ => SpacetimeDB.Internal.Module.WriteReducerError( error, new System.ArgumentOutOfRangeException(nameof(id), id, "Unknown reducer id") diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.OnLocalPingResult.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.OnLocalPingResult.verified.cs new file mode 100644 index 00000000000..c24f0550650 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.OnLocalPingResult.verified.cs @@ -0,0 +1,26 @@ +//HintName: LocalOutboxReducers.OnLocalPingResult.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateOnLocalPingResult( + LocalPingRow row, + SpacetimeDB.Result result + ) => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateOnLocalPingResult<__Context>( + __Context __context, + LocalPingRow row, + SpacetimeDB.Result result + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.ReceiveLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.ReceiveLocalPing.verified.cs new file mode 100644 index 00000000000..91db95c371a --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.ReceiveLocalPing.verified.cs @@ -0,0 +1,26 @@ +//HintName: LocalOutboxReducers.ReceiveLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceiveLocalPing( + string messageBody, + uint attempt + ) => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceiveLocalPing<__Context>( + __Context __context, + string messageBody, + uint attempt + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.SendLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.SendLocalPing.verified.cs new file mode 100644 index 00000000000..9bca9ce5184 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalOutboxReducers.SendLocalPing.verified.cs @@ -0,0 +1,21 @@ +//HintName: LocalOutboxReducers.SendLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateSendLocalPing() => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateSendLocalPing<__Context>( + __Context __context + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext => + throw new System.NotSupportedException( + "VolatileNonatomicScheduleImmediate is unavailable in managed module tests. Call the function directly." + ); +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingGeneratedRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingGeneratedRow.verified.cs new file mode 100644 index 00000000000..7bc713e21c0 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingGeneratedRow.verified.cs @@ -0,0 +1,127 @@ +//HintName: LocalPingGeneratedRow.cs +// +#nullable enable + +partial struct LocalPingGeneratedRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ + public ulong MsgId; + public SpacetimeDB.Identity Target; + public string MessageBody; + public uint Attempt; + +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + MessageBody = BSATN.MessageBodyRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.MessageBodyRW.Write(writer, MessageBody); + BSATN.AttemptRW.Write(writer, Attempt); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingGeneratedRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, MessageBody = {SpacetimeDB.BSATN.StringUtil.GenericToString(MessageBody)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.String MessageBodyRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + + public LocalPingGeneratedRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingGeneratedRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingGeneratedRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("MessageBody", MessageBodyRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashMessageBody = MessageBody == null ? 0 : MessageBody.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashMessageBody ^ ___hashAttempt; + } + +#nullable enable + public bool Equals(LocalPingGeneratedRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqMessageBody = + this.MessageBody == null + ? that.MessageBody == null + : this.MessageBody.Equals(that.MessageBody); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + return ___eqMsgId && ___eqTarget && ___eqMessageBody && ___eqAttempt; + } + + public override bool Equals(object? that) + { + return that is LocalPingGeneratedRow t && Equals(t); + } + + public static bool operator ==(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingGeneratedRow diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingRow.verified.cs new file mode 100644 index 00000000000..d1fb61f01f1 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#LocalPingRow.verified.cs @@ -0,0 +1,117 @@ +//HintName: LocalPingRow.cs +// +#nullable enable + +partial struct LocalPingRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + Body = BSATN.BodyRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.AttemptRW.Write(writer, Attempt); + BSATN.BodyRW.Write(writer, Body); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)}, Body = {SpacetimeDB.BSATN.StringUtil.GenericToString(Body)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + internal static readonly SpacetimeDB.BSATN.String BodyRW = new(); + + public LocalPingRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType(_ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + new("Body", BodyRW.GetAlgebraicType(registrar)), + } + )); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + var ___hashBody = Body == null ? 0 : Body.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashAttempt ^ ___hashBody; + } + +#nullable enable + public bool Equals(LocalPingRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + var ___eqBody = this.Body == null ? that.Body == null : this.Body.Equals(that.Body); + return ___eqMsgId && ___eqTarget && ___eqAttempt && ___eqBody; + } + + public override bool Equals(object? that) + { + return that is LocalPingRow t && Equals(t); + } + + public static bool operator ==(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingRow diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#FFI.verified.cs index 436621d4349..7f8e992897a 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#FFI.verified.cs @@ -248,6 +248,107 @@ public readonly partial struct QueryBuilder new("BTreeViews", new BTreeViewsCols("BTreeViews"), new BTreeViewsIxCols("BTreeViews")); } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => + new( + "LocalPingGenerated", + new LocalPingGeneratedCols("LocalPingGenerated"), + new LocalPingGeneratedIxCols("LocalPingGenerated") + ); + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(string tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(string tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public readonly partial struct QueryBuilder + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => + new( + "LocalPingOutbox", + new LocalPingOutboxCols("LocalPingOutbox"), + new LocalPingOutboxIxCols("LocalPingOutbox") + ); + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -951,6 +1052,14 @@ public sealed class Local : global::SpacetimeDB.LocalBase global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.BTreeViews.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) @@ -1020,8 +1129,9 @@ public static partial class AssemblyDescriptor public const string? CaseConversionPolicy = null; public const string RootOnlyDeclarations = "row-level security filters, environment variables, lifecycle reducer Timers.Init (Init)"; - public const string OutboxTables = "AdmitGenerated, AdmitOutbox, PingOutbox"; - public const int ReducerCount = 8; + public const string OutboxTables = + "AdmitGenerated, AdmitOutbox, LocalPingGenerated, LocalPingOutbox, PingOutbox"; + public const int ReducerCount = 11; public const int ProcedureCount = 0; public const int HttpHandlerCount = 0; public const int ViewCount = 2; @@ -1187,6 +1297,14 @@ public Tables(global::SpacetimeDB.Internal.Local? db) global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.BTreeViews.__GetInstance( __instanceId ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated.__GetInstance( + __instanceId + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox.__GetInstance( + __instanceId + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1.__GetInstance( __instanceId @@ -1246,6 +1364,14 @@ public ReadOnlyTables(global::SpacetimeDB.Internal.LocalReadOnly? db) global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.BTreeViewsReadOnly.__GetInstance( __instanceId ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly.__GetInstance( + __instanceId + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly.__GetInstance( + __instanceId + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly.__GetInstance( __instanceId @@ -1311,6 +1437,14 @@ public static class LocalTableExtensions global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.BTreeViews.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) @@ -1366,6 +1500,14 @@ public static class ReadOnlyTableExtensions global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.BTreeViewsReadOnly.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) @@ -1795,6 +1937,192 @@ public static partial class QueryTableExtensions } } + public readonly struct LocalPingGeneratedCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + > Target; + public readonly global::SpacetimeDB.Col MessageBody; + public readonly global::SpacetimeDB.Col Attempt; + + internal LocalPingGeneratedCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col( + tableName, + "MsgId" + ); + Target = new global::SpacetimeDB.Col< + global::LocalPingGeneratedRow, + SpacetimeDB.Identity + >(tableName, "Target"); + MessageBody = new global::SpacetimeDB.Col( + tableName, + "MessageBody" + ); + Attempt = new global::SpacetimeDB.Col( + tableName, + "Attempt" + ); + } + } + + public readonly struct LocalPingGeneratedIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingGeneratedIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol( + tableName, + "MsgId" + ); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] LocalPingGeneratedSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName LocalPingGeneratedSqlName( + int contextInstance + ) + { + var names = LocalPingGeneratedSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName( + instanceId, + "LocalPingGenerated" + ); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() + { + var tableName = LocalPingGeneratedSqlName(__instanceId); + return new( + tableName, + new LocalPingGeneratedCols(tableName), + new LocalPingGeneratedIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingGeneratedRow, + LocalPingGeneratedCols, + LocalPingGeneratedIxCols + > LocalPingGenerated() => new AssemblyDescriptor.Queries(from).LocalPingGenerated(); + } + } + + public readonly struct LocalPingOutboxCols + { + public readonly global::SpacetimeDB.Col MsgId; + public readonly global::SpacetimeDB.Col Target; + public readonly global::SpacetimeDB.Col Attempt; + public readonly global::SpacetimeDB.Col Body; + + internal LocalPingOutboxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.Col(tableName, "MsgId"); + Target = new global::SpacetimeDB.Col( + tableName, + "Target" + ); + Attempt = new global::SpacetimeDB.Col(tableName, "Attempt"); + Body = new global::SpacetimeDB.Col(tableName, "Body"); + } + } + + public readonly struct LocalPingOutboxIxCols + { + public readonly global::SpacetimeDB.IxCol MsgId; + + internal LocalPingOutboxIxCols(global::SpacetimeDB.SqlTableName tableName) + { + MsgId = new global::SpacetimeDB.IxCol(tableName, "MsgId"); + } + } + + public static partial class AssemblyDescriptor + { + private static global::SpacetimeDB.SqlTableName?[] LocalPingOutboxSqlNames => + field ??= new global::SpacetimeDB.SqlTableName?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + + private static global::SpacetimeDB.SqlTableName LocalPingOutboxSqlName(int contextInstance) + { + var names = LocalPingOutboxSqlNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + var resolvedName = names[instanceId] ??= + global::SpacetimeDB.Internal.Module.ResolveSqlName(instanceId, "LocalPingOutbox"); + names[contextInstance] = resolvedName; + return resolvedName; + } + + public readonly partial struct Queries + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() + { + var tableName = LocalPingOutboxSqlName(__instanceId); + return new( + tableName, + new LocalPingOutboxCols(tableName), + new LocalPingOutboxIxCols(tableName) + ); + } + } + } + + public static partial class QueryTableExtensions + { + extension(global::SpacetimeDB.QueryBuilder from) + { + public global::SpacetimeDB.Table< + global::LocalPingRow, + LocalPingOutboxCols, + LocalPingOutboxIxCols + > LocalPingOutbox() => new AssemblyDescriptor.Queries(from).LocalPingOutbox(); + } + } + public readonly struct MultiTable1Cols { public readonly global::SpacetimeDB.Col Name; @@ -3359,17 +3687,16 @@ public ulong Delete(global::SpacetimeDB.Bound Faction) => internal FactionIndex Faction => __state.__index_Faction ??= new(__state.InstanceId); } - public readonly struct MultiTable1 - : global::SpacetimeDB.Internal.ITableView + public readonly struct LocalPingGenerated + : global::SpacetimeDB.Internal.ITableView { private sealed class __InstanceState(int instanceId) : global::SpacetimeDB.Internal.TableHandle( - global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "MultiTable1") + global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "LocalPingGenerated") ) { internal readonly int InstanceId = instanceId; - internal FooUniqueIndex? __index_Foo; - internal NameIndex? __index_Name; + internal global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly? __readOnly; } private static readonly __InstanceState?[] __instances = new __InstanceState?[ @@ -3377,12 +3704,12 @@ private sealed class __InstanceState(int instanceId) ]; private readonly __InstanceState __state; - static MultiTable1() { } + static LocalPingGenerated() { } - public MultiTable1() + public LocalPingGenerated() : this(__GetInstance(0).__state) { } - private MultiTable1(__InstanceState state) + private LocalPingGenerated(__InstanceState state) { __state = state; } @@ -3390,7 +3717,7 @@ private MultiTable1(__InstanceState state) [global::System.Runtime.CompilerServices.MethodImpl( global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining )] - public static MultiTable1 __GetInstance(int contextInstance) => + public static LocalPingGenerated __GetInstance(int contextInstance) => new(__instances[contextInstance] ??= __CreateInstance(contextInstance)); private static __InstanceState __CreateInstance(int contextInstance) @@ -3402,14 +3729,14 @@ private static __InstanceState __CreateInstance(int contextInstance) return __instances[instanceId] ??= new(instanceId); } - public static global::MultiTableRow ReadGenFields( + public static global::LocalPingGeneratedRow ReadGenFields( System.IO.BinaryReader reader, - global::MultiTableRow row + global::LocalPingGeneratedRow row ) { - if (row.Foo == default) + if (row.MsgId == default) { - row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + row.MsgId = global::LocalPingGeneratedRow.BSATN.MsgIdRW.Read(reader); } return row; } @@ -3418,48 +3745,40 @@ public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( - SourceName: nameof(MultiTable1), + SourceName: nameof(LocalPingGenerated), ProductTypeRef: (uint) - new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, - PrimaryKey: [1], + new global::LocalPingGeneratedRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], Indexes: [ new( - SourceName: "MultiTable1_Foo_idx_btree", - AccessorName: "Foo", - Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) - ), - new( - SourceName: "MultiTable1_Name_idx_btree", - AccessorName: "Name", + SourceName: "LocalPingGenerated_MsgId_idx_btree", + AccessorName: "MsgId", Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) ), ], Constraints: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeUniqueConstraint(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeUniqueConstraint(0), ], Sequences: [ global::SpacetimeDB.Internal.ITableView< - MultiTable1, - global::MultiTableRow - >.MakeSequence(1), + LocalPingGenerated, + global::LocalPingGeneratedRow + >.MakeSequence(0), ], TableType: SpacetimeDB.Internal.TableType.User, - TableAccess: SpacetimeDB.Internal.TableAccess.Public, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, DefaultValues: [], IsEvent: false ); public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; - public static SpacetimeDB.TableCachePolicy CachePolicy => - SpacetimeDB.TableCachePolicy.RequiredOnDisk; - /// /// Returns the number of rows in this table. /// @@ -3467,20 +3786,302 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar /// It also takes into account modifications by the current transaction. /// public ulong Count => - global::SpacetimeDB.Internal.ITableView.DoCount( - __state - ); + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoCount(__state); - public IEnumerable Iter() => - global::SpacetimeDB.Internal.ITableView.DoIter( - __state - ); + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoIter(__state); - public global::MultiTableRow Insert(global::MultiTableRow row) => - global::SpacetimeDB.Internal.ITableView.DoInsert( - row, - __state - ); + public global::LocalPingGeneratedRow Insert(global::LocalPingGeneratedRow row) => + global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.DoInsert(row, __state); + + bool global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Delete(global::LocalPingGeneratedRow row) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingGenerated." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingGenerated, + global::LocalPingGeneratedRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingGenerated can't be cleared." + ); + + private global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly __ReadOnly => + __state.__readOnly ??= new(__state.InstanceId); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct LocalPingOutbox + : global::SpacetimeDB.Internal.ITableView + { + private sealed class __InstanceState(int instanceId) + : global::SpacetimeDB.Internal.TableHandle( + global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "LocalPingOutbox") + ) + { + internal readonly int InstanceId = instanceId; + internal global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly? __readOnly; + } + + private static readonly __InstanceState?[] __instances = new __InstanceState?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + private readonly __InstanceState __state; + + static LocalPingOutbox() { } + + public LocalPingOutbox() + : this(__GetInstance(0).__state) { } + + private LocalPingOutbox(__InstanceState state) + { + __state = state; + } + + [global::System.Runtime.CompilerServices.MethodImpl( + global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] + public static LocalPingOutbox __GetInstance(int contextInstance) => + new(__instances[contextInstance] ??= __CreateInstance(contextInstance)); + + private static __InstanceState __CreateInstance(int contextInstance) + { + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return __instances[instanceId] ??= new(instanceId); + } + + public static global::LocalPingRow ReadGenFields( + System.IO.BinaryReader reader, + global::LocalPingRow row + ) + { + if (row.MsgId == default) + { + row.MsgId = global::LocalPingRow.BSATN.MsgIdRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(LocalPingOutbox), + ProductTypeRef: (uint) + new global::LocalPingRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [0], + Indexes: + [ + new( + SourceName: "LocalPingOutbox_MsgId_idx_btree", + AccessorName: "MsgId", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeUniqueConstraint(0), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.MakeSequence(0), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Private, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView.DoCount( + __state + ); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter( + __state + ); + + public global::LocalPingRow Insert(global::LocalPingRow row) => + global::SpacetimeDB.Internal.ITableView.DoInsert( + row, + __state + ); + + bool global::SpacetimeDB.Internal.ITableView.Delete( + global::LocalPingRow row + ) => + throw new global::System.NotSupportedException( + "Rows can't be deleted from outbox table LocalPingOutbox." + ); + + ulong global::SpacetimeDB.Internal.ITableView< + LocalPingOutbox, + global::LocalPingRow + >.Clear() => + throw new global::System.NotSupportedException( + "Outbox table LocalPingOutbox can't be cleared." + ); + + private global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly __ReadOnly => + __state.__readOnly ??= new(__state.InstanceId); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly.MsgIdIndex MsgId => + __ReadOnly.MsgId; + } + + public readonly struct MultiTable1 + : global::SpacetimeDB.Internal.ITableView + { + private sealed class __InstanceState(int instanceId) + : global::SpacetimeDB.Internal.TableHandle( + global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "MultiTable1") + ) + { + internal readonly int InstanceId = instanceId; + internal FooUniqueIndex? __index_Foo; + internal NameIndex? __index_Name; + } + + private static readonly __InstanceState?[] __instances = new __InstanceState?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + private readonly __InstanceState __state; + + static MultiTable1() { } + + public MultiTable1() + : this(__GetInstance(0).__state) { } + + private MultiTable1(__InstanceState state) + { + __state = state; + } + + [global::System.Runtime.CompilerServices.MethodImpl( + global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] + public static MultiTable1 __GetInstance(int contextInstance) => + new(__instances[contextInstance] ??= __CreateInstance(contextInstance)); + + private static __InstanceState __CreateInstance(int contextInstance) + { + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return __instances[instanceId] ??= new(instanceId); + } + + public static global::MultiTableRow ReadGenFields( + System.IO.BinaryReader reader, + global::MultiTableRow row + ) + { + if (row.Foo == default) + { + row.Foo = global::MultiTableRow.BSATN.FooRW.Read(reader); + } + return row; + } + + public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(MultiTable1), + ProductTypeRef: (uint) + new global::MultiTableRow.BSATN().GetAlgebraicType(registrar).Ref_, + PrimaryKey: [1], + Indexes: + [ + new( + SourceName: "MultiTable1_Foo_idx_btree", + AccessorName: "Foo", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([1]) + ), + new( + SourceName: "MultiTable1_Name_idx_btree", + AccessorName: "Name", + Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0]) + ), + ], + Constraints: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeUniqueConstraint(1), + ], + Sequences: + [ + global::SpacetimeDB.Internal.ITableView< + MultiTable1, + global::MultiTableRow + >.MakeSequence(1), + ], + TableType: SpacetimeDB.Internal.TableType.User, + TableAccess: SpacetimeDB.Internal.TableAccess.Public, + DefaultValues: [], + IsEvent: false + ); + + public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null; + + public static SpacetimeDB.TableCachePolicy CachePolicy => + SpacetimeDB.TableCachePolicy.RequiredOnDisk; + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => + global::SpacetimeDB.Internal.ITableView.DoCount( + __state + ); + + public IEnumerable Iter() => + global::SpacetimeDB.Internal.ITableView.DoIter( + __state + ); + + public global::MultiTableRow Insert(global::MultiTableRow row) => + global::SpacetimeDB.Internal.ITableView.DoInsert( + row, + __state + ); public bool Delete(global::MultiTableRow row) => global::SpacetimeDB.Internal.ITableView.DoDelete( @@ -5241,23 +5842,22 @@ internal FactionIndex(int instanceId) internal FactionIndex Faction => __Faction ??= new(__instanceId); } - public sealed class MultiTable1ReadOnly - : global::SpacetimeDB.Internal.ReadOnlyTableView + public sealed class LocalPingGeneratedReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView { - private static readonly MultiTable1ReadOnly?[] __instances = new MultiTable1ReadOnly?[ - global::SpacetimeDB.Internal.Module.InstanceCount - ]; + private static readonly LocalPingGeneratedReadOnly?[] __instances = + new LocalPingGeneratedReadOnly?[global::SpacetimeDB.Internal.Module.InstanceCount]; private readonly int __instanceId; - static MultiTable1ReadOnly() { } + static LocalPingGeneratedReadOnly() { } [global::System.Runtime.CompilerServices.MethodImpl( global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining )] - public static MultiTable1ReadOnly __GetInstance(int contextInstance) => + public static LocalPingGeneratedReadOnly __GetInstance(int contextInstance) => __instances[contextInstance] ??= __CreateInstance(contextInstance); - private static MultiTable1ReadOnly __CreateInstance(int contextInstance) + private static LocalPingGeneratedReadOnly __CreateInstance(int contextInstance) { var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( contextInstance, @@ -5266,8 +5866,10 @@ private static MultiTable1ReadOnly __CreateInstance(int contextInstance) return __instances[instanceId] ??= new(instanceId); } - internal MultiTable1ReadOnly(int instanceId) - : base(global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "MultiTable1")) + internal LocalPingGeneratedReadOnly(int instanceId) + : base( + global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "LocalPingGenerated") + ) { __instanceId = instanceId; } @@ -5280,10 +5882,133 @@ internal MultiTable1ReadOnly(int instanceId) /// public ulong Count => DoCount(); - public sealed class FooIndex + public sealed class MsgIdIndex : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< - global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly, - global::MultiTableRow, + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly, + global::LocalPingGeneratedRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(int instanceId) + : base( + global::SpacetimeDB.Internal.Module.ResolveName( + instanceId, + "LocalPingGenerated_MsgId_idx_btree" + ) + ) { } + + public global::LocalPingGeneratedRow? Find(ulong key) => FindSingle(key); + } + + private MsgIdIndex? __MsgId; + public MsgIdIndex MsgId => __MsgId ??= new(__instanceId); + } + + public sealed class LocalPingOutboxReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + private static readonly LocalPingOutboxReadOnly?[] __instances = + new LocalPingOutboxReadOnly?[global::SpacetimeDB.Internal.Module.InstanceCount]; + private readonly int __instanceId; + + static LocalPingOutboxReadOnly() { } + + [global::System.Runtime.CompilerServices.MethodImpl( + global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] + public static LocalPingOutboxReadOnly __GetInstance(int contextInstance) => + __instances[contextInstance] ??= __CreateInstance(contextInstance); + + private static LocalPingOutboxReadOnly __CreateInstance(int contextInstance) + { + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return __instances[instanceId] ??= new(instanceId); + } + + internal LocalPingOutboxReadOnly(int instanceId) + : base(global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "LocalPingOutbox")) + { + __instanceId = instanceId; + } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class MsgIdIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly, + global::LocalPingRow, + ulong, + SpacetimeDB.BSATN.U64 + > + { + internal MsgIdIndex(int instanceId) + : base( + global::SpacetimeDB.Internal.Module.ResolveName( + instanceId, + "LocalPingOutbox_MsgId_idx_btree" + ) + ) { } + + public global::LocalPingRow? Find(ulong key) => FindSingle(key); + } + + private MsgIdIndex? __MsgId; + public MsgIdIndex MsgId => __MsgId ??= new(__instanceId); + } + + public sealed class MultiTable1ReadOnly + : global::SpacetimeDB.Internal.ReadOnlyTableView + { + private static readonly MultiTable1ReadOnly?[] __instances = new MultiTable1ReadOnly?[ + global::SpacetimeDB.Internal.Module.InstanceCount + ]; + private readonly int __instanceId; + + static MultiTable1ReadOnly() { } + + [global::System.Runtime.CompilerServices.MethodImpl( + global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] + public static MultiTable1ReadOnly __GetInstance(int contextInstance) => + __instances[contextInstance] ??= __CreateInstance(contextInstance); + + private static MultiTable1ReadOnly __CreateInstance(int contextInstance) + { + var instanceId = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return __instances[instanceId] ??= new(instanceId); + } + + internal MultiTable1ReadOnly(int instanceId) + : base(global::SpacetimeDB.Internal.Module.ResolveName(instanceId, "MultiTable1")) + { + __instanceId = instanceId; + } + + /// + /// Returns the number of rows in this table. + /// + /// This reads datastore metadata, so it runs in constant time. + /// It also takes into account modifications by the current transaction. + /// + public ulong Count => DoCount(); + + public sealed class FooIndex + : global::SpacetimeDB.Internal.ReadOnlyUniqueIndex< + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly, + global::MultiTableRow, uint, SpacetimeDB.BSATN.U32 > @@ -5846,6 +6571,14 @@ public sealed partial class LocalReadOnly global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.BTreeViewsReadOnly.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly LocalPingGenerated => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingGeneratedReadOnly.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); + public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly LocalPingOutbox => + global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.LocalPingOutboxReadOnly.__GetInstance( + global::SpacetimeDB.Internal.Module.GetInstanceId(db) + ); public global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly MultiTable1 => global::SpacetimeDB.Generated.server_D513E4815F57969C.ViewHandles.MultiTable1ReadOnly.__GetInstance( global::SpacetimeDB.Internal.Module.GetInstanceId(db) @@ -5986,6 +6719,41 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class OnLocalPingResult : SpacetimeDB.Internal.IReducer + { + private static readonly LocalPingRow.BSATN rowRW = new(); + private static readonly SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + > resultRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(OnLocalPingResult), + Params: + [ + new("row", rowRW.GetAlgebraicType(registrar)), + new("result", resultRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.OnLocalPingResult( + (SpacetimeDB.ReducerContext)ctx, + rowRW.Read(reader), + resultRW.Read(reader) + ); + } + } + sealed class OnPingResult : SpacetimeDB.Internal.IReducer { private static readonly PingRow.BSATN rowRW = new(); @@ -6021,6 +6789,38 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class ReceiveLocalPing : SpacetimeDB.Internal.IReducer + { + private static readonly SpacetimeDB.BSATN.String messageBodyRW = new(); + private static readonly SpacetimeDB.BSATN.U32 attemptRW = new(); + + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(ReceiveLocalPing), + Params: + [ + new("messageBody", messageBodyRW.GetAlgebraicType(registrar)), + new("attempt", attemptRW.GetAlgebraicType(registrar)), + ], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.ReceiveLocalPing( + (SpacetimeDB.ReducerContext)ctx, + messageBodyRW.Read(reader), + attemptRW.Read(reader) + ); + } + } + sealed class ScheduleImmediate : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN dataRW = new(); @@ -6044,6 +6844,27 @@ public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerCont } } + sealed class SendLocalPing : SpacetimeDB.Internal.IReducer + { + public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + new( + SourceName: nameof(SendLocalPing), + Params: [], + Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable, + OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit, + ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default) + ); + + public SpacetimeDB.Internal.Lifecycle? Lifecycle => null; + + public static void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx) + { + LocalOutboxReducers.SendLocalPing((SpacetimeDB.ReducerContext)ctx); + } + } + sealed class SendOutboxes : SpacetimeDB.Internal.IReducer { public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef( @@ -6168,6 +6989,7 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder false ) ); + builder.RegisterExplicitFunctionName("ReceiveLocalPing", "AcceptLocalPing"); var __memoryStream = new MemoryStream(); var __writer = new BinaryWriter(__memoryStream); @@ -6175,8 +6997,11 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); + builder.RegisterReducer(); builder.RegisterReducer(); builder.RegisterReducer(); @@ -6203,6 +7028,14 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder global::BTreeViews, global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.BTreeViews >(); + builder.RegisterTable< + global::LocalPingGeneratedRow, + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingGenerated + >(); + builder.RegisterTable< + global::LocalPingRow, + global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.LocalPingOutbox + >(); builder.RegisterTable< global::MultiTableRow, global::SpacetimeDB.Generated.server_D513E4815F57969C.TableHandles.MultiTable1 @@ -6261,6 +7094,24 @@ internal static void Register(global::SpacetimeDB.Internal.ModuleBuilder builder ) ) ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingGenerated", + "ReceiveLocalPing", + 1, + [2, 3], + null + ) + ); + builder.RegisterLocalOutbox( + new global::SpacetimeDB.Internal.RawLocalOutboxDefV10( + "LocalPingOutbox", + "ReceiveLocalPing", + 1, + [3, 2], + "OnLocalPingResult" + ) + ); builder.RegisterOutbox( new global::SpacetimeDB.Internal.RawOutboxDefV10( "PingOutbox", @@ -6476,7 +7327,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_4( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - OnPingResult.Invoke(reader, ctx); + OnLocalPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -6516,7 +7367,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_5( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - ScheduleImmediate.Invoke(reader, ctx); + OnPingResult.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -6556,7 +7407,7 @@ private static SpacetimeDB.Internal.Errno __call_reducer_6( ref reducerArgsBuffer ); using var reader = new System.IO.BinaryReader(stream); - SendOutboxes.Invoke(reader, ctx); + ReceiveLocalPing.Invoke(reader, ctx); SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); return SpacetimeDB.Internal.Errno.OK; } @@ -6578,6 +7429,126 @@ private static SpacetimeDB.Internal.Errno __call_reducer_7( SpacetimeDB.Internal.BytesSink error, int instanceId = 0 ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + ScheduleImmediate.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_8( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendLocalPing.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_9( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) + { + try + { + var ctx = SpacetimeDB.Internal.Module.CreateReducerContext( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + instanceId + ); + using var stream = SpacetimeDB.Internal.Module.ConsumeBytes( + args, + ref reducerArgsBuffer + ); + using var reader = new System.IO.BinaryReader(stream); + SendOutboxes.Invoke(reader, ctx); + SpacetimeDB.Internal.Module.EnsureNoUnreadBytes(stream, "reducer arguments"); + return SpacetimeDB.Internal.Errno.OK; + } + catch (System.Exception e) + { + return SpacetimeDB.Internal.Module.WriteReducerError(error, e); + } + } + + private static SpacetimeDB.Internal.Errno __call_reducer_10( + ulong sender_0, + ulong sender_1, + ulong sender_2, + ulong sender_3, + ulong conn_id_0, + ulong conn_id_1, + SpacetimeDB.Timestamp timestamp, + SpacetimeDB.Internal.BytesSource args, + SpacetimeDB.Internal.BytesSink error, + int instanceId = 0 + ) { try { @@ -6878,6 +7849,42 @@ internal static SpacetimeDB.Internal.Errno CallLocalReducer( error, instanceId ), + 8 => __call_reducer_8( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), + 9 => __call_reducer_9( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), + 10 => __call_reducer_10( + sender_0, + sender_1, + sender_2, + sender_3, + conn_id_0, + conn_id_1, + timestamp, + args, + error, + instanceId + ), _ => SpacetimeDB.Internal.Module.WriteReducerError( error, new System.ArgumentOutOfRangeException(nameof(id), id, "Unknown reducer id") diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.OnLocalPingResult.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.OnLocalPingResult.verified.cs new file mode 100644 index 00000000000..9817531a937 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.OnLocalPingResult.verified.cs @@ -0,0 +1,73 @@ +//HintName: LocalOutboxReducers.OnLocalPingResult.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + private static string __ScheduleOnLocalPingResultName => + field ??= global::SpacetimeDB.Internal.Module.ResolveFunctionName( + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + nameof(OnLocalPingResult), + null + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateOnLocalPingResult( + LocalPingRow row, + SpacetimeDB.Result result + ) + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new LocalPingRow.BSATN().Write(writer, row); + new SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + >().Write(writer, result); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate( + __ScheduleOnLocalPingResultName, + stream + ); + } + + private static string?[] __ScheduleOnLocalPingResultNames => + field ??= new string?[global::SpacetimeDB.Internal.Module.InstanceCount]; + + private static string __ResolveScheduleOnLocalPingResultName(int contextInstance) + { + var names = __ScheduleOnLocalPingResultNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instance = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return names[contextInstance] = names[instance] ??= + global::SpacetimeDB.Internal.Module.ResolveFunctionName( + instance, + nameof(OnLocalPingResult), + null + ); + } + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateOnLocalPingResult<__Context>( + __Context __context, + LocalPingRow row, + SpacetimeDB.Result result + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext + { + var __name = __ResolveScheduleOnLocalPingResultName(__context.InstanceId); + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new LocalPingRow.BSATN().Write(writer, row); + new SpacetimeDB.Result.BSATN< + SpacetimeDB.Unit.BSATN, + SpacetimeDB.BSATN.String + >().Write(writer, result); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate(__name, stream); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.ReceiveLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.ReceiveLocalPing.verified.cs new file mode 100644 index 00000000000..c3ca393d1f5 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.ReceiveLocalPing.verified.cs @@ -0,0 +1,67 @@ +//HintName: LocalOutboxReducers.ReceiveLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + private static string __ScheduleReceiveLocalPingName => + field ??= global::SpacetimeDB.Internal.Module.ResolveFunctionName( + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + nameof(ReceiveLocalPing), + "AcceptLocalPing" + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceiveLocalPing( + string messageBody, + uint attempt + ) + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new SpacetimeDB.BSATN.String().Write(writer, messageBody); + new SpacetimeDB.BSATN.U32().Write(writer, attempt); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate( + __ScheduleReceiveLocalPingName, + stream + ); + } + + private static string?[] __ScheduleReceiveLocalPingNames => + field ??= new string?[global::SpacetimeDB.Internal.Module.InstanceCount]; + + private static string __ResolveScheduleReceiveLocalPingName(int contextInstance) + { + var names = __ScheduleReceiveLocalPingNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instance = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return names[contextInstance] = names[instance] ??= + global::SpacetimeDB.Internal.Module.ResolveFunctionName( + instance, + nameof(ReceiveLocalPing), + "AcceptLocalPing" + ); + } + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateReceiveLocalPing<__Context>( + __Context __context, + string messageBody, + uint attempt + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext + { + var __name = __ResolveScheduleReceiveLocalPingName(__context.InstanceId); + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + new SpacetimeDB.BSATN.String().Write(writer, messageBody); + new SpacetimeDB.BSATN.U32().Write(writer, attempt); + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate(__name, stream); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.SendLocalPing.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.SendLocalPing.verified.cs new file mode 100644 index 00000000000..d85c5d0f6d1 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalOutboxReducers.SendLocalPing.verified.cs @@ -0,0 +1,60 @@ +//HintName: LocalOutboxReducers.SendLocalPing.cs +// +#nullable enable + +partial class LocalOutboxReducers +{ + private static string __ScheduleSendLocalPingName => + field ??= global::SpacetimeDB.Internal.Module.ResolveFunctionName( + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", + nameof(SendLocalPing), + null + ); + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateSendLocalPing() + { + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate( + __ScheduleSendLocalPingName, + stream + ); + } + + private static string?[] __ScheduleSendLocalPingNames => + field ??= new string?[global::SpacetimeDB.Internal.Module.InstanceCount]; + + private static string __ResolveScheduleSendLocalPingName(int contextInstance) + { + var names = __ScheduleSendLocalPingNames; + if (names[contextInstance] is { } name) + { + return name; + } + var instance = global::SpacetimeDB.Internal.Module.ResolveInstance( + contextInstance, + "server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + ); + return names[contextInstance] = names[instance] ??= + global::SpacetimeDB.Internal.Module.ResolveFunctionName( + instance, + nameof(SendLocalPing), + null + ); + } + + [System.Diagnostics.CodeAnalysis.Experimental("STDB_UNSTABLE")] + public static void VolatileNonatomicScheduleImmediateSendLocalPing<__Context>( + __Context __context + ) + where __Context : global::SpacetimeDB.Internal.IModuleContext + { + var __name = __ResolveScheduleSendLocalPingName(__context.InstanceId); + using var stream = new MemoryStream(); + using var writer = new BinaryWriter(stream); + + SpacetimeDB.Internal.IReducer.VolatileNonatomicScheduleImmediate(__name, stream); + } +} // LocalOutboxReducers diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingGeneratedRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingGeneratedRow.verified.cs new file mode 100644 index 00000000000..7bc713e21c0 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingGeneratedRow.verified.cs @@ -0,0 +1,127 @@ +//HintName: LocalPingGeneratedRow.cs +// +#nullable enable + +partial struct LocalPingGeneratedRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ + public ulong MsgId; + public SpacetimeDB.Identity Target; + public string MessageBody; + public uint Attempt; + +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + MessageBody = BSATN.MessageBodyRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.MessageBodyRW.Write(writer, MessageBody); + BSATN.AttemptRW.Write(writer, Attempt); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingGeneratedRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, MessageBody = {SpacetimeDB.BSATN.StringUtil.GenericToString(MessageBody)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.String MessageBodyRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + + public LocalPingGeneratedRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingGeneratedRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingGeneratedRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType( + _ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("MessageBody", MessageBodyRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + } + ) + ); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashMessageBody = MessageBody == null ? 0 : MessageBody.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashMessageBody ^ ___hashAttempt; + } + +#nullable enable + public bool Equals(LocalPingGeneratedRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqMessageBody = + this.MessageBody == null + ? that.MessageBody == null + : this.MessageBody.Equals(that.MessageBody); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + return ___eqMsgId && ___eqTarget && ___eqMessageBody && ___eqAttempt; + } + + public override bool Equals(object? that) + { + return that is LocalPingGeneratedRow t && Equals(t); + } + + public static bool operator ==(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingGeneratedRow this_, LocalPingGeneratedRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingGeneratedRow diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingRow.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingRow.verified.cs new file mode 100644 index 00000000000..d1fb61f01f1 --- /dev/null +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10.wasm#LocalPingRow.verified.cs @@ -0,0 +1,117 @@ +//HintName: LocalPingRow.cs +// +#nullable enable + +partial struct LocalPingRow + : System.IEquatable, + SpacetimeDB.BSATN.IStructuralReadWrite +{ +#if NET10_0_OR_GREATER + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining + )] +#endif + public void ReadFields(System.IO.BinaryReader reader) + { + MsgId = BSATN.MsgIdRW.Read(reader); + Target = BSATN.TargetRW.Read(reader); + Attempt = BSATN.AttemptRW.Read(reader); + Body = BSATN.BodyRW.Read(reader); + } + + public void WriteFields(System.IO.BinaryWriter writer) + { + BSATN.MsgIdRW.Write(writer, MsgId); + BSATN.TargetRW.Write(writer, Target); + BSATN.AttemptRW.Write(writer, Attempt); + BSATN.BodyRW.Write(writer, Body); + } + + object SpacetimeDB.BSATN.IStructuralReadWrite.GetSerializer() + { + return new BSATN(); + } + + public override string ToString() => + $"LocalPingRow {{ MsgId = {SpacetimeDB.BSATN.StringUtil.GenericToString(MsgId)}, Target = {SpacetimeDB.BSATN.StringUtil.GenericToString(Target)}, Attempt = {SpacetimeDB.BSATN.StringUtil.GenericToString(Attempt)}, Body = {SpacetimeDB.BSATN.StringUtil.GenericToString(Body)} }}"; + + public readonly partial struct BSATN : SpacetimeDB.BSATN.IReadWrite + { + internal static readonly SpacetimeDB.BSATN.U64 MsgIdRW = new(); + internal static readonly SpacetimeDB.Identity.BSATN TargetRW = new(); + internal static readonly SpacetimeDB.BSATN.U32 AttemptRW = new(); + internal static readonly SpacetimeDB.BSATN.String BodyRW = new(); + + public LocalPingRow Read(System.IO.BinaryReader reader) + { + var ___result = new LocalPingRow(); + ___result.ReadFields(reader); + return ___result; + } + + public void Write(System.IO.BinaryWriter writer, LocalPingRow value) + { + value.WriteFields(writer); + } + + public SpacetimeDB.BSATN.AlgebraicType.Ref GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => + registrar.RegisterType(_ => new SpacetimeDB.BSATN.AlgebraicType.Product( + new SpacetimeDB.BSATN.AggregateElement[] + { + new("MsgId", MsgIdRW.GetAlgebraicType(registrar)), + new("Target", TargetRW.GetAlgebraicType(registrar)), + new("Attempt", AttemptRW.GetAlgebraicType(registrar)), + new("Body", BodyRW.GetAlgebraicType(registrar)), + } + )); + + SpacetimeDB.BSATN.AlgebraicType SpacetimeDB.BSATN.IReadWrite.GetAlgebraicType( + SpacetimeDB.BSATN.ITypeRegistrar registrar + ) => GetAlgebraicType(registrar); + } + + public override int GetHashCode() + { + var ___hashMsgId = MsgId.GetHashCode(); + var ___hashTarget = Target.GetHashCode(); + var ___hashAttempt = Attempt.GetHashCode(); + var ___hashBody = Body == null ? 0 : Body.GetHashCode(); + return ___hashMsgId ^ ___hashTarget ^ ___hashAttempt ^ ___hashBody; + } + +#nullable enable + public bool Equals(LocalPingRow that) + { + var ___eqMsgId = this.MsgId.Equals(that.MsgId); + var ___eqTarget = this.Target.Equals(that.Target); + var ___eqAttempt = this.Attempt.Equals(that.Attempt); + var ___eqBody = this.Body == null ? that.Body == null : this.Body.Equals(that.Body); + return ___eqMsgId && ___eqTarget && ___eqAttempt && ___eqBody; + } + + public override bool Equals(object? that) + { + return that is LocalPingRow t && Equals(t); + } + + public static bool operator ==(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return object.Equals(this_, that); + } + return this_.Equals(that); + } + + public static bool operator !=(LocalPingRow this_, LocalPingRow that) + { + if (((object?)this_) == null || ((object?)that) == null) + { + return !object.Equals(this_, that); + } + return !this_.Equals(that); + } +#nullable restore +} // LocalPingRow diff --git a/crates/bindings-csharp/Codegen/Module.cs b/crates/bindings-csharp/Codegen/Module.cs index 1760b0705da..9e4973971c5 100644 --- a/crates/bindings-csharp/Codegen/Module.cs +++ b/crates/bindings-csharp/Codegen/Module.cs @@ -156,30 +156,38 @@ record OnResultRef(string Row, string? Table); /// /// The resolved outbox of a table accessor: everything RawOutboxDefV10 needs except the -/// on_result reducer, which is attached at registration. +/// on_result reducer, which is attached at registration. SignatureHash is null for +/// a reducer of this module: the host computes it, and RemoteReducer is then the +/// reducer's source name, registered as a RawLocalOutboxDefV10. /// record OutboxInfo( string RemoteReducer, - string SignatureHash, + string? SignatureHash, int TargetColumn, EquatableArray ArgColumns ) { public string GenerateRegistration(string tableName, string? onResultReducer) { + var onResult = onResultReducer is null + ? "null" + : SymbolDisplay.FormatLiteral(onResultReducer, true); + if (SignatureHash is null) + { + return $"builder.RegisterLocalOutbox(new global::SpacetimeDB.Internal.RawLocalOutboxDefV10({SymbolDisplay.FormatLiteral(tableName, true)}, {SymbolDisplay.FormatLiteral(RemoteReducer, true)}, {TargetColumn}, [{string.Join(", ", ArgColumns)}], {onResult}));"; + } // The hash is a `Hash`: a U256 read from its 32 bytes (64 hex digits) in little-endian // order. Word(n) is the ulong made of bytes n..n+7, most significant byte first. string Word(int offset) => "0x" + string.Concat( - Enumerable.Range(0, 8).Select(i => SignatureHash.Substring((offset + 7 - i) * 2, 2)) + Enumerable + .Range(0, 8) + .Select(i => SignatureHash!.Substring((offset + 7 - i) * 2, 2)) ) + "UL"; var hash = $"new global::SpacetimeDB.U256(new global::SpacetimeDB.U128({Word(24)}, {Word(16)}), new global::SpacetimeDB.U128({Word(8)}, {Word(0)}))"; - var onResult = onResultReducer is null - ? "null" - : SymbolDisplay.FormatLiteral(onResultReducer, true); return $"builder.RegisterOutbox(new global::SpacetimeDB.Internal.RawOutboxDefV10({SymbolDisplay.FormatLiteral(tableName, true)}, {SymbolDisplay.FormatLiteral(RemoteReducer, true)}, {TargetColumn}, [{string.Join(", ", ArgColumns)}], {onResult}, {hash}));"; } } @@ -400,7 +408,14 @@ public TableAccessor(TableDeclaration table, AttributeData data, DiagReporter di // Without generated columns, it already has an error, and no columns to check. if (table.HasGeneratedColumns && data.GetTypeArgument("reducer") is { } outboxReducer) { - Outbox = ResolveOutbox(table, outboxReducer, scheduled: false, data, diag); + Outbox = ResolveOutbox( + table, + outboxReducer, + outbox.ReducerName, + scheduled: false, + data, + diag + ); } return; } @@ -447,7 +462,25 @@ attr.Scheduled is { } reducer if (data.GetTypeArgument(nameof(TableAttribute.Outbox)) is { } receiver) { IsOutbox = true; - Outbox = ResolveOutbox(table, receiver, attr.Scheduled is not null, data, diag); + Outbox = ResolveOutbox( + table, + receiver, + attr.OutboxReducer, + attr.Scheduled is not null, + data, + diag + ); + } + else if (attr.OutboxReducer is not null) + { + IsOutbox = true; + diag.Report( + ErrorDescriptor.InvalidOutboxDeclaration, + ( + data, + $"{Name} sets OutboxReducer without Outbox. Set Outbox to the class declaring {attr.OutboxReducer}." + ) + ); } } @@ -455,49 +488,155 @@ attr.Scheduled is { } reducer public static bool IsReceiver(INamedTypeSymbol type) => type.AllInterfaces.Any(i => i.ToString() == "SpacetimeDB.Internal.IOutboxReceiver"); - /// A receiver marker class's fields: one per reducer parameter, in order. - public static IEnumerable ReceiverParameters(INamedTypeSymbol receiver) => - receiver - .GetMembers() - .OfType() - .Where(f => !f.IsConst && !f.IsStatic && !f.IsImplicitlyDeclared); + /// + /// A receiver reducer's parameter. A remote one has its canonical name from the bindings. + /// A local one has its C# name, and also answers to that name in snake case, like a column. + /// + public sealed record ReceiverParameter( + string Name, + ITypeSymbol Type, + ISymbol Symbol, + bool IsLocal + ) + { + public bool Matches(string columnName) => + columnName == Name || (IsLocal && columnName == SnakeCase(Name)); + } /// - /// Validates an outbox table against its receiver reducer's marker class from receiver - /// bindings, and matches the reducer's parameters to columns. Reports every problem. + /// The reducer an outbox calls: a marker class from receiver bindings, or a reducer of this + /// module named by OutboxReducer. is null for a local + /// reducer; the host computes it, and is then the source name. /// - private OutboxInfo? ResolveOutbox( - TableDeclaration table, - INamedTypeSymbol receiver, - bool scheduled, - AttributeData data, - DiagReporter diag + public sealed record Receiver( + string ReducerName, + string? SignatureHash, + string IdentityName, + INamedTypeSymbol? Identity, + ImmutableArray Parameters + ); + + /// + /// Resolves an outbox's receiver, or reports why it can't through . + /// + public static Receiver? ResolveReceiver( + string table, + INamedTypeSymbol type, + string? localReducer, + Action error ) { - var errors = 0; - void Error(string message) + if (localReducer is not null) { - errors++; - diag.Report(ErrorDescriptor.InvalidOutboxDeclaration, (data, message)); + if (IsReceiver(type)) + { + error( + $"{table}: Outbox type {type} is a reducer from receiver bindings, so it can't take OutboxReducer. Remove OutboxReducer, or set Outbox to the class declaring {localReducer}." + ); + return null; + } + var reducers = type.GetMembers(localReducer) + .OfType() + .Where(m => + m.GetAttributes() + .Any(a => a.AttributeClass?.ToString() == typeof(ReducerAttribute).FullName) + ) + .ToArray(); + if (reducers.Length != 1) + { + error( + $"{table}: {type} has no [Reducer] method named {localReducer}. Set Outbox to the class declaring the reducer, and OutboxReducer to nameof(that reducer)." + ); + return null; + } + var method = reducers[0]; + var kind = method + .GetAttributes() + .First(a => a.AttributeClass?.ToString() == typeof(ReducerAttribute).FullName) + .ParseAs() + .Kind; + if (kind != ReducerKind.UserDefined) + { + error( + $"{table}: {localReducer} is a lifecycle reducer, so an outbox can't call it." + ); + return null; + } + // The reducer reports its own error if it doesn't take a ReducerContext first. + // ReducerContext is generated, so it can be an error type here; match its name. + if (method.Parameters.FirstOrDefault()?.Type.Name != "ReducerContext") + { + return null; + } + return new( + // The host matches the source name: the method name, even with [Reducer(Name)]. + method.Name, + null, + "SpacetimeDB.Identity", + // Callers that need the symbol look it up in their compilation. + null, + method + .Parameters.Skip(1) + .Select(p => new ReceiverParameter(p.Name, p.Type, p, IsLocal: true)) + .ToImmutableArray() + ); } string? Constant(string name) => - receiver.GetMembers(name).OfType().FirstOrDefault() + type.GetMembers(name).OfType().FirstOrDefault() is { IsConst: true, ConstantValue: string value } ? value : null; if ( - !IsReceiver(receiver) + !IsReceiver(type) || Constant("ReducerName") is not { } reducerName || Constant("SignatureHash") is not { Length: 64 } signatureHash || !signatureHash.All(c => c is >= '0' and <= '9' or >= 'a' and <= 'f') ) { - Error( - $"{Name}: Outbox type {receiver} is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes." + error( + $"{table}: Outbox type {type} is not a reducer from receiver bindings. Generate them with `spacetime generate --bindings module` and use one of their `Reducers` classes, or set OutboxReducer to call a reducer of this module." ); return null; } + return new( + reducerName, + signatureHash, + $"{SymbolToName(type.ContainingNamespace)}.Identity", + type.ContainingNamespace.GetTypeMembers("Identity").FirstOrDefault(), + type.GetMembers() + .OfType() + .Where(f => !f.IsConst && !f.IsStatic && !f.IsImplicitlyDeclared) + .Select(f => new ReceiverParameter(f.Name, f.Type, f, IsLocal: false)) + .ToImmutableArray() + ); + } + + /// + /// Validates an outbox table against its receiver reducer, and matches the reducer's + /// parameters to columns. Reports every problem. + /// + private OutboxInfo? ResolveOutbox( + TableDeclaration table, + INamedTypeSymbol receiverType, + string? localReducer, + bool scheduled, + AttributeData data, + DiagReporter diag + ) + { + var errors = 0; + void Error(string message) + { + errors++; + diag.Report(ErrorDescriptor.InvalidOutboxDeclaration, (data, message)); + } + + if (ResolveReceiver(Name, receiverType, localReducer, Error) is not { } receiver) + { + return null; + } + var reducerName = receiver.ReducerName; if (IsEvent) { @@ -518,7 +657,7 @@ primaryKey is not { } pk Error($"{Name} is an outbox table, so it needs a [PrimaryKey, AutoInc] ulong column."); } - var identity = $"{SymbolToName(receiver.ContainingNamespace)}.Identity"; + var identity = receiver.IdentityName; var targets = table .Members.Where(m => m.OutboxAttrs.Any(a => a.Param is null && a.AppliesTo(Name))) .ToArray(); @@ -535,7 +674,7 @@ primaryKey is not { } pk ); } - var parameters = ReceiverParameters(receiver).ToArray(); + var parameters = receiver.Parameters; // The name each column answers to: its [Param] for this table, else its snake_case name. var columnNames = new string[table.Members.Length]; for (var i = 0; i < columnNames.Length; i++) @@ -553,7 +692,7 @@ primaryKey is not { } pk ); } var explicitName = explicitNames.FirstOrDefault(); - if (explicitName is not null && parameters.All(p => p.Name != explicitName)) + if (explicitName is not null && !parameters.Any(p => p.Matches(explicitName))) { Error( $"{Name}.{member.Name} is marked [Param(\"{explicitName}\")], but {reducerName} has no parameter named `{explicitName}`." @@ -567,7 +706,7 @@ primaryKey is not { } pk { var matches = Enumerable .Range(0, columnNames.Length) - .Where(i => columnNames[i] == parameter.Name) + .Where(i => parameter.Matches(columnNames[i])) .ToArray(); var parameterType = SymbolToName(parameter.Type); if (matches.Length == 0) @@ -595,7 +734,12 @@ primaryKey is not { } pk } return errors == 0 - ? new(reducerName, signatureHash, targets[0].ColumnIndex, new(argColumns.ToImmutable())) + ? new( + reducerName, + receiver.SignatureHash, + targets[0].ColumnIndex, + new(argColumns.ToImmutable()) + ) : null; } } @@ -984,7 +1128,7 @@ public TableDeclaration(GeneratorAttributeSyntaxContext context, DiagReporter di /// private ImmutableArray? GenerateOutboxColumns( INamedTypeSymbol row, - INamedTypeSymbol receiver, + INamedTypeSymbol receiverType, AttributeData outbox, Compilation compilation, DiagReporter diag @@ -992,8 +1136,14 @@ DiagReporter diag { // An invalid receiver gets no columns; the outbox validation reports it. if ( - !TableAccessor.IsReceiver(receiver) - || receiver.ContainingNamespace.GetTypeMembers("Identity").FirstOrDefault() + TableAccessor.ResolveReceiver( + row.Name, + receiverType, + outbox.ParseAs().ReducerName, + _ => { } + ) + is not { } receiver + || (receiver.Identity ?? compilation.GetTypeByMetadataName(receiver.IdentityName)) is not { } identity ) { @@ -1022,7 +1172,7 @@ bool TryAdd( } var forParameter = parameter is null ? "" - : $" for parameter `{parameter}` of {receiver.Name}"; + : $" for parameter `{parameter}` of {receiver.ReducerName}"; diag.Report( ErrorDescriptor.InvalidOutboxDeclaration, ( @@ -1046,7 +1196,7 @@ bool TryAdd( { return null; } - foreach (var parameter in TableAccessor.ReceiverParameters(receiver)) + foreach (var parameter in receiver.Parameters) { var name = string.Concat( parameter @@ -1060,7 +1210,7 @@ bool TryAdd( parameter.Type, ColumnAttrs.UnSet, new(null, parameter.Name), - parameter, + parameter.Symbol, parameter.Name ) ) diff --git a/crates/bindings-csharp/Runtime/Attrs.cs b/crates/bindings-csharp/Runtime/Attrs.cs index 48668223bf9..fd5882cbea7 100644 --- a/crates/bindings-csharp/Runtime/Attrs.cs +++ b/crates/bindings-csharp/Runtime/Attrs.cs @@ -102,9 +102,17 @@ public sealed class TableAttribute : Attribute /// /// Makes this an outbox table: each row is a call to this reducer in another database. - /// Set it to a reducer from the receiver bindings. + /// Set it to a reducer from the receiver bindings, or, with , + /// to the class declaring a reducer of this module. /// public System.Type? Outbox { get; init; } + + /// + /// The name of a reducer of this module declared in , such as + /// nameof(Module.ReceivePing). Each row calls it in the target database, which + /// runs this module too. It needs no receiver bindings. + /// + public string? OutboxReducer { get; init; } } /// @@ -112,12 +120,18 @@ public sealed class TableAttribute : Attribute /// partial struct: it gets a MsgId message ID column, a Target column, /// and a column for each of the reducer's parameters, named in Pascal case. /// - /// A reducer from the receiver bindings, such as typeof(Gw.Reducers.AdmitPlayer). + /// + /// A reducer from the receiver bindings, such as typeof(Gw.Reducers.AdmitPlayer), + /// or, with , the class declaring a reducer of this module. + /// [AttributeUsage(AttributeTargets.Struct, Inherited = false)] public sealed class OutboxAttribute(System.Type reducer) : Attribute { public System.Type Reducer => reducer; + /// + public string? ReducerName { get; init; } + /// public string? Accessor { get; init; } diff --git a/crates/bindings-csharp/Runtime/Internal/ModuleBuilder.cs b/crates/bindings-csharp/Runtime/Internal/ModuleBuilder.cs index 7c5b0ee6df6..3fd062f94e0 100644 --- a/crates/bindings-csharp/Runtime/Internal/ModuleBuilder.cs +++ b/crates/bindings-csharp/Runtime/Internal/ModuleBuilder.cs @@ -52,6 +52,7 @@ private static class AnonymousViewDispatcherCache private readonly List tableCachePolicyDefs = []; private readonly List scheduleDefs = []; private readonly List outboxDefs = []; + private readonly List localOutboxDefs = []; private readonly List reducerDefs = []; private readonly List lifecycleReducerDefs = []; private readonly List procedureDefs = []; @@ -209,6 +210,12 @@ internal void RegisterTable( public void RegisterOutbox(RawOutboxDefV10 outbox) => outboxDefs.Add(outbox); + /// + /// Registers an outbox calling a reducer of this module. The host resolves the reducer's + /// name and computes its signature hash, so the module doesn't. + /// + public void RegisterLocalOutbox(RawLocalOutboxDefV10 outbox) => localOutboxDefs.Add(outbox); + public void RegisterView() where TDispatcher : IView, new() { @@ -309,6 +316,7 @@ public RawModuleDefV10 BuildModuleDefinition() .Select(l => l.FunctionName) .Concat(scheduleDefs.Select(s => s.FunctionName)) .Concat(outboxDefs.Select(o => o.OnResultReducer).OfType()) + .Concat(localOutboxDefs.Select(o => o.OnResultReducer).OfType()) .ToHashSet(StringComparer.Ordinal); foreach (var reducer in reducerDefs) @@ -385,6 +393,10 @@ public RawModuleDefV10 BuildModuleDefinition() { sections.Add(new RawModuleDefV10Section.Outboxes(outboxDefs)); } + if (localOutboxDefs.Count > 0) + { + sections.Add(new RawModuleDefV10Section.LocalOutboxes(localOutboxDefs)); + } // TODO: Add sections for Event tables and Case conversion policy (mirrors Rust `raw_def/v10.rs` TODO). if (caseConversionPolicy is { } policy) { From 8749b004a5c6a50b0331d9c9ce53c1551c201f6d Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Sat, 28 Nov 2026 12:54:00 +0530 Subject: [PATCH 11/11] Smoketests: local outboxes in TypeScript and C# modules Run the self-outbox scenario, which sends a nested message from a module to its own reducer without receiver bindings, against TypeScript and C# ports of the Rust fixture. Fixture setup for Rust, TypeScript and C# moves out of `IdcTest` so this test can share it. --- .../modules/idc-self-outbox-cs/Lib.cs | 87 +++++++++++++++ .../modules/idc-self-outbox-ts/.npmrc | 1 + .../modules/idc-self-outbox-ts/package.json | 11 ++ .../modules/idc-self-outbox-ts/src/index.ts | 70 ++++++++++++ .../modules/idc-self-outbox-ts/tsconfig.json | 13 +++ crates/smoketests/tests/cluster/idc.rs | 102 ++++++++++++------ 6 files changed, 249 insertions(+), 35 deletions(-) create mode 100644 crates/smoketests/modules/idc-self-outbox-cs/Lib.cs create mode 100644 crates/smoketests/modules/idc-self-outbox-ts/.npmrc create mode 100644 crates/smoketests/modules/idc-self-outbox-ts/package.json create mode 100644 crates/smoketests/modules/idc-self-outbox-ts/src/index.ts create mode 100644 crates/smoketests/modules/idc-self-outbox-ts/tsconfig.json diff --git a/crates/smoketests/modules/idc-self-outbox-cs/Lib.cs b/crates/smoketests/modules/idc-self-outbox-cs/Lib.cs new file mode 100644 index 00000000000..98881b11ced --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox-cs/Lib.cs @@ -0,0 +1,87 @@ +// C# port of idc-self-outbox: an outbox to a reducer in this module, +// declared without receiver bindings. +using SpacetimeDB; + +[Type] +public partial struct State +{ + public ulong revision; + public string? displayName; +} + +[Type] +public partial record Operation : TaggedEnum<(State SetState, Unit ClearState)>; + +[Type] +public partial struct Message +{ + public ulong ItemID; + public List operations; +} + +[Table(Accessor = "delivered_ping")] +public partial struct DeliveredPing +{ + [PrimaryKey, AutoInc] + public ulong id; + public Message body; +} + +[Table(Accessor = "outbound_ping", Outbox = typeof(Module), OutboxReducer = nameof(Module.receivePing))] +public partial struct OutboundPing +{ + [PrimaryKey, AutoInc] + public ulong id; + + [Target] + public Identity target; + + [Param("messageBody")] + public Message payload; +} + +[Table(Accessor = "ping_results")] +public partial struct PingResult +{ + [PrimaryKey] + public ulong id; + public Message body; + public string? error; +} + +public static partial class Module +{ + [SpacetimeDB.Settings] + public const CaseConversionPolicy CASE_CONVERSION_POLICY = CaseConversionPolicy.None; + + [Reducer] + public static void receivePing(ReducerContext ctx, Message messageBody) => + ctx.Db.delivered_ping.Insert(new DeliveredPing { id = 0, body = messageBody }); + + [Reducer(Name = "WirePingResult")] + [OnResult(typeof(OutboundPing))] + public static void onPingResult( + ReducerContext ctx, + OutboundPing row, + Result result + ) => + ctx.Db.ping_results.Insert( + new PingResult + { + id = row.id, + body = row.payload, + error = result is Result.ErrR(var error) ? error : null, + } + ); + + [Reducer] + public static void enqueuePing(ReducerContext ctx, Identity target, Message messageBody) => + ctx.Db.outbound_ping.Insert( + new OutboundPing + { + id = 0, + target = target, + payload = messageBody, + } + ); +} diff --git a/crates/smoketests/modules/idc-self-outbox-ts/.npmrc b/crates/smoketests/modules/idc-self-outbox-ts/.npmrc new file mode 100644 index 00000000000..44bdf80d1df --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox-ts/.npmrc @@ -0,0 +1 @@ +minimum-release-age=1440 diff --git a/crates/smoketests/modules/idc-self-outbox-ts/package.json b/crates/smoketests/modules/idc-self-outbox-ts/package.json new file mode 100644 index 00000000000..3aa58df3d94 --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox-ts/package.json @@ -0,0 +1,11 @@ +{ + "name": "idc-self-outbox-ts", + "private": true, + "type": "module", + "dependencies": { + "spacetimedb": "file:../../../bindings-typescript" + }, + "devDependencies": { + "typescript": "^5.9.3" + } +} diff --git a/crates/smoketests/modules/idc-self-outbox-ts/src/index.ts b/crates/smoketests/modules/idc-self-outbox-ts/src/index.ts new file mode 100644 index 00000000000..c50f7175624 --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox-ts/src/index.ts @@ -0,0 +1,70 @@ +// TypeScript port of idc-self-outbox: an outbox to a reducer in this module, +// declared without receiver bindings. +import { schema, table, t } from 'spacetimedb/server'; + +const State = t.object('State', { + revision: t.u64(), + displayName: t.option(t.string()), +}); +const Operation = t.enum('Operation', { + SetState: State, + ClearState: t.unit(), +}); +const Message = t.object('Message', { + ItemID: t.u64(), + operations: t.array(Operation), +}); + +const deliveredPing = table( + { name: 'delivered_ping' }, + { id: t.u64().primaryKey().autoInc(), body: Message } +); +const outboundPing = table( + { name: 'outbound_ping', outbox: 'local' }, + { + id: t.u64().primaryKey().autoInc(), + target: t.identity().target(), + payload: Message.param({ name: 'messageBody' }), + } +); +const pingResults = table( + { name: 'ping_results' }, + { + id: t.u64().primaryKey(), + body: Message, + error: t.option(t.string()), + } +); + +const spacetimedb = schema( + { deliveredPing, outboundPing, pingResults }, + { CASE_CONVERSION_POLICY: { tag: 'None' } } +); +export default spacetimedb; + +export const receivePing = spacetimedb.reducer( + { receiverFor: outboundPing }, + { messageBody: Message }, + (ctx, { messageBody }) => { + ctx.db.deliveredPing.insert({ id: 0n, body: messageBody }); + } +); + +export const onPingResult = spacetimedb.reducer( + { name: 'WirePingResult', onResult: outboundPing }, + { row: outboundPing.rowType, result: t.result(t.unit(), t.string()) }, + (ctx, { row, result }) => { + ctx.db.pingResults.insert({ + id: row.id, + body: row.payload, + error: 'err' in result ? result.err : undefined, + }); + } +); + +export const enqueuePing = spacetimedb.reducer( + { target: t.identity(), messageBody: Message }, + (ctx, { target, messageBody }) => { + ctx.db.outboundPing.insert({ id: 0n, target, payload: messageBody }); + } +); diff --git a/crates/smoketests/modules/idc-self-outbox-ts/tsconfig.json b/crates/smoketests/modules/idc-self-outbox-ts/tsconfig.json new file mode 100644 index 00000000000..ff6a594528c --- /dev/null +++ b/crates/smoketests/modules/idc-self-outbox-ts/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler", + "target": "ESNext", + "lib": ["ES2021", "dom"], + "module": "ESNext", + "isolatedModules": true, + "noEmit": true + }, + "include": ["src/**/*.ts"] +} diff --git a/crates/smoketests/tests/cluster/idc.rs b/crates/smoketests/tests/cluster/idc.rs index 63385f734d8..0e3956ac8d2 100644 --- a/crates/smoketests/tests/cluster/idc.rs +++ b/crates/smoketests/tests/cluster/idc.rs @@ -435,13 +435,74 @@ fn idc_outbox_uses_regenerated_bindings_after_argument_reordering() { suite.send_detailed_ping("after-update"); } +/// The module path of a fixture prepared by [`prepare_fixture`] under `name`. +/// `spacetime init` puts a C# module in a `spacetimedb` subdirectory. +fn fixture_module_path(name: &str, fixture: &str) -> String { + if fixture.ends_with("-cs") { + format!("./{name}/spacetimedb") + } else { + format!("./{name}") + } +} + +/// Copy a Rust, TypeScript (`-ts`) or C# (`-cs`) module fixture into the project as `name`, +/// using the workspace's bindings. TypeScript dependencies are installed when `install` is set. +fn prepare_fixture(test: &mut Smoketest, name: &str, fixture_name: &str, install: bool) { + use spacetimedb_smoketests::{pnpm, workspace_root}; + + let dir = test.project_dir.path().join(name); + let fixture = workspace_root().join("crates/smoketests/modules").join(fixture_name); + if fixture_name.ends_with("-cs") { + let source = std::fs::read_to_string(fixture.join("Lib.cs")).unwrap(); + test.prepare_csharp_module_source(name, name, &source).unwrap(); + return; + } + if !fixture_name.ends_with("-ts") { + copy_module_fixture(fixture_name, &dir).unwrap(); + patch_module_cargo_to_local_bindings(&dir).unwrap(); + return; + } + std::fs::create_dir_all(dir.join("src")).unwrap(); + std::fs::copy(fixture.join("src/index.ts"), dir.join("src/index.ts")).unwrap(); + std::fs::copy(fixture.join("tsconfig.json"), dir.join("tsconfig.json")).unwrap(); + let mut package: serde_json::Value = + serde_json::from_slice(&std::fs::read(fixture.join("package.json")).unwrap()).unwrap(); + package["dependencies"]["spacetimedb"] = + format!("file:{}", workspace_root().join("crates/bindings-typescript").display()).into(); + std::fs::write(dir.join("package.json"), serde_json::to_vec_pretty(&package).unwrap()).unwrap(); + if install { + pnpm(&["install"], &dir).unwrap(); + } +} + #[test] fn idc_self_outbox_uses_none_case_policy() { + check_self_outbox("idc-self-outbox"); +} + +#[test] +fn idc_typescript_self_outbox_uses_none_case_policy() { + spacetimedb_smoketests::require_pnpm!(); + spacetimedb_smoketests::build_typescript_sdk().expect("failed to build TypeScript SDK"); + check_self_outbox("idc-self-outbox-ts"); +} + +#[test] +fn idc_csharp_self_outbox_uses_none_case_policy() { + spacetimedb_smoketests::require_dotnet!(); + check_self_outbox("idc-self-outbox-cs"); +} + +/// Publish a module whose outbox calls its own reducer, without receiver bindings, +/// and send one message to the database itself. +fn check_self_outbox(fixture: &str) { let mut test = Smoketest::builder().autopublish(false).build(); let database = format!("idc-self-{}", random_string()); - let module_dir = test.project_dir.path().join("self_outbox"); - copy_module_fixture("idc-self-outbox", &module_dir).expect("failed to copy self-outbox fixture"); - patch_module_cargo_to_local_bindings(&module_dir).expect("failed to patch module Cargo.toml"); + prepare_fixture(&mut test, "self_outbox", fixture, true); + let module_dir = test + .project_dir + .path() + .join(fixture_module_path("self_outbox", fixture)); let output = test .spacetime(&[ @@ -617,7 +678,7 @@ impl IdcTest { /// Like `new_with_fixtures`, but `auth_fixture` publishes a separate receiver for the /// sender's `auth` dependency. Without it, both dependencies name the same receiver. fn new_with_receivers(receiver_fixture: &str, auth_fixture: Option<&str>, sender_fixture: &str) -> Self { - use spacetimedb_smoketests::{build_typescript_sdk, pnpm, workspace_root}; + use spacetimedb_smoketests::{build_typescript_sdk, pnpm}; let mut fixtures = vec![("receiver", receiver_fixture), ("sender", sender_fixture)]; fixtures.extend(auth_fixture.map(|fixture| ("auth", fixture))); @@ -629,39 +690,10 @@ impl IdcTest { let auth_db = auth_fixture.map(|_| format!("idc-ts-auth-{}", random_string())); let sender_db = format!("idc-ts-sender-{}", random_string()); let project = test.project_dir.path().to_path_buf(); - // `spacetime init` puts a C# module in a `spacetimedb` subdirectory. - let module_path = |name: &str, fixture: &str| { - if fixture.ends_with("-cs") { - format!("./{name}/spacetimedb") - } else { - format!("./{name}") - } - }; + let module_path = fixture_module_path; for &(name, fixture_name) in &fixtures { - let dir = project.join(name); - let fixture = workspace_root().join("crates/smoketests/modules").join(fixture_name); - if fixture_name.ends_with("-cs") { - let source = std::fs::read_to_string(fixture.join("Lib.cs")).unwrap(); - test.prepare_csharp_module_source(name, name, &source).unwrap(); - continue; - } - if !fixture_name.ends_with("-ts") { - copy_module_fixture(fixture_name, &dir).unwrap(); - patch_module_cargo_to_local_bindings(&dir).unwrap(); - continue; - } - std::fs::create_dir_all(dir.join("src")).unwrap(); - std::fs::copy(fixture.join("src/index.ts"), dir.join("src/index.ts")).unwrap(); - std::fs::copy(fixture.join("tsconfig.json"), dir.join("tsconfig.json")).unwrap(); - let mut package: serde_json::Value = - serde_json::from_slice(&std::fs::read(fixture.join("package.json")).unwrap()).unwrap(); - package["dependencies"]["spacetimedb"] = - format!("file:{}", workspace_root().join("crates/bindings-typescript").display()).into(); - std::fs::write(dir.join("package.json"), serde_json::to_vec_pretty(&package).unwrap()).unwrap(); // The sender is installed once its bindings are generated. - if name != "sender" { - pnpm(&["install"], &dir).unwrap(); - } + prepare_fixture(&mut test, name, fixture_name, name != "sender"); } let mut children = Vec::new(); if let (Some(database), Some(fixture)) = (&auth_db, auth_fixture) {