import { types } from "../../../ledger-sdk/src"; import { Command } from '../command/types'; import { Entry } from '../entry/types'; import { BankJobData } from '../job/bank-job-data'; import { IBankAdapter } from './bank-adapter.service'; export type IntentContext = types.LedgerIntent & { meta: types.LedgerMeta; hash: types.LedgerHash; }; /** * Context of a given transaction. */ export type TransactionContext = { /** * Command received by the bridge from the ledger. */ command: Command; /** * Entry received by the bridge from the ledger. */ entry: Entry; /** * Processor job for the executing command. */ job: BankJobData; /** * Processing intent. */ intent: IntentContext; /** * Context of a previous phase. */ previous?: TransactionContext; }; /** * Details about the transaction error. */ export type ErrorDetails = { /** * Type of an error. */ reason: string; /** * Detailed error message. */ detail: string; /** * Error identifier in bank core system. */ failId?: string; /** * Custom data. */ custom?: any; }; /** * Result statuses. */ export declare enum ResultStatus { Prepared = "prepared", Failed = "failed", Committed = "committed", Aborted = "aborted", Suspended = "suspended", Error = "error" } /** * Suspend current job processing. */ export type JobSuspendedResult> = { /** * Result identifier. */ status: ResultStatus.Suspended; /** * Initiate job execution at this time. * * When field is not set, job is suspended * indefinitely and API request POST on * `/jobs//continue` endpoint * is required in order to initiate job * execution. */ suspendedUntil?: Date; /** * Job suspended state */ state?: StateType; }; /** * Transaction is prepared. */ export type PrepareSucceededResult = { /** * Result identifier. */ status: ResultStatus.Prepared; /** * Transaction identifier in bank core system. */ coreId?: string; /** * Custom data. */ custom?: types.LedgerCustom; }; /** * Transaction prepare failed. */ export type PrepareFailedResult = { /** * Result identifier. */ status: ResultStatus.Failed; /** * Error which caused prepare to fail. */ error: ErrorDetails; /** * Custom data. */ custom?: types.LedgerCustom; }; /** * Prepare result can be: * - prepared * - failed * - suspended */ export type PrepareResult = PrepareSucceededResult | PrepareFailedResult | JobSuspendedResult; /** * Commit succeeded. */ export type CommitSucceededResult = { /** * Result identifier. */ status: ResultStatus.Committed; /** * Transaction identifier in bank core system. */ coreId?: string; /** * Custom data. */ custom?: types.LedgerCustom; }; /** * Commit result can be: * - committed * - suspended * * Failure is not allowed at this * point and commit has to be ensured. */ export type CommitResult = CommitSucceededResult | JobSuspendedResult; /** * Abort succeeded. */ export type AbortSucceededResult = { /** * Result identifier. */ status: ResultStatus.Aborted; /** * Transaction identifier in bank core system. */ coreId?: string; /** * Custom data. */ custom?: types.LedgerCustom; }; /** * Abort failed. */ export type AbortErrorResult = { /** * Result identifier. */ status: ResultStatus.Error; /** * Abortion error. */ error: ErrorDetails; /** * Custom data. */ custom?: types.LedgerCustom; }; /** * Abort result can be: * - error * - aborted * - suspended * */ export type AbortResult = AbortSucceededResult | AbortErrorResult | JobSuspendedResult; /** * Abstract type containing all results. */ export type BankAdapterResult = PrepareResult | AbortResult | CommitResult; /** * Bank adapter class implementing bank adapter interface. */ export type BankAdapterClass = { new (...args: any[]): IBankAdapter; };