@nu-art/jira-backend 0.401.9 → 0.500.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.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./core/module-pack.js";
2
- export * from "./modules/JiraModule.js";
3
- export * from "./modules/utils.js";
1
+ export * from './core/module-pack.js';
2
+ export * from './modules/JiraModule.js';
3
+ export * from './modules/utils.js';
package/index.js CHANGED
@@ -16,6 +16,6 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- export * from "./core/module-pack.js";
20
- export * from "./modules/JiraModule.js";
21
- export * from "./modules/utils.js";
19
+ export * from './core/module-pack.js';
20
+ export * from './modules/JiraModule.js';
21
+ export * from './modules/utils.js';
@@ -18,7 +18,8 @@
18
18
  */
19
19
  import { ApiException, BadImplementationException, composeUrl, ImplementationMissingException, MimeType_json, Module } from '@nu-art/ts-common';
20
20
  import { JiraUtils } from './utils.js';
21
- import { HeaderKey_ContentType, HttpMethod } from '@nu-art/thunderstorm-shared';
21
+ import { HttpMethod } from '@nu-art/api-types';
22
+ const HeaderKey_ContentType = 'content-type';
22
23
  const createFormData = (filename, buffer) => ({ file: { value: buffer, options: { filename } } });
23
24
  export class ModuleBE_Jira_Class extends Module {
24
25
  headersJson;
@@ -127,68 +128,94 @@ export class ModuleBE_Jira_Class extends Module {
127
128
  addIssueAttachment = async (issue, file) => {
128
129
  return this.executeFormRequest(`/issue/${issue}/attachments`, file);
129
130
  };
130
- executeFormRequest = async (path, buffer) => {
131
- return this.executeRequest({
132
- url: `${this.restUrl}${path}`,
133
- method: HttpMethod.POST,
131
+ executeFormRequest = async (url, buffer) => {
132
+ const request = {
134
133
  headers: this.headersForm,
134
+ uri: `${this.restUrl}${url}`,
135
135
  formData: createFormData('logs.zip', buffer),
136
- });
137
- };
138
- async executePostRequest(path, body) {
139
- return this.executeRequest({
140
- url: `${this.restUrl}${path}`,
141
136
  method: HttpMethod.POST,
137
+ };
138
+ return this.executeRequest(request);
139
+ };
140
+ async executePostRequest(url, body, label) {
141
+ const request = {
142
142
  headers: this.headersJson,
143
- body: body,
144
- json: true,
145
- });
143
+ uri: `${this.restUrl}${url}`,
144
+ body,
145
+ method: HttpMethod.POST,
146
+ json: true
147
+ };
148
+ return this.executeRequest(request);
146
149
  }
147
- async executePutRequest(path, body) {
148
- return this.executeRequest({
149
- url: `${this.restUrl}${path}`,
150
- method: HttpMethod.PUT,
150
+ async executePutRequest(url, body) {
151
+ const request = {
151
152
  headers: this.headersJson,
152
- body: body,
153
- json: true,
154
- });
153
+ uri: `${this.restUrl}${url}`,
154
+ body,
155
+ method: HttpMethod.PUT,
156
+ json: true
157
+ };
158
+ return this.executeRequest(request);
155
159
  }
160
+ // async executeGetRequestNew<T>(url: string, _params?: { [k: string]: string }): Promise<T> {
161
+ // if (!this.restUrl)
162
+ // throw new ImplementationMissingException('Need a baseUrl');
163
+ //
164
+ // return AxiosHttpModule
165
+ // .createRequest(HttpMethod.GET, generateHex(8))
166
+ // .setOrigin(this.restUrl)
167
+ // .setUrl(url)
168
+ // .setUrlParams(_params)
169
+ // .setHeaders(this.headersJson)
170
+ // .executeSync();
171
+ // }
156
172
  async handleResponse(response) {
157
173
  if (!response.ok)
158
174
  throw new ApiException(response.status, await response.text());
159
175
  return response.json();
160
176
  }
161
- async executeGetRequest(path, params) {
162
- return this.executeRequest({
163
- url: composeUrl(`${this.restUrl}${path}`, params),
164
- method: HttpMethod.GET,
177
+ async executeGetRequest(url, _params) {
178
+ const request = {
165
179
  headers: this.headersJson,
166
- json: true,
167
- });
180
+ uri: `${composeUrl(`${this.restUrl}${url}`, _params)}`,
181
+ method: HttpMethod.GET,
182
+ json: true
183
+ };
184
+ return this.executeRequest(request);
168
185
  }
169
186
  async executeRequest(request) {
170
- const { url, method, headers, body, json, formData } = request;
187
+ const { uri, method, headers, body, json, formData } = request;
188
+ // Ensure uri is a string
189
+ const url = typeof uri === 'string' ? uri : uri.toString();
171
190
  let fetchBody;
172
191
  const fetchHeaders = { ...headers };
173
192
  if (formData) {
193
+ // Handle formData (for file uploads)
174
194
  const form = new FormData();
175
195
  for (const [key, value] of Object.entries(formData)) {
176
196
  if (value && typeof value === 'object' && 'value' in value) {
177
197
  const fileData = value;
198
+ // Convert Buffer to Uint8Array for Blob
178
199
  const blob = new Blob([new Uint8Array(fileData.value)]);
179
200
  form.append(key, blob, fileData.options?.filename);
180
201
  }
181
202
  }
182
203
  fetchBody = form;
204
+ // Remove Content-Type header to let browser set it with boundary
183
205
  delete fetchHeaders[HeaderKey_ContentType];
184
206
  }
185
- else if (body !== undefined) {
186
- fetchBody = json ? JSON.stringify(body) : body;
207
+ else if (body) {
208
+ if (json) {
209
+ fetchBody = JSON.stringify(body);
210
+ }
211
+ else {
212
+ fetchBody = body;
213
+ }
187
214
  }
188
215
  const response = await fetch(url, {
189
216
  method: method || HttpMethod.GET,
190
217
  headers: fetchHeaders,
191
- body: fetchBody,
218
+ body: fetchBody
192
219
  });
193
220
  return this.handleResponse(response);
194
221
  }
@@ -1,4 +1,4 @@
1
- import { JiraQuery } from "./JiraModule.js";
1
+ import { JiraQuery } from './JiraModule.js';
2
2
  export type JiraIssueText = string | {
3
3
  href: string;
4
4
  text: string;
package/modules/utils.js CHANGED
@@ -16,26 +16,26 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- import { _keys } from "@nu-art/ts-common";
19
+ import { _keys } from '@nu-art/ts-common';
20
20
  function createText(...texts) {
21
21
  return {
22
- type: "doc",
22
+ type: 'doc',
23
23
  version: 1,
24
24
  content: [
25
25
  {
26
- type: "paragraph",
26
+ type: 'paragraph',
27
27
  content: texts.map(text => {
28
- if (typeof text === "string")
28
+ if (typeof text === 'string')
29
29
  return {
30
- type: "text",
30
+ type: 'text',
31
31
  text
32
32
  };
33
33
  return {
34
- type: "text",
34
+ type: 'text',
35
35
  text: text.text,
36
36
  marks: [
37
37
  {
38
- type: "link",
38
+ type: 'link',
39
39
  attrs: {
40
40
  href: text.href
41
41
  }
@@ -52,7 +52,7 @@ function buildJQL(query) {
52
52
  let queryValue;
53
53
  let operator = '=';
54
54
  if (Array.isArray(query[key])) {
55
- queryValue = query[key].map(value => `"${value}"`).join(",");
55
+ queryValue = query[key].map(value => `"${value}"`).join(',');
56
56
  queryValue = `(${queryValue})`;
57
57
  }
58
58
  else if (typeof query[key] === 'object') {
@@ -64,7 +64,7 @@ function buildJQL(query) {
64
64
  queryValue = `"${query[key]}"`;
65
65
  return `${key}${operator}${queryValue}`;
66
66
  });
67
- return params.join(" and ");
67
+ return params.join(' and ');
68
68
  }
69
69
  export const JiraUtils = {
70
70
  createText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/jira-backend",
3
- "version": "0.401.9",
3
+ "version": "0.500.0",
4
4
  "description": "Jira api Module Backend",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -20,22 +20,22 @@
20
20
  "license": "Apache-2.0",
21
21
  "author": "TacB0sS",
22
22
  "dependencies": {
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",
23
+ "@nu-art/jira-shared": "0.500.0",
24
+ "@nu-art/firebase-backend": "0.500.0",
25
+ "@nu-art/firebase-shared": "0.500.0",
26
+ "@nu-art/ts-common": "0.500.0",
29
27
  "body-parser": "^1.18.3",
30
28
  "compression": "^1.7.4",
31
29
  "express": "^4.18.2",
32
30
  "firebase-admin": "13.4.0",
33
- "moment": "^2.29.4"
31
+ "moment": "^2.29.4",
32
+ "@nu-art/api-types": "{{THUNDERSTORM_VERSION}}"
34
33
  },
35
34
  "devDependencies": {
36
35
  "@types/debug": "^4.1.2",
37
36
  "@types/express": "^4.17.17",
38
37
  "@types/js-base64": "^2.3.1",
38
+ "@types/request": "^2.48.3",
39
39
  "@types/saml2-js": "^1.6.8"
40
40
  },
41
41
  "unitConfig": {