@utiliread/http 1.27.0 → 1.27.1

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.
@@ -1,35 +1,35 @@
1
- import typescript from "@rollup/plugin-typescript";
2
-
3
- /** @type {import('rollup').RollupOptions} */
4
- const options = {
5
- input: "src/plugins/cursor/index.ts",
6
- external: [
7
- "@utiliread/http",
8
- "@utiliread/json",
9
- ],
10
- treeshake: false,
11
- plugins: [typescript({ declaration: false })],
12
- };
13
-
14
- export default [
15
- Object.assign(
16
- {
17
- output: {
18
- file: "dist/plugins/cursor/index.mjs",
19
- sourcemap: true,
20
- format: "es",
21
- },
22
- },
23
- options,
24
- ),
25
- Object.assign(
26
- {
27
- output: {
28
- file: "dist/plugins/cursor/index.js",
29
- sourcemap: true,
30
- format: "cjs",
31
- },
32
- },
33
- options,
34
- ),
35
- ];
1
+ import typescript from "@rollup/plugin-typescript";
2
+
3
+ /** @type {import('rollup').RollupOptions} */
4
+ const options = {
5
+ input: "src/plugins/cursor/index.ts",
6
+ external: [
7
+ "@utiliread/http",
8
+ "@utiliread/json",
9
+ ],
10
+ treeshake: false,
11
+ plugins: [typescript({ declaration: false })],
12
+ };
13
+
14
+ export default [
15
+ Object.assign(
16
+ {
17
+ output: {
18
+ file: "dist/plugins/cursor/index.mjs",
19
+ sourcemap: true,
20
+ format: "es",
21
+ },
22
+ },
23
+ options,
24
+ ),
25
+ Object.assign(
26
+ {
27
+ output: {
28
+ file: "dist/plugins/cursor/index.js",
29
+ sourcemap: true,
30
+ format: "cjs",
31
+ },
32
+ },
33
+ options,
34
+ ),
35
+ ];
@@ -3,6 +3,7 @@ export interface ICursorPage<T> {
3
3
  items: T[];
4
4
  nextCursor: string | null;
5
5
  hasMore: boolean;
6
+ totalCount?: number;
6
7
  }
7
8
  declare const _default: {};
8
9
  export default _default;
@@ -17,6 +17,7 @@ http.HttpBuilder.prototype.expectCursorPage = function (typeOrMapper) {
17
17
  items: x.items.map(itemFactory),
18
18
  nextCursor: x.nextCursor,
19
19
  hasMore: x.hasMore,
20
+ totalCount: x.totalCount,
20
21
  };
21
22
  });
22
23
  return promise;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/plugins/cursor/index.ts"],"sourcesContent":[null],"names":["HttpBuilder","getMapper","deserialize"],"mappings":";;;;;AAaA;AACA;AACA,YAAe,EAAE;AAWjBA,gBAAW,CAAC,SAAS,CAAC,gBAAgB,GAAG,UAEvC,YAA6B,EAAA;IAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACtD,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,KAAI;AAClC,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC;AACtB,aAAA,IAAI;AACJ,aAAA,IAAI,CAAC,CAAC,CAAmB,KAAoB;YAC5C,MAAM,WAAW,GAAGC,cAAS,CAACC,gBAAW,EAAE,YAAY,CAAC;YACxD,OAAO;gBACL,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC/B,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,CAAC,CAAC,OAAO;aACnB;AACH,QAAA,CAAC,CAAC;AACJ,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AACJ,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/plugins/cursor/index.ts"],"sourcesContent":[null],"names":["HttpBuilder","getMapper","deserialize"],"mappings":";;;;;AAcA;AACA;AACA,YAAe,EAAE;AAWjBA,gBAAW,CAAC,SAAS,CAAC,gBAAgB,GAAG,UAEvC,YAA6B,EAAA;IAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACtD,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,KAAI;AAClC,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC;AACtB,aAAA,IAAI;AACJ,aAAA,IAAI,CAAC,CAAC,CAAmB,KAAoB;YAC5C,MAAM,WAAW,GAAGC,cAAS,CAACC,gBAAW,EAAE,YAAY,CAAC;YACxD,OAAO;gBACL,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC/B,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;aACzB;AACH,QAAA,CAAC,CAAC;AACJ,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AACJ,CAAC;;;;"}
@@ -15,6 +15,7 @@ HttpBuilder.prototype.expectCursorPage = function (typeOrMapper) {
15
15
  items: x.items.map(itemFactory),
16
16
  nextCursor: x.nextCursor,
17
17
  hasMore: x.hasMore,
18
+ totalCount: x.totalCount,
18
19
  };
19
20
  });
20
21
  return promise;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/plugins/cursor/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAaA;AACA;AACA,YAAe,EAAE;AAWjB,WAAW,CAAC,SAAS,CAAC,gBAAgB,GAAG,UAEvC,YAA6B,EAAA;IAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACtD,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,KAAI;AAClC,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC;AACtB,aAAA,IAAI;AACJ,aAAA,IAAI,CAAC,CAAC,CAAmB,KAAoB;YAC5C,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,YAAY,CAAC;YACxD,OAAO;gBACL,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC/B,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,CAAC,CAAC,OAAO;aACnB;AACH,QAAA,CAAC,CAAC;AACJ,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AACJ,CAAC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/plugins/cursor/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAcA;AACA;AACA,YAAe,EAAE;AAWjB,WAAW,CAAC,SAAS,CAAC,gBAAgB,GAAG,UAEvC,YAA6B,EAAA;IAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC;AACtD,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,KAAI;AAClC,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC;AACtB,aAAA,IAAI;AACJ,aAAA,IAAI,CAAC,CAAC,CAAmB,KAAoB;YAC5C,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,EAAE,YAAY,CAAC;YACxD,OAAO;gBACL,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC/B,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;aACzB;AACH,QAAA,CAAC,CAAC;AACJ,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CAAC;AACJ,CAAC;;;;"}
package/package.json CHANGED
@@ -1,91 +1,91 @@
1
- {
2
- "name": "@utiliread/http",
3
- "version": "1.27.0",
4
- "source": "src/index.ts",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- },
14
- "./json": {
15
- "types": "./dist/plugins/json/index.d.ts",
16
- "import": "./dist/plugins/json/index.mjs",
17
- "require": "./dist/plugins/json/index.js"
18
- },
19
- "./jsonpatch": {
20
- "types": "./dist/plugins/jsonpatch/index.d.ts",
21
- "import": "./dist/plugins/jsonpatch/index.mjs",
22
- "require": "./dist/plugins/jsonpatch/index.js"
23
- },
24
- "./msgpack": {
25
- "types": "./dist/plugins/msgpack/index.d.ts",
26
- "import": "./dist/plugins/msgpack/index.mjs",
27
- "require": "./dist/plugins/msgpack/index.js"
28
- },
29
- "./cursor": {
30
- "types": "./dist/plugins/cursor/index.d.ts",
31
- "import": "./dist/plugins/cursor/index.mjs",
32
- "require": "./dist/plugins/cursor/index.js"
33
- }
34
- },
35
- "sideEffects": [
36
- "./dist/plugins/json/index.{mjs,js}",
37
- "./dist/plugins/jsonpatch/index.{mjs,js}",
38
- "./dist/plugins/msgpack/index.{mjs,js}",
39
- "./dist/plugins/cursor/index.{mjs,js}"
40
- ],
41
- "scripts": {
42
- "build": "rollup -c && npm run build:json && npm run build:jsonpatch && npm run build:msgpack && npm run build:cursor",
43
- "build:core": "rollup -c",
44
- "build:json": "rollup -c json.rollup.config.mjs",
45
- "build:jsonpatch": "rollup -c jsonpatch.rollup.config.mjs",
46
- "build:msgpack": "rollup -c msgpack.rollup.config.mjs",
47
- "build:cursor": "rollup -c cursor.rollup.config.mjs",
48
- "prettier": "prettier --write package.json tsconfig.json *.mjs src/**/*.ts",
49
- "test": "npm run build:core && web-test-runner",
50
- "clean": "rimraf dist"
51
- },
52
- "publishConfig": {
53
- "access": "public"
54
- },
55
- "devDependencies": {
56
- "@rollup/plugin-typescript": "^12.1.1",
57
- "@types/chai": "^5.0.1",
58
- "@types/luxon": "^3.0.1",
59
- "@types/mocha": "^10.0.0",
60
- "@utiliread/json": "^1.3.0",
61
- "@utiliread/jsonpatch": "^1.1.0",
62
- "@utiliread/msgpack": "^1.1.0",
63
- "@web/dev-server-esbuild": "^1.0.1",
64
- "@web/test-runner": "^0.20.2",
65
- "chai": "^6.2.0",
66
- "luxon": "^3.0.4",
67
- "mocha": "^11.5.0",
68
- "prettier": "^3.2.4",
69
- "rimraf": "^6.0.1",
70
- "rollup": "^4.21.3",
71
- "tslib": "^2.7.0",
72
- "typescript": "^5.6.2"
73
- },
74
- "peerDependencies": {
75
- "@utiliread/json": "^1.3.0",
76
- "@utiliread/jsonpatch": "^1.1.0",
77
- "@utiliread/msgpack": "^1.1.0",
78
- "luxon": "^2.1.0 || ^3.0.0"
79
- },
80
- "peerDependenciesMeta": {
81
- "@utiliread/json": {
82
- "optional": true
83
- },
84
- "@utiliread/jsonpatch": {
85
- "optional": true
86
- },
87
- "@utiliread/msgpack": {
88
- "optional": true
89
- }
90
- }
91
- }
1
+ {
2
+ "name": "@utiliread/http",
3
+ "version": "1.27.1",
4
+ "source": "src/index.ts",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./json": {
15
+ "types": "./dist/plugins/json/index.d.ts",
16
+ "import": "./dist/plugins/json/index.mjs",
17
+ "require": "./dist/plugins/json/index.js"
18
+ },
19
+ "./jsonpatch": {
20
+ "types": "./dist/plugins/jsonpatch/index.d.ts",
21
+ "import": "./dist/plugins/jsonpatch/index.mjs",
22
+ "require": "./dist/plugins/jsonpatch/index.js"
23
+ },
24
+ "./msgpack": {
25
+ "types": "./dist/plugins/msgpack/index.d.ts",
26
+ "import": "./dist/plugins/msgpack/index.mjs",
27
+ "require": "./dist/plugins/msgpack/index.js"
28
+ },
29
+ "./cursor": {
30
+ "types": "./dist/plugins/cursor/index.d.ts",
31
+ "import": "./dist/plugins/cursor/index.mjs",
32
+ "require": "./dist/plugins/cursor/index.js"
33
+ }
34
+ },
35
+ "sideEffects": [
36
+ "./dist/plugins/json/index.{mjs,js}",
37
+ "./dist/plugins/jsonpatch/index.{mjs,js}",
38
+ "./dist/plugins/msgpack/index.{mjs,js}",
39
+ "./dist/plugins/cursor/index.{mjs,js}"
40
+ ],
41
+ "scripts": {
42
+ "build": "rollup -c && npm run build:json && npm run build:jsonpatch && npm run build:msgpack && npm run build:cursor",
43
+ "build:core": "rollup -c",
44
+ "build:json": "rollup -c json.rollup.config.mjs",
45
+ "build:jsonpatch": "rollup -c jsonpatch.rollup.config.mjs",
46
+ "build:msgpack": "rollup -c msgpack.rollup.config.mjs",
47
+ "build:cursor": "rollup -c cursor.rollup.config.mjs",
48
+ "prettier": "prettier --write package.json tsconfig.json *.mjs src/**/*.ts",
49
+ "test": "npm run build:core && web-test-runner",
50
+ "clean": "rimraf dist"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "devDependencies": {
56
+ "@rollup/plugin-typescript": "^12.1.1",
57
+ "@types/chai": "^5.0.1",
58
+ "@types/luxon": "^3.0.1",
59
+ "@types/mocha": "^10.0.0",
60
+ "@utiliread/json": "^1.3.0",
61
+ "@utiliread/jsonpatch": "^1.1.0",
62
+ "@utiliread/msgpack": "^1.1.0",
63
+ "@web/dev-server-esbuild": "^1.0.1",
64
+ "@web/test-runner": "^0.20.2",
65
+ "chai": "^6.2.0",
66
+ "luxon": "^3.0.4",
67
+ "mocha": "^11.5.0",
68
+ "prettier": "^3.2.4",
69
+ "rimraf": "^6.0.1",
70
+ "rollup": "^4.21.3",
71
+ "tslib": "^2.7.0",
72
+ "typescript": "^6.0.2"
73
+ },
74
+ "peerDependencies": {
75
+ "@utiliread/json": "^1.3.0",
76
+ "@utiliread/jsonpatch": "^1.1.0",
77
+ "@utiliread/msgpack": "^1.1.0",
78
+ "luxon": "^2.1.0 || ^3.0.0"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@utiliread/json": {
82
+ "optional": true
83
+ },
84
+ "@utiliread/jsonpatch": {
85
+ "optional": true
86
+ },
87
+ "@utiliread/msgpack": {
88
+ "optional": true
89
+ }
90
+ }
91
+ }
@@ -1,52 +1,52 @@
1
- import { HttpResponse } from "../http-response";
2
- import { ProblemDetails } from "../problem-details";
3
-
4
- export class HttpError extends Error {
5
- private jsonPromise?: Promise<any>;
6
-
7
- readonly name: "HttpError" = "HttpError";
8
-
9
- get hasDetails() {
10
- const contentType = this.response?.rawResponse?.headers.get("Content-Type");
11
- return contentType?.includes("application/problem+json");
12
- }
13
-
14
- constructor(
15
- public statusCode: number,
16
- private response: HttpResponse | undefined = undefined,
17
- ) {
18
- super(`The response was not successful: ${statusCode}`);
19
-
20
- // Set the prototype explicitly to allow for "... instanceof HttpError",
21
- // see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
22
- Object.setPrototypeOf(this, HttpError.prototype);
23
- }
24
-
25
- details<TDetails = ProblemDetails>() {
26
- const rawResponse = this.response?.rawResponse;
27
-
28
- if (rawResponse && this.hasDetails) {
29
- this.jsonPromise ??= rawResponse.json();
30
- return this.jsonPromise.then((details) => <TDetails>details);
31
- }
32
-
33
- return Promise.reject(
34
- new Error("There are no problem details in the response"),
35
- );
36
- }
37
-
38
- json() {
39
- const rawResponse = this.response?.rawResponse;
40
-
41
- if (rawResponse) {
42
- this.jsonPromise ??= rawResponse.json();
43
- return this.jsonPromise;
44
- }
45
-
46
- return Promise.reject(new Error("There is no response"));
47
- }
48
- }
49
-
50
- export function isHttpError(error: unknown): error is HttpError {
51
- return error instanceof Error && error.name === "HttpError";
52
- }
1
+ import { HttpResponse } from "../http-response";
2
+ import { ProblemDetails } from "../problem-details";
3
+
4
+ export class HttpError extends Error {
5
+ private jsonPromise?: Promise<any>;
6
+
7
+ readonly name: "HttpError" = "HttpError";
8
+
9
+ get hasDetails() {
10
+ const contentType = this.response?.rawResponse?.headers.get("Content-Type");
11
+ return contentType?.includes("application/problem+json");
12
+ }
13
+
14
+ constructor(
15
+ public statusCode: number,
16
+ private response: HttpResponse | undefined = undefined,
17
+ ) {
18
+ super(`The response was not successful: ${statusCode}`);
19
+
20
+ // Set the prototype explicitly to allow for "... instanceof HttpError",
21
+ // see https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
22
+ Object.setPrototypeOf(this, HttpError.prototype);
23
+ }
24
+
25
+ details<TDetails = ProblemDetails>() {
26
+ const rawResponse = this.response?.rawResponse;
27
+
28
+ if (rawResponse && this.hasDetails) {
29
+ this.jsonPromise ??= rawResponse.json();
30
+ return this.jsonPromise.then((details) => <TDetails>details);
31
+ }
32
+
33
+ return Promise.reject(
34
+ new Error("There are no problem details in the response"),
35
+ );
36
+ }
37
+
38
+ json() {
39
+ const rawResponse = this.response?.rawResponse;
40
+
41
+ if (rawResponse) {
42
+ this.jsonPromise ??= rawResponse.json();
43
+ return this.jsonPromise;
44
+ }
45
+
46
+ return Promise.reject(new Error("There is no response"));
47
+ }
48
+ }
49
+
50
+ export function isHttpError(error: unknown): error is HttpError {
51
+ return error instanceof Error && error.name === "HttpError";
52
+ }