@botpress/sdk 2.0.3 → 2.0.4

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 (64) hide show
  1. package/package.json +2 -2
  2. package/.turbo/turbo-build.log +0 -12
  3. package/dist/bot/client/index.d.ts +0 -62
  4. package/dist/bot/client/types.d.ts +0 -141
  5. package/dist/bot/client/types.test.d.ts +0 -1
  6. package/dist/bot/definition.d.ts +0 -111
  7. package/dist/bot/implementation.d.ts +0 -39
  8. package/dist/bot/index.d.ts +0 -5
  9. package/dist/bot/merge-bots.d.ts +0 -2
  10. package/dist/bot/server/context.d.ts +0 -2
  11. package/dist/bot/server/index.d.ts +0 -5
  12. package/dist/bot/server/types.d.ts +0 -252
  13. package/dist/bot/server/types.test.d.ts +0 -1
  14. package/dist/bot/types/common.d.ts +0 -50
  15. package/dist/bot/types/common.test.d.ts +0 -1
  16. package/dist/bot/types/generic.d.ts +0 -31
  17. package/dist/bot/types/generic.test.d.ts +0 -1
  18. package/dist/bot/types/index.d.ts +0 -2
  19. package/dist/const.d.ts +0 -8
  20. package/dist/fixtures.d.ts +0 -108
  21. package/dist/index.d.ts +0 -15
  22. package/dist/index.js +0 -2
  23. package/dist/index.js.map +0 -7
  24. package/dist/integration/client/index.d.ts +0 -47
  25. package/dist/integration/client/types.d.ts +0 -177
  26. package/dist/integration/client/types.test.d.ts +0 -1
  27. package/dist/integration/definition/branded-schema.d.ts +0 -21
  28. package/dist/integration/definition/generic.d.ts +0 -9
  29. package/dist/integration/definition/index.d.ts +0 -76
  30. package/dist/integration/definition/types.d.ts +0 -106
  31. package/dist/integration/implementation.d.ts +0 -31
  32. package/dist/integration/index.d.ts +0 -5
  33. package/dist/integration/server/action-metadata.d.ts +0 -9
  34. package/dist/integration/server/context.d.ts +0 -3
  35. package/dist/integration/server/index.d.ts +0 -6
  36. package/dist/integration/server/logger.d.ts +0 -12
  37. package/dist/integration/server/types.d.ts +0 -102
  38. package/dist/integration/types/common.d.ts +0 -11
  39. package/dist/integration/types/generic.d.ts +0 -52
  40. package/dist/integration/types/generic.test.d.ts +0 -1
  41. package/dist/integration/types/index.d.ts +0 -2
  42. package/dist/interface/definition.d.ts +0 -70
  43. package/dist/interface/index.d.ts +0 -1
  44. package/dist/interface/types/generic.d.ts +0 -34
  45. package/dist/interface/types/generic.test.d.ts +0 -1
  46. package/dist/log.d.ts +0 -7
  47. package/dist/message.d.ts +0 -474
  48. package/dist/package.d.ts +0 -58
  49. package/dist/plugin/definition.d.ts +0 -50
  50. package/dist/plugin/implementation.d.ts +0 -39
  51. package/dist/plugin/index.d.ts +0 -3
  52. package/dist/plugin/server/types.d.ts +0 -1
  53. package/dist/plugin/server/types.test.d.ts +0 -1
  54. package/dist/plugin/types/generic.d.ts +0 -30
  55. package/dist/plugin/types/generic.test.d.ts +0 -1
  56. package/dist/retry.d.ts +0 -2
  57. package/dist/schema.d.ts +0 -18
  58. package/dist/serve.d.ts +0 -20
  59. package/dist/utils/array-utils.d.ts +0 -1
  60. package/dist/utils/index.d.ts +0 -3
  61. package/dist/utils/record-utils.d.ts +0 -3
  62. package/dist/utils/type-utils.d.ts +0 -33
  63. package/dist/utils/type-utils.test.d.ts +0 -1
  64. package/dist/zui.d.ts +0 -5
@@ -1,47 +0,0 @@
1
- import * as client from '@botpress/client';
2
- import * as common from '../types';
3
- import * as types from './types';
4
- export * from './types';
5
- /**
6
- * Just like the regular botpress client, but typed with the integration's properties.
7
- */
8
- export declare class IntegrationSpecificClient<TIntegration extends common.BaseIntegration> implements types.ClientOperations<TIntegration> {
9
- private readonly _client;
10
- constructor(_client: client.Client);
11
- createConversation: types.CreateConversation<TIntegration>;
12
- getConversation: types.GetConversation<TIntegration>;
13
- listConversations: types.ListConversations<TIntegration>;
14
- getOrCreateConversation: types.GetOrCreateConversation<TIntegration>;
15
- updateConversation: types.UpdateConversation<TIntegration>;
16
- deleteConversation: types.DeleteConversation<TIntegration>;
17
- listParticipants: types.ListParticipants<TIntegration>;
18
- addParticipant: types.AddParticipant<TIntegration>;
19
- getParticipant: types.GetParticipant<TIntegration>;
20
- removeParticipant: types.RemoveParticipant<TIntegration>;
21
- createEvent: types.CreateEvent<TIntegration>;
22
- getEvent: types.GetEvent<TIntegration>;
23
- listEvents: types.ListEvents<TIntegration>;
24
- createMessage: types.CreateMessage<TIntegration>;
25
- getOrCreateMessage: types.GetOrCreateMessage<TIntegration>;
26
- getMessage: types.GetMessage<TIntegration>;
27
- updateMessage: types.UpdateMessage<TIntegration>;
28
- listMessages: types.ListMessages<TIntegration>;
29
- deleteMessage: types.DeleteMessage<TIntegration>;
30
- createUser: types.CreateUser<TIntegration>;
31
- getUser: types.GetUser<TIntegration>;
32
- listUsers: types.ListUsers<TIntegration>;
33
- getOrCreateUser: types.GetOrCreateUser<TIntegration>;
34
- updateUser: types.UpdateUser<TIntegration>;
35
- deleteUser: types.DeleteUser<TIntegration>;
36
- getState: types.GetState<TIntegration>;
37
- setState: types.SetState<TIntegration>;
38
- getOrSetState: types.GetOrSetState<TIntegration>;
39
- patchState: types.PatchState<TIntegration>;
40
- configureIntegration: types.ConfigureIntegration<TIntegration>;
41
- uploadFile: types.UploadFile<TIntegration>;
42
- upsertFile: types.UpsertFile<TIntegration>;
43
- deleteFile: types.DeleteFile<TIntegration>;
44
- listFiles: types.ListFiles<TIntegration>;
45
- getFile: types.GetFile<TIntegration>;
46
- updateFileMetadata: types.UpdateFileMetadata<TIntegration>;
47
- }
@@ -1,177 +0,0 @@
1
- import * as client from '@botpress/client';
2
- import * as utils from '../../utils/type-utils';
3
- import * as common from '../types';
4
- type GetChannelByName<TIntegration extends common.BaseIntegration, TChannelName extends keyof TIntegration['channels']> = utils.Cast<TIntegration['channels'][TChannelName], common.ChannelDefinition>;
5
- /**
6
- * @deprecated Integration's should no longer use their name as prefix for event types or tags.
7
- */
8
- type WithRequiredPrefix<TTags extends string, TPrefix extends string> = string extends TTags ? string : utils.Join<[TPrefix, ':', TTags]>;
9
- /**
10
- * @deprecated Integration's should no longer use their name as prefix for event types or tags.
11
- */
12
- type WithOptionalPrefix<TTags extends string, TPrefix extends string> = TTags | WithRequiredPrefix<TTags, TPrefix>;
13
- type Arg<F extends (...args: any[]) => any> = Parameters<F>[number];
14
- type Res<F extends (...args: any[]) => any> = ReturnType<F>;
15
- type AllChannels<TIntegration extends common.BaseIntegration> = utils.ValueOf<TIntegration['channels']>;
16
- type ConversationResponse<TIntegration extends common.BaseIntegration, ChannelName extends keyof TIntegration['channels'] = keyof TIntegration['channels']> = {
17
- conversation: utils.Merge<Awaited<Res<client.Client['getConversation']>>['conversation'], {
18
- channel: ChannelName;
19
- tags: common.ToTags<keyof TIntegration['channels'][ChannelName]['conversation']['tags']>;
20
- }>;
21
- };
22
- export type CreateConversation<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels']>(x: {
23
- channel: utils.Cast<ChannelName, string>;
24
- tags: common.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
25
- }) => Promise<ConversationResponse<TIntegration, ChannelName>>;
26
- export type GetConversation<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getConversation']>) => Promise<ConversationResponse<TIntegration>>;
27
- export type ListConversations<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels']>(x: utils.Merge<Arg<client.Client['listConversations']>, {
28
- channel?: utils.Cast<ChannelName, string>;
29
- tags?: common.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
30
- }>) => Res<client.Client['listConversations']>;
31
- export type GetOrCreateConversation<TIntegration extends common.BaseIntegration> = <ChannelName extends keyof TIntegration['channels']>(x: {
32
- channel: utils.Cast<ChannelName, string>;
33
- tags: common.ToTags<keyof GetChannelByName<TIntegration, ChannelName>['conversation']['tags']>;
34
- }) => Promise<ConversationResponse<TIntegration, ChannelName>>;
35
- export type UpdateConversation<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateConversation']>, {
36
- tags?: common.ToTags<keyof AllChannels<TIntegration>['conversation']['tags']>;
37
- }>) => Promise<ConversationResponse<TIntegration>>;
38
- export type DeleteConversation<_TIntegration extends common.BaseIntegration> = client.Client['deleteConversation'];
39
- export type ListParticipants<_TIntegration extends common.BaseIntegration> = client.Client['listParticipants'];
40
- export type AddParticipant<_TIntegration extends common.BaseIntegration> = client.Client['addParticipant'];
41
- export type GetParticipant<_TIntegration extends common.BaseIntegration> = client.Client['getParticipant'];
42
- export type RemoveParticipant<_TIntegration extends common.BaseIntegration> = client.Client['removeParticipant'];
43
- type EventResponse<TIntegration extends common.BaseIntegration, TEvent extends keyof TIntegration['events']> = {
44
- event: utils.Merge<Awaited<Res<client.Client['getEvent']>>['event'], {
45
- type: WithRequiredPrefix<utils.Cast<TEvent, string>, TIntegration['name']>;
46
- payload: TIntegration['events'][TEvent];
47
- }>;
48
- };
49
- export type CreateEvent<TIntegration extends common.BaseIntegration> = <TEvent extends keyof TIntegration['events']>(x: utils.Merge<Arg<client.Client['createEvent']>, {
50
- type: WithOptionalPrefix<utils.Cast<TEvent, string>, TIntegration['name']>;
51
- payload: TIntegration['events'][TEvent];
52
- }>) => Promise<EventResponse<TIntegration, TEvent>>;
53
- export type GetEvent<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getEvent']>) => Promise<utils.ValueOf<{
54
- [K in keyof TIntegration['events']]: EventResponse<TIntegration, K>;
55
- }>>;
56
- export type ListEvents<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listEvents']>, {
57
- type?: WithRequiredPrefix<utils.Cast<keyof TIntegration['events'], string>, TIntegration['name']>;
58
- }>) => Res<client.Client['listEvents']>;
59
- type MessageResponse<TIntegration extends common.BaseIntegration, TChannel extends keyof TIntegration['channels'], TMessage extends keyof TIntegration['channels'][TChannel]['messages']> = {
60
- message: utils.Merge<Awaited<Res<client.Client['createMessage']>>['message'], {
61
- type: utils.Cast<TMessage, string>;
62
- payload: TIntegration['channels'][TChannel]['messages'][TMessage];
63
- tags: common.ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
64
- }>;
65
- };
66
- export type CreateMessage<TIntegration extends common.BaseIntegration> = <TChannel extends keyof TIntegration['channels'], TMessage extends keyof TIntegration['channels'][TChannel]['messages']>(x: utils.Merge<Arg<client.Client['createMessage']>, {
67
- type: utils.Cast<TMessage, string>;
68
- payload: TIntegration['channels'][TChannel]['messages'][TMessage];
69
- tags: common.ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
70
- }>) => Promise<MessageResponse<TIntegration, TChannel, TMessage>>;
71
- export type GetOrCreateMessage<TIntegration extends common.BaseIntegration> = <TChannel extends keyof TIntegration['channels'], TMessage extends keyof TIntegration['channels'][TChannel]['messages']>(x: utils.Merge<Arg<client.Client['getOrCreateMessage']>, {
72
- type: utils.Cast<TMessage, string>;
73
- payload: TIntegration['channels'][TChannel]['messages'][TMessage];
74
- tags: common.ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
75
- }>) => Promise<MessageResponse<TIntegration, TChannel, TMessage>>;
76
- export type GetMessage<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getMessage']>) => Promise<MessageResponse<TIntegration, keyof TIntegration['channels'], keyof utils.ValueOf<TIntegration['channels']>['messages']>>;
77
- export type UpdateMessage<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateMessage']>, {
78
- tags: common.ToTags<keyof AllChannels<TIntegration>['message']['tags']>;
79
- }>) => Promise<MessageResponse<TIntegration, keyof TIntegration['channels'], keyof utils.ValueOf<TIntegration['channels']>['messages']>>;
80
- export type ListMessages<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listMessages']>, {
81
- tags?: common.ToTags<keyof AllChannels<TIntegration>['message']['tags']>;
82
- }>) => Res<client.Client['listMessages']>;
83
- export type DeleteMessage<_TIntegration extends common.BaseIntegration> = client.Client['deleteMessage'];
84
- type UserResponse<TIntegration extends common.BaseIntegration> = {
85
- user: utils.Merge<Awaited<Res<client.Client['getUser']>>['user'], {
86
- tags: common.ToTags<keyof TIntegration['user']['tags']>;
87
- }>;
88
- };
89
- export type CreateUser<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['createUser']>, {
90
- tags: common.ToTags<keyof TIntegration['user']['tags']>;
91
- }>) => Promise<UserResponse<TIntegration>>;
92
- export type GetUser<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getUser']>) => Promise<UserResponse<TIntegration>>;
93
- export type ListUsers<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listUsers']>, {
94
- tags?: common.ToTags<keyof TIntegration['user']['tags']>;
95
- }>) => Res<client.Client['listUsers']>;
96
- export type GetOrCreateUser<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['getOrCreateUser']>, {
97
- tags: common.ToTags<keyof TIntegration['user']['tags']>;
98
- }>) => Promise<UserResponse<TIntegration>>;
99
- export type UpdateUser<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['updateUser']>, {
100
- tags?: common.ToTags<keyof TIntegration['user']['tags']>;
101
- }>) => Promise<UserResponse<TIntegration>>;
102
- export type DeleteUser<_TIntegration extends common.BaseIntegration> = client.Client['deleteUser'];
103
- type StateResponse<TIntegration extends common.BaseIntegration, TState extends keyof TIntegration['states']> = {
104
- state: utils.Merge<Awaited<Res<client.Client['getState']>>['state'], {
105
- payload: TIntegration['states'][TState];
106
- }>;
107
- meta: {
108
- cached: boolean;
109
- };
110
- };
111
- export type GetState<TIntegration extends common.BaseIntegration> = <TState extends keyof TIntegration['states']>(x: utils.Merge<Arg<client.Client['getState']>, {
112
- name: utils.Cast<TState, string>;
113
- }>) => Promise<StateResponse<TIntegration, TState>>;
114
- export type SetState<TIntegration extends common.BaseIntegration> = <TState extends keyof TIntegration['states']>(x: utils.Merge<Arg<client.Client['setState']>, {
115
- name: utils.Cast<TState, string>;
116
- payload: TIntegration['states'][TState] | null;
117
- }>) => Promise<StateResponse<TIntegration, TState>>;
118
- export type GetOrSetState<TIntegration extends common.BaseIntegration> = <TState extends keyof TIntegration['states']>(x: utils.Merge<Arg<client.Client['getOrSetState']>, {
119
- name: utils.Cast<TState, string>;
120
- payload: TIntegration['states'][TState];
121
- }>) => Promise<StateResponse<TIntegration, TState>>;
122
- export type PatchState<TIntegration extends common.BaseIntegration> = <TState extends keyof TIntegration['states']>(x: utils.Merge<Arg<client.Client['patchState']>, {
123
- name: utils.Cast<TState, string>;
124
- payload: Partial<TIntegration['states'][TState]>;
125
- }>) => Promise<StateResponse<TIntegration, TState>>;
126
- export type ConfigureIntegration<_TIntegration extends common.BaseIntegration> = client.Client['configureIntegration'];
127
- export type UploadFile<_TIntegration extends common.BaseIntegration> = client.Client['uploadFile'];
128
- export type UpsertFile<_TIntegration extends common.BaseIntegration> = client.Client['upsertFile'];
129
- export type DeleteFile<_TIntegration extends common.BaseIntegration> = client.Client['deleteFile'];
130
- export type ListFiles<_TIntegration extends common.BaseIntegration> = client.Client['listFiles'];
131
- export type GetFile<_TIntegration extends common.BaseIntegration> = client.Client['getFile'];
132
- export type UpdateFileMetadata<_TIntegration extends common.BaseIntegration> = client.Client['updateFileMetadata'];
133
- export type ClientOperations<TIntegration extends common.BaseIntegration> = {
134
- createConversation: CreateConversation<TIntegration>;
135
- getConversation: GetConversation<TIntegration>;
136
- listConversations: ListConversations<TIntegration>;
137
- getOrCreateConversation: GetOrCreateConversation<TIntegration>;
138
- updateConversation: UpdateConversation<TIntegration>;
139
- deleteConversation: DeleteConversation<TIntegration>;
140
- listParticipants: ListParticipants<TIntegration>;
141
- addParticipant: AddParticipant<TIntegration>;
142
- getParticipant: GetParticipant<TIntegration>;
143
- removeParticipant: RemoveParticipant<TIntegration>;
144
- createEvent: CreateEvent<TIntegration>;
145
- getEvent: GetEvent<TIntegration>;
146
- listEvents: ListEvents<TIntegration>;
147
- createMessage: CreateMessage<TIntegration>;
148
- getOrCreateMessage: GetOrCreateMessage<TIntegration>;
149
- getMessage: GetMessage<TIntegration>;
150
- updateMessage: UpdateMessage<TIntegration>;
151
- listMessages: ListMessages<TIntegration>;
152
- deleteMessage: DeleteMessage<TIntegration>;
153
- createUser: CreateUser<TIntegration>;
154
- getUser: GetUser<TIntegration>;
155
- listUsers: ListUsers<TIntegration>;
156
- getOrCreateUser: GetOrCreateUser<TIntegration>;
157
- updateUser: UpdateUser<TIntegration>;
158
- deleteUser: DeleteUser<TIntegration>;
159
- getState: GetState<TIntegration>;
160
- setState: SetState<TIntegration>;
161
- getOrSetState: GetOrSetState<TIntegration>;
162
- patchState: PatchState<TIntegration>;
163
- configureIntegration: ConfigureIntegration<TIntegration>;
164
- uploadFile: UploadFile<TIntegration>;
165
- upsertFile: UpsertFile<TIntegration>;
166
- deleteFile: DeleteFile<TIntegration>;
167
- listFiles: ListFiles<TIntegration>;
168
- getFile: GetFile<TIntegration>;
169
- updateFileMetadata: UpdateFileMetadata<TIntegration>;
170
- };
171
- export type ClientInputs<TIntegration extends common.BaseIntegration> = {
172
- [K in keyof ClientOperations<TIntegration>]: Arg<ClientOperations<TIntegration>[K]>;
173
- };
174
- export type ClientOutputs<TIntegration extends common.BaseIntegration> = {
175
- [K in keyof ClientOperations<TIntegration>]: Awaited<Res<ClientOperations<TIntegration>[K]>>;
176
- };
177
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { z } from '../../zui';
2
- declare const schemaName: unique symbol;
3
- type BaseSchemas = Record<string, z.ZodSchema>;
4
- export type SchemaStoreProps<TSchemas extends BaseSchemas = BaseSchemas> = {
5
- [K in keyof TSchemas]: {
6
- schema: TSchemas[K];
7
- };
8
- };
9
- export type BrandedSchema<TSchema extends BaseSchemas[string] = BaseSchemas[string]> = {
10
- schema: TSchema;
11
- [schemaName]: string;
12
- };
13
- export type SchemaStore<TSchemas extends BaseSchemas = BaseSchemas> = {
14
- [K in keyof TSchemas]: BrandedSchema<TSchemas[K]>;
15
- };
16
- export declare const createStore: <TSchemas extends BaseSchemas>(props: SchemaStoreProps<TSchemas> | undefined) => SchemaStore<TSchemas>;
17
- export declare const isBranded: (schema: BrandedSchema | {
18
- schema: z.ZodSchema;
19
- }) => schema is BrandedSchema;
20
- export declare const getName: (schema: BrandedSchema) => string;
21
- export {};
@@ -1,9 +0,0 @@
1
- import { ZuiObjectSchema } from '../../zui';
2
- export type BaseConfig = ZuiObjectSchema;
3
- export type BaseConfigs = Record<string, BaseConfig>;
4
- export type BaseEvents = Record<string, ZuiObjectSchema>;
5
- export type BaseActions = Record<string, ZuiObjectSchema>;
6
- export type BaseMessages = Record<string, ZuiObjectSchema>;
7
- export type BaseChannels = Record<string, BaseMessages>;
8
- export type BaseStates = Record<string, ZuiObjectSchema>;
9
- export type BaseEntities = Record<string, ZuiObjectSchema>;
@@ -1,76 +0,0 @@
1
- import { InterfacePackage } from '../../package';
2
- import { z } from '../../zui';
3
- import { SchemaStore, BrandedSchema } from './branded-schema';
4
- import { BaseConfig, BaseEvents, BaseActions, BaseChannels, BaseStates, BaseEntities, BaseConfigs } from './generic';
5
- import { ConfigurationDefinition, EventDefinition, ChannelDefinition, ActionDefinition, StateDefinition, UserDefinition, SecretDefinition, EntityDefinition, AdditionalConfigurationDefinition } from './types';
6
- export * from './types';
7
- export type InterfaceExtension = InterfacePackage & {
8
- entities: Record<string, {
9
- name: string;
10
- schema: z.AnyZodObject;
11
- }>;
12
- };
13
- export type IntegrationDefinitionProps<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TConfigs extends BaseConfigs = BaseConfigs, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TChannels extends BaseChannels = BaseChannels, TStates extends BaseStates = BaseStates, TEntities extends BaseEntities = BaseEntities> = {
14
- name: TName;
15
- version: TVersion;
16
- title?: string;
17
- description?: string;
18
- icon?: string;
19
- readme?: string;
20
- identifier?: {
21
- extractScript?: string;
22
- fallbackHandlerScript?: string;
23
- };
24
- configuration?: ConfigurationDefinition<TConfig>;
25
- configurations?: {
26
- [K in keyof TConfigs]: AdditionalConfigurationDefinition<TConfigs[K]>;
27
- };
28
- events?: {
29
- [K in keyof TEvents]: EventDefinition<TEvents[K]>;
30
- };
31
- actions?: {
32
- [K in keyof TActions]: ActionDefinition<TActions[K]>;
33
- };
34
- channels?: {
35
- [K in keyof TChannels]: ChannelDefinition<TChannels[K]>;
36
- };
37
- states?: {
38
- [K in keyof TStates]: StateDefinition<TStates[K]>;
39
- };
40
- user?: UserDefinition;
41
- secrets?: Record<string, SecretDefinition>;
42
- entities?: {
43
- [K in keyof TEntities]: EntityDefinition<TEntities[K]>;
44
- };
45
- interfaces?: Record<string, InterfaceExtension>;
46
- };
47
- type EntitiesOfPackage<TPackage extends InterfacePackage> = {
48
- [K in keyof TPackage['definition']['entities']]: NonNullable<TPackage['definition']['entities']>[K]['schema'];
49
- };
50
- type ExtensionBuilderInput<TIntegrationEntities extends BaseEntities> = SchemaStore<TIntegrationEntities>;
51
- type ExtensionBuilderOutput<TInterfaceEntities extends BaseEntities> = {
52
- [K in keyof TInterfaceEntities]: BrandedSchema<z.ZodSchema<z.infer<TInterfaceEntities[K]>>>;
53
- };
54
- type ExtensionBuilder<TIntegrationEntities extends BaseEntities, TInterfaceEntities extends BaseEntities> = (input: ExtensionBuilderInput<TIntegrationEntities>) => ExtensionBuilderOutput<TInterfaceEntities>;
55
- export declare class IntegrationDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TConfigs extends BaseConfigs = BaseConfigs, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TChannels extends BaseChannels = BaseChannels, TStates extends BaseStates = BaseStates, TEntities extends BaseEntities = BaseEntities> {
56
- readonly props: IntegrationDefinitionProps<TName, TVersion, TConfig, TConfigs, TEvents, TActions, TChannels, TStates, TEntities>;
57
- readonly name: this['props']['name'];
58
- readonly version: this['props']['version'];
59
- readonly title: this['props']['title'];
60
- readonly description: this['props']['description'];
61
- readonly icon: this['props']['icon'];
62
- readonly readme: this['props']['readme'];
63
- readonly configuration: this['props']['configuration'];
64
- readonly configurations: this['props']['configurations'];
65
- readonly events: this['props']['events'];
66
- readonly actions: this['props']['actions'];
67
- readonly channels: this['props']['channels'];
68
- readonly states: this['props']['states'];
69
- readonly user: this['props']['user'];
70
- readonly secrets: this['props']['secrets'];
71
- readonly identifier: this['props']['identifier'];
72
- readonly entities: this['props']['entities'];
73
- readonly interfaces: this['props']['interfaces'];
74
- constructor(props: IntegrationDefinitionProps<TName, TVersion, TConfig, TConfigs, TEvents, TActions, TChannels, TStates, TEntities>);
75
- extend<P extends InterfacePackage>(interfacePkg: P, builder: ExtensionBuilder<TEntities, EntitiesOfPackage<P>>): this;
76
- }
@@ -1,106 +0,0 @@
1
- import { SchemaDefinition } from '../../schema';
2
- import { ZuiObjectSchema } from '../../zui';
3
- import { BaseConfig, BaseEvents, BaseActions, BaseMessages, BaseChannels, BaseStates, BaseEntities, BaseConfigs } from './generic';
4
- export type TagDefinition = {
5
- title?: string;
6
- description?: string;
7
- };
8
- export type ConfigurationDefinition<TConfig extends BaseConfig = BaseConfig> = SchemaDefinition<TConfig> & {
9
- identifier?: {
10
- required?: boolean;
11
- linkTemplateScript?: string;
12
- };
13
- };
14
- export type AdditionalConfigurationDefinition<TConfig extends BaseConfigs[string] = BaseConfigs[string]> = ConfigurationDefinition<TConfig> & {
15
- title?: string;
16
- description?: string;
17
- };
18
- export type EventDefinition<TEvent extends BaseEvents[string] = BaseEvents[string]> = SchemaDefinition<TEvent> & {
19
- title?: string;
20
- description?: string;
21
- };
22
- export type MessageDefinition<TMessage extends BaseMessages[string] = BaseMessages[string]> = SchemaDefinition<TMessage>;
23
- export type ChannelDefinition<TChannel extends BaseChannels[string] = BaseChannels[string]> = {
24
- title?: string;
25
- description?: string;
26
- messages: {
27
- [K in keyof TChannel]: MessageDefinition<TChannel[K]>;
28
- };
29
- message?: {
30
- tags?: Record<string, TagDefinition>;
31
- };
32
- conversation?: Partial<{
33
- tags: Record<string, TagDefinition>;
34
- /**
35
- * @deprecated
36
- */
37
- creation: {
38
- enabled: boolean;
39
- requiredTags: string[];
40
- };
41
- }>;
42
- };
43
- export type ActionDefinition<TAction extends BaseActions[string] = BaseActions[string]> = {
44
- title?: string;
45
- description?: string;
46
- input: SchemaDefinition<TAction>;
47
- output: SchemaDefinition<ZuiObjectSchema>;
48
- billable?: boolean;
49
- cacheable?: boolean;
50
- };
51
- export type StateDefinition<TState extends BaseStates[string] = BaseStates[string]> = SchemaDefinition<TState> & {
52
- type: 'integration' | 'conversation' | 'user';
53
- };
54
- export type UserDefinition = Partial<{
55
- tags: Record<string, TagDefinition>;
56
- /**
57
- * @deprecated
58
- */
59
- creation: {
60
- enabled: boolean;
61
- requiredTags: string[];
62
- };
63
- }>;
64
- export type SecretDefinition = {
65
- optional?: boolean;
66
- description?: string;
67
- };
68
- export type EntityDefinition<TEntity extends BaseEntities[string] = BaseEntities[string]> = SchemaDefinition<TEntity> & {
69
- title?: string;
70
- description?: string;
71
- };
72
- export type ResolvedInterface<TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TChannels extends BaseChannels = BaseChannels> = {
73
- actions: {
74
- [K in keyof TActions]: ActionDefinition<TActions[K]>;
75
- };
76
- events: {
77
- [K in keyof TEvents]: EventDefinition<TEvents[K]>;
78
- };
79
- channels: {
80
- [K in keyof TChannels]: ChannelDefinition<TChannels[K]>;
81
- };
82
- };
83
- export type InterfaceImplementationStatement<TEntities extends BaseEntities = BaseEntities, TActions extends BaseActions = BaseActions, TEvents extends BaseEvents = BaseEvents, TChannels extends BaseChannels = BaseChannels> = {
84
- name: string;
85
- version: string;
86
- entities: {
87
- [K in keyof TEntities]: {
88
- name: string;
89
- };
90
- };
91
- actions: {
92
- [K in keyof TActions]: {
93
- name: string;
94
- };
95
- };
96
- events: {
97
- [K in keyof TEvents]: {
98
- name: string;
99
- };
100
- };
101
- channels: {
102
- [K in keyof TChannels]: {
103
- name: string;
104
- };
105
- };
106
- };
@@ -1,31 +0,0 @@
1
- import type { Server } from 'node:http';
2
- import { RegisterHandler as RegisterFunction, UnregisterHandler as UnregisterFunction, WebhookHandler as WebhookFunction, CreateUserHandler as CreateUserFunction, CreateConversationHandler as CreateConversationFunction, ActionHandlers as ActionFunctions, ChannelHandlers as ChannelFunctions } from './server';
3
- import { BaseIntegration } from './types';
4
- export type IntegrationImplementationProps<TIntegration extends BaseIntegration = BaseIntegration> = {
5
- register: RegisterFunction<TIntegration>;
6
- unregister: UnregisterFunction<TIntegration>;
7
- handler: WebhookFunction<TIntegration>;
8
- /**
9
- * @deprecated
10
- */
11
- createUser?: CreateUserFunction<TIntegration>;
12
- /**
13
- * @deprecated
14
- */
15
- createConversation?: CreateConversationFunction<TIntegration>;
16
- actions: ActionFunctions<TIntegration>;
17
- channels: ChannelFunctions<TIntegration>;
18
- };
19
- export declare class IntegrationImplementation<TIntegration extends BaseIntegration = BaseIntegration> {
20
- readonly props: IntegrationImplementationProps<TIntegration>;
21
- readonly actions: IntegrationImplementationProps<TIntegration>['actions'];
22
- readonly channels: IntegrationImplementationProps<TIntegration>['channels'];
23
- readonly register: IntegrationImplementationProps<TIntegration>['register'];
24
- readonly unregister: IntegrationImplementationProps<TIntegration>['unregister'];
25
- readonly createUser: IntegrationImplementationProps<TIntegration>['createUser'];
26
- readonly createConversation: IntegrationImplementationProps<TIntegration>['createConversation'];
27
- readonly webhook: IntegrationImplementationProps<TIntegration>['handler'];
28
- constructor(props: IntegrationImplementationProps<TIntegration>);
29
- readonly handler: (req: import("../serve").Request) => Promise<import("../serve").Response | void>;
30
- readonly start: (port?: number) => Promise<Server>;
31
- }
@@ -1,5 +0,0 @@
1
- export * from './definition';
2
- export * from './implementation';
3
- export * from './client';
4
- export * from './server';
5
- export * from './types/generic';
@@ -1,9 +0,0 @@
1
- export type ActionMetadata = {
2
- cost: number;
3
- };
4
- export declare class ActionMetadataStore {
5
- private _cost;
6
- get cost(): number;
7
- setCost(cost: number): void;
8
- toJSON(): ActionMetadata;
9
- }
@@ -1,3 +0,0 @@
1
- import { IntegrationContext } from './types';
2
- export declare const integrationOperationSchema: import("@bpinternal/zui").ZodEnum<["webhook_received", "message_created", "action_triggered", "register", "unregister", "ping", "create_user", "create_conversation"]>;
3
- export declare const extractContext: (headers: Record<string, string | undefined>) => IntegrationContext;
@@ -1,6 +0,0 @@
1
- import { Request, Response } from '../../serve';
2
- import { BaseIntegration } from '../types';
3
- import { IntegrationHandlers } from './types';
4
- export * from './types';
5
- export * from './logger';
6
- export declare const integrationHandler: (instance: IntegrationHandlers<BaseIntegration>) => (req: Request) => Promise<Response | void>;
@@ -1,12 +0,0 @@
1
- export declare const integrationLogger: {
2
- /**
3
- * Use this function to log messages that will be displayed to the Bot Owner.
4
- */
5
- forBot: () => {
6
- info: (message?: any, ...optionalParams: any[]) => void;
7
- warn: (message?: any, ...optionalParams: any[]) => void;
8
- error: (message?: any, ...optionalParams: any[]) => void;
9
- debug: (message?: any, ...optionalParams: any[]) => void;
10
- };
11
- };
12
- export type IntegrationLogger = typeof integrationLogger;
@@ -1,102 +0,0 @@
1
- import { type Conversation, type Message, type User } from '@botpress/client';
2
- import { Request, Response } from '../../serve';
3
- import { Cast, Merge, ValueOf } from '../../utils/type-utils';
4
- import { IntegrationSpecificClient } from '../client';
5
- import { BaseIntegration, ToTags } from '../types';
6
- import { IntegrationLogger } from './logger';
7
- type IntegrationOperation = 'webhook_received' | 'message_created' | 'action_triggered' | 'register' | 'unregister' | 'ping' | 'create_user' | 'create_conversation';
8
- type IntegrationContextConfig<TIntegration extends BaseIntegration> = {
9
- configurationType: null;
10
- configuration: TIntegration['configuration'];
11
- } | ValueOf<{
12
- [TConfigType in keyof TIntegration['configurations']]: {
13
- configurationType: TConfigType;
14
- configuration: TIntegration['configurations'][TConfigType];
15
- };
16
- }>;
17
- export type IntegrationContext<TIntegration extends BaseIntegration = BaseIntegration> = {
18
- botId: string;
19
- botUserId: string;
20
- integrationId: string;
21
- webhookId: string;
22
- operation: IntegrationOperation;
23
- } & IntegrationContextConfig<TIntegration>;
24
- export type CommonHandlerProps<TIntegration extends BaseIntegration> = {
25
- ctx: IntegrationContext<TIntegration>;
26
- client: IntegrationSpecificClient<TIntegration>;
27
- logger: IntegrationLogger;
28
- };
29
- export type RegisterPayload = {
30
- webhookUrl: string;
31
- };
32
- export type RegisterHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & RegisterPayload;
33
- export type RegisterHandler<TIntegration extends BaseIntegration> = (props: RegisterHandlerProps<TIntegration>) => Promise<void>;
34
- export type UnregisterPayload = {
35
- webhookUrl: string;
36
- };
37
- export type UnregisterHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & UnregisterPayload;
38
- export type UnregisterHandler<TIntegration extends BaseIntegration> = (props: UnregisterHandlerProps<TIntegration>) => Promise<void>;
39
- export type WebhookPayload = {
40
- req: Request;
41
- };
42
- export type WebhookHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & WebhookPayload;
43
- export type WebhookHandler<TIntegration extends BaseIntegration> = (props: WebhookHandlerProps<TIntegration>) => Promise<Response | void>;
44
- export type ActionMetadata = {
45
- setCost: (cost: number) => void;
46
- };
47
- export type ActionPayload<T extends string, I> = {
48
- type: T;
49
- input: I;
50
- metadata: ActionMetadata;
51
- };
52
- export type ActionHandlerProps<TIntegration extends BaseIntegration, T extends string, I> = CommonHandlerProps<TIntegration> & ActionPayload<T, I>;
53
- export type ActionHandlers<TIntegration extends BaseIntegration> = {
54
- [ActionType in keyof TIntegration['actions']]: (props: ActionHandlerProps<TIntegration, Cast<ActionType, string>, TIntegration['actions'][ActionType]['input']>) => Promise<TIntegration['actions'][ActionType]['output']>;
55
- };
56
- export type CreateUserPayload<TIntegration extends BaseIntegration> = {
57
- tags: ToTags<keyof TIntegration['user']['tags']>;
58
- };
59
- export type CreateUserHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & CreateUserPayload<TIntegration>;
60
- export type CreateUserHandler<TIntegration extends BaseIntegration> = (props: CreateUserHandlerProps<TIntegration>) => Promise<Response | void>;
61
- export type CreateConversationPayload<TIntegration extends BaseIntegration, TChannel extends keyof TIntegration['channels'] = keyof TIntegration['channels']> = {
62
- channel: TChannel;
63
- tags: ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
64
- };
65
- export type CreateConversationHandlerProps<TIntegration extends BaseIntegration> = CommonHandlerProps<TIntegration> & CreateConversationPayload<TIntegration>;
66
- export type CreateConversationHandler<TIntegration extends BaseIntegration> = (props: CreateConversationHandlerProps<TIntegration>) => Promise<Response | void>;
67
- export type MessagePayload<TIntegration extends BaseIntegration, TChannel extends keyof TIntegration['channels'], TMessage extends keyof TIntegration['channels'][TChannel]['messages']> = {
68
- type: TMessage;
69
- payload: TIntegration['channels'][TChannel]['messages'][TMessage];
70
- conversation: Merge<Conversation, {
71
- channel: TChannel;
72
- tags: ToTags<keyof TIntegration['channels'][TChannel]['conversation']['tags']>;
73
- }>;
74
- message: Merge<Message, {
75
- tags: ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
76
- }>;
77
- user: Merge<User, {
78
- tags: ToTags<keyof TIntegration['user']['tags']>;
79
- }>;
80
- };
81
- 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
- ack: (props: {
83
- tags: ToTags<keyof TIntegration['channels'][TChannel]['message']['tags']>;
84
- }) => Promise<void>;
85
- };
86
- export type ChannelHandlers<TIntegration extends BaseIntegration> = {
87
- [ChannelName in keyof TIntegration['channels']]: {
88
- messages: {
89
- [MessageType in keyof TIntegration['channels'][ChannelName]['messages']]: (props: CommonHandlerProps<TIntegration> & MessageHandlerProps<TIntegration, ChannelName, MessageType>) => Promise<void>;
90
- };
91
- };
92
- };
93
- export type IntegrationHandlers<TIntegration extends BaseIntegration> = {
94
- register: RegisterHandler<TIntegration>;
95
- unregister: UnregisterHandler<TIntegration>;
96
- webhook: WebhookHandler<TIntegration>;
97
- createUser?: CreateUserHandler<TIntegration>;
98
- createConversation?: CreateConversationHandler<TIntegration>;
99
- actions: ActionHandlers<TIntegration>;
100
- channels: ChannelHandlers<TIntegration>;
101
- };
102
- export {};
@@ -1,11 +0,0 @@
1
- import * as utils from '../../utils/type-utils';
2
- import { BaseIntegration } from './generic';
3
- export type ConfigurationDefinition = BaseIntegration['configuration'];
4
- export type ActionDefinition = BaseIntegration['actions'][string];
5
- export type ChannelDefinition = BaseIntegration['channels'][string];
6
- export type EventDefinition = BaseIntegration['events'][string];
7
- export type StateDefinition = BaseIntegration['states'][string];
8
- export type UserDefinition = BaseIntegration['user'];
9
- type AsTags<T extends Record<string, string | undefined>> = utils.Cast<T, Record<string, string>>;
10
- export type ToTags<TTags extends string | number | symbol> = AsTags<Partial<Record<utils.Cast<TTags, string>, string>>>;
11
- export {};