-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathtypes.d.ts
88 lines (75 loc) · 2.54 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
import * as twilio from 'twilio';
import { ServiceContext } from 'twilio/lib/rest/sync/v1/service';
import { SyncListListInstance } from 'twilio/lib/rest/sync/v1/service/syncList';
import { SyncMapListInstance } from 'twilio/lib/rest/sync/v1/service/syncMap';
import { TwilioClientOptions } from 'twilio/lib/rest/Twilio';
export type EnvironmentVariables = {
[key: string]: string | undefined;
};
export type ResourceMap = {
[name: string]: {
path: string;
};
};
export type AssetResourceMap = {
[name: string]: {
path: string;
open(): string;
};
};
export interface TwilioResponse {
setStatusCode(code: number): TwilioResponse;
setBody(body: string | object): TwilioResponse;
appendHeader(key: string, value: string): TwilioResponse;
setHeaders(headers: { [key: string]: string }): TwilioResponse;
setCookie(key: string, value: string, attributes?: string[]): TwilioResponse;
removeCookie(key: string): TwilioResponse;
}
export type RuntimeSyncClientOptions = TwilioClientOptions & {
serviceName?: string;
};
export type RuntimeSyncServiceContext = ServiceContext & {
maps: SyncMapListInstance;
lists: SyncListListInstance;
};
export type RuntimeInstance = {
getAssets(): AssetResourceMap;
getFunctions(): ResourceMap;
getSync(options?: RuntimeSyncClientOptions): RuntimeSyncServiceContext;
};
export type Context<T = {}> = {
getTwilioClient(options?: TwilioClientOptions): twilio.Twilio;
DOMAIN_NAME: string;
} & T;
export type ServerlessCallback = (
error: null | Error | string | object,
payload?: object | string | number | boolean
) => void;
export type ServerlessEventObject<
RequestBodyAndQuery = {},
Headers = {},
Cookies = {}
> = {
request: {
cookies: Cookies;
headers: Headers;
};
} & RequestBodyAndQuery;
export type ServerlessFunctionSignature<
T extends EnvironmentVariables = {},
U extends ServerlessEventObject = { request: { cookies: {}; headers: {} } }
> = (
context: Context<T>,
event: U,
callback: ServerlessCallback
) => void | Promise<void>;
export type ResponseConstructor = new (...args: any[]) => TwilioResponse;
export type GlobalTwilio = Omit<typeof twilio, 'default'> & {
Response: ResponseConstructor;
};
export { ServiceContext } from 'twilio/lib/rest/sync/v1/service';
export { SyncListListInstance } from 'twilio/lib/rest/sync/v1/service/syncList';
export { SyncMapListInstance } from 'twilio/lib/rest/sync/v1/service/syncMap';
export { TwilioClientOptions } from 'twilio/lib/rest/Twilio';
export type TwilioClient = twilio.Twilio;
export type TwilioPackage = typeof twilio;