forked from MrRefactoring/jira.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddAttachment.ts
101 lines (97 loc) · 2.34 KB
/
addAttachment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Represents an attachment to be added to an issue.
*
* @example
* ```typescript
* const attachment: Attachment = {
* filename: 'example.txt',
* file: Buffer.from('Hello, world!'),
* mimeType: 'text/plain',
* };
* ```
*/
export interface Attachment {
/**
* The name of the attachment file.
*
* @example
* ```typescript
* const filename = 'document.pdf';
* ```
*/
filename: string;
/**
* The content of the attachment. Can be one of the following:
*
* - `Buffer`: For binary data.
* - `ReadableStream`: For streaming large files.
* - `string`: For text-based content.
* - `Blob`: For browser-like blob objects.
* - `File`: For file objects with metadata (e.g., in web environments).
*
* @example
* ```typescript
* const fileContent = fs.readFileSync('./document.pdf');
* ```
*/
file: Buffer | ReadableStream | string | Blob | File;
/**
* Optional MIME type of the attachment. Example values include:
*
* - 'application/pdf'
* - 'image/png'
*
* If not provided, the MIME type will be automatically detected based on the filename.
*
* @example
* ```typescript
* const mimeType = 'application/pdf';
* ```
*/
mimeType?: string;
}
/**
* Parameters for adding attachments to an issue.
*
* @example
* ```typescript
* const addAttachmentParams: AddAttachment = {
* issueIdOrKey: 'PROJECT-123',
* attachment: {
* filename: 'example.txt',
* file: 'Hello, world!',
* mimeType: 'text/plain',
* },
* };
* ```
*/
export interface AddAttachment {
/**
* The ID or key of the issue to which the attachments will be added.
*
* @example
* ```typescript
* const issueIdOrKey = 'PROJECT-123';
* ```
*/
issueIdOrKey: string;
/**
* The attachment(s) to be added. Can be a single `Attachment` object or an array of `Attachment` objects.
*
* @example
* ```typescript
* const attachments = [
* {
* filename: 'file1.txt',
* file: Buffer.from('File 1 content'),
* mimeType: 'text/plain',
* },
* {
* filename: 'proof image.png',
* file: fs.readFileSync('./image.png'), // Reads the image file into a Buffer
* },
* ];
* ```
*/
attachment: Attachment | Attachment[];
}