mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-09-17 09:06:48 +07:00
node_modules: update (#322)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
import type { Logger } from '../shared/index.js';
|
||||
import type { MimeNodeEnvelope } from '../mime-node/index.js';
|
||||
import type { default as MailMessage, MailMessageData } from '../mailer/mail-message.js';
|
||||
import type { default as Mail, SentMessageInfo, SendMailOptions, TransportOptions } from '../mailer/index.js';
|
||||
/**
|
||||
* Options for the JSON transport
|
||||
*/
|
||||
export interface JSONTransportOptions extends TransportOptions {
|
||||
/** Selects this transport in createTransport */
|
||||
jsonTransport?: boolean | undefined;
|
||||
/** If true, the message is returned as an object instead of a JSON string */
|
||||
skipEncoding?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* The value the JSON transport hands to the send callback
|
||||
*/
|
||||
export interface JSONSentMessageInfo extends SentMessageInfo {
|
||||
/** The envelope the message was generated with */
|
||||
envelope: MimeNodeEnvelope;
|
||||
/** Message-ID value of the message */
|
||||
messageId: string;
|
||||
/** The normalized message as a JSON string, or as the object itself when skipEncoding is set */
|
||||
message: string | MailMessageData;
|
||||
}
|
||||
/**
|
||||
* Generates a Transport object to generate JSON output
|
||||
*
|
||||
* @constructor
|
||||
* @param optional config parameter
|
||||
*/
|
||||
declare class JSONTransport {
|
||||
mailer: Mail<JSONSentMessageInfo>;
|
||||
options: JSONTransportOptions;
|
||||
name: string;
|
||||
version: string;
|
||||
logger: Logger;
|
||||
constructor(options?: JSONTransportOptions);
|
||||
/**
|
||||
* <p>Compiles a mailcomposer message and forwards it to handler that sends it.</p>
|
||||
*
|
||||
* @param mail MailComposer object
|
||||
* @param done Callback function to run when the sending is completed
|
||||
*/
|
||||
send(mail: MailMessage<JSONSentMessageInfo>, done: (err: Error | null, info?: JSONSentMessageInfo) => void): void;
|
||||
}
|
||||
/**
|
||||
* Type aliases in the layout of @types/nodemailer, so `JSONTransport.Options` style references keep working
|
||||
*/
|
||||
declare namespace JSONTransport {
|
||||
type Options = JSONTransportOptions;
|
||||
type MailOptions = SendMailOptions;
|
||||
type SentMessageInfo = JSONSentMessageInfo;
|
||||
}
|
||||
export default JSONTransport;
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
"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 __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const packageData = __importStar(require("../package-info.js"));
|
||||
const shared = __importStar(require("../shared/index.js"));
|
||||
/**
|
||||
* Generates a Transport object to generate JSON output
|
||||
*
|
||||
* @constructor
|
||||
* @param optional config parameter
|
||||
*/
|
||||
class JSONTransport {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
this.options = options;
|
||||
this.name = 'JSONTransport';
|
||||
this.version = packageData.version;
|
||||
this.logger = shared.getLogger(this.options, {
|
||||
component: this.options.component || 'json-transport'
|
||||
});
|
||||
}
|
||||
/**
|
||||
* <p>Compiles a mailcomposer message and forwards it to handler that sends it.</p>
|
||||
*
|
||||
* @param mail MailComposer object
|
||||
* @param done Callback function to run when the sending is completed
|
||||
*/
|
||||
send(mail, done) {
|
||||
// Sendmail strips this header line by itself. send() runs after the message was
|
||||
// compiled, so mail.message is set
|
||||
mail.message.keepBcc = true;
|
||||
const envelope = mail.message.getEnvelope();
|
||||
const messageId = mail.message.messageId();
|
||||
const recipients = [].concat(envelope.to || []);
|
||||
if (recipients.length > 3) {
|
||||
recipients.push('...and ' + recipients.splice(2).length + ' more');
|
||||
}
|
||||
this.logger.info({
|
||||
tnx: 'send',
|
||||
messageId
|
||||
}, 'Composing JSON structure of %s to <%s>', messageId, recipients.join(', '));
|
||||
setImmediate(() => {
|
||||
mail.normalize((err, data) => {
|
||||
if (err) {
|
||||
this.logger.error({
|
||||
err,
|
||||
tnx: 'send',
|
||||
messageId
|
||||
}, 'Failed building JSON structure for %s. %s', messageId, err.message);
|
||||
return done(err);
|
||||
}
|
||||
delete data.envelope;
|
||||
delete data.normalizedHeaders;
|
||||
return done(null, {
|
||||
envelope,
|
||||
messageId,
|
||||
message: this.options.skipEncoding ? data : JSON.stringify(data)
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = JSONTransport;
|
||||
module.exports = exports.default;
|
||||
Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });
|
||||
Reference in New Issue
Block a user