@pxp-nd/flow 1.0.95 → 1.0.97

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,32 @@ 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
+ const resControllerAxios = await (0, axios_1.default)(config);
347
+ }
348
+ }
349
+ catch (error) {
350
+ console.error("Not valid json", error);
351
+ }
352
+ }
353
+ }
326
354
  }
327
355
  else {
328
356
  throw new core_1.PxpError(400, 'Please turn off the flow before make a change');
@@ -348,6 +376,38 @@ let Flow = class Flow extends core_1.Controller {
348
376
  const saveNode = await manager.save(newNode);
349
377
  id = saveNode.nodeId;
350
378
  newId = saveNode.nodeId;
379
+ if (newAction.actionType.name === 'CHAINED FLOW') {
380
+ if (newAction === null || newAction === void 0 ? void 0 : newAction.configJsonTemplate) {
381
+ try {
382
+ const parsedConfig = JSON.parse(newAction.configJsonTemplate);
383
+ if (parsedConfig.addController && parsedConfig.template) {
384
+ const params = {
385
+ template: parsedConfig.template,
386
+ flowId,
387
+ };
388
+ const config = {
389
+ method: "post",
390
+ url: `http://localhost:${process.env.PORT}/api/${parsedConfig.addController}`,
391
+ headers: {
392
+ Authorization: "" + process.env.TOKEN_PXP_ND + "",
393
+ "Content-Type": "application/json",
394
+ },
395
+ data: params,
396
+ };
397
+ const resControllerAxios = await (0, axios_1.default)(config);
398
+ const chainedFlowId = (_b = resControllerAxios.data) === null || _b === void 0 ? void 0 : _b.flowId;
399
+ const parsedValues = {
400
+ flowId: chainedFlowId
401
+ };
402
+ saveNode.actionConfigJson = JSON.stringify(parsedValues);
403
+ await manager.save(saveNode);
404
+ }
405
+ }
406
+ catch (error) {
407
+ console.error("Not valid json", error);
408
+ }
409
+ }
410
+ }
351
411
  }
352
412
  else {
353
413
  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.97",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",