@chevre/domain 21.2.0-alpha.6 → 21.2.0-alpha.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
- package/example/src/chevre/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/deleteTasksByName.ts +2 -1
- package/example/src/chevre/importEventsFromCOA.ts +3 -4
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
- package/example/src/chevre/saveTasks.ts +13 -10
- package/example/src/chevre/searchAbortedTasks.ts +36 -0
- package/example/src/chevre/searchSendEmailActions.ts +44 -0
- package/example/src/chevre/task/executeTasks.ts +26 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/startExportTasks.ts +20 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +25 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +25 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +0 -4
- package/lib/chevre/repo/accountTitle.js +0 -4
- package/lib/chevre/repo/accountTransaction.d.ts +3 -11
- package/lib/chevre/repo/accountTransaction.js +1 -58
- package/lib/chevre/repo/accountingReport.js +0 -4
- package/lib/chevre/repo/action.d.ts +29 -1
- package/lib/chevre/repo/action.js +32 -29
- package/lib/chevre/repo/additionalProperty.js +0 -4
- package/lib/chevre/repo/aggregation.js +0 -4
- package/lib/chevre/repo/assetTransaction.d.ts +23 -8
- package/lib/chevre/repo/assetTransaction.js +207 -68
- package/lib/chevre/repo/categoryCode.js +0 -4
- package/lib/chevre/repo/code.js +0 -4
- package/lib/chevre/repo/comment.d.ts +4 -1
- package/lib/chevre/repo/comment.js +20 -9
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
- package/lib/chevre/repo/confirmationNumber.js +3 -15
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +0 -4
- package/lib/chevre/repo/customer.js +0 -4
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +0 -4
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +0 -4
- package/lib/chevre/repo/member.js +0 -4
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
- package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offer.js +0 -5
- package/lib/chevre/repo/offerCatalog.js +0 -4
- package/lib/chevre/repo/offerItemCondition.d.ts +39 -0
- package/lib/chevre/repo/offerItemCondition.js +112 -0
- package/lib/chevre/repo/order.d.ts +25 -0
- package/lib/chevre/repo/order.js +5 -4
- package/lib/chevre/repo/ownershipInfo.js +0 -4
- package/lib/chevre/repo/permit.js +0 -4
- package/lib/chevre/repo/place.js +0 -4
- package/lib/chevre/repo/priceSpecification.js +0 -4
- package/lib/chevre/repo/product.js +0 -4
- package/lib/chevre/repo/project.js +0 -4
- package/lib/chevre/repo/reservation.js +0 -4
- package/lib/chevre/repo/role.js +0 -4
- package/lib/chevre/repo/seller.js +0 -4
- package/lib/chevre/repo/serviceOutput.js +0 -4
- package/lib/chevre/repo/stockHolder.js +30 -0
- package/lib/chevre/repo/task.d.ts +41 -2
- package/lib/chevre/repo/task.js +97 -12
- package/lib/chevre/repo/telemetry.js +0 -4
- package/lib/chevre/repo/transaction.d.ts +23 -3
- package/lib/chevre/repo/transaction.js +174 -58
- package/lib/chevre/repo/trip.js +0 -4
- package/lib/chevre/repository.d.ts +5 -2
- package/lib/chevre/repository.js +8 -4
- package/lib/chevre/service/aggregation/system.d.ts +67 -22
- package/lib/chevre/service/aggregation/system.js +101 -89
- package/lib/chevre/service/assetTransaction/cancelReservation.js +23 -25
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +23 -21
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
- package/lib/chevre/service/assetTransaction/pay.js +32 -24
- package/lib/chevre/service/assetTransaction/refund.js +23 -21
- package/lib/chevre/service/assetTransaction/registerService.js +23 -22
- package/lib/chevre/service/assetTransaction/reserve.js +23 -21
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/notification/factory.js +2 -2
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +41 -7
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
- package/lib/chevre/service/offer.js +1 -1
- package/lib/chevre/service/order/deleteOrder.js +8 -8
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -36
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
- package/lib/chevre/service/order/placeOrder.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +1 -5
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/payment/any/onPaid.js +1 -1
- package/lib/chevre/service/payment/any/onRefund.js +1 -1
- package/lib/chevre/service/payment/any.js +60 -10
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
- package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket.js +4 -3
- package/lib/chevre/service/product.js +1 -5
- package/lib/chevre/service/report/telemetry.d.ts +0 -11
- package/lib/chevre/service/report/telemetry.js +21 -24
- package/lib/chevre/service/reserve/cancelReservation.js +0 -2
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
- package/lib/chevre/service/reserve/useReservation.js +1 -8
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/deleteTransaction.js +10 -8
- package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
- package/lib/chevre/service/task/returnPayTransaction.js +2 -12
- package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +226 -0
- package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
- package/lib/chevre/service/transaction/orderProgramMembership.js +2 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
- package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +1 -3
- package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
- package/lib/chevre/service/transaction/returnOrder.js +1 -5
- package/lib/chevre/service/transaction.d.ts +8 -13
- package/lib/chevre/service/transaction.js +12 -145
- package/lib/chevre/settings.d.ts +6 -1
- package/lib/chevre/settings.js +17 -5
- package/package.json +5 -5
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
|
@@ -11,22 +11,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
13
|
const moment = require("moment");
|
|
14
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
15
14
|
const assetTransaction_1 = require("./mongoose/schemas/assetTransaction");
|
|
16
15
|
const factory = require("../factory");
|
|
16
|
+
const assetTransaction_2 = require("../eventEmitter/assetTransaction");
|
|
17
17
|
/**
|
|
18
18
|
* 資産取引リポジトリ
|
|
19
19
|
*/
|
|
20
20
|
class MongoRepository {
|
|
21
21
|
constructor(connection) {
|
|
22
22
|
this.transactionModel = connection.model(assetTransaction_1.modelName, assetTransaction_1.schema);
|
|
23
|
-
if (connection.get('autoIndex') === true) {
|
|
24
|
-
this.transactionModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
25
|
-
}
|
|
26
23
|
}
|
|
27
24
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
28
25
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
30
27
|
const andConditions = [
|
|
31
28
|
{
|
|
32
29
|
typeOf: params.typeOf
|
|
@@ -106,6 +103,11 @@ class MongoRepository {
|
|
|
106
103
|
}
|
|
107
104
|
});
|
|
108
105
|
}
|
|
106
|
+
if (Array.isArray(params.tasksExportationStatuses)) {
|
|
107
|
+
andConditions.push({
|
|
108
|
+
tasksExportationStatus: { $in: params.tasksExportationStatuses }
|
|
109
|
+
});
|
|
110
|
+
}
|
|
109
111
|
switch (params.typeOf) {
|
|
110
112
|
case factory.assetTransactionType.Pay:
|
|
111
113
|
const objectAccountIdEq = (_e = (_d = params.object) === null || _d === void 0 ? void 0 : _d.accountId) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
@@ -131,15 +133,18 @@ class MongoRepository {
|
|
|
131
133
|
const objectPaymentMethodIdEq4refund = (_j = (_h = params.object) === null || _h === void 0 ? void 0 : _h.paymentMethodId) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
132
134
|
if (typeof objectPaymentMethodIdEq4refund === 'string') {
|
|
133
135
|
andConditions.push({
|
|
134
|
-
'object.paymentMethodId': {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
'object.paymentMethodId': { $exists: true, $eq: objectPaymentMethodIdEq4refund }
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const objectPaymentMethodIdIn4refund = (_l = (_k = params.object) === null || _k === void 0 ? void 0 : _k.paymentMethodId) === null || _l === void 0 ? void 0 : _l.$in;
|
|
140
|
+
if (Array.isArray(objectPaymentMethodIdIn4refund)) {
|
|
141
|
+
andConditions.push({
|
|
142
|
+
'object.paymentMethodId': { $exists: true, $in: objectPaymentMethodIdIn4refund }
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
145
|
break;
|
|
141
146
|
case factory.assetTransactionType.MoneyTransfer:
|
|
142
|
-
const fromLocationIdentifierEq = (
|
|
147
|
+
const fromLocationIdentifierEq = (_p = (_o = (_m = params.object) === null || _m === void 0 ? void 0 : _m.fromLocation) === null || _o === void 0 ? void 0 : _o.identifier) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
143
148
|
if (typeof fromLocationIdentifierEq === 'string') {
|
|
144
149
|
andConditions.push({
|
|
145
150
|
'object.fromLocation.identifier': {
|
|
@@ -148,7 +153,7 @@ class MongoRepository {
|
|
|
148
153
|
}
|
|
149
154
|
});
|
|
150
155
|
}
|
|
151
|
-
const toLocationIdentifierEq = (
|
|
156
|
+
const toLocationIdentifierEq = (_s = (_r = (_q = params.object) === null || _q === void 0 ? void 0 : _q.toLocation) === null || _r === void 0 ? void 0 : _r.identifier) === null || _s === void 0 ? void 0 : _s.$eq;
|
|
152
157
|
if (typeof toLocationIdentifierEq === 'string') {
|
|
153
158
|
andConditions.push({
|
|
154
159
|
'object.toLocation.identifier': {
|
|
@@ -157,7 +162,7 @@ class MongoRepository {
|
|
|
157
162
|
}
|
|
158
163
|
});
|
|
159
164
|
}
|
|
160
|
-
const pendingTransactionIdentifierEq = (
|
|
165
|
+
const pendingTransactionIdentifierEq = (_v = (_u = (_t = params.object) === null || _t === void 0 ? void 0 : _t.pendingTransaction) === null || _u === void 0 ? void 0 : _u.identifier) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
161
166
|
if (typeof pendingTransactionIdentifierEq === 'string') {
|
|
162
167
|
andConditions.push({
|
|
163
168
|
'object.pendingTransaction.identifier': {
|
|
@@ -170,7 +175,7 @@ class MongoRepository {
|
|
|
170
175
|
case factory.assetTransactionType.CancelReservation:
|
|
171
176
|
break;
|
|
172
177
|
case factory.assetTransactionType.Reserve:
|
|
173
|
-
const objectReservationNumberEq = (
|
|
178
|
+
const objectReservationNumberEq = (_x = (_w = params.object) === null || _w === void 0 ? void 0 : _w.reservationNumber) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
174
179
|
if (typeof objectReservationNumberEq === 'string') {
|
|
175
180
|
andConditions.push({
|
|
176
181
|
'object.reservationNumber': {
|
|
@@ -218,7 +223,7 @@ class MongoRepository {
|
|
|
218
223
|
}
|
|
219
224
|
break;
|
|
220
225
|
case factory.assetTransactionType.RegisterService:
|
|
221
|
-
const objectItemOfferedServiceOutputIdentifierEq = (
|
|
226
|
+
const objectItemOfferedServiceOutputIdentifierEq = (_1 = (_0 = (_z = (_y = params.object) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.serviceOutput) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$eq;
|
|
222
227
|
if (typeof objectItemOfferedServiceOutputIdentifierEq === 'string') {
|
|
223
228
|
andConditions.push({
|
|
224
229
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -227,7 +232,7 @@ class MongoRepository {
|
|
|
227
232
|
}
|
|
228
233
|
});
|
|
229
234
|
}
|
|
230
|
-
const objectItemOfferedServiceOutputIdentifierIn = (
|
|
235
|
+
const objectItemOfferedServiceOutputIdentifierIn = (_5 = (_4 = (_3 = (_2 = params.object) === null || _2 === void 0 ? void 0 : _2.itemOffered) === null || _3 === void 0 ? void 0 : _3.serviceOutput) === null || _4 === void 0 ? void 0 : _4.identifier) === null || _5 === void 0 ? void 0 : _5.$in;
|
|
231
236
|
if (Array.isArray(objectItemOfferedServiceOutputIdentifierIn)) {
|
|
232
237
|
andConditions.push({
|
|
233
238
|
'object.itemOffered.serviceOutput.identifier': {
|
|
@@ -246,7 +251,9 @@ class MongoRepository {
|
|
|
246
251
|
*/
|
|
247
252
|
start(params) {
|
|
248
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined,
|
|
254
|
+
return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate: new Date(), endDate: undefined, tasksExportAction: {
|
|
255
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
256
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
|
|
250
257
|
.then((doc) => doc.toObject());
|
|
251
258
|
});
|
|
252
259
|
}
|
|
@@ -276,15 +283,12 @@ class MongoRepository {
|
|
|
276
283
|
return doc.toObject();
|
|
277
284
|
});
|
|
278
285
|
}
|
|
279
|
-
/**
|
|
280
|
-
* 取引を確定する
|
|
281
|
-
*/
|
|
282
286
|
addReservations(params) {
|
|
283
287
|
return __awaiter(this, void 0, void 0, function* () {
|
|
284
288
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
285
|
-
_id: params.id,
|
|
286
|
-
typeOf: params.typeOf,
|
|
287
|
-
status: factory.transactionStatusType.InProgress
|
|
289
|
+
_id: { $eq: params.id },
|
|
290
|
+
typeOf: { $eq: params.typeOf },
|
|
291
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
288
292
|
}, {
|
|
289
293
|
'object.acceptedOffer': params.object.acceptedOffer,
|
|
290
294
|
// 念のため残す(2021/10/14)が、そのうち削除
|
|
@@ -309,34 +313,40 @@ class MongoRepository {
|
|
|
309
313
|
confirm(params) {
|
|
310
314
|
return __awaiter(this, void 0, void 0, function* () {
|
|
311
315
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
312
|
-
_id: params.id,
|
|
313
|
-
typeOf: params.typeOf,
|
|
314
|
-
status: factory.transactionStatusType.InProgress
|
|
316
|
+
_id: { $eq: params.id },
|
|
317
|
+
typeOf: { $eq: params.typeOf },
|
|
318
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
315
319
|
}, {
|
|
316
320
|
status: factory.transactionStatusType.Confirmed,
|
|
317
321
|
endDate: new Date(),
|
|
318
322
|
result: params.result,
|
|
319
323
|
potentialActions: params.potentialActions // resultを更新
|
|
320
|
-
}, {
|
|
324
|
+
}, {
|
|
325
|
+
new: true,
|
|
326
|
+
projection: { _id: 1 }
|
|
327
|
+
})
|
|
321
328
|
.exec();
|
|
322
329
|
// NotFoundであれば取引状態確認
|
|
323
330
|
if (doc === null) {
|
|
324
331
|
const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
325
332
|
if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
326
|
-
//
|
|
327
|
-
return transaction;
|
|
333
|
+
// すでに確定済の場合スルー
|
|
328
334
|
}
|
|
329
335
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
330
|
-
throw new factory.errors.Argument('Transaction id',
|
|
336
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
331
337
|
}
|
|
332
338
|
else if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
333
|
-
throw new factory.errors.Argument('Transaction id',
|
|
339
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
|
|
334
340
|
}
|
|
335
341
|
else {
|
|
336
342
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
337
343
|
}
|
|
338
344
|
}
|
|
339
|
-
|
|
345
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
346
|
+
id: params.id,
|
|
347
|
+
typeOf: params.typeOf,
|
|
348
|
+
status: factory.transactionStatusType.Confirmed
|
|
349
|
+
});
|
|
340
350
|
});
|
|
341
351
|
}
|
|
342
352
|
/**
|
|
@@ -344,23 +354,42 @@ class MongoRepository {
|
|
|
344
354
|
*/
|
|
345
355
|
startAndConfirm(params) {
|
|
346
356
|
return __awaiter(this, void 0, void 0, function* () {
|
|
347
|
-
|
|
357
|
+
const startDate = new Date();
|
|
358
|
+
const confirmedTransaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { _id: params.id, typeOf: params.typeOf, startDate, status: factory.transactionStatusType.Confirmed, tasksExportAction: {
|
|
359
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
360
|
+
}, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported, endDate: startDate, result: params.result, potentialActions: params.potentialActions }))
|
|
348
361
|
.then((doc) => doc.toObject());
|
|
362
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
363
|
+
id: params.id,
|
|
364
|
+
typeOf: params.typeOf,
|
|
365
|
+
status: factory.transactionStatusType.Confirmed
|
|
366
|
+
});
|
|
367
|
+
return confirmedTransaction;
|
|
349
368
|
});
|
|
350
369
|
}
|
|
351
370
|
/**
|
|
352
371
|
* タスク未エクスポートの取引をひとつ取得してエクスポートを開始する
|
|
353
372
|
*/
|
|
354
373
|
startExportTasks(params) {
|
|
355
|
-
var _a, _b
|
|
374
|
+
var _a, _b;
|
|
356
375
|
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
376
|
+
switch (params.status) {
|
|
377
|
+
case factory.transactionStatusType.InProgress:
|
|
378
|
+
throw new factory.errors.NotImplemented(`status "${params.status}" not implemented on startExportTasks`);
|
|
379
|
+
default:
|
|
380
|
+
// no op
|
|
381
|
+
}
|
|
382
|
+
const typeOfIn = (_a = params.typeOf) === null || _a === void 0 ? void 0 : _a.$in;
|
|
383
|
+
return this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof ((_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === 'string') ? { 'project.id': { $eq: params.project.id } } : undefined), (Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined), { status: { $eq: params.status }, tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported } }), (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), {
|
|
384
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.ActiveActionStatus,
|
|
385
|
+
'tasksExportAction.agent': { name: params.tasksExportAction.agent.name },
|
|
386
|
+
'tasksExportAction.startDate': new Date(),
|
|
387
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting
|
|
388
|
+
}, { new: true })
|
|
389
|
+
.select({
|
|
390
|
+
_id: 1,
|
|
391
|
+
typeOf: 1
|
|
392
|
+
})
|
|
364
393
|
.exec()
|
|
365
394
|
// tslint:disable-next-line:no-null-keyword
|
|
366
395
|
.then((doc) => (doc === null) ? null : doc.toObject());
|
|
@@ -373,17 +402,74 @@ class MongoRepository {
|
|
|
373
402
|
*/
|
|
374
403
|
reexportTasks(params) {
|
|
375
404
|
return __awaiter(this, void 0, void 0, function* () {
|
|
376
|
-
yield this.transactionModel.
|
|
377
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Exporting,
|
|
405
|
+
const reexportingTransactions = yield this.transactionModel.find({
|
|
406
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting },
|
|
378
407
|
updatedAt: {
|
|
379
408
|
$lt: moment()
|
|
380
409
|
.add(-params.intervalInMinutes, 'minutes')
|
|
381
410
|
.toDate()
|
|
382
411
|
}
|
|
383
|
-
}, {
|
|
384
|
-
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
385
412
|
})
|
|
413
|
+
.select({
|
|
414
|
+
_id: 1,
|
|
415
|
+
typeOf: 1,
|
|
416
|
+
status: 1
|
|
417
|
+
})
|
|
418
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
419
|
+
.exec();
|
|
420
|
+
if (reexportingTransactions.length > 0) {
|
|
421
|
+
for (const reexportingTransaction of reexportingTransactions) {
|
|
422
|
+
yield this.transactionModel.updateOne({
|
|
423
|
+
_id: { $eq: reexportingTransaction.id },
|
|
424
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
425
|
+
}, {
|
|
426
|
+
tasksExportAction: {
|
|
427
|
+
actionStatus: factory.actionStatusType.PotentialActionStatus
|
|
428
|
+
},
|
|
429
|
+
tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
|
|
430
|
+
})
|
|
431
|
+
.exec();
|
|
432
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
433
|
+
id: reexportingTransaction.id,
|
|
434
|
+
typeOf: reexportingTransaction.typeOf,
|
|
435
|
+
status: reexportingTransaction.status
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
|
|
443
|
+
*/
|
|
444
|
+
exportTasks(params) {
|
|
445
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
446
|
+
const delayedTransactions = yield this.transactionModel.find({
|
|
447
|
+
status: { $in: params.status.$in },
|
|
448
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Unexported },
|
|
449
|
+
endDate: {
|
|
450
|
+
$exists: true,
|
|
451
|
+
$lt: moment(params.now)
|
|
452
|
+
.add(-params.delayInSeconds, 'seconds')
|
|
453
|
+
.toDate()
|
|
454
|
+
}
|
|
455
|
+
})
|
|
456
|
+
.select({
|
|
457
|
+
_id: 1,
|
|
458
|
+
typeOf: 1,
|
|
459
|
+
status: 1
|
|
460
|
+
})
|
|
461
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
386
462
|
.exec();
|
|
463
|
+
if (delayedTransactions.length > 0) {
|
|
464
|
+
delayedTransactions.forEach((delayedTransaction) => {
|
|
465
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
466
|
+
id: delayedTransaction.id,
|
|
467
|
+
typeOf: delayedTransaction.typeOf,
|
|
468
|
+
status: delayedTransaction.status
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
return delayedTransactions;
|
|
387
473
|
});
|
|
388
474
|
}
|
|
389
475
|
/**
|
|
@@ -392,10 +478,15 @@ class MongoRepository {
|
|
|
392
478
|
*/
|
|
393
479
|
setTasksExportedById(params) {
|
|
394
480
|
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
|
|
481
|
+
const endDate = new Date();
|
|
482
|
+
yield this.transactionModel.updateOne({
|
|
483
|
+
_id: { $eq: params.id },
|
|
484
|
+
tasksExportationStatus: { $eq: factory.transactionTasksExportationStatus.Exporting }
|
|
485
|
+
}, {
|
|
396
486
|
tasksExportationStatus: factory.transactionTasksExportationStatus.Exported,
|
|
397
|
-
tasksExportedAt:
|
|
398
|
-
|
|
487
|
+
tasksExportedAt: endDate,
|
|
488
|
+
'tasksExportAction.actionStatus': factory.actionStatusType.CompletedActionStatus,
|
|
489
|
+
'tasksExportAction.endDate': endDate
|
|
399
490
|
})
|
|
400
491
|
.exec();
|
|
401
492
|
});
|
|
@@ -405,15 +496,36 @@ class MongoRepository {
|
|
|
405
496
|
*/
|
|
406
497
|
makeExpired(params) {
|
|
407
498
|
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
-
//
|
|
409
|
-
yield this.transactionModel.
|
|
410
|
-
status: factory.transactionStatusType.InProgress,
|
|
411
|
-
expires: { $lt: params.expires }
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
499
|
+
// IDをemitしたいのでまずリスト検索(2023-04-27~)
|
|
500
|
+
const expiringTransactions = yield this.transactionModel.find({
|
|
501
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
502
|
+
expires: { $lt: params.expires.$lt }
|
|
503
|
+
})
|
|
504
|
+
.select({
|
|
505
|
+
_id: 1,
|
|
506
|
+
typeOf: 1
|
|
415
507
|
})
|
|
508
|
+
.setOptions({ maxTimeMS: 10000 })
|
|
416
509
|
.exec();
|
|
510
|
+
if (expiringTransactions.length > 0) {
|
|
511
|
+
// ステータスと期限を見て更新
|
|
512
|
+
yield this.transactionModel.updateMany({
|
|
513
|
+
_id: { $in: expiringTransactions.map((t) => t.id) },
|
|
514
|
+
status: { $eq: factory.transactionStatusType.InProgress },
|
|
515
|
+
expires: { $lt: params.expires.$lt }
|
|
516
|
+
}, {
|
|
517
|
+
status: factory.transactionStatusType.Expired,
|
|
518
|
+
endDate: new Date()
|
|
519
|
+
})
|
|
520
|
+
.exec();
|
|
521
|
+
expiringTransactions.forEach((expiringTransaction) => {
|
|
522
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
523
|
+
id: expiringTransaction.id,
|
|
524
|
+
typeOf: expiringTransaction.typeOf,
|
|
525
|
+
status: factory.transactionStatusType.Expired
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
}
|
|
417
529
|
});
|
|
418
530
|
}
|
|
419
531
|
/**
|
|
@@ -421,19 +533,18 @@ class MongoRepository {
|
|
|
421
533
|
*/
|
|
422
534
|
cancel(params) {
|
|
423
535
|
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
-
const endDate =
|
|
425
|
-
.toDate();
|
|
536
|
+
const endDate = new Date();
|
|
426
537
|
// 進行中ステータスの取引を中止する
|
|
427
|
-
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: params.typeOf }, (typeof params.id === 'string') ? { _id: params.id } : undefined), (typeof params.transactionNumber === 'string')
|
|
538
|
+
const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
|
|
428
539
|
? { transactionNumber: { $exists: true, $eq: params.transactionNumber } }
|
|
429
|
-
: undefined), { status: factory.transactionStatusType.InProgress }), {
|
|
540
|
+
: undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
|
|
430
541
|
status: factory.transactionStatusType.Canceled,
|
|
431
542
|
endDate: endDate
|
|
432
543
|
}, { new: true })
|
|
433
544
|
.exec();
|
|
545
|
+
let transaction;
|
|
434
546
|
// NotFoundであれば取引状態確認
|
|
435
547
|
if (doc === null) {
|
|
436
|
-
let transaction;
|
|
437
548
|
if (typeof params.id === 'string') {
|
|
438
549
|
transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
|
|
439
550
|
}
|
|
@@ -447,20 +558,27 @@ class MongoRepository {
|
|
|
447
558
|
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
448
559
|
}
|
|
449
560
|
if (transaction.status === factory.transactionStatusType.Canceled) {
|
|
450
|
-
//
|
|
451
|
-
return transaction;
|
|
561
|
+
// すでに中止済の場合スルー
|
|
452
562
|
}
|
|
453
563
|
else if (transaction.status === factory.transactionStatusType.Expired) {
|
|
454
|
-
throw new factory.errors.Argument('Transaction id',
|
|
564
|
+
throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
|
|
455
565
|
}
|
|
456
566
|
else if (transaction.status === factory.transactionStatusType.Confirmed) {
|
|
457
|
-
throw new factory.errors.Argument('Transaction id',
|
|
567
|
+
throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
|
|
458
568
|
}
|
|
459
569
|
else {
|
|
460
570
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
461
571
|
}
|
|
462
572
|
}
|
|
463
|
-
|
|
573
|
+
else {
|
|
574
|
+
transaction = doc.toObject();
|
|
575
|
+
}
|
|
576
|
+
assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
|
|
577
|
+
id: transaction.id,
|
|
578
|
+
typeOf: params.typeOf,
|
|
579
|
+
status: factory.transactionStatusType.Canceled
|
|
580
|
+
});
|
|
581
|
+
return transaction;
|
|
464
582
|
});
|
|
465
583
|
}
|
|
466
584
|
count(params) {
|
|
@@ -474,12 +592,30 @@ class MongoRepository {
|
|
|
474
592
|
/**
|
|
475
593
|
* 取引を検索する
|
|
476
594
|
*/
|
|
477
|
-
search(params,
|
|
595
|
+
search(params, inclusion, exclusion) {
|
|
478
596
|
var _a;
|
|
479
597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
598
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
599
|
+
let projection = {};
|
|
600
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
601
|
+
inclusion.forEach((field) => {
|
|
602
|
+
projection[field] = 1;
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
projection = {
|
|
607
|
+
__v: 0,
|
|
608
|
+
createdAt: 0,
|
|
609
|
+
updatedAt: 0
|
|
610
|
+
};
|
|
611
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
612
|
+
exclusion.forEach((field) => {
|
|
613
|
+
projection[field] = 0;
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
481
617
|
const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
482
|
-
.select(
|
|
618
|
+
.select(projection);
|
|
483
619
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
484
620
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
485
621
|
query.limit(params.limit)
|
|
@@ -522,9 +658,12 @@ class MongoRepository {
|
|
|
522
658
|
/**
|
|
523
659
|
* 特定の取引を更新する(汎用)
|
|
524
660
|
*/
|
|
525
|
-
|
|
661
|
+
findByIdAndUpdateInProgress(params) {
|
|
526
662
|
return __awaiter(this, void 0, void 0, function* () {
|
|
527
|
-
return this.transactionModel.findOneAndUpdate({
|
|
663
|
+
return this.transactionModel.findOneAndUpdate({
|
|
664
|
+
_id: { $eq: params.id },
|
|
665
|
+
status: { $eq: factory.transactionStatusType.InProgress }
|
|
666
|
+
}, params.update, { new: true })
|
|
528
667
|
.exec()
|
|
529
668
|
.then((doc) => {
|
|
530
669
|
if (doc === null) {
|
|
@@ -21,7 +21,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
25
24
|
const categoryCode_1 = require("./mongoose/schemas/categoryCode");
|
|
26
25
|
const factory = require("../factory");
|
|
27
26
|
/**
|
|
@@ -30,9 +29,6 @@ const factory = require("../factory");
|
|
|
30
29
|
class MongoRepository {
|
|
31
30
|
constructor(connection) {
|
|
32
31
|
this.categoryCodeModel = connection.model(categoryCode_1.modelName, categoryCode_1.schema);
|
|
33
|
-
if (connection.get('autoIndex') === true) {
|
|
34
|
-
this.categoryCodeModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
35
|
-
}
|
|
36
32
|
}
|
|
37
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
38
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
package/lib/chevre/repo/code.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.MongoRepository = exports.modelName = void 0;
|
|
|
13
13
|
const moment = require("moment");
|
|
14
14
|
const uuid = require("uuid");
|
|
15
15
|
const factory = require("../factory");
|
|
16
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
17
16
|
const authorization_1 = require("./mongoose/schemas/authorization");
|
|
18
17
|
Object.defineProperty(exports, "modelName", { enumerable: true, get: function () { return authorization_1.modelName; } });
|
|
19
18
|
/**
|
|
@@ -22,9 +21,6 @@ Object.defineProperty(exports, "modelName", { enumerable: true, get: function ()
|
|
|
22
21
|
class MongoRepository {
|
|
23
22
|
constructor(connection) {
|
|
24
23
|
this.authorizationModel = connection.model(authorization_1.modelName, authorization_1.schema);
|
|
25
|
-
if (connection.get('autoIndex') === true) {
|
|
26
|
-
this.authorizationModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
27
|
-
}
|
|
28
24
|
}
|
|
29
25
|
// tslint:disable-next-line:max-func-body-length
|
|
30
26
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
@@ -34,7 +34,10 @@ export declare class MongoRepository {
|
|
|
34
34
|
/**
|
|
35
35
|
* 検索
|
|
36
36
|
*/
|
|
37
|
-
search(params: factory.creativeWork.comment.ISearchConditions
|
|
37
|
+
search(params: factory.creativeWork.comment.ISearchConditions & {
|
|
38
|
+
inclusion: string[];
|
|
39
|
+
exclusion: string[];
|
|
40
|
+
}): Promise<factory.creativeWork.comment.IComment[]>;
|
|
38
41
|
findById(params: {
|
|
39
42
|
id: string;
|
|
40
43
|
}): Promise<factory.creativeWork.comment.IComment>;
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MongoRepository = void 0;
|
|
13
|
-
const onIndexCreated_1 = require("./mongoose/onIndexCreated");
|
|
14
13
|
const comments_1 = require("./mongoose/schemas/comments");
|
|
15
14
|
const factory = require("../factory");
|
|
16
15
|
/**
|
|
@@ -19,9 +18,6 @@ const factory = require("../factory");
|
|
|
19
18
|
class MongoRepository {
|
|
20
19
|
constructor(connection) {
|
|
21
20
|
this.commentModel = connection.model(comments_1.modelName, comments_1.schema);
|
|
22
|
-
if (connection.get('autoIndex') === true) {
|
|
23
|
-
this.commentModel.on(onIndexCreated_1.INDEX_EVENT, onIndexCreated_1.onIndexCreated);
|
|
24
|
-
}
|
|
25
21
|
}
|
|
26
22
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
27
23
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -46,12 +42,27 @@ class MongoRepository {
|
|
|
46
42
|
search(params) {
|
|
47
43
|
var _a;
|
|
48
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
let projection = {};
|
|
46
|
+
if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
|
|
47
|
+
params.inclusion.forEach((field) => {
|
|
48
|
+
projection[field] = 1;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
projection = {
|
|
53
|
+
__v: 0,
|
|
54
|
+
createdAt: 0,
|
|
55
|
+
updatedAt: 0
|
|
56
|
+
};
|
|
57
|
+
if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
|
|
58
|
+
params.exclusion.forEach((field) => {
|
|
59
|
+
projection[field] = 0;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
49
63
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
50
|
-
const query = this.commentModel.find((conditions.length > 0) ? { $and: conditions } : {}
|
|
51
|
-
|
|
52
|
-
createdAt: 0,
|
|
53
|
-
updatedAt: 0
|
|
54
|
-
});
|
|
64
|
+
const query = this.commentModel.find((conditions.length > 0) ? { $and: conditions } : {})
|
|
65
|
+
.select(projection);
|
|
55
66
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
56
67
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
57
68
|
query.limit(params.limit)
|
|
@@ -4,7 +4,6 @@ import { RedisClientType } from 'redis';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class RedisRepository {
|
|
6
6
|
private static readonly REDIS_KEY_PREFIX_NEW;
|
|
7
|
-
private static readonly REDIS_KEY_PREFIX;
|
|
8
7
|
private readonly redisClient;
|
|
9
8
|
constructor(redisClient: RedisClientType);
|
|
10
9
|
private static alignDigits;
|
|
@@ -16,7 +16,6 @@ const util = require("util");
|
|
|
16
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
17
17
|
const fpe = require('node-fpe');
|
|
18
18
|
const factory = require("../factory");
|
|
19
|
-
const settings_1 = require("../settings");
|
|
20
19
|
const CONFIRMATION_NUMBER_MIN_LENGH = 4;
|
|
21
20
|
/**
|
|
22
21
|
* 確認番号リポジトリ
|
|
@@ -34,19 +33,9 @@ class RedisRepository {
|
|
|
34
33
|
return aligndNumber;
|
|
35
34
|
}
|
|
36
35
|
static createKey(params) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (useNewKey) {
|
|
41
|
-
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
|
|
42
|
-
.tz('Asia/Tokyo')
|
|
43
|
-
.format('YYMM'));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX, moment(params.orderDate)
|
|
47
|
-
.tz('Asia/Tokyo')
|
|
48
|
-
.format('YYMM'));
|
|
49
|
-
}
|
|
36
|
+
return util.format('%s:%s', RedisRepository.REDIS_KEY_PREFIX_NEW, moment(params.orderDate)
|
|
37
|
+
.tz('Asia/Tokyo')
|
|
38
|
+
.format('YYMM'));
|
|
50
39
|
}
|
|
51
40
|
/**
|
|
52
41
|
* 発行する
|
|
@@ -81,5 +70,4 @@ class RedisRepository {
|
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
72
|
RedisRepository.REDIS_KEY_PREFIX_NEW = 'confirmationNumber';
|
|
84
|
-
RedisRepository.REDIS_KEY_PREFIX = 'cinerino:confirmationNumber';
|
|
85
73
|
exports.RedisRepository = RedisRepository;
|
|
@@ -34,9 +34,7 @@ export declare class MongoRepository {
|
|
|
34
34
|
/**
|
|
35
35
|
* コンテンツを保管する
|
|
36
36
|
*/
|
|
37
|
-
saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<
|
|
38
|
-
_id: unknown;
|
|
39
|
-
}>>;
|
|
37
|
+
saveMovie(params: factory.creativeWork.movie.ICreativeWork): Promise<any>;
|
|
40
38
|
findMovieById(params: {
|
|
41
39
|
id: string;
|
|
42
40
|
}): Promise<factory.creativeWork.movie.ICreativeWork>;
|