2022-03-18 06:37:49 +00:00
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2023-07-10 15:50:29 +00:00
|
|
|
import { Contact } from '@hcengineering/contact'
|
|
|
|
import type { AttachedDoc, Class, Doc, Markup, Ref, Space, Timestamp } from '@hcengineering/core'
|
|
|
|
import { NotificationType } from '@hcengineering/notification'
|
|
|
|
import type { Asset, IntlString, Metadata, Plugin } from '@hcengineering/platform'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { plugin } from '@hcengineering/platform'
|
2023-07-10 15:50:29 +00:00
|
|
|
import type { Handler, IntegrationType } from '@hcengineering/setting'
|
2022-09-21 08:08:25 +00:00
|
|
|
import { AnyComponent } from '@hcengineering/ui'
|
2022-03-18 06:37:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Calendar extends Space {}
|
|
|
|
|
2023-07-10 15:50:29 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
* RFC5545
|
|
|
|
*/
|
|
|
|
export interface RecurringRule {
|
|
|
|
freq: 'SECONDLY' | 'MINUTELY' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY'
|
|
|
|
endDate?: Timestamp
|
|
|
|
count?: number
|
|
|
|
interval?: number
|
|
|
|
bySecond?: number[]
|
|
|
|
byMinute?: number[]
|
|
|
|
byHour?: number[]
|
|
|
|
byDay?: string[]
|
|
|
|
byMonthDay?: number[]
|
|
|
|
byYearDay?: number[]
|
|
|
|
byWeekNo?: number[]
|
|
|
|
byMonth?: number[]
|
|
|
|
bySetPos?: number[]
|
|
|
|
wkst?: 'SU' | 'MO' | 'TU' | 'WE' | 'TH' | 'FR' | 'SA'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface ReccuringEvent extends Event {
|
|
|
|
rules: RecurringRule[]
|
|
|
|
exdate: Timestamp[]
|
|
|
|
rdate: Timestamp[]
|
|
|
|
}
|
|
|
|
|
2022-03-18 06:37:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Event extends AttachedDoc {
|
2023-07-10 15:50:29 +00:00
|
|
|
eventId: string
|
2022-03-18 06:37:49 +00:00
|
|
|
title: string
|
|
|
|
description: Markup
|
|
|
|
|
|
|
|
location?: string
|
|
|
|
|
2023-07-10 15:50:29 +00:00
|
|
|
allDay: boolean
|
|
|
|
|
2022-03-18 06:37:49 +00:00
|
|
|
// Event scheduled date
|
|
|
|
date: Timestamp
|
|
|
|
|
|
|
|
// Event due date for long events.
|
2023-07-10 15:50:29 +00:00
|
|
|
dueDate: Timestamp
|
2022-03-18 06:37:49 +00:00
|
|
|
|
|
|
|
attachments?: number
|
|
|
|
|
2023-07-10 15:50:29 +00:00
|
|
|
participants: Ref<Contact>[]
|
|
|
|
|
|
|
|
externalParticipants?: string[]
|
|
|
|
|
|
|
|
reminders?: Timestamp[]
|
|
|
|
|
|
|
|
access: 'freeBusyReader' | 'reader' | 'writer' | 'owner'
|
2022-03-18 06:37:49 +00:00
|
|
|
}
|
|
|
|
|
2022-03-26 17:34:06 +00:00
|
|
|
/**
|
|
|
|
* @public
|
2023-07-10 15:50:29 +00:00
|
|
|
* use for an instance of a recurring event
|
2022-03-26 17:34:06 +00:00
|
|
|
*/
|
2023-07-10 15:50:29 +00:00
|
|
|
export interface ReccuringInstance extends Event {
|
|
|
|
recurringEventId: string
|
|
|
|
originalStartTime: number
|
|
|
|
isCancelled?: boolean
|
|
|
|
virtual?: boolean
|
2022-03-26 17:34:06 +00:00
|
|
|
}
|
|
|
|
|
2022-03-18 06:37:49 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const calendarId = 'calendar' as Plugin
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
const calendarPlugin = plugin(calendarId, {
|
|
|
|
class: {
|
|
|
|
Calendar: '' as Ref<Class<Calendar>>,
|
2023-07-10 15:50:29 +00:00
|
|
|
Event: '' as Ref<Class<Event>>,
|
|
|
|
ReccuringEvent: '' as Ref<Class<ReccuringEvent>>,
|
|
|
|
ReccuringInstance: '' as Ref<Class<ReccuringInstance>>
|
2022-03-26 17:34:06 +00:00
|
|
|
},
|
2022-03-18 06:37:49 +00:00
|
|
|
icon: {
|
|
|
|
Calendar: '' as Asset,
|
2022-03-26 17:34:06 +00:00
|
|
|
Location: '' as Asset,
|
2023-05-22 03:50:44 +00:00
|
|
|
Reminder: '' as Asset,
|
|
|
|
Notifications: '' as Asset
|
2022-03-18 06:37:49 +00:00
|
|
|
},
|
|
|
|
space: {
|
2023-07-10 15:50:29 +00:00
|
|
|
// deprecated
|
2022-03-18 06:37:49 +00:00
|
|
|
PersonalEvents: '' as Ref<Space>
|
|
|
|
},
|
|
|
|
app: {
|
|
|
|
Calendar: '' as Ref<Doc>
|
|
|
|
},
|
|
|
|
component: {
|
2023-08-01 07:58:03 +00:00
|
|
|
CalendarView: '' as AnyComponent,
|
2022-03-23 09:03:41 +00:00
|
|
|
PersonsPresenter: '' as AnyComponent,
|
2022-05-12 09:40:22 +00:00
|
|
|
Events: '' as AnyComponent,
|
2022-03-26 17:34:06 +00:00
|
|
|
DateTimePresenter: '' as AnyComponent,
|
2023-06-01 16:35:21 +00:00
|
|
|
DocReminder: '' as AnyComponent
|
2022-03-18 06:37:49 +00:00
|
|
|
},
|
|
|
|
string: {
|
|
|
|
Title: '' as IntlString,
|
|
|
|
Calendar: '' as IntlString,
|
|
|
|
Description: '' as IntlString,
|
|
|
|
Date: '' as IntlString,
|
|
|
|
DueTo: '' as IntlString,
|
|
|
|
Calendars: '' as IntlString,
|
|
|
|
CreateCalendar: '' as IntlString,
|
|
|
|
Location: '' as IntlString,
|
|
|
|
Participants: '' as IntlString,
|
|
|
|
NoParticipants: '' as IntlString,
|
|
|
|
PersonsLabel: '' as IntlString,
|
2022-03-31 08:32:42 +00:00
|
|
|
EventNumber: '' as IntlString,
|
2023-08-01 07:58:03 +00:00
|
|
|
Reminders: '' as IntlString,
|
|
|
|
Today: '' as IntlString
|
2022-03-26 17:34:06 +00:00
|
|
|
},
|
2023-07-10 15:50:29 +00:00
|
|
|
handler: {
|
|
|
|
DisconnectHandler: '' as Handler
|
|
|
|
},
|
|
|
|
integrationType: {
|
|
|
|
Calendar: '' as Ref<IntegrationType>
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
CalendarServiceURL: '' as Metadata<string>
|
|
|
|
},
|
2022-03-26 17:34:06 +00:00
|
|
|
ids: {
|
2022-06-15 12:00:32 +00:00
|
|
|
ReminderNotification: '' as Ref<NotificationType>,
|
|
|
|
NoAttached: '' as Ref<Event>
|
2022-03-18 06:37:49 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
export default calendarPlugin
|
2023-07-10 15:50:29 +00:00
|
|
|
export * from './utils'
|