forge-sql-orm
Version:
Drizzle ORM integration for Forge-SQL in Atlassian Forge applications.
78 lines • 3.81 kB
TypeScript
import { CRUDForgeSQL, ForgeSqlOperation, ForgeSqlOrmOptions, SchemaAnalyzeForgeSql, SchemaSqlForgeSql } from "./ForgeSQLQueryBuilder";
import { MySqlRemoteDatabase, MySqlRemotePreparedQueryHKT } from "drizzle-orm/mysql-proxy";
import type { SelectedFields } from "drizzle-orm/mysql-core/query-builders/select.types";
import { MySqlSelectBuilder } from "drizzle-orm/mysql-core";
/**
* Public class that acts as a wrapper around the private ForgeSQLORMImpl.
* Provides a clean interface for working with Forge SQL and Drizzle ORM.
*/
declare class ForgeSQLORM implements ForgeSqlOperation {
private readonly ormInstance;
constructor(options?: ForgeSqlOrmOptions);
/**
* Creates a select query with unique field aliases to prevent field name collisions in joins.
* This is particularly useful when working with Atlassian Forge SQL, which collapses fields with the same name in joined tables.
*
* @template TSelection - The type of the selected fields
* @param {TSelection} fields - Object containing the fields to select, with table schemas as values
* @returns {MySqlSelectBuilder<TSelection, MySql2PreparedQueryHKT>} A select query builder with unique field aliases
* @throws {Error} If fields parameter is empty
* @example
* ```typescript
* await forgeSQL
* .select({user: users, order: orders})
* .from(orders)
* .innerJoin(users, eq(orders.userId, users.id));
* ```
*/
select<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
/**
* Creates a distinct select query with unique field aliases to prevent field name collisions in joins.
* This is particularly useful when working with Atlassian Forge SQL, which collapses fields with the same name in joined tables.
*
* @template TSelection - The type of the selected fields
* @param {TSelection} fields - Object containing the fields to select, with table schemas as values
* @returns {MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>} A distinct select query builder with unique field aliases
* @throws {Error} If fields parameter is empty
* @example
* ```typescript
* await forgeSQL
* .selectDistinct({user: users, order: orders})
* .from(orders)
* .innerJoin(users, eq(orders.userId, users.id));
* ```
*/
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): MySqlSelectBuilder<TSelection, MySqlRemotePreparedQueryHKT>;
/**
* Proxies the `crud` method from `ForgeSQLORMImpl`.
* @returns CRUD operations.
*/
crud(): CRUDForgeSQL;
/**
* Proxies the `modify` method from `ForgeSQLORMImpl`.
* @returns Modify operations.
*/
modify(): CRUDForgeSQL;
/**
* Proxies the `fetch` method from `ForgeSQLORMImpl`.
* @returns Fetch operations.
*/
fetch(): SchemaSqlForgeSql;
/**
* Provides query analysis capabilities including EXPLAIN ANALYZE and slow query analysis.
* @returns {SchemaAnalyzeForgeSql} Interface for analyzing query performance
*/
analyze(): SchemaAnalyzeForgeSql;
/**
* Returns a Drizzle query builder instance.
*
* ⚠️ IMPORTANT: This method should be used ONLY for query building purposes.
* The returned instance should NOT be used for direct database connections or query execution.
* All database operations should be performed through Forge SQL's executeRawSQL or executeRawUpdateSQL methods.
*
* @returns A Drizzle query builder instance for query construction only.
*/
getDrizzleQueryBuilder(): MySqlRemoteDatabase<Record<string, unknown>>;
}
export default ForgeSQLORM;
//# sourceMappingURL=ForgeSQLORM.d.ts.map