Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

Commit 6a38482

Browse files
authored
Merge branch 'master' into phoebe/csharp-ref-fix-rust-code
2 parents d231487 + dde2811 commit 6a38482

File tree

20 files changed

+218
-90
lines changed

20 files changed

+218
-90
lines changed

docs/deploying/maincloud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spacetime login
2323
```
2424

2525
1. Open the SpacetimeDB website and log in using your GitHub login.
26-
1. You should now be able to see your published modules [by navigating to your profile on the website](/profile).
26+
1. You should now be able to see your published modules https://spacetimedb.com/profile, or you can navigate to your database directly at https://spacetimedb.com/my-cool-module.
2727

2828
---
2929

docs/deploying/spacetimedb-standalone.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,69 @@ server {
8282
listen 80;
8383
server_name example.com;
8484
85-
location / {
85+
#########################################
86+
# By default SpacetimeDB is completely open so that anyone can publish to it. If you want to block
87+
# users from creating new databases you should keep this section commented out. Otherwise, if you
88+
# want to open it up (probably for dev environments) then you can uncomment this section and then
89+
# also comment out the location / section below.
90+
#########################################
91+
# location / {
92+
# proxy_pass http://localhost:3000;
93+
# proxy_http_version 1.1;
94+
# proxy_set_header Upgrade $http_upgrade;
95+
# proxy_set_header Connection "Upgrade";
96+
# proxy_set_header Host $host;
97+
# }
98+
99+
# Anyone can subscribe to any database.
100+
# Note: This is the only section *required* for the websocket to function properly. Clients will
101+
# be able to create identities, call reducers, and subscribe to tables through this websocket.
102+
location ~ ^/v1/database/[^/]+/subscribe$ {
86103
proxy_pass http://localhost:3000;
87104
proxy_http_version 1.1;
88105
proxy_set_header Upgrade $http_upgrade;
89106
proxy_set_header Connection "Upgrade";
90107
proxy_set_header Host $host;
91108
}
92109
93-
# This restricts who can publish new databases to your SpacetimeDB instance. We recommend
94-
# restricting this ability to local connections.
95-
location /v1/publish {
96-
allow 127.0.0.1;
97-
deny all;
110+
# Uncomment this section to allow all HTTP reducer calls
111+
# location ~ ^/v1/[^/]+/call/[^/]+$ {
112+
# proxy_pass http://localhost:3000;
113+
# proxy_http_version 1.1;
114+
# proxy_set_header Upgrade $http_upgrade;
115+
# proxy_set_header Connection "Upgrade";
116+
# proxy_set_header Host $host;
117+
# }
118+
119+
# Uncomment this section to allow all HTTP sql requests
120+
# location ~ ^/v1/[^/]+/sql$ {
121+
# proxy_pass http://localhost:3000;
122+
# proxy_http_version 1.1;
123+
# proxy_set_header Upgrade $http_upgrade;
124+
# proxy_set_header Connection "Upgrade";
125+
# proxy_set_header Host $host;
126+
# }
127+
128+
# NOTE: This is required for the typescript sdk to function, it is optional
129+
# for the rust and the C# SDKs.
130+
location /v1/identity {
98131
proxy_pass http://localhost:3000;
99132
proxy_http_version 1.1;
100133
proxy_set_header Upgrade $http_upgrade;
101134
proxy_set_header Connection "Upgrade";
102135
proxy_set_header Host $host;
103136
}
137+
138+
# Block all other routes explicitly. Only localhost can use these routes. If you want to open your
139+
# server up so that anyone can publish to it you should comment this section out.
140+
location / {
141+
allow 127.0.0.1;
142+
deny all;
143+
}
104144
}
105145
```
106146

107-
This configuration contains a restriction to the `/v1/publish` route. This restriction makes it so that you can only publish to the database if you're publishing from a local connection on the host.
147+
This configuration by default blocks all connections other than `/v1/identity` and `/v1/database/<database-name>/subscribe` which only allows the most basic functionality. This will prevent all remote users from publishing to your SpacetimeDB instance.
108148

109149
Enable the configuration:
110150

docs/index.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ pub fn world(ctx: &spacetimedb::ReducerContext) -> Result<(), String> {
188188
clear_all_tables(ctx);
189189
}
190190
```
191+
While SpacetimeDB doesn't support nested transactions,
192+
a reducer can [schedule another reducer](https://docs.rs/spacetimedb/latest/spacetimedb/attr.reducer.html#scheduled-reducers) to run at an interval,
193+
or at a specific time.
191194
:::
192195
:::server-csharp
193196
```csharp
@@ -207,19 +210,12 @@ public static void World(ReducerContext ctx)
207210
// ...
208211
}
209212
```
210-
:::
211-
212-
:::server-rust
213-
While SpacetimeDB doesn't support nested transactions,
214-
a reducer can [schedule another reducer](https://docs.rs/spacetimedb/latest/spacetimedb/attr.reducer.html#scheduled-reducers) to run at an interval,
215-
or at a specific time.
216-
:::
217-
:::server-csharp
218213
While SpacetimeDB doesn't support nested transactions,
219214
a reducer can [schedule another reducer](/docs/modules/c-sharp#scheduled-reducers) to run at an interval,
220215
or at a specific time.
221216
:::
222217

218+
223219
### Client
224220
A **client** is an application that connects to a [database](#database). A client logs in using an [identity](#identity) and receives an [connection id](#connectionid) to identify the connection. After that, it can call [reducers](#reducer) and query public [tables](#table).
225221

docs/modules/c-sharp/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ This creates a `dotnet` project in `my-project-directory` with the following `St
8888
</Project>
8989
```
9090

91+
> NOTE: It is important to not change the `StdbModule.csproj` name because SpacetimeDB assumes that this will be the name of the file.
92+
9193
This is a standard `csproj`, with the exception of the line `<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>`.
9294
This line is important: it allows the project to be compiled to a WebAssembly module.
9395

@@ -223,9 +225,9 @@ However:
223225

224226
# Tables
225227

226-
Tables are declared using the [`[SpacetimeDB.Table]` attribute](#table-attribute).
228+
Tables are declared using the `[SpacetimeDB.Table]` attribute.
227229

228-
This macro is applied to a C# `partial class` or `partial struct` with named fields. (The `partial` modifier is required to allow code generation to add methods.) All of the fields of the table must be marked with [`[SpacetimeDB.Type]`](#type-attribute).
230+
This macro is applied to a C# `partial class` or `partial struct` with named fields. (The `partial` modifier is required to allow code generation to add methods.) All of the fields of the table must be marked with [`[SpacetimeDB.Type]`]( #attribute-spacetimedbtype).
229231

230232
The resulting type is used to store rows of the table. It's a normal class (or struct). Row values are not special -- operations on row types do not, by themselves, modify the table. Instead, a [`ReducerContext`](#class-reducercontext) is needed to get a handle to the table.
231233

docs/modules/c-sharp/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,6 @@ spacetime sql quickstart-chat "SELECT * FROM message"
311311

312312
You've just set up your first database in SpacetimeDB! You can find the full code for this client [in the C# server module example](https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/tree/master/examples~/quickstart-chat/server).
313313

314-
The next step would be to create a client that interacts with this module. You can use any of SpacetimDB's supported client languages to do this. Take a look at the quick start guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
314+
The next step would be to create a client that interacts with this module. You can use any of SpacetimeDB's supported client languages to do this. Take a look at the quick start guide for your client language of choice: [Rust](/docs/sdks/rust/quickstart), [C#](/docs/sdks/c-sharp/quickstart), or [TypeScript](/docs/sdks/typescript/quickstart).
315315

316316
If you are planning to use SpacetimeDB with the Unity game engine, you can skip right to the [Unity Comprehensive Tutorial](/docs/unity/part-1).

docs/modules/rust/quickstart.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,15 @@ pub fn identity_disconnected(ctx: &ReducerContext) {
224224
}
225225
```
226226

227+
## Start the Server
228+
229+
If you haven't already started the SpacetimeDB server, run the `spacetime start` command in a _separate_ terminal and leave it running while you continue following along.
230+
227231
## Publish the module
228232

229233
And that's all of our module code! We'll run `spacetime publish` to compile our module and publish it on SpacetimeDB. `spacetime publish` takes an optional name which will map to the database's unique `Identity`. Clients can connect either by name or by `Identity`, but names are much more user-friendly. If you'd like, come up with a unique name that contains only URL-safe characters (letters, numbers, hyphens and underscores), and fill it in where we've written `quickstart-chat`.
230234

231-
From the `quickstart-chat` directory, run:
235+
From the `quickstart-chat` directory, run in another tab:
232236

233237
```bash
234238
spacetime publish --project-path server quickstart-chat
@@ -239,7 +243,7 @@ spacetime publish --project-path server quickstart-chat
239243
You can use the CLI (command line interface) to run reducers. The arguments to the reducer are passed in JSON format.
240244

241245
```bash
242-
spacetime call quickstart-chat send_message 'Hello, World!'
246+
spacetime call quickstart-chat send_message "Hello, World!"
243247
```
244248

245249
Once we've called our `send_message` reducer, we can check to make sure it ran by running the `logs` command.

docs/nav.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const nav = {
3939
page('SQL Reference', 'sql', 'sql/index.md'),
4040
section('Subscriptions'),
4141
page('Subscription Reference', 'subscriptions', 'subscriptions/index.md'),
42+
page('Subscription Semantics', 'subscriptions/semantics', 'subscriptions/semantics.md'),
4243
section('Row Level Security'),
4344
page('Row Level Security', 'rls', 'rls/index.md'),
4445
section('How To'),

docs/rls/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use spacetimedb::{client_visibility_filter, Filter};
3333
/// A client can only see their account
3434
#[client_visibility_filter]
3535
const ACCOUNT_FILTER: Filter = Filter::Sql(
36-
"SELECT * FROM account WHERE identity = :sender"
36+
"SELECT * FROM account WHERE account.identity = :sender"
3737
);
3838
```
3939
:::
@@ -52,7 +52,7 @@ public partial class Module
5252
/// </summary>
5353
[SpacetimeDB.ClientVisibilityFilter]
5454
public static readonly Filter ACCOUNT_FILTER = new Filter.Sql(
55-
"SELECT * FROM account WHERE identity = :sender"
55+
"SELECT * FROM account WHERE account.identity = :sender"
5656
);
5757
}
5858
```
@@ -90,7 +90,7 @@ use spacetimedb::{client_visibility_filter, Filter};
9090
/// A client can only see their account
9191
#[client_visibility_filter]
9292
const ACCOUNT_FILTER: Filter = Filter::Sql(
93-
"SELECT * FROM account WHERE identity = :sender"
93+
"SELECT * FROM account WHERE account.identity = :sender"
9494
);
9595

9696
/// An admin can see all accounts
@@ -113,7 +113,7 @@ public partial class Module
113113
/// </summary>
114114
[SpacetimeDB.ClientVisibilityFilter]
115115
public static readonly Filter ACCOUNT_FILTER = new Filter.Sql(
116-
"SELECT * FROM account WHERE identity = :sender"
116+
"SELECT * FROM account WHERE account.identity = :sender"
117117
);
118118

119119
/// <summary>
@@ -141,7 +141,7 @@ use spacetimedb::{client_visibility_filter, Filter};
141141
/// A client can only see their account
142142
#[client_visibility_filter]
143143
const ACCOUNT_FILTER: Filter = Filter::Sql(
144-
"SELECT * FROM account WHERE identity = :sender"
144+
"SELECT * FROM account WHERE account.identity = :sender"
145145
);
146146

147147
/// An admin can see all accounts
@@ -170,7 +170,7 @@ public partial class Module
170170
/// </summary>
171171
[SpacetimeDB.ClientVisibilityFilter]
172172
public static readonly Filter ACCOUNT_FILTER = new Filter.Sql(
173-
"SELECT * FROM account WHERE identity = :sender"
173+
"SELECT * FROM account WHERE account.identity = :sender"
174174
);
175175

176176
/// <summary>

docs/sdks/c-sharp/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The SpacetimeDB client for C# contains all the tools you need to build native cl
2323
If you would like to create a console application using .NET, you can create a new project using `dotnet new console` and add the SpacetimeDB SDK to your dependencies:
2424

2525
```bash
26-
dotnet add package spacetimedbsdk
26+
dotnet add package SpacetimeDB.ClientSDK
2727
```
2828

2929
(See also the [CSharp Quickstart](/docs/modules/c-sharp/quickstart) for an in-depth example of such a console application.)

docs/sdks/c-sharp/quickstart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Open the project in your IDE of choice.
2222

2323
## Add the NuGet package for the C# SpacetimeDB SDK
2424

25-
Add the `SpacetimeDB.ClientSDK` [NuGet package](https://www.nuget.org/packages/spacetimedbsdk) using Visual Studio or Rider _NuGet Package Manager_ or via the .NET CLI:
25+
Add the `SpacetimeDB.ClientSDK` [NuGet package](https://www.nuget.org/packages/SpacetimeDB.ClientSDK/) using Visual Studio or Rider _NuGet Package Manager_ or via the .NET CLI:
2626

2727
```bash
2828
dotnet add package SpacetimeDB.ClientSDK
@@ -141,15 +141,15 @@ To `Program.cs`, add:
141141
const string HOST = "http://localhost:3000";
142142

143143
/// The database name we chose when we published our module.
144-
const string DBNAME = "quickstart-chat";
144+
const string DB_NAME = "quickstart-chat";
145145

146146
/// Load credentials from a file and connect to the database.
147147
DbConnection ConnectToDB()
148148
{
149149
DbConnection? conn = null;
150150
conn = DbConnection.Builder()
151151
.WithUri(HOST)
152-
.WithModuleName(DBNAME)
152+
.WithModuleName(DB_NAME)
153153
.WithToken(AuthToken.Token)
154154
.OnConnect(OnConnected)
155155
.OnConnectError(OnConnectError)

0 commit comments

Comments
 (0)