forge-sql-orm
Version:
Drizzle ORM integration for Forge-SQL in Atlassian Forge applications.
66 lines • 3.01 kB
TypeScript
import { AnyColumn } from "drizzle-orm";
import { AnyMySqlTable } from "drizzle-orm/mysql-core/index";
import { PrimaryKeyBuilder } from "drizzle-orm/mysql-core/primary-keys";
import { AnyIndexBuilder } from "drizzle-orm/mysql-core/indexes";
import { CheckBuilder } from "drizzle-orm/mysql-core/checks";
import { ForeignKeyBuilder } from "drizzle-orm/mysql-core/foreign-keys";
import { UniqueConstraintBuilder } from "drizzle-orm/mysql-core/unique-constraint";
import type { SelectedFields } from "drizzle-orm/mysql-core/query-builders/select.types";
/**
* Interface representing table metadata information
*/
export interface MetadataInfo {
/** The name of the table */
tableName: string;
/** Record of column names and their corresponding column definitions */
columns: Record<string, AnyColumn>;
/** Array of index builders */
indexes: AnyIndexBuilder[];
/** Array of check constraint builders */
checks: CheckBuilder[];
/** Array of foreign key builders */
foreignKeys: ForeignKeyBuilder[];
/** Array of primary key builders */
primaryKeys: PrimaryKeyBuilder[];
/** Array of unique constraint builders */
uniqueConstraints: UniqueConstraintBuilder[];
/** Array of all extra builders */
extras: any[];
}
/**
* Parses a date string into a Date object using the specified format
* @param value - The date string to parse
* @param format - The format to use for parsing
* @returns Date object
*/
export declare const parseDateTime: (value: string, format: string) => Date;
/**
* Gets primary keys from the schema.
* @template T - The type of the table schema
* @param {T} table - The table schema
* @returns {[string, AnyColumn][]} Array of primary key name and column pairs
*/
export declare function getPrimaryKeys<T extends AnyMySqlTable>(table: T): [string, AnyColumn][];
/**
* Extracts table metadata from the schema.
* @param {AnyMySqlTable} table - The table schema
* @returns {MetadataInfo} Object containing table metadata
*/
export declare function getTableMetadata(table: AnyMySqlTable): MetadataInfo;
/**
* Generates SQL statements to drop tables
* @param tables - Array of table names
* @returns Array of SQL statements for dropping tables
*/
export declare function generateDropTableStatements(tables: string[]): string[];
type AliasColumnMap = Record<string, AnyColumn>;
export declare function mapSelectAllFieldsToAlias(selections: any, name: string, uniqName: string, fields: any, aliasMap: AliasColumnMap): any;
export declare function mapSelectFieldsWithAlias<TSelection extends SelectedFields>(fields: TSelection): {
selections: TSelection;
aliasMap: AliasColumnMap;
};
export declare function applyFromDriverTransform<T, TSelection>(rows: T[], selections: TSelection, aliasMap: Record<string, AnyColumn>): T[];
export declare function formatLimitOffset(limitOrOffset: number): number;
export declare function nextVal(sequenceName: string): number;
export {};
//# sourceMappingURL=sqlUtils.d.ts.map