@wats/graph 0.3.1
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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/client.d.ts +41 -0
- package/dist/client.js +392 -0
- package/dist/createFetchTransport.d.ts +6 -0
- package/dist/createFetchTransport.js +46 -0
- package/dist/createMockTransport.d.ts +20 -0
- package/dist/createMockTransport.js +120 -0
- package/dist/endpoint.d.ts +26 -0
- package/dist/endpoint.js +223 -0
- package/dist/endpoints/businessManagement.d.ts +157 -0
- package/dist/endpoints/businessManagement.js +277 -0
- package/dist/endpoints/calling.d.ts +65 -0
- package/dist/endpoints/calling.js +284 -0
- package/dist/endpoints/flows/callables.d.ts +90 -0
- package/dist/endpoints/flows/callables.js +97 -0
- package/dist/endpoints/flows/dataExchange.d.ts +4 -0
- package/dist/endpoints/flows/dataExchange.js +40 -0
- package/dist/endpoints/flows/flowJson.d.ts +18 -0
- package/dist/endpoints/flows/flowJson.js +214 -0
- package/dist/endpoints/flows/index.d.ts +6 -0
- package/dist/endpoints/flows/index.js +26 -0
- package/dist/endpoints/flows/shared.d.ts +17 -0
- package/dist/endpoints/flows/shared.js +113 -0
- package/dist/endpoints/flows/types.d.ts +105 -0
- package/dist/endpoints/flows/types.js +0 -0
- package/dist/endpoints/flows.d.ts +2 -0
- package/dist/endpoints/flows.js +23 -0
- package/dist/endpoints/media.d.ts +123 -0
- package/dist/endpoints/media.js +976 -0
- package/dist/endpoints/messages.d.ts +375 -0
- package/dist/endpoints/messages.js +675 -0
- package/dist/endpoints/templates/builders.d.ts +9 -0
- package/dist/endpoints/templates/builders.js +101 -0
- package/dist/endpoints/templates/callables.d.ts +54 -0
- package/dist/endpoints/templates/callables.js +98 -0
- package/dist/endpoints/templates/index.d.ts +5 -0
- package/dist/endpoints/templates/index.js +16 -0
- package/dist/endpoints/templates/shared.d.ts +21 -0
- package/dist/endpoints/templates/shared.js +203 -0
- package/dist/endpoints/templates/types.d.ts +135 -0
- package/dist/endpoints/templates/types.js +0 -0
- package/dist/endpoints/templates/validation.d.ts +2 -0
- package/dist/endpoints/templates/validation.js +113 -0
- package/dist/endpoints/templates.d.ts +2 -0
- package/dist/endpoints/templates.js +14 -0
- package/dist/endpoints/waba/index.d.ts +4 -0
- package/dist/endpoints/waba/index.js +1 -0
- package/dist/endpoints/waba/phoneNumbers.d.ts +25 -0
- package/dist/endpoints/waba/phoneNumbers.js +23 -0
- package/dist/endpoints/waba/types.d.ts +8 -0
- package/dist/endpoints/waba/types.js +0 -0
- package/dist/endpoints/wabaEndpoints.d.ts +6 -0
- package/dist/endpoints/wabaEndpoints.js +38 -0
- package/dist/errorRegistry.d.ts +45 -0
- package/dist/errorRegistry.js +68 -0
- package/dist/errorSubclasses.d.ts +277 -0
- package/dist/errorSubclasses.js +613 -0
- package/dist/errors.d.ts +92 -0
- package/dist/errors.js +250 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +48 -0
- package/dist/internal/validation/arrays.d.ts +19 -0
- package/dist/internal/validation/arrays.js +102 -0
- package/dist/internal/validation/errors.d.ts +3 -0
- package/dist/internal/validation/errors.js +13 -0
- package/dist/internal/validation/headers.d.ts +15 -0
- package/dist/internal/validation/headers.js +77 -0
- package/dist/internal/validation/index.d.ts +8 -0
- package/dist/internal/validation/index.js +8 -0
- package/dist/internal/validation/json.d.ts +10 -0
- package/dist/internal/validation/json.js +79 -0
- package/dist/internal/validation/options.d.ts +5 -0
- package/dist/internal/validation/options.js +36 -0
- package/dist/internal/validation/paths.d.ts +8 -0
- package/dist/internal/validation/paths.js +37 -0
- package/dist/internal/validation/records.d.ts +20 -0
- package/dist/internal/validation/records.js +69 -0
- package/dist/internal/validation/strings.d.ts +12 -0
- package/dist/internal/validation/strings.js +46 -0
- package/dist/pagination.d.ts +35 -0
- package/dist/pagination.js +160 -0
- package/dist/subclients/phoneNumberClient.d.ts +60 -0
- package/dist/subclients/phoneNumberClient.js +194 -0
- package/dist/subclients/wabaClient.d.ts +66 -0
- package/dist/subclients/wabaClient.js +180 -0
- package/dist/transport.d.ts +32 -0
- package/dist/transport.js +5 -0
- package/package.json +70 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GraphApiError,
|
|
3
|
+
GraphAuthError,
|
|
4
|
+
GraphRateLimitError
|
|
5
|
+
} from "./errors";
|
|
6
|
+
import {
|
|
7
|
+
isBuiltInRegistered,
|
|
8
|
+
markBuiltInRegistered,
|
|
9
|
+
registerErrorCode
|
|
10
|
+
} from "./errorRegistry";
|
|
11
|
+
function messageOf(ctx, fallback) {
|
|
12
|
+
const payload = ctx.payload;
|
|
13
|
+
if (payload !== undefined && typeof payload.message === "string" && payload.message.length > 0) {
|
|
14
|
+
return payload.message;
|
|
15
|
+
}
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
function coreParams(ctx, fallback) {
|
|
19
|
+
const out = {
|
|
20
|
+
message: messageOf(ctx, fallback),
|
|
21
|
+
status: ctx.status
|
|
22
|
+
};
|
|
23
|
+
if (ctx.payload !== undefined) {
|
|
24
|
+
out.payload = ctx.payload;
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AuthException extends GraphAuthError {
|
|
30
|
+
static errorCode = 0;
|
|
31
|
+
constructor(ctx) {
|
|
32
|
+
super(coreParams(ctx, "We were unable to authenticate the app user."));
|
|
33
|
+
this.name = "AuthException";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class APIMethodError extends GraphAuthError {
|
|
38
|
+
static errorCode = 3;
|
|
39
|
+
constructor(ctx) {
|
|
40
|
+
super(coreParams(ctx, "Capability or permissions issue."));
|
|
41
|
+
this.name = "APIMethodError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class PermissionDeniedError extends GraphAuthError {
|
|
46
|
+
static errorCode = 10;
|
|
47
|
+
constructor(ctx) {
|
|
48
|
+
super(coreParams(ctx, "Permission is either not granted or has been removed."));
|
|
49
|
+
this.name = "PermissionDeniedError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class ExpiredAccessTokenError extends GraphAuthError {
|
|
54
|
+
static errorCode = 190;
|
|
55
|
+
constructor(ctx) {
|
|
56
|
+
super(coreParams(ctx, "Your access token has expired."));
|
|
57
|
+
this.name = "ExpiredAccessTokenError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class APIPermissionError extends GraphAuthError {
|
|
62
|
+
static errorCode = 200;
|
|
63
|
+
constructor(ctx) {
|
|
64
|
+
super(coreParams(ctx, "Permission is either not granted or has been removed."));
|
|
65
|
+
this.name = "APIPermissionError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class ToManyAPICallsError extends GraphRateLimitError {
|
|
70
|
+
static errorCode = 4;
|
|
71
|
+
constructor(ctx) {
|
|
72
|
+
super(coreParams(ctx, "The app has reached its API call rate limit."));
|
|
73
|
+
this.name = "ToManyAPICallsError";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class RateLimitIssuesError extends GraphRateLimitError {
|
|
78
|
+
static errorCode = 80007;
|
|
79
|
+
constructor(ctx) {
|
|
80
|
+
super(coreParams(ctx, "The WhatsApp Business Account has reached its rate limit."));
|
|
81
|
+
this.name = "RateLimitIssuesError";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class RateLimitHitError extends GraphRateLimitError {
|
|
86
|
+
static errorCode = 130429;
|
|
87
|
+
constructor(ctx) {
|
|
88
|
+
super(coreParams(ctx, "Cloud API message throughput has been reached."));
|
|
89
|
+
this.name = "RateLimitHitError";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class SpamRateLimitHitError extends GraphRateLimitError {
|
|
94
|
+
static errorCode = 131048;
|
|
95
|
+
constructor(ctx) {
|
|
96
|
+
super(coreParams(ctx, "Message failed due to spam rate limit restrictions."));
|
|
97
|
+
this.name = "SpamRateLimitHitError";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class TooManyMessagesError extends GraphRateLimitError {
|
|
102
|
+
static errorCode = 131056;
|
|
103
|
+
constructor(ctx) {
|
|
104
|
+
super(coreParams(ctx, "Too many messages from sender to recipient in a short period."));
|
|
105
|
+
this.name = "TooManyMessagesError";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export class TemporarilyBlockedError extends GraphApiError {
|
|
110
|
+
static errorCode = 368;
|
|
111
|
+
constructor(ctx) {
|
|
112
|
+
super(coreParams(ctx, "Account temporarily blocked for a policy violation."));
|
|
113
|
+
this.name = "TemporarilyBlockedError";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export class AccountLockedError extends GraphApiError {
|
|
118
|
+
static errorCode = 131031;
|
|
119
|
+
constructor(ctx) {
|
|
120
|
+
super(coreParams(ctx, "Account locked."));
|
|
121
|
+
this.name = "AccountLockedError";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class AccountRestrictedFromCountryError extends GraphApiError {
|
|
126
|
+
static errorCode = 130497;
|
|
127
|
+
constructor(ctx) {
|
|
128
|
+
super(coreParams(ctx, "Account restricted from messaging users in this country."));
|
|
129
|
+
this.name = "AccountRestrictedFromCountryError";
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class UserIsInExperimentGroupError extends GraphApiError {
|
|
134
|
+
static errorCode = 130472;
|
|
135
|
+
constructor(ctx) {
|
|
136
|
+
super(coreParams(ctx, "User is part of a marketing message experiment group."));
|
|
137
|
+
this.name = "UserIsInExperimentGroupError";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export class MessageUndeliverableError extends GraphApiError {
|
|
142
|
+
static errorCode = 131026;
|
|
143
|
+
constructor(ctx) {
|
|
144
|
+
super(coreParams(ctx, "Message undeliverable."));
|
|
145
|
+
this.name = "MessageUndeliverableError";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class ReEngagementMessageError extends GraphApiError {
|
|
150
|
+
static errorCode = 131047;
|
|
151
|
+
constructor(ctx) {
|
|
152
|
+
super(coreParams(ctx, "More than 24 hours have passed since the recipient last replied."));
|
|
153
|
+
this.name = "ReEngagementMessageError";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export class UnsupportedMessageTypeError extends GraphApiError {
|
|
158
|
+
static errorCode = 131051;
|
|
159
|
+
constructor(ctx) {
|
|
160
|
+
super(coreParams(ctx, "The message type is not supported."));
|
|
161
|
+
this.name = "UnsupportedMessageTypeError";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export class MediaDownloadError extends GraphApiError {
|
|
166
|
+
static errorCode = 131052;
|
|
167
|
+
constructor(ctx) {
|
|
168
|
+
super(coreParams(ctx, "Unable to download the media sent by the user."));
|
|
169
|
+
this.name = "MediaDownloadError";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export class MediaUploadError extends GraphApiError {
|
|
174
|
+
static errorCode = 131053;
|
|
175
|
+
constructor(ctx) {
|
|
176
|
+
super(coreParams(ctx, "Unable to upload the media used in the message."));
|
|
177
|
+
this.name = "MediaUploadError";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export class RecipientNotInAllowedListError extends GraphApiError {
|
|
182
|
+
static errorCode = 131030;
|
|
183
|
+
constructor(ctx) {
|
|
184
|
+
super(coreParams(ctx, "Recipient is not in the test-number allowed list."));
|
|
185
|
+
this.name = "RecipientNotInAllowedListError";
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class InvalidParameterError extends GraphApiError {
|
|
190
|
+
static errorCode = 131009;
|
|
191
|
+
constructor(ctx) {
|
|
192
|
+
super(coreParams(ctx, "The parameter you passed is invalid."));
|
|
193
|
+
this.name = "InvalidParameterError";
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export class MissingRequiredParameterError extends GraphApiError {
|
|
198
|
+
static errorCode = 131008;
|
|
199
|
+
constructor(ctx) {
|
|
200
|
+
super(coreParams(ctx, "A required parameter is missing."));
|
|
201
|
+
this.name = "MissingRequiredParameterError";
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class TemplateParamCountMismatchError extends GraphApiError {
|
|
206
|
+
static errorCode = 132000;
|
|
207
|
+
constructor(ctx) {
|
|
208
|
+
super(coreParams(ctx, "Template parameter count mismatch."));
|
|
209
|
+
this.name = "TemplateParamCountMismatchError";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export class TemplateNotExistsError extends GraphApiError {
|
|
214
|
+
static errorCode = 132001;
|
|
215
|
+
constructor(ctx) {
|
|
216
|
+
super(coreParams(ctx, "Template does not exist in the specified language or is unapproved."));
|
|
217
|
+
this.name = "TemplateNotExistsError";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export class TemplateTextTooLongError extends GraphApiError {
|
|
222
|
+
static errorCode = 132005;
|
|
223
|
+
constructor(ctx) {
|
|
224
|
+
super(coreParams(ctx, "Template text too long."));
|
|
225
|
+
this.name = "TemplateTextTooLongError";
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export class TemplateContentPolicyViolationError extends GraphApiError {
|
|
230
|
+
static errorCode = 132007;
|
|
231
|
+
constructor(ctx) {
|
|
232
|
+
super(coreParams(ctx, "Template content policy violation."));
|
|
233
|
+
this.name = "TemplateContentPolicyViolationError";
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export class TemplateParamValueInvalidError extends GraphApiError {
|
|
238
|
+
static errorCode = 132008;
|
|
239
|
+
constructor(ctx) {
|
|
240
|
+
super(coreParams(ctx, "Template parameter value formatted incorrectly."));
|
|
241
|
+
this.name = "TemplateParamValueInvalidError";
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export class TemplateParamFormatMismatchError extends GraphApiError {
|
|
246
|
+
static errorCode = 132012;
|
|
247
|
+
constructor(ctx) {
|
|
248
|
+
super(coreParams(ctx, "Template parameter format mismatch."));
|
|
249
|
+
this.name = "TemplateParamFormatMismatchError";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export class TemplatePausedError extends GraphApiError {
|
|
254
|
+
static errorCode = 132015;
|
|
255
|
+
constructor(ctx) {
|
|
256
|
+
super(coreParams(ctx, "Template paused due to low quality."));
|
|
257
|
+
this.name = "TemplatePausedError";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export class TemplateDisabledError extends GraphApiError {
|
|
262
|
+
static errorCode = 132016;
|
|
263
|
+
constructor(ctx) {
|
|
264
|
+
super(coreParams(ctx, "Template permanently disabled."));
|
|
265
|
+
this.name = "TemplateDisabledError";
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export class FlowBlockedError extends GraphApiError {
|
|
270
|
+
static errorCode = 132068;
|
|
271
|
+
constructor(ctx) {
|
|
272
|
+
super(coreParams(ctx, "Flow is in blocked state."));
|
|
273
|
+
this.name = "FlowBlockedError";
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export class FlowThrottledError extends GraphApiError {
|
|
278
|
+
static errorCode = 132069;
|
|
279
|
+
constructor(ctx) {
|
|
280
|
+
super(coreParams(ctx, "Flow is in throttled state."));
|
|
281
|
+
this.name = "FlowThrottledError";
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export class GenericError extends GraphApiError {
|
|
286
|
+
static errorCode = 135000;
|
|
287
|
+
constructor(ctx) {
|
|
288
|
+
super(coreParams(ctx, "Generic error."));
|
|
289
|
+
this.name = "GenericError";
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export class UnknownError extends GraphApiError {
|
|
294
|
+
static errorCode = 131000;
|
|
295
|
+
constructor(ctx) {
|
|
296
|
+
super(coreParams(ctx, "Message failed to send due to an unknown error."));
|
|
297
|
+
this.name = "UnknownError";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export class AccessDeniedError extends GraphApiError {
|
|
302
|
+
static errorCode = 131005;
|
|
303
|
+
constructor(ctx) {
|
|
304
|
+
super(coreParams(ctx, "Access denied for this resource."));
|
|
305
|
+
this.name = "AccessDeniedError";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export class ServiceUnavailableError extends GraphApiError {
|
|
310
|
+
static errorCode = 131016;
|
|
311
|
+
constructor(ctx) {
|
|
312
|
+
super(coreParams(ctx, "Service temporarily unavailable."));
|
|
313
|
+
this.name = "ServiceUnavailableError";
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export class RecipientCannotBeSenderError extends GraphApiError {
|
|
318
|
+
static errorCode = 131021;
|
|
319
|
+
constructor(ctx) {
|
|
320
|
+
super(coreParams(ctx, "Recipient cannot be the sender."));
|
|
321
|
+
this.name = "RecipientCannotBeSenderError";
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export class BusinessPaymentIssueError extends GraphApiError {
|
|
326
|
+
static errorCode = 131042;
|
|
327
|
+
constructor(ctx) {
|
|
328
|
+
super(coreParams(ctx, "Business payment issue."));
|
|
329
|
+
this.name = "BusinessPaymentIssueError";
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export class IncorrectCertificateError extends GraphApiError {
|
|
334
|
+
static errorCode = 131045;
|
|
335
|
+
constructor(ctx) {
|
|
336
|
+
super(coreParams(ctx, "Message failed due to a phone number registration error."));
|
|
337
|
+
this.name = "IncorrectCertificateError";
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export class AccountInMaintenanceModeError extends GraphApiError {
|
|
342
|
+
static errorCode = 131057;
|
|
343
|
+
constructor(ctx) {
|
|
344
|
+
super(coreParams(ctx, "Business Account is in maintenance mode."));
|
|
345
|
+
this.name = "AccountInMaintenanceModeError";
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export class UserStoppedMarketingMessagesError extends GraphApiError {
|
|
350
|
+
static errorCode = 131050;
|
|
351
|
+
constructor(ctx) {
|
|
352
|
+
super(coreParams(ctx, "User has stopped marketing messages from the business."));
|
|
353
|
+
this.name = "UserStoppedMarketingMessagesError";
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export class RecipientIdentityKeyMismatchError extends GraphApiError {
|
|
358
|
+
static errorCode = 137000;
|
|
359
|
+
constructor(ctx) {
|
|
360
|
+
super(coreParams(ctx, "The recipient's identity key hash does not match the one on record."));
|
|
361
|
+
this.name = "RecipientIdentityKeyMismatchError";
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export class FlowBlockedByIntegrityError extends GraphApiError {
|
|
366
|
+
static errorCode = 139000;
|
|
367
|
+
constructor(ctx) {
|
|
368
|
+
super(coreParams(ctx, "Flow blocked by an integrity issue on the account."));
|
|
369
|
+
this.name = "FlowBlockedByIntegrityError";
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export class FlowUpdatingError extends GraphApiError {
|
|
374
|
+
static errorCode = 139001;
|
|
375
|
+
constructor(ctx) {
|
|
376
|
+
super(coreParams(ctx, "Flow failed to update."));
|
|
377
|
+
this.name = "FlowUpdatingError";
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export class FlowPublishingError extends GraphApiError {
|
|
382
|
+
static errorCode = 139002;
|
|
383
|
+
constructor(ctx) {
|
|
384
|
+
super(coreParams(ctx, "Flow failed to publish."));
|
|
385
|
+
this.name = "FlowPublishingError";
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export class FlowDeprecatingError extends GraphApiError {
|
|
390
|
+
static errorCode = 139003;
|
|
391
|
+
constructor(ctx) {
|
|
392
|
+
super(coreParams(ctx, "Flow failed to deprecate."));
|
|
393
|
+
this.name = "FlowDeprecatingError";
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export class FlowDeletingError extends GraphApiError {
|
|
398
|
+
static errorCode = 139004;
|
|
399
|
+
constructor(ctx) {
|
|
400
|
+
super(coreParams(ctx, "Flow failed to delete."));
|
|
401
|
+
this.name = "FlowDeletingError";
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export class BulkBlockingFailedError extends GraphApiError {
|
|
406
|
+
static errorCode = 139100;
|
|
407
|
+
constructor(ctx) {
|
|
408
|
+
super(coreParams(ctx, "Bulk blocking failed for some users."));
|
|
409
|
+
this.name = "BulkBlockingFailedError";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export class BlockListLimitReachedError extends GraphApiError {
|
|
414
|
+
static errorCode = 139101;
|
|
415
|
+
constructor(ctx) {
|
|
416
|
+
super(coreParams(ctx, "Blocklist limit reached (64k)."));
|
|
417
|
+
this.name = "BlockListLimitReachedError";
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export class BlockListConcurrentUpdateError extends GraphApiError {
|
|
422
|
+
static errorCode = 139102;
|
|
423
|
+
constructor(ctx) {
|
|
424
|
+
super(coreParams(ctx, "Blocklist concurrent update \u2014 version_id mismatch."));
|
|
425
|
+
this.name = "BlockListConcurrentUpdateError";
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export class BlockUserInternalError extends GraphApiError {
|
|
430
|
+
static errorCode = 139103;
|
|
431
|
+
constructor(ctx) {
|
|
432
|
+
super(coreParams(ctx, "Block-user internal error."));
|
|
433
|
+
this.name = "BlockUserInternalError";
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export class CallingNotEnabledError extends GraphApiError {
|
|
438
|
+
static errorCode = 138000;
|
|
439
|
+
constructor(ctx) {
|
|
440
|
+
super(coreParams(ctx, "Calling is not enabled on this phone number."));
|
|
441
|
+
this.name = "CallingNotEnabledError";
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export class CallingCannotBeEnabledError extends GraphApiError {
|
|
446
|
+
static errorCode = 138018;
|
|
447
|
+
constructor(ctx) {
|
|
448
|
+
super(coreParams(ctx, "Calling cannot be enabled \u2014 technical pre-requisites not met."));
|
|
449
|
+
this.name = "CallingCannotBeEnabledError";
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export class ReceiverUncallableError extends GraphApiError {
|
|
454
|
+
static errorCode = 138001;
|
|
455
|
+
constructor(ctx) {
|
|
456
|
+
super(coreParams(ctx, "Receiver is unable to receive calls."));
|
|
457
|
+
this.name = "ReceiverUncallableError";
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export class ConcurrentCallsLimitError extends GraphApiError {
|
|
462
|
+
static errorCode = 138002;
|
|
463
|
+
constructor(ctx) {
|
|
464
|
+
super(coreParams(ctx, "Limit reached for concurrent calls."));
|
|
465
|
+
this.name = "ConcurrentCallsLimitError";
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
export class DuplicateCallError extends GraphApiError {
|
|
470
|
+
static errorCode = 138003;
|
|
471
|
+
constructor(ctx) {
|
|
472
|
+
super(coreParams(ctx, "A call is already ongoing with the receiver."));
|
|
473
|
+
this.name = "DuplicateCallError";
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
export class CallConnectionError extends GraphApiError {
|
|
478
|
+
static errorCode = 138004;
|
|
479
|
+
constructor(ctx) {
|
|
480
|
+
super(coreParams(ctx, "Error while connecting the call."));
|
|
481
|
+
this.name = "CallConnectionError";
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export class CallRateLimitExceededError extends GraphApiError {
|
|
486
|
+
static errorCode = 138005;
|
|
487
|
+
constructor(ctx) {
|
|
488
|
+
super(coreParams(ctx, "Limit reached for maximum calls from this phone number."));
|
|
489
|
+
this.name = "CallRateLimitExceededError";
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export class CallPermissionNotFoundError extends GraphApiError {
|
|
494
|
+
static errorCode = 138006;
|
|
495
|
+
constructor(ctx) {
|
|
496
|
+
super(coreParams(ctx, "No approved call permission from the recipient."));
|
|
497
|
+
this.name = "CallPermissionNotFoundError";
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export class CallConnectionTimeoutError extends GraphApiError {
|
|
502
|
+
static errorCode = 138007;
|
|
503
|
+
constructor(ctx) {
|
|
504
|
+
super(coreParams(ctx, "Call was unable to connect due to a timeout."));
|
|
505
|
+
this.name = "CallConnectionTimeoutError";
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export class CallPermissionRequestLimitHitError extends GraphApiError {
|
|
510
|
+
static errorCode = 138009;
|
|
511
|
+
constructor(ctx) {
|
|
512
|
+
super(coreParams(ctx, "Limit reached for call-permission-request sends."));
|
|
513
|
+
this.name = "CallPermissionRequestLimitHitError";
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export class BusinessInitiatedCallsLimitHitError extends GraphApiError {
|
|
518
|
+
static errorCode = 138012;
|
|
519
|
+
constructor(ctx) {
|
|
520
|
+
super(coreParams(ctx, "Limit reached for business-initiated calls in 24 hours."));
|
|
521
|
+
this.name = "BusinessInitiatedCallsLimitHitError";
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export class FetchCallPermissionLimitHitError extends GraphApiError {
|
|
526
|
+
static errorCode = 138013;
|
|
527
|
+
constructor(ctx) {
|
|
528
|
+
super(coreParams(ctx, "Limit reached for fetch-call-permission API requests."));
|
|
529
|
+
this.name = "FetchCallPermissionLimitHitError";
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const BUILT_IN_SEEDS = [
|
|
533
|
+
{ code: 0, errorName: "AuthException", factory: (ctx) => new AuthException(ctx) },
|
|
534
|
+
{ code: 3, errorName: "APIMethodError", factory: (ctx) => new APIMethodError(ctx) },
|
|
535
|
+
{ code: 10, errorName: "PermissionDeniedError", factory: (ctx) => new PermissionDeniedError(ctx) },
|
|
536
|
+
{ code: 190, errorName: "ExpiredAccessTokenError", factory: (ctx) => new ExpiredAccessTokenError(ctx) },
|
|
537
|
+
{ code: 200, errorName: "APIPermissionError", factory: (ctx) => new APIPermissionError(ctx) },
|
|
538
|
+
{ code: 4, errorName: "ToManyAPICallsError", factory: (ctx) => new ToManyAPICallsError(ctx) },
|
|
539
|
+
{ code: 80007, errorName: "RateLimitIssuesError", factory: (ctx) => new RateLimitIssuesError(ctx) },
|
|
540
|
+
{ code: 130429, errorName: "RateLimitHitError", factory: (ctx) => new RateLimitHitError(ctx) },
|
|
541
|
+
{ code: 131048, errorName: "SpamRateLimitHitError", factory: (ctx) => new SpamRateLimitHitError(ctx) },
|
|
542
|
+
{ code: 131056, errorName: "TooManyMessagesError", factory: (ctx) => new TooManyMessagesError(ctx) },
|
|
543
|
+
{ code: 368, errorName: "TemporarilyBlockedError", factory: (ctx) => new TemporarilyBlockedError(ctx) },
|
|
544
|
+
{ code: 131031, errorName: "AccountLockedError", factory: (ctx) => new AccountLockedError(ctx) },
|
|
545
|
+
{ code: 130497, errorName: "AccountRestrictedFromCountryError", factory: (ctx) => new AccountRestrictedFromCountryError(ctx) },
|
|
546
|
+
{ code: 130472, errorName: "UserIsInExperimentGroupError", factory: (ctx) => new UserIsInExperimentGroupError(ctx) },
|
|
547
|
+
{ code: 131026, errorName: "MessageUndeliverableError", factory: (ctx) => new MessageUndeliverableError(ctx) },
|
|
548
|
+
{ code: 131047, errorName: "ReEngagementMessageError", factory: (ctx) => new ReEngagementMessageError(ctx) },
|
|
549
|
+
{ code: 131051, errorName: "UnsupportedMessageTypeError", factory: (ctx) => new UnsupportedMessageTypeError(ctx) },
|
|
550
|
+
{ code: 131052, errorName: "MediaDownloadError", factory: (ctx) => new MediaDownloadError(ctx) },
|
|
551
|
+
{ code: 131053, errorName: "MediaUploadError", factory: (ctx) => new MediaUploadError(ctx) },
|
|
552
|
+
{ code: 131030, errorName: "RecipientNotInAllowedListError", factory: (ctx) => new RecipientNotInAllowedListError(ctx) },
|
|
553
|
+
{ code: 131009, errorName: "InvalidParameterError", factory: (ctx) => new InvalidParameterError(ctx) },
|
|
554
|
+
{ code: 131008, errorName: "MissingRequiredParameterError", factory: (ctx) => new MissingRequiredParameterError(ctx) },
|
|
555
|
+
{ code: 132000, errorName: "TemplateParamCountMismatchError", factory: (ctx) => new TemplateParamCountMismatchError(ctx) },
|
|
556
|
+
{ code: 132001, errorName: "TemplateNotExistsError", factory: (ctx) => new TemplateNotExistsError(ctx) },
|
|
557
|
+
{ code: 132005, errorName: "TemplateTextTooLongError", factory: (ctx) => new TemplateTextTooLongError(ctx) },
|
|
558
|
+
{ code: 132007, errorName: "TemplateContentPolicyViolationError", factory: (ctx) => new TemplateContentPolicyViolationError(ctx) },
|
|
559
|
+
{ code: 132008, errorName: "TemplateParamValueInvalidError", factory: (ctx) => new TemplateParamValueInvalidError(ctx) },
|
|
560
|
+
{ code: 132012, errorName: "TemplateParamFormatMismatchError", factory: (ctx) => new TemplateParamFormatMismatchError(ctx) },
|
|
561
|
+
{ code: 132015, errorName: "TemplatePausedError", factory: (ctx) => new TemplatePausedError(ctx) },
|
|
562
|
+
{ code: 132016, errorName: "TemplateDisabledError", factory: (ctx) => new TemplateDisabledError(ctx) },
|
|
563
|
+
{ code: 132068, errorName: "FlowBlockedError", factory: (ctx) => new FlowBlockedError(ctx) },
|
|
564
|
+
{ code: 132069, errorName: "FlowThrottledError", factory: (ctx) => new FlowThrottledError(ctx) },
|
|
565
|
+
{ code: 135000, errorName: "GenericError", factory: (ctx) => new GenericError(ctx) },
|
|
566
|
+
{ code: 131000, errorName: "UnknownError", factory: (ctx) => new UnknownError(ctx) },
|
|
567
|
+
{ code: 131005, errorName: "AccessDeniedError", factory: (ctx) => new AccessDeniedError(ctx) },
|
|
568
|
+
{ code: 131016, errorName: "ServiceUnavailableError", factory: (ctx) => new ServiceUnavailableError(ctx) },
|
|
569
|
+
{ code: 131021, errorName: "RecipientCannotBeSenderError", factory: (ctx) => new RecipientCannotBeSenderError(ctx) },
|
|
570
|
+
{ code: 131042, errorName: "BusinessPaymentIssueError", factory: (ctx) => new BusinessPaymentIssueError(ctx) },
|
|
571
|
+
{ code: 131044, errorName: "BusinessPaymentIssueError", factory: (ctx) => new BusinessPaymentIssueError(ctx) },
|
|
572
|
+
{ code: 131045, errorName: "IncorrectCertificateError", factory: (ctx) => new IncorrectCertificateError(ctx) },
|
|
573
|
+
{ code: 131057, errorName: "AccountInMaintenanceModeError", factory: (ctx) => new AccountInMaintenanceModeError(ctx) },
|
|
574
|
+
{ code: 131050, errorName: "UserStoppedMarketingMessagesError", factory: (ctx) => new UserStoppedMarketingMessagesError(ctx) },
|
|
575
|
+
{ code: 137000, errorName: "RecipientIdentityKeyMismatchError", factory: (ctx) => new RecipientIdentityKeyMismatchError(ctx) },
|
|
576
|
+
{ code: 139000, errorName: "FlowBlockedByIntegrityError", factory: (ctx) => new FlowBlockedByIntegrityError(ctx) },
|
|
577
|
+
{ code: 139001, errorName: "FlowUpdatingError", factory: (ctx) => new FlowUpdatingError(ctx) },
|
|
578
|
+
{ code: 139002, errorName: "FlowPublishingError", factory: (ctx) => new FlowPublishingError(ctx) },
|
|
579
|
+
{ code: 139003, errorName: "FlowDeprecatingError", factory: (ctx) => new FlowDeprecatingError(ctx) },
|
|
580
|
+
{ code: 139004, errorName: "FlowDeletingError", factory: (ctx) => new FlowDeletingError(ctx) },
|
|
581
|
+
{ code: 139100, errorName: "BulkBlockingFailedError", factory: (ctx) => new BulkBlockingFailedError(ctx) },
|
|
582
|
+
{ code: 139101, errorName: "BlockListLimitReachedError", factory: (ctx) => new BlockListLimitReachedError(ctx) },
|
|
583
|
+
{ code: 139102, errorName: "BlockListConcurrentUpdateError", factory: (ctx) => new BlockListConcurrentUpdateError(ctx) },
|
|
584
|
+
{ code: 139103, errorName: "BlockUserInternalError", factory: (ctx) => new BlockUserInternalError(ctx) },
|
|
585
|
+
{ code: 138000, errorName: "CallingNotEnabledError", factory: (ctx) => new CallingNotEnabledError(ctx) },
|
|
586
|
+
{ code: 138018, errorName: "CallingCannotBeEnabledError", factory: (ctx) => new CallingCannotBeEnabledError(ctx) },
|
|
587
|
+
{ code: 138001, errorName: "ReceiverUncallableError", factory: (ctx) => new ReceiverUncallableError(ctx) },
|
|
588
|
+
{ code: 138002, errorName: "ConcurrentCallsLimitError", factory: (ctx) => new ConcurrentCallsLimitError(ctx) },
|
|
589
|
+
{ code: 138003, errorName: "DuplicateCallError", factory: (ctx) => new DuplicateCallError(ctx) },
|
|
590
|
+
{ code: 138004, errorName: "CallConnectionError", factory: (ctx) => new CallConnectionError(ctx) },
|
|
591
|
+
{ code: 138005, errorName: "CallRateLimitExceededError", factory: (ctx) => new CallRateLimitExceededError(ctx) },
|
|
592
|
+
{ code: 138006, errorName: "CallPermissionNotFoundError", factory: (ctx) => new CallPermissionNotFoundError(ctx) },
|
|
593
|
+
{ code: 138007, errorName: "CallConnectionTimeoutError", factory: (ctx) => new CallConnectionTimeoutError(ctx) },
|
|
594
|
+
{ code: 138009, errorName: "CallPermissionRequestLimitHitError", factory: (ctx) => new CallPermissionRequestLimitHitError(ctx) },
|
|
595
|
+
{ code: 138012, errorName: "BusinessInitiatedCallsLimitHitError", factory: (ctx) => new BusinessInitiatedCallsLimitHitError(ctx) },
|
|
596
|
+
{ code: 138013, errorName: "FetchCallPermissionLimitHitError", factory: (ctx) => new FetchCallPermissionLimitHitError(ctx) },
|
|
597
|
+
{ code: 613, errorName: "FetchCallPermissionLimitHitError", factory: (ctx) => new FetchCallPermissionLimitHitError(ctx) },
|
|
598
|
+
{ code: 100, errorName: "InvalidParameterError", factory: (ctx) => new InvalidParameterError(ctx) }
|
|
599
|
+
];
|
|
600
|
+
export function registerBuiltInErrorCodes() {
|
|
601
|
+
if (isBuiltInRegistered()) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
for (const seed of BUILT_IN_SEEDS) {
|
|
605
|
+
registerErrorCode({
|
|
606
|
+
code: seed.code,
|
|
607
|
+
errorName: seed.errorName,
|
|
608
|
+
factory: seed.factory
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
markBuiltInRegistered();
|
|
612
|
+
}
|
|
613
|
+
registerBuiltInErrorCodes();
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface GraphApiErrorPayload {
|
|
2
|
+
message?: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
code?: number;
|
|
5
|
+
error_subcode?: number;
|
|
6
|
+
fbtrace_id?: string;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface GraphErrorEnvelope {
|
|
10
|
+
error: GraphApiErrorPayload;
|
|
11
|
+
}
|
|
12
|
+
export type GraphErrorClassification = "ClientError" | "ServerError" | "Unknown";
|
|
13
|
+
export declare class GraphApiError extends Error {
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly type?: string;
|
|
16
|
+
readonly code?: number;
|
|
17
|
+
readonly errorSubcode?: number;
|
|
18
|
+
readonly fbtraceId?: string;
|
|
19
|
+
readonly payload?: GraphApiErrorPayload;
|
|
20
|
+
/**
|
|
21
|
+
* Broad HTTP-status-driven classification:
|
|
22
|
+
* 4xx → "ClientError"
|
|
23
|
+
* 5xx → "ServerError"
|
|
24
|
+
* anything else → "Unknown"
|
|
25
|
+
*
|
|
26
|
+
* F-5 (WATS-11 L5): this is a coarse axis orthogonal to the registry's
|
|
27
|
+
* per-code subclass identity. A registered subclass (e.g.
|
|
28
|
+
* InvalidParameterError) will still expose the matching classification
|
|
29
|
+
* alongside its own identity.
|
|
30
|
+
*/
|
|
31
|
+
readonly classification: GraphErrorClassification;
|
|
32
|
+
constructor(params: {
|
|
33
|
+
message: string;
|
|
34
|
+
status: number;
|
|
35
|
+
payload?: GraphApiErrorPayload;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export declare class GraphAuthError extends GraphApiError {
|
|
39
|
+
constructor(params: {
|
|
40
|
+
message: string;
|
|
41
|
+
status: number;
|
|
42
|
+
payload?: GraphApiErrorPayload;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export declare class GraphRateLimitError extends GraphApiError {
|
|
46
|
+
constructor(params: {
|
|
47
|
+
message: string;
|
|
48
|
+
status: number;
|
|
49
|
+
payload?: GraphApiErrorPayload;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export declare class GraphNetworkError extends Error {
|
|
53
|
+
readonly cause?: unknown;
|
|
54
|
+
constructor(message: string, cause?: unknown);
|
|
55
|
+
}
|
|
56
|
+
export declare class GraphRequestValidationError extends GraphApiError {
|
|
57
|
+
readonly cause?: unknown;
|
|
58
|
+
constructor(message: string, cause?: unknown);
|
|
59
|
+
}
|
|
60
|
+
export declare class GraphSerializationError extends GraphApiError {
|
|
61
|
+
readonly cause?: unknown;
|
|
62
|
+
constructor(message: string, cause?: unknown);
|
|
63
|
+
}
|
|
64
|
+
export declare function isGraphApiErrorPayload(value: unknown): value is GraphApiErrorPayload;
|
|
65
|
+
export declare function isGraphErrorEnvelope(value: unknown): value is GraphErrorEnvelope;
|
|
66
|
+
/**
|
|
67
|
+
* Rate-limit code set externalised so the registry module can grow it
|
|
68
|
+
* without client.ts churn. F-5 (WATS-27). F-5 remediation (WATS-29):
|
|
69
|
+
* reconciled with pywa/errors.py ThrottlingError. Codes 17 and 32 were
|
|
70
|
+
* WATS fabrications and have been dropped. Code 613 is pywa CallingError
|
|
71
|
+
* (not ThrottlingError) and has also been dropped. Code 131056
|
|
72
|
+
* (pywa TooManyMessages) added.
|
|
73
|
+
*/
|
|
74
|
+
export declare const RATE_LIMIT_CODES: ReadonlySet<number>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns a shallow-cloned copy of `err` with any occurrences of
|
|
77
|
+
* `Bearer <token>` strings redacted to `Bearer ***` in the message,
|
|
78
|
+
* stack, and shallow cause chain. Non-Error / non-string values are
|
|
79
|
+
* returned unchanged.
|
|
80
|
+
*
|
|
81
|
+
* Intended for log/metrics sinks that need to record a Graph failure
|
|
82
|
+
* without leaking the caller's access token. See WATS-13 L7.
|
|
83
|
+
*/
|
|
84
|
+
export declare function scrubErrorCause(err: unknown): unknown;
|
|
85
|
+
export declare function createGraphApiError(params: {
|
|
86
|
+
status: number;
|
|
87
|
+
payload?: GraphApiErrorPayload;
|
|
88
|
+
fallbackMessage?: string;
|
|
89
|
+
classify?: boolean;
|
|
90
|
+
headers?: Headers;
|
|
91
|
+
requestUrl?: string;
|
|
92
|
+
}): GraphApiError;
|