Skip to content

Commit

Permalink
implement websocket api changes in new C# sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Sep 30, 2024
1 parent a8b2cca commit ed7f311
Show file tree
Hide file tree
Showing 21 changed files with 537 additions and 142 deletions.
7 changes: 0 additions & 7 deletions src/BSATNHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,5 @@ public static T Decode<T>(string json)
{
throw new InvalidOperationException("JSON isn't supported at the moment");
}

public static T Decode<T>(EncodedValue value) where T : IStructuralReadWrite, new() => value switch
{
EncodedValue.Binary(var bin) => Decode<T>(bin),
EncodedValue.Text(var text) => Decode<T>(text),
_ => throw new InvalidOperationException()
};
}
}
40 changes: 40 additions & 0 deletions src/SpacetimeDB/ClientApi/BsatnRowList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
// <auto-generated />

#nullable enable

using System;
using SpacetimeDB;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace SpacetimeDB.ClientApi
{
[SpacetimeDB.Type]
[DataContract]
public partial class BsatnRowList
{
[DataMember(Name = "size_hint")]
public SpacetimeDB.ClientApi.RowSizeHint SizeHint;
[DataMember(Name = "rows_data")]
public byte[] RowsData;

public BsatnRowList(
SpacetimeDB.ClientApi.RowSizeHint SizeHint,
byte[] RowsData
)
{
this.SizeHint = SizeHint;
this.RowsData = RowsData;
}

public BsatnRowList()
{
this.SizeHint = null!;
this.RowsData = Array.Empty<byte>();
}

}
}
21 changes: 19 additions & 2 deletions src/SpacetimeDB/ClientApi/CallReducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,28 @@ namespace SpacetimeDB.ClientApi
public partial class CallReducer
{
[DataMember(Name = "reducer")]
public string Reducer = "";
public string Reducer;
[DataMember(Name = "args")]
public SpacetimeDB.ClientApi.EncodedValue Args = null!;
public byte[] Args;
[DataMember(Name = "request_id")]
public uint RequestId;

public CallReducer(
string Reducer,
byte[] Args,
uint RequestId
)
{
this.Reducer = Reducer;
this.Args = Args;
this.RequestId = RequestId;
}

public CallReducer()
{
this.Reducer = "";
this.Args = Array.Empty<byte>();
}

}
}
17 changes: 17 additions & 0 deletions src/SpacetimeDB/ClientApi/CompressableQueryUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
// <auto-generated />

#nullable enable

using System;
using SpacetimeDB;

namespace SpacetimeDB.ClientApi
{
[SpacetimeDB.Type]
public partial record CompressableQueryUpdate : SpacetimeDB.TaggedEnum<(
SpacetimeDB.ClientApi.QueryUpdate Uncompressed,
byte[] Brotli
)>;
}
14 changes: 13 additions & 1 deletion src/SpacetimeDB/ClientApi/DatabaseUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ namespace SpacetimeDB.ClientApi
public partial class DatabaseUpdate
{
[DataMember(Name = "tables")]
public System.Collections.Generic.List<SpacetimeDB.ClientApi.TableUpdate> Tables = new();
public System.Collections.Generic.List<SpacetimeDB.ClientApi.TableUpdate> Tables;

public DatabaseUpdate(
System.Collections.Generic.List<SpacetimeDB.ClientApi.TableUpdate> Tables
)
{
this.Tables = Tables;
}

public DatabaseUpdate()
{
this.Tables = new();
}

}
}
11 changes: 0 additions & 11 deletions src/SpacetimeDB/ClientApi/EncodedValue.cs.meta

This file was deleted.

11 changes: 11 additions & 0 deletions src/SpacetimeDB/ClientApi/EnergyQuanta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,16 @@ public partial class EnergyQuanta
[DataMember(Name = "quanta")]
public U128 Quanta;

public EnergyQuanta(
U128 Quanta
)
{
this.Quanta = Quanta;
}

public EnergyQuanta()
{
}

}
}
24 changes: 21 additions & 3 deletions src/SpacetimeDB/ClientApi/IdentityToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,29 @@ namespace SpacetimeDB.ClientApi
public partial class IdentityToken
{
[DataMember(Name = "identity")]
public SpacetimeDB.Identity Identity = new();
public SpacetimeDB.Identity Identity;
[DataMember(Name = "token")]
public string Token = "";
public string Token;
[DataMember(Name = "address")]
public SpacetimeDB.Address Address = new();
public SpacetimeDB.Address Address;

public IdentityToken(
SpacetimeDB.Identity Identity,
string Token,
SpacetimeDB.Address Address
)
{
this.Identity = Identity;
this.Token = Token;
this.Address = Address;
}

public IdentityToken()
{
this.Identity = new();
this.Token = "";
this.Address = new();
}

}
}
18 changes: 17 additions & 1 deletion src/SpacetimeDB/ClientApi/InitialSubscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@ namespace SpacetimeDB.ClientApi
public partial class InitialSubscription
{
[DataMember(Name = "database_update")]
public SpacetimeDB.ClientApi.DatabaseUpdate DatabaseUpdate = new();
public SpacetimeDB.ClientApi.DatabaseUpdate DatabaseUpdate;
[DataMember(Name = "request_id")]
public uint RequestId;
[DataMember(Name = "total_host_execution_duration_micros")]
public ulong TotalHostExecutionDurationMicros;

public InitialSubscription(
SpacetimeDB.ClientApi.DatabaseUpdate DatabaseUpdate,
uint RequestId,
ulong TotalHostExecutionDurationMicros
)
{
this.DatabaseUpdate = DatabaseUpdate;
this.RequestId = RequestId;
this.TotalHostExecutionDurationMicros = TotalHostExecutionDurationMicros;
}

public InitialSubscription()
{
this.DatabaseUpdate = new();
}

}
}
19 changes: 17 additions & 2 deletions src/SpacetimeDB/ClientApi/OneOffQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ namespace SpacetimeDB.ClientApi
public partial class OneOffQuery
{
[DataMember(Name = "message_id")]
public byte[] MessageId = Array.Empty<byte>();
public byte[] MessageId;
[DataMember(Name = "query_string")]
public string QueryString = "";
public string QueryString;

public OneOffQuery(
byte[] MessageId,
string QueryString
)
{
this.MessageId = MessageId;
this.QueryString = QueryString;
}

public OneOffQuery()
{
this.MessageId = Array.Empty<byte>();
this.QueryString = "";
}

}
}
23 changes: 21 additions & 2 deletions src/SpacetimeDB/ClientApi/OneOffQueryResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,32 @@ namespace SpacetimeDB.ClientApi
public partial class OneOffQueryResponse
{
[DataMember(Name = "message_id")]
public byte[] MessageId = Array.Empty<byte>();
public byte[] MessageId;
[DataMember(Name = "error")]
public string? Error;
[DataMember(Name = "tables")]
public System.Collections.Generic.List<SpacetimeDB.ClientApi.OneOffTable> Tables = new();
public System.Collections.Generic.List<SpacetimeDB.ClientApi.OneOffTable> Tables;
[DataMember(Name = "total_host_execution_duration_micros")]
public ulong TotalHostExecutionDurationMicros;

public OneOffQueryResponse(
byte[] MessageId,
string? Error,
System.Collections.Generic.List<SpacetimeDB.ClientApi.OneOffTable> Tables,
ulong TotalHostExecutionDurationMicros
)
{
this.MessageId = MessageId;
this.Error = Error;
this.Tables = Tables;
this.TotalHostExecutionDurationMicros = TotalHostExecutionDurationMicros;
}

public OneOffQueryResponse()
{
this.MessageId = Array.Empty<byte>();
this.Tables = new();
}

}
}
19 changes: 17 additions & 2 deletions src/SpacetimeDB/ClientApi/OneOffTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ namespace SpacetimeDB.ClientApi
public partial class OneOffTable
{
[DataMember(Name = "table_name")]
public string TableName = "";
public string TableName;
[DataMember(Name = "rows")]
public System.Collections.Generic.List<SpacetimeDB.ClientApi.EncodedValue> Rows = new();
public SpacetimeDB.ClientApi.BsatnRowList Rows;

public OneOffTable(
string TableName,
SpacetimeDB.ClientApi.BsatnRowList Rows
)
{
this.TableName = TableName;
this.Rows = Rows;
}

public OneOffTable()
{
this.TableName = "";
this.Rows = new();
}

}
}
40 changes: 40 additions & 0 deletions src/SpacetimeDB/ClientApi/QueryUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
// <auto-generated />

#nullable enable

using System;
using SpacetimeDB;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;

namespace SpacetimeDB.ClientApi
{
[SpacetimeDB.Type]
[DataContract]
public partial class QueryUpdate
{
[DataMember(Name = "deletes")]
public SpacetimeDB.ClientApi.BsatnRowList Deletes;
[DataMember(Name = "inserts")]
public SpacetimeDB.ClientApi.BsatnRowList Inserts;

public QueryUpdate(
SpacetimeDB.ClientApi.BsatnRowList Deletes,
SpacetimeDB.ClientApi.BsatnRowList Inserts
)
{
this.Deletes = Deletes;
this.Inserts = Inserts;
}

public QueryUpdate()
{
this.Deletes = new();
this.Inserts = new();
}

}
}
23 changes: 21 additions & 2 deletions src/SpacetimeDB/ClientApi/ReducerCallInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,32 @@ namespace SpacetimeDB.ClientApi
public partial class ReducerCallInfo
{
[DataMember(Name = "reducer_name")]
public string ReducerName = "";
public string ReducerName;
[DataMember(Name = "reducer_id")]
public uint ReducerId;
[DataMember(Name = "args")]
public SpacetimeDB.ClientApi.EncodedValue Args = null!;
public byte[] Args;
[DataMember(Name = "request_id")]
public uint RequestId;

public ReducerCallInfo(
string ReducerName,
uint ReducerId,
byte[] Args,
uint RequestId
)
{
this.ReducerName = ReducerName;
this.ReducerId = ReducerId;
this.Args = Args;
this.RequestId = RequestId;
}

public ReducerCallInfo()
{
this.ReducerName = "";
this.Args = Array.Empty<byte>();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace SpacetimeDB.ClientApi
{
[SpacetimeDB.Type]
public partial record EncodedValue : SpacetimeDB.TaggedEnum<(
byte[] Binary,
string Text
public partial record RowSizeHint : SpacetimeDB.TaggedEnum<(
ushort FixedSize,
System.Collections.Generic.List<ulong> RowOffsets
)>;
}
Loading

0 comments on commit ed7f311

Please sign in to comment.