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

    Customer service is special: While it can interact with multiple customers like an admin service, when used in a non-admin context, it should only be used to interact with the current customer.

    get() and search() INNER JOIN organization on customer.organizationId, so customers without a primary organization (or whose organizationId no longer resolves to an organization row) do not surface from this service. Until the underlying customer.organization_id column is migrated to a real int references organization.id FK, this is the application-layer guarantee that every Customer returned has a legalEntityName.

    Index

    Constructors

    Methods

    • Create a customer together with its primary organization in one transaction.

      The Customer↔Organization mutual FK (customer.organization_id ⇄ organization.customer_id) means neither row can be inserted standalone with both ends populated. This method inserts the customer (with organizationId NULL), inserts the organization with the new customer's id, then updates the customer to point at the organization — all inside a single transaction. Under READ COMMITTED (the Postgres default) no other session can observe the intermediate state: the in-flight tx doesn't publish its writes until commit, and get()/search() inner-join organization so a customer with NULL organizationId would be filtered out anyway.

      When organization.verificationProfileId is set, the org is created ACTIVE and an organization.organization.created event is published after commit — matching the deleted OrganizationAdminService.createVerified path. When omitted, the org is PENDING_VERIFICATION and no event is published; callers must drive verification through OrganizationService.

      Parameters

      • __namedParameters: Omit<
            Customer,
            "id"
            | "createdAt"
            | "updatedAt"
            | "organizationId"
            | "legalEntityName",
        > & {
            organization: {
                address: {
                    city: string;
                    countryCode: string;
                    line1: string;
                    line2?: string;
                    postalCode: string;
                    regionCode?: string;
                };
                countryOfIncorporation: string;
                description?: string;
                email?: string;
                legalEntityType: string;
                name: string;
                phone?: E164Phone;
                referenceId?: string;
                taxId: string;
                verificationProfileId?: string;
                websiteUrl?: string;
            };
        }

      Returns Promise<Customer>

    • Parameters

      • __namedParameters: {
            ids?: string[];
            name?: string;
            nameLike?: string;
            propelauthWorkspaceIds?: string[];
        }

      Returns Promise<Customer[]>

    • Parameters

      • __namedParameters: Partial<
            Pick<Customer, "name" | "description"> & {
                aipriseIdentityPersonProfileAmlTemplateId: string;
                aipriseIdentityPersonProfileIdentityDocumentTemplateId: string;
                aipriseOrganizationBusinessProfileTemplateId: string;
                aiprisePaymentInstrumentBusinessProfileTemplateId: string;
                aiprisePaymentInstrumentPersonProfileTemplateId: string;
                victorAchCompanyId: string | null;
                victorAchCompanyName: string | null;
                victorFboAccountNumber: string | null;
                victorLedgerProgramId: string | null;
            },
        > & ({ id: string } | { propelauthWorkspaceId: string })

      Returns Promise<Customer>