@botpress/sdk 4.8.5 → 4.10.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 +4 -4
- package/dist/fixtures.d.ts +7 -0
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +17 -17
- package/dist/index.mjs.map +4 -4
- package/dist/integration/implementation.d.ts +5 -1
- package/dist/integration/server/types.d.ts +4 -0
- package/dist/plugin/event-proxy/index.d.ts +2 -0
- package/dist/plugin/event-proxy/proxy.d.ts +5 -0
- package/dist/plugin/event-proxy/types.d.ts +14 -0
- package/dist/plugin/event-proxy/types.test.d.ts +1 -0
- package/dist/plugin/server/types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import { BaseIntegration } from './common';
|
|
3
|
-
import { RegisterHandler as RegisterFunction, UnregisterHandler as UnregisterFunction, WebhookHandler as WebhookFunction, CreateUserHandler as CreateUserFunction, CreateConversationHandler as CreateConversationFunction, ActionHandlers as ActionFunctions, ChannelHandlers as ChannelFunctions } from './server';
|
|
3
|
+
import { RegisterHandler as RegisterFunction, UnregisterHandler as UnregisterFunction, WebhookHandler as WebhookFunction, CreateUserHandler as CreateUserFunction, CreateConversationHandler as CreateConversationFunction, ActionHandlers as ActionFunctions, ChannelHandlers as ChannelFunctions, IntegrationOperationHandler as IntegrationOperationFunction } from './server';
|
|
4
4
|
export type IntegrationImplementationProps<TIntegration extends BaseIntegration = BaseIntegration> = {
|
|
5
5
|
register: RegisterFunction<TIntegration>;
|
|
6
6
|
unregister: UnregisterFunction<TIntegration>;
|
|
@@ -15,6 +15,9 @@ export type IntegrationImplementationProps<TIntegration extends BaseIntegration
|
|
|
15
15
|
createConversation?: CreateConversationFunction<TIntegration>;
|
|
16
16
|
actions: ActionFunctions<TIntegration>;
|
|
17
17
|
channels: ChannelFunctions<TIntegration>;
|
|
18
|
+
__advanced?: {
|
|
19
|
+
integrationOperationHandler?: IntegrationOperationFunction<TIntegration>;
|
|
20
|
+
};
|
|
18
21
|
};
|
|
19
22
|
export declare class IntegrationImplementation<TIntegration extends BaseIntegration = BaseIntegration> {
|
|
20
23
|
readonly props: IntegrationImplementationProps<TIntegration>;
|
|
@@ -25,6 +28,7 @@ export declare class IntegrationImplementation<TIntegration extends BaseIntegrat
|
|
|
25
28
|
readonly createUser: IntegrationImplementationProps<TIntegration>['createUser'];
|
|
26
29
|
readonly createConversation: IntegrationImplementationProps<TIntegration>['createConversation'];
|
|
27
30
|
readonly webhook: IntegrationImplementationProps<TIntegration>['handler'];
|
|
31
|
+
readonly integrationOperationHandler: NonNullable<IntegrationImplementationProps<TIntegration>['__advanced']>['integrationOperationHandler'];
|
|
28
32
|
constructor(props: IntegrationImplementationProps<TIntegration>);
|
|
29
33
|
readonly handler: (req: import("../serve").Request) => Promise<import("../serve").Response | void>;
|
|
30
34
|
readonly start: (port?: number) => Promise<Server>;
|
|
@@ -90,6 +90,9 @@ export type ChannelHandlers<TIntegration extends BaseIntegration> = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
+
export type IntegrationOperationHandler<TIntegration extends BaseIntegration> = (props: CommonHandlerProps<TIntegration> & {
|
|
94
|
+
req: Request;
|
|
95
|
+
}) => Promise<Response | void>;
|
|
93
96
|
export type IntegrationHandlers<TIntegration extends BaseIntegration> = {
|
|
94
97
|
register: RegisterHandler<TIntegration>;
|
|
95
98
|
unregister: UnregisterHandler<TIntegration>;
|
|
@@ -98,5 +101,6 @@ export type IntegrationHandlers<TIntegration extends BaseIntegration> = {
|
|
|
98
101
|
createConversation?: CreateConversationHandler<TIntegration>;
|
|
99
102
|
actions: ActionHandlers<TIntegration>;
|
|
100
103
|
channels: ChannelHandlers<TIntegration>;
|
|
104
|
+
integrationOperationHandler?: IntegrationOperationHandler<TIntegration>;
|
|
101
105
|
};
|
|
102
106
|
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Client } from '@botpress/client';
|
|
2
|
+
import { BotSpecificClient } from '../../bot';
|
|
3
|
+
import { BasePlugin, PluginRuntimeProps } from '../common';
|
|
4
|
+
import { EventProxy } from './types';
|
|
5
|
+
export declare const proxyEvents: <TPlugin extends BasePlugin>(client: BotSpecificClient<TPlugin> | Client, props: PluginRuntimeProps<TPlugin>) => EventProxy<TPlugin>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientInputs } from '@botpress/client';
|
|
2
|
+
import * as utils from '../../utils/type-utils';
|
|
3
|
+
import { BasePlugin } from '../common';
|
|
4
|
+
export type EventSchedule = NonNullable<ClientInputs['createEvent']['schedule']>;
|
|
5
|
+
export type EventSender<TPayload> = {
|
|
6
|
+
emit: (event: TPayload) => Promise<void>;
|
|
7
|
+
schedule: (event: TPayload, schedule: EventSchedule) => Promise<void>;
|
|
8
|
+
withConversationId: (conversationId: string) => EventSender<TPayload>;
|
|
9
|
+
withUserId: (userId: string) => EventSender<TPayload>;
|
|
10
|
+
withMessageId: (messageId: string) => EventSender<TPayload>;
|
|
11
|
+
};
|
|
12
|
+
export type EventProxy<TPlugin extends BasePlugin> = utils.Normalize<{
|
|
13
|
+
[TEventName in keyof TPlugin['events']]: EventSender<TPlugin['events'][TEventName]>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,7 @@ import * as workflowProxy from '../../bot/workflow-proxy';
|
|
|
4
4
|
import * as utils from '../../utils/type-utils';
|
|
5
5
|
import * as actionProxy from '../action-proxy';
|
|
6
6
|
import * as common from '../common';
|
|
7
|
+
import * as eventProxy from '../event-proxy';
|
|
7
8
|
import * as stateProxy from '../state-proxy';
|
|
8
9
|
type EnumeratePluginEvents<TPlugin extends common.BasePlugin> = bot.EnumerateEvents<TPlugin> & common.EnumerateInterfaceEvents<TPlugin>;
|
|
9
10
|
type _IncomingEvents<TPlugin extends common.BasePlugin> = {
|
|
@@ -114,6 +115,7 @@ export type CommonHandlerProps<TPlugin extends common.BasePlugin> = {
|
|
|
114
115
|
interfaces: common.PluginInterfaceExtensions<TPlugin>;
|
|
115
116
|
actions: actionProxy.ActionProxy<TPlugin>;
|
|
116
117
|
states: stateProxy.StateProxy<TPlugin>;
|
|
118
|
+
events: eventProxy.EventProxy<TPlugin>;
|
|
117
119
|
alias?: string;
|
|
118
120
|
/**
|
|
119
121
|
* # EXPERIMENTAL
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.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": "1.15.
|
|
19
|
+
"@botpress/client": "1.15.3",
|
|
20
20
|
"browser-or-node": "^2.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|