add missing func def (#41904)

This commit is contained in:
하도영 2020-01-29 04:22:08 +09:00 committed by Wesley Wigham
parent d9c56b4f18
commit de18e9f6ee
2 changed files with 59 additions and 2 deletions

View File

@ -1,5 +1,47 @@
import { Client, Variables } from 'camunda-external-task-client-js';
import { Client, HandlerArgs, Task, TaskService, TopicSubscription, Variables } from 'camunda-external-task-client-js';
new Client({ baseUrl: '' }); // $ExpectType Client
new Variables(); // $ExpectType Variables
new Variables().set('a', 42).getAllTyped(); // $ExpectType TypedValue[]
const client: Client = new Client({ baseUrl: '' }); // $ExpectType Client
client.on('subscribe', (topic: string, topicSubscription: TopicSubscription) => {});
client.on('unsubscribe', (topic: string, topicSubscription: TopicSubscription) => {});
client.on('poll:start', () => {});
client.on('poll:stop', () => {});
client.on('poll:success', (tasks: Task[]) => {});
client.on('complete:success', (task: Task) => {});
client.on('handleFailure:success', (task: Task) => {});
client.on('handleBpmnError:success', (task: Task) => {});
client.on('extendLock:success', (task: Task) => {});
client.on('unlock:success', (task: Task) => {});
client.on('handleFailure:error', (task: Task, error: any) => {});
client.on('handleBpmnError:error', (task: Task, error: any) => {});
client.on('extendLock:error', (task: Task, error: any) => {});
client.on('unlock:error', (task: Task, error: any) => {});
client.on('complete:error', (error: any) => {});
client.on('poll:error', (error: any) => {});
client.start();
client.stop();
client.subscribe('', {}, (args: HandlerArgs) => {
const task: Task = args.task;
const taskService: TaskService = args.taskService;
task.businessKey;
task.processInstanceId;
task.id;
task.executionId;
task.activityId;
task.activityInstanceId;
task.tenantId;
task.topicName;
task.workerId;
taskService.handleFailure(task, {});
taskService.complete(task);
});

View File

@ -1,6 +1,7 @@
// Type definitions for camunda-external-task-client-js 1.2
// Type definitions for camunda-external-task-client-js 1.3
// Project: https://github.com/camunda/camunda-external-task-client-js#readme
// Definitions by: MacRusher <https://github.com/MacRusher>
// DoYoung Ha <https://github.com/hados99>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@ -10,6 +11,13 @@ export class Client {
stop(): void;
subscribe(topic: string, options: SubscribeOptions, handler: Handler): TopicSubscription;
subscribe(topic: string, handler: Handler): TopicSubscription;
on(name: TopicEvent, callback: (topic: string, topicSubscription: TopicSubscription) => void): void;
on(name: PollEvent, callback: () => void): void;
on(name: SuccessWithTasksEvent, callback: (tasks: Task[]) => void): void;
on(name: SuccessWithTaskEvent, callback: (task: Task) => void): void;
on(name: ErrorWithTaskEvent, callback: (task: Task, error: any) => void): void;
on(name: ErrorEvent, callback: (error: any) => void): void;
}
export interface ClientConfig {
@ -114,4 +122,11 @@ export type Logger = Middleware & {
error(text: string): void;
};
export type TopicEvent = "subscribe" | "unsubscribe";
export type PollEvent = "poll:start" | "poll:stop";
export type SuccessWithTasksEvent = "poll:success";
export type SuccessWithTaskEvent = "complete:success" | "handleFailure:success" | "handleBpmnError:success" | "extendLock:success" | "unlock:success";
export type ErrorWithTaskEvent = "handleFailure:error" | "handleBpmnError:error" | "extendLock:error" | "unlock:error";
export type ErrorEvent = "poll:error" | "complete:error";
export const logger: Logger;