-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#327: Fixed the issue with the absence of the
File
class in Node.js…
… v18.x.x by using `File` from `formdata-node`. - Enhanced documentation with TSDoc and examples for better clarity.
- Loading branch information
1 parent
293cc52
commit e11ef67
Showing
10 changed files
with
386 additions
and
518 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,103 @@ | ||
/** | ||
* Represents an attachment to be temporarily attached to a Service Desk. | ||
* | ||
* @example | ||
* ```typescript | ||
* const attachment: Attachment = { | ||
* filename: 'example.txt', | ||
* file: Buffer.from('Temporary file content'), | ||
* mimeType: 'text/plain', | ||
* }; | ||
* ``` | ||
*/ | ||
export interface Attachment { | ||
/** | ||
* The name of the attachment file. | ||
* | ||
* @example | ||
* ```typescript | ||
* const filename = 'example.png'; | ||
* ``` | ||
*/ | ||
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 = Buffer.from('Example content here'); | ||
* ``` | ||
*/ | ||
file: Buffer | ReadableStream | string | Blob | File; | ||
|
||
/** | ||
* Optional MIME type of the attachment. Example values include: | ||
* | ||
* - 'application/pdf' | ||
* - 'image/jpeg' If not provided, the MIME type will be automatically detected based on the filename. | ||
* | ||
* @example | ||
* ```typescript | ||
* const mimeType = 'image/jpeg'; | ||
* ``` | ||
*/ | ||
mimeType?: string; | ||
} | ||
|
||
/** | ||
* Parameters for attaching temporary files to a Service Desk. | ||
* | ||
* @example | ||
* ```typescript | ||
* const attachTemporaryFileParams: AttachTemporaryFile = { | ||
* serviceDeskId: '5', | ||
* attachment: [ | ||
* { | ||
* filename: 'example.txt', | ||
* file: Buffer.from('Temporary file content'), | ||
* mimeType: 'text/plain', | ||
* }, | ||
* ], | ||
* }; | ||
* ``` | ||
*/ | ||
export interface AttachTemporaryFile { | ||
/** | ||
* The ID of the Service Desk to which the file will be attached. This can alternatively be a [project | ||
* identifier.](#project-identifiers) | ||
* identifier](#project-identifiers). | ||
* | ||
* @example | ||
* ```typescript | ||
* const serviceDeskId = '5'; | ||
* ``` | ||
*/ | ||
serviceDeskId: 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('Temporary content 1'), | ||
* mimeType: 'text/plain', | ||
* }, | ||
* { | ||
* filename: 'file2.jpeg', | ||
* file: Buffer.from('Temporary content 2'), | ||
* mimeType: 'image/jpeg', | ||
* }, | ||
* ]; | ||
* ``` | ||
*/ | ||
attachment: Attachment | Attachment[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,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 that attachments are added to. */ | ||
/** | ||
* 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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,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 that attachments are added to. */ | ||
/** | ||
* 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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters