Skip to content

Commit

Permalink
DBConnection -> DbConnection for the TypeScript API
Browse files Browse the repository at this point in the history
  • Loading branch information
cloutiertyler committed Feb 11, 2025
1 parent cf68225 commit 1340ff6
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions crates/cli/src/subcommands/generate/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,23 +348,23 @@ removeOnUpdate = (cb: (ctx: EventContext, onRow: {row_type}, newRow: {row_type})
writeln!(out, "}},");
writeln!(
out,
"// Constructors which are used by the DBConnectionImpl to
"// Constructors which are used by the DbConnectionImpl to
// extract type information from the generated RemoteModule.
//
// NOTE: This is not strictly necessary for `eventContextConstructor` because
// all we do is build a TypeScript object which we could have done inside the
// SDK, but if in the future we wanted to create a class this would be
// necessary because classes have methods, so we'll keep it.
eventContextConstructor: (imp: DBConnectionImpl, event: Event<Reducer>) => {{
eventContextConstructor: (imp: DbConnectionImpl, event: Event<Reducer>) => {{
return {{
...(imp as DBConnection),
...(imp as DbConnection),
event
}}
}},
dbViewConstructor: (imp: DBConnectionImpl) => {{
dbViewConstructor: (imp: DbConnectionImpl) => {{
return new RemoteTables(imp);
}},
reducersConstructor: (imp: DBConnectionImpl, setReducerFlags: SetReducerFlags) => {{
reducersConstructor: (imp: DbConnectionImpl, setReducerFlags: SetReducerFlags) => {{
return new RemoteReducers(imp, setReducerFlags);
}},
setReducerFlagsConstructor: () => {{
Expand Down Expand Up @@ -433,7 +433,7 @@ fn print_remote_reducers(module: &ModuleDef, out: &mut Indenter) {
out.indent(1);
writeln!(
out,
"constructor(private connection: DBConnectionImpl, private setCallReducerFlags: SetReducerFlags) {{}}"
"constructor(private connection: DbConnectionImpl, private setCallReducerFlags: SetReducerFlags) {{}}"
);
out.newline();

Expand Down Expand Up @@ -537,7 +537,7 @@ fn print_set_reducer_flags(module: &ModuleDef, out: &mut Indenter) {
fn print_remote_tables(module: &ModuleDef, out: &mut Indenter) {
writeln!(out, "export class RemoteTables {{");
out.indent(1);
writeln!(out, "constructor(private connection: DBConnectionImpl) {{}}");
writeln!(out, "constructor(private connection: DbConnectionImpl) {{}}");

for table in iter_tables(module) {
writeln!(out);
Expand Down Expand Up @@ -571,12 +571,23 @@ fn print_subscription_builder(_module: &ModuleDef, out: &mut Indenter) {
fn print_db_connection(_module: &ModuleDef, out: &mut Indenter) {
writeln!(
out,
<<<<<<< HEAD
"export class DBConnection extends DBConnectionImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{"
);
out.indent(1);
writeln!(
out,
"static builder = (): DBConnectionBuilder<DBConnection, ErrorContext, SubscriptionEventContext> => {{"
=======
"export class DbConnection extends DbConnectionImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{"
);
out.indent(1);
writeln!(out, "static builder = (): DbConnectionBuilder<DbConnection> => {{");
out.indent(1);
writeln!(
out,
"return new DbConnectionBuilder<DbConnection>(REMOTE_MODULE, (imp: DbConnectionImpl) => imp as DbConnection);"
>>>>>>> beca27347 (DBConnection -> DbConnection for the TypeScript API)
);
out.indent(1);
writeln!(
Expand Down Expand Up @@ -620,7 +631,7 @@ fn print_spacetimedb_imports(out: &mut Indenter) {
"ConnectionId",
"Timestamp",
"TimeDuration",
"DBConnectionBuilder",
"DbConnectionBuilder",
"TableCache",
"BinaryWriter",
"CallReducerFlags",
Expand All @@ -630,8 +641,8 @@ fn print_spacetimedb_imports(out: &mut Indenter) {
"ErrorContextInterface",
"SubscriptionBuilderImpl",
"BinaryReader",
"DBConnectionImpl",
"DBContext",
"DbConnectionImpl",
"DbContext",
"Event",
"deepEqual",
];
Expand Down

0 comments on commit 1340ff6

Please sign in to comment.