@adaptware/eagles-db 0.5.33 → 0.5.34

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 (78) hide show
  1. package/client/edge.js +231 -11
  2. package/client/index-browser.js +225 -4
  3. package/client/index.d.ts +67169 -46191
  4. package/client/index.js +231 -11
  5. package/client/libquery_engine-darwin.dylib.node +0 -0
  6. package/client/package.json +1 -1
  7. package/client/schema.prisma +454 -105
  8. package/client/wasm.js +231 -11
  9. package/package.json +1 -1
  10. package/prisma/.DS_Store +0 -0
  11. package/prisma/migrations/20260519120000_migrate_shortlisted_to_selected/migration.sql +2 -0
  12. package/prisma/schema/.DS_Store +0 -0
  13. package/prisma/schema/department.prisma +3 -2
  14. package/prisma/schema/jobDescription.prisma +1 -0
  15. package/prisma/schema/licensing/aiCostLedger.prisma +34 -0
  16. package/prisma/schema/licensing/assignmentHistory.prisma +19 -0
  17. package/prisma/schema/licensing/licensePackageCatalog.prisma +62 -0
  18. package/prisma/schema/licensing/licensingEnums.prisma +80 -0
  19. package/prisma/schema/licensing/licensingLedger.prisma +32 -0
  20. package/prisma/schema/licensing/purchasedLicense.prisma +74 -0
  21. package/prisma/schema/licensing/purchasedTopUp.prisma +39 -0
  22. package/prisma/schema/migrations/20260519120000_add_analytics_schema/migration.sql +84 -0
  23. package/prisma/schema/migrations/20260625120000_add_interviewer_analytics/migration.sql +26 -0
  24. package/prisma/schema/migrations/20260629120000_add_user_lifecycle_activity_events/migration.sql +13 -0
  25. package/prisma/schema/migrations/20260629140000_drop_organisation_org_code/migration.sql +2 -0
  26. package/prisma/schema/migrations/20260629160000_employee_codes_dual_interviewer_analytics/migration.sql +87 -0
  27. package/prisma/schema/migrations/20260630120000_add_application_sources/migration.sql +38 -0
  28. package/prisma/schema/migrations/20260701120000_add_source_effectiveness_analytics/migration.sql +40 -0
  29. package/prisma/schema/migrations/20260702120000_add_analytics_daily_tables/migration.sql +232 -0
  30. package/prisma/schema/migrations/20260716120000_evaluation_category_four_values/migration.sql +204 -0
  31. package/prisma/schema/migrations/20260716130000_application_withdrawn_analytics/migration.sql +31 -0
  32. package/prisma/schema/migrations/20260804120000_contact_us_optional_website_subject/migration.sql +3 -0
  33. package/prisma/schema/migrations/20260810120000_add_licensing_schema/migration.sql +237 -0
  34. package/prisma/schema/migrations/20260814153000_add_licensing_ledger/migration.sql +236 -0
  35. package/prisma/schema/migrations/20260828120000_license_package_orgs_cost_price_ai_cost_ledger/migration.sql +74 -0
  36. package/prisma/schema/migrations/20260831120000_ai_cost_ledger_purchase_reason/migration.sql +2 -0
  37. package/prisma/schema/migrations/20260831140000_ai_cost_ledger_nullable_hiring_unit/migration.sql +3 -0
  38. package/prisma/schema/organisation.prisma +6 -0
  39. package/prisma/schema/schema.prisma +1 -1
  40. package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +0 -25
  41. package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +0 -24
  42. package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +0 -2
  43. package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +0 -9
  44. package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +0 -8
  45. package/prisma/schema/migrations/20260716120000_add_offer_letters/migration.sql +0 -183
  46. package/prisma/schema/migrations/20260716140000_offer_schema_refinements/migration.sql +0 -13
  47. package/prisma/schema/migrations/20260716160000_offer_schema_hardening/migration.sql +0 -95
  48. package/prisma/schema/migrations/20260716180000_offer_letter_template_config/migration.sql +0 -2
  49. package/prisma/schema/migrations/20260716190000_add_evaluation_focus_areas/migration.sql +0 -6
  50. package/prisma/schema/migrations/20260717120000_offer_workflow_approval/migration.sql +0 -30
  51. package/prisma/schema/migrations/20260720120000_offer_letter_template_is_draft/migration.sql +0 -5
  52. package/prisma/schema/migrations/20260720140000_offer_status_split/migration.sql +0 -51
  53. package/prisma/schema/migrations/20260720140001_offer_status_split_backfill/migration.sql +0 -37
  54. package/prisma/schema/migrations/20260722120000_offer_draft_edited_html/migration.sql +0 -13
  55. package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql +0 -10
  56. package/prisma/schema/migrations/20260724120000_open_job_offer_accepted_declined_counts/migration.sql +0 -7
  57. package/prisma/schema/migrations/20260811120000_add_integration_provider_razorpay/migration.sql +0 -6
  58. package/prisma/schema/migrations/20260812120000_add_billing_transactions/migration.sql +0 -49
  59. package/prisma/schema/migrations/20260812130000_drop_billing_transaction_gst_snapshots/migration.sql +0 -3
  60. package/prisma/schema/migrations/20260812180000_billing_transaction_invoice_number/migration.sql +0 -5
  61. package/prisma/schema/migrations/20260813120000_payment_webhooks_gst_refunds/migration.sql +0 -79
  62. package/prisma/schema/migrations/20260813140000_platform_gst_profiles/migration.sql +0 -49
  63. package/prisma/schema/migrations/20260813150000_rename_gst_profiles/migration.sql +0 -53
  64. package/prisma/schema/migrations/20260813160000_remove_gst_billing/migration.sql +0 -16
  65. package/prisma/schema/migrations/20260813170000_billing_licensing_unrecoverable/migration.sql +0 -2
  66. package/prisma/schema/migrations/20260813180000_billing_transaction_payment_method/migration.sql +0 -2
  67. package/prisma/schema/migrations/20260814090000_billing_transaction_purchaser_email/migration.sql +0 -2
  68. package/prisma/schema/migrations/20260816100000_billing_product_organisations/migration.sql +0 -35
  69. package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql +0 -25
  70. package/prisma/schema/migrations/20260817120000_billing_payment_mismatch/migration.sql +0 -7
  71. package/prisma/schema/migrations/20260819120000_billing_product_prices/migration.sql +0 -62
  72. package/prisma/schema/migrations/20260819140000_billing_exchange_rates/migration.sql +0 -25
  73. package/prisma/schema/migrations/20260820120000_billing_transaction_failure_category/migration.sql +0 -31
  74. package/prisma/schema/migrations/20260820130000_backfill_billing_transaction_failure_details/migration.sql +0 -23
  75. package/prisma/schema/migrations/20260820140000_drop_billing_product_price_overrides/migration.sql +0 -2
  76. package/prisma/schema/migrations/20260821120000_drop_billing_product_and_mock_licensing/migration.sql +0 -38
  77. package/prisma/schema/migrations/20260824120000_billing_transaction_purchase_display_name/migration.sql +0 -2
  78. package/prisma/schema/migrations/20260831120000_user_communication_email/migration.sql +0 -6
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "prisma-client-de75bcbd2ad4922270e6cfd18a6db468dbb9c59097af206e057885edaffdab15",
2
+ "name": "prisma-client-05655c10cdac884310a7de347538d0ba3e76ee9bde2b20a0e8765ca45a53bc28",
3
3
  "main": "index.js",
4
4
  "types": "index.d.ts",
5
5
  "browser": "default.js",
@@ -1193,8 +1193,6 @@ enum CompetencyCategory {
1193
1193
  TECHNICAL
1194
1194
  BEHAVIOURAL
1195
1195
  AI
1196
- /// FitCheck analysis only — not a dictionary / job-profile catalog category.
1197
- EXPERIENCE_RELEVANCE
1198
1196
 
1199
1197
  @@schema("public")
1200
1198
  }
@@ -1279,24 +1277,25 @@ enum HiringPlanSectionStatus {
1279
1277
  /// Replaces the free-text `business_unit` string on HiringPlanLine / Employee.
1280
1278
  /// Headship lives on DepartmentMember.is_head (at most one per dept, enforced in service).
1281
1279
  model Department {
1282
- id String @id @default(uuid())
1283
- organisation_id String
1284
- name String
1285
- code String?
1280
+ id String @id @default(uuid())
1281
+ organisation_id String
1282
+ name String
1283
+ code String?
1286
1284
  /// Global display order across departments within the org (drag-reorder in plan grid).
1287
- sort_order Int @default(0)
1288
- created_at DateTime @default(now())
1289
- updated_at DateTime @updatedAt
1290
- created_by String
1291
- updated_by String
1292
- is_active Boolean @default(true)
1293
- organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1294
- members DepartmentMember[]
1295
- hiring_plan_lines HiringPlanLine[]
1296
- employees Employee[]
1297
- job_descriptions JobDescription[]
1298
- job_profiles JobProfile[]
1299
- sections HiringPlanSection[]
1285
+ sort_order Int @default(0)
1286
+ created_at DateTime @default(now())
1287
+ updated_at DateTime @updatedAt
1288
+ created_by String
1289
+ updated_by String
1290
+ is_active Boolean @default(true)
1291
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1292
+ members DepartmentMember[]
1293
+ hiring_plan_lines HiringPlanLine[]
1294
+ employees Employee[]
1295
+ job_descriptions JobDescription[]
1296
+ job_profiles JobProfile[]
1297
+ sections HiringPlanSection[]
1298
+ assigned_hiring_units PurchasedHiringUnit[]
1300
1299
 
1301
1300
  @@unique([organisation_id, name])
1302
1301
  @@index([organisation_id])
@@ -1568,35 +1567,33 @@ enum FitCheckStatus {
1568
1567
 
1569
1568
  model FitCheck {
1570
1569
  /// Primary key (UUID)
1571
- id String @id @default(uuid())
1570
+ id String @id @default(uuid())
1572
1571
  /// FK to organisations table
1573
- organisation_id String?
1574
- candidate_id String?
1575
- resume_id String
1576
- job_description_id String
1572
+ organisation_id String?
1573
+ candidate_id String?
1574
+ resume_id String
1575
+ job_description_id String
1577
1576
  /// Owning application (inverted from Application.fit_check_id)
1578
- application_id String? @unique
1579
- skills_analysis Json?
1580
- overall_analysis Json?
1581
- overall_score Float
1582
- /// Free-text from Overall Analysis agent; preferred over recommendation Json.
1583
- overall_recommendation String?
1584
- short_match_analysis Json[]
1585
- fit_comparison Json?
1586
- recommendation Json?
1587
- competencies_analysis Json?
1577
+ application_id String? @unique
1578
+ skills_analysis Json?
1579
+ overall_analysis Json?
1580
+ overall_score Float
1581
+ short_match_analysis Json[]
1582
+ fit_comparison Json?
1583
+ recommendation Json?
1584
+ competencies_analysis Json?
1588
1585
  /// Audit fields
1589
- created_by String
1590
- updated_by String
1591
- is_active Boolean @default(true)
1592
- created_at DateTime @default(now())
1593
- updated_at DateTime @updatedAt
1586
+ created_by String
1587
+ updated_by String
1588
+ is_active Boolean @default(true)
1589
+ created_at DateTime @default(now())
1590
+ updated_at DateTime @updatedAt
1594
1591
  /// Relations
1595
- organisation Organisation? @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1596
- candidate User? @relation(fields: [candidate_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1597
- resume Resume @relation(fields: [resume_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1598
- job_description JobDescription @relation(fields: [job_description_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1599
- application Application? @relation(fields: [application_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1592
+ organisation Organisation? @relation(fields: [organisation_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1593
+ candidate User? @relation(fields: [candidate_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1594
+ resume Resume @relation(fields: [resume_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1595
+ job_description JobDescription @relation(fields: [job_description_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1596
+ application Application? @relation(fields: [application_id], references: [id], onDelete: Cascade, onUpdate: Cascade)
1600
1597
 
1601
1598
  /// Ensure one FitCheck per (resume_id, job_description_id) pair
1602
1599
  @@unique([resume_id, job_description_id])
@@ -2533,6 +2530,7 @@ model JobDescription {
2533
2530
  hiring_plan_line HiringPlanLine? @relation("PlanLineRequisitions", fields: [hiring_plan_line_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
2534
2531
  /// Plan lines that use this JD as the role template/reference.
2535
2532
  referenced_by_plan_lines HiringPlanLine[] @relation("PlanLineTemplateJd")
2533
+ linked_hiring_units PurchasedHiringUnit[]
2536
2534
 
2537
2535
  @@index([organisation_id])
2538
2536
  @@index([hiring_manager_id])
@@ -2724,6 +2722,353 @@ model JobRoundAnalyticsDaily {
2724
2722
  @@schema("analytics")
2725
2723
  }
2726
2724
 
2725
+ /// Append-only book of AI workflow cost (org pool, optionally a hiring unit).
2726
+ /// Covers every workflow (including license-included names). Amount is always USD.
2727
+ /// total_cost(unit) = SUM(DEBIT amount) - SUM(CREDIT amount) for that unit.
2728
+ /// CREDIT / PURCHASE is full package internal cost (USD) per hiring unit.
2729
+ /// DEBIT / USAGE is every workflow's Orion totalCost (USD), nothing excluded.
2730
+ model AiCostLedgerEntry {
2731
+ id String @id @default(uuid())
2732
+ organisation_id String
2733
+ purchased_hiring_unit_id String?
2734
+ workflow_name String
2735
+ direction LicensingLedgerDirection
2736
+ /// Always non-negative. USD.
2737
+ amount Decimal @db.Decimal(20, 4)
2738
+ reason AiCostLedgerReason
2739
+ occurred_at DateTime @default(now())
2740
+ source_type String?
2741
+ source_id String?
2742
+ description String?
2743
+ idempotency_key String @unique
2744
+ created_at DateTime @default(now())
2745
+ updated_at DateTime @default(now()) @updatedAt
2746
+ created_by String
2747
+ updated_by String
2748
+ is_active Boolean @default(true)
2749
+
2750
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2751
+ purchased_hiring_unit PurchasedHiringUnit? @relation(fields: [purchased_hiring_unit_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2752
+
2753
+ @@index([purchased_hiring_unit_id, occurred_at], map: "ai_cost_ledger_unit_occurred_idx")
2754
+ @@index([purchased_hiring_unit_id, workflow_name, occurred_at], map: "ai_cost_ledger_unit_workflow_occurred_idx")
2755
+ @@index([organisation_id, occurred_at], map: "ai_cost_ledger_org_occurred_idx")
2756
+ @@map("ai_cost_ledger")
2757
+ @@schema("licensing")
2758
+ }
2759
+
2760
+ /// Immutable assignment history for Hiring Unit department/job changes.
2761
+ model PurchasedHiringUnitAssignmentEvent {
2762
+ id String @id @default(uuid())
2763
+ purchased_hiring_unit_id String
2764
+ event_kind PurchasedHiringUnitAssignmentEventKind
2765
+ previous_department_id String?
2766
+ new_department_id String?
2767
+ previous_job_description_id String?
2768
+ new_job_description_id String?
2769
+ effective_at DateTime @default(now())
2770
+ created_by String
2771
+
2772
+ purchased_hiring_unit PurchasedHiringUnit @relation(fields: [purchased_hiring_unit_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2773
+
2774
+ @@index([purchased_hiring_unit_id], map: "purchased_hu_assignment_events_unit_id_idx")
2775
+ @@index([purchased_hiring_unit_id, effective_at], map: "purchased_hu_assignment_events_unit_effective_idx")
2776
+ @@map("purchased_hiring_unit_assignment_events")
2777
+ @@schema("licensing")
2778
+ }
2779
+
2780
+ /// Product catalogue: one wide row per (code, version) with fixed per-hiring-unit entitlements.
2781
+ /// See eagles-db/docs/eagles-db/licensing-catalog.md for column → usage metric_key mapping at purchase.
2782
+ model LicensePackage {
2783
+ id String @id @default(uuid())
2784
+ code String
2785
+ version Int
2786
+ name String
2787
+ description String?
2788
+ price Decimal @db.Decimal(18, 2)
2789
+ /// Internal cost of the package. Same currency as `currency`. Not for org-facing catalogue APIs.
2790
+ cost_price Decimal @default(0) @db.Decimal(18, 2)
2791
+ currency String @default("INR")
2792
+ status LicensePackageStatus @default(DRAFT)
2793
+ /// Number of PurchasedHiringUnit rows created per package purchase.
2794
+ units_per_purchase Int
2795
+
2796
+ /// Per-hiring-unit entitlements. null = not included; 0 = explicitly zero.
2797
+ interview_ai_assisted_hours Decimal? @db.Decimal(20, 4)
2798
+ interview_full_ai_hours Decimal? @db.Decimal(20, 4)
2799
+ interview_non_ai_hours Decimal? @db.Decimal(20, 4)
2800
+ assignment_count Decimal? @db.Decimal(20, 4)
2801
+ test_count Decimal? @db.Decimal(20, 4)
2802
+ resume_count Decimal? @db.Decimal(20, 4)
2803
+ credits Decimal? @db.Decimal(20, 4)
2804
+
2805
+ created_at DateTime @default(now())
2806
+ updated_at DateTime @updatedAt
2807
+ created_by String
2808
+ updated_by String
2809
+ is_active Boolean @default(true)
2810
+
2811
+ purchased_license_packages PurchasedLicensePackage[]
2812
+ organisations LicensePackageOrganisation[]
2813
+
2814
+ @@unique([code, version])
2815
+ @@index([code])
2816
+ @@index([status])
2817
+ @@map("license_packages")
2818
+ @@schema("licensing")
2819
+ }
2820
+
2821
+ /// Many-to-many: which organisations may see this catalogue package.
2822
+ /// Zero rows = visible to nobody except platform list (enforced later in eagles-backend).
2823
+ model LicensePackageOrganisation {
2824
+ id String @id @default(uuid())
2825
+ license_package_id String
2826
+ organisation_id String
2827
+
2828
+ created_at DateTime @default(now())
2829
+ updated_at DateTime @updatedAt
2830
+ created_by String
2831
+ updated_by String
2832
+ is_active Boolean @default(true)
2833
+
2834
+ license_package LicensePackage @relation(fields: [license_package_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2835
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2836
+
2837
+ @@unique([license_package_id, organisation_id], map: "license_package_orgs_pkg_org_key")
2838
+ @@index([organisation_id])
2839
+ @@map("license_package_organisations")
2840
+ @@schema("licensing")
2841
+ }
2842
+
2843
+ enum LicensePackageStatus {
2844
+ DRAFT
2845
+ ACTIVE
2846
+ ARCHIVED
2847
+
2848
+ @@schema("licensing")
2849
+ }
2850
+
2851
+ enum PurchasedLicensePackageStatus {
2852
+ ACTIVE
2853
+ EXPIRED
2854
+ CANCELLED
2855
+
2856
+ @@schema("licensing")
2857
+ }
2858
+
2859
+ enum PurchasedHiringUnitStatus {
2860
+ AVAILABLE
2861
+ ASSIGNED
2862
+ ACTIVE
2863
+ EXPIRED
2864
+
2865
+ @@schema("licensing")
2866
+ }
2867
+
2868
+ enum PurchasedTopUpStatus {
2869
+ ACTIVE
2870
+ DEPLETED
2871
+ CANCELLED
2872
+
2873
+ @@schema("licensing")
2874
+ }
2875
+
2876
+ enum PurchasedHiringUnitAssignmentEventKind {
2877
+ DEPARTMENT_ASSIGNED
2878
+ DEPARTMENT_UNASSIGNED
2879
+ JOB_LINKED
2880
+ JOB_UNLINKED
2881
+
2882
+ @@schema("licensing")
2883
+ }
2884
+
2885
+ enum LicensingLedgerEntitlementType {
2886
+ INTERVIEW_AI_ASSISTED_HOURS
2887
+ INTERVIEW_FULL_AI_HOURS
2888
+ INTERVIEW_NON_AI_HOURS
2889
+ ASSIGNMENT_COUNT
2890
+ TEST_COUNT
2891
+ RESUME_COUNT
2892
+ CREDITS
2893
+
2894
+ @@schema("licensing")
2895
+ }
2896
+
2897
+ enum LicensingLedgerDirection {
2898
+ CREDIT
2899
+ DEBIT
2900
+
2901
+ @@schema("licensing")
2902
+ }
2903
+
2904
+ enum LicensingLedgerReason {
2905
+ PURCHASE
2906
+ TOP_UP
2907
+ USAGE
2908
+ ADJUSTMENT
2909
+ REFUND
2910
+ EXPIRY
2911
+
2912
+ @@schema("licensing")
2913
+ }
2914
+
2915
+ enum AiCostLedgerReason {
2916
+ PURCHASE
2917
+ USAGE
2918
+ ADJUSTMENT
2919
+ REFUND
2920
+
2921
+ @@schema("licensing")
2922
+ }
2923
+
2924
+ /// Append-only book of hiring-unit entitlement movements.
2925
+ /// remaining(unit, type) = SUM(CREDIT amount) - SUM(DEBIT amount).
2926
+ /// See eagles-db/docs/eagles-db/licensing-hiring-unit.md.
2927
+ model LicensingLedgerEntry {
2928
+ id String @id @default(uuid())
2929
+ organisation_id String
2930
+ /// Null for org-level rows (e.g. unallocated top-ups later).
2931
+ purchased_hiring_unit_id String?
2932
+ entitlement_type LicensingLedgerEntitlementType
2933
+ direction LicensingLedgerDirection
2934
+ /// Always non-negative. CREDIT of 0 means the stem is included at zero.
2935
+ amount Decimal @db.Decimal(20, 4)
2936
+ reason LicensingLedgerReason
2937
+ occurred_at DateTime @default(now())
2938
+ source_type String?
2939
+ source_id String?
2940
+ description String?
2941
+ idempotency_key String @unique
2942
+ created_at DateTime @default(now())
2943
+ updated_at DateTime @default(now()) @updatedAt
2944
+ created_by String
2945
+ updated_by String
2946
+ is_active Boolean @default(true)
2947
+
2948
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2949
+ purchased_hiring_unit PurchasedHiringUnit? @relation(fields: [purchased_hiring_unit_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2950
+
2951
+ @@index([purchased_hiring_unit_id, entitlement_type, occurred_at], map: "licensing_ledger_unit_type_occurred_idx")
2952
+ @@index([organisation_id, entitlement_type, occurred_at], map: "licensing_ledger_org_type_occurred_idx")
2953
+ @@map("licensing_ledger")
2954
+ @@schema("licensing")
2955
+ }
2956
+
2957
+ /// Historical package purchase by an organisation (independent per transaction).
2958
+ model PurchasedLicensePackage {
2959
+ id String @id @default(uuid())
2960
+ organisation_id String
2961
+ license_package_id String
2962
+ /// Snapshot of catalogue identity at purchase time.
2963
+ package_code String
2964
+ package_version Int
2965
+ package_name String
2966
+ price Decimal @db.Decimal(18, 2)
2967
+ currency String @default("INR")
2968
+ units_per_purchase Int
2969
+ /// How many package instances were bought in this transaction.
2970
+ package_quantity Int @default(1)
2971
+ purchased_at DateTime @default(now())
2972
+ status PurchasedLicensePackageStatus @default(ACTIVE)
2973
+ created_at DateTime @default(now())
2974
+ updated_at DateTime @updatedAt
2975
+ created_by String
2976
+ updated_by String
2977
+ is_active Boolean @default(true)
2978
+
2979
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2980
+ license_package LicensePackage @relation(fields: [license_package_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
2981
+ hiring_units PurchasedHiringUnit[]
2982
+
2983
+ @@index([organisation_id])
2984
+ @@index([organisation_id, status])
2985
+ @@index([organisation_id, purchased_at])
2986
+ @@map("purchased_license_packages")
2987
+ @@schema("licensing")
2988
+ }
2989
+
2990
+ /// Runtime hiring unit identity and allocation. Entitlement balances live on
2991
+ /// `licensing.licensing_ledger` (Prisma model `LicensingLedgerEntry`).
2992
+ /// See eagles-db/docs/eagles-db/licensing-hiring-unit.md.
2993
+ model PurchasedHiringUnit {
2994
+ id String @id @default(uuid())
2995
+ organisation_id String
2996
+ purchased_license_package_id String
2997
+ status PurchasedHiringUnitStatus @default(AVAILABLE)
2998
+ /// Current department allocation (licensing allocation, not hiring manager).
2999
+ department_id String?
3000
+ /// Set once when department_id is first assigned; not cleared on reassignment.
3001
+ first_assigned_at DateTime?
3002
+ /// Optional unit expiry.
3003
+ expiry_at DateTime?
3004
+ /// Optional job association (distinct from JobDescription.hiring_manager_id).
3005
+ job_description_id String?
3006
+
3007
+ created_at DateTime @default(now())
3008
+ updated_at DateTime @updatedAt
3009
+ created_by String
3010
+ updated_by String
3011
+ is_active Boolean @default(true)
3012
+
3013
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
3014
+ purchased_license_package PurchasedLicensePackage @relation(fields: [purchased_license_package_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
3015
+ department Department? @relation(fields: [department_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
3016
+ job_description JobDescription? @relation(fields: [job_description_id], references: [id], onDelete: SetNull, onUpdate: Cascade)
3017
+ assignment_events PurchasedHiringUnitAssignmentEvent[]
3018
+ ledger_entries LicensingLedgerEntry[]
3019
+ ai_cost_ledger_entries AiCostLedgerEntry[]
3020
+
3021
+ @@index([organisation_id])
3022
+ @@index([purchased_license_package_id])
3023
+ @@index([department_id])
3024
+ @@index([job_description_id])
3025
+ @@index([organisation_id, status])
3026
+ @@index([organisation_id, department_id])
3027
+ @@index([organisation_id, job_description_id])
3028
+ @@map("purchased_hiring_units")
3029
+ @@schema("licensing")
3030
+ }
3031
+
3032
+ /// Wide top-up purchase: org-level per-metric pool (purchased / remaining) before allocation to hiring units.
3033
+ model PurchasedTopUp {
3034
+ id String @id @default(uuid())
3035
+ organisation_id String
3036
+ purchased_at DateTime @default(now())
3037
+ status PurchasedTopUpStatus @default(ACTIVE)
3038
+ total_price Decimal? @db.Decimal(18, 2)
3039
+ currency String? @default("INR")
3040
+ description String?
3041
+
3042
+ interview_ai_assisted_hours_purchased Decimal? @db.Decimal(20, 4)
3043
+ interview_full_ai_hours_purchased Decimal? @db.Decimal(20, 4)
3044
+ interview_non_ai_hours_purchased Decimal? @db.Decimal(20, 4)
3045
+ assignment_count_purchased Decimal? @db.Decimal(20, 4)
3046
+ test_count_purchased Decimal? @db.Decimal(20, 4)
3047
+ resume_count_purchased Decimal? @db.Decimal(20, 4)
3048
+ credits_purchased Decimal? @db.Decimal(20, 4)
3049
+
3050
+ interview_ai_assisted_hours_remaining Decimal? @db.Decimal(20, 4)
3051
+ interview_full_ai_hours_remaining Decimal? @db.Decimal(20, 4)
3052
+ interview_non_ai_hours_remaining Decimal? @db.Decimal(20, 4)
3053
+ assignment_count_remaining Decimal? @db.Decimal(20, 4)
3054
+ test_count_remaining Decimal? @db.Decimal(20, 4)
3055
+ resume_count_remaining Decimal? @db.Decimal(20, 4)
3056
+ credits_remaining Decimal? @db.Decimal(20, 4)
3057
+
3058
+ created_at DateTime @default(now())
3059
+ updated_at DateTime @updatedAt
3060
+ created_by String
3061
+ updated_by String
3062
+ is_active Boolean @default(true)
3063
+
3064
+ organisation Organisation @relation(fields: [organisation_id], references: [id], onDelete: Restrict, onUpdate: Cascade)
3065
+
3066
+ @@index([organisation_id])
3067
+ @@index([organisation_id, status])
3068
+ @@map("purchased_top_ups")
3069
+ @@schema("licensing")
3070
+ }
3071
+
2727
3072
  model LiveAnalysis {
2728
3073
  id String @id @default(uuid())
2729
3074
  //foreign keys
@@ -3146,65 +3491,71 @@ enum OrganisationSize {
3146
3491
  }
3147
3492
 
3148
3493
  model Organisation {
3149
- id String @id @default(uuid())
3150
- name String @unique
3151
- industry String
3152
- about String
3153
- website String
3154
- size OrganisationSize @default(ONE_TO_TEN)
3155
- phone String
3156
- address String
3157
- company_values Json[]
3158
- allowed_email_domains String[]
3159
- send_email Boolean @default(true)
3160
- interviewers User[]
3161
- created_at DateTime @default(now())
3162
- updated_at DateTime @updatedAt
3163
- created_by String
3164
- updated_by String
3165
- is_active Boolean @default(true)
3166
- alias String? @unique
3167
- logo String?
3168
- job_sequence Int @default(1)
3169
- employee_sequence Int @default(1)
3170
- applications Application[]
3171
- user_roles UserRole[]
3172
- job_descriptions JobDescription[]
3173
- job_profiles JobProfile[]
3174
- assessment_library AssessmentLibrary[]
3175
- assignment_library AssignmentLibrary[]
3176
- interviews Interview[]
3177
- assignments Assignment[]
3178
- fit_check FitCheck[] // one-to-many link
3179
- resumes Resume[] // one-to-many link
3180
- approvals Approval[] // one-to-many link
3181
- suggestions Suggestion[]
3182
- ongoing_evaluations OngoingEvaluation[] // optional one-to-many
3183
- actions Action[]
3184
- integration_credentials IntegrationCredential[]
3185
- zoho_sync_mappings ZohoSyncMapping[]
3186
- assessments Assessment[]
3187
- timezone String @default("Asia/Kolkata")
3494
+ id String @id @default(uuid())
3495
+ name String @unique
3496
+ industry String
3497
+ about String
3498
+ website String
3499
+ size OrganisationSize @default(ONE_TO_TEN)
3500
+ phone String
3501
+ address String
3502
+ company_values Json[]
3503
+ allowed_email_domains String[]
3504
+ send_email Boolean @default(true)
3505
+ interviewers User[]
3506
+ created_at DateTime @default(now())
3507
+ updated_at DateTime @updatedAt
3508
+ created_by String
3509
+ updated_by String
3510
+ is_active Boolean @default(true)
3511
+ alias String? @unique
3512
+ logo String?
3513
+ job_sequence Int @default(1)
3514
+ employee_sequence Int @default(1)
3515
+ applications Application[]
3516
+ user_roles UserRole[]
3517
+ job_descriptions JobDescription[]
3518
+ job_profiles JobProfile[]
3519
+ assessment_library AssessmentLibrary[]
3520
+ assignment_library AssignmentLibrary[]
3521
+ interviews Interview[]
3522
+ assignments Assignment[]
3523
+ fit_check FitCheck[] // one-to-many link
3524
+ resumes Resume[] // one-to-many link
3525
+ approvals Approval[] // one-to-many link
3526
+ suggestions Suggestion[]
3527
+ ongoing_evaluations OngoingEvaluation[] // optional one-to-many
3528
+ actions Action[]
3529
+ integration_credentials IntegrationCredential[]
3530
+ zoho_sync_mappings ZohoSyncMapping[]
3531
+ assessments Assessment[]
3532
+ timezone String @default("Asia/Kolkata")
3188
3533
  /// ISO 3166-1 alpha-2 (e.g. IN).
3189
- country_code String @default("IN")
3190
- organisation_configs OrganisationConfig[]
3191
- activity_events ActivityEvent[]
3192
- usage_ledger_entries UsageLedgerEntry[]
3193
- usage_aggregates UsageAggregate[]
3194
- channel_provider_configs ChannelProviderConfig[]
3195
- conversations Conversation[]
3196
- communication_messages CommunicationMessage[]
3197
- job_application_fields JobApplicationField[]
3198
- documents Document[]
3199
- job_application_templates JobApplicationTemplate[]
3200
- offer_letter_templates OfferLetterTemplate[]
3201
- offers Offer[]
3202
- sources Source[]
3203
- evaluation_criteria EvaluationCriteria[]
3204
- departments Department[]
3205
- hiring_plans HiringPlan[]
3206
- employees Employee[]
3207
- competency_dictionaries CompetencyDictionary[]
3534
+ country_code String @default("IN")
3535
+ organisation_configs OrganisationConfig[]
3536
+ activity_events ActivityEvent[]
3537
+ usage_ledger_entries UsageLedgerEntry[]
3538
+ usage_aggregates UsageAggregate[]
3539
+ channel_provider_configs ChannelProviderConfig[]
3540
+ conversations Conversation[]
3541
+ communication_messages CommunicationMessage[]
3542
+ job_application_fields JobApplicationField[]
3543
+ documents Document[]
3544
+ job_application_templates JobApplicationTemplate[]
3545
+ offer_letter_templates OfferLetterTemplate[]
3546
+ offers Offer[]
3547
+ sources Source[]
3548
+ evaluation_criteria EvaluationCriteria[]
3549
+ departments Department[]
3550
+ hiring_plans HiringPlan[]
3551
+ employees Employee[]
3552
+ competency_dictionaries CompetencyDictionary[]
3553
+ purchased_license_packages PurchasedLicensePackage[]
3554
+ purchased_hiring_units PurchasedHiringUnit[]
3555
+ purchased_top_ups PurchasedTopUp[]
3556
+ licensing_ledger_entries LicensingLedgerEntry[]
3557
+ license_package_organisations LicensePackageOrganisation[]
3558
+ ai_cost_ledger_entries AiCostLedgerEntry[]
3208
3559
 
3209
3560
  @@index([name])
3210
3561
  @@schema("public")
@@ -3669,7 +4020,7 @@ datasource db {
3669
4020
  provider = "postgresql"
3670
4021
  url = env("DATABASE_URL")
3671
4022
 
3672
- schemas = ["public", "analytics", "usage"]
4023
+ schemas = ["public", "analytics", "usage", "licensing"]
3673
4024
  }
3674
4025
 
3675
4026
  enum SourceCategory {
@@ -4028,8 +4379,6 @@ model User {
4028
4379
 
4029
4380
  name String?
4030
4381
  phone String?
4031
- /// Contact email for interviews, assessments, and resume export. Login stays on `email`.
4032
- communication_email String?
4033
4382
  description String?
4034
4383
  date_of_birth DateTime?
4035
4384
  designation String?