import { GlobalConfig } from '@n8n/config'; import type { Scope } from '@n8n/permissions'; import { DataSource } from '@n8n/typeorm'; import type { SelectQueryBuilder, UpdateResult, FindOptionsWhere, FindOptionsRelations, EntityManager } from '@n8n/typeorm'; import type { QueryDeepPartialEntity } from '@n8n/typeorm/query-builder/QueryPartialEntity'; import type { ActivityProjectScope } from './activity-event.repository'; import { BaseRepository } from './base-repository'; import { FolderRepository } from './folder.repository'; import { SharedWorkflowRepository } from './shared-workflow.repository'; import { WorkflowHistoryRepository } from './workflow-history.repository'; import { WorkflowEntity, User } from '../entities'; import type { ListQueryDb, FolderWithWorkflowAndSubFolderCount, ListQuery } from '../entities/types-db'; import { type OperationContext, TransactionRunner } from '../services/transaction'; export type WorkflowIdsQuery = { query: string; parameters: Record; }; type WorkflowListQueryOptions = ListQuery.Options & { workflowIdsIn?: WorkflowIdsQuery | null; }; type ResourceType = 'folder' | 'workflow'; type UpsertableWorkflowContent = QueryDeepPartialEntity & Pick & { id?: string; }; export type WorkflowFolderUnionFull = (ListQueryDb.Workflow.Plain | ListQueryDb.Workflow.WithSharing | FolderWithWorkflowAndSubFolderCount) & { resource: ResourceType; }; type WorkflowListResult = { workflows: ListQueryDb.Workflow.Plain[] | ListQueryDb.Workflow.WithSharing[]; count: number; }; export declare function agentToolReferenceWhere(projectId: string, workflowIds: string[], legacyWorkflowNames: string[]): Array>; export declare class WorkflowRepository extends BaseRepository { private readonly globalConfig; private readonly folderRepository; private readonly sharedWorkflowRepository; private readonly workflowHistoryRepository; constructor(dataSource: DataSource, globalConfig: GlobalConfig, folderRepository: FolderRepository, sharedWorkflowRepository: SharedWorkflowRepository, workflowHistoryRepository: WorkflowHistoryRepository, transactionRunner: TransactionRunner); findRecentForProjects(projectIds: ActivityProjectScope, limit: number, options?: { mcpVisibleOnly?: boolean; }): Promise<{ total: number; workflows: Array<{ id: string; name: string; active: boolean; }>; }>; findMcpAvailabilityByIds(workflowIds: string[]): Promise>; get(where: FindOptionsWhere, options?: { relations: string[] | FindOptionsRelations; }, ctx?: OperationContext): Promise; findArchivedState(workflowId: string, ctx?: OperationContext): Promise<{ isArchived: boolean; } | null>; getAllActiveIds(): Promise; getActiveIds({ maxResults }?: { maxResults?: number; }): Promise; getActiveCount(): Promise; getWorkflowInfo({ activeOnly, }: { activeOnly: boolean; }): Promise>; getPublishedCount(): Promise; getPublishedPersonalWorkflowsCount(): Promise; hasAnyWorkflowsWithErrorWorkflow(): Promise; updateContent(id: string, content: QueryDeepPartialEntity, ctx: OperationContext): Promise; createWorkflowWithOwner(workflow: WorkflowEntity, projectId: string, ctx?: OperationContext): Promise; createContent(workflow: WorkflowEntity, ctx: OperationContext): Promise; upsertImportedContent(content: UpsertableWorkflowContent, ctx: OperationContext): Promise; findByCredentialResolverId(resolverId: string): Promise>>; findActiveByCredentialResolverId(resolverId: string): Promise; private addCredentialResolverFilter; clearCredentialResolverId(resolverId: string, trx?: EntityManager): Promise; removeFromCallerAllowlists(workflowIds: string[], ctx: OperationContext): Promise; removeMissingFromCallerAllowlists(ctx: OperationContext): Promise; private purgeCallerAllowlists; private callerIdEntries; private callerIdsWithout; private findCallerAllowlistCandidates; private lockCallerAllowlists; private writeCallerIds; findById(workflowId: string): Promise; findByIdInContext(workflowId: string, ctx: OperationContext): Promise; findForContentUpdate(workflowId: string, ctx: OperationContext): Promise; findByIds(workflowIds: string[], { fields }?: { fields?: string[]; }): Promise; findManyByAgentToolReferences(projectId: string, workflowIds: string[], legacyWorkflowNames: string[]): Promise; findOneByAgentToolReference(projectId: string, reference: { workflowId?: string; workflowName: string; }, options?: { withActiveVersion?: boolean; }): Promise; getIdsAfter(afterId: string | undefined, take: number): Promise; findExistingIds(workflowIds: string[], ctx?: OperationContext): Promise; findPreExistingWorkflows(workflowIds: string[]): Promise; getActiveTriggerCount(): Promise; updateWorkflowTriggerCount(id: string, triggerCount: number): Promise; getWorkflowsWithEvaluationCount(): Promise; private buildBaseUnionQuery; getWorkflowsAndFoldersUnion(workflowIds: string[], options?: WorkflowListQueryOptions, accessibleProjectIds?: string[]): Promise<{ id: string; name: string; resource: ResourceType; createdAt: Date; updatedAt: Date; }[]>; private buildUnionQuery; private applySortingToUnionQuery; private applyPaginationToUnionQuery; private removeNameLowerFromResults; getWorkflowsAndFoldersCount(workflowIds: string[], options?: WorkflowListQueryOptions, accessibleProjectIds?: string[]): Promise; getWorkflowsAndFoldersWithCount(workflowIds: string[], options?: WorkflowListQueryOptions, accessibleProjectIds?: string[]): Promise; getWorkflowsAndFoldersWithCountWithSharingSubquery(user: User, sharingOptions: { scopes?: Scope[]; projectRoles?: string[]; workflowRoles?: string[]; isPersonalProject?: boolean; personalProjectOwnerId?: string; onlySharedWithMe?: boolean; }, options?: WorkflowListQueryOptions): Promise; private getWorkflowsAndFoldersUnionWithSharingSubquery; private getWorkflowsAndFoldersCountWithSharingSubquery; private buildBaseUnionQueryWithSharingSubquery; getAllWorkflowIdsInHierarchy(folderId: string, projectId: string): Promise; private getFolderIds; private getWorkflowsIds; private fetchExtraData; private enrichDataWithExtras; getMany(workflowIds: string[], options?: WorkflowListQueryOptions): Promise; getManyAndCount(sharedWorkflowIds: string[], options?: WorkflowListQueryOptions): Promise; getManyAndCountWithSharingSubquery(user: User, sharingOptions: { scopes?: Scope[]; projectRoles?: string[]; workflowRoles?: string[]; isPersonalProject?: boolean; personalProjectOwnerId?: string; onlySharedWithMe?: boolean; }, options?: WorkflowListQueryOptions): Promise; private getManyQueryWithSharingSubquery; findCallableSubworkflows(user: User, sharingOptions: { scopes: Scope[]; projectRoles: string[]; workflowRoles: string[]; }, parentWorkflowId: string, options: { query?: string; triggerNodeTypes: string[]; skip: number; take: number; }): Promise<{ workflows: WorkflowEntity[]; count: number; }>; private buildCallablePolicySubquery; private settingsTextValue; private buildSharedWorkflowIdsSubquery; getManyQuery(workflowIds: string[], options?: WorkflowListQueryOptions): SelectQueryBuilder; private createBaseQuery; private applyFilters; private applyIdsFilter; private applyAvailableInMCPFilter; private applyTriggerNodeTypesFilter; private parseSearchWords; private getFieldConcatExpression; private buildSearchConditions; private applyNameFilter; private applyParentFolderFilter; private applyActiveFilter; private applyIsArchivedFilter; private applyTagsFilter; private applyProjectFilter; private applyNodeTypesFilter; private buildWorkflowIdsByNodeTypesSubQuery; private applyWorkflowIdsInFilter; private applyOwnedByRelation; private applySelect; private applyRelations; private applyActiveVersionRelation; private applyTagsRelation; private applySorting; private applySortingByColumn; private applyPagination; findStartingWith(workflowName: string): Promise>; findIn(workflowIds: string[]): Promise; findWebhookBasedActiveWorkflows(): Promise<{ id: string; name: string; }[]>; updateActiveState(workflowId: string, newState: boolean): Promise; publishVersion(workflowId: string, versionId?: string): Promise; unpublishAll(): Promise; findByActiveState(activeState: boolean): Promise; moveAllToFolder(fromFolderId: string, toFolderId: string, tx: EntityManager): Promise; moveToFolder(workflowIds: string[], toFolderId: string): Promise; findWorkflowsWithNodeType(nodeTypes: string[], includeNodes?: boolean): Promise<(Pick & Partial>)[]>; findWorkflowsNeedingIndexing(batchSize?: number): Promise; findWorkflowsNeedingPublishedVersionIndexing(batchSize?: number): Promise; isActive(workflowId: string): Promise; } export {};