mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 12:47:45 +02:00
Cleanup rollback (#10304)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
"0.7.312"
|
||||
"0.7.320"
|
||||
|
||||
@@ -79,7 +79,7 @@ import { definePermissions } from './permission'
|
||||
import process from './plugin'
|
||||
import { defineTriggers } from './triggers'
|
||||
|
||||
const DOMAIN_PROCESS = 'process' as Domain
|
||||
export const DOMAIN_PROCESS = 'process' as Domain
|
||||
const DOMAIN_PROCESS_LOG = 'process-log' as Domain
|
||||
|
||||
@Model(process.class.Process, core.class.Doc, DOMAIN_MODEL)
|
||||
|
||||
@@ -18,14 +18,23 @@ import {
|
||||
type MigrateOperation,
|
||||
type MigrationClient,
|
||||
type MigrationUpgradeClient,
|
||||
tryMigrate,
|
||||
tryUpgrade
|
||||
} from '@hcengineering/model'
|
||||
import process, { type State, type Step } from '@hcengineering/process'
|
||||
import { makeRank } from '@hcengineering/rank'
|
||||
import { processId } from '.'
|
||||
import { DOMAIN_PROCESS, processId } from '.'
|
||||
|
||||
export const processOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient, mode): Promise<void> {},
|
||||
async migrate (client: MigrationClient, mode): Promise<void> {
|
||||
await tryMigrate(mode, client, processId, [
|
||||
{
|
||||
state: 'cleanup-rollback',
|
||||
mode: 'upgrade',
|
||||
func: cleanupRollback
|
||||
}
|
||||
])
|
||||
},
|
||||
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>, mode): Promise<void> {
|
||||
await tryUpgrade(mode, state, client, processId, [
|
||||
{
|
||||
@@ -108,3 +117,15 @@ async function migrateActionsFromStates (client: Client): Promise<void> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupRollback (client: MigrationClient): Promise<void> {
|
||||
await client.update(
|
||||
DOMAIN_PROCESS,
|
||||
{
|
||||
_class: process.class.Execution
|
||||
},
|
||||
{
|
||||
rollback: []
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -342,6 +342,7 @@ async function executeTransition (
|
||||
control: ProcessControl
|
||||
): Promise<void> {
|
||||
let nested = false
|
||||
let disableRollback = false
|
||||
let transition: Transition | undefined = _transition
|
||||
while (transition !== undefined) {
|
||||
let deep = control.cache.get(execution._id + 'transition') ?? 0
|
||||
@@ -359,7 +360,7 @@ async function executeTransition (
|
||||
if (trigger === undefined) return
|
||||
const rollback: Tx[] = []
|
||||
const triggerImpl = control.client.getHierarchy().as(trigger, serverProcess.mixin.TriggerImpl)
|
||||
const disableRollback = triggerImpl?.preventRollback ?? false
|
||||
disableRollback = disableRollback || (triggerImpl?.preventRollback ?? false)
|
||||
const triggerRollback = await getTriggerRollback(triggerImpl, control)
|
||||
if (triggerRollback !== undefined) {
|
||||
rollback.push(triggerRollback)
|
||||
|
||||
Reference in New Issue
Block a user