@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
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as client from '@botpress/client';
|
|
2
2
|
import * as utils from '../../utils/type-utils';
|
|
3
3
|
import * as common from '../types';
|
|
4
|
-
type
|
|
4
|
+
type BaseChannelDefinition = common.BaseIntegration['channels'][string];
|
|
5
|
+
type GetChannelByName<TIntegration extends common.BaseIntegration, TChannelName extends keyof TIntegration['channels']> = utils.Cast<TIntegration['channels'][TChannelName], BaseChannelDefinition>;
|
|
5
6
|
/**
|
|
6
7
|
* @deprecated Integration's should no longer use their name as prefix for event types or tags.
|
|
7
8
|
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
+
import type * as esbuild from 'esbuild';
|
|
1
2
|
import { InterfacePackage } from '../../package';
|
|
3
|
+
import * as utils from '../../utils';
|
|
2
4
|
import { z } from '../../zui';
|
|
3
5
|
import { SchemaStore, BrandedSchema } from './branded-schema';
|
|
4
6
|
import { BaseConfig, BaseEvents, BaseActions, BaseChannels, BaseStates, BaseEntities, BaseConfigs } from './generic';
|
|
5
|
-
import { ConfigurationDefinition, EventDefinition, ChannelDefinition, ActionDefinition, StateDefinition, UserDefinition, SecretDefinition, EntityDefinition, AdditionalConfigurationDefinition } from './types';
|
|
7
|
+
import { ConfigurationDefinition, EventDefinition, ChannelDefinition, ActionDefinition, StateDefinition, UserDefinition, SecretDefinition, EntityDefinition, AdditionalConfigurationDefinition, InterfaceExtension } from './types';
|
|
6
8
|
export * from './types';
|
|
7
|
-
export type InterfaceExtension = InterfacePackage & {
|
|
8
|
-
entities: Record<string, {
|
|
9
|
-
name: string;
|
|
10
|
-
schema: z.AnyZodObject;
|
|
11
|
-
}>;
|
|
12
|
-
};
|
|
13
9
|
export type IntegrationDefinitionProps<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TConfigs extends BaseConfigs = BaseConfigs, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TChannels extends BaseChannels = BaseChannels, TStates extends BaseStates = BaseStates, TEntities extends BaseEntities = BaseEntities> = {
|
|
14
10
|
name: TName;
|
|
15
11
|
version: TVersion;
|
|
@@ -43,15 +39,54 @@ export type IntegrationDefinitionProps<TName extends string = string, TVersion e
|
|
|
43
39
|
[K in keyof TEntities]: EntityDefinition<TEntities[K]>;
|
|
44
40
|
};
|
|
45
41
|
interfaces?: Record<string, InterfaceExtension>;
|
|
42
|
+
__advanced?: {
|
|
43
|
+
esbuild?: Partial<esbuild.BuildOptions>;
|
|
44
|
+
};
|
|
46
45
|
};
|
|
47
46
|
type EntitiesOfPackage<TPackage extends InterfacePackage> = {
|
|
48
47
|
[K in keyof TPackage['definition']['entities']]: NonNullable<TPackage['definition']['entities']>[K]['schema'];
|
|
49
48
|
};
|
|
50
|
-
type
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
type ActionsOfPackage<TPackage extends InterfacePackage> = {
|
|
50
|
+
[K in keyof TPackage['definition']['actions']]: NonNullable<TPackage['definition']['actions']>[K]['input']['schema'];
|
|
51
|
+
};
|
|
52
|
+
type EventsOfPackage<TPackage extends InterfacePackage> = {
|
|
53
|
+
[K in keyof TPackage['definition']['events']]: NonNullable<TPackage['definition']['events']>[K]['schema'];
|
|
54
|
+
};
|
|
55
|
+
type ChannelsOfPackage<TPackage extends InterfacePackage> = {
|
|
56
|
+
[K in keyof TPackage['definition']['channels']]: {
|
|
57
|
+
[M in keyof NonNullable<TPackage['definition']['channels']>[K]['messages']]: NonNullable<NonNullable<TPackage['definition']['channels']>[K]['messages']>[M]['schema'];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type ActionOverrideProps = utils.types.AtLeastOneProperty<Pick<Required<ActionDefinition>, 'title' | 'description' | 'billable' | 'cacheable'> & {
|
|
61
|
+
name: string;
|
|
62
|
+
}>;
|
|
63
|
+
export type EventOverrideProps = utils.types.AtLeastOneProperty<Pick<Required<EventDefinition>, 'title' | 'description'> & {
|
|
64
|
+
name: string;
|
|
65
|
+
}>;
|
|
66
|
+
export type ChannelOverrideProps = utils.types.AtLeastOneProperty<Pick<Required<ChannelDefinition>, 'title' | 'description'> & {
|
|
67
|
+
name: string;
|
|
68
|
+
message: {
|
|
69
|
+
tags: Required<Required<ChannelDefinition>['message']>['tags'];
|
|
70
|
+
};
|
|
71
|
+
conversation: {
|
|
72
|
+
tags: Required<Required<ChannelDefinition>['conversation']>['tags'];
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
type ActionOverrides<TInterfaceActionNames extends string = string> = utils.types.AtLeastOneProperty<Record<TInterfaceActionNames, ActionOverrideProps>>;
|
|
76
|
+
type EventOverrides<TInterfaceEventNames extends string = string> = utils.types.AtLeastOneProperty<Record<TInterfaceEventNames, EventOverrideProps>>;
|
|
77
|
+
type ChannelOverrides<TInterfaceChannelNames extends string = string> = utils.types.AtLeastOneProperty<Record<TInterfaceChannelNames, ChannelOverrideProps>>;
|
|
78
|
+
type ExtensionBuilderInput<TIntegrationEntities extends BaseEntities, _TIntegrationActions extends BaseActions, _TIntegrationEvents extends BaseEvents, _TIntegrationChannels extends BaseChannels> = {
|
|
79
|
+
entities: SchemaStore<TIntegrationEntities>;
|
|
80
|
+
};
|
|
81
|
+
type ExtensionBuilderOutput<TInterfaceEntities extends BaseEntities, TInterfaceActions extends BaseActions, TInterfaceEvents extends BaseEvents, TInterfaceChannels extends BaseChannels> = {
|
|
82
|
+
entities: {
|
|
83
|
+
[K in keyof TInterfaceEntities]: BrandedSchema<z.ZodSchema<z.infer<TInterfaceEntities[K]>>>;
|
|
84
|
+
};
|
|
85
|
+
actions?: ActionOverrides<Extract<keyof TInterfaceActions, string>>;
|
|
86
|
+
events?: EventOverrides<Extract<keyof TInterfaceEvents, string>>;
|
|
87
|
+
channels?: ChannelOverrides<Extract<keyof TInterfaceChannels, string>>;
|
|
53
88
|
};
|
|
54
|
-
type ExtensionBuilder<TIntegrationEntities extends BaseEntities, TInterfaceEntities extends BaseEntities> = (input: ExtensionBuilderInput<TIntegrationEntities>) => ExtensionBuilderOutput<TInterfaceEntities>;
|
|
89
|
+
type ExtensionBuilder<TIntegrationEntities extends BaseEntities, TIntegrationActions extends BaseActions, TIntegrationEvents extends BaseEvents, TIntegrationChannels extends BaseChannels, TInterfaceEntities extends BaseEntities, TInterfaceActions extends BaseActions, TInterfaceEvents extends BaseEvents, TInterfaceChannels extends BaseChannels> = (input: ExtensionBuilderInput<TIntegrationEntities, TIntegrationActions, TIntegrationEvents, TIntegrationChannels>) => ExtensionBuilderOutput<TInterfaceEntities, TInterfaceActions, TInterfaceEvents, TInterfaceChannels>;
|
|
55
90
|
export declare class IntegrationDefinition<TName extends string = string, TVersion extends string = string, TConfig extends BaseConfig = BaseConfig, TConfigs extends BaseConfigs = BaseConfigs, TEvents extends BaseEvents = BaseEvents, TActions extends BaseActions = BaseActions, TChannels extends BaseChannels = BaseChannels, TStates extends BaseStates = BaseStates, TEntities extends BaseEntities = BaseEntities> {
|
|
56
91
|
readonly props: IntegrationDefinitionProps<TName, TVersion, TConfig, TConfigs, TEvents, TActions, TChannels, TStates, TEntities>;
|
|
57
92
|
readonly name: this['props']['name'];
|
|
@@ -71,6 +106,12 @@ export declare class IntegrationDefinition<TName extends string = string, TVersi
|
|
|
71
106
|
readonly identifier: this['props']['identifier'];
|
|
72
107
|
readonly entities: this['props']['entities'];
|
|
73
108
|
readonly interfaces: this['props']['interfaces'];
|
|
109
|
+
readonly __advanced: this['props']['__advanced'];
|
|
74
110
|
constructor(props: IntegrationDefinitionProps<TName, TVersion, TConfig, TConfigs, TEvents, TActions, TChannels, TStates, TEntities>);
|
|
75
|
-
extend<P extends InterfacePackage>(interfacePkg: P, builder: ExtensionBuilder<TEntities, EntitiesOfPackage<P>>): this;
|
|
111
|
+
extend<P extends InterfacePackage>(interfacePkg: P, builder: ExtensionBuilder<TEntities, TActions, TEvents, TChannels, EntitiesOfPackage<P>, ActionsOfPackage<P>, EventsOfPackage<P>, ChannelsOfPackage<P>>): this;
|
|
112
|
+
private _callBuilder;
|
|
113
|
+
private _mergeActions;
|
|
114
|
+
private _mergeEvents;
|
|
115
|
+
private _mergeChannels;
|
|
116
|
+
private _mergeMessage;
|
|
76
117
|
}
|
|
@@ -80,7 +80,12 @@ export type ResolvedInterface<TEvents extends BaseEvents = BaseEvents, TActions
|
|
|
80
80
|
[K in keyof TChannels]: ChannelDefinition<TChannels[K]>;
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
|
-
|
|
83
|
+
/**
|
|
84
|
+
* A.K.A. Interface Implementation Statetement
|
|
85
|
+
* Used by an integration to explicitly declare that it implements an interface
|
|
86
|
+
*/
|
|
87
|
+
export type InterfaceExtension<TEntities extends BaseEntities = BaseEntities, TActions extends BaseActions = BaseActions, TEvents extends BaseEvents = BaseEvents, TChannels extends BaseChannels = BaseChannels> = {
|
|
88
|
+
id?: string;
|
|
84
89
|
name: string;
|
|
85
90
|
version: string;
|
|
86
91
|
entities: {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import * as utils from '../../utils/type-utils';
|
|
2
|
-
import { BaseIntegration } from './generic';
|
|
3
|
-
export type ConfigurationDefinition = BaseIntegration['configuration'];
|
|
4
|
-
export type ActionDefinition = BaseIntegration['actions'][string];
|
|
5
|
-
export type ChannelDefinition = BaseIntegration['channels'][string];
|
|
6
|
-
export type EventDefinition = BaseIntegration['events'][string];
|
|
7
|
-
export type StateDefinition = BaseIntegration['states'][string];
|
|
8
|
-
export type UserDefinition = BaseIntegration['user'];
|
|
9
2
|
type AsTags<T extends Record<string, string | undefined>> = utils.Cast<T, Record<string, string>>;
|
|
10
3
|
export type ToTags<TTags extends string | number | symbol> = AsTags<Partial<Record<utils.Cast<TTags, string>, string>>>;
|
|
11
4
|
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -45,7 +45,6 @@ export type InterfaceDefinitionProps<TName extends string = string, TVersion ext
|
|
|
45
45
|
channels?: {
|
|
46
46
|
[K in keyof TChannels]: GenericChannelDefinition<TEntities, TChannels[K]>;
|
|
47
47
|
};
|
|
48
|
-
templateName?: string;
|
|
49
48
|
};
|
|
50
49
|
export declare class InterfaceDefinition<TName extends string = string, TVersion extends string = string, TEntities extends BaseEntities = BaseEntities, TActions extends BaseActions = BaseActions, TEvents extends BaseEvents = BaseEvents, TChannels extends BaseChannels = BaseChannels> {
|
|
51
50
|
readonly props: InterfaceDefinitionProps<TName, TVersion, TEntities, TActions, TEvents, TChannels>;
|
|
@@ -63,7 +62,6 @@ export declare class InterfaceDefinition<TName extends string = string, TVersion
|
|
|
63
62
|
readonly channels: {
|
|
64
63
|
[K in keyof TChannels]: ChannelDefinition<TChannels[K]>;
|
|
65
64
|
};
|
|
66
|
-
readonly templateName: this['props']['templateName'];
|
|
67
65
|
constructor(props: InterfaceDefinitionProps<TName, TVersion, TEntities, TActions, TEvents, TChannels>);
|
|
68
66
|
private _getEntityReference;
|
|
69
67
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionOverrideProps, ChannelOverrideProps, EventOverrideProps, InterfaceExtension, ResolvedInterface } from '../integration';
|
|
2
|
+
import { InterfacePackage } from '../package';
|
|
3
|
+
import { ZuiObjectSchema } from '../zui';
|
|
4
|
+
type ResolveInterfaceInput = InterfacePackage & {
|
|
5
|
+
entities: Record<string, {
|
|
6
|
+
name: string;
|
|
7
|
+
schema: ZuiObjectSchema;
|
|
8
|
+
}>;
|
|
9
|
+
actions: Record<string, ActionOverrideProps>;
|
|
10
|
+
events: Record<string, EventOverrideProps>;
|
|
11
|
+
channels: Record<string, ChannelOverrideProps>;
|
|
12
|
+
};
|
|
13
|
+
type ResolveInterfaceOutput = {
|
|
14
|
+
resolved: ResolvedInterface;
|
|
15
|
+
statement: InterfaceExtension;
|
|
16
|
+
};
|
|
17
|
+
export declare const resolveInterface: (intrface: ResolveInterfaceInput) => ResolveInterfaceOutput;
|
|
18
|
+
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generic';
|
package/dist/log.d.ts
CHANGED
|
File without changes
|
package/dist/message.d.ts
CHANGED
|
File without changes
|
package/dist/package.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as integration from './integration';
|
|
2
2
|
import * as plugin from './plugin';
|
|
3
|
+
import * as utils from './utils/type-utils';
|
|
3
4
|
type NameVersion = {
|
|
4
5
|
name: string;
|
|
5
6
|
version: string;
|
|
@@ -8,6 +9,7 @@ type PackageReference = NameVersion & {
|
|
|
8
9
|
id?: string;
|
|
9
10
|
uri?: string;
|
|
10
11
|
};
|
|
12
|
+
type IntegrationPackageDefinitionInterface = utils.Merge<PackageReference, integration.InterfaceExtension>;
|
|
11
13
|
type IntegrationPackageDefinition = NameVersion & {
|
|
12
14
|
configuration?: integration.ConfigurationDefinition;
|
|
13
15
|
configurations?: Record<string, integration.AdditionalConfigurationDefinition>;
|
|
@@ -18,10 +20,9 @@ type IntegrationPackageDefinition = NameVersion & {
|
|
|
18
20
|
user?: integration.UserDefinition;
|
|
19
21
|
secrets?: Record<string, integration.SecretDefinition>;
|
|
20
22
|
entities?: Record<string, integration.EntityDefinition>;
|
|
21
|
-
interfaces?: Record<string,
|
|
23
|
+
interfaces?: Record<string, IntegrationPackageDefinitionInterface>;
|
|
22
24
|
};
|
|
23
25
|
type InterfacePackageDefinition = NameVersion & {
|
|
24
|
-
templateName?: string;
|
|
25
26
|
entities?: Record<string, integration.EntityDefinition>;
|
|
26
27
|
events?: Record<string, integration.EventDefinition>;
|
|
27
28
|
actions?: Record<string, integration.ActionDefinition>;
|
|
@@ -38,6 +39,7 @@ type PluginPackageDefinition = NameVersion & {
|
|
|
38
39
|
events?: Record<string, plugin.EventDefinition>;
|
|
39
40
|
recurringEvents?: Record<string, plugin.RecurringEventDefinition>;
|
|
40
41
|
actions?: Record<string, plugin.ActionDefinition>;
|
|
42
|
+
tables?: Record<string, plugin.TableDefinition>;
|
|
41
43
|
};
|
|
42
44
|
export type IntegrationPackage = PackageReference & {
|
|
43
45
|
type: 'integration';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Client } from '@botpress/client';
|
|
2
|
+
import { BotSpecificClient } from '../../bot';
|
|
3
|
+
import { BasePlugin, PluginInterfaceExtensions } from '../types';
|
|
4
|
+
import { ActionProxy } from './types';
|
|
5
|
+
export declare const proxyActions: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | Client, interfaces: PluginInterfaceExtensions<TPlugin>) => ActionProxy<TPlugin>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as utils from '../../utils/type-utils';
|
|
2
|
+
import { BasePlugin } from '../types';
|
|
3
|
+
type IntegrationActionProxy<TPlugin extends BasePlugin> = {
|
|
4
|
+
[TIntegrationName in keyof TPlugin['integrations']]: {
|
|
5
|
+
[TActionName in keyof TPlugin['integrations'][TIntegrationName]['actions']]: (input: TPlugin['integrations'][TIntegrationName]['actions'][TActionName]['input']) => Promise<TPlugin['integrations'][TIntegrationName]['actions'][TActionName]['output']>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
type InterfacesActionProxy<TPlugin extends BasePlugin> = {
|
|
9
|
+
[TInterfaceName in keyof TPlugin['interfaces']]: {
|
|
10
|
+
[TActionName in keyof TPlugin['interfaces'][TInterfaceName]['actions']]: (input: TPlugin['interfaces'][TInterfaceName]['actions'][TActionName]['input']) => Promise<TPlugin['interfaces'][TInterfaceName]['actions'][TActionName]['output']>;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type ActionProxy<TPlugin extends BasePlugin> = utils.Normalize<IntegrationActionProxy<TPlugin> & InterfacesActionProxy<TPlugin>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition } from '../bot/definition';
|
|
1
|
+
import { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition } 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, IntegrationConfigInstance, } from '../bot/definition';
|
|
4
|
+
export { StateDefinition, RecurringEventDefinition, EventDefinition, ConfigurationDefinition, UserDefinition, ConversationDefinition, MessageDefinition, ActionDefinition, TableDefinition, IntegrationConfigInstance, } from '../bot/definition';
|
|
5
5
|
type BaseConfig = ZuiObjectSchema;
|
|
6
6
|
type BaseStates = Record<string, ZuiObjectSchema>;
|
|
7
7
|
type BaseEvents = Record<string, ZuiObjectSchema>;
|
|
8
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
13
|
name: TName;
|
|
13
14
|
version: TVersion;
|
|
14
15
|
integrations?: {
|
|
@@ -31,9 +32,12 @@ export type PluginDefinitionProps<TName extends string = string, TVersion extend
|
|
|
31
32
|
actions?: {
|
|
32
33
|
[K in keyof TActions]: ActionDefinition<TActions[K]>;
|
|
33
34
|
};
|
|
35
|
+
tables?: {
|
|
36
|
+
[K in keyof TTables]: TableDefinition<TTables[K]>;
|
|
37
|
+
};
|
|
34
38
|
};
|
|
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>;
|
|
39
|
+
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> {
|
|
40
|
+
readonly props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables>;
|
|
37
41
|
readonly name: this['props']['name'];
|
|
38
42
|
readonly version: this['props']['version'];
|
|
39
43
|
readonly integrations: this['props']['integrations'];
|
|
@@ -46,5 +50,6 @@ export declare class PluginDefinition<TName extends string = string, TVersion ex
|
|
|
46
50
|
readonly events: this['props']['events'];
|
|
47
51
|
readonly recurringEvents: this['props']['recurringEvents'];
|
|
48
52
|
readonly actions: this['props']['actions'];
|
|
49
|
-
|
|
53
|
+
readonly tables: this['props']['tables'];
|
|
54
|
+
constructor(props: PluginDefinitionProps<TName, TVersion, TConfig, TStates, TEvents, TActions, TInterfaces, TIntegrations, TTables>);
|
|
50
55
|
}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { MessageHandlersMap
|
|
2
|
-
import {
|
|
1
|
+
import { MessageHandlersMap as BotMessageHandlersMap, EventHandlersMap as BotEventHandlersMap, StateExpiredHandlersMap as BotStateExpiredHandlersMap, HookHandlersMap as BotHookHandlersMap, ActionHandlers as BotActionHandlers, BotHandlers } from '../bot';
|
|
2
|
+
import { MessageHandlersMap, MessageHandlers, EventHandlersMap, EventHandlers, StateExpiredHandlersMap, StateExpiredHandlers, HookData, HookHandlers, ActionHandlers, PluginConfiguration } from './server/types';
|
|
3
|
+
import { BasePlugin, PluginInterfaceExtensions } from './types';
|
|
3
4
|
export type PluginImplementationProps<TPlugin extends BasePlugin = BasePlugin> = {
|
|
4
5
|
actions: ActionHandlers<TPlugin>;
|
|
5
6
|
};
|
|
6
7
|
export type PluginRuntimeProps<TPlugin extends BasePlugin = BasePlugin> = {
|
|
7
|
-
configuration: TPlugin
|
|
8
|
-
interfaces:
|
|
9
|
-
[K in keyof TPlugin['interfaces']]: {
|
|
10
|
-
name: string;
|
|
11
|
-
version: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
8
|
+
configuration: PluginConfiguration<TPlugin>;
|
|
9
|
+
interfaces: PluginInterfaceExtensions<TPlugin>;
|
|
14
10
|
};
|
|
15
11
|
export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugin> implements BotHandlers<TPlugin> {
|
|
16
12
|
readonly props: PluginImplementationProps<TPlugin>;
|
|
17
13
|
private _runtimeProps;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
private _actionHandlers;
|
|
15
|
+
private _messageHandlers;
|
|
16
|
+
private _eventHandlers;
|
|
17
|
+
private _stateExpiredHandlers;
|
|
18
|
+
private _hookHandlers;
|
|
23
19
|
constructor(props: PluginImplementationProps<TPlugin>);
|
|
24
20
|
initialize(config: PluginRuntimeProps<TPlugin>): this;
|
|
25
|
-
get
|
|
21
|
+
private get _runtime();
|
|
22
|
+
private _getTools;
|
|
23
|
+
get actionHandlers(): BotActionHandlers<TPlugin>;
|
|
24
|
+
get messageHandlers(): BotMessageHandlersMap<TPlugin>;
|
|
25
|
+
get eventHandlers(): BotEventHandlersMap<TPlugin>;
|
|
26
|
+
get stateExpiredHandlers(): BotStateExpiredHandlersMap<TPlugin>;
|
|
27
|
+
get hookHandlers(): BotHookHandlersMap<TPlugin>;
|
|
26
28
|
readonly on: {
|
|
27
29
|
message: <T extends keyof MessageHandlersMap<TPlugin>>(type: T, handler: MessageHandlers<TPlugin>[T]) => void;
|
|
28
30
|
event: <T extends keyof EventHandlersMap<TPlugin>>(type: T, handler: EventHandlers<TPlugin>[T]) => void;
|
|
@@ -36,4 +38,8 @@ export declare class PluginImplementation<TPlugin extends BasePlugin = BasePlugi
|
|
|
36
38
|
afterOutgoingMessage: <T extends keyof HookData<TPlugin>["after_outgoing_message"]>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_message"][T]) => void;
|
|
37
39
|
afterOutgoingCallAction: <T extends keyof HookData<TPlugin>["after_outgoing_call_action"]>(type: T, handler: HookHandlers<TPlugin>["after_outgoing_call_action"][T]) => void;
|
|
38
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* checks if the actual event resolves to the target event
|
|
43
|
+
*/
|
|
44
|
+
private _eventResolvesTo;
|
|
39
45
|
}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PluginInterfaceExtensions } from './types';
|
|
2
|
+
export type ParsedActionRef = {
|
|
3
|
+
namespace: string;
|
|
4
|
+
actionName: string;
|
|
5
|
+
};
|
|
6
|
+
export type ParsedEventRef = {
|
|
7
|
+
namespace: string;
|
|
8
|
+
eventName: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const parseActionRef: (actionRef: string) => ParsedActionRef | null;
|
|
11
|
+
export declare const parseEventRef: (eventRef: string) => ParsedEventRef | null;
|
|
12
|
+
export declare const formatActionRef: (actionRef: ParsedActionRef) => string;
|
|
13
|
+
export declare const formatEventRef: (eventRef: ParsedEventRef) => string;
|
|
14
|
+
export declare const resolveAction: (actionRef: ParsedActionRef, interfaces: PluginInterfaceExtensions<any>) => ParsedActionRef;
|
|
15
|
+
export declare const resolveEvent: (eventRef: ParsedEventRef, interfaces: PluginInterfaceExtensions<any>) => ParsedEventRef;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|