@utiliread/http 1.16.2 → 1.17.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/dist/index.d.ts +227 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +534 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +507 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{esm/json.d.ts → json.d.ts} +15 -17
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +100 -0
- package/dist/json.js.map +1 -0
- package/dist/json.mjs +100 -0
- package/dist/json.mjs.map +1 -0
- package/dist/{esm/jsonpatch.d.ts → jsonpatch.d.ts} +10 -9
- package/dist/jsonpatch.d.ts.map +1 -0
- package/dist/jsonpatch.js +18 -0
- package/dist/jsonpatch.js.map +1 -0
- package/dist/jsonpatch.mjs +18 -0
- package/dist/jsonpatch.mjs.map +1 -0
- package/dist/{esm/msgpack.d.ts → msgpack.d.ts} +9 -10
- package/dist/msgpack.d.ts.map +1 -0
- package/dist/msgpack.js +62 -0
- package/dist/msgpack.js.map +1 -0
- package/dist/msgpack.mjs +62 -0
- package/dist/msgpack.mjs.map +1 -0
- package/json.d.ts +1 -1
- package/jsonpatch.d.ts +1 -1
- package/msgpack.d.ts +1 -1
- package/package.json +28 -20
- package/plugins/json/package-lock.json +145 -0
- package/plugins/json/package.json +11 -0
- package/{src/json.ts → plugins/json/src/index.ts} +123 -117
- package/plugins/json/tsconfig.json +3 -0
- package/plugins/jsonpatch/package-lock.json +124 -0
- package/plugins/jsonpatch/package.json +13 -0
- package/{src/jsonpatch.ts → plugins/jsonpatch/src/index.ts} +31 -30
- package/plugins/jsonpatch/tsconfig.json +3 -0
- package/plugins/msgpack/package-lock.json +134 -0
- package/plugins/msgpack/package.json +12 -0
- package/{src/msgpack.ts → plugins/msgpack/src/index.ts} +60 -64
- package/plugins/msgpack/tsconfig.json +3 -0
- package/src/http-builder.ts +1 -1
- package/src/http.ts +132 -116
- package/src/index.ts +8 -6
- package/src/mapping.ts +1 -0
- package/tsconfig.json +8 -17
- package/dist/cjs/event-aggregator.js +0 -94
- package/dist/cjs/event-aggregator.js.map +0 -1
- package/dist/cjs/events.js +0 -23
- package/dist/cjs/events.js.map +0 -1
- package/dist/cjs/helpers.js +0 -16
- package/dist/cjs/helpers.js.map +0 -1
- package/dist/cjs/http-builder.js +0 -284
- package/dist/cjs/http-builder.js.map +0 -1
- package/dist/cjs/http-error.js +0 -53
- package/dist/cjs/http-error.js.map +0 -1
- package/dist/cjs/http-response.js +0 -102
- package/dist/cjs/http-response.js.map +0 -1
- package/dist/cjs/http.js +0 -97
- package/dist/cjs/http.js.map +0 -1
- package/dist/cjs/http.spec.js +0 -144
- package/dist/cjs/http.spec.js.map +0 -1
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json.js +0 -71
- package/dist/cjs/json.js.map +0 -1
- package/dist/cjs/jsonpatch.js +0 -15
- package/dist/cjs/jsonpatch.js.map +0 -1
- package/dist/cjs/mapping.js +0 -37
- package/dist/cjs/mapping.js.map +0 -1
- package/dist/cjs/msgpack.js +0 -173
- package/dist/cjs/msgpack.js.map +0 -1
- package/dist/cjs/pagination.js +0 -3
- package/dist/cjs/pagination.js.map +0 -1
- package/dist/cjs/problem-details.js +0 -3
- package/dist/cjs/problem-details.js.map +0 -1
- package/dist/cjs/query-string.js +0 -69
- package/dist/cjs/query-string.js.map +0 -1
- package/dist/cjs/query-string.spec.js +0 -52
- package/dist/cjs/query-string.spec.js.map +0 -1
- package/dist/cjs/status-codes.js +0 -71
- package/dist/cjs/status-codes.js.map +0 -1
- package/dist/cjs/timeout-error.js +0 -32
- package/dist/cjs/timeout-error.js.map +0 -1
- package/dist/esm/event-aggregator.d.ts +0 -11
- package/dist/esm/event-aggregator.js +0 -91
- package/dist/esm/event-aggregator.js.map +0 -1
- package/dist/esm/events.d.ts +0 -11
- package/dist/esm/events.js +0 -19
- package/dist/esm/events.js.map +0 -1
- package/dist/esm/helpers.d.ts +0 -5
- package/dist/esm/helpers.js +0 -10
- package/dist/esm/helpers.js.map +0 -1
- package/dist/esm/http-builder.d.ts +0 -60
- package/dist/esm/http-builder.js +0 -281
- package/dist/esm/http-builder.js.map +0 -1
- package/dist/esm/http-error.d.ts +0 -10
- package/dist/esm/http-error.js +0 -50
- package/dist/esm/http-error.js.map +0 -1
- package/dist/esm/http-response.d.ts +0 -18
- package/dist/esm/http-response.js +0 -99
- package/dist/esm/http-response.js.map +0 -1
- package/dist/esm/http.d.ts +0 -32
- package/dist/esm/http.js +0 -94
- package/dist/esm/http.js.map +0 -1
- package/dist/esm/http.spec.d.ts +0 -1
- package/dist/esm/http.spec.js +0 -142
- package/dist/esm/http.spec.js.map +0 -1
- package/dist/esm/index.d.ts +0 -13
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json.js +0 -69
- package/dist/esm/json.js.map +0 -1
- package/dist/esm/jsonpatch.js +0 -13
- package/dist/esm/jsonpatch.js.map +0 -1
- package/dist/esm/mapping.d.ts +0 -8
- package/dist/esm/mapping.js +0 -32
- package/dist/esm/mapping.js.map +0 -1
- package/dist/esm/msgpack.js +0 -171
- package/dist/esm/msgpack.js.map +0 -1
- package/dist/esm/pagination.d.ts +0 -23
- package/dist/esm/pagination.js +0 -2
- package/dist/esm/pagination.js.map +0 -1
- package/dist/esm/problem-details.d.ts +0 -7
- package/dist/esm/problem-details.js +0 -2
- package/dist/esm/problem-details.js.map +0 -1
- package/dist/esm/query-string.d.ts +0 -6
- package/dist/esm/query-string.js +0 -66
- package/dist/esm/query-string.js.map +0 -1
- package/dist/esm/query-string.spec.d.ts +0 -1
- package/dist/esm/query-string.spec.js +0 -50
- package/dist/esm/query-string.spec.js.map +0 -1
- package/dist/esm/status-codes.d.ts +0 -67
- package/dist/esm/status-codes.js +0 -68
- package/dist/esm/status-codes.js.map +0 -1
- package/dist/esm/timeout-error.d.ts +0 -3
- package/dist/esm/timeout-error.js +0 -29
- package/dist/esm/timeout-error.js.map +0 -1
- package/index.d.ts +0 -1
- package/tsconfig.cjs.json +0 -9
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@utiliread/http/json",
|
|
3
|
+
"lockfileVersion": 2,
|
|
4
|
+
"requires": true,
|
|
5
|
+
"packages": {
|
|
6
|
+
"": {
|
|
7
|
+
"name": "@utiliread/http/json",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@utiliread/http": "../"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@utiliread/json": "^1.0.2"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@utiliread/json": "^1.0.2"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"..": {
|
|
19
|
+
"name": "@utiliread/http",
|
|
20
|
+
"version": "1.16.2",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@parcel/packager-ts": "^2.5.0",
|
|
23
|
+
"@parcel/transformer-typescript-types": "^2.5.0",
|
|
24
|
+
"@types/chai": "^4.2.16",
|
|
25
|
+
"@types/luxon": "^2.0.5",
|
|
26
|
+
"@types/mocha": "^9.0.0",
|
|
27
|
+
"@utiliread/json": "^1.0.2",
|
|
28
|
+
"@utiliread/jsonpatch": "^1.0.0",
|
|
29
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
30
|
+
"chai": "^4.3.4",
|
|
31
|
+
"karma": "^6.3.8",
|
|
32
|
+
"karma-chai": "^0.1.0",
|
|
33
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
34
|
+
"karma-mocha": "^2.0.1",
|
|
35
|
+
"karma-typescript": "^5.5.1",
|
|
36
|
+
"luxon": "^2.1.0",
|
|
37
|
+
"mocha": "^9.1.3",
|
|
38
|
+
"parcel": "^2.5.0",
|
|
39
|
+
"replace-in-file": "^6.3.2",
|
|
40
|
+
"rimraf": "^3.0.2",
|
|
41
|
+
"typescript": "^4.2.4"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@utiliread/json": "^1.0.2",
|
|
45
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
46
|
+
"luxon": "^2.1.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"@utiliread/json": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"@utiliread/jsonpatch": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@utiliread/msgpack": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"node_modules/@utiliread/http": {
|
|
61
|
+
"resolved": "..",
|
|
62
|
+
"link": true
|
|
63
|
+
},
|
|
64
|
+
"node_modules/@utiliread/json": {
|
|
65
|
+
"version": "1.1.0",
|
|
66
|
+
"resolved": "https://registry.npmjs.org/@utiliread/json/-/json-1.1.0.tgz",
|
|
67
|
+
"integrity": "sha512-+7Ze03PqzIfRfdClh3UbH13UHrEUt58+Aa561vRKo0WdaIYrsE1XSBVo8+dmwDSLo9XqkgqykUIG/qP69dmtnw==",
|
|
68
|
+
"dev": true,
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"base64-arraybuffer": "^1.0.1"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"luxon": "^2.1.0"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"node_modules/base64-arraybuffer": {
|
|
77
|
+
"version": "1.0.2",
|
|
78
|
+
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
|
|
79
|
+
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
|
|
80
|
+
"dev": true,
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">= 0.6.0"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"node_modules/luxon": {
|
|
86
|
+
"version": "2.4.0",
|
|
87
|
+
"resolved": "https://registry.npmjs.org/luxon/-/luxon-2.4.0.tgz",
|
|
88
|
+
"integrity": "sha512-w+NAwWOUL5hO0SgwOHsMBAmZ15SoknmQXhSO0hIbJCAmPKSsGeK8MlmhYh2w6Iib38IxN2M+/ooXWLbeis7GuA==",
|
|
89
|
+
"dev": true,
|
|
90
|
+
"peer": true,
|
|
91
|
+
"engines": {
|
|
92
|
+
"node": ">=12"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"dependencies": {
|
|
97
|
+
"@utiliread/http": {
|
|
98
|
+
"version": "file:..",
|
|
99
|
+
"requires": {
|
|
100
|
+
"@parcel/packager-ts": "^2.5.0",
|
|
101
|
+
"@parcel/transformer-typescript-types": "^2.5.0",
|
|
102
|
+
"@types/chai": "^4.2.16",
|
|
103
|
+
"@types/luxon": "^2.0.5",
|
|
104
|
+
"@types/mocha": "^9.0.0",
|
|
105
|
+
"@utiliread/json": "^1.0.2",
|
|
106
|
+
"@utiliread/jsonpatch": "^1.0.0",
|
|
107
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
108
|
+
"chai": "^4.3.4",
|
|
109
|
+
"karma": "^6.3.8",
|
|
110
|
+
"karma-chai": "^0.1.0",
|
|
111
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
112
|
+
"karma-mocha": "^2.0.1",
|
|
113
|
+
"karma-typescript": "^5.5.1",
|
|
114
|
+
"luxon": "^2.1.0",
|
|
115
|
+
"mocha": "^9.1.3",
|
|
116
|
+
"parcel": "^2.5.0",
|
|
117
|
+
"replace-in-file": "^6.3.2",
|
|
118
|
+
"rimraf": "^3.0.2",
|
|
119
|
+
"typescript": "^4.2.4"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"@utiliread/json": {
|
|
123
|
+
"version": "1.1.0",
|
|
124
|
+
"resolved": "https://registry.npmjs.org/@utiliread/json/-/json-1.1.0.tgz",
|
|
125
|
+
"integrity": "sha512-+7Ze03PqzIfRfdClh3UbH13UHrEUt58+Aa561vRKo0WdaIYrsE1XSBVo8+dmwDSLo9XqkgqykUIG/qP69dmtnw==",
|
|
126
|
+
"dev": true,
|
|
127
|
+
"requires": {
|
|
128
|
+
"base64-arraybuffer": "^1.0.1"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"base64-arraybuffer": {
|
|
132
|
+
"version": "1.0.2",
|
|
133
|
+
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
|
|
134
|
+
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
|
|
135
|
+
"dev": true
|
|
136
|
+
},
|
|
137
|
+
"luxon": {
|
|
138
|
+
"version": "2.4.0",
|
|
139
|
+
"resolved": "https://registry.npmjs.org/luxon/-/luxon-2.4.0.tgz",
|
|
140
|
+
"integrity": "sha512-w+NAwWOUL5hO0SgwOHsMBAmZ15SoknmQXhSO0hIbJCAmPKSsGeK8MlmhYh2w6Iib38IxN2M+/ooXWLbeis7GuA==",
|
|
141
|
+
"dev": true,
|
|
142
|
+
"peer": true
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -1,117 +1,123 @@
|
|
|
1
|
-
import { HttpBuilder, HttpBuilderOfT } from "
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
import { HttpBuilder, HttpBuilderOfT, TypeOrMapper } from "@utiliread/http";
|
|
2
|
+
import type {
|
|
3
|
+
InfinitePaginationResult,
|
|
4
|
+
PaginationResult,
|
|
5
|
+
} from "../../../src/pagination";
|
|
6
|
+
import { deserialize, serialize } from "@utiliread/json";
|
|
7
|
+
import { getMapper, getNullableMapper } from "../../../src/mapping";
|
|
8
|
+
|
|
9
|
+
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
|
10
|
+
declare module "@utiliread/http" {
|
|
11
|
+
interface HttpBuilder {
|
|
12
|
+
withJson(content: any): this;
|
|
13
|
+
|
|
14
|
+
expectJson<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;
|
|
15
|
+
expectJsonArray<T>(typeOrMapper: TypeOrMapper<T>): HttpBuilderOfT<T[]>;
|
|
16
|
+
expectJsonNullableArray<T>(
|
|
17
|
+
typeOrMapper: TypeOrMapper<T>
|
|
18
|
+
): HttpBuilderOfT<(T | null)[]>;
|
|
19
|
+
expectJsonPaginationResult<T>(
|
|
20
|
+
typeOrMapper: TypeOrMapper<T>
|
|
21
|
+
): HttpBuilderOfT<PaginationResult<T>>;
|
|
22
|
+
expectJsonInfinitePaginationResult<T>(
|
|
23
|
+
typeOrMapper: TypeOrMapper<T>
|
|
24
|
+
): HttpBuilderOfT<InfinitePaginationResult<T>>;
|
|
25
|
+
}
|
|
26
|
+
interface HttpBuilderOfT<T> {
|
|
27
|
+
withJson(content: any): this;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
HttpBuilder.prototype.withJson = function (this: HttpBuilder, content: any) {
|
|
32
|
+
this.message.content = serialize(content);
|
|
33
|
+
this.message.contentType = "application/json";
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
HttpBuilderOfT.prototype.withJson = function <T>(
|
|
38
|
+
this: HttpBuilderOfT<T>,
|
|
39
|
+
content: any
|
|
40
|
+
) {
|
|
41
|
+
this.message.content = serialize(content);
|
|
42
|
+
this.message.contentType = "application/json";
|
|
43
|
+
return this;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
HttpBuilder.prototype.expectJson = function <T>(
|
|
47
|
+
this: HttpBuilder,
|
|
48
|
+
typeOrMapper?: TypeOrMapper<T>
|
|
49
|
+
) {
|
|
50
|
+
this.message.headers.set("Accept", "application/json");
|
|
51
|
+
return this.useHandler((response) => {
|
|
52
|
+
return response.rawResponse
|
|
53
|
+
.json()
|
|
54
|
+
.then((x) => getMapper(deserialize, typeOrMapper)(x));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
HttpBuilder.prototype.expectJsonArray = function <T>(
|
|
59
|
+
this: HttpBuilder,
|
|
60
|
+
typeOrMapper: TypeOrMapper<T>
|
|
61
|
+
) {
|
|
62
|
+
this.message.headers.set("Accept", "application/json");
|
|
63
|
+
return this.useHandler((response) => {
|
|
64
|
+
return response.rawResponse.json().then((x: any[]) => {
|
|
65
|
+
const itemFactory = getMapper(deserialize, typeOrMapper);
|
|
66
|
+
return x.map(itemFactory);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
HttpBuilder.prototype.expectJsonNullableArray = function <T>(
|
|
72
|
+
this: HttpBuilder,
|
|
73
|
+
typeOrMapper: TypeOrMapper<T>
|
|
74
|
+
): HttpBuilderOfT<(T | null)[]> {
|
|
75
|
+
this.message.headers.set("Accept", "application/json");
|
|
76
|
+
return this.useHandler((response) => {
|
|
77
|
+
return response.rawResponse.json().then((x: any[]) => {
|
|
78
|
+
const itemFactory = getNullableMapper(deserialize, typeOrMapper);
|
|
79
|
+
return x.map(itemFactory);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
HttpBuilder.prototype.expectJsonPaginationResult = function <T>(
|
|
85
|
+
this: HttpBuilder,
|
|
86
|
+
typeOrMapper: TypeOrMapper<T>
|
|
87
|
+
) {
|
|
88
|
+
this.message.headers.set("Accept", "application/json");
|
|
89
|
+
return this.useHandler((response) => {
|
|
90
|
+
return response.rawResponse.json().then((x: PaginationResult<any>) => {
|
|
91
|
+
const itemFactory = getMapper(deserialize, typeOrMapper);
|
|
92
|
+
return {
|
|
93
|
+
meta: {
|
|
94
|
+
pageCount: x.meta.pageCount,
|
|
95
|
+
pageSize: x.meta.pageSize,
|
|
96
|
+
totalItems: x.meta.totalItems,
|
|
97
|
+
},
|
|
98
|
+
data: x.data.map(itemFactory),
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
HttpBuilder.prototype.expectJsonInfinitePaginationResult = function <T>(
|
|
105
|
+
this: HttpBuilder,
|
|
106
|
+
typeOrMapper: TypeOrMapper<T>
|
|
107
|
+
) {
|
|
108
|
+
this.message.headers.set("Accept", "application/json");
|
|
109
|
+
return this.useHandler((response) => {
|
|
110
|
+
return response.rawResponse
|
|
111
|
+
.json()
|
|
112
|
+
.then((x: InfinitePaginationResult<any>) => {
|
|
113
|
+
const itemFactory = getMapper(deserialize, typeOrMapper);
|
|
114
|
+
return {
|
|
115
|
+
meta: {
|
|
116
|
+
pageSize: x.meta.pageSize,
|
|
117
|
+
continuationToken: x.meta.continuationToken,
|
|
118
|
+
},
|
|
119
|
+
data: x.data.map(itemFactory),
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@utiliread/http/jsonpatch",
|
|
3
|
+
"lockfileVersion": 2,
|
|
4
|
+
"requires": true,
|
|
5
|
+
"packages": {
|
|
6
|
+
"": {
|
|
7
|
+
"name": "@utiliread/http/jsonpatch",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@utiliread/http": "../../"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@utiliread/jsonpatch": "^1.0.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@utiliread/jsonpatch": "^1.0.0"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"..": {
|
|
19
|
+
"extraneous": true
|
|
20
|
+
},
|
|
21
|
+
"../..": {
|
|
22
|
+
"version": "1.16.2",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@parcel/packager-ts": "^2.5.0",
|
|
25
|
+
"@parcel/transformer-typescript-types": "^2.5.0",
|
|
26
|
+
"@types/chai": "^4.2.16",
|
|
27
|
+
"@types/luxon": "^2.0.5",
|
|
28
|
+
"@types/mocha": "^9.0.0",
|
|
29
|
+
"@utiliread/json": "^1.0.2",
|
|
30
|
+
"@utiliread/jsonpatch": "^1.0.0",
|
|
31
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
32
|
+
"chai": "^4.3.4",
|
|
33
|
+
"karma": "^6.3.8",
|
|
34
|
+
"karma-chai": "^0.1.0",
|
|
35
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
36
|
+
"karma-mocha": "^2.0.1",
|
|
37
|
+
"karma-typescript": "^5.5.1",
|
|
38
|
+
"luxon": "^2.1.0",
|
|
39
|
+
"mocha": "^9.1.3",
|
|
40
|
+
"parcel": "^2.5.0",
|
|
41
|
+
"replace-in-file": "^6.3.2",
|
|
42
|
+
"rimraf": "^3.0.2",
|
|
43
|
+
"typescript": "^4.2.4"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@utiliread/json": "^1.0.2",
|
|
47
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
48
|
+
"luxon": "^2.1.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@utiliread/json": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"@utiliread/jsonpatch": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"@utiliread/msgpack": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"node_modules/@utiliread/http": {
|
|
63
|
+
"resolved": "../..",
|
|
64
|
+
"link": true
|
|
65
|
+
},
|
|
66
|
+
"node_modules/@utiliread/jsonpatch": {
|
|
67
|
+
"version": "1.0.2",
|
|
68
|
+
"resolved": "https://registry.npmjs.org/@utiliread/jsonpatch/-/jsonpatch-1.0.2.tgz",
|
|
69
|
+
"integrity": "sha512-LqadgITwXuuAhVeTOR5y2/4sKMxmVc4Owto6zwTlAgDZXifsOJ/0v+dcl/6qvbFNM7Bq5E4TkBP+6CPo1W4I8g==",
|
|
70
|
+
"dev": true,
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"jiff": "^0.7.3"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"node_modules/jiff": {
|
|
76
|
+
"version": "0.7.3",
|
|
77
|
+
"resolved": "https://registry.npmjs.org/jiff/-/jiff-0.7.3.tgz",
|
|
78
|
+
"integrity": "sha1-QttdkUDxgEOZu1AXRwValDT0D0Y=",
|
|
79
|
+
"dev": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@utiliread/http": {
|
|
84
|
+
"version": "file:../..",
|
|
85
|
+
"requires": {
|
|
86
|
+
"@parcel/packager-ts": "^2.5.0",
|
|
87
|
+
"@parcel/transformer-typescript-types": "^2.5.0",
|
|
88
|
+
"@types/chai": "^4.2.16",
|
|
89
|
+
"@types/luxon": "^2.0.5",
|
|
90
|
+
"@types/mocha": "^9.0.0",
|
|
91
|
+
"@utiliread/json": "^1.0.2",
|
|
92
|
+
"@utiliread/jsonpatch": "^1.0.0",
|
|
93
|
+
"@utiliread/msgpack": "^1.0.1",
|
|
94
|
+
"chai": "^4.3.4",
|
|
95
|
+
"karma": "^6.3.8",
|
|
96
|
+
"karma-chai": "^0.1.0",
|
|
97
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
98
|
+
"karma-mocha": "^2.0.1",
|
|
99
|
+
"karma-typescript": "^5.5.1",
|
|
100
|
+
"luxon": "^2.1.0",
|
|
101
|
+
"mocha": "^9.1.3",
|
|
102
|
+
"parcel": "^2.5.0",
|
|
103
|
+
"replace-in-file": "^6.3.2",
|
|
104
|
+
"rimraf": "^3.0.2",
|
|
105
|
+
"typescript": "^4.2.4"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"@utiliread/jsonpatch": {
|
|
109
|
+
"version": "1.0.2",
|
|
110
|
+
"resolved": "https://registry.npmjs.org/@utiliread/jsonpatch/-/jsonpatch-1.0.2.tgz",
|
|
111
|
+
"integrity": "sha512-LqadgITwXuuAhVeTOR5y2/4sKMxmVc4Owto6zwTlAgDZXifsOJ/0v+dcl/6qvbFNM7Bq5E4TkBP+6CPo1W4I8g==",
|
|
112
|
+
"dev": true,
|
|
113
|
+
"requires": {
|
|
114
|
+
"jiff": "^0.7.3"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"jiff": {
|
|
118
|
+
"version": "0.7.3",
|
|
119
|
+
"resolved": "https://registry.npmjs.org/jiff/-/jiff-0.7.3.tgz",
|
|
120
|
+
"integrity": "sha1-QttdkUDxgEOZu1AXRwValDT0D0Y=",
|
|
121
|
+
"dev": true
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@utiliread/http/jsonpatch",
|
|
3
|
+
"source": "./src/index.ts",
|
|
4
|
+
"main": "../../dist/jsonpatch.js",
|
|
5
|
+
"module": "../../dist/jsonpatch.mjs",
|
|
6
|
+
"types": "../../dist/jsonpatch.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@utiliread/http": "../../",
|
|
9
|
+
"@utiliread/json": "^1.0.2",
|
|
10
|
+
"@utiliread/jsonpatch": "^1.0.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import { HttpBuilder, HttpBuilderOfT } from "
|
|
2
|
-
import { serialize } from "@utiliread/json";
|
|
3
|
-
import type { Operation } from "@utiliread/jsonpatch";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.message.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.message.
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { HttpBuilder, HttpBuilderOfT } from "@utiliread/http";
|
|
2
|
+
import { serialize } from "@utiliread/json";
|
|
3
|
+
import type { Operation } from "@utiliread/jsonpatch";
|
|
4
|
+
|
|
5
|
+
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
|
6
|
+
declare module "@utiliread/http" {
|
|
7
|
+
interface HttpBuilder {
|
|
8
|
+
withJsonPatch(operations: Operation[]): this;
|
|
9
|
+
}
|
|
10
|
+
interface HttpBuilderOfT<T> {
|
|
11
|
+
withJsonPatch(operations: Operation[]): this;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
HttpBuilder.prototype.withJsonPatch = function (
|
|
16
|
+
this: HttpBuilder,
|
|
17
|
+
operations: Operation[]
|
|
18
|
+
) {
|
|
19
|
+
this.message.content = serialize(operations);
|
|
20
|
+
this.message.contentType = "application/json-patch+json";
|
|
21
|
+
return this;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
HttpBuilderOfT.prototype.withJsonPatch = function <T>(
|
|
25
|
+
this: HttpBuilderOfT<T>,
|
|
26
|
+
operations: Operation[]
|
|
27
|
+
) {
|
|
28
|
+
this.message.content = serialize(operations);
|
|
29
|
+
this.message.contentType = "application/json-patch+json";
|
|
30
|
+
return this;
|
|
31
|
+
};
|