import { z } from 'zod'; /** * Supported SpacetimeDB type kinds */ export type StdbTypeKind = 'bool' | 'i8' | 'u8' | 'i16' | 'u16' | 'i32' | 'u32' | 'i64' | 'u64' | 'i128' | 'u128' | 'f32' | 'f64' | 'string' | 'bytes' | 'identity' | 'timestamp' | 'array' | 'option' | 'object' | 'enum'; /** * Type metadata for serialization/deserialization */ export interface TypeMetadata { kind: StdbTypeKind; inner?: TypeMetadata; fields?: Record; variants?: Record; } /** * Serialized value with type information */ export interface TypedValue { type: StdbTypeKind; value: unknown; metadata?: TypeMetadata; } /** * Table schema information */ export interface TableSchema { name: string; columns: ColumnSchema[]; indexes: IndexSchema[]; primaryKey?: string; } export interface ColumnSchema { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; } export interface IndexSchema { name: string; columns: string[]; algorithm: 'btree' | 'hash'; unique: boolean; } /** * Reducer schema information */ export interface ReducerSchema { name: string; args: Record; } /** * Export format version */ export declare const EXPORT_VERSION = "1.0.0"; /** * Complete database export format */ export interface StdbExport { version: typeof EXPORT_VERSION; metadata: ExportMetadata; schema: SchemaMetadata; data: Record; } export interface ExportMetadata { exportedAt: string; databaseName: string; moduleVersion?: string; spacetimedbVersion?: string; totalRows: number; totalBytes: number; } export interface SchemaMetadata { tables: TableSchema[]; reducers: ReducerSchema[]; } export interface TableData { rows: TypedValue[][]; rowCount: number; sizeBytes: number; } /** * Progress callback for long-running operations */ export interface ProgressInfo { phase: 'connecting' | 'exporting' | 'importing' | 'finalizing'; table?: string; rowsProcessed: number; totalRows: number; bytesProcessed: number; totalBytes: number; percent: number; } export type ProgressCallback = (progress: ProgressInfo) => void; /** * Export options */ export interface ExportOptions { output: string; tables?: string[]; compress?: boolean; onProgress?: ProgressCallback; } /** * Import options */ export interface ImportOptions { input: string; validateOnly?: boolean; skipValidation?: boolean; onProgress?: ProgressCallback; onError?: (error: Error) => void; } /** * Validation result */ export interface ValidationResult { valid: boolean; errors: SchemaValidationError[]; warnings: ValidationWarning[]; } export interface SchemaValidationError { type: 'schema_mismatch' | 'missing_table' | 'incompatible_type' | 'constraint_violation'; message: string; table?: string; column?: string; } export interface ValidationWarning { type: 'version_mismatch' | 'performance' | 'data_loss'; message: string; } /** * Snapshot metadata (for in-database snapshots) */ export interface SnapshotMetadata { id: string; name: string; createdAt: number; schemaVersion: string; description: string; sizeBytes: number; tableCount: number; rowCount: number; } /** * Snapshot options */ export interface SnapshotCreateOptions { name: string; description?: string; tables?: string[]; } /** * Connection configuration */ export interface ConnectionConfig { uri: string; moduleName: string; authToken?: string; timeout?: number; } /** * Lifecycle SDK error types */ export declare class LifecycleError extends Error { readonly cause?: Error | undefined; constructor(message: string, cause?: Error | undefined); } export declare class ConnectionError extends LifecycleError { constructor(message: string, cause?: Error); } export declare class ExportError extends LifecycleError { constructor(message: string, cause?: Error); } export declare class ImportError extends LifecycleError { constructor(message: string, cause?: Error); } export declare class ValidationError extends LifecycleError { constructor(message: string, cause?: Error); } export declare class SnapshotError extends LifecycleError { constructor(message: string, cause?: Error); } /** * Zod schemas for runtime validation */ export declare const TypeMetadataSchema: z.ZodSchema; export declare const ColumnSchema: z.ZodObject<{ name: z.ZodString; type: z.ZodType; nullable: z.ZodBoolean; unique: z.ZodBoolean; autoInc: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }>; export declare const IndexSchema: z.ZodObject<{ name: z.ZodString; columns: z.ZodArray; algorithm: z.ZodEnum<["btree", "hash"]>; unique: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }>; export declare const TableSchema: z.ZodObject<{ name: z.ZodString; columns: z.ZodArray; nullable: z.ZodBoolean; unique: z.ZodBoolean; autoInc: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }>, "many">; indexes: z.ZodArray; algorithm: z.ZodEnum<["btree", "hash"]>; unique: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }>, "many">; primaryKey: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }>; export declare const ReducerSchema: z.ZodObject<{ name: z.ZodString; args: z.ZodRecord>; }, "strip", z.ZodTypeAny, { name: string; args: Record; }, { name: string; args: Record; }>; export declare const ExportMetadataSchema: z.ZodObject<{ exportedAt: z.ZodString; databaseName: z.ZodString; moduleVersion: z.ZodOptional; spacetimedbVersion: z.ZodOptional; totalRows: z.ZodNumber; totalBytes: z.ZodNumber; }, "strip", z.ZodTypeAny, { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }, { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }>; export declare const SchemaMetadataSchema: z.ZodObject<{ tables: z.ZodArray; nullable: z.ZodBoolean; unique: z.ZodBoolean; autoInc: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }>, "many">; indexes: z.ZodArray; algorithm: z.ZodEnum<["btree", "hash"]>; unique: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }>, "many">; primaryKey: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }>, "many">; reducers: z.ZodArray>; }, "strip", z.ZodTypeAny, { name: string; args: Record; }, { name: string; args: Record; }>, "many">; }, "strip", z.ZodTypeAny, { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }, { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }>; export declare const TableDataSchema: z.ZodObject<{ rows: z.ZodArray, "many">; rowCount: z.ZodNumber; sizeBytes: z.ZodNumber; }, "strip", z.ZodTypeAny, { rows: unknown[][]; rowCount: number; sizeBytes: number; }, { rows: unknown[][]; rowCount: number; sizeBytes: number; }>; export declare const StdbExportSchema: z.ZodObject<{ version: z.ZodLiteral<"1.0.0">; metadata: z.ZodObject<{ exportedAt: z.ZodString; databaseName: z.ZodString; moduleVersion: z.ZodOptional; spacetimedbVersion: z.ZodOptional; totalRows: z.ZodNumber; totalBytes: z.ZodNumber; }, "strip", z.ZodTypeAny, { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }, { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }>; schema: z.ZodObject<{ tables: z.ZodArray; nullable: z.ZodBoolean; unique: z.ZodBoolean; autoInc: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }, { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }>, "many">; indexes: z.ZodArray; algorithm: z.ZodEnum<["btree", "hash"]>; unique: z.ZodBoolean; }, "strip", z.ZodTypeAny, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }, { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }>, "many">; primaryKey: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }, { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }>, "many">; reducers: z.ZodArray>; }, "strip", z.ZodTypeAny, { name: string; args: Record; }, { name: string; args: Record; }>, "many">; }, "strip", z.ZodTypeAny, { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }, { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }>; data: z.ZodRecord, "many">; rowCount: z.ZodNumber; sizeBytes: z.ZodNumber; }, "strip", z.ZodTypeAny, { rows: unknown[][]; rowCount: number; sizeBytes: number; }, { rows: unknown[][]; rowCount: number; sizeBytes: number; }>>; }, "strip", z.ZodTypeAny, { data: Record; version: "1.0.0"; metadata: { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }; schema: { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }; }, { data: Record; version: "1.0.0"; metadata: { exportedAt: string; databaseName: string; totalRows: number; totalBytes: number; moduleVersion?: string | undefined; spacetimedbVersion?: string | undefined; }; schema: { tables: { name: string; columns: { name: string; type: TypeMetadata; nullable: boolean; unique: boolean; autoInc: boolean; }[]; indexes: { name: string; unique: boolean; columns: string[]; algorithm: "btree" | "hash"; }[]; primaryKey?: string | undefined; }[]; reducers: { name: string; args: Record; }[]; }; }>; //# sourceMappingURL=types.d.ts.map