Separate out TypeScript module library from the SDK (#3182)

# Description of Changes

Please note, much of the code changed in this PR is generated code.

This change updates the TypeScript SDK to use a new `spacetimedb`
TypeScript library which lives under the `/crates/bindings-typescript`
folder alongside `/crates/bindings-csharp`. Just like with the C#
bindings library, the types for `AlgebraicType` and `RawModuleDef` are
now code generated with a script in `/crates/codegen/examples`.

Pulling this out into a library allows us to use the same types and
serialization code on both the server and the client for TypeScript
modules.

In the process of making this change I also found and fixed several
issues with the TypeScript code generation. Namely an issue with
recursive types and an issue with the `never` type. I also removed any
use of `namespace`s since those are a TypeScript only feature, and we
want to have JavaScript + types so that we can use the generated code
with ESBuild without TSC.

I have also improved the npm/pnpm scripts to be able to generate
TypeScript code for us automatically by running `pnpm generate` for any
place that we have to generate typescript code. Namely:

- Quickstart module bindings
- AlgebraicType/ModuleDef for TypeScript module library
- Client API messages for the TypeScript API
- TestApp module bindings

# API and ABI breaking changes

IMPORTANT! This is an API breaking change for clients, as such it should
be a major version change. However, I am going to see if I can shim in
the old API as best as possible to make it compatible.

Notably, we were previously exporting APIs that end users do not need,
and I don't think it would ever occur to them to use, namely the whole
`AlgebraicValue` API and also the `AlgebraicType` API. In principle, no
one should have a need for these, although it was technically possible
for them to use it.

Indeed, we could potentially even just remove AlgebraicType completely
from the API by directly code generating the serialization code.

Listed below are all of the **BREAKING** changes to the API and their
effect:

- `AlgebraicType` is now a structural union literal type instead of a
class (nominal type), this is a consequence of generating the type with
our code gen. Users did not have a reason to use `AlgebraicType`
directly.
- The `AlgebraicValue` type has been removed entirely. This was
previously a class that was exported from the SDK, but very unlikely to
be used by users.
- The `ProductValue` type has been removed.
- The `ReducerArgsAdapter` and `ValueAdapter` types, which were used
with AlgebraicValues have been removed.
- Generated code has changed incompatibly so users will have to
regenerate code when upgrading to this version. Technically a breaking
change, but pretty easy to fix.

Listed below are the non-breaking API changes:
- I am now exporting generated product types as the default export in
addition to how I was exporting them before
- For generated sum type `T`, I am now exporting a `TVariants` namespace
which has the types of all the variants for `T`. This was previously
exposed on the namespace `T`, but was inaccessible in modules other than
the one it was defined in because I also export a type `T` in addition
to namespace `T` and in the type position `T` was being interpreted as a
type rather than a namespace. It's unclear why TypeScript resolved it as
the `T` namespace within the module in which is was defined previously.
Anyway, since the old types were apparently unobservable to users, I've
replaced them with the types in `TVariants`. (Open to other names for
this namespace).
- I fixed a bug where never types (sum types with no variants) were not
correctly generated.

# Expected complexity level and risk

3. The most complex thing about the PR are the potential impacts to the
API. I am reasonably certain, but not 100% certain that I have accounted
for everything above.

# Testing

- [x] I ran `pnpm test` which runs all the tests in the repo including
an integration test which tests the connection to SpacetimeDB. I also
fixed broken tests.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
This commit is contained in:
Tyler Cloutier
2025-09-03 17:12:14 -04:00
committed by GitHub
parent 726345206f
commit 5901fb5063
165 changed files with 11412 additions and 7932 deletions
@@ -2,4 +2,4 @@ node_modules
pnpm-lock.yaml
dist
target
/.github
.github
Generated
+218 -110
View File
@@ -404,7 +404,7 @@ name = "benchmarks-module"
version = "0.1.0"
dependencies = [
"anyhow",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -959,7 +959,7 @@ dependencies = [
[[package]]
name = "connect_disconnect_client"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"spacetimedb-sdk",
@@ -2991,7 +2991,7 @@ name = "keynote-benchmarks"
version = "0.1.0"
dependencies = [
"log",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -3281,7 +3281,7 @@ version = "0.0.0"
dependencies = [
"anyhow",
"log",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -3764,7 +3764,7 @@ name = "perf-test-module"
version = "0.1.0"
dependencies = [
"log",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -4223,7 +4223,7 @@ name = "quickstart-chat-module"
version = "0.1.0"
dependencies = [
"log",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -4903,7 +4903,7 @@ dependencies = [
"anyhow",
"log",
"paste",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
@@ -5264,12 +5264,30 @@ name = "spacetime-module"
version = "0.1.0"
dependencies = [
"log",
"spacetimedb",
"spacetimedb 1.4.0",
]
[[package]]
name = "spacetimedb"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6cd00b22d3170c92858f448db222a135c6302e336f1729c17e77f634c7e9e849"
dependencies = [
"bytemuck",
"derive_more",
"getrandom 0.2.16",
"log",
"rand 0.8.5",
"scoped-tls",
"spacetimedb-bindings-macro 1.3.0",
"spacetimedb-bindings-sys 1.3.0",
"spacetimedb-lib 1.3.0",
"spacetimedb-primitives 1.3.0",
]
[[package]]
name = "spacetimedb"
version = "1.4.0"
dependencies = [
"bytemuck",
"derive_more",
@@ -5278,28 +5296,28 @@ dependencies = [
"log",
"rand 0.8.5",
"scoped-tls",
"spacetimedb-bindings-macro",
"spacetimedb-bindings-sys",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-bindings-macro 1.4.0",
"spacetimedb-bindings-sys 1.4.0",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"trybuild",
]
[[package]]
name = "spacetimedb-auth"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"serde",
"serde_json",
"serde_with",
"spacetimedb-jsonwebtoken",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
]
[[package]]
name = "spacetimedb-bench"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"anymap",
@@ -5327,11 +5345,11 @@ dependencies = [
"spacetimedb-data-structures",
"spacetimedb-datastore",
"spacetimedb-execution",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"spacetimedb-query",
"spacetimedb-sats",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-standalone",
"spacetimedb-table",
@@ -5346,26 +5364,49 @@ dependencies = [
[[package]]
name = "spacetimedb-bindings-macro"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87dcccbad947dbecdb49f6c241762a78451344f04c1bdad023a3b1b5942238b2"
dependencies = [
"heck 0.4.1",
"humantime",
"proc-macro2",
"quote",
"spacetimedb-primitives",
"spacetimedb-primitives 1.3.0",
"syn 2.0.101",
]
[[package]]
name = "spacetimedb-bindings-macro"
version = "1.4.0"
dependencies = [
"heck 0.4.1",
"humantime",
"proc-macro2",
"quote",
"spacetimedb-primitives 1.4.0",
"syn 2.0.101",
]
[[package]]
name = "spacetimedb-bindings-sys"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969e77710b67e7db3e86bb4e195ba325f5f288efd1bfd6b1997ca9c389d22b04"
dependencies = [
"spacetimedb-primitives",
"spacetimedb-primitives 1.3.0",
]
[[package]]
name = "spacetimedb-bindings-sys"
version = "1.4.0"
dependencies = [
"spacetimedb-primitives 1.4.0",
]
[[package]]
name = "spacetimedb-cli"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"base64 0.21.7",
@@ -5401,9 +5442,9 @@ dependencies = [
"spacetimedb-data-structures",
"spacetimedb-fs-utils",
"spacetimedb-jsonwebtoken",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"spacetimedb-schema",
"syntect",
"tabled",
@@ -5426,7 +5467,7 @@ dependencies = [
[[package]]
name = "spacetimedb-client-api"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"async-stream",
@@ -5462,7 +5503,7 @@ dependencies = [
"spacetimedb-data-structures",
"spacetimedb-datastore",
"spacetimedb-jsonwebtoken",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-schema",
"tempfile",
@@ -5479,7 +5520,7 @@ dependencies = [
[[package]]
name = "spacetimedb-client-api-messages"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"bytes",
"bytestring",
@@ -5493,16 +5534,16 @@ dependencies = [
"serde_json",
"serde_with",
"smallvec",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"strum",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-codegen"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"convert_case 0.6.0",
@@ -5511,15 +5552,15 @@ dependencies = [
"itertools 0.12.1",
"regex",
"spacetimedb-data-structures",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-schema",
"spacetimedb-testing",
]
[[package]]
name = "spacetimedb-commitlog"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"async-stream",
"bitflags 2.9.0",
@@ -5539,8 +5580,8 @@ dependencies = [
"spacetimedb-commitlog",
"spacetimedb-fs-utils",
"spacetimedb-paths",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"tempfile",
"thiserror 1.0.69",
"tokio",
@@ -5551,7 +5592,7 @@ dependencies = [
[[package]]
name = "spacetimedb-core"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"arrayvec",
@@ -5628,14 +5669,14 @@ dependencies = [
"spacetimedb-fs-utils",
"spacetimedb-jsonwebtoken",
"spacetimedb-jwks",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-memory-usage",
"spacetimedb-metrics",
"spacetimedb-paths",
"spacetimedb-physical-plan",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"spacetimedb-query",
"spacetimedb-sats",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-snapshot",
"spacetimedb-subscription",
@@ -5670,7 +5711,7 @@ dependencies = [
[[package]]
name = "spacetimedb-data-structures"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"ahash 0.8.12",
"crossbeam-queue",
@@ -5684,7 +5725,7 @@ dependencies = [
[[package]]
name = "spacetimedb-datastore"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"bytes",
@@ -5704,11 +5745,11 @@ dependencies = [
"spacetimedb-data-structures",
"spacetimedb-durability",
"spacetimedb-execution",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-metrics",
"spacetimedb-paths",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-snapshot",
"spacetimedb-table",
@@ -5719,46 +5760,46 @@ dependencies = [
[[package]]
name = "spacetimedb-durability"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"itertools 0.12.1",
"log",
"spacetimedb-commitlog",
"spacetimedb-paths",
"spacetimedb-sats",
"spacetimedb-sats 1.4.0",
"tokio",
"tracing",
]
[[package]]
name = "spacetimedb-execution"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"itertools 0.12.1",
"spacetimedb-expr",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-physical-plan",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-sql-parser",
"spacetimedb-table",
]
[[package]]
name = "spacetimedb-expr"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"bigdecimal",
"derive_more",
"ethnum",
"pretty_assertions",
"spacetimedb",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb 1.4.0",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-sql-parser",
"thiserror 1.0.69",
@@ -5766,7 +5807,7 @@ dependencies = [
[[package]]
name = "spacetimedb-fs-utils"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"hex",
@@ -5808,7 +5849,27 @@ dependencies = [
[[package]]
name = "spacetimedb-lib"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e9b8d04af6da14e3b7cc79b4b88c1c309c994eeba6a97f298fd0cdc7f897209"
dependencies = [
"anyhow",
"bitflags 2.9.0",
"blake3",
"chrono",
"derive_more",
"enum-as-inner",
"hex",
"itertools 0.12.1",
"spacetimedb-bindings-macro 1.3.0",
"spacetimedb-primitives 1.3.0",
"spacetimedb-sats 1.3.0",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-lib"
version = "1.4.0"
dependencies = [
"anyhow",
"bitflags 2.9.0",
@@ -5826,17 +5887,17 @@ dependencies = [
"ron",
"serde",
"serde_json",
"spacetimedb-bindings-macro",
"spacetimedb-bindings-macro 1.4.0",
"spacetimedb-memory-usage",
"spacetimedb-metrics",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-memory-usage"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"decorum",
"ethnum",
@@ -5846,7 +5907,7 @@ dependencies = [
[[package]]
name = "spacetimedb-metrics"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"arrayvec",
"itertools 0.12.1",
@@ -5856,7 +5917,7 @@ dependencies = [
[[package]]
name = "spacetimedb-paths"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"chrono",
@@ -5872,15 +5933,15 @@ dependencies = [
[[package]]
name = "spacetimedb-physical-plan"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"derive_more",
"either",
"pretty_assertions",
"spacetimedb-expr",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-schema",
"spacetimedb-sql-parser",
"spacetimedb-table",
@@ -5888,7 +5949,19 @@ dependencies = [
[[package]]
name = "spacetimedb-primitives"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0181dc495c66138755705e573f0e0a9a7024660f207ebd1e35d0a1f839813e84"
dependencies = [
"bitflags 2.9.0",
"either",
"itertools 0.12.1",
"nohash-hasher",
]
[[package]]
name = "spacetimedb-primitives"
version = "1.4.0"
dependencies = [
"bitflags 2.9.0",
"either",
@@ -5900,7 +5973,7 @@ dependencies = [
[[package]]
name = "spacetimedb-query"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"itertools 0.12.1",
@@ -5908,16 +5981,42 @@ dependencies = [
"spacetimedb-client-api-messages",
"spacetimedb-execution",
"spacetimedb-expr",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-physical-plan",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sql-parser",
"spacetimedb-table",
]
[[package]]
name = "spacetimedb-sats"
version = "1.3.2"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9700ea5d62401c05633ce86d369dbc4a73ec978ac7e347ab8563626ad01fbc"
dependencies = [
"anyhow",
"arrayvec",
"bitflags 2.9.0",
"bytemuck",
"bytes",
"chrono",
"decorum",
"derive_more",
"enum-as-inner",
"ethnum",
"hex",
"itertools 0.12.1",
"second-stack",
"sha3",
"smallvec",
"spacetimedb-bindings-macro 1.3.0",
"spacetimedb-primitives 1.3.0",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-sats"
version = "1.4.0"
dependencies = [
"ahash 0.8.12",
"anyhow",
@@ -5941,16 +6040,16 @@ dependencies = [
"serde",
"sha3",
"smallvec",
"spacetimedb-bindings-macro",
"spacetimedb-bindings-macro 1.4.0",
"spacetimedb-memory-usage",
"spacetimedb-metrics",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-schema"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"derive_more",
@@ -5967,9 +6066,9 @@ dependencies = [
"serial_test",
"smallvec",
"spacetimedb-data-structures",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-sql-parser",
"spacetimedb-testing",
"termcolor",
@@ -5980,7 +6079,7 @@ dependencies = [
[[package]]
name = "spacetimedb-sdk"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anymap",
"base64 0.21.7",
@@ -5999,9 +6098,9 @@ dependencies = [
"rand 0.9.1",
"spacetimedb-client-api-messages",
"spacetimedb-data-structures",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-metrics",
"spacetimedb-sats",
"spacetimedb-sats 1.4.0",
"spacetimedb-testing",
"thiserror 1.0.69",
"tokio",
@@ -6010,7 +6109,7 @@ dependencies = [
[[package]]
name = "spacetimedb-snapshot"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"blake3",
@@ -6027,10 +6126,10 @@ dependencies = [
"spacetimedb-datastore",
"spacetimedb-durability",
"spacetimedb-fs-utils",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-table",
"tempfile",
@@ -6043,17 +6142,17 @@ dependencies = [
[[package]]
name = "spacetimedb-sql-parser"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"derive_more",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"sqlparser",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-standalone"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"async-trait",
@@ -6077,7 +6176,7 @@ dependencies = [
"spacetimedb-client-api-messages",
"spacetimedb-core",
"spacetimedb-datastore",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-table",
"tempfile",
@@ -6092,20 +6191,20 @@ dependencies = [
[[package]]
name = "spacetimedb-subscription"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"spacetimedb-execution",
"spacetimedb-expr",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-physical-plan",
"spacetimedb-primitives",
"spacetimedb-primitives 1.4.0",
"spacetimedb-query",
]
[[package]]
name = "spacetimedb-table"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"ahash 0.8.12",
"blake3",
@@ -6121,17 +6220,17 @@ dependencies = [
"rand 0.9.1",
"smallvec",
"spacetimedb-data-structures",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-memory-usage",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"thiserror 1.0.69",
]
[[package]]
name = "spacetimedb-testing"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"clap 4.5.37",
@@ -6147,7 +6246,7 @@ dependencies = [
"spacetimedb-client-api",
"spacetimedb-core",
"spacetimedb-data-structures",
"spacetimedb-lib",
"spacetimedb-lib 1.4.0",
"spacetimedb-paths",
"spacetimedb-schema",
"spacetimedb-standalone",
@@ -6158,7 +6257,7 @@ dependencies = [
[[package]]
name = "spacetimedb-update"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"bytes",
@@ -6183,7 +6282,7 @@ dependencies = [
[[package]]
name = "spacetimedb-vm"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"arrayvec",
@@ -6193,9 +6292,9 @@ dependencies = [
"smallvec",
"spacetimedb-data-structures",
"spacetimedb-execution",
"spacetimedb-lib",
"spacetimedb-primitives",
"spacetimedb-sats",
"spacetimedb-lib 1.4.0",
"spacetimedb-primitives 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-schema",
"spacetimedb-table",
"tempfile",
@@ -6274,7 +6373,7 @@ dependencies = [
[[package]]
name = "sqltest"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"async-trait",
@@ -6293,8 +6392,8 @@ dependencies = [
"rust_decimal",
"spacetimedb-core",
"spacetimedb-datastore",
"spacetimedb-lib",
"spacetimedb-sats",
"spacetimedb-lib 1.4.0",
"spacetimedb-sats 1.4.0",
"spacetimedb-vm",
"sqllogictest",
"sqllogictest-engines",
@@ -6612,7 +6711,7 @@ dependencies = [
[[package]]
name = "test-client"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"env_logger 0.10.2",
@@ -6624,7 +6723,7 @@ dependencies = [
[[package]]
name = "test-counter"
version = "1.3.2"
version = "1.4.0"
dependencies = [
"anyhow",
"spacetimedb-data-structures",
@@ -7199,6 +7298,15 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
[[package]]
name = "typescript-test-app"
version = "0.1.0"
dependencies = [
"anyhow",
"log",
"spacetimedb 1.3.0",
]
[[package]]
name = "unarray"
version = "0.1.4"
+33 -33
View File
@@ -46,7 +46,7 @@ members = [
"sdks/rust/tests/connect_disconnect_client",
"tools/upgrade-version",
"tools/license-check",
"crates/codegen",
"sdks/typescript/packages/test-app/server",
]
default-members = ["crates/cli", "crates/standalone", "crates/update"]
# cargo feature graph resolver. v3 is default in edition2024 but workspace
@@ -90,43 +90,43 @@ inherits = "release"
debug = true
[workspace.package]
version = "1.3.2"
version = "1.4.0"
edition = "2021"
# update rust-toolchain.toml too!
rust-version = "1.88.0"
[workspace.dependencies]
spacetimedb = { path = "crates/bindings", version = "1.3.2" }
spacetimedb-auth = { path = "crates/auth", version = "1.3.2" }
spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "1.3.2" }
spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "1.3.2" }
spacetimedb-cli = { path = "crates/cli", version = "1.3.2" }
spacetimedb-client-api = { path = "crates/client-api", version = "1.3.2" }
spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "1.3.2" }
spacetimedb-codegen = { path = "crates/codegen", version = "1.3.2" }
spacetimedb-commitlog = { path = "crates/commitlog", version = "1.3.2" }
spacetimedb-core = { path = "crates/core", version = "1.3.2" }
spacetimedb-data-structures = { path = "crates/data-structures", version = "1.3.2" }
spacetimedb-datastore = { path = "crates/datastore", version = "1.3.2" }
spacetimedb-durability = { path = "crates/durability", version = "1.3.2" }
spacetimedb-execution = { path = "crates/execution", version = "1.3.2" }
spacetimedb-expr = { path = "crates/expr", version = "1.3.2" }
spacetimedb-lib = { path = "crates/lib", default-features = false, version = "1.3.2" }
spacetimedb-memory-usage = { path = "crates/memory-usage", version = "1.3.2", default-features = false }
spacetimedb-metrics = { path = "crates/metrics", version = "1.3.2" }
spacetimedb-paths = { path = "crates/paths", version = "1.3.2" }
spacetimedb-physical-plan = { path = "crates/physical-plan", version = "1.3.2" }
spacetimedb-primitives = { path = "crates/primitives", version = "1.3.2" }
spacetimedb-query = { path = "crates/query", version = "1.3.2" }
spacetimedb-sats = { path = "crates/sats", version = "1.3.2" }
spacetimedb-schema = { path = "crates/schema", version = "1.3.2" }
spacetimedb-standalone = { path = "crates/standalone", version = "1.3.2" }
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "1.3.2" }
spacetimedb-table = { path = "crates/table", version = "1.3.2" }
spacetimedb-vm = { path = "crates/vm", version = "1.3.2" }
spacetimedb-fs-utils = { path = "crates/fs-utils", version = "1.3.2" }
spacetimedb-snapshot = { path = "crates/snapshot", version = "1.3.2" }
spacetimedb-subscription = { path = "crates/subscription", version = "1.3.2" }
spacetimedb = { path = "crates/bindings", version = "1.4.0" }
spacetimedb-auth = { path = "crates/auth", version = "1.4.0" }
spacetimedb-bindings-macro = { path = "crates/bindings-macro", version = "1.4.0" }
spacetimedb-bindings-sys = { path = "crates/bindings-sys", version = "1.4.0" }
spacetimedb-cli = { path = "crates/cli", version = "1.4.0" }
spacetimedb-client-api = { path = "crates/client-api", version = "1.4.0" }
spacetimedb-client-api-messages = { path = "crates/client-api-messages", version = "1.4.0" }
spacetimedb-codegen = { path = "crates/codegen", version = "1.4.0" }
spacetimedb-commitlog = { path = "crates/commitlog", version = "1.4.0" }
spacetimedb-core = { path = "crates/core", version = "1.4.0" }
spacetimedb-data-structures = { path = "crates/data-structures", version = "1.4.0" }
spacetimedb-datastore = { path = "crates/datastore", version = "1.4.0" }
spacetimedb-durability = { path = "crates/durability", version = "1.4.0" }
spacetimedb-execution = { path = "crates/execution", version = "1.4.0" }
spacetimedb-expr = { path = "crates/expr", version = "1.4.0" }
spacetimedb-lib = { path = "crates/lib", default-features = false, version = "1.4.0" }
spacetimedb-memory-usage = { path = "crates/memory-usage", version = "1.4.0", default-features = false }
spacetimedb-metrics = { path = "crates/metrics", version = "1.4.0" }
spacetimedb-paths = { path = "crates/paths", version = "1.4.0" }
spacetimedb-physical-plan = { path = "crates/physical-plan", version = "1.4.0" }
spacetimedb-primitives = { path = "crates/primitives", version = "1.4.0" }
spacetimedb-query = { path = "crates/query", version = "1.4.0" }
spacetimedb-sats = { path = "crates/sats", version = "1.4.0" }
spacetimedb-schema = { path = "crates/schema", version = "1.4.0" }
spacetimedb-standalone = { path = "crates/standalone", version = "1.4.0" }
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "1.4.0" }
spacetimedb-table = { path = "crates/table", version = "1.4.0" }
spacetimedb-vm = { path = "crates/vm", version = "1.4.0" }
spacetimedb-fs-utils = { path = "crates/fs-utils", version = "1.4.0" }
spacetimedb-snapshot = { path = "crates/snapshot", version = "1.4.0" }
spacetimedb-subscription = { path = "crates/subscription", version = "1.4.0" }
# Prevent `ahash` from pulling in `getrandom` by disabling default features.
# Modules use `getrandom02` and we need to prevent an incompatible version
+2 -2
View File
@@ -5,7 +5,7 @@ Business Source License 1.1
Parameters
Licensor: Clockwork Laboratories, Inc.
Licensed Work: SpacetimeDB 1.3.2
Licensed Work: SpacetimeDB 1.4.0
The Licensed Work is
(c) 2023 Clockwork Laboratories, Inc.
@@ -21,7 +21,7 @@ Additional Use Grant: You may make use of the Licensed Work provided your
Licensed Work by creating tables whose schemas are
controlled by such third parties.
Change Date: 2030-08-27
Change Date: 2030-09-03
Change License: GNU Affero General Public License v3.0 with a linking
exception
+1
View File
@@ -0,0 +1 @@
../../licenses/BSL.txt
@@ -0,0 +1,41 @@
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import { defineConfig } from 'eslint/config';
export default defineConfig([
{ ignores: ['dist'] },
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...globals.browser, ...globals.node },
},
plugins: {
'@typescript-eslint': tseslint.plugin,
},
extends: [js.configs.recommended, ...tseslint.configs.recommended],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration',
message: 'Do not use enums; stick to JS-compatible types.',
},
{
selector: 'TSEnumDeclaration[const=true]',
message: 'Do not use const enum; use unions or objects.',
},
{ selector: 'Decorator', message: 'Do not use decorators.' },
{
selector: 'TSParameterProperty',
message: 'Do not use parameter properties.',
},
],
},
},
]);
+62
View File
@@ -0,0 +1,62 @@
{
"name": "spacetimedb",
"version": "0.0.1",
"description": "API and ABI bindings for the SpacetimeDB TypeScript module library",
"homepage": "https://github.com/clockworklabs/SpacetimeDB#readme",
"bugs": {
"url": "https://github.com/clockworklabs/SpacetimeDB/issues"
},
"source": "src/index.ts",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "src/index.ts",
"exports": {
".": {
"types": "./src/index.ts",
"source": "./src/index.ts",
"development": "./src/index.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"default": "./dist/index.mjs"
}
},
"files": [
"src",
"dist",
"README.md",
"LICENSE.txt"
],
"repository": {
"type": "git",
"url": "git+https://github.com/clockworklabs/SpacetimeDB.git"
},
"license": "ISC",
"author": "Clockwork Labs",
"type": "module",
"scripts": {
"build": "tsc",
"compile": "pnpm run build",
"format": "prettier --write .",
"lint": "eslint . && prettier . --check",
"test": "vitest run",
"coverage": "vitest run --coverage",
"generate": "cargo run -p spacetimedb-codegen --example regen-typescript-moduledef && prettier --write src/autogen"
},
"dependencies": {
"@zxing/text-encoding": "^0.9.0",
"base64-js": "^1.5.1",
"prettier": "^3.3.3"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"eslint": "^9.33.0",
"globals": "^15.14.0",
"ts-node": "^10.9.2",
"typescript": "^5.9.2",
"typescript-eslint": "^8.18.2",
"vite": "^7.1.3",
"vitest": "^3.2.4"
}
}
@@ -0,0 +1,482 @@
import { TimeDuration } from './time_duration';
import { Timestamp } from './timestamp';
import { ConnectionId } from './connection_id';
import type BinaryReader from './binary_reader';
import BinaryWriter from './binary_writer';
import { Identity } from './identity';
import {
AlgebraicType as AlgebraicTypeType,
AlgebraicType as AlgebraicTypeValue,
} from './autogen/algebraic_type_type';
import {
type ProductType as ProductTypeType,
ProductType as ProductTypeValue,
} from './autogen/product_type_type';
import {
type SumType as SumTypeType,
SumType as SumTypeValue,
} from './autogen/sum_type_type';
import ScheduleAt from './schedule_at';
/**
* A factor / element of a product type.
*
* An element consist of an optional name and a type.
*
* NOTE: Each element has an implicit element tag based on its order.
* Uniquely identifies an element similarly to protobuf tags.
*/
export * from './autogen/product_type_element_type';
/**
* A variant of a sum type.
*
* NOTE: Each element has an implicit element tag based on its order.
* Uniquely identifies an element similarly to protobuf tags.
*/
export * from './autogen/sum_type_variant_type';
/**
* The variant types of the Algebraic Type tagged union.
*/
export type * as AlgebraicTypeVariants from './autogen/algebraic_type_variants';
/**
* The SpacetimeDB Algebraic Type System (SATS) is a structural type system in
* which a nominal type system can be constructed.
*
* The type system unifies the concepts sum types, product types, and built-in
* primitive types into a single type system.
*/
export type AlgebraicType = AlgebraicTypeType;
/**
* Algebraic Type utilities.
*/
export const AlgebraicType: {
createOptionType(innerType: AlgebraicTypeType): AlgebraicTypeType;
createIdentityType(): AlgebraicTypeType;
createConnectionIdType(): AlgebraicTypeType;
createScheduleAtType(): AlgebraicTypeType;
createTimestampType(): AlgebraicTypeType;
createTimeDurationType(): AlgebraicTypeType;
serializeValue(writer: BinaryWriter, ty: AlgebraicTypeType, value: any): void;
deserializeValue(reader: BinaryReader, ty: AlgebraicTypeType): any;
/**
* Convert a value of the algebraic type into something that can be used as a key in a map.
* There are no guarantees about being able to order it.
* This is only guaranteed to be comparable to other values of the same type.
* @param value A value of the algebraic type
* @returns Something that can be used as a key in a map.
*/
intoMapKey(ty: AlgebraicTypeType, value: any): ComparablePrimitive;
} & typeof AlgebraicTypeValue = {
...AlgebraicTypeValue,
createOptionType: function (innerType: AlgebraicTypeType): AlgebraicTypeType {
return AlgebraicTypeValue.Sum({
variants: [
{ name: 'some', algebraicType: innerType },
{
name: 'none',
algebraicType: AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
createIdentityType: function (): AlgebraicTypeType {
return AlgebraicTypeValue.Product({
elements: [
{ name: '__identity__', algebraicType: AlgebraicTypeValue.U256 },
],
});
},
createConnectionIdType: function (): AlgebraicTypeType {
return AlgebraicTypeValue.Product({
elements: [
{ name: '__connection_id__', algebraicType: AlgebraicTypeValue.U128 },
],
});
},
createScheduleAtType: function (): AlgebraicTypeType {
return ScheduleAt.getAlgebraicType();
},
createTimestampType: function (): AlgebraicTypeType {
return AlgebraicTypeValue.Product({
elements: [
{
name: '__timestamp_micros_since_unix_epoch__',
algebraicType: AlgebraicTypeValue.I64,
},
],
});
},
createTimeDurationType: function (): AlgebraicTypeType {
return AlgebraicTypeValue.Product({
elements: [
{
name: '__time_duration_micros__',
algebraicType: AlgebraicTypeValue.I64,
},
],
});
},
serializeValue: function (
writer: BinaryWriter,
ty: AlgebraicTypeType,
value: any
): void {
switch (ty.tag) {
case 'Product':
ProductType.serializeValue(writer, ty.value, value);
break;
case 'Sum':
SumType.serializeValue(writer, ty.value, value);
break;
case 'Array':
if (ty.value.tag === 'U8') {
writer.writeUInt8Array(value);
} else {
const elemType = ty.value;
writer.writeU32(value.length);
for (const elem of value) {
AlgebraicType.serializeValue(writer, elemType, elem);
}
}
break;
case 'Bool':
writer.writeBool(value);
break;
case 'I8':
writer.writeI8(value);
break;
case 'U8':
writer.writeU8(value);
break;
case 'I16':
writer.writeI16(value);
break;
case 'U16':
writer.writeU16(value);
break;
case 'I32':
writer.writeI32(value);
break;
case 'U32':
writer.writeU32(value);
break;
case 'I64':
writer.writeI64(value);
break;
case 'U64':
writer.writeU64(value);
break;
case 'I128':
writer.writeI128(value);
break;
case 'U128':
writer.writeU128(value);
break;
case 'I256':
writer.writeI256(value);
break;
case 'U256':
writer.writeU256(value);
break;
case 'F32':
writer.writeF32(value);
break;
case 'F64':
writer.writeF64(value);
break;
case 'String':
writer.writeString(value);
break;
default:
throw new Error(`not implemented, ${ty.tag}`);
}
},
deserializeValue: function (
reader: BinaryReader,
ty: AlgebraicTypeType
): any {
switch (ty.tag) {
case 'Product':
return ProductType.deserializeValue(reader, ty.value);
case 'Sum':
return SumType.deserializeValue(reader, ty.value);
case 'Array':
if (ty.value.tag === 'U8') {
return reader.readUInt8Array();
} else {
const elemType = ty.value;
const length = reader.readU32();
const result: any[] = [];
for (let i = 0; i < length; i++) {
result.push(AlgebraicType.deserializeValue(reader, elemType));
}
return result;
}
case 'Bool':
return reader.readBool();
case 'I8':
return reader.readI8();
case 'U8':
return reader.readU8();
case 'I16':
return reader.readI16();
case 'U16':
return reader.readU16();
case 'I32':
return reader.readI32();
case 'U32':
return reader.readU32();
case 'I64':
return reader.readI64();
case 'U64':
return reader.readU64();
case 'I128':
return reader.readI128();
case 'U128':
return reader.readU128();
case 'I256':
return reader.readI256();
case 'U256':
return reader.readU256();
case 'F32':
return reader.readF32();
case 'F64':
return reader.readF64();
case 'String':
return reader.readString();
default:
throw new Error(`not implemented, ${ty.tag}`);
}
},
/**
* Convert a value of the algebraic type into something that can be used as a key in a map.
* There are no guarantees about being able to order it.
* This is only guaranteed to be comparable to other values of the same type.
* @param value A value of the algebraic type
* @returns Something that can be used as a key in a map.
*/
intoMapKey: function (
ty: AlgebraicTypeType,
value: any
): ComparablePrimitive {
switch (ty.tag) {
case 'U8':
case 'U16':
case 'U32':
case 'U64':
case 'U128':
case 'U256':
case 'I8':
case 'I16':
case 'I64':
case 'I128':
case 'F32':
case 'F64':
case 'String':
case 'Bool':
return value;
case 'Product':
return ProductType.intoMapKey(ty.value, value);
default: {
const writer = new BinaryWriter(10);
this.serialize(writer, value);
return writer.toBase64();
}
}
},
};
/**
* A structural product type of the factors given by `elements`.
*
* This is also known as `struct` and `tuple` in many languages,
* but note that unlike most languages, products in SATs are *[structural]* and not nominal.
* When checking whether two nominal types are the same,
* their names and/or declaration sites (e.g., module / namespace) are considered.
* Meanwhile, a structural type system would only check the structure of the type itself,
* e.g., the names of its fields and their types in the case of a record.
* The name "product" comes from category theory.
*
* See also: https://ncatlab.org/nlab/show/product+type.
*
* These structures are known as product types because the number of possible values in product
* ```ignore
* { N_0: T_0, N_1: T_1, ..., N_n: T_n }
* ```
* is:
* ```ignore
* Π (i ∈ 0..n). values(T_i)
* ```
* so for example, `values({ A: U64, B: Bool }) = values(U64) * values(Bool)`.
*
* [structural]: https://en.wikipedia.org/wiki/Structural_type_system
*/
export type ProductType = ProductTypeType;
export const ProductType: {
serializeValue(writer: BinaryWriter, ty: ProductTypeType, value: any): void;
deserializeValue(reader: BinaryReader, ty: ProductTypeType): any;
intoMapKey(ty: ProductTypeType, value: any): ComparablePrimitive;
} = {
...ProductTypeValue,
serializeValue(writer: BinaryWriter, ty: ProductTypeType, value: any): void {
for (const element of ty.elements) {
AlgebraicType.serializeValue(
writer,
element.algebraicType,
value[element.name!]
);
}
},
deserializeValue(reader: BinaryReader, ty: ProductTypeType): any {
const result: { [key: string]: any } = {};
if (ty.elements.length === 1) {
if (ty.elements[0].name === '__time_duration_micros__') {
return new TimeDuration(reader.readI64());
}
if (ty.elements[0].name === '__timestamp_micros_since_unix_epoch__') {
return new Timestamp(reader.readI64());
}
if (ty.elements[0].name === '__identity__') {
return new Identity(reader.readU256());
}
if (ty.elements[0].name === '__connection_id__') {
return new ConnectionId(reader.readU128());
}
}
for (const element of ty.elements) {
result[element.name!] = AlgebraicType.deserializeValue(
reader,
element.algebraicType
);
}
return result;
},
intoMapKey(ty: ProductTypeType, value: any): ComparablePrimitive {
if (ty.elements.length === 1) {
if (ty.elements[0].name === '__time_duration_micros__') {
return (value as TimeDuration).__time_duration_micros__;
}
if (ty.elements[0].name === '__timestamp_micros_since_unix_epoch__') {
return (value as Timestamp).__timestamp_micros_since_unix_epoch__;
}
if (ty.elements[0].name === '__identity__') {
return (value as Identity).__identity__;
}
if (ty.elements[0].name === '__connection_id__') {
return (value as ConnectionId).__connection_id__;
}
}
// The fallback is to serialize and base64 encode the bytes.
const writer = new BinaryWriter(10);
AlgebraicType.serializeValue(writer, AlgebraicType.Product(ty), value);
return writer.toBase64();
},
};
/**
* Unlike most languages, sums in SATS are *[structural]* and not nominal.
* When checking whether two nominal types are the same,
* their names and/or declaration sites (e.g., module / namespace) are considered.
* Meanwhile, a structural type system would only check the structure of the type itself,
* e.g., the names of its variants and their inner data types in the case of a sum.
*
* This is also known as a discriminated union (implementation) or disjoint union.
* Another name is [coproduct (category theory)](https://ncatlab.org/nlab/show/coproduct).
*
* These structures are known as sum types because the number of possible values a sum
* ```ignore
* { N_0(T_0), N_1(T_1), ..., N_n(T_n) }
* ```
* is:
* ```ignore
* Σ (i ∈ 0..n). values(T_i)
* ```
* so for example, `values({ A(U64), B(Bool) }) = values(U64) + values(Bool)`.
*
* See also: https://ncatlab.org/nlab/show/sum+type.
*
* [structural]: https://en.wikipedia.org/wiki/Structural_type_system
*/
export const SumType: {
serializeValue(writer: BinaryWriter, ty: SumTypeType, value: any): void;
deserializeValue(reader: BinaryReader, ty: SumTypeType): any;
} = {
...SumTypeValue,
serializeValue: function (
writer: BinaryWriter,
ty: SumTypeType,
value: any
): void {
if (
ty.variants.length == 2 &&
ty.variants[0].name === 'some' &&
ty.variants[1].name === 'none'
) {
if (value !== null && value !== undefined) {
writer.writeByte(0);
AlgebraicType.serializeValue(
writer,
ty.variants[0].algebraicType,
value
);
} else {
writer.writeByte(1);
}
} else {
const variant = value['tag'];
const index = ty.variants.findIndex(v => v.name === variant);
if (index < 0) {
throw `Can't serialize a sum type, couldn't find ${value.tag} tag`;
}
writer.writeU8(index);
AlgebraicType.serializeValue(
writer,
ty.variants[index].algebraicType,
value['value']
);
}
},
deserializeValue: function (reader: BinaryReader, ty: SumTypeType): any {
const tag = reader.readU8();
// In TypeScript we handle Option values as a special case
// we don't represent the some and none variants, but instead
// we represent the value directly.
if (
ty.variants.length == 2 &&
ty.variants[0].name === 'some' &&
ty.variants[1].name === 'none'
) {
if (tag === 0) {
return AlgebraicType.deserializeValue(
reader,
ty.variants[0].algebraicType
);
} else if (tag === 1) {
return undefined;
} else {
throw `Can't deserialize an option type, couldn't find ${tag} tag`;
}
} else {
const variant = ty.variants[tag];
const value = AlgebraicType.deserializeValue(
reader,
variant.algebraicType
);
return { tag: variant.name, value };
}
},
};
export type ComparablePrimitive = number | string | boolean | bigint;
@@ -0,0 +1,10 @@
import BinaryReader from './binary_reader';
export interface ParseableType<T> {
deserialize: (reader: BinaryReader) => T;
}
export function parseValue<T>(ty: ParseableType<T>, src: Uint8Array): T {
const reader = new BinaryReader(src);
return ty.deserialize(reader);
}
@@ -0,0 +1,185 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { SumType } from './sum_type_type';
import { ProductType } from './product_type_type';
import * as AlgebraicTypeVariants from './algebraic_type_variants';
// The tagged union or sum type for the algebraic type `AlgebraicType`.
export type AlgebraicType =
| AlgebraicTypeVariants.Ref
| AlgebraicTypeVariants.Sum
| AlgebraicTypeVariants.Product
| AlgebraicTypeVariants.Array
| AlgebraicTypeVariants.String
| AlgebraicTypeVariants.Bool
| AlgebraicTypeVariants.I8
| AlgebraicTypeVariants.U8
| AlgebraicTypeVariants.I16
| AlgebraicTypeVariants.U16
| AlgebraicTypeVariants.I32
| AlgebraicTypeVariants.U32
| AlgebraicTypeVariants.I64
| AlgebraicTypeVariants.U64
| AlgebraicTypeVariants.I128
| AlgebraicTypeVariants.U128
| AlgebraicTypeVariants.I256
| AlgebraicTypeVariants.U256
| AlgebraicTypeVariants.F32
| AlgebraicTypeVariants.F64;
// A value with helper functions to construct the type.
export const AlgebraicType = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
Ref: (value: number): AlgebraicType => ({ tag: 'Ref', value }),
Sum: (value: SumType): AlgebraicType => ({ tag: 'Sum', value }),
Product: (value: ProductType): AlgebraicType => ({ tag: 'Product', value }),
Array: (value: AlgebraicType): AlgebraicType => ({ tag: 'Array', value }),
String: { tag: 'String' } as const,
Bool: { tag: 'Bool' } as const,
I8: { tag: 'I8' } as const,
U8: { tag: 'U8' } as const,
I16: { tag: 'I16' } as const,
U16: { tag: 'U16' } as const,
I32: { tag: 'I32' } as const,
U32: { tag: 'U32' } as const,
I64: { tag: 'I64' } as const,
U64: { tag: 'U64' } as const,
I128: { tag: 'I128' } as const,
U128: { tag: 'U128' } as const,
I256: { tag: 'I256' } as const,
U256: { tag: 'U256' } as const,
F32: { tag: 'F32' } as const,
F64: { tag: 'F64' } as const,
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{ name: 'Ref', algebraicType: __AlgebraicTypeValue.U32 },
{ name: 'Sum', algebraicType: SumType.getTypeScriptAlgebraicType() },
{
name: 'Product',
algebraicType: ProductType.getTypeScriptAlgebraicType(),
},
{
name: 'Array',
algebraicType: AlgebraicType.getTypeScriptAlgebraicType(),
},
{
name: 'String',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'Bool',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I8',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U8',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I16',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U16',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I32',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U32',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I64',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U64',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I128',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U128',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'I256',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'U256',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'F32',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'F64',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
serialize(writer: __BinaryWriter, value: AlgebraicType): void {
__AlgebraicTypeValue.serializeValue(
writer,
AlgebraicType.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): AlgebraicType {
return __AlgebraicTypeValue.deserializeValue(
reader,
AlgebraicType.getTypeScriptAlgebraicType()
);
},
};
export default AlgebraicType;
@@ -0,0 +1,54 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { AlgebraicType as AlgebraicTypeType } from './algebraic_type_type';
import { SumType as SumTypeType } from './sum_type_type';
import { ProductType as ProductTypeType } from './product_type_type';
export type Ref = { tag: 'Ref'; value: number };
export type Sum = { tag: 'Sum'; value: SumTypeType };
export type Product = { tag: 'Product'; value: ProductTypeType };
export type Array = { tag: 'Array'; value: AlgebraicTypeType };
export type String = { tag: 'String' };
export type Bool = { tag: 'Bool' };
export type I8 = { tag: 'I8' };
export type U8 = { tag: 'U8' };
export type I16 = { tag: 'I16' };
export type U16 = { tag: 'U16' };
export type I32 = { tag: 'I32' };
export type U32 = { tag: 'U32' };
export type I64 = { tag: 'I64' };
export type U64 = { tag: 'U64' };
export type I128 = { tag: 'I128' };
export type U128 = { tag: 'U128' };
export type I256 = { tag: 'I256' };
export type U256 = { tag: 'U256' };
export type F32 = { tag: 'F32' };
export type F64 = { tag: 'F64' };
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import * as IndexTypeVariants from './index_type_variants';
// The tagged union or sum type for the algebraic type `IndexType`.
export type IndexType = IndexTypeVariants.BTree | IndexTypeVariants.Hash;
// A value with helper functions to construct the type.
export const IndexType = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
BTree: { tag: 'BTree' } as const,
Hash: { tag: 'Hash' } as const,
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'BTree',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'Hash',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
serialize(writer: __BinaryWriter, value: IndexType): void {
__AlgebraicTypeValue.serializeValue(
writer,
IndexType.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): IndexType {
return __AlgebraicTypeValue.deserializeValue(
reader,
IndexType.getTypeScriptAlgebraicType()
);
},
};
export default IndexType;
@@ -0,0 +1,33 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type BTree = { tag: 'BTree' };
export type Hash = { tag: 'Hash' };
@@ -0,0 +1,86 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import * as LifecycleVariants from './lifecycle_variants';
// The tagged union or sum type for the algebraic type `Lifecycle`.
export type Lifecycle =
| LifecycleVariants.Init
| LifecycleVariants.OnConnect
| LifecycleVariants.OnDisconnect;
// A value with helper functions to construct the type.
export const Lifecycle = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
Init: { tag: 'Init' } as const,
OnConnect: { tag: 'OnConnect' } as const,
OnDisconnect: { tag: 'OnDisconnect' } as const,
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'Init',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'OnConnect',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'OnDisconnect',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
serialize(writer: __BinaryWriter, value: Lifecycle): void {
__AlgebraicTypeValue.serializeValue(
writer,
Lifecycle.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): Lifecycle {
return __AlgebraicTypeValue.deserializeValue(
reader,
Lifecycle.getTypeScriptAlgebraicType()
);
},
};
export default Lifecycle;
@@ -0,0 +1,34 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type Init = { tag: 'Init' };
export type OnConnect = { tag: 'OnConnect' };
export type OnDisconnect = { tag: 'OnDisconnect' };
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { TypeAlias } from './type_alias_type';
import * as MiscModuleExportVariants from './misc_module_export_variants';
// The tagged union or sum type for the algebraic type `MiscModuleExport`.
export type MiscModuleExport = MiscModuleExportVariants.TypeAlias;
// A value with helper functions to construct the type.
export const MiscModuleExport = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
TypeAlias: (value: TypeAlias): MiscModuleExport => ({
tag: 'TypeAlias',
value,
}),
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'TypeAlias',
algebraicType: TypeAlias.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: MiscModuleExport): void {
__AlgebraicTypeValue.serializeValue(
writer,
MiscModuleExport.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): MiscModuleExport {
return __AlgebraicTypeValue.deserializeValue(
reader,
MiscModuleExport.getTypeScriptAlgebraicType()
);
},
};
export default MiscModuleExport;
@@ -0,0 +1,33 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { TypeAlias as TypeAliasType } from './type_alias_type';
export type TypeAlias = { tag: 'TypeAlias'; value: TypeAliasType };
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { AlgebraicType } from './algebraic_type_type';
export type ProductTypeElement = {
name: string | undefined;
algebraicType: AlgebraicType;
};
/**
* An object for generated helper functions.
*/
export const ProductTypeElement = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{
name: 'algebraicType',
algebraicType: AlgebraicType.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: ProductTypeElement): void {
__AlgebraicTypeValue.serializeValue(
writer,
ProductTypeElement.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): ProductTypeElement {
return __AlgebraicTypeValue.deserializeValue(
reader,
ProductTypeElement.getTypeScriptAlgebraicType()
);
},
};
export default ProductTypeElement;
@@ -0,0 +1,73 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { ProductTypeElement } from './product_type_element_type';
export type ProductType = {
elements: ProductTypeElement[];
};
/**
* An object for generated helper functions.
*/
export const ProductType = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'elements',
algebraicType: __AlgebraicTypeValue.Array(
ProductTypeElement.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: ProductType): void {
__AlgebraicTypeValue.serializeValue(
writer,
ProductType.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): ProductType {
return __AlgebraicTypeValue.deserializeValue(
reader,
ProductType.getTypeScriptAlgebraicType()
);
},
};
export default ProductType;
@@ -0,0 +1,73 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { AlgebraicType } from './algebraic_type_type';
export type RawColumnDefV8 = {
colName: string;
colType: AlgebraicType;
};
/**
* An object for generated helper functions.
*/
export const RawColumnDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'colName', algebraicType: __AlgebraicTypeValue.String },
{
name: 'colType',
algebraicType: AlgebraicType.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawColumnDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawColumnDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawColumnDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawColumnDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawColumnDefV8;
@@ -0,0 +1,74 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawColumnDefaultValueV9 = {
table: string;
colId: number;
value: Uint8Array;
};
/**
* An object for generated helper functions.
*/
export const RawColumnDefaultValueV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'table', algebraicType: __AlgebraicTypeValue.String },
{ name: 'colId', algebraicType: __AlgebraicTypeValue.U16 },
{
name: 'value',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U8),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawColumnDefaultValueV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawColumnDefaultValueV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawColumnDefaultValueV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawColumnDefaultValueV9.getTypeScriptAlgebraicType()
);
},
};
export default RawColumnDefaultValueV9;
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawUniqueConstraintDataV9 } from './raw_unique_constraint_data_v_9_type';
import * as RawConstraintDataV9Variants from './raw_constraint_data_v_9_variants';
// The tagged union or sum type for the algebraic type `RawConstraintDataV9`.
export type RawConstraintDataV9 = RawConstraintDataV9Variants.Unique;
// A value with helper functions to construct the type.
export const RawConstraintDataV9 = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
Unique: (value: RawUniqueConstraintDataV9): RawConstraintDataV9 => ({
tag: 'Unique',
value,
}),
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'Unique',
algebraicType: RawUniqueConstraintDataV9.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawConstraintDataV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawConstraintDataV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawConstraintDataV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawConstraintDataV9.getTypeScriptAlgebraicType()
);
},
};
export default RawConstraintDataV9;
@@ -0,0 +1,33 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawUniqueConstraintDataV9 as RawUniqueConstraintDataV9Type } from './raw_unique_constraint_data_v_9_type';
export type Unique = { tag: 'Unique'; value: RawUniqueConstraintDataV9Type };
@@ -0,0 +1,74 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawConstraintDefV8 = {
constraintName: string;
constraints: number;
columns: number[];
};
/**
* An object for generated helper functions.
*/
export const RawConstraintDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'constraintName', algebraicType: __AlgebraicTypeValue.String },
{ name: 'constraints', algebraicType: __AlgebraicTypeValue.U8 },
{
name: 'columns',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawConstraintDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawConstraintDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawConstraintDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawConstraintDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawConstraintDefV8;
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawConstraintDataV9 } from './raw_constraint_data_v_9_type';
export type RawConstraintDefV9 = {
name: string | undefined;
data: RawConstraintDataV9;
};
/**
* An object for generated helper functions.
*/
export const RawConstraintDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{
name: 'data',
algebraicType: RawConstraintDataV9.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawConstraintDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawConstraintDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawConstraintDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawConstraintDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawConstraintDefV9;
@@ -0,0 +1,83 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import * as RawIndexAlgorithmVariants from './raw_index_algorithm_variants';
// The tagged union or sum type for the algebraic type `RawIndexAlgorithm`.
export type RawIndexAlgorithm =
| RawIndexAlgorithmVariants.BTree
| RawIndexAlgorithmVariants.Hash
| RawIndexAlgorithmVariants.Direct;
// A value with helper functions to construct the type.
export const RawIndexAlgorithm = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
BTree: (value: number[]): RawIndexAlgorithm => ({ tag: 'BTree', value }),
Hash: (value: number[]): RawIndexAlgorithm => ({ tag: 'Hash', value }),
Direct: (value: number): RawIndexAlgorithm => ({ tag: 'Direct', value }),
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'BTree',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
{
name: 'Hash',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
{ name: 'Direct', algebraicType: __AlgebraicTypeValue.U16 },
],
});
},
serialize(writer: __BinaryWriter, value: RawIndexAlgorithm): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawIndexAlgorithm.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawIndexAlgorithm {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawIndexAlgorithm.getTypeScriptAlgebraicType()
);
},
};
export default RawIndexAlgorithm;
@@ -0,0 +1,34 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type BTree = { tag: 'BTree'; value: number[] };
export type Hash = { tag: 'Hash'; value: number[] };
export type Direct = { tag: 'Direct'; value: number };
@@ -0,0 +1,80 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { IndexType } from './index_type_type';
export type RawIndexDefV8 = {
indexName: string;
isUnique: boolean;
indexType: IndexType;
columns: number[];
};
/**
* An object for generated helper functions.
*/
export const RawIndexDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'indexName', algebraicType: __AlgebraicTypeValue.String },
{ name: 'isUnique', algebraicType: __AlgebraicTypeValue.Bool },
{
name: 'indexType',
algebraicType: IndexType.getTypeScriptAlgebraicType(),
},
{
name: 'columns',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawIndexDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawIndexDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawIndexDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawIndexDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawIndexDefV8;
@@ -0,0 +1,85 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawIndexAlgorithm } from './raw_index_algorithm_type';
export type RawIndexDefV9 = {
name: string | undefined;
accessorName: string | undefined;
algorithm: RawIndexAlgorithm;
};
/**
* An object for generated helper functions.
*/
export const RawIndexDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{
name: 'accessorName',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{
name: 'algorithm',
algebraicType: RawIndexAlgorithm.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawIndexDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawIndexDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawIndexDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawIndexDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawIndexDefV9;
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawColumnDefaultValueV9 } from './raw_column_default_value_v_9_type';
import * as RawMiscModuleExportV9Variants from './raw_misc_module_export_v_9_variants';
// The tagged union or sum type for the algebraic type `RawMiscModuleExportV9`.
export type RawMiscModuleExportV9 =
RawMiscModuleExportV9Variants.ColumnDefaultValue;
// A value with helper functions to construct the type.
export const RawMiscModuleExportV9 = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
ColumnDefaultValue: (
value: RawColumnDefaultValueV9
): RawMiscModuleExportV9 => ({ tag: 'ColumnDefaultValue', value }),
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'ColumnDefaultValue',
algebraicType: RawColumnDefaultValueV9.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawMiscModuleExportV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawMiscModuleExportV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawMiscModuleExportV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawMiscModuleExportV9.getTypeScriptAlgebraicType()
);
},
};
export default RawMiscModuleExportV9;
@@ -0,0 +1,36 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawColumnDefaultValueV9 as RawColumnDefaultValueV9Type } from './raw_column_default_value_v_9_type';
export type ColumnDefaultValue = {
tag: 'ColumnDefaultValue';
value: RawColumnDefaultValueV9Type;
};
@@ -0,0 +1,86 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawModuleDefV8 } from './raw_module_def_v_8_type';
import { RawModuleDefV9 } from './raw_module_def_v_9_type';
import * as RawModuleDefVariants from './raw_module_def_variants';
// The tagged union or sum type for the algebraic type `RawModuleDef`.
export type RawModuleDef =
| RawModuleDefVariants.V8BackCompat
| RawModuleDefVariants.V9;
// A value with helper functions to construct the type.
export const RawModuleDef = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
V8BackCompat: (value: RawModuleDefV8): RawModuleDef => ({
tag: 'V8BackCompat',
value,
}),
V9: (value: RawModuleDefV9): RawModuleDef => ({ tag: 'V9', value }),
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'V8BackCompat',
algebraicType: RawModuleDefV8.getTypeScriptAlgebraicType(),
},
{
name: 'V9',
algebraicType: RawModuleDefV9.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawModuleDef): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawModuleDef.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawModuleDef {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawModuleDef.getTypeScriptAlgebraicType()
);
},
};
export default RawModuleDef;
@@ -0,0 +1,95 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { Typespace } from './typespace_type';
import { TableDesc } from './table_desc_type';
import { ReducerDef } from './reducer_def_type';
import { MiscModuleExport } from './misc_module_export_type';
export type RawModuleDefV8 = {
typespace: Typespace;
tables: TableDesc[];
reducers: ReducerDef[];
miscExports: MiscModuleExport[];
};
/**
* An object for generated helper functions.
*/
export const RawModuleDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'typespace',
algebraicType: Typespace.getTypeScriptAlgebraicType(),
},
{
name: 'tables',
algebraicType: __AlgebraicTypeValue.Array(
TableDesc.getTypeScriptAlgebraicType()
),
},
{
name: 'reducers',
algebraicType: __AlgebraicTypeValue.Array(
ReducerDef.getTypeScriptAlgebraicType()
),
},
{
name: 'miscExports',
algebraicType: __AlgebraicTypeValue.Array(
MiscModuleExport.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawModuleDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawModuleDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawModuleDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawModuleDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawModuleDefV8;
@@ -0,0 +1,111 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { Typespace } from './typespace_type';
import { RawTableDefV9 } from './raw_table_def_v_9_type';
import { RawReducerDefV9 } from './raw_reducer_def_v_9_type';
import { RawTypeDefV9 } from './raw_type_def_v_9_type';
import { RawMiscModuleExportV9 } from './raw_misc_module_export_v_9_type';
import { RawRowLevelSecurityDefV9 } from './raw_row_level_security_def_v_9_type';
export type RawModuleDefV9 = {
typespace: Typespace;
tables: RawTableDefV9[];
reducers: RawReducerDefV9[];
types: RawTypeDefV9[];
miscExports: RawMiscModuleExportV9[];
rowLevelSecurity: RawRowLevelSecurityDefV9[];
};
/**
* An object for generated helper functions.
*/
export const RawModuleDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'typespace',
algebraicType: Typespace.getTypeScriptAlgebraicType(),
},
{
name: 'tables',
algebraicType: __AlgebraicTypeValue.Array(
RawTableDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'reducers',
algebraicType: __AlgebraicTypeValue.Array(
RawReducerDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'types',
algebraicType: __AlgebraicTypeValue.Array(
RawTypeDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'miscExports',
algebraicType: __AlgebraicTypeValue.Array(
RawMiscModuleExportV9.getTypeScriptAlgebraicType()
),
},
{
name: 'rowLevelSecurity',
algebraicType: __AlgebraicTypeValue.Array(
RawRowLevelSecurityDefV9.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawModuleDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawModuleDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawModuleDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawModuleDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawModuleDefV9;
@@ -0,0 +1,35 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawModuleDefV8 as RawModuleDefV8Type } from './raw_module_def_v_8_type';
import { RawModuleDefV9 as RawModuleDefV9Type } from './raw_module_def_v_9_type';
export type V8BackCompat = { tag: 'V8BackCompat'; value: RawModuleDefV8Type };
export type V9 = { tag: 'V9'; value: RawModuleDefV9Type };
@@ -0,0 +1,81 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { ProductType } from './product_type_type';
import { Lifecycle } from './lifecycle_type';
export type RawReducerDefV9 = {
name: string;
params: ProductType;
lifecycle: Lifecycle | undefined;
};
/**
* An object for generated helper functions.
*/
export const RawReducerDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'name', algebraicType: __AlgebraicTypeValue.String },
{
name: 'params',
algebraicType: ProductType.getTypeScriptAlgebraicType(),
},
{
name: 'lifecycle',
algebraicType: __AlgebraicTypeValue.createOptionType(
Lifecycle.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawReducerDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawReducerDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawReducerDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawReducerDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawReducerDefV9;
@@ -0,0 +1,65 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawRowLevelSecurityDefV9 = {
sql: string;
};
/**
* An object for generated helper functions.
*/
export const RawRowLevelSecurityDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [{ name: 'sql', algebraicType: __AlgebraicTypeValue.String }],
});
},
serialize(writer: __BinaryWriter, value: RawRowLevelSecurityDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawRowLevelSecurityDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawRowLevelSecurityDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawRowLevelSecurityDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawRowLevelSecurityDefV9;
@@ -0,0 +1,76 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawScheduleDefV9 = {
name: string | undefined;
reducerName: string;
scheduledAtColumn: number;
};
/**
* An object for generated helper functions.
*/
export const RawScheduleDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{ name: 'reducerName', algebraicType: __AlgebraicTypeValue.String },
{ name: 'scheduledAtColumn', algebraicType: __AlgebraicTypeValue.U16 },
],
});
},
serialize(writer: __BinaryWriter, value: RawScheduleDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawScheduleDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawScheduleDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawScheduleDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawScheduleDefV9;
@@ -0,0 +1,74 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawScopedTypeNameV9 = {
scope: string[];
name: string;
};
/**
* An object for generated helper functions.
*/
export const RawScopedTypeNameV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'scope',
algebraicType: __AlgebraicTypeValue.Array(
__AlgebraicTypeValue.String
),
},
{ name: 'name', algebraicType: __AlgebraicTypeValue.String },
],
});
},
serialize(writer: __BinaryWriter, value: RawScopedTypeNameV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawScopedTypeNameV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawScopedTypeNameV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawScopedTypeNameV9.getTypeScriptAlgebraicType()
);
},
};
export default RawScopedTypeNameV9;
@@ -0,0 +1,94 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawSequenceDefV8 = {
sequenceName: string;
colPos: number;
increment: bigint;
start: bigint | undefined;
minValue: bigint | undefined;
maxValue: bigint | undefined;
allocated: bigint;
};
/**
* An object for generated helper functions.
*/
export const RawSequenceDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'sequenceName', algebraicType: __AlgebraicTypeValue.String },
{ name: 'colPos', algebraicType: __AlgebraicTypeValue.U16 },
{ name: 'increment', algebraicType: __AlgebraicTypeValue.I128 },
{
name: 'start',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{
name: 'minValue',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{
name: 'maxValue',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{ name: 'allocated', algebraicType: __AlgebraicTypeValue.I128 },
],
});
},
serialize(writer: __BinaryWriter, value: RawSequenceDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawSequenceDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawSequenceDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawSequenceDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawSequenceDefV8;
@@ -0,0 +1,97 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawSequenceDefV9 = {
name: string | undefined;
column: number;
start: bigint | undefined;
minValue: bigint | undefined;
maxValue: bigint | undefined;
increment: bigint;
};
/**
* An object for generated helper functions.
*/
export const RawSequenceDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{ name: 'column', algebraicType: __AlgebraicTypeValue.U16 },
{
name: 'start',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{
name: 'minValue',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{
name: 'maxValue',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.I128
),
},
{ name: 'increment', algebraicType: __AlgebraicTypeValue.I128 },
],
});
},
serialize(writer: __BinaryWriter, value: RawSequenceDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawSequenceDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawSequenceDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawSequenceDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawSequenceDefV9;
@@ -0,0 +1,110 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawColumnDefV8 } from './raw_column_def_v_8_type';
import { RawIndexDefV8 } from './raw_index_def_v_8_type';
import { RawConstraintDefV8 } from './raw_constraint_def_v_8_type';
import { RawSequenceDefV8 } from './raw_sequence_def_v_8_type';
export type RawTableDefV8 = {
tableName: string;
columns: RawColumnDefV8[];
indexes: RawIndexDefV8[];
constraints: RawConstraintDefV8[];
sequences: RawSequenceDefV8[];
tableType: string;
tableAccess: string;
scheduled: string | undefined;
};
/**
* An object for generated helper functions.
*/
export const RawTableDefV8 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'tableName', algebraicType: __AlgebraicTypeValue.String },
{
name: 'columns',
algebraicType: __AlgebraicTypeValue.Array(
RawColumnDefV8.getTypeScriptAlgebraicType()
),
},
{
name: 'indexes',
algebraicType: __AlgebraicTypeValue.Array(
RawIndexDefV8.getTypeScriptAlgebraicType()
),
},
{
name: 'constraints',
algebraicType: __AlgebraicTypeValue.Array(
RawConstraintDefV8.getTypeScriptAlgebraicType()
),
},
{
name: 'sequences',
algebraicType: __AlgebraicTypeValue.Array(
RawSequenceDefV8.getTypeScriptAlgebraicType()
),
},
{ name: 'tableType', algebraicType: __AlgebraicTypeValue.String },
{ name: 'tableAccess', algebraicType: __AlgebraicTypeValue.String },
{
name: 'scheduled',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawTableDefV8): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawTableDefV8.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawTableDefV8 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawTableDefV8.getTypeScriptAlgebraicType()
);
},
};
export default RawTableDefV8;
@@ -0,0 +1,118 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawIndexDefV9 } from './raw_index_def_v_9_type';
import { RawConstraintDefV9 } from './raw_constraint_def_v_9_type';
import { RawSequenceDefV9 } from './raw_sequence_def_v_9_type';
import { RawScheduleDefV9 } from './raw_schedule_def_v_9_type';
import { TableType } from './table_type_type';
import { TableAccess } from './table_access_type';
export type RawTableDefV9 = {
name: string;
productTypeRef: number;
primaryKey: number[];
indexes: RawIndexDefV9[];
constraints: RawConstraintDefV9[];
sequences: RawSequenceDefV9[];
schedule: RawScheduleDefV9 | undefined;
tableType: TableType;
tableAccess: TableAccess;
};
/**
* An object for generated helper functions.
*/
export const RawTableDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'name', algebraicType: __AlgebraicTypeValue.String },
{ name: 'productTypeRef', algebraicType: __AlgebraicTypeValue.U32 },
{
name: 'primaryKey',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
{
name: 'indexes',
algebraicType: __AlgebraicTypeValue.Array(
RawIndexDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'constraints',
algebraicType: __AlgebraicTypeValue.Array(
RawConstraintDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'sequences',
algebraicType: __AlgebraicTypeValue.Array(
RawSequenceDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'schedule',
algebraicType: __AlgebraicTypeValue.createOptionType(
RawScheduleDefV9.getTypeScriptAlgebraicType()
),
},
{
name: 'tableType',
algebraicType: TableType.getTypeScriptAlgebraicType(),
},
{
name: 'tableAccess',
algebraicType: TableAccess.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawTableDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawTableDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawTableDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawTableDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawTableDefV9;
@@ -0,0 +1,75 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawScopedTypeNameV9 } from './raw_scoped_type_name_v_9_type';
export type RawTypeDefV9 = {
name: RawScopedTypeNameV9;
ty: number;
customOrdering: boolean;
};
/**
* An object for generated helper functions.
*/
export const RawTypeDefV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: RawScopedTypeNameV9.getTypeScriptAlgebraicType(),
},
{ name: 'ty', algebraicType: __AlgebraicTypeValue.U32 },
{ name: 'customOrdering', algebraicType: __AlgebraicTypeValue.Bool },
],
});
},
serialize(writer: __BinaryWriter, value: RawTypeDefV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawTypeDefV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawTypeDefV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawTypeDefV9.getTypeScriptAlgebraicType()
);
},
};
export default RawTypeDefV9;
@@ -0,0 +1,70 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type RawUniqueConstraintDataV9 = {
columns: number[];
};
/**
* An object for generated helper functions.
*/
export const RawUniqueConstraintDataV9 = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'columns',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U16),
},
],
});
},
serialize(writer: __BinaryWriter, value: RawUniqueConstraintDataV9): void {
__AlgebraicTypeValue.serializeValue(
writer,
RawUniqueConstraintDataV9.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): RawUniqueConstraintDataV9 {
return __AlgebraicTypeValue.deserializeValue(
reader,
RawUniqueConstraintDataV9.getTypeScriptAlgebraicType()
);
},
};
export default RawUniqueConstraintDataV9;
@@ -0,0 +1,75 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { ProductTypeElement } from './product_type_element_type';
export type ReducerDef = {
name: string;
args: ProductTypeElement[];
};
/**
* An object for generated helper functions.
*/
export const ReducerDef = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'name', algebraicType: __AlgebraicTypeValue.String },
{
name: 'args',
algebraicType: __AlgebraicTypeValue.Array(
ProductTypeElement.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: ReducerDef): void {
__AlgebraicTypeValue.serializeValue(
writer,
ReducerDef.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): ReducerDef {
return __AlgebraicTypeValue.deserializeValue(
reader,
ReducerDef.getTypeScriptAlgebraicType()
);
},
};
export default ReducerDef;
@@ -0,0 +1,73 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { SumTypeVariant } from './sum_type_variant_type';
export type SumType = {
variants: SumTypeVariant[];
};
/**
* An object for generated helper functions.
*/
export const SumType = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'variants',
algebraicType: __AlgebraicTypeValue.Array(
SumTypeVariant.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: SumType): void {
__AlgebraicTypeValue.serializeValue(
writer,
SumType.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): SumType {
return __AlgebraicTypeValue.deserializeValue(
reader,
SumType.getTypeScriptAlgebraicType()
);
},
};
export default SumType;
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { AlgebraicType } from './algebraic_type_type';
export type SumTypeVariant = {
name: string | undefined;
algebraicType: AlgebraicType;
};
/**
* An object for generated helper functions.
*/
export const SumTypeVariant = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{
name: 'algebraicType',
algebraicType: AlgebraicType.getTypeScriptAlgebraicType(),
},
],
});
},
serialize(writer: __BinaryWriter, value: SumTypeVariant): void {
__AlgebraicTypeValue.serializeValue(
writer,
SumTypeVariant.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): SumTypeVariant {
return __AlgebraicTypeValue.deserializeValue(
reader,
SumTypeVariant.getTypeScriptAlgebraicType()
);
},
};
export default SumTypeVariant;
@@ -0,0 +1,80 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import * as TableAccessVariants from './table_access_variants';
// The tagged union or sum type for the algebraic type `TableAccess`.
export type TableAccess =
| TableAccessVariants.Public
| TableAccessVariants.Private;
// A value with helper functions to construct the type.
export const TableAccess = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
Public: { tag: 'Public' } as const,
Private: { tag: 'Private' } as const,
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'Public',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'Private',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
serialize(writer: __BinaryWriter, value: TableAccess): void {
__AlgebraicTypeValue.serializeValue(
writer,
TableAccess.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): TableAccess {
return __AlgebraicTypeValue.deserializeValue(
reader,
TableAccess.getTypeScriptAlgebraicType()
);
},
};
export default TableAccess;
@@ -0,0 +1,33 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type Public = { tag: 'Public' };
export type Private = { tag: 'Private' };
@@ -0,0 +1,73 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RawTableDefV8 } from './raw_table_def_v_8_type';
export type TableDesc = {
schema: RawTableDefV8;
data: number;
};
/**
* An object for generated helper functions.
*/
export const TableDesc = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'schema',
algebraicType: RawTableDefV8.getTypeScriptAlgebraicType(),
},
{ name: 'data', algebraicType: __AlgebraicTypeValue.U32 },
],
});
},
serialize(writer: __BinaryWriter, value: TableDesc): void {
__AlgebraicTypeValue.serializeValue(
writer,
TableDesc.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): TableDesc {
return __AlgebraicTypeValue.deserializeValue(
reader,
TableDesc.getTypeScriptAlgebraicType()
);
},
};
export default TableDesc;
@@ -0,0 +1,78 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import * as TableTypeVariants from './table_type_variants';
// The tagged union or sum type for the algebraic type `TableType`.
export type TableType = TableTypeVariants.System | TableTypeVariants.User;
// A value with helper functions to construct the type.
export const TableType = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
System: { tag: 'System' } as const,
User: { tag: 'User' } as const,
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'System',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
{
name: 'User',
algebraicType: __AlgebraicTypeValue.Product({ elements: [] }),
},
],
});
},
serialize(writer: __BinaryWriter, value: TableType): void {
__AlgebraicTypeValue.serializeValue(
writer,
TableType.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): TableType {
return __AlgebraicTypeValue.deserializeValue(
reader,
TableType.getTypeScriptAlgebraicType()
);
},
};
export default TableType;
@@ -0,0 +1,33 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type System = { tag: 'System' };
export type User = { tag: 'User' };
@@ -0,0 +1,69 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type TypeAlias = {
name: string;
ty: number;
};
/**
* An object for generated helper functions.
*/
export const TypeAlias = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'name', algebraicType: __AlgebraicTypeValue.String },
{ name: 'ty', algebraicType: __AlgebraicTypeValue.U32 },
],
});
},
serialize(writer: __BinaryWriter, value: TypeAlias): void {
__AlgebraicTypeValue.serializeValue(
writer,
TypeAlias.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): TypeAlias {
return __AlgebraicTypeValue.deserializeValue(
reader,
TypeAlias.getTypeScriptAlgebraicType()
);
},
};
export default TypeAlias;
@@ -0,0 +1,73 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { AlgebraicType } from './algebraic_type_type';
export type Typespace = {
types: AlgebraicType[];
};
/**
* An object for generated helper functions.
*/
export const Typespace = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'types',
algebraicType: __AlgebraicTypeValue.Array(
AlgebraicType.getTypeScriptAlgebraicType()
),
},
],
});
},
serialize(writer: __BinaryWriter, value: Typespace): void {
__AlgebraicTypeValue.serializeValue(
writer,
Typespace.getTypeScriptAlgebraicType(),
value
);
},
deserialize(reader: __BinaryReader): Typespace {
return __AlgebraicTypeValue.deserializeValue(
reader,
Typespace.getTypeScriptAlgebraicType()
);
},
};
export default Typespace;
@@ -69,7 +69,7 @@ export class ConnectionId {
}
static fromStringOrNull(str: string): ConnectionId | null {
let addr = ConnectionId.fromString(str);
const addr = ConnectionId.fromString(str);
if (addr.isZero()) {
return null;
} else {
@@ -1,5 +1,3 @@
import BinaryReader from './binary_reader';
import BinaryWriter from './binary_writer';
import { hexStringToU256, u256ToHexString, u256ToUint8Array } from './utils';
/**
+10
View File
@@ -0,0 +1,10 @@
export * from './connection_id';
export * from './algebraic_type';
export * from './algebraic_value';
export { default as BinaryReader } from './binary_reader';
export { default as BinaryWriter } from './binary_writer';
export * from './schedule_at';
export * from './time_duration';
export * from './timestamp';
export * from './utils';
export * from './identity';
@@ -0,0 +1,37 @@
import { AlgebraicType } from './algebraic_type';
export const ScheduleAt: {
getAlgebraicType(): AlgebraicType;
} = {
getAlgebraicType(): AlgebraicType {
return AlgebraicType.Sum({
variants: [
{
name: 'Interval',
algebraicType: AlgebraicType.createTimeDurationType(),
},
{ name: 'Time', algebraicType: AlgebraicType.createTimestampType() },
],
});
},
};
export type Interval = {
tag: 'Interval';
value: { __time_duration_micros__: bigint };
};
export const Interval = (value: bigint): Interval => ({
tag: 'Interval',
value: { __time_duration_micros__: value },
});
export type Time = {
tag: 'Time';
value: { __timestamp_micros_since_unix_epoch__: bigint };
};
export const Time = (value: bigint): Time => ({
tag: 'Time',
value: { __timestamp_micros_since_unix_epoch__: value },
});
export type ScheduleAt = Interval | Time;
export default ScheduleAt;
@@ -31,7 +31,7 @@ export function deepEqual(obj1: any, obj2: any): boolean {
if (keys1.length !== keys2.length) return false;
// Check all keys and compare values recursively
for (let key of keys1) {
for (const key of keys1) {
if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {
return false;
}
@@ -64,8 +64,10 @@ export function hexStringToUint8Array(str: string): Uint8Array {
if (str.startsWith('0x')) {
str = str.slice(2);
}
let matches = str.match(/.{1,2}/g) || [];
let data = Uint8Array.from(matches.map((byte: string) => parseInt(byte, 16)));
const matches = str.match(/.{1,2}/g) || [];
const data = Uint8Array.from(
matches.map((byte: string) => parseInt(byte, 16))
);
if (data.length != 32) {
return new Uint8Array(0);
}
@@ -81,7 +83,7 @@ export function hexStringToU256(str: string): bigint {
}
export function u128ToUint8Array(data: bigint): Uint8Array {
let writer = new BinaryWriter(16);
const writer = new BinaryWriter(16);
writer.writeU128(data);
return writer.getBuffer();
}
@@ -91,7 +93,7 @@ export function u128ToHexString(data: bigint): string {
}
export function u256ToUint8Array(data: bigint): Uint8Array {
let writer = new BinaryWriter(32);
const writer = new BinaryWriter(32);
writer.writeU256(data);
return writer.getBuffer();
}
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"strict": true,
"declaration": true,
"emitDeclarationOnly": false,
"noEmit": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowImportingTsExtensions": true,
"noImplicitAny": true,
"moduleResolution": "Bundler",
"isolatedDeclarations": true,
// This library is ESM-only, do not import commonjs modules
"esModuleInterop": false,
"allowSyntheticDefaultImports": false,
"useDefineForClassFields": true,
// Crucial when using esbuild/swc/babel instead of tsc emit:
"verbatimModuleSyntax": true,
"isolatedModules": true
},
"include": ["src/**/*", "tests/**/*"],
"exclude": ["node_modules", "**/__tests__/*", "dist/**/*"]
}
+3 -3
View File
@@ -5,7 +5,7 @@ use clap::parser::ValueSource;
use clap::Arg;
use clap::ArgAction::Set;
use fs_err as fs;
use spacetimedb_codegen::{generate, Csharp, Lang, Rust, TypeScript, AUTO_GENERATED_PREFIX};
use spacetimedb_codegen::{generate, Csharp, Lang, OutputFile, Rust, TypeScript, AUTO_GENERATED_PREFIX};
use spacetimedb_lib::de::serde::DeserializeWrapper;
use spacetimedb_lib::{sats, RawModuleDef};
use spacetimedb_schema;
@@ -145,8 +145,8 @@ pub async fn exec_ex(
Language::TypeScript => &TypeScript,
};
for (fname, code) in generate(&module, gen_lang) {
let fname = Path::new(&fname);
for OutputFile { filename, code } in generate(&module, gen_lang) {
let fname = Path::new(&filename);
// If a generator asks for a file in a subdirectory, create the subdirectory first.
if let Some(parent) = fname.parent().filter(|p| !p.as_os_str().is_empty()) {
fs::create_dir_all(out_dir.join(parent))?;
@@ -9,5 +9,5 @@ edition = "2021"
crate-type = ["cdylib"]
[dependencies]
spacetimedb = "1.3.2"
spacetimedb = "1.4.0"
log = "0.4"
+1 -1
View File
@@ -6,7 +6,7 @@ In this directory:
```sh
cargo run --example get_ws_schema > ws_schema.json
spacetime generate --lang <SDK lang> \
spacetime generate -p spacetimedb-cli --lang <SDK lang> \
--out-dir <sdk WebSocket schema bindings dir> \
--module-def ws_schema.json
```
@@ -3,7 +3,7 @@
use fs_err as fs;
use regex::Regex;
use spacetimedb_codegen::{csharp, generate};
use spacetimedb_codegen::{csharp, generate, OutputFile};
use spacetimedb_lib::{RawModuleDef, RawModuleDefV8};
use spacetimedb_schema::def::ModuleDef;
use std::path::Path;
@@ -39,7 +39,7 @@ fn main() -> anyhow::Result<()> {
},
)
.into_iter()
.try_for_each(|(filename, code)| {
.try_for_each(|OutputFile { filename, code }| {
// Skip anything but raw types (in particular, this will skip top-level SpacetimeDBClient.g.cs which we don't need).
let Some(filename) = filename.strip_prefix("Types/") else {
return Ok(());
@@ -0,0 +1,47 @@
//! This script is used to generate the C# bindings for the `RawModuleDef` type.
//! Run `cargo run --example regen-csharp-moduledef` to update C# bindings whenever the module definition changes.
use fs_err as fs;
use regex::Regex;
use spacetimedb_codegen::{generate, typescript, OutputFile};
use spacetimedb_lib::{RawModuleDef, RawModuleDefV8};
use spacetimedb_schema::def::ModuleDef;
use std::path::Path;
use std::sync::OnceLock;
macro_rules! regex_replace {
($value:expr, $re:expr, $replace:expr) => {{
static RE: OnceLock<Regex> = OnceLock::new();
RE.get_or_init(|| Regex::new($re).unwrap())
.replace_all($value, $replace)
}};
}
fn main() -> anyhow::Result<()> {
let module = RawModuleDefV8::with_builder(|module| {
module.add_type::<RawModuleDef>();
});
let dir = &Path::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../bindings-typescript/src/autogen"
))
.canonicalize()?;
fs::remove_dir_all(dir)?;
fs::create_dir(dir)?;
let module: ModuleDef = module.try_into()?;
generate(&module, &typescript::TypeScript)
.into_iter()
.try_for_each(|OutputFile { filename, code }| {
// Skip the index.ts since we don't need it.
if filename == "index.ts" {
return Ok(());
}
let code = regex_replace!(&code, r"@clockworklabs/spacetimedb-sdk", "../index");
fs::write(dir.join(filename), code.as_bytes())
})?;
Ok(())
}
+29 -28
View File
@@ -6,16 +6,15 @@ use std::ops::Deref;
use super::code_indenter::CodeIndenter;
use super::Lang;
use crate::indent_scope;
use crate::util::{
collect_case, is_reducer_invokable, iter_indexes, iter_reducers, iter_tables, print_auto_generated_file_comment,
type_ref_name,
};
use crate::{indent_scope, OutputFile};
use convert_case::{Case, Casing};
use spacetimedb_lib::sats::layout::PrimitiveType;
use spacetimedb_primitives::ColId;
use spacetimedb_schema::def::{BTreeAlgorithm, IndexAlgorithm, ModuleDef, TableDef, TypeDef};
use spacetimedb_schema::identifier::Identifier;
use spacetimedb_schema::schema::{Schema, TableSchema};
use spacetimedb_schema::type_for_generate::{
AlgebraicTypeDef, AlgebraicTypeUse, PlainEnumTypeDef, ProductTypeDef, SumTypeDef, TypespaceForGenerate,
@@ -434,19 +433,7 @@ pub struct Csharp<'opts> {
}
impl Lang for Csharp<'_> {
fn table_filename(&self, _module: &ModuleDef, table: &TableDef) -> String {
format!("Tables/{}.g.cs", table.name.deref().to_case(Case::Pascal))
}
fn type_filename(&self, type_name: &spacetimedb_schema::def::ScopedTypeName) -> String {
format!("Types/{}.g.cs", collect_case(Case::Pascal, type_name.name_segments()))
}
fn reducer_filename(&self, reducer_name: &Identifier) -> String {
format!("Reducers/{}.g.cs", reducer_name.deref().to_case(Case::Pascal))
}
fn generate_table(&self, module: &ModuleDef, table: &TableDef) -> String {
fn generate_table_file(&self, module: &ModuleDef, table: &TableDef) -> OutputFile {
let mut output = CsharpAutogen::new(
self.namespace,
&[
@@ -572,19 +559,27 @@ impl Lang for Csharp<'_> {
writeln!(output, "public readonly {csharp_table_class_name} {csharp_table_name};");
});
output.into_inner()
}
fn generate_type(&self, module: &ModuleDef, typ: &TypeDef) -> String {
let name = collect_case(Case::Pascal, typ.name.name_segments());
match &module.typespace_for_generate()[typ.ty] {
AlgebraicTypeDef::Sum(sum) => autogen_csharp_sum(module, name, sum, self.namespace),
AlgebraicTypeDef::Product(prod) => autogen_csharp_tuple(module, name, prod, self.namespace),
AlgebraicTypeDef::PlainEnum(plain_enum) => autogen_csharp_plain_enum(name, plain_enum, self.namespace),
OutputFile {
filename: format!("Tables/{}.g.cs", table.name.deref().to_case(Case::Pascal)),
code: output.into_inner(),
}
}
fn generate_reducer(&self, module: &ModuleDef, reducer: &spacetimedb_schema::def::ReducerDef) -> String {
fn generate_type_files(&self, module: &ModuleDef, typ: &TypeDef) -> Vec<OutputFile> {
let name = collect_case(Case::Pascal, typ.name.name_segments());
let filename = format!("Types/{name}.g.cs");
let code = match &module.typespace_for_generate()[typ.ty] {
AlgebraicTypeDef::Sum(sum) => autogen_csharp_sum(module, name.clone(), sum, self.namespace),
AlgebraicTypeDef::Product(prod) => autogen_csharp_tuple(module, name.clone(), prod, self.namespace),
AlgebraicTypeDef::PlainEnum(plain_enum) => {
autogen_csharp_plain_enum(name.clone(), plain_enum, self.namespace)
}
};
vec![OutputFile { filename, code }]
}
fn generate_reducer_file(&self, module: &ModuleDef, reducer: &spacetimedb_schema::def::ReducerDef) -> OutputFile {
let mut output = CsharpAutogen::new(
self.namespace,
&[
@@ -704,10 +699,13 @@ impl Lang for Csharp<'_> {
});
}
output.into_inner()
OutputFile {
filename: format!("Reducers/{}.g.cs", reducer.name.deref().to_case(Case::Pascal)),
code: output.into_inner(),
}
}
fn generate_globals(&self, module: &ModuleDef) -> Vec<(String, String)> {
fn generate_globals_file(&self, module: &ModuleDef) -> OutputFile {
let mut output = CsharpAutogen::new(
self.namespace,
&[
@@ -860,7 +858,10 @@ impl Lang for Csharp<'_> {
});
});
vec![("SpacetimeDBClient.g.cs".to_owned(), output.into_inner())]
OutputFile {
filename: "SpacetimeDBClient.g.cs".to_owned(),
code: output.into_inner(),
}
}
}
+16 -25
View File
@@ -1,5 +1,4 @@
use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, TypeDef};
use spacetimedb_schema::identifier::Identifier;
use spacetimedb_schema::def::{ModuleDef, ReducerDef, TableDef, TypeDef};
mod code_indenter;
pub mod csharp;
@@ -12,32 +11,24 @@ pub use self::rust::Rust;
pub use self::typescript::TypeScript;
pub use util::AUTO_GENERATED_PREFIX;
pub fn generate(module: &ModuleDef, lang: &dyn Lang) -> Vec<(String, String)> {
pub fn generate(module: &ModuleDef, lang: &dyn Lang) -> Vec<OutputFile> {
itertools::chain!(
module
.tables()
.map(|tbl| (lang.table_filename(module, tbl), lang.generate_table(module, tbl))),
module
.types()
.map(|typ| (lang.type_filename(&typ.name), lang.generate_type(module, typ))),
util::iter_reducers(module).map(|reducer| {
(
lang.reducer_filename(&reducer.name),
lang.generate_reducer(module, reducer),
)
}),
lang.generate_globals(module),
module.tables().map(|tbl| lang.generate_table_file(module, tbl)),
module.types().flat_map(|typ| lang.generate_type_files(module, typ)),
util::iter_reducers(module).map(|reducer| lang.generate_reducer_file(module, reducer)),
std::iter::once(lang.generate_globals_file(module)),
)
.collect()
}
pub trait Lang {
fn table_filename(&self, module: &ModuleDef, table: &TableDef) -> String;
fn type_filename(&self, type_name: &ScopedTypeName) -> String;
fn reducer_filename(&self, reducer_name: &Identifier) -> String;
fn generate_table(&self, module: &ModuleDef, tbl: &TableDef) -> String;
fn generate_type(&self, module: &ModuleDef, typ: &TypeDef) -> String;
fn generate_reducer(&self, module: &ModuleDef, reducer: &ReducerDef) -> String;
fn generate_globals(&self, module: &ModuleDef) -> Vec<(String, String)>;
pub struct OutputFile {
pub filename: String,
pub code: String,
}
pub trait Lang {
fn generate_table_file(&self, module: &ModuleDef, tbl: &TableDef) -> OutputFile;
fn generate_type_files(&self, module: &ModuleDef, typ: &TypeDef) -> Vec<OutputFile>;
fn generate_reducer_file(&self, module: &ModuleDef, reducer: &ReducerDef) -> OutputFile;
fn generate_globals_file(&self, module: &ModuleDef) -> OutputFile;
}
+21 -24
View File
@@ -2,6 +2,7 @@ use super::code_indenter::{CodeIndenter, Indenter};
use super::util::{collect_case, iter_reducers, print_lines, type_ref_name};
use super::Lang;
use crate::util::{iter_tables, iter_types, iter_unique_cols, print_auto_generated_file_comment};
use crate::OutputFile;
use convert_case::{Case, Casing};
use spacetimedb_lib::sats::layout::PrimitiveType;
use spacetimedb_lib::sats::AlgebraicTypeRef;
@@ -21,23 +22,7 @@ const INDENT: &str = " ";
pub struct Rust;
impl Lang for Rust {
fn table_filename(
&self,
_module: &spacetimedb_schema::def::ModuleDef,
table: &spacetimedb_schema::def::TableDef,
) -> String {
table_module_name(&table.name) + ".rs"
}
fn type_filename(&self, type_name: &ScopedTypeName) -> String {
type_module_name(type_name) + ".rs"
}
fn reducer_filename(&self, reducer_name: &Identifier) -> String {
reducer_module_name(reducer_name) + ".rs"
}
fn generate_type(&self, module: &ModuleDef, typ: &TypeDef) -> String {
fn generate_type_files(&self, module: &ModuleDef, typ: &TypeDef) -> Vec<OutputFile> {
let type_name = collect_case(Case::Pascal, typ.name.name_segments());
let mut output = CodeIndenter::new(String::new(), INDENT);
@@ -78,9 +63,12 @@ impl __sdk::InModule for {type_name} {{
",
);
output.into_inner()
vec![OutputFile {
filename: type_module_name(&typ.name) + ".rs",
code: output.into_inner(),
}]
}
fn generate_table(&self, module: &ModuleDef, table: &TableDef) -> String {
fn generate_table_file(&self, module: &ModuleDef, table: &TableDef) -> OutputFile {
let schema = TableSchema::from_module_def(module, table, (), 0.into())
.validated()
.expect("Failed to generate table due to validation errors");
@@ -301,9 +289,12 @@ pub(super) fn parse_table_update(
// TODO: expose non-unique indices.
output.into_inner()
OutputFile {
filename: table_module_name(&table.name) + ".rs",
code: output.into_inner(),
}
}
fn generate_reducer(&self, module: &ModuleDef, reducer: &ReducerDef) -> String {
fn generate_reducer_file(&self, module: &ModuleDef, reducer: &ReducerDef) -> OutputFile {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
@@ -488,10 +479,13 @@ impl {set_reducer_flags_trait} for super::SetReducerFlags {{
"
);
output.into_inner()
OutputFile {
filename: reducer_module_name(&reducer.name) + ".rs",
code: output.into_inner(),
}
}
fn generate_globals(&self, module: &ModuleDef) -> Vec<(String, String)> {
fn generate_globals_file(&self, module: &ModuleDef) -> OutputFile {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
@@ -534,7 +528,10 @@ impl {set_reducer_flags_trait} for super::SetReducerFlags {{
// This includes a method for initializing the tables in the client cache.
print_impl_spacetime_module(module, out);
vec![("mod.rs".to_string(), (output.into_inner()))]
OutputFile {
filename: "mod.rs".to_string(),
code: output.into_inner(),
}
}
}
+238 -176
View File
@@ -1,5 +1,5 @@
use crate::indent_scope;
use crate::util::{is_reducer_invokable, iter_reducers, iter_tables, iter_types, iter_unique_cols};
use crate::{indent_scope, OutputFile};
use super::util::{collect_case, print_auto_generated_file_comment, type_ref_name};
@@ -13,7 +13,7 @@ use spacetimedb_lib::sats::AlgebraicTypeRef;
use spacetimedb_schema::def::{ModuleDef, ReducerDef, ScopedTypeName, TableDef, TypeDef};
use spacetimedb_schema::identifier::Identifier;
use spacetimedb_schema::schema::{Schema, TableSchema};
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse};
use spacetimedb_schema::type_for_generate::{AlgebraicTypeDef, AlgebraicTypeUse, ProductTypeDef};
use super::code_indenter::{CodeIndenter, Indenter};
use super::Lang;
@@ -26,40 +26,72 @@ const INDENT: &str = " ";
pub struct TypeScript;
impl Lang for TypeScript {
fn table_filename(
&self,
_module: &spacetimedb_schema::def::ModuleDef,
table: &spacetimedb_schema::def::TableDef,
) -> String {
table_module_name(&table.name) + ".ts"
}
fn type_filename(&self, type_name: &ScopedTypeName) -> String {
type_module_name(type_name) + ".ts"
}
fn reducer_filename(&self, reducer_name: &Identifier) -> String {
reducer_module_name(reducer_name) + ".ts"
}
fn generate_type(&self, module: &ModuleDef, typ: &TypeDef) -> String {
// TODO(cloutiertyler): I do think TypeScript does support namespaces:
// https://www.typescriptlang.org/docs/handbook/namespaces.html
fn generate_type_files(&self, module: &ModuleDef, typ: &TypeDef) -> Vec<OutputFile> {
let type_name = collect_case(Case::Pascal, typ.name.name_segments());
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
let define_type_for_product = |product: &ProductTypeDef| {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
print_file_header(out);
print_file_header(out);
gen_and_print_imports(module, out, &product.elements, &[typ.ty], None);
writeln!(out);
define_body_for_product(module, out, &type_name, &product.elements);
out.newline();
OutputFile {
filename: type_module_name(&typ.name) + ".ts",
code: output.into_inner(),
}
};
let define_variants_for_sum = |variants: &[(Identifier, AlgebraicTypeUse)]| {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
print_file_header(out);
// Note that the current type is not included in dont_import below.
gen_and_print_imports(module, out, variants, &[], Some("Type"));
writeln!(out);
write_variant_types(module, out, variants);
out.newline();
OutputFile {
filename: variants_module_name(&typ.name) + ".ts",
code: output.into_inner(),
}
};
let define_type_for_sum = |variants: &[(Identifier, AlgebraicTypeUse)]| {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
print_file_header(out);
gen_and_print_imports(module, out, variants, &[typ.ty], None);
writeln!(
out,
"import * as {}Variants from './{}'",
type_name,
variants_module_name(&typ.name)
);
writeln!(out);
// For the purpose of bootstrapping AlgebraicType, if the name of the type
// is `AlgebraicType`, we need to use an alias.
define_body_for_sum(module, out, &type_name, variants);
out.newline();
OutputFile {
filename: type_module_name(&typ.name) + ".ts",
code: output.into_inner(),
}
};
match &module.typespace_for_generate()[typ.ty] {
AlgebraicTypeDef::Product(product) => {
gen_and_print_imports(module, out, &product.elements, &[typ.ty]);
define_namespace_and_object_type_for_product(module, out, &type_name, &product.elements);
vec![define_type_for_product(product)]
}
AlgebraicTypeDef::Sum(sum) => {
gen_and_print_imports(module, out, &sum.variants, &[typ.ty]);
define_namespace_and_types_for_sum(module, out, &type_name, &sum.variants);
vec![
define_variants_for_sum(&sum.variants),
define_type_for_sum(&sum.variants),
]
}
AlgebraicTypeDef::PlainEnum(plain_enum) => {
let variants = plain_enum
@@ -68,15 +100,12 @@ impl Lang for TypeScript {
.cloned()
.map(|var| (var, AlgebraicTypeUse::Unit))
.collect::<Vec<_>>();
define_namespace_and_types_for_sum(module, out, &type_name, &variants);
vec![define_variants_for_sum(&variants), define_type_for_sum(&variants)]
}
}
out.newline();
output.into_inner()
}
fn generate_table(&self, module: &ModuleDef, table: &TableDef) -> String {
fn generate_table_file(&self, module: &ModuleDef, table: &TableDef) -> OutputFile {
let schema = TableSchema::from_module_def(module, table, (), 0.into())
.validated()
.expect("Failed to generate table due to validation errors");
@@ -102,6 +131,7 @@ impl Lang for TypeScript {
out,
&product_def.elements,
&[], // No need to skip any imports; we're not defining a type, so there's no chance of circular imports.
None,
);
writeln!(
@@ -132,9 +162,9 @@ export class {table_handle} {{
"
);
out.indent(1);
writeln!(out, "tableCache: TableCache<{row_type}>;");
writeln!(out, "tableCache: __TableCache<{row_type}>;");
writeln!(out);
writeln!(out, "constructor(tableCache: TableCache<{row_type}>) {{");
writeln!(out, "constructor(tableCache: __TableCache<{row_type}>) {{");
out.with_indent(|out| writeln!(out, "this.tableCache = tableCache;"));
writeln!(out, "}}");
writeln!(out);
@@ -187,7 +217,7 @@ export class {table_handle} {{
out.with_indent(|out| {
writeln!(out, "for (let row of this.tableCache.iter()) {{");
out.with_indent(|out| {
writeln!(out, "if (deepEqual(row.{unique_field_name}, col_val)) {{");
writeln!(out, "if (__deepEqual(row.{unique_field_name}, col_val)) {{");
out.with_indent(|out| {
writeln!(out, "return row;");
});
@@ -240,10 +270,13 @@ removeOnUpdate = (cb: (ctx: EventContext, onRow: {row_type}, newRow: {row_type})
out.dedent(1);
writeln!(out, "}}");
output.into_inner()
OutputFile {
filename: table_module_name(&table.name) + ".ts",
code: output.into_inner(),
}
}
fn generate_reducer(&self, module: &ModuleDef, reducer: &ReducerDef) -> String {
fn generate_reducer_file(&self, module: &ModuleDef, reducer: &ReducerDef) -> OutputFile {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
@@ -257,16 +290,20 @@ removeOnUpdate = (cb: (ctx: EventContext, onRow: {row_type}, newRow: {row_type})
&reducer.params_for_generate.elements,
// No need to skip any imports; we're not emitting a type that other modules can import.
&[],
None,
);
let args_type = reducer_args_type_name(&reducer.name);
define_namespace_and_object_type_for_product(module, out, &args_type, &reducer.params_for_generate.elements);
define_body_for_product(module, out, &args_type, &reducer.params_for_generate.elements);
output.into_inner()
OutputFile {
filename: reducer_module_name(&reducer.name) + ".ts",
code: output.into_inner(),
}
}
fn generate_globals(&self, module: &ModuleDef) -> Vec<(String, String)> {
fn generate_globals_file(&self, module: &ModuleDef) -> OutputFile {
let mut output = CodeIndenter::new(String::new(), INDENT);
let out = &mut output;
@@ -332,7 +369,7 @@ removeOnUpdate = (cb: (ctx: EventContext, onRow: {row_type}, newRow: {row_type})
writeln!(out, "colName: \"{}\",", pk.col_name.to_string().to_case(Case::Camel));
writeln!(
out,
"colType: {row_type}.getTypeScriptAlgebraicType().product.elements[{}].algebraicType,",
"colType: ({row_type}.getTypeScriptAlgebraicType() as __AlgebraicTypeVariants.Product).value.elements[{}].algebraicType,",
pk.col_pos.0
);
out.dedent(1);
@@ -373,16 +410,16 @@ removeOnUpdate = (cb: (ctx: EventContext, onRow: {row_type}, newRow: {row_type})
// all we do is build a TypeScript object which we could have done inside the
// SDK, but if in the future we wanted to create a class this would be
// necessary because classes have methods, so we'll keep it.
eventContextConstructor: (imp: DbConnectionImpl, event: Event<Reducer>) => {{
eventContextConstructor: (imp: __DbConnectionImpl, event: __Event<Reducer>) => {{
return {{
...(imp as DbConnection),
event
}}
}},
dbViewConstructor: (imp: DbConnectionImpl) => {{
dbViewConstructor: (imp: __DbConnectionImpl) => {{
return new RemoteTables(imp);
}},
reducersConstructor: (imp: DbConnectionImpl, setReducerFlags: SetReducerFlags) => {{
reducersConstructor: (imp: __DbConnectionImpl, setReducerFlags: SetReducerFlags) => {{
return new RemoteReducers(imp, setReducerFlags);
}},
setReducerFlagsConstructor: () => {{
@@ -420,25 +457,28 @@ setReducerFlagsConstructor: () => {{
writeln!(
out,
"export type EventContext = EventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags, Reducer>;"
"export type EventContext = __EventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags, Reducer>;"
);
writeln!(
out,
"export type ReducerEventContext = ReducerEventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags, Reducer>;"
"export type ReducerEventContext = __ReducerEventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags, Reducer>;"
);
writeln!(
out,
"export type SubscriptionEventContext = SubscriptionEventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags>;"
"export type SubscriptionEventContext = __SubscriptionEventContextInterface<RemoteTables, RemoteReducers, SetReducerFlags>;"
);
writeln!(
out,
"export type ErrorContext = ErrorContextInterface<RemoteTables, RemoteReducers, SetReducerFlags>;"
"export type ErrorContext = __ErrorContextInterface<RemoteTables, RemoteReducers, SetReducerFlags>;"
);
vec![("index.ts".to_string(), (output.into_inner()))]
OutputFile {
filename: "index.ts".to_string(),
code: output.into_inner(),
}
}
}
@@ -447,7 +487,7 @@ fn print_remote_reducers(module: &ModuleDef, out: &mut Indenter) {
out.indent(1);
writeln!(
out,
"constructor(private connection: DbConnectionImpl, private setCallReducerFlags: SetReducerFlags) {{}}"
"constructor(private connection: __DbConnectionImpl, private setCallReducerFlags: SetReducerFlags) {{}}"
);
out.newline();
@@ -462,7 +502,7 @@ fn print_remote_reducers(module: &ModuleDef, out: &mut Indenter) {
arg_name_list += &arg_name;
arg_list += &arg_name;
arg_list += ": ";
write_type(module, &mut arg_list, arg_ty, None).unwrap();
write_type(module, &mut arg_list, arg_ty, None, None).unwrap();
arg_list += ", ";
arg_name_list += ", ";
}
@@ -486,7 +526,7 @@ fn print_remote_reducers(module: &ModuleDef, out: &mut Indenter) {
writeln!(out, "{reducer_function_name}({arg_list}) {{");
out.with_indent(|out| {
writeln!(out, "const __args = {{ {arg_name_list} }};");
writeln!(out, "let __writer = new BinaryWriter(1024);");
writeln!(out, "let __writer = new __BinaryWriter(1024);");
writeln!(
out,
"{reducer_variant}.getTypeScriptAlgebraicType().serialize(__writer, __args);"
@@ -535,8 +575,8 @@ fn print_set_reducer_flags(module: &ModuleDef, out: &mut Indenter) {
for reducer in iter_reducers(module).filter(|r| is_reducer_invokable(r)) {
let reducer_function_name = reducer_function_name(reducer);
writeln!(out, "{reducer_function_name}Flags: CallReducerFlags = 'FullUpdate';");
writeln!(out, "{reducer_function_name}(flags: CallReducerFlags) {{");
writeln!(out, "{reducer_function_name}Flags: __CallReducerFlags = 'FullUpdate';");
writeln!(out, "{reducer_function_name}(flags: __CallReducerFlags) {{");
out.with_indent(|out| {
writeln!(out, "this.{reducer_function_name}Flags = flags;");
});
@@ -551,7 +591,7 @@ fn print_set_reducer_flags(module: &ModuleDef, out: &mut Indenter) {
fn print_remote_tables(module: &ModuleDef, out: &mut Indenter) {
writeln!(out, "export class RemoteTables {{");
out.indent(1);
writeln!(out, "constructor(private connection: DbConnectionImpl) {{}}");
writeln!(out, "constructor(private connection: __DbConnectionImpl) {{}}");
for table in iter_tables(module) {
writeln!(out);
@@ -578,24 +618,24 @@ fn print_remote_tables(module: &ModuleDef, out: &mut Indenter) {
fn print_subscription_builder(_module: &ModuleDef, out: &mut Indenter) {
writeln!(
out,
"export class SubscriptionBuilder extends SubscriptionBuilderImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{ }}"
"export class SubscriptionBuilder extends __SubscriptionBuilderImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{ }}"
);
}
fn print_db_connection(_module: &ModuleDef, out: &mut Indenter) {
writeln!(
out,
"export class DbConnection extends DbConnectionImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{"
"export class DbConnection extends __DbConnectionImpl<RemoteTables, RemoteReducers, SetReducerFlags> {{"
);
out.indent(1);
writeln!(
out,
"static builder = (): DbConnectionBuilder<DbConnection, ErrorContext, SubscriptionEventContext> => {{"
"static builder = (): __DbConnectionBuilder<DbConnection, ErrorContext, SubscriptionEventContext> => {{"
);
out.indent(1);
writeln!(
out,
"return new DbConnectionBuilder<DbConnection, ErrorContext, SubscriptionEventContext>(REMOTE_MODULE, (imp: DbConnectionImpl) => imp as DbConnection);"
"return new __DbConnectionBuilder<DbConnection, ErrorContext, SubscriptionEventContext>(REMOTE_MODULE, (imp: __DbConnectionImpl) => imp as DbConnection);"
);
out.dedent(1);
writeln!(out, "}}");
@@ -623,31 +663,29 @@ fn print_reducer_enum_defn(module: &ModuleDef, out: &mut Indenter) {
}
fn print_spacetimedb_imports(out: &mut Indenter) {
// All library imports are prefixed with `__` to avoid
// clashing with the names of user generated types.
let mut types = [
"AlgebraicType",
"ProductType",
"ProductTypeElement",
"SumType",
"SumTypeVariant",
"AlgebraicValue",
"Identity",
"ConnectionId",
"Timestamp",
"TimeDuration",
"DbConnectionBuilder",
"TableCache",
"BinaryWriter",
"type CallReducerFlags",
"type EventContextInterface",
"type ReducerEventContextInterface",
"type SubscriptionEventContextInterface",
"type ErrorContextInterface",
"SubscriptionBuilderImpl",
"BinaryReader",
"DbConnectionImpl",
"type DbContext",
"type Event",
"deepEqual",
"type AlgebraicType as __AlgebraicTypeType",
"AlgebraicType as __AlgebraicTypeValue",
"type AlgebraicTypeVariants as __AlgebraicTypeVariants",
"Identity as __Identity",
"ConnectionId as __ConnectionId",
"Timestamp as __Timestamp",
"TimeDuration as __TimeDuration",
"DbConnectionBuilder as __DbConnectionBuilder",
"TableCache as __TableCache",
"BinaryWriter as __BinaryWriter",
"type CallReducerFlags as __CallReducerFlags",
"type EventContextInterface as __EventContextInterface",
"type ReducerEventContextInterface as __ReducerEventContextInterface",
"type SubscriptionEventContextInterface as __SubscriptionEventContextInterface",
"type ErrorContextInterface as __ErrorContextInterface",
"SubscriptionBuilderImpl as __SubscriptionBuilderImpl",
"BinaryReader as __BinaryReader",
"DbConnectionImpl as __DbConnectionImpl",
"type Event as __Event",
"deepEqual as __deepEqual",
];
types.sort();
writeln!(out, "import {{");
@@ -683,18 +721,18 @@ fn write_get_algebraic_type_for_product(
* This function is derived from the AlgebraicType used to generate this type.
*/"
);
writeln!(out, "export function getTypeScriptAlgebraicType(): AlgebraicType {{");
writeln!(out, "getTypeScriptAlgebraicType(): __AlgebraicTypeType {{");
{
out.indent(1);
write!(out, "return ");
convert_product_type(module, out, elements, "__");
convert_product_type(module, out, elements, "");
writeln!(out, ";");
out.dedent(1);
}
writeln!(out, "}}");
writeln!(out, "}},");
}
fn define_namespace_and_object_type_for_product(
fn define_body_for_product(
module: &ModuleDef,
out: &mut Indenter,
name: &str,
@@ -709,40 +747,45 @@ fn define_namespace_and_object_type_for_product(
writeln!(out, "}};");
}
out.newline();
writeln!(
out,
"/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/"
);
writeln!(out, "export namespace {name} {{");
writeln!(out, "export const {name} = {{");
out.indent(1);
write_get_algebraic_type_for_product(module, out, elements);
writeln!(out);
writeln!(out, "serialize(writer: __BinaryWriter, value: {name}): void {{");
out.indent(1);
writeln!(
out,
"export function serialize(writer: BinaryWriter, value: {name}): void {{"
"__AlgebraicTypeValue.serializeValue(writer, {name}.getTypeScriptAlgebraicType(), value);"
);
out.indent(1);
writeln!(out, "{name}.getTypeScriptAlgebraicType().serialize(writer, value);");
out.dedent(1);
writeln!(out, "}}");
writeln!(out, "}},");
writeln!(out);
writeln!(out, "export function deserialize(reader: BinaryReader): {name} {{");
writeln!(out, "deserialize(reader: __BinaryReader): {name} {{");
out.indent(1);
writeln!(out, "return {name}.getTypeScriptAlgebraicType().deserialize(reader);");
writeln!(
out,
"return __AlgebraicTypeValue.deserializeValue(reader, {name}.getTypeScriptAlgebraicType());"
);
out.dedent(1);
writeln!(out, "}}");
writeln!(out, "}},");
writeln!(out);
out.dedent(1);
writeln!(out, "}}");
out.newline();
writeln!(out, "export default {name};");
out.newline();
}
fn write_arglist_no_delimiters(
@@ -764,7 +807,7 @@ fn write_arglist_no_delimiters(
};
write!(out, "{name}: ")?;
write_type(module, out, ty, Some("__"))?;
write_type(module, out, ty, None, None)?;
writeln!(out, ",")?;
}
@@ -785,25 +828,25 @@ fn write_sum_variant_type(module: &ModuleDef, out: &mut Indenter, ident: &Identi
// If the contained type is not the unit type, write the tag and the value.
// ```
// { tag: "Bar", value: Bar }
// { tag: "Bar", value: BarType }
// { tag: "Bar", value: number }
// { tag: "Bar", value: string }
// ```
// Note you could alternatively do:
// ```
// { tag: "Bar" } & Bar
// { tag: "Bar" } & BarType
// ```
// for non-primitive types but that doesn't extend to primitives.
// Another alternative would be to name the value field the same as the tag field, but lowercased
// ```
// { tag: "Bar", bar: Bar }
// { tag: "Bar", bar: BarType }
// { tag: "Bar", bar: number }
// { tag: "Bar", bar: string }
// ```
// but this is a departure from our previous convention and is not much different.
if !matches!(ty, AlgebraicTypeUse::Unit) {
write!(out, ", value: ");
write_type(module, out, ty, Some("__")).unwrap();
write_type(module, out, ty, None, Some("Type")).unwrap();
}
writeln!(out, " }};");
@@ -828,16 +871,16 @@ fn write_variant_constructors(
if matches!(ty, AlgebraicTypeUse::Unit) {
// If the variant has no members, we can export a simple object.
// ```
// export const Foo = { tag: "Foo" };
// Foo: { tag: "Foo" } = { tag: "Foo" } as const,
// ```
write!(out, "export const {ident} = ");
writeln!(out, "{{ tag: \"{ident}\" }};");
write!(out, "{ident}: {{ tag: \"{ident}\" }} as const,");
writeln!(out);
continue;
}
let variant_name = ident.deref().to_case(Case::Pascal);
write!(out, "export const {variant_name} = (value: ");
write_type(module, out, ty, Some("__")).unwrap();
writeln!(out, "): {name} => ({{ tag: \"{variant_name}\", value }});");
write!(out, "{variant_name}: (value: ");
write_type(module, out, ty, None, None).unwrap();
writeln!(out, "): {name} => ({{ tag: \"{variant_name}\", value }}),");
}
}
@@ -846,35 +889,43 @@ fn write_get_algebraic_type_for_sum(
out: &mut Indenter,
variants: &[(Identifier, AlgebraicTypeUse)],
) {
writeln!(out, "export function getTypeScriptAlgebraicType(): AlgebraicType {{");
writeln!(out, "getTypeScriptAlgebraicType(): __AlgebraicTypeType {{");
{
indent_scope!(out);
write!(out, "return ");
convert_sum_type(module, &mut out, variants, "__");
convert_sum_type(module, &mut out, variants, "");
writeln!(out, ";");
}
writeln!(out, "}}");
writeln!(out, "}},");
}
fn define_namespace_and_types_for_sum(
fn define_body_for_sum(
module: &ModuleDef,
out: &mut Indenter,
name: &str,
variants: &[(Identifier, AlgebraicTypeUse)],
) {
writeln!(out, "// A namespace for generated variants and helper functions.");
writeln!(out, "export namespace {name} {{");
out.indent(1);
writeln!(out, "// The tagged union or sum type for the algebraic type `{name}`.");
write!(out, "export type {name} = ");
// Write all of the variant types.
writeln!(
out,
"// These are the generated variant types for each variant of the tagged union.
// One type is generated per variant and will be used in the `value` field of
// the tagged union."
);
write_variant_types(module, out, variants);
writeln!(out);
let names = variants
.iter()
.map(|(ident, _)| format!("{name}Variants.{}", ident.deref().to_case(Case::Pascal)))
.collect::<Vec<String>>()
.join(" |\n ");
if variants.is_empty() {
writeln!(out, "never;");
} else {
writeln!(out, "{names};");
}
out.newline();
// Write the runtime value with helper functions
writeln!(out, "// A value with helper functions to construct the type.");
writeln!(out, "export const {name} = {{");
out.indent(1);
// Write all of the variant constructors.
writeln!(
@@ -895,17 +946,17 @@ fn define_namespace_and_types_for_sum(
writeln!(
out,
"export function serialize(writer: BinaryWriter, value: {name}): void {{
{name}.getTypeScriptAlgebraicType().serialize(writer, value);
}}"
"serialize(writer: __BinaryWriter, value: {name}): void {{
__AlgebraicTypeValue.serializeValue(writer, {name}.getTypeScriptAlgebraicType(), value);
}},"
);
writeln!(out);
writeln!(
out,
"export function deserialize(reader: BinaryReader): {name} {{
return {name}.getTypeScriptAlgebraicType().deserialize(reader);
}}"
"deserialize(reader: __BinaryReader): {name} {{
return __AlgebraicTypeValue.deserializeValue(reader, {name}.getTypeScriptAlgebraicType());
}},"
);
writeln!(out);
@@ -914,19 +965,9 @@ fn define_namespace_and_types_for_sum(
writeln!(out, "}}");
out.newline();
writeln!(out, "// The tagged union or sum type for the algebraic type `{name}`.");
write!(out, "export type {name} = ");
let names = variants
.iter()
.map(|(ident, _)| format!("{name}.{}", ident.deref().to_case(Case::Pascal)))
.collect::<Vec<String>>()
.join(" | ");
writeln!(out, "{names};");
out.newline();
writeln!(out, "export default {name};");
out.newline();
}
fn type_ref_module_name(module: &ModuleDef, type_ref: AlgebraicTypeRef) -> String {
@@ -938,6 +979,10 @@ fn type_module_name(type_name: &ScopedTypeName) -> String {
collect_case(Case::Snake, type_name.name_segments()) + "_type"
}
fn variants_module_name(type_name: &ScopedTypeName) -> String {
collect_case(Case::Snake, type_name.name_segments()) + "_variants"
}
fn table_module_name(table_name: &Identifier) -> String {
table_name.deref().to_case(Case::Snake) + "_table"
}
@@ -964,7 +1009,7 @@ fn reducer_function_name(reducer: &ReducerDef) -> String {
pub fn type_name(module: &ModuleDef, ty: &AlgebraicTypeUse) -> String {
let mut s = String::new();
write_type(module, &mut s, ty, None).unwrap();
write_type(module, &mut s, ty, None, None).unwrap();
s
}
@@ -996,20 +1041,21 @@ pub fn write_type<W: Write>(
out: &mut W,
ty: &AlgebraicTypeUse,
ref_prefix: Option<&str>,
ref_suffix: Option<&str>,
) -> fmt::Result {
match ty {
AlgebraicTypeUse::Unit => write!(out, "void")?,
AlgebraicTypeUse::Never => write!(out, "never")?,
AlgebraicTypeUse::Identity => write!(out, "Identity")?,
AlgebraicTypeUse::ConnectionId => write!(out, "ConnectionId")?,
AlgebraicTypeUse::Timestamp => write!(out, "Timestamp")?,
AlgebraicTypeUse::TimeDuration => write!(out, "TimeDuration")?,
AlgebraicTypeUse::Identity => write!(out, "__Identity")?,
AlgebraicTypeUse::ConnectionId => write!(out, "__ConnectionId")?,
AlgebraicTypeUse::Timestamp => write!(out, "__Timestamp")?,
AlgebraicTypeUse::TimeDuration => write!(out, "__TimeDuration")?,
AlgebraicTypeUse::ScheduleAt => write!(
out,
"{{ tag: \"Interval\", value: TimeDuration }} | {{ tag: \"Time\", value: Timestamp }}"
"{{ tag: \"Interval\", value: __TimeDuration }} | {{ tag: \"Time\", value: __Timestamp }}"
)?,
AlgebraicTypeUse::Option(inner_ty) => {
write_type(module, out, inner_ty, ref_prefix)?;
write_type(module, out, inner_ty, ref_prefix, ref_suffix)?;
write!(out, " | undefined")?;
}
AlgebraicTypeUse::Primitive(prim) => match prim {
@@ -1039,7 +1085,7 @@ pub fn write_type<W: Write>(
if needs_parens {
write!(out, "(")?;
}
write_type(module, out, elem_ty, ref_prefix)?;
write_type(module, out, elem_ty, ref_prefix, ref_suffix)?;
if needs_parens {
write!(out, ")")?;
}
@@ -1050,6 +1096,9 @@ pub fn write_type<W: Write>(
write!(out, "{prefix}")?;
}
write!(out, "{}", type_ref_name(module, *r))?;
if let Some(suffix) = ref_suffix {
write!(out, "{suffix}")?;
}
}
}
Ok(())
@@ -1062,18 +1111,18 @@ fn convert_algebraic_type<'a>(
ref_prefix: &'a str,
) {
match ty {
AlgebraicTypeUse::ScheduleAt => write!(out, "AlgebraicType.createScheduleAtType()"),
AlgebraicTypeUse::Identity => write!(out, "AlgebraicType.createIdentityType()"),
AlgebraicTypeUse::ConnectionId => write!(out, "AlgebraicType.createConnectionIdType()"),
AlgebraicTypeUse::Timestamp => write!(out, "AlgebraicType.createTimestampType()"),
AlgebraicTypeUse::TimeDuration => write!(out, "AlgebraicType.createTimeDurationType()"),
AlgebraicTypeUse::ScheduleAt => write!(out, "__AlgebraicTypeValue.createScheduleAtType()"),
AlgebraicTypeUse::Identity => write!(out, "__AlgebraicTypeValue.createIdentityType()"),
AlgebraicTypeUse::ConnectionId => write!(out, "__AlgebraicTypeValue.createConnectionIdType()"),
AlgebraicTypeUse::Timestamp => write!(out, "__AlgebraicTypeValue.createTimestampType()"),
AlgebraicTypeUse::TimeDuration => write!(out, "__AlgebraicTypeValue.createTimeDurationType()"),
AlgebraicTypeUse::Option(inner_ty) => {
write!(out, "AlgebraicType.createOptionType(");
write!(out, "__AlgebraicTypeValue.createOptionType(");
convert_algebraic_type(module, out, inner_ty, ref_prefix);
write!(out, ")");
}
AlgebraicTypeUse::Array(ty) => {
write!(out, "AlgebraicType.createArrayType(");
write!(out, "__AlgebraicTypeValue.Array(");
convert_algebraic_type(module, out, ty, ref_prefix);
write!(out, ")");
}
@@ -1083,11 +1132,11 @@ fn convert_algebraic_type<'a>(
type_ref_name(module, *r)
),
AlgebraicTypeUse::Primitive(prim) => {
write!(out, "AlgebraicType.create{prim:?}Type()");
write!(out, "__AlgebraicTypeValue.{prim:?}");
}
AlgebraicTypeUse::Unit => write!(out, "AlgebraicType.createProductType([])"),
AlgebraicTypeUse::Unit => write!(out, "__AlgebraicTypeValue.Product({{ elements: [] }})"),
AlgebraicTypeUse::Never => unimplemented!(),
AlgebraicTypeUse::String => write!(out, "AlgebraicType.createStringType()"),
AlgebraicTypeUse::String => write!(out, "__AlgebraicTypeValue.String"),
}
}
@@ -1097,15 +1146,19 @@ fn convert_sum_type<'a>(
variants: &'a [(Identifier, AlgebraicTypeUse)],
ref_prefix: &'a str,
) {
writeln!(out, "AlgebraicType.createSumType([");
writeln!(out, "__AlgebraicTypeValue.Sum({{");
out.indent(1);
writeln!(out, "variants: [");
out.indent(1);
for (ident, ty) in variants {
write!(out, "new SumTypeVariant(\"{ident}\", ",);
write!(out, "{{ name: \"{ident}\", algebraicType: ",);
convert_algebraic_type(module, out, ty, ref_prefix);
writeln!(out, "),");
writeln!(out, " }},");
}
out.dedent(1);
write!(out, "])")
writeln!(out, "]");
out.dedent(1);
write!(out, "}})")
}
fn convert_product_type<'a>(
@@ -1114,30 +1167,38 @@ fn convert_product_type<'a>(
elements: &'a [(Identifier, AlgebraicTypeUse)],
ref_prefix: &'a str,
) {
writeln!(out, "AlgebraicType.createProductType([");
writeln!(out, "__AlgebraicTypeValue.Product({{");
out.indent(1);
writeln!(out, "elements: [");
out.indent(1);
for (ident, ty) in elements {
write!(
out,
"new ProductTypeElement(\"{}\", ",
"{{ name: \"{}\", algebraicType: ",
ident.deref().to_case(Case::Camel)
);
convert_algebraic_type(module, out, ty, ref_prefix);
writeln!(out, "),");
writeln!(out, "}},");
}
out.dedent(1);
write!(out, "])")
writeln!(out, "]");
out.dedent(1);
write!(out, "}})")
}
/// Print imports for each of the `imports`.
fn print_imports(module: &ModuleDef, out: &mut Indenter, imports: Imports) {
fn print_imports(module: &ModuleDef, out: &mut Indenter, imports: Imports, suffix: Option<&str>) {
for typeref in imports {
let module_name = type_ref_module_name(module, typeref);
let type_name = type_ref_name(module, typeref);
writeln!(
out,
"import {{ {type_name} as __{type_name} }} from \"./{module_name}\";"
);
if let Some(suffix) = suffix {
writeln!(
out,
"import {{ {type_name} as {type_name}{suffix} }} from \"./{module_name}\";"
);
} else {
writeln!(out, "import {{ {type_name} }} from \"./{module_name}\";");
}
}
}
@@ -1151,6 +1212,7 @@ fn gen_and_print_imports(
out: &mut Indenter,
roots: &[(Identifier, AlgebraicTypeUse)],
dont_import: &[AlgebraicTypeRef],
suffix: Option<&str>,
) {
let mut imports = BTreeSet::new();
@@ -1164,7 +1226,7 @@ fn gen_and_print_imports(
}
let len = imports.len();
print_imports(module, out, imports);
print_imports(module, out, imports, suffix);
if len > 0 {
out.newline();
+4 -1
View File
@@ -15,7 +15,10 @@ macro_rules! declare_tests {
#[test]
fn $name() {
let module = compiled_module();
let outfiles = HashMap::<_, _>::from_iter(generate(&module, &$lang));
let outfiles = generate(&module, &$lang)
.into_iter()
.map(|f| (f.filename, f.code))
.collect::<HashMap<_, _>>();
let mut settings = insta::Settings::clone_current();
settings.set_sort_maps(true);
// Ignore the autogenerated comments with version info, since it changes with every
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -5,7 +5,7 @@ Business Source License 1.1
Parameters
Licensor: Clockwork Laboratories, Inc.
Licensed Work: SpacetimeDB 1.2.0
Licensed Work: SpacetimeDB 1.4.0
The Licensed Work is
(c) 2023 Clockwork Laboratories, Inc.
@@ -21,7 +21,7 @@ Additional Use Grant: You may make use of the Licensed Work provided your
Licensed Work by creating tables whose schemas are
controlled by such third parties.
Change Date: 2030-06-04
Change Date: 2030-09-03
Change License: GNU Affero General Public License v3.0 with a linking
exception
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
packages:
- 'crates/bindings-typescript'
- 'sdks/typescript'
- 'sdks/typescript/packages/sdk'
- 'sdks/typescript/packages/test-app'
- 'sdks/typescript/examples/quickstart-chat'
@@ -6,10 +6,12 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"format": "prettier --write .",
"lint": "eslint . && prettier . --check",
"preview": "vite preview",
"test": "vitest",
"spacetime:generate-bindings": "spacetime generate --lang typescript --out-dir src/module_bindings --project-path server",
"generate": "cargo build -p spacetimedb-standalone && cargo run -p spacetimedb-cli generate --lang typescript --out-dir src/module_bindings --project-path ../../../../modules/quickstart-chat && prettier --write src/module_bindings",
"spacetime:generate": "spacetime generate --lang typescript --out-dir src/module_bindings --project-path server",
"spacetime:publish:local": "spacetime publish chat --project-path server --server local",
"spacetime:publish": "spacetime publish chat --project-path server --server testnet"
},
@@ -26,14 +28,16 @@
"@types/jest": "^29.5.14",
"@types/react": "^18.3.18",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^9.17.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"jsdom": "^26.0.0",
"prettier": "^3.3.3",
"typescript": "~5.6.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.5"
"vite": "^6.3.5",
"vitest": "2.1.9"
}
}
@@ -32,16 +32,16 @@ body,
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
font-family:
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family:
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}
/* ----- Buttons ----- */
@@ -1,60 +1,63 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type IdentityConnected = {};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace IdentityConnected {
export const IdentityConnected = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [],
});
},
export function serialize(
writer: BinaryWriter,
value: IdentityConnected
): void {
IdentityConnected.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: IdentityConnected): void {
__AlgebraicTypeValue.serializeValue(
writer,
IdentityConnected.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): IdentityConnected {
return IdentityConnected.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): IdentityConnected {
return __AlgebraicTypeValue.deserializeValue(
reader,
IdentityConnected.getTypeScriptAlgebraicType()
);
},
};
export default IdentityConnected;
@@ -1,62 +1,63 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type IdentityDisconnected = {};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace IdentityDisconnected {
export const IdentityDisconnected = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [],
});
},
export function serialize(
writer: BinaryWriter,
value: IdentityDisconnected
): void {
IdentityDisconnected.getTypeScriptAlgebraicType().serialize(writer, value);
}
export function deserialize(reader: BinaryReader): IdentityDisconnected {
return IdentityDisconnected.getTypeScriptAlgebraicType().deserialize(
reader
serialize(writer: __BinaryWriter, value: IdentityDisconnected): void {
__AlgebraicTypeValue.serializeValue(
writer,
IdentityDisconnected.getTypeScriptAlgebraicType(),
value
);
}
}
},
deserialize(reader: __BinaryReader): IdentityDisconnected {
return __AlgebraicTypeValue.deserializeValue(
reader,
IdentityDisconnected.getTypeScriptAlgebraicType()
);
},
};
export default IdentityDisconnected;
@@ -1,36 +1,32 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
// Import and reexport all reducer arg types
@@ -67,8 +63,9 @@ const REMOTE_MODULE = {
primaryKey: 'identity',
primaryKeyInfo: {
colName: 'identity',
colType:
User.getTypeScriptAlgebraicType().product.elements[0].algebraicType,
colType: (
User.getTypeScriptAlgebraicType() as __AlgebraicTypeVariants.Product
).value.elements[0].algebraicType,
},
},
},
@@ -91,7 +88,7 @@ const REMOTE_MODULE = {
},
},
versionInfo: {
cliVersion: '1.3.2',
cliVersion: '1.4.0',
},
// Constructors which are used by the DbConnectionImpl to
// extract type information from the generated RemoteModule.
@@ -100,17 +97,20 @@ const REMOTE_MODULE = {
// all we do is build a TypeScript object which we could have done inside the
// SDK, but if in the future we wanted to create a class this would be
// necessary because classes have methods, so we'll keep it.
eventContextConstructor: (imp: DbConnectionImpl, event: Event<Reducer>) => {
eventContextConstructor: (
imp: __DbConnectionImpl,
event: __Event<Reducer>
) => {
return {
...(imp as DbConnection),
event,
};
},
dbViewConstructor: (imp: DbConnectionImpl) => {
dbViewConstructor: (imp: __DbConnectionImpl) => {
return new RemoteTables(imp);
},
reducersConstructor: (
imp: DbConnectionImpl,
imp: __DbConnectionImpl,
setReducerFlags: SetReducerFlags
) => {
return new RemoteReducers(imp, setReducerFlags);
@@ -130,7 +130,7 @@ export type Reducer =
export class RemoteReducers {
constructor(
private connection: DbConnectionImpl,
private connection: __DbConnectionImpl,
private setCallReducerFlags: SetReducerFlags
) {}
@@ -152,7 +152,7 @@ export class RemoteReducers {
sendMessage(text: string) {
const __args = { text };
let __writer = new BinaryWriter(1024);
let __writer = new __BinaryWriter(1024);
SendMessage.getTypeScriptAlgebraicType().serialize(__writer, __args);
let __argsBuffer = __writer.getBuffer();
this.connection.callReducer(
@@ -174,7 +174,7 @@ export class RemoteReducers {
setName(name: string) {
const __args = { name };
let __writer = new BinaryWriter(1024);
let __writer = new __BinaryWriter(1024);
SetName.getTypeScriptAlgebraicType().serialize(__writer, __args);
let __argsBuffer = __writer.getBuffer();
this.connection.callReducer(
@@ -194,19 +194,19 @@ export class RemoteReducers {
}
export class SetReducerFlags {
sendMessageFlags: CallReducerFlags = 'FullUpdate';
sendMessage(flags: CallReducerFlags) {
sendMessageFlags: __CallReducerFlags = 'FullUpdate';
sendMessage(flags: __CallReducerFlags) {
this.sendMessageFlags = flags;
}
setNameFlags: CallReducerFlags = 'FullUpdate';
setName(flags: CallReducerFlags) {
setNameFlags: __CallReducerFlags = 'FullUpdate';
setName(flags: __CallReducerFlags) {
this.setNameFlags = flags;
}
}
export class RemoteTables {
constructor(private connection: DbConnectionImpl) {}
constructor(private connection: __DbConnectionImpl) {}
get message(): MessageTableHandle {
return new MessageTableHandle(
@@ -225,51 +225,51 @@ export class RemoteTables {
}
}
export class SubscriptionBuilder extends SubscriptionBuilderImpl<
export class SubscriptionBuilder extends __SubscriptionBuilderImpl<
RemoteTables,
RemoteReducers,
SetReducerFlags
> {}
export class DbConnection extends DbConnectionImpl<
export class DbConnection extends __DbConnectionImpl<
RemoteTables,
RemoteReducers,
SetReducerFlags
> {
static builder = (): DbConnectionBuilder<
static builder = (): __DbConnectionBuilder<
DbConnection,
ErrorContext,
SubscriptionEventContext
> => {
return new DbConnectionBuilder<
return new __DbConnectionBuilder<
DbConnection,
ErrorContext,
SubscriptionEventContext
>(REMOTE_MODULE, (imp: DbConnectionImpl) => imp as DbConnection);
>(REMOTE_MODULE, (imp: __DbConnectionImpl) => imp as DbConnection);
};
subscriptionBuilder = (): SubscriptionBuilder => {
return new SubscriptionBuilder(this);
};
}
export type EventContext = EventContextInterface<
export type EventContext = __EventContextInterface<
RemoteTables,
RemoteReducers,
SetReducerFlags,
Reducer
>;
export type ReducerEventContext = ReducerEventContextInterface<
export type ReducerEventContext = __ReducerEventContextInterface<
RemoteTables,
RemoteReducers,
SetReducerFlags,
Reducer
>;
export type SubscriptionEventContext = SubscriptionEventContextInterface<
export type SubscriptionEventContext = __SubscriptionEventContextInterface<
RemoteTables,
RemoteReducers,
SetReducerFlags
>;
export type ErrorContext = ErrorContextInterface<
export type ErrorContext = __ErrorContextInterface<
RemoteTables,
RemoteReducers,
SetReducerFlags
@@ -1,36 +1,32 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
import { Message } from './message_type';
import {
@@ -51,9 +47,9 @@ import {
* like `ctx.db.message.on_insert(...)`.
*/
export class MessageTableHandle {
tableCache: TableCache<Message>;
tableCache: __TableCache<Message>;
constructor(tableCache: TableCache<Message>) {
constructor(tableCache: __TableCache<Message>) {
this.tableCache = tableCache;
}
@@ -1,64 +1,77 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type Message = {
sender: Identity;
sent: Timestamp;
sender: __Identity;
sent: __Timestamp;
text: string;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace Message {
export const Message = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement('sender', AlgebraicType.createIdentityType()),
new ProductTypeElement('sent', AlgebraicType.createTimestampType()),
new ProductTypeElement('text', AlgebraicType.createStringType()),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'sender',
algebraicType: __AlgebraicTypeValue.createIdentityType(),
},
{
name: 'sent',
algebraicType: __AlgebraicTypeValue.createTimestampType(),
},
{ name: 'text', algebraicType: __AlgebraicTypeValue.String },
],
});
},
export function serialize(writer: BinaryWriter, value: Message): void {
Message.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: Message): void {
__AlgebraicTypeValue.serializeValue(
writer,
Message.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): Message {
return Message.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): Message {
return __AlgebraicTypeValue.deserializeValue(
reader,
Message.getTypeScriptAlgebraicType()
);
},
};
export default Message;
@@ -1,61 +1,65 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type SendMessage = {
text: string;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace SendMessage {
export const SendMessage = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement('text', AlgebraicType.createStringType()),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [{ name: 'text', algebraicType: __AlgebraicTypeValue.String }],
});
},
export function serialize(writer: BinaryWriter, value: SendMessage): void {
SendMessage.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: SendMessage): void {
__AlgebraicTypeValue.serializeValue(
writer,
SendMessage.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): SendMessage {
return SendMessage.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): SendMessage {
return __AlgebraicTypeValue.deserializeValue(
reader,
SendMessage.getTypeScriptAlgebraicType()
);
},
};
export default SendMessage;
@@ -1,61 +1,65 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type SetName = {
name: string;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace SetName {
export const SetName = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement('name', AlgebraicType.createStringType()),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [{ name: 'name', algebraicType: __AlgebraicTypeValue.String }],
});
},
export function serialize(writer: BinaryWriter, value: SetName): void {
SetName.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: SetName): void {
__AlgebraicTypeValue.serializeValue(
writer,
SetName.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): SetName {
return SetName.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): SetName {
return __AlgebraicTypeValue.deserializeValue(
reader,
SetName.getTypeScriptAlgebraicType()
);
},
};
export default SetName;
@@ -1,36 +1,32 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
import { User } from './user_type';
import {
@@ -51,9 +47,9 @@ import {
* like `ctx.db.user.on_insert(...)`.
*/
export class UserTableHandle {
tableCache: TableCache<User>;
tableCache: __TableCache<User>;
constructor(tableCache: TableCache<User>) {
constructor(tableCache: __TableCache<User>) {
this.tableCache = tableCache;
}
@@ -78,9 +74,9 @@ export class UserTableHandle {
identity = {
// Find the subscribed row whose `identity` column value is equal to `col_val`,
// if such a row is present in the client cache.
find: (col_val: Identity): User | undefined => {
find: (col_val: __Identity): User | undefined => {
for (let row of this.tableCache.iter()) {
if (deepEqual(row.identity, col_val)) {
if (__deepEqual(row.identity, col_val)) {
return row;
}
}
@@ -1,67 +1,79 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.3.2 (commit 0027d094e1216119d22b767d8e6dc41d674d1bca).
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
Identity,
ProductType,
ProductTypeElement,
SubscriptionBuilderImpl,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
type CallReducerFlags,
type DbContext,
type ErrorContextInterface,
type Event,
type EventContextInterface,
type ReducerEventContextInterface,
type SubscriptionEventContextInterface,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '@clockworklabs/spacetimedb-sdk';
export type User = {
identity: Identity;
identity: __Identity;
name: string | undefined;
online: boolean;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace User {
export const User = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement('identity', AlgebraicType.createIdentityType()),
new ProductTypeElement(
'name',
AlgebraicType.createOptionType(AlgebraicType.createStringType())
),
new ProductTypeElement('online', AlgebraicType.createBoolType()),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'identity',
algebraicType: __AlgebraicTypeValue.createIdentityType(),
},
{
name: 'name',
algebraicType: __AlgebraicTypeValue.createOptionType(
__AlgebraicTypeValue.String
),
},
{ name: 'online', algebraicType: __AlgebraicTypeValue.Bool },
],
});
},
export function serialize(writer: BinaryWriter, value: User): void {
User.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: User): void {
__AlgebraicTypeValue.serializeValue(
writer,
User.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): User {
return User.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): User {
return __AlgebraicTypeValue.deserializeValue(
reader,
User.getTypeScriptAlgebraicType()
);
},
};
export default User;
+2 -1
View File
@@ -12,7 +12,8 @@
"ci:version": "changeset version",
"format": "prettier --write .",
"lint": "prettier . --check",
"test": "pnpm -r test"
"test": "pnpm -r test",
"generate": "pnpm --filter ./examples/quickstart-chat generate && pnpm --filter ./packages/sdks generate && pnpm --filter ./packages/test-app generate"
},
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
+9 -3
View File
@@ -25,7 +25,10 @@
},
"scripts": {
"compile": "tsup",
"format": "prettier --write .",
"lint": "prettier . --check",
"test": "vitest run",
"generate": "cargo build -p spacetimedb-standalone && cargo run -p spacetimedb-client-api-messages --example get_ws_schema > ws_schema.json && cargo run -p spacetimedb-cli generate --lang typescript --out-dir src/client_api --module-def ws_schema.json && rm ws_schema.json && find src/client_api -type f -exec perl -pi -e 's#\\@clockworklabs/spacetimedb-sdk#../index#g' {} + && prettier --write src/client_api",
"size": "brotli-size dist/min/index.js"
},
"repository": {
@@ -42,12 +45,15 @@
"undici": "^6.19.2"
},
"devDependencies": {
"@clockworklabs/test-app": "file:../test-app",
"@clockworklabs/test-app": "workspace:^",
"prettier": "^3.3.3",
"tsup": "^8.1.0",
"undici": "^6.19.2"
"undici": "^6.19.2",
"vitest": "^3.2.4"
},
"dependencies": {
"@zxing/text-encoding": "^0.9.0",
"base64-js": "^1.5.1"
"base64-js": "^1.5.1",
"spacetimedb": "workspace:^"
}
}
@@ -1,672 +0,0 @@
import { TimeDuration } from './time_duration';
import { Timestamp } from './timestamp';
import { ConnectionId } from './connection_id';
import type BinaryReader from './binary_reader';
import BinaryWriter from './binary_writer';
import { Identity } from './identity';
import ScheduleAt from './schedule_at';
/**
* A variant of a sum type.
*
* NOTE: Each element has an implicit element tag based on its order.
* Uniquely identifies an element similarly to protobuf tags.
*/
export class SumTypeVariant {
name: string;
algebraicType: AlgebraicType;
constructor(name: string, algebraicType: AlgebraicType) {
this.name = name;
this.algebraicType = algebraicType;
}
}
/**
* Unlike most languages, sums in SATS are *[structural]* and not nominal.
* When checking whether two nominal types are the same,
* their names and/or declaration sites (e.g., module / namespace) are considered.
* Meanwhile, a structural type system would only check the structure of the type itself,
* e.g., the names of its variants and their inner data types in the case of a sum.
*
* This is also known as a discriminated union (implementation) or disjoint union.
* Another name is [coproduct (category theory)](https://ncatlab.org/nlab/show/coproduct).
*
* These structures are known as sum types because the number of possible values a sum
* ```ignore
* { N_0(T_0), N_1(T_1), ..., N_n(T_n) }
* ```
* is:
* ```ignore
* Σ (i ∈ 0..n). values(T_i)
* ```
* so for example, `values({ A(U64), B(Bool) }) = values(U64) + values(Bool)`.
*
* See also: https://ncatlab.org/nlab/show/sum+type.
*
* [structural]: https://en.wikipedia.org/wiki/Structural_type_system
*/
export class SumType {
variants: SumTypeVariant[];
constructor(variants: SumTypeVariant[]) {
this.variants = variants;
}
serialize = (writer: BinaryWriter, value: any): void => {
// In TypeScript we handle Option values as a special case
// we don't represent the some and none variants, but instead
// we represent the value directly.
if (
this.variants.length == 2 &&
this.variants[0].name === 'some' &&
this.variants[1].name === 'none'
) {
if (value !== null && value !== undefined) {
writer.writeByte(0);
this.variants[0].algebraicType.serialize(writer, value);
} else {
writer.writeByte(1);
}
} else {
let variant = value['tag'];
const index = this.variants.findIndex(v => v.name === variant);
if (index < 0) {
throw `Can't serialize a sum type, couldn't find ${value.tag} tag`;
}
writer.writeU8(index);
this.variants[index].algebraicType.serialize(writer, value['value']);
}
};
deserialize = (reader: BinaryReader): any => {
let tag = reader.readU8();
// In TypeScript we handle Option values as a special case
// we don't represent the some and none variants, but instead
// we represent the value directly.
if (
this.variants.length == 2 &&
this.variants[0].name === 'some' &&
this.variants[1].name === 'none'
) {
if (tag === 0) {
return this.variants[0].algebraicType.deserialize(reader);
} else if (tag === 1) {
return undefined;
} else {
throw `Can't deserialize an option type, couldn't find ${tag} tag`;
}
} else {
let variant = this.variants[tag];
let value = variant.algebraicType.deserialize(reader);
return { tag: variant.name, value };
}
};
}
/**
* A factor / element of a product type.
*
* An element consist of an optional name and a type.
*
* NOTE: Each element has an implicit element tag based on its order.
* Uniquely identifies an element similarly to protobuf tags.
*/
export class ProductTypeElement {
name: string;
algebraicType: AlgebraicType;
constructor(name: string, algebraicType: AlgebraicType) {
this.name = name;
this.algebraicType = algebraicType;
}
}
/**
* A structural product type of the factors given by `elements`.
*
* This is also known as `struct` and `tuple` in many languages,
* but note that unlike most languages, products in SATs are *[structural]* and not nominal.
* When checking whether two nominal types are the same,
* their names and/or declaration sites (e.g., module / namespace) are considered.
* Meanwhile, a structural type system would only check the structure of the type itself,
* e.g., the names of its fields and their types in the case of a record.
* The name "product" comes from category theory.
*
* See also: https://ncatlab.org/nlab/show/product+type.
*
* These structures are known as product types because the number of possible values in product
* ```ignore
* { N_0: T_0, N_1: T_1, ..., N_n: T_n }
* ```
* is:
* ```ignore
* Π (i ∈ 0..n). values(T_i)
* ```
* so for example, `values({ A: U64, B: Bool }) = values(U64) * values(Bool)`.
*
* [structural]: https://en.wikipedia.org/wiki/Structural_type_system
*/
export class ProductType {
elements: ProductTypeElement[];
constructor(elements: ProductTypeElement[]) {
this.elements = elements;
}
isEmpty(): boolean {
return this.elements.length === 0;
}
serialize = (writer: BinaryWriter, value: object): void => {
for (let element of this.elements) {
element.algebraicType.serialize(writer, value[element.name]);
}
};
intoMapKey(value: any): ComparablePrimitive {
if (this.elements.length === 1) {
if (this.elements[0].name === '__time_duration_micros__') {
return (value as TimeDuration).__time_duration_micros__;
}
if (this.elements[0].name === '__timestamp_micros_since_unix_epoch__') {
return (value as Timestamp).__timestamp_micros_since_unix_epoch__;
}
if (this.elements[0].name === '__identity__') {
return (value as Identity).__identity__;
}
if (this.elements[0].name === '__connection_id__') {
return (value as ConnectionId).__connection_id__;
}
}
// The fallback is to serialize and base64 encode the bytes.
const writer = new BinaryWriter(10);
this.serialize(writer, value);
return writer.toBase64();
}
deserialize = (reader: BinaryReader): { [key: string]: any } => {
let result: { [key: string]: any } = {};
if (this.elements.length === 1) {
if (this.elements[0].name === '__time_duration_micros__') {
return new TimeDuration(reader.readI64());
}
if (this.elements[0].name === '__timestamp_micros_since_unix_epoch__') {
return new Timestamp(reader.readI64());
}
if (this.elements[0].name === '__identity__') {
return new Identity(reader.readU256());
}
if (this.elements[0].name === '__connection_id__') {
return new ConnectionId(reader.readU128());
}
}
for (let element of this.elements) {
result[element.name] = element.algebraicType.deserialize(reader);
}
return result;
};
}
/* A map type from keys of type `keyType` to values of type `valueType`. */
export class MapType {
keyType: AlgebraicType;
valueType: AlgebraicType;
constructor(keyType: AlgebraicType, valueType: AlgebraicType) {
this.keyType = keyType;
this.valueType = valueType;
}
}
type ArrayBaseType = AlgebraicType;
type TypeRef = null;
type None = null;
export type EnumLabel = { label: string };
type AnyType =
| ProductType
| SumType
| ArrayBaseType
| MapType
| EnumLabel
| TypeRef
| None;
export type ComparablePrimitive = number | string | String | boolean | bigint;
/**
* The SpacetimeDB Algebraic Type System (SATS) is a structural type system in
* which a nominal type system can be constructed.
*
* The type system unifies the concepts sum types, product types, and built-in
* primitive types into a single type system.
*/
export class AlgebraicType {
type!: Type;
type_?: AnyType;
#setter(type: Type, payload: AnyType | undefined) {
this.type_ = payload;
this.type = payload === undefined ? Type.None : type;
}
get product(): ProductType {
if (this.type !== Type.ProductType) {
throw 'product type was requested, but the type is not ProductType';
}
return this.type_ as ProductType;
}
set product(value: ProductType | undefined) {
this.#setter(Type.ProductType, value);
}
get sum(): SumType {
if (this.type !== Type.SumType) {
throw 'sum type was requested, but the type is not SumType';
}
return this.type_ as SumType;
}
set sum(value: SumType | undefined) {
this.#setter(Type.SumType, value);
}
get array(): ArrayBaseType {
if (this.type !== Type.ArrayType) {
throw 'array type was requested, but the type is not ArrayType';
}
return this.type_ as ArrayBaseType;
}
set array(value: ArrayBaseType | undefined) {
this.#setter(Type.ArrayType, value);
}
get map(): MapType {
if (this.type !== Type.MapType) {
throw 'map type was requested, but the type is not MapType';
}
return this.type_ as MapType;
}
set map(value: MapType | undefined) {
this.#setter(Type.MapType, value);
}
static #createType(type: Type, payload: AnyType | undefined): AlgebraicType {
let at = new AlgebraicType();
at.#setter(type, payload);
return at;
}
static createProductType(elements: ProductTypeElement[]): AlgebraicType {
return this.#createType(Type.ProductType, new ProductType(elements));
}
static createSumType(variants: SumTypeVariant[]): AlgebraicType {
return this.#createType(Type.SumType, new SumType(variants));
}
static createArrayType(elementType: AlgebraicType): AlgebraicType {
return this.#createType(Type.ArrayType, elementType);
}
static createMapType(key: AlgebraicType, val: AlgebraicType): AlgebraicType {
return this.#createType(Type.MapType, new MapType(key, val));
}
static createBoolType(): AlgebraicType {
return this.#createType(Type.Bool, null);
}
static createI8Type(): AlgebraicType {
return this.#createType(Type.I8, null);
}
static createU8Type(): AlgebraicType {
return this.#createType(Type.U8, null);
}
static createI16Type(): AlgebraicType {
return this.#createType(Type.I16, null);
}
static createU16Type(): AlgebraicType {
return this.#createType(Type.U16, null);
}
static createI32Type(): AlgebraicType {
return this.#createType(Type.I32, null);
}
static createU32Type(): AlgebraicType {
return this.#createType(Type.U32, null);
}
static createI64Type(): AlgebraicType {
return this.#createType(Type.I64, null);
}
static createU64Type(): AlgebraicType {
return this.#createType(Type.U64, null);
}
static createI128Type(): AlgebraicType {
return this.#createType(Type.I128, null);
}
static createU128Type(): AlgebraicType {
return this.#createType(Type.U128, null);
}
static createI256Type(): AlgebraicType {
return this.#createType(Type.I256, null);
}
static createU256Type(): AlgebraicType {
return this.#createType(Type.U256, null);
}
static createF32Type(): AlgebraicType {
return this.#createType(Type.F32, null);
}
static createF64Type(): AlgebraicType {
return this.#createType(Type.F64, null);
}
static createStringType(): AlgebraicType {
return this.#createType(Type.String, null);
}
static createBytesType(): AlgebraicType {
return this.createArrayType(this.createU8Type());
}
static createOptionType(innerType: AlgebraicType): AlgebraicType {
return this.createSumType([
new SumTypeVariant('some', innerType),
new SumTypeVariant('none', this.createProductType([])),
]);
}
static createIdentityType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement('__identity__', this.createU256Type()),
]);
}
static createConnectionIdType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement('__connection_id__', this.createU128Type()),
]);
}
static createScheduleAtType(): AlgebraicType {
return ScheduleAt.getAlgebraicType();
}
static createTimestampType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement(
'__timestamp_micros_since_unix_epoch__',
this.createI64Type()
),
]);
}
static createTimeDurationType(): AlgebraicType {
return this.createProductType([
new ProductTypeElement('__time_duration_micros__', this.createI64Type()),
]);
}
isProductType(): boolean {
return this.type === Type.ProductType;
}
isSumType(): boolean {
return this.type === Type.SumType;
}
isArrayType(): boolean {
return this.type === Type.ArrayType;
}
isMapType(): boolean {
return this.type === Type.MapType;
}
#isBytes(): boolean {
return this.isArrayType() && this.array.type == Type.U8;
}
#isBytesNewtype(tag: string): boolean {
return (
this.isProductType() &&
this.product.elements.length === 1 &&
(this.product.elements[0].algebraicType.type == Type.U128 ||
this.product.elements[0].algebraicType.type == Type.U256) &&
this.product.elements[0].name === tag
);
}
#isI64Newtype(tag: string): boolean {
return (
this.isProductType() &&
this.product.elements.length === 1 &&
this.product.elements[0].algebraicType.type === Type.I64 &&
this.product.elements[0].name === tag
);
}
isIdentity(): boolean {
return this.#isBytesNewtype('__identity__');
}
isConnectionId(): boolean {
return this.#isBytesNewtype('__connection_id__');
}
isScheduleAt(): boolean {
return (
this.isSumType() &&
this.sum.variants.length === 2 &&
this.sum.variants[0].name === 'Interval' &&
this.sum.variants[0].algebraicType.type === Type.U64 &&
this.sum.variants[1].name === 'Time' &&
this.sum.variants[1].algebraicType.type === Type.U64
);
}
isTimestamp(): boolean {
return this.#isI64Newtype('__timestamp_micros_since_unix_epoch__');
}
isTimeDuration(): boolean {
return this.#isI64Newtype('__time_duration_micros__');
}
/**
* Convert a value of the algebraic type into something that can be used as a key in a map.
* There are no guarantees about being able to order it.
* This is only guaranteed to be comparable to other values of the same type.
* @param value A value of the algebraic type
* @returns Something that can be used as a key in a map.
*/
intoMapKey(value: any): ComparablePrimitive {
switch (this.type) {
case Type.U8:
case Type.U16:
case Type.U32:
case Type.U64:
case Type.U128:
case Type.U256:
case Type.I8:
case Type.I16:
case Type.I64:
case Type.I128:
case Type.F32:
case Type.F64:
case Type.String:
case Type.Bool:
return value;
case Type.ProductType:
return this.product.intoMapKey(value);
default:
const writer = new BinaryWriter(10);
this.serialize(writer, value);
return writer.toBase64();
}
}
serialize(writer: BinaryWriter, value: any): void {
switch (this.type) {
case Type.ProductType:
this.product.serialize(writer, value);
break;
case Type.SumType:
this.sum.serialize(writer, value);
break;
case Type.ArrayType:
if (this.#isBytes()) {
writer.writeUInt8Array(value);
} else {
const elemType = this.array;
writer.writeU32(value.length);
for (let elem of value) {
elemType.serialize(writer, elem);
}
}
break;
case Type.MapType:
throw new Error('not implemented');
case Type.Bool:
writer.writeBool(value);
break;
case Type.I8:
writer.writeI8(value);
break;
case Type.U8:
writer.writeU8(value);
break;
case Type.I16:
writer.writeI16(value);
break;
case Type.U16:
writer.writeU16(value);
break;
case Type.I32:
writer.writeI32(value);
break;
case Type.U32:
writer.writeU32(value);
break;
case Type.I64:
writer.writeI64(value);
break;
case Type.U64:
writer.writeU64(value);
break;
case Type.I128:
writer.writeI128(value);
break;
case Type.U128:
writer.writeU128(value);
break;
case Type.I256:
writer.writeI256(value);
break;
case Type.U256:
writer.writeU256(value);
break;
case Type.F32:
writer.writeF32(value);
break;
case Type.F64:
writer.writeF64(value);
break;
case Type.String:
writer.writeString(value);
break;
default:
throw new Error(`not implemented, ${this.type}`);
}
}
deserialize(reader: BinaryReader): any {
switch (this.type) {
case Type.ProductType:
return this.product.deserialize(reader);
case Type.SumType:
return this.sum.deserialize(reader);
case Type.ArrayType:
if (this.#isBytes()) {
return reader.readUInt8Array();
} else {
const elemType = this.array;
const length = reader.readU32();
let result: any[] = [];
for (let i = 0; i < length; i++) {
result.push(elemType.deserialize(reader));
}
return result;
}
case Type.MapType:
// TODO: MapType is being removed
throw new Error('not implemented');
case Type.Bool:
return reader.readBool();
case Type.I8:
return reader.readI8();
case Type.U8:
return reader.readU8();
case Type.I16:
return reader.readI16();
case Type.U16:
return reader.readU16();
case Type.I32:
return reader.readI32();
case Type.U32:
return reader.readU32();
case Type.I64:
return reader.readI64();
case Type.U64:
return reader.readU64();
case Type.I128:
return reader.readI128();
case Type.U128:
return reader.readU128();
case Type.U256:
return reader.readU256();
case Type.F32:
return reader.readF32();
case Type.F64:
return reader.readF64();
case Type.String:
return reader.readString();
default:
throw new Error(`not implemented, ${this.type}`);
}
}
}
export namespace AlgebraicType {
export enum Type {
SumType = 'SumType',
ProductType = 'ProductType',
ArrayType = 'ArrayType',
MapType = 'MapType',
Bool = 'Bool',
I8 = 'I8',
U8 = 'U8',
I16 = 'I16',
U16 = 'U16',
I32 = 'I32',
U32 = 'U32',
I64 = 'I64',
U64 = 'U64',
I128 = 'I128',
U128 = 'U128',
I256 = 'I256',
U256 = 'U256',
F32 = 'F32',
F64 = 'F64',
/** UTF-8 encoded */
String = 'String',
None = 'None',
}
}
// No idea why but in order to have a local alias for both of these
// need to be present
type Type = AlgebraicType.Type;
let Type: typeof AlgebraicType.Type = AlgebraicType.Type;
@@ -1,331 +0,0 @@
import { ConnectionId } from './connection_id';
import { AlgebraicType, ProductType, SumType } from './algebraic_type';
import BinaryReader from './binary_reader';
import { Identity } from './identity';
import { ScheduleAt } from './schedule_at';
export interface ReducerArgsAdapter {
next: () => ValueAdapter;
}
export class BinaryReducerArgsAdapter {
adapter: BinaryAdapter;
constructor(adapter: BinaryAdapter) {
this.adapter = adapter;
}
next(): ValueAdapter {
return this.adapter;
}
}
/** Defines the interface for deserialize `AlgebraicValue`s*/
export interface ValueAdapter {
readUInt8Array: () => Uint8Array;
readArray: (type: AlgebraicType) => AlgebraicValue[];
readMap: (keyType: AlgebraicType, valueType: AlgebraicType) => MapValue;
readString: () => string;
readSum: (type: SumType) => SumValue;
readProduct: (type: ProductType) => ProductValue;
readBool: () => boolean;
readByte: () => number;
readI8: () => number;
readU8: () => number;
readI16: () => number;
readU16: () => number;
readI32: () => number;
readU32: () => number;
readI64: () => bigint;
readU64: () => bigint;
readU128: () => bigint;
readI128: () => bigint;
readF32: () => number;
readF64: () => number;
callMethod<K extends keyof ValueAdapter>(methodName: K): any;
}
export class BinaryAdapter implements ValueAdapter {
#reader: BinaryReader;
constructor(reader: BinaryReader) {
this.#reader = reader;
}
callMethod<K extends keyof ValueAdapter>(methodName: K): any {
return (this[methodName] as Function)();
}
readUInt8Array(): Uint8Array {
return this.#reader.readUInt8Array();
}
readArray(type: AlgebraicType): AlgebraicValue[] {
const length = this.#reader.readU32();
let result: AlgebraicValue[] = [];
for (let i = 0; i < length; i++) {
result.push(AlgebraicValue.deserialize(type, this));
}
return result;
}
readMap(keyType: AlgebraicType, valueType: AlgebraicType): MapValue {
const mapLength = this.#reader.readU32();
let result: MapValue = new Map();
for (let i = 0; i < mapLength; i++) {
const key = AlgebraicValue.deserialize(keyType, this);
const value = AlgebraicValue.deserialize(valueType, this);
result.set(key, value);
}
return result;
}
readString(): string {
return this.#reader.readString();
}
readSum(type: SumType): SumValue {
let tag = this.#reader.readByte();
let sumValue = AlgebraicValue.deserialize(
type.variants[tag].algebraicType,
this
);
return new SumValue(tag, sumValue);
}
readProduct(type: ProductType): ProductValue {
let elements: AlgebraicValue[] = [];
for (let element of type.elements) {
elements.push(AlgebraicValue.deserialize(element.algebraicType, this));
}
return new ProductValue(elements);
}
readBool(): boolean {
return this.#reader.readBool();
}
readByte(): number {
return this.#reader.readByte();
}
readI8(): number {
return this.#reader.readI8();
}
readU8(): number {
return this.#reader.readU8();
}
readI16(): number {
return this.#reader.readI16();
}
readU16(): number {
return this.#reader.readU16();
}
readI32(): number {
return this.#reader.readI32();
}
readU32(): number {
return this.#reader.readU32();
}
readI64(): bigint {
return this.#reader.readI64();
}
readU64(): bigint {
return this.#reader.readU64();
}
readU128(): bigint {
return this.#reader.readU128();
}
readI128(): bigint {
return this.#reader.readI128();
}
readF32(): number {
return this.#reader.readF32();
}
readF64(): number {
return this.#reader.readF64();
}
}
/** A value of a sum type choosing a specific variant of the type. */
export class SumValue {
/** A tag representing the choice of one variant of the sum type's variants. */
tag: number;
/**
* Given a variant `Var(Ty)` in a sum type `{ Var(Ty), ... }`,
* this provides the `value` for `Ty`.
*/
value: AlgebraicValue;
constructor(tag: number, value: AlgebraicValue) {
this.tag = tag;
this.value = value;
}
static deserialize(type: SumType, adapter: ValueAdapter): SumValue {
return adapter.readSum(type);
}
}
/**
* A product value is made of a list of
* "elements" / "fields" / "factors" of other `AlgebraicValue`s.
*
* The type of product value is a [product type](`ProductType`).
*/
export class ProductValue {
elements: AlgebraicValue[];
constructor(elements: AlgebraicValue[]) {
this.elements = elements;
}
static deserialize(type: ProductType, adapter: ValueAdapter): ProductValue {
return adapter.readProduct(type);
}
}
export type MapValue = Map<AlgebraicValue, AlgebraicValue>;
type AnyValue =
| SumValue
| ProductValue
| AlgebraicValue[]
| Uint8Array
| MapValue
| string
| boolean
| number
| bigint;
/** A value in SATS. */
export class AlgebraicValue {
value: AnyValue;
constructor(value: AnyValue | undefined) {
if (value === undefined) {
// TODO: possibly get rid of it
throw 'value is undefined';
}
this.value = value;
}
callMethod<K extends keyof AlgebraicValue>(methodName: K): any {
return (this[methodName] as Function)();
}
static deserialize(
type: AlgebraicType,
adapter: ValueAdapter
): AlgebraicValue {
switch (type.type) {
case AlgebraicType.Type.ProductType:
return new this(ProductValue.deserialize(type.product, adapter));
case AlgebraicType.Type.SumType:
return new this(SumValue.deserialize(type.sum, adapter));
case AlgebraicType.Type.ArrayType:
let elemType = type.array;
if (elemType.type === AlgebraicType.Type.U8) {
return new this(adapter.readUInt8Array());
} else {
return new this(adapter.readArray(elemType));
}
case AlgebraicType.Type.MapType:
let mapType = type.map;
return new this(adapter.readMap(mapType.keyType, mapType.valueType));
case AlgebraicType.Type.Bool:
return new this(adapter.readBool());
case AlgebraicType.Type.I8:
return new this(adapter.readI8());
case AlgebraicType.Type.U8:
return new this(adapter.readU8());
case AlgebraicType.Type.I16:
return new this(adapter.readI16());
case AlgebraicType.Type.U16:
return new this(adapter.readU16());
case AlgebraicType.Type.I32:
return new this(adapter.readI32());
case AlgebraicType.Type.U32:
return new this(adapter.readU32());
case AlgebraicType.Type.I64:
return new this(adapter.readI64());
case AlgebraicType.Type.U64:
return new this(adapter.readU64());
case AlgebraicType.Type.I128:
return new this(adapter.readI128());
case AlgebraicType.Type.U128:
return new this(adapter.readU128());
case AlgebraicType.Type.String:
return new this(adapter.readString());
default:
throw new Error(`not implemented, ${type.type}`);
}
}
// TODO: all of the following methods should actually check the type of `self.value`
// and throw if it does not match.
asProductValue(): ProductValue {
return this.value as ProductValue;
}
asField(index: number): AlgebraicValue {
return this.asProductValue().elements[index];
}
asSumValue(): SumValue {
return this.value as SumValue;
}
asArray(): AlgebraicValue[] {
return this.value as AlgebraicValue[];
}
asMap(): MapValue {
return this.value as MapValue;
}
asString(): string {
return this.value as string;
}
asBoolean(): boolean {
return this.value as boolean;
}
asNumber(): number {
return this.value as number;
}
asBytes(): Uint8Array {
return this.value as Uint8Array;
}
asBigInt(): bigint {
return this.value as bigint;
}
asIdentity(): Identity {
return new Identity(this.asField(0).asBigInt());
}
asConnectionId(): ConnectionId {
return new ConnectionId(this.asField(0).asBigInt());
}
asScheduleAt(): ScheduleAt {
return ScheduleAt.fromValue(this);
}
}
export interface ParseableType<T> {
deserialize: (reader: BinaryReader) => T;
}
export function parseValue<T>(ty: ParseableType<T>, src: Uint8Array): T {
const reader = new BinaryReader(src);
return ty.deserialize(reader);
}
@@ -1,68 +1,76 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
CallReducerFlags,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
DbContext,
ErrorContextInterface,
Event,
EventContextInterface,
Identity,
ProductType,
ProductTypeElement,
ReducerEventContextInterface,
SubscriptionBuilderImpl,
SubscriptionEventContextInterface,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { RowSizeHint as __RowSizeHint } from './row_size_hint_type';
import { RowSizeHint } from './row_size_hint_type';
export type BsatnRowList = {
sizeHint: __RowSizeHint;
sizeHint: RowSizeHint;
rowsData: Uint8Array;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace BsatnRowList {
export const BsatnRowList = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement(
'sizeHint',
__RowSizeHint.getTypeScriptAlgebraicType()
),
new ProductTypeElement(
'rowsData',
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{
name: 'sizeHint',
algebraicType: RowSizeHint.getTypeScriptAlgebraicType(),
},
{
name: 'rowsData',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U8),
},
],
});
},
export function serialize(writer: BinaryWriter, value: BsatnRowList): void {
BsatnRowList.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: BsatnRowList): void {
__AlgebraicTypeValue.serializeValue(
writer,
BsatnRowList.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): BsatnRowList {
return BsatnRowList.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): BsatnRowList {
return __AlgebraicTypeValue.deserializeValue(
reader,
BsatnRowList.getTypeScriptAlgebraicType()
);
},
};
export default BsatnRowList;
@@ -1,67 +1,76 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
CallReducerFlags,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
DbContext,
ErrorContextInterface,
Event,
EventContextInterface,
Identity,
ProductType,
ProductTypeElement,
ReducerEventContextInterface,
SubscriptionBuilderImpl,
SubscriptionEventContextInterface,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
export type CallReducer = {
reducer: string;
args: Uint8Array;
requestId: number;
flags: number;
};
/**
* A namespace for generated helper functions.
* An object for generated helper functions.
*/
export namespace CallReducer {
export const CallReducer = {
/**
* A function which returns this type represented as an AlgebraicType.
* This function is derived from the AlgebraicType used to generate this type.
*/
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createProductType([
new ProductTypeElement('reducer', AlgebraicType.createStringType()),
new ProductTypeElement(
'args',
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
),
new ProductTypeElement('requestId', AlgebraicType.createU32Type()),
new ProductTypeElement('flags', AlgebraicType.createU8Type()),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Product({
elements: [
{ name: 'reducer', algebraicType: __AlgebraicTypeValue.String },
{
name: 'args',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U8),
},
{ name: 'requestId', algebraicType: __AlgebraicTypeValue.U32 },
{ name: 'flags', algebraicType: __AlgebraicTypeValue.U8 },
],
});
},
export function serialize(writer: BinaryWriter, value: CallReducer): void {
CallReducer.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: CallReducer): void {
__AlgebraicTypeValue.serializeValue(
writer,
CallReducer.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): CallReducer {
return CallReducer.getTypeScriptAlgebraicType().deserialize(reader);
}
}
deserialize(reader: __BinaryReader): CallReducer {
return __AlgebraicTypeValue.deserializeValue(
reader,
CallReducer.getTypeScriptAlgebraicType()
);
},
};
export default CallReducer;
@@ -1,146 +1,136 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
CallReducerFlags,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
DbContext,
ErrorContextInterface,
Event,
EventContextInterface,
Identity,
ProductType,
ProductTypeElement,
ReducerEventContextInterface,
SubscriptionBuilderImpl,
SubscriptionEventContextInterface,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { CallReducer as __CallReducer } from './call_reducer_type';
import { Subscribe as __Subscribe } from './subscribe_type';
import { OneOffQuery as __OneOffQuery } from './one_off_query_type';
import { SubscribeSingle as __SubscribeSingle } from './subscribe_single_type';
import { SubscribeMulti as __SubscribeMulti } from './subscribe_multi_type';
import { Unsubscribe as __Unsubscribe } from './unsubscribe_type';
import { UnsubscribeMulti as __UnsubscribeMulti } from './unsubscribe_multi_type';
import { CallReducer } from './call_reducer_type';
import { Subscribe } from './subscribe_type';
import { OneOffQuery } from './one_off_query_type';
import { SubscribeSingle } from './subscribe_single_type';
import { SubscribeMulti } from './subscribe_multi_type';
import { Unsubscribe } from './unsubscribe_type';
import { UnsubscribeMulti } from './unsubscribe_multi_type';
// A namespace for generated variants and helper functions.
export namespace ClientMessage {
// These are the generated variant types for each variant of the tagged union.
// One type is generated per variant and will be used in the `value` field of
// the tagged union.
export type CallReducer = { tag: 'CallReducer'; value: __CallReducer };
export type Subscribe = { tag: 'Subscribe'; value: __Subscribe };
export type OneOffQuery = { tag: 'OneOffQuery'; value: __OneOffQuery };
export type SubscribeSingle = {
tag: 'SubscribeSingle';
value: __SubscribeSingle;
};
export type SubscribeMulti = {
tag: 'SubscribeMulti';
value: __SubscribeMulti;
};
export type Unsubscribe = { tag: 'Unsubscribe'; value: __Unsubscribe };
export type UnsubscribeMulti = {
tag: 'UnsubscribeMulti';
value: __UnsubscribeMulti;
};
import * as ClientMessageVariants from './client_message_variants';
// The tagged union or sum type for the algebraic type `ClientMessage`.
export type ClientMessage =
| ClientMessageVariants.CallReducer
| ClientMessageVariants.Subscribe
| ClientMessageVariants.OneOffQuery
| ClientMessageVariants.SubscribeSingle
| ClientMessageVariants.SubscribeMulti
| ClientMessageVariants.Unsubscribe
| ClientMessageVariants.UnsubscribeMulti;
// A value with helper functions to construct the type.
export const ClientMessage = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
export const CallReducer = (value: __CallReducer): ClientMessage => ({
CallReducer: (value: CallReducer): ClientMessage => ({
tag: 'CallReducer',
value,
});
export const Subscribe = (value: __Subscribe): ClientMessage => ({
tag: 'Subscribe',
value,
});
export const OneOffQuery = (value: __OneOffQuery): ClientMessage => ({
}),
Subscribe: (value: Subscribe): ClientMessage => ({ tag: 'Subscribe', value }),
OneOffQuery: (value: OneOffQuery): ClientMessage => ({
tag: 'OneOffQuery',
value,
});
export const SubscribeSingle = (value: __SubscribeSingle): ClientMessage => ({
}),
SubscribeSingle: (value: SubscribeSingle): ClientMessage => ({
tag: 'SubscribeSingle',
value,
});
export const SubscribeMulti = (value: __SubscribeMulti): ClientMessage => ({
}),
SubscribeMulti: (value: SubscribeMulti): ClientMessage => ({
tag: 'SubscribeMulti',
value,
});
export const Unsubscribe = (value: __Unsubscribe): ClientMessage => ({
}),
Unsubscribe: (value: Unsubscribe): ClientMessage => ({
tag: 'Unsubscribe',
value,
});
export const UnsubscribeMulti = (
value: __UnsubscribeMulti
): ClientMessage => ({ tag: 'UnsubscribeMulti', value });
}),
UnsubscribeMulti: (value: UnsubscribeMulti): ClientMessage => ({
tag: 'UnsubscribeMulti',
value,
}),
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createSumType([
new SumTypeVariant(
'CallReducer',
__CallReducer.getTypeScriptAlgebraicType()
),
new SumTypeVariant('Subscribe', __Subscribe.getTypeScriptAlgebraicType()),
new SumTypeVariant(
'OneOffQuery',
__OneOffQuery.getTypeScriptAlgebraicType()
),
new SumTypeVariant(
'SubscribeSingle',
__SubscribeSingle.getTypeScriptAlgebraicType()
),
new SumTypeVariant(
'SubscribeMulti',
__SubscribeMulti.getTypeScriptAlgebraicType()
),
new SumTypeVariant(
'Unsubscribe',
__Unsubscribe.getTypeScriptAlgebraicType()
),
new SumTypeVariant(
'UnsubscribeMulti',
__UnsubscribeMulti.getTypeScriptAlgebraicType()
),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'CallReducer',
algebraicType: CallReducer.getTypeScriptAlgebraicType(),
},
{
name: 'Subscribe',
algebraicType: Subscribe.getTypeScriptAlgebraicType(),
},
{
name: 'OneOffQuery',
algebraicType: OneOffQuery.getTypeScriptAlgebraicType(),
},
{
name: 'SubscribeSingle',
algebraicType: SubscribeSingle.getTypeScriptAlgebraicType(),
},
{
name: 'SubscribeMulti',
algebraicType: SubscribeMulti.getTypeScriptAlgebraicType(),
},
{
name: 'Unsubscribe',
algebraicType: Unsubscribe.getTypeScriptAlgebraicType(),
},
{
name: 'UnsubscribeMulti',
algebraicType: UnsubscribeMulti.getTypeScriptAlgebraicType(),
},
],
});
},
export function serialize(writer: BinaryWriter, value: ClientMessage): void {
ClientMessage.getTypeScriptAlgebraicType().serialize(writer, value);
}
serialize(writer: __BinaryWriter, value: ClientMessage): void {
__AlgebraicTypeValue.serializeValue(
writer,
ClientMessage.getTypeScriptAlgebraicType(),
value
);
},
export function deserialize(reader: BinaryReader): ClientMessage {
return ClientMessage.getTypeScriptAlgebraicType().deserialize(reader);
}
}
// The tagged union or sum type for the algebraic type `ClientMessage`.
export type ClientMessage =
| ClientMessage.CallReducer
| ClientMessage.Subscribe
| ClientMessage.OneOffQuery
| ClientMessage.SubscribeSingle
| ClientMessage.SubscribeMulti
| ClientMessage.Unsubscribe
| ClientMessage.UnsubscribeMulti;
deserialize(reader: __BinaryReader): ClientMessage {
return __AlgebraicTypeValue.deserializeValue(
reader,
ClientMessage.getTypeScriptAlgebraicType()
);
},
};
export default ClientMessage;
@@ -0,0 +1,54 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { CallReducer as CallReducerType } from './call_reducer_type';
import { Subscribe as SubscribeType } from './subscribe_type';
import { OneOffQuery as OneOffQueryType } from './one_off_query_type';
import { SubscribeSingle as SubscribeSingleType } from './subscribe_single_type';
import { SubscribeMulti as SubscribeMultiType } from './subscribe_multi_type';
import { Unsubscribe as UnsubscribeType } from './unsubscribe_type';
import { UnsubscribeMulti as UnsubscribeMultiType } from './unsubscribe_multi_type';
export type CallReducer = { tag: 'CallReducer'; value: CallReducerType };
export type Subscribe = { tag: 'Subscribe'; value: SubscribeType };
export type OneOffQuery = { tag: 'OneOffQuery'; value: OneOffQueryType };
export type SubscribeSingle = {
tag: 'SubscribeSingle';
value: SubscribeSingleType;
};
export type SubscribeMulti = {
tag: 'SubscribeMulti';
value: SubscribeMultiType;
};
export type Unsubscribe = { tag: 'Unsubscribe'; value: UnsubscribeType };
export type UnsubscribeMulti = {
tag: 'UnsubscribeMulti';
value: UnsubscribeMultiType;
};
@@ -1,102 +1,97 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
// This was generated using spacetimedb cli version 1.4.0 (commit c9276358a10fa5dcbee7683260a68b8f9aef3361).
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
import {
AlgebraicType,
AlgebraicValue,
BinaryReader,
BinaryWriter,
CallReducerFlags,
ConnectionId,
DbConnectionBuilder,
DbConnectionImpl,
DbContext,
ErrorContextInterface,
Event,
EventContextInterface,
Identity,
ProductType,
ProductTypeElement,
ReducerEventContextInterface,
SubscriptionBuilderImpl,
SubscriptionEventContextInterface,
SumType,
SumTypeVariant,
TableCache,
TimeDuration,
Timestamp,
deepEqual,
AlgebraicType as __AlgebraicTypeValue,
BinaryReader as __BinaryReader,
BinaryWriter as __BinaryWriter,
ConnectionId as __ConnectionId,
DbConnectionBuilder as __DbConnectionBuilder,
DbConnectionImpl as __DbConnectionImpl,
Identity as __Identity,
SubscriptionBuilderImpl as __SubscriptionBuilderImpl,
TableCache as __TableCache,
TimeDuration as __TimeDuration,
Timestamp as __Timestamp,
deepEqual as __deepEqual,
type AlgebraicType as __AlgebraicTypeType,
type AlgebraicTypeVariants as __AlgebraicTypeVariants,
type CallReducerFlags as __CallReducerFlags,
type ErrorContextInterface as __ErrorContextInterface,
type Event as __Event,
type EventContextInterface as __EventContextInterface,
type ReducerEventContextInterface as __ReducerEventContextInterface,
type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,
} from '../index';
import { QueryUpdate as __QueryUpdate } from './query_update_type';
import { QueryUpdate } from './query_update_type';
// A namespace for generated variants and helper functions.
export namespace CompressableQueryUpdate {
// These are the generated variant types for each variant of the tagged union.
// One type is generated per variant and will be used in the `value` field of
// the tagged union.
export type Uncompressed = { tag: 'Uncompressed'; value: __QueryUpdate };
export type Brotli = { tag: 'Brotli'; value: Uint8Array };
export type Gzip = { tag: 'Gzip'; value: Uint8Array };
import * as CompressableQueryUpdateVariants from './compressable_query_update_variants';
// The tagged union or sum type for the algebraic type `CompressableQueryUpdate`.
export type CompressableQueryUpdate =
| CompressableQueryUpdateVariants.Uncompressed
| CompressableQueryUpdateVariants.Brotli
| CompressableQueryUpdateVariants.Gzip;
// A value with helper functions to construct the type.
export const CompressableQueryUpdate = {
// Helper functions for constructing each variant of the tagged union.
// ```
// const foo = Foo.A(42);
// assert!(foo.tag === "A");
// assert!(foo.value === 42);
// ```
export const Uncompressed = (
value: __QueryUpdate
): CompressableQueryUpdate => ({ tag: 'Uncompressed', value });
export const Brotli = (value: Uint8Array): CompressableQueryUpdate => ({
Uncompressed: (value: QueryUpdate): CompressableQueryUpdate => ({
tag: 'Uncompressed',
value,
}),
Brotli: (value: Uint8Array): CompressableQueryUpdate => ({
tag: 'Brotli',
value,
});
export const Gzip = (value: Uint8Array): CompressableQueryUpdate => ({
}),
Gzip: (value: Uint8Array): CompressableQueryUpdate => ({
tag: 'Gzip',
value,
});
}),
export function getTypeScriptAlgebraicType(): AlgebraicType {
return AlgebraicType.createSumType([
new SumTypeVariant(
'Uncompressed',
__QueryUpdate.getTypeScriptAlgebraicType()
),
new SumTypeVariant(
'Brotli',
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
),
new SumTypeVariant(
'Gzip',
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
),
]);
}
getTypeScriptAlgebraicType(): __AlgebraicTypeType {
return __AlgebraicTypeValue.Sum({
variants: [
{
name: 'Uncompressed',
algebraicType: QueryUpdate.getTypeScriptAlgebraicType(),
},
{
name: 'Brotli',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U8),
},
{
name: 'Gzip',
algebraicType: __AlgebraicTypeValue.Array(__AlgebraicTypeValue.U8),
},
],
});
},
export function serialize(
writer: BinaryWriter,
value: CompressableQueryUpdate
): void {
CompressableQueryUpdate.getTypeScriptAlgebraicType().serialize(
serialize(writer: __BinaryWriter, value: CompressableQueryUpdate): void {
__AlgebraicTypeValue.serializeValue(
writer,
CompressableQueryUpdate.getTypeScriptAlgebraicType(),
value
);
}
},
export function deserialize(reader: BinaryReader): CompressableQueryUpdate {
return CompressableQueryUpdate.getTypeScriptAlgebraicType().deserialize(
reader
deserialize(reader: __BinaryReader): CompressableQueryUpdate {
return __AlgebraicTypeValue.deserializeValue(
reader,
CompressableQueryUpdate.getTypeScriptAlgebraicType()
);
}
}
// The tagged union or sum type for the algebraic type `CompressableQueryUpdate`.
export type CompressableQueryUpdate =
| CompressableQueryUpdate.Uncompressed
| CompressableQueryUpdate.Brotli
| CompressableQueryUpdate.Gzip;
},
};
export default CompressableQueryUpdate;

Some files were not shown because too many files have changed in this diff Show More