longcelot-sheet-db
Version:
Google Sheets-backed staging database adapter for Node.js with schema-first design
45 lines • 2.46 kB
TypeScript
import { TableSchema, FindOptions, UpdateOptions, DeleteOptions, CreateOptions, UpsertOptions, FKResolver } from '../../schema/types';
import type { TableOperations } from '../types';
import { SQLConnection } from './connection';
import { SQLDialect } from './dialect';
import { TenantScope } from './queryBuilder';
/**
* The SQL-backed equivalent of CRUDOperations (src/adapter/crud.ts) — same validation/defaults/
* FK/soft-delete/uniqueness/timestamps semantics (Phase 16.2 decision 2), but pushes
* where/orderBy/limit/offset/tenant-scoping/soft-delete into real SQL via queryBuilder.ts
* instead of Sheets' full-scan-then-filter-in-JS approach. Deliberately duplicates
* CRUDOperations' validation logic rather than sharing it yet — see TODO.md Phase 16.2.
*/
export declare class SQLTableOperations implements TableOperations {
private connection;
private dialect;
private schema;
private tenant;
private fkResolver?;
constructor(connection: SQLConnection, dialect: SQLDialect, schema: TableSchema, tenant: TenantScope | undefined, fkResolver?: FKResolver | undefined);
create(data: Record<string, unknown>, options?: CreateOptions): Promise<Record<string, unknown>>;
createMany(records: Record<string, unknown>[], options?: CreateOptions): Promise<Record<string, unknown>[]>;
findMany(options?: FindOptions): Promise<Record<string, unknown>[]>;
findOne(options?: FindOptions): Promise<Record<string, unknown> | null>;
update(options: UpdateOptions): Promise<number>;
upsert(options: UpsertOptions): Promise<Record<string, unknown>>;
count(options?: Pick<FindOptions, 'where' | 'includeDeleted'>): Promise<number>;
delete(options: DeleteOptions): Promise<number>;
private execute;
private validateAndApplyDefaults;
private validateForeignKeys;
private checkUniqueness;
private serializeRow;
private serializeValue;
/**
* MySQL's DATETIME/TIMESTAMP columns reject ISO 8601's 'T'/'Z' separators outright
* (ER_TRUNCATED_WRONG_VALUE) — found via real-MySQL integration testing (Phase 16.2). The
* space-separated 'YYYY-MM-DD HH:MM:SS.sss' form is accepted by both Postgres and MySQL, so
* every date value is normalized to it before being sent, regardless of target dialect.
*/
private toSQLDateTime;
private deserializeRow;
private tryParseJSON;
private cleanDateValue;
}
//# sourceMappingURL=sqlTableOperations.d.ts.map