@botpress/sdk 4.15.10 → 4.15.12
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 +5 -5
- package/dist/bot/definition.d.ts +4 -0
- package/dist/bot/implementation.d.ts +8 -8
- package/dist/bot/server/types.d.ts +49 -13
- package/dist/bot/workflow-proxy/proxy.d.ts +1 -0
- package/dist/bot/workflow-proxy/types.d.ts +3 -1
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +4 -4
- package/dist/integration/definition/index.d.ts +1 -0
- package/dist/interface/definition.d.ts +4 -0
- package/dist/plugin/definition.d.ts +4 -0
- package/dist/plugin/implementation.d.ts +2 -2
- package/dist/plugin/server/types.d.ts +48 -13
- package/package.json +1 -1
|
@@ -52,6 +52,9 @@ export type InterfaceDefinitionProps<TName extends string = string, TVersion ext
|
|
|
52
52
|
channels?: {
|
|
53
53
|
[K in keyof TChannels]: GenericChannelDefinition<TEntities, TChannels[K]>;
|
|
54
54
|
};
|
|
55
|
+
__advanced?: {
|
|
56
|
+
useLegacyZuiTransformer?: boolean;
|
|
57
|
+
};
|
|
55
58
|
};
|
|
56
59
|
export declare class InterfaceDefinition<TName extends string = string, TVersion extends string = string, TEntities extends BaseEntities = BaseEntities, TActions extends BaseActions = BaseActions, TEvents extends BaseEvents = BaseEvents, TChannels extends BaseChannels = BaseChannels> {
|
|
57
60
|
readonly props: InterfaceDefinitionProps<TName, TVersion, TEntities, TActions, TEvents, TChannels>;
|
|
@@ -74,6 +77,7 @@ export declare class InterfaceDefinition<TName extends string = string, TVersion
|
|
|
74
77
|
readonly channels: {
|
|
75
78
|
[K in keyof TChannels]: ChannelDefinition<TChannels[K]>;
|
|
76
79
|
};
|
|
80
|
+
readonly __advanced: this['props']['__advanced'];
|
|
77
81
|
constructor(props: InterfaceDefinitionProps<TName, TVersion, TEntities, TActions, TEvents, TChannels>);
|
|
78
82
|
private _getEntityReference;
|
|
79
83
|
}
|
|
@@ -93,6 +93,9 @@ export type PluginDefinitionProps<TName extends string = string, TVersion extend
|
|
|
93
93
|
workflows?: {
|
|
94
94
|
[K in keyof TWorkflows]: WorkflowDefinition<TWorkflows[K]>;
|
|
95
95
|
};
|
|
96
|
+
__advanced?: {
|
|
97
|
+
useLegacyZuiTransformer?: boolean;
|
|
98
|
+
};
|
|
96
99
|
};
|
|
97
100
|
export declare class PluginDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables, TWorkflows extends BaseWorkflows = BaseWorkflows> {
|
|
98
101
|
readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>;
|
|
@@ -123,6 +126,7 @@ export declare class PluginDefinition<TName extends string = string, TVersion ex
|
|
|
123
126
|
[K in keyof TTables]: TableDefinition<TTables[K]>;
|
|
124
127
|
};
|
|
125
128
|
readonly workflows: this['props']['workflows'];
|
|
129
|
+
readonly __advanced: this['props']['__advanced'];
|
|
126
130
|
constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>);
|
|
127
131
|
/**
|
|
128
132
|
* Returns a copy of the plugin definition where all entity references are
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, WorkflowHandlersMap as BotWorkflowHandlersMap,
|
|
1
|
+
import type { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, WorkflowHandlersMap as BotWorkflowHandlersMap, ActionHandlersMap as BotActionHandlersMap, BotHandlers } from '../bot';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
3
|
import { BasePlugin, PluginRuntimeProps } from './common';
|
|
4
4
|
import { ActionHandlers, MessageHandlers, EventHandlers, StateExpiredHandlers, HookHandlers, WorkflowHandlers, MessageHandlersMap, EventHandlersMap, StateExpiredHandlersMap, HookHandlersMap, WorkflowHandlersMap } from './server/types';
|
|
@@ -19,7 +19,7 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
|
|
|
19
19
|
initialize(props: PluginRuntimeProps<TPlugin>): this;
|
|
20
20
|
private get _runtime();
|
|
21
21
|
private _getTools;
|
|
22
|
-
get actionHandlers():
|
|
22
|
+
get actionHandlers(): BotActionHandlersMap<TPlugin>;
|
|
23
23
|
get messageHandlers(): BotMessageHandlersMap<TPlugin>;
|
|
24
24
|
get eventHandlers(): BotEventHandlersMap<TPlugin>;
|
|
25
25
|
get stateExpiredHandlers(): BotStateExpiredHandlersMap<TPlugin>;
|
|
@@ -111,20 +111,23 @@ export type CommonHandlerProps<TPlugin extends common.BasePlugin> = {
|
|
|
111
111
|
ctx: bot.BotContext;
|
|
112
112
|
logger: bot.BotLogger;
|
|
113
113
|
client: PluginClient<TPlugin>;
|
|
114
|
+
};
|
|
115
|
+
export type InjectedHandlerProps<TPlugin extends common.BasePlugin> = {
|
|
114
116
|
configuration: common.PluginConfiguration<TPlugin>;
|
|
115
117
|
interfaces: common.PluginInterfaceExtensions<TPlugin>;
|
|
118
|
+
alias?: string;
|
|
116
119
|
actions: actionProxy.ActionProxy<TPlugin>;
|
|
117
120
|
states: stateProxy.StateProxy<TPlugin>;
|
|
118
121
|
events: eventProxy.EventProxy<TPlugin>;
|
|
119
|
-
alias?: string;
|
|
120
122
|
/**
|
|
121
123
|
* # EXPERIMENTAL
|
|
122
124
|
* This API is experimental and may change in the future.
|
|
123
125
|
*/
|
|
124
126
|
workflows: workflowProxy.WorkflowProxy<TPlugin>;
|
|
125
127
|
};
|
|
128
|
+
export type ExtendedHandlerProps<TPlugin extends common.BasePlugin> = CommonHandlerProps<TPlugin> & InjectedHandlerProps<TPlugin>;
|
|
126
129
|
export type MessagePayloads<TPlugin extends common.BasePlugin> = {
|
|
127
|
-
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]:
|
|
130
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]: ExtendedHandlerProps<TPlugin> & {
|
|
128
131
|
message: IncomingMessages<TPlugin>[TMessageName];
|
|
129
132
|
user: client.User;
|
|
130
133
|
conversation: client.Conversation;
|
|
@@ -135,7 +138,7 @@ export type MessageHandlers<TPlugin extends common.BasePlugin> = {
|
|
|
135
138
|
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]: (args: MessagePayloads<TPlugin>[TMessageName]) => Promise<void>;
|
|
136
139
|
};
|
|
137
140
|
export type EventPayloads<TPlugin extends common.BasePlugin> = {
|
|
138
|
-
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]:
|
|
141
|
+
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]: ExtendedHandlerProps<TPlugin> & {
|
|
139
142
|
event: IncomingEvents<TPlugin>[TEventName];
|
|
140
143
|
};
|
|
141
144
|
};
|
|
@@ -143,7 +146,7 @@ export type EventHandlers<TPlugin extends common.BasePlugin> = {
|
|
|
143
146
|
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]: (args: EventPayloads<TPlugin>[TEventName]) => Promise<void>;
|
|
144
147
|
};
|
|
145
148
|
export type StateExpiredPayloads<TPlugin extends common.BasePlugin> = {
|
|
146
|
-
[TSateName in utils.StringKeys<IncomingStates<TPlugin>>]:
|
|
149
|
+
[TSateName in utils.StringKeys<IncomingStates<TPlugin>>]: ExtendedHandlerProps<TPlugin> & {
|
|
147
150
|
state: IncomingStates<TPlugin>[TSateName];
|
|
148
151
|
};
|
|
149
152
|
};
|
|
@@ -151,7 +154,7 @@ export type StateExpiredHandlers<TPlugin extends common.BasePlugin> = {
|
|
|
151
154
|
[TSateName in utils.StringKeys<IncomingStates<TPlugin>>]: (args: StateExpiredPayloads<TPlugin>[TSateName]) => Promise<void>;
|
|
152
155
|
};
|
|
153
156
|
export type ActionHandlerPayloads<TPlugin extends common.BasePlugin> = {
|
|
154
|
-
[TActionName in utils.StringKeys<TPlugin['actions']>]:
|
|
157
|
+
[TActionName in utils.StringKeys<TPlugin['actions']>]: ExtendedHandlerProps<TPlugin> & {
|
|
155
158
|
type?: TActionName;
|
|
156
159
|
input: TPlugin['actions'][TActionName]['input'];
|
|
157
160
|
};
|
|
@@ -160,7 +163,7 @@ export type ActionHandlers<TPlugin extends common.BasePlugin> = {
|
|
|
160
163
|
[TActionName in utils.StringKeys<TPlugin['actions']>]: (props: ActionHandlerPayloads<TPlugin>[TActionName]) => Promise<TPlugin['actions'][TActionName]['output']>;
|
|
161
164
|
};
|
|
162
165
|
export type WorkflowPayloads<TPlugin extends common.BasePlugin> = {
|
|
163
|
-
[TWorkflowName in utils.StringKeys<TPlugin['workflows']>]:
|
|
166
|
+
[TWorkflowName in utils.StringKeys<TPlugin['workflows']>]: ExtendedHandlerProps<TPlugin> & {
|
|
164
167
|
conversation?: client.Conversation;
|
|
165
168
|
user?: client.User;
|
|
166
169
|
event: bot.WorkflowUpdateEvent;
|
|
@@ -258,7 +261,7 @@ export type HookData<TPlugin extends common.BasePlugin> = {
|
|
|
258
261
|
};
|
|
259
262
|
export type HookInputs<TPlugin extends common.BasePlugin> = {
|
|
260
263
|
[THookType in utils.StringKeys<HookData<TPlugin>>]: {
|
|
261
|
-
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]:
|
|
264
|
+
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]: ExtendedHandlerProps<TPlugin> & {
|
|
262
265
|
data: HookData<TPlugin>[THookType][THookDataName];
|
|
263
266
|
};
|
|
264
267
|
};
|
|
@@ -277,24 +280,29 @@ export type HookHandlers<TPlugin extends common.BasePlugin> = {
|
|
|
277
280
|
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]: (input: HookInputs<TPlugin>[THookType][THookDataName]) => Promise<HookOutputs<TPlugin>[THookType][THookDataName] | undefined>;
|
|
278
281
|
};
|
|
279
282
|
};
|
|
283
|
+
export type ActionHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
284
|
+
[TActionName in utils.StringKeys<TPlugin['actions']>]?: (props: Omit<Parameters<ActionHandlers<TPlugin>[TActionName]>[0], keyof InjectedHandlerProps<TPlugin>>) => Promise<Awaited<ReturnType<ActionHandlers<TPlugin>[TActionName]>>>;
|
|
285
|
+
};
|
|
280
286
|
export type MessageHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
281
|
-
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]?: MessageHandlers<TPlugin>[TMessageName][];
|
|
287
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]?: ((props: Omit<Parameters<MessageHandlers<TPlugin>[TMessageName]>[0], keyof InjectedHandlerProps<TPlugin>>) => Promise<void>)[];
|
|
282
288
|
};
|
|
283
289
|
export type EventHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
284
|
-
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]?: EventHandlers<TPlugin>[TEventName][];
|
|
290
|
+
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]?: ((props: Omit<Parameters<EventHandlers<TPlugin>[TEventName]>[0], keyof InjectedHandlerProps<TPlugin>>) => Promise<void>)[];
|
|
285
291
|
};
|
|
286
292
|
export type StateExpiredHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
287
|
-
[TStateName in utils.StringKeys<IncomingStates<TPlugin>>]?: StateExpiredHandlers<TPlugin>[TStateName][];
|
|
293
|
+
[TStateName in utils.StringKeys<IncomingStates<TPlugin>>]?: ((props: Omit<Parameters<StateExpiredHandlers<TPlugin>[TStateName]>[0], keyof InjectedHandlerProps<TPlugin>>) => Promise<void>)[];
|
|
288
294
|
};
|
|
289
295
|
export type HookHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
290
296
|
[THookType in utils.StringKeys<HookData<TPlugin>>]: {
|
|
291
|
-
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]?: HookHandlers<TPlugin>[THookType][THookDataName][];
|
|
297
|
+
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]?: ((props: Omit<Parameters<HookHandlers<TPlugin>[THookType][THookDataName]>[0], keyof InjectedHandlerProps<TPlugin>>) => Promise<Awaited<ReturnType<HookHandlers<TPlugin>[THookType][THookDataName]>>>)[];
|
|
292
298
|
};
|
|
293
299
|
};
|
|
294
300
|
export type WorkflowHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
295
301
|
[TWorkflowUpdateType in bot.WorkflowUpdateType]: {
|
|
296
302
|
[TWorkflowName in utils.StringKeys<TPlugin['workflows']>]?: {
|
|
297
|
-
handler: WorkflowHandlers<TPlugin>[TWorkflowName]
|
|
303
|
+
handler: (props: Omit<Parameters<WorkflowHandlers<TPlugin>[TWorkflowName]>[0], keyof InjectedHandlerProps<TPlugin> | 'workflow'> & {
|
|
304
|
+
workflow: client.Workflow;
|
|
305
|
+
}) => Promise<client.Workflow>;
|
|
298
306
|
order: number;
|
|
299
307
|
}[];
|
|
300
308
|
};
|
|
@@ -333,12 +341,39 @@ export type OrderedWorkflowHandlersMap<TPlugin extends common.BasePlugin> = {
|
|
|
333
341
|
}[];
|
|
334
342
|
};
|
|
335
343
|
};
|
|
344
|
+
/** Plugin handlers without InjectedHandlerProps */
|
|
336
345
|
export type PluginHandlers<TPlugin extends common.BasePlugin> = {
|
|
337
|
-
actionHandlers:
|
|
346
|
+
actionHandlers: ActionHandlersMap<TPlugin>;
|
|
338
347
|
messageHandlers: MessageHandlersMap<TPlugin>;
|
|
339
348
|
eventHandlers: EventHandlersMap<TPlugin>;
|
|
340
349
|
stateExpiredHandlers: StateExpiredHandlersMap<TPlugin>;
|
|
341
350
|
hookHandlers: HookHandlersMap<TPlugin>;
|
|
342
351
|
workflowHandlers: WorkflowHandlersMap<TPlugin>;
|
|
343
352
|
};
|
|
353
|
+
/** identical to PluginHandlers, but contains the injected properties */
|
|
354
|
+
export type InjectedPluginHandlers<TPlugin extends common.BasePlugin> = {
|
|
355
|
+
actionHandlers: ActionHandlers<TPlugin>;
|
|
356
|
+
messageHandlers: {
|
|
357
|
+
[TMessageName in utils.StringKeys<IncomingMessages<TPlugin>>]?: MessageHandlers<TPlugin>[TMessageName][];
|
|
358
|
+
};
|
|
359
|
+
eventHandlers: {
|
|
360
|
+
[TEventName in utils.StringKeys<IncomingEvents<TPlugin>>]?: EventHandlers<TPlugin>[TEventName][];
|
|
361
|
+
};
|
|
362
|
+
stateExpiredHandlers: {
|
|
363
|
+
[TStateName in utils.StringKeys<IncomingStates<TPlugin>>]?: StateExpiredHandlers<TPlugin>[TStateName][];
|
|
364
|
+
};
|
|
365
|
+
hookHandlers: {
|
|
366
|
+
[THookType in utils.StringKeys<HookData<TPlugin>>]: {
|
|
367
|
+
[THookDataName in utils.StringKeys<HookData<TPlugin>[THookType]>]?: HookHandlers<TPlugin>[THookType][THookDataName][];
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
workflowHandlers: {
|
|
371
|
+
[TWorkflowUpdateType in bot.WorkflowUpdateType]: {
|
|
372
|
+
[TWorkflowName in utils.StringKeys<TPlugin['workflows']>]?: {
|
|
373
|
+
handler: WorkflowHandlers<TPlugin>[TWorkflowName];
|
|
374
|
+
order: number;
|
|
375
|
+
}[];
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
};
|
|
344
379
|
export {};
|