mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 09:17:08 +02:00
refactor(editor): Extract assistant code into features (no-changelog) (#20419)
This commit is contained in:
parent
50d63718c9
commit
1c39bf2652
|
|
@ -1,8 +1,8 @@
|
|||
<script setup lang="ts">
|
||||
import '@/polyfills';
|
||||
|
||||
import AssistantsHub from '@/components/AskAssistant/AssistantsHub.vue';
|
||||
import AskAssistantFloatingButton from '@/components/AskAssistant/Chat/AskAssistantFloatingButton.vue';
|
||||
import AssistantsHub from '@/features/assistant/components/AssistantsHub.vue';
|
||||
import AskAssistantFloatingButton from '@/features/assistant/components/Chat/AskAssistantFloatingButton.vue';
|
||||
import BannerStack from '@/components/banners/BannerStack.vue';
|
||||
import Modals from '@/components/Modals.vue';
|
||||
import Telemetry from '@/components/Telemetry.vue';
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
HIRING_BANNER,
|
||||
VIEWS,
|
||||
} from '@/constants';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useBuilderStore } from '@/stores/builder.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { chatWithBuilder, getBuilderCredits } from './ai';
|
||||
import * as apiUtils from '@n8n/rest-api-client';
|
||||
import type { IRestApiContext } from '@n8n/rest-api-client';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { vi, describe, it, beforeEach, afterEach, expect } from 'vitest';
|
||||
import type { MockInstance } from 'vitest';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { useAIAssistantHelpers } from '@/composables/useAIAssistantHelpers';
|
||||
import { useAIAssistantHelpers } from '@/features/assistant/composables/useAIAssistantHelpers';
|
||||
import { AI_ASSISTANT_MAX_CONTENT_LENGTH } from '@/constants';
|
||||
import type { ICredentialsResponse } from '@/Interface';
|
||||
import type { IRestApiContext } from '@n8n/rest-api-client';
|
||||
import type { AskAiRequest, ChatRequest, ReplaceCodeRequest } from '@/types/assistant.types';
|
||||
import type {
|
||||
AskAiRequest,
|
||||
ChatRequest,
|
||||
ReplaceCodeRequest,
|
||||
} from '@/features/assistant/assistant.types';
|
||||
import { makeRestApiRequest, streamRequest } from '@n8n/rest-api-client';
|
||||
import { getObjectSizeInKB } from '@/utils/objectUtils';
|
||||
import type { IDataObject } from 'n8n-workflow';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|||
import { generateCodeForAiTransform, reducePayloadSizeOrThrow } from './utils';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { generateCodeForPrompt } from '@/api/ai';
|
||||
import type { AskAiRequest } from '@/types/assistant.types';
|
||||
import type { AskAiRequest } from '@/features/assistant/assistant.types';
|
||||
import type { Schema } from '@/Interface';
|
||||
|
||||
vi.mock('./utils', async () => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { useDataSchema } from '@/composables/useDataSchema';
|
|||
import { executionDataToJson } from '@/utils/nodeTypesUtils';
|
||||
import { generateCodeForPrompt } from '@/api/ai';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
import { type AskAiRequest } from '@/types/assistant.types';
|
||||
import { type AskAiRequest } from '@/features/assistant/assistant.types';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { format } from 'prettier';
|
||||
import jsParser from 'prettier/plugins/babel';
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import {
|
|||
ASK_AI_MIN_PROMPT_LENGTH,
|
||||
ASK_AI_LOADING_DURATION_MS,
|
||||
} from '@/constants';
|
||||
import type { AskAiRequest } from '@/types/assistant.types';
|
||||
import type { AskAiRequest } from '@/features/assistant/assistant.types';
|
||||
const emit = defineEmits<{
|
||||
submit: [code: string];
|
||||
replaceCode: [code: string];
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import CopyInput from '../CopyInput.vue';
|
|||
import CredentialInputs from './CredentialInputs.vue';
|
||||
import GoogleAuthButton from './GoogleAuthButton.vue';
|
||||
import OauthButton from './OauthButton.vue';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import FreeAiCreditsCallout from '@/components/FreeAiCreditsCallout.vue';
|
||||
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { mockedStore } from '@/__tests__/utils';
|
|||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
import type { IExecutionResponse } from '@/Interface';
|
||||
import NodeErrorView from '@/components/Error/NodeErrorView.vue';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import type {
|
|||
import { sanitizeHtml } from '@/utils/htmlUtils';
|
||||
import { MAX_DISPLAY_DATA_SIZE, NEW_ASSISTANT_SESSION_MODAL, VIEWS } from '@/constants';
|
||||
import type { BaseTextKey } from '@n8n/i18n';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { isCommunityPackageName } from '@/utils/nodeTypesUtils';
|
||||
import { useAIAssistantHelpers } from '@/composables/useAIAssistantHelpers';
|
||||
import { useAIAssistantHelpers } from '@/features/assistant/composables/useAIAssistantHelpers';
|
||||
import {
|
||||
N8nInlineAskAssistantButton,
|
||||
N8nButton,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import {
|
|||
import AboutModal from '@/components/AboutModal.vue';
|
||||
import ActivationModal from '@/components/ActivationModal.vue';
|
||||
import ApiKeyCreateOrEditModal from '@/components/ApiKeyCreateOrEditModal.vue';
|
||||
import NewAssistantSessionModal from '@/components/AskAssistant/Chat/NewAssistantSessionModal.vue';
|
||||
import NewAssistantSessionModal from '@/features/assistant/components/Chat/NewAssistantSessionModal.vue';
|
||||
import ChangePasswordModal from '@/components/ChangePasswordModal.vue';
|
||||
import ConfirmPasswordModal from '@/components/ConfirmPasswordModal/ConfirmPasswordModal.vue';
|
||||
import ChatEmbedModal from '@/components/ChatEmbedModal.vue';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import { useActions } from './NodeCreator/composables/useActions';
|
|||
import KeyboardShortcutTooltip from '@/components/KeyboardShortcutTooltip.vue';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useBuilderStore } from '@/stores/builder.store';
|
||||
|
||||
import { N8nAssistantIcon, N8nButton, N8nIconButton, N8nTooltip } from '@n8n/design-system';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import NodesListPanel from './Panel/NodesListPanel.vue';
|
|||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { DRAG_EVENT_DATA_KEY } from '@/constants';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useBuilderStore } from '@/stores/builder.store';
|
||||
import type { NodeTypeSelectedPayload } from '@/Interface';
|
||||
import { onClickOutside } from '@vueuse/core';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { useBuilderMessages } from '@/composables/useBuilderMessages';
|
||||
import type { ChatUI } from '@n8n/design-system/types/assistant';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
|
||||
// Mock useI18n to return the keys instead of translations
|
||||
vi.mock('@n8n/i18n', () => ({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
import type { ChatUI } from '@n8n/design-system/types/assistant';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { isTextMessage, isWorkflowUpdatedMessage, isToolMessage } from '@/types/assistant.types';
|
||||
import {
|
||||
isTextMessage,
|
||||
isWorkflowUpdatedMessage,
|
||||
isToolMessage,
|
||||
} from '@/features/assistant/assistant.types';
|
||||
|
||||
export interface MessageProcessingResult {
|
||||
messages: ChatUI.AssistantMessage[];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { NDV_UI_OVERHAUL_EXPERIMENT } from '@/constants';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useLogsStore } from '@/stores/logs.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { createTestingPinia } from '@pinia/testing';
|
|||
import { setActivePinia } from 'pinia';
|
||||
import { nodeExecuteAfter } from './nodeExecuteAfter';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { mockedStore } from '@/__tests__/utils';
|
||||
import type { NodeExecuteAfter } from '@n8n/api-types/push/execution';
|
||||
import { TRIMMED_TASK_DATA_CONNECTIONS_KEY } from 'n8n-workflow';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { NodeExecuteAfter } from '@n8n/api-types/push/execution';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { INodeExecutionData, ITaskData } from 'n8n-workflow';
|
||||
import { TRIMMED_TASK_DATA_CONNECTIONS_KEY } from 'n8n-workflow';
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ import {
|
|||
MAX_CHAT_WIDTH,
|
||||
MIN_CHAT_WIDTH,
|
||||
useAssistantStore,
|
||||
} from '@/stores/assistant.store';
|
||||
import { useWorkflowsStore } from './workflows.store';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import { usePostHog } from './posthog.store';
|
||||
} from '@/features/assistant/assistant.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { defaultSettings } from '../__tests__/defaults';
|
||||
import { defaultSettings } from '@/__tests__/defaults';
|
||||
import merge from 'lodash/merge';
|
||||
import { DEFAULT_POSTHOG_SETTINGS } from './posthog.store.test';
|
||||
import { DEFAULT_POSTHOG_SETTINGS } from '@/stores/posthog.store.test';
|
||||
import { VIEWS } from '@/constants';
|
||||
import { reactive } from 'vue';
|
||||
import * as chatAPI from '@/api/ai';
|
||||
|
|
@ -7,29 +7,29 @@ import {
|
|||
ASK_AI_SLIDE_OUT_DURATION_MS,
|
||||
} from '@/constants';
|
||||
import { STORES } from '@n8n/stores';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import type { ChatUI } from '@n8n/design-system/types/assistant';
|
||||
import { defineStore } from 'pinia';
|
||||
import type { PushPayload } from '@n8n/api-types';
|
||||
import { computed, h, ref, watch } from 'vue';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
import { useUsersStore } from './users.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useSettingsStore } from './settings.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { assert } from '@n8n/utils/assert';
|
||||
import { useWorkflowsStore } from './workflows.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { ICredentialType, INodeParameters, NodeError, INode } from 'n8n-workflow';
|
||||
import { deepCopy } from 'n8n-workflow';
|
||||
import { ndvEventBus, codeNodeEditorEventBus } from '@/event-bus';
|
||||
import { useNDVStore } from './ndv.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import type { IUpdateInformation } from '@/Interface';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useUIStore } from './ui.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import AiUpdatedCodeMessage from '@/components/AiUpdatedCodeMessage.vue';
|
||||
import { useCredentialsStore } from './credentials.store';
|
||||
import { useAIAssistantHelpers } from '@/composables/useAIAssistantHelpers';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import { useAIAssistantHelpers } from '@/features/assistant/composables/useAIAssistantHelpers';
|
||||
|
||||
export const MAX_CHAT_WIDTH = 425;
|
||||
export const MIN_CHAT_WIDTH = 380;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import { useBuilderStore } from '@/stores/builder.store';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useDebounce } from '@/composables/useDebounce';
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
import SlideTransition from '@/components/transitions/SlideTransition.vue';
|
||||
|
|
@ -8,7 +8,7 @@ import AskAssistantBuild from './Agent/AskAssistantBuild.vue';
|
|||
import AskAssistantChat from './Chat/AskAssistantChat.vue';
|
||||
|
||||
import { N8nResizeWrapper } from '@n8n/design-system';
|
||||
import HubSwitcher from '@/components/AskAssistant/HubSwitcher.vue';
|
||||
import HubSwitcher from '@/features/assistant/components/HubSwitcher.vue';
|
||||
|
||||
const builderStore = useBuilderStore();
|
||||
const assistantStore = useAssistantStore();
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { computed, ref } from 'vue';
|
||||
import { N8nAskAssistantChat } from '@n8n/design-system';
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useStyles } from '@/composables/useStyles';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import { useBuilderStore } from '@/stores/builder.store';
|
||||
import { computed } from 'vue';
|
||||
|
||||
|
|
@ -3,8 +3,8 @@ import { NEW_ASSISTANT_SESSION_MODAL } from '@/constants';
|
|||
import Modal from '@/components/Modal.vue';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import { useAssistantStore } from '@/stores/assistant.store';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { useAssistantStore } from '@/features/assistant/assistant.store';
|
||||
import type { ICredentialType } from 'n8n-workflow';
|
||||
|
||||
import { N8nAssistantIcon, N8nAssistantText, N8nButton, N8nText } from '@n8n/design-system';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { VIEWS } from '@/constants';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '../assistant.types';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
export const PAYLOAD_SIZE_FOR_1_PASS = 4;
|
||||
|
|
@ -9,7 +9,7 @@ import { useAIAssistantHelpers } from './useAIAssistantHelpers';
|
|||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
import type { IWorkflowDb } from '@/Interface';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '../assistant.types';
|
||||
import {
|
||||
ERROR_HELPER_TEST_PAYLOAD,
|
||||
PAYLOAD_SIZE_FOR_1_PASS,
|
||||
|
|
@ -7,13 +7,13 @@ import type {
|
|||
NodeOperationError,
|
||||
INode,
|
||||
} from 'n8n-workflow';
|
||||
import { useWorkflowHelpers } from './useWorkflowHelpers';
|
||||
import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { executionDataToJson, getMainAuthField, getNodeAuthOptions } from '@/utils/nodeTypesUtils';
|
||||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import type { ChatRequest } from '../assistant.types';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useDataSchema } from './useDataSchema';
|
||||
import { useDataSchema } from '@/composables/useDataSchema';
|
||||
import { AI_ASSISTANT_MAX_CONTENT_LENGTH, VIEWS } from '@/constants';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import type { IWorkflowDb } from '@/Interface';
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import type { ChatRequest } from '@/types/assistant.types';
|
||||
import { useAIAssistantHelpers } from '@/composables/useAIAssistantHelpers';
|
||||
import type { ChatRequest } from '@/features/assistant/assistant.types';
|
||||
import { useAIAssistantHelpers } from '@/features/assistant/composables/useAIAssistantHelpers';
|
||||
import type { IRunExecutionData, NodeExecutionSchema } from 'n8n-workflow';
|
||||
import type { IWorkflowDb } from '@/Interface';
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,11 @@ import {
|
|||
} from '@/composables/useWorkflowState';
|
||||
import type { Telemetry } from '@/plugins/telemetry';
|
||||
import type { ChatUI } from '@n8n/design-system/types/assistant';
|
||||
import { DEFAULT_CHAT_WIDTH, MAX_CHAT_WIDTH, MIN_CHAT_WIDTH } from './assistant.store';
|
||||
import {
|
||||
DEFAULT_CHAT_WIDTH,
|
||||
MAX_CHAT_WIDTH,
|
||||
MIN_CHAT_WIDTH,
|
||||
} from '@/features/assistant/assistant.store';
|
||||
import { type INodeTypeDescription } from 'n8n-workflow';
|
||||
import type {} from 'n8n-workflow';
|
||||
import { mockedStore } from '@/__tests__/utils';
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import { useI18n } from '@n8n/i18n';
|
|||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useUIStore } from './ui.store';
|
||||
import { usePostHog } from './posthog.store';
|
||||
import { DEFAULT_CHAT_WIDTH, MAX_CHAT_WIDTH, MIN_CHAT_WIDTH } from './assistant.store';
|
||||
import {
|
||||
DEFAULT_CHAT_WIDTH,
|
||||
MAX_CHAT_WIDTH,
|
||||
MIN_CHAT_WIDTH,
|
||||
} from '@/features/assistant/assistant.store';
|
||||
import { useWorkflowsStore } from './workflows.store';
|
||||
import { useBuilderMessages } from '@/composables/useBuilderMessages';
|
||||
import { chatWithBuilder, getAiSessions, getBuilderCredits } from '@/api/ai';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user