spacetimedb 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/react/index.mjs.map +1 -1
- package/dist/index.browser.mjs +18 -4
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +18 -16
- package/dist/index.mjs.map +1 -1
- package/dist/lib/algebraic_type.d.ts +115 -0
- package/dist/lib/algebraic_type.d.ts.map +1 -0
- package/dist/lib/algebraic_value.d.ts +6 -0
- package/dist/lib/algebraic_value.d.ts.map +1 -0
- package/dist/lib/autogen/algebraic_type_type.d.ts +64 -0
- package/dist/lib/autogen/algebraic_type_type.d.ts.map +1 -0
- package/dist/lib/autogen/algebraic_type_variants.d.ts +68 -0
- package/dist/lib/autogen/algebraic_type_variants.d.ts.map +1 -0
- package/dist/lib/autogen/index_type_type.d.ts +16 -0
- package/dist/lib/autogen/index_type_type.d.ts.map +1 -0
- package/dist/lib/autogen/index_type_variants.d.ts +7 -0
- package/dist/lib/autogen/index_type_variants.d.ts.map +1 -0
- package/dist/lib/autogen/lifecycle_type.d.ts +19 -0
- package/dist/lib/autogen/lifecycle_type.d.ts.map +1 -0
- package/dist/lib/autogen/lifecycle_variants.d.ts +10 -0
- package/dist/lib/autogen/lifecycle_variants.d.ts.map +1 -0
- package/dist/lib/autogen/misc_module_export_type.d.ts +12 -0
- package/dist/lib/autogen/misc_module_export_type.d.ts.map +1 -0
- package/dist/lib/autogen/misc_module_export_variants.d.ts +6 -0
- package/dist/lib/autogen/misc_module_export_variants.d.ts.map +1 -0
- package/dist/lib/autogen/product_type_element_type.d.ts +20 -0
- package/dist/lib/autogen/product_type_element_type.d.ts.map +1 -0
- package/dist/lib/autogen/product_type_type.d.ts +19 -0
- package/dist/lib/autogen/product_type_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_column_def_v_8_type.d.ts +20 -0
- package/dist/lib/autogen/raw_column_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_column_default_value_v_9_type.d.ts +20 -0
- package/dist/lib/autogen/raw_column_default_value_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_constraint_data_v_9_type.d.ts +12 -0
- package/dist/lib/autogen/raw_constraint_data_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_constraint_data_v_9_variants.d.ts +6 -0
- package/dist/lib/autogen/raw_constraint_data_v_9_variants.d.ts.map +1 -0
- package/dist/lib/autogen/raw_constraint_def_v_8_type.d.ts +20 -0
- package/dist/lib/autogen/raw_constraint_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_constraint_def_v_9_type.d.ts +20 -0
- package/dist/lib/autogen/raw_constraint_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_index_algorithm_type.d.ts +13 -0
- package/dist/lib/autogen/raw_index_algorithm_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_index_algorithm_variants.d.ts +13 -0
- package/dist/lib/autogen/raw_index_algorithm_variants.d.ts.map +1 -0
- package/dist/lib/autogen/raw_index_def_v_8_type.d.ts +22 -0
- package/dist/lib/autogen/raw_index_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_index_def_v_9_type.d.ts +21 -0
- package/dist/lib/autogen/raw_index_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_misc_module_export_v_9_type.d.ts +12 -0
- package/dist/lib/autogen/raw_misc_module_export_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_misc_module_export_v_9_variants.d.ts +6 -0
- package/dist/lib/autogen/raw_misc_module_export_v_9_variants.d.ts.map +1 -0
- package/dist/lib/autogen/raw_module_def_type.d.ts +14 -0
- package/dist/lib/autogen/raw_module_def_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_module_def_v_8_type.d.ts +25 -0
- package/dist/lib/autogen/raw_module_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_module_def_v_9_type.d.ts +29 -0
- package/dist/lib/autogen/raw_module_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_module_def_variants.d.ts +11 -0
- package/dist/lib/autogen/raw_module_def_variants.d.ts.map +1 -0
- package/dist/lib/autogen/raw_reducer_def_v_9_type.d.ts +22 -0
- package/dist/lib/autogen/raw_reducer_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_row_level_security_def_v_9_type.d.ts +18 -0
- package/dist/lib/autogen/raw_row_level_security_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_schedule_def_v_9_type.d.ts +20 -0
- package/dist/lib/autogen/raw_schedule_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_scoped_type_name_v_9_type.d.ts +19 -0
- package/dist/lib/autogen/raw_scoped_type_name_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_sequence_def_v_8_type.d.ts +24 -0
- package/dist/lib/autogen/raw_sequence_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_sequence_def_v_9_type.d.ts +23 -0
- package/dist/lib/autogen/raw_sequence_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_table_def_v_8_type.d.ts +29 -0
- package/dist/lib/autogen/raw_table_def_v_8_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_table_def_v_9_type.d.ts +32 -0
- package/dist/lib/autogen/raw_table_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_type_def_v_9_type.d.ts +21 -0
- package/dist/lib/autogen/raw_type_def_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/raw_unique_constraint_data_v_9_type.d.ts +18 -0
- package/dist/lib/autogen/raw_unique_constraint_data_v_9_type.d.ts.map +1 -0
- package/dist/lib/autogen/reducer_def_type.d.ts +20 -0
- package/dist/lib/autogen/reducer_def_type.d.ts.map +1 -0
- package/dist/lib/autogen/sum_type_type.d.ts +19 -0
- package/dist/lib/autogen/sum_type_type.d.ts.map +1 -0
- package/dist/lib/autogen/sum_type_variant_type.d.ts +20 -0
- package/dist/lib/autogen/sum_type_variant_type.d.ts.map +1 -0
- package/dist/lib/autogen/table_access_type.d.ts +16 -0
- package/dist/lib/autogen/table_access_type.d.ts.map +1 -0
- package/dist/lib/autogen/table_access_variants.d.ts +7 -0
- package/dist/lib/autogen/table_access_variants.d.ts.map +1 -0
- package/dist/lib/autogen/table_desc_type.d.ts +20 -0
- package/dist/lib/autogen/table_desc_type.d.ts.map +1 -0
- package/dist/lib/autogen/table_type_type.d.ts +16 -0
- package/dist/lib/autogen/table_type_type.d.ts.map +1 -0
- package/dist/lib/autogen/table_type_variants.d.ts +7 -0
- package/dist/lib/autogen/table_type_variants.d.ts.map +1 -0
- package/dist/lib/autogen/type_alias_type.d.ts +19 -0
- package/dist/lib/autogen/type_alias_type.d.ts.map +1 -0
- package/dist/lib/autogen/typespace_type.d.ts +19 -0
- package/dist/lib/autogen/typespace_type.d.ts.map +1 -0
- package/dist/lib/binary_reader.d.ts +25 -0
- package/dist/lib/binary_reader.d.ts.map +1 -0
- package/dist/lib/binary_writer.d.ts +25 -0
- package/dist/lib/binary_writer.d.ts.map +1 -0
- package/dist/lib/connection_id.d.ts +37 -0
- package/dist/lib/connection_id.d.ts.map +1 -0
- package/dist/lib/identity.d.ts +39 -0
- package/dist/lib/identity.d.ts.map +1 -0
- package/dist/lib/schedule_at.d.ts +23 -0
- package/dist/lib/schedule_at.d.ts.map +1 -0
- package/dist/lib/time_duration.d.ts +18 -0
- package/dist/lib/time_duration.d.ts.map +1 -0
- package/dist/lib/timestamp.d.ts +35 -0
- package/dist/lib/timestamp.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/min/index.browser.mjs +1 -1
- package/dist/min/index.browser.mjs.map +1 -1
- package/dist/min/react/index.mjs.map +1 -1
- package/dist/min/sdk/index.browser.mjs +1 -1
- package/dist/min/sdk/index.browser.mjs.map +1 -1
- package/dist/react/SpacetimeDBProvider.d.ts +8 -0
- package/dist/react/SpacetimeDBProvider.d.ts.map +1 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/useSpacetimeDB.d.ts +5 -0
- package/dist/react/useSpacetimeDB.d.ts.map +1 -0
- package/dist/react/useTable.d.ts +120 -0
- package/dist/react/useTable.d.ts.map +1 -0
- package/dist/sdk/client_api/bsatn_row_list_type.d.ts +20 -0
- package/dist/sdk/client_api/bsatn_row_list_type.d.ts.map +1 -0
- package/dist/sdk/client_api/call_reducer_type.d.ts +21 -0
- package/dist/sdk/client_api/call_reducer_type.d.ts.map +1 -0
- package/dist/sdk/client_api/client_message_type.d.ts +24 -0
- package/dist/sdk/client_api/client_message_type.d.ts.map +1 -0
- package/dist/sdk/client_api/client_message_variants.d.ts +36 -0
- package/dist/sdk/client_api/client_message_variants.d.ts.map +1 -0
- package/dist/sdk/client_api/compressable_query_update_type.d.ts +14 -0
- package/dist/sdk/client_api/compressable_query_update_type.d.ts.map +1 -0
- package/dist/sdk/client_api/compressable_query_update_variants.d.ts +14 -0
- package/dist/sdk/client_api/compressable_query_update_variants.d.ts.map +1 -0
- package/dist/sdk/client_api/database_update_type.d.ts +19 -0
- package/dist/sdk/client_api/database_update_type.d.ts.map +1 -0
- package/dist/sdk/client_api/energy_quanta_type.d.ts +18 -0
- package/dist/sdk/client_api/energy_quanta_type.d.ts.map +1 -0
- package/dist/sdk/client_api/identity_token_type.d.ts +20 -0
- package/dist/sdk/client_api/identity_token_type.d.ts.map +1 -0
- package/dist/sdk/client_api/index.d.ts +86 -0
- package/dist/sdk/client_api/index.d.ts.map +1 -0
- package/dist/sdk/client_api/initial_subscription_type.d.ts +21 -0
- package/dist/sdk/client_api/initial_subscription_type.d.ts.map +1 -0
- package/dist/sdk/client_api/one_off_query_response_type.d.ts +22 -0
- package/dist/sdk/client_api/one_off_query_response_type.d.ts.map +1 -0
- package/dist/sdk/client_api/one_off_query_type.d.ts +19 -0
- package/dist/sdk/client_api/one_off_query_type.d.ts.map +1 -0
- package/dist/sdk/client_api/one_off_table_type.d.ts +20 -0
- package/dist/sdk/client_api/one_off_table_type.d.ts.map +1 -0
- package/dist/sdk/client_api/query_id_type.d.ts +18 -0
- package/dist/sdk/client_api/query_id_type.d.ts.map +1 -0
- package/dist/sdk/client_api/query_update_type.d.ts +20 -0
- package/dist/sdk/client_api/query_update_type.d.ts.map +1 -0
- package/dist/sdk/client_api/reducer_call_info_type.d.ts +21 -0
- package/dist/sdk/client_api/reducer_call_info_type.d.ts.map +1 -0
- package/dist/sdk/client_api/row_size_hint_type.d.ts +12 -0
- package/dist/sdk/client_api/row_size_hint_type.d.ts.map +1 -0
- package/dist/sdk/client_api/row_size_hint_variants.d.ts +9 -0
- package/dist/sdk/client_api/row_size_hint_variants.d.ts.map +1 -0
- package/dist/sdk/client_api/server_message_type.d.ts +30 -0
- package/dist/sdk/client_api/server_message_type.d.ts.map +1 -0
- package/dist/sdk/client_api/server_message_variants.d.ts +51 -0
- package/dist/sdk/client_api/server_message_variants.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_applied_type.d.ts +23 -0
- package/dist/sdk/client_api/subscribe_applied_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_multi_applied_type.d.ts +23 -0
- package/dist/sdk/client_api/subscribe_multi_applied_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_multi_type.d.ts +21 -0
- package/dist/sdk/client_api/subscribe_multi_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_rows_type.d.ts +21 -0
- package/dist/sdk/client_api/subscribe_rows_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_single_type.d.ts +21 -0
- package/dist/sdk/client_api/subscribe_single_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscribe_type.d.ts +19 -0
- package/dist/sdk/client_api/subscribe_type.d.ts.map +1 -0
- package/dist/sdk/client_api/subscription_error_type.d.ts +22 -0
- package/dist/sdk/client_api/subscription_error_type.d.ts.map +1 -0
- package/dist/sdk/client_api/table_update_type.d.ts +22 -0
- package/dist/sdk/client_api/table_update_type.d.ts.map +1 -0
- package/dist/sdk/client_api/transaction_update_light_type.d.ts +20 -0
- package/dist/sdk/client_api/transaction_update_light_type.d.ts.map +1 -0
- package/dist/sdk/client_api/transaction_update_type.d.ts +27 -0
- package/dist/sdk/client_api/transaction_update_type.d.ts.map +1 -0
- package/dist/sdk/client_api/unsubscribe_applied_type.d.ts +23 -0
- package/dist/sdk/client_api/unsubscribe_applied_type.d.ts.map +1 -0
- package/dist/sdk/client_api/unsubscribe_multi_applied_type.d.ts +23 -0
- package/dist/sdk/client_api/unsubscribe_multi_applied_type.d.ts.map +1 -0
- package/dist/sdk/client_api/unsubscribe_multi_type.d.ts +20 -0
- package/dist/sdk/client_api/unsubscribe_multi_type.d.ts.map +1 -0
- package/dist/sdk/client_api/unsubscribe_type.d.ts +20 -0
- package/dist/sdk/client_api/unsubscribe_type.d.ts.map +1 -0
- package/dist/sdk/client_api/update_status_type.d.ts +16 -0
- package/dist/sdk/client_api/update_status_type.d.ts.map +1 -0
- package/dist/sdk/client_api/update_status_variants.d.ts +13 -0
- package/dist/sdk/client_api/update_status_variants.d.ts.map +1 -0
- package/dist/sdk/client_cache.d.ts +17 -0
- package/dist/sdk/client_cache.d.ts.map +1 -0
- package/dist/sdk/db_connection_builder.d.ts +145 -0
- package/dist/sdk/db_connection_builder.d.ts.map +1 -0
- package/dist/sdk/db_connection_impl.d.ts +102 -0
- package/dist/sdk/db_connection_impl.d.ts.map +1 -0
- package/dist/sdk/db_context.d.ts +25 -0
- package/dist/sdk/db_context.d.ts.map +1 -0
- package/dist/sdk/decompress.d.ts +2 -0
- package/dist/sdk/decompress.d.ts.map +1 -0
- package/dist/sdk/event.d.ts +15 -0
- package/dist/sdk/event.d.ts.map +1 -0
- package/dist/sdk/event_context.d.ts +18 -0
- package/dist/sdk/event_context.d.ts.map +1 -0
- package/dist/sdk/event_emitter.d.ts +7 -0
- package/dist/sdk/event_emitter.d.ts.map +1 -0
- package/dist/sdk/index.browser.mjs +18 -4
- package/dist/sdk/index.browser.mjs.map +1 -1
- package/dist/sdk/index.cjs +18 -16
- package/dist/sdk/index.cjs.map +1 -1
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.mjs +18 -16
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/json_api.d.ts +40 -0
- package/dist/sdk/json_api.d.ts.map +1 -0
- package/dist/sdk/logger.d.ts +4 -0
- package/dist/sdk/logger.d.ts.map +1 -0
- package/dist/sdk/message_types.d.ts +50 -0
- package/dist/sdk/message_types.d.ts.map +1 -0
- package/dist/sdk/reducer_event.d.ts +42 -0
- package/dist/sdk/reducer_event.d.ts.map +1 -0
- package/dist/sdk/spacetime_module.d.ts +31 -0
- package/dist/sdk/spacetime_module.d.ts.map +1 -0
- package/dist/sdk/subscription_builder_impl.d.ts +126 -0
- package/dist/sdk/subscription_builder_impl.d.ts.map +1 -0
- package/dist/sdk/table_cache.d.ts +111 -0
- package/dist/sdk/table_cache.d.ts.map +1 -0
- package/dist/sdk/version.d.ts +18 -0
- package/dist/sdk/version.d.ts.map +1 -0
- package/dist/sdk/websocket_decompress_adapter.d.ts +21 -0
- package/dist/sdk/websocket_decompress_adapter.d.ts.map +1 -0
- package/dist/sdk/websocket_test_adapter.d.ts +22 -0
- package/dist/sdk/websocket_test_adapter.d.ts.map +1 -0
- package/dist/sdk/ws.d.ts +2 -0
- package/dist/sdk/ws.d.ts.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/type_builders.d.ts +656 -0
- package/dist/server/type_builders.d.ts.map +1 -0
- package/dist/server/type_builders.test-d.d.ts +2 -0
- package/dist/server/type_builders.test-d.d.ts.map +1 -0
- package/dist/server/type_util.d.ts +18 -0
- package/dist/server/type_util.d.ts.map +1 -0
- package/package.json +30 -27
- package/src/react/SpacetimeDBProvider.ts +4 -1
- package/src/react/useSpacetimeDB.ts +1 -1
- package/src/react/useTable.ts +1 -1
- package/src/sdk/db_connection_builder.ts +1 -1
- package/src/sdk/db_connection_impl.ts +6 -6
- package/src/sdk/message_types.ts +3 -3
- package/src/sdk/reducer_event.ts +3 -3
- package/src/sdk/spacetime_module.ts +1 -1
- package/src/sdk/table_cache.ts +1 -1
- package/src/sdk/websocket_decompress_adapter.ts +2 -30
- package/src/sdk/websocket_test_adapter.ts +1 -1
- package/src/sdk/ws.ts +24 -0
- package/LICENSE.txt +0 -759
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import { AlgebraicType, ConnectionId, Identity, ScheduleAt, TimeDuration, Timestamp, type AlgebraicTypeVariants } from '..';
|
|
2
|
+
import type { Set } from './type_util';
|
|
3
|
+
/**
|
|
4
|
+
* Helper type to extract the TypeScript type from a TypeBuilder
|
|
5
|
+
*/
|
|
6
|
+
export type InferTypeOfTypeBuilder<T> = T extends TypeBuilder<infer U, any> ? U : never;
|
|
7
|
+
/**
|
|
8
|
+
* Helper type to extract the TypeScript type from a TypeBuilder
|
|
9
|
+
*/
|
|
10
|
+
export type Infer<T> = InferTypeOfTypeBuilder<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper type to extract the type of a row from an object.
|
|
13
|
+
*/
|
|
14
|
+
export type InferTypeOfRow<T> = T extends Record<string, ColumnBuilder<any, any, any> | TypeBuilder<any, any>> ? {
|
|
15
|
+
[K in keyof T]: T[K] extends ColumnBuilder<infer V, any, any> ? V : T[K] extends TypeBuilder<infer V, any> ? V : never;
|
|
16
|
+
} : never;
|
|
17
|
+
/**
|
|
18
|
+
* Type which represents a valid argument to the ProductColumnBuilder
|
|
19
|
+
*/
|
|
20
|
+
type ElementsObj = Record<string, TypeBuilder<any, any>>;
|
|
21
|
+
/**
|
|
22
|
+
* Type which converts the elements of ElementsObj to a ProductType elements array
|
|
23
|
+
*/
|
|
24
|
+
type ElementsArrayFromElementsObj<Obj extends ElementsObj> = {
|
|
25
|
+
name: keyof Obj & string;
|
|
26
|
+
algebraicType: Obj[keyof Obj & string]['spacetimeType'];
|
|
27
|
+
}[];
|
|
28
|
+
/**
|
|
29
|
+
* A type which converts the elements of ElementsObj to a TypeScript object type.
|
|
30
|
+
* It works by `Infer`ing the types of the column builders which are the values of
|
|
31
|
+
* the keys in the object passed in.
|
|
32
|
+
*
|
|
33
|
+
* e.g. { a: I32TypeBuilder, b: StringBuilder } -> { a: number, b: string }
|
|
34
|
+
*/
|
|
35
|
+
type TypeScriptTypeFromElementsObj<Elements extends ElementsObj> = {
|
|
36
|
+
[K in keyof Elements]: InferTypeOfTypeBuilder<Elements[K]>;
|
|
37
|
+
};
|
|
38
|
+
type VariantsObj = Record<string, TypeBuilder<any, any>>;
|
|
39
|
+
/**
|
|
40
|
+
* A type which converts the elements of ElementsObj to a TypeScript object type.
|
|
41
|
+
* It works by `Infer`ing the types of the column builders which are the values of
|
|
42
|
+
* the keys in the object passed in.
|
|
43
|
+
*
|
|
44
|
+
* e.g. { A: I32TypeBuilder, B: StringBuilder } -> { tag: "A", value: number } | { tag: "B", value: string }
|
|
45
|
+
*/
|
|
46
|
+
type TypeScriptTypeFromVariantsObj<Variants extends VariantsObj> = {
|
|
47
|
+
[K in keyof Variants]: {
|
|
48
|
+
tag: K;
|
|
49
|
+
value: InferTypeOfTypeBuilder<Variants[K]>;
|
|
50
|
+
};
|
|
51
|
+
}[keyof Variants];
|
|
52
|
+
/**
|
|
53
|
+
* Type which converts the elements of VariantsObj to a SumType variants array
|
|
54
|
+
*/
|
|
55
|
+
type VariantsArrayFromVariantsObj<Obj extends VariantsObj> = {
|
|
56
|
+
name: keyof Obj & string;
|
|
57
|
+
algebraicType: Obj[keyof Obj & string]['spacetimeType'];
|
|
58
|
+
}[];
|
|
59
|
+
/**
|
|
60
|
+
* A generic type builder that captures both the TypeScript type
|
|
61
|
+
* and the corresponding `AlgebraicType`.
|
|
62
|
+
*/
|
|
63
|
+
export declare class TypeBuilder<Type, SpacetimeType extends AlgebraicType> {
|
|
64
|
+
/**
|
|
65
|
+
* The TypeScript phantom type. This is not stored at runtime,
|
|
66
|
+
* but is visible to the compiler
|
|
67
|
+
*/
|
|
68
|
+
readonly type: Type;
|
|
69
|
+
/**
|
|
70
|
+
* TypeScript phantom type representing the type of the particular
|
|
71
|
+
* AlgebraicType stored in {@link algebraicType}.
|
|
72
|
+
*/
|
|
73
|
+
readonly spacetimeType: SpacetimeType;
|
|
74
|
+
/**
|
|
75
|
+
* The SpacetimeDB algebraic type (run‑time value). In addition to storing
|
|
76
|
+
* the runtime representation of the `AlgebraicType`, it also captures
|
|
77
|
+
* the TypeScript type information of the `AlgebraicType`. That is to say
|
|
78
|
+
* the value is not merely an `AlgebraicType`, but is constructed to be
|
|
79
|
+
* the corresponding concrete `AlgebraicType` for the TypeScript type `Type`.
|
|
80
|
+
*
|
|
81
|
+
* e.g. `string` corresponds to `AlgebraicType.String`
|
|
82
|
+
*/
|
|
83
|
+
readonly algebraicType: AlgebraicType;
|
|
84
|
+
constructor(algebraicType: AlgebraicType);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Interface for types that can be converted into a column builder with primary key metadata.
|
|
88
|
+
*
|
|
89
|
+
* Implementing this interface allows a type to be marked as the primary key of a table column
|
|
90
|
+
* in a type-safe manner. The `primaryKey()` method returns a new `ColumnBuilder` instance
|
|
91
|
+
* with the metadata updated to indicate that the column is a primary key.
|
|
92
|
+
*
|
|
93
|
+
* @typeParam Type - The TypeScript type of the column's value.
|
|
94
|
+
* @typeParam SpacetimeType - The corresponding SpacetimeDB algebraic type.
|
|
95
|
+
* @typeParam M - The metadata type for the column, defaulting to `DefaultMetadata`.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* - This interface is typically implemented by type builders for primitive and complex types.
|
|
99
|
+
* - The returned `ColumnBuilder` will have its metadata extended with `{ isPrimaryKey: true }`.
|
|
100
|
+
* - Marking a column as a primary key is mutually exclusive with certain other metadata flags,
|
|
101
|
+
* such as `isAutoIncrement` or `isUnique`, depending on the database schema rules.
|
|
102
|
+
*/
|
|
103
|
+
interface PrimaryKeyable<Type, SpacetimeType extends AlgebraicType, M extends ColumnMetadata = DefaultMetadata> {
|
|
104
|
+
/**
|
|
105
|
+
* Specify this column as primary key
|
|
106
|
+
*/
|
|
107
|
+
primaryKey(): ColumnBuilder<Type, SpacetimeType, Set<M, 'isPrimaryKey', true>>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Interface for types that can be converted into a column builder with unique metadata.
|
|
111
|
+
*
|
|
112
|
+
* Implementing this interface allows a type to be marked as unique in a table column
|
|
113
|
+
* in a type-safe manner. The `unique()` method returns a new `ColumnBuilder` instance
|
|
114
|
+
* with the metadata updated to indicate that the column is unique.
|
|
115
|
+
*
|
|
116
|
+
* @typeParam Type - The TypeScript type of the column's value.
|
|
117
|
+
* @typeParam SpacetimeType - The corresponding SpacetimeDB algebraic type.
|
|
118
|
+
* @typeParam M - The metadata type for the column, defaulting to `DefaultMetadata`.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* - This interface is typically implemented by type builders for primitive and complex types.
|
|
122
|
+
* - The returned `ColumnBuilder` will have its metadata extended with `{ isUnique: true }`.
|
|
123
|
+
* - Marking a column as unique is mutually exclusive with certain other metadata flags,
|
|
124
|
+
* such as `isAutoIncrement` or `isPrimaryKey`, depending on the database schema rules.
|
|
125
|
+
*/
|
|
126
|
+
interface Uniqueable<Type, SpacetimeType extends AlgebraicType, M extends ColumnMetadata = DefaultMetadata> {
|
|
127
|
+
/**
|
|
128
|
+
* Specify this column as unique
|
|
129
|
+
*/
|
|
130
|
+
unique(): ColumnBuilder<Type, SpacetimeType, Set<M, 'isUnique', true>>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Interface for types that can be converted into a column builder with index metadata.
|
|
134
|
+
*
|
|
135
|
+
* Implementing this interface allows a type to be indexed in a table column
|
|
136
|
+
* in a type-safe manner. The `index()` method returns a new `ColumnBuilder` instance
|
|
137
|
+
* with the metadata updated to indicate the index type.
|
|
138
|
+
*
|
|
139
|
+
* @typeParam Type - The TypeScript type of the column's value.
|
|
140
|
+
* @typeParam SpacetimeType - The corresponding SpacetimeDB algebraic type.
|
|
141
|
+
* @typeParam M - The metadata type for the column, defaulting to `DefaultMetadata`.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* - This interface is typically implemented by type builders for primitive and complex types.
|
|
145
|
+
* - The returned `ColumnBuilder` will have its metadata extended with `{ indexType: N }`.
|
|
146
|
+
* - Indexing a column may have implications for performance and query optimization.
|
|
147
|
+
*/
|
|
148
|
+
interface Indexable<Type, SpacetimeType extends AlgebraicType, M extends ColumnMetadata = DefaultMetadata> {
|
|
149
|
+
/**
|
|
150
|
+
* Specify the index type for this column
|
|
151
|
+
* @param algorithm The index algorithm to use
|
|
152
|
+
*/
|
|
153
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): ColumnBuilder<Type, SpacetimeType, Set<M, 'indexType', N>>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Interface for types that can be converted into a column builder with auto-increment metadata.
|
|
157
|
+
*
|
|
158
|
+
* Implementing this interface allows a type to be marked as auto-incrementing in a table column
|
|
159
|
+
* in a type-safe manner. The `autoInc()` method returns a new `ColumnBuilder` instance
|
|
160
|
+
* with the metadata updated to indicate that the column is auto-incrementing.
|
|
161
|
+
*
|
|
162
|
+
* @typeParam Type - The TypeScript type of the column's value.
|
|
163
|
+
* @typeParam SpacetimeType - The corresponding SpacetimeDB algebraic type.
|
|
164
|
+
* @typeParam M - The metadata type for the column, defaulting to `DefaultMetadata`.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* - This interface is typically implemented by type builders for primitive and complex types.
|
|
168
|
+
* - The returned `ColumnBuilder` will have its metadata extended with `{ isAutoIncrement: true }`.
|
|
169
|
+
* - Marking a column as auto-incrementing is mutually exclusive with certain other metadata flags,
|
|
170
|
+
* such as `isUnique` or `isPrimaryKey`, depending on the database schema rules.
|
|
171
|
+
*/
|
|
172
|
+
interface AutoIncrementable<Type, SpacetimeType extends AlgebraicType, M extends ColumnMetadata = DefaultMetadata> {
|
|
173
|
+
/**
|
|
174
|
+
* Specify this column as auto-incrementing
|
|
175
|
+
*/
|
|
176
|
+
autoInc(): ColumnBuilder<Type, SpacetimeType, Set<M, 'isAutoIncrement', true>>;
|
|
177
|
+
}
|
|
178
|
+
export declare class U8Builder extends TypeBuilder<number, AlgebraicTypeVariants.U8> implements Indexable<number, AlgebraicTypeVariants.U8>, Uniqueable<number, AlgebraicTypeVariants.U8>, PrimaryKeyable<number, AlgebraicTypeVariants.U8>, AutoIncrementable<number, AlgebraicTypeVariants.U8> {
|
|
179
|
+
constructor();
|
|
180
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U8ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
181
|
+
unique(): U8ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
182
|
+
primaryKey(): U8ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
183
|
+
autoInc(): U8ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
184
|
+
}
|
|
185
|
+
export declare class U16Builder extends TypeBuilder<number, AlgebraicTypeVariants.U16> implements Indexable<number, AlgebraicTypeVariants.U16>, Uniqueable<number, AlgebraicTypeVariants.U16>, PrimaryKeyable<number, AlgebraicTypeVariants.U16>, AutoIncrementable<number, AlgebraicTypeVariants.U16> {
|
|
186
|
+
constructor();
|
|
187
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U16ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
188
|
+
unique(): U16ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
189
|
+
primaryKey(): U16ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
190
|
+
autoInc(): U16ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
191
|
+
}
|
|
192
|
+
export declare class U32Builder extends TypeBuilder<number, AlgebraicTypeVariants.U32> implements Indexable<number, AlgebraicTypeVariants.U32>, Uniqueable<number, AlgebraicTypeVariants.U32>, PrimaryKeyable<number, AlgebraicTypeVariants.U32>, AutoIncrementable<number, AlgebraicTypeVariants.U32> {
|
|
193
|
+
constructor();
|
|
194
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U32ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
195
|
+
unique(): U32ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
196
|
+
primaryKey(): U32ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
197
|
+
autoInc(): U32ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
198
|
+
}
|
|
199
|
+
export declare class U64Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.U64> implements Indexable<bigint, AlgebraicTypeVariants.U64>, Uniqueable<bigint, AlgebraicTypeVariants.U64>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U64>, AutoIncrementable<bigint, AlgebraicTypeVariants.U64> {
|
|
200
|
+
constructor();
|
|
201
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U64ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
202
|
+
unique(): U64ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
203
|
+
primaryKey(): U64ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
204
|
+
autoInc(): U64ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
205
|
+
}
|
|
206
|
+
export declare class U128Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.U128> implements Indexable<bigint, AlgebraicTypeVariants.U128>, Uniqueable<bigint, AlgebraicTypeVariants.U128>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U128>, AutoIncrementable<bigint, AlgebraicTypeVariants.U128> {
|
|
207
|
+
constructor();
|
|
208
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U128ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
209
|
+
unique(): U128ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
210
|
+
primaryKey(): U128ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
211
|
+
autoInc(): U128ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
212
|
+
}
|
|
213
|
+
export declare class U256Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.U256> implements Indexable<bigint, AlgebraicTypeVariants.U256>, Uniqueable<bigint, AlgebraicTypeVariants.U256>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U256>, AutoIncrementable<bigint, AlgebraicTypeVariants.U256> {
|
|
214
|
+
constructor();
|
|
215
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U256ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
216
|
+
unique(): U256ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
217
|
+
primaryKey(): U256ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
218
|
+
autoInc(): U256ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
219
|
+
}
|
|
220
|
+
export declare class I8Builder extends TypeBuilder<number, AlgebraicTypeVariants.I8> implements Indexable<number, AlgebraicTypeVariants.I8>, Uniqueable<number, AlgebraicTypeVariants.I8>, PrimaryKeyable<number, AlgebraicTypeVariants.I8>, AutoIncrementable<number, AlgebraicTypeVariants.I8> {
|
|
221
|
+
constructor();
|
|
222
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I8ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
223
|
+
unique(): I8ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
224
|
+
primaryKey(): I8ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
225
|
+
autoInc(): I8ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
226
|
+
}
|
|
227
|
+
export declare class I16Builder extends TypeBuilder<number, AlgebraicTypeVariants.I16> implements Indexable<number, AlgebraicTypeVariants.I16>, Uniqueable<number, AlgebraicTypeVariants.I16>, PrimaryKeyable<number, AlgebraicTypeVariants.I16>, AutoIncrementable<number, AlgebraicTypeVariants.I16> {
|
|
228
|
+
constructor();
|
|
229
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I16ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
230
|
+
unique(): I16ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
231
|
+
primaryKey(): I16ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
232
|
+
autoInc(): I16ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
233
|
+
}
|
|
234
|
+
export declare class I32Builder extends TypeBuilder<number, AlgebraicTypeVariants.I32> implements Indexable<number, AlgebraicTypeVariants.I32>, Uniqueable<number, AlgebraicTypeVariants.I32>, PrimaryKeyable<number, AlgebraicTypeVariants.I32>, AutoIncrementable<number, AlgebraicTypeVariants.I32> {
|
|
235
|
+
constructor();
|
|
236
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I32ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
237
|
+
unique(): I32ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
238
|
+
primaryKey(): I32ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
239
|
+
autoInc(): I32ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
240
|
+
}
|
|
241
|
+
export declare class I64Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.I64> implements Indexable<bigint, AlgebraicTypeVariants.I64>, Uniqueable<bigint, AlgebraicTypeVariants.I64>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I64>, AutoIncrementable<bigint, AlgebraicTypeVariants.I64> {
|
|
242
|
+
constructor();
|
|
243
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I64ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
244
|
+
unique(): I64ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
245
|
+
primaryKey(): I64ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
246
|
+
autoInc(): I64ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
247
|
+
}
|
|
248
|
+
export declare class I128Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.I128> implements Indexable<bigint, AlgebraicTypeVariants.I128>, Uniqueable<bigint, AlgebraicTypeVariants.I128>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I128>, AutoIncrementable<bigint, AlgebraicTypeVariants.I128> {
|
|
249
|
+
constructor();
|
|
250
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I128ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
251
|
+
unique(): I128ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
252
|
+
primaryKey(): I128ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
253
|
+
autoInc(): I128ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
254
|
+
}
|
|
255
|
+
export declare class I256Builder extends TypeBuilder<bigint, AlgebraicTypeVariants.I256> implements Indexable<bigint, AlgebraicTypeVariants.I256>, Uniqueable<bigint, AlgebraicTypeVariants.I256>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I256>, AutoIncrementable<bigint, AlgebraicTypeVariants.I256> {
|
|
256
|
+
constructor();
|
|
257
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I256ColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
258
|
+
unique(): I256ColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
259
|
+
primaryKey(): I256ColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
260
|
+
autoInc(): I256ColumnBuilder<Set<DefaultMetadata, 'isAutoIncrement', true>>;
|
|
261
|
+
}
|
|
262
|
+
export declare class F32Builder extends TypeBuilder<number, AlgebraicTypeVariants.F32> {
|
|
263
|
+
constructor();
|
|
264
|
+
}
|
|
265
|
+
export declare class F64Builder extends TypeBuilder<number, AlgebraicTypeVariants.F64> {
|
|
266
|
+
constructor();
|
|
267
|
+
}
|
|
268
|
+
export declare class BoolBuilder extends TypeBuilder<boolean, AlgebraicTypeVariants.Bool> implements Indexable<boolean, AlgebraicTypeVariants.Bool>, Uniqueable<boolean, AlgebraicTypeVariants.Bool>, PrimaryKeyable<boolean, AlgebraicTypeVariants.Bool> {
|
|
269
|
+
constructor();
|
|
270
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): BoolColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
271
|
+
unique(): BoolColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
272
|
+
primaryKey(): BoolColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
273
|
+
}
|
|
274
|
+
export declare class StringBuilder extends TypeBuilder<string, AlgebraicTypeVariants.String> implements Indexable<string, AlgebraicTypeVariants.String>, Uniqueable<string, AlgebraicTypeVariants.String>, PrimaryKeyable<string, AlgebraicTypeVariants.String> {
|
|
275
|
+
constructor();
|
|
276
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): StringColumnBuilder<Set<DefaultMetadata, 'indexType', N>>;
|
|
277
|
+
unique(): StringColumnBuilder<Set<DefaultMetadata, 'isUnique', true>>;
|
|
278
|
+
primaryKey(): StringColumnBuilder<Set<DefaultMetadata, 'isPrimaryKey', true>>;
|
|
279
|
+
}
|
|
280
|
+
export declare class ArrayBuilder<Element extends TypeBuilder<any, any>> extends TypeBuilder<Array<Element['type']>, {
|
|
281
|
+
tag: 'Array';
|
|
282
|
+
value: Element['spacetimeType'];
|
|
283
|
+
}> {
|
|
284
|
+
/**
|
|
285
|
+
* The phantom element type of the array for TypeScript
|
|
286
|
+
*/
|
|
287
|
+
readonly element: Element;
|
|
288
|
+
constructor(element: Element);
|
|
289
|
+
}
|
|
290
|
+
export declare class ProductBuilder<Elements extends ElementsObj> extends TypeBuilder<TypeScriptTypeFromElementsObj<Elements>, {
|
|
291
|
+
tag: 'Product';
|
|
292
|
+
value: {
|
|
293
|
+
elements: ElementsArrayFromElementsObj<Elements>;
|
|
294
|
+
};
|
|
295
|
+
}> {
|
|
296
|
+
/**
|
|
297
|
+
* The phantom element types of the product for TypeScript
|
|
298
|
+
*/
|
|
299
|
+
readonly elements: Elements;
|
|
300
|
+
constructor(elements: Elements);
|
|
301
|
+
}
|
|
302
|
+
export declare class SumBuilder<Variants extends VariantsObj> extends TypeBuilder<TypeScriptTypeFromVariantsObj<Variants>, {
|
|
303
|
+
tag: 'Sum';
|
|
304
|
+
value: {
|
|
305
|
+
variants: VariantsArrayFromVariantsObj<Variants>;
|
|
306
|
+
};
|
|
307
|
+
}> {
|
|
308
|
+
/**
|
|
309
|
+
* The phantom variant types of the sum for TypeScript
|
|
310
|
+
*/
|
|
311
|
+
readonly variants: Variants;
|
|
312
|
+
constructor(variants: Variants);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The type of index types that can be applied to a column.
|
|
316
|
+
* `undefined` is the default
|
|
317
|
+
*/
|
|
318
|
+
type IndexTypes = 'btree' | 'hash' | undefined;
|
|
319
|
+
/**
|
|
320
|
+
* Metadata describing column constraints and index type
|
|
321
|
+
*/
|
|
322
|
+
export type ColumnMetadata = {
|
|
323
|
+
isPrimaryKey?: true;
|
|
324
|
+
isUnique?: true;
|
|
325
|
+
isAutoIncrement?: true;
|
|
326
|
+
isScheduleAt?: true;
|
|
327
|
+
indexType?: IndexTypes;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Default metadata state type for a newly created column
|
|
331
|
+
*/
|
|
332
|
+
type DefaultMetadata = object;
|
|
333
|
+
/**
|
|
334
|
+
* A column builder allows you to incrementally specify constraints
|
|
335
|
+
* and metadata for a column in a type-safe way.
|
|
336
|
+
*
|
|
337
|
+
* It carries both a phantom TypeScript type (the `Type`) and
|
|
338
|
+
* runtime algebraic type information.
|
|
339
|
+
*/
|
|
340
|
+
export declare class ColumnBuilder<Type, SpacetimeType extends AlgebraicType, M extends ColumnMetadata = DefaultMetadata> {
|
|
341
|
+
/**
|
|
342
|
+
* The TypeScript phantom type. This is not stored at runtime,
|
|
343
|
+
* but is visible to the compiler
|
|
344
|
+
*/
|
|
345
|
+
readonly columnMetadataType: M;
|
|
346
|
+
typeBuilder: TypeBuilder<Type, SpacetimeType>;
|
|
347
|
+
columnMetadata: ColumnMetadata;
|
|
348
|
+
constructor(typeBuilder: TypeBuilder<Type, SpacetimeType>, metadata?: ColumnMetadata);
|
|
349
|
+
}
|
|
350
|
+
export declare class U8ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.U8, M> implements Indexable<number, AlgebraicTypeVariants.U8>, Uniqueable<number, AlgebraicTypeVariants.U8>, PrimaryKeyable<number, AlgebraicTypeVariants.U8>, AutoIncrementable<number, AlgebraicTypeVariants.U8> {
|
|
351
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U8ColumnBuilder<Set<M, 'indexType', N>>;
|
|
352
|
+
unique(): U8ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
353
|
+
primaryKey(): U8ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
354
|
+
autoInc(): U8ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
355
|
+
}
|
|
356
|
+
export declare class U16ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.U16, M> implements Indexable<number, AlgebraicTypeVariants.U16>, Uniqueable<number, AlgebraicTypeVariants.U16>, PrimaryKeyable<number, AlgebraicTypeVariants.U16>, AutoIncrementable<number, AlgebraicTypeVariants.U16> {
|
|
357
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U16ColumnBuilder<Set<M, 'indexType', N>>;
|
|
358
|
+
unique(): U16ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
359
|
+
primaryKey(): U16ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
360
|
+
autoInc(): U16ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
361
|
+
}
|
|
362
|
+
export declare class U32ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.U32, M> implements Indexable<number, AlgebraicTypeVariants.U32>, Uniqueable<number, AlgebraicTypeVariants.U32>, PrimaryKeyable<number, AlgebraicTypeVariants.U32>, AutoIncrementable<number, AlgebraicTypeVariants.U32> {
|
|
363
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U32ColumnBuilder<Set<M, 'indexType', N>>;
|
|
364
|
+
unique(): U32ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
365
|
+
primaryKey(): U32ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
366
|
+
autoInc(): U32ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
367
|
+
}
|
|
368
|
+
export declare class U64ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.U64, M> implements Indexable<bigint, AlgebraicTypeVariants.U64>, Uniqueable<bigint, AlgebraicTypeVariants.U64>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U64>, AutoIncrementable<bigint, AlgebraicTypeVariants.U64> {
|
|
369
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U64ColumnBuilder<Set<M, 'indexType', N>>;
|
|
370
|
+
unique(): U64ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
371
|
+
primaryKey(): U64ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
372
|
+
autoInc(): U64ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
373
|
+
}
|
|
374
|
+
export declare class U128ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.U128, M> implements Indexable<bigint, AlgebraicTypeVariants.U128>, Uniqueable<bigint, AlgebraicTypeVariants.U128>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U128>, AutoIncrementable<bigint, AlgebraicTypeVariants.U128> {
|
|
375
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U128ColumnBuilder<Set<M, 'indexType', N>>;
|
|
376
|
+
unique(): U128ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
377
|
+
primaryKey(): U128ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
378
|
+
autoInc(): U128ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
379
|
+
}
|
|
380
|
+
export declare class U256ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.U256, M> implements Indexable<bigint, AlgebraicTypeVariants.U256>, Uniqueable<bigint, AlgebraicTypeVariants.U256>, PrimaryKeyable<bigint, AlgebraicTypeVariants.U256>, AutoIncrementable<bigint, AlgebraicTypeVariants.U256> {
|
|
381
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): U256ColumnBuilder<Set<M, 'indexType', N>>;
|
|
382
|
+
unique(): U256ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
383
|
+
primaryKey(): U256ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
384
|
+
autoInc(): U256ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
385
|
+
}
|
|
386
|
+
export declare class I8ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.I8, M> implements Indexable<number, AlgebraicTypeVariants.I8>, Uniqueable<number, AlgebraicTypeVariants.I8>, PrimaryKeyable<number, AlgebraicTypeVariants.I8>, AutoIncrementable<number, AlgebraicTypeVariants.I8> {
|
|
387
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I8ColumnBuilder<Set<M, 'indexType', N>>;
|
|
388
|
+
unique(): I8ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
389
|
+
primaryKey(): I8ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
390
|
+
autoInc(): I8ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
391
|
+
}
|
|
392
|
+
export declare class I16ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.I16, M> implements Indexable<number, AlgebraicTypeVariants.I16>, Uniqueable<number, AlgebraicTypeVariants.I16>, PrimaryKeyable<number, AlgebraicTypeVariants.I16>, AutoIncrementable<number, AlgebraicTypeVariants.I16> {
|
|
393
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I16ColumnBuilder<Set<M, 'indexType', N>>;
|
|
394
|
+
unique(): I16ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
395
|
+
primaryKey(): I16ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
396
|
+
autoInc(): I16ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
397
|
+
}
|
|
398
|
+
export declare class I32ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.I32, M> implements Indexable<number, AlgebraicTypeVariants.I32>, Uniqueable<number, AlgebraicTypeVariants.I32>, PrimaryKeyable<number, AlgebraicTypeVariants.I32>, AutoIncrementable<number, AlgebraicTypeVariants.I32> {
|
|
399
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I32ColumnBuilder<Set<M, 'indexType', N>>;
|
|
400
|
+
unique(): I32ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
401
|
+
primaryKey(): I32ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
402
|
+
autoInc(): I32ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
403
|
+
}
|
|
404
|
+
export declare class I64ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.I64, M> implements Indexable<bigint, AlgebraicTypeVariants.I64>, Uniqueable<bigint, AlgebraicTypeVariants.I64>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I64>, AutoIncrementable<bigint, AlgebraicTypeVariants.I64> {
|
|
405
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I64ColumnBuilder<Set<M, 'indexType', N>>;
|
|
406
|
+
unique(): I64ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
407
|
+
primaryKey(): I64ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
408
|
+
autoInc(): I64ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
409
|
+
}
|
|
410
|
+
export declare class I128ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.I128, M> implements Indexable<bigint, AlgebraicTypeVariants.I128>, Uniqueable<bigint, AlgebraicTypeVariants.I128>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I128>, AutoIncrementable<bigint, AlgebraicTypeVariants.I128> {
|
|
411
|
+
index<M extends ColumnMetadata = DefaultMetadata, N extends IndexTypes = 'btree'>(algorithm?: N): I128ColumnBuilder<Set<M, 'indexType', N>>;
|
|
412
|
+
unique(): I128ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
413
|
+
primaryKey(): I128ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
414
|
+
autoInc(): I128ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
415
|
+
}
|
|
416
|
+
export declare class I256ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<bigint, AlgebraicTypeVariants.I256, M> implements Indexable<bigint, AlgebraicTypeVariants.I256>, Uniqueable<bigint, AlgebraicTypeVariants.I256>, PrimaryKeyable<bigint, AlgebraicTypeVariants.I256>, AutoIncrementable<bigint, AlgebraicTypeVariants.I256> {
|
|
417
|
+
index<N extends IndexTypes = 'btree'>(algorithm?: N): I256ColumnBuilder<Set<M, 'indexType', N>>;
|
|
418
|
+
unique(): I256ColumnBuilder<Set<M, 'isUnique', true>>;
|
|
419
|
+
primaryKey(): I256ColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
420
|
+
autoInc(): I256ColumnBuilder<Set<M, 'isAutoIncrement', true>>;
|
|
421
|
+
}
|
|
422
|
+
export declare class F32ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.F32, M> {
|
|
423
|
+
}
|
|
424
|
+
export declare class F64ColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<number, AlgebraicTypeVariants.F64, M> {
|
|
425
|
+
}
|
|
426
|
+
export declare class BoolColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<boolean, AlgebraicTypeVariants.Bool, M> implements Indexable<boolean, AlgebraicTypeVariants.Bool>, Uniqueable<boolean, AlgebraicTypeVariants.Bool>, PrimaryKeyable<boolean, AlgebraicTypeVariants.Bool> {
|
|
427
|
+
index<M extends ColumnMetadata = DefaultMetadata, N extends IndexTypes = 'btree'>(algorithm?: N): BoolColumnBuilder<Set<M, 'indexType', N>>;
|
|
428
|
+
unique(): BoolColumnBuilder<Set<M, 'isUnique', true>>;
|
|
429
|
+
primaryKey(): BoolColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
430
|
+
}
|
|
431
|
+
export declare class StringColumnBuilder<M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<string, AlgebraicTypeVariants.String, M> implements Indexable<string, AlgebraicTypeVariants.String>, Uniqueable<string, AlgebraicTypeVariants.String>, PrimaryKeyable<string, AlgebraicTypeVariants.String> {
|
|
432
|
+
index<M extends ColumnMetadata = DefaultMetadata, N extends IndexTypes = 'btree'>(algorithm?: N): StringColumnBuilder<Set<M, 'indexType', N>>;
|
|
433
|
+
unique(): StringColumnBuilder<Set<M, 'isUnique', true>>;
|
|
434
|
+
primaryKey(): StringColumnBuilder<Set<M, 'isPrimaryKey', true>>;
|
|
435
|
+
}
|
|
436
|
+
export declare class ArrayColumnBuilder<Element extends TypeBuilder<any, any>, M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<Array<Element['type']>, {
|
|
437
|
+
tag: 'Array';
|
|
438
|
+
value: Element['spacetimeType'];
|
|
439
|
+
}, M> {
|
|
440
|
+
}
|
|
441
|
+
export declare class ProductColumnBuilder<Elements extends Array<{
|
|
442
|
+
name: string;
|
|
443
|
+
algebraicType: AlgebraicType;
|
|
444
|
+
}>, M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<{
|
|
445
|
+
[K in Elements[number]['name']]: any;
|
|
446
|
+
}, {
|
|
447
|
+
tag: 'Product';
|
|
448
|
+
value: {
|
|
449
|
+
elements: Elements;
|
|
450
|
+
};
|
|
451
|
+
}, M> {
|
|
452
|
+
}
|
|
453
|
+
export declare class SumColumnBuilder<Variants extends Array<{
|
|
454
|
+
name: string;
|
|
455
|
+
algebraicType: AlgebraicType;
|
|
456
|
+
}>, M extends ColumnMetadata = DefaultMetadata> extends ColumnBuilder<{
|
|
457
|
+
[K in Variants[number]['name']]: {
|
|
458
|
+
tag: K;
|
|
459
|
+
value: any;
|
|
460
|
+
};
|
|
461
|
+
}[Variants[number]['name']], {
|
|
462
|
+
tag: 'Sum';
|
|
463
|
+
value: {
|
|
464
|
+
variants: Variants;
|
|
465
|
+
};
|
|
466
|
+
}, M> {
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* A collection of factory functions for creating various SpacetimeDB algebraic types
|
|
470
|
+
* to be used in table definitions. Each function returns a corresponding builder
|
|
471
|
+
* for a specific type, such as `BoolBuilder`, `StringBuilder`, or `F64Builder`.
|
|
472
|
+
*
|
|
473
|
+
* These builders are used to define the schema of tables in SpacetimeDB, and each
|
|
474
|
+
* builder implements the {@link TypeBuilder} interface, allowing for type-safe
|
|
475
|
+
* schema construction in TypeScript.
|
|
476
|
+
*
|
|
477
|
+
* @remarks
|
|
478
|
+
* - Primitive types (e.g., `bool`, `string`, `number`) map to their respective TypeScript types.
|
|
479
|
+
* - Integer and floating-point types (e.g., `i8`, `u64`, `f32`) are represented as `number` or `bigint` in TypeScript.
|
|
480
|
+
* - Complex types such as `object`, `array`, and `enum` allow for nested and structured schemas.
|
|
481
|
+
* - The `scheduleAt` builder is a special column type for scheduling.
|
|
482
|
+
*
|
|
483
|
+
* @see {@link TypeBuilder}
|
|
484
|
+
*/
|
|
485
|
+
declare const t: {
|
|
486
|
+
/**
|
|
487
|
+
* Creates a new `Bool` {@link AlgebraicType} to be used in table definitions
|
|
488
|
+
* Represented as `boolean` in TypeScript.
|
|
489
|
+
* @returns A new {@link BoolBuilder} instance
|
|
490
|
+
*/
|
|
491
|
+
readonly bool: () => BoolBuilder;
|
|
492
|
+
/**
|
|
493
|
+
* Creates a new `String` {@link AlgebraicType} to be used in table definitions
|
|
494
|
+
* Represented as `string` in TypeScript.
|
|
495
|
+
* @returns A new {@link StringBuilder} instance
|
|
496
|
+
*/
|
|
497
|
+
readonly string: () => StringBuilder;
|
|
498
|
+
/**
|
|
499
|
+
* Creates a new `F64` {@link AlgebraicType} to be used in table definitions
|
|
500
|
+
* Represented as `number` in TypeScript.
|
|
501
|
+
* @returns A new {@link F64Builder} instance
|
|
502
|
+
*/
|
|
503
|
+
readonly number: () => F64Builder;
|
|
504
|
+
/**
|
|
505
|
+
* Creates a new `I8` {@link AlgebraicType} to be used in table definitions
|
|
506
|
+
* Represented as `number` in TypeScript.
|
|
507
|
+
* @returns A new {@link I8Builder} instance
|
|
508
|
+
*/
|
|
509
|
+
readonly i8: () => I8Builder;
|
|
510
|
+
/**
|
|
511
|
+
* Creates a new `U8` {@link AlgebraicType} to be used in table definitions
|
|
512
|
+
* Represented as `number` in TypeScript.
|
|
513
|
+
* @returns A new {@link U8Builder} instance
|
|
514
|
+
*/
|
|
515
|
+
readonly u8: () => U8Builder;
|
|
516
|
+
/**
|
|
517
|
+
* Creates a new `I16` {@link AlgebraicType} to be used in table definitions
|
|
518
|
+
* Represented as `number` in TypeScript.
|
|
519
|
+
* @returns A new {@link I16Builder} instance
|
|
520
|
+
*/
|
|
521
|
+
readonly i16: () => I16Builder;
|
|
522
|
+
/**
|
|
523
|
+
* Creates a new `U16` {@link AlgebraicType} to be used in table definitions
|
|
524
|
+
* Represented as `number` in TypeScript.
|
|
525
|
+
* @returns A new {@link U16Builder} instance
|
|
526
|
+
*/
|
|
527
|
+
readonly u16: () => U16Builder;
|
|
528
|
+
/**
|
|
529
|
+
* Creates a new `I32` {@link AlgebraicType} to be used in table definitions
|
|
530
|
+
* Represented as `number` in TypeScript.
|
|
531
|
+
* @returns A new {@link I32Builder} instance
|
|
532
|
+
*/
|
|
533
|
+
readonly i32: () => I32Builder;
|
|
534
|
+
/**
|
|
535
|
+
* Creates a new `U32` {@link AlgebraicType} to be used in table definitions
|
|
536
|
+
* Represented as `number` in TypeScript.
|
|
537
|
+
* @returns A new {@link U32Builder} instance
|
|
538
|
+
*/
|
|
539
|
+
readonly u32: () => U32Builder;
|
|
540
|
+
/**
|
|
541
|
+
* Creates a new `I64` {@link AlgebraicType} to be used in table definitions
|
|
542
|
+
* Represented as `bigint` in TypeScript.
|
|
543
|
+
* @returns A new {@link I64Builder} instance
|
|
544
|
+
*/
|
|
545
|
+
readonly i64: () => I64Builder;
|
|
546
|
+
/**
|
|
547
|
+
* Creates a new `U64` {@link AlgebraicType} to be used in table definitions
|
|
548
|
+
* Represented as `bigint` in TypeScript.
|
|
549
|
+
* @returns A new {@link U64Builder} instance
|
|
550
|
+
*/
|
|
551
|
+
readonly u64: () => U64Builder;
|
|
552
|
+
/**
|
|
553
|
+
* Creates a new `I128` {@link AlgebraicType} to be used in table definitions
|
|
554
|
+
* Represented as `bigint` in TypeScript.
|
|
555
|
+
* @returns A new {@link I128Builder} instance
|
|
556
|
+
*/
|
|
557
|
+
readonly i128: () => I128Builder;
|
|
558
|
+
/**
|
|
559
|
+
* Creates a new `U128` {@link AlgebraicType} to be used in table definitions
|
|
560
|
+
* Represented as `bigint` in TypeScript.
|
|
561
|
+
* @returns A new {@link U128Builder} instance
|
|
562
|
+
*/
|
|
563
|
+
readonly u128: () => U128Builder;
|
|
564
|
+
/**
|
|
565
|
+
* Creates a new `I256` {@link AlgebraicType} to be used in table definitions
|
|
566
|
+
* Represented as `bigint` in TypeScript.
|
|
567
|
+
* @returns A new {@link I256Builder} instance
|
|
568
|
+
*/
|
|
569
|
+
readonly i256: () => I256Builder;
|
|
570
|
+
/**
|
|
571
|
+
* Creates a new `U256` {@link AlgebraicType} to be used in table definitions
|
|
572
|
+
* Represented as `bigint` in TypeScript.
|
|
573
|
+
* @returns A new {@link U256Builder} instance
|
|
574
|
+
*/
|
|
575
|
+
readonly u256: () => U256Builder;
|
|
576
|
+
/**
|
|
577
|
+
* Creates a new `F32` {@link AlgebraicType} to be used in table definitions
|
|
578
|
+
* Represented as `number` in TypeScript.
|
|
579
|
+
* @returns A new {@link F32Builder} instance
|
|
580
|
+
*/
|
|
581
|
+
readonly f32: () => F32Builder;
|
|
582
|
+
/**
|
|
583
|
+
* Creates a new `F64` {@link AlgebraicType} to be used in table definitions
|
|
584
|
+
* Represented as `number` in TypeScript.
|
|
585
|
+
* @returns A new {@link F64Builder} instance
|
|
586
|
+
*/
|
|
587
|
+
readonly f64: () => F64Builder;
|
|
588
|
+
/**
|
|
589
|
+
* Creates a new `Product` {@link AlgebraicType} to be used in table definitions. Product types in SpacetimeDB
|
|
590
|
+
* are essentially the same as objects in JavaScript/TypeScript.
|
|
591
|
+
* Properties of the object must also be {@link TypeBuilder}s.
|
|
592
|
+
* Represented as an object with specific properties in TypeScript.
|
|
593
|
+
* @param obj The object defining the properties of the type, whose property
|
|
594
|
+
* values must be {@link TypeBuilder}s.
|
|
595
|
+
* @returns A new {@link ProductBuilder} instance
|
|
596
|
+
*/
|
|
597
|
+
readonly object: <Obj extends ElementsObj>(obj: Obj) => ProductBuilder<Obj>;
|
|
598
|
+
/**
|
|
599
|
+
* Creates a new `Array` {@link AlgebraicType} to be used in table definitions.
|
|
600
|
+
* Represented as an array in TypeScript.
|
|
601
|
+
* @param element The element type of the array, which must be a `TypeBuilder`.
|
|
602
|
+
* @returns A new {@link ArrayBuilder} instance
|
|
603
|
+
*/
|
|
604
|
+
readonly array: <Element extends TypeBuilder<any, any>>(e: Element) => ArrayBuilder<Element>;
|
|
605
|
+
/**
|
|
606
|
+
* Creates a new `Sum` {@link AlgebraicType} to be used in table definitions. Sum types in SpacetimeDB
|
|
607
|
+
* are similar to enums or unions in languages like Rust or TypeScript respectively.
|
|
608
|
+
* Each variant of the enum must be a {@link TypeBuilder}.
|
|
609
|
+
* Represented as a union of string literals in TypeScript.
|
|
610
|
+
* @param obj The object defining the variants of the enum, whose variant
|
|
611
|
+
* types must be `TypeBuilder`s.
|
|
612
|
+
* @returns A new {@link SumBuilder} instance
|
|
613
|
+
*/
|
|
614
|
+
readonly enum: <Obj extends VariantsObj>(obj: Obj) => SumBuilder<Obj>;
|
|
615
|
+
/**
|
|
616
|
+
* This is a special helper function for conveniently creating {@link ScheduleAt} type columns.
|
|
617
|
+
* @returns A new ColumnBuilder instance with the {@link ScheduleAt} type.
|
|
618
|
+
*/
|
|
619
|
+
readonly scheduleAt: () => ColumnBuilder<ScheduleAt, ReturnType<typeof ScheduleAt.getAlgebraicType>, Omit<ColumnMetadata, "isScheduleAt"> & {
|
|
620
|
+
isScheduleAt: true;
|
|
621
|
+
}>;
|
|
622
|
+
/**
|
|
623
|
+
* This is a convenience method for creating a column with the {@link Identity} type.
|
|
624
|
+
* You can create a column of the same type by constructing an `object` with a single `__identity__` element.
|
|
625
|
+
* @returns A new {@link TypeBuilder} instance with the {@link Identity} type.
|
|
626
|
+
*/
|
|
627
|
+
readonly identity: () => TypeBuilder<Identity, AlgebraicTypeVariants.Product & {
|
|
628
|
+
value: typeof Identity;
|
|
629
|
+
}>;
|
|
630
|
+
/**
|
|
631
|
+
* This is a convenience method for creating a column with the {@link ConnectionId} type.
|
|
632
|
+
* You can create a column of the same type by constructing an `object` with a single `__connection_id__` element.
|
|
633
|
+
* @returns A new {@link TypeBuilder} instance with the {@link ConnectionId} type.
|
|
634
|
+
*/
|
|
635
|
+
readonly connectionId: () => TypeBuilder<string, AlgebraicTypeVariants.Product & {
|
|
636
|
+
value: typeof ConnectionId;
|
|
637
|
+
}>;
|
|
638
|
+
/**
|
|
639
|
+
* This is a convenience method for creating a column with the {@link Timestamp} type.
|
|
640
|
+
* You can create a column of the same type by constructing an `object` with a single `__timestamp_micros_since_unix_epoch__` element.
|
|
641
|
+
* @returns A new {@link TypeBuilder} instance with the {@link Timestamp} type.
|
|
642
|
+
*/
|
|
643
|
+
readonly timestamp: () => TypeBuilder<Timestamp, AlgebraicTypeVariants.Product & {
|
|
644
|
+
value: typeof Timestamp;
|
|
645
|
+
}>;
|
|
646
|
+
/**
|
|
647
|
+
* This is a convenience method for creating a column with the {@link TimeDuration} type.
|
|
648
|
+
* You can create a column of the same type by constructing an `object` with a single `__time_duration_micros__` element.
|
|
649
|
+
* @returns A new {@link TypeBuilder} instance with the {@link TimeDuration} type.
|
|
650
|
+
*/
|
|
651
|
+
readonly timeDuration: () => TypeBuilder<TimeDuration, AlgebraicTypeVariants.Product & {
|
|
652
|
+
value: typeof TimeDuration;
|
|
653
|
+
}>;
|
|
654
|
+
};
|
|
655
|
+
export default t;
|
|
656
|
+
//# sourceMappingURL=type_builders.d.ts.map
|