@adaptware/eagles-db 0.4.46 → 0.5.2

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 (32) hide show
  1. package/client/edge.js +192 -6
  2. package/client/index-browser.js +187 -1
  3. package/client/index.d.ts +66407 -45772
  4. package/client/index.js +192 -6
  5. package/client/package.json +1 -1
  6. package/client/schema.prisma +338 -31
  7. package/client/wasm.js +192 -6
  8. package/package.json +1 -1
  9. package/prisma/schema/budget.prisma +4 -0
  10. package/prisma/schema/candidateProfile.prisma +9 -8
  11. package/prisma/schema/department.prisma +89 -0
  12. package/prisma/schema/hiringPlan.prisma +197 -0
  13. package/prisma/schema/jobDescription.prisma +10 -0
  14. package/prisma/schema/migrations/20260610100000_add_communication/migration.sql +131 -0
  15. package/prisma/schema/migrations/20260610170000_add_communication_application_scope/migration.sql +45 -0
  16. package/prisma/schema/migrations/20260718120000_add_hiring_plan/migration.sql +208 -0
  17. package/prisma/schema/migrations/20260718140000_hiring_plan_assumptions/migration.sql +2 -0
  18. package/prisma/schema/organisation.prisma +3 -1
  19. package/prisma/schema/user.prisma +2 -0
  20. package/client/libquery_engine-darwin.dylib.node +0 -0
  21. package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +0 -2
  22. package/prisma/schema/.DS_Store +0 -0
  23. package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +0 -84
  24. package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +0 -26
  25. package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +0 -13
  26. package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +0 -2
  27. package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +0 -87
  28. package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +0 -38
  29. package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +0 -40
  30. package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +0 -232
  31. package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +0 -204
  32. package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +0 -31
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "prisma-client-3fc8f0ac96e7706dd9bf382b74975c1fc9c1d02f5d180621781338e9e94db387",
2
+ "name": "prisma-client-9cf4644c23ca38a4d545286e5b8e8a46022dec5ef60dab0b679be3afe8489cc9",
3
3
  "main": "index.js",
4
4
  "types": "index.d.ts",
5
5
  "browser": "default.js",
@@ -881,28 +881,32 @@ enum JDCreationType {
881
881
  }
882
882
 
883
883
  model Budget {
884
- id String @id @default(uuid())
885
- job_type JobType
886
- location String
887
- shift String
888
- openings Int
889
- budget_per_job String
890
- level String
891
- start_date DateTime
892
- closing_date DateTime
893
- business_unit String
894
- purpose String
895
- role String
896
- domain String
897
- jd_creation_type JDCreationType
898
- job_description_id String @unique
899
- job_description JobDescription @relation(fields: [job_description_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
900
- created_at DateTime @default(now())
901
- updated_at DateTime @updatedAt
902
- created_by String
903
- updated_by String
904
- is_active Boolean @default(true)
905
-
884
+ id String @id @default(uuid())
885
+ job_type JobType
886
+ location String
887
+ shift String
888
+ openings Int
889
+ budget_per_job String
890
+ level String
891
+ start_date DateTime
892
+ closing_date DateTime
893
+ business_unit String
894
+ purpose String
895
+ role String
896
+ domain String
897
+ jd_creation_type JDCreationType
898
+ job_description_id String @unique
899
+ job_description JobDescription @relation(fields: [job_description_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
900
+ /// Optional link to annual plan line (legacy Budget API; primary commit path is JobDescription).
901
+ hiring_plan_line_id String?
902
+ hiring_plan_line HiringPlanLine? @relation(fields: [hiring_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
903
+ created_at DateTime @default(now())
904
+ updated_at DateTime @updatedAt
905
+ created_by String
906
+ updated_by String
907
+ is_active Boolean @default(true)
908
+
909
+ @@index([hiring_plan_line_id])
906
910
  @@schema("public")
907
911
  }
908
912
 
@@ -944,14 +948,15 @@ model CandidateProfile {
944
948
 
945
949
  resume Resume? @relation(fields: [resume_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
946
950
 
947
- work_experience Json?
948
- education Json?
949
- notice_period String?
950
- gender String?
951
- ethnicity String?
952
- veteran_status String?
953
- disability_status String?
954
- is_active Boolean @default(true)
951
+ work_experience Json?
952
+ education Json?
953
+ notice_period String?
954
+ gender String?
955
+ ethnicity String?
956
+ veteran_status String?
957
+ disability_status String?
958
+ is_active Boolean @default(true)
959
+ planned_candidates PlannedCandidate[]
955
960
 
956
961
  @@schema("public")
957
962
  }
@@ -1139,6 +1144,96 @@ model ContactUs {
1139
1144
  @@schema("public")
1140
1145
  }
1141
1146
 
1147
+ /// Section-level status for a department's slice of the hiring plan.
1148
+ /// DRAFT — department head is editing
1149
+ /// SUBMITTED — head submitted; awaiting CHRO
1150
+ /// APPROVED — CHRO locked; line writes rejected until reopened to DRAFT
1151
+ enum HiringPlanSectionStatus {
1152
+ DRAFT
1153
+ SUBMITTED
1154
+ APPROVED
1155
+
1156
+ @@schema("public")
1157
+ }
1158
+
1159
+ /// First-class org unit that owns a slice of the annual hiring plan.
1160
+ /// Replaces the free-text `business_unit` string on HiringPlanLine / Employee.
1161
+ /// Headship lives on DepartmentMember.is_head (at most one per dept, enforced in service).
1162
+ model Department {
1163
+ id String @id @default(uuid())
1164
+ organisation_id String
1165
+ name String
1166
+ code String?
1167
+ /// Global display order across departments within the org (drag-reorder in plan grid).
1168
+ sort_order Int @default(0)
1169
+ created_at DateTime @default(now())
1170
+ updated_at DateTime @updatedAt
1171
+ created_by String
1172
+ updated_by String
1173
+ is_active Boolean @default(true)
1174
+
1175
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1176
+ members DepartmentMember[]
1177
+ hiring_plan_lines HiringPlanLine[]
1178
+ employees Employee[]
1179
+ job_descriptions JobDescription[]
1180
+ sections HiringPlanSection[]
1181
+
1182
+ @@unique([organisation_id, name])
1183
+ @@index([organisation_id])
1184
+ @@schema("public")
1185
+ }
1186
+
1187
+ /// Many-to-many membership: a user can belong to multiple departments.
1188
+ /// is_head marks the department head for that membership row. The same user can
1189
+ /// be head of multiple departments (multiple rows with is_head=true). At most
1190
+ /// one is_head=true per department is enforced in DepartmentService.
1191
+ model DepartmentMember {
1192
+ id String @id @default(uuid())
1193
+ department_id String
1194
+ user_id String
1195
+ is_head Boolean @default(false)
1196
+ created_at DateTime @default(now())
1197
+ updated_at DateTime @updatedAt
1198
+ created_by String
1199
+ updated_by String
1200
+ is_active Boolean @default(true)
1201
+
1202
+ department Department @relation(fields: [department_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1203
+ user User @relation("DepartmentMemberships", fields: [user_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1204
+
1205
+ @@unique([department_id, user_id])
1206
+ @@index([user_id])
1207
+ @@index([department_id, is_head])
1208
+ @@schema("public")
1209
+ }
1210
+
1211
+ /// Per-department status for a specific hiring plan (submit → approve/lock).
1212
+ model HiringPlanSection {
1213
+ id String @id @default(uuid())
1214
+ hiring_plan_id String
1215
+ department_id String
1216
+ status HiringPlanSectionStatus @default(DRAFT)
1217
+ submitted_by String?
1218
+ submitted_at DateTime?
1219
+ approved_by String?
1220
+ approved_at DateTime?
1221
+ created_at DateTime @default(now())
1222
+ updated_at DateTime @updatedAt
1223
+ created_by String
1224
+ updated_by String
1225
+ is_active Boolean @default(true)
1226
+
1227
+ hiring_plan HiringPlan @relation(fields: [hiring_plan_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1228
+ department Department @relation(fields: [department_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1229
+
1230
+ @@unique([hiring_plan_id, department_id])
1231
+ @@index([hiring_plan_id])
1232
+ @@index([department_id])
1233
+ @@index([status])
1234
+ @@schema("public")
1235
+ }
1236
+
1142
1237
  model Document {
1143
1238
  // Primary key
1144
1239
  id String @id @default(uuid())
@@ -1444,6 +1539,204 @@ model Google {
1444
1539
  @@schema("public")
1445
1540
  }
1446
1541
 
1542
+ enum HiringPlanStatus {
1543
+ DRAFT
1544
+ ACTIVE
1545
+ CLOSED
1546
+
1547
+ @@schema("public")
1548
+ }
1549
+
1550
+ enum PeriodType {
1551
+ ANNUAL
1552
+
1553
+ @@schema("public")
1554
+ }
1555
+
1556
+ enum EmployeeStatus {
1557
+ ACTIVE
1558
+ ATTRITION_EXPECTED
1559
+ DEPARTED
1560
+
1561
+ @@schema("public")
1562
+ }
1563
+
1564
+ enum AttritionRisk {
1565
+ LOW
1566
+ MEDIUM
1567
+ HIGH
1568
+
1569
+ @@schema("public")
1570
+ }
1571
+
1572
+ enum ReviewRating {
1573
+ OUTSTANDING
1574
+ EXCEEDS_EXPECTATIONS
1575
+ MEETS_EXPECTATIONS
1576
+ NEEDS_IMPROVEMENT
1577
+ UNSATISFACTORY
1578
+
1579
+ @@schema("public")
1580
+ }
1581
+
1582
+ enum PlannedCandidateStatus {
1583
+ IDENTIFIED
1584
+ IN_PIPELINE
1585
+ OFFER
1586
+ SELECTED
1587
+ DECLINED
1588
+
1589
+ @@schema("public")
1590
+ }
1591
+
1592
+ /// Org-level annual hiring plan (CHRO budgeting).
1593
+ model HiringPlan {
1594
+ id String @id @default(uuid())
1595
+ organisation_id String
1596
+ fiscal_year Int
1597
+ period_type PeriodType @default(ANNUAL)
1598
+ currency String @default("INR")
1599
+ status HiringPlanStatus @default(DRAFT)
1600
+ total_headcount_budget Int?
1601
+ total_cost_budget Decimal? @db.Decimal(18, 2)
1602
+ /// Workbook assumptions (multipliers, inflation, fiscal start month, etc.).
1603
+ assumptions Json?
1604
+ notes String?
1605
+ created_at DateTime @default(now())
1606
+ updated_at DateTime @updatedAt
1607
+ created_by String
1608
+ updated_by String
1609
+ is_active Boolean @default(true)
1610
+
1611
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1612
+ lines HiringPlanLine[]
1613
+ sections HiringPlanSection[]
1614
+
1615
+ @@unique([organisation_id, fiscal_year])
1616
+ @@index([organisation_id])
1617
+ @@index([status])
1618
+ @@schema("public")
1619
+ }
1620
+
1621
+ /// One allocation row: dimensions + planned headcount + monthly phasing inputs.
1622
+ model HiringPlanLine {
1623
+ id String @id @default(uuid())
1624
+ hiring_plan_id String
1625
+ /// Owning department (grouping + section ownership). Legacy `business_unit` is
1626
+ /// kept for back-compat and populated from Department.name for a while.
1627
+ department_id String?
1628
+ business_unit String?
1629
+ level String?
1630
+ location String?
1631
+ role String?
1632
+ planned_headcount Int @default(1)
1633
+ /// Fully-loaded annual run-rate cost per hire (not in-year cost).
1634
+ cost_per_hire Decimal @db.Decimal(18, 2)
1635
+ /// Fiscal month 1–12 when hires start (used when hire_schedule is null).
1636
+ start_month Int @default(1)
1637
+ /// Optional staggered starts: { "1": 2, "4": 2 } (fiscal-month → count).
1638
+ hire_schedule Json?
1639
+ /// Display order within a business unit (lower first).
1640
+ sort_order Int @default(0)
1641
+ /// Reference/template JD for this role (definition).
1642
+ job_description_id String?
1643
+ created_at DateTime @default(now())
1644
+ updated_at DateTime @updatedAt
1645
+ created_by String
1646
+ updated_by String
1647
+ is_active Boolean @default(true)
1648
+
1649
+ hiring_plan HiringPlan @relation(fields: [hiring_plan_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1650
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
1651
+ job_description JobDescription? @relation("PlanLineTemplateJd", fields: [job_description_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
1652
+ requisitions JobDescription[] @relation("PlanLineRequisitions")
1653
+ budgets Budget[]
1654
+ planned_candidates PlannedCandidate[]
1655
+ backfill_from_employees Employee[] @relation("EmployeeBackfillLine")
1656
+
1657
+ @@index([hiring_plan_id])
1658
+ @@index([department_id])
1659
+ @@index([job_description_id])
1660
+ @@index([business_unit, level, location, role])
1661
+ @@schema("public")
1662
+ }
1663
+
1664
+ /// Existing workforce roster (manual / CSV). Baseline for net-new vs backfill.
1665
+ model Employee {
1666
+ id String @id @default(uuid())
1667
+ organisation_id String
1668
+ /// Owning department (Department.name mirrors legacy business_unit for back-compat).
1669
+ department_id String?
1670
+ employee_code String?
1671
+ name String?
1672
+ email String?
1673
+ gender String?
1674
+ business_unit String?
1675
+ level String?
1676
+ location String?
1677
+ role String?
1678
+ employment_type JobType?
1679
+ starting_designation String?
1680
+ current_designation String?
1681
+ start_date DateTime?
1682
+ starting_salary Decimal? @db.Decimal(18, 2)
1683
+ /// Comp immediately before the latest raise (or prior cycle). Optional.
1684
+ previous_salary Decimal? @db.Decimal(18, 2)
1685
+ current_comp Decimal @db.Decimal(18, 2)
1686
+ currency String @default("INR")
1687
+ last_increment_date DateTime?
1688
+ last_increment_amount Decimal? @db.Decimal(18, 2)
1689
+ last_increment_pct Decimal? @db.Decimal(8, 4)
1690
+ last_review_date DateTime?
1691
+ last_review_rating ReviewRating?
1692
+ last_feedback_date DateTime?
1693
+ last_feedback_summary String?
1694
+ status EmployeeStatus @default(ACTIVE)
1695
+ attrition_risk AttritionRisk?
1696
+ expected_exit_date DateTime?
1697
+ backfill_plan_line_id String?
1698
+ created_at DateTime @default(now())
1699
+ updated_at DateTime @updatedAt
1700
+ created_by String
1701
+ updated_by String
1702
+ is_active Boolean @default(true)
1703
+
1704
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1705
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
1706
+ backfill_plan_line HiringPlanLine? @relation("EmployeeBackfillLine", fields: [backfill_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
1707
+
1708
+ @@unique([organisation_id, employee_code])
1709
+ @@index([organisation_id])
1710
+ @@index([department_id])
1711
+ @@index([status])
1712
+ @@index([business_unit, level, location, role])
1713
+ @@index([backfill_plan_line_id])
1714
+ @@schema("public")
1715
+ }
1716
+
1717
+ /// Tentative candidate attached to a plan line (ATS CandidateProfile or free-text).
1718
+ model PlannedCandidate {
1719
+ id String @id @default(uuid())
1720
+ hiring_plan_line_id String
1721
+ candidate_profile_id String?
1722
+ name String?
1723
+ status PlannedCandidateStatus @default(IDENTIFIED)
1724
+ note String?
1725
+ created_at DateTime @default(now())
1726
+ updated_at DateTime @updatedAt
1727
+ created_by String
1728
+ updated_by String
1729
+ is_active Boolean @default(true)
1730
+
1731
+ hiring_plan_line HiringPlanLine @relation(fields: [hiring_plan_line_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1732
+ candidate_profile CandidateProfile? @relation(fields: [candidate_profile_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
1733
+
1734
+ @@index([hiring_plan_line_id])
1735
+ @@index([candidate_profile_id])
1736
+ @@index([status])
1737
+ @@schema("public")
1738
+ }
1739
+
1447
1740
  enum IntegrationProvider {
1448
1741
  NAUKRI
1449
1742
  ZOHO_RECRUIT
@@ -2093,6 +2386,8 @@ enum JobDescriptionStatus {
2093
2386
  model JobDescription {
2094
2387
  id String @id @default(uuid())
2095
2388
  organisation_id String
2389
+ /// Owning department (visibility scope for DepartmentHead; optional).
2390
+ department_id String?
2096
2391
  hiring_manager_id String?
2097
2392
  status JobDescriptionStatus @default(DRAFT)
2098
2393
  screeningQuestions String[]
@@ -2125,6 +2420,7 @@ model JobDescription {
2125
2420
  job_profile_id String?
2126
2421
  job_profile JobProfile? @relation(fields: [job_profile_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
2127
2422
  organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
2423
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
2128
2424
  source_document Document? @relation("SourceDocument", fields: [source_document_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
2129
2425
  applications Application[]
2130
2426
  interviews Interview[]
@@ -2144,10 +2440,17 @@ model JobDescription {
2144
2440
  job_application_template JobApplicationTemplate?
2145
2441
  conversations Conversation[]
2146
2442
  communication_messages CommunicationMessage[]
2443
+ /// Plan line this opening is committed against (requisition → plan).
2444
+ hiring_plan_line_id String?
2445
+ hiring_plan_line HiringPlanLine? @relation("PlanLineRequisitions", fields: [hiring_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
2446
+ /// Plan lines that use this JD as the role template/reference.
2447
+ referenced_by_plan_lines HiringPlanLine[] @relation("PlanLineTemplateJd")
2147
2448
 
2148
2449
  @@index([organisation_id])
2149
2450
  @@index([hiring_manager_id])
2150
2451
  @@index([job_profile_id])
2452
+ @@index([hiring_plan_line_id])
2453
+ @@index([department_id])
2151
2454
  @@schema("public")
2152
2455
  }
2153
2456
 
@@ -2618,7 +2921,9 @@ model Organisation {
2618
2921
  job_application_templates JobApplicationTemplate[]
2619
2922
  sources Source[]
2620
2923
  evaluation_criteria EvaluationCriteria[]
2621
- // departments Department[]
2924
+ departments Department[]
2925
+ hiring_plans HiringPlan[]
2926
+ employees Employee[]
2622
2927
 
2623
2928
  @@index([name])
2624
2929
  @@schema("public")
@@ -3343,6 +3648,8 @@ model User {
3343
3648
  employee_number Int?
3344
3649
  employee_code String? @unique
3345
3650
 
3651
+ department_members DepartmentMember[] @relation("DepartmentMemberships")
3652
+
3346
3653
  @@index([role_id])
3347
3654
  @@index([permission_id])
3348
3655
  @@index([organisation_id])