From 0e93fe064ecd45bcf764f82595914b0a7e0da3dd Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:23:15 +0300 Subject: [PATCH] refactor(core): Forbid raw enums (no-changelog) --- packages/@n8n_io/eslint-config/base.js | 12 +++++++++++ packages/cli/src/CurlConverterHelper.ts | 2 +- packages/cli/src/constants.ts | 4 ++-- .../databases/entities/WorkflowStatistics.ts | 2 +- packages/cli/src/events/WorkflowStatistics.ts | 2 +- packages/editor-ui/src/Interface.ts | 2 +- packages/editor-ui/src/constants.ts | 14 ++++++------- packages/editor-ui/src/models/history.ts | 2 +- packages/editor-ui/src/permissions.ts | 2 +- packages/nodes-base/.eslintrc.js | 1 - .../nodes-base/nodes/Aws/DynamoDB/types.d.ts | 2 +- .../nodes-base/nodes/Clockify/CommonDtos.ts | 4 ++-- .../nodes/Clockify/EntryTypeEnum.ts | 2 +- .../nodes/Clockify/ProjectInterfaces.ts | 4 ++-- .../nodes-base/nodes/Clockify/UserDtos.ts | 2 +- .../nodes/Clockify/WorkpaceInterfaces.ts | 8 +++---- .../nodes/Cortex/AnalyzerInterface.ts | 6 +++--- .../nodes/Formstack/GenericFunctions.ts | 2 +- .../nodes/Freshdesk/Freshdesk.node.ts | 6 +++--- .../nodes/Google/Chat/MessageInterface.ts | 2 +- .../Sheet/v2/helpers/GoogleSheets.types.ts | 10 ++++----- .../nodes/ItemLists/V1/summarize.operation.ts | 20 +++++++++--------- .../nodes/ItemLists/V2/summarize.operation.ts | 21 ++++++++++--------- .../nodes/Mailchimp/Mailchimp.node.ts | 2 +- .../nodes/PayPal/PaymentInteface.ts | 4 ++-- .../nodes/SendInBlue/GenericFunctions.ts | 4 ++-- .../TheHive/interfaces/AlertInterface.ts | 4 ++-- .../nodes/TheHive/interfaces/CaseInterface.ts | 6 +++--- .../nodes/TheHive/interfaces/LogInterface.ts | 2 +- .../TheHive/interfaces/ObservableInterface.ts | 4 ++-- .../nodes/TheHive/interfaces/TaskInterface.ts | 2 +- .../nodes/Todoist/v1/OperationHandler.ts | 2 +- .../nodes-base/nodes/Todoist/v1/Service.ts | 21 +++++++++---------- .../nodes/Todoist/v1/TodoistV1.node.ts | 11 ++++------ .../nodes/Todoist/v2/OperationHandler.ts | 2 +- .../nodes-base/nodes/Todoist/v2/Service.ts | 21 +++++++++---------- .../nodes/Todoist/v2/TodoistV2.node.ts | 11 ++++------ packages/workflow/src/Interfaces.ts | 2 +- packages/workflow/src/MessageEventBus.ts | 4 ++-- 39 files changed, 119 insertions(+), 115 deletions(-) diff --git a/packages/@n8n_io/eslint-config/base.js b/packages/@n8n_io/eslint-config/base.js index 2f673ece0b..4242429369 100644 --- a/packages/@n8n_io/eslint-config/base.js +++ b/packages/@n8n_io/eslint-config/base.js @@ -397,6 +397,18 @@ const config = (module.exports = { }, ], + /** + * https://www.typescriptlang.org/docs/handbook/enums.html#const-enums + */ + 'no-restricted-syntax': [ + 'error', + { + selector: 'TSEnumDeclaration:not([const=true])', + message: + 'Do not declare raw enums as it leads to runtime overhead. Use const enum instead. See https://www.typescriptlang.org/docs/handbook/enums.html#const-enums', + }, + ], + // ---------------------------------- // import // ---------------------------------- diff --git a/packages/cli/src/CurlConverterHelper.ts b/packages/cli/src/CurlConverterHelper.ts index 3035ada4c4..06da059030 100644 --- a/packages/cli/src/CurlConverterHelper.ts +++ b/packages/cli/src/CurlConverterHelper.ts @@ -80,7 +80,7 @@ type HttpNodeHeaders = Pick; -enum ContentTypes { +const enum ContentTypes { applicationJson = 'application/json', applicationFormUrlEncoded = 'application/x-www-form-urlencoded', applicationMultipart = 'multipart/form-data', diff --git a/packages/cli/src/constants.ts b/packages/cli/src/constants.ts index 913f37381f..6d6ebab385 100644 --- a/packages/cli/src/constants.ts +++ b/packages/cli/src/constants.ts @@ -68,7 +68,7 @@ export const WORKFLOW_REACTIVATE_MAX_TIMEOUT = 24 * 60 * 60 * 1000; // 1 day export const SETTINGS_LICENSE_CERT_KEY = 'license.cert'; -export enum LICENSE_FEATURES { +export const enum LICENSE_FEATURES { SHARING = 'feat:sharing', LDAP = 'feat:ldap', SAML = 'feat:saml', @@ -78,7 +78,7 @@ export enum LICENSE_FEATURES { VERSION_CONTROL = 'feat:versionControl', } -export enum LICENSE_QUOTAS { +export const enum LICENSE_QUOTAS { TRIGGER_LIMIT = 'quota:activeWorkflows', VARIABLES_LIMIT = 'quota:maxVariables', } diff --git a/packages/cli/src/databases/entities/WorkflowStatistics.ts b/packages/cli/src/databases/entities/WorkflowStatistics.ts index 1d3de6316d..5181bb257c 100644 --- a/packages/cli/src/databases/entities/WorkflowStatistics.ts +++ b/packages/cli/src/databases/entities/WorkflowStatistics.ts @@ -3,7 +3,7 @@ import { idStringifier } from '../utils/transformers'; import { datetimeColumnType } from './AbstractEntity'; import { WorkflowEntity } from './WorkflowEntity'; -export enum StatisticsNames { +export const enum StatisticsNames { productionSuccess = 'production_success', productionError = 'production_error', manualSuccess = 'manual_success', diff --git a/packages/cli/src/events/WorkflowStatistics.ts b/packages/cli/src/events/WorkflowStatistics.ts index 5567ded3b8..863aeb6e18 100644 --- a/packages/cli/src/events/WorkflowStatistics.ts +++ b/packages/cli/src/events/WorkflowStatistics.ts @@ -9,7 +9,7 @@ import { InternalHooks } from '@/InternalHooks'; import config from '@/config'; import { UserService } from '@/user/user.service'; -enum StatisticsUpsertResult { +const enum StatisticsUpsertResult { insert = 'insert', update = 'update', failed = 'failed', diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 00c80ca47f..84b072f545 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -635,7 +635,7 @@ export interface IN8nPromptResponse { updated: boolean; } -export enum UserManagementAuthenticationMethod { +export const enum UserManagementAuthenticationMethod { Email = 'email', Ldap = 'ldap', Saml = 'saml', diff --git a/packages/editor-ui/src/constants.ts b/packages/editor-ui/src/constants.ts index f600da467a..c4b0914103 100644 --- a/packages/editor-ui/src/constants.ts +++ b/packages/editor-ui/src/constants.ts @@ -362,7 +362,7 @@ export const NODE_TYPE_COUNT_MAPPER = { }; export const TEMPLATES_NODES_FILTER = ['n8n-nodes-base.start', 'n8n-nodes-base.respondToWebhook']; -export enum VIEWS { +export const enum VIEWS { HOMEPAGE = 'Homepage', COLLECTION = 'TemplatesCollectionView', EXECUTIONS = 'Executions', @@ -398,7 +398,7 @@ export enum VIEWS { VERSION_CONTROL = 'VersionControl', } -export enum FAKE_DOOR_FEATURES { +export const enum FAKE_DOOR_FEATURES { ENVIRONMENTS = 'environments', LOGGING = 'logging', SSO = 'sso', @@ -443,7 +443,7 @@ export const MAPPING_PARAMS = [ export const DEFAULT_STICKY_HEIGHT = 160; export const DEFAULT_STICKY_WIDTH = 240; -export enum WORKFLOW_MENU_ACTIONS { +export const enum WORKFLOW_MENU_ACTIONS { DUPLICATE = 'duplicate', DOWNLOAD = 'download', IMPORT_FROM_URL = 'import-from-url', @@ -455,7 +455,7 @@ export enum WORKFLOW_MENU_ACTIONS { /** * Enterprise edition */ -export enum EnterpriseEditionFeature { +export const enum EnterpriseEditionFeature { AdvancedExecutionFilters = 'advancedExecutionFilters', Sharing = 'sharing', Ldap = 'ldap', @@ -466,7 +466,7 @@ export enum EnterpriseEditionFeature { } export const MAIN_NODE_PANEL_WIDTH = 360; -export enum MAIN_HEADER_TABS { +export const enum MAIN_HEADER_TABS { WORKFLOW = 'workflow', EXECUTIONS = 'executions', SETTINGS = 'settings', @@ -504,7 +504,7 @@ export const CURL_IMPORT_NODES_PROTOCOLS: { [key: string]: string } = { imaps: 'IMAP', }; -export enum STORES { +export const enum STORES { COMMUNITY_NODES = 'communityNodes', ROOT = 'root', SETTINGS = 'settings', @@ -523,7 +523,7 @@ export enum STORES { HISTORY = 'history', } -export enum SignInType { +export const enum SignInType { LDAP = 'ldap', EMAIL = 'email', } diff --git a/packages/editor-ui/src/models/history.ts b/packages/editor-ui/src/models/history.ts index 5a404b27f3..72733ab5ed 100644 --- a/packages/editor-ui/src/models/history.ts +++ b/packages/editor-ui/src/models/history.ts @@ -6,7 +6,7 @@ import { createEventBus } from '@/event-bus'; // Command names don't serve any particular purpose in the app // but they make it easier to identify each command on stack // when debugging -export enum COMMANDS { +export const enum COMMANDS { MOVE_NODE = 'moveNode', ADD_NODE = 'addNode', REMOVE_NODE = 'removeNode', diff --git a/packages/editor-ui/src/permissions.ts b/packages/editor-ui/src/permissions.ts index a2300d6399..0635491cc9 100644 --- a/packages/editor-ui/src/permissions.ts +++ b/packages/editor-ui/src/permissions.ts @@ -14,7 +14,7 @@ import { import { EnterpriseEditionFeature, PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants'; import { useSettingsStore } from './stores/settings'; -export enum UserRole { +export const enum UserRole { InstanceOwner = 'isInstanceOwner', ResourceOwner = 'isOwner', ResourceEditor = 'isEditor', diff --git a/packages/nodes-base/.eslintrc.js b/packages/nodes-base/.eslintrc.js index a5d9b31cce..a06183204c 100644 --- a/packages/nodes-base/.eslintrc.js +++ b/packages/nodes-base/.eslintrc.js @@ -24,7 +24,6 @@ module.exports = { '@typescript-eslint/naming-convention': ['error', { selector: 'memberLike', format: null }], '@typescript-eslint/no-explicit-any': 'off', //812 warnings, better to fix in separate PR '@typescript-eslint/no-non-null-assertion': 'off', //665 errors, better to fix in separate PR - // '@typescript-eslint/no-unsafe-argument': 'off', //1538 errors, better to fix in separate PR '@typescript-eslint/no-unsafe-assignment': 'off', //7084 problems, better to fix in separate PR '@typescript-eslint/no-unsafe-call': 'off', //541 errors, better to fix in separate PR '@typescript-eslint/no-unsafe-member-access': 'off', //4591 errors, better to fix in separate PR diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts b/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts index c03eb89ab5..201fecbc34 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts @@ -51,7 +51,7 @@ export type PartitionKey = { }; }; -export enum EAttributeValueType { +export const enum EAttributeValueType { S = 'S', SS = 'SS', M = 'M', diff --git a/packages/nodes-base/nodes/Clockify/CommonDtos.ts b/packages/nodes-base/nodes/Clockify/CommonDtos.ts index 858b58bb97..7e7f5bbd91 100644 --- a/packages/nodes-base/nodes/Clockify/CommonDtos.ts +++ b/packages/nodes-base/nodes/Clockify/CommonDtos.ts @@ -3,14 +3,14 @@ export interface IHourlyRateDto { currency: string; } -enum MembershipStatusEnum { +const enum MembershipStatusEnum { PENDING = 'PENDING', ACTIVE = 'ACTIVE', DECLINED = 'DECLINED', INACTIVE = 'INACTIVE', } -enum TaskStatusEnum { +const enum TaskStatusEnum { ACTIVE = 'ACTIVE', DONE = 'DONE', } diff --git a/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts b/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts index 0df2a71019..d83881685f 100644 --- a/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts +++ b/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts @@ -1,3 +1,3 @@ -export enum EntryTypeEnum { +export const enum EntryTypeEnum { NEW_TIME_ENTRY, } diff --git a/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts b/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts index 0e7419cb69..623a9fe517 100644 --- a/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts +++ b/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts @@ -1,6 +1,6 @@ import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; -enum EstimateEnum { +const enum EstimateEnum { AUTO = 'AUTO', MANUAL = 'MANUAL', } @@ -40,7 +40,7 @@ export interface IProjectRequest { tasks: ITaskDto; } -enum TaskStatusEnum { +const enum TaskStatusEnum { ACTIVE = 'ACTIVE', DONE = 'DONE', } diff --git a/packages/nodes-base/nodes/Clockify/UserDtos.ts b/packages/nodes-base/nodes/Clockify/UserDtos.ts index dc1f96c75b..6365b057df 100644 --- a/packages/nodes-base/nodes/Clockify/UserDtos.ts +++ b/packages/nodes-base/nodes/Clockify/UserDtos.ts @@ -1,7 +1,7 @@ import type { IDataObject } from 'n8n-workflow'; import type { IMembershipDto } from './CommonDtos'; -enum UserStatusEnum { +const enum UserStatusEnum { ACTIVE, PENDING_EMAIL_VERIFICATION, DELETED, diff --git a/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts b/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts index f46be67faa..11eb0557e7 100644 --- a/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts +++ b/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts @@ -1,12 +1,12 @@ import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; -enum AdminOnlyPagesEnum { +const enum AdminOnlyPagesEnum { PROJECT = 'PROJECT', TEAM = 'TEAM', REPORTS = 'REPORTS', } -enum DaysOfWeekEnum { +const enum DaysOfWeekEnum { MONDAY = 'MONDAY', TUESDAY = 'TUESDAY', WEDNESDAY = 'WEDNESDAY', @@ -16,13 +16,13 @@ enum DaysOfWeekEnum { SUNDAY = 'SUNDAY', } -enum DatePeriodEnum { +const enum DatePeriodEnum { DAYS = 'DAYS', WEEKS = 'WEEKS', MONTHS = 'MONTHS', } -enum AutomaticLockTypeEnum { +const enum AutomaticLockTypeEnum { WEEKLY = 'WEEKLY', MONTHLY = 'MONTHLY', OLDER_THAN = 'OLDER_THAN', diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts index 09e3a6ff57..5f9f8fe827 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts @@ -1,6 +1,6 @@ import type { IDataObject } from 'n8n-workflow'; -export enum JobStatus { +export const enum JobStatus { WAITING = 'Waiting', INPROGRESS = 'InProgress', SUCCESS = 'Success', @@ -8,14 +8,14 @@ export enum JobStatus { DELETED = 'Deleted', } -export enum TLP { +export const enum TLP { white, green, amber, red, } -export enum ObservableDataType { +export const enum ObservableDataType { 'domain' = 'domain', 'file' = 'file', 'filename' = 'filename', diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index 7de8096dfc..de19384130 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -39,7 +39,7 @@ export interface IFormstackSubmissionFieldContainer { value: string; } -export enum FormstackFieldFormat { +export const enum FormstackFieldFormat { ID = 'id', Label = 'label', Name = 'name', diff --git a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts index 428a8a7731..dbeb8d14d6 100644 --- a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts +++ b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts @@ -20,21 +20,21 @@ import type { ICreateContactBody } from './ContactInterface'; import { contactFields, contactOperations } from './ContactDescription'; -enum Status { +const enum Status { Open = 2, Pending = 3, Resolved = 4, Closed = 5, } -enum Priority { +const enum Priority { Low = 1, Medium = 2, High = 3, Urgent = 4, } -enum Source { +const enum Source { Email = 1, Portal = 2, Phone = 3, diff --git a/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts b/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts index 8dc2d0e570..a03ab9f130 100644 --- a/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts +++ b/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts @@ -31,7 +31,7 @@ export interface IUser { type?: Type; isAnonymous?: boolean; } -enum Type { +const enum Type { 'TYPE_UNSPECIFIED', 'HUMAN', 'BOT', diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.types.ts b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.types.ts index aac00508c4..a55fc71ae4 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.types.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/helpers/GoogleSheets.types.ts @@ -64,11 +64,11 @@ export type SheetProperties = PropertiesOf; export type ResourceLocator = 'id' | 'url' | 'list'; -export enum ResourceLocatorUiNames { - id = 'By ID', - url = 'By URL', - list = 'From List', -} +export const ResourceLocatorUiNames = { + id: 'By ID', + url: 'By URL', + list: 'From List', +}; export type SheetCellDecoded = { cell?: string; diff --git a/packages/nodes-base/nodes/ItemLists/V1/summarize.operation.ts b/packages/nodes-base/nodes/ItemLists/V1/summarize.operation.ts index 0e0db54bcb..81ee759a35 100644 --- a/packages/nodes-base/nodes/ItemLists/V1/summarize.operation.ts +++ b/packages/nodes-base/nodes/ItemLists/V1/summarize.operation.ts @@ -29,16 +29,16 @@ type Aggregation = { type Aggregations = Aggregation[]; -enum AggregationDisplayNames { - append = 'appended_', - average = 'average_', - concatenate = 'concatenated_', - count = 'count_', - countUnique = 'unique_count_', - max = 'max_', - min = 'min_', - sum = 'sum_', -} +const AggregationDisplayNames = { + append: 'appended_', + average: 'average_', + concatenate: 'concatenated_', + count: 'count_', + countUnique: 'unique_count_', + max: 'max_', + min: 'min_', + sum: 'sum_', +}; const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum']; diff --git a/packages/nodes-base/nodes/ItemLists/V2/summarize.operation.ts b/packages/nodes-base/nodes/ItemLists/V2/summarize.operation.ts index c3accbd330..72347b4cb4 100644 --- a/packages/nodes-base/nodes/ItemLists/V2/summarize.operation.ts +++ b/packages/nodes-base/nodes/ItemLists/V2/summarize.operation.ts @@ -29,16 +29,17 @@ type Aggregation = { type Aggregations = Aggregation[]; -enum AggregationDisplayNames { - append = 'appended_', - average = 'average_', - concatenate = 'concatenated_', - count = 'count_', - countUnique = 'unique_count_', - max = 'max_', - min = 'min_', - sum = 'sum_', -} +// eslint-disable-next-line no-restricted-syntax +const AggregationDisplayNames = { + append: 'appended_', + average: 'average_', + concatenate: 'concatenated_', + count: 'count_', + countUnique: 'unique_count_', + max: 'max_', + min: 'min_', + sum: 'sum_', +}; const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum']; diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index 8359700365..0d3728ad2c 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -17,7 +17,7 @@ import { import moment from 'moment'; -enum Status { +const enum Status { subscribe = 'subscribe', unsubscribed = 'unsubscribe', cleaned = 'cleaned', diff --git a/packages/nodes-base/nodes/PayPal/PaymentInteface.ts b/packages/nodes-base/nodes/PayPal/PaymentInteface.ts index 53b2ec1457..d4e28c6cee 100644 --- a/packages/nodes-base/nodes/PayPal/PaymentInteface.ts +++ b/packages/nodes-base/nodes/PayPal/PaymentInteface.ts @@ -1,10 +1,10 @@ -export enum RecipientType { +export const enum RecipientType { email = 'EMAIL', phone = 'PHONE', paypalId = 'PAYPAL_ID', } -export enum RecipientWallet { +export const enum RecipientWallet { paypal = 'PAYPAL', venmo = 'VENMO', } diff --git a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts index 73ab3272cf..7fa7a6e4bd 100644 --- a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts @@ -18,13 +18,13 @@ export namespace SendInBlueNode { type BBCEmail = { bbc: Email[] }; type ValidatedEmail = ToEmail | SenderEmail | CCEmail | BBCEmail; - enum OVERRIDE_MAP_VALUES { + const enum OVERRIDE_MAP_VALUES { 'CATEGORY' = 'category', 'NORMAL' = 'boolean', 'TRANSACTIONAL' = 'id', } - enum OVERRIDE_MAP_TYPE { + const enum OVERRIDE_MAP_TYPE { 'CATEGORY' = 'category', 'NORMAL' = 'normal', 'TRANSACTIONAL' = 'transactional', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts index f8ee11271a..0286d8247a 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts @@ -1,11 +1,11 @@ import type { IDataObject } from 'n8n-workflow'; -export enum AlertStatus { +export const enum AlertStatus { NEW = 'New', UPDATED = 'Updated', IGNORED = 'Ignored', IMPORTED = 'Imported', } -export enum TLP { +export const enum TLP { white, green, amber, diff --git a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts index 58e910c6ff..297ae58f51 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts @@ -31,13 +31,13 @@ export interface ICase { upadtedAt?: Date; } -export enum CaseStatus { +export const enum CaseStatus { OPEN = 'Open', RESOLVED = 'Resolved', DELETED = 'Deleted', } -export enum CaseResolutionStatus { +export const enum CaseResolutionStatus { INDETERMINATE = 'Indeterminate', FALSEPOSITIVE = 'FalsePositive', TRUEPOSITIVE = 'TruePositive', @@ -45,7 +45,7 @@ export enum CaseResolutionStatus { DUPLICATED = 'Duplicated', } -export enum CaseImpactStatus { +export const enum CaseImpactStatus { NOIMPACT = 'NoImpact', WITHIMPACT = 'WithImpact', NOTAPPLICABLE = 'NotApplicable', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts index 5e02a41c62..2e786a962f 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts @@ -1,5 +1,5 @@ import type { IAttachment } from './ObservableInterface'; -export enum LogStatus { +export const enum LogStatus { OK = 'Ok', DELETED = 'Deleted', } diff --git a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts index a18b85c2db..cb35df2189 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts @@ -1,10 +1,10 @@ import type { TLP } from './AlertInterface'; -export enum ObservableStatus { +export const enum ObservableStatus { OK = 'Ok', DELETED = 'Deleted', } -export enum ObservableDataType { +export const enum ObservableDataType { 'domain' = 'domain', 'file' = 'file', 'filename' = 'filename', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts index c453e10b1e..daff422198 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts @@ -17,7 +17,7 @@ export interface ITask { upadtedAt?: Date; } -export enum TaskStatus { +export const enum TaskStatus { WAITING = 'Waiting', INPROGRESS = 'InProgress', COMPLETED = 'Completed', diff --git a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts index 8225bad42e..a45773a880 100644 --- a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts @@ -42,7 +42,7 @@ export interface Command { }; } -export enum CommandType { +export const enum CommandType { ITEM_MOVE = 'item_move', ITEM_ADD = 'item_add', ITEM_UPDATE = 'item_update', diff --git a/packages/nodes-base/nodes/Todoist/v1/Service.ts b/packages/nodes-base/nodes/Todoist/v1/Service.ts index 3e951608a8..e40fe25be0 100644 --- a/packages/nodes-base/nodes/Todoist/v1/Service.ts +++ b/packages/nodes-base/nodes/Todoist/v1/Service.ts @@ -35,17 +35,16 @@ export class TodoistService implements Service { }; } -export enum OperationType { - create = 'create', - close = 'close', - delete = 'delete', - get = 'get', - getAll = 'getAll', - reopen = 'reopen', - update = 'update', - move = 'move', - sync = 'sync', -} +export type OperationType = + | 'create' + | 'close' + | 'delete' + | 'get' + | 'getAll' + | 'reopen' + | 'update' + | 'move' + | 'sync'; export interface Section { name: string; diff --git a/packages/nodes-base/nodes/Todoist/v1/TodoistV1.node.ts b/packages/nodes-base/nodes/Todoist/v1/TodoistV1.node.ts index 6dcecc9787..adf48942cf 100644 --- a/packages/nodes-base/nodes/Todoist/v1/TodoistV1.node.ts +++ b/packages/nodes-base/nodes/Todoist/v1/TodoistV1.node.ts @@ -13,7 +13,8 @@ import type { import { todoistApiRequest } from '../GenericFunctions'; -import { OperationType, TodoistService } from './Service'; +import type { OperationType } from './Service'; +import { TodoistService } from './Service'; // interface IBodyCreateTask { // content?: string; @@ -702,15 +703,11 @@ export class TodoistV1 implements INodeType { const service = new TodoistService(); let responseData; const resource = this.getNodeParameter('resource', 0); - const operation = this.getNodeParameter('operation', 0); + const operation = this.getNodeParameter('operation', 0) as OperationType; for (let i = 0; i < length; i++) { try { if (resource === 'task') { - responseData = await service.execute( - this, - OperationType[operation as keyof typeof OperationType], - i, - ); + responseData = await service.execute(this, operation, i); } if (Array.isArray(responseData?.data)) { returnData.push.apply(returnData, responseData?.data as IDataObject[]); diff --git a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts index 179d958be7..fbe65589c8 100644 --- a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts @@ -42,7 +42,7 @@ export interface Command { }; } -export enum CommandType { +export const enum CommandType { ITEM_MOVE = 'item_move', ITEM_ADD = 'item_add', ITEM_UPDATE = 'item_update', diff --git a/packages/nodes-base/nodes/Todoist/v2/Service.ts b/packages/nodes-base/nodes/Todoist/v2/Service.ts index 3e951608a8..e40fe25be0 100644 --- a/packages/nodes-base/nodes/Todoist/v2/Service.ts +++ b/packages/nodes-base/nodes/Todoist/v2/Service.ts @@ -35,17 +35,16 @@ export class TodoistService implements Service { }; } -export enum OperationType { - create = 'create', - close = 'close', - delete = 'delete', - get = 'get', - getAll = 'getAll', - reopen = 'reopen', - update = 'update', - move = 'move', - sync = 'sync', -} +export type OperationType = + | 'create' + | 'close' + | 'delete' + | 'get' + | 'getAll' + | 'reopen' + | 'update' + | 'move' + | 'sync'; export interface Section { name: string; diff --git a/packages/nodes-base/nodes/Todoist/v2/TodoistV2.node.ts b/packages/nodes-base/nodes/Todoist/v2/TodoistV2.node.ts index 6cb751d787..f3813ca59b 100644 --- a/packages/nodes-base/nodes/Todoist/v2/TodoistV2.node.ts +++ b/packages/nodes-base/nodes/Todoist/v2/TodoistV2.node.ts @@ -13,7 +13,8 @@ import type { import { todoistApiRequest } from '../GenericFunctions'; -import { OperationType, TodoistService } from './Service'; +import type { OperationType } from './Service'; +import { TodoistService } from './Service'; // interface IBodyCreateTask { // content?: string; @@ -701,15 +702,11 @@ export class TodoistV2 implements INodeType { const service = new TodoistService(); let responseData; const resource = this.getNodeParameter('resource', 0); - const operation = this.getNodeParameter('operation', 0); + const operation = this.getNodeParameter('operation', 0) as OperationType; for (let i = 0; i < length; i++) { try { if (resource === 'task') { - responseData = await service.execute( - this, - OperationType[operation as keyof typeof OperationType], - i, - ); + responseData = await service.execute(this, operation, i); } if (responseData !== undefined && Array.isArray(responseData?.data)) { diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 6c1b687b3f..e3eccd8a0d 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -1868,7 +1868,7 @@ export interface IConnectedNode { depth: number; } -export enum OAuth2GrantType { +export const enum OAuth2GrantType { authorizationCode = 'authorizationCode', clientCredentials = 'clientCredentials', } diff --git a/packages/workflow/src/MessageEventBus.ts b/packages/workflow/src/MessageEventBus.ts index cf604ea655..2da8c7a20d 100644 --- a/packages/workflow/src/MessageEventBus.ts +++ b/packages/workflow/src/MessageEventBus.ts @@ -5,7 +5,7 @@ import type { INodeCredentials } from './Interfaces'; // General Enums And Interfaces // =============================== -export enum EventMessageTypeNames { +export const enum EventMessageTypeNames { generic = '$$EventMessage', audit = '$$EventMessageAudit', confirm = '$$EventMessageConfirm', @@ -13,7 +13,7 @@ export enum EventMessageTypeNames { node = '$$EventMessageNode', } -export enum MessageEventBusDestinationTypeNames { +export const enum MessageEventBusDestinationTypeNames { abstract = '$$AbstractMessageEventBusDestination', webhook = '$$MessageEventBusDestinationWebhook', sentry = '$$MessageEventBusDestinationSentry',