ConsiderationDetails Types

ConsiderationDetails Types

The ConsiderationDetails type system represents various types of legal sources and documents that are used to generate responses in the Legal Research API. Each type has specific properties and use cases.

ConsiderationType Enum

Defines all possible types of legal considerations:

export enum ConsiderationType {
  ParagraphOrArticle = 'paragraph',
  CantonalParagraphOrArticle = 'cantonal_paragraph',
  CommunalParagraphOrArticle = 'communal_paragraph',
  CourtDecision = 'court_decision',
  Webpage = 'webpage',
  Commentary = 'commentary',
  Koordination = 'koordination',
  Document = 'document',
  Deadline = 'deadline',
  Authority = 'authority',
  ExplicitlyMentioned = 'explicitly_mentioned',
  CaseDocument = 'case_document',
  FAQ = 'faq',
  Template = 'template',
  Nutshell = 'nutshell',
  OtherInternal = 'other_internal',
  Reasoning = 'reasoning',
  Other = 'other',
}

Imports and Type Dependencies

import { ConsiderationType } from './consideration-types';
 
// Paragraph interface used in CaseDocumentDetails and OtherInternalDetails
export interface Paragraph {
  content?: string; // Optional - omit when storing references to reduce payload size
  role?: string;
  boundingRegions?: {
    pageNumber: number;
    polygon: number[];
  }[];
  spans?: {
    offset: number;
    length: number;
  }[];
}

Base Type

All consideration details share a common base structure:

export type ConsiderationDetailsBase = {
  label: ConsiderationType;
  title: string;
  relevant_ids: number[];
  citations: string[];
  content: string[];
};

Type Definitions

Most consideration types extend the base structure and add a url field. The base structure already includes:

  • label: The consideration type
  • title: Document/source title
  • relevant_ids: Array of relevant segment IDs
  • citations: Array of article/section citations
  • content: Array of relevant text excerpts

Article Types

ParagraphOrArticle

Federal law articles and paragraphs:

export type ParagraphOrArticleDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.ParagraphOrArticle;
  url: string;
};

CantonalParagraphOrArticle

Cantonal (state-level) law articles:

export type CantonalParagraphOrArticleDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.CantonalParagraphOrArticle;
  url: string;
};

CommunalParagraphOrArticle

Communal (municipal-level) law articles:

export type CommunalParagraphOrArticleDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.CommunalParagraphOrArticle;
  url: string;
};

Commentary Types

Commentary

Legal commentaries (Legalis or Omnilex based on permissions):

export type CommentaryDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Commentary;
  url: string;
};

Koordination

Koordination legal resources:

export type KoordinationDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Koordination;
  url: string;
};

Deadlines

export type DeadlineDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Deadline;
  url: string;
};

Authorities

export type AuthorityDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Authority;
  url: string;
};

Court Decisions

Court decisions and rulings:

export type CourtDecisionDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.CourtDecision;
  url: string;
};

Webpages

export type WebpageDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Webpage;
  url: string;
};

Files

Document

General documents:

export type DocumentDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Document;
  url: string;
};

CaseDocument

Case-specific documents with paragraph structure:

export type CaseDocumentDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.CaseDocument;
  url: string;
  paragraphs: Paragraph[];
};

FAQ

Frequently asked questions:

export type FAQDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.FAQ;
  url: string;
};

Template

Document templates:

export type TemplateDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Template;
  url: string;
};

Nutshell

Summarized legal information:

export type NutshellDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Nutshell;
  url: string;
};

OtherInternal

Internal file sources with additional file-specific fields:

export type OtherInternalDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.OtherInternal;
  url: string;
  paragraphs: Paragraph[];
  // TODO : Moha, we do not need these field once we refactor the internal files
  file_name?: string;
  file_segments_title?: string[];
  file_segments_content?: string[];
  file_segments_url?: string[];
};

Non-Displayable Sources

Reasoning

AI reasoning steps (backend use):

export type ReasoningDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Reasoning;
  url: string;
};

ExplicitlyMentioned

Sources explicitly requested by user:

export type ExplicitlyMentionedDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.ExplicitlyMentioned;
  url: string;
};

Other

Other source types:

export type OtherDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Other;
  url: string;
};

Legacy

Legacy source type for backward compatibility:

export type LegacyDetails = ConsiderationDetailsBase & {
  label: ConsiderationType.Other;
  url: string;
};

Union Type

The ConsiderationDetails type is a discriminated union of all possible consideration detail types:

export type ConsiderationDetails =
  | ParagraphOrArticleDetails
  | CantonalParagraphOrArticleDetails
  | CommunalParagraphOrArticleDetails
  | CourtDecisionDetails
  | WebpageDetails
  | CommentaryDetails
  | KoordinationDetails
  | DocumentDetails
  | DeadlineDetails
  | AuthorityDetails
  | ExplicitlyMentionedDetails
  | CaseDocumentDetails
  | FAQDetails
  | TemplateDetails
  | NutshellDetails
  | OtherInternalDetails
  | ReasoningDetails
  | OtherDetails
  | LegacyDetails;

Usage Example

When processing consideration details from the API response:

function processConsideration(detail: ConsiderationDetails) {
    // Common properties available on all types
    console.log("Type:", detail.label);
    console.log("Title:", detail.title);
    console.log("Citations:", detail.citations.join(", "));
    console.log("Content:", detail.content);
    
    // Type-specific handling
    switch (detail.label) {
        case ConsiderationType.OtherInternal:
            // detail is typed as OtherInternalDetails
            if (detail.file_name) {
                console.log("File name:", detail.file_name);
            }
            detail.paragraphs.forEach(paragraph => {
                console.log("Paragraph:", paragraph);
            });
            break;
            
        case ConsiderationType.CaseDocument:
            // detail is typed as CaseDocumentDetails
            console.log("URL:", detail.url);
            detail.paragraphs.forEach(paragraph => {
                console.log("Paragraph:", paragraph);
            });
            break;
            
        case ConsiderationType.ParagraphOrArticle:
            // detail is typed as ParagraphOrArticleDetails
            console.log("URL:", detail.url);
            break;
            
        // ... handle other types
    }
}

Response Example

Here's an example of consideration details in an API response:

{
  "considerationDetails": [
    {
      "label": "paragraph",
      "title": "VRV, 3. Teil: Verhalten bei Unfällen, Sicherung der Unfallstelle",
      "relevant_ids": [95, 87, 82],
      "url": "https://www.fedlex.admin.ch/eli/cc/1962/1364_1409_1420/de#art_54",
      "citations": ["Art. 54", "Art. 55", "Art. 56"],
      "content": ["Bei Unfällen...", "Der Fahrzeugführer...", "Die Polizei..."]
    },
    {
      "label": "court_decision",
      "title": "BGE 145 IV 123",
      "relevant_ids": [88],
      "url": "https://www.bger.ch/ext/eurospider/live/de/php/aza/http/index.php?highlight_docid=atf%3A%2F%2F145-IV-123",
      "citations": ["E. 3.2"],
      "content": ["Das Bundesgericht hat entschieden..."]
    },
    {
      "label": "case_document",
      "title": "Case Analysis Document",
      "relevant_ids": [101, 102],
      "url": "https://example.com/case-doc",
      "citations": ["Section 1", "Section 2"],
      "content": ["The case analysis shows...", "Further considerations include..."],
      "paragraphs": [
        {
          "content": "First paragraph of case document",
          "role": "paragraph",
          "boundingRegions": [
            {
              "pageNumber": 1,
              "polygon": [0, 0, 595, 0, 595, 100, 0, 100]
            }
          ],
          "spans": [
            {
              "offset": 0,
              "length": 35
            }
          ]
        },
        {
          "content": "Second paragraph of case document",
          "role": "paragraph",
          "boundingRegions": [
            {
              "pageNumber": 1,
              "polygon": [0, 100, 595, 100, 595, 200, 0, 200]
            }
          ],
          "spans": [
            {
              "offset": 35,
              "length": 33
            }
          ]
        }
      ]
    },
    {
      "label": "other_internal",
      "title": "Internal Guidelines",
      "relevant_ids": [75, 70],
      "url": "internal://guidelines",
      "citations": ["Section 2.1", "Section 2.2"],
      "content": ["Guidelines state...", "Procedures require..."],
      "paragraphs": [],
      "file_name": "internal_guidelines.pdf",
      "file_segments_title": ["Section 2.1", "Section 2.2"],
      "file_segments_url": ["#section-2-1", "#section-2-2"],
      "file_segments_content": ["Guidelines state...", "Procedures require..."]
    }
  ]
}