@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.
- package/.turbo/turbo-build.log +4 -4
- package/dist/bot/client/types.d.ts +10 -9
- package/dist/bot/common/generic.d.ts +6 -1
- package/dist/bot/server/types.d.ts +2 -7
- package/dist/consts.d.ts +1 -0
- package/dist/fixtures.d.ts +31 -2
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +16 -16
- package/dist/index.mjs.map +4 -4
- package/dist/integration/client/types.d.ts +10 -4
- package/dist/integration/common/generic.d.ts +6 -1
- package/dist/integration/definition/types.d.ts +2 -1
- package/dist/message.d.ts +44 -44
- package/dist/plugin/action-proxy/proxy.d.ts +2 -2
- package/dist/plugin/common/generic.d.ts +6 -1
- package/dist/plugin/common/types.d.ts +6 -0
- package/dist/plugin/implementation.d.ts +2 -7
- package/dist/plugin/server/types.d.ts +3 -8
- package/dist/plugin/state-proxy/index.d.ts +2 -0
- package/dist/plugin/state-proxy/proxy.d.ts +5 -0
- package/dist/plugin/state-proxy/types.d.ts +25 -0
- package/dist/plugin/state-proxy/types.test.d.ts +1 -0
- package/dist/utils/type-utils.d.ts +14 -1
- package/package.json +2 -2
- package/readme.md +1 -48
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @botpress/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@
|
|
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@
|
|
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@
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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,
|
|
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
|
-
|
|
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> = {
|
package/dist/consts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PLUGIN_PREFIX_SEPARATOR = "#";
|
package/dist/fixtures.d.ts
CHANGED
|
@@ -169,8 +169,11 @@ export type FooBarBazBot = DefaultBot<{
|
|
|
169
169
|
};
|
|
170
170
|
states: {
|
|
171
171
|
currentUser: {
|
|
172
|
-
|
|
173
|
-
|
|
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: {};
|