@algolia/requester-fetch 5.1.0 → 5.2.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.
@@ -9,7 +9,7 @@ function getErrorMessage(error, abortContent) {
9
9
  }
10
10
  return error instanceof Error ? error.message : 'Network request failed';
11
11
  }
12
- function createFetchRequester({ requesterOptions = {}, } = {}) {
12
+ function createFetchRequester({ requesterOptions = {} } = {}) {
13
13
  async function send(request) {
14
14
  const abortController = new AbortController();
15
15
  const signal = abortController.signal;
@@ -7,7 +7,7 @@ function getErrorMessage(error, abortContent) {
7
7
  }
8
8
  return error instanceof Error ? error.message : 'Network request failed';
9
9
  }
10
- function createFetchRequester({ requesterOptions = {}, } = {}) {
10
+ function createFetchRequester({ requesterOptions = {} } = {}) {
11
11
  async function send(request) {
12
12
  const abortController = new AbortController();
13
13
  const signal = abortController.signal;
@@ -2,5 +2,5 @@ import type { Requester } from '@algolia/client-common';
2
2
  export type FetchRequesterOptions = {
3
3
  readonly requesterOptions?: RequestInit;
4
4
  };
5
- export declare function createFetchRequester({ requesterOptions, }?: FetchRequesterOptions): Requester;
5
+ export declare function createFetchRequester({ requesterOptions }?: FetchRequesterOptions): Requester;
6
6
  //# sourceMappingURL=createFetchRequester.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createFetchRequester.d.ts","sourceRoot":"","sources":["../../src/createFetchRequester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EAEV,MAAM,wBAAwB,CAAC;AAahC,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC;CACzC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,gBAAqB,GACtB,GAAE,qBAA0B,GAAG,SAAS,CAwDxC"}
1
+ {"version":3,"file":"createFetchRequester.d.ts","sourceRoot":"","sources":["../../src/createFetchRequester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAA+B,MAAM,wBAAwB,CAAC;AAajG,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC;CACzC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EAAE,gBAAqB,EAAE,GAAE,qBAA0B,GAAG,SAAS,CAwDrG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/requester-fetch",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "description": "Promise-based request library using Fetch.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,17 +23,17 @@
23
23
  "test": "jest"
24
24
  },
25
25
  "dependencies": {
26
- "@algolia/client-common": "5.1.0"
26
+ "@algolia/client-common": "5.2.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@babel/preset-env": "7.25.3",
29
+ "@babel/preset-env": "7.25.4",
30
30
  "@babel/preset-typescript": "7.24.7",
31
31
  "@types/jest": "29.5.12",
32
- "@types/node": "20.14.14",
32
+ "@types/node": "22.5.0",
33
33
  "cross-fetch": "4.0.0",
34
34
  "jest": "29.7.0",
35
- "nock": "13.5.4",
36
- "ts-jest": "29.2.4",
35
+ "nock": "13.5.5",
36
+ "ts-jest": "29.2.5",
37
37
  "typescript": "5.5.4"
38
38
  },
39
39
  "engines": {
@@ -32,10 +32,7 @@ describe('status code handling', () => {
32
32
  it('sends requests', async () => {
33
33
  const body = getStringifiedBody();
34
34
 
35
- nock(testQueryBaseUrl, { reqheaders: headers })
36
- .post('/foo')
37
- .query(testQueryHeader)
38
- .reply(200, body);
35
+ nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, body);
39
36
 
40
37
  const response = await requester.send(requestStub);
41
38
 
@@ -45,10 +42,7 @@ describe('status code handling', () => {
45
42
  it('resolves status 200', async () => {
46
43
  const body = getStringifiedBody();
47
44
 
48
- nock(testQueryBaseUrl, { reqheaders: headers })
49
- .post('/foo')
50
- .query(testQueryHeader)
51
- .reply(200, body);
45
+ nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, body);
52
46
 
53
47
  const response = await requester.send(requestStub);
54
48
 
@@ -60,10 +54,7 @@ describe('status code handling', () => {
60
54
  it('resolves status 300', async () => {
61
55
  const reason = 'Multiple Choices';
62
56
 
63
- nock(testQueryBaseUrl, { reqheaders: headers })
64
- .post('/foo')
65
- .query(testQueryHeader)
66
- .reply(300, reason);
57
+ nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(300, reason);
67
58
 
68
59
  const response = await requester.send(requestStub);
69
60
 
@@ -77,10 +68,7 @@ describe('status code handling', () => {
77
68
  message: 'Invalid Application-Id or API-Key',
78
69
  });
79
70
 
80
- nock(testQueryBaseUrl, { reqheaders: headers })
81
- .post('/foo')
82
- .query(testQueryHeader)
83
- .reply(400, body);
71
+ nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(400, body);
84
72
 
85
73
  const response = await requester.send(requestStub);
86
74
 
@@ -101,10 +89,7 @@ describe('status code handling', () => {
101
89
 
102
90
  const testStream = Readable.from(generate());
103
91
 
104
- nock(testQueryBaseUrl, { reqheaders: headers })
105
- .post('/foo')
106
- .query(testQueryHeader)
107
- .reply(200, testStream);
92
+ nock(testQueryBaseUrl, { reqheaders: headers }).post('/foo').query(testQueryHeader).reply(200, testStream);
108
93
 
109
94
  const response = await requester.send(requestStub);
110
95
 
@@ -232,7 +217,7 @@ describe('error handling', (): void => {
232
217
 
233
218
  expect(response.status).toBe(0);
234
219
  expect(response.content).toBe(
235
- 'request to https://algolia-dns.net/foo?x-algolia-header=bar failed, reason: This is a general error'
220
+ 'request to https://algolia-dns.net/foo?x-algolia-header=bar failed, reason: This is a general error',
236
221
  );
237
222
  expect(response.isTimedOut).toBe(false);
238
223
  });
@@ -1,8 +1,4 @@
1
- import type {
2
- EndRequest,
3
- Requester,
4
- Response as AlgoliaResponse,
5
- } from '@algolia/client-common';
1
+ import type { EndRequest, Requester, Response as AlgoliaResponse } from '@algolia/client-common';
6
2
 
7
3
  function isAbortError(error: unknown): boolean {
8
4
  return error instanceof Error && error.name === 'AbortError';
@@ -19,9 +15,7 @@ export type FetchRequesterOptions = {
19
15
  readonly requesterOptions?: RequestInit;
20
16
  };
21
17
 
22
- export function createFetchRequester({
23
- requesterOptions = {},
24
- }: FetchRequesterOptions = {}): Requester {
18
+ export function createFetchRequester({ requesterOptions = {} }: FetchRequesterOptions = {}): Requester {
25
19
  async function send(request: EndRequest): Promise<AlgoliaResponse> {
26
20
  const abortController = new AbortController();
27
21
  const signal = abortController.signal;