@botpress/sdk 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -4
- package/dist/bot/bot-logger.d.ts +4 -0
- package/dist/bot/implementation.d.ts +26 -14
- package/dist/bot/server/types.d.ts +91 -63
- package/dist/bot/server/workflows/update-handler.d.ts +1 -1
- package/dist/bot/server/workflows/update-type-conv.d.ts +1 -2
- package/dist/index.cjs +25 -25
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +27 -27
- package/dist/index.mjs.map +3 -3
- package/dist/plugin/implementation.d.ts +26 -24
- package/dist/plugin/server/types.d.ts +94 -38
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/sdk@3.
|
|
2
|
+
> @botpress/sdk@3.6.0 build /home/runner/work/botpress/botpress/packages/sdk
|
|
3
3
|
> pnpm build:type && pnpm build:node && pnpm build:browser
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @botpress/sdk@3.
|
|
6
|
+
> @botpress/sdk@3.6.0 build:type /home/runner/work/botpress/botpress/packages/sdk
|
|
7
7
|
> tsc --emitDeclarationOnly --declaration
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @botpress/sdk@3.
|
|
10
|
+
> @botpress/sdk@3.6.0 build:node /home/runner/work/botpress/botpress/packages/sdk
|
|
11
11
|
> ts-node -T ./build.ts --node
|
|
12
12
|
|
|
13
13
|
Done
|
|
14
14
|
|
|
15
|
-
> @botpress/sdk@3.
|
|
15
|
+
> @botpress/sdk@3.6.0 build:browser /home/runner/work/botpress/botpress/packages/sdk
|
|
16
16
|
> ts-node -T ./build.ts --browser
|
|
17
17
|
|
|
18
18
|
Done
|
package/dist/bot/bot-logger.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ type BotLogOptions = {
|
|
|
3
3
|
userId?: string;
|
|
4
4
|
conversationId?: string;
|
|
5
5
|
workflowId?: string;
|
|
6
|
+
eventId?: string;
|
|
7
|
+
messageId?: string;
|
|
6
8
|
};
|
|
7
9
|
export declare class BotLogger extends BaseLogger<BotLogOptions> {
|
|
8
10
|
constructor(options?: BotLogOptions);
|
|
@@ -10,5 +12,7 @@ export declare class BotLogger extends BaseLogger<BotLogOptions> {
|
|
|
10
12
|
withUserId(userId: string): BotLogger;
|
|
11
13
|
withConversationId(conversationId: string): BotLogger;
|
|
12
14
|
withWorkflowId(workflowId: string): BotLogger;
|
|
15
|
+
withEventId(eventId: string): BotLogger;
|
|
16
|
+
withMessageId(messageId: string): BotLogger;
|
|
13
17
|
}
|
|
14
18
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import { BasePlugin, PluginImplementation } from '../plugin';
|
|
3
|
+
import * as utils from '../utils';
|
|
3
4
|
import { BaseBot } from './common';
|
|
4
|
-
import {
|
|
5
|
+
import { ActionHandlers, MessageHandlers, EventHandlers, StateExpiredHandlers, HookHandlers, WorkflowHandlers, MessageHandlersMap, EventHandlersMap, StateExpiredHandlersMap, HookHandlersMap, WorkflowHandlersMap, BotHandlers, UnimplementedActionHandlers } from './server';
|
|
5
6
|
export type BotImplementationProps<TBot extends BaseBot = BaseBot, TPlugins extends Record<string, BasePlugin> = {}> = {
|
|
6
7
|
actions: UnimplementedActionHandlers<TBot, TPlugins>;
|
|
7
8
|
plugins: {
|
|
8
|
-
[K in
|
|
9
|
+
[K in utils.types.StringKeys<TPlugins>]: PluginImplementation<TPlugins[K]>;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
export declare class BotImplementation<TBot extends BaseBot = BaseBot, TPlugins extends Record<string, BasePlugin> = {}> implements BotHandlers<TBot> {
|
|
@@ -17,6 +18,7 @@ export declare class BotImplementation<TBot extends BaseBot = BaseBot, TPlugins
|
|
|
17
18
|
private _hookHandlers;
|
|
18
19
|
private _workflowHandlers;
|
|
19
20
|
private _plugins;
|
|
21
|
+
private _registerOrder;
|
|
20
22
|
constructor(props: BotImplementationProps<TBot, TPlugins>);
|
|
21
23
|
get actionHandlers(): ActionHandlers<TBot>;
|
|
22
24
|
get messageHandlers(): MessageHandlersMap<TBot>;
|
|
@@ -25,22 +27,32 @@ export declare class BotImplementation<TBot extends BaseBot = BaseBot, TPlugins
|
|
|
25
27
|
get hookHandlers(): HookHandlersMap<TBot>;
|
|
26
28
|
get workflowHandlers(): WorkflowHandlersMap<TBot>;
|
|
27
29
|
readonly on: {
|
|
28
|
-
message: <T extends
|
|
30
|
+
message: <T extends utils.types.StringKeys<MessageHandlersMap<TBot>>>(type: T, handler: MessageHandlers<TBot>[T]) => void;
|
|
31
|
+
event: <T extends utils.types.StringKeys<EventHandlersMap<TBot>>>(type: T, handler: EventHandlers<TBot>[T]) => void;
|
|
32
|
+
stateExpired: <T extends utils.types.StringKeys<StateExpiredHandlersMap<TBot>>>(type: T, handler: StateExpiredHandlers<TBot>[T]) => void;
|
|
33
|
+
beforeIncomingEvent: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["before_incoming_event"]>>(type: T, handler: HookHandlers<TBot>["before_incoming_event"][T]) => void;
|
|
34
|
+
beforeIncomingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["before_incoming_message"]>>(type: T, handler: HookHandlers<TBot>["before_incoming_message"][T]) => void;
|
|
35
|
+
beforeOutgoingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["before_outgoing_message"]>>(type: T, handler: HookHandlers<TBot>["before_outgoing_message"][T]) => void;
|
|
36
|
+
beforeOutgoingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["before_outgoing_call_action"]>>(type: T, handler: HookHandlers<TBot>["before_outgoing_call_action"][T]) => void;
|
|
37
|
+
afterIncomingEvent: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["after_incoming_event"]>>(type: T, handler: HookHandlers<TBot>["after_incoming_event"][T]) => void;
|
|
38
|
+
afterIncomingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["after_incoming_message"]>>(type: T, handler: HookHandlers<TBot>["after_incoming_message"][T]) => void;
|
|
39
|
+
afterOutgoingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["after_outgoing_message"]>>(type: T, handler: HookHandlers<TBot>["after_outgoing_message"][T]) => void;
|
|
40
|
+
afterOutgoingCallAction: <T extends utils.types.StringKeys<HookHandlersMap<TBot>["after_outgoing_call_action"]>>(type: T, handler: HookHandlers<TBot>["after_outgoing_call_action"][T]) => void;
|
|
29
41
|
/**
|
|
30
42
|
* # EXPERIMENTAL
|
|
31
43
|
* This API is experimental and may change in the future.
|
|
32
44
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
workflowStart: <T extends utils.types.StringKeys<WorkflowHandlersMap<TBot>["started"]>>(type: T, handler: WorkflowHandlers<TBot>[T]) => void;
|
|
46
|
+
/**
|
|
47
|
+
* # EXPERIMENTAL
|
|
48
|
+
* This API is experimental and may change in the future.
|
|
49
|
+
*/
|
|
50
|
+
workflowContinue: <T extends utils.types.StringKeys<WorkflowHandlersMap<TBot>["continued"]>>(type: T, handler: WorkflowHandlers<TBot>[T]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* # EXPERIMENTAL
|
|
53
|
+
* This API is experimental and may change in the future.
|
|
54
|
+
*/
|
|
55
|
+
workflowTimeout: <T extends utils.types.StringKeys<WorkflowHandlersMap<TBot>["timed_out"]>>(type: T, handler: WorkflowHandlers<TBot>[T]) => void;
|
|
44
56
|
};
|
|
45
57
|
readonly handler: (req: import("../serve").Request) => Promise<import("../serve").Response | void>;
|
|
46
58
|
readonly start: (port?: number) => Promise<Server>;
|
|
@@ -16,31 +16,31 @@ export type BotContext = {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
type _IncomingEvents<TBot extends common.BaseBot> = {
|
|
19
|
-
[K in
|
|
19
|
+
[K in utils.StringKeys<common.EnumerateEvents<TBot>>]: utils.Merge<client.Event, {
|
|
20
20
|
type: K;
|
|
21
21
|
payload: common.EnumerateEvents<TBot>[K];
|
|
22
22
|
}>;
|
|
23
23
|
};
|
|
24
24
|
type _IncomingMessages<TBot extends common.BaseBot> = {
|
|
25
|
-
[K in
|
|
25
|
+
[K in utils.StringKeys<common.GetMessages<TBot>>]: utils.Merge<client.Message, {
|
|
26
26
|
type: K;
|
|
27
27
|
payload: common.GetMessages<TBot>[K];
|
|
28
28
|
}>;
|
|
29
29
|
};
|
|
30
30
|
type _IncomingStates<TBot extends common.BaseBot> = {
|
|
31
|
-
[K in
|
|
31
|
+
[K in utils.StringKeys<common.EnumerateStates<TBot>>]: utils.Merge<client.State, {
|
|
32
32
|
name: K;
|
|
33
33
|
payload: common.EnumerateStates<TBot>[K];
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
36
|
type _OutgoingMessageRequests<TBot extends common.BaseBot> = {
|
|
37
|
-
[K in
|
|
37
|
+
[K in utils.StringKeys<common.GetMessages<TBot>>]: utils.Merge<client.ClientInputs['createMessage'], {
|
|
38
38
|
type: K;
|
|
39
39
|
payload: common.GetMessages<TBot>[K];
|
|
40
40
|
}>;
|
|
41
41
|
};
|
|
42
42
|
type _OutgoingMessageResponses<TBot extends common.BaseBot> = {
|
|
43
|
-
[K in
|
|
43
|
+
[K in utils.StringKeys<common.GetMessages<TBot>>]: utils.Merge<client.ClientOutputs['createMessage'], {
|
|
44
44
|
message: utils.Merge<client.Message, {
|
|
45
45
|
type: K;
|
|
46
46
|
payload: common.GetMessages<TBot>[K];
|
|
@@ -48,13 +48,13 @@ type _OutgoingMessageResponses<TBot extends common.BaseBot> = {
|
|
|
48
48
|
}>;
|
|
49
49
|
};
|
|
50
50
|
type _OutgoingCallActionRequests<TBot extends common.BaseBot> = {
|
|
51
|
-
[K in
|
|
51
|
+
[K in utils.StringKeys<common.EnumerateActionInputs<TBot>>]: utils.Merge<client.ClientInputs['callAction'], {
|
|
52
52
|
type: K;
|
|
53
53
|
input: common.EnumerateActionInputs<TBot>[K];
|
|
54
54
|
}>;
|
|
55
55
|
};
|
|
56
56
|
type _OutgoingCallActionResponses<TBot extends common.BaseBot> = {
|
|
57
|
-
[K in
|
|
57
|
+
[K in utils.StringKeys<common.EnumerateActionOutputs<TBot>>]: utils.Merge<client.ClientOutputs['callAction'], {
|
|
58
58
|
output: common.EnumerateActionOutputs<TBot>[K];
|
|
59
59
|
}>;
|
|
60
60
|
};
|
|
@@ -97,13 +97,13 @@ export type CommonHandlerProps<TBot extends common.BaseBot> = {
|
|
|
97
97
|
workflows: workflowProxy.WorkflowProxy<TBot>;
|
|
98
98
|
};
|
|
99
99
|
export type MessagePayloads<TBot extends common.BaseBot> = {
|
|
100
|
-
[
|
|
101
|
-
message: IncomingMessages<TBot>[
|
|
100
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TBot>>]: CommonHandlerProps<TBot> & {
|
|
101
|
+
message: IncomingMessages<TBot>[TMessageName];
|
|
102
102
|
user: client.User;
|
|
103
103
|
conversation: client.Conversation;
|
|
104
104
|
event: client.Event;
|
|
105
105
|
states: {
|
|
106
|
-
[TState in
|
|
106
|
+
[TState in utils.StringKeys<TBot['states']>]: {
|
|
107
107
|
type: 'user' | 'conversation' | 'bot';
|
|
108
108
|
payload: TBot['states'][TState];
|
|
109
109
|
};
|
|
@@ -111,32 +111,32 @@ export type MessagePayloads<TBot extends common.BaseBot> = {
|
|
|
111
111
|
};
|
|
112
112
|
};
|
|
113
113
|
export type MessageHandlers<TBot extends common.BaseBot> = {
|
|
114
|
-
[
|
|
114
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TBot>>]: (args: MessagePayloads<TBot>[TMessageName]) => Promise<void>;
|
|
115
115
|
};
|
|
116
116
|
export type EventPayloads<TBot extends common.BaseBot> = {
|
|
117
|
-
[
|
|
118
|
-
event: IncomingEvents<TBot>[
|
|
117
|
+
[TEventName in utils.StringKeys<IncomingEvents<TBot>>]: CommonHandlerProps<TBot> & {
|
|
118
|
+
event: IncomingEvents<TBot>[TEventName];
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
121
|
export type EventHandlers<TBot extends common.BaseBot> = {
|
|
122
|
-
[
|
|
122
|
+
[TEventName in utils.StringKeys<IncomingEvents<TBot>>]: (args: EventPayloads<TBot>[TEventName]) => Promise<void>;
|
|
123
123
|
};
|
|
124
124
|
export type StateExpiredPayloads<TBot extends common.BaseBot> = {
|
|
125
|
-
[
|
|
126
|
-
state: IncomingStates<TBot>[
|
|
125
|
+
[TSateName in utils.StringKeys<IncomingStates<TBot>>]: CommonHandlerProps<TBot> & {
|
|
126
|
+
state: IncomingStates<TBot>[TSateName];
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
129
|
export type StateExpiredHandlers<TBot extends common.BaseBot> = {
|
|
130
|
-
[
|
|
130
|
+
[TSateName in utils.StringKeys<IncomingStates<TBot>>]: (args: StateExpiredPayloads<TBot>[TSateName]) => Promise<void>;
|
|
131
131
|
};
|
|
132
132
|
export type ActionHandlerPayloads<TBot extends common.BaseBot> = {
|
|
133
|
-
[
|
|
134
|
-
type?:
|
|
135
|
-
input: TBot['actions'][
|
|
133
|
+
[TActionName in utils.StringKeys<TBot['actions']>]: CommonHandlerProps<TBot> & {
|
|
134
|
+
type?: TActionName;
|
|
135
|
+
input: TBot['actions'][TActionName]['input'];
|
|
136
136
|
};
|
|
137
137
|
};
|
|
138
138
|
export type ActionHandlers<TBot extends common.BaseBot> = {
|
|
139
|
-
[
|
|
139
|
+
[TActionName in utils.StringKeys<TBot['actions']>]: (props: ActionHandlerPayloads<TBot>[TActionName]) => Promise<TBot['actions'][TActionName]['output']>;
|
|
140
140
|
};
|
|
141
141
|
export type BridgeWorkflowUpdateType = 'child_workflow_deleted' | 'child_workflow_finished' | 'workflow_timedout' | 'workflow_started' | 'workflow_continued';
|
|
142
142
|
export type WorkflowUpdateEventPayload = {
|
|
@@ -150,6 +150,20 @@ export type WorkflowUpdateEvent = utils.Merge<client.Event, {
|
|
|
150
150
|
type: 'workflow_update';
|
|
151
151
|
payload: WorkflowUpdateEventPayload;
|
|
152
152
|
}>;
|
|
153
|
+
export type WorkflowPayloads<TBot extends common.BaseBot> = {
|
|
154
|
+
[TWorkflowName in utils.StringKeys<TBot['workflows']>]: CommonHandlerProps<TBot> & {
|
|
155
|
+
conversation?: client.Conversation;
|
|
156
|
+
user?: client.User;
|
|
157
|
+
/**
|
|
158
|
+
* # EXPERIMENTAL
|
|
159
|
+
* This API is experimental and may change in the future.
|
|
160
|
+
*/
|
|
161
|
+
workflow: workflowProxy.WorkflowWithUtilities<TBot, TWorkflowName>;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
export type WorkflowHandlers<TBot extends common.BaseBot> = {
|
|
165
|
+
[TWorkflowName in utils.StringKeys<TBot['workflows']>]: (props: WorkflowPayloads<TBot>[TWorkflowName]) => Promise<void>;
|
|
166
|
+
};
|
|
153
167
|
type BaseHookDefinition = {
|
|
154
168
|
stoppable?: boolean;
|
|
155
169
|
data: any;
|
|
@@ -215,69 +229,83 @@ export type HookDefinitions<TBot extends common.BaseBot> = {
|
|
|
215
229
|
}>;
|
|
216
230
|
};
|
|
217
231
|
export type HookData<TBot extends common.BaseBot> = {
|
|
218
|
-
[
|
|
219
|
-
[
|
|
232
|
+
[THookType in utils.StringKeys<HookDefinitions<TBot>>]: {
|
|
233
|
+
[THookDataName in utils.StringKeys<HookDefinitions<TBot>[THookType]['data']>]: HookDefinitions<TBot>[THookType]['data'][THookDataName];
|
|
220
234
|
};
|
|
221
235
|
};
|
|
222
236
|
export type HookInputs<TBot extends common.BaseBot> = {
|
|
223
|
-
[
|
|
224
|
-
[
|
|
225
|
-
data: HookData<TBot>[
|
|
237
|
+
[THookType in utils.StringKeys<HookData<TBot>>]: {
|
|
238
|
+
[THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]: CommonHandlerProps<TBot> & {
|
|
239
|
+
data: HookData<TBot>[THookType][THookDataName];
|
|
226
240
|
};
|
|
227
241
|
};
|
|
228
242
|
};
|
|
229
243
|
export type HookOutputs<TBot extends common.BaseBot> = {
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
data?: HookData<TBot>[
|
|
233
|
-
} & (HookDefinitions<TBot>[
|
|
244
|
+
[THookType in utils.StringKeys<HookData<TBot>>]: {
|
|
245
|
+
[THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]: {
|
|
246
|
+
data?: HookData<TBot>[THookType][THookDataName];
|
|
247
|
+
} & (HookDefinitions<TBot>[THookType]['stoppable'] extends true ? {
|
|
234
248
|
stop?: boolean;
|
|
235
249
|
} : {});
|
|
236
250
|
};
|
|
237
251
|
};
|
|
238
252
|
export type HookHandlers<TBot extends common.BaseBot> = {
|
|
239
|
-
[
|
|
240
|
-
[
|
|
253
|
+
[THookType in utils.StringKeys<HookData<TBot>>]: {
|
|
254
|
+
[THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]: (input: HookInputs<TBot>[THookType][THookDataName]) => Promise<HookOutputs<TBot>[THookType][THookDataName] | undefined>;
|
|
241
255
|
};
|
|
242
256
|
};
|
|
243
257
|
export type MessageHandlersMap<TBot extends common.BaseBot> = {
|
|
244
|
-
[
|
|
258
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TBot>>]?: MessageHandlers<TBot>[TMessageName][];
|
|
245
259
|
};
|
|
246
260
|
export type EventHandlersMap<TBot extends common.BaseBot> = {
|
|
247
|
-
[
|
|
261
|
+
[TEventName in utils.StringKeys<IncomingEvents<TBot>>]?: EventHandlers<TBot>[TEventName][];
|
|
248
262
|
};
|
|
249
263
|
export type StateExpiredHandlersMap<TBot extends common.BaseBot> = {
|
|
250
|
-
[
|
|
264
|
+
[TStateName in utils.StringKeys<IncomingStates<TBot>>]?: StateExpiredHandlers<TBot>[TStateName][];
|
|
251
265
|
};
|
|
252
266
|
export type HookHandlersMap<TBot extends common.BaseBot> = {
|
|
253
|
-
[
|
|
254
|
-
[
|
|
267
|
+
[THookType in utils.StringKeys<HookData<TBot>>]: {
|
|
268
|
+
[THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]?: HookHandlers<TBot>[THookType][THookDataName][];
|
|
255
269
|
};
|
|
256
270
|
};
|
|
257
|
-
export type
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
* # EXPERIMENTAL
|
|
263
|
-
* This API is experimental and may change in the future.
|
|
264
|
-
*/
|
|
265
|
-
workflow: workflowProxy.WorkflowWithUtilities<TBot, WorkflowName>;
|
|
266
|
-
} & TExtraTools;
|
|
267
|
-
};
|
|
268
|
-
export type WorkflowHandlers<TBot extends common.BaseBot, TExtraTools extends object = {}> = {
|
|
269
|
-
[K in utils.StringKeys<TBot['workflows']>]: (props: WorkflowPayloads<TBot, TExtraTools>[K]) => Promise<void>;
|
|
271
|
+
export type WorkflowUpdateType = 'started' | 'continued' | 'timed_out';
|
|
272
|
+
export type WorkflowHandlersMap<TBot extends common.BaseBot> = {
|
|
273
|
+
[TWorkflowUpdateType in WorkflowUpdateType]: {
|
|
274
|
+
[TWorkflowName in utils.StringKeys<TBot['workflows']>]?: WorkflowHandlers<TBot>[TWorkflowName][];
|
|
275
|
+
};
|
|
270
276
|
};
|
|
271
|
-
export type
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
export type OrderedMessageHandlersMap<TBot extends common.BaseBot> = {
|
|
278
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TBot>>]?: {
|
|
279
|
+
handler: MessageHandlers<TBot>[TMessageName];
|
|
280
|
+
order: number;
|
|
281
|
+
}[];
|
|
282
|
+
};
|
|
283
|
+
export type OrderedEventHandlersMap<TBot extends common.BaseBot> = {
|
|
284
|
+
[TEventName in utils.StringKeys<IncomingEvents<TBot>>]?: {
|
|
285
|
+
handler: EventHandlers<TBot>[TEventName];
|
|
286
|
+
order: number;
|
|
287
|
+
}[];
|
|
288
|
+
};
|
|
289
|
+
export type OrderedStateExpiredHandlersMap<TBot extends common.BaseBot> = {
|
|
290
|
+
[TStateName in utils.StringKeys<IncomingStates<TBot>>]?: {
|
|
291
|
+
handler: StateExpiredHandlers<TBot>[TStateName];
|
|
292
|
+
order: number;
|
|
293
|
+
}[];
|
|
294
|
+
};
|
|
295
|
+
export type OrderedHookHandlersMap<TBot extends common.BaseBot> = {
|
|
296
|
+
[THookType in utils.StringKeys<HookData<TBot>>]: {
|
|
297
|
+
[THookDataName in utils.StringKeys<HookData<TBot>[THookType]>]?: {
|
|
298
|
+
handler: HookHandlers<TBot>[THookType][THookDataName];
|
|
299
|
+
order: number;
|
|
300
|
+
}[];
|
|
276
301
|
};
|
|
277
302
|
};
|
|
278
|
-
export type
|
|
279
|
-
[
|
|
280
|
-
[
|
|
303
|
+
export type OrderedWorkflowHandlersMap<TBot extends common.BaseBot> = {
|
|
304
|
+
[TWorkflowUpdateType in WorkflowUpdateType]: {
|
|
305
|
+
[TWorkflowName in utils.StringKeys<TBot['workflows']>]?: {
|
|
306
|
+
handler: WorkflowHandlers<TBot>[TWorkflowName];
|
|
307
|
+
order: number;
|
|
308
|
+
}[];
|
|
281
309
|
};
|
|
282
310
|
};
|
|
283
311
|
/**
|
|
@@ -295,16 +323,16 @@ export type BotHandlers<TBot extends common.BaseBot> = {
|
|
|
295
323
|
};
|
|
296
324
|
type _GetPluginPrefix<TKey extends string, TPlugin extends plugin.BasePlugin> = TKey extends TPlugin['name'] ? '' : `${TKey}#`;
|
|
297
325
|
type ImplementedActions<_TBot extends common.BaseBot, TPlugins extends Record<string, plugin.BasePlugin>> = utils.UnionToIntersection<utils.ValueOf<{
|
|
298
|
-
[TPlugin in
|
|
299
|
-
[TAction in
|
|
326
|
+
[TPlugin in utils.StringKeys<TPlugins>]: {
|
|
327
|
+
[TAction in utils.StringKeys<TPlugins[TPlugin]['actions']> as `${_GetPluginPrefix<utils.Cast<TPlugin, string>, TPlugins[TPlugin]>}${utils.Cast<TAction, string>}`]: TPlugins[TPlugin]['actions'][TAction];
|
|
300
328
|
};
|
|
301
329
|
}>>;
|
|
302
|
-
type UnimplementedActions<TBot extends common.BaseBot, TPlugins extends Record<string, plugin.BasePlugin>> = Omit<TBot['actions'],
|
|
330
|
+
type UnimplementedActions<TBot extends common.BaseBot, TPlugins extends Record<string, plugin.BasePlugin>> = Omit<TBot['actions'], utils.StringKeys<ImplementedActions<TBot, TPlugins>>>;
|
|
303
331
|
export type ImplementedActionHandlers<TBot extends common.BaseBot, TPlugins extends Record<string, plugin.BasePlugin>> = {
|
|
304
|
-
[K in
|
|
332
|
+
[K in utils.StringKeys<ImplementedActions<TBot, TPlugins>>]: ActionHandlers<TBot>[utils.Cast<K, keyof ActionHandlers<TBot>>];
|
|
305
333
|
};
|
|
306
334
|
export type UnimplementedActionHandlers<TBot extends common.BaseBot, TPlugins extends Record<string, plugin.BasePlugin>> = {
|
|
307
|
-
[K in
|
|
335
|
+
[K in utils.StringKeys<UnimplementedActions<TBot, TPlugins>>]: ActionHandlers<TBot>[utils.Cast<K, keyof ActionHandlers<TBot>>];
|
|
308
336
|
};
|
|
309
337
|
export type ServerProps = Omit<CommonHandlerProps<common.BaseBot>, 'workflows'> & {
|
|
310
338
|
req: Request;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Response } from '../../../serve';
|
|
2
2
|
import * as types from '../types';
|
|
3
|
-
export declare const handleWorkflowUpdateEvent: (
|
|
3
|
+
export declare const handleWorkflowUpdateEvent: (rawProps: types.ServerProps, event: types.WorkflowUpdateEvent) => Promise<Response>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import * as types from '../types';
|
|
2
|
-
export declare const bridgeUpdateTypeToSnakeCase: (updateType: types.BridgeWorkflowUpdateType) => types.
|
|
3
|
-
export declare const camelCaseUpdateTypeToSnakeCase: (updateType: types.WorkflowUpdateTypeCamelCase) => types.WorkflowUpdateTypeSnakeCase;
|
|
2
|
+
export declare const bridgeUpdateTypeToSnakeCase: (updateType: types.BridgeWorkflowUpdateType) => types.WorkflowUpdateType;
|