refactor(editor): Consolidate IN8nUISettings interface (#6055)

* consolidate IN8nUISettings

* cleanup
This commit is contained in:
Michael Auerswald 2023-04-21 13:30:57 +02:00 committed by GitHub
parent 0e93fe064e
commit ac245fdb8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 151 additions and 214 deletions

View file

@ -13,7 +13,6 @@ import type {
IRunData,
IRunExecutionData,
ITaskData,
ITelemetrySettings,
ITelemetryTrackProperties,
IWorkflowBase,
CredentialLoadingDetails,
@ -23,8 +22,6 @@ import type {
ExecutionStatus,
IExecutionsSummary,
FeatureFlags,
WorkflowSettings,
AuthenticationMethod,
} from 'n8n-workflow';
import type { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
@ -469,90 +466,6 @@ export interface IVersionNotificationSettings {
infoUrl: string;
}
export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: WorkflowSettings.SaveDataExecution;
saveDataSuccessExecution: WorkflowSettings.SaveDataExecution;
saveManualExecutions: boolean;
executionTimeout: number;
maxExecutionTimeout: number;
workflowCallerPolicyDefaultOption: WorkflowSettings.CallerPolicy;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
timezone: string;
urlBaseWebhook: string;
urlBaseEditor: string;
versionCli: string;
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
telemetry: ITelemetrySettings;
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
personalizationSurveyEnabled: boolean;
userActivationSurveyEnabled: boolean;
defaultLocale: string;
userManagement: IUserManagementSettings;
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
publicApi: IPublicApiSettings;
workflowTagsDisabled: boolean;
logLevel: 'info' | 'debug' | 'warn' | 'error' | 'verbose' | 'silent';
hiringBannerEnabled: boolean;
templates: {
enabled: boolean;
host: string;
};
onboardingCallPromptEnabled: boolean;
missingPackages?: boolean;
executionMode: 'regular' | 'queue';
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
deployment: {
type: string;
};
isNpmAvailable: boolean;
allowedModules: {
builtIn?: string;
external?: string;
};
enterprise: {
sharing: boolean;
ldap: boolean;
saml: boolean;
logStreaming: boolean;
advancedExecutionFilters: boolean;
variables: boolean;
versionControl: boolean;
};
hideUsagePage: boolean;
license: {
environment: 'production' | 'staging';
};
variables: {
limit: number;
};
}
export interface IPersonalizationSurveyAnswers {
email: string | null;
codingSkill: string | null;
@ -570,23 +483,9 @@ export interface IUserSettings {
userActivated?: boolean;
}
export interface IUserManagementSettings {
enabled: boolean;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: AuthenticationMethod;
}
export interface IActiveDirectorySettings {
enabled: boolean;
}
export interface IPublicApiSettings {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
}
export interface IPackageVersions {
cli: string;

View file

@ -49,6 +49,7 @@ import type {
ICredentialTypes,
ExecutionStatus,
IExecutionsSummary,
IN8nUISettings,
} from 'n8n-workflow';
import { LoggerProxy, jsonParse } from 'n8n-workflow';
@ -112,7 +113,6 @@ import type {
IDiagnosticInfo,
IExecutionFlattedDb,
IExecutionsStopData,
IN8nUISettings,
} from '@/Interfaces';
import { ActiveExecutions } from '@/ActiveExecutions';
import {
@ -313,8 +313,8 @@ class Server extends AbstractServer {
},
isNpmAvailable: false,
allowedModules: {
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN,
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL,
builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
},
enterprise: {
sharing: false,

View file

@ -17,7 +17,6 @@ import {
IRun,
IRunData,
ITaskData,
ITelemetrySettings,
IWorkflowSettings as IWorkflowSettingsWorkflow,
WorkflowExecuteMode,
PublicInstalledPackage,
@ -33,6 +32,9 @@ import {
FeatureFlags,
ExecutionStatus,
ITelemetryTrackProperties,
IN8nUISettings,
IUserManagementSettings,
WorkflowSettings,
} from 'n8n-workflow';
import { SignInType } from './constants';
import { FAKE_DOOR_FEATURES, TRIGGER_NODE_FILTER, REGULAR_NODE_FILTER } from './constants';
@ -641,13 +643,6 @@ export const enum UserManagementAuthenticationMethod {
Saml = 'saml',
}
export interface IUserManagementConfig {
enabled: boolean;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: UserManagementAuthenticationMethod;
}
export interface IPermissionGroup {
loginStatus?: ILogInStatus[];
role?: IRole[];
@ -732,94 +727,14 @@ export interface ITemplatesCategory {
export type WorkflowCallerPolicyDefaultOption = 'any' | 'none' | 'workflowsFromAList';
export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: string;
saveDataSuccessExecution: string;
saveManualExecutions: boolean;
workflowCallerPolicyDefaultOption: WorkflowCallerPolicyDefaultOption;
timezone: string;
executionTimeout: number;
maxExecutionTimeout: number;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
urlBaseEditor: string;
urlBaseWebhook: string;
versionCli: string;
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
personalizationSurveyEnabled: boolean;
userActivationSurveyEnabled: boolean;
telemetry: ITelemetrySettings;
userManagement: IUserManagementConfig;
defaultLocale: string;
workflowTagsDisabled: boolean;
logLevel: ILogLevel;
hiringBannerEnabled: boolean;
templates: {
enabled: boolean;
host: string;
};
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
executionMode: string;
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
isNpmAvailable: boolean;
publicApi: {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
};
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
onboardingCallPromptEnabled: boolean;
allowedModules: {
builtIn?: string[];
external?: string[];
};
enterprise: Record<string, boolean>;
deployment?: {
type: string | 'default' | 'n8n-internal' | 'cloud' | 'desktop_mac' | 'desktop_win';
};
hideUsagePage: boolean;
license: {
environment: 'development' | 'production';
};
}
export interface IWorkflowSettings extends IWorkflowSettingsWorkflow {
errorWorkflow?: string;
saveDataErrorExecution?: string;
saveDataSuccessExecution?: string;
saveManualExecutions?: boolean;
timezone?: string;
executionTimeout?: number;
maxExecutionTimeout?: number;
callerIds?: string;
callerPolicy?: WorkflowCallerPolicyDefaultOption;
callerPolicy?: WorkflowSettings.CallerPolicy;
}
export interface ITimeoutHMS {
@ -1177,9 +1092,6 @@ export interface UIState {
addFirstStepOnLoad: boolean;
executionSidebarAutoRefresh: boolean;
}
export type ILogLevel = 'info' | 'debug' | 'warn' | 'error' | 'verbose';
export type IFakeDoor = {
id: FAKE_DOOR_FEATURES;
featureName: string;
@ -1221,7 +1133,7 @@ export interface INodeCreatorState {
export interface ISettingsState {
settings: IN8nUISettings;
promptsData: IN8nPrompts;
userManagement: IUserManagementConfig;
userManagement: IUserManagementSettings;
templatesEndpointHealthy: boolean;
api: {
enabled: boolean;

View file

@ -1,6 +1,6 @@
import { Response, Server } from 'miragejs';
import { AppSchema } from '../types';
import { IN8nUISettings, ISettingsState } from '@/Interface';
import { IN8nUISettings } from 'n8n-workflow';
const defaultSettings: IN8nUISettings = {
allowedModules: {},
@ -9,9 +9,15 @@ const defaultSettings: IN8nUISettings = {
endpointWebhook: '',
endpointWebhookTest: '',
enterprise: {
sharing: false,
ldap: false,
saml: false,
logStreaming: false,
advancedExecutionFilters: false,
variables: true,
versionControl: false,
},
executionMode: '',
executionMode: 'regular',
executionTimeout: 0,
hideUsagePage: false,
hiringBannerEnabled: false,
@ -33,8 +39,8 @@ const defaultSettings: IN8nUISettings = {
},
publicApi: { enabled: false, latestVersion: 0, path: '', swaggerUi: { enabled: false } },
pushBackend: 'websocket',
saveDataErrorExecution: '',
saveDataSuccessExecution: '',
saveDataErrorExecution: 'DEFAULT',
saveDataSuccessExecution: 'DEFAULT',
saveManualExecutions: false,
sso: {
ldap: { loginEnabled: false, loginLabel: '' },
@ -51,6 +57,7 @@ const defaultSettings: IN8nUISettings = {
enabled: true,
showSetupOnFirstLoad: true,
smtpSetup: true,
authenticationMethod: 'email',
},
versionCli: '',
versionNotifications: {
@ -60,6 +67,13 @@ const defaultSettings: IN8nUISettings = {
},
workflowCallerPolicyDefaultOption: 'any',
workflowTagsDisabled: false,
variables: {
limit: -1,
},
userActivationSurveyEnabled: false,
deployment: {
type: 'default',
},
};
export function routesForSettings(server: Server) {

View file

@ -2,11 +2,11 @@ import {
IRestApiContext,
IN8nPrompts,
IN8nValueSurveyData,
IN8nUISettings,
IN8nPromptResponse,
} from '../Interface';
import { makeRestApiRequest, get, post } from '@/utils';
import { N8N_IO_BASE_URL, NPM_COMMUNITY_NODE_SEARCH_API_URL } from '@/constants';
import { IN8nUISettings } from 'n8n-workflow';
export function getSettings(context: IRestApiContext): Promise<IN8nUISettings> {
return makeRestApiRequest(context, 'GET', '/settings');

View file

@ -348,7 +348,7 @@ import {
import mixins from 'vue-typed-mixins';
import { deepCopy } from 'n8n-workflow';
import { WorkflowSettings, deepCopy } from 'n8n-workflow';
import { mapStores } from 'pinia';
import { useWorkflowsStore } from '@/stores/workflows';
import { useSettingsStore } from '@/stores/settings';
@ -504,7 +504,7 @@ export default mixins(externalHooks, genericHelpers, restApi, showMessage).exten
}
if (workflowSettings.callerPolicy === undefined) {
workflowSettings.callerPolicy = this.defaultValues
.workflowCallerPolicy as WorkflowCallerPolicyDefaultOption;
.workflowCallerPolicy as WorkflowSettings.CallerPolicy;
}
if (workflowSettings.executionTimeout === undefined) {
workflowSettings.executionTimeout = this.rootStore.executionTimeout;

View file

@ -2,9 +2,9 @@ import { createPinia, setActivePinia } from 'pinia';
import { usePostHog } from '@/stores/posthog';
import { useUsersStore } from '@/stores/users';
import { useSettingsStore } from '@/stores/settings';
import { IN8nUISettings } from '@/Interface';
import { useRootStore } from '@/stores/n8nRootStore';
import { useTelemetryStore } from '@/stores/telemetry';
import { IN8nUISettings } from 'n8n-workflow';
const DEFAULT_POSTHOG_SETTINGS: IN8nUISettings['posthog'] = {
enabled: true,

View file

@ -2,8 +2,8 @@ import { createPinia, setActivePinia } from 'pinia';
import { useSettingsStore } from '@/stores/settings';
import { useSSOStore } from '@/stores/sso';
import { merge } from 'lodash-es';
import { IN8nUISettings } from '@/Interface';
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
import { IN8nUISettings } from 'n8n-workflow';
let ssoStore: ReturnType<typeof useSSOStore>;
let settingsStore: ReturnType<typeof useSettingsStore>;

View file

@ -16,16 +16,19 @@ import {
} from '@/constants';
import {
ILdapConfig,
ILogLevel,
IN8nPromptResponse,
IN8nPrompts,
IN8nUISettings,
IN8nValueSurveyData,
ISettingsState,
UserManagementAuthenticationMethod,
WorkflowCallerPolicyDefaultOption,
} from '@/Interface';
import { IDataObject, ITelemetrySettings } from 'n8n-workflow';
import {
IDataObject,
ILogLevel,
IN8nUISettings,
ITelemetrySettings,
WorkflowSettings,
} from 'n8n-workflow';
import { defineStore } from 'pinia';
import Vue from 'vue';
import { useRootStore } from './n8nRootStore';
@ -175,7 +178,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
isQueueModeEnabled(): boolean {
return this.settings.executionMode === 'queue';
},
workflowCallerPolicyDefaultOption(): WorkflowCallerPolicyDefaultOption {
workflowCallerPolicyDefaultOption(): WorkflowSettings.CallerPolicy {
return this.settings.workflowCallerPolicyDefaultOption;
},
isDefaultAuthenticationSaml(): boolean {

View file

@ -4,10 +4,11 @@ import { merge } from 'lodash-es';
import { isAuthorized } from '@/utils';
import { useSettingsStore } from '@/stores/settings';
import { useSSOStore } from '@/stores/sso';
import { IN8nUISettings, IUser } from '@/Interface';
import { IUser } from '@/Interface';
import { routes } from '@/router';
import { VIEWS } from '@/constants';
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
import { IN8nUISettings } from 'n8n-workflow';
const DEFAULT_SETTINGS: IN8nUISettings = SETTINGS_STORE_DEFAULT_STATE.settings;

View file

@ -17,6 +17,7 @@ import type { NodeApiError, NodeOperationError } from './NodeErrors';
import type { ExpressionError } from './ExpressionError';
import type { PathLike } from 'fs';
import type { ExecutionStatus } from './ExecutionStatus';
import type { AuthenticationMethod } from './Authentication';
export interface IAdditionalCredentialOptions {
oauth2?: IOAuth2Options;
@ -385,7 +386,6 @@ export interface IDataObject {
[key: string]: GenericValue | IDataObject | GenericValue[] | IDataObject[];
}
// export type IExecuteResponsePromiseData = IDataObject;
export type IExecuteResponsePromiseData = IDataObject | IN8nHttpFullResponse;
export interface INodeTypeNameVersion {
@ -1948,3 +1948,111 @@ export interface ExecutionFilters {
waitTill?: boolean;
workflowId?: number | string;
}
export interface IVersionNotificationSettings {
enabled: boolean;
endpoint: string;
infoUrl: string;
}
export interface IUserManagementSettings {
enabled: boolean;
showSetupOnFirstLoad?: boolean;
smtpSetup: boolean;
authenticationMethod: AuthenticationMethod;
}
export interface IPublicApiSettings {
enabled: boolean;
latestVersion: number;
path: string;
swaggerUi: {
enabled: boolean;
};
}
export type ILogLevel = 'info' | 'debug' | 'warn' | 'error' | 'verbose' | 'silent';
export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;
saveDataErrorExecution: WorkflowSettings.SaveDataExecution;
saveDataSuccessExecution: WorkflowSettings.SaveDataExecution;
saveManualExecutions: boolean;
executionTimeout: number;
maxExecutionTimeout: number;
workflowCallerPolicyDefaultOption: WorkflowSettings.CallerPolicy;
oauthCallbackUrls: {
oauth1: string;
oauth2: string;
};
timezone: string;
urlBaseWebhook: string;
urlBaseEditor: string;
versionCli: string;
n8nMetadata?: {
[key: string]: string | number | undefined;
};
versionNotifications: IVersionNotificationSettings;
instanceId: string;
telemetry: ITelemetrySettings;
posthog: {
enabled: boolean;
apiHost: string;
apiKey: string;
autocapture: boolean;
disableSessionRecording: boolean;
debug: boolean;
};
personalizationSurveyEnabled: boolean;
userActivationSurveyEnabled: boolean;
defaultLocale: string;
userManagement: IUserManagementSettings;
sso: {
saml: {
loginLabel: string;
loginEnabled: boolean;
};
ldap: {
loginLabel: string;
loginEnabled: boolean;
};
};
publicApi: IPublicApiSettings;
workflowTagsDisabled: boolean;
logLevel: ILogLevel;
hiringBannerEnabled: boolean;
templates: {
enabled: boolean;
host: string;
};
onboardingCallPromptEnabled: boolean;
missingPackages?: boolean;
executionMode: 'regular' | 'queue';
pushBackend: 'sse' | 'websocket';
communityNodesEnabled: boolean;
deployment: {
type: string | 'default' | 'n8n-internal' | 'cloud' | 'desktop_mac' | 'desktop_win';
};
isNpmAvailable: boolean;
allowedModules: {
builtIn?: string[];
external?: string[];
};
enterprise: {
sharing: boolean;
ldap: boolean;
saml: boolean;
logStreaming: boolean;
advancedExecutionFilters: boolean;
variables: boolean;
versionControl: boolean;
};
hideUsagePage: boolean;
license: {
environment: 'development' | 'production' | 'staging';
};
variables: {
limit: number;
};
}