@botpress/sdk 4.21.0 → 5.0.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.
Files changed (41) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/dist/bot/definition.d.ts +45 -7
  3. package/dist/bot/server/types.d.ts +2 -5
  4. package/dist/bot/workflow-proxy/proxy.d.ts +7 -3
  5. package/dist/bot/workflow-proxy/types.d.ts +24 -23
  6. package/dist/common/index.d.ts +1 -0
  7. package/dist/common/types.d.ts +2 -0
  8. package/dist/fixtures.d.ts +84 -13
  9. package/dist/index.cjs +41 -38
  10. package/dist/index.cjs.map +4 -4
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.mjs +39 -36
  13. package/dist/index.mjs.map +4 -4
  14. package/dist/integration/client/types.d.ts +15 -14
  15. package/dist/integration/common/index.d.ts +0 -1
  16. package/dist/integration/server/types.d.ts +8 -7
  17. package/dist/plugin/common/generic.d.ts +12 -0
  18. package/dist/plugin/common/types.d.ts +17 -5
  19. package/dist/plugin/conversation-proxy/index.d.ts +2 -0
  20. package/dist/plugin/conversation-proxy/proxy.d.ts +13 -0
  21. package/dist/plugin/conversation-proxy/types.d.ts +54 -0
  22. package/dist/plugin/conversation-proxy/types.test.d.ts +1 -0
  23. package/dist/plugin/definition.d.ts +1 -1
  24. package/dist/plugin/event-proxy/proxy.d.ts +2 -2
  25. package/dist/plugin/event-proxy/types.d.ts +11 -6
  26. package/dist/plugin/implementation.d.ts +4 -4
  27. package/dist/plugin/message-proxy/index.d.ts +2 -0
  28. package/dist/plugin/message-proxy/proxy.d.ts +13 -0
  29. package/dist/plugin/message-proxy/types.d.ts +22 -0
  30. package/dist/plugin/server/types.d.ts +129 -51
  31. package/dist/plugin/tag-prefixer.d.ts +10 -0
  32. package/dist/plugin/tag-prefixer.test.d.ts +1 -0
  33. package/dist/plugin/user-proxy/index.d.ts +2 -0
  34. package/dist/plugin/user-proxy/proxy.d.ts +14 -0
  35. package/dist/plugin/user-proxy/types.d.ts +30 -0
  36. package/dist/utils/api-paging-utils.d.ts +43 -0
  37. package/dist/utils/api-paging-utils.test.d.ts +1 -0
  38. package/dist/utils/type-utils.d.ts +1 -0
  39. package/package.json +2 -2
  40. package/dist/integration/common/types.d.ts +0 -2
  41. package/dist/plugin/interface-resolution.d.ts +0 -15
@@ -1,4 +1,5 @@
1
1
  import * as client from '@botpress/client';
2
+ import type { commonTypes } from '../../common';
2
3
  import * as utils from '../../utils/type-utils';
3
4
  import * as common from '../common';
4
5
  import { EnumerateMessages, ConversationTags, GetChannelByName, GetMessageByName, MessageTags } from './sub-types';
@@ -8,26 +9,26 @@ type ConversationResponse<TIntegration extends common.BaseIntegration, ChannelNa
8
9
  [TChannelName in ChannelName]: {
9
10
  conversation: utils.Merge<Awaited<Res<client.Client['getConversation']>>['conversation'], {
10
11
  channel: TChannelName;
11
- tags: common.ToTags<keyof TIntegration['channels'][TChannelName]['conversation']['tags']>;
12
+ tags: commonTypes.ToTags<keyof TIntegration['channels'][TChannelName]['conversation']['tags']>;
12
13
  }>;
13
14
  };
14
15
  }>;
15
16
  export type CreateConversation<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels']>(x: {
16
17
  channel: utils.Cast<ChannelName, string>;
17
- tags: common.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
18
+ tags: commonTypes.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
18
19
  }) => Promise<ConversationResponse<TIntegration, ChannelName>>;
19
20
  export type GetConversation<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getConversation']>) => Promise<ConversationResponse<TIntegration>>;
20
21
  export type ListConversations<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels']>(x: utils.Merge<Arg<client.Client['listConversations']>, {
21
22
  channel?: utils.Cast<ChannelName, string>;
22
- tags?: common.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
23
+ tags?: commonTypes.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
23
24
  }>) => Res<client.Client['listConversations']>;
24
25
  export type GetOrCreateConversation<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels'], TTags extends keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>(x: utils.Merge<Arg<client.Client['getOrCreateConversation']>, {
25
26
  channel: utils.Cast<ChannelName, string>;
26
- tags: common.ToTags<TTags>;
27
+ tags: commonTypes.ToTags<TTags>;
27
28
  discriminateByTags?: NoInfer<utils.Cast<TTags[], string[]>>;
28
29
  }>) => Promise<ConversationResponse<TIntegration, ChannelName>>;
29
30
  export type UpdateConversation<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateConversation']>, {
30
- tags?: common.ToTags<ConversationTags<TIntegration>>;
31
+ tags?: commonTypes.ToTags<ConversationTags<TIntegration>>;
31
32
  }>) => Promise<ConversationResponse<TIntegration>>;
32
33
  export type DeleteConversation<_TIntegration extends common.BaseIntegration> = client.Client['deleteConversation'];
33
34
  export type ListParticipants<_TIntegration extends common.BaseIntegration> = client.Client['listParticipants'];
@@ -56,40 +57,40 @@ type MessageResponse<TIntegration extends common.BaseIntegration, TMessage exten
56
57
  export type CreateMessage<TIntegration extends common.BaseIntegration> = <TMessage extends keyof EnumerateMessages<TIntegration>>(x: utils.Merge<Arg<client.Client['createMessage']>, {
57
58
  type: utils.Cast<TMessage, string>;
58
59
  payload: GetMessageByName<TIntegration, TMessage>['payload'];
59
- tags: common.ToTags<keyof GetMessageByName<TIntegration, TMessage>['tags']>;
60
+ tags: commonTypes.ToTags<keyof GetMessageByName<TIntegration, TMessage>['tags']>;
60
61
  }>) => Promise<MessageResponse<TIntegration, TMessage>>;
61
62
  export type GetOrCreateMessage<TIntegration extends common.BaseIntegration> = <TMessage extends keyof EnumerateMessages<TIntegration>, TTags extends keyof GetMessageByName<TIntegration, TMessage>['tags']>(x: utils.Merge<Arg<client.Client['getOrCreateMessage']>, {
62
63
  type: utils.Cast<TMessage, string>;
63
64
  payload: GetMessageByName<TIntegration, TMessage>['payload'];
64
- tags: common.ToTags<TTags>;
65
+ tags: commonTypes.ToTags<TTags>;
65
66
  discriminateByTags?: NoInfer<utils.Cast<TTags[], string[]>>;
66
67
  }>) => Promise<MessageResponse<TIntegration, TMessage>>;
67
68
  export type GetMessage<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getMessage']>) => Promise<MessageResponse<TIntegration>>;
68
69
  export type UpdateMessage<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateMessage']>, {
69
- tags: common.ToTags<MessageTags<TIntegration>>;
70
+ tags: commonTypes.ToTags<MessageTags<TIntegration>>;
70
71
  }>) => Promise<MessageResponse<TIntegration>>;
71
72
  export type ListMessages<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listMessages']>, {
72
- tags?: common.ToTags<MessageTags<TIntegration>>;
73
+ tags?: commonTypes.ToTags<MessageTags<TIntegration>>;
73
74
  }>) => Res<client.Client['listMessages']>;
74
75
  export type DeleteMessage<_TIntegration extends common.BaseIntegration> = client.Client['deleteMessage'];
75
76
  type UserResponse<TIntegration extends common.BaseIntegration> = {
76
77
  user: utils.Merge<Awaited<Res<client.Client['getUser']>>['user'], {
77
- tags: common.ToTags<keyof TIntegration['user']['tags']>;
78
+ tags: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
78
79
  }>;
79
80
  };
80
81
  export type CreateUser<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['createUser']>, {
81
- tags: common.ToTags<keyof TIntegration['user']['tags']>;
82
+ tags: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
82
83
  }>) => Promise<UserResponse<TIntegration>>;
83
84
  export type GetUser<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getUser']>) => Promise<UserResponse<TIntegration>>;
84
85
  export type ListUsers<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listUsers']>, {
85
- tags?: common.ToTags<keyof TIntegration['user']['tags']>;
86
+ tags?: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
86
87
  }>) => Res<client.Client['listUsers']>;
87
88
  export type GetOrCreateUser<TIntegration extends common.BaseIntegration> = <TTags extends keyof TIntegration['user']['tags']>(x: utils.Merge<Arg<client.Client['getOrCreateUser']>, {
88
- tags: common.ToTags<TTags>;
89
+ tags: commonTypes.ToTags<TTags>;
89
90
  discriminateByTags?: NoInfer<utils.Cast<TTags[], string[]>>;
90
91
  }>) => Promise<UserResponse<TIntegration>>;
91
92
  export type UpdateUser<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateUser']>, {
92
- tags?: common.ToTags<keyof TIntegration['user']['tags']>;
93
+ tags?: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
93
94
  }>) => Promise<UserResponse<TIntegration>>;
94
95
  export type DeleteUser<_TIntegration extends common.BaseIntegration> = client.Client['deleteUser'];
95
96
  type StateResponse<TIntegration extends common.BaseIntegration, TState extends keyof TIntegration['states']> = {
@@ -1,2 +1 @@
1
1
  export * from './generic';
2
- export * from './types';
@@ -1,8 +1,9 @@
1
1
  import { type Conversation, type Message, type User } from '@botpress/client';
2
+ import type { commonTypes } from '../../common';
2
3
  import { Request, Response } from '../../serve';
3
4
  import { Cast, Merge, ValueOf } from '../../utils/type-utils';
4
5
  import { IntegrationSpecificClient } from '../client';
5
- import { BaseIntegration, ToTags } from '../common';
6
+ import { BaseIntegration } from '../common';
6
7
  import { type IntegrationLogger } from './integration-logger';
7
8
  type IntegrationContextConfig<TIntegration extends BaseIntegration> = {
8
9
  configurationType: null;
@@ -54,13 +55,13 @@ export type ActionHandlers<TIntegration extends BaseIntegration> = {
54
55
  [ActionType in keyof TIntegration['actions']]: (props: ActionHandlerProps<TIntegration, Cast<ActionType, string>, TIntegration['actions'][ActionType]['input']>) => Promise<TIntegration['actions'][ActionType]['output']>;
55
56
  };
56
57
  export type CreateUserPayload<TIntegration extends BaseIntegration> = {
57
- tags: ToTags<keyof TIntegration['user']['tags']>;
58
+ tags: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
58
59
  };
59
60
  export type CreateUserHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & CreateUserPayload<TIntegration>;
60
61
  export type CreateUserHandler<TIntegration extends BaseIntegration> = (props: CreateUserHandlerProps<TIntegration>) => Promise<Response | void>;
61
62
  export type CreateConversationPayload<TIntegration extends BaseIntegration, TChannel extends keyof TIntegration['channels'] = keyof TIntegration['channels']> = {
62
63
  channel: TChannel;
63
- tags: ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
64
+ tags: commonTypes.ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
64
65
  };
65
66
  export type CreateConversationHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & CreateConversationPayload<TIntegration>;
66
67
  export type CreateConversationHandler<TIntegration extends BaseIntegration> = (props: CreateConversationHandlerProps<TIntegration>) => Promise<Response | void>;
@@ -69,18 +70,18 @@ export type MessagePayload<TIntegration extends BaseIntegration, TChannel extend
69
70
  payload: TIntegration['channels'][TChannel]['messages'][TMessage];
70
71
  conversation: Merge<Conversation, {
71
72
  channel: TChannel;
72
- tags: ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
73
+ tags: commonTypes.ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
73
74
  }>;
74
75
  message: Merge<Message, {
75
- tags: ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
76
+ tags: commonTypes.ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
76
77
  }>;
77
78
  user: Merge<User, {
78
- tags: ToTags<keyof TIntegration['user']['tags']>;
79
+ tags: commonTypes.ToTags<keyof TIntegration['user']['tags']>;
79
80
  }>;
80
81
  };
81
82
  export type MessageHandlerProps<TIntegration extends BaseIntegration, TChannel extends keyof TIntegration['channels'], TMessage extends keyof TIntegration['channels'][TChannel]['messages']> = CommonHandlerProps<TIntegration> & MessagePayload<TIntegration, TChannel, TMessage> & {
82
83
  ack: (props: {
83
- tags: ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
84
+ tags: commonTypes.ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
84
85
  }) => Promise<void>;
85
86
  };
86
87
  export type ChannelHandlers<TIntegration extends BaseIntegration> = {
@@ -31,6 +31,15 @@ export type BasePlugin = {
31
31
  actions: Record<string, BaseAction>;
32
32
  tables: Record<string, BaseTable>;
33
33
  workflows: Record<string, BaseWorkflow>;
34
+ conversation: {
35
+ tags: Record<string, any>;
36
+ };
37
+ user: {
38
+ tags: Record<string, any>;
39
+ };
40
+ message: {
41
+ tags: Record<string, any>;
42
+ };
34
43
  };
35
44
  export type InputBasePlugin = utils.DeepPartial<BasePlugin>;
36
45
  export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
@@ -48,4 +57,7 @@ export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
48
57
  interfaces: undefined extends B['interfaces'] ? BasePlugin['interfaces'] : {
49
58
  [K in keyof B['interfaces']]: DefaultInterface<utils.Cast<B['interfaces'][K], InputBaseInterface>>;
50
59
  };
60
+ conversation: utils.Default<B['conversation'], BasePlugin['conversation']>;
61
+ user: utils.Default<B['user'], BasePlugin['user']>;
62
+ message: utils.Default<B['message'], BasePlugin['message']>;
51
63
  };
@@ -1,6 +1,6 @@
1
- import { BaseInterface } from '../../interface';
2
- import { Cast, Join, UnionToIntersection } from '../../utils/type-utils';
3
- import { BasePlugin } from './generic';
1
+ import type { BaseInterface } from '../../interface';
2
+ import type { Cast, Join, UnionToIntersection } from '../../utils/type-utils';
3
+ import type { BasePlugin } from './generic';
4
4
  type EventKey<TIntegrationName extends string, TEventName extends string> = string extends TIntegrationName ? string : string extends TEventName ? string : Join<[TIntegrationName, ':', TEventName]>;
5
5
  export type EnumerateInterfaceEvents<TPlugin extends BasePlugin> = UnionToIntersection<{
6
6
  [TInterfaceName in keyof TPlugin['interfaces']]: {
@@ -14,6 +14,8 @@ export type PluginInterfaceExtension<TInterface extends BaseInterface = BaseInte
14
14
  id?: string;
15
15
  name: string;
16
16
  version: string;
17
+ integrationAlias: string;
18
+ integrationInterfaceAlias: string;
17
19
  entities: {
18
20
  [K in keyof TInterface['entities']]: {
19
21
  name: string;
@@ -35,13 +37,23 @@ export type PluginInterfaceExtension<TInterface extends BaseInterface = BaseInte
35
37
  };
36
38
  };
37
39
  };
40
+ export type PluginIntegrationExtension = {
41
+ id?: string;
42
+ name: string;
43
+ version: string;
44
+ integrationAlias: string;
45
+ };
38
46
  export type PluginInterfaceExtensions<TPlugin extends BasePlugin = BasePlugin> = {
39
- [K in keyof TPlugin['interfaces']]: PluginInterfaceExtension<TPlugin['interfaces'][K]>;
47
+ [TPluginInterfaceAlias in keyof TPlugin['interfaces']]: PluginInterfaceExtension<TPlugin['interfaces'][TPluginInterfaceAlias]>;
48
+ };
49
+ export type PluginIntegrationExtensions<TPlugin extends BasePlugin = BasePlugin> = {
50
+ [TPluginIntegrationAlias in keyof TPlugin['integrations']]: PluginIntegrationExtension;
40
51
  };
41
52
  export type PluginConfiguration<TPlugin extends BasePlugin> = TPlugin['configuration'];
42
53
  export type PluginRuntimeProps<TPlugin extends BasePlugin = BasePlugin> = {
43
- alias?: string;
54
+ alias: string;
44
55
  configuration: PluginConfiguration<TPlugin>;
45
56
  interfaces: PluginInterfaceExtensions<TPlugin>;
57
+ integrations: PluginIntegrationExtensions<TPlugin>;
46
58
  };
47
59
  export {};
@@ -0,0 +1,2 @@
1
+ export { proxyConversation, proxyConversations } from './proxy';
2
+ export { ActionableConversation, ConversationFinder } from './types';
@@ -0,0 +1,13 @@
1
+ import type * as client from '@botpress/client';
2
+ import type { BotSpecificClient } from '../../bot';
3
+ import type { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import type { ActionableConversation, ConversationFinder } from './types';
5
+ export declare const proxyConversations: <TPlugin extends BasePlugin>(props: {
6
+ client: BotSpecificClient<TPlugin> | client.Client;
7
+ plugin?: PluginRuntimeProps<TPlugin>;
8
+ }) => ConversationFinder<TPlugin>;
9
+ export declare const proxyConversation: <TPlugin extends BasePlugin>(props: {
10
+ client: BotSpecificClient<TPlugin> | client.Client;
11
+ plugin?: PluginRuntimeProps<TPlugin>;
12
+ conversation: client.Conversation;
13
+ }) => ActionableConversation<TPlugin>;
@@ -0,0 +1,54 @@
1
+ import type * as client from '@botpress/client';
2
+ import type { commonTypes } from '../../common';
3
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
4
+ import type * as typeUtils from '../../utils/type-utils';
5
+ import type { BasePlugin } from '../common';
6
+ import type * as messageProxy from '../message-proxy/types';
7
+ import type * as userProxy from '../user-proxy/types';
8
+ export type ConversationFinder<TPlugin extends BasePlugin> = _ConversationFinderForDepType<TPlugin, 'interfaces'> & _ConversationFinderForDepType<TPlugin, 'integrations'>;
9
+ type _ConversationFinderForDepType<TPlugin extends BasePlugin, TDepType extends 'interfaces' | 'integrations'> = {
10
+ [TAlias in typeUtils.StringKeys<TPlugin[TDepType]> | '*']: {
11
+ [TChannelName in TAlias extends '*' ? '*' : typeUtils.StringKeys<TPlugin[TDepType][TAlias]['channels']> | '*']: _ConversationFinderForChannel<TPlugin, TChannelName, _MessageForChannel<TPlugin, TDepType, TAlias extends '*' ? string : TAlias, TChannelName extends '*' ? string : TChannelName>>;
12
+ };
13
+ };
14
+ type _ConversationFinderForChannel<TPlugin extends BasePlugin, TChannelName extends string, TMessage extends client.Message> = {
15
+ list: (props?: typeUtils.Merge<Omit<client.ClientInputs['listConversations'], 'integrationName' | 'channel' | 'nextToken'>, {
16
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
17
+ }>) => AsyncCollection<ActionableConversation<TPlugin, TChannelName extends '*' ? string : TChannelName, TMessage>>;
18
+ getById: (props: {
19
+ id: string;
20
+ }) => Promise<ActionableConversation<TPlugin, TChannelName extends '*' ? string : TChannelName, TMessage>>;
21
+ };
22
+ type _MessageForChannel<TPlugin extends BasePlugin, TDepType extends 'interfaces' | 'integrations', TAlias extends keyof TPlugin[TDepType], TChannelName extends keyof TPlugin[TDepType][TAlias]['channels']> = _FallbackWhenNever<Omit<client.Message, 'type' | 'payload' | 'tags'> & typeUtils.ValueOf<{
23
+ [TMessageName in typeUtils.StringKeys<TPlugin[TDepType][TAlias]['channels'][TChannelName]['messages']>]: {
24
+ type: TMessageName;
25
+ payload: TPlugin[TDepType][TAlias]['channels'][TChannelName]['messages'][TMessageName];
26
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
27
+ };
28
+ }>, typeUtils.Merge<client.Message, {
29
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
30
+ }>>;
31
+ type _FallbackWhenNever<T, TFallback> = [T] extends [never] ? TFallback : T;
32
+ export type ActionableConversation<TPlugin extends BasePlugin, TChannelName extends string = string, TMessage extends client.Message = client.Message> = typeUtils.Merge<client.Conversation, {
33
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
34
+ channel: TChannelName;
35
+ }> & {
36
+ delete: () => Promise<void>;
37
+ update: (props: typeUtils.Merge<Omit<client.ClientInputs['updateConversation'], 'id'>, {
38
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
39
+ }>) => Promise<ActionableConversation<TPlugin>>;
40
+ getMessage: (props: {
41
+ id: string;
42
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
43
+ getOrCreateMessage: (props: Omit<client.ClientInputs['getOrCreateMessage'], 'conversationId' | 'tags' | 'type' | 'payload'> & typeUtils.DistributivePick<TMessage, 'type' | 'payload'> & {
44
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
45
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
46
+ createMessage: (props: Omit<client.ClientInputs['createMessage'], 'conversationId' | 'tags' | 'type' | 'payload'> & typeUtils.DistributivePick<TMessage, 'type' | 'payload'> & {
47
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
48
+ }) => Promise<messageProxy.ActionableMessage<TPlugin, TMessage>>;
49
+ listMessages: (props?: typeUtils.Merge<Omit<client.ClientInputs['listMessages'], 'conversationId' | 'nextToken'>, {
50
+ tags?: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
51
+ }>) => AsyncCollection<messageProxy.ActionableMessage<TPlugin, TMessage>>;
52
+ listParticipants: () => AsyncCollection<userProxy.ActionableUser<TPlugin, string>>;
53
+ };
54
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,7 +2,7 @@ import { StateDefinition as BotStateDefinition, EventDefinition as BotEventDefin
2
2
  import { IntegrationPackage, InterfacePackage } from '../package';
3
3
  import * as typeUtils from '../utils/type-utils';
4
4
  import { ZuiObjectSchema, ZuiObjectOrRefSchema, z } from '../zui';
5
- export { UserDefinition, ConversationDefinition, MessageDefinition, IntegrationConfigInstance, WorkflowDefinition, } from '../bot/definition';
5
+ export { UserDefinition, ConversationDefinition, MessageDefinition, WorkflowDefinition } from '../bot/definition';
6
6
  type BaseConfig = ZuiObjectOrRefSchema;
7
7
  type BaseStates = Record<string, ZuiObjectOrRefSchema>;
8
8
  type BaseEvents = Record<string, ZuiObjectOrRefSchema>;
@@ -1,5 +1,5 @@
1
- import { Client } from '@botpress/client';
1
+ import type * as client from '@botpress/client';
2
2
  import { BotSpecificClient } from '../../bot';
3
3
  import { BasePlugin, PluginRuntimeProps } from '../common';
4
4
  import { EventProxy } from './types';
5
- export declare const proxyEvents: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | Client, props: PluginRuntimeProps<TPlugin>) => EventProxy<TPlugin>;
5
+ export declare const proxyEvents: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | client.Client, props: PluginRuntimeProps<TPlugin>) => EventProxy<TPlugin>;
@@ -1,13 +1,18 @@
1
- import { ClientInputs } from '@botpress/client';
2
- import * as utils from '../../utils/type-utils';
3
- import { BasePlugin } from '../common';
4
- export type EventSchedule = NonNullable<ClientInputs['createEvent']['schedule']>;
1
+ import type * as client from '@botpress/client';
2
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
3
+ import type * as utils from '../../utils/type-utils';
4
+ import type { BasePlugin } from '../common';
5
+ export type EventSchedule = NonNullable<client.ClientInputs['createEvent']['schedule']>;
5
6
  export type EventSender<TPayload> = {
6
- emit: (event: TPayload) => Promise<void>;
7
- schedule: (event: TPayload, schedule: EventSchedule) => Promise<void>;
7
+ emit: (event: TPayload) => Promise<client.Event>;
8
+ schedule: (event: TPayload, schedule: EventSchedule) => Promise<client.Event>;
8
9
  withConversationId: (conversationId: string) => EventSender<TPayload>;
9
10
  withUserId: (userId: string) => EventSender<TPayload>;
10
11
  withMessageId: (messageId: string) => EventSender<TPayload>;
12
+ list: (props?: Omit<client.ClientInputs['listEvents'], 'type' | 'nextToken' | 'conversationId' | 'messageId' | 'userId'>) => AsyncCollection<client.Event>;
13
+ getById: (props: {
14
+ id: string;
15
+ }) => Promise<client.Event>;
11
16
  };
12
17
  export type EventProxy<TPlugin extends BasePlugin> = utils.Normalize<{
13
18
  [TEventName in keyof TPlugin['events']]: EventSender<TPlugin['events'][TEventName]>;
@@ -1,7 +1,7 @@
1
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
- import { ActionHandlers, MessageHandlers, EventHandlers, StateExpiredHandlers, HookHandlers, WorkflowHandlers, MessageHandlersMap, EventHandlersMap, StateExpiredHandlersMap, HookHandlersMap, WorkflowHandlersMap } from './server/types';
4
+ import { ActionHandlers, MessageHandlers, EventHandlers, StateExpiredHandlers, HookHandlers, WorkflowHandlers, HookHandlersMap, WorkflowHandlersMap } from './server/types';
5
5
  export type PluginImplementationProps<TPlugin extends BasePlugin = BasePlugin> = {
6
6
  actions: ActionHandlers<TPlugin>;
7
7
  };
@@ -26,9 +26,9 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
26
26
  get hookHandlers(): BotHookHandlersMap<TPlugin>;
27
27
  get workflowHandlers(): BotWorkflowHandlersMap<TPlugin>;
28
28
  readonly on: {
29
- message: <T extends utils.types.StringKeys<MessageHandlersMap<TPlugin>>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
30
- event: <T extends utils.types.StringKeys<EventHandlersMap<TPlugin>>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
31
- stateExpired: <T extends utils.types.StringKeys<StateExpiredHandlersMap<TPlugin>>>(type: T, handler: StateExpiredHandlers<TPlugin>[T]) => void;
29
+ message: <T extends utils.types.StringKeys<MessageHandlers<TPlugin>>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
30
+ event: <T extends utils.types.StringKeys<EventHandlers<TPlugin>>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
31
+ stateExpired: <T extends utils.types.StringKeys<StateExpiredHandlers<TPlugin>>>(type: T, handler: StateExpiredHandlers<TPlugin>[T]) => void;
32
32
  beforeIncomingEvent: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_incoming_event"]>>(type: T, handler: HookHandlers<TPlugin>["before_incoming_event"][T]) => void;
33
33
  beforeIncomingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_incoming_message"]>>(type: T, handler: HookHandlers<TPlugin>["before_incoming_message"][T]) => void;
34
34
  beforeOutgoingMessage: <T extends utils.types.StringKeys<HookHandlersMap<TPlugin>["before_outgoing_message"]>>(type: T, handler: HookHandlers<TPlugin>["before_outgoing_message"][T]) => void;
@@ -0,0 +1,2 @@
1
+ export { proxyMessage, proxyMessages } from './proxy';
2
+ export { ActionableMessage, MessageFinder } from './types';
@@ -0,0 +1,13 @@
1
+ import type * as client from '@botpress/client';
2
+ import type { BotSpecificClient } from '../../bot';
3
+ import type { BasePlugin, PluginRuntimeProps } from '../common';
4
+ import type { ActionableMessage, AnyPluginMessage, MessageFinder } from './types';
5
+ export declare const proxyMessages: <TPlugin extends BasePlugin>(props: {
6
+ client: BotSpecificClient<TPlugin> | client.Client;
7
+ plugin?: PluginRuntimeProps<TPlugin>;
8
+ }) => MessageFinder<TPlugin>;
9
+ export declare const proxyMessage: <TPlugin extends BasePlugin, TMessage extends client.Message | AnyPluginMessage<TPlugin> = AnyPluginMessage<TPlugin>>(props: {
10
+ client: BotSpecificClient<TPlugin> | client.Client;
11
+ plugin?: PluginRuntimeProps<TPlugin>;
12
+ message: TMessage;
13
+ }) => ActionableMessage<TPlugin, TMessage>;
@@ -0,0 +1,22 @@
1
+ import type * as client from '@botpress/client';
2
+ import type { GetMessages } from '../../bot';
3
+ import type { commonTypes } from '../../common';
4
+ import type { AsyncCollection } from '../../utils/api-paging-utils';
5
+ import type * as typeUtils from '../../utils/type-utils';
6
+ import type { BasePlugin } from '../common';
7
+ import type { IncomingMessages } from '../server';
8
+ export type MessageFinder<TPlugin extends BasePlugin> = {
9
+ list: (props?: Omit<client.ClientInputs['listMessages'], 'nextToken'>) => AsyncCollection<ActionableMessage<TPlugin>>;
10
+ getById: (props: {
11
+ id: string;
12
+ }) => Promise<ActionableMessage<TPlugin>>;
13
+ };
14
+ export type AnyPluginMessage<TPlugin extends BasePlugin> = IncomingMessages<TPlugin>['*'] | IncomingMessages<TPlugin>[typeUtils.StringKeys<GetMessages<TPlugin>>];
15
+ export type ActionableMessage<TPlugin extends BasePlugin, TMessage extends client.Message | AnyPluginMessage<TPlugin> = client.Message> = typeUtils.Merge<TMessage, {
16
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['conversation']['tags']>>;
17
+ }> & {
18
+ delete: () => Promise<void>;
19
+ update: (props: typeUtils.Merge<Omit<client.ClientInputs['updateMessage'], 'id'>, {
20
+ tags: commonTypes.ToTags<typeUtils.StringKeys<TPlugin['message']['tags']>>;
21
+ }>) => Promise<ActionableMessage<TPlugin, TMessage>>;
22
+ };