import { Table } from '@botpress/client'; import { SchemaTransformOptions } from '../common/types'; import { IntegrationPackage, PluginPackage } from '../package'; import { PluginInterfaceExtension, PluginIntegrationExtension } from '../plugin'; import { SchemaDefinition } from '../schema'; import { ValueOf, Merge, StringKeys } from '../utils/type-utils'; import { z } from '../zui'; type BaseConfig = z.ZuiObjectSchema; type BaseStates = Record; type BaseEvents = Record; type BaseActions = Record; type BaseTables = Record; type BaseWorkflows = Record; export type TagDefinition = { title?: string; description?: string; }; export type StateType = 'conversation' | 'user' | 'bot' | 'workflow'; export type StateDefinition = SchemaDefinition & { type: StateType; expiry?: number; }; export type RecurringEventDefinition = { [K in keyof TEvents]: { type: K; payload: z.infer; schedule: { cron: string; }; }; }[keyof TEvents]; export type EventDefinition = SchemaDefinition & { attributes?: Record; }; export type ConfigurationDefinition = SchemaDefinition; export type UserDefinition = { tags?: Record; }; export type ConversationDefinition = { tags?: Record; }; export type MessageDefinition = { tags?: Record; }; export type SecretDefinition = { optional?: boolean; description?: string; }; export type ActionDefinition = { title?: string; description?: string; input: SchemaDefinition; output: SchemaDefinition; attributes?: Record; }; export type WorkflowDefinition = { title?: string; description?: string; input: SchemaDefinition; output: SchemaDefinition; tags?: Record; }; export type TableDefinition = Merge, { schema: TTable; }>; export type ResolvedIntegrationConfigInstance = { enabled?: boolean; alias: string; disabledChannels?: StringKeys>[]; } & ({ configurationType?: null; configuration: z.input['schema']>; } | ValueOf<{ [K in StringKeys>]: { configurationType: K; configuration: z.input[K]['schema']>; }; }>); type IntegrationConfigInstance = Omit, 'alias'> & { alias?: string; }; type _ResolvedPluginConfigInstance

= { alias: string; configuration: z.input['schema']>; interfaces: { [I in keyof NonNullable]: PluginInterfaceExtension; }; integrations: { [I in keyof NonNullable]: PluginIntegrationExtension; }; }; type PluginConfigInstance

= Omit<_ResolvedPluginConfigInstance

, 'alias' | 'integrations' | 'interfaces'> & { alias?: string; /** Backing integrations for the plugin's dependencies */ dependencies: { [K in StringKeys>]: { /** * Alias of the integration to use to fullfil this dependency. * * This is the alias given when adding the integration to the bot * via `addIntegration()`. */ integrationAlias: string; /** * Alias of the interface within the integration. * * This is the alias defined by the integration package for the * interface it implements. */ integrationInterfaceAlias: string; }; } & { [K in StringKeys>]: { /** * Alias of the integration to use to fullfil this dependency. * * This is the alias given when adding the integration to the bot * via `addIntegration()`. */ integrationAlias: string; }; }; }; export type IntegrationInstance = IntegrationPackage & ResolvedIntegrationConfigInstance; export type PluginInstance = PluginPackage & _ResolvedPluginConfigInstance; export type BotDefinitionProps = { integrations?: { [K: string]: IntegrationInstance; }; plugins?: { [K: string]: PluginInstance; }; user?: UserDefinition; conversation?: ConversationDefinition; message?: MessageDefinition; states?: { [K in keyof TStates]: StateDefinition; }; configuration?: ConfigurationDefinition; events?: { [K in keyof TEvents]: EventDefinition; }; recurringEvents?: Record>; actions?: { [K in keyof TActions]: ActionDefinition; }; tables?: { [K in keyof TTables]: TableDefinition; }; secrets?: Record; /** * # EXPERIMENTAL * This API is experimental and may change in the future. */ workflows?: { [K in keyof TWorkflows]: WorkflowDefinition; }; attributes?: Record; __advanced?: SchemaTransformOptions; }; export declare class BotDefinition { readonly props: BotDefinitionProps; readonly integrations: this['props']['integrations']; readonly plugins: this['props']['plugins']; readonly user: this['props']['user']; readonly conversation: this['props']['conversation']; readonly message: this['props']['message']; readonly states: this['props']['states']; readonly configuration: this['props']['configuration']; readonly events: this['props']['events']; readonly recurringEvents: this['props']['recurringEvents']; readonly actions: this['props']['actions']; readonly tables: this['props']['tables']; readonly secrets: this['props']['secrets']; readonly workflows: this['props']['workflows']; readonly attributes: this['props']['attributes']; readonly __advanced: this['props']['__advanced']; /** Bot definition with plugins merged into it */ readonly withPlugins: Pick; constructor(props: BotDefinitionProps); get metadata(): { readonly sdkVersion: string; }; addIntegration(integrationPkg: I, config?: IntegrationConfigInstance): this; addPlugin

(pluginPkg: P, config: PluginConfigInstance

): this; private _mergeUser; private _mergeConversation; private _mergeMessage; private _mergeStates; private _mergeEvents; private _mergeRecurringEvents; private _mergeActions; private _mergeTables; private _mergeWorkflows; private _prefixKeysWithPluginAlias; /** * Returns a copy of the bot definition where all interface entity references * are resolved to the base entity schema as extended by the backing * integration. */ dereferencePluginEntities(): this; private _buildZuiReferenceMap; private _dereferenceZuiSchema; private _dereferenceDefinitionSchemas; private _dereferenceDefinitionSchema; private _dereferenceActionDefinitionSchemas; } export {};