@nocobase/plugin-workflow 0.7.0-alpha.33 → 0.7.0-alpha.56

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.
Files changed (134) hide show
  1. package/lib/actions/index.js +31 -32
  2. package/lib/actions/nodes.js +310 -182
  3. package/lib/actions/workflows.js +260 -157
  4. package/lib/calculators/index.js +142 -90
  5. package/lib/collections/executions.js +40 -43
  6. package/lib/collections/flow_nodes.js +60 -72
  7. package/lib/collections/jobs.js +45 -47
  8. package/lib/collections/workflows.js +78 -87
  9. package/lib/constants.js +22 -17
  10. package/lib/index.js +71 -22
  11. package/lib/instructions/calculation.js +34 -29
  12. package/lib/instructions/condition.js +94 -87
  13. package/lib/instructions/create.d.ts +1 -1
  14. package/lib/instructions/create.js +43 -25
  15. package/lib/instructions/destroy.js +42 -25
  16. package/lib/instructions/index.js +46 -25
  17. package/lib/instructions/parallel.js +99 -84
  18. package/lib/instructions/prompt.js +21 -13
  19. package/lib/instructions/query.js +47 -25
  20. package/lib/instructions/update.d.ts +2 -1
  21. package/lib/instructions/update.js +44 -25
  22. package/lib/models/Execution.js +401 -248
  23. package/lib/models/FlowNode.js +18 -5
  24. package/lib/models/Job.js +18 -5
  25. package/lib/models/Workflow.js +132 -88
  26. package/lib/server.js +93 -66
  27. package/lib/triggers/collection.js +113 -51
  28. package/lib/triggers/index.js +25 -11
  29. package/package.json +7 -12
  30. package/esm/actions/index.d.ts +0 -1
  31. package/esm/actions/index.js +0 -14
  32. package/esm/actions/index.js.map +0 -1
  33. package/esm/actions/nodes.d.ts +0 -4
  34. package/esm/actions/nodes.js +0 -187
  35. package/esm/actions/nodes.js.map +0 -1
  36. package/esm/actions/workflows.d.ts +0 -3
  37. package/esm/actions/workflows.js +0 -163
  38. package/esm/actions/workflows.js.map +0 -1
  39. package/esm/calculators/index.d.ts +0 -38
  40. package/esm/calculators/index.js +0 -128
  41. package/esm/calculators/index.js.map +0 -1
  42. package/esm/collections/executions.d.ts +0 -3
  43. package/esm/collections/executions.js +0 -43
  44. package/esm/collections/executions.js.map +0 -1
  45. package/esm/collections/flow_nodes.d.ts +0 -3
  46. package/esm/collections/flow_nodes.js +0 -72
  47. package/esm/collections/flow_nodes.js.map +0 -1
  48. package/esm/collections/jobs.d.ts +0 -3
  49. package/esm/collections/jobs.js +0 -47
  50. package/esm/collections/jobs.js.map +0 -1
  51. package/esm/collections/workflows.d.ts +0 -3
  52. package/esm/collections/workflows.js +0 -87
  53. package/esm/collections/workflows.js.map +0 -1
  54. package/esm/constants.d.ts +0 -17
  55. package/esm/constants.js +0 -18
  56. package/esm/constants.js.map +0 -1
  57. package/esm/index.d.ts +0 -5
  58. package/esm/index.js +0 -6
  59. package/esm/index.js.map +0 -1
  60. package/esm/instructions/calculation.d.ts +0 -8
  61. package/esm/instructions/calculation.js +0 -55
  62. package/esm/instructions/calculation.js.map +0 -1
  63. package/esm/instructions/condition.d.ts +0 -5
  64. package/esm/instructions/condition.js +0 -99
  65. package/esm/instructions/condition.js.map +0 -1
  66. package/esm/instructions/create.d.ts +0 -8
  67. package/esm/instructions/create.js +0 -25
  68. package/esm/instructions/create.js.map +0 -1
  69. package/esm/instructions/destroy.d.ts +0 -8
  70. package/esm/instructions/destroy.js +0 -25
  71. package/esm/instructions/destroy.js.map +0 -1
  72. package/esm/instructions/index.d.ts +0 -15
  73. package/esm/instructions/index.js +0 -20
  74. package/esm/instructions/index.js.map +0 -1
  75. package/esm/instructions/parallel.d.ts +0 -13
  76. package/esm/instructions/parallel.js +0 -88
  77. package/esm/instructions/parallel.js.map +0 -1
  78. package/esm/instructions/prompt.d.ts +0 -7
  79. package/esm/instructions/prompt.js +0 -13
  80. package/esm/instructions/prompt.js.map +0 -1
  81. package/esm/instructions/query.d.ts +0 -8
  82. package/esm/instructions/query.js +0 -25
  83. package/esm/instructions/query.js.map +0 -1
  84. package/esm/instructions/update.d.ts +0 -8
  85. package/esm/instructions/update.js +0 -25
  86. package/esm/instructions/update.js.map +0 -1
  87. package/esm/models/Execution.d.ts +0 -51
  88. package/esm/models/Execution.js +0 -256
  89. package/esm/models/Execution.js.map +0 -1
  90. package/esm/models/FlowNode.d.ts +0 -17
  91. package/esm/models/FlowNode.js +0 -4
  92. package/esm/models/FlowNode.js.map +0 -1
  93. package/esm/models/Job.d.ts +0 -15
  94. package/esm/models/Job.js +0 -4
  95. package/esm/models/Job.js.map +0 -1
  96. package/esm/models/Workflow.d.ts +0 -29
  97. package/esm/models/Workflow.js +0 -88
  98. package/esm/models/Workflow.js.map +0 -1
  99. package/esm/server.d.ts +0 -5
  100. package/esm/server.js +0 -62
  101. package/esm/server.js.map +0 -1
  102. package/esm/triggers/collection.d.ts +0 -12
  103. package/esm/triggers/collection.js +0 -61
  104. package/esm/triggers/collection.js.map +0 -1
  105. package/esm/triggers/index.d.ts +0 -9
  106. package/esm/triggers/index.js +0 -6
  107. package/esm/triggers/index.js.map +0 -1
  108. package/lib/actions/index.js.map +0 -1
  109. package/lib/actions/nodes.js.map +0 -1
  110. package/lib/actions/workflows.js.map +0 -1
  111. package/lib/calculators/index.js.map +0 -1
  112. package/lib/collections/executions.js.map +0 -1
  113. package/lib/collections/flow_nodes.js.map +0 -1
  114. package/lib/collections/jobs.js.map +0 -1
  115. package/lib/collections/workflows.js.map +0 -1
  116. package/lib/constants.js.map +0 -1
  117. package/lib/index.js.map +0 -1
  118. package/lib/instructions/calculation.js.map +0 -1
  119. package/lib/instructions/condition.js.map +0 -1
  120. package/lib/instructions/create.js.map +0 -1
  121. package/lib/instructions/destroy.js.map +0 -1
  122. package/lib/instructions/index.js.map +0 -1
  123. package/lib/instructions/parallel.js.map +0 -1
  124. package/lib/instructions/prompt.js.map +0 -1
  125. package/lib/instructions/query.js.map +0 -1
  126. package/lib/instructions/update.js.map +0 -1
  127. package/lib/models/Execution.js.map +0 -1
  128. package/lib/models/FlowNode.js.map +0 -1
  129. package/lib/models/Job.js.map +0 -1
  130. package/lib/models/Workflow.js.map +0 -1
  131. package/lib/server.js.map +0 -1
  132. package/lib/triggers/collection.js.map +0 -1
  133. package/lib/triggers/index.js.map +0 -1
  134. package/tsconfig.build.json +0 -9
@@ -1,168 +1,271 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __asyncValues = (this && this.__asyncValues) || function (o) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var m = o[Symbol.asyncIterator], i;
14
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.duplicate = exports.update = void 0;
20
- const actions_1 = require("@nocobase/actions");
21
- const database_1 = require("@nocobase/database");
22
- function update(context, next) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const { db } = context;
25
- const repository = actions_1.utils.getRepositoryFromParams(context);
26
- const { filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } = context.action.params;
27
- context.body = yield db.sequelize.transaction((transaction) => __awaiter(this, void 0, void 0, function* () {
28
- const others = {};
29
- if (values.enabled) {
30
- values.current = true;
31
- others.enabled = false;
32
- }
33
- if (values.current) {
34
- others.current = false;
35
- yield repository.update({
36
- filter: {
37
- key: values.key,
38
- id: {
39
- [database_1.Op.ne]: filterByTk
40
- }
41
- },
42
- values: others,
43
- context,
44
- transaction
45
- });
46
- }
47
- const instance = yield repository.update({
48
- filterByTk,
49
- values,
50
- whitelist,
51
- blacklist,
52
- filter,
53
- updateAssociationValues,
54
- context,
55
- transaction
56
- });
57
- return instance;
58
- }));
59
- yield next();
60
- });
61
- }
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.duplicate = duplicate;
62
7
  exports.update = update;
8
+
9
+ function _actions() {
10
+ const data = require("@nocobase/actions");
11
+
12
+ _actions = function _actions() {
13
+ return data;
14
+ };
15
+
16
+ return data;
17
+ }
18
+
19
+ function _database() {
20
+ const data = require("@nocobase/database");
21
+
22
+ _database = function _database() {
23
+ return data;
24
+ };
25
+
26
+ return data;
27
+ }
28
+
29
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
30
+
31
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
32
+
33
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
34
+
35
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
36
+
37
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
38
+
39
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
40
+
41
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
42
+
43
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
44
+
45
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
46
+
47
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
48
+
49
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
50
+
51
+ function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
52
+
53
+ function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
54
+
55
+ function update(_x, _x2) {
56
+ return _update.apply(this, arguments);
57
+ }
58
+
59
+ function _update() {
60
+ _update = _asyncToGenerator(function* (context, next) {
61
+ const db = context.db;
62
+
63
+ const repository = _actions().utils.getRepositoryFromParams(context);
64
+
65
+ const _context$action$param = context.action.params,
66
+ filterByTk = _context$action$param.filterByTk,
67
+ values = _context$action$param.values,
68
+ whitelist = _context$action$param.whitelist,
69
+ blacklist = _context$action$param.blacklist,
70
+ filter = _context$action$param.filter,
71
+ updateAssociationValues = _context$action$param.updateAssociationValues;
72
+ context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
73
+ var _ref = _asyncToGenerator(function* (transaction) {
74
+ const others = {};
75
+
76
+ if (values.enabled) {
77
+ values.current = true;
78
+ others.enabled = false;
79
+ }
80
+
81
+ if (values.current) {
82
+ others.current = false;
83
+ yield repository.update({
84
+ filter: {
85
+ key: values.key,
86
+ id: {
87
+ [_database().Op.ne]: filterByTk
88
+ }
89
+ },
90
+ values: others,
91
+ context,
92
+ transaction
93
+ });
94
+ }
95
+
96
+ const instance = yield repository.update({
97
+ filterByTk,
98
+ values,
99
+ whitelist,
100
+ blacklist,
101
+ filter,
102
+ updateAssociationValues,
103
+ context,
104
+ transaction
105
+ });
106
+ return instance;
107
+ });
108
+
109
+ return function (_x5) {
110
+ return _ref.apply(this, arguments);
111
+ };
112
+ }());
113
+ yield next();
114
+ });
115
+ return _update.apply(this, arguments);
116
+ }
117
+
63
118
  function typeOf(value) {
64
- if (Array.isArray(value)) {
65
- return 'array';
66
- }
67
- else if (value instanceof Date) {
68
- return 'date';
69
- }
70
- else if (value === null) {
71
- return 'null';
72
- }
73
- return typeof value;
119
+ if (Array.isArray(value)) {
120
+ return 'array';
121
+ } else if (value instanceof Date) {
122
+ return 'date';
123
+ } else if (value === null) {
124
+ return 'null';
125
+ }
126
+
127
+ return typeof value;
74
128
  }
129
+
75
130
  function migrateConfig(config, oldToNew) {
76
- function migrate(value) {
77
- switch (typeOf(value)) {
78
- case 'object':
79
- return Object.keys(value).reduce((result, key) => (Object.assign(Object.assign({}, result), { [key]: migrate(value[key]) })), {});
80
- case 'array':
81
- return value.map(item => migrate(item));
82
- case 'string':
83
- return value
84
- .replace(/(\{\{\$jobsMapByNodeId\.)(\d+)/, (_, prefix, id) => `${prefix}${oldToNew.get(Number.parseInt(id, 10)).id}`);
85
- default:
86
- return value;
87
- }
131
+ function migrate(value) {
132
+ switch (typeOf(value)) {
133
+ case 'object':
134
+ return Object.keys(value).reduce((result, key) => _objectSpread(_objectSpread({}, result), {}, {
135
+ [key]: migrate(value[key])
136
+ }), {});
137
+
138
+ case 'array':
139
+ return value.map(item => migrate(item));
140
+
141
+ case 'string':
142
+ return value.replace(/(\{\{\$jobsMapByNodeId\.)(\d+)/, (_, prefix, id) => `${prefix}${oldToNew.get(Number.parseInt(id, 10)).id}`);
143
+
144
+ default:
145
+ return value;
88
146
  }
89
- return migrate(config);
147
+ }
148
+
149
+ return migrate(config);
90
150
  }
91
- function duplicate(context, next) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const { db } = context;
94
- const repository = actions_1.utils.getRepositoryFromParams(context);
95
- const { filterByTk } = context.action.params;
96
- context.body = yield db.sequelize.transaction((transaction) => __awaiter(this, void 0, void 0, function* () {
97
- var e_1, _a, e_2, _b;
98
- var _c, _d;
99
- const origin = yield repository.findOne({
100
- filterByTk,
101
- appends: ['nodes'],
102
- context,
103
- transaction
104
- });
105
- const instance = yield repository.create({
106
- values: {
107
- key: origin.key,
108
- title: origin.title,
109
- description: origin.description,
110
- type: origin.type,
111
- config: origin.config
112
- },
113
- transaction
114
- });
115
- const originalNodesMap = new Map();
116
- origin.nodes.forEach((node) => {
117
- originalNodesMap.set(node.id, node);
118
- });
119
- const oldToNew = new Map();
120
- const newToOld = new Map();
121
- try {
122
- for (var _e = __asyncValues(origin.nodes), _f; _f = yield _e.next(), !_f.done;) {
123
- const node = _f.value;
124
- const newNode = yield instance.createNode({
125
- type: node.type,
126
- config: node.config,
127
- title: node.title,
128
- branchIndex: node.branchIndex
129
- }, { transaction });
130
- // NOTE: keep original node references for later replacement
131
- oldToNew.set(node.id, newNode);
132
- newToOld.set(newNode.id, node);
133
- }
151
+
152
+ function duplicate(_x3, _x4) {
153
+ return _duplicate.apply(this, arguments);
154
+ }
155
+
156
+ function _duplicate() {
157
+ _duplicate = _asyncToGenerator(function* (context, next) {
158
+ const db = context.db;
159
+
160
+ const repository = _actions().utils.getRepositoryFromParams(context);
161
+
162
+ const filterByTk = context.action.params.filterByTk;
163
+ context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
164
+ var _ref2 = _asyncToGenerator(function* (transaction) {
165
+ const origin = yield repository.findOne({
166
+ filterByTk,
167
+ appends: ['nodes'],
168
+ context,
169
+ transaction
170
+ });
171
+ const instance = yield repository.create({
172
+ values: {
173
+ key: origin.key,
174
+ title: origin.title,
175
+ description: origin.description,
176
+ type: origin.type,
177
+ config: origin.config
178
+ },
179
+ transaction
180
+ });
181
+ const originalNodesMap = new Map();
182
+ origin.nodes.forEach(node => {
183
+ originalNodesMap.set(node.id, node);
184
+ });
185
+ const oldToNew = new Map();
186
+ const newToOld = new Map();
187
+ var _iteratorAbruptCompletion = false;
188
+ var _didIteratorError = false;
189
+
190
+ var _iteratorError;
191
+
192
+ try {
193
+ for (var _iterator = _asyncIterator(origin.nodes), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
194
+ const node = _step.value;
195
+ const newNode = yield instance.createNode({
196
+ type: node.type,
197
+ config: node.config,
198
+ title: node.title,
199
+ branchIndex: node.branchIndex
200
+ }, {
201
+ transaction
202
+ }); // NOTE: keep original node references for later replacement
203
+
204
+ oldToNew.set(node.id, newNode);
205
+ newToOld.set(newNode.id, node);
206
+ }
207
+ } catch (err) {
208
+ _didIteratorError = true;
209
+ _iteratorError = err;
210
+ } finally {
211
+ try {
212
+ if (_iteratorAbruptCompletion && _iterator.return != null) {
213
+ yield _iterator.return();
134
214
  }
135
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
136
- finally {
137
- try {
138
- if (_f && !_f.done && (_a = _e.return)) yield _a.call(_e);
139
- }
140
- finally { if (e_1) throw e_1.error; }
215
+ } finally {
216
+ if (_didIteratorError) {
217
+ throw _iteratorError;
141
218
  }
142
- try {
143
- for (var _g = __asyncValues(oldToNew.entries()), _h; _h = yield _g.next(), !_h.done;) {
144
- const [oldId, newNode] = _h.value;
145
- const oldNode = originalNodesMap.get(oldId);
146
- const newUpstream = oldNode.upstreamId ? oldToNew.get(oldNode.upstreamId) : null;
147
- const newDownstream = oldNode.downstreamId ? oldToNew.get(oldNode.downstreamId) : null;
148
- yield newNode.update({
149
- upstreamId: (_c = newUpstream === null || newUpstream === void 0 ? void 0 : newUpstream.id) !== null && _c !== void 0 ? _c : null,
150
- downstreamId: (_d = newDownstream === null || newDownstream === void 0 ? void 0 : newDownstream.id) !== null && _d !== void 0 ? _d : null,
151
- config: migrateConfig(oldNode.config, oldToNew)
152
- }, { transaction });
153
- }
219
+ }
220
+ }
221
+
222
+ var _iteratorAbruptCompletion2 = false;
223
+ var _didIteratorError2 = false;
224
+
225
+ var _iteratorError2;
226
+
227
+ try {
228
+ for (var _iterator2 = _asyncIterator(oldToNew.entries()), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _iterator2.next()).done; _iteratorAbruptCompletion2 = false) {
229
+ var _newUpstream$id, _newDownstream$id;
230
+
231
+ const _step2$value = _slicedToArray(_step2.value, 2),
232
+ oldId = _step2$value[0],
233
+ newNode = _step2$value[1];
234
+
235
+ const oldNode = originalNodesMap.get(oldId);
236
+ const newUpstream = oldNode.upstreamId ? oldToNew.get(oldNode.upstreamId) : null;
237
+ const newDownstream = oldNode.downstreamId ? oldToNew.get(oldNode.downstreamId) : null;
238
+ yield newNode.update({
239
+ upstreamId: (_newUpstream$id = newUpstream === null || newUpstream === void 0 ? void 0 : newUpstream.id) !== null && _newUpstream$id !== void 0 ? _newUpstream$id : null,
240
+ downstreamId: (_newDownstream$id = newDownstream === null || newDownstream === void 0 ? void 0 : newDownstream.id) !== null && _newDownstream$id !== void 0 ? _newDownstream$id : null,
241
+ config: migrateConfig(oldNode.config, oldToNew)
242
+ }, {
243
+ transaction
244
+ });
245
+ }
246
+ } catch (err) {
247
+ _didIteratorError2 = true;
248
+ _iteratorError2 = err;
249
+ } finally {
250
+ try {
251
+ if (_iteratorAbruptCompletion2 && _iterator2.return != null) {
252
+ yield _iterator2.return();
154
253
  }
155
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
156
- finally {
157
- try {
158
- if (_h && !_h.done && (_b = _g.return)) yield _b.call(_g);
159
- }
160
- finally { if (e_2) throw e_2.error; }
254
+ } finally {
255
+ if (_didIteratorError2) {
256
+ throw _iteratorError2;
161
257
  }
162
- return instance;
163
- }));
164
- yield next();
165
- });
166
- }
167
- exports.duplicate = duplicate;
168
- //# sourceMappingURL=workflows.js.map
258
+ }
259
+ }
260
+
261
+ return instance;
262
+ });
263
+
264
+ return function (_x6) {
265
+ return _ref2.apply(this, arguments);
266
+ };
267
+ }());
268
+ yield next();
269
+ });
270
+ return _duplicate.apply(this, arguments);
271
+ }