Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 13 additions & 24 deletions crates/bindings-typescript/src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,21 @@ export function tablesToSchema<
// UntypedTableDef expects mutable array; idxs are readonly, spread to copy.
indexes: [
...schema.idxs.map(
(idx: Infer<typeof RawIndexDefV9>): IndexOpts<any> =>
({
(idx: Infer<typeof RawIndexDefV9>): IndexOpts<any> => {
const columnIds =
idx.algorithm.tag === 'Direct'
? [idx.algorithm.value]
: idx.algorithm.value;
const columns = columnIds.map(i => colNameList[i]);
return {
name: idx.accessorName,
unique: schema.tableDef.constraints
.map(c => {
if (idx.algorithm.tag == 'BTree') {
return c.data.value.columns.every(col => {
const idxColumns = idx.algorithm.value;
if (Array.isArray(idxColumns)) {
return idxColumns.includes(col);
} else {
return col === idxColumns;
}
});
}
})
.includes(true),
unique: schema.tableDef.constraints.some(c =>
c.data.value.columns.every(col => columnIds.includes(col))
),
algorithm: idx.algorithm.tag.toLowerCase() as 'btree',
columns: (() => {
const cols =
idx.algorithm.tag === 'Direct'
? [idx.algorithm.value]
: idx.algorithm.value;
return cols.map(i => colNameList[i]);
})(),
}) as IndexOpts<any>
columns,
} as IndexOpts<any>;
}
),
],
} as const;
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-typescript/src/sdk/client_api/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl Lang for TypeScript {

writeln!(out);
writeln!(out, "/** Creates a new {{@link SubscriptionBuilder}} to configure a subscription to the remote SpacetimeDB instance. */");
writeln!(out, "subscriptionBuilder = (): SubscriptionBuilder => {{");
writeln!(out, "override subscriptionBuilder = (): SubscriptionBuilder => {{");
out.indent(1);
writeln!(out, "return new SubscriptionBuilder(this);");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/codegen/tests/codegen.rs
assertion_line: 37
expression: outfiles
---
"add_player_reducer.ts" = '''
Expand Down Expand Up @@ -587,7 +586,7 @@ export class DbConnection extends __DbConnectionImpl<typeof REMOTE_MODULE> {
};

/** Creates a new {@link SubscriptionBuilder} to configure a subscription to the remote SpacetimeDB instance. */
subscriptionBuilder = (): SubscriptionBuilder => {
override subscriptionBuilder = (): SubscriptionBuilder => {
return new SubscriptionBuilder(this);
};
}
Expand Down