104 lines
6.7 KiB
TypeScript
104 lines
6.7 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, two schools, the six product
|
|
* campuses, 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/school/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';
|
|
|
|
/**
|
|
* Two schools under the primary org (Organization → School → Campus). School 1
|
|
* (North) owns the first three campuses (incl. the `tigers` campus the fixture
|
|
* staff are on); School 2 (South) owns the rest — used to prove hard isolation
|
|
* between schools. Every campus belongs to exactly one school.
|
|
*/
|
|
export const SEED_SCHOOL_ID = 'b1a7c0de-0000-4000-8000-000000000031';
|
|
export const SEED_SCHOOL_NAME = 'Demo Academy North';
|
|
export const SEED_SCHOOL_2_ID = 'b1a7c0de-0000-4000-8000-000000000032';
|
|
export const SEED_SCHOOL_2_NAME = 'Demo Academy South';
|
|
|
|
/** The campus the fixture staff are assigned to (the seeded `tigers` campus). */
|
|
export const SEED_CAMPUS_ID = PRODUCT_CAMPUS_SEED_ROWS[0].id;
|
|
|
|
/** Campus → school assignment (campus belongs to exactly one school). */
|
|
export const SEED_SCHOOL_CAMPUS_IDS: Readonly<Record<string, readonly string[]>> =
|
|
Object.freeze({
|
|
[SEED_SCHOOL_ID]: PRODUCT_CAMPUS_SEED_ROWS.slice(0, 3).map((c) => c.id),
|
|
[SEED_SCHOOL_2_ID]: PRODUCT_CAMPUS_SEED_ROWS.slice(3).map((c) => c.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/school/campus/external roles; not the system roles). */
|
|
readonly organization: boolean;
|
|
/** Gets `schoolId` = `SEED_SCHOOL_ID` (school + campus + external roles in School 1). */
|
|
readonly school: 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, school: 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, school: 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, school: false, 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, school: false, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000021', email: 'principal@flatlogic.com', namePrefix: USER_NAME_PREFIXES.DR, firstName: 'Karen', lastName: 'Mitchell', role: ROLE_NAMES.PRINCIPAL, admin: false, organization: true, school: true, campus: false },
|
|
{ id: 'b1a7c0de-0000-4000-8000-000000000022', email: 'registrar@flatlogic.com', namePrefix: USER_NAME_PREFIXES.MS, firstName: 'Nicole', lastName: 'Adams', role: ROLE_NAMES.REGISTRAR, admin: false, organization: true, school: 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, school: 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, school: 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, school: 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, school: 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, school: 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, school: 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,
|
|
school: false,
|
|
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,
|
|
];
|