mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
refactor(editor): Migrate n8nRootStore
to use composition API (no-changelog) (#9770)
This commit is contained in:
parent
653953e2bd
commit
41e06be6fd
|
@ -51,7 +51,7 @@ 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 { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useTemplatesStore } from '@/stores/templates.store';
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useUsersStore } from '@/stores/users.store';
|
|||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { initializeAuthenticatedFeatures, initializeCore } from '@/init';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
|
@ -13,7 +13,7 @@ vi.mock('@/stores/users.store', () => ({
|
|||
useUsersStore: vi.fn().mockReturnValue({ initialize: vi.fn() }),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
vi.mock('@/stores/root.store', () => ({
|
||||
useRootStore: vi.fn(),
|
||||
}));
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ import { createEventBus } from 'n8n-design-system/utils';
|
|||
import Modal from './Modal.vue';
|
||||
import { ABOUT_MODAL_KEY } from '../constants';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'About',
|
||||
|
|
|
@ -4,7 +4,7 @@ import { computed, ref } from 'vue';
|
|||
import { STORES } from '@/constants';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useStorage } from '@/composables/useStorage';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { getBecomeCreatorCta } from '@/api/ctas';
|
||||
|
||||
const LOCAL_STORAGE_KEY = 'N8N_BECOME_TEMPLATE_CREATOR_CTA_DISMISSED_AT';
|
||||
|
@ -42,7 +42,7 @@ export const useBecomeTemplateCreatorStore = defineStore(STORES.BECOME_TEMPLATE_
|
|||
};
|
||||
|
||||
const fetchBecomeCreatorCta = async () => {
|
||||
const becomeCreatorCta = await getBecomeCreatorCta(rootStore.getRestApiContext);
|
||||
const becomeCreatorCta = await getBecomeCreatorCta(rootStore.restApiContext);
|
||||
|
||||
ctaMeetsCriteria.value = becomeCreatorCta;
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { EventBus } from 'n8n-design-system/utils';
|
|||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import Modal from './Modal.vue';
|
||||
import { CHAT_EMBED_MODAL_KEY, CHAT_TRIGGER_NODE_TYPE, WEBHOOK_NODE_TYPE } from '../constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import HtmlEditor from '@/components/HtmlEditor/HtmlEditor.vue';
|
||||
import JsEditor from '@/components/JsEditor/JsEditor.vue';
|
||||
|
@ -68,7 +68,7 @@ const webhookNode = computed(() => {
|
|||
});
|
||||
|
||||
const webhookUrl = computed(() => {
|
||||
const url = `${rootStore.getWebhookUrl}${
|
||||
const url = `${rootStore.webhookUrl}${
|
||||
webhookNode.value ? `/${webhookNode.value.node.webhookId}` : ''
|
||||
}`;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ 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 { useRootStore } from '@/stores/root.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { executionDataToJson } from '@/utils/nodeTypesUtils';
|
||||
import {
|
||||
|
@ -131,7 +131,7 @@ function stopLoading() {
|
|||
}
|
||||
|
||||
async function onSubmit() {
|
||||
const { getRestApiContext } = useRootStore();
|
||||
const { restApiContext } = useRootStore();
|
||||
const { activeNode } = useNDVStore();
|
||||
const { showMessage } = useToast();
|
||||
const { alert } = useMessage();
|
||||
|
@ -153,20 +153,22 @@ async function onSubmit() {
|
|||
|
||||
startLoading();
|
||||
|
||||
const rootStore = useRootStore();
|
||||
|
||||
try {
|
||||
const version = useRootStore().versionCli;
|
||||
const version = rootStore.versionCli;
|
||||
const model =
|
||||
usePostHog().getVariant(ASK_AI_EXPERIMENT.name) === ASK_AI_EXPERIMENT.gpt4
|
||||
? 'gpt-4'
|
||||
: 'gpt-3.5-turbo-16k';
|
||||
|
||||
const { code } = await generateCodeForPrompt(getRestApiContext, {
|
||||
const { code } = await generateCodeForPrompt(restApiContext, {
|
||||
question: prompt.value,
|
||||
context: {
|
||||
schema: schemas.parentNodesSchemas,
|
||||
inputSchema: schemas.inputSchema!,
|
||||
ndvPushRef: useNDVStore().pushRef,
|
||||
pushRef: useRootStore().pushRef,
|
||||
pushRef: rootStore.pushRef,
|
||||
},
|
||||
model,
|
||||
n8nVersion: version,
|
||||
|
|
|
@ -65,7 +65,7 @@ import { CODE_EXECUTION_MODES, CODE_LANGUAGES } from 'n8n-workflow';
|
|||
|
||||
import { ASK_AI_EXPERIMENT, CODE_NODE_TYPE } from '@/constants';
|
||||
import { codeNodeEditorEventBus } from '@/event-bus';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
|
||||
import { readOnlyEditorExtensions, writableEditorExtensions } from './baseExtensions';
|
||||
|
|
|
@ -40,7 +40,7 @@ import type { IN8nPromptResponse, ModalKey } from '@/Interface';
|
|||
import { VALID_EMAIL_REGEX } from '@/constants';
|
||||
import Modal from '@/components/Modal.vue';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useNpsSurveyStore } from '@/stores/npsSurvey.store';
|
||||
|
|
|
@ -162,7 +162,7 @@ import type { PermissionsMap } from '@/permissions';
|
|||
import type { CredentialScope } from '@n8n/permissions';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
|
@ -338,7 +338,7 @@ export default defineComponent({
|
|||
this.credentialTypeName === 'oAuth2Api' || this.parentTypes.includes('oAuth2Api')
|
||||
? 'oauth2'
|
||||
: 'oauth1';
|
||||
return this.rootStore.oauthCallbackUrls[oauthType as keyof {}];
|
||||
return this.rootStore.OAuthCallbackUrls[oauthType as keyof {}];
|
||||
},
|
||||
showOAuthSuccessBanner(): boolean {
|
||||
return (
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
const { baseUrl } = useRootStore();
|
||||
const type = useUIStore().appliedTheme === 'dark' ? '.dark.png' : '.png';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import type { ICredentialType } from 'n8n-workflow';
|
||||
import NodeIcon from '@/components/NodeIcon.vue';
|
||||
|
@ -26,7 +26,7 @@ const filePath = computed(() => {
|
|||
return null;
|
||||
}
|
||||
|
||||
return rootStore.getBaseUrl + themeIconUrl;
|
||||
return rootStore.baseUrl + themeIconUrl;
|
||||
});
|
||||
|
||||
const relevantNode = computed(() => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useClipboard } from '@/composables/useClipboard';
|
|||
import { useToast } from '@/composables/useToast';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import type {
|
||||
IDataObject,
|
||||
INodeProperties,
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import type { IFakeDoor } from '@/Interface';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
|
|
|
@ -45,7 +45,7 @@ import { type StyleValue, defineComponent, type PropType } from 'vue';
|
|||
import type { ITemplatesNode } from '@/Interface';
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
interface NodeIconData {
|
||||
type: string;
|
||||
|
@ -124,7 +124,7 @@ export default defineComponent({
|
|||
return (nodeType as ITemplatesNode).iconData;
|
||||
}
|
||||
|
||||
const restUrl = this.rootStore.getRestUrl;
|
||||
const restUrl = this.rootStore.restUrl;
|
||||
|
||||
if (typeof nodeType.icon === 'string') {
|
||||
const [type, path] = nodeType.icon.split(':');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
||||
export default defineComponent({
|
||||
|
|
|
@ -24,7 +24,7 @@ import InlineTextEdit from '@/components/InlineTextEdit.vue';
|
|||
import BreakpointsObserver from '@/components/BreakpointsObserver.vue';
|
||||
import CollaborationPane from '@/components/MainHeader/CollaborationPane.vue';
|
||||
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useTagsStore } from '@/stores/tags.store';
|
||||
|
|
|
@ -115,7 +115,7 @@ import { useUserHelpers } from '@/composables/useUserHelpers';
|
|||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from '@/constants';
|
||||
|
||||
import type { BaseTextKey } from '@/plugins/i18n';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
|
||||
|
||||
import { TriggerView, RegularView, AIView, AINodesView } from '../viewsData';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import type { IVersionNode, SimplifiedNodeType } from '@/Interface';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import {
|
||||
getBadgeIconUrl,
|
||||
|
@ -84,7 +84,7 @@ const color = computed(() => getNodeIconColor(props.nodeType) ?? props.colorDefa
|
|||
|
||||
const iconSource = computed<NodeIconSource>(() => {
|
||||
const nodeType = props.nodeType;
|
||||
const baseUrl = rootStore.getBaseUrl;
|
||||
const baseUrl = rootStore.baseUrl;
|
||||
|
||||
if (nodeType) {
|
||||
// If node type has icon data, use it
|
||||
|
@ -122,7 +122,7 @@ const badge = computed(() => {
|
|||
if (nodeType && 'badgeIconUrl' in nodeType && nodeType.badgeIconUrl) {
|
||||
return {
|
||||
type: 'file',
|
||||
src: rootStore.getBaseUrl + getBadgeIconUrl(nodeType, uiStore.appliedTheme),
|
||||
src: rootStore.baseUrl + getBadgeIconUrl(nodeType, uiStore.appliedTheme),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import { VALID_EMAIL_REGEX, NPS_SURVEY_MODAL_KEY } from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import ModalDrawer from '@/components/ModalDrawer.vue';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
|
|
|
@ -146,7 +146,7 @@ import { getAccountAge } from '@/utils/userUtils';
|
|||
import type { GenericValue } from 'n8n-workflow';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PushConnectionTracker',
|
||||
|
|
|
@ -148,7 +148,7 @@ import type { DynamicNodeParameters, IResourceLocatorResultExpanded } from '@/In
|
|||
import DraggableTarget from '@/components/DraggableTarget.vue';
|
||||
import ExpressionParameterInput from '@/components/ExpressionParameterInput.vue';
|
||||
import ParameterIssues from '@/components/ParameterIssues.vue';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
|
|
@ -630,7 +630,7 @@ import { useToast } from '@/composables/useToast';
|
|||
import { isEqual, isObject } from 'lodash-es';
|
||||
import { useExternalHooks } from '@/composables/useExternalHooks';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import RunDataPinButton from '@/components/RunDataPinButton.vue';
|
||||
|
||||
const RunDataTable = defineAsyncComponent(
|
||||
|
|
|
@ -210,7 +210,7 @@ import EventSelection from '@/components/SettingsLogStreaming/EventSelection.ee.
|
|||
import type { EventBus } from 'n8n-design-system';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'EventDestinationSettingsModal',
|
||||
|
|
|
@ -30,7 +30,7 @@ import type { IMenuItem } from 'n8n-design-system';
|
|||
import type { BaseTextKey } from '@/plugins/i18n';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { hasPermission } from '@/utils/rbac/permissions';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import type { ITelemetrySettings } from 'n8n-workflow';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { format, register } from 'timeago.js';
|
||||
import { convertToHumanReadableDate } from '@/utils/typesUtils';
|
||||
import { computed, onBeforeMount } from 'vue';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useI18n } from '@/composables/useI18n';
|
||||
|
||||
type Props = {
|
||||
|
|
|
@ -46,7 +46,7 @@ import VariableSelectorItem from '@/components/VariableSelectorItem.vue';
|
|||
import type { INodeUi, IVariableItemSelected, IVariableSelectorOption } from '@/Interface';
|
||||
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useWorkflowHelpers } from '@/composables/useWorkflowHelpers';
|
||||
|
|
|
@ -33,7 +33,7 @@ import WorkerCard from './Workers/WorkerCard.ee.vue';
|
|||
import { usePushConnection } from '@/composables/usePushConnection';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { usePushConnectionStore } from '@/stores/pushConnection.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default defineComponent({
|
||||
|
|
|
@ -375,7 +375,7 @@ import type { WorkflowSettings } from 'n8n-workflow';
|
|||
import { deepCopy } from 'n8n-workflow';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useWorkflowsEEStore } from '@/stores/workflows.ee.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { createEventBus } from 'n8n-design-system/utils';
|
||||
|
|
|
@ -2,6 +2,7 @@ import { describe, it, expect, vi } from 'vitest';
|
|||
import { fireEvent } from '@testing-library/vue';
|
||||
import GlobalExecutionsListItem from './GlobalExecutionsListItem.vue';
|
||||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
vi.mock('vue-router', async () => {
|
||||
const actual = await vi.importActual('vue-router');
|
||||
|
@ -96,6 +97,8 @@ describe('GlobalExecutionsListItem', () => {
|
|||
props: { execution: { status: 'success', id: 123, startedAt: testDate } },
|
||||
});
|
||||
|
||||
expect(getByText(`1 Jan, 2022 at ${new Date(testDate).getHours()}:00:00`)).toBeInTheDocument();
|
||||
expect(
|
||||
getByText(`1 Jan, 2022 at ${DateTime.fromJSDate(new Date(testDate)).toFormat('hh')}:00:00`),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
import { defineComponent } from 'vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
|
|
|
@ -21,7 +21,7 @@ vi.mock('@/stores/ndv.store', () => ({
|
|||
})),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
vi.mock('@/stores/root.store', () => ({
|
||||
useRootStore: vi.fn(() => ({
|
||||
instanceId: 'test-instance-id',
|
||||
})),
|
||||
|
|
|
@ -3,7 +3,7 @@ import { ExpressionExtensions } from 'n8n-workflow';
|
|||
import { EditorView, type ViewUpdate } from '@codemirror/view';
|
||||
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useTelemetry } from '../composables/useTelemetry';
|
||||
import type { Compartment } from '@codemirror/state';
|
||||
import { debounce } from 'lodash-es';
|
||||
|
|
|
@ -14,7 +14,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
|
|||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useTelemetry } from './useTelemetry';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { isFullExecutionResponse } from '@/utils/typeGuards';
|
||||
|
||||
export const useExecutionDebugging = () => {
|
||||
|
|
|
@ -15,8 +15,7 @@ import { useExternalHooks } from '@/composables/useExternalHooks';
|
|||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import type { MaybeRef } from 'vue';
|
||||
import { computed, unref } from 'vue';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNodeType } from '@/composables/useNodeType';
|
||||
import { useDataSchema } from './useDataSchema';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
|
@ -52,7 +51,6 @@ export function usePinnedData(
|
|||
const externalHooks = useExternalHooks();
|
||||
const { getInputDataWithPinned } = useDataSchema();
|
||||
|
||||
const { pushRef } = storeToRefs(rootStore);
|
||||
const { isSubNodeType, isMultipleOutputsNodeType } = useNodeType({
|
||||
node,
|
||||
});
|
||||
|
@ -197,7 +195,7 @@ export function usePinnedData(
|
|||
const telemetryPayload = {
|
||||
pinning_source: source,
|
||||
node_type: targetNode?.type,
|
||||
push_ref: pushRef.value,
|
||||
push_ref: rootStore.pushRef,
|
||||
data_size: stringSizeInBytes(data.value),
|
||||
view: displayMode,
|
||||
run_index: runIndex,
|
||||
|
@ -221,7 +219,7 @@ export function usePinnedData(
|
|||
telemetry.track('Ndv data pinning failure', {
|
||||
pinning_source: source,
|
||||
node_type: targetNode?.type,
|
||||
push_ref: pushRef.value,
|
||||
push_ref: rootStore.pushRef,
|
||||
data_size: stringSizeInBytes(data.value),
|
||||
view: displayMode,
|
||||
run_index: runIndex,
|
||||
|
@ -259,7 +257,7 @@ export function usePinnedData(
|
|||
|
||||
telemetry.track('User unpinned ndv data', {
|
||||
node_type: targetNode?.type,
|
||||
push_ref: pushRef.value,
|
||||
push_ref: rootStore.pushRef,
|
||||
run_index: runIndex,
|
||||
source,
|
||||
data_size: stringSizeInBytes(data.value),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useRunWorkflow } from '@/composables/useRunWorkflow';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { setActivePinia } from 'pinia';
|
||||
|
@ -10,10 +10,6 @@ import { useRouter } from 'vue-router';
|
|||
import { ExpressionError, type IPinData, type IRunData, type Workflow } from 'n8n-workflow';
|
||||
import type * as router from 'vue-router';
|
||||
|
||||
vi.mock('@/stores/n8nRoot.store', () => ({
|
||||
useRootStore: vi.fn().mockReturnValue({ pushConnectionActive: true }),
|
||||
}));
|
||||
|
||||
vi.mock('@/stores/workflows.store', () => ({
|
||||
useWorkflowsStore: vi.fn().mockReturnValue({
|
||||
runWorkflow: vi.fn(),
|
||||
|
@ -95,7 +91,7 @@ describe('useRunWorkflow({ router })', () => {
|
|||
let workflowHelpers: ReturnType<typeof useWorkflowHelpers>;
|
||||
|
||||
beforeAll(() => {
|
||||
const pinia = createTestingPinia();
|
||||
const pinia = createTestingPinia({ stubActions: false });
|
||||
|
||||
setActivePinia(pinia);
|
||||
|
||||
|
@ -110,7 +106,8 @@ describe('useRunWorkflow({ router })', () => {
|
|||
describe('runWorkflowApi()', () => {
|
||||
it('should throw an error if push connection is not active', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
rootStore.pushConnectionActive = false;
|
||||
|
||||
rootStore.setPushConnectionInactive();
|
||||
|
||||
await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow(
|
||||
'workflowRun.noActiveConnectionToTheServer',
|
||||
|
@ -119,7 +116,8 @@ describe('useRunWorkflow({ router })', () => {
|
|||
|
||||
it('should successfully run a workflow', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
rootStore.pushConnectionActive = true;
|
||||
|
||||
rootStore.setPushConnectionActive();
|
||||
|
||||
const mockResponse = { executionId: '123', waitingForWebhook: false };
|
||||
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockResponse);
|
||||
|
@ -135,7 +133,7 @@ describe('useRunWorkflow({ router })', () => {
|
|||
it('should handle workflow run failure', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
|
||||
rootStore.pushConnectionActive = true;
|
||||
rootStore.setPushConnectionActive();
|
||||
vi.mocked(workflowsStore).runWorkflow.mockRejectedValue(new Error('Failed to run workflow'));
|
||||
|
||||
await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow('Failed to run workflow');
|
||||
|
@ -145,7 +143,7 @@ describe('useRunWorkflow({ router })', () => {
|
|||
it('should set waitingForWebhook if response indicates waiting', async () => {
|
||||
const { runWorkflowApi } = useRunWorkflow({ router });
|
||||
|
||||
rootStore.pushConnectionActive = true;
|
||||
rootStore.setPushConnectionActive();
|
||||
const mockResponse = { executionId: '123', waitingForWebhook: true };
|
||||
vi.mocked(workflowsStore).runWorkflow.mockResolvedValue(mockResponse);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import {
|
|||
WORKFLOW_LM_CHAT_MODAL_KEY,
|
||||
} from '@/constants';
|
||||
import { useTitleChange } from '@/composables/useTitleChange';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { openPopUpWindow } from '@/utils/executionUtils';
|
||||
|
@ -279,12 +279,12 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
|||
|
||||
if (node.type === FORM_TRIGGER_NODE_TYPE && node.typeVersion === 1) {
|
||||
const webhookPath = (node.parameters.path as string) || node.webhookId;
|
||||
testUrl = `${rootStore.getWebhookTestUrl}/${webhookPath}/${FORM_TRIGGER_PATH_IDENTIFIER}`;
|
||||
testUrl = `${rootStore.webhookTestUrl}/${webhookPath}/${FORM_TRIGGER_PATH_IDENTIFIER}`;
|
||||
}
|
||||
|
||||
if (node.type === FORM_TRIGGER_NODE_TYPE && node.typeVersion > 1) {
|
||||
const webhookPath = (node.parameters.path as string) || node.webhookId;
|
||||
testUrl = `${rootStore.getFormTestUrl}/${webhookPath}`;
|
||||
testUrl = `${rootStore.formTestUrl}/${webhookPath}`;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -308,7 +308,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
|||
const { webhookSuffix } = (node.parameters.options ?? {}) as IDataObject;
|
||||
const suffix =
|
||||
webhookSuffix && typeof webhookSuffix !== 'object' ? `/${webhookSuffix}` : '';
|
||||
testUrl = `${rootStore.getFormWaitingUrl}/${runWorkflowApiResponse.executionId}${suffix}`;
|
||||
testUrl = `${rootStore.formWaitingUrl}/${runWorkflowApiResponse.executionId}${suffix}`;
|
||||
}
|
||||
|
||||
if (testUrl) openPopUpWindow(testUrl);
|
||||
|
|
|
@ -50,7 +50,7 @@ import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
|||
import { get, isEqual } from 'lodash-es';
|
||||
|
||||
import { useEnvironmentsStore } from '@/stores/environments.ee.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useTemplatesStore } from '@/stores/templates.store';
|
||||
|
@ -779,9 +779,9 @@ export function useWorkflowHelpers(options: { router: ReturnType<typeof useRoute
|
|||
|
||||
let baseUrl;
|
||||
if (showUrlFor === 'test') {
|
||||
baseUrl = isForm ? rootStore.getFormTestUrl : rootStore.getWebhookTestUrl;
|
||||
baseUrl = isForm ? rootStore.formTestUrl : rootStore.webhookTestUrl;
|
||||
} else {
|
||||
baseUrl = isForm ? rootStore.getFormUrl : rootStore.getWebhookUrl;
|
||||
baseUrl = isForm ? rootStore.formUrl : rootStore.webhookUrl;
|
||||
}
|
||||
|
||||
const workflowId = workflowsStore.workflowId;
|
||||
|
|
|
@ -11,7 +11,7 @@ import { useNDVStore } from '@/stores/ndv.store';
|
|||
import type { TelemetryEventData } from '@/hooks/types';
|
||||
import type { INodeUi } from '@/Interface';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
export interface UserSavedCredentialsEventData {
|
||||
credential_type: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
|
|
|
@ -7,7 +7,7 @@ import type { INodeProperties, INodePropertyCollection, INodePropertyOptions } f
|
|||
import type { INodeTranslationHeaders } from '@/Interface';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import englishBaseText from './locales/en.json';
|
||||
import {
|
||||
deriveMiddleKey,
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
SLACK_NODE_TYPE,
|
||||
TELEGRAM_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
|
|
|
@ -2,7 +2,7 @@ import { createPinia, setActivePinia } from 'pinia';
|
|||
import { usePostHog } from '@/stores/posthog.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useTelemetryStore } from '@/stores/telemetry.store';
|
||||
import type { IN8nUISettings } from 'n8n-workflow';
|
||||
import { LOCAL_STORAGE_EXPERIMENT_OVERRIDES } from '@/constants';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useSettingsStore } from '@/stores/settings.store';
|
|||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { merge } from 'lodash-es';
|
||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import * as cloudPlanApi from '@/api/cloudPlans';
|
||||
import {
|
||||
|
@ -53,6 +53,7 @@ describe('UI store', () => {
|
|||
uiStore = useUIStore();
|
||||
settingsStore = useSettingsStore();
|
||||
rootStore = useRootStore();
|
||||
|
||||
cloudPlanStore = useCloudPlanStore();
|
||||
|
||||
mockedCloudStore = vi.spyOn(cloudPlanStore, 'getAutoLoginCode');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import * as aiApi from '@/api/ai';
|
||||
import type { GenerateCurlPayload } from '@/api/ai';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
|
@ -51,7 +51,7 @@ export const useAIStore = defineStore('ai', () => {
|
|||
}
|
||||
|
||||
async function generateCurl(payload: GenerateCurlPayload) {
|
||||
return await aiApi.generateCurl(rootStore.getRestApiContext, payload);
|
||||
return await aiApi.generateCurl(rootStore.restApiContext, payload);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { computed, reactive } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import type { CloudPlanState } from '@/Interface';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
|
@ -72,7 +72,7 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
|
|||
};
|
||||
|
||||
const getAutoLoginCode = async (): Promise<{ code: string }> => {
|
||||
return await getAdminPanelLoginCode(rootStore.getRestApiContext);
|
||||
return await getAdminPanelLoginCode(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const getOwnerCurrentPlan = async () => {
|
||||
|
@ -80,7 +80,7 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
|
|||
state.loadingPlan = true;
|
||||
let plan;
|
||||
try {
|
||||
plan = await getCurrentPlan(rootStore.getRestApiContext);
|
||||
plan = await getCurrentPlan(rootStore.restApiContext);
|
||||
state.data = plan;
|
||||
state.loadingPlan = false;
|
||||
|
||||
|
@ -100,7 +100,7 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
|
|||
};
|
||||
|
||||
const getInstanceCurrentUsage = async () => {
|
||||
const usage = await getCurrentUsage({ baseUrl: rootStore.getBaseUrl, pushRef: '' });
|
||||
const usage = await getCurrentUsage({ baseUrl: rootStore.baseUrl, pushRef: '' });
|
||||
state.usage = usage;
|
||||
return usage;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as communityNodesApi from '@/api/communityNodes';
|
||||
import { getAvailableCommunityPackageCount } from '@/api/settings';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import type { PublicInstalledPackage } from 'n8n-workflow';
|
||||
import type { CommunityPackageMap } from '@/Interface';
|
||||
import { STORES } from '@/constants';
|
||||
|
@ -49,7 +49,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
const fetchInstalledPackages = async (): Promise<void> => {
|
||||
const rootStore = useRootStore();
|
||||
const installedPackages = await communityNodesApi.getInstalledCommunityNodes(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
);
|
||||
setInstalledPackages(installedPackages);
|
||||
const timeout = installedPackages.length > 0 ? 0 : LOADER_DELAY;
|
||||
|
@ -61,7 +61,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
const installPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
const rootStore = useRootStore();
|
||||
await communityNodesApi.installNewPackage(rootStore.getRestApiContext, packageName);
|
||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||
await fetchInstalledPackages();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
@ -71,7 +71,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
const uninstallPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
const rootStore = useRootStore();
|
||||
await communityNodesApi.uninstallPackage(rootStore.getRestApiContext, packageName);
|
||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||
removePackageByName(packageName);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
@ -92,7 +92,7 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
const rootStore = useRootStore();
|
||||
const packageToUpdate: PublicInstalledPackage = getInstalledPackageByName.value(packageName);
|
||||
const updatedPackage: PublicInstalledPackage = await communityNodesApi.updatePackage(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
updatePackageObject(updatedPackage);
|
||||
|
|
|
@ -20,7 +20,7 @@ import type {
|
|||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { useNodeTypesStore } from './nodeTypes.store';
|
||||
import { useSettingsStore } from './settings.store';
|
||||
import { isEmpty } from '@/utils/typesUtils';
|
||||
|
@ -257,7 +257,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
return;
|
||||
}
|
||||
const rootStore = useRootStore();
|
||||
const credentialTypes = await credentialsApi.getCredentialTypes(rootStore.getBaseUrl);
|
||||
const credentialTypes = await credentialsApi.getCredentialTypes(rootStore.baseUrl);
|
||||
setCredentialTypes(credentialTypes);
|
||||
};
|
||||
|
||||
|
@ -272,7 +272,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
};
|
||||
|
||||
const credentials = await credentialsApi.getAllCredentials(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
isEmpty(filter) ? undefined : filter,
|
||||
includeScopes,
|
||||
);
|
||||
|
@ -286,7 +286,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
const rootStore = useRootStore();
|
||||
|
||||
const credentials = await credentialsApi.getAllCredentialsForWorkflow(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
options,
|
||||
);
|
||||
setCredentials(credentials);
|
||||
|
@ -299,7 +299,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
id: string;
|
||||
}): Promise<ICredentialsResponse | ICredentialsDecryptedResponse | undefined> => {
|
||||
const rootStore = useRootStore();
|
||||
return await credentialsApi.getCredentialData(rootStore.getRestApiContext, id);
|
||||
return await credentialsApi.getCredentialData(rootStore.restApiContext, id);
|
||||
};
|
||||
|
||||
const createNewCredential = async (
|
||||
|
@ -309,7 +309,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
const rootStore = useRootStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const credential = await credentialsApi.createNewCredential(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
data,
|
||||
projectId,
|
||||
);
|
||||
|
@ -334,7 +334,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
}): Promise<ICredentialsResponse> => {
|
||||
const { id, data } = params;
|
||||
const rootStore = useRootStore();
|
||||
const credential = await credentialsApi.updateCredential(rootStore.getRestApiContext, id, data);
|
||||
const credential = await credentialsApi.updateCredential(rootStore.restApiContext, id, data);
|
||||
|
||||
upsertCredential(credential);
|
||||
|
||||
|
@ -343,7 +343,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
|
||||
const deleteCredential = async ({ id }: { id: string }) => {
|
||||
const rootStore = useRootStore();
|
||||
const deleted = await credentialsApi.deleteCredential(rootStore.getRestApiContext, id);
|
||||
const deleted = await credentialsApi.deleteCredential(rootStore.restApiContext, id);
|
||||
if (deleted) {
|
||||
const { [id]: deletedCredential, ...rest } = state.value.credentials;
|
||||
state.value.credentials = rest;
|
||||
|
@ -352,19 +352,19 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
|
||||
const oAuth2Authorize = async (data: ICredentialsResponse): Promise<string> => {
|
||||
const rootStore = useRootStore();
|
||||
return await credentialsApi.oAuth2CredentialAuthorize(rootStore.getRestApiContext, data);
|
||||
return await credentialsApi.oAuth2CredentialAuthorize(rootStore.restApiContext, data);
|
||||
};
|
||||
|
||||
const oAuth1Authorize = async (data: ICredentialsResponse): Promise<string> => {
|
||||
const rootStore = useRootStore();
|
||||
return await credentialsApi.oAuth1CredentialAuthorize(rootStore.getRestApiContext, data);
|
||||
return await credentialsApi.oAuth1CredentialAuthorize(rootStore.restApiContext, data);
|
||||
};
|
||||
|
||||
const testCredential = async (
|
||||
data: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> => {
|
||||
const rootStore = useRootStore();
|
||||
return await credentialsApi.testCredential(rootStore.getRestApiContext, { credentials: data });
|
||||
return await credentialsApi.testCredential(rootStore.restApiContext, { credentials: data });
|
||||
};
|
||||
|
||||
const getNewCredentialName = async (params: { credentialTypeName: string }): Promise<string> => {
|
||||
|
@ -378,7 +378,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
newName.length > 0 ? `${newName} ${DEFAULT_CREDENTIAL_POSTFIX}` : DEFAULT_CREDENTIAL_NAME;
|
||||
}
|
||||
const rootStore = useRootStore();
|
||||
const res = await credentialsApi.getCredentialsNewName(rootStore.getRestApiContext, newName);
|
||||
const res = await credentialsApi.getCredentialsNewName(rootStore.restApiContext, newName);
|
||||
return res.name;
|
||||
} catch (e) {
|
||||
return DEFAULT_CREDENTIAL_NAME;
|
||||
|
@ -391,7 +391,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
}): Promise<ICredentialsResponse> => {
|
||||
if (useSettingsStore().isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing)) {
|
||||
await credentialsEeApi.setCredentialSharedWith(
|
||||
useRootStore().getRestApiContext,
|
||||
useRootStore().restApiContext,
|
||||
payload.credentialId,
|
||||
{
|
||||
shareWithIds: payload.sharedWithProjects.map((project) => project.id),
|
||||
|
@ -408,7 +408,7 @@ export const useCredentialsStore = defineStore(STORES.CREDENTIALS, () => {
|
|||
|
||||
const getCredentialTranslation = async (credentialType: string): Promise<object> => {
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(rootStore.getRestApiContext, 'GET', '/credential-translation', {
|
||||
return await makeRestApiRequest(rootStore.restApiContext, 'GET', '/credential-translation', {
|
||||
credentialType,
|
||||
});
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
|||
import { computed, ref } from 'vue';
|
||||
import type { EnvironmentVariable } from '@/Interface';
|
||||
import * as environmentsApi from '@/api/environments.ee';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { ExpressionError } from 'n8n-workflow';
|
||||
|
||||
export const useEnvironmentsStore = defineStore('environments', () => {
|
||||
|
@ -11,7 +11,7 @@ export const useEnvironmentsStore = defineStore('environments', () => {
|
|||
const variables = ref<EnvironmentVariable[]>([]);
|
||||
|
||||
async function fetchAllVariables() {
|
||||
const data = await environmentsApi.getVariables(rootStore.getRestApiContext);
|
||||
const data = await environmentsApi.getVariables(rootStore.restApiContext);
|
||||
|
||||
variables.value = data;
|
||||
|
||||
|
@ -19,7 +19,7 @@ export const useEnvironmentsStore = defineStore('environments', () => {
|
|||
}
|
||||
|
||||
async function createVariable(variable: Omit<EnvironmentVariable, 'id'>) {
|
||||
const data = await environmentsApi.createVariable(rootStore.getRestApiContext, variable);
|
||||
const data = await environmentsApi.createVariable(rootStore.restApiContext, variable);
|
||||
|
||||
variables.value.unshift(data);
|
||||
|
||||
|
@ -27,7 +27,7 @@ export const useEnvironmentsStore = defineStore('environments', () => {
|
|||
}
|
||||
|
||||
async function updateVariable(variable: EnvironmentVariable) {
|
||||
const data = await environmentsApi.updateVariable(rootStore.getRestApiContext, variable);
|
||||
const data = await environmentsApi.updateVariable(rootStore.restApiContext, variable);
|
||||
|
||||
variables.value = variables.value.map((v) => (v.id === data.id ? data : v));
|
||||
|
||||
|
@ -35,7 +35,7 @@ export const useEnvironmentsStore = defineStore('environments', () => {
|
|||
}
|
||||
|
||||
async function deleteVariable(variable: EnvironmentVariable) {
|
||||
const data = await environmentsApi.deleteVariable(rootStore.getRestApiContext, {
|
||||
const data = await environmentsApi.deleteVariable(rootStore.restApiContext, {
|
||||
id: variable.id,
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import type {
|
|||
IExecutionsListResponse,
|
||||
IExecutionsStopData,
|
||||
} from '@/Interface';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { makeRestApiRequest, unflattenExecutionData } from '@/utils/apiUtils';
|
||||
import { executionFilterToQueryFilter, getDefaultExecutionFilters } from '@/utils/executionUtils';
|
||||
|
||||
|
@ -119,7 +119,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
loading.value = true;
|
||||
try {
|
||||
const data = await makeRestApiRequest<IExecutionsListResponse>(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'GET',
|
||||
'/executions',
|
||||
{
|
||||
|
@ -150,7 +150,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
|
||||
async function fetchExecution(id: string): Promise<IExecutionResponse | undefined> {
|
||||
const response = await makeRestApiRequest<IExecutionFlattedResponse>(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'GET',
|
||||
`/executions/${id}`,
|
||||
);
|
||||
|
@ -186,7 +186,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
|
||||
async function stopCurrentExecution(executionId: string): Promise<IExecutionsStopData> {
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'POST',
|
||||
`/executions/${executionId}/stop`,
|
||||
);
|
||||
|
@ -194,7 +194,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
|
||||
async function retryExecution(id: string, loadWorkflow?: boolean): Promise<boolean> {
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'POST',
|
||||
`/executions/${id}/retry`,
|
||||
loadWorkflow
|
||||
|
@ -207,7 +207,7 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
|
||||
async function deleteExecutions(sendData: IExecutionDeleteFilter): Promise<void> {
|
||||
await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'POST',
|
||||
'/executions/delete',
|
||||
sendData as unknown as IDataObject,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { computed, reactive } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import * as externalSecretsApi from '@/api/externalSecrets.ee';
|
||||
import { connectProvider } from '@/api/externalSecrets.ee';
|
||||
|
@ -67,7 +67,7 @@ export const useExternalSecretsStore = defineStore('externalSecrets', () => {
|
|||
async function fetchAllSecrets() {
|
||||
if (rbacStore.hasScope('externalSecret:list')) {
|
||||
try {
|
||||
state.secrets = await externalSecretsApi.getExternalSecrets(rootStore.getRestApiContext);
|
||||
state.secrets = await externalSecretsApi.getExternalSecrets(rootStore.restApiContext);
|
||||
} catch (error) {
|
||||
state.secrets = {};
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ export const useExternalSecretsStore = defineStore('externalSecrets', () => {
|
|||
}
|
||||
|
||||
async function reloadProvider(id: string) {
|
||||
const { updated } = await externalSecretsApi.reloadProvider(rootStore.getRestApiContext, id);
|
||||
const { updated } = await externalSecretsApi.reloadProvider(rootStore.restApiContext, id);
|
||||
if (updated) {
|
||||
await fetchAllSecrets();
|
||||
}
|
||||
|
@ -85,13 +85,13 @@ export const useExternalSecretsStore = defineStore('externalSecrets', () => {
|
|||
|
||||
async function getProviders() {
|
||||
state.providers = await externalSecretsApi.getExternalSecretsProviders(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
);
|
||||
}
|
||||
|
||||
async function testProviderConnection(id: string, data: ExternalSecretsProvider['data']) {
|
||||
return await externalSecretsApi.testExternalSecretsProviderConnection(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
id,
|
||||
data,
|
||||
);
|
||||
|
@ -99,7 +99,7 @@ export const useExternalSecretsStore = defineStore('externalSecrets', () => {
|
|||
|
||||
async function getProvider(id: string) {
|
||||
const provider = await externalSecretsApi.getExternalSecretsProvider(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
id,
|
||||
);
|
||||
|
||||
|
@ -130,13 +130,13 @@ export const useExternalSecretsStore = defineStore('externalSecrets', () => {
|
|||
}
|
||||
|
||||
async function updateProviderConnected(id: string, value: boolean) {
|
||||
await connectProvider(rootStore.getRestApiContext, id, value);
|
||||
await connectProvider(rootStore.restApiContext, id, value);
|
||||
await fetchAllSecrets();
|
||||
updateStoredProvider(id, { connected: value, state: value ? 'connected' : 'initializing' });
|
||||
}
|
||||
|
||||
async function updateProvider(id: string, { data }: Partial<ExternalSecretsProvider>) {
|
||||
await externalSecretsApi.updateProvider(rootStore.getRestApiContext, id, data);
|
||||
await externalSecretsApi.updateProvider(rootStore.restApiContext, id, data);
|
||||
await fetchAllSecrets();
|
||||
updateStoredProvider(id, { data });
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
saveDestinationToDb,
|
||||
sendTestMessageToDestination,
|
||||
} from '../api/eventbus.ee';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
|
||||
export interface EventSelectionItem {
|
||||
selected: boolean;
|
||||
|
@ -194,7 +194,7 @@ export const useLogStreamingStore = defineStore('logStreaming', {
|
|||
const rootStore = useRootStore();
|
||||
const selectedEvents = this.getSelectedEvents(destination.id);
|
||||
try {
|
||||
await saveDestinationToDb(rootStore.getRestApiContext, destination, selectedEvents);
|
||||
await saveDestinationToDb(rootStore.restApiContext, destination, selectedEvents);
|
||||
this.updateDestination(destination);
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
@ -207,23 +207,20 @@ export const useLogStreamingStore = defineStore('logStreaming', {
|
|||
}
|
||||
|
||||
const rootStore = useRootStore();
|
||||
const testResult = await sendTestMessageToDestination(
|
||||
rootStore.getRestApiContext,
|
||||
destination,
|
||||
);
|
||||
const testResult = await sendTestMessageToDestination(rootStore.restApiContext, destination);
|
||||
return testResult;
|
||||
},
|
||||
async fetchEventNames(): Promise<string[]> {
|
||||
const rootStore = useRootStore();
|
||||
return await getEventNamesFromBackend(rootStore.getRestApiContext);
|
||||
return await getEventNamesFromBackend(rootStore.restApiContext);
|
||||
},
|
||||
async fetchDestinations(): Promise<MessageEventBusDestinationOptions[]> {
|
||||
const rootStore = useRootStore();
|
||||
return await getDestinationsFromBackend(rootStore.getRestApiContext);
|
||||
return await getDestinationsFromBackend(rootStore.restApiContext);
|
||||
},
|
||||
async deleteDestination(destinationId: string) {
|
||||
const rootStore = useRootStore();
|
||||
await deleteDestinationFromDb(rootStore.getRestApiContext, destinationId);
|
||||
await deleteDestinationFromDb(rootStore.restApiContext, destinationId);
|
||||
this.removeDestination(destinationId);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
import { CLOUD_BASE_URL_PRODUCTION, CLOUD_BASE_URL_STAGING, STORES } from '@/constants';
|
||||
import type { IRestApiContext, RootState } from '@/Interface';
|
||||
import { setGlobalState, type IDataObject } from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
const { VUE_APP_URL_BASE_API } = import.meta.env;
|
||||
|
||||
export const useRootStore = defineStore(STORES.ROOT, {
|
||||
state: (): RootState => ({
|
||||
baseUrl: VUE_APP_URL_BASE_API ?? window.BASE_PATH,
|
||||
restEndpoint:
|
||||
!window.REST_ENDPOINT || window.REST_ENDPOINT === '{{REST_ENDPOINT}}'
|
||||
? 'rest'
|
||||
: window.REST_ENDPOINT,
|
||||
defaultLocale: 'en',
|
||||
endpointForm: 'form',
|
||||
endpointFormTest: 'form-test',
|
||||
endpointFormWaiting: 'form-waiting',
|
||||
endpointWebhook: 'webhook',
|
||||
endpointWebhookTest: 'webhook-test',
|
||||
pushConnectionActive: true,
|
||||
timezone: 'America/New_York',
|
||||
executionTimeout: -1,
|
||||
maxExecutionTimeout: Number.MAX_SAFE_INTEGER,
|
||||
versionCli: '0.0.0',
|
||||
oauthCallbackUrls: {},
|
||||
n8nMetadata: {},
|
||||
pushRef: Math.random().toString(36).substring(2, 15),
|
||||
urlBaseWebhook: 'http://localhost:5678/',
|
||||
urlBaseEditor: 'http://localhost:5678',
|
||||
isNpmAvailable: false,
|
||||
instanceId: '',
|
||||
binaryDataMode: 'default',
|
||||
}),
|
||||
getters: {
|
||||
getBaseUrl(): string {
|
||||
return this.baseUrl;
|
||||
},
|
||||
|
||||
getFormUrl(): string {
|
||||
return `${this.urlBaseWebhook}${this.endpointForm}`;
|
||||
},
|
||||
|
||||
getFormTestUrl(): string {
|
||||
return `${this.urlBaseEditor}${this.endpointFormTest}`;
|
||||
},
|
||||
|
||||
getFormWaitingUrl(): string {
|
||||
return `${this.baseUrl}${this.endpointFormWaiting}`;
|
||||
},
|
||||
|
||||
getWebhookUrl(): string {
|
||||
return `${this.urlBaseWebhook}${this.endpointWebhook}`;
|
||||
},
|
||||
|
||||
getWebhookTestUrl(): string {
|
||||
return `${this.urlBaseEditor}${this.endpointWebhookTest}`;
|
||||
},
|
||||
|
||||
getRestUrl(): string {
|
||||
return `${this.baseUrl}${this.restEndpoint}`;
|
||||
},
|
||||
|
||||
getRestCloudApiContext(): IRestApiContext {
|
||||
return {
|
||||
baseUrl: window.location.host.includes('stage-app.n8n.cloud')
|
||||
? CLOUD_BASE_URL_STAGING
|
||||
: CLOUD_BASE_URL_PRODUCTION,
|
||||
pushRef: '',
|
||||
};
|
||||
},
|
||||
|
||||
getRestApiContext(): IRestApiContext {
|
||||
return {
|
||||
baseUrl: this.getRestUrl,
|
||||
pushRef: this.pushRef,
|
||||
};
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setUrlBaseWebhook(urlBaseWebhook: string): void {
|
||||
const url = urlBaseWebhook.endsWith('/') ? urlBaseWebhook : `${urlBaseWebhook}/`;
|
||||
this.urlBaseWebhook = url;
|
||||
},
|
||||
setUrlBaseEditor(urlBaseEditor: string): void {
|
||||
const url = urlBaseEditor.endsWith('/') ? urlBaseEditor : `${urlBaseEditor}/`;
|
||||
this.urlBaseEditor = url;
|
||||
},
|
||||
setEndpointForm(endpointForm: string): void {
|
||||
this.endpointForm = endpointForm;
|
||||
},
|
||||
setEndpointFormTest(endpointFormTest: string): void {
|
||||
this.endpointFormTest = endpointFormTest;
|
||||
},
|
||||
setEndpointFormWaiting(endpointFormWaiting: string): void {
|
||||
this.endpointFormWaiting = endpointFormWaiting;
|
||||
},
|
||||
setEndpointWebhook(endpointWebhook: string): void {
|
||||
this.endpointWebhook = endpointWebhook;
|
||||
},
|
||||
setEndpointWebhookTest(endpointWebhookTest: string): void {
|
||||
this.endpointWebhookTest = endpointWebhookTest;
|
||||
},
|
||||
setTimezone(timezone: string): void {
|
||||
this.timezone = timezone;
|
||||
setGlobalState({ defaultTimezone: timezone });
|
||||
},
|
||||
setExecutionTimeout(executionTimeout: number): void {
|
||||
this.executionTimeout = executionTimeout;
|
||||
},
|
||||
setMaxExecutionTimeout(maxExecutionTimeout: number): void {
|
||||
this.maxExecutionTimeout = maxExecutionTimeout;
|
||||
},
|
||||
setVersionCli(version: string): void {
|
||||
this.versionCli = version;
|
||||
},
|
||||
setInstanceId(instanceId: string): void {
|
||||
this.instanceId = instanceId;
|
||||
},
|
||||
setOauthCallbackUrls(urls: IDataObject): void {
|
||||
this.oauthCallbackUrls = urls;
|
||||
},
|
||||
setN8nMetadata(metadata: IDataObject): void {
|
||||
this.n8nMetadata = metadata as RootState['n8nMetadata'];
|
||||
},
|
||||
setDefaultLocale(locale: string): void {
|
||||
this.defaultLocale = locale;
|
||||
},
|
||||
setIsNpmAvailable(isNpmAvailable: boolean): void {
|
||||
this.isNpmAvailable = isNpmAvailable;
|
||||
},
|
||||
setBinaryDataMode(binaryDataMode: string): void {
|
||||
this.binaryDataMode = binaryDataMode;
|
||||
},
|
||||
},
|
||||
});
|
|
@ -24,7 +24,7 @@ import type {
|
|||
import { NodeConnectionType, NodeHelpers } from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useCredentialsStore } from './credentials.store';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import {
|
||||
getCredentialOnlyNodeType,
|
||||
getCredentialTypeName,
|
||||
|
@ -230,7 +230,7 @@ export const useNodeTypesStore = defineStore(STORES.NODE_TYPES, {
|
|||
replace = true,
|
||||
): Promise<INodeTypeDescription[]> {
|
||||
const rootStore = useRootStore();
|
||||
const nodesInformation = await getNodesInformation(rootStore.getRestApiContext, nodeInfos);
|
||||
const nodesInformation = await getNodesInformation(rootStore.restApiContext, nodeInfos);
|
||||
|
||||
nodesInformation.forEach((nodeInformation) => {
|
||||
if (nodeInformation.translation) {
|
||||
|
@ -250,7 +250,7 @@ export const useNodeTypesStore = defineStore(STORES.NODE_TYPES, {
|
|||
},
|
||||
async getNodeTypes(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const nodeTypes = await getNodeTypes(rootStore.getBaseUrl);
|
||||
const nodeTypes = await getNodeTypes(rootStore.baseUrl);
|
||||
if (nodeTypes.length) {
|
||||
this.setNodeTypes(nodeTypes);
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ export const useNodeTypesStore = defineStore(STORES.NODE_TYPES, {
|
|||
},
|
||||
async getNodeTranslationHeaders(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const headers = await getNodeTranslationHeaders(rootStore.getRestApiContext);
|
||||
const headers = await getNodeTranslationHeaders(rootStore.restApiContext);
|
||||
|
||||
if (headers) {
|
||||
addHeaders(headers, rootStore.defaultLocale);
|
||||
|
@ -275,20 +275,20 @@ export const useNodeTypesStore = defineStore(STORES.NODE_TYPES, {
|
|||
sendData: DynamicNodeParameters.OptionsRequest,
|
||||
): Promise<INodePropertyOptions[]> {
|
||||
const rootStore = useRootStore();
|
||||
return await getNodeParameterOptions(rootStore.getRestApiContext, sendData);
|
||||
return await getNodeParameterOptions(rootStore.restApiContext, sendData);
|
||||
},
|
||||
async getResourceLocatorResults(
|
||||
sendData: DynamicNodeParameters.ResourceLocatorResultsRequest,
|
||||
): Promise<INodeListSearchResult> {
|
||||
const rootStore = useRootStore();
|
||||
return await getResourceLocatorResults(rootStore.getRestApiContext, sendData);
|
||||
return await getResourceLocatorResults(rootStore.restApiContext, sendData);
|
||||
},
|
||||
async getResourceMapperFields(
|
||||
sendData: DynamicNodeParameters.ResourceMapperFieldsRequest,
|
||||
): Promise<ResourceMapperFields | null> {
|
||||
const rootStore = useRootStore();
|
||||
try {
|
||||
return await getResourceMapperFields(rootStore.getRestApiContext, sendData);
|
||||
return await getResourceMapperFields(rootStore.restApiContext, sendData);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
NPS_SURVEY_MODAL_KEY,
|
||||
CONTACT_PROMPT_MODAL_KEY,
|
||||
} from '@/constants';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import type { IUserSettings, NpsSurveyState } from 'n8n-workflow';
|
||||
import { useSettingsStore } from './settings.store';
|
||||
import { updateNpsSurveyState } from '@/api/npsSurvey';
|
||||
|
@ -96,7 +96,7 @@ export const useNpsSurveyStore = defineStore('npsSurvey', () => {
|
|||
? currentSurveyState.value.ignoredCount
|
||||
: 0,
|
||||
};
|
||||
await updateNpsSurveyState(rootStore.getRestApiContext, updatedState);
|
||||
await updateNpsSurveyState(rootStore.restApiContext, updatedState);
|
||||
currentSurveyState.value = updatedState;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ export const useNpsSurveyStore = defineStore('npsSurvey', () => {
|
|||
responded: true,
|
||||
lastShownAt: currentSurveyState.value.lastShownAt,
|
||||
};
|
||||
await updateNpsSurveyState(rootStore.getRestApiContext, updatedState);
|
||||
await updateNpsSurveyState(rootStore.restApiContext, updatedState);
|
||||
currentSurveyState.value = updatedState;
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ export const useNpsSurveyStore = defineStore('npsSurvey', () => {
|
|||
lastShownAt: currentSurveyState.value.lastShownAt,
|
||||
ignoredCount: ignoredCount + 1,
|
||||
};
|
||||
await updateNpsSurveyState(rootStore.getRestApiContext, updatedState);
|
||||
await updateNpsSurveyState(rootStore.restApiContext, updatedState);
|
||||
currentSurveyState.value = updatedState;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import type { IPushDataWorkerStatusPayload } from '../Interface';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { sendGetWorkerStatus } from '../api/orchestration';
|
||||
|
||||
export const WORKER_HISTORY_LENGTH = 100;
|
||||
|
@ -56,7 +56,7 @@ export const useOrchestrationStore = defineStore('orchestrationManager', {
|
|||
const rootStore = useRootStore();
|
||||
if (!this.statusInterval) {
|
||||
this.statusInterval = setInterval(async () => {
|
||||
await sendGetWorkerStatus(rootStore.getRestApiContext);
|
||||
await sendGetWorkerStatus(rootStore.restApiContext);
|
||||
this.removeStaleWorkers();
|
||||
}, 1000);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { ref } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
import { useStorage } from '@/composables/useStorage';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import type { FeatureFlags, IDataObject } from 'n8n-workflow';
|
||||
import { EXPERIMENTS_TO_TRACK, LOCAL_STORAGE_EXPERIMENT_OVERRIDES } from '@/constants';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import * as projectsApi from '@/api/projects.api';
|
||||
import * as workflowsEEApi from '@/api/workflows.ee';
|
||||
import * as credentialsEEApi from '@/api/credentials.ee';
|
||||
|
@ -79,33 +79,33 @@ export const useProjectsStore = defineStore('projects', () => {
|
|||
};
|
||||
|
||||
const getAllProjects = async () => {
|
||||
projects.value = await projectsApi.getAllProjects(rootStore.getRestApiContext);
|
||||
projects.value = await projectsApi.getAllProjects(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const getMyProjects = async () => {
|
||||
myProjects.value = await projectsApi.getMyProjects(rootStore.getRestApiContext);
|
||||
myProjects.value = await projectsApi.getMyProjects(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const getPersonalProject = async () => {
|
||||
personalProject.value = await projectsApi.getPersonalProject(rootStore.getRestApiContext);
|
||||
personalProject.value = await projectsApi.getPersonalProject(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const fetchProject = async (id: string) =>
|
||||
await projectsApi.getProject(rootStore.getRestApiContext, id);
|
||||
await projectsApi.getProject(rootStore.restApiContext, id);
|
||||
|
||||
const getProject = async (id: string) => {
|
||||
currentProject.value = await fetchProject(id);
|
||||
};
|
||||
|
||||
const createProject = async (project: ProjectCreateRequest): Promise<Project> => {
|
||||
const newProject = await projectsApi.createProject(rootStore.getRestApiContext, project);
|
||||
const newProject = await projectsApi.createProject(rootStore.restApiContext, project);
|
||||
await getProjectsCount();
|
||||
myProjects.value = [...myProjects.value, newProject as unknown as ProjectListItem];
|
||||
return newProject;
|
||||
};
|
||||
|
||||
const updateProject = async (projectData: ProjectUpdateRequest): Promise<void> => {
|
||||
await projectsApi.updateProject(rootStore.getRestApiContext, projectData);
|
||||
await projectsApi.updateProject(rootStore.restApiContext, projectData);
|
||||
const projectIndex = myProjects.value.findIndex((p) => p.id === projectData.id);
|
||||
if (projectIndex !== -1) {
|
||||
myProjects.value[projectIndex].name = projectData.name;
|
||||
|
@ -119,13 +119,13 @@ export const useProjectsStore = defineStore('projects', () => {
|
|||
};
|
||||
|
||||
const deleteProject = async (projectId: string, transferId?: string): Promise<void> => {
|
||||
await projectsApi.deleteProject(rootStore.getRestApiContext, projectId, transferId);
|
||||
await projectsApi.deleteProject(rootStore.restApiContext, projectId, transferId);
|
||||
await getProjectsCount();
|
||||
myProjects.value = myProjects.value.filter((p) => p.id !== projectId);
|
||||
};
|
||||
|
||||
const getProjectsCount = async () => {
|
||||
projectsCount.value = await projectsApi.getProjectsCount(rootStore.getRestApiContext);
|
||||
projectsCount.value = await projectsApi.getProjectsCount(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const setProjectNavActiveIdByWorkflowHomeProject = async (
|
||||
|
@ -147,15 +147,11 @@ export const useProjectsStore = defineStore('projects', () => {
|
|||
projectId: string,
|
||||
) => {
|
||||
if (resourceType === 'workflow') {
|
||||
await workflowsEEApi.moveWorkflowToProject(
|
||||
rootStore.getRestApiContext,
|
||||
resourceId,
|
||||
projectId,
|
||||
);
|
||||
await workflowsEEApi.moveWorkflowToProject(rootStore.restApiContext, resourceId, projectId);
|
||||
await workflowsStore.fetchAllWorkflows(currentProjectId.value);
|
||||
} else {
|
||||
await credentialsEEApi.moveCredentialToProject(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
resourceId,
|
||||
projectId,
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
|
|||
import { STORES, TIME } from '@/constants';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useSettingsStore } from './settings.store';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import type { IPushData } from '../Interface';
|
||||
|
||||
export interface PushState {
|
||||
|
@ -84,7 +84,7 @@ export const usePushConnectionStore = defineStore(STORES.PUSH, () => {
|
|||
|
||||
const useWebSockets = settingsStore.pushBackend === 'websocket';
|
||||
|
||||
const { getRestUrl: restUrl } = rootStore;
|
||||
const restUrl = rootStore.restUrl;
|
||||
const url = `/push?pushRef=${pushRef.value}`;
|
||||
|
||||
if (useWebSockets) {
|
||||
|
@ -116,7 +116,7 @@ export const usePushConnectionStore = defineStore(STORES.PUSH, () => {
|
|||
isConnectionOpen.value = true;
|
||||
connectRetries.value = 0;
|
||||
lostConnection.value = false;
|
||||
rootStore.pushConnectionActive = true;
|
||||
rootStore.setPushConnectionActive();
|
||||
pushSource.value?.removeEventListener('open', onConnectionSuccess);
|
||||
|
||||
if (outgoingQueue.value.length) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { ProjectRole, RoleMap } from '@/types/roles.types';
|
|||
import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
import * as rolesApi from '@/api/roles.api';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
|
||||
export const useRolesStore = defineStore('roles', () => {
|
||||
const rootStore = useRootStore();
|
||||
|
@ -37,7 +37,7 @@ export const useRolesStore = defineStore('roles', () => {
|
|||
);
|
||||
|
||||
const fetchRoles = async () => {
|
||||
roles.value = await rolesApi.getRoles(rootStore.getRestApiContext);
|
||||
roles.value = await rolesApi.getRoles(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
219
packages/editor-ui/src/stores/root.store.ts
Normal file
219
packages/editor-ui/src/stores/root.store.ts
Normal file
|
@ -0,0 +1,219 @@
|
|||
import { CLOUD_BASE_URL_PRODUCTION, CLOUD_BASE_URL_STAGING, STORES } from '@/constants';
|
||||
import type { RootState } from '@/Interface';
|
||||
import { setGlobalState } from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
const { VUE_APP_URL_BASE_API } = import.meta.env;
|
||||
|
||||
export const useRootStore = defineStore(STORES.ROOT, () => {
|
||||
const state = ref({
|
||||
baseUrl: VUE_APP_URL_BASE_API ?? window.BASE_PATH,
|
||||
restEndpoint:
|
||||
!window.REST_ENDPOINT || window.REST_ENDPOINT === '{{REST_ENDPOINT}}'
|
||||
? 'rest'
|
||||
: window.REST_ENDPOINT,
|
||||
defaultLocale: 'en',
|
||||
endpointForm: 'form',
|
||||
endpointFormTest: 'form-test',
|
||||
endpointFormWaiting: 'form-waiting',
|
||||
endpointWebhook: 'webhook',
|
||||
endpointWebhookTest: 'webhook-test',
|
||||
pushConnectionActive: true,
|
||||
timezone: 'America/New_York',
|
||||
executionTimeout: -1,
|
||||
maxExecutionTimeout: Number.MAX_SAFE_INTEGER,
|
||||
versionCli: '0.0.0',
|
||||
oauthCallbackUrls: {},
|
||||
n8nMetadata: {},
|
||||
pushRef: Math.random().toString(36).substring(2, 15),
|
||||
urlBaseWebhook: 'http://localhost:5678/',
|
||||
urlBaseEditor: 'http://localhost:5678',
|
||||
isNpmAvailable: false,
|
||||
instanceId: '',
|
||||
binaryDataMode: 'default',
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// #region Computed
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const baseUrl = computed(() => state.value.baseUrl);
|
||||
|
||||
const formUrl = computed(() => `${state.value.urlBaseWebhook}${state.value.endpointForm}`);
|
||||
|
||||
const formTestUrl = computed(() => `${state.value.urlBaseEditor}${state.value.endpointFormTest}`);
|
||||
|
||||
const formWaitingUrl = computed(() => `${state.value.baseUrl}${state.value.endpointFormWaiting}`);
|
||||
|
||||
const webhookUrl = computed(() => `${state.value.urlBaseWebhook}${state.value.endpointWebhook}`);
|
||||
|
||||
const pushRef = computed(() => state.value.pushRef);
|
||||
|
||||
const binaryDataMode = computed(() => state.value.binaryDataMode);
|
||||
|
||||
const defaultLocale = computed(() => state.value.defaultLocale);
|
||||
|
||||
const urlBaseEditor = computed(() => state.value.urlBaseEditor);
|
||||
|
||||
const instanceId = computed(() => state.value.instanceId);
|
||||
|
||||
const versionCli = computed(() => state.value.versionCli);
|
||||
|
||||
const pushConnectionActive = computed(() => state.value.pushConnectionActive);
|
||||
|
||||
const OAuthCallbackUrls = computed(() => state.value.oauthCallbackUrls);
|
||||
|
||||
const webhookTestUrl = computed(
|
||||
() => `${state.value.urlBaseEditor}${state.value.endpointWebhookTest}`,
|
||||
);
|
||||
|
||||
const restUrl = computed(() => `${state.value.baseUrl}${state.value.restEndpoint}`);
|
||||
|
||||
const executionTimeout = computed(() => state.value.executionTimeout);
|
||||
|
||||
const maxExecutionTimeout = computed(() => state.value.maxExecutionTimeout);
|
||||
|
||||
const timezone = computed(() => state.value.timezone);
|
||||
|
||||
const restCloudApiContext = computed(() => ({
|
||||
baseUrl: window.location.host.includes('stage-app.n8n.cloud')
|
||||
? CLOUD_BASE_URL_STAGING
|
||||
: CLOUD_BASE_URL_PRODUCTION,
|
||||
pushRef: '',
|
||||
}));
|
||||
|
||||
const restApiContext = computed(() => ({
|
||||
baseUrl: restUrl.value,
|
||||
pushRef: state.value.pushRef,
|
||||
}));
|
||||
|
||||
// #endregion
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// #region Methods
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const setUrlBaseWebhook = (urlBaseWebhook: string) => {
|
||||
const url = urlBaseWebhook.endsWith('/') ? urlBaseWebhook : `${urlBaseWebhook}/`;
|
||||
state.value.urlBaseWebhook = url;
|
||||
};
|
||||
|
||||
const setPushConnectionActive = () => {
|
||||
state.value.pushConnectionActive = true;
|
||||
};
|
||||
|
||||
const setPushConnectionInactive = () => {
|
||||
state.value.pushConnectionActive = false;
|
||||
};
|
||||
|
||||
const setUrlBaseEditor = (urlBaseEditor: string) => {
|
||||
const url = urlBaseEditor.endsWith('/') ? urlBaseEditor : `${urlBaseEditor}/`;
|
||||
state.value.urlBaseEditor = url;
|
||||
};
|
||||
|
||||
const setEndpointForm = (endpointForm: string) => {
|
||||
state.value.endpointForm = endpointForm;
|
||||
};
|
||||
|
||||
const setEndpointFormTest = (endpointFormTest: string) => {
|
||||
state.value.endpointFormTest = endpointFormTest;
|
||||
};
|
||||
|
||||
const setEndpointFormWaiting = (endpointFormWaiting: string) => {
|
||||
state.value.endpointFormWaiting = endpointFormWaiting;
|
||||
};
|
||||
|
||||
const setEndpointWebhook = (endpointWebhook: string) => {
|
||||
state.value.endpointWebhook = endpointWebhook;
|
||||
};
|
||||
|
||||
const setEndpointWebhookTest = (endpointWebhookTest: string) => {
|
||||
state.value.endpointWebhookTest = endpointWebhookTest;
|
||||
};
|
||||
|
||||
const setTimezone = (timezone: string) => {
|
||||
state.value.timezone = timezone;
|
||||
setGlobalState({ defaultTimezone: timezone });
|
||||
};
|
||||
|
||||
const setExecutionTimeout = (executionTimeout: number) => {
|
||||
state.value.executionTimeout = executionTimeout;
|
||||
};
|
||||
|
||||
const setMaxExecutionTimeout = (maxExecutionTimeout: number) => {
|
||||
state.value.maxExecutionTimeout = maxExecutionTimeout;
|
||||
};
|
||||
|
||||
const setVersionCli = (version: string) => {
|
||||
state.value.versionCli = version;
|
||||
};
|
||||
|
||||
const setInstanceId = (instanceId: string) => {
|
||||
state.value.instanceId = instanceId;
|
||||
};
|
||||
|
||||
const setOauthCallbackUrls = (urls: RootState['oauthCallbackUrls']) => {
|
||||
state.value.oauthCallbackUrls = urls;
|
||||
};
|
||||
|
||||
const setN8nMetadata = (metadata: RootState['n8nMetadata']) => {
|
||||
state.value.n8nMetadata = metadata;
|
||||
};
|
||||
|
||||
const setDefaultLocale = (locale: string) => {
|
||||
state.value.defaultLocale = locale;
|
||||
};
|
||||
|
||||
const setIsNpmAvailable = (isNpmAvailable: boolean) => {
|
||||
state.value.isNpmAvailable = isNpmAvailable;
|
||||
};
|
||||
|
||||
const setBinaryDataMode = (binaryDataMode: string) => {
|
||||
state.value.binaryDataMode = binaryDataMode;
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
return {
|
||||
baseUrl,
|
||||
formUrl,
|
||||
formTestUrl,
|
||||
formWaitingUrl,
|
||||
webhookUrl,
|
||||
webhookTestUrl,
|
||||
restUrl,
|
||||
restCloudApiContext,
|
||||
restApiContext,
|
||||
urlBaseEditor,
|
||||
versionCli,
|
||||
instanceId,
|
||||
pushRef,
|
||||
defaultLocale,
|
||||
binaryDataMode,
|
||||
pushConnectionActive,
|
||||
OAuthCallbackUrls,
|
||||
executionTimeout,
|
||||
maxExecutionTimeout,
|
||||
timezone,
|
||||
setPushConnectionInactive,
|
||||
setPushConnectionActive,
|
||||
setUrlBaseWebhook,
|
||||
setUrlBaseEditor,
|
||||
setEndpointForm,
|
||||
setEndpointFormTest,
|
||||
setEndpointFormWaiting,
|
||||
setEndpointWebhook,
|
||||
setEndpointWebhookTest,
|
||||
setTimezone,
|
||||
setExecutionTimeout,
|
||||
setMaxExecutionTimeout,
|
||||
setVersionCli,
|
||||
setInstanceId,
|
||||
setOauthCallbackUrls,
|
||||
setN8nMetadata,
|
||||
setDefaultLocale,
|
||||
setIsNpmAvailable,
|
||||
setBinaryDataMode,
|
||||
};
|
||||
});
|
|
@ -25,7 +25,7 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { ExpressionEvaluatorProxy } from 'n8n-workflow';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { useUIStore } from './ui.store';
|
||||
import { useUsersStore } from './users.store';
|
||||
import { useVersionsStore } from './versions.store';
|
||||
|
@ -262,7 +262,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
|
|||
},
|
||||
async getSettings(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const settings = await getSettings(rootStore.getRestApiContext);
|
||||
const settings = await getSettings(rootStore.restApiContext);
|
||||
|
||||
this.setSettings(settings);
|
||||
this.settings.communityNodesEnabled = settings.communityNodesEnabled;
|
||||
|
@ -325,37 +325,37 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
|
|||
},
|
||||
async getApiKey(): Promise<string | null> {
|
||||
const rootStore = useRootStore();
|
||||
const { apiKey } = await getApiKey(rootStore.getRestApiContext);
|
||||
const { apiKey } = await getApiKey(rootStore.restApiContext);
|
||||
return apiKey;
|
||||
},
|
||||
async createApiKey(): Promise<string | null> {
|
||||
const rootStore = useRootStore();
|
||||
const { apiKey } = await createApiKey(rootStore.getRestApiContext);
|
||||
const { apiKey } = await createApiKey(rootStore.restApiContext);
|
||||
return apiKey;
|
||||
},
|
||||
async deleteApiKey(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await deleteApiKey(rootStore.getRestApiContext);
|
||||
await deleteApiKey(rootStore.restApiContext);
|
||||
},
|
||||
async getLdapConfig() {
|
||||
const rootStore = useRootStore();
|
||||
return await getLdapConfig(rootStore.getRestApiContext);
|
||||
return await getLdapConfig(rootStore.restApiContext);
|
||||
},
|
||||
async getLdapSynchronizations(pagination: { page: number }) {
|
||||
const rootStore = useRootStore();
|
||||
return await getLdapSynchronizations(rootStore.getRestApiContext, pagination);
|
||||
return await getLdapSynchronizations(rootStore.restApiContext, pagination);
|
||||
},
|
||||
async testLdapConnection() {
|
||||
const rootStore = useRootStore();
|
||||
return await testLdapConnection(rootStore.getRestApiContext);
|
||||
return await testLdapConnection(rootStore.restApiContext);
|
||||
},
|
||||
async updateLdapConfig(ldapConfig: ILdapConfig) {
|
||||
const rootStore = useRootStore();
|
||||
return await updateLdapConfig(rootStore.getRestApiContext, ldapConfig);
|
||||
return await updateLdapConfig(rootStore.restApiContext, ldapConfig);
|
||||
},
|
||||
async runLdapSync(data: IDataObject) {
|
||||
const rootStore = useRootStore();
|
||||
return await runLdapSync(rootStore.getRestApiContext, data);
|
||||
return await runLdapSync(rootStore.restApiContext, data);
|
||||
},
|
||||
setSaveDataErrorExecution(newValue: string) {
|
||||
this.saveDataErrorExecution = newValue;
|
||||
|
@ -368,7 +368,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
|
|||
},
|
||||
async getTimezones(): Promise<IDataObject> {
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(rootStore.getRestApiContext, 'GET', '/options/timezones');
|
||||
return await makeRestApiRequest(rootStore.restApiContext, 'GET', '/options/timezones');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { computed, reactive } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import * as vcApi from '@/api/sourceControl';
|
||||
import type { SourceControlPreferences, SshKeyTypes } from '@/Interface';
|
||||
import type { TupleToUnion } from '@/utils/typeHelpers';
|
||||
|
@ -52,7 +52,7 @@ export const useSourceControlStore = defineStore('sourceControl', () => {
|
|||
force: boolean;
|
||||
}) => {
|
||||
state.commitMessage = data.commitMessage;
|
||||
await vcApi.pushWorkfolder(rootStore.getRestApiContext, {
|
||||
await vcApi.pushWorkfolder(rootStore.restApiContext, {
|
||||
force: data.force,
|
||||
message: data.commitMessage,
|
||||
...(data.fileNames ? { fileNames: data.fileNames } : {}),
|
||||
|
@ -60,7 +60,7 @@ export const useSourceControlStore = defineStore('sourceControl', () => {
|
|||
};
|
||||
|
||||
const pullWorkfolder = async (force: boolean) => {
|
||||
return await vcApi.pullWorkfolder(rootStore.getRestApiContext, { force });
|
||||
return await vcApi.pullWorkfolder(rootStore.restApiContext, { force });
|
||||
};
|
||||
|
||||
const setPreferences = (data: Partial<SourceControlPreferences>) => {
|
||||
|
@ -70,17 +70,17 @@ export const useSourceControlStore = defineStore('sourceControl', () => {
|
|||
const makePreferencesAction =
|
||||
(action: typeof vcApi.savePreferences) =>
|
||||
async (preferences: Partial<SourceControlPreferences>) => {
|
||||
const data = await action(rootStore.getRestApiContext, preferences);
|
||||
const data = await action(rootStore.restApiContext, preferences);
|
||||
setPreferences(data);
|
||||
};
|
||||
|
||||
const getBranches = async () => {
|
||||
const data = await vcApi.getBranches(rootStore.getRestApiContext);
|
||||
const data = await vcApi.getBranches(rootStore.restApiContext);
|
||||
setPreferences(data);
|
||||
};
|
||||
|
||||
const getPreferences = async () => {
|
||||
const data = await vcApi.getPreferences(rootStore.getRestApiContext);
|
||||
const data = await vcApi.getPreferences(rootStore.restApiContext);
|
||||
setPreferences(data);
|
||||
};
|
||||
|
||||
|
@ -89,13 +89,13 @@ export const useSourceControlStore = defineStore('sourceControl', () => {
|
|||
const updatePreferences = makePreferencesAction(vcApi.updatePreferences);
|
||||
|
||||
const disconnect = async (keepKeyPair: boolean) => {
|
||||
await vcApi.disconnect(rootStore.getRestApiContext, keepKeyPair);
|
||||
await vcApi.disconnect(rootStore.restApiContext, keepKeyPair);
|
||||
setPreferences({ connected: false, branches: [] });
|
||||
};
|
||||
|
||||
const generateKeyPair = async (keyGeneratorType?: TupleToUnion<SshKeyTypes>) => {
|
||||
await vcApi.generateKeyPair(rootStore.getRestApiContext, keyGeneratorType);
|
||||
const data = await vcApi.getPreferences(rootStore.getRestApiContext); // To be removed once the API is updated
|
||||
await vcApi.generateKeyPair(rootStore.restApiContext, keyGeneratorType);
|
||||
const data = await vcApi.getPreferences(rootStore.restApiContext); // To be removed once the API is updated
|
||||
|
||||
preferences.publicKey = data.publicKey;
|
||||
|
||||
|
@ -103,11 +103,11 @@ export const useSourceControlStore = defineStore('sourceControl', () => {
|
|||
};
|
||||
|
||||
const getStatus = async () => {
|
||||
return await vcApi.getStatus(rootStore.getRestApiContext);
|
||||
return await vcApi.getStatus(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
const getAggregatedStatus = async () => {
|
||||
return await vcApi.getAggregatedStatus(rootStore.getRestApiContext);
|
||||
return await vcApi.getAggregatedStatus(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { computed, reactive } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import * as ssoApi from '@/api/sso';
|
||||
import type { SamlPreferences, SamlPreferencesExtractedData } from '@/Interface';
|
||||
|
@ -53,23 +53,23 @@ export const useSSOStore = defineStore('sso', () => {
|
|||
isDefaultAuthenticationSaml.value,
|
||||
);
|
||||
|
||||
const getSSORedirectUrl = async () => await ssoApi.initSSO(rootStore.getRestApiContext);
|
||||
const getSSORedirectUrl = async () => await ssoApi.initSSO(rootStore.restApiContext);
|
||||
|
||||
const toggleLoginEnabled = async (enabled: boolean) =>
|
||||
await ssoApi.toggleSamlConfig(rootStore.getRestApiContext, { loginEnabled: enabled });
|
||||
await ssoApi.toggleSamlConfig(rootStore.restApiContext, { loginEnabled: enabled });
|
||||
|
||||
const getSamlMetadata = async () => await ssoApi.getSamlMetadata(rootStore.getRestApiContext);
|
||||
const getSamlMetadata = async () => await ssoApi.getSamlMetadata(rootStore.restApiContext);
|
||||
const getSamlConfig = async () => {
|
||||
const samlConfig = await ssoApi.getSamlConfig(rootStore.getRestApiContext);
|
||||
const samlConfig = await ssoApi.getSamlConfig(rootStore.restApiContext);
|
||||
state.samlConfig = samlConfig;
|
||||
return samlConfig;
|
||||
};
|
||||
const saveSamlConfig = async (config: SamlPreferences) =>
|
||||
await ssoApi.saveSamlConfig(rootStore.getRestApiContext, config);
|
||||
const testSamlConfig = async () => await ssoApi.testSamlConfig(rootStore.getRestApiContext);
|
||||
await ssoApi.saveSamlConfig(rootStore.restApiContext, config);
|
||||
const testSamlConfig = async () => await ssoApi.testSamlConfig(rootStore.restApiContext);
|
||||
|
||||
const updateUser = async (params: { firstName: string; lastName: string }) =>
|
||||
await updateCurrentUser(rootStore.getRestApiContext, {
|
||||
await updateCurrentUser(rootStore.restApiContext, {
|
||||
id: usersStore.currentUser!.id,
|
||||
email: usersStore.currentUser!.email!,
|
||||
...params,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { createTag, deleteTag, getTags, updateTag } from '@/api/tags';
|
|||
import { STORES } from '@/constants';
|
||||
import type { ITag, ITagsState } from '@/Interface';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { useWorkflowsStore } from './workflows.store';
|
||||
|
||||
export const useTagsStore = defineStore(STORES.TAGS, {
|
||||
|
@ -69,7 +69,7 @@ export const useTagsStore = defineStore(STORES.TAGS, {
|
|||
|
||||
this.loading = true;
|
||||
const rootStore = useRootStore();
|
||||
const tags = await getTags(rootStore.getRestApiContext, Boolean(withUsageCount));
|
||||
const tags = await getTags(rootStore.restApiContext, Boolean(withUsageCount));
|
||||
this.setAllTags(tags);
|
||||
this.loading = false;
|
||||
|
||||
|
@ -77,21 +77,21 @@ export const useTagsStore = defineStore(STORES.TAGS, {
|
|||
},
|
||||
async create(name: string): Promise<ITag> {
|
||||
const rootStore = useRootStore();
|
||||
const tag = await createTag(rootStore.getRestApiContext, { name });
|
||||
const tag = await createTag(rootStore.restApiContext, { name });
|
||||
this.upsertTags([tag]);
|
||||
|
||||
return tag;
|
||||
},
|
||||
async rename({ id, name }: { id: string; name: string }) {
|
||||
const rootStore = useRootStore();
|
||||
const tag = await updateTag(rootStore.getRestApiContext, id, { name });
|
||||
const tag = await updateTag(rootStore.restApiContext, id, { name });
|
||||
this.upsertTags([tag]);
|
||||
|
||||
return tag;
|
||||
},
|
||||
async delete(id: string) {
|
||||
const rootStore = useRootStore();
|
||||
const deleted = await deleteTag(rootStore.getRestApiContext, id);
|
||||
const deleted = await deleteTag(rootStore.restApiContext, id);
|
||||
|
||||
if (deleted) {
|
||||
this.deleteTag(id);
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
getWorkflowTemplate,
|
||||
} from '@/api/templates';
|
||||
import { getFixedNodesList } from '@/utils/nodeViewUtils';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUsersStore } from './users.store';
|
||||
import { useWorkflowsStore } from './workflows.store';
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ import type {
|
|||
ModalKey,
|
||||
} from '@/Interface';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { getCurlToJson } from '@/api/curlHelper';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
|
@ -552,7 +552,7 @@ export const useUIStore = defineStore(STORES.UI, {
|
|||
},
|
||||
async getCurlToJson(curlCommand: string): Promise<CurlToJSONResponse> {
|
||||
const rootStore = useRootStore();
|
||||
const parameters = await getCurlToJson(rootStore.getRestApiContext, curlCommand);
|
||||
const parameters = await getCurlToJson(rootStore.restApiContext, curlCommand);
|
||||
|
||||
// Normalize placeholder values
|
||||
if (parameters['parameters.url']) {
|
||||
|
@ -594,7 +594,7 @@ export const useUIStore = defineStore(STORES.UI, {
|
|||
type: 'temporary' | 'permanent' = 'temporary',
|
||||
): Promise<void> {
|
||||
if (type === 'permanent') {
|
||||
await dismissBannerPermanently(useRootStore().getRestApiContext, {
|
||||
await dismissBannerPermanently(useRootStore().restApiContext, {
|
||||
bannerName: name,
|
||||
dismissedBanners: useSettingsStore().permanentlyDismissedBanners,
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import { computed, reactive } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
import type { UsageState } from '@/Interface';
|
||||
import { activateLicenseKey, getLicense, renewLicense, requestLicenseTrial } from '@/api/usage';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
|
||||
|
@ -65,19 +65,19 @@ export const useUsageStore = defineStore('usage', () => {
|
|||
};
|
||||
|
||||
const getLicenseInfo = async () => {
|
||||
const data = await getLicense(rootStore.getRestApiContext);
|
||||
const data = await getLicense(rootStore.restApiContext);
|
||||
setData(data);
|
||||
};
|
||||
|
||||
const activateLicense = async (activationKey: string) => {
|
||||
const data = await activateLicenseKey(rootStore.getRestApiContext, { activationKey });
|
||||
const data = await activateLicenseKey(rootStore.restApiContext, { activationKey });
|
||||
setData(data);
|
||||
await settingsStore.getSettings();
|
||||
};
|
||||
|
||||
const refreshLicenseManagementToken = async () => {
|
||||
try {
|
||||
const data = await renewLicense(rootStore.getRestApiContext);
|
||||
const data = await renewLicense(rootStore.restApiContext);
|
||||
setData(data);
|
||||
} catch (error) {
|
||||
await getLicenseInfo();
|
||||
|
@ -85,7 +85,7 @@ export const useUsageStore = defineStore('usage', () => {
|
|||
};
|
||||
|
||||
const requestEnterpriseLicenseTrial = async () => {
|
||||
await requestLicenseTrial(rootStore.getRestApiContext);
|
||||
await requestLicenseTrial(rootStore.restApiContext);
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -32,7 +32,7 @@ import type {
|
|||
} from '@/Interface';
|
||||
import { getPersonalizedNodeTypes } from '@/utils/userUtils';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { usePostHog } from './posthog.store';
|
||||
import { useSettingsStore } from './settings.store';
|
||||
import { useUIStore } from './ui.store';
|
||||
|
@ -159,7 +159,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
},
|
||||
async loginWithCookie(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const user = await loginCurrentUser(rootStore.getRestApiContext);
|
||||
const user = await loginCurrentUser(rootStore.restApiContext);
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
mfaRecoveryCode?: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const user = await login(rootStore.getRestApiContext, params);
|
||||
const user = await login(rootStore.restApiContext, params);
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
},
|
||||
async logout(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await logout(rootStore.getRestApiContext);
|
||||
await logout(rootStore.restApiContext);
|
||||
this.unsetCurrentUser();
|
||||
useCloudPlanStore().reset();
|
||||
usePostHog().reset();
|
||||
|
@ -196,7 +196,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
password: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const user = await setupOwner(rootStore.getRestApiContext, params);
|
||||
const user = await setupOwner(rootStore.restApiContext, params);
|
||||
const settingsStore = useSettingsStore();
|
||||
if (user) {
|
||||
this.setCurrentUser(user);
|
||||
|
@ -208,7 +208,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
inviterId: string;
|
||||
}): Promise<{ inviter: { firstName: string; lastName: string } }> {
|
||||
const rootStore = useRootStore();
|
||||
return await validateSignupToken(rootStore.getRestApiContext, params);
|
||||
return await validateSignupToken(rootStore.restApiContext, params);
|
||||
},
|
||||
async acceptInvitation(params: {
|
||||
inviteeId: string;
|
||||
|
@ -218,18 +218,18 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
password: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const user = await acceptInvitation(rootStore.getRestApiContext, params);
|
||||
const user = await acceptInvitation(rootStore.restApiContext, params);
|
||||
if (user) {
|
||||
this.setCurrentUser(user);
|
||||
}
|
||||
},
|
||||
async sendForgotPasswordEmail(params: { email: string }): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await sendForgotPasswordEmail(rootStore.getRestApiContext, params);
|
||||
await sendForgotPasswordEmail(rootStore.restApiContext, params);
|
||||
},
|
||||
async validatePasswordToken(params: { token: string }): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await validatePasswordToken(rootStore.getRestApiContext, params);
|
||||
await validatePasswordToken(rootStore.restApiContext, params);
|
||||
},
|
||||
async changePassword(params: {
|
||||
token: string;
|
||||
|
@ -237,7 +237,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
mfaToken?: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await changePassword(rootStore.getRestApiContext, params);
|
||||
await changePassword(rootStore.restApiContext, params);
|
||||
},
|
||||
async updateUser(params: {
|
||||
id: string;
|
||||
|
@ -246,15 +246,12 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
email: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const user = await updateCurrentUser(rootStore.getRestApiContext, params);
|
||||
const user = await updateCurrentUser(rootStore.restApiContext, params);
|
||||
this.addUsers([user]);
|
||||
},
|
||||
async updateUserSettings(settings: IUpdateUserSettingsReqPayload): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const updatedSettings = await updateCurrentUserSettings(
|
||||
rootStore.getRestApiContext,
|
||||
settings,
|
||||
);
|
||||
const updatedSettings = await updateCurrentUserSettings(rootStore.restApiContext, settings);
|
||||
if (this.currentUser) {
|
||||
this.currentUser.settings = updatedSettings;
|
||||
this.addUsers([this.currentUser]);
|
||||
|
@ -266,7 +263,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const updatedSettings = await updateOtherUserSettings(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
userId,
|
||||
settings,
|
||||
);
|
||||
|
@ -281,26 +278,26 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
currentPassword: string;
|
||||
}): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await updateCurrentUserPassword(rootStore.getRestApiContext, {
|
||||
await updateCurrentUserPassword(rootStore.restApiContext, {
|
||||
newPassword: password,
|
||||
currentPassword,
|
||||
});
|
||||
},
|
||||
async deleteUser(params: { id: string; transferId?: string }): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await deleteUser(rootStore.getRestApiContext, params);
|
||||
await deleteUser(rootStore.restApiContext, params);
|
||||
this.deleteUserById(params.id);
|
||||
},
|
||||
async fetchUsers(): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const users = await getUsers(rootStore.getRestApiContext);
|
||||
const users = await getUsers(rootStore.restApiContext);
|
||||
this.addUsers(users);
|
||||
},
|
||||
async inviteUsers(
|
||||
params: Array<{ email: string; role: InvitableRoleName }>,
|
||||
): Promise<IInviteResponse[]> {
|
||||
const rootStore = useRootStore();
|
||||
const users = await inviteUsers(rootStore.getRestApiContext, params);
|
||||
const users = await inviteUsers(rootStore.restApiContext, params);
|
||||
this.addUsers(
|
||||
users.map(({ user }, index) => ({
|
||||
isPending: true,
|
||||
|
@ -312,18 +309,18 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
},
|
||||
async reinviteUser({ email, role }: { email: string; role: InvitableRoleName }): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const invitationResponse = await inviteUsers(rootStore.getRestApiContext, [{ email, role }]);
|
||||
const invitationResponse = await inviteUsers(rootStore.restApiContext, [{ email, role }]);
|
||||
if (!invitationResponse[0].user.emailSent) {
|
||||
throw Error(invitationResponse[0].error);
|
||||
}
|
||||
},
|
||||
async getUserPasswordResetLink(params: { id: string }): Promise<{ link: string }> {
|
||||
const rootStore = useRootStore();
|
||||
return await getPasswordResetLink(rootStore.getRestApiContext, params);
|
||||
return await getPasswordResetLink(rootStore.restApiContext, params);
|
||||
},
|
||||
async submitPersonalizationSurvey(results: IPersonalizationLatestVersion): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
await submitPersonalizationSurvey(rootStore.getRestApiContext, results);
|
||||
await submitPersonalizationSurvey(rootStore.restApiContext, results);
|
||||
this.setPersonalizationAnswers(results);
|
||||
},
|
||||
async showPersonalizationSurvey(): Promise<void> {
|
||||
|
@ -337,16 +334,16 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
},
|
||||
async getMfaQR(): Promise<{ qrCode: string; secret: string; recoveryCodes: string[] }> {
|
||||
const rootStore = useRootStore();
|
||||
return await getMfaQR(rootStore.getRestApiContext);
|
||||
return await getMfaQR(rootStore.restApiContext);
|
||||
},
|
||||
async verifyMfaToken(data: { token: string }): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
return await verifyMfaToken(rootStore.getRestApiContext, data);
|
||||
return await verifyMfaToken(rootStore.restApiContext, data);
|
||||
},
|
||||
async enableMfa(data: { token: string }) {
|
||||
const rootStore = useRootStore();
|
||||
const usersStore = useUsersStore();
|
||||
await enableMfa(rootStore.getRestApiContext, data);
|
||||
await enableMfa(rootStore.restApiContext, data);
|
||||
const currentUser = usersStore.currentUser;
|
||||
if (currentUser) {
|
||||
currentUser.mfaEnabled = true;
|
||||
|
@ -355,7 +352,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
async disabledMfa() {
|
||||
const rootStore = useRootStore();
|
||||
const usersStore = useUsersStore();
|
||||
await disableMfa(rootStore.getRestApiContext);
|
||||
await disableMfa(rootStore.restApiContext);
|
||||
const currentUser = usersStore.currentUser;
|
||||
if (currentUser) {
|
||||
currentUser.mfaEnabled = false;
|
||||
|
@ -364,19 +361,19 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
async fetchUserCloudAccount() {
|
||||
let cloudUser: Cloud.UserAccount | null = null;
|
||||
try {
|
||||
cloudUser = await getCloudUserInfo(useRootStore().getRestApiContext);
|
||||
cloudUser = await getCloudUserInfo(useRootStore().restApiContext);
|
||||
this.currentUserCloudInfo = cloudUser;
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
async confirmEmail() {
|
||||
await confirmEmail(useRootStore().getRestApiContext);
|
||||
await confirmEmail(useRootStore().restApiContext);
|
||||
},
|
||||
|
||||
async updateGlobalRole({ id, newRoleName }: UpdateGlobalRolePayload) {
|
||||
const rootStore = useRootStore();
|
||||
await updateGlobalRole(rootStore.getRestApiContext, { id, newRoleName });
|
||||
await updateGlobalRole(rootStore.restApiContext, { id, newRoleName });
|
||||
await this.fetchUsers();
|
||||
},
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ import { getNextVersions } from '@/api/versions';
|
|||
import { STORES, VERSIONS_MODAL_KEY } from '@/constants';
|
||||
import type { IVersion, IVersionNotificationSettings, IVersionsState } from '@/Interface';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { STORES } from '@/constants';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useRootStore } from './n8nRoot.store';
|
||||
import { useRootStore } from './root.store';
|
||||
import { useNDVStore } from './ndv.store';
|
||||
import { useUIStore } from './ui.store';
|
||||
import { useUsersStore } from './users.store';
|
||||
|
|
|
@ -9,7 +9,7 @@ import type {
|
|||
WorkflowVersionId,
|
||||
} from '@/types/workflowHistory';
|
||||
import * as whApi from '@/api/workflowHistory';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { getNewWorkflow } from '@/api/workflows';
|
||||
|
@ -30,13 +30,13 @@ export const useWorkflowHistoryStore = defineStore('workflowHistory', () => {
|
|||
workflowId: string,
|
||||
queryParams: WorkflowHistoryRequestParams,
|
||||
): Promise<WorkflowHistory[]> =>
|
||||
await whApi.getWorkflowHistory(rootStore.getRestApiContext, workflowId, queryParams);
|
||||
await whApi.getWorkflowHistory(rootStore.restApiContext, workflowId, queryParams);
|
||||
|
||||
const getWorkflowVersion = async (
|
||||
workflowId: string,
|
||||
versionId: string,
|
||||
): Promise<WorkflowVersion> =>
|
||||
await whApi.getWorkflowVersion(rootStore.getRestApiContext, workflowId, versionId);
|
||||
await whApi.getWorkflowVersion(rootStore.restApiContext, workflowId, versionId);
|
||||
|
||||
const downloadVersion = async (
|
||||
workflowId: string,
|
||||
|
@ -65,7 +65,7 @@ export const useWorkflowHistoryStore = defineStore('workflowHistory', () => {
|
|||
]);
|
||||
const { connections, nodes } = workflowVersion;
|
||||
const { name } = workflow;
|
||||
const newWorkflow = await getNewWorkflow(rootStore.getRestApiContext, {
|
||||
const newWorkflow = await getNewWorkflow(rootStore.restApiContext, {
|
||||
name: `${name} (${data.formattedCreatedAt})`,
|
||||
});
|
||||
const newWorkflowData: IWorkflowDataUpdate = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { setWorkflowSharedWith } from '@/api/workflows.ee';
|
||||
import { EnterpriseEditionFeature, STORES } from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
|
@ -51,7 +51,7 @@ export const useWorkflowsEEStore = defineStore(STORES.WORKFLOWS_EE, {
|
|||
const settingsStore = useSettingsStore();
|
||||
|
||||
if (settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing)) {
|
||||
await setWorkflowSharedWith(rootStore.getRestApiContext, payload.workflowId, {
|
||||
await setWorkflowSharedWith(rootStore.restApiContext, payload.workflowId, {
|
||||
shareWithIds: payload.sharedWithProjects.map((p) => p.id),
|
||||
});
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ import type {
|
|||
import { deepCopy, NodeHelpers, Workflow } from 'n8n-workflow';
|
||||
import { findLast } from 'lodash-es';
|
||||
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import * as workflowsApi from '@/api/workflows';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { dataPinningEventBus } from '@/event-bus';
|
||||
|
@ -371,7 +371,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
async function getWorkflowFromUrl(url: string): Promise<IWorkflowDb> {
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(rootStore.getRestApiContext, 'GET', '/workflows/from-url', {
|
||||
return await makeRestApiRequest(rootStore.restApiContext, 'GET', '/workflows/from-url', {
|
||||
url,
|
||||
});
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
async function getActivationError(id: string): Promise<string | undefined> {
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'GET',
|
||||
`/active-workflows/error/${id}`,
|
||||
);
|
||||
|
@ -393,7 +393,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
};
|
||||
|
||||
const workflows = await workflowsApi.getWorkflows(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
isEmpty(filter) ? undefined : filter,
|
||||
);
|
||||
setWorkflows(workflows);
|
||||
|
@ -402,7 +402,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
async function fetchWorkflow(id: string): Promise<IWorkflowDb> {
|
||||
const rootStore = useRootStore();
|
||||
const workflow = await workflowsApi.getWorkflow(rootStore.getRestApiContext, id);
|
||||
const workflow = await workflowsApi.getWorkflow(rootStore.restApiContext, id);
|
||||
addWorkflow(workflow);
|
||||
return workflow;
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
};
|
||||
|
||||
workflowData = await workflowsApi.getNewWorkflow(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
isEmpty(data) ? undefined : data,
|
||||
);
|
||||
} catch (e) {
|
||||
|
@ -544,7 +544,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
async function deleteWorkflow(id: string) {
|
||||
const rootStore = useRootStore();
|
||||
await makeRestApiRequest(rootStore.getRestApiContext, 'DELETE', `/workflows/${id}`);
|
||||
await makeRestApiRequest(rootStore.restApiContext, 'DELETE', `/workflows/${id}`);
|
||||
const { [id]: deletedWorkflow, ...workflows } = workflowsById.value;
|
||||
workflowsById.value = workflows;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
async function fetchActiveWorkflows(): Promise<string[]> {
|
||||
const rootStore = useRootStore();
|
||||
const data = await workflowsApi.getActiveWorkflows(rootStore.getRestApiContext);
|
||||
const data = await workflowsApi.getActiveWorkflows(rootStore.restApiContext);
|
||||
activeWorkflows.value = data;
|
||||
return data;
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
let newName = `${currentWorkflowName}${DUPLICATE_POSTFFIX}`;
|
||||
try {
|
||||
const rootStore = useRootStore();
|
||||
const newWorkflow = await workflowsApi.getNewWorkflow(rootStore.getRestApiContext, {
|
||||
const newWorkflow = await workflowsApi.getNewWorkflow(rootStore.restApiContext, {
|
||||
name: newName,
|
||||
});
|
||||
newName = newWorkflow.name;
|
||||
|
@ -1285,7 +1285,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
};
|
||||
}
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(rootStore.getRestApiContext, 'GET', '/executions', sendData);
|
||||
return await makeRestApiRequest(rootStore.restApiContext, 'GET', '/executions', sendData);
|
||||
}
|
||||
|
||||
async function getActiveExecutions(
|
||||
|
@ -1299,7 +1299,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
}
|
||||
const rootStore = useRootStore();
|
||||
const output = await makeRestApiRequest<{ results: IExecutionsCurrentSummaryExtended[] }>(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'GET',
|
||||
'/executions',
|
||||
sendData,
|
||||
|
@ -1311,7 +1311,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
async function getExecution(id: string): Promise<IExecutionResponse | undefined> {
|
||||
const rootStore = useRootStore();
|
||||
const response = await makeRestApiRequest<IExecutionFlattedResponse | undefined>(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'GET',
|
||||
`/executions/${id}`,
|
||||
);
|
||||
|
@ -1331,7 +1331,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
}
|
||||
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'POST',
|
||||
'/workflows',
|
||||
sendData as unknown as IDataObject,
|
||||
|
@ -1350,7 +1350,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
}
|
||||
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'PATCH',
|
||||
`/workflows/${id}${forceSave ? '?forceSave=true' : ''}`,
|
||||
data as unknown as IDataObject,
|
||||
|
@ -1366,7 +1366,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
try {
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'POST',
|
||||
`/workflows/${startRunData.workflowData.id}/run`,
|
||||
startRunData as unknown as IDataObject,
|
||||
|
@ -1385,7 +1385,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
async function removeTestWebhook(targetWorkflowId: string): Promise<boolean> {
|
||||
const rootStore = useRootStore();
|
||||
return await makeRestApiRequest(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
'DELETE',
|
||||
`/test-webhook/${targetWorkflowId}`,
|
||||
);
|
||||
|
@ -1404,14 +1404,14 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
const rootStore = useRootStore();
|
||||
if ((!requestFilter.status || !requestFilter.finished) && isEmpty(requestFilter.metadata)) {
|
||||
retrievedActiveExecutions = await workflowsApi.getActiveExecutions(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
{
|
||||
workflowId: requestFilter.workflowId,
|
||||
},
|
||||
);
|
||||
}
|
||||
const retrievedFinishedExecutions = await workflowsApi.getExecutions(
|
||||
rootStore.getRestApiContext,
|
||||
rootStore.restApiContext,
|
||||
requestFilter,
|
||||
);
|
||||
finishedExecutionsCount.value = retrievedFinishedExecutions.count;
|
||||
|
@ -1423,7 +1423,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
|
||||
async function fetchExecutionDataById(executionId: string): Promise<IExecutionResponse | null> {
|
||||
const rootStore = useRootStore();
|
||||
return await workflowsApi.getExecutionData(rootStore.getRestApiContext, executionId);
|
||||
return await workflowsApi.getExecutionData(rootStore.restApiContext, executionId);
|
||||
}
|
||||
|
||||
function deleteExecution(execution: ExecutionSummary): void {
|
||||
|
@ -1446,7 +1446,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
mimeType: string,
|
||||
): string {
|
||||
const rootStore = useRootStore();
|
||||
let restUrl = rootStore.getRestUrl;
|
||||
let restUrl = rootStore.restUrl;
|
||||
if (restUrl.startsWith('/')) restUrl = window.location.origin + restUrl;
|
||||
const url = new URL(`${restUrl}/binary-data`);
|
||||
url.searchParams.append('id', binaryDataId);
|
||||
|
|
|
@ -6,7 +6,7 @@ import type {
|
|||
} from '@/Interface';
|
||||
import { getNewWorkflow } from '@/api/workflows';
|
||||
import { TEMPLATE_CREDENTIAL_SETUP_EXPERIMENT, VIEWS } from '@/constants';
|
||||
import type { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import type { useRootStore } from '@/stores/root.store';
|
||||
import type { PosthogStore } from '@/stores/posthog.store';
|
||||
import type { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { getFixedNodesList } from '@/utils/nodeViewUtils';
|
||||
|
@ -37,7 +37,7 @@ export async function createWorkflowFromTemplate(opts: {
|
|||
}) {
|
||||
const { credentialOverrides, nodeTypeProvider, rootStore, template, workflowsStore } = opts;
|
||||
|
||||
const workflowData = await getNewWorkflow(rootStore.getRestApiContext, { name: template.name });
|
||||
const workflowData = await getNewWorkflow(rootStore.restApiContext, { name: template.name });
|
||||
const nodesWithCreds = replaceAllTemplateNodeCredentials(
|
||||
nodeTypeProvider,
|
||||
template.workflow.nodes,
|
||||
|
|
|
@ -33,7 +33,7 @@ import { useSettingsStore } from '@/stores/settings.store';
|
|||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import useEnvironmentsStore from '@/stores/environments.ee.store';
|
||||
import { useExternalSecretsStore } from '@/stores/externalSecrets.ee.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useCollaborationStore } from '@/stores/collaboration.store';
|
||||
import { getUniqueNodeName } from '@/utils/canvasUtilsV2';
|
||||
import { historyBus } from '@/models/history';
|
||||
|
@ -1001,6 +1001,7 @@ function onUpdateNodeValue(parameterData: IUpdateInformation) {
|
|||
<NodeDetailsView
|
||||
:read-only="isReadOnlyRoute || isReadOnlyEnvironment"
|
||||
:is-production-execution-preview="isProductionExecutionPreview"
|
||||
:renaming="false"
|
||||
@value-changed="onUpdateNodeValue"
|
||||
@switch-selected-node="onSwitchSelectedNode"
|
||||
@open-connection-node-creator="onOpenConnectionNodeCreator"
|
||||
|
|
|
@ -336,7 +336,7 @@ import { useNDVStore } from '@/stores/ndv.store';
|
|||
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { usePushConnectionStore } from '@/stores/pushConnection.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useSegment } from '@/stores/segment.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useTagsStore } from '@/stores/tags.store';
|
||||
|
|
|
@ -93,7 +93,7 @@ import { useMessage } from '@/composables/useMessage';
|
|||
import CopyInput from '@/components/CopyInput.vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useCloudPlanStore } from '@/stores/cloudPlan.store';
|
||||
|
|
|
@ -7,7 +7,7 @@ import { useI18n } from '@/composables/useI18n';
|
|||
import { useMessage } from '@/composables/useMessage';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useTelemetry } from '@/composables/useTelemetry';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
const IdentityProviderSettingsType = {
|
||||
URL: 'url',
|
||||
|
|
|
@ -3,7 +3,7 @@ import { computed, ref } from 'vue';
|
|||
import type { Router } from 'vue-router';
|
||||
import { useCredentialsStore } from '@/stores/credentials.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
import { useTemplatesStore } from '@/stores/templates.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import type { INodeTypeDescription } from 'n8n-workflow';
|
||||
|
|
|
@ -18,7 +18,7 @@ import { useWorkflowHistoryStore } from '@/stores/workflowHistory.store';
|
|||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { telemetry } from '@/plugins/telemetry';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
|
||||
type WorkflowHistoryActionRecord = {
|
||||
[K in Uppercase<WorkflowHistoryActionTypes[number]>]: Lowercase<K>;
|
||||
|
|
Loading…
Reference in a new issue