@chevre/domain 24.0.0-alpha.2 → 24.0.0-alpha.20
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/lib/chevre/repo/action/acceptCOAOffer.d.ts +23 -0
- package/lib/chevre/repo/action/acceptCOAOffer.js +64 -0
- package/lib/chevre/repo/action/acceptPay.d.ts +8 -0
- package/lib/chevre/repo/action/acceptPay.js +13 -0
- package/lib/chevre/repo/action/actionProcess.d.ts +115 -0
- package/lib/chevre/repo/action/actionProcess.js +293 -0
- package/lib/chevre/repo/action/authorizeOffer.d.ts +21 -0
- package/lib/chevre/repo/action/authorizeOffer.js +85 -0
- package/lib/chevre/repo/action/checkMovieTicket.d.ts +93 -0
- package/lib/chevre/repo/action/checkMovieTicket.js +200 -0
- package/lib/chevre/repo/action/checkThing.d.ts +8 -0
- package/lib/chevre/repo/action/checkThing.js +13 -0
- package/lib/chevre/repo/action.d.ts +9 -249
- package/lib/chevre/repo/action.js +308 -708
- package/lib/chevre/repo/aggregateAction.d.ts +102 -0
- package/lib/chevre/repo/aggregateAction.js +379 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.js +31 -0
- package/lib/chevre/repo/orderInTransaction.d.ts +8 -0
- package/lib/chevre/repo/orderInTransaction.js +16 -2
- package/lib/chevre/repo/orderNumber.d.ts +3 -2
- package/lib/chevre/repo/orderNumber.js +23 -28
- package/lib/chevre/repo/transaction/moneyTransfer.d.ts +61 -0
- package/lib/chevre/repo/transaction/moneyTransfer.js +379 -0
- package/lib/chevre/repo/transaction/placeOrder.d.ts +140 -0
- package/lib/chevre/repo/transaction/placeOrder.js +528 -0
- package/lib/chevre/repo/transaction/returnOrder.d.ts +45 -0
- package/lib/chevre/repo/transaction/returnOrder.js +341 -0
- package/lib/chevre/repo/transaction.d.ts +1 -125
- package/lib/chevre/repo/transaction.js +726 -632
- package/lib/chevre/repository.d.ts +49 -0
- package/lib/chevre/repository.js +107 -2
- package/lib/chevre/service/aggregation/system.d.ts +10 -10
- package/lib/chevre/service/aggregation/system.js +9 -9
- package/lib/chevre/service/assetTransaction/pay/check.d.ts +5 -4
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +5 -2
- package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +3 -3
- package/lib/chevre/service/assetTransaction/pay/start/factory.d.ts +51 -3
- package/lib/chevre/service/assetTransaction/pay/start/factory.js +58 -21
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.d.ts +10 -0
- package/lib/chevre/service/assetTransaction/pay/start/preStart/fixPaymentService.js +88 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.d.ts +55 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorize.js +56 -0
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +1 -11
- package/lib/chevre/service/assetTransaction/pay/start.d.ts +2 -0
- package/lib/chevre/service/assetTransaction/pay/start.js +8 -132
- package/lib/chevre/service/notification/triggerWebhook.d.ts +7 -6
- package/lib/chevre/service/offer/event/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize.js +3 -3
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +2 -2
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +0 -2
- package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.js +1 -0
- package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer/event/voidTransaction.js +2 -2
- package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +3 -3
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +16 -5
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +7 -7
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.d.ts +6 -4
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -10
- package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +21 -13
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +19 -10
- package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +6 -3
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.d.ts +2 -2
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +4 -1
- package/lib/chevre/service/offer/product.d.ts +3 -3
- package/lib/chevre/service/offer/product.js +4 -4
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
- package/lib/chevre/service/order/confirmPayTransaction.js +1 -0
- package/lib/chevre/service/order/findPlaceOrderTransaction.d.ts +2 -2
- package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.d.ts +16 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/isDeliverable.js +97 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.d.ts +21 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +86 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.d.ts +22 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionConfirmed.js +112 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.d.ts +22 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onReserveTransactionConfirmed.js +74 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.d.ts +25 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/paymentDue2Processing.js +111 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.d.ts +16 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/processing2inTransit.js +74 -0
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +8 -30
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +37 -348
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +6 -7
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +6 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.d.ts +7 -6
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
- package/lib/chevre/service/order/payOrder.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.d.ts +2 -2
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -1
- package/lib/chevre/service/order/placeOrder.d.ts +13 -12
- package/lib/chevre/service/order/returnOrder.d.ts +2 -2
- package/lib/chevre/service/order/returnOrder.js +1 -1
- package/lib/chevre/service/order/sendOrder.d.ts +6 -6
- package/lib/chevre/service/order/sendOrder.js +10 -8
- package/lib/chevre/service/order.d.ts +3 -6
- package/lib/chevre/service/order.js +3 -9
- package/lib/chevre/service/payment/any/{fixOrderAsNeeded.d.ts → authorize/fixOrderAsNeeded.d.ts} +6 -6
- package/lib/chevre/service/payment/any/{fixOrderAsNeeded.js → authorize/fixOrderAsNeeded.js} +5 -8
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +3 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +3 -3
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
- package/lib/chevre/service/payment/any/authorize.d.ts +92 -0
- package/lib/chevre/service/payment/any/authorize.js +225 -0
- package/lib/chevre/service/payment/any/findAcceptAction.d.ts +43 -0
- package/lib/chevre/service/payment/any/findAcceptAction.js +94 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.d.ts +41 -0
- package/lib/chevre/service/payment/any/findAuthorizeAction.js +83 -0
- package/lib/chevre/service/payment/any/findCheckAction.d.ts +45 -0
- package/lib/chevre/service/payment/any/findCheckAction.js +89 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.d.ts +28 -0
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +185 -0
- package/lib/chevre/service/payment/any/onPayActionCompleted.d.ts +7 -3
- package/lib/chevre/service/payment/any/onPayActionCompleted.js +3 -0
- package/lib/chevre/service/payment/any/processVoidPayTransaction.d.ts +29 -0
- package/lib/chevre/service/payment/any/processVoidPayTransaction.js +125 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +2 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +66 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +133 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.d.ts +31 -0
- package/lib/chevre/service/payment/any/voidPayTransaction.js +38 -0
- package/lib/chevre/service/payment/any.d.ts +8 -305
- package/lib/chevre/service/payment/any.js +17 -857
- package/lib/chevre/service/payment/movieTicket/authorize.d.ts +2 -0
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +3 -3
- package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +3 -3
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +11 -10
- package/lib/chevre/service/payment/movieTicket/validation.js +18 -15
- package/lib/chevre/service/report/telemetry.d.ts +4 -0
- package/lib/chevre/service/report/telemetry.js +7 -12
- package/lib/chevre/service/task/acceptCOAOffer.js +11 -6
- package/lib/chevre/service/task/authorizePayment.js +6 -2
- package/lib/chevre/service/task/checkMovieTicket.js +3 -3
- package/lib/chevre/service/task/checkResource.js +2 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +2 -2
- package/lib/chevre/service/task/deleteTransaction.js +7 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +4 -2
- package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -2
- package/lib/chevre/service/task/placeOrder.js +6 -4
- package/lib/chevre/service/task/publishPaymentUrl.js +8 -4
- package/lib/chevre/service/task/returnOrder.js +4 -4
- package/lib/chevre/service/task/returnPayTransaction.js +4 -3
- package/lib/chevre/service/task/sendOrder.js +4 -4
- package/lib/chevre/service/task/voidMoneyTransferTransaction.js +6 -3
- package/lib/chevre/service/task/voidPayTransaction.js +4 -2
- package/lib/chevre/service/task/voidRegisterServiceTransaction.js +3 -3
- package/lib/chevre/service/task/voidReserveTransaction.js +4 -3
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +6 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +56 -14
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +5 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +5 -5
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.js +10 -9
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +7 -6
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.d.ts → issueOrderNumberIfNotExist.d.ts} +4 -4
- package/lib/chevre/service/transaction/placeOrder/{publishOrderNumberIfNotExist.js → issueOrderNumberIfNotExist.js} +21 -13
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/publishConfirmationNumberIfNotExist.js +3 -3
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +3 -3
- package/lib/chevre/service/transaction/placeOrder/start.js +2 -2
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +23 -0
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +126 -0
- package/lib/chevre/service/transaction/placeOrder.d.ts +2 -1
- package/lib/chevre/service/transaction/placeOrder.js +3 -1
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +1 -1
- package/lib/chevre/service/transaction/returnOrder.d.ts +16 -14
- package/lib/chevre/service/transaction/returnOrder.js +4 -4
- package/lib/chevre/service/transaction.d.ts +9 -21
- package/lib/chevre/service/transaction.js +5 -111
- package/package.json +4 -8
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IActionRecipe, IKeyOfProjection, ActionProcessRepo } from './actionProcess';
|
|
3
|
+
export type IAcceptCOAOfferAction = factory.action.accept.coaOffer.IAction;
|
|
4
|
+
/**
|
|
5
|
+
* COAオファー採用リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class AcceptCOAOfferActionRepo extends ActionProcessRepo<IAcceptCOAOfferAction, IActionRecipe<factory.recipe.RecipeCategory.acceptCOAOffer>> {
|
|
8
|
+
/**
|
|
9
|
+
* 完了済の採用アクションを参照する
|
|
10
|
+
*/
|
|
11
|
+
findCompletedById(params: {
|
|
12
|
+
project: {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* アクションID
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
purpose: {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
}, inclusion: IKeyOfProjection[]): Promise<IAcceptCOAOfferAction>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AcceptCOAOfferActionRepo = void 0;
|
|
27
|
+
const factory = __importStar(require("../../factory"));
|
|
28
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
29
|
+
// import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
|
|
30
|
+
// import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
|
|
31
|
+
const actionProcess_1 = require("./actionProcess");
|
|
32
|
+
/**
|
|
33
|
+
* COAオファー採用リポジトリ
|
|
34
|
+
*/
|
|
35
|
+
class AcceptCOAOfferActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
36
|
+
/**
|
|
37
|
+
* 完了済の採用アクションを参照する
|
|
38
|
+
*/
|
|
39
|
+
async findCompletedById(params, inclusion) {
|
|
40
|
+
let positiveProjectionFields = actionProcess_1.AVAILABLE_PROJECT_FIELDS;
|
|
41
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
42
|
+
positiveProjectionFields = inclusion.filter((key) => actionProcess_1.AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
43
|
+
}
|
|
44
|
+
const projection = {
|
|
45
|
+
_id: 0,
|
|
46
|
+
id: { $toString: '$_id' },
|
|
47
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
48
|
+
};
|
|
49
|
+
const doc = await this.actionModel.findOne({
|
|
50
|
+
_id: { $eq: params.id },
|
|
51
|
+
typeOf: { $eq: factory.actionType.AcceptAction },
|
|
52
|
+
'project.id': { $eq: params.project.id },
|
|
53
|
+
'purpose.id': { $exists: true, $eq: params.purpose.id },
|
|
54
|
+
actionStatus: { $in: [factory.actionStatusType.CompletedActionStatus] }
|
|
55
|
+
}, projection)
|
|
56
|
+
.lean()
|
|
57
|
+
.exec();
|
|
58
|
+
if (doc === null) {
|
|
59
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
60
|
+
}
|
|
61
|
+
return doc;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.AcceptCOAOfferActionRepo = AcceptCOAOfferActionRepo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IActionRecipe, ActionProcessRepo } from './actionProcess';
|
|
3
|
+
export type IAcceptPayAction = factory.action.accept.pay.IAction;
|
|
4
|
+
/**
|
|
5
|
+
* 決済採用リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class AcceptPayActionRepo extends ActionProcessRepo<IAcceptPayAction, IActionRecipe<factory.recipe.RecipeCategory.publishPaymentUrl>> {
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AcceptPayActionRepo = void 0;
|
|
4
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
5
|
+
// import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
|
|
6
|
+
// import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
|
|
7
|
+
const actionProcess_1 = require("./actionProcess");
|
|
8
|
+
/**
|
|
9
|
+
* 決済採用リポジトリ
|
|
10
|
+
*/
|
|
11
|
+
class AcceptPayActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
12
|
+
}
|
|
13
|
+
exports.AcceptPayActionRepo = AcceptPayActionRepo;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
import { IModel as IActionModel } from '../mongoose/schemas/action';
|
|
4
|
+
import { IModel as IActionRecipeModel } from '../mongoose/schemas/actionRecipe';
|
|
5
|
+
export type IAction4transaction<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction> = T extends factory.actionType.AcceptAction ? factory.action.accept.coaOffer.IAction | factory.action.accept.pay.IAction : T extends factory.actionType.AuthorizeAction ? (factory.action.authorize.offer.eventService.IAction | factory.action.authorize.offer.moneyTransfer.IAction | factory.action.authorize.offer.product.IAction | factory.action.authorize.paymentMethod.any.IAction) : never;
|
|
6
|
+
export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.thing.IAction) : T extends factory.actionType.CreateAction ? factory.action.create.IAction : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.AddAction ? factory.action.update.add.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAction : T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction<factory.action.interact.inform.IAttributes<factory.action.interact.inform.IObject>> & {
|
|
7
|
+
error?: any;
|
|
8
|
+
purpose?: never;
|
|
9
|
+
} : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
|
|
10
|
+
export interface ICancelActionAction {
|
|
11
|
+
typeOf: factory.actionType.CancelAction;
|
|
12
|
+
agent: factory.action.IParticipantAsPerson | factory.action.IParticipantAsProject | factory.action.IParticipantAsWebApplication;
|
|
13
|
+
endTime: Date;
|
|
14
|
+
startTime: Date;
|
|
15
|
+
sameAs?: {
|
|
16
|
+
id: string;
|
|
17
|
+
typeOf: 'Task';
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type IActionRecipe<T extends factory.recipe.RecipeCategory> = T extends factory.recipe.RecipeCategory.checkMovieTicket ? factory.action.check.paymentMethod.movieTicket.IRecipe : T extends factory.recipe.RecipeCategory.payCreditCard ? factory.action.trade.pay.IPayCreditCardRecipe : T extends factory.recipe.RecipeCategory.payMovieTicket ? factory.action.trade.pay.IPayMovieTicketRecipe : T extends factory.recipe.RecipeCategory.publishPaymentUrl ? factory.action.accept.pay.IRecipe : T extends factory.recipe.RecipeCategory.refundCreditCard ? factory.action.trade.refund.IRefundCreditCardRecipe : T extends factory.recipe.RecipeCategory.refundMovieTicket ? factory.action.trade.refund.IRefundMovieTicketRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice ? factory.action.authorize.invoice.IAuthorizeInvoiceRecipe : T extends factory.recipe.RecipeCategory.authorizeInvoice3ds ? factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe : T extends factory.recipe.RecipeCategory.acceptCOAOffer ? factory.action.accept.coaOffer.IRecipe : T extends factory.recipe.RecipeCategory.confirmCOAReserve ? factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe : T extends factory.recipe.RecipeCategory.cancelPendingCOAReserve ? factory.action.cancel.coaReserve.ICancelPendingCOAReserveRecipe : T extends factory.recipe.RecipeCategory.returnCOAReserve ? factory.action.transfer.returnAction.reserveTransaction.IReturnCOAReserveRecipe : T extends factory.recipe.RecipeCategory.sendEmailMessage ? factory.action.transfer.send.message.email.IRecipe : never;
|
|
21
|
+
export type IRecipeAsDocument = factory.recipe.IRecipe & {
|
|
22
|
+
recipeFor: {
|
|
23
|
+
id: string;
|
|
24
|
+
typeOf: factory.actionType;
|
|
25
|
+
};
|
|
26
|
+
dateCreated: Date;
|
|
27
|
+
dateModified?: Date;
|
|
28
|
+
};
|
|
29
|
+
export type IRecipeAsActionAttributes<T extends factory.recipe.RecipeCategory> = Pick<IActionRecipe<T>, 'project' | 'recipeCategory' | 'step' | 'typeOf'>;
|
|
30
|
+
export type IMinimizedPurchaseNumberAuthResult = Pick<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult, 'mkknmiNumSum' | 'resultInfo' | 'ykknmiNumSum'> & {
|
|
31
|
+
knyknrNoInfoOut: Omit<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberInfo, 'ykknInfo' | 'mkknInfo'>[] | null;
|
|
32
|
+
};
|
|
33
|
+
export type IKeyOfProjection = keyof IAction<factory.actionType> | keyof IAction<factory.actionType.AuthorizeAction> | keyof IAction<factory.actionType.MoneyTransfer> | keyof IAction<factory.actionType.ReplaceAction> | 'identifier';
|
|
34
|
+
export declare const AVAILABLE_PROJECT_FIELDS: IKeyOfProjection[];
|
|
35
|
+
/**
|
|
36
|
+
* アクション状態管理リポジトリ
|
|
37
|
+
*/
|
|
38
|
+
export declare class ActionProcessRepo<TAction extends IAction<factory.actionType>, TActionRecipe extends IActionRecipe<factory.recipe.RecipeCategory>> {
|
|
39
|
+
protected readonly actionModel: IActionModel;
|
|
40
|
+
protected readonly actionRecipeModel: IActionRecipeModel;
|
|
41
|
+
constructor(connection: Connection);
|
|
42
|
+
/**
|
|
43
|
+
* アクション開始
|
|
44
|
+
*/
|
|
45
|
+
start<T extends TAction['typeOf']>(attributes: factory.action.IAttributes<T, any, any>, options?: {
|
|
46
|
+
recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
|
|
47
|
+
}): Promise<Pick<IAction<T>, 'id' | 'typeOf' | 'startDate'>>;
|
|
48
|
+
completeWithVoid(params: {
|
|
49
|
+
typeOf: TAction['typeOf'];
|
|
50
|
+
id: string;
|
|
51
|
+
result: any;
|
|
52
|
+
recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* アクション取消
|
|
56
|
+
*/
|
|
57
|
+
cancelWithVoid(params: {
|
|
58
|
+
typeOf: factory.actionType.AcceptAction | factory.actionType.AuthorizeAction;
|
|
59
|
+
id: string;
|
|
60
|
+
cancelAction?: Pick<ICancelActionAction, 'agent' | 'sameAs' | 'startTime'>;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* アクション失敗
|
|
64
|
+
*/
|
|
65
|
+
giveUp(params: {
|
|
66
|
+
typeOf: TAction['typeOf'];
|
|
67
|
+
id: string;
|
|
68
|
+
error: Error | Error[];
|
|
69
|
+
recipe?: IRecipeAsActionAttributes<TActionRecipe['recipeCategory']>;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
73
|
+
*/
|
|
74
|
+
giveUpStartDatePassedCertainPeriod(params: {
|
|
75
|
+
id?: {
|
|
76
|
+
$eq?: string;
|
|
77
|
+
};
|
|
78
|
+
error: any;
|
|
79
|
+
startDate: {
|
|
80
|
+
$lt: Date;
|
|
81
|
+
};
|
|
82
|
+
}): Promise<any>;
|
|
83
|
+
findRecipeByAction<T extends TActionRecipe['recipeCategory']>(params: {
|
|
84
|
+
project: {
|
|
85
|
+
id: string;
|
|
86
|
+
};
|
|
87
|
+
recipeFor: {
|
|
88
|
+
id: string;
|
|
89
|
+
};
|
|
90
|
+
}): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
|
|
91
|
+
findById(params: {
|
|
92
|
+
typeOf: TAction['typeOf'];
|
|
93
|
+
id: string;
|
|
94
|
+
}, inclusion?: IKeyOfProjection[], exclusion?: IKeyOfProjection[]): Promise<TAction>;
|
|
95
|
+
searchBySameAs(params: {
|
|
96
|
+
sameAs: {
|
|
97
|
+
id: {
|
|
98
|
+
$eq: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
purpose?: {
|
|
102
|
+
id: {
|
|
103
|
+
$eq: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
|
|
108
|
+
*/
|
|
109
|
+
typeOf: {
|
|
110
|
+
$eq: TAction['typeOf'];
|
|
111
|
+
};
|
|
112
|
+
}): Promise<Pick<TAction, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
|
|
113
|
+
private findActionStatusById;
|
|
114
|
+
protected upsertRecipe(savingRecipe: Pick<IRecipeAsDocument, 'project' | 'recipeCategory' | 'recipeFor' | 'step' | 'typeOf'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
115
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ActionProcessRepo = exports.AVAILABLE_PROJECT_FIELDS = void 0;
|
|
27
|
+
const factory = __importStar(require("../../factory"));
|
|
28
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
29
|
+
const action_1 = require("../mongoose/schemas/action");
|
|
30
|
+
const actionRecipe_1 = require("../mongoose/schemas/actionRecipe");
|
|
31
|
+
exports.AVAILABLE_PROJECT_FIELDS = [
|
|
32
|
+
'project',
|
|
33
|
+
'actionStatus',
|
|
34
|
+
'typeOf',
|
|
35
|
+
'description',
|
|
36
|
+
'agent',
|
|
37
|
+
'recipient',
|
|
38
|
+
'result',
|
|
39
|
+
'error',
|
|
40
|
+
'object',
|
|
41
|
+
'startDate',
|
|
42
|
+
'endDate',
|
|
43
|
+
'purpose',
|
|
44
|
+
'potentialActions',
|
|
45
|
+
'amount',
|
|
46
|
+
'fromLocation',
|
|
47
|
+
'toLocation',
|
|
48
|
+
'instrument',
|
|
49
|
+
'location',
|
|
50
|
+
'replacer',
|
|
51
|
+
'targetCollection',
|
|
52
|
+
'sameAs',
|
|
53
|
+
'cancelAction',
|
|
54
|
+
'about',
|
|
55
|
+
'target',
|
|
56
|
+
'identifier'
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* アクション状態管理リポジトリ
|
|
60
|
+
*/
|
|
61
|
+
class ActionProcessRepo {
|
|
62
|
+
actionModel;
|
|
63
|
+
actionRecipeModel;
|
|
64
|
+
constructor(connection) {
|
|
65
|
+
this.actionModel = connection.model(action_1.modelName, (0, action_1.createSchema)());
|
|
66
|
+
this.actionRecipeModel = connection.model(actionRecipe_1.modelName, (0, actionRecipe_1.createSchema)());
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* アクション開始
|
|
70
|
+
*/
|
|
71
|
+
async start(
|
|
72
|
+
// public async start<T extends Exclude<TAction['typeOf'], factory.actionType.AcceptAction>>(
|
|
73
|
+
attributes, options) {
|
|
74
|
+
const startDate = new Date();
|
|
75
|
+
const creatingAction = {
|
|
76
|
+
...attributes,
|
|
77
|
+
actionStatus: factory.actionStatusType.ActiveActionStatus,
|
|
78
|
+
startDate
|
|
79
|
+
};
|
|
80
|
+
// reimplemnt with insertMany(2024-08-29~)
|
|
81
|
+
const result = await this.actionModel.insertMany(creatingAction, { rawResult: true });
|
|
82
|
+
const id = result.insertedIds?.[0]?.toHexString();
|
|
83
|
+
if (typeof id !== 'string') {
|
|
84
|
+
throw new factory.errors.Internal('action not saved');
|
|
85
|
+
}
|
|
86
|
+
// add recipe(2024-06-09~)
|
|
87
|
+
const savingRecipe = options?.recipe;
|
|
88
|
+
if (savingRecipe?.typeOf === 'Recipe') {
|
|
89
|
+
await this.upsertRecipe({ ...savingRecipe, recipeFor: { id, typeOf: creatingAction.typeOf } });
|
|
90
|
+
}
|
|
91
|
+
return { id, startDate, typeOf: creatingAction.typeOf };
|
|
92
|
+
}
|
|
93
|
+
async completeWithVoid(params) {
|
|
94
|
+
if (params.recipe?.typeOf === 'Recipe') {
|
|
95
|
+
await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
96
|
+
}
|
|
97
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
98
|
+
_id: { $eq: params.id },
|
|
99
|
+
typeOf: { $eq: params.typeOf }
|
|
100
|
+
}, {
|
|
101
|
+
$set: {
|
|
102
|
+
actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
103
|
+
result: params.result,
|
|
104
|
+
endDate: new Date()
|
|
105
|
+
}
|
|
106
|
+
}, { new: false, projection: { _id: 1 } })
|
|
107
|
+
.lean()
|
|
108
|
+
.exec();
|
|
109
|
+
if (doc === null) {
|
|
110
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* アクション取消
|
|
115
|
+
*/
|
|
116
|
+
async cancelWithVoid(params) {
|
|
117
|
+
const cancelDate = new Date();
|
|
118
|
+
const cancelAction = (params.cancelAction !== undefined)
|
|
119
|
+
? {
|
|
120
|
+
...params.cancelAction,
|
|
121
|
+
endTime: cancelDate,
|
|
122
|
+
typeOf: factory.actionType.CancelAction
|
|
123
|
+
}
|
|
124
|
+
: undefined;
|
|
125
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
126
|
+
_id: { $eq: params.id },
|
|
127
|
+
typeOf: { $eq: params.typeOf },
|
|
128
|
+
actionStatus: { $ne: factory.actionStatusType.CanceledActionStatus } // 冪等性確保(2024-05-26~)
|
|
129
|
+
}, {
|
|
130
|
+
$set: {
|
|
131
|
+
actionStatus: factory.actionStatusType.CanceledActionStatus,
|
|
132
|
+
...(cancelAction !== undefined) ? { cancelAction } : undefined // cancelAction連携(2024-05-26~)
|
|
133
|
+
}
|
|
134
|
+
}, { new: false, projection: { _id: 1 } })
|
|
135
|
+
.lean()
|
|
136
|
+
.exec();
|
|
137
|
+
if (doc === null) {
|
|
138
|
+
// 既にCanceledActionStatusであればok
|
|
139
|
+
const existingAction = await this.findActionStatusById({ id: params.id, typeOf: params.typeOf });
|
|
140
|
+
if (existingAction.actionStatus !== factory.actionStatusType.CanceledActionStatus) {
|
|
141
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// endDateが存在しなければセット(2024-04-22~)
|
|
145
|
+
await this.actionModel.updateOne({
|
|
146
|
+
_id: { $eq: params.id },
|
|
147
|
+
endDate: { $exists: false }
|
|
148
|
+
}, { $set: { endDate: cancelDate } })
|
|
149
|
+
.exec();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* アクション失敗
|
|
153
|
+
*/
|
|
154
|
+
async giveUp(params) {
|
|
155
|
+
const actionError = (Array.isArray(params.error))
|
|
156
|
+
? params.error.map((e) => ({ ...e, message: e.message, name: e.name }))
|
|
157
|
+
: { ...params.error, message: params.error.message, name: params.error.name };
|
|
158
|
+
if (params.recipe?.typeOf === 'Recipe') {
|
|
159
|
+
await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
160
|
+
}
|
|
161
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
162
|
+
typeOf: { $eq: params.typeOf },
|
|
163
|
+
_id: { $eq: params.id }
|
|
164
|
+
}, {
|
|
165
|
+
$set: {
|
|
166
|
+
actionStatus: factory.actionStatusType.FailedActionStatus,
|
|
167
|
+
error: actionError,
|
|
168
|
+
endDate: new Date()
|
|
169
|
+
}
|
|
170
|
+
}, { new: true, projection: { _id: 1 } })
|
|
171
|
+
.lean()
|
|
172
|
+
.exec();
|
|
173
|
+
if (doc === null) {
|
|
174
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
|
|
179
|
+
*/
|
|
180
|
+
async giveUpStartDatePassedCertainPeriod(params) {
|
|
181
|
+
return this.actionModel.updateMany({
|
|
182
|
+
actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus },
|
|
183
|
+
// 一定期間過ぎたもの
|
|
184
|
+
startDate: { $lt: params.startDate.$lt },
|
|
185
|
+
...(typeof params.id?.$eq === 'string') ? { _id: { $eq: params.id.$eq } } : undefined
|
|
186
|
+
}, {
|
|
187
|
+
actionStatus: factory.actionStatusType.FailedActionStatus,
|
|
188
|
+
error: params.error,
|
|
189
|
+
endDate: new Date()
|
|
190
|
+
})
|
|
191
|
+
.exec();
|
|
192
|
+
}
|
|
193
|
+
async findRecipeByAction(params) {
|
|
194
|
+
return this.actionRecipeModel.findOne({
|
|
195
|
+
'project.id': { $eq: params.project.id },
|
|
196
|
+
'recipeFor.id': { $eq: params.recipeFor.id }
|
|
197
|
+
}, { step: 1, recipeCategory: 1 }
|
|
198
|
+
// { lean: true }
|
|
199
|
+
)
|
|
200
|
+
.lean()
|
|
201
|
+
.exec();
|
|
202
|
+
// if (result === null) {
|
|
203
|
+
// throw new factory.errors.NotFound(this.actionRecipeModel.modelName);
|
|
204
|
+
// }
|
|
205
|
+
// return result;
|
|
206
|
+
}
|
|
207
|
+
async findById(params, inclusion, exclusion) {
|
|
208
|
+
let positiveProjectionFields = exports.AVAILABLE_PROJECT_FIELDS;
|
|
209
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
210
|
+
positiveProjectionFields = inclusion.filter((key) => exports.AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
214
|
+
positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const projection = {
|
|
218
|
+
_id: 0,
|
|
219
|
+
id: { $toString: '$_id' },
|
|
220
|
+
...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
|
|
221
|
+
};
|
|
222
|
+
const doc = await this.actionModel.findOne({
|
|
223
|
+
typeOf: { $eq: params.typeOf },
|
|
224
|
+
_id: { $eq: params.id }
|
|
225
|
+
}, projection)
|
|
226
|
+
.lean() // 2024-08-26~
|
|
227
|
+
.exec();
|
|
228
|
+
if (doc === null) {
|
|
229
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
230
|
+
}
|
|
231
|
+
return doc;
|
|
232
|
+
}
|
|
233
|
+
async searchBySameAs(params) {
|
|
234
|
+
const projection = {
|
|
235
|
+
_id: 0,
|
|
236
|
+
id: { $toString: '$_id' },
|
|
237
|
+
actionStatus: 1,
|
|
238
|
+
error: 1,
|
|
239
|
+
purpose: 1
|
|
240
|
+
};
|
|
241
|
+
const query = this.actionModel.find({
|
|
242
|
+
typeOf: { $eq: params.typeOf.$eq },
|
|
243
|
+
'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq },
|
|
244
|
+
...(typeof params.purpose?.id.$eq === 'string')
|
|
245
|
+
? { 'purpose.id': { $exists: true, $eq: params.purpose.id.$eq } }
|
|
246
|
+
: undefined
|
|
247
|
+
}, projection)
|
|
248
|
+
// .select({ _id: 1, actionStatus: 1, error: 1, purpose: 1 })
|
|
249
|
+
.limit(1);
|
|
250
|
+
return query
|
|
251
|
+
.lean() // 2024-08-26~
|
|
252
|
+
.exec();
|
|
253
|
+
}
|
|
254
|
+
async findActionStatusById(params) {
|
|
255
|
+
const projection = {
|
|
256
|
+
_id: 0,
|
|
257
|
+
id: { $toString: '$_id' },
|
|
258
|
+
actionStatus: 1
|
|
259
|
+
};
|
|
260
|
+
const doc = await this.actionModel.findOne({
|
|
261
|
+
typeOf: { $eq: params.typeOf },
|
|
262
|
+
_id: { $eq: params.id }
|
|
263
|
+
}, projection)
|
|
264
|
+
.lean() // 2024-08-26~
|
|
265
|
+
.exec();
|
|
266
|
+
if (doc === null) {
|
|
267
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
268
|
+
}
|
|
269
|
+
return doc;
|
|
270
|
+
}
|
|
271
|
+
async upsertRecipe(savingRecipe) {
|
|
272
|
+
const dateModified = new Date();
|
|
273
|
+
const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
|
|
274
|
+
const filter = {
|
|
275
|
+
'recipeFor.id': { $eq: recipeFor.id }
|
|
276
|
+
};
|
|
277
|
+
const setOnInsert = {
|
|
278
|
+
project, typeOf, recipeCategory, recipeFor,
|
|
279
|
+
dateCreated: dateModified
|
|
280
|
+
};
|
|
281
|
+
const setKeys = { step, dateModified };
|
|
282
|
+
const update = {
|
|
283
|
+
$setOnInsert: setOnInsert,
|
|
284
|
+
$set: setKeys
|
|
285
|
+
};
|
|
286
|
+
return this.actionRecipeModel.updateOne(filter, update, {
|
|
287
|
+
upsert: true,
|
|
288
|
+
includeResultMetadata: true
|
|
289
|
+
})
|
|
290
|
+
.exec();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.ActionProcessRepo = ActionProcessRepo;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { ActionProcessRepo } from './actionProcess';
|
|
3
|
+
export type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction;
|
|
4
|
+
/**
|
|
5
|
+
* オファー承認リポジトリ
|
|
6
|
+
*/
|
|
7
|
+
export declare class AuthorizeOfferActionRepo extends ActionProcessRepo<IAuthorizeOfferAction, never> {
|
|
8
|
+
/**
|
|
9
|
+
* アクション再開
|
|
10
|
+
*/
|
|
11
|
+
reStart(params: {
|
|
12
|
+
typeOf: factory.actionType;
|
|
13
|
+
id: string;
|
|
14
|
+
recipe?: never;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
reCompleteAuthorizeEventOfferAction(params: {
|
|
17
|
+
id: string;
|
|
18
|
+
object: factory.action.authorize.offer.eventService.IObject;
|
|
19
|
+
result: factory.action.authorize.offer.eventService.IResult;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AuthorizeOfferActionRepo = void 0;
|
|
27
|
+
const factory = __importStar(require("../../factory"));
|
|
28
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
29
|
+
// import { createSchema, IModel as IActionModel, modelName } from './mongoose/schemas/action';
|
|
30
|
+
// import { createSchema as createRecipeSchema, IModel as IActionRecipeModel, modelName as recipeModelName } from './mongoose/schemas/actionRecipe';
|
|
31
|
+
const actionProcess_1 = require("./actionProcess");
|
|
32
|
+
/**
|
|
33
|
+
* オファー承認リポジトリ
|
|
34
|
+
*/
|
|
35
|
+
class AuthorizeOfferActionRepo extends actionProcess_1.ActionProcessRepo {
|
|
36
|
+
/**
|
|
37
|
+
* アクション再開
|
|
38
|
+
*/
|
|
39
|
+
async reStart(params) {
|
|
40
|
+
const doc = await this.actionModel.findOneAndUpdate({
|
|
41
|
+
_id: { $eq: params.id },
|
|
42
|
+
typeOf: { $eq: params.typeOf },
|
|
43
|
+
actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
|
|
44
|
+
}, {
|
|
45
|
+
$set: {
|
|
46
|
+
actionStatus: factory.actionStatusType.ActiveActionStatus,
|
|
47
|
+
startDate: new Date()
|
|
48
|
+
},
|
|
49
|
+
$unset: { endDate: 1 }
|
|
50
|
+
}, { new: false, projection: { _id: 1 } })
|
|
51
|
+
.lean()
|
|
52
|
+
.exec();
|
|
53
|
+
if (doc === null) {
|
|
54
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
55
|
+
}
|
|
56
|
+
// // add recipe(2024-06-09~)
|
|
57
|
+
// if (params.recipe?.typeOf === 'Recipe') {
|
|
58
|
+
// await this.upsertRecipe({ ...params.recipe, recipeFor: { id: params.id, typeOf: params.typeOf } });
|
|
59
|
+
// }
|
|
60
|
+
}
|
|
61
|
+
async reCompleteAuthorizeEventOfferAction(params) {
|
|
62
|
+
return this.actionModel.findOneAndUpdate({
|
|
63
|
+
// typeOf: factory.actionType.AuthorizeAction,
|
|
64
|
+
_id: { $eq: params.id },
|
|
65
|
+
// ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
|
|
66
|
+
// actionStatus: factory.actionStatusType.CompletedActionStatus
|
|
67
|
+
actionStatus: { $eq: factory.actionStatusType.ActiveActionStatus }
|
|
68
|
+
}, {
|
|
69
|
+
$set: {
|
|
70
|
+
actionStatus: factory.actionStatusType.CompletedActionStatus,
|
|
71
|
+
object: params.object,
|
|
72
|
+
result: params.result,
|
|
73
|
+
endDate: new Date()
|
|
74
|
+
}
|
|
75
|
+
}, { new: true, projection: { _id: 1 } })
|
|
76
|
+
.lean()
|
|
77
|
+
.exec()
|
|
78
|
+
.then((doc) => {
|
|
79
|
+
if (doc === null) {
|
|
80
|
+
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.AuthorizeOfferActionRepo = AuthorizeOfferActionRepo;
|