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

    Role catalog + role↔permission mapping + per-user role assignment.

    Single role per user. Role mutations on users are written to admin.dashboard_user_activity as user.roleChanged; this service is the authoritative writer for both surfaces.

    Index

    Constructors

    Properties

    Methods

    • Permission keys (resource[/sub]:r|w) granted by the user's role. Returns [] when the user has no role assigned. Result is deduped and sorted for stable consumption by the auth layer.

      NOTE: This is a derived computation (flat string[] of effective permission keys), not a getByX shortcut against the role catalog. The service-pattern.md "no special gets — add a filter to search" rule targets entity lookups; there's no search filter shape on Role or Permission that produces this projection without the same three-table join. Kept here for the hot auth path (admin-dashboard/src/lib/auth.ts → getAuthPermissions).

      Parameters

      • userId: string

      Returns Promise<
          {
              ok: true;
              value: { permissionKeys: string[]; roleName: string
              | null };
          },
      >

    • Parameters

      • Optionalinput: {
            ids?: string[];
            names?: string[];
            page?: number;
            pageSize?: number;
            userIds?: string[];
        }
        • Optionalids?: string[]

          External ids (role_…) of roles to filter by.

        • Optionalnames?: string[]

          Role names to filter by (exact match).

        • Optionalpage?: number
        • OptionalpageSize?: number
        • OptionaluserIds?: string[]

          External ids of users — returns the (deduped) set of roles held by any user in this list. Single-role model, so each input user contributes at most one role.

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

    • Update name / description and/or replace the permission set.

      When permissionKeys is provided, it is treated as a full replacement — the diff against the current set is computed in-service and applied as an INSERT/DELETE pair inside a single transaction.

      Parameters

      • input: {
            data: { description?: string; name?: string; permissionKeys?: string[] };
            id: string;
        }

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