refactor: Convert all enums to const object types in nodes-base (no-changelog) (#14131)

This commit is contained in:
Alex Grozav
2025-03-24 14:40:19 +02:00
committed by GitHub
parent defeb2e817
commit b9608647ca
31 changed files with 422 additions and 345 deletions

View File

@@ -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;

View File

@@ -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<string, (body: JsonObject) => void>([
[

View File

@@ -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<INodeExecutionData[][] | null> {
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`;

View File

@@ -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;

View File

@@ -0,0 +1,5 @@
export const EntryTypes = {
NEW_TIME_ENTRY: 0,
} as const;
export type EntryType = (typeof EntryTypes)[keyof typeof EntryTypes];

View File

@@ -1,3 +0,0 @@
export const enum EntryTypeEnum {
NEW_TIME_ENTRY,
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,

View File

@@ -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;

View File

@@ -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.',

View File

@@ -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

View File

@@ -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;

View File

@@ -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
//

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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.',

View File

@@ -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.',

View File

@@ -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.',

View File

@@ -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

View File

@@ -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];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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];

View File

@@ -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,
},
],
};

View File

@@ -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,

View File

@@ -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 };

View File

@@ -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<string[]> {
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<string, string>, 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;
}
}

View File

@@ -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<TodoistResponse> {
@@ -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<string, string>, 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;
}
}