import { AlgebraicType, type AlgebraicTypeType } from './algebraic_type.ts'; import type { CaseConversionPolicy, RawSubmoduleV10, RawModuleDefV10, RawModuleDefV10Section, RawScopedTypeNameV10, RawTableDefV10 } from './autogen/types.ts'; import type { UntypedIndex } from './indexes.ts'; import type { UntypedTableDef } from './table.ts'; import type { OutboxMetadata, UntypedTableSchema } from './table_schema.ts'; import { ProductBuilder, RefBuilder, RowBuilder, SumBuilder, TypeBuilder, type Infer, type InferSpacetimeTypeOfTypeBuilder } from './type_builders.ts'; import type { Values } from './type_util.ts'; export type TableNamesOf = Values['accessorName']; /** * An untyped representation of the database schema. */ export type UntypedSchemaDef = { tables: Record; namespaces?: Record; }; /** * Helper type to convert an array of TableSchema into a schema definition */ export interface TablesToSchema> extends UntypedSchemaDef { tables: { readonly [AccName in keyof T & string]: TableToSchema; }; } export interface TableToSchema extends UntypedTableDef { accessorName: AccName; isOutbox: T['outbox'] extends OutboxMetadata ? true : false; columns: T['rowType']['row']; rowType: T['rowSpacetimeType']; indexes: T['idxs']; resolvedIndexes: readonly UntypedIndex[]; constraints: T['constraints']; } export declare function tablesToSchema>(ctx: ModuleContext, tables: T): TablesToSchema; export declare function tableToSchema(accName: AccName, schema: T, tableDef: RawTableDefV10): TableToSchema; export type ModuleDef = { [S in RawModuleDefV10Section as Uncapitalize]: S['value']; }; export declare class ModuleContext { #private; get moduleDef(): ModuleDef; rawModuleDefV10(): RawModuleDefV10; addSubmodule(submodule: RawSubmoduleV10): void; /** * Set the case conversion policy for this module. * Called by the settings mechanism. */ setCaseConversionPolicy(policy: CaseConversionPolicy): void; get typespace(): { readonly types: ({ tag: "Ref"; value: number; } | { tag: "Sum"; value: import("./algebraic_type.ts").SumTypeType; } | { tag: "Product"; value: import("./algebraic_type.ts").ProductTypeType; } | { tag: "Array"; value: AlgebraicTypeType; } | { tag: "String"; } | { tag: "Bool"; } | { tag: "I8"; } | { tag: "U8"; } | { tag: "I16"; } | { tag: "U16"; } | { tag: "I32"; } | { tag: "U32"; } | { tag: "I64"; } | { tag: "U64"; } | { tag: "I128"; } | { tag: "U128"; } | { tag: "I256"; } | { tag: "U256"; } | { tag: "F32"; } | { tag: "F64"; })[]; }; /** * Resolves the actual type of a TypeBuilder by following its references until it reaches a non-ref type. * @param typespace The typespace to resolve types against. * @param typeBuilder The TypeBuilder to resolve. * @returns The resolved algebraic type. */ resolveType(typeBuilder: RefBuilder): AT; /** * Adds a type to the module definition's typespace as a `Ref` if it is a named compound type (Product or Sum). * Otherwise, returns the type as is. * @param name * @param ty * @returns */ registerTypesRecursively>(typeBuilder: T): T extends SumBuilder | ProductBuilder | RowBuilder ? RefBuilder, InferSpacetimeTypeOfTypeBuilder> : T; } export declare function splitName(name: string): RawScopedTypeNameV10; //# sourceMappingURL=schema.d.ts.map