@chevre/domain 24.0.0-alpha.1 → 24.0.0-alpha.11

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 (184) hide show
  1. package/lib/chevre/repo/acceptedPaymentMethod.js +1 -1
  2. package/lib/chevre/repo/additionalProperty.js +1 -1
  3. package/lib/chevre/repo/aggregateOffer.js +1 -1
  4. package/lib/chevre/repo/confirmationNumber.js +2 -4
  5. package/lib/chevre/repo/creativeWork.js +1 -1
  6. package/lib/chevre/repo/eventOffer.js +1 -1
  7. package/lib/chevre/repo/eventSeries.js +1 -1
  8. package/lib/chevre/repo/identity.js +1 -2
  9. package/lib/chevre/repo/issuer.js +2 -4
  10. package/lib/chevre/repo/message.js +1 -1
  11. package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
  12. package/lib/chevre/repo/note.js +1 -1
  13. package/lib/chevre/repo/noteAboutOrder.js +1 -1
  14. package/lib/chevre/repo/offer/unitPriceInCatalog.js +1 -1
  15. package/lib/chevre/repo/offerItemCondition.js +1 -1
  16. package/lib/chevre/repo/order.js +1 -1
  17. package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
  18. package/lib/chevre/repo/orderInTransaction.js +17 -4
  19. package/lib/chevre/repo/orderNumber.d.ts +3 -2
  20. package/lib/chevre/repo/orderNumber.js +25 -32
  21. package/lib/chevre/repo/place/movieTheater.js +1 -1
  22. package/lib/chevre/repo/place/seat.js +1 -1
  23. package/lib/chevre/repo/product.js +1 -1
  24. package/lib/chevre/repo/productOffer.js +1 -1
  25. package/lib/chevre/repo/project.js +1 -1
  26. package/lib/chevre/repo/reservation.js +1 -1
  27. package/lib/chevre/repo/role.js +1 -2
  28. package/lib/chevre/repo/seller.js +1 -1
  29. package/lib/chevre/repo/serviceOutputIdentifier.js +2 -4
  30. package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
  31. package/lib/chevre/repo/transaction/placeOrder.js +528 -0
  32. package/lib/chevre/repo/transaction/returnOrder.d.ts +23 -0
  33. package/lib/chevre/repo/transaction/returnOrder.js +213 -0
  34. package/lib/chevre/repo/transaction.d.ts +11 -84
  35. package/lib/chevre/repo/transaction.js +331 -270
  36. package/lib/chevre/repo/transactionNumber.js +2 -4
  37. package/lib/chevre/repo/trip.js +1 -2
  38. package/lib/chevre/repository.d.ts +12 -0
  39. package/lib/chevre/repository.js +26 -1
  40. package/lib/chevre/service/account.js +14 -21
  41. package/lib/chevre/service/accountTransaction/deposit.js +2 -8
  42. package/lib/chevre/service/accountTransaction/transfer.js +2 -8
  43. package/lib/chevre/service/accountTransaction/withdraw.js +2 -8
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +24 -32
  45. package/lib/chevre/service/assetTransaction/cancelReservationCOA.js +2 -4
  46. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -23
  47. package/lib/chevre/service/assetTransaction/pay/check.js +6 -11
  48. package/lib/chevre/service/assetTransaction/pay/confirm.js +1 -2
  49. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
  51. package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
  52. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
  53. package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
  54. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +53 -0
  55. package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
  56. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +1 -1
  57. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
  58. package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
  59. package/lib/chevre/service/assetTransaction/refund.js +13 -20
  60. package/lib/chevre/service/assetTransaction/registerService.js +1 -7
  61. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +2 -4
  62. package/lib/chevre/service/assetTransaction/reserveCOA.js +2 -4
  63. package/lib/chevre/service/delivery/product/factory.js +1 -2
  64. package/lib/chevre/service/delivery/reservation/factory.js +1 -2
  65. package/lib/chevre/service/event/saveScreeningEvents.js +1 -0
  66. package/lib/chevre/service/event.js +0 -1
  67. package/lib/chevre/service/moneyTransfer.js +2 -2
  68. package/lib/chevre/service/notification/factory.js +1 -1
  69. package/lib/chevre/service/notification/notifyByEmail.js +50 -56
  70. package/lib/chevre/service/notification/sendEmailMessage.js +2 -3
  71. package/lib/chevre/service/notification/triggerWebhook.js +32 -37
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +1 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
  74. package/lib/chevre/service/offer/event/authorize.js +4 -4
  75. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
  76. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  77. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
  78. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
  79. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
  80. package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
  81. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -2
  82. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
  83. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/authorize.js +1 -2
  84. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +2 -2
  85. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +6 -6
  86. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +2 -2
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
  88. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +2 -2
  89. package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
  90. package/lib/chevre/service/offer/moneyTransfer/authorize.js +53 -57
  91. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
  92. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
  93. package/lib/chevre/service/offer/product.d.ts +3 -3
  94. package/lib/chevre/service/offer/product.js +4 -4
  95. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  96. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  97. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
  98. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  99. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +4 -4
  100. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +10 -19
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +1 -1
  103. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +1 -1
  104. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +2 -2
  105. package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
  106. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -1
  107. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
  108. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +1 -1
  109. package/lib/chevre/service/order/onOrderUpdated.js +1 -2
  110. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  111. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
  112. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -3
  113. package/lib/chevre/service/order/placeOrder.d.ts +2 -2
  114. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  115. package/lib/chevre/service/order/returnOrder.js +2 -2
  116. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  117. package/lib/chevre/service/order/sendOrder.js +1 -1
  118. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
  119. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
  120. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  121. package/lib/chevre/service/payment/any/fixOrderAsNeeded.d.ts +2 -2
  122. package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +4 -8
  123. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
  124. package/lib/chevre/service/payment/any.d.ts +6 -6
  125. package/lib/chevre/service/payment/any.js +10 -11
  126. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +1 -2
  127. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  128. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +1 -2
  129. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3dsResult2recipe.d.ts +1 -1
  130. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCardResult2recipe.d.ts +1 -1
  131. package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -1
  132. package/lib/chevre/service/payment/movieTicket/authorize.js +1 -1
  133. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -4
  134. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +4 -6
  135. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +1 -2
  136. package/lib/chevre/service/payment/paymentCard.js +2 -4
  137. package/lib/chevre/service/report/telemetry.d.ts +4 -0
  138. package/lib/chevre/service/report/telemetry.js +7 -12
  139. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -6
  140. package/lib/chevre/service/task/acceptCOAOffer.js +6 -4
  141. package/lib/chevre/service/task/authorizePayment.js +4 -2
  142. package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
  143. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
  144. package/lib/chevre/service/task/deleteTransaction.js +5 -1
  145. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
  146. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +3 -6
  148. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +1 -1
  149. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +1 -1
  150. package/lib/chevre/service/task/pay.js +1 -2
  151. package/lib/chevre/service/task/placeOrder.js +6 -4
  152. package/lib/chevre/service/task/publishPaymentUrl.js +4 -2
  153. package/lib/chevre/service/task/returnOrder.js +4 -4
  154. package/lib/chevre/service/task/returnPayTransaction.js +4 -3
  155. package/lib/chevre/service/task/sendOrder.js +2 -2
  156. package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
  157. package/lib/chevre/service/task/voidPayTransaction.js +4 -2
  158. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
  159. package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
  160. package/lib/chevre/service/transaction/deleteTransaction.d.ts +4 -0
  161. package/lib/chevre/service/transaction/deleteTransaction.js +57 -15
  162. package/lib/chevre/service/transaction/moneyTransfer.js +15 -23
  163. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  164. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
  165. package/lib/chevre/service/transaction/placeOrder/confirm.js +12 -13
  166. package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +2 -2
  167. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
  168. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
  169. package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
  170. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
  171. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
  172. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -2
  173. package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
  174. package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
  175. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
  176. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
  177. package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
  178. package/lib/chevre/service/transaction/placeOrder.js +3 -1
  179. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -2
  180. package/lib/chevre/service/transaction/returnOrder/preStart/getReturnPolicyByProject.js +1 -1
  181. package/lib/chevre/service/transaction/returnOrder.js +4 -4
  182. package/lib/chevre/service/transaction.d.ts +5 -21
  183. package/lib/chevre/service/transaction.js +5 -111
  184. package/package.json +6 -18
@@ -95,7 +95,7 @@ class AcceptedPaymentMethodRepo {
95
95
  }
96
96
  async findAcceptedPaymentMethods(params, inclusion) {
97
97
  const conditions = AcceptedPaymentMethodRepo.CREATE_MONGO_CONDITIONS(params);
98
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
98
+ let positiveProjectionFields;
99
99
  if (Array.isArray(inclusion) && inclusion.length > 0) {
100
100
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
101
101
  }
@@ -84,7 +84,7 @@ class AdditionalPropertyRepo {
84
84
  */
85
85
  async projectFields(params, inclusion) {
86
86
  const conditions = AdditionalPropertyRepo.CREATE_MONGO_CONDITIONS(params);
87
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
87
+ let positiveProjectionFields;
88
88
  if (Array.isArray(inclusion) && inclusion.length > 0) {
89
89
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
90
90
  }
@@ -443,7 +443,7 @@ class AggregateOfferRepo {
443
443
  else if (negativeProjectionFields.length > 0) {
444
444
  negativeProjectionFields.forEach((field) => {
445
445
  if (typeof projectStage[field] === 'string') {
446
- delete projectStage[field];
446
+ delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
447
447
  }
448
448
  });
449
449
  }
@@ -61,16 +61,14 @@ class ConfirmationNumberRepo {
61
61
  * 発行する
62
62
  */
63
63
  async publish(params) {
64
- let dataFeedExpires;
65
64
  const dataFeedIdentifier = ConfirmationNumberRepo.createDataFeedIdentifier({ orderDate: params.orderDate });
66
- let incrReply;
67
65
  // support publishByMongo(2025-05-23~)
68
66
  // const useMongoBySettings = await this.useMongoBySettings(params);
69
67
  // データ保管期間はとりあえず2 months
70
- dataFeedExpires = (0, moment_timezone_1.default)(params.orderDate)
68
+ const dataFeedExpires = (0, moment_timezone_1.default)(params.orderDate)
71
69
  .add(2, 'months')
72
70
  .toDate();
73
- incrReply = await this.counterRepo.incrementByMongo({
71
+ const incrReply = await this.counterRepo.incrementByMongo({
74
72
  identifier: dataFeedIdentifier,
75
73
  includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
76
74
  expires: dataFeedExpires
@@ -253,7 +253,7 @@ class CreativeWorkRepo {
253
253
  */
254
254
  async projectFields(params, inclusion) {
255
255
  const conditions = CreativeWorkRepo.CREATE_MONGO_CONDITIONS(params);
256
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
256
+ let positiveProjectionFields;
257
257
  if (Array.isArray(inclusion) && inclusion.length > 0) {
258
258
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
259
259
  }
@@ -96,7 +96,7 @@ class EventOfferRepo {
96
96
  }
97
97
  async findEventOffers(params, inclusion) {
98
98
  const conditions = EventOfferRepo.CREATE_MONGO_CONDITIONS(params);
99
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
99
+ let positiveProjectionFields;
100
100
  if (Array.isArray(inclusion) && inclusion.length > 0) {
101
101
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
102
102
  }
@@ -481,7 +481,7 @@ class EventSeriesRepo {
481
481
  */
482
482
  async projectEventSeriesFields(params, inclusion) {
483
483
  const conditions = EventSeriesRepo.CREATE_MONGO_CONDITIONS(params);
484
- let projection = {};
484
+ let projection;
485
485
  const positiveProjectionFields = (Array.isArray(inclusion))
486
486
  ? inclusion.filter((key) => key !== 'id' && key !== '_id')
487
487
  : [];
@@ -148,7 +148,6 @@ class IdentityRepo {
148
148
  .cursor();
149
149
  }
150
150
  async updateIssuedBy2array(params) {
151
- let doc;
152
151
  const { id, issuedBy } = params;
153
152
  const filter = {
154
153
  _id: { $eq: id }
@@ -163,7 +162,7 @@ class IdentityRepo {
163
162
  new: true,
164
163
  projection: { _id: 1, id: { $toString: '$_id' } }
165
164
  };
166
- doc = await this.identityModel.findOneAndUpdate(filter, update, options)
165
+ const doc = await this.identityModel.findOneAndUpdate(filter, update, options)
167
166
  .lean()
168
167
  .exec();
169
168
  if (doc === null) {
@@ -75,12 +75,10 @@ class IssuerRepo {
75
75
  return { id: savedId };
76
76
  }
77
77
  async renameIssuerIdentifier(params) {
78
- let savedId;
79
- let doc;
80
78
  const { id, ...updateFields } = params;
81
- doc = await this.issuerModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $set: updateFields }, { upsert: false, new: true, projection: { _id: 1 } })
79
+ const doc = await this.issuerModel.findOneAndUpdate({ _id: { $eq: params.id } }, { $set: updateFields }, { upsert: false, new: true, projection: { _id: 1 } })
82
80
  .exec();
83
- savedId = params.id;
81
+ const savedId = params.id;
84
82
  if (doc === null) {
85
83
  throw new factory.errors.NotFound(this.issuerModel.modelName);
86
84
  }
@@ -78,7 +78,7 @@ class MessageRepo {
78
78
  */
79
79
  async projectFields(params, inclusion) {
80
80
  const conditions = MessageRepo.CREATE_MONGO_CONDITIONS(params);
81
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
81
+ let positiveProjectionFields;
82
82
  if (Array.isArray(inclusion) && inclusion.length > 0) {
83
83
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
84
84
  }
@@ -163,6 +163,37 @@ const indexes = [
163
163
  }
164
164
  }
165
165
  ],
166
+ [
167
+ // 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
168
+ {
169
+ typeOf: 1,
170
+ 'object.orderNumber': 1
171
+ },
172
+ {
173
+ name: 'uniquePlacingOrderNumber20260221',
174
+ unique: true,
175
+ partialFilterExpression: {
176
+ typeOf: factory.transactionType.PlaceOrder,
177
+ 'object.orderNumber': { $exists: true },
178
+ startDate: { $gte: new Date('2026-02-21T11:00:00Z') }
179
+ }
180
+ }
181
+ ],
182
+ [
183
+ // 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
184
+ {
185
+ typeOf: 1,
186
+ 'object.orderNumber': 1
187
+ },
188
+ {
189
+ name: 'uniquePlacingOrderNumber',
190
+ unique: true,
191
+ partialFilterExpression: {
192
+ typeOf: factory.transactionType.PlaceOrder,
193
+ 'object.orderNumber': { $exists: true }
194
+ }
195
+ }
196
+ ],
166
197
  [
167
198
  // ひとつの注文取引に対する確定返品取引はユニークなはず
168
199
  { 'object.order.orderNumber': 1 },
@@ -99,7 +99,7 @@ class NoteRepo {
99
99
  }
100
100
  async findNotes(params, inclusion) {
101
101
  const conditions = NoteRepo.CREATE_MONGO_CONDITIONS(params);
102
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
102
+ let positiveProjectionFields;
103
103
  if (Array.isArray(inclusion) && inclusion.length > 0) {
104
104
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
105
105
  }
@@ -95,7 +95,7 @@ class NoteAboutOrderRepo {
95
95
  */
96
96
  async findOrderNotes(params, inclusion) {
97
97
  const conditions = NoteAboutOrderRepo.CREATE_MONGO_CONDITIONS(params);
98
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
98
+ let positiveProjectionFields;
99
99
  if (Array.isArray(inclusion) && inclusion.length > 0) {
100
100
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
101
101
  }
@@ -113,7 +113,7 @@ class OfferRepo {
113
113
  // idは除外しない(2023-12-14~)
114
114
  if (field !== 'id') {
115
115
  if (typeof projectStage[field] === 'string') {
116
- delete projectStage[field];
116
+ delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
117
117
  }
118
118
  }
119
119
  });
@@ -74,7 +74,7 @@ class OfferItemConditionRepo {
74
74
  // ? Object.values(projection)
75
75
  // .some((value) => value !== 0)
76
76
  // : false;
77
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
77
+ let positiveProjectionFields;
78
78
  if (Array.isArray(inclusion) && inclusion.length > 0) {
79
79
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
80
80
  }
@@ -988,7 +988,7 @@ class OrderRepo {
988
988
  async projectFields(params, options) {
989
989
  const { inclusion } = options;
990
990
  const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
991
- let projectStage = {};
991
+ let projectStage;
992
992
  const positiveProjectionFields = (Array.isArray(inclusion))
993
993
  ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
994
994
  : [];
@@ -28,6 +28,10 @@ export declare class OrderInTransactionRepo {
28
28
  * 注文を受注する
29
29
  */
30
30
  placeOrder(order: IPlacingOrder): Promise<void>;
31
+ /**
32
+ * 注文documentがなければ作成し、受け入れられたオファーを追加する
33
+ * このメソッドでdocumentが初めて生成される(typeOf:PlaceOrderとして)
34
+ */
31
35
  acceptOffer(params: Pick<IOrderInTransaction, 'acceptedOffers' | 'orderNumber' | 'project'>): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
32
36
  /**
33
37
  * serialNumberからオファーを除外する
@@ -45,6 +49,10 @@ export declare class OrderInTransactionRepo {
45
49
  setCustomer(params: Pick<IOrderInTransaction, 'orderNumber' | 'project'> & {
46
50
  customer: factory.order.ICustomer;
47
51
  }): Promise<import("mongoose").UpdateWriteOpResult>;
52
+ /**
53
+ * 注文ドキュメントからcustomer属性を参照する
54
+ * customer未設定であれば、NotFound
55
+ */
48
56
  findCustomerByOrderNumber(params: {
49
57
  orderNumber: {
50
58
  $eq: string;
@@ -56,10 +56,9 @@ class OrderInTransactionRepo {
56
56
  if (!(order.orderDate instanceof Date)) {
57
57
  throw new factory.errors.Argument('orderDate', 'must be Date');
58
58
  }
59
- let setFields;
60
59
  // acceptedOffersを上書きしない
61
60
  // const { acceptedOffers, ...orderWithoutAcceptedOffers } = order;
62
- setFields = order;
61
+ const setFields = order;
63
62
  // typeOf:PlaceOrderのドキュメントが存在すれば、typeOf:Orderに変更する
64
63
  await this.orderModel.updateOne({
65
64
  orderNumber: { $eq: order.orderNumber },
@@ -67,6 +66,10 @@ class OrderInTransactionRepo {
67
66
  }, { $set: setFields }, {})
68
67
  .exec();
69
68
  }
69
+ /**
70
+ * 注文documentがなければ作成し、受け入れられたオファーを追加する
71
+ * このメソッドでdocumentが初めて生成される(typeOf:PlaceOrderとして)
72
+ */
70
73
  async acceptOffer(params) {
71
74
  if (!Array.isArray(params.acceptedOffers) || params.acceptedOffers.length === 0) {
72
75
  return;
@@ -79,7 +82,10 @@ class OrderInTransactionRepo {
79
82
  };
80
83
  return this.orderModel.updateOne({
81
84
  typeOf: { $eq: factory.transactionType.PlaceOrder },
82
- orderNumber: { $eq: params.orderNumber }
85
+ orderNumber: { $eq: params.orderNumber },
86
+ // プロジェクトでもフィルター(注文番号重複バグがあったため)(2026-02-21~)
87
+ // 万が一異なるプロジェクトで同じ注文番号でオファーを受け入れようとしても、DBにインデックスによってDuplicateKey
88
+ 'project.id': { $eq: params.project.id }
83
89
  }, {
84
90
  $setOnInsert: setOnInsert,
85
91
  $push: {
@@ -131,7 +137,10 @@ class OrderInTransactionRepo {
131
137
  const { customer, orderNumber, project } = params;
132
138
  const filter = {
133
139
  typeOf: { $eq: factory.transactionType.PlaceOrder },
134
- orderNumber: { $eq: orderNumber }
140
+ orderNumber: { $eq: orderNumber },
141
+ // プロジェクトでもフィルター(注文番号重複バグがあったため)(2026-02-21~)
142
+ // 万が一異なるプロジェクトで同じ注文番号でオファーを受け入れようとしても、DBにインデックスによってDuplicateKey
143
+ 'project.id': { $eq: project.id }
135
144
  };
136
145
  const setOnInsert = {
137
146
  typeOf: factory.transactionType.PlaceOrder,
@@ -146,6 +155,10 @@ class OrderInTransactionRepo {
146
155
  }, { upsert: true })
147
156
  .exec();
148
157
  }
158
+ /**
159
+ * 注文ドキュメントからcustomer属性を参照する
160
+ * customer未設定であれば、NotFound
161
+ */
149
162
  async findCustomerByOrderNumber(params) {
150
163
  const doc = await this.orderModel.findOne({
151
164
  orderNumber: { $eq: params.orderNumber.$eq }
@@ -9,9 +9,10 @@ export declare class OrderNumberRepo {
9
9
  connection: Connection;
10
10
  });
11
11
  /**
12
- * タイムスタンプから発行する
12
+ * 注文日時から新しい注文番号を発行する
13
+ * グローバルユニークである前提
13
14
  */
14
- publishByTimestamp(params: {
15
+ issueOrderNumber(params: {
15
16
  project: {
16
17
  alternateName: string;
17
18
  };
@@ -34,11 +34,6 @@ const setting_1 = require("./mongoose/schemas/setting");
34
34
  const transactionNumber_2 = require("./mongoose/schemas/transactionNumber");
35
35
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
36
36
  const ORDER_NUMBER_SEPARATOR = '-';
37
- const defaultVersioningForceProjects = [
38
- 'HMX',
39
- 'SMT',
40
- 'KOJ'
41
- ];
42
37
  /**
43
38
  * 注文番号リポジトリ
44
39
  */
@@ -59,39 +54,38 @@ class OrderNumberRepo {
59
54
  // return orderNumber;
60
55
  // }
61
56
  /**
62
- * タイムスタンプから発行する
57
+ * 注文日時から新しい注文番号を発行する
58
+ * グローバルユニークである前提
63
59
  */
64
- async publishByTimestamp(params) {
65
- const { fpeSecret, version, validFrom, versioningForceProjects, versioningExceptionProjects } = await this.findSetting();
60
+ async issueOrderNumber(params) {
61
+ const { fpeSecret, version, validFrom
62
+ // versioningForceProjects
63
+ // versioningExceptionProjects
64
+ } = await this.findSetting();
66
65
  const timestamp = (0, moment_timezone_1.default)(params.orderDate)
67
66
  .valueOf()
68
67
  .toString();
68
+ // const projectPrefix = params.project.alternateName
69
+ // .toUpperCase();
69
70
  const projectPrefix = params.project.alternateName
70
- .toUpperCase();
71
- let dataFeedExpires;
72
- const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
73
- let incrReply;
74
- dataFeedExpires = (0, moment_timezone_1.default)(params.orderDate)
71
+ .toUpperCase().at(0);
72
+ // const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
73
+ const dataFeedIdentifier = timestamp; // reconsider increment scope(2026-02-21~)
74
+ const dataFeedExpires = (0, moment_timezone_1.default)(params.orderDate)
75
75
  .add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
76
76
  .toDate();
77
- incrReply = await this.counterRepo.incrementByMongo({
77
+ const incrReply = await this.counterRepo.incrementByMongo({
78
78
  identifier: dataFeedIdentifier,
79
79
  includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.orderNumber },
80
80
  expires: dataFeedExpires
81
81
  });
82
82
  let orderNumber;
83
- let useVersioning = (validFrom instanceof Date && (0, moment_timezone_1.default)(validFrom)
84
- .isSameOrBefore(params.orderDate))
85
- // versioningForceProjectsであれば強制的にversioning(2026-02-05~)
86
- || versioningForceProjects.includes(projectPrefix);
87
- // versioningExceptionProjectsであれば強制的にversioning不使用(2026-02-10~)
88
- if (versioningExceptionProjects.includes(projectPrefix)) {
89
- useVersioning = false;
90
- }
83
+ const useVersioning = (validFrom instanceof Date && (0, moment_timezone_1.default)(validFrom)
84
+ .isSameOrBefore(params.orderDate));
91
85
  if (typeof fpeSecret === 'string' && typeof version === 'string' && useVersioning) {
92
86
  const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
93
87
  orderNumber = transactionFactory.generate(timestamp, incrReply);
94
- orderNumber = `${projectPrefix.at(0)}${orderNumber}`; // 桁数をversion0に合わせるためにエイリアスの1文字目のみを採用
88
+ orderNumber = `${projectPrefix}${orderNumber}`; // 桁数をversion0に合わせるためにエイリアスの1文字目のみを採用
95
89
  orderNumber = `${[
96
90
  orderNumber.slice(0, 4),
97
91
  orderNumber.slice(4, 11),
@@ -140,11 +134,11 @@ class OrderNumberRepo {
140
134
  .exec();
141
135
  if (setting === null || setting.orderNumber === undefined) {
142
136
  return {
143
- versioningForceProjects: [],
144
- versioningExceptionProjects: []
137
+ // versioningForceProjects: []
138
+ // versioningExceptionProjects: []
145
139
  };
146
140
  }
147
- const { fpeSecret, version, validFrom, versioningForceProjects, versioningExceptionProjects } = setting.orderNumber;
141
+ const { fpeSecret, version, validFrom } = setting.orderNumber;
148
142
  if (typeof fpeSecret !== 'string' || fpeSecret === '') {
149
143
  throw new factory.errors.NotFound('setting.orderNumber.secret');
150
144
  }
@@ -155,12 +149,11 @@ class OrderNumberRepo {
155
149
  throw new factory.errors.NotFound('setting.orderNumber.validFrom must be Date');
156
150
  }
157
151
  return {
158
- fpeSecret, version, validFrom,
159
- versioningForceProjects: [
160
- ...(Array.isArray(versioningForceProjects)) ? versioningForceProjects : [],
161
- ...defaultVersioningForceProjects
162
- ],
163
- versioningExceptionProjects: (Array.isArray(versioningExceptionProjects)) ? versioningExceptionProjects : []
152
+ fpeSecret, version, validFrom
153
+ // versioningForceProjects: [
154
+ // ...(Array.isArray(versioningForceProjects)) ? versioningForceProjects : []
155
+ // ]
156
+ // versioningExceptionProjects: (Array.isArray(versioningExceptionProjects)) ? versioningExceptionProjects : []
164
157
  };
165
158
  }
166
159
  }
@@ -240,7 +240,7 @@ class MovieTheaterRepo {
240
240
  */
241
241
  async projectFields(params, inclusion) {
242
242
  const conditions = MovieTheaterRepo.CREATE_MOVIE_THEATER_MONGO_CONDITIONS(params);
243
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
243
+ let positiveProjectionFields;
244
244
  if (Array.isArray(inclusion) && inclusion.length > 0) {
245
245
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
246
246
  }
@@ -84,7 +84,7 @@ class SeatRepo {
84
84
  Object.keys(params)
85
85
  .forEach((field) => {
86
86
  if (typeof projectStage[field] === 'string') {
87
- delete projectStage[field];
87
+ delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
88
88
  }
89
89
  });
90
90
  return projectStage;
@@ -175,7 +175,7 @@ class ProductRepo {
175
175
  */
176
176
  async projectFields(conditions, inclusion) {
177
177
  const andConditions = ProductRepo.CREATE_MONGO_CONDITIONS(conditions);
178
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
178
+ let positiveProjectionFields;
179
179
  if (Array.isArray(inclusion) && inclusion.length > 0) {
180
180
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
181
181
  }
@@ -97,7 +97,7 @@ class ProductOfferRepo {
97
97
  }
98
98
  async findProductOffers(params, inclusion) {
99
99
  const conditions = ProductOfferRepo.CREATE_MONGO_CONDITIONS(params);
100
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
100
+ let positiveProjectionFields;
101
101
  if (Array.isArray(inclusion) && inclusion.length > 0) {
102
102
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
103
103
  }
@@ -91,7 +91,7 @@ class ProjectRepo {
91
91
  */
92
92
  async projectFields(conditions, inclusion) {
93
93
  const andConditions = ProjectRepo.CREATE_MONGO_CONDITIONS(conditions);
94
- let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
94
+ let positiveProjectionFields;
95
95
  if (Array.isArray(inclusion) && inclusion.length > 0) {
96
96
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
97
97
  }
@@ -789,7 +789,7 @@ class ReservationRepo {
789
789
  */
790
790
  async projectFields(params, inclusion) {
791
791
  const conditions = ReservationRepo.CREATE_MONGO_CONDITIONS(params);
792
- let projection = {};
792
+ let projection;
793
793
  if (inclusion !== undefined && inclusion !== null) {
794
794
  projection = {
795
795
  _id: 0, // hide _id(2024-08-08~)
@@ -177,7 +177,6 @@ class RoleRepo {
177
177
  .exec();
178
178
  }
179
179
  async create(params) {
180
- let savedId;
181
180
  const { member, memberOf, permissions, roleName } = params;
182
181
  const creatingRole = {
183
182
  member, memberOf, permissions, roleName,
@@ -188,7 +187,7 @@ class RoleRepo {
188
187
  if (typeof insertedId !== 'string') {
189
188
  throw new factory.errors.Internal(`role not saved unexpectedly. result:${JSON.stringify(result)}`);
190
189
  }
191
- savedId = insertedId;
190
+ const savedId = insertedId;
192
191
  return { id: savedId };
193
192
  }
194
193
  }
@@ -201,7 +201,7 @@ class SellerRepo {
201
201
  if (exclusion.length > 0) {
202
202
  exclusion.forEach((field) => {
203
203
  if (typeof projectStage[field] === 'string' || typeof projectStage[field] === 'object') {
204
- delete projectStage[field];
204
+ delete projectStage[field]; // eslint-disable-line @typescript-eslint/no-dynamic-delete
205
205
  }
206
206
  });
207
207
  }
@@ -53,13 +53,11 @@ class ServiceOutputIdentifierRepo {
53
53
  const timestamp = (0, moment_timezone_1.default)(params.startDate)
54
54
  .valueOf()
55
55
  .toString();
56
- let dataFeedExpires;
57
56
  const dataFeedIdentifier = timestamp;
58
- let incrReply;
59
- dataFeedExpires = (0, moment_timezone_1.default)(params.startDate)
57
+ const dataFeedExpires = (0, moment_timezone_1.default)(params.startDate)
60
58
  .add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
61
59
  .toDate();
62
- incrReply = await this.counterRepo.incrementByMongo({
60
+ const incrReply = await this.counterRepo.incrementByMongo({
63
61
  identifier: dataFeedIdentifier,
64
62
  includedInDataCatalog: { identifier: transactionNumber_2.DataCatalogIdentifier.serviceOutputIdentifier },
65
63
  expires: dataFeedExpires