From a71a24e539214a8e2dd4b9416ee6201ef57232f8 Mon Sep 17 00:00:00 2001 From: Jeffrey Dallatezza Date: Sat, 7 Feb 2026 11:34:50 -0800 Subject: [PATCH 1/3] Reorganize types generated for typescript clients (#4127) This changes generated types in ts client bindings. We currently generate a few different types of types: reducer args, procedure args, rows, and user defined types. To avoid potential conflicts between these types (for example, if a user defined a type called `FooRow`, and also had a tabled named `foo`, we would end up with two types named `FooRow`), this puts each set of types in a different file and namespace. We also stopped exporting the `xxxRow` types, because there is always another type generated for those. We now have a `types` directory, which has an `index.ts` with user defined types, along with `reducers.ts` and `procedures.ts` for the types generated for reducer/procedure parameters. ``` import type * as Types from './module_bindings/types'; var currentMessages: Types.Message[] = []; ``` or ``` import { type Message } from './module_bindings/types'; var currentMessages: Message[] = []; ``` This has a couple other changes: - For procedure and reducer types, this adds a suffix of `Args`, since we may want types for the return values in the future. - For all of the types, instead of exposing the schema object, we are now giving the typescript type (e.g. `export type Message = __Infer;`). I couldn't think of a reason for users to want the schema object, so this should save users from needing to do all of the `Infer` boilerplate. This is a breaking change for v2. 2. This only changes typescript, and it should generally make thing easier to use. - [ ] - [ ] --- .../lib/autogen/function_visibility_type.ts | 19 ++ .../raw_column_default_value_v_10_type.ts | 16 ++ .../autogen/raw_constraint_def_v_10_type.ts | 19 ++ .../lib/autogen/raw_index_def_v_10_type.ts | 20 ++ .../raw_life_cycle_reducer_def_v_10_type.ts | 19 ++ .../src/lib/autogen/raw_module_def_type.ts | 4 + .../raw_module_def_v_10_section_type.ts | 53 ++++++ .../lib/autogen/raw_module_def_v_10_type.ts | 18 ++ .../autogen/raw_procedure_def_v_10_type.ts | 27 +++ .../lib/autogen/raw_reducer_def_v_10_type.ts | 30 +++ .../lib/autogen/raw_schedule_def_v_10_type.ts | 18 ++ .../autogen/raw_scoped_type_name_v_10_type.ts | 16 ++ .../lib/autogen/raw_sequence_def_v_10_type.ts | 20 ++ .../lib/autogen/raw_table_def_v_10_type.ts | 41 ++++ .../src/lib/autogen/raw_type_def_v_10_type.ts | 20 ++ .../src/lib/autogen/raw_view_def_v_10_type.ts | 26 +++ .../src/sdk/client_api/index.ts | 86 +-------- .../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 ++++++++ .../src/sdk/client_api/types/index.ts | 77 ++++++++ .../src/sdk/client_api/types/procedures.ts | 8 + .../src/sdk/client_api/types/reducers.ts | 8 + .../test-app/src/module_bindings/index.ts | 26 +-- .../src/module_bindings/procedures.ts | 8 + .../test-app/src/module_bindings/reducers.ts | 11 ++ .../test-app/src/module_bindings/types.ts | 17 ++ .../src/module_bindings/types/index.ts | 17 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 11 ++ .../tests/db_connection.test.ts | 89 ++++----- crates/bindings-typescript/tests/utils.ts | 12 +- crates/cli/src/subcommands/generate.rs | 2 + .../examples/regen-typescript-moduledef.rs | 4 + crates/codegen/src/typescript.rs | 143 ++++++++++++-- .../codegen__codegen_typescript.snap | 178 +++++++++++------- package.json | 2 +- .../src/module_bindings/mod.rs | 2 +- .../src/module_bindings/mod.rs | 4 +- .../scheduled_proc_procedure.rs | 46 ----- .../test-client/src/module_bindings/mod.rs | 2 +- .../view-client/src/module_bindings/mod.rs | 2 +- .../basic-ts/src/module_bindings/index.ts | 33 +--- .../src/module_bindings/procedures.ts | 8 + .../basic-ts/src/module_bindings/reducers.ts | 17 ++ .../basic-ts/src/module_bindings/types.ts | 11 ++ .../src/module_bindings/types/index.ts | 11 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ templates/chat-react-ts/src/App.tsx | 9 +- .../src/module_bindings/index.ts | 34 +--- .../src/module_bindings/procedures.ts | 8 + .../src/module_bindings/reducers.ts | 17 ++ .../src/module_bindings/types.ts | 13 ++ .../src/module_bindings/types/index.ts | 13 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ .../react-ts/src/module_bindings/index.ts | 33 +--- .../src/module_bindings/procedures.ts | 8 + .../react-ts/src/module_bindings/reducers.ts | 17 ++ .../react-ts/src/module_bindings/types.ts | 11 ++ .../src/module_bindings/types/index.ts | 11 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ .../svelte-ts/src/module_bindings/index.ts | 39 ++-- .../src/module_bindings/types/index.ts | 11 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ .../src/module_bindings/custom_type_type.ts | 15 ++ templates/vue-ts/src/module_bindings/index.ts | 39 ++-- .../vue-ts/src/module_bindings/procedures.ts | 8 + .../vue-ts/src/module_bindings/reducers.ts | 17 ++ .../src/module_bindings/testtable_type.ts | 18 ++ templates/vue-ts/src/module_bindings/types.ts | 11 ++ .../vue-ts/src/module_bindings/types/index.ts | 11 ++ .../src/module_bindings/types/procedures.ts | 8 + .../src/module_bindings/types/reducers.ts | 17 ++ tools/replace-spacetimedb/src/lib.rs | 14 +- 79 files changed, 1373 insertions(+), 419 deletions(-) create mode 100644 crates/bindings-typescript/src/lib/autogen/function_visibility_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_column_default_value_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_constraint_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_index_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_life_cycle_reducer_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_section_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_procedure_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_reducer_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_schedule_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_scoped_type_name_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_sequence_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_table_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_type_def_v_10_type.ts create mode 100644 crates/bindings-typescript/src/lib/autogen/raw_view_def_v_10_type.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/src/sdk/client_api/types/index.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/types/procedures.ts create mode 100644 crates/bindings-typescript/src/sdk/client_api/types/reducers.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/types.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types/index.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types/procedures.ts create mode 100644 crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts delete mode 100644 sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs 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/types.ts create mode 100644 templates/basic-ts/src/module_bindings/types/index.ts create mode 100644 templates/basic-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/basic-ts/src/module_bindings/types/reducers.ts create mode 100644 templates/chat-react-ts/src/module_bindings/procedures.ts create mode 100644 templates/chat-react-ts/src/module_bindings/reducers.ts create mode 100644 templates/chat-react-ts/src/module_bindings/types.ts create mode 100644 templates/chat-react-ts/src/module_bindings/types/index.ts 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 create mode 100644 templates/react-ts/src/module_bindings/procedures.ts create mode 100644 templates/react-ts/src/module_bindings/reducers.ts create mode 100644 templates/react-ts/src/module_bindings/types.ts create mode 100644 templates/react-ts/src/module_bindings/types/index.ts create mode 100644 templates/react-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/react-ts/src/module_bindings/types/reducers.ts create mode 100644 templates/svelte-ts/src/module_bindings/types/index.ts create mode 100644 templates/svelte-ts/src/module_bindings/types/procedures.ts create mode 100644 templates/svelte-ts/src/module_bindings/types/reducers.ts create mode 100644 templates/vue-ts/src/module_bindings/custom_type_type.ts create mode 100644 templates/vue-ts/src/module_bindings/procedures.ts create mode 100644 templates/vue-ts/src/module_bindings/reducers.ts create mode 100644 templates/vue-ts/src/module_bindings/testtable_type.ts create mode 100644 templates/vue-ts/src/module_bindings/types.ts create mode 100644 templates/vue-ts/src/module_bindings/types/index.ts 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/function_visibility_type.ts b/crates/bindings-typescript/src/lib/autogen/function_visibility_type.ts new file mode 100644 index 00000000000..12a7c77593d --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/function_visibility_type.ts @@ -0,0 +1,19 @@ +// 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 '../../lib/type_builders'; + +// The tagged union or sum type for the algebraic type `FunctionVisibility`. +const FunctionVisibility = __t.enum('FunctionVisibility', { + Private: __t.unit(), + ClientCallable: __t.unit(), +}); + +export default FunctionVisibility; diff --git a/crates/bindings-typescript/src/lib/autogen/raw_column_default_value_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_column_default_value_v_10_type.ts new file mode 100644 index 00000000000..5f37afa4604 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_column_default_value_v_10_type.ts @@ -0,0 +1,16 @@ +// 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 '../../lib/type_builders'; + +export default __t.object('RawColumnDefaultValueV10', { + colId: __t.u16(), + value: __t.byteArray(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_constraint_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_constraint_def_v_10_type.ts new file mode 100644 index 00000000000..76145329659 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_constraint_def_v_10_type.ts @@ -0,0 +1,19 @@ +// 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 '../../lib/type_builders'; +import RawConstraintDataV9 from './raw_constraint_data_v_9_type'; + +export default __t.object('RawConstraintDefV10', { + sourceName: __t.option(__t.string()), + get data() { + return RawConstraintDataV9; + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_index_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_index_def_v_10_type.ts new file mode 100644 index 00000000000..2a1913b7ae4 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_index_def_v_10_type.ts @@ -0,0 +1,20 @@ +// 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 '../../lib/type_builders'; +import RawIndexAlgorithm from './raw_index_algorithm_type'; + +export default __t.object('RawIndexDefV10', { + sourceName: __t.option(__t.string()), + accessorName: __t.option(__t.string()), + get algorithm() { + return RawIndexAlgorithm; + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_life_cycle_reducer_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_life_cycle_reducer_def_v_10_type.ts new file mode 100644 index 00000000000..7ccc26d79a3 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_life_cycle_reducer_def_v_10_type.ts @@ -0,0 +1,19 @@ +// 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 '../../lib/type_builders'; +import Lifecycle from './lifecycle_type'; + +export default __t.object('RawLifeCycleReducerDefV10', { + get lifecycleSpec() { + return Lifecycle; + }, + functionName: __t.string(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_module_def_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_module_def_type.ts index e0f91b646ff..40255921356 100644 --- a/crates/bindings-typescript/src/lib/autogen/raw_module_def_type.ts +++ b/crates/bindings-typescript/src/lib/autogen/raw_module_def_type.ts @@ -11,6 +11,7 @@ import { } from '../../lib/type_builders'; import RawModuleDefV8 from './raw_module_def_v_8_type'; import RawModuleDefV9 from './raw_module_def_v_9_type'; +import RawModuleDefV10 from './raw_module_def_v_10_type'; // The tagged union or sum type for the algebraic type `RawModuleDef`. const RawModuleDef = __t.enum('RawModuleDef', { @@ -20,6 +21,9 @@ const RawModuleDef = __t.enum('RawModuleDef', { get V9() { return RawModuleDefV9; }, + get V10() { + return RawModuleDefV10; + }, }); export default RawModuleDef; diff --git a/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_section_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_section_type.ts new file mode 100644 index 00000000000..dcf579b9fd6 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_section_type.ts @@ -0,0 +1,53 @@ +// 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 '../../lib/type_builders'; +import Typespace from './typespace_type'; +import RawRowLevelSecurityDefV9 from './raw_row_level_security_def_v_9_type'; +import RawTypeDefV10 from './raw_type_def_v_10_type'; +import RawTableDefV10 from './raw_table_def_v_10_type'; +import RawReducerDefV10 from './raw_reducer_def_v_10_type'; +import RawProcedureDefV10 from './raw_procedure_def_v_10_type'; +import RawViewDefV10 from './raw_view_def_v_10_type'; +import RawScheduleDefV10 from './raw_schedule_def_v_10_type'; +import RawLifeCycleReducerDefV10 from './raw_life_cycle_reducer_def_v_10_type'; + +// The tagged union or sum type for the algebraic type `RawModuleDefV10Section`. +const RawModuleDefV10Section = __t.enum('RawModuleDefV10Section', { + get Typespace() { + return Typespace; + }, + get Types() { + return __t.array(RawTypeDefV10); + }, + get Tables() { + return __t.array(RawTableDefV10); + }, + get Reducers() { + return __t.array(RawReducerDefV10); + }, + get Procedures() { + return __t.array(RawProcedureDefV10); + }, + get Views() { + return __t.array(RawViewDefV10); + }, + get Schedules() { + return __t.array(RawScheduleDefV10); + }, + get LifeCycleReducers() { + return __t.array(RawLifeCycleReducerDefV10); + }, + get RowLevelSecurity() { + return __t.array(RawRowLevelSecurityDefV9); + }, +}); + +export default RawModuleDefV10Section; diff --git a/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_type.ts new file mode 100644 index 00000000000..f12b1e66523 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_module_def_v_10_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 '../../lib/type_builders'; +import RawModuleDefV10Section from './raw_module_def_v_10_section_type'; + +export default __t.object('RawModuleDefV10', { + get sections() { + return __t.array(RawModuleDefV10Section); + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_procedure_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_procedure_def_v_10_type.ts new file mode 100644 index 00000000000..1c2b312c126 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_procedure_def_v_10_type.ts @@ -0,0 +1,27 @@ +// 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 '../../lib/type_builders'; +import AlgebraicType from './algebraic_type_type'; +import ProductType from './product_type_type'; +import FunctionVisibility from './function_visibility_type'; + +export default __t.object('RawProcedureDefV10', { + sourceName: __t.string(), + get params() { + return ProductType; + }, + get returnType() { + return AlgebraicType; + }, + get visibility() { + return FunctionVisibility; + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_reducer_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_reducer_def_v_10_type.ts new file mode 100644 index 00000000000..2c40195ebb9 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_reducer_def_v_10_type.ts @@ -0,0 +1,30 @@ +// 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 '../../lib/type_builders'; +import AlgebraicType from './algebraic_type_type'; +import ProductType from './product_type_type'; +import FunctionVisibility from './function_visibility_type'; + +export default __t.object('RawReducerDefV10', { + sourceName: __t.string(), + get params() { + return ProductType; + }, + get visibility() { + return FunctionVisibility; + }, + get okReturnType() { + return AlgebraicType; + }, + get errReturnType() { + return AlgebraicType; + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_schedule_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_schedule_def_v_10_type.ts new file mode 100644 index 00000000000..7ad8b18bad1 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_schedule_def_v_10_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 '../../lib/type_builders'; + +export default __t.object('RawScheduleDefV10', { + sourceName: __t.option(__t.string()), + tableName: __t.string(), + scheduleAtCol: __t.u16(), + functionName: __t.string(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_scoped_type_name_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_scoped_type_name_v_10_type.ts new file mode 100644 index 00000000000..91bf0da5915 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_scoped_type_name_v_10_type.ts @@ -0,0 +1,16 @@ +// 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 '../../lib/type_builders'; + +export default __t.object('RawScopedTypeNameV10', { + scope: __t.array(__t.string()), + sourceName: __t.string(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_sequence_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_sequence_def_v_10_type.ts new file mode 100644 index 00000000000..e5ebe17d853 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_sequence_def_v_10_type.ts @@ -0,0 +1,20 @@ +// 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 '../../lib/type_builders'; + +export default __t.object('RawSequenceDefV10', { + sourceName: __t.option(__t.string()), + column: __t.u16(), + start: __t.option(__t.i128()), + minValue: __t.option(__t.i128()), + maxValue: __t.option(__t.i128()), + increment: __t.i128(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_table_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_table_def_v_10_type.ts new file mode 100644 index 00000000000..47d112d4506 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_table_def_v_10_type.ts @@ -0,0 +1,41 @@ +// 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 '../../lib/type_builders'; +import TableType from './table_type_type'; +import TableAccess from './table_access_type'; +import RawIndexDefV10 from './raw_index_def_v_10_type'; +import RawConstraintDefV10 from './raw_constraint_def_v_10_type'; +import RawSequenceDefV10 from './raw_sequence_def_v_10_type'; +import RawColumnDefaultValueV10 from './raw_column_default_value_v_10_type'; + +export default __t.object('RawTableDefV10', { + sourceName: __t.string(), + productTypeRef: __t.u32(), + primaryKey: __t.array(__t.u16()), + get indexes() { + return __t.array(RawIndexDefV10); + }, + get constraints() { + return __t.array(RawConstraintDefV10); + }, + get sequences() { + return __t.array(RawSequenceDefV10); + }, + get tableType() { + return TableType; + }, + get tableAccess() { + return TableAccess; + }, + get defaultValues() { + return __t.array(RawColumnDefaultValueV10); + }, +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_type_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_type_def_v_10_type.ts new file mode 100644 index 00000000000..e3800eff3d2 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_type_def_v_10_type.ts @@ -0,0 +1,20 @@ +// 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 '../../lib/type_builders'; +import RawScopedTypeNameV10 from './raw_scoped_type_name_v_10_type'; + +export default __t.object('RawTypeDefV10', { + get sourceName() { + return RawScopedTypeNameV10; + }, + ty: __t.u32(), + customOrdering: __t.bool(), +}); diff --git a/crates/bindings-typescript/src/lib/autogen/raw_view_def_v_10_type.ts b/crates/bindings-typescript/src/lib/autogen/raw_view_def_v_10_type.ts new file mode 100644 index 00000000000..755076ed315 --- /dev/null +++ b/crates/bindings-typescript/src/lib/autogen/raw_view_def_v_10_type.ts @@ -0,0 +1,26 @@ +// 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 '../../lib/type_builders'; +import AlgebraicType from './algebraic_type_type'; +import ProductType from './product_type_type'; + +export default __t.object('RawViewDefV10', { + sourceName: __t.string(), + index: __t.u32(), + isPublic: __t.bool(), + isAnonymous: __t.bool(), + get params() { + return ProductType; + }, + get returnType() { + return AlgebraicType; + }, +}); diff --git a/crates/bindings-typescript/src/sdk/client_api/index.ts b/crates/bindings-typescript/src/sdk/client_api/index.ts index 5b7fa1a1f21..0c79a92b5b7 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.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* eslint-disable */ /* tslint:disable */ @@ -33,81 +33,13 @@ 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. */ /** 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(); @@ -121,7 +53,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.3' as const, + cliVersion: '1.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, 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/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/sdk/client_api/types/procedures.ts b/crates/bindings-typescript/src/sdk/client_api/types/procedures.ts new file mode 100644 index 00000000000..8726cd8baf0 --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/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 '../../../lib/type_builders'; + +// Import all procedure arg schemas diff --git a/crates/bindings-typescript/src/sdk/client_api/types/reducers.ts b/crates/bindings-typescript/src/sdk/client_api/types/reducers.ts new file mode 100644 index 00000000000..183aff65fa7 --- /dev/null +++ b/crates/bindings-typescript/src/sdk/client_api/types/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/test-app/src/module_bindings/index.ts b/crates/bindings-typescript/test-app/src/module_bindings/index.ts index 22483e31050..b0c9b471b18 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.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* eslint-disable */ /* tslint:disable */ @@ -33,29 +33,17 @@ 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. */ /** 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( @@ -112,7 +100,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.3' as const, + cliVersion: '1.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, 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/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/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/test-app/src/module_bindings/types/procedures.ts b/crates/bindings-typescript/test-app/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..a39363a990e --- /dev/null +++ b/crates/bindings-typescript/test-app/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 '../../../../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..1d7e61f99ef --- /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 CreatePlayerParams = __Infer; diff --git a/crates/bindings-typescript/tests/db_connection.test.ts b/crates/bindings-typescript/tests/db_connection.test.ts index 5589e2a1202..897e228e40b 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 } 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(), @@ -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' ), @@ -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 afb5f1782c1..67d4e2466f5 100644 --- a/crates/bindings-typescript/tests/utils.ts +++ b/crates/bindings-typescript/tests/utils.ts @@ -1,7 +1,9 @@ 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 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' @@ -13,15 +15,15 @@ export const sallyIdentity = Identity.fromString( '000000000000000000000000000000000000000000000000000000000006a111' ); -export function encodePlayer(value: Infer): Uint8Array { +export function encodePlayer(value: Infer): 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: Infer): Uint8Array { const writer = new BinaryWriter(1024); - User.serialize(writer, value); + 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 e153d756996..3f9cae78e99 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -210,44 +210,39 @@ 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) { + 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); 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); 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. */"); @@ -446,10 +441,128 @@ impl Lang for TypeScript { writeln!(out, "}}"); out.newline(); - vec![OutputFile { + let index_file = OutputFile { filename: "index.ts".to_string(), code: output.into_inner(), - }] + }; + + let reducers_file = generate_reducers_file(module); + let procedures_file = generate_procedures_file(module); + let types_file = generate_types_file(module); + + vec![index_file, reducers_file, procedures_file, types_file] + } +} + +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}Params = __Infer;" + ); + } + out.newline(); + + OutputFile { + filename: "types/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}Args = __Infer;" + ); + writeln!( + out, + "export type {procedure_name_pascalcase}Result = __Infer;" + ); + } + out.newline(); + + OutputFile { + filename: "types/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/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 d3df905c700..825a94717f9 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -239,107 +239,43 @@ 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 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 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. */ /** 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( @@ -1258,6 +1194,112 @@ export default { return NamespaceTestF; }, }; +''' +"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. + +/* 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; + +''' +"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 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 SayHelloReducer from "../say_hello_reducer"; +import TestReducer from "../test_reducer"; +import TestBtreeIndexArgsReducer from "../test_btree_index_args_reducer"; + +export type AddParams = __Infer; +export type AddPlayerParams = __Infer; +export type AddPrivateParams = __Infer; +export type AssertCallerIdentityIsModuleIdentityParams = __Infer; +export type DeletePlayerParams = __Infer; +export type DeletePlayersByNameParams = __Infer; +export type ListOverAgeParams = __Infer; +export type LogModuleIdentityParams = __Infer; +export type QueryPrivateParams = __Infer; +export type SayHelloParams = __Infer; +export type TestParams = __Infer; +export type TestBtreeIndexArgsParams = __Infer; + ''' "with_tx_procedure.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE diff --git a/package.json b/package.json index 3c8eb23d14c..91bf60e0c4b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "type": "module", "scripts": { - "run-all": "pnpm -F ./crates/bindings-typescript -F ./crates/bindings-typescript/examples/quickstart-chat -F ./crates/bindings-typescript/examples/quickstart-chat -F ./crates/bindings-typescript/test-app -F ./docs run", + "run-all": "pnpm -r -F ./crates/bindings-typescript -F ./crates/bindings-typescript/examples/quickstart-chat -F ./crates/bindings-typescript/test-app -F ./docs -F \"./templates/**\" run", "format": "pnpm run-all format && prettier eslint.config.js --write", "lint": "pnpm run-all lint && prettier eslint.config.js --check", "build": "pnpm run-all build", diff --git a/sdks/rust/tests/connect_disconnect_client/src/module_bindings/mod.rs b/sdks/rust/tests/connect_disconnect_client/src/module_bindings/mod.rs index 5a54035abec..83378c9d38a 100644 --- a/sdks/rust/tests/connect_disconnect_client/src/module_bindings/mod.rs +++ b/sdks/rust/tests/connect_disconnect_client/src/module_bindings/mod.rs @@ -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 13a0172567170d9b8c87d2aa71de3246c21acb8c). +// This was generated using spacetimedb cli version 1.12.0 (commit 8d9a0a040ece2b8b579b050d8b1dac87d801e98e). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs b/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs index 892f78d2899..5b4eb30668f 100644 --- a/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs +++ b/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs @@ -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 13a0172567170d9b8c87d2aa71de3246c21acb8c). +// This was generated using spacetimedb cli version 1.12.0 (commit 8d9a0a040ece2b8b579b050d8b1dac87d801e98e). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; @@ -23,7 +23,6 @@ pub mod return_primitive_procedure; pub mod return_struct_procedure; pub mod return_struct_type; pub mod schedule_proc_reducer; -pub mod scheduled_proc_procedure; pub mod scheduled_proc_table_table; pub mod scheduled_proc_table_type; pub mod sorted_uuids_insert_procedure; @@ -46,7 +45,6 @@ pub use return_primitive_procedure::return_primitive; pub use return_struct_procedure::return_struct; pub use return_struct_type::ReturnStruct; pub use schedule_proc_reducer::{schedule_proc, set_flags_for_schedule_proc, ScheduleProcCallbackId}; -pub use scheduled_proc_procedure::scheduled_proc; pub use scheduled_proc_table_table::*; pub use scheduled_proc_table_type::ScheduledProcTable; pub use sorted_uuids_insert_procedure::sorted_uuids_insert; diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs deleted file mode 100644 index 124f51162f0..00000000000 --- a/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs +++ /dev/null @@ -1,46 +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. - -#![allow(unused, clippy::all)] -use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; - -use super::scheduled_proc_table_type::ScheduledProcTable; - -#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] -#[sats(crate = __lib)] -struct ScheduledProcArgs { - pub data: ScheduledProcTable, -} - -impl __sdk::InModule for ScheduledProcArgs { - type Module = super::RemoteModule; -} - -#[allow(non_camel_case_types)] -/// Extension trait for access to the procedure `scheduled_proc`. -/// -/// Implemented for [`super::RemoteProcedures`]. -pub trait scheduled_proc { - fn scheduled_proc(&self, data: ScheduledProcTable) { - self.scheduled_proc_then(data, |_, _| {}); - } - - fn scheduled_proc_then( - &self, - data: ScheduledProcTable, - - __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, - ); -} - -impl scheduled_proc for super::RemoteProcedures { - fn scheduled_proc_then( - &self, - data: ScheduledProcTable, - - __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, - ) { - self.imp - .invoke_procedure_with_callback::<_, ()>("scheduled_proc", ScheduledProcArgs { data }, __callback); - } -} diff --git a/sdks/rust/tests/test-client/src/module_bindings/mod.rs b/sdks/rust/tests/test-client/src/module_bindings/mod.rs index 88c57803d23..1c4c56f6c5d 100644 --- a/sdks/rust/tests/test-client/src/module_bindings/mod.rs +++ b/sdks/rust/tests/test-client/src/module_bindings/mod.rs @@ -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 13a0172567170d9b8c87d2aa71de3246c21acb8c). +// This was generated using spacetimedb cli version 1.12.0 (commit 8d9a0a040ece2b8b579b050d8b1dac87d801e98e). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; diff --git a/sdks/rust/tests/view-client/src/module_bindings/mod.rs b/sdks/rust/tests/view-client/src/module_bindings/mod.rs index 40ff3f092bf..e5c447d1554 100644 --- a/sdks/rust/tests/view-client/src/module_bindings/mod.rs +++ b/sdks/rust/tests/view-client/src/module_bindings/mod.rs @@ -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 13a0172567170d9b8c87d2aa71de3246c21acb8c). +// This was generated using spacetimedb cli version 1.12.0 (commit 8d9a0a040ece2b8b579b050d8b1dac87d801e98e). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; diff --git a/templates/basic-ts/src/module_bindings/index.ts b/templates/basic-ts/src/module_bindings/index.ts index 23ea2b9deb3..563fde09843 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 f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* eslint-disable */ /* tslint:disable */ @@ -33,35 +33,16 @@ 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. */ /** 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( @@ -87,7 +68,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.3' as const, + cliVersion: '1.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, 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/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; diff --git a/templates/basic-ts/src/module_bindings/types/index.ts b/templates/basic-ts/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..06296d8bf15 --- /dev/null +++ b/templates/basic-ts/src/module_bindings/types/index.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-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..de9884fd999 --- /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 OnConnectParams = __Infer; +export type OnDisconnectParams = __Infer; +export type AddParams = __Infer; +export type SayHelloParams = __Infer; diff --git a/templates/chat-react-ts/src/App.tsx b/templates/chat-react-ts/src/App.tsx index 1da2737cd82..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, Message } from './module_bindings'; +import { tables, reducers } from './module_bindings'; +import type * as Types from './module_bindings/types'; import { useSpacetimeDB, useTable, @@ -8,7 +9,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 +21,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 Types.Message[]); const [newMessage, setNewMessage] = useState(''); const { identity, isActive: connected } = useSpacetimeDB(); diff --git a/templates/chat-react-ts/src/module_bindings/index.ts b/templates/chat-react-ts/src/module_bindings/index.ts index 8d00c314360..4eb2bfaf57b 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.12.0 (commit 4a6228fec73c9fefa0ee32ceebf06c91933453ab). +// This was generated using spacetimedb cli version 1.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* eslint-disable */ /* tslint:disable */ @@ -33,39 +33,17 @@ 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. */ /** 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/procedures.ts b/templates/chat-react-ts/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/chat-react-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/chat-react-ts/src/module_bindings/reducers.ts b/templates/chat-react-ts/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..f6189b8f46b --- /dev/null +++ b/templates/chat-react-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 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/chat-react-ts/src/module_bindings/types.ts b/templates/chat-react-ts/src/module_bindings/types.ts new file mode 100644 index 00000000000..50bbdd264ea --- /dev/null +++ b/templates/chat-react-ts/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; diff --git a/templates/chat-react-ts/src/module_bindings/types/index.ts b/templates/chat-react-ts/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..b1c4f33f07a --- /dev/null +++ b/templates/chat-react-ts/src/module_bindings/types/index.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; 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..e0d53afb748 --- /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 SetNameParams = __Infer; +export type SendMessageParams = __Infer; +export type OnConnectParams = __Infer; +export type OnDisconnectParams = __Infer; diff --git a/templates/react-ts/src/module_bindings/index.ts b/templates/react-ts/src/module_bindings/index.ts index 23ea2b9deb3..563fde09843 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 f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* eslint-disable */ /* tslint:disable */ @@ -33,35 +33,16 @@ 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. */ /** 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( @@ -87,7 +68,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.3' as const, + cliVersion: '1.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, diff --git a/templates/react-ts/src/module_bindings/procedures.ts b/templates/react-ts/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/react-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/react-ts/src/module_bindings/reducers.ts b/templates/react-ts/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..0259dbf4b1a --- /dev/null +++ b/templates/react-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/react-ts/src/module_bindings/types.ts b/templates/react-ts/src/module_bindings/types.ts new file mode 100644 index 00000000000..8f2d578255a --- /dev/null +++ b/templates/react-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; diff --git a/templates/react-ts/src/module_bindings/types/index.ts b/templates/react-ts/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..06296d8bf15 --- /dev/null +++ b/templates/react-ts/src/module_bindings/types/index.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/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..de9884fd999 --- /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 OnConnectParams = __Infer; +export type OnDisconnectParams = __Infer; +export type AddParams = __Infer; +export type SayHelloParams = __Infer; diff --git a/templates/svelte-ts/src/module_bindings/index.ts b/templates/svelte-ts/src/module_bindings/index.ts index d726335a186..563fde09843 100644 --- a/templates/svelte-ts/src/module_bindings/index.ts +++ b/templates/svelte-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 02449737ca3b29e7e39679fccbef541a50f32094). +// This was generated using spacetimedb cli version 1.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* 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,23 @@ 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. */ /** 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 +68,7 @@ const proceduresSchema = __procedures(); /** The remote SpacetimeDB module schema, both runtime and type information. */ const REMOTE_MODULE = { versionInfo: { - cliVersion: '1.11.3' as const, + cliVersion: '1.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, @@ -99,6 +82,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 diff --git a/templates/svelte-ts/src/module_bindings/types/index.ts b/templates/svelte-ts/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..06296d8bf15 --- /dev/null +++ b/templates/svelte-ts/src/module_bindings/types/index.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/svelte-ts/src/module_bindings/types/procedures.ts b/templates/svelte-ts/src/module_bindings/types/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/svelte-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/svelte-ts/src/module_bindings/types/reducers.ts b/templates/svelte-ts/src/module_bindings/types/reducers.ts new file mode 100644 index 00000000000..de9884fd999 --- /dev/null +++ b/templates/svelte-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 OnConnectParams = __Infer; +export type OnDisconnectParams = __Infer; +export type AddParams = __Infer; +export type SayHelloParams = __Infer; diff --git a/templates/vue-ts/src/module_bindings/custom_type_type.ts b/templates/vue-ts/src/module_bindings/custom_type_type.ts new file mode 100644 index 00000000000..1c9dcb38596 --- /dev/null +++ b/templates/vue-ts/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/vue-ts/src/module_bindings/index.ts b/templates/vue-ts/src/module_bindings/index.ts index 3c2919c1917..563fde09843 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.12.0 (commit e2920b5e361495b16bd50e2899024ca680d52e8b). /* 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,23 @@ 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. */ /** 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 +68,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.12.0' as const, }, tables: tablesSchema.schemaType.tables, reducers: reducersSchema.reducersType.reducers, @@ -99,6 +82,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 diff --git a/templates/vue-ts/src/module_bindings/procedures.ts b/templates/vue-ts/src/module_bindings/procedures.ts new file mode 100644 index 00000000000..b2102264f4d --- /dev/null +++ b/templates/vue-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/vue-ts/src/module_bindings/reducers.ts b/templates/vue-ts/src/module_bindings/reducers.ts new file mode 100644 index 00000000000..0259dbf4b1a --- /dev/null +++ b/templates/vue-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/vue-ts/src/module_bindings/testtable_type.ts b/templates/vue-ts/src/module_bindings/testtable_type.ts new file mode 100644 index 00000000000..5d0a364a28b --- /dev/null +++ b/templates/vue-ts/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/vue-ts/src/module_bindings/types.ts b/templates/vue-ts/src/module_bindings/types.ts new file mode 100644 index 00000000000..8f2d578255a --- /dev/null +++ b/templates/vue-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; diff --git a/templates/vue-ts/src/module_bindings/types/index.ts b/templates/vue-ts/src/module_bindings/types/index.ts new file mode 100644 index 00000000000..06296d8bf15 --- /dev/null +++ b/templates/vue-ts/src/module_bindings/types/index.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/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..de9884fd999 --- /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 OnConnectParams = __Infer; +export type OnDisconnectParams = __Infer; +export type AddParams = __Infer; +export type SayHelloParams = __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 e9a44c237d3bfd55f95a979305c439ec8b2a0fe1 Mon Sep 17 00:00:00 2001 From: joshua-spacetime Date: Tue, 10 Feb 2026 15:34:35 -0800 Subject: [PATCH 2/3] Regen procedure test module bindings --- .../src/module_bindings/mod.rs | 4 +- .../scheduled_proc_procedure.rs | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs b/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs index 5b4eb30668f..a739477e2d7 100644 --- a/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs +++ b/sdks/rust/tests/procedure-client/src/module_bindings/mod.rs @@ -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.12.0 (commit 8d9a0a040ece2b8b579b050d8b1dac87d801e98e). +// This was generated using spacetimedb cli version 1.12.0 (commit a71a24e539214a8e2dd4b9416ee6201ef57232f8). #![allow(unused, clippy::all)] use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; @@ -23,6 +23,7 @@ pub mod return_primitive_procedure; pub mod return_struct_procedure; pub mod return_struct_type; pub mod schedule_proc_reducer; +pub mod scheduled_proc_procedure; pub mod scheduled_proc_table_table; pub mod scheduled_proc_table_type; pub mod sorted_uuids_insert_procedure; @@ -45,6 +46,7 @@ pub use return_primitive_procedure::return_primitive; pub use return_struct_procedure::return_struct; pub use return_struct_type::ReturnStruct; pub use schedule_proc_reducer::{schedule_proc, set_flags_for_schedule_proc, ScheduleProcCallbackId}; +pub use scheduled_proc_procedure::scheduled_proc; pub use scheduled_proc_table_table::*; pub use scheduled_proc_table_type::ScheduledProcTable; pub use sorted_uuids_insert_procedure::sorted_uuids_insert; diff --git a/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs new file mode 100644 index 00000000000..124f51162f0 --- /dev/null +++ b/sdks/rust/tests/procedure-client/src/module_bindings/scheduled_proc_procedure.rs @@ -0,0 +1,46 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +#![allow(unused, clippy::all)] +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; + +use super::scheduled_proc_table_type::ScheduledProcTable; + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +struct ScheduledProcArgs { + pub data: ScheduledProcTable, +} + +impl __sdk::InModule for ScheduledProcArgs { + type Module = super::RemoteModule; +} + +#[allow(non_camel_case_types)] +/// Extension trait for access to the procedure `scheduled_proc`. +/// +/// Implemented for [`super::RemoteProcedures`]. +pub trait scheduled_proc { + fn scheduled_proc(&self, data: ScheduledProcTable) { + self.scheduled_proc_then(data, |_, _| {}); + } + + fn scheduled_proc_then( + &self, + data: ScheduledProcTable, + + __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, + ); +} + +impl scheduled_proc for super::RemoteProcedures { + fn scheduled_proc_then( + &self, + data: ScheduledProcTable, + + __callback: impl FnOnce(&super::ProcedureEventContext, Result<(), __sdk::InternalError>) + Send + 'static, + ) { + self.imp + .invoke_procedure_with_callback::<_, ()>("scheduled_proc", ScheduledProcArgs { data }, __callback); + } +} From 347ea05f30e08ceb1b3117a946fd88e0f2bddbd3 Mon Sep 17 00:00:00 2001 From: joshua-spacetime Date: Tue, 10 Feb 2026 20:57:29 -0800 Subject: [PATCH 3/3] empty commit for cla check