UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

382 lines (381 loc) 14.3 kB
import type { Connection, FilterQuery } from 'mongoose'; import * as factory from '../factory'; interface IAggregationByStatus { transactionCount: number; avgDuration: number; maxDuration: number; minDuration: number; percentilesDuration: { name: string; value: number; }[]; reservationCount: number; avgGraceTime: number; maxGraceTime: number; minGraceTime: number; } interface IStatus { status: factory.transactionStatusType; aggregation: IAggregationByStatus; } export interface IAggregateReserve { statuses: IStatus[]; } type IKeyOfProjection<T extends factory.assetTransactionType> = keyof Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'agent' | 'endDate' | 'expires' | 'project' | 'startDate' | 'status' | 'typeOf' | 'transactionNumber'> | Exclude<keyof factory.assetTransaction.ITransaction<T>, 'id'>; type AvailableAssetTransactionType = factory.assetTransactionType.CancelReservation | factory.assetTransactionType.MoneyTransfer | factory.assetTransactionType.Pay | factory.assetTransactionType.Refund | factory.assetTransactionType.RegisterService | factory.assetTransactionType.Reserve; /** * 資産取引リポジトリ */ export declare class AssetTransactionRepo { private readonly transactionModel; constructor(connection: Connection); static CREATE_MONGO_CONDITIONS(params: factory.assetTransaction.ISearchConditions<factory.assetTransactionType>): FilterQuery<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction>[]; /** * 取引を開始する */ start<T extends factory.assetTransactionType>(params: factory.assetTransaction.IStartParams<T>): Promise<factory.assetTransaction.ITransaction<T>>; startWithMinimalResponse<T extends factory.assetTransactionType>(params: factory.assetTransaction.IStartParams<T>): Promise<Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'startDate'>>; findById<T extends factory.assetTransactionType>(params: { typeOf: T; id: string; }, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>; findByTransactionNumber<T extends factory.assetTransactionType>(params: { typeOf: T; transactionNumber: string; }, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>; addReservations(params: { typeOf: factory.assetTransactionType.Reserve; id: string; object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'subReservation'>; }): Promise<void>; /** * 取引を確定する */ confirm<T extends factory.assetTransactionType>(params: { typeOf: T; id: string; object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'> & { /** * 決済取引における決済方法区分指定 */ paymentMethod?: { identifier?: string; }; }; result: factory.assetTransaction.IResult<T>; potentialActions: factory.assetTransaction.IPotentialActions<T>; }): Promise<void>; /** * 取引を開始&確定 */ startAndConfirm<T extends AvailableAssetTransactionType>(params: factory.assetTransaction.IStartParams<T> & { id: string; result: factory.assetTransaction.IResult<T>; potentialActions: factory.assetTransaction.IPotentialActions<T>; }): Promise<{ id: string; }>; countPotentiallyExportTasks(params: { endDate: { $lt: Date; }; limit?: number; }): Promise<{ count: number; }>; /** * タスク未エクスポートの取引をひとつ取得してエクスポートを開始する */ startExportTasks(params: { status?: { $eq?: factory.transactionStatusType; }; id?: string; tasksExportAction: { agent: { name: string; }; }; endDate: { $lt: Date; }; sort?: { endDate?: factory.sortType; }; }): Promise<Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'typeOf'> | null>; /** * tasksExportAction.actionStatusがActiveActionStatusのまま一定時間経過した取引について * PotentialActionStatusに変更する * 2025-03-10~ */ reExportAction(params: { startDate: { $lt: Date; }; }): Promise<import("mongoose").UpdateWriteOpResult>; /** * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する */ exportTasksMany(params: { now: Date; delayInSeconds: number; status: { $in: factory.transactionStatusType[]; }; limit: number; }): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction, "id" | "status" | "typeOf">[]>; /** * set task status exported by transaction id * IDでタスクをエクスポート済に変更する */ setTasksExportedById(params: { id: string; }): Promise<void>; /** * add(2025-03-17~) */ countPotentiallyExpired(params: { expires: { $lt: Date; }; limit?: number; }): Promise<{ count: number; }>; /** * add(2025-03-12~) */ makeOneExpiredIfExists(params: { expires: { $lt: Date; }; }): Promise<Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'id' | 'typeOf'> | void>; /** * 取引を期限切れにする */ makeExpired(params: { expires: { $lt: Date; }; }): Promise<void>; /** * 取引を中止する */ cancel<T extends factory.assetTransactionType>(params: { typeOf: T; id?: string; transactionNumber?: string; }): Promise<{ id: string; }>; count<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>): Promise<{ count: number; }>; /** * 取引を検索する */ search<T extends AvailableAssetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>, inclusion?: string[], exclusion?: string[]): Promise<factory.assetTransaction.ITransaction<T>[]>; /** * 取引番号指定で削除する */ deleteByTransactionNumber(params: { project: { id: string; }; transactionNumbers: string[]; typeOf: factory.assetTransactionType; }): Promise<{ n?: number; ok?: number; deletedCount?: number; } | null>; /** * プロジェクト指定で削除する */ deleteByProject(params: { project: { id: string; }; }): Promise<void>; /** * 終了日時を一定期間過ぎたアクションを削除する */ deleteEndDatePassedCertainPeriod(params: { $lt: Date; }): Promise<void>; /** * 特定の取引を更新する(汎用) */ findByIdAndUpdateInProgress<T extends factory.assetTransactionType>(params: { id: string; update: any; }): Promise<factory.assetTransaction.ITransaction<T>>; /** * 互換性維持対応 */ migrateObjectReservationNumber(params: { id: string; object: { reservationNumber: string; }; }): Promise<(import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>) | (import("@chevre/factory/lib/assetTransaction/moneyTransfer").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>) | (import("@chevre/factory/lib/assetTransaction/pay").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>) | (import("@chevre/factory/lib/assetTransaction/refund").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>) | (import("@chevre/factory/lib/assetTransaction/registerService").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>) | (import("@chevre/factory/lib/assetTransaction/reserve").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; } & Required<{ _id: import("mongoose").Types.ObjectId; }>)>; /** * 互換性維持対応専用 */ fixReservedTicketIdentifier(params: { project: { id: string; }; transactionNumber: string; object: { paymentMethod: { movieTickets: factory.action.trade.pay.IMovieTicket[]; }; }; }): Promise<void>; findByIdAndDelete(params: { id: string; }): Promise<void>; getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, (import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction) & { seller?: any; }> & ((import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/moneyTransfer").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/pay").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/refund").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/registerService").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/reserve").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; })), import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, (import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction) & { seller?: any; }> & ((import("@chevre/factory/lib/assetTransaction/cancelReservation").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/moneyTransfer").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/pay").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/refund").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/registerService").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }) | (import("@chevre/factory/lib/assetTransaction/reserve").IAttributes & { id: string; } & { seller?: any; } & { _id: import("mongoose").Types.ObjectId; }))>>; unsetUnnecessaryFields(params: { filter: any; $unset: any; }): Promise<import("mongoose").UpdateWriteOpResult>; aggregateAssetTransaction(params: { project?: { id?: { $eq?: string; $ne?: string; }; }; startFrom: Date; startThrough: Date; typeOf: factory.assetTransactionType; }): Promise<IAggregateReserve>; private agggregateByStatus; } export {};