@botpress/sdk 3.6.3 → 4.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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @botpress/sdk@3.6.3 build /home/runner/work/botpress/botpress/packages/sdk
2
+ > @botpress/sdk@4.0.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.6.3 build:type /home/runner/work/botpress/botpress/packages/sdk
6
+ > @botpress/sdk@4.0.1 build:type /home/runner/work/botpress/botpress/packages/sdk
7
7
  > tsc --emitDeclarationOnly --declaration
8
8
 
9
9
 
10
- > @botpress/sdk@3.6.3 build:node /home/runner/work/botpress/botpress/packages/sdk
10
+ > @botpress/sdk@4.0.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.6.3 build:browser /home/runner/work/botpress/botpress/packages/sdk
15
+ > @botpress/sdk@4.0.1 build:browser /home/runner/work/botpress/botpress/packages/sdk
16
16
  > ts-node -T ./build.ts --browser
17
17
 
18
18
  Done
@@ -21,7 +21,8 @@ type MessageResponse<TBot extends common.BaseBot, TMessage extends keyof common.
21
21
  };
22
22
  type StateResponse<TBot extends common.BaseBot, TState extends keyof TBot['states'] = keyof TBot['states']> = utils.Merge<Awaited<Res<client.Client['getState']>>, {
23
23
  state: utils.Merge<Awaited<Res<client.Client['getState']>>['state'], {
24
- payload: TBot['states'][TState];
24
+ type: utils.Cast<TBot['states'][TState]['type'], string>;
25
+ payload: TBot['states'][TState]['payload'];
25
26
  }>;
26
27
  }>;
27
28
  export type CreateConversation<_TBot extends common.BaseBot> = client.Client['createConversation'];
@@ -60,23 +61,23 @@ export type UpdateUser<_TBot extends common.BaseBot> = client.Client['updateUser
60
61
  export type DeleteUser<_TBot extends common.BaseBot> = client.Client['deleteUser'];
61
62
  export type GetState<TBot extends common.BaseBot> = <TState extends keyof TBot['states']>(x: utils.Merge<Arg<client.Client['getState']>, {
62
63
  name: utils.Cast<TState, string>;
64
+ type: utils.Cast<TBot['states'][TState]['type'], string>;
63
65
  }>) => Promise<StateResponse<TBot, TState>>;
64
66
  export type SetState<TBot extends common.BaseBot> = <TState extends keyof TBot['states']>(x: utils.Merge<Arg<client.Client['setState']>, {
65
67
  name: utils.Cast<TState, string>;
66
- payload: TBot['states'][TState] | null;
68
+ type: utils.Cast<TBot['states'][TState]['type'], string>;
69
+ payload: TBot['states'][TState]['payload'] | null;
67
70
  }>) => Promise<StateResponse<TBot, TState>>;
68
71
  export type GetOrSetState<TBot extends common.BaseBot> = <TState extends keyof TBot['states']>(x: utils.Merge<Arg<client.Client['getOrSetState']>, {
69
72
  name: utils.Cast<TState, string>;
70
- payload: TBot['states'][TState];
73
+ type: utils.Cast<TBot['states'][TState]['type'], string>;
74
+ payload: TBot['states'][TState]['payload'];
71
75
  }>) => Promise<StateResponse<TBot, TState>>;
72
76
  export type PatchState<TBot extends common.BaseBot> = <TState extends keyof TBot['states']>(x: utils.Merge<Arg<client.Client['patchState']>, {
73
77
  name: utils.Cast<TState, string>;
74
- payload: Partial<TBot['states'][TState]>;
75
- }>) => Promise<{
76
- state: utils.Merge<Awaited<Res<client.Client['patchState']>>['state'], {
77
- payload: TBot['states'][TState];
78
- }>;
79
- }>;
78
+ type: utils.Cast<TBot['states'][TState]['type'], string>;
79
+ payload: Partial<TBot['states'][TState]['payload']>;
80
+ }>) => Promise<StateResponse<TBot, TState>>;
80
81
  export type CallAction<TBot extends common.BaseBot> = <ActionType extends keyof common.EnumerateActions<TBot>>(x: utils.Merge<Arg<client.Client['callAction']>, {
81
82
  type: utils.Cast<ActionType, string>;
82
83
  input: utils.Cast<common.EnumerateActions<TBot>[ActionType], common.IntegrationInstanceActionDefinition>['input'];
@@ -1,5 +1,6 @@
1
1
  import { BaseIntegration, DefaultIntegration, InputBaseIntegration } from '../../integration/common/generic';
2
2
  import * as utils from '../../utils/type-utils';
3
+ import * as def from '../definition';
3
4
  export * from '../../integration/common/generic';
4
5
  export type BaseAction = {
5
6
  input: any;
@@ -15,10 +16,14 @@ export type BaseWorkflow = {
15
16
  [k: string]: string;
16
17
  };
17
18
  };
19
+ export type BaseState = {
20
+ type: def.StateType;
21
+ payload: any;
22
+ };
18
23
  export type BaseBot = {
19
24
  integrations: Record<string, BaseIntegration>;
20
25
  events: Record<string, any>;
21
- states: Record<string, any>;
26
+ states: Record<string, BaseState>;
22
27
  actions: Record<string, BaseAction>;
23
28
  tables: Record<string, BaseTable>;
24
29
  workflows: Record<string, BaseWorkflow>;
@@ -30,7 +30,8 @@ type _IncomingMessages<TBot extends common.BaseBot> = {
30
30
  type _IncomingStates<TBot extends common.BaseBot> = {
31
31
  [K in utils.StringKeys<common.EnumerateStates<TBot>>]: utils.Merge<client.State, {
32
32
  name: K;
33
- payload: common.EnumerateStates<TBot>[K];
33
+ type: common.EnumerateStates<TBot>[K]['type'];
34
+ payload: common.EnumerateStates<TBot>[K]['payload'];
34
35
  }>;
35
36
  };
36
37
  type _OutgoingMessageRequests<TBot extends common.BaseBot> = {
@@ -102,12 +103,6 @@ export type MessagePayloads<TBot extends common.BaseBot> = {
102
103
  user: client.User;
103
104
  conversation: client.Conversation;
104
105
  event: client.Event;
105
- states: {
106
- [TState in utils.StringKeys<TBot['states']>]: {
107
- type: 'user' | 'conversation' | 'bot';
108
- payload: TBot['states'][TState];
109
- };
110
- };
111
106
  };
112
107
  };
113
108
  export type MessageHandlers<TBot extends common.BaseBot> = {
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_PREFIX_SEPARATOR = "#";
@@ -169,8 +169,11 @@ export type FooBarBazBot = DefaultBot<{
169
169
  };
170
170
  states: {
171
171
  currentUser: {
172
- name: string;
173
- age: number;
172
+ type: 'conversation';
173
+ payload: {
174
+ name: string;
175
+ age: number;
176
+ };
174
177
  };
175
178
  };
176
179
  workflows: {
@@ -221,6 +224,32 @@ export type FooBarBazPlugin = DefaultPlugin<{
221
224
  };
222
225
  };
223
226
  };
227
+ states: {
228
+ alpha: {
229
+ type: 'conversation';
230
+ payload: {
231
+ alpha: string;
232
+ };
233
+ };
234
+ beta: {
235
+ type: 'user';
236
+ payload: {
237
+ beta: number;
238
+ };
239
+ };
240
+ gamma: {
241
+ type: 'bot';
242
+ payload: {
243
+ gamma: boolean;
244
+ };
245
+ };
246
+ delta: {
247
+ type: 'conversation';
248
+ payload: {
249
+ delta: null;
250
+ };
251
+ };
252
+ };
224
253
  }>;
225
254
  export type EmptyBot = DefaultBot<{
226
255
  integrations: {};