import { Sql } from 'postgres'; import { TextAstArticle, TextAstDivision, TextAstPosition, TextAstReference, TextAstText } from '../text_parsers/ast.js'; import { FragmentPosition, FragmentReverseTransformation } from '../text_parsers/fragments.js'; import { TextParserContext } from '../text_parsers/parsers.js'; import { Transformation } from '../text_parsers/transformers.js'; export type DefinitionOrLink = ArticleDefinition | ArticleLink | DivisionLink | TextLink; export interface ArticleDefinition { article: TextAstArticle; /** * Same value as article.originalTransformation, added for homogeneity * * Only defined when a transformation was used to convert input text * to simplified text. */ originalTransformation?: FragmentReverseTransformation; /** * Same value as article.position, added for homogeneity */ position: FragmentPosition; reference: TextAstReference; textId: string; type: "article_definition"; } export interface ArticleExternalLink { article: TextAstArticle; articleId?: string; /** * Only defined when a transformation was used to convert input text * to simpeurolified text. */ originalTransformation?: FragmentReverseTransformation; position: FragmentPosition; reference: TextAstReference; type: "external_article"; } export interface ArticleInternalLink { article: TextAstArticle; definition: ArticleDefinition; /** * Only defined when a transformation was used to convert input text * to simplified text. */ originalTransformation?: FragmentReverseTransformation; position: FragmentPosition; reference: TextAstReference; type: "internal_article"; } export type ArticleLink = ArticleExternalLink | ArticleInternalLink; export interface DivisionExternalLink { division: TextAstDivision; /** * Only defined when a transformation was used to convert input text * to simplified text. */ originalTransformation?: FragmentReverseTransformation; position: FragmentPosition; reference: TextAstReference; sectionTaId?: string; type: "external_division"; } export type DivisionLink = DivisionExternalLink; export interface ExtractedLinkDb { field_name: string; index: number; link: ArticleExternalLink | DivisionExternalLink | TextEuropeanLink | TextExternalLink; source_id: string; target_id: string | null; } export interface TextEuropeanLink { /** * Only defined when a transformation was used to convert input text * to simplified text. */ originalTransformation?: FragmentReverseTransformation; position: FragmentPosition; reference: TextAstReference; text: TextAstText & TextAstPosition; titleId: string; type: "european_text"; url?: string; } export interface TextExternalLink { /** * Only defined when a transformation was used to convert input text * to simplified text. */ originalTransformation?: FragmentReverseTransformation; position: FragmentPosition; reference: TextAstReference; text: TextAstText & TextAstPosition; type: "external_text"; } export type TextLink = TextEuropeanLink | TextExternalLink; export interface TextLinksParserState { articleId?: string; codeId?: string; constitutionId?: string; decreeId?: string; defaultTextId?: string; lawId?: string; sectionTaId?: string; textId?: string; } export declare function extractTextLinks({ context, date, canutesDb, logIgnoredReferencesTypes, logPartialReferences, logReferences, state: inputState, transformation, }: { context: TextParserContext; date: string; canutesDb: Sql; logIgnoredReferencesTypes?: boolean; logPartialReferences?: boolean; logReferences?: boolean; /** * When given, state is modified by this generator, so that the callers * always has the latest state version (and can reuse it for the next article, * for example). */ state?: TextLinksParserState; transformation?: Transformation; }): AsyncGenerator; export declare function iterReferenceLinks({ articleDefinitionByNumByTextId: articleDefinitionByNumByTextIdInput, canutesDb, context, date, logIgnoredReferencesTypes, logPartialReferences, originalPositionsFromTransformedIterator, reference, state: inputState, }: { articleDefinitionByNumByTextId?: Record>; canutesDb: Sql; context: TextParserContext; date: string; logIgnoredReferencesTypes?: boolean; logPartialReferences?: boolean; originalPositionsFromTransformedIterator?: Generator; reference: TextAstReference; /** * When given, state is modified by this generator, so that the callers * always has the latest state version (and can reuse it for the next article, * for example). */ state?: TextLinksParserState; }): AsyncGenerator;