@utiliread/http 1.10.2 → 1.13.0
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/.vscode/settings.json +2 -2
- package/dist/cjs/events.js +19 -85
- package/dist/cjs/events.js.map +1 -1
- package/dist/cjs/http-builder.js.map +1 -1
- package/dist/cjs/http.js +2 -1
- package/dist/cjs/http.js.map +1 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/msgpack.js +17 -0
- package/dist/cjs/msgpack.js.map +1 -1
- package/dist/esm/events.d.ts +4 -22
- package/dist/esm/events.js +17 -84
- package/dist/esm/events.js.map +1 -1
- package/dist/esm/http-builder.d.ts +3 -0
- package/dist/esm/http-builder.js.map +1 -1
- package/dist/esm/http.js +2 -1
- package/dist/esm/http.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/msgpack.d.ts +1 -0
- package/dist/esm/msgpack.js +18 -1
- package/dist/esm/msgpack.js.map +1 -1
- package/karma.config.js +30 -30
- package/package.json +1 -1
- package/src/event-aggregator.ts +31 -31
- package/src/events.ts +35 -0
- package/src/helpers.ts +13 -13
- package/src/http-builder.ts +254 -253
- package/src/http-error.ts +25 -25
- package/src/http-response.ts +55 -55
- package/src/http.spec.ts +104 -104
- package/src/http.ts +121 -120
- package/src/index.ts +17 -16
- package/src/json.ts +138 -138
- package/src/mapping.ts +42 -42
- package/src/msgpack.ts +63 -48
- package/src/pagination.ts +25 -25
- package/src/problem-details.ts +7 -7
- package/src/query-string.spec.ts +62 -62
- package/src/query-string.ts +69 -69
- package/src/timeout-error.ts +10 -10
- package/tsconfig.cjs.json +8 -8
- package/tsconfig.json +13 -13
- package/dist/cjs/settings.js +0 -3
- package/dist/cjs/settings.js.map +0 -1
- package/dist/cjs/utils.js +0 -8
- package/dist/cjs/utils.js.map +0 -1
- package/dist/esm/settings.d.ts +0 -6
- package/dist/esm/settings.js +0 -2
- package/dist/esm/settings.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -3
- package/dist/esm/utils.js +0 -4
- package/dist/esm/utils.js.map +0 -1
package/src/query-string.ts
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
|
|
3
|
-
export class QueryString {
|
|
4
|
-
static serialize(params: any) {
|
|
5
|
-
if (!params) {
|
|
6
|
-
return "";
|
|
7
|
-
}
|
|
8
|
-
const serialized = this._serializeQueryString(params);
|
|
9
|
-
if (!serialized.length) {
|
|
10
|
-
return "";
|
|
11
|
-
}
|
|
12
|
-
return "?" + serialized;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static append(url: string, params: any) {
|
|
16
|
-
if (!params) {
|
|
17
|
-
return url;
|
|
18
|
-
}
|
|
19
|
-
const any = url.indexOf("?") >= 0;
|
|
20
|
-
const separator = any ? "&" : "?";
|
|
21
|
-
|
|
22
|
-
return url + separator + this._serializeQueryString(params);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static getParameter(name: string) {
|
|
26
|
-
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
|
27
|
-
const match = regex.exec(window.location.href);
|
|
28
|
-
if (match) {
|
|
29
|
-
if (match[1].length > 0) {
|
|
30
|
-
return decodeURIComponent(match[2]);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private static _serializeQueryString(source: any, prefix?: string) {
|
|
39
|
-
const parts: string[] = [];
|
|
40
|
-
for (const propertyName in source) {
|
|
41
|
-
if (source.hasOwnProperty(propertyName)) {
|
|
42
|
-
const key = prefix != null
|
|
43
|
-
? prefix + (
|
|
44
|
-
Array.isArray(source)
|
|
45
|
-
? "[" + encodeURIComponent(propertyName) + "]"
|
|
46
|
-
: "." + encodeURIComponent(propertyName)
|
|
47
|
-
)
|
|
48
|
-
: encodeURIComponent(propertyName);
|
|
49
|
-
const value = source[propertyName];
|
|
50
|
-
|
|
51
|
-
if (value instanceof DateTime) {
|
|
52
|
-
parts.push(key + "=" + encodeURIComponent(value.toISO()));
|
|
53
|
-
}
|
|
54
|
-
else if (value === null) {
|
|
55
|
-
parts.push(key);
|
|
56
|
-
}
|
|
57
|
-
else if (value !== undefined) {
|
|
58
|
-
if (typeof value === "object") {
|
|
59
|
-
parts.push(this._serializeQueryString(value, key));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
parts.push(key + "=" + encodeURIComponent(value));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return parts.join("&");
|
|
69
|
-
}
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
|
|
3
|
+
export class QueryString {
|
|
4
|
+
static serialize(params: any) {
|
|
5
|
+
if (!params) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
const serialized = this._serializeQueryString(params);
|
|
9
|
+
if (!serialized.length) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return "?" + serialized;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static append(url: string, params: any) {
|
|
16
|
+
if (!params) {
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
const any = url.indexOf("?") >= 0;
|
|
20
|
+
const separator = any ? "&" : "?";
|
|
21
|
+
|
|
22
|
+
return url + separator + this._serializeQueryString(params);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static getParameter(name: string) {
|
|
26
|
+
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
|
|
27
|
+
const match = regex.exec(window.location.href);
|
|
28
|
+
if (match) {
|
|
29
|
+
if (match[1].length > 0) {
|
|
30
|
+
return decodeURIComponent(match[2]);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static _serializeQueryString(source: any, prefix?: string) {
|
|
39
|
+
const parts: string[] = [];
|
|
40
|
+
for (const propertyName in source) {
|
|
41
|
+
if (source.hasOwnProperty(propertyName)) {
|
|
42
|
+
const key = prefix != null
|
|
43
|
+
? prefix + (
|
|
44
|
+
Array.isArray(source)
|
|
45
|
+
? "[" + encodeURIComponent(propertyName) + "]"
|
|
46
|
+
: "." + encodeURIComponent(propertyName)
|
|
47
|
+
)
|
|
48
|
+
: encodeURIComponent(propertyName);
|
|
49
|
+
const value = source[propertyName];
|
|
50
|
+
|
|
51
|
+
if (value instanceof DateTime) {
|
|
52
|
+
parts.push(key + "=" + encodeURIComponent(value.toISO()));
|
|
53
|
+
}
|
|
54
|
+
else if (value === null) {
|
|
55
|
+
parts.push(key);
|
|
56
|
+
}
|
|
57
|
+
else if (value !== undefined) {
|
|
58
|
+
if (typeof value === "object") {
|
|
59
|
+
parts.push(this._serializeQueryString(value, key));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
parts.push(key + "=" + encodeURIComponent(value));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return parts.join("&");
|
|
69
|
+
}
|
|
70
70
|
}
|
package/src/timeout-error.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export class TimeoutError extends Error {
|
|
2
|
-
constructor() {
|
|
3
|
-
super("Timeout: The request was not successful");
|
|
4
|
-
this.name = 'TimeoutError';
|
|
5
|
-
|
|
6
|
-
// Set the prototype explicitly to allow for "... instanceof TimeoutError",
|
|
7
|
-
// see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
8
|
-
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
export class TimeoutError extends Error {
|
|
2
|
+
constructor() {
|
|
3
|
+
super("Timeout: The request was not successful");
|
|
4
|
+
this.name = 'TimeoutError';
|
|
5
|
+
|
|
6
|
+
// Set the prototype explicitly to allow for "... instanceof TimeoutError",
|
|
7
|
+
// see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
8
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
package/tsconfig.cjs.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"outDir": "dist/cjs",
|
|
7
|
-
"declaration": false
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"outDir": "dist/cjs",
|
|
7
|
+
"declaration": false
|
|
8
|
+
}
|
|
9
9
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"rootDir": "src",
|
|
10
|
-
"outDir": "dist/esm",
|
|
11
|
-
"lib": [ "es2017", "dom" ],
|
|
12
|
-
"stripInternal": true,
|
|
13
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"strict": true,
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"outDir": "dist/esm",
|
|
11
|
+
"lib": [ "es2017", "dom" ],
|
|
12
|
+
"stripInternal": true,
|
|
13
|
+
}
|
|
14
14
|
}
|
package/dist/cjs/settings.js
DELETED
package/dist/cjs/settings.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":""}
|
package/dist/cjs/utils.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isZeroArgumentFunction = void 0;
|
|
4
|
-
function isZeroArgumentFunction(typeCtor) {
|
|
5
|
-
return typeCtor.length === 0;
|
|
6
|
-
}
|
|
7
|
-
exports.isZeroArgumentFunction = isZeroArgumentFunction;
|
|
8
|
-
//# sourceMappingURL=utils.js.map
|
package/dist/cjs/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,sBAAsB,CAAI,QAAkB;IACxD,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;AACjC,CAAC;AAFD,wDAEC"}
|
package/dist/esm/settings.d.ts
DELETED
package/dist/esm/settings.js
DELETED
package/dist/esm/settings.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":""}
|
package/dist/esm/utils.d.ts
DELETED
package/dist/esm/utils.js
DELETED
package/dist/esm/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,sBAAsB,CAAI,QAAkB;IACxD,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;AACjC,CAAC"}
|