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

    Unless need to directly act on an organization specifically, you should be using EntityService instead.

    The shared search cache is rooted at OrganizationCache, so this writer inherits it and self-busts via invalidateWrite — one call that reaches both the customer and admin surfaces, since they share a namespace and a tag vocabulary, and every other namespace copying the organization's columns.

    Hierarchy (View Summary)

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

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

    • Adopts people onto an org that already exists, skipping any it holds: the retry of an onboarding whose create stopped partway through them.

      Parameters

      • __namedParameters: { adoptedPeople: AdoptedPerson[]; customerId: string; id: string }

      Returns Promise<{ ok: true; value: undefined } | { error: ServiceError; ok: false }>

    • Parameters

      • input: Pick<
            {
                achName: string;
                capabilities: (
                    | "TRANSACT"
                    | "MANAGE_PAYMENT_INSTRUMENT"
                    | "MANAGE_LEDGER_ACCOUNT"
                    | "MANAGE_DEPOSIT_MEMO"
                )[];
                countryCode: string;
                countryOfIncorporation: string;
                createdAt: Date;
                deletedAt?: Date;
                description?: string;
                email?: string;
                expectedActivity?: {
                    currencyCount: "TWO_OR_FEWER"
                    | "THREE"
                    | "MORE_THAN_THREE";
                    expectsOnlineGambling: boolean;
                    expectsSanctionedCountryActivity: boolean;
                    monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                    monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                    monthlyInternationalWireDepositAmount:
                        | "UP_TO_30000"
                        | "30000_TO_100000"
                        | "OVER_100000";
                    monthlyInternationalWireDepositCount: "1_TO_5"
                    | "6_TO_10"
                    | "11_OR_MORE";
                    monthlyInternationalWirePaymentAmount:
                        | "UP_TO_30000"
                        | "30000_TO_100000"
                        | "OVER_100000";
                    monthlyInternationalWirePaymentCount: "1_TO_5"
                    | "6_TO_10"
                    | "11_OR_MORE";
                    monthlyPaymentAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                    monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                    operationsStartDate: string;
                    primaryPurpose:
                        | "RECEIVE_CUSTOMER_PAYMENTS"
                        | "EVERYDAY_PURCHASES"
                        | "PAY_SUPPLIERS_AND_EMPLOYEES"
                        | "MANAGE_MULTIPLE_CURRENCIES"
                        | "OTHER";
                    primaryPurposeDetail?: string;
                    sanctionedCountryActivityDetail?: string;
                    services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                    topCountries: string[];
                };
                fullName: string;
                id: string;
                incorporationDate?: string;
                legalEntityType: string;
                metadata: Record<string, string>;
                naicsCode?: string;
                name: string;
                operatingAddress?: OrganizationAddress;
                phone?: E164Phone;
                referenceId?: string;
                registeredAddress?: OrganizationAddress;
                registrationNumber?: string;
                requiredInfo: RequiredInfoField[];
                routeFusionEntity?: {
                    documentsUploadedAt?: string;
                    entityId: string;
                    lastFinalizeError?: { at: string; message: string } | null;
                    programId?: string;
                    requiredDocuments?: string[][];
                    status: "PENDING" | "VERIFIED" | "REJECTED";
                } & { statusDescription: string };
                stateOfIncorporation?: string;
                status:
                    | "PENDING_VERIFICATION"
                    | "ACTION_REQUIRED"
                    | "APPROVED"
                    | "DISABLED"
                    | "DELETED";
                statusDescription: string;
                taxId: string;
                type: "ORGANIZATION";
                updatedAt: Date;
                uuid: string;
                verificationData?: {
                    status: VerificationStatus;
                    verificationSessionId?: string;
                    verificationTemplateId: string;
                } & { statusDescription: string };
                verificationProfileId?: string;
                verificationReasonCode?:
                    | "OTHER"
                    | "INVALID_TAX_ID"
                    | "ADDRESS_MISMATCH"
                    | "REGISTRY_NOT_FOUND"
                    | "DOCUMENT_ISSUE"
                    | "IDENTITY_MISMATCH";
                verificationReasonCodeDescription?: string;
                verifiedAt?: Date;
                websiteUrl?: string;
                wireName: string;
            },
            | "referenceId"
            | "name"
            | "description"
            | "countryOfIncorporation"
            | "taxId"
            | "websiteUrl"
            | "operatingAddress"
            | "registrationNumber"
            | "stateOfIncorporation"
            | "incorporationDate"
            | "legalEntityType",
        > & {
            customerId: string;
            email?: string;
            isMainOrg?: boolean;
            metadata?: Record<string, string>;
            phone?: string;
            registeredAddress: OrganizationAddress;
            relatedPeople?: NewRelatedPerson[];
            verificationProfileId?: string;
        }
        • customerId: string
        • Optionalemail?: string

          Required when the caller's contactPolicy is REQUIRED.

        • OptionalisMainOrg?: boolean

          Mark this as the customer's PRIMARY organization (organization.is_main_org) — the one every customer-scoped read resolves to, and the replacement for the old customer.organization_id pointer. Exactly one per customer, enforced by the partial unique index organization_main_org_per_customer_idx; a second one surfaces as DUPLICATE through the existing unique-violation catch. Set only by the customer-onboarding flow (@cfxlabsinc/onboarding-services).

        • Optionalmetadata?: Record<string, string>
        • Optionalphone?: string

          Any common format; stored as E.164. Required like email.

        • registeredAddress: OrganizationAddress

          The registered address. Required on create; older organizations may lack it, so the domain object keeps it optional.

        • OptionalrelatedPeople?: NewRelatedPerson[]

          Control persons / beneficial owners to create against this org right after it's inserted (organization-api forces at least one CONTROL person when the customer is RouteFusion-enabled — see OrganizationController). Each is forwarded to relatedPersonService the same way the standalone related-person endpoint does.

        • OptionalverificationProfileId?: string

          An existing AiPrise business profile to attach to this org. When supplied the profile is FETCHED here and its current result/session are attached to the org INSTEAD of kicking off a fresh async verify(). The customer-onboarding flow pastes a profile the operator already validated, often one the CRM created, so the profile is then relinked to this org (client_reference_id and our callbacks) for later decisions to reach it.

          Only the id is accepted: the verification outcome is always read from AiPrise (the source of truth), never trusted from the caller.

      • __namedParameters: {
            adoptedPeople?: AdoptedPerson[];
            contactPolicy: OrganizationContactPolicy;
            preApproved?: true;
        }
        • OptionaladoptedPeople?: AdoptedPerson[]

          People AiPrise already holds linked to verificationProfileId's business profile, adopted with RelatedPersonService.adopt. Onboarding only: a second argument, so no request-typed first argument can name it.

        • contactPolicy: OrganizationContactPolicy

          Whether this caller's organizations must have an email and a phone.

        • OptionalpreApproved?: true

          Dev sandbox only: skips AiPrise and treats its verdict as APPROVED, still through the activation predicate. Refused outside dev and local.

      Returns Promise<
          | {
              ok: true;
              value: {
                  achName: string;
                  capabilities: (
                      | "TRANSACT"
                      | "MANAGE_PAYMENT_INSTRUMENT"
                      | "MANAGE_LEDGER_ACCOUNT"
                      | "MANAGE_DEPOSIT_MEMO"
                  )[];
                  countryCode: string;
                  countryOfIncorporation: string;
                  createdAt: Date;
                  deletedAt?: Date;
                  description?: string;
                  email?: string;
                  expectedActivity?: {
                      currencyCount: "TWO_OR_FEWER"
                      | "THREE"
                      | "MORE_THAN_THREE";
                      expectsOnlineGambling: boolean;
                      expectsSanctionedCountryActivity: boolean;
                      monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                      monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      monthlyInternationalWireDepositAmount:
                          | "UP_TO_30000"
                          | "30000_TO_100000"
                          | "OVER_100000";
                      monthlyInternationalWireDepositCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyInternationalWirePaymentCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyPaymentAmount: "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      operationsStartDate: string;
                      primaryPurpose:
                          | "RECEIVE_CUSTOMER_PAYMENTS"
                          | "EVERYDAY_PURCHASES"
                          | "PAY_SUPPLIERS_AND_EMPLOYEES"
                          | "MANAGE_MULTIPLE_CURRENCIES"
                          | "OTHER";
                      primaryPurposeDetail?: string;
                      sanctionedCountryActivityDetail?: string;
                      services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                      topCountries: string[];
                  };
                  fullName: string;
                  id: string;
                  incorporationDate?: string;
                  legalEntityType: string;
                  metadata: Record<string, string>;
                  naicsCode?: string;
                  name: string;
                  operatingAddress?: OrganizationAddress;
                  phone?: E164Phone;
                  referenceId?: string;
                  registeredAddress?: OrganizationAddress;
                  registrationNumber?: string;
                  requiredInfo: RequiredInfoField[];
                  routeFusionEntity?: {
                      documentsUploadedAt?: string;
                      entityId: string;
                      lastFinalizeError?: { at: string; message: string } | null;
                      programId?: string;
                      requiredDocuments?: string[][];
                      status: "PENDING" | "VERIFIED" | "REJECTED";
                  } & { statusDescription: string };
                  stateOfIncorporation?: string;
                  status:
                      | "PENDING_VERIFICATION"
                      | "ACTION_REQUIRED"
                      | "APPROVED"
                      | "DISABLED"
                      | "DELETED";
                  statusDescription: string;
                  taxId: string;
                  type: "ORGANIZATION";
                  updatedAt: Date;
                  uuid: string;
                  verificationData?: {
                      status: VerificationStatus;
                      verificationSessionId?: string;
                      verificationTemplateId: string;
                  } & { statusDescription: string };
                  verificationProfileId?: string;
                  verificationReasonCode?:
                      | "OTHER"
                      | "INVALID_TAX_ID"
                      | "ADDRESS_MISMATCH"
                      | "REGISTRY_NOT_FOUND"
                      | "DOCUMENT_ISSUE"
                      | "IDENTITY_MISMATCH";
                  verificationReasonCodeDescription?: string;
                  verifiedAt?: Date;
                  websiteUrl?: string;
                  wireName: string;
              };
          }
          | {
              error: | ServiceError<"METADATA_INVALID" | "METADATA_TOO_LARGE">
              | ServiceError<
                  | "INVALID_PHONE"
                  | "INVALID_EMAIL"
                  | "INVALID_WEBSITE_URL"
                  | "INVALID_US_STATE"
                  | "INVALID_STATE_OF_INCORPORATION",
              >
              | ServiceError<
                  | "DUPLICATE"
                  | "RELATED_PERSON_CREATE_FAILED"
                  | "PRE_APPROVED_NOT_ALLOWED",
              >
              | ServiceError<"ORGANIZATION_PROFILE_REJECTED", { cause: AiPriseError }>
              | ServiceError<"EMAIL_REQUIRED" | "PHONE_REQUIRED">
              | ServiceError<
                  | "INVALID_COUNTRY"
                  | "INVALID_PHONE"
                  | "INVALID_EMAIL"
                  | "INVALID_DATE_OF_BIRTH"
                  | "INVALID_US_STATE",
              >
              | ServiceError<"INVALID_BENEFICIAL_OWNERSHIP">
              | ServiceError<"DUPLICATE_RELATED_PERSON">
              | OrganizationVerificationFailed;
              ok: false;
          },
      >

    • Parameters

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

      Returns Promise<
          | {
              ok: true;
              value: {
                  achName: string;
                  capabilities: (
                      | "TRANSACT"
                      | "MANAGE_PAYMENT_INSTRUMENT"
                      | "MANAGE_LEDGER_ACCOUNT"
                      | "MANAGE_DEPOSIT_MEMO"
                  )[];
                  countryCode: string;
                  countryOfIncorporation: string;
                  createdAt: Date;
                  deletedAt?: Date;
                  description?: string;
                  email?: string;
                  expectedActivity?: {
                      currencyCount: "TWO_OR_FEWER"
                      | "THREE"
                      | "MORE_THAN_THREE";
                      expectsOnlineGambling: boolean;
                      expectsSanctionedCountryActivity: boolean;
                      monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                      monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      monthlyInternationalWireDepositAmount:
                          | "UP_TO_30000"
                          | "30000_TO_100000"
                          | "OVER_100000";
                      monthlyInternationalWireDepositCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyInternationalWirePaymentCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyPaymentAmount: "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      operationsStartDate: string;
                      primaryPurpose:
                          | "RECEIVE_CUSTOMER_PAYMENTS"
                          | "EVERYDAY_PURCHASES"
                          | "PAY_SUPPLIERS_AND_EMPLOYEES"
                          | "MANAGE_MULTIPLE_CURRENCIES"
                          | "OTHER";
                      primaryPurposeDetail?: string;
                      sanctionedCountryActivityDetail?: string;
                      services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                      topCountries: string[];
                  };
                  fullName: string;
                  id: string;
                  incorporationDate?: string;
                  legalEntityType: string;
                  metadata: Record<string, string>;
                  naicsCode?: string;
                  name: string;
                  operatingAddress?: OrganizationAddress;
                  phone?: E164Phone;
                  referenceId?: string;
                  registeredAddress?: OrganizationAddress;
                  registrationNumber?: string;
                  requiredInfo: RequiredInfoField[];
                  routeFusionEntity?: {
                      documentsUploadedAt?: string;
                      entityId: string;
                      lastFinalizeError?: { at: string; message: string } | null;
                      programId?: string;
                      requiredDocuments?: string[][];
                      status: "PENDING" | "VERIFIED" | "REJECTED";
                  } & { statusDescription: string };
                  stateOfIncorporation?: string;
                  status:
                      | "PENDING_VERIFICATION"
                      | "ACTION_REQUIRED"
                      | "APPROVED"
                      | "DISABLED"
                      | "DELETED";
                  statusDescription: string;
                  taxId: string;
                  type: "ORGANIZATION";
                  updatedAt: Date;
                  uuid: string;
                  verificationData?: {
                      status: VerificationStatus;
                      verificationSessionId?: string;
                      verificationTemplateId: string;
                  } & { statusDescription: string };
                  verificationProfileId?: string;
                  verificationReasonCode?:
                      | "OTHER"
                      | "INVALID_TAX_ID"
                      | "ADDRESS_MISMATCH"
                      | "REGISTRY_NOT_FOUND"
                      | "DOCUMENT_ISSUE"
                      | "IDENTITY_MISMATCH";
                  verificationReasonCodeDescription?: string;
                  verifiedAt?: Date;
                  websiteUrl?: string;
                  wireName: string;
              };
          }
          | { error: ServiceError; ok: false },
      >

    • Resolve the organization's incorporation (formation) date from its AiPrise business profile, for prefilling the RouteFusion virtual-account creation form (RouteFusion's createBusinessEntity requires incorporation_date).

      The date is not stored on the org record — it is read from AiPrise's registration_info.formation_date (falling back to the profile's top-level formation_date). Absence of a verification profile or a formation date is not an error: the admin can enter the value manually, so this returns { incorporationDate: null } in those cases.

      Parameters

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

          Organization external id

      Returns Promise<
          | { ok: true; value: { incorporationDate: string
          | null } }
          | { error: ServiceError; ok: false },
      >

    • Parameters

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

          The URL to redirect to, after verification is completed

      Returns Promise<
          | { error: ServiceError; ok: false }
          | { ok: true; value: { url: string } },
      >

      URL to start an identity document verification session

    • 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>

    • The bust every organization write makes, whatever it changed: its record tag in every namespace projecting it, its customer's pages on both surfaces, and the writer's own folded get keys.

      Parameters

      • __namedParameters: { customerId: string; id: string; keys: readonly CacheKey[] }

      Returns Promise<void>

    • Tags for a page: the scope it searched, each customer whose name its rows copy, and the fields of records it may not hold that chose its rows.

      Parameters

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

      Returns string[]

    • Parameters

      • __namedParameters: {
            countriesOfIncorporation?: string[];
            createdAt?: DbTimestampCriteria;
            customerId: string;
            descriptionLike?: string;
            ids?: string[];
            includeDeleted?: boolean;
            legalEntityTypeLike?: string;
            legalEntityTypes?: (
                | "LIMITED_LIABILITY_COMPANY"
                | "C_CORPORATION"
                | "S_CORPORATION"
                | "B_CORPORATION"
                | "CLOSE_CORPORATION"
                | "COOPERATIVE"
                | "GENERAL_PARTNERSHIP"
                | "LIMITED_PARTNERSHIP"
                | "NONPROFIT_CORPORATION"
                | "SOLE_PROPRIETORSHIP"
            )[];
            nameLike?: string;
            orderBy?: DbOrderByCriterion<
                Omit<
                    PgTableWithColumns<
                        {
                            columns: {
                                achName: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                countryOfIncorporation: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                createdAt: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                customerExternalId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                customerId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                data: PgBuildColumn<
                                    "organization",
                                    Set$Type<
                                        PgJsonbBuilder,
                                        {
                                            email?: ...;
                                            expectedActivity?: ...;
                                            incorporationDate?: ...;
                                            naicsCode?: ...;
                                            operatingAddress?: ...;
                                            phone?: ...;
                                            registeredAddress?: ...;
                                            registrationNumber?: ...;
                                            routeFusionEntity?: ...;
                                            stateOfIncorporation?: ...;
                                            verificationData?: ...;
                                            verificationProfileId?: ...;
                                            websiteUrl?: ...;
                                            zenusOnboardedAt?: ...;
                                            zenusPersonId?: ...;
                                        },
                                    >,
                                    {
                                        data: {
                                            email?: ...;
                                            expectedActivity?: ...;
                                            incorporationDate?: ...;
                                            naicsCode?: ...;
                                            operatingAddress?: ...;
                                            phone?: ...;
                                            registeredAddress?: ...;
                                            registrationNumber?: ...;
                                            routeFusionEntity?: ...;
                                            stateOfIncorporation?: ...;
                                            verificationData?: ...;
                                            verificationProfileId?: ...;
                                            websiteUrl?: ...;
                                            zenusOnboardedAt?: ...;
                                            zenusPersonId?: ...;
                                        };
                                        dataType: "object json";
                                        driverParam: unknown;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "organization";
                                    },
                                >;
                                deletedAt: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                description: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                email: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                entityType: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                externalId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                id: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                isMainOrg: PgBuildColumn<
                                    "organization",
                                    SetHasDefault<SetNotNull<(...)>>,
                                    {
                                        data: boolean;
                                        dataType: "boolean";
                                        driverParam: boolean;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "organization";
                                    },
                                >;
                                metadata: PgBuildColumn<
                                    "organization",
                                    SetHasDefault<SetNotNull<(...)>>,
                                    {
                                        data: TData;
                                        dataType: "object json";
                                        driverParam: unknown;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "organization";
                                    },
                                >;
                                name: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                referenceId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                searchDocument: PgBuildColumn<
                                    "organization",
                                    SetHasGenerated<SetNotNull<(...)>>,
                                    {
                                        data: string;
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: true;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "organization";
                                    },
                                >;
                                searchDocumentAdmin: PgBuildColumn<
                                    "organization",
                                    SetHasGenerated<SetNotNull<(...)>>,
                                    {
                                        data: string;
                                        dataType: "string";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: true;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "organization";
                                    },
                                >;
                                status: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                taxId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                updatedAt: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                uuid: PgBuildColumn<
                                    "organization",
                                    SetHasDefault<SetNotNull<(...)>>,
                                    {
                                        data: string;
                                        dataType: "string uuid";
                                        driverParam: string;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: true;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: true;
                                        tableName: "organization";
                                    },
                                >;
                                verificationProfileId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                verificationReasons: PgBuildColumn<
                                    "organization",
                                    Set$Type<PgJsonbBuilder, VerificationReasons>,
                                    {
                                        data: VerificationReasons;
                                        dataType: "object json";
                                        driverParam: unknown;
                                        enumValues: undefined;
                                        generated: undefined;
                                        hasDefault: false;
                                        hasRuntimeDefault: false;
                                        identity: undefined;
                                        isAutoincrement: false;
                                        isPrimaryKey: false;
                                        name: string;
                                        notNull: false;
                                        tableName: "organization";
                                    },
                                >;
                                verifiedAt: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                wireName: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                workspaceExternalId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                                workspaceId: PgBuildColumn<
                                    "organization",
                                    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: "organization";
                                    },
                                >;
                            };
                            dialect: "pg";
                            isAlias: false;
                            name: "organization";
                            schema: "b2b";
                        },
                    >,
                    "enableRLS",
                >,
                "name"
                | "createdAt"
                | "updatedAt",
            >[];
            page?: number;
            pageSize?: number;
            referenceIdLike?: string;
            referenceIds?: string[];
            routeFusionEntityIds?: string[];
            statuses?: (
                | "PENDING_VERIFICATION"
                | "ACTION_REQUIRED"
                | "APPROVED"
                | "DISABLED"
                | "DELETED"
            )[];
            updatedAt?: DbTimestampCriteria;
            verificationProfileIds?: string[];
        }
        • OptionalcountriesOfIncorporation?: string[]
        • OptionalcreatedAt?: DbTimestampCriteria
        • customerId: string
        • OptionaldescriptionLike?: string

          Partial match on description

        • Optionalids?: string[]
        • OptionalincludeDeleted?: boolean
        • OptionallegalEntityTypeLike?: string

          Partial match on legal entity type

        • OptionallegalEntityTypes?: (
              | "LIMITED_LIABILITY_COMPANY"
              | "C_CORPORATION"
              | "S_CORPORATION"
              | "B_CORPORATION"
              | "CLOSE_CORPORATION"
              | "COOPERATIVE"
              | "GENERAL_PARTNERSHIP"
              | "LIMITED_PARTNERSHIP"
              | "NONPROFIT_CORPORATION"
              | "SOLE_PROPRIETORSHIP"
          )[]

          Exact match to these canonical legal-entity-type codes (US structures).

        • OptionalnameLike?: string

          Partial match on legal entity name

        • OptionalorderBy?: DbOrderByCriterion<
              Omit<
                  PgTableWithColumns<
                      {
                          columns: {
                              achName: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              countryOfIncorporation: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              createdAt: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              customerExternalId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              customerId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              data: PgBuildColumn<
                                  "organization",
                                  Set$Type<
                                      PgJsonbBuilder,
                                      {
                                          email?: ...;
                                          expectedActivity?: ...;
                                          incorporationDate?: ...;
                                          naicsCode?: ...;
                                          operatingAddress?: ...;
                                          phone?: ...;
                                          registeredAddress?: ...;
                                          registrationNumber?: ...;
                                          routeFusionEntity?: ...;
                                          stateOfIncorporation?: ...;
                                          verificationData?: ...;
                                          verificationProfileId?: ...;
                                          websiteUrl?: ...;
                                          zenusOnboardedAt?: ...;
                                          zenusPersonId?: ...;
                                      },
                                  >,
                                  {
                                      data: {
                                          email?: ...;
                                          expectedActivity?: ...;
                                          incorporationDate?: ...;
                                          naicsCode?: ...;
                                          operatingAddress?: ...;
                                          phone?: ...;
                                          registeredAddress?: ...;
                                          registrationNumber?: ...;
                                          routeFusionEntity?: ...;
                                          stateOfIncorporation?: ...;
                                          verificationData?: ...;
                                          verificationProfileId?: ...;
                                          websiteUrl?: ...;
                                          zenusOnboardedAt?: ...;
                                          zenusPersonId?: ...;
                                      };
                                      dataType: "object json";
                                      driverParam: unknown;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "organization";
                                  },
                              >;
                              deletedAt: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              description: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              email: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              entityType: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              externalId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              id: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              isMainOrg: PgBuildColumn<
                                  "organization",
                                  SetHasDefault<SetNotNull<(...)>>,
                                  {
                                      data: boolean;
                                      dataType: "boolean";
                                      driverParam: boolean;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "organization";
                                  },
                              >;
                              metadata: PgBuildColumn<
                                  "organization",
                                  SetHasDefault<SetNotNull<(...)>>,
                                  {
                                      data: TData;
                                      dataType: "object json";
                                      driverParam: unknown;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "organization";
                                  },
                              >;
                              name: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              referenceId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              searchDocument: PgBuildColumn<
                                  "organization",
                                  SetHasGenerated<SetNotNull<(...)>>,
                                  {
                                      data: string;
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: true;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "organization";
                                  },
                              >;
                              searchDocumentAdmin: PgBuildColumn<
                                  "organization",
                                  SetHasGenerated<SetNotNull<(...)>>,
                                  {
                                      data: string;
                                      dataType: "string";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: true;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "organization";
                                  },
                              >;
                              status: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              taxId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              updatedAt: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              uuid: PgBuildColumn<
                                  "organization",
                                  SetHasDefault<SetNotNull<(...)>>,
                                  {
                                      data: string;
                                      dataType: "string uuid";
                                      driverParam: string;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: true;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: true;
                                      tableName: "organization";
                                  },
                              >;
                              verificationProfileId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              verificationReasons: PgBuildColumn<
                                  "organization",
                                  Set$Type<PgJsonbBuilder, VerificationReasons>,
                                  {
                                      data: VerificationReasons;
                                      dataType: "object json";
                                      driverParam: unknown;
                                      enumValues: undefined;
                                      generated: undefined;
                                      hasDefault: false;
                                      hasRuntimeDefault: false;
                                      identity: undefined;
                                      isAutoincrement: false;
                                      isPrimaryKey: false;
                                      name: string;
                                      notNull: false;
                                      tableName: "organization";
                                  },
                              >;
                              verifiedAt: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              wireName: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              workspaceExternalId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                              workspaceId: PgBuildColumn<
                                  "organization",
                                  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: "organization";
                                  },
                              >;
                          };
                          dialect: "pg";
                          isAlias: false;
                          name: "organization";
                          schema: "b2b";
                      },
                  >,
                  "enableRLS",
              >,
              "name"
              | "createdAt"
              | "updatedAt",
          >[]

          Ties break on the row id, in the last criterion's direction. name is served by organization_*name_idx.

        • Optionalpage?: number

          Defaults to 1

        • OptionalpageSize?: number

          Defaults to 50

        • OptionalreferenceIdLike?: string

          Partial match on reference ID

        • OptionalreferenceIds?: string[]
        • OptionalrouteFusionEntityIds?: string[]

          Matches the pinned RouteFusion business-entity id on data->'routeFusionEntity'->>'entityId'. Mirrors the admin-side filter so Service/AdminService search signatures stay aligned.

        • Optionalstatuses?: (
              | "PENDING_VERIFICATION"
              | "ACTION_REQUIRED"
              | "APPROVED"
              | "DISABLED"
              | "DELETED"
          )[]
        • OptionalupdatedAt?: DbTimestampCriteria
        • OptionalverificationProfileIds?: string[]

          Organizations holding one of these AiPrise business profiles.

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

    • 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[]

    • Parameters

      • __namedParameters: {
            contactPolicy: OrganizationContactPolicy;
            customerId: string;
            data: Partial<
                Pick<
                    Organization,
                    | "taxId"
                    | "countryOfIncorporation"
                    | "legalEntityType"
                    | "referenceId"
                    | "description"
                    | "email"
                    | "websiteUrl"
                    | "registeredAddress"
                    | "operatingAddress"
                    | "registrationNumber"
                    | "stateOfIncorporation"
                    | "incorporationDate",
                > & {
                    metadata: Record<string, Organization["metadata"][string] | null>;
                    phone: string;
                },
            >;
            id: string;
        }
        • contactPolicy: OrganizationContactPolicy

          REQUIRED: an absent email or phone keeps the stored one, a blank one is refused. OPTIONAL: a blank phone clears the stored one.

        • customerId: string
        • data: Partial<
              Pick<
                  Organization,
                  | "taxId"
                  | "countryOfIncorporation"
                  | "legalEntityType"
                  | "referenceId"
                  | "description"
                  | "email"
                  | "websiteUrl"
                  | "registeredAddress"
                  | "operatingAddress"
                  | "registrationNumber"
                  | "stateOfIncorporation"
                  | "incorporationDate",
              > & {
                  metadata: Record<string, Organization["metadata"][string] | null>;
                  phone: string;
              },
          >
        • id: string

      Returns Promise<
          | {
              ok: true;
              value: {
                  achName: string;
                  capabilities: (
                      | "TRANSACT"
                      | "MANAGE_PAYMENT_INSTRUMENT"
                      | "MANAGE_LEDGER_ACCOUNT"
                      | "MANAGE_DEPOSIT_MEMO"
                  )[];
                  countryCode: string;
                  countryOfIncorporation: string;
                  createdAt: Date;
                  deletedAt?: Date;
                  description?: string;
                  email?: string;
                  expectedActivity?: {
                      currencyCount: "TWO_OR_FEWER"
                      | "THREE"
                      | "MORE_THAN_THREE";
                      expectsOnlineGambling: boolean;
                      expectsSanctionedCountryActivity: boolean;
                      monthlyDepositAmount: "UP_TO_30000" | "30000_TO_100000" | "OVER_100000";
                      monthlyDepositCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      monthlyInternationalWireDepositAmount:
                          | "UP_TO_30000"
                          | "30000_TO_100000"
                          | "OVER_100000";
                      monthlyInternationalWireDepositCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyInternationalWirePaymentAmount: | "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyInternationalWirePaymentCount: | "1_TO_5"
                      | "6_TO_10"
                      | "11_OR_MORE";
                      monthlyPaymentAmount: "UP_TO_30000"
                      | "30000_TO_100000"
                      | "OVER_100000";
                      monthlyPaymentCount: "TWO_OR_FEWER" | "THREE" | "MORE_THAN_THREE";
                      operationsStartDate: string;
                      primaryPurpose:
                          | "RECEIVE_CUSTOMER_PAYMENTS"
                          | "EVERYDAY_PURCHASES"
                          | "PAY_SUPPLIERS_AND_EMPLOYEES"
                          | "MANAGE_MULTIPLE_CURRENCIES"
                          | "OTHER";
                      primaryPurposeDetail?: string;
                      sanctionedCountryActivityDetail?: string;
                      services: ("WIRES" | "ACH" | "FOREIGN_EXCHANGE" | "DEBIT_CARD")[];
                      topCountries: string[];
                  };
                  fullName: string;
                  id: string;
                  incorporationDate?: string;
                  legalEntityType: string;
                  metadata: Record<string, string>;
                  naicsCode?: string;
                  name: string;
                  operatingAddress?: OrganizationAddress;
                  phone?: E164Phone;
                  referenceId?: string;
                  registeredAddress?: OrganizationAddress;
                  registrationNumber?: string;
                  requiredInfo: RequiredInfoField[];
                  routeFusionEntity?: {
                      documentsUploadedAt?: string;
                      entityId: string;
                      lastFinalizeError?: { at: string; message: string } | null;
                      programId?: string;
                      requiredDocuments?: string[][];
                      status: "PENDING" | "VERIFIED" | "REJECTED";
                  } & { statusDescription: string };
                  stateOfIncorporation?: string;
                  status:
                      | "PENDING_VERIFICATION"
                      | "ACTION_REQUIRED"
                      | "APPROVED"
                      | "DISABLED"
                      | "DELETED";
                  statusDescription: string;
                  taxId: string;
                  type: "ORGANIZATION";
                  updatedAt: Date;
                  uuid: string;
                  verificationData?: {
                      status: VerificationStatus;
                      verificationSessionId?: string;
                      verificationTemplateId: string;
                  } & { statusDescription: string };
                  verificationProfileId?: string;
                  verificationReasonCode?:
                      | "OTHER"
                      | "INVALID_TAX_ID"
                      | "ADDRESS_MISMATCH"
                      | "REGISTRY_NOT_FOUND"
                      | "DOCUMENT_ISSUE"
                      | "IDENTITY_MISMATCH";
                  verificationReasonCodeDescription?: string;
                  verifiedAt?: Date;
                  websiteUrl?: string;
                  wireName: string;
              };
          }
          | {
              error: | ServiceError<"METADATA_INVALID" | "METADATA_TOO_LARGE">
              | ServiceError<"NOT_FOUND" | "DUPLICATE">
              | ServiceError<
                  | "INVALID_PHONE"
                  | "INVALID_EMAIL"
                  | "INVALID_WEBSITE_URL"
                  | "INVALID_US_STATE"
                  | "INVALID_STATE_OF_INCORPORATION",
              >
              | ServiceError<"EMAIL_REQUIRED" | "PHONE_REQUIRED">
              | OrganizationVerificationFailed;
              ok: false;
          },
      >

    • The exact key OrganizationAdminQueryService.get reads through, for its includeDeleted: false callers.

      The includeDeleted: true variant hashes differently and is reached only by the collection tag, which every Valkey-backed environment has. That gap is deliberate and pre-existing: it only matters in memory mode, where no admin get runs with includeDeleted: true.

      Parameters

      • __namedParameters: { id: string }

      Returns Record<string, unknown>

    • The exact key OrganizationQueryService.get reads through.

      get folds onto search, so these args must stay identical to the ones it passes ({ customerId, ids: [id], pageSize: 1 }) plus the defaults search bakes into its own key — includeDeleted: false and page: 1. Every other filter is undefined there, and serviceCacheKey canonicalizes with JCS, which drops undefined properties. organizationCache.test.ts pins the equivalence.

      Parameters

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

      Returns Record<string, unknown>