@chevre/domain 21.18.0-alpha.2 → 21.18.0-alpha.20

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 (106) hide show
  1. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +24 -0
  2. package/example/src/chevre/searchAcceptedOfferIds.ts +57 -0
  3. package/example/src/chevre/searchOrderAcceptedOffers.ts +12 -12
  4. package/example/src/chevre/searchOrders.ts +36 -19
  5. package/example/src/chevre/searchReservationsByOrder.ts +30 -0
  6. package/example/src/chevre/searchTransactions.ts +41 -0
  7. package/example/src/chevre/transaction/processReturnOrder.ts +1 -0
  8. package/example/src/chevre/upsertMoviesByIdentifier.ts +57 -0
  9. package/example/src/chevre/upsertScreeningEventSeriesByVersion.ts +141 -0
  10. package/example/src/duration.ts +22 -0
  11. package/lib/chevre/repo/acceptedOffer.d.ts +60 -0
  12. package/lib/chevre/repo/acceptedOffer.js +158 -0
  13. package/lib/chevre/repo/creativeWork.d.ts +5 -1
  14. package/lib/chevre/repo/creativeWork.js +42 -22
  15. package/lib/chevre/repo/event.d.ts +12 -0
  16. package/lib/chevre/repo/event.js +61 -0
  17. package/lib/chevre/repo/offerCatalog.d.ts +8 -2
  18. package/lib/chevre/repo/offerCatalog.js +8 -8
  19. package/lib/chevre/repo/order.d.ts +14 -54
  20. package/lib/chevre/repo/order.js +46 -180
  21. package/lib/chevre/repo/place.js +14 -10
  22. package/lib/chevre/repo/transaction.d.ts +5 -4
  23. package/lib/chevre/repository.d.ts +5 -7
  24. package/lib/chevre/repository.js +14 -17
  25. package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +3 -1
  26. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  27. package/lib/chevre/service/assetTransaction/pay.d.ts +2 -0
  28. package/lib/chevre/service/assetTransaction/pay.js +10 -6
  29. package/lib/chevre/service/delivery/factory.d.ts +3 -1
  30. package/lib/chevre/service/delivery/factory.js +4 -2
  31. package/lib/chevre/service/delivery.d.ts +1 -2
  32. package/lib/chevre/service/delivery.js +1 -3
  33. package/lib/chevre/service/offer/product.d.ts +0 -14
  34. package/lib/chevre/service/offer/product.js +59 -42
  35. package/lib/chevre/service/order/confirmPayTransaction.d.ts +2 -0
  36. package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
  37. package/lib/chevre/service/order/createAccountingReportIfNotExist.d.ts +3 -1
  38. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +4 -1
  39. package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
  40. package/lib/chevre/service/order/deleteOrder.js +15 -4
  41. package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +3 -1
  42. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -2
  43. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -3
  44. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +15 -9
  45. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +11 -0
  46. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.js +54 -0
  47. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +10 -0
  48. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.js +38 -0
  49. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +12 -0
  50. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +111 -0
  51. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +12 -0
  52. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +64 -0
  53. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +10 -0
  54. package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +103 -0
  55. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +30 -0
  56. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +227 -0
  57. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +14 -0
  58. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +216 -0
  59. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +10 -0
  60. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +110 -0
  61. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +14 -0
  62. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +164 -0
  63. package/lib/chevre/service/order/onOrderStatusChanged.d.ts +9 -15
  64. package/lib/chevre/service/order/onOrderStatusChanged.js +11 -446
  65. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +6 -0
  66. package/lib/chevre/service/order/onOrderUpdated/factory.js +45 -0
  67. package/lib/chevre/service/order/onOrderUpdated.js +1 -1
  68. package/lib/chevre/service/order/payOrder.d.ts +2 -2
  69. package/lib/chevre/service/order/placeOrder.d.ts +2 -3
  70. package/lib/chevre/service/order/placeOrder.js +65 -22
  71. package/lib/chevre/service/order/returnOrder.d.ts +2 -2
  72. package/lib/chevre/service/order/returnOrder.js +34 -13
  73. package/lib/chevre/service/order/sendOrder.d.ts +2 -2
  74. package/lib/chevre/service/order/sendOrder.js +19 -6
  75. package/lib/chevre/service/order.d.ts +2 -2
  76. package/lib/chevre/service/order.js +2 -2
  77. package/lib/chevre/service/payment/any.js +1 -1
  78. package/lib/chevre/service/reserve/searchByOrder.d.ts +21 -0
  79. package/lib/chevre/service/reserve/searchByOrder.js +113 -0
  80. package/lib/chevre/service/reserve/verifyToken4reservation.js +0 -11
  81. package/lib/chevre/service/reserve.d.ts +2 -1
  82. package/lib/chevre/service/reserve.js +3 -1
  83. package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
  84. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  85. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +5 -6
  86. package/lib/chevre/service/task/onAuthorizationCreated.js +9 -18
  87. package/lib/chevre/service/task/onOrderPaymentCompleted.js +5 -6
  88. package/lib/chevre/service/task/placeOrder.js +10 -17
  89. package/lib/chevre/service/task/returnOrder.js +10 -17
  90. package/lib/chevre/service/task/sendOrder.js +10 -17
  91. package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -7
  92. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  93. package/lib/chevre/service/transaction/moneyTransfer.js +3 -4
  94. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  95. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  96. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +1 -0
  97. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +3 -3
  98. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -0
  99. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
  100. package/lib/chevre/service/transaction/returnOrder.d.ts +3 -0
  101. package/lib/chevre/service/transaction/returnOrder.js +73 -55
  102. package/package.json +2 -2
  103. package/lib/chevre/repo/action/registerServiceInProgress.d.ts +0 -29
  104. package/lib/chevre/repo/action/registerServiceInProgress.js +0 -58
  105. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -42
  106. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +0 -467
@@ -697,7 +697,8 @@ class MongoRepository {
697
697
  projection: {
698
698
  __v: 0,
699
699
  createdAt: 0,
700
- updatedAt: 0
700
+ updatedAt: 0,
701
+ acceptedOffers: 0 // 除外(2023-12-08~)
701
702
  }
702
703
  })
703
704
  .exec();
@@ -707,7 +708,9 @@ class MongoRepository {
707
708
  orderNumber: params.orderNumber,
708
709
  project: { id: params.project.id },
709
710
  inclusion: [],
710
- exclusion: []
711
+ exclusion: [
712
+ 'acceptedOffers' // 除外(2023-12-08~)
713
+ ]
711
714
  });
712
715
  // tslint:disable-next-line:no-single-line-block-comment
713
716
  /* istanbul ignore next */
@@ -741,9 +744,11 @@ class MongoRepository {
741
744
  }, {
742
745
  new: true,
743
746
  projection: {
744
- __v: 0,
745
- createdAt: 0,
746
- updatedAt: 0
747
+ _id: 1, project: 1, typeOf: 1, orderNumber: 1, dateReturned: 1,
748
+ customer: 1, returner: 1, seller: 1, price: 1, priceCurrency: 1, orderDate: 1 // optimize(2023-12-07~)
749
+ // __v: 0,
750
+ // createdAt: 0,
751
+ // updatedAt: 0
747
752
  }
748
753
  })
749
754
  .exec();
@@ -752,8 +757,11 @@ class MongoRepository {
752
757
  const order = yield this.findByOrderNumber({
753
758
  orderNumber: params.orderNumber,
754
759
  project: { id: params.project.id },
755
- inclusion: [],
756
- exclusion: []
760
+ inclusion: [
761
+ 'project', 'typeOf', 'orderNumber', 'dateReturned', 'id',
762
+ 'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
763
+ ],
764
+ exclusion: [] // 除外(2023-12-07~)
757
765
  });
758
766
  // tslint:disable-next-line:no-single-line-block-comment
759
767
  /* istanbul ignore next */
@@ -825,17 +833,20 @@ class MongoRepository {
825
833
  }
826
834
  findById(params) {
827
835
  return __awaiter(this, void 0, void 0, function* () {
828
- let projection = {};
836
+ let projection = { _id: 1 };
829
837
  if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
830
838
  params.inclusion.forEach((field) => {
831
- projection[field] = 1;
839
+ if (String(field) !== 'acceptedOffers') {
840
+ projection[field] = 1;
841
+ }
832
842
  });
833
843
  }
834
844
  else {
835
845
  projection = {
836
846
  __v: 0,
837
847
  createdAt: 0,
838
- updatedAt: 0
848
+ updatedAt: 0,
849
+ acceptedOffers: 0
839
850
  };
840
851
  if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
841
852
  params.exclusion.forEach((field) => {
@@ -859,14 +870,17 @@ class MongoRepository {
859
870
  let projection = {};
860
871
  if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
861
872
  params.inclusion.forEach((field) => {
862
- projection[field] = 1;
873
+ if (String(field) !== 'acceptedOffers') {
874
+ projection[field] = 1;
875
+ }
863
876
  });
864
877
  }
865
878
  else {
866
879
  projection = {
867
880
  __v: 0,
868
881
  createdAt: 0,
869
- updatedAt: 0
882
+ updatedAt: 0,
883
+ acceptedOffers: 0 // defaultで除外(2023-12-08~)
870
884
  };
871
885
  if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
872
886
  params.exclusion.forEach((field) => {
@@ -929,19 +943,30 @@ class MongoRepository {
929
943
  /**
930
944
  * 注文を検索する
931
945
  */
932
- search(params, projection) {
946
+ search(params,
947
+ // 必須化(2023-12-08~)
948
+ projection) {
933
949
  var _a;
934
950
  return __awaiter(this, void 0, void 0, function* () {
935
951
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
936
- const projectionSpecified = projection !== undefined && projection !== null;
937
- const positiveProjectionExists = (projectionSpecified)
938
- ? Object.values(projection)
939
- .some((value) => value !== 0)
940
- : false;
952
+ let projectStage = {};
953
+ const positiveProjectionFields = (projection !== undefined && projection !== null)
954
+ ? Object.keys(projection)
955
+ .filter((key) => projection[key] !== 0
956
+ && key !== 'acceptedOffers' // defaultで隠蔽(2023-12-06~)
957
+ )
958
+ : [];
959
+ if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
960
+ projectStage = {};
961
+ positiveProjectionFields.forEach((field) => {
962
+ projectStage[field] = 1;
963
+ });
964
+ }
965
+ else {
966
+ projectStage = Object.assign({ __v: 0, createdAt: 0, updatedAt: 0, acceptedOffers: 0 }, projection);
967
+ }
941
968
  const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
942
- .select((projectionSpecified && positiveProjectionExists)
943
- ? projection
944
- : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
969
+ .select(projectStage);
945
970
  if (typeof params.limit === 'number' && params.limit > 0) {
946
971
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
947
972
  query.limit(params.limit)
@@ -959,165 +984,6 @@ class MongoRepository {
959
984
  .then((docs) => docs.map((doc) => doc.toObject()));
960
985
  });
961
986
  }
962
- /**
963
- * 注文の受入オファーIDリストを検索する
964
- */
965
- searchAcceptedOfferIds(params) {
966
- return __awaiter(this, void 0, void 0, function* () {
967
- const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
968
- const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
969
- .select({
970
- 'acceptedOffers.id': 1
971
- });
972
- const orders = yield query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
973
- .exec()
974
- .then((docs) => docs.map((doc) => {
975
- return doc.toObject();
976
- }));
977
- const offerIds = orders.reduce((a, b) => {
978
- const offerIdsByOrder = (Array.isArray(b.acceptedOffers))
979
- ? b.acceptedOffers.filter((offer) => typeof offer.id === 'string')
980
- .map((offer) => {
981
- return String(offer.id);
982
- })
983
- : [];
984
- return [...a, ...offerIdsByOrder];
985
- }, []);
986
- return [...new Set(offerIds)];
987
- });
988
- }
989
- /**
990
- * オファー展開の注文検索
991
- */
992
- searchWithUnwoundAcceptedOffers(params, projection) {
993
- var _a;
994
- return __awaiter(this, void 0, void 0, function* () {
995
- const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
996
- const aggregate = this.orderModel.aggregate();
997
- // pipelineの順序に注意
998
- // @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
999
- // tslint:disable-next-line:no-single-line-block-comment
1000
- /* istanbul ignore else */
1001
- if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
1002
- aggregate.sort({ orderDate: params.sort.orderDate });
1003
- }
1004
- aggregate.unwind('$acceptedOffers');
1005
- conditions.forEach((c) => {
1006
- aggregate.match(c);
1007
- });
1008
- aggregate.project(Object.assign(Object.assign({}, projection), { acceptedOffers: ['$acceptedOffers'] }));
1009
- if (typeof params.limit === 'number' && params.limit > 0) {
1010
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1011
- aggregate.limit(params.limit * page)
1012
- .skip(params.limit * (page - 1));
1013
- }
1014
- return aggregate
1015
- // .allowDiskUse(true) // false化(2023-11-30~)
1016
- .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1017
- .exec();
1018
- });
1019
- }
1020
- /**
1021
- * オファーのみ展開して検索する
1022
- */
1023
- searchAcceptedOffers(params, inclusion) {
1024
- var _a;
1025
- return __awaiter(this, void 0, void 0, function* () {
1026
- const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
1027
- const aggregate = this.orderModel.aggregate();
1028
- // pipelineの順序に注意
1029
- // @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
1030
- // tslint:disable-next-line:no-single-line-block-comment
1031
- /* istanbul ignore else */
1032
- if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.orderDate) === 'number') {
1033
- aggregate.sort({ orderDate: params.sort.orderDate });
1034
- }
1035
- aggregate.unwind('$acceptedOffers');
1036
- conditions.forEach((c) => {
1037
- aggregate.match(c);
1038
- });
1039
- if (Array.isArray(inclusion) && inclusion.length > 0) {
1040
- const specifiedProjection = {
1041
- _id: 0
1042
- };
1043
- inclusion.forEach((key) => {
1044
- specifiedProjection[key] = `$acceptedOffers.${key}`;
1045
- });
1046
- aggregate.project(specifiedProjection);
1047
- }
1048
- else {
1049
- aggregate.project({
1050
- _id: 0,
1051
- itemOffered: '$acceptedOffers.itemOffered',
1052
- priceSpecification: '$acceptedOffers.priceSpecification',
1053
- typeOf: '$acceptedOffers.typeOf',
1054
- id: '$acceptedOffers.id',
1055
- offeredThrough: '$acceptedOffers.offeredThrough',
1056
- name: '$acceptedOffers.name'
1057
- });
1058
- }
1059
- if (typeof params.limit === 'number' && params.limit > 0) {
1060
- const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1061
- aggregate.limit(params.limit * page)
1062
- .skip(params.limit * (page - 1));
1063
- }
1064
- return aggregate
1065
- .option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1066
- .exec();
1067
- });
1068
- }
1069
- /**
1070
- * 注文に含まれる予約番号を検索する
1071
- */
1072
- searchReservationNumbersByOrderNumbers(params) {
1073
- return __awaiter(this, void 0, void 0, function* () {
1074
- if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
1075
- return [];
1076
- }
1077
- return this.orderModel.distinct('acceptedOffers.itemOffered.reservationNumber', {
1078
- 'acceptedOffers.itemOffered.reservationNumber': { $exists: true },
1079
- orderNumber: { $in: params.orderNumber.$in }
1080
- })
1081
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1082
- .exec();
1083
- });
1084
- }
1085
- /**
1086
- * 注文に含まれるイベントIDを検索する
1087
- */
1088
- searchReservationForIdsByOrderNumbers(params) {
1089
- return __awaiter(this, void 0, void 0, function* () {
1090
- if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
1091
- return [];
1092
- }
1093
- return this.orderModel.distinct('acceptedOffers.itemOffered.reservationFor.id', {
1094
- 'acceptedOffers.itemOffered.reservationFor.id': { $exists: true },
1095
- orderNumber: { $in: params.orderNumber.$in }
1096
- })
1097
- .setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1098
- .exec();
1099
- });
1100
- }
1101
- /**
1102
- * 注文に含まれるacceptedOffersを検索する
1103
- */
1104
- searchAcceptedOffersByOrderNumbers(params) {
1105
- return __awaiter(this, void 0, void 0, function* () {
1106
- if (!Array.isArray(params.orderNumber.$in) || params.orderNumber.$in.length === 0) {
1107
- return [];
1108
- }
1109
- const aggregate = this.orderModel.aggregate();
1110
- aggregate.unwind('$acceptedOffers');
1111
- aggregate.match({ orderNumber: { $in: params.orderNumber.$in } });
1112
- aggregate.project({
1113
- _id: 0,
1114
- id: '$acceptedOffers.id',
1115
- priceSpecification: '$acceptedOffers.priceSpecification'
1116
- });
1117
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1118
- .exec();
1119
- });
1120
- }
1121
987
  getCursor(conditions, projection) {
1122
988
  return this.orderModel.find(conditions, projection)
1123
989
  .sort({ orderDate: factory.sortType.Descending })
@@ -625,7 +625,7 @@ class MongoRepository {
625
625
  }
626
626
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
627
627
  searchScreeningRoomSections(searchConditions) {
628
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
628
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
629
629
  return __awaiter(this, void 0, void 0, function* () {
630
630
  const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.ScreeningRoom } } }];
631
631
  const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -722,17 +722,21 @@ class MongoRepository {
722
722
  { $unwind: '$containsPlace' },
723
723
  ...matchStages,
724
724
  {
725
- $project: Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', containedInPlace: {
726
- typeOf: '$typeOf',
727
- branchCode: '$branchCode',
728
- name: '$name',
725
+ $project: Object.assign(Object.assign({ _id: 0, typeOf: '$containsPlace.typeOf', branchCode: '$containsPlace.branchCode', name: '$containsPlace.name', additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.containedInPlace) === 1)
726
+ ? {
729
727
  containedInPlace: {
730
- id: '$containedInPlace.id',
731
- typeOf: '$containedInPlace.typeOf',
732
- branchCode: '$containedInPlace.branchCode',
733
- name: '$containedInPlace.name'
728
+ typeOf: '$typeOf',
729
+ branchCode: '$branchCode',
730
+ name: '$name',
731
+ containedInPlace: {
732
+ id: '$containedInPlace.id',
733
+ typeOf: '$containedInPlace.typeOf',
734
+ branchCode: '$containedInPlace.branchCode',
735
+ name: '$containedInPlace.name'
736
+ }
734
737
  }
735
- }, additionalProperty: '$containsPlace.additionalProperty' }, (((_p = searchConditions.$projection) === null || _p === void 0 ? void 0 : _p.seatCount) === 1)
738
+ }
739
+ : undefined), (((_q = searchConditions.$projection) === null || _q === void 0 ? void 0 : _q.seatCount) === 1)
736
740
  ? {
737
741
  seatCount: {
738
742
  $cond: {
@@ -24,6 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
+ type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt';
27
28
  interface IAggregationByStatus {
28
29
  transactionCount: number;
29
30
  avgDuration: number;
@@ -64,8 +65,8 @@ export declare class MongoRepository {
64
65
  findById<T extends factory.transactionType>(params: {
65
66
  typeOf: T;
66
67
  id: string;
67
- inclusion?: string[];
68
- exclusion?: string[];
68
+ inclusion?: IKeyOfProjection<T>[];
69
+ exclusion?: IKeyOfProjection<T>[];
69
70
  }): Promise<factory.transaction.ITransaction<T>>;
70
71
  /**
71
72
  * 進行中の取引を取得する
@@ -187,8 +188,8 @@ export declare class MongoRepository {
187
188
  * 取引を検索する
188
189
  */
189
190
  search<T extends factory.transactionType>(params: factory.transaction.ISearchConditions<T> & {
190
- inclusion: string[];
191
- exclusion: string[];
191
+ inclusion: IKeyOfProjection<T>[];
192
+ exclusion: IKeyOfProjection<T>[];
192
193
  }): Promise<factory.transaction.ITransaction<T>[]>;
193
194
  /**
194
195
  * 特定の取引を更新する(汎用)
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * リポジトリ
3
3
  */
4
+ import type { MongoRepository as AcceptedOfferRepo } from './repo/acceptedOffer';
4
5
  import type { MongoRepository as AccountRepo } from './repo/account';
5
6
  import type { MongoRepository as AccountingReportRepo } from './repo/accountingReport';
6
7
  import type { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
@@ -46,11 +47,14 @@ import type { MongoRepository as TelemetryRepo } from './repo/telemetry';
46
47
  import type { MongoRepository as TransactionRepo } from './repo/transaction';
47
48
  import type { RedisRepository as TransactionNumberRepo } from './repo/transactionNumber';
48
49
  import type { MongoRepository as TripRepo } from './repo/trip';
49
- import type { RedisRepository as RegisterServiceActionInProgress } from './repo/action/registerServiceInProgress';
50
50
  import type { RedisRepository as ConfirmationNumberRepo } from './repo/confirmationNumber';
51
51
  import type { RedisRepository as OrderNumberRepo } from './repo/orderNumber';
52
52
  import type { GMORepository as CreditCardRepo } from './repo/paymentMethod/creditCard';
53
53
  import type { CognitoRepository as PersonRepo } from './repo/person';
54
+ export type AcceptedOffer = AcceptedOfferRepo;
55
+ export declare namespace AcceptedOffer {
56
+ function createInstance(...params: ConstructorParameters<typeof AcceptedOfferRepo>): Promise<AcceptedOfferRepo>;
57
+ }
54
58
  export type Account = AccountRepo;
55
59
  export declare namespace Account {
56
60
  function createInstance(...params: ConstructorParameters<typeof AccountRepo>): Promise<AccountRepo>;
@@ -83,12 +87,6 @@ export type Aggregation = AggregationRepo;
83
87
  export declare namespace Aggregation {
84
88
  function createInstance(...params: ConstructorParameters<typeof AggregationRepo>): Promise<AggregationRepo>;
85
89
  }
86
- export declare namespace action {
87
- type RegisterServiceInProgress = RegisterServiceActionInProgress;
88
- namespace RegisterServiceInProgress {
89
- function createInstance(...params: ConstructorParameters<typeof RegisterServiceActionInProgress>): Promise<RegisterServiceActionInProgress>;
90
- }
91
- }
92
90
  export type AssetTransaction = AssetTransactionRepo;
93
91
  export declare namespace AssetTransaction {
94
92
  function createInstance(...params: ConstructorParameters<typeof AssetTransactionRepo>): Promise<AssetTransactionRepo>;
@@ -9,7 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
12
+ exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.place = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
+ var AcceptedOffer;
14
+ (function (AcceptedOffer) {
15
+ let repo;
16
+ function createInstance(...params) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ if (repo === undefined) {
19
+ repo = (yield Promise.resolve().then(() => require('./repo/acceptedOffer'))).MongoRepository;
20
+ }
21
+ return new repo(...params);
22
+ });
23
+ }
24
+ AcceptedOffer.createInstance = createInstance;
25
+ })(AcceptedOffer = exports.AcceptedOffer || (exports.AcceptedOffer = {}));
13
26
  var Account;
14
27
  (function (Account) {
15
28
  let repo;
@@ -114,22 +127,6 @@ var Aggregation;
114
127
  }
115
128
  Aggregation.createInstance = createInstance;
116
129
  })(Aggregation = exports.Aggregation || (exports.Aggregation = {}));
117
- var action;
118
- (function (action) {
119
- let RegisterServiceInProgress;
120
- (function (RegisterServiceInProgress) {
121
- let repo;
122
- function createInstance(...params) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- if (repo === undefined) {
125
- repo = (yield Promise.resolve().then(() => require('./repo/action/registerServiceInProgress'))).RedisRepository;
126
- }
127
- return new repo(...params);
128
- });
129
- }
130
- RegisterServiceInProgress.createInstance = createInstance;
131
- })(RegisterServiceInProgress = action.RegisterServiceInProgress || (action.RegisterServiceInProgress = {}));
132
- })(action = exports.action || (exports.action = {}));
133
130
  var AssetTransaction;
134
131
  (function (AssetTransaction) {
135
132
  let repo;
@@ -6,5 +6,7 @@ export type IUnitPriceSpecification = factory.unitPriceOffer.IUnitPriceOfferPric
6
6
  export declare function createPotentialActions(params: {
7
7
  transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Pay>;
8
8
  potentialActions?: factory.assetTransaction.pay.IPotentialActionsParams;
9
- order: factory.order.IOrder;
9
+ order: Pick<factory.order.IOrder, 'typeOf' | 'confirmationNumber' | 'orderNumber'> & {
10
+ acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
11
+ };
10
12
  }): factory.assetTransaction.IPotentialActions<factory.assetTransactionType.Pay>;
@@ -214,12 +214,12 @@ function reservationPriceComponent2invoicePriceComponent(component) {
214
214
  }
215
215
  }
216
216
  function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType) {
217
- var _a, _b;
217
+ var _a;
218
218
  let ticketToken;
219
219
  let reservationNumber = '';
220
220
  let priceComponents4invoice = [];
221
221
  // Orderから対象予約を取得
222
- const reservationOffer = (_a = order === null || order === void 0 ? void 0 : order.acceptedOffers) === null || _a === void 0 ? void 0 : _a.find((o) => {
222
+ const reservationOffer = order.acceptedOffers.find((o) => {
223
223
  var _a, _b, _c, _d;
224
224
  let mvtkUnitPriceSpec;
225
225
  // MovieTicket適用単価オファーからidentifierを取り出す
@@ -259,7 +259,7 @@ function movieTicket2reservation4invoice(movieTicket, order, paymentMethodType)
259
259
  ticketToken = ticketTokenByReservationOffer;
260
260
  }
261
261
  reservationNumber = reservationOffer.itemOffered.reservationNumber;
262
- const priceComponent = (_b = reservationOffer.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceComponent;
262
+ const priceComponent = (_a = reservationOffer.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent;
263
263
  if (Array.isArray(priceComponent)) {
264
264
  priceComponents4invoice = priceComponent.map(reservationPriceComponent2invoicePriceComponent);
265
265
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as GMO from '@motionpicture/gmo-service';
5
5
  import * as factory from '../../factory';
6
+ import type { MongoRepository as AcceptedOfferRepo } from '../../repo/acceptedOffer';
6
7
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
7
8
  import type { MongoRepository as ActionRepo } from '../../repo/action';
8
9
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
@@ -38,6 +39,7 @@ export interface ICancelRepos {
38
39
  }
39
40
  export type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
40
41
  export interface IConfirmRepos {
42
+ acceptedOffer: AcceptedOfferRepo;
41
43
  action: ActionRepo;
42
44
  accountingReport: AccountingReportRepo;
43
45
  assetTransaction: AssetTransactionRepo;
@@ -365,25 +365,29 @@ exports.confirm = confirm;
365
365
  function fixOrderAsPurpose(params, transaction) {
366
366
  return (repos) => __awaiter(this, void 0, void 0, function* () {
367
367
  var _a, _b, _c, _d, _e, _f;
368
- let order;
369
368
  const payPurposeConfirmationNumber = (_c = (_b = (_a = params.potentialActions) === null || _a === void 0 ? void 0 : _a.pay) === null || _b === void 0 ? void 0 : _b.purpose) === null || _c === void 0 ? void 0 : _c.confirmationNumber;
370
369
  const payPurposeOrderNumber = (_f = (_e = (_d = params.potentialActions) === null || _d === void 0 ? void 0 : _d.pay) === null || _e === void 0 ? void 0 : _e.purpose) === null || _f === void 0 ? void 0 : _f.orderNumber;
371
370
  if (typeof payPurposeConfirmationNumber !== 'string' || payPurposeConfirmationNumber.length === 0
372
371
  || typeof payPurposeOrderNumber !== 'string' || payPurposeOrderNumber.length === 0) {
373
372
  throw new factory.errors.ArgumentNull('potentialActions.pay.purpose');
374
373
  }
375
- const orders = yield repos.order.search({
374
+ const ordersWithoutAcceptedOffers = yield repos.order.search({
376
375
  limit: 1,
377
376
  page: 1,
378
377
  project: { id: { $eq: transaction.project.id } },
379
378
  confirmationNumbers: [payPurposeConfirmationNumber],
380
379
  orderNumbers: [payPurposeOrderNumber]
381
- });
382
- order = orders.shift();
383
- if (order === undefined) {
380
+ }, { typeOf: 1, confirmationNumber: 1, orderNumber: 1 });
381
+ const orderWithoutAcceptedOffers = ordersWithoutAcceptedOffers.shift();
382
+ if (orderWithoutAcceptedOffers === undefined) {
384
383
  throw new factory.errors.NotFound('Order as purpose');
385
384
  }
386
- return order;
385
+ // 全acceptedOffersを検索(2023-12-06~)
386
+ const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
387
+ orderNumber: { $eq: orderWithoutAcceptedOffers.orderNumber },
388
+ project: { id: { $eq: transaction.project.id } }
389
+ });
390
+ return Object.assign(Object.assign({}, orderWithoutAcceptedOffers), { acceptedOffers });
387
391
  });
388
392
  }
389
393
  /**
@@ -4,5 +4,7 @@ export type IOwnershipInfo = factory.ownershipInfo.IOwnershipInfo<factory.owners
4
4
  * 注文から所有権を作成する
5
5
  */
6
6
  export declare function createOwnershipInfosFromOrder(params: {
7
- order: Pick<factory.order.IOrder, 'acceptedOffers' | 'orderDate' | 'project' | 'customer' | 'orderNumber' | 'seller'>;
7
+ order: Pick<factory.order.IOrder, 'orderDate' | 'project' | 'customer' | 'orderNumber' | 'seller'> & {
8
+ acceptedOffers: factory.order.IAcceptedOffer<factory.order.IItemOffered>[];
9
+ };
8
10
  }): IOwnershipInfo[];
@@ -11,8 +11,10 @@ const factory_2 = require("./reservation/factory");
11
11
  */
12
12
  function createOwnershipInfosFromOrder(params) {
13
13
  const ownershipInfos = [];
14
- const acceptedOffers = (Array.isArray(params.order.acceptedOffers)) ? params.order.acceptedOffers : [];
15
- acceptedOffers.forEach((acceptedOffer, offerIndex) => {
14
+ if (!Array.isArray(params.order.acceptedOffers)) {
15
+ throw new factory.errors.ArgumentNull('order.acceptedOffers');
16
+ }
17
+ params.order.acceptedOffers.forEach((acceptedOffer, offerIndex) => {
16
18
  const itemOffered = acceptedOffer.itemOffered;
17
19
  let ownershipInfo;
18
20
  const ownedFrom = moment(params.order.orderDate)
@@ -4,7 +4,6 @@ import type { MongoRepository as AssetRepo } from '../repo/assetTransaction';
4
4
  import type { MongoRepository as ProductRepo } from '../repo/product';
5
5
  import type { MongoRepository as ProjectRepo } from '../repo/project';
6
6
  import type { RedisRepository as TransactionNumberRepo } from '../repo/transactionNumber';
7
- import { createOwnershipInfosFromOrder } from './delivery/factory';
8
7
  /**
9
8
  * 特典付与
10
9
  */
@@ -25,4 +24,4 @@ declare function returnPointAward(params: factory.task.IData<factory.taskName.Re
25
24
  project: ProjectRepo;
26
25
  transactionNumber: TransactionNumberRepo;
27
26
  }) => Promise<void>;
28
- export { createOwnershipInfosFromOrder, givePointAward, returnPointAward };
27
+ export { givePointAward, returnPointAward };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.returnPointAward = exports.givePointAward = exports.createOwnershipInfosFromOrder = void 0;
12
+ exports.returnPointAward = exports.givePointAward = void 0;
13
13
  /**
14
14
  * 配送サービス
15
15
  * ここでいう「配送」とは、「エンドユーザーが獲得した所有権を利用可能な状態にすること」を指します。
@@ -21,8 +21,6 @@ exports.returnPointAward = exports.givePointAward = exports.createOwnershipInfos
21
21
  const moment = require("moment");
22
22
  const factory = require("../factory");
23
23
  const MoneyTransferAssetTransactionService = require("./assetTransaction/moneyTransfer");
24
- const factory_1 = require("./delivery/factory");
25
- Object.defineProperty(exports, "createOwnershipInfosFromOrder", { enumerable: true, get: function () { return factory_1.createOwnershipInfosFromOrder; } });
26
24
  const accountTransactionIdentifier_1 = require("../factory/accountTransactionIdentifier");
27
25
  /**
28
26
  * 特典付与
@@ -1,7 +1,6 @@
1
1
  import * as factory from '../../factory';
2
2
  import type { MongoRepository as AccountRepo } from '../../repo/account';
3
3
  import type { MongoRepository as ActionRepo } from '../../repo/action';
4
- import type { RedisRepository as RegisterServiceInProgressRepo } from '../../repo/action/registerServiceInProgress';
5
4
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
6
5
  import type { MongoRepository as OfferRepo } from '../../repo/offer';
7
6
  import type { MongoRepository as OfferCatalogRepo } from '../../repo/offerCatalog';
@@ -23,7 +22,6 @@ export interface IAuthorizeOperationRepos {
23
22
  ownershipInfo: OwnershipInfoRepo;
24
23
  product: ProductRepo;
25
24
  project: ProjectRepo;
26
- registerActionInProgress: RegisterServiceInProgressRepo;
27
25
  serviceOutput: ServiceOutputRepo;
28
26
  serviceOutputIdentifier: ServiceOutputIdentifierRepo;
29
27
  transaction: TransactionRepo;
@@ -94,17 +92,5 @@ export declare function authorize(params: {
94
92
  export declare function voidTransaction(params: factory.task.IData<factory.taskName.VoidRegisterServiceTransaction>): (repos: {
95
93
  action: ActionRepo;
96
94
  assetTransaction: AssetTransactionRepo;
97
- registerActionInProgress: RegisterServiceInProgressRepo;
98
95
  transaction: TransactionRepo;
99
96
  }) => Promise<void>;
100
- export declare function processUnlockRegisterMembershipService(params: {
101
- agent: {
102
- id: string;
103
- };
104
- product: {
105
- id: string;
106
- };
107
- purpose: factory.action.authorize.offer.product.IPurpose;
108
- }): (repos: {
109
- registerActionInProgress: RegisterServiceInProgressRepo;
110
- }) => Promise<void>;