@moltenship/ics 0.0.0-stage → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,726 @@
1
+ //#region src/standard-schema.d.ts
2
+ /** The Standard Typed interface. This is a base type extended by other specs. */
3
+ interface StandardTypedV1<Input = unknown, Output = Input> {
4
+ /** The Standard properties. */
5
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
6
+ }
7
+ declare namespace StandardTypedV1 {
8
+ /** The Standard Typed properties interface. */
9
+ interface Props<Input = unknown, Output = Input> {
10
+ /** The version number of the standard. */
11
+ readonly version: 1;
12
+ /** The vendor name of the schema library. */
13
+ readonly vendor: string;
14
+ /** Inferred types associated with the schema. */
15
+ readonly types?: Types<Input, Output> | undefined;
16
+ }
17
+ /** The Standard Typed types interface. */
18
+ interface Types<Input = unknown, Output = Input> {
19
+ /** The input type of the schema. */
20
+ readonly input: Input;
21
+ /** The output type of the schema. */
22
+ readonly output: Output;
23
+ }
24
+ /** Infers the input type of a Standard Typed. */
25
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
26
+ /** Infers the output type of a Standard Typed. */
27
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
28
+ }
29
+ /** The Standard Schema interface. */
30
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
31
+ /** The Standard Schema properties. */
32
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
33
+ }
34
+ declare namespace StandardSchemaV1 {
35
+ /** The Standard Schema properties interface. */
36
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
37
+ /** Validates unknown input values. */
38
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options) => Result<Output> | Promise<Result<Output>>;
39
+ }
40
+ /** The result interface of the validate function. */
41
+ type Result<Output> = SuccessResult<Output> | FailureResult;
42
+ /** The result interface if validation succeeds. */
43
+ interface SuccessResult<Output> {
44
+ /** The typed output value. */
45
+ readonly value: Output;
46
+ /** A falsy value for `issues` indicates success. */
47
+ readonly issues?: undefined;
48
+ }
49
+ interface Options {
50
+ /** Explicit support for additional vendor-specific parameters, if needed. */
51
+ readonly libraryOptions?: Record<string, unknown> | undefined;
52
+ }
53
+ /** The result interface if validation fails. */
54
+ interface FailureResult {
55
+ /** The issues of failed validation. */
56
+ readonly issues: ReadonlyArray<Issue>;
57
+ }
58
+ /** The issue interface of the failure output. */
59
+ interface Issue {
60
+ /** The error message of the issue. */
61
+ readonly message: string;
62
+ /** The path of the issue, if any. */
63
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
64
+ }
65
+ /** The path segment interface of the issue. */
66
+ interface PathSegment {
67
+ /** The key representing a path segment. */
68
+ readonly key: PropertyKey;
69
+ }
70
+ /** The Standard types interface. */
71
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
72
+ /** Infers the input type of a Standard. */
73
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
74
+ /** Infers the output type of a Standard. */
75
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
+ }
77
+ //#endregion
78
+ //#region src/types.d.ts
79
+ /** One content line after unfolding. */
80
+ interface IcsProperty {
81
+ /** 1-based line of the property's first physical line; absent for properties built in code. */
82
+ readonly line?: number;
83
+ /** Upper-cased property name, such as `DTSTART` or `X-WR-CALNAME`. */
84
+ readonly name: string;
85
+ /**
86
+ * Upper-cased parameter names to their values: unquoted, RFC 6868-decoded and split on commas
87
+ * outside quotes, in source order. Indexing an absent parameter gives `undefined`.
88
+ */
89
+ readonly parameters: IcsParameters;
90
+ /** The value exactly as written after unfolding: TEXT escapes are still in place. */
91
+ readonly value: string;
92
+ }
93
+ type IcsParameters = Readonly<Partial<Record<string, readonly string[]>>>;
94
+ /** A `BEGIN:…` / `END:…` block. */
95
+ interface IcsComponent {
96
+ /** Nested components in source order. */
97
+ readonly components: readonly IcsComponent[];
98
+ /** 1-based line of the `BEGIN` line; absent for components built in code. */
99
+ readonly line?: number;
100
+ /** Upper-cased component name, such as `VCALENDAR` or `VEVENT`. */
101
+ readonly name: string;
102
+ /** Properties in source order. */
103
+ readonly properties: readonly IcsProperty[];
104
+ }
105
+ type IcsIssueSeverity = "error" | "warning";
106
+ type IcsIssueCode =
107
+ /**
108
+ * A required property is absent, such as UID or DTSTART: an error that skips the component. The
109
+ * issue's line is the component's BEGIN line.
110
+ */
111
+ "missing-property" |
112
+ /** A property that may occur once occurs again: a warning; the first one wins. */
113
+ "duplicate-property" |
114
+ /**
115
+ * Properties that exclude each other: a warning. DTEND wins over DURATION; a rule with both
116
+ * COUNT and UNTIL keeps both.
117
+ */
118
+ "conflicting-properties" |
119
+ /** A line that isn't `name *(;param) : value`, or an invalid parameter. */
120
+ "invalid-content-line" |
121
+ /** BEGIN/END nesting is broken: an END without its BEGIN, or a component left open. */
122
+ "invalid-structure" |
123
+ /** A value doesn't parse as its value type. */
124
+ "invalid-value" |
125
+ /** A TZID that resolves to no time zone. The value is kept as `unresolved`. */
126
+ "unknown-time-zone" |
127
+ /** A construct the package recognizes but doesn't interpret, such as RSCALE. */
128
+ "unsupported" |
129
+ /** An extension's Standard Schema rejected a value, or returned a promise. */
130
+ "schema";
131
+ interface IcsIssue {
132
+ readonly code: IcsIssueCode;
133
+ /** Upper-cased name of the component the issue belongs to, such as `VEVENT`. */
134
+ readonly component?: string;
135
+ /** 1-based source line, when the issue comes from one. */
136
+ readonly line?: number;
137
+ readonly message: string;
138
+ /**
139
+ * Where the issue lands in the typed result, such as `["calendars", 0, "events", 3, "start"]`.
140
+ * Indexes count the components that were kept; a skipped component's path ends at its
141
+ * collection, such as `["calendars", 0, "events"]`. Empty for syntax issues.
142
+ */
143
+ readonly path: readonly (number | string)[];
144
+ /** Upper-cased name of the property the issue belongs to, such as `DTSTART`. */
145
+ readonly property?: string;
146
+ /** Errors drop the value or component they concern; warnings keep a best-effort value. */
147
+ readonly severity: IcsIssueSeverity;
148
+ }
149
+ type IcsValueType = "BINARY" | "BOOLEAN" | "CAL-ADDRESS" | "DATE" | "DATE-TIME" | "DURATION" | "FLOAT" | "INTEGER" | "PERIOD" | "RECUR" | "TEXT" | "TIME" | "URI" | "UTC-OFFSET";
150
+ /** A DATE value. */
151
+ interface IcsDate {
152
+ readonly date: Temporal.PlainDate;
153
+ readonly kind: "date";
154
+ }
155
+ /** A DATE-TIME ending in `Z`. */
156
+ interface IcsUtcDateTime {
157
+ readonly instant: Temporal.Instant;
158
+ readonly kind: "utc";
159
+ }
160
+ /**
161
+ * A DATE-TIME with a TZID that resolved to a time zone. A wall time in a DST gap or fold resolves
162
+ * as RFC 5545 §3.3.5 says, which is Temporal's `compatible` disambiguation.
163
+ */
164
+ interface IcsZonedDateTime {
165
+ readonly kind: "zoned";
166
+ /** The TZID parameter as written. `zoned.timeZoneId` is the time zone it resolved to. */
167
+ readonly tzid: string;
168
+ /** The wall time as written, which differs from `zoned` inside a DST gap. */
169
+ readonly wallTime: Temporal.PlainDateTime;
170
+ readonly zoned: Temporal.ZonedDateTime;
171
+ }
172
+ /** A DATE-TIME with a TZID that resolved to no time zone. */
173
+ interface IcsUnresolvedDateTime {
174
+ readonly kind: "unresolved";
175
+ readonly tzid: string;
176
+ readonly wallTime: Temporal.PlainDateTime;
177
+ }
178
+ /** A DATE-TIME with neither `Z` nor TZID: the same wall time in every time zone. */
179
+ interface IcsFloatingDateTime {
180
+ readonly kind: "floating";
181
+ readonly wallTime: Temporal.PlainDateTime;
182
+ }
183
+ type IcsDateTime = IcsFloatingDateTime | IcsUnresolvedDateTime | IcsUtcDateTime | IcsZonedDateTime;
184
+ /** What DTSTART, DTEND, DUE, RECURRENCE-ID, EXDATE, RDATE and UNTIL may hold. */
185
+ type IcsDateValue = IcsDate | IcsDateTime;
186
+ /** A TIME value. */
187
+ interface IcsTime {
188
+ readonly time: Temporal.PlainTime;
189
+ /** The value ends in `Z`. */
190
+ readonly utc: boolean;
191
+ }
192
+ /** A PERIOD value: an explicit end, or a duration. */
193
+ type IcsPeriod = {
194
+ readonly end: IcsDateTime;
195
+ readonly start: IcsDateTime;
196
+ } | {
197
+ readonly duration: Temporal.Duration;
198
+ readonly start: IcsDateTime;
199
+ };
200
+ /**
201
+ * A UTC-OFFSET value as a Temporal offset string, `±HH:MM` or `±HH:MM:SS`, such as `"+05:30"`.
202
+ */
203
+ type IcsUtcOffset = string;
204
+ type IcsFrequency = "DAILY" | "HOURLY" | "MINUTELY" | "MONTHLY" | "SECONDLY" | "WEEKLY" | "YEARLY";
205
+ type IcsWeekday = "FR" | "MO" | "SA" | "SU" | "TH" | "TU" | "WE";
206
+ /** A BYDAY entry: `MO`, `1MO` (first Monday) or `-1FR` (last Friday). */
207
+ interface IcsWeekdayNumber {
208
+ /** −53 to 53, never 0; absent for every such weekday in the period. */
209
+ readonly ordinal?: number;
210
+ readonly weekday: IcsWeekday;
211
+ }
212
+ /** A RECUR value, parsed but not expanded. Parts that the rule doesn't state are absent. */
213
+ interface IcsRecurrenceRule {
214
+ readonly byDay?: readonly IcsWeekdayNumber[];
215
+ readonly byHour?: readonly number[];
216
+ readonly byMinute?: readonly number[];
217
+ /** 1 to 12. */
218
+ readonly byMonth?: readonly number[];
219
+ /** −31 to 31, never 0. */
220
+ readonly byMonthDay?: readonly number[];
221
+ readonly bySecond?: readonly number[];
222
+ /** −366 to 366, never 0. */
223
+ readonly bySetPosition?: readonly number[];
224
+ /** −53 to 53, never 0. */
225
+ readonly byWeekNumber?: readonly number[];
226
+ /** −366 to 366, never 0. */
227
+ readonly byYearDay?: readonly number[];
228
+ readonly count?: number;
229
+ readonly frequency: IcsFrequency;
230
+ /** A positive integer; RFC 5545 defaults it to 1. */
231
+ readonly interval?: number;
232
+ readonly until?: IcsDateValue;
233
+ /** WKST; RFC 5545 defaults it to `MO`. */
234
+ readonly weekStart?: IcsWeekday;
235
+ }
236
+ /** The decoded type of each value type. */
237
+ interface IcsDecodedValueMap {
238
+ /** Base64 text as written. */
239
+ readonly BINARY: string;
240
+ readonly BOOLEAN: boolean;
241
+ /** The URI as written, such as `mailto:ann@example.com`. */
242
+ readonly "CAL-ADDRESS": string;
243
+ readonly DATE: IcsDate;
244
+ readonly "DATE-TIME": IcsDateTime;
245
+ readonly DURATION: Temporal.Duration;
246
+ readonly FLOAT: number;
247
+ readonly INTEGER: number;
248
+ readonly PERIOD: IcsPeriod;
249
+ readonly RECUR: IcsRecurrenceRule;
250
+ readonly TEXT: string;
251
+ readonly TIME: IcsTime;
252
+ readonly URI: string;
253
+ readonly "UTC-OFFSET": IcsUtcOffset;
254
+ }
255
+ /** An open string union: the listed values autocomplete, any other string is accepted. */
256
+ type IcsOpen<T extends string> = T | (string & {});
257
+ type IcsClassification = IcsOpen<"CONFIDENTIAL" | "PRIVATE" | "PUBLIC">;
258
+ type IcsEventStatus = IcsOpen<"CANCELLED" | "CONFIRMED" | "TENTATIVE">;
259
+ type IcsTodoStatus = IcsOpen<"CANCELLED" | "COMPLETED" | "IN-PROCESS" | "NEEDS-ACTION">;
260
+ type IcsJournalStatus = IcsOpen<"CANCELLED" | "DRAFT" | "FINAL">;
261
+ type IcsTransparency = IcsOpen<"OPAQUE" | "TRANSPARENT">;
262
+ /** ORGANIZER, or the common part of ATTENDEE. */
263
+ interface IcsCalendarUser {
264
+ /** The CAL-ADDRESS as written, such as `mailto:ann@example.com`. */
265
+ readonly address: string;
266
+ /** DIR. */
267
+ readonly directory?: string;
268
+ /** The EMAIL parameter (RFC 7986), else the address without `mailto:`, when it has one. */
269
+ readonly email?: string;
270
+ /** LANGUAGE. */
271
+ readonly language?: string;
272
+ /** CN. */
273
+ readonly name?: string;
274
+ /** Parameters no field maps, such as `X-NUM-GUESTS` or `SCHEDULE-STATUS`. */
275
+ readonly otherParameters: IcsParameters;
276
+ /** SENT-BY. */
277
+ readonly sentBy?: string;
278
+ }
279
+ interface IcsAttendee extends IcsCalendarUser {
280
+ /** CUTYPE. */
281
+ readonly calendarUserType?: IcsOpen<"GROUP" | "INDIVIDUAL" | "RESOURCE" | "ROOM" | "UNKNOWN">;
282
+ /** DELEGATED-FROM. */
283
+ readonly delegatedFrom: readonly string[];
284
+ /** DELEGATED-TO. */
285
+ readonly delegatedTo: readonly string[];
286
+ /** MEMBER. */
287
+ readonly memberOf: readonly string[];
288
+ /** PARTSTAT. */
289
+ readonly participationStatus?: IcsOpen<"ACCEPTED" | "COMPLETED" | "DECLINED" | "DELEGATED" | "IN-PROCESS" | "NEEDS-ACTION" | "TENTATIVE">;
290
+ /** ROLE. */
291
+ readonly role?: IcsOpen<"CHAIR" | "NON-PARTICIPANT" | "OPT-PARTICIPANT" | "REQ-PARTICIPANT">;
292
+ /** RSVP; absent when the parameter is. */
293
+ readonly rsvp?: boolean;
294
+ }
295
+ /** ATTACH: a URI, or inline base64 data (`ENCODING=BASE64;VALUE=BINARY`). */
296
+ type IcsAttachment = {
297
+ readonly formatType?: string;
298
+ readonly kind: "uri";
299
+ readonly uri: string;
300
+ } | {
301
+ readonly data: string;
302
+ readonly formatType?: string;
303
+ readonly kind: "binary";
304
+ };
305
+ /** CONFERENCE (RFC 7986). */
306
+ interface IcsConference {
307
+ /** FEATURE, such as `AUDIO`, `VIDEO` or `PHONE`. */
308
+ readonly features: readonly string[];
309
+ /** LABEL. */
310
+ readonly label?: string;
311
+ readonly uri: string;
312
+ }
313
+ /** GEO. */
314
+ interface IcsGeo {
315
+ readonly latitude: number;
316
+ readonly longitude: number;
317
+ }
318
+ /** RELATED-TO. */
319
+ interface IcsRelation {
320
+ /** RELTYPE; RFC 5545 defaults it to `PARENT`. */
321
+ readonly relationship?: IcsOpen<"CHILD" | "PARENT" | "SIBLING">;
322
+ readonly uid: string;
323
+ }
324
+ /** TRIGGER: relative to the start or end of its component, or an absolute instant. */
325
+ type IcsAlarmTrigger = {
326
+ readonly kind: "absolute";
327
+ readonly instant: Temporal.Instant;
328
+ } | {
329
+ readonly kind: "relative";
330
+ readonly offset: Temporal.Duration;
331
+ /** RELATED; RFC 5545 defaults it to `START`. */
332
+ readonly relatedTo: "END" | "START";
333
+ };
334
+ /** VALARM. */
335
+ interface IcsAlarm {
336
+ readonly action: IcsOpen<"AUDIO" | "DISPLAY" | "EMAIL">;
337
+ readonly attachments: readonly IcsAttachment[];
338
+ readonly attendees: readonly IcsAttendee[];
339
+ readonly description?: string;
340
+ /** DURATION between repeats. */
341
+ readonly duration?: Temporal.Duration;
342
+ readonly otherComponents: readonly IcsComponent[];
343
+ readonly otherProperties: readonly IcsProperty[];
344
+ /** REPEAT. */
345
+ readonly repeat?: number;
346
+ readonly summary?: string;
347
+ readonly trigger: IcsAlarmTrigger;
348
+ /** UID (RFC 9074). */
349
+ readonly uid?: string;
350
+ }
351
+ /** The properties VEVENT, VTODO and VJOURNAL share. */
352
+ interface IcsSchedulingFields {
353
+ readonly attachments: readonly IcsAttachment[];
354
+ readonly attendees: readonly IcsAttendee[];
355
+ readonly categories: readonly string[];
356
+ /** CLASS. */
357
+ readonly classification?: IcsClassification;
358
+ /** COLOR (RFC 7986): a CSS3 color name. */
359
+ readonly color?: string;
360
+ /** COMMENT, every occurrence. */
361
+ readonly comments: readonly string[];
362
+ /** CONTACT, every occurrence. */
363
+ readonly contacts: readonly string[];
364
+ /** CREATED, in UTC. */
365
+ readonly created?: Temporal.Instant;
366
+ readonly description?: string;
367
+ /** EXDATE, every value of every occurrence. */
368
+ readonly exceptionDates: readonly IcsDateValue[];
369
+ /** LAST-MODIFIED, in UTC. */
370
+ readonly lastModified?: Temporal.Instant;
371
+ readonly organizer?: IcsCalendarUser;
372
+ /** Properties no typed field or extension claims, in source order, including `X-` ones. */
373
+ readonly otherProperties: readonly IcsProperty[];
374
+ /** RDATE, every value of every occurrence. */
375
+ readonly recurrenceDates: readonly (IcsDateValue | IcsPeriod)[];
376
+ /** RECURRENCE-ID: this component overrides that occurrence of the series with its UID. */
377
+ readonly recurrenceId?: IcsDateValue;
378
+ /** RANGE on RECURRENCE-ID. */
379
+ readonly recurrenceRange?: "THISANDFUTURE";
380
+ /** RRULE. RFC 5545 allows one; any further RRULE is reported and skipped. */
381
+ readonly recurrenceRule?: IcsRecurrenceRule;
382
+ readonly relatedTo: readonly IcsRelation[];
383
+ /** SEQUENCE. */
384
+ readonly sequence?: number;
385
+ /** DTSTAMP, in UTC. Required by RFC 5545, but often missing from exports. */
386
+ readonly stamp?: Temporal.Instant;
387
+ readonly summary?: string;
388
+ readonly uid: string;
389
+ readonly url?: string;
390
+ }
391
+ /** VEVENT. `TExtensions` is the parser's `extensions` option, as for `IcsCalendar`. */
392
+ interface IcsEvent<TExtensions extends IcsExtensionsConfig = {}> extends IcsSchedulingFields {
393
+ readonly alarms: readonly IcsAlarm[];
394
+ readonly conferences: readonly IcsConference[];
395
+ /**
396
+ * DURATION as written; a negative one, which RFC 5545 doesn't allow, is kept and reported. Use
397
+ * `getEventEnd` for the effective end.
398
+ */
399
+ readonly duration?: Temporal.Duration;
400
+ /** DTEND as written. Use `getEventEnd` for the effective end. */
401
+ readonly end?: IcsDateValue;
402
+ readonly extensions: IcsExtensionValues<TExtensions["event"]>;
403
+ readonly geo?: IcsGeo;
404
+ readonly location?: string;
405
+ readonly otherComponents: readonly IcsComponent[];
406
+ /** 0 (undefined) to 9 (lowest). */
407
+ readonly priority?: number;
408
+ readonly resources: readonly string[];
409
+ /** DTSTART. An event without one is reported and skipped. */
410
+ readonly start: IcsDateValue;
411
+ readonly status?: IcsEventStatus;
412
+ /** TRANSP. */
413
+ readonly transparency?: IcsTransparency;
414
+ }
415
+ /** VTODO. `TExtensions` is the parser's `extensions` option, as for `IcsCalendar`. */
416
+ interface IcsTodo<TExtensions extends IcsExtensionsConfig = {}> extends IcsSchedulingFields {
417
+ readonly alarms: readonly IcsAlarm[];
418
+ /** COMPLETED, in UTC. */
419
+ readonly completed?: Temporal.Instant;
420
+ readonly conferences: readonly IcsConference[];
421
+ /** DUE. */
422
+ readonly due?: IcsDateValue;
423
+ readonly duration?: Temporal.Duration;
424
+ readonly extensions: IcsExtensionValues<TExtensions["todo"]>;
425
+ readonly geo?: IcsGeo;
426
+ readonly location?: string;
427
+ readonly otherComponents: readonly IcsComponent[];
428
+ /** PERCENT-COMPLETE. */
429
+ readonly percentComplete?: number;
430
+ readonly priority?: number;
431
+ readonly resources: readonly string[];
432
+ /** DTSTART. */
433
+ readonly start?: IcsDateValue;
434
+ readonly status?: IcsTodoStatus;
435
+ }
436
+ /** VJOURNAL. `TExtensions` is the parser's `extensions` option, as for `IcsCalendar`. */
437
+ interface IcsJournal<TExtensions extends IcsExtensionsConfig = {}> extends IcsSchedulingFields {
438
+ readonly extensions: IcsExtensionValues<TExtensions["journal"]>;
439
+ readonly otherComponents: readonly IcsComponent[];
440
+ /** DTSTART. */
441
+ readonly start?: IcsDateValue;
442
+ readonly status?: IcsJournalStatus;
443
+ }
444
+ /** FREEBUSY: periods of one type. */
445
+ interface IcsFreeBusyPeriods {
446
+ readonly periods: readonly IcsPeriod[];
447
+ /** FBTYPE; RFC 5545 defaults it to `BUSY`. */
448
+ readonly type: IcsOpen<"BUSY" | "BUSY-TENTATIVE" | "BUSY-UNAVAILABLE" | "FREE">;
449
+ }
450
+ /** VFREEBUSY. */
451
+ interface IcsFreeBusy {
452
+ readonly attendees: readonly IcsAttendee[];
453
+ readonly comments: readonly string[];
454
+ readonly contact?: string;
455
+ /** DTEND. */
456
+ readonly end?: IcsDateValue;
457
+ readonly freeBusy: readonly IcsFreeBusyPeriods[];
458
+ readonly organizer?: IcsCalendarUser;
459
+ readonly otherComponents: readonly IcsComponent[];
460
+ readonly otherProperties: readonly IcsProperty[];
461
+ /** DTSTAMP. */
462
+ readonly stamp?: Temporal.Instant;
463
+ /** DTSTART. */
464
+ readonly start?: IcsDateValue;
465
+ readonly uid: string;
466
+ readonly url?: string;
467
+ }
468
+ /** STANDARD or DAYLIGHT inside a VTIMEZONE. */
469
+ interface IcsTimeZoneObservance {
470
+ readonly comments: readonly string[];
471
+ readonly kind: "daylight" | "standard";
472
+ /** TZNAME, every occurrence. */
473
+ readonly names: readonly string[];
474
+ /** TZOFFSETFROM. */
475
+ readonly offsetFrom: IcsUtcOffset;
476
+ /** TZOFFSETTO. */
477
+ readonly offsetTo: IcsUtcOffset;
478
+ readonly otherProperties: readonly IcsProperty[];
479
+ /** RDATE. */
480
+ readonly recurrenceDates: readonly (IcsDateValue | IcsPeriod)[];
481
+ readonly recurrenceRule?: IcsRecurrenceRule;
482
+ /** DTSTART: a local wall time in the offset before the onset. */
483
+ readonly start: Temporal.PlainDateTime;
484
+ }
485
+ /** VTIMEZONE. */
486
+ interface IcsTimeZone {
487
+ readonly lastModified?: Temporal.Instant;
488
+ readonly observances: readonly IcsTimeZoneObservance[];
489
+ readonly otherComponents: readonly IcsComponent[];
490
+ readonly otherProperties: readonly IcsProperty[];
491
+ /** The time zone the TZID resolved to, if any: an IANA id or a `±HH:MM` offset. */
492
+ readonly timeZone?: string;
493
+ /** TZID as written. */
494
+ readonly tzid: string;
495
+ /** TZURL. */
496
+ readonly url?: string;
497
+ }
498
+ /**
499
+ * VCALENDAR. `TExtensions` is the parser's `extensions` option, the same argument every component
500
+ * type takes: `IcsCalendar<typeof config>`, `IcsEvent<typeof config>`.
501
+ */
502
+ interface IcsCalendar<TExtensions extends IcsExtensionsConfig = {}> {
503
+ /** CALSCALE; RFC 5545 defaults it to `GREGORIAN`. */
504
+ readonly calendarScale?: string;
505
+ /** COLOR (RFC 7986). */
506
+ readonly color?: string;
507
+ /** DESCRIPTION (RFC 7986), else `X-WR-CALDESC`. */
508
+ readonly description?: string;
509
+ readonly events: readonly IcsEvent<TExtensions>[];
510
+ readonly extensions: IcsExtensionValues<TExtensions["calendar"]>;
511
+ readonly freeBusy: readonly IcsFreeBusy[];
512
+ readonly journals: readonly IcsJournal<TExtensions>[];
513
+ readonly lastModified?: Temporal.Instant;
514
+ /** METHOD, such as `PUBLISH`, `REQUEST` or `CANCEL` (iTIP). */
515
+ readonly method?: string;
516
+ /** NAME (RFC 7986), else `X-WR-CALNAME`. */
517
+ readonly name?: string;
518
+ readonly otherComponents: readonly IcsComponent[];
519
+ readonly otherProperties: readonly IcsProperty[];
520
+ /** PRODID. */
521
+ readonly productId?: string;
522
+ /** REFRESH-INTERVAL (RFC 7986), else `X-PUBLISHED-TTL`. */
523
+ readonly refreshInterval?: Temporal.Duration;
524
+ /** SOURCE (RFC 7986). */
525
+ readonly source?: string;
526
+ /**
527
+ * `X-WR-TIMEZONE`, resolved to a time zone id: the zone the publisher meant for floating
528
+ * times. Floating values stay floating; apply it yourself if you want it.
529
+ */
530
+ readonly timeZone?: string;
531
+ readonly timeZones: readonly IcsTimeZone[];
532
+ readonly todos: readonly IcsTodo<TExtensions>[];
533
+ /** UID (RFC 7986). */
534
+ readonly uid?: string;
535
+ /** URL (RFC 7986). */
536
+ readonly url?: string;
537
+ readonly version?: string;
538
+ }
539
+ /** What an extension property's raw value is decoded to before its schema sees it. */
540
+ type IcsExtensionInput<TType extends IcsValueType> = TType extends "DATE" | "DATE-TIME" ? IcsDateValue : IcsDecodedValueMap[TType];
541
+ /** A typed property read into `extensions`. Build one with `icsExtension`. */
542
+ interface IcsExtension<TOutput = unknown> {
543
+ /** Collects every occurrence and every comma-separated value into an array. */
544
+ readonly multiple: boolean;
545
+ /** Upper-cased property name. */
546
+ readonly name: string;
547
+ /** Validates or transforms each decoded value. Must validate synchronously. */
548
+ readonly schema: StandardSchemaV1 | undefined;
549
+ /** The value type the raw value is decoded as, whatever its VALUE parameter says. */
550
+ readonly type: IcsValueType;
551
+ /** Type-level only: the value type in `extensions`. */
552
+ readonly "~output"?: TOutput;
553
+ }
554
+ type IcsExtensionMap = Readonly<Record<string, IcsExtension>>;
555
+ /** Extension properties per component, keyed by the field name they get in `extensions`. */
556
+ interface IcsExtensionsConfig {
557
+ readonly calendar?: IcsExtensionMap;
558
+ readonly event?: IcsExtensionMap;
559
+ readonly journal?: IcsExtensionMap;
560
+ readonly todo?: IcsExtensionMap;
561
+ }
562
+ /** The `extensions` object that an extension map produces. */
563
+ type IcsExtensionValues<TMap> = TMap extends IcsExtensionMap ? { readonly [K in keyof TMap]: TMap[K] extends IcsExtension<infer TOutput> ? TOutput : never; } : {};
564
+ /**
565
+ * A TZID resolver: a time zone id Temporal knows (an IANA id or a `±HH:MM` offset), or `undefined`
566
+ * to fall through to the built-in rules. An id Temporal doesn't know is treated like `undefined`.
567
+ */
568
+ type IcsTimeZoneResolver = (tzid: string,
569
+ /** The calendar's VTIMEZONE with this TZID, if it has one. */
570
+ definition: IcsComponent | undefined) => string | undefined;
571
+ /**
572
+ * Bad data becomes issues; only `strict` turns them into an `IcsParseError`. An exception thrown by
573
+ * a callback you pass, `resolveTimeZone` or an extension schema's `validate`, propagates out of
574
+ * `parse` as it is: it is a bug in your code, not in the text.
575
+ */
576
+ interface IcsParseOptions<TExtensions extends IcsExtensionsConfig = {}> {
577
+ readonly extensions?: TExtensions;
578
+ /** Consulted before the built-in TZID rules. */
579
+ readonly resolveTimeZone?: IcsTimeZoneResolver;
580
+ /** Throw `IcsParseError` when any error-severity issue is found. Default `false`. */
581
+ readonly strict?: boolean;
582
+ }
583
+ interface IcsParseResult<TExtensions extends IcsExtensionsConfig = {}> {
584
+ /** Every VCALENDAR in the text, usually one. Their components keep source order. */
585
+ readonly calendars: readonly IcsCalendar<TExtensions>[];
586
+ readonly issues: readonly IcsIssue[];
587
+ }
588
+ /**
589
+ * A configured parser. It is also a Standard Schema: `validate` takes the ICS text and fails with
590
+ * the error-severity issues, or succeeds with the parse result.
591
+ */
592
+ interface IcsParser<TExtensions extends IcsExtensionsConfig = {}> extends StandardSchemaV1<string, IcsParseResult<TExtensions>> {
593
+ parse(text: string): IcsParseResult<TExtensions>;
594
+ }
595
+ //#endregion
596
+ //#region src/model/event-end.d.ts
597
+ /**
598
+ * The event's effective end: DTEND, else DTSTART + DURATION, else RFC 5545's default (the next day
599
+ * for a date, the start itself for a date-time). Always the same kind as the start: a DTEND of
600
+ * another kind is converted, keeping its instant where both have one, else its wall time.
601
+ *
602
+ * DURATION on a zoned start adds days as calendar days and hours as exact time (RFC 5545 §3.3.6).
603
+ * On a date start it adds whole days: a time part, which RFC 5545 doesn't allow there, rounds up
604
+ * to whole days, so the end covers it (`PT1H` ends the next day).
605
+ */
606
+ export declare function getEventEnd(event: Pick<IcsEvent, "duration" | "end" | "start">): IcsDateValue;
607
+ //#endregion
608
+ //#region src/values/result.d.ts
609
+ interface IcsValueContext {
610
+ /**
611
+ * Resolves a TZID to an IANA time zone id, or `undefined`. Without it, a TZID resolves only when
612
+ * it is itself a time zone id Temporal knows.
613
+ */
614
+ readonly resolveTimeZone?: (tzid: string) => string | undefined;
615
+ /** The property's TZID parameter. */
616
+ readonly tzid?: string;
617
+ }
618
+ /** A deviation a decoder tolerated; the decoded value is its best reading. */
619
+ interface IcsValueWarning {
620
+ /** The code `parseIcs` reports it under, such as `invalid-value` or `unsupported`. */
621
+ readonly code: IcsIssueCode;
622
+ readonly message: string;
623
+ }
624
+ type IcsDecodeResult<T> = {
625
+ readonly ok: false;
626
+ readonly message: string;
627
+ } | {
628
+ readonly ok: true;
629
+ readonly value: T;
630
+ /** Absent when the value decoded cleanly. */
631
+ readonly warnings?: readonly IcsValueWarning[];
632
+ };
633
+ //#endregion
634
+ //#region src/values/registry.d.ts
635
+ /** The property's value type: its VALUE parameter, else its registered default, else TEXT. */
636
+ export declare function icsValueTypeOf(property: IcsProperty): IcsValueType;
637
+ //#endregion
638
+ //#region src/values/index.d.ts
639
+ /**
640
+ * Decodes one raw value as `type`. It doesn't split lists: use `decodeIcsValues` for a property
641
+ * such as CATEGORIES or EXDATE. Never throws: a value that doesn't parse is `{ ok: false }`, and
642
+ * one read leniently carries `warnings`.
643
+ */
644
+ export declare function decodeIcsValue<TType extends IcsValueType>(type: TType, raw: string, context?: IcsValueContext): IcsDecodeResult<IcsDecodedValueMap[TType]>;
645
+ /**
646
+ * The items of a list value, such as CATEGORIES or EXDATE, as raw text: split on separating
647
+ * commas, TEXT escapes left in place, so `a\,b,c` gives `a\,b` and `c`. RECUR, whose parts hold
648
+ * commas, is never split.
649
+ */
650
+ export declare function splitIcsValues(type: IcsValueType, raw: string): string[];
651
+ /**
652
+ * Splits a list value on its separating commas and decodes each item as `type`: one result per
653
+ * item, in order, so one bad item doesn't lose the others.
654
+ */
655
+ export declare function decodeIcsValues<TType extends IcsValueType>(type: TType, raw: string, context?: IcsValueContext): IcsDecodeResult<IcsDecodedValueMap[TType]>[];
656
+ /**
657
+ * Decodes a DATE or DATE-TIME by its shape, so a date written without `VALUE=DATE` still decodes
658
+ * (with a warning). `declared` is the property's value type, as `icsValueTypeOf` gives it. Use it
659
+ * for DTSTART, DTEND, DUE, RECURRENCE-ID and each item of EXDATE or RDATE.
660
+ */
661
+ export declare function decodeIcsDateValue(raw: string, declared: "DATE" | "DATE-TIME", context?: IcsValueContext): IcsDecodeResult<IcsDateValue>;
662
+ /**
663
+ * Encodes one value as raw property text. Zoned and unresolved DATE-TIMEs are written as their wall
664
+ * time; writing the TZID parameter is the caller's job.
665
+ */
666
+ export declare function encodeIcsValue<TType extends IcsValueType>(type: TType, value: IcsDecodedValueMap[TType]): string;
667
+ //#endregion
668
+ //#region src/model/extensions.d.ts
669
+ /**
670
+ * Whether a schema whose input type is `TInput` can take `TValue`: an `unknown` input, a wider
671
+ * one, or one that overlaps it, such as a union of string literals for a TEXT value.
672
+ */
673
+ type IcsSchemaAccepts<TInput, TValue> = unknown extends TInput ? true : [TValue] extends [TInput] ? true : [Extract<TInput, TValue> | Extract<TValue, TInput>] extends [never] ? false : true;
674
+ /**
675
+ * The schema itself when it can take the decoded value; otherwise a schema of the input it would
676
+ * need, so the call fails to type-check.
677
+ */
678
+ type IcsCheckedSchema<TType extends IcsValueType, TSchema> = TSchema extends StandardSchemaV1 ? IcsSchemaAccepts<StandardSchemaV1.InferInput<TSchema>, IcsExtensionInput<TType>> extends true ? TSchema : StandardSchemaV1<IcsExtensionInput<TType>, StandardSchemaV1.InferOutput<TSchema>> : TSchema;
679
+ interface IcsExtensionOptions<TType extends IcsValueType, TSchema extends StandardSchemaV1 | undefined, TMultiple extends boolean> {
680
+ /** Collect every occurrence, and every comma-separated value, into an array. Default `false`. */
681
+ readonly multiple?: TMultiple;
682
+ /**
683
+ * A Standard Schema (Zod, Valibot, ArkType…) applied to each decoded value. Its input type must
684
+ * accept the decoded value: `unknown`, the decoded type, or a narrower one.
685
+ */
686
+ readonly schema?: TSchema & NoInfer<IcsCheckedSchema<TType, TSchema>>;
687
+ /** How to decode the raw value. Default `TEXT`. */
688
+ readonly type?: TType;
689
+ }
690
+ type IcsExtensionItem<TType extends IcsValueType, TSchema extends StandardSchemaV1 | undefined> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : IcsExtensionInput<TType>;
691
+ type IcsExtensionOutput<TType extends IcsValueType, TSchema extends StandardSchemaV1 | undefined, TMultiple extends boolean> = TMultiple extends true ? readonly IcsExtensionItem<TType, TSchema>[] : IcsExtensionItem<TType, TSchema> | undefined;
692
+ /** Declares a typed extension property, such as `X-RESOURCE-ID`, for `IcsParseOptions.extensions`. */
693
+ export declare function icsExtension<TType extends IcsValueType = "TEXT", TSchema extends StandardSchemaV1 | undefined = undefined, TMultiple extends boolean = false>(name: string, options?: IcsExtensionOptions<TType, TSchema, TMultiple>): IcsExtension<IcsExtensionOutput<TType, TSchema, TMultiple>>;
694
+ //#endregion
695
+ //#region src/model/parser.d.ts
696
+ /** Builds a reusable parser. The parser is also a Standard Schema for ICS text. */
697
+ export declare function createIcsParser<TExtensions extends IcsExtensionsConfig = {}>(options?: IcsParseOptions<TExtensions>): IcsParser<TExtensions>;
698
+ /** Parses iCalendar text into typed calendars. */
699
+ export declare function parseIcs<TExtensions extends IcsExtensionsConfig = {}>(text: string, options?: IcsParseOptions<TExtensions>): IcsParseResult<TExtensions>;
700
+ //#endregion
701
+ //#region src/issues.d.ts
702
+ /** Thrown by a strict parser when it finds error-severity issues. */
703
+ export declare class IcsParseError extends Error {
704
+ readonly issues: readonly IcsIssue[];
705
+ constructor(issues: readonly IcsIssue[]);
706
+ }
707
+ //#endregion
708
+ //#region src/syntax/index.d.ts
709
+ interface IcsComponentsResult {
710
+ /** Top-level components, normally VCALENDARs. */
711
+ readonly components: readonly IcsComponent[];
712
+ readonly issues: readonly IcsIssue[];
713
+ }
714
+ /** Splits iCalendar text into a lossless component tree, collecting syntax issues. */
715
+ export declare function parseIcsComponents(text: string): IcsComponentsResult;
716
+ /**
717
+ * Writes components back as iCalendar text: CRLF line ends, folded at 75 octets. Parameter values
718
+ * are RFC 6868-encoded, so they may hold line breaks; values are written as they are.
719
+ *
720
+ * @throws {RangeError} When a component name, property name, parameter name or property value
721
+ * contains CR or LF, which would end the content line. The message names the property. Escape
722
+ * line breaks in TEXT values as `\n` first.
723
+ */
724
+ export declare function stringifyIcsComponents(components: IcsComponent | readonly IcsComponent[]): string;
725
+ //#endregion
726
+ export type { IcsAlarm, IcsAlarmTrigger, IcsAttachment, IcsAttendee, IcsCalendar, IcsCalendarUser, IcsClassification, IcsComponent, IcsComponentsResult, IcsConference, IcsDate, IcsDateTime, IcsDateValue, IcsDecodeResult, IcsDecodedValueMap, IcsEvent, IcsEventStatus, IcsExtension, IcsExtensionInput, IcsExtensionMap, IcsExtensionOptions, IcsExtensionOutput, IcsExtensionValues, IcsExtensionsConfig, IcsFloatingDateTime, IcsFreeBusy, IcsFreeBusyPeriods, IcsFrequency, IcsGeo, IcsIssue, IcsIssueCode, IcsIssueSeverity, IcsJournal, IcsJournalStatus, IcsOpen, IcsParameters, IcsParseOptions, IcsParseResult, IcsParser, IcsPeriod, IcsProperty, IcsRecurrenceRule, IcsRelation, IcsSchedulingFields, IcsTime, IcsTimeZone, IcsTimeZoneObservance, IcsTimeZoneResolver, IcsTodo, IcsTodoStatus, IcsTransparency, IcsUnresolvedDateTime, IcsUtcDateTime, IcsUtcOffset, IcsValueContext, IcsValueType, IcsValueWarning, IcsWeekday, IcsWeekdayNumber, IcsZonedDateTime, StandardSchemaV1, StandardTypedV1 };