@nu-art/jira-backend 0.401.3 → 0.401.4
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/modules/JiraModule.js +37 -6
- package/package.json +8 -9
package/modules/JiraModule.js
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { ApiException, BadImplementationException, composeUrl, ImplementationMissingException, MimeType_json, Module } from '@nu-art/ts-common';
|
|
20
|
-
import { promisifyRequest } from '@nu-art/thunderstorm-backend';
|
|
21
20
|
import { JiraUtils } from './utils.js';
|
|
22
21
|
import { HeaderKey_ContentType, HttpMethod } from '@nu-art/thunderstorm-shared';
|
|
23
22
|
const createFormData = (filename, buffer) => ({ file: { value: buffer, options: { filename } } });
|
|
@@ -169,10 +168,10 @@ export class ModuleBE_Jira_Class extends Module {
|
|
|
169
168
|
// .setHeaders(this.headersJson)
|
|
170
169
|
// .executeSync();
|
|
171
170
|
// }
|
|
172
|
-
handleResponse(response) {
|
|
173
|
-
if (
|
|
174
|
-
throw new ApiException(response.
|
|
175
|
-
return response.
|
|
171
|
+
async handleResponse(response) {
|
|
172
|
+
if (!response.ok)
|
|
173
|
+
throw new ApiException(response.status, await response.text());
|
|
174
|
+
return response.json();
|
|
176
175
|
}
|
|
177
176
|
async executeGetRequest(url, _params) {
|
|
178
177
|
const request = {
|
|
@@ -184,7 +183,39 @@ export class ModuleBE_Jira_Class extends Module {
|
|
|
184
183
|
return this.executeRequest(request);
|
|
185
184
|
}
|
|
186
185
|
async executeRequest(request) {
|
|
187
|
-
const
|
|
186
|
+
const { uri, method, headers, body, json, formData } = request;
|
|
187
|
+
// Ensure uri is a string
|
|
188
|
+
const url = typeof uri === 'string' ? uri : uri.toString();
|
|
189
|
+
let fetchBody;
|
|
190
|
+
const fetchHeaders = { ...headers };
|
|
191
|
+
if (formData) {
|
|
192
|
+
// Handle formData (for file uploads)
|
|
193
|
+
const form = new FormData();
|
|
194
|
+
for (const [key, value] of Object.entries(formData)) {
|
|
195
|
+
if (value && typeof value === 'object' && 'value' in value) {
|
|
196
|
+
const fileData = value;
|
|
197
|
+
// Convert Buffer to Uint8Array for Blob
|
|
198
|
+
const blob = new Blob([new Uint8Array(fileData.value)]);
|
|
199
|
+
form.append(key, blob, fileData.options?.filename);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
fetchBody = form;
|
|
203
|
+
// Remove Content-Type header to let browser set it with boundary
|
|
204
|
+
delete fetchHeaders[HeaderKey_ContentType];
|
|
205
|
+
}
|
|
206
|
+
else if (body) {
|
|
207
|
+
if (json) {
|
|
208
|
+
fetchBody = JSON.stringify(body);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
fetchBody = body;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const response = await fetch(url, {
|
|
215
|
+
method: method || HttpMethod.GET,
|
|
216
|
+
headers: fetchHeaders,
|
|
217
|
+
body: fetchBody
|
|
218
|
+
});
|
|
188
219
|
return this.handleResponse(response);
|
|
189
220
|
}
|
|
190
221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/jira-backend",
|
|
3
|
-
"version": "0.401.
|
|
3
|
+
"version": "0.401.4",
|
|
4
4
|
"description": "Jira api Module Backend",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"TacB0sS",
|
|
@@ -20,18 +20,17 @@
|
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"author": "TacB0sS",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nu-art/jira-shared": "0.401.
|
|
24
|
-
"@nu-art/firebase-backend": "0.401.
|
|
25
|
-
"@nu-art/firebase-shared": "0.401.
|
|
26
|
-
"@nu-art/thunderstorm-backend": "0.401.
|
|
27
|
-
"@nu-art/thunderstorm-shared": "0.401.
|
|
28
|
-
"@nu-art/ts-common": "0.401.
|
|
23
|
+
"@nu-art/jira-shared": "0.401.4",
|
|
24
|
+
"@nu-art/firebase-backend": "0.401.4",
|
|
25
|
+
"@nu-art/firebase-shared": "0.401.4",
|
|
26
|
+
"@nu-art/thunderstorm-backend": "0.401.4",
|
|
27
|
+
"@nu-art/thunderstorm-shared": "0.401.4",
|
|
28
|
+
"@nu-art/ts-common": "0.401.4",
|
|
29
29
|
"body-parser": "^1.18.3",
|
|
30
30
|
"compression": "^1.7.4",
|
|
31
31
|
"express": "^4.18.2",
|
|
32
32
|
"firebase-admin": "13.4.0",
|
|
33
|
-
"moment": "^2.29.4"
|
|
34
|
-
"request": "^2.88.0"
|
|
33
|
+
"moment": "^2.29.4"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/debug": "^4.1.2",
|