import type { Scope } from '@n8n/permissions'; import type { FindOperator } from '@n8n/typeorm'; import type express from 'express'; import type { ICredentialsEncrypted, IRunExecutionData, IWorkflowBase, WorkflowExecuteMode, ExecutionStatus, FeatureFlagPayloads, FeatureFlags, IUserSettings, AnnotationVote, ExecutionSummary, IUser, IDataObject, IBinaryKeyData, IPairedItemData } from 'n8n-workflow'; import { z } from 'zod'; import type { OperationContext } from '../services/transaction'; import type { CredentialUsageScope, CredentialsEntity } from './credentials-entity'; import type { ExecutionDataStorageLocation } from './execution-entity'; import type { Folder } from './folder'; import type { Project } from './project'; import type { SharedCredentials } from './shared-credentials'; import type { SharedWorkflow } from './shared-workflow'; import type { TagEntity } from './tag-entity'; import type { User } from './user'; import type { WorkflowEntity } from './workflow-entity'; import type { WorkflowHistory } from './workflow-history'; export type UsageCount = { usageCount: number; }; export interface ITagBase { id: string; name: string; } export interface ICredentialsBase { createdAt: Date; updatedAt: Date; } export interface IExecutionBase { id: string; mode: WorkflowExecuteMode; createdAt: Date; startedAt: Date; stoppedAt?: Date; workflowId: string; finished: boolean; retryOf?: string; retrySuccessId?: string; status: ExecutionStatus; waitTill?: Date | null; storedAt: ExecutionDataStorageLocation; tracingContext?: { traceparent: string; tracestate?: string; identity?: Record; } | null; deletedAt?: Date | null; deduplicationKey?: string | null; jsonSizeBytes?: number; binaryDataSizeBytes?: number; workflowVersionId?: string | null; usedPrivateCredentials?: boolean; } export interface IPersonalizationSurveyAnswers { email: string | null; codingSkill: string | null; companyIndustry: string[]; companySize: string | null; otherCompanyIndustry: string | null; otherWorkArea: string | null; workArea: string[] | string | null; } export type ITagDb = Pick; export type ITagWithCountDb = ITagDb & UsageCount; export interface IWorkflowDb extends IWorkflowBase { triggerCount: number; tags?: TagEntity[]; parentFolder?: Folder | null; activeVersion?: WorkflowHistory | null; } export interface ICredentialsDb extends ICredentialsBase, ICredentialsEncrypted { id: string; name: string; description?: string | null; shared?: SharedCredentials[]; isGlobal?: boolean; isResolvable?: boolean; isManaged?: boolean; usageScope?: CredentialUsageScope; } export interface IExecutionResponse extends IExecutionBase { id: string; data: IRunExecutionData; retryOf?: string; retrySuccessId?: string; workflowData: IWorkflowBase | WorkflowWithSharingsAndCredentials; workflowVersionId?: string | null; customData: Record; annotation: { tags: ITagBase[]; }; dataTooLargeToDisplay?: boolean; } export interface PublicUser { id: string; email?: string; firstName?: string; lastName?: string; personalizationAnswers?: IPersonalizationSurveyAnswers | null; password?: string; passwordResetToken?: string; createdAt: Date; isPending: boolean; role?: string; globalScopes?: Scope[]; signInType: AuthProviderType; disabled: boolean; settings?: IUserSettings | null; inviteAcceptUrl?: string; isOwner?: boolean; featureFlags?: FeatureFlags; featureFlagPayloads?: FeatureFlagPayloads; lastActiveAt?: Date | null; mfaAuthenticated?: boolean; isManagedByEnv?: boolean; } export type UserSettings = Pick; export type SlimProject = Pick; export interface CredentialUsedByWorkflow { id: string; name: string; type?: string; currentUserCanUse: boolean; homeProject: SlimProject | null; sharedWithProjects: SlimProject[]; } export interface WorkflowWithSharingsAndCredentials extends Omit { homeProject?: SlimProject; sharedWithProjects?: SlimProject[]; usedCredentials?: CredentialUsedByWorkflow[]; shared?: SharedWorkflow[]; } export interface WorkflowWithSharingsMetaDataAndCredentials extends Omit { homeProject?: SlimProject | null; sharedWithProjects: SlimProject[]; usedCredentials?: CredentialUsedByWorkflow[]; } export type CreateExecutionPayload = Omit; export interface IExecutionDb extends IExecutionBase { data: IRunExecutionData; workflowData: IWorkflowBase; } export interface IExecutionFlattedDb extends IExecutionBase { id: string; data: string; workflowData: Omit; customData: Record; } export declare namespace ExecutionSummaries { export type Query = RangeQuery | CountQuery; export type RangeQuery = { kind: 'range'; } & FilterFields & AccessFields & RangeFields & OrderFields; export type CountQuery = { kind: 'count'; } & FilterFields & AccessFields; export type FilterFields = Partial<{ mode: WorkflowExecuteMode; status: ExecutionStatus[]; workflowId: string; metadata: Array<{ key: string; value: string; exactMatch?: boolean; }>; startedAfter: string; startedBefore: string; annotationTags: string[]; vote: AnnotationVote; projectId: string; workflowVersionId: string; isArchived: boolean; workflowBooleanSettings: Array<{ key: string; value: boolean; }>; }>; export type StopExecutionFilterQuery = { workflowId: string; } & Pick; type AccessFields = { user?: User; sharingOptions?: { scopes?: Scope[]; projectRoles?: string[]; workflowRoles?: string[]; }; }; type RangeFields = { range: { limit: number; beforeId?: string; }; }; type OrderFields = { order?: { top?: ExecutionStatus; startedAt?: 'DESC'; }; }; export type ExecutionSummaryWithScopes = ExecutionSummary & { scopes: Scope[]; }; export {}; } export declare namespace ListQueryDb { namespace Workflow { type OptionalBaseFields = 'name' | 'active' | 'versionId' | 'activeVersionId' | 'createdAt' | 'updatedAt' | 'tags' | 'description'; type BaseFields = Pick & Partial>; type SharedField = Partial>; type SortingField = 'createdAt' | 'updatedAt' | 'name'; export type SortOrder = `${SortingField}:asc` | `${SortingField}:desc`; type OwnedByField = { ownedBy: SlimUser | null; homeProject: SlimProject | null; }; export type Plain = BaseFields; export type WithSharing = BaseFields & SharedField; export type WithOwnership = BaseFields & OwnedByField; type SharedWithField = { sharedWith: SlimUser[]; sharedWithProjects: SlimProject[]; }; export type WithOwnedByAndSharedWith = BaseFields & OwnedByField & SharedWithField & SharedField; export type WithScopes = BaseFields & ScopesField & SharedField; export {}; } namespace Credentials { type OwnedByField = { homeProject: SlimProject | null; }; type SharedField = Partial>; type SharedWithField = { sharedWithProjects: SlimProject[]; }; export type WithSharing = CredentialsEntity & SharedField; export type WithOwnedByAndSharedWith = CredentialsEntity & OwnedByField & SharedWithField & SharedField; export type WithScopes = CredentialsEntity & ScopesField & SharedField; export {}; } } type SlimUser = Pick; export type ScopesField = { scopes: Scope[]; }; export declare const enum StatisticsNames { productionSuccess = "production_success", productionError = "production_error", manualSuccess = "manual_success", manualError = "manual_error", dataLoaded = "data_loaded" } declare const ALL_AUTH_PROVIDERS: z.ZodEnum<["ldap", "email", "saml", "oidc", "token-exchange"]>; export type AuthProviderType = z.infer; export declare function isAuthProviderType(value: string): value is AuthProviderType; export type FolderWithWorkflowAndSubFolderCount = Folder & { workflowCount?: number; subFolderCount?: number; }; export type FolderWithWorkflowAndSubFolderCountAndPath = FolderWithWorkflowAndSubFolderCount & { path?: string[]; }; export type TestRunFinalResult = 'success' | 'error' | 'warning'; export declare const TestRunErrorCode: { readonly TEST_CASES_NOT_FOUND: 'TEST_CASES_NOT_FOUND'; readonly INTERRUPTED: 'INTERRUPTED'; readonly UNKNOWN_ERROR: 'UNKNOWN_ERROR'; readonly EVALUATION_TRIGGER_NOT_FOUND: 'EVALUATION_TRIGGER_NOT_FOUND'; readonly EVALUATION_TRIGGER_NOT_CONFIGURED: 'EVALUATION_TRIGGER_NOT_CONFIGURED'; readonly EVALUATION_TRIGGER_DISABLED: 'EVALUATION_TRIGGER_DISABLED'; readonly EVALUATION_CONFIG_NOT_FOUND: 'EVALUATION_CONFIG_NOT_FOUND'; readonly COMPILATION_FAILED: 'COMPILATION_FAILED'; readonly SET_OUTPUTS_NODE_NOT_CONFIGURED: 'SET_OUTPUTS_NODE_NOT_CONFIGURED'; readonly SET_METRICS_NODE_NOT_FOUND: 'SET_METRICS_NODE_NOT_FOUND'; readonly SET_METRICS_NODE_NOT_CONFIGURED: 'SET_METRICS_NODE_NOT_CONFIGURED'; readonly CANT_FETCH_TEST_CASES: 'CANT_FETCH_TEST_CASES'; }; export type TestRunErrorCode = (typeof TestRunErrorCode)[keyof typeof TestRunErrorCode]; export declare const TestCaseExecutionErrorCode: { readonly NO_METRICS_COLLECTED: 'NO_METRICS_COLLECTED'; readonly MOCKED_NODE_NOT_FOUND: 'MOCKED_NODE_NOT_FOUND'; readonly FAILED_TO_EXECUTE_WORKFLOW: 'FAILED_TO_EXECUTE_WORKFLOW'; readonly INVALID_METRICS: 'INVALID_METRICS'; readonly UNKNOWN_ERROR: 'UNKNOWN_ERROR'; }; export type TestCaseExecutionErrorCode = (typeof TestCaseExecutionErrorCode)[keyof typeof TestCaseExecutionErrorCode]; export type AggregatedTestRunMetrics = Record; export type MockedNodeItem = { name?: string; id: string; }; export type RunningMode = 'dry' | 'live'; export type SyncStatus = 'success' | 'error'; export declare namespace ListQuery { type Options = { filter?: Record; select?: Record; skip?: number; take?: number; sortBy?: string; }; } export interface IGetExecutionsQueryFilter { id?: FindOperator | string; finished?: boolean; mode?: string; retryOf?: string; retrySuccessId?: string; status?: ExecutionStatus[]; workflowId?: string; waitTill?: FindOperator | boolean; metadata?: Array<{ key: string; value: string; exactMatch?: boolean; }>; startedAfter?: string; startedBefore?: string; } export type ResourceType = 'folder' | 'workflow'; export type WorkflowFolderUnionFull = (ListQueryDb.Workflow.Plain | ListQueryDb.Workflow.WithSharing | FolderWithWorkflowAndSubFolderCount) & { resource: ResourceType; }; export type APIRequest = express.Request & { browserId?: string; }; export type AuthenticationInformation = { usedMfa: boolean; mfaEnrollmentRequired?: boolean; }; export interface TokenGrant { scopes: string[]; apiKeyScopes?: string[]; apiKeyId?: string; actor?: User; subject: User; } export type AuthenticatedRequest = Omit, 'user' | 'cookies'> & { user: User; authInfo?: AuthenticationInformation; cookies: Record; headers: express.Request['headers'] & { 'push-ref': string; }; tokenGrant?: TokenGrant; ctx?: OperationContext; }; export declare function isAuthenticatedRequest(req: express.Request): req is AuthenticatedRequest; export interface ISimplifiedPinData { [nodeName: string]: Array<{ json: IDataObject; binary?: IBinaryKeyData; pairedItem?: IPairedItemData | IPairedItemData[] | number; }>; } export {};