@digipair/skill-http 0.62.0 → 0.63.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.
- package/index.cjs.js +26 -6
- package/index.esm.js +26 -6
- package/package.json +1 -1
- package/schema.fr.json +28 -28
- package/schema.json +28 -28
package/index.cjs.js
CHANGED
|
@@ -16,10 +16,11 @@ function _extends() {
|
|
|
16
16
|
let HttpService = class HttpService {
|
|
17
17
|
async call(url, method, data, headers, signal) {
|
|
18
18
|
const requestHeaders = _extends({
|
|
19
|
-
Accept: this.
|
|
19
|
+
Accept: this.type === 'json' ? 'application/json' : '*/*'
|
|
20
20
|
}, data ? {
|
|
21
21
|
'Content-Type': 'application/json'
|
|
22
22
|
} : {}, headers);
|
|
23
|
+
let result;
|
|
23
24
|
let body = undefined;
|
|
24
25
|
if (requestHeaders['Content-Type'] === 'application/json') {
|
|
25
26
|
body = JSON.stringify(data);
|
|
@@ -36,7 +37,16 @@ let HttpService = class HttpService {
|
|
|
36
37
|
body
|
|
37
38
|
});
|
|
38
39
|
if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
|
|
39
|
-
|
|
40
|
+
if (this.type === 'json') {
|
|
41
|
+
result = await response.json();
|
|
42
|
+
} else if (this.type === 'text') {
|
|
43
|
+
result = await response.text();
|
|
44
|
+
} else {
|
|
45
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
46
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
47
|
+
result = buffer.toString('base64');
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
40
50
|
}
|
|
41
51
|
async create(params, _pinsSettingsList, context) {
|
|
42
52
|
var _context_protected;
|
|
@@ -72,6 +82,7 @@ let HttpService = class HttpService {
|
|
|
72
82
|
var _context_protected;
|
|
73
83
|
const { path, parameters, method = 'POST', headers = {} } = params;
|
|
74
84
|
const formData = typeof window !== 'undefined' ? new FormData() : new (require('form-data'))();
|
|
85
|
+
let result;
|
|
75
86
|
// Ajout des paramètres au FormData
|
|
76
87
|
parameters.forEach((param)=>{
|
|
77
88
|
if (!Array.isArray(param.value)) {
|
|
@@ -88,12 +99,21 @@ let HttpService = class HttpService {
|
|
|
88
99
|
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
89
100
|
method,
|
|
90
101
|
headers: _extends({}, formData.getHeaders(), {
|
|
91
|
-
Accept: this.
|
|
102
|
+
Accept: this.type === 'json' ? 'application/json' : '*/*'
|
|
92
103
|
}, headers),
|
|
93
104
|
body: formData.getBuffer()
|
|
94
105
|
});
|
|
95
106
|
if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
|
|
96
|
-
|
|
107
|
+
if (this.type === 'json') {
|
|
108
|
+
result = await response.json();
|
|
109
|
+
} else if (this.type === 'text') {
|
|
110
|
+
result = await response.text();
|
|
111
|
+
} else {
|
|
112
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
113
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
114
|
+
result = buffer.toString('base64');
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
97
117
|
}
|
|
98
118
|
appendParam(formData, param) {
|
|
99
119
|
if (param.type == 'text') {
|
|
@@ -113,8 +133,8 @@ let HttpService = class HttpService {
|
|
|
113
133
|
}
|
|
114
134
|
}
|
|
115
135
|
constructor(_context, params){
|
|
116
|
-
const {
|
|
117
|
-
this.
|
|
136
|
+
const { type = 'json' } = params;
|
|
137
|
+
this.type = type;
|
|
118
138
|
}
|
|
119
139
|
};
|
|
120
140
|
const create = (params, pinsSettingsList, context)=>new HttpService(context, params).create(params, pinsSettingsList, context);
|
package/index.esm.js
CHANGED
|
@@ -12,10 +12,11 @@ function _extends() {
|
|
|
12
12
|
let HttpService = class HttpService {
|
|
13
13
|
async call(url, method, data, headers, signal) {
|
|
14
14
|
const requestHeaders = _extends({
|
|
15
|
-
Accept: this.
|
|
15
|
+
Accept: this.type === 'json' ? 'application/json' : '*/*'
|
|
16
16
|
}, data ? {
|
|
17
17
|
'Content-Type': 'application/json'
|
|
18
18
|
} : {}, headers);
|
|
19
|
+
let result;
|
|
19
20
|
let body = undefined;
|
|
20
21
|
if (requestHeaders['Content-Type'] === 'application/json') {
|
|
21
22
|
body = JSON.stringify(data);
|
|
@@ -32,7 +33,16 @@ let HttpService = class HttpService {
|
|
|
32
33
|
body
|
|
33
34
|
});
|
|
34
35
|
if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
|
|
35
|
-
|
|
36
|
+
if (this.type === 'json') {
|
|
37
|
+
result = await response.json();
|
|
38
|
+
} else if (this.type === 'text') {
|
|
39
|
+
result = await response.text();
|
|
40
|
+
} else {
|
|
41
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
42
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
43
|
+
result = buffer.toString('base64');
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
36
46
|
}
|
|
37
47
|
async create(params, _pinsSettingsList, context) {
|
|
38
48
|
var _context_protected;
|
|
@@ -68,6 +78,7 @@ let HttpService = class HttpService {
|
|
|
68
78
|
var _context_protected;
|
|
69
79
|
const { path, parameters, method = 'POST', headers = {} } = params;
|
|
70
80
|
const formData = typeof window !== 'undefined' ? new FormData() : new (require('form-data'))();
|
|
81
|
+
let result;
|
|
71
82
|
// Ajout des paramètres au FormData
|
|
72
83
|
parameters.forEach((param)=>{
|
|
73
84
|
if (!Array.isArray(param.value)) {
|
|
@@ -84,12 +95,21 @@ let HttpService = class HttpService {
|
|
|
84
95
|
signal: (_context_protected = context.protected) == null ? void 0 : _context_protected.signal,
|
|
85
96
|
method,
|
|
86
97
|
headers: _extends({}, formData.getHeaders(), {
|
|
87
|
-
Accept: this.
|
|
98
|
+
Accept: this.type === 'json' ? 'application/json' : '*/*'
|
|
88
99
|
}, headers),
|
|
89
100
|
body: formData.getBuffer()
|
|
90
101
|
});
|
|
91
102
|
if (!response.ok) throw new Error('[SKILL-HTTP] REQUEST FAILED: ' + response.status);
|
|
92
|
-
|
|
103
|
+
if (this.type === 'json') {
|
|
104
|
+
result = await response.json();
|
|
105
|
+
} else if (this.type === 'text') {
|
|
106
|
+
result = await response.text();
|
|
107
|
+
} else {
|
|
108
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
109
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
110
|
+
result = buffer.toString('base64');
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
93
113
|
}
|
|
94
114
|
appendParam(formData, param) {
|
|
95
115
|
if (param.type == 'text') {
|
|
@@ -109,8 +129,8 @@ let HttpService = class HttpService {
|
|
|
109
129
|
}
|
|
110
130
|
}
|
|
111
131
|
constructor(_context, params){
|
|
112
|
-
const {
|
|
113
|
-
this.
|
|
132
|
+
const { type = 'json' } = params;
|
|
133
|
+
this.type = type;
|
|
114
134
|
}
|
|
115
135
|
};
|
|
116
136
|
const create = (params, pinsSettingsList, context)=>new HttpService(context, params).create(params, pinsSettingsList, context);
|
package/package.json
CHANGED
package/schema.fr.json
CHANGED
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
"name": "
|
|
54
|
-
"summary": "
|
|
53
|
+
"name": "type",
|
|
54
|
+
"summary": "Type de réponse",
|
|
55
55
|
"required": false,
|
|
56
|
-
"description": "
|
|
56
|
+
"description": "Type de réponse attendu",
|
|
57
57
|
"schema": {
|
|
58
|
-
"type": "
|
|
58
|
+
"type": "string"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
],
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
|
-
"name": "
|
|
99
|
-
"summary": "
|
|
98
|
+
"name": "type",
|
|
99
|
+
"summary": "Type de réponse",
|
|
100
100
|
"required": false,
|
|
101
|
-
"description": "
|
|
101
|
+
"description": "Type de réponse attendu",
|
|
102
102
|
"schema": {
|
|
103
|
-
"type": "
|
|
103
|
+
"type": "string"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
],
|
|
@@ -131,12 +131,12 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
|
-
"name": "
|
|
135
|
-
"summary": "
|
|
134
|
+
"name": "type",
|
|
135
|
+
"summary": "Type de réponse",
|
|
136
136
|
"required": false,
|
|
137
|
-
"description": "
|
|
137
|
+
"description": "Type de réponse attendu",
|
|
138
138
|
"schema": {
|
|
139
|
-
"type": "
|
|
139
|
+
"type": "string"
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
],
|
|
@@ -176,12 +176,12 @@
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
|
-
"name": "
|
|
180
|
-
"summary": "
|
|
179
|
+
"name": "type",
|
|
180
|
+
"summary": "Type de réponse",
|
|
181
181
|
"required": false,
|
|
182
|
-
"description": "
|
|
182
|
+
"description": "Type de réponse attendu",
|
|
183
183
|
"schema": {
|
|
184
|
-
"type": "
|
|
184
|
+
"type": "string"
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
],
|
|
@@ -221,12 +221,12 @@
|
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
|
-
"name": "
|
|
225
|
-
"summary": "
|
|
224
|
+
"name": "type",
|
|
225
|
+
"summary": "Type de réponse",
|
|
226
226
|
"required": false,
|
|
227
|
-
"description": "
|
|
227
|
+
"description": "Type de réponse attendu",
|
|
228
228
|
"schema": {
|
|
229
|
-
"type": "
|
|
229
|
+
"type": "string"
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
],
|
|
@@ -257,12 +257,12 @@
|
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
|
-
"name": "
|
|
261
|
-
"summary": "
|
|
260
|
+
"name": "type",
|
|
261
|
+
"summary": "Type de réponse",
|
|
262
262
|
"required": false,
|
|
263
|
-
"description": "
|
|
263
|
+
"description": "Type de réponse attendu",
|
|
264
264
|
"schema": {
|
|
265
|
-
"type": "
|
|
265
|
+
"type": "string"
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
],
|
|
@@ -315,12 +315,12 @@
|
|
|
315
315
|
}
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
|
-
"name": "
|
|
319
|
-
"summary": "
|
|
318
|
+
"name": "type",
|
|
319
|
+
"summary": "Type de réponse",
|
|
320
320
|
"required": false,
|
|
321
|
-
"description": "
|
|
321
|
+
"description": "Type de réponse attendu",
|
|
322
322
|
"schema": {
|
|
323
|
-
"type": "
|
|
323
|
+
"type": "string"
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
],
|
package/schema.json
CHANGED
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
"name": "
|
|
54
|
-
"summary": "
|
|
53
|
+
"name": "type",
|
|
54
|
+
"summary": "Response type",
|
|
55
55
|
"required": false,
|
|
56
|
-
"description": "
|
|
56
|
+
"description": "Expected response type",
|
|
57
57
|
"schema": {
|
|
58
|
-
"type": "
|
|
58
|
+
"type": "string"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
],
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
|
-
"name": "
|
|
99
|
-
"summary": "
|
|
98
|
+
"name": "type",
|
|
99
|
+
"summary": "Response type",
|
|
100
100
|
"required": false,
|
|
101
|
-
"description": "
|
|
101
|
+
"description": "Expected response type",
|
|
102
102
|
"schema": {
|
|
103
|
-
"type": "
|
|
103
|
+
"type": "string"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
],
|
|
@@ -131,12 +131,12 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
{
|
|
134
|
-
"name": "
|
|
135
|
-
"summary": "
|
|
134
|
+
"name": "type",
|
|
135
|
+
"summary": "Response type",
|
|
136
136
|
"required": false,
|
|
137
|
-
"description": "
|
|
137
|
+
"description": "Expected response type",
|
|
138
138
|
"schema": {
|
|
139
|
-
"type": "
|
|
139
|
+
"type": "string"
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
],
|
|
@@ -176,12 +176,12 @@
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
|
-
"name": "
|
|
180
|
-
"summary": "
|
|
179
|
+
"name": "type",
|
|
180
|
+
"summary": "Response type",
|
|
181
181
|
"required": false,
|
|
182
|
-
"description": "
|
|
182
|
+
"description": "Expected response type",
|
|
183
183
|
"schema": {
|
|
184
|
-
"type": "
|
|
184
|
+
"type": "string"
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
],
|
|
@@ -221,12 +221,12 @@
|
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
|
-
"name": "
|
|
225
|
-
"summary": "
|
|
224
|
+
"name": "type",
|
|
225
|
+
"summary": "Response type",
|
|
226
226
|
"required": false,
|
|
227
|
-
"description": "
|
|
227
|
+
"description": "Expected response type",
|
|
228
228
|
"schema": {
|
|
229
|
-
"type": "
|
|
229
|
+
"type": "string"
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
],
|
|
@@ -257,12 +257,12 @@
|
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
|
-
"name": "
|
|
261
|
-
"summary": "
|
|
260
|
+
"name": "type",
|
|
261
|
+
"summary": "Response type",
|
|
262
262
|
"required": false,
|
|
263
|
-
"description": "
|
|
263
|
+
"description": "Expected response type",
|
|
264
264
|
"schema": {
|
|
265
|
-
"type": "
|
|
265
|
+
"type": "string"
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
],
|
|
@@ -314,12 +314,12 @@
|
|
|
314
314
|
}
|
|
315
315
|
},
|
|
316
316
|
{
|
|
317
|
-
"name": "
|
|
318
|
-
"summary": "
|
|
317
|
+
"name": "type",
|
|
318
|
+
"summary": "Response type",
|
|
319
319
|
"required": false,
|
|
320
|
-
"description": "
|
|
320
|
+
"description": "Expected response type",
|
|
321
321
|
"schema": {
|
|
322
|
-
"type": "
|
|
322
|
+
"type": "string"
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
],
|