@botpress/sdk 4.5.0 → 4.6.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.
|
@@ -23,8 +23,4 @@ export type TagsOfMessage<TIntegration extends common.BaseIntegration, TMessageN
|
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated Integration's should no longer use their name as prefix for event types or tags.
|
|
25
25
|
*/
|
|
26
|
-
export type
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Integration's should no longer use their name as prefix for event types or tags.
|
|
29
|
-
*/
|
|
30
|
-
export type WithOptionalPrefix<TTags extends string, TPrefix extends string> = TTags | WithRequiredPrefix<TTags, TPrefix>;
|
|
26
|
+
export type WithPrefix<TTags extends string, TPrefix extends string> = string extends TTags ? string : utils.Join<[TPrefix, ':', TTags]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as client from '@botpress/client';
|
|
2
2
|
import * as utils from '../../utils/type-utils';
|
|
3
3
|
import * as common from '../common';
|
|
4
|
-
import { EnumerateMessages, ConversationTags, GetChannelByName, GetMessageByName, MessageTags,
|
|
4
|
+
import { EnumerateMessages, ConversationTags, GetChannelByName, GetMessageByName, MessageTags, WithPrefix, TagsOfMessage } from './sub-types';
|
|
5
5
|
type Arg<F extends (...args: any[]) => any> = Parameters<F>[number];
|
|
6
6
|
type Res<F extends (...args: any[]) => any> = ReturnType<F>;
|
|
7
7
|
type ConversationResponse<TIntegration extends common.BaseIntegration, ChannelName extends keyof TIntegration['channels'] = keyof TIntegration['channels']> = {
|
|
@@ -34,19 +34,19 @@ export type GetParticipant<_TIntegration extends common.BaseIntegration> = clien
|
|
|
34
34
|
export type RemoveParticipant<_TIntegration extends common.BaseIntegration> = client.Client['removeParticipant'];
|
|
35
35
|
type EventResponse<TIntegration extends common.BaseIntegration, TEvent extends keyof TIntegration['events']> = {
|
|
36
36
|
event: utils.Merge<Awaited<Res<client.Client['getEvent']>>['event'], {
|
|
37
|
-
type:
|
|
37
|
+
type: WithPrefix<utils.Cast<TEvent, string>, TIntegration['name']>;
|
|
38
38
|
payload: TIntegration['events'][TEvent];
|
|
39
39
|
}>;
|
|
40
40
|
};
|
|
41
41
|
export type CreateEvent<TIntegration extends common.BaseIntegration> = <TEvent extends keyof TIntegration['events']>(x: utils.Merge<Arg<client.Client['createEvent']>, {
|
|
42
|
-
type:
|
|
42
|
+
type: utils.Cast<TEvent, string>;
|
|
43
43
|
payload: TIntegration['events'][TEvent];
|
|
44
44
|
}>) => Promise<EventResponse<TIntegration, TEvent>>;
|
|
45
45
|
export type GetEvent<TIntegration extends common.BaseIntegration> = (x: Arg<client.Client['getEvent']>) => Promise<utils.ValueOf<{
|
|
46
46
|
[K in keyof TIntegration['events']]: EventResponse<TIntegration, K>;
|
|
47
47
|
}>>;
|
|
48
48
|
export type ListEvents<TIntegration extends common.BaseIntegration> = (x: utils.Merge<Arg<client.Client['listEvents']>, {
|
|
49
|
-
type?:
|
|
49
|
+
type?: utils.Cast<keyof TIntegration['events'], string>;
|
|
50
50
|
}>) => Res<client.Client['listEvents']>;
|
|
51
51
|
type MessageResponse<TIntegration extends common.BaseIntegration, TMessage extends keyof EnumerateMessages<TIntegration> = keyof EnumerateMessages<TIntegration>> = {
|
|
52
52
|
message: utils.Merge<Awaited<Res<client.Client['createMessage']>>['message'], {
|