@botpress/sdk 2.4.3 → 3.0.0
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 +11 -5
- package/dist/base-logger.d.ts +0 -0
- package/dist/bot/bot-logger.d.ts +0 -0
- package/dist/bot/client/index.d.ts +6 -0
- package/dist/bot/client/types.d.ts +87 -0
- package/dist/bot/client/types.test.d.ts +0 -0
- package/dist/bot/definition.d.ts +17 -9
- package/dist/bot/implementation.d.ts +11 -10
- package/dist/bot/index.d.ts +1 -1
- package/dist/bot/server/context.d.ts +0 -0
- package/dist/bot/server/index.d.ts +0 -0
- package/dist/bot/server/types.d.ts +32 -26
- package/dist/bot/server/types.test.d.ts +0 -0
- package/dist/bot/types/common.d.ts +6 -2
- package/dist/bot/types/common.test.d.ts +0 -0
- package/dist/bot/types/generic.d.ts +110 -9
- package/dist/bot/types/generic.test.d.ts +0 -0
- package/dist/bot/types/index.d.ts +0 -0
- package/dist/const.d.ts +0 -0
- package/dist/fixtures.d.ts +49 -0
- package/dist/index.cjs +129 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +123 -0
- package/dist/index.mjs.map +7 -0
- package/dist/integration/client/index.d.ts +0 -0
- package/dist/integration/client/types.d.ts +2 -1
- package/dist/integration/client/types.test.d.ts +0 -0
- package/dist/integration/definition/branded-schema.d.ts +0 -0
- package/dist/integration/definition/generic.d.ts +0 -0
- package/dist/integration/definition/index.d.ts +53 -12
- package/dist/integration/definition/types.d.ts +6 -1
- package/dist/integration/implementation.d.ts +0 -0
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/server/action-metadata.d.ts +0 -0
- package/dist/integration/server/context.d.ts +0 -0
- package/dist/integration/server/index.d.ts +0 -0
- package/dist/integration/server/integration-logger.d.ts +0 -0
- package/dist/integration/server/types.d.ts +0 -0
- package/dist/integration/types/common.d.ts +0 -7
- package/dist/integration/types/generic.d.ts +0 -0
- package/dist/integration/types/generic.test.d.ts +0 -0
- package/dist/integration/types/index.d.ts +0 -0
- package/dist/interface/definition.d.ts +0 -2
- package/dist/interface/index.d.ts +1 -0
- package/dist/interface/resolve.d.ts +18 -0
- package/dist/interface/types/generic.d.ts +0 -0
- package/dist/interface/types/generic.test.d.ts +0 -0
- package/dist/interface/types/index.d.ts +1 -0
- package/dist/log.d.ts +0 -0
- package/dist/message.d.ts +0 -0
- package/dist/package.d.ts +4 -2
- package/dist/plugin/action-proxy/index.d.ts +2 -0
- package/dist/plugin/action-proxy/proxy.d.ts +5 -0
- package/dist/plugin/action-proxy/types.d.ts +14 -0
- package/dist/plugin/action-proxy/types.test.d.ts +1 -0
- package/dist/plugin/definition.d.ts +11 -6
- package/dist/plugin/implementation.d.ts +21 -15
- package/dist/plugin/index.d.ts +2 -1
- package/dist/plugin/interface-resolution.d.ts +15 -0
- package/dist/plugin/server/index.d.ts +1 -0
- package/dist/plugin/server/types.d.ts +241 -1
- package/dist/plugin/server/types.test.d.ts +0 -0
- package/dist/plugin/types/common.d.ts +41 -0
- package/dist/plugin/types/generic.d.ts +110 -2
- package/dist/plugin/types/generic.test.d.ts +0 -0
- package/dist/plugin/types/index.d.ts +2 -0
- package/dist/retry.d.ts +0 -0
- package/dist/schema.d.ts +0 -0
- package/dist/serve.d.ts +2 -2
- package/dist/utils/array-utils.d.ts +0 -0
- package/dist/utils/index.d.ts +0 -0
- package/dist/utils/record-utils.d.ts +2 -0
- package/dist/utils/record-utils.test.d.ts +1 -0
- package/dist/utils/type-utils.d.ts +15 -0
- package/dist/utils/type-utils.test.d.ts +0 -0
- package/dist/zui.d.ts +1 -0
- package/package.json +18 -8
- package/dist/bot/merge-bots.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/index.js.map +0 -7
|
@@ -1 +1,241 @@
|
|
|
1
|
-
|
|
1
|
+
import * as client from '@botpress/client';
|
|
2
|
+
import * as bot from '../../bot';
|
|
3
|
+
import * as utils from '../../utils/type-utils';
|
|
4
|
+
import * as proxy from '../action-proxy';
|
|
5
|
+
import * as types from '../types';
|
|
6
|
+
type EnumeratePluginEvents<TPlugin extends types.BasePlugin> = bot.EnumerateEvents<TPlugin> & types.EnumerateInterfaceEvents<TPlugin>;
|
|
7
|
+
type _IncomingEvents<TPlugin extends types.BasePlugin> = {
|
|
8
|
+
[K in keyof EnumeratePluginEvents<TPlugin>]: utils.Merge<client.Event, {
|
|
9
|
+
type: K;
|
|
10
|
+
payload: EnumeratePluginEvents<TPlugin>[K];
|
|
11
|
+
}>;
|
|
12
|
+
};
|
|
13
|
+
type _IncomingMessages<TPlugin extends types.BasePlugin> = {
|
|
14
|
+
[K in keyof bot.GetMessages<TPlugin>]: utils.Merge<client.Message, {
|
|
15
|
+
type: K;
|
|
16
|
+
payload: bot.GetMessages<TPlugin>[K];
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
type _IncomingStates<TPlugin extends types.BasePlugin> = {
|
|
20
|
+
[K in keyof bot.EnumerateStates<TPlugin>]: utils.Merge<client.State, {
|
|
21
|
+
name: K;
|
|
22
|
+
payload: bot.EnumerateStates<TPlugin>[K];
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
type _OutgoingMessageRequests<TPlugin extends types.BasePlugin> = {
|
|
26
|
+
[K in keyof bot.GetMessages<TPlugin>]: utils.Merge<client.ClientInputs['createMessage'], {
|
|
27
|
+
type: K;
|
|
28
|
+
payload: bot.GetMessages<TPlugin>[K];
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
type _OutgoingMessageResponses<TPlugin extends types.BasePlugin> = {
|
|
32
|
+
[K in keyof bot.GetMessages<TPlugin>]: utils.Merge<client.ClientOutputs['createMessage'], {
|
|
33
|
+
message: utils.Merge<client.Message, {
|
|
34
|
+
type: K;
|
|
35
|
+
payload: bot.GetMessages<TPlugin>[K];
|
|
36
|
+
}>;
|
|
37
|
+
}>;
|
|
38
|
+
};
|
|
39
|
+
type _OutgoingCallActionRequests<TPlugin extends types.BasePlugin> = {
|
|
40
|
+
[K in keyof bot.EnumerateActionInputs<TPlugin>]: utils.Merge<client.ClientInputs['callAction'], {
|
|
41
|
+
type: K;
|
|
42
|
+
input: bot.EnumerateActionInputs<TPlugin>[K];
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
type _OutgoingCallActionResponses<TPlugin extends types.BasePlugin> = {
|
|
46
|
+
[K in keyof bot.EnumerateActionOutputs<TPlugin>]: utils.Merge<client.ClientOutputs['callAction'], {
|
|
47
|
+
output: bot.EnumerateActionOutputs<TPlugin>[K];
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
export type AnyIncomingEvent<_TPlugin extends types.BasePlugin> = client.Event;
|
|
51
|
+
export type AnyIncomingMessage<_TPlugin extends types.BasePlugin> = client.Message;
|
|
52
|
+
export type AnyOutgoingMessageRequest<_TPlugin extends types.BasePlugin> = client.ClientInputs['createMessage'];
|
|
53
|
+
export type AnyOutgoingMessageResponse<_TPlugin extends types.BasePlugin> = client.ClientOutputs['createMessage'];
|
|
54
|
+
export type AnyOutgoingCallActionRequest<_TPlugin extends types.BasePlugin> = client.ClientInputs['callAction'];
|
|
55
|
+
export type AnyOutgoingCallActionResponse<_TPlugin extends types.BasePlugin> = client.ClientOutputs['callAction'];
|
|
56
|
+
export type IncomingEvents<TPlugin extends types.BasePlugin> = _IncomingEvents<TPlugin> & {
|
|
57
|
+
'*': AnyIncomingEvent<TPlugin>;
|
|
58
|
+
};
|
|
59
|
+
export type IncomingMessages<TPlugin extends types.BasePlugin> = _IncomingMessages<TPlugin> & {
|
|
60
|
+
'*': AnyIncomingMessage<TPlugin>;
|
|
61
|
+
};
|
|
62
|
+
export type IncomingStates<_TPlugin extends types.BasePlugin> = _IncomingStates<_TPlugin> & {
|
|
63
|
+
'*': client.State;
|
|
64
|
+
};
|
|
65
|
+
export type OutgoingMessageRequests<TPlugin extends types.BasePlugin> = _OutgoingMessageRequests<TPlugin> & {
|
|
66
|
+
'*': AnyOutgoingMessageRequest<TPlugin>;
|
|
67
|
+
};
|
|
68
|
+
export type OutgoingMessageResponses<TPlugin extends types.BasePlugin> = _OutgoingMessageResponses<TPlugin> & {
|
|
69
|
+
'*': AnyOutgoingMessageResponse<TPlugin>;
|
|
70
|
+
};
|
|
71
|
+
export type OutgoingCallActionRequests<TPlugin extends types.BasePlugin> = _OutgoingCallActionRequests<TPlugin> & {
|
|
72
|
+
'*': AnyOutgoingCallActionRequest<TPlugin>;
|
|
73
|
+
};
|
|
74
|
+
export type OutgoingCallActionResponses<TPlugin extends types.BasePlugin> = _OutgoingCallActionResponses<TPlugin> & {
|
|
75
|
+
'*': AnyOutgoingCallActionResponse<TPlugin>;
|
|
76
|
+
};
|
|
77
|
+
export type PluginClient<_TPlugin extends types.BasePlugin> = bot.BotSpecificClient<types.BasePlugin>;
|
|
78
|
+
export type PluginConfiguration<TPlugin extends types.BasePlugin> = TPlugin['configuration'];
|
|
79
|
+
export type CommonHandlerProps<TPlugin extends types.BasePlugin> = {
|
|
80
|
+
ctx: bot.BotContext;
|
|
81
|
+
logger: bot.BotLogger;
|
|
82
|
+
client: PluginClient<TPlugin>;
|
|
83
|
+
configuration: PluginConfiguration<TPlugin>;
|
|
84
|
+
interfaces: types.PluginInterfaceExtensions<TPlugin>;
|
|
85
|
+
actions: proxy.ActionProxy<TPlugin>;
|
|
86
|
+
};
|
|
87
|
+
export type MessagePayloads<TPlugin extends types.BasePlugin> = {
|
|
88
|
+
[K in keyof IncomingMessages<TPlugin>]: CommonHandlerProps<TPlugin> & {
|
|
89
|
+
message: IncomingMessages<TPlugin>[K];
|
|
90
|
+
user: client.User;
|
|
91
|
+
conversation: client.Conversation;
|
|
92
|
+
event: client.Event;
|
|
93
|
+
states: {
|
|
94
|
+
[TState in keyof TPlugin['states']]: {
|
|
95
|
+
type: 'user' | 'conversation' | 'bot';
|
|
96
|
+
payload: TPlugin['states'][TState];
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export type MessageHandlers<TPlugin extends types.BasePlugin> = {
|
|
102
|
+
[K in keyof IncomingMessages<TPlugin>]: (args: MessagePayloads<TPlugin>[K]) => Promise<void>;
|
|
103
|
+
};
|
|
104
|
+
export type EventPayloads<TPlugin extends types.BasePlugin> = {
|
|
105
|
+
[K in keyof IncomingEvents<TPlugin>]: CommonHandlerProps<TPlugin> & {
|
|
106
|
+
event: IncomingEvents<TPlugin>[K];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export type EventHandlers<TPlugin extends types.BasePlugin> = {
|
|
110
|
+
[K in keyof IncomingEvents<TPlugin>]: (args: EventPayloads<TPlugin>[K]) => Promise<void>;
|
|
111
|
+
};
|
|
112
|
+
export type StateExpiredPayloads<TPlugin extends types.BasePlugin> = {
|
|
113
|
+
[K in keyof IncomingStates<TPlugin>]: CommonHandlerProps<TPlugin> & {
|
|
114
|
+
state: IncomingStates<TPlugin>[K];
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export type StateExpiredHandlers<TPlugin extends types.BasePlugin> = {
|
|
118
|
+
[K in keyof IncomingStates<TPlugin>]: (args: StateExpiredPayloads<TPlugin>[K]) => Promise<void>;
|
|
119
|
+
};
|
|
120
|
+
export type ActionHandlerPayloads<TPlugin extends types.BasePlugin> = {
|
|
121
|
+
[K in keyof TPlugin['actions']]: CommonHandlerProps<TPlugin> & {
|
|
122
|
+
type?: K;
|
|
123
|
+
input: TPlugin['actions'][K]['input'];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export type ActionHandlers<TPlugin extends types.BasePlugin> = {
|
|
127
|
+
[K in keyof TPlugin['actions']]: (props: ActionHandlerPayloads<TPlugin>[K]) => Promise<TPlugin['actions'][K]['output']>;
|
|
128
|
+
};
|
|
129
|
+
type BaseHookDefinition = {
|
|
130
|
+
stoppable?: boolean;
|
|
131
|
+
data: any;
|
|
132
|
+
};
|
|
133
|
+
type HookDefinition<THookDef extends BaseHookDefinition = BaseHookDefinition> = THookDef;
|
|
134
|
+
/**
|
|
135
|
+
* TODO: add hooks for:
|
|
136
|
+
* - before_register
|
|
137
|
+
* - after_register
|
|
138
|
+
* - before_state_expired
|
|
139
|
+
* - after_state_expired
|
|
140
|
+
* - before_incoming_call_action
|
|
141
|
+
* - after_incoming_call_action
|
|
142
|
+
*/
|
|
143
|
+
export type HookDefinitionType = keyof HookDefinitions<types.BasePlugin>;
|
|
144
|
+
export type HookDefinitions<TPlugin extends types.BasePlugin> = {
|
|
145
|
+
before_incoming_event: HookDefinition<{
|
|
146
|
+
stoppable: true;
|
|
147
|
+
data: _IncomingEvents<TPlugin> & {
|
|
148
|
+
'*': AnyIncomingEvent<TPlugin>;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
before_incoming_message: HookDefinition<{
|
|
152
|
+
stoppable: true;
|
|
153
|
+
data: _IncomingMessages<TPlugin> & {
|
|
154
|
+
'*': AnyIncomingMessage<TPlugin>;
|
|
155
|
+
};
|
|
156
|
+
}>;
|
|
157
|
+
before_outgoing_message: HookDefinition<{
|
|
158
|
+
stoppable: false;
|
|
159
|
+
data: _OutgoingMessageRequests<TPlugin> & {
|
|
160
|
+
'*': AnyOutgoingMessageRequest<TPlugin>;
|
|
161
|
+
};
|
|
162
|
+
}>;
|
|
163
|
+
before_outgoing_call_action: HookDefinition<{
|
|
164
|
+
stoppable: false;
|
|
165
|
+
data: _OutgoingCallActionRequests<TPlugin> & {
|
|
166
|
+
'*': AnyOutgoingCallActionRequest<TPlugin>;
|
|
167
|
+
};
|
|
168
|
+
}>;
|
|
169
|
+
after_incoming_event: HookDefinition<{
|
|
170
|
+
stoppable: true;
|
|
171
|
+
data: _IncomingEvents<TPlugin> & {
|
|
172
|
+
'*': AnyIncomingEvent<TPlugin>;
|
|
173
|
+
};
|
|
174
|
+
}>;
|
|
175
|
+
after_incoming_message: HookDefinition<{
|
|
176
|
+
stoppable: true;
|
|
177
|
+
data: _IncomingMessages<TPlugin> & {
|
|
178
|
+
'*': AnyIncomingMessage<TPlugin>;
|
|
179
|
+
};
|
|
180
|
+
}>;
|
|
181
|
+
after_outgoing_message: HookDefinition<{
|
|
182
|
+
stoppable: false;
|
|
183
|
+
data: _OutgoingMessageResponses<TPlugin> & {
|
|
184
|
+
'*': AnyOutgoingMessageResponse<TPlugin>;
|
|
185
|
+
};
|
|
186
|
+
}>;
|
|
187
|
+
after_outgoing_call_action: HookDefinition<{
|
|
188
|
+
stoppable: false;
|
|
189
|
+
data: _OutgoingCallActionResponses<TPlugin> & {
|
|
190
|
+
'*': AnyOutgoingCallActionResponse<TPlugin>;
|
|
191
|
+
};
|
|
192
|
+
}>;
|
|
193
|
+
};
|
|
194
|
+
export type HookData<TPlugin extends types.BasePlugin> = {
|
|
195
|
+
[H in keyof HookDefinitions<TPlugin>]: {
|
|
196
|
+
[T in keyof HookDefinitions<TPlugin>[H]['data']]: HookDefinitions<TPlugin>[H]['data'][T];
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
export type HookInputs<TPlugin extends types.BasePlugin> = {
|
|
200
|
+
[H in keyof HookData<TPlugin>]: {
|
|
201
|
+
[T in keyof HookData<TPlugin>[H]]: CommonHandlerProps<TPlugin> & {
|
|
202
|
+
data: HookData<TPlugin>[H][T];
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
export type HookOutputs<TPlugin extends types.BasePlugin> = {
|
|
207
|
+
[H in keyof HookData<TPlugin>]: {
|
|
208
|
+
[T in keyof HookData<TPlugin>[H]]: {
|
|
209
|
+
data?: HookData<TPlugin>[H][T];
|
|
210
|
+
} & (HookDefinitions<TPlugin>[H]['stoppable'] extends true ? {
|
|
211
|
+
stop?: boolean;
|
|
212
|
+
} : {});
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
export type HookHandlers<TPlugin extends types.BasePlugin> = {
|
|
216
|
+
[H in keyof HookData<TPlugin>]: {
|
|
217
|
+
[T in keyof HookData<TPlugin>[H]]: (input: HookInputs<TPlugin>[H][T]) => Promise<HookOutputs<TPlugin>[H][T] | undefined>;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export type MessageHandlersMap<TPlugin extends types.BasePlugin> = {
|
|
221
|
+
[T in keyof IncomingMessages<TPlugin>]?: MessageHandlers<TPlugin>[T][];
|
|
222
|
+
};
|
|
223
|
+
export type EventHandlersMap<TPlugin extends types.BasePlugin> = {
|
|
224
|
+
[T in keyof IncomingEvents<TPlugin>]?: EventHandlers<TPlugin>[T][];
|
|
225
|
+
};
|
|
226
|
+
export type StateExpiredHandlersMap<TPlugin extends types.BasePlugin> = {
|
|
227
|
+
[T in keyof IncomingStates<TPlugin>]?: StateExpiredHandlers<TPlugin>[T][];
|
|
228
|
+
};
|
|
229
|
+
export type HookHandlersMap<TPlugin extends types.BasePlugin> = {
|
|
230
|
+
[H in keyof HookData<TPlugin>]: {
|
|
231
|
+
[T in keyof HookData<TPlugin>[H]]?: HookHandlers<TPlugin>[H][T][];
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
export type PluginHandlers<TPlugin extends types.BasePlugin> = {
|
|
235
|
+
actionHandlers: ActionHandlers<TPlugin>;
|
|
236
|
+
messageHandlers: MessageHandlersMap<TPlugin>;
|
|
237
|
+
eventHandlers: EventHandlersMap<TPlugin>;
|
|
238
|
+
stateExpiredHandlers: StateExpiredHandlersMap<TPlugin>;
|
|
239
|
+
hookHandlers: HookHandlersMap<TPlugin>;
|
|
240
|
+
};
|
|
241
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseInterface } from '../../interface';
|
|
2
|
+
import { Cast, Join, UnionToIntersection } from '../../utils/type-utils';
|
|
3
|
+
import { BasePlugin } from './generic';
|
|
4
|
+
type EventKey<TIntegrationName extends string, TEventName extends string> = string extends TIntegrationName ? string : string extends TEventName ? string : Join<[TIntegrationName, ':', TEventName]>;
|
|
5
|
+
export type EnumerateInterfaceEvents<TPlugin extends BasePlugin> = UnionToIntersection<{
|
|
6
|
+
[TInterfaceName in keyof TPlugin['interfaces']]: {
|
|
7
|
+
[TEventName in keyof TPlugin['interfaces'][TInterfaceName]['events'] as EventKey<Cast<TInterfaceName, string>, Cast<TEventName, string>>]: TPlugin['interfaces'][TInterfaceName]['events'][TEventName];
|
|
8
|
+
};
|
|
9
|
+
}[keyof TPlugin['interfaces']]>;
|
|
10
|
+
/**
|
|
11
|
+
* Used by a bot to tell the plugin what integration should be used to implement an interface.
|
|
12
|
+
*/
|
|
13
|
+
export type PluginInterfaceExtension<TInterface extends BaseInterface = BaseInterface> = {
|
|
14
|
+
id?: string;
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
entities: {
|
|
18
|
+
[K in keyof TInterface['entities']]: {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
actions: {
|
|
23
|
+
[K in keyof TInterface['actions']]: {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
events: {
|
|
28
|
+
[K in keyof TInterface['events']]: {
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
channels: {
|
|
33
|
+
[K in keyof TInterface['channels']]: {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type PluginInterfaceExtensions<TPlugin extends BasePlugin = BasePlugin> = {
|
|
39
|
+
[K in keyof TPlugin['interfaces']]: PluginInterfaceExtension<TPlugin['interfaces'][K]>;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
@@ -5,6 +5,114 @@ export type BaseAction = {
|
|
|
5
5
|
input: any;
|
|
6
6
|
output: any;
|
|
7
7
|
};
|
|
8
|
+
export type BaseTable = {
|
|
9
|
+
/**
|
|
10
|
+
* Required. This name is used to identify your table.
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* The 'factor' multiplies the row's data storage limit by 4KB and its quota count, but can only be set at table creation and not modified later. For instance, a factor of 2 increases storage to 8KB but counts as 2 rows in your quota. The default factor is 1.
|
|
15
|
+
*/
|
|
16
|
+
factor?: number;
|
|
17
|
+
/**
|
|
18
|
+
* A table designated as "frozen" is immutable in terms of its name and schema structure; modifications to its schema or a renaming operation are not permitted. The only action that can be taken on such a table is deletion. The schema established at the time of creation is locked in as the final structure. To implement any changes, the table must be duplicated with the desired alterations.
|
|
19
|
+
*/
|
|
20
|
+
frozen?: boolean;
|
|
21
|
+
schema: {
|
|
22
|
+
$schema?: string;
|
|
23
|
+
/**
|
|
24
|
+
* List of keys/columns in the table.
|
|
25
|
+
*/
|
|
26
|
+
properties: {
|
|
27
|
+
[k: string]: {
|
|
28
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
|
|
29
|
+
format?: 'date-time';
|
|
30
|
+
description?: string;
|
|
31
|
+
/**
|
|
32
|
+
* String properties must match this pattern
|
|
33
|
+
*/
|
|
34
|
+
pattern?: string;
|
|
35
|
+
/**
|
|
36
|
+
* String properties must be one of these values
|
|
37
|
+
*/
|
|
38
|
+
enum?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Defines the shape of items in an array
|
|
41
|
+
*/
|
|
42
|
+
items?: {
|
|
43
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
|
|
44
|
+
[k: string]: any;
|
|
45
|
+
};
|
|
46
|
+
nullable?: boolean;
|
|
47
|
+
properties?: {
|
|
48
|
+
[k: string]: {
|
|
49
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'null';
|
|
50
|
+
[k: string]: any;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
'x-zui': {
|
|
54
|
+
index: number;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates if the column is vectorized and searchable.
|
|
57
|
+
*/
|
|
58
|
+
searchable?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Indicates if the field is hidden in the UI
|
|
61
|
+
*/
|
|
62
|
+
hidden?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Order of the column in the UI
|
|
65
|
+
*/
|
|
66
|
+
order?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Width of the column in the UI
|
|
69
|
+
*/
|
|
70
|
+
width?: number;
|
|
71
|
+
computed?: {
|
|
72
|
+
action: 'ai' | 'code' | 'workflow';
|
|
73
|
+
dependencies?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Prompt when action is "ai"
|
|
76
|
+
*/
|
|
77
|
+
prompt?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Code to execute when action is "code"
|
|
80
|
+
*/
|
|
81
|
+
code?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Model to use when action is "ai"
|
|
84
|
+
*/
|
|
85
|
+
model?: string;
|
|
86
|
+
/**
|
|
87
|
+
* ID of Workflow to execute when action is "workflow"
|
|
88
|
+
*/
|
|
89
|
+
workflowId?: string;
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Additional properties can be provided, but they will be ignored if no column matches.
|
|
97
|
+
*/
|
|
98
|
+
additionalProperties: true;
|
|
99
|
+
/**
|
|
100
|
+
* Array of required properties.
|
|
101
|
+
*/
|
|
102
|
+
required?: string[];
|
|
103
|
+
type: 'object';
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Optional tags to help organize your tables. These should be passed here as an object representing key/value pairs.
|
|
107
|
+
*/
|
|
108
|
+
tags?: {
|
|
109
|
+
[k: string]: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Indicates if the table is enabled for computation.
|
|
113
|
+
*/
|
|
114
|
+
isComputeEnabled?: boolean;
|
|
115
|
+
};
|
|
8
116
|
export type BasePlugin = {
|
|
9
117
|
configuration: any;
|
|
10
118
|
integrations: Record<string, BaseIntegration>;
|
|
@@ -12,7 +120,7 @@ export type BasePlugin = {
|
|
|
12
120
|
events: Record<string, any>;
|
|
13
121
|
states: Record<string, any>;
|
|
14
122
|
actions: Record<string, BaseAction>;
|
|
15
|
-
|
|
123
|
+
tables: Record<string, BaseTable>;
|
|
16
124
|
};
|
|
17
125
|
export type InputBasePlugin = utils.DeepPartial<BasePlugin>;
|
|
18
126
|
export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
|
|
@@ -20,7 +128,7 @@ export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
|
|
|
20
128
|
events: utils.Default<B['events'], BasePlugin['events']>;
|
|
21
129
|
states: utils.Default<B['states'], BasePlugin['states']>;
|
|
22
130
|
actions: utils.Default<B['actions'], BasePlugin['actions']>;
|
|
23
|
-
|
|
131
|
+
tables: utils.Default<B['tables'], BasePlugin['tables']>;
|
|
24
132
|
integrations: undefined extends B['integrations'] ? BasePlugin['integrations'] : {
|
|
25
133
|
[K in keyof B['integrations']]: DefaultIntegration<utils.Cast<B['integrations'][K], InputBaseIntegration>>;
|
|
26
134
|
};
|
|
File without changes
|
package/dist/retry.d.ts
CHANGED
|
File without changes
|
package/dist/schema.d.ts
CHANGED
|
File without changes
|
package/dist/serve.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as http from 'node:http';
|
|
2
2
|
export type Request = {
|
|
3
3
|
body?: string;
|
|
4
4
|
path: string;
|
|
@@ -17,4 +17,4 @@ export type Response = {
|
|
|
17
17
|
};
|
|
18
18
|
export type Handler = (req: Request) => Promise<Response | void>;
|
|
19
19
|
export declare function parseBody<T>(req: Request): T;
|
|
20
|
-
export declare function serve(handler: Handler, port?: number, callback?: (port: number) => void): Promise<Server>;
|
|
20
|
+
export declare function serve(handler: Handler, port?: number, callback?: (port: number) => void): Promise<http.Server>;
|
|
File without changes
|
package/dist/utils/index.d.ts
CHANGED
|
File without changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare const pairs: <K extends string, V>(obj: Record<K, V>) => [K, V][];
|
|
2
2
|
export declare const values: <K extends string, V>(obj: Record<K, V>) => V[];
|
|
3
3
|
export declare const mapValues: <K extends string, V, R>(obj: Record<K, V>, fn: (value: V, key: K) => R) => Record<K, R>;
|
|
4
|
+
export declare const stripUndefinedProps: <K extends string, V>(obj: Record<K, V | undefined>) => Record<K, V>;
|
|
5
|
+
export declare const mergeRecords: <K extends string, V>(a: Record<K, V>, b: Record<K, V>, merge: (v1: V, v2: V) => V) => Record<K, V>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,11 +6,25 @@ export type Writable<T> = {
|
|
|
6
6
|
-readonly [K in keyof T]: T[K];
|
|
7
7
|
};
|
|
8
8
|
export type Default<T, U> = undefined extends T ? U : T;
|
|
9
|
+
export type AtLeastOne<T> = [T, ...T[]];
|
|
10
|
+
export type AtLeastOneProperty<T> = {
|
|
11
|
+
[K in keyof T]?: T[K];
|
|
12
|
+
} & {
|
|
13
|
+
[K in keyof T]: Pick<T, K>;
|
|
14
|
+
}[keyof T];
|
|
15
|
+
export type ExactlyOneProperty<T> = {
|
|
16
|
+
[K in keyof T]: {
|
|
17
|
+
[P in K]: T[P];
|
|
18
|
+
} & {
|
|
19
|
+
[P in Exclude<keyof T, K>]?: never;
|
|
20
|
+
};
|
|
21
|
+
}[keyof T];
|
|
9
22
|
export type IsExtend<X, Y> = X extends Y ? true : false;
|
|
10
23
|
export type IsEquivalent<X, Y> = IsExtend<X, Y> extends true ? IsExtend<Y, X> : false;
|
|
11
24
|
export type IsIdentical<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
12
25
|
export type IsEqual<X, Y> = IsIdentical<Normalize<X>, Normalize<Y>>;
|
|
13
26
|
export type AssertExtends<_A extends B, B> = true;
|
|
27
|
+
export type AssertNotExtends<A, B> = A extends B ? false : true;
|
|
14
28
|
export type AssertTrue<_T extends true> = true;
|
|
15
29
|
export type AssertAll<_T extends true[]> = true;
|
|
16
30
|
export type Join<S extends (string | number | symbol)[]> = S extends [infer H, ...infer T] ? `${Cast<H, string>}${Join<Cast<T, string[]>>}` : S extends [infer H] ? Cast<H, string> : '';
|
|
@@ -30,4 +44,5 @@ type DeepPartialObject<T extends object> = T extends infer O ? {
|
|
|
30
44
|
[K in keyof O]?: DeepPartial<O[K]>;
|
|
31
45
|
} : never;
|
|
32
46
|
export type DeepPartial<T> = T extends (...args: infer A) => infer R ? (...args: DeepPartial<A>) => DeepPartial<R> : T extends Array<infer E> ? Array<DeepPartial<E>> : T extends ReadonlyArray<infer E> ? ReadonlyArray<DeepPartial<E>> : T extends Promise<infer R> ? Promise<DeepPartial<R>> : T extends Buffer ? Buffer : T extends object ? DeepPartialObject<T> : T;
|
|
47
|
+
export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
|
|
33
48
|
export {};
|
|
File without changes
|
package/dist/zui.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { z } from '@bpinternal/zui';
|
|
|
2
2
|
export * from '@bpinternal/zui';
|
|
3
3
|
export type GenericZuiSchema<A extends Record<string, z.ZodTypeAny> = Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny = z.ZodTypeAny> = (typeArguments: A) => R;
|
|
4
4
|
export type ZuiObjectSchema = z.ZodObject | z.ZodRecord;
|
|
5
|
+
export declare const mergeObjectSchemas: (a: ZuiObjectSchema, b: ZuiObjectSchema) => ZuiObjectSchema;
|
|
5
6
|
export default z;
|
package/package.json
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Botpress SDK",
|
|
5
|
-
"main": "./dist/index.
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"check:type": "tsc --noEmit",
|
|
9
10
|
"build:type": "tsc --emitDeclarationOnly --declaration",
|
|
10
|
-
"build:
|
|
11
|
-
"build": "
|
|
11
|
+
"build:browser": "ts-node -T ./build.ts --browser",
|
|
12
|
+
"build:node": "ts-node -T ./build.ts --node",
|
|
13
|
+
"build": "pnpm build:type && pnpm build:node && pnpm build:browser"
|
|
12
14
|
},
|
|
13
15
|
"keywords": [],
|
|
14
16
|
"author": "",
|
|
15
17
|
"license": "MIT",
|
|
16
18
|
"dependencies": {
|
|
17
|
-
"@botpress/client": "0.41.0"
|
|
18
|
-
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"@bpinternal/zui": "^0.13.5"
|
|
19
|
+
"@botpress/client": "0.41.0",
|
|
20
|
+
"browser-or-node": "^2.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"esbuild": "^0.16.12",
|
|
24
|
+
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
24
25
|
"tsup": "^8.0.2"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@bpinternal/zui": "^0.13.5",
|
|
29
|
+
"esbuild": "^0.16.12"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"esbuild": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
25
35
|
}
|
|
26
36
|
}
|
package/dist/bot/merge-bots.d.ts
DELETED