@nu-art/jira-backend 0.401.7 → 0.401.9

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.
@@ -127,94 +127,68 @@ export class ModuleBE_Jira_Class extends Module {
127
127
  addIssueAttachment = async (issue, file) => {
128
128
  return this.executeFormRequest(`/issue/${issue}/attachments`, file);
129
129
  };
130
- executeFormRequest = async (url, buffer) => {
131
- const request = {
130
+ executeFormRequest = async (path, buffer) => {
131
+ return this.executeRequest({
132
+ url: `${this.restUrl}${path}`,
133
+ method: HttpMethod.POST,
132
134
  headers: this.headersForm,
133
- uri: `${this.restUrl}${url}`,
134
135
  formData: createFormData('logs.zip', buffer),
135
- method: HttpMethod.POST,
136
- };
137
- return this.executeRequest(request);
136
+ });
138
137
  };
139
- async executePostRequest(url, body, label) {
140
- const request = {
141
- headers: this.headersJson,
142
- uri: `${this.restUrl}${url}`,
143
- body,
138
+ async executePostRequest(path, body) {
139
+ return this.executeRequest({
140
+ url: `${this.restUrl}${path}`,
144
141
  method: HttpMethod.POST,
145
- json: true
146
- };
147
- return this.executeRequest(request);
148
- }
149
- async executePutRequest(url, body) {
150
- const request = {
151
142
  headers: this.headersJson,
152
- uri: `${this.restUrl}${url}`,
153
- body,
143
+ body: body,
144
+ json: true,
145
+ });
146
+ }
147
+ async executePutRequest(path, body) {
148
+ return this.executeRequest({
149
+ url: `${this.restUrl}${path}`,
154
150
  method: HttpMethod.PUT,
155
- json: true
156
- };
157
- return this.executeRequest(request);
151
+ headers: this.headersJson,
152
+ body: body,
153
+ json: true,
154
+ });
158
155
  }
159
- // async executeGetRequestNew<T>(url: string, _params?: { [k: string]: string }): Promise<T> {
160
- // if (!this.restUrl)
161
- // throw new ImplementationMissingException('Need a baseUrl');
162
- //
163
- // return AxiosHttpModule
164
- // .createRequest(HttpMethod.GET, generateHex(8))
165
- // .setOrigin(this.restUrl)
166
- // .setUrl(url)
167
- // .setUrlParams(_params)
168
- // .setHeaders(this.headersJson)
169
- // .executeSync();
170
- // }
171
156
  async handleResponse(response) {
172
157
  if (!response.ok)
173
158
  throw new ApiException(response.status, await response.text());
174
159
  return response.json();
175
160
  }
176
- async executeGetRequest(url, _params) {
177
- const request = {
178
- headers: this.headersJson,
179
- uri: `${composeUrl(`${this.restUrl}${url}`, _params)}`,
161
+ async executeGetRequest(path, params) {
162
+ return this.executeRequest({
163
+ url: composeUrl(`${this.restUrl}${path}`, params),
180
164
  method: HttpMethod.GET,
181
- json: true
182
- };
183
- return this.executeRequest(request);
165
+ headers: this.headersJson,
166
+ json: true,
167
+ });
184
168
  }
185
169
  async executeRequest(request) {
186
- const { uri, method, headers, body, json, formData } = request;
187
- // Ensure uri is a string
188
- const url = typeof uri === 'string' ? uri : uri.toString();
170
+ const { url, method, headers, body, json, formData } = request;
189
171
  let fetchBody;
190
172
  const fetchHeaders = { ...headers };
191
173
  if (formData) {
192
- // Handle formData (for file uploads)
193
174
  const form = new FormData();
194
175
  for (const [key, value] of Object.entries(formData)) {
195
176
  if (value && typeof value === 'object' && 'value' in value) {
196
177
  const fileData = value;
197
- // Convert Buffer to Uint8Array for Blob
198
178
  const blob = new Blob([new Uint8Array(fileData.value)]);
199
179
  form.append(key, blob, fileData.options?.filename);
200
180
  }
201
181
  }
202
182
  fetchBody = form;
203
- // Remove Content-Type header to let browser set it with boundary
204
183
  delete fetchHeaders[HeaderKey_ContentType];
205
184
  }
206
- else if (body) {
207
- if (json) {
208
- fetchBody = JSON.stringify(body);
209
- }
210
- else {
211
- fetchBody = body;
212
- }
185
+ else if (body !== undefined) {
186
+ fetchBody = json ? JSON.stringify(body) : body;
213
187
  }
214
188
  const response = await fetch(url, {
215
189
  method: method || HttpMethod.GET,
216
190
  headers: fetchHeaders,
217
- body: fetchBody
191
+ body: fetchBody,
218
192
  });
219
193
  return this.handleResponse(response);
220
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/jira-backend",
3
- "version": "0.401.7",
3
+ "version": "0.401.9",
4
4
  "description": "Jira api Module Backend",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -20,12 +20,12 @@
20
20
  "license": "Apache-2.0",
21
21
  "author": "TacB0sS",
22
22
  "dependencies": {
23
- "@nu-art/jira-shared": "0.401.7",
24
- "@nu-art/firebase-backend": "0.401.7",
25
- "@nu-art/firebase-shared": "0.401.7",
26
- "@nu-art/thunderstorm-backend": "0.401.7",
27
- "@nu-art/thunderstorm-shared": "0.401.7",
28
- "@nu-art/ts-common": "0.401.7",
23
+ "@nu-art/jira-shared": "0.401.9",
24
+ "@nu-art/firebase-backend": "0.401.9",
25
+ "@nu-art/firebase-shared": "0.401.9",
26
+ "@nu-art/thunderstorm-backend": "0.401.9",
27
+ "@nu-art/thunderstorm-shared": "0.401.9",
28
+ "@nu-art/ts-common": "0.401.9",
29
29
  "body-parser": "^1.18.3",
30
30
  "compression": "^1.7.4",
31
31
  "express": "^4.18.2",
@@ -36,7 +36,6 @@
36
36
  "@types/debug": "^4.1.2",
37
37
  "@types/express": "^4.17.17",
38
38
  "@types/js-base64": "^2.3.1",
39
- "@types/request": "^2.48.3",
40
39
  "@types/saml2-js": "^1.6.8"
41
40
  },
42
41
  "unitConfig": {