getta 1.0.6 → 1.0.8
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 +30 -30
- package/dist/types/cjs/constants.d.cts +33 -33
- package/dist/types/cjs/constants.d.cts.map +1 -1
- package/dist/types/cjs/helpers/defaultPathTemplateCallback/index.d.cts.map +1 -1
- package/dist/types/cjs/main.d.cts +1 -1
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +2 -4
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/constants.d.ts +33 -33
- package/dist/types/esm/constants.d.ts.map +1 -1
- package/dist/types/esm/helpers/defaultPathTemplateCallback/index.d.ts.map +1 -1
- package/dist/types/esm/main.d.ts +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +2 -4
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +45 -89
- package/shellScripts/installActivateMise.sh +12 -0
- package/src/__testUtils__/helpers/index.ts +1 -1
- package/src/constants.ts +27 -27
- package/src/helpers/buildEndpoint/index.ts +1 -1
- package/src/helpers/defaultPathTemplateCallback/index.test.ts +2 -2
- package/src/helpers/defaultPathTemplateCallback/index.ts +1 -1
- package/src/main.test.ts +27 -24
- package/src/main.ts +45 -35
- package/src/types.ts +6 -4
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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.8",
|
|
5
5
|
"author": "Dylan Aubrey",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/getta",
|
|
8
|
-
"repository": "
|
|
8
|
+
"repository": "badbatch/getta",
|
|
9
9
|
"bugs": "https://github.com/badbatch/getta/issues",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -25,96 +25,51 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"lodash-es": "<5"
|
|
28
|
+
"@types/lodash-es": "^4.17.12",
|
|
29
|
+
"cacheability": "^4.0.27",
|
|
30
|
+
"core-js": "^3.39.0",
|
|
31
|
+
"lodash-es": "^4.17.21",
|
|
32
|
+
"query-string": "^9.1.1",
|
|
33
|
+
"ts-md5": "^1.3.1",
|
|
34
|
+
"type-fest": "^4.26.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@babel/plugin-proposal-decorators": "^7.23.3",
|
|
42
|
-
"@babel/plugin-syntax-import-assertions": "^7.22.5",
|
|
43
|
-
"@babel/plugin-transform-class-properties": "^7.23.3",
|
|
44
|
-
"@babel/plugin-transform-export-namespace-from": "^7.23.4",
|
|
45
|
-
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
46
|
-
"@babel/plugin-transform-runtime": "^7.23.2",
|
|
47
|
-
"@babel/preset-env": "^7.23.2",
|
|
48
|
-
"@babel/preset-react": "^7.22.15",
|
|
49
|
-
"@babel/preset-typescript": "^7.23.2",
|
|
50
|
-
"@babel/runtime": "^7.23.2",
|
|
51
|
-
"@cachemap/core": "^5.0.8",
|
|
52
|
-
"@cachemap/map": "^5.0.6",
|
|
53
|
-
"@commitlint/cli": "^17.7.2",
|
|
54
|
-
"@commitlint/config-conventional": "^17.7.0",
|
|
55
|
-
"@commitlint/prompt-cli": "^17.7.2",
|
|
37
|
+
"@cachemap/core": "^5.2.2",
|
|
38
|
+
"@cachemap/map": "^5.0.8",
|
|
39
|
+
"@commitlint/cli": "^19.5.0",
|
|
56
40
|
"@jest/globals": "^29.7.0",
|
|
57
|
-
"@repodog/
|
|
58
|
-
"@repodog/
|
|
59
|
-
"@repodog/
|
|
60
|
-
"@repodog/eslint-config": "^
|
|
61
|
-
"@repodog/
|
|
62
|
-
"@repodog/
|
|
63
|
-
"@repodog/
|
|
64
|
-
"@repodog/
|
|
65
|
-
"@repodog/
|
|
66
|
-
"@repodog/syncpack-config": "^
|
|
67
|
-
"@repodog/ts-config": "^
|
|
68
|
-
"@rollup/plugin-
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
78
|
-
"@typescript-eslint/parser": "^5.62.0",
|
|
79
|
-
"babel-jest": "^29.7.0",
|
|
80
|
-
"babel-plugin-codegen": "^4.1.5",
|
|
81
|
-
"babel-plugin-macros": "^3.1.0",
|
|
82
|
-
"core-js": "^3.33.0",
|
|
83
|
-
"cts-types": "^0.0.6",
|
|
84
|
-
"del-cli": "^5.1.0",
|
|
85
|
-
"eslint": "^8.51.0",
|
|
86
|
-
"eslint-config-prettier": "^8.10.0",
|
|
87
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
88
|
-
"eslint-plugin-import": "^2.28.1",
|
|
89
|
-
"eslint-plugin-jest": "^27.4.2",
|
|
90
|
-
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
91
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
92
|
-
"eslint-plugin-sort-class-members": "^1.19.0",
|
|
93
|
-
"eslint-plugin-sort-destructure-keys": "^1.5.0",
|
|
94
|
-
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
95
|
-
"eslint-plugin-typescript-sort-keys": "^2.3.0",
|
|
96
|
-
"eslint-plugin-unicorn": "^46.0.1",
|
|
97
|
-
"fetch-mocked": "^0.0.21",
|
|
41
|
+
"@repodog/cli": "^1.6.36",
|
|
42
|
+
"@repodog/commitlint-config": "^19.0.3",
|
|
43
|
+
"@repodog/eslint-config": "^9.0.7",
|
|
44
|
+
"@repodog/eslint-config-jest": "^9.0.3",
|
|
45
|
+
"@repodog/jest-config": "^29.0.3",
|
|
46
|
+
"@repodog/markdownlint-config": "^1.2.4",
|
|
47
|
+
"@repodog/prettier-config": "^3.0.2",
|
|
48
|
+
"@repodog/rollup-config": "^4.0.3",
|
|
49
|
+
"@repodog/swc-config": "^1.0.3",
|
|
50
|
+
"@repodog/syncpack-config": "^13.0.2",
|
|
51
|
+
"@repodog/ts-config": "^5.0.4",
|
|
52
|
+
"@rollup/plugin-swc": "^0.3.0",
|
|
53
|
+
"@swc/core": "^1.7.26",
|
|
54
|
+
"@swc/jest": "^0.2.36",
|
|
55
|
+
"@types/jest": "^29.5.13",
|
|
56
|
+
"@types/node": "^22.8.7",
|
|
57
|
+
"cts-types": "^0.0.7",
|
|
58
|
+
"del-cli": "^6.0.0",
|
|
59
|
+
"eslint": "^9.11.0",
|
|
60
|
+
"fetch-mocked": "^0.0.26",
|
|
98
61
|
"generate-changelog": "^1.8.0",
|
|
99
|
-
"husky": "^
|
|
100
|
-
"identity-obj-proxy": "^3.0.0",
|
|
62
|
+
"husky": "^9.1.6",
|
|
101
63
|
"jest": "^29.7.0",
|
|
102
64
|
"jest-environment-jsdom": "^29.7.0",
|
|
103
65
|
"jest-environment-node": "^29.7.0",
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
112
|
-
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
113
|
-
"suppress-experimental-warnings": "^1.1.17",
|
|
114
|
-
"syncpack": "^12.3.0",
|
|
115
|
-
"type-fest": "^3.13.1",
|
|
116
|
-
"typescript": "^5.2.2",
|
|
117
|
-
"zod": "^3.22.4"
|
|
66
|
+
"markdownlint-cli2": "^0.14.0",
|
|
67
|
+
"prettier": "^3.3.3",
|
|
68
|
+
"rollup": "^4.22.4",
|
|
69
|
+
"suppress-experimental-warnings": "^2.0.0",
|
|
70
|
+
"syncpack": "^13.0.0",
|
|
71
|
+
"typescript": "^5.6.2",
|
|
72
|
+
"zod": "^3.23.8"
|
|
118
73
|
},
|
|
119
74
|
"keywords": [
|
|
120
75
|
"api-client",
|
|
@@ -126,17 +81,18 @@
|
|
|
126
81
|
"build": "pnpm run clean:dist && pnpm run compile",
|
|
127
82
|
"clean:deps": "del-cli ./node_modules",
|
|
128
83
|
"clean:dist": "del-cli ./dist",
|
|
129
|
-
"commit": "commit",
|
|
130
84
|
"compile": "pnpm run /^compile:.*/",
|
|
131
85
|
"compile:cjs": "MODULE_SYSTEM=cjs rollup -c ./rollup.config.cjs",
|
|
132
86
|
"compile:esm": "rollup -c ./rollup.config.cjs",
|
|
133
87
|
"compile:types": "tsc --project ./tsconfig.build.json && cts-types build dist/types/esm dist/types/cjs",
|
|
134
88
|
"cut:changelog": "changelog",
|
|
135
|
-
"
|
|
136
|
-
"lint": "
|
|
89
|
+
"installActivateMise": "sh shellScripts/installActivateMise.sh",
|
|
90
|
+
"lint": "pnpm run /^lint:.*/",
|
|
91
|
+
"lint:code": "eslint .",
|
|
92
|
+
"lint:docs": "markdownlint-cli2 --config \".markdownlint.json\" \"**/*.md\" \"!**/node_modules/**\"",
|
|
137
93
|
"repodog": "repodog",
|
|
138
94
|
"syncpack": "syncpack format && syncpack list-mismatches && syncpack lint-semver-ranges",
|
|
139
|
-
"test": "node --require=suppress-experimental-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
95
|
+
"test": "COMPILER=swc node --require=suppress-experimental-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
140
96
|
"type-check": "tsc --noEmit",
|
|
141
97
|
"validate": "pnpm run syncpack && pnpm run build && pnpm run lint && pnpm run type-check && pnpm run test"
|
|
142
98
|
}
|
|
@@ -38,7 +38,7 @@ export const getCache = () => {
|
|
|
38
38
|
|
|
39
39
|
export const buildTestEndpoint = (
|
|
40
40
|
path: string,
|
|
41
|
-
{ pathTemplateData = defaultPathTemplateData, queryParams }: RequestOptions = {}
|
|
41
|
+
{ pathTemplateData = defaultPathTemplateData, queryParams }: RequestOptions = {},
|
|
42
42
|
) =>
|
|
43
43
|
buildEndpoint(basePath, path, {
|
|
44
44
|
optionalPathTemplateRegExp: OPTIONAL_PATH_TEMPLATE_REGEX,
|
package/src/constants.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PlainObject } from './types.ts';
|
|
2
2
|
|
|
3
|
-
export const ARRAY_BUFFER_FORMAT = 'arrayBuffer'
|
|
4
|
-
export const BLOB_FORMAT = 'blob'
|
|
5
|
-
export const FORM_DATA_FORMAT = 'formData'
|
|
6
|
-
export const JSON_FORMAT = 'json'
|
|
7
|
-
export const TEXT_FORMAT = 'text'
|
|
3
|
+
export const ARRAY_BUFFER_FORMAT = 'arrayBuffer';
|
|
4
|
+
export const BLOB_FORMAT = 'blob';
|
|
5
|
+
export const FORM_DATA_FORMAT = 'formData';
|
|
6
|
+
export const JSON_FORMAT = 'json';
|
|
7
|
+
export const TEXT_FORMAT = 'text';
|
|
8
8
|
|
|
9
9
|
export const STREAM_READERS = {
|
|
10
10
|
ARRAY_BUFFER_FORMAT,
|
|
@@ -15,10 +15,10 @@ export const STREAM_READERS = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_BODY_PARSER = (body: PlainObject) => body;
|
|
18
|
-
export const DEFAULT_FETCH_TIMEOUT = 5000
|
|
18
|
+
export const DEFAULT_FETCH_TIMEOUT = 5000;
|
|
19
19
|
export const DEFAULT_HEADERS = { 'content-type': 'application/json' };
|
|
20
|
-
export const DEFAULT_MAX_REDIRECTS = 5
|
|
21
|
-
export const DEFAULT_MAX_RETRIES = 3
|
|
20
|
+
export const DEFAULT_MAX_REDIRECTS = 5;
|
|
21
|
+
export const DEFAULT_MAX_RETRIES = 3;
|
|
22
22
|
export const DEFAULT_PATH_TEMPLATE_REGEX = /({type})|({id})|({id,\+})|({brief\|standard})/g;
|
|
23
23
|
export const OPTIONAL_PATH_TEMPLATE_REGEX = /({\w+\?})/g;
|
|
24
24
|
export const DEFAULT_RATE_LIMIT = 50;
|
|
@@ -37,27 +37,27 @@ export const RESOURCE_NOT_FOUND_ERROR = 'The requested resource could not been f
|
|
|
37
37
|
|
|
38
38
|
export const FETCH_TIMEOUT_ERROR = 'The request timed out. Getta did not get a response within';
|
|
39
39
|
|
|
40
|
-
export const GET_METHOD = 'get'
|
|
41
|
-
export const POST_METHOD = 'post'
|
|
42
|
-
export const PUT_METHOD = 'put'
|
|
43
|
-
export const DELETE_METHOD = 'delete'
|
|
40
|
+
export const GET_METHOD = 'get';
|
|
41
|
+
export const POST_METHOD = 'post';
|
|
42
|
+
export const PUT_METHOD = 'put';
|
|
43
|
+
export const DELETE_METHOD = 'delete';
|
|
44
44
|
|
|
45
45
|
export const FETCH_METHODS = [GET_METHOD, POST_METHOD, PUT_METHOD, DELETE_METHOD];
|
|
46
46
|
|
|
47
|
-
export const INFORMATION_REPSONSE = 'information'
|
|
48
|
-
export const SUCCESSFUL_REPSONSE = 'successful'
|
|
49
|
-
export const REDIRECTION_REPSONSE = 'redirection'
|
|
50
|
-
export const CLIENT_ERROR_REPSONSE = 'clientError'
|
|
51
|
-
export const SERVER_ERROR_REPSONSE = 'serverError'
|
|
47
|
+
export const INFORMATION_REPSONSE = 'information';
|
|
48
|
+
export const SUCCESSFUL_REPSONSE = 'successful';
|
|
49
|
+
export const REDIRECTION_REPSONSE = 'redirection';
|
|
50
|
+
export const CLIENT_ERROR_REPSONSE = 'clientError';
|
|
51
|
+
export const SERVER_ERROR_REPSONSE = 'serverError';
|
|
52
52
|
|
|
53
|
-
export const NOT_MODIFIED_STATUS_CODE = 304
|
|
54
|
-
export const NOT_FOUND_STATUS_CODE = 404
|
|
53
|
+
export const NOT_MODIFIED_STATUS_CODE = 304;
|
|
54
|
+
export const NOT_FOUND_STATUS_CODE = 404;
|
|
55
55
|
|
|
56
|
-
export const COOKIE_HEADER = 'Cookie'
|
|
57
|
-
export const ETAG_HEADER = 'ETag'
|
|
58
|
-
export const LOCATION_HEADER = 'Location'
|
|
59
|
-
export const IF_NONE_MATCH_HEADER = 'If-None-Match'
|
|
60
|
-
export const CACHE_CONTROL_HEADER = 'Cache-Control'
|
|
56
|
+
export const COOKIE_HEADER = 'Cookie';
|
|
57
|
+
export const ETAG_HEADER = 'ETag';
|
|
58
|
+
export const LOCATION_HEADER = 'Location';
|
|
59
|
+
export const IF_NONE_MATCH_HEADER = 'If-None-Match';
|
|
60
|
+
export const CACHE_CONTROL_HEADER = 'Cache-Control';
|
|
61
61
|
|
|
62
|
-
export const REQUEST_SENT = 'request_sent'
|
|
63
|
-
export const RESPONSE_RECEIVED = 'response_received'
|
|
62
|
+
export const REQUEST_SENT = 'request_sent';
|
|
63
|
+
export const RESPONSE_RECEIVED = 'response_received';
|
|
@@ -10,7 +10,7 @@ export const buildEndpoint = (
|
|
|
10
10
|
pathTemplateData,
|
|
11
11
|
pathTemplateRegExp,
|
|
12
12
|
queryParams,
|
|
13
|
-
}: BuildEndpointOptions
|
|
13
|
+
}: BuildEndpointOptions,
|
|
14
14
|
) => {
|
|
15
15
|
const pathJoiner = basePath.endsWith('/') || path.startsWith('/') ? '' : '/';
|
|
16
16
|
let endpoint = `${basePath}${pathJoiner}${path}`;
|
|
@@ -5,13 +5,13 @@ import { defaultPathTemplateCallback } from './index.ts';
|
|
|
5
5
|
describe('defaultPathTemplateCallback', () => {
|
|
6
6
|
it('SHOULD populate the path template correctly', () => {
|
|
7
7
|
expect(defaultPathTemplateCallback(defaultPath, defaultPathTemplateData, DEFAULT_PATH_TEMPLATE_REGEX)).toBe(
|
|
8
|
-
'/direct/rest/content/catalog/product/136-7317?format=standard'
|
|
8
|
+
'/direct/rest/content/catalog/product/136-7317?format=standard',
|
|
9
9
|
);
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it('SHOULD populate the path template correctly when the data value is a zero', () => {
|
|
13
13
|
expect(
|
|
14
|
-
defaultPathTemplateCallback(defaultPath, { ...defaultPathTemplateData, 'id,+': 0 }, DEFAULT_PATH_TEMPLATE_REGEX)
|
|
14
|
+
defaultPathTemplateCallback(defaultPath, { ...defaultPathTemplateData, 'id,+': 0 }, DEFAULT_PATH_TEMPLATE_REGEX),
|
|
15
15
|
).toBe('/direct/rest/content/catalog/product/0?format=standard');
|
|
16
16
|
});
|
|
17
17
|
});
|
package/src/main.test.ts
CHANGED
|
@@ -50,7 +50,7 @@ describe('Getta', () => {
|
|
|
50
50
|
pathTemplateData: pathTemplateDataWithoutID,
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
54
|
);
|
|
55
55
|
});
|
|
56
56
|
|
|
@@ -76,7 +76,7 @@ describe('Getta', () => {
|
|
|
76
76
|
expect(response).toEqual(
|
|
77
77
|
expect.objectContaining({
|
|
78
78
|
data: PRD_136_7317.body,
|
|
79
|
-
})
|
|
79
|
+
}),
|
|
80
80
|
);
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -99,7 +99,7 @@ describe('Getta', () => {
|
|
|
99
99
|
expect(response).toEqual(
|
|
100
100
|
expect.objectContaining({
|
|
101
101
|
data: PRD_136_7317.body,
|
|
102
|
-
})
|
|
102
|
+
}),
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
});
|
|
@@ -125,7 +125,7 @@ describe('Getta', () => {
|
|
|
125
125
|
expect(response).toEqual(
|
|
126
126
|
expect.objectContaining({
|
|
127
127
|
data: PRD_136_7317.body,
|
|
128
|
-
})
|
|
128
|
+
}),
|
|
129
129
|
);
|
|
130
130
|
});
|
|
131
131
|
});
|
|
@@ -146,7 +146,7 @@ describe('Getta', () => {
|
|
|
146
146
|
beforeEach(async () => {
|
|
147
147
|
mockedFetch.mockGetOnce(
|
|
148
148
|
{ headers: { [consts.IF_NONE_MATCH_HEADER]: defaultEtag }, url: buildTestEndpoint(defaultPath) },
|
|
149
|
-
{ headers: defaultHeaders, status: 304 }
|
|
149
|
+
{ headers: defaultHeaders, status: 304 },
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
response = await restClient.getProduct({ pathTemplateData: idPathTemplateData });
|
|
@@ -160,7 +160,7 @@ describe('Getta', () => {
|
|
|
160
160
|
expect(response).toEqual(
|
|
161
161
|
expect.objectContaining({
|
|
162
162
|
data: PRD_136_7317.body,
|
|
163
|
-
})
|
|
163
|
+
}),
|
|
164
164
|
);
|
|
165
165
|
});
|
|
166
166
|
});
|
|
@@ -169,7 +169,7 @@ describe('Getta', () => {
|
|
|
169
169
|
beforeEach(async () => {
|
|
170
170
|
mockedFetch.mockGetOnce(
|
|
171
171
|
{ headers: { [consts.IF_NONE_MATCH_HEADER]: defaultEtag }, url: buildTestEndpoint(defaultPath) },
|
|
172
|
-
{ body: PRD_136_7317.body, headers: defaultHeaders }
|
|
172
|
+
{ body: PRD_136_7317.body, headers: defaultHeaders },
|
|
173
173
|
);
|
|
174
174
|
|
|
175
175
|
response = await restClient.getProduct({ pathTemplateData: idPathTemplateData });
|
|
@@ -183,7 +183,7 @@ describe('Getta', () => {
|
|
|
183
183
|
expect(response).toEqual(
|
|
184
184
|
expect.objectContaining({
|
|
185
185
|
data: PRD_136_7317.body,
|
|
186
|
-
})
|
|
186
|
+
}),
|
|
187
187
|
);
|
|
188
188
|
});
|
|
189
189
|
});
|
|
@@ -192,7 +192,7 @@ describe('Getta', () => {
|
|
|
192
192
|
beforeEach(async () => {
|
|
193
193
|
mockedFetch.mockGetOnce(
|
|
194
194
|
{ headers: { [consts.IF_NONE_MATCH_HEADER]: defaultEtag }, url: buildTestEndpoint(defaultPath) },
|
|
195
|
-
{ status: 404 }
|
|
195
|
+
{ status: 404 },
|
|
196
196
|
);
|
|
197
197
|
|
|
198
198
|
response = await restClient.getProduct({ pathTemplateData: idPathTemplateData });
|
|
@@ -206,7 +206,7 @@ describe('Getta', () => {
|
|
|
206
206
|
expect(response).toEqual(
|
|
207
207
|
expect.objectContaining({
|
|
208
208
|
errors: [new Error(consts.RESOURCE_NOT_FOUND_ERROR)],
|
|
209
|
-
})
|
|
209
|
+
}),
|
|
210
210
|
);
|
|
211
211
|
});
|
|
212
212
|
});
|
|
@@ -219,7 +219,7 @@ describe('Getta', () => {
|
|
|
219
219
|
beforeEach(async () => {
|
|
220
220
|
mockedFetch.mockGet(
|
|
221
221
|
{ headers: { [consts.COOKIE_HEADER]: REDIRECT_COOKIE_FLAG }, url: '*' },
|
|
222
|
-
{ headers: { ...defaultHeaders, [consts.LOCATION_HEADER]: basePath }, status: 301 }
|
|
222
|
+
{ headers: { ...defaultHeaders, [consts.LOCATION_HEADER]: basePath }, status: 301 },
|
|
223
223
|
);
|
|
224
224
|
|
|
225
225
|
response = await restClient.getProduct({
|
|
@@ -236,7 +236,7 @@ describe('Getta', () => {
|
|
|
236
236
|
expect(response).toEqual(
|
|
237
237
|
expect.objectContaining({
|
|
238
238
|
errors: [new Error(`${consts.MAX_REDIRECTS_EXCEEDED_ERROR} 5.`)],
|
|
239
|
-
})
|
|
239
|
+
}),
|
|
240
240
|
);
|
|
241
241
|
});
|
|
242
242
|
});
|
|
@@ -247,7 +247,7 @@ describe('Getta', () => {
|
|
|
247
247
|
beforeEach(async () => {
|
|
248
248
|
mockedFetch.mockGet(
|
|
249
249
|
{ headers: { [consts.COOKIE_HEADER]: RETRY_COOKIE_FLAG }, url: buildTestEndpoint(defaultPath) },
|
|
250
|
-
{ body: PRD_136_7317.body, status: 500 }
|
|
250
|
+
{ body: PRD_136_7317.body, status: 500 },
|
|
251
251
|
);
|
|
252
252
|
|
|
253
253
|
response = await restClient.getProduct({
|
|
@@ -264,7 +264,7 @@ describe('Getta', () => {
|
|
|
264
264
|
expect(response).toEqual(
|
|
265
265
|
expect.objectContaining({
|
|
266
266
|
errors: [new Error(`${consts.MAX_RETRIES_EXCEEDED_ERROR} 3.`)],
|
|
267
|
-
})
|
|
267
|
+
}),
|
|
268
268
|
);
|
|
269
269
|
});
|
|
270
270
|
});
|
|
@@ -314,7 +314,7 @@ describe('Getta', () => {
|
|
|
314
314
|
expect(response).toEqual(
|
|
315
315
|
expect.objectContaining({
|
|
316
316
|
errors: [new Error(`${consts.FETCH_TIMEOUT_ERROR} 100ms.`)],
|
|
317
|
-
})
|
|
317
|
+
}),
|
|
318
318
|
);
|
|
319
319
|
});
|
|
320
320
|
});
|
|
@@ -334,7 +334,7 @@ describe('Getta', () => {
|
|
|
334
334
|
method: consts.POST_METHOD,
|
|
335
335
|
},
|
|
336
336
|
],
|
|
337
|
-
}
|
|
337
|
+
},
|
|
338
338
|
);
|
|
339
339
|
});
|
|
340
340
|
|
|
@@ -346,7 +346,7 @@ describe('Getta', () => {
|
|
|
346
346
|
beforeEach(async () => {
|
|
347
347
|
mockedFetch.mockPostOnce(
|
|
348
348
|
{ body: { mock: true }, url: buildTestEndpoint(graphqlPath) },
|
|
349
|
-
{ body: PRD_136_7317.body, headers: defaultHeaders }
|
|
349
|
+
{ body: PRD_136_7317.body, headers: defaultHeaders },
|
|
350
350
|
);
|
|
351
351
|
|
|
352
352
|
response = await restClient.post(graphqlPath, {
|
|
@@ -362,7 +362,7 @@ describe('Getta', () => {
|
|
|
362
362
|
expect(response).toEqual(
|
|
363
363
|
expect.objectContaining({
|
|
364
364
|
data: PRD_136_7317.body,
|
|
365
|
-
})
|
|
365
|
+
}),
|
|
366
366
|
);
|
|
367
367
|
});
|
|
368
368
|
});
|
|
@@ -371,7 +371,7 @@ describe('Getta', () => {
|
|
|
371
371
|
beforeEach(async () => {
|
|
372
372
|
mockedFetch.mockPostOnce(
|
|
373
373
|
{ body: { mock: true }, url: buildTestEndpoint(graphqlPath) },
|
|
374
|
-
{ body: PRD_136_7317.body, headers: defaultHeaders }
|
|
374
|
+
{ body: PRD_136_7317.body, headers: defaultHeaders },
|
|
375
375
|
);
|
|
376
376
|
|
|
377
377
|
response = await restClient.postProduct({ body: JSON.stringify({ ...defaultPayload, mock: true }) });
|
|
@@ -385,7 +385,7 @@ describe('Getta', () => {
|
|
|
385
385
|
expect(response).toEqual(
|
|
386
386
|
expect.objectContaining({
|
|
387
387
|
data: PRD_136_7317.body,
|
|
388
|
-
})
|
|
388
|
+
}),
|
|
389
389
|
);
|
|
390
390
|
});
|
|
391
391
|
});
|
|
@@ -406,7 +406,7 @@ describe('Getta', () => {
|
|
|
406
406
|
pathTemplateData: pathTemplateDataWithoutID,
|
|
407
407
|
},
|
|
408
408
|
],
|
|
409
|
-
}
|
|
409
|
+
},
|
|
410
410
|
);
|
|
411
411
|
});
|
|
412
412
|
|
|
@@ -486,7 +486,7 @@ describe('Getta', () => {
|
|
|
486
486
|
pathTemplateData: pathTemplateDataWithoutID,
|
|
487
487
|
},
|
|
488
488
|
],
|
|
489
|
-
}
|
|
489
|
+
},
|
|
490
490
|
);
|
|
491
491
|
});
|
|
492
492
|
|
|
@@ -551,12 +551,15 @@ describe('Getta', () => {
|
|
|
551
551
|
const requestKeys = [...Array.from({ length: 55 }).keys()];
|
|
552
552
|
|
|
553
553
|
for (const key of requestKeys) {
|
|
554
|
-
mockedFetch.mockGetOnce(buildTestEndpoint(`product/${key}`));
|
|
554
|
+
mockedFetch.mockGetOnce(buildTestEndpoint(`product/${String(key)}`));
|
|
555
555
|
}
|
|
556
556
|
|
|
557
557
|
// @ts-expect-error property is private
|
|
558
558
|
restClient._addRequestToRateLimitedQueue = jest.fn().mockResolvedValue({ status: 200 });
|
|
559
|
-
|
|
559
|
+
|
|
560
|
+
await Promise.all(
|
|
561
|
+
requestKeys.map(key => restClient.get(`product/${String(key)}`, { headers: defaultHeaders })),
|
|
562
|
+
);
|
|
560
563
|
});
|
|
561
564
|
|
|
562
565
|
it('should call fetch one less than the rate limit', () => {
|