@chevre/domain 21.2.0-alpha.99 → 21.2.0
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.
- package/example/src/chevre/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/aggregateSellerPaymentAccepted.ts +27 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +53 -22
- package/example/src/chevre/countDelayedTasks.ts +7 -2
- package/example/src/chevre/createManyEventsIfNotExist.ts +199 -46
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +4 -3
- package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +56 -0
- package/example/src/chevre/lockStockHolder.ts +5 -2
- package/example/src/chevre/migrateCategoryCodeAdditionalProperties.ts +116 -0
- package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
- package/example/src/chevre/processRegisterMembership.ts +8 -4
- package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
- package/example/src/chevre/processReserve.ts +1 -1
- package/example/src/chevre/searchAbortedTasks.ts +4 -6
- package/example/src/chevre/searchEventSeats.ts +5 -2
- package/example/src/chevre/searchHoldReservations.ts +38 -0
- package/example/src/chevre/searchPermissions.ts +54 -0
- package/example/src/chevre/searchScreeningRooms.ts +35 -0
- package/example/src/chevre/sendEmailMessage.ts +1 -2
- package/example/src/chevre/syncScreeningRooms.ts +22 -0
- package/example/src/chevre/syncScreeningRoomsAll.ts +44 -0
- package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +41 -0
- package/lib/chevre/factory/order.d.ts +4 -1
- package/lib/chevre/factory/order.js +19 -6
- package/lib/chevre/repo/account.js +3 -2
- package/lib/chevre/repo/accountTransaction.js +2 -1
- package/lib/chevre/repo/accountingReport.d.ts +1 -3
- package/lib/chevre/repo/action.d.ts +50 -1
- package/lib/chevre/repo/action.js +53 -2
- package/lib/chevre/repo/additionalProperty.js +2 -1
- package/lib/chevre/repo/aggregation.d.ts +3 -0
- package/lib/chevre/repo/aggregation.js +3 -0
- package/lib/chevre/repo/assetTransaction.js +6 -5
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.js +37 -25
- package/lib/chevre/repo/code.js +3 -2
- package/lib/chevre/repo/comment.js +2 -1
- package/lib/chevre/repo/creativeWork.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.js +35 -12
- package/lib/chevre/repo/customer.js +2 -1
- package/lib/chevre/repo/emailMessage.js +2 -1
- package/lib/chevre/repo/event.d.ts +30 -2
- package/lib/chevre/repo/event.js +87 -36
- package/lib/chevre/repo/member.d.ts +14 -0
- package/lib/chevre/repo/member.js +31 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +75 -0
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +93 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +21 -21
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -0
- package/lib/chevre/repo/mongoose/schemas/place.js +16 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +9 -9
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +3 -3
- package/lib/chevre/repo/offer.js +3 -2
- package/lib/chevre/repo/offerCatalog.js +0 -27
- package/lib/chevre/repo/offerItemCondition.js +2 -1
- package/lib/chevre/repo/order.js +8 -7
- package/lib/chevre/repo/ownershipInfo.js +2 -7
- package/lib/chevre/repo/paymentServiceProvider.d.ts +65 -0
- package/lib/chevre/repo/paymentServiceProvider.js +156 -0
- package/lib/chevre/repo/place.d.ts +203 -27
- package/lib/chevre/repo/place.js +1726 -694
- package/lib/chevre/repo/priceSpecification.js +3 -2
- package/lib/chevre/repo/product.d.ts +5 -3
- package/lib/chevre/repo/product.js +92 -5
- package/lib/chevre/repo/project.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +9 -1
- package/lib/chevre/repo/reservation.js +29 -20
- package/lib/chevre/repo/role.d.ts +7 -0
- package/lib/chevre/repo/role.js +39 -2
- package/lib/chevre/repo/seller.d.ts +21 -1
- package/lib/chevre/repo/seller.js +59 -4
- package/lib/chevre/repo/serviceOutput.js +2 -1
- package/lib/chevre/repo/stockHolder.d.ts +143 -7
- package/lib/chevre/repo/stockHolder.js +622 -104
- package/lib/chevre/repo/task.d.ts +12 -1
- package/lib/chevre/repo/task.js +17 -7
- package/lib/chevre/repo/transaction.js +6 -5
- package/lib/chevre/repo/trip.js +2 -1
- package/lib/chevre/repository.d.ts +6 -0
- package/lib/chevre/repository.js +8 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +18 -8
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +19 -8
- package/lib/chevre/service/aggregation/system.d.ts +43 -1
- package/lib/chevre/service/aggregation/system.js +112 -2
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +2 -2
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve.js +10 -3
- package/lib/chevre/service/event.d.ts +3 -0
- package/lib/chevre/service/event.js +52 -21
- package/lib/chevre/service/iam.d.ts +6 -2
- package/lib/chevre/service/iam.js +23 -9
- package/lib/chevre/service/offer/event/factory.js +22 -13
- package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +15 -8
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
- package/lib/chevre/service/offer/product/factory.js +13 -6
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/offer.d.ts +16 -8
- package/lib/chevre/service/offer.js +71 -8
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +31 -17
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -2
- package/lib/chevre/service/order/placeOrder.js +4 -4
- package/lib/chevre/service/order/returnOrder.js +1 -1
- package/lib/chevre/service/order/sendOrder.js +3 -3
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +4 -6
- package/lib/chevre/service/payment/any/onRefund.js +46 -42
- package/lib/chevre/service/payment/creditCard.js +2 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.js +16 -9
- package/lib/chevre/service/payment/movieTicket.js +2 -2
- package/lib/chevre/service/reserve/cancelReservation.js +15 -3
- package/lib/chevre/service/reserve/confirmReservation.js +19 -11
- package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
- package/lib/chevre/service/task/cancelReservation.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/onEventChanged.d.ts +7 -0
- package/lib/chevre/service/task/onEventChanged.js +29 -0
- package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
- package/lib/chevre/service/task/onResourceUpdated.js +396 -0
- package/lib/chevre/service/task/syncScreeningRooms.d.ts +7 -0
- package/lib/chevre/service/task/syncScreeningRooms.js +24 -0
- package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +129 -1
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +3 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +8 -12
- package/lib/chevre/service/transaction/placeOrderInProgress.js +6 -4
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +5 -5
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +3 -3
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/returnOrder.js +3 -1
- package/lib/chevre/settings.d.ts +11 -0
- package/lib/chevre/settings.js +44 -2
- package/package.json +3 -3
- package/example/src/chevre/eventCatalog2eventService.ts +0 -123
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +0 -85
- package/example/src/chevre/migrateStockHolderKeys.ts +0 -89
|
@@ -106,7 +106,7 @@ function getCreditCardPaymentServiceChannel(params) {
|
|
|
106
106
|
project: { id: { $eq: params.project.id } },
|
|
107
107
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
108
108
|
serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
109
|
-
});
|
|
109
|
+
}, [], []);
|
|
110
110
|
const paymentServiceSetting = paymentServices.shift();
|
|
111
111
|
if (paymentServiceSetting === undefined) {
|
|
112
112
|
throw new factory.errors.NotFound('PaymentService');
|
|
@@ -22,7 +22,7 @@ function findPaymentCardPermit(params) {
|
|
|
22
22
|
page: 1,
|
|
23
23
|
project: { id: { $eq: params.project.id } },
|
|
24
24
|
typeOf: { $eq: factory.product.ProductType.PaymentCard }
|
|
25
|
-
});
|
|
25
|
+
}, [], []);
|
|
26
26
|
const accountProduct = searchProductsResult
|
|
27
27
|
.find((p) => { var _a, _b; return ((_b = (_a = p.serviceOutput) === null || _a === void 0 ? void 0 : _a.amount) === null || _b === void 0 ? void 0 : _b.currency) === params.accountType; });
|
|
28
28
|
if (accountProduct === undefined) {
|
|
@@ -316,7 +316,7 @@ function processAuthorizeCreditCard(params) {
|
|
|
316
316
|
project: { id: { $eq: params.project.id } },
|
|
317
317
|
typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
318
318
|
serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
319
|
-
});
|
|
319
|
+
}, [], []);
|
|
320
320
|
const creditCardPaymentService = searchCreditCardPaymentServicesResult.shift();
|
|
321
321
|
if (creditCardPaymentService === undefined) {
|
|
322
322
|
throw new factory.errors.NotFound('CreditCardPaymentService');
|
|
@@ -76,6 +76,7 @@ function createTasks(params) {
|
|
|
76
76
|
executionResults: [],
|
|
77
77
|
data: {
|
|
78
78
|
object: {
|
|
79
|
+
specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
79
80
|
endDate: transaction.endDate,
|
|
80
81
|
id: transaction.id,
|
|
81
82
|
object: Object.assign(Object.assign({}, (typeof transaction.object.confirmationNumber === 'string')
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js
CHANGED
|
@@ -47,7 +47,7 @@ function createGivePointAwardActions(params) {
|
|
|
47
47
|
typeOf: params.order.typeOf,
|
|
48
48
|
seller: params.order.seller,
|
|
49
49
|
// mask
|
|
50
|
-
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
50
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
51
51
|
// IOrderへ移行(2022-11-17~)
|
|
52
52
|
// confirmationNumber: params.order.confirmationNumber,
|
|
53
53
|
orderNumber: params.order.orderNumber,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js
CHANGED
|
@@ -65,7 +65,7 @@ function createMoneyTransferActions(params) {
|
|
|
65
65
|
typeOf: params.order.typeOf,
|
|
66
66
|
seller: params.order.seller,
|
|
67
67
|
// mask
|
|
68
|
-
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
68
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
69
69
|
// IOrderへ移行(2022-11-17~)
|
|
70
70
|
// confirmationNumber: params.order.confirmationNumber,
|
|
71
71
|
orderNumber: params.order.orderNumber,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js
CHANGED
|
@@ -50,7 +50,7 @@ function createRegisterServiceActions(params) {
|
|
|
50
50
|
typeOf: params.order.typeOf,
|
|
51
51
|
seller: params.order.seller,
|
|
52
52
|
// mask
|
|
53
|
-
customer: (0, order_1.createMaskedCustomer)(params.order),
|
|
53
|
+
customer: (0, order_1.createMaskedCustomer)(params.order, { noProfile: true }),
|
|
54
54
|
// IOrderへ移行(2022-11-17~)
|
|
55
55
|
// confirmationNumber: params.order.confirmationNumber,
|
|
56
56
|
orderNumber: params.order.orderNumber,
|
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js
CHANGED
|
@@ -19,12 +19,12 @@ function createSendEmailMessageActions(params) {
|
|
|
19
19
|
// 注文配送メール送信設定
|
|
20
20
|
const sendEmailMessageActions = [];
|
|
21
21
|
const project = params.transaction.project;
|
|
22
|
-
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order);
|
|
22
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
23
23
|
const sendActionPurpose = {
|
|
24
24
|
typeOf: params.order.typeOf,
|
|
25
25
|
seller: params.order.seller,
|
|
26
26
|
// mask
|
|
27
|
-
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id
|
|
27
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
28
28
|
// IOrderへ移行(2022-11-17~)
|
|
29
29
|
// confirmationNumber: params.order.confirmationNumber,
|
|
30
30
|
orderNumber: params.order.orderNumber,
|
|
@@ -48,8 +48,8 @@ function createSendEmailMessageActions(params) {
|
|
|
48
48
|
agent: params.transaction.project,
|
|
49
49
|
recipient: {
|
|
50
50
|
typeOf: params.order.customer.typeOf,
|
|
51
|
-
id: params.order.customer.id
|
|
52
|
-
name: String(params.order.customer.name)
|
|
51
|
+
id: params.order.customer.id
|
|
52
|
+
// name: String(params.order.customer.name)
|
|
53
53
|
},
|
|
54
54
|
potentialActions: {},
|
|
55
55
|
purpose: sendActionPurpose
|
|
@@ -28,13 +28,13 @@ function createPotentialActions(params) {
|
|
|
28
28
|
const givePointAwardActions = yield (0, givePointAward_1.createGivePointAwardActions)(params);
|
|
29
29
|
// 注文配送メール送信設定
|
|
30
30
|
const sendEmailMessageActions = yield (0, sendEmailMessage_1.createSendEmailMessageActions)(params);
|
|
31
|
-
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order);
|
|
31
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(params.order, { noProfile: true });
|
|
32
32
|
const simpleOrder = {
|
|
33
33
|
// project: params.order.project,
|
|
34
34
|
typeOf: params.order.typeOf,
|
|
35
35
|
seller: params.order.seller,
|
|
36
36
|
// mask
|
|
37
|
-
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id
|
|
37
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
38
38
|
// IOrderへ移行(2022-11-17~)
|
|
39
39
|
// confirmationNumber: params.order.confirmationNumber,
|
|
40
40
|
orderNumber: params.order.orderNumber,
|
|
@@ -50,8 +50,7 @@ function createPotentialActions(params) {
|
|
|
50
50
|
agent: params.transaction.project,
|
|
51
51
|
recipient: {
|
|
52
52
|
typeOf: params.order.customer.typeOf,
|
|
53
|
-
id: params.order.customer.id
|
|
54
|
-
name: String(params.order.customer.name)
|
|
53
|
+
id: params.order.customer.id
|
|
55
54
|
},
|
|
56
55
|
potentialActions: {
|
|
57
56
|
moneyTransfer: moneyTransferActions,
|
|
@@ -159,19 +159,15 @@ function createMoneyTransferAcceptedOffers(params) {
|
|
|
159
159
|
name: `${amountValue} ${currency}`
|
|
160
160
|
};
|
|
161
161
|
acceptedOffers.push({
|
|
162
|
-
// 不要なので廃止(2022-11-05~)
|
|
163
|
-
// project: { typeOf: params.transaction.project.typeOf, id: params.transaction.project.id },
|
|
164
162
|
typeOf: factory.offerType.Offer,
|
|
165
|
-
itemOffered
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
seller: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
name: params.seller.name
|
|
174
|
-
}
|
|
163
|
+
itemOffered
|
|
164
|
+
// 不要なので廃止(2023-07-01~)
|
|
165
|
+
// priceCurrency: authorizeMoneyTansferAction.result.priceCurrency,
|
|
166
|
+
// 不要なので廃止(2023-07-01~)
|
|
167
|
+
// seller: {
|
|
168
|
+
// typeOf: params.seller.typeOf,
|
|
169
|
+
// name: params.seller.name
|
|
170
|
+
// }
|
|
175
171
|
});
|
|
176
172
|
}
|
|
177
173
|
});
|
|
@@ -29,10 +29,12 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
|
29
29
|
function start(params) {
|
|
30
30
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
var _a;
|
|
32
|
-
const seller = yield repos.seller.findById({ id: params.seller.id },
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const seller = yield repos.seller.findById({ id: params.seller.id }, ['name', 'project', 'typeOf', 'makesOffer'], []
|
|
33
|
+
// {
|
|
34
|
+
// hasMerchantReturnPolicy: 0,
|
|
35
|
+
// paymentAccepted: 0
|
|
36
|
+
// }
|
|
37
|
+
);
|
|
36
38
|
let makesOfferFromClient;
|
|
37
39
|
// 販売者オファー検証(2022-10-14~)
|
|
38
40
|
if (params.validateSeller === true) {
|
|
@@ -17,12 +17,12 @@ function createReturnMoneyTransferActions(params) {
|
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const order = params.order;
|
|
19
19
|
const returnMoneyTransferActions = [];
|
|
20
|
-
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
20
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
21
21
|
const purpose = {
|
|
22
22
|
typeOf: order.typeOf,
|
|
23
23
|
seller: order.seller,
|
|
24
24
|
// mask
|
|
25
|
-
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id
|
|
25
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
26
26
|
// IOrderへ移行(2022-11-17~)
|
|
27
27
|
// confirmationNumber: order.confirmationNumber,
|
|
28
28
|
orderNumber: order.orderNumber,
|
|
@@ -44,7 +44,7 @@ function createReturnPaymentMethodPotentialActions(params) {
|
|
|
44
44
|
typeOf: order.typeOf,
|
|
45
45
|
seller: order.seller,
|
|
46
46
|
// mask
|
|
47
|
-
customer: (0, order_1.createMaskedCustomer)(order),
|
|
47
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
48
48
|
// IOrderへ移行(2022-11-17~)
|
|
49
49
|
// confirmationNumber: order.confirmationNumber,
|
|
50
50
|
orderNumber: order.orderNumber,
|
|
@@ -59,8 +59,8 @@ function createReturnPaymentMethodPotentialActions(params) {
|
|
|
59
59
|
agent: order.project,
|
|
60
60
|
recipient: {
|
|
61
61
|
typeOf: order.customer.typeOf,
|
|
62
|
-
id: order.customer.id
|
|
63
|
-
name: String(order.customer.name)
|
|
62
|
+
id: order.customer.id
|
|
63
|
+
// name: String(order.customer.name)
|
|
64
64
|
},
|
|
65
65
|
potentialActions: {},
|
|
66
66
|
purpose: sendActionPurpose
|
|
@@ -109,7 +109,7 @@ function createReturnPaymentMethodActions(params) {
|
|
|
109
109
|
typeOf: order.typeOf,
|
|
110
110
|
seller: order.seller,
|
|
111
111
|
// mask
|
|
112
|
-
customer: (0, order_1.createMaskedCustomer)(order),
|
|
112
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
113
113
|
// IOrderへ移行(2022-11-17~)
|
|
114
114
|
// confirmationNumber: order.confirmationNumber,
|
|
115
115
|
orderNumber: order.orderNumber,
|
|
@@ -188,7 +188,7 @@ function createReturnPaymentMethodIssuedThroughMovieTicketActions(params) {
|
|
|
188
188
|
typeOf: order.typeOf,
|
|
189
189
|
seller: order.seller,
|
|
190
190
|
// mask
|
|
191
|
-
customer: (0, order_1.createMaskedCustomer)(order),
|
|
191
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
192
192
|
// IOrderへ移行(2022-11-17~)
|
|
193
193
|
// confirmationNumber: order.confirmationNumber,
|
|
194
194
|
orderNumber: order.orderNumber,
|
|
@@ -48,12 +48,12 @@ function createReturnPointAwardActions(params) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const order = params.order;
|
|
51
|
-
const maskedCustomer = (0, order_1.createMaskedCustomer)(order);
|
|
51
|
+
const maskedCustomer = (0, order_1.createMaskedCustomer)(order, { noProfile: true });
|
|
52
52
|
const purpose = {
|
|
53
53
|
typeOf: order.typeOf,
|
|
54
54
|
seller: order.seller,
|
|
55
55
|
// mask
|
|
56
|
-
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id
|
|
56
|
+
customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id },
|
|
57
57
|
// IOrderへ移行(2022-11-17~)
|
|
58
58
|
// confirmationNumber: order.confirmationNumber,
|
|
59
59
|
orderNumber: order.orderNumber,
|
|
@@ -22,7 +22,7 @@ function createSendEmailMessaegActionsOnReturn(params) {
|
|
|
22
22
|
typeOf: order.typeOf,
|
|
23
23
|
seller: order.seller,
|
|
24
24
|
// mask
|
|
25
|
-
customer: (0, order_1.createMaskedCustomer)(order),
|
|
25
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
26
26
|
// IOrderへ移行(2022-11-17~)
|
|
27
27
|
// confirmationNumber: order.confirmationNumber,
|
|
28
28
|
orderNumber: order.orderNumber,
|
|
@@ -47,8 +47,8 @@ function createSendEmailMessaegActionsOnReturn(params) {
|
|
|
47
47
|
agent: order.project,
|
|
48
48
|
recipient: {
|
|
49
49
|
typeOf: order.customer.typeOf,
|
|
50
|
-
id: order.customer.id
|
|
51
|
-
name: String(order.customer.name)
|
|
50
|
+
id: order.customer.id
|
|
51
|
+
// name: String(order.customer.name)
|
|
52
52
|
},
|
|
53
53
|
potentialActions: {},
|
|
54
54
|
purpose: sendActionPurpose
|
|
@@ -53,7 +53,7 @@ function createPotentialActions(params) {
|
|
|
53
53
|
typeOf: order.typeOf,
|
|
54
54
|
seller: order.seller,
|
|
55
55
|
// mask
|
|
56
|
-
customer: (0, order_1.createMaskedCustomer)(order),
|
|
56
|
+
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
57
57
|
confirmationNumber: order.confirmationNumber,
|
|
58
58
|
orderNumber: order.orderNumber,
|
|
59
59
|
price: order.price,
|
|
@@ -29,7 +29,9 @@ function start(params) {
|
|
|
29
29
|
const now = new Date();
|
|
30
30
|
const { acceptedOffers, eventIds, offerIds, orders } = yield fixOrders(params)(repos);
|
|
31
31
|
// sellerはorderから自動取得
|
|
32
|
-
const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) },
|
|
32
|
+
const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) }, ['name', 'project', 'hasMerchantReturnPolicy', 'typeOf'], []
|
|
33
|
+
// { additionalProperty: 0, paymentAccepted: 0 }
|
|
34
|
+
);
|
|
33
35
|
yield validateOrder({ orders })(repos);
|
|
34
36
|
let offers = [];
|
|
35
37
|
if (offerIds.length > 0) {
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -17,9 +17,15 @@ export declare const TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS: number;
|
|
|
17
17
|
export declare const TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS: number;
|
|
18
18
|
export declare const DEFAULT_SENDER_EMAIL: string;
|
|
19
19
|
export type ISettings = factory.project.ISettings & {
|
|
20
|
+
onEventChanged: {
|
|
21
|
+
informEvent?: factory.project.IInformParams[];
|
|
22
|
+
};
|
|
20
23
|
onReservationStatusChanged: {
|
|
21
24
|
informReservation?: factory.project.IInformParams[];
|
|
22
25
|
};
|
|
26
|
+
onResourceUpdated: {
|
|
27
|
+
informResource?: factory.project.IInformParams[];
|
|
28
|
+
};
|
|
23
29
|
maximumReservationGracePeriodInDays: number;
|
|
24
30
|
userPoolIdOld: string;
|
|
25
31
|
userPoolIdNew: string;
|
|
@@ -33,7 +39,12 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
|
33
39
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
34
40
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
35
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
42
|
+
export declare const USE_NEW_STOCK_HOLDER_REPO_FROM: moment.Moment;
|
|
43
|
+
export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
|
|
44
|
+
export declare const USE_READ_SCREENING_ROOM_TYPE: boolean;
|
|
45
|
+
export declare const USE_WRITE_SCREENING_ROOM_TYPE: boolean;
|
|
36
46
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
47
|
+
export declare const MONGO_MAX_TIME_MS: number;
|
|
37
48
|
/**
|
|
38
49
|
* グローバル設定
|
|
39
50
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = 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_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = 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.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_WRITE_SCREENING_ROOM_TYPE = exports.USE_READ_SCREENING_ROOM_TYPE = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_STOCK_HOLDER_REPO_FROM = 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_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = 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')
|
|
7
7
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
8
8
|
: [];
|
|
9
|
+
const informEventUrls = (typeof process.env.INFORM_EVENT_URL === 'string')
|
|
10
|
+
? process.env.INFORM_EVENT_URL.split(' ')
|
|
11
|
+
: [];
|
|
9
12
|
const informOrderUrls = (typeof process.env.INFORM_ORDER_URL === 'string')
|
|
10
13
|
? process.env.INFORM_ORDER_URL.split(' ')
|
|
11
14
|
: [];
|
|
12
15
|
const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'string')
|
|
13
16
|
? process.env.INFORM_RESERVATION_URL.split(' ')
|
|
14
17
|
: [];
|
|
18
|
+
const informResourceUrls = (typeof process.env.INFORM_RESOURCE_URL === 'string')
|
|
19
|
+
? process.env.INFORM_RESOURCE_URL.split(' ')
|
|
20
|
+
: [];
|
|
15
21
|
// tslint:disable-next-line:no-magic-numbers
|
|
16
22
|
const triggerWebhookTimeout = (process.env.TRIGGER_WEBHOOK_TIMEOUT !== undefined) ? Number(process.env.TRIGGER_WEBHOOK_TIMEOUT) : 15000;
|
|
17
23
|
exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = (typeof process.env.TRIGGER_WEBHOOK_MAX_RETRY_COUNT === 'string')
|
|
@@ -59,13 +65,37 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
59
65
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
60
66
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
61
67
|
: moment('2023-08-31T15:00:00Z');
|
|
68
|
+
exports.USE_NEW_STOCK_HOLDER_REPO_FROM = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_FROM === 'string')
|
|
69
|
+
? moment(process.env.USE_NEW_STOCK_HOLDER_REPO_FROM)
|
|
70
|
+
: moment('2024-11-30T15:00:00Z');
|
|
71
|
+
exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
|
|
72
|
+
? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
73
|
+
: [];
|
|
74
|
+
exports.USE_READ_SCREENING_ROOM_TYPE = process.env.USE_READ_SCREENING_ROOM_TYPE === '1';
|
|
75
|
+
exports.USE_WRITE_SCREENING_ROOM_TYPE = process.env.USE_WRITE_SCREENING_ROOM_TYPE === '1';
|
|
62
76
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
63
77
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
64
78
|
: 0;
|
|
79
|
+
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
80
|
+
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
81
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
82
|
+
: 10000;
|
|
65
83
|
/**
|
|
66
84
|
* グローバル設定
|
|
67
85
|
*/
|
|
68
|
-
exports.settings = Object.assign(Object.assign({ transactionWebhookUrls,
|
|
86
|
+
exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onEventChanged: {
|
|
87
|
+
informEvent: informEventUrls
|
|
88
|
+
.filter((url) => url.length > 0)
|
|
89
|
+
.map((url) => {
|
|
90
|
+
return {
|
|
91
|
+
recipient: {
|
|
92
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
93
|
+
name: 'Global HUB',
|
|
94
|
+
url
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
})
|
|
98
|
+
}, onOrderStatusChanged: {
|
|
69
99
|
informOrder: informOrderUrls
|
|
70
100
|
.filter((url) => url.length > 0)
|
|
71
101
|
.map((url) => {
|
|
@@ -77,6 +107,18 @@ exports.settings = Object.assign(Object.assign({ transactionWebhookUrls, onOrder
|
|
|
77
107
|
}
|
|
78
108
|
};
|
|
79
109
|
})
|
|
110
|
+
}, onResourceUpdated: {
|
|
111
|
+
informResource: informResourceUrls
|
|
112
|
+
.filter((url) => url.length > 0)
|
|
113
|
+
.map((url) => {
|
|
114
|
+
return {
|
|
115
|
+
recipient: {
|
|
116
|
+
typeOf: factory.creativeWorkType.WebApplication,
|
|
117
|
+
name: 'Global HUB',
|
|
118
|
+
url
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
})
|
|
80
122
|
},
|
|
81
123
|
// 廃止(2022-10-29~)
|
|
82
124
|
// onPaymentStatusChanged: {
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0
|
|
13
|
-
"@cinerino/sdk": "3.157.
|
|
12
|
+
"@chevre/factory": "4.313.0",
|
|
13
|
+
"@cinerino/sdk": "3.157.1",
|
|
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.2.0
|
|
120
|
+
"version": "21.2.0"
|
|
121
121
|
}
|
|
@@ -1,123 +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
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
-
|
|
12
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
13
|
-
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
14
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
'project.id': { $ne: '' },
|
|
20
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
-
startDate: {
|
|
22
|
-
$gte: moment()
|
|
23
|
-
.add(-1, 'month')
|
|
24
|
-
.toDate()
|
|
25
|
-
}
|
|
26
|
-
// _id: { $eq: 'al6afd7np' }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
// _id: 1,
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
console.log('events found');
|
|
33
|
-
|
|
34
|
-
let i = 0;
|
|
35
|
-
let updateCount = 0;
|
|
36
|
-
await cursor.eachAsync(async (doc) => {
|
|
37
|
-
i += 1;
|
|
38
|
-
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
39
|
-
|
|
40
|
-
const itemOfferedId = (<chevre.factory.event.screeningEvent.IOffer | undefined>event.offers)?.itemOffered?.id;
|
|
41
|
-
const catalogId = (<any>event).hasOfferCatalog?.id;
|
|
42
|
-
|
|
43
|
-
if (typeof catalogId === 'string' && catalogId.length > 0) {
|
|
44
|
-
if (typeof itemOfferedId === 'string' && itemOfferedId.length > 0) {
|
|
45
|
-
console.log(
|
|
46
|
-
'already exist...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
47
|
-
} else {
|
|
48
|
-
const existingCatalogs = await offerCatalogRepo.search({
|
|
49
|
-
limit: 1,
|
|
50
|
-
page: 1,
|
|
51
|
-
project: { id: { $eq: event.project.id } },
|
|
52
|
-
id: { $in: [catalogId] }
|
|
53
|
-
});
|
|
54
|
-
const existingCatalog = existingCatalogs.shift();
|
|
55
|
-
|
|
56
|
-
if (existingCatalog !== undefined) {
|
|
57
|
-
const existingProducts = await productRepo.search({
|
|
58
|
-
limit: 1,
|
|
59
|
-
page: 1,
|
|
60
|
-
project: { id: { $eq: event.project.id } },
|
|
61
|
-
productID: { $eq: `${chevre.factory.product.ProductType.EventService}${catalogId}` }
|
|
62
|
-
});
|
|
63
|
-
const existingProduct = existingProducts.shift();
|
|
64
|
-
if (existingProduct === undefined) {
|
|
65
|
-
throw new Error(`product not found ${event.id}`);
|
|
66
|
-
}
|
|
67
|
-
console.log(
|
|
68
|
-
'updating event...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
69
|
-
await eventRepo.updatePartiallyById({
|
|
70
|
-
id: event.id,
|
|
71
|
-
attributes: <any>{
|
|
72
|
-
typeOf: event.typeOf,
|
|
73
|
-
'offers.itemOffered.id': String(existingProduct.id)
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
updateCount += 1;
|
|
77
|
-
console.log(
|
|
78
|
-
'updated', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
79
|
-
} else {
|
|
80
|
-
// カタログが存在しないのではもはや無効なのでスルー
|
|
81
|
-
console.log(
|
|
82
|
-
'catalog not exist', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
console.log(
|
|
87
|
-
'no catalog...', event.project.id, event.id, event.startDate, itemOfferedId, i);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
console.log(i, 'events checked');
|
|
92
|
-
console.log(updateCount, 'events updated');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// function offerCatalog2eventService(offerCatalog: chevre.factory.offerCatalog.IOfferCatalog): chevre.factory.product.IProduct {
|
|
96
|
-
// tslint:disable-next-line:max-line-length
|
|
97
|
-
// const serviceType: chevre.factory.product.IServiceType | undefined = (typeof offerCatalog.itemOffered.serviceType?.typeOf === 'string')
|
|
98
|
-
// ? {
|
|
99
|
-
// codeValue: offerCatalog.itemOffered.serviceType.codeValue,
|
|
100
|
-
// inCodeSet: offerCatalog.itemOffered.serviceType.inCodeSet,
|
|
101
|
-
// project: offerCatalog.itemOffered.serviceType.project,
|
|
102
|
-
// typeOf: offerCatalog.itemOffered.serviceType.typeOf
|
|
103
|
-
// }
|
|
104
|
-
// : undefined;
|
|
105
|
-
|
|
106
|
-
// if (typeof offerCatalog.id !== 'string' || offerCatalog.id.length === 0) {
|
|
107
|
-
// throw new Error('offerCatalog.id undefined');
|
|
108
|
-
// }
|
|
109
|
-
|
|
110
|
-
// return {
|
|
111
|
-
// project: offerCatalog.project,
|
|
112
|
-
// typeOf: chevre.factory.product.ProductType.EventService,
|
|
113
|
-
// // productIDフォーマット確定(matches(/^[0-9a-zA-Z]+$/)に注意)(.isLength({ min: 3, max: 30 })に注意)
|
|
114
|
-
// productID: `${chevre.factory.product.ProductType.EventService}${offerCatalog.id}`,
|
|
115
|
-
// name: offerCatalog.name,
|
|
116
|
-
// hasOfferCatalog: { id: offerCatalog.id, typeOf: offerCatalog.typeOf },
|
|
117
|
-
// ...(typeof serviceType?.typeOf === 'string') ? { serviceType } : undefined
|
|
118
|
-
// };
|
|
119
|
-
// }
|
|
120
|
-
|
|
121
|
-
main()
|
|
122
|
-
.then()
|
|
123
|
-
.catch(console.error);
|
|
@@ -1,85 +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 orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = orderRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
// 'project.id': { $eq: project.id },
|
|
19
|
-
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
-
orderDate: {
|
|
21
|
-
$gte: moment()
|
|
22
|
-
.add(-1, 'months')
|
|
23
|
-
.toDate()
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
paymentMethods: 1,
|
|
28
|
-
project: 1,
|
|
29
|
-
orderDate: 1
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
console.log('movies found');
|
|
33
|
-
|
|
34
|
-
const additionalPropertyNames: string[] = [];
|
|
35
|
-
const projectIds: string[] = [];
|
|
36
|
-
const unexpextedprojectIds: string[] = [];
|
|
37
|
-
|
|
38
|
-
let i = 0;
|
|
39
|
-
await cursor.eachAsync(async (doc) => {
|
|
40
|
-
i += 1;
|
|
41
|
-
const order: chevre.factory.order.IOrder = doc.toObject();
|
|
42
|
-
|
|
43
|
-
const additionalPropertyNamesOnOrder = order.paymentMethods.reduce<string[]>(
|
|
44
|
-
(a, b) => {
|
|
45
|
-
if (Array.isArray(b.additionalProperty)) {
|
|
46
|
-
return [...a, ...b.additionalProperty.map((p) => p.name)];
|
|
47
|
-
} else {
|
|
48
|
-
return a;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
[]
|
|
52
|
-
);
|
|
53
|
-
if (Array.isArray(additionalPropertyNamesOnOrder) && additionalPropertyNamesOnOrder.length > 0) {
|
|
54
|
-
console.log(
|
|
55
|
-
additionalPropertyNamesOnOrder.join(','),
|
|
56
|
-
additionalPropertyNamesOnOrder.length,
|
|
57
|
-
'additionalPropertyNamesOnOrder found',
|
|
58
|
-
order.project.id,
|
|
59
|
-
order.id,
|
|
60
|
-
order.orderDate
|
|
61
|
-
);
|
|
62
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnOrder);
|
|
63
|
-
projectIds.push(order.project.id);
|
|
64
|
-
additionalPropertyNamesOnOrder.forEach((name) => {
|
|
65
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
66
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
67
|
-
unexpextedprojectIds.push(order.project.id);
|
|
68
|
-
}
|
|
69
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
70
|
-
if (name.length < 5) {
|
|
71
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
72
|
-
unexpextedprojectIds.push(order.project.id);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
console.log(i, 'orders checked');
|
|
78
|
-
console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
|
|
79
|
-
console.log('projectIds:', [...new Set(projectIds)]);
|
|
80
|
-
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
main()
|
|
84
|
-
.then()
|
|
85
|
-
.catch(console.error);
|