@utiliread/http 1.17.8 → 1.19.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 (160) hide show
  1. package/.vscode/settings.json +2 -2
  2. package/dist/index.d.ts +231 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +564 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +535 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/json.d.ts +15 -0
  9. package/dist/json.d.ts.map +1 -0
  10. package/dist/json.js +73 -0
  11. package/dist/json.js.map +1 -0
  12. package/dist/json.mjs +73 -0
  13. package/dist/json.mjs.map +1 -0
  14. package/dist/{esm/jsonpatch/index.d.ts → jsonpatch.d.ts} +10 -9
  15. package/dist/jsonpatch.d.ts.map +1 -0
  16. package/dist/jsonpatch.js +18 -0
  17. package/dist/jsonpatch.js.map +1 -0
  18. package/dist/jsonpatch.mjs +18 -0
  19. package/dist/jsonpatch.mjs.map +1 -0
  20. package/dist/msgpack.d.ts +9 -0
  21. package/dist/msgpack.d.ts.map +1 -0
  22. package/dist/msgpack.js +35 -0
  23. package/dist/msgpack.js.map +1 -0
  24. package/dist/msgpack.mjs +35 -0
  25. package/dist/msgpack.mjs.map +1 -0
  26. package/json.d.ts +1 -1
  27. package/jsonpatch.d.ts +1 -1
  28. package/mapper.d.ts +1 -0
  29. package/msgpack.d.ts +1 -1
  30. package/package.json +40 -38
  31. package/plugins/json/node_modules/@utiliread/http/package.json +4 -0
  32. package/plugins/json/package.json +15 -0
  33. package/plugins/json/src/index.ts +128 -122
  34. package/plugins/json/tsconfig.json +1 -2
  35. package/plugins/jsonpatch/node_modules/@utiliread/http/package.json +4 -0
  36. package/plugins/jsonpatch/package.json +16 -0
  37. package/plugins/jsonpatch/src/index.ts +31 -31
  38. package/plugins/jsonpatch/tsconfig.json +1 -2
  39. package/plugins/msgpack/node_modules/@utiliread/http/package.json +4 -0
  40. package/plugins/msgpack/package.json +16 -0
  41. package/plugins/msgpack/src/index.ts +60 -60
  42. package/plugins/msgpack/tsconfig.json +1 -2
  43. package/src/event-aggregator.ts +21 -21
  44. package/src/events.ts +39 -39
  45. package/src/helpers.ts +6 -6
  46. package/src/http-builder.ts +252 -218
  47. package/src/http-error.ts +30 -23
  48. package/src/http-response.ts +1 -1
  49. package/src/http.spec.ts +1 -1
  50. package/src/http.ts +8 -5
  51. package/src/index.ts +1 -1
  52. package/src/mapper.ts +52 -0
  53. package/src/pagination.ts +16 -16
  54. package/src/problem-details.ts +6 -6
  55. package/src/query-string.spec.ts +59 -43
  56. package/src/query-string.ts +56 -58
  57. package/src/status-codes.ts +67 -67
  58. package/src/timeout-error.ts +7 -7
  59. package/tsconfig.cjs.json +1 -0
  60. package/tsconfig.json +1 -2
  61. package/web-test-runner.config.mjs +7 -0
  62. package/dist/cjs/event-aggregator.js +0 -30
  63. package/dist/cjs/event-aggregator.js.map +0 -1
  64. package/dist/cjs/events.js +0 -19
  65. package/dist/cjs/events.js.map +0 -1
  66. package/dist/cjs/helpers.js +0 -16
  67. package/dist/cjs/helpers.js.map +0 -1
  68. package/dist/cjs/http-builder.js +0 -192
  69. package/dist/cjs/http-builder.js.map +0 -1
  70. package/dist/cjs/http-error.js +0 -30
  71. package/dist/cjs/http-error.js.map +0 -1
  72. package/dist/cjs/http-response.js +0 -51
  73. package/dist/cjs/http-response.js.map +0 -1
  74. package/dist/cjs/http.js +0 -96
  75. package/dist/cjs/http.js.map +0 -1
  76. package/dist/cjs/http.spec.js +0 -69
  77. package/dist/cjs/http.spec.js.map +0 -1
  78. package/dist/cjs/index.js +0 -38
  79. package/dist/cjs/index.js.map +0 -1
  80. package/dist/cjs/json/index.js +0 -74
  81. package/dist/cjs/json/index.js.map +0 -1
  82. package/dist/cjs/jsonpatch/index.js +0 -15
  83. package/dist/cjs/jsonpatch/index.js.map +0 -1
  84. package/dist/cjs/mapping.js +0 -37
  85. package/dist/cjs/mapping.js.map +0 -1
  86. package/dist/cjs/msgpack/index.js +0 -35
  87. package/dist/cjs/msgpack/index.js.map +0 -1
  88. package/dist/cjs/pagination.js +0 -3
  89. package/dist/cjs/pagination.js.map +0 -1
  90. package/dist/cjs/problem-details.js +0 -3
  91. package/dist/cjs/problem-details.js.map +0 -1
  92. package/dist/cjs/query-string.js +0 -66
  93. package/dist/cjs/query-string.js.map +0 -1
  94. package/dist/cjs/query-string.spec.js +0 -52
  95. package/dist/cjs/query-string.spec.js.map +0 -1
  96. package/dist/cjs/status-codes.js +0 -71
  97. package/dist/cjs/status-codes.js.map +0 -1
  98. package/dist/cjs/timeout-error.js +0 -14
  99. package/dist/cjs/timeout-error.js.map +0 -1
  100. package/dist/esm/event-aggregator.d.ts +0 -11
  101. package/dist/esm/event-aggregator.js +0 -26
  102. package/dist/esm/event-aggregator.js.map +0 -1
  103. package/dist/esm/events.d.ts +0 -11
  104. package/dist/esm/events.js +0 -15
  105. package/dist/esm/events.js.map +0 -1
  106. package/dist/esm/helpers.d.ts +0 -5
  107. package/dist/esm/helpers.js +0 -10
  108. package/dist/esm/helpers.js.map +0 -1
  109. package/dist/esm/http-builder.d.ts +0 -60
  110. package/dist/esm/http-builder.js +0 -187
  111. package/dist/esm/http-builder.js.map +0 -1
  112. package/dist/esm/http-error.d.ts +0 -10
  113. package/dist/esm/http-error.js +0 -26
  114. package/dist/esm/http-error.js.map +0 -1
  115. package/dist/esm/http-response.d.ts +0 -18
  116. package/dist/esm/http-response.js +0 -46
  117. package/dist/esm/http-response.js.map +0 -1
  118. package/dist/esm/http.d.ts +0 -33
  119. package/dist/esm/http.js +0 -92
  120. package/dist/esm/http.js.map +0 -1
  121. package/dist/esm/http.spec.d.ts +0 -1
  122. package/dist/esm/http.spec.js +0 -67
  123. package/dist/esm/http.spec.js.map +0 -1
  124. package/dist/esm/index.d.ts +0 -15
  125. package/dist/esm/index.js +0 -11
  126. package/dist/esm/index.js.map +0 -1
  127. package/dist/esm/json/index.d.ts +0 -15
  128. package/dist/esm/json/index.js +0 -72
  129. package/dist/esm/json/index.js.map +0 -1
  130. package/dist/esm/jsonpatch/index.js +0 -13
  131. package/dist/esm/jsonpatch/index.js.map +0 -1
  132. package/dist/esm/mapping.d.ts +0 -9
  133. package/dist/esm/mapping.js +0 -32
  134. package/dist/esm/mapping.js.map +0 -1
  135. package/dist/esm/msgpack/index.d.ts +0 -8
  136. package/dist/esm/msgpack/index.js +0 -33
  137. package/dist/esm/msgpack/index.js.map +0 -1
  138. package/dist/esm/pagination.d.ts +0 -23
  139. package/dist/esm/pagination.js +0 -2
  140. package/dist/esm/pagination.js.map +0 -1
  141. package/dist/esm/problem-details.d.ts +0 -7
  142. package/dist/esm/problem-details.js +0 -2
  143. package/dist/esm/problem-details.js.map +0 -1
  144. package/dist/esm/query-string.d.ts +0 -6
  145. package/dist/esm/query-string.js +0 -62
  146. package/dist/esm/query-string.js.map +0 -1
  147. package/dist/esm/query-string.spec.d.ts +0 -1
  148. package/dist/esm/query-string.spec.js +0 -50
  149. package/dist/esm/query-string.spec.js.map +0 -1
  150. package/dist/esm/status-codes.d.ts +0 -67
  151. package/dist/esm/status-codes.js +0 -68
  152. package/dist/esm/status-codes.js.map +0 -1
  153. package/dist/esm/timeout-error.d.ts +0 -3
  154. package/dist/esm/timeout-error.js +0 -10
  155. package/dist/esm/timeout-error.js.map +0 -1
  156. package/karma.config.js +0 -29
  157. package/plugins/json/tsconfig.cjs.json +0 -8
  158. package/plugins/jsonpatch/tsconfig.cjs.json +0 -8
  159. package/plugins/msgpack/tsconfig.cjs.json +0 -8
  160. package/src/mapping.ts +0 -44
package/dist/json.js ADDED
@@ -0,0 +1,73 @@
1
+ var $hjeo4$utilireadhttp = require("@utiliread/http");
2
+ var $hjeo4$utilireadjson = require("@utiliread/json");
3
+
4
+
5
+
6
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.withJson = function(content) {
7
+ this.message.content = (0, $hjeo4$utilireadjson.serialize)(content);
8
+ this.message.contentType = "application/json";
9
+ return this;
10
+ };
11
+ (0, $hjeo4$utilireadhttp.HttpBuilderOfT).prototype.withJson = function(content) {
12
+ this.message.content = (0, $hjeo4$utilireadjson.serialize)(content);
13
+ this.message.contentType = "application/json";
14
+ return this;
15
+ };
16
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.expectJson = function(typeOrMapper) {
17
+ this.message.headers.set("Accept", "application/json");
18
+ return this.useHandler((response)=>{
19
+ return response.rawResponse.json().then((x)=>(0, $hjeo4$utilireadhttp.getMapper)((0, $hjeo4$utilireadjson.deserialize), typeOrMapper)(x));
20
+ });
21
+ };
22
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.expectJsonArray = function(typeOrMapper) {
23
+ this.message.headers.set("Accept", "application/json");
24
+ return this.useHandler((response)=>{
25
+ return response.rawResponse.json().then((x)=>{
26
+ const itemFactory = (0, $hjeo4$utilireadhttp.getMapper)((0, $hjeo4$utilireadjson.deserialize), typeOrMapper);
27
+ return x.map(itemFactory);
28
+ });
29
+ });
30
+ };
31
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.expectJsonNullableArray = function(typeOrMapper) {
32
+ this.message.headers.set("Accept", "application/json");
33
+ return this.useHandler((response)=>{
34
+ return response.rawResponse.json().then((x)=>{
35
+ const itemFactory = (0, $hjeo4$utilireadhttp.getNullableMapper)((0, $hjeo4$utilireadjson.deserialize), typeOrMapper);
36
+ return x.map(itemFactory);
37
+ });
38
+ });
39
+ };
40
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.expectJsonPaginationResult = function(typeOrMapper) {
41
+ this.message.headers.set("Accept", "application/json");
42
+ return this.useHandler((response)=>{
43
+ return response.rawResponse.json().then((x)=>{
44
+ const itemFactory = (0, $hjeo4$utilireadhttp.getMapper)((0, $hjeo4$utilireadjson.deserialize), typeOrMapper);
45
+ return {
46
+ meta: {
47
+ pageCount: x.meta.pageCount,
48
+ pageSize: x.meta.pageSize,
49
+ totalItems: x.meta.totalItems
50
+ },
51
+ data: x.data.map(itemFactory)
52
+ };
53
+ });
54
+ });
55
+ };
56
+ (0, $hjeo4$utilireadhttp.HttpBuilder).prototype.expectJsonInfinitePaginationResult = function(typeOrMapper) {
57
+ this.message.headers.set("Accept", "application/json");
58
+ return this.useHandler((response)=>{
59
+ return response.rawResponse.json().then((x)=>{
60
+ const itemFactory = (0, $hjeo4$utilireadhttp.getMapper)((0, $hjeo4$utilireadjson.deserialize), typeOrMapper);
61
+ return {
62
+ meta: {
63
+ pageSize: x.meta.pageSize,
64
+ continuationToken: x.meta.continuationToken
65
+ },
66
+ data: x.data.map(itemFactory)
67
+ };
68
+ });
69
+ });
70
+ };
71
+
72
+
73
+ //# sourceMappingURL=json.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"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","sources":["plugins/json/src/index.ts"],"sourcesContent":["import {\n HttpBuilder,\n HttpBuilderOfT,\n getMapper,\n getNullableMapper\n} from \"@utiliread/http\";\nimport type {\n InfinitePaginationResult,\n PaginationResult,\n TypeOrMapper\n} from \"@utiliread/http\";\nimport { deserialize, serialize } from \"@utiliread/json\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n withJson(content: any): this;\n\n expectJson<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;\n expectJsonArray<T>(typeOrMapper: TypeOrMapper<T>): HttpBuilderOfT<T[]>;\n expectJsonNullableArray<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<(T | null)[]>;\n expectJsonPaginationResult<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<PaginationResult<T>>;\n expectJsonInfinitePaginationResult<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<InfinitePaginationResult<T>>;\n }\n interface HttpBuilderOfT<T> {\n withJson(content: any): this;\n }\n}\n\nHttpBuilder.prototype.withJson = function (this: HttpBuilder, content: any) {\n this.message.content = serialize(content);\n this.message.contentType = \"application/json\";\n return this;\n};\n\nHttpBuilderOfT.prototype.withJson = function <T>(\n this: HttpBuilderOfT<T>,\n content: any,\n) {\n this.message.content = serialize(content);\n this.message.contentType = \"application/json\";\n return this;\n};\n\nHttpBuilder.prototype.expectJson = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse\n .json()\n .then((x) => getMapper(deserialize, typeOrMapper)(x));\n });\n};\n\nHttpBuilder.prototype.expectJsonArray = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: any[]) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return x.map(itemFactory);\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonNullableArray = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n): HttpBuilderOfT<(T | null)[]> {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: any[]) => {\n const itemFactory = getNullableMapper(deserialize, typeOrMapper);\n return x.map(itemFactory);\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonPaginationResult = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: PaginationResult<any>) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return {\n meta: {\n pageCount: x.meta.pageCount,\n pageSize: x.meta.pageSize,\n totalItems: x.meta.totalItems,\n },\n data: x.data.map(itemFactory),\n };\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonInfinitePaginationResult = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse\n .json()\n .then((x: InfinitePaginationResult<any>) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return {\n meta: {\n pageSize: x.meta.pageSize,\n continuationToken: x.meta.continuationToken,\n },\n data: x.data.map(itemFactory),\n };\n });\n });\n};\n"],"names":[],"version":3,"file":"json.js.map"}
package/dist/json.mjs ADDED
@@ -0,0 +1,73 @@
1
+ import {HttpBuilder as $017Lt$HttpBuilder, HttpBuilderOfT as $017Lt$HttpBuilderOfT, getMapper as $017Lt$getMapper, getNullableMapper as $017Lt$getNullableMapper} from "@utiliread/http";
2
+ import {serialize as $017Lt$serialize, deserialize as $017Lt$deserialize} from "@utiliread/json";
3
+
4
+
5
+
6
+ (0, $017Lt$HttpBuilder).prototype.withJson = function(content) {
7
+ this.message.content = (0, $017Lt$serialize)(content);
8
+ this.message.contentType = "application/json";
9
+ return this;
10
+ };
11
+ (0, $017Lt$HttpBuilderOfT).prototype.withJson = function(content) {
12
+ this.message.content = (0, $017Lt$serialize)(content);
13
+ this.message.contentType = "application/json";
14
+ return this;
15
+ };
16
+ (0, $017Lt$HttpBuilder).prototype.expectJson = function(typeOrMapper) {
17
+ this.message.headers.set("Accept", "application/json");
18
+ return this.useHandler((response)=>{
19
+ return response.rawResponse.json().then((x)=>(0, $017Lt$getMapper)((0, $017Lt$deserialize), typeOrMapper)(x));
20
+ });
21
+ };
22
+ (0, $017Lt$HttpBuilder).prototype.expectJsonArray = function(typeOrMapper) {
23
+ this.message.headers.set("Accept", "application/json");
24
+ return this.useHandler((response)=>{
25
+ return response.rawResponse.json().then((x)=>{
26
+ const itemFactory = (0, $017Lt$getMapper)((0, $017Lt$deserialize), typeOrMapper);
27
+ return x.map(itemFactory);
28
+ });
29
+ });
30
+ };
31
+ (0, $017Lt$HttpBuilder).prototype.expectJsonNullableArray = function(typeOrMapper) {
32
+ this.message.headers.set("Accept", "application/json");
33
+ return this.useHandler((response)=>{
34
+ return response.rawResponse.json().then((x)=>{
35
+ const itemFactory = (0, $017Lt$getNullableMapper)((0, $017Lt$deserialize), typeOrMapper);
36
+ return x.map(itemFactory);
37
+ });
38
+ });
39
+ };
40
+ (0, $017Lt$HttpBuilder).prototype.expectJsonPaginationResult = function(typeOrMapper) {
41
+ this.message.headers.set("Accept", "application/json");
42
+ return this.useHandler((response)=>{
43
+ return response.rawResponse.json().then((x)=>{
44
+ const itemFactory = (0, $017Lt$getMapper)((0, $017Lt$deserialize), typeOrMapper);
45
+ return {
46
+ meta: {
47
+ pageCount: x.meta.pageCount,
48
+ pageSize: x.meta.pageSize,
49
+ totalItems: x.meta.totalItems
50
+ },
51
+ data: x.data.map(itemFactory)
52
+ };
53
+ });
54
+ });
55
+ };
56
+ (0, $017Lt$HttpBuilder).prototype.expectJsonInfinitePaginationResult = function(typeOrMapper) {
57
+ this.message.headers.set("Accept", "application/json");
58
+ return this.useHandler((response)=>{
59
+ return response.rawResponse.json().then((x)=>{
60
+ const itemFactory = (0, $017Lt$getMapper)((0, $017Lt$deserialize), typeOrMapper);
61
+ return {
62
+ meta: {
63
+ pageSize: x.meta.pageSize,
64
+ continuationToken: x.meta.continuationToken
65
+ },
66
+ data: x.data.map(itemFactory)
67
+ };
68
+ });
69
+ });
70
+ };
71
+
72
+
73
+ //# sourceMappingURL=json.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":"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","sources":["plugins/json/src/index.ts"],"sourcesContent":["import {\n HttpBuilder,\n HttpBuilderOfT,\n getMapper,\n getNullableMapper\n} from \"@utiliread/http\";\nimport type {\n InfinitePaginationResult,\n PaginationResult,\n TypeOrMapper\n} from \"@utiliread/http\";\nimport { deserialize, serialize } from \"@utiliread/json\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n withJson(content: any): this;\n\n expectJson<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;\n expectJsonArray<T>(typeOrMapper: TypeOrMapper<T>): HttpBuilderOfT<T[]>;\n expectJsonNullableArray<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<(T | null)[]>;\n expectJsonPaginationResult<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<PaginationResult<T>>;\n expectJsonInfinitePaginationResult<T>(\n typeOrMapper: TypeOrMapper<T>,\n ): HttpBuilderOfT<InfinitePaginationResult<T>>;\n }\n interface HttpBuilderOfT<T> {\n withJson(content: any): this;\n }\n}\n\nHttpBuilder.prototype.withJson = function (this: HttpBuilder, content: any) {\n this.message.content = serialize(content);\n this.message.contentType = \"application/json\";\n return this;\n};\n\nHttpBuilderOfT.prototype.withJson = function <T>(\n this: HttpBuilderOfT<T>,\n content: any,\n) {\n this.message.content = serialize(content);\n this.message.contentType = \"application/json\";\n return this;\n};\n\nHttpBuilder.prototype.expectJson = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse\n .json()\n .then((x) => getMapper(deserialize, typeOrMapper)(x));\n });\n};\n\nHttpBuilder.prototype.expectJsonArray = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: any[]) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return x.map(itemFactory);\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonNullableArray = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n): HttpBuilderOfT<(T | null)[]> {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: any[]) => {\n const itemFactory = getNullableMapper(deserialize, typeOrMapper);\n return x.map(itemFactory);\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonPaginationResult = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse.json().then((x: PaginationResult<any>) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return {\n meta: {\n pageCount: x.meta.pageCount,\n pageSize: x.meta.pageSize,\n totalItems: x.meta.totalItems,\n },\n data: x.data.map(itemFactory),\n };\n });\n });\n};\n\nHttpBuilder.prototype.expectJsonInfinitePaginationResult = function <T>(\n this: HttpBuilder,\n typeOrMapper: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/json\");\n return this.useHandler((response) => {\n return response.rawResponse\n .json()\n .then((x: InfinitePaginationResult<any>) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n return {\n meta: {\n pageSize: x.meta.pageSize,\n continuationToken: x.meta.continuationToken,\n },\n data: x.data.map(itemFactory),\n };\n });\n });\n};\n"],"names":[],"version":3,"file":"json.mjs.map"}
@@ -1,9 +1,10 @@
1
- import type { Operation } from "@utiliread/jsonpatch";
2
- declare module "@utiliread/http" {
3
- interface HttpBuilder {
4
- withJsonPatch(operations: Operation[]): this;
5
- }
6
- interface HttpBuilderOfT<T> {
7
- withJsonPatch(operations: Operation[]): this;
8
- }
9
- }
1
+ declare module "@utiliread/http" {
2
+ interface HttpBuilder {
3
+ withJsonPatch(operations: Operation[]): this;
4
+ }
5
+ interface HttpBuilderOfT<T> {
6
+ withJsonPatch(operations: Operation[]): this;
7
+ }
8
+ }
9
+
10
+ //# sourceMappingURL=jsonpatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAKA,eAAe,iBAAiB,CAAC;IAC/B,UAAU,WAAW;QACnB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;KAC9C;IACD,UAAU,cAAc,CAAC,CAAC;QACxB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;KAC9C;CACF","sources":["plugins/jsonpatch/src/plugins/jsonpatch/src/index.ts","plugins/jsonpatch/src/index.ts"],"sourcesContent":[null,"import { HttpBuilder, HttpBuilderOfT } from \"@utiliread/http\";\nimport { serialize } from \"@utiliread/json\";\nimport type { Operation } from \"@utiliread/jsonpatch\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n withJsonPatch(operations: Operation[]): this;\n }\n interface HttpBuilderOfT<T> {\n withJsonPatch(operations: Operation[]): this;\n }\n}\n\nHttpBuilder.prototype.withJsonPatch = function (\n this: HttpBuilder,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n\nHttpBuilderOfT.prototype.withJsonPatch = function <T>(\n this: HttpBuilderOfT<T>,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n"],"names":[],"version":3,"file":"jsonpatch.d.ts.map"}
@@ -0,0 +1,18 @@
1
+ var $lxUpO$utilireadhttp = require("@utiliread/http");
2
+ var $lxUpO$utilireadjson = require("@utiliread/json");
3
+
4
+
5
+
6
+ (0, $lxUpO$utilireadhttp.HttpBuilder).prototype.withJsonPatch = function(operations) {
7
+ this.message.content = (0, $lxUpO$utilireadjson.serialize)(operations);
8
+ this.message.contentType = "application/json-patch+json";
9
+ return this;
10
+ };
11
+ (0, $lxUpO$utilireadhttp.HttpBuilderOfT).prototype.withJsonPatch = function(operations) {
12
+ this.message.content = (0, $lxUpO$utilireadjson.serialize)(operations);
13
+ this.message.contentType = "application/json-patch+json";
14
+ return this;
15
+ };
16
+
17
+
18
+ //# sourceMappingURL=jsonpatch.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAcA,CAAA,GAAA,gCAAU,EAAE,SAAS,CAAC,aAAa,GAAG,SAEpC,UAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,CAAA,GAAA,8BAAQ,EAAE;IACjC,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG;IAC3B,OAAO,IAAI;AACb;AAEA,CAAA,GAAA,mCAAa,EAAE,SAAS,CAAC,aAAa,GAAG,SAEvC,UAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,CAAA,GAAA,8BAAQ,EAAE;IACjC,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG;IAC3B,OAAO,IAAI;AACb","sources":["plugins/jsonpatch/src/index.ts"],"sourcesContent":["import { HttpBuilder, HttpBuilderOfT } from \"@utiliread/http\";\nimport { serialize } from \"@utiliread/json\";\nimport type { Operation } from \"@utiliread/jsonpatch\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n withJsonPatch(operations: Operation[]): this;\n }\n interface HttpBuilderOfT<T> {\n withJsonPatch(operations: Operation[]): this;\n }\n}\n\nHttpBuilder.prototype.withJsonPatch = function (\n this: HttpBuilder,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n\nHttpBuilderOfT.prototype.withJsonPatch = function <T>(\n this: HttpBuilderOfT<T>,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n"],"names":[],"version":3,"file":"jsonpatch.js.map"}
@@ -0,0 +1,18 @@
1
+ import {HttpBuilder as $8CiR8$HttpBuilder, HttpBuilderOfT as $8CiR8$HttpBuilderOfT} from "@utiliread/http";
2
+ import {serialize as $8CiR8$serialize} from "@utiliread/json";
3
+
4
+
5
+
6
+ (0, $8CiR8$HttpBuilder).prototype.withJsonPatch = function(operations) {
7
+ this.message.content = (0, $8CiR8$serialize)(operations);
8
+ this.message.contentType = "application/json-patch+json";
9
+ return this;
10
+ };
11
+ (0, $8CiR8$HttpBuilderOfT).prototype.withJsonPatch = function(operations) {
12
+ this.message.content = (0, $8CiR8$serialize)(operations);
13
+ this.message.contentType = "application/json-patch+json";
14
+ return this;
15
+ };
16
+
17
+
18
+ //# sourceMappingURL=jsonpatch.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAcA,CAAA,GAAA,kBAAU,EAAE,SAAS,CAAC,aAAa,GAAG,SAEpC,UAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,CAAA,GAAA,gBAAQ,EAAE;IACjC,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG;IAC3B,OAAO,IAAI;AACb;AAEA,CAAA,GAAA,qBAAa,EAAE,SAAS,CAAC,aAAa,GAAG,SAEvC,UAAuB;IAEvB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,CAAA,GAAA,gBAAQ,EAAE;IACjC,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG;IAC3B,OAAO,IAAI;AACb","sources":["plugins/jsonpatch/src/index.ts"],"sourcesContent":["import { HttpBuilder, HttpBuilderOfT } from \"@utiliread/http\";\nimport { serialize } from \"@utiliread/json\";\nimport type { Operation } from \"@utiliread/jsonpatch\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n withJsonPatch(operations: Operation[]): this;\n }\n interface HttpBuilderOfT<T> {\n withJsonPatch(operations: Operation[]): this;\n }\n}\n\nHttpBuilder.prototype.withJsonPatch = function (\n this: HttpBuilder,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n\nHttpBuilderOfT.prototype.withJsonPatch = function <T>(\n this: HttpBuilderOfT<T>,\n operations: Operation[],\n) {\n this.message.content = serialize(operations);\n this.message.contentType = \"application/json-patch+json\";\n return this;\n};\n"],"names":[],"version":3,"file":"jsonpatch.mjs.map"}
@@ -0,0 +1,9 @@
1
+ declare module "@utiliread/http" {
2
+ interface HttpBuilder {
3
+ expectMessagePack<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;
4
+ expectMessagePackArray<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T[]>;
5
+ streamMessagePackArray<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<AsyncGenerator<T, void, unknown>>;
6
+ }
7
+ }
8
+
9
+ //# sourceMappingURL=msgpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAMA,eAAe,iBAAiB,CAAC;IAC/B,UAAU,WAAW;QACnB,iBAAiB,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QACxE,sBAAsB,CAAC,CAAC,EACtB,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAC7B,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;QACvB,sBAAsB,CAAC,CAAC,EACtB,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAC7B,cAAc,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;KACrD;CACF","sources":["plugins/msgpack/src/plugins/msgpack/src/index.ts","plugins/msgpack/src/index.ts"],"sourcesContent":[null,"import { HttpBuilder, HttpBuilderOfT, HttpResponse, TypeOrMapper, getMapper } from \"@utiliread/http\";\nimport { decodeArrayStream, decodeAsync } from \"@msgpack/msgpack\";\n\nimport { deserialize } from \"@utiliread/msgpack\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n expectMessagePack<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;\n expectMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<T[]>;\n streamMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<AsyncGenerator<T, void, unknown>>;\n }\n}\n\nHttpBuilder.prototype.expectMessagePack = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n const decoded = await decodeAsync(response.rawResponse.body!);\n return itemFactory(decoded);\n });\n};\n\nHttpBuilder.prototype.expectMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const items: T[] = [];\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n items.push(itemFactory(item));\n }\n return items;\n });\n};\n\nHttpBuilder.prototype.streamMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n\n async function* handler(response: HttpResponse) {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n yield itemFactory(item);\n }\n }\n\n return this.useHandler((response) => Promise.resolve(handler(response)));\n};\n"],"names":[],"version":3,"file":"msgpack.d.ts.map"}
@@ -0,0 +1,35 @@
1
+ var $aEV4B$utilireadhttp = require("@utiliread/http");
2
+ var $aEV4B$msgpackmsgpack = require("@msgpack/msgpack");
3
+ var $aEV4B$utilireadmsgpack = require("@utiliread/msgpack");
4
+
5
+
6
+
7
+
8
+ (0, $aEV4B$utilireadhttp.HttpBuilder).prototype.expectMessagePack = function(typeOrMapper) {
9
+ this.message.headers.set("Accept", "application/x-msgpack");
10
+ return this.useHandler(async (response)=>{
11
+ const itemFactory = (0, $aEV4B$utilireadhttp.getMapper)((0, $aEV4B$utilireadmsgpack.deserialize), typeOrMapper);
12
+ const decoded = await (0, $aEV4B$msgpackmsgpack.decodeAsync)(response.rawResponse.body);
13
+ return itemFactory(decoded);
14
+ });
15
+ };
16
+ (0, $aEV4B$utilireadhttp.HttpBuilder).prototype.expectMessagePackArray = function(typeOrMapper) {
17
+ this.message.headers.set("Accept", "application/x-msgpack");
18
+ return this.useHandler(async (response)=>{
19
+ const items = [];
20
+ const itemFactory = (0, $aEV4B$utilireadhttp.getMapper)((0, $aEV4B$utilireadmsgpack.deserialize), typeOrMapper);
21
+ for await (const item of (0, $aEV4B$msgpackmsgpack.decodeArrayStream)(response.rawResponse.body))items.push(itemFactory(item));
22
+ return items;
23
+ });
24
+ };
25
+ (0, $aEV4B$utilireadhttp.HttpBuilder).prototype.streamMessagePackArray = function(typeOrMapper) {
26
+ this.message.headers.set("Accept", "application/x-msgpack");
27
+ async function* handler(response) {
28
+ const itemFactory = (0, $aEV4B$utilireadhttp.getMapper)((0, $aEV4B$utilireadmsgpack.deserialize), typeOrMapper);
29
+ for await (const item of (0, $aEV4B$msgpackmsgpack.decodeArrayStream)(response.rawResponse.body))yield itemFactory(item);
30
+ }
31
+ return this.useHandler((response)=>Promise.resolve(handler(response)));
32
+ };
33
+
34
+
35
+ //# sourceMappingURL=msgpack.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAkBA,CAAA,GAAA,gCAAU,EAAE,SAAS,CAAC,iBAAiB,GAAG,SAExC,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5B,MAAM,cAAc,CAAA,GAAA,8BAAQ,EAAE,CAAA,GAAA,mCAAU,GAAG;QAC3C,MAAM,UAAU,MAAM,CAAA,GAAA,iCAAU,EAAE,SAAS,WAAW,CAAC,IAAI;QAC3D,OAAO,YAAY;IACrB;AACF;AAEA,CAAA,GAAA,gCAAU,EAAE,SAAS,CAAC,sBAAsB,GAAG,SAE7C,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5B,MAAM,QAAa,EAAE;QACrB,MAAM,cAAc,CAAA,GAAA,8BAAQ,EAAE,CAAA,GAAA,mCAAU,GAAG;QAC3C,WAAW,MAAM,QAAQ,CAAA,GAAA,uCAAgB,EAAE,SAAS,WAAW,CAAC,IAAI,EAClE,MAAM,IAAI,CAAC,YAAY;QAEzB,OAAO;IACT;AACF;AAEA,CAAA,GAAA,gCAAU,EAAE,SAAS,CAAC,sBAAsB,GAAG,SAE7C,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IAEnC,gBAAgB,QAAQ,QAAsB;QAC5C,MAAM,cAAc,CAAA,GAAA,8BAAQ,EAAE,CAAA,GAAA,mCAAU,GAAG;QAC3C,WAAW,MAAM,QAAQ,CAAA,GAAA,uCAAgB,EAAE,SAAS,WAAW,CAAC,IAAI,EAClE,MAAM,YAAY;IAEtB;IAEA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,WAAa,QAAQ,OAAO,CAAC,QAAQ;AAC/D","sources":["plugins/msgpack/src/index.ts"],"sourcesContent":["import { HttpBuilder, HttpBuilderOfT, HttpResponse, TypeOrMapper, getMapper } from \"@utiliread/http\";\nimport { decodeArrayStream, decodeAsync } from \"@msgpack/msgpack\";\n\nimport { deserialize } from \"@utiliread/msgpack\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n expectMessagePack<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;\n expectMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<T[]>;\n streamMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<AsyncGenerator<T, void, unknown>>;\n }\n}\n\nHttpBuilder.prototype.expectMessagePack = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n const decoded = await decodeAsync(response.rawResponse.body!);\n return itemFactory(decoded);\n });\n};\n\nHttpBuilder.prototype.expectMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const items: T[] = [];\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n items.push(itemFactory(item));\n }\n return items;\n });\n};\n\nHttpBuilder.prototype.streamMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n\n async function* handler(response: HttpResponse) {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n yield itemFactory(item);\n }\n }\n\n return this.useHandler((response) => Promise.resolve(handler(response)));\n};\n"],"names":[],"version":3,"file":"msgpack.js.map"}
@@ -0,0 +1,35 @@
1
+ import {HttpBuilder as $ce1lZ$HttpBuilder, getMapper as $ce1lZ$getMapper} from "@utiliread/http";
2
+ import {decodeAsync as $ce1lZ$decodeAsync, decodeArrayStream as $ce1lZ$decodeArrayStream} from "@msgpack/msgpack";
3
+ import {deserialize as $ce1lZ$deserialize} from "@utiliread/msgpack";
4
+
5
+
6
+
7
+
8
+ (0, $ce1lZ$HttpBuilder).prototype.expectMessagePack = function(typeOrMapper) {
9
+ this.message.headers.set("Accept", "application/x-msgpack");
10
+ return this.useHandler(async (response)=>{
11
+ const itemFactory = (0, $ce1lZ$getMapper)((0, $ce1lZ$deserialize), typeOrMapper);
12
+ const decoded = await (0, $ce1lZ$decodeAsync)(response.rawResponse.body);
13
+ return itemFactory(decoded);
14
+ });
15
+ };
16
+ (0, $ce1lZ$HttpBuilder).prototype.expectMessagePackArray = function(typeOrMapper) {
17
+ this.message.headers.set("Accept", "application/x-msgpack");
18
+ return this.useHandler(async (response)=>{
19
+ const items = [];
20
+ const itemFactory = (0, $ce1lZ$getMapper)((0, $ce1lZ$deserialize), typeOrMapper);
21
+ for await (const item of (0, $ce1lZ$decodeArrayStream)(response.rawResponse.body))items.push(itemFactory(item));
22
+ return items;
23
+ });
24
+ };
25
+ (0, $ce1lZ$HttpBuilder).prototype.streamMessagePackArray = function(typeOrMapper) {
26
+ this.message.headers.set("Accept", "application/x-msgpack");
27
+ async function* handler(response) {
28
+ const itemFactory = (0, $ce1lZ$getMapper)((0, $ce1lZ$deserialize), typeOrMapper);
29
+ for await (const item of (0, $ce1lZ$decodeArrayStream)(response.rawResponse.body))yield itemFactory(item);
30
+ }
31
+ return this.useHandler((response)=>Promise.resolve(handler(response)));
32
+ };
33
+
34
+
35
+ //# sourceMappingURL=msgpack.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAkBA,CAAA,GAAA,kBAAU,EAAE,SAAS,CAAC,iBAAiB,GAAG,SAExC,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5B,MAAM,cAAc,CAAA,GAAA,gBAAQ,EAAE,CAAA,GAAA,kBAAU,GAAG;QAC3C,MAAM,UAAU,MAAM,CAAA,GAAA,kBAAU,EAAE,SAAS,WAAW,CAAC,IAAI;QAC3D,OAAO,YAAY;IACrB;AACF;AAEA,CAAA,GAAA,kBAAU,EAAE,SAAS,CAAC,sBAAsB,GAAG,SAE7C,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5B,MAAM,QAAa,EAAE;QACrB,MAAM,cAAc,CAAA,GAAA,gBAAQ,EAAE,CAAA,GAAA,kBAAU,GAAG;QAC3C,WAAW,MAAM,QAAQ,CAAA,GAAA,wBAAgB,EAAE,SAAS,WAAW,CAAC,IAAI,EAClE,MAAM,IAAI,CAAC,YAAY;QAEzB,OAAO;IACT;AACF;AAEA,CAAA,GAAA,kBAAU,EAAE,SAAS,CAAC,sBAAsB,GAAG,SAE7C,YAA8B;IAE9B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;IAEnC,gBAAgB,QAAQ,QAAsB;QAC5C,MAAM,cAAc,CAAA,GAAA,gBAAQ,EAAE,CAAA,GAAA,kBAAU,GAAG;QAC3C,WAAW,MAAM,QAAQ,CAAA,GAAA,wBAAgB,EAAE,SAAS,WAAW,CAAC,IAAI,EAClE,MAAM,YAAY;IAEtB;IAEA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,WAAa,QAAQ,OAAO,CAAC,QAAQ;AAC/D","sources":["plugins/msgpack/src/index.ts"],"sourcesContent":["import { HttpBuilder, HttpBuilderOfT, HttpResponse, TypeOrMapper, getMapper } from \"@utiliread/http\";\nimport { decodeArrayStream, decodeAsync } from \"@msgpack/msgpack\";\n\nimport { deserialize } from \"@utiliread/msgpack\";\n\n// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\ndeclare module \"@utiliread/http\" {\n interface HttpBuilder {\n expectMessagePack<T>(typeOrMapper?: TypeOrMapper<T>): HttpBuilderOfT<T>;\n expectMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<T[]>;\n streamMessagePackArray<T>(\n typeOrMapper?: TypeOrMapper<T>,\n ): HttpBuilderOfT<AsyncGenerator<T, void, unknown>>;\n }\n}\n\nHttpBuilder.prototype.expectMessagePack = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n const decoded = await decodeAsync(response.rawResponse.body!);\n return itemFactory(decoded);\n });\n};\n\nHttpBuilder.prototype.expectMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n return this.useHandler(async (response) => {\n const items: T[] = [];\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n items.push(itemFactory(item));\n }\n return items;\n });\n};\n\nHttpBuilder.prototype.streamMessagePackArray = function <T>(\n this: HttpBuilder,\n typeOrMapper?: TypeOrMapper<T>,\n) {\n this.message.headers.set(\"Accept\", \"application/x-msgpack\");\n\n async function* handler(response: HttpResponse) {\n const itemFactory = getMapper(deserialize, typeOrMapper);\n for await (const item of decodeArrayStream(response.rawResponse.body!)) {\n yield itemFactory(item);\n }\n }\n\n return this.useHandler((response) => Promise.resolve(handler(response)));\n};\n"],"names":[],"version":3,"file":"msgpack.mjs.map"}
package/json.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./dist/esm/json";
1
+ export * from "./dist/json";
package/jsonpatch.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./dist/esm/jsonpatch";
1
+ export * from "./dist/jsonpatch";
package/mapper.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/mapper";
package/msgpack.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./dist/esm/msgpack";
1
+ export * from "./dist/msgpack";
package/package.json CHANGED
@@ -1,67 +1,69 @@
1
1
  {
2
2
  "name": "@utiliread/http",
3
- "version": "1.17.8",
4
- "main": "dist/cjs/index.js",
5
- "module": "dist/esm/index.js",
6
- "types": "dist/esm/index.d.ts",
3
+ "version": "1.19.0",
4
+ "source": "src/index.ts",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
7
8
  "exports": {
8
9
  ".": {
9
- "import": "./dist/esm/index.js",
10
- "require": "./dist/cjs/index.js"
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
11
12
  },
12
13
  "./json": {
13
- "import": "./dist/esm/json/index.js",
14
- "require": "./dist/cjs/json/index.js"
14
+ "import": "./dist/json.mjs",
15
+ "require": "./dist/json.js"
15
16
  },
16
17
  "./jsonpatch": {
17
- "import": "./dist/esm/jsonpatch/index.js",
18
- "require": "./dist/cjs/jsonpatch/index.js"
18
+ "import": "./dist/jsonpatch.mjs",
19
+ "require": "./dist/jsonpatch.js"
19
20
  },
20
21
  "./msgpack": {
21
- "import": "./dist/esm/msgpack/index.js",
22
- "require": "./dist/cjs/msgpack/index.js"
22
+ "import": "./dist/msgpack.mjs",
23
+ "require": "./dist/msgpack.js"
23
24
  }
24
25
  },
25
26
  "sideEffects": [
26
- "./dist/*/json/index.js",
27
- "./dist/*/jsonpatch/index.js",
28
- "./dist/*/msgpack/index.js"
27
+ "./dist/json.m?js",
28
+ "./dist/jsonpatch.m?js",
29
+ "./dist/msgpack.m?js"
29
30
  ],
30
31
  "scripts": {
31
- "build": "npm run build:core && npm run build:json && npm run build:jsonpatch && npm run build:msgpack",
32
- "build:core": "tsc && tsc -p tsconfig.cjs.json",
33
- "build:json": "cd ./plugins/json && tsc && tsc -p tsconfig.cjs.json",
34
- "build:jsonpatch": "cd ./plugins/jsonpatch && tsc && tsc -p tsconfig.cjs.json",
35
- "build:msgpack": "cd ./plugins/msgpack && tsc && tsc -p tsconfig.cjs.json",
36
- "test": "karma start --single-run --browsers ChromeHeadless karma.config.js",
37
- "watch": "karma start --auto-watch --browsers ChromeDebugging karma.config.js",
38
- "clean": "rimraf dist"
32
+ "build": "npm run build:main && npm run build:json && npm run build:jsonpatch && npm run build:msgpack",
33
+ "build:main": "parcel build",
34
+ "build:json": "parcel build plugins/json",
35
+ "build:jsonpatch": "parcel build plugins/jsonpatch",
36
+ "build:msgpack": "parcel build plugins/msgpack",
37
+ "prettier": "prettier --write *.mjs src/**/*.ts plugins/**/*.ts",
38
+ "test": "web-test-runner",
39
+ "clean": "rimraf .parcel-cache dist"
39
40
  },
40
41
  "publishConfig": {
41
42
  "access": "public"
42
43
  },
43
44
  "devDependencies": {
44
- "@types/chai": "^4.2.16",
45
+ "@parcel/packager-ts": "^2.12.0",
46
+ "@parcel/transformer-typescript-types": "^2.12.0",
47
+ "@types/chai": "^4.3.11",
45
48
  "@types/luxon": "^3.0.1",
46
49
  "@types/mocha": "^10.0.0",
47
- "@utiliread/json": "^1.0.2",
48
- "@utiliread/jsonpatch": "^1.0.0",
49
- "@utiliread/msgpack": "^1.0.1",
50
- "chai": "^4.3.4",
51
- "karma": "^6.3.8",
52
- "karma-chai": "^0.1.0",
53
- "karma-chrome-launcher": "^3.1.0",
54
- "karma-mocha": "^2.0.1",
55
- "karma-typescript": "^5.5.1",
50
+ "@utiliread/json": "^1.3.0",
51
+ "@utiliread/jsonpatch": "^1.1.0",
52
+ "@utiliread/msgpack": "^1.1.0",
53
+ "@web/dev-server-esbuild": "^1.0.1",
54
+ "@web/test-runner": "^0.19.0",
55
+ "chai": "^5.0.0",
56
56
  "luxon": "^3.0.4",
57
57
  "mocha": "^10.0.0",
58
- "rimraf": "^3.0.2",
59
- "typescript": "^4.2.4"
58
+ "parcel": "^2.12.0",
59
+ "prettier": "^3.2.4",
60
+ "rimraf": "^6.0.1",
61
+ "typescript": "^5.3.3"
60
62
  },
61
63
  "peerDependencies": {
62
- "@utiliread/json": "^1.0.2",
63
- "@utiliread/jsonpatch": "^1.0.0",
64
- "@utiliread/msgpack": "^1.0.1",
64
+ "@utiliread/json": "^1.3.0",
65
+ "@utiliread/jsonpatch": "^1.1.0",
66
+ "@utiliread/msgpack": "^1.1.0",
65
67
  "luxon": "^2.1.0 || ^3.0.0"
66
68
  },
67
69
  "peerDependenciesMeta": {
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@utiliread/http",
3
+ "types": "../../../../../dist/index.d.ts"
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "source": "src/index.ts",
3
+ "main": "./../../dist/json.js",
4
+ "module": "./../../dist/json.mjs",
5
+ "types": "./../../dist/json.d.ts",
6
+ "alias": {
7
+ "@utiliread/http": false
8
+ },
9
+ "dependencies": {
10
+ "@utiliread/http": "file:../../"
11
+ },
12
+ "peerDependencies": {
13
+ "@utiliread/json": "file:../../node_modules/@utiliread/json"
14
+ }
15
+ }