@chevre/domain 21.20.0-alpha.8 → 21.20.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/findTransactionById.ts +21 -0
- package/example/src/chevre/importCategoryCodesFromCOA.ts +2 -1
- package/example/src/chevre/importOffersFromCOA.ts +2 -1
- package/example/src/chevre/migrateActionInstrumentTransactionNumber.ts +93 -0
- package/example/src/chevre/migrateDeleteTransactionTasks.ts +119 -0
- package/example/src/chevre/migrateEventMakesOfferAvailableAtOrFrom.ts +87 -0
- package/example/src/chevre/migrateIAMMemberPOSRoles.ts +3 -2
- package/example/src/chevre/migrateOfferAvailableAtOrFrom.ts +63 -0
- package/example/src/chevre/{migrateOrderPaymentMethodIdentifier.ts → migrateOrderAcceptedOfferSerialNumber.ts} +18 -19
- package/example/src/chevre/onAssetTransactionStatusChanged.ts +36 -0
- package/example/src/chevre/retryTasks.ts +39 -0
- package/example/src/chevre/searchActions.ts +13 -7
- package/example/src/chevre/searchOrderAcceptedOffers.ts +13 -3
- package/example/src/chevre/searchOrders.ts +13 -15
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +28 -0
- package/example/src/chevre/sendOrder.ts +37 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -3
- package/example/src/verifyToken.ts +44 -0
- package/lib/chevre/credentials.d.ts +2 -0
- package/lib/chevre/credentials.js +4 -2
- package/lib/chevre/errorHandler.js +3 -0
- package/lib/chevre/factory/order.d.ts +1 -0
- package/lib/chevre/factory/order.js +2 -1
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +2 -1
- package/lib/chevre/factory/transaction.d.ts +10 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +58 -2
- package/lib/chevre/repo/acceptedOffer.js +100 -4
- package/lib/chevre/repo/accountingReport.d.ts +33 -7
- package/lib/chevre/repo/accountingReport.js +157 -5
- package/lib/chevre/repo/action.d.ts +32 -8
- package/lib/chevre/repo/action.js +114 -54
- package/lib/chevre/repo/event.d.ts +20 -0
- package/lib/chevre/repo/event.js +22 -0
- package/lib/chevre/repo/member.d.ts +8 -1
- package/lib/chevre/repo/member.js +7 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/action.js +25 -11
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +38 -11
- package/lib/chevre/repo/offer.d.ts +42 -0
- package/lib/chevre/repo/offer.js +35 -0
- package/lib/chevre/repo/order.js +43 -20
- package/lib/chevre/repo/orderInTransaction.d.ts +44 -0
- package/lib/chevre/repo/orderInTransaction.js +164 -0
- package/lib/chevre/repo/paymentServiceProvider.js +2 -1
- package/lib/chevre/repo/person.js +1 -4
- package/lib/chevre/repo/task.d.ts +26 -3
- package/lib/chevre/repo/task.js +61 -46
- package/lib/chevre/repo/transaction.d.ts +2 -2
- package/lib/chevre/repo/transaction.js +13 -36
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/aggregation/event/importFromCOA.js +5 -5
- package/lib/chevre/service/assetTransaction/pay/factory.js +1 -6
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +9 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +143 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions.d.ts +11 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +4 -165
- package/lib/chevre/service/assetTransaction/pay.d.ts +21 -6
- package/lib/chevre/service/assetTransaction/pay.js +64 -23
- package/lib/chevre/service/assetTransaction/reserve/factory.js +11 -14
- package/lib/chevre/service/assetTransaction/reserveCOA.d.ts +19 -0
- package/lib/chevre/service/assetTransaction/reserveCOA.js +46 -0
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +16 -24
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +71 -66
- package/lib/chevre/service/offer/any.d.ts +35 -0
- package/lib/chevre/service/offer/any.js +67 -0
- package/lib/chevre/service/offer/event/authorize.d.ts +7 -0
- package/lib/chevre/service/offer/event/authorize.js +27 -17
- package/lib/chevre/service/offer/event/cancel.d.ts +2 -0
- package/lib/chevre/service/offer/event/cancel.js +13 -1
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +11 -22
- package/lib/chevre/service/offer/event/importFromCOA.js +6 -8
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +24 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +54 -0
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +138 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.d.ts +39 -0
- package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +59 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.d.ts +25 -0
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +165 -0
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +10 -23
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +4 -89
- package/lib/chevre/service/offer/eventServiceByCOA.js +7 -292
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +10 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +49 -3
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +47 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product/factory.js +2 -5
- package/lib/chevre/service/offer/product.d.ts +2 -0
- package/lib/chevre/service/offer/product.js +11 -23
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +3 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +5 -5
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +12 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +206 -7
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +51 -53
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +10 -25
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +16 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +91 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +37 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +12 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +115 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +19 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +8 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +41 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +6 -10
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +116 -92
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +81 -84
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +18 -15
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +62 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -1
- package/lib/chevre/service/order/placeOrder.d.ts +3 -1
- package/lib/chevre/service/order/placeOrder.js +157 -50
- package/lib/chevre/service/order/returnOrder.js +25 -16
- package/lib/chevre/service/order/sendOrder.d.ts +5 -0
- package/lib/chevre/service/order/sendOrder.js +67 -33
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.js +15 -9
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +3 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.js +8 -5
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +2 -2
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -5
- package/lib/chevre/service/payment/any.js +3 -2
- package/lib/chevre/service/payment/creditCard.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +62 -68
- package/lib/chevre/service/payment/faceToFace.d.ts +1 -5
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -7
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +1 -3
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.d.ts +5 -0
- package/lib/chevre/service/payment.js +40 -5
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/checkInReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/checkInReservation.js +6 -5
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/factory.js +0 -8
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/searchByOrder.js +2 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -3
- package/lib/chevre/service/reserve/useReservation.js +10 -9
- package/lib/chevre/service/reserve/verifyToken4reservation.js +2 -0
- package/lib/chevre/service/task/confirmMoneyTransfer.js +4 -4
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +30 -8
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +176 -29
- package/lib/chevre/service/task/createAccountingReport.d.ts +6 -0
- package/lib/chevre/service/task/createAccountingReport.js +80 -0
- package/lib/chevre/service/task/importOffersFromCOA.js +2 -1
- package/lib/chevre/service/task/onAuthorizationCreated.js +0 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/pay.js +6 -0
- package/lib/chevre/service/task/placeOrder.js +9 -10
- package/lib/chevre/service/task/returnOrder.js +0 -3
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +3 -2
- package/lib/chevre/service/task/sendOrder.js +8 -4
- package/lib/chevre/service/task/useReservation.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +8 -12
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +2 -18
- package/lib/chevre/service/transaction/moneyTransfer.js +7 -6
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +17 -20
- package/lib/chevre/service/transaction/placeOrder.js +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +51 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +268 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +22 -44
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +14 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +41 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.d.ts +18 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishConfirmationNumberIfNotExist.js +42 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/publishOrderNumberIfNotExist.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +34 -37
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +13 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +19 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/start.js +46 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.d.ts +26 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateStartRequest.js +109 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +10 -23
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +20 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +11 -73
- package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -286
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +1 -2
- package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +0 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +8 -3
- package/lib/chevre/service/transaction/returnOrder/preStart.js +78 -50
- package/lib/chevre/service/transaction/returnOrder.js +3 -10
- package/lib/chevre/service.js +0 -10
- package/lib/chevre/settings.d.ts +7 -3
- package/lib/chevre/settings.js +13 -4
- package/package.json +5 -9
- package/example/src/chevre/cleanAccountingReports.ts +0 -57
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +0 -78
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +0 -11
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +0 -30
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.d.ts +0 -7
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +0 -82
- package/lib/chevre/service/util.d.ts +0 -19
- package/lib/chevre/service/util.js +0 -126
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const transaction = await transactionRepo.findById({
|
|
12
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
13
|
+
id: '65ab04d5206595479469f50c',
|
|
14
|
+
inclusion: ['endDate', 'id', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']
|
|
15
|
+
});
|
|
16
|
+
console.log('transaction:', transaction);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
main()
|
|
20
|
+
.then(console.log)
|
|
21
|
+
.catch(console.error);
|
|
@@ -9,7 +9,8 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
9
9
|
|
|
10
10
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
11
11
|
endpoint: chevre.credentials.coa.endpoint,
|
|
12
|
-
refreshToken: chevre.credentials.coa.refreshToken
|
|
12
|
+
refreshToken: chevre.credentials.coa.refreshToken,
|
|
13
|
+
useFetch: chevre.credentials.coa.useFetch
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
async function main() {
|
|
@@ -9,7 +9,8 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
9
9
|
|
|
10
10
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
11
11
|
endpoint: chevre.credentials.coa.endpoint,
|
|
12
|
-
refreshToken: chevre.credentials.coa.refreshToken
|
|
12
|
+
refreshToken: chevre.credentials.coa.refreshToken,
|
|
13
|
+
useFetch: chevre.credentials.coa.useFetch
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
async function main() {
|
|
@@ -0,0 +1,93 @@
|
|
|
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 = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = actionRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'instrument.transactionNumber': { $exists: false },
|
|
19
|
+
'object.typeOf': { $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
|
|
20
|
+
// 'project.id': { $eq: project.id },
|
|
21
|
+
startDate: {
|
|
22
|
+
$gte: moment()
|
|
23
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
.add(-12, 'months')
|
|
25
|
+
.toDate()
|
|
26
|
+
// $lte: moment('2023-08-01T21:20:43.133Z')
|
|
27
|
+
// .toDate()
|
|
28
|
+
},
|
|
29
|
+
// actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus }
|
|
30
|
+
'project.id': {
|
|
31
|
+
$ne: EXCLUDED_PROJECT_ID
|
|
32
|
+
}
|
|
33
|
+
// _id: { $eq: '6500d53f8f5a524f061b4771' }
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
startDate: 1,
|
|
37
|
+
object: 1,
|
|
38
|
+
project: 1,
|
|
39
|
+
instrument: 1,
|
|
40
|
+
purpose: 1
|
|
41
|
+
// result: 1
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
console.log('actions found');
|
|
45
|
+
|
|
46
|
+
let i = 0;
|
|
47
|
+
let updateCount = 0;
|
|
48
|
+
await cursor.eachAsync(async (doc) => {
|
|
49
|
+
i += 1;
|
|
50
|
+
const action: Pick<
|
|
51
|
+
chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
|
|
52
|
+
'startDate' | 'object' | 'project' | 'instrument' | 'id' | 'purpose'
|
|
53
|
+
> = doc.toObject();
|
|
54
|
+
|
|
55
|
+
const noPendingTransaction = false;
|
|
56
|
+
const transactionNumber = action.object.pendingTransaction?.transactionNumber;
|
|
57
|
+
// const transactionNumberFromResult = (<any>action).result?.responseBody?.tmpReserveNum;
|
|
58
|
+
if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
|
|
59
|
+
// noPendingTransaction = true;
|
|
60
|
+
// console.error('transactionNumber not found.', action.project.id, action.id, transactionNumber, action.startDate, i);
|
|
61
|
+
// if (typeof transactionNumberFromResult !== 'string' || transactionNumberFromResult.length === 0) {
|
|
62
|
+
// throw new Error('transactionNumber & transactionNumberFromResult not found.');
|
|
63
|
+
// } else {
|
|
64
|
+
// transactionNumber = transactionNumberFromResult;
|
|
65
|
+
// }
|
|
66
|
+
throw new Error('transactionNumber & transactionNumberFromResult not found.');
|
|
67
|
+
}
|
|
68
|
+
const alreadyMigrated = typeof action.instrument.transactionNumber === 'string'
|
|
69
|
+
&& action.instrument.transactionNumber === transactionNumber;
|
|
70
|
+
|
|
71
|
+
if (alreadyMigrated) {
|
|
72
|
+
console.log('already exist.', action.project.id, action.id, action.purpose.id, transactionNumber, action.startDate, i);
|
|
73
|
+
} else {
|
|
74
|
+
console.log('updating...', action.project.id, action.id, action.purpose.id, transactionNumber, action.startDate, i);
|
|
75
|
+
await actionRepo.fixInstrumentTransactionNumber({
|
|
76
|
+
id: action.id,
|
|
77
|
+
instrument: { transactionNumber },
|
|
78
|
+
...(noPendingTransaction)
|
|
79
|
+
? { object: { pendingTransaction: { transactionNumber } } }
|
|
80
|
+
: undefined
|
|
81
|
+
});
|
|
82
|
+
updateCount += 1;
|
|
83
|
+
console.log('updated.', action.project.id, action.id, transactionNumber, action.startDate, i);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
console.log(i, 'actions checked');
|
|
88
|
+
console.log(updateCount, 'actions updated');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main()
|
|
92
|
+
.then()
|
|
93
|
+
.catch(console.error);
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
// 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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
14
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = taskRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
name: { $eq: chevre.factory.taskName.DeleteTransaction },
|
|
19
|
+
status: { $eq: chevre.factory.taskStatus.Ready },
|
|
20
|
+
runsAt: {
|
|
21
|
+
$gte: moment()
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
.add(150, 'days')
|
|
24
|
+
.toDate(),
|
|
25
|
+
$lte: moment()
|
|
26
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
27
|
+
.add(200, 'days')
|
|
28
|
+
.toDate()
|
|
29
|
+
}
|
|
30
|
+
// _id: { $eq: '64aba5f37b8b8ef9eca60be5' }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
_id: 1,
|
|
34
|
+
project: 1,
|
|
35
|
+
data: 1,
|
|
36
|
+
status: 1,
|
|
37
|
+
name: 1,
|
|
38
|
+
runsAt: 1
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
console.log('tasks found');
|
|
42
|
+
|
|
43
|
+
let i = 0;
|
|
44
|
+
let updateCount = 0;
|
|
45
|
+
await cursor.eachAsync(async (doc) => {
|
|
46
|
+
i += 1;
|
|
47
|
+
const deleteTransactionTask: Pick<
|
|
48
|
+
chevre.factory.task.deleteTransaction.ITask,
|
|
49
|
+
'id' | 'project' | 'data' | 'status' | 'name' | 'runsAt'
|
|
50
|
+
> = doc.toObject();
|
|
51
|
+
|
|
52
|
+
let placeOrderTransactionId: string | undefined;
|
|
53
|
+
if (deleteTransactionTask.data.object.typeOf === chevre.factory.transactionType.PlaceOrder) {
|
|
54
|
+
if (deleteTransactionTask.data.object.specifyingMethod === chevre.factory.task.deleteTransaction.SpecifyingMethod.Id) {
|
|
55
|
+
placeOrderTransactionId = deleteTransactionTask.data.object.id;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let alreadyMigrated = true;
|
|
60
|
+
let runsAtExpected: moment.Moment | undefined;
|
|
61
|
+
if (typeof placeOrderTransactionId === 'string') {
|
|
62
|
+
const { endDate, status } = await transactionRepo.findById({
|
|
63
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
64
|
+
id: placeOrderTransactionId,
|
|
65
|
+
inclusion: ['endDate', 'status'],
|
|
66
|
+
exclusion: []
|
|
67
|
+
});
|
|
68
|
+
runsAtExpected = moment(endDate)
|
|
69
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
70
|
+
.add(180, 'days');
|
|
71
|
+
|
|
72
|
+
if (status !== chevre.factory.transactionStatusType.Confirmed) {
|
|
73
|
+
const taskRunsTooLate = moment(deleteTransactionTask.runsAt)
|
|
74
|
+
.isAfter(runsAtExpected);
|
|
75
|
+
const diff = moment(deleteTransactionTask.runsAt)
|
|
76
|
+
.diff(moment(endDate));
|
|
77
|
+
console.log('taskRunsTooLate?:', taskRunsTooLate, placeOrderTransactionId, endDate, status, diff.toLocaleString());
|
|
78
|
+
if (taskRunsTooLate) {
|
|
79
|
+
alreadyMigrated = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (alreadyMigrated) {
|
|
85
|
+
console.log(
|
|
86
|
+
'already exist.',
|
|
87
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
88
|
+
i, updateCount);
|
|
89
|
+
} else {
|
|
90
|
+
console.log(
|
|
91
|
+
'updating...',
|
|
92
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
93
|
+
i, updateCount, runsAtExpected);
|
|
94
|
+
if (runsAtExpected !== undefined) {
|
|
95
|
+
await taskRepo.taskModel.findByIdAndUpdate(
|
|
96
|
+
deleteTransactionTask.id,
|
|
97
|
+
{
|
|
98
|
+
$set: {
|
|
99
|
+
runsAt: runsAtExpected.toDate()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
.exec();
|
|
104
|
+
}
|
|
105
|
+
updateCount += 1;
|
|
106
|
+
console.log(
|
|
107
|
+
'updated.',
|
|
108
|
+
deleteTransactionTask.project.id, deleteTransactionTask.name, deleteTransactionTask.id, deleteTransactionTask.runsAt,
|
|
109
|
+
i, updateCount, runsAtExpected);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log(i, 'tasks checked');
|
|
114
|
+
console.log(updateCount, 'tasks updated');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
main()
|
|
118
|
+
.then()
|
|
119
|
+
.catch(console.error);
|
|
@@ -0,0 +1,87 @@
|
|
|
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 OLD_CLIENT = String(process.env.OLD_CLIENT);
|
|
8
|
+
const NEW_CLIENT = String(process.env.NEW_CLIENT);
|
|
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 eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'project.id': { $eq: project.id },
|
|
19
|
+
// _id: { $eq: 'als04raei' },
|
|
20
|
+
'offers.seller.makesOffer.availableAtOrFrom.id': { $eq: OLD_CLIENT },
|
|
21
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
_id: 1,
|
|
25
|
+
offers: 1,
|
|
26
|
+
project: 1,
|
|
27
|
+
startDate: 1
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
console.log('events found');
|
|
31
|
+
|
|
32
|
+
let i = 0;
|
|
33
|
+
let updateCount = 0;
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const event: Pick<
|
|
37
|
+
chevre.factory.event.screeningEvent.IEvent,
|
|
38
|
+
'id' | 'offers' | 'project' | 'startDate'
|
|
39
|
+
> = doc.toObject();
|
|
40
|
+
|
|
41
|
+
const eventOffers = <chevre.factory.event.screeningEvent.IOffer>event.offers;
|
|
42
|
+
const alreadyMigrated = eventOffers.seller.makesOffer.some(
|
|
43
|
+
({ availableAtOrFrom }) => availableAtOrFrom?.some((({ id }) => id === NEW_CLIENT))
|
|
44
|
+
);
|
|
45
|
+
const offerOnOldClient = eventOffers.seller.makesOffer.find(
|
|
46
|
+
({ availableAtOrFrom }) => availableAtOrFrom?.some((({ id }) => id === OLD_CLIENT))
|
|
47
|
+
);
|
|
48
|
+
if (offerOnOldClient === undefined) {
|
|
49
|
+
throw new Error('!oldClientExists');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (alreadyMigrated) {
|
|
53
|
+
await eventRepo.deleteAvailableAtOrFrom({
|
|
54
|
+
id: String(event.id),
|
|
55
|
+
offers: {
|
|
56
|
+
seller: {
|
|
57
|
+
makesOffer: { availableAtOrFrom: { id: OLD_CLIENT } }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
console.log('already exist.', event.project.id, event.id, event.startDate, i);
|
|
62
|
+
} else {
|
|
63
|
+
const offerNewOldClient: chevre.factory.event.screeningEvent.ISellerMakesOffer = {
|
|
64
|
+
...offerOnOldClient,
|
|
65
|
+
availableAtOrFrom: [{ id: NEW_CLIENT }]
|
|
66
|
+
};
|
|
67
|
+
console.log('updating...', event.project.id, event.id, event.startDate, i);
|
|
68
|
+
await eventRepo.addAvailableAtOrFrom({
|
|
69
|
+
id: String(event.id),
|
|
70
|
+
offers: {
|
|
71
|
+
seller: {
|
|
72
|
+
makesOffer: offerNewOldClient
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
updateCount += 1;
|
|
77
|
+
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
console.log(i, 'offers checked');
|
|
82
|
+
console.log(updateCount, 'offers updated');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
main()
|
|
86
|
+
.then()
|
|
87
|
+
.catch(console.error);
|
|
@@ -46,7 +46,7 @@ async function main() {
|
|
|
46
46
|
throw new Error('has no customer role!');
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const newHasRole: chevre.factory.iam.
|
|
49
|
+
const newHasRole: chevre.factory.iam.IMemberRole[] = iamMember.member.hasRole;
|
|
50
50
|
newHasRole.push({ roleName: ROLE_NAME.POS, typeOf: chevre.factory.iam.RoleType.OrganizationRole });
|
|
51
51
|
console.log(
|
|
52
52
|
'updating reservation...',
|
|
@@ -60,7 +60,8 @@ async function main() {
|
|
|
60
60
|
typeOf: chevre.factory.organizationType.Project
|
|
61
61
|
},
|
|
62
62
|
hasRole: newHasRole
|
|
63
|
-
}
|
|
63
|
+
},
|
|
64
|
+
$unset: {}
|
|
64
65
|
});
|
|
65
66
|
updateCount += 1;
|
|
66
67
|
console.log(
|
|
@@ -0,0 +1,63 @@
|
|
|
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 OLD_CLIENT = String(process.env.OLD_CLIENT);
|
|
8
|
+
const NEW_CLIENT = String(process.env.NEW_CLIENT);
|
|
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 offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = offerRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'project.id': { $eq: project.id },
|
|
19
|
+
// _id: { $eq: 'blqm9a6ui' },
|
|
20
|
+
'offers.availableAtOrFrom.id': { $eq: OLD_CLIENT }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
_id: 1,
|
|
24
|
+
offers: 1,
|
|
25
|
+
project: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('offers found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let updateCount = 0;
|
|
32
|
+
await cursor.eachAsync(async (doc) => {
|
|
33
|
+
i += 1;
|
|
34
|
+
const aggregateOffer: chevre.factory.aggregateOffer.IAggregateOffer = doc.toObject();
|
|
35
|
+
|
|
36
|
+
const alreadyMigrated = aggregateOffer.offers[0].availableAtOrFrom?.some(({ id }) => id === NEW_CLIENT);
|
|
37
|
+
console.log(aggregateOffer.offers[0].availableAtOrFrom, i);
|
|
38
|
+
|
|
39
|
+
if (alreadyMigrated) {
|
|
40
|
+
await offerRepo.deleteAvailableAtOrFrom({
|
|
41
|
+
id: String(aggregateOffer.id),
|
|
42
|
+
offers: { availableAtOrFrom: { id: OLD_CLIENT } }
|
|
43
|
+
});
|
|
44
|
+
console.log('already exist.', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
45
|
+
} else {
|
|
46
|
+
console.log('updating...', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
47
|
+
await offerRepo.addAvailableAtOrFrom({
|
|
48
|
+
id: String(aggregateOffer.id),
|
|
49
|
+
identifier: aggregateOffer.offers[0].identifier,
|
|
50
|
+
offers: { availableAtOrFrom: { id: NEW_CLIENT } }
|
|
51
|
+
});
|
|
52
|
+
updateCount += 1;
|
|
53
|
+
console.log('updated.', aggregateOffer.project.id, aggregateOffer.id, i);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(i, 'offers checked');
|
|
58
|
+
console.log(updateCount, 'offers updated');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main()
|
|
62
|
+
.then()
|
|
63
|
+
.catch(console.error);
|
|
@@ -10,14 +10,15 @@ import { chevre } from '../../../lib/index';
|
|
|
10
10
|
async function main() {
|
|
11
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
|
+
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
13
14
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
15
|
|
|
15
16
|
const cursor = orderRepo.getCursor(
|
|
16
17
|
{
|
|
17
|
-
'
|
|
18
|
-
'
|
|
18
|
+
// 'acceptedOffers.serialNumber': { $exists: false },
|
|
19
|
+
'acceptedOffers.itemOffered.reservationNumber': { $exists: true },
|
|
19
20
|
// 'project.id': { $eq: project.id },
|
|
20
|
-
// orderNumber: { $eq: '
|
|
21
|
+
// orderNumber: { $eq: 'KOB1-3749861-4732433' },
|
|
21
22
|
orderDate: {
|
|
22
23
|
$gte: moment()
|
|
23
24
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -33,7 +34,7 @@ async function main() {
|
|
|
33
34
|
orderDate: 1,
|
|
34
35
|
orderNumber: 1,
|
|
35
36
|
project: 1,
|
|
36
|
-
|
|
37
|
+
acceptedOffers: 1
|
|
37
38
|
}
|
|
38
39
|
);
|
|
39
40
|
console.log('orders found');
|
|
@@ -45,28 +46,26 @@ async function main() {
|
|
|
45
46
|
const order: Pick<
|
|
46
47
|
chevre.factory.order.IOrder,
|
|
47
48
|
'orderDate' | 'orderNumber' | 'project' | 'paymentMethods'
|
|
48
|
-
>
|
|
49
|
+
> & {
|
|
50
|
+
acceptedOffers: chevre.factory.order.IAcceptedOffer<chevre.factory.order.IReservation>[];
|
|
51
|
+
} = doc.toObject();
|
|
49
52
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
&&
|
|
54
|
-
// && invoice.paymentMethod.identifier === (<any>invoice).typeOf;
|
|
53
|
+
const alreadyMigrated = order.acceptedOffers.every((offer) => {
|
|
54
|
+
return typeof offer.serialNumber === 'string'
|
|
55
|
+
&& offer.serialNumber.length > 0
|
|
56
|
+
&& offer.itemOffered.reservationNumber === offer.serialNumber;
|
|
55
57
|
});
|
|
56
58
|
|
|
57
|
-
if (
|
|
58
|
-
console.log('noPayment.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
59
|
-
} else if (alreadyMigrated) {
|
|
59
|
+
if (alreadyMigrated) {
|
|
60
60
|
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
61
61
|
} else {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
await
|
|
62
|
+
for (const offer of order.acceptedOffers) {
|
|
63
|
+
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, offer.itemOffered.reservationNumber, i);
|
|
64
|
+
await acceptedOfferRepo.fixSerialNumber({
|
|
65
65
|
project: { id: order.project.id },
|
|
66
66
|
orderNumber: order.orderNumber,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
paymentMethod: { identifier: (<any>invoice).typeOf }
|
|
67
|
+
acceptedOffers: {
|
|
68
|
+
serialNumber: offer.itemOffered.reservationNumber
|
|
70
69
|
}
|
|
71
70
|
});
|
|
72
71
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
(await chevre.service.order.createService())
|
|
12
|
+
.onAssetTransactionStatusChanged({
|
|
13
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
14
|
+
object: {
|
|
15
|
+
typeOf: chevre.factory.assetTransactionType.Reserve,
|
|
16
|
+
transactionNumber: '863918387495116',
|
|
17
|
+
status: chevre.factory.transactionStatusType.Confirmed
|
|
18
|
+
},
|
|
19
|
+
purpose: {
|
|
20
|
+
confirmationNumber: '',
|
|
21
|
+
orderNumber: 'CIN1-3748070-2008463',
|
|
22
|
+
typeOf: chevre.factory.order.OrderType.Order
|
|
23
|
+
},
|
|
24
|
+
useOnOrderStatusChanged: true
|
|
25
|
+
})({
|
|
26
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
27
|
+
acceptedOffer: await chevre.repository.AcceptedOffer.createInstance(mongoose.connection),
|
|
28
|
+
order: await chevre.repository.Order.createInstance(mongoose.connection),
|
|
29
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
30
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then(console.log)
|
|
36
|
+
.catch(console.error);
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
const result = await taskRepo.taskModel.updateMany(
|
|
14
|
+
{
|
|
15
|
+
status: { $eq: chevre.factory.taskStatus.Aborted },
|
|
16
|
+
lastTriedAt: {
|
|
17
|
+
$gt: moment()
|
|
18
|
+
.add(-1, 'day')
|
|
19
|
+
.toDate()
|
|
20
|
+
},
|
|
21
|
+
name: { $eq: chevre.factory.taskName.TriggerWebhook },
|
|
22
|
+
'project.id': { $eq: project.id }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$set: {
|
|
26
|
+
status: chevre.factory.taskStatus.Ready,
|
|
27
|
+
remainingNumberOfTries: 20
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
.exec();
|
|
32
|
+
console.log('result:', result);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then(() => {
|
|
37
|
+
console.log('success!');
|
|
38
|
+
})
|
|
39
|
+
.catch(console.error);
|
|
@@ -5,20 +5,26 @@ import * as mongoose from 'mongoose';
|
|
|
5
5
|
|
|
6
6
|
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
async function main() {
|
|
9
13
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
14
|
|
|
11
15
|
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
16
|
const actions = await actionRepo.search(
|
|
13
17
|
{
|
|
14
|
-
|
|
18
|
+
limit: 1,
|
|
19
|
+
// typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
15
20
|
// project: { id: { $eq: project.id } },
|
|
16
|
-
object: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
21
|
+
// object: {
|
|
22
|
+
// movieTickets: {
|
|
23
|
+
// identifier: { $eq: '0947524082' },
|
|
24
|
+
// serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
instrument: { transactionNumber: { $eq: 'x' } }
|
|
22
28
|
},
|
|
23
29
|
['_id'],
|
|
24
30
|
[]
|
|
@@ -5,6 +5,10 @@ import { chevre } from '../../../lib/index';
|
|
|
5
5
|
|
|
6
6
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
8
12
|
async function main() {
|
|
9
13
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
14
|
|
|
@@ -16,10 +20,16 @@ async function main() {
|
|
|
16
20
|
limit: 10,
|
|
17
21
|
page: 1,
|
|
18
22
|
project: { id: { $eq: project.id } },
|
|
19
|
-
orderNumber: { $eq: '
|
|
20
|
-
acceptedOffers: {
|
|
23
|
+
orderNumber: { $eq: 'CIN7-9247770-0699829' },
|
|
24
|
+
acceptedOffers: {
|
|
25
|
+
itemOffered: {
|
|
26
|
+
typeOf: { $in: [chevre.factory.reservationType.EventReservation] },
|
|
27
|
+
reservationFor: { id: { $in: ['blpw1ew8f'] } },
|
|
28
|
+
reservedTicket: { ticketedSeat: { seatNumber: { $in: ['A-26', 'xxx'] } } }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
21
31
|
},
|
|
22
|
-
['itemOffered', '
|
|
32
|
+
['itemOffered', 'priceSpecification']
|
|
23
33
|
);
|
|
24
34
|
// tslint:disable-next-line:no-null-keyword
|
|
25
35
|
console.dir(acceptedOffers, { depth: 1 });
|