-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
142 lines (115 loc) · 3.61 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* modules with no declaration file */
declare module "restify-clients";
declare namespace Types {
/* alias */
type Activity = import("botbuilder").Activity;
type ConversationReference = import("botbuilder").ConversationReference;
type Context = import("botbuilder").TurnContext;
interface Storage {
/** @return success flag. Updates the conversationRef if needed. */
saveConversation: (
user: string,
conversation: Partial<ConversationReference>
) => Promise<boolean>;
/** @return null if err */
getConversation: (
user: string
) => Promise<Partial<ConversationReference> | null>;
/** @return success flag (independently of actual operation - e.g. already existing entry) */
registerTopic: (topic: string) => Promise<boolean>;
removeTopic: (topic: string) => Promise<boolean>;
/** @return success flag (independently of actual operation - e.g. already existing entry) */
subscribe: (user: string, topic: string) => Promise<boolean>;
cancelSubscription: (user: string, topic: string) => Promise<boolean>;
/** @return null if err */
getSubscribedTopics: (user: string) => Promise<string[] | null>;
/** @return null if err */
getSubscribers: (topic: string) => Promise<string[] | null>;
listUsers: () => Promise<string[]>;
listTopics: () => Promise<string[]>;
/** @return success flag (independently of actual operation - e.g. already existing entry) */
resetSubscriptions: (user: string) => Promise<boolean>;
/** @return success flag (independently of actual operation - e.g. already existing entry) */
removeSubscribers: (topic: string) => Promise<boolean>;
}
interface NotifyOpts {
includeMention?: boolean;
}
interface BroadcastOpts {
ensureTopic?: boolean;
}
interface TopicObj {
name: string;
subscribers: string[];
}
interface UserObj {
user: string;
subscriptions: string[];
}
interface Handlers {
// --------------
// main methods
// --------------
/** bot-SDK entry point */
processMessage: (
req: import("restify").Request,
res: import("restify").Response
) => Promise<void>;
/** @return conversationKey */
notify: (
user: string,
message: string | Partial<Activity>,
opts?: NotifyOpts
) => Promise<string>;
/** @return conversationKeys */
broadcast: (
topics: string[],
message: string | Partial<Activity>,
opts?: BroadcastOpts
) => Promise<string[]>;
// --------------
// admin methods
// --------------
getUsers: () => Promise<string[]>;
getUser: (user: string) => Promise<UserObj>;
getTopics: () => Promise<string[]>;
getTopic: (topic: string) => Promise<TopicObj>;
createTopic: (topic: string) => Promise<TopicObj>;
removeTopic: (topic: string) => Promise<string[]>;
forceSubscription: (user: string, topic: string) => Promise<TopicObj>;
cancelSubscription: (user: string, topic: string) => Promise<TopicObj>;
}
interface ICard {
title: string;
text: string;
}
interface IButton {
title: string;
value: string;
}
interface Config {
cards: {
welcome: ICard;
unknown: ICard;
menu: {
title: string;
checkButton: IButton;
resetButton: IButton;
listButton: IButton;
};
};
}
interface InfoFromContext {
user: string;
text: string;
selectedTopics?: {
subscribeTo: string[];
unsubscribeFrom: string[];
};
conversation: Partial<ConversationReference>;
}
interface SubcriptionStatus {
topic: string;
subscribed: boolean;
}
}