Commit Graph

362 Commits

Author SHA1 Message Date
Tyler Cloutier 5901fb5063 Separate out TypeScript module library from the SDK (#3182)
# Description of Changes

Please note, much of the code changed in this PR is generated code.

This change updates the TypeScript SDK to use a new `spacetimedb`
TypeScript library which lives under the `/crates/bindings-typescript`
folder alongside `/crates/bindings-csharp`. Just like with the C#
bindings library, the types for `AlgebraicType` and `RawModuleDef` are
now code generated with a script in `/crates/codegen/examples`.

Pulling this out into a library allows us to use the same types and
serialization code on both the server and the client for TypeScript
modules.

In the process of making this change I also found and fixed several
issues with the TypeScript code generation. Namely an issue with
recursive types and an issue with the `never` type. I also removed any
use of `namespace`s since those are a TypeScript only feature, and we
want to have JavaScript + types so that we can use the generated code
with ESBuild without TSC.

I have also improved the npm/pnpm scripts to be able to generate
TypeScript code for us automatically by running `pnpm generate` for any
place that we have to generate typescript code. Namely:

- Quickstart module bindings
- AlgebraicType/ModuleDef for TypeScript module library
- Client API messages for the TypeScript API
- TestApp module bindings

# API and ABI breaking changes

IMPORTANT! This is an API breaking change for clients, as such it should
be a major version change. However, I am going to see if I can shim in
the old API as best as possible to make it compatible.

Notably, we were previously exporting APIs that end users do not need,
and I don't think it would ever occur to them to use, namely the whole
`AlgebraicValue` API and also the `AlgebraicType` API. In principle, no
one should have a need for these, although it was technically possible
for them to use it.

Indeed, we could potentially even just remove AlgebraicType completely
from the API by directly code generating the serialization code.

Listed below are all of the **BREAKING** changes to the API and their
effect:

- `AlgebraicType` is now a structural union literal type instead of a
class (nominal type), this is a consequence of generating the type with
our code gen. Users did not have a reason to use `AlgebraicType`
directly.
- The `AlgebraicValue` type has been removed entirely. This was
previously a class that was exported from the SDK, but very unlikely to
be used by users.
- The `ProductValue` type has been removed.
- The `ReducerArgsAdapter` and `ValueAdapter` types, which were used
with AlgebraicValues have been removed.
- Generated code has changed incompatibly so users will have to
regenerate code when upgrading to this version. Technically a breaking
change, but pretty easy to fix.

Listed below are the non-breaking API changes:
- I am now exporting generated product types as the default export in
addition to how I was exporting them before
- For generated sum type `T`, I am now exporting a `TVariants` namespace
which has the types of all the variants for `T`. This was previously
exposed on the namespace `T`, but was inaccessible in modules other than
the one it was defined in because I also export a type `T` in addition
to namespace `T` and in the type position `T` was being interpreted as a
type rather than a namespace. It's unclear why TypeScript resolved it as
the `T` namespace within the module in which is was defined previously.
Anyway, since the old types were apparently unobservable to users, I've
replaced them with the types in `TVariants`. (Open to other names for
this namespace).
- I fixed a bug where never types (sum types with no variants) were not
correctly generated.

# Expected complexity level and risk

3. The most complex thing about the PR are the potential impacts to the
API. I am reasonably certain, but not 100% certain that I have accounted
for everything above.

# Testing

- [x] I ran `pnpm test` which runs all the tests in the repo including
an integration test which tests the connection to SpacetimeDB. I also
fixed broken tests.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-09-03 21:12:14 +00:00
John Detter b4a839b544 Version upgrade to 1.3.2 (#3207)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

- Simple patch version bump. Because we forgot to bump the version
number for 1.3.1 this is bumping from 1.3.0 => 1.3.2

# API and ABI breaking changes

0

# Testing

- Verified that the version number in the license has been updated
- Verified the output of `spacetime --version`:
```
$ spacetime --version
spacetime Path: C:\Users\boppy\AppData\Local\SpacetimeDB\bin\current\spacetimedb-cli.exe
Commit: 0027d094e1
spacetimedb tool version 1.3.2; spacetimedb-lib version 1.3.2;
```

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-08-29 16:52:30 +00:00
Zeke Foppa f6f0909ea4 Update all licenses (#3002)
# Description of Changes

We recently merged several repos together. This PR clarifies the license
terms for several subdirectories, as well as the relationship between
the licenses.

The licenses in our subdirectories have become symbolic links to
licenses in our toplevel `licenses` directory. For any particular
subdirectory's license file in the diff, you can click `... -> View
file` and then click on the text that says "Symbolic Link" on that page.
This will take you to the license file that it links to.

I have also updated the `tools/upgrade-version` script to update the
change date in the new `licenses/BSL.txt` file.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

None. Only changes to license files.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-12 18:20:58 +00:00
Zeke Foppa e107144998 Bump versions to 1.3.0 (#3005)
# Description of Changes

Bumped all versions to 1.3.0 in preparation for an upcoming minor
release.

# API and ABI breaking changes

No breaking changes.

# Expected complexity level and risk

1

# Testing

None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-30 19:16:16 +00:00
Kim Altintop 08c2a3e2fe cli: Close the websocket connection gracefully (#2925)
The `subscribe` command would drop the connection without sending a
close frame. Doing so creates a warning on the server, which can be
distracting when debugging other connections issues.


# Expected complexity level and risk

1

# Testing

Use the `subscribe` command with a local database and compare server
logs before
and after.
2025-07-28 07:49:23 +00:00
Noa 742303ca49 Bump rust-toolchain to rust 1.88 (#2749)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-07-15 17:39:41 +00:00
Tyler Cloutier 013e268eb5 Fixed rename by using put instead of post (#2764)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-06-12 17:05:02 +00:00
Zeke Foppa 380acf14c8 Bump versions to 1.2.0 (#2837)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-06-06 16:17:24 +00:00
Zeke Foppa c3b0009758 Bump versions to 1.1.3 (#2828)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-06-04 17:39:15 +00:00
Viktor Szépe f6da9e1f5f Fix typos (#2812)
Signed-off-by: Viktor Szépe <viktor@szepe.net>
2025-06-04 16:33:32 +00:00
Zeke Foppa 2308c989fc Bump version to 1.1.2 (#2767)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-05-22 04:55:49 +00:00
Kim Altintop 1c33aa4e36 cli: Add value_parser for num-replicas (#2759) 2025-05-20 17:39:27 +00:00
Kim Altintop c729c2100d Reintroduce replication factor parameter (#2718) 2025-05-19 06:55:09 +00:00
Noa c5f1d8d0dd Use spacetimedb-standalone to get schema for spacetime generate (#2644) 2025-05-07 21:56:53 +00:00
Jeffrey Dallatezza 14ba750155 Add information about the CLI version to generated code. (#2673) 2025-05-01 21:17:30 +00:00
Noa 020d64c1f1 Split client codegen out into its own crate (#2593)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-29 17:54:25 +00:00
Jeffrey Dallatezza 228ec0c8d8 Add the primary key type to typescript's TableRuntimeTypeInfo (#2671) 2025-04-28 21:14:32 +00:00
james gilles eeb3333f1f Implement OnUnhandledReducerError in C# (#2636) 2025-04-23 22:38:58 +00:00
Jeffrey Dallatezza 69ec80331f Typescript Generation: Wrap union types in parens if for arrays (#2615) 2025-04-22 19:32:18 +00:00
Zeke Foppa 3083c1b83e Bump versions to 1.1.1 (#2658)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-22 19:20:17 +00:00
Jeffrey Dallatezza 9f09e8ac53 Use camel case for typescript unique indexes (#2628) 2025-04-21 17:58:02 +00:00
Zeke Foppa bf395a66a6 Bump a missed version (#2607)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-14 17:54:52 +00:00
Noa 68d23d4c25 Remove spacetimedb-core as a dep of cli (#2244) 2025-04-09 19:37:44 +00:00
Mazdak Farrokhzad c39f7fa64c Plain enums as index keys with specialized indices (#2506) 2025-04-09 18:52:15 +00:00
Mario Montoya 4ade692700 Update formatting of timestamps and identities in PsqlFormatter (#2486) 2025-04-02 16:53:27 +00:00
Mario Montoya 98395ca530 Print back the # of rows affected (ins, upd, del) with timings (#2462)
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-03-28 16:57:23 +00:00
Zeke Foppa c3c0d92fbe Bump versions to 1.1.0 (#2518)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-27 23:37:38 +00:00
Mario Montoya ee7970e752 Add .cargo/config.toml to spacetime init Rust project with default target to wasm (#2328) 2025-03-26 14:34:32 +00:00
Jeffrey Dallatezza a4a2925f12 Use jemalloc in standalone and add stats. (#2470) 2025-03-20 19:00:06 +00:00
Jeffrey Dallatezza 872a8d839c When generating for typescript, convert the primary key to camel case. (#2409) 2025-03-12 22:14:12 +00:00
Phoebe Goldman e67b5f8565 Fix outdated advice in getrandom warning (#2444) 2025-03-12 15:55:22 +00:00
Zeke Foppa 8930e78f97 Bump versions to 1.0.1 (#2431)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-11 18:43:48 +00:00
Zeke Foppa ba971ae440 CLI - Fix sql --interactive case where returned rows are 0 (#2359)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-11 17:00:35 +00:00
Noa 74661be0c2 Clarify what is a valid module name (#2386) 2025-03-07 19:21:19 +00:00
Zeke Foppa 6acd881115 CLI - Fix helptext for --build-options (#2349)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-05 19:04:43 +00:00
Zeke Foppa 20f4bfbd21 Bump Rust and C# package versions to 1.0.0 (#2283)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2025-02-28 20:13:07 +00:00
james gilles 4fc4963f21 Final C# codegen changes (#2303) 2025-02-25 18:57:45 +00:00
Mazdak Farrokhzad b34caf8306 Rust SDK: Deduplicate rows accross queries (#2286)
Signed-off-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-02-21 21:12:29 +00:00
Jeffrey Dallatezza fc71275a46 Fix some typos in the ts code gen. (#2287) 2025-02-21 19:10:58 +00:00
Zeke Foppa 4665c5243c CLI - Add feature to print markdown docs (#2276)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-02-19 04:33:07 +00:00
Zeke Foppa 0162acebdd CLI - Remove newlines from command helptext (#2277)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-02-18 23:24:38 +00:00
james gilles 2f30dc1c2c C# SDK - Emit Event.UnknownTransaction rather than throwing on unknown reducer (#2241) (#2249) 2025-02-11 21:54:06 +00:00
Tyler Cloutier 03fda01fb9 Implemented error arguments in error callbacks (#2229) 2025-02-11 15:48:05 +00:00
Noa 6a8375260f Refactor HTTP api to better adhere to REST guidelines (real) (#2243) 2025-02-11 02:59:45 +00:00
Zeke Foppa 6fc5ce44d7 CLI - Default config lists maincloud, not testnet (#2237)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-02-11 02:46:39 +00:00
Tyler Cloutier d191b8561b DBConnection -> DbConnection for the TypeScript API (#2230) 2025-02-11 02:14:02 +00:00
Noa cf6822541f Remove janky schema from http API (#2181) 2025-02-11 00:56:07 +00:00
Jeffrey Dallatezza c2d40f86fb Add metrics for index inserts and deletes (#2236) 2025-02-10 21:34:02 +00:00
Noa d43548b1de Fix confusing csharp workload-install error message (#2238) 2025-02-10 20:31:11 +00:00
Phoebe Goldman aedc601145 Rename Address to ConnectionId (#2220)
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-02-10 00:40:16 +00:00