81 lines
5.0 KiB
TypeScript
81 lines
5.0 KiB
TypeScript
import { ROLE_NAMES, type RoleName } from '@/shared/constants/roles';
|
|
import { PRODUCT_CAMPUS_SEED_ROWS } from '@/shared/constants/campuses';
|
|
import {
|
|
USER_NAME_PREFIXES,
|
|
type UserNamePrefix,
|
|
} from '@/shared/constants/users';
|
|
|
|
/**
|
|
* RBAC seed fixtures (Workstream 4): one company, one campus (the `tigers`
|
|
* product campus), staff covering every campus role, and exactly one loginable
|
|
* user per stored role. Single source shared by the admin-user seeder (creates
|
|
* the users), the user-roles seeder (assigns roles), and the rbac-fixtures
|
|
* seeder (org/campus/staff links). Pre-launch — reset the DB and reseed.
|
|
*/
|
|
|
|
export const SEED_ORGANIZATION_ID = 'b1a7c0de-0000-4000-8000-000000000001';
|
|
export const SEED_ORGANIZATION_NAME = 'Demo Academy';
|
|
|
|
/** The campus the fixture staff are assigned to (the seeded `tigers` campus). */
|
|
export const SEED_CAMPUS_ID = PRODUCT_CAMPUS_SEED_ROWS[0].id;
|
|
|
|
export type StaffType = 'teacher' | 'admin' | 'support';
|
|
|
|
export interface SeedFixtureUser {
|
|
readonly id: string;
|
|
readonly email: string;
|
|
/** Honorific title; the UI renders it before the name (not baked into it). */
|
|
readonly namePrefix?: UserNamePrefix;
|
|
readonly firstName: string;
|
|
readonly lastName: string;
|
|
readonly role: RoleName;
|
|
/** Uses `SEED_ADMIN_PASSWORD` (system roles) vs `SEED_USER_PASSWORD`. */
|
|
readonly admin: boolean;
|
|
/** Gets `organizationId` (org/campus/external roles; not the system roles). */
|
|
readonly organization: boolean;
|
|
/** Gets `campusId` (campus + external roles). */
|
|
readonly campus: boolean;
|
|
/** When set, a staff profile is created with this `staff_type`. */
|
|
readonly staffType?: StaffType;
|
|
}
|
|
|
|
export const SEED_FIXTURE_USERS: readonly SeedFixtureUser[] = [
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000010', email: 'admin@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MR, firstName: 'Alex', lastName: 'Morgan', role: ROLE_NAMES.SUPER_ADMIN, admin: true, organization: false, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000011', email: 'system_admin@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MS, firstName: 'Jordan', lastName: 'Chen', role: ROLE_NAMES.SYSTEM_ADMIN, admin: true, organization: false, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000012', email: 'owner@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MRS, firstName: 'Patricia', lastName: 'Hayes', role: ROLE_NAMES.OWNER, admin: false, organization: true, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000013', email: 'superintendent@flatlogic.com', namePrefix: USER_NAME_PREFIXES.DR, firstName: 'Michael', lastName: 'Torres', role: ROLE_NAMES.SUPERINTENDENT, admin: false, organization: true, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000014', email: 'director@flatlogic.com', namePrefix: USER_NAME_PREFIXES.DR, firstName: 'Sarah', lastName: 'Williams', role: ROLE_NAMES.DIRECTOR, admin: false, organization: true, campus: true, staffType: 'admin' },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000015', email: 'office_manager@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MS, firstName: 'Lisa', lastName: 'Park', role: ROLE_NAMES.OFFICE_MANAGER, admin: false, organization: true, campus: true, staffType: 'admin' },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000016', email: 'teacher@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MRS, firstName: 'Emily', lastName: 'Johnson', role: ROLE_NAMES.TEACHER, admin: false, organization: true, campus: true, staffType: 'teacher' },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000017', email: 'support_staff@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MR, firstName: 'Marcus', lastName: 'Davis', role: ROLE_NAMES.SUPPORT_STAFF, admin: false, organization: true, campus: true, staffType: 'support' },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000018', email: 'student@flatlogic.com', firstName: 'Emma', lastName: 'Clark', role: ROLE_NAMES.STUDENT, admin: false, organization: true, campus: true },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000019', email: 'guardian@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MR, firstName: 'Robert', lastName: 'Clark', role: ROLE_NAMES.GUARDIAN, admin: false, organization: true, campus: true },
|
|
];
|
|
|
|
/**
|
|
* A **second tenant** used only to prove cross-tenant isolation in tests
|
|
* (Workstream 8). It is one organization with one `owner` whose data must never
|
|
* be visible or mutable to the primary-tenant users above. Kept separate from
|
|
* `SEED_FIXTURE_USERS` so the "exactly one user per role in one company"
|
|
* invariant of the primary fixtures still holds.
|
|
*/
|
|
export const SEED_ORGANIZATION_2_ID = 'b1a7c0de-0000-4000-8000-000000000002';
|
|
export const SEED_ORGANIZATION_2_NAME = 'Rival Academy';
|
|
|
|
export const SEED_SECONDARY_OWNER: SeedFixtureUser = {
|
|
id: 'b1a7c0de-0000-4000-8000-000000000020',
|
|
email: 'owner2@flatlogic.com',
|
|
firstName: 'Mr. David',
|
|
lastName: 'Martinez',
|
|
role: ROLE_NAMES.OWNER,
|
|
admin: false,
|
|
organization: true,
|
|
campus: false,
|
|
};
|
|
|
|
/** Every seeded login user: the per-role primary fixtures + the 2nd-tenant owner. */
|
|
export const SEED_ALL_USERS: readonly SeedFixtureUser[] = [
|
|
...SEED_FIXTURE_USERS,
|
|
SEED_SECONDARY_OWNER,
|
|
];
|