@adaptware/eagles-db 0.4.41 → 0.4.42

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 (26) hide show
  1. package/client/edge.js +8 -7
  2. package/client/index-browser.js +2 -0
  3. package/client/index.d.ts +150 -2
  4. package/client/index.js +8 -7
  5. package/client/package.json +1 -1
  6. package/client/schema.prisma +2 -0
  7. package/client/wasm.js +8 -7
  8. package/package.json +1 -1
  9. package/prisma/.DS_Store +0 -0
  10. package/prisma/schema/evaluationPlan.prisma +1 -0
  11. package/prisma/schema/migrations/20260519120000_interview_deadline/migration.sql +2 -0
  12. package/prisma/schema/migrations/20260520120000_interview_duration_drop_deadline/migration.sql +30 -0
  13. package/prisma/schema/migrations/20260602120000_resume_file_hash_drop_unique/migration.sql +2 -0
  14. package/prisma/schema/migrations/20260603120000_job_application_field_is_mandatory/migration.sql +2 -0
  15. package/prisma/schema/migrations/20260604120000_job_application_response_updated_by_organisation/migration.sql +2 -0
  16. package/prisma/schema/migrations/20260605120000_drop_document_application_id/migration.sql +3 -0
  17. package/prisma/schema/migrations/20260610120000_jaf_template_model/migration.sql +70 -0
  18. package/prisma/schema/migrations/20260610130000_assignment_document_fks/migration.sql +15 -0
  19. package/prisma/schema/migrations/20260610140000_jaf_draft_activation/migration.sql +12 -0
  20. package/prisma/schema/migrations/20260713120000_add_focus_areas_backfill/migration.sql +16 -0
  21. package/prisma/schema/ongoingEvaluation.prisma +1 -0
  22. package/prisma/schema/migrations/20260522120000_ongoing_evaluation_record_kind/migration.sql +0 -25
  23. package/prisma/schema/migrations/20260523120000_replace_record_kind_with_is_committed/migration.sql +0 -24
  24. package/prisma/schema/migrations/20260528120000_drop_job_description_recommendation_config/migration.sql +0 -2
  25. package/prisma/schema/migrations/20260710120000_add_resume_rendered_export_fields/migration.sql +0 -9
  26. package/prisma/schema/migrations/20260714120000_add_job_description_display_html_document/migration.sql +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptware/eagles-db",
3
- "version": "0.4.41",
3
+ "version": "0.4.42",
4
4
  "description": "A Prisma client package for Treadspace database operations",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
Binary file
@@ -90,6 +90,7 @@ model EvaluationPlan {
90
90
  title String
91
91
  description String?
92
92
  format EvaluationRoundFormat?
93
+ focus_areas String[]
93
94
  topics String[]
94
95
  assignee String?
95
96
  elimination_round Boolean @default(false)
@@ -0,0 +1,2 @@
1
+ -- Full AI interview completion window (calendar days); nullable for non–Full AI rows.
2
+ ALTER TABLE "Interview" ADD COLUMN IF NOT EXISTS "deadline" INTEGER;
@@ -0,0 +1,30 @@
1
+ -- Interview.duration (minutes) replaces timestamp-derived length; Interview.deadline removed (window = scheduled_end_time).
2
+ ALTER TABLE "Interview" ADD COLUMN IF NOT EXISTS "duration" INTEGER;
3
+
4
+ ALTER TABLE "Interview" DROP COLUMN IF EXISTS "deadline";
5
+
6
+ -- Best-effort inline backfill (Full AI rows may be wrong until backfill-interview-duration.ts runs).
7
+ UPDATE "Interview" i
8
+ SET "duration" = GREATEST(
9
+ 1,
10
+ ROUND(
11
+ EXTRACT(EPOCH FROM (i."scheduled_end_time" - i."scheduled_start_time")) / 60
12
+ )::integer
13
+ )
14
+ WHERE i."duration" IS NULL
15
+ AND i."scheduled_start_time" IS NOT NULL
16
+ AND i."scheduled_end_time" IS NOT NULL
17
+ AND i."scheduled_end_time" > i."scheduled_start_time"
18
+ AND (i."evaluation_type" IS NULL OR i."evaluation_type"::text <> 'TREADSPACE_FULL_AI');
19
+
20
+ UPDATE "Interview" i
21
+ SET "duration" = oe."duration"
22
+ FROM "OngoingEvaluation" oe
23
+ WHERE oe."interview_id" = i."id"
24
+ AND i."duration" IS NULL
25
+ AND oe."duration" IS NOT NULL
26
+ AND oe."duration_unit" = 'MINUTES';
27
+
28
+ UPDATE "Interview"
29
+ SET "duration" = 45
30
+ WHERE "duration" IS NULL;
@@ -0,0 +1,2 @@
1
+ -- Drop unique constraint on Resume.file_hash (dedup moves to Document.file_hash).
2
+ DROP INDEX IF EXISTS "Resume_file_hash_key";
@@ -0,0 +1,2 @@
1
+ -- Add is_mandatory flag to job application form fields.
2
+ ALTER TABLE "JobApplicationField" ADD COLUMN IF NOT EXISTS "is_mandatory" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,2 @@
1
+ -- Track whether the latest response change was made by the organisation (vs candidate).
2
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "updated_by_organisation" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,3 @@
1
+ -- Drop Document.application_id FK and column (linking stays on JobApplicationResponse.document_id).
2
+ ALTER TABLE "Document" DROP CONSTRAINT IF EXISTS "Document_application_id_fkey";
3
+ ALTER TABLE "Document" DROP COLUMN IF EXISTS "application_id";
@@ -0,0 +1,70 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "JobApplicationTemplateScope" AS ENUM ('ORGANIZATION', 'JOB');
3
+
4
+ -- CreateTable
5
+ CREATE TABLE "JobApplicationTemplate" (
6
+ "id" TEXT NOT NULL,
7
+ "organisation_id" TEXT NOT NULL,
8
+ "job_description_id" TEXT,
9
+ "name" TEXT NOT NULL,
10
+ "description" TEXT,
11
+ "scope" "JobApplicationTemplateScope" NOT NULL DEFAULT 'ORGANIZATION',
12
+ "is_active" BOOLEAN NOT NULL DEFAULT true,
13
+ "created_by" TEXT NOT NULL,
14
+ "updated_by" TEXT NOT NULL,
15
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
16
+ "updated_at" TIMESTAMP(3) NOT NULL,
17
+
18
+ CONSTRAINT "JobApplicationTemplate_pkey" PRIMARY KEY ("id")
19
+ );
20
+
21
+ -- Drop legacy scope model on JobApplicationField (greenfield — no data backfill)
22
+ ALTER TABLE "JobApplicationField" DROP CONSTRAINT IF EXISTS "JobApplicationField_job_description_id_fkey";
23
+ ALTER TABLE "JobApplicationField" DROP CONSTRAINT IF EXISTS "JobApplicationField_application_id_fkey";
24
+ DROP INDEX IF EXISTS "JobApplicationField_organisation_id_scope_idx";
25
+ DROP INDEX IF EXISTS "JobApplicationField_job_description_id_idx";
26
+ DROP INDEX IF EXISTS "JobApplicationField_application_id_idx";
27
+
28
+ ALTER TABLE "JobApplicationField" DROP COLUMN IF EXISTS "scope";
29
+ ALTER TABLE "JobApplicationField" DROP COLUMN IF EXISTS "job_description_id";
30
+ ALTER TABLE "JobApplicationField" DROP COLUMN IF EXISTS "application_id";
31
+
32
+ DROP TYPE IF EXISTS "JobApplicationFieldScope";
33
+
34
+ ALTER TABLE "JobApplicationField" ADD COLUMN IF NOT EXISTS "template_id" TEXT;
35
+
36
+ -- JobApplicationResponse snapshot columns
37
+ ALTER TABLE "JobApplicationResponse" DROP CONSTRAINT IF EXISTS "JobApplicationResponse_job_application_field_id_fkey";
38
+ DROP INDEX IF EXISTS "JobApplicationResponse_application_id_job_application_field_id_key";
39
+
40
+ ALTER TABLE "JobApplicationResponse" ALTER COLUMN "job_application_field_id" DROP NOT NULL;
41
+
42
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "field_type" "JobApplicationFieldType";
43
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "label" TEXT;
44
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "description" TEXT;
45
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "is_mandatory" BOOLEAN;
46
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "options" TEXT[] DEFAULT ARRAY[]::TEXT[];
47
+
48
+ -- Document: remove application link
49
+ ALTER TABLE "Document" DROP CONSTRAINT IF EXISTS "Document_application_id_fkey";
50
+ DROP INDEX IF EXISTS "Document_application_id_idx";
51
+ ALTER TABLE "Document" DROP COLUMN IF EXISTS "application_id";
52
+
53
+ -- Greenfield: no legacy JAF rows — clear any orphan fields before NOT NULL
54
+ DELETE FROM "JobApplicationField";
55
+ ALTER TABLE "JobApplicationField" ALTER COLUMN "template_id" SET NOT NULL;
56
+
57
+ -- Indexes and foreign keys
58
+ CREATE UNIQUE INDEX IF NOT EXISTS "JobApplicationTemplate_job_description_id_key" ON "JobApplicationTemplate"("job_description_id");
59
+ CREATE INDEX IF NOT EXISTS "JobApplicationTemplate_organisation_id_scope_idx" ON "JobApplicationTemplate"("organisation_id", "scope");
60
+ CREATE INDEX IF NOT EXISTS "JobApplicationTemplate_job_description_id_idx" ON "JobApplicationTemplate"("job_description_id");
61
+
62
+ ALTER TABLE "JobApplicationTemplate" ADD CONSTRAINT "JobApplicationTemplate_organisation_id_fkey" FOREIGN KEY ("organisation_id") REFERENCES "Organisation"("id") ON DELETE CASCADE ON UPDATE CASCADE;
63
+ ALTER TABLE "JobApplicationTemplate" ADD CONSTRAINT "JobApplicationTemplate_job_description_id_fkey" FOREIGN KEY ("job_description_id") REFERENCES "JobDescription"("id") ON DELETE CASCADE ON UPDATE CASCADE;
64
+
65
+ ALTER TABLE "JobApplicationField" ADD CONSTRAINT "JobApplicationField_template_id_fkey" FOREIGN KEY ("template_id") REFERENCES "JobApplicationTemplate"("id") ON DELETE CASCADE ON UPDATE CASCADE;
66
+ CREATE INDEX IF NOT EXISTS "JobApplicationField_organisation_id_template_id_idx" ON "JobApplicationField"("organisation_id", "template_id");
67
+
68
+ ALTER TABLE "JobApplicationResponse" ADD CONSTRAINT "JobApplicationResponse_job_application_field_id_fkey" FOREIGN KEY ("job_application_field_id") REFERENCES "JobApplicationField"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
69
+
70
+ CREATE UNIQUE INDEX "JobApplicationResponse_application_id_job_application_field_id_key" ON "JobApplicationResponse"("application_id", "job_application_field_id") WHERE "job_application_field_id" IS NOT NULL;
@@ -0,0 +1,15 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Assignment" ADD COLUMN "solution_document_id" TEXT,
3
+ ADD COLUMN "zip_document_id" TEXT;
4
+
5
+ -- CreateIndex
6
+ CREATE UNIQUE INDEX "Assignment_solution_document_id_key" ON "Assignment"("solution_document_id");
7
+
8
+ -- CreateIndex
9
+ CREATE UNIQUE INDEX "Assignment_zip_document_id_key" ON "Assignment"("zip_document_id");
10
+
11
+ -- AddForeignKey
12
+ ALTER TABLE "Assignment" ADD CONSTRAINT "Assignment_solution_document_id_fkey" FOREIGN KEY ("solution_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
13
+
14
+ -- AddForeignKey
15
+ ALTER TABLE "Assignment" ADD CONSTRAINT "Assignment_zip_document_id_fkey" FOREIGN KEY ("zip_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,12 @@
1
+ -- JobApplicationField: draft gate for template/job fields
2
+ ALTER TABLE "JobApplicationField" ADD COLUMN IF NOT EXISTS "is_draft" BOOLEAN DEFAULT true;
3
+ UPDATE "JobApplicationField" SET "is_draft" = false WHERE "is_draft" IS NULL;
4
+ ALTER TABLE "JobApplicationField" ALTER COLUMN "is_draft" SET NOT NULL;
5
+ ALTER TABLE "JobApplicationField" ALTER COLUMN "is_draft" SET DEFAULT true;
6
+
7
+ -- JobApplicationResponse: per-row draft/submit state
8
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "is_draft" BOOLEAN;
9
+ ALTER TABLE "JobApplicationResponse" ADD COLUMN IF NOT EXISTS "is_submitted" BOOLEAN DEFAULT false;
10
+ UPDATE "JobApplicationResponse" SET "is_draft" = false WHERE "is_draft" IS NULL;
11
+ UPDATE "JobApplicationResponse" SET "is_submitted" = false WHERE "is_submitted" IS NULL;
12
+ ALTER TABLE "JobApplicationResponse" ALTER COLUMN "is_draft" SET DEFAULT false;
@@ -0,0 +1,16 @@
1
+ -- Add focus_areas to evaluation plan rounds; backfill from legacy topics.
2
+ ALTER TABLE "EvaluationPlan"
3
+ ADD COLUMN IF NOT EXISTS "focus_areas" TEXT[] NOT NULL DEFAULT '{}';
4
+
5
+ ALTER TABLE "OngoingEvaluation"
6
+ ADD COLUMN IF NOT EXISTS "focus_areas" TEXT[] NOT NULL DEFAULT '{}';
7
+
8
+ UPDATE "EvaluationPlan"
9
+ SET "focus_areas" = "topics"
10
+ WHERE cardinality("focus_areas") = 0
11
+ AND cardinality("topics") > 0;
12
+
13
+ UPDATE "OngoingEvaluation"
14
+ SET "focus_areas" = "topics"
15
+ WHERE cardinality("focus_areas") = 0
16
+ AND cardinality("topics") > 0;
@@ -44,6 +44,7 @@ model OngoingEvaluation {
44
44
  order_no Int?
45
45
  format EvaluationRoundFormat?
46
46
  round_purpose String?
47
+ focus_areas String[]
47
48
  topics String[]
48
49
  assignee String?
49
50
  elimination_round Boolean? @default(false)
@@ -1,25 +0,0 @@
1
- -- Safe to re-run: adds record_kind without breaking existing ongoing evaluations.
2
-
3
- DO $$ BEGIN
4
- CREATE TYPE "OngoingEvaluationRecordKind" AS ENUM (
5
- 'AI_RECOMMENDED',
6
- 'PLAN_SELECTED',
7
- 'COMMITTED'
8
- );
9
- EXCEPTION
10
- WHEN duplicate_object THEN NULL;
11
- END $$;
12
-
13
- ALTER TABLE "OngoingEvaluation"
14
- ADD COLUMN IF NOT EXISTS "record_kind" "OngoingEvaluationRecordKind";
15
-
16
- ALTER TABLE "OngoingEvaluation"
17
- ALTER COLUMN "evaluation_plan_id" DROP NOT NULL;
18
-
19
- -- All existing rows are real pipeline rounds — not pre-Proceed drafts.
20
- UPDATE "OngoingEvaluation"
21
- SET "record_kind" = 'COMMITTED'
22
- WHERE "record_kind" IS NULL;
23
-
24
- CREATE INDEX IF NOT EXISTS "OngoingEvaluation_application_id_record_kind_idx"
25
- ON "OngoingEvaluation"("application_id", "record_kind");
@@ -1,24 +0,0 @@
1
- -- Replace record_kind enum with is_committed (null = legacy, false = draft, true = committed).
2
-
3
- ALTER TABLE "OngoingEvaluation"
4
- ADD COLUMN IF NOT EXISTS "is_committed" BOOLEAN;
5
-
6
- UPDATE "OngoingEvaluation"
7
- SET "is_committed" = false
8
- WHERE "record_kind" IN ('AI_RECOMMENDED', 'PLAN_SELECTED');
9
-
10
- UPDATE "OngoingEvaluation"
11
- SET "is_committed" = true
12
- WHERE "record_kind" = 'COMMITTED';
13
-
14
- -- Legacy rows without record_kind stay null (treated as committed in app queries).
15
-
16
- DROP INDEX IF EXISTS "OngoingEvaluation_application_id_record_kind_idx";
17
-
18
- ALTER TABLE "OngoingEvaluation"
19
- DROP COLUMN IF EXISTS "record_kind";
20
-
21
- DROP TYPE IF EXISTS "OngoingEvaluationRecordKind";
22
-
23
- CREATE INDEX IF NOT EXISTS "OngoingEvaluation_application_id_is_committed_idx"
24
- ON "OngoingEvaluation"("application_id", "is_committed");
@@ -1,2 +0,0 @@
1
- -- Drop unused per-job AI recommendation threshold storage (defaults live in application code).
2
- ALTER TABLE "JobDescription" DROP COLUMN IF EXISTS "recommendation_config";
@@ -1,9 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "Resume" ADD COLUMN "rendered_export_document_id" TEXT,
3
- ADD COLUMN "resume_template_id" TEXT;
4
-
5
- -- CreateIndex
6
- CREATE UNIQUE INDEX "Resume_rendered_export_document_id_key" ON "Resume"("rendered_export_document_id");
7
-
8
- -- AddForeignKey
9
- ALTER TABLE "Resume" ADD CONSTRAINT "Resume_rendered_export_document_id_fkey" FOREIGN KEY ("rendered_export_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -1,8 +0,0 @@
1
- -- AlterTable
2
- ALTER TABLE "JobDescription" ADD COLUMN "display_html_document_id" TEXT;
3
-
4
- -- CreateIndex
5
- CREATE UNIQUE INDEX "JobDescription_display_html_document_id_key" ON "JobDescription"("display_html_document_id");
6
-
7
- -- AddForeignKey
8
- ALTER TABLE "JobDescription" ADD CONSTRAINT "JobDescription_display_html_document_id_fkey" FOREIGN KEY ("display_html_document_id") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE;