mailgun.js 3.5.6 → 3.6.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.
- package/.eslintrc +6 -2
- package/CHANGELOG.md +39 -0
- package/README.md +243 -37
- package/commitlint.config.js +1 -2
- package/dist/index.d.ts +4 -2
- package/dist/{mailgun.js → mailgun.node.js} +3 -3
- package/dist/{mailgun.js.LICENSE.txt → mailgun.node.js.LICENSE.txt} +1 -1
- package/dist/mailgun.web.js +3 -0
- package/dist/mailgun.web.js.LICENSE.txt +7 -0
- package/index.ts +4 -2
- package/lib/events.ts +8 -5
- package/package.json +9 -6
- package/tsconfig.json +1 -0
- package/tsconfig.webpack.json +1 -1
- package/webpack/webpack.common.config.js +48 -0
- package/webpack/webpack.dev.config.js +19 -0
- package/webpack/webpack.release.config.js +38 -0
- package/.eslintignore +0 -2
- package/webpack.config.js +0 -49
- package/webpack.release.config.js +0 -16
package/index.ts
CHANGED
|
@@ -2,14 +2,16 @@ import Client from './lib/client';
|
|
|
2
2
|
import Options from './lib/interfaces/Options';
|
|
3
3
|
import IFormData from './lib/interfaces/IFormData';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
class Mailgun {
|
|
6
6
|
private formData: new () => IFormData
|
|
7
7
|
|
|
8
8
|
constructor(FormData: new (...args: any[]) => IFormData) {
|
|
9
9
|
this.formData = FormData;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
client(options: Options) :
|
|
12
|
+
client(options: Options) : Client {
|
|
13
13
|
return new Client(options, this.formData);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
export = Mailgun;
|
package/lib/events.ts
CHANGED
|
@@ -20,13 +20,16 @@ export default class EventClient {
|
|
|
20
20
|
_parsePageLinks(response: { body: { paging: any } }) {
|
|
21
21
|
const pages = Object.entries(response.body.paging);
|
|
22
22
|
return pages.reduce(
|
|
23
|
-
(acc: any,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
(acc: any, entrie: [url: string, id: string]) => {
|
|
24
|
+
const id = entrie[0];
|
|
25
|
+
const url = entrie[1];
|
|
26
|
+
acc[id] = this._parsePage(id, url);
|
|
27
|
+
return acc;
|
|
28
|
+
}, {}
|
|
29
|
+
);
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
_parseEventList(response: { body: { items: any, paging: any }
|
|
32
|
+
_parseEventList(response: { body: { items: any, paging: any } }) {
|
|
30
33
|
return {
|
|
31
34
|
items: response.body.items,
|
|
32
35
|
pages: this._parsePageLinks(response)
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailgun.js",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"main": "dist/mailgun.js",
|
|
3
|
+
"version": "3.6.0",
|
|
4
|
+
"main": "dist/mailgun.node.js",
|
|
5
|
+
"browser": "dist/mailgun.web.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
6
7
|
"author": "Mailgun",
|
|
7
8
|
"license": "MIT",
|
|
@@ -18,8 +19,9 @@
|
|
|
18
19
|
},
|
|
19
20
|
"homepage": "https://github.com/mailgun/mailgun-js#readme",
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "webpack --config ./webpack.config.js --progress --color",
|
|
22
|
-
"
|
|
22
|
+
"build": "webpack --config ./webpack/webpack.dev.config.js --progress --color",
|
|
23
|
+
"build:release": "webpack --config ./webpack/webpack.release.config.js --progress --color",
|
|
24
|
+
"start": "webpack --watch --config ./webpack/webpack.dev.config.js --progress --color",
|
|
23
25
|
"release": "standard-version -a",
|
|
24
26
|
"test": "multi='dot=- xunit=./results.xml' mocha -t 10000 -R mocha-multi -r ts-node/register test/*.test.ts",
|
|
25
27
|
"test-watch": "mocha -r ts-node/register -w -R dot test/*.test.ts",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@babel/core": "^7.12.3",
|
|
42
44
|
"@babel/preset-env": "^7.12.1",
|
|
43
|
-
"@commitlint/cli": "^
|
|
45
|
+
"@commitlint/cli": "^13.1.0",
|
|
44
46
|
"@commitlint/config-conventional": "^12.1.4",
|
|
45
47
|
"@types/base-64": "^1.0.0",
|
|
46
48
|
"@types/chai": "^4.2.14",
|
|
@@ -64,6 +66,7 @@
|
|
|
64
66
|
"path-browserify": "^1.0.1",
|
|
65
67
|
"should": "^4.1.0",
|
|
66
68
|
"standard-version": "^9.3.1",
|
|
69
|
+
"terser-webpack-plugin": "^5.2.0",
|
|
67
70
|
"ts-loader": "^8.0.12",
|
|
68
71
|
"ts-node": "^9.1.1",
|
|
69
72
|
"typedoc": "^0.20.36",
|
|
@@ -103,7 +106,7 @@
|
|
|
103
106
|
"commitUrlFormat": "https://github.com/mailgun/mailgun-js/commits/{{hash}}",
|
|
104
107
|
"compareUrlFormat": "https://github.com/mailgun/mailgun-js/compare/{{previousTag}}...{{currentTag}}",
|
|
105
108
|
"scripts": {
|
|
106
|
-
"prerelease": "npm test && webpack --config ./webpack.release.config.js --progress --color && git add -A dist",
|
|
109
|
+
"prerelease": "npm test && webpack --config ./webpack/webpack.release.config.js --progress --color && git add -A dist",
|
|
107
110
|
"posttag": "git push && git push --tags && rm -rf build"
|
|
108
111
|
}
|
|
109
112
|
}
|
package/tsconfig.json
CHANGED
package/tsconfig.webpack.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const webpack = require('webpack');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const pkg = require('../package.json');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const SRC_DIR = path.join(__dirname, '../');
|
|
7
|
+
|
|
8
|
+
const outputDir = 'dist';
|
|
9
|
+
const commonConfig = {
|
|
10
|
+
mode: 'development',
|
|
11
|
+
context: SRC_DIR,
|
|
12
|
+
entry: {
|
|
13
|
+
mailgun: path.join(SRC_DIR, 'index.ts'),
|
|
14
|
+
'mailgun.min': path.join(SRC_DIR, 'index.ts')
|
|
15
|
+
},
|
|
16
|
+
output: {
|
|
17
|
+
path: path.join(SRC_DIR, outputDir),
|
|
18
|
+
filename: 'mailgun.js',
|
|
19
|
+
library: 'mailgun',
|
|
20
|
+
libraryTarget: 'umd',
|
|
21
|
+
globalObject: 'this',
|
|
22
|
+
},
|
|
23
|
+
module: {
|
|
24
|
+
rules: [
|
|
25
|
+
{
|
|
26
|
+
test: /\.(ts|js)?/,
|
|
27
|
+
use: [
|
|
28
|
+
{
|
|
29
|
+
loader: 'babel-loader',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
loader: 'ts-loader?configFile='+path.join(SRC_DIR,'tsconfig.webpack.json')
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
exclude: /(node_modules|test)/
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
plugins: [
|
|
40
|
+
new webpack.BannerPlugin(`${pkg.name} v${pkg.version}`)
|
|
41
|
+
],
|
|
42
|
+
resolve: {
|
|
43
|
+
extensions: ['.ts', '.js', '.json']
|
|
44
|
+
},
|
|
45
|
+
devtool: 'inline-source-map'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = commonConfig;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const commonConfig = require('./webpack.common.config');
|
|
2
|
+
|
|
3
|
+
const { merge } = require('webpack-merge');
|
|
4
|
+
|
|
5
|
+
const nodeConf = merge(commonConfig, {
|
|
6
|
+
target: 'node',
|
|
7
|
+
output: {
|
|
8
|
+
filename: 'mailgun.node.js'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const webConf = merge(commonConfig, {
|
|
13
|
+
target: 'web',
|
|
14
|
+
output: {
|
|
15
|
+
filename: 'mailgun.web.js'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
module.exports = [nodeConf, webConf];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
|
|
4
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
5
|
+
const baseConfig = require('./webpack.common.config');
|
|
6
|
+
|
|
7
|
+
const { merge } = require('webpack-merge');
|
|
8
|
+
|
|
9
|
+
const productionConfig = merge(baseConfig, {
|
|
10
|
+
mode: 'production',
|
|
11
|
+
devtool: undefined,
|
|
12
|
+
optimization: {
|
|
13
|
+
minimize: true,
|
|
14
|
+
minimizer: [
|
|
15
|
+
new TerserPlugin({
|
|
16
|
+
parallel: true,
|
|
17
|
+
terserOptions: {
|
|
18
|
+
keep_classnames: true,
|
|
19
|
+
}
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const nodeConf = merge(productionConfig, {
|
|
26
|
+
target: 'node',
|
|
27
|
+
output: {
|
|
28
|
+
filename: 'mailgun.node.js'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const webConf = merge(productionConfig, {
|
|
33
|
+
target: 'web',
|
|
34
|
+
output: {
|
|
35
|
+
filename: 'mailgun.web.js'
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
module.exports = [nodeConf, webConf];
|
package/.eslintignore
DELETED
package/webpack.config.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const pkg = require('./package.json');
|
|
5
|
-
|
|
6
|
-
module.exports = () => {
|
|
7
|
-
const outputDir = 'dist';
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
mode: 'development',
|
|
11
|
-
target: 'node',
|
|
12
|
-
context: __dirname,
|
|
13
|
-
entry: {
|
|
14
|
-
mailgun: path.resolve(__dirname, './index.ts'),
|
|
15
|
-
'mailgun.min': path.resolve(__dirname, './index.ts')
|
|
16
|
-
},
|
|
17
|
-
output: {
|
|
18
|
-
path: path.resolve('./', outputDir),
|
|
19
|
-
filename: 'mailgun.js',
|
|
20
|
-
library: 'mailgun',
|
|
21
|
-
libraryExport: 'default',
|
|
22
|
-
libraryTarget: 'umd',
|
|
23
|
-
globalObject: 'this',
|
|
24
|
-
},
|
|
25
|
-
module: {
|
|
26
|
-
rules: [
|
|
27
|
-
{
|
|
28
|
-
test: /\.(ts|js)?/,
|
|
29
|
-
use: [
|
|
30
|
-
{
|
|
31
|
-
loader: 'babel-loader',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
loader: 'ts-loader?configFile=tsconfig.webpack.json',
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
exclude: /(node_modules|test)/
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
plugins: [
|
|
42
|
-
new webpack.BannerPlugin(`${pkg.name} v${pkg.version}`)
|
|
43
|
-
],
|
|
44
|
-
resolve: {
|
|
45
|
-
extensions: ['.ts', '.js', '.json']
|
|
46
|
-
},
|
|
47
|
-
devtool: 'inline-source-map'
|
|
48
|
-
};
|
|
49
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const { merge } = require('webpack-merge');
|
|
3
|
-
|
|
4
|
-
const baseConfig = require('./webpack.config.js');
|
|
5
|
-
|
|
6
|
-
module.exports = (env) => {
|
|
7
|
-
const outputDir = 'dist';
|
|
8
|
-
|
|
9
|
-
return merge(baseConfig(env), {
|
|
10
|
-
mode: 'production',
|
|
11
|
-
output: {
|
|
12
|
-
path: path.resolve('./', outputDir),
|
|
13
|
-
},
|
|
14
|
-
devtool: undefined
|
|
15
|
-
});
|
|
16
|
-
};
|