diff --git a/.github/workflows/test-workflows.yml b/.github/workflows/test-workflows.yml index ec9de8dedc..90a69438ab 100644 --- a/.github/workflows/test-workflows.yml +++ b/.github/workflows/test-workflows.yml @@ -4,18 +4,70 @@ on: schedule: - cron: '0 2 * * *' workflow_dispatch: + pull_request: + paths: + - packages/core/package.json + - packages/nodes-base/package.json + - packages/@n8n/nodes-langchain/package.json + - .github/workflows/test-workflows.yml + pull_request_review: + types: [submitted] jobs: - run-test-workflows: + build: + name: Install & Build runs-on: ubuntu-latest - - timeout-minutes: 30 - + if: github.event_name != 'pull_request_review' || startsWith(github.event.pull_request.base.ref, 'release/') steps: - - name: Checkout - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4.1.1 + - run: corepack enable + - uses: actions/setup-node@v4.0.2 with: - path: n8n + node-version: 20.x + cache: 'pnpm' + - run: pnpm install --frozen-lockfile + + - name: Setup build cache + uses: rharkor/caching-for-turbo@v1.5 + + - name: Build Backend + run: pnpm build:backend + + - name: Cache build artifacts + uses: actions/cache/save@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ github.sha }}:workflow-tests + + run-test-workflows: + name: Workflow Tests + runs-on: ubuntu-latest + needs: build + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4.1.1 + - run: corepack enable + - uses: actions/setup-node@v4.0.2 + with: + node-version: 20.x + cache: 'pnpm' + - run: pnpm install --frozen-lockfile + + - name: Setup build cache + uses: rharkor/caching-for-turbo@v1.5 + + - name: Restore cached build artifacts + uses: actions/cache/restore@v4.0.0 + with: + path: ./packages/**/dist + key: ${{ github.sha }}:workflow-tests + + - name: Install OS dependencies + run: | + sudo apt update -y + echo 'tzdata tzdata/Areas select Europe' | sudo debconf-set-selections + echo 'tzdata tzdata/Zones/Europe select Paris' | sudo debconf-set-selections + DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y graphicsmagick - name: Checkout workflows repo uses: actions/checkout@v4.1.1 @@ -23,52 +75,24 @@ jobs: repository: n8n-io/test-workflows path: test-workflows - - run: corepack enable - working-directory: n8n - - - uses: actions/setup-node@v4.0.2 - with: - node-version: 20.x - cache: 'pnpm' - cache-dependency-path: 'n8n/pnpm-lock.yaml' - - - name: Install dependencies - run: | - sudo apt update -y - echo 'tzdata tzdata/Areas select Europe' | sudo debconf-set-selections - echo 'tzdata tzdata/Zones/Europe select Paris' | sudo debconf-set-selections - DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y graphicsmagick - shell: bash - - - name: pnpm install and build - working-directory: n8n - run: | - pnpm install --frozen-lockfile - pnpm build:backend - shell: bash - - name: Import credentials - run: n8n/packages/cli/bin/n8n import:credentials --input=test-workflows/credentials.json - shell: bash + run: packages/cli/bin/n8n import:credentials --input=test-workflows/credentials.json env: N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}} - name: Import workflows - run: n8n/packages/cli/bin/n8n import:workflow --separate --input=test-workflows/workflows - shell: bash + run: packages/cli/bin/n8n import:workflow --separate --input=test-workflows/workflows env: N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}} - name: Copy static assets run: | - cp n8n/assets/n8n-logo.png /tmp/n8n-logo.png - cp n8n/assets/n8n-screenshot.png /tmp/n8n-screenshot.png + cp assets/n8n-logo.png /tmp/n8n-logo.png + cp assets/n8n-screenshot.png /tmp/n8n-screenshot.png cp test-workflows/testData/pdfs/*.pdf /tmp/ - shell: bash - name: Run tests - run: n8n/packages/cli/bin/n8n executeBatch --shallow --skipList=test-workflows/skipList.txt --githubWorkflow --shortOutput --concurrency=16 --compare=test-workflows/snapshots - shell: bash + run: packages/cli/bin/n8n executeBatch --shallow --skipList=test-workflows/skipList.txt --githubWorkflow --shortOutput --concurrency=16 --compare=test-workflows/snapshots id: tests env: N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}} @@ -76,23 +100,6 @@ jobs: DB_SQLITE_POOL_SIZE: 4 N8N_SENTRY_DSN: ${{secrets.CI_SENTRY_DSN}} - # - - # name: Export credentials - # if: always() - # run: n8n/packages/cli/bin/n8n export:credentials --output=test-workflows/credentials.json --all --pretty - # shell: bash - # env: - # N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}} - # - - # name: Commit and push credential changes - # if: always() - # run: | - # cd test-workflows - # git config --global user.name 'n8n test bot' - # git config --global user.email 'n8n-test-bot@users.noreply.github.com' - # git commit -am "Automated credential update" - # git push --force --quiet "https://janober:${{ secrets.TOKEN }}@github.com/n8n-io/test-workflows.git" main:main - - name: Notify Slack on failure uses: act10ns/slack@v2.0.0 if: failure() && github.ref == 'refs/heads/master' diff --git a/cypress/composables/modals/credential-modal.ts b/cypress/composables/modals/credential-modal.ts index 77b69fc586..53ba0c3a28 100644 --- a/cypress/composables/modals/credential-modal.ts +++ b/cypress/composables/modals/credential-modal.ts @@ -40,6 +40,7 @@ export function saveCredential() { .within(() => { cy.get('button').should('not.exist'); }); + getCredentialSaveButton().should('have.text', 'Saved'); } export function closeCredentialModal() { diff --git a/cypress/e2e/17-sharing.cy.ts b/cypress/e2e/17-sharing.cy.ts index 8a8fd4e4c1..30a990fb28 100644 --- a/cypress/e2e/17-sharing.cy.ts +++ b/cypress/e2e/17-sharing.cy.ts @@ -1,3 +1,4 @@ +import { saveCredential } from '../composables/modals/credential-modal'; import * as projects from '../composables/projects'; import { INSTANCE_MEMBERS, INSTANCE_OWNER, INSTANCE_ADMIN, NOTION_NODE_NAME } from '../constants'; import { @@ -225,8 +226,7 @@ describe('Sharing', { disableAutoLogin: true }, () => { .filter(':contains("Development")') .should('have.length', 1) .click(); - credentialsModal.getters.saveButton().click(); - credentialsModal.getters.saveButton().should('have.text', 'Saved'); + saveCredential(); credentialsModal.actions.close(); projects.getProjectTabWorkflows().click(); @@ -252,8 +252,7 @@ describe('Sharing', { disableAutoLogin: true }, () => { credentialsModal.actions.changeTab('Sharing'); credentialsModal.getters.usersSelect().click(); getVisibleSelect().find('li').should('have.length', 4).first().click(); - credentialsModal.getters.saveButton().click(); - credentialsModal.getters.saveButton().should('have.text', 'Saved'); + saveCredential(); credentialsModal.actions.close(); credentialsPage.getters diff --git a/cypress/e2e/2-credentials.cy.ts b/cypress/e2e/2-credentials.cy.ts index 71c3083856..cda01c71a3 100644 --- a/cypress/e2e/2-credentials.cy.ts +++ b/cypress/e2e/2-credentials.cy.ts @@ -1,5 +1,6 @@ import { type ICredentialType } from 'n8n-workflow'; +import { getCredentialSaveButton, saveCredential } from '../composables/modals/credential-modal'; import { AGENT_NODE_NAME, AI_TOOL_HTTP_NODE_NAME, @@ -194,7 +195,7 @@ describe('Credentials', () => { credentialsModal.getters.credentialsEditModal().should('be.visible'); credentialsModal.getters.name().click(); credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME); - credentialsModal.getters.saveButton().click(); + saveCredential(); credentialsModal.getters.closeButton().click(); workflowPage.getters .nodeCredentialsSelect() @@ -212,7 +213,7 @@ describe('Credentials', () => { credentialsModal.getters.credentialsEditModal().should('be.visible'); credentialsModal.getters.name().click(); credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME2); - credentialsModal.getters.saveButton().click(); + saveCredential(); credentialsModal.getters.closeButton().click(); workflowPage.getters .nodeCredentialsSelect() @@ -237,7 +238,7 @@ describe('Credentials', () => { credentialsModal.getters.credentialsEditModal().should('be.visible'); credentialsModal.getters.name().click(); credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME); - credentialsModal.getters.saveButton().click(); + saveCredential(); credentialsModal.getters.closeButton().click(); workflowPage.getters .nodeCredentialsSelect() @@ -342,7 +343,8 @@ describe('Credentials', () => { credentialsModal.getters.connectionParameter('Internal Integration Secret').type('1234567890'); credentialsModal.actions.setName('My awesome Notion account'); - credentialsModal.getters.saveButton().click({ force: true }); + getCredentialSaveButton().click(); + errorToast().should('have.length', 1); errorToast().should('be.visible'); diff --git a/cypress/e2e/27-two-factor-authentication.cy.ts b/cypress/e2e/27-two-factor-authentication.cy.ts index dc62a0c58c..759964f155 100644 --- a/cypress/e2e/27-two-factor-authentication.cy.ts +++ b/cypress/e2e/27-two-factor-authentication.cy.ts @@ -49,33 +49,35 @@ describe('Two-factor authentication', { disableAutoLogin: true }, () => { cy.intercept('GET', '/rest/mfa/qr').as('getMfaQrCode'); }); - it('Should be able to login with MFA token', () => { + it('Should be able to login with MFA code', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); mainSidebar.actions.signout(); - const token = generateOTPToken(user.mfaSecret); - mfaLoginPage.actions.loginWithMfaToken(email, password, token); + const mfaCode = generateOTPToken(user.mfaSecret); + mfaLoginPage.actions.loginWithMfaCode(email, password, mfaCode); mainSidebar.actions.signout(); }); - it('Should be able to login with recovery code', () => { + it('Should be able to login with MFA recovery code', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); mainSidebar.actions.signout(); - mfaLoginPage.actions.loginWithRecoveryCode(email, password, user.mfaRecoveryCodes[0]); + mfaLoginPage.actions.loginWithMfaRecoveryCode(email, password, user.mfaRecoveryCodes[0]); mainSidebar.actions.signout(); }); - it('Should be able to disable MFA in account', () => { + it('Should be able to disable MFA in account with MFA code ', () => { const { email, password } = user; signinPage.actions.loginWithEmailAndPassword(email, password); personalSettingsPage.actions.enableMfa(); mainSidebar.actions.signout(); - const token = generateOTPToken(user.mfaSecret); - mfaLoginPage.actions.loginWithMfaToken(email, password, token); - personalSettingsPage.actions.disableMfa(); + const loginToken = generateOTPToken(user.mfaSecret); + mfaLoginPage.actions.loginWithMfaCode(email, password, loginToken); + const disableToken = generateOTPToken(user.mfaSecret); + personalSettingsPage.actions.disableMfa(disableToken); + personalSettingsPage.getters.enableMfaButton().should('exist'); mainSidebar.actions.signout(); }); }); diff --git a/cypress/e2e/43-oauth-flow.cy.ts b/cypress/e2e/43-oauth-flow.cy.ts index 300a202540..d91315627b 100644 --- a/cypress/e2e/43-oauth-flow.cy.ts +++ b/cypress/e2e/43-oauth-flow.cy.ts @@ -1,3 +1,4 @@ +import { getCredentialSaveButton } from '../composables/modals/credential-modal'; import { CredentialsPage, CredentialsModal } from '../pages'; const credentialsPage = new CredentialsPage(); @@ -40,7 +41,7 @@ describe('Credentials', () => { }); // Check that the credential was saved and connected successfully - credentialsModal.getters.saveButton().should('contain.text', 'Saved'); + getCredentialSaveButton().should('contain.text', 'Saved'); credentialsModal.getters.oauthConnectSuccessBanner().should('be.visible'); }); }); diff --git a/cypress/pages/mfa-login.ts b/cypress/pages/mfa-login.ts index 66fc197e3f..7e679804ff 100644 --- a/cypress/pages/mfa-login.ts +++ b/cypress/pages/mfa-login.ts @@ -8,18 +8,18 @@ export class MfaLoginPage extends BasePage { getters = { form: () => cy.getByTestId('mfa-login-form'), - token: () => cy.getByTestId('token'), - recoveryCode: () => cy.getByTestId('recoveryCode'), + mfaCode: () => cy.getByTestId('mfaCode'), + mfaRecoveryCode: () => cy.getByTestId('mfaRecoveryCode'), enterRecoveryCodeButton: () => cy.getByTestId('mfa-enter-recovery-code-button'), }; actions = { - loginWithMfaToken: (email: string, password: string, mfaToken: string) => { + loginWithMfaCode: (email: string, password: string, mfaCode: string) => { const signinPage = new SigninPage(); const workflowsPage = new WorkflowsPage(); cy.session( - [mfaToken], + [mfaCode], () => { cy.visit(signinPage.url); @@ -30,7 +30,7 @@ export class MfaLoginPage extends BasePage { }); this.getters.form().within(() => { - this.getters.token().type(mfaToken); + this.getters.mfaCode().type(mfaCode); }); // we should be redirected to /workflows @@ -43,12 +43,12 @@ export class MfaLoginPage extends BasePage { }, ); }, - loginWithRecoveryCode: (email: string, password: string, recoveryCode: string) => { + loginWithMfaRecoveryCode: (email: string, password: string, mfaRecoveryCode: string) => { const signinPage = new SigninPage(); const workflowsPage = new WorkflowsPage(); cy.session( - [recoveryCode], + [mfaRecoveryCode], () => { cy.visit(signinPage.url); @@ -61,7 +61,7 @@ export class MfaLoginPage extends BasePage { this.getters.enterRecoveryCodeButton().click(); this.getters.form().within(() => { - this.getters.recoveryCode().type(recoveryCode); + this.getters.mfaRecoveryCode().type(mfaRecoveryCode); }); // we should be redirected to /workflows diff --git a/cypress/pages/modals/credentials-modal.ts b/cypress/pages/modals/credentials-modal.ts index cd3ded63f8..b8907386a0 100644 --- a/cypress/pages/modals/credentials-modal.ts +++ b/cypress/pages/modals/credentials-modal.ts @@ -1,3 +1,4 @@ +import { getCredentialSaveButton, saveCredential } from '../../composables/modals/credential-modal'; import { getVisibleSelect } from '../../utils'; import { BasePage } from '../base'; @@ -13,8 +14,6 @@ export class CredentialsModal extends BasePage { this.getters.credentialInputs().find(`:contains('${fieldName}') .n8n-input input`), name: () => cy.getByTestId('credential-name'), nameInput: () => cy.getByTestId('credential-name').find('input'), - // Saving of the credentials takes a while on the CI so we need to increase the timeout - saveButton: () => cy.getByTestId('credential-save-button', { timeout: 5000 }), deleteButton: () => cy.getByTestId('credential-delete-button'), closeButton: () => this.getters.editCredentialModal().find('.el-dialog__close').first(), oauthConnectButton: () => cy.getByTestId('oauth-connect-button'), @@ -41,17 +40,17 @@ export class CredentialsModal extends BasePage { }, save: (test = false) => { cy.intercept('POST', '/rest/credentials').as('saveCredential'); - this.getters.saveButton().click({ force: true }); + saveCredential(); cy.wait('@saveCredential'); if (test) cy.wait('@testCredential'); - this.getters.saveButton().should('contain.text', 'Saved'); + getCredentialSaveButton().should('contain.text', 'Saved'); }, saveSharing: () => { cy.intercept('PUT', '/rest/credentials/*/share').as('shareCredential'); - this.getters.saveButton().click({ force: true }); + saveCredential(); cy.wait('@shareCredential'); - this.getters.saveButton().should('contain.text', 'Saved'); + getCredentialSaveButton().should('contain.text', 'Saved'); }, close: () => { this.getters.closeButton().click(); @@ -65,7 +64,7 @@ export class CredentialsModal extends BasePage { .each(($el) => { cy.wrap($el).type('test'); }); - this.getters.saveButton().click(); + saveCredential(); if (closeModal) { this.getters.closeButton().click(); } diff --git a/cypress/pages/settings-personal.ts b/cypress/pages/settings-personal.ts index 4574f95691..5602bd7e92 100644 --- a/cypress/pages/settings-personal.ts +++ b/cypress/pages/settings-personal.ts @@ -22,6 +22,8 @@ export class PersonalSettingsPage extends BasePage { saveSettingsButton: () => cy.getByTestId('save-settings-button'), enableMfaButton: () => cy.getByTestId('enable-mfa-button'), disableMfaButton: () => cy.getByTestId('disable-mfa-button'), + mfaCodeOrMfaRecoveryCodeInput: () => cy.getByTestId('mfa-code-or-recovery-code-input'), + mfaSaveButton: () => cy.getByTestId('mfa-save-button'), themeSelector: () => cy.getByTestId('theme-select'), selectOptionsVisible: () => cy.get('.el-select-dropdown:visible .el-select-dropdown__item'), }; @@ -83,9 +85,11 @@ export class PersonalSettingsPage extends BasePage { mfaSetupModal.getters.saveButton().click(); }); }, - disableMfa: () => { + disableMfa: (mfaCodeOrRecoveryCode: string) => { cy.visit(this.url); this.getters.disableMfaButton().click(); + this.getters.mfaCodeOrMfaRecoveryCodeInput().type(mfaCodeOrRecoveryCode); + this.getters.mfaSaveButton().click(); }, }; } diff --git a/packages/@n8n/config/src/configs/workflows.config.ts b/packages/@n8n/config/src/configs/workflows.config.ts index 3d6eaad12f..c5b88775c8 100644 --- a/packages/@n8n/config/src/configs/workflows.config.ts +++ b/packages/@n8n/config/src/configs/workflows.config.ts @@ -6,10 +6,6 @@ export class WorkflowsConfig { @Env('WORKFLOWS_DEFAULT_NAME') defaultName: string = 'My workflow'; - /** Show onboarding flow in new workflow */ - @Env('N8N_ONBOARDING_FLOW_DISABLED') - onboardingFlowDisabled: boolean = false; - /** Default option for which workflows may call the current workflow */ @Env('N8N_WORKFLOW_CALLER_POLICY_DEFAULT_OPTION') callerPolicyDefaultOption: 'any' | 'none' | 'workflowsFromAList' | 'workflowsFromSameOwner' = diff --git a/packages/@n8n/config/test/config.test.ts b/packages/@n8n/config/test/config.test.ts index 58b808ee4b..771d915ee4 100644 --- a/packages/@n8n/config/test/config.test.ts +++ b/packages/@n8n/config/test/config.test.ts @@ -150,7 +150,6 @@ describe('GlobalConfig', () => { }, workflows: { defaultName: 'My workflow', - onboardingFlowDisabled: false, callerPolicyDefaultOption: 'workflowsFromSameOwner', }, endpoints: { diff --git a/packages/@n8n/json-schema-to-zod/src/index.ts b/packages/@n8n/json-schema-to-zod/src/index.ts index 10dae97784..8de0516a2f 100644 --- a/packages/@n8n/json-schema-to-zod/src/index.ts +++ b/packages/@n8n/json-schema-to-zod/src/index.ts @@ -1,2 +1,2 @@ export type * from './types'; -export { jsonSchemaToZod } from './json-schema-to-zod.js'; +export { jsonSchemaToZod } from './json-schema-to-zod'; diff --git a/packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/utils.ts b/packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/utils.ts index 0d85806bf3..144b622c76 100644 --- a/packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/utils.ts +++ b/packages/@n8n/nodes-langchain/nodes/agents/Agent/agents/utils.ts @@ -1,8 +1,10 @@ -import type { ZodObjectAny } from '@langchain/core/dist/types/zod'; +import type { z } from 'zod'; import type { BaseOutputParser } from '@langchain/core/output_parsers'; import type { DynamicStructuredTool, Tool } from 'langchain/tools'; import { NodeOperationError, type IExecuteFunctions, type INode } from 'n8n-workflow'; +type ZodObjectAny = z.ZodObject; + export async function extractParsedOutput( ctx: IExecuteFunctions, outputParser: BaseOutputParser, diff --git a/packages/@n8n/nodes-langchain/package.json b/packages/@n8n/nodes-langchain/package.json index da65509956..11e2c61cf1 100644 --- a/packages/@n8n/nodes-langchain/package.json +++ b/packages/@n8n/nodes-langchain/package.json @@ -135,47 +135,47 @@ "@getzep/zep-js": "0.9.0", "@google-ai/generativelanguage": "2.6.0", "@google-cloud/resource-manager": "5.3.0", - "@google/generative-ai": "0.19.0", + "@google/generative-ai": "0.21.0", "@huggingface/inference": "2.8.0", - "@langchain/anthropic": "0.3.7", - "@langchain/aws": "0.1.1", + "@langchain/anthropic": "0.3.8", + "@langchain/aws": "0.1.2", "@langchain/cohere": "0.3.1", - "@langchain/community": "0.3.11", + "@langchain/community": "0.3.15", "@langchain/core": "catalog:", - "@langchain/google-genai": "0.1.2", - "@langchain/google-vertexai": "0.1.0", + "@langchain/google-genai": "0.1.4", + "@langchain/google-vertexai": "0.1.3", "@langchain/groq": "0.1.2", - "@langchain/mistralai": "0.1.1", - "@langchain/ollama": "0.1.1", - "@langchain/openai": "0.3.11", - "@langchain/pinecone": "0.1.1", - "@langchain/qdrant": "0.1.0", + "@langchain/mistralai": "0.2.0", + "@langchain/ollama": "0.1.2", + "@langchain/openai": "0.3.14", + "@langchain/pinecone": "0.1.3", + "@langchain/qdrant": "0.1.1", "@langchain/redis": "0.1.0", "@langchain/textsplitters": "0.1.0", "@mozilla/readability": "0.5.0", "@n8n/json-schema-to-zod": "workspace:*", "@n8n/typeorm": "0.3.20-12", "@n8n/vm2": "3.9.25", - "@pinecone-database/pinecone": "3.0.3", + "@pinecone-database/pinecone": "4.0.0", "@qdrant/js-client-rest": "1.11.0", "@supabase/supabase-js": "2.45.4", "@xata.io/client": "0.28.4", "basic-auth": "catalog:", "cheerio": "1.0.0", - "cohere-ai": "7.13.2", + "cohere-ai": "7.14.0", "d3-dsv": "2.0.0", "epub2": "3.0.2", "form-data": "catalog:", "generate-schema": "2.6.0", "html-to-text": "9.0.5", "jsdom": "23.0.1", - "langchain": "0.3.5", + "langchain": "0.3.6", "lodash": "catalog:", "mammoth": "1.7.2", "mime-types": "2.1.35", "n8n-nodes-base": "workspace:*", "n8n-workflow": "workspace:*", - "openai": "4.69.0", + "openai": "4.73.1", "pdf-parse": "1.1.1", "pg": "8.12.0", "redis": "4.6.12", diff --git a/packages/@n8n/nodes-langchain/utils/output_parsers/N8nStructuredOutputParser.ts b/packages/@n8n/nodes-langchain/utils/output_parsers/N8nStructuredOutputParser.ts index a24052f5e1..3b8410df74 100644 --- a/packages/@n8n/nodes-langchain/utils/output_parsers/N8nStructuredOutputParser.ts +++ b/packages/@n8n/nodes-langchain/utils/output_parsers/N8nStructuredOutputParser.ts @@ -32,7 +32,9 @@ export class N8nStructuredOutputParser extends StructuredOutputParser< [{ json: { action: 'parse', text } }], ]); try { - const parsed = await super.parse(text); + const jsonString = text.includes('```') ? text.split(/```(?:json)?/)[1] : text; + const json = JSON.parse(jsonString.trim()); + const parsed = await this.schema.parseAsync(json); const result = (get(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_OBJECT_KEY]) ?? get(parsed, [STRUCTURED_OUTPUT_KEY, STRUCTURED_OUTPUT_ARRAY_KEY]) ?? diff --git a/packages/cli/package.json b/packages/cli/package.json index 18cd195620..413bc5d700 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -94,7 +94,7 @@ "@n8n/permissions": "workspace:*", "@n8n/task-runner": "workspace:*", "@n8n/typeorm": "0.3.20-12", - "@n8n_io/ai-assistant-sdk": "1.10.3", + "@n8n_io/ai-assistant-sdk": "1.12.0", "@n8n_io/license-sdk": "2.13.1", "@oclif/core": "4.0.7", "@rudderstack/rudder-sdk-node": "2.0.9", diff --git a/packages/cli/src/__tests__/error-reporting.test.ts b/packages/cli/src/__tests__/error-reporting.test.ts new file mode 100644 index 0000000000..5e472b8b99 --- /dev/null +++ b/packages/cli/src/__tests__/error-reporting.test.ts @@ -0,0 +1,61 @@ +import { GlobalConfig } from '@n8n/config'; +import type { ClientOptions, ErrorEvent } from '@sentry/types'; +import { strict as assert } from 'node:assert'; +import { Container } from 'typedi'; + +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; + +const init = jest.fn(); + +jest.mock('@sentry/integrations'); +jest.mock('@sentry/node', () => ({ + init, + setTag: jest.fn(), + captureException: jest.fn(), + Integrations: {}, +})); + +jest.spyOn(process, 'on'); + +describe('initErrorHandling', () => { + let beforeSend: ClientOptions['beforeSend']; + + beforeAll(async () => { + Container.get(GlobalConfig).sentry.backendDsn = 'backend-dsn'; + const errorReporting = require('@/error-reporting'); + await errorReporting.initErrorHandling(); + const options = (init.mock.calls[0] as [ClientOptions])[0]; + beforeSend = options.beforeSend; + }); + + it('ignores errors with level warning', async () => { + const originalException = new InternalServerError('test'); + originalException.level = 'warning'; + + const event = {} as ErrorEvent; + + assert(beforeSend); + expect(await beforeSend(event, { originalException })).toEqual(null); + }); + + it('keeps events with a cause with error level', async () => { + const cause = new Error('cause-error'); + + const originalException = new InternalServerError('test', cause); + const event = {} as ErrorEvent; + + assert(beforeSend); + expect(await beforeSend(event, { originalException })).toEqual(event); + }); + + it('ignores events with error cause with warning level', async () => { + const cause: Error & { level?: 'warning' } = new Error('cause-error'); + cause.level = 'warning'; + + const originalException = new InternalServerError('test', cause); + const event = {} as ErrorEvent; + + assert(beforeSend); + expect(await beforeSend(event, { originalException })).toEqual(null); + }); +}); diff --git a/packages/cli/src/controllers/ai.controller.ts b/packages/cli/src/controllers/ai.controller.ts index 1957db2971..be1231911a 100644 --- a/packages/cli/src/controllers/ai.controller.ts +++ b/packages/cli/src/controllers/ai.controller.ts @@ -1,6 +1,5 @@ import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; import type { Response } from 'express'; -import { ErrorReporterProxy } from 'n8n-workflow'; import { strict as assert } from 'node:assert'; import { WritableStream } from 'node:stream/web'; @@ -33,8 +32,7 @@ export class AiController { } } catch (e) { assert(e instanceof Error); - ErrorReporterProxy.error(e); - throw new InternalServerError(`Something went wrong: ${e.message}`); + throw new InternalServerError(e.message, e); } } @@ -46,8 +44,7 @@ export class AiController { return await this.aiService.applySuggestion(req.body, req.user); } catch (e) { assert(e instanceof Error); - ErrorReporterProxy.error(e); - throw new InternalServerError(`Something went wrong: ${e.message}`); + throw new InternalServerError(e.message, e); } } @@ -57,8 +54,7 @@ export class AiController { return await this.aiService.askAi(req.body, req.user); } catch (e) { assert(e instanceof Error); - ErrorReporterProxy.error(e); - throw new InternalServerError(`Something went wrong: ${e.message}`); + throw new InternalServerError(e.message, e); } } } diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index c2ee1c92fb..46ee73a562 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -41,7 +41,7 @@ export class AuthController { /** Log in a user */ @Post('/login', { skipAuth: true, rateLimit: true }) async login(req: LoginRequest, res: Response): Promise { - const { email, password, mfaToken, mfaRecoveryCode } = req.body; + const { email, password, mfaCode, mfaRecoveryCode } = req.body; if (!email) throw new ApplicationError('Email is required to log in'); if (!password) throw new ApplicationError('Password is required to log in'); @@ -75,16 +75,16 @@ export class AuthController { if (user) { if (user.mfaEnabled) { - if (!mfaToken && !mfaRecoveryCode) { + if (!mfaCode && !mfaRecoveryCode) { throw new AuthError('MFA Error', 998); } - const isMFATokenValid = await this.mfaService.validateMfa( + const isMfaCodeOrMfaRecoveryCodeValid = await this.mfaService.validateMfa( user.id, - mfaToken, + mfaCode, mfaRecoveryCode, ); - if (!isMFATokenValid) { + if (!isMfaCodeOrMfaRecoveryCodeValid) { throw new AuthError('Invalid mfa token or recovery code'); } } diff --git a/packages/cli/src/controllers/community-packages.controller.ts b/packages/cli/src/controllers/community-packages.controller.ts index 5caf835f60..918f1cdf74 100644 --- a/packages/cli/src/controllers/community-packages.controller.ts +++ b/packages/cli/src/controllers/community-packages.controller.ts @@ -201,7 +201,7 @@ export class CommunityPackagesController { error instanceof Error ? error.message : UNKNOWN_FAILURE_REASON, ].join(':'); - throw new InternalServerError(message); + throw new InternalServerError(message, error); } // broadcast to connected frontends that node list has been updated @@ -283,7 +283,7 @@ export class CommunityPackagesController { error instanceof Error ? error.message : UNKNOWN_FAILURE_REASON, ].join(':'); - throw new InternalServerError(message); + throw new InternalServerError(message, error); } } } diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index 6cbbda3622..a7fb7235fd 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -68,8 +68,8 @@ export class MeController { throw new BadRequestError('Two-factor code is required to change email'); } - const isMfaTokenValid = await this.mfaService.validateMfa(userId, payload.mfaCode, undefined); - if (!isMfaTokenValid) { + const isMfaCodeValid = await this.mfaService.validateMfa(userId, payload.mfaCode, undefined); + if (!isMfaCodeValid) { throw new InvalidMfaCodeError(); } } @@ -142,8 +142,8 @@ export class MeController { throw new BadRequestError('Two-factor code is required to change password.'); } - const isMfaTokenValid = await this.mfaService.validateMfa(user.id, mfaCode, undefined); - if (!isMfaTokenValid) { + const isMfaCodeValid = await this.mfaService.validateMfa(user.id, mfaCode, undefined); + if (!isMfaCodeValid) { throw new InvalidMfaCodeError(); } } diff --git a/packages/cli/src/controllers/mfa.controller.ts b/packages/cli/src/controllers/mfa.controller.ts index 694765761c..54e67692ee 100644 --- a/packages/cli/src/controllers/mfa.controller.ts +++ b/packages/cli/src/controllers/mfa.controller.ts @@ -59,7 +59,7 @@ export class MFAController { @Post('/enable', { rateLimit: true }) async activateMFA(req: MFA.Activate) { - const { token = null } = req.body; + const { mfaCode = null } = req.body; const { id, mfaEnabled } = req.user; await this.externalHooks.run('mfa.beforeSetup', [req.user]); @@ -67,7 +67,7 @@ export class MFAController { const { decryptedSecret: secret, decryptedRecoveryCodes: recoveryCodes } = await this.mfaService.getSecretAndRecoveryCodes(id); - if (!token) throw new BadRequestError('Token is required to enable MFA feature'); + if (!mfaCode) throw new BadRequestError('Token is required to enable MFA feature'); if (mfaEnabled) throw new BadRequestError('MFA already enabled'); @@ -75,10 +75,10 @@ export class MFAController { throw new BadRequestError('Cannot enable MFA without generating secret and recovery codes'); } - const verified = this.mfaService.totp.verifySecret({ secret, token, window: 10 }); + const verified = this.mfaService.totp.verifySecret({ secret, mfaCode, window: 10 }); if (!verified) - throw new BadRequestError('MFA token expired. Close the modal and enable MFA again', 997); + throw new BadRequestError('MFA code expired. Close the modal and enable MFA again', 997); await this.mfaService.enableMfa(id); } @@ -86,27 +86,27 @@ export class MFAController { @Post('/disable', { rateLimit: true }) async disableMFA(req: MFA.Disable) { const { id: userId } = req.user; - const { token = null } = req.body; + const { mfaCode = null } = req.body; - if (typeof token !== 'string' || !token) { + if (typeof mfaCode !== 'string' || !mfaCode) { throw new BadRequestError('Token is required to disable MFA feature'); } - await this.mfaService.disableMfa(userId, token); + await this.mfaService.disableMfa(userId, mfaCode); } @Post('/verify', { rateLimit: true }) async verifyMFA(req: MFA.Verify) { const { id } = req.user; - const { token } = req.body; + const { mfaCode } = req.body; const { decryptedSecret: secret } = await this.mfaService.getSecretAndRecoveryCodes(id); - if (!token) throw new BadRequestError('Token is required to enable MFA feature'); + if (!mfaCode) throw new BadRequestError('MFA code is required to enable MFA feature'); if (!secret) throw new BadRequestError('No MFA secret se for this user'); - const verified = this.mfaService.totp.verifySecret({ secret, token }); + const verified = this.mfaService.totp.verifySecret({ secret, mfaCode }); if (!verified) throw new BadRequestError('MFA secret could not be verified'); } diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index 88155e420a..2179ff3d9e 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -120,7 +120,7 @@ export class PasswordResetController { publicApi: false, }); if (error instanceof Error) { - throw new InternalServerError(`Please contact your administrator: ${error.message}`); + throw new InternalServerError(`Please contact your administrator: ${error.message}`, error); } } @@ -171,7 +171,7 @@ export class PasswordResetController { */ @Post('/change-password', { skipAuth: true }) async changePassword(req: PasswordResetRequest.NewPassword, res: Response) { - const { token, password, mfaToken } = req.body; + const { token, password, mfaCode } = req.body; if (!token || !password) { this.logger.debug( @@ -189,11 +189,11 @@ export class PasswordResetController { if (!user) throw new NotFoundError(''); if (user.mfaEnabled) { - if (!mfaToken) throw new BadRequestError('If MFA enabled, mfaToken is required.'); + if (!mfaCode) throw new BadRequestError('If MFA enabled, mfaCode is required.'); const { decryptedSecret: secret } = await this.mfaService.getSecretAndRecoveryCodes(user.id); - const validToken = this.mfaService.totp.verifySecret({ secret, token: mfaToken }); + const validToken = this.mfaService.totp.verifySecret({ secret, mfaCode }); if (!validToken) throw new BadRequestError('Invalid MFA token.'); } diff --git a/packages/cli/src/controllers/translation.controller.ts b/packages/cli/src/controllers/translation.controller.ts index 485e290cad..d6ae656afe 100644 --- a/packages/cli/src/controllers/translation.controller.ts +++ b/packages/cli/src/controllers/translation.controller.ts @@ -54,7 +54,7 @@ export class TranslationController { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return require(NODE_HEADERS_PATH); } catch (error) { - throw new InternalServerError('Failed to load headers file'); + throw new InternalServerError('Failed to load headers file', error); } } } diff --git a/packages/cli/src/error-reporting.ts b/packages/cli/src/error-reporting.ts index 897bef6fef..fd2ce078cd 100644 --- a/packages/cli/src/error-reporting.ts +++ b/packages/cli/src/error-reporting.ts @@ -90,6 +90,17 @@ export const initErrorHandling = async () => { if (tags) event.tags = { ...event.tags, ...tags }; } + if ( + originalException instanceof Error && + 'cause' in originalException && + originalException.cause instanceof Error && + 'level' in originalException.cause && + originalException.cause.level === 'warning' + ) { + // handle underlying errors propagating from dependencies like ai-assistant-sdk + return null; + } + if (originalException instanceof Error && originalException.stack) { const eventHash = createHash('sha1').update(originalException.stack).digest('base64'); if (seenErrors.has(eventHash)) return null; diff --git a/packages/cli/src/errors/response-errors/abstract/response.error.ts b/packages/cli/src/errors/response-errors/abstract/response.error.ts index f756afce41..fa7d4a8b06 100644 --- a/packages/cli/src/errors/response-errors/abstract/response.error.ts +++ b/packages/cli/src/errors/response-errors/abstract/response.error.ts @@ -16,8 +16,9 @@ export abstract class ResponseError extends ApplicationError { readonly errorCode: number = httpStatusCode, // The error hint the response readonly hint: string | undefined = undefined, + cause?: unknown, ) { - super(message); + super(message, { cause }); this.name = 'ResponseError'; } } diff --git a/packages/cli/src/errors/response-errors/internal-server.error.ts b/packages/cli/src/errors/response-errors/internal-server.error.ts index 4c10e93f95..2a6a8d6b77 100644 --- a/packages/cli/src/errors/response-errors/internal-server.error.ts +++ b/packages/cli/src/errors/response-errors/internal-server.error.ts @@ -1,7 +1,7 @@ import { ResponseError } from './abstract/response.error'; export class InternalServerError extends ResponseError { - constructor(message: string, errorCode = 500) { - super(message, 500, errorCode); + constructor(message: string, cause?: unknown) { + super(message, 500, 500, undefined, cause); } } diff --git a/packages/cli/src/evaluation/test-runner/__tests__/evaluation-metrics.ee.test.ts b/packages/cli/src/evaluation/test-runner/__tests__/evaluation-metrics.ee.test.ts new file mode 100644 index 0000000000..27daf3aa79 --- /dev/null +++ b/packages/cli/src/evaluation/test-runner/__tests__/evaluation-metrics.ee.test.ts @@ -0,0 +1,72 @@ +import { EvaluationMetrics } from '../evaluation-metrics.ee'; + +describe('EvaluationMetrics', () => { + test('should aggregate metrics correctly', () => { + const testMetricNames = new Set(['metric1', 'metric2']); + const metrics = new EvaluationMetrics(testMetricNames); + + metrics.addResults({ metric1: 1, metric2: 0 }); + metrics.addResults({ metric1: 0.5, metric2: 0.2 }); + + const aggregatedMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedMetrics).toEqual({ metric1: 0.75, metric2: 0.1 }); + }); + + test('should aggregate only numbers', () => { + const testMetricNames = new Set(['metric1', 'metric2']); + const metrics = new EvaluationMetrics(testMetricNames); + + metrics.addResults({ metric1: 1, metric2: 0 }); + metrics.addResults({ metric1: '0.5', metric2: 0.2 }); + metrics.addResults({ metric1: 'not a number', metric2: [1, 2, 3] }); + + const aggregatedUpMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedUpMetrics).toEqual({ metric1: 1, metric2: 0.1 }); + }); + + test('should handle missing values', () => { + const testMetricNames = new Set(['metric1', 'metric2']); + const metrics = new EvaluationMetrics(testMetricNames); + + metrics.addResults({ metric1: 1 }); + metrics.addResults({ metric2: 0.2 }); + + const aggregatedMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedMetrics).toEqual({ metric1: 1, metric2: 0.2 }); + }); + + test('should handle empty metrics', () => { + const testMetricNames = new Set(['metric1', 'metric2']); + const metrics = new EvaluationMetrics(testMetricNames); + + const aggregatedMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedMetrics).toEqual({}); + }); + + test('should handle empty testMetrics', () => { + const metrics = new EvaluationMetrics(new Set()); + + metrics.addResults({ metric1: 1, metric2: 0 }); + metrics.addResults({ metric1: 0.5, metric2: 0.2 }); + + const aggregatedMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedMetrics).toEqual({}); + }); + + test('should ignore non-relevant values', () => { + const testMetricNames = new Set(['metric1']); + const metrics = new EvaluationMetrics(testMetricNames); + + metrics.addResults({ metric1: 1, notRelevant: 0 }); + metrics.addResults({ metric1: 0.5, notRelevant2: { foo: 'bar' } }); + + const aggregatedMetrics = metrics.getAggregatedMetrics(); + + expect(aggregatedMetrics).toEqual({ metric1: 0.75 }); + }); +}); diff --git a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json b/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json index c2386f010c..6ec7f2c386 100644 --- a/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json +++ b/packages/cli/src/evaluation/test-runner/__tests__/mock-data/workflow.evaluation.json @@ -57,6 +57,12 @@ "name": "success", "value": true, "type": "boolean" + }, + { + "id": "877d1bf8-31a7-4571-9293-a6837b51d22b", + "name": "metric1", + "value": 0.1, + "type": "number" } ] }, diff --git a/packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts b/packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts index 5c8f8e958b..cdb8e848d9 100644 --- a/packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts +++ b/packages/cli/src/evaluation/test-runner/__tests__/test-runner.service.ee.test.ts @@ -2,15 +2,17 @@ import type { SelectQueryBuilder } from '@n8n/typeorm'; import { stringify } from 'flatted'; import { readFileSync } from 'fs'; import { mock, mockDeep } from 'jest-mock-extended'; -import type { IRun } from 'n8n-workflow'; +import type { GenericValue, IRun } from 'n8n-workflow'; import path from 'path'; import type { ActiveExecutions } from '@/active-executions'; import type { ExecutionEntity } from '@/databases/entities/execution-entity'; import type { TestDefinition } from '@/databases/entities/test-definition.ee'; +import type { TestMetric } from '@/databases/entities/test-metric.ee'; import type { TestRun } from '@/databases/entities/test-run.ee'; import type { User } from '@/databases/entities/user'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import type { TestMetricRepository } from '@/databases/repositories/test-metric.repository.ee'; import type { TestRunRepository } from '@/databases/repositories/test-run.repository.ee'; import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { WorkflowRunner } from '@/workflow-runner'; @@ -58,12 +60,38 @@ function mockExecutionData() { }); } +function mockEvaluationExecutionData(metrics: Record) { + return mock({ + data: { + resultData: { + lastNodeExecuted: 'lastNode', + runData: { + lastNode: [ + { + data: { + main: [ + [ + { + json: metrics, + }, + ], + ], + }, + }, + ], + }, + }, + }, + }); +} + describe('TestRunnerService', () => { const executionRepository = mock(); const workflowRepository = mock(); const workflowRunner = mock(); const activeExecutions = mock(); const testRunRepository = mock(); + const testMetricRepository = mock(); beforeEach(() => { const executionsQbMock = mockDeep>({ @@ -80,6 +108,11 @@ describe('TestRunnerService', () => { .mockResolvedValueOnce(executionMocks[1]); testRunRepository.createTestRun.mockResolvedValue(mock({ id: 'test-run-id' })); + + testMetricRepository.find.mockResolvedValue([ + mock({ name: 'metric1' }), + mock({ name: 'metric2' }), + ]); }); afterEach(() => { @@ -97,6 +130,7 @@ describe('TestRunnerService', () => { executionRepository, activeExecutions, testRunRepository, + testMetricRepository, ); expect(testRunnerService).toBeInstanceOf(TestRunnerService); @@ -109,6 +143,7 @@ describe('TestRunnerService', () => { executionRepository, activeExecutions, testRunRepository, + testMetricRepository, ); workflowRepository.findById.calledWith('workflow-under-test-id').mockResolvedValueOnce({ @@ -143,6 +178,7 @@ describe('TestRunnerService', () => { executionRepository, activeExecutions, testRunRepository, + testMetricRepository, ); workflowRepository.findById.calledWith('workflow-under-test-id').mockResolvedValueOnce({ @@ -166,17 +202,17 @@ describe('TestRunnerService', () => { .mockResolvedValue(mockExecutionData()); activeExecutions.getPostExecutePromise - .calledWith('some-execution-id-2') + .calledWith('some-execution-id-3') .mockResolvedValue(mockExecutionData()); // Mock executions of evaluation workflow activeExecutions.getPostExecutePromise - .calledWith('some-execution-id-3') - .mockResolvedValue(mockExecutionData()); + .calledWith('some-execution-id-2') + .mockResolvedValue(mockEvaluationExecutionData({ metric1: 1, metric2: 0 })); activeExecutions.getPostExecutePromise .calledWith('some-execution-id-4') - .mockResolvedValue(mockExecutionData()); + .mockResolvedValue(mockEvaluationExecutionData({ metric1: 0.5 })); await testRunnerService.runTest( mock(), @@ -225,7 +261,8 @@ describe('TestRunnerService', () => { expect(testRunRepository.markAsRunning).toHaveBeenCalledWith('test-run-id'); expect(testRunRepository.markAsCompleted).toHaveBeenCalledTimes(1); expect(testRunRepository.markAsCompleted).toHaveBeenCalledWith('test-run-id', { - success: false, + metric1: 0.75, + metric2: 0, }); }); }); diff --git a/packages/cli/src/evaluation/test-runner/evaluation-metrics.ee.ts b/packages/cli/src/evaluation/test-runner/evaluation-metrics.ee.ts new file mode 100644 index 0000000000..ab5c921f8c --- /dev/null +++ b/packages/cli/src/evaluation/test-runner/evaluation-metrics.ee.ts @@ -0,0 +1,32 @@ +import type { IDataObject } from 'n8n-workflow'; + +export class EvaluationMetrics { + private readonly rawMetricsByName = new Map(); + + constructor(private readonly metricNames: Set) { + for (const metricName of metricNames) { + this.rawMetricsByName.set(metricName, []); + } + } + + addResults(result: IDataObject) { + for (const [metricName, metricValue] of Object.entries(result)) { + if (typeof metricValue === 'number' && this.metricNames.has(metricName)) { + this.rawMetricsByName.get(metricName)!.push(metricValue); + } + } + } + + getAggregatedMetrics() { + const aggregatedMetrics: Record = {}; + + for (const [metricName, metricValues] of this.rawMetricsByName.entries()) { + if (metricValues.length > 0) { + const metricSum = metricValues.reduce((acc, val) => acc + val, 0); + aggregatedMetrics[metricName] = metricSum / metricValues.length; + } + } + + return aggregatedMetrics; + } +} diff --git a/packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts b/packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts index 433a84c9dc..5aaaf25558 100644 --- a/packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts +++ b/packages/cli/src/evaluation/test-runner/test-runner.service.ee.ts @@ -15,11 +15,13 @@ import type { TestDefinition } from '@/databases/entities/test-definition.ee'; import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { TestMetricRepository } from '@/databases/repositories/test-metric.repository.ee'; import { TestRunRepository } from '@/databases/repositories/test-run.repository.ee'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { getRunData } from '@/workflow-execute-additional-data'; import { WorkflowRunner } from '@/workflow-runner'; +import { EvaluationMetrics } from './evaluation-metrics.ee'; import { createPinData, getPastExecutionStartNode } from './utils.ee'; /** @@ -40,6 +42,7 @@ export class TestRunnerService { private readonly executionRepository: ExecutionRepository, private readonly activeExecutions: ActiveExecutions, private readonly testRunRepository: TestRunRepository, + private readonly testMetricRepository: TestMetricRepository, ) {} /** @@ -113,6 +116,11 @@ export class TestRunnerService { return await executePromise; } + /** + * Evaluation result is the first item in the output of the last node + * executed in the evaluation workflow. Defaults to an empty object + * in case the node doesn't produce any output items. + */ private extractEvaluationResult(execution: IRun): IDataObject { const lastNodeExecuted = execution.data.resultData.lastNodeExecuted; assert(lastNodeExecuted, 'Could not find the last node executed in evaluation workflow'); @@ -124,6 +132,21 @@ export class TestRunnerService { return mainConnectionData?.[0]?.json ?? {}; } + /** + * Get the metrics to collect from the evaluation workflow execution results. + */ + private async getTestMetricNames(testDefinitionId: string) { + const metrics = await this.testMetricRepository.find({ + where: { + testDefinition: { + id: testDefinitionId, + }, + }, + }); + + return new Set(metrics.map((m) => m.name)); + } + /** * Creates a new test run for the given test definition. */ @@ -152,11 +175,15 @@ export class TestRunnerService { .andWhere('execution.workflowId = :workflowId', { workflowId: test.workflowId }) .getMany(); + // Get the metrics to collect from the evaluation workflow + const testMetricNames = await this.getTestMetricNames(test.id); + // 2. Run over all the test cases await this.testRunRepository.markAsRunning(testRun.id); - const metrics = []; + // Object to collect the results of the evaluation workflow executions + const metrics = new EvaluationMetrics(testMetricNames); for (const { id: pastExecutionId } of pastExecutions) { // Fetch past execution with data @@ -192,12 +219,10 @@ export class TestRunnerService { assert(evalExecution); // Extract the output of the last node executed in the evaluation workflow - metrics.push(this.extractEvaluationResult(evalExecution)); + metrics.addResults(this.extractEvaluationResult(evalExecution)); } - // TODO: 3. Aggregate the results - // Now we just set success to true if all the test cases passed - const aggregatedMetrics = { success: metrics.every((metric) => metric.success) }; + const aggregatedMetrics = metrics.getAggregatedMetrics(); await this.testRunRepository.markAsCompleted(testRun.id, aggregatedMetrics); } diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index 60dadfdc1b..67eb145b19 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -251,7 +251,7 @@ export class ExecutionService { requestFilters = requestFiltersRaw as IGetExecutionsQueryFilter; } } catch (error) { - throw new InternalServerError('Parameter "filter" contained invalid JSON string.'); + throw new InternalServerError('Parameter "filter" contained invalid JSON string.', error); } } diff --git a/packages/cli/src/mfa/mfa.service.ts b/packages/cli/src/mfa/mfa.service.ts index 5f730b7bf1..afce8927f9 100644 --- a/packages/cli/src/mfa/mfa.service.ts +++ b/packages/cli/src/mfa/mfa.service.ts @@ -56,13 +56,13 @@ export class MfaService { async validateMfa( userId: string, - mfaToken: string | undefined, + mfaCode: string | undefined, mfaRecoveryCode: string | undefined, ) { const user = await this.authUserRepository.findOneByOrFail({ id: userId }); - if (mfaToken) { + if (mfaCode) { const decryptedSecret = this.cipher.decrypt(user.mfaSecret!); - return this.totp.verifySecret({ secret: decryptedSecret, token: mfaToken }); + return this.totp.verifySecret({ secret: decryptedSecret, mfaCode }); } if (mfaRecoveryCode) { @@ -85,8 +85,8 @@ export class MfaService { return await this.authUserRepository.save(user); } - async disableMfa(userId: string, mfaToken: string) { - const isValidToken = await this.validateMfa(userId, mfaToken, undefined); + async disableMfa(userId: string, mfaCode: string) { + const isValidToken = await this.validateMfa(userId, mfaCode, undefined); if (!isValidToken) { throw new InvalidMfaCodeError(); } diff --git a/packages/cli/src/mfa/totp.service.ts b/packages/cli/src/mfa/totp.service.ts index cbb1f65aac..ec9f651635 100644 --- a/packages/cli/src/mfa/totp.service.ts +++ b/packages/cli/src/mfa/totp.service.ts @@ -23,10 +23,14 @@ export class TOTPService { }).toString(); } - verifySecret({ secret, token, window = 2 }: { secret: string; token: string; window?: number }) { + verifySecret({ + secret, + mfaCode, + window = 2, + }: { secret: string; mfaCode: string; window?: number }) { return new OTPAuth.TOTP({ secret: OTPAuth.Secret.fromBase32(secret), - }).validate({ token, window }) === null + }).validate({ token: mfaCode, window }) === null ? false : true; } diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index f233d7db46..72d6fcf135 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -228,7 +228,7 @@ export declare namespace PasswordResetRequest { export type NewPassword = AuthlessRequest< {}, {}, - Pick & { token?: string; userId?: string; mfaToken?: string } + Pick & { token?: string; userId?: string; mfaCode?: string } >; } @@ -306,7 +306,7 @@ export type LoginRequest = AuthlessRequest< { email: string; password: string; - mfaToken?: string; + mfaCode?: string; mfaRecoveryCode?: string; } >; @@ -316,9 +316,9 @@ export type LoginRequest = AuthlessRequest< // ---------------------------------- export declare namespace MFA { - type Verify = AuthenticatedRequest<{}, {}, { token: string }, {}>; - type Activate = AuthenticatedRequest<{}, {}, { token: string }, {}>; - type Disable = AuthenticatedRequest<{}, {}, { token: string }, {}>; + type Verify = AuthenticatedRequest<{}, {}, { mfaCode: string }, {}>; + type Activate = AuthenticatedRequest<{}, {}, { mfaCode: string }, {}>; + type Disable = AuthenticatedRequest<{}, {}, { mfaCode: string }, {}>; type Config = AuthenticatedRequest<{}, {}, { login: { enabled: boolean } }, {}>; type ValidateRecoveryCode = AuthenticatedRequest< {}, diff --git a/packages/cli/src/services/user-onboarding.service.ts b/packages/cli/src/services/user-onboarding.service.ts deleted file mode 100644 index 5e92830a87..0000000000 --- a/packages/cli/src/services/user-onboarding.service.ts +++ /dev/null @@ -1,72 +0,0 @@ -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In } from '@n8n/typeorm'; -import { Service } from 'typedi'; - -import type { User } from '@/databases/entities/user'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { UserService } from '@/services/user.service'; - -@Service() -export class UserOnboardingService { - constructor( - private readonly sharedWorkflowRepository: SharedWorkflowRepository, - private readonly workflowRepository: WorkflowRepository, - private readonly userService: UserService, - ) {} - - /** - * Check if user owns more than 15 workflows or more than 2 workflows with at least 2 nodes. - * If user does, set flag in its settings. - */ - async isBelowThreshold(user: User): Promise { - let belowThreshold = true; - const skippedTypes = ['n8n-nodes-base.start', 'n8n-nodes-base.stickyNote']; - - const ownedWorkflowsIds = await this.sharedWorkflowRepository - .find({ - where: { - project: { - projectRelations: { - role: 'project:personalOwner', - userId: user.id, - }, - }, - role: 'workflow:owner', - }, - select: ['workflowId'], - }) - .then((ownedWorkflows) => ownedWorkflows.map(({ workflowId }) => workflowId)); - - if (ownedWorkflowsIds.length > 15) { - belowThreshold = false; - } else { - // just fetch workflows' nodes to keep memory footprint low - const workflows = await this.workflowRepository.find({ - where: { id: In(ownedWorkflowsIds) }, - select: ['nodes'], - }); - - // valid workflow: 2+ nodes without start node - const validWorkflowCount = workflows.reduce((counter, workflow) => { - if (counter <= 2 && workflow.nodes.length > 2) { - const nodes = workflow.nodes.filter((node) => !skippedTypes.includes(node.type)); - if (nodes.length >= 2) { - return counter + 1; - } - } - return counter; - }, 0); - - // more than 2 valid workflows required - belowThreshold = validWorkflowCount <= 2; - } - - // user is above threshold --> set flag in settings - if (!belowThreshold) { - void this.userService.updateSettings(user.id, { isOnboarded: true }); - } - - return belowThreshold; - } -} diff --git a/packages/cli/src/services/user.service.ts b/packages/cli/src/services/user.service.ts index ba02375aba..e47dd026b0 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -1,5 +1,5 @@ import type { IUserSettings } from 'n8n-workflow'; -import { ApplicationError, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; import type { User, AssignableRole } from '@/databases/entities/user'; @@ -213,9 +213,8 @@ export class UserService { ), ); } catch (error) { - ErrorReporter.error(error); this.logger.error('Failed to create user shells', { userShells: createdUsers }); - throw new InternalServerError('An error occurred during user creation'); + throw new InternalServerError('An error occurred during user creation', error); } pendingUsersToInvite.forEach(({ email, id }) => createdUsers.set(email, id)); diff --git a/packages/cli/src/user-management/email/user-management-mailer.ts b/packages/cli/src/user-management/email/user-management-mailer.ts index b5df958d7d..3acddad185 100644 --- a/packages/cli/src/user-management/email/user-management-mailer.ts +++ b/packages/cli/src/user-management/email/user-management-mailer.ts @@ -125,7 +125,7 @@ export class UserManagementMailer { const error = toError(e); - throw new InternalServerError(`Please contact your administrator: ${error.message}`); + throw new InternalServerError(`Please contact your administrator: ${error.message}`, e); } } @@ -180,7 +180,7 @@ export class UserManagementMailer { const error = toError(e); - throw new InternalServerError(`Please contact your administrator: ${error.message}`); + throw new InternalServerError(`Please contact your administrator: ${error.message}`, e); } } diff --git a/packages/cli/src/webhooks/webhook-helpers.ts b/packages/cli/src/webhooks/webhook-helpers.ts index c3fbc5c018..259142561a 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -773,7 +773,7 @@ export async function executeWebhook( ); } - const internalServerError = new InternalServerError(e.message); + const internalServerError = new InternalServerError(e.message, e); if (e instanceof ExecutionCancelledError) internalServerError.level = 'warning'; throw internalServerError; }); diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index 59f53e0df1..24765b422a 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -33,7 +33,6 @@ import * as ResponseHelper from '@/response-helper'; import { NamingService } from '@/services/naming.service'; import { ProjectService } from '@/services/project.service'; import { TagService } from '@/services/tag.service'; -import { UserOnboardingService } from '@/services/user-onboarding.service'; import { UserManagementMailer } from '@/user-management/email'; import * as utils from '@/utils'; import * as WorkflowHelpers from '@/workflow-helpers'; @@ -55,7 +54,6 @@ export class WorkflowsController { private readonly workflowHistoryService: WorkflowHistoryService, private readonly tagService: TagService, private readonly namingService: NamingService, - private readonly userOnboardingService: UserOnboardingService, private readonly workflowRepository: WorkflowRepository, private readonly workflowService: WorkflowService, private readonly workflowExecutionService: WorkflowExecutionService, @@ -213,13 +211,7 @@ export class WorkflowsController { const requestedName = req.query.name ?? this.globalConfig.workflows.defaultName; const name = await this.namingService.getUniqueWorkflowName(requestedName); - - const onboardingFlowEnabled = - !this.globalConfig.workflows.onboardingFlowDisabled && - !req.user.settings?.isOnboarded && - (await this.userOnboardingService.isBelowThreshold(req.user)); - - return { name, onboardingFlowEnabled }; + return { name }; } @Get('/from-url') diff --git a/packages/cli/test/integration/auth.api.test.ts b/packages/cli/test/integration/auth.api.test.ts index 2880526668..6c1ddc5892 100644 --- a/packages/cli/test/integration/auth.api.test.ts +++ b/packages/cli/test/integration/auth.api.test.ts @@ -89,7 +89,7 @@ describe('POST /login', () => { const response = await testServer.authlessAgent.post('/login').send({ email: owner.email, password: ownerPassword, - mfaToken: mfaService.totp.generateTOTP(secret), + mfaCode: mfaService.totp.generateTOTP(secret), }); expect(response.statusCode).toBe(200); diff --git a/packages/cli/test/integration/mfa/mfa.api.test.ts b/packages/cli/test/integration/mfa/mfa.api.test.ts index 3f19632506..95c3334277 100644 --- a/packages/cli/test/integration/mfa/mfa.api.test.ts +++ b/packages/cli/test/integration/mfa/mfa.api.test.ts @@ -55,8 +55,8 @@ describe('Enable MFA setup', () => { secondCall.body.data.recoveryCodes.join(''), ); - const token = new TOTPService().generateTOTP(firstCall.body.data.secret); - await testServer.authAgentFor(owner).post('/mfa/disable').send({ token }).expect(200); + const mfaCode = new TOTPService().generateTOTP(firstCall.body.data.secret); + await testServer.authAgentFor(owner).post('/mfa/disable').send({ mfaCode }).expect(200); const thirdCall = await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); @@ -84,22 +84,22 @@ describe('Enable MFA setup', () => { await testServer.authlessAgent.post('/mfa/verify').expect(401); }); - test('POST /verify should fail due to invalid MFA token', async () => { - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token: '123' }).expect(400); + test('POST /verify should fail due to invalid MFA code', async () => { + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode: '123' }).expect(400); }); - test('POST /verify should fail due to missing token parameter', async () => { + test('POST /verify should fail due to missing mfaCode parameter', async () => { await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token: '' }).expect(400); + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode: '' }).expect(400); }); - test('POST /verify should validate MFA token', async () => { + test('POST /verify should validate MFA code', async () => { const response = await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); const { secret } = response.body.data; - const token = new TOTPService().generateTOTP(secret); + const mfaCode = new TOTPService().generateTOTP(secret); - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token }).expect(200); + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode }).expect(200); }); }); @@ -108,13 +108,13 @@ describe('Enable MFA setup', () => { await testServer.authlessAgent.post('/mfa/enable').expect(401); }); - test('POST /verify should fail due to missing token parameter', async () => { - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token: '' }).expect(400); + test('POST /verify should fail due to missing mfaCode parameter', async () => { + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode: '' }).expect(400); }); - test('POST /enable should fail due to invalid MFA token', async () => { + test('POST /enable should fail due to invalid MFA code', async () => { await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); - await testServer.authAgentFor(owner).post('/mfa/enable').send({ token: '123' }).expect(400); + await testServer.authAgentFor(owner).post('/mfa/enable').send({ mfaCode: '123' }).expect(400); }); test('POST /enable should fail due to empty secret and recovery codes', async () => { @@ -125,10 +125,10 @@ describe('Enable MFA setup', () => { const response = await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); const { secret } = response.body.data; - const token = new TOTPService().generateTOTP(secret); + const mfaCode = new TOTPService().generateTOTP(secret); - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token }).expect(200); - await testServer.authAgentFor(owner).post('/mfa/enable').send({ token }).expect(200); + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode }).expect(200); + await testServer.authAgentFor(owner).post('/mfa/enable').send({ mfaCode }).expect(200); const user = await Container.get(AuthUserRepository).findOneOrFail({ where: {}, @@ -145,13 +145,13 @@ describe('Enable MFA setup', () => { const response = await testServer.authAgentFor(owner).get('/mfa/qr').expect(200); const { secret } = response.body.data; - const token = new TOTPService().generateTOTP(secret); + const mfaCode = new TOTPService().generateTOTP(secret); - await testServer.authAgentFor(owner).post('/mfa/verify').send({ token }).expect(200); + await testServer.authAgentFor(owner).post('/mfa/verify').send({ mfaCode }).expect(200); externalHooks.run.mockRejectedValue(new BadRequestError('Error message')); - await testServer.authAgentFor(owner).post('/mfa/enable').send({ token }).expect(400); + await testServer.authAgentFor(owner).post('/mfa/enable').send({ mfaCode }).expect(400); const user = await Container.get(AuthUserRepository).findOneOrFail({ where: {}, @@ -165,13 +165,13 @@ describe('Enable MFA setup', () => { describe('Disable MFA setup', () => { test('POST /disable should disable login with MFA', async () => { const { user, rawSecret } = await createUserWithMfaEnabled(); - const token = new TOTPService().generateTOTP(rawSecret); + const mfaCode = new TOTPService().generateTOTP(rawSecret); await testServer .authAgentFor(user) .post('/mfa/disable') .send({ - token, + mfaCode, }) .expect(200); @@ -184,21 +184,21 @@ describe('Disable MFA setup', () => { expect(dbUser.mfaRecoveryCodes.length).toBe(0); }); - test('POST /disable should fail if invalid token is given', async () => { + test('POST /disable should fail if invalid mfaCode is given', async () => { const { user } = await createUserWithMfaEnabled(); await testServer .authAgentFor(user) .post('/mfa/disable') .send({ - token: 'invalid token', + mfaCode: 'invalid token', }) .expect(403); }); }); describe('Change password with MFA enabled', () => { - test('POST /change-password should fail due to missing MFA token', async () => { + test('POST /change-password should fail due to missing MFA code', async () => { await createUserWithMfaEnabled(); const newPassword = randomValidPassword(); @@ -210,7 +210,7 @@ describe('Change password with MFA enabled', () => { .expect(404); }); - test('POST /change-password should fail due to invalid MFA token', async () => { + test('POST /change-password should fail due to invalid MFA code', async () => { await createUserWithMfaEnabled(); const newPassword = randomValidPassword(); @@ -221,7 +221,7 @@ describe('Change password with MFA enabled', () => { .send({ password: newPassword, token: resetPasswordToken, - mfaToken: randomInt(10), + mfaCode: randomInt(10), }) .expect(404); }); @@ -235,14 +235,14 @@ describe('Change password with MFA enabled', () => { const resetPasswordToken = Container.get(AuthService).generatePasswordResetToken(user); - const mfaToken = new TOTPService().generateTOTP(rawSecret); + const mfaCode = new TOTPService().generateTOTP(rawSecret); await testServer.authlessAgent .post('/change-password') .send({ password: newPassword, token: resetPasswordToken, - mfaToken, + mfaCode, }) .expect(200); @@ -252,7 +252,7 @@ describe('Change password with MFA enabled', () => { .send({ email: user.email, password: newPassword, - mfaToken: new TOTPService().generateTOTP(rawSecret), + mfaCode: new TOTPService().generateTOTP(rawSecret), }) .expect(200); @@ -315,7 +315,7 @@ describe('Login', () => { await testServer.authlessAgent .post('/login') - .send({ email: user.email, password: rawPassword, mfaToken: 'wrongvalue' }) + .send({ email: user.email, password: rawPassword, mfaCode: 'wrongvalue' }) .expect(401); }); @@ -337,7 +337,7 @@ describe('Login', () => { const response = await testServer.authlessAgent .post('/login') - .send({ email: user.email, password: rawPassword, mfaToken: token }) + .send({ email: user.email, password: rawPassword, mfaCode: token }) .expect(200); const data = response.body.data; diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 5e1fecdfac..808bc17c9b 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -1194,7 +1194,7 @@ export class WorkflowExecute { } if (nodeSuccessData instanceof NodeExecutionOutput) { - const hints: NodeExecutionHint[] = nodeSuccessData.getHints(); + const hints = (nodeSuccessData as NodeExecutionOutput).getHints(); executionHints.push(...hints); } diff --git a/packages/editor-ui/public/static/quickstart_thumbnail.png b/packages/editor-ui/public/static/quickstart_thumbnail.png deleted file mode 100644 index 2958955a2c..0000000000 Binary files a/packages/editor-ui/public/static/quickstart_thumbnail.png and /dev/null differ diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 20b7079b6f..40e3a64584 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -250,7 +250,6 @@ export interface IWorkflowToShare extends IWorkflowDataUpdate { export interface NewWorkflowResponse { name: string; - onboardingFlowEnabled?: boolean; defaultSettings: IWorkflowSettings; } @@ -277,7 +276,6 @@ export interface IWorkflowTemplate { export interface INewWorkflowData { name: string; - onboardingFlowEnabled: boolean; } export interface WorkflowMetadata { diff --git a/packages/editor-ui/src/api/mfa.ts b/packages/editor-ui/src/api/mfa.ts index 0cce31c96d..a28e2146b1 100644 --- a/packages/editor-ui/src/api/mfa.ts +++ b/packages/editor-ui/src/api/mfa.ts @@ -11,19 +11,22 @@ export async function getMfaQR( return await makeRestApiRequest(context, 'GET', '/mfa/qr'); } -export async function enableMfa(context: IRestApiContext, data: { token: string }): Promise { +export async function enableMfa( + context: IRestApiContext, + data: { mfaCode: string }, +): Promise { return await makeRestApiRequest(context, 'POST', '/mfa/enable', data); } -export async function verifyMfaToken( +export async function verifyMfaCode( context: IRestApiContext, - data: { token: string }, + data: { mfaCode: string }, ): Promise { return await makeRestApiRequest(context, 'POST', '/mfa/verify', data); } export type DisableMfaParams = { - token: string; + mfaCode: string; }; export async function disableMfa(context: IRestApiContext, data: DisableMfaParams): Promise { diff --git a/packages/editor-ui/src/api/users.ts b/packages/editor-ui/src/api/users.ts index ea14cb6c79..bff4f65fac 100644 --- a/packages/editor-ui/src/api/users.ts +++ b/packages/editor-ui/src/api/users.ts @@ -21,7 +21,7 @@ export async function loginCurrentUser( export async function login( context: IRestApiContext, - params: { email: string; password: string; mfaToken?: string; mfaRecoveryToken?: string }, + params: { email: string; password: string; mfaCode?: string; mfaRecoveryToken?: string }, ): Promise { return await makeRestApiRequest(context, 'POST', '/login', params); } @@ -84,7 +84,7 @@ export async function validatePasswordToken( export async function changePassword( context: IRestApiContext, - params: { token: string; password: string; mfaToken?: string }, + params: { token: string; password: string; mfaCode?: string }, ): Promise { await makeRestApiRequest(context, 'POST', '/change-password', params); } diff --git a/packages/editor-ui/src/api/workflows.ts b/packages/editor-ui/src/api/workflows.ts index c65c788ae2..e565a95c9e 100644 --- a/packages/editor-ui/src/api/workflows.ts +++ b/packages/editor-ui/src/api/workflows.ts @@ -22,7 +22,6 @@ export async function getNewWorkflow(context: IRestApiContext, data?: IDataObjec ); return { name: response.name, - onboardingFlowEnabled: response.onboardingFlowEnabled === true, settings: response.defaultSettings, }; } diff --git a/packages/editor-ui/src/components/CanvasChat/CanvasChat.vue b/packages/editor-ui/src/components/CanvasChat/CanvasChat.vue index 7b27cf4b3d..adfbc8cdd4 100644 --- a/packages/editor-ui/src/components/CanvasChat/CanvasChat.vue +++ b/packages/editor-ui/src/components/CanvasChat/CanvasChat.vue @@ -283,7 +283,7 @@ watchEffect(() => { :style="rootStyles" @resize="onResizeDebounced" > -
+
- +