iamcal 1.0.2 → 1.1.0

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.
package/README.md CHANGED
@@ -10,9 +10,11 @@ A library for reading, modifying and writing [ICalendar](https://en.wikipedia.or
10
10
  npm install iamcal
11
11
  ```
12
12
 
13
- ## Getting started/Example
13
+ ## Getting started
14
14
 
15
- This code;
15
+ ### Parsing and editing a calendar
16
+
17
+ This code:
16
18
 
17
19
  ```typescript
18
20
  import { Calendar } from 'iamcal'
@@ -58,4 +60,6 @@ DTSTART:20241211T200000Z
58
60
  DTEND:20241211T230000Z
59
61
  END:VEVENT
60
62
  END:VCALENDAR
61
- ```
63
+ ```
64
+
65
+ ### Creating a new calendar
package/lib/index.d.ts CHANGED
@@ -1,36 +1,150 @@
1
- export interface Property {
2
- name: string;
3
- params: string[];
4
- value: string;
5
- }
1
+ import { Property } from './types';
6
2
  export declare class Component {
7
3
  name: string;
8
- properties: Array<Property>;
9
- components: Array<Component>;
10
- constructor(name: string, properties?: Array<Property>, components?: Array<Component>);
4
+ properties: Property[];
5
+ components: Component[];
6
+ constructor(name: string, properties?: Property[], components?: Component[]);
11
7
  serialize(): string;
12
8
  getProperty(name: string): Property | null;
13
- setProperty(name: string, value: string): void;
9
+ setProperty(name: string, value: string): this;
10
+ removePropertiesWithName(name: string): this | undefined;
14
11
  getPropertyParams(name: string): string[] | null;
15
- setPropertyParams(name: string, params: string[]): void;
12
+ setPropertyParams(name: string, params: string[]): this;
13
+ addComponent(component: Component): this;
14
+ /**
15
+ * Remove a component from this component
16
+ * @returns `true` if the component was removed. `false` if the component was not present
17
+ */
18
+ removeComponent(component: Component): boolean;
19
+ getComponents(name: string): Component[];
16
20
  }
21
+ /**
22
+ * Represents a VCALENDAR component, the root component of an iCalendar file.
23
+ */
17
24
  export declare class Calendar extends Component {
18
25
  name: string;
26
+ /**
27
+ * @param prodid A unique identifier of the program creating the calendar.
28
+ *
29
+ * Example: `-//Google Inc//Google Calendar 70.9054//EN`
30
+ */
31
+ constructor(prodid: string);
32
+ /**
33
+ * @param prodid A unique identifier of the program creating the calendar.
34
+ *
35
+ * Example: `-//Google Inc//Google Calendar 70.9054//EN`
36
+ * @param version The version of the iCalendar specification that this calendar uses.
37
+ */
38
+ constructor(prodid: string, version: string);
39
+ /**
40
+ * @param component A VCALENDAR component.
41
+ */
42
+ constructor(component: Component);
43
+ events(): CalendarEvent[];
44
+ removeEvent(event: CalendarEvent): boolean;
45
+ removeEvent(uid: string): boolean;
46
+ prodId(): string;
47
+ setProdId(value: string): this;
48
+ version(): string;
49
+ setVersion(value: string): this;
50
+ calScale(): string | undefined;
51
+ setCalScale(value: string): this;
52
+ removeCalScale(): void;
53
+ method(): string | undefined;
54
+ setMethod(value: string): void;
55
+ removeMethod(): void;
56
+ calendarName(): string | undefined;
57
+ setCalendarName(value: string): void;
58
+ removeCalendarName(): void;
59
+ calendarDescription(): string | undefined;
60
+ setCalendarDescription(value: string): this;
61
+ removeCalendarDescription(): void;
62
+ }
63
+ /**
64
+ * Represents a VTIMEZONE component, containing time zone definitions.
65
+ */
66
+ export declare class TimeZone extends Component {
67
+ constructor(id: string);
19
68
  constructor(component: Component);
20
- events(): Array<CalendarEvent>;
69
+ id(): string;
70
+ setId(value: string): this;
71
+ lastMod(): Date | undefined;
72
+ setLastMod(value: Date): this;
73
+ removeLastMod(): void;
74
+ url(): string | undefined;
75
+ setUrl(value: string): this;
76
+ removeUrl(): void;
77
+ /** Get all time offsets. */
78
+ offsets(): TimeZoneOffset[];
79
+ /** Get standard/winter time offsets. */
80
+ standardOffsets(): TimeZoneOffset[];
81
+ /** Get daylight savings time offsets. */
82
+ daylightOffsets(): TimeZoneOffset[];
83
+ }
84
+ export type OffsetType = 'DAYLIGHT' | 'STANDARD';
85
+ type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
86
+ export type Offset = `${'-' | '+'}${Digit}${Digit}${Digit}${Digit}`;
87
+ /** Represents a STANDARD or DAYLIGHT component, defining a time zone offset. */
88
+ declare class TimeZoneOffset extends Component {
89
+ /**
90
+ *
91
+ * @param type If this is a STANDARD or DAYLIGHT component.
92
+ * @param start From when this offset is active.
93
+ * @param offsetFrom The offset that is in use prior to this time zone observance.
94
+ * @param offsetTo The offset that is in use during this time zone observance.
95
+ */
96
+ constructor(type: OffsetType, start: Date, offsetFrom: Offset, offsetTo: Offset);
97
+ constructor(component: Component);
98
+ start(): Date;
99
+ setStart(value: Date, fullDay?: boolean): this;
100
+ offsetFrom(): Offset;
101
+ setOffsetFrom(value: Offset): this;
102
+ offsetTo(): Offset;
103
+ setOffsetTo(value: Offset): this;
104
+ comment(): string | undefined;
105
+ setComment(value: string): this;
106
+ removeComment(): void;
107
+ timeZoneName(): string | undefined;
108
+ setTimeZoneName(value: string): this;
109
+ removeTimeZoneName(): void;
21
110
  }
22
111
  export declare class CalendarEvent extends Component {
23
112
  name: string;
113
+ constructor(uid: string, dtstamp: Date);
24
114
  constructor(component: Component);
115
+ stamp(): Date;
116
+ setStamp(value: Date, fullDay?: boolean): this;
117
+ uid(): string;
118
+ setUid(value: string): this;
25
119
  summary(): string;
26
- setSummary(value: string): void;
120
+ setSummary(value: string): this;
121
+ removeSummary(): void;
27
122
  description(): string;
28
- setDescription(value: string): void;
123
+ setDescription(value: string): this;
124
+ removeDescription(): void;
29
125
  location(): string | undefined;
30
- setLocation(value: string): void;
126
+ setLocation(value: string): this;
127
+ removeLocation(): void;
128
+ /**
129
+ * Get the start of the event.
130
+ * If set as a full day the time will be at the start of the day.
131
+ */
31
132
  start(): Date;
32
- setStart(value: Date): void;
133
+ setStart(value: Date, fullDay?: boolean): this;
134
+ removeStart(): void;
135
+ /**
136
+ * Get the end of the event.
137
+ * If set as a full day the time will be at the end of the day.
138
+ */
33
139
  end(): Date;
34
- setEnd(value: Date): void;
140
+ setEnd(value: Date, fullDay?: boolean): this;
141
+ removeEnd(): void;
142
+ created(): Date | undefined;
143
+ setCreated(value: Date): this;
144
+ removeCreated(): void;
145
+ geo(): [number, number] | undefined;
146
+ setGeo(latitude: number, longitude: number): this;
147
+ removeGeo(): void;
35
148
  }
149
+ export {};
36
150
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CAChB;AAKD,qBAAa,SAAS;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC3B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;gBAEhB,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAcrF,SAAS,IAAI,MAAM;IA+BnB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI;IAS1C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAcvC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAShD,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAOnD;AAED,qBAAa,QAAS,SAAQ,SAAS;IACnC,IAAI,SAAc;gBAEN,SAAS,EAAE,SAAS;IAIhC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC;CAWjC;AAED,qBAAa,aAAc,SAAQ,SAAS;IACxC,IAAI,SAAW;gBAEH,SAAS,EAAE,SAAS;IAIhC,OAAO,IAAI,MAAM;IAIjB,UAAU,CAAC,KAAK,EAAE,MAAM;IAIxB,WAAW,IAAI,MAAM;IAIrB,cAAc,CAAC,KAAK,EAAE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