mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-09 11:17:43 +02:00
throw error in case of non-model space for classes in model (#5694)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { DocumentUpdate, Hierarchy, MixinData, MixinUpdate, ModelDb, toFindResult } from '.'
|
||||
import { DocumentUpdate, DOMAIN_MODEL, Hierarchy, MixinData, MixinUpdate, ModelDb, toFindResult } from '.'
|
||||
import type {
|
||||
Account,
|
||||
AnyAttribute,
|
||||
@@ -93,6 +93,9 @@ export class TxOperations implements Omit<Client, 'notify'> {
|
||||
if (hierarchy.isDerived(_class, core.class.AttachedDoc)) {
|
||||
throw new Error('createDoc cannot be used for objects inherited from AttachedDoc')
|
||||
}
|
||||
if (hierarchy.findDomain(_class) === DOMAIN_MODEL && space !== core.space.Model) {
|
||||
throw new Error('createDoc cannot be called for DOMAIN_MODEL classes with non-model space')
|
||||
}
|
||||
const tx = this.txFactory.createTxCreateDoc(_class, space, attributes, id, modifiedOn, modifiedBy)
|
||||
await this.client.tx(tx)
|
||||
return tx.objectId
|
||||
|
||||
Reference in New Issue
Block a user