@commercetools-frontend/mc-scripts 22.2.0 → 22.3.0
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.
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +51 -41
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +51 -41
- package/dist/{build-02d316bd.esm.js → build-8227e71d.esm.js} +22 -31
- package/dist/{build-aed21f37.cjs.dev.js → build-a888cacd.cjs.dev.js} +22 -31
- package/dist/{build-0a80531f.cjs.prod.js → build-a9f085a0.cjs.prod.js} +22 -31
- package/dist/{build-vite-2dc2b366.cjs.prod.js → build-vite-1ba28dd8.cjs.prod.js} +18 -19
- package/dist/{build-vite-290aaf04.esm.js → build-vite-9de4820c.esm.js} +18 -19
- package/dist/{build-vite-b5c7ac91.cjs.dev.js → build-vite-e7a6315c.cjs.dev.js} +18 -19
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +2 -3
- package/dist/commercetools-frontend-mc-scripts.esm.js +2 -3
- package/dist/{compile-html-41195e35.cjs.dev.js → compile-html-079067bd.cjs.prod.js} +1 -7
- package/dist/{compile-html-5abd78aa.cjs.prod.js → compile-html-3ff2fed0.cjs.dev.js} +1 -7
- package/dist/{compile-html-f9de842c.esm.js → compile-html-606b302e.esm.js} +1 -7
- package/dist/{config-sync-ed18a088.cjs.prod.js → config-sync-058dca05.cjs.prod.js} +81 -193
- package/dist/{config-sync-64575302.cjs.dev.js → config-sync-866d8c22.cjs.dev.js} +83 -194
- package/dist/{config-sync-78a1327e.esm.js → config-sync-dc5a68ed.esm.js} +83 -194
- package/dist/{create-postcss-config-e91e13f4.esm.js → create-postcss-config-9d266de4.esm.js} +9 -13
- package/dist/{create-postcss-config-552fce51.cjs.dev.js → create-postcss-config-a29e83fc.cjs.dev.js} +9 -13
- package/dist/{create-postcss-config-19002549.cjs.prod.js → create-postcss-config-d4f8ca51.cjs.prod.js} +9 -13
- package/dist/{create-webpack-config-for-development-b56d7c4e.cjs.prod.js → create-webpack-config-for-development-02fa9041.cjs.prod.js} +46 -37
- package/dist/{create-webpack-config-for-development-0a2ffd8e.esm.js → create-webpack-config-for-development-17376d1f.esm.js} +46 -37
- package/dist/{create-webpack-config-for-development-5c2ea60f.cjs.dev.js → create-webpack-config-for-development-ac4ad0b2.cjs.dev.js} +46 -37
- package/dist/{create-webpack-config-for-production-e1d05d7a.cjs.prod.js → create-webpack-config-for-production-190c7797.cjs.prod.js} +37 -32
- package/dist/{create-webpack-config-for-production-40bdef05.esm.js → create-webpack-config-for-production-25d7c593.esm.js} +37 -32
- package/dist/{create-webpack-config-for-production-9c45b356.cjs.dev.js → create-webpack-config-for-production-c1ec1058.cjs.dev.js} +37 -32
- package/dist/{credentials-storage-84a6e074.esm.js → credentials-storage-5a3b88be.esm.js} +3 -15
- package/dist/{credentials-storage-304b7805.cjs.dev.js → credentials-storage-5d3da1c0.cjs.prod.js} +3 -15
- package/dist/{credentials-storage-22418387.cjs.prod.js → credentials-storage-6c51d561.cjs.dev.js} +3 -15
- package/dist/declarations/src/generated/settings.d.ts +90 -1172
- package/dist/{has-jsx-runtime-0b03b72e.cjs.prod.js → has-jsx-runtime-aa5d21ee.cjs.dev.js} +0 -2
- package/dist/{has-jsx-runtime-3d4bb633.cjs.dev.js → has-jsx-runtime-c3202df5.cjs.prod.js} +0 -2
- package/dist/{has-jsx-runtime-8314226e.esm.js → has-jsx-runtime-e3ecb09b.esm.js} +0 -2
- package/dist/{login-059d867b.cjs.dev.js → login-0dc4f62a.cjs.prod.js} +12 -23
- package/dist/{login-10f1c74d.esm.js → login-1b051481.esm.js} +12 -23
- package/dist/{login-144bca7b.cjs.prod.js → login-9f35d543.cjs.dev.js} +12 -23
- package/dist/{package-15989579.cjs.dev.js → package-46d27f5f.cjs.dev.js} +15 -13
- package/dist/{package-ca4ca6d5.esm.js → package-4fcd2667.esm.js} +15 -13
- package/dist/{package-cf9c43de.cjs.prod.js → package-6ee0354d.cjs.prod.js} +15 -13
- package/dist/{paths-284c77fb.cjs.prod.js → paths-854af5ef.cjs.prod.js} +8 -12
- package/dist/{paths-db35ac0f.cjs.dev.js → paths-d1febc82.cjs.dev.js} +8 -12
- package/dist/{paths-55c5d5a2.esm.js → paths-ded20ae1.esm.js} +8 -12
- package/dist/{serve-b8063204.cjs.dev.js → serve-12571b42.cjs.prod.js} +1 -2
- package/dist/{serve-660e2ee0.esm.js → serve-65b5a149.esm.js} +1 -2
- package/dist/{serve-41077dad.cjs.prod.js → serve-7339c495.cjs.dev.js} +1 -2
- package/dist/{start-a6039c83.cjs.dev.js → start-216f84b7.cjs.dev.js} +26 -34
- package/dist/{start-72100470.esm.js → start-4a922c4f.esm.js} +26 -34
- package/dist/{start-03117482.cjs.prod.js → start-b2e2dab7.cjs.prod.js} +26 -34
- package/dist/{start-vite-8f03b0df.cjs.dev.js → start-vite-3966d625.cjs.dev.js} +18 -17
- package/dist/{start-vite-324af14d.cjs.prod.js → start-vite-5c78605b.cjs.prod.js} +18 -17
- package/dist/{start-vite-7d10ae71.esm.js → start-vite-cf0213a1.esm.js} +18 -17
- package/dist/{vite-plugin-svgr-f17db78a.esm.js → vite-plugin-svgr-5c953fe7.esm.js} +1 -6
- package/dist/{vite-plugin-svgr-fdb37ccf.cjs.dev.js → vite-plugin-svgr-5eb1c511.cjs.dev.js} +1 -6
- package/dist/{vite-plugin-svgr-9a4e7f77.cjs.prod.js → vite-plugin-svgr-a732f8df.cjs.prod.js} +1 -6
- package/package.json +31 -17
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +2 -2
- package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +2 -2
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +6 -6
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +6 -6
|
@@ -10,7 +10,7 @@ var chalk = require('chalk');
|
|
|
10
10
|
var omit = require('lodash/omit');
|
|
11
11
|
var prompts = require('prompts');
|
|
12
12
|
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
13
|
-
var credentialsStorage$2 = require('./credentials-storage-
|
|
13
|
+
var credentialsStorage$2 = require('./credentials-storage-6c51d561.cjs.dev.js');
|
|
14
14
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
15
15
|
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
16
16
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
@@ -27,7 +27,7 @@ var graphql = require('graphql');
|
|
|
27
27
|
var graphqlRequest = require('graphql-request');
|
|
28
28
|
var constants = require('@commercetools-frontend/constants');
|
|
29
29
|
require('@commercetools/http-user-agent');
|
|
30
|
-
require('./package-
|
|
30
|
+
require('./package-46d27f5f.cjs.dev.js');
|
|
31
31
|
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
32
32
|
require('@babel/runtime-corejs3/helpers/createClass');
|
|
33
33
|
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
@@ -58,64 +58,52 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
58
58
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
59
59
|
|
|
60
60
|
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
61
|
-
|
|
62
61
|
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var _context20, _context21; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context20 = ownKeys$1(Object(source), !0)).call(_context20, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context21 = ownKeys$1(Object(source))).call(_context21, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
63
|
-
// during tests the color used is appended before the string instead of coloring it.
|
|
64
62
|
|
|
63
|
+
// Since not all terminal supports colors, to make things more consistent for testing purposes,
|
|
64
|
+
// during tests the color used is appended before the string instead of coloring it.
|
|
65
65
|
const isTest = process.env.NODE_ENV === 'test';
|
|
66
|
-
|
|
67
66
|
const red = str => {
|
|
68
67
|
if (isTest) return "<color-red>".concat(str, "</color-red>");
|
|
69
68
|
return chalk__default["default"].red(str);
|
|
70
69
|
};
|
|
71
|
-
|
|
72
70
|
const green = str => {
|
|
73
71
|
if (isTest) return "<color-green>".concat(str, "</color-green>");
|
|
74
72
|
return chalk__default["default"].green(str);
|
|
75
|
-
};
|
|
76
|
-
|
|
73
|
+
};
|
|
77
74
|
|
|
75
|
+
// Two spaces are used for indentation.
|
|
78
76
|
const indent = indentLevel => {
|
|
79
77
|
var _context;
|
|
80
|
-
|
|
81
78
|
return _repeatInstanceProperty__default["default"](_context = ' ').call(_context, indentLevel);
|
|
82
79
|
};
|
|
83
|
-
|
|
84
80
|
const getStringDiff = _ref => {
|
|
85
81
|
let previousValue = _ref.previousValue,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
nextValue = _ref.nextValue,
|
|
83
|
+
label = _ref.label,
|
|
84
|
+
_ref$indentLevel = _ref.indentLevel,
|
|
85
|
+
indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
|
|
91
86
|
if (!previousValue && nextValue) {
|
|
92
87
|
var _context2, _context3;
|
|
93
|
-
|
|
94
88
|
return _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(indent(indentLevel))).call(_context3, label, " added: ")).call(_context2, green(nextValue));
|
|
95
89
|
}
|
|
96
|
-
|
|
97
90
|
if (previousValue && !nextValue) {
|
|
98
91
|
var _context4, _context5;
|
|
99
|
-
|
|
100
92
|
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(indent(indentLevel))).call(_context5, label, " removed: ")).call(_context4, red(previousValue));
|
|
101
93
|
}
|
|
102
|
-
|
|
103
94
|
if (previousValue && nextValue && previousValue !== nextValue) {
|
|
104
95
|
var _context6, _context7, _context8;
|
|
105
|
-
|
|
106
96
|
return _concatInstanceProperty__default["default"](_context6 = _concatInstanceProperty__default["default"](_context7 = _concatInstanceProperty__default["default"](_context8 = "".concat(indent(indentLevel))).call(_context8, label, " changed: ")).call(_context7, red(previousValue), " => ")).call(_context6, green(nextValue));
|
|
107
97
|
}
|
|
108
|
-
|
|
109
98
|
return null;
|
|
110
99
|
};
|
|
111
|
-
|
|
112
100
|
// NOTE: this assumes that the array values are scalar values (not objects).
|
|
113
101
|
const getArrayDiff = _ref2 => {
|
|
114
102
|
let previousValue = _ref2.previousValue,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
nextValue = _ref2.nextValue,
|
|
104
|
+
label = _ref2.label,
|
|
105
|
+
_ref2$indentLevel = _ref2.indentLevel,
|
|
106
|
+
indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
|
|
119
107
|
const oldArraySet = new _Set__default["default"](previousValue);
|
|
120
108
|
const arrayDiff = [];
|
|
121
109
|
nextValue === null || nextValue === void 0 ? void 0 : _forEachInstanceProperty__default["default"](nextValue).call(nextValue, item => {
|
|
@@ -129,7 +117,6 @@ const getArrayDiff = _ref2 => {
|
|
|
129
117
|
}));
|
|
130
118
|
}
|
|
131
119
|
});
|
|
132
|
-
|
|
133
120
|
_forEachInstanceProperty__default["default"](oldArraySet).call(oldArraySet, item => {
|
|
134
121
|
arrayDiff.push(getStringDiff({
|
|
135
122
|
previousValue: item,
|
|
@@ -137,37 +124,31 @@ const getArrayDiff = _ref2 => {
|
|
|
137
124
|
indentLevel
|
|
138
125
|
}));
|
|
139
126
|
});
|
|
140
|
-
|
|
141
127
|
return arrayDiff.join('\n');
|
|
142
128
|
};
|
|
143
|
-
|
|
144
129
|
const getPermissionsDiff = _ref3 => {
|
|
145
130
|
var _context11;
|
|
146
|
-
|
|
147
131
|
let previousValue = _ref3.previousValue,
|
|
148
|
-
|
|
132
|
+
nextValue = _ref3.nextValue;
|
|
149
133
|
const permissionDiff = ['permissions changed'];
|
|
150
|
-
|
|
151
134
|
const mappedOldPermissions = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousPermission, _ref4) => {
|
|
152
135
|
let name = _ref4.name,
|
|
153
|
-
|
|
136
|
+
oAuthScopes = _ref4.oAuthScopes;
|
|
154
137
|
return _objectSpread$1(_objectSpread$1({}, previousPermission), {}, {
|
|
155
138
|
[name]: oAuthScopes
|
|
156
139
|
});
|
|
157
140
|
}, {});
|
|
158
|
-
|
|
159
141
|
const indentLevel = 1;
|
|
160
|
-
|
|
161
142
|
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newPermission => {
|
|
162
143
|
var _context9;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
144
|
+
const currentDiff = [_concatInstanceProperty__default["default"](_context9 = "".concat(indent(indentLevel), "\"")).call(_context9, newPermission.name, "\" changed")];
|
|
145
|
+
// if the permission name is not in the old config, it means it is a new addition.
|
|
166
146
|
if (!mappedOldPermissions[newPermission.name]) {
|
|
167
147
|
var _context10;
|
|
168
|
-
|
|
169
148
|
permissionDiff.push(_concatInstanceProperty__default["default"](_context10 = "".concat(indent(indentLevel), "\"")).call(_context10, green(newPermission.name), "\" was added"));
|
|
170
|
-
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// if permission name is in the old config, now we check if there was a change
|
|
171
152
|
else {
|
|
172
153
|
currentDiff.push(getArrayDiff({
|
|
173
154
|
previousValue: mappedOldPermissions[newPermission.name],
|
|
@@ -177,50 +158,40 @@ const getPermissionsDiff = _ref3 => {
|
|
|
177
158
|
}));
|
|
178
159
|
delete mappedOldPermissions[newPermission.name];
|
|
179
160
|
}
|
|
180
|
-
|
|
181
161
|
_filterInstanceProperty__default["default"](currentDiff).call(currentDiff, Boolean).length > 1 && permissionDiff.push(currentDiff.join('\n'));
|
|
182
|
-
});
|
|
183
|
-
|
|
162
|
+
});
|
|
184
163
|
|
|
164
|
+
// if there are old permissions left, it means they were deleted in the new Permissions.
|
|
185
165
|
_forEachInstanceProperty__default["default"](_context11 = _Object$keys__default["default"](mappedOldPermissions)).call(_context11, oldPermissionName => {
|
|
186
166
|
var _context12;
|
|
187
|
-
|
|
188
167
|
permissionDiff.push(_concatInstanceProperty__default["default"](_context12 = "".concat(indent(indentLevel), "\"")).call(_context12, red(oldPermissionName), "\" was removed"));
|
|
189
168
|
});
|
|
190
|
-
|
|
191
169
|
if (permissionDiff.length > 1) return permissionDiff.join('\n');
|
|
192
170
|
return null;
|
|
193
171
|
};
|
|
194
|
-
|
|
195
172
|
const getLabelAllLocalesDiff = _ref5 => {
|
|
196
173
|
var _context16;
|
|
197
|
-
|
|
198
174
|
let _ref5$previousValue = _ref5.previousValue,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
175
|
+
previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
|
|
176
|
+
_ref5$nextValue = _ref5.nextValue,
|
|
177
|
+
nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
|
|
178
|
+
_ref5$indentLevel = _ref5.indentLevel,
|
|
179
|
+
indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
|
|
204
180
|
const labelAllLocalesDiff = ["".concat(indent(indentLevel - 1), "labelAllLocales changed")];
|
|
205
|
-
|
|
206
181
|
const mappedOldLabelAllLocales = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousLabelAllLocale, _ref6) => {
|
|
207
182
|
let locale = _ref6.locale,
|
|
208
|
-
|
|
183
|
+
value = _ref6.value;
|
|
209
184
|
return _objectSpread$1(_objectSpread$1({}, previousLabelAllLocale), {}, {
|
|
210
185
|
[locale]: value
|
|
211
186
|
});
|
|
212
187
|
}, {});
|
|
213
|
-
|
|
214
188
|
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newLabelAllLocale => {
|
|
215
189
|
if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
|
|
216
190
|
const oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
217
|
-
|
|
218
191
|
if (oldLocaleValue !== newLabelAllLocale.value) {
|
|
219
192
|
var _context13, _context14, _context15;
|
|
220
|
-
|
|
221
193
|
labelAllLocalesDiff.push(_concatInstanceProperty__default["default"](_context13 = _concatInstanceProperty__default["default"](_context14 = _concatInstanceProperty__default["default"](_context15 = "".concat(indent(indentLevel), "locale \"")).call(_context15, newLabelAllLocale.locale, "\" changed: ")).call(_context14, red(oldLocaleValue), " => ")).call(_context13, green(newLabelAllLocale.value)));
|
|
222
194
|
}
|
|
223
|
-
|
|
224
195
|
delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
|
|
225
196
|
} else {
|
|
226
197
|
const localeDiff = getStringDiff({
|
|
@@ -228,32 +199,27 @@ const getLabelAllLocalesDiff = _ref5 => {
|
|
|
228
199
|
label: 'locale',
|
|
229
200
|
indentLevel
|
|
230
201
|
});
|
|
231
|
-
|
|
232
202
|
if (localeDiff) {
|
|
233
203
|
labelAllLocalesDiff.push(localeDiff);
|
|
234
204
|
}
|
|
235
205
|
}
|
|
236
206
|
});
|
|
237
|
-
|
|
238
207
|
_forEachInstanceProperty__default["default"](_context16 = _Object$keys__default["default"](mappedOldLabelAllLocales)).call(_context16, key => {
|
|
239
208
|
const localeDiff = getStringDiff({
|
|
240
209
|
previousValue: key,
|
|
241
210
|
label: 'locale',
|
|
242
211
|
indentLevel
|
|
243
212
|
});
|
|
244
|
-
|
|
245
213
|
if (localeDiff) {
|
|
246
214
|
labelAllLocalesDiff.push(localeDiff);
|
|
247
215
|
}
|
|
248
216
|
});
|
|
249
|
-
|
|
250
217
|
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
251
218
|
return null;
|
|
252
219
|
};
|
|
253
|
-
|
|
254
220
|
const getMainMenuLinkDiff = _ref7 => {
|
|
255
221
|
let previousValue = _ref7.previousValue,
|
|
256
|
-
|
|
222
|
+
nextValue = _ref7.nextValue;
|
|
257
223
|
const mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
258
224
|
const menuDiff = getStringDiff({
|
|
259
225
|
previousValue: previousValue.defaultLabel,
|
|
@@ -261,58 +227,44 @@ const getMainMenuLinkDiff = _ref7 => {
|
|
|
261
227
|
label: 'defaultLabel',
|
|
262
228
|
indentLevel: 1
|
|
263
229
|
});
|
|
264
|
-
|
|
265
230
|
if (menuDiff) {
|
|
266
231
|
mainMenuLinkDiff.push(menuDiff);
|
|
267
232
|
}
|
|
268
|
-
|
|
269
233
|
const mainMenuLinkPermissionsDiff = getArrayDiff({
|
|
270
234
|
previousValue: previousValue.permissions,
|
|
271
235
|
nextValue: nextValue.permissions,
|
|
272
236
|
label: 'applied permission',
|
|
273
237
|
indentLevel: 2
|
|
274
238
|
});
|
|
275
|
-
|
|
276
239
|
if (mainMenuLinkPermissionsDiff.length > 0) {
|
|
277
240
|
mainMenuLinkDiff.push("".concat(indent(1), "permissions changed"));
|
|
278
241
|
mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
|
|
279
242
|
}
|
|
280
|
-
|
|
281
243
|
const menuLabelsDiff = getLabelAllLocalesDiff({
|
|
282
244
|
previousValue: previousValue.labelAllLocales,
|
|
283
245
|
nextValue: nextValue.labelAllLocales,
|
|
284
246
|
indentLevel: 2
|
|
285
247
|
});
|
|
286
|
-
|
|
287
248
|
if (menuLabelsDiff) {
|
|
288
249
|
mainMenuLinkDiff.push(menuLabelsDiff);
|
|
289
250
|
}
|
|
290
|
-
|
|
291
251
|
const filteredMainMenuLinkDiff = _filterInstanceProperty__default["default"](mainMenuLinkDiff).call(mainMenuLinkDiff, Boolean);
|
|
292
|
-
|
|
293
252
|
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
294
253
|
return null;
|
|
295
254
|
};
|
|
296
|
-
|
|
297
255
|
const getSubmenuLinksDiff = _ref8 => {
|
|
298
256
|
var _context19;
|
|
299
|
-
|
|
300
257
|
let previousValue = _ref8.previousValue,
|
|
301
|
-
|
|
258
|
+
nextValue = _ref8.nextValue;
|
|
302
259
|
const submenuLinksDiff = ['submenuLink changed'];
|
|
303
|
-
|
|
304
260
|
const mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread$1(_objectSpread$1({}, previousSubmenuLink), {}, {
|
|
305
261
|
[currentSubmenuLink.uriPath]: currentSubmenuLink
|
|
306
262
|
}), {});
|
|
307
|
-
|
|
308
263
|
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
|
|
309
264
|
const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
310
|
-
|
|
311
265
|
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
312
266
|
var _context17, _context18;
|
|
313
|
-
|
|
314
267
|
const submenuLinkDiff = [_concatInstanceProperty__default["default"](_context17 = "".concat(indent(1), "menu link \"")).call(_context17, newSubmenuLink.uriPath, "\" changed")];
|
|
315
|
-
|
|
316
268
|
_forEachInstanceProperty__default["default"](_context18 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context18, key => {
|
|
317
269
|
switch (key) {
|
|
318
270
|
case 'defaultLabel':
|
|
@@ -323,14 +275,11 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
323
275
|
label: 'defaultLabel',
|
|
324
276
|
indentLevel: 2
|
|
325
277
|
});
|
|
326
|
-
|
|
327
278
|
if (labelDiff) {
|
|
328
279
|
submenuLinkDiff.push(labelDiff);
|
|
329
280
|
}
|
|
330
|
-
|
|
331
281
|
break;
|
|
332
282
|
}
|
|
333
|
-
|
|
334
283
|
case 'permissions':
|
|
335
284
|
{
|
|
336
285
|
const submenuLinkPermissionsDiff = getArrayDiff({
|
|
@@ -339,15 +288,12 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
339
288
|
label: 'applied permission',
|
|
340
289
|
indentLevel: 3
|
|
341
290
|
});
|
|
342
|
-
|
|
343
291
|
if (submenuLinkPermissionsDiff.length > 0) {
|
|
344
292
|
submenuLinkDiff.push("".concat(indent(2), "permissions changed"));
|
|
345
293
|
submenuLinkDiff.push(submenuLinkPermissionsDiff);
|
|
346
294
|
}
|
|
347
|
-
|
|
348
295
|
break;
|
|
349
296
|
}
|
|
350
|
-
|
|
351
297
|
case 'labelAllLocales':
|
|
352
298
|
{
|
|
353
299
|
const labelsDiff = getLabelAllLocalesDiff({
|
|
@@ -355,20 +301,15 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
355
301
|
nextValue: newSubmenuLink.labelAllLocales,
|
|
356
302
|
indentLevel: 3
|
|
357
303
|
});
|
|
358
|
-
|
|
359
304
|
if (labelsDiff) {
|
|
360
305
|
submenuLinkDiff.push(labelsDiff);
|
|
361
306
|
}
|
|
362
|
-
|
|
363
307
|
break;
|
|
364
308
|
}
|
|
365
309
|
}
|
|
366
310
|
});
|
|
367
|
-
|
|
368
311
|
delete mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
369
|
-
|
|
370
312
|
const filteredSubmenuLinksDiff = _filterInstanceProperty__default["default"](submenuLinkDiff).call(submenuLinkDiff, Boolean);
|
|
371
|
-
|
|
372
313
|
if (filteredSubmenuLinksDiff.length > 1) {
|
|
373
314
|
submenuLinksDiff.push(filteredSubmenuLinksDiff.join('\n'));
|
|
374
315
|
}
|
|
@@ -378,13 +319,11 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
378
319
|
label: 'menu link',
|
|
379
320
|
indentLevel: 1
|
|
380
321
|
});
|
|
381
|
-
|
|
382
322
|
if (linksDiff) {
|
|
383
323
|
submenuLinksDiff.push(linksDiff);
|
|
384
324
|
}
|
|
385
325
|
}
|
|
386
326
|
});
|
|
387
|
-
|
|
388
327
|
_forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context19, key => {
|
|
389
328
|
const linksDiff = getStringDiff({
|
|
390
329
|
previousValue: key,
|
|
@@ -393,49 +332,46 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
393
332
|
});
|
|
394
333
|
if (linksDiff) submenuLinksDiff.push(linksDiff);
|
|
395
334
|
});
|
|
396
|
-
|
|
397
335
|
if (submenuLinksDiff.length > 1) return submenuLinksDiff.join('\n');
|
|
398
336
|
return null;
|
|
399
|
-
};
|
|
400
|
-
// NOTE: Only known keys are evaluated.
|
|
401
|
-
|
|
337
|
+
};
|
|
402
338
|
|
|
339
|
+
// Compute diff changes of the Custom Application config.
|
|
340
|
+
// NOTE: Only known keys are evaluated.
|
|
403
341
|
const getConfigDiff = (oldConfig, newConfig) => {
|
|
404
|
-
const diff = [];
|
|
342
|
+
const diff = [];
|
|
405
343
|
|
|
344
|
+
// Name
|
|
406
345
|
const nameDiff = getStringDiff({
|
|
407
346
|
previousValue: oldConfig.name,
|
|
408
347
|
nextValue: newConfig.name,
|
|
409
348
|
label: 'name'
|
|
410
349
|
});
|
|
411
|
-
|
|
412
350
|
if (nameDiff) {
|
|
413
351
|
diff.push(nameDiff);
|
|
414
|
-
}
|
|
415
|
-
|
|
352
|
+
}
|
|
416
353
|
|
|
354
|
+
// Description
|
|
417
355
|
const descriptionDiff = getStringDiff({
|
|
418
356
|
previousValue: oldConfig.description,
|
|
419
357
|
nextValue: newConfig.description,
|
|
420
358
|
label: 'description'
|
|
421
359
|
});
|
|
422
|
-
|
|
423
360
|
if (descriptionDiff) {
|
|
424
361
|
diff.push(descriptionDiff);
|
|
425
|
-
}
|
|
426
|
-
|
|
362
|
+
}
|
|
427
363
|
|
|
364
|
+
// URL
|
|
428
365
|
const urlDiff = getStringDiff({
|
|
429
366
|
previousValue: oldConfig.url,
|
|
430
367
|
nextValue: newConfig.url,
|
|
431
368
|
label: 'url'
|
|
432
369
|
});
|
|
433
|
-
|
|
434
370
|
if (urlDiff) {
|
|
435
371
|
diff.push(urlDiff);
|
|
436
|
-
}
|
|
437
|
-
|
|
372
|
+
}
|
|
438
373
|
|
|
374
|
+
// Icon
|
|
439
375
|
const iconDiff = getStringDiff({
|
|
440
376
|
// This icon stored in the database has already been sanitized.
|
|
441
377
|
previousValue: oldConfig.icon,
|
|
@@ -444,53 +380,48 @@ const getConfigDiff = (oldConfig, newConfig) => {
|
|
|
444
380
|
nextValue: applicationConfig.sanitizeSvg(newConfig.icon),
|
|
445
381
|
label: 'icon'
|
|
446
382
|
});
|
|
447
|
-
|
|
448
383
|
if (iconDiff) {
|
|
449
384
|
diff.push(iconDiff);
|
|
450
|
-
}
|
|
451
|
-
|
|
385
|
+
}
|
|
452
386
|
|
|
387
|
+
// Permissions
|
|
453
388
|
const permissionsDiff = getPermissionsDiff({
|
|
454
389
|
previousValue: oldConfig.permissions,
|
|
455
390
|
nextValue: newConfig.permissions
|
|
456
391
|
});
|
|
457
|
-
|
|
458
392
|
if (permissionsDiff) {
|
|
459
393
|
diff.push(permissionsDiff);
|
|
460
|
-
}
|
|
461
|
-
|
|
394
|
+
}
|
|
462
395
|
|
|
396
|
+
// Main menu link
|
|
463
397
|
const mainMenuDiff = getMainMenuLinkDiff({
|
|
464
398
|
previousValue: oldConfig.mainMenuLink,
|
|
465
399
|
nextValue: newConfig.mainMenuLink
|
|
466
400
|
});
|
|
467
|
-
|
|
468
401
|
if (mainMenuDiff) {
|
|
469
402
|
diff.push(mainMenuDiff);
|
|
470
|
-
}
|
|
471
|
-
|
|
403
|
+
}
|
|
472
404
|
|
|
405
|
+
// Submenu links
|
|
473
406
|
const submenuDiff = getSubmenuLinksDiff({
|
|
474
407
|
previousValue: oldConfig.submenuLinks,
|
|
475
408
|
nextValue: newConfig.submenuLinks
|
|
476
409
|
});
|
|
477
|
-
|
|
478
410
|
if (submenuDiff) {
|
|
479
411
|
diff.push(submenuDiff);
|
|
480
412
|
}
|
|
481
|
-
|
|
482
413
|
return diff.join('\n');
|
|
483
414
|
};
|
|
484
415
|
|
|
485
416
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
486
|
-
|
|
487
417
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
488
418
|
var CreateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 201, source: { body: "mutation CreateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n) {\n createCustomApplication(organizationId: $organizationId, data: $data) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
489
419
|
var FetchCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationExtensionForCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "entryPointUriPath" }, value: { kind: "Variable", name: { kind: "Name", value: "entryPointUriPath" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "application" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "entryPointUriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "description" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "icon" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "oAuthScopes" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "mainMenuLink" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "submenuLinks" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "uriPath" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "permissions" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "labelAllLocales" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "locale" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "value" }, arguments: [], directives: [] }] } }] } }] } }] } }] } }], loc: { start: 0, end: 647, source: { body: "query FetchCustomApplicationFromCli($entryPointUriPath: String!) {\n organizationExtensionForCustomApplication(\n entryPointUriPath: $entryPointUriPath\n ) {\n organizationId\n application {\n id\n entryPointUriPath\n name\n description\n url\n icon\n permissions {\n name\n oAuthScopes\n }\n mainMenuLink {\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n submenuLinks {\n uriPath\n defaultLabel\n permissions\n labelAllLocales {\n locale\n value\n }\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
490
420
|
var FetchMyOrganizationsFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchMyOrganizationsFromCli" }, variableDefinitions: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "myOrganizations" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "total" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "results" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "name" }, arguments: [], directives: [] }] } }] } }] } }], loc: { start: 0, end: 112, source: { body: "query FetchMyOrganizationsFromCli {\n myOrganizations {\n total\n results {\n id\n name\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
491
421
|
var UpdateCustomApplicationFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomApplicationFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "organizationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDraftDataInput" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "applicationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "ID" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomApplication" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "data" }, value: { kind: "Variable", name: { kind: "Name", value: "data" } } }, { kind: "Argument", name: { kind: "Name", value: "applicationId" }, value: { kind: "Variable", name: { kind: "Name", value: "applicationId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 268, source: { body: "mutation UpdateCustomApplicationFromCli(\n $organizationId: String!\n $data: CustomApplicationDraftDataInput!\n $applicationId: ID!\n) {\n updateCustomApplication(\n organizationId: $organizationId\n data: $data\n applicationId: $applicationId\n ) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
492
422
|
const credentialsStorage$1 = new credentialsStorage$2.CredentialsStorage();
|
|
493
|
-
const client = new graphqlRequest.GraphQLClient('',
|
|
423
|
+
const client = new graphqlRequest.GraphQLClient('',
|
|
424
|
+
// <-- Set on demand
|
|
494
425
|
{
|
|
495
426
|
headers: {
|
|
496
427
|
Accept: 'application/json',
|
|
@@ -498,46 +429,39 @@ const client = new graphqlRequest.GraphQLClient('', // <-- Set on demand
|
|
|
498
429
|
'x-user-agent': credentialsStorage$2.userAgent
|
|
499
430
|
}
|
|
500
431
|
});
|
|
501
|
-
|
|
502
432
|
async function requestWithTokenRetry(document, requestOptions) {
|
|
503
433
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
504
434
|
const token = credentialsStorage$1.getToken(requestOptions.mcApiUrl);
|
|
505
435
|
client.setEndpoint("".concat(requestOptions.mcApiUrl, "/graphql"));
|
|
506
436
|
client.setHeaders(requestOptions.headers);
|
|
507
|
-
|
|
508
437
|
if (token) {
|
|
509
438
|
client.setHeader('x-mc-cli-access-token', token);
|
|
510
439
|
}
|
|
511
|
-
|
|
512
440
|
try {
|
|
513
|
-
const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
|
|
441
|
+
const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
|
|
514
442
|
|
|
443
|
+
// In case a new session token is returned from the server, save it.
|
|
515
444
|
const refreshedSessionToken = result.headers.get('x-refreshed-session-token');
|
|
516
|
-
|
|
517
445
|
if (refreshedSessionToken) {
|
|
518
446
|
console.log(chalk__default["default"].green('Session token refreshed.'));
|
|
519
447
|
console.log();
|
|
520
|
-
const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
|
|
521
|
-
|
|
448
|
+
const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
|
|
449
|
+
// Store the updated access token.
|
|
522
450
|
credentialsStorage$1.setToken(requestOptions.mcApiUrl, {
|
|
523
451
|
token: refreshedSessionToken,
|
|
524
452
|
expiresAt: Number(refreshedSessionTokenExpiresAt)
|
|
525
453
|
});
|
|
526
454
|
}
|
|
527
|
-
|
|
528
455
|
return result.data;
|
|
529
456
|
} catch (error) {
|
|
530
457
|
if (error instanceof graphqlRequest.ClientError) {
|
|
531
458
|
// If it's an unauthorized error, retry the request to force the token to be refreshed.
|
|
532
459
|
if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
|
|
533
460
|
var _context;
|
|
534
|
-
|
|
535
461
|
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => {
|
|
536
462
|
var _graphqlError$extensi;
|
|
537
|
-
|
|
538
463
|
return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
|
|
539
464
|
});
|
|
540
|
-
|
|
541
465
|
if (isUnauthorizedError) {
|
|
542
466
|
console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
|
|
543
467
|
return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
|
@@ -548,14 +472,12 @@ async function requestWithTokenRetry(document, requestOptions) {
|
|
|
548
472
|
}
|
|
549
473
|
}
|
|
550
474
|
}
|
|
551
|
-
|
|
552
475
|
throw error;
|
|
553
476
|
}
|
|
554
477
|
}
|
|
555
|
-
|
|
556
478
|
const fetchCustomApplication = async _ref => {
|
|
557
479
|
let mcApiUrl = _ref.mcApiUrl,
|
|
558
|
-
|
|
480
|
+
entryPointUriPath = _ref.entryPointUriPath;
|
|
559
481
|
const customAppData = await requestWithTokenRetry(FetchCustomApplicationFromCli, {
|
|
560
482
|
variables: {
|
|
561
483
|
entryPointUriPath
|
|
@@ -567,12 +489,11 @@ const fetchCustomApplication = async _ref => {
|
|
|
567
489
|
});
|
|
568
490
|
return customAppData.organizationExtensionForCustomApplication;
|
|
569
491
|
};
|
|
570
|
-
|
|
571
492
|
const updateCustomApplication = async _ref2 => {
|
|
572
493
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
494
|
+
applicationId = _ref2.applicationId,
|
|
495
|
+
organizationId = _ref2.organizationId,
|
|
496
|
+
data = _ref2.data;
|
|
576
497
|
const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
|
|
577
498
|
variables: {
|
|
578
499
|
organizationId,
|
|
@@ -586,11 +507,10 @@ const updateCustomApplication = async _ref2 => {
|
|
|
586
507
|
});
|
|
587
508
|
return updatedCustomAppsData.updateCustomApplication;
|
|
588
509
|
};
|
|
589
|
-
|
|
590
510
|
const createCustomApplication = async _ref3 => {
|
|
591
511
|
let mcApiUrl = _ref3.mcApiUrl,
|
|
592
|
-
|
|
593
|
-
|
|
512
|
+
organizationId = _ref3.organizationId,
|
|
513
|
+
data = _ref3.data;
|
|
594
514
|
const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
|
|
595
515
|
variables: {
|
|
596
516
|
organizationId,
|
|
@@ -603,7 +523,6 @@ const createCustomApplication = async _ref3 => {
|
|
|
603
523
|
});
|
|
604
524
|
return createdCustomAppData.createCustomApplication;
|
|
605
525
|
};
|
|
606
|
-
|
|
607
526
|
const fetchUserOrganizations = async _ref4 => {
|
|
608
527
|
let mcApiUrl = _ref4.mcApiUrl;
|
|
609
528
|
const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
|
|
@@ -616,97 +535,76 @@ const fetchUserOrganizations = async _ref4 => {
|
|
|
616
535
|
};
|
|
617
536
|
|
|
618
537
|
const credentialsStorage = new credentialsStorage$2.CredentialsStorage();
|
|
619
|
-
|
|
620
538
|
const getMcUrlLink = (mcApiUrl, organizationId, applicationId) => {
|
|
621
539
|
var _context, _context2;
|
|
622
|
-
|
|
623
540
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
624
|
-
|
|
625
541
|
const customAppLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "".concat(mcUrl, "/account/organizations/")).call(_context2, organizationId, "/custom-applications/owned/")).call(_context, applicationId);
|
|
626
|
-
|
|
627
542
|
return customAppLink;
|
|
628
543
|
};
|
|
629
|
-
|
|
630
544
|
async function run(options) {
|
|
631
545
|
var _context5;
|
|
632
|
-
|
|
633
546
|
const applicationConfig$1 = applicationConfig.processConfig();
|
|
634
547
|
const localCustomAppData = applicationConfig$1.data;
|
|
635
548
|
const mcApiUrl = applicationConfig$1.env.mcApiUrl;
|
|
636
549
|
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
637
550
|
console.log();
|
|
638
551
|
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
639
|
-
|
|
640
552
|
if (!isSessionValid) {
|
|
641
553
|
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
642
554
|
}
|
|
643
|
-
|
|
644
555
|
const fetchedCustomApplication = await fetchCustomApplication({
|
|
645
556
|
mcApiUrl,
|
|
646
557
|
entryPointUriPath: localCustomAppData.entryPointUriPath
|
|
647
558
|
});
|
|
648
|
-
|
|
649
559
|
if (!fetchedCustomApplication) {
|
|
650
560
|
var _context4;
|
|
651
|
-
|
|
652
561
|
const userOrganizations = await fetchUserOrganizations({
|
|
653
562
|
mcApiUrl
|
|
654
563
|
});
|
|
655
564
|
let organizationId, organizationName;
|
|
656
|
-
|
|
657
565
|
if (userOrganizations.total === 0) {
|
|
658
566
|
throw new Error("It seems you are not an admin of any Organization. Please make sure to be part of the Administrators team of the Organization you want the Custom Application to be configured to.");
|
|
659
567
|
}
|
|
660
|
-
|
|
661
568
|
if (userOrganizations.total === 1) {
|
|
662
569
|
const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
|
|
663
|
-
|
|
664
|
-
|
|
570
|
+
organization = _userOrganizations$re[0];
|
|
665
571
|
organizationId = organization.id;
|
|
666
572
|
organizationName = organization.name;
|
|
667
573
|
} else {
|
|
668
574
|
var _context3;
|
|
669
|
-
|
|
670
575
|
const organizationChoices = _mapInstanceProperty__default["default"](_context3 = userOrganizations.results).call(_context3, organization => ({
|
|
671
576
|
title: organization.name,
|
|
672
577
|
value: organization.id
|
|
673
578
|
}));
|
|
674
|
-
|
|
675
579
|
const _await$prompts = await prompts__default["default"]({
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
580
|
+
type: 'select',
|
|
581
|
+
name: 'organizationId',
|
|
582
|
+
message: 'Select an Organization',
|
|
583
|
+
choices: organizationChoices,
|
|
584
|
+
initial: 0
|
|
585
|
+
}),
|
|
586
|
+
selectedOrganizationId = _await$prompts.organizationId;
|
|
684
587
|
if (!selectedOrganizationId) {
|
|
685
588
|
throw new Error("No Organization selected, aborting.");
|
|
686
589
|
}
|
|
687
|
-
|
|
688
590
|
organizationId = selectedOrganizationId;
|
|
689
591
|
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref => {
|
|
690
592
|
let value = _ref.value;
|
|
691
593
|
return value === organizationId;
|
|
692
594
|
}).title;
|
|
693
595
|
}
|
|
694
|
-
|
|
695
596
|
const _await$prompts2 = await prompts__default["default"]({
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
597
|
+
type: 'text',
|
|
598
|
+
name: 'confirmation',
|
|
599
|
+
message: _filterInstanceProperty__default["default"](_context4 = ["You are about to create a new Custom Application in the \"".concat(chalk__default["default"].green(organizationName), "\" organization. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be created.')]).call(_context4, Boolean).join('\n'),
|
|
600
|
+
initial: 'yes'
|
|
601
|
+
}),
|
|
602
|
+
confirmation = _await$prompts2.confirmation;
|
|
703
603
|
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
704
604
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
705
605
|
return;
|
|
706
606
|
}
|
|
707
|
-
|
|
708
607
|
const data = omit__default["default"](localCustomAppData, ['id']);
|
|
709
|
-
|
|
710
608
|
if (options.dryRun) {
|
|
711
609
|
console.log();
|
|
712
610
|
console.log("The following payload would be used to create a new Custom Application.");
|
|
@@ -714,54 +612,46 @@ async function run(options) {
|
|
|
714
612
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
715
613
|
return;
|
|
716
614
|
}
|
|
717
|
-
|
|
718
615
|
const createdCustomApplication = await createCustomApplication({
|
|
719
616
|
mcApiUrl,
|
|
720
617
|
organizationId,
|
|
721
618
|
data
|
|
722
|
-
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
723
622
|
// throws an error in case of GraphQL errors.
|
|
724
623
|
// However, the generated TypeScript data related to the GraphQL query has the
|
|
725
624
|
// field typed as optional, thus having an extra check for type correctness.
|
|
726
|
-
|
|
727
625
|
if (!createdCustomApplication) {
|
|
728
626
|
throw new Error('Failed to create the Custom Application.');
|
|
729
627
|
}
|
|
730
|
-
|
|
731
628
|
const customAppLink = getMcUrlLink(mcApiUrl, organizationId, createdCustomApplication.id);
|
|
732
629
|
console.log(chalk__default["default"].green("Custom Application created.\nPlease update the \"env.production.applicationId\" field in your local Custom Application config file with the following value: \"".concat(chalk__default["default"].green(createdCustomApplication.id), "\".")));
|
|
733
630
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
734
631
|
return;
|
|
735
632
|
}
|
|
736
|
-
|
|
737
633
|
const customAppLink = getMcUrlLink(mcApiUrl, fetchedCustomApplication.organizationId, fetchedCustomApplication.application.id);
|
|
738
634
|
const configDiff = getConfigDiff(fetchedCustomApplication.application, localCustomAppData);
|
|
739
|
-
|
|
740
635
|
if (!configDiff) {
|
|
741
636
|
console.log(chalk__default["default"].green("Custom Application up-to-date."));
|
|
742
637
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
743
638
|
return;
|
|
744
639
|
}
|
|
745
|
-
|
|
746
640
|
console.log('Changes detected:');
|
|
747
641
|
console.log(configDiff);
|
|
748
642
|
console.log();
|
|
749
|
-
|
|
750
643
|
const _await$prompts3 = await prompts__default["default"]({
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
644
|
+
type: 'text',
|
|
645
|
+
name: 'confirmation',
|
|
646
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomAppData.entryPointUriPath), "\" with the changes above. Are you sure you want to proceed?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no data will be updated.')]).call(_context5, Boolean).join('\n'),
|
|
647
|
+
initial: 'yes'
|
|
648
|
+
}),
|
|
649
|
+
confirmation = _await$prompts3.confirmation;
|
|
758
650
|
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
759
651
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
760
652
|
return;
|
|
761
653
|
}
|
|
762
|
-
|
|
763
654
|
const data = omit__default["default"](localCustomAppData, ['id']);
|
|
764
|
-
|
|
765
655
|
if (options.dryRun) {
|
|
766
656
|
console.log();
|
|
767
657
|
console.log("The following payload would be used to update the Custom Application \"".concat(chalk__default["default"].green(data.entryPointUriPath), "\"."));
|
|
@@ -769,7 +659,6 @@ async function run(options) {
|
|
|
769
659
|
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
770
660
|
return;
|
|
771
661
|
}
|
|
772
|
-
|
|
773
662
|
await updateCustomApplication({
|
|
774
663
|
mcApiUrl,
|
|
775
664
|
organizationId: fetchedCustomApplication.organizationId,
|