Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2025-03-07 02:51:37 +00:00
commit 97d6a2e74d
2 changed files with 22 additions and 1 deletions

View File

@ -161,6 +161,23 @@ describe('workflow > triggers > collection', () => {
expect(executions.length).toBe(1);
expect(executions[0].context.data.title).toBe('c1');
});
it('skipWorkflow', async () => {
const workflow = await WorkflowModel.create({
enabled: true,
sync: true,
type: 'collection',
config: {
mode: 1,
collection: 'posts',
},
});
const post = await PostRepo.create({ values: { title: 't1' }, context: { skipWorkflow: true } });
const executions = await workflow.getExecutions();
expect(executions.length).toBe(0);
});
});
describe('config.mode', () => {

View File

@ -53,13 +53,17 @@ export default class CollectionTrigger extends Trigger {
// async function, should return promise
private static async handler(this: CollectionTrigger, workflow: WorkflowModel, data: Model, options) {
const { skipWorkflow = false, stack } = options.context ?? {};
if (skipWorkflow) {
return;
}
const [dataSourceName] = parseCollectionName(workflow.config.collection);
const transaction = this.workflow.useDataSourceTransaction(dataSourceName, options.transaction);
const ctx = await this.prepare(workflow, data, { ...options, transaction });
if (!ctx) {
return;
}
const { stack } = options.context ?? {};
if (workflow.sync) {
await this.workflow.trigger(workflow, ctx, {
transaction,