Skip to content

Commit 4ca7a04

Browse files
committed
Add some table cache tests and regen stuff.
1 parent 5534ace commit 4ca7a04

18 files changed

+1003
-30
lines changed

examples/quickstart-chat/src/module_bindings/identity_connected_reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/identity_disconnected_reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck
@@ -63,11 +65,6 @@ const REMOTE_MODULE = {
6365
tableName: 'user',
6466
rowType: User.getTypeScriptAlgebraicType(),
6567
primaryKey: 'identity',
66-
primaryKeyInfo: {
67-
colName: 'identity',
68-
colType:
69-
User.getTypeScriptAlgebraicType().product.elements[0].algebraicType,
70-
},
7168
},
7269
},
7370
reducers: {
@@ -88,6 +85,9 @@ const REMOTE_MODULE = {
8885
argsType: SetName.getTypeScriptAlgebraicType(),
8986
},
9087
},
88+
versionInfo: {
89+
cliVersion: '1.1.1',
90+
},
9191
// Constructors which are used by the DbConnectionImpl to
9292
// extract type information from the generated RemoteModule.
9393
//

examples/quickstart-chat/src/module_bindings/message_table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/message_type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/send_message_reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/set_name_reducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/user_table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

examples/quickstart-chat/src/module_bindings/user_type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
22
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
33

4+
// This was generated using spacetimedb cli version 1.1.1 (commit e2c36856906f0d365d76d4e633bac6d84755eb2f).
5+
46
/* eslint-disable */
57
/* tslint:disable */
68
// @ts-nocheck

packages/sdk/src/db_connection_impl.ts

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ import {
1515
} from './algebraic_value.ts';
1616
import BinaryReader from './binary_reader.ts';
1717
import BinaryWriter from './binary_writer.ts';
18-
import * as ws from './client_api/index.ts';
18+
import { BsatnRowList } from './client_api/bsatn_row_list_type.ts';
19+
import { ClientMessage } from './client_api/client_message_type.ts';
20+
import { DatabaseUpdate } from './client_api/database_update_type.ts';
21+
import { QueryUpdate } from './client_api/query_update_type.ts';
22+
import { ServerMessage } from './client_api/server_message_type.ts';
23+
import { TableUpdate as RawTableUpdate } from './client_api/table_update_type.ts';
24+
import type * as clientApi from './client_api/index.ts';
1925
import { ClientCache } from './client_cache.ts';
2026
import { DbConnectionBuilder } from './db_connection_builder.ts';
2127
import { type DbContext } from './db_context.ts';
@@ -41,7 +47,7 @@ import {
4147
TableCache,
4248
type Operation,
4349
type PendingCallback,
44-
type TableUpdate,
50+
type TableUpdate as CacheTableUpdate,
4551
} from './table_cache.ts';
4652
import { deepEqual, toPascalCase } from './utils.ts';
4753
import { WebsocketDecompressAdapter } from './websocket_decompress_adapter.ts';
@@ -53,7 +59,7 @@ import {
5359
type SubscribeEvent,
5460
} from './subscription_builder_impl.ts';
5561
import { stdbLogger } from './logger.ts';
56-
import type { ReducerRuntimeTypeInfo } from './spacetime_module.ts';
62+
import { type ReducerRuntimeTypeInfo } from './spacetime_module.ts';
5763
import { fromByteArray } from 'base64-js';
5864

5965
export {
@@ -274,7 +280,7 @@ export class DbConnectionImpl<
274280
emitter: handleEmitter,
275281
});
276282
this.#sendMessage(
277-
ws.ClientMessage.SubscribeMulti({
283+
ClientMessage.SubscribeMulti({
278284
queryStrings: querySql,
279285
queryId: { id: queryId },
280286
// The TypeScript SDK doesn't currently track `request_id`s,
@@ -287,7 +293,7 @@ export class DbConnectionImpl<
287293

288294
unregisterSubscription(queryId: number): void {
289295
this.#sendMessage(
290-
ws.ClientMessage.UnsubscribeMulti({
296+
ClientMessage.UnsubscribeMulti({
291297
queryId: { id: queryId },
292298
// The TypeScript SDK doesn't currently track `request_id`s,
293299
// so always use 0.
@@ -298,12 +304,12 @@ export class DbConnectionImpl<
298304

299305
// This function is async because we decompress the message async
300306
async #processParsedMessage(
301-
message: ws.ServerMessage
307+
message: ServerMessage
302308
): Promise<Message | undefined> {
303309
const parseRowList = (
304310
type: 'insert' | 'delete',
305311
tableName: string,
306-
rowList: ws.BsatnRowList
312+
rowList: BsatnRowList
307313
): Operation[] => {
308314
const buffer = rowList.rowsData;
309315
const reader = new BinaryReader(buffer);
@@ -340,15 +346,15 @@ export class DbConnectionImpl<
340346
};
341347

342348
const parseTableUpdate = async (
343-
rawTableUpdate: ws.TableUpdate
344-
): Promise<TableUpdate> => {
349+
rawTableUpdate: RawTableUpdate
350+
): Promise<CacheTableUpdate> => {
345351
const tableName = rawTableUpdate.tableName;
346352
let operations: Operation[] = [];
347353
for (const update of rawTableUpdate.updates) {
348-
let decompressed: ws.QueryUpdate;
354+
let decompressed: QueryUpdate;
349355
if (update.tag === 'Gzip') {
350356
const decompressedBuffer = await decompress(update.value, 'gzip');
351-
decompressed = ws.QueryUpdate.deserialize(
357+
decompressed = QueryUpdate.deserialize(
352358
new BinaryReader(decompressedBuffer)
353359
);
354360
} else if (update.tag === 'Brotli') {
@@ -372,9 +378,9 @@ export class DbConnectionImpl<
372378
};
373379

374380
const parseDatabaseUpdate = async (
375-
dbUpdate: ws.DatabaseUpdate
376-
): Promise<TableUpdate[]> => {
377-
const tableUpdates: TableUpdate[] = [];
381+
dbUpdate: DatabaseUpdate
382+
): Promise<CacheTableUpdate[]> => {
383+
const tableUpdates: CacheTableUpdate[] = [];
378384
for (const rawTableUpdate of dbUpdate.tables) {
379385
tableUpdates.push(await parseTableUpdate(rawTableUpdate));
380386
}
@@ -412,7 +418,7 @@ export class DbConnectionImpl<
412418
const args = txUpdate.reducerCall.args;
413419
const energyQuantaUsed = txUpdate.energyQuantaUsed;
414420

415-
let tableUpdates: TableUpdate[];
421+
let tableUpdates: CacheTableUpdate[];
416422
let errMessage = '';
417423
switch (txUpdate.status.tag) {
418424
case 'Committed':
@@ -512,11 +518,11 @@ export class DbConnectionImpl<
512518
}
513519
}
514520

515-
#sendMessage(message: ws.ClientMessage): void {
521+
#sendMessage(message: ClientMessage): void {
516522
this.wsPromise.then(wsResolved => {
517523
if (wsResolved) {
518524
const writer = new BinaryWriter(1024);
519-
ws.ClientMessage.serialize(writer, message);
525+
ClientMessage.serialize(writer, message);
520526
const encoded = writer.getBuffer();
521527
wsResolved.send(encoded);
522528
}
@@ -531,7 +537,7 @@ export class DbConnectionImpl<
531537
}
532538

533539
#applyTableUpdates(
534-
tableUpdates: TableUpdate[],
540+
tableUpdates: CacheTableUpdate[],
535541
eventContext: EventContextInterface
536542
): PendingCallback[] {
537543
let pendingCallbacks: PendingCallback[] = [];
@@ -549,7 +555,7 @@ export class DbConnectionImpl<
549555
}
550556

551557
async #processMessage(data: Uint8Array): Promise<void> {
552-
const serverMessage = parseValue(ws.ServerMessage, data);
558+
const serverMessage = parseValue(ServerMessage, data);
553559
const message = await this.#processParsedMessage(serverMessage);
554560
if (!message) {
555561
return;
@@ -803,7 +809,7 @@ export class DbConnectionImpl<
803809
argsBuffer: Uint8Array,
804810
flags: CallReducerFlags
805811
): void {
806-
const message = ws.ClientMessage.CallReducer({
812+
const message = ClientMessage.CallReducer({
807813
reducer: reducerName,
808814
args: argsBuffer,
809815
// The TypeScript SDK doesn't currently track `request_id`s,

0 commit comments

Comments
 (0)