* Working on improving commands that use identities
* Fix lints
* Reverted file that shouldn't have changed
* Found and fixed all other todos
* Addressed more CLI TODOs
* Fixes for formatting issues
* Set names of identities
* Set name of identities + clippy
* Small fix
* Added the start of a doc comment, switching over to another PR
* Fixed tests that needed to be updated
* Addressed more feedback and fixed several clippy issues
* Small fix
* Apply suggestions from code review
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
* Added more doc comments
* Addressing more feedback
* Fixed really old bug in SpacetimeDB
* Tests to verify new functionality
* Fix clippy lints
* Email during identity creation is optional
* Some work
* Getting smoketests working on mac
* All tests are passing except known failing tests
* Working on parallel smoketests
* Fixed some bugs in saving configs that was preventing this from working
* Fixes required for parallel tests
* Tests are working in parallel
* Pruned changes
* retab
* re-retab
* retab the lib file
* Cargo profile for building more quickly
* I have to rebase on another PR
* smoketest fixes
* create_project and reset_project are now the same thing, removed
create_project
* More fixes
* Removed print statement
* Small fix
* Another fix
* Tons of improvements to the smoketests
* Have to rebase on master
* Small fixes
* More progress
* Finally working correctly!
* Apparently we're missing this
* Enable command output
* Listing installed targets
* Clean before building
* What is going on
* Something super wonky going on
* Another test
* Skip building containers for now
* Small fix
* Test using cargo instead
* Changed workflow a bit
* CI is stuck
* Small fix
* Another fix
* Try cargo run instead of building spacetime CLI
* Removed workflow step
* Fixing all of the tests
* Identity test
* Tests should finally be working
* Enable debug
* Remove spacetime from path
* Another try
* Logic fix
* Another fix
* Another fix
* Working now?
* Another fix
* Finally working again
* Adding github containers back in
* CI fix
* Use SpacetimeDB Large Runner
* Updated test to get more output
* Changed 0ms to 10ms to improve parallel test stability
* Removed unused logs
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
* Removed unnecessary reset_project
* Removed reset_config where its not needed
* Reset template
---------
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
* SDK: Convert `http[s]` uri schemes to `ws[s]`
Prior to this commit, the Rust SDK would reject host URIs which began with `http://` or
`https://`, requiring exactly one of `ws://` or `wss://`.
Now, the SDK converts `http` URI schemes to their websocket equivalents,
so clients can do `connect("http://localhost:3000", "my-database", my-creds)`.
* SDK: Append `Args` suffix to generated reducer args structs
This reduces the liklihood of name collisions,
e.g. when a user has both a table `Guess` and a reducer `guess`.
Prior to this commit, in that case, the SDK would generate
a `struct guess::Guess` for the table, and
a `struct guess_reducer::Guess` for the reducer args.
Now, the latter is `struct guess_reducer::GuessArgs`.
This will allow the CLI's codegen to re-export all generated structs
from its main `mod.rs` file.
* SDK: generated `mod.rs` re-exports all other files
The `mod.rs` generated by `spacetime generate --lang rust`
now re-exports all of the types and functions
defined in other files it generates.
This allows users to write e.g. `spacetime_types::Player`,
rather than `spacetime_types::player::Player`.
Prior to this commit, it was possible for a module to crash SpacetimeDB
by scheduling a reducer with a delay longer than ~2yrs.
This was due to our use of `tokio_utils::time::DelayQueue` to handle scheduling.
`DelayQueue`'s internal data structure imposes a limit of 64^6 ms on delays,
a little more than two years.
Attempting to insert with a delay longer than that panics.
With this commit, we avoid the panic by checking ourselves that the requested delay
is not longer than 64^6 ms.
This requires bubbling a `ScheduleError` up from `Scheduler::schedule`
to `WasmInstanceEnv::schedule`, where it is converted into a `RuntimeError`
which crashes the module.
`Scheduler::schedule` could also fail because its transaction to compute a new id
was fallible. This seems unlikely to ever fail, and if it does, we have bigger problems,
so `unwrap`ping might still be reasonable for that case,
but this commit converts it into a handle-able `Err`or anyway,
as there's essentially no cost in complexity to doing so.
* Added commands for spacetime server list and spacetime server ping
* Small fix
* Updated test
---------
Co-authored-by: Boppy <no-reply@boppygames.gg>
* SDK: Correctly encode auth header, and ser/de `Credentials`
Prior to this commit, the Rust SDK incorrectly encoded a `Token` passed to `connect`,
making it impossible to re-connect an existing user.
(Shows what I get for never testing that.)
With this commit, auth tokens are correctly base64-encoded
in an `Authorization: Basic` header with the username `token`,
which allows re-connecting as an existing user.
Also, it was difficult to re-use `Credentials` from the Rust SDK, as:
- they were opaque types with non-exported members
- they did not implement any serialization / deserialization
This commit makes `token.string` and `identity.bytes` public fields,
and implements SATN `Serialize` and `Deserialize`
for `Identity`, `Token` and `Credentials`,
allowing clients to save their credentials for re-use, e.g. to a file.
* SDK: Handful of small changes
- `subscribe_owned` accepts `Vec<String>`; behaves like `subscribe`.
- While developing `letrs`, a demo game, we needed to generate query strings at runtime,
and passing them to `subscribe` would have involved an unergonomic dance
of taking references which would then be converted to owned containers
by the SDK.
`subscribe_owned` eliminates that, allowing client authors
to construct a set of queries at runtime and pass it directly to the SDK,
without intervening referencies and copies.
- Docstrings for `subscribe` and `subscribe_owned`.
- Methods on `Identity` and `Token` for converting to/from strings and byte-vectors.
- Removed long-forgotten `println` within `connect`
which wrote the computed URI to stdout.
* Script for publishing crates to crates.io
* Added sdk to the publish-crates script, renamed client-sdk to sdk
* Updated Cargo.lock and added 2 crates to the upgrade version script
* Small fix
* Actual fix
* Updated client API messages crate to be publishable
* Added LICENSE file to sdk
* Chose specific version for tokio-tungstenite
---------
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
* Initial bootstrap for private tables
* Separate Access (private, public) for kind o table (system, user)
* Validates the access to private tables
* Check auth for drop table
* [TypeScript] Remove entries from filtering
In the TypeScript SDK we keep "entries" - an algebraic value of records.
I added them because they were also used in the C# SDK, but we don't
really need them. This commit changes generated filtering functions so
that they compare actual instances instead of product values.
* Fixes the restart problem (i.e. rebuilding the datastore from the message log)
* Remove logging
* Enable restart tests
* Fixed small issues with tests
* Fixed restart-repeating-reducer test probably
---------
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
With this commit, module-side `filter_by_{non-unique-field}` methods will use an index on the non-unique-field, if one exists.
This is accomplished by altering `query::filter_by_field` to call `iter_by_col_eq` (formerly `seek_eq`), and having the returned `FilterByIter` gradually deserialize the returned buffer in a `Cursor`.
* Change NetworkManager to SpacetimeDBClient
* Update csharp gen for ReducerEventBase
* More fixes for ReducerEventBase
* Remove commented out code
---------
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
* `ReducerEvent` enum in Rust client SDK
With this commit, row callbacks (`on_insert`, `on_delete`, `on_update`)
in the Rust client SDK take an additional argument,
`Option<&ReducerEvent>`, where `ReducerEvent` is an enum
generated by the CLI's codegen
with a variant for each reducer defined in the module.
Having the SDK pass around an autogenerated type in this way
(without adding a bunch of `<ReducerEvent>` generic parameters everywhere)
requires storing the `ReducerEvent` in an `Arc<dyn Any>`.
This has the added tangential benefit of avoiding cloning the `ReducerEvent`
for each row callback.
When running `spacetime generate` on a module which fails to compile,
the last line of the output is now a human-readable error message
which includes the module path and instructions to review the build errors.
`IndexDef` contains a table id, which is not yet known (i.e. zero) when
constructing `TableDef` from the module describers. But it /is/ known
for the schema obtained from the database catalog, so schemas compare
inequal even if they're structurally equivalent.
Fixed by just updating the proposed schema for known tables before
comparing. Also update the smoke test to contain an indexed column.
Prior to this commit, callbacks in the Rust client SDK shared access to the global
ClientCache while running asynchronously. This meant that a long-running or delayed
callback could observe the ClientCache in a state later than the one that caused the
callback's invocation, and had no way to access the specific state for which it was
invoked.
With this commit, each `Invoke` message to the callback worker includes an
`Arc<ClientCache>` snapshot of the DB state when that callback was invoked. The callback
worker stores that state in a `thread_local`, and methods that inspect
tables (e.g. `TableType::iter`) read the state out of the `thread_local` when it is
present. This allows callbacks to observe exactly the state which caused their invocation,
never a later state, while maintaining the C#-like API where `ClientCache` access is based
on free functions or static trait methods.
---------
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>