@pixelplex/mail-service 0.2.6 → 0.2.8

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/.gitlab-ci.yml CHANGED
@@ -2,7 +2,7 @@ stages:
2
2
  - 📦 package
3
3
 
4
4
  📦 package:
5
- image: node:20.17-alpine
5
+ image: node:20.19.1-alpine
6
6
  stage: 📦 package
7
7
  tags:
8
8
  - docker
package/README.md CHANGED
@@ -1,69 +1,50 @@
1
1
  # Mail Service
2
2
 
3
- Library for fast implementation of the functionality of sending email messages.
3
+ Library for sending email messages through configured gateways.
4
4
 
5
- The sends messages them via email.
6
-
7
- ## How to use
8
-
9
- 1. create template for html, plain text and subject
10
- 2. add `@pixelplex/mail-service` to your application
11
- 3. Call `MailModule.forRoot` from `@pixelplex/mail-service`
12
- with specified gateways and options
13
- 4. send a message by calling `this.mailSenderService.sendEmail('test@gmail.com', { htmlPath: htmlTemplatePath, plainPath: plainTextTemplatePath, subjectPath: subjectTemplatePath }, {year: 20});` where `mailSenderService` is `MailSenderService`
14
-
15
- Currently supported gateways:
5
+ ## Supported gateways
16
6
 
17
7
  - slack
18
8
  - console
19
9
  - smtp
20
10
  - sendgrid
11
+ - resend
21
12
 
22
- Didn't understand anything? Okay, let's see more details
13
+ ## Templates
23
14
 
24
- ### Prepare templates
15
+ The service uses Handlebars as the template engine.
25
16
 
26
- The service uses Handlebars as template engine. So all your email templates should be prepared as handlebars templates.
17
+ Expected template files:
27
18
 
28
- For sending message your templates folder should include this files:
19
+ - `{name}.handlebars` for HTML body
20
+ - `{name}.subject.handlebars` for subject
21
+ - `{name}.plain.handlebars` for plain-text body
29
22
 
30
- - `{name}.handlebars` - body of your email where `{name}` is just your template name for email. For example `welcome.handlebars` for the welcome use email
31
- - `{name}.subject.handlebars` - subject (title) of your email. You can use subject field to specify subject directly. It will override subjectPath
32
- - `{name}.plain.handlebars` - subject (title) of your email. You can use plain field to specify plain directly. It will override plainPath
23
+ Example:
33
24
 
34
25
  ```handlebars
35
- # welcome.subject.handlebars Welcome, {{name}}! This is subject
26
+ # welcome.subject.handlebars Welcome, {{name}}!
36
27
  ```
37
28
 
38
29
  ```handlebars
39
30
  # welcome.handlebars
40
-
41
31
  <html>
42
32
  <head></head>
43
33
  <body>
44
34
  <p>Welcome, {{name}}!</p>
45
- <p>How are you?</p>
46
35
  </body>
47
36
  </html>
48
37
  ```
49
38
 
50
39
  ```handlebars
51
- # welcome.plain.handlebars
52
-
53
- <html>
54
- <head></head>
55
- <body>
56
- <p>Welcome, {{name}}!</p>
57
- <p>How are you?</p>
58
- </body>
59
- </html>
40
+ # welcome.plain.handlebars Welcome, {{name}}!
60
41
  ```
61
42
 
62
43
  ## Configuration
63
44
 
64
45
  | Name | Description | Example |
65
46
  | --------------- | -------------------------------------------------------- | ------------------------- |
66
- | gateways | Array of gateways to send email | `['slack']` |
47
+ | gateways | Array of gateways to send email | `['resend']` |
67
48
  | customGateways | Array of custom gateways classes | `[CustomGateway]` |
68
49
  | smtp.host | Mail gateway host address | `smtp.gmail.com` |
69
50
  | smtp.port | Mail gateway port number | `586` |
@@ -71,28 +52,36 @@ For sending message your templates folder should include this files:
71
52
  | smtp.password | Mail gateway password | `qh05780c2qcm034579` |
72
53
  | \*.sender | Mail sender address | `postmail@pixelplex.io` |
73
54
  | slack.url | Hook URL in case you want to duplicate messages to Slack | `https://hooks.slack.com` |
74
- | sendgrid.apiKey | Sendgrid api key | `oiqur9823uiofhaoafoe` |
55
+ | sendgrid.apiKey | Sendgrid API key | `oiqur9823uiofhaoafoe` |
56
+ | resend.apiKey | Resend API key | `re_xxxxxxxxx` |
75
57
 
76
- ### Trigger new message sending
58
+ ### Resend config
77
59
 
78
- **1. Install npm package**
60
+ ```typescript
61
+ export const mailConfig = {
62
+ gateways: ['resend'],
63
+ resend: {
64
+ apiKey: process.env.RESEND_API_KEY,
65
+ sender: process.env.MAIL_SENDER,
66
+ },
67
+ };
68
+ ```
69
+
70
+ ## Usage
79
71
 
80
72
  ```bash
81
73
  yarn add @pixelplex/mail-service
82
74
  ```
83
75
 
84
- **2. Import MailModule** in your module you'll send mail from:
85
-
86
76
  ```typescript
87
77
  import { Module } from '@nestjs/common';
88
78
  import { MailModule } from '@pixelplex/mail-service';
89
79
  import { AppService } from './app.service';
90
80
 
91
81
  @Module({
92
- controllers: [],
93
82
  imports: [
94
83
  MailModule.forRoot({
95
- gateways: ['slack', 'smtp', 'console'],
84
+ gateways: ['slack', 'smtp', 'console', 'resend'],
96
85
  slack: { url: 'hooks.slack.com' },
97
86
  smtp: {
98
87
  username: 'postmail@pixelplex.io',
@@ -101,6 +90,10 @@ import { AppService } from './app.service';
101
90
  port: 678,
102
91
  password: 'password',
103
92
  },
93
+ resend: {
94
+ apiKey: RESEND_API_KEY,
95
+ sender: MAIL_SENDER,
96
+ },
104
97
  }),
105
98
  ],
106
99
  providers: [AppService],
@@ -108,35 +101,40 @@ import { AppService } from './app.service';
108
101
  export class AppModule {}
109
102
  ```
110
103
 
111
- **3. Call sendEmail** to send your mail:
112
-
113
104
  ```typescript
114
105
  import { Injectable } from '@nestjs/common';
115
106
  import { MailSenderService } from '@pixelplex/mail-service';
116
107
 
117
108
  @Injectable()
118
109
  export class AppService {
119
- constructor(private mailSenderService: MailSenderService) {}
110
+ constructor(private readonly mailSenderService: MailSenderService) {}
120
111
 
121
- async onModuleInit() {
122
- this.mailSenderService.sendEmail(
112
+ async sendWelcomeEmail() {
113
+ await this.mailSenderService.sendEmail(
123
114
  'test@gmail.com',
124
- // additionaly you can use plain: plainText, subject: subjectText to specify plain or subject directly
125
- // if so, plainPath or subjectPath will be ignored
126
- { htmlPath: htmlTemplatePath, plainPath: plainTextTemplatePath, subjectPath: subjectTemplatePath },
115
+ {
116
+ htmlPath: htmlTemplatePath,
117
+ plainPath: plainTextTemplatePath,
118
+ subjectPath: subjectTemplatePath,
119
+ },
127
120
  { year: 20 },
128
121
  );
129
122
  }
130
123
  }
131
124
  ```
132
125
 
133
- `{year: 20}` is the object with data which will used as payload data during processing your handlebars template.
126
+ `{ year: 20 }` is the Handlebars context passed into the templates.
127
+
128
+ React templates are not supported at the moment. The package supports the same Handlebars-based flow as before, including for the new `resend` gateway.
134
129
 
135
- ### Custom gateways
130
+ ## Custom gateways
136
131
 
137
- To add custom gateways, provide class, that extends IGateway to customGateways options
132
+ To add a custom gateway, provide a class that implements `IGateway` in `customGateways`.
138
133
 
139
134
  ```typescript
135
+ import { Injectable } from '@nestjs/common';
136
+ import { Content, IGateway } from '@pixelplex/mail-service';
137
+
140
138
  @Injectable()
141
139
  class CustomGateway implements IGateway {
142
140
  async send(to: string, content: Content): Promise<void> {
@@ -144,5 +142,8 @@ class CustomGateway implements IGateway {
144
142
  }
145
143
  }
146
144
 
147
- MailModule.forRoot({ customGateways: [CustomGateway] });
145
+ MailModule.forRoot({
146
+ gateways: ['console'],
147
+ customGateways: [CustomGateway],
148
+ });
148
149
  ```
@@ -7,5 +7,6 @@ export declare enum GATEWAY {
7
7
  SMTP = "smtp",
8
8
  SLACK = "slack",
9
9
  CONSOLE = "console",
10
- SENDGRID = "sendgrid"
10
+ SENDGRID = "sendgrid",
11
+ RESEND = "resend"
11
12
  }
@@ -13,5 +13,6 @@ var GATEWAY;
13
13
  GATEWAY["SLACK"] = "slack";
14
14
  GATEWAY["CONSOLE"] = "console";
15
15
  GATEWAY["SENDGRID"] = "sendgrid";
16
+ GATEWAY["RESEND"] = "resend";
16
17
  })(GATEWAY || (exports.GATEWAY = GATEWAY = {}));
17
18
  //# sourceMappingURL=mail.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail.constants.js","sourceRoot":"","sources":["../../src/constants/mail.constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,uDAA8B,CAAA;IAC9B,iEAAwC,CAAA;IACxC,mEAA0C,CAAA;AAC5C,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAED,IAAY,OAKX;AALD,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,0BAAe,CAAA;IACf,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;AACvB,CAAC,EALW,OAAO,uBAAP,OAAO,QAKlB"}
1
+ {"version":3,"file":"mail.constants.js","sourceRoot":"","sources":["../../src/constants/mail.constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,uDAA8B,CAAA;IAC9B,iEAAwC,CAAA;IACxC,mEAA0C,CAAA;AAC5C,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC;AAED,IAAY,OAMX;AAND,WAAY,OAAO;IACjB,wBAAa,CAAA;IACb,0BAAe,CAAA;IACf,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;IACrB,4BAAiB,CAAA;AACnB,CAAC,EANW,OAAO,uBAAP,OAAO,QAMlB"}
@@ -10,6 +10,7 @@ class GatewayFactory {
10
10
  [constants_1.GATEWAY.CONSOLE]: gateways_1.ConsoleGateway,
11
11
  [constants_1.GATEWAY.SMTP]: gateways_1.SmtpGateway,
12
12
  [constants_1.GATEWAY.SENDGRID]: gateways_1.SendgridGateway,
13
+ [constants_1.GATEWAY.RESEND]: gateways_1.ResendGateway,
13
14
  };
14
15
  return gateways[gateway];
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.factory.js","sourceRoot":"","sources":["../../src/factories/gateway.factory.ts"],"names":[],"mappings":";;;AAAA,4CAAuC;AACvC,0CAAyF;AAGzF,MAAa,cAAc;IACzB,MAAM,CAAC,UAAU,CAAC,OAAgB;QAChC,MAAM,QAAQ,GAAG;YACf,CAAC,mBAAO,CAAC,KAAK,CAAC,EAAE,uBAAY;YAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,yBAAc;YACjC,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE,sBAAW;YAC3B,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,0BAAe;SACpC,CAAC;QAEF,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AAXD,wCAWC"}
1
+ {"version":3,"file":"gateway.factory.js","sourceRoot":"","sources":["../../src/factories/gateway.factory.ts"],"names":[],"mappings":";;;AAAA,4CAAuC;AACvC,0CAAwG;AAGxG,MAAa,cAAc;IACzB,MAAM,CAAC,UAAU,CAAC,OAAgB;QAChC,MAAM,QAAQ,GAAG;YACf,CAAC,mBAAO,CAAC,KAAK,CAAC,EAAE,uBAAY;YAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,yBAAc;YACjC,CAAC,mBAAO,CAAC,IAAI,CAAC,EAAE,sBAAW;YAC3B,CAAC,mBAAO,CAAC,QAAQ,CAAC,EAAE,0BAAe;YACnC,CAAC,mBAAO,CAAC,MAAM,CAAC,EAAE,wBAAa;SAChC,CAAC;QAEF,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF;AAZD,wCAYC"}
@@ -1,4 +1,5 @@
1
1
  export * from './console.gateway';
2
+ export * from './resend.gateway';
2
3
  export * from './sendgrid.gateway';
3
4
  export * from './slack.gateway';
4
5
  export * from './smtp.gateway';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./console.gateway"), exports);
18
+ __exportStar(require("./resend.gateway"), exports);
18
19
  __exportStar(require("./sendgrid.gateway"), exports);
19
20
  __exportStar(require("./slack.gateway"), exports);
20
21
  __exportStar(require("./smtp.gateway"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gateways/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC;AAChC,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gateways/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,iDAA+B"}
@@ -0,0 +1,12 @@
1
+ import { IGateway } from '../interfaces';
2
+ import { Content, ResendOptions } from '../types';
3
+ export declare class ResendGateway implements IGateway {
4
+ private readonly resendOptions;
5
+ private readonly logger;
6
+ private readonly client;
7
+ constructor(resendOptions: ResendOptions);
8
+ send(to: string, content: Content): Promise<void>;
9
+ private prepareAttachments;
10
+ private getAttachmentContent;
11
+ private createSendError;
12
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ResendGateway = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const constants_1 = require("../constants");
18
+ const decorators_1 = require("../decorators");
19
+ const utils_1 = require("../utils");
20
+ const { Resend } = require('resend');
21
+ let ResendGateway = class ResendGateway {
22
+ constructor(resendOptions) {
23
+ this.resendOptions = resendOptions;
24
+ this.logger = new common_1.Logger('Mail::ResendGateway');
25
+ if (!(resendOptions === null || resendOptions === void 0 ? void 0 : resendOptions.apiKey)) {
26
+ throw new Error('Resend gateway requires "resend.apiKey"');
27
+ }
28
+ if (!(resendOptions === null || resendOptions === void 0 ? void 0 : resendOptions.sender)) {
29
+ throw new Error('Resend gateway requires "resend.sender"');
30
+ }
31
+ this.client = new Resend(resendOptions.apiKey);
32
+ }
33
+ async send(to, content) {
34
+ const { error } = await this.client.emails.send(Object.assign(Object.assign({ to, from: this.resendOptions.sender, subject: content.subject, html: content.html }, (content.plain ? { text: content.plain } : {})), (content.attachments ? { attachments: this.prepareAttachments(content.attachments) } : {})));
35
+ if (error) {
36
+ throw this.createSendError(error);
37
+ }
38
+ this.logger.debug(`Message to ${to} sent with resend`);
39
+ }
40
+ prepareAttachments(attachments) {
41
+ return attachments.map((attachment) => ({
42
+ content: this.getAttachmentContent(attachment),
43
+ filename: attachment.filename,
44
+ contentType: attachment.mimeType,
45
+ }));
46
+ }
47
+ getAttachmentContent(attachment) {
48
+ if ((0, utils_1.isBuffer)(attachment.content)) {
49
+ return attachment.content.toString('base64');
50
+ }
51
+ return attachment.encoding === 'base64' ? attachment.content : Buffer.from(attachment.content).toString('base64');
52
+ }
53
+ createSendError(error) {
54
+ const sendError = new Error(`Failed to send mail with resend: ${error.message}`);
55
+ sendError.name = 'ResendGatewayError';
56
+ Object.assign(sendError, { cause: error });
57
+ return sendError;
58
+ }
59
+ };
60
+ exports.ResendGateway = ResendGateway;
61
+ exports.ResendGateway = ResendGateway = __decorate([
62
+ (0, common_1.Injectable)(),
63
+ __param(0, (0, decorators_1.InjectGatewayOptions)(constants_1.GATEWAY.RESEND)),
64
+ __metadata("design:paramtypes", [Object])
65
+ ], ResendGateway);
66
+ //# sourceMappingURL=resend.gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resend.gateway.js","sourceRoot":"","sources":["../../src/gateways/resend.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,4CAAuC;AACvC,8CAAqD;AAGrD,oCAAoC;AA+BpC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAElC,CAAC;A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c,EAAE,mBAAmB,CAAC,CAAC;IACzD,CAAC;IAEO,kBAAkB,CAAC,WAAyB;QAClD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACtC,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;YAC9C,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,WAAW,EAAE,UAAU,CAAC,QAAQ;SACjC,CAAC,CAAC,CAAC;IACN,CAAC;IAEO,oBAAoB,CAAC,UAAsB;QACjD,IAAI,IAAA,gBAAQ,EAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpH,CAAC;IAEO,eAAe,CAAC,KAAkB;QACxC,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC,oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,SAAS,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAE3C,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AAzDY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAME,WAAA,IAAA,iCAAoB,EAAC,mBAAO,CAAC,MAAM,CAAC,CAAA;;GALtC,aAAa,CAyDzB"}
@@ -31,7 +31,8 @@ let SmtpGateway = class SmtpGateway {
31
31
  });
32
32
  }
33
33
  async send(to, content) {
34
- const info = await this.transporter.sendMail(Object.assign(Object.assign(Object.assign({ from: this.smtpOptions.sender, to }, content), { text: content.plain }), (content.attachments ? { attachments: this.prepareAttachments(content.attachments) } : {})));
34
+ const mailOptions = Object.assign(Object.assign(Object.assign({ from: this.smtpOptions.sender, to }, content), { text: content.plain }), (content.attachments ? { attachments: this.prepareAttachments(content.attachments) } : {}));
35
+ const info = await this.transporter.sendMail(mailOptions);
35
36
  this.logger.debug(`Message sent: ${info.messageId}, ${info.response}`);
36
37
  }
37
38
  prepareAttachments(attachments) {
@@ -1 +1 @@
1
- {"version":3,"file":"smtp.gateway.js","sourceRoot":"","sources":["../../src/gateways/smtp.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA2E;AAE3E,4CAAuC;AACvC,8CAAqD;AAK9C,IAAM,WAAW,GAAjB,MAAM,WAAW;IAItB,YAAgD,WAAyC;QAAxB,gBAAW,GAAX,WAAW,CAAa;QAHxE,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAmB,CAAC,CAAC;QAIxD,IAAI,CAAC,WAAW,GAAG,IAAA,4BAAe,EAAC;YACjC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE;gBACJ,IAAI,EAAE,WAAW,CAAC,QAAQ;gBAC1B,IAAI,EAAE,WAAW,CAAC,QAAQ;aAC3B;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU,EAAE,OAAgB;QACrC,MAAM,IAAI,GAAoB,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,6CAC3D,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,EAC7B,EAAE,IACC,OAAO,KACV,IAAI,EAAE,OAAO,CAAC,KAAK,KAChB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,E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