import type { Scope } from '@n8n/permissions'; import type { FindOptionsWhere } from '@n8n/typeorm'; import { DataSource } from '@n8n/typeorm'; import type { QueryDeepPartialEntity } from '@n8n/typeorm/query-builder/QueryPartialEntity'; import { UserError } from 'n8n-workflow'; import { CredentialsEntity, type User } from '../entities'; import { BaseRepository } from './base-repository'; import { CredentialDependencyRepository, type CredentialDependencyFilter } from './credential-dependency.repository'; import { InstanceCredentialAssignmentRepository } from './instance-credential-assignment.repository'; import type { ICredentialsDb, ListQuery } from '../entities/types-db'; import type { OperationContext } from '../services/transaction'; import { TransactionRunner } from '../services/transaction'; export declare class CredentialIdConflictError extends UserError { constructor(); } type UpsertableCredentialContent = QueryDeepPartialEntity & Pick & { id?: string; }; export type CredentialSharingRelation = 'shared' | 'shared.project' | 'shared.project.projectRelations'; type CredentialsListQueryOptions = ListQuery.Options & { includeData?: boolean; includeGlobal?: boolean; user?: User; relations?: CredentialSharingRelation[]; }; export declare class CredentialsRepository extends BaseRepository { private readonly instanceCredentialAssignmentRepository; private readonly credentialDependencyRepository; constructor(dataSource: DataSource, instanceCredentialAssignmentRepository: InstanceCredentialAssignmentRepository, transactionRunner: TransactionRunner, credentialDependencyRepository: CredentialDependencyRepository); insertProjectCredentialWithOwner(credential: Pick & Partial>, projectId: string, externalSecretProviderIds: string[], ctx: OperationContext): Promise; findStartingWith(credentialName: string): Promise; findNonProjectCredentialsByIds(ids: string[]): Promise; findNamesByIds(ids: string[]): Promise>>; findExistingIds(ids: string[]): Promise; findGlobalProjectCredentialIds(ids: string[]): Promise; findPromotionBindingAccess(ids: string[], projectIds: string[]): Promise & { projectIds: string[]; }>>; hasResolvableCredential(ids: string[]): Promise; findDanglingProjectCredentials(): Promise; findInstanceCredentialById(credentialId: string, ctx: OperationContext): Promise; createContent(credential: CredentialsEntity, ctx: OperationContext): Promise; updateContent(id: string, content: QueryDeepPartialEntity, ctx: OperationContext): Promise; updateDataIfUnchanged(id: string, type: string, expectedData: string, data: string, ctx?: OperationContext): Promise; upsertImportedContent(content: UpsertableCredentialContent, ctx: OperationContext): Promise; saveInstanceCredential(credential: CredentialsEntity, ctx: OperationContext): Promise; updateInstanceCredential(credentialId: string, data: Pick, ctx: OperationContext): Promise; findProjectCredentialWithoutOwner(credentialId: string, ctx?: OperationContext): Promise; deleteInstanceCredentialIfUnassigned(credentialId: string, ctx?: OperationContext): Promise<{ status: 'deleted'; } | { status: 'notFound'; } | { status: 'assigned'; credentialUseIds: string[]; }>; findManyAndCount(listQueryOptions?: CredentialsListQueryOptions, credentialIds?: string[]): Promise<[CredentialsEntity[], number]>; private onlyProjectCredentials; excludePendingAuthorization(where: FindOptionsWhere): FindOptionsWhere; deleteExpiredPendingAuthorizations(now: Date): Promise; private toFindManyOptions; private handleSharedFilters; getManyByIds(ids: string[], { withSharings }?: { withSharings: boolean; }): Promise; findAllGlobalCredentials(options?: { includeData?: boolean; }): Promise; findAllPersonalCredentials(): Promise; findAllCredentialsForWorkflow(workflowId: string): Promise; findAllCredentialsForProject(projectId: string): Promise; findByNameAndTypeInProject(name: string, type: string, projectId: string): Promise; findByTypesInProject(types: string[], projectId: string): Promise; getManyAndCountWithSharingSubquery(user: User, sharingOptions: { scopes?: Scope[]; projectRoles?: string[]; credentialRoles?: string[]; isPersonalProject?: boolean; personalProjectOwnerId?: string; onlySharedWithMe?: boolean; }, options?: CredentialsListQueryOptions & { filters?: { dependency?: CredentialDependencyFilter; }; }): Promise<{ credentials: CredentialsEntity[]; count: number; }>; private getManyQueryWithSharingSubquery; } export {};