Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor): Delete some barrel files and reduce circular dependencies (no-changelog) #7838

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PropType } from 'vue';
import { computed, defineComponent, ref, useCssModule } from 'vue';
import type { DatatableColumn, DatatableRow, DatatableRowDataType } from '../../types';
import { getValueByPath } from '../../utils';
import { useI18n } from '../../composables';
import { useI18n } from '../../composables/useI18n';
import N8nSelect from '../N8nSelect';
import N8nOption from '../N8nOption';
import N8nPagination from '../N8nPagination';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed } from 'vue';
import { useDeviceSupport } from '../../composables';
import { useDeviceSupport } from '../../composables/useDeviceSupport';
import type { KeyboardShortcut } from '../../types/keyboardshortcut';
const props = defineProps<KeyboardShortcut>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useI18n } from '@/composables';
import { useI18n } from '@/composables/useI18n';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import N8nTooltip from '../N8nTooltip';

Expand Down
2 changes: 0 additions & 2 deletions packages/design-system/src/composables/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/design-system/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as locale from './locale';

export { useDeviceSupport } from './composables';
export { useDeviceSupport } from './composables/useDeviceSupport';
export * from './components';
export * from './plugin';
export * from './types';
Expand Down
1 change: 1 addition & 0 deletions packages/design-system/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { defineConfig as defineVitestConfig } from 'vitest/config';

export const vitestConfig = defineVitestConfig({
test: {
silent: true,
globals: true,
environment: 'jsdom',
setupFiles: ['./src/__tests__/setup.ts'],
Expand Down
26 changes: 13 additions & 13 deletions packages/editor-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ import { HIRING_BANNER, VIEWS } from '@/constants';

import { userHelpers } from '@/mixins/userHelpers';
import { loadLanguage } from '@/plugins/i18n';
import { useGlobalLinkActions, useToast, useExternalHooks } from '@/composables';
import {
useUIStore,
useSettingsStore,
useUsersStore,
useRootStore,
useTemplatesStore,
useNodeTypesStore,
useCloudPlanStore,
useSourceControlStore,
useUsageStore,
} from '@/stores';
import useGlobalLinkActions from '@/composables/useGlobalLinkActions';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useToast } from '@/composables/useToast';
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useSettingsStore } from '@/stores/settings.store';
import { useSourceControlStore } from '@/stores/sourceControl.store';
import { useTemplatesStore } from '@/stores/templates.store';
import { useUIStore } from '@/stores/ui.store';
import { useUsageStore } from '@/stores/usage.store';
import { useUsersStore } from '@/stores/users.store';
import { useHistoryHelper } from '@/composables/useHistoryHelper';
import { useRoute } from 'vue-router';
import { runExternalHook } from '@/utils';
import { runExternalHook } from '@/utils/externalHooks';
import { initializeAuthenticatedFeatures } from '@/init';

export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import type { BulkCommand, Undoable } from '@/models/history';
import type { PartialBy, TupleToUnion } from '@/utils/typeHelpers';
import type { Component } from 'vue';
import type { Scope } from '@n8n/permissions';
import type { runExternalHook } from '@/utils';
import type { runExternalHook } from '@/utils/externalHooks';

export * from 'n8n-design-system/types';

Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/__tests__/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createComponentRenderer } from '@/__tests__/render';
import router from '@/router';
import { VIEWS } from '@/constants';
import { setupServer } from '@/__tests__/server';
import { useSettingsStore } from '@/stores';
import { useSettingsStore } from '@/stores/settings.store';

const App = {
template: '<div />',
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/cloudPlans.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Cloud, IRestApiContext, InstanceUsage } from '@/Interface';
import { get, post } from '@/utils';
import { get, post } from '@/utils/apiUtils';

export async function getCurrentPlan(context: IRestApiContext): Promise<Cloud.PlanData> {
return get(context.baseUrl, '/admin/cloud-plan');
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/communityNodes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IRestApiContext } from '@/Interface';
import type { PublicInstalledPackage } from 'n8n-workflow';
import { get, post, makeRestApiRequest } from '@/utils';
import { get, post, makeRestApiRequest } from '@/utils/apiUtils';

export async function getInstalledCommunityNodes(
context: IRestApiContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/environments.ee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EnvironmentVariable, IRestApiContext } from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type { IDataObject } from 'n8n-workflow';

export async function getVariables(context: IRestApiContext): Promise<EnvironmentVariable[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/eventbus.ee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRestApiContext } from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type { IDataObject, MessageEventBusDestinationOptions } from 'n8n-workflow';

export async function saveDestinationToDb(
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/externalSecrets.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ExternalSecretsProvider,
ExternalSecretsProviderWithProperties,
} from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';

export const getExternalSecrets = async (
context: IRestApiContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/orchestration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRestApiContext } from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';

const GET_STATUS_ENDPOINT = '/orchestration/worker/status';

Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/api/sourceControl.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { IDataObject } from 'n8n-workflow';
import type {
IRestApiContext,
SourceControlAggregatedFile,
SourceControlPreferences,
SourceControlStatus,
SshKeyTypes,
} from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import type { IDataObject } from 'n8n-workflow';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type { TupleToUnion } from '@/utils/typeHelpers';

const sourceControlApiRoot = '/source-control';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/sso.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';
import type {
IRestApiContext,
SamlPreferencesLoginEnabled,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/tags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRestApiContext, ITag } from '@/Interface';
import { makeRestApiRequest } from '@/utils';
import { makeRestApiRequest } from '@/utils/apiUtils';

export async function getTags(context: IRestApiContext, withUsageCount = false): Promise<ITag[]> {
return makeRestApiRequest(context, 'GET', '/tags', { withUsageCount });
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/api/workflowHistory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IRestApiContext } from '@/Interface';
import { get } from '@/utils';
import { get } from '@/utils/apiUtils';
import type {
WorkflowHistory,
WorkflowVersion,
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ActivationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
LOCAL_STORAGE_ACTIVATION_FLAG,
VIEWS,
} from '../constants';
import { getActivatableTriggerNodes, getTriggerNodeServiceName } from '@/utils';
import { getActivatableTriggerNodes, getTriggerNodeServiceName } from '@/utils/nodeTypesUtils';
import { useUIStore } from '@/stores/ui.store';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { IBinaryData } from 'n8n-workflow';
import { jsonParse } from 'n8n-workflow';
import type { PropType } from 'vue';
import VueJsonPretty from 'vue-json-pretty';
import { useWorkflowsStore } from '@/stores';
import { useWorkflowsStore } from '@/stores/workflows.store';
import RunDataHtml from '@/components/RunDataHtml.vue';

export default defineComponent({
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/BreakpointsObserver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { BREAKPOINT_SM, BREAKPOINT_MD, BREAKPOINT_LG, BREAKPOINT_XL } from '@/co

import { genericHelpers } from '@/mixins/genericHelpers';
import { debounceHelper } from '@/mixins/debounce';
import { useUIStore } from '@/stores';
import { getBannerRowHeight } from '@/utils';
import { useUIStore } from '@/stores/ui.store';
import { getBannerRowHeight } from '@/utils/htmlUtils';

export default defineComponent({
name: 'BreakpointsObserver',
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ChangePasswordModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import { defineComponent } from 'vue';
import { CHANGE_PASSWORD_MODAL_KEY } from '../constants';
import { useToast } from '@/composables';
import { useToast } from '@/composables/useToast';
import Modal from '@/components/Modal.vue';
import type { IFormInputs } from '@/Interface';
import { mapStores } from 'pinia';
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/ChatEmbedModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import Modal from './Modal.vue';
import { CHAT_EMBED_MODAL_KEY, WEBHOOK_NODE_TYPE } from '../constants';
import { useSettingsStore } from '@/stores/settings.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useWorkflowsStore } from '@/stores';
import { useWorkflowsStore } from '@/stores/workflows.store';
import HtmlEditor from '@/components/HtmlEditor/HtmlEditor.vue';
import CodeNodeEditor from '@/components/CodeNodeEditor/CodeNodeEditor.vue';
import { useI18n } from '@/composables';
import { useI18n } from '@/composables/useI18n';

const props = defineProps({
modalBus: {
Expand Down
13 changes: 10 additions & 3 deletions packages/editor-ui/src/components/CodeNodeEditor/AskAI/AskAI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import type { CodeExecutionMode, INodeExecutionData } from 'n8n-workflow';
import type { BaseTextKey } from '@/plugins/i18n';
import type { INodeUi, Schema } from '@/Interface';
import { generateCodeForPrompt } from '@/api/ai';
import { useDataSchema, useI18n, useMessage, useTelemetry, useToast } from '@/composables';
import { useNDVStore, usePostHog, useRootStore, useWorkflowsStore } from '@/stores';
import { executionDataToJson } from '@/utils';
import { useTelemetry } from '@/composables/useTelemetry';
import { useDataSchema } from '@/composables/useDataSchema';
import { useI18n } from '@/composables/useI18n';
import { useMessage } from '@/composables/useMessage';
import { useToast } from '@/composables/useToast';
import { useNDVStore } from '@/stores/ndv.store';
import { usePostHog } from '@/stores/posthog.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { executionDataToJson } from '@/utils/nodeTypesUtils';
import {
ASK_AI_EXPERIMENT,
ASK_AI_MAX_PROMPT_LENGTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ import { CODE_EXECUTION_MODES, CODE_LANGUAGES } from 'n8n-workflow';
import { workflowHelpers } from '@/mixins/workflowHelpers'; // for json field completions
import { ASK_AI_EXPERIMENT, CODE_NODE_TYPE } from '@/constants';
import { codeNodeEditorEventBus } from '@/event-bus';
import { useRootStore, usePostHog } from '@/stores';
import { useRootStore } from '@/stores/n8nRoot.store';
import { usePostHog } from '@/stores/posthog.store';

import { readOnlyEditorExtensions, writableEditorExtensions } from './baseExtensions';
import { CODE_PLACEHOLDERS } from './constants';
import { linterExtension } from './linter';
import { completerExtension } from './completer';
import { codeNodeEditorTheme } from './theme';
import AskAI from './AskAI/AskAI.vue';
import { useMessage } from '@/composables';
import { useMessage } from '@/composables/useMessage';

export default defineComponent({
name: 'code-node-editor',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Vue from 'vue';
import { addVarType } from '../utils';
import type { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete';
import type { CodeNodeEditorMixin } from '../types';
import { useExternalSecretsStore } from '@/stores';
import { useExternalSecretsStore } from '@/stores/externalSecrets.ee.store';

const escape = (str: string) => str.replace('$', '\\$');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addVarType } from '../utils';
import type { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete';
import { useEnvironmentsStore } from '@/stores';
import { useEnvironmentsStore } from '@/stores/environments.ee.store';
import { defineComponent } from 'vue';

const escape = (str: string) => str.replace('$', '\\$');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import {
COMMUNITY_NODES_INSTALLATION_DOCS_URL,
COMMUNITY_NODES_RISKS_DOCS_URL,
} from '@/constants';
import { useToast } from '@/composables';
import { useToast } from '@/composables/useToast';
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
export default defineComponent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import { defineComponent } from 'vue';
import Modal from '@/components/Modal.vue';
import { COMMUNITY_PACKAGE_CONFIRM_MODAL_KEY, COMMUNITY_PACKAGE_MANAGE_ACTIONS } from '@/constants';
import { useToast } from '@/composables';
import { useToast } from '@/composables/useToast';
import { mapStores } from 'pinia';
import { useCommunityNodesStore } from '@/stores/communityNodes.store';
import { createEventBus } from 'n8n-design-system/utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ContactPromptModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Modal from '@/components/Modal.vue';
import { useSettingsStore } from '@/stores/settings.store';
import { useRootStore } from '@/stores/n8nRoot.store';
import { createEventBus } from 'n8n-design-system/utils';
import { useToast } from '@/composables';
import { useToast } from '@/composables/useToast';
export default defineComponent({
name: 'ContactPromptModal',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { type ContextMenuAction, useContextMenu } from '@/composables';
import { type ContextMenuAction, useContextMenu } from '@/composables/useContextMenu';
import { N8nActionDropdown } from 'n8n-design-system';
import type { INode } from 'n8n-workflow';
import { watch, ref } from 'vue';
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/CopyInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { copyPaste } from '@/mixins/copyPaste';
import { useToast } from '@/composables';
import { useToast } from '@/composables/useToast';
import { i18n } from '@/plugins/i18n';
export default defineComponent({
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/CredentialCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { defineComponent } from 'vue';
import type { ICredentialsResponse, IUser } from '@/Interface';
import type { ICredentialType } from 'n8n-workflow';
import { EnterpriseEditionFeature, MODAL_CONFIRM } from '@/constants';
import { useMessage } from '@/composables';
import { useMessage } from '@/composables/useMessage';
import CredentialIcon from '@/components/CredentialIcon.vue';
import type { IPermissions } from '@/permissions';
import { getCredentialPermissions } from '@/permissions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getNodeAuthFields,
getNodeAuthOptions,
isAuthRelatedParameter,
} from '@/utils';
} from '@/utils/nodeTypesUtils';
import type { INodeProperties, INodeTypeDescription, NodeParameterValue } from 'n8n-workflow';
import { computed, onMounted, ref } from 'vue';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ import { defineComponent } from 'vue';
import { mapStores } from 'pinia';

import type { ICredentialType, INodeTypeDescription } from 'n8n-workflow';
import { getAppNameFromCredType, isCommunityPackageName } from '@/utils';
import { getAppNameFromCredType, isCommunityPackageName } from '@/utils/nodeTypesUtils';

import Banner from '../Banner.vue';
import CopyInput from '../CopyInput.vue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ import { NodeHelpers } from 'n8n-workflow';
import CredentialIcon from '@/components/CredentialIcon.vue';

import { nodeHelpers } from '@/mixins/nodeHelpers';
import { useToast, useMessage } from '@/composables';
import { useMessage } from '@/composables/useMessage';
import { useToast } from '@/composables/useToast';

import CredentialConfig from '@/components/CredentialEdit/CredentialConfig.vue';
import CredentialInfo from '@/components/CredentialEdit/CredentialInfo.vue';
Expand All @@ -157,14 +158,12 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
import { useNDVStore } from '@/stores/ndv.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import {
isValidCredentialResponse,
getNodeAuthOptions,
getNodeCredentialForSelectedAuthType,
updateNodeAuthType,
isCredentialModalState,
isExpression,
isTestableExpression,
} from '@/utils';
} from '@/utils/nodeTypesUtils';
import { isValidCredentialResponse, isCredentialModalState } from '@/utils/typeGuards';
import { isExpression, isTestableExpression } from '@/utils/expressions';
import { externalHooks } from '@/mixins/externalHooks';

interface NodeAccessMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<script lang="ts">
import type { IUser, IUserListAction } from '@/Interface';
import { defineComponent } from 'vue';
import { useMessage } from '@/composables';
import { useMessage } from '@/composables/useMessage';
import { mapStores } from 'pinia';
import { useUsersStore } from '@/stores/users.store';
import { useSettingsStore } from '@/stores/settings.store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script lang="ts" setup>
import { useUIStore } from '@/stores';
import { useUIStore } from '@/stores/ui.store';
import { useRootStore } from '@/stores/n8nRoot.store';

const { baseUrl } = useRootStore();
Expand Down
Loading
Loading