caccl-send-request 2.2.11 → 2.2.13-beta.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/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -4
- package/lib/ErrorCode.d.ts +0 -6
- package/lib/ErrorCode.js +0 -12
- package/lib/ErrorCode.js.map +0 -1
- package/lib/ResponseType.d.ts +0 -9
- package/lib/ResponseType.js +0 -13
- package/lib/ResponseType.js.map +0 -1
- package/lib/types/ResponseType.d.ts +0 -9
- package/lib/types/ResponseType.js +0 -15
- package/lib/types/ResponseType.js.map +0 -1
- package/src/types/ResponseType.ts +0 -12
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ResponseType from './types/ResponseType';
|
|
2
1
|
/**
|
|
3
2
|
* Sends and retries an http request
|
|
4
3
|
* @author Gabriel Abrams
|
|
@@ -28,7 +27,7 @@ declare const sendRequest: (opts: {
|
|
|
28
27
|
};
|
|
29
28
|
numRetries?: number;
|
|
30
29
|
sendCrossDomainCredentials?: boolean;
|
|
31
|
-
responseType?:
|
|
30
|
+
responseType?: 'Text' | 'JSON';
|
|
32
31
|
}) => Promise<{
|
|
33
32
|
body: any;
|
|
34
33
|
status: number;
|
package/lib/index.js
CHANGED
|
@@ -56,7 +56,6 @@ var qs_1 = __importDefault(require("qs"));
|
|
|
56
56
|
var caccl_error_1 = __importDefault(require("caccl-error"));
|
|
57
57
|
// Import shared types
|
|
58
58
|
var ErrorCode_1 = __importDefault(require("./types/ErrorCode"));
|
|
59
|
-
var ResponseType_1 = __importDefault(require("./types/ResponseType"));
|
|
60
59
|
/**
|
|
61
60
|
* Sends and retries an http request
|
|
62
61
|
* @author Gabriel Abrams
|
|
@@ -157,7 +156,7 @@ var sendRequest = function (opts) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
157
156
|
_b.trys.push([3, 8, , 9]);
|
|
158
157
|
responseBody = void 0;
|
|
159
158
|
if (!(opts.responseType
|
|
160
|
-
&& opts.responseType ===
|
|
159
|
+
&& opts.responseType === 'Text')) return [3 /*break*/, 5];
|
|
161
160
|
return [4 /*yield*/, response.text()];
|
|
162
161
|
case 4:
|
|
163
162
|
// Response type is text
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,0CAAoB;AAEpB,0BAA0B;AAC1B,4DAAqC;AAErC,sBAAsB;AACtB,gEAA0C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,0CAAoB;AAEpB,0BAA0B;AAC1B,4DAAqC;AAErC,sBAAsB;AACtB,gEAA0C;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,IAAM,WAAW,GAAG,UAClB,IASC;;;;;;gBAOK,SAAS,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC,CAAC;gBAG7C,0BAA0B,GAAG,CAAC,CAAC,CACnC,IAAI,CAAC,0BAA0B;uBAC5B,SAAS;uBACT,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,MAAK,SAAS,CAC3C,CAAC;gBAGI,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAGrD,MAAM,GAAwC,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;gBAM3E,IAAI,IAAI,CAAC,MAAM,EAAE;oBACf,MAAM,GAAG,EAAE,CAAC;oBACZ,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gBADpC,wBAAwB;gBACxB,YAAY,GAAG,SAAqB,CAAC;;;YAGvC,kBAAkB;YAClB,sBAAO;oBACL,IAAI,EAAE,YAAY;oBAClB,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,OAAO,EAAE,iBAAe;iBACzB,EAAC;;;gBAEF,MAAM,IAAI,qBAAU,CAAC;oBACnB,OAAO,EAAE,sCAA+B,IAAI,CAAC,YAAY,eAAM,KAAW,aAAX,KAAG,uBAAH,KAAG,CAAU,OAAO,CAAE;oBACrF,IAAI,EAAE,mBAAS,CAAC,kBAAkB;iBACnC,CAAC,CAAC;;;;gBAGL,iDAAiD;gBACjD,IAAI,UAAU,GAAG,CAAC,EAAE;oBAClB,kCAAkC;oBAClC,sBAAO,WAAW,uBACb,IAAI,KACP,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,CAAC,IAC/B,EAAC;iBACJ;gBAED,iCAAiC;gBACjC,IAAI,KAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE;oBACnD,MAAM,IAAI,qBAAU,CAAC;wBACnB,OAAO,EAAE,iFAAiF;wBAC1F,IAAI,EAAE,mBAAS,CAAC,UAAU;qBAC3B,CAAC,CAAC;iBACJ;gBAED,gBAAgB;gBAChB,MAAM,IAAI,qBAAU,CAAC;oBACnB,OAAO,EAAE,0HAAoH,KAAW,aAAX,KAAG,uBAAH,KAAG,CAAU,OAAO,CAAE;oBACnJ,IAAI,EAAE,mBAAS,CAAC,YAAY;iBAC7B,CAAC,CAAC;;;;KAEN,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caccl-send-request",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.13-beta.2",
|
|
4
4
|
"description": "The default request sender used throughout the CACCL project.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"typescript": "^4.5.5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"caccl-error": "^2.2.
|
|
39
|
+
"caccl-error": "^2.2.13-beta.2",
|
|
40
40
|
"qs": "^6.9.6"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import CACCLError from 'caccl-error';
|
|
|
6
6
|
|
|
7
7
|
// Import shared types
|
|
8
8
|
import ErrorCode from './types/ErrorCode';
|
|
9
|
-
import ResponseType from './types/ResponseType';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Sends and retries an http request
|
|
@@ -22,7 +21,7 @@ import ResponseType from './types/ResponseType';
|
|
|
22
21
|
* fails
|
|
23
22
|
* @param [opts.sendCrossDomainCredentials=true if in development mode] if true,
|
|
24
23
|
* send cross-domain credentials even if not in dev mode
|
|
25
|
-
* @param [opts.responseType=
|
|
24
|
+
* @param [opts.responseType=JSON] expected response type
|
|
26
25
|
* @returns { body, status, headers } on success
|
|
27
26
|
*/
|
|
28
27
|
const sendRequest = async (
|
|
@@ -34,7 +33,7 @@ const sendRequest = async (
|
|
|
34
33
|
headers?: { [k in string]: any },
|
|
35
34
|
numRetries?: number,
|
|
36
35
|
sendCrossDomainCredentials?: boolean,
|
|
37
|
-
responseType?:
|
|
36
|
+
responseType?: 'Text' | 'JSON',
|
|
38
37
|
},
|
|
39
38
|
): Promise<{
|
|
40
39
|
body: any,
|
|
@@ -148,7 +147,7 @@ const sendRequest = async (
|
|
|
148
147
|
let responseBody: any;
|
|
149
148
|
if (
|
|
150
149
|
opts.responseType
|
|
151
|
-
&& opts.responseType ===
|
|
150
|
+
&& opts.responseType === 'Text'
|
|
152
151
|
) {
|
|
153
152
|
// Response type is text
|
|
154
153
|
responseBody = await response.text();
|
package/lib/ErrorCode.d.ts
DELETED
package/lib/ErrorCode.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Highest error code: CSR3
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
var ErrorCode;
|
|
5
|
-
(function (ErrorCode) {
|
|
6
|
-
ErrorCode["NotConnected"] = "CSR1";
|
|
7
|
-
ErrorCode["SelfSigned"] = "CSR2";
|
|
8
|
-
ErrorCode["ResponseParseError"] = "CSR3";
|
|
9
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
10
|
-
;
|
|
11
|
-
exports.default = ErrorCode;
|
|
12
|
-
//# sourceMappingURL=ErrorCode.js.map
|
package/lib/ErrorCode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorCode.js","sourceRoot":"","sources":["../src/ErrorCode.ts"],"names":[],"mappings":";AAAA,2BAA2B;;AAE3B,IAAK,SAIJ;AAJD,WAAK,SAAS;IACZ,kCAAqB,CAAA;IACrB,gCAAmB,CAAA;IACnB,wCAA2B,CAAA;AAC7B,CAAC,EAJI,SAAS,KAAT,SAAS,QAIb;AAAA,CAAC;AAEF,kBAAe,SAAS,CAAC"}
|
package/lib/ResponseType.d.ts
DELETED
package/lib/ResponseType.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Response types
|
|
5
|
-
* @author Yuen Ler Chow
|
|
6
|
-
*/
|
|
7
|
-
var ResponseType;
|
|
8
|
-
(function (ResponseType) {
|
|
9
|
-
ResponseType["Text"] = "Text";
|
|
10
|
-
ResponseType["JSON"] = "JSON";
|
|
11
|
-
})(ResponseType || (ResponseType = {}));
|
|
12
|
-
exports.default = ResponseType;
|
|
13
|
-
//# sourceMappingURL=ResponseType.js.map
|
package/lib/ResponseType.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseType.js","sourceRoot":"","sources":["../src/ResponseType.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,6BAAa,CAAA;IACb,6BAAa,CAAA;AACf,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Response types
|
|
5
|
-
* @author Yuen Ler Chow
|
|
6
|
-
*/
|
|
7
|
-
var ResponseType;
|
|
8
|
-
(function (ResponseType) {
|
|
9
|
-
// Response is plain text
|
|
10
|
-
ResponseType["Text"] = "Text";
|
|
11
|
-
// Response is encoded JSON (object or array)
|
|
12
|
-
ResponseType["JSON"] = "JSON";
|
|
13
|
-
})(ResponseType || (ResponseType = {}));
|
|
14
|
-
exports.default = ResponseType;
|
|
15
|
-
//# sourceMappingURL=ResponseType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseType.js","sourceRoot":"","sources":["../../src/types/ResponseType.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAK,YAKJ;AALD,WAAK,YAAY;IACf,yBAAyB;IACzB,6BAAa,CAAA;IACb,6CAA6C;IAC7C,6BAAa,CAAA;AACf,CAAC,EALI,YAAY,KAAZ,YAAY,QAKhB;AAED,kBAAe,YAAY,CAAC"}
|