@utiliread/http 1.12.0 → 1.13.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/events.js +23 -0
- package/dist/cjs/events.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/msgpack.js +8 -3
- package/dist/cjs/msgpack.js.map +1 -1
- package/dist/esm/events.d.ts +11 -0
- package/dist/esm/events.js +19 -0
- package/dist/esm/events.js.map +1 -0
- 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.js +8 -3
- package/dist/esm/msgpack.js.map +1 -1
- package/dist/esm/pagination.d.ts +1 -1
- package/package.json +1 -1
- package/src/events.ts +39 -0
- package/src/index.ts +2 -1
- package/src/msgpack.ts +1 -1
- package/src/pagination.ts +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.events = void 0;
|
|
4
|
+
var http_builder_1 = require("./http-builder");
|
|
5
|
+
function events(action, configure) {
|
|
6
|
+
return function () {
|
|
7
|
+
var params = [];
|
|
8
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
9
|
+
params[_i] = arguments[_i];
|
|
10
|
+
}
|
|
11
|
+
var builder = action.apply(void 0, params);
|
|
12
|
+
var events = configure.apply(void 0, params);
|
|
13
|
+
if (events.sent) {
|
|
14
|
+
builder.onSent(events.sent);
|
|
15
|
+
}
|
|
16
|
+
if (builder instanceof http_builder_1.HttpBuilderOfT && events.received) {
|
|
17
|
+
builder.onReceived(events.received);
|
|
18
|
+
}
|
|
19
|
+
return builder;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.events = events;
|
|
23
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":";;;AAAA,+CAAsE;AAuBtE,SAAgB,MAAM,CACpB,MAA2B,EAC3B,SAAkD;IAElD,OAAO;QAAU,gBAAY;aAAZ,UAAY,EAAZ,qBAAY,EAAZ,IAAY;YAAZ,2BAAY;;QAC3B,IAAM,OAAO,GAAG,MAAM,eAAI,MAAM,CAAC,CAAC;QAClC,IAAM,MAAM,GAAG,SAAS,eAAI,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,IAAI,EAAE;YACf,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC7B;QACD,IAAI,OAAO,YAAY,6BAAc,IAAI,MAAM,CAAC,QAAQ,EAAE;YACxD,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACrC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAfD,wBAeC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.TimeoutError = exports.HttpError = exports.HttpBuilderOfT = exports.HttpBuilder = exports.HttpResponseOfT = exports.HttpResponse = exports.QueryString = exports.Http = void 0;
|
|
13
|
+
exports.events = exports.TimeoutError = exports.HttpError = exports.HttpBuilderOfT = exports.HttpBuilder = exports.HttpResponseOfT = exports.HttpResponse = exports.QueryString = exports.Http = void 0;
|
|
14
14
|
var http_1 = require("./http");
|
|
15
15
|
Object.defineProperty(exports, "Http", { enumerable: true, get: function () { return http_1.Http; } });
|
|
16
16
|
var query_string_1 = require("./query-string");
|
|
@@ -25,5 +25,7 @@ var http_error_1 = require("./http-error");
|
|
|
25
25
|
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return http_error_1.HttpError; } });
|
|
26
26
|
var timeout_error_1 = require("./timeout-error");
|
|
27
27
|
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return timeout_error_1.TimeoutError; } });
|
|
28
|
+
var events_1 = require("./events");
|
|
29
|
+
Object.defineProperty(exports, "events", { enumerable: true, get: function () { return events_1.events; } });
|
|
28
30
|
__exportStar(require("./helpers"), exports);
|
|
29
31
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAQb,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,iDAAgE;AAAvD,6GAAA,YAAY,OAAA;AAAE,gHAAA,eAAe,OAAA;AACtC,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAQb,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,iDAAgE;AAAvD,6GAAA,YAAY,OAAA;AAAE,gHAAA,eAAe,OAAA;AACtC,+CAAsE;AAA7D,2GAAA,WAAW,OAAA;AAAE,8GAAA,cAAc,OAAA;AACpC,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,4CAA0B"}
|
package/dist/cjs/msgpack.js
CHANGED
|
@@ -65,9 +65,14 @@ http_builder_1.HttpBuilder.prototype.expectMessagePack = function (typeOrMapper)
|
|
|
65
65
|
return this.useHandler(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
66
66
|
var itemFactory, decoded;
|
|
67
67
|
return __generator(this, function (_a) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
itemFactory = (0, mapping_1.getMapper)(msgpack_1.deserialize, typeOrMapper);
|
|
71
|
+
return [4 /*yield*/, (0, msgpack_2.decodeAsync)(response.body)];
|
|
72
|
+
case 1:
|
|
73
|
+
decoded = _a.sent();
|
|
74
|
+
return [2 /*return*/, itemFactory(decoded)];
|
|
75
|
+
}
|
|
71
76
|
});
|
|
72
77
|
}); });
|
|
73
78
|
};
|
package/dist/cjs/msgpack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgpack.js","sourceRoot":"","sources":["../../src/msgpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAiD;AACjD,+CAA6C;AAC7C,4CAAkE;AAClE,qCAAoD;AAkBpD,0BAAW,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAExC,YAA8B;IAFU,iBAUzC;IANC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,UAAU,CAAC,UAAO,QAAQ
|
|
1
|
+
{"version":3,"file":"msgpack.js","sourceRoot":"","sources":["../../src/msgpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAiD;AACjD,+CAA6C;AAC7C,4CAAkE;AAClE,qCAAoD;AAkBpD,0BAAW,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAExC,YAA8B;IAFU,iBAUzC;IANC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,UAAU,CAAC,UAAO,QAAQ;;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AvB,gCAAuB;;wBAAvB,SAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;KAE3B;IAED,OAAO,IAAI,CAAC,UAAU,CAAC,UAAC,QAAQ,IAAK,OAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;AAC3E,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpBuilder, HttpBuilderOfT, Message } from "./http-builder";
|
|
2
|
+
import { HttpResponse } from "./http-response";
|
|
3
|
+
interface Events {
|
|
4
|
+
sent: (response: HttpResponse, request: Message) => void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
interface EventsOfT<T> extends Events {
|
|
7
|
+
received: (response: HttpResponse, request: Message, value: T) => void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function events<P extends any[]>(action: (...params: P) => HttpBuilder, configure: (...params: P) => Partial<Events>): (...params: P) => HttpBuilder;
|
|
10
|
+
export declare function events<B extends HttpBuilderOfT<T>, P extends any[], T>(action: (...params: P) => B, configure: (...params: P) => Partial<EventsOfT<T>>): (...params: P) => B;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpBuilderOfT } from "./http-builder";
|
|
2
|
+
export function events(action, configure) {
|
|
3
|
+
return function () {
|
|
4
|
+
var params = [];
|
|
5
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6
|
+
params[_i] = arguments[_i];
|
|
7
|
+
}
|
|
8
|
+
var builder = action.apply(void 0, params);
|
|
9
|
+
var events = configure.apply(void 0, params);
|
|
10
|
+
if (events.sent) {
|
|
11
|
+
builder.onSent(events.sent);
|
|
12
|
+
}
|
|
13
|
+
if (builder instanceof HttpBuilderOfT && events.received) {
|
|
14
|
+
builder.onReceived(events.received);
|
|
15
|
+
}
|
|
16
|
+
return builder;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAW,MAAM,gBAAgB,CAAC;AAuBtE,MAAM,UAAU,MAAM,CACpB,MAA2B,EAC3B,SAAkD;IAElD,OAAO;QAAU,gBAAY;aAAZ,UAAY,EAAZ,qBAAY,EAAZ,IAAY;YAAZ,2BAAY;;QAC3B,IAAM,OAAO,GAAG,MAAM,eAAI,MAAM,CAAC,CAAC;QAClC,IAAM,MAAM,GAAG,SAAS,eAAI,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,IAAI,EAAE;YACf,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC7B;QACD,IAAI,OAAO,YAAY,cAAc,IAAI,MAAM,CAAC,QAAQ,EAAE;YACxD,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACrC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ export { Page, PaginationResult, InfinitePage, InfinitePaginationResult, } from
|
|
|
3
3
|
export { ProblemDetails } from "./problem-details";
|
|
4
4
|
export { QueryString } from "./query-string";
|
|
5
5
|
export { HttpResponse, HttpResponseOfT } from "./http-response";
|
|
6
|
-
export { HttpBuilder, HttpBuilderOfT } from "./http-builder";
|
|
6
|
+
export { HttpBuilder, HttpBuilderOfT, Message } from "./http-builder";
|
|
7
7
|
export { HttpError } from "./http-error";
|
|
8
8
|
export { TimeoutError } from "./timeout-error";
|
|
9
|
+
export { events } from "./events";
|
|
9
10
|
export * from "./helpers";
|
|
10
11
|
export { Fetch } from "./http";
|
|
11
12
|
export { Subscription } from "./event-aggregator";
|
package/dist/esm/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { HttpResponse, HttpResponseOfT } from "./http-response";
|
|
|
4
4
|
export { HttpBuilder, HttpBuilderOfT } from "./http-builder";
|
|
5
5
|
export { HttpError } from "./http-error";
|
|
6
6
|
export { TimeoutError } from "./timeout-error";
|
|
7
|
+
export { events } from "./events";
|
|
7
8
|
export * from "./helpers";
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ9B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAW,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
package/dist/esm/msgpack.js
CHANGED
|
@@ -63,9 +63,14 @@ HttpBuilder.prototype.expectMessagePack = function (typeOrMapper) {
|
|
|
63
63
|
return this.useHandler(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
64
64
|
var itemFactory, decoded;
|
|
65
65
|
return __generator(this, function (_a) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0:
|
|
68
|
+
itemFactory = getMapper(deserialize, typeOrMapper);
|
|
69
|
+
return [4 /*yield*/, decodeAsync(response.body)];
|
|
70
|
+
case 1:
|
|
71
|
+
decoded = _a.sent();
|
|
72
|
+
return [2 /*return*/, itemFactory(decoded)];
|
|
73
|
+
}
|
|
69
74
|
});
|
|
70
75
|
}); });
|
|
71
76
|
};
|
package/dist/esm/msgpack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgpack.js","sourceRoot":"","sources":["../../src/msgpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAgB,MAAM,WAAW,CAAC;AAkBpD,WAAW,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAExC,YAA8B;IAFU,iBAUzC;IANC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,UAAU,CAAC,UAAO,QAAQ
|
|
1
|
+
{"version":3,"file":"msgpack.js","sourceRoot":"","sources":["../../src/msgpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAgB,MAAM,WAA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AAS,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;;;;wBAChC,KAAA,cAAA,iBAAiB,CAAC,QAAQ,CAAC,IAAK,CAAC,CAAA;;;;;wBAAzC,IAAI,WAAA,CAAA;qDACb,WAAW,CAAC,IAAI,CAAC;4BAAvB,gCAAuB;;wBAAvB,SAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;KAE3B;IAED,OAAO,IAAI,CAAC,UAAU,CAAC,UAAC,QAAQ,IAAK,OAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAlC,CAAkC,CAAC,CAAC;AAC3E,CAAC,CAAC"}
|
package/dist/esm/pagination.d.ts
CHANGED
package/package.json
CHANGED
package/src/events.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HttpBuilder, HttpBuilderOfT, Message } from "./http-builder";
|
|
2
|
+
import { HttpResponse } from "./http-response";
|
|
3
|
+
|
|
4
|
+
interface Events {
|
|
5
|
+
sent: (response: HttpResponse, request: Message) => void | Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface EventsOfT<T> extends Events {
|
|
9
|
+
received: (
|
|
10
|
+
response: HttpResponse,
|
|
11
|
+
request: Message,
|
|
12
|
+
value: T
|
|
13
|
+
) => void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function events<P extends any[]>(
|
|
17
|
+
action: (...params: P) => HttpBuilder,
|
|
18
|
+
configure: (...params: P) => Partial<Events>
|
|
19
|
+
): (...params: P) => HttpBuilder;
|
|
20
|
+
export function events<B extends HttpBuilderOfT<T>, P extends any[], T>(
|
|
21
|
+
action: (...params: P) => B,
|
|
22
|
+
configure: (...params: P) => Partial<EventsOfT<T>>
|
|
23
|
+
): (...params: P) => B;
|
|
24
|
+
export function events<B extends HttpBuilderOfT<T>, P extends any[], T>(
|
|
25
|
+
action: (...params: P) => B,
|
|
26
|
+
configure: (...params: P) => Partial<EventsOfT<T>>
|
|
27
|
+
): (...params: P) => B {
|
|
28
|
+
return function (...params: P) {
|
|
29
|
+
const builder = action(...params);
|
|
30
|
+
const events = configure(...params);
|
|
31
|
+
if (events.sent) {
|
|
32
|
+
builder.onSent(events.sent);
|
|
33
|
+
}
|
|
34
|
+
if (builder instanceof HttpBuilderOfT && events.received) {
|
|
35
|
+
builder.onReceived(events.received);
|
|
36
|
+
}
|
|
37
|
+
return builder;
|
|
38
|
+
};
|
|
39
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,9 +8,10 @@ export {
|
|
|
8
8
|
export { ProblemDetails } from "./problem-details";
|
|
9
9
|
export { QueryString } from "./query-string";
|
|
10
10
|
export { HttpResponse, HttpResponseOfT } from "./http-response";
|
|
11
|
-
export { HttpBuilder, HttpBuilderOfT } from "./http-builder";
|
|
11
|
+
export { HttpBuilder, HttpBuilderOfT, Message } from "./http-builder";
|
|
12
12
|
export { HttpError } from "./http-error";
|
|
13
13
|
export { TimeoutError } from "./timeout-error";
|
|
14
|
+
export { events } from "./events";
|
|
14
15
|
export * from "./helpers";
|
|
15
16
|
export { Fetch } from "./http";
|
|
16
17
|
export { Subscription } from "./event-aggregator";
|
package/src/msgpack.ts
CHANGED
|
@@ -26,7 +26,7 @@ HttpBuilder.prototype.expectMessagePack = function <T>(
|
|
|
26
26
|
this.message.headers.set("Accept", "application/x-msgpack");
|
|
27
27
|
return this.useHandler(async (response) => {
|
|
28
28
|
const itemFactory = getMapper(deserialize, typeOrMapper);
|
|
29
|
-
const decoded = decodeAsync(response.body!);
|
|
29
|
+
const decoded = await decodeAsync(response.body!);
|
|
30
30
|
return itemFactory(decoded);
|
|
31
31
|
});
|
|
32
32
|
};
|
package/src/pagination.ts
CHANGED