import { TransactionalAsyncOptionsBase, TransactionalRootOptionsBase } from '@nestjs-transactions/core'; import { TypeOrmTransactionOptions } from '@nestjs-cls/transactional-adapter-typeorm'; import { InjectionToken, ModuleMetadata, Provider } from '@nestjs/common'; import type { TypeOrmDataSourceFactory, TypeOrmModuleOptions as NestTypeOrmModuleOptions } from '@nestjs/typeorm'; import { DataSource, DataSourceOptions } from 'typeorm'; /** How a TypeORM DataSource is referenced — same forms `@nestjs/typeorm` accepts. */ export type DataSourceRef = DataSource | DataSourceOptions | string; export interface TypeOrmTransactionalOptions extends TransactionalRootOptionsBase { /** * The DataSource this connection wraps, in any form accepted by * `getDataSourceToken()`. Defaults to `connectionName` when that is set * (convention: name the connection after the data source), otherwise to the * default DataSource. */ dataSource?: DataSourceRef; /** Default options merged into every transaction on this connection. */ defaultTxOptions?: Partial; /** Extra modules that export the DataSource token, if it is not globally available. */ imports?: ModuleMetadata['imports']; } export interface TypeOrmTransactionalAsyncFactoryResult { defaultTxOptions?: Partial; } /** * Async variant: `dataSource` (a DI token) and `connectionName` stay static; * the factory resolves `defaultTxOptions` at DI time (e.g. from ConfigService). */ export interface TypeOrmTransactionalAsyncOptions extends TransactionalAsyncOptionsBase { dataSource?: DataSourceRef; } /** * Options of the unified `NestjsTypeormModule.forRoot()`: everything * `@nestjs/typeorm`'s `forRoot` accepts (the module creates the DataSource), * plus the transactional options. `name` drives both the DataSource name and * the transactional connection name. */ export type NestjsTypeormRootOptions = NestTypeOrmModuleOptions & { /** Default options merged into every transaction on this connection. */ defaultTxOptions?: Partial; /** * Enables injecting the transaction instance directly with `@InjectTransaction()`. * * Default: `false` */ enableTransactionProxy?: boolean; }; /** * Async variant of {@link NestjsTypeormRootOptions}: the factory resolves the * combined options at DI time. `name` and `enableTransactionProxy` must be * static — DI tokens and the CLS plugin are registered at module-definition * time, so a `name` returned by the factory is ignored (replaced with the * static one). */ export interface NestjsTypeormRootAsyncOptions extends Pick { /** Name of the DataSource and transactional connection. Must be static. */ name?: string; /** See {@link NestjsTypeormRootOptions.enableTransactionProxy}. Must be static. */ enableTransactionProxy?: boolean; useFactory: (...args: any[]) => Promise | NestjsTypeormRootOptions; inject?: InjectionToken[]; /** Extra providers registered alongside the options factory. */ extraProviders?: Provider[]; /** Passed through to `@nestjs/typeorm` — custom DataSource instantiation. */ dataSourceFactory?: TypeOrmDataSourceFactory; } /** * Second argument of `forFeature`: a plain string sets both the connection * name and the data source name (the convention); the object form covers the * rare case where they differ. */ export type ForFeatureConnection = string | { connectionName?: string; dataSource?: DataSourceRef; }; /** * The single place the "connectionName and dataSource default to each other" * convention lives. Used by forRoot, forRootAsync, forFeature and the testing * module so all of them always resolve the same DataSource/TransactionHost pair. */ export declare function resolveConnection(connection?: ForFeatureConnection): { connectionName: string | undefined; dataSource: DataSourceRef | undefined; }; /** Map the literal 'default' name to `undefined` (the default connection). */ export declare function normalizeName(name: string | undefined): string | undefined; //# sourceMappingURL=interfaces.d.ts.map