import { type Knex } from "knex"; import { type DatabaseForeignKeys, type DatabaseSchemaExtend, type EntityIndex } from "../types/types"; import { type ColumnKeys, type ForeignKeyColumns, type IdType, type TableName } from "./puri.types"; /** * FK 타입 추론을 위해 DatabaseForeignKeys export * (module augmentation 자동 로드 보장) */ export type { DatabaseForeignKeys }; type InheritableColumns> = TTable extends keyof DatabaseSchemaExtend ? ColumnKeys : never; type TableData = { references: Set; rows: Record[]; uniqueIndexes: EntityIndex[]; uniquesMap: Map; jsonColumns: string[]; }; export type UBRef = { uuid: string; of: string; use?: string; }; export type UpsertOptions> = { chunkSize?: number; cleanOrphans?: ForeignKeyColumns | ForeignKeyColumns[]; inherit?: InheritableColumns[]; }; export type InsertOnlyOptions = { chunkSize?: number; }; export declare function isRefField(field: unknown): field is UBRef; export declare class UpsertBuilder { tables: Map; constructor(); getTable(tableName: string): TableData; hasTable(tableName: string): boolean; register(tableName: string, row: { [key in T]?: UBRef | string | number | boolean | bigint | null | object | unknown; }): UBRef; upsert>(wdb: Knex, tableName: TTable, options?: UpsertOptions): Promise[]>; insertOnly>(wdb: Knex, tableName: TTable, options?: InsertOnlyOptions): Promise[]>; upsertOrInsert>(wdb: Knex, tableName: TTable, mode: "upsert" | "insert", options?: UpsertOptions): Promise[]>; updateBatch(wdb: Knex, tableName: string, options?: { chunkSize?: number; where?: string | string[]; }): Promise; /** * rows를 의존성 순서에 따라 레벨별로 그룹화 * - 자기 참조 없는 경우 : 모든 rows가 Level 0 * - 자기 참조 있는 경우 : 자기 참조 관계를 위상 정렬하여 레벨별로 그룹화 */ private buildInsertLevels; } //# sourceMappingURL=upsert-builder.d.ts.map