extract ObjectDDParticipantFunc (#4236)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-12-21 14:51:14 +06:00 committed by GitHub
parent ac3fec3f35
commit d80ca00f98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 107 deletions

View File

@ -14,27 +14,19 @@
// limitations under the License. // limitations under the License.
// //
import { type Builder, Model, Mixin } from '@hcengineering/model' import { Mixin, Model, type Builder } from '@hcengineering/model'
import { TClass, TDoc } from '@hcengineering/model-core' import { TClass, TDoc } from '@hcengineering/model-core'
import type { Resource } from '@hcengineering/platform' import type { Resource } from '@hcengineering/platform'
import core, { import core, { DOMAIN_MODEL } from '@hcengineering/core'
type Class,
DOMAIN_MODEL,
type Doc,
type DocumentQuery,
type FindOptions,
type FindResult,
type Hierarchy,
type Ref
} from '@hcengineering/core'
import type { import type {
ClassSearchConfig,
ObjectDDParticipant, ObjectDDParticipant,
Trigger, ObjectDDParticipantFunc,
TriggerFunc,
SearchPresenter, SearchPresenter,
SearchPresenterFunc, SearchPresenterFunc,
ClassSearchConfig Trigger,
TriggerFunc
} from '@hcengineering/server-core' } from '@hcengineering/server-core'
import serverCore from '@hcengineering/server-core' import serverCore from '@hcengineering/server-core'
@ -47,17 +39,7 @@ export class TTrigger extends TDoc implements Trigger {
@Model(serverCore.mixin.ObjectDDParticipant, core.class.Class) @Model(serverCore.mixin.ObjectDDParticipant, core.class.Class)
export class TObjectDDParticipant extends TClass implements ObjectDDParticipant { export class TObjectDDParticipant extends TClass implements ObjectDDParticipant {
collectDocs!: Resource< collectDocs!: Resource<ObjectDDParticipantFunc>
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>
} }
@Mixin(serverCore.mixin.SearchPresenter, core.class.Class) @Mixin(serverCore.mixin.SearchPresenter, core.class.Class)

View File

@ -14,11 +14,10 @@
// limitations under the License. // limitations under the License.
// //
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform' import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import type { ObjectDDParticipantFunc, TriggerFunc } from '@hcengineering/server-core'
import { Presenter } from '@hcengineering/server-notification' import { Presenter } from '@hcengineering/server-notification'
import type { TriggerFunc } from '@hcengineering/server-core'
/** /**
* @public * @public
@ -32,17 +31,7 @@ export default plugin(serverCalendarId, {
function: { function: {
ReminderHTMLPresenter: '' as Resource<Presenter>, ReminderHTMLPresenter: '' as Resource<Presenter>,
ReminderTextPresenter: '' as Resource<Presenter>, ReminderTextPresenter: '' as Resource<Presenter>,
FindReminders: '' as Resource< FindReminders: '' as Resource<ObjectDDParticipantFunc>
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>
}, },
trigger: { trigger: {
OnPersonAccountCreate: '' as Resource<TriggerFunc> OnPersonAccountCreate: '' as Resource<TriggerFunc>

View File

@ -13,11 +13,10 @@
// limitations under the License. // limitations under the License.
// //
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform' import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import { TriggerFunc } from '@hcengineering/server-core' import { ObjectDDParticipantFunc, TriggerFunc } from '@hcengineering/server-core'
import { Presenter, TypeMatchFunc, NotificationContentProvider } from '@hcengineering/server-notification' import { NotificationContentProvider, Presenter, TypeMatchFunc } from '@hcengineering/server-notification'
/** /**
* @public * @public
@ -34,17 +33,7 @@ export default plugin(serverChunterId, {
OnMessageSent: '' as Resource<TriggerFunc> OnMessageSent: '' as Resource<TriggerFunc>
}, },
function: { function: {
CommentRemove: '' as Resource< CommentRemove: '' as Resource<ObjectDDParticipantFunc>,
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>,
ChannelHTMLPresenter: '' as Resource<Presenter>, ChannelHTMLPresenter: '' as Resource<Presenter>,
ChannelTextPresenter: '' as Resource<Presenter>, ChannelTextPresenter: '' as Resource<Presenter>,
IsDirectMessage: '' as TypeMatchFunc, IsDirectMessage: '' as TypeMatchFunc,

View File

@ -14,11 +14,10 @@
// limitations under the License. // limitations under the License.
// //
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform' import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import { ObjectDDParticipantFunc, TriggerFunc } from '@hcengineering/server-core'
import { TypeMatchFunc } from '@hcengineering/server-notification' import { TypeMatchFunc } from '@hcengineering/server-notification'
import { TriggerFunc } from '@hcengineering/server-core'
/** /**
* @public * @public
@ -34,16 +33,6 @@ export default plugin(serverGmailId, {
}, },
function: { function: {
IsIncomingMessage: '' as TypeMatchFunc, IsIncomingMessage: '' as TypeMatchFunc,
FindMessages: '' as Resource< FindMessages: '' as Resource<ObjectDDParticipantFunc>
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>
} }
}) })

View File

@ -13,10 +13,9 @@
// limitations under the License. // limitations under the License.
// //
import { Class, Doc, Hierarchy, Ref, FindResult, FindOptions, DocumentQuery } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform' import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import { TriggerFunc } from '@hcengineering/server-core' import { ObjectDDParticipantFunc, TriggerFunc } from '@hcengineering/server-core'
/** /**
* @public * @public
@ -31,16 +30,6 @@ export default plugin(serverTagsId, {
onTagReference: '' as Resource<TriggerFunc> onTagReference: '' as Resource<TriggerFunc>
}, },
function: { function: {
TagElementRemove: '' as Resource< TagElementRemove: '' as Resource<ObjectDDParticipantFunc>
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>
} }
}) })

View File

@ -14,11 +14,10 @@
// limitations under the License. // limitations under the License.
// //
import { Class, Doc, DocumentQuery, FindOptions, FindResult, Hierarchy, Ref } from '@hcengineering/core'
import type { Plugin, Resource } from '@hcengineering/platform' import type { Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform'
import { ObjectDDParticipantFunc, TriggerFunc } from '@hcengineering/server-core'
import { TypeMatchFunc } from '@hcengineering/server-notification' import { TypeMatchFunc } from '@hcengineering/server-notification'
import { TriggerFunc } from '@hcengineering/server-core'
/** /**
* @public * @public
@ -34,16 +33,6 @@ export default plugin(serverTelegramId, {
}, },
function: { function: {
IsIncomingMessage: '' as TypeMatchFunc, IsIncomingMessage: '' as TypeMatchFunc,
FindMessages: '' as Resource< FindMessages: '' as Resource<ObjectDDParticipantFunc>
(
doc: Doc,
hiearachy: Hierarchy,
findAll: <T extends Doc>(
clazz: Ref<Class<T>>,
query: DocumentQuery<T>,
options?: FindOptions<T>
) => Promise<FindResult<T>>
) => Promise<Doc[]>
>
} }
}) })

View File

@ -27,6 +27,9 @@ import {
ModelDb, ModelDb,
Obj, Obj,
Ref, Ref,
SearchOptions,
SearchQuery,
SearchResult,
ServerStorage, ServerStorage,
Space, Space,
Storage, Storage,
@ -34,13 +37,10 @@ import {
Tx, Tx,
TxFactory, TxFactory,
TxResult, TxResult,
WorkspaceId, WorkspaceId
SearchQuery,
SearchOptions,
SearchResult
} from '@hcengineering/core' } from '@hcengineering/core'
import { MinioService } from '@hcengineering/minio' import { MinioService } from '@hcengineering/minio'
import type { Resource, Asset } from '@hcengineering/platform' import type { Asset, Resource } from '@hcengineering/platform'
import { Readable } from 'stream' import { Readable } from 'stream'
/** /**
@ -321,8 +321,10 @@ export interface WithFind {
*/ */
export interface ObjectDDParticipant extends Class<Obj> { export interface ObjectDDParticipant extends Class<Obj> {
// Collect more items to be deleted if parent document is deleted. // Collect more items to be deleted if parent document is deleted.
collectDocs: Resource< collectDocs: Resource<ObjectDDParticipantFunc>
( }
export type ObjectDDParticipantFunc = (
doc: Doc, doc: Doc,
hiearachy: Hierarchy, hiearachy: Hierarchy,
findAll: <T extends Doc>( findAll: <T extends Doc>(
@ -331,8 +333,6 @@ export interface ObjectDDParticipant extends Class<Obj> {
options?: FindOptions<T> options?: FindOptions<T>
) => Promise<FindResult<T>> ) => Promise<FindResult<T>>
) => Promise<Doc[]> ) => Promise<Doc[]>
>
}
/** /**
* @public * @public