@cfxlabsinc/b2b-services
    Preparing search index...

    Admin withdrawal reads. Extends WithdrawalCache, which owns the withdrawal-search namespace these reads go through.

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<WithdrawalSearchItem>>
    db: B2bDatabase
    instance: (...args: []) => WithdrawalAdminQueryService = ...

    The process default: built from each dependency's own instance().

    • The ACH_DEBIT withdrawal opened for an inbound debit, read from the database. method_data->>'achId' has no unique constraint, so this read is the only dedupe on that debit.

      Parameters

      • __namedParameters: {
            achId: string;
            statuses?: ("PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED")[];
        }

      Returns Promise<{ ok: true; value: WithdrawalSearchItem | null }>

    • The withdrawal while it is still in one of statuses, read from the database. For a guard that acts on that status, where a stale cached status would let it act twice (finalize after a return, refund after a completion).

      Parameters

      • __namedParameters: {
            id: string;
            methodIds?: (
                | "ACH_CREDIT"
                | "ACH_DEBIT"
                | "BLOCKCHAIN"
                | "MX_SPEI"
                | "US_WIRE_DRAWDOWN"
                | "US_INSTANT"
                | "SWIFT_WIRE"
                | "US_WIRE"
                | "AF_WITHDRAWAL"
            )[];
            statuses: ("PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED")[];
        }

      Returns Promise<{ ok: true; value: WithdrawalSearchItem | null }>

    • Get a withdrawal by ID without customer restriction

      Parameters

      • __namedParameters: {
            customerId?: string;
            entityId?: string;
            id: string;
            includeHistory?: boolean;
            methodIds?: (
                | "ACH_CREDIT"
                | "ACH_DEBIT"
                | "BLOCKCHAIN"
                | "MX_SPEI"
                | "US_WIRE_DRAWDOWN"
                | "US_INSTANT"
                | "SWIFT_WIRE"
                | "US_WIRE"
                | "AF_WITHDRAWAL"
            )[];
            statuses?: ("PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED")[];
            tx?: PgAsyncTransaction<NodePgQueryResultHKT, EmptyRelations>;
        }

      Returns Promise<
          {
              ok: true;
              value: | {
                  createdAt: Date;
                  customerId: string;
                  data: {
                      achTraceId?: string;
                      addenda?: string;
                      companyEntryDescription?: string;
                      companyId?: string;
                      companyName?: string;
                      effectiveEntryDate?: string;
                      imad?: string;
                      methodTransactionId?: string;
                      omad?: string;
                      originatorName?: string;
                      routeFusionTransferId?: string;
                      secCode?: string;
                      settlementDate?: string;
                      signedTransaction?: string;
                      victorTraceId?: string;
                      victorTransactionId?: string;
                  };
                  entityId: string;
                  entityType: "IDENTITY"
                  | "ORGANIZATION";
                  feeSweepTxId: string | null;
                  feeSweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  history: WithdrawalStatusUpdateHistory[];
                  id: string;
                  quote: {
                      createdAt: Date;
                      customerId: string;
                      deviceIpAddress: string | null;
                      deviceLocation: { lat: number; long: number; source: "ip" } | null;
                      entityId: string;
                      expiresAt: Date;
                      fees: (
                          {
                              amount: BigNumber;
                              receiver: "CUSTOMER"
                              | "PROVIDER"
                              | "CFX";
                              type: "FIXED" | "VARIABLE";
                          } & { currency: string }
                      )[];
                      id: string;
                      metadata: {
                          brand?: string;
                          marketing?: {
                              fbp?: string;
                              gclid?: string;
                              sub1?: string;
                              sub2?: string;
                              sub3?: string;
                              userAgent?: string;
                              utmCampaign?: string;
                              utmContent?: string;
                              utmMedium?: string;
                              utmSource?: string;
                          };
                      };
                      methodData: | {
                          achBatchId?: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          speed?: "same-day"
                          | "next-day";
                          type: "ACH_CREDIT";
                          vendorId?: string;
                      }
                      | {
                          achId: string;
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "ACH_DEBIT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          beneficiaryReference?: string;
                          purpose: WireWithdrawalPurpose;
                          senderMessage?: string;
                          sourceLedgerAccountId: string;
                          type: "SWIFT_WIRE"
                          | "US_WIRE";
                          vendorId?: string;
                          wireBatchId?: string;
                      }
                      | {
                          country: string;
                          sourceLedgerAccountId?: string;
                          type: "AF_WITHDRAWAL";
                          withdrawalType: "bank"
                          | "momo";
                      }
                      | {
                          asset?: {
                              decimals: number;
                              mint: string;
                              symbol: string;
                              tokenProgram: string;
                          };
                          sourceLedgerAccountId: string;
                          type: "BLOCKCHAIN";
                      }
                      | {
                          bankId?: string;
                          sourceLedgerAccountId?: string;
                          type: "US_INSTANT";
                          vendorId?: string;
                      }
                      | {
                          bankId?: string;
                          drawdownId: string;
                          sourceAccountId: string;
                          type: "US_WIRE_DRAWDOWN";
                          vendorId?: string;
                      }
                      | null;
                      methodId: | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                      paymentInstrumentId: string;
                      productQuoteId: string;
                      providerQuoteId: string
                      | null;
                      sourceAmount: BigNumber;
                      sourceAmountAfterFees: BigNumber;
                      sourceCurrency: string;
                      status: "ACTIVE" | "ACCEPTED" | "REJECTED" | "EXPIRED";
                      targetAmount: BigNumber;
                      targetAmountAfterFees: BigNumber;
                      targetCurrency: string;
                      unsignedWithdrawalTransaction: string | null;
                      updatedAt: Date;
                      walletAddress: Address;
                      walletBlockchain: string;
                  };
                  receiptId: string
                  | null;
                  receiptType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  returnReceiptId: string | null;
                  status: "PENDING" | "FAILED" | "PROCESSING" | "COMPLETED" | "RETURNED";
                  statusDescription: string;
                  sweepTxId: string | null;
                  sweepTxType: "SOLANA_TRANSACTION_SIGNATURE" | null;
                  type:
                      | "ACH_CREDIT"
                      | "ACH_DEBIT"
                      | "BLOCKCHAIN"
                      | "MX_SPEI"
                      | "US_WIRE_DRAWDOWN"
                      | "US_INSTANT"
                      | "SWIFT_WIRE"
                      | "US_WIRE"
                      | "AF_WITHDRAWAL";
                  updatedAt: Date;
              } & { customerName: string }
              | null;
          },
      >

    • Clear each customer's membership tag and each record tag wherever cached, and always this namespace's collection tag. keys are exact deletes in this instance's key space: the only bust a null client honours.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[];
            keys?: readonly CacheKey[];
            records?: readonly string[];
        }

      Returns Promise<void>

    • Admin search for withdrawals without customer restriction. Reads through the withdrawal-search cache, except under a caller's tx.

      Parameters

      • __namedParameters: WithdrawalAdminSearchArgs

      Returns Promise<{ ok: true; value: WithdrawalAdminSearchPage }>

    • Tags for a page: the scope its query searched (each customer's membership tag, else the collection tag), so an empty page is bustable too, plus the records it projects and the fields that chose or ordered its rows.

      Parameters

      • __namedParameters: {
            customerIds: readonly string[] | undefined;
            fields?: readonly string[];
            records?: readonly string[];
        }

      Returns string[]

    • The keys an unfiltered WithdrawalAdminQueryService.get({ id }) reads through.

      Parameters

      • __namedParameters: { id: string }

      Returns CacheKey[]

    • The keys WithdrawalQueryService.get reads through, one per includeHistory variant (search's page default included). Writers pass them so read-after-write holds under a null client, where tag busts no-op.

      Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns CacheKey[]