/**
 * データ測定サービス
 * 実験的実装中
 */
import type { ActionRepo } from '../../repo/action';
import type { TaskRepo } from '../../repo/task';
import type { TelemetryRepo } from '../../repo/telemetry';
import type { TransactionRepo } from '../../repo/transaction';
import * as factory from '../../factory';
export type TelemetryOperation<T> = (repos: {
    telemetry: TelemetryRepo;
}) => Promise<T>;
export type TaskOperation<T> = (repos: {
    task: TaskRepo;
}) => Promise<T>;
export type TransactionOperation<T> = (repos: {
    transaction: TransactionRepo;
}) => Promise<T>;
export type TaskAndTransactionOperation<T> = (repos: {
    task: TaskRepo;
    transaction: TransactionRepo;
}) => Promise<T>;
export type TaskAndTransactionAndActionOperation<T> = (repos: {
    task: TaskRepo;
    transaction: TransactionRepo;
    action: ActionRepo;
}) => Promise<T>;
export type TransactionAndActionOperation<T> = (repos: {
    transaction: TransactionRepo;
    action: ActionRepo;
}) => Promise<T>;
export type TaskAndTelemetryAndTransactionOperation<T> = (repos: {
    task: TaskRepo;
    telemetry: TelemetryRepo;
    transaction: TransactionRepo;
    action: ActionRepo;
}) => Promise<T>;
export interface IGlobalFlowTaskResultByName {
    name: factory.taskName;
    /**
     * 集計期間中に作成されたタスク数
     */
    numberOfCreated: number;
    /**
     * 集計期間中に実行されたタスク数
     */
    numberOfExecuted: number;
    /**
     * 集計期間中に中止されたタスク数
     */
    numberOfAborted: number;
    /**
     * 合計待ち時間
     */
    totalLatencyInMilliseconds: number;
    /**
     * 最大待ち時間
     */
    maxLatencyInMilliseconds: number;
    /**
     * 最小待ち時間
     */
    minLatencyInMilliseconds: number;
    /**
     * 合計試行回数
     */
    totalNumberOfTrials: number;
    /**
     * 最大試行回数
     */
    maxNumberOfTrials: number;
    /**
     * 最小試行回数
     */
    minNumberOfTrials: number;
}
/**
 * フローデータ
 * https://en.wikipedia.org/wiki/Stock_and_flow
 */
export interface IGlobalFlowResult {
    tasks: IGlobalFlowTaskResultByName[];
    measuredFrom: Date;
    measuredThrough: Date;
}
/**
 * ストックデータ
 * https://en.wikipedia.org/wiki/Stock_and_flow
 */
export interface IGlobalStockResult {
    tasks: {
        numberOfUnexecuted: number;
    };
    measuredAt: Date;
}
export interface ISellerFlowTransactionResultByAction {
    /**
     * アクション数合計値(期限切れ取引)
     */
    totalNumberOfActionsOnExpired: number;
    /**
     * 最大アクション数(期限切れ取引)
     */
    maxNumberOfActionsOnExpired: number;
    /**
     * 最小アクション数(期限切れ取引)
     */
    minNumberOfActionsOnExpired: number;
    /**
     * 平均アクション数(期限切れ取引)
     */
    averageNumberOfActionsOnExpired: number;
}
export interface ISellerFlowTransactionResult {
    /**
     * 集計期間中に開始された取引数
     */
    numberOfStarted: number;
    /**
     * 集計期間中に開始されてその後成立した取引数
     */
    numberOfStartedAndConfirmed: number;
    /**
     * 集計期間中に開始されてその後期限切れになった取引数
     */
    numberOfStartedAndExpired: number;
    /**
     * 集計期間中に成立した取引数
     */
    numberOfConfirmed: number;
    /**
     * 集計期間中に期限切れになった取引数
     */
    numberOfExpired: number;
    /**
     * 取引の合計所要時間(ミリ秒)
     */
    totalRequiredTimeInMilliseconds: number;
    /**
     * 取引の最大所要時間(ミリ秒)
     */
    maxRequiredTimeInMilliseconds: number;
    /**
     * 取引の最小所要時間(ミリ秒)
     */
    minRequiredTimeInMilliseconds: number;
    /**
     * 取引の平均所要時間(ミリ秒)
     */
    averageRequiredTimeInMilliseconds: number;
    /**
     * イベントまでの合計残り時間(ミリ秒)
     */
    /**
     * イベントまでの最大残り時間(ミリ秒)
     */
    /**
     * イベントまでの最小残り時間(ミリ秒)
     */
    /**
     * イベントまでの平均残り時間(ミリ秒)
     */
    /**
     * 取引の合計金額(yen)
     */
    totalAmount: number;
    /**
     * 最大金額
     */
    maxAmount: number;
    /**
     * 最小金額
     */
    minAmount: number;
    /**
     * 平均金額
     */
    averageAmount: number;
    /**
     * アクション数合計値(成立取引)
     */
    /**
     * 最大アクション数(成立取引)
     */
    /**
     * 最小アクション数(成立取引)
     */
    /**
     * 注文アイテム数合計値
     */
    totalNumberOfOrderItems: number;
    /**
     * 最大注文アイテム数
     */
    maxNumberOfOrderItems: number;
    /**
     * 最小注文アイテム数
     */
    minNumberOfOrderItems: number;
    /**
     * 平均注文アイテム数
     */
    averageNumberOfOrderItems: number;
}
/**
 * 販売者が対象のフローデータ
 */
export interface ISellerFlowResult {
    transactions: ISellerFlowTransactionResult & ISellerFlowTransactionResultByAction;
    measuredFrom: Date;
    measuredThrough: Date;
}
/**
 * 販売者が対象のストックデータ
 */
export interface ISellerStockResult {
    transactions: {
        numberOfUnderway: number;
    };
    measuredAt: Date;
}
export declare enum TelemetryScope {
    Global = "Global",
    Seller = "Seller"
}
export declare enum TelemetryPurposeType {
    Flow = "Flow",
    Stock = "Stock"
}
export interface IGlobalObect {
    scope: TelemetryScope;
    measuredAt: Date;
}
export interface ISellerObect {
    scope: TelemetryScope;
    measuredAt: Date;
    sellerId: string;
}
/**
 * 測定データインターフェース
 */
export interface ITelemetry {
    object: any;
    result: any;
    startDate: Date;
    endDate: Date;
    purpose: {
        typeOf: TelemetryPurposeType;
    };
}
export interface IGlobalStockTelemetry extends ITelemetry {
    object: IGlobalObect;
    result: IGlobalStockResult;
}
export interface IGlobalFlowTelemetry extends ITelemetry {
    object: IGlobalObect;
    result: IGlobalFlowResult;
}
export interface ISellerStockTelemetry extends ITelemetry {
    object: ISellerObect;
    result: ISellerStockResult;
}
export interface ISellerFlowTelemetry extends ITelemetry {
    object: ISellerObect;
    result: ISellerFlowResult;
}
export declare function searchGlobalFlow(searchConditions: {
    measuredFrom: Date;
    measuredThrough: Date;
}): TelemetryOperation<IGlobalFlowTelemetry[]>;
export declare function searchGlobalStock(searchConditions: {
    measuredFrom: Date;
    measuredThrough: Date;
}): TelemetryOperation<IGlobalStockTelemetry[]>;
export declare function searchSellerFlow(searchConditions: {
    measuredFrom: Date;
    measuredThrough: Date;
}): TelemetryOperation<ISellerFlowTelemetry[]>;
export declare function searchSellerStock(searchConditions: {
    measuredFrom: Date;
    measuredThrough: Date;
}): TelemetryOperation<ISellerStockTelemetry[]>;
/**
 * 計測データを検索する
 * @param searchConditions.measuredFrom 計測日時from
 * @param searchConditions.measuredThrough 計測日時through
 */
export declare function search(searchConditions: {
    measuredFrom: Date;
    measuredThrough: Date;
    scope: TelemetryScope;
    purpose: TelemetryPurposeType;
}): (repos: {
    telemetry: TelemetryRepo;
}) => Promise<ITelemetry[]>;
/**
 * フロー測定データを作成する
 */
export declare function createFlow(target: {
    measuredAt: Date;
    sellerId?: string;
}): TaskAndTelemetryAndTransactionOperation<void>;
/**
 * ストック測定データを作成する
 */
export declare function createStock(target: {
    measuredAt: Date;
    sellerId?: string;
}): TaskAndTelemetryAndTransactionOperation<void>;
