Skip to content

Commit c022d34

Browse files
authored
Merge branch 'master' into drogus/spacetime-init
2 parents 59de7eb + 92cd260 commit c022d34

File tree

44 files changed

+827
-664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+827
-664
lines changed

.cargo/config.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ rustflags = ["--cfg", "tokio_unstable"]
33

44
[alias]
55
bump-versions = "run -p upgrade-version --"
6+
7+
[target.x86_64-pc-windows-msvc]
8+
# Use a different linker. Otherwise, the build fails with some obscure linker error that
9+
# seems to be a result of us producing a massive PDB file.
10+
# I (@bfops) tried a variety of other link options besides switching linkers, but this
11+
# seems to be the only thing that worked.
12+
linker = "lld-link"

.github/workflows/ci.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ jobs:
5858
$ErrorActionPreference = 'Stop'
5959
$PSNativeCommandUseErrorActionPreference = $true
6060
61-
# Use a different linker. Otherwise, the build fails with some obscure linker error that
62-
# seems to be a result of us producing a massive PDB file.
63-
# I (@bfops) tried a variety of other link options besides switching linkers, but this
64-
# seems to be the only thing that worked.
65-
$env:RUSTFLAGS='-Clinker=lld-link'
66-
6761
cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
6862
Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
6963
cd modules

.github/workflows/csharp-test.yml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,20 @@ jobs:
8383
CARGO_TARGET_DIR: demo/Blackholio/server-rust/target
8484

8585
- name: Check quickstart-chat bindings are up to date
86-
working-directory: sdks/csharp/examples~/quickstart-chat
86+
working-directory: sdks/csharp
8787
run: |
88-
bash ../../tools~/gen-quickstart.sh "${GITHUB_WORKSPACE}"
89-
# This was copied from tools/check-diff.sh.
90-
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
91-
# version, which would make this `git diff` check very brittle if included.
92-
PATTERN='^// This was generated using spacetimedb cli version.*'
93-
git diff --exit-code --ignore-matching-lines="$PATTERN" -- . || {
94-
echo "Error: quickstart-chat bindings have changed. Please regenerate the bindings and commit them to this branch."
88+
bash tools~/gen-quickstart.sh
89+
"${GITHUB_WORKSPACE}"/tools/check-diff.sh examples~/quickstart-chat || {
90+
echo 'Error: quickstart-chat bindings have changed. Please run `sdks/csharp/tools~/gen-quickstart.sh`.'
91+
exit 1
92+
}
93+
94+
- name: Check client-api bindings are up to date
95+
working-directory: sdks/csharp
96+
run: |
97+
bash tools~/gen-client-api.sh
98+
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || {
99+
echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.'
95100
exit 1
96101
}
97102
@@ -101,12 +106,8 @@ jobs:
101106

102107
- name: Check for changes
103108
run: |
104-
# This was copied from tools/check-diff.sh.
105-
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
106-
# version, which would make this `git diff` check very brittle if included.
107-
PATTERN='^// This was generated using spacetimedb cli version.*'
108-
git diff --exit-code --ignore-matching-lines="$PATTERN" -- demo/Blackholio/client-unity/Assets/Scripts/autogen || {
109-
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
109+
tools/check-diff.sh demo/Blackholio/client-unity/Assets/Scripts/autogen || {
110+
echo 'Error: Bindings are dirty. Please run `demo/Blackholio/server-rust/generate.sh`.'
110111
exit 1
111112
}
112113
@@ -124,7 +125,12 @@ jobs:
124125
disown
125126
126127
- name: Run regression tests
127-
run: bash sdks/csharp/tools~/run-regression-tests.sh .
128+
run: |
129+
bash sdks/csharp/tools~/run-regression-tests.sh
130+
tools/check-diff.sh sdks/csharp/examples~/regression-tests || {
131+
echo 'Error: Bindings are dirty. Please run `sdks/csharp/tools~/gen-regression-tests.sh`.'
132+
exit 1
133+
}
128134
129135
- name: Publish unity-tests module to SpacetimeDB
130136
working-directory: demo/Blackholio/server-rust

.github/workflows/typescript-test.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,10 @@ jobs:
102102
- name: Check for changes
103103
working-directory: crates/bindings-typescript
104104
run: |
105-
# This was copied from SpacetimeDB/tools/check-diff.sh.
106-
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
107-
# version, which would make this `git diff` check very brittle if included.
108-
PATTERN='^// This was generated using spacetimedb cli version.*'
109-
if ! git diff --exit-code --ignore-matching-lines="$PATTERN" -- examples/quickstart-chat/src/module_bindings; then
105+
"${GITHUB_WORKSPACE}"/tools/check-diff.sh examples/quickstart-chat/src/module_bindings || {
110106
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
111107
exit 1
112-
fi
108+
}
113109
114110
# - name: Start SpacetimeDB
115111
# run: |

crates/bindings-csharp/Runtime/Exceptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public class NoSpaceException : StdbException
7272
public override string Message => "The provided bytes sink has no more room left";
7373
}
7474

75+
public class AutoIncOverflowException : StdbException
76+
{
77+
public override string Message => "The auto-increment sequence overflowed";
78+
}
79+
7580
public class UnknownException : StdbException
7681
{
7782
private readonly Errno code;

crates/bindings-csharp/Runtime/Internal/FFI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public enum Errno : short
3636
SCHEDULE_AT_DELAY_TOO_LONG = 13,
3737
INDEX_NOT_UNIQUE = 14,
3838
NO_SUCH_ROW = 15,
39+
AUTO_INC_OVERFLOW = 16,
3940
}
4041

4142
#pragma warning disable IDE1006 // Naming Styles - Not applicable to FFI stuff.
@@ -96,6 +97,7 @@ public static CheckedStatus ConvertToManaged(Errno status)
9697
Errno.SCHEDULE_AT_DELAY_TOO_LONG => new ScheduleAtDelayTooLongException(),
9798
Errno.INDEX_NOT_UNIQUE => new IndexNotUniqueException(),
9899
Errno.NO_SUCH_ROW => new NoSuchRowException(),
100+
Errno.AUTO_INC_OVERFLOW => new AutoIncOverflowException(),
99101
_ => new UnknownException(status),
100102
};
101103
}

crates/bindings-typescript/src/react/useTable.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,6 @@ export function useTable<
368368
if (whereClause && !evaluate(whereClause, row)) {
369369
return;
370370
}
371-
if (tableName === 'message') {
372-
console.log('onInsert for messages table:', row);
373-
}
374371
callbacks?.onInsert?.(row);
375372
if (
376373
ctx.event !== latestTransactionEvent.current ||
@@ -386,9 +383,6 @@ export function useTable<
386383
if (whereClause && !evaluate(whereClause, row)) {
387384
return;
388385
}
389-
if (tableName === 'message') {
390-
console.log('onDelete for messages table:', row);
391-
}
392386
callbacks?.onDelete?.(row);
393387
if (
394388
ctx.event !== latestTransactionEvent.current ||

crates/bindings/src/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ fn insert<T: Table>(mut row: T::Row, mut buf: IterBuf) -> Result<T::Row, TryInse
10091009
sys::Errno::UNIQUE_ALREADY_EXISTS => {
10101010
T::UniqueConstraintViolation::get().map(TryInsertError::UniqueConstraintViolation)
10111011
}
1012-
// sys::Errno::AUTO_INC_OVERFLOW => Tbl::AutoIncOverflow::get().map(TryInsertError::AutoIncOverflow),
1012+
sys::Errno::AUTO_INC_OVERFLOW => T::AutoIncOverflow::get().map(TryInsertError::AutoIncOverflow),
10131013
_ => None,
10141014
};
10151015
err.unwrap_or_else(|| panic!("unexpected insertion error: {e}"))

crates/cli/src/subcommands/publish.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ pub async fn exec(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::E
169169
&client,
170170
&database_host,
171171
&domain.to_string(),
172+
host_type,
172173
&program_bytes,
173174
&auth_header,
174175
break_clients_flag,
@@ -275,16 +276,27 @@ pub fn pretty_print_style_from_env() -> PrettyPrintStyle {
275276

276277
/// Applies pre-publish logic: checking for migration plan, prompting user, and
277278
/// modifying the request builder accordingly.
279+
#[allow(clippy::too_many_arguments)]
278280
async fn apply_pre_publish_if_needed(
279281
mut builder: reqwest::RequestBuilder,
280282
client: &reqwest::Client,
281283
base_url: &str,
282284
domain: &String,
285+
host_type: &str,
283286
program_bytes: &[u8],
284287
auth_header: &AuthHeader,
285288
break_clients_flag: bool,
286289
) -> Result<reqwest::RequestBuilder, anyhow::Error> {
287-
if let Some(pre) = call_pre_publish(client, base_url, &domain.to_string(), program_bytes, auth_header).await? {
290+
if let Some(pre) = call_pre_publish(
291+
client,
292+
base_url,
293+
&domain.to_string(),
294+
host_type,
295+
program_bytes,
296+
auth_header,
297+
)
298+
.await?
299+
{
288300
println!("{}", pre.migrate_plan);
289301

290302
if pre.break_clients
@@ -310,12 +322,15 @@ async fn call_pre_publish(
310322
client: &reqwest::Client,
311323
database_host: &str,
312324
domain: &String,
325+
host_type: &str,
313326
program_bytes: &[u8],
314327
auth_header: &AuthHeader,
315328
) -> Result<Option<PrePublishResult>, anyhow::Error> {
316329
let mut builder = client.post(format!("{database_host}/v1/database/{domain}/pre_publish"));
317330
let style = pretty_print_style_from_env();
318-
builder = builder.query(&[("pretty_print_style", style)]);
331+
builder = builder
332+
.query(&[("pretty_print_style", style)])
333+
.query(&[("host_type", host_type)]);
319334

320335
builder = add_auth_header_opt(builder, auth_header);
321336

crates/client-api/src/routes/database.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,15 +701,29 @@ pub struct PrePublishParams {
701701
pub struct PrePublishQueryParams {
702702
#[serde(default)]
703703
style: PrettyPrintStyle,
704+
#[serde(default)]
705+
host_type: HostType,
704706
}
705707

706708
pub async fn pre_publish<S: NodeDelegate + ControlStateDelegate>(
707709
State(ctx): State<S>,
708710
Path(PrePublishParams { name_or_identity }): Path<PrePublishParams>,
709-
Query(PrePublishQueryParams { style }): Query<PrePublishQueryParams>,
711+
Query(PrePublishQueryParams { style, host_type }): Query<PrePublishQueryParams>,
710712
Extension(auth): Extension<SpacetimeAuth>,
711713
body: Bytes,
712714
) -> axum::response::Result<axum::Json<PrePublishResult>> {
715+
// Feature gate V8 modules.
716+
// The host must've been compiled with the `unstable` feature.
717+
// TODO(v8): ungate this when V8 is ready to ship.
718+
#[cfg(not(feature = "unstable"))]
719+
if host_type == HostType::Js {
720+
return Err((
721+
StatusCode::BAD_REQUEST,
722+
"JS host type requires a host with unstable features",
723+
)
724+
.into());
725+
}
726+
713727
// User should not be able to print migration plans for a database that they do not own
714728
let database_identity = resolve_and_authenticate(&ctx, &name_or_identity, &auth).await?;
715729
let style = match style {
@@ -723,7 +737,7 @@ pub async fn pre_publish<S: NodeDelegate + ControlStateDelegate>(
723737
database_identity,
724738
program_bytes: body.into(),
725739
num_replicas: None,
726-
host_type: HostType::Wasm,
740+
host_type,
727741
},
728742
style,
729743
)

0 commit comments

Comments
 (0)