refactor(core): Forbid raw enums (no-changelog)

This commit is contained in:
Michael Kret 2023-04-21 14:23:15 +03:00 committed by GitHub
parent da31925083
commit 0e93fe064e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 119 additions and 115 deletions

View file

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

View file

@ -80,7 +80,7 @@ type HttpNodeHeaders = Pick<HttpNodeParameters, 'sendHeaders' | 'headerParameter
type HttpNodeQueries = Pick<HttpNodeParameters, 'sendQuery' | 'queryParameters'>; type HttpNodeQueries = Pick<HttpNodeParameters, 'sendQuery' | 'queryParameters'>;
enum ContentTypes { const enum ContentTypes {
applicationJson = 'application/json', applicationJson = 'application/json',
applicationFormUrlEncoded = 'application/x-www-form-urlencoded', applicationFormUrlEncoded = 'application/x-www-form-urlencoded',
applicationMultipart = 'multipart/form-data', applicationMultipart = 'multipart/form-data',

View file

@ -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 const SETTINGS_LICENSE_CERT_KEY = 'license.cert';
export enum LICENSE_FEATURES { export const enum LICENSE_FEATURES {
SHARING = 'feat:sharing', SHARING = 'feat:sharing',
LDAP = 'feat:ldap', LDAP = 'feat:ldap',
SAML = 'feat:saml', SAML = 'feat:saml',
@ -78,7 +78,7 @@ export enum LICENSE_FEATURES {
VERSION_CONTROL = 'feat:versionControl', VERSION_CONTROL = 'feat:versionControl',
} }
export enum LICENSE_QUOTAS { export const enum LICENSE_QUOTAS {
TRIGGER_LIMIT = 'quota:activeWorkflows', TRIGGER_LIMIT = 'quota:activeWorkflows',
VARIABLES_LIMIT = 'quota:maxVariables', VARIABLES_LIMIT = 'quota:maxVariables',
} }

View file

@ -3,7 +3,7 @@ import { idStringifier } from '../utils/transformers';
import { datetimeColumnType } from './AbstractEntity'; import { datetimeColumnType } from './AbstractEntity';
import { WorkflowEntity } from './WorkflowEntity'; import { WorkflowEntity } from './WorkflowEntity';
export enum StatisticsNames { export const enum StatisticsNames {
productionSuccess = 'production_success', productionSuccess = 'production_success',
productionError = 'production_error', productionError = 'production_error',
manualSuccess = 'manual_success', manualSuccess = 'manual_success',

View file

@ -9,7 +9,7 @@ import { InternalHooks } from '@/InternalHooks';
import config from '@/config'; import config from '@/config';
import { UserService } from '@/user/user.service'; import { UserService } from '@/user/user.service';
enum StatisticsUpsertResult { const enum StatisticsUpsertResult {
insert = 'insert', insert = 'insert',
update = 'update', update = 'update',
failed = 'failed', failed = 'failed',

View file

@ -635,7 +635,7 @@ export interface IN8nPromptResponse {
updated: boolean; updated: boolean;
} }
export enum UserManagementAuthenticationMethod { export const enum UserManagementAuthenticationMethod {
Email = 'email', Email = 'email',
Ldap = 'ldap', Ldap = 'ldap',
Saml = 'saml', Saml = 'saml',

View file

@ -362,7 +362,7 @@ export const NODE_TYPE_COUNT_MAPPER = {
}; };
export const TEMPLATES_NODES_FILTER = ['n8n-nodes-base.start', 'n8n-nodes-base.respondToWebhook']; export const TEMPLATES_NODES_FILTER = ['n8n-nodes-base.start', 'n8n-nodes-base.respondToWebhook'];
export enum VIEWS { export const enum VIEWS {
HOMEPAGE = 'Homepage', HOMEPAGE = 'Homepage',
COLLECTION = 'TemplatesCollectionView', COLLECTION = 'TemplatesCollectionView',
EXECUTIONS = 'Executions', EXECUTIONS = 'Executions',
@ -398,7 +398,7 @@ export enum VIEWS {
VERSION_CONTROL = 'VersionControl', VERSION_CONTROL = 'VersionControl',
} }
export enum FAKE_DOOR_FEATURES { export const enum FAKE_DOOR_FEATURES {
ENVIRONMENTS = 'environments', ENVIRONMENTS = 'environments',
LOGGING = 'logging', LOGGING = 'logging',
SSO = 'sso', SSO = 'sso',
@ -443,7 +443,7 @@ export const MAPPING_PARAMS = [
export const DEFAULT_STICKY_HEIGHT = 160; export const DEFAULT_STICKY_HEIGHT = 160;
export const DEFAULT_STICKY_WIDTH = 240; export const DEFAULT_STICKY_WIDTH = 240;
export enum WORKFLOW_MENU_ACTIONS { export const enum WORKFLOW_MENU_ACTIONS {
DUPLICATE = 'duplicate', DUPLICATE = 'duplicate',
DOWNLOAD = 'download', DOWNLOAD = 'download',
IMPORT_FROM_URL = 'import-from-url', IMPORT_FROM_URL = 'import-from-url',
@ -455,7 +455,7 @@ export enum WORKFLOW_MENU_ACTIONS {
/** /**
* Enterprise edition * Enterprise edition
*/ */
export enum EnterpriseEditionFeature { export const enum EnterpriseEditionFeature {
AdvancedExecutionFilters = 'advancedExecutionFilters', AdvancedExecutionFilters = 'advancedExecutionFilters',
Sharing = 'sharing', Sharing = 'sharing',
Ldap = 'ldap', Ldap = 'ldap',
@ -466,7 +466,7 @@ export enum EnterpriseEditionFeature {
} }
export const MAIN_NODE_PANEL_WIDTH = 360; export const MAIN_NODE_PANEL_WIDTH = 360;
export enum MAIN_HEADER_TABS { export const enum MAIN_HEADER_TABS {
WORKFLOW = 'workflow', WORKFLOW = 'workflow',
EXECUTIONS = 'executions', EXECUTIONS = 'executions',
SETTINGS = 'settings', SETTINGS = 'settings',
@ -504,7 +504,7 @@ export const CURL_IMPORT_NODES_PROTOCOLS: { [key: string]: string } = {
imaps: 'IMAP', imaps: 'IMAP',
}; };
export enum STORES { export const enum STORES {
COMMUNITY_NODES = 'communityNodes', COMMUNITY_NODES = 'communityNodes',
ROOT = 'root', ROOT = 'root',
SETTINGS = 'settings', SETTINGS = 'settings',
@ -523,7 +523,7 @@ export enum STORES {
HISTORY = 'history', HISTORY = 'history',
} }
export enum SignInType { export const enum SignInType {
LDAP = 'ldap', LDAP = 'ldap',
EMAIL = 'email', EMAIL = 'email',
} }

View file

@ -6,7 +6,7 @@ import { createEventBus } from '@/event-bus';
// Command names don't serve any particular purpose in the app // Command names don't serve any particular purpose in the app
// but they make it easier to identify each command on stack // but they make it easier to identify each command on stack
// when debugging // when debugging
export enum COMMANDS { export const enum COMMANDS {
MOVE_NODE = 'moveNode', MOVE_NODE = 'moveNode',
ADD_NODE = 'addNode', ADD_NODE = 'addNode',
REMOVE_NODE = 'removeNode', REMOVE_NODE = 'removeNode',

View file

@ -14,7 +14,7 @@ import {
import { EnterpriseEditionFeature, PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants'; import { EnterpriseEditionFeature, PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants';
import { useSettingsStore } from './stores/settings'; import { useSettingsStore } from './stores/settings';
export enum UserRole { export const enum UserRole {
InstanceOwner = 'isInstanceOwner', InstanceOwner = 'isInstanceOwner',
ResourceOwner = 'isOwner', ResourceOwner = 'isOwner',
ResourceEditor = 'isEditor', ResourceEditor = 'isEditor',

View file

@ -24,7 +24,6 @@ module.exports = {
'@typescript-eslint/naming-convention': ['error', { selector: 'memberLike', format: null }], '@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-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-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-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-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 '@typescript-eslint/no-unsafe-member-access': 'off', //4591 errors, better to fix in separate PR

View file

@ -51,7 +51,7 @@ export type PartitionKey = {
}; };
}; };
export enum EAttributeValueType { export const enum EAttributeValueType {
S = 'S', S = 'S',
SS = 'SS', SS = 'SS',
M = 'M', M = 'M',

View file

@ -3,14 +3,14 @@ export interface IHourlyRateDto {
currency: string; currency: string;
} }
enum MembershipStatusEnum { const enum MembershipStatusEnum {
PENDING = 'PENDING', PENDING = 'PENDING',
ACTIVE = 'ACTIVE', ACTIVE = 'ACTIVE',
DECLINED = 'DECLINED', DECLINED = 'DECLINED',
INACTIVE = 'INACTIVE', INACTIVE = 'INACTIVE',
} }
enum TaskStatusEnum { const enum TaskStatusEnum {
ACTIVE = 'ACTIVE', ACTIVE = 'ACTIVE',
DONE = 'DONE', DONE = 'DONE',
} }

View file

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

View file

@ -1,6 +1,6 @@
import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; import type { IHourlyRateDto, IMembershipDto } from './CommonDtos';
enum EstimateEnum { const enum EstimateEnum {
AUTO = 'AUTO', AUTO = 'AUTO',
MANUAL = 'MANUAL', MANUAL = 'MANUAL',
} }
@ -40,7 +40,7 @@ export interface IProjectRequest {
tasks: ITaskDto; tasks: ITaskDto;
} }
enum TaskStatusEnum { const enum TaskStatusEnum {
ACTIVE = 'ACTIVE', ACTIVE = 'ACTIVE',
DONE = 'DONE', DONE = 'DONE',
} }

View file

@ -1,7 +1,7 @@
import type { IDataObject } from 'n8n-workflow'; import type { IDataObject } from 'n8n-workflow';
import type { IMembershipDto } from './CommonDtos'; import type { IMembershipDto } from './CommonDtos';
enum UserStatusEnum { const enum UserStatusEnum {
ACTIVE, ACTIVE,
PENDING_EMAIL_VERIFICATION, PENDING_EMAIL_VERIFICATION,
DELETED, DELETED,

View file

@ -1,12 +1,12 @@
import type { IHourlyRateDto, IMembershipDto } from './CommonDtos'; import type { IHourlyRateDto, IMembershipDto } from './CommonDtos';
enum AdminOnlyPagesEnum { const enum AdminOnlyPagesEnum {
PROJECT = 'PROJECT', PROJECT = 'PROJECT',
TEAM = 'TEAM', TEAM = 'TEAM',
REPORTS = 'REPORTS', REPORTS = 'REPORTS',
} }
enum DaysOfWeekEnum { const enum DaysOfWeekEnum {
MONDAY = 'MONDAY', MONDAY = 'MONDAY',
TUESDAY = 'TUESDAY', TUESDAY = 'TUESDAY',
WEDNESDAY = 'WEDNESDAY', WEDNESDAY = 'WEDNESDAY',
@ -16,13 +16,13 @@ enum DaysOfWeekEnum {
SUNDAY = 'SUNDAY', SUNDAY = 'SUNDAY',
} }
enum DatePeriodEnum { const enum DatePeriodEnum {
DAYS = 'DAYS', DAYS = 'DAYS',
WEEKS = 'WEEKS', WEEKS = 'WEEKS',
MONTHS = 'MONTHS', MONTHS = 'MONTHS',
} }
enum AutomaticLockTypeEnum { const enum AutomaticLockTypeEnum {
WEEKLY = 'WEEKLY', WEEKLY = 'WEEKLY',
MONTHLY = 'MONTHLY', MONTHLY = 'MONTHLY',
OLDER_THAN = 'OLDER_THAN', OLDER_THAN = 'OLDER_THAN',

View file

@ -1,6 +1,6 @@
import type { IDataObject } from 'n8n-workflow'; import type { IDataObject } from 'n8n-workflow';
export enum JobStatus { export const enum JobStatus {
WAITING = 'Waiting', WAITING = 'Waiting',
INPROGRESS = 'InProgress', INPROGRESS = 'InProgress',
SUCCESS = 'Success', SUCCESS = 'Success',
@ -8,14 +8,14 @@ export enum JobStatus {
DELETED = 'Deleted', DELETED = 'Deleted',
} }
export enum TLP { export const enum TLP {
white, white,
green, green,
amber, amber,
red, red,
} }
export enum ObservableDataType { export const enum ObservableDataType {
'domain' = 'domain', 'domain' = 'domain',
'file' = 'file', 'file' = 'file',
'filename' = 'filename', 'filename' = 'filename',

View file

@ -39,7 +39,7 @@ export interface IFormstackSubmissionFieldContainer {
value: string; value: string;
} }
export enum FormstackFieldFormat { export const enum FormstackFieldFormat {
ID = 'id', ID = 'id',
Label = 'label', Label = 'label',
Name = 'name', Name = 'name',

View file

@ -20,21 +20,21 @@ import type { ICreateContactBody } from './ContactInterface';
import { contactFields, contactOperations } from './ContactDescription'; import { contactFields, contactOperations } from './ContactDescription';
enum Status { const enum Status {
Open = 2, Open = 2,
Pending = 3, Pending = 3,
Resolved = 4, Resolved = 4,
Closed = 5, Closed = 5,
} }
enum Priority { const enum Priority {
Low = 1, Low = 1,
Medium = 2, Medium = 2,
High = 3, High = 3,
Urgent = 4, Urgent = 4,
} }
enum Source { const enum Source {
Email = 1, Email = 1,
Portal = 2, Portal = 2,
Phone = 3, Phone = 3,

View file

@ -31,7 +31,7 @@ export interface IUser {
type?: Type; type?: Type;
isAnonymous?: boolean; isAnonymous?: boolean;
} }
enum Type { const enum Type {
'TYPE_UNSPECIFIED', 'TYPE_UNSPECIFIED',
'HUMAN', 'HUMAN',
'BOT', 'BOT',

View file

@ -64,11 +64,11 @@ export type SheetProperties = PropertiesOf<GoogleSheetsSheet>;
export type ResourceLocator = 'id' | 'url' | 'list'; export type ResourceLocator = 'id' | 'url' | 'list';
export enum ResourceLocatorUiNames { export const ResourceLocatorUiNames = {
id = 'By ID', id: 'By ID',
url = 'By URL', url: 'By URL',
list = 'From List', list: 'From List',
} };
export type SheetCellDecoded = { export type SheetCellDecoded = {
cell?: string; cell?: string;

View file

@ -29,16 +29,16 @@ type Aggregation = {
type Aggregations = Aggregation[]; type Aggregations = Aggregation[];
enum AggregationDisplayNames { const AggregationDisplayNames = {
append = 'appended_', append: 'appended_',
average = 'average_', average: 'average_',
concatenate = 'concatenated_', concatenate: 'concatenated_',
count = 'count_', count: 'count_',
countUnique = 'unique_count_', countUnique: 'unique_count_',
max = 'max_', max: 'max_',
min = 'min_', min: 'min_',
sum = 'sum_', sum: 'sum_',
} };
const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum']; const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum'];

View file

@ -29,16 +29,17 @@ type Aggregation = {
type Aggregations = Aggregation[]; type Aggregations = Aggregation[];
enum AggregationDisplayNames { // eslint-disable-next-line no-restricted-syntax
append = 'appended_', const AggregationDisplayNames = {
average = 'average_', append: 'appended_',
concatenate = 'concatenated_', average: 'average_',
count = 'count_', concatenate: 'concatenated_',
countUnique = 'unique_count_', count: 'count_',
max = 'max_', countUnique: 'unique_count_',
min = 'min_', max: 'max_',
sum = 'sum_', min: 'min_',
} sum: 'sum_',
};
const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum']; const NUMERICAL_AGGREGATIONS = ['average', 'max', 'min', 'sum'];

View file

@ -17,7 +17,7 @@ import {
import moment from 'moment'; import moment from 'moment';
enum Status { const enum Status {
subscribe = 'subscribe', subscribe = 'subscribe',
unsubscribed = 'unsubscribe', unsubscribed = 'unsubscribe',
cleaned = 'cleaned', cleaned = 'cleaned',

View file

@ -1,10 +1,10 @@
export enum RecipientType { export const enum RecipientType {
email = 'EMAIL', email = 'EMAIL',
phone = 'PHONE', phone = 'PHONE',
paypalId = 'PAYPAL_ID', paypalId = 'PAYPAL_ID',
} }
export enum RecipientWallet { export const enum RecipientWallet {
paypal = 'PAYPAL', paypal = 'PAYPAL',
venmo = 'VENMO', venmo = 'VENMO',
} }

View file

@ -18,13 +18,13 @@ export namespace SendInBlueNode {
type BBCEmail = { bbc: Email[] }; type BBCEmail = { bbc: Email[] };
type ValidatedEmail = ToEmail | SenderEmail | CCEmail | BBCEmail; type ValidatedEmail = ToEmail | SenderEmail | CCEmail | BBCEmail;
enum OVERRIDE_MAP_VALUES { const enum OVERRIDE_MAP_VALUES {
'CATEGORY' = 'category', 'CATEGORY' = 'category',
'NORMAL' = 'boolean', 'NORMAL' = 'boolean',
'TRANSACTIONAL' = 'id', 'TRANSACTIONAL' = 'id',
} }
enum OVERRIDE_MAP_TYPE { const enum OVERRIDE_MAP_TYPE {
'CATEGORY' = 'category', 'CATEGORY' = 'category',
'NORMAL' = 'normal', 'NORMAL' = 'normal',
'TRANSACTIONAL' = 'transactional', 'TRANSACTIONAL' = 'transactional',

View file

@ -1,11 +1,11 @@
import type { IDataObject } from 'n8n-workflow'; import type { IDataObject } from 'n8n-workflow';
export enum AlertStatus { export const enum AlertStatus {
NEW = 'New', NEW = 'New',
UPDATED = 'Updated', UPDATED = 'Updated',
IGNORED = 'Ignored', IGNORED = 'Ignored',
IMPORTED = 'Imported', IMPORTED = 'Imported',
} }
export enum TLP { export const enum TLP {
white, white,
green, green,
amber, amber,

View file

@ -31,13 +31,13 @@ export interface ICase {
upadtedAt?: Date; upadtedAt?: Date;
} }
export enum CaseStatus { export const enum CaseStatus {
OPEN = 'Open', OPEN = 'Open',
RESOLVED = 'Resolved', RESOLVED = 'Resolved',
DELETED = 'Deleted', DELETED = 'Deleted',
} }
export enum CaseResolutionStatus { export const enum CaseResolutionStatus {
INDETERMINATE = 'Indeterminate', INDETERMINATE = 'Indeterminate',
FALSEPOSITIVE = 'FalsePositive', FALSEPOSITIVE = 'FalsePositive',
TRUEPOSITIVE = 'TruePositive', TRUEPOSITIVE = 'TruePositive',
@ -45,7 +45,7 @@ export enum CaseResolutionStatus {
DUPLICATED = 'Duplicated', DUPLICATED = 'Duplicated',
} }
export enum CaseImpactStatus { export const enum CaseImpactStatus {
NOIMPACT = 'NoImpact', NOIMPACT = 'NoImpact',
WITHIMPACT = 'WithImpact', WITHIMPACT = 'WithImpact',
NOTAPPLICABLE = 'NotApplicable', NOTAPPLICABLE = 'NotApplicable',

View file

@ -1,5 +1,5 @@
import type { IAttachment } from './ObservableInterface'; import type { IAttachment } from './ObservableInterface';
export enum LogStatus { export const enum LogStatus {
OK = 'Ok', OK = 'Ok',
DELETED = 'Deleted', DELETED = 'Deleted',
} }

View file

@ -1,10 +1,10 @@
import type { TLP } from './AlertInterface'; import type { TLP } from './AlertInterface';
export enum ObservableStatus { export const enum ObservableStatus {
OK = 'Ok', OK = 'Ok',
DELETED = 'Deleted', DELETED = 'Deleted',
} }
export enum ObservableDataType { export const enum ObservableDataType {
'domain' = 'domain', 'domain' = 'domain',
'file' = 'file', 'file' = 'file',
'filename' = 'filename', 'filename' = 'filename',

View file

@ -17,7 +17,7 @@ export interface ITask {
upadtedAt?: Date; upadtedAt?: Date;
} }
export enum TaskStatus { export const enum TaskStatus {
WAITING = 'Waiting', WAITING = 'Waiting',
INPROGRESS = 'InProgress', INPROGRESS = 'InProgress',
COMPLETED = 'Completed', COMPLETED = 'Completed',

View file

@ -42,7 +42,7 @@ export interface Command {
}; };
} }
export enum CommandType { export const enum CommandType {
ITEM_MOVE = 'item_move', ITEM_MOVE = 'item_move',
ITEM_ADD = 'item_add', ITEM_ADD = 'item_add',
ITEM_UPDATE = 'item_update', ITEM_UPDATE = 'item_update',

View file

@ -35,17 +35,16 @@ export class TodoistService implements Service {
}; };
} }
export enum OperationType { export type OperationType =
create = 'create', | 'create'
close = 'close', | 'close'
delete = 'delete', | 'delete'
get = 'get', | 'get'
getAll = 'getAll', | 'getAll'
reopen = 'reopen', | 'reopen'
update = 'update', | 'update'
move = 'move', | 'move'
sync = 'sync', | 'sync';
}
export interface Section { export interface Section {
name: string; name: string;

View file

@ -13,7 +13,8 @@ import type {
import { todoistApiRequest } from '../GenericFunctions'; import { todoistApiRequest } from '../GenericFunctions';
import { OperationType, TodoistService } from './Service'; import type { OperationType } from './Service';
import { TodoistService } from './Service';
// interface IBodyCreateTask { // interface IBodyCreateTask {
// content?: string; // content?: string;
@ -702,15 +703,11 @@ export class TodoistV1 implements INodeType {
const service = new TodoistService(); const service = new TodoistService();
let responseData; let responseData;
const resource = this.getNodeParameter('resource', 0); 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++) { for (let i = 0; i < length; i++) {
try { try {
if (resource === 'task') { if (resource === 'task') {
responseData = await service.execute( responseData = await service.execute(this, operation, i);
this,
OperationType[operation as keyof typeof OperationType],
i,
);
} }
if (Array.isArray(responseData?.data)) { if (Array.isArray(responseData?.data)) {
returnData.push.apply(returnData, responseData?.data as IDataObject[]); returnData.push.apply(returnData, responseData?.data as IDataObject[]);

View file

@ -42,7 +42,7 @@ export interface Command {
}; };
} }
export enum CommandType { export const enum CommandType {
ITEM_MOVE = 'item_move', ITEM_MOVE = 'item_move',
ITEM_ADD = 'item_add', ITEM_ADD = 'item_add',
ITEM_UPDATE = 'item_update', ITEM_UPDATE = 'item_update',

View file

@ -35,17 +35,16 @@ export class TodoistService implements Service {
}; };
} }
export enum OperationType { export type OperationType =
create = 'create', | 'create'
close = 'close', | 'close'
delete = 'delete', | 'delete'
get = 'get', | 'get'
getAll = 'getAll', | 'getAll'
reopen = 'reopen', | 'reopen'
update = 'update', | 'update'
move = 'move', | 'move'
sync = 'sync', | 'sync';
}
export interface Section { export interface Section {
name: string; name: string;

View file

@ -13,7 +13,8 @@ import type {
import { todoistApiRequest } from '../GenericFunctions'; import { todoistApiRequest } from '../GenericFunctions';
import { OperationType, TodoistService } from './Service'; import type { OperationType } from './Service';
import { TodoistService } from './Service';
// interface IBodyCreateTask { // interface IBodyCreateTask {
// content?: string; // content?: string;
@ -701,15 +702,11 @@ export class TodoistV2 implements INodeType {
const service = new TodoistService(); const service = new TodoistService();
let responseData; let responseData;
const resource = this.getNodeParameter('resource', 0); 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++) { for (let i = 0; i < length; i++) {
try { try {
if (resource === 'task') { if (resource === 'task') {
responseData = await service.execute( responseData = await service.execute(this, operation, i);
this,
OperationType[operation as keyof typeof OperationType],
i,
);
} }
if (responseData !== undefined && Array.isArray(responseData?.data)) { if (responseData !== undefined && Array.isArray(responseData?.data)) {

View file

@ -1868,7 +1868,7 @@ export interface IConnectedNode {
depth: number; depth: number;
} }
export enum OAuth2GrantType { export const enum OAuth2GrantType {
authorizationCode = 'authorizationCode', authorizationCode = 'authorizationCode',
clientCredentials = 'clientCredentials', clientCredentials = 'clientCredentials',
} }

View file

@ -5,7 +5,7 @@ import type { INodeCredentials } from './Interfaces';
// General Enums And Interfaces // General Enums And Interfaces
// =============================== // ===============================
export enum EventMessageTypeNames { export const enum EventMessageTypeNames {
generic = '$$EventMessage', generic = '$$EventMessage',
audit = '$$EventMessageAudit', audit = '$$EventMessageAudit',
confirm = '$$EventMessageConfirm', confirm = '$$EventMessageConfirm',
@ -13,7 +13,7 @@ export enum EventMessageTypeNames {
node = '$$EventMessageNode', node = '$$EventMessageNode',
} }
export enum MessageEventBusDestinationTypeNames { export const enum MessageEventBusDestinationTypeNames {
abstract = '$$AbstractMessageEventBusDestination', abstract = '$$AbstractMessageEventBusDestination',
webhook = '$$MessageEventBusDestinationWebhook', webhook = '$$MessageEventBusDestinationWebhook',
sentry = '$$MessageEventBusDestinationSentry', sentry = '$$MessageEventBusDestinationSentry',