@botpress/sdk 3.3.2 → 3.5.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/dist/package.d.ts CHANGED
@@ -40,6 +40,7 @@ type PluginPackageDefinition = NameVersion & {
40
40
  recurringEvents?: Record<string, plugin.RecurringEventDefinition>;
41
41
  actions?: Record<string, plugin.ActionDefinition>;
42
42
  tables?: Record<string, plugin.TableDefinition>;
43
+ workflows?: Record<string, plugin.WorkflowDefinition>;
43
44
  };
44
45
  export type IntegrationPackage = PackageReference & {
45
46
  type: 'integration';
@@ -6,114 +6,18 @@ export type BaseAction = {
6
6
  output: any;
7
7
  };
8
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
- */
9
+ [k: string]: any;
10
+ };
11
+ export type BaseWorkflow = {
12
+ input: any;
13
+ output: any;
108
14
  tags?: {
109
15
  [k: string]: string;
110
16
  };
111
- /**
112
- * Indicates if the table is enabled for computation.
113
- */
114
- isComputeEnabled?: boolean;
115
17
  };
116
18
  export type BasePlugin = {
19
+ name: string;
20
+ version: string;
117
21
  configuration: any;
118
22
  integrations: Record<string, BaseIntegration>;
119
23
  interfaces: Record<string, BaseInterface>;
@@ -121,14 +25,18 @@ export type BasePlugin = {
121
25
  states: Record<string, any>;
122
26
  actions: Record<string, BaseAction>;
123
27
  tables: Record<string, BaseTable>;
28
+ workflows: Record<string, BaseWorkflow>;
124
29
  };
125
30
  export type InputBasePlugin = utils.DeepPartial<BasePlugin>;
126
31
  export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
32
+ name: utils.Default<B['name'], BasePlugin['name']>;
33
+ version: utils.Default<B['version'], BasePlugin['version']>;
127
34
  configuration: utils.Default<B['configuration'], BasePlugin['configuration']>;
128
35
  events: utils.Default<B['events'], BasePlugin['events']>;
129
36
  states: utils.Default<B['states'], BasePlugin['states']>;
130
37
  actions: utils.Default<B['actions'], BasePlugin['actions']>;
131
38
  tables: utils.Default<B['tables'], BasePlugin['tables']>;
39
+ workflows: utils.Default<B['workflows'], BasePlugin['workflows']>;
132
40
  integrations: undefined extends B['integrations'] ? BasePlugin['integrations'] : {
133
41
  [K in keyof B['integrations']]: DefaultIntegration<utils.Cast<B['integrations'][K], InputBaseIntegration>>;
134
42
  };
@@ -1,7 +1,7 @@
1
- import { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition } from '../bot/definition';
1
+ import { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition, WorkflowDefinition } from '../bot/definition';
2
2
  import { IntegrationPackage, InterfacePackage } from '../package';
3
3
  import { ZuiObjectSchema } from '../zui';
4
- export { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition, IntegrationConfigInstance, } from '../bot/definition';
4
+ export { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition, IntegrationConfigInstance, WorkflowDefinition, } from '../bot/definition';
5
5
  type BaseConfig = ZuiObjectSchema;
6
6
  type BaseStates = Record<string, ZuiObjectSchema>;
7
7
  type BaseEvents = Record<string, ZuiObjectSchema>;
@@ -9,7 +9,8 @@ type BaseActions = Record<string, ZuiObjectSchema>;
9
9
  type BaseInterfaces = Record<string, any>;
10
10
  type BaseIntegrations = Record<string, any>;
11
11
  type BaseTables = Record<string, ZuiObjectSchema>;
12
- export type PluginDefinitionProps<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables> = {
12
+ type BaseWorkflows = Record<string, ZuiObjectSchema>;
13
+ export type PluginDefinitionProps<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables, TWorkflows extends BaseWorkflows = BaseWorkflows> = {
13
14
  name: TName;
14
15
  version: TVersion;
15
16
  title?: string;
@@ -39,9 +40,16 @@ export type PluginDefinitionProps<TName extends string = string, TVersion extend
39
40
  tables?: {
40
41
  [K in keyof TTables]: TableDefinition<TTables[K]>;
41
42
  };
43
+ /**
44
+ * # EXPERIMENTAL
45
+ * This API is experimental and may change in the future.
46
+ */
47
+ workflows?: {
48
+ [K in keyof TWorkflows]: WorkflowDefinition<TWorkflows[K]>;
49
+ };
42
50
  };
43
- export declare class PluginDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables> {
44
- readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables>;
51
+ export declare class PluginDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TStates extends BaseStates = BaseStates, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TInterfaces extends BaseInterfaces = BaseInterfaces, TIntegrations extends BaseIntegrations = BaseIntegrations, TTables extends BaseTables = BaseTables, TWorkflows extends BaseWorkflows = BaseWorkflows> {
52
+ readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>;
45
53
  readonly name: this['props']['name'];
46
54
  readonly version: this['props']['version'];
47
55
  readonly title: this['props']['title'];
@@ -59,5 +67,6 @@ export declare class PluginDefinition<TName extends string = string, TVersion ex
59
67
  readonly recurringEvents: this['props']['recurringEvents'];
60
68
  readonly actions: this['props']['actions'];
61
69
  readonly tables: this['props']['tables'];
62
- constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables>);
70
+ readonly workflows: this['props']['workflows'];
71
+ constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables, TWorkflows>);
63
72
  }
@@ -1,13 +1,23 @@
1
- import { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, ActionHandlers as BotActionHandlers, BotHandlers } from '../bot';
1
+ import type { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, ActionHandlers as BotActionHandlers, BotHandlers, WorkflowHandlersMap as BotWorkflowHandlersMap, WorkflowHandlersFnMap as BotWorkflowHandlersFnMap } from '../bot';
2
+ import { WorkflowProxy } from '../bot/workflow-proxy';
3
+ import { ActionProxy } from './action-proxy';
2
4
  import { BasePlugin, PluginInterfaceExtensions } from './common';
3
5
  import { MessageHandlersMap, MessageHandlers, EventHandlersMap, EventHandlers, StateExpiredHandlersMap, StateExpiredHandlers, HookData, HookHandlers, ActionHandlers, PluginConfiguration } from './server/types';
4
6
  export type PluginImplementationProps<TPlugin extends BasePlugin = BasePlugin> = {
5
7
  actions: ActionHandlers<TPlugin>;
6
8
  };
7
9
  export type PluginRuntimeProps<TPlugin extends BasePlugin = BasePlugin> = {
10
+ alias?: string;
8
11
  configuration: PluginConfiguration<TPlugin>;
9
12
  interfaces: PluginInterfaceExtensions<TPlugin>;
10
13
  };
14
+ type Tools<TPlugin extends BasePlugin = BasePlugin> = {
15
+ configuration: PluginConfiguration<TPlugin>;
16
+ interfaces: PluginInterfaceExtensions<TPlugin>;
17
+ actions: ActionProxy<TPlugin>;
18
+ workflows: WorkflowProxy<TPlugin>;
19
+ alias?: string;
20
+ };
11
21
  export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugin> implements BotHandlers<TPlugin> {
12
22
  readonly props: PluginImplementationProps<TPlugin>;
13
23
  private _runtimeProps;
@@ -16,8 +26,9 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
16
26
  private _eventHandlers;
17
27
  private _stateExpiredHandlers;
18
28
  private _hookHandlers;
29
+ private _workflowHandlers;
19
30
  constructor(props: PluginImplementationProps<TPlugin>);
20
- initialize(config: PluginRuntimeProps<TPlugin>): this;
31
+ initialize(props: PluginRuntimeProps<TPlugin>): this;
21
32
  private get _runtime();
22
33
  private _getTools;
23
34
  get actionHandlers(): BotActionHandlers<TPlugin>;
@@ -25,8 +36,14 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
25
36
  get eventHandlers(): BotEventHandlersMap<TPlugin>;
26
37
  get stateExpiredHandlers(): BotStateExpiredHandlersMap<TPlugin>;
27
38
  get hookHandlers(): BotHookHandlersMap<TPlugin>;
39
+ get workflowHandlers(): BotWorkflowHandlersMap<TPlugin>;
28
40
  readonly on: {
29
41
  message: <T extends keyof MessageHandlersMap<TPlugin>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
42
+ /**
43
+ * # EXPERIMENTAL
44
+ * This API is experimental and may change in the future.
45
+ */
46
+ workflows: BotWorkflowHandlersFnMap<TPlugin, Tools<TPlugin>>;
30
47
  event: <T extends keyof EventHandlersMap<TPlugin>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
31
48
  stateExpired: <T extends keyof StateExpiredHandlersMap<TPlugin>>(type: T, handler: StateExpiredHandlers<TPlugin>[T]) => void;
32
49
  beforeIncomingEvent: <T extends keyof HookData<TPlugin>["before_incoming_event"]>(type: T, handler: HookHandlers<TPlugin>["before_incoming_event"][T]) => void;
@@ -42,4 +59,6 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
42
59
  * checks if the actual event resolves to the target event
43
60
  */
44
61
  private _eventResolvesTo;
62
+ private _stripAliasPrefix;
45
63
  }
64
+ export {};
@@ -1,7 +1,8 @@
1
1
  import * as client from '@botpress/client';
2
2
  import * as bot from '../../bot';
3
+ import * as workflowProxy from '../../bot/workflow-proxy';
3
4
  import * as utils from '../../utils/type-utils';
4
- import * as proxy from '../action-proxy';
5
+ import * as actionProxy from '../action-proxy';
5
6
  import * as common from '../common';
6
7
  type EnumeratePluginEvents<TPlugin extends common.BasePlugin> = bot.EnumerateEvents<TPlugin> & common.EnumerateInterfaceEvents<TPlugin>;
7
8
  type _IncomingEvents<TPlugin extends common.BasePlugin> = {
@@ -82,7 +83,13 @@ export type CommonHandlerProps<TPlugin extends common.BasePlugin> = {
82
83
  client: PluginClient<TPlugin>;
83
84
  configuration: PluginConfiguration<TPlugin>;
84
85
  interfaces: common.PluginInterfaceExtensions<TPlugin>;
85
- actions: proxy.ActionProxy<TPlugin>;
86
+ actions: actionProxy.ActionProxy<TPlugin>;
87
+ /**
88
+ * # EXPERIMENTAL
89
+ * This API is experimental and may change in the future.
90
+ */
91
+ workflows: workflowProxy.WorkflowProxy<TPlugin>;
92
+ alias: string;
86
93
  };
87
94
  export type MessagePayloads<TPlugin extends common.BasePlugin> = {
88
95
  [K in keyof IncomingMessages<TPlugin>]: CommonHandlerProps<TPlugin> & {
@@ -1,5 +1,6 @@
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 mapKeys: <K1 extends string, K2 extends string, V>(obj: Record<K1, V>, fn: (key: K1) => K2) => Record<K2, V>;
4
5
  export declare const stripUndefinedProps: <K extends string, V>(obj: Record<K, V | undefined>) => Record<K, V>;
5
6
  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>;
@@ -7,12 +7,12 @@ export type Writable<T> = {
7
7
  };
8
8
  export type Default<T, U> = undefined extends T ? U : T;
9
9
  export type AtLeastOne<T> = [T, ...T[]];
10
- export type AtLeastOneProperty<T> = {
10
+ export type AtLeastOneProperty<T> = T extends undefined ? {} : {
11
11
  [K in keyof T]?: T[K];
12
12
  } & {
13
13
  [K in keyof T]: Pick<T, K>;
14
14
  }[keyof T];
15
- export type ExactlyOneProperty<T> = {
15
+ export type ExactlyOneProperty<T> = T extends undefined ? {} : {
16
16
  [K in keyof T]: {
17
17
  [P in K]: T[P];
18
18
  } & {
@@ -45,4 +45,5 @@ type DeepPartialObject<T extends object> = T extends infer O ? {
45
45
  } : never;
46
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
47
  export type SafeOmit<T, K extends keyof T> = Omit<T, K>;
48
+ export type StringKeys<T> = Extract<keyof T, string>;
48
49
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/sdk",
3
- "version": "3.3.2",
3
+ "version": "3.5.0",
4
4
  "description": "Botpress SDK",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -16,7 +16,7 @@
16
16
  "author": "",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@botpress/client": "0.47.0",
19
+ "@botpress/client": "0.48.0",
20
20
  "browser-or-node": "^2.1.1"
21
21
  },
22
22
  "devDependencies": {