@mablhq/mabl-cli 2.51.37 → 2.51.42

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findUsedVariables = exports.addUserNamespace = exports.generateVariablesSummaryForExport = exports.generateVariablesSummaryForImport = exports.API_CREDENTIALS_PASSWORD_VARIABLE_NAME = exports.API_CREDENTIALS_USERNAME_VARIABLE_NAME = exports.API_CREDENTIALS_NAMESPACE = exports.API_URL_VARIABLE_NAME = exports.API_NAMESPACE = exports.FLOW_NAMESPACE = exports.USER_NAMESPACE = void 0;
3
+ exports.findUsedVariables = exports.addUserNamespace = exports.addFlowNamespace = exports.generateVariablesSummaryForExport = exports.generateVariablesSummaryForImport = exports.API_CREDENTIALS_PASSWORD_VARIABLE_NAME = exports.API_CREDENTIALS_USERNAME_VARIABLE_NAME = exports.API_CREDENTIALS_NAMESPACE = exports.API_URL_VARIABLE_NAME = exports.API_NAMESPACE = exports.FLOW_NAMESPACE = exports.USER_NAMESPACE = void 0;
4
4
  const domUtil_1 = require("../../domUtil");
5
5
  exports.USER_NAMESPACE = 'user.';
6
6
  exports.FLOW_NAMESPACE = 'flow.';
@@ -10,8 +10,8 @@ exports.API_CREDENTIALS_NAMESPACE = `${exports.API_NAMESPACE}credentials.`;
10
10
  exports.API_CREDENTIALS_USERNAME_VARIABLE_NAME = `${exports.API_CREDENTIALS_NAMESPACE}username`;
11
11
  exports.API_CREDENTIALS_PASSWORD_VARIABLE_NAME = `${exports.API_CREDENTIALS_NAMESPACE}password`;
12
12
  function generateVariablesSummaryForImport(variableSources) {
13
- var _a, _b, _c, _d, _e, _f, _g, _h;
14
- const { environment, scenario, url, credentials, plan, flow, journeyRun, previousFlowVariables, flowConfiguration, } = variableSources;
13
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
14
+ const { environment, scenario, url, credentials, plan, flow, journeyRun, previousFlowVariables, flowConfiguration, test, } = variableSources;
15
15
  const summary = {
16
16
  dataDriven: {},
17
17
  effective: {},
@@ -20,60 +20,75 @@ function generateVariablesSummaryForImport(variableSources) {
20
20
  journey: {},
21
21
  parameters: {},
22
22
  };
23
+ (_b = (_a = test === null || test === void 0 ? void 0 : test.variables) === null || _a === void 0 ? void 0 : _a.inputs) === null || _b === void 0 ? void 0 : _b.forEach((variable) => {
24
+ const name = removeUserNamespace(variable.name);
25
+ const value = variable.default_value;
26
+ summary.journey[name] = value;
27
+ summary.effective[name] = value;
28
+ });
23
29
  const environmentVariables = (environment === null || environment === void 0 ? void 0 : environment.variables) || {};
24
- Object.keys(environmentVariables).forEach((key) => (summary.environment[removeUserNamespace(key)] =
25
- environmentVariables[key]));
30
+ Object.entries(environmentVariables).forEach(([key, value]) => {
31
+ const name = removeUserNamespace(key);
32
+ summary.environment[name] = value;
33
+ summary.effective[name] = value;
34
+ });
26
35
  const planParameters = extractValueParameters(plan === null || plan === void 0 ? void 0 : plan.parameters);
27
- planParameters.forEach((parameter) => (summary.parameters[removeUserNamespace(parameter.name)] =
28
- parameter.value));
36
+ planParameters.forEach((parameter) => {
37
+ const name = removeUserNamespace(parameter.name);
38
+ const { value } = parameter;
39
+ summary.parameters[name] = value;
40
+ summary.effective[name] = value;
41
+ });
29
42
  const journeyParameters = extractValueParameters(journeyRun &&
30
43
  (plan === null || plan === void 0 ? void 0 : plan.execution_stages) &&
31
- ((_c = (_b = (_a = plan.execution_stages[journeyRun.stage_index]) === null || _a === void 0 ? void 0 : _a.journeys) === null || _b === void 0 ? void 0 : _b.find((journey) => journey.journey_id)) === null || _c === void 0 ? void 0 : _c.parameters));
32
- journeyParameters.forEach((parameter) => (summary.parameters[removeUserNamespace(parameter.name)] =
33
- parameter.value));
34
- const journeyInputs = ((_d = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _d === void 0 ? void 0 : _d.imported_variables) || {};
35
- Object.keys(journeyInputs).forEach((key) => (summary.journey[removeUserNamespace(key)] = journeyInputs[key]));
36
- const ddtVariables = ((_f = (_e = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _e === void 0 ? void 0 : _e.user_variables) === null || _f === void 0 ? void 0 : _f.row) ||
44
+ ((_e = (_d = (_c = plan.execution_stages[journeyRun.stage_index]) === null || _c === void 0 ? void 0 : _c.journeys) === null || _d === void 0 ? void 0 : _d.find((journey) => journey.journey_id)) === null || _e === void 0 ? void 0 : _e.parameters));
45
+ journeyParameters.forEach((parameter) => {
46
+ const name = removeUserNamespace(parameter.name);
47
+ const { value } = parameter;
48
+ summary.parameters[name] = value;
49
+ summary.effective[name] = value;
50
+ });
51
+ const journeyInputs = ((_f = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _f === void 0 ? void 0 : _f.imported_variables) || {};
52
+ Object.entries(journeyInputs).forEach(([key, value]) => {
53
+ const name = removeUserNamespace(key);
54
+ summary.journey[name] = value;
55
+ summary.effective[name] = value;
56
+ });
57
+ const ddtVariables = ((_h = (_g = journeyRun === null || journeyRun === void 0 ? void 0 : journeyRun.journey_parameters) === null || _g === void 0 ? void 0 : _g.user_variables) === null || _h === void 0 ? void 0 : _h.row) ||
37
58
  (scenario === null || scenario === void 0 ? void 0 : scenario.variables) ||
38
59
  [];
39
- ddtVariables.forEach((variable) => (summary.dataDriven[removeUserNamespace(variable.name)] =
40
- variable.value));
41
- const precedence = [
42
- summary.environment,
43
- summary.parameters,
44
- summary.journey,
45
- summary.dataDriven,
46
- ];
47
- precedence.forEach((variables) => Object.keys(variables).forEach((name) => (summary.effective[name] = variables[name])));
48
- if (flow === null || flow === void 0 ? void 0 : flow.parameters) {
49
- flow.parameters.forEach((parameter) => {
50
- var _a, _b;
51
- const parameterName = `${exports.FLOW_NAMESPACE}${parameter.name}`;
52
- const parameterValue = (_b = (_a = flowConfiguration === null || flowConfiguration === void 0 ? void 0 : flowConfiguration.parameters) === null || _a === void 0 ? void 0 : _a[parameter.name]) !== null && _b !== void 0 ? _b : parameter.default_value;
53
- summary.flow[parameterName] = parameterValue;
54
- if (!summary.effective[parameterName]) {
55
- summary.effective[parameterName] = parameterValue;
56
- }
57
- });
58
- }
60
+ ddtVariables.forEach((variable) => {
61
+ const name = removeUserNamespace(variable.name);
62
+ const { value } = variable;
63
+ summary.dataDriven[name] = value;
64
+ summary.effective[name] = value;
65
+ });
59
66
  const exportedVariables = previousFlowVariables || {};
60
- Object.keys(exportedVariables).forEach((key) => {
61
- summary.dataDriven[key] = exportedVariables[key];
62
- summary.effective[key] = exportedVariables[key];
67
+ Object.entries(exportedVariables).forEach(([key, value]) => {
68
+ const name = removeUserNamespace(key);
69
+ summary.dataDriven[name] = value;
70
+ summary.effective[name] = value;
71
+ });
72
+ (_j = flow === null || flow === void 0 ? void 0 : flow.parameters) === null || _j === void 0 ? void 0 : _j.forEach((parameter) => {
73
+ var _a, _b;
74
+ const name = removeFlowNamespace(parameter.name);
75
+ const value = (_b = (_a = flowConfiguration === null || flowConfiguration === void 0 ? void 0 : flowConfiguration.parameters) === null || _a === void 0 ? void 0 : _a[parameter.name]) !== null && _b !== void 0 ? _b : parameter.default_value;
76
+ summary.flow[name] = value;
77
+ summary.effective[addFlowNamespace(name)] = value;
63
78
  });
64
79
  if (url) {
65
80
  summary.effective[exports.API_URL_VARIABLE_NAME] = url;
66
81
  }
67
82
  if (credentials) {
68
83
  summary.effective[exports.API_CREDENTIALS_USERNAME_VARIABLE_NAME] =
69
- (_g = credentials.properties) === null || _g === void 0 ? void 0 : _g.username;
84
+ (_k = credentials.properties) === null || _k === void 0 ? void 0 : _k.username;
70
85
  summary.effective[exports.API_CREDENTIALS_PASSWORD_VARIABLE_NAME] =
71
- (_h = credentials.properties) === null || _h === void 0 ? void 0 : _h.password;
86
+ (_l = credentials.properties) === null || _l === void 0 ? void 0 : _l.password;
72
87
  }
73
88
  return summary;
74
89
  }
75
90
  exports.generateVariablesSummaryForImport = generateVariablesSummaryForImport;
76
- function generateVariablesSummaryForExport(testContext, plan, flow, journeyRun, exportedVariables) {
91
+ function generateVariablesSummaryForExport(testContext, plan, test, flow, journeyRun, exportedVariables) {
77
92
  return normalizeVariablesSummaryForExport(generateVariablesSummaryForImport({
78
93
  environment: testContext.environment,
79
94
  url: testContext.url,
@@ -83,6 +98,7 @@ function generateVariablesSummaryForExport(testContext, plan, flow, journeyRun,
83
98
  flow,
84
99
  journeyRun,
85
100
  previousFlowVariables: exportedVariables,
101
+ test,
86
102
  }));
87
103
  }
88
104
  exports.generateVariablesSummaryForExport = generateVariablesSummaryForExport;
@@ -91,7 +107,7 @@ function normalizeVariablesSummaryForExport(summary) {
91
107
  dataDriven: addUserNamespaceToVariableNames(sanitizeVariables(summary.dataDriven)),
92
108
  effective: sanitizeVariables(summary.effective),
93
109
  environment: addUserNamespaceToVariableNames(sanitizeVariables(summary.environment)),
94
- flow: addPrefixToVariableNames(sanitizeVariables(summary.flow), exports.FLOW_NAMESPACE),
110
+ flow: addFlowNamespaceToVariableNames(sanitizeVariables(summary.flow)),
95
111
  journey: addUserNamespaceToVariableNames(sanitizeVariables(summary.journey)),
96
112
  parameters: addUserNamespaceToVariableNames(sanitizeVariables(summary.parameters)),
97
113
  };
@@ -103,6 +119,9 @@ function sanitizeVariables(variables) {
103
119
  .forEach((name) => (sanitizedVariables[name] = variables[name]));
104
120
  return sanitizedVariables;
105
121
  }
122
+ function addFlowNamespaceToVariableNames(variables) {
123
+ return addPrefixToVariableNames(variables, exports.FLOW_NAMESPACE);
124
+ }
106
125
  function addUserNamespaceToVariableNames(variables) {
107
126
  return addPrefixToVariableNames(variables, exports.USER_NAMESPACE);
108
127
  }
@@ -125,6 +144,9 @@ function extractValueParameters(parameters) {
125
144
  }
126
145
  return parameters.filter((parameter) => { var _a; return ((_a = parameter.type) === null || _a === void 0 ? void 0 : _a.toString()) === 'value'; });
127
146
  }
147
+ function removeFlowNamespace(variableName) {
148
+ return removePrefix(variableName, exports.FLOW_NAMESPACE);
149
+ }
128
150
  function removeUserNamespace(variableName) {
129
151
  return removePrefix(variableName, exports.USER_NAMESPACE);
130
152
  }
@@ -134,6 +156,10 @@ function removePrefix(variableName, prefix) {
134
156
  }
135
157
  return variableName;
136
158
  }
159
+ function addFlowNamespace(variableName) {
160
+ return addPrefix(variableName, exports.FLOW_NAMESPACE);
161
+ }
162
+ exports.addFlowNamespace = addFlowNamespace;
137
163
  function addUserNamespace(variableName) {
138
164
  return addPrefix(variableName, exports.USER_NAMESPACE);
139
165
  }