mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-29 06:29:42 -08:00
9a1cc56806
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
61 lines
1.2 KiB
TypeScript
61 lines
1.2 KiB
TypeScript
import type { IDataObject } from 'n8n-workflow';
|
|
import type { Context } from '../GenericFunctions';
|
|
import {
|
|
CloseHandler,
|
|
CreateHandler,
|
|
DeleteHandler,
|
|
GetAllHandler,
|
|
GetHandler,
|
|
MoveHandler,
|
|
ReopenHandler,
|
|
SyncHandler,
|
|
UpdateHandler,
|
|
} from './OperationHandler';
|
|
|
|
export class TodoistService implements Service {
|
|
async execute(
|
|
ctx: Context,
|
|
operation: OperationType,
|
|
itemIndex: number,
|
|
): Promise<TodoistResponse> {
|
|
return await this.handlers[operation].handleOperation(ctx, itemIndex);
|
|
}
|
|
|
|
private handlers = {
|
|
create: new CreateHandler(),
|
|
close: new CloseHandler(),
|
|
delete: new DeleteHandler(),
|
|
get: new GetHandler(),
|
|
getAll: new GetAllHandler(),
|
|
reopen: new ReopenHandler(),
|
|
update: new UpdateHandler(),
|
|
move: new MoveHandler(),
|
|
sync: new SyncHandler(),
|
|
};
|
|
}
|
|
|
|
export type OperationType =
|
|
| 'create'
|
|
| 'close'
|
|
| 'delete'
|
|
| 'get'
|
|
| 'getAll'
|
|
| 'reopen'
|
|
| 'update'
|
|
| 'move'
|
|
| 'sync';
|
|
|
|
export interface Section {
|
|
name: string;
|
|
id: string;
|
|
}
|
|
|
|
export interface Service {
|
|
execute(ctx: Context, operation: OperationType, itemIndex: number): Promise<TodoistResponse>;
|
|
}
|
|
|
|
export interface TodoistResponse {
|
|
success?: boolean;
|
|
data?: IDataObject;
|
|
}
|