* Move connection events to reducers
* More rebase fixups
* Avoid double-reference
* Filter out special reducers in generate cli
This updates filtering of `__init__` to exclude all special reducers, as well as moves the filtering to centralised place before calling language-specific generate command.
* Incrememted ABI version number
---------
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
* 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>
* Add `address: Address` to `ReducerContext`
Initial support for identifying connections via an `Address`,
passed as the caller address in `ReducerContext`.
Notable design choices:
- The same type `Address` is used for clients and dbs,
as opposed to having distinct `DbAddress` and `ClientAddress` types.
- For automatic reducers (init, scheduled, &c), the passed `Address`
is the database's address, not the address of the client which called `publish`.
- Clients may specify an `Address` as a query parameter
to the `subscribe` and `call` endpoints.
If they do not, an `Address` will be randomly generated for them.
Still to do:
- Send the client's `Address` alongside their `Identity` and token
upon WebSocket init in `IdentityToken`,
so the client can save its `Address` for re-connection.
- SDK support.
- C# module support.
- Documentation.
- Refuse new connections if an existing connection
with the same `(Identity, Address)` pair exists.
- Ensure we can store `Address` in tables,
so modules can track connected clients,
and ser/de `Address`, so those tables can be synced to clients.
* Use `None` in `ReducerContext` for HTTP calls without client address
* Fix typo in trait argument name
* `Address` representation amenable to SDK usage
Similar to `Identity`, make `Address` a product type with a double-underscored field name.
This will allow SDKs to distinguish `Address` from `Vec<u8>`,
but does necessitate some ugly `AddressForUrl` hackery
to get ser/de working correctly in different contexts.
This commit does not yet include SDK support for `Address`,
only the server-side machinery necessary for it.
* Add client_address parameter to /publish; pass to init and update reducers
Per discussion with Kim, it's useful for SpacetimeDB-cloud
for the client_address passed to the init reducer
to be that of the caller of /database/publish,
rather than the database's address.
This commit implements that behavior. Now:
- `init` and `update` take the client_address passed to publish, if any,
or `None` if no client_address was supplied.
- Scheduled reducers never receive a client_address.
- Reducers invoked by HTTP /call take the client_address passed to /call, if any,
or `None` if no client_address was supplied.
- Reducers invoked by WebSocket always receive the address of the WebSocket connection.
* `Address` support in Rust client SDK
* Add test that addresses are stable within a client process
* Run rustfmt against merge changes
* Not sure why my local `cargo fmt` didn't get this...
* Add caller_address argument to reducer arguments in Rust SDK
* rustfmt again...
* Add caller address to `EventJson` message
* Python codegen for client addresses
* C# module support for client addresses
* Fix scoping error
* Add `Address`-related stuff to C# codegen
- Emit `SpacetimeDB.Address` for address types
- Add `callerAddress` field to `ReducerEvent`
* TypeScript codegen changes
* Fix merge conflict with new test
* Run rustfmt
---------
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
* SpacetimeDB is hanging, might be because of my changes
* Fixed issue - put connect/disconnect in right spot
* Tested, working
* Reverted changes that are irrelevant
* Added test for detecting connect/disconnect when calling from the CLI
* Smoketest fix
* Fix compilation issue with test
* Addressing some feedback
* Updated test for a better test case
* Addressing review
* connect is a substring of disconnect which was causing a failure
* Fixing another test bug, should be correct now 👍
---------
Co-authored-by: John Detter <no-reply@boppygames.gg>
In the client API's log_and_500,
return an ErrorResponse with a body derived from the error,
rather than a bare 500 code.
Note that this exposes previously-internal error messages to users.
* Client API changes to accomodate new cloud architecture
The exact trait interfaces for `client-api` is TBD
* Ensure we're not blocking when accessing the filesystem
* Derive Clone for SendGridController
* Add YOLO error variant to InsertDomainResult
* Rebase
* fixup! Rebase
* Fix SpacetimeType for Address
* Temporarily disable message / frame size limits for SDK WS
* Remove get_database_instance_state from API trait
It's an internal (worker db) thing, which does not need to be satisfied
by impls.
* Update indexes when updating a database
It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.
* Update indexes when updating a database
It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.
* Fix -S instead of -s for update-module smoke test
-s now means "server", -S "skip clippy", changed in:
a1e9984 (Multiple server configurations for CLI (#214), 2023-09-01)
* Invalidate schema cache when committing a tx
* Use long options in update-module.sh, fix unused warning
* Add test asserting schema_for_table reflects index updates
Fixes#259
(1) Updates MemTable to use RelValue instead of ProductValue
(2) Adds a DataKey member to DataRef and RelValue
(3) Subscriptions compute DataKey only when not present on row
Fixes#259
(1) Updates MemTable to use RelValue instead of ProductValue
(2) Adds a DataKey member to DataRef and RelValue
(3) Subscriptions compute DataKey only when not present on row
This commit adds a new endpoint to the `/identity` block,
which returns the public key STDB uses to decode JWTs.
This will allow clients, incl. the CLI and SDKs,
to verify multiple identity/token pairs without spamming STDB with requests.
The public key can also be used as a "fingerprint", to identify the server.
This will allow clients to determine:
- When multiple URIs or addresses refer to the same STDB instance.
- When a STDB instance has rotated its keys, so past identities become invalid.
* Remove unused datastore traits
We previously anticipated factoring the database in such a way that
the typed vs untyped distinctions, and the transactional vs not,
semantics would be more visible. We have not used these distinctions
and no longer need to expose these traits.
* Fix recovery of sequences after restart
* Debug
* More debug logs
* Export more tyeps
* More debug info and small changes
* More logs
* Change waiting on messages from client to be async
* Remove some trace lines
* Revert "Fix recovery of sequences after restart"
This reverts commit eef0089b78.
* Remove more trace lines
* cargo fmt
* clippy
---------
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: George Kulakowski <george@clockworklabs.io>
Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
This commit adds a new route to the `/identity` HTTP block,
`/identity/:identity/verify`,
which requires a SpacetimeDB auth header.
If the token in the authorization header is valid
and corresponds to the identity in the path,
it returns `NO_CONTENT`.
If the token in the authorization header is valid
but does not correspond to the identity in the path,
it returns `BAD_REQUEST`.
If the token in the authorization header is invalid or unsupplied,
it returns `UNAUTHORIZED`.
* Return parsed `DomainName` alongside `Address` when resolving `NameOrAddress`
Helps to avoid repeatedly parsing `DomainName`, and to simplify the
`/database/publish` handler (not included in this patch).
* Refactoring some stuff for energy
* Fix an issue with i128 query params
* Infinite budget in Standalone
* Energy and crash fixes
* Hopefully fixed the test that now has energy
* Addresses Centril's comments
* Cargo fmt
---------
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
* Identity: use identity_bytes in SpacetimeType
* Use SDK's version of Identity instead
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
* make CI happy
* make axum happy<
* make axum happy v2
* Identity Codegen Impl C# (#100)
* Changes required for identity generation in csharp
* Clippy fix
* Seems to be working
* Fixes based on Mazdak suggestions
---------
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
* Fix compile error that somehow got merged in from https://github.com/clockworklabs/SpacetimeDB/pull/100
* Minor changes to allow `Identity` columns and reducer args in the SDK
- `sdk::identity::Identity` must now be `Hash`,
because declaring a `#[primarykey]` column with type `Identity`
will cause the SDK to generate code that uses `Identity` as a `HashMap` key.
This instance was previously not necessary because the key would be `Vec<u8>`,
but probably should've been included anyway.
- The codegen can just refer to `Identity` without path-qualifying,
because it already imports the `Identity` type into all files it generates.
* address pheobe's review
* pacify clippy
---------
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: Boppy <no-reply@boppygames.gg>
Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net>
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
* Document most of SATS
* sats: simplify Serialize impls
* sats: simplify Deserialize impls
* improve sats::de docs
* document sats::bsatn
* simplify sats fmt/map notation
* value serializer: docs + opt
* docs/refactor sats::algebraic_value::{ser,de}
* sats: document serde conversions
* cargo fmt
* small fixes
* fix tests
* fix serde feature
* sats: address pheobe's review
* fix doc comment
* fix test failure
* Remove unusued import
* Fix a borrowing issue introduced by the merge of master
The definitions of these were tweaked in some way, I think,
such that references to them are no longer automatically 'static?
---------
Co-authored-by: George Kulakowski <george@clockworklabs.io>
* Added commands for spacetime server list and spacetime server ping
* Small fix
* Updated test
---------
Co-authored-by: Boppy <no-reply@boppygames.gg>
* 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
* 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
* Fix output so testsuite passes
---------
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>