From 907c4c4196a38fb0ea5e038850ba7b0fad4da32a Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Fri, 23 Jan 2026 09:53:34 -0800 Subject: [PATCH 01/12] WIP with some codegen changes for ts --- crates/codegen/src/typescript.rs | 186 ++++++++++++++++++++++++++++--- 1 file changed, 171 insertions(+), 15 deletions(-) diff --git a/crates/codegen/src/typescript.rs b/crates/codegen/src/typescript.rs index 5059330882a..8cc9db961e8 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -209,44 +209,42 @@ impl Lang for TypeScript { print_file_header(out, true, false); writeln!(out); - writeln!(out, "// Import and reexport all reducer arg types"); + writeln!(out, "// Import all reducer arg schemas"); for reducer in iter_reducers(module) { let reducer_name = &reducer.name; let reducer_module_name = reducer_module_name(reducer_name); let args_type = reducer_args_type_name(&reducer.name); writeln!(out, "import {args_type} from \"./{reducer_module_name}\";"); - writeln!(out, "export {{ {args_type} }};"); } writeln!(out); - writeln!(out, "// Import and reexport all procedure arg types"); + writeln!(out, "// Import all procedure arg schemas"); for procedure in iter_procedures(module) { let procedure_name = &procedure.name; let procedure_module_name = procedure_module_name(procedure_name); let args_type = procedure_args_type_name(&procedure.name); writeln!(out, "import * as {args_type} from \"./{procedure_module_name}\";"); - writeln!(out, "export {{ {args_type} }};"); } writeln!(out); - writeln!(out, "// Import and reexport all table handle types"); + writeln!(out, "// Import all table schema definitions"); for (table_name, _) in iter_table_names_and_types(module) { let table_module_name = table_module_name(table_name); let table_name_pascalcase = table_name.deref().to_case(Case::Pascal); // TODO: This really shouldn't be necessary. We could also have `table()` accept // `__t.object(...)`s. writeln!(out, "import {table_name_pascalcase}Row from \"./{table_module_name}\";"); - writeln!(out, "export {{ {table_name_pascalcase}Row }};"); } writeln!(out); - writeln!(out, "// Import and reexport all types"); - for ty in iter_types(module) { - let type_name = collect_case(Case::Pascal, ty.name.name_segments()); - let type_module_name = type_module_name(&ty.name); - writeln!(out, "import {type_name} from \"./{type_module_name}\";"); - writeln!(out, "export {{ {type_name} }};"); - } + writeln!( + out, + "/** Type-only namespace exports for generated type groups. */" + ); + writeln!(out, "export type * as Rows from \"./rows\";"); + writeln!(out, "export type * as Reducers from \"./reducers\";"); + writeln!(out, "export type * as Procedures from \"./procedures\";"); + writeln!(out, "export type * as Types from \"./types\";"); writeln!(out); writeln!(out, "/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */"); @@ -445,10 +443,168 @@ impl Lang for TypeScript { writeln!(out, "}}"); out.newline(); - vec![OutputFile { + let index_file = OutputFile { filename: "index.ts".to_string(), code: output.into_inner(), - }] + }; + + let rows_file = generate_rows_file(module); + let reducers_file = generate_reducers_file(module); + let procedures_file = generate_procedures_file(module); + let types_file = generate_types_file(module); + + vec![index_file, rows_file, reducers_file, procedures_file, types_file] + } +} + +fn generate_rows_file(module: &ModuleDef) -> OutputFile { + let mut output = CodeIndenter::new(String::new(), INDENT); + let out = &mut output; + + print_auto_generated_file_comment(out); + print_lint_suppression(out); + writeln!(out, "import {{ type Infer as __Infer }} from \"spacetimedb\";"); + + writeln!(out); + writeln!(out, "// Import all table schema definitions"); + for (table_name, _) in iter_table_names_and_types(module) { + let table_module_name = table_module_name(table_name); + let table_name_pascalcase = table_name.deref().to_case(Case::Pascal); + writeln!(out, "import {table_name_pascalcase}Row from \"./{table_module_name}\";"); + } + + writeln!(out); + for table in iter_tables(module) { + let table_name_pascalcase = table.name.deref().to_case(Case::Pascal); + writeln!( + out, + "export type {table_name_pascalcase} = __Infer;" + ); + } + for view in iter_views(module) { + let view_name_pascalcase = view.name.deref().to_case(Case::Pascal); + writeln!( + out, + "export type {view_name_pascalcase} = __Infer;" + ); + } + out.newline(); + + OutputFile { + filename: "rows.ts".to_string(), + code: output.into_inner(), + } +} + +fn generate_reducers_file(module: &ModuleDef) -> OutputFile { + let mut output = CodeIndenter::new(String::new(), INDENT); + let out = &mut output; + + print_auto_generated_file_comment(out); + print_lint_suppression(out); + writeln!(out, "import {{ type Infer as __Infer }} from \"spacetimedb\";"); + + writeln!(out); + writeln!(out, "// Import all reducer arg schemas"); + for reducer in iter_reducers(module) { + let reducer_name = &reducer.name; + let reducer_module_name = reducer_module_name(reducer_name); + let args_type = reducer_args_type_name(&reducer.name); + writeln!(out, "import {args_type} from \"./{reducer_module_name}\";"); + } + + writeln!(out); + for reducer in iter_reducers(module) { + let reducer_name_pascalcase = reducer.name.deref().to_case(Case::Pascal); + let args_type = reducer_args_type_name(&reducer.name); + writeln!( + out, + "export type {reducer_name_pascalcase} = __Infer;" + ); + } + out.newline(); + + OutputFile { + filename: "reducers.ts".to_string(), + code: output.into_inner(), + } +} + +fn generate_procedures_file(module: &ModuleDef) -> OutputFile { + let mut output = CodeIndenter::new(String::new(), INDENT); + let out = &mut output; + + print_auto_generated_file_comment(out); + print_lint_suppression(out); + writeln!(out, "import {{ type Infer as __Infer }} from \"spacetimedb\";"); + + writeln!(out); + writeln!(out, "// Import all procedure arg schemas"); + for procedure in iter_procedures(module) { + let procedure_name = &procedure.name; + let procedure_module_name = procedure_module_name(procedure_name); + let args_type = procedure_args_type_name(&procedure.name); + writeln!(out, "import * as {args_type} from \"./{procedure_module_name}\";"); + } + + writeln!(out); + for procedure in iter_procedures(module) { + let procedure_name_pascalcase = procedure.name.deref().to_case(Case::Pascal); + let args_type = procedure_args_type_name(&procedure.name); + writeln!( + out, + "export type {procedure_name_pascalcase} = __Infer;" + ); + writeln!( + out, + "export type {procedure_name_pascalcase}Result = __Infer;" + ); + } + out.newline(); + + OutputFile { + filename: "procedures.ts".to_string(), + code: output.into_inner(), + } +} + +fn generate_types_file(module: &ModuleDef) -> OutputFile { + let mut output = CodeIndenter::new(String::new(), INDENT); + let out = &mut output; + + print_auto_generated_file_comment(out); + print_lint_suppression(out); + writeln!(out, "import {{ type Infer as __Infer }} from \"spacetimedb\";"); + + let reducer_type_names = module + .reducers() + .map(|reducer| reducer.name.deref().to_case(Case::Pascal)) + .collect::>(); + + writeln!(out); + writeln!(out, "// Import all non-reducer types"); + for ty in iter_types(module) { + let type_name = collect_case(Case::Pascal, ty.name.name_segments()); + if reducer_type_names.contains(&type_name) { + continue; + } + let type_module_name = type_module_name(&ty.name); + writeln!(out, "import {type_name} from \"./{type_module_name}\";"); + } + + writeln!(out); + for ty in iter_types(module) { + let type_name = collect_case(Case::Pascal, ty.name.name_segments()); + if reducer_type_names.contains(&type_name) { + continue; + } + writeln!(out, "export type {type_name} = __Infer;"); + } + out.newline(); + + OutputFile { + filename: "types.ts".to_string(), + code: output.into_inner(), } } From 617ef675e98b819808c64dfffbfb44943fd2b612 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 26 Jan 2026 10:32:38 -0800 Subject: [PATCH 02/12] Add Args suffix for reducers --- crates/codegen/src/typescript.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/codegen/src/typescript.rs b/crates/codegen/src/typescript.rs index 8cc9db961e8..aa0f6f339f2 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -519,7 +519,7 @@ fn generate_reducers_file(module: &ModuleDef) -> OutputFile { let args_type = reducer_args_type_name(&reducer.name); writeln!( out, - "export type {reducer_name_pascalcase} = __Infer;" + "export type {reducer_name_pascalcase}Args = __Infer;" ); } out.newline(); From 7a665e275b3a31eb6874290c64f6f4de216e90ff Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 26 Jan 2026 11:02:55 -0800 Subject: [PATCH 03/12] Only import reducer args that are callable --- crates/codegen/src/typescript.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/codegen/src/typescript.rs b/crates/codegen/src/typescript.rs index aa0f6f339f2..7ad1d920870 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -211,6 +211,10 @@ impl Lang for TypeScript { writeln!(out); writeln!(out, "// Import all reducer arg schemas"); for reducer in iter_reducers(module) { + if !is_reducer_invokable(reducer) { + // Skip system-defined reducers + continue; + } let reducer_name = &reducer.name; let reducer_module_name = reducer_module_name(reducer_name); let args_type = reducer_args_type_name(&reducer.name); @@ -553,7 +557,7 @@ fn generate_procedures_file(module: &ModuleDef) -> OutputFile { let args_type = procedure_args_type_name(&procedure.name); writeln!( out, - "export type {procedure_name_pascalcase} = __Infer;" + "export type {procedure_name_pascalcase}Args = __Infer;" ); writeln!( out, From a38b6e39ebd113123972675399cfcb2197c62246 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 26 Jan 2026 11:07:54 -0800 Subject: [PATCH 04/12] Add regenerated stuff --- .../src/lib/autogen/procedures.ts | 8 ++ .../src/lib/autogen/reducers.ts | 8 ++ .../src/lib/autogen/rows.ts | 8 ++ .../src/lib/autogen/types.ts | 101 ++++++++++++++++++ .../src/sdk/client_api/index.ts | 88 +++------------ .../src/sdk/client_api/procedures.ts | 8 ++ .../src/sdk/client_api/reducers.ts | 8 ++ .../src/sdk/client_api/rows.ts | 8 ++ .../src/sdk/client_api/types.ts | 77 +++++++++++++ .../test-app/src/module_bindings/index.ts | 28 ++--- .../src/module_bindings/procedures.ts | 8 ++ .../test-app/src/module_bindings/reducers.ts | 11 ++ .../test-app/src/module_bindings/rows.ts | 15 +++ .../test-app/src/module_bindings/types.ts | 17 +++ .../src/module_bindings/custom_type_type.ts | 15 +++ .../basic-react/src/module_bindings/index.ts | 35 ++---- .../src/module_bindings/procedures.ts | 8 ++ .../src/module_bindings/reducers.ts | 17 +++ .../basic-react/src/module_bindings/rows.ts | 11 ++ .../src/module_bindings/testtable_type.ts | 18 ++++ .../basic-react/src/module_bindings/types.ts | 11 ++ .../src/module_bindings/index.ts | 35 ++---- .../src/module_bindings/procedures.ts | 8 ++ .../src/module_bindings/reducers.ts | 17 +++ .../src/module_bindings/rows.ts | 11 ++ .../src/module_bindings/types.ts | 11 ++ .../quickstart-chat-typescript/src/App.tsx | 8 +- .../src/module_bindings/index.ts | 38 ++----- .../src/module_bindings/procedures.ts | 8 ++ .../src/module_bindings/reducers.ts | 17 +++ .../src/module_bindings/rows.ts | 13 +++ .../src/module_bindings/types.ts | 13 +++ 32 files changed, 510 insertions(+), 177 deletions(-) create mode 100644 crates/bindings-typescript/src/lib/autogen/procedures.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/reducers.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/rows.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/types.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/procedures.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/reducers.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/rows.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/types.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/procedures.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/reducers.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/rows.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types.ts create mode 100644 templates/basic-react/src/module_bindings/custom_type_type.ts create mode 100644 templates/basic-react/src/module_bindings/procedures.ts create mode 100644 templates/basic-react/src/module_bindings/reducers.ts create mode 100644 templates/basic-react/src/module_bindings/rows.ts create mode 100644 templates/basic-react/src/module_bindings/testtable_type.ts create mode 100644 templates/basic-react/src/module_bindings/types.ts create mode 100644 templates/basic-typescript/src/module_bindings/procedures.ts create mode 100644 templates/basic-typescript/src/module_bindings/reducers.ts create mode 100644 templates/basic-typescript/src/module_bindings/rows.ts create mode 100644 templates/basic-typescript/src/module_bindings/types.ts create mode 100644 templates/quickstart-chat-typescript/src/module_bindings/procedures.ts create mode 100644 templates/quickstart-chat-typescript/src/module_bindings/reducers.ts create mode 100644 templates/quickstart-chat-typescript/src/module_bindings/rows.ts create mode 100644 templates/quickstart-chat-typescript/src/module_bindings/types.ts diff --git a/crates/bindings-typescript/src/lib/autogen/procedures.ts b/crates/bindings-typescript/src/lib/autogen/procedures.ts new file mode 100644 index 00000000000..6625edb1b2e --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all procedure arg schemas diff --git a/crates/bindings-typescript/src/lib/autogen/reducers.ts b/crates/bindings-typescript/src/lib/autogen/reducers.ts new file mode 100644 index 00000000000..69fa905ce4f --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/reducers.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all reducer arg schemas diff --git a/crates/bindings-typescript/src/lib/autogen/rows.ts b/crates/bindings-typescript/src/lib/autogen/rows.ts new file mode 100644 index 00000000000..693f6effe27 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/rows.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all table schema definitions diff --git a/crates/bindings-typescript/src/lib/autogen/types.ts b/crates/bindings-typescript/src/lib/autogen/types.ts new file mode 100644 index 00000000000..673f4a67b2b --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/types.ts @@ -0,0 +1,101 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all non-reducer types +import AlgebraicType from './algebraic_type_type'; +import HttpHeaderPair from './http_header_pair_type'; +import HttpHeaders from './http_headers_type'; +import HttpMethod from './http_method_type'; +import HttpRequest from './http_request_type'; +import HttpResponse from './http_response_type'; +import HttpVersion from './http_version_type'; +import IndexType from './index_type_type'; +import Lifecycle from './lifecycle_type'; +import MiscModuleExport from './misc_module_export_type'; +import ProductType from './product_type_type'; +import ProductTypeElement from './product_type_element_type'; +import RawColumnDefV8 from './raw_column_def_v_8_type'; +import RawColumnDefaultValueV9 from './raw_column_default_value_v_9_type'; +import RawConstraintDataV9 from './raw_constraint_data_v_9_type'; +import RawConstraintDefV8 from './raw_constraint_def_v_8_type'; +import RawConstraintDefV9 from './raw_constraint_def_v_9_type'; +import RawIndexAlgorithm from './raw_index_algorithm_type'; +import RawIndexDefV8 from './raw_index_def_v_8_type'; +import RawIndexDefV9 from './raw_index_def_v_9_type'; +import RawMiscModuleExportV9 from './raw_misc_module_export_v_9_type'; +import RawModuleDef from './raw_module_def_type'; +import RawModuleDefV8 from './raw_module_def_v_8_type'; +import RawModuleDefV9 from './raw_module_def_v_9_type'; +import RawProcedureDefV9 from './raw_procedure_def_v_9_type'; +import RawReducerDefV9 from './raw_reducer_def_v_9_type'; +import RawRowLevelSecurityDefV9 from './raw_row_level_security_def_v_9_type'; +import RawScheduleDefV9 from './raw_schedule_def_v_9_type'; +import RawScopedTypeNameV9 from './raw_scoped_type_name_v_9_type'; +import RawSequenceDefV8 from './raw_sequence_def_v_8_type'; +import RawSequenceDefV9 from './raw_sequence_def_v_9_type'; +import RawTableDefV8 from './raw_table_def_v_8_type'; +import RawTableDefV9 from './raw_table_def_v_9_type'; +import RawTypeDefV9 from './raw_type_def_v_9_type'; +import RawUniqueConstraintDataV9 from './raw_unique_constraint_data_v_9_type'; +import RawViewDefV9 from './raw_view_def_v_9_type'; +import ReducerDef from './reducer_def_type'; +import SumType from './sum_type_type'; +import SumTypeVariant from './sum_type_variant_type'; +import TableAccess from './table_access_type'; +import TableDesc from './table_desc_type'; +import TableType from './table_type_type'; +import TypeAlias from './type_alias_type'; +import Typespace from './typespace_type'; +import ViewResultHeader from './view_result_header_type'; + +export type AlgebraicType = __Infer; +export type HttpHeaderPair = __Infer; +export type HttpHeaders = __Infer; +export type HttpMethod = __Infer; +export type HttpRequest = __Infer; +export type HttpResponse = __Infer; +export type HttpVersion = __Infer; +export type IndexType = __Infer; +export type Lifecycle = __Infer; +export type MiscModuleExport = __Infer; +export type ProductType = __Infer; +export type ProductTypeElement = __Infer; +export type RawColumnDefV8 = __Infer; +export type RawColumnDefaultValueV9 = __Infer; +export type RawConstraintDataV9 = __Infer; +export type RawConstraintDefV8 = __Infer; +export type RawConstraintDefV9 = __Infer; +export type RawIndexAlgorithm = __Infer; +export type RawIndexDefV8 = __Infer; +export type RawIndexDefV9 = __Infer; +export type RawMiscModuleExportV9 = __Infer; +export type RawModuleDef = __Infer; +export type RawModuleDefV8 = __Infer; +export type RawModuleDefV9 = __Infer; +export type RawProcedureDefV9 = __Infer; +export type RawReducerDefV9 = __Infer; +export type RawRowLevelSecurityDefV9 = __Infer; +export type RawScheduleDefV9 = __Infer; +export type RawScopedTypeNameV9 = __Infer; +export type RawSequenceDefV8 = __Infer; +export type RawSequenceDefV9 = __Infer; +export type RawTableDefV8 = __Infer; +export type RawTableDefV9 = __Infer; +export type RawTypeDefV9 = __Infer; +export type RawUniqueConstraintDataV9 = __Infer< + typeof RawUniqueConstraintDataV9 +>; +export type RawViewDefV9 = __Infer; +export type ReducerDef = __Infer; +export type SumType = __Infer; +export type SumTypeVariant = __Infer; +export type TableAccess = __Infer; +export type TableDesc = __Infer; +export type TableType = __Infer; +export type TypeAlias = __Infer; +export type Typespace = __Infer; +export type ViewResultHeader = __Infer; diff --git a/crates/bindings-typescript/src/sdk/client_api/index.ts b/crates/bindings-typescript/src/sdk/client_api/index.ts index 5b7fa1a1f21..77a0cd4f89b 100644 --- a/crates/bindings-typescript/src/sdk/client_api/index.ts +++ b/crates/bindings-typescript/src/sdk/client_api/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). /* eslint-disable */ /* tslint:disable */ @@ -33,81 +33,17 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from '../../index'; -// Import and reexport all reducer arg types - -// Import and reexport all procedure arg types - -// Import and reexport all table handle types - -// Import and reexport all types -import BsatnRowList from './bsatn_row_list_type'; -export { BsatnRowList }; -import CallProcedure from './call_procedure_type'; -export { CallProcedure }; -import CallReducer from './call_reducer_type'; -export { CallReducer }; -import ClientMessage from './client_message_type'; -export { ClientMessage }; -import CompressableQueryUpdate from './compressable_query_update_type'; -export { CompressableQueryUpdate }; -import DatabaseUpdate from './database_update_type'; -export { DatabaseUpdate }; -import EnergyQuanta from './energy_quanta_type'; -export { EnergyQuanta }; -import IdentityToken from './identity_token_type'; -export { IdentityToken }; -import InitialSubscription from './initial_subscription_type'; -export { InitialSubscription }; -import OneOffQuery from './one_off_query_type'; -export { OneOffQuery }; -import OneOffQueryResponse from './one_off_query_response_type'; -export { OneOffQueryResponse }; -import OneOffTable from './one_off_table_type'; -export { OneOffTable }; -import ProcedureResult from './procedure_result_type'; -export { ProcedureResult }; -import ProcedureStatus from './procedure_status_type'; -export { ProcedureStatus }; -import QueryId from './query_id_type'; -export { QueryId }; -import QueryUpdate from './query_update_type'; -export { QueryUpdate }; -import ReducerCallInfo from './reducer_call_info_type'; -export { ReducerCallInfo }; -import RowSizeHint from './row_size_hint_type'; -export { RowSizeHint }; -import ServerMessage from './server_message_type'; -export { ServerMessage }; -import Subscribe from './subscribe_type'; -export { Subscribe }; -import SubscribeApplied from './subscribe_applied_type'; -export { SubscribeApplied }; -import SubscribeMulti from './subscribe_multi_type'; -export { SubscribeMulti }; -import SubscribeMultiApplied from './subscribe_multi_applied_type'; -export { SubscribeMultiApplied }; -import SubscribeRows from './subscribe_rows_type'; -export { SubscribeRows }; -import SubscribeSingle from './subscribe_single_type'; -export { SubscribeSingle }; -import SubscriptionError from './subscription_error_type'; -export { SubscriptionError }; -import TableUpdate from './table_update_type'; -export { TableUpdate }; -import TransactionUpdate from './transaction_update_type'; -export { TransactionUpdate }; -import TransactionUpdateLight from './transaction_update_light_type'; -export { TransactionUpdateLight }; -import Unsubscribe from './unsubscribe_type'; -export { Unsubscribe }; -import UnsubscribeApplied from './unsubscribe_applied_type'; -export { UnsubscribeApplied }; -import UnsubscribeMulti from './unsubscribe_multi_type'; -export { UnsubscribeMulti }; -import UnsubscribeMultiApplied from './unsubscribe_multi_applied_type'; -export { UnsubscribeMultiApplied }; -import UpdateStatus from './update_status_type'; -export { UpdateStatus }; +// Import all reducer arg schemas + +// Import all procedure arg schemas + +// Import all table schema definitions + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema(); diff --git a/crates/bindings-typescript/src/sdk/client_api/procedures.ts b/crates/bindings-typescript/src/sdk/client_api/procedures.ts new file mode 100644 index 00000000000..6625edb1b2e --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all procedure arg schemas diff --git a/crates/bindings-typescript/src/sdk/client_api/reducers.ts b/crates/bindings-typescript/src/sdk/client_api/reducers.ts new file mode 100644 index 00000000000..69fa905ce4f --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/reducers.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all reducer arg schemas diff --git a/crates/bindings-typescript/src/sdk/client_api/rows.ts b/crates/bindings-typescript/src/sdk/client_api/rows.ts new file mode 100644 index 00000000000..693f6effe27 --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/rows.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all table schema definitions diff --git a/crates/bindings-typescript/src/sdk/client_api/types.ts b/crates/bindings-typescript/src/sdk/client_api/types.ts new file mode 100644 index 00000000000..70dcff626c4 --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/types.ts @@ -0,0 +1,77 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../lib/type_builders'; + +// Import all non-reducer types +import BsatnRowList from './bsatn_row_list_type'; +import CallProcedure from './call_procedure_type'; +import CallReducer from './call_reducer_type'; +import ClientMessage from './client_message_type'; +import CompressableQueryUpdate from './compressable_query_update_type'; +import DatabaseUpdate from './database_update_type'; +import EnergyQuanta from './energy_quanta_type'; +import IdentityToken from './identity_token_type'; +import InitialSubscription from './initial_subscription_type'; +import OneOffQuery from './one_off_query_type'; +import OneOffQueryResponse from './one_off_query_response_type'; +import OneOffTable from './one_off_table_type'; +import ProcedureResult from './procedure_result_type'; +import ProcedureStatus from './procedure_status_type'; +import QueryId from './query_id_type'; +import QueryUpdate from './query_update_type'; +import ReducerCallInfo from './reducer_call_info_type'; +import RowSizeHint from './row_size_hint_type'; +import ServerMessage from './server_message_type'; +import Subscribe from './subscribe_type'; +import SubscribeApplied from './subscribe_applied_type'; +import SubscribeMulti from './subscribe_multi_type'; +import SubscribeMultiApplied from './subscribe_multi_applied_type'; +import SubscribeRows from './subscribe_rows_type'; +import SubscribeSingle from './subscribe_single_type'; +import SubscriptionError from './subscription_error_type'; +import TableUpdate from './table_update_type'; +import TransactionUpdate from './transaction_update_type'; +import TransactionUpdateLight from './transaction_update_light_type'; +import Unsubscribe from './unsubscribe_type'; +import UnsubscribeApplied from './unsubscribe_applied_type'; +import UnsubscribeMulti from './unsubscribe_multi_type'; +import UnsubscribeMultiApplied from './unsubscribe_multi_applied_type'; +import UpdateStatus from './update_status_type'; + +export type BsatnRowList = __Infer; +export type CallProcedure = __Infer; +export type CallReducer = __Infer; +export type ClientMessage = __Infer; +export type CompressableQueryUpdate = __Infer; +export type DatabaseUpdate = __Infer; +export type EnergyQuanta = __Infer; +export type IdentityToken = __Infer; +export type InitialSubscription = __Infer; +export type OneOffQuery = __Infer; +export type OneOffQueryResponse = __Infer; +export type OneOffTable = __Infer; +export type ProcedureResult = __Infer; +export type ProcedureStatus = __Infer; +export type QueryId = __Infer; +export type QueryUpdate = __Infer; +export type ReducerCallInfo = __Infer; +export type RowSizeHint = __Infer; +export type ServerMessage = __Infer; +export type Subscribe = __Infer; +export type SubscribeApplied = __Infer; +export type SubscribeMulti = __Infer; +export type SubscribeMultiApplied = __Infer; +export type SubscribeRows = __Infer; +export type SubscribeSingle = __Infer; +export type SubscriptionError = __Infer; +export type TableUpdate = __Infer; +export type TransactionUpdate = __Infer; +export type TransactionUpdateLight = __Infer; +export type Unsubscribe = __Infer; +export type UnsubscribeApplied = __Infer; +export type UnsubscribeMulti = __Infer; +export type UnsubscribeMultiApplied = __Infer; +export type UpdateStatus = __Infer; diff --git a/crates/bindings-typescript/test-app/src/module_bindings/index.ts b/crates/bindings-typescript/test-app/src/module_bindings/index.ts index 22483e31050..41be99e7b37 100644 --- a/crates/bindings-typescript/test-app/src/module_bindings/index.ts +++ b/crates/bindings-typescript/test-app/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). /* eslint-disable */ /* tslint:disable */ @@ -33,29 +33,21 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from '../../../src/index'; -// Import and reexport all reducer arg types +// Import all reducer arg schemas import CreatePlayerReducer from './create_player_reducer'; -export { CreatePlayerReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas -// Import and reexport all table handle types +// Import all table schema definitions import PlayerRow from './player_table'; -export { PlayerRow }; import UnindexedPlayerRow from './unindexed_player_table'; -export { UnindexedPlayerRow }; import UserRow from './user_table'; -export { UserRow }; - -// Import and reexport all types -import Player from './player_type'; -export { Player }; -import Point from './point_type'; -export { Point }; -import UnindexedPlayer from './unindexed_player_type'; -export { UnindexedPlayer }; -import User from './user_type'; -export { User }; + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/crates/bindings-typescript/test-app/src/module_bindings/procedures.ts b/crates/bindings-typescript/test-app/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b0921721821 --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../src/index'; + +// Import all procedure arg schemas diff --git a/crates/bindings-typescript/test-app/src/module_bindings/reducers.ts b/crates/bindings-typescript/test-app/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..7008968ffef --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/reducers.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../src/index'; + +// Import all reducer arg schemas +import CreatePlayerReducer from './create_player_reducer'; + +export type CreatePlayerArgs = __Infer; diff --git a/crates/bindings-typescript/test-app/src/module_bindings/rows.ts b/crates/bindings-typescript/test-app/src/module_bindings/rows.ts new file mode 100644 index 00000000000..904ba9a3f12 --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/rows.ts @@ -0,0 +1,15 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../src/index'; + +// Import all table schema definitions +import PlayerRow from './player_table'; +import UnindexedPlayerRow from './unindexed_player_table'; +import UserRow from './user_table'; + +export type Player = __Infer; +export type UnindexedPlayer = __Infer; +export type User = __Infer; diff --git a/crates/bindings-typescript/test-app/src/module_bindings/types.ts b/crates/bindings-typescript/test-app/src/module_bindings/types.ts new file mode 100644 index 00000000000..3d8eb202900 --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/types.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../src/index'; + +// Import all non-reducer types +import Player from './player_type'; +import Point from './point_type'; +import UnindexedPlayer from './unindexed_player_type'; +import User from './user_type'; + +export type Player = __Infer; +export type Point = __Infer; +export type UnindexedPlayer = __Infer; +export type User = __Infer; diff --git a/templates/basic-react/src/module_bindings/custom_type_type.ts b/templates/basic-react/src/module_bindings/custom_type_type.ts new file mode 100644 index 00000000000..1c9dcb38596 --- /dev/null +++ b/templates/basic-react/src/module_bindings/custom_type_type.ts @@ -0,0 +1,15 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, +} from 'spacetimedb'; + +export default __t.object('CustomType', { + name: __t.string(), +}); diff --git a/templates/basic-react/src/module_bindings/index.ts b/templates/basic-react/src/module_bindings/index.ts index 23ea2b9deb3..44ba6d56704 100644 --- a/templates/basic-react/src/module_bindings/index.ts +++ b/templates/basic-react/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). /* eslint-disable */ /* tslint:disable */ @@ -33,35 +33,20 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from 'spacetimedb'; -// Import and reexport all reducer arg types -import OnConnectReducer from './on_connect_reducer'; -export { OnConnectReducer }; -import OnDisconnectReducer from './on_disconnect_reducer'; -export { OnDisconnectReducer }; +// Import all reducer arg schemas import AddReducer from './add_reducer'; -export { AddReducer }; import SayHelloReducer from './say_hello_reducer'; -export { SayHelloReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas -// Import and reexport all table handle types +// Import all table schema definitions import PersonRow from './person_table'; -export { PersonRow }; - -// Import and reexport all types -import Add from './add_type'; -export { Add }; -import Init from './init_type'; -export { Init }; -import OnConnect from './on_connect_type'; -export { OnConnect }; -import OnDisconnect from './on_disconnect_type'; -export { OnDisconnect }; -import Person from './person_type'; -export { Person }; -import SayHello from './say_hello_type'; -export { SayHello }; + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/basic-react/src/module_bindings/procedures.ts b/templates/basic-react/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/basic-react/src/module_bindings/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/basic-react/src/module_bindings/reducers.ts b/templates/basic-react/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..0259dbf4b1a --- /dev/null +++ b/templates/basic-react/src/module_bindings/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from './on_connect_reducer'; +import OnDisconnectReducer from './on_disconnect_reducer'; +import AddReducer from './add_reducer'; +import SayHelloReducer from './say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/basic-react/src/module_bindings/rows.ts b/templates/basic-react/src/module_bindings/rows.ts new file mode 100644 index 00000000000..8fad581583d --- /dev/null +++ b/templates/basic-react/src/module_bindings/rows.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all table schema definitions +import PersonRow from './person_table'; + +export type Person = __Infer; diff --git a/templates/basic-react/src/module_bindings/testtable_type.ts b/templates/basic-react/src/module_bindings/testtable_type.ts new file mode 100644 index 00000000000..5d0a364a28b --- /dev/null +++ b/templates/basic-react/src/module_bindings/testtable_type.ts @@ -0,0 +1,18 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { + TypeBuilder as __TypeBuilder, + t as __t, + type AlgebraicTypeType as __AlgebraicTypeType, + type Infer as __Infer, +} from 'spacetimedb'; +import CustomType from './custom_type_type'; + +export default __t.object('Testtable', { + get idk() { + return CustomType; + }, +}); diff --git a/templates/basic-react/src/module_bindings/types.ts b/templates/basic-react/src/module_bindings/types.ts new file mode 100644 index 00000000000..8f2d578255a --- /dev/null +++ b/templates/basic-react/src/module_bindings/types.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all non-reducer types +import Person from './person_type'; + +export type Person = __Infer; diff --git a/templates/basic-typescript/src/module_bindings/index.ts b/templates/basic-typescript/src/module_bindings/index.ts index 23ea2b9deb3..44ba6d56704 100644 --- a/templates/basic-typescript/src/module_bindings/index.ts +++ b/templates/basic-typescript/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). /* eslint-disable */ /* tslint:disable */ @@ -33,35 +33,20 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from 'spacetimedb'; -// Import and reexport all reducer arg types -import OnConnectReducer from './on_connect_reducer'; -export { OnConnectReducer }; -import OnDisconnectReducer from './on_disconnect_reducer'; -export { OnDisconnectReducer }; +// Import all reducer arg schemas import AddReducer from './add_reducer'; -export { AddReducer }; import SayHelloReducer from './say_hello_reducer'; -export { SayHelloReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas -// Import and reexport all table handle types +// Import all table schema definitions import PersonRow from './person_table'; -export { PersonRow }; - -// Import and reexport all types -import Add from './add_type'; -export { Add }; -import Init from './init_type'; -export { Init }; -import OnConnect from './on_connect_type'; -export { OnConnect }; -import OnDisconnect from './on_disconnect_type'; -export { OnDisconnect }; -import Person from './person_type'; -export { Person }; -import SayHello from './say_hello_type'; -export { SayHello }; + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/basic-typescript/src/module_bindings/procedures.ts b/templates/basic-typescript/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/basic-typescript/src/module_bindings/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/basic-typescript/src/module_bindings/reducers.ts b/templates/basic-typescript/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..0259dbf4b1a --- /dev/null +++ b/templates/basic-typescript/src/module_bindings/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from './on_connect_reducer'; +import OnDisconnectReducer from './on_disconnect_reducer'; +import AddReducer from './add_reducer'; +import SayHelloReducer from './say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/basic-typescript/src/module_bindings/rows.ts b/templates/basic-typescript/src/module_bindings/rows.ts new file mode 100644 index 00000000000..8fad581583d --- /dev/null +++ b/templates/basic-typescript/src/module_bindings/rows.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all table schema definitions +import PersonRow from './person_table'; + +export type Person = __Infer; diff --git a/templates/basic-typescript/src/module_bindings/types.ts b/templates/basic-typescript/src/module_bindings/types.ts new file mode 100644 index 00000000000..8f2d578255a --- /dev/null +++ b/templates/basic-typescript/src/module_bindings/types.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all non-reducer types +import Person from './person_type'; + +export type Person = __Infer; diff --git a/templates/quickstart-chat-typescript/src/App.tsx b/templates/quickstart-chat-typescript/src/App.tsx index 1da2737cd82..e7025f3712c 100644 --- a/templates/quickstart-chat-typescript/src/App.tsx +++ b/templates/quickstart-chat-typescript/src/App.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import './App.css'; -import { tables, reducers, Message } from './module_bindings'; +import { tables, reducers, Rows } from './module_bindings'; import { useSpacetimeDB, useTable, @@ -8,7 +8,7 @@ import { eq, useReducer, } from 'spacetimedb/react'; -import { Identity, Infer, Timestamp } from 'spacetimedb'; +import { Identity, Timestamp } from 'spacetimedb'; export type PrettyMessage = { senderName: string; @@ -20,9 +20,7 @@ export type PrettyMessage = { function App() { const [newName, setNewName] = useState(''); const [settingName, setSettingName] = useState(false); - const [systemMessages, setSystemMessages] = useState( - [] as Infer[] - ); + const [systemMessages, setSystemMessages] = useState([] as Rows.Message[]); const [newMessage, setNewMessage] = useState(''); const { identity, isActive: connected } = useSpacetimeDB(); diff --git a/templates/quickstart-chat-typescript/src/module_bindings/index.ts b/templates/quickstart-chat-typescript/src/module_bindings/index.ts index 5dc82db57f6..4f0c30b1657 100644 --- a/templates/quickstart-chat-typescript/src/module_bindings/index.ts +++ b/templates/quickstart-chat-typescript/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). /* eslint-disable */ /* tslint:disable */ @@ -33,39 +33,21 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from 'spacetimedb'; -// Import and reexport all reducer arg types +// Import all reducer arg schemas import SetNameReducer from './set_name_reducer'; -export { SetNameReducer }; import SendMessageReducer from './send_message_reducer'; -export { SendMessageReducer }; -import OnConnectReducer from './on_connect_reducer'; -export { OnConnectReducer }; -import OnDisconnectReducer from './on_disconnect_reducer'; -export { OnDisconnectReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas -// Import and reexport all table handle types +// Import all table schema definitions import MessageRow from './message_table'; -export { MessageRow }; import UserRow from './user_table'; -export { UserRow }; - -// Import and reexport all types -import Init from './init_type'; -export { Init }; -import Message from './message_type'; -export { Message }; -import OnConnect from './on_connect_type'; -export { OnConnect }; -import OnDisconnect from './on_disconnect_type'; -export { OnDisconnect }; -import SendMessage from './send_message_type'; -export { SendMessage }; -import SetName from './set_name_type'; -export { SetName }; -import User from './user_type'; -export { User }; + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/quickstart-chat-typescript/src/module_bindings/procedures.ts b/templates/quickstart-chat-typescript/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/quickstart-chat-typescript/src/module_bindings/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/quickstart-chat-typescript/src/module_bindings/reducers.ts b/templates/quickstart-chat-typescript/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..f6189b8f46b --- /dev/null +++ b/templates/quickstart-chat-typescript/src/module_bindings/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import SetNameReducer from './set_name_reducer'; +import SendMessageReducer from './send_message_reducer'; +import OnConnectReducer from './on_connect_reducer'; +import OnDisconnectReducer from './on_disconnect_reducer'; + +export type SetNameArgs = __Infer; +export type SendMessageArgs = __Infer; +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; diff --git a/templates/quickstart-chat-typescript/src/module_bindings/rows.ts b/templates/quickstart-chat-typescript/src/module_bindings/rows.ts new file mode 100644 index 00000000000..4ca40647ec6 --- /dev/null +++ b/templates/quickstart-chat-typescript/src/module_bindings/rows.ts @@ -0,0 +1,13 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all table schema definitions +import MessageRow from './message_table'; +import UserRow from './user_table'; + +export type Message = __Infer; +export type User = __Infer; diff --git a/templates/quickstart-chat-typescript/src/module_bindings/types.ts b/templates/quickstart-chat-typescript/src/module_bindings/types.ts new file mode 100644 index 00000000000..50bbdd264ea --- /dev/null +++ b/templates/quickstart-chat-typescript/src/module_bindings/types.ts @@ -0,0 +1,13 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all non-reducer types +import Message from './message_type'; +import User from './user_type'; + +export type Message = __Infer; +export type User = __Infer; From 36bf624fed8949e753c863d300eca167a90a78d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 26 Jan 2026 11:28:27 -0800 Subject: [PATCH 05/12] regen a template --- templates/basic-ts/src/module_bindings/index.ts | 2 +- .../basic-ts/src/module_bindings/procedures.ts | 8 ++++++++ .../basic-ts/src/module_bindings/reducers.ts | 17 +++++++++++++++++ templates/basic-ts/src/module_bindings/rows.ts | 11 +++++++++++ templates/basic-ts/src/module_bindings/types.ts | 11 +++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 templates/basic-ts/src/module_bindings/procedures.ts create mode 100644 templates/basic-ts/src/module_bindings/reducers.ts create mode 100644 templates/basic-ts/src/module_bindings/rows.ts create mode 100644 templates/basic-ts/src/module_bindings/types.ts diff --git a/templates/basic-ts/src/module_bindings/index.ts b/templates/basic-ts/src/module_bindings/index.ts index 44ba6d56704..dea9b5470e0 100644 --- a/templates/basic-ts/src/module_bindings/index.ts +++ b/templates/basic-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). +// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). /* eslint-disable */ /* tslint:disable */ diff --git a/templates/basic-ts/src/module_bindings/procedures.ts b/templates/basic-ts/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/basic-ts/src/module_bindings/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/basic-ts/src/module_bindings/reducers.ts b/templates/basic-ts/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..0259dbf4b1a --- /dev/null +++ b/templates/basic-ts/src/module_bindings/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from './on_connect_reducer'; +import OnDisconnectReducer from './on_disconnect_reducer'; +import AddReducer from './add_reducer'; +import SayHelloReducer from './say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/basic-ts/src/module_bindings/rows.ts b/templates/basic-ts/src/module_bindings/rows.ts new file mode 100644 index 00000000000..8fad581583d --- /dev/null +++ b/templates/basic-ts/src/module_bindings/rows.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all table schema definitions +import PersonRow from './person_table'; + +export type Person = __Infer; diff --git a/templates/basic-ts/src/module_bindings/types.ts b/templates/basic-ts/src/module_bindings/types.ts new file mode 100644 index 00000000000..8f2d578255a --- /dev/null +++ b/templates/basic-ts/src/module_bindings/types.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all non-reducer types +import Person from './person_type'; + +export type Person = __Infer; From 55f1fe331241e1f80b3af7b7dbb093ba3db1b4f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Mon, 26 Jan 2026 11:31:17 -0800 Subject: [PATCH 06/12] Regen --- .../src/module_bindings/index.ts | 2 +- .../react-ts/src/module_bindings/index.ts | 2 +- templates/vue-ts/src/module_bindings/index.ts | 43 ++++++++----------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/templates/chat-react-ts/src/module_bindings/index.ts b/templates/chat-react-ts/src/module_bindings/index.ts index 4f0c30b1657..be96c277b6e 100644 --- a/templates/chat-react-ts/src/module_bindings/index.ts +++ b/templates/chat-react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). +// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). /* eslint-disable */ /* tslint:disable */ diff --git a/templates/react-ts/src/module_bindings/index.ts b/templates/react-ts/src/module_bindings/index.ts index 44ba6d56704..dea9b5470e0 100644 --- a/templates/react-ts/src/module_bindings/index.ts +++ b/templates/react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). +// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). /* eslint-disable */ /* tslint:disable */ diff --git a/templates/vue-ts/src/module_bindings/index.ts b/templates/vue-ts/src/module_bindings/index.ts index 3c2919c1917..dea9b5470e0 100644 --- a/templates/vue-ts/src/module_bindings/index.ts +++ b/templates/vue-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.2 (commit 5508f620e2fd5a4d8a3b7aaf5303776d127f5cbd). +// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). /* eslint-disable */ /* tslint:disable */ @@ -12,6 +12,7 @@ import { TypeBuilder as __TypeBuilder, Uuid as __Uuid, convertToAccessorMap as __convertToAccessorMap, + makeQueryBuilder as __makeQueryBuilder, procedureSchema as __procedureSchema, procedures as __procedures, reducerSchema as __reducerSchema, @@ -25,41 +26,27 @@ import { type Event as __Event, type EventContextInterface as __EventContextInterface, type Infer as __Infer, + type QueryBuilder as __QueryBuilder, type ReducerEventContextInterface as __ReducerEventContextInterface, type RemoteModule as __RemoteModule, type SubscriptionEventContextInterface as __SubscriptionEventContextInterface, type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from 'spacetimedb'; -// Import and reexport all reducer arg types -import OnConnectReducer from './on_connect_reducer'; -export { OnConnectReducer }; -import OnDisconnectReducer from './on_disconnect_reducer'; -export { OnDisconnectReducer }; +// Import all reducer arg schemas import AddReducer from './add_reducer'; -export { AddReducer }; import SayHelloReducer from './say_hello_reducer'; -export { SayHelloReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas -// Import and reexport all table handle types +// Import all table schema definitions import PersonRow from './person_table'; -export { PersonRow }; - -// Import and reexport all types -import Add from './add_type'; -export { Add }; -import Init from './init_type'; -export { Init }; -import OnConnect from './on_connect_type'; -export { OnConnect }; -import OnDisconnect from './on_disconnect_type'; -export { OnDisconnect }; -import Person from './person_type'; -export { Person }; -import SayHello from './say_hello_type'; -export { SayHello }; + +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from './rows'; +export type * as Reducers from './reducers'; +export type * as Procedures from './procedures'; +export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( @@ -85,7 +72,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.2' as const, + cliVersion: '1.11.3' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, @@ -99,6 +86,10 @@ const REMOTE_MODULE = { /** The tables available in this remote SpacetimeDB module. */ export const tables = __convertToAccessorMap(tablesSchema.schemaType.tables); +/** A typed query builder for this remote SpacetimeDB module. */ +export const query: __QueryBuilder = + __makeQueryBuilder(tablesSchema.schemaType); + /** The reducers available in this remote SpacetimeDB module. */ export const reducers = __convertToAccessorMap( reducersSchema.reducersType.reducers From 7eb7feed0ab242e3d848cd11c0cbd44a8cbe4e10 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Tue, 27 Jan 2026 10:01:00 -0800 Subject: [PATCH 07/12] Update codegen snap --- .../codegen__codegen_typescript.snap | 229 ++++++++++++------ 1 file changed, 158 insertions(+), 71 deletions(-) diff --git a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap index c4fbcde807f..7a8828d893e 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -254,111 +254,48 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from "spacetimedb"; -// Import and reexport all reducer arg types +// Import all reducer arg schemas import AddReducer from "./add_reducer"; -export { AddReducer }; import AddPlayerReducer from "./add_player_reducer"; -export { AddPlayerReducer }; import AddPrivateReducer from "./add_private_reducer"; -export { AddPrivateReducer }; import AssertCallerIdentityIsModuleIdentityReducer from "./assert_caller_identity_is_module_identity_reducer"; -export { AssertCallerIdentityIsModuleIdentityReducer }; -import ClientConnectedReducer from "./client_connected_reducer"; -export { ClientConnectedReducer }; import DeletePlayerReducer from "./delete_player_reducer"; -export { DeletePlayerReducer }; import DeletePlayersByNameReducer from "./delete_players_by_name_reducer"; -export { DeletePlayersByNameReducer }; import ListOverAgeReducer from "./list_over_age_reducer"; -export { ListOverAgeReducer }; import LogModuleIdentityReducer from "./log_module_identity_reducer"; -export { LogModuleIdentityReducer }; import QueryPrivateReducer from "./query_private_reducer"; -export { QueryPrivateReducer }; import RepeatingTestReducer from "./repeating_test_reducer"; -export { RepeatingTestReducer }; import SayHelloReducer from "./say_hello_reducer"; -export { SayHelloReducer }; import TestReducer from "./test_reducer"; -export { TestReducer }; import TestBtreeIndexArgsReducer from "./test_btree_index_args_reducer"; -export { TestBtreeIndexArgsReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas import * as GetMySchemaViaHttpProcedure from "./get_my_schema_via_http_procedure"; -export { GetMySchemaViaHttpProcedure }; import * as ReturnValueProcedure from "./return_value_procedure"; -export { ReturnValueProcedure }; import * as SleepOneSecondProcedure from "./sleep_one_second_procedure"; -export { SleepOneSecondProcedure }; import * as WithTxProcedure from "./with_tx_procedure"; -export { WithTxProcedure }; -// Import and reexport all table handle types +// Import all table schema definitions import HasSpecialStuffRow from "./has_special_stuff_table"; -export { HasSpecialStuffRow }; import LoggedOutPlayerRow from "./logged_out_player_table"; -export { LoggedOutPlayerRow }; import MyPlayerRow from "./my_player_table"; -export { MyPlayerRow }; import PersonRow from "./person_table"; -export { PersonRow }; import PkMultiIdentityRow from "./pk_multi_identity_table"; -export { PkMultiIdentityRow }; import PlayerRow from "./player_table"; -export { PlayerRow }; import PointsRow from "./points_table"; -export { PointsRow }; import PrivateTableRow from "./private_table_table"; -export { PrivateTableRow }; import RepeatingTestArgRow from "./repeating_test_arg_table"; -export { RepeatingTestArgRow }; import TableToRemoveRow from "./table_to_remove_table"; -export { TableToRemoveRow }; import TestARow from "./test_a_table"; -export { TestARow }; import TestDRow from "./test_d_table"; -export { TestDRow }; import TestERow from "./test_e_table"; -export { TestERow }; import TestFRow from "./test_f_table"; -export { TestFRow }; -// Import and reexport all types -import Baz from "./baz_type"; -export { Baz }; -import Foobar from "./foobar_type"; -export { Foobar }; -import HasSpecialStuff from "./has_special_stuff_type"; -export { HasSpecialStuff }; -import Person from "./person_type"; -export { Person }; -import PkMultiIdentity from "./pk_multi_identity_type"; -export { PkMultiIdentity }; -import Player from "./player_type"; -export { Player }; -import Point from "./point_type"; -export { Point }; -import PrivateTable from "./private_table_type"; -export { PrivateTable }; -import RemoveTable from "./remove_table_type"; -export { RemoveTable }; -import RepeatingTestArg from "./repeating_test_arg_type"; -export { RepeatingTestArg }; -import TestA from "./test_a_type"; -export { TestA }; -import TestB from "./test_b_type"; -export { TestB }; -import TestD from "./test_d_type"; -export { TestD }; -import TestE from "./test_e_type"; -export { TestE }; -import TestFoobar from "./test_foobar_type"; -export { TestFoobar }; -import NamespaceTestC from "./namespace_test_c_type"; -export { NamespaceTestC }; -import NamespaceTestF from "./namespace_test_f_type"; -export { NamespaceTestF }; +/** Type-only namespace exports for generated type groups. */ +export type * as Rows from "./rows"; +export type * as Reducers from "./reducers"; +export type * as Procedures from "./procedures"; +export type * as Types from "./types"; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( @@ -904,6 +841,30 @@ export default __t.object("PrivateTable", { }); +''' +"procedures.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all procedure arg schemas +import * as GetMySchemaViaHttpProcedure from "./get_my_schema_via_http_procedure"; +import * as ReturnValueProcedure from "./return_value_procedure"; +import * as SleepOneSecondProcedure from "./sleep_one_second_procedure"; +import * as WithTxProcedure from "./with_tx_procedure"; + +export type GetMySchemaViaHttpArgs = __Infer; +export type GetMySchemaViaHttpResult = __Infer; +export type ReturnValueArgs = __Infer; +export type ReturnValueResult = __Infer; +export type SleepOneSecondArgs = __Infer; +export type SleepOneSecondResult = __Infer; +export type WithTxArgs = __Infer; +export type WithTxResult = __Infer; + ''' "query_private_reducer.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE @@ -919,6 +880,46 @@ import { } from "spacetimedb"; export default {}; +''' +"reducers.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all reducer arg schemas +import AddReducer from "./add_reducer"; +import AddPlayerReducer from "./add_player_reducer"; +import AddPrivateReducer from "./add_private_reducer"; +import AssertCallerIdentityIsModuleIdentityReducer from "./assert_caller_identity_is_module_identity_reducer"; +import ClientConnectedReducer from "./client_connected_reducer"; +import DeletePlayerReducer from "./delete_player_reducer"; +import DeletePlayersByNameReducer from "./delete_players_by_name_reducer"; +import ListOverAgeReducer from "./list_over_age_reducer"; +import LogModuleIdentityReducer from "./log_module_identity_reducer"; +import QueryPrivateReducer from "./query_private_reducer"; +import RepeatingTestReducer from "./repeating_test_reducer"; +import SayHelloReducer from "./say_hello_reducer"; +import TestReducer from "./test_reducer"; +import TestBtreeIndexArgsReducer from "./test_btree_index_args_reducer"; + +export type AddArgs = __Infer; +export type AddPlayerArgs = __Infer; +export type AddPrivateArgs = __Infer; +export type AssertCallerIdentityIsModuleIdentityArgs = __Infer; +export type ClientConnectedArgs = __Infer; +export type DeletePlayerArgs = __Infer; +export type DeletePlayersByNameArgs = __Infer; +export type ListOverAgeArgs = __Infer; +export type LogModuleIdentityArgs = __Infer; +export type QueryPrivateArgs = __Infer; +export type RepeatingTestArgs = __Infer; +export type SayHelloArgs = __Infer; +export type TestArgs = __Infer; +export type TestBtreeIndexArgsArgs = __Infer; + ''' "remove_table_type.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE @@ -1019,6 +1020,46 @@ export const params = { foo: __t.u64(), }; export const returnType = Baz''' +"rows.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all table schema definitions +import HasSpecialStuffRow from "./has_special_stuff_table"; +import LoggedOutPlayerRow from "./logged_out_player_table"; +import MyPlayerRow from "./my_player_table"; +import PersonRow from "./person_table"; +import PkMultiIdentityRow from "./pk_multi_identity_table"; +import PlayerRow from "./player_table"; +import PointsRow from "./points_table"; +import PrivateTableRow from "./private_table_table"; +import RepeatingTestArgRow from "./repeating_test_arg_table"; +import TableToRemoveRow from "./table_to_remove_table"; +import TestARow from "./test_a_table"; +import TestDRow from "./test_d_table"; +import TestERow from "./test_e_table"; +import TestFRow from "./test_f_table"; + +export type HasSpecialStuff = __Infer; +export type LoggedOutPlayer = __Infer; +export type Person = __Infer; +export type PkMultiIdentity = __Infer; +export type Player = __Infer; +export type Points = __Infer; +export type PrivateTable = __Infer; +export type RepeatingTestArg = __Infer; +export type TableToRemove = __Infer; +export type TestA = __Infer; +export type TestD = __Infer; +export type TestE = __Infer; +export type TestF = __Infer; +export type MyPlayer = __Infer; + +''' "say_hello_reducer.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. @@ -1299,6 +1340,52 @@ export default { return NamespaceTestF; }, }; +''' +"types.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all non-reducer types +import Baz from "./baz_type"; +import Foobar from "./foobar_type"; +import HasSpecialStuff from "./has_special_stuff_type"; +import Person from "./person_type"; +import PkMultiIdentity from "./pk_multi_identity_type"; +import Player from "./player_type"; +import Point from "./point_type"; +import PrivateTable from "./private_table_type"; +import RemoveTable from "./remove_table_type"; +import RepeatingTestArg from "./repeating_test_arg_type"; +import TestA from "./test_a_type"; +import TestB from "./test_b_type"; +import TestD from "./test_d_type"; +import TestE from "./test_e_type"; +import TestFoobar from "./test_foobar_type"; +import NamespaceTestC from "./namespace_test_c_type"; +import NamespaceTestF from "./namespace_test_f_type"; + +export type Baz = __Infer; +export type Foobar = __Infer; +export type HasSpecialStuff = __Infer; +export type Person = __Infer; +export type PkMultiIdentity = __Infer; +export type Player = __Infer; +export type Point = __Infer; +export type PrivateTable = __Infer; +export type RemoveTable = __Infer; +export type RepeatingTestArg = __Infer; +export type TestA = __Infer; +export type TestB = __Infer; +export type TestD = __Infer; +export type TestE = __Infer; +export type TestFoobar = __Infer; +export type NamespaceTestC = __Infer; +export type NamespaceTestF = __Infer; + ''' "with_tx_procedure.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE From c0fc9956fa45c153a8637cdec172de2f57b1e3a8 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Tue, 27 Jan 2026 10:03:58 -0800 Subject: [PATCH 08/12] fmt --- crates/codegen/src/typescript.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/codegen/src/typescript.rs b/crates/codegen/src/typescript.rs index 7ad1d920870..c873c0d867d 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -241,10 +241,7 @@ impl Lang for TypeScript { } writeln!(out); - writeln!( - out, - "/** Type-only namespace exports for generated type groups. */" - ); + writeln!(out, "/** Type-only namespace exports for generated type groups. */"); writeln!(out, "export type * as Rows from \"./rows\";"); writeln!(out, "export type * as Reducers from \"./reducers\";"); writeln!(out, "export type * as Procedures from \"./procedures\";"); From dbe8a0dff3bfe776501978389e28b0fdfaf53eed Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Wed, 28 Jan 2026 09:58:04 -0800 Subject: [PATCH 09/12] fix some tests --- .../tests/db_connection.test.ts | 95 ++++++++++--------- crates/bindings-typescript/tests/utils.ts | 13 ++- 2 files changed, 56 insertions(+), 52 deletions(-) diff --git a/crates/bindings-typescript/tests/db_connection.test.ts b/crates/bindings-typescript/tests/db_connection.test.ts index 5589e2a1202..1f380349653 100644 --- a/crates/bindings-typescript/tests/db_connection.test.ts +++ b/crates/bindings-typescript/tests/db_connection.test.ts @@ -1,14 +1,15 @@ -import { - CreatePlayerReducer, - DbConnection, - Player, - User, -} from '../test-app/src/module_bindings'; +import { DbConnection, type Rows } from '../test-app/src/module_bindings'; +import CreatePlayerReducer from '../test-app/src/module_bindings/create_player_reducer'; +import Player from '../test-app/src/module_bindings/player_table'; +import User from '../test-app/src/module_bindings/user_table'; import { beforeEach, describe, expect, test } from 'vitest'; import { ConnectionId, type Infer } from '../src'; import { Timestamp } from '../src'; import { TimeDuration } from '../src'; -import * as ws from '../src/sdk/client_api'; +import CompressableQueryUpdate from '../src/sdk/client_api/compressable_query_update_type'; +import RowSizeHint from '../src/sdk/client_api/row_size_hint_type'; +import ServerMessage from '../src/sdk/client_api/server_message_type'; +import UpdateStatus from '../src/sdk/client_api/update_status_type'; import type { ReducerEvent } from '../src/sdk/db_connection_impl'; import { Identity } from '../src'; import WebsocketTestAdapter from '../src/sdk/websocket_test_adapter'; @@ -109,7 +110,7 @@ describe('DbConnection', () => { await client['wsPromise']; wsAdapter.acceptConnection(); - const tokenMessage = ws.ServerMessage.IdentityToken({ + const tokenMessage = ServerMessage.IdentityToken({ identity: anIdentity, token: 'a-token', connectionId: ConnectionId.random(), @@ -138,7 +139,7 @@ describe('DbConnection', () => { ]); wsAdapter.acceptConnection(); - const tokenMessage = ws.ServerMessage.IdentityToken({ + const tokenMessage = ServerMessage.IdentityToken({ identity: anIdentity, token: 'a-token', connectionId: ConnectionId.random(), @@ -152,7 +153,7 @@ describe('DbConnection', () => { args: Infer; }> | undefined; - player: Infer; + player: Rows.Player; }[] = []; const insert1Promise = new Deferred(); @@ -190,8 +191,8 @@ describe('DbConnection', () => { } ); - const subscriptionMessage: Infer = - ws.ServerMessage.InitialSubscription({ + const subscriptionMessage: Infer = + ServerMessage.InitialSubscription({ databaseUpdate: { tables: [ { @@ -199,13 +200,13 @@ describe('DbConnection', () => { tableName: 'player', numRows: BigInt(1), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array(), }, inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: encodePlayer({ id: 1, userId: anIdentity, @@ -235,21 +236,21 @@ describe('DbConnection', () => { expect(inserts[0].player.id).toEqual(1); expect(inserts[0].reducerEvent).toEqual(undefined); - const transactionUpdate = ws.ServerMessage.TransactionUpdate({ - status: ws.UpdateStatus.Committed({ + const transactionUpdate = ServerMessage.TransactionUpdate({ + status: UpdateStatus.Committed({ tables: [ { tableId: 35, tableName: 'player', numRows: BigInt(2), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array(), }, inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: encodePlayer({ id: 2, userId: anIdentity, @@ -321,22 +322,22 @@ describe('DbConnection', () => { updatePromise.resolve(); }); - const transactionUpdate = ws.ServerMessage.TransactionUpdate({ - status: ws.UpdateStatus.Committed({ + const transactionUpdate = ServerMessage.TransactionUpdate({ + status: UpdateStatus.Committed({ tables: [ { tableId: 35, tableName: 'player', numRows: BigInt(1), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array(), }, // FIXME: this test is evil: an initial subscription can never contain deletes or updates. inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([ ...encodePlayer({ id: 1, @@ -397,22 +398,22 @@ describe('DbConnection', () => { updatePromise.resolve(); }); - const transactionUpdate = ws.ServerMessage.TransactionUpdate({ - status: ws.UpdateStatus.Committed({ + const transactionUpdate = ServerMessage.TransactionUpdate({ + status: UpdateStatus.Committed({ tables: [ { tableId: 35, tableName: 'player', numRows: BigInt(1), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array(), }, // FIXME: this test is evil: an initial subscription can never contain deletes or updates. inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([ ...encodePlayer({ id: 2, @@ -458,7 +459,7 @@ describe('DbConnection', () => { await client['wsPromise']; wsAdapter.acceptConnection(); - const tokenMessage = ws.ServerMessage.IdentityToken({ + const tokenMessage = ServerMessage.IdentityToken({ identity: Identity.fromString( '0000000000000000000000000000000000000000000000000000000000000069' ), @@ -473,11 +474,11 @@ describe('DbConnection', () => { '41db74c20cdda916dd2637e5a11b9f31eb1672249aa7172f7e22b4043a6a9008' ); - const initialUser: Infer = { + const initialUser: Rows.User = { identity: userIdentity, username: 'originalName', }; - const updatedUser: Infer = { + const updatedUser: Rows.User = { identity: userIdentity, username: 'newName', }; @@ -498,7 +499,7 @@ describe('DbConnection', () => { update1Promise.resolve(); }); - const subscriptionMessage = ws.ServerMessage.InitialSubscription({ + const subscriptionMessage = ServerMessage.InitialSubscription({ databaseUpdate: { tables: [ { @@ -507,13 +508,13 @@ describe('DbConnection', () => { numRows: BigInt(1), updates: [ // pgoldman 2024-06-25: This is weird, `InitialSubscription`s aren't supposed to contain deletes or updates. - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([]), }, inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([...encodeUser(initialUser)]), }, }), @@ -531,22 +532,22 @@ describe('DbConnection', () => { await initialInsertPromise.promise; console.log('First insert is done'); - const transactionUpdate = ws.ServerMessage.TransactionUpdate({ - status: ws.UpdateStatus.Committed({ + const transactionUpdate = ServerMessage.TransactionUpdate({ + status: UpdateStatus.Committed({ tables: [ { tableId: 35, tableName: 'user', numRows: BigInt(1), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([...encodeUser(initialUser)]), }, // FIXME: this test is evil: an initial subscription can never contain deletes or updates. inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([...encodeUser(updatedUser)]), }, }), @@ -594,22 +595,22 @@ describe('DbConnection', () => { username: 'sally', }; const binary = [...encodeUser(user1)].concat([...encodeUser(user2)]); - const transactionUpdate = ws.ServerMessage.TransactionUpdate({ - status: ws.UpdateStatus.Committed({ + const transactionUpdate = ServerMessage.TransactionUpdate({ + status: UpdateStatus.Committed({ tables: [ { tableId: 35, tableName: 'user', numRows: BigInt(1), updates: [ - ws.CompressableQueryUpdate.Uncompressed({ + CompressableQueryUpdate.Uncompressed({ deletes: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array([]), }, // FIXME: this test is evil: an initial subscription can never contain deletes or updates. inserts: { - sizeHint: ws.RowSizeHint.FixedSize(0), // not used + sizeHint: RowSizeHint.FixedSize(0), // not used rowsData: new Uint8Array(binary), }, }), diff --git a/crates/bindings-typescript/tests/utils.ts b/crates/bindings-typescript/tests/utils.ts index 4ed63d7e2ed..e00ece3a001 100644 --- a/crates/bindings-typescript/tests/utils.ts +++ b/crates/bindings-typescript/tests/utils.ts @@ -2,7 +2,10 @@ import { AlgebraicType } from '../src/lib/algebraic_type'; import BinaryWriter from '../src/lib/binary_writer'; import { Identity } from '../src/lib/identity'; import type { Infer } from '../src/lib/type_builders'; -import { Player, Point, User } from '../test-app/src/module_bindings'; +import { type Rows } from '../test-app/src/module_bindings'; +import PlayerRow from '../test-app/src/module_bindings/player_table'; +import UserRow from '../test-app/src/module_bindings/user_table'; +import Point from '../test-app/src/module_bindings/point_type'; export const anIdentity = Identity.fromString( '0000000000000000000000000000000000000000000000000000000000000069' @@ -14,15 +17,15 @@ export const sallyIdentity = Identity.fromString( '000000000000000000000000000000000000000000000000000000000006a111' ); -export function encodePlayer(value: Infer): Uint8Array { +export function encodePlayer(value: Rows.Player): Uint8Array { const writer = new BinaryWriter(1024); - Player.serialize(writer, value); + PlayerRow.serialize(writer, value); return writer.getBuffer(); } -export function encodeUser(value: Infer): Uint8Array { +export function encodeUser(value: Rows.User): Uint8Array { const writer = new BinaryWriter(1024); - User.serialize(writer, value); + UserRow.serialize(writer, value); return writer.getBuffer(); } From a41319d12f7ee4290ffc3ca054955762486e1fb6 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Fri, 30 Jan 2026 08:49:50 -0800 Subject: [PATCH 10/12] Import from Types instead of Rows --- templates/chat-react-ts/src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/chat-react-ts/src/App.tsx b/templates/chat-react-ts/src/App.tsx index e7025f3712c..2fa203a449a 100644 --- a/templates/chat-react-ts/src/App.tsx +++ b/templates/chat-react-ts/src/App.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import './App.css'; -import { tables, reducers, Rows } from './module_bindings'; +import { tables, reducers, type Types } from './module_bindings'; import { useSpacetimeDB, useTable, @@ -20,7 +20,7 @@ export type PrettyMessage = { function App() { const [newName, setNewName] = useState(''); const [settingName, setSettingName] = useState(false); - const [systemMessages, setSystemMessages] = useState([] as Rows.Message[]); + const [systemMessages, setSystemMessages] = useState([] as Types.Message[]); const [newMessage, setNewMessage] = useState(''); const { identity, isActive: connected } = useSpacetimeDB(); From 1e22ef27d147e64668582eb64d420ff326c7c333 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Fri, 30 Jan 2026 10:46:22 -0800 Subject: [PATCH 11/12] Put ts generated type files in a subdirectory --- .../src/lib/autogen/types.ts | 101 --------- .../src/sdk/client_api/index.ts | 6 +- .../src/sdk/client_api/types/index.ts | 77 +++++++ .../client_api/types/procedures.ts} | 4 +- .../client_api/types}/reducers.ts | 2 +- .../test-app/src/module_bindings/index.ts | 6 +- .../test-app/src/module_bindings/rows.ts | 15 -- .../src/module_bindings/types/index.ts | 17 ++ .../src/module_bindings/types}/procedures.ts | 2 +- .../src/module_bindings/types/reducers.ts | 11 + .../tests/db_connection.test.ts | 8 +- crates/bindings-typescript/tests/utils.ts | 5 +- crates/cli/src/subcommands/generate.rs | 2 + .../examples/regen-typescript-moduledef.rs | 4 + crates/codegen/src/typescript.rs | 58 +---- .../codegen__codegen_typescript.snap | 210 +++++++----------- .../basic-ts/src/module_bindings/index.ts | 6 +- .../src/module_bindings/types/index.ts} | 6 +- .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ templates/chat-react-ts/src/App.tsx | 3 +- .../src/module_bindings/index.ts | 6 +- .../{rows.ts => types/index.ts} | 10 +- .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ .../react-ts/src/module_bindings/index.ts | 6 +- .../src/module_bindings/types/index.ts} | 6 +- .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ templates/vue-ts/src/module_bindings/index.ts | 6 +- .../src/module_bindings/types/index.ts} | 6 +- .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ tools/replace-spacetimedb/src/lib.rs | 14 +- 34 files changed, 347 insertions(+), 350 deletions(-) delete mode 100644 crates/bindings-typescript/src/lib/autogen/types.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/types/index.ts rename crates/bindings-typescript/src/{lib/autogen/rows.ts => sdk/client_api/types/procedures.ts} (64%) rename crates/bindings-typescript/src/{lib/autogen => sdk/client_api/types}/reducers.ts (76%) delete mode 100644 crates/bindings-typescript/test-app/src/module_bindings/rows.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types/index.ts rename crates/bindings-typescript/{src/lib/autogen => test-app/src/module_bindings/types}/procedures.ts (77%) create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts rename templates/{react-ts/src/module_bindings/rows.ts => basic-ts/src/module_bindings/types/index.ts} (65%) create mode 100644 templates/basic-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/basic-ts/src/module_bindings/types/reducers.ts rename templates/chat-react-ts/src/module_bindings/{rows.ts => types/index.ts} (53%) create mode 100644 templates/chat-react-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/chat-react-ts/src/module_bindings/types/reducers.ts rename templates/{vue-ts/src/module_bindings/rows.ts => react-ts/src/module_bindings/types/index.ts} (65%) create mode 100644 templates/react-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/react-ts/src/module_bindings/types/reducers.ts rename templates/{basic-ts/src/module_bindings/rows.ts => vue-ts/src/module_bindings/types/index.ts} (65%) create mode 100644 templates/vue-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/vue-ts/src/module_bindings/types/reducers.ts diff --git a/crates/bindings-typescript/src/lib/autogen/types.ts b/crates/bindings-typescript/src/lib/autogen/types.ts deleted file mode 100644 index 673f4a67b2b..00000000000 --- a/crates/bindings-typescript/src/lib/autogen/types.ts +++ /dev/null @@ -1,101 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from '../../lib/type_builders'; - -// Import all non-reducer types -import AlgebraicType from './algebraic_type_type'; -import HttpHeaderPair from './http_header_pair_type'; -import HttpHeaders from './http_headers_type'; -import HttpMethod from './http_method_type'; -import HttpRequest from './http_request_type'; -import HttpResponse from './http_response_type'; -import HttpVersion from './http_version_type'; -import IndexType from './index_type_type'; -import Lifecycle from './lifecycle_type'; -import MiscModuleExport from './misc_module_export_type'; -import ProductType from './product_type_type'; -import ProductTypeElement from './product_type_element_type'; -import RawColumnDefV8 from './raw_column_def_v_8_type'; -import RawColumnDefaultValueV9 from './raw_column_default_value_v_9_type'; -import RawConstraintDataV9 from './raw_constraint_data_v_9_type'; -import RawConstraintDefV8 from './raw_constraint_def_v_8_type'; -import RawConstraintDefV9 from './raw_constraint_def_v_9_type'; -import RawIndexAlgorithm from './raw_index_algorithm_type'; -import RawIndexDefV8 from './raw_index_def_v_8_type'; -import RawIndexDefV9 from './raw_index_def_v_9_type'; -import RawMiscModuleExportV9 from './raw_misc_module_export_v_9_type'; -import RawModuleDef from './raw_module_def_type'; -import RawModuleDefV8 from './raw_module_def_v_8_type'; -import RawModuleDefV9 from './raw_module_def_v_9_type'; -import RawProcedureDefV9 from './raw_procedure_def_v_9_type'; -import RawReducerDefV9 from './raw_reducer_def_v_9_type'; -import RawRowLevelSecurityDefV9 from './raw_row_level_security_def_v_9_type'; -import RawScheduleDefV9 from './raw_schedule_def_v_9_type'; -import RawScopedTypeNameV9 from './raw_scoped_type_name_v_9_type'; -import RawSequenceDefV8 from './raw_sequence_def_v_8_type'; -import RawSequenceDefV9 from './raw_sequence_def_v_9_type'; -import RawTableDefV8 from './raw_table_def_v_8_type'; -import RawTableDefV9 from './raw_table_def_v_9_type'; -import RawTypeDefV9 from './raw_type_def_v_9_type'; -import RawUniqueConstraintDataV9 from './raw_unique_constraint_data_v_9_type'; -import RawViewDefV9 from './raw_view_def_v_9_type'; -import ReducerDef from './reducer_def_type'; -import SumType from './sum_type_type'; -import SumTypeVariant from './sum_type_variant_type'; -import TableAccess from './table_access_type'; -import TableDesc from './table_desc_type'; -import TableType from './table_type_type'; -import TypeAlias from './type_alias_type'; -import Typespace from './typespace_type'; -import ViewResultHeader from './view_result_header_type'; - -export type AlgebraicType = __Infer; -export type HttpHeaderPair = __Infer; -export type HttpHeaders = __Infer; -export type HttpMethod = __Infer; -export type HttpRequest = __Infer; -export type HttpResponse = __Infer; -export type HttpVersion = __Infer; -export type IndexType = __Infer; -export type Lifecycle = __Infer; -export type MiscModuleExport = __Infer; -export type ProductType = __Infer; -export type ProductTypeElement = __Infer; -export type RawColumnDefV8 = __Infer; -export type RawColumnDefaultValueV9 = __Infer; -export type RawConstraintDataV9 = __Infer; -export type RawConstraintDefV8 = __Infer; -export type RawConstraintDefV9 = __Infer; -export type RawIndexAlgorithm = __Infer; -export type RawIndexDefV8 = __Infer; -export type RawIndexDefV9 = __Infer; -export type RawMiscModuleExportV9 = __Infer; -export type RawModuleDef = __Infer; -export type RawModuleDefV8 = __Infer; -export type RawModuleDefV9 = __Infer; -export type RawProcedureDefV9 = __Infer; -export type RawReducerDefV9 = __Infer; -export type RawRowLevelSecurityDefV9 = __Infer; -export type RawScheduleDefV9 = __Infer; -export type RawScopedTypeNameV9 = __Infer; -export type RawSequenceDefV8 = __Infer; -export type RawSequenceDefV9 = __Infer; -export type RawTableDefV8 = __Infer; -export type RawTableDefV9 = __Infer; -export type RawTypeDefV9 = __Infer; -export type RawUniqueConstraintDataV9 = __Infer< - typeof RawUniqueConstraintDataV9 ->; -export type RawViewDefV9 = __Infer; -export type ReducerDef = __Infer; -export type SumType = __Infer; -export type SumTypeVariant = __Infer; -export type TableAccess = __Infer; -export type TableDesc = __Infer; -export type TableType = __Infer; -export type TypeAlias = __Infer; -export type Typespace = __Infer; -export type ViewResultHeader = __Infer; diff --git a/crates/bindings-typescript/src/sdk/client_api/index.ts b/crates/bindings-typescript/src/sdk/client_api/index.ts index 77a0cd4f89b..c437f74400e 100644 --- a/crates/bindings-typescript/src/sdk/client_api/index.ts +++ b/crates/bindings-typescript/src/sdk/client_api/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -40,10 +40,6 @@ import { // Import all table schema definitions /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema(); diff --git a/crates/bindings-typescript/src/sdk/client_api/types/index.ts b/crates/bindings-typescript/src/sdk/client_api/types/index.ts new file mode 100644 index 00000000000..e031a8e7a51 --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/types/index.ts @@ -0,0 +1,77 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../lib/type_builders'; + +// Import all non-reducer types +import BsatnRowList from '../bsatn_row_list_type'; +import CallProcedure from '../call_procedure_type'; +import CallReducer from '../call_reducer_type'; +import ClientMessage from '../client_message_type'; +import CompressableQueryUpdate from '../compressable_query_update_type'; +import DatabaseUpdate from '../database_update_type'; +import EnergyQuanta from '../energy_quanta_type'; +import IdentityToken from '../identity_token_type'; +import InitialSubscription from '../initial_subscription_type'; +import OneOffQuery from '../one_off_query_type'; +import OneOffQueryResponse from '../one_off_query_response_type'; +import OneOffTable from '../one_off_table_type'; +import ProcedureResult from '../procedure_result_type'; +import ProcedureStatus from '../procedure_status_type'; +import QueryId from '../query_id_type'; +import QueryUpdate from '../query_update_type'; +import ReducerCallInfo from '../reducer_call_info_type'; +import RowSizeHint from '../row_size_hint_type'; +import ServerMessage from '../server_message_type'; +import Subscribe from '../subscribe_type'; +import SubscribeApplied from '../subscribe_applied_type'; +import SubscribeMulti from '../subscribe_multi_type'; +import SubscribeMultiApplied from '../subscribe_multi_applied_type'; +import SubscribeRows from '../subscribe_rows_type'; +import SubscribeSingle from '../subscribe_single_type'; +import SubscriptionError from '../subscription_error_type'; +import TableUpdate from '../table_update_type'; +import TransactionUpdate from '../transaction_update_type'; +import TransactionUpdateLight from '../transaction_update_light_type'; +import Unsubscribe from '../unsubscribe_type'; +import UnsubscribeApplied from '../unsubscribe_applied_type'; +import UnsubscribeMulti from '../unsubscribe_multi_type'; +import UnsubscribeMultiApplied from '../unsubscribe_multi_applied_type'; +import UpdateStatus from '../update_status_type'; + +export type BsatnRowList = __Infer; +export type CallProcedure = __Infer; +export type CallReducer = __Infer; +export type ClientMessage = __Infer; +export type CompressableQueryUpdate = __Infer; +export type DatabaseUpdate = __Infer; +export type EnergyQuanta = __Infer; +export type IdentityToken = __Infer; +export type InitialSubscription = __Infer; +export type OneOffQuery = __Infer; +export type OneOffQueryResponse = __Infer; +export type OneOffTable = __Infer; +export type ProcedureResult = __Infer; +export type ProcedureStatus = __Infer; +export type QueryId = __Infer; +export type QueryUpdate = __Infer; +export type ReducerCallInfo = __Infer; +export type RowSizeHint = __Infer; +export type ServerMessage = __Infer; +export type Subscribe = __Infer; +export type SubscribeApplied = __Infer; +export type SubscribeMulti = __Infer; +export type SubscribeMultiApplied = __Infer; +export type SubscribeRows = __Infer; +export type SubscribeSingle = __Infer; +export type SubscriptionError = __Infer; +export type TableUpdate = __Infer; +export type TransactionUpdate = __Infer; +export type TransactionUpdateLight = __Infer; +export type Unsubscribe = __Infer; +export type UnsubscribeApplied = __Infer; +export type UnsubscribeMulti = __Infer; +export type UnsubscribeMultiApplied = __Infer; +export type UpdateStatus = __Infer; diff --git a/crates/bindings-typescript/src/lib/autogen/rows.ts b/crates/bindings-typescript/src/sdk/client_api/types/procedures.ts similarity index 64% rename from crates/bindings-typescript/src/lib/autogen/rows.ts rename to crates/bindings-typescript/src/sdk/client_api/types/procedures.ts index 693f6effe27..8726cd8baf0 100644 --- a/crates/bindings-typescript/src/lib/autogen/rows.ts +++ b/crates/bindings-typescript/src/sdk/client_api/types/procedures.ts @@ -3,6 +3,6 @@ /* eslint-disable */ /* tslint:disable */ -import { type Infer as __Infer } from '../../lib/type_builders'; +import { type Infer as __Infer } from '../../../lib/type_builders'; -// Import all table schema definitions +// Import all procedure arg schemas diff --git a/crates/bindings-typescript/src/lib/autogen/reducers.ts b/crates/bindings-typescript/src/sdk/client_api/types/reducers.ts similarity index 76% rename from crates/bindings-typescript/src/lib/autogen/reducers.ts rename to crates/bindings-typescript/src/sdk/client_api/types/reducers.ts index 69fa905ce4f..183aff65fa7 100644 --- a/crates/bindings-typescript/src/lib/autogen/reducers.ts +++ b/crates/bindings-typescript/src/sdk/client_api/types/reducers.ts @@ -3,6 +3,6 @@ /* eslint-disable */ /* tslint:disable */ -import { type Infer as __Infer } from '../../lib/type_builders'; +import { type Infer as __Infer } from '../../../lib/type_builders'; // Import all reducer arg schemas diff --git a/crates/bindings-typescript/test-app/src/module_bindings/index.ts b/crates/bindings-typescript/test-app/src/module_bindings/index.ts index 41be99e7b37..8ccbd096d65 100644 --- a/crates/bindings-typescript/test-app/src/module_bindings/index.ts +++ b/crates/bindings-typescript/test-app/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit b5a7b37660b6cb7ce327f409456329e1142466e6). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -44,10 +44,6 @@ import UnindexedPlayerRow from './unindexed_player_table'; import UserRow from './user_table'; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/crates/bindings-typescript/test-app/src/module_bindings/rows.ts b/crates/bindings-typescript/test-app/src/module_bindings/rows.ts deleted file mode 100644 index 904ba9a3f12..00000000000 --- a/crates/bindings-typescript/test-app/src/module_bindings/rows.ts +++ /dev/null @@ -1,15 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from '../../../src/index'; - -// Import all table schema definitions -import PlayerRow from './player_table'; -import UnindexedPlayerRow from './unindexed_player_table'; -import UserRow from './user_table'; - -export type Player = __Infer; -export type UnindexedPlayer = __Infer; -export type User = __Infer; diff --git a/crates/bindings-typescript/test-app/src/module_bindings/types/index.ts b/crates/bindings-typescript/test-app/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..c16e6c5e5b3 --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/types/index.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../../src/index'; + +// Import all non-reducer types +import Player from '../player_type'; +import Point from '../point_type'; +import UnindexedPlayer from '../unindexed_player_type'; +import User from '../user_type'; + +export type Player = __Infer; +export type Point = __Infer; +export type UnindexedPlayer = __Infer; +export type User = __Infer; diff --git a/crates/bindings-typescript/src/lib/autogen/procedures.ts b/crates/bindings-typescript/test-app/src/module_bindings/types/procedures.ts similarity index 77% rename from crates/bindings-typescript/src/lib/autogen/procedures.ts rename to crates/bindings-typescript/test-app/src/module_bindings/types/procedures.ts index 6625edb1b2e..a39363a990e 100644 --- a/crates/bindings-typescript/src/lib/autogen/procedures.ts +++ b/crates/bindings-typescript/test-app/src/module_bindings/types/procedures.ts @@ -3,6 +3,6 @@ /* eslint-disable */ /* tslint:disable */ -import { type Infer as __Infer } from '../../lib/type_builders'; +import { type Infer as __Infer } from '../../../../src/index'; // Import all procedure arg schemas diff --git a/crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts b/crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..086e5bc5a2d --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../../src/index'; + +// Import all reducer arg schemas +import CreatePlayerReducer from '../create_player_reducer'; + +export type CreatePlayerArgs = __Infer; diff --git a/crates/bindings-typescript/tests/db_connection.test.ts b/crates/bindings-typescript/tests/db_connection.test.ts index 1f380349653..897e228e40b 100644 --- a/crates/bindings-typescript/tests/db_connection.test.ts +++ b/crates/bindings-typescript/tests/db_connection.test.ts @@ -1,4 +1,4 @@ -import { DbConnection, type Rows } from '../test-app/src/module_bindings'; +import { DbConnection } from '../test-app/src/module_bindings'; import CreatePlayerReducer from '../test-app/src/module_bindings/create_player_reducer'; import Player from '../test-app/src/module_bindings/player_table'; import User from '../test-app/src/module_bindings/user_table'; @@ -153,7 +153,7 @@ describe('DbConnection', () => { args: Infer; }> | undefined; - player: Rows.Player; + player: Infer; }[] = []; const insert1Promise = new Deferred(); @@ -474,11 +474,11 @@ describe('DbConnection', () => { '41db74c20cdda916dd2637e5a11b9f31eb1672249aa7172f7e22b4043a6a9008' ); - const initialUser: Rows.User = { + const initialUser: Infer = { identity: userIdentity, username: 'originalName', }; - const updatedUser: Rows.User = { + const updatedUser: Infer = { identity: userIdentity, username: 'newName', }; diff --git a/crates/bindings-typescript/tests/utils.ts b/crates/bindings-typescript/tests/utils.ts index e00ece3a001..a0164fdbd35 100644 --- a/crates/bindings-typescript/tests/utils.ts +++ b/crates/bindings-typescript/tests/utils.ts @@ -2,7 +2,6 @@ import { AlgebraicType } from '../src/lib/algebraic_type'; import BinaryWriter from '../src/lib/binary_writer'; import { Identity } from '../src/lib/identity'; import type { Infer } from '../src/lib/type_builders'; -import { type Rows } from '../test-app/src/module_bindings'; import PlayerRow from '../test-app/src/module_bindings/player_table'; import UserRow from '../test-app/src/module_bindings/user_table'; import Point from '../test-app/src/module_bindings/point_type'; @@ -17,13 +16,13 @@ export const sallyIdentity = Identity.fromString( '000000000000000000000000000000000000000000000000000000000006a111' ); -export function encodePlayer(value: Rows.Player): Uint8Array { +export function encodePlayer(value: Infer): Uint8Array { const writer = new BinaryWriter(1024); PlayerRow.serialize(writer, value); return writer.getBuffer(); } -export function encodeUser(value: Rows.User): Uint8Array { +export function encodeUser(value: Infer): Uint8Array { const writer = new BinaryWriter(1024); UserRow.serialize(writer, value); return writer.getBuffer(); diff --git a/crates/cli/src/subcommands/generate.rs b/crates/cli/src/subcommands/generate.rs index 4e6fb5ec124..48e70c25aaf 100644 --- a/crates/cli/src/subcommands/generate.rs +++ b/crates/cli/src/subcommands/generate.rs @@ -197,10 +197,12 @@ pub async fn exec_ex( let fname = Path::new(&filename); // If a generator asks for a file in a subdirectory, create the subdirectory first. if let Some(parent) = fname.parent().filter(|p| !p.as_os_str().is_empty()) { + println!("Creating directory {}", out_dir.join(parent).display()); fs::create_dir_all(out_dir.join(parent))?; } let path = out_dir.join(fname); if !path.exists() || fs::read_to_string(&path)? != code { + println!("Writing file {}", path.display()); fs::write(&path, code)?; } paths.insert(path); diff --git a/crates/codegen/examples/regen-typescript-moduledef.rs b/crates/codegen/examples/regen-typescript-moduledef.rs index 47ecb692863..3c7e511da0d 100644 --- a/crates/codegen/examples/regen-typescript-moduledef.rs +++ b/crates/codegen/examples/regen-typescript-moduledef.rs @@ -45,6 +45,10 @@ fn main() -> anyhow::Result<()> { if filename == "index.ts" { return Ok(()); } + // We don't need the convenience types. + if filename.starts_with("types/") { + return Ok(()); + } let code = regex_replace!(&code, r#"from "spacetimedb";"#, r#"from "../../lib/type_builders";"#); // Elide types which are related to client-side only things diff --git a/crates/codegen/src/typescript.rs b/crates/codegen/src/typescript.rs index c873c0d867d..8f0e07303c7 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -242,10 +242,6 @@ impl Lang for TypeScript { writeln!(out); writeln!(out, "/** Type-only namespace exports for generated type groups. */"); - writeln!(out, "export type * as Rows from \"./rows\";"); - writeln!(out, "export type * as Reducers from \"./reducers\";"); - writeln!(out, "export type * as Procedures from \"./procedures\";"); - writeln!(out, "export type * as Types from \"./types\";"); writeln!(out); writeln!(out, "/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */"); @@ -449,51 +445,11 @@ impl Lang for TypeScript { code: output.into_inner(), }; - let rows_file = generate_rows_file(module); let reducers_file = generate_reducers_file(module); let procedures_file = generate_procedures_file(module); let types_file = generate_types_file(module); - vec![index_file, rows_file, reducers_file, procedures_file, types_file] - } -} - -fn generate_rows_file(module: &ModuleDef) -> OutputFile { - let mut output = CodeIndenter::new(String::new(), INDENT); - let out = &mut output; - - print_auto_generated_file_comment(out); - print_lint_suppression(out); - writeln!(out, "import {{ type Infer as __Infer }} from \"spacetimedb\";"); - - writeln!(out); - writeln!(out, "// Import all table schema definitions"); - for (table_name, _) in iter_table_names_and_types(module) { - let table_module_name = table_module_name(table_name); - let table_name_pascalcase = table_name.deref().to_case(Case::Pascal); - writeln!(out, "import {table_name_pascalcase}Row from \"./{table_module_name}\";"); - } - - writeln!(out); - for table in iter_tables(module) { - let table_name_pascalcase = table.name.deref().to_case(Case::Pascal); - writeln!( - out, - "export type {table_name_pascalcase} = __Infer;" - ); - } - for view in iter_views(module) { - let view_name_pascalcase = view.name.deref().to_case(Case::Pascal); - writeln!( - out, - "export type {view_name_pascalcase} = __Infer;" - ); - } - out.newline(); - - OutputFile { - filename: "rows.ts".to_string(), - code: output.into_inner(), + vec![index_file, reducers_file, procedures_file, types_file] } } @@ -511,7 +467,7 @@ fn generate_reducers_file(module: &ModuleDef) -> OutputFile { let reducer_name = &reducer.name; let reducer_module_name = reducer_module_name(reducer_name); let args_type = reducer_args_type_name(&reducer.name); - writeln!(out, "import {args_type} from \"./{reducer_module_name}\";"); + writeln!(out, "import {args_type} from \"../{reducer_module_name}\";"); } writeln!(out); @@ -526,7 +482,7 @@ fn generate_reducers_file(module: &ModuleDef) -> OutputFile { out.newline(); OutputFile { - filename: "reducers.ts".to_string(), + filename: "types/reducers.ts".to_string(), code: output.into_inner(), } } @@ -545,7 +501,7 @@ fn generate_procedures_file(module: &ModuleDef) -> OutputFile { let procedure_name = &procedure.name; let procedure_module_name = procedure_module_name(procedure_name); let args_type = procedure_args_type_name(&procedure.name); - writeln!(out, "import * as {args_type} from \"./{procedure_module_name}\";"); + writeln!(out, "import * as {args_type} from \"../{procedure_module_name}\";"); } writeln!(out); @@ -564,7 +520,7 @@ fn generate_procedures_file(module: &ModuleDef) -> OutputFile { out.newline(); OutputFile { - filename: "procedures.ts".to_string(), + filename: "types/procedures.ts".to_string(), code: output.into_inner(), } } @@ -590,7 +546,7 @@ fn generate_types_file(module: &ModuleDef) -> OutputFile { continue; } let type_module_name = type_module_name(&ty.name); - writeln!(out, "import {type_name} from \"./{type_module_name}\";"); + writeln!(out, "import {type_name} from \"../{type_module_name}\";"); } writeln!(out); @@ -604,7 +560,7 @@ fn generate_types_file(module: &ModuleDef) -> OutputFile { out.newline(); OutputFile { - filename: "types.ts".to_string(), + filename: "types/index.ts".to_string(), code: output.into_inner(), } } diff --git a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap index 7a8828d893e..514228c2e03 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -292,10 +292,8 @@ import TestERow from "./test_e_table"; import TestFRow from "./test_f_table"; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from "./rows"; -export type * as Reducers from "./reducers"; -export type * as Procedures from "./procedures"; -export type * as Types from "./types"; +export type * as Reducers from "./types/reducers"; +export type * as Procedures from "./types/procedures"; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( @@ -841,30 +839,6 @@ export default __t.object("PrivateTable", { }); -''' -"procedures.ts" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all procedure arg schemas -import * as GetMySchemaViaHttpProcedure from "./get_my_schema_via_http_procedure"; -import * as ReturnValueProcedure from "./return_value_procedure"; -import * as SleepOneSecondProcedure from "./sleep_one_second_procedure"; -import * as WithTxProcedure from "./with_tx_procedure"; - -export type GetMySchemaViaHttpArgs = __Infer; -export type GetMySchemaViaHttpResult = __Infer; -export type ReturnValueArgs = __Infer; -export type ReturnValueResult = __Infer; -export type SleepOneSecondArgs = __Infer; -export type SleepOneSecondResult = __Infer; -export type WithTxArgs = __Infer; -export type WithTxResult = __Infer; - ''' "query_private_reducer.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE @@ -880,46 +854,6 @@ import { } from "spacetimedb"; export default {}; -''' -"reducers.ts" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all reducer arg schemas -import AddReducer from "./add_reducer"; -import AddPlayerReducer from "./add_player_reducer"; -import AddPrivateReducer from "./add_private_reducer"; -import AssertCallerIdentityIsModuleIdentityReducer from "./assert_caller_identity_is_module_identity_reducer"; -import ClientConnectedReducer from "./client_connected_reducer"; -import DeletePlayerReducer from "./delete_player_reducer"; -import DeletePlayersByNameReducer from "./delete_players_by_name_reducer"; -import ListOverAgeReducer from "./list_over_age_reducer"; -import LogModuleIdentityReducer from "./log_module_identity_reducer"; -import QueryPrivateReducer from "./query_private_reducer"; -import RepeatingTestReducer from "./repeating_test_reducer"; -import SayHelloReducer from "./say_hello_reducer"; -import TestReducer from "./test_reducer"; -import TestBtreeIndexArgsReducer from "./test_btree_index_args_reducer"; - -export type AddArgs = __Infer; -export type AddPlayerArgs = __Infer; -export type AddPrivateArgs = __Infer; -export type AssertCallerIdentityIsModuleIdentityArgs = __Infer; -export type ClientConnectedArgs = __Infer; -export type DeletePlayerArgs = __Infer; -export type DeletePlayersByNameArgs = __Infer; -export type ListOverAgeArgs = __Infer; -export type LogModuleIdentityArgs = __Infer; -export type QueryPrivateArgs = __Infer; -export type RepeatingTestArgs = __Infer; -export type SayHelloArgs = __Infer; -export type TestArgs = __Infer; -export type TestBtreeIndexArgsArgs = __Infer; - ''' "remove_table_type.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE @@ -1020,46 +954,6 @@ export const params = { foo: __t.u64(), }; export const returnType = Baz''' -"rows.ts" = ''' -// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE -// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. - -/* eslint-disable */ -/* tslint:disable */ -import { type Infer as __Infer } from "spacetimedb"; - -// Import all table schema definitions -import HasSpecialStuffRow from "./has_special_stuff_table"; -import LoggedOutPlayerRow from "./logged_out_player_table"; -import MyPlayerRow from "./my_player_table"; -import PersonRow from "./person_table"; -import PkMultiIdentityRow from "./pk_multi_identity_table"; -import PlayerRow from "./player_table"; -import PointsRow from "./points_table"; -import PrivateTableRow from "./private_table_table"; -import RepeatingTestArgRow from "./repeating_test_arg_table"; -import TableToRemoveRow from "./table_to_remove_table"; -import TestARow from "./test_a_table"; -import TestDRow from "./test_d_table"; -import TestERow from "./test_e_table"; -import TestFRow from "./test_f_table"; - -export type HasSpecialStuff = __Infer; -export type LoggedOutPlayer = __Infer; -export type Person = __Infer; -export type PkMultiIdentity = __Infer; -export type Player = __Infer; -export type Points = __Infer; -export type PrivateTable = __Infer; -export type RepeatingTestArg = __Infer; -export type TableToRemove = __Infer; -export type TestA = __Infer; -export type TestD = __Infer; -export type TestE = __Infer; -export type TestF = __Infer; -export type MyPlayer = __Infer; - -''' "say_hello_reducer.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. @@ -1341,7 +1235,7 @@ export default { }, }; ''' -"types.ts" = ''' +"types/index.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. @@ -1350,23 +1244,23 @@ export default { import { type Infer as __Infer } from "spacetimedb"; // Import all non-reducer types -import Baz from "./baz_type"; -import Foobar from "./foobar_type"; -import HasSpecialStuff from "./has_special_stuff_type"; -import Person from "./person_type"; -import PkMultiIdentity from "./pk_multi_identity_type"; -import Player from "./player_type"; -import Point from "./point_type"; -import PrivateTable from "./private_table_type"; -import RemoveTable from "./remove_table_type"; -import RepeatingTestArg from "./repeating_test_arg_type"; -import TestA from "./test_a_type"; -import TestB from "./test_b_type"; -import TestD from "./test_d_type"; -import TestE from "./test_e_type"; -import TestFoobar from "./test_foobar_type"; -import NamespaceTestC from "./namespace_test_c_type"; -import NamespaceTestF from "./namespace_test_f_type"; +import Baz from "../baz_type"; +import Foobar from "../foobar_type"; +import HasSpecialStuff from "../has_special_stuff_type"; +import Person from "../person_type"; +import PkMultiIdentity from "../pk_multi_identity_type"; +import Player from "../player_type"; +import Point from "../point_type"; +import PrivateTable from "../private_table_type"; +import RemoveTable from "../remove_table_type"; +import RepeatingTestArg from "../repeating_test_arg_type"; +import TestA from "../test_a_type"; +import TestB from "../test_b_type"; +import TestD from "../test_d_type"; +import TestE from "../test_e_type"; +import TestFoobar from "../test_foobar_type"; +import NamespaceTestC from "../namespace_test_c_type"; +import NamespaceTestF from "../namespace_test_f_type"; export type Baz = __Infer; export type Foobar = __Infer; @@ -1386,6 +1280,70 @@ export type TestFoobar = __Infer; export type NamespaceTestC = __Infer; export type NamespaceTestF = __Infer; +''' +"types/procedures.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all procedure arg schemas +import * as GetMySchemaViaHttpProcedure from "../get_my_schema_via_http_procedure"; +import * as ReturnValueProcedure from "../return_value_procedure"; +import * as SleepOneSecondProcedure from "../sleep_one_second_procedure"; +import * as WithTxProcedure from "../with_tx_procedure"; + +export type GetMySchemaViaHttpArgs = __Infer; +export type GetMySchemaViaHttpResult = __Infer; +export type ReturnValueArgs = __Infer; +export type ReturnValueResult = __Infer; +export type SleepOneSecondArgs = __Infer; +export type SleepOneSecondResult = __Infer; +export type WithTxArgs = __Infer; +export type WithTxResult = __Infer; + +''' +"types/reducers.ts" = ''' +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from "spacetimedb"; + +// Import all reducer arg schemas +import AddReducer from "../add_reducer"; +import AddPlayerReducer from "../add_player_reducer"; +import AddPrivateReducer from "../add_private_reducer"; +import AssertCallerIdentityIsModuleIdentityReducer from "../assert_caller_identity_is_module_identity_reducer"; +import ClientConnectedReducer from "../client_connected_reducer"; +import DeletePlayerReducer from "../delete_player_reducer"; +import DeletePlayersByNameReducer from "../delete_players_by_name_reducer"; +import ListOverAgeReducer from "../list_over_age_reducer"; +import LogModuleIdentityReducer from "../log_module_identity_reducer"; +import QueryPrivateReducer from "../query_private_reducer"; +import RepeatingTestReducer from "../repeating_test_reducer"; +import SayHelloReducer from "../say_hello_reducer"; +import TestReducer from "../test_reducer"; +import TestBtreeIndexArgsReducer from "../test_btree_index_args_reducer"; + +export type AddArgs = __Infer; +export type AddPlayerArgs = __Infer; +export type AddPrivateArgs = __Infer; +export type AssertCallerIdentityIsModuleIdentityArgs = __Infer; +export type ClientConnectedArgs = __Infer; +export type DeletePlayerArgs = __Infer; +export type DeletePlayersByNameArgs = __Infer; +export type ListOverAgeArgs = __Infer; +export type LogModuleIdentityArgs = __Infer; +export type QueryPrivateArgs = __Infer; +export type RepeatingTestArgs = __Infer; +export type SayHelloArgs = __Infer; +export type TestArgs = __Infer; +export type TestBtreeIndexArgsArgs = __Infer; + ''' "with_tx_procedure.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE diff --git a/templates/basic-ts/src/module_bindings/index.ts b/templates/basic-ts/src/module_bindings/index.ts index dea9b5470e0..003de49a6cb 100644 --- a/templates/basic-ts/src/module_bindings/index.ts +++ b/templates/basic-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -43,10 +43,6 @@ import SayHelloReducer from './say_hello_reducer'; import PersonRow from './person_table'; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/react-ts/src/module_bindings/rows.ts b/templates/basic-ts/src/module_bindings/types/index.ts similarity index 65% rename from templates/react-ts/src/module_bindings/rows.ts rename to templates/basic-ts/src/module_bindings/types/index.ts index 8fad581583d..06296d8bf15 100644 --- a/templates/react-ts/src/module_bindings/rows.ts +++ b/templates/basic-ts/src/module_bindings/types/index.ts @@ -5,7 +5,7 @@ /* tslint:disable */ import { type Infer as __Infer } from 'spacetimedb'; -// Import all table schema definitions -import PersonRow from './person_table'; +// Import all non-reducer types +import Person from '../person_type'; -export type Person = __Infer; +export type Person = __Infer; diff --git a/templates/basic-ts/src/module_bindings/types/procedures.ts b/templates/basic-ts/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/basic-ts/src/module_bindings/types/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/basic-ts/src/module_bindings/types/reducers.ts b/templates/basic-ts/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..9f40b85850c --- /dev/null +++ b/templates/basic-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/chat-react-ts/src/App.tsx b/templates/chat-react-ts/src/App.tsx index 2fa203a449a..0b91e48ecd1 100644 --- a/templates/chat-react-ts/src/App.tsx +++ b/templates/chat-react-ts/src/App.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import './App.css'; -import { tables, reducers, type Types } from './module_bindings'; +import { tables, reducers } from './module_bindings'; +import type * as Types from './module_bindings/types'; import { useSpacetimeDB, useTable, diff --git a/templates/chat-react-ts/src/module_bindings/index.ts b/templates/chat-react-ts/src/module_bindings/index.ts index be96c277b6e..90c95e8c179 100644 --- a/templates/chat-react-ts/src/module_bindings/index.ts +++ b/templates/chat-react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -44,10 +44,6 @@ import MessageRow from './message_table'; import UserRow from './user_table'; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/chat-react-ts/src/module_bindings/rows.ts b/templates/chat-react-ts/src/module_bindings/types/index.ts similarity index 53% rename from templates/chat-react-ts/src/module_bindings/rows.ts rename to templates/chat-react-ts/src/module_bindings/types/index.ts index 4ca40647ec6..b1c4f33f07a 100644 --- a/templates/chat-react-ts/src/module_bindings/rows.ts +++ b/templates/chat-react-ts/src/module_bindings/types/index.ts @@ -5,9 +5,9 @@ /* tslint:disable */ import { type Infer as __Infer } from 'spacetimedb'; -// Import all table schema definitions -import MessageRow from './message_table'; -import UserRow from './user_table'; +// Import all non-reducer types +import Message from '../message_type'; +import User from '../user_type'; -export type Message = __Infer; -export type User = __Infer; +export type Message = __Infer; +export type User = __Infer; diff --git a/templates/chat-react-ts/src/module_bindings/types/procedures.ts b/templates/chat-react-ts/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/chat-react-ts/src/module_bindings/types/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/chat-react-ts/src/module_bindings/types/reducers.ts b/templates/chat-react-ts/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..8f6f02eb73d --- /dev/null +++ b/templates/chat-react-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import SetNameReducer from '../set_name_reducer'; +import SendMessageReducer from '../send_message_reducer'; +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; + +export type SetNameArgs = __Infer; +export type SendMessageArgs = __Infer; +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; diff --git a/templates/react-ts/src/module_bindings/index.ts b/templates/react-ts/src/module_bindings/index.ts index dea9b5470e0..003de49a6cb 100644 --- a/templates/react-ts/src/module_bindings/index.ts +++ b/templates/react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -43,10 +43,6 @@ import SayHelloReducer from './say_hello_reducer'; import PersonRow from './person_table'; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/vue-ts/src/module_bindings/rows.ts b/templates/react-ts/src/module_bindings/types/index.ts similarity index 65% rename from templates/vue-ts/src/module_bindings/rows.ts rename to templates/react-ts/src/module_bindings/types/index.ts index 8fad581583d..06296d8bf15 100644 --- a/templates/vue-ts/src/module_bindings/rows.ts +++ b/templates/react-ts/src/module_bindings/types/index.ts @@ -5,7 +5,7 @@ /* tslint:disable */ import { type Infer as __Infer } from 'spacetimedb'; -// Import all table schema definitions -import PersonRow from './person_table'; +// Import all non-reducer types +import Person from '../person_type'; -export type Person = __Infer; +export type Person = __Infer; diff --git a/templates/react-ts/src/module_bindings/types/procedures.ts b/templates/react-ts/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/react-ts/src/module_bindings/types/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/react-ts/src/module_bindings/types/reducers.ts b/templates/react-ts/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..9f40b85850c --- /dev/null +++ b/templates/react-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/vue-ts/src/module_bindings/index.ts b/templates/vue-ts/src/module_bindings/index.ts index dea9b5470e0..003de49a6cb 100644 --- a/templates/vue-ts/src/module_bindings/index.ts +++ b/templates/vue-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit c06bf8b59468ce56b6731c98302ad4fe4b7cc931). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* eslint-disable */ /* tslint:disable */ @@ -43,10 +43,6 @@ import SayHelloReducer from './say_hello_reducer'; import PersonRow from './person_table'; /** Type-only namespace exports for generated type groups. */ -export type * as Rows from './rows'; -export type * as Reducers from './reducers'; -export type * as Procedures from './procedures'; -export type * as Types from './types'; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema( diff --git a/templates/basic-ts/src/module_bindings/rows.ts b/templates/vue-ts/src/module_bindings/types/index.ts similarity index 65% rename from templates/basic-ts/src/module_bindings/rows.ts rename to templates/vue-ts/src/module_bindings/types/index.ts index 8fad581583d..06296d8bf15 100644 --- a/templates/basic-ts/src/module_bindings/rows.ts +++ b/templates/vue-ts/src/module_bindings/types/index.ts @@ -5,7 +5,7 @@ /* tslint:disable */ import { type Infer as __Infer } from 'spacetimedb'; -// Import all table schema definitions -import PersonRow from './person_table'; +// Import all non-reducer types +import Person from '../person_type'; -export type Person = __Infer; +export type Person = __Infer; diff --git a/templates/vue-ts/src/module_bindings/types/procedures.ts b/templates/vue-ts/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/vue-ts/src/module_bindings/types/procedures.ts @@ -0,0 +1,8 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all procedure arg schemas diff --git a/templates/vue-ts/src/module_bindings/types/reducers.ts b/templates/vue-ts/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..9f40b85850c --- /dev/null +++ b/templates/vue-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/tools/replace-spacetimedb/src/lib.rs b/tools/replace-spacetimedb/src/lib.rs index ff91bda9cfd..8037af72e64 100644 --- a/tools/replace-spacetimedb/src/lib.rs +++ b/tools/replace-spacetimedb/src/lib.rs @@ -94,13 +94,25 @@ pub fn replace_in_tree( continue; } + // Determine depth relative to root, in case we need to add ../ + let rel_parent = path + .parent() + .and_then(|p| p.strip_prefix(&root).ok()) + .unwrap_or_else(|| Path::new("")); + let depth = rel_parent.components().count(); + // Decide which replacement to use for this file - let is_index_ts = path.file_name().and_then(|n| n.to_str()) == Some("index.ts"); + let is_index_ts = depth == 0 && path.file_name().and_then(|n| n.to_str()) == Some("index.ts"); let repl = if is_index_ts { replacement_index_ts } else { replacement_other_ts }; + let repl = if depth > 0 { + format!("{}{}", "../".repeat(depth), repl) + } else { + repl.to_string() + }; let bytes = match fs::read(path) { Ok(b) => b, From a71f0f51727952e773070354117191efe2f8dc28 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Fri, 30 Jan 2026 13:25:10 -0800 Subject: [PATCH 12/12] Update snap --- crates/codegen/tests/snapshots/codegen__codegen_typescript.snap | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap index 514228c2e03..db4ead76caa 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -292,8 +292,6 @@ import TestERow from "./test_e_table"; import TestFRow from "./test_f_table"; /** Type-only namespace exports for generated type groups. */ -export type * as Reducers from "./types/reducers"; -export type * as Procedures from "./types/procedures"; /** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */ const tablesSchema = __schema(