Commit Graph

199 Commits

Author SHA1 Message Date
Jeremie Pelletier 3e6f91be89 Moving recovery code APIs under /identity and using POST (#1492)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-07-17 13:24:23 +00:00
Shubham Mishra 276387d2b3 Timer Table Implementation (#1449)
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2024-07-16 08:38:56 +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
Ingvar Stepanyan 6f0f20bf7a Restructure C# SpacetimeDB runtime (#1455) 2024-07-12 17:12:21 +00:00
Zeke Foppa 3266aa4ebe CLI: Use --server and --identity args consistently instead of anonymous args (#1482)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-07-10 17:48:49 +00:00
Zeke Foppa e913e8cd26 CLI: Put some common params in a central place (#1484)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-07-09 13:40:05 +00:00
Zeke Foppa b2eb08c9cb Fix C# module smoketests (#1475)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-07-04 12:48:41 +00:00
SteveBoytsun 81085b0817 Fixed exceptions in C# SDK when someone disconnects or when a transaction originates from CLI (#1461)
Co-authored-by: Steve Boytsun <steve@clockwokrlabs.io>
2024-06-26 17:39:12 +00:00
Zeke Foppa 637a6547d9 CLI - Update help text suggesting spacetime server fingerprint to have the correct -s param (#1457)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-24 18:42:05 +00:00
Ingvar Stepanyan 137f26da5f Restructure NuGet packaging (#1440)
Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2024-06-18 19:48:46 +00:00
Zeke Foppa dcc70b82f2 Bump version to 0.10.1 (#1443)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-17 23:34:13 +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
Ingvar Stepanyan 4b7eff66da Generate tagged enums in C# client code (#1421) 2024-06-13 16:32:46 +00:00
Mario Montoya 114aa994bf Fix output of binary, Identity, Address for SQL output and the 'Display' of them to show a full hex value (#1087) 2024-06-10 16:49:46 +00:00
Zeke Foppa 2d09485f74 Bump version to 0.10.0 (#1349)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-10 16:25:02 +00:00
Ingvar Stepanyan d1033b5d93 Shared C# codegen for BSATN (#1312)
Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
Co-authored-by: james gilles <jameshgilles@gmail.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-06-07 19:22:02 +00:00
Zeke Foppa b06b2e59f1 Fix bug with Lockfile sticking around (#1341)
* [bfops/fix-config-lock]: do thing

* [bfops/fix-config-lock]: review

* [bfops/fix-config-lock]: review

* [bfops/fix-config-lock]: fix

* [bfops/fix-config-lock]: TODOs

* [bfops/fix-config-lock]: review

* [bfops/fix-config-lock]: review

* [bfops/fix-config-lock]: review

* [bfops/fix-config-lock]: review

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-06-05 22:40:24 +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
Mazdak Farrokhzad 5e47b61f8a Tables only become public explicitly via #[spacetimedb(table(public))] (#1278)
* make user tables private by default and define privacy via attribute

* switch to spacetimedb(table(public)) syntax

* accept codegen snap changes

* sdk: use public in define_tables!

* bindings-macro: adjust some doc comments

* sdk-test-connect-disconnect: make Connected/Disconnected public tables

* Make Public Private again
2024-06-03 11:22:58 +00:00
Noa f8beb699c7 Implement new rand api (#1283)
* Implement new rand api

* Address comments
2024-05-31 17:42:58 +00:00
Ingvar Stepanyan 9e1e66f708 Fix FilterBy regression in C# (#1309)
* Fix FilterBy regression in C#

Fixes regression accidentally introduced in #1277: if FindBy returns null, FilterBy will return an iterable with a single null item instead of an empty iterable.

* Fix snapshots
2024-05-31 17:40:26 +00:00
Zeke Foppa 0bc42bfe48 Bump version to 0.9.3 (#1224)
* [bfops/bump-version]: empty

* [bfops/bump-version]: version bump

* [bfops/bump-version]: update

* [bfops/bump-version]: bump C# module versions too

* [bfops/bump-version]: bump 0.9.3

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-29 17:22:51 +00:00
Mazdak Farrokhzad c8225db8f5 1. Reduce visibilities, preparing to extract datastore crate (#1306)
2. More direct imports, preparing to extract datastore crate
3. Remove some dead code
2024-05-28 17:46:07 +00:00
Zeke Foppa 3b33f22c07 CLI - Drop Config lock earlier for spacetime logs (#1303)
* [bfops/lockfiles]: do thing

* [bfops/lockfiles]: empty

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-28 16:08:09 +00:00
Zeke Foppa be74474721 CLI - Fix Lockfile error message format strings (#1302)
* [bfops/lockfile-err]: do thing

* [bfops/lockfile-err]: empty

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-28 16:05:05 +00:00
Ingvar Stepanyan ac0c097f3d Implement consistent filtering rules for TypeScript (#1276)
- Limit types to those defined in the consistent filtering proposal (#1256).
- Make `filterBy` a lazy iterable for consistency and performance reasons.
- Add `findBy` for unique fields as per proposal.
2024-05-28 14:23:25 +00:00
Ingvar Stepanyan 307dfeebd3 Update C# codegen to consistent filtering rules (#1277)
* Update C# codegen to consistent filtering rules

- Limit types as per proposal.
- Add `Query` client-side SDK helper for API parity with server-side modules (on client-side it's a simple wrapper around Iter + Where).
- Change return type of `FilterBy` to always be iterable, with new `FindBy` function for unique fields.
- Simplify the way primary keys are handled - must go with https://github.com/clockworklabs/spacetimedb-csharp-sdk/pull/93 for the client SDK counterpart.

* Add using for System.Linq

* Update snapshot
2024-05-28 14:22:12 +00:00
Ingvar Stepanyan f5a13b6f26 Consistent filtering in Rust client + minor fixes (#1275)
* Extend codegen tests to Rust

* Replace cursive-chat module_bindings with symlink

* Implement consistent filtering rules for Rust

* Fixup

* Regenerate tests

* Fix non-deterministic import order

* cargo fmt

* Fix chat examples

* Change symlinks to files themselves

* Revert accidental change

This needs to wait for server-side API break to be implemented as well.
2024-05-28 13:02:25 +00:00
Zeke Foppa 8096ab657d fix(1297): spacetime logs -f should not start at the very beginning (#1298)
* [bfops/logs-f]: do thing

* [bfops/logs-f]: empty

* [bfops/logs-f]: review

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-28 00:40:39 +00:00
Ingvar Stepanyan c665503eb5 Remove unreachable branches from C# generate (#1247)
These branches are already inside of `if is_unique {} else { ... }` branch, so `is_unique` can never be `true`.
2024-05-18 01:55:35 +00:00
John Detter f13a1433f0 Make identity naming more consistent + fix bugs (#1140)
* Prevent importing an identity with a name that already exists in the
config

* Make identity naming more consistent

* Fix clippy lints

* Several bug fixes and UX improvements

* Prevent someone from adding the same identity twice

* Fix lint

* [jdetter/make-identity-naming-more-consistent]: review

* [jdetter/make-identity-naming-more-consistent]: review

* [jdetter/make-identity-naming-more-consistent]: review

* Reverted file

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-14 16:38:42 +00:00
Zeke Foppa 8ab55d2f59 spacetime publish: Add confirmation for -c (#1038)
* [bfops/confirm-publish-clear]: spacetime publish: add confirmation for -c

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: rename

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: fix?

* [bfops/confirm-publish-clear]: fix smoketests

* [bfops/confirm-publish-clear]: review

* [bfops/confirm-publish-clear]: fix rest of smoketests?

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-14 16:34:20 +00:00
Zeke Foppa 08ecaf8569 [bfops/cli-identity-refactor]: do thing (#1169)
Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-14 06:17:48 +00:00
Zeke Foppa c7f191fb5d Bump version to 0.9.0 (#1055)
* [bfops/bump-version]:

* [bfops/bump-version]: bump lockfile

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-05-13 18:28:17 +00:00
Phoebe Goldman f6573c444e Create a lockfile when opening config files (#1196)
* Create a lockfile when opening config files

In the past, we've had issues where multiple concurrent CLI processes
would race to read and write the CLI config file,
leading to data loss.

We considered using `flock`/`LockFileEx` and blocking until the file became available,
but unfortunately it's not possible to atomically create and lock a nonexistent file,
which we need to do in the case where the configuration doesn't yet exist.

Instead, we opt for a classic lockfile-based scheme:
Before opening a config file `foo.conf`, attempt to exclusively create `foo.lock`,
and panic if the exclusive creation fails.
Once it becomes clear that we will not write the config any more,
i.e. in `Config::drop`,
delete the lockfile, allowing another process to operate.

This means that attempting to run multiple concurrent Spacetime CLI processes
with the same config file is now a hard error.

* Fix CI failures

This commit fixes two CI failures:

- `spacetime start`, and a few other CLI subcommands, do not access their `Config` at all,
  but the CLI constructs it unconditionally in `main`,
  which made it an error to run any CLI command while `spacetime start` was running.
  This is fixed by having subcommands which don't need a `Config`
  drop it before doing anything.
- Contrary to my assumption,
  the test configuration created by `Config::new_with_localhost` does get `drop`ped,
  because the test harness `clone`s is and passes an owned version to the CLI.
  This was causing it to attempt to delete the empty path, which failed.
  This is fixed by having the home configuration be `Option`al,
  and setting it to `None` in tests.

* Clap before config because they suppress destructors

Perform Clap argument parsing as the very first thing in a CLI process,
before locking the config,
because Clap calls `exit` directly on error rather than panicing
(presumably to have more control over error output),
which prevents destructors from running,
leaving stale lockfiles.

* Encapsulate lockfile logic in a type

Also deduplicate logic for finding config file paths.

* Define `create_parent_dir` helper with comments

* Replace `drop` calls with more explicit `Config::release_lock`.
2024-05-13 18:22:54 +00:00
Ingvar Stepanyan e252b0cf63 Remove RowUpdate event from C# (#1190)
We talked about this for a while, so decided to do this in a separate PR.
2024-05-10 21:41:16 +00:00
John Detter b275dbfee8 spacetime build uses --project-path param (#1212)
* `spacetime build` uses `--project-path` param

* Fix smoketests

* Another small fix

* Another fix

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-05-09 16:56:43 +00:00
Ingvar Stepanyan 165f750d73 Remove C# GetArgsAsObjectArray (#1188)
* Remove C# GetArgsAsObjectArray

This is a weird "duck-typed" API that has one usage in BitCraft, but it's easy to replace with either real reflection or strong-typed interfaces.

* Update csharp.rs

Signed-off-by: Ingvar Stepanyan <me@rreverser.com>

---------

Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
2024-05-03 01:48:05 +00:00
Ingvar Stepanyan 27a7b67608 NFC: reuse common parts of C# generation (#1187)
Reuse the `indented_block` helper more and add new `CsharpAutogen` helper structure for consistent header / footer structure and reduced boilerplate.
2024-04-30 18:31:36 +00:00
Dylan Hunt d2b98e0b19 doc: Link directly to cargo install on missing (#1102) 2024-04-29 12:22:35 -05:00
Ingvar Stepanyan 175ca25504 NFC: inline format args in generate code (#1153)
CLI `generate` code is a particularly heavy user of format-based macros, and so it benefits most from inlining format args where possible.

This is done by adding `#![warn(clippy::uninlined_format_args)]` + running `cargo clippy --fix` followed by `cargo fmt`, so shouldn't require manual review.

This is a follow-up to #1142 and, like that PR, is mainly done to make generate's code a bit cleaner and diffs simpler.
2024-04-25 23:03:41 +00:00
Dylan Hunt 20856910ba CLI - Set default server to testnet (#1078)
* refactor!: Change DEFAULT_HOST_NICKNAME to "testnet"

- from "local"
- Suggested by Tyler

* refactor!: Change more const to default testnet srv

* [bfops/tests-use-explicit-server]: fix?

* [bfops/tests-use-explicit-server]: empty

* [dylan/refactor/set-default-server-to-testnet]: fix?

* [bfops/default-server-inline]: do thing

* [bfops/default-server-inline]: fix

* [dylan/refactor/set-default-server-to-testnet]: fix

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-04-25 05:12:54 +00:00
Zeke Foppa a6d81dc0ac CLI - Small refactor to default server configs (#1151)
* [bfops/tests-use-explicit-server]: fix?

* [bfops/tests-use-explicit-server]: empty

* [bfops/default-server-inline]: do thing

* [bfops/default-server-inline]: fix

---------

Co-authored-by: Zeke Foppa <github.com/bfops>
2024-04-25 03:00:10 +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
Ingvar Stepanyan d3db4a12ef Reduce unwrap noise in CLI generate code (#1142)
This adds a non-fallible `write_fmt` method to `CodeIndenter<String>` (since we know it should never fail), which allows to use `write!` and `writeln!` without `.unwrap()` everywhere, making code a lot less noisy.
2024-04-24 14:03:01 +00:00
John Detter 2712844484 Fixes an inconsistency issue with spacetime server fingerprint -s <server> (#1131)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 16:04:15 +00:00
John Detter 06f766fd70 Use -s to specify server for spacetime identity list -s <server> (#1130)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 16:04:03 +00:00
John Detter 64fe230b69 Build uses -S for skip clippy (#1129)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2024-04-22 15:57:22 +00:00
Kim Altintop dcfbf685c8 cli: Suggest to make new identity the default for server (#1109)
When a server key rotation is suspected, suggest to make the new
identity the default.

This usually happens during development using an ephemeral instance. If
one follows the instructions, the `default_identity` is not set for the
existing server, which makes the CLI generate a fresh identity every
time.

See also: #333
2024-04-19 10:12:01 +00:00
Mazdak Farrokhzad d6815ebf9c Shrink AV and AT to 24 & 16 bytes respectively, and also friends. (#1047) 2024-04-13 16:51:18 +00:00