@pxp-nd/flow 1.1.15 → 1.1.17

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.
@@ -66,7 +66,6 @@ const Action_1 = __importDefault(require("../entity/Action"));
66
66
  const NodeConnection_1 = __importDefault(require("../entity/NodeConnection"));
67
67
  const Flow_1 = __importDefault(require("../entity/Flow"));
68
68
  const FlowInstance_1 = __importDefault(require("../entity/FlowInstance"));
69
- const NodeInstance_1 = __importDefault(require("../entity/NodeInstance"));
70
69
  const Node_2 = __importDefault(require("./Node"));
71
70
  const axios_1 = __importDefault(require("axios"));
72
71
  //import {configFacebookStrategy} from "./passport-facebook";
@@ -747,21 +746,25 @@ let Flow = class Flow extends core_1.Controller {
747
746
  validFlowInstances.push(flowInstance.flowInstanceId);
748
747
  }
749
748
  else {
749
+ /*Commented because scheduled nodes shouldn't be affected by stopping
750
750
  let flowInstanceId = flowInstance.flowInstanceId;
751
- const totalNI = await NodeInstance_1.default.find({ flowInstanceId, isActive: true });
752
- const nodeInstances = await (0, typeorm_1.getManager)().transaction(async (transactionalEntityManager) => {
753
- const queryBuilder = transactionalEntityManager.createQueryBuilder(NodeInstance_1.default, 'node_instance');
754
- queryBuilder
755
- .where('node_instance.flowInstanceId = :flowInstanceId', { flowInstanceId })
756
- .andWhere('((node_instance.status IS NULL AND (node_instance.schedule = :schedule OR node_instance.schedule IS NULL)) OR (node_instance.status = :status AND node_instance.schedule != :schedule AND node_instance.schedule IS NOT NULL))', {
757
- status: 'executed',
758
- schedule: '0000-00-00 00:00:00',
759
- });
760
- return queryBuilder.getMany();
761
- });
762
- if (totalNI.length > nodeInstances.length) {
763
- validFlowInstances.push(flowInstanceId);
764
- }
751
+ const totalNI = await NodeInstanceModel.find({ flowInstanceId, isActive: true});
752
+ const nodeInstances = await getManager().transaction(async (transactionalEntityManager) => {
753
+ const queryBuilder: SelectQueryBuilder<NodeInstanceModel> = transactionalEntityManager.createQueryBuilder(NodeInstanceModel, 'node_instance');
754
+ queryBuilder
755
+ .where('node_instance.flowInstanceId = :flowInstanceId', { flowInstanceId })
756
+ .andWhere('((node_instance.status IS NULL AND (node_instance.schedule = :schedule OR node_instance.schedule IS NULL)) OR (node_instance.status = :status AND node_instance.schedule != :schedule AND node_instance.schedule IS NOT NULL))', {
757
+ status: 'executed',
758
+ schedule: '0000-00-00 00:00:00',
759
+ });
760
+
761
+ return queryBuilder.getMany();
762
+ });
763
+
764
+
765
+ if (totalNI.length > nodeInstances.length ) {
766
+ validFlowInstances.push(flowInstanceId);
767
+ }*/
765
768
  }
766
769
  }
767
770
  if (validFlowInstances.length > 0) {
@@ -18,5 +18,6 @@ declare class FlowInstance extends Controller {
18
18
  processPending(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
19
19
  eventProcesss(manager: EntityManager): Promise<void>;
20
20
  checkConditions(viewData: Record<string, any>, flowId: number, actionId: number): Promise<boolean>;
21
+ insert(params: Record<string, any>, manager: EntityManager): Promise<unknown>;
21
22
  }
22
23
  export default FlowInstance;
@@ -135,6 +135,18 @@ class FlowInstance extends core_1.Controller {
135
135
  }
136
136
  return res;
137
137
  }
138
+ async insert(params, manager) {
139
+ const { flowId, dataId, status, actionId, originName = '', originKey = '' } = params;
140
+ let flowInstance = new FlowInstance_1.default();
141
+ flowInstance.flowId = flowId;
142
+ flowInstance.dataId = dataId;
143
+ flowInstance.originName = originName;
144
+ flowInstance.originKey = originKey;
145
+ flowInstance.actionId = actionId;
146
+ flowInstance.status = status;
147
+ flowInstance = await manager.save(FlowInstance_1.default, flowInstance);
148
+ return flowInstance;
149
+ }
138
150
  }
139
151
  __decorate([
140
152
  (0, core_1.Post)(),
@@ -145,4 +157,13 @@ __decorate([
145
157
  __metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
146
158
  __metadata("design:returntype", Promise)
147
159
  ], FlowInstance.prototype, "processPending", null);
160
+ __decorate([
161
+ (0, core_1.Post)(),
162
+ (0, core_1.DbSettings)('Orm'),
163
+ (0, core_1.ReadOnly)(false),
164
+ (0, core_1.Log)(true),
165
+ __metadata("design:type", Function),
166
+ __metadata("design:paramtypes", [Object, typeorm_1.EntityManager]),
167
+ __metadata("design:returntype", Promise)
168
+ ], FlowInstance.prototype, "insert", null);
148
169
  exports.default = FlowInstance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",