Commit Graph

50 Commits

Author SHA1 Message Date
Tyler Cloutier 46f3e07dfc Fixes issues with --delete-data=on-conflict (#3730)
# Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/3729

I genuinely don't know what came over me.

# API and ABI breaking changes

None

# Expected complexity level and risk

1.5 very straightforward but not strictly trivial

# Testing
Adds automated integration tests (written in Rust and run with `cargo
test`, although note this comment from @matklad about integration tests
for the future
https://internals.rust-lang.org/t/running-test-crates-in-parallel/15639/2):

- [x] Can publish an updated module if no migration is required
- [x] Can publish an updated module if auto-migration is required (with
the yes-break flag true/false)
- [x] Cannot publish if a manual migration is required
- [x] Can publish if a manual migration is required but the user
specified `--delete-data`
- [x] Can publish if a manual migration is required by the user
specified `--delete-data=on-conflict`
- [x] No data deletion occurs if no migration is required and
`--delete-data=on-conflict` is specified

---------

Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-12-04 21:45:41 +00:00
Kim Altintop a36f7091d5 [teams 3/5] API authorization, CLI, smoketests (#3523)
This adds authorization to the relevant API endpoints, updates the CLI
commands and adds smoketests for the teams feature.

**Note**: Authorizing SQL (incl. subscriptions) is a bit more involved,
and submitted as a separate PR in the series.

Depends-on: https://github.com/clockworklabs/SpacetimeDB/pull/3519
2025-11-11 14:10:58 +00:00
Piotr Sarnacki b2cee93b52 New command: spacetime dev (#3469)
# Description of Changes

This PR implements a new command for the CLI: `spacetime dev`. If run
from outside of a project directory, it will call `init` in interactive
mode to allow user to create a project. If run from a project directory,
it will ask for a module to conect to and it will:

* subscribe to logs
* observe files in the `spacetimedb` directory and automatically publish
to SpacetimeDB

One caveat is that instead of reusing the `logs` code I did some
repetition cause currently the logs code acquires a lock that lives
through await points. It is fixable, but due to limited time I decided
to go with a bit of code duplication. It shouldn't be very hard to fix
later, though.

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-10-30 21:04:29 +00:00
Piotr Sarnacki 647be7e9c0 spacetime init rewrite (#3366)
This is a draft of the new functionality for `spacetime init`. In order
to run it with built-in templates you have to set the path to the config
file:

```
export SPACETIMEDB_CLI_TEMPLATES_FILE=crates/cli/.init-templates.json
```

In the future it will fetch the list from GH.

A few notes:

* the previous functionality of `spacetime init` does not work at the
moment
* the code needs a bit more cleanup and tests before merging
* there is a bit of a mix in how we generate empty server and client
projects. For Rust we use the existing way of generating. For TypeScript
we clone an empty project from the repo. I wanted to play with both ways
of doing things, and I'm still not sure which is better. Generation in
Rust means that the generated code will match the CLI version and not
necessarily whatever is in Git. On the other hand, for the builtin
templates we will be fetching the newest version from GH, which I guess
might also not what we want, ie. we probably want only stable templates.
More discussion is needed here
* we use `spacetimedb` directory for the server files
* I don't particularly like the inability to disable interactive mode
easily. We discussed disabling it by default if all of the required
arguments are passed, but I don't think it's feature proof. For example,
if someone relies on a non-interactive mode, and we add a new required
argument, instead of printing a message `missing --foo`, we will
automatically launch interactive mode, which is harder to debug. That's
why I think I'd prefer to implement `--non-interactive` argument
* it's kind of hard to keep the legacy behaviour. If you don't pass any
arguments, we go into interactive mode. In the legacy version, we would
print required arguments. If someone passes `--lang` or `--project-path`
explicitly, I guess we could run the legacy workflow, but not sure if
it's worth it, as the command was marked as unstable anyway
* the project path defaults to the project name, but I think we should
probably replace change whitespaces to dashes, or at least ask for the
project path with the project name being the default (or both)

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-10-30 04:26:08 +00:00
Noa bb43213245 Typescript module API (#3327)
# Description of Changes

Currently based on #3361 

Implements most of the TS module API (not yet a function for type
aliases).

# Expected complexity level and risk

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] Extremely basic module stuff works
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->

---------

Signed-off-by: Noa <coolreader18@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-16 14:58:50 +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
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
Noa 68d23d4c25 Remove spacetimedb-core as a dep of cli (#2244) 2025-04-09 19:37:44 +00:00
Jeffrey Dallatezza a4a2925f12 Use jemalloc in standalone and add stats. (#2470) 2025-03-20 19:00:06 +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
Noa 6a8375260f Refactor HTTP api to better adhere to REST guidelines (real) (#2243) 2025-02-11 02:59:45 +00:00
Ingvar Stepanyan 88090ec73a Rewrite C# codegen to the new Lang infra + fixes (#2184)
Co-authored-by: James Gilles <jameshgilles@gmail.com>
2025-02-05 22:07:45 +00:00
Noa fbb5c9ecdc Fix ctrl-c handling (#2200) 2025-02-04 20:08:22 +00:00
Kim Altintop 73fe4ef2f7 Set tracing static level for binaries only (#2144) 2025-01-22 20:13:52 +00:00
Zeke Foppa a54ea3a391 CLI - Replace clippy with a manual check (#1928)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-01-17 00:03:11 +00:00
Noa c24042609e Split binaries (#2011) 2025-01-15 18:45:14 +00:00
Mario Montoya df58e84eba Preserve the comments of the "cli.toml" on changes (#2002)
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
2025-01-03 20:52:15 +00:00
Noa f136670420 Directory structure impl (#1879)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2024-11-12 04:24:43 +00:00
Zeke Foppa 61360387be CLI - Login flow (#1878)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-10-29 20:28:45 +00:00
Ingvar Stepanyan 607f7ce6b8 Auto-generate C# ModuleDef bindings from Rust (#1680) 2024-09-09 18:22:17 +00:00
james gilles 45b2ceee9a Move schemas to schema crate, rename Def to RawDefV8 (#1498) 2024-07-24 17:38:30 +00:00
Noa 10b151b999 Protobufectomy: server (#1077)
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Jeremie Pelletier <jeremiep@gmail.com>
2024-07-12 18:02:18 +00:00
Noa 66112bbdf0 Impl subscribe subcommand & subscription smoketests (#1343)
Signed-off-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Kim Altintop <kim@eagain.io>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-06-14 09:16:05 +00:00
Phoebe Goldman db34ff6a8e Create new crate fs-utils; move Lockfile and create_parent_dir (#1334)
* Create new crate `fs-utils`; move `Lockfile` and `create_parent_dir`

The snapshot crate will need to create lockfiles.
Rather than duplicating code to do so, we choose to move our definition of `Lockfile`
into a crate that can be depended on by both `cli` and `snapshot`.
No existing crate seems like an obvious choice for this
-- a `Lockfile` is not really a data structure, so `data-structures` seems wrong --
so we add a new crate, `fs-utils`.
Currently this contains only `Lockfile` and `create_parent_dir`,
but a follow-up PR will add `DirTrie`, a Git-like on-disk object store.

* Deduplicate `map_err` closure

* Zeke's nit: simplify control flow

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>

---------

Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2024-06-04 16:57:28 +00:00
Ingvar Stepanyan 45f6cd6f0c Fix codegen tests (#1146)
While working on the new C# codegen, I accidentally noticed that those tests were passing even when they clearly should've been failing due to changed output.

After running with `--nocapture`, I found out it's because the tests are silently skipped and reported as successful when `rust_wasm_test.wasm` isn't built.

This further led to finding that `rust_wasm_test.wasm` is never built - the relevant module results in `rust_wasm_test_module.wasm` instead - so these tests have been incorrectly passing for ages.

This PR changes them to actually build the module as part of testing and updates the snapshots to latest master.
2024-04-24 14:03:03 +00:00
Noa abdaf88563 Move lib::{name,recovery} to client-api-messages (#570) 2024-04-10 20:24:05 +00:00
Mazdak Farrokhzad 344861f290 use nohasher_hash and ahash instead of siphash13 (#1040)
* use nohasher_hash and ahash instead of siphash13

* re-export types in spacetimedb_data_structures::map
2024-04-05 17:30:51 +00:00
Mario Montoya ffc3caedeb Show the error text of the server when a sql call fails on cli (#1004) 2024-03-21 20:23:51 +00:00
Noa 37658aae7e Add rust-version to Cargo.toml (#802)
* Add rust-version to Cargo.toml

* Use workspace inheritance to make bumping the spacetime version easier
2024-02-07 20:02:05 +00:00
Mazdak Farrokhzad a68ad8f85f add ColList: a compact repr of NonEmpty<ColId>, 8 vs 32 bytes (#730) 2024-01-19 23:44:19 +00:00
John Detter 8524d244f3 Version upgrade to 0.8.1 (#729)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-01-18 18:16:58 +00:00
Noa f8296c0281 Add timestamp to module logs (#641)
* Add timestamp to module logs

* Update tests
2023-12-09 00:01:55 +00:00
John Detter 79ff6dffc6 Version upgrade to 0.8.0 (#622)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-04 13:19:25 -06:00
Mario Montoya b3ccc13dab Refactoring IDs for system objects (#439)
* Refactoring IDs for system objects

* fixup

* Fix stray constraints text on refactor

* Fix conflict

* Merge

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-15 10:21:20 -05:00
John Detter dff23de939 Version upgrade to v0.7.3 (#536)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-11-07 21:55:14 -06:00
John Detter 331b1d8943 Spacetime Upgrade (#339)
* Upgrade command

* Lints

* Working on upgrade command

* More improvements - testing now

* Rebasing on master

* Download spinner is working properly

* More UX improvements

* Small fix

* Small fix for Linux

* Small change to upgrade, much cleaner now

* Fixes for windows

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-10-30 23:22:22 -07:00
John Detter b35e184051 Version Upgrade to v0.7.2-beta (#498)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-30 16:53:06 -05:00
Ingvar Stepanyan 0a55646773 Switch allocator to mimalloc for the DB CLI (#447) 2023-10-19 19:22:55 +00:00
John Detter 5864bfa8d7 Version upgrade: v0.7.1-beta (#441)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-17 16:57:36 -07:00
John Detter de43e96b11 Version Upgrade to 0.7.0 (#355)
* Saving because I'm testing writing files

* New upgrade program working quite well

* Update license file as well

* Tool seems good to go

* Cargo check is passing, new upgrade-version is ready, old version
removed

* Updating lock file is required for CI to pass

* main.rs clippy lints

* More sensible default

* Version upgrade to 0.7.0 via new version-upgrade util

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-10-03 22:27:11 +00:00
Phoebe Goldman a1e9984840 Multiple server configurations for CLI (#214)
Alters the CLI's configuration format to support storing multiple server configurations,
and having each server configuration store an (optional) default identity.
Many CLI commands take an additional -s argument, the server on which to operate,
which defaults to the configured default_server.
Using -s consistently requires renaming the publish skip-clippy short flag to -S.

Per discussion with @jdetter , this PR does not directly associate identities with servers.
Instead, each server configuration stores the server's "fingerprint" (i.e. PEM-formatted ECDSA public key),
and the CLI uses that public key to decode tokens to determine if they apply to a given server.
This architecture allows the CLI to behave reasonably
when multiple server configurations use the same set of tokens,
e.g. if multiple distinct URLs resolve to the same SpacetimeDB instance.
For example, one could imagine a configuration with server configurations for both http://127.0.0.1:3000
and http://localhost:3000, which should use the same set of identities.
2023-09-01 17:29:20 +00:00
George Kulakowski 66a8f22e94 Remove the bitrotted trace replay functionality (#219)
* Remove the bitrotted trace replay functionality

* cargo fmt

* Remove unused tracelogging feature from ci actions

* Remove unneeded clone
2023-08-22 21:29:05 +00:00
John Detter 116bdee090 Version upgrade to 0.6.1 (#180)
* Version upgrade to 0.6.1

* Upgrade version used by CLI

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-12 08:56:28 -07:00
Mario Montoya 80a0a29704 Move cargo deps to the workspace (#172)
* Moving deps to workspace

* Merge
2023-08-11 15:24:31 -07:00
Tyler Cloutier 3e0caff415 Updated version to 0.6.0 2023-08-03 01:39:03 +02:00
John Detter 0f63e70694 spacetime start 2 (#125)
* spacetime start

README revert

Reverted stuff that shouldn't have changed

* Build fix

* Cargo fmt

* Cargo clippy

---------

Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-02 11:21:49 -05:00
Mario Montoya 300e9050a1 Remove implicit transactions and thread the Tx instead (#65)
* Remove implicit transactions and thread the Tx instead

* Split logic for proper Tx handling
2023-08-01 23:17:03 +02:00
John Detter 41dc128533 Upgrade Version to 0.5.0 (#47)
* Committing version upgrade script

* Fixes to the upgrade script

* Upgrade version to 0.5.0

* Update Cargo.toml

No longer optional

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>

* Fixed small issue in the version upgrade script

---------

Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
2023-08-01 23:17:02 +02:00
Mazdak Farrokhzad b2e4d371e8 CLI: Improves errors for call + misc refactoring (#45)
* cli: refactor + improve call errors

* cli: improve call errors

* cli: simplify tasks

* misc improvements

* cargo fmt + clippy
2023-08-01 23:17:02 +02:00
Tyler Cloutier 44df6c6e7d Initial commit 2023-08-01 23:16:37 +02:00