ical-generator 6.0.2-develop.5 → 6.0.2-develop.7

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/package.json CHANGED
@@ -16,8 +16,8 @@
16
16
  "@touch4it/ical-timezones": "^1.9.0",
17
17
  "@types/luxon": "^3.4.2",
18
18
  "@types/mocha": "^10.0.6",
19
- "@typescript-eslint/eslint-plugin": "^6.18.1",
20
- "@typescript-eslint/parser": "^6.18.1",
19
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
20
+ "@typescript-eslint/parser": "^6.21.0",
21
21
  "c8": "^9.1.0",
22
22
  "dayjs": "^1.11.10",
23
23
  "eslint": "^8.56.0",
@@ -28,7 +28,7 @@
28
28
  "mocha": "^10.2.0",
29
29
  "mochawesome": "^7.1.3",
30
30
  "moment": "^2.30.1",
31
- "moment-timezone": "^0.5.44",
31
+ "moment-timezone": "^0.5.45",
32
32
  "nyc": "^15.1.0",
33
33
  "rrule": "^2.8.1",
34
34
  "semantic-release": "^23.0.0",
@@ -125,5 +125,5 @@
125
125
  "test": "mocha"
126
126
  },
127
127
  "type": "module",
128
- "version": "6.0.2-develop.5"
128
+ "version": "6.0.2-develop.7"
129
129
  }
package/src/calendar.ts CHANGED
@@ -89,7 +89,7 @@ export default class ICalCalendar {
89
89
  private readonly data: ICalCalendarInternalData;
90
90
 
91
91
  /**
92
- * You can pass options to setup your calendar or use setters to do this.
92
+ * You can pass options to set up your calendar or use setters to do this.
93
93
  *
94
94
  * ```javascript
95
95
  * * import ical from 'ical-generator';
@@ -110,6 +110,16 @@ export default class ICalCalendar {
110
110
  * cal.name('sebbo.net');
111
111
  * ```
112
112
  *
113
+ * `cal.toString()` would then produce the following string:
114
+ * ```text
115
+ * BEGIN:VCALENDAR
116
+ * VERSION:2.0
117
+ * PRODID:-//sebbo.net//ical-generator//EN
118
+ * NAME:sebbo.net
119
+ * X-WR-CALNAME:sebbo.net
120
+ * END:VCALENDAR
121
+ * ```
122
+ *
113
123
  * @param data Calendar data
114
124
  */
115
125
  constructor(data: ICalCalendarData = {}) {
@@ -161,6 +171,11 @@ export default class ICalCalendar {
161
171
  * });
162
172
  * ```
163
173
  *
174
+ * `cal.toString()` would then produce the following string:
175
+ * ```text
176
+ * PRODID:-//My Company//My Product//EN
177
+ * ```
178
+ *
164
179
  * @since 0.2.0
165
180
  */
166
181
  prodId(prodId: ICalCalendarProdIdData | string): this;
@@ -206,6 +221,8 @@ export default class ICalCalendar {
206
221
  * #### Typescript Example
207
222
  * ```typescript
208
223
  * import {ICalCalendarMethod} from 'ical-generator';
224
+ *
225
+ * // METHOD:PUBLISH
209
226
  * calendar.method(ICalCalendarMethod.PUBLISH);
210
227
  * ```
211
228
  *
@@ -236,6 +253,24 @@ export default class ICalCalendar {
236
253
  * Set your feed's name. Is used to fill `NAME`
237
254
  * and `X-WR-CALNAME` in your iCal file.
238
255
  *
256
+ * ```typescript
257
+ * import ical from 'ical-generator';
258
+ *
259
+ * const cal = ical();
260
+ * cal.name('Next Arrivals');
261
+ *
262
+ * cal.toString();
263
+ * ```
264
+ *
265
+ * ```text
266
+ * BEGIN:VCALENDAR
267
+ * VERSION:2.0
268
+ * PRODID:-//sebbo.net//ical-generator//EN
269
+ * NAME:Next Arrivals
270
+ * X-WR-CALNAME:Next Arrivals
271
+ * END:VCALENDAR
272
+ * ```
273
+ *
239
274
  * @since 0.2.0
240
275
  */
241
276
  name(name: string | null): this;
@@ -312,7 +347,7 @@ export default class ICalCalendar {
312
347
  * import ical from 'ical-generator';
313
348
  * import {getVtimezoneComponent} from '@touch4it/ical-timezones';
314
349
  *
315
- * const cal = new ICalCalendar();
350
+ * const cal = ical();
316
351
  * cal.timezone({
317
352
  * name: 'FOO',
318
353
  * generator: getVtimezoneComponent
@@ -363,6 +398,10 @@ export default class ICalCalendar {
363
398
  * cal.source('http://example.com/my/original_source.ical');
364
399
  * ```
365
400
  *
401
+ * ```text
402
+ * SOURCE;VALUE=URI:http://example.com/my/original_source.ical
403
+ * ```
404
+ *
366
405
  * @since 2.2.0-develop.1
367
406
  */
368
407
  source(source: string | null): this;
@@ -595,6 +634,14 @@ export default class ICalCalendar {
595
634
  * });
596
635
  * ```
597
636
  *
637
+ * ```text
638
+ * BEGIN:VCALENDAR
639
+ * VERSION:2.0
640
+ * PRODID:-//sebbo.net//ical-generator//EN
641
+ * X-MY-CUSTOM-ATTR:1337!
642
+ * END:VCALENDAR
643
+ * ```
644
+ *
598
645
  * @since 1.9.0
599
646
  */
600
647
  x (keyOrArray: {key: string, value: string}[] | [string, string][] | Record<string, string>): this;
@@ -608,6 +655,14 @@ export default class ICalCalendar {
608
655
  * calendar.x("X-MY-CUSTOM-ATTR", "1337!");
609
656
  * ```
610
657
  *
658
+ * ```text
659
+ * BEGIN:VCALENDAR
660
+ * VERSION:2.0
661
+ * PRODID:-//sebbo.net//ical-generator//EN
662
+ * X-MY-CUSTOM-ATTR:1337!
663
+ * END:VCALENDAR
664
+ * ```
665
+ *
611
666
  * @since 1.9.0
612
667
  */
613
668
  x (keyOrArray: string, value: string): this;
package/src/event.ts CHANGED
@@ -326,6 +326,35 @@ export default class ICalEvent {
326
326
  * [Readme](https://github.com/sebbo2002/ical-generator#-date-time--timezones)
327
327
  * for details about supported values and timezone handling.
328
328
  *
329
+ * ```typescript
330
+ * import ical from 'ical-generator';
331
+ *
332
+ * const cal = ical();
333
+ *
334
+ * const event = cal.createEvent({
335
+ * start: new Date('2020-01-01')
336
+ * });
337
+ *
338
+ * // overwrites old start date
339
+ * event.start(new Date('2024-02-01'));
340
+ *
341
+ * cal.toString();
342
+ * ```
343
+ *
344
+ * ```text
345
+ * BEGIN:VCALENDAR
346
+ * VERSION:2.0
347
+ * PRODID:-//sebbo.net//ical-generator//EN
348
+ * BEGIN:VEVENT
349
+ * UID:7e2aee64-b07a-4256-9b3e-e9eaa452bac8
350
+ * SEQUENCE:0
351
+ * DTSTAMP:20240212T190915Z
352
+ * DTSTART:20240201T000000Z
353
+ * SUMMARY:
354
+ * END:VEVENT
355
+ * END:VCALENDAR
356
+ * ```
357
+ *
329
358
  * @since 0.2.0
330
359
  */
331
360
  start(start: ICalDateTimeValue): this;
@@ -513,6 +542,36 @@ export default class ICalEvent {
513
542
  * event.allDay(true); // → appointment is for the whole day
514
543
  * ```
515
544
  *
545
+ * ```typescript
546
+ * import ical from 'ical-generator';
547
+ *
548
+ * const cal = ical();
549
+ *
550
+ * cal.createEvent({
551
+ * start: new Date('2020-01-01'),
552
+ * summary: 'Very Important Day',
553
+ * allDay: true
554
+ * });
555
+ *
556
+ * cal.toString();
557
+ * ```
558
+ *
559
+ * ```text
560
+ * BEGIN:VCALENDAR
561
+ * VERSION:2.0
562
+ * PRODID:-//sebbo.net//ical-generator//EN
563
+ * BEGIN:VEVENT
564
+ * UID:1964fe8d-32c5-4f2a-bd62-7d9d7de5992b
565
+ * SEQUENCE:0
566
+ * DTSTAMP:20240212T191956Z
567
+ * DTSTART;VALUE=DATE:20200101
568
+ * X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
569
+ * X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE
570
+ * SUMMARY:Very Important Day
571
+ * END:VEVENT
572
+ * END:VCALENDAR
573
+ * ```
574
+ *
516
575
  * @since 0.2.0
517
576
  */
518
577
  allDay(allDay: boolean): this;
@@ -537,6 +596,34 @@ export default class ICalEvent {
537
596
  * Events whose floating flag is set to true always take place at the
538
597
  * same time, regardless of the time zone.
539
598
  *
599
+ * ```typescript
600
+ * import ical from 'ical-generator';
601
+ *
602
+ * const cal = ical();
603
+ *
604
+ * cal.createEvent({
605
+ * start: new Date('2020-01-01T20:00:00Z'),
606
+ * summary: 'Always at 20:00 in every <Timezone',
607
+ * floating: true
608
+ * });
609
+ *
610
+ * cal.toString();
611
+ * ```
612
+ *
613
+ * ```text
614
+ * BEGIN:VCALENDAR
615
+ * VERSION:2.0
616
+ * PRODID:-//sebbo.net//ical-generator//EN
617
+ * BEGIN:VEVENT
618
+ * UID:5d7278f9-ada3-40ef-83d1-23c29ce0a763
619
+ * SEQUENCE:0
620
+ * DTSTAMP:20240212T192214Z
621
+ * DTSTART:20200101T200000
622
+ * SUMMARY:Always at 20:00 in every <Timezone
623
+ * END:VEVENT
624
+ * END:VCALENDAR
625
+ * ```
626
+ *
540
627
  * @since 0.2.0
541
628
  */
542
629
  floating(floating?: boolean): this | boolean {
@@ -577,6 +664,40 @@ export default class ICalEvent {
577
664
  * });
578
665
  * ```
579
666
  *
667
+ * **Example:**
668
+ *
669
+ *```typescript
670
+ * import ical, { ICalEventRepeatingFreq } from 'ical-generator';
671
+ *
672
+ * const cal = ical();
673
+ *
674
+ * const event = cal.createEvent({
675
+ * start: new Date('2020-01-01T20:00:00Z'),
676
+ * summary: 'Repeating Event'
677
+ * });
678
+ * event.repeating({
679
+ * freq: ICalEventRepeatingFreq.WEEKLY,
680
+ * count: 4
681
+ * });
682
+ *
683
+ * cal.toString();
684
+ * ```
685
+ *
686
+ * ```text
687
+ * BEGIN:VCALENDAR
688
+ * VERSION:2.0
689
+ * PRODID:-//sebbo.net//ical-generator//EN
690
+ * BEGIN:VEVENT
691
+ * UID:b80e6a68-c2cd-48f5-b94d-cecc7ce83871
692
+ * SEQUENCE:0
693
+ * DTSTAMP:20240212T193646Z
694
+ * DTSTART:20200101T200000Z
695
+ * RRULE:FREQ=WEEKLY;COUNT=4
696
+ * SUMMARY:Repeating Event
697
+ * END:VEVENT
698
+ * END:VCALENDAR
699
+ * ```
700
+ *
580
701
  * @since 0.2.0
581
702
  */
582
703
  repeating(repeating: ICalRepeatingOptions | null): this;
@@ -584,6 +705,44 @@ export default class ICalEvent {
584
705
  /**
585
706
  * Set the event's repeating options by passing an [RRule object](https://github.com/jakubroztocil/rrule).
586
707
  * @since 2.0.0-develop.5
708
+ *
709
+ * ```typescript
710
+ * import ical from 'ical-generator';
711
+ * import { datetime, RRule } from 'rrule';
712
+ *
713
+ * const cal = ical();
714
+ *
715
+ * const event = cal.createEvent({
716
+ * start: new Date('2020-01-01T20:00:00Z'),
717
+ * summary: 'Repeating Event'
718
+ * });
719
+ *
720
+ * const rule = new RRule({
721
+ * freq: RRule.WEEKLY,
722
+ * interval: 5,
723
+ * byweekday: [RRule.MO, RRule.FR],
724
+ * dtstart: datetime(2012, 2, 1, 10, 30),
725
+ * until: datetime(2012, 12, 31)
726
+ * })
727
+ * event.repeating(rule);
728
+ *
729
+ * cal.toString();
730
+ * ```
731
+ *
732
+ * ```text
733
+ * BEGIN:VCALENDAR
734
+ * VERSION:2.0
735
+ * PRODID:-//sebbo.net//ical-generator//EN
736
+ * BEGIN:VEVENT
737
+ * UID:36585e40-8fa8-460d-af0c-88b6f434030b
738
+ * SEQUENCE:0
739
+ * DTSTAMP:20240212T193827Z
740
+ * DTSTART:20200101T200000Z
741
+ * RRULE:FREQ=WEEKLY;INTERVAL=5;BYDAY=MO,FR;UNTIL=20121231T000000Z
742
+ * SUMMARY:Repeating Event
743
+ * END:VEVENT
744
+ * END:VCALENDAR
745
+ * ```
587
746
  */
588
747
  repeating(repeating: ICalRRuleStub | null): this;
589
748
 
@@ -736,6 +895,15 @@ export default class ICalEvent {
736
895
  * });
737
896
  * ```
738
897
  *
898
+ * ```text
899
+ * LOCATION:Apple Store Kurfürstendamm\nKurfürstendamm 26\, 10719 Berlin\,
900
+ * Deutschland
901
+ * X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=Kurfürstendamm 26\, 10719
902
+ * Berlin\, Deutschland;X-APPLE-RADIUS=141.1751386318387;X-TITLE=Apple Store
903
+ * Kurfürstendamm:geo:52.50363,13.32865
904
+ * GEO:52.50363;13.32865
905
+ * ```
906
+ *
739
907
  * @since 0.2.0
740
908
  */
741
909
  location(location: ICalLocation | string | null): this;
@@ -778,11 +946,16 @@ export default class ICalEvent {
778
946
  *
779
947
  * ```javascript
780
948
  * event.description({
781
- * plain: 'Hello World!';
782
- * html: '<p>Hello World!</p>';
949
+ * plain: 'Hello World!',
950
+ * html: '<p>Hello World!</p>'
783
951
  * });
784
952
  * ```
785
953
  *
954
+ * ```text
955
+ * DESCRIPTION:Hello World!
956
+ * X-ALT-DESC;FMTTYPE=text/html:<p>Hello World!</p>
957
+ * ```
958
+ *
786
959
  * @since 0.2.0
787
960
  */
788
961
  description(description: ICalDescription | string | null): this;
@@ -859,14 +1032,35 @@ export default class ICalEvent {
859
1032
  * an empty attendee.
860
1033
  *
861
1034
  * ```javascript
1035
+ * import ical from 'ical-generator';
1036
+ *
862
1037
  * const cal = ical();
863
- * const event = cal.createEvent();
864
- * const attendee = event.createAttendee({email: 'hui@example.com', name: 'Hui'});
1038
+ * const event = cal.createEvent({
1039
+ * start: new Date()
1040
+ * });
1041
+ *
1042
+ * event.createAttendee({email: 'hui@example.com', name: 'Hui'});
865
1043
  *
866
1044
  * // add another attendee
867
1045
  * event.createAttendee('Buh <buh@example.net>');
868
1046
  * ```
869
1047
  *
1048
+ * ```text
1049
+ * BEGIN:VCALENDAR
1050
+ * VERSION:2.0
1051
+ * PRODID:-//sebbo.net//ical-generator//EN
1052
+ * BEGIN:VEVENT
1053
+ * UID:b4944f07-98e4-4581-ac80-2589bb20273d
1054
+ * SEQUENCE:0
1055
+ * DTSTAMP:20240212T194232Z
1056
+ * DTSTART:20240212T194232Z
1057
+ * SUMMARY:
1058
+ * ATTENDEE;ROLE=REQ-PARTICIPANT;CN="Hui":MAILTO:hui@example.com
1059
+ * ATTENDEE;ROLE=REQ-PARTICIPANT;CN="Buh":MAILTO:buh@example.net
1060
+ * END:VEVENT
1061
+ * END:VCALENDAR
1062
+ * ```
1063
+ *
870
1064
  * As with the organizer, you can also add an explicit `mailto` address.
871
1065
  *
872
1066
  * ```javascript