@datocms/rest-client-utils 3.3.15 → 3.4.2
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/dist/cjs/errors.js +0 -54
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/request.js +25 -23
- package/dist/cjs/request.js.map +1 -1
- package/dist/esm/errors.d.ts +2 -1
- package/dist/esm/errors.js +0 -54
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/request.js +25 -23
- package/dist/esm/request.js.map +1 -1
- package/dist/types/errors.d.ts +2 -1
- package/package.json +2 -2
- package/src/errors.ts +2 -61
- package/src/request.ts +5 -2
package/dist/cjs/errors.js
CHANGED
|
@@ -39,41 +39,6 @@ function isErrorBody(body) {
|
|
|
39
39
|
}
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
|
-
var humanMessageForCode = {
|
|
43
|
-
BATCH_DATA_VALIDATION_IN_PROGRESS: "The schema of this model changed, we're re-running validations over every record in background. Please retry with this operation in a few seconds!",
|
|
44
|
-
INSUFFICIENT_PERMISSIONS: 'Your role does not permit this action',
|
|
45
|
-
MAINTENANCE_MODE: 'The project is currently in maintenance mode!',
|
|
46
|
-
DELETE_RESTRICTION: "Sorry, but you cannot delete this resource, as it's currently used/referenced elsewhere!",
|
|
47
|
-
INVALID_CREDENTIALS: 'Credentials are incorrect!',
|
|
48
|
-
INVALID_EMAIL: 'Email address is incorrect!',
|
|
49
|
-
INVALID_FORMAT: "The format of the parameters passed is incorrect, take a look at the details of the error to know what's wrong!",
|
|
50
|
-
ITEM_LOCKED: 'The operation cannot be completed as some other user is currently editing this record!',
|
|
51
|
-
LINKED_FROM_PUBLISHED_ITEMS: "Couldn't unpublish the record, as some published records are linked to it!",
|
|
52
|
-
PLAN_UPGRADE_REQUIRED: 'Cannot proceed, please upgrade plan!',
|
|
53
|
-
PUBLISHED_CHILDREN: "Couldn't unpublish the record, some children records are still published!",
|
|
54
|
-
REQUIRED_2FA_SETUP: 'This project requires every user to turn on 2-factor authentication! Please go to your Dashboard and activate it! (https://dashboard.datocms.com/account/setup-2fa)',
|
|
55
|
-
REQUIRED_BY_ASSOCIATION: "Cannot delete the record, as it's required by other records:",
|
|
56
|
-
STALE_ITEM_VERSION: 'Someone else made a change while you were editing this record, please refresh the page!',
|
|
57
|
-
TITLE_ALREADY_PRESENT: 'There can only be one Title field per model',
|
|
58
|
-
UNPUBLISHED_LINK: "Couldn't publish the record, as it links some unpublished records!",
|
|
59
|
-
UNPUBLISHED_PARENT: "Couldn't publish the record, as the parent record is not published!",
|
|
60
|
-
UPLOAD_IS_CURRENTLY_IN_USE: "Couldn't delete this asset, as it's currently used by some records!",
|
|
61
|
-
UPLOAD_NOT_PASSING_FIELD_VALIDATIONS: "Couldn't update this asset since some records are failing to pass the validations!",
|
|
62
|
-
};
|
|
63
|
-
var humanMessageForPlanUpgradeLimit = {
|
|
64
|
-
build_triggers: "You've reached the maximum number of build triggers your plan allows",
|
|
65
|
-
sandbox_environments: "You've reached the maximum number of environments your plan allows",
|
|
66
|
-
item_types: "You've reached the maximum number of models your plan allows to create",
|
|
67
|
-
items: "You've reached the maximum number of records your plan allows to create",
|
|
68
|
-
locales: "You've reached the maximum number of locales your plan allows",
|
|
69
|
-
mux_encoding_seconds: "You've reached the maximum video encoding limits of your plan",
|
|
70
|
-
otp: 'Two-factor authentication cannot be on the current plan',
|
|
71
|
-
plugins: "You've reached the maximum number of plugins your plan allows",
|
|
72
|
-
roles: "You've reached the maximum number of roles your plan allows to create",
|
|
73
|
-
uploadable_bytes: "You've reached the file storage limits of your plan",
|
|
74
|
-
users: "You've reached the maximum number of collaborators your plan allows to invite to the project",
|
|
75
|
-
access_tokens: "You've reached the maximum number of API tokens your plan allows to create",
|
|
76
|
-
};
|
|
77
42
|
var TimeoutError = /** @class */ (function (_super) {
|
|
78
43
|
__extends(TimeoutError, _super);
|
|
79
44
|
function TimeoutError(initObject) {
|
|
@@ -145,25 +110,6 @@ var ApiError = /** @class */ (function (_super) {
|
|
|
145
110
|
})));
|
|
146
111
|
});
|
|
147
112
|
};
|
|
148
|
-
Object.defineProperty(ApiError.prototype, "humanMessage", {
|
|
149
|
-
get: function () {
|
|
150
|
-
var _this = this;
|
|
151
|
-
var planUpgradeError = this.findError('PLAN_UPGRADE_REQUIRED');
|
|
152
|
-
if (planUpgradeError) {
|
|
153
|
-
var limit = planUpgradeError.attributes.details.limit;
|
|
154
|
-
return "".concat(humanMessageForPlanUpgradeLimit[limit], ". Please head over to your account dashboard (https://dashboard.datocms.com/) to upgrade the plan or, if no publicly available plan suits your needs, contact our Sales team (https://www.datocms.com/contact) to get a custom quote!");
|
|
155
|
-
}
|
|
156
|
-
var errors = Object.keys(humanMessageForCode)
|
|
157
|
-
.filter(function (code) { return _this.findError(code); })
|
|
158
|
-
.map(function (code) { return humanMessageForCode[code]; });
|
|
159
|
-
if (errors.length === 0) {
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
return errors.join('\n');
|
|
163
|
-
},
|
|
164
|
-
enumerable: false,
|
|
165
|
-
configurable: true
|
|
166
|
-
});
|
|
167
113
|
return ApiError;
|
|
168
114
|
}(Error));
|
|
169
115
|
exports.ApiError = ApiError;
|
package/dist/cjs/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAcA,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE;QAClE,OAAO,KAAK,CAAC;KACd;IAED,IAAM,YAAY,GAAG,IAAyB,CAAC;IAE/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC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AED,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QACjC,CAAC;;;OAAA;IAED,4BAAS,GAAT,UACE,WAA8B,EAC9B,aAAiD;QAEjD,IAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CACrB,UAAC,KAAK;YACJ,OAAA,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;gBACrC,CAAC,CAAC,aAAa;oBACb,CAAC,OAAO,aAAa,KAAK,UAAU;wBAClC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;wBACzC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,KAAK,CACjC,UAAC,EAAY;gCAAX,GAAG,QAAA,EAAE,KAAK,QAAA;4BAAM,OAAA,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK;wBAAvC,CAAuC,CAC1D,CAAC,CAAC;QANT,CAMS,CACZ,CAAC;IACJ,CAAC;IACH,eAAC;AAAD,CAAC,AAxDD,CAA8B,KAAK,GAwDlC;AAxDY,4BAAQ"}
|
package/dist/cjs/request.js
CHANGED
|
@@ -129,10 +129,11 @@ function lowercaseKeys(obj) {
|
|
|
129
129
|
}
|
|
130
130
|
var requestCount = 1;
|
|
131
131
|
function request(options) {
|
|
132
|
+
var _a;
|
|
132
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
-
var requestId, fetchFn, preCallStack, userAgent, retryCount, logLevel, autoRetry, log, headers, baseUrl, body, queryString, url, _i,
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
switch (
|
|
134
|
+
var requestId, fetchFn, preCallStack, userAgent, retryCount, logLevel, autoRetry, log, headers, baseUrl, body, queryString, url, _i, _b, _c, key, value, requestPromise_1, timeoutId, response, responseContentType, invalidContentType, waitTimeInSecs, _d, _e, key, value, responseBody, _f, jobResult, error, transientErrorCode, error_1;
|
|
135
|
+
return __generator(this, function (_g) {
|
|
136
|
+
switch (_g.label) {
|
|
136
137
|
case 0:
|
|
137
138
|
requestId = requestCount;
|
|
138
139
|
requestCount += 1;
|
|
@@ -162,8 +163,8 @@ function request(options) {
|
|
|
162
163
|
if (logLevel >= LogLevel.BASIC) {
|
|
163
164
|
log("[".concat(requestId, "] ").concat(options.method, " ").concat(url));
|
|
164
165
|
if (logLevel >= LogLevel.BODY_AND_HEADERS) {
|
|
165
|
-
for (_i = 0,
|
|
166
|
-
|
|
166
|
+
for (_i = 0, _b = Object.entries(headers || {}); _i < _b.length; _i++) {
|
|
167
|
+
_c = _b[_i], key = _c[0], value = _c[1];
|
|
167
168
|
log("[".concat(requestId, "] ").concat(key, ": ").concat(value));
|
|
168
169
|
}
|
|
169
170
|
}
|
|
@@ -171,9 +172,9 @@ function request(options) {
|
|
|
171
172
|
log("[".concat(requestId, "] ").concat(body));
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
_g.label = 1;
|
|
175
176
|
case 1:
|
|
176
|
-
|
|
177
|
+
_g.trys.push([1, 12, , 16]);
|
|
177
178
|
requestPromise_1 = (0, makeCancelablePromise_1.makeCancelablePromise)(fetchFn(url, {
|
|
178
179
|
method: options.method,
|
|
179
180
|
headers: headers,
|
|
@@ -184,7 +185,7 @@ function request(options) {
|
|
|
184
185
|
}, options.requestTimeout || 30000);
|
|
185
186
|
return [4 /*yield*/, requestPromise_1];
|
|
186
187
|
case 2:
|
|
187
|
-
response =
|
|
188
|
+
response = _g.sent();
|
|
188
189
|
clearTimeout(timeoutId);
|
|
189
190
|
responseContentType = response.headers.get('Content-Type');
|
|
190
191
|
invalidContentType = responseContentType && !responseContentType.includes('application/json');
|
|
@@ -205,21 +206,21 @@ function request(options) {
|
|
|
205
206
|
}
|
|
206
207
|
return [4 /*yield*/, (0, wait_1.wait)(waitTimeInSecs * 1000)];
|
|
207
208
|
case 3:
|
|
208
|
-
|
|
209
|
+
_g.sent();
|
|
209
210
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
210
211
|
case 4:
|
|
211
212
|
if (logLevel >= LogLevel.BASIC) {
|
|
212
213
|
log("[".concat(requestId, "] Status: ").concat(response.status, " (").concat(response.statusText, ")"));
|
|
213
214
|
if (logLevel >= LogLevel.BODY_AND_HEADERS) {
|
|
214
|
-
for (
|
|
215
|
+
for (_d = 0, _e = [
|
|
215
216
|
'x-api-version',
|
|
216
217
|
'x-environment',
|
|
217
218
|
'x-queue-time',
|
|
218
219
|
'x-ratelimit-remaining',
|
|
219
220
|
'x-request-id',
|
|
220
221
|
'cf-ray',
|
|
221
|
-
];
|
|
222
|
-
key = _d
|
|
222
|
+
]; _d < _e.length; _d++) {
|
|
223
|
+
key = _e[_d];
|
|
223
224
|
value = response.headers.get(key);
|
|
224
225
|
if (value) {
|
|
225
226
|
log("[".concat(requestId, "] ").concat(key, ": ").concat(value));
|
|
@@ -228,42 +229,43 @@ function request(options) {
|
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
if (!(response.status === 204)) return [3 /*break*/, 5];
|
|
231
|
-
|
|
232
|
+
_f = undefined;
|
|
232
233
|
return [3 /*break*/, 7];
|
|
233
234
|
case 5: return [4 /*yield*/, response.json()];
|
|
234
235
|
case 6:
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
_f = _g.sent();
|
|
237
|
+
_g.label = 7;
|
|
237
238
|
case 7:
|
|
238
|
-
responseBody =
|
|
239
|
+
responseBody = _f;
|
|
239
240
|
if (logLevel >= LogLevel.BODY && responseBody) {
|
|
240
241
|
log("[".concat(requestId, "] ").concat(JSON.stringify(responseBody, null, 2)));
|
|
241
242
|
}
|
|
242
243
|
if (!(response.status === 202)) return [3 /*break*/, 9];
|
|
243
244
|
return [4 /*yield*/, options.fetchJobResult(responseBody.data.id)];
|
|
244
245
|
case 8:
|
|
245
|
-
jobResult =
|
|
246
|
+
jobResult = _g.sent();
|
|
246
247
|
if (jobResult.status < 200 || jobResult.status >= 300) {
|
|
247
248
|
throw new errors_1.ApiError(buildApiErrorInitObjectFromJobResult(options.method, url, headers, options.body, jobResult.status, jobResult.payload, preCallStack));
|
|
248
249
|
}
|
|
249
250
|
responseBody = jobResult.payload;
|
|
250
|
-
|
|
251
|
+
_g.label = 9;
|
|
251
252
|
case 9:
|
|
252
253
|
if (response.status >= 200 && response.status < 300) {
|
|
253
254
|
return [2 /*return*/, responseBody];
|
|
254
255
|
}
|
|
255
256
|
error = new errors_1.ApiError(buildApiErrorInitObject(options.method, url, headers, options.body, response, responseBody, preCallStack));
|
|
256
|
-
|
|
257
|
+
transientErrorCode = (_a = error.errors.find(function (e) { return e.attributes.transient; })) === null || _a === void 0 ? void 0 : _a.attributes.code;
|
|
258
|
+
if (!(autoRetry && transientErrorCode)) return [3 /*break*/, 11];
|
|
257
259
|
if (logLevel >= LogLevel.BASIC) {
|
|
258
|
-
log("[".concat(requestId, "]
|
|
260
|
+
log("[".concat(requestId, "] ").concat(transientErrorCode, ", wait ").concat(retryCount, " seconds then retry..."));
|
|
259
261
|
}
|
|
260
262
|
return [4 /*yield*/, (0, wait_1.wait)(retryCount * 1000)];
|
|
261
263
|
case 10:
|
|
262
|
-
|
|
264
|
+
_g.sent();
|
|
263
265
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
264
266
|
case 11: throw error;
|
|
265
267
|
case 12:
|
|
266
|
-
error_1 =
|
|
268
|
+
error_1 = _g.sent();
|
|
267
269
|
if (!(error_1 instanceof makeCancelablePromise_1.CanceledPromiseError ||
|
|
268
270
|
(isErrorWithCode(error_1) && error_1.code.includes('ETIMEDOUT')))) return [3 /*break*/, 15];
|
|
269
271
|
if (!(autoRetry && retryCount < MAX_RETRY_COUNT_ON_TIMEOUT_ERROR)) return [3 /*break*/, 14];
|
|
@@ -272,7 +274,7 @@ function request(options) {
|
|
|
272
274
|
}
|
|
273
275
|
return [4 /*yield*/, (0, wait_1.wait)(retryCount * 1000)];
|
|
274
276
|
case 13:
|
|
275
|
-
|
|
277
|
+
_g.sent();
|
|
276
278
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
277
279
|
case 14: throw new errors_1.TimeoutError(buildTimeoutErrorInitObject(options.method, url, headers, options.body, preCallStack));
|
|
278
280
|
case 15: throw error_1;
|
package/dist/cjs/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":";AAAA,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3B,iEAAgE;AAChE,mCAKkB;AAElB,iEAGiC;AACjC,+BAA8B;AAE9B,IAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAE1E,IAAM,gCAAgC,GAAG,CAAC,CAAC;AAE3C,IAAY,QASX;AATD,WAAY,QAAQ;IAClB,iBAAiB;IACjB,uCAAQ,CAAA;IACR,8DAA8D;IAC9D,yCAAS,CAAA;IACT,0EAA0E;IAC1E,uCAAQ,CAAA;IACR,4FAA4F;IAC5F,+DAAoB,CAAA;AACtB,CAAC,EATW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QASnB;AA8BD,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,OAAO,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,GAAG;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAc,EACd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AU,2BAAwB,CACjF,CAAC;qBACH;oBAED,qBAAM,IAAA,WAAI,EAAC,UAAU,GAAG,IAAI,CAAC,EAAA;;oBAA7B,SAA6B,CAAC;oBAE9B,sBAAO,OAAO,uBAAM,OAAO,KAAE,UAAU,EAAE,UAAU,GAAG,CAAC,IAAG,EAAC;yBAG7D,MAAM,KAAK,CAAC;;;yBAGV,CAAA,OAAK,YAAY,4CAAoB;wBACrC,CAAC,eAAe,CAAC,OAAK,CAAC,IAAI,OAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA,EAD5D,yBAC4D;yBAExD,CAAA,SAAS,IAAI,UAAU,GAAG,gCAAgC,CAAA,EAA1D,yBAA0D;oBAC5D,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;wBAC9B,GAAG,CACD,WAAI,SAAS,mCAAyB,UAAU,2BAAwB,CACzE,CAAC;qBACH;oBAED,qBAAM,IAAA,WAAI,EAAC,UAAU,GAAG,IAAI,CAAC,EAAA;;oBAA7B,SAA6B,CAAC;oBAE9B,sBAAO,OAAO,uBAAM,OAAO,KAAE,UAAU,EAAE,UAAU,GAAG,CAAC,IAAG,EAAC;yBAG7D,MAAM,IAAI,qBAAY,CACpB,2BAA2B,CACzB,OAAO,CAAC,MAAM,EACd,GAAG,EACH,OAAO,EACP,OAAO,CAAC,IAAI,EACZ,YAAY,CACb,CACF,CAAC;yBAGJ,MAAM,OAAK,CAAC;;;;;CAEf;AAlOD,0BAkOC"}
|
package/dist/esm/errors.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type ErrorEntity = {
|
|
|
3
3
|
type: 'api_error';
|
|
4
4
|
attributes: {
|
|
5
5
|
code: string;
|
|
6
|
+
transient?: true;
|
|
7
|
+
doc_url: string;
|
|
6
8
|
details: Record<string, unknown>;
|
|
7
9
|
};
|
|
8
10
|
};
|
|
@@ -40,6 +42,5 @@ export declare class ApiError extends Error {
|
|
|
40
42
|
constructor(initObject: ApiErrorInitObject);
|
|
41
43
|
get errors(): ErrorEntity[];
|
|
42
44
|
findError(codeOrCodes: string | string[], filterDetails?: Record<string, string> | FilterFn): ErrorEntity | undefined;
|
|
43
|
-
get humanMessage(): string | null;
|
|
44
45
|
}
|
|
45
46
|
export {};
|
package/dist/esm/errors.js
CHANGED
|
@@ -36,41 +36,6 @@ function isErrorBody(body) {
|
|
|
36
36
|
}
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
|
-
var humanMessageForCode = {
|
|
40
|
-
BATCH_DATA_VALIDATION_IN_PROGRESS: "The schema of this model changed, we're re-running validations over every record in background. Please retry with this operation in a few seconds!",
|
|
41
|
-
INSUFFICIENT_PERMISSIONS: 'Your role does not permit this action',
|
|
42
|
-
MAINTENANCE_MODE: 'The project is currently in maintenance mode!',
|
|
43
|
-
DELETE_RESTRICTION: "Sorry, but you cannot delete this resource, as it's currently used/referenced elsewhere!",
|
|
44
|
-
INVALID_CREDENTIALS: 'Credentials are incorrect!',
|
|
45
|
-
INVALID_EMAIL: 'Email address is incorrect!',
|
|
46
|
-
INVALID_FORMAT: "The format of the parameters passed is incorrect, take a look at the details of the error to know what's wrong!",
|
|
47
|
-
ITEM_LOCKED: 'The operation cannot be completed as some other user is currently editing this record!',
|
|
48
|
-
LINKED_FROM_PUBLISHED_ITEMS: "Couldn't unpublish the record, as some published records are linked to it!",
|
|
49
|
-
PLAN_UPGRADE_REQUIRED: 'Cannot proceed, please upgrade plan!',
|
|
50
|
-
PUBLISHED_CHILDREN: "Couldn't unpublish the record, some children records are still published!",
|
|
51
|
-
REQUIRED_2FA_SETUP: 'This project requires every user to turn on 2-factor authentication! Please go to your Dashboard and activate it! (https://dashboard.datocms.com/account/setup-2fa)',
|
|
52
|
-
REQUIRED_BY_ASSOCIATION: "Cannot delete the record, as it's required by other records:",
|
|
53
|
-
STALE_ITEM_VERSION: 'Someone else made a change while you were editing this record, please refresh the page!',
|
|
54
|
-
TITLE_ALREADY_PRESENT: 'There can only be one Title field per model',
|
|
55
|
-
UNPUBLISHED_LINK: "Couldn't publish the record, as it links some unpublished records!",
|
|
56
|
-
UNPUBLISHED_PARENT: "Couldn't publish the record, as the parent record is not published!",
|
|
57
|
-
UPLOAD_IS_CURRENTLY_IN_USE: "Couldn't delete this asset, as it's currently used by some records!",
|
|
58
|
-
UPLOAD_NOT_PASSING_FIELD_VALIDATIONS: "Couldn't update this asset since some records are failing to pass the validations!",
|
|
59
|
-
};
|
|
60
|
-
var humanMessageForPlanUpgradeLimit = {
|
|
61
|
-
build_triggers: "You've reached the maximum number of build triggers your plan allows",
|
|
62
|
-
sandbox_environments: "You've reached the maximum number of environments your plan allows",
|
|
63
|
-
item_types: "You've reached the maximum number of models your plan allows to create",
|
|
64
|
-
items: "You've reached the maximum number of records your plan allows to create",
|
|
65
|
-
locales: "You've reached the maximum number of locales your plan allows",
|
|
66
|
-
mux_encoding_seconds: "You've reached the maximum video encoding limits of your plan",
|
|
67
|
-
otp: 'Two-factor authentication cannot be on the current plan',
|
|
68
|
-
plugins: "You've reached the maximum number of plugins your plan allows",
|
|
69
|
-
roles: "You've reached the maximum number of roles your plan allows to create",
|
|
70
|
-
uploadable_bytes: "You've reached the file storage limits of your plan",
|
|
71
|
-
users: "You've reached the maximum number of collaborators your plan allows to invite to the project",
|
|
72
|
-
access_tokens: "You've reached the maximum number of API tokens your plan allows to create",
|
|
73
|
-
};
|
|
74
39
|
var TimeoutError = /** @class */ (function (_super) {
|
|
75
40
|
__extends(TimeoutError, _super);
|
|
76
41
|
function TimeoutError(initObject) {
|
|
@@ -142,25 +107,6 @@ var ApiError = /** @class */ (function (_super) {
|
|
|
142
107
|
})));
|
|
143
108
|
});
|
|
144
109
|
};
|
|
145
|
-
Object.defineProperty(ApiError.prototype, "humanMessage", {
|
|
146
|
-
get: function () {
|
|
147
|
-
var _this = this;
|
|
148
|
-
var planUpgradeError = this.findError('PLAN_UPGRADE_REQUIRED');
|
|
149
|
-
if (planUpgradeError) {
|
|
150
|
-
var limit = planUpgradeError.attributes.details.limit;
|
|
151
|
-
return "".concat(humanMessageForPlanUpgradeLimit[limit], ". Please head over to your account dashboard (https://dashboard.datocms.com/) to upgrade the plan or, if no publicly available plan suits your needs, contact our Sales team (https://www.datocms.com/contact) to get a custom quote!");
|
|
152
|
-
}
|
|
153
|
-
var errors = Object.keys(humanMessageForCode)
|
|
154
|
-
.filter(function (code) { return _this.findError(code); })
|
|
155
|
-
.map(function (code) { return humanMessageForCode[code]; });
|
|
156
|
-
if (errors.length === 0) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
return errors.join('\n');
|
|
160
|
-
},
|
|
161
|
-
enumerable: false,
|
|
162
|
-
configurable: true
|
|
163
|
-
});
|
|
164
110
|
return ApiError;
|
|
165
111
|
}(Error));
|
|
166
112
|
export { ApiError };
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE;QAClE,OAAO,KAAK,CAAC;KACd;IAED,IAAM,YAAY,GAAG,IAAyB,CAAC;IAE/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QACrC,OAAO,KAAK,CAAC;KACd;IAED,IAAM,gBAAgB,GAAG,YAAmC,CAAC;IAE7D,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,OAAO,KAAK,CAAC;KACd;IAED,IAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC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C,MAAM,CAAC,IAAI,CACrB,UAAC,KAAK;YACJ,OAAA,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;gBACrC,CAAC,CAAC,aAAa;oBACb,CAAC,OAAO,aAAa,KAAK,UAAU;wBAClC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;wBACzC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,KAAK,CACjC,UAAC,EAAY;gCAAX,GAAG,QAAA,EAAE,KAAK,QAAA;4BAAM,OAAA,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK;wBAAvC,CAAuC,CAC1D,CAAC,CAAC;QANT,CAMS,CACZ,CAAC;IACJ,CAAC;IACH,eAAC;AAAD,CAAC,AAxDD,CAA8B,KAAK,GAwDlC"}
|
package/dist/esm/request.js
CHANGED
|
@@ -126,10 +126,11 @@ function lowercaseKeys(obj) {
|
|
|
126
126
|
}
|
|
127
127
|
var requestCount = 1;
|
|
128
128
|
export function request(options) {
|
|
129
|
+
var _a;
|
|
129
130
|
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
var requestId, fetchFn, preCallStack, userAgent, retryCount, logLevel, autoRetry, log, headers, baseUrl, body, queryString, url, _i,
|
|
131
|
-
return __generator(this, function (
|
|
132
|
-
switch (
|
|
131
|
+
var requestId, fetchFn, preCallStack, userAgent, retryCount, logLevel, autoRetry, log, headers, baseUrl, body, queryString, url, _i, _b, _c, key, value, requestPromise_1, timeoutId, response, responseContentType, invalidContentType, waitTimeInSecs, _d, _e, key, value, responseBody, _f, jobResult, error, transientErrorCode, error_1;
|
|
132
|
+
return __generator(this, function (_g) {
|
|
133
|
+
switch (_g.label) {
|
|
133
134
|
case 0:
|
|
134
135
|
requestId = requestCount;
|
|
135
136
|
requestCount += 1;
|
|
@@ -159,8 +160,8 @@ export function request(options) {
|
|
|
159
160
|
if (logLevel >= LogLevel.BASIC) {
|
|
160
161
|
log("[".concat(requestId, "] ").concat(options.method, " ").concat(url));
|
|
161
162
|
if (logLevel >= LogLevel.BODY_AND_HEADERS) {
|
|
162
|
-
for (_i = 0,
|
|
163
|
-
|
|
163
|
+
for (_i = 0, _b = Object.entries(headers || {}); _i < _b.length; _i++) {
|
|
164
|
+
_c = _b[_i], key = _c[0], value = _c[1];
|
|
164
165
|
log("[".concat(requestId, "] ").concat(key, ": ").concat(value));
|
|
165
166
|
}
|
|
166
167
|
}
|
|
@@ -168,9 +169,9 @@ export function request(options) {
|
|
|
168
169
|
log("[".concat(requestId, "] ").concat(body));
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
_g.label = 1;
|
|
172
173
|
case 1:
|
|
173
|
-
|
|
174
|
+
_g.trys.push([1, 12, , 16]);
|
|
174
175
|
requestPromise_1 = makeCancelablePromise(fetchFn(url, {
|
|
175
176
|
method: options.method,
|
|
176
177
|
headers: headers,
|
|
@@ -181,7 +182,7 @@ export function request(options) {
|
|
|
181
182
|
}, options.requestTimeout || 30000);
|
|
182
183
|
return [4 /*yield*/, requestPromise_1];
|
|
183
184
|
case 2:
|
|
184
|
-
response =
|
|
185
|
+
response = _g.sent();
|
|
185
186
|
clearTimeout(timeoutId);
|
|
186
187
|
responseContentType = response.headers.get('Content-Type');
|
|
187
188
|
invalidContentType = responseContentType && !responseContentType.includes('application/json');
|
|
@@ -202,21 +203,21 @@ export function request(options) {
|
|
|
202
203
|
}
|
|
203
204
|
return [4 /*yield*/, wait(waitTimeInSecs * 1000)];
|
|
204
205
|
case 3:
|
|
205
|
-
|
|
206
|
+
_g.sent();
|
|
206
207
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
207
208
|
case 4:
|
|
208
209
|
if (logLevel >= LogLevel.BASIC) {
|
|
209
210
|
log("[".concat(requestId, "] Status: ").concat(response.status, " (").concat(response.statusText, ")"));
|
|
210
211
|
if (logLevel >= LogLevel.BODY_AND_HEADERS) {
|
|
211
|
-
for (
|
|
212
|
+
for (_d = 0, _e = [
|
|
212
213
|
'x-api-version',
|
|
213
214
|
'x-environment',
|
|
214
215
|
'x-queue-time',
|
|
215
216
|
'x-ratelimit-remaining',
|
|
216
217
|
'x-request-id',
|
|
217
218
|
'cf-ray',
|
|
218
|
-
];
|
|
219
|
-
key = _d
|
|
219
|
+
]; _d < _e.length; _d++) {
|
|
220
|
+
key = _e[_d];
|
|
220
221
|
value = response.headers.get(key);
|
|
221
222
|
if (value) {
|
|
222
223
|
log("[".concat(requestId, "] ").concat(key, ": ").concat(value));
|
|
@@ -225,42 +226,43 @@ export function request(options) {
|
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
if (!(response.status === 204)) return [3 /*break*/, 5];
|
|
228
|
-
|
|
229
|
+
_f = undefined;
|
|
229
230
|
return [3 /*break*/, 7];
|
|
230
231
|
case 5: return [4 /*yield*/, response.json()];
|
|
231
232
|
case 6:
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
_f = _g.sent();
|
|
234
|
+
_g.label = 7;
|
|
234
235
|
case 7:
|
|
235
|
-
responseBody =
|
|
236
|
+
responseBody = _f;
|
|
236
237
|
if (logLevel >= LogLevel.BODY && responseBody) {
|
|
237
238
|
log("[".concat(requestId, "] ").concat(JSON.stringify(responseBody, null, 2)));
|
|
238
239
|
}
|
|
239
240
|
if (!(response.status === 202)) return [3 /*break*/, 9];
|
|
240
241
|
return [4 /*yield*/, options.fetchJobResult(responseBody.data.id)];
|
|
241
242
|
case 8:
|
|
242
|
-
jobResult =
|
|
243
|
+
jobResult = _g.sent();
|
|
243
244
|
if (jobResult.status < 200 || jobResult.status >= 300) {
|
|
244
245
|
throw new ApiError(buildApiErrorInitObjectFromJobResult(options.method, url, headers, options.body, jobResult.status, jobResult.payload, preCallStack));
|
|
245
246
|
}
|
|
246
247
|
responseBody = jobResult.payload;
|
|
247
|
-
|
|
248
|
+
_g.label = 9;
|
|
248
249
|
case 9:
|
|
249
250
|
if (response.status >= 200 && response.status < 300) {
|
|
250
251
|
return [2 /*return*/, responseBody];
|
|
251
252
|
}
|
|
252
253
|
error = new ApiError(buildApiErrorInitObject(options.method, url, headers, options.body, response, responseBody, preCallStack));
|
|
253
|
-
|
|
254
|
+
transientErrorCode = (_a = error.errors.find(function (e) { return e.attributes.transient; })) === null || _a === void 0 ? void 0 : _a.attributes.code;
|
|
255
|
+
if (!(autoRetry && transientErrorCode)) return [3 /*break*/, 11];
|
|
254
256
|
if (logLevel >= LogLevel.BASIC) {
|
|
255
|
-
log("[".concat(requestId, "]
|
|
257
|
+
log("[".concat(requestId, "] ").concat(transientErrorCode, ", wait ").concat(retryCount, " seconds then retry..."));
|
|
256
258
|
}
|
|
257
259
|
return [4 /*yield*/, wait(retryCount * 1000)];
|
|
258
260
|
case 10:
|
|
259
|
-
|
|
261
|
+
_g.sent();
|
|
260
262
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
261
263
|
case 11: throw error;
|
|
262
264
|
case 12:
|
|
263
|
-
error_1 =
|
|
265
|
+
error_1 = _g.sent();
|
|
264
266
|
if (!(error_1 instanceof CanceledPromiseError ||
|
|
265
267
|
(isErrorWithCode(error_1) && error_1.code.includes('ETIMEDOUT')))) return [3 /*break*/, 15];
|
|
266
268
|
if (!(autoRetry && retryCount < MAX_RETRY_COUNT_ON_TIMEOUT_ERROR)) return [3 /*break*/, 14];
|
|
@@ -269,7 +271,7 @@ export function request(options) {
|
|
|
269
271
|
}
|
|
270
272
|
return [4 /*yield*/, wait(retryCount * 1000)];
|
|
271
273
|
case 13:
|
|
272
|
-
|
|
274
|
+
_g.sent();
|
|
273
275
|
return [2 /*return*/, request(__assign(__assign({}, options), { retryCount: retryCount + 1 }))];
|
|
274
276
|
case 14: throw new TimeoutError(buildTimeoutErrorInitObject(options.method, url, headers, options.body, preCallStack));
|
|
275
277
|
case 15: throw error_1;
|
package/dist/esm/request.js.map
CHAN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CAAC,UAAU,GAAG,IAAI,CAAC,EAAA;;oBAA7B,SAA6B,CAAC;oBAE9B,sBAAO,OAAO,uBAAM,OAAO,KAAE,UAAU,EAAE,UAAU,GAAG,CAAC,IAAG,EAAC;yBAG7D,MAAM,KAAK,CAAC;;;yBAGV,CAAA,OAAK,YAAY,oBAAoB;wBACrC,CAAC,eAAe,CAAC,OAAK,CAAC,IAAI,OAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA,EAD5D,yBAC4D;yBAExD,CAAA,SAAS,IAAI,UAAU,GAAG,gCAAgC,CAAA,EAA1D,yBAA0D;oBAC5D,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;wBAC9B,GAAG,CACD,WAAI,SAAS,mCAAyB,UAAU,2BAAwB,CACzE,CAAC;qBACH;oBAED,qBAAM,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,EAAA;;oBAA7B,SAA6B,CAAC;oBAE9B,sBAAO,OAAO,uBAAM,OAAO,KAAE,UAAU,EAAE,UAAU,GAAG,CAAC,IAAG,EAAC;yBAG7D,MAAM,IAAI,YAAY,CACpB,2BAA2B,CACzB,OAAO,CAAC,MAAM,EACd,GAAG,EACH,OAAO,EACP,OAAO,CAAC,IAAI,EACZ,YAAY,CACb,CACF,CAAC;yBAGJ,MAAM,OAAK,CAAC;;;;;CAEf"}
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type ErrorEntity = {
|
|
|
3
3
|
type: 'api_error';
|
|
4
4
|
attributes: {
|
|
5
5
|
code: string;
|
|
6
|
+
transient?: true;
|
|
7
|
+
doc_url: string;
|
|
6
8
|
details: Record<string, unknown>;
|
|
7
9
|
};
|
|
8
10
|
};
|
|
@@ -40,6 +42,5 @@ export declare class ApiError extends Error {
|
|
|
40
42
|
constructor(initObject: ApiErrorInitObject);
|
|
41
43
|
get errors(): ErrorEntity[];
|
|
42
44
|
findError(codeOrCodes: string | string[], filterDetails?: Record<string, string> | FilterFn): ErrorEntity | undefined;
|
|
43
|
-
get humanMessage(): string | null;
|
|
44
45
|
}
|
|
45
46
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datocms/rest-client-utils",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.2",
|
|
4
4
|
"description": "Utilities for DatoCMS REST API clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"async-scheduler": "^1.4.4"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "9a48e980dee5adfc7b304fa3f5b8d1c66229304a",
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/qs": "^6.9.7"
|
|
44
44
|
}
|
package/src/errors.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type ErrorEntity = {
|
|
|
3
3
|
type: 'api_error';
|
|
4
4
|
attributes: {
|
|
5
5
|
code: string;
|
|
6
|
+
transient?: true;
|
|
7
|
+
doc_url: string;
|
|
6
8
|
details: Record<string, unknown>;
|
|
7
9
|
};
|
|
8
10
|
};
|
|
@@ -43,46 +45,6 @@ function isErrorBody(body: unknown): body is ErrorBody {
|
|
|
43
45
|
return true;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
const humanMessageForCode: Record<string, string | undefined> = {
|
|
47
|
-
BATCH_DATA_VALIDATION_IN_PROGRESS: `The schema of this model changed, we're re-running validations over every record in background. Please retry with this operation in a few seconds!`,
|
|
48
|
-
INSUFFICIENT_PERMISSIONS: 'Your role does not permit this action',
|
|
49
|
-
MAINTENANCE_MODE: 'The project is currently in maintenance mode!',
|
|
50
|
-
DELETE_RESTRICTION: `Sorry, but you cannot delete this resource, as it's currently used/referenced elsewhere!`,
|
|
51
|
-
INVALID_CREDENTIALS: 'Credentials are incorrect!',
|
|
52
|
-
INVALID_EMAIL: 'Email address is incorrect!',
|
|
53
|
-
INVALID_FORMAT: `The format of the parameters passed is incorrect, take a look at the details of the error to know what's wrong!`,
|
|
54
|
-
ITEM_LOCKED:
|
|
55
|
-
'The operation cannot be completed as some other user is currently editing this record!',
|
|
56
|
-
LINKED_FROM_PUBLISHED_ITEMS: `Couldn't unpublish the record, as some published records are linked to it!`,
|
|
57
|
-
PLAN_UPGRADE_REQUIRED: 'Cannot proceed, please upgrade plan!',
|
|
58
|
-
PUBLISHED_CHILDREN: `Couldn't unpublish the record, some children records are still published!`,
|
|
59
|
-
REQUIRED_2FA_SETUP:
|
|
60
|
-
'This project requires every user to turn on 2-factor authentication! Please go to your Dashboard and activate it! (https://dashboard.datocms.com/account/setup-2fa)',
|
|
61
|
-
REQUIRED_BY_ASSOCIATION: `Cannot delete the record, as it's required by other records:`,
|
|
62
|
-
STALE_ITEM_VERSION:
|
|
63
|
-
'Someone else made a change while you were editing this record, please refresh the page!',
|
|
64
|
-
TITLE_ALREADY_PRESENT: 'There can only be one Title field per model',
|
|
65
|
-
UNPUBLISHED_LINK: `Couldn't publish the record, as it links some unpublished records!`,
|
|
66
|
-
UNPUBLISHED_PARENT: `Couldn't publish the record, as the parent record is not published!`,
|
|
67
|
-
UPLOAD_IS_CURRENTLY_IN_USE: `Couldn't delete this asset, as it's currently used by some records!`,
|
|
68
|
-
UPLOAD_NOT_PASSING_FIELD_VALIDATIONS: `Couldn't update this asset since some records are failing to pass the validations!`,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const humanMessageForPlanUpgradeLimit: Record<string, string | undefined> = {
|
|
72
|
-
build_triggers: `You've reached the maximum number of build triggers your plan allows`,
|
|
73
|
-
sandbox_environments: `You've reached the maximum number of environments your plan allows`,
|
|
74
|
-
item_types: `You've reached the maximum number of models your plan allows to create`,
|
|
75
|
-
items: `You've reached the maximum number of records your plan allows to create`,
|
|
76
|
-
locales: `You've reached the maximum number of locales your plan allows`,
|
|
77
|
-
mux_encoding_seconds: `You've reached the maximum video encoding limits of your plan`,
|
|
78
|
-
otp: 'Two-factor authentication cannot be on the current plan',
|
|
79
|
-
plugins: `You've reached the maximum number of plugins your plan allows`,
|
|
80
|
-
roles: `You've reached the maximum number of roles your plan allows to create`,
|
|
81
|
-
uploadable_bytes: `You've reached the file storage limits of your plan`,
|
|
82
|
-
users: `You've reached the maximum number of collaborators your plan allows to invite to the project`,
|
|
83
|
-
access_tokens: `You've reached the maximum number of API tokens your plan allows to create`,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
48
|
export type ApiErrorRequest = {
|
|
87
49
|
url: string;
|
|
88
50
|
method: string;
|
|
@@ -189,25 +151,4 @@ export class ApiError extends Error {
|
|
|
189
151
|
))),
|
|
190
152
|
);
|
|
191
153
|
}
|
|
192
|
-
|
|
193
|
-
get humanMessage() {
|
|
194
|
-
const planUpgradeError = this.findError('PLAN_UPGRADE_REQUIRED');
|
|
195
|
-
|
|
196
|
-
if (planUpgradeError) {
|
|
197
|
-
const { limit } = planUpgradeError.attributes.details as {
|
|
198
|
-
limit: string;
|
|
199
|
-
};
|
|
200
|
-
return `${humanMessageForPlanUpgradeLimit[limit]}. Please head over to your account dashboard (https://dashboard.datocms.com/) to upgrade the plan or, if no publicly available plan suits your needs, contact our Sales team (https://www.datocms.com/contact) to get a custom quote!`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const errors = Object.keys(humanMessageForCode)
|
|
204
|
-
.filter((code) => this.findError(code))
|
|
205
|
-
.map((code) => humanMessageForCode[code]);
|
|
206
|
-
|
|
207
|
-
if (errors.length === 0) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return errors.join('\n');
|
|
212
|
-
}
|
|
213
154
|
}
|
package/src/request.ts
CHANGED
|
@@ -330,10 +330,13 @@ export async function request<T>(options: RequestOptions): Promise<T> {
|
|
|
330
330
|
),
|
|
331
331
|
);
|
|
332
332
|
|
|
333
|
-
|
|
333
|
+
const transientErrorCode = error.errors.find((e) => e.attributes.transient)
|
|
334
|
+
?.attributes.code;
|
|
335
|
+
|
|
336
|
+
if (autoRetry && transientErrorCode) {
|
|
334
337
|
if (logLevel >= LogLevel.BASIC) {
|
|
335
338
|
log(
|
|
336
|
-
`[${requestId}]
|
|
339
|
+
`[${requestId}] ${transientErrorCode}, wait ${retryCount} seconds then retry...`,
|
|
337
340
|
);
|
|
338
341
|
}
|
|
339
342
|
|