// // 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. // import { Account, AttachedDoc, Class, Doc, Mixin, Ref, Space, Timestamp, TxCUD } from '@hcengineering/core' import type { Asset, IntlString, Plugin, Resource } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform' import { IntegrationType } from '@hcengineering/setting' import { AnyComponent } from '@hcengineering/ui' import { Writable } from './types' export * from './types' /** * @public */ export interface LastView extends Doc { user: Ref [key: string]: any } /** * @public */ export interface Notification extends AttachedDoc { tx: Ref> status: NotificationStatus text: string type: Ref } /** * @public */ export interface EmailNotification extends Doc { sender: string receivers: string[] subject: string text: string html?: string status: 'new' | 'sent' | 'error' error?: string } /** * @public */ export enum NotificationStatus { New, Notified, Read } /** * @public */ export interface NotificationType extends Doc { hidden: boolean label: IntlString textTemplate: string htmlTemplate: string subjectTemplate: string } /** * @public */ export interface NotificationProvider extends Doc { label: IntlString default: boolean } /** * @public */ export interface NotificationSetting extends Doc { type: Ref provider: Ref enabled: boolean } /** * @public */ export interface SpaceLastEdit extends Class { lastEditField: string } /** * @public */ export interface AnotherUserNotifications extends Class { fields: string[] } /** * @public */ export interface ClassCollaborators extends Class { fields: string[] // Ref | Ref | Ref[] | Ref[] } /** * @public */ export interface TrackedDoc extends Class {} /** * @public */ export interface Collaborators extends Doc { collaborators: Ref[] } /** * @public */ export const notificationId = 'notification' as Plugin /** * @public */ export interface NotificationClient { getLastViews: () => Writable updateLastView: (_id: Ref, _class: Ref>, time?: Timestamp, force?: boolean) => Promise unsubscribe: (_id: Ref) => Promise } /** * @public */ export type NotificationClientFactoy = () => NotificationClient /** * @public */ const notification = plugin(notificationId, { mixin: { SpaceLastEdit: '' as Ref>, AnotherUserNotifications: '' as Ref>, ClassCollaborators: '' as Ref>, Collaborators: '' as Ref>, TrackedDoc: '' as Ref> }, class: { LastView: '' as Ref>, Notification: '' as Ref>, EmailNotification: '' as Ref>, NotificationType: '' as Ref>, NotificationProvider: '' as Ref>, NotificationSetting: '' as Ref> }, ids: { MentionNotification: '' as Ref, DMNotification: '' as Ref, CollaboratorNotification: '' as Ref, PlatformNotification: '' as Ref, BrowserNotification: '' as Ref, EmailNotification: '' as Ref, NotificationSettings: '' as Ref }, integrationType: { MobileApp: '' as Ref }, component: { NotificationsPopup: '' as AnyComponent, NotificationPresenter: '' as AnyComponent }, icon: { Notifications: '' as Asset, Track: '' as Asset, DontTrack: '' as Asset }, space: { Notifications: '' as Ref }, string: { Notification: '' as IntlString, Notifications: '' as IntlString }, function: { GetNotificationClient: '' as Resource } }) export default notification