@catladder/pipeline 1.41.2 → 1.41.4

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.
@@ -1,5 +1,146 @@
1
1
  "use strict";
2
2
 
3
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) {
5
+ return value instanceof P ? value : new P(function (resolve) {
6
+ resolve(value);
7
+ });
8
+ }
9
+
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) {
12
+ try {
13
+ step(generator.next(value));
14
+ } catch (e) {
15
+ reject(e);
16
+ }
17
+ }
18
+
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+
27
+ function step(result) {
28
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29
+ }
30
+
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+
35
+ var __generator = this && this.__generator || function (thisArg, body) {
36
+ var _ = {
37
+ label: 0,
38
+ sent: function () {
39
+ if (t[0] & 1) throw t[1];
40
+ return t[1];
41
+ },
42
+ trys: [],
43
+ ops: []
44
+ },
45
+ f,
46
+ y,
47
+ t,
48
+ g;
49
+ return g = {
50
+ next: verb(0),
51
+ "throw": verb(1),
52
+ "return": verb(2)
53
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
54
+ return this;
55
+ }), g;
56
+
57
+ function verb(n) {
58
+ return function (v) {
59
+ return step([n, v]);
60
+ };
61
+ }
62
+
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+
66
+ while (_) try {
67
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+
70
+ switch (op[0]) {
71
+ case 0:
72
+ case 1:
73
+ t = op;
74
+ break;
75
+
76
+ case 4:
77
+ _.label++;
78
+ return {
79
+ value: op[1],
80
+ done: false
81
+ };
82
+
83
+ case 5:
84
+ _.label++;
85
+ y = op[1];
86
+ op = [0];
87
+ continue;
88
+
89
+ case 7:
90
+ op = _.ops.pop();
91
+
92
+ _.trys.pop();
93
+
94
+ continue;
95
+
96
+ default:
97
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
98
+ _ = 0;
99
+ continue;
100
+ }
101
+
102
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
103
+ _.label = op[1];
104
+ break;
105
+ }
106
+
107
+ if (op[0] === 6 && _.label < t[1]) {
108
+ _.label = t[1];
109
+ t = op;
110
+ break;
111
+ }
112
+
113
+ if (t && _.label < t[2]) {
114
+ _.label = t[2];
115
+
116
+ _.ops.push(op);
117
+
118
+ break;
119
+ }
120
+
121
+ if (t[2]) _.ops.pop();
122
+
123
+ _.trys.pop();
124
+
125
+ continue;
126
+ }
127
+
128
+ op = body.call(thisArg, _);
129
+ } catch (e) {
130
+ op = [6, e];
131
+ y = 0;
132
+ } finally {
133
+ f = t = 0;
134
+ }
135
+
136
+ if (op[0] & 5) throw op[1];
137
+ return {
138
+ value: op[0] ? op[1] : void 0,
139
+ done: true
140
+ };
141
+ }
142
+ };
143
+
3
144
  var __read = this && this.__read || function (o, n) {
4
145
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
146
  if (!m) return o;
@@ -25,11 +166,19 @@ var __read = this && this.__read || function (o, n) {
25
166
  return ar;
26
167
  };
27
168
 
169
+ var __importDefault = this && this.__importDefault || function (mod) {
170
+ return mod && mod.__esModule ? mod : {
171
+ "default": mod
172
+ };
173
+ };
174
+
28
175
  exports.__esModule = true;
29
176
  exports.translateLegacyFromComponents = exports.resolveReferences = void 0;
30
177
 
31
178
  var lodash_1 = require("lodash");
32
179
 
180
+ var string_replace_async_1 = __importDefault(require("string-replace-async"));
181
+
33
182
  var REGEX = /\$\{(([^:]+):)?([^}]+)}/gm;
34
183
 
35
184
  var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
@@ -37,39 +186,139 @@ var resolveReferences = function (vars, getOtherVariables, alreadyVisitedBase) {
37
186
  alreadyVisitedBase = {};
38
187
  }
39
188
 
40
- var replaceSingleValue = function (value, alreadyVisited) {
41
- if (alreadyVisited === void 0) {
42
- alreadyVisited = alreadyVisitedBase;
43
- }
189
+ return __awaiter(void 0, void 0, void 0, function () {
190
+ var replaceSingleValue, _a, _b;
44
191
 
45
- if (REGEX.test(value)) {
46
- return value.replace(REGEX, function (match, _, componentName, variableName) {
47
- var _a, _b;
192
+ return __generator(this, function (_c) {
193
+ switch (_c.label) {
194
+ case 0:
195
+ replaceSingleValue = function (value, alreadyVisited) {
196
+ if (alreadyVisited === void 0) {
197
+ alreadyVisited = alreadyVisitedBase;
198
+ }
48
199
 
49
- var _c, _d;
200
+ return __awaiter(void 0, void 0, void 0, function () {
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0:
204
+ if (!REGEX.test(value)) return [3
205
+ /*break*/
206
+ , 2];
207
+ return [4
208
+ /*yield*/
209
+ , (0, string_replace_async_1["default"])(value, REGEX, function (match, _, componentName, variableName) {
210
+ return __awaiter(void 0, void 0, void 0, function () {
211
+ var newAlreadyVisited, result, _a, replaced, _b;
50
212
 
51
- if ((_c = alreadyVisited[componentName]) === null || _c === void 0 ? void 0 : _c[variableName]) {
52
- return match; // prevent endless loop
53
- }
213
+ var _c, _d;
54
214
 
55
- var newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_a = {}, _a[componentName] = (_b = {}, _b[variableName] = true, _b), _a));
56
- var result = componentName ? (_d = getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, variableName, newAlreadyVisited)) !== null && _d !== void 0 ? _d : null : vars[variableName]; // is self reference
215
+ var _e, _f;
57
216
 
58
- var replaced = result !== null && result !== undefined ? replaceSingleValue(result, newAlreadyVisited) : match;
59
- return replaced;
60
- });
61
- } else {
62
- return value;
63
- }
64
- };
217
+ return __generator(this, function (_g) {
218
+ switch (_g.label) {
219
+ case 0:
220
+ if ((_e = alreadyVisited[componentName]) === null || _e === void 0 ? void 0 : _e[variableName]) {
221
+ return [2
222
+ /*return*/
223
+ , match]; // prevent endless loop
224
+ }
65
225
 
66
- return Object.fromEntries(Object.entries(vars).map(function (_a) {
67
- var _b = __read(_a, 2),
68
- key = _b[0],
69
- value = _b[1];
226
+ newAlreadyVisited = (0, lodash_1.merge)({}, alreadyVisited, (_c = {}, _c[componentName] = (_d = {}, _d[variableName] = true, _d), _c));
227
+ if (!componentName) return [3
228
+ /*break*/
229
+ , 2];
230
+ return [4
231
+ /*yield*/
232
+ , getOtherVariables === null || getOtherVariables === void 0 ? void 0 : getOtherVariables(componentName, variableName, newAlreadyVisited)];
70
233
 
71
- return [key, replaceSingleValue(value)];
72
- }));
234
+ case 1:
235
+ _a = (_f = _g.sent()) !== null && _f !== void 0 ? _f : null;
236
+ return [3
237
+ /*break*/
238
+ , 3];
239
+
240
+ case 2:
241
+ _a = vars[variableName];
242
+ _g.label = 3;
243
+
244
+ case 3:
245
+ result = _a;
246
+ if (!(result !== null && result !== undefined)) return [3
247
+ /*break*/
248
+ , 5];
249
+ return [4
250
+ /*yield*/
251
+ , replaceSingleValue(result, newAlreadyVisited)];
252
+
253
+ case 4:
254
+ _b = _g.sent();
255
+ return [3
256
+ /*break*/
257
+ , 6];
258
+
259
+ case 5:
260
+ _b = match;
261
+ _g.label = 6;
262
+
263
+ case 6:
264
+ replaced = _b;
265
+ return [2
266
+ /*return*/
267
+ , replaced];
268
+ }
269
+ });
270
+ });
271
+ })];
272
+
273
+ case 1:
274
+ return [2
275
+ /*return*/
276
+ , _a.sent()];
277
+
278
+ case 2:
279
+ return [2
280
+ /*return*/
281
+ , value];
282
+ }
283
+ });
284
+ });
285
+ };
286
+
287
+ _b = (_a = Object).fromEntries;
288
+ return [4
289
+ /*yield*/
290
+ , Promise.all(Object.entries(vars).map(function (_a) {
291
+ var _b = __read(_a, 2),
292
+ key = _b[0],
293
+ value = _b[1];
294
+
295
+ return __awaiter(void 0, void 0, void 0, function () {
296
+ var _c;
297
+
298
+ return __generator(this, function (_d) {
299
+ switch (_d.label) {
300
+ case 0:
301
+ _c = [key];
302
+ return [4
303
+ /*yield*/
304
+ , replaceSingleValue(value)];
305
+
306
+ case 1:
307
+ return [2
308
+ /*return*/
309
+ , _c.concat([_d.sent()])];
310
+ }
311
+ });
312
+ });
313
+ }))];
314
+
315
+ case 1:
316
+ return [2
317
+ /*return*/
318
+ , _b.apply(_a, [_c.sent()])];
319
+ }
320
+ });
321
+ });
73
322
  };
74
323
 
75
324
  exports.resolveReferences = resolveReferences;