Skip to content

Commit

Permalink
chore(release): 5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scroll17 committed Jul 22, 2022
1 parent 7fc9899 commit 5b69924
Show file tree
Hide file tree
Showing 300 changed files with 2,142 additions and 84 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [5.1.0](https://github.com/mailjet/mailjet-apiv3-nodejs/compare/v5.0.1...v5.1.0) (2022-07-22)


### Added features

* Add full TypeScript cover for Mailjet types ([784c4cd](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/784c4cd79c5531aaeacbdde5547e2793b57d1427))


### Other changes

* Change global and TypeScript rules ([fa4fb60](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/fa4fb606f4e380886734468ac18c2c90e05ebd17))


### Docs changes

* Update TypeScript documentation part; Add example of using Mailjet types ([15f2d11](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/15f2d11dae63fe54fdb350864b99129fcc26afb0))


### Dependency changes for security

* Change webpack dependency terser package 5.0.0 - 5.14.1 ([959018a](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/959018a77ff36a70769f36e22f57bdc89cba2157))

### [5.0.1](https://github.com/mailjet/mailjet-apiv3-nodejs/compare/v5.0.0...v5.0.1) (2022-06-30)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Mailjet JS

[![Build Status](https://travis-ci.org/mailjet/mailjet-apiv3-nodejs.svg?branch=master)](https://travis-ci.org/mailjet/mailjet-apiv3-nodejs)
![Current Version](https://img.shields.io/badge/version-5.0.1-green.svg)
![Current Version](https://img.shields.io/badge/version-5.1.0-green.svg)

## Overview

Expand Down
22 changes: 22 additions & 0 deletions dist/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [5.1.0](https://github.com/mailjet/mailjet-apiv3-nodejs/compare/v5.0.1...v5.1.0) (2022-07-22)


### Added features

* Add full TypeScript cover for Mailjet types ([784c4cd](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/784c4cd79c5531aaeacbdde5547e2793b57d1427))


### Other changes

* Change global and TypeScript rules ([fa4fb60](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/fa4fb606f4e380886734468ac18c2c90e05ebd17))


### Docs changes

* Update TypeScript documentation part; Add example of using Mailjet types ([15f2d11](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/15f2d11dae63fe54fdb350864b99129fcc26afb0))


### Dependency changes for security

* Change webpack dependency terser package 5.0.0 - 5.14.1 ([959018a](https://github.com/mailjet/mailjet-apiv3-nodejs/commits/959018a77ff36a70769f36e22f57bdc89cba2157))

### [5.0.1](https://github.com/mailjet/mailjet-apiv3-nodejs/compare/v5.0.0...v5.0.1) (2022-06-30)


Expand Down
130 changes: 100 additions & 30 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Mailjet JS

[![Build Status](https://travis-ci.org/mailjet/mailjet-apiv3-nodejs.svg?branch=master)](https://travis-ci.org/mailjet/mailjet-apiv3-nodejs)
![Current Version](https://img.shields.io/badge/version-5.0.1-green.svg)
![Current Version](https://img.shields.io/badge/version-5.1.0-green.svg)

## Overview

Expand Down Expand Up @@ -46,6 +46,8 @@ Check out all the resources and JS code examples in the official [Mailjet Docume
- [Response output](#response-output)
- [Disable API call](#disable-api-call)
- [TypeScript](#typescript)
- [Send Email example](#send-email-example)
- [Get Contact example](#get-contact-example)
- [Our external Typings](#our-external-typings)
- [Browser Demo](#browser-demo)
- [App examples](#app-examples)
Expand Down Expand Up @@ -459,57 +461,125 @@ const request = mailjet

## TypeScript

At the moment library based on `TypeScript` and provide **generic** method `Request.request<TResult>(options)`:
Current library based on `TypeScript` and provide **full cover** for **Mailjet types**. \
All **types** can be exported from main entrypoint `'node-mailjet'`:
```typescript
import Mailjet from 'node-mailjet'
import {
Contact,
SendEmailV3,
SendEmailV3_1,
Message,
Segmentation,
Template,
SendMessage,
Webhook
} from 'node-mailjet';
```

As well library has a **generic** method `Request.request<TResult>(data, params, performAPICall)` that could use with these **types**.

### Send Email example

```typescript
import Mailjet, { SendEmailV3_1 } from 'node-mailjet'

const mailjet = new Mailjet({
apiKey: process.env.MJ_APIKEY_PUBLIC,
apiSecret: process.env.MJ_APIKEY_PRIVATE
});

interface IContact {
IsExcludedFromCampaigns: boolean;
Name: string;
CreatedAt: string;
DeliveredCount: number;
Email: string;
}
(async () => {
const data: SendEmailV3_1.IBody = {
Messages: [
{
From: {
Email: '[email protected]',
},
To: [
{
Email: '[email protected]',
},
],
TemplateErrorReporting: {
Email: '[email protected]',
Name: 'Reporter',
},
Subject: 'Your email flight plan!',
HTMLPart: '<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!',
TextPart: 'Dear passenger, welcome to Mailjet! May the delivery force be with you!',
},
],
};

const result = await mailjet
.post('send', { version: 'v3.1' })
.request<SendEmailV3_1.IResponse>(data);

type TResponse<TEntity> = {
Count: number;
Total: number;
Data: Array<TEntity>
const { Status } = result.body.Messages[0];
})();
```

And `response` will have this shape:
```typescript
{
response: Response;
body: {
Messages: Array<{
Status: string;
Errors: Array<Record<string, string>>;
CustomID: string;
...
}>;
}
}
```

const request = mailjet
.get('contact')
.request<TResponse<IContact>>()
### Get Contact Example

```typescript
import Mailjet, { Contact } from 'node-mailjet'

const mailjet = new Mailjet({
apiKey: process.env.MJ_APIKEY_PUBLIC,
apiSecret: process.env.MJ_APIKEY_PRIVATE
});

(async () => {
const queryData: Contact.IGetContactQueryParams = {
IsExcludedFromCampaigns: false,
Campaign: 2234234,
};

const result = await mailjet
.get('contact', { version: 'v3' })
.request<Contact.TGetContactResponse>({}, queryData);

const ContactID = result.body.Data[0].ID;
})();
```

And `response` will have this shape:
```typescript
{
response: Response;
body: {
Count: number;
Total: number;
Data: Array<{
IsExcludedFromCampaigns: boolean;
Name: string;
CreatedAt: string;
DeliveredCount: number;
Email: string;
}>;
Count: number;
Total: number;
Data: Array<{
IsExcludedFromCampaigns: boolean;
Name: string;
CreatedAt: string;
DeliveredCount: number;
Email: string;
...
}>;
}
}
```

> At the moment library provide a types for Mailjet API only for _library level_.\
> But we work to cover all Mailjet types.
### Our external Typings

For new or for earlier versions of library you can use `@types/node-mailjet` dependency.
For earlier versions _(`3.*.*` and low)_ of library you can use `@types/node-mailjet` dependency.

The `types` are published in `npm` and ready for use. \
[Here](https://www.npmjs.com/package/@types/node-mailjet) is the `npm` page.
Expand Down
2 changes: 1 addition & 1 deletion dist/VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.1
5.1.0
1 change: 1 addition & 0 deletions dist/declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ declare class Mailjet extends Client {
static Request: typeof Request;
static HttpMethods: typeof HttpMethods;
}
export * from './types/api';
export { Client, Request, HttpMethods };
export default Mailjet;
6 changes: 3 additions & 3 deletions dist/declarations/request/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TObject } from "../types";
import { IAPILocalResponse, IAPIResponse } from "../types/api/Response";
import { ILibraryResponse, ILibraryLocalResponse } from "../types/api/LibraryResponse";
import HttpMethods from './HttpMethods';
import { TRequestData, TRequestParams, TRequestConstructorConfig } from './IRequest';
import Client from '../client';
Expand Down Expand Up @@ -27,8 +27,8 @@ declare class Request {
private setBaseURL;
id(value: string | number): this;
action(name: string): this;
request<TBody extends TRequestData>(data?: TRequestData, params?: TRequestParams, performAPICall?: true): Promise<IAPIResponse<TBody>>;
request<TBody extends TRequestData, TParams extends TUnknownRec>(data?: TBody, params?: TParams, performAPICall?: false): Promise<IAPILocalResponse<TBody, TParams>>;
request<TBody extends TRequestData>(data?: TRequestData, params?: TRequestParams, performAPICall?: true): Promise<ILibraryResponse<TBody>>;
request<TBody extends TRequestData, TParams extends TUnknownRec>(data?: TBody, params?: TParams, performAPICall?: false): Promise<ILibraryLocalResponse<TBody, TParams>>;
static protocol: "https://";
static parseToJSONb(text: string): any;
static isBrowser(): boolean;
Expand Down
Loading

0 comments on commit 5b69924

Please sign in to comment.