import { DateTime, DurationLikeObject } from "luxon"; import { Caches } from "./Cache.js"; import { Recurrence, RecurrenceInText } from "./dateRange/checkRecurrence.js"; import { DocumentMessage, Foldable, ParseMessage } from "./ParsingContext.js"; export type DateTimeGranularity = "instant" | "year" | "month" | "week" | "day" | "hour" | "minute"; export type GranularDateTime = { dateTimeIso: DateTimeIso; granularity: DateTimeGranularity; }; export type DateFormat = typeof AMERICAN_DATE_FORMAT | typeof EUROPEAN_DATE_FORMAT; export declare const AMERICAN_DATE_FORMAT = "M/d/y"; export declare const EUROPEAN_DATE_FORMAT = "d/M/y"; export declare const DATE_TIME_FORMAT_MONTH_YEAR = "M/y"; export declare const DATE_TIME_FORMAT_YEAR = "y"; export declare class RelativeDate { /** * Note that this does not accurately work for week days as * we would otherwise need to know the date that this is * being diffed from. * @param raw */ static diffFromString(raw: string): DurationLikeObject; static fromPlus(raw: string, priorDate: DateTime): DateTime; static fromMinus(raw: string, priorDate: DateTime): DateTime; static from(raw: string, priorDate: DateTime, plusOrMinus?: "plus" | "minus"): DateTime; } export interface DateRange { fromDateTime: DateTime; toDateTime: DateTime; } export type DateTimeIso = string; export declare class DateRangePart implements DateRange { fromDateTime: DateTime; toDateTime: DateTime; originalString?: string; eventText: string; dateRangeInText: Range; definition: Range; recurrence?: Recurrence; isRelative: boolean; recurrenceRangeInText?: Range; fromRelativeTo?: { path: Path; dt: DateTime; }; toRelativeTo?: { path: Path; dt: DateTime; }; constructor({ from, to, originalString, dateRangeInText, eventText, definition, isRelative, recurrence, fromRelativeTo, toRelativeTo, }: { from: DateTime; to: DateTime; originalString: string; dateRangeInText: Range; eventText: string; definition: Range; isRelative: boolean; recurrence?: RecurrenceInText; fromRelativeTo?: { path: Path; dt: DateTime; }; toRelativeTo?: { path: Path; dt: DateTime; }; }); } export declare const LINK_REGEX: RegExp; export declare const LOCATION_REGEX: RegExp; export declare const IMAGE_REGEX: RegExp; export declare const AT_REGEX: RegExp; export declare enum BlockType { TEXT = "text", LIST_ITEM = "listItem", CHECKBOX = "checkbox", IMAGE = "image" } export interface MarkdownBlock { type: BlockType; } export declare class Block implements MarkdownBlock { type: BlockType; value?: any; raw: string; constructor(raw: string); } export declare class Image implements MarkdownBlock { type: BlockType; altText: string; link: string; constructor(altText: string, link: string); } export declare class EventDescription { eventDescription: string; tags: string[]; supplemental: MarkdownBlock[]; matchedListItems: Range[]; locations: string[]; id?: string; percent?: number; completed?: boolean; constructor(lines: string[], matchedListItems: Range[], completed?: boolean); } export declare enum RangeType { Comment = "comment", CheckboxItemIndicator = "checkboxItemIndicator", listItemIndicator = "listItemIndicator", ListItemContents = "listItemContents", Tag = "tag", tagDefinition = "tagDefinition", Title = "title", View = "view", Viewer = "viewer", Description = "description", Section = "section", DateRange = "dateRange", DateRangeColon = "dateRangeColon", Event = "event", Edit = "edit", Editor = "editor", Recurrence = "recurrence", FrontmatterDelimiter = "frontMatterDelimiter", HeaderKey = "headerKey", HeaderKeyColon = "headerKeyColon", HeaderValue = "headerValue", PropertyKey = "propertyKey", PropertyKeyColon = "propertyKeyColon", PropertyValue = "propertyValue", EventDefinition = "eventDefinition", SectionDefinition = "sectionDefinition", Properties = "properties" } export type Range = { from: number; to: number; type: RangeType; content?: any; }; export interface DateRangeIso { fromDateTimeIso: DateTimeIso; toDateTimeIso: DateTimeIso; } export declare const toDateRangeIso: (dr: DateRange) => DateRangeIso; export declare const toDateRange: (dr: DateRangeIso) => { fromDateTime: DateTime | DateTime; toDateTime: DateTime | DateTime; }; export type Eventy = Event | EventGroup; export declare function isEvent(eventy: Eventy): eventy is Event; export declare function isGroup(eventy: Eventy): eventy is EventGroup; export type GroupRange = DateRange & { maxFrom: DateTime; }; export declare class EventGroup { textRanges: { whole: Range; definition: Range; properties?: Range; }; properties: any; propOrder: string[]; propRange?: Range; tags: string[]; title: string; range?: GroupRange; startExpanded?: boolean; style?: GroupStyle; children: Array; } export declare class Event { firstLine: { full: string; datePart?: string; rest: string; restTrimmed: string; }; textRanges: { whole: Range; datePart: Range; definition: Range; recurrence?: Range; properties?: Range; }; properties: any; propOrder: string[]; dateRangeIso: DateRangeIso; recurrence?: Recurrence; tags: string[]; supplemental: MarkdownBlock[]; matchedListItems: Range[]; isRelative: boolean; fromRelativeTo?: { path: Path; dt: DateTimeIso; }; toRelativeTo?: { path: Path; dt: DateTimeIso; }; id?: string; percent?: number; completed?: boolean; constructor(firstLine: string, properties: any, propOrder: string[], propRange: Range | undefined, dateRange: DateRangePart, rangeInText: Range, dateRangeInText: Range, eventDescription: EventDescription); } export type Tags = { [tagName: string]: string; }; export type IdedEvents = { [id: string]: number[]; }; export interface Timeline { ranges: Range[]; foldables: { [index: number]: Foldable; }; events: EventGroup; header: any; ids: IdedEvents; parseMessages: ParseMessage[]; documentMessages: DocumentMessage[]; } export declare function emptyTimeline(): Timeline; export type ParseResult = Timeline & { cache?: Caches; parser: { version: string; incremental?: boolean; }; }; export type GroupStyle = "section" | "group"; export type Path = number[]; export declare const toArray: (node: Eventy) => { path: Path; eventy: Eventy; }[]; export declare function iterateTreeFromPath(root: EventGroup, path: Path): Generator<{ eventy: Eventy; path: Path; }, void, unknown>; export declare function iter(eventy: Eventy, path?: Path): Generator<{ eventy: Eventy; path: number[]; }>; export declare const push: (node: Event | EventGroup, onto: EventGroup, path?: Path, tail?: Event) => { path: number[]; tail?: Event; }; export declare const get: (root: Eventy, path: Path) => Eventy | undefined; export declare const getLast: (node: Eventy) => { node: Eventy; path: Path; }; export declare const flat: (node: Eventy) => Array; export declare const flatMap: (node: Eventy, mapper: (n: Eventy) => T) => Array; export declare const eventRange: (e: Event) => { fromDateTime: DateTime | DateTime; toDateTime: DateTime | DateTime; }; export declare const ranges: (root?: Eventy) => GroupRange | undefined;