@botpress/sdk 3.5.0 → 3.5.1

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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @botpress/sdk@3.5.0 build /home/runner/work/botpress/botpress/packages/sdk
2
+ > @botpress/sdk@3.5.1 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.5.0 build:type /home/runner/work/botpress/botpress/packages/sdk
6
+ > @botpress/sdk@3.5.1 build:type /home/runner/work/botpress/botpress/packages/sdk
7
7
  > tsc --emitDeclarationOnly --declaration
8
8
 
9
9
 
10
- > @botpress/sdk@3.5.0 build:node /home/runner/work/botpress/botpress/packages/sdk
10
+ > @botpress/sdk@3.5.1 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.5.0 build:browser /home/runner/work/botpress/botpress/packages/sdk
15
+ > @botpress/sdk@3.5.1 build:browser /home/runner/work/botpress/botpress/packages/sdk
16
16
  > ts-node -T ./build.ts --browser
17
17
 
18
18
  Done
@@ -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 { type MessageHandlersMap, type MessageHandlers, type EventHandlersMap, type EventHandlers, type StateExpiredHandlersMap, type StateExpiredHandlers, type HookHandlersMap, type HookData, type HookHandlers, type ActionHandlers, type BotHandlers, type UnimplementedActionHandlers, type WorkflowHandlersMap, type WorkflowHandlersFnMap } from './server';
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 keyof TPlugins]: PluginImplementation<TPlugins[K]>;
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 keyof MessageHandlersMap<TBot>>(type: T, handler: MessageHandlers<TBot>[T]) => void;
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
- workflows: WorkflowHandlersFnMap<TBot>;
34
- event: <T extends keyof EventHandlersMap<TBot>>(type: T, handler: EventHandlers<TBot>[T]) => void;
35
- stateExpired: <T extends keyof StateExpiredHandlersMap<TBot>>(type: T, handler: StateExpiredHandlers<TBot>[T]) => void;
36
- beforeIncomingEvent: <T extends keyof HookData<TBot>["before_incoming_event"]>(type: T, handler: HookHandlers<TBot>["before_incoming_event"][T]) => void;
37
- beforeIncomingMessage: <T extends keyof HookData<TBot>["before_incoming_message"]>(type: T, handler: HookHandlers<TBot>["before_incoming_message"][T]) => void;
38
- beforeOutgoingMessage: <T extends keyof HookData<TBot>["before_outgoing_message"]>(type: T, handler: HookHandlers<TBot>["before_outgoing_message"][T]) => void;
39
- beforeOutgoingCallAction: <T extends keyof HookData<TBot>["before_outgoing_call_action"]>(type: T, handler: HookHandlers<TBot>["before_outgoing_call_action"][T]) => void;
40
- afterIncomingEvent: <T extends keyof HookData<TBot>["after_incoming_event"]>(type: T, handler: HookHandlers<TBot>["after_incoming_event"][T]) => void;
41
- afterIncomingMessage: <T extends keyof HookData<TBot>["after_incoming_message"]>(type: T, handler: HookHandlers<TBot>["after_incoming_message"][T]) => void;
42
- afterOutgoingMessage: <T extends keyof HookData<TBot>["after_outgoing_message"]>(type: T, handler: HookHandlers<TBot>["after_outgoing_message"][T]) => void;
43
- afterOutgoingCallAction: <T extends keyof HookData<TBot>["after_outgoing_call_action"]>(type: T, handler: HookHandlers<TBot>["after_outgoing_call_action"][T]) => void;
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 keyof common.EnumerateEvents<TBot>]: utils.Merge<client.Event, {
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 keyof common.GetMessages<TBot>]: utils.Merge<client.Message, {
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 keyof common.EnumerateStates<TBot>]: utils.Merge<client.State, {
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 keyof common.GetMessages<TBot>]: utils.Merge<client.ClientInputs['createMessage'], {
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 keyof common.GetMessages<TBot>]: utils.Merge<client.ClientOutputs['createMessage'], {
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 keyof common.EnumerateActionInputs<TBot>]: utils.Merge<client.ClientInputs['callAction'], {
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 keyof common.EnumerateActionOutputs<TBot>]: utils.Merge<client.ClientOutputs['callAction'], {
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
- [K in keyof IncomingMessages<TBot>]: CommonHandlerProps<TBot> & {
101
- message: IncomingMessages<TBot>[K];
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 keyof TBot['states']]: {
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
- [K in keyof IncomingMessages<TBot>]: (args: MessagePayloads<TBot>[K]) => Promise<void>;
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
- [K in keyof IncomingEvents<TBot>]: CommonHandlerProps<TBot> & {
118
- event: IncomingEvents<TBot>[K];
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
- [K in keyof IncomingEvents<TBot>]: (args: EventPayloads<TBot>[K]) => Promise<void>;
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
- [K in keyof IncomingStates<TBot>]: CommonHandlerProps<TBot> & {
126
- state: IncomingStates<TBot>[K];
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
- [K in keyof IncomingStates<TBot>]: (args: StateExpiredPayloads<TBot>[K]) => Promise<void>;
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
- [K in keyof TBot['actions']]: CommonHandlerProps<TBot> & {
134
- type?: K;
135
- input: TBot['actions'][K]['input'];
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
- [K in keyof TBot['actions']]: (props: ActionHandlerPayloads<TBot>[K]) => Promise<TBot['actions'][K]['output']>;
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
- [H in keyof HookDefinitions<TBot>]: {
219
- [T in keyof HookDefinitions<TBot>[H]['data']]: HookDefinitions<TBot>[H]['data'][T];
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
- [H in keyof HookData<TBot>]: {
224
- [T in keyof HookData<TBot>[H]]: CommonHandlerProps<TBot> & {
225
- data: HookData<TBot>[H][T];
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
- [H in keyof HookData<TBot>]: {
231
- [T in keyof HookData<TBot>[H]]: {
232
- data?: HookData<TBot>[H][T];
233
- } & (HookDefinitions<TBot>[H]['stoppable'] extends true ? {
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
- [H in keyof HookData<TBot>]: {
240
- [T in keyof HookData<TBot>[H]]: (input: HookInputs<TBot>[H][T]) => Promise<HookOutputs<TBot>[H][T] | undefined>;
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
- [T in keyof IncomingMessages<TBot>]?: MessageHandlers<TBot>[T][];
258
+ [TMessageName in utils.StringKeys<IncomingMessages<TBot>>]?: MessageHandlers<TBot>[TMessageName][];
245
259
  };
246
260
  export type EventHandlersMap<TBot extends common.BaseBot> = {
247
- [T in keyof IncomingEvents<TBot>]?: EventHandlers<TBot>[T][];
261
+ [TEventName in utils.StringKeys<IncomingEvents<TBot>>]?: EventHandlers<TBot>[TEventName][];
248
262
  };
249
263
  export type StateExpiredHandlersMap<TBot extends common.BaseBot> = {
250
- [T in keyof IncomingStates<TBot>]?: StateExpiredHandlers<TBot>[T][];
264
+ [TStateName in utils.StringKeys<IncomingStates<TBot>>]?: StateExpiredHandlers<TBot>[TStateName][];
251
265
  };
252
266
  export type HookHandlersMap<TBot extends common.BaseBot> = {
253
- [H in keyof HookData<TBot>]: {
254
- [T in keyof HookData<TBot>[H]]?: HookHandlers<TBot>[H][T][];
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 WorkflowPayloads<TBot extends common.BaseBot, TExtraTools extends object = {}> = {
258
- [WorkflowName in utils.StringKeys<TBot['workflows']>]: CommonHandlerProps<TBot> & {
259
- conversation?: client.Conversation;
260
- user?: client.User;
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 WorkflowUpdateTypeSnakeCase = 'started' | 'continued' | 'timed_out';
272
- export type WorkflowUpdateTypeCamelCase = 'started' | 'continued' | 'timedOut';
273
- export type WorkflowHandlersMap<TBot extends common.BaseBot, TExtraTools extends object = {}> = {
274
- [UpdateType in WorkflowUpdateTypeSnakeCase]?: {
275
- [WorkflowName in utils.StringKeys<TBot['workflows']>]?: WorkflowHandlers<TBot, TExtraTools>[WorkflowName][];
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 WorkflowHandlersFnMap<TBot extends common.BaseBot, TExtraTools extends object = {}> = {
279
- [WorkflowName in utils.StringKeys<TBot['workflows']>]: {
280
- [UType in WorkflowUpdateTypeCamelCase]: (handler: WorkflowHandlers<TBot, TExtraTools>[WorkflowName]) => void;
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 keyof TPlugins]: {
299
- [TAction in keyof TPlugins[TPlugin]['actions'] as `${_GetPluginPrefix<utils.Cast<TPlugin, string>, TPlugins[TPlugin]>}${utils.Cast<TAction, string>}`]: TPlugins[TPlugin]['actions'][TAction];
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'], keyof ImplementedActions<TBot, TPlugins>>;
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 keyof ImplementedActions<TBot, TPlugins>]: ActionHandlers<TBot>[utils.Cast<K, keyof ActionHandlers<TBot>>];
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 keyof UnimplementedActions<TBot, TPlugins>]: ActionHandlers<TBot>[utils.Cast<K, keyof ActionHandlers<TBot>>];
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,2 @@
1
1
  import * as types from '../types';
2
- export declare const bridgeUpdateTypeToSnakeCase: (updateType: types.BridgeWorkflowUpdateType) => types.WorkflowUpdateTypeSnakeCase;
3
- export declare const camelCaseUpdateTypeToSnakeCase: (updateType: types.WorkflowUpdateTypeCamelCase) => types.WorkflowUpdateTypeSnakeCase;
2
+ export declare const bridgeUpdateTypeToSnakeCase: (updateType: types.BridgeWorkflowUpdateType) => types.WorkflowUpdateType;