diff --git a/drizzle/0001_curved_fabian_cortez.sql b/drizzle/0001_curved_fabian_cortez.sql new file mode 100644 index 0000000..262dea4 --- /dev/null +++ b/drizzle/0001_curved_fabian_cortez.sql @@ -0,0 +1,148 @@ +CREATE TYPE "public"."clause_rating" AS ENUM('standard', 'abweichend', 'kritisch', 'unbekannt');--> statement-breakpoint +CREATE TYPE "public"."contract_doc_status" AS ENUM('uploaded', 'extracting', 'extracted', 'analyzing', 'completed', 'failed');--> statement-breakpoint +CREATE TYPE "public"."deadline_type" AS ENUM('frist', 'termin', 'vorfrist');--> statement-breakpoint +CREATE TYPE "public"."proceeding_status" AS ENUM('vorbereitung', 'eingereicht', 'laufend', 'verhandlung', 'entschieden', 'abgeschlossen', 'ruht');--> statement-breakpoint +CREATE TYPE "public"."proceeding_step_status" AS ENUM('ausstehend', 'aktiv', 'abgeschlossen', 'uebersprungen');--> statement-breakpoint +CREATE TYPE "public"."proceeding_type" AS ENUM('bschgo_bezirk', 'bschgo_bund', 'arbgg_erste_instanz', 'arbgg_berufung', 'arbgg_revision');--> statement-breakpoint +CREATE TABLE "contract_clauses" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "document_id" uuid NOT NULL, + "category" varchar(200) NOT NULL, + "extracted_text" text NOT NULL, + "position_start" integer, + "position_end" integer, + "standard_clause_id" uuid, + "rating" "clause_rating" DEFAULT 'unbekannt' NOT NULL, + "analysis" text, + "deviations" jsonb, + "risk_score" integer, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "contract_documents" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" uuid NOT NULL, + "case_id" uuid, + "user_id" uuid NOT NULL, + "filename" varchar(500) NOT NULL, + "mime_type" varchar(100) NOT NULL, + "file_size_bytes" integer NOT NULL, + "storage_path" text NOT NULL, + "extracted_text" text, + "status" "contract_doc_status" DEFAULT 'uploaded' NOT NULL, + "error_message" text, + "fachgruppe_id" uuid, + "metadata" jsonb, + "delete_after" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "proceeding_deadlines" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "proceeding_id" uuid NOT NULL, + "step_id" uuid, + "type" "deadline_type" DEFAULT 'frist' NOT NULL, + "label" varchar(255) NOT NULL, + "description" text, + "due_date" date NOT NULL, + "due_time" varchar(10), + "warning_date" date, + "warning_days_before" integer, + "is_completed" boolean DEFAULT false, + "completed_at" timestamp with time zone, + "is_calculated" boolean DEFAULT false, + "calculation_basis" text, + "legal_basis" varchar(255), + "notes" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "proceeding_steps" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "proceeding_id" uuid NOT NULL, + "step_key" varchar(100) NOT NULL, + "label" varchar(255) NOT NULL, + "description" text, + "sort_order" integer DEFAULT 0 NOT NULL, + "status" "proceeding_step_status" DEFAULT 'ausstehend' NOT NULL, + "legal_basis" varchar(255), + "responsible_party" varchar(255), + "completed_at" timestamp with time zone, + "notes" text, + "metadata" jsonb, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "proceedings" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "tenant_id" uuid NOT NULL, + "case_id" uuid, + "type" "proceeding_type" NOT NULL, + "status" "proceeding_status" DEFAULT 'vorbereitung' NOT NULL, + "filing_date" date, + "internal_ref" varchar(100), + "external_ref" varchar(100), + "tribunal_id" uuid, + "court_name" varchar(255), + "chamber" varchar(100), + "presiding_judge" varchar(255), + "applicant" varchar(255), + "respondent" varchar(255), + "subject" text, + "amount_in_dispute_cents" integer, + "fachgruppe_id" uuid, + "current_step_key" varchar(100), + "notes" text, + "metadata" jsonb, + "closed_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "standard_clauses" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "instrument_id" uuid NOT NULL, + "category" varchar(200) NOT NULL, + "label" varchar(500) NOT NULL, + "body" text NOT NULL, + "fachgruppe_ids" jsonb, + "norm_id" uuid, + "sort_order" integer DEFAULT 0, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "contract_clauses" ADD CONSTRAINT "contract_clauses_document_id_contract_documents_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."contract_documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contract_clauses" ADD CONSTRAINT "contract_clauses_standard_clause_id_standard_clauses_id_fk" FOREIGN KEY ("standard_clause_id") REFERENCES "public"."standard_clauses"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contract_documents" ADD CONSTRAINT "contract_documents_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contract_documents" ADD CONSTRAINT "contract_documents_case_id_cases_id_fk" FOREIGN KEY ("case_id") REFERENCES "public"."cases"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contract_documents" ADD CONSTRAINT "contract_documents_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "contract_documents" ADD CONSTRAINT "contract_documents_fachgruppe_id_nv_buehne_fachgruppen_id_fk" FOREIGN KEY ("fachgruppe_id") REFERENCES "public"."nv_buehne_fachgruppen"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceeding_deadlines" ADD CONSTRAINT "proceeding_deadlines_proceeding_id_proceedings_id_fk" FOREIGN KEY ("proceeding_id") REFERENCES "public"."proceedings"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceeding_deadlines" ADD CONSTRAINT "proceeding_deadlines_step_id_proceeding_steps_id_fk" FOREIGN KEY ("step_id") REFERENCES "public"."proceeding_steps"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceeding_steps" ADD CONSTRAINT "proceeding_steps_proceeding_id_proceedings_id_fk" FOREIGN KEY ("proceeding_id") REFERENCES "public"."proceedings"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceedings" ADD CONSTRAINT "proceedings_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceedings" ADD CONSTRAINT "proceedings_case_id_cases_id_fk" FOREIGN KEY ("case_id") REFERENCES "public"."cases"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceedings" ADD CONSTRAINT "proceedings_tribunal_id_arbitration_tribunals_id_fk" FOREIGN KEY ("tribunal_id") REFERENCES "public"."arbitration_tribunals"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "proceedings" ADD CONSTRAINT "proceedings_fachgruppe_id_nv_buehne_fachgruppen_id_fk" FOREIGN KEY ("fachgruppe_id") REFERENCES "public"."nv_buehne_fachgruppen"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "standard_clauses" ADD CONSTRAINT "standard_clauses_instrument_id_norm_instruments_id_fk" FOREIGN KEY ("instrument_id") REFERENCES "public"."norm_instruments"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "standard_clauses" ADD CONSTRAINT "standard_clauses_norm_id_norms_id_fk" FOREIGN KEY ("norm_id") REFERENCES "public"."norms"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "contract_clauses_doc_idx" ON "contract_clauses" USING btree ("document_id");--> statement-breakpoint +CREATE INDEX "contract_clauses_category_idx" ON "contract_clauses" USING btree ("category");--> statement-breakpoint +CREATE INDEX "contract_clauses_rating_idx" ON "contract_clauses" USING btree ("rating");--> statement-breakpoint +CREATE INDEX "contract_docs_tenant_idx" ON "contract_documents" USING btree ("tenant_id");--> statement-breakpoint +CREATE INDEX "contract_docs_case_idx" ON "contract_documents" USING btree ("case_id");--> statement-breakpoint +CREATE INDEX "contract_docs_status_idx" ON "contract_documents" USING btree ("status");--> statement-breakpoint +CREATE INDEX "contract_docs_delete_after_idx" ON "contract_documents" USING btree ("delete_after");--> statement-breakpoint +CREATE INDEX "proceeding_deadlines_proceeding_idx" ON "proceeding_deadlines" USING btree ("proceeding_id");--> statement-breakpoint +CREATE INDEX "proceeding_deadlines_step_idx" ON "proceeding_deadlines" USING btree ("step_id");--> statement-breakpoint +CREATE INDEX "proceeding_deadlines_due_date_idx" ON "proceeding_deadlines" USING btree ("due_date");--> statement-breakpoint +CREATE INDEX "proceeding_deadlines_warning_idx" ON "proceeding_deadlines" USING btree ("warning_date");--> statement-breakpoint +CREATE INDEX "proceeding_steps_proceeding_idx" ON "proceeding_steps" USING btree ("proceeding_id");--> statement-breakpoint +CREATE UNIQUE INDEX "proceeding_steps_key_idx" ON "proceeding_steps" USING btree ("proceeding_id","step_key");--> statement-breakpoint +CREATE INDEX "proceedings_tenant_idx" ON "proceedings" USING btree ("tenant_id");--> statement-breakpoint +CREATE INDEX "proceedings_case_idx" ON "proceedings" USING btree ("case_id");--> statement-breakpoint +CREATE INDEX "proceedings_type_idx" ON "proceedings" USING btree ("type");--> statement-breakpoint +CREATE INDEX "proceedings_status_idx" ON "proceedings" USING btree ("status");--> statement-breakpoint +CREATE INDEX "standard_clauses_instrument_idx" ON "standard_clauses" USING btree ("instrument_id");--> statement-breakpoint +CREATE INDEX "standard_clauses_category_idx" ON "standard_clauses" USING btree ("category"); \ No newline at end of file diff --git a/drizzle/0002_contract_analysis.sql b/drizzle/0002_contract_analysis.sql new file mode 100644 index 0000000..7d861a4 --- /dev/null +++ b/drizzle/0002_contract_analysis.sql @@ -0,0 +1,87 @@ +-- Phase 3.3: Contract Analysis Module (Vertragsanalyse) +-- Adds contract document upload, clause extraction, and standard clause comparison + +-- Enums +CREATE TYPE contract_doc_status AS ENUM ('uploaded', 'extracting', 'extracted', 'analyzing', 'completed', 'failed'); +CREATE TYPE clause_rating AS ENUM ('standard', 'abweichend', 'kritisch', 'unbekannt'); + +-- Contract documents table +CREATE TABLE contract_documents ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE, + case_id UUID REFERENCES cases(id) ON DELETE SET NULL, + user_id UUID NOT NULL REFERENCES users(id), + filename VARCHAR(500) NOT NULL, + mime_type VARCHAR(100) NOT NULL, + file_size_bytes INTEGER NOT NULL, + storage_path TEXT NOT NULL, + extracted_text TEXT, + status contract_doc_status NOT NULL DEFAULT 'uploaded', + error_message TEXT, + fachgruppe_id UUID REFERENCES nv_buehne_fachgruppen(id), + metadata JSONB, + delete_after TIMESTAMPTZ, + created_at TIMESTAMPTZ NOT NULL DEFAULT now(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +CREATE INDEX contract_docs_tenant_idx ON contract_documents(tenant_id); +CREATE INDEX contract_docs_case_idx ON contract_documents(case_id); +CREATE INDEX contract_docs_status_idx ON contract_documents(status); +CREATE INDEX contract_docs_delete_after_idx ON contract_documents(delete_after); + +-- Standard clauses (reference data from NV Bühne etc.) +CREATE TABLE standard_clauses ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + instrument_id UUID NOT NULL REFERENCES norm_instruments(id) ON DELETE CASCADE, + category VARCHAR(200) NOT NULL, + label VARCHAR(500) NOT NULL, + body TEXT NOT NULL, + fachgruppe_ids JSONB, + norm_id UUID REFERENCES norms(id), + sort_order INTEGER DEFAULT 0, + created_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +CREATE INDEX standard_clauses_instrument_idx ON standard_clauses(instrument_id); +CREATE INDEX standard_clauses_category_idx ON standard_clauses(category); + +-- Contract clauses (extracted from uploaded documents) +CREATE TABLE contract_clauses ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + document_id UUID NOT NULL REFERENCES contract_documents(id) ON DELETE CASCADE, + category VARCHAR(200) NOT NULL, + extracted_text TEXT NOT NULL, + position_start INTEGER, + position_end INTEGER, + standard_clause_id UUID REFERENCES standard_clauses(id), + rating clause_rating NOT NULL DEFAULT 'unbekannt', + analysis TEXT, + deviations JSONB, + risk_score INTEGER, + created_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +CREATE INDEX contract_clauses_doc_idx ON contract_clauses(document_id); +CREATE INDEX contract_clauses_category_idx ON contract_clauses(category); +CREATE INDEX contract_clauses_rating_idx ON contract_clauses(rating); + +-- RLS policies for contract_documents +ALTER TABLE contract_documents ENABLE ROW LEVEL SECURITY; + +CREATE POLICY contract_documents_tenant_isolation ON contract_documents + USING (tenant_id = current_setting('app.tenant_id')::uuid); + +CREATE POLICY contract_documents_tenant_insert ON contract_documents + FOR INSERT WITH CHECK (tenant_id = current_setting('app.tenant_id')::uuid); + +-- RLS policies for contract_clauses (via document join) +ALTER TABLE contract_clauses ENABLE ROW LEVEL SECURITY; + +CREATE POLICY contract_clauses_tenant_isolation ON contract_clauses + USING (document_id IN ( + SELECT id FROM contract_documents + WHERE tenant_id = current_setting('app.tenant_id')::uuid + )); + +-- Standard clauses are shared reference data (no RLS needed) diff --git a/drizzle/meta/0001_snapshot.json b/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..9898771 --- /dev/null +++ b/drizzle/meta/0001_snapshot.json @@ -0,0 +1,3070 @@ +{ + "id": "e62c26f7-4b34-4c87-9cce-db34b9789f60", + "prevId": "5d49fd29-b748-4be9-a6f3-418dca5d85f3", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.analyses": { + "name": "analyses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "case_id": { + "name": "case_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "analysis_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "analysis_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "title": { + "name": "title", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "query": { + "name": "query", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sources": { + "name": "sources", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ai_provider": { + "name": "ai_provider", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "ai_model": { + "name": "ai_model", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "token_usage": { + "name": "token_usage", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "analyses_tenant_idx": { + "name": "analyses_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analyses_case_idx": { + "name": "analyses_case_idx", + "columns": [ + { + "expression": "case_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "analyses_mode_idx": { + "name": "analyses_mode_idx", + "columns": [ + { + "expression": "mode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "analyses_tenant_id_tenants_id_fk": { + "name": "analyses_tenant_id_tenants_id_fk", + "tableFrom": "analyses", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "analyses_case_id_cases_id_fk": { + "name": "analyses_case_id_cases_id_fk", + "tableFrom": "analyses", + "tableTo": "cases", + "columnsFrom": [ + "case_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "analyses_user_id_users_id_fk": { + "name": "analyses_user_id_users_id_fk", + "tableFrom": "analyses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.arbitration_tribunals": { + "name": "arbitration_tribunals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true + }, + "seat": { + "name": "seat", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "bschgo_ref": { + "name": "bschgo_ref", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "details": { + "name": "details", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "varchar(45)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_log_tenant_idx": { + "name": "audit_log_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_entity_idx": { + "name": "audit_log_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_created_idx": { + "name": "audit_log_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_tenant_id_tenants_id_fk": { + "name": "audit_log_tenant_id_tenants_id_fk", + "tableFrom": "audit_log", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "audit_log_user_id_users_id_fk": { + "name": "audit_log_user_id_users_id_fk", + "tableFrom": "audit_log", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cases": { + "name": "cases", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "case_number": { + "name": "case_number", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_name": { + "name": "client_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "opposing_party": { + "name": "opposing_party", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "venue": { + "name": "venue", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "fachgruppe_id": { + "name": "fachgruppe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "domains": { + "name": "domains", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "status": { + "name": "status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "filing_date": { + "name": "filing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "hearing_date": { + "name": "hearing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cases_tenant_number_idx": { + "name": "cases_tenant_number_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "case_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cases_tenant_idx": { + "name": "cases_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cases_status_idx": { + "name": "cases_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cases_tenant_id_tenants_id_fk": { + "name": "cases_tenant_id_tenants_id_fk", + "tableFrom": "cases", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "cases_fachgruppe_id_nv_buehne_fachgruppen_id_fk": { + "name": "cases_fachgruppe_id_nv_buehne_fachgruppen_id_fk", + "tableFrom": "cases", + "tableTo": "nv_buehne_fachgruppen", + "columnsFrom": [ + "fachgruppe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contract_clauses": { + "name": "contract_clauses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "document_id": { + "name": "document_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "varchar(200)", + "primaryKey": false, + "notNull": true + }, + "extracted_text": { + "name": "extracted_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position_start": { + "name": "position_start", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "position_end": { + "name": "position_end", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "standard_clause_id": { + "name": "standard_clause_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "rating": { + "name": "rating", + "type": "clause_rating", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'unbekannt'" + }, + "analysis": { + "name": "analysis", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deviations": { + "name": "deviations", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "risk_score": { + "name": "risk_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "contract_clauses_doc_idx": { + "name": "contract_clauses_doc_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contract_clauses_category_idx": { + "name": "contract_clauses_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contract_clauses_rating_idx": { + "name": "contract_clauses_rating_idx", + "columns": [ + { + "expression": "rating", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "contract_clauses_document_id_contract_documents_id_fk": { + "name": "contract_clauses_document_id_contract_documents_id_fk", + "tableFrom": "contract_clauses", + "tableTo": "contract_documents", + "columnsFrom": [ + "document_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contract_clauses_standard_clause_id_standard_clauses_id_fk": { + "name": "contract_clauses_standard_clause_id_standard_clauses_id_fk", + "tableFrom": "contract_clauses", + "tableTo": "standard_clauses", + "columnsFrom": [ + "standard_clause_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.contract_documents": { + "name": "contract_documents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "case_id": { + "name": "case_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "file_size_bytes": { + "name": "file_size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "extracted_text": { + "name": "extracted_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "contract_doc_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'uploaded'" + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "fachgruppe_id": { + "name": "fachgruppe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "delete_after": { + "name": "delete_after", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "contract_docs_tenant_idx": { + "name": "contract_docs_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contract_docs_case_idx": { + "name": "contract_docs_case_idx", + "columns": [ + { + "expression": "case_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contract_docs_status_idx": { + "name": "contract_docs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "contract_docs_delete_after_idx": { + "name": "contract_docs_delete_after_idx", + "columns": [ + { + "expression": "delete_after", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "contract_documents_tenant_id_tenants_id_fk": { + "name": "contract_documents_tenant_id_tenants_id_fk", + "tableFrom": "contract_documents", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "contract_documents_case_id_cases_id_fk": { + "name": "contract_documents_case_id_cases_id_fk", + "tableFrom": "contract_documents", + "tableTo": "cases", + "columnsFrom": [ + "case_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "contract_documents_user_id_users_id_fk": { + "name": "contract_documents_user_id_users_id_fk", + "tableFrom": "contract_documents", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "contract_documents_fachgruppe_id_nv_buehne_fachgruppen_id_fk": { + "name": "contract_documents_fachgruppe_id_nv_buehne_fachgruppen_id_fk", + "tableFrom": "contract_documents", + "tableTo": "nv_buehne_fachgruppen", + "columnsFrom": [ + "fachgruppe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decision_norms": { + "name": "decision_norms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "decision_id": { + "name": "decision_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "norm_id": { + "name": "norm_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "application_type": { + "name": "application_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'angewendet'" + }, + "passage": { + "name": "passage", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "decision_norms_unique_idx": { + "name": "decision_norms_unique_idx", + "columns": [ + { + "expression": "decision_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "norm_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "decision_norms_decision_id_decisions_id_fk": { + "name": "decision_norms_decision_id_decisions_id_fk", + "tableFrom": "decision_norms", + "tableTo": "decisions", + "columnsFrom": [ + "decision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "decision_norms_norm_id_norms_id_fk": { + "name": "decision_norms_norm_id_norms_id_fk", + "tableFrom": "decision_norms", + "tableTo": "norms", + "columnsFrom": [ + "norm_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decision_references": { + "name": "decision_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source_decision_id": { + "name": "source_decision_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_decision_id": { + "name": "target_decision_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reference_type": { + "name": "reference_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "decision_refs_unique_idx": { + "name": "decision_refs_unique_idx", + "columns": [ + { + "expression": "source_decision_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_decision_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reference_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "decision_references_source_decision_id_decisions_id_fk": { + "name": "decision_references_source_decision_id_decisions_id_fk", + "tableFrom": "decision_references", + "tableTo": "decisions", + "columnsFrom": [ + "source_decision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "decision_references_target_decision_id_decisions_id_fk": { + "name": "decision_references_target_decision_id_decisions_id_fk", + "tableFrom": "decision_references", + "tableTo": "decisions", + "columnsFrom": [ + "target_decision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "decision_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "case_reference": { + "name": "case_reference", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "decision_date": { + "name": "decision_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "court": { + "name": "court", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "tribunal_id": { + "name": "tribunal_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "chamber": { + "name": "chamber", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "headnote": { + "name": "headnote", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tenor": { + "name": "tenor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "facts": { + "name": "facts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "full_text": { + "name": "full_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "domains": { + "name": "domains", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "publication_source": { + "name": "publication_source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_published": { + "name": "is_published", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "is_anonymized": { + "name": "is_anonymized", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "decisions_type_idx": { + "name": "decisions_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "decisions_date_idx": { + "name": "decisions_date_idx", + "columns": [ + { + "expression": "decision_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "decisions_court_idx": { + "name": "decisions_court_idx", + "columns": [ + { + "expression": "court", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "decisions_tenant_idx": { + "name": "decisions_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "decisions_case_ref_idx": { + "name": "decisions_case_ref_idx", + "columns": [ + { + "expression": "case_reference", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "decisions_tenant_id_tenants_id_fk": { + "name": "decisions_tenant_id_tenants_id_fk", + "tableFrom": "decisions", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "decisions_tribunal_id_arbitration_tribunals_id_fk": { + "name": "decisions_tribunal_id_arbitration_tribunals_id_fk", + "tableFrom": "decisions", + "tableTo": "arbitration_tribunals", + "columnsFrom": [ + "tribunal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.norm_instruments": { + "name": "norm_instruments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "norm_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source_rank": { + "name": "source_rank", + "type": "source_rank", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "abbreviation": { + "name": "abbreviation", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "full_title": { + "name": "full_title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enacted_at": { + "name": "enacted_at", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "issuing_body": { + "name": "issuing_body", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "citation": { + "name": "citation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "norm_instruments_type_idx": { + "name": "norm_instruments_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "norm_instruments_tenant_idx": { + "name": "norm_instruments_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "norm_instruments_tenant_id_tenants_id_fk": { + "name": "norm_instruments_tenant_id_tenants_id_fk", + "tableFrom": "norm_instruments", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.norm_references": { + "name": "norm_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "source_norm_id": { + "name": "source_norm_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_norm_id": { + "name": "target_norm_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reference_type": { + "name": "reference_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true, + "default": "'verweist_auf'" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "norm_refs_unique_idx": { + "name": "norm_refs_unique_idx", + "columns": [ + { + "expression": "source_norm_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_norm_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "reference_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "norm_references_source_norm_id_norms_id_fk": { + "name": "norm_references_source_norm_id_norms_id_fk", + "tableFrom": "norm_references", + "tableTo": "norms", + "columnsFrom": [ + "source_norm_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "norm_references_target_norm_id_norms_id_fk": { + "name": "norm_references_target_norm_id_norms_id_fk", + "tableFrom": "norm_references", + "tableTo": "norms", + "columnsFrom": [ + "target_norm_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.norms": { + "name": "norms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "instrument_id": { + "name": "instrument_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "paragraph": { + "name": "paragraph", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "subsection": { + "name": "subsection", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "varchar(500)", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "valid_from": { + "name": "valid_from", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "valid_to": { + "name": "valid_to", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "previous_version_id": { + "name": "previous_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "version_number": { + "name": "version_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "domains": { + "name": "domains", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "norms_instrument_idx": { + "name": "norms_instrument_idx", + "columns": [ + { + "expression": "instrument_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "norms_paragraph_idx": { + "name": "norms_paragraph_idx", + "columns": [ + { + "expression": "instrument_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "paragraph", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "norms_valid_from_idx": { + "name": "norms_valid_from_idx", + "columns": [ + { + "expression": "valid_from", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "norms_tenant_idx": { + "name": "norms_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "norms_tenant_id_tenants_id_fk": { + "name": "norms_tenant_id_tenants_id_fk", + "tableFrom": "norms", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "norms_instrument_id_norm_instruments_id_fk": { + "name": "norms_instrument_id_norm_instruments_id_fk", + "tableFrom": "norms", + "tableTo": "norm_instruments", + "columnsFrom": [ + "instrument_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "norms_previous_version_id_norms_id_fk": { + "name": "norms_previous_version_id_norms_id_fk", + "tableFrom": "norms", + "tableTo": "norms", + "columnsFrom": [ + "previous_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.nv_buehne_fachgruppen": { + "name": "nv_buehne_fachgruppen", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "abbreviation": { + "name": "abbreviation", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "section_ref": { + "name": "section_ref", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "special_provisions": { + "name": "special_provisions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proceeding_deadlines": { + "name": "proceeding_deadlines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proceeding_id": { + "name": "proceeding_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "deadline_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'frist'" + }, + "label": { + "name": "label", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "due_date": { + "name": "due_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "due_time": { + "name": "due_time", + "type": "varchar(10)", + "primaryKey": false, + "notNull": false + }, + "warning_date": { + "name": "warning_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "warning_days_before": { + "name": "warning_days_before", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_completed": { + "name": "is_completed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "is_calculated": { + "name": "is_calculated", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "calculation_basis": { + "name": "calculation_basis", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "legal_basis": { + "name": "legal_basis", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proceeding_deadlines_proceeding_idx": { + "name": "proceeding_deadlines_proceeding_idx", + "columns": [ + { + "expression": "proceeding_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceeding_deadlines_step_idx": { + "name": "proceeding_deadlines_step_idx", + "columns": [ + { + "expression": "step_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceeding_deadlines_due_date_idx": { + "name": "proceeding_deadlines_due_date_idx", + "columns": [ + { + "expression": "due_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceeding_deadlines_warning_idx": { + "name": "proceeding_deadlines_warning_idx", + "columns": [ + { + "expression": "warning_date", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proceeding_deadlines_proceeding_id_proceedings_id_fk": { + "name": "proceeding_deadlines_proceeding_id_proceedings_id_fk", + "tableFrom": "proceeding_deadlines", + "tableTo": "proceedings", + "columnsFrom": [ + "proceeding_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proceeding_deadlines_step_id_proceeding_steps_id_fk": { + "name": "proceeding_deadlines_step_id_proceeding_steps_id_fk", + "tableFrom": "proceeding_deadlines", + "tableTo": "proceeding_steps", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proceeding_steps": { + "name": "proceeding_steps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proceeding_id": { + "name": "proceeding_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "step_key": { + "name": "step_key", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "proceeding_step_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'ausstehend'" + }, + "legal_basis": { + "name": "legal_basis", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "responsible_party": { + "name": "responsible_party", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proceeding_steps_proceeding_idx": { + "name": "proceeding_steps_proceeding_idx", + "columns": [ + { + "expression": "proceeding_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceeding_steps_key_idx": { + "name": "proceeding_steps_key_idx", + "columns": [ + { + "expression": "proceeding_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "step_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proceeding_steps_proceeding_id_proceedings_id_fk": { + "name": "proceeding_steps_proceeding_id_proceedings_id_fk", + "tableFrom": "proceeding_steps", + "tableTo": "proceedings", + "columnsFrom": [ + "proceeding_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proceedings": { + "name": "proceedings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "case_id": { + "name": "case_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "proceeding_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "proceeding_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'vorbereitung'" + }, + "filing_date": { + "name": "filing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "internal_ref": { + "name": "internal_ref", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "external_ref": { + "name": "external_ref", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "tribunal_id": { + "name": "tribunal_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "court_name": { + "name": "court_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "chamber": { + "name": "chamber", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "presiding_judge": { + "name": "presiding_judge", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "applicant": { + "name": "applicant", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "respondent": { + "name": "respondent", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "amount_in_dispute_cents": { + "name": "amount_in_dispute_cents", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fachgruppe_id": { + "name": "fachgruppe_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "current_step_key": { + "name": "current_step_key", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proceedings_tenant_idx": { + "name": "proceedings_tenant_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceedings_case_idx": { + "name": "proceedings_case_idx", + "columns": [ + { + "expression": "case_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceedings_type_idx": { + "name": "proceedings_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proceedings_status_idx": { + "name": "proceedings_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proceedings_tenant_id_tenants_id_fk": { + "name": "proceedings_tenant_id_tenants_id_fk", + "tableFrom": "proceedings", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proceedings_case_id_cases_id_fk": { + "name": "proceedings_case_id_cases_id_fk", + "tableFrom": "proceedings", + "tableTo": "cases", + "columnsFrom": [ + "case_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "proceedings_tribunal_id_arbitration_tribunals_id_fk": { + "name": "proceedings_tribunal_id_arbitration_tribunals_id_fk", + "tableFrom": "proceedings", + "tableTo": "arbitration_tribunals", + "columnsFrom": [ + "tribunal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "proceedings_fachgruppe_id_nv_buehne_fachgruppen_id_fk": { + "name": "proceedings_fachgruppe_id_nv_buehne_fachgruppen_id_fk", + "tableFrom": "proceedings", + "tableTo": "nv_buehne_fachgruppen", + "columnsFrom": [ + "fachgruppe_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.standard_clauses": { + "name": "standard_clauses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "instrument_id": { + "name": "instrument_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "varchar(200)", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "varchar(500)", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fachgruppe_ids": { + "name": "fachgruppe_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "norm_id": { + "name": "norm_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "standard_clauses_instrument_idx": { + "name": "standard_clauses_instrument_idx", + "columns": [ + { + "expression": "instrument_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "standard_clauses_category_idx": { + "name": "standard_clauses_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "standard_clauses_instrument_id_norm_instruments_id_fk": { + "name": "standard_clauses_instrument_id_norm_instruments_id_fk", + "tableFrom": "standard_clauses", + "tableTo": "norm_instruments", + "columnsFrom": [ + "instrument_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "standard_clauses_norm_id_norms_id_fk": { + "name": "standard_clauses_norm_id_norms_id_fk", + "tableFrom": "standard_clauses", + "tableTo": "norms", + "columnsFrom": [ + "norm_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tenants": { + "name": "tenants", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "retention_days": { + "name": "retention_days", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 3650 + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "tenants_slug_unique": { + "name": "tenants_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "tenant_id": { + "name": "tenant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "user_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_verified_at": { + "name": "email_verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_login_at": { + "name": "last_login_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_tenant_email_idx": { + "name": "users_tenant_email_idx", + "columns": [ + { + "expression": "tenant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_tenant_id_tenants_id_fk": { + "name": "users_tenant_id_tenants_id_fk", + "tableFrom": "users", + "tableTo": "tenants", + "columnsFrom": [ + "tenant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.analysis_mode": { + "name": "analysis_mode", + "schema": "public", + "values": [ + "gutachten", + "entscheidung", + "vergleich", + "risiko" + ] + }, + "public.analysis_status": { + "name": "analysis_status", + "schema": "public", + "values": [ + "draft", + "in_progress", + "completed", + "archived" + ] + }, + "public.clause_rating": { + "name": "clause_rating", + "schema": "public", + "values": [ + "standard", + "abweichend", + "kritisch", + "unbekannt" + ] + }, + "public.contract_doc_status": { + "name": "contract_doc_status", + "schema": "public", + "values": [ + "uploaded", + "extracting", + "extracted", + "analyzing", + "completed", + "failed" + ] + }, + "public.deadline_type": { + "name": "deadline_type", + "schema": "public", + "values": [ + "frist", + "termin", + "vorfrist" + ] + }, + "public.decision_type": { + "name": "decision_type", + "schema": "public", + "values": [ + "schiedsspruch", + "urteil", + "beschluss", + "vergleich", + "einstweilige_verfuegung" + ] + }, + "public.legal_domain": { + "name": "legal_domain", + "schema": "public", + "values": [ + "buehnenrecht", + "arbeitsrecht", + "tarifrecht", + "urheberrecht", + "sozialrecht", + "vertragsrecht", + "prozessrecht" + ] + }, + "public.norm_type": { + "name": "norm_type", + "schema": "public", + "values": [ + "gesetz", + "tarifvertrag", + "schiedsordnung", + "verordnung", + "satzung", + "richtlinie" + ] + }, + "public.proceeding_status": { + "name": "proceeding_status", + "schema": "public", + "values": [ + "vorbereitung", + "eingereicht", + "laufend", + "verhandlung", + "entschieden", + "abgeschlossen", + "ruht" + ] + }, + "public.proceeding_step_status": { + "name": "proceeding_step_status", + "schema": "public", + "values": [ + "ausstehend", + "aktiv", + "abgeschlossen", + "uebersprungen" + ] + }, + "public.proceeding_type": { + "name": "proceeding_type", + "schema": "public", + "values": [ + "bschgo_bezirk", + "bschgo_bund", + "arbgg_erste_instanz", + "arbgg_berufung", + "arbgg_revision" + ] + }, + "public.source_rank": { + "name": "source_rank", + "schema": "public", + "values": [ + "gesetz", + "tarif", + "schiedsordnung", + "praxis", + "kommentar" + ] + }, + "public.user_role": { + "name": "user_role", + "schema": "public", + "values": [ + "admin", + "attorney", + "paralegal", + "viewer" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 7a6618b..c0ddb10 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -8,6 +8,13 @@ "when": 1775682934077, "tag": "0000_peaceful_amazoness", "breakpoints": true + }, + { + "idx": 1, + "version": "7", + "when": 1775690117252, + "tag": "0001_curved_fabian_cortez", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6858e05..6dc4a4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,25 +10,29 @@ "dependencies": { "@ai-sdk/anthropic": "^3.0.68", "@ai-sdk/openai": "^3.0.52", + "@types/bcryptjs": "^2.4.6", "ai": "^6.0.154", + "bcryptjs": "^3.0.3", "drizzle-orm": "^0.45.2", + "mammoth": "^1.12.0", "next": "16.2.3", "next-auth": "^4.24.13", + "pdf-parse": "^2.4.5", "pg": "^8.20.0", "react": "19.2.4", "react-dom": "19.2.4" }, "devDependencies": { - "@tailwindcss/postcss": "^4", + "@tailwindcss/postcss": "^4.2.2", "@types/node": "^20", "@types/pg": "^8.20.0", - "@types/react": "^19", + "@types/react": "19.2.14", "@types/react-dom": "^19", "drizzle-kit": "^0.31.10", "eslint": "^9", "eslint-config-next": "16.2.3", - "tailwindcss": "^4", - "typescript": "^5" + "tailwindcss": "^4.2.2", + "typescript": "5.9.3" } }, "node_modules/@ai-sdk/anthropic": { @@ -2049,6 +2053,205 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@napi-rs/canvas": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.80.tgz", + "integrity": "sha512-DxuT1ClnIPts1kQx8FBmkk4BQDTfI5kIzywAaMjQSXfNnra5UFU9PwurXrl+Je3bJ6BGsp/zmshVVFbCmyI+ww==", + "license": "MIT", + "workspaces": [ + "e2e/*" + ], + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@napi-rs/canvas-android-arm64": "0.1.80", + "@napi-rs/canvas-darwin-arm64": "0.1.80", + "@napi-rs/canvas-darwin-x64": "0.1.80", + "@napi-rs/canvas-linux-arm-gnueabihf": "0.1.80", + "@napi-rs/canvas-linux-arm64-gnu": "0.1.80", + "@napi-rs/canvas-linux-arm64-musl": "0.1.80", + "@napi-rs/canvas-linux-riscv64-gnu": "0.1.80", + "@napi-rs/canvas-linux-x64-gnu": "0.1.80", + "@napi-rs/canvas-linux-x64-musl": "0.1.80", + "@napi-rs/canvas-win32-x64-msvc": "0.1.80" + } + }, + "node_modules/@napi-rs/canvas-android-arm64": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-0.1.80.tgz", + "integrity": "sha512-sk7xhN/MoXeuExlggf91pNziBxLPVUqF2CAVnB57KLG/pz7+U5TKG8eXdc3pm0d7Od0WreB6ZKLj37sX9muGOQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-darwin-arm64": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-0.1.80.tgz", + "integrity": "sha512-O64APRTXRUiAz0P8gErkfEr3lipLJgM6pjATwavZ22ebhjYl/SUbpgM0xcWPQBNMP1n29afAC/Us5PX1vg+JNQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-darwin-x64": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-0.1.80.tgz", + "integrity": "sha512-FqqSU7qFce0Cp3pwnTjVkKjjOtxMqRe6lmINxpIZYaZNnVI0H5FtsaraZJ36SiTHNjZlUB69/HhxNDT1Aaa9vA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-arm-gnueabihf": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-0.1.80.tgz", + "integrity": "sha512-eyWz0ddBDQc7/JbAtY4OtZ5SpK8tR4JsCYEZjCE3dI8pqoWUC8oMwYSBGCYfsx2w47cQgQCgMVRVTFiiO38hHQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-arm64-gnu": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-0.1.80.tgz", + "integrity": "sha512-qwA63t8A86bnxhuA/GwOkK3jvb+XTQaTiVML0vAWoHyoZYTjNs7BzoOONDgTnNtr8/yHrq64XXzUoLqDzU+Uuw==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-arm64-musl": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-0.1.80.tgz", + "integrity": "sha512-1XbCOz/ymhj24lFaIXtWnwv/6eFHXDrjP0jYkc6iHQ9q8oXKzUX1Lc6bu+wuGiLhGh2GS/2JlfORC5ZcXimRcg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-riscv64-gnu": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-0.1.80.tgz", + "integrity": "sha512-XTzR125w5ZMs0lJcxRlS1K3P5RaZ9RmUsPtd1uGt+EfDyYMu4c6SEROYsxyatbbu/2+lPe7MPHOO/0a0x7L/gw==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-x64-gnu": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-0.1.80.tgz", + "integrity": "sha512-BeXAmhKg1kX3UCrJsYbdQd3hIMDH/K6HnP/pG2LuITaXhXBiNdh//TVVVVCBbJzVQaV5gK/4ZOCMrQW9mvuTqA==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-linux-x64-musl": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-0.1.80.tgz", + "integrity": "sha512-x0XvZWdHbkgdgucJsRxprX/4o4sEed7qo9rCQA9ugiS9qE2QvP0RIiEugtZhfLH3cyI+jIRFJHV4Fuz+1BHHMg==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@napi-rs/canvas-win32-x64-msvc": { + "version": "0.1.80", + "resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-0.1.80.tgz", + "integrity": "sha512-Z8jPsM6df5V8B1HrCHB05+bDiCxjE9QA//3YrkKIdVDEwn5RKaqOxCJDRJkl48cJbylcrJbW4HxZbTte8juuPg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@napi-rs/wasm-runtime": { "version": "0.2.12", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.12.tgz", @@ -2600,6 +2803,12 @@ "tslib": "^2.4.0" } }, + "node_modules/@types/bcryptjs": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", + "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==", + "license": "MIT" + }, "node_modules/@types/estree": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", @@ -3260,6 +3469,15 @@ "node": ">= 20" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.8.12", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.12.tgz", + "integrity": "sha512-9k/gHF6n/pAi/9tqr3m3aqkuiNosYTurLLUtc7xQ9sxB/wm7WPygCv8GYa6mS0fLJEHhqMC1ATYhz++U/lRHqg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/acorn": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", @@ -3571,6 +3789,26 @@ "dev": true, "license": "MIT" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/baseline-browser-mapping": { "version": "2.10.16", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.16.tgz", @@ -3583,6 +3821,21 @@ "node": ">=6.0.0" } }, + "node_modules/bcryptjs": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-3.0.3.tgz", + "integrity": "sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g==", + "license": "BSD-3-Clause", + "bin": { + "bcrypt": "bin/bcrypt" + } + }, + "node_modules/bluebird": { + "version": "3.4.7", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", + "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==", + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz", @@ -3794,6 +4047,12 @@ "node": ">= 0.6" } }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -3948,6 +4207,12 @@ "node": ">=8" } }, + "node_modules/dingbat-to-unicode": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dingbat-to-unicode/-/dingbat-to-unicode-1.0.1.tgz", + "integrity": "sha512-98l0sW87ZT58pU4i61wa2OHwxbiYSbuxsCBozaVnYX2iCnr3bLM3fIes1/ej7h1YdOKuKt/MLs706TVnALA65w==", + "license": "BSD-2-Clause" + }, "node_modules/doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -4102,6 +4367,15 @@ } } }, + "node_modules/duck": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/duck/-/duck-0.1.12.tgz", + "integrity": "sha512-wkctla1O6VfP89gQ+J/yDesM0S7B7XLXjKGzXxMDVFg7uEn706niAtyYovKbyq1oT9YwDcly721/iUWoc8MVRg==", + "license": "BSD", + "dependencies": { + "underscore": "^1.13.1" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -5274,6 +5548,12 @@ "node": ">= 4" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "license": "MIT" + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -5301,6 +5581,12 @@ "node": ">=0.8.19" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, "node_modules/internal-slot": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", @@ -5871,6 +6157,18 @@ "node": ">=4.0" } }, + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "license": "(MIT OR GPL-3.0-or-later)", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -5915,6 +6213,15 @@ "node": ">= 0.8.0" } }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "license": "MIT", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/lightningcss": { "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", @@ -6224,6 +6531,17 @@ "loose-envify": "cli.js" } }, + "node_modules/lop": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/lop/-/lop-0.4.2.tgz", + "integrity": "sha512-RefILVDQ4DKoRZsJ4Pj22TxE3omDO47yFpkIBoDKzkqPRISs5U1cnAdg/5583YPkWPaLIYHOKRMQSvjFsO26cw==", + "license": "BSD-2-Clause", + "dependencies": { + "duck": "^0.1.12", + "option": "~0.2.1", + "underscore": "^1.13.1" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -6244,6 +6562,39 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/mammoth": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/mammoth/-/mammoth-1.12.0.tgz", + "integrity": "sha512-cwnK1RIcRdDMi2HRx2EXGYlxqIEh0Oo3bLhorgnsVJi2UkbX1+jKxuBNR9PC5+JaX7EkmJxFPmo6mjLpqShI2w==", + "license": "BSD-2-Clause", + "dependencies": { + "@xmldom/xmldom": "^0.8.6", + "argparse": "~1.0.3", + "base64-js": "^1.5.1", + "bluebird": "~3.4.0", + "dingbat-to-unicode": "^1.0.1", + "jszip": "^3.7.1", + "lop": "^0.4.2", + "path-is-absolute": "^1.0.0", + "underscore": "^1.13.1", + "xmlbuilder": "^10.0.0" + }, + "bin": { + "mammoth": "bin/mammoth" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/mammoth/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -6668,6 +7019,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "license": "ISC" }, + "node_modules/option": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/option/-/option-0.2.4.tgz", + "integrity": "sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==", + "license": "BSD-2-Clause" + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -6736,6 +7093,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "license": "(MIT AND Zlib)" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -6759,6 +7122,15 @@ "node": ">=8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -6776,6 +7148,38 @@ "dev": true, "license": "MIT" }, + "node_modules/pdf-parse": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/pdf-parse/-/pdf-parse-2.4.5.tgz", + "integrity": "sha512-mHU89HGh7v+4u2ubfnevJ03lmPgQ5WU4CxAVmTSh/sxVTEDYd1er/dKS/A6vg77NX47KTEoihq8jZBLr8Cxuwg==", + "license": "Apache-2.0", + "dependencies": { + "@napi-rs/canvas": "0.1.80", + "pdfjs-dist": "5.4.296" + }, + "bin": { + "pdf-parse": "bin/cli.mjs" + }, + "engines": { + "node": ">=20.16.0 <21 || >=22.3.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/mehmet-kozan" + } + }, + "node_modules/pdfjs-dist": { + "version": "5.4.296", + "resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-5.4.296.tgz", + "integrity": "sha512-DlOzet0HO7OEnmUmB6wWGJrrdvbyJKftI1bhMitK7O2N8W2gc757yyYBbINy9IDafXAV9wmKr9t7xsTaNKRG5Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=20.16.0 || >=22.3.0" + }, + "optionalDependencies": { + "@napi-rs/canvas": "^0.1.80" + } + }, "node_modules/pg": { "version": "8.20.0", "resolved": "https://registry.npmjs.org/pg/-/pg-8.20.0.tgz", @@ -7000,6 +7404,12 @@ "integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew==", "license": "MIT" }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -7071,6 +7481,27 @@ "dev": true, "license": "MIT" }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -7214,6 +7645,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, "node_modules/safe-push-apply": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", @@ -7314,6 +7751,12 @@ "node": ">= 0.4" } }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "license": "MIT" + }, "node_modules/sharp": { "version": "0.34.5", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", @@ -7510,6 +7953,12 @@ "node": ">= 10.x" } }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "license": "BSD-3-Clause" + }, "node_modules/stable-hash": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz", @@ -7531,6 +7980,15 @@ "node": ">= 0.4" } }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/string.prototype.includes": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.1.tgz", @@ -8495,6 +8953,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/underscore": { + "version": "1.13.8", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.8.tgz", + "integrity": "sha512-DXtD3ZtEQzc7M8m4cXotyHR+FAS18C64asBYY5vqZexfYryNNnDc02W4hKg3rdQuqOYas1jkseX0+nZXjTXnvQ==", + "license": "MIT" + }, "node_modules/undici-types": { "version": "6.21.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", @@ -8578,6 +9042,12 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, "node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -8702,6 +9172,15 @@ "node": ">=0.10.0" } }, + "node_modules/xmlbuilder": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-10.1.1.tgz", + "integrity": "sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==", + "license": "MIT", + "engines": { + "node": ">=4.0" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index c415322..fe8b6bf 100644 --- a/package.json +++ b/package.json @@ -11,24 +11,28 @@ "dependencies": { "@ai-sdk/anthropic": "^3.0.68", "@ai-sdk/openai": "^3.0.52", + "@types/bcryptjs": "^2.4.6", "ai": "^6.0.154", + "bcryptjs": "^3.0.3", "drizzle-orm": "^0.45.2", + "mammoth": "^1.12.0", "next": "16.2.3", "next-auth": "^4.24.13", + "pdf-parse": "^2.4.5", "pg": "^8.20.0", "react": "19.2.4", "react-dom": "19.2.4" }, "devDependencies": { - "@tailwindcss/postcss": "^4", + "@tailwindcss/postcss": "^4.2.2", "@types/node": "^20", "@types/pg": "^8.20.0", - "@types/react": "^19", + "@types/react": "19.2.14", "@types/react-dom": "^19", "drizzle-kit": "^0.31.10", "eslint": "^9", "eslint-config-next": "16.2.3", - "tailwindcss": "^4", - "typescript": "^5" + "tailwindcss": "^4.2.2", + "typescript": "5.9.3" } } diff --git a/src/app/(auth)/login/page.tsx b/src/app/(auth)/login/page.tsx new file mode 100644 index 0000000..cae4523 --- /dev/null +++ b/src/app/(auth)/login/page.tsx @@ -0,0 +1,104 @@ +'use client'; + +import { useState } from 'react'; +import { signIn } from 'next-auth/react'; +import { useRouter } from 'next/navigation'; +import Link from 'next/link'; + +export default function LoginPage() { + const router = useRouter(); + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(false); + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + setError(''); + setLoading(true); + + const result = await signIn('credentials', { + email, + password, + redirect: false, + }); + + setLoading(false); + + if (result?.error) { + setError('E-Mail oder Passwort ungültig.'); + } else { + router.push('/dashboard'); + } + } + + return ( +
+
+
+
+ + + +
+

LegalAI

+

Bühnenrecht-Plattform

+
+ +
+

Anmelden

+ + {error && ( +
+ {error} +
+ )} + +
+ + setEmail(e.target.value)} + required + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" + placeholder="anwalt@kanzlei.de" + /> +
+ +
+ + setPassword(e.target.value)} + required + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" + /> +
+ + + +

+ Noch kein Konto?{' '} + + Registrieren + +

+
+
+
+ ); +} diff --git a/src/app/(auth)/register/page.tsx b/src/app/(auth)/register/page.tsx new file mode 100644 index 0000000..bdf240a --- /dev/null +++ b/src/app/(auth)/register/page.tsx @@ -0,0 +1,102 @@ +'use client'; + +import { useState } from 'react'; +import { useRouter } from 'next/navigation'; +import Link from 'next/link'; + +export default function RegisterPage() { + const router = useRouter(); + const [form, setForm] = useState({ name: '', email: '', password: '', tenantName: '' }); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(false); + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + setError(''); + setLoading(true); + + try { + const res = await fetch('/api/auth/register', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(form), + }); + + if (!res.ok) { + const data = await res.json(); + throw new Error(data.error || 'Registrierung fehlgeschlagen'); + } + + router.push('/login?registered=true'); + } catch (err) { + setError(err instanceof Error ? err.message : 'Ein Fehler ist aufgetreten'); + } finally { + setLoading(false); + } + } + + function updateForm(field: string, value: string) { + setForm((prev) => ({ ...prev, [field]: value })); + } + + return ( +
+
+
+
+ + + +
+

LegalAI

+

Konto erstellen

+
+ +
+

Registrieren

+ + {error && ( +
{error}
+ )} + +
+ + updateForm('tenantName', e.target.value)} required + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" + placeholder="Kanzlei Muster" /> +
+ +
+ + updateForm('name', e.target.value)} required + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" + placeholder="Max Mustermann" /> +
+ +
+ + updateForm('email', e.target.value)} required + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" + placeholder="anwalt@kanzlei.de" /> +
+ +
+ + updateForm('password', e.target.value)} required minLength={8} + className="w-full rounded-lg border border-card-border px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary" /> +
+ + + +

+ Bereits registriert?{' '} + Anmelden +

+
+
+
+ ); +} diff --git a/src/app/(dashboard)/analyse/analyse-form.tsx b/src/app/(dashboard)/analyse/analyse-form.tsx new file mode 100644 index 0000000..b768cdc --- /dev/null +++ b/src/app/(dashboard)/analyse/analyse-form.tsx @@ -0,0 +1,140 @@ +'use client'; + +import { useState } from 'react'; + +interface CaseOption { + id: string; + title: string; + caseNumber: string; +} + +const MODES = [ + { key: 'gutachten', label: 'Gutachten' }, + { key: 'entscheidung', label: 'Entscheidungsprognose' }, + { key: 'vergleich', label: 'Vergleichsanalyse' }, + { key: 'risiko', label: 'Risikoanalyse' }, +] as const; + +export default function AnalyseForm({ cases }: { cases: CaseOption[] }) { + const [mode, setMode] = useState('gutachten'); + const [caseId, setCaseId] = useState(''); + const [question, setQuestion] = useState(''); + const [result, setResult] = useState(''); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + if (!question.trim()) return; + + setError(''); + setResult(''); + setLoading(true); + + try { + const res = await fetch('/api/analyses', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + mode, + question: question.trim(), + caseId: caseId || undefined, + }), + }); + + if (!res.ok) { + throw new Error('Analyse konnte nicht gestartet werden'); + } + + const reader = res.body?.getReader(); + const decoder = new TextDecoder(); + + if (reader) { + let text = ''; + while (true) { + const { done, value } = await reader.read(); + if (done) break; + text += decoder.decode(value, { stream: true }); + setResult(text); + } + } + } catch (err) { + setError(err instanceof Error ? err.message : 'Ein Fehler ist aufgetreten'); + } finally { + setLoading(false); + } + } + + return ( +
+
+
+
+ + +
+ +
+ + +
+
+ +
+ +