@chevre/domain 21.13.0-alpha.0 → 21.13.0-alpha.10
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/importEventsFromCOA.ts +11 -8
- package/example/src/chevre/searchEvents.ts +5 -2
- package/example/src/chevre/searchOrders.ts +1 -1
- package/example/src/chevre/transaction/findPaymentCardPermit.ts +2 -2
- package/example/src/chevre/transaction/processReturnOrder.ts +9 -9
- package/example/src/chevre/transaction/startExportTasks.ts +1 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +1 -1
- package/example/src/retryConnectMongo.ts +82 -0
- package/lib/chevre/errorHandler.d.ts +2 -2
- package/lib/chevre/errorHandler.js +38 -19
- package/lib/chevre/factory/transaction.d.ts +42 -0
- package/lib/chevre/factory/transaction.js +2 -0
- package/lib/chevre/index.d.ts +5 -5
- package/lib/chevre/index.js +30 -12
- package/lib/chevre/pecorinoapi.d.ts +2 -3
- package/lib/chevre/pecorinoapi.js +3 -3
- package/lib/chevre/repo/account.d.ts +1 -1
- package/lib/chevre/repo/accountTitle.d.ts +1 -1
- package/lib/chevre/repo/accountTransaction.d.ts +1 -1
- package/lib/chevre/repo/accountingReport.d.ts +1 -1
- package/lib/chevre/repo/accountingReport.js +1 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/additionalProperty.d.ts +1 -1
- package/lib/chevre/repo/aggregateOffer.d.ts +1 -1
- package/lib/chevre/repo/aggregation.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/categoryCode.d.ts +1 -1
- package/lib/chevre/repo/code.d.ts +1 -1
- package/lib/chevre/repo/comment.d.ts +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +8 -2
- package/lib/chevre/repo/creativeWork.js +36 -8
- package/lib/chevre/repo/customer.d.ts +1 -1
- package/lib/chevre/repo/emailMessage.d.ts +1 -1
- package/lib/chevre/repo/event.d.ts +5 -5
- package/lib/chevre/repo/event.js +7 -3
- package/lib/chevre/repo/member.d.ts +1 -1
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -1
- package/lib/chevre/repo/mongoose/writeConcern.d.ts +1 -1
- package/lib/chevre/repo/offer.js +2 -1
- package/lib/chevre/repo/offerCatalog.d.ts +1 -1
- package/lib/chevre/repo/offerCatalog.js +1 -1
- package/lib/chevre/repo/offerItemCondition.d.ts +1 -1
- package/lib/chevre/repo/order.d.ts +1 -8
- package/lib/chevre/repo/order.js +20 -17
- package/lib/chevre/repo/ownershipInfo.d.ts +1 -1
- package/lib/chevre/repo/ownershipInfo.js +1 -1
- package/lib/chevre/repo/permit.d.ts +1 -1
- package/lib/chevre/repo/place.d.ts +1 -1
- package/lib/chevre/repo/priceSpecification.d.ts +1 -1
- package/lib/chevre/repo/product.d.ts +1 -1
- package/lib/chevre/repo/project.d.ts +1 -1
- package/lib/chevre/repo/reservation.d.ts +3 -3
- package/lib/chevre/repo/role.d.ts +1 -1
- package/lib/chevre/repo/serviceOutput.d.ts +1 -1
- package/lib/chevre/repo/stockHolder.d.ts +2 -2
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/telemetry.d.ts +1 -1
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repo/trip.d.ts +1 -1
- package/lib/chevre/repository.d.ts +203 -171
- package/lib/chevre/repository.js +646 -269
- package/lib/chevre/service/account.d.ts +2 -2
- package/lib/chevre/service/accountTransaction/deposit.d.ts +2 -2
- package/lib/chevre/service/accountTransaction/transfer.d.ts +2 -2
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +2 -2
- package/lib/chevre/service/accountTransaction.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +7 -7
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.d.ts +6 -6
- package/lib/chevre/service/aggregation/event/findEventOffers.d.ts +4 -4
- package/lib/chevre/service/aggregation/event/importFromCOA.d.ts +1 -1
- package/lib/chevre/service/aggregation/project.d.ts +3 -3
- package/lib/chevre/service/aggregation/system.d.ts +5 -5
- package/lib/chevre/service/assetTransaction/cancelReservation.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
- package/lib/chevre/service/assetTransaction/moneyTransfer.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +5 -5
- package/lib/chevre/service/assetTransaction/pay/account/validation.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +15 -10
- package/lib/chevre/service/assetTransaction/refund.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/registerService.d.ts +8 -8
- package/lib/chevre/service/assetTransaction/registerService.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve.d.ts +14 -14
- package/lib/chevre/service/assetTransaction/reserve.js +2 -2
- package/lib/chevre/service/assetTransaction.d.ts +2 -2
- package/lib/chevre/service/code.d.ts +2 -2
- package/lib/chevre/service/code.js +1 -2
- package/lib/chevre/service/delivery.d.ts +5 -5
- package/lib/chevre/service/event/createEvent.d.ts +4 -4
- package/lib/chevre/service/event.d.ts +10 -7
- package/lib/chevre/service/event.js +26 -2
- package/lib/chevre/service/iam.d.ts +2 -2
- package/lib/chevre/service/moneyTransfer.d.ts +5 -5
- package/lib/chevre/service/moneyTransfer.js +14 -14
- package/lib/chevre/service/notification.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +15 -15
- package/lib/chevre/service/offer/event/cancel.d.ts +7 -7
- package/lib/chevre/service/offer/event/importFromCOA.d.ts +3 -3
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/validateAcceptedOffers.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA.d.ts +5 -5
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -6
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.d.ts +5 -5
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +3 -3
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +3 -3
- package/lib/chevre/service/offer/product.d.ts +14 -14
- package/lib/chevre/service/offer.d.ts +6 -6
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +10 -10
- package/lib/chevre/service/order/deleteOrder.d.ts +5 -5
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +5 -5
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -2
- package/lib/chevre/service/order/onOrderUpdated.d.ts +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +4 -4
- package/lib/chevre/service/order/placeOrder.d.ts +6 -6
- package/lib/chevre/service/order/returnOrder.d.ts +6 -6
- package/lib/chevre/service/order/sendOrder.d.ts +6 -6
- package/lib/chevre/service/payment/any/onPaid.d.ts +3 -3
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onPaid.d.ts +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged/onRefunded.d.ts +1 -1
- package/lib/chevre/service/payment/any/onPaymentStatusChanged.d.ts +2 -2
- package/lib/chevre/service/payment/any/onRefund.d.ts +3 -3
- package/lib/chevre/service/payment/any.d.ts +16 -11
- package/lib/chevre/service/payment/creditCard.d.ts +13 -8
- package/lib/chevre/service/payment/creditCard.js +24 -16
- package/lib/chevre/service/payment/faceToFace.d.ts +6 -6
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +5 -5
- package/lib/chevre/service/payment/movieTicket.d.ts +6 -6
- package/lib/chevre/service/payment/paymentCard.d.ts +7 -7
- package/lib/chevre/service/payment/paymentCard.js +10 -10
- package/lib/chevre/service/payment.d.ts +13 -9
- package/lib/chevre/service/permit.d.ts +2 -2
- package/lib/chevre/service/product.d.ts +3 -3
- package/lib/chevre/service/project.d.ts +16 -16
- package/lib/chevre/service/report/telemetry.d.ts +19 -16
- package/lib/chevre/service/reserve/cancelReservation.d.ts +3 -3
- package/lib/chevre/service/reserve/checkInReservation.d.ts +5 -5
- package/lib/chevre/service/reserve/confirmReservation.d.ts +4 -4
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +2 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/useReservation.d.ts +5 -5
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +1 -1
- package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +3 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +15 -15
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +2 -2
- package/lib/chevre/service/task/pay.js +9 -14
- package/lib/chevre/service/task/refund.js +10 -16
- package/lib/chevre/service/task/voidPayTransaction.js +10 -16
- package/lib/chevre/service/task/voidPayment.js +8 -12
- package/lib/chevre/service/task.d.ts +3 -3
- package/lib/chevre/service/task.js +12 -7
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +9 -9
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +11 -13
- package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +12 -39
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder.d.ts +10 -10
- package/lib/chevre/service/transaction/returnOrder.js +1 -1
- package/lib/chevre/service/transaction/validation.d.ts +1 -3
- package/lib/chevre/service/transaction.d.ts +2 -2
- package/lib/chevre/service.d.ts +75 -39
- package/lib/chevre/service.js +258 -39
- package/package.json +3 -3
- package/example/src/chevre/assetTransaction/searchGMOTrade.ts +0 -27
- package/example/src/chevre/countDelayedTasks.ts +0 -22
- package/example/src/chevre/countDelayedTransactions.ts +0 -60
- package/example/src/chevre/countMoneyTransferTransaction.ts +0 -36
- package/example/src/chevre/countOffers.ts +0 -32
- package/example/src/chevre/createDeleteTransactionTasks.ts +0 -108
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +0 -98
- package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +0 -126
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -365
- package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +0 -31
- package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +0 -32
- package/example/src/chevre/offer/searchAllByIdsAndOfferCatalogId.ts +0 -34
- package/example/src/chevre/offer/searchEventTicketOffers.ts +0 -54
- package/example/src/chevre/offer/searchOffersByCatalog.ts +0 -40
- package/example/src/chevre/processPay.ts +0 -90
- package/example/src/chevre/processRegisterMembership.ts +0 -110
- package/example/src/chevre/processRegisterPaymentCard.ts +0 -98
- package/example/src/chevre/processReserve.ts +0 -114
- package/example/src/chevre/publishConfirmationNumber.ts +0 -27
- package/example/src/chevre/publishPermitOwnershipInfoToken.ts +0 -56
- package/example/src/chevre/reIndex.ts +0 -25
- package/example/src/chevre/redisConfig.ts +0 -32
- package/example/src/chevre/saveTasks.ts +0 -41
- package/example/src/chevre/searchAbortedTasks.ts +0 -34
- package/example/src/chevre/searchAcceptedOfferIds.ts +0 -23
- package/example/src/chevre/searchOffersFromAggregateOffer.ts +0 -168
- package/example/src/chevre/searchOrdersWithUnwoundOffers.ts +0 -35
- package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +0 -58
- package/example/src/chevre/searchSendEmailActions.ts +0 -44
- package/example/src/chevre/searchTasks.ts +0 -31
- package/example/src/chevre/searchTransactions.ts +0 -25
- package/example/src/chevre/sendEmailMessage.ts +0 -80
- package/example/src/chevre/syncCatalogs2aggregateOffers.ts +0 -87
- package/example/src/chevre/task/executeTasks.ts +0 -26
- package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +0 -41
- package/example/src/chevre/updateOfferCatalogs.ts +0 -40
- package/example/src/chevre/updateTransaction.ts +0 -38
- package/example/src/playOnMoment.ts +0 -24
|
@@ -10,28 +10,31 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
10
10
|
async function main() {
|
|
11
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
|
-
const actionRepo =
|
|
14
|
-
const categoryCodeRepo =
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
13
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
15
|
+
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
16
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
17
|
+
const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
|
|
18
|
+
const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
|
|
18
19
|
|
|
19
|
-
await chevre.service.event.importFromCOA({
|
|
20
|
+
await (await chevre.service.event.createService()).importFromCOA({
|
|
20
21
|
project: {
|
|
21
22
|
id: project.id,
|
|
22
23
|
typeOf: chevre.factory.organizationType.Project
|
|
23
24
|
},
|
|
24
|
-
locationBranchCode: '
|
|
25
|
+
locationBranchCode: '120',
|
|
25
26
|
importFrom: moment()
|
|
26
27
|
.toDate(),
|
|
27
28
|
importThrough: moment()
|
|
28
29
|
.add(1, 'day')
|
|
29
30
|
.toDate(),
|
|
30
31
|
saveMovieTheater: false,
|
|
31
|
-
saveScreeningEventSeries:
|
|
32
|
+
saveScreeningEventSeries: true,
|
|
33
|
+
saveScreeningEventSeriesPeriodInMonth: 24
|
|
32
34
|
})({
|
|
33
35
|
action: actionRepo,
|
|
34
36
|
categoryCode: categoryCodeRepo,
|
|
37
|
+
creativeWork: creativeWorkRepo,
|
|
35
38
|
event: eventRepo,
|
|
36
39
|
place: placeRepo,
|
|
37
40
|
seller: sellerRepo
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
3
|
|
|
4
|
+
const startTime = process.hrtime();
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
6
|
+
const diff = process.hrtime(startTime);
|
|
7
|
+
console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
|
|
5
8
|
|
|
6
9
|
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
10
|
|
|
8
11
|
async function main() {
|
|
9
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
13
|
|
|
11
|
-
const eventRepo =
|
|
14
|
+
const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
12
15
|
|
|
13
16
|
const events = await eventRepo.search(
|
|
14
17
|
{
|
|
@@ -26,7 +29,7 @@ async function main() {
|
|
|
26
29
|
}
|
|
27
30
|
);
|
|
28
31
|
console.log(events);
|
|
29
|
-
console.log(events.length);
|
|
32
|
+
console.log(events.length, 'events found');
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
main()
|
|
@@ -8,7 +8,7 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const orderRepo =
|
|
11
|
+
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const orders = await orderRepo.search({
|
|
14
14
|
limit: 10,
|
|
@@ -9,8 +9,8 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const ownershipInfoRepo =
|
|
13
|
-
const productRepo =
|
|
12
|
+
const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
|
|
13
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
14
14
|
|
|
15
15
|
const result = await findPaymentCardPermit({
|
|
16
16
|
project: { id: project.id },
|
|
@@ -8,7 +8,7 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const result = await chevre.service.transaction.returnOrder.start({
|
|
11
|
+
const result = await (await chevre.service.transaction.createService()).returnOrder.start({
|
|
12
12
|
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
13
13
|
expiresInSeconds: 60,
|
|
14
14
|
agent: { id: 'xxx', typeOf: chevre.factory.creativeWorkType.WebApplication },
|
|
@@ -23,14 +23,14 @@ async function main() {
|
|
|
23
23
|
id: 'xxx'
|
|
24
24
|
}
|
|
25
25
|
})({
|
|
26
|
-
event:
|
|
27
|
-
merchantReturnPolicy:
|
|
28
|
-
offer:
|
|
29
|
-
offerItemCondition:
|
|
30
|
-
order:
|
|
31
|
-
reservation:
|
|
32
|
-
seller:
|
|
33
|
-
transaction:
|
|
26
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
27
|
+
merchantReturnPolicy: await chevre.repository.MerchantReturnPolicy.createInstance(mongoose.connection),
|
|
28
|
+
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
29
|
+
offerItemCondition: await chevre.repository.OfferItemCondition.createInstance(mongoose.connection),
|
|
30
|
+
order: await chevre.repository.Order.createInstance(mongoose.connection),
|
|
31
|
+
reservation: await chevre.repository.Reservation.createInstance(mongoose.connection),
|
|
32
|
+
seller: await chevre.repository.Seller.createInstance(mongoose.connection),
|
|
33
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
34
34
|
});
|
|
35
35
|
console.log(result);
|
|
36
36
|
}
|
|
@@ -6,7 +6,7 @@ import { chevre } from '../../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
|
-
const transactionRepo =
|
|
9
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
10
10
|
const result = await transactionRepo.startExportTasks({
|
|
11
11
|
typeOf: { $in: [chevre.factory.transactionType.PlaceOrder] },
|
|
12
12
|
status: chevre.factory.transactionStatusType.Confirmed,
|
|
@@ -9,7 +9,7 @@ const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
|
9
9
|
async function main() {
|
|
10
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
11
|
|
|
12
|
-
const transactionRepo =
|
|
12
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
let updateResult: any;
|
|
15
15
|
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
let connection: mongoose.Connection | undefined;
|
|
6
|
+
let mongoLastConnected: Date | undefined;
|
|
7
|
+
const MONGO_RETRY_INTERVAL_IN_MILLISECONDS = 1000;
|
|
8
|
+
const MONGO_GIVE_UP_IN_SECONDS = 5;
|
|
9
|
+
async function getConnection(): Promise<mongoose.Connection> {
|
|
10
|
+
if (mongoLastConnected instanceof Date) {
|
|
11
|
+
if (connection === undefined) {
|
|
12
|
+
if (moment()
|
|
13
|
+
.isAfter(moment(mongoLastConnected)
|
|
14
|
+
.add(MONGO_GIVE_UP_IN_SECONDS, 'seconds'))
|
|
15
|
+
) {
|
|
16
|
+
mongoLastConnected = void 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 最終接続から一定期間経過していればリトライ
|
|
20
|
+
connection = await new Promise<mongoose.Connection>((resolve, reject) => {
|
|
21
|
+
setTimeout(
|
|
22
|
+
async () => {
|
|
23
|
+
console.log('retrying...', mongoLastConnected);
|
|
24
|
+
try {
|
|
25
|
+
resolve(await getConnection());
|
|
26
|
+
} catch (error) {
|
|
27
|
+
reject(error);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
MONGO_RETRY_INTERVAL_IN_MILLISECONDS
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
mongoLastConnected = new Date();
|
|
36
|
+
console.log('creating connection...', mongoLastConnected);
|
|
37
|
+
if (connection === undefined) {
|
|
38
|
+
connection = await new Promise<mongoose.Connection>((resolve) => {
|
|
39
|
+
setTimeout(
|
|
40
|
+
async () => {
|
|
41
|
+
resolve(await mongoose.createConnection(<string>process.env.MONGOLAB_URI, { autoIndex: false }));
|
|
42
|
+
},
|
|
43
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
+
2000
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
// throw new Error('failed in createConnection')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return connection;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getConnection()
|
|
55
|
+
.then(() => {
|
|
56
|
+
console.log('sucess!', mongoose.connections.length);
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
console.error(error, mongoose.connections.length);
|
|
60
|
+
});
|
|
61
|
+
getConnection()
|
|
62
|
+
.then(() => {
|
|
63
|
+
console.log('sucess!', mongoose.connections.length);
|
|
64
|
+
})
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
console.error(error, mongoose.connections.length);
|
|
67
|
+
});
|
|
68
|
+
getConnection()
|
|
69
|
+
.then(() => {
|
|
70
|
+
console.log('sucess!', mongoose.connections.length);
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
console.error(error, mongoose.connections.length);
|
|
74
|
+
});
|
|
75
|
+
// setInterval(
|
|
76
|
+
// () => {
|
|
77
|
+
// getConnection()
|
|
78
|
+
// .then(console.log)
|
|
79
|
+
// .catch(console.error);
|
|
80
|
+
// },
|
|
81
|
+
// 1000
|
|
82
|
+
// );
|
|
@@ -3,8 +3,8 @@ export declare enum MongoErrorCode {
|
|
|
3
3
|
MaxTimeMSExpired = 50,
|
|
4
4
|
ExceededTimeLimit = 262
|
|
5
5
|
}
|
|
6
|
-
export declare function isMongoError(error: unknown): boolean
|
|
7
|
-
export declare function handleMongoError(error: unknown): unknown
|
|
6
|
+
export declare function isMongoError(error: unknown): Promise<boolean>;
|
|
7
|
+
export declare function handleMongoError(error: unknown): Promise<unknown>;
|
|
8
8
|
/**
|
|
9
9
|
* 汎用的なCOAエラーハンドリング
|
|
10
10
|
*/
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.handleAWSError = exports.handleMvtkReserveError = exports.handlePecorinoError = exports.handleCOAError = exports.handleMongoError = exports.isMongoError = exports.MongoErrorCode = void 0;
|
|
4
13
|
/**
|
|
@@ -7,7 +16,7 @@ exports.handleAWSError = exports.handleMvtkReserveError = exports.handlePecorino
|
|
|
7
16
|
*/
|
|
8
17
|
const http_status_1 = require("http-status");
|
|
9
18
|
const factory_1 = require("./factory");
|
|
10
|
-
|
|
19
|
+
let mongo;
|
|
11
20
|
var MongoErrorCode;
|
|
12
21
|
(function (MongoErrorCode) {
|
|
13
22
|
MongoErrorCode[MongoErrorCode["DuplicateKey"] = 11000] = "DuplicateKey";
|
|
@@ -15,28 +24,38 @@ var MongoErrorCode;
|
|
|
15
24
|
MongoErrorCode[MongoErrorCode["ExceededTimeLimit"] = 262] = "ExceededTimeLimit";
|
|
16
25
|
})(MongoErrorCode = exports.MongoErrorCode || (exports.MongoErrorCode = {}));
|
|
17
26
|
function isMongoError(error) {
|
|
18
|
-
return (
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (mongo === undefined) {
|
|
29
|
+
mongo = (yield Promise.resolve().then(() => require('mongoose'))).mongo;
|
|
30
|
+
}
|
|
31
|
+
return (error instanceof mongo.MongoError || error instanceof mongo.MongoServerError);
|
|
32
|
+
});
|
|
19
33
|
}
|
|
20
34
|
exports.isMongoError = isMongoError;
|
|
21
35
|
function handleMongoError(error) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
case MongoErrorCode.DuplicateKey:
|
|
26
|
-
handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
|
|
27
|
-
// no op
|
|
28
|
-
break;
|
|
29
|
-
case MongoErrorCode.MaxTimeMSExpired:
|
|
30
|
-
case MongoErrorCode.ExceededTimeLimit:
|
|
31
|
-
handledError = new factory_1.errors.GatewayTimeout(`Gateway Timeout. name:${handledError.name} code:${handledError.code} message:${handledError.message}`);
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
if (mongo === undefined) {
|
|
38
|
+
mongo = (yield Promise.resolve().then(() => require('mongoose'))).mongo;
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
let handledError = error;
|
|
41
|
+
if (handledError instanceof mongo.MongoError || handledError instanceof mongo.MongoServerError) {
|
|
42
|
+
switch (handledError.code) {
|
|
43
|
+
case MongoErrorCode.DuplicateKey:
|
|
44
|
+
handledError = new factory_1.errors.AlreadyInUse('', [], `Some fields already in use. code:${handledError.code} message:${handledError.message}`);
|
|
45
|
+
// no op
|
|
46
|
+
break;
|
|
47
|
+
case MongoErrorCode.MaxTimeMSExpired:
|
|
48
|
+
case MongoErrorCode.ExceededTimeLimit:
|
|
49
|
+
handledError = new factory_1.errors.GatewayTimeout(`Gateway Timeout. name:${handledError.name} code:${handledError.code} message:${handledError.message}`);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (mongo.BSON.BSONError.isBSONError(handledError)) {
|
|
55
|
+
handledError = new factory_1.errors.Argument('', handledError.message);
|
|
56
|
+
}
|
|
57
|
+
return handledError;
|
|
58
|
+
});
|
|
40
59
|
}
|
|
41
60
|
exports.handleMongoError = handleMongoError;
|
|
42
61
|
/**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as factory from '../factory';
|
|
2
|
+
export type IPassportValidator = (params: {
|
|
3
|
+
passport: factory.waiter.passport.IPassport;
|
|
4
|
+
}) => boolean;
|
|
5
|
+
export declare namespace moneyTransfer {
|
|
6
|
+
type IStartParams = factory.transaction.moneyTransfer.IStartParamsWithoutDetail & {
|
|
7
|
+
passportValidator?: IPassportValidator;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare namespace placeOrder {
|
|
11
|
+
type IStartParams = factory.transaction.placeOrder.IStartParamsWithoutDetail & {
|
|
12
|
+
passportValidator?: IPassportValidator;
|
|
13
|
+
broker?: factory.order.IBroker;
|
|
14
|
+
validateSeller?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type IOrderURLGenerator = (order: factory.order.IOrder) => string;
|
|
17
|
+
type IResultOrderParams = factory.transaction.placeOrder.IResultOrderParams & {
|
|
18
|
+
/**
|
|
19
|
+
* 注文日時
|
|
20
|
+
*/
|
|
21
|
+
orderDate: Date;
|
|
22
|
+
/**
|
|
23
|
+
* 注文確認URLのカスタム指定
|
|
24
|
+
*/
|
|
25
|
+
url?: string | IOrderURLGenerator;
|
|
26
|
+
/**
|
|
27
|
+
* 注文アイテム数
|
|
28
|
+
*/
|
|
29
|
+
numItems?: {
|
|
30
|
+
maxValue?: number;
|
|
31
|
+
minValue?: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
type IConfirmParams = factory.transaction.placeOrder.IConfirmParams & {
|
|
35
|
+
project: {
|
|
36
|
+
id: string;
|
|
37
|
+
};
|
|
38
|
+
result: {
|
|
39
|
+
order: IResultOrderParams;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
package/lib/chevre/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* index module
|
|
3
3
|
*/
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as surfrock from '@surfrock/sdk';
|
|
4
|
+
import type * as GMOService from '@motionpicture/gmo-service';
|
|
5
|
+
import type * as Pecorinoapi from './pecorinoapi';
|
|
7
6
|
import { credentials } from './credentials';
|
|
8
7
|
import * as errorHandler from './errorHandler';
|
|
9
8
|
import * as eventEmitter from './eventEmitter';
|
|
10
9
|
import * as factory from './factory';
|
|
11
|
-
import * as pecorinoapi from './pecorinoapi';
|
|
12
10
|
import * as repository from './repository';
|
|
13
11
|
import * as service from './service';
|
|
14
12
|
import * as settings from './settings';
|
|
15
|
-
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings
|
|
13
|
+
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings };
|
|
14
|
+
export declare function loadPecorinoapi(): Promise<typeof Pecorinoapi>;
|
|
15
|
+
export declare function loadGMO(): Promise<typeof GMOService>;
|
package/lib/chevre/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
/**
|
|
5
|
-
* index module
|
|
6
|
-
*/
|
|
7
|
-
const COA = require("@motionpicture/coa-service");
|
|
8
|
-
exports.COA = COA;
|
|
9
|
-
const GMO = require("@motionpicture/gmo-service");
|
|
10
|
-
exports.GMO = GMO;
|
|
11
|
-
const surfrock = require("@surfrock/sdk");
|
|
12
|
-
exports.surfrock = surfrock;
|
|
12
|
+
exports.loadGMO = exports.loadPecorinoapi = exports.settings = exports.service = exports.repository = exports.factory = exports.eventEmitter = exports.errorHandler = exports.credentials = void 0;
|
|
13
13
|
const credentials_1 = require("./credentials");
|
|
14
14
|
Object.defineProperty(exports, "credentials", { enumerable: true, get: function () { return credentials_1.credentials; } });
|
|
15
15
|
const errorHandler = require("./errorHandler");
|
|
@@ -18,11 +18,29 @@ const eventEmitter = require("./eventEmitter");
|
|
|
18
18
|
exports.eventEmitter = eventEmitter;
|
|
19
19
|
const factory = require("./factory");
|
|
20
20
|
exports.factory = factory;
|
|
21
|
-
const pecorinoapi = require("./pecorinoapi");
|
|
22
|
-
exports.pecorinoapi = pecorinoapi;
|
|
23
21
|
const repository = require("./repository");
|
|
24
22
|
exports.repository = repository;
|
|
25
23
|
const service = require("./service");
|
|
26
24
|
exports.service = service;
|
|
27
25
|
const settings = require("./settings");
|
|
28
26
|
exports.settings = settings;
|
|
27
|
+
let pecorinoapi;
|
|
28
|
+
function loadPecorinoapi() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (pecorinoapi === undefined) {
|
|
31
|
+
pecorinoapi = yield Promise.resolve().then(() => require('./pecorinoapi'));
|
|
32
|
+
}
|
|
33
|
+
return pecorinoapi;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.loadPecorinoapi = loadPecorinoapi;
|
|
37
|
+
let GMO;
|
|
38
|
+
function loadGMO() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (GMO === undefined) {
|
|
41
|
+
GMO = yield Promise.resolve().then(() => require('@motionpicture/gmo-service'));
|
|
42
|
+
}
|
|
43
|
+
return GMO;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.loadGMO = loadGMO;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.loadPecorino = exports.auth = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Pecorino API Client
|
|
6
6
|
*/
|
|
7
7
|
const sdk_1 = require("@cinerino/sdk");
|
|
8
|
-
exports
|
|
9
|
-
exports
|
|
8
|
+
Object.defineProperty(exports, "auth", { enumerable: true, get: function () { return sdk_1.auth; } });
|
|
9
|
+
Object.defineProperty(exports, "loadPecorino", { enumerable: true, get: function () { return sdk_1.loadPecorino; } });
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection, Model } from 'mongoose';
|
|
25
|
+
import type { Connection, Model } from 'mongoose';
|
|
26
26
|
/**
|
|
27
27
|
* 科目リポジトリ
|
|
28
28
|
*/
|
|
@@ -30,7 +30,7 @@ class MongoRepository {
|
|
|
30
30
|
}
|
|
31
31
|
catch (error) {
|
|
32
32
|
let throwsError = true;
|
|
33
|
-
if ((0, errorHandler_1.isMongoError)(error)) {
|
|
33
|
+
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
34
34
|
// すでにorderNumberが存在する場合ok
|
|
35
35
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
36
36
|
throwsError = false;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
28
28
|
export type IPayAction = factory.action.trade.pay.IAction;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
1
|
+
import type { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
type IMatchStage = PipelineStage.Match;
|
|
4
4
|
type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
interface IAggregationByStatus {
|
|
28
28
|
transactionCount: number;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
/**
|
|
28
28
|
* 区分リポジトリ
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import type { Connection } from 'mongoose';
|
|
26
26
|
import * as factory from '../factory';
|
|
27
27
|
/**
|
|
28
28
|
* コメントリポジトリ
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import {
|
|
25
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
26
|
+
import type { Connection } from 'mongoose';
|
|
26
27
|
import * as factory from '../factory';
|
|
27
28
|
/**
|
|
28
29
|
* コンテンツリポジトリ
|
|
@@ -35,10 +36,15 @@ export declare class MongoRepository {
|
|
|
35
36
|
* コンテンツを保管する
|
|
36
37
|
*/
|
|
37
38
|
saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* コードをキーにして冪等作成
|
|
41
|
+
*/
|
|
42
|
+
upsertMoviesByIdentifier(params: {
|
|
43
|
+
attributes: factory.creativeWork.movie.ICreativeWork;
|
|
44
|
+
}[]): Promise<BulkWriteResult | void>;
|
|
38
45
|
findMovieById(params: {
|
|
39
46
|
id: string;
|
|
40
47
|
}): Promise<factory.creativeWork.movie.ICreativeWork>;
|
|
41
|
-
countMovies(params: factory.creativeWork.movie.ISearchConditions): Promise<number>;
|
|
42
48
|
/**
|
|
43
49
|
* コンテンツを検索する
|
|
44
50
|
*/
|