@digipair/skill-http 0.48.1 → 0.49.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.
package/index.cjs.js CHANGED
@@ -14,8 +14,9 @@ function _extends() {
14
14
  }
15
15
 
16
16
  let HttpService = class HttpService {
17
- async call(url, method, data = null, headers = {}) {
17
+ async call(url, method, data, headers, signal) {
18
18
  const response = await fetch(url, {
19
+ signal,
19
20
  method,
20
21
  headers: _extends({
21
22
  Accept: this.IS_JSON ? 'application/json' : '*/*'
@@ -27,31 +28,38 @@ let HttpService = class HttpService {
27
28
  if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
28
29
  return this.IS_JSON ? response.json() : response.text();
29
30
  }
30
- async create(params, _pinsSettingsList, _context) {
31
+ async create(params, _pinsSettingsList, context) {
32
+ var _context_protected;
31
33
  const { path, body = {}, headers = {} } = params;
32
- return await this.call(path, 'POST', body, headers);
34
+ return await this.call(path, 'POST', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
33
35
  }
34
- async read(params, _pinsSettingsList, _context) {
36
+ async read(params, _pinsSettingsList, context) {
37
+ var _context_protected;
35
38
  const { path, headers = {} } = params;
36
- return await this.call(path, 'GET', null, headers);
39
+ return await this.call(path, 'GET', null, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
37
40
  }
38
- async update(params, _pinsSettingsList, _context) {
41
+ async update(params, _pinsSettingsList, context) {
42
+ var _context_protected;
39
43
  const { path, body = {}, headers = {} } = params;
40
- return await this.call(path, 'PUT', body, headers);
44
+ return await this.call(path, 'PUT', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
41
45
  }
42
- async partialUpdate(params, _pinsSettingsList, _context) {
46
+ async partialUpdate(params, _pinsSettingsList, context) {
47
+ var _context_protected;
43
48
  const { path, body = {}, headers = {} } = params;
44
- return await this.call(path, 'PATCH', body, headers);
49
+ return await this.call(path, 'PATCH', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
45
50
  }
46
- async remove(params, _pinsSettingsList, _context) {
51
+ async remove(params, _pinsSettingsList, context) {
52
+ var _context_protected;
47
53
  const { path, headers = {} } = params;
48
- return await this.call(path, 'DELETE', null, headers);
54
+ return await this.call(path, 'DELETE', null, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
49
55
  }
50
- async request(params, _pinsSettingsList, _context) {
56
+ async request(params, _pinsSettingsList, context) {
57
+ var _context_protected;
51
58
  const { path, method = 'GET', body = null, headers = {} } = params;
52
- return await this.call(path, method, body, headers);
59
+ return await this.call(path, method, body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
53
60
  }
54
- async upload(params, _pinsSettingsList, _context) {
61
+ async upload(params, _pinsSettingsList, context) {
62
+ var _context_protected;
55
63
  const { path, parameters, method = 'POST', headers = {} } = params;
56
64
  const formData = typeof window !== 'undefined' ? new FormData() : new (require('form-data'))();
57
65
  // Ajout des paramètres au FormData
@@ -67,6 +75,7 @@ let HttpService = class HttpService {
67
75
  }
68
76
  });
69
77
  const response = await fetch(path, {
78
+ signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
70
79
  method,
71
80
  headers: _extends({}, formData.getHeaders(), {
72
81
  Accept: this.IS_JSON ? 'application/json' : '*/*'
package/index.esm.js CHANGED
@@ -10,8 +10,9 @@ function _extends() {
10
10
  }
11
11
 
12
12
  let HttpService = class HttpService {
13
- async call(url, method, data = null, headers = {}) {
13
+ async call(url, method, data, headers, signal) {
14
14
  const response = await fetch(url, {
15
+ signal,
15
16
  method,
16
17
  headers: _extends({
17
18
  Accept: this.IS_JSON ? 'application/json' : '*/*'
@@ -23,31 +24,38 @@ let HttpService = class HttpService {
23
24
  if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
24
25
  return this.IS_JSON ? response.json() : response.text();
25
26
  }
26
- async create(params, _pinsSettingsList, _context) {
27
+ async create(params, _pinsSettingsList, context) {
28
+ var _context_protected;
27
29
  const { path, body = {}, headers = {} } = params;
28
- return await this.call(path, 'POST', body, headers);
30
+ return await this.call(path, 'POST', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
29
31
  }
30
- async read(params, _pinsSettingsList, _context) {
32
+ async read(params, _pinsSettingsList, context) {
33
+ var _context_protected;
31
34
  const { path, headers = {} } = params;
32
- return await this.call(path, 'GET', null, headers);
35
+ return await this.call(path, 'GET', null, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
33
36
  }
34
- async update(params, _pinsSettingsList, _context) {
37
+ async update(params, _pinsSettingsList, context) {
38
+ var _context_protected;
35
39
  const { path, body = {}, headers = {} } = params;
36
- return await this.call(path, 'PUT', body, headers);
40
+ return await this.call(path, 'PUT', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
37
41
  }
38
- async partialUpdate(params, _pinsSettingsList, _context) {
42
+ async partialUpdate(params, _pinsSettingsList, context) {
43
+ var _context_protected;
39
44
  const { path, body = {}, headers = {} } = params;
40
- return await this.call(path, 'PATCH', body, headers);
45
+ return await this.call(path, 'PATCH', body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
41
46
  }
42
- async remove(params, _pinsSettingsList, _context) {
47
+ async remove(params, _pinsSettingsList, context) {
48
+ var _context_protected;
43
49
  const { path, headers = {} } = params;
44
- return await this.call(path, 'DELETE', null, headers);
50
+ return await this.call(path, 'DELETE', null, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
45
51
  }
46
- async request(params, _pinsSettingsList, _context) {
52
+ async request(params, _pinsSettingsList, context) {
53
+ var _context_protected;
47
54
  const { path, method = 'GET', body = null, headers = {} } = params;
48
- return await this.call(path, method, body, headers);
55
+ return await this.call(path, method, body, headers, (_context_protected = context.protected) == null ? void 0 : _context_protected.signal);
49
56
  }
50
- async upload(params, _pinsSettingsList, _context) {
57
+ async upload(params, _pinsSettingsList, context) {
58
+ var _context_protected;
51
59
  const { path, parameters, method = 'POST', headers = {} } = params;
52
60
  const formData = typeof window !== 'undefined' ? new FormData() : new (require('form-data'))();
53
61
  // Ajout des paramètres au FormData
@@ -63,6 +71,7 @@ let HttpService = class HttpService {
63
71
  }
64
72
  });
65
73
  const response = await fetch(path, {
74
+ signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
66
75
  method,
67
76
  headers: _extends({}, formData.getHeaders(), {
68
77
  Accept: this.IS_JSON ? 'application/json' : '*/*'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-http",
3
- "version": "0.48.1",
3
+ "version": "0.49.0",
4
4
  "dependencies": {
5
5
  "form-data": "4.0.1"
6
6
  },
File without changes