Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten SATS + convenience APIs #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions examples/quickstart/client/src/module_bindings/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
__SPACETIMEDB__,
AlgebraicType,
ProductType,
BuiltinType,
ProductTypeElement,
SumType,
SumTypeVariant,
Expand Down Expand Up @@ -41,19 +40,17 @@ export class Message extends IDatabaseTable {
AlgebraicType.createProductType([
new ProductTypeElement(
"__identity_bytes",
AlgebraicType.createArrayType(
AlgebraicType.createPrimitiveType(BuiltinType.Type.U8)
)
AlgebraicType.createBytesType()
),
])
),
new ProductTypeElement(
"sent",
AlgebraicType.createPrimitiveType(BuiltinType.Type.U64)
AlgebraicType.createU64Type()
),
new ProductTypeElement(
"text",
AlgebraicType.createPrimitiveType(BuiltinType.Type.String)
AlgebraicType.createStringType()
),
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
__SPACETIMEDB__,
AlgebraicType,
ProductType,
BuiltinType,
ProductTypeElement,
IDatabaseTable,
AlgebraicValue,
Expand All @@ -22,16 +21,14 @@ export class SendMessageReducer {
public static call(_text: string) {
if (__SPACETIMEDB__.spacetimeDBClient) {
const serializer = __SPACETIMEDB__.spacetimeDBClient.getSerializer();
let _textType = AlgebraicType.createPrimitiveType(
BuiltinType.Type.String
);
let _textType = AlgebraicType.createStringType();
serializer.write(_textType, _text);
__SPACETIMEDB__.spacetimeDBClient.call("send_message", serializer);
}
}

public static deserializeArgs(adapter: ReducerArgsAdapter): any[] {
let textType = AlgebraicType.createPrimitiveType(BuiltinType.Type.String);
let textType = AlgebraicType.createStringType();
let textValue = AlgebraicValue.deserialize(textType, adapter.next());
let text = textValue.asString();
return [text];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
__SPACETIMEDB__,
AlgebraicType,
ProductType,
BuiltinType,
ProductTypeElement,
IDatabaseTable,
AlgebraicValue,
Expand All @@ -22,16 +21,14 @@ export class SetNameReducer {
public static call(_name: string) {
if (__SPACETIMEDB__.spacetimeDBClient) {
const serializer = __SPACETIMEDB__.spacetimeDBClient.getSerializer();
let _nameType = AlgebraicType.createPrimitiveType(
BuiltinType.Type.String
);
let _nameType = AlgebraicType.createStringType();
serializer.write(_nameType, _name);
__SPACETIMEDB__.spacetimeDBClient.call("set_name", serializer);
}
}

public static deserializeArgs(adapter: ReducerArgsAdapter): any[] {
let nameType = AlgebraicType.createPrimitiveType(BuiltinType.Type.String);
let nameType = AlgebraicType.createStringType();
let nameValue = AlgebraicValue.deserialize(nameType, adapter.next());
let name = nameValue.asString();
return [name];
Expand Down
9 changes: 3 additions & 6 deletions examples/quickstart/client/src/module_bindings/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
__SPACETIMEDB__,
AlgebraicType,
ProductType,
BuiltinType,
ProductTypeElement,
SumType,
SumTypeVariant,
Expand Down Expand Up @@ -47,9 +46,7 @@ export class User extends IDatabaseTable {
AlgebraicType.createProductType([
new ProductTypeElement(
"__identity_bytes",
AlgebraicType.createArrayType(
AlgebraicType.createPrimitiveType(BuiltinType.Type.U8)
)
AlgebraicType.createBytesType()
),
])
),
Expand All @@ -58,14 +55,14 @@ export class User extends IDatabaseTable {
AlgebraicType.createSumType([
new SumTypeVariant(
"some",
AlgebraicType.createPrimitiveType(BuiltinType.Type.String)
AlgebraicType.createStringType()
),
new SumTypeVariant("none", AlgebraicType.createProductType([])),
])
),
new ProductTypeElement(
"online",
AlgebraicType.createPrimitiveType(BuiltinType.Type.Bool)
AlgebraicType.createBoolType()
),
]);
}
Expand Down
Loading
Loading