Skip to content

Commit

Permalink
Add support for transp attribute (adamgibbons#245)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Gibbons <[email protected]>
  • Loading branch information
OlegWock and adamgibbons authored Aug 14, 2023
1 parent 5397d2e commit 92c008d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ The following properties are accepted:
| recurrenceRule | A recurrence rule, commonly referred to as an RRULE, defines the repeat pattern or rule for to-dos, journal entries and events. If specified, RRULE can be used to compute the recurrence set (the complete set of recurrence instances in a calendar component). You can use a generator like this [one](https://www.textmagic.com/free-tools/rrule-generator) | `FREQ=DAILY`
| sequence | For sending an update for an event (with the same uid), defines the revision sequence number. | `2`
| busyStatus | Used to specify busy status for Microsoft applications, like Outlook. See [Microsoft spec](https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/cd68eae7-ed65-4dd3-8ea7-ad585c76c736). | `'BUSY'` OR `'FREE'` OR `'TENTATIVE`' OR `'OOF'`
| transp | Used to specify event transparency (does event consume actual time of an individual). Used by Google Calendar to determine if event should change attendees availability to 'Busy' or not. | `'TRANSPARENT'` OR `'OPAQUE'`
| classification | This property defines the access classification for a calendar component. See [iCalender spec](https://icalendar.org/iCalendar-RFC-5545/3-8-1-3-classification.html). | `'PUBLIC'` OR `'PRIVATE'` OR `'CONFIDENTIAL`' OR any non-standard string
| created | Date-time representing event's creation date. Provide a date-time in UTC | [2000, 1, 5, 10, 0] (January 5, 2000 GMT +00:00)
| lastModified | Date-time representing date when event was last modified. Provide a date-time in UTC | [2000, 1, 5, 10, 0] (January 5, 2000 GMT +00:00)
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type EventAttributes = {
url?: string;
status?: EventStatus;
busyStatus?: 'FREE' | 'BUSY' | 'TENTATIVE' | 'OOF';
transp?: 'TRANSPARENT' | 'OPAQUE';

organizer?: Person & {
sentBy?: string;
Expand Down
2 changes: 1 addition & 1 deletion notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TZID=America/New_York:19980119T020000
- [ ] seq
- [x] status
- [x] summary
- [ ] transp
- [x] transp
- [x] url
- [ ] recurid

Expand Down
2 changes: 2 additions & 0 deletions src/pipeline/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function formatEvent(attributes = {}) {
alarms,
recurrenceRule,
busyStatus,
transp,
classification,
created,
lastModified,
Expand Down Expand Up @@ -77,6 +78,7 @@ export default function formatEvent(attributes = {}) {
icsFormat += categories ? (foldLine(`CATEGORIES:${categories}`) + '\r\n') : ''
icsFormat += organizer ? (foldLine(`ORGANIZER;${setOrganizer(organizer)}`) + '\r\n') : ''
icsFormat += busyStatus ? (foldLine(`X-MICROSOFT-CDO-BUSYSTATUS:${busyStatus}`) + '\r\n') : ''
icsFormat += transp ? (foldLine(`TRANSP:${transp}`) + '\r\n') : ''
icsFormat += classification ? (foldLine(`CLASS:${classification}`) + '\r\n') : ''
icsFormat += created ? ('CREATED:' + formatDate(created) + '\r\n') : ''
icsFormat += lastModified ? ('LAST-MODIFIED:' + formatDate(lastModified) + '\r\n') : ''
Expand Down
1 change: 1 addition & 0 deletions src/schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const schema = yup.object().shape({
alarms: yup.array().of(alarmSchema),
recurrenceRule: yup.string(),
busyStatus: yup.string().matches(/TENTATIVE|FREE|BUSY|OOF/i),
transp: yup.string().matches(/TRANSPARENT|OPAQUE/i),
classification: yup.string(),
created: dateTimeSchema,
lastModified: dateTimeSchema,
Expand Down
8 changes: 8 additions & 0 deletions test/pipeline/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ describe('pipeline.formatEvent', () => {
expect(formattedEventTent).to.contain('X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE')
expect(formattedEventOOF).to.contain('X-MICROSOFT-CDO-BUSYSTATUS:OOF')
})
it('writes a transp', () => {
const eventFree = buildEvent({ transp: "TRANSPARENT" })
const eventBusy = buildEvent({ transp: "OPAQUE"})
const formattedEventFree = formatEvent(eventFree)
const formattedEventBusy = formatEvent(eventBusy)
expect(formattedEventFree).to.contain('TRANSP:TRANSPARENT')
expect(formattedEventBusy).to.contain('TRANSP:OPAQUE')
})
it('writes a access classification', () => {
const eventPublic = buildEvent({ classification: "PUBLIC" })
const eventPrivate = buildEvent({ classification: "PRIVATE"})
Expand Down
9 changes: 9 additions & 0 deletions test/schema/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ describe('.validateEvent', () => {
}).value.created).to.exist
})

it('transp', () => {
expect(validateEvent({
title: 'foo',
uid: 'foo',
start: [2018, 12, 1, 10, 30],
transp: 'TRANSPARENT'
}).value.transp).to.exist
})

it('lastModified', () => {
expect(validateEvent({
title: 'foo',
Expand Down

0 comments on commit 92c008d

Please sign in to comment.