@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.60

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 (129) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +23 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateAggregateOffers.ts +89 -0
  5. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  7. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  12. package/example/src/chevre/searchEventTicketOffers.ts +3 -1
  13. package/example/src/chevre/searchEvents.ts +9 -7
  14. package/example/src/chevre/searchOffersByCatalog.ts +9 -5
  15. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  16. package/example/src/chevre/searchOrders.ts +9 -7
  17. package/example/src/chevre/sync2aggregateOffer.ts +27 -0
  18. package/example/src/chevre/syncAggregateOffer.ts +25 -0
  19. package/lib/chevre/emailMessageBuilder.js +6 -5
  20. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  21. package/lib/chevre/repo/aggregateOffer.js +534 -0
  22. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  23. package/lib/chevre/repo/assetTransaction.js +54 -2
  24. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  25. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +177 -0
  26. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  27. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  28. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  29. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +24 -33
  30. package/lib/chevre/repo/mongoose/schemas/offer.js +4 -3
  31. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  32. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  33. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  34. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  35. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  36. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  37. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  38. package/lib/chevre/repo/offer.d.ts +82 -47
  39. package/lib/chevre/repo/offer.js +1279 -289
  40. package/lib/chevre/repo/offerCatalog.d.ts +6 -0
  41. package/lib/chevre/repo/offerCatalog.js +13 -0
  42. package/lib/chevre/repo/order.d.ts +15 -0
  43. package/lib/chevre/repo/order.js +58 -26
  44. package/lib/chevre/repo/task.d.ts +7 -1
  45. package/lib/chevre/repo/task.js +100 -0
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
  49. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
  50. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  51. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  52. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  53. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  54. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  55. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  56. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  57. package/lib/chevre/service/delivery.js +17 -0
  58. package/lib/chevre/service/offer/event/authorize.js +39 -35
  59. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  60. package/lib/chevre/service/offer/event/factory.js +8 -8
  61. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
  63. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -3
  64. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  65. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  66. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  67. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  68. package/lib/chevre/service/offer/factory.d.ts +12 -4
  69. package/lib/chevre/service/offer/factory.js +9 -11
  70. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +8 -1
  71. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -3
  72. package/lib/chevre/service/offer/product.d.ts +1 -0
  73. package/lib/chevre/service/offer/product.js +3 -2
  74. package/lib/chevre/service/offer.d.ts +1 -0
  75. package/lib/chevre/service/offer.js +7 -1
  76. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  77. package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  81. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  82. package/lib/chevre/service/order/onOrderStatusChanged.js +81 -54
  83. package/lib/chevre/service/order/payOrder.d.ts +2 -10
  84. package/lib/chevre/service/order/payOrder.js +4 -45
  85. package/lib/chevre/service/order/placeOrder.js +11 -13
  86. package/lib/chevre/service/order.d.ts +3 -1
  87. package/lib/chevre/service/order.js +6 -2
  88. package/lib/chevre/service/payment/any/factory.js +33 -8
  89. package/lib/chevre/service/payment/any.js +30 -21
  90. package/lib/chevre/service/payment/creditCard.js +12 -12
  91. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  92. package/lib/chevre/service/payment/movieTicket.js +10 -11
  93. package/lib/chevre/service/payment/paymentCard.js +9 -12
  94. package/lib/chevre/service/project.js +1 -1
  95. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  96. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  99. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  100. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  101. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  102. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  103. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  104. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  105. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  106. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  107. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  108. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  109. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
  110. package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
  111. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  113. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  114. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
  115. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  116. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  117. package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
  118. package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
  119. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  120. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  122. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  123. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  124. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  125. package/lib/chevre/settings.d.ts +5 -3
  126. package/lib/chevre/settings.js +6 -6
  127. package/package.json +3 -3
  128. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  129. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
@@ -13,6 +13,7 @@ exports.call = void 0;
13
13
  const factory = require("../../factory");
14
14
  const accountTitle_1 = require("../../repo/accountTitle");
15
15
  const action_1 = require("../../repo/action");
16
+ const aggregateOffer_1 = require("../../repo/aggregateOffer");
16
17
  const categoryCode_1 = require("../../repo/categoryCode");
17
18
  const creativeWork_1 = require("../../repo/creativeWork");
18
19
  const event_1 = require("../../repo/event");
@@ -25,6 +26,7 @@ const product_1 = require("../../repo/product");
25
26
  const productOffer_1 = require("../../repo/productOffer");
26
27
  const task_1 = require("../../repo/task");
27
28
  const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
29
+ const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
28
30
  const settings_1 = require("../../settings");
29
31
  const informResources = settings_1.settings.onResourceUpdated.informResource;
30
32
  /**
@@ -35,6 +37,7 @@ function call(data) {
35
37
  yield onResourceUpdated(data)({
36
38
  accountTitle: new accountTitle_1.MongoRepository(connectionSettings.connection),
37
39
  action: new action_1.MongoRepository(connectionSettings.connection),
40
+ aggregateOffer: new aggregateOffer_1.MongoRepository(connectionSettings.connection),
38
41
  categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
39
42
  creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
40
43
  event: new event_1.MongoRepository(connectionSettings.connection),
@@ -107,6 +110,15 @@ function onResourceUpdated(params) {
107
110
  typeOf: params.typeOf
108
111
  })(repos);
109
112
  break;
113
+ // カタログに対応(2023-09-12~)
114
+ case 'OfferCatalog':
115
+ yield (0, syncOfferCatalog_1.syncOfferCatalog)({
116
+ project: { id: params.project.id },
117
+ ids: params.id,
118
+ typeOf: params.typeOf,
119
+ isDeleted: false
120
+ })(repos);
121
+ break;
110
122
  default:
111
123
  // no op
112
124
  }
@@ -159,7 +159,11 @@ function transaction2refundFee(params) {
159
159
  return refundFee;
160
160
  }
161
161
  function createStartRefundTransactionParams(params) {
162
- var _a;
162
+ var _a, _b;
163
+ const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
164
+ if (typeof paymentMethodType !== 'string') {
165
+ throw new factory.errors.NotFound('object.paymentMethod.identifier');
166
+ }
163
167
  return {
164
168
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
165
169
  typeOf: factory.assetTransactionType.Refund,
@@ -173,11 +177,12 @@ function createStartRefundTransactionParams(params) {
173
177
  recipient: { typeOf: params.recipient.typeOf, name: params.recipient.name },
174
178
  object: {
175
179
  typeOf: params.paymentServiceType,
176
- id: (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? params.object.issuedThrough.id : '',
180
+ id: (typeof ((_b = params.object.issuedThrough) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? params.object.issuedThrough.id : '',
177
181
  paymentMethod: {
178
182
  additionalProperty: params.object.additionalProperty,
179
183
  name: params.object.name,
180
- typeOf: params.object.typeOf,
184
+ // typeOf: params.object.typeOf,
185
+ typeOf: paymentMethodType,
181
186
  paymentMethodId: params.object.paymentMethodId
182
187
  },
183
188
  refundFee: params.refundFee
@@ -0,0 +1,7 @@
1
+ import * as factory from '../../factory';
2
+ import { IConnectionSettings } from '../task';
3
+ export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
4
+ /**
5
+ * タスク実行関数
6
+ */
7
+ export declare function call(data: factory.task.syncAggregateOffer.IData): IOperation<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.call = void 0;
13
+ const offer_1 = require("../../repo/offer");
14
+ /**
15
+ * タスク実行関数
16
+ */
17
+ function call(data) {
18
+ return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
19
+ const offerRepo = new offer_1.MongoRepository(connectionSettings.connection);
20
+ yield offerRepo.sync2aggregateOffer(data);
21
+ });
22
+ }
23
+ exports.call = call;
@@ -65,35 +65,51 @@ function createPaymentMethods(params) {
65
65
  const authorizePaymentActions = params.authorizeActions
66
66
  .filter((a) => {
67
67
  var _a;
68
+ const resultAsInvoice = (Array.isArray(a.result))
69
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
70
+ : a.result;
68
71
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
69
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
72
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
70
73
  });
71
74
  // 決済方法をセット
72
75
  authorizePaymentActions.forEach((a) => {
73
- var _a, _b, _c;
74
- const result = a.result;
75
- const paymentMethodAmountCurrencyByAuthorizeAction = (_b = (_a = result.paymentMethodAsObject) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency;
76
- const paymentMethodOfInvoice = (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
77
- { amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
78
- : undefined;
76
+ var _a, _b, _c, _d;
77
+ // const result = (<factory.action.authorize.paymentMethod.any.IResult>a.result);
78
+ const resultAsInvoice = (Array.isArray(a.result))
79
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
80
+ : a.result;
81
+ const paymentMethodAmountCurrencyByAuthorizeAction = (_c = (_b = resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.amount) === null || _c === void 0 ? void 0 : _c.currency;
79
82
  // 決済方法区分は必ず存在するはず(2023-08-15~)
80
- const paymentMethodType = (_c = result.paymentMethodAsObject) === null || _c === void 0 ? void 0 : _c.typeOf;
83
+ const paymentMethodType = (_d = resultAsInvoice.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf;
81
84
  if (typeof paymentMethodType !== 'string') {
82
85
  throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
83
86
  }
84
- paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, paymentStatus: result.paymentStatus, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
87
+ const paymentMethodOfInvoice = Object.assign({ identifier: paymentMethodType }, (typeof paymentMethodAmountCurrencyByAuthorizeAction === 'string') ?
88
+ { amount: { currency: paymentMethodAmountCurrencyByAuthorizeAction } }
89
+ : undefined);
90
+ paymentMethods.push({
91
+ accountId: resultAsInvoice.accountId,
92
+ additionalProperty: (Array.isArray(resultAsInvoice.additionalProperty)) ? resultAsInvoice.additionalProperty : [],
93
+ issuedThrough: resultAsInvoice.issuedThrough,
94
+ name: resultAsInvoice.name,
95
+ paymentMethodId: resultAsInvoice.paymentMethodId,
96
+ paymentStatus: resultAsInvoice.paymentStatus,
97
+ totalPaymentDue: resultAsInvoice.totalPaymentDue,
98
+ typeOf: paymentMethodType,
99
+ // CreditCardIFのカード通貨区分を追加(2023-08-15~)
100
+ // 決済方法区分を保証(2023-08-28~)
101
+ paymentMethod: paymentMethodOfInvoice
102
+ });
85
103
  });
86
104
  // 決済方法から注文金額の計算
87
- // price += authorizePaymentActions
88
- // .filter((a) => {
89
- // return a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY;
90
- // })
91
- // .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
92
105
  price += authorizePaymentActions
93
106
  .reduce((a, b) => {
94
107
  var _a, _b;
95
- const jpyAmount = (((_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
96
- ? b.result.totalPaymentDue.value
108
+ const resultAsInvoice = (Array.isArray(b.result))
109
+ ? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
110
+ : b.result;
111
+ const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
112
+ ? resultAsInvoice.totalPaymentDue.value
97
113
  : 0;
98
114
  return a + jpyAmount;
99
115
  }, 0);
@@ -12,15 +12,17 @@ const debug = createDebug('cinerino-domain:service:validateMovieTicket');
12
12
  */
13
13
  function validateMovieTicket(paymentMethodType, transaction, authorizeActions) {
14
14
  const authorizeMovieTicketActions = authorizeActions.filter((a) => {
15
- var _a, _b, _c, _d;
15
+ var _a, _b;
16
+ const resultAsInvoice = (Array.isArray(a.result))
17
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
18
+ : a.result;
16
19
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
17
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
18
- && ((_b = a.result) === null || _b === void 0 ? void 0 : _b.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
20
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
21
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket
19
22
  // 決済方法区分は必ず存在するはず(2023-08-15~)
20
- && ((_d = (_c = a.result) === null || _c === void 0 ? void 0 : _c.paymentMethodAsObject) === null || _d === void 0 ? void 0 : _d.typeOf) === paymentMethodType;
21
- }
22
- // && a.result?.paymentMethod === paymentMethodType
23
- );
23
+ && ((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf) === paymentMethodType;
24
+ // && a.result?.paymentMethod === paymentMethodType
25
+ });
24
26
  const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
25
27
  && a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
26
28
  // 予約によって必要とされるMovieTicket
@@ -149,10 +151,10 @@ function authorizeSeatReservationActions2requiredMovieTickets(params) {
149
151
  appliesToMovieTickets4paymentMethod = appliesToMovieTickets4reservation.filter((a) => {
150
152
  return a.serviceOutput.typeOf === paymentMethodType;
151
153
  });
152
- }
153
- else if (typeof (appliesToMovieTickets4reservation === null || appliesToMovieTickets4reservation === void 0 ? void 0 : appliesToMovieTickets4reservation.identifier) === 'string') {
154
- // Arrayでない場合を廃止(2022-08-01~)
155
- throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
154
+ // Array以外への考慮自体を廃止(2023-09-01~)
155
+ // } else if (typeof appliesToMovieTickets4reservation?.identifier === 'string') {
156
+ // // Arrayでない場合を廃止(2022-08-01~)
157
+ // throw new factory.errors.NotImplemented('appliesToMovieTickets.typeOf as string not implemented');
156
158
  }
157
159
  if (Array.isArray(appliesToMovieTickets4paymentMethod) && appliesToMovieTickets4paymentMethod.length > 0) {
158
160
  appliesToMovieTickets4paymentMethod.forEach((appliesToMovieTicket) => {
@@ -40,10 +40,13 @@ function validateTransaction(transaction, authorizeActions) {
40
40
  exports.validateTransaction = validateTransaction;
41
41
  function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
42
42
  const authorizeMovieTicketPaymentActions = authorizeActions.filter((a) => {
43
- var _a, _b;
43
+ var _a;
44
+ const resultAsInvoice = (Array.isArray(a.result))
45
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
46
+ : a.result;
44
47
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
45
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
46
- && ((_b = a.result) === null || _b === void 0 ? void 0 : _b.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket;
48
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
49
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.issuedThrough.typeOf) === factory.service.paymentService.PaymentServiceType.MovieTicket;
47
50
  });
48
51
  const seatReservationAuthorizeActions = authorizeActions.filter((a) => a.actionStatus === factory.actionStatusType.CompletedActionStatus
49
52
  && a.object.typeOf === factory.action.authorize.offer.seatReservation.ObjectType.SeatReservation);
@@ -67,7 +70,13 @@ function findMovieTicketPaymentMethodTypesFromTransaction(authorizeActions) {
67
70
  });
68
71
  const paymentMethodTypes = [
69
72
  // 決済方法区分は必ず存在するはず(2023-08-15~)
70
- ...authorizeMovieTicketPaymentActions.map((a) => { var _a, _b; return String((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf); }),
73
+ ...authorizeMovieTicketPaymentActions.map((a) => {
74
+ var _a, _b;
75
+ const resultAsInvoice = (Array.isArray(a.result))
76
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
77
+ : a.result;
78
+ return String((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodAsObject) === null || _b === void 0 ? void 0 : _b.typeOf);
79
+ }),
71
80
  // ...authorizeMovieTicketPaymentActions.map((a) => String(a.result?.paymentMethod)),
72
81
  ...requiredMovieTicketPaymentMethodTypes
73
82
  ];
@@ -90,17 +99,20 @@ function validatePrice(transaction, authorizeActions) {
90
99
  const authorizePaymentActions = authorizeActions
91
100
  .filter((a) => {
92
101
  var _a;
102
+ const resultAsInvoice = (Array.isArray(a.result))
103
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
104
+ : a.result;
93
105
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
94
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
106
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
95
107
  });
96
- // priceByAgent += authorizePaymentActions
97
- // .filter((a) => a.result?.totalPaymentDue?.currency === factory.priceCurrency.JPY)
98
- // .reduce((a, b) => a + (<IAuthorizeAnyPaymentResult>b.result).amount, 0);
99
108
  priceByAgent += authorizePaymentActions
100
109
  .reduce((a, b) => {
101
110
  var _a, _b;
102
- const jpyAmount = (((_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
103
- ? b.result.totalPaymentDue.value
111
+ const resultAsInvoice = (Array.isArray(b.result))
112
+ ? (_a = b.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
113
+ : b.result;
114
+ const jpyAmount = (((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === factory.priceCurrency.JPY)
115
+ ? resultAsInvoice.totalPaymentDue.value
104
116
  : 0;
105
117
  return a + jpyAmount;
106
118
  }, 0);
@@ -125,11 +137,20 @@ function validatePaymentUrl(transaction, authorizeActions) {
125
137
  const authorizePaymentActions = authorizeActions
126
138
  .filter((a) => {
127
139
  var _a;
140
+ const resultAsInvoice = (Array.isArray(a.result))
141
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
142
+ : a.result;
128
143
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
129
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
144
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment;
130
145
  });
131
146
  // 決済承認を確認
132
- const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some((a) => { var _a; return ((_a = a.result) === null || _a === void 0 ? void 0 : _a.paymentMethodId) === paymentMethodId; });
147
+ const authorizePaymentAction4paymentUrlExists = authorizePaymentActions.some((a) => {
148
+ var _a;
149
+ const resultAsInvoice = (Array.isArray(a.result))
150
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
151
+ : a.result;
152
+ return (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.paymentMethodId) === paymentMethodId;
153
+ });
133
154
  if (!authorizePaymentAction4paymentUrlExists) {
134
155
  throw new factory.errors.Argument('Transaction', 'Payment for published payment URL required');
135
156
  }
@@ -142,11 +163,14 @@ function validateMonetaryAmount(authorizeActions) {
142
163
  const authorizeMonetaryAmountActions = authorizeActions
143
164
  .filter((a) => {
144
165
  var _a, _b;
166
+ const resultAsInvoice = (Array.isArray(a.result))
167
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
168
+ : a.result;
145
169
  return a.actionStatus === factory.actionStatusType.CompletedActionStatus
146
- && ((_a = a.result) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
170
+ && (resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.typeOf) === factory.action.authorize.paymentMethod.any.ResultType.Payment
147
171
  // JPY以外の通貨に対して承認可能なのはPaymentServiceType.PaymentCardのみ
148
- && a.result.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard
149
- && ((_b = a.result.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) !== factory.priceCurrency.JPY;
172
+ && resultAsInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.PaymentCard
173
+ && ((_b = resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) !== factory.priceCurrency.JPY;
150
174
  });
151
175
  const requiredMonetaryAmountByCurrencyType = [];
152
176
  authorizeActions
@@ -163,7 +187,13 @@ function validateMonetaryAmount(authorizeActions) {
163
187
  }
164
188
  }, 0);
165
189
  const requiredCurrencyTypes = [...new Set(requiredMonetaryAmountByCurrencyType.map((m) => m.currency))];
166
- const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map((m) => { var _a, _b; return (_b = (_a = m.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency; }))];
190
+ const authorizedCurrencyTypes = [...new Set(authorizeMonetaryAmountActions.map((a) => {
191
+ var _a, _b;
192
+ const resultAsInvoice = (Array.isArray(a.result))
193
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
194
+ : a.result;
195
+ return (_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency;
196
+ }))];
167
197
  if (requiredCurrencyTypes.length !== authorizedCurrencyTypes.length) {
168
198
  throw new factory.errors.Argument('Transaction', 'MonetaryAmount account types not matched');
169
199
  }
@@ -172,7 +202,13 @@ function validateMonetaryAmount(authorizeActions) {
172
202
  .filter((m) => m.currency === currencyType)
173
203
  .reduce((a, b) => a + b.value, 0);
174
204
  const authorizedMonetaryAmount = authorizeMonetaryAmountActions
175
- .filter((a) => { var _a, _b; return ((_b = (_a = a.result) === null || _a === void 0 ? void 0 : _a.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === currencyType; })
205
+ .filter((a) => {
206
+ var _a, _b;
207
+ const resultAsInvoice = (Array.isArray(a.result))
208
+ ? (_a = a.result) === null || _a === void 0 ? void 0 : _a.find((resultObject) => resultObject.typeOf === factory.action.authorize.paymentMethod.any.ResultType.Payment)
209
+ : a.result;
210
+ return ((_b = resultAsInvoice === null || resultAsInvoice === void 0 ? void 0 : resultAsInvoice.totalPaymentDue) === null || _b === void 0 ? void 0 : _b.currency) === currencyType;
211
+ })
176
212
  .reduce((a, b) => a + b.object.amount, 0);
177
213
  return requiredMonetaryAmount === authorizedMonetaryAmount;
178
214
  });
@@ -22,6 +22,7 @@ const validation_1 = require("./placeOrderInProgress/validation");
22
22
  const validateSeller_1 = require("./placeOrderInProgress/validation/validateSeller");
23
23
  const validation_2 = require("./validation");
24
24
  const errorHandler_1 = require("../../errorHandler");
25
+ const settings_1 = require("../../settings");
25
26
  exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
26
27
  /**
27
28
  * 取引開始
@@ -226,7 +227,9 @@ function createResult(params) {
226
227
  orderNumber: params.orderNumber,
227
228
  transaction: transaction,
228
229
  orderDate: params.result.order.orderDate,
229
- orderStatus: factory.orderStatus.OrderProcessing,
230
+ // OrderPaymentDueオプションを追加(2023-08-25~)
231
+ // 注文作成時のステータスとなる
232
+ orderStatus: (settings_1.USE_ORDER_PAYMENT_DUE_ON_PLACED) ? factory.orderStatus.OrderPaymentDue : factory.orderStatus.OrderProcessing,
230
233
  isGift: false,
231
234
  authorizeActions: params.authorizeActions
232
235
  });
@@ -138,18 +138,19 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
138
138
  const order = params.order;
139
139
  const returnFeesMovieTicketByTransaction = params.transaction.object.returnPolicy.returnFeesMovieTicket;
140
140
  return Promise.all(params.order.paymentMethods
141
- .filter((paymentMethod) => {
142
- return paymentMethod.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
141
+ .filter((invoice) => {
142
+ return invoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket;
143
143
  })
144
144
  // 決済カード着券取消有無設定を適用
145
- .filter((paymentMethod) => {
145
+ .filter((invoice) => {
146
146
  // デフォルトで実行する
147
147
  let returnPaymentMethod = true;
148
- const movieTicketIdentifier = paymentMethod.accountId;
148
+ const movieTicketIdentifier = invoice.accountId;
149
149
  const returnFeesMovieTicketSettingsByIdentifier = returnFeesMovieTicketByTransaction === null || returnFeesMovieTicketByTransaction === void 0 ? void 0 : returnFeesMovieTicketByTransaction.filter((r) => {
150
- var _a;
150
+ var _a, _b;
151
151
  return r.identifier === String(movieTicketIdentifier)
152
- && ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === paymentMethod.typeOf;
152
+ // && r.serviceOutput?.typeOf === invoice.typeOf;
153
+ && ((_a = r.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === ((_b = invoice.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier);
153
154
  });
154
155
  // 設定がなければスルー
155
156
  if (Array.isArray(returnFeesMovieTicketSettingsByIdentifier) && returnFeesMovieTicketSettingsByIdentifier.length > 0) {
@@ -356,7 +356,11 @@ function isSellerReturnPolicyApplicable(params) {
356
356
  if (Array.isArray(applicablePaymentMethod)) {
357
357
  const everyOrderApplicable = params.orders.every((order) => {
358
358
  // 全決済方法区分がapplicablePaymentMethodに含まれれば適用
359
- return order.paymentMethods.every((paymentMethod) => applicablePaymentMethod.includes(paymentMethod.typeOf));
359
+ return order.paymentMethods.every((invoice) => {
360
+ var _a;
361
+ return typeof ((_a = invoice.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier) === 'string'
362
+ && applicablePaymentMethod.includes(invoice.paymentMethod.identifier);
363
+ });
360
364
  });
361
365
  // 全注文について確認ができれば適用
362
366
  if (everyOrderApplicable) {
@@ -36,13 +36,15 @@ export type ISettings = factory.project.ISettings & {
36
36
  };
37
37
  export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
38
38
  export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
39
- export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
40
39
  export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
41
40
  export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
42
41
  export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
43
42
  export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
44
- export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
45
- export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
43
+ export declare const USE_ORDER_PAYMENT_DUE_ON_PLACED: boolean;
44
+ export declare const USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY: boolean;
45
+ export declare const USE_AGGREGATE_OFFERS_AS_PRIMARY: boolean;
46
+ export declare const USE_PROHIBIT_OFFERS_AS_PRIMARY: boolean;
47
+ export declare const USE_OPTIMIZE_TICKET_OFFER: boolean;
46
48
  export declare const MONGO_MAX_TIME_MS: number;
47
49
  /**
48
50
  * グローバル設定
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_PROHIBIT_OFFERS_AS_PRIMARY = exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const moment = require("moment");
5
5
  const factory = require("./factory");
6
6
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
@@ -60,7 +60,6 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSA
60
60
  exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
61
61
  exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
62
62
  exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
63
- exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
64
63
  exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
65
64
  ? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
66
65
  : moment('2023-08-31T15:00:00Z');
@@ -73,10 +72,11 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
73
72
  exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
74
73
  exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
75
74
  exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
76
- exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
77
- exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
78
- ? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
79
- : 0;
75
+ exports.USE_ORDER_PAYMENT_DUE_ON_PLACED = process.env.USE_ORDER_PAYMENT_DUE_ON_PLACED === '1';
76
+ exports.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY = process.env.USE_AUTHORIZE_PAYMENT_RESULT_AS_ARRAY === '1';
77
+ exports.USE_AGGREGATE_OFFERS_AS_PRIMARY = process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY === '1';
78
+ exports.USE_PROHIBIT_OFFERS_AS_PRIMARY = process.env.USE_PROHIBIT_OFFERS_AS_PRIMARY === '1';
79
+ exports.USE_OPTIMIZE_TICKET_OFFER = process.env.USE_OPTIMIZE_TICKET_OFFER === '1';
80
80
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
81
81
  ? Number(process.env.MONGO_MAX_TIME_MS)
82
82
  // tslint:disable-next-line:no-magic-numbers
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.327.0-alpha.2",
13
- "@cinerino/sdk": "3.165.0",
12
+ "@chevre/factory": "4.329.0-alpha.12",
13
+ "@cinerino/sdk": "3.167.0-alpha.5",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.6"
120
+ "version": "21.8.0-alpha.60"
121
121
  }
@@ -1,83 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
- // const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const actionRepo = new chevre.repository.Action(mongoose.connection);
15
-
16
- const cursor = actionRepo.getCursor(
17
- {
18
- typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
19
- actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
20
- 'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
21
- 'result.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
22
- startDate: {
23
- $gte: moment('2022-08-16T00:00:00Z')
24
- .toDate()
25
- // $lte: moment('2023-08-01T00:00:00Z')
26
- // .toDate()
27
- }
28
- },
29
- {
30
- _id: 1,
31
- typeOf: 1,
32
- result: 1,
33
- project: 1,
34
- startDate: 1,
35
- actionStatus: 1
36
- }
37
- );
38
- console.log('actions found');
39
-
40
- let i = 0;
41
- let updateCount = 0;
42
- await cursor.eachAsync(async (doc) => {
43
- i += 1;
44
- const action: Pick<
45
- chevre.factory.action.authorize.paymentMethod.any.IAction,
46
- 'id' | 'project' | 'result' | 'typeOf' | 'startDate' | 'actionStatus'
47
- > = doc.toObject();
48
-
49
- const oldPaymentMethodType = (<any>action).result?.paymentMethod;
50
- const paymentMethodType = action.result?.paymentMethodAsObject?.typeOf;
51
- const alreadyMigrated = typeof paymentMethodType === 'string' && oldPaymentMethodType === paymentMethodType;
52
-
53
- if (alreadyMigrated) {
54
- console.log('already exist...', action.project.id, action.id, action.startDate, paymentMethodType, i);
55
- } else {
56
- if (typeof oldPaymentMethodType !== 'string') {
57
- console.error('updating action...', action.project.id, action.id, action.startDate, oldPaymentMethodType, i, updateCount);
58
- throw new Error('oldPaymentMethodType undefined');
59
- }
60
-
61
- const newPaymentMethodAsObject: chevre.factory.action.authorize.paymentMethod.any.IResultPaymentMethod = {
62
- typeOf: oldPaymentMethodType
63
- };
64
- console.log(
65
- 'updating action...', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
66
- await actionRepo.updateById({
67
- id: action.id,
68
- update: {
69
- 'result.paymentMethodAsObject': newPaymentMethodAsObject
70
- }
71
- });
72
- updateCount += 1;
73
- console.log('updated.', action.project.id, action.id, action.startDate, newPaymentMethodAsObject.typeOf, i, updateCount);
74
- }
75
- });
76
-
77
- console.log(i, 'actions checked');
78
- console.log(updateCount, 'actions updated');
79
- }
80
-
81
- main()
82
- .then()
83
- .catch(console.error);