@botpress/sdk 2.5.0 → 3.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 +11 -5
- package/dist/bot/client/index.d.ts +6 -0
- package/dist/bot/client/types.d.ts +87 -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/types.d.ts +32 -26
- package/dist/bot/types/common.d.ts +6 -2
- package/dist/bot/types/generic.d.ts +110 -9
- 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/types.d.ts +2 -1
- package/dist/integration/definition/index.d.ts +48 -12
- package/dist/integration/definition/types.d.ts +6 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/integration/types/common.d.ts +0 -7
- 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/index.d.ts +1 -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/types/common.d.ts +41 -0
- package/dist/plugin/types/generic.d.ts +110 -2
- package/dist/plugin/types/index.d.ts +2 -0
- package/dist/serve.d.ts +2 -2
- 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/zui.d.ts +1 -0
- package/package.json +9 -5
- package/dist/bot/merge-bots.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/index.js.map +0 -7
|
@@ -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
|
};
|
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>;
|
|
@@ -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 {};
|
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,23 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
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.
|
|
19
|
+
"@botpress/client": "0.41.1",
|
|
20
|
+
"browser-or-node": "^2.1.1"
|
|
18
21
|
},
|
|
19
22
|
"devDependencies": {
|
|
20
23
|
"esbuild": "^0.16.12",
|
|
24
|
+
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
21
25
|
"tsup": "^8.0.2"
|
|
22
26
|
},
|
|
23
27
|
"peerDependencies": {
|
package/dist/bot/merge-bots.d.ts
DELETED