@botpress/sdk 2.0.4 → 2.0.5

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.
Files changed (64) hide show
  1. package/.turbo/turbo-build.log +12 -0
  2. package/dist/bot/client/index.d.ts +62 -0
  3. package/dist/bot/client/types.d.ts +141 -0
  4. package/dist/bot/client/types.test.d.ts +1 -0
  5. package/dist/bot/definition.d.ts +111 -0
  6. package/dist/bot/implementation.d.ts +39 -0
  7. package/dist/bot/index.d.ts +5 -0
  8. package/dist/bot/merge-bots.d.ts +2 -0
  9. package/dist/bot/server/context.d.ts +2 -0
  10. package/dist/bot/server/index.d.ts +5 -0
  11. package/dist/bot/server/types.d.ts +252 -0
  12. package/dist/bot/server/types.test.d.ts +1 -0
  13. package/dist/bot/types/common.d.ts +50 -0
  14. package/dist/bot/types/common.test.d.ts +1 -0
  15. package/dist/bot/types/generic.d.ts +31 -0
  16. package/dist/bot/types/generic.test.d.ts +1 -0
  17. package/dist/bot/types/index.d.ts +2 -0
  18. package/dist/const.d.ts +8 -0
  19. package/dist/fixtures.d.ts +108 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.js +2 -0
  22. package/dist/index.js.map +7 -0
  23. package/dist/integration/client/index.d.ts +47 -0
  24. package/dist/integration/client/types.d.ts +177 -0
  25. package/dist/integration/client/types.test.d.ts +1 -0
  26. package/dist/integration/definition/branded-schema.d.ts +21 -0
  27. package/dist/integration/definition/generic.d.ts +9 -0
  28. package/dist/integration/definition/index.d.ts +76 -0
  29. package/dist/integration/definition/types.d.ts +106 -0
  30. package/dist/integration/implementation.d.ts +31 -0
  31. package/dist/integration/index.d.ts +5 -0
  32. package/dist/integration/server/action-metadata.d.ts +9 -0
  33. package/dist/integration/server/context.d.ts +3 -0
  34. package/dist/integration/server/index.d.ts +6 -0
  35. package/dist/integration/server/logger.d.ts +12 -0
  36. package/dist/integration/server/types.d.ts +102 -0
  37. package/dist/integration/types/common.d.ts +11 -0
  38. package/dist/integration/types/generic.d.ts +52 -0
  39. package/dist/integration/types/generic.test.d.ts +1 -0
  40. package/dist/integration/types/index.d.ts +2 -0
  41. package/dist/interface/definition.d.ts +70 -0
  42. package/dist/interface/index.d.ts +1 -0
  43. package/dist/interface/types/generic.d.ts +34 -0
  44. package/dist/interface/types/generic.test.d.ts +1 -0
  45. package/dist/log.d.ts +7 -0
  46. package/dist/message.d.ts +474 -0
  47. package/dist/package.d.ts +58 -0
  48. package/dist/plugin/definition.d.ts +50 -0
  49. package/dist/plugin/implementation.d.ts +39 -0
  50. package/dist/plugin/index.d.ts +3 -0
  51. package/dist/plugin/server/types.d.ts +1 -0
  52. package/dist/plugin/server/types.test.d.ts +1 -0
  53. package/dist/plugin/types/generic.d.ts +30 -0
  54. package/dist/plugin/types/generic.test.d.ts +1 -0
  55. package/dist/retry.d.ts +2 -0
  56. package/dist/schema.d.ts +18 -0
  57. package/dist/serve.d.ts +20 -0
  58. package/dist/utils/array-utils.d.ts +1 -0
  59. package/dist/utils/index.d.ts +3 -0
  60. package/dist/utils/record-utils.d.ts +3 -0
  61. package/dist/utils/type-utils.d.ts +33 -0
  62. package/dist/utils/type-utils.test.d.ts +1 -0
  63. package/dist/zui.d.ts +5 -0
  64. package/package.json +2 -2
@@ -0,0 +1,58 @@
1
+ import * as integration from './integration';
2
+ import * as plugin from './plugin';
3
+ type NameVersion = {
4
+ name: string;
5
+ version: string;
6
+ };
7
+ type PackageReference = NameVersion & {
8
+ id?: string;
9
+ uri?: string;
10
+ };
11
+ type IntegrationPackageDefinition = NameVersion & {
12
+ configuration?: integration.ConfigurationDefinition;
13
+ configurations?: Record<string, integration.AdditionalConfigurationDefinition>;
14
+ events?: Record<string, integration.EventDefinition>;
15
+ actions?: Record<string, integration.ActionDefinition>;
16
+ channels?: Record<string, integration.ChannelDefinition>;
17
+ states?: Record<string, integration.StateDefinition>;
18
+ user?: integration.UserDefinition;
19
+ secrets?: Record<string, integration.SecretDefinition>;
20
+ entities?: Record<string, integration.EntityDefinition>;
21
+ interfaces?: Record<string, PackageReference>;
22
+ };
23
+ type InterfacePackageDefinition = NameVersion & {
24
+ templateName?: string;
25
+ entities?: Record<string, integration.EntityDefinition>;
26
+ events?: Record<string, integration.EventDefinition>;
27
+ actions?: Record<string, integration.ActionDefinition>;
28
+ channels?: Record<string, integration.ChannelDefinition>;
29
+ };
30
+ type PluginPackageDefinition = NameVersion & {
31
+ integrations?: Record<string, PackageReference>;
32
+ interfaces?: Record<string, PackageReference>;
33
+ user?: plugin.UserDefinition;
34
+ conversation?: plugin.ConversationDefinition;
35
+ message?: plugin.MessageDefinition;
36
+ states?: Record<string, plugin.StateDefinition>;
37
+ configuration?: plugin.ConfigurationDefinition;
38
+ events?: Record<string, plugin.EventDefinition>;
39
+ recurringEvents?: Record<string, plugin.RecurringEventDefinition>;
40
+ actions?: Record<string, plugin.ActionDefinition>;
41
+ };
42
+ export type IntegrationPackage = PackageReference & {
43
+ type: 'integration';
44
+ definition: IntegrationPackageDefinition;
45
+ implementation?: null;
46
+ };
47
+ export type InterfacePackage = PackageReference & {
48
+ type: 'interface';
49
+ definition: InterfacePackageDefinition;
50
+ implementation?: null;
51
+ };
52
+ export type PluginPackage = PackageReference & {
53
+ type: 'plugin';
54
+ definition: PluginPackageDefinition;
55
+ implementation: Buffer;
56
+ };
57
+ export type Package = IntegrationPackage | InterfacePackage | PluginPackage;
58
+ export {};
@@ -0,0 +1,50 @@
1
+ import { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition } from '../bot/definition';
2
+ import { IntegrationPackage, InterfacePackage } from '../package';
3
+ import { ZuiObjectSchema } from '../zui';
4
+ export { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, IntegrationConfigInstance, } from '../bot/definition';
5
+ type BaseConfig = ZuiObjectSchema;
6
+ type BaseStates = Record<string, ZuiObjectSchema>;
7
+ type BaseEvents = Record<string, ZuiObjectSchema>;
8
+ type BaseActions = Record<string, ZuiObjectSchema>;
9
+ type BaseInterfaces = Record<string, any>;
10
+ type BaseIntegrations = Record<string, any>;
11
+ 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> = {
12
+ name: TName;
13
+ version: TVersion;
14
+ integrations?: {
15
+ [K in keyof TIntegrations]: IntegrationPackage;
16
+ };
17
+ interfaces?: {
18
+ [K in keyof TInterfaces]: InterfacePackage;
19
+ };
20
+ user?: UserDefinition;
21
+ conversation?: ConversationDefinition;
22
+ message?: MessageDefinition;
23
+ states?: {
24
+ [K in keyof TStates]: StateDefinition<TStates[K]>;
25
+ };
26
+ configuration?: ConfigurationDefinition<TConfig>;
27
+ events?: {
28
+ [K in keyof TEvents]: EventDefinition<TEvents[K]>;
29
+ };
30
+ recurringEvents?: Record<string, RecurringEventDefinition<TEvents>>;
31
+ actions?: {
32
+ [K in keyof TActions]: ActionDefinition<TActions[K]>;
33
+ };
34
+ };
35
+ 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> {
36
+ readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations>;
37
+ readonly name: this['props']['name'];
38
+ readonly version: this['props']['version'];
39
+ readonly integrations: this['props']['integrations'];
40
+ readonly interfaces: this['props']['interfaces'];
41
+ readonly user: this['props']['user'];
42
+ readonly conversation: this['props']['conversation'];
43
+ readonly message: this['props']['message'];
44
+ readonly states: this['props']['states'];
45
+ readonly configuration: this['props']['configuration'];
46
+ readonly events: this['props']['events'];
47
+ readonly recurringEvents: this['props']['recurringEvents'];
48
+ readonly actions: this['props']['actions'];
49
+ constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations>);
50
+ }
@@ -0,0 +1,39 @@
1
+ import { MessageHandlersMap, MessageHandlers, EventHandlersMap, EventHandlers, StateExpiredHandlersMap, StateExpiredHandlers, HookHandlersMap, HookData, HookHandlers, ActionHandlers, BotHandlers } from './server/types';
2
+ import { BasePlugin } from './types/generic';
3
+ export type PluginImplementationProps<TPlugin extends BasePlugin = BasePlugin> = {
4
+ actions: ActionHandlers<TPlugin>;
5
+ };
6
+ export type PluginRuntimeProps<TPlugin extends BasePlugin = BasePlugin> = {
7
+ configuration: TPlugin['configuration'];
8
+ interfaces: {
9
+ [K in keyof TPlugin['interfaces']]: {
10
+ name: string;
11
+ version: string;
12
+ };
13
+ };
14
+ };
15
+ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugin> implements BotHandlers<TPlugin> {
16
+ readonly props: PluginImplementationProps<TPlugin>;
17
+ private _runtimeProps;
18
+ readonly actionHandlers: ActionHandlers<TPlugin>;
19
+ readonly messageHandlers: MessageHandlersMap<TPlugin>;
20
+ readonly eventHandlers: EventHandlersMap<TPlugin>;
21
+ readonly stateExpiredHandlers: StateExpiredHandlersMap<TPlugin>;
22
+ readonly hookHandlers: HookHandlersMap<TPlugin>;
23
+ constructor(props: PluginImplementationProps<TPlugin>);
24
+ initialize(config: PluginRuntimeProps<TPlugin>): this;
25
+ get config(): PluginRuntimeProps<TPlugin>;
26
+ readonly on: {
27
+ message: <T extends keyof MessageHandlersMap<TPlugin>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
28
+ event: <T extends keyof EventHandlersMap<TPlugin>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
29
+ stateExpired: <T extends keyof StateExpiredHandlersMap<TPlugin>>(type: T, handler: StateExpiredHandlers<TPlugin>[T]) => void;
30
+ beforeIncomingEvent: <T extends keyof HookData<TPlugin>["before_incoming_event"]>(type: T, handler: HookHandlers<TPlugin>["before_incoming_event"][T]) => void;
31
+ beforeIncomingMessage: <T extends keyof HookData<TPlugin>["before_incoming_message"]>(type: T, handler: HookHandlers<TPlugin>["before_incoming_message"][T]) => void;
32
+ beforeOutgoingMessage: <T extends keyof HookData<TPlugin>["before_outgoing_message"]>(type: T, handler: HookHandlers<TPlugin>["before_outgoing_message"][T]) => void;
33
+ beforeOutgoingCallAction: <T extends keyof HookData<TPlugin>["before_outgoing_call_action"]>(type: T, handler: HookHandlers<TPlugin>["before_outgoing_call_action"][T]) => void;
34
+ afterIncomingEvent: <T extends keyof HookData<TPlugin>["after_incoming_event"]>(type: T, handler: HookHandlers<TPlugin>["after_incoming_event"][T]) => void;
35
+ afterIncomingMessage: <T extends keyof HookData<TPlugin>["after_incoming_message"]>(type: T, handler: HookHandlers<TPlugin>["after_incoming_message"][T]) => void;
36
+ afterOutgoingMessage: <T extends keyof HookData<TPlugin>["after_outgoing_message"]>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_message"][T]) => void;
37
+ afterOutgoingCallAction: <T extends keyof HookData<TPlugin>["after_outgoing_call_action"]>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_call_action"][T]) => void;
38
+ };
39
+ }
@@ -0,0 +1,3 @@
1
+ export * from './definition';
2
+ export * from './implementation';
3
+ export * from './types/generic';
@@ -0,0 +1 @@
1
+ export * from '../../bot/server/types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { BaseIntegration, DefaultIntegration, InputBaseIntegration } from '../../integration/types/generic';
2
+ import { BaseInterface, InputBaseInterface, DefaultInterface } from '../../interface/types/generic';
3
+ import * as utils from '../../utils/type-utils';
4
+ export type BaseAction = {
5
+ input: any;
6
+ output: any;
7
+ };
8
+ export type BasePlugin = {
9
+ configuration: any;
10
+ integrations: Record<string, BaseIntegration>;
11
+ interfaces: Record<string, BaseInterface>;
12
+ events: Record<string, any>;
13
+ states: Record<string, any>;
14
+ actions: Record<string, BaseAction>;
15
+ unknownDefinitions: true;
16
+ };
17
+ export type InputBasePlugin = utils.DeepPartial<BasePlugin>;
18
+ export type DefaultPlugin<B extends utils.DeepPartial<BasePlugin>> = {
19
+ configuration: utils.Default<B['configuration'], BasePlugin['configuration']>;
20
+ events: utils.Default<B['events'], BasePlugin['events']>;
21
+ states: utils.Default<B['states'], BasePlugin['states']>;
22
+ actions: utils.Default<B['actions'], BasePlugin['actions']>;
23
+ unknownDefinitions: utils.Default<B['unknownDefinitions'], BasePlugin['unknownDefinitions']>;
24
+ integrations: undefined extends B['integrations'] ? BasePlugin['integrations'] : {
25
+ [K in keyof B['integrations']]: DefaultIntegration<utils.Cast<B['integrations'][K], InputBaseIntegration>>;
26
+ };
27
+ interfaces: undefined extends B['interfaces'] ? BasePlugin['interfaces'] : {
28
+ [K in keyof B['interfaces']]: DefaultInterface<utils.Cast<B['interfaces'][K], InputBaseInterface>>;
29
+ };
30
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { RetryConfig } from '@botpress/client';
2
+ export declare const retryConfig: RetryConfig;
@@ -0,0 +1,18 @@
1
+ import * as z from './zui';
2
+ type SchemaOptions<T> = {
3
+ title: string;
4
+ examples: T[];
5
+ };
6
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
7
+ type UiDefinition<TSchema extends z.ZuiObjectSchema = z.ZuiObjectSchema> = IsEmptyObject<z.infer<TSchema>> extends true ? Record<string, never> : {
8
+ [K in keyof z.infer<TSchema>]: Partial<SchemaOptions<z.infer<TSchema>[K]>>;
9
+ };
10
+ export type SchemaDefinition<TSchema extends z.ZuiObjectSchema = z.ZuiObjectSchema> = {
11
+ schema: TSchema;
12
+ /**
13
+ * @deprecated
14
+ * Use zod.Schema.displayAs() instead
15
+ **/
16
+ ui?: Partial<UiDefinition<TSchema>>;
17
+ };
18
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Server } from 'node:http';
2
+ export type Request = {
3
+ body?: string;
4
+ path: string;
5
+ query: string;
6
+ method: string;
7
+ headers: {
8
+ [key: string]: string | undefined;
9
+ };
10
+ };
11
+ export type Response = {
12
+ body?: string;
13
+ headers?: {
14
+ [key: string]: string;
15
+ };
16
+ status?: number;
17
+ };
18
+ export type Handler = (req: Request) => Promise<Response | void>;
19
+ export declare function parseBody<T>(req: Request): T;
20
+ export declare function serve(handler: Handler, port?: number, callback?: (port: number) => void): Promise<Server>;
@@ -0,0 +1 @@
1
+ export declare const safePush: <T>(arr: T[] | undefined, ...values: T[]) => T[];
@@ -0,0 +1,3 @@
1
+ export * as records from './record-utils';
2
+ export * as arrays from './array-utils';
3
+ export * as types from './type-utils';
@@ -0,0 +1,3 @@
1
+ export declare const pairs: <K extends string, V>(obj: Record<K, V>) => [K, V][];
2
+ export declare const values: <K extends string, V>(obj: Record<K, V>) => V[];
3
+ export declare const mapValues: <K extends string, V, R>(obj: Record<K, V>, fn: (value: V, key: K) => R) => Record<K, R>;
@@ -0,0 +1,33 @@
1
+ export type ValueOf<T> = T[keyof T];
2
+ export type Merge<A extends object, B extends object> = Omit<A, keyof B> & B;
3
+ export type Cast<T, U> = T extends U ? T : U;
4
+ export type SafeCast<T, U> = [T] extends [never] ? U : Cast<T, U>;
5
+ export type Writable<T> = {
6
+ -readonly [K in keyof T]: T[K];
7
+ };
8
+ export type Default<T, U> = undefined extends T ? U : T;
9
+ export type IsExtend<X, Y> = X extends Y ? true : false;
10
+ export type IsEquivalent<X, Y> = IsExtend<X, Y> extends true ? IsExtend<Y, X> : false;
11
+ export type IsIdentical<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
12
+ export type IsEqual<X, Y> = IsIdentical<Normalize<X>, Normalize<Y>>;
13
+ export type AssertExtends<_A extends B, B> = true;
14
+ export type AssertTrue<_T extends true> = true;
15
+ export type AssertAll<_T extends true[]> = true;
16
+ 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> : '';
17
+ export type Split<S extends string | number | symbol, D extends string> = S extends `${infer H}${D}${infer T}` ? [H, ...Split<Cast<T, string>, D>] : [S];
18
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
19
+ /**
20
+ * removes string index signature from Record
21
+ */
22
+ export type ToSealedRecord<R extends Record<string, any>> = {
23
+ [K in keyof R as string extends K ? never : K]: R[K];
24
+ };
25
+ type NormalizeObject<T extends object> = T extends infer O ? {
26
+ [K in keyof O]: Normalize<O[K]>;
27
+ } : never;
28
+ export type Normalize<T> = T extends (...args: infer A) => infer R ? (...args: Normalize<A>) => Normalize<R> : T extends Array<infer E> ? Array<Normalize<E>> : T extends ReadonlyArray<infer E> ? ReadonlyArray<Normalize<E>> : T extends Promise<infer R> ? Promise<Normalize<R>> : T extends Buffer ? Buffer : T extends object ? NormalizeObject<T> : T;
29
+ type DeepPartialObject<T extends object> = T extends infer O ? {
30
+ [K in keyof O]?: DeepPartial<O[K]>;
31
+ } : never;
32
+ 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;
33
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/zui.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { z } from '@bpinternal/zui';
2
+ export * from '@bpinternal/zui';
3
+ export type GenericZuiSchema<A extends Record<string, z.ZodTypeAny> = Record<string, z.ZodTypeAny>, R extends z.ZodTypeAny = z.ZodTypeAny> = (typeArguments: A) => R;
4
+ export type ZuiObjectSchema = z.ZodObject | z.ZodRecord;
5
+ export default z;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Botpress SDK",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "author": "",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@botpress/client": "0.38.0",
17
+ "@botpress/client": "0.38.1",
18
18
  "@bpinternal/zui": "0.12.0"
19
19
  },
20
20
  "devDependencies": {