@chevre/domain 21.13.0-alpha.0 → 21.13.0-alpha.2
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/searchEvents.ts +5 -2
- package/example/src/chevre/searchOrders.ts +1 -1
- package/example/src/chevre/task/executeTasks.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/unsetContainsInPlaceFromMovieTheater.ts +1 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +1 -1
- package/example/src/chevre/updateOfferCatalogs.ts +1 -1
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/lib/chevre/errorHandler.d.ts +2 -2
- package/lib/chevre/errorHandler.js +38 -19
- package/lib/chevre/index.d.ts +5 -5
- package/lib/chevre/index.js +31 -12
- 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 +1 -1
- 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 +2 -2
- 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 -1
- package/lib/chevre/repo/order.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/lib/chevre/service/assetTransaction/pay/account/validation.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay.d.ts +10 -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/reserve.d.ts +14 -14
- 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 +7 -7
- package/lib/chevre/service/iam.d.ts +2 -2
- package/lib/chevre/service/moneyTransfer.d.ts +5 -5
- 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 +10 -10
- package/lib/chevre/service/payment/creditCard.d.ts +6 -6
- 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.d.ts +9 -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/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.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 +9 -9
- 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 +7 -7
- 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.d.ts +2 -2
- package/lib/chevre/service.d.ts +73 -39
- package/lib/chevre/service.js +255 -39
- package/package.json +1 -1
- 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
|
@@ -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,
|
|
@@ -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 taskRepo =
|
|
9
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
10
10
|
const result = await taskRepo.executeTasks({
|
|
11
11
|
now: new Date(),
|
|
12
12
|
delayInSeconds: 60,
|
|
@@ -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,
|
|
@@ -8,7 +8,7 @@ import { chevre } from '../../../lib/index';
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const placeRepo =
|
|
11
|
+
const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const cursor = placeRepo.getCursor(
|
|
14
14
|
{
|
|
@@ -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({
|
|
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
8
|
|
|
9
|
-
const offerCatalogRepo =
|
|
9
|
+
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
await offerCatalogRepo.updateManyById({
|
|
12
12
|
id: { $in: ['0002'] },
|
|
@@ -7,7 +7,7 @@ import { chevre } from '../../../lib/index';
|
|
|
7
7
|
async function main() {
|
|
8
8
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
9
|
|
|
10
|
-
const transactionRepo =
|
|
10
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
11
11
|
const transactionId = '63ce4d501c45c2000bdb2f9d';
|
|
12
12
|
let update = {
|
|
13
13
|
$set: { 'object.modifiedTime': new Date() }
|
|
@@ -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
|
/**
|
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,16 @@
|
|
|
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
|
+
// import * as surfrock from '@surfrock/sdk';
|
|
13
14
|
const credentials_1 = require("./credentials");
|
|
14
15
|
Object.defineProperty(exports, "credentials", { enumerable: true, get: function () { return credentials_1.credentials; } });
|
|
15
16
|
const errorHandler = require("./errorHandler");
|
|
@@ -18,11 +19,29 @@ const eventEmitter = require("./eventEmitter");
|
|
|
18
19
|
exports.eventEmitter = eventEmitter;
|
|
19
20
|
const factory = require("./factory");
|
|
20
21
|
exports.factory = factory;
|
|
21
|
-
const pecorinoapi = require("./pecorinoapi");
|
|
22
|
-
exports.pecorinoapi = pecorinoapi;
|
|
23
22
|
const repository = require("./repository");
|
|
24
23
|
exports.repository = repository;
|
|
25
24
|
const service = require("./service");
|
|
26
25
|
exports.service = service;
|
|
27
26
|
const settings = require("./settings");
|
|
28
27
|
exports.settings = settings;
|
|
28
|
+
let pecorinoapi;
|
|
29
|
+
function loadPecorinoapi() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
if (pecorinoapi === undefined) {
|
|
32
|
+
pecorinoapi = yield Promise.resolve().then(() => require('./pecorinoapi'));
|
|
33
|
+
}
|
|
34
|
+
return pecorinoapi;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.loadPecorinoapi = loadPecorinoapi;
|
|
38
|
+
let GMO;
|
|
39
|
+
function loadGMO() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (GMO === undefined) {
|
|
42
|
+
GMO = yield Promise.resolve().then(() => require('@motionpicture/gmo-service'));
|
|
43
|
+
}
|
|
44
|
+
return GMO;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.loadGMO = loadGMO;
|
|
@@ -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,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,8 +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 { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
26
|
-
import { Connection } from 'mongoose';
|
|
25
|
+
import type { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
26
|
+
import type { Connection } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
28
|
import * as EventFactory from '../factory/event';
|
|
29
29
|
export interface IAttributes4patchUpdate<T extends factory.eventType> {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -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 = exports.PROJECTION_MINIMIZED_EVENT = void 0;
|
|
24
|
-
const uniqid = require("uniqid");
|
|
25
24
|
const factory = require("../factory");
|
|
26
25
|
const EventFactory = require("../factory/event");
|
|
27
26
|
const event_1 = require("./mongoose/schemas/event");
|
|
@@ -468,6 +467,7 @@ class MongoRepository {
|
|
|
468
467
|
*/
|
|
469
468
|
createMany(params) {
|
|
470
469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
470
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
471
471
|
let docs;
|
|
472
472
|
try {
|
|
473
473
|
docs = yield this.eventModel.insertMany(params.attributes.map((p) => {
|
|
@@ -475,7 +475,7 @@ class MongoRepository {
|
|
|
475
475
|
}));
|
|
476
476
|
}
|
|
477
477
|
catch (error) {
|
|
478
|
-
if ((0, errorHandler_1.isMongoError)(error)) {
|
|
478
|
+
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
479
479
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
480
480
|
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
|
|
481
481
|
}
|
|
@@ -494,6 +494,7 @@ class MongoRepository {
|
|
|
494
494
|
*/
|
|
495
495
|
createManyIfNotExist(params) {
|
|
496
496
|
return __awaiter(this, void 0, void 0, function* () {
|
|
497
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
497
498
|
const bulkWriteOps = [];
|
|
498
499
|
const additionalProperties = [];
|
|
499
500
|
if (Array.isArray(params)) {
|
|
@@ -554,6 +555,7 @@ class MongoRepository {
|
|
|
554
555
|
*/
|
|
555
556
|
createScreeningEventSeriesIfNotExistByWorkPerformed(params) {
|
|
556
557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
558
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
557
559
|
const bulkWriteOps = [];
|
|
558
560
|
if (Array.isArray(params)) {
|
|
559
561
|
params.forEach((creatingEventParams) => {
|
|
@@ -624,6 +626,7 @@ class MongoRepository {
|
|
|
624
626
|
let doc;
|
|
625
627
|
try {
|
|
626
628
|
if (params.id === undefined) {
|
|
629
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
627
630
|
const id = uniqid();
|
|
628
631
|
doc = yield this.eventModel.create(Object.assign(Object.assign({}, params.attributes), { _id: id }));
|
|
629
632
|
}
|
|
@@ -641,7 +644,7 @@ class MongoRepository {
|
|
|
641
644
|
}
|
|
642
645
|
}
|
|
643
646
|
catch (error) {
|
|
644
|
-
if ((0, errorHandler_1.isMongoError)(error)) {
|
|
647
|
+
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
645
648
|
if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
|
|
646
649
|
throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
|
|
647
650
|
}
|
|
@@ -705,6 +708,7 @@ class MongoRepository {
|
|
|
705
708
|
return __awaiter(this, void 0, void 0, function* () {
|
|
706
709
|
let doc;
|
|
707
710
|
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
711
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
708
712
|
const id = uniqid();
|
|
709
713
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
710
714
|
'project.id': { $eq: params.attributes.project.id },
|
|
@@ -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
|
* IAMメンバーリポジトリ
|
|
@@ -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
|
* 返品ポリシーリポジトリ
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.MongoRepository = void 0;
|
|
24
24
|
const createDebug = require("debug");
|
|
25
25
|
const mongoose_1 = require("mongoose");
|
|
26
|
-
const uniqid = require("uniqid");
|
|
27
26
|
const factory = require("../factory");
|
|
28
27
|
const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
|
|
29
28
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
@@ -735,6 +734,7 @@ class MongoRepository {
|
|
|
735
734
|
const { $unset } = params, paramsWithoutUnset = __rest(params, ["$unset"]);
|
|
736
735
|
let savedUnitPriceOffer;
|
|
737
736
|
if (params.id === '') {
|
|
737
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
738
738
|
const id = uniqid();
|
|
739
739
|
savedUnitPriceOffer = Object.assign(Object.assign({}, paramsWithoutUnset), { id });
|
|
740
740
|
const aggregateOffer = {
|
|
@@ -783,6 +783,7 @@ class MongoRepository {
|
|
|
783
783
|
// tslint:disable-next-line:max-func-body-length
|
|
784
784
|
saveManyByIdentifier(params) {
|
|
785
785
|
return __awaiter(this, void 0, void 0, function* () {
|
|
786
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
786
787
|
const insertBulkWriteOps = [];
|
|
787
788
|
const updateBulkWriteOps = [];
|
|
788
789
|
if (Array.isArray(params)) {
|
|
@@ -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 IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & {
|
|
28
28
|
numberOfItems?: number;
|
|
@@ -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 uniqid = require("uniqid");
|
|
25
24
|
const factory = require("../factory");
|
|
26
25
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
27
26
|
/**
|
|
@@ -133,6 +132,7 @@ class MongoRepository {
|
|
|
133
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
133
|
let doc;
|
|
135
134
|
if (params.id === '') {
|
|
135
|
+
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
136
136
|
const id = uniqid();
|
|
137
137
|
doc = yield this.offerCatalogModel.create(Object.assign(Object.assign({}, params), { _id: id }));
|
|
138
138
|
}
|
|
@@ -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
|
* 注文リポジトリ
|