mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
Expose RawModuleDefV10 via the HTTP schema route (#4540)
# Description of Changes Add `?version=10` as an option to `/v1/database/:name-or-identity/schema`, where previously only `?version=9` was supported. This seems to have been forgotten when we introduced `RawModuleDefV10`. Also, in an unrelated minor fixup, fix a copy-paste error in a doc comment in the V2 WebSocket format definition. # API and ABI breaking changes Additive extension to HTTP API. # Expected complexity level and risk 1 # Testing - [x] Did a local get against this route and got a JSON-ified `RawModuleDefV10`: ```bash $ curl http://localhost:3000/v1/database/chat-console-rs/schema?version=10 {"sections":[{"Typespace":{"types":[{"Product":{"elements":[{"name":{"some":"sender"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__identity__"},"algebraic_type":{"U256":[]}}]}}},{"name":{"some":"sent"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__timestamp_micros_since_unix_epoch__"},"algebraic_type":{"I64":[]}}]}}},{"name":{"some":"text"},"algebraic_type":{"String":[]}}]}},{"Product":{"elements":[{"name":{"some":"identity"},"algebraic_type":{"Product":{"elements":[{"name":{"some":"__identity__"},"algebraic_type":{"U256":[]}}]}}},{"name":{"some":"name"},"algebraic_type":{"Sum":{"variants":[{"name":{"some":"some"},"algebraic_type":{"String":[]}},{"name":{"some":"none"},"algebraic_type":{"Product":{"elements":[]}}}]}}},{"name":{"some":"online"},"algebraic_type":{"Bool":[]}}]}}]}},{"Types":[{"source_name":{"scope":[],"source_name":"Message"},"ty":0,"custom_ordering":true},{"source_name":{"scope":[],"source_name":"User"},"ty":1,"custom_ordering":true}]},{"Tables":[{"source_name":"message","product_type_ref":0,"primary_key":[],"indexes":[],"constraints":[],"sequences":[],"table_type":{"User":[]},"table_access":{"Public":[]},"default_values":[],"is_event":false},{"source_name":"user","product_type_ref":1,"primary_key":[0],"indexes":[{"source_name":{"some":"user_identity_idx_btree"},"accessor_name":{"some":"identity"},"algorithm":{"BTree":[0]}}],"constraints":[{"source_name":{"some":"user_identity_key"},"data":{"Unique":{"columns":[0]}}}],"sequences":[],"table_type":{"User":[]},"table_access":{"Public":[]},"default_values":[],"is_event":false}]},{"Reducers":[{"source_name":"identity_connected","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"identity_disconnected","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"init","params":{"elements":[]},"visibility":{"Private":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"send_message","params":{"elements":[{"name":{"some":"text"},"algebraic_type":{"String":[]}}]},"visibility":{"ClientCallable":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}},{"source_name":"set_name","params":{"elements":[{"name":{"some":"name"},"algebraic_type":{"String":[]}}]},"visibility":{"ClientCallable":[]},"ok_return_type":{"Product":{"elements":[]}},"err_return_type":{"String":[]}}]},{"LifeCycleReducers":[{"lifecycle_spec":{"Init":[]},"function_name":"init"},{"lifecycle_spec":{"OnConnect":[]},"function_name":"identity_connected"},{"lifecycle_spec":{"OnDisconnect":[]},"function_name":"identity_disconnected"}]},{"ExplicitNames":{"entries":[{"Table":{"source_name":"message","canonical_name":"message"}},{"Table":{"source_name":"user","canonical_name":"user"}},{"Function":{"source_name":"identity_connected","canonical_name":"identity_connected"}},{"Function":{"source_name":"identity_disconnected","canonical_name":"identity_disconnected"}},{"Function":{"source_name":"init","canonical_name":"init"}},{"Function":{"source_name":"send_message","canonical_name":"send_message"}},{"Function":{"source_name":"set_name","canonical_name":"set_name"}}]}}]} ```
This commit is contained in:
@@ -354,7 +354,7 @@ pub struct EventTableRows {
|
||||
pub events: BsatnRowList,
|
||||
}
|
||||
|
||||
/// Response to [`Subscribe`] containing the initial matching rows.
|
||||
/// Response to [`OneOffQuery`] containing the matching rows or error.
|
||||
#[derive(SpacetimeType, Debug)]
|
||||
#[sats(crate = spacetimedb_lib)]
|
||||
pub struct OneOffQueryResult {
|
||||
|
||||
@@ -37,6 +37,7 @@ use spacetimedb_client_api_messages::name::{
|
||||
self, DatabaseName, DomainName, MigrationPolicy, PrePublishAutoMigrateResult, PrePublishManualMigrateResult,
|
||||
PrePublishResult, PrettyPrintStyle, PublishOp, PublishResult,
|
||||
};
|
||||
use spacetimedb_lib::db::raw_def::v10::RawModuleDefV10;
|
||||
use spacetimedb_lib::db::raw_def::v9::RawModuleDefV9;
|
||||
use spacetimedb_lib::{sats, AlgebraicValue, Hash, ProductValue, Timestamp};
|
||||
use spacetimedb_schema::auto_migrate::{
|
||||
@@ -327,6 +328,8 @@ pub struct SchemaQueryParams {
|
||||
enum SchemaVersion {
|
||||
#[serde(rename = "9")]
|
||||
V9,
|
||||
#[serde(rename = "10")]
|
||||
V10,
|
||||
}
|
||||
|
||||
pub async fn schema<S>(
|
||||
@@ -346,6 +349,10 @@ where
|
||||
let raw = RawModuleDefV9::from(module_def.as_ref().clone());
|
||||
axum::Json(sats::serde::SerdeWrapper(raw)).into_response()
|
||||
}
|
||||
SchemaVersion::V10 => {
|
||||
let raw = RawModuleDefV10::from(module_def.as_ref().clone());
|
||||
axum::Json(sats::serde::SerdeWrapper(raw)).into_response()
|
||||
}
|
||||
};
|
||||
|
||||
Ok((
|
||||
|
||||
Reference in New Issue
Block a user