@chevre/domain 21.7.0-alpha.15 → 21.7.0-alpha.17

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.
@@ -50,6 +50,7 @@ export declare class MongoRepository {
50
50
  logo?: string;
51
51
  name?: string;
52
52
  settings?: {
53
+ sendEmailMessage?: factory.project.ISendEmailMessageSettings;
53
54
  sendgridApiKey?: string;
54
55
  };
55
56
  subscription?: {
@@ -142,13 +142,19 @@ class MongoRepository {
142
142
  });
143
143
  }
144
144
  findByIdAndIUpdate(params) {
145
- var _a, _b;
145
+ var _a, _b, _c, _d, _e;
146
146
  return __awaiter(this, void 0, void 0, function* () {
147
- yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
147
+ yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
148
148
  ? { alternateName: params.alternateName }
149
- : undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_a = params.settings) === null || _a === void 0 ? void 0 : _a.sendgridApiKey) === 'string')
149
+ : undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_c = (_b = (_a = params.settings) === null || _a === void 0 ? void 0 : _a.sendEmailMessage) === null || _b === void 0 ? void 0 : _b.sender) === null || _c === void 0 ? void 0 : _c.email) === 'string')
150
+ ? {
151
+ 'settings.sendEmailMessage': {
152
+ sender: { email: params.settings.sendEmailMessage.sender.email }
153
+ }
154
+ }
155
+ : undefined), (typeof ((_d = params.settings) === null || _d === void 0 ? void 0 : _d.sendgridApiKey) === 'string')
150
156
  ? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
151
- : undefined), (typeof ((_b = params.subscription) === null || _b === void 0 ? void 0 : _b.useEventServiceAsProduct) === 'boolean')
157
+ : undefined), (typeof ((_e = params.subscription) === null || _e === void 0 ? void 0 : _e.useEventServiceAsProduct) === 'boolean')
152
158
  ? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
153
159
  : undefined), {
154
160
  // ↓customerUserPoolは廃止
@@ -24,8 +24,9 @@ const debug = createDebug('chevre-domain:service');
24
24
  * https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
25
25
  */
26
26
  function sendEmailMessage(params) {
27
+ // tslint:disable-next-line:max-func-body-length
27
28
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b;
29
+ var _a, _b, _c, _d, _e;
29
30
  const project = yield repos.project.findById({
30
31
  id: params.project.id,
31
32
  inclusion: ['_id', 'settings'],
@@ -45,6 +46,15 @@ function sendEmailMessage(params) {
45
46
  }
46
47
  sgMail.setApiKey(apiKey);
47
48
  const emailMessage = params.object;
49
+ const emailMessageFrom = {
50
+ name: emailMessage.sender.name,
51
+ email: emailMessage.sender.email
52
+ };
53
+ // プロジェクト設定対応(2023-08-21~)
54
+ const senderEmailByProjectSettings = (_d = (_c = (_b = project.settings) === null || _b === void 0 ? void 0 : _b.sendEmailMessage) === null || _c === void 0 ? void 0 : _c.sender) === null || _d === void 0 ? void 0 : _d.email;
55
+ if (typeof senderEmailByProjectSettings === 'string' && senderEmailByProjectSettings.length > 0) {
56
+ emailMessageFrom.email = senderEmailByProjectSettings;
57
+ }
48
58
  let subject;
49
59
  // 互換性維持対応として、String型に対応
50
60
  if (typeof emailMessage.about === 'string') {
@@ -52,7 +62,7 @@ function sendEmailMessage(params) {
52
62
  subject = String(emailMessage.about);
53
63
  }
54
64
  }
55
- else if (typeof ((_b = emailMessage.about) === null || _b === void 0 ? void 0 : _b.name) === 'string') {
65
+ else if (typeof ((_e = emailMessage.about) === null || _e === void 0 ? void 0 : _e.name) === 'string') {
56
66
  if (emailMessage.about.name.length > 0) {
57
67
  subject = emailMessage.about.name;
58
68
  }
@@ -69,10 +79,7 @@ function sendEmailMessage(params) {
69
79
  name: emailMessage.toRecipient.name,
70
80
  email: emailMessage.toRecipient.email
71
81
  }];
72
- const msg = Object.assign(Object.assign(Object.assign({ to: emailDatas, from: {
73
- name: emailMessage.sender.name,
74
- email: emailMessage.sender.email
75
- } }, (typeof subject === 'string') ? { subject } : undefined), (String(emailMessage.text).length > 0) ? { text: String(emailMessage.text) } : undefined), {
82
+ const msg = Object.assign(Object.assign(Object.assign({ to: emailDatas, from: emailMessageFrom }, (typeof subject === 'string') ? { subject } : undefined), (String(emailMessage.text).length > 0) ? { text: String(emailMessage.text) } : undefined), {
76
83
  // html: '<strong>and easy to do anywhere, even with Node.js</strong>',
77
84
  // categories: ['Transactional', 'My category'],
78
85
  // 送信予定を追加することもできるが、タスクの実行予定日時でコントロールする想定
@@ -338,6 +338,14 @@ function createOnPlaceOrderTasksByTransaction(params) {
338
338
  // tslint:disable-next-line:no-single-line-block-comment
339
339
  /* istanbul ignore else */
340
340
  if (potentialActions.sendOrder !== undefined) {
341
+ const sendOrderTaskData = {
342
+ project: potentialActions.sendOrder.project,
343
+ object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber })
344
+ // 廃止(2023-08-21~)
345
+ // ...(potentialActions.sendOrder.potentialActions !== undefined)
346
+ // ? { potentialActions: potentialActions.sendOrder.potentialActions }
347
+ // : undefined
348
+ };
341
349
  const sendOrderTask = {
342
350
  project: potentialActions.sendOrder.project,
343
351
  name: factory.taskName.SendOrder,
@@ -346,9 +354,7 @@ function createOnPlaceOrderTasksByTransaction(params) {
346
354
  remainingNumberOfTries: 10,
347
355
  numberOfTried: 0,
348
356
  executionResults: [],
349
- data: Object.assign({ project: potentialActions.sendOrder.project, object: Object.assign(Object.assign({}, potentialActions.sendOrder.object), { confirmationNumber: params.object.confirmationNumber }) }, (potentialActions.sendOrder.potentialActions !== undefined)
350
- ? { potentialActions: potentialActions.sendOrder.potentialActions }
351
- : undefined)
357
+ data: sendOrderTaskData
352
358
  };
353
359
  taskAttributes.push(sendOrderTask);
354
360
  }
@@ -130,6 +130,17 @@ function createTasks(params) {
130
130
  throw new factory.errors.NotFound('Transaction Result');
131
131
  }
132
132
  const orderActionAttributes = potentialActions.order;
133
+ const placeOrderTaskData = {
134
+ project: orderActionAttributes.project,
135
+ object: {
136
+ confirmationNumber: orderFromTransaction.confirmationNumber,
137
+ orderNumber: orderActionAttributes.object.orderNumber
138
+ }
139
+ // 廃止(2023-08-21~)
140
+ // ...(orderActionAttributes.potentialActions !== undefined)
141
+ // ? { potentialActions: orderActionAttributes.potentialActions }
142
+ // : undefined
143
+ };
133
144
  const placeOrderTaskAttributes = {
134
145
  project: transaction.project,
135
146
  name: factory.taskName.PlaceOrder,
@@ -138,12 +149,7 @@ function createTasks(params) {
138
149
  remainingNumberOfTries: 10,
139
150
  numberOfTried: 0,
140
151
  executionResults: [],
141
- data: Object.assign({ project: orderActionAttributes.project, object: {
142
- confirmationNumber: orderFromTransaction.confirmationNumber,
143
- orderNumber: orderActionAttributes.object.orderNumber
144
- } }, (orderActionAttributes.potentialActions !== undefined)
145
- ? { potentialActions: orderActionAttributes.potentialActions }
146
- : undefined)
152
+ data: placeOrderTaskData
147
153
  };
148
154
  taskAttributes.push(placeOrderTaskAttributes);
149
155
  break;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.326.0-alpha.0",
12
+ "@chevre/factory": "4.326.0-alpha.2",
13
13
  "@cinerino/sdk": "3.165.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.7.0-alpha.15"
120
+ "version": "21.7.0-alpha.17"
121
121
  }