diff --git a/crates/bindings-typescript/src/sdk/client_api/index.ts b/crates/bindings-typescript/src/sdk/client_api/index.ts index 5b7fa1a1f21..c437f74400e 100644 --- a/crates/bindings-typescript/src/sdk/client_api/index.ts +++ b/crates/bindings-typescript/src/sdk/client_api/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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(); 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..8ccbd096d65 100644 --- a/crates/bindings-typescript/test-app/src/module_bindings/index.ts +++ b/crates/bindings-typescript/test-app/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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( 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..086e5bc5a2d --- /dev/null +++ b/crates/bindings-typescript/test-app/src/module_bindings/types/reducers.ts @@ -0,0 +1,11 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from '../../../../src/index'; + +// Import all reducer arg schemas +import CreatePlayerReducer from '../create_player_reducer'; + +export type CreatePlayerArgs = __Infer; diff --git a/crates/bindings-typescript/tests/db_connection.test.ts b/crates/bindings-typescript/tests/db_connection.test.ts index 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 4ed63d7e2ed..a0164fdbd35 100644 --- a/crates/bindings-typescript/tests/utils.ts +++ b/crates/bindings-typescript/tests/utils.ts @@ -2,7 +2,9 @@ import { AlgebraicType } from '../src/lib/algebraic_type'; import BinaryWriter from '../src/lib/binary_writer'; import { Identity } from '../src/lib/identity'; import type { Infer } from '../src/lib/type_builders'; -import { Player, Point, User } from '../test-app/src/module_bindings'; +import PlayerRow from '../test-app/src/module_bindings/player_table'; +import UserRow from '../test-app/src/module_bindings/user_table'; +import Point from '../test-app/src/module_bindings/point_type'; export const anIdentity = Identity.fromString( '0000000000000000000000000000000000000000000000000000000000000069' @@ -14,15 +16,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 5059330882a..8f0e07303c7 100644 --- a/crates/codegen/src/typescript.rs +++ b/crates/codegen/src/typescript.rs @@ -209,44 +209,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. */"); @@ -445,10 +440,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}Args = __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 c4fbcde807f..db4ead76caa 100644 --- a/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap +++ b/crates/codegen/tests/snapshots/codegen__codegen_typescript.snap @@ -254,111 +254,44 @@ import { type SubscriptionHandleImpl as __SubscriptionHandleImpl, } from "spacetimedb"; -// Import and reexport all reducer arg types +// Import all reducer arg schemas import AddReducer from "./add_reducer"; -export { AddReducer }; import AddPlayerReducer from "./add_player_reducer"; -export { AddPlayerReducer }; import AddPrivateReducer from "./add_private_reducer"; -export { AddPrivateReducer }; import AssertCallerIdentityIsModuleIdentityReducer from "./assert_caller_identity_is_module_identity_reducer"; -export { AssertCallerIdentityIsModuleIdentityReducer }; -import ClientConnectedReducer from "./client_connected_reducer"; -export { ClientConnectedReducer }; import DeletePlayerReducer from "./delete_player_reducer"; -export { DeletePlayerReducer }; import DeletePlayersByNameReducer from "./delete_players_by_name_reducer"; -export { DeletePlayersByNameReducer }; import ListOverAgeReducer from "./list_over_age_reducer"; -export { ListOverAgeReducer }; import LogModuleIdentityReducer from "./log_module_identity_reducer"; -export { LogModuleIdentityReducer }; import QueryPrivateReducer from "./query_private_reducer"; -export { QueryPrivateReducer }; import RepeatingTestReducer from "./repeating_test_reducer"; -export { RepeatingTestReducer }; import SayHelloReducer from "./say_hello_reducer"; -export { SayHelloReducer }; import TestReducer from "./test_reducer"; -export { TestReducer }; import TestBtreeIndexArgsReducer from "./test_btree_index_args_reducer"; -export { TestBtreeIndexArgsReducer }; -// Import and reexport all procedure arg types +// Import all procedure arg schemas import * as GetMySchemaViaHttpProcedure from "./get_my_schema_via_http_procedure"; -export { GetMySchemaViaHttpProcedure }; import * as ReturnValueProcedure from "./return_value_procedure"; -export { ReturnValueProcedure }; import * as SleepOneSecondProcedure from "./sleep_one_second_procedure"; -export { SleepOneSecondProcedure }; import * as WithTxProcedure from "./with_tx_procedure"; -export { WithTxProcedure }; -// Import and reexport all table handle types +// Import all table schema definitions import HasSpecialStuffRow from "./has_special_stuff_table"; -export { HasSpecialStuffRow }; import LoggedOutPlayerRow from "./logged_out_player_table"; -export { LoggedOutPlayerRow }; import MyPlayerRow from "./my_player_table"; -export { MyPlayerRow }; import PersonRow from "./person_table"; -export { PersonRow }; import PkMultiIdentityRow from "./pk_multi_identity_table"; -export { PkMultiIdentityRow }; import PlayerRow from "./player_table"; -export { PlayerRow }; import PointsRow from "./points_table"; -export { PointsRow }; import PrivateTableRow from "./private_table_table"; -export { PrivateTableRow }; import RepeatingTestArgRow from "./repeating_test_arg_table"; -export { RepeatingTestArgRow }; import TableToRemoveRow from "./table_to_remove_table"; -export { TableToRemoveRow }; import TestARow from "./test_a_table"; -export { TestARow }; import TestDRow from "./test_d_table"; -export { TestDRow }; import TestERow from "./test_e_table"; -export { TestERow }; import TestFRow from "./test_f_table"; -export { TestFRow }; -// Import and reexport all types -import Baz from "./baz_type"; -export { Baz }; -import Foobar from "./foobar_type"; -export { Foobar }; -import HasSpecialStuff from "./has_special_stuff_type"; -export { HasSpecialStuff }; -import Person from "./person_type"; -export { Person }; -import PkMultiIdentity from "./pk_multi_identity_type"; -export { PkMultiIdentity }; -import Player from "./player_type"; -export { Player }; -import Point from "./point_type"; -export { Point }; -import PrivateTable from "./private_table_type"; -export { PrivateTable }; -import RemoveTable from "./remove_table_type"; -export { RemoveTable }; -import RepeatingTestArg from "./repeating_test_arg_type"; -export { RepeatingTestArg }; -import TestA from "./test_a_type"; -export { TestA }; -import TestB from "./test_b_type"; -export { TestB }; -import TestD from "./test_d_type"; -export { TestD }; -import TestE from "./test_e_type"; -export { TestE }; -import TestFoobar from "./test_foobar_type"; -export { TestFoobar }; -import NamespaceTestC from "./namespace_test_c_type"; -export { NamespaceTestC }; -import NamespaceTestF from "./namespace_test_f_type"; -export { NamespaceTestF }; +/** Type-only namespace exports for generated type groups. */ /** 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( @@ -1299,6 +1232,116 @@ 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 ClientConnectedReducer from "../client_connected_reducer"; +import DeletePlayerReducer from "../delete_player_reducer"; +import DeletePlayersByNameReducer from "../delete_players_by_name_reducer"; +import ListOverAgeReducer from "../list_over_age_reducer"; +import LogModuleIdentityReducer from "../log_module_identity_reducer"; +import QueryPrivateReducer from "../query_private_reducer"; +import RepeatingTestReducer from "../repeating_test_reducer"; +import SayHelloReducer from "../say_hello_reducer"; +import TestReducer from "../test_reducer"; +import TestBtreeIndexArgsReducer from "../test_btree_index_args_reducer"; + +export type AddArgs = __Infer; +export type AddPlayerArgs = __Infer; +export type AddPrivateArgs = __Infer; +export type AssertCallerIdentityIsModuleIdentityArgs = __Infer; +export type ClientConnectedArgs = __Infer; +export type DeletePlayerArgs = __Infer; +export type DeletePlayersByNameArgs = __Infer; +export type ListOverAgeArgs = __Infer; +export type LogModuleIdentityArgs = __Infer; +export type QueryPrivateArgs = __Infer; +export type RepeatingTestArgs = __Infer; +export type SayHelloArgs = __Infer; +export type TestArgs = __Infer; +export type TestBtreeIndexArgsArgs = __Infer; + ''' "with_tx_procedure.ts" = ''' // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE diff --git a/templates/basic-ts/src/module_bindings/index.ts b/templates/basic-ts/src/module_bindings/index.ts index 23ea2b9deb3..003de49a6cb 100644 --- a/templates/basic-ts/src/module_bindings/index.ts +++ b/templates/basic-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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( 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..9f40b85850c --- /dev/null +++ b/templates/basic-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/chat-react-ts/src/App.tsx b/templates/chat-react-ts/src/App.tsx index 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 5dc82db57f6..90c95e8c179 100644 --- a/templates/chat-react-ts/src/module_bindings/index.ts +++ b/templates/chat-react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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..8f6f02eb73d --- /dev/null +++ b/templates/chat-react-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import SetNameReducer from '../set_name_reducer'; +import SendMessageReducer from '../send_message_reducer'; +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; + +export type SetNameArgs = __Infer; +export type SendMessageArgs = __Infer; +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; diff --git a/templates/react-ts/src/module_bindings/index.ts b/templates/react-ts/src/module_bindings/index.ts index 23ea2b9deb3..003de49a6cb 100644 --- a/templates/react-ts/src/module_bindings/index.ts +++ b/templates/react-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.3 (commit f9bca6a8df856d950360b40cbce744fcbffc9a63). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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( 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..9f40b85850c --- /dev/null +++ b/templates/react-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/templates/vue-ts/src/module_bindings/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..003de49a6cb 100644 --- a/templates/vue-ts/src/module_bindings/index.ts +++ b/templates/vue-ts/src/module_bindings/index.ts @@ -1,7 +1,7 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. -// This was generated using spacetimedb cli version 1.11.2 (commit 5508f620e2fd5a4d8a3b7aaf5303776d127f5cbd). +// This was generated using spacetimedb cli version 1.11.3 (commit dbe8a0dff3bfe776501978389e28b0fdfaf53eed). /* 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.11.3' 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..9f40b85850c --- /dev/null +++ b/templates/vue-ts/src/module_bindings/types/reducers.ts @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. + +/* eslint-disable */ +/* tslint:disable */ +import { type Infer as __Infer } from 'spacetimedb'; + +// Import all reducer arg schemas +import OnConnectReducer from '../on_connect_reducer'; +import OnDisconnectReducer from '../on_disconnect_reducer'; +import AddReducer from '../add_reducer'; +import SayHelloReducer from '../say_hello_reducer'; + +export type OnConnectArgs = __Infer; +export type OnDisconnectArgs = __Infer; +export type AddArgs = __Infer; +export type SayHelloArgs = __Infer; diff --git a/tools/replace-spacetimedb/src/lib.rs b/tools/replace-spacetimedb/src/lib.rs index ff91bda9cfd..8037af72e64 100644 --- a/tools/replace-spacetimedb/src/lib.rs +++ b/tools/replace-spacetimedb/src/lib.rs @@ -94,13 +94,25 @@ pub fn replace_in_tree( continue; } + // Determine depth relative to root, in case we need to add ../ + let rel_parent = path + .parent() + .and_then(|p| p.strip_prefix(&root).ok()) + .unwrap_or_else(|| Path::new("")); + let depth = rel_parent.components().count(); + // Decide which replacement to use for this file - let is_index_ts = path.file_name().and_then(|n| n.to_str()) == Some("index.ts"); + let is_index_ts = depth == 0 && path.file_name().and_then(|n| n.to_str()) == Some("index.ts"); let repl = if is_index_ts { replacement_index_ts } else { replacement_other_ts }; + let repl = if depth > 0 { + format!("{}{}", "../".repeat(depth), repl) + } else { + repl.to_string() + }; let bytes = match fs::read(path) { Ok(b) => b,