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

    Cross-customer queries and instrument type-agnostic admin actions

    Hierarchy (View Summary)

    Index
    cache: ServiceCache<CachedSearchPage<CachedPaymentInstrumentSearchItem>>
    db: B2bDatabase
    • Get instrument by ID or reference ID

      It can be further narrowed down by type, customer ID and entity ID.

      Parameters

      • __namedParameters: {
            customerId?: string;
            deleted?: boolean;
            entityId?: string;
            type?:
                | "MX_CLABE"
                | "AF_BANK"
                | "AF_MOMO"
                | "EXTERNAL_US_ACH"
                | "NETWORK_WALLET"
                | "SWIFT_WIRE"
                | "US_ACH"
                | "US_INSTANT"
                | "US_WIRE"
                | "WALLET";
        } & ({ id: string } | { referenceId: string })

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

    • Bust every cached page — consumer or admin — that a write touching customerIds could have affected.

      The collection tag is always cleared alongside, because an unscoped admin page carries only that tag and no customer id can reach it.

      keys deletes exact entries in addition to the tag surgery, passing the key arguments — this cache hashes and prefixes them. It exists because invalidateTag resolves keys through the FT index, which does not exist in memory mode (valkeyClient: null); there the tag bust is a total no-op, and an exact-key delete is the only thing that keeps read-after-write honest. Services that folded get onto search pass that get's arguments.

      These deletes only reach this instance's own key space, because the key space is partitioned per surface. That is sufficient, and a writer must not try to name the other surface's key:

      • With Valkey, the other surface's get entry is itself tagged (by customer id, or by the collection tag when unscoped), so the tag bust above already evicts it from the shared L2 and publishes the peer eviction.
      • Without Valkey, the two surfaces are separate instances with separate L1 maps, so deleting a key from this instance could never have affected the other one anyway.

      Parameters

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

      Returns Promise<void>

    • Parameters

      • __namedParameters: {
            anyFieldLike?: string;
            createdAt?: DbTimestampCriteria;
            customerIds?: string[];
            deleted?: boolean;
            entityIds?: string[];
            ids?: string[];
            nameLike?: string;
            nominisWalletScreenRequestIds?: string[];
            orderBy?: DbOrderByCriterion<
                Omit<
                    PgTableWithColumns<
                        {
                            columns: {
                                createdAt: PgBuildColumn<
                                    "payment_instrument",
                                    SetHasDefault<SetNotNull<(...)>>,
                                    {
                                        data: Date;
                                        dataType: "object date";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                customerId: PgBuildColumn<
                                    "payment_instrument",
                                    SetNotNull<PgIntegerBuilder>,
                                    {
                                        data: number;
                                        dataType: "number int32";
                                        driverParam: (...) | (...);
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                deletedAt: PgBuildColumn<
                                    "payment_instrument",
                                    PgTimestampBuilder,
                                    {
                                        data: Date;
                                        dataType: "object date";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                externalId: PgBuildColumn<
                                    "payment_instrument",
                                    SetHasRuntimeDefault<SetNotNull<(...)>>,
                                    {
                                        data: string;
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                id: PgBuildColumn<
                                    "payment_instrument",
                                    HasIdentity<SetIsPrimaryKey<(...)>, "byDefault">,
                                    {
                                        data: number;
                                        dataType: "number int32";
                                        driverParam: (...) | (...);
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: "byDefault";
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                identityId: PgBuildColumn<
                                    "payment_instrument",
                                    PgIntegerBuilder,
                                    {
                                        data: number;
                                        dataType: "number int32";
                                        driverParam: (...)
                                        | (...);
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                instrumentData: PgBuildColumn<
                                    "payment_instrument",
                                    SetNotNull<PgJsonbBuilder>,
                                    {
                                        data: unknown;
                                        dataType: "object json";
                                        driverParam: unknown;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                organizationId: PgBuildColumn<
                                    "payment_instrument",
                                    PgIntegerBuilder,
                                    {
                                        data: number;
                                        dataType: "number int32";
                                        driverParam: (...)
                                        | (...);
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                provider: PgBuildColumn<
                                    "payment_instrument",
                                    SetNotNull<Set$Type<(...), (...)>>,
                                    {
                                        data:
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...);
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                providerId: PgBuildColumn<
                                    "payment_instrument",
                                    SetNotNull<PgTextBuilder<(...)>>,
                                    {
                                        data: string;
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                referenceId: PgBuildColumn<
                                    "payment_instrument",
                                    PgTextBuilder<[(...), ...(...)[]]>,
                                    {
                                        data: string;
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                status: PgBuildColumn<
                                    "payment_instrument",
                                    Set$Type<SetNotNull<(...)>, (...) | (...) | (...) | (...)>,
                                    {
                                        data: (...) | (...) | (...) | (...);
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                type: PgBuildColumn<
                                    "payment_instrument",
                                    Set$Type<
                                        SetNotNull<(...)>,

                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...),
                                    >,
                                    {
                                        data:
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...)
                                            | (...);
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                                updatedAt: PgBuildColumn<
                                    "payment_instrument",
                                    SetHasDefault<SetHasDefault<(...)>>,
                                    {
                                        data: Date;
                                        dataType: "object date";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "payment_instrument";
                                    },
                                >;
                            };
                            dialect: "pg";
                            name: "payment_instrument";
                            schema: "b2b";
                        },
                    >,
                    "enableRLS",
                >,
                "createdAt"
                | "updatedAt",
            >[];
            page?: number;
            pageSize?: number | null;
            partialText?: string;
            providerIds?: string[];
            providers?: (
                | "MX_CLABE"
                | "ACH_PUSH_DEPOSIT"
                | "CFX"
                | "LEDGER_ACCOUNT"
                | "QUILTT"
                | "VICTOR"
                | "WIRE_DEPOSIT"
                | "YELLOWCARD"
                | `chn_${string}`
            )[];
            quilttConnectionIds?: string[];
            referenceIdLike?: string;
            referenceIds?: string[];
            statuses?: ("ACTIVE" | "BLOCKED" | "DELETED" | "PENDING_VERIFICATION")[];
            tx?: PgAsyncTransaction<NodePgQueryResultHKT, EmptyRelations>;
            types?: (
                | "MX_CLABE"
                | "AF_BANK"
                | "AF_MOMO"
                | "EXTERNAL_US_ACH"
                | "NETWORK_WALLET"
                | "SWIFT_WIRE"
                | "US_ACH"
                | "US_INSTANT"
                | "US_WIRE"
                | "WALLET"
            )[];
            updatedAt?: DbTimestampCriteria;
        }
        • OptionalanyFieldLike?: string

          Unscoped partial match over every instrumentData value — reaches fields no type map lists (account numbers, bank names), at the cost of a scan. Admin-only; this is what the admin surface used to expose under the name partialText.

        • OptionalcreatedAt?: DbTimestampCriteria
        • OptionalcustomerIds?: string[]
        • Optionaldeleted?: boolean
        • OptionalentityIds?: string[]
        • Optionalids?: string[]
        • OptionalnameLike?: string

          Partial match over the requested types' name-ish fields. Requires types.

        • OptionalnominisWalletScreenRequestIds?: string[]
        • OptionalorderBy?: DbOrderByCriterion<
              Omit<
                  PgTableWithColumns<
                      {
                          columns: {
                              createdAt: PgBuildColumn<
                                  "payment_instrument",
                                  SetHasDefault<SetNotNull<(...)>>,
                                  {
                                      data: Date;
                                      dataType: "object date";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              customerId: PgBuildColumn<
                                  "payment_instrument",
                                  SetNotNull<PgIntegerBuilder>,
                                  {
                                      data: number;
                                      dataType: "number int32";
                                      driverParam: (...) | (...);
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              deletedAt: PgBuildColumn<
                                  "payment_instrument",
                                  PgTimestampBuilder,
                                  {
                                      data: Date;
                                      dataType: "object date";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              externalId: PgBuildColumn<
                                  "payment_instrument",
                                  SetHasRuntimeDefault<SetNotNull<(...)>>,
                                  {
                                      data: string;
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              id: PgBuildColumn<
                                  "payment_instrument",
                                  HasIdentity<SetIsPrimaryKey<(...)>, "byDefault">,
                                  {
                                      data: number;
                                      dataType: "number int32";
                                      driverParam: (...) | (...);
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: "byDefault";
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              identityId: PgBuildColumn<
                                  "payment_instrument",
                                  PgIntegerBuilder,
                                  {
                                      data: number;
                                      dataType: "number int32";
                                      driverParam: (...)
                                      | (...);
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              instrumentData: PgBuildColumn<
                                  "payment_instrument",
                                  SetNotNull<PgJsonbBuilder>,
                                  {
                                      data: unknown;
                                      dataType: "object json";
                                      driverParam: unknown;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              organizationId: PgBuildColumn<
                                  "payment_instrument",
                                  PgIntegerBuilder,
                                  {
                                      data: number;
                                      dataType: "number int32";
                                      driverParam: (...)
                                      | (...);
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              provider: PgBuildColumn<
                                  "payment_instrument",
                                  SetNotNull<Set$Type<(...), (...)>>,
                                  {
                                      data:
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...);
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              providerId: PgBuildColumn<
                                  "payment_instrument",
                                  SetNotNull<PgTextBuilder<(...)>>,
                                  {
                                      data: string;
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              referenceId: PgBuildColumn<
                                  "payment_instrument",
                                  PgTextBuilder<[(...), ...(...)[]]>,
                                  {
                                      data: string;
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              status: PgBuildColumn<
                                  "payment_instrument",
                                  Set$Type<SetNotNull<(...)>, (...) | (...) | (...) | (...)>,
                                  {
                                      data: (...) | (...) | (...) | (...);
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              type: PgBuildColumn<
                                  "payment_instrument",
                                  Set$Type<
                                      SetNotNull<(...)>,

                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...),
                                  >,
                                  {
                                      data:
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...)
                                          | (...);
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                              updatedAt: PgBuildColumn<
                                  "payment_instrument",
                                  SetHasDefault<SetHasDefault<(...)>>,
                                  {
                                      data: Date;
                                      dataType: "object date";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "payment_instrument";
                                  },
                              >;
                          };
                          dialect: "pg";
                          name: "payment_instrument";
                          schema: "b2b";
                      },
                  >,
                  "enableRLS",
              >,
              "createdAt"
              | "updatedAt",
          >[]
        • Optionalpage?: number

          Defaults to 1

        • OptionalpageSize?: number | null

          Defaults to 10. null for no limit

        • OptionalpartialText?: string

          Partial match over referenceId plus each requested type's searchable fields. Requires types. Same filter, same meaning as the consumer surface's — see internal/search.ts.

        • OptionalproviderIds?: string[]

          Provider-side account identifier. The blacklist is keyed on this, so block / unblock read their affected rows through here rather than running a bespoke query.

        • Optionalproviders?: (
              | "MX_CLABE"
              | "ACH_PUSH_DEPOSIT"
              | "CFX"
              | "LEDGER_ACCOUNT"
              | "QUILTT"
              | "VICTOR"
              | "WIRE_DEPOSIT"
              | "YELLOWCARD"
              | `chn_${string}`
          )[]
        • OptionalquilttConnectionIds?: string[]
        • OptionalreferenceIdLike?: string
        • OptionalreferenceIds?: string[]
        • Optionalstatuses?: ("ACTIVE" | "BLOCKED" | "DELETED" | "PENDING_VERIFICATION")[]
        • Optionaltx?: PgAsyncTransaction<NodePgQueryResultHKT, EmptyRelations>
        • Optionaltypes?: (
              | "MX_CLABE"
              | "AF_BANK"
              | "AF_MOMO"
              | "EXTERNAL_US_ACH"
              | "NETWORK_WALLET"
              | "SWIFT_WIRE"
              | "US_ACH"
              | "US_INSTANT"
              | "US_WIRE"
              | "WALLET"
          )[]
        • OptionalupdatedAt?: DbTimestampCriteria

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: PaymentInstrumentSearchItem[];
                  total: number;
              };
          },
      >

    • Tags to write on a page, derived from the scope the query searched — never from the customers present in the result.

      That distinction is load-bearing. An entry tagged with the customer ids in the page carries no tags when the page is empty, so nothing can ever bust it and a later create leaves it stale for the full L2 TTL. Tagging by scope means an empty page still carries the tag for what it searched.

      An unscoped read falls back to the collection tag, since no customer-id tag can reach a row whose owner did not exist when the entry was written.

      Parameters

      • __namedParameters: { customerIds: readonly string[] | undefined }

      Returns string[]