@adaptware/eagles-db 0.6.2 → 0.6.5

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 (68) hide show
  1. package/client/edge.js +58 -88
  2. package/client/index-browser.js +53 -83
  3. package/client/index.d.ts +8707 -5629
  4. package/client/index.js +58 -88
  5. package/client/package.json +1 -1
  6. package/client/schema.prisma +224 -256
  7. package/client/wasm.js +58 -88
  8. package/package.json +1 -1
  9. package/prisma/schema/consent.prisma +108 -34
  10. package/prisma/schema/document.prisma +1 -0
  11. package/prisma/schema/integration.prisma +0 -1
  12. package/prisma/schema/jobDescription.prisma +38 -37
  13. package/prisma/schema/migrations/20261006120000_add_jd_restrict_candidate_upload/migration.sql +2 -0
  14. package/prisma/schema/organisation.prisma +6 -2
  15. package/prisma/schema/user.prisma +2 -0
  16. package/client/libquery_engine-darwin.dylib.node +0 -0
  17. package/client/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
  18. package/client/query_engine-windows.dll.node +0 -0
  19. package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +0 -25
  20. package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +0 -24
  21. package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +0 -2
  22. package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +0 -9
  23. package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +0 -8
  24. package/prisma/schema/migrations/20260716120000_add_offer_letters/migration.sql +0 -183
  25. package/prisma/schema/migrations/20260716140000_offer_schema_refinements/migration.sql +0 -13
  26. package/prisma/schema/migrations/20260716160000_offer_schema_hardening/migration.sql +0 -95
  27. package/prisma/schema/migrations/20260716180000_offer_letter_template_config/migration.sql +0 -2
  28. package/prisma/schema/migrations/20260716190000_add_evaluation_focus_areas/migration.sql +0 -6
  29. package/prisma/schema/migrations/20260717120000_offer_workflow_approval/migration.sql +0 -30
  30. package/prisma/schema/migrations/20260720120000_offer_letter_template_is_draft/migration.sql +0 -5
  31. package/prisma/schema/migrations/20260720140000_offer_status_split/migration.sql +0 -51
  32. package/prisma/schema/migrations/20260720140001_offer_status_split_backfill/migration.sql +0 -37
  33. package/prisma/schema/migrations/20260722120000_offer_draft_edited_html/migration.sql +0 -13
  34. package/prisma/schema/migrations/20260723150000_offer_withdraw_actor_no_show_reason/migration.sql +0 -10
  35. package/prisma/schema/migrations/20260724120000_open_job_offer_accepted_declined_counts/migration.sql +0 -7
  36. package/prisma/schema/migrations/20260811120000_add_integration_provider_razorpay/migration.sql +0 -6
  37. package/prisma/schema/migrations/20260812120000_add_billing_transactions/migration.sql +0 -49
  38. package/prisma/schema/migrations/20260812130000_drop_billing_transaction_gst_snapshots/migration.sql +0 -3
  39. package/prisma/schema/migrations/20260812180000_billing_transaction_invoice_number/migration.sql +0 -5
  40. package/prisma/schema/migrations/20260813120000_payment_webhooks_gst_refunds/migration.sql +0 -79
  41. package/prisma/schema/migrations/20260813140000_platform_gst_profiles/migration.sql +0 -49
  42. package/prisma/schema/migrations/20260813150000_rename_gst_profiles/migration.sql +0 -53
  43. package/prisma/schema/migrations/20260813160000_remove_gst_billing/migration.sql +0 -16
  44. package/prisma/schema/migrations/20260813170000_billing_licensing_unrecoverable/migration.sql +0 -2
  45. package/prisma/schema/migrations/20260813180000_billing_transaction_payment_method/migration.sql +0 -2
  46. package/prisma/schema/migrations/20260814090000_billing_transaction_purchaser_email/migration.sql +0 -2
  47. package/prisma/schema/migrations/20260816100000_billing_product_organisations/migration.sql +0 -35
  48. package/prisma/schema/migrations/20260816120000_merge_billing_product_organisations/migration.sql +0 -25
  49. package/prisma/schema/migrations/20260817120000_billing_payment_mismatch/migration.sql +0 -7
  50. package/prisma/schema/migrations/20260819120000_billing_product_prices/migration.sql +0 -62
  51. package/prisma/schema/migrations/20260819140000_billing_exchange_rates/migration.sql +0 -25
  52. package/prisma/schema/migrations/20260820120000_billing_transaction_failure_category/migration.sql +0 -31
  53. package/prisma/schema/migrations/20260820130000_backfill_billing_transaction_failure_details/migration.sql +0 -23
  54. package/prisma/schema/migrations/20260820140000_drop_billing_product_price_overrides/migration.sql +0 -2
  55. package/prisma/schema/migrations/20260821120000_drop_billing_product_and_mock_licensing/migration.sql +0 -38
  56. package/prisma/schema/migrations/20260824120000_billing_transaction_purchase_display_name/migration.sql +0 -2
  57. package/prisma/schema/migrations/20260831120000_user_communication_email/migration.sql +0 -6
  58. package/prisma/schema/migrations/20260901143000_assessment_question_bank_state/migration.sql +0 -15
  59. package/prisma/schema/migrations/20260902120000_question_category_two_values/migration.sql +0 -16
  60. package/prisma/schema/migrations/20260902143000_question_bank_item_key/migration.sql +0 -17
  61. package/prisma/schema/migrations/20260903120000_split_round_type_assessment/migration.sql +0 -9
  62. package/prisma/schema/migrations/20260904110000_restore_round_type_assessment_enum/migration.sql +0 -5
  63. package/prisma/schema/migrations/20260904120000_revert_wrong_split_assessment_round_types/migration.sql +0 -42
  64. package/prisma/schema/migrations/20260909140000_profile_interview_session/migration.sql +0 -99
  65. package/prisma/schema/migrations/20260911120000_unify_profile_interview_into_interview/migration.sql +0 -139
  66. package/prisma/schema/migrations/20260929120000_add_evaluation_type_in_person/migration.sql +0 -2
  67. package/prisma/schema/payment/billingTransaction.prisma +0 -83
  68. package/prisma/schema/payment/paymentWebhookEvent.prisma +0 -28
@@ -1,62 +0,0 @@
1
- -- CreateTable
2
- CREATE TABLE "billing_product_prices" (
3
- "id" TEXT NOT NULL,
4
- "product_id" TEXT NOT NULL,
5
- "currency" TEXT NOT NULL,
6
- "amount" INTEGER NOT NULL,
7
- "is_active" BOOLEAN NOT NULL DEFAULT true,
8
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
- "updated_at" TIMESTAMP(3) NOT NULL,
10
-
11
- CONSTRAINT "billing_product_prices_pkey" PRIMARY KEY ("id")
12
- );
13
-
14
- -- CreateTable
15
- CREATE TABLE "billing_product_price_overrides" (
16
- "id" TEXT NOT NULL,
17
- "product_id" TEXT NOT NULL,
18
- "country_code" TEXT NOT NULL,
19
- "currency" TEXT NOT NULL,
20
- "amount" INTEGER NOT NULL,
21
- "is_active" BOOLEAN NOT NULL DEFAULT true,
22
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
- "updated_at" TIMESTAMP(3) NOT NULL,
24
-
25
- CONSTRAINT "billing_product_price_overrides_pkey" PRIMARY KEY ("id")
26
- );
27
-
28
- -- CreateIndex
29
- CREATE UNIQUE INDEX "billing_product_prices_product_id_currency_key" ON "billing_product_prices"("product_id", "currency");
30
-
31
- -- CreateIndex
32
- CREATE INDEX "billing_product_prices_product_id_is_active_idx" ON "billing_product_prices"("product_id", "is_active");
33
-
34
- -- CreateIndex
35
- CREATE UNIQUE INDEX "billing_product_price_overrides_product_id_country_code_key" ON "billing_product_price_overrides"("product_id", "country_code");
36
-
37
- -- CreateIndex
38
- CREATE INDEX "billing_product_price_overrides_product_id_is_active_idx" ON "billing_product_price_overrides"("product_id", "is_active");
39
-
40
- -- AddForeignKey
41
- ALTER TABLE "billing_product_prices" ADD CONSTRAINT "billing_product_prices_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "billing_products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
42
-
43
- -- AddForeignKey
44
- ALTER TABLE "billing_product_price_overrides" ADD CONSTRAINT "billing_product_price_overrides_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "billing_products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
45
-
46
- -- Backfill one currency price per existing product from scalar price_amount/currency
47
- -- (already stored in minor units). Scalar columns are retained until callers migrate.
48
- INSERT INTO "billing_product_prices" ("id", "product_id", "currency", "amount", "is_active", "created_at", "updated_at")
49
- SELECT gen_random_uuid()::text,
50
- bp."id",
51
- bp."currency",
52
- bp."price_amount",
53
- bp."is_active",
54
- bp."created_at",
55
- bp."updated_at"
56
- FROM "billing_products" AS bp
57
- WHERE NOT EXISTS (
58
- SELECT 1
59
- FROM "billing_product_prices" AS bpp
60
- WHERE bpp."product_id" = bp."id"
61
- AND bpp."currency" = bp."currency"
62
- );
@@ -1,25 +0,0 @@
1
- -- CreateTable
2
- CREATE TABLE "billing_exchange_rates" (
3
- "id" TEXT NOT NULL,
4
- "from_currency" TEXT NOT NULL,
5
- "to_currency" TEXT NOT NULL,
6
- "rate" DECIMAL(20,10) NOT NULL,
7
- "is_active" BOOLEAN NOT NULL DEFAULT true,
8
- "updated_by" TEXT NOT NULL,
9
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
- "updated_at" TIMESTAMP(3) NOT NULL,
11
-
12
- CONSTRAINT "billing_exchange_rates_pkey" PRIMARY KEY ("id")
13
- );
14
-
15
- -- CreateIndex
16
- CREATE UNIQUE INDEX "billing_exchange_rates_from_currency_to_currency_key" ON "billing_exchange_rates"("from_currency", "to_currency");
17
-
18
- -- CreateIndex
19
- CREATE INDEX "billing_exchange_rates_is_active_idx" ON "billing_exchange_rates"("is_active");
20
-
21
- -- Seed v1 INR ↔ USD rates used by the admin converter (major units).
22
- INSERT INTO "billing_exchange_rates" ("id", "from_currency", "to_currency", "rate", "is_active", "updated_by", "created_at", "updated_at")
23
- VALUES
24
- (gen_random_uuid()::text, 'INR', 'USD', 0.0117000000, true, 'system', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
25
- (gen_random_uuid()::text, 'USD', 'INR', 85.4700854701, true, 'system', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
@@ -1,31 +0,0 @@
1
- -- CreateEnum
2
- CREATE TYPE "BillingTransactionFailureCategory" AS ENUM ('RAZORPAY_ORDER', 'RAZORPAY_PAYMENT', 'LICENSING', 'REFUND', 'INTERNAL');
3
-
4
- -- Add failure_category and migrate enum failure_reason to text detail
5
- ALTER TABLE "billing_transactions" ADD COLUMN "failure_category" "BillingTransactionFailureCategory";
6
- ALTER TABLE "billing_transactions" ADD COLUMN "failure_reason_text" TEXT;
7
-
8
- UPDATE "billing_transactions"
9
- SET
10
- "failure_category" = CASE "failure_reason"::text
11
- WHEN 'RAZORPAY_ORDER_CREATION_FAILED' THEN 'RAZORPAY_ORDER'::"BillingTransactionFailureCategory"
12
- WHEN 'PAYMENT_FAILED' THEN 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory"
13
- WHEN 'PAYMENT_CANCELLED' THEN 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory"
14
- WHEN 'WEBHOOK_PROCESSING_FAILED' THEN 'INTERNAL'::"BillingTransactionFailureCategory"
15
- WHEN 'LICENSING_GRANT_FAILED' THEN 'LICENSING'::"BillingTransactionFailureCategory"
16
- WHEN 'REFUND_FAILED' THEN 'REFUND'::"BillingTransactionFailureCategory"
17
- END,
18
- "failure_reason_text" = CASE "failure_reason"::text
19
- WHEN 'RAZORPAY_ORDER_CREATION_FAILED' THEN 'Razorpay order creation failed'
20
- WHEN 'PAYMENT_FAILED' THEN 'Payment failed'
21
- WHEN 'PAYMENT_CANCELLED' THEN 'Payment was cancelled'
22
- WHEN 'WEBHOOK_PROCESSING_FAILED' THEN 'Webhook processing failed'
23
- WHEN 'LICENSING_GRANT_FAILED' THEN 'Unable to provision purchased entitlements'
24
- WHEN 'REFUND_FAILED' THEN 'Refund failed'
25
- END
26
- WHERE "failure_reason" IS NOT NULL;
27
-
28
- ALTER TABLE "billing_transactions" DROP COLUMN "failure_reason";
29
- DROP TYPE "BillingTransactionFailureReason";
30
-
31
- ALTER TABLE "billing_transactions" RENAME COLUMN "failure_reason_text" TO "failure_reason";
@@ -1,23 +0,0 @@
1
- -- Historical FAILED rows were stored without failure_category / failure_reason.
2
- UPDATE "billing_transactions"
3
- SET
4
- "failure_category" = 'RAZORPAY_ORDER'::"BillingTransactionFailureCategory",
5
- "failure_reason" = 'Checkout failed before a Razorpay order was created'
6
- WHERE "status" = 'FAILED'
7
- AND "failure_reason" IS NULL
8
- AND "razorpay_order_id" IS NULL;
9
-
10
- UPDATE "billing_transactions"
11
- SET
12
- "failure_category" = 'RAZORPAY_PAYMENT'::"BillingTransactionFailureCategory",
13
- "failure_reason" = 'Payment failed'
14
- WHERE "status" = 'FAILED'
15
- AND "failure_reason" IS NULL
16
- AND "razorpay_order_id" IS NOT NULL;
17
-
18
- UPDATE "billing_transactions"
19
- SET
20
- "failure_category" = 'REFUND'::"BillingTransactionFailureCategory",
21
- "failure_reason" = 'Refund failed'
22
- WHERE "status" = 'REFUND_FAILED'
23
- AND "failure_reason" IS NULL;
@@ -1,2 +0,0 @@
1
- -- DropTable
2
- DROP TABLE IF EXISTS "billing_product_price_overrides";
@@ -1,38 +0,0 @@
1
- -- Preserve all billing_transactions rows.
2
- -- Rename product identity to an opaque purchase_reference (values unchanged).
3
- -- Drop catalog tables and mock licensing column only.
4
-
5
- -- 1. Drop FK + rename product identity column
6
- ALTER TABLE "billing_transactions" DROP CONSTRAINT IF EXISTS "billing_transactions_product_id_fkey";
7
- ALTER TABLE "billing_transactions" RENAME COLUMN "product_id" TO "purchase_reference";
8
- DROP INDEX IF EXISTS "billing_transactions_product_id_idx";
9
- CREATE INDEX "billing_transactions_purchase_reference_idx" ON "billing_transactions"("purchase_reference");
10
-
11
- -- 2. Drop mock licensing columns/indexes
12
- DROP INDEX IF EXISTS "billing_transactions_licensing_status_idx";
13
- ALTER TABLE "billing_transactions" DROP COLUMN IF EXISTS "licensing_status";
14
-
15
- -- 3. Remap mock licensing failure category, then rebuild enum without LICENSING
16
- UPDATE "billing_transactions"
17
- SET "failure_category" = 'INTERNAL'::"BillingTransactionFailureCategory"
18
- WHERE "failure_category" = 'LICENSING'::"BillingTransactionFailureCategory";
19
-
20
- CREATE TYPE "BillingTransactionFailureCategory_new" AS ENUM ('RAZORPAY_ORDER', 'RAZORPAY_PAYMENT', 'REFUND', 'INTERNAL');
21
-
22
- ALTER TABLE "billing_transactions"
23
- ALTER COLUMN "failure_category" TYPE "BillingTransactionFailureCategory_new"
24
- USING ("failure_category"::text::"BillingTransactionFailureCategory_new");
25
-
26
- DROP TYPE "BillingTransactionFailureCategory";
27
- ALTER TYPE "BillingTransactionFailureCategory_new" RENAME TO "BillingTransactionFailureCategory";
28
-
29
- -- 4. Drop catalog tables (order: prices → products)
30
- DROP TABLE IF EXISTS "billing_product_prices";
31
- DROP TABLE IF EXISTS "billing_products";
32
-
33
- -- 5. Drop catalog FX table
34
- DROP TABLE IF EXISTS "billing_exchange_rates";
35
-
36
- -- 6. Drop unused enums
37
- DROP TYPE IF EXISTS "BillingLicensingStatus";
38
- DROP TYPE IF EXISTS "BillingProductType";
@@ -1,2 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "billing_transactions" ADD COLUMN IF NOT EXISTS "purchase_display_name" TEXT;
@@ -1,6 +0,0 @@
1
- -- Candidate contact email (separate from login `email`).
2
- ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "communication_email" TEXT;
3
-
4
- UPDATE "User"
5
- SET "communication_email" = "email"
6
- WHERE "communication_email" IS NULL;
@@ -1,15 +0,0 @@
1
- -- Question bank: category + stable plan identity on reusable Question rows.
2
- CREATE TYPE "QuestionCategory" AS ENUM (
3
- 'GENERAL_APTITUDE',
4
- 'DOMAIN_APTITUDE',
5
- 'DOMAIN_KNOWLEDGE'
6
- );
7
-
8
- ALTER TABLE "Question" ADD COLUMN IF NOT EXISTS "category" "QuestionCategory";
9
- ALTER TABLE "Question" ADD COLUMN IF NOT EXISTS "plan_index" INTEGER;
10
-
11
- CREATE INDEX IF NOT EXISTS "Question_assessment_library_id_candidate_id_plan_index_idx"
12
- ON "Question" ("assessment_library_id", "candidate_id", "plan_index");
13
-
14
- -- Incremental bank generation state on the reusable AssessmentLibrary.
15
- ALTER TABLE "AssessmentLibrary" ADD COLUMN IF NOT EXISTS "generation_state" JSONB;
@@ -1,16 +0,0 @@
1
- -- Collapse QuestionCategory to GENERAL_APTITUDE + DOMAIN_KNOWLEDGE (drop DOMAIN_APTITUDE).
2
- UPDATE "Question"
3
- SET category = 'DOMAIN_KNOWLEDGE'
4
- WHERE category = 'DOMAIN_APTITUDE';
5
-
6
- CREATE TYPE "QuestionCategory_new" AS ENUM (
7
- 'GENERAL_APTITUDE',
8
- 'DOMAIN_KNOWLEDGE'
9
- );
10
-
11
- ALTER TABLE "Question"
12
- ALTER COLUMN "category" TYPE "QuestionCategory_new"
13
- USING ("category"::text::"QuestionCategory_new");
14
-
15
- DROP TYPE "QuestionCategory";
16
- ALTER TYPE "QuestionCategory_new" RENAME TO "QuestionCategory";
@@ -1,17 +0,0 @@
1
- -- Replace plan_index on Question with deterministic bank_item_key for idempotent persist.
2
-
3
- ALTER TABLE "Question" ADD COLUMN IF NOT EXISTS "bank_item_key" TEXT;
4
-
5
- UPDATE "Question"
6
- SET "bank_item_key" = 'legacy:' || "assessment_library_id" || ':' || "plan_index"::text
7
- WHERE "candidate_id" IS NULL
8
- AND "plan_index" IS NOT NULL
9
- AND "bank_item_key" IS NULL
10
- AND "assessment_library_id" IS NOT NULL;
11
-
12
- DROP INDEX IF EXISTS "Question_assessment_library_id_candidate_id_plan_index_idx";
13
-
14
- ALTER TABLE "Question" DROP COLUMN IF EXISTS "plan_index";
15
-
16
- CREATE UNIQUE INDEX IF NOT EXISTS "Question_assessment_library_id_bank_item_key_key"
17
- ON "Question" ("assessment_library_id", "bank_item_key");
@@ -1,9 +0,0 @@
1
- -- Add explicit MCQ round types for NEW aptitude / domain knowledge tests.
2
- --
3
- -- Keep RoundType.ASSESSMENT for backward compatibility.
4
- -- Do NOT rewrite EvaluationPlan, OngoingEvaluation, or analytics rows.
5
- -- Do NOT drop or recreate the enum.
6
- -- Do NOT touch ActivityEventType.ASSESSMENT_* or ActivityEntityType.ASSESSMENT.
7
-
8
- ALTER TYPE "RoundType" ADD VALUE IF NOT EXISTS 'GENERAL_APTITUDE_ASSESSMENT';
9
- ALTER TYPE "RoundType" ADD VALUE IF NOT EXISTS 'DOMAIN_KNOWLEDGE_ASSESSMENT';
@@ -1,5 +0,0 @@
1
- -- Restore legacy RoundType.ASSESSMENT when an older enum swap dropped it.
2
- -- Must run in its own migration: PostgreSQL requires new enum values to be
3
- -- committed before they can be assigned to rows (see revert migration next).
4
-
5
- ALTER TYPE "RoundType" ADD VALUE IF NOT EXISTS 'ASSESSMENT';
@@ -1,42 +0,0 @@
1
- -- Revert evaluation plans that were incorrectly stored as split MCQ round types
2
- -- back to legacy ASSESSMENT.
3
- --
4
- -- Does NOT change rows already on ASSESSMENT.
5
- -- Keeps intentional new GENERAL_APTITUDE_ASSESSMENT / DOMAIN_KNOWLEDGE_ASSESSMENT
6
- -- rounds when title or details show an explicit split-type configuration.
7
- --
8
- -- Requires 20260904110000_restore_round_type_assessment_enum to run first so
9
- -- RoundType.ASSESSMENT exists (some DBs lost it during an earlier bad enum swap).
10
-
11
- UPDATE "EvaluationPlan"
12
- SET type_of_round = 'ASSESSMENT'
13
- WHERE is_active = true
14
- AND type_of_round IN ('GENERAL_APTITUDE_ASSESSMENT', 'DOMAIN_KNOWLEDGE_ASSESSMENT')
15
- AND (
16
- (
17
- COALESCE((details #>> '{question_category_distribution,GENERAL_APTITUDE}')::int, 0) > 0
18
- AND COALESCE((details #>> '{question_category_distribution,DOMAIN_KNOWLEDGE}')::int, 0) > 0
19
- )
20
- OR (
21
- upper(COALESCE(details->>'primary_question_category', '')) = 'GENERAL_APTITUDE'
22
- AND type_of_round = 'DOMAIN_KNOWLEDGE_ASSESSMENT'
23
- )
24
- OR (
25
- upper(COALESCE(details->>'primary_question_category', '')) = 'DOMAIN_KNOWLEDGE'
26
- AND type_of_round = 'GENERAL_APTITUDE_ASSESSMENT'
27
- )
28
- OR (
29
- type_of_round = 'DOMAIN_KNOWLEDGE_ASSESSMENT'
30
- AND lower(title) !~* '(domain knowledge|domain test|backend domain|frontend domain|\mdomain\M)'
31
- AND COALESCE((details #>> '{question_category_distribution,GENERAL_APTITUDE}')::int, 0) = 0
32
- AND COALESCE((details #>> '{question_category_distribution,DOMAIN_KNOWLEDGE}')::int, 0) = 0
33
- AND NULLIF(trim(COALESCE(details->>'primary_question_category', '')), '') IS NULL
34
- )
35
- OR (
36
- type_of_round = 'GENERAL_APTITUDE_ASSESSMENT'
37
- AND lower(title) !~* '(aptitude|general aptitude|numerical|verbal reasoning|logical reasoning)'
38
- AND COALESCE((details #>> '{question_category_distribution,GENERAL_APTITUDE}')::int, 0) = 0
39
- AND COALESCE((details #>> '{question_category_distribution,DOMAIN_KNOWLEDGE}')::int, 0) = 0
40
- AND NULLIF(trim(COALESCE(details->>'primary_question_category', '')), '') IS NULL
41
- )
42
- );
@@ -1,99 +0,0 @@
1
- -- CreateEnum (idempotent: enum may already exist from a prior partial apply)
2
- DO $$ BEGIN
3
- CREATE TYPE "public"."ProfileInterviewSessionStatus" AS ENUM (
4
- 'SCHEDULED',
5
- 'IN_PROGRESS',
6
- 'COMPLETED',
7
- 'CANCELLED'
8
- );
9
- EXCEPTION
10
- WHEN duplicate_object THEN NULL;
11
- END $$;
12
-
13
- -- CreateTable
14
- CREATE TABLE IF NOT EXISTS "public"."ProfileInterviewSession" (
15
- "id" TEXT NOT NULL,
16
- "candidate_id" TEXT NOT NULL,
17
- "organisation_id" TEXT,
18
- "resume_id" TEXT NOT NULL,
19
- "job_description_id" TEXT,
20
- "purpose" TEXT NOT NULL,
21
- "focus_areas" JSONB NOT NULL,
22
- "duration_minutes" INTEGER NOT NULL,
23
- "room_name" TEXT NOT NULL,
24
- "status" "public"."ProfileInterviewSessionStatus" NOT NULL DEFAULT 'SCHEDULED',
25
- "actual_start_time" TIMESTAMP(3),
26
- "actual_end_time" TIMESTAMP(3),
27
- "evidence_result" JSONB,
28
- "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
29
- "updated_at" TIMESTAMP(3) NOT NULL,
30
- "created_by" TEXT NOT NULL,
31
- "updated_by" TEXT NOT NULL,
32
- "is_active" BOOLEAN NOT NULL DEFAULT true,
33
-
34
- CONSTRAINT "ProfileInterviewSession_pkey" PRIMARY KEY ("id")
35
- );
36
-
37
- -- AlterTable
38
- ALTER TABLE "public"."Transcript"
39
- ADD COLUMN IF NOT EXISTS "profile_interview_session_id" TEXT;
40
-
41
- -- CreateIndex
42
- CREATE INDEX IF NOT EXISTS "ProfileInterviewSession_candidate_id_idx"
43
- ON "public"."ProfileInterviewSession"("candidate_id");
44
-
45
- CREATE INDEX IF NOT EXISTS "ProfileInterviewSession_candidate_id_status_idx"
46
- ON "public"."ProfileInterviewSession"("candidate_id", "status");
47
-
48
- CREATE INDEX IF NOT EXISTS "Transcript_profile_interview_session_id_idx"
49
- ON "public"."Transcript"("profile_interview_session_id");
50
-
51
- CREATE UNIQUE INDEX IF NOT EXISTS "Transcript_profile_interview_session_id_order_no_key"
52
- ON "public"."Transcript"("profile_interview_session_id", "order_no");
53
-
54
- -- AddForeignKey (idempotent)
55
- DO $$ BEGIN
56
- ALTER TABLE "public"."ProfileInterviewSession"
57
- ADD CONSTRAINT "ProfileInterviewSession_candidate_id_fkey"
58
- FOREIGN KEY ("candidate_id") REFERENCES "public"."User"("id")
59
- ON DELETE CASCADE ON UPDATE CASCADE;
60
- EXCEPTION
61
- WHEN duplicate_object THEN NULL;
62
- END $$;
63
-
64
- DO $$ BEGIN
65
- ALTER TABLE "public"."ProfileInterviewSession"
66
- ADD CONSTRAINT "ProfileInterviewSession_organisation_id_fkey"
67
- FOREIGN KEY ("organisation_id") REFERENCES "public"."Organisation"("id")
68
- ON DELETE SET NULL ON UPDATE CASCADE;
69
- EXCEPTION
70
- WHEN duplicate_object THEN NULL;
71
- END $$;
72
-
73
- DO $$ BEGIN
74
- ALTER TABLE "public"."ProfileInterviewSession"
75
- ADD CONSTRAINT "ProfileInterviewSession_resume_id_fkey"
76
- FOREIGN KEY ("resume_id") REFERENCES "public"."Resume"("id")
77
- ON DELETE CASCADE ON UPDATE CASCADE;
78
- EXCEPTION
79
- WHEN duplicate_object THEN NULL;
80
- END $$;
81
-
82
- DO $$ BEGIN
83
- ALTER TABLE "public"."ProfileInterviewSession"
84
- ADD CONSTRAINT "ProfileInterviewSession_job_description_id_fkey"
85
- FOREIGN KEY ("job_description_id") REFERENCES "public"."JobDescription"("id")
86
- ON DELETE SET NULL ON UPDATE CASCADE;
87
- EXCEPTION
88
- WHEN duplicate_object THEN NULL;
89
- END $$;
90
-
91
- DO $$ BEGIN
92
- ALTER TABLE "public"."Transcript"
93
- ADD CONSTRAINT "Transcript_profile_interview_session_id_fkey"
94
- FOREIGN KEY ("profile_interview_session_id")
95
- REFERENCES "public"."ProfileInterviewSession"("id")
96
- ON DELETE SET NULL ON UPDATE SET NULL;
97
- EXCEPTION
98
- WHEN duplicate_object THEN NULL;
99
- END $$;
@@ -1,139 +0,0 @@
1
- -- AlterTable: candidate-initiated profile AI on Interview
2
- ALTER TABLE "public"."Interview" ADD COLUMN "candidate_initiated" BOOLEAN NOT NULL DEFAULT false;
3
- ALTER TABLE "public"."Interview" ADD COLUMN "candidate_interview_metadata" JSONB;
4
-
5
- -- Relax FK columns for profile rows
6
- ALTER TABLE "public"."Interview" ALTER COLUMN "organisation_id" DROP NOT NULL;
7
- ALTER TABLE "public"."Interview" ALTER COLUMN "job_description_id" DROP NOT NULL;
8
- ALTER TABLE "public"."Interview" ALTER COLUMN "evaluation_plan_id" DROP NOT NULL;
9
-
10
- -- Drop old composite unique (replaced by partial index below)
11
- DROP INDEX IF EXISTS "public"."Interview_interviewer_id_candidate_id_evaluation_plan_id_key";
12
-
13
- -- Backfill ProfileInterviewSession -> Interview (preserve ids for URLs)
14
- INSERT INTO "public"."Interview" (
15
- "id",
16
- "organisation_id",
17
- "candidate_id",
18
- "interviewer_id",
19
- "evaluation_plan_id",
20
- "application_id",
21
- "resume_id",
22
- "job_description_id",
23
- "candidate_initiated",
24
- "candidate_interview_metadata",
25
- "room_name",
26
- "duration",
27
- "actual_start_time",
28
- "actual_end_time",
29
- "evaluation_type",
30
- "interview_status",
31
- "interview_platform",
32
- "ai_feedback",
33
- "ai_feedback_generated_at",
34
- "created_at",
35
- "updated_at",
36
- "created_by",
37
- "updated_by",
38
- "is_active",
39
- "interview_summary",
40
- "section_feedback",
41
- "beta_section_feedback",
42
- "reschedule_count",
43
- "awaiting_recruiter_action"
44
- )
45
- SELECT
46
- pis."id",
47
- pis."organisation_id",
48
- pis."candidate_id",
49
- NULL,
50
- NULL,
51
- NULL,
52
- pis."resume_id",
53
- pis."job_description_id",
54
- true,
55
- jsonb_build_object(
56
- 'purpose', pis."purpose",
57
- 'focusAreas', pis."focus_areas"
58
- ),
59
- pis."room_name",
60
- pis."duration_minutes",
61
- pis."actual_start_time",
62
- pis."actual_end_time",
63
- 'TREADSPACE_FULL_AI'::"public"."EvaluationType",
64
- CASE pis."status"
65
- WHEN 'SCHEDULED' THEN 'SCHEDULED'::"public"."InterviewStatus"
66
- WHEN 'IN_PROGRESS' THEN 'IN_PROGRESS'::"public"."InterviewStatus"
67
- WHEN 'CANCELLED' THEN 'CANCELLED'::"public"."InterviewStatus"
68
- WHEN 'COMPLETED' THEN
69
- CASE
70
- WHEN pis."evidence_result" IS NOT NULL THEN 'EVALUATED'::"public"."InterviewStatus"
71
- ELSE 'EVALUATION_PENDING'::"public"."InterviewStatus"
72
- END
73
- ELSE 'SCHEDULED'::"public"."InterviewStatus"
74
- END,
75
- 'TREADSPACE'::"public"."InterviewPlatform",
76
- pis."evidence_result",
77
- CASE WHEN pis."evidence_result" IS NOT NULL THEN pis."updated_at" ELSE NULL END,
78
- pis."created_at",
79
- pis."updated_at",
80
- pis."created_by",
81
- pis."updated_by",
82
- pis."is_active",
83
- ARRAY[]::TEXT[],
84
- ARRAY[]::JSONB[],
85
- ARRAY[]::JSONB[],
86
- 0,
87
- false
88
- FROM "public"."ProfileInterviewSession" pis
89
- ON CONFLICT ("id") DO NOTHING;
90
-
91
- -- Point transcripts at Interview rows
92
- UPDATE "public"."Transcript" t
93
- SET "interview_id" = t."profile_interview_session_id"
94
- WHERE t."profile_interview_session_id" IS NOT NULL
95
- AND t."interview_id" IS NULL;
96
-
97
- -- Transcript: drop profile session FK
98
- ALTER TABLE "public"."Transcript" DROP CONSTRAINT IF EXISTS "Transcript_profile_interview_session_id_fkey";
99
- DROP INDEX IF EXISTS "public"."Transcript_profile_interview_session_id_order_no_key";
100
- DROP INDEX IF EXISTS "public"."Transcript_profile_interview_session_id_idx";
101
- ALTER TABLE "public"."Transcript" DROP COLUMN IF EXISTS "profile_interview_session_id";
102
-
103
- -- Drop profile session table
104
- DROP TABLE IF EXISTS "public"."ProfileInterviewSession";
105
- DROP TYPE IF EXISTS "public"."ProfileInterviewSessionStatus";
106
-
107
- -- Interview FK: organisation / job_description ON DELETE SET NULL
108
- ALTER TABLE "public"."Interview" DROP CONSTRAINT IF EXISTS "Interview_organisation_id_fkey";
109
- ALTER TABLE "public"."Interview" ADD CONSTRAINT "Interview_organisation_id_fkey"
110
- FOREIGN KEY ("organisation_id") REFERENCES "public"."Organisation"("id")
111
- ON DELETE SET NULL ON UPDATE CASCADE;
112
-
113
- ALTER TABLE "public"."Interview" DROP CONSTRAINT IF EXISTS "Interview_job_description_id_fkey";
114
- ALTER TABLE "public"."Interview" ADD CONSTRAINT "Interview_job_description_id_fkey"
115
- FOREIGN KEY ("job_description_id") REFERENCES "public"."JobDescription"("id")
116
- ON DELETE SET NULL ON UPDATE CASCADE;
117
-
118
- -- Hiring row invariants
119
- ALTER TABLE "public"."Interview" ADD CONSTRAINT "interview_hiring_required_fks"
120
- CHECK (
121
- "candidate_initiated" = true
122
- OR (
123
- "organisation_id" IS NOT NULL
124
- AND "job_description_id" IS NOT NULL
125
- AND "evaluation_plan_id" IS NOT NULL
126
- )
127
- );
128
-
129
- -- Partial unique for hiring triple only
130
- CREATE UNIQUE INDEX "interview_hiring_triple_uidx"
131
- ON "public"."Interview" ("interviewer_id", "candidate_id", "evaluation_plan_id")
132
- WHERE "candidate_initiated" = false AND "evaluation_plan_id" IS NOT NULL;
133
-
134
- -- List indexes
135
- CREATE INDEX IF NOT EXISTS "Interview_candidate_id_candidate_initiated_created_at_idx"
136
- ON "public"."Interview" ("candidate_id", "candidate_initiated", "created_at");
137
-
138
- CREATE INDEX IF NOT EXISTS "Interview_candidate_initiated_interview_status_idx"
139
- ON "public"."Interview" ("candidate_initiated", "interview_status");
@@ -1,2 +0,0 @@
1
- -- In-person interviews: staff schedules on-site; feedback without a platform session.
2
- ALTER TYPE "public"."EvaluationType" ADD VALUE IF NOT EXISTS 'IN_PERSON';
@@ -1,83 +0,0 @@
1
- // PAYMENT SERVICE boundary — portable payment microservice owns these enums/columns.
2
-
3
- enum BillingTransactionStatus {
4
- INITIATED
5
- ORDER_CREATED
6
- PAYMENT_PENDING
7
- SUCCESS
8
- FAILED
9
- CANCELLED
10
- REFUND_PENDING
11
- REFUND_FAILED
12
- REFUNDED
13
-
14
- @@schema("public")
15
- }
16
-
17
- enum BillingTransactionType {
18
- PURCHASE
19
- TOP_UP
20
- REFUND
21
-
22
- @@schema("public")
23
- }
24
-
25
- enum BillingTransactionFailureCategory {
26
- RAZORPAY_ORDER
27
- RAZORPAY_PAYMENT
28
- REFUND
29
- INTERNAL
30
-
31
- @@schema("public")
32
- }
33
-
34
- /// Payment reconciliation state when Treadspace status is FAILED but Razorpay captured payment.
35
- enum BillingPaymentMismatchStatus {
36
- DETECTED
37
- UNFULFILLED
38
-
39
- @@schema("public")
40
- }
41
-
42
- /// Financial transaction lifecycle for organisation billing purchases.
43
- model BillingTransaction {
44
- id String @id @default(uuid())
45
- organisation_id String
46
- /// Opaque plan/product identity supplied at checkout. Not a catalog FK.
47
- purchase_reference String
48
- /// Human-readable snapshot captured at checkout for invoices and receipts.
49
- purchase_display_name String?
50
- transaction_type BillingTransactionType
51
- status BillingTransactionStatus @default(INITIATED)
52
- failure_category BillingTransactionFailureCategory?
53
- /// Human-readable or provider detail (e.g. Razorpay error_description).
54
- failure_reason String?
55
- amount Int
56
- currency String @default("INR")
57
- razorpay_order_id String?
58
- razorpay_payment_id String? @unique
59
- /// Razorpay payment method at capture (card, netbanking, upi, wallet, etc.).
60
- payment_method String?
61
- razorpay_subscription_id String?
62
- razorpay_refund_id String?
63
- refund_reason String?
64
- refund_amount Int?
65
- idempotency_key String @unique
66
- invoice_number String? @unique
67
- /// Email of the org Admin who initiated checkout (bill-to).
68
- purchaser_email String?
69
- /// Set when FAILED but Razorpay order/payment is captured (reconciliation path).
70
- payment_mismatch_status BillingPaymentMismatchStatus?
71
- /// Strict same-intent SUCCESS transaction that fulfilled the purchase (UNFULFILLED only).
72
- payment_mismatch_fulfilled_by_id String?
73
- created_at DateTime @default(now())
74
- updated_at DateTime @updatedAt
75
-
76
- organisation Organisation @relation(fields: [organisation_id], references: [id])
77
-
78
- @@index([organisation_id, status])
79
- @@index([purchase_reference])
80
- @@index([razorpay_order_id])
81
- @@map("billing_transactions")
82
- @@schema("public")
83
- }