@spinajs/email 2.0.38

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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `email`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const email = require('email');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,16 @@
1
+ import { CliCommand } from '@spinajs/cli';
2
+ import { ILog } from '@spinajs/log';
3
+ interface EmailOptions {
4
+ connection: string;
5
+ from: string;
6
+ to: string;
7
+ template?: string;
8
+ model?: string;
9
+ subject: string;
10
+ content?: string;
11
+ }
12
+ export declare class SendEmailCommand extends CliCommand {
13
+ protected Log: ILog;
14
+ execute(options: EmailOptions): Promise<void>;
15
+ }
16
+ export {};
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.SendEmailCommand = void 0;
36
+ const cli_1 = require("@spinajs/cli");
37
+ const di_1 = require("@spinajs/di");
38
+ const fs = __importStar(require("fs"));
39
+ const log_1 = require("@spinajs/log");
40
+ const index_1 = require("./../index");
41
+ let SendEmailCommand = class SendEmailCommand extends cli_1.CliCommand {
42
+ async execute(options) {
43
+ this.Log.trace(`Sending email with options options: ${JSON.stringify(options)}`);
44
+ try {
45
+ const emails = await di_1.DI.resolve(index_1.Emails);
46
+ let model = {};
47
+ if (options.model && fs.existsSync(options.model)) {
48
+ this.Log.trace(`Found model file at ${options.model}, trying to load model data ... `);
49
+ const mText = fs.readFileSync(options.model, { encoding: 'utf-8' });
50
+ model = JSON.parse(mText);
51
+ }
52
+ await emails.send({
53
+ from: options.from,
54
+ to: [options.to],
55
+ connection: options.connection,
56
+ template: options.template,
57
+ model: model,
58
+ subject: options.subject,
59
+ text: options.content,
60
+ });
61
+ this.Log.success(`Email send succesyfully to: ${options.to}, from: ${options.from}, subject: ${options.subject}`);
62
+ }
63
+ catch (err) {
64
+ this.Log.error(`Cannot send email, reason: ${err.message}, stack: ${err.stack}`);
65
+ }
66
+ }
67
+ };
68
+ __decorate([
69
+ (0, log_1.Logger)('templates'),
70
+ __metadata("design:type", Object)
71
+ ], SendEmailCommand.prototype, "Log", void 0);
72
+ SendEmailCommand = __decorate([
73
+ (0, cli_1.Command)('email-send', 'Sends email, mainly for testing purpose or scheduled tasks'),
74
+ (0, cli_1.Option)('-c, --connection [connection]', true, 'name of connection'),
75
+ (0, cli_1.Option)('-f, --from [from]', true, 'from email'),
76
+ (0, cli_1.Option)('-t, --to [to]', true, 'receipients, can be many ( comma separated )'),
77
+ (0, cli_1.Option)('-e, --template [template]', false, 'template name'),
78
+ (0, cli_1.Option)('-m, --model [model]', false, 'path to model data for template, in json format'),
79
+ (0, cli_1.Option)('-s, --subject [model]', true, 'subject'),
80
+ (0, cli_1.Option)('-c, --content [content]', false, 'text content if template is not provided')
81
+ ], SendEmailCommand);
82
+ exports.SendEmailCommand = SendEmailCommand;
83
+ //# sourceMappingURL=SendEmail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SendEmail.js","sourceRoot":"","sources":["../../../../src/cli/SendEmail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAA2D;AAC3D,oCAAiC;AACjC,uCAAyB;AACzB,sCAA4C;AAC5C,sCAAoC;AAoBpC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,gBAAU;IAIvC,KAAK,CAAC,OAAO,CAAC,OAAqB;QACxC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uCAAuC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAEjF,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,OAAE,CAAC,OAAO,CAAC,cAAM,CAAC,CAAC;YACxC,IAAI,KAAK,GAAG,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,OAAO,CAAC,KAAK,kCAAkC,CAAC,CAAC;gBAEvF,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;aAC3B;YAED,MAAM,MAAM,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,OAAO;aACtB,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,+BAA+B,OAAO,CAAC,EAAE,WAAW,OAAO,CAAC,IAAI,cAAc,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;SACnH;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8BAA8B,GAAG,CAAC,OAAO,YAAY,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;SAClF;IACH,CAAC;CACF,CAAA;AA/BC;IADC,IAAA,YAAM,EAAC,WAAW,CAAC;;6CACA;AAFT,gBAAgB;IAR5B,IAAA,aAAO,EAAC,YAAY,EAAE,4DAA4D,CAAC;IACnF,IAAA,YAAM,EAAC,+BAA+B,EAAE,IAAI,EAAE,oBAAoB,CAAC;IACnE,IAAA,YAAM,EAAC,mBAAmB,EAAE,IAAI,EAAE,YAAY,CAAC;IAC/C,IAAA,YAAM,EAAC,eAAe,EAAE,IAAI,EAAE,8CAA8C,CAAC;IAC7E,IAAA,YAAM,EAAC,2BAA2B,EAAE,KAAK,EAAE,eAAe,CAAC;IAC3D,IAAA,YAAM,EAAC,qBAAqB,EAAE,KAAK,EAAE,iDAAiD,CAAC;IACvF,IAAA,YAAM,EAAC,uBAAuB,EAAE,IAAI,EAAE,SAAS,CAAC;IAChD,IAAA,YAAM,EAAC,yBAAyB,EAAE,KAAK,EAAE,0CAA0C,CAAC;GACxE,gBAAgB,CAiC5B;AAjCY,4CAAgB"}
@@ -0,0 +1,8 @@
1
+ declare const email: {
2
+ system: {
3
+ dirs: {
4
+ cli: string[];
5
+ };
6
+ };
7
+ };
8
+ export default email;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ function dir(path) {
5
+ return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(__dirname, path)));
6
+ }
7
+ const email = {
8
+ system: {
9
+ dirs: {
10
+ cli: [dir('./../cli')],
11
+ },
12
+ },
13
+ };
14
+ exports.default = email;
15
+ //# sourceMappingURL=email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email.js","sourceRoot":"","sources":["../../../../src/config/email.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;SACvB;KACF;CACF,CAAC;AAEF,kBAAe,KAAK,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { AsyncModule } from '@spinajs/di';
2
+ import { Log } from '@spinajs/log';
3
+ import { Email, EmailSender, EmailConfiguration } from './interfaces';
4
+ export * from './interfaces';
5
+ /**
6
+ * Inject INTL module for language support. We does nothing but to initialize module for use in templates.
7
+ */
8
+ export declare class Emails extends AsyncModule {
9
+ protected Log: Log;
10
+ protected Senders: Map<string, EmailSender>;
11
+ protected Configuration: EmailConfiguration;
12
+ resolveAsync(): Promise<void>;
13
+ send(email: Email): Promise<void>;
14
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
18
+ };
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ var __metadata = (this && this.__metadata) || function (k, v) {
23
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Emails = void 0;
27
+ const index_1 = require("./../../exceptions/src/index");
28
+ const di_1 = require("@spinajs/di");
29
+ const log_1 = require("@spinajs/log");
30
+ const configuration_1 = require("@spinajs/configuration");
31
+ __exportStar(require("./interfaces"), exports);
32
+ /**
33
+ * Inject INTL module for language support. We does nothing but to initialize module for use in templates.
34
+ */
35
+ class Emails extends di_1.AsyncModule {
36
+ constructor() {
37
+ super(...arguments);
38
+ this.Senders = new Map();
39
+ }
40
+ async resolveAsync() {
41
+ for (const c of this.Configuration.connections) {
42
+ this.Log.trace(`Found connection ${c.name} ${c.login}@${c.host}`);
43
+ const connection = (await di_1.DI.resolve)(c.sender, [c]);
44
+ this.Senders.set(c.name, connection);
45
+ this.Log.trace(`Connection initialized - ${c.name} ${c.login}@${c.host}`);
46
+ }
47
+ await super.resolveAsync();
48
+ }
49
+ async send(email) {
50
+ if (!this.Senders.has(email.connection)) {
51
+ throw new index_1.InvalidOperation(`Email sender ${email.connection} not exists. Please check your configuration files.`);
52
+ }
53
+ const connection = this.Senders.get(email.connection);
54
+ await connection.send(email);
55
+ }
56
+ }
57
+ __decorate([
58
+ (0, log_1.Logger)('email'),
59
+ __metadata("design:type", log_1.Log)
60
+ ], Emails.prototype, "Log", void 0);
61
+ __decorate([
62
+ (0, configuration_1.Config)('email'),
63
+ __metadata("design:type", Object)
64
+ ], Emails.prototype, "Configuration", void 0);
65
+ exports.Emails = Emails;
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAgE;AAChE,oCAA8C;AAC9C,sCAA2C;AAE3C,0DAAgD;AAChD,+CAA6B;AAE7B;;GAEG;AACH,MAAa,MAAO,SAAQ,gBAAW;IAAvC;;QAIY,YAAO,GAA6B,IAAI,GAAG,EAAuB,CAAC;IA0B/E,CAAC;IArBQ,KAAK,CAAC,YAAY;QACvB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YAC9C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAElE,MAAM,UAAU,GAAG,CAAC,MAAM,OAAE,CAAC,OAAO,CAAC,CAAc,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAErC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;SAC3E;QAED,MAAM,KAAK,CAAC,YAAY,EAAE,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,KAAY;QAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YACvC,MAAM,IAAI,wBAAgB,CAAC,gBAAgB,KAAK,CAAC,UAAU,qDAAqD,CAAC,CAAC;SACnH;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF;AA5BC;IADC,IAAA,YAAM,EAAC,OAAO,CAAC;8BACD,SAAG;mCAAC;AAKnB;IADC,IAAA,sBAAM,EAAC,OAAO,CAAC;;6CAC4B;AAP9C,wBA8BC"}
@@ -0,0 +1,88 @@
1
+ export declare abstract class EmailSender {
2
+ Options: EmailConnectionOptions;
3
+ abstract send(email: Email): Promise<void>;
4
+ }
5
+ export interface IEmailAttachement {
6
+ /**
7
+ * - filename to be reported as the name of the attached file. Use of unicode is allowed.
8
+ */
9
+ name: string;
10
+ /**
11
+ * Path to file
12
+ */
13
+ path: string;
14
+ /**
15
+ * File provider could be local fs, aws s3 etc. Default is always fs-local
16
+ */
17
+ provider?: string;
18
+ }
19
+ export interface Email {
20
+ to: string[];
21
+ cc?: string[];
22
+ bcc?: string[];
23
+ from: string;
24
+ connection: string;
25
+ attachements?: IEmailAttachement[];
26
+ /**
27
+ * Local template name. Must be avaible in one of dirs set in template config
28
+ */
29
+ template?: string;
30
+ /**
31
+ * Some implementations have predefined templates. It can be accessed by this Id
32
+ * eg. mailersend
33
+ */
34
+ templateId?: string;
35
+ /**
36
+ * Data passed to template
37
+ */
38
+ model?: unknown;
39
+ /**
40
+ * Text representation of email
41
+ */
42
+ text?: string;
43
+ subject: string;
44
+ lang?: string;
45
+ priority?: string;
46
+ replyTo?: string;
47
+ /**
48
+ * Additional tag for email,
49
+ * usefull for identyfying emails by category or module that sends it
50
+ */
51
+ tag?: string;
52
+ /**
53
+ * Unique email id, for identification eg. in case of delivery failure
54
+ */
55
+ emailId?: string;
56
+ }
57
+ export interface EmailConfiguration {
58
+ connections: EmailConnectionOptions[];
59
+ defaultConnection: string;
60
+ }
61
+ export interface EmailConnectionOptions {
62
+ sender: string;
63
+ name: string;
64
+ host?: string;
65
+ port?: number;
66
+ login?: string;
67
+ password?: string;
68
+ ssl?: boolean;
69
+ /**
70
+ * defaults for messages
71
+ */
72
+ defaults?: {
73
+ /**
74
+ * defalt `from` adress, can be override when sending
75
+ */
76
+ mailFrom?: string;
77
+ };
78
+ /**
79
+ * Additional options passed
80
+ * lib specific
81
+ */
82
+ options?: unknown;
83
+ attachements: {
84
+ maxSingleSize: number;
85
+ maxTotalSize: number;
86
+ maxCount: number;
87
+ };
88
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailSender = void 0;
4
+ class EmailSender {
5
+ }
6
+ exports.EmailSender = EmailSender;
7
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces.ts"],"names":[],"mappings":";;;AAAA,MAAsB,WAAW;CAIhC;AAJD,kCAIC"}
package/lib/email.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ module.exports = email;
4
+
5
+ function email() {
6
+ // TODO
7
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Base class of all exceptions in framework
3
+ */
4
+ export declare class Exception extends Error {
5
+ inner?: Error;
6
+ /**
7
+ * Constructs new exception with message
8
+ *
9
+ * @param message - error message
10
+ * @param inner - inner exception ( eg. original couse of error )
11
+ */
12
+ constructor(message?: string, inner?: Error);
13
+ }
14
+ /**
15
+ * Exception thrown when functionality is not supported
16
+ */
17
+ export declare class NotSupported extends Exception {
18
+ }
19
+ /**
20
+ * Exception thrown when argument passed to function is invalid eg. out of range
21
+ */
22
+ export declare class InvalidArgument extends Exception {
23
+ }
24
+ /**
25
+ * Exception thrown when config option is invalidl eg. missing or in invalid format
26
+ */
27
+ export declare class InvalidOption extends Exception {
28
+ }
29
+ /**
30
+ * The exception that is thrown when a method call is invalid for the object's current state.
31
+ */
32
+ export declare class InvalidOperation extends Exception {
33
+ }
34
+ /**
35
+ * Exception is thrown when authentication fails eg. user credentials are invalid
36
+ */
37
+ export declare class AuthenticationFailed extends Exception {
38
+ }
39
+ /**
40
+ * Exception is thrown when request data are invalid
41
+ */
42
+ export declare class BadRequest extends Exception {
43
+ }
44
+ /**
45
+ * Exception indicating that an access to resource by a client has been forbidden by the server
46
+ * HTTP 403 - Forbidden
47
+ */
48
+ export declare class Forbidden extends Exception {
49
+ }
50
+ /**
51
+ * Exception thrown when there was error with IO operations ie. not accessible file
52
+ */
53
+ export declare class IOFail extends Exception {
54
+ }
55
+ /**
56
+ * The exception that is thrown when resource is not found eg. model in database or missing file
57
+ */
58
+ export declare class ResourceNotFound extends Exception {
59
+ }
60
+ /**
61
+ * The exception that is thrown when method is not implemented
62
+ */
63
+ export declare class MethodNotImplemented extends Exception {
64
+ }
65
+ /**
66
+ * The exception that is thrown when strange things happends in server eg. generic server error
67
+ */
68
+ export declare class UnexpectedServerError extends Exception {
69
+ }
70
+ /**
71
+ * Exception occurs when resource is duplicated eg. unique constraint failed in db
72
+ */
73
+ export declare class ResourceDuplicated extends Exception {
74
+ }
75
+ /**
76
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
77
+ */
78
+ export declare class JsonValidationFailed extends Exception {
79
+ }
80
+ /**
81
+ * The exception that is thrown if app not supports requestes `Accept` header eg. if client wants
82
+ * html response but server can send only json.
83
+ */
84
+ export declare class ExpectedResponseUnacceptable extends Exception {
85
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpectedResponseUnacceptable = exports.JsonValidationFailed = exports.ResourceDuplicated = exports.UnexpectedServerError = exports.MethodNotImplemented = exports.ResourceNotFound = exports.IOFail = exports.Forbidden = exports.BadRequest = exports.AuthenticationFailed = exports.InvalidOperation = exports.InvalidOption = exports.InvalidArgument = exports.NotSupported = exports.Exception = void 0;
4
+ /**
5
+ * Base class of all exceptions in framework
6
+ */
7
+ class Exception extends Error {
8
+ /**
9
+ * Constructs new exception with message
10
+ *
11
+ * @param message - error message
12
+ * @param inner - inner exception ( eg. original couse of error )
13
+ */
14
+ constructor(message, inner) {
15
+ super(message);
16
+ this.inner = inner;
17
+ }
18
+ }
19
+ exports.Exception = Exception;
20
+ /**
21
+ * Exception thrown when functionality is not supported
22
+ */
23
+ class NotSupported extends Exception {
24
+ }
25
+ exports.NotSupported = NotSupported;
26
+ /**
27
+ * Exception thrown when argument passed to function is invalid eg. out of range
28
+ */
29
+ class InvalidArgument extends Exception {
30
+ }
31
+ exports.InvalidArgument = InvalidArgument;
32
+ /**
33
+ * Exception thrown when config option is invalidl eg. missing or in invalid format
34
+ */
35
+ class InvalidOption extends Exception {
36
+ }
37
+ exports.InvalidOption = InvalidOption;
38
+ /**
39
+ * The exception that is thrown when a method call is invalid for the object's current state.
40
+ */
41
+ class InvalidOperation extends Exception {
42
+ }
43
+ exports.InvalidOperation = InvalidOperation;
44
+ /**
45
+ * Exception is thrown when authentication fails eg. user credentials are invalid
46
+ */
47
+ class AuthenticationFailed extends Exception {
48
+ }
49
+ exports.AuthenticationFailed = AuthenticationFailed;
50
+ /**
51
+ * Exception is thrown when request data are invalid
52
+ */
53
+ class BadRequest extends Exception {
54
+ }
55
+ exports.BadRequest = BadRequest;
56
+ /**
57
+ * Exception indicating that an access to resource by a client has been forbidden by the server
58
+ * HTTP 403 - Forbidden
59
+ */
60
+ class Forbidden extends Exception {
61
+ }
62
+ exports.Forbidden = Forbidden;
63
+ /**
64
+ * Exception thrown when there was error with IO operations ie. not accessible file
65
+ */
66
+ class IOFail extends Exception {
67
+ }
68
+ exports.IOFail = IOFail;
69
+ /**
70
+ * The exception that is thrown when resource is not found eg. model in database or missing file
71
+ */
72
+ class ResourceNotFound extends Exception {
73
+ }
74
+ exports.ResourceNotFound = ResourceNotFound;
75
+ /**
76
+ * The exception that is thrown when method is not implemented
77
+ */
78
+ class MethodNotImplemented extends Exception {
79
+ }
80
+ exports.MethodNotImplemented = MethodNotImplemented;
81
+ /**
82
+ * The exception that is thrown when strange things happends in server eg. generic server error
83
+ */
84
+ class UnexpectedServerError extends Exception {
85
+ }
86
+ exports.UnexpectedServerError = UnexpectedServerError;
87
+ /**
88
+ * Exception occurs when resource is duplicated eg. unique constraint failed in db
89
+ */
90
+ class ResourceDuplicated extends Exception {
91
+ }
92
+ exports.ResourceDuplicated = ResourceDuplicated;
93
+ /**
94
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
95
+ */
96
+ class JsonValidationFailed extends Exception {
97
+ }
98
+ exports.JsonValidationFailed = JsonValidationFailed;
99
+ /**
100
+ * The exception that is thrown if app not supports requestes `Accept` header eg. if client wants
101
+ * html response but server can send only json.
102
+ */
103
+ class ExpectedResponseUnacceptable extends Exception {
104
+ }
105
+ exports.ExpectedResponseUnacceptable = ExpectedResponseUnacceptable;
106
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../exceptions/src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;IAClC;;;;;OAKG;IACH,YAAY,OAAgB,EAAS,KAAa;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QADoB,UAAK,GAAL,KAAK,CAAQ;IAElD,CAAC;CACF;AAVD,8BAUC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,SAAS;CAAG;AAA9C,oCAA8C;AAE9C;;GAEG;AACH,MAAa,eAAgB,SAAQ,SAAS;CAAG;AAAjD,0CAAiD;AAEjD;;GAEG;AACH,MAAa,aAAc,SAAQ,SAAS;CAAG;AAA/C,sCAA+C;AAE/C;;GAEG;AACH,MAAa,gBAAiB,SAAQ,SAAS;CAAG;AAAlD,4CAAkD;AAElD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,SAAS;CAAG;AAAtD,oDAAsD;AAEtD;;GAEG;AACH,MAAa,UAAW,SAAQ,SAAS;CAAG;AAA5C,gCAA4C;AAE5C;;;GAGG;AACH,MAAa,SAAU,SAAQ,SAAS;CAAG;AAA3C,8BAA2C;AAE3C;;GAEG;AACH,MAAa,MAAO,SAAQ,SAAS;CAAG;AAAxC,wBAAwC;AAExC;;GAEG;AACH,MAAa,gBAAiB,SAAQ,SAAS;CAAG;AAAlD,4CAAkD;AAElD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,SAAS;CAAG;AAAtD,oDAAsD;AAEtD;;GAEG;AACH,MAAa,qBAAsB,SAAQ,SAAS;CAAG;AAAvD,sDAAuD;AAEvD;;GAEG;AACH,MAAa,kBAAmB,SAAQ,SAAS;CAAG;AAApD,gDAAoD;AAEpD;;GAEG;AACH,MAAa,oBAAqB,SAAQ,SAAS;CAAG;AAAtD,oDAAsD;AAEtD;;;GAGG;AACH,MAAa,4BAA6B,SAAQ,SAAS;CAAG;AAA9D,oEAA8D"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@spinajs/email",
3
+ "version": "2.0.38",
4
+ "description": "sending emails easy & reliable way",
5
+ "main": "lib/index.js",
6
+ "private": false,
7
+ "scripts": {
8
+ "build": "npm run clean && npm run compile && cpx src/views/**/* lib/views && cpx src/static/**/* lib/static",
9
+ "compile": "tsc -p tsconfig.build.json",
10
+ "clean": "",
11
+ "test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
12
+ "coverage": "nyc npm run test",
13
+ "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
14
+ "prepare": "npm run build",
15
+ "format": "prettier --write \"src/**/*.ts\"",
16
+ "lint": "eslint -c .eslintrc.js --ext .ts src --fix",
17
+ "prepublishOnly": "npm test && npm run lint",
18
+ "preversion": "npm run lint",
19
+ "version": "npm run format && git add -A src",
20
+ "postversion": "git push && git push --tags"
21
+ },
22
+ "files": [
23
+ "lib/**/*"
24
+ ],
25
+ "types": "lib",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/spinajs/main.git"
29
+ },
30
+ "keywords": [
31
+ "spinajs",
32
+ "http"
33
+ ],
34
+ "author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
35
+ "license": "MIT",
36
+ "bugs": {
37
+ "url": "https://github.com/spinajs/main/issues"
38
+ },
39
+ "homepage": "https://github.com/spinajs/main#readme",
40
+ "devDependencies": {
41
+ "@types/luxon": "^2.3.1",
42
+ "@types/node": "^16.11.11",
43
+ "@types/nodemailer": "^6.4.4"
44
+ },
45
+ "dependencies": {
46
+ "@spinajs/configuration": "^2.0.38",
47
+ "@spinajs/di": "^2.0.38",
48
+ "@spinajs/exceptions": "^2.0.12",
49
+ "@spinajs/internal-logger": "^2.0.38",
50
+ "@spinajs/intl": "^2.0.38",
51
+ "@spinajs/log": "^2.0.38",
52
+ "luxon": "^2.3.0"
53
+ },
54
+ "gitHead": "5ea5440ee9db49595f531592ebdbc6d69f457082"
55
+ }