mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-15 12:18:01 -04:00
ada45d464f
# Description of Changes This is a purely additive change to introduce, `TypeBuilder`s, `ColumnBuilder`s, and a `t` factory export that has methods for creating `TypeBuilder`s. There are derived types from `TypeBuilder`s for each variant of `AlgebraicType`. `TypeBuilder`s can be converted into a `ColumnBuilder` which supports creating additional metadata specifying whether a column is a primary key or should be unique. `ColumnBuilder`s are not allowed within `TypeBuilder`s, but the opposite is allowed (for composite types). `ColumnBuilder`s can only be used at the top level and contain a `TypeBuilder`. `TypeBuilder` stores three pieces of information: 1. A phantom typescript type that the SATS type should be interpreted as in TS 2. A phantom typescript type which is the type of the SATS type 3. A runtime AlgebraicType which stores the information to be reported to host. `ColumnBuilder` stores three pieces of information: 1. A `TypeBuilder` 2. A phantom typescript type with the column metadata 3. A runtime `ColumnMetadata` which stores the information to be reported to the host. Additionally, it is only possible to add metadata to `ColumnBuilder` or `TypeBuilder` types which are compatible with that metadata. e.g. It is a compile-time error to add `isAutoIncrementing` to a `String` type/column. # API and ABI breaking changes None # Expected complexity level and risk 2 # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] I've created a set of type tests in `type_builders.test-d.ts` - [x] I also created a set of runtime tests in `index.test.ts` - [x] I have modified CI so that these tests run on every PR