session.d.cts 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import type { ExecuteStatementCommandOutput, RDSDataClient } from '@aws-sdk/client-rds-data';
  2. import type { Cache } from "../../cache/core/cache.cjs";
  3. import type { WithCacheConfig } from "../../cache/core/types.cjs";
  4. import { entityKind } from "../../entity.cjs";
  5. import type { Logger } from "../../logger.cjs";
  6. import { type PgDialect, PgPreparedQuery, type PgQueryResultHKT, PgSession, PgTransaction, type PgTransactionConfig, type PreparedQueryConfig } from "../../pg-core/index.cjs";
  7. import type { SelectedFieldsOrdered } from "../../pg-core/query-builders/select.types.cjs";
  8. import type { RelationalSchemaConfig, TablesRelationalConfig } from "../../relations.cjs";
  9. import { type QueryTypingsValue, type QueryWithTypings, type SQL } from "../../sql/sql.cjs";
  10. export type AwsDataApiClient = RDSDataClient;
  11. export declare class AwsDataApiPreparedQuery<T extends PreparedQueryConfig & {
  12. values: AwsDataApiPgQueryResult<unknown[]>;
  13. }> extends PgPreparedQuery<T> {
  14. private client;
  15. private queryString;
  16. private params;
  17. private typings;
  18. private options;
  19. private fields;
  20. private _isResponseInArrayMode;
  21. private customResultMapper?;
  22. static readonly [entityKind]: string;
  23. private rawQuery;
  24. constructor(client: AwsDataApiClient, queryString: string, params: unknown[], typings: QueryTypingsValue[], options: AwsDataApiSessionOptions, cache: Cache, queryMetadata: {
  25. type: 'select' | 'update' | 'delete' | 'insert';
  26. tables: string[];
  27. } | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined,
  28. /** @internal */
  29. transactionId: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
  30. execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
  31. all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
  32. values(placeholderValues?: Record<string, unknown>): Promise<T['values']>;
  33. }
  34. export interface AwsDataApiSessionOptions {
  35. logger?: Logger;
  36. cache?: Cache;
  37. database: string;
  38. resourceArn: string;
  39. secretArn: string;
  40. }
  41. export declare class AwsDataApiSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
  42. private schema;
  43. private options;
  44. static readonly [entityKind]: string;
  45. private cache;
  46. constructor(
  47. /** @internal */
  48. client: AwsDataApiClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options: AwsDataApiSessionOptions,
  49. /** @internal */
  50. transactionId: string | undefined);
  51. prepareQuery<T extends PreparedQueryConfig & {
  52. values: AwsDataApiPgQueryResult<unknown[]>;
  53. } = PreparedQueryConfig & {
  54. values: AwsDataApiPgQueryResult<unknown[]>;
  55. }>(query: QueryWithTypings, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute'], queryMetadata?: {
  56. type: 'select' | 'update' | 'delete' | 'insert';
  57. tables: string[];
  58. }, cacheConfig?: WithCacheConfig, transactionId?: string): AwsDataApiPreparedQuery<T>;
  59. execute<T>(query: SQL): Promise<T>;
  60. transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
  61. }
  62. export declare class AwsDataApiTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<AwsDataApiPgQueryResultHKT, TFullSchema, TSchema> {
  63. static readonly [entityKind]: string;
  64. transaction<T>(transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
  65. }
  66. export type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & {
  67. rows: T[];
  68. };
  69. export interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {
  70. type: AwsDataApiPgQueryResult<any>;
  71. }