@chevre/domain 20.1.0-alpha.4 → 20.1.0-alpha.40

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.
Files changed (107) hide show
  1. package/example/src/chevre/deleteEvents.ts +9 -1
  2. package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +157 -0
  3. package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +116 -0
  4. package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +139 -0
  5. package/example/src/chevre/migrateEventProjectAttributes.ts +57 -0
  6. package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
  7. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
  8. package/example/src/chevre/searchEvents.ts +36 -16
  9. package/lib/chevre/repo/accountAction.d.ts +0 -18
  10. package/lib/chevre/repo/accountAction.js +402 -355
  11. package/lib/chevre/repo/accountTitle.d.ts +1 -0
  12. package/lib/chevre/repo/accountTitle.js +6 -1
  13. package/lib/chevre/repo/additionalProperty.d.ts +35 -0
  14. package/lib/chevre/repo/additionalProperty.js +205 -0
  15. package/lib/chevre/repo/categoryCode.d.ts +1 -0
  16. package/lib/chevre/repo/categoryCode.js +15 -1
  17. package/lib/chevre/repo/creativeWork.js +10 -1
  18. package/lib/chevre/repo/customer.d.ts +1 -0
  19. package/lib/chevre/repo/customer.js +5 -0
  20. package/lib/chevre/repo/event.d.ts +12 -4
  21. package/lib/chevre/repo/event.js +84 -48
  22. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
  23. package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
  24. package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
  25. package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
  26. package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
  27. package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
  28. package/lib/chevre/repo/mongoose/model/event.js +53 -0
  29. package/lib/chevre/repo/mongoose/model/offer.js +7 -1
  30. package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
  31. package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
  32. package/lib/chevre/repo/mongoose/model/place.js +42 -0
  33. package/lib/chevre/repo/offer.js +10 -1
  34. package/lib/chevre/repo/offerCatalog.js +10 -10
  35. package/lib/chevre/repo/place.d.ts +1 -0
  36. package/lib/chevre/repo/place.js +54 -7
  37. package/lib/chevre/repo/reservation.d.ts +13 -0
  38. package/lib/chevre/repo/reservation.js +28 -0
  39. package/lib/chevre/repo/transaction.js +20 -5
  40. package/lib/chevre/repository.d.ts +6 -3
  41. package/lib/chevre/repository.js +10 -5
  42. package/lib/chevre/service/account.d.ts +0 -4
  43. package/lib/chevre/service/account.js +24 -22
  44. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
  45. package/lib/chevre/service/accountTransaction/deposit.js +3 -3
  46. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
  47. package/lib/chevre/service/accountTransaction/transfer.js +3 -3
  48. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
  49. package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
  50. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +9 -19
  51. package/lib/chevre/service/assetTransaction/reserve/factory.js +119 -115
  52. package/lib/chevre/service/assetTransaction/reserve.js +99 -89
  53. package/lib/chevre/service/delivery/factory.js +2 -1
  54. package/lib/chevre/service/event.js +20 -6
  55. package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
  56. package/lib/chevre/service/offer/event/authorize.js +65 -27
  57. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  58. package/lib/chevre/service/offer/event/factory.js +17 -12
  59. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
  60. package/lib/chevre/service/offer/factory.js +7 -20
  61. package/lib/chevre/service/offer.js +6 -6
  62. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +4 -2
  63. package/lib/chevre/service/order/onOrderStatusChanged.js +3 -2
  64. package/lib/chevre/service/order/placeOrder.js +13 -5
  65. package/lib/chevre/service/order/returnOrder.js +2 -1
  66. package/lib/chevre/service/order/sendOrder.js +2 -1
  67. package/lib/chevre/service/reserve/cancelReservation.js +135 -87
  68. package/lib/chevre/service/reserve/confirmReservation.js +65 -33
  69. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
  70. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +67 -30
  71. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
  72. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -8
  73. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +6 -3
  74. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
  75. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +2 -1
  76. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +2 -1
  77. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +2 -1
  78. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -3
  79. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -1
  80. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
  81. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -4
  82. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
  83. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
  84. package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
  85. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +4 -5
  86. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +6 -3
  87. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +4 -6
  88. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +2 -1
  89. package/lib/chevre/service/transaction/returnOrder.js +10 -1
  90. package/lib/chevre/service/transaction.js +1 -14
  91. package/package.json +4 -4
  92. package/example/src/chevre/accountBlanceTest.ts +0 -24
  93. package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
  94. package/example/src/chevre/createSeats.ts +0 -59
  95. package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
  96. package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
  97. package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
  98. package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
  99. package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
  100. package/example/src/chevre/publishConfirmationNumber.ts +0 -30
  101. package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
  102. package/example/src/chevre/publishTransactionNumber.ts +0 -28
  103. package/example/src/chevre/renameTransaction.ts +0 -22
  104. package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
  105. package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
  106. package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
  107. package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
@@ -19,78 +19,121 @@ const onReservationCanceled_1 = require("./potentialActions/onReservationCancele
19
19
  /**
20
20
  * 進行中の予約をキャンセルする
21
21
  */
22
+ // tslint:disable-next-line:max-func-body-length
22
23
  function cancelPendingReservation(actionAttributesList) {
24
+ // tslint:disable-next-line:max-func-body-length
23
25
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
26
  const now = new Date();
25
- const canceledReservations = [];
26
- yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
27
- var _a;
28
- let canceledReservation;
29
- const reserveTransactionId = actionAttributes.purpose.id;
30
- // アクション開始
31
- const action = yield repos.action.start(actionAttributes);
32
- try {
33
- // 予約取引を検索
34
- const reserveTransactions = yield repos.assetTransaction.search({
35
- limit: 1,
36
- page: 1,
37
- typeOf: factory.assetTransactionType.Reserve,
38
- ids: [reserveTransactionId]
39
- });
40
- const reserveTransaction = reserveTransactions.shift();
41
- if (reserveTransaction !== undefined) {
42
- const cancelingSubReservation = (_a = reserveTransaction.object.subReservation) === null || _a === void 0 ? void 0 : _a.find((r) => {
43
- return r.id === actionAttributes.object.id;
27
+ let canceledReservations = [];
28
+ if (actionAttributesList.length > 0) {
29
+ // tslint:disable-next-line:max-func-body-length
30
+ yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
31
+ var _a;
32
+ // let canceledReservation: factory.reservation.eventReservation.IReservation | undefined;
33
+ const reserveTransactionId = actionAttributes.purpose.id;
34
+ // アクション開始
35
+ const action = yield repos.action.start(actionAttributes);
36
+ try {
37
+ // 予約取引を検索
38
+ const reserveTransactions = yield repos.assetTransaction.search({
39
+ limit: 1,
40
+ page: 1,
41
+ typeOf: factory.assetTransactionType.Reserve,
42
+ ids: [reserveTransactionId]
44
43
  });
45
- // 取消対象予約が取引に存在すれば、適宜unlock
46
- if (cancelingSubReservation !== undefined) {
47
- const reservationFor = reserveTransaction.object.reservationFor;
48
- if (reservationFor === undefined) {
49
- throw new factory.errors.NotFound('transaction.object.reservationFor');
50
- }
51
- const cancelingReservation = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
52
- yield processUnlockSeat({
53
- reservation: cancelingReservation,
54
- expectedHolder: reserveTransactionId
55
- })(repos);
56
- yield processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
57
- // 予約が存在すればキャンセル状態に変更する
58
- const reservationCount = yield repos.reservation.count({
59
- typeOf: cancelingSubReservation.typeOf,
60
- ids: [cancelingSubReservation.id]
61
- });
62
- if (reservationCount > 0) {
63
- canceledReservation = yield repos.reservation.cancel({
64
- id: cancelingSubReservation.id,
65
- previousReservationStatus: actionAttributes.object.reservationStatus,
44
+ const reserveTransaction = reserveTransactions.shift();
45
+ const actionObject = actionAttributes.object;
46
+ if (reserveTransaction !== undefined) {
47
+ // ReservationPackageに対応(2022-12-23~)
48
+ if (actionObject.typeOf === factory.reservationType.ReservationPackage) {
49
+ const reservationFor = reserveTransaction.object.reservationFor;
50
+ if (reservationFor === undefined) {
51
+ throw new factory.errors.NotFound('transaction.object.reservationFor');
52
+ }
53
+ const subReservation = reserveTransaction.object.subReservation;
54
+ if (Array.isArray(subReservation) && subReservation.length > 0) {
55
+ yield Promise.all(subReservation.map((cancelingSubReservation) => __awaiter(this, void 0, void 0, function* () {
56
+ const cancelingReservation = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
57
+ yield processUnlockSeat({
58
+ reservation: cancelingReservation,
59
+ expectedHolder: reserveTransactionId
60
+ })(repos);
61
+ yield processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
62
+ })));
63
+ }
64
+ // 予約番号単位でキャンセル状態に変更する
65
+ yield repos.reservation.cancelByReservationNumber({
66
+ reservationNumber: actionObject.reservationNumber,
67
+ previousReservationStatus: actionObject.reservationStatus,
66
68
  now
67
69
  });
68
- canceledReservations.push(canceledReservation);
70
+ }
71
+ else {
72
+ const cancelingSubReservation = (_a = reserveTransaction.object.subReservation) === null || _a === void 0 ? void 0 : _a.find((r) => {
73
+ return r.id === actionObject.id;
74
+ });
75
+ // 取消対象予約が取引に存在すれば、適宜unlock
76
+ if (cancelingSubReservation !== undefined) {
77
+ const reservationFor = reserveTransaction.object.reservationFor;
78
+ if (reservationFor === undefined) {
79
+ throw new factory.errors.NotFound('transaction.object.reservationFor');
80
+ }
81
+ const cancelingReservation = Object.assign(Object.assign({}, cancelingSubReservation), { reservationFor });
82
+ yield processUnlockSeat({
83
+ reservation: cancelingReservation,
84
+ expectedHolder: reserveTransactionId
85
+ })(repos);
86
+ yield processUnlockOfferRateLimit({ reservation: cancelingReservation, reservationFor })(repos);
87
+ // 予約が存在すればキャンセル状態に変更する
88
+ const reservationCount = yield repos.reservation.count({
89
+ typeOf: cancelingSubReservation.typeOf,
90
+ ids: [cancelingSubReservation.id]
91
+ });
92
+ if (reservationCount > 0) {
93
+ yield repos.reservation.cancel({
94
+ id: cancelingSubReservation.id,
95
+ previousReservationStatus: actionObject.reservationStatus,
96
+ now
97
+ });
98
+ // canceledReservations.push(canceledReservation);
99
+ }
100
+ }
69
101
  }
70
102
  }
71
103
  }
72
- }
73
- catch (error) {
74
- // actionにエラー結果を追加
75
- try {
76
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
77
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
78
- }
79
- catch (__) {
80
- // 失敗したら仕方ない
104
+ catch (error) {
105
+ // actionにエラー結果を追加
106
+ try {
107
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
108
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
109
+ }
110
+ catch (__) {
111
+ // 失敗したら仕方ない
112
+ }
113
+ throw error;
81
114
  }
82
- throw error;
83
- }
84
- // アクション完了
85
- const actionResult = {
86
- canceledReservationId: canceledReservation === null || canceledReservation === void 0 ? void 0 : canceledReservation.id
87
- };
88
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
89
- if (canceledReservation !== undefined) {
115
+ // アクション完了
116
+ const actionResult = {
117
+ // canceledReservationId: canceledReservation?.id
118
+ };
119
+ yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
90
120
  yield (0, onReservationCanceled_1.onReservationCanceledByAction)(actionAttributes)({ task: repos.task });
121
+ })));
122
+ const reservationNumber = actionAttributesList[0].object.reservationNumber;
123
+ if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
124
+ // 最新のconfirmedReservationsを検索
125
+ canceledReservations = yield repos.reservation.search({
126
+ reservationNumber: { $eq: reservationNumber },
127
+ typeOf: factory.reservationType.EventReservation
128
+ });
129
+ canceledReservations = canceledReservations.map((r) => {
130
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
131
+ delete r._id;
132
+ return r;
133
+ });
91
134
  }
92
- })));
93
- yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false)({ task: repos.task });
135
+ yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false)({ task: repos.task });
136
+ }
94
137
  });
95
138
  }
96
139
  exports.cancelPendingReservation = cancelPendingReservation;
@@ -105,35 +148,40 @@ function cancelReservation(actionAttributesList) {
105
148
  let canceledReservation;
106
149
  const action = yield repos.action.start(actionAttributes);
107
150
  try {
108
- const reservation = yield repos.reservation.findById({
109
- id: actionAttributes.object.id
110
- });
111
- // 予約取引を検索
112
- const reserveTransactions = yield repos.assetTransaction.search({
113
- limit: 1,
114
- page: 1,
115
- typeOf: factory.assetTransactionType.Reserve,
116
- object: { reservations: { id: { $in: [reservation.id] } } }
117
- });
118
- const reserveTransaction = reserveTransactions.shift();
119
- let exectedHolder;
120
- if (reserveTransaction !== undefined) {
121
- exectedHolder = reserveTransaction.id;
151
+ if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
152
+ throw new factory.errors.NotImplemented('ReservationPackage not implemented');
122
153
  }
123
- if (typeof exectedHolder === 'string') {
124
- yield processUnlockSeat({
125
- reservation: reservation,
126
- expectedHolder: exectedHolder
127
- })(repos);
154
+ else {
155
+ const reservation = yield repos.reservation.findById({
156
+ id: actionAttributes.object.id
157
+ });
158
+ // 予約取引を検索
159
+ const reserveTransactions = yield repos.assetTransaction.search({
160
+ limit: 1,
161
+ page: 1,
162
+ typeOf: factory.assetTransactionType.Reserve,
163
+ object: { reservations: { id: { $in: [reservation.id] } } }
164
+ });
165
+ const reserveTransaction = reserveTransactions.shift();
166
+ let exectedHolder;
167
+ if (reserveTransaction !== undefined) {
168
+ exectedHolder = reserveTransaction.id;
169
+ }
170
+ if (typeof exectedHolder === 'string') {
171
+ yield processUnlockSeat({
172
+ reservation: reservation,
173
+ expectedHolder: exectedHolder
174
+ })(repos);
175
+ }
176
+ yield processUnlockOfferRateLimit({ reservation, reservationFor: reservation.reservationFor })(repos);
177
+ // 予約をキャンセル状態に変更する
178
+ canceledReservation = yield repos.reservation.cancel({
179
+ id: reservation.id,
180
+ previousReservationStatus: actionAttributes.object.reservationStatus,
181
+ now
182
+ });
183
+ canceledReservations.push(canceledReservation);
128
184
  }
129
- yield processUnlockOfferRateLimit({ reservation, reservationFor: reservation.reservationFor })(repos);
130
- // 予約をキャンセル状態に変更する
131
- canceledReservation = yield repos.reservation.cancel({
132
- id: reservation.id,
133
- previousReservationStatus: actionAttributes.object.reservationStatus,
134
- now
135
- });
136
- canceledReservations.push(canceledReservation);
137
185
  }
138
186
  catch (error) {
139
187
  // actionにエラー結果を追加
@@ -10,49 +10,81 @@ 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
+ */
16
+ const factory = require("../../factory");
13
17
  const onReservationConfirmed_1 = require("./potentialActions/onReservationConfirmed");
14
18
  /**
15
19
  * 予約を確定する
16
20
  */
17
21
  function confirmReservation(actionAttributesList) {
22
+ // tslint:disable-next-line:max-func-body-length
18
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
19
- const confirmedReservations = [];
20
- yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
21
- let reservation = actionAttributes.object;
22
- const action = yield repos.action.start(actionAttributes);
23
- try {
24
- // 予約を確定状態に変更する
25
- reservation = yield repos.reservation.confirm({
26
- // 更新属性をwhitelist化(2022-06-13~)
27
- // ...actionAttributes.object,
28
- id: reservation.id,
29
- previousReservationStatus: reservation.reservationStatus,
30
- underName: reservation.underName,
31
- reservedTicket: reservation.reservedTicket
32
- });
33
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
34
- delete reservation._id;
35
- confirmedReservations.push(reservation);
36
- }
37
- catch (error) {
38
- // actionにエラー結果を追加
24
+ let confirmedReservations = [];
25
+ if (actionAttributesList.length > 0) {
26
+ yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
27
+ const reservation = actionAttributes.object;
28
+ const action = yield repos.action.start(actionAttributes);
39
29
  try {
40
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
41
- yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
30
+ // ReservationPackageに対応(2022-12-22~)
31
+ if (reservation.typeOf === factory.reservationType.ReservationPackage) {
32
+ // 予約を確定状態に変更する
33
+ yield repos.reservation.confirmByReservationNumber({
34
+ reservationNumber: reservation.reservationNumber,
35
+ previousReservationStatus: reservation.reservationStatus,
36
+ underName: reservation.underName
37
+ });
38
+ }
39
+ else {
40
+ // 予約を確定状態に変更する
41
+ // reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
42
+ yield repos.reservation.confirm({
43
+ // 更新属性をwhitelist化(2022-06-13~)
44
+ // ...actionAttributes.object,
45
+ id: reservation.id,
46
+ previousReservationStatus: reservation.reservationStatus,
47
+ underName: reservation.underName
48
+ // issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
49
+ // reservedTicket: reservation.reservedTicket
50
+ });
51
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
52
+ // delete (<any>reservation)._id;
53
+ // confirmedReservations.push(reservation);
54
+ }
42
55
  }
43
- catch (__) {
44
- // 失敗したら仕方ない
56
+ catch (error) {
57
+ // actionにエラー結果を追加
58
+ try {
59
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
60
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
61
+ }
62
+ catch (__) {
63
+ // 失敗したら仕方ない
64
+ }
65
+ throw error;
45
66
  }
46
- throw error;
67
+ // アクション完了
68
+ const actionResult = {};
69
+ yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
70
+ yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes)({ task: repos.task });
71
+ })));
72
+ // 確定予約通知タスクを予約番号単位で作成する(2022-12-21~)
73
+ const reservationNumber = actionAttributesList[0].object.reservationNumber;
74
+ if (typeof reservationNumber === 'string' && reservationNumber.length > 0) {
75
+ // 最新のconfirmedReservationsを検索
76
+ confirmedReservations = yield repos.reservation.search({
77
+ reservationNumber: { $eq: reservationNumber },
78
+ typeOf: factory.reservationType.EventReservation
79
+ });
80
+ confirmedReservations = confirmedReservations.map((r) => {
81
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
82
+ delete r._id;
83
+ return r;
84
+ });
47
85
  }
48
- // アクション完了
49
- const actionResult = {
50
- confirmedReservationId: reservation.id
51
- };
52
- yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
53
- yield (0, onReservationConfirmed_1.onReservationConfirmedByAction)(actionAttributes, reservation)({ task: repos.task });
54
- })));
55
- yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
86
+ yield (0, onReservationConfirmed_1.onReservationConfirmed)(confirmedReservations)({ task: repos.task });
87
+ }
56
88
  });
57
89
  }
58
90
  exports.confirmReservation = confirmReservation;
@@ -7,7 +7,7 @@ declare type IEventReservation = factory.reservation.IReservation<factory.reserv
7
7
  /**
8
8
  * 予約確定後のアクション
9
9
  */
10
- export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes, confirmedReservation: IEventReservation): (repos: {
10
+ export declare function onReservationConfirmedByAction(actionAttributes: factory.action.reserve.IAttributes): (repos: {
11
11
  task: TaskRepo;
12
12
  }) => Promise<void>;
13
13
  export declare function onReservationConfirmed(confirmedReservations: IEventReservation[]): (repos: {
@@ -21,7 +21,9 @@ const informReservations = settings_1.settings.onReservationStatusChanged.inform
21
21
  /**
22
22
  * 予約確定後のアクション
23
23
  */
24
- function onReservationConfirmedByAction(actionAttributes, confirmedReservation) {
24
+ function onReservationConfirmedByAction(actionAttributes
25
+ // confirmedReservation: IEventReservation
26
+ ) {
25
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
26
28
  const potentialActions = actionAttributes.potentialActions;
27
29
  const now = new Date();
@@ -45,35 +47,34 @@ function onReservationConfirmedByAction(actionAttributes, confirmedReservation)
45
47
  }
46
48
  }
47
49
  // inform galobally
48
- if (Array.isArray(informReservations)) {
49
- const reservation4inform = (0, factory_1.maskUnderName)(confirmedReservation);
50
- taskAttributes.push(...informReservations.map((informReservation) => {
51
- var _a;
52
- const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
53
- const informReservationAttributes = {
54
- agent: confirmedReservation.project,
55
- object: [reservation4inform],
56
- project: confirmedReservation.project,
57
- recipient: {
58
- id: '',
59
- name: informUrl,
60
- typeOf: factory.creativeWorkType.WebApplication,
61
- url: informUrl
62
- },
63
- typeOf: factory.actionType.InformAction
64
- };
65
- return {
66
- project: actionAttributes.project,
67
- name: factory.taskName.TriggerWebhook,
68
- status: factory.taskStatus.Ready,
69
- runsAt: now,
70
- remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
71
- numberOfTried: 0,
72
- executionResults: [],
73
- data: informReservationAttributes
74
- };
75
- }));
76
- }
50
+ // if (Array.isArray(informReservations)) {
51
+ // const reservation4inform: IReservation4informConfirmed = maskUnderName(confirmedReservation);
52
+ // taskAttributes.push(...informReservations.map<ITriggerWebhookTaskAttributes>((informReservation) => {
53
+ // const informUrl: string = String(informReservation.recipient?.url);
54
+ // const informReservationAttributes: InformReservationActionattributes = {
55
+ // agent: confirmedReservation.project,
56
+ // object: [reservation4inform],
57
+ // project: confirmedReservation.project,
58
+ // recipient: {
59
+ // id: '',
60
+ // name: informUrl,
61
+ // typeOf: factory.creativeWorkType.WebApplication,
62
+ // url: informUrl
63
+ // },
64
+ // typeOf: factory.actionType.InformAction
65
+ // };
66
+ // return {
67
+ // project: actionAttributes.project,
68
+ // name: factory.taskName.TriggerWebhook,
69
+ // status: factory.taskStatus.Ready,
70
+ // runsAt: now,
71
+ // remainingNumberOfTries: NUM_TRY_INFORM_RESERVATION,
72
+ // numberOfTried: 0,
73
+ // executionResults: [],
74
+ // data: informReservationAttributes
75
+ // };
76
+ // }));
77
+ // }
77
78
  // タスク保管
78
79
  if (taskAttributes.length > 0) {
79
80
  yield repos.task.saveMany(taskAttributes);
@@ -88,6 +89,42 @@ function onReservationConfirmed(confirmedReservations) {
88
89
  project: confirmedReservations[0].project,
89
90
  reservationFor: { id: confirmedReservations[0].reservationFor.id }
90
91
  })({ task: repos.task });
92
+ const now = new Date();
93
+ const taskAttributes = [];
94
+ // inform galobally
95
+ if (Array.isArray(informReservations)) {
96
+ taskAttributes.push(...informReservations.map((informReservation) => {
97
+ var _a;
98
+ const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
99
+ const informObject = confirmedReservations.map(factory_1.maskUnderName);
100
+ const informReservationAttributes = {
101
+ agent: confirmedReservations[0].project,
102
+ object: informObject,
103
+ project: confirmedReservations[0].project,
104
+ recipient: {
105
+ id: '',
106
+ name: informUrl,
107
+ typeOf: factory.creativeWorkType.WebApplication,
108
+ url: informUrl
109
+ },
110
+ typeOf: factory.actionType.InformAction
111
+ };
112
+ return {
113
+ project: confirmedReservations[0].project,
114
+ name: factory.taskName.TriggerWebhook,
115
+ status: factory.taskStatus.Ready,
116
+ runsAt: now,
117
+ remainingNumberOfTries: factory_1.NUM_TRY_INFORM_RESERVATION,
118
+ numberOfTried: 0,
119
+ executionResults: [],
120
+ data: informReservationAttributes
121
+ };
122
+ }));
123
+ }
124
+ // タスク保管
125
+ if (taskAttributes.length > 0) {
126
+ yield repos.task.saveMany(taskAttributes);
127
+ }
91
128
  }
92
129
  });
93
130
  }
@@ -72,7 +72,7 @@ function confirmReserveTransaction(params) {
72
72
  object = object;
73
73
  yield ReserveTransactionService.confirm({
74
74
  transactionNumber: object.transactionNumber,
75
- object: object.object,
75
+ // object: object.object,
76
76
  potentialActions: object.potentialActions
77
77
  })(repos);
78
78
  }
@@ -15,7 +15,6 @@ exports.orderProgramMembership = exports.ISS_PREFIX = void 0;
15
15
  */
16
16
  const GMO = require("@motionpicture/gmo-service");
17
17
  const createDebug = require("debug");
18
- const moment = require("moment-timezone");
19
18
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
20
19
  const OfferService = require("../offer");
21
20
  const AnyPaymentService = require("../payment/any");
@@ -120,16 +119,15 @@ function createStartPlaceOrderInProgressParams(params) {
120
119
  id: customer.id,
121
120
  identifier: customer.identifier,
122
121
  memberOf: customer.memberOf
123
- // ↓不要なので廃止(2022-05-26~)
124
- // paramsにadditionalPropertyの指定があれば反映する
125
- // ...(Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : []
126
122
  };
127
123
  return {
128
124
  project: { typeOf: factory.organizationType.Project, id: params.project.id },
129
- expires: moment()
130
- // tslint:disable-next-line:no-magic-numbers
131
- .add(5, 'minutes')
132
- .toDate(),
125
+ // expiresInSeconds指定に変更(2022-11-29~)
126
+ // expires: moment()
127
+ // // tslint:disable-next-line:no-magic-numbers
128
+ // .add(5, 'minutes')
129
+ // .toDate(),
130
+ expiresInSeconds: 300,
133
131
  agent,
134
132
  seller: { id: params.seller.id },
135
133
  object: {
@@ -9,6 +9,7 @@ const settings_1 = require("../../../../settings");
9
9
  */
10
10
  // tslint:disable-next-line:max-func-body-length
11
11
  function createTasks(params) {
12
+ var _a;
12
13
  const taskAttributes = [];
13
14
  const transaction = params.transaction;
14
15
  const taskRunsAt = params.runsAt;
@@ -24,7 +25,6 @@ function createTasks(params) {
24
25
  executionResults: [],
25
26
  data: {
26
27
  agent: transaction.project,
27
- // agent: transaction.seller,
28
28
  object: transaction,
29
29
  project: transaction.project,
30
30
  purpose: { typeOf: transaction.typeOf, id: transaction.id },
@@ -72,6 +72,10 @@ function createTasks(params) {
72
72
  if (potentialActions === undefined) {
73
73
  throw new factory.errors.NotFound('Transaction PotentialActions');
74
74
  }
75
+ const orderFromTransaction = (_a = transaction.result) === null || _a === void 0 ? void 0 : _a.order;
76
+ if (orderFromTransaction === undefined) {
77
+ throw new factory.errors.NotFound('Transaction Result');
78
+ }
75
79
  const orderActionAttributes = potentialActions.order;
76
80
  const placeOrderTaskAttributes = {
77
81
  project: transaction.project,
@@ -81,9 +85,8 @@ function createTasks(params) {
81
85
  remainingNumberOfTries: 10,
82
86
  numberOfTried: 0,
83
87
  executionResults: [],
84
- // data: orderActionAttributes
85
88
  data: Object.assign({ project: orderActionAttributes.project, object: {
86
- confirmationNumber: orderActionAttributes.object.confirmationNumber,
89
+ confirmationNumber: orderFromTransaction.confirmationNumber,
87
90
  orderNumber: orderActionAttributes.object.orderNumber
88
91
  } }, (orderActionAttributes.potentialActions !== undefined)
89
92
  ? { potentialActions: orderActionAttributes.potentialActions }
@@ -10,7 +10,9 @@ function createStartParams(params, passport, seller, broker) {
10
10
  if (typeof seller.id !== 'string') {
11
11
  throw new factory.errors.NotFound('seller.id');
12
12
  }
13
- // 取引ファクトリーで新しい進行中取引オブジェクトを作成
13
+ if (typeof params.expiresInSeconds !== 'number') {
14
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
15
+ }
14
16
  return {
15
17
  project: { typeOf: seller.project.typeOf, id: seller.project.id },
16
18
  typeOf: factory.transactionType.PlaceOrder,
@@ -19,11 +21,14 @@ function createStartParams(params, passport, seller, broker) {
19
21
  id: seller.id,
20
22
  name: seller.name,
21
23
  typeOf: seller.typeOf
22
- // ↓最適化(2022-05-24~)
23
- // ...{ project: seller.project }
24
24
  },
25
25
  object: transactionObject,
26
- expires: params.expires
26
+ // expires: params.expires,
27
+ expiresInSeconds: params.expiresInSeconds
28
+ // 販売者にexpires設定があれば適用
29
+ // ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
30
+ // ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
31
+ // : undefined
27
32
  };
28
33
  }
29
34
  exports.createStartParams = createStartParams;
@@ -48,7 +48,8 @@ function createGivePointAwardActions(params) {
48
48
  seller: params.order.seller,
49
49
  // mask
50
50
  customer: (0, order_1.createMaskedCustomer)(params.order),
51
- confirmationNumber: params.order.confirmationNumber,
51
+ // IOrderへ移行(2022-11-17~)
52
+ // confirmationNumber: params.order.confirmationNumber,
52
53
  orderNumber: params.order.orderNumber,
53
54
  price: params.order.price,
54
55
  priceCurrency: params.order.priceCurrency,
@@ -66,7 +66,8 @@ function createMoneyTransferActions(params) {
66
66
  seller: params.order.seller,
67
67
  // mask
68
68
  customer: (0, order_1.createMaskedCustomer)(params.order),
69
- confirmationNumber: params.order.confirmationNumber,
69
+ // IOrderへ移行(2022-11-17~)
70
+ // confirmationNumber: params.order.confirmationNumber,
70
71
  orderNumber: params.order.orderNumber,
71
72
  price: params.order.price,
72
73
  priceCurrency: params.order.priceCurrency,
@@ -51,7 +51,8 @@ function createRegisterServiceActions(params) {
51
51
  seller: params.order.seller,
52
52
  // mask
53
53
  customer: (0, order_1.createMaskedCustomer)(params.order),
54
- confirmationNumber: params.order.confirmationNumber,
54
+ // IOrderへ移行(2022-11-17~)
55
+ // confirmationNumber: params.order.confirmationNumber,
55
56
  orderNumber: params.order.orderNumber,
56
57
  price: params.order.price,
57
58
  priceCurrency: params.order.priceCurrency,