Skip to content

Commit 038059b

Browse files
committed
Push creds
1 parent b62ca68 commit 038059b

File tree

2 files changed

+69
-39
lines changed

2 files changed

+69
-39
lines changed

packages/test-app/src/App.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function App() {
2424
})
2525
.withCredentials([
2626
Identity.fromString(
27-
'93dda09db9a56d8fa6c024d843e805d8262191db3b4ba84c5efcd1ad451fed4e'
27+
'c200c4018ee1d21bb54b0379bedb68643ca1dd209710e504fac2a41d43567fb2'
2828
),
29-
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJoZXhfaWRlbnRpdHkiOiI5M2RkYTA5ZGI5YTU2ZDhmYTZjMDI0ZDg0M2U4MDVkODI2MjE5MWRiM2I0YmE4NGM1ZWZjZDFhZDQ1MWZlZDRlIiwiaWF0IjoxNzI4MzY3NDk0LCJleHAiOm51bGx9.ua3DQaiXo5i3Ye0okughs84PV9uZLCnov26zvCMG-3ibqGg6vH0uDDY6L-zDf8XiFgUqEIcvnJvuKLThPDipjQ',
29+
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJoZXhfaWRlbnRpdHkiOiJjMjAwYzQwMThlZTFkMjFiYjU0YjAzNzliZWRiNjg2NDNjYTFkZDIwOTcxMGU1MDRmYWMyYTQxZDQzNTY3ZmIyIiwic3ViIjoiYjNhZWRmNDgtZDExNC00MmVjLWI0Y2EtNmY5MjAwNjk2OGJmIiwiaXNzIjoibG9jYWxob3N0IiwiYXVkIjpbInNwYWNldGltZWRiIl0sImlhdCI6MTcyOTYyMTI2NiwiZXhwIjpudWxsfQ.TIJGisLeX3SuN8_9horfk2NifEGjCutq4wh7Fm5Qfp1-vhpKWmFCtAY0MRuYdalQtaWXT0bQ2seHlXA4PkOGbg',
3030
])
3131
.build()
3232
);

packages/test-app/src/module_bindings/index.ts

+67-37
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,42 @@ import {
3838
TableCache,
3939
// @ts-ignore
4040
deepEqual,
41-
} from "@clockworklabs/spacetimedb-sdk";
41+
} from '@clockworklabs/spacetimedb-sdk';
4242

4343
// Import and reexport all reducer arg types
44-
import { CreatePlayer } from "./create_player_reducer.ts";
44+
import { CreatePlayer } from './create_player_reducer.ts';
4545
export { CreatePlayer };
4646

4747
// Import and reexport all table handle types
48-
import { PlayerTableHandle } from "./player_table.ts";
48+
import { PlayerTableHandle } from './player_table.ts';
4949
export { PlayerTableHandle };
50-
import { UserTableHandle } from "./user_table.ts";
50+
import { UserTableHandle } from './user_table.ts';
5151
export { UserTableHandle };
5252

5353
// Import and reexport all types
54-
import { Player } from "./player_type.ts";
54+
import { Player } from './player_type.ts';
5555
export { Player };
56-
import { Point } from "./point_type.ts";
56+
import { Point } from './point_type.ts';
5757
export { Point };
58-
import { User } from "./user_type.ts";
58+
import { User } from './user_type.ts';
5959
export { User };
6060

6161
const REMOTE_MODULE = {
6262
tables: {
6363
player: {
64-
tableName: "player",
64+
tableName: 'player',
6565
rowType: Player.getTypeScriptAlgebraicType(),
66-
primaryKey: "owner_id",
66+
primaryKey: 'owner_id',
6767
},
6868
user: {
69-
tableName: "user",
69+
tableName: 'user',
7070
rowType: User.getTypeScriptAlgebraicType(),
71-
primaryKey: "identity",
71+
primaryKey: 'identity',
7272
},
7373
},
7474
reducers: {
7575
create_player: {
76-
reducerName: "create_player",
76+
reducerName: 'create_player',
7777
argsType: CreatePlayer.getTypeScriptAlgebraicType(),
7878
},
7979
},
@@ -82,70 +82,100 @@ const REMOTE_MODULE = {
8282
eventContextConstructor: (imp: DBConnectionImpl, event: Event<Reducer>) => {
8383
return {
8484
...(imp as DBConnection),
85-
event
86-
}
85+
event,
86+
};
8787
},
8888
dbViewConstructor: (imp: DBConnectionImpl) => {
8989
return new RemoteTables(imp);
9090
},
91-
reducersConstructor: (imp: DBConnectionImpl, setReducerFlags: SetReducerFlags) => {
91+
reducersConstructor: (
92+
imp: DBConnectionImpl,
93+
setReducerFlags: SetReducerFlags
94+
) => {
9295
return new RemoteReducers(imp, setReducerFlags);
93-
}
96+
},
9497
setReducerFlagsConstructor: () => {
9598
return new SetReducerFlags();
96-
}
97-
}
99+
},
100+
};
98101

99102
// A type representing all the possible variants of a reducer.
100-
export type Reducer = never
101-
| { name: "CreatePlayer", args: CreatePlayer }
102-
;
103+
export type Reducer = never | { name: 'CreatePlayer'; args: CreatePlayer };
103104

104105
export class RemoteReducers {
105-
constructor(private connection: DBConnectionImpl, private setCallReducerFlags: SetReducerFlags) {}
106+
constructor(
107+
private connection: DBConnectionImpl,
108+
private setCallReducerFlags: SetReducerFlags
109+
) {}
106110

107111
createPlayer(name: string, location: Point) {
108112
const __args = { name, location };
109113
let __writer = new BinaryWriter(1024);
110114
CreatePlayer.getTypeScriptAlgebraicType().serialize(__writer, __args);
111115
let __argsBuffer = __writer.getBuffer();
112-
this.connection.callReducer("create_player", __argsBuffer, this.setCallReducerFlags.createPlayerFlags);
116+
this.connection.callReducer(
117+
'create_player',
118+
__argsBuffer,
119+
this.setCallReducerFlags.createPlayerFlags
120+
);
113121
}
114122

115-
onCreatePlayer(callback: (ctx: EventContext, name: string, location: Point) => void) {
116-
this.connection.onReducer("create_player", callback);
123+
onCreatePlayer(
124+
callback: (ctx: EventContext, name: string, location: Point) => void
125+
) {
126+
this.connection.onReducer('create_player', callback);
117127
}
118128

119-
removeOnCreatePlayer(callback: (ctx: EventContext, name: string, location: Point) => void) {
120-
this.connection.offReducer("create_player", callback);
129+
removeOnCreatePlayer(
130+
callback: (ctx: EventContext, name: string, location: Point) => void
131+
) {
132+
this.connection.offReducer('create_player', callback);
121133
}
122-
123134
}
124135

125136
export class SetReducerFlags {
126-
createPlayerFlags: CallReducerFlags;
137+
createPlayerFlags: CallReducerFlags = 'FullUpdate';
127138
createPlayer(flags: CallReducerFlags) {
128139
this.createPlayerFlags = flags;
129140
}
130-
131141
}
132142

133143
export class RemoteTables {
134144
constructor(private connection: DBConnectionImpl) {}
135145

136146
get player(): PlayerTableHandle {
137-
return new PlayerTableHandle(this.connection.clientCache.getOrCreateTable<Player>(REMOTE_MODULE.tables.player));
147+
return new PlayerTableHandle(
148+
this.connection.clientCache.getOrCreateTable<Player>(
149+
REMOTE_MODULE.tables.player
150+
)
151+
);
138152
}
139153

140154
get user(): UserTableHandle {
141-
return new UserTableHandle(this.connection.clientCache.getOrCreateTable<User>(REMOTE_MODULE.tables.user));
155+
return new UserTableHandle(
156+
this.connection.clientCache.getOrCreateTable<User>(
157+
REMOTE_MODULE.tables.user
158+
)
159+
);
142160
}
143161
}
144162

145-
export class DBConnection extends DBConnectionImpl<RemoteTables, RemoteReducers, SetReducerFlags> {
146-
static builder = (): DBConnectionBuilder<DBConnection> => {
147-
return new DBConnectionBuilder<DBConnection>(REMOTE_MODULE, (imp: DBConnectionImpl) => imp as DBConnection);
148-
}
163+
export class DBConnection extends DBConnectionImpl<
164+
RemoteTables,
165+
RemoteReducers,
166+
SetReducerFlags
167+
> {
168+
static builder = (): DBConnectionBuilder<DBConnection> => {
169+
return new DBConnectionBuilder<DBConnection>(
170+
REMOTE_MODULE,
171+
(imp: DBConnectionImpl) => imp as DBConnection
172+
);
173+
};
149174
}
150175

151-
export type EventContext = EventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags, Reducer>;
176+
export type EventContext = EventContextInterface<
177+
RemoteTables,
178+
RemoteReducers,
179+
SetReducerFlags,
180+
Reducer
181+
>;

0 commit comments

Comments
 (0)