From 5d4b0eff682c32e7b9cd9f9e7cd19f0dd216fb80 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Thu, 18 Jun 2020 22:00:00 +0000 Subject: [PATCH] fix(core): update --- .gitignore | 4 +--- .gitlab-ci.yml | 7 ++++--- .vscode/settings.json | 8 +++++++- package.json | 11 ++++++----- readme.md | 27 ++++++++++++++++++++------- test/test.ts | 5 +++-- ts/interfaces/notification.ts | 6 +++--- ts/mailgun.classes.account.ts | 32 +++++++++++++++++--------------- 8 files changed, 61 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a95dfb6..8ebc8b5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,13 +24,14 @@ mirror: - docker - notpriv -snyk: - image: registry.gitlab.com/hosttoday/ht-docker-node:snyk +audit: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - npmci command npm install --ignore-scripts - - npmci command snyk test + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high tags: - lossless - docker diff --git a/.vscode/settings.json b/.vscode/settings.json index 6763058..01d2b8d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,7 +11,13 @@ }, "gitzone": { "type": "object", - "description": "settings for gitzone" + "description": "settings for gitzone", + "properties": { + "projectType": { + "type": "string", + "enum": ["website", "element", "service", "npm"] + } + } } } } diff --git a/package.json b/package.json index eda59cc..804b515 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,13 @@ "version": "1.0.25", "private": false, "description": "an api abstraction package for mailgun", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "main": "dist_ts/index.js", + "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", "license": "MIT", "scripts": { "test": "(tstest test/)", - "build": "(tsbuild)", + "build": "(tsbuild --web)", "format": "(gitzone format)" }, "devDependencies": { @@ -31,11 +31,12 @@ "ts/**/*", "ts_web/**/*", "dist/**/*", - "dist_web/**/*", + "dist_*/**/*", + "dist_ts/**/*", "dist_ts_web/**/*", "assets/**/*", "cli.js", "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index 5a709a0..d5d35ae 100644 --- a/readme.md +++ b/readme.md @@ -8,16 +8,29 @@ an api abstraction package for mailgun * [docs (typedoc)](https://mojoio.gitlab.io/mailgun/) ## Status for master -[![build status](https://gitlab.com/mojoio/mailgun/badges/master/build.svg)](https://gitlab.com/mojoio/mailgun/commits/master) -[![coverage report](https://gitlab.com/mojoio/mailgun/badges/master/coverage.svg)](https://gitlab.com/mojoio/mailgun/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/mailgun.svg)](https://www.npmjs.com/package/@mojoio/mailgun) -[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/mailgun/badge.svg)](https://snyk.io/test/npm/@mojoio/mailgun) -[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) + +Status Category | Status Badge +-- | -- +GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/mailgun/badges/master/pipeline.svg)](https://lossless.cloud) +GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/mailgun/badges/master/coverage.svg)](https://lossless.cloud) +npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/mailgun)](https://lossless.cloud) +Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/mailgun)](https://lossless.cloud) +TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) +node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) +PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@mojoio/mailgun)](https://lossless.cloud) +PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/mailgun)](https://lossless.cloud) +BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/mailgun)](https://lossless.cloud) +Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) ## Usage +Use TypeScript for best in class intellisense. + +## Contribution + +We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) + For further information read the linked docs at the top of this readme. > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) diff --git a/test/test.ts b/test/test.ts index 0fce9da..1bea394 100644 --- a/test/test.ts +++ b/test/test.ts @@ -7,7 +7,6 @@ const testQenv = new Qenv('./', './.nogit'); import * as mailgun from '../ts/index'; import { IMailgunMessage } from '../ts/index'; - let testMailgunAccount: mailgun.MailgunAccount; let testSmartmail: smartmail.Smartmail; @@ -30,7 +29,9 @@ tap.test('should send a smartmail', async () => { }); tap.test('should retrieve a mail using a retrieval url', async () => { - const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl('https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA=='); + const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl( + 'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA==' + ); if (result) { result.options.subject = 'hi there. This is a testmail with attachment'; result.options.from = 'noreply@mail.lossless.com'; diff --git a/ts/interfaces/notification.ts b/ts/interfaces/notification.ts index 7ae4534..972c708 100644 --- a/ts/interfaces/notification.ts +++ b/ts/interfaces/notification.ts @@ -6,7 +6,7 @@ export interface IMailgunNotification { 'Received-Spf': string; From: string; 'Return-Path': string; - 'Arc-Seal': string[], + 'Arc-Seal': string[]; 'Delivered-To': string; 'X-Google-Dkim-Signature': string; To: string; @@ -43,5 +43,5 @@ export interface IMailgunNotification { 'stripped-signature': string; // Lossless specific - "X-Lossless-Auth": string; -} \ No newline at end of file + 'X-Lossless-Auth': string; +} diff --git a/ts/mailgun.classes.account.ts b/ts/mailgun.classes.account.ts index cf540a1..0ead213 100644 --- a/ts/mailgun.classes.account.ts +++ b/ts/mailgun.classes.account.ts @@ -12,14 +12,12 @@ export class MailgunAccount { public async getRequest(routeArg: string, binaryArg: boolean = false) { let requestUrl = routeArg; const needsBaseUrlPrefix = !routeArg.startsWith('https://'); - needsBaseUrlPrefix ? requestUrl = `${this.baseUrl}${routeArg}` : null; + needsBaseUrlPrefix ? (requestUrl = `${this.baseUrl}${routeArg}`) : null; console.log(requestUrl); const requestOptions: plugins.smartrequest.ISmartRequestOptions = { method: 'GET', headers: { - Authorization: `Basic ${plugins.smartstring.base64.encode( - `api:${this.apiToken}` - )}`, + Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`, 'Content-Type': 'application/json' } }; @@ -38,9 +36,7 @@ export class MailgunAccount { requestUrl, { headers: { - Authorization: `Basic ${plugins.smartstring.base64.encode( - `api:${this.apiToken}` - )}` + Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}` } }, formFields @@ -51,7 +47,11 @@ export class MailgunAccount { /** * sends a SmartMail */ - public async sendSmartMail(smartmailArg: plugins.smartmail.Smartmail, toArg: string, dataArg = {}) { + public async sendSmartMail( + smartmailArg: plugins.smartmail.Smartmail, + toArg: string, + dataArg = {} + ) { const domain = smartmailArg.options.from.split('@')[1].replace('>', ''); const formFields: plugins.smartrequest.IFormField[] = [ { @@ -105,7 +105,7 @@ export class MailgunAccount { const responseBody: interfaces.IMailgunMessage = response.body; const smartmail = new plugins.smartmail.Smartmail({ from: responseBody.From, - body: responseBody["body-html"], + body: responseBody['body-html'], subject: responseBody.Subject, creationObjectRef: responseBody }); @@ -115,17 +115,19 @@ export class MailgunAccount { for (const attachmentInfo of responseBody.attachments) { const attachmentName = attachmentInfo.name; const attachmentContents = await this.getRequest(attachmentInfo.url, true); - smartmail.addAttachment(new plugins.smartfile.Smartfile({ - path: `./${attachmentName}`, - base: `./${attachmentName}`, - contentBuffer: attachmentContents.body - })); + smartmail.addAttachment( + new plugins.smartfile.Smartfile({ + path: `./${attachmentName}`, + base: `./${attachmentName}`, + contentBuffer: attachmentContents.body + }) + ); } } return smartmail; } - + public async retrieveSmartMailFromNotifyPayload(notifyPayloadArg: any) { return await this.retrieveSmartMailFromMessageUrl(notifyPayloadArg['message-url']); }