@spinajs/email 2.0.180 → 2.0.182

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.
Files changed (47) hide show
  1. package/lib/cjs/cli/SendEmail.d.ts +16 -16
  2. package/lib/cjs/cli/SendEmail.js +82 -82
  3. package/lib/cjs/cli/SendEmail.js.map +1 -1
  4. package/lib/cjs/config/email.d.ts +28 -28
  5. package/lib/cjs/config/email.js +35 -35
  6. package/lib/cjs/events/EmailSent.d.ts +23 -23
  7. package/lib/cjs/events/EmailSent.js +32 -32
  8. package/lib/cjs/events/EmailSent.js.map +1 -1
  9. package/lib/cjs/index.d.ts +23 -23
  10. package/lib/cjs/index.js +76 -76
  11. package/lib/cjs/index.js.map +1 -1
  12. package/lib/cjs/interfaces.d.ts +114 -114
  13. package/lib/cjs/interfaces.js +44 -44
  14. package/lib/cjs/interfaces.js.map +1 -1
  15. package/lib/cjs/jobs/EmailSend.d.ts +30 -30
  16. package/lib/cjs/jobs/EmailSend.js +36 -36
  17. package/lib/cjs/jobs/EmailSend.js.map +1 -1
  18. package/lib/cjs/schemas/email.smtp.configuration.d.ts +52 -52
  19. package/lib/cjs/schemas/email.smtp.configuration.js +38 -38
  20. package/lib/cjs/transports.d.ts +9 -9
  21. package/lib/cjs/transports.js +24 -24
  22. package/lib/cjs/transports.js.map +1 -1
  23. package/lib/mjs/cli/SendEmail.d.ts +16 -16
  24. package/lib/mjs/cli/SendEmail.js +56 -56
  25. package/lib/mjs/cli/SendEmail.js.map +1 -1
  26. package/lib/mjs/config/email.d.ts +28 -28
  27. package/lib/mjs/config/email.js +33 -33
  28. package/lib/mjs/events/EmailSent.d.ts +23 -23
  29. package/lib/mjs/events/EmailSent.js +29 -29
  30. package/lib/mjs/events/EmailSent.js.map +1 -1
  31. package/lib/mjs/index.d.ts +23 -23
  32. package/lib/mjs/index.js +56 -56
  33. package/lib/mjs/index.js.map +1 -1
  34. package/lib/mjs/interfaces.d.ts +114 -114
  35. package/lib/mjs/interfaces.js +39 -39
  36. package/lib/mjs/interfaces.js.map +1 -1
  37. package/lib/mjs/jobs/EmailSend.d.ts +30 -30
  38. package/lib/mjs/jobs/EmailSend.js +33 -33
  39. package/lib/mjs/jobs/EmailSend.js.map +1 -1
  40. package/lib/mjs/schemas/email.smtp.configuration.d.ts +52 -52
  41. package/lib/mjs/schemas/email.smtp.configuration.js +36 -36
  42. package/lib/mjs/transports.d.ts +9 -9
  43. package/lib/mjs/transports.js +21 -21
  44. package/lib/mjs/transports.js.map +1 -1
  45. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  46. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  47. package/package.json +8 -8
@@ -1,30 +1,30 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { QueueEvent, Event } from '@spinajs/queue';
11
- import { DateTime } from 'luxon';
12
- let EmailSent = class EmailSent extends QueueEvent {
13
- constructor(email) {
14
- super();
15
- this.Connection = email.connection;
16
- this.From = email.from;
17
- this.To = email.to;
18
- this.Template = email.template;
19
- this.Model = email.model;
20
- this.Subject = email.subject;
21
- this.Content = email.text;
22
- this.SentAt = DateTime.now();
23
- }
24
- };
25
- EmailSent = __decorate([
26
- Event(),
27
- __metadata("design:paramtypes", [Object])
28
- ], EmailSent);
29
- export { EmailSent };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { QueueEvent, Event } from '@spinajs/queue';
11
+ import { DateTime } from 'luxon';
12
+ let EmailSent = class EmailSent extends QueueEvent {
13
+ constructor(email) {
14
+ super();
15
+ this.Connection = email.connection;
16
+ this.From = email.from;
17
+ this.To = email.to;
18
+ this.Template = email.template;
19
+ this.Model = email.model;
20
+ this.Subject = email.subject;
21
+ this.Content = email.text;
22
+ this.SentAt = DateTime.now();
23
+ }
24
+ };
25
+ EmailSent = __decorate([
26
+ Event(),
27
+ __metadata("design:paramtypes", [Object])
28
+ ], EmailSent);
29
+ export { EmailSent };
30
30
  //# sourceMappingURL=EmailSent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmailSent.js","sourceRoot":"","sources":["../../../src/events/EmailSent.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI1B,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IA0BvC,YAAY,KAAa;QACvB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,KAAK,CA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Bootstrapper } from '@spinajs/di';
2
- import { IEmail, EmailService } from './interfaces.js';
3
- import { EmailSend } from './jobs/EmailSend.js';
4
- export * from './interfaces.js';
5
- export * from './transports.js';
6
- export * from './jobs/EmailSend.js';
7
- export declare class LogBotstrapper extends Bootstrapper {
8
- bootstrap(): void;
9
- }
10
- /**
11
- * Email sending service.
12
- */
13
- export declare class DefaultEmailService extends EmailService {
14
- /**
15
- *
16
- * Tries to sends email immediately
17
- *
18
- * @param email - email struct
19
- */
20
- send(email: IEmail): Promise<void>;
21
- sendDeferred(email: IEmail): Promise<EmailSend>;
22
- processDefferedEmails(): Promise<void>;
23
- }
1
+ import { Bootstrapper } from '@spinajs/di';
2
+ import { IEmail, EmailService } from './interfaces.js';
3
+ import { EmailSend } from './jobs/EmailSend.js';
4
+ export * from './interfaces.js';
5
+ export * from './transports.js';
6
+ export * from './jobs/EmailSend.js';
7
+ export declare class LogBotstrapper extends Bootstrapper {
8
+ bootstrap(): void;
9
+ }
10
+ /**
11
+ * Email sending service.
12
+ */
13
+ export declare class DefaultEmailService extends EmailService {
14
+ /**
15
+ *
16
+ * Tries to sends email immediately
17
+ *
18
+ * @param email - email struct
19
+ */
20
+ send(email: IEmail): Promise<void>;
21
+ sendDeferred(email: IEmail): Promise<EmailSend>;
22
+ processDefferedEmails(): Promise<void>;
23
+ }
24
24
  //# sourceMappingURL=index.d.ts.map
package/lib/mjs/index.js CHANGED
@@ -1,57 +1,57 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { InvalidOperation } from '@spinajs/exceptions';
8
- import { DI, Bootstrapper, Injectable } from '@spinajs/di';
9
- import { EmailService } from './interfaces.js';
10
- import CONFIGURATION_SCHEMA from './schemas/email.smtp.configuration.js';
11
- import { EmailSent } from './events/EmailSent.js';
12
- import { EmailSend } from './jobs/EmailSend.js';
13
- export * from './interfaces.js';
14
- export * from './transports.js';
15
- export * from './jobs/EmailSend.js';
16
- let LogBotstrapper = class LogBotstrapper extends Bootstrapper {
17
- bootstrap() {
18
- DI.register(CONFIGURATION_SCHEMA).asValue('__configurationSchema__');
19
- }
20
- };
21
- LogBotstrapper = __decorate([
22
- Injectable(Bootstrapper)
23
- ], LogBotstrapper);
24
- export { LogBotstrapper };
25
- /**
26
- * Email sending service.
27
- */
28
- let DefaultEmailService = class DefaultEmailService extends EmailService {
29
- /**
30
- *
31
- * Tries to sends email immediately
32
- *
33
- * @param email - email struct
34
- */
35
- async send(email) {
36
- if (!this.Senders.has(email.connection)) {
37
- throw new InvalidOperation(`Email sender ${email.connection} not exists. Please check your configuration files.`);
38
- }
39
- await this.Senders.get(email.connection).send(email);
40
- // inform others of email event
41
- await this.Queue.emit(new EmailSent(email));
42
- }
43
- async sendDeferred(email) {
44
- const dEmail = new EmailSend();
45
- dEmail.hydrate(email);
46
- await this.Queue.emit(dEmail);
47
- return dEmail;
48
- }
49
- async processDefferedEmails() {
50
- await this.Queue.consume(EmailSend);
51
- }
52
- };
53
- DefaultEmailService = __decorate([
54
- Injectable(EmailService)
55
- ], DefaultEmailService);
56
- export { DefaultEmailService };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { InvalidOperation } from '@spinajs/exceptions';
8
+ import { DI, Bootstrapper, Injectable } from '@spinajs/di';
9
+ import { EmailService } from './interfaces.js';
10
+ import CONFIGURATION_SCHEMA from './schemas/email.smtp.configuration.js';
11
+ import { EmailSent } from './events/EmailSent.js';
12
+ import { EmailSend } from './jobs/EmailSend.js';
13
+ export * from './interfaces.js';
14
+ export * from './transports.js';
15
+ export * from './jobs/EmailSend.js';
16
+ let LogBotstrapper = class LogBotstrapper extends Bootstrapper {
17
+ bootstrap() {
18
+ DI.register(CONFIGURATION_SCHEMA).asValue('__configurationSchema__');
19
+ }
20
+ };
21
+ LogBotstrapper = __decorate([
22
+ Injectable(Bootstrapper)
23
+ ], LogBotstrapper);
24
+ export { LogBotstrapper };
25
+ /**
26
+ * Email sending service.
27
+ */
28
+ let DefaultEmailService = class DefaultEmailService extends EmailService {
29
+ /**
30
+ *
31
+ * Tries to sends email immediately
32
+ *
33
+ * @param email - email struct
34
+ */
35
+ async send(email) {
36
+ if (!this.Senders.has(email.connection)) {
37
+ throw new InvalidOperation(`Email sender ${email.connection} not exists. Please check your configuration files.`);
38
+ }
39
+ await this.Senders.get(email.connection).send(email);
40
+ // inform others of email event
41
+ await this.Queue.emit(new EmailSent(email));
42
+ }
43
+ async sendDeferred(email) {
44
+ const dEmail = new EmailSend();
45
+ dEmail.hydrate(email);
46
+ await this.Queue.emit(dEmail);
47
+ return dEmail;
48
+ }
49
+ async processDefferedEmails() {
50
+ await this.Queue.consume(EmailSend);
51
+ }
52
+ };
53
+ DefaultEmailService = __decorate([
54
+ Injectable(EmailService)
55
+ ], DefaultEmailService);
56
+ export { DefaultEmailService };
57
57
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACv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AI,gBAAgB,CAAC,gBAAgB,KAAK,CAAC,UAAU,qDAAqD,CAAC,CAAC;SACnH;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAErD,+BAA+B;QAC/B,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,KAAa;QACrC,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AA7BY,mBAAmB;IAD/B,UAAU,CAAC,YAAY,CAAC;GACZ,mBAAmB,CA6B/B"}
@@ -1,115 +1,115 @@
1
- import { AsyncService, IInstanceCheck, IMappableService } from '@spinajs/di';
2
- import { Log } from '@spinajs/log';
3
- import { QueueService } from '@spinajs/queue';
4
- import { EmailSend } from './jobs/EmailSend.js';
5
- export declare abstract class EmailSender extends AsyncService implements IInstanceCheck, IMappableService {
6
- Options: EmailConnectionOptions;
7
- get ServiceName(): string;
8
- abstract send(email: IEmail): Promise<void>;
9
- __checkInstance__(creationOptions: any): boolean;
10
- }
11
- export interface IEmailAttachement {
12
- /**
13
- * - filename to be reported as the name of the attached file. Use of unicode is allowed.
14
- */
15
- name: string;
16
- /**
17
- * Path to file
18
- */
19
- path: string;
20
- /**
21
- * File provider could be local fs, aws s3 etc. Default is always fs-local
22
- */
23
- provider?: string;
24
- }
25
- export interface IEmail {
26
- to: string[];
27
- cc?: string[];
28
- bcc?: string[];
29
- from: string;
30
- connection: string;
31
- attachements?: IEmailAttachement[];
32
- /**
33
- * Local template name. Must be avaible in one of dirs set in template config
34
- */
35
- template?: string;
36
- /**
37
- * Some implementations have predefined templates. It can be accessed by this Id
38
- * eg. mailersend
39
- */
40
- templateId?: string;
41
- /**
42
- * Data passed to template
43
- */
44
- model?: unknown;
45
- /**
46
- * Text representation of email
47
- */
48
- text?: string;
49
- subject: string;
50
- lang?: string;
51
- priority?: string;
52
- replyTo?: string;
53
- /**
54
- * Additional tag for email,
55
- * usefull for identyfying emails by category or module that sends it
56
- */
57
- tag?: string;
58
- /**
59
- * Unique email id, for identification eg. in case of delivery failure
60
- */
61
- emailId?: string;
62
- }
63
- export interface EmailConfiguration {
64
- connections: EmailConnectionOptions[];
65
- defaultConnection: string;
66
- }
67
- export interface EmailConnectionOptions {
68
- sender: string;
69
- name: string;
70
- host?: string;
71
- port?: number;
72
- user?: string;
73
- pass?: string;
74
- ssl?: boolean;
75
- /**
76
- * defaults for messages
77
- */
78
- defaults?: {
79
- /**
80
- * defalt `from` adress, can be override when sending
81
- */
82
- mailFrom?: string;
83
- };
84
- /**
85
- * Additional options passed
86
- * lib specific
87
- */
88
- options?: unknown;
89
- }
90
- export declare abstract class EmailService extends AsyncService {
91
- protected Log: Log;
92
- protected Senders: Map<string, EmailSender>;
93
- protected Configuration: EmailConfiguration;
94
- protected Queue: QueueService;
95
- /**
96
- *
97
- * Sends email immediatelly ( in current process )
98
- *
99
- * @param email - email to send
100
- */
101
- abstract send(email: IEmail): Promise<void>;
102
- /**
103
- *
104
- * Schedules email to send ( adds to queue ). Email is sent by separate process
105
- * that subscribe for specific events
106
- *
107
- * @param email - email to send
108
- */
109
- abstract sendDeferred(email: IEmail): Promise<EmailSend>;
110
- /**
111
- * Subscribte to queue for emails to send
112
- */
113
- abstract processDefferedEmails(): Promise<void>;
114
- }
1
+ import { AsyncService, IInstanceCheck, IMappableService } from '@spinajs/di';
2
+ import { Log } from '@spinajs/log';
3
+ import { QueueService } from '@spinajs/queue';
4
+ import { EmailSend } from './jobs/EmailSend.js';
5
+ export declare abstract class EmailSender extends AsyncService implements IInstanceCheck, IMappableService {
6
+ Options: EmailConnectionOptions;
7
+ get ServiceName(): string;
8
+ abstract send(email: IEmail): Promise<void>;
9
+ __checkInstance__(creationOptions: any): boolean;
10
+ }
11
+ export interface IEmailAttachement {
12
+ /**
13
+ * - filename to be reported as the name of the attached file. Use of unicode is allowed.
14
+ */
15
+ name: string;
16
+ /**
17
+ * Path to file
18
+ */
19
+ path: string;
20
+ /**
21
+ * File provider could be local fs, aws s3 etc. Default is always fs-local
22
+ */
23
+ provider?: string;
24
+ }
25
+ export interface IEmail {
26
+ to: string[];
27
+ cc?: string[];
28
+ bcc?: string[];
29
+ from: string;
30
+ connection: string;
31
+ attachements?: IEmailAttachement[];
32
+ /**
33
+ * Local template name. Must be avaible in one of dirs set in template config
34
+ */
35
+ template?: string;
36
+ /**
37
+ * Some implementations have predefined templates. It can be accessed by this Id
38
+ * eg. mailersend
39
+ */
40
+ templateId?: string;
41
+ /**
42
+ * Data passed to template
43
+ */
44
+ model?: unknown;
45
+ /**
46
+ * Text representation of email
47
+ */
48
+ text?: string;
49
+ subject: string;
50
+ lang?: string;
51
+ priority?: string;
52
+ replyTo?: string;
53
+ /**
54
+ * Additional tag for email,
55
+ * usefull for identyfying emails by category or module that sends it
56
+ */
57
+ tag?: string;
58
+ /**
59
+ * Unique email id, for identification eg. in case of delivery failure
60
+ */
61
+ emailId?: string;
62
+ }
63
+ export interface EmailConfiguration {
64
+ connections: EmailConnectionOptions[];
65
+ defaultConnection: string;
66
+ }
67
+ export interface EmailConnectionOptions {
68
+ sender: string;
69
+ name: string;
70
+ host?: string;
71
+ port?: number;
72
+ user?: string;
73
+ pass?: string;
74
+ ssl?: boolean;
75
+ /**
76
+ * defaults for messages
77
+ */
78
+ defaults?: {
79
+ /**
80
+ * defalt `from` adress, can be override when sending
81
+ */
82
+ mailFrom?: string;
83
+ };
84
+ /**
85
+ * Additional options passed
86
+ * lib specific
87
+ */
88
+ options?: unknown;
89
+ }
90
+ export declare abstract class EmailService extends AsyncService {
91
+ protected Log: Log;
92
+ protected Senders: Map<string, EmailSender>;
93
+ protected Configuration: EmailConfiguration;
94
+ protected Queue: QueueService;
95
+ /**
96
+ *
97
+ * Sends email immediatelly ( in current process )
98
+ *
99
+ * @param email - email to send
100
+ */
101
+ abstract send(email: IEmail): Promise<void>;
102
+ /**
103
+ *
104
+ * Schedules email to send ( adds to queue ). Email is sent by separate process
105
+ * that subscribe for specific events
106
+ *
107
+ * @param email - email to send
108
+ */
109
+ abstract sendDeferred(email: IEmail): Promise<EmailSend>;
110
+ /**
111
+ * Subscribte to queue for emails to send
112
+ */
113
+ abstract processDefferedEmails(): Promise<void>;
114
+ }
115
115
  //# sourceMappingURL=interfaces.d.ts.map
@@ -1,40 +1,40 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { AsyncService, Autoinject } from '@spinajs/di';
11
- import { Log, Logger } from '@spinajs/log';
12
- import { AutoinjectService, Config } from '@spinajs/configuration';
13
- import { QueueService } from '@spinajs/queue';
14
- export class EmailSender extends AsyncService {
15
- get ServiceName() {
16
- return this.Options.name;
17
- }
18
- __checkInstance__(creationOptions) {
19
- return this.Options.name === creationOptions[0].name;
20
- }
21
- }
22
- export class EmailService extends AsyncService {
23
- }
24
- __decorate([
25
- Logger('email'),
26
- __metadata("design:type", Log)
27
- ], EmailService.prototype, "Log", void 0);
28
- __decorate([
29
- AutoinjectService('email.connections', EmailSender),
30
- __metadata("design:type", Map)
31
- ], EmailService.prototype, "Senders", void 0);
32
- __decorate([
33
- Config('email'),
34
- __metadata("design:type", Object)
35
- ], EmailService.prototype, "Configuration", void 0);
36
- __decorate([
37
- Autoinject(QueueService),
38
- __metadata("design:type", QueueService)
39
- ], EmailService.prototype, "Queue", void 0);
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { AsyncService, Autoinject } from '@spinajs/di';
11
+ import { Log, Logger } from '@spinajs/log';
12
+ import { AutoinjectService, Config } from '@spinajs/configuration';
13
+ import { QueueService } from '@spinajs/queue';
14
+ export class EmailSender extends AsyncService {
15
+ get ServiceName() {
16
+ return this.Options.name;
17
+ }
18
+ __checkInstance__(creationOptions) {
19
+ return this.Options.name === creationOptions[0].name;
20
+ }
21
+ }
22
+ export class EmailService extends AsyncService {
23
+ }
24
+ __decorate([
25
+ Logger('email'),
26
+ __metadata("design:type", Log)
27
+ ], EmailService.prototype, "Log", void 0);
28
+ __decorate([
29
+ AutoinjectService('email.connections', EmailSender),
30
+ __metadata("design:type", Map)
31
+ ], EmailService.prototype, "Senders", void 0);
32
+ __decorate([
33
+ Config('email'),
34
+ __metadata("design:type", Object)
35
+ ], EmailService.prototype, "Configuration", void 0);
36
+ __decorate([
37
+ Autoinject(QueueService),
38
+ __metadata("design:type", QueueService)
39
+ ], EmailService.prototype, "Queue", void 0);
40
40
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoC,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,OAAgB,WAAY,SAAQ,YAAY;IAGpD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAIM,iBAAiB,CAAC,eAAoB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;CACF;AAwGD,MAAM,OAAgB,YAAa,SAAQ,YAAY;CAkCtD;AAjCC;IAAC,MAAM,CAAC,OAAO,CAAC;8BACD,GAAG;yCAAC;AAEnB;IAAC,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC;8BACjC,GAAG;6CAAsB;AAE5C;IAAC,MAAM,CAAC,OAAO,CAAC;;mDAC4B;AAE5C;IAAC,UAAU,CAAC,YAAY,CAAC;8BACR,YAAY;2CAAC"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoC,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,OAAgB,WAAY,SAAQ,YAAY;IAGpD,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAIM,iBAAiB,CAAC,eAAoB;QAC3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;CACF;AAwGD,MAAM,OAAgB,YAAa,SAAQ,YAAY;CAkCtD;AAhCW;IADT,MAAM,CAAC,OAAO,CAAC;8BACD,GAAG;yCAAC;AAGT;IADT,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC;8BACjC,GAAG;6CAAsB;AAGlC;IADT,MAAM,CAAC,OAAO,CAAC;;mDAC4B;AAGlC;IADT,UAAU,CAAC,YAAY,CAAC;8BACR,YAAY;2CAAC"}
@@ -1,31 +1,31 @@
1
- import { QueueJob } from '@spinajs/queue';
2
- import { IEmail, IEmailAttachement } from '../interfaces.js';
3
- /**
4
- * Job for sending emails in background
5
- */
6
- export declare class EmailSend extends QueueJob implements IEmail {
7
- to: string[];
8
- cc?: string[];
9
- bcc?: string[];
10
- from: string;
11
- connection: string;
12
- attachements?: IEmailAttachement[];
13
- template?: string;
14
- templateId?: string;
15
- model?: unknown;
16
- text?: string;
17
- subject: string;
18
- lang?: string;
19
- priority?: string;
20
- replyTo?: string;
21
- tag?: string;
22
- emailId?: string;
23
- execute(): Promise<{
24
- result: boolean;
25
- error: any;
26
- } | {
27
- result: boolean;
28
- error?: undefined;
29
- }>;
30
- }
1
+ import { QueueJob } from '@spinajs/queue';
2
+ import { IEmail, IEmailAttachement } from '../interfaces.js';
3
+ /**
4
+ * Job for sending emails in background
5
+ */
6
+ export declare class EmailSend extends QueueJob implements IEmail {
7
+ to: string[];
8
+ cc?: string[];
9
+ bcc?: string[];
10
+ from: string;
11
+ connection: string;
12
+ attachements?: IEmailAttachement[];
13
+ template?: string;
14
+ templateId?: string;
15
+ model?: unknown;
16
+ text?: string;
17
+ subject: string;
18
+ lang?: string;
19
+ priority?: string;
20
+ replyTo?: string;
21
+ tag?: string;
22
+ emailId?: string;
23
+ execute(): Promise<{
24
+ result: boolean;
25
+ error: any;
26
+ } | {
27
+ result: boolean;
28
+ error?: undefined;
29
+ }>;
30
+ }
31
31
  //# sourceMappingURL=EmailSend.d.ts.map