@burdenoff/microfe-crewfoundry 2026.1102.1 → 2026.1107.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/crewfoundry/CrewFoundryRoot.d.ts.map +1 -1
  2. package/dist/crewfoundry/CrewFoundryRoot.js +14 -0
  3. package/dist/crewfoundry/CrewFoundryRoot.js.map +1 -1
  4. package/dist/crewfoundry/CrewFoundryRoutes.d.ts.map +1 -1
  5. package/dist/crewfoundry/CrewFoundryRoutes.js +27 -19
  6. package/dist/crewfoundry/CrewFoundryRoutes.js.map +1 -1
  7. package/dist/crewfoundry/components/field/DispatchBoardCard.d.ts +13 -0
  8. package/dist/crewfoundry/components/field/DispatchBoardCard.d.ts.map +1 -0
  9. package/dist/crewfoundry/components/field/DispatchBoardCard.js +127 -0
  10. package/dist/crewfoundry/components/field/DispatchBoardCard.js.map +1 -0
  11. package/dist/crewfoundry/components/field/FieldBadges.d.ts +12 -0
  12. package/dist/crewfoundry/components/field/FieldBadges.d.ts.map +1 -0
  13. package/dist/crewfoundry/components/field/FieldBadges.js +45 -0
  14. package/dist/crewfoundry/components/field/FieldBadges.js.map +1 -0
  15. package/dist/crewfoundry/components/field/MyDispatchItem.d.ts +12 -0
  16. package/dist/crewfoundry/components/field/MyDispatchItem.d.ts.map +1 -0
  17. package/dist/crewfoundry/components/field/MyDispatchItem.js +46 -0
  18. package/dist/crewfoundry/components/field/MyDispatchItem.js.map +1 -0
  19. package/dist/crewfoundry/components/field/MyShiftItem.d.ts +14 -0
  20. package/dist/crewfoundry/components/field/MyShiftItem.d.ts.map +1 -0
  21. package/dist/crewfoundry/components/field/MyShiftItem.js +87 -0
  22. package/dist/crewfoundry/components/field/MyShiftItem.js.map +1 -0
  23. package/dist/crewfoundry/components/field/ShiftsCard.d.ts +12 -0
  24. package/dist/crewfoundry/components/field/ShiftsCard.d.ts.map +1 -0
  25. package/dist/crewfoundry/components/field/ShiftsCard.js +87 -0
  26. package/dist/crewfoundry/components/field/ShiftsCard.js.map +1 -0
  27. package/dist/crewfoundry/components/field/fieldFormat.d.ts +8 -0
  28. package/dist/crewfoundry/components/field/fieldFormat.d.ts.map +1 -0
  29. package/dist/crewfoundry/components/field/fieldFormat.js +15 -0
  30. package/dist/crewfoundry/components/field/fieldFormat.js.map +1 -0
  31. package/dist/crewfoundry/components/field/fieldForms.d.ts +19 -0
  32. package/dist/crewfoundry/components/field/fieldForms.d.ts.map +1 -0
  33. package/dist/crewfoundry/components/field/fieldForms.js +223 -0
  34. package/dist/crewfoundry/components/field/fieldForms.js.map +1 -0
  35. package/dist/crewfoundry/components/forms/FormModal.d.ts +1 -1
  36. package/dist/crewfoundry/components/forms/FormModal.d.ts.map +1 -1
  37. package/dist/crewfoundry/components/forms/FormModal.js +1 -1
  38. package/dist/crewfoundry/components/forms/FormModal.js.map +1 -1
  39. package/dist/crewfoundry/lib/fieldOps.d.ts +105 -0
  40. package/dist/crewfoundry/lib/fieldOps.d.ts.map +1 -0
  41. package/dist/crewfoundry/lib/fieldOps.js +85 -0
  42. package/dist/crewfoundry/lib/fieldOps.js.map +1 -0
  43. package/dist/crewfoundry/lib/useFieldOpsData.d.ts +14 -0
  44. package/dist/crewfoundry/lib/useFieldOpsData.d.ts.map +1 -0
  45. package/dist/crewfoundry/lib/useFieldOpsData.js +31 -0
  46. package/dist/crewfoundry/lib/useFieldOpsData.js.map +1 -0
  47. package/dist/crewfoundry/pages/FieldMyWorkPagePage.d.ts +9 -0
  48. package/dist/crewfoundry/pages/FieldMyWorkPagePage.d.ts.map +1 -0
  49. package/dist/crewfoundry/pages/FieldMyWorkPagePage.js +141 -0
  50. package/dist/crewfoundry/pages/FieldMyWorkPagePage.js.map +1 -0
  51. package/dist/crewfoundry/pages/FieldOperationsPagePage.d.ts +9 -0
  52. package/dist/crewfoundry/pages/FieldOperationsPagePage.d.ts.map +1 -0
  53. package/dist/crewfoundry/pages/FieldOperationsPagePage.js +231 -0
  54. package/dist/crewfoundry/pages/FieldOperationsPagePage.js.map +1 -0
  55. package/dist/crewfoundry/pages/HiringCandidatesPagePage.js +24 -24
  56. package/dist/crewfoundry/pages/HrEmployeeProfilePagePage.js +4 -4
  57. package/dist/crewfoundry/store/crewfoundryStore.d.ts +3 -1
  58. package/dist/crewfoundry/store/crewfoundryStore.d.ts.map +1 -1
  59. package/dist/crewfoundry/store/crewfoundryStore.js +1 -1
  60. package/dist/crewfoundry/store/crewfoundryStore.js.map +1 -1
  61. package/dist/crewfoundry/store/fieldOpsStore.d.ts +76 -0
  62. package/dist/crewfoundry/store/fieldOpsStore.d.ts.map +1 -0
  63. package/dist/crewfoundry/store/fieldOpsStore.js +188 -0
  64. package/dist/crewfoundry/store/fieldOpsStore.js.map +1 -0
  65. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"crewfoundryStore.js","names":[],"sources":["../../../src/crewfoundry/store/crewfoundryStore.ts"],"sourcesContent":["import { create } from 'zustand';\nimport type { OverviewMetric, WorkItem } from '../types';\n\n// ── Domain Types ────────────────────────────────────────────────\nexport interface Employee {\n id: string;\n firstName: string;\n lastName: string;\n email: string;\n department: string;\n position: string;\n status: 'active' | 'inactive' | 'on_leave' | 'terminated';\n type: 'full_time' | 'part_time' | 'contract' | 'intern';\n salary: number;\n startDate: string;\n avatar?: string;\n location: string;\n managerId?: string;\n phone: string;\n performanceScore: number;\n /** Real per-employee skill tags (backend default `[]`). */\n skills: string[];\n /** Exit date for terminated employees; ISO string or null while employed. */\n terminationDate?: string | null;\n}\n\nexport interface Department {\n id: string;\n name: string;\n headId: string;\n headName: string;\n employeeCount: number;\n budget: number;\n location: string;\n status: 'active' | 'restructuring';\n}\n\nexport interface JobPosting {\n id: string;\n title: string;\n department: string;\n location: string;\n type: 'full_time' | 'part_time' | 'contract' | 'remote';\n experienceLevel: 'entry' | 'mid' | 'senior' | 'lead' | 'executive';\n salaryMin: number;\n salaryMax: number;\n status: 'draft' | 'active' | 'paused' | 'closed' | 'filled';\n applicants: number;\n postedDate: string;\n deadline: string | null;\n description: string;\n requirements: string[];\n benefits: string[];\n}\n\nexport interface Candidate {\n id: string;\n firstName: string;\n lastName: string;\n email: string;\n phone: string;\n position: string;\n status: 'new' | 'screening' | 'interview' | 'assessment' | 'offer' | 'hired' | 'rejected';\n appliedDate: string;\n resumeUrl?: string;\n rating: number;\n source: string;\n experience: number;\n skills: string[];\n currentCompany: string;\n notes: string;\n /** Date the candidate was hired; ISO string or null until hired. */\n hiredDate?: string | null;\n}\n\nexport interface Interview {\n id: string;\n candidateId: string;\n candidateName: string;\n position: string;\n interviewerName: string;\n date: string;\n time: string;\n type: 'phone' | 'video' | 'onsite' | 'panel' | 'technical';\n status: 'scheduled' | 'completed' | 'cancelled' | 'no_show';\n feedback?: string;\n rating?: number;\n}\n\nexport interface Announcement {\n id: string;\n title: string;\n content: string;\n author: string;\n authorRole: string;\n category: 'general' | 'hr' | 'it' | 'emergency' | 'event';\n priority: 'low' | 'medium' | 'high' | 'urgent';\n isPinned: boolean;\n createdAt: string;\n viewCount: number;\n tags: string[];\n}\n\nexport interface Team {\n id: string;\n name: string;\n description: string;\n leadId: string;\n leadName: string;\n members: string[];\n memberCount: number;\n department: string;\n status: 'active' | 'forming' | 'disbanded';\n projectCount: number;\n createdAt: string;\n}\n\nexport interface Project {\n id: string;\n name: string;\n description: string;\n status: 'planning' | 'active' | 'on_hold' | 'completed' | 'cancelled';\n priority: 'low' | 'medium' | 'high' | 'critical';\n startDate: string;\n endDate: string;\n progress: number;\n budget: number;\n spent: number;\n teamId: string;\n teamName: string;\n managerId: string;\n managerName: string;\n tasks: number;\n completedTasks: number;\n}\n\nexport interface PayrollRecord {\n id: string;\n employeeId: string;\n employeeName: string;\n department: string;\n period: string;\n grossPay: number;\n deductions: number;\n netPay: number;\n status: 'draft' | 'processing' | 'approved' | 'paid' | 'failed';\n payDate: string;\n paymentMethod: string;\n}\n\nexport interface LeaveRequest {\n id: string;\n employeeId: string;\n employeeName: string;\n department: string;\n type: 'annual' | 'sick' | 'personal' | 'maternity' | 'paternity' | 'unpaid';\n startDate: string;\n endDate: string;\n days: number;\n status: 'pending' | 'approved' | 'rejected' | 'cancelled';\n reason: string;\n approverName?: string;\n}\n\nexport interface TimeEntry {\n id: string;\n employeeId: string;\n employeeName: string;\n date: string;\n clockIn: string;\n clockOut: string;\n totalHours: number;\n overtime: number;\n project: string;\n status: 'pending' | 'approved' | 'rejected';\n /** Whether the logged time is billable to a client (backend default `true`). */\n billable: boolean;\n}\n\nexport interface Notification {\n id: string;\n title: string;\n message: string;\n type: 'info' | 'success' | 'warning' | 'error';\n category: string;\n read: boolean;\n createdAt: string;\n actionUrl?: string;\n}\n\nexport interface Vendor {\n id: string;\n name: string;\n category: string;\n contactPerson: string;\n email: string;\n phone: string;\n status: 'active' | 'inactive' | 'pending';\n contractValue: number;\n rating: number;\n}\n\nexport interface Client {\n id: string;\n name: string;\n industry: string;\n contactPerson: string;\n email: string;\n phone: string;\n status: 'active' | 'prospect' | 'churned';\n revenue: number;\n projects: number;\n since: string;\n}\n\n// BOFF-3987 — employee profile Documents tab. The binary + canonical file\n// metadata live in wspace-files-svc; this is just the (employee, file)\n// association crewfoundry owns.\nexport interface CrewEmployeeDocument {\n id: string;\n employeeId: string;\n fileId: string;\n title: string;\n category?: string | null;\n uploadedBy: string;\n uploadedAt: string;\n}\n\n// BOFF-3717 — canonical skills. An employee's skill profile is a list of\n// taxonomy skills with proficiency (0-100, null when not assessed) and\n// provenance, replacing the free-text `skills` tags.\nexport interface CrewSkillSummary {\n id: string;\n name: string;\n category: string;\n source: string;\n}\n\nexport interface CrewEmployeeSkill {\n id: string;\n skillId: string;\n proficiency: number | null;\n verifiedFrom: string;\n lastUsedAt: string | null;\n skill: CrewSkillSummary;\n}\n\n// BOFF-10361 — skills taxonomy administration and \"find people by skill\".\n/** A typed edge of the workspace skills graph (ids only; names come from the taxonomy). */\nexport interface CrewSkillRelationRef {\n id: string;\n /** IMPLIES, RELATED_TO or SUPERSEDES. */\n type: string;\n fromSkillId: string;\n toSkillId: string;\n}\n\n/** A skill in the workspace taxonomy, with holder counts and direct relations. */\nexport interface CrewTaxonomySkill {\n id: string;\n name: string;\n slug: string;\n category: string;\n /** TAXONOMY, CUSTOM or BACKFILL (unmatched legacy string awaiting triage). */\n source: string;\n description: string | null;\n aliases: string[];\n employeeCount: number;\n candidateCount: number;\n relations: CrewSkillRelationRef[];\n}\n\nexport interface CrewSkillUpdateInput {\n name?: string;\n category?: string;\n aliases?: string[];\n description?: string;\n}\n\nexport interface CrewSkillMergeOutcome {\n targetName: string;\n employeesMoved: number;\n candidatesMoved: number;\n jobPostingsMoved: number;\n}\n\n/** An employee who can do a skill, matched through aliases and IMPLIES / SUPERSEDES edges. */\nexport interface CrewSkillHolderMatch {\n employee: {\n id: string;\n firstName: string;\n lastName: string;\n position: string;\n department: string;\n };\n /** EXACT, SUPERSEDED or IMPLIED. */\n matchType: string;\n matchedSkill: { id: string; name: string };\n proficiency: number | null;\n verifiedFrom: string;\n explanation: string;\n}\n\n/** A canonical skill a job posting asks for. */\nexport interface CrewJobPostingSkillRequirement {\n id: string;\n skillId: string;\n required: boolean;\n minProficiency: number | null;\n skill: CrewSkillSummary;\n}\n\nexport interface CrewCandidateSkill {\n id: string;\n skillId: string;\n proficiency: number | null;\n /** RESUME, SELF_REPORTED, RECRUITER, ASSESSMENT or LEGACY. */\n source: string;\n skill: CrewSkillSummary;\n}\n\n// BOFF-3983 — requisition-to-hire onboarding tracker (mock cf-30).\nexport type OnboardingStage = 'offer' | 'paperwork' | 'it_setup' | 'training' | 'day_one';\nexport type OnboardingStatus = 'not_started' | 'in_progress' | 'completed' | 'cancelled';\n\nexport interface CrewOnboardingTask {\n id: string;\n onboardingId: string;\n stage: OnboardingStage;\n title: string;\n assigneeActorId?: string | null;\n assigneeName?: string | null;\n dueDate?: string | null;\n completedAt?: string | null;\n sortOrder: number;\n}\n\nexport interface CrewOnboarding {\n id: string;\n candidateId?: string | null;\n employeeId?: string | null;\n fullName: string;\n position: string;\n department?: string | null;\n startDate?: string | null;\n status: OnboardingStatus;\n currentStage: OnboardingStage;\n createdAt: string;\n tasks: CrewOnboardingTask[];\n totalTaskCount: number;\n completedTaskCount: number;\n progressPercent: number;\n}\n\n// BOFF-4195 — AI-assisted candidate/worker matching engine. Deterministic,\n// rule-based (skill overlap 70% + experience fit 30%) — the backend never\n// fabricates an AI summary; `rationale` is a plain-language breakdown of the\n// two sub-scores so the ranking is never a black box.\nexport interface CrewCandidateMatch {\n candidateId: string;\n jobPostingId: string;\n candidate: Candidate;\n score: number;\n skillScore: number;\n experienceScore: number;\n matchedSkills: string[];\n missingSkills: string[];\n rationale: string;\n}\n\n// Workspace skills supply/demand, computed server-side by\n// `Query.crewSkillsGap` (wspace-crewfoundry-svc analytics service):\n// employeesWithSkill — ACTIVE employees carrying that skill tag\n// openJobsRequiringSkill — open (ACTIVE or PAUSED) job postings listing it\n// shortage — max(0, demand − supply)\n// Rows arrive already sorted by shortage desc, then demand desc. Skills are\n// free-text tags matched case-insensitively; `skill` is the first-seen casing.\nexport interface CrewSkillsGapRow {\n skill: string;\n employeesWithSkill: number;\n openJobsRequiringSkill: number;\n shortage: number;\n}\n\n// BOFF-4208 — executive workforce analytics, computed server-side by\n// `Query.crewExecutiveDashboard`. Every figure is a deterministic rollup of\n// the workspace's own rows (employees, job postings, approved leave); the\n// attrition bands are heuristic signals, not a trained prediction:\n// riskScore — 0..1 sum of driver weights (low performance 0.30, tenure\n// under 6 months 0.20 / under 12 months 0.10, contract or\n// intern 0.15, more than 10 approved leave days in 90 days 0.15)\n// riskLevel — HIGH >= 0.66, MEDIUM >= 0.33, else LOW\n// Headcount gap and skills demand count open (ACTIVE or PAUSED) postings;\n// cost projection is the annualised salary run-rate of ACTIVE employees.\nexport type CrewAttritionRiskLevel = 'HIGH' | 'MEDIUM' | 'LOW';\n\nexport interface CrewAttritionRisk {\n employeeId: string;\n employeeName: string;\n department: string;\n riskLevel: CrewAttritionRiskLevel;\n riskScore: number;\n drivers: string[];\n}\n\nexport interface CrewHeadcountGapRow {\n department: string;\n current: number;\n openPostings: number;\n projectedHeadcount: number;\n}\n\nexport interface CrewCostProjectionRow {\n department: string;\n monthly: number;\n annual: number;\n headcount: number;\n}\n\nexport interface CrewExecutiveDashboard {\n totalHeadcount: number;\n activeHeadcount: number;\n newHiresLast90Days: number;\n exitsLast90Days: number;\n averagePerformanceScore: number;\n averageTenureMonths: number;\n attritionRisk: {\n highCount: number;\n mediumCount: number;\n lowCount: number;\n totalAssessed: number;\n topRisks: CrewAttritionRisk[];\n };\n headcountGap: CrewHeadcountGapRow[];\n skillsGap: CrewSkillsGapRow[];\n costProjection: CrewCostProjectionRow[];\n generatedAt: string;\n}\n\n// BOFF-4193 — native gross-to-net payroll calculation engine (US/IN/GB\n// reference countries). NOT a licensed EOR/statutory-filing platform — see\n// wspace-crewfoundry-svc/src/modules/workforce/services/payroll/README.md\n// for the full scope note. `country`/`status` are kept in the exact\n// UPPER_SNAKE casing the schema's enums use (unlike most entities in this\n// store, which get lower-cased on read) since they're small closed sets\n// displayed as badges, not compared against lower_snake literals elsewhere.\nexport interface CrewPayrollRun {\n id: string;\n country: 'US' | 'IN' | 'GB';\n currency: string;\n period: string;\n payDate?: string | null;\n status: 'DRAFT' | 'CALCULATED' | 'APPROVED' | 'CLOSED';\n employeeCount: number;\n totalGrossPay: number;\n totalNetPay: number;\n calculatedAt?: string | null;\n approvedAt?: string | null;\n approvedBy?: string | null;\n notes?: string | null;\n}\n\nexport interface CrewPayslipTaxBracket {\n label: string;\n rate: number;\n bandFrom: number;\n bandTo?: number | null;\n taxableInBand: number;\n taxOnBand: number;\n}\n\nexport interface CrewPayslipContributionLine {\n label: string;\n rate?: number | null;\n base: number;\n amount: number;\n}\n\nexport interface CrewPayslip {\n id: string;\n payrollRunId: string;\n employeeId: string;\n employeeName: string;\n country: 'US' | 'IN' | 'GB';\n currency: string;\n period: string;\n annualGrossSalary: number;\n grossPay: number;\n taxableIncome: number;\n incomeTax: number;\n employeeSocialContrib: number;\n employerSocialContrib: number;\n otherDeductions: number;\n netPay: number;\n incomeTaxBrackets: CrewPayslipTaxBracket[];\n employeeContributions: CrewPayslipContributionLine[];\n employerContributions: CrewPayslipContributionLine[];\n otherDeductionLines: CrewPayslipContributionLine[];\n assumptions: string[];\n}\n\nexport interface CreateCrewPayrollRunEmployeeInput {\n employeeId: string;\n employeeName: string;\n annualGrossSalary: number;\n}\n\n// ── Learning & Development (BOFF-3401 / BOFF-4201) ─────────────\n// Served by wspace-crewfoundry-svc's learning module: an external-link course\n// catalog plus per-employee enrollment tracking. Course content itself lives\n// wherever `contentUrl` points (an internal doc, an existing LMS, ...).\nexport type CrewEnrollmentStatus = 'not_started' | 'in_progress' | 'completed';\n\nexport interface CrewTrainingCourse {\n id: string;\n title: string;\n description: string;\n contentUrl: string;\n durationMinutes: number | null;\n isActive: boolean;\n requiredForRoles: string[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewEnrollment {\n id: string;\n courseId: string;\n courseTitle: string;\n employeeId: string;\n employeeName: string;\n status: CrewEnrollmentStatus;\n startedAt: string | null;\n completedAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewTrainingCourseCompletion {\n courseId: string;\n courseTitle: string;\n totalEnrolled: number;\n notStartedCount: number;\n inProgressCount: number;\n completedCount: number;\n /** 0-100, as computed by the service. */\n completionRate: number;\n}\n\nexport interface CrewTrainingCourseInput {\n title: string;\n description: string;\n contentUrl: string;\n durationMinutes?: number | null;\n isActive?: boolean;\n requiredForRoles?: string[];\n}\n\n// ── Talent marketplace (BOFF-3401 / BOFF-4203) ─────────────────\n// Served by wspace-crewfoundry-svc's marketplace module. Escrow records are a\n// calculation-only ledger of intended holds/releases — never fund custody.\nexport type CrewServiceListingStatus = 'active' | 'paused';\nexport type CrewBookingStatus = 'requested' | 'confirmed' | 'completed' | 'cancelled';\nexport type CrewEscrowStatus = 'pending_hold' | 'held' | 'released' | 'cancelled';\n\nexport interface CrewServiceListing {\n id: string;\n title: string;\n description: string;\n category: string | null;\n providerActorId: string;\n providerName: string;\n rate: number;\n rateUnit: string;\n currency: string;\n status: CrewServiceListingStatus;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewServiceListingInput {\n title: string;\n description: string;\n providerName: string;\n category?: string | null;\n rate: number;\n rateUnit: string;\n currency?: string;\n}\n\nexport interface CrewBooking {\n id: string;\n listingId: string;\n listingTitle: string;\n providerActorId: string;\n providerName: string;\n clientActorId: string;\n clientName: string;\n status: CrewBookingStatus;\n rate: number;\n rateUnit: string;\n currency: string;\n notes: string | null;\n scheduledStart: string | null;\n scheduledEnd: string | null;\n cancelledReason: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewBookingInput {\n listingId: string;\n clientName: string;\n notes?: string | null;\n scheduledStart?: string | null;\n scheduledEnd?: string | null;\n}\n\nexport interface CrewEscrowRecord {\n id: string;\n bookingId: string;\n amount: number;\n currency: string;\n releaseCondition: string;\n status: CrewEscrowStatus;\n heldAt: string | null;\n releasedAt: string | null;\n releasedBy: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nimport { clearGraphqlFetchResponseCache, graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport type { Gateway } from '@burdenoff/fe-libs/shared/config';\n\ntype InitParams = {\n workspaceId?: string;\n authToken?: string;\n apiGatewayUrl?: string;\n actorId?: string;\n /** Display name of the signed-in actor (default provider/client label). */\n actorName?: string;\n};\n\ntype GraphqlResult<T> = {\n data: T | null;\n errors?: Array<{ message: string }>;\n};\n\nconst BOOTSTRAP_QUERY = `\n query CrewfoundryBootstrap {\n crewfoundryBootstrap {\n employees { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate }\n departments { id name headId headName employeeCount budget location status }\n jobPostings { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits }\n candidates { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate }\n interviews { id candidateId candidateName position interviewerName date time type status feedback rating }\n announcements { id title content author authorRole category priority isPinned createdAt viewCount tags }\n teams { id name description leadId leadName members memberCount department status projectCount createdAt }\n projects { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks }\n leaveRequests { id employeeId employeeName department type startDate endDate days status reason approverName }\n timeEntries { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable }\n vendors { id name category contactPerson email phone status contractValue rating }\n clients { id name industry contactPerson email phone status revenue projects since }\n }\n }\n`;\n\n// Payroll (BOFF-4887) is deliberately NOT part of crewfoundryBootstrap — it is\n// gated by the dedicated `crewfoundry-payroll` RBAC resource rather than the\n// general `crewfoundry:read` the bootstrap query uses, so a Workforce\n// Coordinator (or any role with only general workforce access) must not be\n// able to read gross/net pay and deductions just by loading the dashboard.\n// Fetched separately via `runOverlap` below (best-effort — a FORBIDDEN\n// response from a role without payroll access degrades to an empty list\n// rather than failing the whole bootstrap load).\nconst CREW_PAYROLL_RECORDS_QUERY = `\n query CrewPayrollRecords {\n crewPayrollRecords { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod }\n }\n`;\n\ntype CrewPayrollRecordsResponse = {\n crewPayrollRecords: PayrollRecord[];\n};\n\nconst WORKSPACE_BOOTSTRAP_WITH_OVERLAP_QUERY = `\n query CrewfoundryWorkspaceBootstrapWithOverlap(\n $workspaceId: ID!\n $projectPagination: PaginationInput\n $groupFirst: Int\n $conversationFirst: Int\n ) {\n crewfoundryBootstrap {\n employees { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate }\n departments { id name headId headName employeeCount budget location status }\n jobPostings { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits }\n candidates { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate }\n interviews { id candidateId candidateName position interviewerName date time type status feedback rating }\n announcements { id title content author authorRole category priority isPinned createdAt viewCount tags }\n teams { id name description leadId leadName members memberCount department status projectCount createdAt }\n projects { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks }\n leaveRequests { id employeeId employeeName department type startDate endDate days status reason approverName }\n timeEntries { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable }\n vendors { id name category contactPerson email phone status contractValue rating }\n clients { id name industry contactPerson email phone status revenue projects since }\n }\n projects(filter: { workspaceId: $workspaceId }, pagination: $projectPagination) {\n items {\n id\n name\n key\n creatorId\n status\n config\n archived\n createdAt\n updatedAt\n }\n }\n groups(first: $groupFirst) {\n edges {\n node {\n id\n name\n description\n groupType\n status\n memberCount\n ownerId\n createdAt\n }\n }\n }\n conversations(first: $conversationFirst) {\n edges {\n node {\n id\n title\n description\n state\n unreadCount\n memberCount\n updatedAt\n }\n }\n }\n }\n`;\n\nconst CREATE_EMPLOYEE_MUTATION = `mutation CreateCrewEmployee($input: CreateCrewEmployeeInput!) { createCrewEmployee(input: $input) { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate } }`;\nconst UPDATE_EMPLOYEE_MUTATION = `mutation UpdateCrewEmployee($id: ID!, $input: UpdateCrewEmployeeInput!) { updateCrewEmployee(id: $id, input: $input) { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate } }`;\nconst REMOVE_EMPLOYEE_MUTATION = `mutation RemoveCrewEmployee($id: ID!) { removeCrewEmployee(id: $id) }`;\nconst CREATE_JOB_MUTATION = `mutation CreateCrewJobPosting($input: CreateCrewJobPostingInput!) { createCrewJobPosting(input: $input) { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits } }`;\nconst UPDATE_JOB_MUTATION = `mutation UpdateCrewJobPosting($id: ID!, $input: UpdateCrewJobPostingInput!) { updateCrewJobPosting(id: $id, input: $input) { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits } }`;\nconst CREATE_CANDIDATE_MUTATION = `mutation CreateCrewCandidate($input: CreateCrewCandidateInput!) { createCrewCandidate(input: $input) { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } }`;\nconst UPDATE_CANDIDATE_MUTATION = `mutation UpdateCrewCandidate($id: ID!, $input: UpdateCrewCandidateInput!) { updateCrewCandidate(id: $id, input: $input) { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } }`;\nconst CREATE_ANNOUNCEMENT_MUTATION = `mutation CreateCrewAnnouncement($input: CreateCrewAnnouncementInput!) { createCrewAnnouncement(input: $input) { id title content author authorRole category priority isPinned createdAt viewCount tags } }`;\nconst CREATE_LEAVE_MUTATION = `mutation CreateCrewLeaveRequest($input: CreateCrewLeaveRequestInput!) { createCrewLeaveRequest(input: $input) { id employeeId employeeName department type startDate endDate days status reason approverName } }`;\nconst UPDATE_LEAVE_MUTATION = `mutation UpdateCrewLeaveRequest($id: ID!, $input: UpdateCrewLeaveRequestInput!) { updateCrewLeaveRequest(id: $id, input: $input) { id employeeId employeeName department type startDate endDate days status reason approverName } }`;\n// Extra removes / updates for existing entities (delete + edit buttons).\nconst REMOVE_JOB_MUTATION = `mutation RemoveCrewJobPosting($id: ID!) { removeCrewJobPosting(id: $id) }`;\nconst REMOVE_CANDIDATE_MUTATION = `mutation RemoveCrewCandidate($id: ID!) { removeCrewCandidate(id: $id) }`;\nconst UPDATE_ANNOUNCEMENT_MUTATION = `mutation UpdateCrewAnnouncement($id: ID!, $input: UpdateCrewAnnouncementInput!) { updateCrewAnnouncement(id: $id, input: $input) { id title content author authorRole category priority isPinned createdAt viewCount tags } }`;\nconst REMOVE_ANNOUNCEMENT_MUTATION = `mutation RemoveCrewAnnouncement($id: ID!) { removeCrewAnnouncement(id: $id) }`;\n\n// Interview\nconst CREATE_INTERVIEW_MUTATION = `mutation CreateCrewInterview($input: CreateCrewInterviewInput!) { createCrewInterview(input: $input) { id candidateId candidateName position interviewerName date time type status feedback rating } }`;\nconst UPDATE_INTERVIEW_MUTATION = `mutation UpdateCrewInterview($id: ID!, $input: UpdateCrewInterviewInput!) { updateCrewInterview(id: $id, input: $input) { id candidateId candidateName position interviewerName date time type status feedback rating } }`;\nconst REMOVE_INTERVIEW_MUTATION = `mutation RemoveCrewInterview($id: ID!) { removeCrewInterview(id: $id) }`;\n\n// Vendor\nconst CREATE_VENDOR_MUTATION = `mutation CreateCrewVendor($input: CreateCrewVendorInput!) { createCrewVendor(input: $input) { id name category contactPerson email phone status contractValue rating } }`;\nconst UPDATE_VENDOR_MUTATION = `mutation UpdateCrewVendor($id: ID!, $input: UpdateCrewVendorInput!) { updateCrewVendor(id: $id, input: $input) { id name category contactPerson email phone status contractValue rating } }`;\nconst REMOVE_VENDOR_MUTATION = `mutation RemoveCrewVendor($id: ID!) { removeCrewVendor(id: $id) }`;\n\n// Client\nconst CREATE_CLIENT_MUTATION = `mutation CreateCrewClient($input: CreateCrewClientInput!) { createCrewClient(input: $input) { id name industry contactPerson email phone status revenue projects since } }`;\nconst UPDATE_CLIENT_MUTATION = `mutation UpdateCrewClient($id: ID!, $input: UpdateCrewClientInput!) { updateCrewClient(id: $id, input: $input) { id name industry contactPerson email phone status revenue projects since } }`;\nconst REMOVE_CLIENT_MUTATION = `mutation RemoveCrewClient($id: ID!) { removeCrewClient(id: $id) }`;\n\n// Team\nconst CREATE_TEAM_MUTATION = `mutation CreateCrewTeam($input: CreateCrewTeamInput!) { createCrewTeam(input: $input) { id name description leadId leadName members memberCount department status projectCount createdAt } }`;\nconst UPDATE_TEAM_MUTATION = `mutation UpdateCrewTeam($id: ID!, $input: UpdateCrewTeamInput!) { updateCrewTeam(id: $id, input: $input) { id name description leadId leadName members memberCount department status projectCount createdAt } }`;\nconst REMOVE_TEAM_MUTATION = `mutation RemoveCrewTeam($id: ID!) { removeCrewTeam(id: $id) }`;\n\n// Project\nconst CREATE_PROJECT_MUTATION = `mutation CreateCrewProject($input: CreateCrewProjectInput!) { createCrewProject(input: $input) { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks } }`;\nconst UPDATE_PROJECT_MUTATION = `mutation UpdateCrewProject($id: ID!, $input: UpdateCrewProjectInput!) { updateCrewProject(id: $id, input: $input) { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks } }`;\nconst REMOVE_PROJECT_MUTATION = `mutation RemoveCrewProject($id: ID!) { removeCrewProject(id: $id) }`;\n\n// Department\nconst CREATE_DEPARTMENT_MUTATION = `mutation CreateCrewDepartment($input: CreateCrewDepartmentInput!) { createCrewDepartment(input: $input) { id name headId headName employeeCount budget location status } }`;\nconst UPDATE_DEPARTMENT_MUTATION = `mutation UpdateCrewDepartment($id: ID!, $input: UpdateCrewDepartmentInput!) { updateCrewDepartment(id: $id, input: $input) { id name headId headName employeeCount budget location status } }`;\nconst REMOVE_DEPARTMENT_MUTATION = `mutation RemoveCrewDepartment($id: ID!) { removeCrewDepartment(id: $id) }`;\n\n// PayrollRecord\nconst CREATE_PAYROLL_MUTATION = `mutation CreateCrewPayrollRecord($input: CreateCrewPayrollRecordInput!) { createCrewPayrollRecord(input: $input) { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod } }`;\nconst UPDATE_PAYROLL_MUTATION = `mutation UpdateCrewPayrollRecord($id: ID!, $input: UpdateCrewPayrollRecordInput!) { updateCrewPayrollRecord(id: $id, input: $input) { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod } }`;\nconst REMOVE_PAYROLL_MUTATION = `mutation RemoveCrewPayrollRecord($id: ID!) { removeCrewPayrollRecord(id: $id) }`;\n\n// BOFF-4193 — native payroll calculation engine (PayrollRun/Payslip). Fetched\n// lazily (see `fetchPayrollRuns`/`fetchPayslipsForRun` below), not on\n// bootstrap — same `crewfoundry-payroll` RBAC gate as CrewPayrollRecord\n// above, so a caller without payroll access simply never triggers the fetch\n// rather than failing the dashboard load.\nconst PAYROLL_RUN_FIELDS = `id country currency period payDate status employeeCount totalGrossPay totalNetPay calculatedAt approvedAt approvedBy notes`;\nconst CREW_PAYROLL_RUNS_QUERY = `query CrewPayrollRuns { crewPayrollRuns { ${PAYROLL_RUN_FIELDS} } }`;\nconst CREATE_PAYROLL_RUN_MUTATION = `mutation CreateCrewPayrollRun($input: CreateCrewPayrollRunInput!) { createCrewPayrollRun(input: $input) { ${PAYROLL_RUN_FIELDS} } }`;\nconst CALCULATE_PAYROLL_RUN_MUTATION = `mutation CalculateCrewPayrollRun($id: ID!) { calculateCrewPayrollRun(id: $id) { ${PAYROLL_RUN_FIELDS} } }`;\nconst APPROVE_PAYROLL_RUN_MUTATION = `mutation ApproveCrewPayrollRun($id: ID!) { approveCrewPayrollRun(id: $id) { ${PAYROLL_RUN_FIELDS} } }`;\nconst REMOVE_PAYROLL_RUN_MUTATION = `mutation RemoveCrewPayrollRun($id: ID!) { removeCrewPayrollRun(id: $id) }`;\nconst PAYSLIP_FIELDS = `id payrollRunId employeeId employeeName country currency period annualGrossSalary grossPay taxableIncome incomeTax employeeSocialContrib employerSocialContrib otherDeductions netPay incomeTaxBrackets { label rate bandFrom bandTo taxableInBand taxOnBand } employeeContributions { label rate base amount } employerContributions { label rate base amount } otherDeductionLines { label rate base amount } assumptions`;\nconst CREW_PAYSLIPS_QUERY = `query CrewPayslips($filter: CrewPayslipFilterInput) { crewPayslips(filter: $filter) { ${PAYSLIP_FIELDS} } }`;\n\n// TimeEntry\nconst CREATE_TIME_ENTRY_MUTATION = `mutation CreateCrewTimeEntry($input: CreateCrewTimeEntryInput!) { createCrewTimeEntry(input: $input) { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable } }`;\nconst UPDATE_TIME_ENTRY_MUTATION = `mutation UpdateCrewTimeEntry($id: ID!, $input: UpdateCrewTimeEntryInput!) { updateCrewTimeEntry(id: $id, input: $input) { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable } }`;\nconst REMOVE_TIME_ENTRY_MUTATION = `mutation RemoveCrewTimeEntry($id: ID!) { removeCrewTimeEntry(id: $id) }`;\n\n// BOFF-4195 — AI-assisted candidate/worker matching. `candidate` is the full\n// CrewCandidate record so the UI can show name/skills/experience alongside\n// the score without a second round-trip.\nconst JOB_POSTING_MATCHES_QUERY = `query CrewJobPostingMatches($jobPostingId: ID!, $filter: CrewCandidateMatchFilterInput, $limit: Int) { crewJobPostingMatches(jobPostingId: $jobPostingId, filter: $filter, limit: $limit) { candidateId jobPostingId score skillScore experienceScore matchedSkills missingSkills rationale candidate { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } } }`;\n\n// Skills supply/demand. Not part of `crewfoundryBootstrap` (it isn't a bootstrap\n// field), so it is fetched lazily by the one surface that renders it — the\n// resourcing page — rather than on every dashboard load. Same `crewfoundry:read`\n// RBAC resource as the bootstrap query, so any caller that can load the module\n// can read it. `department` is omitted because the resourcing page shows\n// workspace-wide coverage; when passed, the resolver scopes both supply\n// (employees) and demand (job postings) to that department.\nconst SKILLS_GAP_QUERY = `query CrewSkillsGap { crewSkillsGap { skill employeesWithSkill openJobsRequiringSkill shortage } }`;\n\n// BOFF-4208 — single-call executive rollup (read-only, `crewfoundry` read RBAC).\nconst EXECUTIVE_DASHBOARD_QUERY = `query CrewExecutiveDashboard { crewExecutiveDashboard { totalHeadcount activeHeadcount newHiresLast90Days exitsLast90Days averagePerformanceScore averageTenureMonths attritionRisk { highCount mediumCount lowCount totalAssessed topRisks { employeeId employeeName department riskLevel riskScore drivers } } headcountGap { department current openPostings projectedHeadcount } skillsGap { skill employeesWithSkill openJobsRequiringSkill shortage } costProjection { department monthly annual headcount } generatedAt } }`;\n\n// BOFF-3987 — employee documents\nconst EMPLOYEE_DOCUMENTS_QUERY = `query EmployeeDocuments($employeeId: ID!) { employeeDocuments(employeeId: $employeeId) { id employeeId fileId title category uploadedBy uploadedAt } }`;\nconst ATTACH_EMPLOYEE_DOCUMENT_MUTATION = `mutation AttachEmployeeDocument($input: AttachCrewEmployeeDocumentInput!) { attachEmployeeDocument(input: $input) { id employeeId fileId title category uploadedBy uploadedAt } }`;\nconst DETACH_EMPLOYEE_DOCUMENT_MUTATION = `mutation DetachEmployeeDocument($id: ID!) { detachEmployeeDocument(id: $id) }`;\n// BOFF-3717 — the profile query also returns the (deprecated) legacy `skills`\n// tags so the directory's tag view stays in step after an attach/detach.\nconst EMPLOYEE_SKILL_PROFILE_QUERY = `query CrewEmployeeSkillProfile($id: ID!) { crewEmployee(id: $id) { id skills skillProfile { id skillId proficiency verifiedFrom lastUsedAt skill { id name category source } } } }`;\nconst ATTACH_CREW_SKILL_MUTATION = `mutation AttachCrewSkill($input: AttachCrewSkillInput!) { attachCrewSkill(input: $input) { id } }`;\nconst DETACH_CREW_SKILL_MUTATION = `mutation DetachCrewSkill($employeeId: ID!, $skillId: ID!) { detachCrewSkill(employeeId: $employeeId, skillId: $skillId) }`;\n// BOFF-10361 — taxonomy administration, find-people-by-skill and candidate skills.\n// Relations are fetched as ids only: names are joined client-side from the\n// taxonomy, so a listing does not resolve two skills per edge.\nconst TAXONOMY_PAGE_SIZE = 100;\n/** Hard stop on taxonomy paging (100 skills per page). */\nconst TAXONOMY_MAX_PAGES = 50;\nconst CREW_SKILLS_TAXONOMY_QUERY = `query CrewSkillsTaxonomy($pagination: PaginationInput) { crewSkills(pagination: $pagination) { id name slug category source description aliases employeeCount candidateCount relations { id type fromSkillId toSkillId } } }`;\nconst CREW_SKILL_CATEGORIES_QUERY = `query CrewSkillCategories { crewSkillCategories }`;\nconst CREATE_CREW_SKILL_MUTATION = `mutation CreateCrewSkill($input: CreateCrewSkillInput!) { createCrewSkill(input: $input) { id } }`;\nconst UPDATE_CREW_SKILL_MUTATION = `mutation UpdateCrewSkill($id: ID!, $input: UpdateCrewSkillInput!) { updateCrewSkill(id: $id, input: $input) { id } }`;\nconst MERGE_CREW_SKILLS_MUTATION = `mutation MergeCrewSkills($sourceId: ID!, $targetId: ID!) { mergeCrewSkills(sourceId: $sourceId, targetId: $targetId) { target { id name } employeesMoved candidatesMoved jobPostingsMoved } }`;\nconst REMOVE_CREW_SKILL_MUTATION = `mutation RemoveCrewSkill($id: ID!) { removeCrewSkill(id: $id) }`;\nconst CREATE_CREW_SKILL_RELATION_MUTATION = `mutation CreateCrewSkillRelation($input: CreateCrewSkillRelationInput!) { createCrewSkillRelation(input: $input) { id } }`;\nconst REMOVE_CREW_SKILL_RELATION_MUTATION = `mutation RemoveCrewSkillRelation($id: ID!) { removeCrewSkillRelation(id: $id) }`;\nconst CREW_EMPLOYEES_BY_SKILL_QUERY = `query CrewEmployeesBySkill($skillId: ID!, $minProficiency: Int, $limit: Int) { crewEmployeesBySkill(skillId: $skillId, minProficiency: $minProficiency, limit: $limit) { employee { id firstName lastName position department } matchType matchedSkill { id name } proficiency verifiedFrom explanation } }`;\nconst JOB_POSTING_SKILL_REQUIREMENTS_QUERY = `query CrewJobPostingSkillRequirements($id: ID!) { crewJobPosting(id: $id) { id skillRequirements { id skillId required minProficiency skill { id name category source } } } }`;\nconst CANDIDATE_SKILL_PROFILE_QUERY = `query CrewCandidateSkillProfile($id: ID!) { crewCandidate(id: $id) { id skills skillProfile { id skillId proficiency source skill { id name category source } } } }`;\nconst ATTACH_CANDIDATE_SKILL_MUTATION = `mutation AttachCrewCandidateSkill($input: AttachCrewCandidateSkillInput!) { attachCrewCandidateSkill(input: $input) { id } }`;\ninterface MergeCrewSkillsPayload {\n target: { id: string; name: string };\n employeesMoved: number;\n candidatesMoved: number;\n jobPostingsMoved: number;\n}\nconst DETACH_CANDIDATE_SKILL_MUTATION = `mutation DetachCrewCandidateSkill($candidateId: ID!, $skillId: ID!) { detachCrewCandidateSkill(candidateId: $candidateId, skillId: $skillId) }`;\n// Files-svc presigned upload dance (same 3-step protocol fe-libs' SaveToFilesButton\n// uses — see ~/products/dev/platform/context/data/files/), replicated here with the\n// store's own graphqlFetch helper instead of Apollo since this MFE has no Apollo\n// client wired in.\nconst ENSURE_FOLDER_BY_PATH_MUTATION = `mutation EnsureFolderByPath($path: String!) { ensureFolderByPath(path: $path) { id } }`;\nconst INITIATE_UPLOAD_MUTATION = `mutation InitiateUpload($input: InitiateUploadInput!) { initiateUpload(input: $input) { session { id } uploadUrl } }`;\nconst COMPLETE_UPLOAD_MUTATION = `mutation CompleteUpload($input: CompleteUploadInput!) { completeUpload(input: $input) { file { id } } }`;\n\n// BOFF-3983 — onboarding\nconst ONBOARDINGS_QUERY = `query CrewOnboardings { crewOnboardings { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst CREATE_ONBOARDING_MUTATION = `mutation CreateCrewOnboarding($input: CreateCrewOnboardingInput!) { createCrewOnboarding(input: $input) { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst UPDATE_ONBOARDING_MUTATION = `mutation UpdateCrewOnboarding($id: ID!, $input: UpdateCrewOnboardingInput!) { updateCrewOnboarding(id: $id, input: $input) { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst REMOVE_ONBOARDING_MUTATION = `mutation RemoveCrewOnboarding($id: ID!) { removeCrewOnboarding(id: $id) }`;\nconst CREATE_ONBOARDING_TASK_MUTATION = `mutation CreateCrewOnboardingTask($input: CreateCrewOnboardingTaskInput!) { createCrewOnboardingTask(input: $input) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\nconst UPDATE_ONBOARDING_TASK_MUTATION = `mutation UpdateCrewOnboardingTask($id: ID!, $input: UpdateCrewOnboardingTaskInput!) { updateCrewOnboardingTask(id: $id, input: $input) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\nconst REMOVE_ONBOARDING_TASK_MUTATION = `mutation RemoveCrewOnboardingTask($id: ID!) { removeCrewOnboardingTask(id: $id) }`;\nconst TOGGLE_ONBOARDING_TASK_MUTATION = `mutation ToggleCrewOnboardingTask($id: ID!, $completed: Boolean!) { toggleCrewOnboardingTask(id: $id, completed: $completed) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\n\n// BOFF-3401 — Learning & Development. Lazy-loaded by the Learning pages (see\n// `fetchLearning`), not on bootstrap: the catalog, enrollments and the\n// completion dashboard come back in one round trip.\nconst TRAINING_COURSE_FIELDS = `id title description contentUrl durationMinutes isActive requiredForRoles createdAt updatedAt`;\nconst ENROLLMENT_FIELDS = `id courseId courseTitle employeeId employeeName status startedAt completedAt createdAt updatedAt`;\nconst LEARNING_QUERY = `query CrewLearning($coursePage: PaginationInput, $enrollmentPage: PaginationInput) { crewTrainingCourses(pagination: $coursePage) { ${TRAINING_COURSE_FIELDS} } crewEnrollments(pagination: $enrollmentPage) { ${ENROLLMENT_FIELDS} } crewTrainingCompletionDashboard { courseId courseTitle totalEnrolled notStartedCount inProgressCount completedCount completionRate } }`;\nconst TRAINING_COURSES_PAGE_QUERY = `query CrewTrainingCourses($pagination: PaginationInput) { crewTrainingCourses(pagination: $pagination) { ${TRAINING_COURSE_FIELDS} } }`;\nconst ENROLLMENTS_PAGE_QUERY = `query CrewEnrollments($pagination: PaginationInput) { crewEnrollments(pagination: $pagination) { ${ENROLLMENT_FIELDS} } }`;\nconst TRAINING_COMPLETION_QUERY = `query CrewTrainingCompletionDashboard { crewTrainingCompletionDashboard { courseId courseTitle totalEnrolled notStartedCount inProgressCount completedCount completionRate } }`;\nconst CREATE_TRAINING_COURSE_MUTATION = `mutation CreateCrewTrainingCourse($input: CreateCrewTrainingCourseInput!) { createCrewTrainingCourse(input: $input) { ${TRAINING_COURSE_FIELDS} } }`;\nconst UPDATE_TRAINING_COURSE_MUTATION = `mutation UpdateCrewTrainingCourse($id: ID!, $input: UpdateCrewTrainingCourseInput!) { updateCrewTrainingCourse(id: $id, input: $input) { ${TRAINING_COURSE_FIELDS} } }`;\nconst REMOVE_TRAINING_COURSE_MUTATION = `mutation RemoveCrewTrainingCourse($id: ID!) { removeCrewTrainingCourse(id: $id) }`;\nconst CREATE_ENROLLMENT_MUTATION = `mutation CreateCrewEnrollment($input: CreateCrewEnrollmentInput!) { createCrewEnrollment(input: $input) { ${ENROLLMENT_FIELDS} } }`;\nconst UPDATE_ENROLLMENT_STATUS_MUTATION = `mutation UpdateCrewEnrollmentStatus($id: ID!, $status: String!) { updateCrewEnrollmentStatus(id: $id, status: $status) { ${ENROLLMENT_FIELDS} } }`;\nconst REMOVE_ENROLLMENT_MUTATION = `mutation RemoveCrewEnrollment($id: ID!) { removeCrewEnrollment(id: $id) }`;\n\n// BOFF-3401 — talent marketplace. Lazy-loaded by the Marketplace pages (see\n// `fetchMarketplace`). Escrow is gated by the separate `crewfoundry-payroll`\n// RBAC resource, so it is fetched on its own (`fetchEscrowRecords`) and a\n// caller without that grant still gets the listings and bookings.\nconst SERVICE_LISTING_FIELDS = `id title description category providerActorId providerName rate rateUnit currency status createdAt updatedAt`;\nconst BOOKING_FIELDS = `id listingId listingTitle providerActorId providerName clientActorId clientName status rate rateUnit currency notes scheduledStart scheduledEnd cancelledReason createdAt updatedAt`;\nconst ESCROW_FIELDS = `id bookingId amount currency releaseCondition status heldAt releasedAt releasedBy notes createdAt updatedAt`;\nconst SERVICE_LISTINGS_PAGE_QUERY = `query CrewServiceListings($pagination: PaginationInput) { crewServiceListings(pagination: $pagination) { ${SERVICE_LISTING_FIELDS} } }`;\nconst BOOKINGS_PAGE_QUERY = `query CrewBookings($pagination: PaginationInput) { crewBookings(pagination: $pagination) { ${BOOKING_FIELDS} } }`;\nconst ESCROW_RECORDS_PAGE_QUERY = `query CrewEscrowRecords($pagination: PaginationInput) { crewEscrowRecords(pagination: $pagination) { ${ESCROW_FIELDS} } }`;\nconst CREATE_SERVICE_LISTING_MUTATION = `mutation CreateCrewServiceListing($input: CreateCrewServiceListingInput!) { createCrewServiceListing(input: $input) { ${SERVICE_LISTING_FIELDS} } }`;\nconst UPDATE_SERVICE_LISTING_MUTATION = `mutation UpdateMyServiceListing($id: ID!, $input: UpdateCrewServiceListingInput!) { updateMyServiceListing(id: $id, input: $input) { ${SERVICE_LISTING_FIELDS} } }`;\nconst REMOVE_SERVICE_LISTING_MUTATION = `mutation RemoveMyServiceListing($id: ID!) { removeMyServiceListing(id: $id) }`;\nconst CREATE_BOOKING_MUTATION = `mutation CreateCrewBooking($input: CreateCrewBookingInput!) { createCrewBooking(input: $input) { ${BOOKING_FIELDS} } }`;\nconst UPDATE_BOOKING_STATUS_MUTATION = `mutation UpdateMyBookingStatus($id: ID!, $status: String!) { updateMyBookingStatus(id: $id, status: $status) { ${BOOKING_FIELDS} } }`;\nconst RELEASE_ESCROW_MUTATION = `mutation ReleaseCrewEscrowRecord($id: ID!) { releaseCrewEscrowRecord(id: $id) { ${ESCROW_FIELDS} } }`;\nconst CANCEL_ESCROW_MUTATION = `mutation CancelCrewEscrowRecord($id: ID!) { cancelCrewEscrowRecord(id: $id) { ${ESCROW_FIELDS} } }`;\n\n/** Server page ceiling (wspace-crewfoundry-svc MAX_LIMIT). */\nconst LIST_PAGE_SIZE = 100;\n/** Safety ceiling on pages fetched per list (10 x 100 rows). */\nconst LIST_MAX_PAGES = 10;\n\nconst normalizeStatus = (value: string) => value.toUpperCase().replaceAll('-', '_');\n\n// The backend returns enum values in UPPER_SNAKE case (e.g. \"ACTIVE\", \"FULL_TIME\", \"HIGH\"),\n// but the frontend model + every comparison/filter/badge uses lower_snake ('active', 'full_time').\n// Normalization is per-entity, NOT per-key: fields like `category` are genuine enums on some\n// entities (Announcement.category) yet free text on others (Vendor.category,\n// CrewServiceListing.category) — a global key list would corrupt those.\n// Each list below mirrors exactly the string-literal-union fields declared on that entity's interface.\nconst ENUM_KEYS = {\n employee: ['status', 'type'],\n department: ['status'],\n jobPosting: ['type', 'experienceLevel', 'status'],\n candidate: ['status'],\n interview: ['type', 'status'],\n enrollment: ['status'],\n serviceListing: ['status'],\n booking: ['status'],\n escrow: ['status'],\n announcement: ['category', 'priority'],\n team: ['status'],\n project: ['status', 'priority'],\n payrollRecord: ['status'],\n leaveRequest: ['type', 'status'],\n timeEntry: ['status'],\n notification: ['type'],\n vendor: ['status'],\n client: ['status'],\n onboarding: ['status', 'currentStage'],\n onboardingTask: ['stage'],\n} as const;\n\n// Lowercase only the given enum keys on an entity read back from the backend; leave every other\n// (free-text) field untouched. Idempotent — safe on already-lowercase values (some subgraphs\n// return lowercase already). This is the read-path inverse of `normalizeStatus`.\nconst lowerEnumKeys = <T>(entity: T, keys: readonly string[]): T => {\n if (!entity || typeof entity !== 'object') return entity;\n const out = { ...(entity as Record<string, unknown>) };\n for (const key of keys) {\n const value = out[key];\n if (typeof value === 'string') out[key] = value.toLowerCase();\n }\n return out as T;\n};\n\n// lowerEnumKeys only lowercases top-level string fields; CrewOnboarding nests\n// a `tasks` array whose own `stage` field also needs the same treatment, so\n// this composes lowerEnumKeys over both levels rather than duplicating it.\nconst lowerOnboarding = (onboarding: CrewOnboarding): CrewOnboarding => {\n const lowered = lowerEnumKeys(onboarding, ENUM_KEYS.onboarding);\n return {\n ...lowered,\n tasks: (onboarding.tasks ?? []).map((task) => lowerEnumKeys(task, ENUM_KEYS.onboardingTask)),\n };\n};\n\nconst toDateOnly = (value?: string | null) => (value ? value.slice(0, 10) : 'TBD');\n\nconst asRecord = (value: unknown): Record<string, unknown> | null => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n return null;\n }\n return value as Record<string, unknown>;\n};\n\nconst asNumber = (value: unknown): number | null => (typeof value === 'number' ? value : null);\n\nconst asString = (value: unknown): string | null => (typeof value === 'string' ? value : null);\n\nconst mapProjectStatus = (value: string): Project['status'] => {\n const status = value.toLowerCase();\n if (status === 'active') return 'active';\n if (status === 'completed') return 'completed';\n if (status === 'cancelled') return 'cancelled';\n if (status === 'archived') return 'on_hold';\n return 'planning';\n};\n\nconst mapGroupStatus = (value: string): Team['status'] => {\n const status = value.toLowerCase();\n if (status === 'active') return 'active';\n if (status === 'inactive' || status === 'archived' || status === 'deleted') return 'disbanded';\n return 'forming';\n};\n\ntype OverlapWorkspaceResponse = {\n projects: {\n items: Array<{\n id: string;\n name: string;\n key: string;\n creatorId: string;\n status: string;\n config?: unknown;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n }>;\n };\n groups: {\n edges: Array<{\n node: {\n id: string;\n name: string;\n description?: string | null;\n groupType?: string | null;\n status: string;\n memberCount: number;\n ownerId: string;\n createdAt: string;\n };\n }>;\n };\n conversations: {\n edges: Array<{\n node: {\n id: string;\n title?: string | null;\n description?: string | null;\n state: string;\n unreadCount: number;\n memberCount: number;\n updatedAt: string;\n };\n }>;\n };\n};\n\ntype WorkspaceBootstrapWithOverlapResponse = BootstrapPayload & OverlapWorkspaceResponse;\n\ntype BootstrapPayload = {\n crewfoundryBootstrap: {\n employees: Employee[];\n departments: Department[];\n jobPostings: JobPosting[];\n candidates: Candidate[];\n interviews: Interview[];\n announcements: Announcement[];\n teams: Team[];\n projects: Project[];\n leaveRequests: LeaveRequest[];\n timeEntries: TimeEntry[];\n vendors: Vendor[];\n clients: Client[];\n };\n};\n\nconst mapOverlapProjects = (\n projects: OverlapWorkspaceResponse['projects']['items'],\n teams: Team[]\n) =>\n projects.map((project, index): Project => {\n const config = asRecord(project.config);\n const budget = asNumber(config?.budget) ?? 25000 + index * 2500;\n const spent =\n asNumber(config?.spent) ?? Math.round(budget * (project.status === 'COMPLETED' ? 1 : 0.62));\n const progress = asNumber(config?.progress) ?? (project.status === 'COMPLETED' ? 100 : 58);\n const tasks = asNumber(config?.tasks) ?? 20 + (index % 9);\n const completedTasks = asNumber(config?.completedTasks) ?? Math.round((progress / 100) * tasks);\n const team = teams[index % Math.max(teams.length, 1)];\n\n return {\n id: project.id,\n name: project.name,\n description: asString(config?.description) || `${project.key} delivery plan`,\n status: mapProjectStatus(project.status),\n priority: (asString(config?.priority)?.toLowerCase() as Project['priority']) || 'medium',\n startDate: toDateOnly(project.createdAt),\n endDate: toDateOnly(project.updatedAt),\n progress,\n budget,\n spent,\n teamId: team?.id || 'unassigned',\n teamName: team?.name || 'Unassigned Team',\n managerId: project.creatorId,\n managerName: `Lead ${project.creatorId.slice(0, 8)}`,\n tasks,\n completedTasks,\n };\n });\n\nconst mapOverlapTeams = (groups: OverlapWorkspaceResponse['groups']['edges']): Team[] =>\n groups.map(({ node }) => ({\n id: node.id,\n name: node.name,\n description: node.description || `${node.name} team workspace`,\n leadId: node.ownerId,\n leadName: `Lead ${node.ownerId.slice(0, 8)}`,\n members: [],\n memberCount: node.memberCount,\n department: node.groupType?.toLowerCase().replaceAll('_', ' ') || 'operations',\n status: mapGroupStatus(node.status),\n projectCount: 0,\n createdAt: toDateOnly(node.createdAt),\n }));\n\n/** Shell route of the shared Conversations app (microfe-conversations). */\nexport const CONVERSATIONS_ROUTE = '/conversations';\n\nconst mapConversationNotifications = (\n conversations: OverlapWorkspaceResponse['conversations']['edges']\n): Notification[] =>\n conversations\n .filter(({ node }) => node.unreadCount > 0)\n .map(({ node }) => ({\n id: `conversation-${node.id}`,\n title: node.title || 'Conversation update',\n message: `${node.unreadCount} unread in ${node.memberCount}-member channel`,\n type: node.state.toLowerCase() === 'active' ? 'info' : 'warning',\n category: 'communications',\n read: false,\n createdAt: node.updatedAt,\n // Conversations are owned by wspace-conversations-svc and rendered by the\n // shell's shared Conversations app, not by a CrewFoundry page.\n actionUrl: CONVERSATIONS_ROUTE,\n }));\n\nconst parseGraphql = <T>(result: GraphqlResult<T>, fallbackMessage: string): T => {\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || fallbackMessage);\n }\n if (!result.data) {\n throw new Error(fallbackMessage);\n }\n return result.data;\n};\n\n// Fields that live on the client-side entity objects but are NEVER accepted by\n// any Crew* Create/Update GraphQL input — either a client-generated temp `id`,\n// a server-set timestamp, or a server-derived rollup counter. Sending them makes\n// the gateway reject the whole operation with a GraphQL validation error (which\n// the public gateway masks to a generic INTERNAL_SERVER_ERROR), so no row is\n// ever written. Stripping them centrally keeps every create/update mutation valid\n// without each caller having to hand-pick input fields. (Counters like rating /\n// applicants / viewCount that a few inputs DO accept are safe to drop too — they\n// default server-side, and the UI never lets a user set a derived rollup.)\nconst MUTATION_INPUT_OMIT_KEYS = new Set<string>([\n 'id',\n 'createdAt',\n 'createdOn',\n 'updatedAt',\n 'deletedAt',\n 'employeeCount',\n 'memberCount',\n 'projectCount',\n 'enrolled',\n 'completed',\n 'completionRate',\n 'reviews',\n 'rating',\n 'tasks',\n 'completedTasks',\n 'spent',\n 'progress',\n 'applicants',\n 'viewCount',\n 'revenue',\n 'projects',\n]);\n\nconst sanitizeMutationInput = (\n variables: Record<string, unknown> | undefined\n): Record<string, unknown> | undefined => {\n if (!variables) {\n return variables;\n }\n const input = variables.input;\n if (!input || typeof input !== 'object' || Array.isArray(input)) {\n return variables;\n }\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n if (!MUTATION_INPUT_OMIT_KEYS.has(key)) {\n cleaned[key] = value;\n }\n }\n return { ...variables, input: cleaned };\n};\n\nconst isMutationDocument = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst runGraphql = async <T>(\n query: string,\n variables: Record<string, unknown> | undefined,\n params: InitParams,\n fallbackMessage: string,\n gateway: Gateway = 'workspace'\n) => {\n const result = await graphqlFetch<T>({\n gateway,\n query,\n variables: sanitizeMutationInput(variables),\n authToken: params.authToken,\n // `apiGatewayUrl` is the workspace gateway base (dev override only). The\n // global gateway (e.g. billing overlap) resolves its own URL from fe-libs\n // config, so never force the workspace base onto a global-gateway call.\n baseUrl: gateway === 'workspace' ? params.apiGatewayUrl : undefined,\n extraHeaders: {\n ...(gateway === 'workspace' && params.workspaceId\n ? { 'x-workspace-id': params.workspaceId }\n : {}),\n },\n });\n const data = parseGraphql(result as GraphqlResult<T>, fallbackMessage);\n // fe-libs graphqlFetch caches query responses for a few seconds, keyed by\n // operation + variables. A read issued right after a successful write (e.g.\n // the skill profile refetch after attachCrewSkill) would otherwise be served\n // the pre-mutation response, so the change only appears after a reload.\n if (isMutationDocument(query)) clearGraphqlFetchResponseCache();\n return data;\n};\n\n// Overlap queries are best-effort: they enrich the crew bootstrap with real\n// wspace/global platform data but must never block the page if a field is\n// unavailable in a given environment. Swallow to null, but surface the reason\n// in dev so schema-arg drift (the historical failure mode) is visible.\n// Vite injects `import.meta.env.DEV`, but this package's tsconfig does not pull\n// in `vite/client` ambient types — narrow through a typed shape instead of `any`.\nconst isDevEnv = (): boolean => Boolean((import.meta as { env?: { DEV?: boolean } }).env?.DEV);\n\nconst runOverlap = async <T>(\n query: string,\n variables: Record<string, unknown> | undefined,\n params: InitParams,\n fallbackMessage: string,\n gateway: Gateway = 'workspace'\n): Promise<T | null> => {\n try {\n return await runGraphql<T>(query, variables, params, fallbackMessage, gateway);\n } catch (error) {\n if (isDevEnv()) {\n console.warn(`[crewfoundry] overlap query skipped: ${fallbackMessage}`, error);\n }\n return null;\n }\n};\n\n// ── BOFF-3401 list helpers ──────────────────────────────────────\n/**\n * Fetch every page of a list query (offset paging, `LIST_PAGE_SIZE` rows per\n * page, at most `LIST_MAX_PAGES` pages). A short page ends the walk.\n */\nconst fetchAllPages = async <TRow>(\n query: string,\n field: string,\n params: InitParams,\n fallbackMessage: string,\n firstPage?: TRow[]\n): Promise<TRow[]> => {\n const rows: TRow[] = firstPage ? [...firstPage] : [];\n if (firstPage && firstPage.length < LIST_PAGE_SIZE) {\n return rows;\n }\n for (let page = firstPage ? 1 : 0; page < LIST_MAX_PAGES; page += 1) {\n const data = await runGraphql<Record<string, TRow[]>>(\n query,\n { pagination: { limit: LIST_PAGE_SIZE, offset: page * LIST_PAGE_SIZE } },\n params,\n fallbackMessage\n );\n const batch = data[field] ?? [];\n rows.push(...batch);\n if (batch.length < LIST_PAGE_SIZE) {\n break;\n }\n }\n return rows;\n};\n\n/**\n * Write counters for the lazily loaded slices. A list fetch that was already\n * in flight when a create/update/remove landed would otherwise overwrite the\n * fresh local row with its older snapshot; a fetch that sees the counter move\n * re-reads instead of committing stale data (bounded by WRITE_RACE_RETRIES).\n */\nconst sliceWrites = { learning: 0, marketplace: 0 };\nconst WRITE_RACE_RETRIES = 3;\n\nconst lowerEnrollment = (row: CrewEnrollment) => lowerEnumKeys(row, ENUM_KEYS.enrollment);\nconst lowerListing = (row: CrewServiceListing) => lowerEnumKeys(row, ENUM_KEYS.serviceListing);\nconst lowerBooking = (row: CrewBooking) => lowerEnumKeys(row, ENUM_KEYS.booking);\nconst lowerEscrow = (row: CrewEscrowRecord) => lowerEnumKeys(row, ENUM_KEYS.escrow);\n\n/** Replace a row by id, keeping list order. */\nconst replaceById = <T extends { id: string }>(rows: T[], next: T): T[] =>\n rows.map((row) => (row.id === next.id ? next : row));\n\n/** Re-read the completion dashboard after an enrollment change (best-effort). */\nconst refreshTrainingCompletion = async (\n params: InitParams\n): Promise<CrewTrainingCourseCompletion[] | null> => {\n const data = await runOverlap<{\n crewTrainingCompletionDashboard: CrewTrainingCourseCompletion[];\n }>(TRAINING_COMPLETION_QUERY, undefined, params, 'Unable to load training completion');\n return data?.crewTrainingCompletionDashboard ?? null;\n};\n\n// ── Store Interface ─────────────────────────────────────────────\ninterface CrewFoundryState {\n // Overview\n metrics: OverviewMetric[];\n workItems: WorkItem[];\n selectedView: string;\n\n // Domain data\n employees: Employee[];\n departments: Department[];\n jobPostings: JobPosting[];\n candidates: Candidate[];\n interviews: Interview[];\n announcements: Announcement[];\n teams: Team[];\n projects: Project[];\n payrollRecords: PayrollRecord[];\n leaveRequests: LeaveRequest[];\n timeEntries: TimeEntry[];\n notifications: Notification[];\n vendors: Vendor[];\n clients: Client[];\n employeeDocuments: CrewEmployeeDocument[];\n // BOFF-3717 — skill profiles keyed by employee id, loaded per profile view.\n employeeSkillProfiles: Record<string, CrewEmployeeSkill[]>;\n // BOFF-10361 — workspace skills taxonomy (lazy-loaded by the taxonomy and\n // resourcing pages) and candidate skill profiles keyed by candidate id.\n skillsTaxonomy: CrewTaxonomySkill[];\n skillsTaxonomyLoaded: boolean;\n skillCategories: string[];\n candidateSkillProfiles: Record<string, CrewCandidateSkill[]>;\n onboardings: CrewOnboarding[];\n onboardingsLoaded: boolean;\n // BOFF-4195 — AI-assisted matching. Keyed by jobPostingId so switching\n // between postings' match views doesn't require a refetch each time.\n jobPostingMatches: Record<string, CrewCandidateMatch[]>;\n jobPostingMatchesLoading: boolean;\n\n // BOFF-4193 — native payroll calculation engine. Lazy-loaded (see\n // `fetchPayrollRuns` below), same gating rationale as jobPostingMatches.\n payrollRuns: CrewPayrollRun[];\n payrollRunsLoaded: boolean;\n payrollRunsLoading: boolean;\n // Keyed by payrollRunId so switching between runs' payslip views doesn't\n // require a refetch each time.\n payslipsByRun: Record<string, CrewPayslip[]>;\n payslipsLoading: boolean;\n\n // Workspace skills supply/demand. Lazy-loaded by the resourcing page (see\n // `fetchSkillsGap`), so `skillsGapLoaded` distinguishes \"not fetched yet\"\n // from \"fetched and genuinely empty\" — the two render differently.\n skillsGap: CrewSkillsGapRow[];\n skillsGapLoaded: boolean;\n\n // BOFF-4208 — executive analytics rollup. Lazy-loaded and refreshed by the\n // executive dashboard on every visit (see `fetchExecutiveDashboard`); null\n // until the first successful read. A failed read keeps the last good copy\n // and records the message in `executiveDashboardError`.\n executiveDashboard: CrewExecutiveDashboard | null;\n executiveDashboardLoading: boolean;\n executiveDashboardError: string | null;\n\n // BOFF-3401 — Learning & Development (lazy, see `fetchLearning`).\n trainingCourses: CrewTrainingCourse[];\n enrollments: CrewEnrollment[];\n trainingCompletion: CrewTrainingCourseCompletion[];\n learningLoaded: boolean;\n\n // BOFF-3401 — talent marketplace (lazy, see `fetchMarketplace` /\n // `fetchEscrowRecords`). `escrowError` carries a FORBIDDEN (no\n // crewfoundry-payroll grant) or load failure so the page can say so.\n serviceListings: CrewServiceListing[];\n bookings: CrewBooking[];\n marketplaceLoaded: boolean;\n escrowRecords: CrewEscrowRecord[];\n escrowLoaded: boolean;\n escrowError: string | null;\n\n // Actions\n initialized: boolean;\n loading: boolean;\n error: string | null;\n initParams: InitParams;\n initializeData: (params: InitParams) => Promise<void>;\n setSelectedView: (view: string) => void;\n setWorkItems: (items: WorkItem[]) => void;\n addEmployee: (employee: Employee) => Promise<void>;\n updateEmployee: (id: string, updates: Partial<Employee>) => Promise<void>;\n removeEmployee: (id: string) => Promise<void>;\n addJobPosting: (job: JobPosting) => Promise<void>;\n updateJobPosting: (id: string, updates: Partial<JobPosting>) => Promise<void>;\n addCandidate: (candidate: Candidate) => Promise<void>;\n updateCandidate: (id: string, updates: Partial<Candidate>) => Promise<void>;\n removeJobPosting: (id: string) => Promise<void>;\n removeCandidate: (id: string) => Promise<void>;\n addAnnouncement: (announcement: Announcement) => Promise<void>;\n updateAnnouncement: (id: string, updates: Partial<Announcement>) => Promise<void>;\n removeAnnouncement: (id: string) => Promise<void>;\n addLeaveRequest: (request: LeaveRequest) => Promise<void>;\n updateLeaveRequest: (id: string, updates: Partial<LeaveRequest>) => Promise<void>;\n addInterview: (interview: Interview) => Promise<void>;\n updateInterview: (id: string, updates: Partial<Interview>) => Promise<void>;\n removeInterview: (id: string) => Promise<void>;\n addVendor: (vendor: Vendor) => Promise<void>;\n updateVendor: (id: string, updates: Partial<Vendor>) => Promise<void>;\n removeVendor: (id: string) => Promise<void>;\n addClient: (client: Client) => Promise<void>;\n updateClient: (id: string, updates: Partial<Client>) => Promise<void>;\n removeClient: (id: string) => Promise<void>;\n addTeam: (team: Team) => Promise<void>;\n updateTeam: (id: string, updates: Partial<Team>) => Promise<void>;\n removeTeam: (id: string) => Promise<void>;\n addProject: (project: Project) => Promise<void>;\n updateProject: (id: string, updates: Partial<Project>) => Promise<void>;\n removeProject: (id: string) => Promise<void>;\n addDepartment: (department: Department) => Promise<void>;\n updateDepartment: (id: string, updates: Partial<Department>) => Promise<void>;\n removeDepartment: (id: string) => Promise<void>;\n addPayrollRecord: (record: PayrollRecord) => Promise<void>;\n updatePayrollRecord: (id: string, updates: Partial<PayrollRecord>) => Promise<void>;\n removePayrollRecord: (id: string) => Promise<void>;\n addTimeEntry: (entry: TimeEntry) => Promise<void>;\n updateTimeEntry: (id: string, updates: Partial<TimeEntry>) => Promise<void>;\n removeTimeEntry: (id: string) => Promise<void>;\n markNotificationRead: (id: string) => Promise<void>;\n markAllNotificationsRead: () => Promise<void>;\n\n // BOFF-4195 — AI-assisted candidate/worker matching\n fetchJobPostingMatches: (jobPostingId: string) => Promise<void>;\n\n // BOFF-4193 — native payroll calculation engine\n fetchPayrollRuns: () => Promise<void>;\n createPayrollRun: (input: {\n country: 'US' | 'IN' | 'GB';\n period: string;\n payDate?: string;\n notes?: string;\n employees: CreateCrewPayrollRunEmployeeInput[];\n }) => Promise<void>;\n calculatePayrollRun: (id: string) => Promise<void>;\n approvePayrollRun: (id: string) => Promise<void>;\n removePayrollRun: (id: string) => Promise<void>;\n fetchPayslipsForRun: (payrollRunId: string) => Promise<void>;\n\n // BOFF-3987 — employee documents\n fetchEmployeeDocuments: (employeeId: string) => Promise<void>;\n uploadEmployeeDocument: (params: {\n employeeId: string;\n file: File;\n title: string;\n category?: string;\n }) => Promise<void>;\n detachEmployeeDocument: (id: string) => Promise<void>;\n\n // BOFF-3717 — canonical skills with proficiency\n fetchEmployeeSkillProfile: (employeeId: string) => Promise<void>;\n attachEmployeeSkill: (params: {\n employeeId: string;\n skillName: string;\n proficiency: number | null;\n }) => Promise<void>;\n detachEmployeeSkill: (employeeId: string, skillId: string) => Promise<void>;\n\n // BOFF-10361 — taxonomy administration, find people by skill, candidate skills\n fetchSkillsTaxonomy: () => Promise<void>;\n createTaxonomySkill: (input: {\n name: string;\n category: string;\n aliases: string[];\n description?: string;\n }) => Promise<void>;\n updateTaxonomySkill: (id: string, input: CrewSkillUpdateInput) => Promise<void>;\n mergeTaxonomySkills: (sourceId: string, targetId: string) => Promise<CrewSkillMergeOutcome>;\n removeTaxonomySkill: (id: string) => Promise<void>;\n createSkillRelation: (input: {\n fromSkillId: string;\n toSkillId: string;\n type: string;\n }) => Promise<void>;\n removeSkillRelation: (id: string) => Promise<void>;\n fetchEmployeesBySkill: (\n skillId: string,\n options?: { minProficiency?: number | null; limit?: number }\n ) => Promise<CrewSkillHolderMatch[]>;\n fetchJobPostingSkillRequirements: (\n jobPostingId: string\n ) => Promise<CrewJobPostingSkillRequirement[]>;\n fetchCandidateSkillProfile: (candidateId: string) => Promise<void>;\n attachCandidateSkill: (params: {\n candidateId: string;\n skillName: string;\n proficiency: number | null;\n }) => Promise<void>;\n detachCandidateSkill: (candidateId: string, skillId: string) => Promise<void>;\n\n // BOFF-3983 — onboarding\n fetchOnboardings: () => Promise<void>;\n createOnboarding: (input: {\n candidateId?: string;\n employeeId?: string;\n fullName: string;\n position: string;\n department?: string;\n startDate?: string;\n }) => Promise<void>;\n updateOnboarding: (id: string, updates: Partial<CrewOnboarding>) => Promise<void>;\n removeOnboarding: (id: string) => Promise<void>;\n createOnboardingTask: (input: {\n onboardingId: string;\n stage: OnboardingStage;\n title: string;\n assigneeActorId?: string;\n assigneeName?: string;\n dueDate?: string;\n sortOrder?: number;\n }) => Promise<void>;\n updateOnboardingTask: (id: string, updates: Partial<CrewOnboardingTask>) => Promise<void>;\n removeOnboardingTask: (id: string) => Promise<void>;\n toggleOnboardingTask: (id: string, completed: boolean) => Promise<void>;\n\n fetchSkillsGap: () => Promise<void>;\n fetchExecutiveDashboard: () => Promise<void>;\n\n // BOFF-3401 — Learning & Development\n fetchLearning: () => Promise<void>;\n createTrainingCourse: (input: CrewTrainingCourseInput) => Promise<CrewTrainingCourse>;\n updateTrainingCourse: (id: string, input: Partial<CrewTrainingCourseInput>) => Promise<void>;\n removeTrainingCourse: (id: string) => Promise<void>;\n enrollEmployee: (\n courseId: string,\n employee: Pick<Employee, 'id' | 'firstName' | 'lastName'>\n ) => Promise<void>;\n updateEnrollmentStatus: (id: string, status: CrewEnrollmentStatus) => Promise<void>;\n removeEnrollment: (id: string) => Promise<void>;\n\n // BOFF-3401 — talent marketplace\n fetchMarketplace: () => Promise<void>;\n createServiceListing: (input: CrewServiceListingInput) => Promise<CrewServiceListing>;\n updateServiceListing: (\n id: string,\n input: Partial<Omit<CrewServiceListingInput, 'providerName'>> & {\n status?: CrewServiceListingStatus;\n }\n ) => Promise<void>;\n removeServiceListing: (id: string) => Promise<void>;\n bookServiceListing: (input: CrewBookingInput) => Promise<CrewBooking>;\n updateBookingStatus: (id: string, status: CrewBookingStatus) => Promise<void>;\n fetchEscrowRecords: () => Promise<void>;\n releaseEscrowRecord: (id: string) => Promise<void>;\n cancelEscrowRecord: (id: string) => Promise<void>;\n}\n\nexport const useCrewFoundryStore = create<CrewFoundryState>((set) => ({\n // Overview\n metrics: [\n { label: 'Total Employees', value: '247', trend: '+5.2%' },\n { label: 'Open Positions', value: '24', trend: '+3 this week' },\n { label: 'Hiring Pipeline', value: '347', trend: '+52 applications' },\n { label: 'Employee Satisfaction', value: '4.6/5', trend: '+0.2' },\n ],\n workItems: [\n {\n id: 'w1',\n title: 'Q1 Performance Review Cycle',\n status: 'active',\n owner: 'HR',\n updatedAt: '2h ago',\n },\n {\n id: 'w2',\n title: 'New Health Benefits Enrollment',\n status: 'active',\n owner: 'Benefits',\n updatedAt: '5h ago',\n },\n {\n id: 'w3',\n title: 'Engineering Headcount Planning',\n status: 'at_risk',\n owner: 'Recruiting',\n updatedAt: '1d ago',\n },\n {\n id: 'w4',\n title: 'Employee Onboarding Automation',\n status: 'completed',\n owner: 'HR Ops',\n updatedAt: '2d ago',\n },\n ],\n selectedView: 'overview',\n initialized: false,\n loading: false,\n error: null,\n initParams: {},\n\n // Domain data\n employees: [],\n departments: [],\n jobPostings: [],\n candidates: [],\n interviews: [],\n announcements: [],\n teams: [],\n projects: [],\n payrollRecords: [],\n leaveRequests: [],\n timeEntries: [],\n notifications: [],\n vendors: [],\n clients: [],\n employeeDocuments: [],\n employeeSkillProfiles: {},\n skillsTaxonomy: [],\n skillsTaxonomyLoaded: false,\n skillCategories: [],\n candidateSkillProfiles: {},\n onboardings: [],\n onboardingsLoaded: false,\n jobPostingMatches: {},\n jobPostingMatchesLoading: false,\n payrollRuns: [],\n payrollRunsLoaded: false,\n payrollRunsLoading: false,\n payslipsByRun: {},\n payslipsLoading: false,\n skillsGap: [],\n skillsGapLoaded: false,\n executiveDashboard: null,\n executiveDashboardLoading: false,\n executiveDashboardError: null,\n trainingCourses: [],\n enrollments: [],\n trainingCompletion: [],\n learningLoaded: false,\n serviceListings: [],\n bookings: [],\n marketplaceLoaded: false,\n escrowRecords: [],\n escrowLoaded: false,\n escrowError: null,\n\n // Actions\n initializeData: async (params) => {\n if (!params.workspaceId) {\n return;\n }\n // BOFF-4208: the executive rollup belongs to one workspace; drop it when\n // the host switches workspace so the dashboard never shows another\n // workspace's figures while the new rollup loads.\n if (useCrewFoundryStore.getState().initParams.workspaceId !== params.workspaceId) {\n set({ executiveDashboard: null, executiveDashboardError: null });\n }\n set({ loading: true, error: null, initParams: params });\n try {\n const [workspaceWithOverlapData, payrollData] = await Promise.all([\n runOverlap<WorkspaceBootstrapWithOverlapResponse>(\n WORKSPACE_BOOTSTRAP_WITH_OVERLAP_QUERY,\n {\n workspaceId: params.workspaceId,\n projectPagination: { limit: 50, offset: 0 },\n groupFirst: 30,\n conversationFirst: 30,\n },\n params,\n 'Unable to load workspace bootstrap with overlap data'\n ),\n // Payroll (BOFF-4887): fetched via runOverlap (best-effort), not\n // runGraphql, because crewPayrollRecords is gated by the dedicated\n // crewfoundry-payroll RBAC resource — a caller without that grant\n // (e.g. Workforce Coordinator) gets a FORBIDDEN response here, which\n // must degrade to an empty payroll list, not fail the whole\n // dashboard load.\n runOverlap<CrewPayrollRecordsResponse>(\n CREW_PAYROLL_RECORDS_QUERY,\n undefined,\n params,\n 'Unable to load payroll records'\n ),\n ]);\n\n const bootstrap = workspaceWithOverlapData\n ? workspaceWithOverlapData.crewfoundryBootstrap\n : (\n await runGraphql<BootstrapPayload>(\n BOOTSTRAP_QUERY,\n undefined,\n params,\n 'Unable to load CrewFoundry data'\n )\n ).crewfoundryBootstrap;\n\n const overlapTeams = workspaceWithOverlapData\n ? mapOverlapTeams(workspaceWithOverlapData.groups.edges)\n : [];\n const overlapProjects = workspaceWithOverlapData\n ? mapOverlapProjects(workspaceWithOverlapData.projects.items, overlapTeams)\n : [];\n const overlapNotifications = workspaceWithOverlapData\n ? mapConversationNotifications(workspaceWithOverlapData.conversations.edges)\n : [];\n\n const teams = overlapTeams.length > 0 ? overlapTeams : bootstrap.teams;\n const projects = overlapProjects.length > 0 ? overlapProjects : bootstrap.projects;\n const notifications = overlapNotifications;\n\n // Normalize enum casing (UPPER_SNAKE from the backend -> lower_snake) once, per entity, so\n // every downstream count/filter/badge and the metrics below all operate on the same casing.\n const nEmployees = bootstrap.employees.map((e) => lowerEnumKeys(e, ENUM_KEYS.employee));\n const nDepartments = bootstrap.departments.map((d) => lowerEnumKeys(d, ENUM_KEYS.department));\n const nJobPostings = bootstrap.jobPostings.map((j) => lowerEnumKeys(j, ENUM_KEYS.jobPosting));\n const nCandidates = bootstrap.candidates.map((c) => lowerEnumKeys(c, ENUM_KEYS.candidate));\n const nInterviews = bootstrap.interviews.map((i) => lowerEnumKeys(i, ENUM_KEYS.interview));\n const nAnnouncements = bootstrap.announcements.map((a) =>\n lowerEnumKeys(a, ENUM_KEYS.announcement)\n );\n const nTeams = teams.map((t) => lowerEnumKeys(t, ENUM_KEYS.team));\n const nProjects = projects.map((p) => lowerEnumKeys(p, ENUM_KEYS.project));\n // Payroll (BOFF-4887): sourced from its own dedicated, crewfoundry-payroll\n // gated query, not the bootstrap response — see CREW_PAYROLL_RECORDS_QUERY\n // above. `payrollData` is null when the query fails or the caller lacks\n // payroll access; either way that degrades to an empty list.\n const nPayrollRecords = (payrollData?.crewPayrollRecords ?? []).map((r) =>\n lowerEnumKeys(r, ENUM_KEYS.payrollRecord)\n );\n const nLeaveRequests = bootstrap.leaveRequests.map((r) =>\n lowerEnumKeys(r, ENUM_KEYS.leaveRequest)\n );\n const nTimeEntries = bootstrap.timeEntries.map((t) => lowerEnumKeys(t, ENUM_KEYS.timeEntry));\n const nNotifications = notifications.map((n) => lowerEnumKeys(n, ENUM_KEYS.notification));\n const nVendors = bootstrap.vendors.map((v) => lowerEnumKeys(v, ENUM_KEYS.vendor));\n const nClients = bootstrap.clients.map((c) => lowerEnumKeys(c, ENUM_KEYS.client));\n\n set({\n employees: nEmployees,\n departments: nDepartments,\n jobPostings: nJobPostings,\n candidates: nCandidates,\n interviews: nInterviews,\n announcements: nAnnouncements,\n teams: nTeams,\n projects: nProjects,\n payrollRecords: nPayrollRecords,\n leaveRequests: nLeaveRequests,\n timeEntries: nTimeEntries,\n notifications: nNotifications,\n vendors: nVendors,\n clients: nClients,\n metrics: [\n { label: 'Total Employees', value: String(nEmployees.length), trend: 'Live' },\n {\n label: 'Open Positions',\n value: String(nJobPostings.filter((j) => j.status === 'active').length),\n trend: 'Live',\n },\n { label: 'Hiring Pipeline', value: String(nCandidates.length), trend: 'Live' },\n {\n label: 'Cross-Team Projects',\n value: String(nProjects.filter((project) => project.status === 'active').length),\n trend: 'Live',\n },\n ],\n initialized: true,\n loading: false,\n });\n } catch (error) {\n set({\n error: error instanceof Error ? error.message : 'Unable to load CrewFoundry data',\n loading: false,\n });\n }\n },\n setSelectedView: (view) => set({ selectedView: view }),\n setWorkItems: (items) => set({ workItems: items }),\n addEmployee: async (employee) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewEmployee: Employee }>(\n CREATE_EMPLOYEE_MUTATION,\n {\n input: {\n ...employee,\n status: normalizeStatus(employee.status),\n type: normalizeStatus(employee.type),\n },\n },\n params,\n 'Unable to create employee'\n );\n set((state) => ({\n employees: [lowerEnumKeys(data.createCrewEmployee, ENUM_KEYS.employee), ...state.employees],\n }));\n },\n updateEmployee: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const payload = {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n };\n const data = await runGraphql<{ updateCrewEmployee: Employee }>(\n UPDATE_EMPLOYEE_MUTATION,\n { id, input: payload },\n params,\n 'Unable to update employee'\n );\n set((state) => ({\n employees: state.employees.map((e) =>\n e.id === id ? lowerEnumKeys(data.updateCrewEmployee, ENUM_KEYS.employee) : e\n ),\n }));\n },\n removeEmployee: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewEmployee: boolean }>(\n REMOVE_EMPLOYEE_MUTATION,\n { id },\n params,\n 'Unable to remove employee'\n );\n set((state) => ({ employees: state.employees.filter((e) => e.id !== id) }));\n },\n addJobPosting: async (job) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewJobPosting: JobPosting }>(\n CREATE_JOB_MUTATION,\n {\n input: {\n ...job,\n status: normalizeStatus(job.status),\n },\n },\n params,\n 'Unable to create job posting'\n );\n set((state) => ({\n jobPostings: [\n lowerEnumKeys(data.createCrewJobPosting, ENUM_KEYS.jobPosting),\n ...state.jobPostings,\n ],\n }));\n },\n updateJobPosting: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewJobPosting: JobPosting }>(\n UPDATE_JOB_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update job posting'\n );\n set((state) => ({\n jobPostings: state.jobPostings.map((j) =>\n j.id === id ? lowerEnumKeys(data.updateCrewJobPosting, ENUM_KEYS.jobPosting) : j\n ),\n }));\n },\n addCandidate: async (candidate) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewCandidate: Candidate }>(\n CREATE_CANDIDATE_MUTATION,\n { input: { ...candidate, status: normalizeStatus(candidate.status) } },\n params,\n 'Unable to create candidate'\n );\n set((state) => ({\n candidates: [\n lowerEnumKeys(data.createCrewCandidate, ENUM_KEYS.candidate),\n ...state.candidates,\n ],\n }));\n },\n updateCandidate: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewCandidate: Candidate }>(\n UPDATE_CANDIDATE_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update candidate'\n );\n set((state) => ({\n candidates: state.candidates.map((c) =>\n c.id === id ? lowerEnumKeys(data.updateCrewCandidate, ENUM_KEYS.candidate) : c\n ),\n }));\n },\n addAnnouncement: async (announcement) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewAnnouncement: Announcement }>(\n CREATE_ANNOUNCEMENT_MUTATION,\n { input: announcement },\n params,\n 'Unable to create announcement'\n );\n set((state) => ({\n announcements: [\n lowerEnumKeys(data.createCrewAnnouncement, ENUM_KEYS.announcement),\n ...state.announcements,\n ],\n }));\n },\n addLeaveRequest: async (request) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewLeaveRequest: LeaveRequest }>(\n CREATE_LEAVE_MUTATION,\n {\n input: {\n ...request,\n type: normalizeStatus(request.type),\n status: normalizeStatus(request.status),\n },\n },\n params,\n 'Unable to create leave request'\n );\n set((state) => ({\n leaveRequests: [\n lowerEnumKeys(data.createCrewLeaveRequest, ENUM_KEYS.leaveRequest),\n ...state.leaveRequests,\n ],\n }));\n },\n updateLeaveRequest: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewLeaveRequest: LeaveRequest }>(\n UPDATE_LEAVE_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update leave request'\n );\n set((state) => ({\n leaveRequests: state.leaveRequests.map((l) =>\n l.id === id ? lowerEnumKeys(data.updateCrewLeaveRequest, ENUM_KEYS.leaveRequest) : l\n ),\n }));\n },\n markNotificationRead: async (id) => {\n set((state) => ({\n notifications: state.notifications.map((n) => (n.id === id ? { ...n, read: true } : n)),\n }));\n },\n markAllNotificationsRead: async () => {\n set((state) => ({ notifications: state.notifications.map((n) => ({ ...n, read: true })) }));\n },\n\n // ── Extra removes for existing entities ───────────────────────\n removeJobPosting: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewJobPosting: boolean }>(\n REMOVE_JOB_MUTATION,\n { id },\n params,\n 'Unable to remove job posting'\n );\n set((state) => ({ jobPostings: state.jobPostings.filter((j) => j.id !== id) }));\n },\n removeCandidate: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewCandidate: boolean }>(\n REMOVE_CANDIDATE_MUTATION,\n { id },\n params,\n 'Unable to remove candidate'\n );\n set((state) => ({ candidates: state.candidates.filter((c) => c.id !== id) }));\n },\n updateAnnouncement: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewAnnouncement: Announcement }>(\n UPDATE_ANNOUNCEMENT_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update announcement'\n );\n set((state) => ({\n announcements: state.announcements.map((a) =>\n a.id === id ? lowerEnumKeys(data.updateCrewAnnouncement, ENUM_KEYS.announcement) : a\n ),\n }));\n },\n removeAnnouncement: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewAnnouncement: boolean }>(\n REMOVE_ANNOUNCEMENT_MUTATION,\n { id },\n params,\n 'Unable to remove announcement'\n );\n set((state) => ({ announcements: state.announcements.filter((a) => a.id !== id) }));\n },\n\n // ── Interview (enum: type, status) ────────────────────────────\n addInterview: async (interview) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewInterview: Interview }>(\n CREATE_INTERVIEW_MUTATION,\n {\n input: {\n ...interview,\n type: normalizeStatus(interview.type),\n status: normalizeStatus(interview.status),\n },\n },\n params,\n 'Unable to schedule interview'\n );\n set((state) => ({\n interviews: [\n lowerEnumKeys(data.createCrewInterview, ENUM_KEYS.interview),\n ...state.interviews,\n ],\n }));\n },\n updateInterview: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewInterview: Interview }>(\n UPDATE_INTERVIEW_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update interview'\n );\n set((state) => ({\n interviews: state.interviews.map((i) =>\n i.id === id ? lowerEnumKeys(data.updateCrewInterview, ENUM_KEYS.interview) : i\n ),\n }));\n },\n removeInterview: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewInterview: boolean }>(\n REMOVE_INTERVIEW_MUTATION,\n { id },\n params,\n 'Unable to remove interview'\n );\n set((state) => ({ interviews: state.interviews.filter((i) => i.id !== id) }));\n },\n\n // ── Vendor (enum: status) ─────────────────────────────────────\n addVendor: async (vendor) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewVendor: Vendor }>(\n CREATE_VENDOR_MUTATION,\n { input: { ...vendor, status: normalizeStatus(vendor.status) } },\n params,\n 'Unable to create vendor'\n );\n set((state) => ({\n vendors: [lowerEnumKeys(data.createCrewVendor, ENUM_KEYS.vendor), ...state.vendors],\n }));\n },\n updateVendor: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewVendor: Vendor }>(\n UPDATE_VENDOR_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update vendor'\n );\n set((state) => ({\n vendors: state.vendors.map((v) =>\n v.id === id ? lowerEnumKeys(data.updateCrewVendor, ENUM_KEYS.vendor) : v\n ),\n }));\n },\n removeVendor: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewVendor: boolean }>(\n REMOVE_VENDOR_MUTATION,\n { id },\n params,\n 'Unable to remove vendor'\n );\n set((state) => ({ vendors: state.vendors.filter((v) => v.id !== id) }));\n },\n\n // ── Client (enum: status; `since`) ────────────────────────────\n addClient: async (client) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewClient: Client }>(\n CREATE_CLIENT_MUTATION,\n { input: { ...client, status: normalizeStatus(client.status) } },\n params,\n 'Unable to create client'\n );\n set((state) => ({\n clients: [lowerEnumKeys(data.createCrewClient, ENUM_KEYS.client), ...state.clients],\n }));\n },\n updateClient: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewClient: Client }>(\n UPDATE_CLIENT_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update client'\n );\n set((state) => ({\n clients: state.clients.map((c) =>\n c.id === id ? lowerEnumKeys(data.updateCrewClient, ENUM_KEYS.client) : c\n ),\n }));\n },\n removeClient: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewClient: boolean }>(\n REMOVE_CLIENT_MUTATION,\n { id },\n params,\n 'Unable to remove client'\n );\n set((state) => ({ clients: state.clients.filter((c) => c.id !== id) }));\n },\n\n // ── Team (plain status; not normalized) ───────────────────────\n addTeam: async (team) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTeam: Team }>(\n CREATE_TEAM_MUTATION,\n { input: team },\n params,\n 'Unable to create team'\n );\n set((state) => ({\n teams: [lowerEnumKeys(data.createCrewTeam, ENUM_KEYS.team), ...state.teams],\n }));\n },\n updateTeam: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTeam: Team }>(\n UPDATE_TEAM_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update team'\n );\n set((state) => ({\n teams: state.teams.map((t) =>\n t.id === id ? lowerEnumKeys(data.updateCrewTeam, ENUM_KEYS.team) : t\n ),\n }));\n },\n removeTeam: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTeam: boolean }>(\n REMOVE_TEAM_MUTATION,\n { id },\n params,\n 'Unable to remove team'\n );\n set((state) => ({ teams: state.teams.filter((t) => t.id !== id) }));\n },\n\n // ── Project (enum: status, priority) ──────────────────────────\n addProject: async (project) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewProject: Project }>(\n CREATE_PROJECT_MUTATION,\n {\n input: {\n ...project,\n status: normalizeStatus(project.status),\n priority: normalizeStatus(project.priority),\n },\n },\n params,\n 'Unable to create project'\n );\n set((state) => ({\n projects: [lowerEnumKeys(data.createCrewProject, ENUM_KEYS.project), ...state.projects],\n }));\n },\n updateProject: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewProject: Project }>(\n UPDATE_PROJECT_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n ...(updates.priority ? { priority: normalizeStatus(updates.priority) } : {}),\n },\n },\n params,\n 'Unable to update project'\n );\n set((state) => ({\n projects: state.projects.map((p) =>\n p.id === id ? lowerEnumKeys(data.updateCrewProject, ENUM_KEYS.project) : p\n ),\n }));\n },\n removeProject: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewProject: boolean }>(\n REMOVE_PROJECT_MUTATION,\n { id },\n params,\n 'Unable to remove project'\n );\n set((state) => ({ projects: state.projects.filter((p) => p.id !== id) }));\n },\n\n // ── Department (plain status; not normalized) ─────────────────\n addDepartment: async (department) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewDepartment: Department }>(\n CREATE_DEPARTMENT_MUTATION,\n { input: department },\n params,\n 'Unable to create department'\n );\n set((state) => ({\n departments: [\n lowerEnumKeys(data.createCrewDepartment, ENUM_KEYS.department),\n ...state.departments,\n ],\n }));\n },\n updateDepartment: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewDepartment: Department }>(\n UPDATE_DEPARTMENT_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update department'\n );\n set((state) => ({\n departments: state.departments.map((d) =>\n d.id === id ? lowerEnumKeys(data.updateCrewDepartment, ENUM_KEYS.department) : d\n ),\n }));\n },\n removeDepartment: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewDepartment: boolean }>(\n REMOVE_DEPARTMENT_MUTATION,\n { id },\n params,\n 'Unable to remove department'\n );\n set((state) => ({ departments: state.departments.filter((d) => d.id !== id) }));\n },\n\n // ── PayrollRecord (enum: status) ──────────────────────────────\n addPayrollRecord: async (record) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewPayrollRecord: PayrollRecord }>(\n CREATE_PAYROLL_MUTATION,\n { input: { ...record, status: normalizeStatus(record.status) } },\n params,\n 'Unable to create payroll record'\n );\n set((state) => ({\n payrollRecords: [\n lowerEnumKeys(data.createCrewPayrollRecord, ENUM_KEYS.payrollRecord),\n ...state.payrollRecords,\n ],\n }));\n },\n updatePayrollRecord: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewPayrollRecord: PayrollRecord }>(\n UPDATE_PAYROLL_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update payroll record'\n );\n set((state) => ({\n payrollRecords: state.payrollRecords.map((p) =>\n p.id === id ? lowerEnumKeys(data.updateCrewPayrollRecord, ENUM_KEYS.payrollRecord) : p\n ),\n }));\n },\n removePayrollRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewPayrollRecord: boolean }>(\n REMOVE_PAYROLL_MUTATION,\n { id },\n params,\n 'Unable to remove payroll record'\n );\n set((state) => ({ payrollRecords: state.payrollRecords.filter((p) => p.id !== id) }));\n },\n\n // ── TimeEntry (plain status; not normalized) ──────────────────\n addTimeEntry: async (entry) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTimeEntry: TimeEntry }>(\n CREATE_TIME_ENTRY_MUTATION,\n { input: entry },\n params,\n 'Unable to create time entry'\n );\n set((state) => ({\n timeEntries: [\n lowerEnumKeys(data.createCrewTimeEntry, ENUM_KEYS.timeEntry),\n ...state.timeEntries,\n ],\n }));\n },\n updateTimeEntry: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTimeEntry: TimeEntry }>(\n UPDATE_TIME_ENTRY_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update time entry'\n );\n set((state) => ({\n timeEntries: state.timeEntries.map((t) =>\n t.id === id ? lowerEnumKeys(data.updateCrewTimeEntry, ENUM_KEYS.timeEntry) : t\n ),\n }));\n },\n removeTimeEntry: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTimeEntry: boolean }>(\n REMOVE_TIME_ENTRY_MUTATION,\n { id },\n params,\n 'Unable to remove time entry'\n );\n set((state) => ({ timeEntries: state.timeEntries.filter((t) => t.id !== id) }));\n },\n\n // ── BOFF-4195: AI-assisted candidate/worker matching ────────────\n fetchJobPostingMatches: async (jobPostingId) => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ jobPostingMatchesLoading: true });\n try {\n const data = await runGraphql<{ crewJobPostingMatches: CrewCandidateMatch[] }>(\n JOB_POSTING_MATCHES_QUERY,\n { jobPostingId },\n params,\n 'Unable to load candidate matches'\n );\n const normalized = data.crewJobPostingMatches.map((match) => ({\n ...match,\n candidate: lowerEnumKeys(match.candidate, ENUM_KEYS.candidate),\n }));\n set((state) => ({\n jobPostingMatches: { ...state.jobPostingMatches, [jobPostingId]: normalized },\n jobPostingMatchesLoading: false,\n }));\n } catch (err) {\n set({ jobPostingMatchesLoading: false });\n throw err;\n }\n },\n\n // ── BOFF-4193: native payroll calculation engine ────────────────\n fetchPayrollRuns: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ payrollRunsLoading: true });\n try {\n const data = await runGraphql<{ crewPayrollRuns: CrewPayrollRun[] }>(\n CREW_PAYROLL_RUNS_QUERY,\n undefined,\n params,\n 'Unable to load payroll runs'\n );\n set({\n payrollRuns: data.crewPayrollRuns,\n payrollRunsLoaded: true,\n payrollRunsLoading: false,\n });\n } catch (err) {\n set({ payrollRunsLoading: false });\n throw err;\n }\n },\n createPayrollRun: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewPayrollRun: CrewPayrollRun }>(\n CREATE_PAYROLL_RUN_MUTATION,\n { input },\n params,\n 'Unable to create payroll run'\n );\n set((state) => ({ payrollRuns: [data.createCrewPayrollRun, ...state.payrollRuns] }));\n },\n calculatePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ calculateCrewPayrollRun: CrewPayrollRun }>(\n CALCULATE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to calculate payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.map((r) => (r.id === id ? data.calculateCrewPayrollRun : r)),\n // Recalculating replaces the run's payslips server-side — drop any\n // previously cached payslip view for this run so the next open\n // refetches the fresh set instead of showing stale figures.\n payslipsByRun: Object.fromEntries(\n Object.entries(state.payslipsByRun).filter(([runId]) => runId !== id)\n ),\n }));\n },\n approvePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ approveCrewPayrollRun: CrewPayrollRun }>(\n APPROVE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to approve payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.map((r) => (r.id === id ? data.approveCrewPayrollRun : r)),\n }));\n },\n removePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewPayrollRun: boolean }>(\n REMOVE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to remove payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.filter((r) => r.id !== id),\n payslipsByRun: Object.fromEntries(\n Object.entries(state.payslipsByRun).filter(([runId]) => runId !== id)\n ),\n }));\n },\n fetchPayslipsForRun: async (payrollRunId) => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ payslipsLoading: true });\n try {\n const data = await runGraphql<{ crewPayslips: CrewPayslip[] }>(\n CREW_PAYSLIPS_QUERY,\n { filter: { payrollRunId } },\n params,\n 'Unable to load payslips'\n );\n set((state) => ({\n payslipsByRun: { ...state.payslipsByRun, [payrollRunId]: data.crewPayslips },\n payslipsLoading: false,\n }));\n } catch (err) {\n set({ payslipsLoading: false });\n throw err;\n }\n },\n\n // ── BOFF-3987: employee documents ──────────────────────────────\n fetchEmployeeDocuments: async (employeeId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ employeeDocuments: CrewEmployeeDocument[] }>(\n EMPLOYEE_DOCUMENTS_QUERY,\n { employeeId },\n params,\n 'Unable to load employee documents'\n );\n set((state) => ({\n // Replace only this employee's documents; leave any other employee's\n // already-fetched documents in the flat cache untouched.\n employeeDocuments: [\n ...state.employeeDocuments.filter((d) => d.employeeId !== employeeId),\n ...data.employeeDocuments,\n ],\n }));\n },\n uploadEmployeeDocument: async ({ employeeId, file, title, category }) => {\n const params = useCrewFoundryStore.getState().initParams;\n\n const folder = await runGraphql<{ ensureFolderByPath: { id: string } }>(\n ENSURE_FOLDER_BY_PATH_MUTATION,\n { path: '/CrewFoundry/Employee Documents' },\n params,\n 'Unable to resolve the employee documents folder'\n );\n\n const extension = file.name.includes('.')\n ? file.name.substring(file.name.lastIndexOf('.') + 1)\n : '';\n const initiated = await runGraphql<{\n initiateUpload: { session: { id: string }; uploadUrl: string | null };\n }>(\n INITIATE_UPLOAD_MUTATION,\n {\n input: {\n fileName: file.name,\n fileSize: String(file.size),\n mimeType: file.type || 'application/octet-stream',\n extension,\n folderId: folder.ensureFolderByPath.id,\n },\n },\n params,\n 'Unable to start the document upload'\n );\n\n if (initiated.initiateUpload.uploadUrl) {\n const putResponse = await fetch(initiated.initiateUpload.uploadUrl, {\n method: 'PUT',\n headers: { 'Content-Type': file.type || 'application/octet-stream' },\n body: file,\n });\n if (!putResponse.ok) {\n throw new Error(`Failed to upload file bytes (status ${putResponse.status})`);\n }\n }\n\n const completed = await runGraphql<{ completeUpload: { file: { id: string } } }>(\n COMPLETE_UPLOAD_MUTATION,\n {\n input: {\n sessionId: initiated.initiateUpload.session.id,\n fileSize: String(file.size),\n folderId: folder.ensureFolderByPath.id,\n },\n },\n params,\n 'Unable to finish the document upload'\n );\n\n const attached = await runGraphql<{ attachEmployeeDocument: CrewEmployeeDocument }>(\n ATTACH_EMPLOYEE_DOCUMENT_MUTATION,\n {\n input: {\n employeeId,\n fileId: completed.completeUpload.file.id,\n title,\n category: category || undefined,\n },\n },\n params,\n 'Unable to attach the document to this employee'\n );\n\n set((state) => ({\n employeeDocuments: [attached.attachEmployeeDocument, ...state.employeeDocuments],\n }));\n },\n detachEmployeeDocument: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachEmployeeDocument: boolean }>(\n DETACH_EMPLOYEE_DOCUMENT_MUTATION,\n { id },\n params,\n 'Unable to remove this document'\n );\n set((state) => ({\n employeeDocuments: state.employeeDocuments.filter((d) => d.id !== id),\n }));\n },\n\n // ── BOFF-3717: canonical skills ─────────────────────────────────\n fetchEmployeeSkillProfile: async (employeeId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{\n crewEmployee: { id: string; skills: string[]; skillProfile: CrewEmployeeSkill[] } | null;\n }>(EMPLOYEE_SKILL_PROFILE_QUERY, { id: employeeId }, params, 'Unable to load skills');\n const record = data.crewEmployee;\n set((state) => ({\n employeeSkillProfiles: {\n ...state.employeeSkillProfiles,\n [employeeId]: record?.skillProfile ?? [],\n },\n employees: record\n ? state.employees.map((employee) =>\n employee.id === employeeId ? { ...employee, skills: record.skills } : employee\n )\n : state.employees,\n }));\n },\n attachEmployeeSkill: async ({ employeeId, skillName, proficiency }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ attachCrewSkill: { id: string } }>(\n ATTACH_CREW_SKILL_MUTATION,\n { input: { employeeId, skillName, proficiency } },\n params,\n 'Unable to add this skill'\n );\n await useCrewFoundryStore.getState().fetchEmployeeSkillProfile(employeeId);\n },\n detachEmployeeSkill: async (employeeId, skillId) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachCrewSkill: boolean }>(\n DETACH_CREW_SKILL_MUTATION,\n { employeeId, skillId },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchEmployeeSkillProfile(employeeId);\n },\n\n // ── BOFF-10361: skills taxonomy administration ──────────────────\n fetchSkillsTaxonomy: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const loadPages = async () => {\n const all: CrewTaxonomySkill[] = [];\n for (let page = 0; page < TAXONOMY_MAX_PAGES; page += 1) {\n const data = await runGraphql<{ crewSkills: CrewTaxonomySkill[] }>(\n CREW_SKILLS_TAXONOMY_QUERY,\n { pagination: { limit: TAXONOMY_PAGE_SIZE, offset: page * TAXONOMY_PAGE_SIZE } },\n params,\n 'Unable to load the skills taxonomy'\n );\n all.push(...data.crewSkills);\n if (data.crewSkills.length < TAXONOMY_PAGE_SIZE) break;\n }\n return all;\n };\n const [skills, categories] = await Promise.all([\n loadPages(),\n runGraphql<{ crewSkillCategories: string[] }>(\n CREW_SKILL_CATEGORIES_QUERY,\n undefined,\n params,\n 'Unable to load skill categories'\n ),\n ]);\n set({\n skillsTaxonomy: skills,\n skillsTaxonomyLoaded: true,\n skillCategories: categories.crewSkillCategories,\n });\n },\n createTaxonomySkill: async ({ name, category, aliases, description }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ createCrewSkill: { id: string } }>(\n CREATE_CREW_SKILL_MUTATION,\n { input: { name, category, aliases, ...(description ? { description } : {}) } },\n params,\n 'Unable to create this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n updateTaxonomySkill: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ updateCrewSkill: { id: string } }>(\n UPDATE_CREW_SKILL_MUTATION,\n { id, input },\n params,\n 'Unable to update this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n mergeTaxonomySkills: async (sourceId, targetId): Promise<CrewSkillMergeOutcome> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: { mergeCrewSkills: MergeCrewSkillsPayload } = await runGraphql<{\n mergeCrewSkills: MergeCrewSkillsPayload;\n }>(MERGE_CREW_SKILLS_MUTATION, { sourceId, targetId }, params, 'Unable to merge these skills');\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n const result = data.mergeCrewSkills;\n return {\n targetName: result.target.name,\n employeesMoved: result.employeesMoved,\n candidatesMoved: result.candidatesMoved,\n jobPostingsMoved: result.jobPostingsMoved,\n };\n },\n removeTaxonomySkill: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewSkill: boolean }>(\n REMOVE_CREW_SKILL_MUTATION,\n { id },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n createSkillRelation: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ createCrewSkillRelation: { id: string } }>(\n CREATE_CREW_SKILL_RELATION_MUTATION,\n { input },\n params,\n 'Unable to add this relation'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n removeSkillRelation: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewSkillRelation: boolean }>(\n REMOVE_CREW_SKILL_RELATION_MUTATION,\n { id },\n params,\n 'Unable to remove this relation'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n fetchEmployeesBySkill: async (skillId, options): Promise<CrewSkillHolderMatch[]> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: { crewEmployeesBySkill: CrewSkillHolderMatch[] } = await runGraphql<{\n crewEmployeesBySkill: CrewSkillHolderMatch[];\n }>(\n CREW_EMPLOYEES_BY_SKILL_QUERY,\n {\n skillId,\n minProficiency: options?.minProficiency ?? null,\n limit: options?.limit ?? 50,\n },\n params,\n 'Unable to find people with this skill'\n );\n return data.crewEmployeesBySkill;\n },\n fetchJobPostingSkillRequirements: async (\n jobPostingId\n ): Promise<CrewJobPostingSkillRequirement[]> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: {\n crewJobPosting: { id: string; skillRequirements: CrewJobPostingSkillRequirement[] } | null;\n } = await runGraphql<{\n crewJobPosting: { id: string; skillRequirements: CrewJobPostingSkillRequirement[] } | null;\n }>(\n JOB_POSTING_SKILL_REQUIREMENTS_QUERY,\n { id: jobPostingId },\n params,\n 'Unable to load the skills this role needs'\n );\n return data.crewJobPosting?.skillRequirements ?? [];\n },\n fetchCandidateSkillProfile: async (candidateId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{\n crewCandidate: { id: string; skills: string[]; skillProfile: CrewCandidateSkill[] } | null;\n }>(CANDIDATE_SKILL_PROFILE_QUERY, { id: candidateId }, params, 'Unable to load skills');\n const record = data.crewCandidate;\n set((state) => ({\n candidateSkillProfiles: {\n ...state.candidateSkillProfiles,\n [candidateId]: record?.skillProfile ?? [],\n },\n candidates: record\n ? state.candidates.map((candidate) =>\n candidate.id === candidateId ? { ...candidate, skills: record.skills } : candidate\n )\n : state.candidates,\n }));\n },\n attachCandidateSkill: async ({ candidateId, skillName, proficiency }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ attachCrewCandidateSkill: { id: string } }>(\n ATTACH_CANDIDATE_SKILL_MUTATION,\n { input: { candidateId, skillName, proficiency } },\n params,\n 'Unable to add this skill'\n );\n await useCrewFoundryStore.getState().fetchCandidateSkillProfile(candidateId);\n },\n detachCandidateSkill: async (candidateId, skillId) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachCrewCandidateSkill: boolean }>(\n DETACH_CANDIDATE_SKILL_MUTATION,\n { candidateId, skillId },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchCandidateSkillProfile(candidateId);\n },\n\n // ── BOFF-3983: onboarding ───────────────────────────────────────\n fetchOnboardings: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ crewOnboardings: CrewOnboarding[] }>(\n ONBOARDINGS_QUERY,\n {},\n params,\n 'Unable to load onboarding'\n );\n set({\n onboardings: data.crewOnboardings.map(lowerOnboarding),\n onboardingsLoaded: true,\n });\n },\n createOnboarding: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewOnboarding: CrewOnboarding }>(\n CREATE_ONBOARDING_MUTATION,\n { input },\n params,\n 'Unable to start onboarding'\n );\n set((state) => ({\n onboardings: [lowerOnboarding(data.createCrewOnboarding), ...state.onboardings],\n }));\n },\n updateOnboarding: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewOnboarding: CrewOnboarding }>(\n UPDATE_ONBOARDING_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update onboarding'\n );\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === id ? lowerOnboarding(data.updateCrewOnboarding) : o\n ),\n }));\n },\n removeOnboarding: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewOnboarding: boolean }>(\n REMOVE_ONBOARDING_MUTATION,\n { id },\n params,\n 'Unable to remove onboarding'\n );\n set((state) => ({ onboardings: state.onboardings.filter((o) => o.id !== id) }));\n },\n createOnboardingTask: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewOnboardingTask: CrewOnboardingTask }>(\n CREATE_ONBOARDING_TASK_MUTATION,\n { input },\n params,\n 'Unable to create onboarding task'\n );\n const task = lowerEnumKeys(data.createCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === task.onboardingId\n ? {\n ...o,\n tasks: [...o.tasks, task],\n totalTaskCount: o.totalTaskCount + 1,\n }\n : o\n ),\n }));\n },\n updateOnboardingTask: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewOnboardingTask: CrewOnboardingTask }>(\n UPDATE_ONBOARDING_TASK_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update onboarding task'\n );\n const task = lowerEnumKeys(data.updateCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === task.onboardingId\n ? { ...o, tasks: o.tasks.map((t) => (t.id === id ? task : t)) }\n : o\n ),\n }));\n },\n removeOnboardingTask: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewOnboardingTask: boolean }>(\n REMOVE_ONBOARDING_TASK_MUTATION,\n { id },\n params,\n 'Unable to remove onboarding task'\n );\n set((state) => ({\n onboardings: state.onboardings.map((o) => {\n if (!o.tasks.some((t) => t.id === id)) return o;\n return {\n ...o,\n tasks: o.tasks.filter((t) => t.id !== id),\n totalTaskCount: Math.max(0, o.totalTaskCount - 1),\n };\n }),\n }));\n },\n toggleOnboardingTask: async (id, completed) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ toggleCrewOnboardingTask: CrewOnboardingTask }>(\n TOGGLE_ONBOARDING_TASK_MUTATION,\n { id, completed },\n params,\n 'Unable to update onboarding task'\n );\n const task = lowerEnumKeys(data.toggleCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) => {\n if (o.id !== task.onboardingId) return o;\n const tasks = o.tasks.map((t) => (t.id === id ? task : t));\n const completedTaskCount = tasks.filter((t) => t.completedAt).length;\n return {\n ...o,\n tasks,\n completedTaskCount,\n progressPercent:\n tasks.length === 0 ? 0 : Math.round((completedTaskCount / tasks.length) * 1000) / 10,\n };\n }),\n }));\n },\n\n // ── Skills supply/demand ────────────────────────────────────────\n fetchSkillsGap: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ crewSkillsGap: CrewSkillsGapRow[] }>(\n SKILLS_GAP_QUERY,\n undefined,\n params,\n 'Unable to load skills coverage'\n );\n // No enum normalization: every field is a plain string/number, and `skill`\n // is a free-text tag whose casing must be preserved as recorded.\n set({ skillsGap: data.crewSkillsGap, skillsGapLoaded: true });\n },\n\n // ── BOFF-4208 — executive analytics rollup ─────────────────────\n fetchExecutiveDashboard: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n // A response for a workspace the host has since left must not land.\n const isStale = () =>\n useCrewFoundryStore.getState().initParams.workspaceId !== params.workspaceId;\n set({ executiveDashboardLoading: true, executiveDashboardError: null });\n try {\n const data = await runGraphql<{ crewExecutiveDashboard: CrewExecutiveDashboard }>(\n EXECUTIVE_DASHBOARD_QUERY,\n undefined,\n params,\n 'Unable to load workforce analytics'\n );\n if (isStale()) return;\n set({ executiveDashboard: data.crewExecutiveDashboard, executiveDashboardLoading: false });\n } catch (err) {\n if (isStale()) return;\n // Recorded rather than rethrown: the dashboard renders the message with\n // a retry, and there is no other caller to propagate to.\n set({\n executiveDashboardLoading: false,\n executiveDashboardError:\n err instanceof Error ? err.message : 'Unable to load workforce analytics',\n });\n }\n },\n\n // ── BOFF-3401 — Learning & Development ────────────────────────\n fetchLearning: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const firstPage = { limit: LIST_PAGE_SIZE, offset: 0 };\n for (let attempt = 1; attempt <= WRITE_RACE_RETRIES; attempt += 1) {\n const writesAtStart = sliceWrites.learning;\n const data = await runGraphql<{\n crewTrainingCourses: CrewTrainingCourse[];\n crewEnrollments: CrewEnrollment[];\n crewTrainingCompletionDashboard: CrewTrainingCourseCompletion[];\n }>(\n LEARNING_QUERY,\n { coursePage: firstPage, enrollmentPage: firstPage },\n params,\n 'Unable to load learning'\n );\n const [courses, enrollments] = await Promise.all([\n fetchAllPages<CrewTrainingCourse>(\n TRAINING_COURSES_PAGE_QUERY,\n 'crewTrainingCourses',\n params,\n 'Unable to load courses',\n data.crewTrainingCourses\n ),\n fetchAllPages<CrewEnrollment>(\n ENROLLMENTS_PAGE_QUERY,\n 'crewEnrollments',\n params,\n 'Unable to load enrollments',\n data.crewEnrollments\n ),\n ]);\n if (writesAtStart !== sliceWrites.learning && attempt < WRITE_RACE_RETRIES) {\n continue;\n }\n set({\n trainingCourses: courses,\n enrollments: enrollments.map(lowerEnrollment),\n trainingCompletion: data.crewTrainingCompletionDashboard,\n learningLoaded: true,\n });\n return;\n }\n },\n createTrainingCourse: async (input): Promise<CrewTrainingCourse> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTrainingCourse: CrewTrainingCourse }>(\n CREATE_TRAINING_COURSE_MUTATION,\n { input },\n params,\n 'Unable to create course'\n );\n const course = data.createCrewTrainingCourse;\n sliceWrites.learning += 1;\n set((state) => ({ trainingCourses: [course, ...state.trainingCourses] }));\n return course;\n },\n updateTrainingCourse: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTrainingCourse: CrewTrainingCourse }>(\n UPDATE_TRAINING_COURSE_MUTATION,\n { id, input },\n params,\n 'Unable to update course'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n trainingCourses: replaceById(state.trainingCourses, data.updateCrewTrainingCourse),\n }));\n },\n removeTrainingCourse: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTrainingCourse: boolean }>(\n REMOVE_TRAINING_COURSE_MUTATION,\n { id },\n params,\n 'Unable to remove course'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n trainingCourses: state.trainingCourses.filter((course) => course.id !== id),\n trainingCompletion: state.trainingCompletion.filter((row) => row.courseId !== id),\n }));\n },\n enrollEmployee: async (courseId, employee) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewEnrollment: CrewEnrollment }>(\n CREATE_ENROLLMENT_MUTATION,\n {\n input: {\n courseId,\n employeeId: employee.id,\n employeeName: `${employee.firstName} ${employee.lastName}`.trim(),\n },\n },\n params,\n 'Unable to enroll employee'\n );\n // The service is idempotent on (course, employee): an existing enrollment\n // comes back unchanged, so upsert instead of blindly prepending.\n const enrollment = lowerEnrollment(data.createCrewEnrollment);\n sliceWrites.learning += 1;\n set((state) => ({\n enrollments: state.enrollments.some((row) => row.id === enrollment.id)\n ? replaceById(state.enrollments, enrollment)\n : [enrollment, ...state.enrollments],\n }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n updateEnrollmentStatus: async (id, status) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewEnrollmentStatus: CrewEnrollment }>(\n UPDATE_ENROLLMENT_STATUS_MUTATION,\n { id, status: normalizeStatus(status) },\n params,\n 'Unable to update enrollment'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n enrollments: replaceById(state.enrollments, lowerEnrollment(data.updateCrewEnrollmentStatus)),\n }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n removeEnrollment: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewEnrollment: boolean }>(\n REMOVE_ENROLLMENT_MUTATION,\n { id },\n params,\n 'Unable to remove enrollment'\n );\n sliceWrites.learning += 1;\n set((state) => ({ enrollments: state.enrollments.filter((row) => row.id !== id) }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n\n // ── BOFF-3401 — talent marketplace ────────────────────────────\n fetchMarketplace: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n for (let attempt = 1; attempt <= WRITE_RACE_RETRIES; attempt += 1) {\n const writesAtStart = sliceWrites.marketplace;\n const [listings, bookings] = await Promise.all([\n fetchAllPages<CrewServiceListing>(\n SERVICE_LISTINGS_PAGE_QUERY,\n 'crewServiceListings',\n params,\n 'Unable to load marketplace services'\n ),\n fetchAllPages<CrewBooking>(\n BOOKINGS_PAGE_QUERY,\n 'crewBookings',\n params,\n 'Unable to load bookings'\n ),\n ]);\n if (writesAtStart !== sliceWrites.marketplace && attempt < WRITE_RACE_RETRIES) {\n continue;\n }\n set({\n serviceListings: listings.map(lowerListing),\n bookings: bookings.map(lowerBooking),\n marketplaceLoaded: true,\n });\n return;\n }\n },\n createServiceListing: async (input): Promise<CrewServiceListing> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewServiceListing: CrewServiceListing }>(\n CREATE_SERVICE_LISTING_MUTATION,\n { input },\n params,\n 'Unable to publish service'\n );\n const listing = lowerListing(data.createCrewServiceListing);\n sliceWrites.marketplace += 1;\n set((state) => ({ serviceListings: [listing, ...state.serviceListings] }));\n return listing;\n },\n updateServiceListing: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateMyServiceListing: CrewServiceListing }>(\n UPDATE_SERVICE_LISTING_MUTATION,\n { id, input: input.status ? { ...input, status: normalizeStatus(input.status) } : input },\n params,\n 'Unable to update service'\n );\n sliceWrites.marketplace += 1;\n set((state) => ({\n serviceListings: replaceById(\n state.serviceListings,\n lowerListing(data.updateMyServiceListing)\n ),\n }));\n },\n removeServiceListing: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeMyServiceListing: boolean }>(\n REMOVE_SERVICE_LISTING_MUTATION,\n { id },\n params,\n 'Unable to remove service'\n );\n sliceWrites.marketplace += 1;\n set((state) => ({ serviceListings: state.serviceListings.filter((row) => row.id !== id) }));\n },\n bookServiceListing: async (input): Promise<CrewBooking> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewBooking: CrewBooking }>(\n CREATE_BOOKING_MUTATION,\n { input },\n params,\n 'Unable to book service'\n );\n const booking = lowerBooking(data.createCrewBooking);\n // A booking opens a linked escrow ledger row server-side; drop the cached\n // escrow list so the Escrow page re-reads it.\n sliceWrites.marketplace += 1;\n set((state) => ({ bookings: [booking, ...state.bookings], escrowLoaded: false }));\n return booking;\n },\n updateBookingStatus: async (id, status) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateMyBookingStatus: CrewBooking }>(\n UPDATE_BOOKING_STATUS_MUTATION,\n { id, status: normalizeStatus(status) },\n params,\n 'Unable to update booking'\n );\n // Completing or cancelling a booking releases/cancels its escrow row.\n sliceWrites.marketplace += 1;\n set((state) => ({\n bookings: replaceById(state.bookings, lowerBooking(data.updateMyBookingStatus)),\n escrowLoaded: false,\n }));\n },\n fetchEscrowRecords: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n try {\n const rows = await fetchAllPages<CrewEscrowRecord>(\n ESCROW_RECORDS_PAGE_QUERY,\n 'crewEscrowRecords',\n params,\n 'Unable to load escrow records'\n );\n set({ escrowRecords: rows.map(lowerEscrow), escrowLoaded: true, escrowError: null });\n } catch (error) {\n set({\n escrowRecords: [],\n escrowLoaded: true,\n escrowError: error instanceof Error ? error.message : 'Unable to load escrow records',\n });\n }\n },\n releaseEscrowRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ releaseCrewEscrowRecord: CrewEscrowRecord }>(\n RELEASE_ESCROW_MUTATION,\n { id },\n params,\n 'Unable to release escrow'\n );\n set((state) => ({\n escrowRecords: replaceById(state.escrowRecords, lowerEscrow(data.releaseCrewEscrowRecord)),\n }));\n },\n cancelEscrowRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ cancelCrewEscrowRecord: CrewEscrowRecord }>(\n CANCEL_ESCROW_MUTATION,\n { id },\n params,\n 'Unable to cancel escrow'\n );\n set((state) => ({\n escrowRecords: replaceById(state.escrowRecords, lowerEscrow(data.cancelCrewEscrowRecord)),\n }));\n },\n}));\n"],"mappings":";;;AA0oBA,IAAM,IAAkB,6hDA2BlB,IAA6B,0KAU7B,IAAyC,65EAgEzC,IAA2B,gQAC3B,IAA2B,mRAC3B,IAA2B,yEAC3B,IAAsB,+PACtB,IAAsB,kRACtB,IAA4B,qPAC5B,IAA4B,wQAC5B,IAA+B,8MAC/B,IAAwB,oNACxB,IAAwB,uOAExB,IAAsB,6EACtB,IAA4B,2EAC5B,IAA+B,iOAC/B,IAA+B,iFAG/B,IAA4B,0MAC5B,IAA4B,6NAC5B,KAA4B,2EAG5B,KAAyB,4KACzB,KAAyB,+LACzB,KAAyB,qEAGzB,KAAyB,8KACzB,KAAyB,iMACzB,KAAyB,qEAGzB,KAAuB,gMACvB,KAAuB,mNACvB,KAAuB,iEAGvB,KAA0B,+OAC1B,KAA0B,kQAC1B,KAA0B,uEAG1B,KAA6B,8KAC7B,KAA6B,iMAC7B,KAA6B,6EAG7B,KAA0B,+NAC1B,KAA0B,kPAC1B,KAA0B,mFAO1B,IAAqB,8HACrB,KAA0B,6CAA6C,EAAmB,OAC1F,KAA8B,6GAA6G,EAAmB,OAC9J,KAAiC,mFAAmF,EAAmB,OACvI,KAA+B,+EAA+E,EAAmB,OACjI,KAA8B,6EAE9B,KAAsB,yfAGtB,KAA6B,2MAC7B,KAA6B,8NAC7B,KAA6B,2EAK7B,KAA4B,wbAS5B,IAAmB,sGAGnB,IAA4B,sgBAG5B,IAA2B,0JAC3B,KAAoC,qLACpC,KAAoC,iFAGpC,KAA+B,sLAC/B,KAA6B,qGAC7B,KAA6B,6HAI7B,IAAqB,KAErB,KAAqB,IACrB,KAA6B,gOAC7B,KAA8B,qDAC9B,KAA6B,qGAC7B,KAA6B,wHAC7B,KAA6B,iMAC7B,KAA6B,mEAC7B,KAAsC,6HACtC,KAAsC,mFACtC,KA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IACA,EAAE,OAAI,EACN,GACA,0BACD;AACD,KAAK,OAAW,EACd,eAAe,EAAY,EAAM,eAAe,EAAY,EAAK,uBAAuB,CAAC,EAC1F,EAAE;;CAEN,EAAE"}
1
+ {"version":3,"file":"crewfoundryStore.js","names":[],"sources":["../../../src/crewfoundry/store/crewfoundryStore.ts"],"sourcesContent":["import { create } from 'zustand';\nimport type { OverviewMetric, WorkItem } from '../types';\n\n// ── Domain Types ────────────────────────────────────────────────\nexport interface Employee {\n id: string;\n firstName: string;\n lastName: string;\n email: string;\n department: string;\n position: string;\n status: 'active' | 'inactive' | 'on_leave' | 'terminated';\n type: 'full_time' | 'part_time' | 'contract' | 'intern';\n salary: number;\n startDate: string;\n avatar?: string;\n location: string;\n managerId?: string;\n phone: string;\n performanceScore: number;\n /** Real per-employee skill tags (backend default `[]`). */\n skills: string[];\n /** Exit date for terminated employees; ISO string or null while employed. */\n terminationDate?: string | null;\n}\n\nexport interface Department {\n id: string;\n name: string;\n headId: string;\n headName: string;\n employeeCount: number;\n budget: number;\n location: string;\n status: 'active' | 'restructuring';\n}\n\nexport interface JobPosting {\n id: string;\n title: string;\n department: string;\n location: string;\n type: 'full_time' | 'part_time' | 'contract' | 'remote';\n experienceLevel: 'entry' | 'mid' | 'senior' | 'lead' | 'executive';\n salaryMin: number;\n salaryMax: number;\n status: 'draft' | 'active' | 'paused' | 'closed' | 'filled';\n applicants: number;\n postedDate: string;\n deadline: string | null;\n description: string;\n requirements: string[];\n benefits: string[];\n}\n\nexport interface Candidate {\n id: string;\n firstName: string;\n lastName: string;\n email: string;\n phone: string;\n position: string;\n status: 'new' | 'screening' | 'interview' | 'assessment' | 'offer' | 'hired' | 'rejected';\n appliedDate: string;\n resumeUrl?: string;\n rating: number;\n source: string;\n experience: number;\n skills: string[];\n currentCompany: string;\n notes: string;\n /** Date the candidate was hired; ISO string or null until hired. */\n hiredDate?: string | null;\n}\n\nexport interface Interview {\n id: string;\n candidateId: string;\n candidateName: string;\n position: string;\n interviewerName: string;\n date: string;\n time: string;\n type: 'phone' | 'video' | 'onsite' | 'panel' | 'technical';\n status: 'scheduled' | 'completed' | 'cancelled' | 'no_show';\n feedback?: string;\n rating?: number;\n}\n\nexport interface Announcement {\n id: string;\n title: string;\n content: string;\n author: string;\n authorRole: string;\n category: 'general' | 'hr' | 'it' | 'emergency' | 'event';\n priority: 'low' | 'medium' | 'high' | 'urgent';\n isPinned: boolean;\n createdAt: string;\n viewCount: number;\n tags: string[];\n}\n\nexport interface Team {\n id: string;\n name: string;\n description: string;\n leadId: string;\n leadName: string;\n members: string[];\n memberCount: number;\n department: string;\n status: 'active' | 'forming' | 'disbanded';\n projectCount: number;\n createdAt: string;\n}\n\nexport interface Project {\n id: string;\n name: string;\n description: string;\n status: 'planning' | 'active' | 'on_hold' | 'completed' | 'cancelled';\n priority: 'low' | 'medium' | 'high' | 'critical';\n startDate: string;\n endDate: string;\n progress: number;\n budget: number;\n spent: number;\n teamId: string;\n teamName: string;\n managerId: string;\n managerName: string;\n tasks: number;\n completedTasks: number;\n}\n\nexport interface PayrollRecord {\n id: string;\n employeeId: string;\n employeeName: string;\n department: string;\n period: string;\n grossPay: number;\n deductions: number;\n netPay: number;\n status: 'draft' | 'processing' | 'approved' | 'paid' | 'failed';\n payDate: string;\n paymentMethod: string;\n}\n\nexport interface LeaveRequest {\n id: string;\n employeeId: string;\n employeeName: string;\n department: string;\n type: 'annual' | 'sick' | 'personal' | 'maternity' | 'paternity' | 'unpaid';\n startDate: string;\n endDate: string;\n days: number;\n status: 'pending' | 'approved' | 'rejected' | 'cancelled';\n reason: string;\n approverName?: string;\n}\n\nexport interface TimeEntry {\n id: string;\n employeeId: string;\n employeeName: string;\n date: string;\n clockIn: string;\n clockOut: string;\n totalHours: number;\n overtime: number;\n project: string;\n status: 'pending' | 'approved' | 'rejected';\n /** Whether the logged time is billable to a client (backend default `true`). */\n billable: boolean;\n}\n\nexport interface Notification {\n id: string;\n title: string;\n message: string;\n type: 'info' | 'success' | 'warning' | 'error';\n category: string;\n read: boolean;\n createdAt: string;\n actionUrl?: string;\n}\n\nexport interface Vendor {\n id: string;\n name: string;\n category: string;\n contactPerson: string;\n email: string;\n phone: string;\n status: 'active' | 'inactive' | 'pending';\n contractValue: number;\n rating: number;\n}\n\nexport interface Client {\n id: string;\n name: string;\n industry: string;\n contactPerson: string;\n email: string;\n phone: string;\n status: 'active' | 'prospect' | 'churned';\n revenue: number;\n projects: number;\n since: string;\n}\n\n// BOFF-3987 — employee profile Documents tab. The binary + canonical file\n// metadata live in wspace-files-svc; this is just the (employee, file)\n// association crewfoundry owns.\nexport interface CrewEmployeeDocument {\n id: string;\n employeeId: string;\n fileId: string;\n title: string;\n category?: string | null;\n uploadedBy: string;\n uploadedAt: string;\n}\n\n// BOFF-3717 — canonical skills. An employee's skill profile is a list of\n// taxonomy skills with proficiency (0-100, null when not assessed) and\n// provenance, replacing the free-text `skills` tags.\nexport interface CrewSkillSummary {\n id: string;\n name: string;\n category: string;\n source: string;\n}\n\nexport interface CrewEmployeeSkill {\n id: string;\n skillId: string;\n proficiency: number | null;\n verifiedFrom: string;\n lastUsedAt: string | null;\n skill: CrewSkillSummary;\n}\n\n// BOFF-10361 — skills taxonomy administration and \"find people by skill\".\n/** A typed edge of the workspace skills graph (ids only; names come from the taxonomy). */\nexport interface CrewSkillRelationRef {\n id: string;\n /** IMPLIES, RELATED_TO or SUPERSEDES. */\n type: string;\n fromSkillId: string;\n toSkillId: string;\n}\n\n/** A skill in the workspace taxonomy, with holder counts and direct relations. */\nexport interface CrewTaxonomySkill {\n id: string;\n name: string;\n slug: string;\n category: string;\n /** TAXONOMY, CUSTOM or BACKFILL (unmatched legacy string awaiting triage). */\n source: string;\n description: string | null;\n aliases: string[];\n employeeCount: number;\n candidateCount: number;\n relations: CrewSkillRelationRef[];\n}\n\nexport interface CrewSkillUpdateInput {\n name?: string;\n category?: string;\n aliases?: string[];\n description?: string;\n}\n\nexport interface CrewSkillMergeOutcome {\n targetName: string;\n employeesMoved: number;\n candidatesMoved: number;\n jobPostingsMoved: number;\n}\n\n/** An employee who can do a skill, matched through aliases and IMPLIES / SUPERSEDES edges. */\nexport interface CrewSkillHolderMatch {\n employee: {\n id: string;\n firstName: string;\n lastName: string;\n position: string;\n department: string;\n };\n /** EXACT, SUPERSEDED or IMPLIED. */\n matchType: string;\n matchedSkill: { id: string; name: string };\n proficiency: number | null;\n verifiedFrom: string;\n explanation: string;\n}\n\n/** A canonical skill a job posting asks for. */\nexport interface CrewJobPostingSkillRequirement {\n id: string;\n skillId: string;\n required: boolean;\n minProficiency: number | null;\n skill: CrewSkillSummary;\n}\n\nexport interface CrewCandidateSkill {\n id: string;\n skillId: string;\n proficiency: number | null;\n /** RESUME, SELF_REPORTED, RECRUITER, ASSESSMENT or LEGACY. */\n source: string;\n skill: CrewSkillSummary;\n}\n\n// BOFF-3983 — requisition-to-hire onboarding tracker (mock cf-30).\nexport type OnboardingStage = 'offer' | 'paperwork' | 'it_setup' | 'training' | 'day_one';\nexport type OnboardingStatus = 'not_started' | 'in_progress' | 'completed' | 'cancelled';\n\nexport interface CrewOnboardingTask {\n id: string;\n onboardingId: string;\n stage: OnboardingStage;\n title: string;\n assigneeActorId?: string | null;\n assigneeName?: string | null;\n dueDate?: string | null;\n completedAt?: string | null;\n sortOrder: number;\n}\n\nexport interface CrewOnboarding {\n id: string;\n candidateId?: string | null;\n employeeId?: string | null;\n fullName: string;\n position: string;\n department?: string | null;\n startDate?: string | null;\n status: OnboardingStatus;\n currentStage: OnboardingStage;\n createdAt: string;\n tasks: CrewOnboardingTask[];\n totalTaskCount: number;\n completedTaskCount: number;\n progressPercent: number;\n}\n\n// BOFF-4195 — AI-assisted candidate/worker matching engine. Deterministic,\n// rule-based (skill overlap 70% + experience fit 30%) — the backend never\n// fabricates an AI summary; `rationale` is a plain-language breakdown of the\n// two sub-scores so the ranking is never a black box.\nexport interface CrewCandidateMatch {\n candidateId: string;\n jobPostingId: string;\n candidate: Candidate;\n score: number;\n skillScore: number;\n experienceScore: number;\n matchedSkills: string[];\n missingSkills: string[];\n rationale: string;\n}\n\n// Workspace skills supply/demand, computed server-side by\n// `Query.crewSkillsGap` (wspace-crewfoundry-svc analytics service):\n// employeesWithSkill — ACTIVE employees carrying that skill tag\n// openJobsRequiringSkill — open (ACTIVE or PAUSED) job postings listing it\n// shortage — max(0, demand − supply)\n// Rows arrive already sorted by shortage desc, then demand desc. Skills are\n// free-text tags matched case-insensitively; `skill` is the first-seen casing.\nexport interface CrewSkillsGapRow {\n skill: string;\n employeesWithSkill: number;\n openJobsRequiringSkill: number;\n shortage: number;\n}\n\n// BOFF-4208 — executive workforce analytics, computed server-side by\n// `Query.crewExecutiveDashboard`. Every figure is a deterministic rollup of\n// the workspace's own rows (employees, job postings, approved leave); the\n// attrition bands are heuristic signals, not a trained prediction:\n// riskScore — 0..1 sum of driver weights (low performance 0.30, tenure\n// under 6 months 0.20 / under 12 months 0.10, contract or\n// intern 0.15, more than 10 approved leave days in 90 days 0.15)\n// riskLevel — HIGH >= 0.66, MEDIUM >= 0.33, else LOW\n// Headcount gap and skills demand count open (ACTIVE or PAUSED) postings;\n// cost projection is the annualised salary run-rate of ACTIVE employees.\nexport type CrewAttritionRiskLevel = 'HIGH' | 'MEDIUM' | 'LOW';\n\nexport interface CrewAttritionRisk {\n employeeId: string;\n employeeName: string;\n department: string;\n riskLevel: CrewAttritionRiskLevel;\n riskScore: number;\n drivers: string[];\n}\n\nexport interface CrewHeadcountGapRow {\n department: string;\n current: number;\n openPostings: number;\n projectedHeadcount: number;\n}\n\nexport interface CrewCostProjectionRow {\n department: string;\n monthly: number;\n annual: number;\n headcount: number;\n}\n\nexport interface CrewExecutiveDashboard {\n totalHeadcount: number;\n activeHeadcount: number;\n newHiresLast90Days: number;\n exitsLast90Days: number;\n averagePerformanceScore: number;\n averageTenureMonths: number;\n attritionRisk: {\n highCount: number;\n mediumCount: number;\n lowCount: number;\n totalAssessed: number;\n topRisks: CrewAttritionRisk[];\n };\n headcountGap: CrewHeadcountGapRow[];\n skillsGap: CrewSkillsGapRow[];\n costProjection: CrewCostProjectionRow[];\n generatedAt: string;\n}\n\n// BOFF-4193 — native gross-to-net payroll calculation engine (US/IN/GB\n// reference countries). NOT a licensed EOR/statutory-filing platform — see\n// wspace-crewfoundry-svc/src/modules/workforce/services/payroll/README.md\n// for the full scope note. `country`/`status` are kept in the exact\n// UPPER_SNAKE casing the schema's enums use (unlike most entities in this\n// store, which get lower-cased on read) since they're small closed sets\n// displayed as badges, not compared against lower_snake literals elsewhere.\nexport interface CrewPayrollRun {\n id: string;\n country: 'US' | 'IN' | 'GB';\n currency: string;\n period: string;\n payDate?: string | null;\n status: 'DRAFT' | 'CALCULATED' | 'APPROVED' | 'CLOSED';\n employeeCount: number;\n totalGrossPay: number;\n totalNetPay: number;\n calculatedAt?: string | null;\n approvedAt?: string | null;\n approvedBy?: string | null;\n notes?: string | null;\n}\n\nexport interface CrewPayslipTaxBracket {\n label: string;\n rate: number;\n bandFrom: number;\n bandTo?: number | null;\n taxableInBand: number;\n taxOnBand: number;\n}\n\nexport interface CrewPayslipContributionLine {\n label: string;\n rate?: number | null;\n base: number;\n amount: number;\n}\n\nexport interface CrewPayslip {\n id: string;\n payrollRunId: string;\n employeeId: string;\n employeeName: string;\n country: 'US' | 'IN' | 'GB';\n currency: string;\n period: string;\n annualGrossSalary: number;\n grossPay: number;\n taxableIncome: number;\n incomeTax: number;\n employeeSocialContrib: number;\n employerSocialContrib: number;\n otherDeductions: number;\n netPay: number;\n incomeTaxBrackets: CrewPayslipTaxBracket[];\n employeeContributions: CrewPayslipContributionLine[];\n employerContributions: CrewPayslipContributionLine[];\n otherDeductionLines: CrewPayslipContributionLine[];\n assumptions: string[];\n}\n\nexport interface CreateCrewPayrollRunEmployeeInput {\n employeeId: string;\n employeeName: string;\n annualGrossSalary: number;\n}\n\n// ── Learning & Development (BOFF-3401 / BOFF-4201) ─────────────\n// Served by wspace-crewfoundry-svc's learning module: an external-link course\n// catalog plus per-employee enrollment tracking. Course content itself lives\n// wherever `contentUrl` points (an internal doc, an existing LMS, ...).\nexport type CrewEnrollmentStatus = 'not_started' | 'in_progress' | 'completed';\n\nexport interface CrewTrainingCourse {\n id: string;\n title: string;\n description: string;\n contentUrl: string;\n durationMinutes: number | null;\n isActive: boolean;\n requiredForRoles: string[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewEnrollment {\n id: string;\n courseId: string;\n courseTitle: string;\n employeeId: string;\n employeeName: string;\n status: CrewEnrollmentStatus;\n startedAt: string | null;\n completedAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewTrainingCourseCompletion {\n courseId: string;\n courseTitle: string;\n totalEnrolled: number;\n notStartedCount: number;\n inProgressCount: number;\n completedCount: number;\n /** 0-100, as computed by the service. */\n completionRate: number;\n}\n\nexport interface CrewTrainingCourseInput {\n title: string;\n description: string;\n contentUrl: string;\n durationMinutes?: number | null;\n isActive?: boolean;\n requiredForRoles?: string[];\n}\n\n// ── Talent marketplace (BOFF-3401 / BOFF-4203) ─────────────────\n// Served by wspace-crewfoundry-svc's marketplace module. Escrow records are a\n// calculation-only ledger of intended holds/releases — never fund custody.\nexport type CrewServiceListingStatus = 'active' | 'paused';\nexport type CrewBookingStatus = 'requested' | 'confirmed' | 'completed' | 'cancelled';\nexport type CrewEscrowStatus = 'pending_hold' | 'held' | 'released' | 'cancelled';\n\nexport interface CrewServiceListing {\n id: string;\n title: string;\n description: string;\n category: string | null;\n providerActorId: string;\n providerName: string;\n rate: number;\n rateUnit: string;\n currency: string;\n status: CrewServiceListingStatus;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewServiceListingInput {\n title: string;\n description: string;\n providerName: string;\n category?: string | null;\n rate: number;\n rateUnit: string;\n currency?: string;\n}\n\nexport interface CrewBooking {\n id: string;\n listingId: string;\n listingTitle: string;\n providerActorId: string;\n providerName: string;\n clientActorId: string;\n clientName: string;\n status: CrewBookingStatus;\n rate: number;\n rateUnit: string;\n currency: string;\n notes: string | null;\n scheduledStart: string | null;\n scheduledEnd: string | null;\n cancelledReason: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CrewBookingInput {\n listingId: string;\n clientName: string;\n notes?: string | null;\n scheduledStart?: string | null;\n scheduledEnd?: string | null;\n}\n\nexport interface CrewEscrowRecord {\n id: string;\n bookingId: string;\n amount: number;\n currency: string;\n releaseCondition: string;\n status: CrewEscrowStatus;\n heldAt: string | null;\n releasedAt: string | null;\n releasedBy: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nimport { clearGraphqlFetchResponseCache, graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport type { Gateway } from '@burdenoff/fe-libs/shared/config';\n\nexport type InitParams = {\n workspaceId?: string;\n authToken?: string;\n apiGatewayUrl?: string;\n actorId?: string;\n /** Display name of the signed-in actor (default provider/client label). */\n actorName?: string;\n};\n\ntype GraphqlResult<T> = {\n data: T | null;\n errors?: Array<{ message: string }>;\n};\n\nconst BOOTSTRAP_QUERY = `\n query CrewfoundryBootstrap {\n crewfoundryBootstrap {\n employees { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate }\n departments { id name headId headName employeeCount budget location status }\n jobPostings { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits }\n candidates { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate }\n interviews { id candidateId candidateName position interviewerName date time type status feedback rating }\n announcements { id title content author authorRole category priority isPinned createdAt viewCount tags }\n teams { id name description leadId leadName members memberCount department status projectCount createdAt }\n projects { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks }\n leaveRequests { id employeeId employeeName department type startDate endDate days status reason approverName }\n timeEntries { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable }\n vendors { id name category contactPerson email phone status contractValue rating }\n clients { id name industry contactPerson email phone status revenue projects since }\n }\n }\n`;\n\n// Payroll (BOFF-4887) is deliberately NOT part of crewfoundryBootstrap — it is\n// gated by the dedicated `crewfoundry-payroll` RBAC resource rather than the\n// general `crewfoundry:read` the bootstrap query uses, so a Workforce\n// Coordinator (or any role with only general workforce access) must not be\n// able to read gross/net pay and deductions just by loading the dashboard.\n// Fetched separately via `runOverlap` below (best-effort — a FORBIDDEN\n// response from a role without payroll access degrades to an empty list\n// rather than failing the whole bootstrap load).\nconst CREW_PAYROLL_RECORDS_QUERY = `\n query CrewPayrollRecords {\n crewPayrollRecords { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod }\n }\n`;\n\ntype CrewPayrollRecordsResponse = {\n crewPayrollRecords: PayrollRecord[];\n};\n\nconst WORKSPACE_BOOTSTRAP_WITH_OVERLAP_QUERY = `\n query CrewfoundryWorkspaceBootstrapWithOverlap(\n $workspaceId: ID!\n $projectPagination: PaginationInput\n $groupFirst: Int\n $conversationFirst: Int\n ) {\n crewfoundryBootstrap {\n employees { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate }\n departments { id name headId headName employeeCount budget location status }\n jobPostings { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits }\n candidates { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate }\n interviews { id candidateId candidateName position interviewerName date time type status feedback rating }\n announcements { id title content author authorRole category priority isPinned createdAt viewCount tags }\n teams { id name description leadId leadName members memberCount department status projectCount createdAt }\n projects { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks }\n leaveRequests { id employeeId employeeName department type startDate endDate days status reason approverName }\n timeEntries { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable }\n vendors { id name category contactPerson email phone status contractValue rating }\n clients { id name industry contactPerson email phone status revenue projects since }\n }\n projects(filter: { workspaceId: $workspaceId }, pagination: $projectPagination) {\n items {\n id\n name\n key\n creatorId\n status\n config\n archived\n createdAt\n updatedAt\n }\n }\n groups(first: $groupFirst) {\n edges {\n node {\n id\n name\n description\n groupType\n status\n memberCount\n ownerId\n createdAt\n }\n }\n }\n conversations(first: $conversationFirst) {\n edges {\n node {\n id\n title\n description\n state\n unreadCount\n memberCount\n updatedAt\n }\n }\n }\n }\n`;\n\nconst CREATE_EMPLOYEE_MUTATION = `mutation CreateCrewEmployee($input: CreateCrewEmployeeInput!) { createCrewEmployee(input: $input) { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate } }`;\nconst UPDATE_EMPLOYEE_MUTATION = `mutation UpdateCrewEmployee($id: ID!, $input: UpdateCrewEmployeeInput!) { updateCrewEmployee(id: $id, input: $input) { id firstName lastName email department position status type salary startDate avatar location managerId phone performanceScore skills terminationDate } }`;\nconst REMOVE_EMPLOYEE_MUTATION = `mutation RemoveCrewEmployee($id: ID!) { removeCrewEmployee(id: $id) }`;\nconst CREATE_JOB_MUTATION = `mutation CreateCrewJobPosting($input: CreateCrewJobPostingInput!) { createCrewJobPosting(input: $input) { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits } }`;\nconst UPDATE_JOB_MUTATION = `mutation UpdateCrewJobPosting($id: ID!, $input: UpdateCrewJobPostingInput!) { updateCrewJobPosting(id: $id, input: $input) { id title department location type experienceLevel salaryMin salaryMax status applicants postedDate deadline description requirements benefits } }`;\nconst CREATE_CANDIDATE_MUTATION = `mutation CreateCrewCandidate($input: CreateCrewCandidateInput!) { createCrewCandidate(input: $input) { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } }`;\nconst UPDATE_CANDIDATE_MUTATION = `mutation UpdateCrewCandidate($id: ID!, $input: UpdateCrewCandidateInput!) { updateCrewCandidate(id: $id, input: $input) { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } }`;\nconst CREATE_ANNOUNCEMENT_MUTATION = `mutation CreateCrewAnnouncement($input: CreateCrewAnnouncementInput!) { createCrewAnnouncement(input: $input) { id title content author authorRole category priority isPinned createdAt viewCount tags } }`;\nconst CREATE_LEAVE_MUTATION = `mutation CreateCrewLeaveRequest($input: CreateCrewLeaveRequestInput!) { createCrewLeaveRequest(input: $input) { id employeeId employeeName department type startDate endDate days status reason approverName } }`;\nconst UPDATE_LEAVE_MUTATION = `mutation UpdateCrewLeaveRequest($id: ID!, $input: UpdateCrewLeaveRequestInput!) { updateCrewLeaveRequest(id: $id, input: $input) { id employeeId employeeName department type startDate endDate days status reason approverName } }`;\n// Extra removes / updates for existing entities (delete + edit buttons).\nconst REMOVE_JOB_MUTATION = `mutation RemoveCrewJobPosting($id: ID!) { removeCrewJobPosting(id: $id) }`;\nconst REMOVE_CANDIDATE_MUTATION = `mutation RemoveCrewCandidate($id: ID!) { removeCrewCandidate(id: $id) }`;\nconst UPDATE_ANNOUNCEMENT_MUTATION = `mutation UpdateCrewAnnouncement($id: ID!, $input: UpdateCrewAnnouncementInput!) { updateCrewAnnouncement(id: $id, input: $input) { id title content author authorRole category priority isPinned createdAt viewCount tags } }`;\nconst REMOVE_ANNOUNCEMENT_MUTATION = `mutation RemoveCrewAnnouncement($id: ID!) { removeCrewAnnouncement(id: $id) }`;\n\n// Interview\nconst CREATE_INTERVIEW_MUTATION = `mutation CreateCrewInterview($input: CreateCrewInterviewInput!) { createCrewInterview(input: $input) { id candidateId candidateName position interviewerName date time type status feedback rating } }`;\nconst UPDATE_INTERVIEW_MUTATION = `mutation UpdateCrewInterview($id: ID!, $input: UpdateCrewInterviewInput!) { updateCrewInterview(id: $id, input: $input) { id candidateId candidateName position interviewerName date time type status feedback rating } }`;\nconst REMOVE_INTERVIEW_MUTATION = `mutation RemoveCrewInterview($id: ID!) { removeCrewInterview(id: $id) }`;\n\n// Vendor\nconst CREATE_VENDOR_MUTATION = `mutation CreateCrewVendor($input: CreateCrewVendorInput!) { createCrewVendor(input: $input) { id name category contactPerson email phone status contractValue rating } }`;\nconst UPDATE_VENDOR_MUTATION = `mutation UpdateCrewVendor($id: ID!, $input: UpdateCrewVendorInput!) { updateCrewVendor(id: $id, input: $input) { id name category contactPerson email phone status contractValue rating } }`;\nconst REMOVE_VENDOR_MUTATION = `mutation RemoveCrewVendor($id: ID!) { removeCrewVendor(id: $id) }`;\n\n// Client\nconst CREATE_CLIENT_MUTATION = `mutation CreateCrewClient($input: CreateCrewClientInput!) { createCrewClient(input: $input) { id name industry contactPerson email phone status revenue projects since } }`;\nconst UPDATE_CLIENT_MUTATION = `mutation UpdateCrewClient($id: ID!, $input: UpdateCrewClientInput!) { updateCrewClient(id: $id, input: $input) { id name industry contactPerson email phone status revenue projects since } }`;\nconst REMOVE_CLIENT_MUTATION = `mutation RemoveCrewClient($id: ID!) { removeCrewClient(id: $id) }`;\n\n// Team\nconst CREATE_TEAM_MUTATION = `mutation CreateCrewTeam($input: CreateCrewTeamInput!) { createCrewTeam(input: $input) { id name description leadId leadName members memberCount department status projectCount createdAt } }`;\nconst UPDATE_TEAM_MUTATION = `mutation UpdateCrewTeam($id: ID!, $input: UpdateCrewTeamInput!) { updateCrewTeam(id: $id, input: $input) { id name description leadId leadName members memberCount department status projectCount createdAt } }`;\nconst REMOVE_TEAM_MUTATION = `mutation RemoveCrewTeam($id: ID!) { removeCrewTeam(id: $id) }`;\n\n// Project\nconst CREATE_PROJECT_MUTATION = `mutation CreateCrewProject($input: CreateCrewProjectInput!) { createCrewProject(input: $input) { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks } }`;\nconst UPDATE_PROJECT_MUTATION = `mutation UpdateCrewProject($id: ID!, $input: UpdateCrewProjectInput!) { updateCrewProject(id: $id, input: $input) { id name description status priority startDate endDate progress budget spent teamId teamName managerId managerName tasks completedTasks } }`;\nconst REMOVE_PROJECT_MUTATION = `mutation RemoveCrewProject($id: ID!) { removeCrewProject(id: $id) }`;\n\n// Department\nconst CREATE_DEPARTMENT_MUTATION = `mutation CreateCrewDepartment($input: CreateCrewDepartmentInput!) { createCrewDepartment(input: $input) { id name headId headName employeeCount budget location status } }`;\nconst UPDATE_DEPARTMENT_MUTATION = `mutation UpdateCrewDepartment($id: ID!, $input: UpdateCrewDepartmentInput!) { updateCrewDepartment(id: $id, input: $input) { id name headId headName employeeCount budget location status } }`;\nconst REMOVE_DEPARTMENT_MUTATION = `mutation RemoveCrewDepartment($id: ID!) { removeCrewDepartment(id: $id) }`;\n\n// PayrollRecord\nconst CREATE_PAYROLL_MUTATION = `mutation CreateCrewPayrollRecord($input: CreateCrewPayrollRecordInput!) { createCrewPayrollRecord(input: $input) { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod } }`;\nconst UPDATE_PAYROLL_MUTATION = `mutation UpdateCrewPayrollRecord($id: ID!, $input: UpdateCrewPayrollRecordInput!) { updateCrewPayrollRecord(id: $id, input: $input) { id employeeId employeeName department period grossPay deductions netPay status payDate paymentMethod } }`;\nconst REMOVE_PAYROLL_MUTATION = `mutation RemoveCrewPayrollRecord($id: ID!) { removeCrewPayrollRecord(id: $id) }`;\n\n// BOFF-4193 — native payroll calculation engine (PayrollRun/Payslip). Fetched\n// lazily (see `fetchPayrollRuns`/`fetchPayslipsForRun` below), not on\n// bootstrap — same `crewfoundry-payroll` RBAC gate as CrewPayrollRecord\n// above, so a caller without payroll access simply never triggers the fetch\n// rather than failing the dashboard load.\nconst PAYROLL_RUN_FIELDS = `id country currency period payDate status employeeCount totalGrossPay totalNetPay calculatedAt approvedAt approvedBy notes`;\nconst CREW_PAYROLL_RUNS_QUERY = `query CrewPayrollRuns { crewPayrollRuns { ${PAYROLL_RUN_FIELDS} } }`;\nconst CREATE_PAYROLL_RUN_MUTATION = `mutation CreateCrewPayrollRun($input: CreateCrewPayrollRunInput!) { createCrewPayrollRun(input: $input) { ${PAYROLL_RUN_FIELDS} } }`;\nconst CALCULATE_PAYROLL_RUN_MUTATION = `mutation CalculateCrewPayrollRun($id: ID!) { calculateCrewPayrollRun(id: $id) { ${PAYROLL_RUN_FIELDS} } }`;\nconst APPROVE_PAYROLL_RUN_MUTATION = `mutation ApproveCrewPayrollRun($id: ID!) { approveCrewPayrollRun(id: $id) { ${PAYROLL_RUN_FIELDS} } }`;\nconst REMOVE_PAYROLL_RUN_MUTATION = `mutation RemoveCrewPayrollRun($id: ID!) { removeCrewPayrollRun(id: $id) }`;\nconst PAYSLIP_FIELDS = `id payrollRunId employeeId employeeName country currency period annualGrossSalary grossPay taxableIncome incomeTax employeeSocialContrib employerSocialContrib otherDeductions netPay incomeTaxBrackets { label rate bandFrom bandTo taxableInBand taxOnBand } employeeContributions { label rate base amount } employerContributions { label rate base amount } otherDeductionLines { label rate base amount } assumptions`;\nconst CREW_PAYSLIPS_QUERY = `query CrewPayslips($filter: CrewPayslipFilterInput) { crewPayslips(filter: $filter) { ${PAYSLIP_FIELDS} } }`;\n\n// TimeEntry\nconst CREATE_TIME_ENTRY_MUTATION = `mutation CreateCrewTimeEntry($input: CreateCrewTimeEntryInput!) { createCrewTimeEntry(input: $input) { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable } }`;\nconst UPDATE_TIME_ENTRY_MUTATION = `mutation UpdateCrewTimeEntry($id: ID!, $input: UpdateCrewTimeEntryInput!) { updateCrewTimeEntry(id: $id, input: $input) { id employeeId employeeName date clockIn clockOut totalHours overtime project status billable } }`;\nconst REMOVE_TIME_ENTRY_MUTATION = `mutation RemoveCrewTimeEntry($id: ID!) { removeCrewTimeEntry(id: $id) }`;\n\n// BOFF-4195 — AI-assisted candidate/worker matching. `candidate` is the full\n// CrewCandidate record so the UI can show name/skills/experience alongside\n// the score without a second round-trip.\nconst JOB_POSTING_MATCHES_QUERY = `query CrewJobPostingMatches($jobPostingId: ID!, $filter: CrewCandidateMatchFilterInput, $limit: Int) { crewJobPostingMatches(jobPostingId: $jobPostingId, filter: $filter, limit: $limit) { candidateId jobPostingId score skillScore experienceScore matchedSkills missingSkills rationale candidate { id firstName lastName email phone position status appliedDate resumeUrl rating source experience skills currentCompany notes hiredDate } } }`;\n\n// Skills supply/demand. Not part of `crewfoundryBootstrap` (it isn't a bootstrap\n// field), so it is fetched lazily by the one surface that renders it — the\n// resourcing page — rather than on every dashboard load. Same `crewfoundry:read`\n// RBAC resource as the bootstrap query, so any caller that can load the module\n// can read it. `department` is omitted because the resourcing page shows\n// workspace-wide coverage; when passed, the resolver scopes both supply\n// (employees) and demand (job postings) to that department.\nconst SKILLS_GAP_QUERY = `query CrewSkillsGap { crewSkillsGap { skill employeesWithSkill openJobsRequiringSkill shortage } }`;\n\n// BOFF-4208 — single-call executive rollup (read-only, `crewfoundry` read RBAC).\nconst EXECUTIVE_DASHBOARD_QUERY = `query CrewExecutiveDashboard { crewExecutiveDashboard { totalHeadcount activeHeadcount newHiresLast90Days exitsLast90Days averagePerformanceScore averageTenureMonths attritionRisk { highCount mediumCount lowCount totalAssessed topRisks { employeeId employeeName department riskLevel riskScore drivers } } headcountGap { department current openPostings projectedHeadcount } skillsGap { skill employeesWithSkill openJobsRequiringSkill shortage } costProjection { department monthly annual headcount } generatedAt } }`;\n\n// BOFF-3987 — employee documents\nconst EMPLOYEE_DOCUMENTS_QUERY = `query EmployeeDocuments($employeeId: ID!) { employeeDocuments(employeeId: $employeeId) { id employeeId fileId title category uploadedBy uploadedAt } }`;\nconst ATTACH_EMPLOYEE_DOCUMENT_MUTATION = `mutation AttachEmployeeDocument($input: AttachCrewEmployeeDocumentInput!) { attachEmployeeDocument(input: $input) { id employeeId fileId title category uploadedBy uploadedAt } }`;\nconst DETACH_EMPLOYEE_DOCUMENT_MUTATION = `mutation DetachEmployeeDocument($id: ID!) { detachEmployeeDocument(id: $id) }`;\n// BOFF-3717 — the profile query also returns the (deprecated) legacy `skills`\n// tags so the directory's tag view stays in step after an attach/detach.\nconst EMPLOYEE_SKILL_PROFILE_QUERY = `query CrewEmployeeSkillProfile($id: ID!) { crewEmployee(id: $id) { id skills skillProfile { id skillId proficiency verifiedFrom lastUsedAt skill { id name category source } } } }`;\nconst ATTACH_CREW_SKILL_MUTATION = `mutation AttachCrewSkill($input: AttachCrewSkillInput!) { attachCrewSkill(input: $input) { id } }`;\nconst DETACH_CREW_SKILL_MUTATION = `mutation DetachCrewSkill($employeeId: ID!, $skillId: ID!) { detachCrewSkill(employeeId: $employeeId, skillId: $skillId) }`;\n// BOFF-10361 — taxonomy administration, find-people-by-skill and candidate skills.\n// Relations are fetched as ids only: names are joined client-side from the\n// taxonomy, so a listing does not resolve two skills per edge.\nconst TAXONOMY_PAGE_SIZE = 100;\n/** Hard stop on taxonomy paging (100 skills per page). */\nconst TAXONOMY_MAX_PAGES = 50;\nconst CREW_SKILLS_TAXONOMY_QUERY = `query CrewSkillsTaxonomy($pagination: PaginationInput) { crewSkills(pagination: $pagination) { id name slug category source description aliases employeeCount candidateCount relations { id type fromSkillId toSkillId } } }`;\nconst CREW_SKILL_CATEGORIES_QUERY = `query CrewSkillCategories { crewSkillCategories }`;\nconst CREATE_CREW_SKILL_MUTATION = `mutation CreateCrewSkill($input: CreateCrewSkillInput!) { createCrewSkill(input: $input) { id } }`;\nconst UPDATE_CREW_SKILL_MUTATION = `mutation UpdateCrewSkill($id: ID!, $input: UpdateCrewSkillInput!) { updateCrewSkill(id: $id, input: $input) { id } }`;\nconst MERGE_CREW_SKILLS_MUTATION = `mutation MergeCrewSkills($sourceId: ID!, $targetId: ID!) { mergeCrewSkills(sourceId: $sourceId, targetId: $targetId) { target { id name } employeesMoved candidatesMoved jobPostingsMoved } }`;\nconst REMOVE_CREW_SKILL_MUTATION = `mutation RemoveCrewSkill($id: ID!) { removeCrewSkill(id: $id) }`;\nconst CREATE_CREW_SKILL_RELATION_MUTATION = `mutation CreateCrewSkillRelation($input: CreateCrewSkillRelationInput!) { createCrewSkillRelation(input: $input) { id } }`;\nconst REMOVE_CREW_SKILL_RELATION_MUTATION = `mutation RemoveCrewSkillRelation($id: ID!) { removeCrewSkillRelation(id: $id) }`;\nconst CREW_EMPLOYEES_BY_SKILL_QUERY = `query CrewEmployeesBySkill($skillId: ID!, $minProficiency: Int, $limit: Int) { crewEmployeesBySkill(skillId: $skillId, minProficiency: $minProficiency, limit: $limit) { employee { id firstName lastName position department } matchType matchedSkill { id name } proficiency verifiedFrom explanation } }`;\nconst JOB_POSTING_SKILL_REQUIREMENTS_QUERY = `query CrewJobPostingSkillRequirements($id: ID!) { crewJobPosting(id: $id) { id skillRequirements { id skillId required minProficiency skill { id name category source } } } }`;\nconst CANDIDATE_SKILL_PROFILE_QUERY = `query CrewCandidateSkillProfile($id: ID!) { crewCandidate(id: $id) { id skills skillProfile { id skillId proficiency source skill { id name category source } } } }`;\nconst ATTACH_CANDIDATE_SKILL_MUTATION = `mutation AttachCrewCandidateSkill($input: AttachCrewCandidateSkillInput!) { attachCrewCandidateSkill(input: $input) { id } }`;\ninterface MergeCrewSkillsPayload {\n target: { id: string; name: string };\n employeesMoved: number;\n candidatesMoved: number;\n jobPostingsMoved: number;\n}\nconst DETACH_CANDIDATE_SKILL_MUTATION = `mutation DetachCrewCandidateSkill($candidateId: ID!, $skillId: ID!) { detachCrewCandidateSkill(candidateId: $candidateId, skillId: $skillId) }`;\n// Files-svc presigned upload dance (same 3-step protocol fe-libs' SaveToFilesButton\n// uses — see ~/products/dev/platform/context/data/files/), replicated here with the\n// store's own graphqlFetch helper instead of Apollo since this MFE has no Apollo\n// client wired in.\nconst ENSURE_FOLDER_BY_PATH_MUTATION = `mutation EnsureFolderByPath($path: String!) { ensureFolderByPath(path: $path) { id } }`;\nconst INITIATE_UPLOAD_MUTATION = `mutation InitiateUpload($input: InitiateUploadInput!) { initiateUpload(input: $input) { session { id } uploadUrl } }`;\nconst COMPLETE_UPLOAD_MUTATION = `mutation CompleteUpload($input: CompleteUploadInput!) { completeUpload(input: $input) { file { id } } }`;\n\n// BOFF-3983 — onboarding\nconst ONBOARDINGS_QUERY = `query CrewOnboardings { crewOnboardings { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst CREATE_ONBOARDING_MUTATION = `mutation CreateCrewOnboarding($input: CreateCrewOnboardingInput!) { createCrewOnboarding(input: $input) { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst UPDATE_ONBOARDING_MUTATION = `mutation UpdateCrewOnboarding($id: ID!, $input: UpdateCrewOnboardingInput!) { updateCrewOnboarding(id: $id, input: $input) { id candidateId employeeId fullName position department startDate status currentStage createdAt totalTaskCount completedTaskCount progressPercent tasks { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } } }`;\nconst REMOVE_ONBOARDING_MUTATION = `mutation RemoveCrewOnboarding($id: ID!) { removeCrewOnboarding(id: $id) }`;\nconst CREATE_ONBOARDING_TASK_MUTATION = `mutation CreateCrewOnboardingTask($input: CreateCrewOnboardingTaskInput!) { createCrewOnboardingTask(input: $input) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\nconst UPDATE_ONBOARDING_TASK_MUTATION = `mutation UpdateCrewOnboardingTask($id: ID!, $input: UpdateCrewOnboardingTaskInput!) { updateCrewOnboardingTask(id: $id, input: $input) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\nconst REMOVE_ONBOARDING_TASK_MUTATION = `mutation RemoveCrewOnboardingTask($id: ID!) { removeCrewOnboardingTask(id: $id) }`;\nconst TOGGLE_ONBOARDING_TASK_MUTATION = `mutation ToggleCrewOnboardingTask($id: ID!, $completed: Boolean!) { toggleCrewOnboardingTask(id: $id, completed: $completed) { id onboardingId stage title assigneeActorId assigneeName dueDate completedAt sortOrder } }`;\n\n// BOFF-3401 — Learning & Development. Lazy-loaded by the Learning pages (see\n// `fetchLearning`), not on bootstrap: the catalog, enrollments and the\n// completion dashboard come back in one round trip.\nconst TRAINING_COURSE_FIELDS = `id title description contentUrl durationMinutes isActive requiredForRoles createdAt updatedAt`;\nconst ENROLLMENT_FIELDS = `id courseId courseTitle employeeId employeeName status startedAt completedAt createdAt updatedAt`;\nconst LEARNING_QUERY = `query CrewLearning($coursePage: PaginationInput, $enrollmentPage: PaginationInput) { crewTrainingCourses(pagination: $coursePage) { ${TRAINING_COURSE_FIELDS} } crewEnrollments(pagination: $enrollmentPage) { ${ENROLLMENT_FIELDS} } crewTrainingCompletionDashboard { courseId courseTitle totalEnrolled notStartedCount inProgressCount completedCount completionRate } }`;\nconst TRAINING_COURSES_PAGE_QUERY = `query CrewTrainingCourses($pagination: PaginationInput) { crewTrainingCourses(pagination: $pagination) { ${TRAINING_COURSE_FIELDS} } }`;\nconst ENROLLMENTS_PAGE_QUERY = `query CrewEnrollments($pagination: PaginationInput) { crewEnrollments(pagination: $pagination) { ${ENROLLMENT_FIELDS} } }`;\nconst TRAINING_COMPLETION_QUERY = `query CrewTrainingCompletionDashboard { crewTrainingCompletionDashboard { courseId courseTitle totalEnrolled notStartedCount inProgressCount completedCount completionRate } }`;\nconst CREATE_TRAINING_COURSE_MUTATION = `mutation CreateCrewTrainingCourse($input: CreateCrewTrainingCourseInput!) { createCrewTrainingCourse(input: $input) { ${TRAINING_COURSE_FIELDS} } }`;\nconst UPDATE_TRAINING_COURSE_MUTATION = `mutation UpdateCrewTrainingCourse($id: ID!, $input: UpdateCrewTrainingCourseInput!) { updateCrewTrainingCourse(id: $id, input: $input) { ${TRAINING_COURSE_FIELDS} } }`;\nconst REMOVE_TRAINING_COURSE_MUTATION = `mutation RemoveCrewTrainingCourse($id: ID!) { removeCrewTrainingCourse(id: $id) }`;\nconst CREATE_ENROLLMENT_MUTATION = `mutation CreateCrewEnrollment($input: CreateCrewEnrollmentInput!) { createCrewEnrollment(input: $input) { ${ENROLLMENT_FIELDS} } }`;\nconst UPDATE_ENROLLMENT_STATUS_MUTATION = `mutation UpdateCrewEnrollmentStatus($id: ID!, $status: String!) { updateCrewEnrollmentStatus(id: $id, status: $status) { ${ENROLLMENT_FIELDS} } }`;\nconst REMOVE_ENROLLMENT_MUTATION = `mutation RemoveCrewEnrollment($id: ID!) { removeCrewEnrollment(id: $id) }`;\n\n// BOFF-3401 — talent marketplace. Lazy-loaded by the Marketplace pages (see\n// `fetchMarketplace`). Escrow is gated by the separate `crewfoundry-payroll`\n// RBAC resource, so it is fetched on its own (`fetchEscrowRecords`) and a\n// caller without that grant still gets the listings and bookings.\nconst SERVICE_LISTING_FIELDS = `id title description category providerActorId providerName rate rateUnit currency status createdAt updatedAt`;\nconst BOOKING_FIELDS = `id listingId listingTitle providerActorId providerName clientActorId clientName status rate rateUnit currency notes scheduledStart scheduledEnd cancelledReason createdAt updatedAt`;\nconst ESCROW_FIELDS = `id bookingId amount currency releaseCondition status heldAt releasedAt releasedBy notes createdAt updatedAt`;\nconst SERVICE_LISTINGS_PAGE_QUERY = `query CrewServiceListings($pagination: PaginationInput) { crewServiceListings(pagination: $pagination) { ${SERVICE_LISTING_FIELDS} } }`;\nconst BOOKINGS_PAGE_QUERY = `query CrewBookings($pagination: PaginationInput) { crewBookings(pagination: $pagination) { ${BOOKING_FIELDS} } }`;\nconst ESCROW_RECORDS_PAGE_QUERY = `query CrewEscrowRecords($pagination: PaginationInput) { crewEscrowRecords(pagination: $pagination) { ${ESCROW_FIELDS} } }`;\nconst CREATE_SERVICE_LISTING_MUTATION = `mutation CreateCrewServiceListing($input: CreateCrewServiceListingInput!) { createCrewServiceListing(input: $input) { ${SERVICE_LISTING_FIELDS} } }`;\nconst UPDATE_SERVICE_LISTING_MUTATION = `mutation UpdateMyServiceListing($id: ID!, $input: UpdateCrewServiceListingInput!) { updateMyServiceListing(id: $id, input: $input) { ${SERVICE_LISTING_FIELDS} } }`;\nconst REMOVE_SERVICE_LISTING_MUTATION = `mutation RemoveMyServiceListing($id: ID!) { removeMyServiceListing(id: $id) }`;\nconst CREATE_BOOKING_MUTATION = `mutation CreateCrewBooking($input: CreateCrewBookingInput!) { createCrewBooking(input: $input) { ${BOOKING_FIELDS} } }`;\nconst UPDATE_BOOKING_STATUS_MUTATION = `mutation UpdateMyBookingStatus($id: ID!, $status: String!) { updateMyBookingStatus(id: $id, status: $status) { ${BOOKING_FIELDS} } }`;\nconst RELEASE_ESCROW_MUTATION = `mutation ReleaseCrewEscrowRecord($id: ID!) { releaseCrewEscrowRecord(id: $id) { ${ESCROW_FIELDS} } }`;\nconst CANCEL_ESCROW_MUTATION = `mutation CancelCrewEscrowRecord($id: ID!) { cancelCrewEscrowRecord(id: $id) { ${ESCROW_FIELDS} } }`;\n\n/** Server page ceiling (wspace-crewfoundry-svc MAX_LIMIT). */\nconst LIST_PAGE_SIZE = 100;\n/** Safety ceiling on pages fetched per list (10 x 100 rows). */\nconst LIST_MAX_PAGES = 10;\n\nconst normalizeStatus = (value: string) => value.toUpperCase().replaceAll('-', '_');\n\n// The backend returns enum values in UPPER_SNAKE case (e.g. \"ACTIVE\", \"FULL_TIME\", \"HIGH\"),\n// but the frontend model + every comparison/filter/badge uses lower_snake ('active', 'full_time').\n// Normalization is per-entity, NOT per-key: fields like `category` are genuine enums on some\n// entities (Announcement.category) yet free text on others (Vendor.category,\n// CrewServiceListing.category) — a global key list would corrupt those.\n// Each list below mirrors exactly the string-literal-union fields declared on that entity's interface.\nconst ENUM_KEYS = {\n employee: ['status', 'type'],\n department: ['status'],\n jobPosting: ['type', 'experienceLevel', 'status'],\n candidate: ['status'],\n interview: ['type', 'status'],\n enrollment: ['status'],\n serviceListing: ['status'],\n booking: ['status'],\n escrow: ['status'],\n announcement: ['category', 'priority'],\n team: ['status'],\n project: ['status', 'priority'],\n payrollRecord: ['status'],\n leaveRequest: ['type', 'status'],\n timeEntry: ['status'],\n notification: ['type'],\n vendor: ['status'],\n client: ['status'],\n onboarding: ['status', 'currentStage'],\n onboardingTask: ['stage'],\n} as const;\n\n// Lowercase only the given enum keys on an entity read back from the backend; leave every other\n// (free-text) field untouched. Idempotent — safe on already-lowercase values (some subgraphs\n// return lowercase already). This is the read-path inverse of `normalizeStatus`.\nconst lowerEnumKeys = <T>(entity: T, keys: readonly string[]): T => {\n if (!entity || typeof entity !== 'object') return entity;\n const out = { ...(entity as Record<string, unknown>) };\n for (const key of keys) {\n const value = out[key];\n if (typeof value === 'string') out[key] = value.toLowerCase();\n }\n return out as T;\n};\n\n// lowerEnumKeys only lowercases top-level string fields; CrewOnboarding nests\n// a `tasks` array whose own `stage` field also needs the same treatment, so\n// this composes lowerEnumKeys over both levels rather than duplicating it.\nconst lowerOnboarding = (onboarding: CrewOnboarding): CrewOnboarding => {\n const lowered = lowerEnumKeys(onboarding, ENUM_KEYS.onboarding);\n return {\n ...lowered,\n tasks: (onboarding.tasks ?? []).map((task) => lowerEnumKeys(task, ENUM_KEYS.onboardingTask)),\n };\n};\n\nconst toDateOnly = (value?: string | null) => (value ? value.slice(0, 10) : 'TBD');\n\nconst asRecord = (value: unknown): Record<string, unknown> | null => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n return null;\n }\n return value as Record<string, unknown>;\n};\n\nconst asNumber = (value: unknown): number | null => (typeof value === 'number' ? value : null);\n\nconst asString = (value: unknown): string | null => (typeof value === 'string' ? value : null);\n\nconst mapProjectStatus = (value: string): Project['status'] => {\n const status = value.toLowerCase();\n if (status === 'active') return 'active';\n if (status === 'completed') return 'completed';\n if (status === 'cancelled') return 'cancelled';\n if (status === 'archived') return 'on_hold';\n return 'planning';\n};\n\nconst mapGroupStatus = (value: string): Team['status'] => {\n const status = value.toLowerCase();\n if (status === 'active') return 'active';\n if (status === 'inactive' || status === 'archived' || status === 'deleted') return 'disbanded';\n return 'forming';\n};\n\ntype OverlapWorkspaceResponse = {\n projects: {\n items: Array<{\n id: string;\n name: string;\n key: string;\n creatorId: string;\n status: string;\n config?: unknown;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n }>;\n };\n groups: {\n edges: Array<{\n node: {\n id: string;\n name: string;\n description?: string | null;\n groupType?: string | null;\n status: string;\n memberCount: number;\n ownerId: string;\n createdAt: string;\n };\n }>;\n };\n conversations: {\n edges: Array<{\n node: {\n id: string;\n title?: string | null;\n description?: string | null;\n state: string;\n unreadCount: number;\n memberCount: number;\n updatedAt: string;\n };\n }>;\n };\n};\n\ntype WorkspaceBootstrapWithOverlapResponse = BootstrapPayload & OverlapWorkspaceResponse;\n\ntype BootstrapPayload = {\n crewfoundryBootstrap: {\n employees: Employee[];\n departments: Department[];\n jobPostings: JobPosting[];\n candidates: Candidate[];\n interviews: Interview[];\n announcements: Announcement[];\n teams: Team[];\n projects: Project[];\n leaveRequests: LeaveRequest[];\n timeEntries: TimeEntry[];\n vendors: Vendor[];\n clients: Client[];\n };\n};\n\nconst mapOverlapProjects = (\n projects: OverlapWorkspaceResponse['projects']['items'],\n teams: Team[]\n) =>\n projects.map((project, index): Project => {\n const config = asRecord(project.config);\n const budget = asNumber(config?.budget) ?? 25000 + index * 2500;\n const spent =\n asNumber(config?.spent) ?? Math.round(budget * (project.status === 'COMPLETED' ? 1 : 0.62));\n const progress = asNumber(config?.progress) ?? (project.status === 'COMPLETED' ? 100 : 58);\n const tasks = asNumber(config?.tasks) ?? 20 + (index % 9);\n const completedTasks = asNumber(config?.completedTasks) ?? Math.round((progress / 100) * tasks);\n const team = teams[index % Math.max(teams.length, 1)];\n\n return {\n id: project.id,\n name: project.name,\n description: asString(config?.description) || `${project.key} delivery plan`,\n status: mapProjectStatus(project.status),\n priority: (asString(config?.priority)?.toLowerCase() as Project['priority']) || 'medium',\n startDate: toDateOnly(project.createdAt),\n endDate: toDateOnly(project.updatedAt),\n progress,\n budget,\n spent,\n teamId: team?.id || 'unassigned',\n teamName: team?.name || 'Unassigned Team',\n managerId: project.creatorId,\n managerName: `Lead ${project.creatorId.slice(0, 8)}`,\n tasks,\n completedTasks,\n };\n });\n\nconst mapOverlapTeams = (groups: OverlapWorkspaceResponse['groups']['edges']): Team[] =>\n groups.map(({ node }) => ({\n id: node.id,\n name: node.name,\n description: node.description || `${node.name} team workspace`,\n leadId: node.ownerId,\n leadName: `Lead ${node.ownerId.slice(0, 8)}`,\n members: [],\n memberCount: node.memberCount,\n department: node.groupType?.toLowerCase().replaceAll('_', ' ') || 'operations',\n status: mapGroupStatus(node.status),\n projectCount: 0,\n createdAt: toDateOnly(node.createdAt),\n }));\n\n/** Shell route of the shared Conversations app (microfe-conversations). */\nexport const CONVERSATIONS_ROUTE = '/conversations';\n\nconst mapConversationNotifications = (\n conversations: OverlapWorkspaceResponse['conversations']['edges']\n): Notification[] =>\n conversations\n .filter(({ node }) => node.unreadCount > 0)\n .map(({ node }) => ({\n id: `conversation-${node.id}`,\n title: node.title || 'Conversation update',\n message: `${node.unreadCount} unread in ${node.memberCount}-member channel`,\n type: node.state.toLowerCase() === 'active' ? 'info' : 'warning',\n category: 'communications',\n read: false,\n createdAt: node.updatedAt,\n // Conversations are owned by wspace-conversations-svc and rendered by the\n // shell's shared Conversations app, not by a CrewFoundry page.\n actionUrl: CONVERSATIONS_ROUTE,\n }));\n\nconst parseGraphql = <T>(result: GraphqlResult<T>, fallbackMessage: string): T => {\n if (result.errors?.length) {\n throw new Error(result.errors[0]?.message || fallbackMessage);\n }\n if (!result.data) {\n throw new Error(fallbackMessage);\n }\n return result.data;\n};\n\n// Fields that live on the client-side entity objects but are NEVER accepted by\n// any Crew* Create/Update GraphQL input — either a client-generated temp `id`,\n// a server-set timestamp, or a server-derived rollup counter. Sending them makes\n// the gateway reject the whole operation with a GraphQL validation error (which\n// the public gateway masks to a generic INTERNAL_SERVER_ERROR), so no row is\n// ever written. Stripping them centrally keeps every create/update mutation valid\n// without each caller having to hand-pick input fields. (Counters like rating /\n// applicants / viewCount that a few inputs DO accept are safe to drop too — they\n// default server-side, and the UI never lets a user set a derived rollup.)\nconst MUTATION_INPUT_OMIT_KEYS = new Set<string>([\n 'id',\n 'createdAt',\n 'createdOn',\n 'updatedAt',\n 'deletedAt',\n 'employeeCount',\n 'memberCount',\n 'projectCount',\n 'enrolled',\n 'completed',\n 'completionRate',\n 'reviews',\n 'rating',\n 'tasks',\n 'completedTasks',\n 'spent',\n 'progress',\n 'applicants',\n 'viewCount',\n 'revenue',\n 'projects',\n]);\n\nconst sanitizeMutationInput = (\n variables: Record<string, unknown> | undefined\n): Record<string, unknown> | undefined => {\n if (!variables) {\n return variables;\n }\n const input = variables.input;\n if (!input || typeof input !== 'object' || Array.isArray(input)) {\n return variables;\n }\n const cleaned: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n if (!MUTATION_INPUT_OMIT_KEYS.has(key)) {\n cleaned[key] = value;\n }\n }\n return { ...variables, input: cleaned };\n};\n\nconst isMutationDocument = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nexport const runGraphql = async <T>(\n query: string,\n variables: Record<string, unknown> | undefined,\n params: InitParams,\n fallbackMessage: string,\n gateway: Gateway = 'workspace'\n) => {\n const result = await graphqlFetch<T>({\n gateway,\n query,\n variables: sanitizeMutationInput(variables),\n authToken: params.authToken,\n // `apiGatewayUrl` is the workspace gateway base (dev override only). The\n // global gateway (e.g. billing overlap) resolves its own URL from fe-libs\n // config, so never force the workspace base onto a global-gateway call.\n baseUrl: gateway === 'workspace' ? params.apiGatewayUrl : undefined,\n extraHeaders: {\n ...(gateway === 'workspace' && params.workspaceId\n ? { 'x-workspace-id': params.workspaceId }\n : {}),\n },\n });\n const data = parseGraphql(result as GraphqlResult<T>, fallbackMessage);\n // fe-libs graphqlFetch caches query responses for a few seconds, keyed by\n // operation + variables. A read issued right after a successful write (e.g.\n // the skill profile refetch after attachCrewSkill) would otherwise be served\n // the pre-mutation response, so the change only appears after a reload.\n if (isMutationDocument(query)) clearGraphqlFetchResponseCache();\n return data;\n};\n\n// Overlap queries are best-effort: they enrich the crew bootstrap with real\n// wspace/global platform data but must never block the page if a field is\n// unavailable in a given environment. Swallow to null, but surface the reason\n// in dev so schema-arg drift (the historical failure mode) is visible.\n// Vite injects `import.meta.env.DEV`, but this package's tsconfig does not pull\n// in `vite/client` ambient types — narrow through a typed shape instead of `any`.\nconst isDevEnv = (): boolean => Boolean((import.meta as { env?: { DEV?: boolean } }).env?.DEV);\n\nconst runOverlap = async <T>(\n query: string,\n variables: Record<string, unknown> | undefined,\n params: InitParams,\n fallbackMessage: string,\n gateway: Gateway = 'workspace'\n): Promise<T | null> => {\n try {\n return await runGraphql<T>(query, variables, params, fallbackMessage, gateway);\n } catch (error) {\n if (isDevEnv()) {\n console.warn(`[crewfoundry] overlap query skipped: ${fallbackMessage}`, error);\n }\n return null;\n }\n};\n\n// ── BOFF-3401 list helpers ──────────────────────────────────────\n/**\n * Fetch every page of a list query (offset paging, `LIST_PAGE_SIZE` rows per\n * page, at most `LIST_MAX_PAGES` pages). A short page ends the walk.\n */\nconst fetchAllPages = async <TRow>(\n query: string,\n field: string,\n params: InitParams,\n fallbackMessage: string,\n firstPage?: TRow[]\n): Promise<TRow[]> => {\n const rows: TRow[] = firstPage ? [...firstPage] : [];\n if (firstPage && firstPage.length < LIST_PAGE_SIZE) {\n return rows;\n }\n for (let page = firstPage ? 1 : 0; page < LIST_MAX_PAGES; page += 1) {\n const data = await runGraphql<Record<string, TRow[]>>(\n query,\n { pagination: { limit: LIST_PAGE_SIZE, offset: page * LIST_PAGE_SIZE } },\n params,\n fallbackMessage\n );\n const batch = data[field] ?? [];\n rows.push(...batch);\n if (batch.length < LIST_PAGE_SIZE) {\n break;\n }\n }\n return rows;\n};\n\n/**\n * Write counters for the lazily loaded slices. A list fetch that was already\n * in flight when a create/update/remove landed would otherwise overwrite the\n * fresh local row with its older snapshot; a fetch that sees the counter move\n * re-reads instead of committing stale data (bounded by WRITE_RACE_RETRIES).\n */\nconst sliceWrites = { learning: 0, marketplace: 0 };\nconst WRITE_RACE_RETRIES = 3;\n\nconst lowerEnrollment = (row: CrewEnrollment) => lowerEnumKeys(row, ENUM_KEYS.enrollment);\nconst lowerListing = (row: CrewServiceListing) => lowerEnumKeys(row, ENUM_KEYS.serviceListing);\nconst lowerBooking = (row: CrewBooking) => lowerEnumKeys(row, ENUM_KEYS.booking);\nconst lowerEscrow = (row: CrewEscrowRecord) => lowerEnumKeys(row, ENUM_KEYS.escrow);\n\n/** Replace a row by id, keeping list order. */\nconst replaceById = <T extends { id: string }>(rows: T[], next: T): T[] =>\n rows.map((row) => (row.id === next.id ? next : row));\n\n/** Re-read the completion dashboard after an enrollment change (best-effort). */\nconst refreshTrainingCompletion = async (\n params: InitParams\n): Promise<CrewTrainingCourseCompletion[] | null> => {\n const data = await runOverlap<{\n crewTrainingCompletionDashboard: CrewTrainingCourseCompletion[];\n }>(TRAINING_COMPLETION_QUERY, undefined, params, 'Unable to load training completion');\n return data?.crewTrainingCompletionDashboard ?? null;\n};\n\n// ── Store Interface ─────────────────────────────────────────────\ninterface CrewFoundryState {\n // Overview\n metrics: OverviewMetric[];\n workItems: WorkItem[];\n selectedView: string;\n\n // Domain data\n employees: Employee[];\n departments: Department[];\n jobPostings: JobPosting[];\n candidates: Candidate[];\n interviews: Interview[];\n announcements: Announcement[];\n teams: Team[];\n projects: Project[];\n payrollRecords: PayrollRecord[];\n leaveRequests: LeaveRequest[];\n timeEntries: TimeEntry[];\n notifications: Notification[];\n vendors: Vendor[];\n clients: Client[];\n employeeDocuments: CrewEmployeeDocument[];\n // BOFF-3717 — skill profiles keyed by employee id, loaded per profile view.\n employeeSkillProfiles: Record<string, CrewEmployeeSkill[]>;\n // BOFF-10361 — workspace skills taxonomy (lazy-loaded by the taxonomy and\n // resourcing pages) and candidate skill profiles keyed by candidate id.\n skillsTaxonomy: CrewTaxonomySkill[];\n skillsTaxonomyLoaded: boolean;\n skillCategories: string[];\n candidateSkillProfiles: Record<string, CrewCandidateSkill[]>;\n onboardings: CrewOnboarding[];\n onboardingsLoaded: boolean;\n // BOFF-4195 — AI-assisted matching. Keyed by jobPostingId so switching\n // between postings' match views doesn't require a refetch each time.\n jobPostingMatches: Record<string, CrewCandidateMatch[]>;\n jobPostingMatchesLoading: boolean;\n\n // BOFF-4193 — native payroll calculation engine. Lazy-loaded (see\n // `fetchPayrollRuns` below), same gating rationale as jobPostingMatches.\n payrollRuns: CrewPayrollRun[];\n payrollRunsLoaded: boolean;\n payrollRunsLoading: boolean;\n // Keyed by payrollRunId so switching between runs' payslip views doesn't\n // require a refetch each time.\n payslipsByRun: Record<string, CrewPayslip[]>;\n payslipsLoading: boolean;\n\n // Workspace skills supply/demand. Lazy-loaded by the resourcing page (see\n // `fetchSkillsGap`), so `skillsGapLoaded` distinguishes \"not fetched yet\"\n // from \"fetched and genuinely empty\" — the two render differently.\n skillsGap: CrewSkillsGapRow[];\n skillsGapLoaded: boolean;\n\n // BOFF-4208 — executive analytics rollup. Lazy-loaded and refreshed by the\n // executive dashboard on every visit (see `fetchExecutiveDashboard`); null\n // until the first successful read. A failed read keeps the last good copy\n // and records the message in `executiveDashboardError`.\n executiveDashboard: CrewExecutiveDashboard | null;\n executiveDashboardLoading: boolean;\n executiveDashboardError: string | null;\n\n // BOFF-3401 — Learning & Development (lazy, see `fetchLearning`).\n trainingCourses: CrewTrainingCourse[];\n enrollments: CrewEnrollment[];\n trainingCompletion: CrewTrainingCourseCompletion[];\n learningLoaded: boolean;\n\n // BOFF-3401 — talent marketplace (lazy, see `fetchMarketplace` /\n // `fetchEscrowRecords`). `escrowError` carries a FORBIDDEN (no\n // crewfoundry-payroll grant) or load failure so the page can say so.\n serviceListings: CrewServiceListing[];\n bookings: CrewBooking[];\n marketplaceLoaded: boolean;\n escrowRecords: CrewEscrowRecord[];\n escrowLoaded: boolean;\n escrowError: string | null;\n\n // Actions\n initialized: boolean;\n loading: boolean;\n error: string | null;\n initParams: InitParams;\n initializeData: (params: InitParams) => Promise<void>;\n setSelectedView: (view: string) => void;\n setWorkItems: (items: WorkItem[]) => void;\n addEmployee: (employee: Employee) => Promise<void>;\n updateEmployee: (id: string, updates: Partial<Employee>) => Promise<void>;\n removeEmployee: (id: string) => Promise<void>;\n addJobPosting: (job: JobPosting) => Promise<void>;\n updateJobPosting: (id: string, updates: Partial<JobPosting>) => Promise<void>;\n addCandidate: (candidate: Candidate) => Promise<void>;\n updateCandidate: (id: string, updates: Partial<Candidate>) => Promise<void>;\n removeJobPosting: (id: string) => Promise<void>;\n removeCandidate: (id: string) => Promise<void>;\n addAnnouncement: (announcement: Announcement) => Promise<void>;\n updateAnnouncement: (id: string, updates: Partial<Announcement>) => Promise<void>;\n removeAnnouncement: (id: string) => Promise<void>;\n addLeaveRequest: (request: LeaveRequest) => Promise<void>;\n updateLeaveRequest: (id: string, updates: Partial<LeaveRequest>) => Promise<void>;\n addInterview: (interview: Interview) => Promise<void>;\n updateInterview: (id: string, updates: Partial<Interview>) => Promise<void>;\n removeInterview: (id: string) => Promise<void>;\n addVendor: (vendor: Vendor) => Promise<void>;\n updateVendor: (id: string, updates: Partial<Vendor>) => Promise<void>;\n removeVendor: (id: string) => Promise<void>;\n addClient: (client: Client) => Promise<void>;\n updateClient: (id: string, updates: Partial<Client>) => Promise<void>;\n removeClient: (id: string) => Promise<void>;\n addTeam: (team: Team) => Promise<void>;\n updateTeam: (id: string, updates: Partial<Team>) => Promise<void>;\n removeTeam: (id: string) => Promise<void>;\n addProject: (project: Project) => Promise<void>;\n updateProject: (id: string, updates: Partial<Project>) => Promise<void>;\n removeProject: (id: string) => Promise<void>;\n addDepartment: (department: Department) => Promise<void>;\n updateDepartment: (id: string, updates: Partial<Department>) => Promise<void>;\n removeDepartment: (id: string) => Promise<void>;\n addPayrollRecord: (record: PayrollRecord) => Promise<void>;\n updatePayrollRecord: (id: string, updates: Partial<PayrollRecord>) => Promise<void>;\n removePayrollRecord: (id: string) => Promise<void>;\n addTimeEntry: (entry: TimeEntry) => Promise<void>;\n updateTimeEntry: (id: string, updates: Partial<TimeEntry>) => Promise<void>;\n removeTimeEntry: (id: string) => Promise<void>;\n markNotificationRead: (id: string) => Promise<void>;\n markAllNotificationsRead: () => Promise<void>;\n\n // BOFF-4195 — AI-assisted candidate/worker matching\n fetchJobPostingMatches: (jobPostingId: string) => Promise<void>;\n\n // BOFF-4193 — native payroll calculation engine\n fetchPayrollRuns: () => Promise<void>;\n createPayrollRun: (input: {\n country: 'US' | 'IN' | 'GB';\n period: string;\n payDate?: string;\n notes?: string;\n employees: CreateCrewPayrollRunEmployeeInput[];\n }) => Promise<void>;\n calculatePayrollRun: (id: string) => Promise<void>;\n approvePayrollRun: (id: string) => Promise<void>;\n removePayrollRun: (id: string) => Promise<void>;\n fetchPayslipsForRun: (payrollRunId: string) => Promise<void>;\n\n // BOFF-3987 — employee documents\n fetchEmployeeDocuments: (employeeId: string) => Promise<void>;\n uploadEmployeeDocument: (params: {\n employeeId: string;\n file: File;\n title: string;\n category?: string;\n }) => Promise<void>;\n detachEmployeeDocument: (id: string) => Promise<void>;\n\n // BOFF-3717 — canonical skills with proficiency\n fetchEmployeeSkillProfile: (employeeId: string) => Promise<void>;\n attachEmployeeSkill: (params: {\n employeeId: string;\n skillName: string;\n proficiency: number | null;\n }) => Promise<void>;\n detachEmployeeSkill: (employeeId: string, skillId: string) => Promise<void>;\n\n // BOFF-10361 — taxonomy administration, find people by skill, candidate skills\n fetchSkillsTaxonomy: () => Promise<void>;\n createTaxonomySkill: (input: {\n name: string;\n category: string;\n aliases: string[];\n description?: string;\n }) => Promise<void>;\n updateTaxonomySkill: (id: string, input: CrewSkillUpdateInput) => Promise<void>;\n mergeTaxonomySkills: (sourceId: string, targetId: string) => Promise<CrewSkillMergeOutcome>;\n removeTaxonomySkill: (id: string) => Promise<void>;\n createSkillRelation: (input: {\n fromSkillId: string;\n toSkillId: string;\n type: string;\n }) => Promise<void>;\n removeSkillRelation: (id: string) => Promise<void>;\n fetchEmployeesBySkill: (\n skillId: string,\n options?: { minProficiency?: number | null; limit?: number }\n ) => Promise<CrewSkillHolderMatch[]>;\n fetchJobPostingSkillRequirements: (\n jobPostingId: string\n ) => Promise<CrewJobPostingSkillRequirement[]>;\n fetchCandidateSkillProfile: (candidateId: string) => Promise<void>;\n attachCandidateSkill: (params: {\n candidateId: string;\n skillName: string;\n proficiency: number | null;\n }) => Promise<void>;\n detachCandidateSkill: (candidateId: string, skillId: string) => Promise<void>;\n\n // BOFF-3983 — onboarding\n fetchOnboardings: () => Promise<void>;\n createOnboarding: (input: {\n candidateId?: string;\n employeeId?: string;\n fullName: string;\n position: string;\n department?: string;\n startDate?: string;\n }) => Promise<void>;\n updateOnboarding: (id: string, updates: Partial<CrewOnboarding>) => Promise<void>;\n removeOnboarding: (id: string) => Promise<void>;\n createOnboardingTask: (input: {\n onboardingId: string;\n stage: OnboardingStage;\n title: string;\n assigneeActorId?: string;\n assigneeName?: string;\n dueDate?: string;\n sortOrder?: number;\n }) => Promise<void>;\n updateOnboardingTask: (id: string, updates: Partial<CrewOnboardingTask>) => Promise<void>;\n removeOnboardingTask: (id: string) => Promise<void>;\n toggleOnboardingTask: (id: string, completed: boolean) => Promise<void>;\n\n fetchSkillsGap: () => Promise<void>;\n fetchExecutiveDashboard: () => Promise<void>;\n\n // BOFF-3401 — Learning & Development\n fetchLearning: () => Promise<void>;\n createTrainingCourse: (input: CrewTrainingCourseInput) => Promise<CrewTrainingCourse>;\n updateTrainingCourse: (id: string, input: Partial<CrewTrainingCourseInput>) => Promise<void>;\n removeTrainingCourse: (id: string) => Promise<void>;\n enrollEmployee: (\n courseId: string,\n employee: Pick<Employee, 'id' | 'firstName' | 'lastName'>\n ) => Promise<void>;\n updateEnrollmentStatus: (id: string, status: CrewEnrollmentStatus) => Promise<void>;\n removeEnrollment: (id: string) => Promise<void>;\n\n // BOFF-3401 — talent marketplace\n fetchMarketplace: () => Promise<void>;\n createServiceListing: (input: CrewServiceListingInput) => Promise<CrewServiceListing>;\n updateServiceListing: (\n id: string,\n input: Partial<Omit<CrewServiceListingInput, 'providerName'>> & {\n status?: CrewServiceListingStatus;\n }\n ) => Promise<void>;\n removeServiceListing: (id: string) => Promise<void>;\n bookServiceListing: (input: CrewBookingInput) => Promise<CrewBooking>;\n updateBookingStatus: (id: string, status: CrewBookingStatus) => Promise<void>;\n fetchEscrowRecords: () => Promise<void>;\n releaseEscrowRecord: (id: string) => Promise<void>;\n cancelEscrowRecord: (id: string) => Promise<void>;\n}\n\nexport const useCrewFoundryStore = create<CrewFoundryState>((set) => ({\n // Overview\n metrics: [\n { label: 'Total Employees', value: '247', trend: '+5.2%' },\n { label: 'Open Positions', value: '24', trend: '+3 this week' },\n { label: 'Hiring Pipeline', value: '347', trend: '+52 applications' },\n { label: 'Employee Satisfaction', value: '4.6/5', trend: '+0.2' },\n ],\n workItems: [\n {\n id: 'w1',\n title: 'Q1 Performance Review Cycle',\n status: 'active',\n owner: 'HR',\n updatedAt: '2h ago',\n },\n {\n id: 'w2',\n title: 'New Health Benefits Enrollment',\n status: 'active',\n owner: 'Benefits',\n updatedAt: '5h ago',\n },\n {\n id: 'w3',\n title: 'Engineering Headcount Planning',\n status: 'at_risk',\n owner: 'Recruiting',\n updatedAt: '1d ago',\n },\n {\n id: 'w4',\n title: 'Employee Onboarding Automation',\n status: 'completed',\n owner: 'HR Ops',\n updatedAt: '2d ago',\n },\n ],\n selectedView: 'overview',\n initialized: false,\n loading: false,\n error: null,\n initParams: {},\n\n // Domain data\n employees: [],\n departments: [],\n jobPostings: [],\n candidates: [],\n interviews: [],\n announcements: [],\n teams: [],\n projects: [],\n payrollRecords: [],\n leaveRequests: [],\n timeEntries: [],\n notifications: [],\n vendors: [],\n clients: [],\n employeeDocuments: [],\n employeeSkillProfiles: {},\n skillsTaxonomy: [],\n skillsTaxonomyLoaded: false,\n skillCategories: [],\n candidateSkillProfiles: {},\n onboardings: [],\n onboardingsLoaded: false,\n jobPostingMatches: {},\n jobPostingMatchesLoading: false,\n payrollRuns: [],\n payrollRunsLoaded: false,\n payrollRunsLoading: false,\n payslipsByRun: {},\n payslipsLoading: false,\n skillsGap: [],\n skillsGapLoaded: false,\n executiveDashboard: null,\n executiveDashboardLoading: false,\n executiveDashboardError: null,\n trainingCourses: [],\n enrollments: [],\n trainingCompletion: [],\n learningLoaded: false,\n serviceListings: [],\n bookings: [],\n marketplaceLoaded: false,\n escrowRecords: [],\n escrowLoaded: false,\n escrowError: null,\n\n // Actions\n initializeData: async (params) => {\n if (!params.workspaceId) {\n return;\n }\n // BOFF-4208: the executive rollup belongs to one workspace; drop it when\n // the host switches workspace so the dashboard never shows another\n // workspace's figures while the new rollup loads.\n if (useCrewFoundryStore.getState().initParams.workspaceId !== params.workspaceId) {\n set({ executiveDashboard: null, executiveDashboardError: null });\n }\n set({ loading: true, error: null, initParams: params });\n try {\n const [workspaceWithOverlapData, payrollData] = await Promise.all([\n runOverlap<WorkspaceBootstrapWithOverlapResponse>(\n WORKSPACE_BOOTSTRAP_WITH_OVERLAP_QUERY,\n {\n workspaceId: params.workspaceId,\n projectPagination: { limit: 50, offset: 0 },\n groupFirst: 30,\n conversationFirst: 30,\n },\n params,\n 'Unable to load workspace bootstrap with overlap data'\n ),\n // Payroll (BOFF-4887): fetched via runOverlap (best-effort), not\n // runGraphql, because crewPayrollRecords is gated by the dedicated\n // crewfoundry-payroll RBAC resource — a caller without that grant\n // (e.g. Workforce Coordinator) gets a FORBIDDEN response here, which\n // must degrade to an empty payroll list, not fail the whole\n // dashboard load.\n runOverlap<CrewPayrollRecordsResponse>(\n CREW_PAYROLL_RECORDS_QUERY,\n undefined,\n params,\n 'Unable to load payroll records'\n ),\n ]);\n\n const bootstrap = workspaceWithOverlapData\n ? workspaceWithOverlapData.crewfoundryBootstrap\n : (\n await runGraphql<BootstrapPayload>(\n BOOTSTRAP_QUERY,\n undefined,\n params,\n 'Unable to load CrewFoundry data'\n )\n ).crewfoundryBootstrap;\n\n const overlapTeams = workspaceWithOverlapData\n ? mapOverlapTeams(workspaceWithOverlapData.groups.edges)\n : [];\n const overlapProjects = workspaceWithOverlapData\n ? mapOverlapProjects(workspaceWithOverlapData.projects.items, overlapTeams)\n : [];\n const overlapNotifications = workspaceWithOverlapData\n ? mapConversationNotifications(workspaceWithOverlapData.conversations.edges)\n : [];\n\n const teams = overlapTeams.length > 0 ? overlapTeams : bootstrap.teams;\n const projects = overlapProjects.length > 0 ? overlapProjects : bootstrap.projects;\n const notifications = overlapNotifications;\n\n // Normalize enum casing (UPPER_SNAKE from the backend -> lower_snake) once, per entity, so\n // every downstream count/filter/badge and the metrics below all operate on the same casing.\n const nEmployees = bootstrap.employees.map((e) => lowerEnumKeys(e, ENUM_KEYS.employee));\n const nDepartments = bootstrap.departments.map((d) => lowerEnumKeys(d, ENUM_KEYS.department));\n const nJobPostings = bootstrap.jobPostings.map((j) => lowerEnumKeys(j, ENUM_KEYS.jobPosting));\n const nCandidates = bootstrap.candidates.map((c) => lowerEnumKeys(c, ENUM_KEYS.candidate));\n const nInterviews = bootstrap.interviews.map((i) => lowerEnumKeys(i, ENUM_KEYS.interview));\n const nAnnouncements = bootstrap.announcements.map((a) =>\n lowerEnumKeys(a, ENUM_KEYS.announcement)\n );\n const nTeams = teams.map((t) => lowerEnumKeys(t, ENUM_KEYS.team));\n const nProjects = projects.map((p) => lowerEnumKeys(p, ENUM_KEYS.project));\n // Payroll (BOFF-4887): sourced from its own dedicated, crewfoundry-payroll\n // gated query, not the bootstrap response — see CREW_PAYROLL_RECORDS_QUERY\n // above. `payrollData` is null when the query fails or the caller lacks\n // payroll access; either way that degrades to an empty list.\n const nPayrollRecords = (payrollData?.crewPayrollRecords ?? []).map((r) =>\n lowerEnumKeys(r, ENUM_KEYS.payrollRecord)\n );\n const nLeaveRequests = bootstrap.leaveRequests.map((r) =>\n lowerEnumKeys(r, ENUM_KEYS.leaveRequest)\n );\n const nTimeEntries = bootstrap.timeEntries.map((t) => lowerEnumKeys(t, ENUM_KEYS.timeEntry));\n const nNotifications = notifications.map((n) => lowerEnumKeys(n, ENUM_KEYS.notification));\n const nVendors = bootstrap.vendors.map((v) => lowerEnumKeys(v, ENUM_KEYS.vendor));\n const nClients = bootstrap.clients.map((c) => lowerEnumKeys(c, ENUM_KEYS.client));\n\n set({\n employees: nEmployees,\n departments: nDepartments,\n jobPostings: nJobPostings,\n candidates: nCandidates,\n interviews: nInterviews,\n announcements: nAnnouncements,\n teams: nTeams,\n projects: nProjects,\n payrollRecords: nPayrollRecords,\n leaveRequests: nLeaveRequests,\n timeEntries: nTimeEntries,\n notifications: nNotifications,\n vendors: nVendors,\n clients: nClients,\n metrics: [\n { label: 'Total Employees', value: String(nEmployees.length), trend: 'Live' },\n {\n label: 'Open Positions',\n value: String(nJobPostings.filter((j) => j.status === 'active').length),\n trend: 'Live',\n },\n { label: 'Hiring Pipeline', value: String(nCandidates.length), trend: 'Live' },\n {\n label: 'Cross-Team Projects',\n value: String(nProjects.filter((project) => project.status === 'active').length),\n trend: 'Live',\n },\n ],\n initialized: true,\n loading: false,\n });\n } catch (error) {\n set({\n error: error instanceof Error ? error.message : 'Unable to load CrewFoundry data',\n loading: false,\n });\n }\n },\n setSelectedView: (view) => set({ selectedView: view }),\n setWorkItems: (items) => set({ workItems: items }),\n addEmployee: async (employee) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewEmployee: Employee }>(\n CREATE_EMPLOYEE_MUTATION,\n {\n input: {\n ...employee,\n status: normalizeStatus(employee.status),\n type: normalizeStatus(employee.type),\n },\n },\n params,\n 'Unable to create employee'\n );\n set((state) => ({\n employees: [lowerEnumKeys(data.createCrewEmployee, ENUM_KEYS.employee), ...state.employees],\n }));\n },\n updateEmployee: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const payload = {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n };\n const data = await runGraphql<{ updateCrewEmployee: Employee }>(\n UPDATE_EMPLOYEE_MUTATION,\n { id, input: payload },\n params,\n 'Unable to update employee'\n );\n set((state) => ({\n employees: state.employees.map((e) =>\n e.id === id ? lowerEnumKeys(data.updateCrewEmployee, ENUM_KEYS.employee) : e\n ),\n }));\n },\n removeEmployee: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewEmployee: boolean }>(\n REMOVE_EMPLOYEE_MUTATION,\n { id },\n params,\n 'Unable to remove employee'\n );\n set((state) => ({ employees: state.employees.filter((e) => e.id !== id) }));\n },\n addJobPosting: async (job) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewJobPosting: JobPosting }>(\n CREATE_JOB_MUTATION,\n {\n input: {\n ...job,\n status: normalizeStatus(job.status),\n },\n },\n params,\n 'Unable to create job posting'\n );\n set((state) => ({\n jobPostings: [\n lowerEnumKeys(data.createCrewJobPosting, ENUM_KEYS.jobPosting),\n ...state.jobPostings,\n ],\n }));\n },\n updateJobPosting: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewJobPosting: JobPosting }>(\n UPDATE_JOB_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update job posting'\n );\n set((state) => ({\n jobPostings: state.jobPostings.map((j) =>\n j.id === id ? lowerEnumKeys(data.updateCrewJobPosting, ENUM_KEYS.jobPosting) : j\n ),\n }));\n },\n addCandidate: async (candidate) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewCandidate: Candidate }>(\n CREATE_CANDIDATE_MUTATION,\n { input: { ...candidate, status: normalizeStatus(candidate.status) } },\n params,\n 'Unable to create candidate'\n );\n set((state) => ({\n candidates: [\n lowerEnumKeys(data.createCrewCandidate, ENUM_KEYS.candidate),\n ...state.candidates,\n ],\n }));\n },\n updateCandidate: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewCandidate: Candidate }>(\n UPDATE_CANDIDATE_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update candidate'\n );\n set((state) => ({\n candidates: state.candidates.map((c) =>\n c.id === id ? lowerEnumKeys(data.updateCrewCandidate, ENUM_KEYS.candidate) : c\n ),\n }));\n },\n addAnnouncement: async (announcement) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewAnnouncement: Announcement }>(\n CREATE_ANNOUNCEMENT_MUTATION,\n { input: announcement },\n params,\n 'Unable to create announcement'\n );\n set((state) => ({\n announcements: [\n lowerEnumKeys(data.createCrewAnnouncement, ENUM_KEYS.announcement),\n ...state.announcements,\n ],\n }));\n },\n addLeaveRequest: async (request) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewLeaveRequest: LeaveRequest }>(\n CREATE_LEAVE_MUTATION,\n {\n input: {\n ...request,\n type: normalizeStatus(request.type),\n status: normalizeStatus(request.status),\n },\n },\n params,\n 'Unable to create leave request'\n );\n set((state) => ({\n leaveRequests: [\n lowerEnumKeys(data.createCrewLeaveRequest, ENUM_KEYS.leaveRequest),\n ...state.leaveRequests,\n ],\n }));\n },\n updateLeaveRequest: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewLeaveRequest: LeaveRequest }>(\n UPDATE_LEAVE_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update leave request'\n );\n set((state) => ({\n leaveRequests: state.leaveRequests.map((l) =>\n l.id === id ? lowerEnumKeys(data.updateCrewLeaveRequest, ENUM_KEYS.leaveRequest) : l\n ),\n }));\n },\n markNotificationRead: async (id) => {\n set((state) => ({\n notifications: state.notifications.map((n) => (n.id === id ? { ...n, read: true } : n)),\n }));\n },\n markAllNotificationsRead: async () => {\n set((state) => ({ notifications: state.notifications.map((n) => ({ ...n, read: true })) }));\n },\n\n // ── Extra removes for existing entities ───────────────────────\n removeJobPosting: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewJobPosting: boolean }>(\n REMOVE_JOB_MUTATION,\n { id },\n params,\n 'Unable to remove job posting'\n );\n set((state) => ({ jobPostings: state.jobPostings.filter((j) => j.id !== id) }));\n },\n removeCandidate: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewCandidate: boolean }>(\n REMOVE_CANDIDATE_MUTATION,\n { id },\n params,\n 'Unable to remove candidate'\n );\n set((state) => ({ candidates: state.candidates.filter((c) => c.id !== id) }));\n },\n updateAnnouncement: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewAnnouncement: Announcement }>(\n UPDATE_ANNOUNCEMENT_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update announcement'\n );\n set((state) => ({\n announcements: state.announcements.map((a) =>\n a.id === id ? lowerEnumKeys(data.updateCrewAnnouncement, ENUM_KEYS.announcement) : a\n ),\n }));\n },\n removeAnnouncement: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewAnnouncement: boolean }>(\n REMOVE_ANNOUNCEMENT_MUTATION,\n { id },\n params,\n 'Unable to remove announcement'\n );\n set((state) => ({ announcements: state.announcements.filter((a) => a.id !== id) }));\n },\n\n // ── Interview (enum: type, status) ────────────────────────────\n addInterview: async (interview) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewInterview: Interview }>(\n CREATE_INTERVIEW_MUTATION,\n {\n input: {\n ...interview,\n type: normalizeStatus(interview.type),\n status: normalizeStatus(interview.status),\n },\n },\n params,\n 'Unable to schedule interview'\n );\n set((state) => ({\n interviews: [\n lowerEnumKeys(data.createCrewInterview, ENUM_KEYS.interview),\n ...state.interviews,\n ],\n }));\n },\n updateInterview: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewInterview: Interview }>(\n UPDATE_INTERVIEW_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.type ? { type: normalizeStatus(updates.type) } : {}),\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update interview'\n );\n set((state) => ({\n interviews: state.interviews.map((i) =>\n i.id === id ? lowerEnumKeys(data.updateCrewInterview, ENUM_KEYS.interview) : i\n ),\n }));\n },\n removeInterview: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewInterview: boolean }>(\n REMOVE_INTERVIEW_MUTATION,\n { id },\n params,\n 'Unable to remove interview'\n );\n set((state) => ({ interviews: state.interviews.filter((i) => i.id !== id) }));\n },\n\n // ── Vendor (enum: status) ─────────────────────────────────────\n addVendor: async (vendor) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewVendor: Vendor }>(\n CREATE_VENDOR_MUTATION,\n { input: { ...vendor, status: normalizeStatus(vendor.status) } },\n params,\n 'Unable to create vendor'\n );\n set((state) => ({\n vendors: [lowerEnumKeys(data.createCrewVendor, ENUM_KEYS.vendor), ...state.vendors],\n }));\n },\n updateVendor: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewVendor: Vendor }>(\n UPDATE_VENDOR_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update vendor'\n );\n set((state) => ({\n vendors: state.vendors.map((v) =>\n v.id === id ? lowerEnumKeys(data.updateCrewVendor, ENUM_KEYS.vendor) : v\n ),\n }));\n },\n removeVendor: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewVendor: boolean }>(\n REMOVE_VENDOR_MUTATION,\n { id },\n params,\n 'Unable to remove vendor'\n );\n set((state) => ({ vendors: state.vendors.filter((v) => v.id !== id) }));\n },\n\n // ── Client (enum: status; `since`) ────────────────────────────\n addClient: async (client) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewClient: Client }>(\n CREATE_CLIENT_MUTATION,\n { input: { ...client, status: normalizeStatus(client.status) } },\n params,\n 'Unable to create client'\n );\n set((state) => ({\n clients: [lowerEnumKeys(data.createCrewClient, ENUM_KEYS.client), ...state.clients],\n }));\n },\n updateClient: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewClient: Client }>(\n UPDATE_CLIENT_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update client'\n );\n set((state) => ({\n clients: state.clients.map((c) =>\n c.id === id ? lowerEnumKeys(data.updateCrewClient, ENUM_KEYS.client) : c\n ),\n }));\n },\n removeClient: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewClient: boolean }>(\n REMOVE_CLIENT_MUTATION,\n { id },\n params,\n 'Unable to remove client'\n );\n set((state) => ({ clients: state.clients.filter((c) => c.id !== id) }));\n },\n\n // ── Team (plain status; not normalized) ───────────────────────\n addTeam: async (team) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTeam: Team }>(\n CREATE_TEAM_MUTATION,\n { input: team },\n params,\n 'Unable to create team'\n );\n set((state) => ({\n teams: [lowerEnumKeys(data.createCrewTeam, ENUM_KEYS.team), ...state.teams],\n }));\n },\n updateTeam: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTeam: Team }>(\n UPDATE_TEAM_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update team'\n );\n set((state) => ({\n teams: state.teams.map((t) =>\n t.id === id ? lowerEnumKeys(data.updateCrewTeam, ENUM_KEYS.team) : t\n ),\n }));\n },\n removeTeam: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTeam: boolean }>(\n REMOVE_TEAM_MUTATION,\n { id },\n params,\n 'Unable to remove team'\n );\n set((state) => ({ teams: state.teams.filter((t) => t.id !== id) }));\n },\n\n // ── Project (enum: status, priority) ──────────────────────────\n addProject: async (project) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewProject: Project }>(\n CREATE_PROJECT_MUTATION,\n {\n input: {\n ...project,\n status: normalizeStatus(project.status),\n priority: normalizeStatus(project.priority),\n },\n },\n params,\n 'Unable to create project'\n );\n set((state) => ({\n projects: [lowerEnumKeys(data.createCrewProject, ENUM_KEYS.project), ...state.projects],\n }));\n },\n updateProject: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewProject: Project }>(\n UPDATE_PROJECT_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n ...(updates.priority ? { priority: normalizeStatus(updates.priority) } : {}),\n },\n },\n params,\n 'Unable to update project'\n );\n set((state) => ({\n projects: state.projects.map((p) =>\n p.id === id ? lowerEnumKeys(data.updateCrewProject, ENUM_KEYS.project) : p\n ),\n }));\n },\n removeProject: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewProject: boolean }>(\n REMOVE_PROJECT_MUTATION,\n { id },\n params,\n 'Unable to remove project'\n );\n set((state) => ({ projects: state.projects.filter((p) => p.id !== id) }));\n },\n\n // ── Department (plain status; not normalized) ─────────────────\n addDepartment: async (department) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewDepartment: Department }>(\n CREATE_DEPARTMENT_MUTATION,\n { input: department },\n params,\n 'Unable to create department'\n );\n set((state) => ({\n departments: [\n lowerEnumKeys(data.createCrewDepartment, ENUM_KEYS.department),\n ...state.departments,\n ],\n }));\n },\n updateDepartment: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewDepartment: Department }>(\n UPDATE_DEPARTMENT_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update department'\n );\n set((state) => ({\n departments: state.departments.map((d) =>\n d.id === id ? lowerEnumKeys(data.updateCrewDepartment, ENUM_KEYS.department) : d\n ),\n }));\n },\n removeDepartment: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewDepartment: boolean }>(\n REMOVE_DEPARTMENT_MUTATION,\n { id },\n params,\n 'Unable to remove department'\n );\n set((state) => ({ departments: state.departments.filter((d) => d.id !== id) }));\n },\n\n // ── PayrollRecord (enum: status) ──────────────────────────────\n addPayrollRecord: async (record) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewPayrollRecord: PayrollRecord }>(\n CREATE_PAYROLL_MUTATION,\n { input: { ...record, status: normalizeStatus(record.status) } },\n params,\n 'Unable to create payroll record'\n );\n set((state) => ({\n payrollRecords: [\n lowerEnumKeys(data.createCrewPayrollRecord, ENUM_KEYS.payrollRecord),\n ...state.payrollRecords,\n ],\n }));\n },\n updatePayrollRecord: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewPayrollRecord: PayrollRecord }>(\n UPDATE_PAYROLL_MUTATION,\n {\n id,\n input: {\n ...updates,\n ...(updates.status ? { status: normalizeStatus(updates.status) } : {}),\n },\n },\n params,\n 'Unable to update payroll record'\n );\n set((state) => ({\n payrollRecords: state.payrollRecords.map((p) =>\n p.id === id ? lowerEnumKeys(data.updateCrewPayrollRecord, ENUM_KEYS.payrollRecord) : p\n ),\n }));\n },\n removePayrollRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewPayrollRecord: boolean }>(\n REMOVE_PAYROLL_MUTATION,\n { id },\n params,\n 'Unable to remove payroll record'\n );\n set((state) => ({ payrollRecords: state.payrollRecords.filter((p) => p.id !== id) }));\n },\n\n // ── TimeEntry (plain status; not normalized) ──────────────────\n addTimeEntry: async (entry) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTimeEntry: TimeEntry }>(\n CREATE_TIME_ENTRY_MUTATION,\n { input: entry },\n params,\n 'Unable to create time entry'\n );\n set((state) => ({\n timeEntries: [\n lowerEnumKeys(data.createCrewTimeEntry, ENUM_KEYS.timeEntry),\n ...state.timeEntries,\n ],\n }));\n },\n updateTimeEntry: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTimeEntry: TimeEntry }>(\n UPDATE_TIME_ENTRY_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update time entry'\n );\n set((state) => ({\n timeEntries: state.timeEntries.map((t) =>\n t.id === id ? lowerEnumKeys(data.updateCrewTimeEntry, ENUM_KEYS.timeEntry) : t\n ),\n }));\n },\n removeTimeEntry: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTimeEntry: boolean }>(\n REMOVE_TIME_ENTRY_MUTATION,\n { id },\n params,\n 'Unable to remove time entry'\n );\n set((state) => ({ timeEntries: state.timeEntries.filter((t) => t.id !== id) }));\n },\n\n // ── BOFF-4195: AI-assisted candidate/worker matching ────────────\n fetchJobPostingMatches: async (jobPostingId) => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ jobPostingMatchesLoading: true });\n try {\n const data = await runGraphql<{ crewJobPostingMatches: CrewCandidateMatch[] }>(\n JOB_POSTING_MATCHES_QUERY,\n { jobPostingId },\n params,\n 'Unable to load candidate matches'\n );\n const normalized = data.crewJobPostingMatches.map((match) => ({\n ...match,\n candidate: lowerEnumKeys(match.candidate, ENUM_KEYS.candidate),\n }));\n set((state) => ({\n jobPostingMatches: { ...state.jobPostingMatches, [jobPostingId]: normalized },\n jobPostingMatchesLoading: false,\n }));\n } catch (err) {\n set({ jobPostingMatchesLoading: false });\n throw err;\n }\n },\n\n // ── BOFF-4193: native payroll calculation engine ────────────────\n fetchPayrollRuns: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ payrollRunsLoading: true });\n try {\n const data = await runGraphql<{ crewPayrollRuns: CrewPayrollRun[] }>(\n CREW_PAYROLL_RUNS_QUERY,\n undefined,\n params,\n 'Unable to load payroll runs'\n );\n set({\n payrollRuns: data.crewPayrollRuns,\n payrollRunsLoaded: true,\n payrollRunsLoading: false,\n });\n } catch (err) {\n set({ payrollRunsLoading: false });\n throw err;\n }\n },\n createPayrollRun: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewPayrollRun: CrewPayrollRun }>(\n CREATE_PAYROLL_RUN_MUTATION,\n { input },\n params,\n 'Unable to create payroll run'\n );\n set((state) => ({ payrollRuns: [data.createCrewPayrollRun, ...state.payrollRuns] }));\n },\n calculatePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ calculateCrewPayrollRun: CrewPayrollRun }>(\n CALCULATE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to calculate payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.map((r) => (r.id === id ? data.calculateCrewPayrollRun : r)),\n // Recalculating replaces the run's payslips server-side — drop any\n // previously cached payslip view for this run so the next open\n // refetches the fresh set instead of showing stale figures.\n payslipsByRun: Object.fromEntries(\n Object.entries(state.payslipsByRun).filter(([runId]) => runId !== id)\n ),\n }));\n },\n approvePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ approveCrewPayrollRun: CrewPayrollRun }>(\n APPROVE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to approve payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.map((r) => (r.id === id ? data.approveCrewPayrollRun : r)),\n }));\n },\n removePayrollRun: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewPayrollRun: boolean }>(\n REMOVE_PAYROLL_RUN_MUTATION,\n { id },\n params,\n 'Unable to remove payroll run'\n );\n set((state) => ({\n payrollRuns: state.payrollRuns.filter((r) => r.id !== id),\n payslipsByRun: Object.fromEntries(\n Object.entries(state.payslipsByRun).filter(([runId]) => runId !== id)\n ),\n }));\n },\n fetchPayslipsForRun: async (payrollRunId) => {\n const params = useCrewFoundryStore.getState().initParams;\n set({ payslipsLoading: true });\n try {\n const data = await runGraphql<{ crewPayslips: CrewPayslip[] }>(\n CREW_PAYSLIPS_QUERY,\n { filter: { payrollRunId } },\n params,\n 'Unable to load payslips'\n );\n set((state) => ({\n payslipsByRun: { ...state.payslipsByRun, [payrollRunId]: data.crewPayslips },\n payslipsLoading: false,\n }));\n } catch (err) {\n set({ payslipsLoading: false });\n throw err;\n }\n },\n\n // ── BOFF-3987: employee documents ──────────────────────────────\n fetchEmployeeDocuments: async (employeeId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ employeeDocuments: CrewEmployeeDocument[] }>(\n EMPLOYEE_DOCUMENTS_QUERY,\n { employeeId },\n params,\n 'Unable to load employee documents'\n );\n set((state) => ({\n // Replace only this employee's documents; leave any other employee's\n // already-fetched documents in the flat cache untouched.\n employeeDocuments: [\n ...state.employeeDocuments.filter((d) => d.employeeId !== employeeId),\n ...data.employeeDocuments,\n ],\n }));\n },\n uploadEmployeeDocument: async ({ employeeId, file, title, category }) => {\n const params = useCrewFoundryStore.getState().initParams;\n\n const folder = await runGraphql<{ ensureFolderByPath: { id: string } }>(\n ENSURE_FOLDER_BY_PATH_MUTATION,\n { path: '/CrewFoundry/Employee Documents' },\n params,\n 'Unable to resolve the employee documents folder'\n );\n\n const extension = file.name.includes('.')\n ? file.name.substring(file.name.lastIndexOf('.') + 1)\n : '';\n const initiated = await runGraphql<{\n initiateUpload: { session: { id: string }; uploadUrl: string | null };\n }>(\n INITIATE_UPLOAD_MUTATION,\n {\n input: {\n fileName: file.name,\n fileSize: String(file.size),\n mimeType: file.type || 'application/octet-stream',\n extension,\n folderId: folder.ensureFolderByPath.id,\n },\n },\n params,\n 'Unable to start the document upload'\n );\n\n if (initiated.initiateUpload.uploadUrl) {\n const putResponse = await fetch(initiated.initiateUpload.uploadUrl, {\n method: 'PUT',\n headers: { 'Content-Type': file.type || 'application/octet-stream' },\n body: file,\n });\n if (!putResponse.ok) {\n throw new Error(`Failed to upload file bytes (status ${putResponse.status})`);\n }\n }\n\n const completed = await runGraphql<{ completeUpload: { file: { id: string } } }>(\n COMPLETE_UPLOAD_MUTATION,\n {\n input: {\n sessionId: initiated.initiateUpload.session.id,\n fileSize: String(file.size),\n folderId: folder.ensureFolderByPath.id,\n },\n },\n params,\n 'Unable to finish the document upload'\n );\n\n const attached = await runGraphql<{ attachEmployeeDocument: CrewEmployeeDocument }>(\n ATTACH_EMPLOYEE_DOCUMENT_MUTATION,\n {\n input: {\n employeeId,\n fileId: completed.completeUpload.file.id,\n title,\n category: category || undefined,\n },\n },\n params,\n 'Unable to attach the document to this employee'\n );\n\n set((state) => ({\n employeeDocuments: [attached.attachEmployeeDocument, ...state.employeeDocuments],\n }));\n },\n detachEmployeeDocument: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachEmployeeDocument: boolean }>(\n DETACH_EMPLOYEE_DOCUMENT_MUTATION,\n { id },\n params,\n 'Unable to remove this document'\n );\n set((state) => ({\n employeeDocuments: state.employeeDocuments.filter((d) => d.id !== id),\n }));\n },\n\n // ── BOFF-3717: canonical skills ─────────────────────────────────\n fetchEmployeeSkillProfile: async (employeeId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{\n crewEmployee: { id: string; skills: string[]; skillProfile: CrewEmployeeSkill[] } | null;\n }>(EMPLOYEE_SKILL_PROFILE_QUERY, { id: employeeId }, params, 'Unable to load skills');\n const record = data.crewEmployee;\n set((state) => ({\n employeeSkillProfiles: {\n ...state.employeeSkillProfiles,\n [employeeId]: record?.skillProfile ?? [],\n },\n employees: record\n ? state.employees.map((employee) =>\n employee.id === employeeId ? { ...employee, skills: record.skills } : employee\n )\n : state.employees,\n }));\n },\n attachEmployeeSkill: async ({ employeeId, skillName, proficiency }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ attachCrewSkill: { id: string } }>(\n ATTACH_CREW_SKILL_MUTATION,\n { input: { employeeId, skillName, proficiency } },\n params,\n 'Unable to add this skill'\n );\n await useCrewFoundryStore.getState().fetchEmployeeSkillProfile(employeeId);\n },\n detachEmployeeSkill: async (employeeId, skillId) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachCrewSkill: boolean }>(\n DETACH_CREW_SKILL_MUTATION,\n { employeeId, skillId },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchEmployeeSkillProfile(employeeId);\n },\n\n // ── BOFF-10361: skills taxonomy administration ──────────────────\n fetchSkillsTaxonomy: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const loadPages = async () => {\n const all: CrewTaxonomySkill[] = [];\n for (let page = 0; page < TAXONOMY_MAX_PAGES; page += 1) {\n const data = await runGraphql<{ crewSkills: CrewTaxonomySkill[] }>(\n CREW_SKILLS_TAXONOMY_QUERY,\n { pagination: { limit: TAXONOMY_PAGE_SIZE, offset: page * TAXONOMY_PAGE_SIZE } },\n params,\n 'Unable to load the skills taxonomy'\n );\n all.push(...data.crewSkills);\n if (data.crewSkills.length < TAXONOMY_PAGE_SIZE) break;\n }\n return all;\n };\n const [skills, categories] = await Promise.all([\n loadPages(),\n runGraphql<{ crewSkillCategories: string[] }>(\n CREW_SKILL_CATEGORIES_QUERY,\n undefined,\n params,\n 'Unable to load skill categories'\n ),\n ]);\n set({\n skillsTaxonomy: skills,\n skillsTaxonomyLoaded: true,\n skillCategories: categories.crewSkillCategories,\n });\n },\n createTaxonomySkill: async ({ name, category, aliases, description }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ createCrewSkill: { id: string } }>(\n CREATE_CREW_SKILL_MUTATION,\n { input: { name, category, aliases, ...(description ? { description } : {}) } },\n params,\n 'Unable to create this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n updateTaxonomySkill: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ updateCrewSkill: { id: string } }>(\n UPDATE_CREW_SKILL_MUTATION,\n { id, input },\n params,\n 'Unable to update this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n mergeTaxonomySkills: async (sourceId, targetId): Promise<CrewSkillMergeOutcome> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: { mergeCrewSkills: MergeCrewSkillsPayload } = await runGraphql<{\n mergeCrewSkills: MergeCrewSkillsPayload;\n }>(MERGE_CREW_SKILLS_MUTATION, { sourceId, targetId }, params, 'Unable to merge these skills');\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n const result = data.mergeCrewSkills;\n return {\n targetName: result.target.name,\n employeesMoved: result.employeesMoved,\n candidatesMoved: result.candidatesMoved,\n jobPostingsMoved: result.jobPostingsMoved,\n };\n },\n removeTaxonomySkill: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewSkill: boolean }>(\n REMOVE_CREW_SKILL_MUTATION,\n { id },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n createSkillRelation: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ createCrewSkillRelation: { id: string } }>(\n CREATE_CREW_SKILL_RELATION_MUTATION,\n { input },\n params,\n 'Unable to add this relation'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n removeSkillRelation: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewSkillRelation: boolean }>(\n REMOVE_CREW_SKILL_RELATION_MUTATION,\n { id },\n params,\n 'Unable to remove this relation'\n );\n await useCrewFoundryStore.getState().fetchSkillsTaxonomy();\n },\n fetchEmployeesBySkill: async (skillId, options): Promise<CrewSkillHolderMatch[]> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: { crewEmployeesBySkill: CrewSkillHolderMatch[] } = await runGraphql<{\n crewEmployeesBySkill: CrewSkillHolderMatch[];\n }>(\n CREW_EMPLOYEES_BY_SKILL_QUERY,\n {\n skillId,\n minProficiency: options?.minProficiency ?? null,\n limit: options?.limit ?? 50,\n },\n params,\n 'Unable to find people with this skill'\n );\n return data.crewEmployeesBySkill;\n },\n fetchJobPostingSkillRequirements: async (\n jobPostingId\n ): Promise<CrewJobPostingSkillRequirement[]> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data: {\n crewJobPosting: { id: string; skillRequirements: CrewJobPostingSkillRequirement[] } | null;\n } = await runGraphql<{\n crewJobPosting: { id: string; skillRequirements: CrewJobPostingSkillRequirement[] } | null;\n }>(\n JOB_POSTING_SKILL_REQUIREMENTS_QUERY,\n { id: jobPostingId },\n params,\n 'Unable to load the skills this role needs'\n );\n return data.crewJobPosting?.skillRequirements ?? [];\n },\n fetchCandidateSkillProfile: async (candidateId) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{\n crewCandidate: { id: string; skills: string[]; skillProfile: CrewCandidateSkill[] } | null;\n }>(CANDIDATE_SKILL_PROFILE_QUERY, { id: candidateId }, params, 'Unable to load skills');\n const record = data.crewCandidate;\n set((state) => ({\n candidateSkillProfiles: {\n ...state.candidateSkillProfiles,\n [candidateId]: record?.skillProfile ?? [],\n },\n candidates: record\n ? state.candidates.map((candidate) =>\n candidate.id === candidateId ? { ...candidate, skills: record.skills } : candidate\n )\n : state.candidates,\n }));\n },\n attachCandidateSkill: async ({ candidateId, skillName, proficiency }) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ attachCrewCandidateSkill: { id: string } }>(\n ATTACH_CANDIDATE_SKILL_MUTATION,\n { input: { candidateId, skillName, proficiency } },\n params,\n 'Unable to add this skill'\n );\n await useCrewFoundryStore.getState().fetchCandidateSkillProfile(candidateId);\n },\n detachCandidateSkill: async (candidateId, skillId) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ detachCrewCandidateSkill: boolean }>(\n DETACH_CANDIDATE_SKILL_MUTATION,\n { candidateId, skillId },\n params,\n 'Unable to remove this skill'\n );\n await useCrewFoundryStore.getState().fetchCandidateSkillProfile(candidateId);\n },\n\n // ── BOFF-3983: onboarding ───────────────────────────────────────\n fetchOnboardings: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ crewOnboardings: CrewOnboarding[] }>(\n ONBOARDINGS_QUERY,\n {},\n params,\n 'Unable to load onboarding'\n );\n set({\n onboardings: data.crewOnboardings.map(lowerOnboarding),\n onboardingsLoaded: true,\n });\n },\n createOnboarding: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewOnboarding: CrewOnboarding }>(\n CREATE_ONBOARDING_MUTATION,\n { input },\n params,\n 'Unable to start onboarding'\n );\n set((state) => ({\n onboardings: [lowerOnboarding(data.createCrewOnboarding), ...state.onboardings],\n }));\n },\n updateOnboarding: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewOnboarding: CrewOnboarding }>(\n UPDATE_ONBOARDING_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update onboarding'\n );\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === id ? lowerOnboarding(data.updateCrewOnboarding) : o\n ),\n }));\n },\n removeOnboarding: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewOnboarding: boolean }>(\n REMOVE_ONBOARDING_MUTATION,\n { id },\n params,\n 'Unable to remove onboarding'\n );\n set((state) => ({ onboardings: state.onboardings.filter((o) => o.id !== id) }));\n },\n createOnboardingTask: async (input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewOnboardingTask: CrewOnboardingTask }>(\n CREATE_ONBOARDING_TASK_MUTATION,\n { input },\n params,\n 'Unable to create onboarding task'\n );\n const task = lowerEnumKeys(data.createCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === task.onboardingId\n ? {\n ...o,\n tasks: [...o.tasks, task],\n totalTaskCount: o.totalTaskCount + 1,\n }\n : o\n ),\n }));\n },\n updateOnboardingTask: async (id, updates) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewOnboardingTask: CrewOnboardingTask }>(\n UPDATE_ONBOARDING_TASK_MUTATION,\n { id, input: updates },\n params,\n 'Unable to update onboarding task'\n );\n const task = lowerEnumKeys(data.updateCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) =>\n o.id === task.onboardingId\n ? { ...o, tasks: o.tasks.map((t) => (t.id === id ? task : t)) }\n : o\n ),\n }));\n },\n removeOnboardingTask: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewOnboardingTask: boolean }>(\n REMOVE_ONBOARDING_TASK_MUTATION,\n { id },\n params,\n 'Unable to remove onboarding task'\n );\n set((state) => ({\n onboardings: state.onboardings.map((o) => {\n if (!o.tasks.some((t) => t.id === id)) return o;\n return {\n ...o,\n tasks: o.tasks.filter((t) => t.id !== id),\n totalTaskCount: Math.max(0, o.totalTaskCount - 1),\n };\n }),\n }));\n },\n toggleOnboardingTask: async (id, completed) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ toggleCrewOnboardingTask: CrewOnboardingTask }>(\n TOGGLE_ONBOARDING_TASK_MUTATION,\n { id, completed },\n params,\n 'Unable to update onboarding task'\n );\n const task = lowerEnumKeys(data.toggleCrewOnboardingTask, ENUM_KEYS.onboardingTask);\n set((state) => ({\n onboardings: state.onboardings.map((o) => {\n if (o.id !== task.onboardingId) return o;\n const tasks = o.tasks.map((t) => (t.id === id ? task : t));\n const completedTaskCount = tasks.filter((t) => t.completedAt).length;\n return {\n ...o,\n tasks,\n completedTaskCount,\n progressPercent:\n tasks.length === 0 ? 0 : Math.round((completedTaskCount / tasks.length) * 1000) / 10,\n };\n }),\n }));\n },\n\n // ── Skills supply/demand ────────────────────────────────────────\n fetchSkillsGap: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ crewSkillsGap: CrewSkillsGapRow[] }>(\n SKILLS_GAP_QUERY,\n undefined,\n params,\n 'Unable to load skills coverage'\n );\n // No enum normalization: every field is a plain string/number, and `skill`\n // is a free-text tag whose casing must be preserved as recorded.\n set({ skillsGap: data.crewSkillsGap, skillsGapLoaded: true });\n },\n\n // ── BOFF-4208 — executive analytics rollup ─────────────────────\n fetchExecutiveDashboard: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n // A response for a workspace the host has since left must not land.\n const isStale = () =>\n useCrewFoundryStore.getState().initParams.workspaceId !== params.workspaceId;\n set({ executiveDashboardLoading: true, executiveDashboardError: null });\n try {\n const data = await runGraphql<{ crewExecutiveDashboard: CrewExecutiveDashboard }>(\n EXECUTIVE_DASHBOARD_QUERY,\n undefined,\n params,\n 'Unable to load workforce analytics'\n );\n if (isStale()) return;\n set({ executiveDashboard: data.crewExecutiveDashboard, executiveDashboardLoading: false });\n } catch (err) {\n if (isStale()) return;\n // Recorded rather than rethrown: the dashboard renders the message with\n // a retry, and there is no other caller to propagate to.\n set({\n executiveDashboardLoading: false,\n executiveDashboardError:\n err instanceof Error ? err.message : 'Unable to load workforce analytics',\n });\n }\n },\n\n // ── BOFF-3401 — Learning & Development ────────────────────────\n fetchLearning: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n const firstPage = { limit: LIST_PAGE_SIZE, offset: 0 };\n for (let attempt = 1; attempt <= WRITE_RACE_RETRIES; attempt += 1) {\n const writesAtStart = sliceWrites.learning;\n const data = await runGraphql<{\n crewTrainingCourses: CrewTrainingCourse[];\n crewEnrollments: CrewEnrollment[];\n crewTrainingCompletionDashboard: CrewTrainingCourseCompletion[];\n }>(\n LEARNING_QUERY,\n { coursePage: firstPage, enrollmentPage: firstPage },\n params,\n 'Unable to load learning'\n );\n const [courses, enrollments] = await Promise.all([\n fetchAllPages<CrewTrainingCourse>(\n TRAINING_COURSES_PAGE_QUERY,\n 'crewTrainingCourses',\n params,\n 'Unable to load courses',\n data.crewTrainingCourses\n ),\n fetchAllPages<CrewEnrollment>(\n ENROLLMENTS_PAGE_QUERY,\n 'crewEnrollments',\n params,\n 'Unable to load enrollments',\n data.crewEnrollments\n ),\n ]);\n if (writesAtStart !== sliceWrites.learning && attempt < WRITE_RACE_RETRIES) {\n continue;\n }\n set({\n trainingCourses: courses,\n enrollments: enrollments.map(lowerEnrollment),\n trainingCompletion: data.crewTrainingCompletionDashboard,\n learningLoaded: true,\n });\n return;\n }\n },\n createTrainingCourse: async (input): Promise<CrewTrainingCourse> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewTrainingCourse: CrewTrainingCourse }>(\n CREATE_TRAINING_COURSE_MUTATION,\n { input },\n params,\n 'Unable to create course'\n );\n const course = data.createCrewTrainingCourse;\n sliceWrites.learning += 1;\n set((state) => ({ trainingCourses: [course, ...state.trainingCourses] }));\n return course;\n },\n updateTrainingCourse: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewTrainingCourse: CrewTrainingCourse }>(\n UPDATE_TRAINING_COURSE_MUTATION,\n { id, input },\n params,\n 'Unable to update course'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n trainingCourses: replaceById(state.trainingCourses, data.updateCrewTrainingCourse),\n }));\n },\n removeTrainingCourse: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewTrainingCourse: boolean }>(\n REMOVE_TRAINING_COURSE_MUTATION,\n { id },\n params,\n 'Unable to remove course'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n trainingCourses: state.trainingCourses.filter((course) => course.id !== id),\n trainingCompletion: state.trainingCompletion.filter((row) => row.courseId !== id),\n }));\n },\n enrollEmployee: async (courseId, employee) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewEnrollment: CrewEnrollment }>(\n CREATE_ENROLLMENT_MUTATION,\n {\n input: {\n courseId,\n employeeId: employee.id,\n employeeName: `${employee.firstName} ${employee.lastName}`.trim(),\n },\n },\n params,\n 'Unable to enroll employee'\n );\n // The service is idempotent on (course, employee): an existing enrollment\n // comes back unchanged, so upsert instead of blindly prepending.\n const enrollment = lowerEnrollment(data.createCrewEnrollment);\n sliceWrites.learning += 1;\n set((state) => ({\n enrollments: state.enrollments.some((row) => row.id === enrollment.id)\n ? replaceById(state.enrollments, enrollment)\n : [enrollment, ...state.enrollments],\n }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n updateEnrollmentStatus: async (id, status) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateCrewEnrollmentStatus: CrewEnrollment }>(\n UPDATE_ENROLLMENT_STATUS_MUTATION,\n { id, status: normalizeStatus(status) },\n params,\n 'Unable to update enrollment'\n );\n sliceWrites.learning += 1;\n set((state) => ({\n enrollments: replaceById(state.enrollments, lowerEnrollment(data.updateCrewEnrollmentStatus)),\n }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n removeEnrollment: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeCrewEnrollment: boolean }>(\n REMOVE_ENROLLMENT_MUTATION,\n { id },\n params,\n 'Unable to remove enrollment'\n );\n sliceWrites.learning += 1;\n set((state) => ({ enrollments: state.enrollments.filter((row) => row.id !== id) }));\n const completion = await refreshTrainingCompletion(params);\n if (completion) set({ trainingCompletion: completion });\n },\n\n // ── BOFF-3401 — talent marketplace ────────────────────────────\n fetchMarketplace: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n for (let attempt = 1; attempt <= WRITE_RACE_RETRIES; attempt += 1) {\n const writesAtStart = sliceWrites.marketplace;\n const [listings, bookings] = await Promise.all([\n fetchAllPages<CrewServiceListing>(\n SERVICE_LISTINGS_PAGE_QUERY,\n 'crewServiceListings',\n params,\n 'Unable to load marketplace services'\n ),\n fetchAllPages<CrewBooking>(\n BOOKINGS_PAGE_QUERY,\n 'crewBookings',\n params,\n 'Unable to load bookings'\n ),\n ]);\n if (writesAtStart !== sliceWrites.marketplace && attempt < WRITE_RACE_RETRIES) {\n continue;\n }\n set({\n serviceListings: listings.map(lowerListing),\n bookings: bookings.map(lowerBooking),\n marketplaceLoaded: true,\n });\n return;\n }\n },\n createServiceListing: async (input): Promise<CrewServiceListing> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewServiceListing: CrewServiceListing }>(\n CREATE_SERVICE_LISTING_MUTATION,\n { input },\n params,\n 'Unable to publish service'\n );\n const listing = lowerListing(data.createCrewServiceListing);\n sliceWrites.marketplace += 1;\n set((state) => ({ serviceListings: [listing, ...state.serviceListings] }));\n return listing;\n },\n updateServiceListing: async (id, input) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateMyServiceListing: CrewServiceListing }>(\n UPDATE_SERVICE_LISTING_MUTATION,\n { id, input: input.status ? { ...input, status: normalizeStatus(input.status) } : input },\n params,\n 'Unable to update service'\n );\n sliceWrites.marketplace += 1;\n set((state) => ({\n serviceListings: replaceById(\n state.serviceListings,\n lowerListing(data.updateMyServiceListing)\n ),\n }));\n },\n removeServiceListing: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n await runGraphql<{ removeMyServiceListing: boolean }>(\n REMOVE_SERVICE_LISTING_MUTATION,\n { id },\n params,\n 'Unable to remove service'\n );\n sliceWrites.marketplace += 1;\n set((state) => ({ serviceListings: state.serviceListings.filter((row) => row.id !== id) }));\n },\n bookServiceListing: async (input): Promise<CrewBooking> => {\n const params: InitParams = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ createCrewBooking: CrewBooking }>(\n CREATE_BOOKING_MUTATION,\n { input },\n params,\n 'Unable to book service'\n );\n const booking = lowerBooking(data.createCrewBooking);\n // A booking opens a linked escrow ledger row server-side; drop the cached\n // escrow list so the Escrow page re-reads it.\n sliceWrites.marketplace += 1;\n set((state) => ({ bookings: [booking, ...state.bookings], escrowLoaded: false }));\n return booking;\n },\n updateBookingStatus: async (id, status) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ updateMyBookingStatus: CrewBooking }>(\n UPDATE_BOOKING_STATUS_MUTATION,\n { id, status: normalizeStatus(status) },\n params,\n 'Unable to update booking'\n );\n // Completing or cancelling a booking releases/cancels its escrow row.\n sliceWrites.marketplace += 1;\n set((state) => ({\n bookings: replaceById(state.bookings, lowerBooking(data.updateMyBookingStatus)),\n escrowLoaded: false,\n }));\n },\n fetchEscrowRecords: async () => {\n const params = useCrewFoundryStore.getState().initParams;\n try {\n const rows = await fetchAllPages<CrewEscrowRecord>(\n ESCROW_RECORDS_PAGE_QUERY,\n 'crewEscrowRecords',\n params,\n 'Unable to load escrow records'\n );\n set({ escrowRecords: rows.map(lowerEscrow), escrowLoaded: true, escrowError: null });\n } catch (error) {\n set({\n escrowRecords: [],\n escrowLoaded: true,\n escrowError: error instanceof Error ? error.message : 'Unable to load escrow records',\n });\n }\n },\n releaseEscrowRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ releaseCrewEscrowRecord: CrewEscrowRecord }>(\n RELEASE_ESCROW_MUTATION,\n { id },\n params,\n 'Unable to release escrow'\n );\n set((state) => ({\n escrowRecords: replaceById(state.escrowRecords, lowerEscrow(data.releaseCrewEscrowRecord)),\n }));\n },\n cancelEscrowRecord: async (id) => {\n const params = useCrewFoundryStore.getState().initParams;\n const data = await runGraphql<{ cancelCrewEscrowRecord: CrewEscrowRecord }>(\n CANCEL_ESCROW_MUTATION,\n { id },\n params,\n 'Unable to cancel escrow'\n );\n set((state) => ({\n escrowRecords: replaceById(state.escrowRecords, lowerEscrow(data.cancelCrewEscrowRecord)),\n }));\n },\n}));\n"],"mappings":";;;AA0oBA,IAAM,IAAkB,6hDA2BlB,IAA6B,0KAU7B,IAAyC,65EAgEzC,IAA2B,gQAC3B,IAA2B,mRAC3B,IAA2B,yEAC3B,IAAsB,+PACtB,IAAsB,kRACtB,IAA4B,qPAC5B,IAA4B,wQAC5B,IAA+B,8MAC/B,IAAwB,oNACxB,IAAwB,uOAExB,IAAsB,6EACtB,IAA4B,2EAC5B,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