2021-12-06 10:07:08 +00:00
|
|
|
//
|
2021-09-27 08:06:05 +00:00
|
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
|
|
// Copyright © 2021 Hardcore Engineering Inc.
|
2021-12-06 10:07:08 +00:00
|
|
|
//
|
2021-09-27 08:06:05 +00:00
|
|
|
// 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
|
2021-12-06 10:07:08 +00:00
|
|
|
//
|
2021-09-27 08:06:05 +00:00
|
|
|
// 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.
|
2021-12-06 10:07:08 +00:00
|
|
|
//
|
2021-09-27 08:06:05 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-12-06 10:07:08 +00:00
|
|
|
//
|
2021-09-27 08:06:05 +00:00
|
|
|
|
2022-01-12 09:52:22 +00:00
|
|
|
import type { Ref, Class, AttachedDoc, Space, Doc } from '@anticrm/core'
|
|
|
|
import { plugin, Resource } from '@anticrm/platform'
|
2021-12-06 10:07:08 +00:00
|
|
|
import type { Asset, Plugin } from '@anticrm/platform'
|
|
|
|
import { AnyComponent } from '@anticrm/ui'
|
2021-10-23 16:48:22 +00:00
|
|
|
|
2021-12-06 10:07:08 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Attachment extends AttachedDoc {
|
|
|
|
name: string
|
|
|
|
file: string
|
|
|
|
size: number
|
|
|
|
type: string
|
|
|
|
lastModified: number
|
|
|
|
}
|
2021-09-27 08:06:05 +00:00
|
|
|
|
2022-01-14 09:20:31 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export interface Photo extends Attachment {}
|
|
|
|
|
2021-12-06 10:07:08 +00:00
|
|
|
/**
|
|
|
|
* @public
|
|
|
|
*/
|
|
|
|
export const attachmentId = 'attachment' as Plugin
|
2021-09-27 08:06:05 +00:00
|
|
|
|
2021-12-06 10:07:08 +00:00
|
|
|
export default plugin(attachmentId, {
|
|
|
|
component: {
|
2022-01-14 09:20:31 +00:00
|
|
|
Attachments: '' as AnyComponent,
|
|
|
|
Photos: '' as AnyComponent
|
2021-12-06 10:07:08 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
Attachment: '' as Asset
|
|
|
|
},
|
|
|
|
class: {
|
2022-01-14 09:20:31 +00:00
|
|
|
Attachment: '' as Ref<Class<Attachment>>,
|
|
|
|
Photo: '' as Ref<Class<Photo>>
|
2022-01-12 09:52:22 +00:00
|
|
|
},
|
|
|
|
helper: {
|
2022-01-14 09:09:01 +00:00
|
|
|
UploadFile: '' as Resource<(file: File, space?: Ref<Space>, attachedTo?: Ref<Doc>) => Promise<string>>,
|
|
|
|
DeleteFile: '' as Resource<(id: string) => Promise<void>>
|
2021-12-06 10:07:08 +00:00
|
|
|
}
|
|
|
|
})
|