ical-generator 3.6.2-develop.3 → 4.0.0-develop.1

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.
@@ -1,490 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import ICalEvent, { ICalEventData, ICalEventJSONData } from './event';
4
- import { ServerResponse } from 'http';
5
- import { ICalMomentDurationStub, ICalTimezone } from './types';
6
- export interface ICalCalendarData {
7
- prodId?: ICalCalendarProdIdData | string;
8
- method?: ICalCalendarMethod | null;
9
- name?: string | null;
10
- description?: string | null;
11
- timezone?: ICalTimezone | string | null;
12
- source?: string | null;
13
- url?: string | null;
14
- scale?: string | null;
15
- ttl?: number | ICalMomentDurationStub | null;
16
- events?: (ICalEvent | ICalEventData)[];
17
- x?: {
18
- key: string;
19
- value: string;
20
- }[] | [string, string][] | Record<string, string>;
21
- }
22
- export interface ICalCalendarJSONData {
23
- prodId: string;
24
- method: ICalCalendarMethod | null;
25
- name: string | null;
26
- description: string | null;
27
- timezone: string | null;
28
- source: string | null;
29
- url: string | null;
30
- scale: string | null;
31
- ttl: number | null;
32
- events: ICalEventJSONData[];
33
- x: {
34
- key: string;
35
- value: string;
36
- }[];
37
- }
38
- export interface ICalCalendarProdIdData {
39
- company: string;
40
- product: string;
41
- language?: string;
42
- }
43
- export declare enum ICalCalendarMethod {
44
- PUBLISH = "PUBLISH",
45
- REQUEST = "REQUEST",
46
- REPLY = "REPLY",
47
- ADD = "ADD",
48
- CANCEL = "CANCEL",
49
- REFRESH = "REFRESH",
50
- COUNTER = "COUNTER",
51
- DECLINECOUNTER = "DECLINECOUNTER"
52
- }
53
- /**
54
- * Usually you get an `ICalCalendar` object like this:
55
- * ```javascript
56
- * import ical from 'ical-generator';
57
- * const calendar = ical();
58
- * ```
59
- *
60
- * But you can also use the constructor directly like this:
61
- * ```javascript
62
- * import {ICalCalendar} from 'ical-generator';
63
- * const calendar = new ICalCalendar();
64
- * ```
65
- */
66
- export default class ICalCalendar {
67
- private readonly data;
68
- /**
69
- * You can pass options to setup your calendar or use setters to do this.
70
- *
71
- * ```javascript
72
- * * import ical from 'ical-generator';
73
- *
74
- * // or use require:
75
- * // const ical = require('ical-generator');
76
- *
77
- *
78
- * const cal = ical({name: 'my first iCal'});
79
- *
80
- * // is the same as
81
- *
82
- * const cal = ical().name('my first iCal');
83
- *
84
- * // is the same as
85
- *
86
- * const cal = ical();
87
- * cal.name('sebbo.net');
88
- * ```
89
- *
90
- * @param data Calendar data
91
- */
92
- constructor(data?: ICalCalendarData);
93
- /**
94
- * Get your feed's prodid. Will always return a string.
95
- * @since 0.2.0
96
- */
97
- prodId(): string;
98
- /**
99
- * Set your feed's prodid. `prodid` can be either a
100
- * string like `//sebbo.net//ical-generator//EN` or a
101
- * valid [[`ICalCalendarProdIdData`]] object. `language`
102
- * is optional and defaults to `EN`.
103
- *
104
- * ```javascript
105
- * cal.prodId({
106
- * company: 'My Company',
107
- * product: 'My Product',
108
- * language: 'EN' // optional, defaults to EN
109
- * });
110
- * ```
111
- *
112
- * @since 0.2.0
113
- */
114
- prodId(prodId: ICalCalendarProdIdData | string): this;
115
- /**
116
- * Get the feed method attribute.
117
- * See [[`ICalCalendarMethod`]] for possible results.
118
- *
119
- * @since 0.2.8
120
- */
121
- method(): ICalCalendarMethod | null;
122
- /**
123
- * Set the feed method attribute.
124
- * See [[`ICalCalendarMethod`]] for available options.
125
- *
126
- * #### Typescript Example
127
- * ```typescript
128
- * import {ICalCalendarMethod} from 'ical-generator';
129
- * calendar.method(ICalCalendarMethod.PUBLISH);
130
- * ```
131
- *
132
- * @since 0.2.8
133
- */
134
- method(method: ICalCalendarMethod | null): this;
135
- /**
136
- * Get your feed's name
137
- * @since 0.2.0
138
- */
139
- name(): string | null;
140
- /**
141
- * Set your feed's name. Is used to fill `NAME`
142
- * and `X-WR-CALNAME` in your iCal file.
143
- *
144
- * @since 0.2.0
145
- */
146
- name(name: string | null): this;
147
- /**
148
- * Get your feed's description
149
- * @since 0.2.7
150
- */
151
- description(): string | null;
152
- /**
153
- * Set your feed's description
154
- * @since 0.2.7
155
- */
156
- description(description: string | null): this;
157
- /**
158
- * Get the current calendar timezone
159
- * @since 0.2.0
160
- */
161
- timezone(): string | null;
162
- /**
163
- * Use this method to set your feed's timezone. Is used
164
- * to fill `TIMEZONE-ID` and `X-WR-TIMEZONE` in your iCal export.
165
- * Please not that all date values are treaded differently, if
166
- * a timezone was set. See [[`formatDate`]] for details. If no
167
- * time zone is specified, all information is output as UTC.
168
- *
169
- * ```javascript
170
- * cal.timezone('America/New_York');
171
- * ```
172
- *
173
- * @see https://github.com/sebbo2002/ical-generator#-date-time--timezones
174
- * @since 0.2.0
175
- */
176
- timezone(timezone: string | null): this;
177
- /**
178
- * Sets the time zone to be used in this calendar file for all times of all
179
- * events. Please note that if the time zone is set, ical-generator assumes
180
- * that all times are already in the correct time zone. Alternatively, a
181
- * `moment-timezone` or a Luxon object can be passed with `setZone`,
182
- * ical-generator will then set the time zone itself.
183
- *
184
- * For the best support of time zones, a VTimezone entry in the calendar is
185
- * recommended, which informs the client about the corresponding time zones
186
- * (daylight saving time, deviation from UTC, etc.). `ical-generator` itself
187
- * does not have a time zone database, so an external generator is needed here.
188
- *
189
- * A VTimezone generator is a function that takes a time zone as a string and
190
- * returns a VTimezone component according to the ical standard. For example,
191
- * ical-timezones can be used for this:
192
- *
193
- * ```typescript
194
- * import ical from 'ical-generator';
195
- * import {getVtimezoneComponent} from '@touch4it/ical-timezones';
196
- *
197
- * const cal = new ICalCalendar();
198
- * cal.timezone({
199
- * name: 'FOO',
200
- * generator: getVtimezoneComponent
201
- * });
202
- * cal.createEvent({
203
- * start: new Date(),
204
- * timezone: 'Europe/London'
205
- * });
206
- * ```
207
- *
208
- * @see https://github.com/sebbo2002/ical-generator#-date-time--timezones
209
- * @since 2.0.0
210
- */
211
- timezone(timezone: ICalTimezone | string | null): this;
212
- /**
213
- * Get current value of the `SOURCE` attribute.
214
- * @since 2.2.0-develop.1
215
- */
216
- source(): string | null;
217
- /**
218
- * Use this method to set your feed's `SOURCE` attribute.
219
- * This tells the client where to refresh your feed.
220
- *
221
- * ```javascript
222
- * cal.source('http://example.com/my/original_source.ical');
223
- * ```
224
- *
225
- * @since 2.2.0-develop.1
226
- */
227
- source(source: string | null): this;
228
- /**
229
- * Get your feed's URL
230
- * @since 0.2.5
231
- */
232
- url(): string | null;
233
- /**
234
- * Set your feed's URL
235
- *
236
- * ```javascript
237
- * calendar.url('http://example.com/my/feed.ical');
238
- * ```
239
- *
240
- * @since 0.2.5
241
- */
242
- url(url: string | null): this;
243
- /**
244
- * Get current value of the `CALSCALE` attribute. It will
245
- * return `null` if no value was set. The iCal standard
246
- * specifies this as `GREGORIAN` if no value is present.
247
- *
248
- * @since 1.8.0
249
- */
250
- scale(): string | null;
251
- /**
252
- * Use this method to set your feed's `CALSCALE` attribute. There is no
253
- * default value for this property and it will not appear in your iCal
254
- * file unless set. The iCal standard specifies this as `GREGORIAN` if
255
- * no value is present.
256
- *
257
- * ```javascript
258
- * cal.scale('gregorian');
259
- * ```
260
- *
261
- * @since 1.8.0
262
- */
263
- scale(scale: string | null): this;
264
- /**
265
- * Get the current ttl duration in seconds
266
- * @since 0.2.5
267
- */
268
- ttl(): number | null;
269
- /**
270
- * Use this method to set your feed's time to live
271
- * (in seconds). Is used to fill `REFRESH-INTERVAL` and
272
- * `X-PUBLISHED-TTL` in your iCal.
273
- *
274
- * ```javascript
275
- * const cal = ical().ttl(60 * 60 * 24); // 1 day
276
- * ```
277
- *
278
- * You can also pass a moment.js duration object. Zero, null
279
- * or negative numbers will reset the `ttl` attribute.
280
- *
281
- * @since 0.2.5
282
- */
283
- ttl(ttl: number | ICalMomentDurationStub | null): this;
284
- /**
285
- * Creates a new [[`ICalEvent`]] and returns it. Use options to prefill the event's attributes.
286
- * Calling this method without options will create an empty event.
287
- *
288
- * ```javascript
289
- * import ical from 'ical-generator';
290
- *
291
- * // or use require:
292
- * // const ical = require('ical-generator');
293
- *
294
- * const cal = ical();
295
- * const event = cal.createEvent({summary: 'My Event'});
296
- *
297
- * // overwrite event summary
298
- * event.summary('Your Event');
299
- * ```
300
- *
301
- * @since 0.2.0
302
- */
303
- createEvent(data: ICalEvent | ICalEventData): ICalEvent;
304
- /**
305
- * Returns all events of this calendar.
306
- *
307
- * ```javascript
308
- * const cal = ical();
309
- *
310
- * cal.events([
311
- * {
312
- * start: new Date(),
313
- * end: new Date(new Date().getTime() + 3600000),
314
- * summary: 'Example Event',
315
- * description: 'It works ;)',
316
- * url: 'http://sebbo.net/'
317
- * }
318
- * ]);
319
- *
320
- * cal.events(); // --> [ICalEvent]
321
- * ```
322
- *
323
- * @since 0.2.0
324
- */
325
- events(): ICalEvent[];
326
- /**
327
- * Add multiple events to your calendar.
328
- *
329
- * ```javascript
330
- * const cal = ical();
331
- *
332
- * cal.events([
333
- * {
334
- * start: new Date(),
335
- * end: new Date(new Date().getTime() + 3600000),
336
- * summary: 'Example Event',
337
- * description: 'It works ;)',
338
- * url: 'http://sebbo.net/'
339
- * }
340
- * ]);
341
- *
342
- * cal.events(); // --> [ICalEvent]
343
- * ```
344
- *
345
- * @since 0.2.0
346
- */
347
- events(events: (ICalEvent | ICalEventData)[]): this;
348
- /**
349
- * Remove all events from the calendar without
350
- * touching any other data like name or prodId.
351
- *
352
- * @since 2.0.0-develop.1
353
- */
354
- clear(): this;
355
- /**
356
- * Save ical file using [`fs/promises`](https://nodejs.org/api/fs.html#fs_fspromises_writefile_file_data_options).
357
- * Only works in node.js environments.
358
- *
359
- * ```javascript
360
- * await calendar.save('./calendar.ical');
361
- * ```
362
- */
363
- save(path: string): Promise<void>;
364
- /**
365
- * Save ical file with [`fs.writeFile`](http://nodejs.org/api/fs.html#fs_fs_writefile_filename_data_options_callback).
366
- * Only works in node.js environments.
367
- *
368
- * ```javascript
369
- * calendar.save('./calendar.ical', err => {
370
- * console.log(err);
371
- * });
372
- * ```
373
- */
374
- save(path: string, cb?: (err: NodeJS.ErrnoException | null) => void): this;
375
- /**
376
- * Save Calendar to disk synchronously using
377
- * [fs.writeFileSync](http://nodejs.org/api/fs.html#fs_fs_writefilesync_filename_data_options).
378
- * Only works in node.js environments.
379
- *
380
- * ```javascript
381
- * calendar.saveSync('./calendar.ical');
382
- * ```
383
- */
384
- saveSync(path: string): this;
385
- /**
386
- * Send calendar to the user when using HTTP using the passed `ServerResponse` object.
387
- * Use second parameter `filename` to change the filename, which defaults to `'calendar.ics'`.
388
- *
389
- * @param response HTTP Response object which is used to send the calendar
390
- * @param [filename = 'calendar.ics'] Filename of the calendar file
391
- */
392
- serve(response: ServerResponse, filename?: string): this;
393
- /**
394
- * Generates a blob to use for downloads or to generate a download URL.
395
- * Only supported in browsers supporting the Blob API.
396
- *
397
- * Unfortunately, because node.js has no Blob implementation (they have Buffer
398
- * instead), this method is currently untested. Sorry Dave…
399
- *
400
- * @since 1.9.0
401
- */
402
- toBlob(): Blob;
403
- /**
404
- * Returns a URL to download the ical file. Uses the Blob object internally,
405
- * so it's only supported in browsers supporting the Blob API.
406
- *
407
- * Unfortunately, because node.js has no Blob implementation (they have Buffer
408
- * instead), this can't be tested right now. Sorry Dave…
409
- *
410
- * @since 1.9.0
411
- */
412
- toURL(): string;
413
- /**
414
- * Set X-* attributes. Woun't filter double attributes,
415
- * which are also added by another method (e.g. busystatus),
416
- * so these attributes may be inserted twice.
417
- *
418
- * ```javascript
419
- * calendar.x([
420
- * {
421
- * key: "X-MY-CUSTOM-ATTR",
422
- * value: "1337!"
423
- * }
424
- * ]);
425
- *
426
- * calendar.x([
427
- * ["X-MY-CUSTOM-ATTR", "1337!"]
428
- * ]);
429
- *
430
- * calendar.x({
431
- * "X-MY-CUSTOM-ATTR": "1337!"
432
- * });
433
- * ```
434
- *
435
- * @since 1.9.0
436
- */
437
- x(keyOrArray: {
438
- key: string;
439
- value: string;
440
- }[] | [string, string][] | Record<string, string>): this;
441
- /**
442
- * Set a X-* attribute. Woun't filter double attributes,
443
- * which are also added by another method (e.g. busystatus),
444
- * so these attributes may be inserted twice.
445
- *
446
- * ```javascript
447
- * calendar.x("X-MY-CUSTOM-ATTR", "1337!");
448
- * ```
449
- *
450
- * @since 1.9.0
451
- */
452
- x(keyOrArray: string, value: string): this;
453
- /**
454
- * Get all custom X-* attributes.
455
- * @since 1.9.0
456
- */
457
- x(): {
458
- key: string;
459
- value: string;
460
- }[];
461
- /**
462
- * Return a shallow copy of the calendar's options for JSON stringification.
463
- * Third party objects like moment.js values or RRule objects are stringified
464
- * as well. Can be used for persistence.
465
- *
466
- * ```javascript
467
- * const cal = ical();
468
- * const json = JSON.stringify(cal);
469
- *
470
- * // later: restore calendar data
471
- * cal = ical(JSON.parse(json));
472
- * ```
473
- *
474
- * @since 0.2.4
475
- */
476
- toJSON(): ICalCalendarJSONData;
477
- /**
478
- * Get the number of events added to your calendar
479
- */
480
- length(): number;
481
- /**
482
- * Return generated calendar as a string.
483
- *
484
- * ```javascript
485
- * const cal = ical();
486
- * console.log(cal.toString()); // → BEGIN:VCALENDAR…
487
- * ```
488
- */
489
- toString(): string;
490
- }