mailgun.js
Advanced tools
Comparing version 10.1.0 to 10.2.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [10.2.0](https://github.com/mailgun/mailgun.js/compare/v10.1.0...v10.2.0) (2024-02-15) | ||
### Features | ||
* Better types and handling for different FormData implementations ([c547be9](https://github.com/mailgun/mailgun.js/commits/c547be9895dc1fcfb625ddf0aadc82778e82a259)) | ||
## [10.1.0](https://github.com/mailgun/mailgun.js/compare/v10.0.1...v10.1.0) (2024-01-31) | ||
@@ -7,0 +14,0 @@ |
@@ -7,3 +7,4 @@ import { APIErrorOptions, APIErrorType } from '../../Types/Common'; | ||
type: string; | ||
static getUserDataError(statusText: string, message: string): APIError; | ||
constructor({ status, statusText, message, body }: APIErrorOptions); | ||
} |
import * as NodeFormData from 'form-data'; | ||
import { InputFormData } from '../../Types/Common'; | ||
import { FormDataInput, InputFormData } from '../../Types/Common'; | ||
import { MimeMessage } from '../../Types'; | ||
declare class FormDataBuilder { | ||
private FormDataConstructor; | ||
private fileKeys; | ||
private attachmentsHandler; | ||
constructor(FormDataConstructor: InputFormData); | ||
createFormData(data: any): NodeFormData | FormData; | ||
createFormData(data: FormDataInput): NodeFormData | FormData; | ||
private addMimeDataToFD; | ||
isMIME(data: unknown): data is MimeMessage; | ||
private isFormDataPackage; | ||
private getAttachmentOptions; | ||
private addMimeDataToFD; | ||
private isMessageAttachment; | ||
private addFilesToFD; | ||
private isStream; | ||
private addCommonPropertyToFD; | ||
} | ||
export default FormDataBuilder; |
import * as NodeFormData from 'form-data'; | ||
import { RequestOptions, InputFormData, APIResponse, IpPoolDeleteData } from '../../Types'; | ||
import { RequestOptions, InputFormData, APIResponse, IpPoolDeleteData, FormDataInput } from '../../Types'; | ||
declare class Request { | ||
@@ -23,8 +23,8 @@ private username; | ||
post(url: string, data?: Record<string, unknown> | string, options?: Record<string, unknown>): Promise<APIResponse>; | ||
postWithFD(url: string, data: Record<string, unknown> | Record<string, unknown>[]): Promise<APIResponse>; | ||
putWithFD(url: string, data: Record<string, unknown>): Promise<APIResponse>; | ||
patchWithFD(url: string, data: Record<string, unknown>): Promise<APIResponse>; | ||
put(url: string, data?: Record<string, unknown> | string, options?: Record<string, unknown>): Promise<APIResponse>; | ||
postWithFD(url: string, data: FormDataInput): Promise<APIResponse>; | ||
putWithFD(url: string, data: FormDataInput): Promise<APIResponse>; | ||
patchWithFD(url: string, data: FormDataInput): Promise<APIResponse>; | ||
put(url: string, data?: FormDataInput | string, options?: Record<string, unknown>): Promise<APIResponse>; | ||
delete(url: string, data?: IpPoolDeleteData): Promise<APIResponse>; | ||
} | ||
export default Request; |
@@ -35,2 +35,3 @@ import NavigationThruPages from '../common/NavigationThruPages'; | ||
request: Request; | ||
private attachmentsHandler; | ||
constructor(request: Request); | ||
@@ -41,4 +42,5 @@ private handleResponse; | ||
get(listId: string): Promise<MultipleValidationJob>; | ||
private convertToExpectedShape; | ||
create(listId: string, data: MultipleValidationCreationData): Promise<CreatedMultipleValidationJob>; | ||
destroy(listId: string): Promise<CanceledMultipleValidationJob>; | ||
} |
@@ -17,2 +17,2 @@ /*! | ||
/*! mailgun.js v10.0.1 */ | ||
/*! mailgun.js v10.1.0 */ |
/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */ | ||
/*! mailgun.js v10.0.1 */ | ||
/*! mailgun.js v10.1.0 */ |
{ | ||
"name": "mailgun.js", | ||
"version": "10.1.0", | ||
"version": "10.2.0", | ||
"main": "./mailgun.node.js", | ||
@@ -5,0 +5,0 @@ "browser": "./mailgun.web.js", |
import * as NodeFormData from 'form-data'; | ||
import { FormDataInputValue } from '../Messages'; | ||
export type FormDataOptions = { | ||
[key: string]: any; | ||
[key: string]: NodeFormData; | ||
}; | ||
export type InputFormData = { | ||
new (options?: HTMLFormElement | FormDataOptions): NodeFormData | FormData; | ||
new (form?: HTMLFormElement | undefined, submitter?: HTMLElement | null | undefined): FormData; | ||
} | { | ||
new (options?: FormDataOptions): NodeFormData; | ||
}; | ||
export type FormDataInput = { | ||
[key: string]: FormDataInputValue; | ||
}; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/** | ||
@@ -10,2 +11,13 @@ * Ensures the object has least one key present and not undefined | ||
}[Keys]; | ||
export type MimeMessage = string | Blob | Buffer | NodeJS.ReadableStream; | ||
export type CustomFileData = string | Blob | File | Buffer | NodeJS.ReadableStream; | ||
export type CustomFile = { | ||
data: CustomFileData; | ||
filename?: string; | ||
contentType?: string; | ||
knownLength?: number; | ||
[key: string]: unknown; | ||
}; | ||
export type MessageAttachment = CustomFile | CustomFile[] | File | File[] | string | CustomFileData | CustomFileData[]; | ||
export type FormDataInputValue = MimeMessage | CustomFileData | string | string[] | boolean | MessageAttachment | undefined | number; | ||
export type MailgunMessageContent = AtLeastOneKeyPresent<{ | ||
@@ -23,3 +35,3 @@ /** | ||
*/ | ||
message?: string | Buffer | Blob; | ||
message?: MimeMessage; | ||
/** | ||
@@ -62,3 +74,3 @@ * Name of a template stored via [template API](https://documentation.mailgun.com/en/latest/api-templates.html#api-templates). See [Templates](https://documentation.mailgun.com/en/latest/user_manual.html#templating) for more information | ||
*/ | ||
attachment?: any; | ||
attachment?: MessageAttachment; | ||
/** | ||
@@ -169,3 +181,3 @@ * Attachment with `inline` disposition. Can be used to send inline images (see example). | ||
'v:my-var'?: string; | ||
[key: string]: unknown; | ||
[key: string]: FormDataInputValue; | ||
}; | ||
@@ -172,0 +184,0 @@ export type MessagesSendAPIResponse = { |
import { PagesList, ParsedPagesList } from '../Common'; | ||
import { CustomFile, CustomFileData } from '../Messages'; | ||
export type MultipleValidationJobData = { | ||
@@ -60,8 +61,6 @@ created_at: number; | ||
export type MultipleValidationCreationData = { | ||
file: Record<string, unknown>; | ||
[key: string]: unknown | undefined; | ||
file: CustomFileData | CustomFile; | ||
}; | ||
export type MultipleValidationCreationDataUpdated = { | ||
multipleValidationFile: Record<string, unknown>; | ||
[key: string]: unknown | undefined; | ||
multipleValidationFile: CustomFileData | CustomFile; | ||
}; | ||
@@ -68,0 +67,0 @@ export type MultipleValidationJobsListResult = { |
@@ -1,1 +0,1 @@ | ||
10.1.0 | ||
10.2.0 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1670114
124
4122