@dereekb/nestjs 9.7.7 → 9.9.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/CHANGELOG.md +13 -0
- package/mailgun/CHANGELOG.md +10 -0
- package/mailgun/LICENSE +21 -0
- package/mailgun/README.md +11 -0
- package/mailgun/package.json +21 -0
- package/mailgun/src/index.d.ts +1 -0
- package/mailgun/src/index.js +5 -0
- package/mailgun/src/index.js.map +1 -0
- package/mailgun/src/lib/index.d.ts +5 -0
- package/mailgun/src/lib/index.js +9 -0
- package/mailgun/src/lib/index.js.map +1 -0
- package/mailgun/src/lib/mailgun.api.d.ts +10 -0
- package/mailgun/src/lib/mailgun.api.js +30 -0
- package/mailgun/src/lib/mailgun.api.js.map +1 -0
- package/mailgun/src/lib/mailgun.config.d.ts +21 -0
- package/mailgun/src/lib/mailgun.config.js +24 -0
- package/mailgun/src/lib/mailgun.config.js.map +1 -0
- package/mailgun/src/lib/mailgun.d.ts +60 -0
- package/mailgun/src/lib/mailgun.js +84 -0
- package/mailgun/src/lib/mailgun.js.map +1 -0
- package/mailgun/src/lib/mailgun.service.d.ts +9 -0
- package/mailgun/src/lib/mailgun.service.js +38 -0
- package/mailgun/src/lib/mailgun.service.js.map +1 -0
- package/mailgun/src/lib/mailgun.service.module.d.ts +6 -0
- package/mailgun/src/lib/mailgun.service.module.js +80 -0
- package/mailgun/src/lib/mailgun.service.module.js.map +1 -0
- package/mailgun/src/lib/mailgun.type.d.ts +5 -0
- package/mailgun/src/lib/mailgun.type.js +3 -0
- package/mailgun/src/lib/mailgun.type.js.map +1 -0
- package/package.json +2 -2
- package/src/lib/module/env/env.config.d.ts +21 -0
- package/src/lib/module/env/env.config.js +3 -0
- package/src/lib/module/env/env.config.js.map +1 -0
- package/src/lib/module/env/env.d.ts +4 -0
- package/src/lib/module/env/env.js +11 -0
- package/src/lib/module/env/env.js.map +1 -0
- package/src/lib/module/env/env.nest.d.ts +7 -0
- package/src/lib/module/env/env.nest.js +16 -0
- package/src/lib/module/env/env.nest.js.map +1 -0
- package/src/lib/module/env/env.service.d.ts +8 -0
- package/src/lib/module/env/env.service.js +28 -0
- package/src/lib/module/env/env.service.js.map +1 -0
- package/src/lib/module/env/index.d.ts +4 -0
- package/src/lib/module/env/index.js +8 -0
- package/src/lib/module/env/index.js.map +1 -0
- package/src/lib/module/index.d.ts +1 -0
- package/src/lib/module/index.js +1 -0
- package/src/lib/module/index.js.map +1 -1
- package/stripe/CHANGELOG.md +8 -0
- package/stripe/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [9.9.0](https://github.com/dereekb/dbx-components/compare/v9.8.0-dev...v9.9.0) (2022-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* mailgun ([#16](https://github.com/dereekb/dbx-components/issues/16)) ([9c7d4cc](https://github.com/dereekb/dbx-components/commit/9c7d4cc997e86b664ff7e2bc6e04392e650b7910))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [9.8.0](https://github.com/dereekb/dbx-components/compare/v9.7.7-dev...v9.8.0) (2022-09-15)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
5
18
|
## [9.7.7](https://github.com/dereekb/dbx-components/compare/v9.7.6-dev...v9.7.7) (2022-09-12)
|
|
6
19
|
|
|
7
20
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
+
|
|
5
|
+
# [9.9.0](https://github.com/dereekb/dbx-components/compare/v9.8.0-dev...v9.9.0) (2022-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* mailgun ([#16](https://github.com/dereekb/dbx-components/issues/16)) ([9c7d4cc](https://github.com/dereekb/dbx-components/commit/9c7d4cc997e86b664ff7e2bc6e04392e650b7910))
|
package/mailgun/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Hapier Creative LLC.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# nestjs-mailgun
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build nestjs-mailgun` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test nestjs-mailgun` to execute the unit tests via [Jest](https://jestjs.io).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dereekb/nestjs/mailgun",
|
|
3
|
+
"version": "9.9.0",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"typings": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@nestjs/common": "^9.0.0",
|
|
10
|
+
"mailgun.js": "^8.0.0",
|
|
11
|
+
"form-data": "^4.0.0",
|
|
12
|
+
"@dereekb/util": "9.9.0",
|
|
13
|
+
"lodash.isequal": "^4.5.0",
|
|
14
|
+
"make-error": "^1.3.0",
|
|
15
|
+
"ts-essentials": "^9.1.2",
|
|
16
|
+
"extra-set": "^2.2.11",
|
|
17
|
+
"@dereekb/nestjs": "9.9.0",
|
|
18
|
+
"@nestjs/config": "^2.0.1",
|
|
19
|
+
"tslib": "^2.0.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/nestjs/mailgun/src/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./mailgun"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./mailgun.type"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./mailgun.api"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./mailgun.service.module"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./mailgun.service"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,mEAAyC;AACzC,4DAAkC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MailgunServiceConfig } from './mailgun.config';
|
|
2
|
+
import { MailgunClient, MailgunMessagesClient } from './mailgun.type';
|
|
3
|
+
export declare class MailgunApi {
|
|
4
|
+
readonly config: MailgunServiceConfig;
|
|
5
|
+
readonly client: MailgunClient;
|
|
6
|
+
constructor(config: MailgunServiceConfig);
|
|
7
|
+
get messages(): MailgunMessagesClient;
|
|
8
|
+
get domain(): string;
|
|
9
|
+
get sender(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailgunApi = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const mailgun_config_1 = require("./mailgun.config");
|
|
7
|
+
const mailgun_js_1 = require("mailgun.js");
|
|
8
|
+
const FormData = require("form-data");
|
|
9
|
+
let MailgunApi = class MailgunApi {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.client = new mailgun_js_1.default(FormData).client(Object.assign({}, config.mailgun));
|
|
13
|
+
}
|
|
14
|
+
get messages() {
|
|
15
|
+
return this.client.messages;
|
|
16
|
+
}
|
|
17
|
+
get domain() {
|
|
18
|
+
return this.config.domain;
|
|
19
|
+
}
|
|
20
|
+
get sender() {
|
|
21
|
+
return this.config.sender;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
MailgunApi = tslib_1.__decorate([
|
|
25
|
+
(0, common_1.Injectable)(),
|
|
26
|
+
tslib_1.__param(0, (0, common_1.Inject)(mailgun_config_1.MailgunServiceConfig)),
|
|
27
|
+
tslib_1.__metadata("design:paramtypes", [mailgun_config_1.MailgunServiceConfig])
|
|
28
|
+
], MailgunApi);
|
|
29
|
+
exports.MailgunApi = MailgunApi;
|
|
30
|
+
//# sourceMappingURL=mailgun.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.api.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.api.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,qDAAwD;AAExD,2CAAiC;AAEjC,sCAAsC;AAGtC,IAAa,UAAU,GAAvB,MAAa,UAAU;IAGrB,YAA0D,MAA4B;QAA5B,WAAM,GAAN,MAAM,CAAsB;QACpF,IAAI,CAAC,MAAM,GAAG,IAAI,oBAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,mBACrC,MAAM,CAAC,OAAO,EACjB,CAAC;IACL,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF,CAAA;AApBY,UAAU;IADtB,IAAA,mBAAU,GAAE;IAIE,mBAAA,IAAA,eAAM,EAAC,qCAAoB,CAAC,CAAA;6CAAyB,qCAAoB;GAH3E,UAAU,CAoBtB;AApBY,gCAAU"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmailParticipantString } from '@dereekb/util';
|
|
2
|
+
import { MailgunSenderDomainString } from './mailgun';
|
|
3
|
+
import { MailgunOptions } from './mailgun.type';
|
|
4
|
+
export declare abstract class MailgunServiceConfig {
|
|
5
|
+
mailgun: MailgunOptions;
|
|
6
|
+
/**
|
|
7
|
+
* Main domain to send emails from.
|
|
8
|
+
*/
|
|
9
|
+
domain: MailgunSenderDomainString;
|
|
10
|
+
/**
|
|
11
|
+
* Mailgun sender string.
|
|
12
|
+
*/
|
|
13
|
+
sender: EmailParticipantString;
|
|
14
|
+
/**
|
|
15
|
+
* Additional messages config
|
|
16
|
+
*/
|
|
17
|
+
messages: {
|
|
18
|
+
recipientVariablePrefix?: string | false;
|
|
19
|
+
};
|
|
20
|
+
static assertValidConfig(config: MailgunServiceConfig): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailgunServiceConfig = void 0;
|
|
4
|
+
class MailgunServiceConfig {
|
|
5
|
+
static assertValidConfig(config) {
|
|
6
|
+
if (!config.mailgun.username) {
|
|
7
|
+
throw new Error('No mailgun username specified.');
|
|
8
|
+
}
|
|
9
|
+
else if (!config.mailgun.key) {
|
|
10
|
+
throw new Error('No mailgun key specified.');
|
|
11
|
+
}
|
|
12
|
+
else if (!config.domain) {
|
|
13
|
+
throw new Error('No mailgun domain specified.');
|
|
14
|
+
}
|
|
15
|
+
else if (!config.sender) {
|
|
16
|
+
throw new Error('No mailgun sender specified.');
|
|
17
|
+
}
|
|
18
|
+
else if (!config.messages) {
|
|
19
|
+
throw new Error('No mailgun messages config specified.');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.MailgunServiceConfig = MailgunServiceConfig;
|
|
24
|
+
//# sourceMappingURL=mailgun.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.config.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.config.ts"],"names":[],"mappings":";;;AAIA,MAAsB,oBAAoB;IAqBxC,MAAM,CAAC,iBAAiB,CAAC,MAA4B;QACnD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACnD;aAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;SAC9C;aAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;aAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;aAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;IACH,CAAC;CACF;AAlCD,oDAkCC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ArrayOrValue, EmailAddressDomain, NameEmailPair, EmailParticipantString, Maybe } from '@dereekb/util';
|
|
3
|
+
import APIResponse from 'mailgun.js/interfaces/ApiResponse';
|
|
4
|
+
import { MailgunMessageData, MessagesSendResult } from 'mailgun.js/interfaces/Messages';
|
|
5
|
+
export declare type MailgunSenderDomainString = EmailAddressDomain;
|
|
6
|
+
export declare type MailgunTemplateKey = string;
|
|
7
|
+
export interface MailgunRecipient extends NameEmailPair {
|
|
8
|
+
userVariables?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface MailgunEmailRequest {
|
|
11
|
+
from?: MailgunRecipient;
|
|
12
|
+
to: ArrayOrValue<MailgunRecipient>;
|
|
13
|
+
subject: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MailgunFileAttachment {
|
|
16
|
+
/**
|
|
17
|
+
* File name
|
|
18
|
+
*/
|
|
19
|
+
filename: string;
|
|
20
|
+
/**
|
|
21
|
+
* File data as a buffer or string.
|
|
22
|
+
*/
|
|
23
|
+
data: Buffer | string;
|
|
24
|
+
}
|
|
25
|
+
export interface MailgunTemplateEmailParameters {
|
|
26
|
+
/**
|
|
27
|
+
* Mailgun template name.
|
|
28
|
+
*/
|
|
29
|
+
template: MailgunTemplateKey;
|
|
30
|
+
/**
|
|
31
|
+
* Template variables. Each value is converted to a JSON string before being sent to Mailgun server.
|
|
32
|
+
*/
|
|
33
|
+
templateVariables?: Record<string, any>;
|
|
34
|
+
/**
|
|
35
|
+
* Sends a test email to the Mailgun API
|
|
36
|
+
*/
|
|
37
|
+
testEmail?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface MailgunTemplateEmailRequest extends MailgunEmailRequest, MailgunTemplateEmailParameters {
|
|
40
|
+
/**
|
|
41
|
+
* Attachment(s) to send with the email.
|
|
42
|
+
*/
|
|
43
|
+
attachments?: ArrayOrValue<MailgunFileAttachment>;
|
|
44
|
+
/**
|
|
45
|
+
* Apply custom parameters directly.
|
|
46
|
+
*/
|
|
47
|
+
messageData?: Partial<MailgunMessageData>;
|
|
48
|
+
}
|
|
49
|
+
export declare type MailgunEmailMessageSendResult = MessagesSendResult;
|
|
50
|
+
export declare type MailgunAPIResponse = APIResponse;
|
|
51
|
+
export declare const DEFAULT_RECIPIENT_VARIABLE_PREFIX = "recipient-";
|
|
52
|
+
export interface ConvertMailgunTemplateEmailRequestToMailgunMessageDataConfig {
|
|
53
|
+
readonly request: MailgunTemplateEmailRequest;
|
|
54
|
+
readonly defaultSender?: string;
|
|
55
|
+
readonly recipientVariablePrefix?: Maybe<string | false>;
|
|
56
|
+
readonly testEnvironment?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export declare function convertMailgunTemplateEmailRequestToMailgunMessageData(config: ConvertMailgunTemplateEmailRequestToMailgunMessageDataConfig): MailgunMessageData;
|
|
59
|
+
export declare function convertMailgunRecipientsToStrings(recipients: MailgunRecipient[]): EmailParticipantString[];
|
|
60
|
+
export declare function convertMailgunRecipientToString(recipient: MailgunRecipient): EmailParticipantString;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertMailgunRecipientToString = exports.convertMailgunRecipientsToStrings = exports.convertMailgunTemplateEmailRequestToMailgunMessageData = exports.DEFAULT_RECIPIENT_VARIABLE_PREFIX = void 0;
|
|
4
|
+
const nestjs_1 = require("@dereekb/nestjs");
|
|
5
|
+
const util_1 = require("@dereekb/util");
|
|
6
|
+
exports.DEFAULT_RECIPIENT_VARIABLE_PREFIX = 'recipient-';
|
|
7
|
+
function convertMailgunTemplateEmailRequestToMailgunMessageData(config) {
|
|
8
|
+
const { request, defaultSender, testEnvironment, recipientVariablePrefix = exports.DEFAULT_RECIPIENT_VARIABLE_PREFIX } = config;
|
|
9
|
+
const toInput = (0, util_1.asArray)(request.to).map((x) => (Object.assign(Object.assign({}, x), { email: x.email.toLowerCase() })));
|
|
10
|
+
const from = request.from ? convertMailgunRecipientToString(request.from) : defaultSender;
|
|
11
|
+
const to = convertMailgunRecipientsToStrings(toInput);
|
|
12
|
+
const data = Object.assign({ from,
|
|
13
|
+
to, subject: request.subject, template: request.template }, request.messageData);
|
|
14
|
+
if (request.testEmail === true || ((testEnvironment !== null && testEnvironment !== void 0 ? testEnvironment : (0, nestjs_1.isTestNodeEnv)()) && request.testEmail !== false)) {
|
|
15
|
+
data['o:testmode'] = true;
|
|
16
|
+
}
|
|
17
|
+
if (request.templateVariables) {
|
|
18
|
+
(0, util_1.forEachKeyValue)(request.templateVariables, {
|
|
19
|
+
forEach: (x) => {
|
|
20
|
+
const [key, value] = x;
|
|
21
|
+
data[`v:${key}`] = JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const hasUserVariables = Boolean(data['recipient-variables']) || toInput.findIndex((x) => x.userVariables != null) !== -1;
|
|
26
|
+
if (hasUserVariables) {
|
|
27
|
+
const recipientVariables = {};
|
|
28
|
+
const allRecipientVariableKeys = new Set();
|
|
29
|
+
toInput.forEach(({ email, userVariables }) => {
|
|
30
|
+
if (userVariables != null && !(0, util_1.objectIsEmpty)(userVariables)) {
|
|
31
|
+
recipientVariables[email] = userVariables;
|
|
32
|
+
(0, util_1.addToSet)(allRecipientVariableKeys, Object.keys(userVariables));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (data['recipient-variables']) {
|
|
36
|
+
const decoded = JSON.parse(data['recipient-variables']);
|
|
37
|
+
(0, util_1.forEachKeyValue)(decoded, {
|
|
38
|
+
forEach: (x) => {
|
|
39
|
+
const [recipientEmail, userVariables] = x;
|
|
40
|
+
const email = recipientEmail.toLowerCase();
|
|
41
|
+
if (recipientVariables[email] != null) {
|
|
42
|
+
(0, util_1.overrideInObject)(recipientVariables[email], { from: [userVariables], filter: { valueFilter: util_1.KeyValueTypleValueFilter.UNDEFINED } });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
recipientVariables[email] = userVariables;
|
|
46
|
+
}
|
|
47
|
+
(0, util_1.addToSet)(allRecipientVariableKeys, Object.keys(userVariables));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
data['recipient-variables'] = JSON.stringify(recipientVariables);
|
|
52
|
+
// add all recipient variable to the other variables so they can be used easily/directly in templates as variables too.
|
|
53
|
+
// https://documentation.mailgun.com/en/latest/user_manual.html#attaching-data-to-messages
|
|
54
|
+
if (recipientVariablePrefix) {
|
|
55
|
+
(0, util_1.forEachInIterable)(allRecipientVariableKeys, (key) => {
|
|
56
|
+
const recipientVariableKey = `${recipientVariablePrefix}${key}`;
|
|
57
|
+
// v:recipient-id=%recipient.id%
|
|
58
|
+
data[`v:${recipientVariableKey}`] = `%recipient.${key}%`;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const inputAttachments = request.attachments;
|
|
63
|
+
if (inputAttachments) {
|
|
64
|
+
if (data.attachment) {
|
|
65
|
+
throw new Error(`Cannot specify attachments in both messageData and in the request's attachments field.`);
|
|
66
|
+
}
|
|
67
|
+
data.attachment = inputAttachments;
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
71
|
+
exports.convertMailgunTemplateEmailRequestToMailgunMessageData = convertMailgunTemplateEmailRequestToMailgunMessageData;
|
|
72
|
+
function convertMailgunRecipientsToStrings(recipients) {
|
|
73
|
+
return recipients.map((x) => convertMailgunRecipientToString(x));
|
|
74
|
+
}
|
|
75
|
+
exports.convertMailgunRecipientsToStrings = convertMailgunRecipientsToStrings;
|
|
76
|
+
function convertMailgunRecipientToString(recipient) {
|
|
77
|
+
let address = recipient.email;
|
|
78
|
+
if (recipient.name) {
|
|
79
|
+
address = `${recipient.name} <${address}>`;
|
|
80
|
+
}
|
|
81
|
+
return address;
|
|
82
|
+
}
|
|
83
|
+
exports.convertMailgunRecipientToString = convertMailgunRecipientToString;
|
|
84
|
+
//# sourceMappingURL=mailgun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAChD,wCAA+O;AAyDlO,QAAA,iCAAiC,GAAG,YAAY,CAAC;AAS9D,SAAgB,sDAAsD,CAAC,MAAoE;IACzI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,yCAAiC,EAAE,GAAG,MAAM,CAAC;IACxH,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCAAM,CAAC,KAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,IAAG,CAAC,CAAC;IAEzF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,+BAA+B,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAC1F,M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,oBAAoB,EAAE,CAAC,GAAG,cAAc,GAAG,GAAG,CAAC;YAC3D,CAAC,CAAC,CAAC;SACJ;KACF;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAE7C,IAAI,gBAAgB,EAAE;QACpB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,wFAAwF,CAAC,CAAC;SAC3G;QAED,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AArFD,wHAqFC;AAED,SAAgB,iCAAiC,CAAC,UAA8B;IAC9E,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAFD,8EAEC;AAED,SAAgB,+BAA+B,CAAC,SAA2B;IACzE,IAAI,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC;IAE9B,IAAI,SAAS,CAAC,IAAI,EAAE;QAClB,OAAO,GAAG,GAAG,SAAS,CAAC,IAAI,KAAK,OAAO,GAAG,CAAC;KAC5C;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AARD,0EAQC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ServerEnvironmentService } from '@dereekb/nestjs';
|
|
2
|
+
import { MailgunTemplateEmailRequest, MailgunEmailMessageSendResult } from './mailgun';
|
|
3
|
+
import { MailgunApi } from './mailgun.api';
|
|
4
|
+
export declare class MailgunService {
|
|
5
|
+
readonly mailgunApi: MailgunApi;
|
|
6
|
+
readonly serverEnvironmentService: ServerEnvironmentService;
|
|
7
|
+
constructor(mailgunApi: MailgunApi, serverEnvironmentService: ServerEnvironmentService);
|
|
8
|
+
sendTemplateEmail(request: MailgunTemplateEmailRequest): Promise<MailgunEmailMessageSendResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailgunService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const nestjs_1 = require("@dereekb/nestjs");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const mailgun_1 = require("./mailgun");
|
|
8
|
+
const mailgun_api_1 = require("./mailgun.api");
|
|
9
|
+
let MailgunService = class MailgunService {
|
|
10
|
+
constructor(mailgunApi, serverEnvironmentService) {
|
|
11
|
+
this.mailgunApi = mailgunApi;
|
|
12
|
+
this.serverEnvironmentService = serverEnvironmentService;
|
|
13
|
+
}
|
|
14
|
+
sendTemplateEmail(request) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const domain = this.mailgunApi.domain;
|
|
17
|
+
const sender = this.mailgunApi.sender;
|
|
18
|
+
const testEnvironment = this.serverEnvironmentService.isTestingEnv;
|
|
19
|
+
const { recipientVariablePrefix } = this.mailgunApi.config.messages;
|
|
20
|
+
const data = (0, mailgun_1.convertMailgunTemplateEmailRequestToMailgunMessageData)({ request, defaultSender: sender, recipientVariablePrefix, testEnvironment });
|
|
21
|
+
let result;
|
|
22
|
+
try {
|
|
23
|
+
result = yield this.mailgunApi.messages.create(domain, data);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
console.error('Failed sending email: ', e);
|
|
27
|
+
throw e;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
MailgunService = tslib_1.__decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
tslib_1.__metadata("design:paramtypes", [mailgun_api_1.MailgunApi, nestjs_1.ServerEnvironmentService])
|
|
36
|
+
], MailgunService);
|
|
37
|
+
exports.MailgunService = MailgunService;
|
|
38
|
+
//# sourceMappingURL=mailgun.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.service.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.service.ts"],"names":[],"mappings":";;;;AAAA,4CAA2D;AAC3D,2CAA4C;AAC5C,uCAA+I;AAC/I,+CAA2C;AAG3C,IAAa,cAAc,GAA3B,MAAa,cAAc;IACzB,YAA4B,UAAsB,EAAW,wBAAkD;QAAnF,eAAU,GAAV,UAAU,CAAY;QAAW,6BAAwB,GAAxB,wBAAwB,CAA0B;IAAG,CAAC;IAE7G,iBAAiB,CAAC,OAAoC;;YAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACtC,MAAM,eAAe,GAAG,IAAI,CAAC,wBAAwB,CAAC,YAAY,CAAC;YACnE,MAAM,EAAE,uBAAuB,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpE,MAAM,IAAI,GAAG,IAAA,gEAAsD,EAAC,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,CAAC,CAAC;YAElJ,IAAI,MAAM,CAAC;YAEX,IAAI;gBACF,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAC9D;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC;gBAC3C,MAAM,CAAC,CAAC;aACT;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAA;AArBY,cAAc;IAD1B,IAAA,mBAAU,GAAE;6CAE6B,wBAAU,EAAqC,iCAAwB;GADpG,cAAc,CAqB1B;AArBY,wCAAc"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServerEnvironmentService } from '@dereekb/nestjs';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { MailgunServiceConfig } from './mailgun.config';
|
|
4
|
+
export declare function mailgunServiceConfigFactory(configService: ConfigService, serverEnvironmentService: ServerEnvironmentService): MailgunServiceConfig;
|
|
5
|
+
export declare class MailgunServiceModule {
|
|
6
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailgunServiceModule = exports.mailgunServiceConfigFactory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const nestjs_1 = require("@dereekb/nestjs");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const config_1 = require("@nestjs/config");
|
|
8
|
+
const mailgun_1 = require("./mailgun");
|
|
9
|
+
const mailgun_api_1 = require("./mailgun.api");
|
|
10
|
+
const mailgun_config_1 = require("./mailgun.config");
|
|
11
|
+
const mailgun_service_1 = require("./mailgun.service");
|
|
12
|
+
function mailgunServiceConfigFactory(configService, serverEnvironmentService) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const useSandbox = (_a = configService.get('USE_MAILGUN_SANDBOX')) !== null && _a !== void 0 ? _a : false;
|
|
15
|
+
let key = configService.get('MAILGUN_API_KEY');
|
|
16
|
+
let domain = configService.get('MAILGUN_DOMAIN');
|
|
17
|
+
if (useSandbox) {
|
|
18
|
+
key = configService.get('MAILGUN_SANDBOX_API_KEY');
|
|
19
|
+
domain = configService.get('MAILGUN_SANDBOX_DOMAIN');
|
|
20
|
+
if (!key || !domain) {
|
|
21
|
+
throw new Error('USE_MAILGUN_SANDBOX is set to "true", but no sandbox variables (MAILGUN_SANDBOX_API_KEY, MAILGUN_SANDBOX_DOMAIN) are provided.');
|
|
22
|
+
}
|
|
23
|
+
else if (!serverEnvironmentService.isTestingEnv) {
|
|
24
|
+
console.log('Using Mailgun Sandbox Domain: ', domain);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else if (!serverEnvironmentService.isTestingEnv) {
|
|
28
|
+
console.log('Using Mailgun Production Domain: ', domain);
|
|
29
|
+
}
|
|
30
|
+
const name = configService.get('MAILGUN_SENDER_NAME');
|
|
31
|
+
const email = configService.get('MAILGUN_SENDER_EMAIL');
|
|
32
|
+
const url = configService.get('MAILGUN_API_URL');
|
|
33
|
+
const recipientVariablePrefix = (_b = configService.get('MAILGUN_MESSAGES_RECIPIENT_VARIABLE_PREFIX')) !== null && _b !== void 0 ? _b : undefined;
|
|
34
|
+
if (!email) {
|
|
35
|
+
throw new Error('MAILGUN_SENDER_EMAIL is required but was not configured.');
|
|
36
|
+
}
|
|
37
|
+
else if (!key) {
|
|
38
|
+
throw new Error('MAILGUN_API_KEY is required but was not configured.');
|
|
39
|
+
}
|
|
40
|
+
else if (!domain) {
|
|
41
|
+
throw new Error('MAILGUN_DOMAIN is required but was not configured.');
|
|
42
|
+
}
|
|
43
|
+
const config = {
|
|
44
|
+
mailgun: {
|
|
45
|
+
username: (_c = configService.get('MAILGUN_USERNAME')) !== null && _c !== void 0 ? _c : 'api',
|
|
46
|
+
key,
|
|
47
|
+
url
|
|
48
|
+
},
|
|
49
|
+
domain,
|
|
50
|
+
sender: (0, mailgun_1.convertMailgunRecipientToString)({
|
|
51
|
+
name,
|
|
52
|
+
email
|
|
53
|
+
}),
|
|
54
|
+
messages: {
|
|
55
|
+
recipientVariablePrefix
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
mailgun_config_1.MailgunServiceConfig.assertValidConfig(config);
|
|
59
|
+
return config;
|
|
60
|
+
}
|
|
61
|
+
exports.mailgunServiceConfigFactory = mailgunServiceConfigFactory;
|
|
62
|
+
let MailgunServiceModule = class MailgunServiceModule {
|
|
63
|
+
};
|
|
64
|
+
MailgunServiceModule = tslib_1.__decorate([
|
|
65
|
+
(0, common_1.Module)({
|
|
66
|
+
imports: [config_1.ConfigModule],
|
|
67
|
+
providers: [
|
|
68
|
+
{
|
|
69
|
+
provide: mailgun_config_1.MailgunServiceConfig,
|
|
70
|
+
inject: [config_1.ConfigService, nestjs_1.ServerEnvironmentService],
|
|
71
|
+
useFactory: mailgunServiceConfigFactory
|
|
72
|
+
},
|
|
73
|
+
mailgun_api_1.MailgunApi,
|
|
74
|
+
mailgun_service_1.MailgunService
|
|
75
|
+
],
|
|
76
|
+
exports: [mailgun_api_1.MailgunApi, mailgun_service_1.MailgunService]
|
|
77
|
+
})
|
|
78
|
+
], MailgunServiceModule);
|
|
79
|
+
exports.MailgunServiceModule = MailgunServiceModule;
|
|
80
|
+
//# sourceMappingURL=mailgun.service.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.service.module.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.service.module.ts"],"names":[],"mappings":";;;;AAAA,4CAA2D;AAC3D,2CAAwC;AACxC,2CAA6D;AAC7D,uCAA4D;AAC5D,+CAA2C;AAC3C,qDAAwD;AACxD,uDAAmD;AAEnD,SAAgB,2BAA2B,CAAC,aAA4B,EAAE,wBAAkD;;IAC1H,MAAM,UAAU,GAAG,MAAA,aAAa,CAAC,GAAG,CAAU,qBAAqB,CAAC,mCAAI,KAAK,CAAC;IAE9E,IAAI,GAAG,GAAG,aAAa,CAAC,GAAG,CAAS,iBAAiB,CAAC,CAAC;IACvD,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAS,gBAAgB,CAAC,CAAC;IAEzD,IAAI,UAAU,EAAE;QACd,GAAG,GAAG,aAAa,CAAC,GAAG,CAAS,yBAAyB,CAAC,CAAC;QAC3D,MAAM,GAAG,aAAa,CAAC,GAAG,CAAS,wBAAwB,CAAC,CAAC;QAE7D,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,gIAAgI,CAAC,CAAC;SACnJ;aAAM,IAAI,CAAC,wBAAwB,CAAC,YAAY,EAAE;YACjD,OAAO,CAA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BAAY,CAAC;QACvB,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,qCAAoB;gBAC7B,MAAM,EAAE,CAAC,sBAAa,EAAE,iCAAwB,CAAC;gBACjD,UAAU,EAAE,2BAA2B;aACxC;YACD,wBAAU;YACV,gCAAc;SACf;QACD,OAAO,EAAE,CAAC,wBAAU,EAAE,gCAAc,CAAC;KACtC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import Mailgun from 'mailgun.js';
|
|
2
|
+
import Options from 'mailgun.js/interfaces/Options';
|
|
3
|
+
export declare type MailgunOptions = Options;
|
|
4
|
+
export declare type MailgunClient = ReturnType<Mailgun['client']>;
|
|
5
|
+
export declare type MailgunMessagesClient = ReturnType<Mailgun['client']>['messages'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailgun.type.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/mailgun/src/lib/mailgun.type.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/nestjs",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@nestjs/common": "^9.0.0",
|
|
22
22
|
"@nestjs/config": "^2.0.1",
|
|
23
|
-
"@dereekb/util": "9.
|
|
23
|
+
"@dereekb/util": "9.9.0",
|
|
24
24
|
"lodash.isequal": "^4.5.0",
|
|
25
25
|
"make-error": "^1.3.0",
|
|
26
26
|
"ts-essentials": "^9.1.2",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A server environment configuration.
|
|
3
|
+
*
|
|
4
|
+
* Explicitly states whether or not this is a production environment, and optionally some other config.
|
|
5
|
+
*
|
|
6
|
+
* This config is not meant to replace other typical configurations, like .env files, but instead is part of the build system.
|
|
7
|
+
*/
|
|
8
|
+
export interface ServerEnvironmentConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not this is a production environment.
|
|
11
|
+
*/
|
|
12
|
+
production: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* (Optional) Whether or not custom "developer tools" should be enabled.
|
|
15
|
+
*
|
|
16
|
+
* In general this is referred to in order to check whether or not to allow skipping typical safety checks in order to speed up local development.
|
|
17
|
+
*
|
|
18
|
+
* This is always false when production is true.
|
|
19
|
+
*/
|
|
20
|
+
developerToolsEnabled?: boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.config.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/src/lib/module/env/env.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTestNodeEnv = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks process.env.NODE_ENV for "test"
|
|
6
|
+
*/
|
|
7
|
+
function isTestNodeEnv() {
|
|
8
|
+
return process.env['NODE_ENV'] === 'test';
|
|
9
|
+
}
|
|
10
|
+
exports.isTestNodeEnv = isTestNodeEnv;
|
|
11
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/src/lib/module/env/env.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,CAAC;AAC5C,CAAC;AAFD,sCAEC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@nestjs/common';
|
|
2
|
+
import { ServerEnvironmentConfig } from './env.config';
|
|
3
|
+
/**
|
|
4
|
+
* Token to access a configured ServerEnvironmentServiceConfig for the app.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SERVER_ENV_TOKEN: InjectionToken;
|
|
7
|
+
export declare function serverEnvTokenProvider<T extends ServerEnvironmentConfig = ServerEnvironmentConfig>(env: T): Provider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serverEnvTokenProvider = exports.SERVER_ENV_TOKEN = void 0;
|
|
4
|
+
// MARK: Tokens
|
|
5
|
+
/**
|
|
6
|
+
* Token to access a configured ServerEnvironmentServiceConfig for the app.
|
|
7
|
+
*/
|
|
8
|
+
exports.SERVER_ENV_TOKEN = 'SERVER_ENV_TOKEN';
|
|
9
|
+
function serverEnvTokenProvider(env) {
|
|
10
|
+
return {
|
|
11
|
+
provide: exports.SERVER_ENV_TOKEN,
|
|
12
|
+
useValue: env
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.serverEnvTokenProvider = serverEnvTokenProvider;
|
|
16
|
+
//# sourceMappingURL=env.nest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.nest.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/src/lib/module/env/env.nest.ts"],"names":[],"mappings":";;;AAGA,eAAe;AACf;;GAEG;AACU,QAAA,gBAAgB,GAAmB,kBAAkB,CAAC;AAEnE,SAAgB,sBAAsB,CAA8D,GAAM;IACxG,OAAO;QACL,OAAO,EAAE,wBAAgB;QACzB,QAAQ,EAAE,GAAG;KACd,CAAC;AACJ,CAAC;AALD,wDAKC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ServerEnvironmentConfig } from './env.config';
|
|
2
|
+
export declare class ServerEnvironmentService {
|
|
3
|
+
readonly env: ServerEnvironmentConfig;
|
|
4
|
+
constructor(env: ServerEnvironmentConfig);
|
|
5
|
+
get isTestingEnv(): boolean;
|
|
6
|
+
get isProduction(): boolean;
|
|
7
|
+
get developerToolsEnabled(): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServerEnvironmentService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const env_1 = require("./env");
|
|
7
|
+
const env_nest_1 = require("./env.nest");
|
|
8
|
+
let ServerEnvironmentService = class ServerEnvironmentService {
|
|
9
|
+
constructor(env) {
|
|
10
|
+
this.env = env;
|
|
11
|
+
}
|
|
12
|
+
get isTestingEnv() {
|
|
13
|
+
return (0, env_1.isTestNodeEnv)();
|
|
14
|
+
}
|
|
15
|
+
get isProduction() {
|
|
16
|
+
return this.env.production;
|
|
17
|
+
}
|
|
18
|
+
get developerToolsEnabled() {
|
|
19
|
+
return Boolean(!this.isProduction && this.env.developerToolsEnabled);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
ServerEnvironmentService = tslib_1.__decorate([
|
|
23
|
+
(0, common_1.Injectable)(),
|
|
24
|
+
tslib_1.__param(0, (0, common_1.Inject)(env_nest_1.SERVER_ENV_TOKEN)),
|
|
25
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
26
|
+
], ServerEnvironmentService);
|
|
27
|
+
exports.ServerEnvironmentService = ServerEnvironmentService;
|
|
28
|
+
//# sourceMappingURL=env.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.service.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/src/lib/module/env/env.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,+BAAsC;AAEtC,yCAA8C;AAG9C,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IACnC,YAA+C,GAA4B;QAA5B,QAAG,GAAH,GAAG,CAAyB;IAAG,CAAC;IAE/E,IAAI,YAAY;QACd,OAAO,IAAA,mBAAa,GAAE,CAAC;IACzB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AAdY,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAEE,mBAAA,IAAA,eAAM,EAAC,2BAAgB,CAAC,CAAA;;GAD1B,wBAAwB,CAcpC;AAdY,4DAAwB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./env.config"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./env.nest"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./env.service"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./env"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nestjs/src/lib/module/env/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,qDAA2B;AAC3B,wDAA8B;AAC9B,gDAAsB"}
|
package/src/lib/module/index.js
CHANGED
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./module"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./client"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./env"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/src/lib/module/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,mDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nestjs/src/lib/module/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,mDAAyB;AACzB,gDAAsB"}
|
package/stripe/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [9.9.0](https://github.com/dereekb/dbx-components/compare/v9.8.0-dev...v9.9.0) (2022-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# [9.8.0](https://github.com/dereekb/dbx-components/compare/v9.7.7-dev...v9.8.0) (2022-09-15)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.7.7](https://github.com/dereekb/dbx-components/compare/v9.7.6-dev...v9.7.7) (2022-09-12)
|
|
6
14
|
|
|
7
15
|
|
package/stripe/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/nestjs/stripe",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.9.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "9.
|
|
9
|
+
"@dereekb/util": "9.9.0",
|
|
10
10
|
"lodash.isequal": "^4.5.0",
|
|
11
11
|
"make-error": "^1.3.0",
|
|
12
12
|
"ts-essentials": "^9.1.2",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"stripe": "^9.1.0",
|
|
15
15
|
"@nestjs/common": "^9.0.0",
|
|
16
16
|
"@nestjs/config": "^2.0.1",
|
|
17
|
-
"@dereekb/nestjs": "9.
|
|
17
|
+
"@dereekb/nestjs": "9.9.0",
|
|
18
18
|
"tslib": "^2.0.0"
|
|
19
19
|
}
|
|
20
20
|
}
|