@chevre/domain 21.2.0-alpha.86 → 21.2.0-alpha.87

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.
@@ -729,7 +729,8 @@ function confirm(params) {
729
729
  // sync対応(2023-01-13~)
730
730
  yield (0, confirmReservation_1.confirmReservation)({
731
731
  actionAttributesList: potentialActions.reserve,
732
- useOnReservationConfirmed: true
732
+ useOnReservationConfirmed: true,
733
+ byTask: true
733
734
  })(repos);
734
735
  }
735
736
  });
@@ -10,13 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.checkInReservation = void 0;
13
+ const createDebug = require("debug");
13
14
  const factory = require("../../factory");
14
15
  const confirmReservation_1 = require("./confirmReservation");
15
16
  const onReservationCheckedIn_1 = require("./potentialActions/onReservationCheckedIn");
17
+ const debug = createDebug('chevre-domain:service:reserve:checkInReservation');
16
18
  function checkInReservation(params) {
17
19
  return (repos) => __awaiter(this, void 0, void 0, function* () {
18
20
  const now = new Date();
19
21
  // confirmReservationが間に合わない可能性を考慮する(2023-06-01~)
22
+ debug('reserveIfNotYet?', params.reserveIfNotYet, params.object.ids, params.object.reservationNumbers);
20
23
  if (params.reserveIfNotYet === true) {
21
24
  yield reserveIfNotYet(params)(repos);
22
25
  }
@@ -71,6 +74,7 @@ function reserveIfNotYet(params) {
71
74
  },
72
75
  statuses: [factory.transactionStatusType.Confirmed]
73
76
  }, ['_id', 'transactionNumber', 'object', 'project', 'typeOf']);
77
+ debug(reserveTransactions.length, 'reserveTransactions found in reserveIfNotYet.', params.object.ids);
74
78
  }
75
79
  if (Array.isArray(params.object.reservationNumbers) && params.object.reservationNumbers.length > 0) {
76
80
  reserveTransactions = yield repos.assetTransaction.search({
@@ -80,6 +84,7 @@ function reserveIfNotYet(params) {
80
84
  },
81
85
  statuses: [factory.transactionStatusType.Confirmed]
82
86
  }, ['_id', 'transactionNumber', 'object', 'project', 'typeOf']);
87
+ debug(reserveTransactions.length, 'reserveTransactions found in reserveIfNotYet.', params.object.reservationNumbers);
83
88
  }
84
89
  yield Promise.all(reserveTransactions.map((reserveTransaction) => __awaiter(this, void 0, void 0, function* () {
85
90
  var _a;
@@ -99,8 +104,10 @@ function reserveIfNotYet(params) {
99
104
  agent: reserveTransaction.project,
100
105
  purpose: { typeOf: reserveTransaction.typeOf, id: reserveTransaction.id }
101
106
  }],
102
- useOnReservationConfirmed: false // ここでは確定予約の存在を担保すればよいだけ
107
+ useOnReservationConfirmed: false,
108
+ byTask: false
103
109
  })(repos);
110
+ debug('confirmReservation processed in reserveIfNotYet.', reserveTransaction.object.reservationNumber);
104
111
  }
105
112
  })));
106
113
  });
@@ -1,6 +1,3 @@
1
- /**
2
- * 予約サービス
3
- */
4
1
  import * as factory from '../../factory';
5
2
  import { MongoRepository as ActionRepo } from '../../repo/action';
6
3
  import { MongoRepository as AssetTrasactionRepo } from '../../repo/assetTransaction';
@@ -12,6 +9,7 @@ import { MongoRepository as TaskRepo } from '../../repo/task';
12
9
  export declare function confirmReservation(params: {
13
10
  actionAttributesList: factory.action.reserve.IAttributes[];
14
11
  useOnReservationConfirmed: boolean;
12
+ byTask: boolean;
15
13
  }): (repos: {
16
14
  action: ActionRepo;
17
15
  assetTransaction: AssetTrasactionRepo;
@@ -10,11 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.confirmReservation = void 0;
13
- /**
14
- * 予約サービス
15
- */
13
+ const createDebug = require("debug");
16
14
  const factory = require("../../factory");
17
15
  const onReservationConfirmed_1 = require("./potentialActions/onReservationConfirmed");
16
+ const debug = createDebug('chevre-domain:service:reserve:confirmReservation');
18
17
  /**
19
18
  * 予約を確定する
20
19
  */
@@ -22,7 +21,7 @@ function confirmReservation(params) {
22
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
23
22
  if (params.actionAttributesList.length > 0) {
24
23
  yield Promise.all(params.actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
25
- yield reserveIfNotYet(actionAttributes)(repos);
24
+ yield reserveIfNotYet(actionAttributes, { byTask: params.byTask })(repos);
26
25
  if (params.useOnReservationConfirmed) {
27
26
  yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
28
27
  }
@@ -49,12 +48,13 @@ function confirmReservation(params) {
49
48
  });
50
49
  }
51
50
  exports.confirmReservation = confirmReservation;
52
- function reserveIfNotYet(params) {
51
+ function reserveIfNotYet(params, options) {
53
52
  // tslint:disable-next-line:max-func-body-length
54
53
  return (repos) => __awaiter(this, void 0, void 0, function* () {
55
54
  var _a;
56
55
  const reservationPackage = params.object;
57
56
  // 冪等性を担保(2023-05-31~)
57
+ debug('reserveAction not completed yet?', options === null || options === void 0 ? void 0 : options.byTask, reservationPackage.reservationNumber);
58
58
  const completedActions = yield repos.action.search({
59
59
  limit: 1,
60
60
  page: 1,
@@ -69,6 +69,7 @@ function reserveIfNotYet(params) {
69
69
  typeOf: { $in: [params.purpose.typeOf] }
70
70
  }
71
71
  }, ['_id'], []);
72
+ debug(completedActions.length, 'completed reserveAction found', options === null || options === void 0 ? void 0 : options.byTask, reservationPackage.reservationNumber);
72
73
  if (completedActions.length === 0) {
73
74
  const action = yield repos.action.start(params);
74
75
  try {
@@ -25,6 +25,7 @@ export declare function useReservation(params: {
25
25
  identifier?: string;
26
26
  };
27
27
  verifyToken: boolean;
28
+ reserveIfNotYet: boolean;
28
29
  }): (repos: {
29
30
  action: ActionRepo;
30
31
  order: OrderRepo;
@@ -97,7 +97,7 @@ function onAuthorizationCreated(params) {
97
97
  reservationNumbers: reservationNumbers,
98
98
  reservationFor: { ids: reservationForIds }
99
99
  },
100
- reserveIfNotYet: false
100
+ reserveIfNotYet: params.reserveIfNotYet
101
101
  })({
102
102
  action: repos.action,
103
103
  assetTransaction: repos.assetTransaction,
@@ -22,7 +22,8 @@ function call(data) {
22
22
  return (settings) => __awaiter(this, void 0, void 0, function* () {
23
23
  yield ReserveService.confirmReservation({
24
24
  actionAttributesList: data.actionAttributes,
25
- useOnReservationConfirmed: true
25
+ useOnReservationConfirmed: true,
26
+ byTask: true
26
27
  })({
27
28
  action: new action_1.MongoRepository(settings.connection),
28
29
  assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
@@ -23,7 +23,7 @@ function call(data) {
23
23
  var _a, _b;
24
24
  yield (0, reserve_1.useReservation)(Object.assign(Object.assign({ project: data.project, agent: data.agent, object: data.object,
25
25
  // タスク作成前に検証済なので検証不要
26
- verifyToken: false }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
26
+ verifyToken: false, reserveIfNotYet: data.reserveIfNotYet }, (typeof ((_a = data.instrument) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { instrument: data.instrument } : undefined), (typeof ((_b = data.location) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') ? { location: data.location } : undefined))({
27
27
  action: new action_1.MongoRepository(settings.connection),
28
28
  order: new order_1.MongoRepository(settings.connection),
29
29
  reservation: new reservation_1.MongoRepository(settings.connection),
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.21",
12
+ "@chevre/factory": "4.313.0-alpha.22",
13
13
  "@cinerino/sdk": "3.157.0-alpha.5",
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.2.0-alpha.86"
120
+ "version": "21.2.0-alpha.87"
121
121
  }