UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

363 lines (362 loc) 14.2 kB
import { factory as surfrockFactory } from '@surfrock/sdk'; import { Connection, FilterQuery, UpdateQuery } from 'mongoose'; import * as factory from '../factory'; 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; 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.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction<factory.action.update.replace.IAttributes<any, any>> : T extends factory.actionType.InformAction ? factory.action.interact.inform.IAction<factory.action.interact.inform.IAttributes<factory.action.interact.inform.IObject>> & { error?: any; purpose?: never; } : factory.action.IAction<factory.action.IAttributes<T, any, any>>; interface IAggregationByStatus { actionCount: number; avgDuration: number; maxDuration: number; minDuration: number; percentilesDuration: { name: string; value: number; }[]; } interface IStatus { status: factory.actionStatusType; aggregation: IAggregationByStatus; } interface IAggregateAction { statuses: IStatus[]; } export interface ICancelActionAction { typeOf: factory.actionType.CancelAction; agent: factory.action.IParticipantAsPerson | factory.action.IParticipantAsProject | factory.action.IParticipantAsWebApplication; endTime: Date; startTime: Date; sameAs?: { id: string; typeOf: 'Task'; }; } 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.acceptCOAOffer ? factory.action.accept.coaOffer.IRecipe : T extends factory.recipe.RecipeCategory.confirmCOAReserve ? factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe : never; export type IRecipeAsDocument = factory.recipe.IRecipe & { recipeFor: { id: string; typeOf: factory.actionType; }; dateCreated: Date; dateModified?: Date; }; export type IRecipeAsActionAttributes = Pick<factory.recipe.IRecipe, 'project' | 'recipeCategory' | 'step' | 'typeOf'>; export type IMinimizedPurchaseNumberAuthResult = Pick<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult, 'mkknmiNumSum' | 'resultInfo' | 'ykknmiNumSum'> & { knyknrNoInfoOut: Omit<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberInfo, 'ykknInfo' | 'mkknInfo'>[] | null; }; type IKeyOfProjection = keyof IAction<factory.actionType> | keyof IAction<factory.actionType.AuthorizeAction> | keyof IAction<factory.actionType.MoneyTransfer> | keyof IAction<factory.actionType.ReplaceAction> | 'identifier'; /** * アクションリポジトリ */ export declare class ActionRepo { private readonly actionModel; private readonly actionRecipeModel; constructor(connection: Connection); static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): any[]; /** * アクション検索 */ search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAction<T>[]>; /** * アクション開始 */ start<T extends factory.actionType>(attributes: factory.action.IAttributes<T, any, any>, options?: { recipe?: IRecipeAsActionAttributes; }): Promise<Pick<IAction<T>, 'id' | 'typeOf' | 'startDate'>>; completeWithVoid(params: { typeOf: factory.actionType; id: string; result: any; recipe?: IRecipeAsActionAttributes; }): Promise<void>; /** * アクション取消 */ cancelWithVoid(params: { typeOf: factory.actionType.AcceptAction | factory.actionType.AuthorizeAction; id: string; cancelAction?: Pick<ICancelActionAction, 'agent' | 'sameAs' | 'startTime'>; }): Promise<void>; /** * アクション失敗 */ giveUp(params: { typeOf: factory.actionType; id: string; error: Error | Error[]; recipe?: IRecipeAsActionAttributes; }): Promise<void>; /** * アクション再開 */ reStart(params: { typeOf: factory.actionType; id: string; recipe?: IRecipeAsActionAttributes; }): Promise<void>; /** * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする */ giveUpStartDatePassedCertainPeriod(params: { id?: { $eq?: string; }; error: any; startDate: { $lt: Date; }; }): Promise<any>; findById<T extends factory.actionType>(params: { typeOf: T; id: string; }, inclusion?: IKeyOfProjection[], exclusion?: IKeyOfProjection[]): Promise<IAction<T>>; findPayAction(params: { project: { id: string; }; paymentMethodId: string; actionStatus?: { $in?: factory.actionStatusType[]; }; }): Promise<factory.action.trade.pay.IAction | undefined>; /** * 取引に対するアクションを検索する */ searchByPurpose<T extends factory.actionType.AcceptAction | factory.actionType.AuthorizeAction>(params: { typeOf?: T; purpose: { typeOf: factory.transactionType; id: string; }; object?: { typeOf?: { $eq?: factory.action.authorize.offer.eventService.ObjectType.SeatReservation | factory.action.authorize.paymentMethod.any.ResultType.Payment | factory.offerType.AggregateOffer; }; paymentMethodId?: { $eq?: string; }; }; actionStatus?: { $eq?: factory.actionStatusType.CompletedActionStatus; }; sort?: factory.action.ISortOrder; }): Promise<IAction4transaction<T>[]>; /** * 注文番号から、注文に対するアクションを検索する */ searchByOrderNumber(params: { orderNumber: string; sort?: factory.action.ISortOrder; }): Promise<IAction<factory.actionType>[]>; searchBySameAs<T extends factory.actionType>(params: { sameAs: { id: { $eq: string; }; }; purpose?: { id: { $eq: string; }; }; /** * 1taskから複数actionが発生する可能性があるので、typeOf指定が必須 */ typeOf: { $eq: T; }; }): Promise<Pick<IAction<T>, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>; deleteByProject(params: { project: { id: string; }; }): Promise<void>; reCompleteAuthorizeEventOfferAction(params: { id: string; object: factory.action.authorize.offer.eventService.IObject; result: factory.action.authorize.offer.eventService.IResult; }): Promise<void>; updateById(params: { id: string; update: any; }): Promise<void>; findByIdAndUpdate(params: { id: string; update: UpdateQuery<IAction<factory.actionType>>; }): Promise<void>; /** * イベントと入場ゲート指定で予約使用アクションを集計する * discontinue(2024-12-26~) */ searchYkknInfoByCheckRecipe(filter: { limit: number; page: number; /** * 認証アクションID */ id: string; project: { id: string; }; purpose: { id: string; }; }): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.IValidTicket & { knyknrNo: string; })[]>; searchMkknInfoByCheckRecipe(filter: { limit: number; page: number; /** * 認証アクションID */ id: string; project: { id: string; }; purpose: { id: string; }; }): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.INvalidTicket & { knyknrNo: string; })[]>; /** * 開始日時を一定期間過ぎたアクションを削除する */ deleteStartDatePassedCertainPeriod(params: { $lt: Date; }): Promise<any>; /** * 終了日時を一定期間過ぎたアクションを削除する * 作成日時を一定期間過ぎたアクションレシピも削除する */ deleteEndDatePassedCertainPeriod(params: { $lt: Date; }): Promise<void>; /** * 取引からアクションを削除する */ deleteByPurpose(params: { project: { id: string; }; purpose: { typeOf: factory.transactionType; id: string; }; typeOf: { $in: factory.actionType[]; }; }): Promise<{ deletedCount?: number; } | null>; saveActionWithEndDate(savingAction: Omit<factory.action.authorize.invoice.IAction, 'id'>): Promise<import("mongoose").UpdateWriteOpResult>; findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: { project: { id: string; }; recipeFor: { id: string; }; }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>; findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params: { project: { id: string; }; recipeFor: { id: string; }; }): Promise<IMinimizedPurchaseNumberAuthResult | undefined>; aggregateAuthorizeEventServiceOfferAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; typeOf: factory.actionType; }): Promise<IAggregateAction>; aggregateAuthorizePaymentAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; typeOf: factory.actionType; }): Promise<IAggregateAction>; aggregateAuthorizeOrderAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; typeOf: factory.actionType; }): Promise<IAggregateAction>; aggregateCancelReservationAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; }): Promise<IAggregateAction>; /** * アクションタイプによる汎用的な集計 */ aggregateByTypeOf(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; typeOf: factory.actionType; }): Promise<IAggregateAction>; aggregateCheckMovieTicketAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; }): Promise<IAggregateAction>; aggregatePayMovieTicketAction(params: { project?: { id?: { $ne?: string; }; }; startFrom: Date; startThrough: Date; }): Promise<IAggregateAction>; getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/action").IAction<import("@chevre/factory/lib/action").IAttributes<factory.actionType, any, any>>, "id"> & { identifier?: string; }> & Omit<import("@chevre/factory/lib/action").IAction<import("@chevre/factory/lib/action").IAttributes<factory.actionType, any, any>>, "id"> & { identifier?: string; } & { _id: import("mongoose").Types.ObjectId; }, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/action").IAction<import("@chevre/factory/lib/action").IAttributes<factory.actionType, any, any>>, "id"> & { identifier?: string; }> & Omit<import("@chevre/factory/lib/action").IAction<import("@chevre/factory/lib/action").IAttributes<factory.actionType, any, any>>, "id"> & { identifier?: string; } & { _id: import("mongoose").Types.ObjectId; }>>; unsetUnnecessaryFields(params: { filter: FilterQuery<factory.action.IAction<factory.action.IAttributes<factory.actionType, any, any>>>; $unset: any; }): Promise<import("mongoose").UpdateWriteOpResult>; private agggregateByStatus; private upsertRecipe; } export {};