@chevre/domain 21.2.0-alpha.40 → 21.2.0-alpha.43

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.
@@ -46,7 +46,9 @@ export declare class MongoRepository {
46
46
  * 取引を期限切れにする
47
47
  */
48
48
  makeExpired(params: {
49
- expires: Date;
49
+ expires: {
50
+ $lt: Date;
51
+ };
50
52
  }): Promise<void>;
51
53
  /**
52
54
  * 取引を検索する
@@ -229,7 +229,7 @@ class MongoRepository {
229
229
  // ステータスと期限を見て更新
230
230
  yield this.transactionModel.updateMany({
231
231
  status: factory.transactionStatusType.InProgress,
232
- expires: { $lt: params.expires }
232
+ expires: { $lt: params.expires.$lt }
233
233
  }, {
234
234
  status: factory.transactionStatusType.Expired,
235
235
  endDate: new Date()
@@ -117,6 +117,9 @@ export declare class MongoRepository {
117
117
  exportTasks(params: {
118
118
  now: Date;
119
119
  delayInSeconds: number;
120
+ status: {
121
+ $in: factory.transactionStatusType[];
122
+ };
120
123
  }): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction, "id" | "typeOf" | "status">[]>;
121
124
  /**
122
125
  * set task status exported by transaction id
@@ -129,7 +132,9 @@ export declare class MongoRepository {
129
132
  * 取引を期限切れにする
130
133
  */
131
134
  makeExpired(params: {
132
- expires: Date;
135
+ expires: {
136
+ $lt: Date;
137
+ };
133
138
  }): Promise<void>;
134
139
  /**
135
140
  * 取引を中止する
@@ -441,13 +441,7 @@ class MongoRepository {
441
441
  exportTasks(params) {
442
442
  return __awaiter(this, void 0, void 0, function* () {
443
443
  const delayedTransactions = yield this.transactionModel.find({
444
- status: {
445
- $in: [
446
- factory.transactionStatusType.Canceled,
447
- factory.transactionStatusType.Confirmed,
448
- factory.transactionStatusType.Expired
449
- ]
450
- },
444
+ status: { $in: params.status.$in },
451
445
  tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
452
446
  endDate: {
453
447
  $exists: true,
@@ -502,7 +496,7 @@ class MongoRepository {
502
496
  // IDをemitしたいのでまずリスト検索(2023-04-27~)
503
497
  const expiringTransactions = yield this.transactionModel.find({
504
498
  status: { $eq: factory.transactionStatusType.InProgress },
505
- expires: { $lt: params.expires }
499
+ expires: { $lt: params.expires.$lt }
506
500
  })
507
501
  .select({
508
502
  _id: 1,
@@ -133,6 +133,9 @@ export declare class MongoRepository {
133
133
  exportTasks(params: {
134
134
  now: Date;
135
135
  delayInSeconds: number;
136
+ status: {
137
+ $in: factory.transactionStatusType[];
138
+ };
136
139
  }): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
137
140
  /**
138
141
  * set task status exported by transaction id
@@ -145,7 +148,9 @@ export declare class MongoRepository {
145
148
  * 取引を期限切れにする
146
149
  */
147
150
  makeExpired(params: {
148
- expires: Date;
151
+ expires: {
152
+ $lt: Date;
153
+ };
149
154
  }): Promise<void>;
150
155
  /**
151
156
  * 取引を中止する
@@ -313,7 +313,9 @@ class MongoRepository {
313
313
  const doc = yield this.transactionModel.findOne({
314
314
  _id: { $eq: params.id },
315
315
  typeOf: { $eq: params.typeOf },
316
- status: { $eq: factory.transactionStatusType.InProgress }
316
+ status: { $eq: factory.transactionStatusType.InProgress },
317
+ // expiresを条件に追加(2023-05-12~),
318
+ expires: { $gt: new Date() }
317
319
  })
318
320
  .exec();
319
321
  if (doc === null) {
@@ -543,13 +545,7 @@ class MongoRepository {
543
545
  exportTasks(params) {
544
546
  return __awaiter(this, void 0, void 0, function* () {
545
547
  const delayedTransactions = yield this.transactionModel.find({
546
- status: {
547
- $in: [
548
- factory.transactionStatusType.Canceled,
549
- factory.transactionStatusType.Confirmed,
550
- factory.transactionStatusType.Expired
551
- ]
552
- },
548
+ status: { $in: params.status.$in },
553
549
  tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
554
550
  endDate: {
555
551
  $exists: true,
@@ -604,7 +600,7 @@ class MongoRepository {
604
600
  // IDをemitしたいのでまずリスト検索(2023-04-27~)
605
601
  const expiringTransactions = yield this.transactionModel.find({
606
602
  status: { $eq: factory.transactionStatusType.InProgress },
607
- expires: { $lt: params.expires }
603
+ expires: { $lt: params.expires.$lt }
608
604
  })
609
605
  .select({
610
606
  _id: 1,
@@ -150,6 +150,32 @@ ${content}`;
150
150
  exports.report2developers = report2developers;
151
151
  const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
152
152
  function triggerWebhook(params) {
153
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
154
+ // retryableにする(2023-05-12~)
155
+ let retry = true;
156
+ let numberOfTry = 0;
157
+ while (numberOfTry >= 0) {
158
+ try {
159
+ numberOfTry += 1;
160
+ if (numberOfTry > settings_1.MAX_RETRY_COUNT_TRIGGER_WEBHOOK) {
161
+ retry = false;
162
+ }
163
+ yield processInformAction(params)(repos);
164
+ break;
165
+ }
166
+ catch (error) {
167
+ if (retry) {
168
+ continue;
169
+ }
170
+ else {
171
+ throw error;
172
+ }
173
+ }
174
+ }
175
+ });
176
+ }
177
+ exports.triggerWebhook = triggerWebhook;
178
+ function processInformAction(params) {
153
179
  return (repos) => __awaiter(this, void 0, void 0, function* () {
154
180
  var _a, _b;
155
181
  // アクション開始
@@ -215,4 +241,3 @@ function triggerWebhook(params) {
215
241
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
216
242
  });
217
243
  }
218
- exports.triggerWebhook = triggerWebhook;
@@ -19,7 +19,6 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
23
22
  /**
24
23
  * 予約取消後のアクション
25
24
  */
@@ -51,7 +50,7 @@ function onReservationCanceled(canceledReservations, useInformReservation) {
51
50
  if (Array.isArray(informReservations)) {
52
51
  // やや遅延させる(確定通知が未達の可能性を考慮して)
53
52
  const informTaskRunsAt = moment(now)
54
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
53
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
55
54
  .toDate();
56
55
  const reservations4inform = canceledReservations.map((r) => {
57
56
  return {
@@ -19,7 +19,6 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
23
22
  // tslint:disable-next-line:max-func-body-length
24
23
  function onReservationCheckedIn(params) {
25
24
  // tslint:disable-next-line:max-func-body-length
@@ -31,7 +30,7 @@ function onReservationCheckedIn(params) {
31
30
  if (Array.isArray(informReservations)) {
32
31
  // やや遅延させる(確定通知が未達の可能性を考慮して)
33
32
  const informTaskRunsAt = moment(params.now)
34
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
33
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
35
34
  .toDate();
36
35
  informReservations.forEach((informReservation) => {
37
36
  var _a;
@@ -19,7 +19,6 @@ const settings_1 = require("../../../settings");
19
19
  const offer_1 = require("../../offer");
20
20
  const factory_1 = require("../factory");
21
21
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
22
- const INFORM_TASK_DELAY_IN_SECONDS = 30;
23
22
  /**
24
23
  * 予約使用
25
24
  */
@@ -32,7 +31,7 @@ function onReservationUsed(action, attendedReservation) {
32
31
  if (Array.isArray(informReservations)) {
33
32
  // やや遅延させる(確定通知が未達の可能性を考慮して)
34
33
  const informTaskRunsAt = moment(now)
35
- .add(INFORM_TASK_DELAY_IN_SECONDS, 'seconds')
34
+ .add(settings_1.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS, 'seconds')
36
35
  .toDate();
37
36
  const reservation4inform = {
38
37
  typeOf: attendedReservation.typeOf,
@@ -31,6 +31,8 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
31
31
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
32
32
  export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
33
33
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
34
+ export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
35
+ export declare const MAX_RETRY_COUNT_TRIGGER_WEBHOOK: number;
34
36
  /**
35
37
  * グローバル設定
36
38
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
3
+ exports.settings = exports.MAX_RETRY_COUNT_TRIGGER_WEBHOOK = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -50,6 +50,12 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
50
50
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
51
51
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
52
52
  : moment('2023-08-31T15:00:00Z');
53
+ exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
54
+ ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
55
+ : 0;
56
+ exports.MAX_RETRY_COUNT_TRIGGER_WEBHOOK = (typeof process.env.MAX_RETRY_COUNT_TRIGGER_WEBHOOK === 'string')
57
+ ? Number(process.env.MAX_RETRY_COUNT_TRIGGER_WEBHOOK)
58
+ : 0;
53
59
  /**
54
60
  * グローバル設定
55
61
  */
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.40"
120
+ "version": "21.2.0-alpha.43"
121
121
  }