@chevre/domain 22.9.0-alpha.6 → 22.9.0-alpha.61
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/checkPaymentServiceUniqueness.ts +79 -0
- package/example/src/chevre/executeOneTask.ts +41 -0
- package/example/src/chevre/{aggregateAllEvents2.ts → executeTaskIfExists.ts} +19 -10
- package/example/src/chevre/findExecutableTask.ts +50 -0
- package/example/src/chevre/makeExpiredManyTasks.ts +27 -0
- package/example/src/chevre/makeTransactionExpired.ts +28 -0
- package/example/src/chevre/migratePaymentServiceChannelIds.ts +107 -0
- package/example/src/chevre/recreateRefundTasks.ts +187 -0
- package/example/src/chevre/saveWebSite.ts +59 -0
- package/example/src/chevre/searchPaymentServices.ts +32 -0
- package/example/src/chevre/transaction/startExportTasks.ts +4 -3
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -5
- package/lib/chevre/eventEmitter/task.d.ts +1 -1
- package/lib/chevre/repo/action.d.ts +13 -98
- package/lib/chevre/repo/action.js +54 -41
- package/lib/chevre/repo/identity.d.ts +5 -5
- package/lib/chevre/repo/identityProvider.d.ts +32 -7
- package/lib/chevre/repo/identityProvider.js +11 -4
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +3 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +41 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -2
- package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/identityProvider.d.ts +1 -29
- package/lib/chevre/repo/mongoose/schemas/identityProvider.js +0 -4
- package/lib/chevre/repo/mongoose/schemas/paymentService.js +29 -3
- package/lib/chevre/repo/mongoose/schemas/potentialAction.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/potentialAction.js +56 -0
- package/lib/chevre/repo/mongoose/schemas/{interface.d.ts → reserveInterface.d.ts} +1 -1
- package/lib/chevre/repo/mongoose/schemas/{interface.js → reserveInterface.js} +2 -2
- package/lib/chevre/repo/mongoose/schemas/task.js +24 -9
- package/lib/chevre/repo/mongoose/schemas/webSite.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/webSite.js +69 -0
- package/lib/chevre/repo/paymentService.d.ts +11 -6
- package/lib/chevre/repo/paymentService.js +141 -34
- package/lib/chevre/repo/paymentServiceChannel.d.ts +29 -4
- package/lib/chevre/repo/paymentServiceChannel.js +68 -0
- package/lib/chevre/repo/potentialAction.d.ts +56 -0
- package/lib/chevre/repo/potentialAction.js +137 -0
- package/lib/chevre/repo/product.js +2 -1
- package/lib/chevre/repo/reservation.d.ts +1 -1
- package/lib/chevre/repo/{interface.d.ts → reserveInterface.d.ts} +3 -4
- package/lib/chevre/repo/{interface.js → reserveInterface.js} +11 -13
- package/lib/chevre/repo/seller.d.ts +12 -12
- package/lib/chevre/repo/task.d.ts +51 -8
- package/lib/chevre/repo/task.js +148 -53
- package/lib/chevre/repo/transaction.d.ts +22 -11
- package/lib/chevre/repo/transaction.js +94 -18
- package/lib/chevre/repo/webSite.d.ts +45 -0
- package/lib/chevre/repo/webSite.js +165 -0
- package/lib/chevre/repository.d.ts +15 -5
- package/lib/chevre/repository.js +41 -15
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +51 -59
- package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +28 -0
- package/lib/chevre/service/assetTransaction/cancelReservation/start.js +106 -0
- package/lib/chevre/service/assetTransaction/cancelReservation/startAndConfirm.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/cancelReservation/startAndConfirm.js +52 -0
- package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +6 -23
- package/lib/chevre/service/assetTransaction/cancelReservation.js +5 -130
- package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/fixInformAction.js +51 -0
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +7 -0
- package/lib/chevre/service/assetTransaction/pay/factory.js +27 -16
- package/lib/chevre/service/assetTransaction/pay.d.ts +12 -20
- package/lib/chevre/service/assetTransaction/pay.js +23 -44
- package/lib/chevre/service/assetTransaction/refund/factory.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/refund/factory.js +29 -22
- package/lib/chevre/service/assetTransaction/refund/potentialActions.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund/potentialActions.js +37 -33
- package/lib/chevre/service/assetTransaction/refund.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/refund.js +11 -4
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +1 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +3 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +6 -4
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.d.ts +26 -0
- package/lib/chevre/service/assetTransaction/reserveCOA/cancel.js +112 -0
- package/lib/chevre/service/notification.d.ts +2 -0
- package/lib/chevre/service/notification.js +62 -15
- package/lib/chevre/service/offer/any.d.ts +1 -9
- package/lib/chevre/service/offer/any.js +1 -8
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -1
- package/lib/chevre/service/offer/event/authorize.js +10 -3
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.d.ts +14 -0
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4coa.js +5 -89
- package/lib/chevre/service/offer/event/voidTransaction.js +8 -6
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +5 -3
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +8 -1
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +9 -2
- package/lib/chevre/service/offer/onEventChanged.js +16 -7
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +31 -23
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +31 -23
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +3 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +50 -32
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +31 -23
- package/lib/chevre/service/order/onOrderUpdated/factory.js +30 -23
- package/lib/chevre/service/payment/any/factory.d.ts +20 -14
- package/lib/chevre/service/payment/any/factory.js +47 -16
- package/lib/chevre/service/payment/any/{fixConfirmationNumberAsNeeded.d.ts → fixOrderAsNeeded.d.ts} +13 -3
- package/lib/chevre/service/payment/any/fixOrderAsNeeded.js +41 -0
- package/lib/chevre/service/payment/any/{onPaid.d.ts → onPayActionCompleted.d.ts} +2 -5
- package/lib/chevre/service/payment/any/{onPaid.js → onPayActionCompleted.js} +35 -10
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.d.ts +2 -2
- package/lib/chevre/service/payment/any/{onRefund.d.ts → onRefundActionCompletedOrFailed.d.ts} +4 -2
- package/lib/chevre/service/payment/any/{onRefund.js → onRefundActionCompletedOrFailed.js} +48 -29
- package/lib/chevre/service/payment/any.d.ts +13 -7
- package/lib/chevre/service/payment/any.js +173 -89
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/authorize.js +5 -3
- package/lib/chevre/service/payment/creditCard/factory.d.ts +1 -0
- package/lib/chevre/service/payment/creditCard/factory.js +2 -2
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +1 -0
- package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +8 -6
- package/lib/chevre/service/payment/creditCard/gmoError.d.ts +8 -1
- package/lib/chevre/service/payment/creditCard/gmoError.js +7 -0
- package/lib/chevre/service/payment/creditCard/payCreditCard.js +10 -6
- package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +3 -4
- package/lib/chevre/service/payment/creditCard/refundCreditCard.js +119 -65
- package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +5 -3
- package/lib/chevre/service/payment/faceToFace.js +5 -5
- package/lib/chevre/service/payment/factory.d.ts +1 -1
- package/lib/chevre/service/payment/factory.js +32 -37
- package/lib/chevre/service/payment/movieTicket/authorize.js +35 -17
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +9 -13
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +5 -1
- package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +14 -12
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +4 -1
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +16 -15
- package/lib/chevre/service/payment/movieTicket/voidTransaction.js +7 -2
- package/lib/chevre/service/payment/paymentCard.js +5 -6
- package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +17 -23
- package/lib/chevre/service/reserve/checkInReservation.d.ts +3 -0
- package/lib/chevre/service/reserve/checkInReservation.js +4 -4
- package/lib/chevre/service/reserve/confirmReservation.d.ts +0 -5
- package/lib/chevre/service/reserve/confirmReservation.js +4 -11
- package/lib/chevre/service/reserve/factory.d.ts +1 -3
- package/lib/chevre/service/reserve/factory.js +11 -7
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +2 -0
- package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +23 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +23 -10
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +3 -0
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +17 -9
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +23 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +22 -10
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +22 -10
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
- package/lib/chevre/service/reserve/useReservation.js +25 -7
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -1
- package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
- package/lib/chevre/service/reserveCOA/cancelReservation.d.ts +12 -0
- package/lib/chevre/service/reserveCOA/cancelReservation.js +78 -0
- package/lib/chevre/service/reserveCOA/factory.d.ts +13 -0
- package/lib/chevre/service/reserveCOA/factory.js +23 -0
- package/lib/chevre/service/task/acceptCOAOffer.js +3 -3
- package/lib/chevre/service/task/authorizePayment.js +7 -6
- package/lib/chevre/service/task/cancelPendingReservation.d.ts +2 -2
- package/lib/chevre/service/task/cancelPendingReservation.js +52 -16
- package/lib/chevre/service/task/confirmReserveTransaction.js +3 -3
- package/lib/chevre/service/task/deletePerson.js +54 -45
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +3 -3
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -3
- package/lib/chevre/service/task/importOffersFromCOA.js +3 -4
- package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +3 -0
- package/lib/chevre/service/task/invalidatePaymentUrl.js +33 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +4 -3
- package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +8 -5
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +8 -5
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +8 -5
- package/lib/chevre/service/task/onResourceUpdated.js +48 -27
- package/lib/chevre/service/task/pay.js +3 -3
- package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.d.ts +28 -0
- package/lib/chevre/service/task/payment/invalidatePaymentUrlByTask.js +33 -0
- package/lib/chevre/service/task/payment/payByTask.d.ts +48 -0
- package/lib/chevre/service/{payment.js → task/payment/payByTask.js} +16 -65
- package/lib/chevre/service/task/payment/refundByTask.d.ts +31 -0
- package/lib/chevre/service/task/payment/refundByTask.js +41 -0
- package/lib/chevre/service/task/payment/voidPaymentByTask.d.ts +23 -0
- package/lib/chevre/service/task/payment/voidPaymentByTask.js +38 -0
- package/lib/chevre/service/task/refund.js +2 -2
- package/lib/chevre/service/task/returnPayTransaction.js +10 -2
- package/lib/chevre/service/task/returnReserveTransaction.js +15 -6
- package/lib/chevre/service/task/triggerWebhook.js +2 -2
- package/lib/chevre/service/task/useReservation.js +12 -1
- package/lib/chevre/service/task/voidPayTransaction.js +4 -2
- package/lib/chevre/service/task/voidPayment.js +2 -2
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -3
- package/lib/chevre/service/task.d.ts +11 -4
- package/lib/chevre/service/task.js +16 -13
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +13 -7
- package/lib/chevre/service/transaction/placeOrder/confirm.js +29 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +4 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +67 -53
- package/lib/chevre/service/transaction/placeOrder.js +0 -2
- package/lib/chevre/service/transaction.d.ts +6 -7
- package/lib/chevre/service/transaction.js +6 -10
- package/package.json +3 -3
- package/example/src/chevre/migratePaymentServiceChannelsCreditCard.ts +0 -108
- package/example/src/chevre/migratePaymentServiceChannelsMovieTicket.ts +0 -112
- package/example/src/chevre/retryTasks.ts +0 -41
- package/example/src/chevre/saveTasks.ts +0 -53
- package/example/src/chevre/searchPriceSpecifications.ts +0 -56
- package/lib/chevre/service/payment/any/fixConfirmationNumberAsNeeded.js +0 -31
- package/lib/chevre/service/payment.d.ts +0 -95
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: {
|
|
18
|
+
$in: [
|
|
19
|
+
chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
20
|
+
chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
// _id: { $eq: '5f9a4fed4f3709000abe6415' }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
_id: 1,
|
|
27
|
+
availableChannel: 1,
|
|
28
|
+
productID: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
typeOf: 1,
|
|
31
|
+
serviceType: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('docs found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
// let updateCount = 0;
|
|
38
|
+
const unexpectedIds: string[] = [];
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const paymentService: Pick<
|
|
42
|
+
chevre.factory.service.paymentService.IService,
|
|
43
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf' | 'serviceType'
|
|
44
|
+
> = doc.toObject();
|
|
45
|
+
|
|
46
|
+
console.log(
|
|
47
|
+
'alreadyMigrated?', paymentService.project.id, paymentService.productID, i);
|
|
48
|
+
if (typeof paymentService.id !== 'string') {
|
|
49
|
+
throw new Error('id must be string');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let isUnique = false;
|
|
53
|
+
const existingServices = await paymentServiceRepo.projectFields(
|
|
54
|
+
{
|
|
55
|
+
project: { id: { $eq: paymentService.project.id } },
|
|
56
|
+
serviceType: { codeValue: { $eq: paymentService.serviceType.codeValue } }
|
|
57
|
+
},
|
|
58
|
+
['id']
|
|
59
|
+
);
|
|
60
|
+
if (existingServices.length === 1 && existingServices.at(0)?.id === paymentService.id) {
|
|
61
|
+
isUnique = true;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isUnique) {
|
|
65
|
+
console.log(
|
|
66
|
+
'unique.', paymentService.project.id, paymentService.productID, i);
|
|
67
|
+
} else {
|
|
68
|
+
unexpectedIds.push(paymentService.productID);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log(unexpectedIds);
|
|
73
|
+
console.log(i, 'docs checked');
|
|
74
|
+
console.log(unexpectedIds.length, 'docs unexpected');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main()
|
|
78
|
+
.then()
|
|
79
|
+
.catch(console.error);
|
|
@@ -0,0 +1,41 @@
|
|
|
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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
const task = await taskRepo.executeOneIfExists({
|
|
14
|
+
name: {
|
|
15
|
+
$nin: [
|
|
16
|
+
chevre.factory.taskName.DeleteTransaction,
|
|
17
|
+
chevre.factory.taskName.ImportEventCapacitiesFromCOA,
|
|
18
|
+
chevre.factory.taskName.ImportEventsFromCOA,
|
|
19
|
+
chevre.factory.taskName.AcceptCOAOffer,
|
|
20
|
+
chevre.factory.taskName.CheckMovieTicket,
|
|
21
|
+
chevre.factory.taskName.AuthorizePayment,
|
|
22
|
+
chevre.factory.taskName.PublishPaymentUrl
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
executor: { name: 'sample' },
|
|
26
|
+
runsAt: {
|
|
27
|
+
$lt: moment()
|
|
28
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
29
|
+
.add(-2, 'years')
|
|
30
|
+
// .add(-60, 'seconds')
|
|
31
|
+
.toDate()
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// tslint:disable-next-line:no-null-keyword
|
|
36
|
+
console.dir(task, { depth: null });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main()
|
|
40
|
+
.then()
|
|
41
|
+
.catch(console.error);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
/**
|
|
3
|
-
* イベント集計タスク実行
|
|
4
|
-
*/
|
|
5
2
|
import { chevre } from '../../../lib/index';
|
|
6
3
|
|
|
7
4
|
import * as mongoose from 'mongoose';
|
|
8
5
|
import * as redis from 'redis';
|
|
9
6
|
|
|
10
|
-
export async function
|
|
7
|
+
export async function executeTaskIfExists() {
|
|
11
8
|
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
12
9
|
socket: {
|
|
13
10
|
port: Number(<string>process.env.REDIS_PORT),
|
|
@@ -21,8 +18,8 @@ export async function aggregateScreeningEvent() {
|
|
|
21
18
|
|
|
22
19
|
let count = 0;
|
|
23
20
|
|
|
24
|
-
const MAX_NUBMER_OF_PARALLEL_TASKS =
|
|
25
|
-
const INTERVAL_MILLISECONDS =
|
|
21
|
+
const MAX_NUBMER_OF_PARALLEL_TASKS = 1;
|
|
22
|
+
const INTERVAL_MILLISECONDS = 1000;
|
|
26
23
|
|
|
27
24
|
setInterval(
|
|
28
25
|
async () => {
|
|
@@ -34,9 +31,21 @@ export async function aggregateScreeningEvent() {
|
|
|
34
31
|
|
|
35
32
|
try {
|
|
36
33
|
console.log('executing...', count);
|
|
37
|
-
await (await chevre.service.task.createService()).
|
|
38
|
-
name: chevre.factory.taskName.AggregateScreeningEvent,
|
|
39
|
-
executor: { name: 'sample' }
|
|
34
|
+
await (await chevre.service.task.createService()).executeOneIfExists({
|
|
35
|
+
// name: chevre.factory.taskName.AggregateScreeningEvent,
|
|
36
|
+
executor: { name: 'sample' },
|
|
37
|
+
runsAt: { $lt: new Date() },
|
|
38
|
+
name: {
|
|
39
|
+
$nin: [
|
|
40
|
+
chevre.factory.taskName.DeleteTransaction,
|
|
41
|
+
chevre.factory.taskName.ImportEventCapacitiesFromCOA,
|
|
42
|
+
chevre.factory.taskName.ImportEventsFromCOA,
|
|
43
|
+
chevre.factory.taskName.AcceptCOAOffer,
|
|
44
|
+
chevre.factory.taskName.CheckMovieTicket,
|
|
45
|
+
chevre.factory.taskName.AuthorizePayment,
|
|
46
|
+
chevre.factory.taskName.PublishPaymentUrl
|
|
47
|
+
]
|
|
48
|
+
}
|
|
40
49
|
})({
|
|
41
50
|
connection: mongoose.connection,
|
|
42
51
|
redisClient,
|
|
@@ -64,7 +73,7 @@ export async function aggregateScreeningEvent() {
|
|
|
64
73
|
);
|
|
65
74
|
}
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
executeTaskIfExists()
|
|
68
77
|
.then(() => {
|
|
69
78
|
console.log('success!');
|
|
70
79
|
})
|
|
@@ -0,0 +1,50 @@
|
|
|
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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
setInterval(
|
|
15
|
+
async () => {
|
|
16
|
+
const startTime = process.hrtime();
|
|
17
|
+
const task = await taskRepo.findExecutableOne({
|
|
18
|
+
name: {
|
|
19
|
+
// $eq: chevre.factory.taskName.DeleteTransaction,
|
|
20
|
+
$nin: [
|
|
21
|
+
chevre.factory.taskName.DeleteTransaction,
|
|
22
|
+
chevre.factory.taskName.ImportEventCapacitiesFromCOA,
|
|
23
|
+
chevre.factory.taskName.ImportEventsFromCOA,
|
|
24
|
+
chevre.factory.taskName.AcceptCOAOffer,
|
|
25
|
+
chevre.factory.taskName.CheckMovieTicket,
|
|
26
|
+
chevre.factory.taskName.AuthorizePayment,
|
|
27
|
+
chevre.factory.taskName.PublishPaymentUrl
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
runsAt: {
|
|
31
|
+
$lt: moment()
|
|
32
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
33
|
+
.add(-60, 'seconds')
|
|
34
|
+
.toDate()
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const diff = process.hrtime(startTime);
|
|
38
|
+
console.log(`took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
|
|
39
|
+
|
|
40
|
+
// tslint:disable-next-line:no-null-keyword
|
|
41
|
+
console.dir(task?.id, { depth: null });
|
|
42
|
+
},
|
|
43
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
+
1000
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
main()
|
|
49
|
+
.then()
|
|
50
|
+
.catch(console.error);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
import * as mongoose from 'mongoose';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const expiresLt = moment()
|
|
15
|
+
.add(-1, 'hour')
|
|
16
|
+
.toDate();
|
|
17
|
+
const result = await taskRepo.makeExpiredMany({
|
|
18
|
+
expiresLt
|
|
19
|
+
});
|
|
20
|
+
console.log('result:', result);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main()
|
|
24
|
+
.then(() => {
|
|
25
|
+
console.log('success!');
|
|
26
|
+
})
|
|
27
|
+
.catch(console.error);
|
|
@@ -0,0 +1,28 @@
|
|
|
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, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const result = await transactionRepo.makeOneExpiredIfExists({
|
|
15
|
+
expires: {
|
|
16
|
+
$lt: moment()
|
|
17
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
18
|
+
.add(-60, 'seconds')
|
|
19
|
+
.toDate()
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('result:', result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then()
|
|
28
|
+
.catch(console.error);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: {
|
|
18
|
+
$in: [
|
|
19
|
+
chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
20
|
+
chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
// _id: { $eq: '5f9a4fed4f3709000abe6415' }
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
_id: 1,
|
|
27
|
+
availableChannel: 1,
|
|
28
|
+
productID: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
typeOf: 1
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('docs found');
|
|
34
|
+
|
|
35
|
+
let i = 0;
|
|
36
|
+
let updateCount = 0;
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
const paymentService: Pick<
|
|
40
|
+
chevre.factory.service.paymentService.IService,
|
|
41
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf'
|
|
42
|
+
> = doc.toObject();
|
|
43
|
+
|
|
44
|
+
console.log(
|
|
45
|
+
'alreadyMigrated?', paymentService.project.id, paymentService.productID, i);
|
|
46
|
+
if (typeof paymentService.id !== 'string') {
|
|
47
|
+
throw new Error('id must be string');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let alreadyMigrated = false;
|
|
51
|
+
try {
|
|
52
|
+
const channelId = paymentService.availableChannel?.id;
|
|
53
|
+
if (typeof channelId === 'string' && channelId !== '') {
|
|
54
|
+
if (paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.CreditCard) {
|
|
55
|
+
const existingChannel = await paymentServiceRepo.findAvailableChannelCreditCard({
|
|
56
|
+
project: { id: paymentService.project.id },
|
|
57
|
+
id: paymentService.id
|
|
58
|
+
});
|
|
59
|
+
if (typeof existingChannel.id === 'string'
|
|
60
|
+
&& existingChannel.id === channelId) {
|
|
61
|
+
alreadyMigrated = true;
|
|
62
|
+
}
|
|
63
|
+
} else if (paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
64
|
+
const existingChannel = await paymentServiceRepo.findAvailableChannelMovieTicket({
|
|
65
|
+
project: { id: paymentService.project.id },
|
|
66
|
+
id: paymentService.id
|
|
67
|
+
});
|
|
68
|
+
if (typeof existingChannel.id === 'string'
|
|
69
|
+
&& existingChannel.id === channelId) {
|
|
70
|
+
alreadyMigrated = true;
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
throw new Error('invalid paymentServiceType');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
// no op
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (alreadyMigrated) {
|
|
81
|
+
console.log(
|
|
82
|
+
'already migrated.', paymentService.project.id, paymentService.productID, i);
|
|
83
|
+
} else {
|
|
84
|
+
if (paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
85
|
+
|| paymentService.typeOf === chevre.factory.service.paymentService.PaymentServiceType.MovieTicket) {
|
|
86
|
+
// await paymentServiceRepo.migrateChannelId({
|
|
87
|
+
// project: { id: paymentService.project.id },
|
|
88
|
+
// id: paymentService.id,
|
|
89
|
+
// typeOf: paymentService.typeOf
|
|
90
|
+
// });
|
|
91
|
+
updateCount += 1;
|
|
92
|
+
console.log(
|
|
93
|
+
'updated.',
|
|
94
|
+
paymentService.project.id, paymentService.productID, i);
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error('invalid paymentServiceType');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
console.log(i, 'docs checked');
|
|
102
|
+
console.log(updateCount, 'docs updated');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
main()
|
|
106
|
+
.then()
|
|
107
|
+
.catch(console.error);
|
|
@@ -0,0 +1,187 @@
|
|
|
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 excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
type IAcceptPayAction = chevre.factory.action.accept.pay.IAction;
|
|
11
|
+
|
|
12
|
+
// tslint:disable-next-line:max-func-body-length
|
|
13
|
+
async function main() {
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
// 注文取引が中止、期限切れであれば、返金タスクを作成
|
|
17
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
18
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
19
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
20
|
+
|
|
21
|
+
const runsAt = new Date();
|
|
22
|
+
const cursor = transactionRepo.getCursor(
|
|
23
|
+
{
|
|
24
|
+
status: {
|
|
25
|
+
$in: [
|
|
26
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
27
|
+
chevre.factory.transactionStatusType.Expired
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
31
|
+
startDate: {
|
|
32
|
+
$gte: moment('2025-02-22T15:00:00Z')
|
|
33
|
+
.toDate(),
|
|
34
|
+
$lte: moment('2025-02-22T17:00:00Z')
|
|
35
|
+
.toDate()
|
|
36
|
+
}
|
|
37
|
+
// _id: { $eq: 'cinerino' }
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
_id: 1,
|
|
41
|
+
status: 1,
|
|
42
|
+
object: 1,
|
|
43
|
+
typeOf: 1,
|
|
44
|
+
project: 1,
|
|
45
|
+
startDate: 1,
|
|
46
|
+
seller: 1,
|
|
47
|
+
agent: 1
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
console.log('docs found');
|
|
51
|
+
|
|
52
|
+
let i = 0;
|
|
53
|
+
let updateCount = 0;
|
|
54
|
+
// tslint:disable-next-line:max-func-body-length
|
|
55
|
+
await cursor.eachAsync(async (doc) => {
|
|
56
|
+
|
|
57
|
+
i += 1;
|
|
58
|
+
const transaction: Pick<chevre.factory.transaction.placeOrder.ITransaction,
|
|
59
|
+
'id' | 'typeOf' | 'object' | 'status' | 'project' | 'startDate' | 'seller' | 'agent'
|
|
60
|
+
> = doc.toObject();
|
|
61
|
+
|
|
62
|
+
// console.log(
|
|
63
|
+
// 'alreadyRefunded?', transaction.project.id, transaction.status, transaction.typeOf, transaction.startDate, i);
|
|
64
|
+
|
|
65
|
+
const acceptPayActions = (<Pick<IAcceptPayAction, 'object'>[]>await actionRepo.search(
|
|
66
|
+
{
|
|
67
|
+
project: { id: { $eq: transaction.project.id } },
|
|
68
|
+
typeOf: { $eq: chevre.factory.actionType.AcceptAction },
|
|
69
|
+
actionStatus: { $in: [chevre.factory.actionStatusType.CompletedActionStatus] },
|
|
70
|
+
purpose: { id: { $in: [transaction.id] } },
|
|
71
|
+
object: {
|
|
72
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay }
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
['object']
|
|
76
|
+
));
|
|
77
|
+
|
|
78
|
+
for (const acceptPayAction of acceptPayActions) {
|
|
79
|
+
const paymentMethodId = acceptPayAction.object.transactionNumber;
|
|
80
|
+
const paymentMethodType = acceptPayAction.object.object.paymentMethod.identifier;
|
|
81
|
+
|
|
82
|
+
let alreadyRefunded = false;
|
|
83
|
+
const refundAction = (await actionRepo.search(
|
|
84
|
+
{
|
|
85
|
+
limit: 1,
|
|
86
|
+
page: 1,
|
|
87
|
+
typeOf: chevre.factory.actionType.RefundAction,
|
|
88
|
+
object: {
|
|
89
|
+
paymentMethod: {
|
|
90
|
+
paymentMethodId: { $eq: paymentMethodId }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
['id']
|
|
95
|
+
)).shift();
|
|
96
|
+
if (refundAction !== undefined) {
|
|
97
|
+
alreadyRefunded = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (alreadyRefunded) {
|
|
101
|
+
// console.log(
|
|
102
|
+
// 'already migrated.',
|
|
103
|
+
// transaction.project.id, transaction.status, transaction.typeOf, paymentMethodId, i);
|
|
104
|
+
} else {
|
|
105
|
+
if (typeof paymentMethodType === 'string' && paymentMethodType.length > 0
|
|
106
|
+
// && paymentMethodId === '792043512179199'
|
|
107
|
+
) {
|
|
108
|
+
// create task
|
|
109
|
+
const purpose: chevre.factory.action.trade.refund.IPurposeAsPlaceOrder = {
|
|
110
|
+
typeOf: transaction.typeOf, id: transaction.id
|
|
111
|
+
};
|
|
112
|
+
const data: Omit<chevre.factory.task.refund.IData, 'purpose'> & {
|
|
113
|
+
purpose: chevre.factory.action.trade.refund.IPurposeAsPlaceOrder;
|
|
114
|
+
} = {
|
|
115
|
+
project: transaction.project,
|
|
116
|
+
typeOf: chevre.factory.actionType.RefundAction,
|
|
117
|
+
agent: {
|
|
118
|
+
typeOf: transaction.seller.typeOf,
|
|
119
|
+
name: (typeof transaction.seller.name === 'string')
|
|
120
|
+
? transaction.seller.name
|
|
121
|
+
: String(transaction.seller.name?.ja),
|
|
122
|
+
id: transaction.seller.id
|
|
123
|
+
},
|
|
124
|
+
recipient: {
|
|
125
|
+
typeOf: transaction.agent.typeOf,
|
|
126
|
+
id: transaction.agent.id
|
|
127
|
+
// name: transaction.agent.name
|
|
128
|
+
},
|
|
129
|
+
object: [{
|
|
130
|
+
typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
131
|
+
id: acceptPayAction.object.object.id,
|
|
132
|
+
paymentMethod: {
|
|
133
|
+
additionalProperty: [],
|
|
134
|
+
name: paymentMethodType,
|
|
135
|
+
typeOf: paymentMethodType,
|
|
136
|
+
paymentMethodId: paymentMethodId
|
|
137
|
+
},
|
|
138
|
+
refundFee: 0
|
|
139
|
+
}],
|
|
140
|
+
purpose,
|
|
141
|
+
instrument: []
|
|
142
|
+
|
|
143
|
+
};
|
|
144
|
+
const refundTask: Omit<chevre.factory.task.refund.IAttributes, 'data'> & {
|
|
145
|
+
data: Omit<chevre.factory.task.refund.IData, 'purpose'> & {
|
|
146
|
+
purpose: chevre.factory.action.trade.refund.IPurposeAsPlaceOrder;
|
|
147
|
+
};
|
|
148
|
+
} = {
|
|
149
|
+
name: chevre.factory.taskName.Refund,
|
|
150
|
+
data,
|
|
151
|
+
status: chevre.factory.taskStatus.Ready,
|
|
152
|
+
runsAt,
|
|
153
|
+
project: transaction.project,
|
|
154
|
+
remainingNumberOfTries: 10,
|
|
155
|
+
numberOfTried: 0,
|
|
156
|
+
executionResults: []
|
|
157
|
+
};
|
|
158
|
+
console.log(
|
|
159
|
+
'creating task...',
|
|
160
|
+
transaction.project.id, transaction.status,
|
|
161
|
+
transaction.typeOf, transaction.startDate,
|
|
162
|
+
acceptPayAction.object.transactionNumber,
|
|
163
|
+
i,
|
|
164
|
+
refundTask
|
|
165
|
+
);
|
|
166
|
+
await taskRepo.saveMany([refundTask], { emitImmediately: false });
|
|
167
|
+
updateCount += 1;
|
|
168
|
+
console.log(
|
|
169
|
+
'created.',
|
|
170
|
+
transaction.project.id, transaction.status,
|
|
171
|
+
transaction.typeOf, transaction.startDate,
|
|
172
|
+
acceptPayAction.object.transactionNumber,
|
|
173
|
+
acceptPayAction.object.transactionNumber,
|
|
174
|
+
i
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
console.log(i, 'docs checked');
|
|
182
|
+
console.log(updateCount, 'docs updated');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
main()
|
|
186
|
+
.then()
|
|
187
|
+
.catch(console.error);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const webSiteRepo = await chevre.repository.WebSite.createInstance(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const creatingWebSites: Pick<
|
|
16
|
+
chevre.factory.creativeWork.certification.webSite.ICertification,
|
|
17
|
+
'about' | 'certificationStatus' | 'project' | 'auditDate'
|
|
18
|
+
>[] = [
|
|
19
|
+
// {
|
|
20
|
+
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
21
|
+
// about: {
|
|
22
|
+
// identifier: 'xxx',
|
|
23
|
+
// typeOf: chevre.factory.creativeWorkType.WebSite
|
|
24
|
+
// },
|
|
25
|
+
// certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
|
|
26
|
+
// },
|
|
27
|
+
// {
|
|
28
|
+
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
29
|
+
// about: {
|
|
30
|
+
// identifier: 'xxx',
|
|
31
|
+
// typeOf: chevre.factory.creativeWorkType.WebSite
|
|
32
|
+
// },
|
|
33
|
+
// certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationInactive
|
|
34
|
+
// }
|
|
35
|
+
];
|
|
36
|
+
for (const creatingWebSite of creatingWebSites) {
|
|
37
|
+
console.log('updating...', creatingWebSite);
|
|
38
|
+
try {
|
|
39
|
+
const { id } = await webSiteRepo.save({
|
|
40
|
+
attributes: creatingWebSite
|
|
41
|
+
});
|
|
42
|
+
await webSiteRepo.save({
|
|
43
|
+
id,
|
|
44
|
+
attributes: {
|
|
45
|
+
...creatingWebSite,
|
|
46
|
+
auditDate: new Date(),
|
|
47
|
+
certificationStatus: chevre.factory.CertificationStatusEnumeration.CertificationActive
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
console.log('updated.');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
main()
|
|
58
|
+
.then()
|
|
59
|
+
.catch(console.error);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import { chevre } from '../../../lib/index';
|
|
4
|
+
|
|
5
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const limit = 10;
|
|
13
|
+
const page = 1;
|
|
14
|
+
const docs = await paymentServiceRepo.projectFields(
|
|
15
|
+
{
|
|
16
|
+
limit,
|
|
17
|
+
page,
|
|
18
|
+
project: { id: { $eq: project.id } },
|
|
19
|
+
availableChannel: { serviceUrl: { $eq: 'xxx' } }
|
|
20
|
+
},
|
|
21
|
+
['availableChannel', 'productID']
|
|
22
|
+
);
|
|
23
|
+
// tslint:disable-next-line:no-null-keyword
|
|
24
|
+
console.dir(docs, { depth: null });
|
|
25
|
+
console.log(docs.length, 'docs found');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
main()
|
|
29
|
+
.then(() => {
|
|
30
|
+
console.log('success!');
|
|
31
|
+
})
|
|
32
|
+
.catch(console.error);
|