import type { RawOutboxDefV10, RawScheduleDefV10, RawTableDefV10 } from './autogen/types.ts'; import type { IndexOpts } from './indexes.ts'; import type { ModuleContext } from './schema.ts'; import type { ColumnBuilder, RowBuilder } from './type_builders.ts'; import type { HasExactlyOneKnownKey } from './type_util.ts'; import type { ProcedureExport, ReducerExport } from '../server/index.ts'; /** * Internal erased form of a scheduled reducer/procedure export. * * The legacy `TableOpts.scheduled` option checks the scheduled function shape * before it reaches `TableSchema`. From here, schedule resolution only needs * the export object identity to look up its registered function name. */ export type UntypedScheduledFunctionExport = ReducerExport | ProcedureExport; export type TableSchedule = { scheduleAtCol: number; reducer: () => UntypedScheduledFunctionExport; }; /** Outbox metadata before table and callback names are resolved. */ export type OutboxMetadata = Omit; export type ScheduleTableForParams> = HasExactlyOneKnownKey extends true ? Params[keyof Params] extends RowBuilder>> ? TableSchema[]> : never : never; /** * Represents a handle to a database table, including its name, row type, and row spacetime type. */ export type TableSchema>, Idx extends readonly IndexOpts[], Outbox extends OutboxMetadata | undefined = OutboxMetadata | undefined> = { /** * The name of the table. */ readonly tableName?: string; /** * The outbox receiver and argument mapping, if this is an outbox table. * Schema registration supplies the table name and resolves the result callback. * Its presence marks an outbox, whose database handles expose only inserts * and reads; the table builder types it as `undefined` for ordinary tables. */ readonly outbox: Outbox; /** * The TypeBuilder representation of the type of the rows in the table. **/ readonly rowType: RowBuilder; /** * The {@link ProductType} representing the structure of a row in the table. */ readonly rowSpacetimeType: RowBuilder['algebraicType']['value']; /** * The {@link RawTableDefV10} of the configured table */ tableDef(ctx: ModuleContext, accName: string): RawTableDefV10 & { schedule?: RawScheduleDefV10; }; /** * The indexes defined on the table. */ readonly idxs: Idx; /** * The constraints defined on the table. */ readonly constraints: readonly { name: string | undefined; constraint: 'unique'; columns: [any]; }[]; /** * The column id of the schedule-at column, if this table has a ScheduleAt column. */ readonly scheduleAtCol?: number; /** * The legacy schedule defined on the table, if any. * * @deprecated Prefer `spacetime.reducer({ onSchedule: table }, ...)` or * `spacetime.procedure({ onSchedule: table }, ...)` so table definitions can * live in a separate module from reducer/procedure definitions. */ readonly schedule?: TableSchedule; }; export type UntypedTableSchema = TableSchema>, readonly IndexOpts[]>; //# sourceMappingURL=table_schema.d.ts.map