@chevre/domain 21.26.0-alpha.4 → 21.26.0-alpha.6

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,25 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const PROJECT_ID = String(process.env.PROJECT_ID);
8
+
9
+ // tslint:disable-next-line:max-func-body-length
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
+
13
+ const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
14
+
15
+ await (await chevre.service.task.createService()).notifyAbortedTasks({
16
+ dateAbortedGte: moment()
17
+ // tslint:disable-next-line:no-magic-numbers
18
+ .add(-30, 'day')
19
+ .toDate()
20
+ })({ task: taskRepo });
21
+ }
22
+
23
+ main()
24
+ .then(console.log)
25
+ .catch(console.error);
@@ -22,7 +22,11 @@ async function main() {
22
22
  orderDate: {
23
23
  $gte: moment()
24
24
  // tslint:disable-next-line:no-magic-numbers
25
- .add(-365, 'days')
25
+ .add(-275, 'days')
26
+ .toDate(),
27
+ $lte: moment()
28
+ // tslint:disable-next-line:no-magic-numbers
29
+ .add(-270, 'days')
26
30
  .toDate()
27
31
  }
28
32
  },
@@ -30,7 +30,7 @@ lastMessage:${lastMessage}`;
30
30
  };
31
31
  }
32
32
  exports.task2lineNotify = task2lineNotify;
33
- const MAX_LAST_MESSAGE_LENGTH = 20;
33
+ const MAX_LAST_MESSAGE_LENGTH = 60;
34
34
  function tasks2lineNotify(params) {
35
35
  const subject = `${params.tasks.length} ${exports.ABORT_REPORT_SUBJECT}`;
36
36
  let content = subject;
@@ -38,28 +38,34 @@ function tasks2lineNotify(params) {
38
38
  // tslint:disable-next-line:no-magic-numbers
39
39
  if (params.tasks.length > 10) {
40
40
  content = params.tasks.map((task) => {
41
- return `project:${task.project.id}
42
- id:${task.id}
43
- name:${task.name}`;
41
+ return `* project:${task.project.id}
42
+ ${task.id}
43
+ ${task.name}`;
44
44
  })
45
45
  .join('\n');
46
46
  }
47
47
  else {
48
48
  // tslint:disable-next-line:no-magic-numbers
49
- const maxLastMessageLength = (params.tasks.length <= 5) ? 80 : MAX_LAST_MESSAGE_LENGTH; // 通知タスク数に応じてメッセージ長を調整
49
+ const maxLastMessageLength = (params.tasks.length <= 5) ? 150 : MAX_LAST_MESSAGE_LENGTH; // 通知タスク数に応じてメッセージ長を調整
50
50
  content = params.tasks.map((task) => {
51
51
  const lastExecutionResult = (task.executionResults.length > 0) ? task.executionResults.slice(-1)[0] : undefined;
52
52
  let lastError = lastExecutionResult === null || lastExecutionResult === void 0 ? void 0 : lastExecutionResult.error;
53
53
  if (typeof lastError === 'string') {
54
54
  lastError = { message: lastError, name: 'Error' };
55
55
  }
56
- const lastMessage = `${String(lastError === null || lastError === void 0 ? void 0 : lastError.name)} ${String(lastError === null || lastError === void 0 ? void 0 : lastError.message)}`;
57
- return `project:${task.project.id}
58
- id:${task.id}
59
- name:${task.name}
60
- runsAt:${moment(task.runsAt)
56
+ let lastMessage = String(lastError === null || lastError === void 0 ? void 0 : lastError.name);
57
+ if (typeof (lastError === null || lastError === void 0 ? void 0 : lastError.message) === 'string' && lastError.message.length > 0) {
58
+ lastMessage = lastError.message;
59
+ }
60
+ const abbreviatedMessage = (lastMessage.length > maxLastMessageLength)
61
+ ? `${lastMessage.slice(0, maxLastMessageLength)}...`
62
+ : lastMessage;
63
+ return `* project:${task.project.id}
64
+ ${task.id}
65
+ ${task.name}
66
+ ${moment(task.runsAt)
61
67
  .toISOString()}
62
- lastMessage:${lastMessage.slice(0, maxLastMessageLength)}...`;
68
+ ${abbreviatedMessage}`;
63
69
  })
64
70
  .join('\n');
65
71
  }
@@ -95,13 +95,14 @@ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder) {
95
95
  typeOf: factory.actionType.ConfirmAction,
96
96
  object: confirmObject,
97
97
  agent: order.project,
98
- purpose: simpleOrder,
99
- instrument: {
100
- typeOf: 'WebAPI',
101
- identifier: (confirmObject.typeOf === 'COAReserveTransaction')
102
- ? factory.service.webAPI.Identifier.COA
103
- : factory.service.webAPI.Identifier.Chevre
104
- }
98
+ purpose: simpleOrder
99
+ // instrument廃止(2024-03-13~)
100
+ // instrument: {
101
+ // typeOf: 'WebAPI',
102
+ // identifier: (confirmObject.typeOf === 'COAReserveTransaction')
103
+ // ? factory.service.webAPI.Identifier.COA
104
+ // : factory.service.webAPI.Identifier.Chevre
105
+ // }
105
106
  };
106
107
  const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', data.project.id, factory.taskName.ConfirmReserveTransaction, data.purpose.typeOf, data.purpose.orderNumber, data.object.typeOf, data.object.transactionNumber);
107
108
  const confirmReserveTransactionTask = {
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.362.0-alpha.3",
13
+ "@chevre/factory": "4.362.0-alpha.4",
14
14
  "@cinerino/sdk": "5.14.0-alpha.1",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.26.0-alpha.4"
113
+ "version": "21.26.0-alpha.6"
114
114
  }