@chevre/domain 21.2.0-alpha.24 → 21.2.0-alpha.26

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.
@@ -0,0 +1,30 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
11
+
12
+ const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.Pay>[]>await taskRepo.search({
13
+ // limit: 100,
14
+ // page: 1,
15
+ name: chevre.factory.taskName.Pay,
16
+ statuses: [chevre.factory.taskStatus.Aborted],
17
+ runsFrom: moment('2023-04-27T00:00:00Z')
18
+ .toDate(),
19
+ sort: { runsAt: chevre.factory.sortType.Ascending }
20
+ });
21
+ console.log(tasks.map((task) => `${task.project.id},${task.id},${moment(task.runsAt)
22
+ .tz('Asia/Tokyo')
23
+ .format('YYYY-MM-DDTHH:mm:ssZ')},"${task.data.object[0].paymentMethod.paymentMethodId}"`)
24
+ .join('\n'));
25
+ console.log(tasks.length);
26
+ }
27
+
28
+ main()
29
+ .then(console.log)
30
+ .catch(console.error);
@@ -27,6 +27,7 @@ export declare const credentials: {
27
27
  lineNotify: {
28
28
  url: string;
29
29
  accessToken: string;
30
+ accessTokenAlert: string;
30
31
  };
31
32
  movieticketReserve: {
32
33
  timeout: number;
@@ -31,7 +31,8 @@ exports.credentials = {
31
31
  },
32
32
  lineNotify: {
33
33
  url: process.env.LINE_NOTIFY_URL,
34
- accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN
34
+ accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
35
+ accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT
35
36
  },
36
37
  movieticketReserve: {
37
38
  // tslint:disable-next-line:no-magic-numbers
@@ -534,12 +534,14 @@ class MongoRepository {
534
534
  */
535
535
  setTasksExportedById(params) {
536
536
  return __awaiter(this, void 0, void 0, function* () {
537
+ const endDate = new Date();
537
538
  yield this.transactionModel.updateOne({
538
539
  _id: { $eq: params.id },
539
540
  tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
540
541
  }, {
541
542
  tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
542
- tasksExportedAt: new Date()
543
+ tasksExportedAt: endDate,
544
+ 'tasksExportAction.endDate': endDate
543
545
  })
544
546
  .exec();
545
547
  });
@@ -1,7 +1,9 @@
1
1
  import * as factory from '../factory';
2
2
  import { MongoRepository as ActionRepo } from '../repo/action';
3
3
  import { MongoRepository as ProjectRepo } from '../repo/project';
4
- export type Operation<T> = () => Promise<T>;
4
+ export type Operation<T> = (repos: {
5
+ accessToken: string;
6
+ }) => Promise<T>;
5
7
  /**
6
8
  * Eメールメッセージを送信する
7
9
  * https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
@@ -111,15 +111,11 @@ exports.sendEmailMessage = sendEmailMessage;
111
111
  * https://notify-bot.line.me/doc/ja/
112
112
  */
113
113
  function report2developers(subject, content, imageThumbnail, imageFullsize) {
114
- return () => __awaiter(this, void 0, void 0, function* () {
114
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
115
115
  const LINE_NOTIFY_URL = credentials_1.credentials.lineNotify.url;
116
- const LINE_NOTIFY_ACCESS_TOKEN = credentials_1.credentials.lineNotify.accessToken;
117
116
  if (LINE_NOTIFY_URL === undefined) {
118
117
  throw new Error('Environment variable LINE_NOTIFY_URL not set');
119
118
  }
120
- if (LINE_NOTIFY_ACCESS_TOKEN === undefined) {
121
- throw new Error('Environment variable LINE_NOTIFY_ACCESS_TOKEN not set');
122
- }
123
119
  const message = `--------
124
120
  ${subject}
125
121
  --------
@@ -130,7 +126,7 @@ ${content}`;
130
126
  var _a;
131
127
  request.post({
132
128
  url: LINE_NOTIFY_URL,
133
- auth: { bearer: LINE_NOTIFY_ACCESS_TOKEN },
129
+ auth: { bearer: repos.accessToken },
134
130
  form: formData,
135
131
  json: true,
136
132
  timeout: (_a = settings_1.settings.webhook) === null || _a === void 0 ? void 0 : _a.timeout
@@ -18,6 +18,7 @@ const factory = require("../factory");
18
18
  const task_1 = require("../repo/task");
19
19
  const NotificationService = require("./notification");
20
20
  const factory_1 = require("./notification/factory");
21
+ const credentials_1 = require("../credentials");
21
22
  const settings_1 = require("../settings");
22
23
  const debug = createDebug('chevre-domain:service:task');
23
24
  const DEFAULT_EXECUTOR_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
@@ -140,7 +141,9 @@ function abort(params) {
140
141
  }
141
142
  // 開発者へ報告
142
143
  const message = (0, factory_1.task2lineNotify)({ task: abortedTask });
143
- yield NotificationService.report2developers(message.subject, message.content)();
144
+ yield NotificationService.report2developers(message.subject, message.content)({
145
+ accessToken: credentials_1.credentials.lineNotify.accessTokenAlert
146
+ });
144
147
  }
145
148
  });
146
149
  }
@@ -157,7 +160,9 @@ function notifyAbortedTasks(params) {
157
160
  if (abortedTasks.length > 0) {
158
161
  // 開発者へ報告
159
162
  const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
160
- yield NotificationService.report2developers(message.subject, message.content)();
163
+ yield NotificationService.report2developers(message.subject, message.content)({
164
+ accessToken: credentials_1.credentials.lineNotify.accessTokenAlert
165
+ });
161
166
  }
162
167
  });
163
168
  }
package/package.json CHANGED
@@ -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.2.0-alpha.24"
120
+ "version": "21.2.0-alpha.26"
121
121
  }