Skip to content
Draft
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
102 changes: 51 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,46 +114,46 @@ inherits = "release"
debug = true

[workspace.package]
version = "2.6.0"
version = "2.6.1"
edition = "2024"
# update rust-toolchain.toml too!
rust-version = "1.93.0"

[workspace.dependencies]
spacetimedb = { path = "crates/bindings", version = "=2.6.0" }
spacetimedb-auth = { path = "crates/auth", version = "=2.6.0" }
spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "=2.6.0" }
spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "=2.6.0" }
spacetimedb-cli = { path = "crates/cli", version = "=2.6.0" }
spacetimedb-client-api = { path = "crates/client-api", version = "=2.6.0" }
spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "=2.6.0" }
spacetimedb-codegen = { path = "crates/codegen", version = "=2.6.0" }
spacetimedb-commitlog = { path = "crates/commitlog", version = "=2.6.0" }
spacetimedb-core = { path = "crates/core", version = "=2.6.0" }
spacetimedb-data-structures = { path = "crates/data-structures", version = "=2.6.0" }
spacetimedb-datastore = { path = "crates/datastore", version = "=2.6.0" }
spacetimedb-durability = { path = "crates/durability", version = "=2.6.0" }
spacetimedb-execution = { path = "crates/execution", version = "=2.6.0" }
spacetimedb-expr = { path = "crates/expr", version = "=2.6.0" }
spacetimedb-guard = { path = "crates/guard", version = "=2.6.0" }
spacetimedb-lib = { path = "crates/lib", default-features = false, version = "=2.6.0" }
spacetimedb-memory-usage = { path = "crates/memory-usage", version = "=2.6.0", default-features = false }
spacetimedb-metrics = { path = "crates/metrics", version = "=2.6.0" }
spacetimedb-paths = { path = "crates/paths", version = "=2.6.0" }
spacetimedb-pg = { path = "crates/pg", version = "=2.6.0" }
spacetimedb-physical-plan = { path = "crates/physical-plan", version = "=2.6.0" }
spacetimedb-primitives = { path = "crates/primitives", version = "=2.6.0" }
spacetimedb-query = { path = "crates/query", version = "=2.6.0" }
spacetimedb-sats = { path = "crates/sats", version = "=2.6.0" }
spacetimedb-schema = { path = "crates/schema", version = "=2.6.0" }
spacetimedb-standalone = { path = "crates/standalone", version = "=2.6.0" }
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=2.6.0" }
spacetimedb-table = { path = "crates/table", version = "=2.6.0" }
spacetimedb-fs-utils = { path = "crates/fs-utils", version = "=2.6.0" }
spacetimedb-snapshot = { path = "crates/snapshot", version = "=2.6.0" }
spacetimedb-subscription = { path = "crates/subscription", version = "=2.6.0" }
spacetimedb-query-builder = { path = "crates/query-builder", version = "=2.6.0" }
spacetimedb-runtime = { path = "crates/runtime", version = "=2.6.0" }
spacetimedb = { path = "crates/bindings", version = "=2.6.1" }
spacetimedb-auth = { path = "crates/auth", version = "=2.6.1" }
spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "=2.6.1" }
spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "=2.6.1" }
spacetimedb-cli = { path = "crates/cli", version = "=2.6.1" }
spacetimedb-client-api = { path = "crates/client-api", version = "=2.6.1" }
spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "=2.6.1" }
spacetimedb-codegen = { path = "crates/codegen", version = "=2.6.1" }
spacetimedb-commitlog = { path = "crates/commitlog", version = "=2.6.1" }
spacetimedb-core = { path = "crates/core", version = "=2.6.1" }
spacetimedb-data-structures = { path = "crates/data-structures", version = "=2.6.1" }
spacetimedb-datastore = { path = "crates/datastore", version = "=2.6.1" }
spacetimedb-durability = { path = "crates/durability", version = "=2.6.1" }
spacetimedb-execution = { path = "crates/execution", version = "=2.6.1" }
spacetimedb-expr = { path = "crates/expr", version = "=2.6.1" }
spacetimedb-guard = { path = "crates/guard", version = "=2.6.1" }
spacetimedb-lib = { path = "crates/lib", default-features = false, version = "=2.6.1" }
spacetimedb-memory-usage = { path = "crates/memory-usage", version = "=2.6.1", default-features = false }
spacetimedb-metrics = { path = "crates/metrics", version = "=2.6.1" }
spacetimedb-paths = { path = "crates/paths", version = "=2.6.1" }
spacetimedb-pg = { path = "crates/pg", version = "=2.6.1" }
spacetimedb-physical-plan = { path = "crates/physical-plan", version = "=2.6.1" }
spacetimedb-primitives = { path = "crates/primitives", version = "=2.6.1" }
spacetimedb-query = { path = "crates/query", version = "=2.6.1" }
spacetimedb-sats = { path = "crates/sats", version = "=2.6.1" }
spacetimedb-schema = { path = "crates/schema", version = "=2.6.1" }
spacetimedb-standalone = { path = "crates/standalone", version = "=2.6.1" }
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=2.6.1" }
spacetimedb-table = { path = "crates/table", version = "=2.6.1" }
spacetimedb-fs-utils = { path = "crates/fs-utils", version = "=2.6.1" }
spacetimedb-snapshot = { path = "crates/snapshot", version = "=2.6.1" }
spacetimedb-subscription = { path = "crates/subscription", version = "=2.6.1" }
spacetimedb-query-builder = { path = "crates/query-builder", version = "=2.6.1" }
spacetimedb-runtime = { path = "crates/runtime", version = "=2.6.1" }

# Prevent `ahash` from pulling in `getrandom` by disabling default features.
# Modules use `getrandom02` and we need to prevent an incompatible version
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Business Source License 1.1
Parameters

Licensor: Clockwork Laboratories, Inc.
Licensed Work: SpacetimeDB 2.6.0
Licensed Work: SpacetimeDB 2.6.1
The Licensed Work is
(c) 2023 Clockwork Laboratories, Inc.

Expand All @@ -21,7 +21,7 @@ Additional Use Grant: You may make use of the Licensed Work provided your
Licensed Work by creating tables whose schemas are
controlled by such third parties.

Change Date: 2031-06-15
Change Date: 2031-06-29

Change License: GNU Affero General Public License v3.0 with a linking
exception
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cmake_minimum_required(VERSION 3.15)
project(SpacetimeDBCppModuleLibrary
VERSION 2.6.0
VERSION 2.6.1
LANGUAGES CXX)

# Generate version header from template
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/BSATN.Codegen/BSATN.Codegen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyName>SpacetimeDB.BSATN.Codegen</AssemblyName>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Title>SpacetimeDB BSATN Codegen</Title>
<Description>The SpacetimeDB BSATN Codegen implements the Roslyn incremental generators for BSATN serialization/deserialization in C#.</Description>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/BSATN.Runtime/BSATN.Runtime.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>SpacetimeDB.BSATN.Runtime</AssemblyName>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Title>SpacetimeDB BSATN Runtime</Title>
<Description>The SpacetimeDB BSATN Runtime implements APIs for BSATN serialization/deserialization in C#.</Description>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/Codegen/Codegen.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>SpacetimeDB.Codegen</AssemblyName>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Title>SpacetimeDB Module Codegen</Title>
<Description>The SpacetimeDB Codegen implements the Roslyn incremental generators for writing SpacetimeDB modules in C#.</Description>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-csharp/Runtime/Runtime.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AssemblyName>SpacetimeDB.Runtime</AssemblyName>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Title>SpacetimeDB Module Runtime</Title>
<Description>The SpacetimeDB Runtime implements the database runtime bindings for writing SpacetimeDB modules in C#.</Description>
</PropertyGroup>
Expand Down

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

2 changes: 1 addition & 1 deletion crates/bindings-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spacetimedb",
"version": "2.6.0",
"version": "2.6.1",
"description": "API and ABI bindings for the SpacetimeDB TypeScript module library",
"homepage": "https://github.com/clockworklabs/SpacetimeDB#readme",
"bugs": {
Expand Down
2 changes: 2 additions & 0 deletions crates/bindings-typescript/src/lib/type_builders.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const rowOptionOptional = {
};
type RowOptionOptional = InferTypeOfRow<typeof rowOptionOptional>;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _rowOptionOptionalOmitted: RowOptionOptional = {};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _rowOptionOptionalNone: RowOptionOptional = {
foo: undefined,
};
Expand Down
42 changes: 39 additions & 3 deletions crates/bindings-typescript/src/lib/type_builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,45 @@ export type Infer<T> = T extends RowObj
/**
* Helper type to extract the type of a row from an object.
*/
export type InferTypeOfRow<T extends RowObj> = {
[K in keyof T & string]: InferTypeOfTypeBuilder<CollapseColumn<T[K]>>;
};
type OptionalRowKeys<T extends RowObj> = {
[K in keyof T & string]-?: CollapseColumn<T[K]> extends OptionBuilder<any>
? K
: never;
}[keyof T & string];

type RequiredRowKeys<T extends RowObj> = Exclude<
keyof T & string,
OptionalRowKeys<T>
>;

export type InferTypeOfRow<T extends RowObj> = Prettify<
{
[K in RequiredRowKeys<T>]: InferTypeOfTypeBuilder<CollapseColumn<T[K]>>;
} & {
[K in OptionalRowKeys<T>]?: InferTypeOfTypeBuilder<CollapseColumn<T[K]>>;
}
>;

type OptionalParamKeys<T extends RowObj> = {
[K in keyof T & string]-?: undefined extends InferTypeOfTypeBuilder<
CollapseColumn<T[K]>
>
? K
: never;
}[keyof T & string];

type RequiredParamKeys<T extends RowObj> = Exclude<
keyof T & string,
OptionalParamKeys<T>
>;

export type InferTypeOfParams<T extends RowObj> = Prettify<
{
[K in RequiredParamKeys<T>]: InferTypeOfTypeBuilder<CollapseColumn<T[K]>>;
} & {
[K in OptionalParamKeys<T>]?: InferTypeOfTypeBuilder<CollapseColumn<T[K]>>;
}
>;

/**
* Helper type to extract the type of a row from an object.
Expand Down
15 changes: 11 additions & 4 deletions crates/bindings-typescript/src/sdk/db_connection_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import {
type SubscriptionEventContextInterface,
} from './event_context.ts';
import { EventEmitter } from './event_emitter.ts';
import type { Deserializer, Identity, InferTypeOfRow, Serializer } from '../';
import type {
Deserializer,
Identity,
InferTypeOfParams,
Serializer,
} from '../';
import type {
ProcedureResultMessage,
ReducerResultMessage,
Expand Down Expand Up @@ -383,7 +388,9 @@ export class DbConnectionImpl<RemoteModule extends UntypedRemoteModule>
const { serialize: serializeArgs } =
this.#reducerArgsSerializers[reducerName];

(out as any)[key] = (params: InferTypeOfRow<typeof reducer.params>) => {
(out as any)[key] = (
params: InferTypeOfParams<typeof reducer.params>
) => {
const writer = this.#reducerArgsEncoder;
writer.clear();
serializeArgs(writer, params);
Expand Down Expand Up @@ -414,7 +421,7 @@ export class DbConnectionImpl<RemoteModule extends UntypedRemoteModule>
this.#procedureSerializers[procedureName];

(out as any)[key] = (
params: InferTypeOfRow<typeof procedure.params>
params: InferTypeOfParams<typeof procedure.params>
): Promise<any> => {
writer.clear();
serializeArgs(writer, params);
Expand All @@ -436,7 +443,7 @@ export class DbConnectionImpl<RemoteModule extends UntypedRemoteModule>
event: Event<
ReducerEventInfo<
RemoteModule['reducers'][number]['name'],
InferTypeOfRow<RemoteModule['reducers'][number]['params']>
InferTypeOfParams<RemoteModule['reducers'][number]['params']>
>
>
): EventContextInterface<RemoteModule> {
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-typescript/src/sdk/event_context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InferTypeOfRow } from '../lib/type_builders.ts';
import type { InferTypeOfParams } from '../lib/type_builders.ts';
import type { DbContext } from './db_context';
import type { Event } from './event.ts';
import type { ReducerEvent } from './reducer_event.ts';
Expand All @@ -13,7 +13,7 @@ export interface EventContextInterface<RemoteModule extends UntypedRemoteModule>
event: Event<
ReducerEventInfo<
RemoteModule['reducers'][number]['name'],
InferTypeOfRow<RemoteModule['reducers'][number]['params']>
InferTypeOfParams<RemoteModule['reducers'][number]['params']>
>
>;
}
Expand All @@ -25,7 +25,7 @@ export interface ReducerEventContextInterface<
event: ReducerEvent<
ReducerEventInfo<
RemoteModule['reducers'][number]['name'],
InferTypeOfRow<RemoteModule['reducers'][number]['params']>
InferTypeOfParams<RemoteModule['reducers'][number]['params']>
>
>;
}
Expand Down
8 changes: 6 additions & 2 deletions crates/bindings-typescript/src/sdk/procedures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { ParamsObj } from '../lib/reducers';
import type { Infer, InferTypeOfRow, TypeBuilder } from '../lib/type_builders';
import type {
Infer,
InferTypeOfParams,
TypeBuilder,
} from '../lib/type_builders';
import type { CamelCase } from '../lib/type_util';
import { coerceParams, toCamelCase, type CoerceParams } from '../lib/util';
import type { UntypedRemoteModule } from './spacetime_module';
Expand All @@ -20,7 +24,7 @@ export type ProceduresView<RemoteModule> = IfAny<
? // x: camelCase(name)
{
[K in RemoteModule['procedures'][number] as K['accessorName']]: (
params: InferTypeOfRow<K['params']>
params: InferTypeOfParams<K['params']>
) => Promise<Infer<K['returnType']>>;
}
: never
Expand Down
7 changes: 3 additions & 4 deletions crates/bindings-typescript/src/sdk/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { ProductType } from '../lib/algebraic_type';
import type { ReducerSchema } from '../lib/reducer_schema';
import type { ParamsObj } from '../lib/reducers';
import type { CoerceRow } from '../lib/table';
import { RowBuilder, type InferTypeOfRow } from '../lib/type_builders';
import { RowBuilder, type InferTypeOfParams } from '../lib/type_builders';
import { toCamelCase } from '../lib/util';
import type { SubscriptionEventContextInterface } from './event_context';
import type { UntypedRemoteModule } from './spacetime_module';
Expand All @@ -26,7 +25,7 @@ export type ReducersView<RemoteModule> = IfAny<
RemoteModule extends UntypedRemoteModule
? {
[K in RemoteModule['reducers'][number] as K['accessorName']]: (
params: InferTypeOfRow<K['params']>
params: InferTypeOfParams<K['params']>
) => Promise<void>;
}
: never
Expand All @@ -43,7 +42,7 @@ export type ReducerEventInfo<
export type UntypedReducerDef = {
name: string;
accessorName: string;
params: CoerceRow<ParamsObj>;
params: ParamsObj;
paramsType: ProductType;
};

Expand Down
3 changes: 2 additions & 1 deletion crates/bindings-typescript/src/sdk/table_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export class TableCacheImpl<
const columns = idx.columns;

// Extract the tuple key for this btree index (column order preserved)
const getKey = (row: Row): readonly unknown[] => columns.map(c => row[c]);
const getKey = (row: Row): readonly unknown[] =>
columns.map(c => (row as Record<string, unknown>)[c]);

// The server’s ranged scan fixes all prefix cols to equality and applies
// the bound only to the *last* term. We mirror that.
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings-typescript/src/sdk/type_utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Infer, InferTypeOfRow } from '.';
import type { Infer, InferTypeOfParams } from '.';
import type { Prettify } from '../lib/type_util';
import type { UntypedProcedureDef } from './procedures';
import type { UntypedReducerDef } from './reducers';
Expand All @@ -7,11 +7,11 @@ export type IsEmptyObject<T> = [keyof T] extends [never] ? true : false;
export type MaybeParams<T> = IsEmptyObject<T> extends true ? [] : [params: T];

export type ParamsType<R extends UntypedReducerDef> = MaybeParams<
Prettify<InferTypeOfRow<R['params']>>
Prettify<InferTypeOfParams<R['params']>>
>;

export type ProcedureParamsType<P extends UntypedProcedureDef> = MaybeParams<
Prettify<InferTypeOfRow<P['params']>>
Prettify<InferTypeOfParams<P['params']>>
>;

export type ProcedureReturnType<P extends UntypedProcedureDef> = Infer<
Expand Down
7 changes: 5 additions & 2 deletions crates/bindings-typescript/src/server/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,11 @@ type ViewInfo<F> = {
returnTypeBaseSize: number;
};

export type Views = ViewInfo<ViewFn<any, any, any>>[];
export type AnonViews = ViewInfo<AnonymousViewFn<any, any, any>>[];
type AnyViewFn = (ctx: ViewCtx<any>, params: any) => any;
type AnyAnonymousViewFn = (ctx: AnonymousViewCtx<any>, params: any) => any;

export type Views = ViewInfo<AnyViewFn>[];
export type AnonViews = ViewInfo<AnyAnonymousViewFn>[];

// A helper to get the product type out of a type builder.
// This is only non-never if the type builder is an array.
Expand Down
Loading
Loading