@periskope/types 0.6.243 → 0.6.244

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.
@@ -0,0 +1,5 @@
1
+ export * from './object.types';
2
+ export * from './rules.types';
3
+ export * from './supabase.types';
4
+ export * from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,348 @@
1
+ import { Merge, OverrideProperties } from 'type-fest';
2
+ import { Tables } from './supabase.types';
3
+ import { ChatRuleInfoType, MessageRuleInfoType, ReactionRuleInfoType, SenderRuleInfoType, TicketRuleInfoType } from './types';
4
+ export type AppendTypes<T extends object, O extends string> = {
5
+ [K in keyof T & string as `${K}${O}${keyof T[K] & string}`]: T[K][keyof T[K]];
6
+ };
7
+ export type TicketVariablesType = TicketRuleInfoType['ticket'];
8
+ export type MessageVariablesType = MessageRuleInfoType['message'];
9
+ export type SenderVariablesType = SenderRuleInfoType;
10
+ export type ReactionVariablesType = ReactionRuleInfoType['reaction'];
11
+ export type ChatVariablesType = ChatRuleInfoType;
12
+ export type MessageRulesInfoType = Merge<AppendTypes<{
13
+ message: MessageVariablesType;
14
+ sender: SenderVariablesType;
15
+ chat: ChatVariablesType;
16
+ }, '.'>, {
17
+ rule: Tables<'tbl_automation_rules'>[];
18
+ id: 'message.message_id';
19
+ type: `message.${'created' | 'updated' | 'flagged'}`;
20
+ org_id: string;
21
+ }>;
22
+ export type TicketRulesInfoType = Merge<AppendTypes<{
23
+ ticket: TicketVariablesType;
24
+ message: MessageVariablesType;
25
+ sender: SenderVariablesType;
26
+ chat: ChatVariablesType;
27
+ }, '.'>, {
28
+ id: 'ticket.ticket_id';
29
+ type: `ticket.${'created' | 'updated'}`;
30
+ org_id: string;
31
+ rule: Tables<'tbl_automation_rules'>[];
32
+ }>;
33
+ export type ReactionRulesInfoType = Merge<AppendTypes<{
34
+ reaction: ReactionVariablesType;
35
+ message: MessageVariablesType;
36
+ sender: SenderVariablesType;
37
+ chat: ChatVariablesType;
38
+ }, '.'>, {
39
+ rule: Tables<'tbl_automation_rules'>[];
40
+ id: 'reaction.reaction_id';
41
+ type: `reaction.added`;
42
+ org_id: string;
43
+ }>;
44
+ export type ChatRulesInfoType = Merge<AppendTypes<{
45
+ chat: ChatVariablesType;
46
+ }, '.'>, {
47
+ rule: Tables<'tbl_automation_rules'>[];
48
+ id: 'chat.chat_id';
49
+ type: 'chat.created' | 'chat.label.updated';
50
+ org_id: string;
51
+ }>;
52
+ export type RuleInfoType = MessageRulesInfoType | ChatRulesInfoType | TicketRulesInfoType | ReactionRulesInfoType;
53
+ export interface Filter {
54
+ id: string;
55
+ condition: 'CONTAINS' | 'NCONTAINS' | 'EQ' | 'NEQ' | 'LT' | 'LTE' | 'GT' | 'GTE' | 'KNOWN' | 'NKNOWN' | 'IS' | 'NIS' | 'ON';
56
+ variable: string;
57
+ value: string | string[];
58
+ variable_type?: 'string' | 'number' | 'boolean' | 'day-time' | 'date' | 'day';
59
+ }
60
+ export declare const isFilter: (filter: any) => filter is Filter;
61
+ export declare const FilterNameMap: Record<Filter['condition'], {
62
+ name: string;
63
+ input: boolean;
64
+ }>;
65
+ export type VariableNameValueType = {
66
+ text: string;
67
+ type: 'string' | 'time' | 'boolean' | 'dropdown' | 'day-time' | 'number' | 'date';
68
+ variable_type: 'string' | 'number' | 'boolean' | 'day-time' | 'date';
69
+ value?: string | {
70
+ id: string;
71
+ value: string | number | boolean;
72
+ label: string;
73
+ }[] | null;
74
+ filters: Partial<Record<Filter['condition'], {
75
+ info?: string;
76
+ }>> | Filter['condition'][];
77
+ hidden?: boolean;
78
+ placeholder?: string;
79
+ info?: string;
80
+ };
81
+ export declare const MessageVariableNameMap: Record<keyof AppendTypes<{
82
+ message: MessageVariablesType;
83
+ }, '.'>, VariableNameValueType>;
84
+ export declare const SenderVariableNameMap: Record<keyof AppendTypes<{
85
+ sender: SenderVariablesType;
86
+ }, '.'>, VariableNameValueType>;
87
+ export declare const ChatVariableNameMap: Record<keyof AppendTypes<{
88
+ chat: ChatVariablesType;
89
+ }, '.'>, VariableNameValueType>;
90
+ export declare const TicketVariableNameMap: Record<keyof AppendTypes<{
91
+ ticket: TicketVariablesType;
92
+ }, '.'>, VariableNameValueType>;
93
+ export declare const ReactionVariableNameMap: Record<keyof AppendTypes<{
94
+ reaction: ReactionVariablesType;
95
+ }, '.'>, VariableNameValueType>;
96
+ export declare enum FilterConditionMap {
97
+ 'CONTAINS' = "contains",
98
+ 'NCONTAINS' = "does not contain",
99
+ 'EQ' = "=",
100
+ 'NEQ' = "<>",
101
+ 'LT' = "<",
102
+ 'LTE' = "<=",
103
+ 'GT' = ">",
104
+ 'GTE' = ">=",
105
+ 'KNOWN' = "is known",
106
+ 'NKNOWN' = "is not known",
107
+ 'IS' = "=",
108
+ 'NIS' = "<>",
109
+ 'ON' = "on"
110
+ }
111
+ interface FilterGroup {
112
+ filters: Filter[];
113
+ condition: 'allOf' | 'anyOf';
114
+ }
115
+ export interface Conditions {
116
+ filters: FilterGroup[];
117
+ condition: 'allOf' | 'anyOf';
118
+ variables: string[];
119
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
120
+ org_phones: string[];
121
+ allow_messages_from_org_phones?: boolean;
122
+ }
123
+ export type SendMessageAction = {
124
+ id: string;
125
+ type: 'send_message';
126
+ metadata: {
127
+ message: string;
128
+ media?: {
129
+ url: string;
130
+ type: 'image' | 'video' | 'audio' | 'document';
131
+ name: string;
132
+ };
133
+ maintain_flag_status: 'true' | 'false';
134
+ debounce_messages: 'true' | 'false';
135
+ debounce_message_time: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null | undefined;
136
+ };
137
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
138
+ };
139
+ export type NotifyHttpAction = {
140
+ id: string;
141
+ type: 'notify_http';
142
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
143
+ metadata: {
144
+ url: string;
145
+ };
146
+ };
147
+ export type CreateTicketAction = {
148
+ id: string;
149
+ type: 'create_ticket';
150
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
151
+ metadata: {
152
+ priority?: '0' | '1' | '2' | '3' | '4';
153
+ label?: string;
154
+ append_to_latest_ticket?: 'true' | 'false';
155
+ round_robin?: 'true' | 'false';
156
+ assignee?: string;
157
+ };
158
+ };
159
+ export type FlagMessageAction = {
160
+ id: string;
161
+ type: 'flag_message';
162
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
163
+ metadata: {
164
+ flag: 'true' | 'false';
165
+ };
166
+ };
167
+ export type AssignTicketAction = {
168
+ id: string;
169
+ type: 'assign_ticket';
170
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
171
+ metadata: {
172
+ assignee: string;
173
+ round_robin: 'true' | 'false';
174
+ };
175
+ };
176
+ export type CloseTicketAction = {
177
+ id: string;
178
+ type: 'close_ticket';
179
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
180
+ metadata: {
181
+ closing_note: string;
182
+ };
183
+ };
184
+ export type AddChatLabelAction = {
185
+ id: string;
186
+ type: 'add_chat_label';
187
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
188
+ metadata: {
189
+ label: string;
190
+ };
191
+ };
192
+ export type AddTicketLabelAction = {
193
+ id: string;
194
+ type: 'add_ticket_label';
195
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
196
+ metadata: {
197
+ label: string;
198
+ };
199
+ };
200
+ export type AssignChatAction = {
201
+ id: string;
202
+ type: 'assign_chat';
203
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
204
+ metadata: {
205
+ assignee: string;
206
+ round_robin: 'true' | 'false';
207
+ };
208
+ };
209
+ export type ForwardMessageAction = {
210
+ id: string;
211
+ type: 'forward_message';
212
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
213
+ metadata: {
214
+ chat_id: string;
215
+ prefix: string;
216
+ };
217
+ };
218
+ export type SendEmailAction = {
219
+ id: string;
220
+ type: 'send_email';
221
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
222
+ metadata: {
223
+ email: string;
224
+ subject: string;
225
+ body: string;
226
+ };
227
+ };
228
+ export type ReplyToMessageAction = {
229
+ id: string;
230
+ type: 'reply_to_message';
231
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
232
+ metadata: {
233
+ message: string;
234
+ media?: {
235
+ url: string;
236
+ type: 'image' | 'video' | 'audio' | 'document';
237
+ name: string;
238
+ };
239
+ maintain_flag_status: 'true' | 'false';
240
+ debounce_messages: 'true' | 'false';
241
+ debounce_message_time: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}` | null | undefined;
242
+ };
243
+ };
244
+ export type UpdateCustomPropertyAction = {
245
+ id: string;
246
+ type: 'update_custom_property';
247
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
248
+ metadata: {
249
+ property_id: string;
250
+ value: string;
251
+ };
252
+ };
253
+ export type DeleteMessageAction = {
254
+ id: string;
255
+ type: 'delete_message';
256
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
257
+ metadata: {};
258
+ };
259
+ export type SendSlackNotificationAction = {
260
+ id: string;
261
+ type: 'send_slack_notification';
262
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
263
+ metadata: {
264
+ slack_payload: string;
265
+ webhook_url: string;
266
+ };
267
+ };
268
+ export type AttachMessageToTicketAction = {
269
+ id: string;
270
+ type: 'attach_message_to_ticket';
271
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
272
+ metadata: {
273
+ status: 'open' | 'inprogress' | 'open_inprogress' | null;
274
+ };
275
+ };
276
+ export type CloseChatAction = {
277
+ id: string;
278
+ type: 'close_chat';
279
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
280
+ metadata: {};
281
+ };
282
+ export type SendMessageToChatAction = {
283
+ id: string;
284
+ type: 'send_message_to_chat';
285
+ delay: `${number} ${'seconds' | 'minutes' | 'hours' | 'days'}`;
286
+ metadata: {
287
+ chat_id: string;
288
+ message: string;
289
+ media?: {
290
+ url: string;
291
+ type: 'image' | 'video' | 'audio' | 'document';
292
+ name: string;
293
+ };
294
+ };
295
+ };
296
+ export type Action = SendMessageAction | NotifyHttpAction | CreateTicketAction | FlagMessageAction | AssignTicketAction | CloseTicketAction | AddChatLabelAction | AddTicketLabelAction | AssignChatAction | ForwardMessageAction | SendEmailAction | ReplyToMessageAction | UpdateCustomPropertyAction | DeleteMessageAction | SendSlackNotificationAction | AttachMessageToTicketAction | CloseChatAction | SendMessageToChatAction;
297
+ export declare const isSendMessageOrReplyToMessageAction: (action: Action) => action is SendMessageAction | ReplyToMessageAction;
298
+ export type Rule = OverrideProperties<Tables<'tbl_automation_rules'>, {
299
+ actions: Action[];
300
+ conditions: Conditions;
301
+ trigger: 'message.created' | 'message.updated' | 'chat.created' | 'ticket.updated' | 'ticket.created' | 'reaction.added' | 'chat.label.updated' | 'message.flagged';
302
+ }>;
303
+ export declare const RuleNameMap: Record<Rule['trigger'], {
304
+ title: string;
305
+ description: string;
306
+ base_conditions: {
307
+ org_phone: boolean;
308
+ };
309
+ }>;
310
+ export declare const ActionNameMap: Record<Action['type'], {
311
+ title: string;
312
+ description: string;
313
+ inputs: Record<string, {
314
+ id: string;
315
+ type: 'text' | 'dropdown' | 'editor' | 'date' | 'file' | 'textarea' | 'dynamic' | 'json_editor';
316
+ value: 'ticket.labels' | 'org.members' | 'chat.labels' | 'org.chats' | {
317
+ id: string;
318
+ value: string;
319
+ label: string;
320
+ }[] | null | 'org.custom_properties' | 'custom_property_values' | 'debounce_messages';
321
+ label: string;
322
+ placeholder: string;
323
+ info?: string;
324
+ required: boolean;
325
+ description?: string;
326
+ }>;
327
+ info?: string;
328
+ validTriggers: Rule['trigger'][];
329
+ }>;
330
+ type editorVariablesList = 'chat.assigned_to' | 'chat.chat_id' | 'chat.chat_name' | 'chat.chat_type' | 'chat.org_phone' | 'chat.org_id' | 'chat.group_description' | 'ticket.assignee' | 'ticket.due_date' | 'ticket.priority' | 'ticket.status' | 'ticket.subject' | 'ticket.ticket_id' | 'ticket.raised_by' | 'ticket.created_at' | 'sender.is_internal' | 'sender.is_admin' | 'sender.contact_name' | 'sender.contact_id' | 'reaction.sender_id' | 'reaction.reaction' | 'message.message_id' | 'message.timestamp' | 'message.sender_phone' | 'message.message_type' | 'message.media' | 'message.body';
331
+ export declare const editorVariables: Array<{
332
+ label: string;
333
+ value: editorVariablesList;
334
+ validTriggers: Rule['trigger'][];
335
+ }>;
336
+ export declare const variablesExclusionList: Record<Rule['trigger'], Array<keyof AppendTypes<{
337
+ message: MessageVariablesType;
338
+ }, '.'> | keyof AppendTypes<{
339
+ sender: SenderVariablesType;
340
+ }, '.'> | keyof AppendTypes<{
341
+ chat: ChatVariablesType;
342
+ }, '.'> | keyof AppendTypes<{
343
+ ticket: TicketVariablesType;
344
+ }, '.'> | keyof AppendTypes<{
345
+ reaction: ReactionVariablesType;
346
+ }, '.'>>>;
347
+ export {};
348
+ //# sourceMappingURL=rules.types.d.ts.map