getta 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +15 -15
- package/dist/types/cjs/constants.d.cts.map +1 -1
- package/dist/types/cjs/helpers/buildEndpoint/index.d.cts.map +1 -1
- package/dist/types/cjs/helpers/defaultPathTemplateCallback/index.d.cts.map +1 -1
- package/dist/types/cjs/helpers/delay/index.d.cts.map +1 -1
- package/dist/types/cjs/helpers/getResponseGroup/index.d.cts.map +1 -1
- package/dist/types/cjs/helpers/isCacheabilityValid/index.d.cts.map +1 -1
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/esm/constants.d.ts.map +1 -1
- package/dist/types/esm/helpers/buildEndpoint/index.d.ts.map +1 -1
- package/dist/types/esm/helpers/defaultPathTemplateCallback/index.d.ts.map +1 -1
- package/dist/types/esm/helpers/delay/index.d.ts.map +1 -1
- package/dist/types/esm/helpers/getResponseGroup/index.d.ts.map +1 -1
- package/dist/types/esm/helpers/isCacheabilityValid/index.d.ts.map +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +37 -34
- package/src/helpers/buildEndpoint/index.ts +7 -3
- package/src/main.ts +12 -18
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getta",
|
|
3
3
|
"description": "An isomorphic rest client based on the Fetch API.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.17",
|
|
5
5
|
"author": "miami-man",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/getta",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"main": "./dist/cjs/index.cjs",
|
|
12
12
|
"module": "./dist/esm/index.mjs",
|
|
13
13
|
"types": "./dist/types/cjs/index.d.cts",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#*": "./src/*"
|
|
16
|
+
},
|
|
14
17
|
"exports": {
|
|
15
18
|
".": {
|
|
16
19
|
"types": {
|
|
@@ -26,50 +29,50 @@
|
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
31
|
"@types/lodash-es": "^4.17.12",
|
|
29
|
-
"cacheability": "^4.0.
|
|
30
|
-
"core-js": "^3.
|
|
32
|
+
"cacheability": "^4.0.30",
|
|
33
|
+
"core-js": "^3.43.0",
|
|
31
34
|
"lodash-es": "^4.17.21",
|
|
32
|
-
"query-string": "^9.
|
|
35
|
+
"query-string": "^9.2.0",
|
|
33
36
|
"ts-md5": "^1.3.1",
|
|
34
|
-
"type-fest": "^4.
|
|
37
|
+
"type-fest": "^4.41.0"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
|
-
"@cachemap/core": "^5.2.
|
|
38
|
-
"@cachemap/map": "^5.0.
|
|
39
|
-
"@commitlint/cli": "^19.
|
|
40
|
+
"@cachemap/core": "^5.2.8",
|
|
41
|
+
"@cachemap/map": "^5.0.10",
|
|
42
|
+
"@commitlint/cli": "^19.8.1",
|
|
40
43
|
"@jest/globals": "^29.7.0",
|
|
41
|
-
"@repodog/cli": "^1.6.
|
|
42
|
-
"@repodog/commitlint-config": "^19.0.
|
|
43
|
-
"@repodog/eslint-config": "^9.0.
|
|
44
|
-
"@repodog/eslint-config-jest": "^9.0.
|
|
45
|
-
"@repodog/jest-config": "^29.0.
|
|
46
|
-
"@repodog/markdownlint-config": "^1.2.
|
|
47
|
-
"@repodog/prettier-config": "^3.0.
|
|
48
|
-
"@repodog/rollup-config": "^4.0.
|
|
49
|
-
"@repodog/swc-config": "^1.0.
|
|
50
|
-
"@repodog/syncpack-config": "^13.0.
|
|
51
|
-
"@repodog/ts-config": "^5.0.
|
|
44
|
+
"@repodog/cli": "^1.6.44",
|
|
45
|
+
"@repodog/commitlint-config": "^19.0.4",
|
|
46
|
+
"@repodog/eslint-config": "^9.0.16",
|
|
47
|
+
"@repodog/eslint-config-jest": "^9.0.5",
|
|
48
|
+
"@repodog/jest-config": "^29.0.5",
|
|
49
|
+
"@repodog/markdownlint-config": "^1.2.5",
|
|
50
|
+
"@repodog/prettier-config": "^3.0.3",
|
|
51
|
+
"@repodog/rollup-config": "^4.0.10",
|
|
52
|
+
"@repodog/swc-config": "^1.0.11",
|
|
53
|
+
"@repodog/syncpack-config": "^13.0.4",
|
|
54
|
+
"@repodog/ts-config": "^5.0.5",
|
|
52
55
|
"@rollup/plugin-swc": "^0.3.0",
|
|
53
|
-
"@swc/core": "^1.
|
|
54
|
-
"@swc/jest": "^0.2.
|
|
56
|
+
"@swc/core": "^1.12.1",
|
|
57
|
+
"@swc/jest": "^0.2.38",
|
|
55
58
|
"@types/jest": "^29.5.13",
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"cts-types": "^0.0.
|
|
59
|
+
"@types/node": "^24.0.1",
|
|
60
|
+
"cts-types": "^0.0.10",
|
|
58
61
|
"del-cli": "^6.0.0",
|
|
59
|
-
"eslint": "^9.
|
|
60
|
-
"fetch-mocked": "^0.0.
|
|
62
|
+
"eslint": "^9.29.0",
|
|
63
|
+
"fetch-mocked": "^0.0.29",
|
|
61
64
|
"generate-changelog": "^1.8.0",
|
|
62
|
-
"husky": "^9.1.
|
|
65
|
+
"husky": "^9.1.7",
|
|
63
66
|
"jest": "^29.7.0",
|
|
64
67
|
"jest-environment-jsdom": "^29.7.0",
|
|
65
68
|
"jest-environment-node": "^29.7.0",
|
|
66
|
-
"markdownlint-cli2": "^0.
|
|
67
|
-
"prettier": "^3.
|
|
68
|
-
"rollup": "^4.
|
|
69
|
+
"markdownlint-cli2": "^0.18.1",
|
|
70
|
+
"prettier": "^3.5.3",
|
|
71
|
+
"rollup": "^4.43.0",
|
|
69
72
|
"suppress-experimental-warnings": "^2.0.0",
|
|
70
|
-
"syncpack": "^13.0.
|
|
71
|
-
"typescript": "^5.
|
|
72
|
-
"zod": "^3.
|
|
73
|
+
"syncpack": "^13.0.4",
|
|
74
|
+
"typescript": "^5.8.3",
|
|
75
|
+
"zod": "^3.25.64"
|
|
73
76
|
},
|
|
74
77
|
"keywords": [
|
|
75
78
|
"api-client",
|
|
@@ -82,8 +85,8 @@
|
|
|
82
85
|
"clean:deps": "del-cli ./node_modules",
|
|
83
86
|
"clean:dist": "del-cli ./dist",
|
|
84
87
|
"compile": "pnpm run /^compile:.*/",
|
|
85
|
-
"compile:cjs": "MODULE_SYSTEM=cjs rollup -c ./rollup.config.
|
|
86
|
-
"compile:esm": "rollup -c ./rollup.config.
|
|
88
|
+
"compile:cjs": "MODULE_SYSTEM=cjs rollup -c ./rollup.config.mjs",
|
|
89
|
+
"compile:esm": "rollup -c ./rollup.config.mjs",
|
|
87
90
|
"compile:types": "tsc --project ./tsconfig.build.json && cts-types build dist/types/esm dist/types/cjs",
|
|
88
91
|
"cut:changelog": "changelog",
|
|
89
92
|
"installActivateMise": "sh shellScripts/installActivateMise.sh",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { omitBy } from 'lodash-es';
|
|
1
2
|
import queryString from 'query-string';
|
|
3
|
+
import { type PlainObject } from '#types.ts';
|
|
2
4
|
import { type BuildEndpointOptions } from './types.ts';
|
|
3
5
|
|
|
4
6
|
export const buildEndpoint = (
|
|
@@ -9,7 +11,7 @@ export const buildEndpoint = (
|
|
|
9
11
|
pathTemplateCallback,
|
|
10
12
|
pathTemplateData,
|
|
11
13
|
pathTemplateRegExp,
|
|
12
|
-
queryParams,
|
|
14
|
+
queryParams = {},
|
|
13
15
|
}: BuildEndpointOptions,
|
|
14
16
|
) => {
|
|
15
17
|
const pathJoiner = basePath.endsWith('/') || path.startsWith('/') ? '' : '/';
|
|
@@ -25,9 +27,11 @@ export const buildEndpoint = (
|
|
|
25
27
|
endpoint = endpoint.slice(0, Math.max(0, endpoint.length - 1));
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
const sanitisedSearchParams = omitBy<PlainObject>(queryParams, entry => !entry);
|
|
31
|
+
|
|
32
|
+
if (Object.keys(sanitisedSearchParams).length > 0) {
|
|
29
33
|
const queryJoin = queryString.extract(endpoint) ? '&' : '?';
|
|
30
|
-
endpoint = `${endpoint}${queryJoin}${queryString.stringify(
|
|
34
|
+
endpoint = `${endpoint}${queryJoin}${queryString.stringify(sanitisedSearchParams)}`;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
return endpoint;
|
package/src/main.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class Getta {
|
|
|
49
49
|
private _rateLimitCount = 0;
|
|
50
50
|
private _rateLimitedRequestQueue: RequestQueue = [];
|
|
51
51
|
private _rateLimitPerSecond: number;
|
|
52
|
-
private _rateLimitTimer: NodeJS.
|
|
52
|
+
private _rateLimitTimer: NodeJS.Timeout | undefined = undefined;
|
|
53
53
|
private _requestRetryWait: number;
|
|
54
54
|
private _requestTracker: RequestTracker = { active: [], pending: new Map() };
|
|
55
55
|
private _streamReader: StreamReader;
|
|
@@ -299,7 +299,7 @@ export class Getta {
|
|
|
299
299
|
try {
|
|
300
300
|
Object.defineProperty(res, 'data', {
|
|
301
301
|
enumerable: true,
|
|
302
|
-
|
|
302
|
+
|
|
303
303
|
value: body ? this._bodyParser(await res[this._streamReader]()) : undefined,
|
|
304
304
|
writable: true,
|
|
305
305
|
});
|
|
@@ -423,11 +423,7 @@ export class Getta {
|
|
|
423
423
|
if (status === consts.NOT_FOUND_STATUS_CODE) {
|
|
424
424
|
void this._cacheEntryDelete(requestHash);
|
|
425
425
|
let { errors } = res;
|
|
426
|
-
|
|
427
|
-
if (!errors) {
|
|
428
|
-
errors = [];
|
|
429
|
-
}
|
|
430
|
-
|
|
426
|
+
errors ??= [];
|
|
431
427
|
errors.push(new Error(consts.RESOURCE_NOT_FOUND_ERROR));
|
|
432
428
|
res.errors = errors;
|
|
433
429
|
} else if (status === consts.NOT_MODIFIED_STATUS_CODE) {
|
|
@@ -524,22 +520,20 @@ export class Getta {
|
|
|
524
520
|
|
|
525
521
|
private _setPendingRequest(requestHash: string, resolver: PendingRequestResolvers) {
|
|
526
522
|
let pending = this._requestTracker.pending.get(requestHash);
|
|
527
|
-
|
|
523
|
+
pending ??= [];
|
|
528
524
|
pending.push(resolver);
|
|
529
525
|
this._requestTracker.pending.set(requestHash, pending);
|
|
530
526
|
}
|
|
531
527
|
|
|
532
528
|
private _startRateLimit() {
|
|
533
|
-
|
|
534
|
-
this._rateLimitTimer =
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}, 1000);
|
|
542
|
-
}
|
|
529
|
+
this._rateLimitTimer ??= setTimeout(() => {
|
|
530
|
+
this._rateLimitTimer = undefined;
|
|
531
|
+
this._rateLimitCount = 0;
|
|
532
|
+
|
|
533
|
+
if (this._rateLimitedRequestQueue.length > 0) {
|
|
534
|
+
void this._releaseRateLimitedRequestQueue();
|
|
535
|
+
}
|
|
536
|
+
}, 1000);
|
|
543
537
|
|
|
544
538
|
this._rateLimitCount += 1;
|
|
545
539
|
}
|