AK-21/Graphite-Industrial-Intelligence
0
1import type { BatchItem } from "../batch.cjs";2import { type Cache } from "../cache/core/index.cjs";3import type { WithCacheConfig } from "../cache/core/types.cjs";4import { entityKind } from "../entity.cjs";5import type { Logger } from "../logger.cjs";6import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";7import { type Query } from "../sql/sql.cjs";8import type { SQLiteAsyncDialect } from "../sqlite-core/dialect.cjs";9import { SQLiteTransaction } from "../sqlite-core/index.cjs";10import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.cjs";11import type { PreparedQueryConfig as PreparedQueryConfigBase, SQLiteExecuteMethod, SQLiteTransactionConfig } from "../sqlite-core/session.cjs";12import { SQLitePreparedQuery, SQLiteSession } from "../sqlite-core/session.cjs";13export interface SQLiteD1SessionOptions {14 logger?: Logger;15 cache?: Cache;16}17type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;18export declare class SQLiteD1Session<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'async', D1Result, TFullSchema, TSchema> {19 private client;20 private schema;21 private options;22 static readonly [entityKind]: string;23 private logger;24 private cache;25 constructor(client: D1Database, dialect: SQLiteAsyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLiteD1SessionOptions);26 prepareQuery(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown, queryMetadata?: {27 type: 'select' | 'update' | 'delete' | 'insert';28 tables: string[];29 }, cacheConfig?: WithCacheConfig): D1PreparedQuery;30 batch<T extends BatchItem<'sqlite'>[] | readonly BatchItem<'sqlite'>[]>(queries: T): Promise<unknown[]>;31 extractRawAllValueFromBatchResult(result: unknown): unknown;32 extractRawGetValueFromBatchResult(result: unknown): unknown;33 extractRawValuesValueFromBatchResult(result: unknown): unknown;34 transaction<T>(transaction: (tx: D1Transaction<TFullSchema, TSchema>) => T | Promise<T>, config?: SQLiteTransactionConfig): Promise<T>;35}36export declare class D1Transaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'async', D1Result, TFullSchema, TSchema> {37 static readonly [entityKind]: string;38 transaction<T>(transaction: (tx: D1Transaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;39}40export declare class D1PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{41 type: 'async';42 run: D1Response;43 all: T['all'];44 get: T['get'];45 values: T['values'];46 execute: T['execute'];47}> {48 private logger;49 private _isResponseInArrayMode;50 static readonly [entityKind]: string;51 constructor(stmt: D1PreparedStatement, query: Query, logger: Logger, cache: Cache, queryMetadata: {52 type: 'select' | 'update' | 'delete' | 'insert';53 tables: string[];54 } | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown);55 run(placeholderValues?: Record<string, unknown>): Promise<D1Response>;56 all(placeholderValues?: Record<string, unknown>): Promise<T['all']>;57 mapAllResult(rows: unknown, isFromBatch?: boolean): unknown;58 get(placeholderValues?: Record<string, unknown>): Promise<T['get']>;59 mapGetResult(result: unknown, isFromBatch?: boolean): unknown;60 values<T extends any[] = unknown[]>(placeholderValues?: Record<string, unknown>): Promise<T[]>;61}62export {};63 