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

    Class CustomerNotificationPreferencesService

    Manage customer-wide notification preferences, kept on the customer's dashboard workspace

    Index
    instance: (...args: []) => CustomerNotificationPreferencesService = ...

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

    • Parameters

      • __namedParameters: { customerId: string }

      Returns Promise<
          {
              ok: true;
              value: | Required<
                  Pick<
                      {
                          email?: {
                              emailAddresses: string[];
                              events: NotificationEventToggles;
                              userGroups: string[];
                              userIds: string[];
                          };
                          internalEmailUserIds?: string[];
                          slack?: NotificationEventToggles;
                          sms?: {
                              events: NotificationEventToggles;
                              userGroups: string[];
                              userIds: string[];
                          };
                      },
                      "email"
                      | "slack"
                      | "sms",
                  >,
              >
              | null;
          },
      >

      Persisted customer notification preferences, or the defaults if not set. null if the customer does not exist.

    • Parameters

      • __namedParameters: { customerId: string }

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

      The CFX staff emailed alongside the customer's recipients, hidden from the customer. null if the customer does not exist.

    • Add or remove one hidden recipient in a single statement, so concurrent toggles and customer saves never overwrite each other. Idempotent.

      Parameters

      • __namedParameters: { customerId: string; subscribed: boolean; userId: string }

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

      The hidden recipients after the change

    • Parameters

      Returns Promise<
          | { error: ServiceError; ok: false }
          | {
              ok: true;
              value: Omit<
                  {
                      emailAddresses: string[];
                      events: NotificationEventToggles;
                      userGroups: string[];
                      userIds: string[];
                  },
                  "events",
              > & { internalUserIds: InternalEmailUserIds };
          },
      >

      Who will receive the email notification. Empty arrays means no one. internalUserIds are CFX staff admin users, gated on user-shadow:r by the caller.

    • Create or update the customer notification preferences

      The top-level fields are replaced completely if present, i.e. if email preferences are supplied, it overrides the persisted values but leaves slack preferences as-is. The internal recipients are another top-level key, so no upsert touches them.

      Parameters

      • __namedParameters: Partial<
            Required<
                Pick<
                    {
                        email?: {
                            emailAddresses: string[];
                            events: NotificationEventToggles;
                            userGroups: string[];
                            userIds: string[];
                        };
                        internalEmailUserIds?: string[];
                        slack?: NotificationEventToggles;
                        sms?: {
                            events: NotificationEventToggles;
                            userGroups: string[];
                            userIds: string[];
                        };
                    },
                    "email"
                    | "slack"
                    | "sms",
                >,
            >,
        > & { customerId: string }

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