@pxp-nd/flow 1.0.95 → 1.0.96

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.
@@ -67,6 +67,7 @@ const Flow_1 = __importDefault(require("../entity/Flow"));
67
67
  const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
68
68
  const NodeInstance_1 = __importDefault(require("../entity/NodeInstance"));
69
69
  const Node_2 = __importDefault(require("./Node"));
70
+ const axios_1 = __importDefault(require("axios"));
70
71
  //import {configFacebookStrategy} from "./passport-facebook";
71
72
  let Flow = class Flow extends core_1.Controller {
72
73
  async get(params) {
@@ -232,6 +233,7 @@ let Flow = class Flow extends core_1.Controller {
232
233
  }
233
234
  }
234
235
  async saveFlow(params, manager) {
236
+ var _a, _b;
235
237
  let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
236
238
  let nodes = params.board.tasks ? params.board.tasks : [];
237
239
  let masterId = null;
@@ -323,6 +325,31 @@ let Flow = class Flow extends core_1.Controller {
323
325
  await manager.query(dNode);
324
326
  }
325
327
  }
328
+ if (flowIdDel.action.actionType.name === 'CHAINED FLOW') {
329
+ if (((_a = flowIdDel.action) === null || _a === void 0 ? void 0 : _a.configJsonTemplate) && flowIdDel.actionConfigJson) {
330
+ try {
331
+ const parsedConfig = JSON.parse(flowIdDel.action.configJsonTemplate);
332
+ const parsedValues = JSON.parse(flowIdDel.actionConfigJson);
333
+ if (parsedConfig.deleteController && parsedValues.flowId) {
334
+ const params = {
335
+ flowId: parsedValues.flowId,
336
+ };
337
+ const config = {
338
+ method: "post",
339
+ url: `http://localhost:${process.env.PORT}/api/${parsedConfig.addController}`,
340
+ headers: {
341
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
342
+ "Content-Type": "application/json",
343
+ },
344
+ data: params,
345
+ };
346
+ }
347
+ }
348
+ catch (error) {
349
+ console.error("Not valid json", error);
350
+ }
351
+ }
352
+ }
326
353
  }
327
354
  else {
328
355
  throw new core_1.PxpError(400, 'Please turn off the flow before make a change');
@@ -348,6 +375,38 @@ let Flow = class Flow extends core_1.Controller {
348
375
  const saveNode = await manager.save(newNode);
349
376
  id = saveNode.nodeId;
350
377
  newId = saveNode.nodeId;
378
+ if (newAction.actionType.name === 'CHAINED FLOW') {
379
+ if (newAction === null || newAction === void 0 ? void 0 : newAction.configJsonTemplate) {
380
+ try {
381
+ const parsedConfig = JSON.parse(newAction.configJsonTemplate);
382
+ if (parsedConfig.addController && parsedConfig.template) {
383
+ const params = {
384
+ template: parsedConfig.template,
385
+ flowId,
386
+ };
387
+ const config = {
388
+ method: "post",
389
+ url: `http://localhost:${process.env.PORT}/api/${parsedConfig.addController}`,
390
+ headers: {
391
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
392
+ "Content-Type": "application/json",
393
+ },
394
+ data: params,
395
+ };
396
+ const resControllerAxios = await (0, axios_1.default)(config);
397
+ const chainedFlowId = (_b = resControllerAxios.data) === null || _b === void 0 ? void 0 : _b.flowId;
398
+ const parsedValues = {
399
+ flowId: chainedFlowId
400
+ };
401
+ saveNode.actionConfigJson = JSON.stringify(parsedValues);
402
+ await manager.save(saveNode);
403
+ }
404
+ }
405
+ catch (error) {
406
+ console.error("Not valid json", error);
407
+ }
408
+ }
409
+ }
351
410
  }
352
411
  else {
353
412
  id = nodeId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.95",
3
+ "version": "1.0.96",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",