@magda/utils 3.0.0-alpha.0 → 3.0.0-alpha.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/index-web.js CHANGED
@@ -2502,12 +2502,14 @@ function encodeURIComponentWithApost(string) {
2502
2502
 
2503
2503
  // ../../magda-typescript-common/dist/formatServiceError.js
2504
2504
  function formatServiceError(baseMessage, e, retriesLeft) {
2505
+ var _a, _b, _c, _d;
2505
2506
  let messageParts = [baseMessage];
2506
2507
  if (retriesLeft) {
2507
2508
  messageParts.push(`${retriesLeft} retries left.`);
2508
2509
  }
2509
- if (e && e.response && e.response.statusCode && e.body) {
2510
- messageParts.push(`Status code: ${e.response.statusCode}, body:
2510
+ if ((((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.statusCode) || ((_b = e == null ? void 0 : e.response) == null ? void 0 : _b.status)) && e.body) {
2511
+ const statusCode = ((_c = e == null ? void 0 : e.response) == null ? void 0 : _c.status) || ((_d = e == null ? void 0 : e.response) == null ? void 0 : _d.statusCode);
2512
+ messageParts.push(`Status code: ${statusCode}, body:
2511
2513
  ${JSON.stringify(e.body, null, " ")}`);
2512
2514
  } else if (e && e instanceof Error) {
2513
2515
  messageParts.push(`Exception:
@@ -2537,8 +2539,10 @@ ${JSON.stringify(errorResponse, null, " ")}`, e);
2537
2539
  }
2538
2540
  };
2539
2541
  function createServiceError(e) {
2540
- if (e && e.response && e.response.statusCode && e.body) {
2541
- return new BadRequestError(e.response.statusCode, e.body, e);
2542
+ var _a, _b, _c, _d;
2543
+ if ((((_a = e == null ? void 0 : e.response) == null ? void 0 : _a.statusCode) || ((_b = e == null ? void 0 : e.response) == null ? void 0 : _b.status)) && e.body) {
2544
+ const statusCode = ((_c = e == null ? void 0 : e.response) == null ? void 0 : _c.status) || ((_d = e == null ? void 0 : e.response) == null ? void 0 : _d.statusCode);
2545
+ return new BadRequestError(statusCode, e.body, e);
2542
2546
  } else if (e && e instanceof Error) {
2543
2547
  return e;
2544
2548
  } else if (e && e.toString() !== {}.toString()) {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- /// <reference types="node" />
2
-
3
1
  import { Arguments } from 'yargs';
4
- import requestOriginal from 'request';
5
2
 
6
3
  /**
7
4
  * Checks to see whether the passed argv has a jwtSecret object. If not,
@@ -17,6 +14,17 @@ export declare function addJwtSecretFromEnvVar<T>(argv: {
17
14
  [key in keyof Arguments<T>]: Arguments<T>[key];
18
15
  };
19
16
 
17
+ /**
18
+ *
19
+ * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
20
+ *
21
+ * OpenAPI spec version: 0.1
22
+ *
23
+ *
24
+ * NOTE: This class is auto generated by the swagger code generator program.
25
+ * https://github.com/swagger-api/swagger-codegen.git
26
+ * Do not edit the class manually.
27
+ */
20
28
  declare class ApiError {
21
29
  'message': string;
22
30
  }
@@ -161,8 +169,6 @@ declare interface Monad<T> {
161
169
  chain<U>(f: (t: T) => Monad<U>): Monad<U>;
162
170
  }
163
171
 
164
- export declare const request: requestOriginal.RequestAPI<requestOriginal.Request, requestOriginal.CoreOptions, requestOriginal.RequiredUriUrl>;
165
-
166
172
  declare type RequestContentType = RequestContentTypeJson | RequestContentTypePlainText | RequestContentTypeForm | RequestContentTypeBinary | RequestContentTypeMultipartForm;
167
173
 
168
174
  declare type RequestContentTypeBinary = "application/octet-stream";