@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.
Files changed (139) hide show
  1. package/dist/index.d.ts +227 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +534 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +507 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/{esm/json.d.ts → json.d.ts} +15 -17
  8. package/dist/json.d.ts.map +1 -0
  9. package/dist/json.js +100 -0
  10. package/dist/json.js.map +1 -0
  11. package/dist/json.mjs +100 -0
  12. package/dist/json.mjs.map +1 -0
  13. package/dist/{esm/jsonpatch.d.ts → jsonpatch.d.ts} +10 -9
  14. package/dist/jsonpatch.d.ts.map +1 -0
  15. package/dist/jsonpatch.js +18 -0
  16. package/dist/jsonpatch.js.map +1 -0
  17. package/dist/jsonpatch.mjs +18 -0
  18. package/dist/jsonpatch.mjs.map +1 -0
  19. package/dist/{esm/msgpack.d.ts → msgpack.d.ts} +9 -10
  20. package/dist/msgpack.d.ts.map +1 -0
  21. package/dist/msgpack.js +62 -0
  22. package/dist/msgpack.js.map +1 -0
  23. package/dist/msgpack.mjs +62 -0
  24. package/dist/msgpack.mjs.map +1 -0
  25. package/json.d.ts +1 -1
  26. package/jsonpatch.d.ts +1 -1
  27. package/msgpack.d.ts +1 -1
  28. package/package.json +28 -20
  29. package/plugins/json/package-lock.json +145 -0
  30. package/plugins/json/package.json +11 -0
  31. package/{src/json.ts → plugins/json/src/index.ts} +123 -117
  32. package/plugins/json/tsconfig.json +3 -0
  33. package/plugins/jsonpatch/package-lock.json +124 -0
  34. package/plugins/jsonpatch/package.json +13 -0
  35. package/{src/jsonpatch.ts → plugins/jsonpatch/src/index.ts} +31 -30
  36. package/plugins/jsonpatch/tsconfig.json +3 -0
  37. package/plugins/msgpack/package-lock.json +134 -0
  38. package/plugins/msgpack/package.json +12 -0
  39. package/{src/msgpack.ts → plugins/msgpack/src/index.ts} +60 -64
  40. package/plugins/msgpack/tsconfig.json +3 -0
  41. package/src/http-builder.ts +1 -1
  42. package/src/http.ts +132 -116
  43. package/src/index.ts +8 -6
  44. package/src/mapping.ts +1 -0
  45. package/tsconfig.json +8 -17
  46. package/dist/cjs/event-aggregator.js +0 -94
  47. package/dist/cjs/event-aggregator.js.map +0 -1
  48. package/dist/cjs/events.js +0 -23
  49. package/dist/cjs/events.js.map +0 -1
  50. package/dist/cjs/helpers.js +0 -16
  51. package/dist/cjs/helpers.js.map +0 -1
  52. package/dist/cjs/http-builder.js +0 -284
  53. package/dist/cjs/http-builder.js.map +0 -1
  54. package/dist/cjs/http-error.js +0 -53
  55. package/dist/cjs/http-error.js.map +0 -1
  56. package/dist/cjs/http-response.js +0 -102
  57. package/dist/cjs/http-response.js.map +0 -1
  58. package/dist/cjs/http.js +0 -97
  59. package/dist/cjs/http.js.map +0 -1
  60. package/dist/cjs/http.spec.js +0 -144
  61. package/dist/cjs/http.spec.js.map +0 -1
  62. package/dist/cjs/index.js +0 -37
  63. package/dist/cjs/index.js.map +0 -1
  64. package/dist/cjs/json.js +0 -71
  65. package/dist/cjs/json.js.map +0 -1
  66. package/dist/cjs/jsonpatch.js +0 -15
  67. package/dist/cjs/jsonpatch.js.map +0 -1
  68. package/dist/cjs/mapping.js +0 -37
  69. package/dist/cjs/mapping.js.map +0 -1
  70. package/dist/cjs/msgpack.js +0 -173
  71. package/dist/cjs/msgpack.js.map +0 -1
  72. package/dist/cjs/pagination.js +0 -3
  73. package/dist/cjs/pagination.js.map +0 -1
  74. package/dist/cjs/problem-details.js +0 -3
  75. package/dist/cjs/problem-details.js.map +0 -1
  76. package/dist/cjs/query-string.js +0 -69
  77. package/dist/cjs/query-string.js.map +0 -1
  78. package/dist/cjs/query-string.spec.js +0 -52
  79. package/dist/cjs/query-string.spec.js.map +0 -1
  80. package/dist/cjs/status-codes.js +0 -71
  81. package/dist/cjs/status-codes.js.map +0 -1
  82. package/dist/cjs/timeout-error.js +0 -32
  83. package/dist/cjs/timeout-error.js.map +0 -1
  84. package/dist/esm/event-aggregator.d.ts +0 -11
  85. package/dist/esm/event-aggregator.js +0 -91
  86. package/dist/esm/event-aggregator.js.map +0 -1
  87. package/dist/esm/events.d.ts +0 -11
  88. package/dist/esm/events.js +0 -19
  89. package/dist/esm/events.js.map +0 -1
  90. package/dist/esm/helpers.d.ts +0 -5
  91. package/dist/esm/helpers.js +0 -10
  92. package/dist/esm/helpers.js.map +0 -1
  93. package/dist/esm/http-builder.d.ts +0 -60
  94. package/dist/esm/http-builder.js +0 -281
  95. package/dist/esm/http-builder.js.map +0 -1
  96. package/dist/esm/http-error.d.ts +0 -10
  97. package/dist/esm/http-error.js +0 -50
  98. package/dist/esm/http-error.js.map +0 -1
  99. package/dist/esm/http-response.d.ts +0 -18
  100. package/dist/esm/http-response.js +0 -99
  101. package/dist/esm/http-response.js.map +0 -1
  102. package/dist/esm/http.d.ts +0 -32
  103. package/dist/esm/http.js +0 -94
  104. package/dist/esm/http.js.map +0 -1
  105. package/dist/esm/http.spec.d.ts +0 -1
  106. package/dist/esm/http.spec.js +0 -142
  107. package/dist/esm/http.spec.js.map +0 -1
  108. package/dist/esm/index.d.ts +0 -13
  109. package/dist/esm/index.js +0 -10
  110. package/dist/esm/index.js.map +0 -1
  111. package/dist/esm/json.js +0 -69
  112. package/dist/esm/json.js.map +0 -1
  113. package/dist/esm/jsonpatch.js +0 -13
  114. package/dist/esm/jsonpatch.js.map +0 -1
  115. package/dist/esm/mapping.d.ts +0 -8
  116. package/dist/esm/mapping.js +0 -32
  117. package/dist/esm/mapping.js.map +0 -1
  118. package/dist/esm/msgpack.js +0 -171
  119. package/dist/esm/msgpack.js.map +0 -1
  120. package/dist/esm/pagination.d.ts +0 -23
  121. package/dist/esm/pagination.js +0 -2
  122. package/dist/esm/pagination.js.map +0 -1
  123. package/dist/esm/problem-details.d.ts +0 -7
  124. package/dist/esm/problem-details.js +0 -2
  125. package/dist/esm/problem-details.js.map +0 -1
  126. package/dist/esm/query-string.d.ts +0 -6
  127. package/dist/esm/query-string.js +0 -66
  128. package/dist/esm/query-string.js.map +0 -1
  129. package/dist/esm/query-string.spec.d.ts +0 -1
  130. package/dist/esm/query-string.spec.js +0 -50
  131. package/dist/esm/query-string.spec.js.map +0 -1
  132. package/dist/esm/status-codes.d.ts +0 -67
  133. package/dist/esm/status-codes.js +0 -68
  134. package/dist/esm/status-codes.js.map +0 -1
  135. package/dist/esm/timeout-error.d.ts +0 -3
  136. package/dist/esm/timeout-error.js +0 -29
  137. package/dist/esm/timeout-error.js.map +0 -1
  138. package/index.d.ts +0 -1
  139. 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
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@utiliread/http/json",
3
+ "source": "./src/index.ts",
4
+ "main": "../../dist/json.js",
5
+ "module": "../../dist/json.mjs",
6
+ "types": "../../dist/json.d.ts",
7
+ "dependencies": {
8
+ "@utiliread/http": "../../",
9
+ "@utiliread/json": "^1.0.2"
10
+ }
11
+ }
@@ -1,117 +1,123 @@
1
- import { HttpBuilder, HttpBuilderOfT } from "./http-builder";
2
- import { InfinitePaginationResult, PaginationResult } from "./pagination";
3
- import { deserialize, serialize } from "@utiliread/json";
4
- import { getMapper, getNullableMapper, Mapper, Type } from "./mapping";
5
-
6
- type TypeOrMapper<T> = Type<T> | Mapper<T>;
7
-
8
- declare module "./http-builder" {
9
- interface HttpBuilder {
10
- withJson(content: any): this;
11
-
12
- expectJson<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;
13
- expectJsonArray<T>(typeOrMapper: TypeOrMapper<T>): HttpBuilderOfT<T[]>;
14
- expectJsonNullableArray<T>(
15
- typeOrMapper: TypeOrMapper<T>
16
- ): HttpBuilderOfT<(T | null)[]>;
17
- expectJsonPaginationResult<T>(
18
- typeOrMapper: TypeOrMapper<T>
19
- ): HttpBuilderOfT<PaginationResult<T>>;
20
- expectJsonInfinitePaginationResult<T>(
21
- typeOrMapper: TypeOrMapper<T>
22
- ): HttpBuilderOfT<InfinitePaginationResult<T>>;
23
- }
24
- interface HttpBuilderOfT<T> {
25
- withJson(content: any): this;
26
- }
27
- }
28
-
29
- HttpBuilder.prototype.withJson = function (this: HttpBuilder, content: any) {
30
- this.message.content = serialize(content);
31
- this.message.contentType = "application/json";
32
- return this;
33
- };
34
-
35
- HttpBuilderOfT.prototype.withJson = function <T>(
36
- this: HttpBuilderOfT<T>,
37
- content: any
38
- ) {
39
- this.message.content = serialize(content);
40
- this.message.contentType = "application/json";
41
- return this;
42
- };
43
-
44
- HttpBuilder.prototype.expectJson = function <T>(
45
- this: HttpBuilder,
46
- typeOrMapper?: TypeOrMapper<T>
47
- ) {
48
- this.message.headers.set("Accept", "application/json");
49
- return this.useHandler((response) => {
50
- return response.rawResponse.json().then((x) => getMapper(deserialize, typeOrMapper)(x));
51
- });
52
- };
53
-
54
- HttpBuilder.prototype.expectJsonArray = function <T>(
55
- this: HttpBuilder,
56
- typeOrMapper: TypeOrMapper<T>
57
- ) {
58
- this.message.headers.set("Accept", "application/json");
59
- return this.useHandler((response) => {
60
- return response.rawResponse.json().then((x: any[]) => {
61
- const itemFactory = getMapper(deserialize, typeOrMapper);
62
- return x.map(itemFactory);
63
- });
64
- });
65
- };
66
-
67
- HttpBuilder.prototype.expectJsonNullableArray = function <T>(
68
- this: HttpBuilder,
69
- typeOrMapper: TypeOrMapper<T>
70
- ): HttpBuilderOfT<(T | null)[]> {
71
- this.message.headers.set("Accept", "application/json");
72
- return this.useHandler((response) => {
73
- return response.rawResponse.json().then((x: any[]) => {
74
- const itemFactory = getNullableMapper(deserialize, typeOrMapper);
75
- return x.map(itemFactory);
76
- });
77
- });
78
- };
79
-
80
- HttpBuilder.prototype.expectJsonPaginationResult = function <T>(
81
- this: HttpBuilder,
82
- typeOrMapper: TypeOrMapper<T>
83
- ) {
84
- this.message.headers.set("Accept", "application/json");
85
- return this.useHandler((response) => {
86
- return response.rawResponse.json().then((x: PaginationResult<any>) => {
87
- const itemFactory = getMapper(deserialize, typeOrMapper);
88
- return {
89
- meta: {
90
- pageCount: x.meta.pageCount,
91
- pageSize: x.meta.pageSize,
92
- totalItems: x.meta.totalItems,
93
- },
94
- data: x.data.map(itemFactory),
95
- };
96
- });
97
- });
98
- };
99
-
100
- HttpBuilder.prototype.expectJsonInfinitePaginationResult = function <T>(
101
- this: HttpBuilder,
102
- typeOrMapper: TypeOrMapper<T>
103
- ) {
104
- this.message.headers.set("Accept", "application/json");
105
- return this.useHandler((response) => {
106
- return response.rawResponse.json().then((x: InfinitePaginationResult<any>) => {
107
- const itemFactory = getMapper(deserialize, typeOrMapper);
108
- return {
109
- meta: {
110
- pageSize: x.meta.pageSize,
111
- continuationToken: x.meta.continuationToken,
112
- },
113
- data: x.data.map(itemFactory),
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,3 @@
1
+ {
2
+ "extends": "../../tsconfig.json"
3
+ }
@@ -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 "./http-builder";
2
- import { serialize } from "@utiliread/json";
3
- import type { Operation } from "@utiliread/jsonpatch";
4
-
5
- declare module "./http-builder" {
6
- interface HttpBuilder {
7
- withJsonPatch(operations: Operation[]): this;
8
- }
9
- interface HttpBuilderOfT<T> {
10
- withJsonPatch(operations: Operation[]): this;
11
- }
12
- }
13
-
14
- HttpBuilder.prototype.withJsonPatch = function (
15
- this: HttpBuilder,
16
- operations: Operation[]
17
- ) {
18
- this.message.content = serialize(operations);
19
- this.message.contentType = "application/json-patch+json";
20
- return this;
21
- };
22
-
23
- HttpBuilderOfT.prototype.withJsonPatch = function <T>(
24
- this: HttpBuilderOfT<T>,
25
- operations: Operation[]
26
- ) {
27
- this.message.content = serialize(operations);
28
- this.message.contentType = "application/json-patch+json";
29
- return this;
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
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.json"
3
+ }