ical-generator 9.0.0-develop.2 → 9.0.0-develop.3

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
@@ -129,5 +129,5 @@
129
129
  "test": "mocha"
130
130
  },
131
131
  "type": "module",
132
- "version": "9.0.0-develop.2"
132
+ "version": "9.0.0-develop.3"
133
133
  }
package/src/attendee.ts CHANGED
@@ -17,6 +17,13 @@ export enum ICalAttendeeRole {
17
17
  REQ = 'REQ-PARTICIPANT',
18
18
  }
19
19
 
20
+ // ref: https://datatracker.ietf.org/doc/html/rfc6638#section-7.1
21
+ export enum ICalAttendeeScheduleAgent {
22
+ CLIENT = 'CLIENT',
23
+ NONE = 'NONE',
24
+ SERVER = 'SERVER',
25
+ }
26
+
20
27
  export enum ICalAttendeeStatus {
21
28
  ACCEPTED = 'ACCEPTED',
22
29
  DECLINED = 'DECLINED',
@@ -33,7 +40,6 @@ export enum ICalAttendeeType {
33
40
  ROOM = 'ROOM',
34
41
  UNKNOWN = 'UNKNOWN',
35
42
  }
36
-
37
43
  export interface ICalAttendeeData {
38
44
  delegatedFrom?: ICalAttendee | ICalAttendeeData | null | string;
39
45
  delegatedTo?: ICalAttendee | ICalAttendeeData | null | string;
@@ -44,6 +50,7 @@ export interface ICalAttendeeData {
44
50
  name?: null | string;
45
51
  role?: ICalAttendeeRole;
46
52
  rsvp?: boolean | null;
53
+ scheduleAgent?: ICalAttendeeScheduleAgent | ICalXName | null;
47
54
  sentBy?: null | string;
48
55
  status?: ICalAttendeeStatus | null;
49
56
  type?: ICalAttendeeType | null;
@@ -67,6 +74,8 @@ export interface ICalAttendeeJSONData {
67
74
  x: { key: string; value: string }[];
68
75
  }
69
76
 
77
+ export type ICalXName = `X-${string}`;
78
+
70
79
  interface ICalInternalAttendeeData {
71
80
  delegatedFrom: ICalAttendee | null;
72
81
  delegatedTo: ICalAttendee | null;
@@ -75,6 +84,7 @@ interface ICalInternalAttendeeData {
75
84
  name: null | string;
76
85
  role: ICalAttendeeRole;
77
86
  rsvp: boolean | null;
87
+ scheduleAgent: ICalAttendeeScheduleAgent | ICalXName | null;
78
88
  sentBy: null | string;
79
89
  status: ICalAttendeeStatus | null;
80
90
  type: ICalAttendeeType | null;
@@ -119,6 +129,7 @@ export default class ICalAttendee {
119
129
  name: null,
120
130
  role: ICalAttendeeRole.REQ,
121
131
  rsvp: null,
132
+ scheduleAgent: null,
122
133
  sentBy: null,
123
134
  status: null,
124
135
  type: null,
@@ -145,6 +156,8 @@ export default class ICalAttendee {
145
156
  this.delegatedFrom(data.delegatedFrom);
146
157
  if (data.delegatesTo) this.delegatesTo(data.delegatesTo);
147
158
  if (data.delegatesFrom) this.delegatesFrom(data.delegatesFrom);
159
+ if (data.scheduleAgent !== undefined)
160
+ this.scheduleAgent(data.scheduleAgent);
148
161
  if (data.x !== undefined) this.x(data.x);
149
162
  }
150
163
 
@@ -402,6 +415,46 @@ export default class ICalAttendee {
402
415
  this.data.rsvp = Boolean(rsvp);
403
416
  return this;
404
417
  }
418
+ /**
419
+ * Get attendee's schedule agent
420
+ * @since 9.0.0
421
+ */
422
+ scheduleAgent(): ICalAttendeeScheduleAgent | ICalXName;
423
+ /**
424
+ * Set attendee's schedule agent
425
+ * See {@link ICalAttendeeScheduleAgent} for available values.
426
+ * You can also use custom X-* values.
427
+ *
428
+ * @since 9.0.0
429
+ */
430
+ scheduleAgent(
431
+ scheduleAgent: ICalAttendeeScheduleAgent | ICalXName | null,
432
+ ): this;
433
+ scheduleAgent(
434
+ scheduleAgent?: ICalAttendeeScheduleAgent | ICalXName | null,
435
+ ): ICalAttendeeScheduleAgent | ICalXName | null | this {
436
+ if (scheduleAgent === undefined) {
437
+ return this.data.scheduleAgent;
438
+ }
439
+ if (!scheduleAgent) {
440
+ this.data.scheduleAgent = null;
441
+ return this;
442
+ }
443
+
444
+ if (
445
+ typeof scheduleAgent == 'string' &&
446
+ scheduleAgent.toUpperCase().startsWith('X-')
447
+ ) {
448
+ this.data.scheduleAgent = scheduleAgent as string as ICalXName;
449
+ return this;
450
+ }
451
+
452
+ this.data.scheduleAgent = checkEnum(
453
+ ICalAttendeeScheduleAgent,
454
+ scheduleAgent,
455
+ ) as ICalAttendeeScheduleAgent;
456
+ return this;
457
+ }
405
458
  /**
406
459
  * Get the acting user's email adress
407
460
  * @since 3.3.0
@@ -462,7 +515,6 @@ export default class ICalAttendee {
462
515
  x: this.x(),
463
516
  });
464
517
  }
465
-
466
518
  /**
467
519
  * Return generated attendee as a string.
468
520
  *
@@ -520,6 +572,11 @@ export default class ICalAttendee {
520
572
  g += ';EMAIL=' + escape(this.data.email, false);
521
573
  }
522
574
 
575
+ // SCHEDULE-AGENT
576
+ if (this.data.scheduleAgent) {
577
+ g += ';SCHEDULE-AGENT=' + this.data.scheduleAgent;
578
+ }
579
+
523
580
  // CUSTOM X ATTRIBUTES
524
581
  if (this.data.x.length) {
525
582
  g +=
@@ -564,7 +621,6 @@ export default class ICalAttendee {
564
621
  this.data.type = checkEnum(ICalAttendeeType, type) as ICalAttendeeType;
565
622
  return this;
566
623
  }
567
-
568
624
  /**
569
625
  * Set X-* attributes. Woun't filter double attributes,
570
626
  * which are also added by another method (e.g. status),
package/src/index.ts CHANGED
@@ -65,6 +65,7 @@ export {
65
65
  type ICalAttendeeData,
66
66
  type ICalAttendeeJSONData,
67
67
  ICalAttendeeRole,
68
+ type ICalAttendeeScheduleAgent,
68
69
  ICalAttendeeStatus,
69
70
  ICalAttendeeType,
70
71
  } from './attendee.ts';