@pipedream/jira_service_desk 2.1.1 → 2.3.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.
@@ -4,7 +4,7 @@ export default {
4
4
  key: "jira_service_desk-create-comment-on-request",
5
5
  name: "Create Comment on Request",
6
6
  description: "Create a comment on a customer request. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-comment-post)",
7
- version: "0.1.3",
7
+ version: "0.1.4",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -12,9 +12,10 @@ export default {
12
12
  + " Use **List Sites** to get `cloudId`, **List Service Desks** to get `serviceDeskId`, and **List Request Types** to choose the `requestTypeId` whose name and description match the user's intent."
13
13
  + " Call **List Request Type Fields** to see which fields that request type requires; pass anything beyond summary and description in `additionalFieldValues`, keyed by Jira field ID."
14
14
  + " Worked example: on service desk `1`, request type `4` (\"Onboard new employees\") requires `summary` and also accepts a `duedate`, so call with Summary `Joseph Wilson starts on September 1`, Description `Needs a laptop and an email account`, and Additional Field Values `{ \"duedate\": \"2026-09-01\" }`."
15
- + " Returns the created request including its `issueKey` and `issueId`."
15
+ + " Optionally attach one or more files at creation time via `attachments`; to add, replace, or delete attachments on a request that already exists, use **Manage Request Attachment** instead."
16
+ + " Returns the created request including its `issueKey` and `issueId`. If `attachments` is set, the response also includes either an `attachments` array (on success) or an `attachmentError` string (if the request was created but the attachment step failed) — the request itself is never rolled back because of an attachment failure."
16
17
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-post)",
17
- version: "1.0.3",
18
+ version: "1.1.0",
18
19
  annotations: {
19
20
  destructiveHint: false,
20
21
  openWorldHint: true,
@@ -95,6 +96,26 @@ export default {
95
96
  description: "Extra information about the channel the request came in on. Marked experimental by Atlassian.",
96
97
  optional: true,
97
98
  },
99
+ attachments: {
100
+ type: "string[]",
101
+ label: "Attachments",
102
+ description: "File(s) to attach to the request as it's created. Provide file URLs or paths to files in the /tmp directory (e.g. `/tmp/myFile.pdf`).",
103
+ format: "file-ref",
104
+ optional: true,
105
+ },
106
+ attachmentsPublic: {
107
+ type: "boolean",
108
+ label: "Attachments Public",
109
+ description: "Whether the attached file(s) are visible to the customer who raised the request. Defaults to `true`; set to `false` to attach internal-only files.",
110
+ optional: true,
111
+ default: true,
112
+ },
113
+ syncDir: {
114
+ type: "dir",
115
+ accessMode: "read",
116
+ sync: true,
117
+ optional: true,
118
+ },
98
119
  },
99
120
  async run({ $ }) {
100
121
  const {
@@ -110,6 +131,8 @@ export default {
110
131
  form,
111
132
  isAdfRequest,
112
133
  channel,
134
+ attachments,
135
+ attachmentsPublic,
113
136
  } = this;
114
137
 
115
138
  let extraFields = additionalFieldValues;
@@ -172,7 +195,32 @@ export default {
172
195
  },
173
196
  });
174
197
 
175
- $.export("$summary", `Successfully created request ${response.issueKey}`);
176
- return response;
198
+ if (!attachments?.length) {
199
+ $.export("$summary", `Successfully created request ${response.issueKey}`);
200
+ return response;
201
+ }
202
+
203
+ try {
204
+ const attachResponse = await jiraServiceDesk.attachFilesToRequestFromSource({
205
+ $,
206
+ cloudId,
207
+ serviceDeskId,
208
+ issueIdOrKey: response.issueKey,
209
+ files: attachments,
210
+ isPublic: attachmentsPublic,
211
+ });
212
+
213
+ $.export("$summary", `Created request ${response.issueKey} with ${attachments.length} attachment(s)`);
214
+ return {
215
+ ...response,
216
+ attachments: attachResponse.attachments.values,
217
+ };
218
+ } catch (error) {
219
+ $.export("$summary", `Created request ${response.issueKey}, but attaching file(s) failed: ${error.message}`);
220
+ return {
221
+ ...response,
222
+ attachmentError: error.message,
223
+ };
224
+ }
177
225
  },
178
226
  };
@@ -12,7 +12,7 @@ export default {
12
12
  key: "jira_service_desk-download-issue-attachment",
13
13
  name: "Download Issue Attachment",
14
14
  description: "Download the binary content of a Jira Service Desk attachment to the file-stash directory, returning the saved path plus the attachment metadata (`filename`, `mimeType`, `size`). Run **List Issue Attachments** first to obtain the attachment `id`, then pass both it and the same `issueIdOrKey` here. Example: passing `issueIdOrKey` `IT-42` and `attachmentId` `10042` downloads `screenshot.png` to `/tmp/10042-screenshot.png` and returns `{ \"filedata\": [\"10042-screenshot.png\", \"/tmp/10042-screenshot.png\"], \"attachment\": { \"id\": \"10042\", \"filename\": \"screenshot.png\", \"mimeType\": \"image/png\", \"size\": 84213 } }`. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-attachment-attachmentid-get)",
15
- version: "0.0.2",
15
+ version: "0.0.3",
16
16
  type: "action",
17
17
  ai: "optimized",
18
18
  annotations: {
@@ -8,7 +8,7 @@ export default {
8
8
  + " Use this to identify who is logged in, or to filter requests by the current user's `account_id`."
9
9
  + " No `cloudId` required — this uses the Atlassian Identity API directly."
10
10
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/)",
11
- version: "0.0.6",
11
+ version: "0.0.7",
12
12
  type: "action",
13
13
  ai: "optimized",
14
14
  annotations: {
@@ -10,7 +10,7 @@ export default {
10
10
  + " Use **List Sites** first to obtain the required `cloudId`."
11
11
  + " Use **List My Requests** to find the `issueKey` of a request (e.g. `IT-42`)."
12
12
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-get)",
13
- version: "0.2.3",
13
+ version: "0.2.4",
14
14
  type: "action",
15
15
  ai: "optimized",
16
16
  annotations: {
@@ -11,7 +11,7 @@ export default {
11
11
  + " Use **List Sites** first to obtain the required `cloudId`."
12
12
  + " Use **List My Requests** to find the `issueKey` (e.g. `IT-42`)."
13
13
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-status-get)",
14
- version: "1.1.3",
14
+ version: "1.1.4",
15
15
  type: "action",
16
16
  ai: "optimized",
17
17
  annotations: {
@@ -4,7 +4,7 @@ export default {
4
4
  key: "jira_service_desk-list-cloud-id-options",
5
5
  name: "List Cloud ID Options",
6
6
  description: "Lists the Atlassian sites you can raise requests on, as `{label, value}` options, to discover the `cloudId` every other Jira Service Desk tool needs. Takes no input beyond the account. Example: returns `[{ \"label\": \"acme\", \"value\": \"822faf0d-5427-420e-9016-999d3dc76918\" }]`. Use **List Sites** instead if you want the full site records. [See the documentation](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/#3-1-get-the-cloudid-for-your-site)",
7
- version: "0.1.2",
7
+ version: "0.1.3",
8
8
  type: "action",
9
9
  annotations: {
10
10
  destructiveHint: false,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "jira_service_desk-list-issue-attachments",
6
6
  name: "List Issue Attachments",
7
7
  description: "List metadata for every attachment on a Jira Service Desk request. `issueIdOrKey` accepts either a Jira issue key (e.g. `IT-42`) or a numeric Jira issue ID (e.g. `10001`). Results are paginated automatically up to `maxResults`. Returns `{ attachments, truncated }`, where each attachment includes `id`, `filename`, `size` (bytes), `mimeType`, and `content` (an opaque reference URL whose exact shape varies by account access level and is **not** directly fetchable through this connection's authentication), and `truncated` is `true` when more attachments remained unfetched. Use **Download Issue Attachment** with an attachment `id` and the same `issueIdOrKey` to fetch the binary content — do not call `content` directly. If this connection has customer-level access rather than agent access, only public attachments are returned; internal attachments exist but won't appear here. Returns `{ attachments: [], truncated: false }` (no error) when the request exists but has no visible attachments. Example: issue `IT-42` with one attachment returns `{ \"attachments\": [{ \"id\": \"10042\", \"filename\": \"screenshot.png\", \"size\": 84213, \"mimeType\": \"image/png\", \"content\": \"<opaque reference URL>\" }], \"truncated\": false }`. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-attachment-get)",
8
- version: "0.0.2",
8
+ version: "0.0.3",
9
9
  type: "action",
10
10
  ai: "optimized",
11
11
  annotations: {
@@ -13,7 +13,7 @@ export default {
13
13
  + " `requestStatus`: `OPEN_REQUESTS` (default), `CLOSED_REQUESTS`, or `ALL_REQUESTS`."
14
14
  + " `requestOwnership`: `OWNED_REQUESTS` (default) or `PARTICIPATED_REQUESTS`."
15
15
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-get)",
16
- version: "1.1.3",
16
+ version: "1.1.4",
17
17
  type: "action",
18
18
  ai: "optimized",
19
19
  annotations: {
@@ -11,7 +11,7 @@ export default {
11
11
  + " Use **List Sites** first to obtain the required `cloudId`."
12
12
  + " Use **List My Requests** or **Get Request** to find the `issueKey` (e.g. `IT-42`)."
13
13
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-transition-get)",
14
- version: "1.1.3",
14
+ version: "1.1.4",
15
15
  type: "action",
16
16
  ai: "optimized",
17
17
  annotations: {
@@ -11,7 +11,7 @@ export default {
11
11
  + " Also returns `canRaiseOnBehalfOf` and `canAddRequestParticipants`, which tell you whether the `raiseOnBehalfOf` and `requestParticipants` arguments of **Create Request** are usable with this account."
12
12
  + " Hidden fields are only visible to service desk administrators."
13
13
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-servicedeskid-requesttype-requesttypeid-field-get)",
14
- version: "0.0.4",
14
+ version: "0.0.5",
15
15
  type: "action",
16
16
  ai: "optimized",
17
17
  annotations: {
@@ -14,7 +14,7 @@ export default {
14
14
  + " Types with `canCreateRequest: false` cannot be used to raise a request."
15
15
  + " Then call **List Request Type Fields** to see what the chosen type requires."
16
16
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-servicedeskid-requesttype-get)",
17
- version: "0.0.4",
17
+ version: "0.0.5",
18
18
  type: "action",
19
19
  ai: "optimized",
20
20
  annotations: {
@@ -11,7 +11,7 @@ export default {
11
11
  + " Returns `{ serviceDesks, truncated }`, where `truncated` is `true` when more desks remained unfetched."
12
12
  + " Example: a site with one desk returns `{ \"serviceDesks\": [{ \"id\": \"1\", \"projectName\": \"Support\", \"projectKey\": \"SUP\" }], \"truncated\": false }`."
13
13
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-rest-servicedeskapi-servicedesk-get)",
14
- version: "0.0.4",
14
+ version: "0.0.5",
15
15
  type: "action",
16
16
  ai: "optimized",
17
17
  annotations: {
@@ -8,7 +8,7 @@ export default {
8
8
  + " **Call this tool first** to obtain the `cloudId` (returned as `id`) required by every other Jira Service Desk tool."
9
9
  + " Each site includes its `id` (cloudId), `name`, and `url`."
10
10
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/#3-1-get-the-cloudid-for-your-site)",
11
- version: "0.0.6",
11
+ version: "0.0.7",
12
12
  type: "action",
13
13
  ai: "optimized",
14
14
  annotations: {
@@ -0,0 +1,173 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import jiraServiceDesk from "../../jira_service_desk.app.mjs";
3
+ import constants from "../../common/constants.mjs";
4
+
5
+ export default {
6
+ key: "jira_service_desk-manage-request-attachment",
7
+ name: "Manage Request Attachment",
8
+ description:
9
+ "Adds, replaces, or deletes a single attachment on a customer request (ticket) that already exists."
10
+ + " To attach file(s) while creating a brand-new request, use **Create Request**'s `attachments` prop instead — use this tool only for requests that already exist."
11
+ + " Set `operation` to `add` to attach a new file, `update` to replace an existing attachment with a different file (there's no in-place replace in the API, so this uploads the new file and only deletes the old one once the new one is confirmed attached), or `delete` to remove an attachment."
12
+ + " `add` and `update` require `serviceDeskId` (the temp-file upload step is scoped by service desk, not by issue) — use **List Service Desks** to find it, or read it off the response of the request that created the ticket."
13
+ + " `update` and `delete` require `attachmentId`, the numeric ID of the attachment being replaced or removed; the `add`/`update` response doesn't expose this as a plain field, so use **List Issue Attachments** on the same request to look it up."
14
+ + " Worked example: to replace an attachment `10050` on request `HD-12` with a new file, call with Operation `update`, Issue ID Or Key `HD-12`, Service Desk ID `1`, Attachment ID `10050`, and File `/tmp/revised-report.pdf`."
15
+ + " For `update`, if the new file attaches successfully but removing the old attachment then fails, the response includes a `deleteError` string alongside the successful attachment data — the request ends up with both files rather than losing either one, and the error is never masked as a full failure."
16
+ + " By default the attachment is visible to the customer who raised the request (`public: true`); set `public` to `false` to attach an internal-only file."
17
+ + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-attachment-post)",
18
+ version: "0.0.1",
19
+ annotations: {
20
+ destructiveHint: true,
21
+ openWorldHint: true,
22
+ readOnlyHint: false,
23
+ },
24
+ type: "action",
25
+ ai: "optimized",
26
+ props: {
27
+ jiraServiceDesk,
28
+ cloudId: {
29
+ propDefinition: [
30
+ jiraServiceDesk,
31
+ "cloudId",
32
+ ],
33
+ },
34
+ operation: {
35
+ type: "string",
36
+ label: "Operation",
37
+ description: "Whether to add a new attachment, replace (`update`) an existing one, or delete one.",
38
+ options: [
39
+ "add",
40
+ "update",
41
+ "delete",
42
+ ],
43
+ },
44
+ issueIdOrKey: {
45
+ propDefinition: [
46
+ jiraServiceDesk,
47
+ "issueIdOrKey",
48
+ ],
49
+ },
50
+ serviceDeskId: {
51
+ propDefinition: [
52
+ jiraServiceDesk,
53
+ "serviceDeskId",
54
+ ],
55
+ description: "Required for `add` and `update`. The service desk the request belongs to. Use **List Service Desks** to find valid IDs (e.g. `1`).",
56
+ optional: true,
57
+ },
58
+ file: {
59
+ type: "string",
60
+ label: "File",
61
+ description: "Required for `add` and `update`. The file to attach, as a file URL or a path to a file in the /tmp directory (e.g. `/tmp/myFile.pdf`).",
62
+ format: "file-ref",
63
+ optional: true,
64
+ },
65
+ attachmentId: {
66
+ type: "string",
67
+ label: "Attachment ID",
68
+ description: "Required for `update` and `delete`. The numeric ID of the attachment being replaced or removed, e.g. `10050`. The `add`/`update` response doesn't expose this as a plain field — the ID is only embedded in a `_links.jiraRest` URL nested under `attachments.values[]`. Use **List Issue Attachments** instead, which extracts the ID for you.",
69
+ optional: true,
70
+ },
71
+ public: {
72
+ type: "boolean",
73
+ label: "Public",
74
+ description: "Whether the attached file is visible to the customer who raised the request. Defaults to `true`; set to `false` to attach an internal-only file. Only applies to `add` and `update`.",
75
+ optional: true,
76
+ default: true,
77
+ },
78
+ syncDir: {
79
+ type: "dir",
80
+ accessMode: "read",
81
+ sync: true,
82
+ optional: true,
83
+ },
84
+ },
85
+ async run({ $ }) {
86
+ const {
87
+ jiraServiceDesk,
88
+ cloudId,
89
+ operation,
90
+ issueIdOrKey,
91
+ serviceDeskId,
92
+ file,
93
+ attachmentId,
94
+ public: isPublic,
95
+ } = this;
96
+
97
+ const verifyAttachmentBelongsToRequest = async () => {
98
+ const { attachments } = await jiraServiceDesk.getIssueAttachments({
99
+ $,
100
+ cloudId,
101
+ issueIdOrKey,
102
+ maxResults: constants.MAX_RESULTS_MAX,
103
+ });
104
+ if (!attachments.some(({ id }) => id === attachmentId)) {
105
+ throw new ConfigurationError(`Attachment ID "${attachmentId}" was not found on request "${issueIdOrKey}". Run List Issue Attachments to confirm the ID and issue match.`);
106
+ }
107
+ };
108
+
109
+ if (operation === "delete") {
110
+ if (!attachmentId) {
111
+ throw new ConfigurationError("Attachment ID is required to delete an attachment.");
112
+ }
113
+ await verifyAttachmentBelongsToRequest();
114
+ await jiraServiceDesk.deleteAttachment({
115
+ $,
116
+ cloudId,
117
+ attachmentId,
118
+ });
119
+ $.export("$summary", `Deleted attachment ${attachmentId} from request ${issueIdOrKey}`);
120
+ return {
121
+ deleted: true,
122
+ attachmentId,
123
+ };
124
+ }
125
+
126
+ if (!serviceDeskId) {
127
+ throw new ConfigurationError("Service Desk ID is required to add or update an attachment.");
128
+ }
129
+ if (!file) {
130
+ throw new ConfigurationError("File is required to add or update an attachment.");
131
+ }
132
+ if (operation === "update") {
133
+ if (!attachmentId) {
134
+ throw new ConfigurationError("Attachment ID is required to update (replace) an attachment.");
135
+ }
136
+ await verifyAttachmentBelongsToRequest();
137
+ }
138
+
139
+ const attachResponse = await jiraServiceDesk.attachFilesToRequestFromSource({
140
+ $,
141
+ cloudId,
142
+ serviceDeskId,
143
+ issueIdOrKey,
144
+ files: [
145
+ file,
146
+ ],
147
+ isPublic,
148
+ });
149
+
150
+ // The new attachment must succeed before the old one is removed — deleting first
151
+ // would leave the request with no attachment at all if the upload then failed.
152
+ if (operation === "update") {
153
+ try {
154
+ await jiraServiceDesk.deleteAttachment({
155
+ $,
156
+ cloudId,
157
+ attachmentId,
158
+ });
159
+ } catch (error) {
160
+ $.export("$summary", `Added the new attachment on request ${issueIdOrKey}, but the old attachment (${attachmentId}) could not be removed: ${error.message}`);
161
+ return {
162
+ ...attachResponse,
163
+ deleteError: error.message,
164
+ };
165
+ }
166
+ }
167
+
168
+ $.export("$summary", `${operation === "update"
169
+ ? "Replaced"
170
+ : "Added"} attachment on request ${issueIdOrKey}`);
171
+ return attachResponse;
172
+ },
173
+ };
@@ -10,7 +10,7 @@ export default {
10
10
  + " Use **List My Requests** or **Get Request** to find the `issueKey` (e.g. `IT-42`)."
11
11
  + " Optionally include a comment to explain the transition."
12
12
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-transition-post)",
13
- version: "0.1.3",
13
+ version: "0.1.4",
14
14
  type: "action",
15
15
  ai: "optimized",
16
16
  annotations: {
@@ -11,7 +11,7 @@ export default {
11
11
  + " `fields` is a JSON object of field name-value pairs."
12
12
  + " Example: `{\"summary\": \"Updated title\", \"priority\": {\"name\": \"High\"}}`."
13
13
  + " [See the documentation](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-put)",
14
- version: "0.1.3",
14
+ version: "0.1.4",
15
15
  type: "action",
16
16
  ai: "optimized",
17
17
  annotations: {
@@ -1,5 +1,7 @@
1
- // x-pd-ai: optimized
2
- import { axios } from "@pipedream/platform";
1
+ import {
2
+ axios, getFileStreamAndMetadata,
3
+ } from "@pipedream/platform";
4
+ import FormData from "form-data";
3
5
  import constants from "./common/constants.mjs";
4
6
 
5
7
  export default {
@@ -280,5 +282,89 @@ export default {
280
282
  responseType: constants.STREAM_RESPONSE_TYPE,
281
283
  });
282
284
  },
285
+ async uploadTemporaryFile({
286
+ cloudId, serviceDeskId, ...opts
287
+ }) {
288
+ return this._makeRequest({
289
+ ...opts,
290
+ method: "POST",
291
+ path: `/ex/jira/${cloudId}/rest/servicedeskapi/servicedesk/${serviceDeskId}/attachTemporaryFile`,
292
+ });
293
+ },
294
+ async attachFilesToRequest({
295
+ cloudId, issueIdOrKey, ...opts
296
+ }) {
297
+ return this._makeRequest({
298
+ ...opts,
299
+ method: "POST",
300
+ path: `/ex/jira/${cloudId}/rest/servicedeskapi/request/${issueIdOrKey}/attachment`,
301
+ });
302
+ },
303
+ async deleteAttachment({
304
+ cloudId, attachmentId, ...opts
305
+ }) {
306
+ return this._makeRequest({
307
+ ...opts,
308
+ method: "DELETE",
309
+ path: `/ex/jira/${cloudId}/rest/api/3/attachment/${attachmentId}`,
310
+ });
311
+ },
312
+ /**
313
+ * Uploads one or more local/remote files as temporary attachments scoped
314
+ * to `serviceDeskId`, then attaches them to `issueIdOrKey`. Two-step dance
315
+ * required by the JSM API: a file can't be attached to a request directly.
316
+ */
317
+ async attachFilesToRequestFromSource({
318
+ $, cloudId, serviceDeskId, issueIdOrKey, files, isPublic,
319
+ }) {
320
+ // Uploaded one file at a time (rather than buffering every file into one shared
321
+ // FormData first) so only the small temporaryAttachmentId is retained across
322
+ // iterations instead of holding every file's full content in memory at once.
323
+ const temporaryAttachmentIds = [];
324
+ for (const file of files) {
325
+ const {
326
+ stream, metadata,
327
+ } = await getFileStreamAndMetadata(file);
328
+ // Buffered rather than piped as a live stream: attachTemporaryFile consistently
329
+ // 500'd at the Atlassian edge when the multipart body was a live Readable (verified
330
+ // against the JSM API directly), even with Content-Length set from a known size.
331
+ const chunks = [];
332
+ for await (const chunk of stream) {
333
+ chunks.push(chunk);
334
+ }
335
+ const data = new FormData();
336
+ data.append("file", Buffer.concat(chunks), {
337
+ contentType: metadata.contentType,
338
+ filename: metadata.name,
339
+ });
340
+
341
+ const uploadResponse = await this.uploadTemporaryFile({
342
+ $,
343
+ cloudId,
344
+ serviceDeskId,
345
+ headers: {
346
+ "Content-Type": `multipart/form-data; boundary=${data._boundary}`,
347
+ "Content-Length": data.getLengthSync(),
348
+ "X-Atlassian-Token": "no-check",
349
+ },
350
+ data,
351
+ });
352
+ temporaryAttachmentIds.push(
353
+ ...uploadResponse.temporaryAttachments.map(
354
+ ({ temporaryAttachmentId }) => temporaryAttachmentId,
355
+ ),
356
+ );
357
+ }
358
+
359
+ return this.attachFilesToRequest({
360
+ $,
361
+ cloudId,
362
+ issueIdOrKey,
363
+ data: {
364
+ temporaryAttachmentIds,
365
+ public: isPublic ?? true,
366
+ },
367
+ });
368
+ },
283
369
  },
284
370
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/jira_service_desk",
3
- "version": "2.1.1",
3
+ "version": "2.3.0",
4
4
  "description": "Pipedream Jira Service Desk Components",
5
5
  "main": "jira_service_desk.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^3.4.0"
16
+ "@pipedream/platform": "^3.4.0",
17
+ "form-data": "^4.0.4"
17
18
  }
18
19
  }
@@ -6,7 +6,7 @@ export default {
6
6
  name: "New Request Created",
7
7
  description:
8
8
  "Emit new event when a customer request is created. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-rest-servicedeskapi-request-get)",
9
- version: "0.1.2",
9
+ version: "0.1.3",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Request Status Updated",
7
7
  description:
8
8
  "Emit new event when a customer request is updated. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/#api-rest-servicedeskapi-request-get)",
9
- version: "0.1.2",
9
+ version: "0.1.3",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {