-
Notifications
You must be signed in to change notification settings - Fork 0
/
moveo.d.ts
140 lines (124 loc) · 2.99 KB
/
moveo.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
import { NextApiHandler, NextApiRequest } from 'next';
import pino from 'pino';
declare global {
namespace NodeJS {
interface ProcessEnv {
PRIVATE_RSA_KEY: string;
// Deprecated variable use the one above
PISTI_PRIVATE_RSA_KEY: string;
PRIVATE_PISTI_RSA_KEY: string;
VERCEL_ENV: string;
VERCEL: string;
// Only in kubernetes
MY_POD_NAME: string;
USE_PROXY: string;
NODE_ENV: 'development' | 'production';
PORT?: string;
}
}
}
type MoveoChannel =
| 'facebook'
| 'viber'
| 'web'
| 'zendesk'
| 'hangout'
| 'apifon';
type MoveoContextWithPageInfo = {
context: MoveoContext;
page?: FacebookPageContext | null;
trigger_node_id?: string;
user_id?: string;
};
interface MoveoContext {
[key: string]: string | number | boolean | null | undefined;
}
/**
* Output/Responses can be undefined in case no context variables are
* returned and because `{}` does not work in TypeScript
*/
interface WebhookResponse {
output?: MoveoContext;
responses?: Action[];
}
export type WebhookAction = {
action_id: string;
type: 'webhook';
webhook_id: string;
fallback: Action[];
};
export type Action = {
action_id: string;
} & (
| {
type: 'text';
texts: string[];
options?: { label: string; text: string }[];
}
| {
type: 'handover';
external: boolean;
}
| { type: 'url'; url: string }
| { type: 'audio'; url: string }
| { type: 'image'; url: string; name: string; size: number }
| { type: 'video'; url: string; name: string; size: number }
| { type: 'file'; url: string; name: string; size: number }
| { type: 'carousel'; cards: CarouselCardProps[] }
| {
type: 'webview';
url: string;
name: string;
label: string;
height: string;
trigger_node_id: string;
}
| {
type: 'reset';
nodeId: string;
name: string;
variables?: string[];
}
| WebhookAction
| {
type: 'tag';
tags: string[];
}
| {
type: 'event';
name: string;
trigger_node_id: string;
}
);
type ButtonBase = { label: string; type: string };
type AsUrl = { type: 'url'; url: string };
type AsPostback = { type: 'postback'; value: string };
type AsPhone = { type: 'phone'; value: string };
type AsWebview = {
type: 'webview';
url: string;
trigger_node_id: string;
height?: 'tall' | 'compact' | 'full';
};
export type CarouselButton = ButtonBase &
(AsUrl | AsPostback | AsPhone | AsWebview);
export type CarouselCardProps = {
title: string;
subtitle: string;
media: { type: 'image' | 'video'; url: string };
default_action?: CarouselButton;
buttons: CarouselButton[];
};
type NextApiRequestWithLog = NextApiRequest & {
moveo_id: string;
id: string;
log: pino.Logger;
rawBody?: ArrayBuffer;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type ApiHandler<T = any> =
| NextApiHandler<T>
| ((
req: NextApiRequestWithLog,
res: NextApiResponse<T>
) => void | Promise<void>);