@nocobase/plugin-workflow 1.9.0-beta.16 → 1.9.0-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,7 +144,9 @@ class Processor {
144
144
  async start() {
145
145
  const { execution } = this;
146
146
  if (execution.status) {
147
- this.logger.warn(`execution was ended with status ${execution.status} before, could not be started again`);
147
+ this.logger.warn(`execution was ended with status ${execution.status} before, could not be started again`, {
148
+ workflowId: execution.workflowId
149
+ });
148
150
  return;
149
151
  }
150
152
  await this.prepare();
@@ -158,7 +160,9 @@ class Processor {
158
160
  async resume(job) {
159
161
  const { execution } = this;
160
162
  if (execution.status) {
161
- this.logger.warn(`execution was ended with status ${execution.status} before, could not be resumed`);
163
+ this.logger.warn(`execution was ended with status ${execution.status} before, could not be resumed`, {
164
+ workflowId: execution.workflowId
165
+ });
162
166
  return;
163
167
  }
164
168
  await this.prepare();
@@ -168,7 +172,7 @@ class Processor {
168
172
  async exec(instruction, node, prevJob) {
169
173
  let job;
170
174
  try {
171
- this.logger.debug(`config of node`, { data: node.config });
175
+ this.logger.debug(`config of node`, { data: node.config, workflowId: node.workflowId });
172
176
  job = await instruction(node, prevJob, this);
173
177
  if (job === null) {
174
178
  return this.exit();
@@ -179,7 +183,7 @@ class Processor {
179
183
  } catch (err) {
180
184
  this.logger.error(
181
185
  `execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) failed: `,
182
- err
186
+ { error: err, workflowId: node.workflowId }
183
187
  );
184
188
  job = {
185
189
  result: err instanceof Error ? {
@@ -199,7 +203,10 @@ class Processor {
199
203
  }
200
204
  const savedJob = this.saveJob(job);
201
205
  this.logger.info(
202
- `execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) finished as status: ${savedJob.status}`
206
+ `execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) finished as status: ${savedJob.status}`,
207
+ {
208
+ workflowId: node.workflowId
209
+ }
203
210
  );
204
211
  this.logger.debug(`result of node`, { data: savedJob.result });
205
212
  if (savedJob.status === import_constants.JOB_STATUS.RESOLVED && node.downstream) {
@@ -217,7 +224,9 @@ class Processor {
217
224
  if (typeof instruction.run !== "function") {
218
225
  return Promise.reject(new Error("`run` should be implemented for customized execution of the node"));
219
226
  }
220
- this.logger.info(`execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id})`);
227
+ this.logger.info(`execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id})`, {
228
+ workflowId: node.workflowId
229
+ });
221
230
  return this.exec(instruction.run.bind(instruction), node, input);
222
231
  }
223
232
  // parent node should take over the control
@@ -225,7 +234,9 @@ class Processor {
225
234
  this.logger.debug(`branch ended at node (${node.id})`);
226
235
  const parentNode = this.findBranchParentNode(node);
227
236
  if (parentNode) {
228
- this.logger.debug(`not on main, recall to parent entry node (${node.id})})`);
237
+ this.logger.debug(`not on main, recall to parent entry node (${node.id})})`, {
238
+ workflowId: node.workflowId
239
+ });
229
240
  await this.recall(parentNode, job);
230
241
  return null;
231
242
  }
@@ -242,7 +253,9 @@ class Processor {
242
253
  new Error(`"resume" method should be implemented for [${node.type}] instruction of node (#${node.id})`)
243
254
  );
244
255
  }
245
- this.logger.info(`execution (${this.execution.id}) resume instruction [${node.type}] for node (${node.id})`);
256
+ this.logger.info(`execution (${this.execution.id}) resume instruction [${node.type}] for node (${node.id})`, {
257
+ workflowId: node.workflowId
258
+ });
246
259
  return this.exec(instruction.resume.bind(instruction), node, job);
247
260
  }
248
261
  async exit(s) {
@@ -295,7 +308,9 @@ class Processor {
295
308
  if (this.mainTransaction && this.mainTransaction !== this.transaction) {
296
309
  await this.mainTransaction.commit();
297
310
  }
298
- this.logger.info(`execution (${this.execution.id}) exiting with status ${this.execution.status}`);
311
+ this.logger.info(`execution (${this.execution.id}) exiting with status ${this.execution.status}`, {
312
+ workflowId: this.execution.workflowId
313
+ });
299
314
  return null;
300
315
  }
301
316
  /**
@@ -326,7 +341,9 @@ class Processor {
326
341
  this.lastSavedJob = job;
327
342
  this.jobsMapByNodeKey[job.nodeKey] = job;
328
343
  this.jobResultsMapByNodeKey[job.nodeKey] = job.result;
329
- this.logger.debug(`job added to save list: ${JSON.stringify(job)}`);
344
+ this.logger.debug(`job added to save list: ${JSON.stringify(job)}`, {
345
+ workflowId: this.execution.workflowId
346
+ });
330
347
  return job;
331
348
  }
332
349
  /**
@@ -147,14 +147,20 @@ class CollectionTrigger extends import__.default {
147
147
  };
148
148
  }
149
149
  on(workflow) {
150
- var _a, _b;
150
+ var _a;
151
151
  const { collection, mode } = workflow.config;
152
152
  if (!collection) {
153
153
  return;
154
154
  }
155
155
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
156
- const { db } = ((_b = (_a = this.workflow.app.dataSourceManager) == null ? void 0 : _a.dataSources.get(dataSourceName)) == null ? void 0 : _b.collectionManager) ?? {};
156
+ const dataSource = (_a = this.workflow.app.dataSourceManager) == null ? void 0 : _a.dataSources.get(dataSourceName);
157
+ if (!dataSource) {
158
+ this.workflow.getLogger().warn(`[CollectionTrigger] data source not exists: ${dataSourceName}`);
159
+ return;
160
+ }
161
+ const { db } = dataSource.collectionManager;
157
162
  if (!db || !db.getCollection(collectionName)) {
163
+ this.workflow.getLogger().warn(`[CollectionTrigger] collection not exists: ${dataSourceName}`);
158
164
  return;
159
165
  }
160
166
  for (const [key, type] of MODE_BITMAP_EVENTS.entries()) {
@@ -182,8 +188,14 @@ class CollectionTrigger extends import__.default {
182
188
  return;
183
189
  }
184
190
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
185
- const { db } = ((_a = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName)) == null ? void 0 : _a.collectionManager) ?? {};
191
+ const dataSource = (_a = this.workflow.app.dataSourceManager) == null ? void 0 : _a.dataSources.get(dataSourceName);
192
+ if (!dataSource) {
193
+ this.workflow.getLogger().warn(`[CollectionTrigger] data source not exists: ${dataSourceName}`);
194
+ return;
195
+ }
196
+ const { db } = dataSource.collectionManager;
186
197
  if (!db || !db.getCollection(collectionName)) {
198
+ this.workflow.getLogger().warn(`[CollectionTrigger] collection not exists: ${dataSourceName}`);
187
199
  return;
188
200
  }
189
201
  for (const [key, type] of MODE_BITMAP_EVENTS.entries()) {
@@ -379,6 +379,10 @@ class DateFieldScheduleTrigger {
379
379
  };
380
380
  this.events.set(name, listener);
381
381
  const dataSource = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName);
382
+ if (!dataSource) {
383
+ this.workflow.getLogger().warn(`[Schedule on date field] data source not exists: ${dataSourceName}`);
384
+ return;
385
+ }
382
386
  const { db } = dataSource.collectionManager;
383
387
  db.on(event, listener);
384
388
  }
@@ -396,6 +400,10 @@ class DateFieldScheduleTrigger {
396
400
  const listener = this.events.get(name);
397
401
  if (listener) {
398
402
  const dataSource = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName);
403
+ if (!dataSource) {
404
+ this.workflow.getLogger().warn(`[Schedule on date field] data source not exists: ${dataSourceName}`);
405
+ return;
406
+ }
399
407
  const { db } = dataSource.collectionManager;
400
408
  db.off(event, listener);
401
409
  this.events.delete(name);
package/package.json CHANGED
@@ -2,13 +2,16 @@
2
2
  "name": "@nocobase/plugin-workflow",
3
3
  "displayName": "Workflow",
4
4
  "displayName.zh-CN": "工作流",
5
+ "displayName.ru-RU": "Рабочий процесс",
5
6
  "description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
6
7
  "description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
7
- "version": "1.9.0-beta.16",
8
+ "description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
9
+ "version": "1.9.0-beta.18",
8
10
  "license": "AGPL-3.0",
9
11
  "main": "./dist/server/index.js",
10
12
  "homepage": "https://docs.nocobase.com/handbook/workflow",
11
13
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
14
+ "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/workflow",
12
15
  "devDependencies": {
13
16
  "@ant-design/icons": "5.x",
14
17
  "@formily/antd-v5": "1.x",
@@ -45,7 +48,7 @@
45
48
  "@nocobase/test": "1.x",
46
49
  "@nocobase/utils": "1.x"
47
50
  },
48
- "gitHead": "ff9b917d27840cc08e3f60d02384504ae0e35995",
51
+ "gitHead": "1c211ab8c30d9442c38d07e2ebef2c2935e0fbac",
49
52
  "keywords": [
50
53
  "Workflow"
51
54
  ]