@spinajs/email
Advanced tools
Comparing version 2.0.46 to 2.0.48
@@ -17,1 +17,2 @@ import { CliCommand } from '@spinajs/cli'; | ||
export {}; | ||
//# sourceMappingURL=SendEmail.d.ts.map |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -24,24 +7,15 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SendEmailCommand = void 0; | ||
const cli_1 = require("@spinajs/cli"); | ||
const di_1 = require("@spinajs/di"); | ||
const fs = __importStar(require("fs")); | ||
const log_1 = require("@spinajs/log"); | ||
const index_1 = require("./../index"); | ||
let SendEmailCommand = class SendEmailCommand extends cli_1.CliCommand { | ||
import { CliCommand, Command, Option } from '@spinajs/cli'; | ||
import { DI } from '@spinajs/di'; | ||
import * as fs from 'fs'; | ||
import { Logger } from '@spinajs/log'; | ||
import { DefaultEmailService } from './../index.js'; | ||
let SendEmailCommand = class SendEmailCommand extends CliCommand { | ||
async execute(options) { | ||
this.Log.trace(`Sending email with options options: ${JSON.stringify(options)}`); | ||
try { | ||
const emails = await di_1.DI.resolve(index_1.DefaultEmailService); | ||
const emails = await DI.resolve(DefaultEmailService); | ||
let model = {}; | ||
@@ -70,16 +44,16 @@ if (options.model && fs.existsSync(options.model)) { | ||
__decorate([ | ||
(0, log_1.Logger)('email'), | ||
Logger('email'), | ||
__metadata("design:type", Object) | ||
], SendEmailCommand.prototype, "Log", void 0); | ||
SendEmailCommand = __decorate([ | ||
(0, cli_1.Command)('email-send', 'Sends email, mainly for testing purpose or scheduled tasks'), | ||
(0, cli_1.Option)('-c, --connection [connection]', true, 'name of connection'), | ||
(0, cli_1.Option)('-f, --from [from]', true, 'from email'), | ||
(0, cli_1.Option)('-t, --to [to]', true, 'receipients, can be many ( comma separated )'), | ||
(0, cli_1.Option)('-e, --template [template]', false, 'template name'), | ||
(0, cli_1.Option)('-m, --model [model]', false, 'path to model data for template, in json format'), | ||
(0, cli_1.Option)('-s, --subject [model]', true, 'subject'), | ||
(0, cli_1.Option)('-c, --content [content]', false, 'text content if template is not provided') | ||
Command('email-send', 'Sends email, mainly for testing purpose or scheduled tasks'), | ||
Option('-c, --connection [connection]', true, 'name of connection'), | ||
Option('-f, --from [from]', true, 'from email'), | ||
Option('-t, --to [to]', true, 'receipients, can be many ( comma separated )'), | ||
Option('-e, --template [template]', false, 'template name'), | ||
Option('-m, --model [model]', false, 'path to model data for template, in json format'), | ||
Option('-s, --subject [model]', true, 'subject'), | ||
Option('-c, --content [content]', false, 'text content if template is not provided') | ||
], SendEmailCommand); | ||
exports.SendEmailCommand = SendEmailCommand; | ||
export { SendEmailCommand }; | ||
//# sourceMappingURL=SendEmail.js.map |
@@ -29,1 +29,2 @@ declare const email: { | ||
export default email; | ||
//# sourceMappingURL=email.d.ts.map |
@@ -1,6 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path_1 = require("path"); | ||
import { join, normalize, resolve } from 'path'; | ||
function dir(path) { | ||
return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(__dirname, path))); | ||
return resolve(normalize(join(__dirname, path))); | ||
} | ||
@@ -34,3 +32,3 @@ const email = { | ||
}; | ||
exports.default = email; | ||
export default email; | ||
//# sourceMappingURL=email.js.map |
import { QueueEvent } from '@spinajs/queue'; | ||
import { DateTime } from 'luxon'; | ||
import { IEmail } from '../interfaces'; | ||
import { IEmail } from '../interfaces.js'; | ||
export declare class EmailSent extends QueueEvent { | ||
@@ -24,1 +24,2 @@ Connection?: string; | ||
} | ||
//# sourceMappingURL=EmailSent.d.ts.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -11,7 +10,5 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EmailSent = void 0; | ||
const queue_1 = require("@spinajs/queue"); | ||
const luxon_1 = require("luxon"); | ||
let EmailSent = class EmailSent extends queue_1.QueueEvent { | ||
import { QueueEvent, Event } from '@spinajs/queue'; | ||
import { DateTime } from 'luxon'; | ||
let EmailSent = class EmailSent extends QueueEvent { | ||
constructor(email) { | ||
@@ -26,10 +23,10 @@ super(); | ||
this.Content = email.text; | ||
this.SentAt = luxon_1.DateTime.now(); | ||
this.SentAt = DateTime.now(); | ||
} | ||
}; | ||
EmailSent = __decorate([ | ||
(0, queue_1.Event)(), | ||
Event(), | ||
__metadata("design:paramtypes", [Object]) | ||
], EmailSent); | ||
exports.EmailSent = EmailSent; | ||
export { EmailSent }; | ||
//# sourceMappingURL=EmailSent.js.map |
import { Bootstrapper } from '@spinajs/di'; | ||
import { IEmail, EmailService } from './interfaces'; | ||
import { EmailSend } from './jobs/EmailSend'; | ||
export * from './interfaces'; | ||
export * from './transports'; | ||
export * from './jobs/EmailSend'; | ||
import { IEmail, EmailService } from './interfaces.js'; | ||
import { EmailSend } from './jobs/EmailSend.js'; | ||
export * from './interfaces.js'; | ||
export * from './transports.js'; | ||
export * from './jobs/EmailSend.js'; | ||
export declare class LogBotstrapper extends Bootstrapper { | ||
@@ -24,1 +24,2 @@ bootstrap(): void; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,13 +0,1 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -19,32 +7,24 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DefaultEmailService = exports.LogBotstrapper = void 0; | ||
const exceptions_1 = require("@spinajs/exceptions"); | ||
const di_1 = require("@spinajs/di"); | ||
const interfaces_1 = require("./interfaces"); | ||
const email_smtp_configuration_1 = __importDefault(require("./schemas/email.smtp.configuration")); | ||
const EmailSent_1 = require("./events/EmailSent"); | ||
const EmailSend_1 = require("./jobs/EmailSend"); | ||
__exportStar(require("./interfaces"), exports); | ||
__exportStar(require("./transports"), exports); | ||
__exportStar(require("./jobs/EmailSend"), exports); | ||
let LogBotstrapper = class LogBotstrapper extends di_1.Bootstrapper { | ||
import { InvalidOperation } from '../../exceptions/lib/index.js'; | ||
import { DI, Bootstrapper, Injectable } from '@spinajs/di'; | ||
import { EmailService } from './interfaces.js'; | ||
import CONFIGURATION_SCHEMA from './schemas/email.smtp.configuration.js'; | ||
import { EmailSent } from './events/EmailSent.js'; | ||
import { EmailSend } from './jobs/EmailSend.js'; | ||
export * from './interfaces.js'; | ||
export * from './transports.js'; | ||
export * from './jobs/EmailSend.js'; | ||
let LogBotstrapper = class LogBotstrapper extends Bootstrapper { | ||
bootstrap() { | ||
di_1.DI.register(email_smtp_configuration_1.default).asValue('__configurationSchema__'); | ||
DI.register(CONFIGURATION_SCHEMA).asValue('__configurationSchema__'); | ||
} | ||
}; | ||
LogBotstrapper = __decorate([ | ||
(0, di_1.Injectable)(di_1.Bootstrapper) | ||
Injectable(Bootstrapper) | ||
], LogBotstrapper); | ||
exports.LogBotstrapper = LogBotstrapper; | ||
export { LogBotstrapper }; | ||
/** | ||
* Email sending service. | ||
*/ | ||
let DefaultEmailService = class DefaultEmailService extends interfaces_1.EmailService { | ||
let DefaultEmailService = class DefaultEmailService extends EmailService { | ||
/** | ||
@@ -58,10 +38,10 @@ * | ||
if (!this.Senders.has(email.connection)) { | ||
throw new exceptions_1.InvalidOperation(`Email sender ${email.connection} not exists. Please check your configuration files.`); | ||
throw new InvalidOperation(`Email sender ${email.connection} not exists. Please check your configuration files.`); | ||
} | ||
await this.Senders.get(email.connection).send(email); | ||
// inform others of email event | ||
await this.Queue.emit(new EmailSent_1.EmailSent(email)); | ||
await this.Queue.emit(new EmailSent(email)); | ||
} | ||
async sendDeferred(email) { | ||
const dEmail = new EmailSend_1.EmailSend(); | ||
const dEmail = new EmailSend(); | ||
dEmail.hydrate(email); | ||
@@ -72,9 +52,9 @@ await this.Queue.emit(dEmail); | ||
async processDefferedEmails() { | ||
await this.Queue.consume(EmailSend_1.EmailSend); | ||
await this.Queue.consume(EmailSend); | ||
} | ||
}; | ||
DefaultEmailService = __decorate([ | ||
(0, di_1.Injectable)(interfaces_1.EmailService) | ||
Injectable(EmailService) | ||
], DefaultEmailService); | ||
exports.DefaultEmailService = DefaultEmailService; | ||
export { DefaultEmailService }; | ||
//# sourceMappingURL=index.js.map |
import { AsyncService, IInstanceCheck, IMappableService } from '@spinajs/di'; | ||
import { Log } from '@spinajs/log'; | ||
import { QueueService } from '@spinajs/queue'; | ||
import { EmailSend } from './jobs/EmailSend'; | ||
import { EmailSend } from './jobs/EmailSend.js'; | ||
export declare abstract class EmailSender extends AsyncService implements IInstanceCheck, IMappableService { | ||
@@ -115,1 +115,2 @@ Options: EmailConnectionOptions; | ||
} | ||
//# sourceMappingURL=interfaces.d.ts.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -11,9 +10,7 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EmailService = exports.EmailSender = void 0; | ||
const di_1 = require("@spinajs/di"); | ||
const log_1 = require("@spinajs/log"); | ||
const configuration_1 = require("@spinajs/configuration"); | ||
const queue_1 = require("@spinajs/queue"); | ||
class EmailSender extends di_1.AsyncService { | ||
import { AsyncService, Autoinject } from '@spinajs/di'; | ||
import { Log, Logger } from '@spinajs/log'; | ||
import { AutoinjectService, Config } from '@spinajs/configuration'; | ||
import { QueueService } from '@spinajs/queue'; | ||
export class EmailSender extends AsyncService { | ||
get ServiceName() { | ||
@@ -26,22 +23,20 @@ return this.Options.name; | ||
} | ||
exports.EmailSender = EmailSender; | ||
class EmailService extends di_1.AsyncService { | ||
export class EmailService extends AsyncService { | ||
} | ||
__decorate([ | ||
(0, log_1.Logger)('email'), | ||
__metadata("design:type", log_1.Log) | ||
Logger('email'), | ||
__metadata("design:type", Log) | ||
], EmailService.prototype, "Log", void 0); | ||
__decorate([ | ||
(0, configuration_1.AutoinjectService)('email.connections', EmailSender), | ||
AutoinjectService('email.connections', EmailSender), | ||
__metadata("design:type", Map) | ||
], EmailService.prototype, "Senders", void 0); | ||
__decorate([ | ||
(0, configuration_1.Config)('email'), | ||
Config('email'), | ||
__metadata("design:type", Object) | ||
], EmailService.prototype, "Configuration", void 0); | ||
__decorate([ | ||
(0, di_1.Autoinject)(queue_1.QueueService), | ||
__metadata("design:type", queue_1.QueueService) | ||
Autoinject(QueueService), | ||
__metadata("design:type", QueueService) | ||
], EmailService.prototype, "Queue", void 0); | ||
exports.EmailService = EmailService; | ||
//# sourceMappingURL=interfaces.js.map |
import { QueueJob } from '@spinajs/queue'; | ||
import { IEmail, IEmailAttachement } from '../interfaces'; | ||
import { IEmail, IEmailAttachement } from '../interfaces.js'; | ||
/** | ||
@@ -31,1 +31,2 @@ * Job for sending emails in background | ||
} | ||
//# sourceMappingURL=EmailSend.d.ts.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -8,14 +7,12 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EmailSend = void 0; | ||
const di_1 = require("@spinajs/di"); | ||
const queue_1 = require("@spinajs/queue"); | ||
const interfaces_1 = require("../interfaces"); | ||
import { DI } from '@spinajs/di'; | ||
import { QueueJob, Job } from '@spinajs/queue'; | ||
import { EmailService } from '../interfaces.js'; | ||
/** | ||
* Job for sending emails in background | ||
*/ | ||
let EmailSend = class EmailSend extends queue_1.QueueJob { | ||
let EmailSend = class EmailSend extends QueueJob { | ||
async execute() { | ||
try { | ||
const emails = await di_1.DI.resolve(interfaces_1.EmailService); | ||
const emails = await DI.resolve(EmailService); | ||
await emails.send(this); | ||
@@ -35,5 +32,5 @@ } | ||
EmailSend = __decorate([ | ||
(0, queue_1.Job)() | ||
Job() | ||
], EmailSend); | ||
exports.EmailSend = EmailSend; | ||
export { EmailSend }; | ||
//# sourceMappingURL=EmailSend.js.map |
@@ -53,1 +53,2 @@ declare const CONFIGURATION_SCHEMA: { | ||
export default CONFIGURATION_SCHEMA; | ||
//# sourceMappingURL=email.smtp.configuration.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CONFIGURATION_SCHEMA = { | ||
@@ -38,3 +36,3 @@ $id: 'spinajs/email.configuration.schema.json', | ||
}; | ||
exports.default = CONFIGURATION_SCHEMA; | ||
export default CONFIGURATION_SCHEMA; | ||
//# sourceMappingURL=email.smtp.configuration.js.map |
@@ -1,2 +0,2 @@ | ||
import { EmailSender } from './interfaces'; | ||
import { EmailSender } from './interfaces.js'; | ||
/** | ||
@@ -10,1 +10,2 @@ * Transport that does nothing. | ||
} | ||
//# sourceMappingURL=transports.d.ts.map |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
@@ -8,6 +7,4 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BlackHoleEmailTransport = void 0; | ||
const di_1 = require("@spinajs/di"); | ||
const interfaces_1 = require("./interfaces"); | ||
import { Injectable, NewInstance } from '@spinajs/di'; | ||
import { EmailSender } from './interfaces.js'; | ||
/** | ||
@@ -18,10 +15,10 @@ * Transport that does nothing. | ||
*/ | ||
let BlackHoleEmailTransport = class BlackHoleEmailTransport extends interfaces_1.EmailSender { | ||
let BlackHoleEmailTransport = class BlackHoleEmailTransport extends EmailSender { | ||
async send() { } | ||
}; | ||
BlackHoleEmailTransport = __decorate([ | ||
(0, di_1.Injectable)(), | ||
(0, di_1.NewInstance)() | ||
Injectable(), | ||
NewInstance() | ||
], BlackHoleEmailTransport); | ||
exports.BlackHoleEmailTransport = BlackHoleEmailTransport; | ||
export { BlackHoleEmailTransport }; | ||
//# sourceMappingURL=transports.js.map |
{ | ||
"name": "@spinajs/email", | ||
"version": "2.0.46", | ||
"version": "2.0.48", | ||
"description": "sending emails easy & reliable way", | ||
"main": "lib/index.js", | ||
"exports": "./lib/index.js", | ||
"type": "module", | ||
"private": false, | ||
"engines": { | ||
"node": ">=16.11" | ||
}, | ||
"scripts": { | ||
"build": "npm run clean && npm run compile", | ||
"compile": "tsc -p tsconfig.build.json", | ||
"clean": "", | ||
"compile": "tsc -b tsconfig.json", | ||
"rimraf": "./node_modules/rimraf/bin.js", | ||
"clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo", | ||
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts", | ||
"coverage": "nyc npm run test", | ||
"build-docs": "rimraf docs && typedoc --options typedoc.json src/", | ||
"prepare": "npm run build", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"lint": "eslint -c .eslintrc.js --ext .ts src --fix", | ||
"prepublishOnly": "npm test && npm run lint", | ||
"lint": "eslint -c .eslintrc.cjs --ext .ts src --fix", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags" | ||
"postinstall": "npm run build" | ||
}, | ||
@@ -41,8 +44,5 @@ "files": [ | ||
"devDependencies": { | ||
"@spinajs/queue-stomp-transport": "^2.0.46", | ||
"@spinajs/templates-handlebars": "^2.0.46", | ||
"@spinajs/templates-pug": "^2.0.46", | ||
"@types/luxon": "^2.3.1", | ||
"@types/node": "^16.11.11", | ||
"@types/nodemailer": "^6.4.4" | ||
"@types/luxon": "^3.2.0", | ||
"@types/node": "^18.11.18", | ||
"@types/nodemailer": "^6.4.7" | ||
}, | ||
@@ -54,3 +54,2 @@ "dependencies": { | ||
"@spinajs/exceptions": "^2.0.39", | ||
"@spinajs/internal-logger": "^2.0.46", | ||
"@spinajs/intl": "^2.0.46", | ||
@@ -61,3 +60,3 @@ "@spinajs/log": "^2.0.46", | ||
}, | ||
"gitHead": "bd560afd6c9a156071102cc6b4f36115b5498e9d" | ||
"gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee" | ||
} |
@@ -0,0 +0,0 @@ # `email` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
36381
8
3
34
Yes
597
1
- Removed@spinajs/internal-logger@^2.0.46