-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
types.ts
160 lines (151 loc) · 3.76 KB
/
types.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
export enum Framework {
// < 100 - Web frameworks
WebUnknown = '0',
React = '1',
NextJs = '2',
Angular = '3',
VueJs = '4',
Nuxt = '5',
Svelte = '6',
// 100s - Server side frameworks
ServerSideUnknown = '100',
ReactSSR = '101',
NextJsSSR = '102',
AngularSSR = '103',
VueJsSSR = '104',
NuxtSSR = '105',
SvelteSSR = '106',
// 200s - Mobile framework
ReactNative = '201',
Expo = '202',
}
export enum Category {
API = 'api',
Auth = 'auth',
Analytics = 'analytics',
DataStore = 'datastore',
Geo = 'geo',
InAppMessaging = 'inappmessaging',
Interactions = 'interactions',
Predictions = 'predictions',
PubSub = 'pubsub',
PushNotification = 'pushnotification',
Storage = 'storage',
}
export enum AnalyticsAction {
Record = '1',
UpdateEndpoint = '2',
}
export enum ApiAction {
GraphQl = '1',
Get = '2',
Post = '3',
Put = '4',
Patch = '5',
Del = '6',
Head = '7',
}
export enum AuthAction {
// SignUp = '1',
// ConfirmSignUp = '2',
// ResendSignUp = '3',
// SignIn = '4',
// GetMFAOptions = '5',
// GetPreferredMFA = '6',
// SetPreferredMFA = '7',
// DisableSMS = '8',
// EnableSMS = '9',
// SetupTOTP = '10',
// VerifyTotpToken = '11',
// ConfirmSignIn = '12',
// CompleteNewPassword = '13',
// SendCustomChallengeAnswer = '14',
// DeleteUserAttributes = '15',
// DeleteUser = '16',
// UpdateUserAttributes = '17',
// UserAttributes = '18',
// CurrentUserPoolUser = '19',
// CurrentAuthenticatedUser = '20',
// CurrentSession = '21',
// VerifyUserAttribute = '22',
// VerifyUserAttributeSubmit = '23',
// VerifyCurrentUserAttribute = '24',
// VerifyCurrentUserAttributeSubmit = '25',
// SignOut = '26',
// ChangePassword = '27',
// ForgotPassword = '28',
// ForgotPasswordSubmit = '29',
FederatedSignIn = '30',
// CurrentUserInfo = '31',
// RememberDevice = '32',
// ForgetDevice = '33',
// FetchDevices = '34',
}
export enum DataStoreAction {
Subscribe = '1',
GraphQl = '2',
}
export enum GeoAction {
None = '0',
}
export enum InAppMessagingAction {
None = '0',
}
export enum InteractionsAction {
None = '0',
}
export enum PredictionsAction {
Convert = '1',
Identify = '2',
Interpret = '3',
}
export enum PubSubAction {
Subscribe = '1',
}
export enum PushNotificationAction {
None = '0',
}
export enum StorageAction {
Put = '1',
Get = '2',
List = '3',
Copy = '4',
Remove = '5',
GetProperties = '6',
}
type ActionMap = {
[Category.Auth]: AuthAction;
[Category.API]: ApiAction;
[Category.Analytics]: AnalyticsAction;
[Category.DataStore]: DataStoreAction;
[Category.Geo]: GeoAction;
[Category.InAppMessaging]: InAppMessagingAction;
[Category.Interactions]: InteractionsAction;
[Category.Predictions]: PredictionsAction;
[Category.PubSub]: PubSubAction;
[Category.PushNotification]: PushNotificationAction;
[Category.Storage]: StorageAction;
};
type UserAgentDetailsWithCategory<T extends Category> =
CustomUserAgentDetailsBase & {
category: T;
action: T extends keyof ActionMap ? ActionMap[T] : never;
};
type CustomUserAgentDetailsBase = {
framework?: Framework;
};
export type CustomUserAgentDetails =
| (CustomUserAgentDetailsBase & { category?: never; action?: never })
| UserAgentDetailsWithCategory<Category.API>
| UserAgentDetailsWithCategory<Category.Auth>
| UserAgentDetailsWithCategory<Category.Analytics>
| UserAgentDetailsWithCategory<Category.DataStore>
| UserAgentDetailsWithCategory<Category.Geo>
| UserAgentDetailsWithCategory<Category.Interactions>
| UserAgentDetailsWithCategory<Category.InAppMessaging>
| UserAgentDetailsWithCategory<Category.Predictions>
| UserAgentDetailsWithCategory<Category.PubSub>
| UserAgentDetailsWithCategory<Category.PushNotification>
| UserAgentDetailsWithCategory<Category.Storage>;