diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/types.ts b/packages/nodes-base/nodes/Aws/DynamoDB/types.ts index 8431e199c0..aca032974d 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/types.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/types.ts @@ -51,18 +51,20 @@ export type PartitionKey = { }; }; -export const enum EAttributeValueType { - S = 'S', - SS = 'SS', - M = 'M', - L = 'L', - NS = 'NS', - N = 'N', - BOOL = 'BOOL', - B = 'B', - BS = 'BS', - NULL = 'NULL', -} +export const EAttributeValueTypes = { + S: 'S', + SS: 'SS', + M: 'M', + L: 'L', + NS: 'NS', + N: 'N', + BOOL: 'BOOL', + B: 'B', + BS: 'BS', + NULL: 'NULL', +} as const; + +export type EAttributeValueType = (typeof EAttributeValueTypes)[keyof typeof EAttributeValueTypes]; export interface IExpressionAttributeValue { attribute: string; diff --git a/packages/nodes-base/nodes/Brevo/GenericFunctions.ts b/packages/nodes-base/nodes/Brevo/GenericFunctions.ts index 4b5da056c1..683861c800 100644 --- a/packages/nodes-base/nodes/Brevo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brevo/GenericFunctions.ts @@ -18,17 +18,17 @@ export namespace BrevoNode { type BBCEmail = { bbc: Email[] }; type ValidatedEmail = ToEmail | SenderEmail | CCEmail | BBCEmail; - const enum OVERRIDE_MAP_VALUES { - CATEGORY = 'category', - NORMAL = 'boolean', - TRANSACTIONAL = 'id', - } + const OVERRIDE_MAP_VALUES = { + CATEGORY: 'category', + NORMAL: 'boolean', + TRANSACTIONAL: 'id', + } as const; - const enum OVERRIDE_MAP_TYPE { - CATEGORY = 'category', - NORMAL = 'normal', - TRANSACTIONAL = 'transactional', - } + const OVERRIDE_MAP_TYPE = { + CATEGORY: 'category', + NORMAL: 'normal', + TRANSACTIONAL: 'transactional', + } as const; export const INTERCEPTORS = new Map void>([ [ diff --git a/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts b/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts index d9aa509547..4702812ebe 100644 --- a/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts @@ -10,7 +10,8 @@ import type { } from 'n8n-workflow'; import { NodeConnectionTypes } from 'n8n-workflow'; -import { EntryTypeEnum } from './EntryTypeEnum'; +import type { EntryType } from './EntryType'; +import { EntryTypes } from './EntryType'; import { clockifyApiRequest } from './GenericFunctions'; import type { IUserDto } from './UserDtos'; import type { IWorkspaceDto } from './WorkpaceInterfaces'; @@ -56,11 +57,11 @@ export class ClockifyTrigger implements INodeType { options: [ { name: 'New Time Entry', - value: EntryTypeEnum.NEW_TIME_ENTRY, + value: EntryTypes.NEW_TIME_ENTRY, }, ], required: true, - default: EntryTypeEnum.NEW_TIME_ENTRY, + default: EntryTypes.NEW_TIME_ENTRY, }, ], }; @@ -89,7 +90,7 @@ export class ClockifyTrigger implements INodeType { async poll(this: IPollFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); - const triggerField = this.getNodeParameter('watchField') as EntryTypeEnum; + const triggerField = this.getNodeParameter('watchField') as EntryType; const workspaceId = this.getNodeParameter('workspaceId'); if (!webhookData.userId) { @@ -103,7 +104,7 @@ export class ClockifyTrigger implements INodeType { let result = null; switch (triggerField) { - case EntryTypeEnum.NEW_TIME_ENTRY: + case EntryTypes.NEW_TIME_ENTRY: default: const workflowTimezone = this.getTimezone(); resource = `workspaces/${workspaceId}/user/${webhookData.userId}/time-entries`; diff --git a/packages/nodes-base/nodes/Clockify/CommonDtos.ts b/packages/nodes-base/nodes/Clockify/CommonDtos.ts index 7e7f5bbd91..86168a3131 100644 --- a/packages/nodes-base/nodes/Clockify/CommonDtos.ts +++ b/packages/nodes-base/nodes/Clockify/CommonDtos.ts @@ -3,17 +3,21 @@ export interface IHourlyRateDto { currency: string; } -const enum MembershipStatusEnum { - PENDING = 'PENDING', - ACTIVE = 'ACTIVE', - DECLINED = 'DECLINED', - INACTIVE = 'INACTIVE', -} +const MembershipStatuses = { + PENDING: 'PENDING', + ACTIVE: 'ACTIVE', + DECLINED: 'DECLINED', + INACTIVE: 'INACTIVE', +} as const; -const enum TaskStatusEnum { - ACTIVE = 'ACTIVE', - DONE = 'DONE', -} +type MembershipStatusEnum = (typeof MembershipStatuses)[keyof typeof MembershipStatuses]; + +const TaskStatuses = { + ACTIVE: 'ACTIVE', + DONE: 'DONE', +} as const; + +type TaskStatusEnum = (typeof TaskStatuses)[keyof typeof TaskStatuses]; export interface IMembershipDto { hourlyRate: IHourlyRateDto; diff --git a/packages/nodes-base/nodes/Clockify/EntryType.ts b/packages/nodes-base/nodes/Clockify/EntryType.ts new file mode 100644 index 0000000000..ba68a58a17 --- /dev/null +++ b/packages/nodes-base/nodes/Clockify/EntryType.ts @@ -0,0 +1,5 @@ +export const EntryTypes = { + NEW_TIME_ENTRY: 0, +} as const; + +export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes]; diff --git a/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts b/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts deleted file mode 100644 index d83881685f..0000000000 --- a/packages/nodes-base/nodes/Clockify/EntryTypeEnum.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 623a9fe517..612e0b1569 100644 --- a/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts +++ b/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts @@ -1,9 +1,11 @@ import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; -const enum EstimateEnum { - AUTO = 'AUTO', - MANUAL = 'MANUAL', -} +const Estimates = { + AUTO: 'AUTO', + MANUAL: 'MANUAL', +} as const; + +type EstimateEnum = (typeof Estimates)[keyof typeof Estimates]; interface IEstimateDto { estimate: string; @@ -40,10 +42,12 @@ export interface IProjectRequest { tasks: ITaskDto; } -const enum TaskStatusEnum { - ACTIVE = 'ACTIVE', - DONE = 'DONE', -} +const TaskStatuses = { + ACTIVE: 'ACTIVE', + DONE: 'DONE', +} as const; + +type TaskStatusEnum = (typeof TaskStatuses)[keyof typeof TaskStatuses]; export interface ITaskDto { assigneeIds: object; diff --git a/packages/nodes-base/nodes/Clockify/UserDtos.ts b/packages/nodes-base/nodes/Clockify/UserDtos.ts index e482e47030..ed72d2e7c4 100644 --- a/packages/nodes-base/nodes/Clockify/UserDtos.ts +++ b/packages/nodes-base/nodes/Clockify/UserDtos.ts @@ -2,11 +2,13 @@ import type { IDataObject } from 'n8n-workflow'; import type { IMembershipDto } from './CommonDtos'; -const enum UserStatusEnum { - ACTIVE, - PENDING_EMAIL_VERIFICATION, - DELETED, -} +const UserStatuses = { + ACTIVE: 0, + PENDING_EMAIL_VERIFICATION: 1, + DELETED: 2, +}; + +export type UserStatusEnum = (typeof UserStatuses)[keyof typeof UserStatuses]; export interface IUserDto { activeWorkspace: string; diff --git a/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts b/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts index 11eb0557e7..775dc83e12 100644 --- a/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts +++ b/packages/nodes-base/nodes/Clockify/WorkpaceInterfaces.ts @@ -1,32 +1,40 @@ import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; -const enum AdminOnlyPagesEnum { - PROJECT = 'PROJECT', - TEAM = 'TEAM', - REPORTS = 'REPORTS', -} +export const AdminOnlyPages = { + PROJECT: 'PROJECT', + TEAM: 'TEAM', + REPORTS: 'REPORTS', +} as const; -const enum DaysOfWeekEnum { - MONDAY = 'MONDAY', - TUESDAY = 'TUESDAY', - WEDNESDAY = 'WEDNESDAY', - THURSDAY = 'THURSDAY', - FRIDAY = 'FRIDAY', - SATURDAY = 'SATURDAY', - SUNDAY = 'SUNDAY', -} +export type AdminOnlyPagesEnum = (typeof AdminOnlyPages)[keyof typeof AdminOnlyPages]; -const enum DatePeriodEnum { - DAYS = 'DAYS', - WEEKS = 'WEEKS', - MONTHS = 'MONTHS', -} +export const DaysOfWeek = { + MONDAY: 'MONDAY', + TUESDAY: 'TUESDAY', + WEDNESDAY: 'WEDNESDAY', + THURSDAY: 'THURSDAY', + FRIDAY: 'FRIDAY', + SATURDAY: 'SATURDAY', + SUNDAY: 'SUNDAY', +} as const; -const enum AutomaticLockTypeEnum { - WEEKLY = 'WEEKLY', - MONTHLY = 'MONTHLY', - OLDER_THAN = 'OLDER_THAN', -} +export type DaysOfWeekEnum = (typeof DaysOfWeek)[keyof typeof DaysOfWeek]; + +export const DatePeriods = { + DAYS: 'DAYS', + WEEKS: 'WEEKS', + MONTHS: 'MONTHS', +} as const; + +export type DatePeriodEnum = (typeof DatePeriods)[keyof typeof DatePeriods]; + +export const AutomaticLockTypes = { + WEEKLY: 'WEEKLY', + MONTHLY: 'MONTHLY', + OLDER_THAN: 'OLDER_THAN', +} as const; + +export type AutomaticLockTypeEnum = (typeof AutomaticLockTypes)[keyof typeof AutomaticLockTypes]; interface IAutomaticLockDto { changeDay: DaysOfWeekEnum; diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts index 338410f736..d0c9c379fd 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from './AnalyzerInterface'; +import { TLPs } from './AnalyzerInterface'; export const analyzersOperations: INodeProperties[] = [ { @@ -120,19 +120,19 @@ export const analyzerFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], default: 2, diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts index a20948d01b..4804924b91 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts @@ -1,36 +1,43 @@ import type { IDataObject } from 'n8n-workflow'; -export const enum JobStatus { - WAITING = 'Waiting', - INPROGRESS = 'InProgress', - SUCCESS = 'Success', - FAILURE = 'Failure', - DELETED = 'Deleted', -} +export const JobStatuses = { + WAITING: 'Waiting', + INPROGRESS: 'InProgress', + SUCCESS: 'Success', + FAILURE: 'Failure', + DELETED: 'Deleted', +} as const; -export const enum TLP { - white, - green, - amber, - red, -} +export type JobStatus = (typeof JobStatuses)[keyof typeof JobStatuses]; + +export const TLPs = { + white: 0, + green: 1, + amber: 2, + red: 3, +} as const; + +export type TLP = (typeof TLPs)[keyof typeof TLPs]; + +export const ObservableDataTypes = { + domain: 'domain', + file: 'file', + filename: 'filename', + fqdn: 'fqdn', + hash: 'hash', + ip: 'ip', + mail: 'mail', + mail_subject: 'mail_subject', + other: 'other', + regexp: 'regexp', + registry: 'registry', + uri_path: 'uri_path', + url: 'url', + 'user-agent': 'user-agent', +} as const; + +export type ObservableDataType = (typeof ObservableDataTypes)[keyof typeof ObservableDataTypes]; -export const enum ObservableDataType { - domain = 'domain', - file = 'file', - filename = 'filename', - fqdn = 'fqdn', - hash = 'hash', - ip = 'ip', - mail = 'mail', - mail_subject = 'mail_subject', - other = 'other', - regexp = 'regexp', - registry = 'registry', - uri_path = 'uri_path', - url = 'url', - 'user-agent' = 'user-agent', -} export interface IJob { id?: string; organization?: string; diff --git a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts index 6de2a32589..57aab4bb24 100644 --- a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts +++ b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from './AnalyzerInterface'; +import { TLPs } from './AnalyzerInterface'; export const respondersOperations: INodeProperties[] = [ { @@ -172,19 +172,19 @@ export const responderFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffic Light Protocol (TLP). Default=Amber.', @@ -436,19 +436,19 @@ export const responderFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffic Light Protocol (TLP). Default=Amber.', @@ -621,19 +621,19 @@ export const responderFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffic Light Protocol (TLP). Default=Amber.', diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index 2637cedecf..abec8f8f96 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -39,11 +39,14 @@ export interface IFormstackSubmissionFieldContainer { value: string; } -export const enum FormstackFieldFormat { - ID = 'id', - Label = 'label', - Name = 'name', -} +export const FormstackFieldFormats = { + ID: 'id', + Label: 'label', + Name: 'name', +} as const; + +export type FormstackFieldFormat = + (typeof FormstackFieldFormats)[keyof typeof FormstackFieldFormats]; /** * Make an API request to Formstack diff --git a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts index 83a5a0724e..61da979f3e 100644 --- a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts +++ b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts @@ -18,29 +18,35 @@ import { // validateJSON, } from './GenericFunctions'; -const enum Status { - Open = 2, - Pending = 3, - Resolved = 4, - Closed = 5, -} +const Statuses = { + Open: 2, + Pending: 3, + Resolved: 4, + Closed: 5, +} as const; -const enum Priority { - Low = 1, - Medium = 2, - High = 3, - Urgent = 4, -} +type Status = (typeof Statuses)[keyof typeof Statuses]; -const enum Source { - Email = 1, - Portal = 2, - Phone = 3, - Chat = 7, - Mobihelp = 8, - FeedbackWidget = 9, - OutboundEmail = 10, -} +const Priorities = { + Low: 1, + Medium: 2, + High: 3, + Urgent: 4, +} as const; + +type Priority = (typeof Priorities)[keyof typeof Priorities]; + +const Sources = { + Email: 1, + Portal: 2, + Phone: 3, + Chat: 7, + Mobihelp: 8, + FeedbackWidget: 9, + OutboundEmail: 10, +} as const; + +type Source = (typeof Sources)[keyof typeof Sources]; interface ICreateTicketBody { name?: string; diff --git a/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts b/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts index b2193f9820..5833fc7ab9 100644 --- a/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts +++ b/packages/nodes-base/nodes/Google/Chat/MessageInterface.ts @@ -31,11 +31,13 @@ export interface IUser { type?: Type; isAnonymous?: boolean; } -const enum Type { - TYPE_UNSPECIFIED, - HUMAN, - BOT, -} +const Types = { + TYPE_UNSPECIFIED: 0, + HUMAN: 1, + BOT: 2, +} as const; + +export type Type = (typeof Types)[keyof typeof Types]; // // TODO: define other interfaces // diff --git a/packages/nodes-base/nodes/Google/Drive/v2/helpers/interfaces.ts b/packages/nodes-base/nodes/Google/Drive/v2/helpers/interfaces.ts index 8da73ac857..e4ed0dec83 100644 --- a/packages/nodes-base/nodes/Google/Drive/v2/helpers/interfaces.ts +++ b/packages/nodes-base/nodes/Google/Drive/v2/helpers/interfaces.ts @@ -17,21 +17,21 @@ export type SearchFilter = { export const RLC_DRIVE_DEFAULT = 'My Drive'; export const RLC_FOLDER_DEFAULT = 'root'; -export const enum DRIVE { - FOLDER = 'application/vnd.google-apps.folder', - AUDIO = 'application/vnd.google-apps.audio', - DOCUMENT = 'application/vnd.google-apps.document', - SDK = 'application/vnd.google-apps.drive-sdk', - DRAWING = 'application/vnd.google-apps.drawing', - FILE = 'application/vnd.google-apps.file', - FORM = 'application/vnd.google-apps.form', - FUSIONTABLE = 'application/vnd.google-apps.fusiontable', - MAP = 'application/vnd.google-apps.map', - PHOTO = 'application/vnd.google-apps.photo', - PRESENTATION = 'application/vnd.google-apps.presentation', - APP_SCRIPTS = 'application/vnd.google-apps.script', - SITES = 'application/vnd.google-apps.sites', - SPREADSHEET = 'application/vnd.google-apps.spreadsheet', - UNKNOWN = 'application/vnd.google-apps.unknown', - VIDEO = 'application/vnd.google-apps.video', -} +export const DRIVE = { + FOLDER: 'application/vnd.google-apps.folder', + AUDIO: 'application/vnd.google-apps.audio', + DOCUMENT: 'application/vnd.google-apps.document', + SDK: 'application/vnd.google-apps.drive-sdk', + DRAWING: 'application/vnd.google-apps.drawing', + FILE: 'application/vnd.google-apps.file', + FORM: 'application/vnd.google-apps.form', + FUSIONTABLE: 'application/vnd.google-apps.fusiontable', + MAP: 'application/vnd.google-apps.map', + PHOTO: 'application/vnd.google-apps.photo', + PRESENTATION: 'application/vnd.google-apps.presentation', + APP_SCRIPTS: 'application/vnd.google-apps.script', + SITES: 'application/vnd.google-apps.sites', + SPREADSHEET: 'application/vnd.google-apps.spreadsheet', + UNKNOWN: 'application/vnd.google-apps.unknown', + VIDEO: 'application/vnd.google-apps.video', +} as const; diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index f7203cb4d1..c4f5983000 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -17,13 +17,15 @@ import { validateJSON, } from './GenericFunctions'; -const enum Status { - subscribe = 'subscribe', - unsubscribed = 'unsubscribe', - cleaned = 'cleaned', - pending = 'pending', - transactional = 'transactional', -} +const Statuses = { + subscribe: 'subscribe', + unsubscribed: 'unsubscribe', + cleaned: 'cleaned', + pending: 'pending', + transactional: 'transactional', +} as const; + +type Status = (typeof Statuses)[keyof typeof Statuses]; interface ILocation { latitude?: number; diff --git a/packages/nodes-base/nodes/PayPal/PaymentInteface.ts b/packages/nodes-base/nodes/PayPal/PaymentInteface.ts index d4e28c6cee..bc1a97956c 100644 --- a/packages/nodes-base/nodes/PayPal/PaymentInteface.ts +++ b/packages/nodes-base/nodes/PayPal/PaymentInteface.ts @@ -1,13 +1,17 @@ -export const enum RecipientType { - email = 'EMAIL', - phone = 'PHONE', - paypalId = 'PAYPAL_ID', -} +export const RecipientTypes = { + email: 'EMAIL', + phone: 'PHONE', + paypalId: 'PAYPAL_ID', +} as const; -export const enum RecipientWallet { - paypal = 'PAYPAL', - venmo = 'VENMO', -} +export type RecipientType = (typeof RecipientTypes)[keyof typeof RecipientTypes]; + +export const RecipientWallets = { + paypal: 'PAYPAL', + venmo: 'VENMO', +} as const; + +export type RecipientWallet = (typeof RecipientWallets)[keyof typeof RecipientWallets]; export interface IAmount { currency?: string; diff --git a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts index 4742b95a46..a532f22aa1 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from '../interfaces/AlertInterface'; +import { TLPs } from '../interfaces/AlertInterface'; export const alertOperations: INodeProperties[] = [ { @@ -185,19 +185,19 @@ export const alertFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], displayOptions: { @@ -722,19 +722,19 @@ export const alertFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -891,19 +891,19 @@ export const alertFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', diff --git a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts index adc3e571e6..80b7fba5f0 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from '../interfaces/AlertInterface'; +import { TLPs } from '../interfaces/AlertInterface'; export const caseOperations: INodeProperties[] = [ { @@ -179,19 +179,19 @@ export const caseFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], displayOptions: { @@ -578,19 +578,19 @@ export const caseFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -823,19 +823,19 @@ export const caseFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', diff --git a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts index 2e2c7ce576..b2cf3bcb9f 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from '../interfaces/AlertInterface'; +import { TLPs } from '../interfaces/AlertInterface'; export const observableOperations: INodeProperties[] = [ { @@ -177,19 +177,19 @@ export const observableFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -351,19 +351,19 @@ export const observableFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -542,19 +542,19 @@ export const observableFields: INodeProperties[] = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], description: 'Traffict Light Protocol (TLP). Default=Amber.', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts index 0286d8247a..0821ccf1b6 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts @@ -1,16 +1,22 @@ import type { IDataObject } from 'n8n-workflow'; -export const enum AlertStatus { - NEW = 'New', - UPDATED = 'Updated', - IGNORED = 'Ignored', - IMPORTED = 'Imported', -} -export const enum TLP { - white, - green, - amber, - red, -} + +export const AlertStatuses = { + NEW: 'New', + UPDATED: 'Updated', + IGNORED: 'Ignored', + IMPORTED: 'Imported', +} as const; + +export type AlertStatus = (typeof AlertStatuses)[keyof typeof AlertStatuses]; + +export const TLPs = { + white: 0, + green: 1, + amber: 2, + red: 3, +} as const; + +export type TLP = (typeof TLPs)[keyof typeof TLPs]; export interface IAlert { // Required attributes diff --git a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts index 3eeee45b48..7fad8dd3c8 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts @@ -32,22 +32,29 @@ export interface ICase { upadtedAt?: Date; } -export const enum CaseStatus { - OPEN = 'Open', - RESOLVED = 'Resolved', - DELETED = 'Deleted', -} +export const CaseStatuses = { + OPEN: 'Open', + RESOLVED: 'Resolved', + DELETED: 'Deleted', +} as const; -export const enum CaseResolutionStatus { - INDETERMINATE = 'Indeterminate', - FALSEPOSITIVE = 'FalsePositive', - TRUEPOSITIVE = 'TruePositive', - OTHER = 'Other', - DUPLICATED = 'Duplicated', -} +export type CaseStatus = (typeof CaseStatuses)[keyof typeof CaseStatuses]; -export const enum CaseImpactStatus { - NOIMPACT = 'NoImpact', - WITHIMPACT = 'WithImpact', - NOTAPPLICABLE = 'NotApplicable', -} +export const CaseResolutionStatuses = { + INDETERMINATE: 'Indeterminate', + FALSEPOSITIVE: 'FalsePositive', + TRUEPOSITIVE: 'TruePositive', + OTHER: 'Other', + DUPLICATED: 'Duplicated', +} as const; + +export type CaseResolutionStatus = + (typeof CaseResolutionStatuses)[keyof typeof CaseResolutionStatuses]; + +export const CaseImpactStatuses = { + NOIMPACT: 'NoImpact', + WITHIMPACT: 'WithImpact', + NOTAPPLICABLE: 'NotApplicable', +} as const; + +export type CaseImpactStatus = (typeof CaseImpactStatuses)[keyof typeof CaseImpactStatuses]; diff --git a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts index 2e786a962f..2acee18e7d 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/LogInterface.ts @@ -1,8 +1,12 @@ import type { IAttachment } from './ObservableInterface'; -export const enum LogStatus { - OK = 'Ok', - DELETED = 'Deleted', -} + +export const LogStatuses = { + OK: 'Ok', + DELETED: 'Deleted', +} as const; + +export type LogStatus = (typeof LogStatuses)[keyof typeof LogStatuses]; + export interface ILog { // Required attributes id?: string; diff --git a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts index da792ba07a..b48baf9963 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts @@ -1,25 +1,30 @@ import type { TLP } from './AlertInterface'; -export const enum ObservableStatus { - OK = 'Ok', - DELETED = 'Deleted', -} -export const enum ObservableDataType { - domain = 'domain', - file = 'file', - filename = 'filename', - fqdn = 'fqdn', - hash = 'hash', - ip = 'ip', - mail = 'mail', - mail_subject = 'mail_subject', - other = 'other', - regexp = 'regexp', - registry = 'registry', - uri_path = 'uri_path', - url = 'url', - 'user-agent' = 'user-agent', -} +export const ObservableStatuses = { + OK: 'Ok', + DELETED: 'Deleted', +} as const; + +export type ObservableStatus = (typeof ObservableStatuses)[keyof typeof ObservableStatuses]; + +export const ObservableDataTypes = { + domain: 'domain', + file: 'file', + filename: 'filename', + fqdn: 'fqdn', + hash: 'hash', + ip: 'ip', + mail: 'mail', + mail_subject: 'mail_subject', + other: 'other', + regexp: 'regexp', + registry: 'registry', + uri_path: 'uri_path', + url: 'url', + 'user-agent': 'user-agent', +} as const; + +export type ObservableDataType = (typeof ObservableDataTypes)[keyof typeof ObservableDataTypes]; export interface IAttachment { name?: string; diff --git a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts index daff422198..89766f4360 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/TaskInterface.ts @@ -17,9 +17,11 @@ export interface ITask { upadtedAt?: Date; } -export const enum TaskStatus { - WAITING = 'Waiting', - INPROGRESS = 'InProgress', - COMPLETED = 'Completed', - CANCEL = 'Cancel', -} +export const TaskStatuses = { + WAITING: 'Waiting', + INPROGRESS: 'InProgress', + COMPLETED: 'Completed', + CANCEL: 'Cancel', +} as const; + +export type TaskStatus = (typeof TaskStatuses)[keyof typeof TaskStatuses]; diff --git a/packages/nodes-base/nodes/TheHiveProject/descriptions/common.description.ts b/packages/nodes-base/nodes/TheHiveProject/descriptions/common.description.ts index 5653375dd4..64352491a5 100644 --- a/packages/nodes-base/nodes/TheHiveProject/descriptions/common.description.ts +++ b/packages/nodes-base/nodes/TheHiveProject/descriptions/common.description.ts @@ -1,6 +1,6 @@ import type { INodeProperties } from 'n8n-workflow'; -import { TLP } from '../helpers/interfaces'; +import { TLPs } from '../helpers/interfaces'; export const returnAllAndLimit: INodeProperties[] = [ { @@ -54,19 +54,19 @@ export const tlpOptions: INodeProperties = { options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], }; diff --git a/packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts b/packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts index 33553fe127..3d67f4f085 100644 --- a/packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts +++ b/packages/nodes-base/nodes/TheHiveProject/helpers/constants.ts @@ -1,4 +1,4 @@ -import { TLP } from './interfaces'; +import { TLPs } from './interfaces'; export const alertCommonFields = [ { @@ -98,19 +98,19 @@ export const alertCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: true, @@ -122,19 +122,19 @@ export const alertCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: true, @@ -241,19 +241,19 @@ export const caseCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: false, @@ -265,19 +265,19 @@ export const caseCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: false, @@ -451,19 +451,19 @@ export const observableCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: false, @@ -475,19 +475,19 @@ export const observableCommonFields = [ options: [ { name: 'White', - value: TLP.white, + value: TLPs.white, }, { name: 'Green', - value: TLP.green, + value: TLPs.green, }, { name: 'Amber', - value: TLP.amber, + value: TLPs.amber, }, { name: 'Red', - value: TLP.red, + value: TLPs.red, }, ], removed: false, diff --git a/packages/nodes-base/nodes/TheHiveProject/helpers/interfaces.ts b/packages/nodes-base/nodes/TheHiveProject/helpers/interfaces.ts index ebd508251f..cb48c997ef 100644 --- a/packages/nodes-base/nodes/TheHiveProject/helpers/interfaces.ts +++ b/packages/nodes-base/nodes/TheHiveProject/helpers/interfaces.ts @@ -1,8 +1,10 @@ -export const enum TLP { - white, - green, - amber, - red, -} +export const TLPs = { + white: 0, + green: 1, + amber: 2, + red: 3, +}; + +export type TLP = (typeof TLPs)[keyof typeof TLPs]; export type QueryScope = { query: string; id?: string; restrictTo?: string }; diff --git a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts index d2c48a5d07..c1ac012d5c 100644 --- a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts @@ -43,14 +43,16 @@ export interface Command { }; } -export const enum CommandType { - ITEM_MOVE = 'item_move', - ITEM_ADD = 'item_add', - ITEM_UPDATE = 'item_update', - ITEM_REORDER = 'item_reorder', - ITEM_DELETE = 'item_delete', - ITEM_COMPLETE = 'item_complete', -} +export const CommandTypes = { + ITEM_MOVE: 'item_move', + ITEM_ADD: 'item_add', + ITEM_UPDATE: 'item_update', + ITEM_REORDER: 'item_reorder', + ITEM_DELETE: 'item_delete', + ITEM_COMPLETE: 'item_complete', +} as const; + +export type CommandType = (typeof CommandTypes)[keyof typeof CommandTypes]; async function getLabelNameFromId(ctx: Context, labelIds: number[]): Promise { const labelList = []; @@ -263,7 +265,7 @@ export class MoveHandler implements OperationHandler { const body: SyncRequest = { commands: [ { - type: CommandType.ITEM_MOVE, + type: CommandTypes.ITEM_MOVE, uuid: uuid(), args: { id: taskId, @@ -339,7 +341,7 @@ export class SyncHandler implements OperationHandler { } private requiresProjectId(command: Command) { - return command.type === CommandType.ITEM_ADD; + return command.type === CommandTypes.ITEM_ADD; } private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { @@ -350,6 +352,6 @@ export class SyncHandler implements OperationHandler { } private requiresTempId(command: Command) { - return command.type === CommandType.ITEM_ADD; + return command.type === CommandTypes.ITEM_ADD; } } diff --git a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts index d1b3009a9f..b5c0393510 100644 --- a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts @@ -44,14 +44,16 @@ export interface Command { }; } -export const enum CommandType { - ITEM_MOVE = 'item_move', - ITEM_ADD = 'item_add', - ITEM_UPDATE = 'item_update', - ITEM_REORDER = 'item_reorder', - ITEM_DELETE = 'item_delete', - ITEM_COMPLETE = 'item_complete', -} +export const CommandTypes = { + ITEM_MOVE: 'item_move', + ITEM_ADD: 'item_add', + ITEM_UPDATE: 'item_update', + ITEM_REORDER: 'item_reorder', + ITEM_DELETE: 'item_delete', + ITEM_COMPLETE: 'item_complete', +} as const; + +export type CommandType = (typeof CommandTypes)[keyof typeof CommandTypes]; export class CreateHandler implements OperationHandler { async handleOperation(ctx: Context, itemIndex: number): Promise { @@ -261,7 +263,7 @@ export class MoveHandler implements OperationHandler { const body: SyncRequest = { commands: [ { - type: CommandType.ITEM_MOVE, + type: CommandTypes.ITEM_MOVE, uuid: uuid(), args: { id: taskId, @@ -351,7 +353,7 @@ export class SyncHandler implements OperationHandler { } private requiresProjectId(command: Command) { - return command.type === CommandType.ITEM_ADD; + return command.type === CommandTypes.ITEM_ADD; } private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { @@ -362,6 +364,6 @@ export class SyncHandler implements OperationHandler { } private requiresTempId(command: Command) { - return command.type === CommandType.ITEM_ADD; + return command.type === CommandTypes.ITEM_ADD; } }