diff --git a/packages/core/client/src/locale/zh_CN.ts b/packages/core/client/src/locale/zh_CN.ts index f4e9c53ce..eff8bba0a 100644 --- a/packages/core/client/src/locale/zh_CN.ts +++ b/packages/core/client/src/locale/zh_CN.ts @@ -612,6 +612,7 @@ export default { 'Control': '流程控制', 'Collection operations': '数据表操作', + 'Extended': '扩展类型', 'Node type': '节点类型', diff --git a/packages/plugins/workflow/src/client/AddButton.tsx b/packages/plugins/workflow/src/client/AddButton.tsx index ba51ba5e5..5eb531fb0 100644 --- a/packages/plugins/workflow/src/client/AddButton.tsx +++ b/packages/plugins/workflow/src/client/AddButton.tsx @@ -49,6 +49,7 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) { const groups = [ { value: 'control', name: '{{t("Control")}}' }, { value: 'collection', name: '{{t("Collection operations")}}' }, + { value: 'extended', name: '{{t("Extended")}}' }, ]; const instructionList = (Array.from(instructions.getValues()) as Instruction[]); @@ -58,21 +59,24 @@ export function AddButton({ upstream, branchIndex = null }: AddButtonProps) { trigger={['click']} overlay={
} disabled={workflow.executed} diff --git a/packages/plugins/workflow/src/client/index.tsx b/packages/plugins/workflow/src/client/index.tsx index a245465d9..b7b42845f 100644 --- a/packages/plugins/workflow/src/client/index.tsx +++ b/packages/plugins/workflow/src/client/index.tsx @@ -1,4 +1,5 @@ export { triggers } from './triggers'; export * from './nodes'; export { calculators } from './calculators'; +export * from './FlowContext'; export { WorkflowProvider as default } from './WorkflowProvider'; diff --git a/packages/plugins/workflow/src/server/Plugin.ts b/packages/plugins/workflow/src/server/Plugin.ts index 63ad67e44..97713d00a 100644 --- a/packages/plugins/workflow/src/server/Plugin.ts +++ b/packages/plugins/workflow/src/server/Plugin.ts @@ -13,6 +13,7 @@ import ExecutionModel from './models/Execution'; import WorkflowModel from './models/Workflow'; import Processor from './Processor'; import initTriggers, { Trigger } from './triggers'; +import JobModel from './models/Job'; @@ -80,7 +81,9 @@ export default class WorkflowPlugin extends Plugin { db.on('workflows.afterSave', (model: WorkflowModel) => this.toggle(model)); db.on('workflows.afterDestroy', (model: WorkflowModel) => this.toggle(model, false)); - this.app.on('afterLoadAll', async () => this.extensions.reduce((promise, extend) => promise.then(() => extend(this)), Promise.resolve())); + this.app.on('afterLoad', async () => { + this.extensions.reduce((promise, extend) => promise.then(() => extend(this)), Promise.resolve()); + }); // [Life Cycle]: // * load all workflows in db @@ -196,6 +199,14 @@ export default class WorkflowPlugin extends Plugin { return execution; } + async resume(job) { + if (!job.execution) { + job.execution = await job.getExecution(); + } + const processor = this.createProcessor(job.execution); + return processor.resume(job); + } + createProcessor(execution: ExecutionModel, options = {}): Processor { return new Processor(execution, { ...options, plugin: this }); } diff --git a/packages/plugins/workflow/src/server/__tests__/instructions/prompt.test.ts b/packages/plugins/workflow/src/server/__tests__/instructions/prompt.test.ts index ad9354bf1..a38b29deb 100644 --- a/packages/plugins/workflow/src/server/__tests__/instructions/prompt.test.ts +++ b/packages/plugins/workflow/src/server/__tests__/instructions/prompt.test.ts @@ -6,6 +6,7 @@ import { EXECUTION_STATUS, JOB_STATUS } from '../../constants'; +// NOTE: skipped because time is not stable on github ci, but should work in local describe.skip('workflow > instructions > prompt', () => { describe('base', () => { let app: MockServer; diff --git a/packages/plugins/workflow/src/server/actions/jobs.ts b/packages/plugins/workflow/src/server/actions/jobs.ts index 3350609cd..cff78bb21 100644 --- a/packages/plugins/workflow/src/server/actions/jobs.ts +++ b/packages/plugins/workflow/src/server/actions/jobs.ts @@ -22,7 +22,6 @@ export async function submit(context: Context, next) { await next(); const plugin = context.app.pm.get('workflow'); - const processor = plugin.createProcessor(instance.execution); // NOTE: resume the process and no `await` for quick returning - processor.resume(instance); + plugin.resume(instance); } diff --git a/packages/plugins/workflow/src/server/constants.ts b/packages/plugins/workflow/src/server/constants.ts index a66cb4bb7..920cc24b9 100644 --- a/packages/plugins/workflow/src/server/constants.ts +++ b/packages/plugins/workflow/src/server/constants.ts @@ -1,4 +1,5 @@ export const EXECUTION_STATUS = { + CRETEAD: null, STARTED: 0, RESOLVED: 1, REJECTED: -1, diff --git a/packages/plugins/workflow/src/server/extensions/assignees/actions.ts b/packages/plugins/workflow/src/server/extensions/assignees/actions.ts index dc58ad45e..4fc2adee4 100644 --- a/packages/plugins/workflow/src/server/extensions/assignees/actions.ts +++ b/packages/plugins/workflow/src/server/extensions/assignees/actions.ts @@ -52,7 +52,6 @@ export async function submit(context: Context, next) { instance.job.latestUserJob = instance; const plugin = context.app.pm.get('workflow'); - const processor = plugin.createProcessor(instance.execution); // NOTE: resume the process and no `await` for quick returning - processor.resume(instance.job); + plugin.resume(instance.job); } diff --git a/packages/plugins/workflow/src/server/index.ts b/packages/plugins/workflow/src/server/index.ts index c774f4411..36e7e72ed 100644 --- a/packages/plugins/workflow/src/server/index.ts +++ b/packages/plugins/workflow/src/server/index.ts @@ -1,6 +1,6 @@ -export * from './calculators'; export * from './constants'; -export * from './instructions'; -export * from './triggers'; -export * from './Processor'; +export * from './calculators'; +// export * from './instructions'; +export { Trigger } from './triggers'; +export { default as Processor } from './Processor'; export { default } from './Plugin'; diff --git a/packages/plugins/workflow/src/server/instructions/index.ts b/packages/plugins/workflow/src/server/instructions/index.ts index c1cfe8fbd..8e538f561 100644 --- a/packages/plugins/workflow/src/server/instructions/index.ts +++ b/packages/plugins/workflow/src/server/instructions/index.ts @@ -15,25 +15,15 @@ export type Job = { export type InstructionResult = Job | Promise