@chevre/domain 25.2.0-alpha.4 → 25.2.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 (172) hide show
  1. package/lib/chevre/factory/customerTelephone2COATelNum.d.ts +3 -0
  2. package/lib/chevre/factory/customerTelephone2COATelNum.js +22 -0
  3. package/lib/chevre/repo/action/acceptPay.d.ts +15 -0
  4. package/lib/chevre/repo/action/acceptPay.js +47 -19
  5. package/lib/chevre/repo/action/actionProcess.js +57 -57
  6. package/lib/chevre/repo/action.d.ts +16 -9
  7. package/lib/chevre/repo/action.js +99 -180
  8. package/lib/chevre/repo/aggregateOffer.d.ts +2 -3
  9. package/lib/chevre/repo/creativeWork.d.ts +2 -3
  10. package/lib/chevre/repo/customerType.d.ts +2 -3
  11. package/lib/chevre/repo/event.d.ts +10 -11
  12. package/lib/chevre/repo/eventOffer.d.ts +4 -5
  13. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +2 -3
  14. package/lib/chevre/repo/eventSeries.d.ts +4 -5
  15. package/lib/chevre/repo/message.d.ts +1 -1
  16. package/lib/chevre/repo/message.js +1 -1
  17. package/lib/chevre/repo/mongoose/schemas/action.js +67 -66
  18. package/lib/chevre/repo/mongoose/schemas/order.d.ts +4 -0
  19. package/lib/chevre/repo/mongoose/schemas/order.js +10 -0
  20. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
  21. package/lib/chevre/repo/mongoose/schemas/task.js +12 -12
  22. package/lib/chevre/repo/note.d.ts +3 -4
  23. package/lib/chevre/repo/noteAboutOrder.d.ts +2 -3
  24. package/lib/chevre/repo/offerCatalog.d.ts +2 -3
  25. package/lib/chevre/repo/offerCatalogItem.d.ts +2 -3
  26. package/lib/chevre/repo/order.d.ts +2 -0
  27. package/lib/chevre/repo/order.js +14 -14
  28. package/lib/chevre/repo/orderInTransaction.d.ts +68 -1
  29. package/lib/chevre/repo/orderInTransaction.js +181 -3
  30. package/lib/chevre/repo/person.d.ts +0 -15
  31. package/lib/chevre/repo/person.js +122 -108
  32. package/lib/chevre/repo/place/entranceGate.d.ts +4 -5
  33. package/lib/chevre/repo/place/movieTheater.d.ts +3 -4
  34. package/lib/chevre/repo/place/screeningRoom.d.ts +4 -5
  35. package/lib/chevre/repo/place/seat.d.ts +4 -5
  36. package/lib/chevre/repo/place/section.d.ts +3 -4
  37. package/lib/chevre/repo/product.d.ts +3 -4
  38. package/lib/chevre/repo/rateLimit/offer.js +0 -12
  39. package/lib/chevre/repo/reservation.d.ts +2 -3
  40. package/lib/chevre/repo/sellerMakesOffer.d.ts +3 -4
  41. package/lib/chevre/repo/stockHolder.d.ts +1 -1
  42. package/lib/chevre/repo/stockHolder.js +0 -146
  43. package/lib/chevre/repo/transaction/placeOrder.d.ts +2 -45
  44. package/lib/chevre/repo/transaction/placeOrder.js +43 -83
  45. package/lib/chevre/repo/transaction.d.ts +2 -2
  46. package/lib/chevre/repo/transactionNumberCounter.js +0 -34
  47. package/lib/chevre/repo/transactionProcess.js +0 -13
  48. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +1 -1
  49. package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +1 -1
  50. package/lib/chevre/service/assetTransaction/pay/start/factory.js +3 -4
  51. package/lib/chevre/service/assetTransaction/pay/start.d.ts +1 -1
  52. package/lib/chevre/service/notification/factory.d.ts +2 -4
  53. package/lib/chevre/service/notification/factory.js +26 -24
  54. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +11 -5
  55. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +11 -3
  56. package/lib/chevre/service/offer/event/authorize/factory.d.ts +3 -5
  57. package/lib/chevre/service/offer/event/authorize/factory.js +93 -75
  58. package/lib/chevre/service/offer/event/authorize.d.ts +0 -4
  59. package/lib/chevre/service/offer/event/authorize.js +2 -2
  60. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +6 -7
  61. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +10 -10
  62. package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +0 -5
  63. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +17 -14
  64. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.d.ts +0 -5
  65. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +2 -2
  66. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  67. package/lib/chevre/service/order/deleteOrder.d.ts +5 -1
  68. package/lib/chevre/service/order/deleteOrder.js +8 -1
  69. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +19 -11
  70. package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +2 -0
  71. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +2 -2
  72. package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +1 -7
  73. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +2 -0
  74. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +2 -0
  75. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +5 -1
  76. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +95 -33
  77. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -2
  78. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +4 -2
  79. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +2 -6
  80. package/lib/chevre/service/order/payOrder.d.ts +2 -0
  81. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -1
  82. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +13 -58
  83. package/lib/chevre/service/order/placeOrder/factory.js +3 -21
  84. package/lib/chevre/service/order/placeOrder.d.ts +4 -5
  85. package/lib/chevre/service/order/placeOrder.js +20 -31
  86. package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +1 -2
  87. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -2
  88. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +4 -3
  89. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +3 -31
  90. package/lib/chevre/service/payment/any/authorize.js +13 -37
  91. package/lib/chevre/service/payment/any/factory.d.ts +7 -7
  92. package/lib/chevre/service/payment/any/factory.js +19 -22
  93. package/lib/chevre/service/payment/any/findAcceptAction.d.ts +3 -1
  94. package/lib/chevre/service/payment/any/findAcceptAction.js +14 -6
  95. package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +2 -0
  96. package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +4 -66
  97. package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +4 -0
  98. package/lib/chevre/service/payment/any/publishPaymentUrl.js +4 -18
  99. package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +2 -0
  100. package/lib/chevre/service/payment/any/voidPayTransaction.js +1 -23
  101. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  102. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +5 -9
  103. package/lib/chevre/service/reserve/adminFindReservations.d.ts +15 -0
  104. package/lib/chevre/service/reserve/adminFindReservations.js +35 -0
  105. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +17 -8
  106. package/lib/chevre/service/reserve/searchByOrder.js +2 -6
  107. package/lib/chevre/service/reserve.d.ts +2 -2
  108. package/lib/chevre/service/reserve.js +3 -3
  109. package/lib/chevre/service/task/aggregateOffers.d.ts +2 -2
  110. package/lib/chevre/service/task/aggregateOffers.js +2 -1
  111. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +2 -2
  112. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -1
  113. package/lib/chevre/service/task/authorizePayment.js +3 -1
  114. package/lib/chevre/service/task/cancelReservation.d.ts +2 -2
  115. package/lib/chevre/service/task/cancelReservation.js +2 -1
  116. package/lib/chevre/service/task/confirmPayTransaction.js +0 -1
  117. package/lib/chevre/service/task/confirmReserveTransaction.js +2 -7
  118. package/lib/chevre/service/task/deleteTransaction.d.ts +2 -2
  119. package/lib/chevre/service/task/deleteTransaction.js +2 -1
  120. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +2 -2
  121. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -3
  122. package/lib/chevre/service/task/onEventChanged.d.ts +2 -2
  123. package/lib/chevre/service/task/onEventChanged.js +2 -1
  124. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +2 -2
  125. package/lib/chevre/service/task/onOrderPaymentCompleted.js +4 -1
  126. package/lib/chevre/service/task/onResourceUpdated.d.ts +2 -2
  127. package/lib/chevre/service/task/onResourceUpdated.js +2 -1
  128. package/lib/chevre/service/task/placeOrder.d.ts +2 -2
  129. package/lib/chevre/service/task/placeOrder.js +6 -3
  130. package/lib/chevre/service/task/publishPaymentUrl.js +7 -3
  131. package/lib/chevre/service/task/refund.d.ts +2 -2
  132. package/lib/chevre/service/task/refund.js +4 -10
  133. package/lib/chevre/service/task/reserve.d.ts +2 -2
  134. package/lib/chevre/service/task/reserve.js +2 -1
  135. package/lib/chevre/service/task/returnOrder.d.ts +2 -2
  136. package/lib/chevre/service/task/returnOrder.js +2 -1
  137. package/lib/chevre/service/task/sendOrder.d.ts +2 -2
  138. package/lib/chevre/service/task/sendOrder.js +2 -1
  139. package/lib/chevre/service/task/voidPayTransaction.js +3 -7
  140. package/lib/chevre/service/task/voidPayment.d.ts +2 -2
  141. package/lib/chevre/service/task/voidPayment.js +2 -1
  142. package/lib/chevre/service/taskHandler.d.ts +2 -2
  143. package/lib/chevre/service/taskHandler.js +36 -37
  144. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.d.ts +15 -0
  145. package/lib/chevre/service/transaction/deleteTransaction/deletePayTransactionsByPlaceOrder.js +51 -0
  146. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.d.ts +23 -0
  147. package/lib/chevre/service/transaction/deleteTransaction/deleteReservationsByPlaceOrder.js +64 -0
  148. package/lib/chevre/service/transaction/deleteTransaction.js +15 -152
  149. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +28 -2
  150. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.js +11 -12
  151. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +4 -2
  152. package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.js +6 -7
  153. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.d.ts +35 -2
  154. package/lib/chevre/service/transaction/placeOrder/confirm/prepareUnitPriceOfferConditions.js +16 -12
  155. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +5 -1
  156. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +11 -2
  157. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +112 -91
  158. package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +6 -5
  159. package/lib/chevre/service/transaction/placeOrder/confirm.js +33 -78
  160. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +4 -7
  161. package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +33 -15
  162. package/lib/chevre/service/transaction/placeOrder/start.d.ts +1 -1
  163. package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.d.ts +20 -0
  164. package/lib/chevre/service/transaction/placeOrder/updateAgent/fixCustomer.js +63 -0
  165. package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +0 -1
  166. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +17 -86
  167. package/lib/chevre/taskSettings.d.ts +1 -3
  168. package/package.json +8 -11
  169. package/lib/chevre/service/order/findConfirmedPlaceOrder.d.ts +0 -13
  170. package/lib/chevre/service/order/findConfirmedPlaceOrder.js +0 -32
  171. package/lib/chevre/service/reserve/findReservations.d.ts +0 -33
  172. package/lib/chevre/service/reserve/findReservations.js +0 -61
@@ -5,6 +5,7 @@ exports.OrderInTransactionRepo = void 0;
5
5
  const errorHandler_1 = require("../errorHandler");
6
6
  const factory_1 = require("../factory");
7
7
  const order_1 = require("./mongoose/schemas/order");
8
+ const transaction_1 = require("./mongoose/schemas/transaction");
8
9
  const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
9
10
  // const debug = createDebug('chevre-domain:repo:orderInTransaction');
10
11
  /**
@@ -12,9 +13,11 @@ const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
12
13
  */
13
14
  class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInReserveRepo {
14
15
  orderModel;
16
+ transactionModel;
15
17
  constructor(connection) {
16
18
  super(connection);
17
19
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
20
+ this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
18
21
  }
19
22
  async createPlaceOrderIfNotExists(params) {
20
23
  const { orderNumber, project, identifier, broker, seller, customer } = params;
@@ -93,10 +96,12 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
93
96
  * 取引進行中の注文からacceptedOffersを検索する
94
97
  * 予約取引から予約ごとの価格仕様も参照する
95
98
  */
96
- async findAcceptedOffersWithPriceByIdentifier(params) {
99
+ async findAcceptedOffersWithPriceByIdentifier(params, options) {
100
+ const onlyPlaceOrder = options.onlyPlaceOrder === true;
97
101
  const doc = await this.orderModel.findOne({
98
102
  identifier: { $eq: params.identifier },
99
- typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
103
+ 'project.id': { $eq: params.project.id },
104
+ ...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
100
105
  }, { acceptedOffers: 1 })
101
106
  .lean()
102
107
  .exec();
@@ -142,7 +147,8 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
142
147
  if (!(order.orderDate instanceof Date)) {
143
148
  throw new factory_1.factory.errors.Argument('orderDate', 'must be Date');
144
149
  }
145
- const setFields = order;
150
+ const { confirmationNumber: _confirmationNumber, orderNumber: _orderNumber, ...setFields } = order;
151
+ // const setFields: AnyKeys<factory.order.IOrder> = order;
146
152
  // typeOf:PlaceOrderのドキュメントが存在すれば、typeOf:Orderに変更する
147
153
  await this.orderModel.updateOne({
148
154
  identifier: { $eq: identifier },
@@ -241,6 +247,178 @@ class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInRes
241
247
  }
242
248
  return result;
243
249
  }
250
+ /**
251
+ * 確認番号を参照する
252
+ */
253
+ async findConfirmationNumberByIdentifier(params) {
254
+ const { identifier } = params;
255
+ const doc = await this.orderModel.findOne({
256
+ identifier: { $eq: identifier },
257
+ // typeOf: { $eq: factory.transactionType.PlaceOrder }, // 取引確定の冪等性確保のためtypeOfを検証しない
258
+ }, { confirmationNumber: 1 })
259
+ .lean()
260
+ .exec();
261
+ if (doc === null) {
262
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
263
+ }
264
+ return doc.confirmationNumber;
265
+ }
266
+ /**
267
+ * 注文ドキュメントに確認番号を保管する
268
+ * 確認番号未発行の場合のみ保管される
269
+ */
270
+ async saveConfirmationNumberIfNotExist(params, options) {
271
+ const { identifier, confirmationNumber } = params;
272
+ const onlyPlaceOrder = options.onlyPlaceOrder === true;
273
+ if (typeof confirmationNumber !== 'string' || confirmationNumber === '') {
274
+ throw new factory_1.factory.errors.ArgumentNull('confirmationNumber');
275
+ }
276
+ return this.orderModel.updateOne({
277
+ identifier: { $eq: identifier },
278
+ confirmationNumber: { $exists: false },
279
+ ...((onlyPlaceOrder) && { typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder } })
280
+ }, { $set: { confirmationNumber } })
281
+ .exec();
282
+ }
283
+ /**
284
+ * 特定の進行中取引の決済方法IDを保管する
285
+ * transactionsへの保管としてひとまず定義(2026-07-11~)
286
+ */
287
+ async savePaymentMethodId(params, options) {
288
+ const { savePaymentMethodIdInTransaction } = options;
289
+ const { paymentMethodId } = params.paymentMethod;
290
+ if (typeof paymentMethodId !== 'string' || paymentMethodId === '') {
291
+ throw new factory_1.factory.errors.ArgumentNull('paymentMethod.paymentMethodId');
292
+ }
293
+ if (savePaymentMethodIdInTransaction) {
294
+ await this.transactionModel.findOneAndUpdate({
295
+ _id: { $eq: params.id },
296
+ status: { $eq: factory_1.factory.transactionStatusType.InProgress }
297
+ }, {
298
+ $set: { 'object.paymentMethods': { paymentMethodId } }
299
+ }, {
300
+ projection: { _id: 1 }
301
+ })
302
+ .lean()
303
+ .exec()
304
+ .then((doc) => {
305
+ if (doc === null) {
306
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
307
+ }
308
+ });
309
+ }
310
+ // 注文ドキュメントにも保管する(2026-07-12~)
311
+ await this.orderModel.findOneAndUpdate({
312
+ identifier: { $eq: params.id },
313
+ paymentMethodId: { $exists: false },
314
+ typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
315
+ }, { $set: { paymentMethodId } }, { projection: { _id: 1 } })
316
+ .lean()
317
+ .exec()
318
+ .then((doc) => {
319
+ if (doc === null) {
320
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
321
+ }
322
+ });
323
+ }
324
+ /**
325
+ * 進行中取引に保管された採用済決済方法を検索する
326
+ * 注文ドキュメントから参照する(2026-07-13~)
327
+ */
328
+ async findInProgressPaymentMethodId(params) {
329
+ // const doc = await this.transactionModel.findOne(
330
+ // {
331
+ // _id: { $eq: params.id },
332
+ // typeOf: { $eq: factory.transactionType.PlaceOrder },
333
+ // status: { $eq: factory.transactionStatusType.InProgress }
334
+ // },
335
+ // {
336
+ // 'object.paymentMethods': 1,
337
+ // _id: 0
338
+ // }
339
+ // )
340
+ // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>()
341
+ // .exec();
342
+ // if (doc === null) {
343
+ // throw new factory.errors.NotFound(
344
+ // this.transactionModel.modelName,
345
+ // `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
346
+ // );
347
+ // }
348
+ // return (typeof doc.object.paymentMethods?.paymentMethodId === 'string') ? doc.object.paymentMethods.paymentMethodId : undefined;
349
+ const doc = await this.orderModel.findOne({
350
+ identifier: { $eq: params.id },
351
+ typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder }
352
+ }, {
353
+ paymentMethodId: 1,
354
+ _id: 0
355
+ })
356
+ .lean()
357
+ .exec();
358
+ if (doc === null) {
359
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
360
+ }
361
+ return (typeof doc.paymentMethodId === 'string') ? doc.paymentMethodId : undefined;
362
+ }
363
+ /**
364
+ * 保管された採用済決済方法を検索する
365
+ * 注文ドキュメントから参照する(2026-07-13~)
366
+ */
367
+ async findPaymentMethodId(params) {
368
+ // const doc = await this.transactionModel.findOne(
369
+ // {
370
+ // _id: { $eq: params.id },
371
+ // typeOf: { $eq: factory.transactionType.PlaceOrder }
372
+ // },
373
+ // {
374
+ // 'object.paymentMethods': 1,
375
+ // _id: 0
376
+ // }
377
+ // )
378
+ // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'paymentMethods'> }>()
379
+ // .exec();
380
+ // if (doc === null) {
381
+ // throw new factory.errors.NotFound(
382
+ // this.transactionModel.modelName,
383
+ // `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
384
+ // );
385
+ // }
386
+ // const paymentMethodId = doc.object.paymentMethods?.paymentMethodId;
387
+ // if (typeof paymentMethodId === 'string') {
388
+ // // 注文ドキュメントにも発行済の場合、同一性を検証(2026-07-12~)
389
+ // const orderDoc = await this.orderModel.findOne(
390
+ // { identifier: { $eq: params.id } },
391
+ // {
392
+ // paymentMethodId: 1,
393
+ // _id: 0
394
+ // }
395
+ // )
396
+ // .lean<Pick<IDocType, 'paymentMethodId'>>()
397
+ // .exec();
398
+ // if (orderDoc === null) {
399
+ // throw new factory.errors.NotFound('orderInTransaction');
400
+ // }
401
+ // const paymentMethodIdByOrder = orderDoc.paymentMethodId;
402
+ // if (typeof paymentMethodIdByOrder === 'string') {
403
+ // // console.log('paymentMethodId matched?', JSON.stringify(doc), JSON.stringify(orderDoc));
404
+ // if (paymentMethodId !== paymentMethodIdByOrder) {
405
+ // throw new factory.errors.Internal('paymentMethodId not matched unexpectedly');
406
+ // }
407
+ // }
408
+ // }
409
+ // return (typeof paymentMethodId === 'string') ? paymentMethodId : undefined;
410
+ const doc = await this.orderModel.findOne({ identifier: { $eq: params.id } }, {
411
+ paymentMethodId: 1,
412
+ _id: 0
413
+ })
414
+ .lean()
415
+ .exec();
416
+ if (doc === null) {
417
+ throw new factory_1.factory.errors.NotFound('orderInTransaction');
418
+ }
419
+ const paymentMethodId = doc.paymentMethodId;
420
+ return (typeof paymentMethodId === 'string') ? paymentMethodId : undefined;
421
+ }
244
422
  async deleteByIdentifier(params) {
245
423
  return this.orderModel.deleteOne({
246
424
  typeOf: { $eq: factory_1.factory.transactionType.PlaceOrder },
@@ -21,20 +21,12 @@ export declare class PersonRepo {
21
21
  userPoolId?: string;
22
22
  attributes?: AttributeType[];
23
23
  }): factory.person.IPerson;
24
- static PROFILE2ATTRIBUTE(params: factory.person.IProfile): AttributeType[];
25
24
  /**
26
25
  * 管理者権限でユーザー属性を取得する
27
26
  */
28
27
  getUserAttributes(params: {
29
28
  username: string;
30
29
  }): Promise<factory.person.IProfile>;
31
- /**
32
- * 管理者権限でプロフィール更新
33
- */
34
- updateProfile(params: {
35
- username: string;
36
- profile: factory.person.IProfile;
37
- }): Promise<void>;
38
30
  /**
39
31
  * 管理者権限でsubでユーザーを検索する
40
32
  */
@@ -45,13 +37,6 @@ export declare class PersonRepo {
45
37
  * アクセストークンでユーザー属性を取得する
46
38
  */
47
39
  getUserAttributesByAccessToken(accessToken: string): Promise<factory.person.IProfile>;
48
- /**
49
- * 会員プロフィール更新
50
- */
51
- updateProfileByAccessToken(params: {
52
- accessToken: string;
53
- profile: factory.person.IProfile;
54
- }): Promise<void>;
55
40
  /**
56
41
  * 削除
57
42
  */
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PersonRepo = void 0;
4
- // import { fromEnv } from '@aws-sdk/credential-providers';
5
- const google_libphonenumber_1 = require("google-libphonenumber");
6
4
  const factory_1 = require("../factory");
7
5
  /**
8
6
  * 会員リポジトリ
@@ -92,73 +90,81 @@ class PersonRepo {
92
90
  }
93
91
  return person;
94
92
  }
95
- static PROFILE2ATTRIBUTE(params) {
96
- let formatedPhoneNumber;
97
- if (typeof params.telephone === 'string' && params.telephone.length > 0) {
98
- try {
99
- const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
100
- const phoneNumber = phoneUtil.parse(params.telephone);
101
- /* istanbul ignore if */
102
- if (!phoneUtil.isValidNumber(phoneNumber)) {
103
- throw new factory_1.factory.errors.Argument('telephone', 'Invalid phone number');
104
- }
105
- formatedPhoneNumber = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.E164);
106
- }
107
- catch (_error) {
108
- throw new factory_1.factory.errors.Argument('telephone', 'Invalid phone number');
109
- }
110
- }
111
- const userAttributes = [];
112
- if (typeof params.givenName === 'string') {
113
- userAttributes.push({
114
- Name: 'given_name',
115
- Value: params.givenName
116
- });
117
- }
118
- if (typeof params.familyName === 'string') {
119
- userAttributes.push({
120
- Name: 'family_name',
121
- Value: params.familyName
122
- });
123
- }
124
- if (typeof params.email === 'string') {
125
- userAttributes.push({
126
- Name: 'email',
127
- Value: params.email
128
- });
129
- }
130
- if (typeof formatedPhoneNumber === 'string') {
131
- userAttributes.push({
132
- Name: 'phone_number',
133
- Value: formatedPhoneNumber
134
- });
135
- }
136
- if (Array.isArray(params.additionalProperty)) {
137
- userAttributes.push(...params.additionalProperty.map((a) => {
138
- let userAttributesValue = a.value;
139
- // custom:telephoneに関してもtelephoneと同様のバリデーションを追加
140
- if (a.name === 'custom:telephone') {
141
- try {
142
- const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
143
- const phoneNumber = phoneUtil.parse(String(a.value));
144
- /* istanbul ignore if */
145
- if (!phoneUtil.isValidNumber(phoneNumber)) {
146
- throw new factory_1.factory.errors.Argument('custom:telephone', 'Invalid phone number');
147
- }
148
- userAttributesValue = phoneUtil.format(phoneNumber, google_libphonenumber_1.PhoneNumberFormat.E164);
149
- }
150
- catch (_error) {
151
- throw new factory_1.factory.errors.Argument('custome:telephone', 'Invalid phone number');
152
- }
153
- }
154
- return {
155
- Name: a.name,
156
- Value: userAttributesValue
157
- };
158
- }));
159
- }
160
- return userAttributes;
161
- }
93
+ // public static PROFILE2ATTRIBUTE(params: factory.person.IProfile): AttributeType[] {
94
+ // let formatedPhoneNumber: string | undefined;
95
+ // if (typeof params.telephone === 'string' && params.telephone.length > 0) {
96
+ // try {
97
+ // // const phoneUtil = PhoneNumberUtil.getInstance();
98
+ // // const phoneNumber = phoneUtil.parse(params.telephone);
99
+ // // /* istanbul ignore if */
100
+ // // if (!phoneUtil.isValidNumber(phoneNumber)) {
101
+ // // throw new factory.errors.Argument('telephone', 'Invalid phone number');
102
+ // // }
103
+ // // formatedPhoneNumber = phoneUtil.format(phoneNumber, PhoneNumberFormat.E164);
104
+ // const phoneNumber = parsePhoneNumberFromString(params.telephone);
105
+ // if (phoneNumber === undefined || !phoneNumber.isValid()) {
106
+ // throw new factory.errors.Argument('telephone', 'Invalid phone number');
107
+ // }
108
+ // formatedPhoneNumber = phoneNumber.format('E.164');
109
+ // } catch (_error) {
110
+ // throw new factory.errors.Argument('telephone', 'Invalid phone number');
111
+ // }
112
+ // }
113
+ // const userAttributes: AttributeType[] = [];
114
+ // if (typeof params.givenName === 'string') {
115
+ // userAttributes.push({
116
+ // Name: 'given_name',
117
+ // Value: params.givenName
118
+ // });
119
+ // }
120
+ // if (typeof params.familyName === 'string') {
121
+ // userAttributes.push({
122
+ // Name: 'family_name',
123
+ // Value: params.familyName
124
+ // });
125
+ // }
126
+ // if (typeof params.email === 'string') {
127
+ // userAttributes.push({
128
+ // Name: 'email',
129
+ // Value: params.email
130
+ // });
131
+ // }
132
+ // if (typeof formatedPhoneNumber === 'string') {
133
+ // userAttributes.push({
134
+ // Name: 'phone_number',
135
+ // Value: formatedPhoneNumber
136
+ // });
137
+ // }
138
+ // if (Array.isArray(params.additionalProperty)) {
139
+ // userAttributes.push(...params.additionalProperty.map((a) => {
140
+ // let userAttributesValue: string = a.value;
141
+ // // custom:telephoneに関してもtelephoneと同様のバリデーションを追加
142
+ // if (a.name === 'custom:telephone') {
143
+ // try {
144
+ // // const phoneUtil = PhoneNumberUtil.getInstance();
145
+ // // const phoneNumber = phoneUtil.parse(String(a.value));
146
+ // // /* istanbul ignore if */
147
+ // // if (!phoneUtil.isValidNumber(phoneNumber)) {
148
+ // // throw new factory.errors.Argument('custom:telephone', 'Invalid phone number');
149
+ // // }
150
+ // // userAttributesValue = phoneUtil.format(phoneNumber, PhoneNumberFormat.E164);
151
+ // const phoneNumber = parsePhoneNumberFromString(String(a.value));
152
+ // if (phoneNumber === undefined || !phoneNumber.isValid()) {
153
+ // throw new factory.errors.Argument('telephone', 'Invalid phone number');
154
+ // }
155
+ // userAttributesValue = phoneNumber.format('E.164');
156
+ // } catch (_error) {
157
+ // throw new factory.errors.Argument('custome:telephone', 'Invalid phone number');
158
+ // }
159
+ // }
160
+ // return {
161
+ // Name: a.name,
162
+ // Value: userAttributesValue
163
+ // };
164
+ // }));
165
+ // }
166
+ // return userAttributes;
167
+ // }
162
168
  /**
163
169
  * 管理者権限でユーザー属性を取得する
164
170
  */
@@ -177,26 +183,30 @@ class PersonRepo {
177
183
  });
178
184
  });
179
185
  }
180
- /**
181
- * 管理者権限でプロフィール更新
182
- */
183
- async updateProfile(params) {
184
- return new Promise((resolve, reject) => {
185
- const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
186
- this.cognitoIdentityServiceProvider.adminUpdateUserAttributes({
187
- UserPoolId: this.userPoolId,
188
- Username: params.username,
189
- UserAttributes: userAttributes
190
- }, (err) => {
191
- if (err instanceof Error) {
192
- reject(new factory_1.factory.errors.Argument('profile', err.message));
193
- }
194
- else {
195
- resolve();
196
- }
197
- });
198
- });
199
- }
186
+ // /**
187
+ // * 管理者権限でプロフィール更新
188
+ // */
189
+ // public async updateProfile(params: {
190
+ // username: string;
191
+ // profile: factory.person.IProfile;
192
+ // }): Promise<void> {
193
+ // return new Promise<void>((resolve, reject) => {
194
+ // const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
195
+ // this.cognitoIdentityServiceProvider.adminUpdateUserAttributes(
196
+ // {
197
+ // UserPoolId: this.userPoolId,
198
+ // Username: params.username,
199
+ // UserAttributes: userAttributes
200
+ // },
201
+ // (err) => {
202
+ // if (err instanceof Error) {
203
+ // reject(new factory.errors.Argument('profile', err.message));
204
+ // } else {
205
+ // resolve();
206
+ // }
207
+ // });
208
+ // });
209
+ // }
200
210
  /**
201
211
  * 管理者権限でsubでユーザーを検索する
202
212
  */
@@ -249,25 +259,29 @@ class PersonRepo {
249
259
  });
250
260
  });
251
261
  }
252
- /**
253
- * 会員プロフィール更新
254
- */
255
- async updateProfileByAccessToken(params) {
256
- return new Promise((resolve, reject) => {
257
- const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
258
- this.cognitoIdentityServiceProvider.updateUserAttributes({
259
- AccessToken: params.accessToken,
260
- UserAttributes: userAttributes
261
- }, (err) => {
262
- if (err instanceof Error) {
263
- reject(new factory_1.factory.errors.Argument('profile', err.message));
264
- }
265
- else {
266
- resolve();
267
- }
268
- });
269
- });
270
- }
262
+ // /**
263
+ // * 会員プロフィール更新
264
+ // */
265
+ // public async updateProfileByAccessToken(params: {
266
+ // accessToken: string;
267
+ // profile: factory.person.IProfile;
268
+ // }): Promise<void> {
269
+ // return new Promise<void>((resolve, reject) => {
270
+ // const userAttributes = PersonRepo.PROFILE2ATTRIBUTE(params.profile);
271
+ // this.cognitoIdentityServiceProvider.updateUserAttributes(
272
+ // {
273
+ // AccessToken: params.accessToken,
274
+ // UserAttributes: userAttributes
275
+ // },
276
+ // (err) => {
277
+ // if (err instanceof Error) {
278
+ // reject(new factory.errors.Argument('profile', err.message));
279
+ // } else {
280
+ // resolve();
281
+ // }
282
+ // });
283
+ // });
284
+ // }
271
285
  /**
272
286
  * 削除
273
287
  */
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { Connection } from 'mongoose';
1
+ import { Connection, mongo } from 'mongoose';
3
2
  import { factory } from '../../factory';
4
3
  /**
5
4
  * ゲートを操作する組織
@@ -37,12 +36,12 @@ export declare class EntranceGateRepo {
37
36
  addEntranceGatesByIdentifierIfNotExist(params: {
38
37
  $set: ICreatingEntranceGate;
39
38
  }[], options: IUpdateOptions): Promise<{
40
- bulkWriteResult?: BulkWriteResult;
39
+ bulkWriteResult?: mongo.BulkWriteResult;
41
40
  }>;
42
41
  updateEntranceGatesByIdentifier(params: {
43
42
  $set: ICreatingEntranceGate;
44
43
  }[], options: IUpdateOptions): Promise<{
45
- bulkWriteResult?: BulkWriteResult;
44
+ bulkWriteResult?: mongo.BulkWriteResult;
46
45
  }>;
47
46
  deleteEntranceGatesByIdentifier(params: {
48
47
  /**
@@ -50,7 +49,7 @@ export declare class EntranceGateRepo {
50
49
  */
51
50
  identifier: string;
52
51
  }[], options: IUpdateOptions): Promise<{
53
- bulkWriteResult?: BulkWriteResult;
52
+ bulkWriteResult?: mongo.BulkWriteResult;
54
53
  }>;
55
54
  private createMatchStages;
56
55
  }
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection, FilterQuery } from 'mongoose';
1
+ import type { Connection, FilterQuery, mongo } from 'mongoose';
3
2
  import { factory } from '../../factory';
4
3
  import { IDocType } from '../mongoose/schemas/civicStructure';
5
4
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
@@ -49,7 +48,7 @@ export declare class MovieTheaterRepo {
49
48
  [key in keyof IUpsertingMovieTheater]?: 1;
50
49
  };
51
50
  }[], options: IUpsertOptions): Promise<{
52
- bulkWriteResult?: BulkWriteResult;
51
+ bulkWriteResult?: mongo.BulkWriteResult;
53
52
  /**
54
53
  * 追加あるいは編集された施設
55
54
  */
@@ -86,7 +85,7 @@ export declare class MovieTheaterRepo {
86
85
  */
87
86
  id: string;
88
87
  };
89
- }): Promise<import("mongodb").DeleteResult>;
88
+ }): Promise<mongo.DeleteResult>;
90
89
  /**
91
90
  * プロジェクトに属する施設を全削除
92
91
  */
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { Connection, FilterQuery, PipelineStage } from 'mongoose';
1
+ import type { Connection, FilterQuery, PipelineStage, mongo } from 'mongoose';
3
2
  import { factory } from '../../factory';
4
3
  import { IDocType } from '../mongoose/schemas/place';
5
4
  export type IScreeningRoomFoundByBranchCode = Pick<factory.place.screeningRoom.IPlace, 'typeOf' | 'branchCode' | 'name' | 'containsPlace' | 'seatCount' | 'parentOrganization'>;
@@ -66,7 +65,7 @@ export declare class ScreeningRoomRepo {
66
65
  [key in keyof IUpsertingRoom]?: 1;
67
66
  };
68
67
  }[], options: IUpsertOptions): Promise<{
69
- bulkWriteResult?: BulkWriteResult;
68
+ bulkWriteResult?: mongo.BulkWriteResult;
70
69
  }>;
71
70
  deleteRoomByBranchCode(screeningRoom: {
72
71
  /**
@@ -84,7 +83,7 @@ export declare class ScreeningRoomRepo {
84
83
  */
85
84
  id: string;
86
85
  };
87
- }): Promise<import("mongodb").DeleteResult>;
86
+ }): Promise<mongo.DeleteResult>;
88
87
  searchScreeningRooms(searchConditions: factory.place.screeningRoom.ISearchConditions): Promise<Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>[]>;
89
88
  findRooms(params: Omit<factory.place.screeningRoom.ISearchConditions, '$projection'>): Promise<Pick<factory.place.screeningRoom.IPlace, 'additionalProperty' | 'address' | 'branchCode' | 'name' | 'openSeatingAllowed' | 'maximumAttendeeCapacity'>[]>;
90
89
  /**
@@ -116,7 +115,7 @@ export declare class ScreeningRoomRepo {
116
115
  */
117
116
  id: string;
118
117
  };
119
- }): Promise<import("mongodb").DeleteResult>;
118
+ }): Promise<mongo.DeleteResult>;
120
119
  /**
121
120
  * プロジェクトに属するルームを全削除
122
121
  */
@@ -1,5 +1,4 @@
1
- import type { BulkWriteResult } from 'mongodb';
2
- import { AnyExpression, Connection, PipelineStage } from 'mongoose';
1
+ import type { AnyExpression, Connection, PipelineStage, mongo } from 'mongoose';
3
2
  import { factory } from '../../factory';
4
3
  type IMatchStage = PipelineStage.Match;
5
4
  type ICreatingSeat = Pick<factory.place.seat.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'maximumAttendeeCapacity' | 'seatingType'>;
@@ -45,7 +44,7 @@ export declare class SeatRepo {
45
44
  addSeatsByBranchCodeIfNotExist(params: {
46
45
  $set: ICreatingSeat;
47
46
  }[], options: IUpdateOptions): Promise<{
48
- bulkWriteResult?: BulkWriteResult;
47
+ bulkWriteResult?: mongo.BulkWriteResult;
49
48
  }>;
50
49
  /**
51
50
  * コードをキーにして冪等編集
@@ -56,7 +55,7 @@ export declare class SeatRepo {
56
55
  [key in keyof ICreatingSeat]?: 1;
57
56
  };
58
57
  }[], options: IUpdateOptions): Promise<{
59
- bulkWriteResult?: BulkWriteResult;
58
+ bulkWriteResult?: mongo.BulkWriteResult;
60
59
  }>;
61
60
  updateSeatByBranchCode(seat: ICreatingSeat, $unset: any, // eslint-disable-line @typescript-eslint/no-explicit-any
62
61
  options: IUpdateOptions): Promise<IUpdateSeatResult>;
@@ -166,7 +165,7 @@ export declare class SeatRepo {
166
165
  */
167
166
  branchCode: string;
168
167
  }[], options: IUpdateOptions): Promise<{
169
- bulkWriteResult?: BulkWriteResult;
168
+ bulkWriteResult?: mongo.BulkWriteResult;
170
169
  }>;
171
170
  deleteSeatByBranchCode(seat: {
172
171
  /**