@commercetools-frontend/mc-scripts 22.11.0 → 22.13.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 +5 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +5 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +5 -5
- package/dist/{build-32837342.cjs.prod.js → build-5bfca7c8.cjs.prod.js} +3 -3
- package/dist/{build-5c91b773.cjs.dev.js → build-9bd2f410.cjs.dev.js} +3 -3
- package/dist/{build-fcc2b53e.esm.js → build-c99a4685.esm.js} +3 -3
- package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +1 -1
- package/dist/commercetools-frontend-mc-scripts.esm.js +1 -1
- package/dist/{config-sync-dc8c5825.cjs.dev.js → config-sync-52f1daf8.cjs.dev.js} +417 -62
- package/dist/{config-sync-1b9901fd.esm.js → config-sync-aa114b0b.esm.js} +417 -62
- package/dist/{config-sync-cb6355ee.cjs.prod.js → config-sync-bef101a0.cjs.prod.js} +417 -62
- package/dist/{create-postcss-config-83bf7e4e.cjs.prod.js → create-postcss-config-1fd98922.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-cb5f7725.esm.js → create-postcss-config-354ba07a.esm.js} +1 -1
- package/dist/{create-postcss-config-e77490e3.cjs.dev.js → create-postcss-config-843c2974.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-db0db557.esm.js → create-webpack-config-for-development-3b40205e.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-50b8a7e7.cjs.dev.js → create-webpack-config-for-development-8f11a518.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-development-4d3956ab.cjs.prod.js → create-webpack-config-for-development-90aa6ec0.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-production-78307ac6.cjs.prod.js → create-webpack-config-for-production-2716c37e.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-production-421bdf70.cjs.dev.js → create-webpack-config-for-production-cacd3a52.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-c1e7bfaa.esm.js → create-webpack-config-for-production-e57dacb7.esm.js} +1 -1
- package/dist/{credentials-storage-39492166.esm.js → credentials-storage-001c09fb.esm.js} +1 -1
- package/dist/{credentials-storage-6c8f8a6a.cjs.prod.js → credentials-storage-252b2ead.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-2a0046c3.cjs.dev.js → credentials-storage-e637c260.cjs.dev.js} +1 -1
- package/dist/declarations/src/generated/settings.d.ts +114 -1
- package/dist/declarations/src/utils/get-config-diff.d.ts +3 -3
- package/dist/declarations/src/utils/graphql-requests.d.ts +56 -3
- package/dist/{login-256c8d6b.cjs.prod.js → login-506d2457.cjs.prod.js} +2 -2
- package/dist/{login-d0ac94e2.cjs.dev.js → login-67e038da.cjs.dev.js} +2 -2
- package/dist/{login-cf3d1b7f.esm.js → login-f7a8221b.esm.js} +2 -2
- package/dist/{package-afdd385b.esm.js → package-53e602ff.esm.js} +9 -8
- package/dist/{package-582f21e6.cjs.prod.js → package-933e64f5.cjs.dev.js} +9 -8
- package/dist/{package-9f63548c.cjs.dev.js → package-db6d1141.cjs.prod.js} +9 -8
- package/dist/{start-3021daa5.esm.js → start-18591a38.esm.js} +3 -3
- package/dist/{start-7dc2bd3d.cjs.prod.js → start-19554dc8.cjs.prod.js} +3 -3
- package/dist/{start-860d7653.cjs.dev.js → start-6b8d264b.cjs.dev.js} +3 -3
- package/package.json +9 -8
- 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 +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +4 -4
- package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +4 -4
|
@@ -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-252b2ead.cjs.prod.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-db6d1141.cjs.prod.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,7 +58,7 @@ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
|
58
58
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
59
59
|
|
|
60
60
|
function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
61
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var
|
|
61
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context21, _context22; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context21 = ownKeys$1(Object(t), !0)).call(_context21, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context22 = ownKeys$1(Object(t))).call(_context22, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
62
62
|
const red = str => {
|
|
63
63
|
return chalk__default["default"].red(str);
|
|
64
64
|
};
|
|
@@ -211,9 +211,47 @@ const getLabelAllLocalesDiff = _ref5 => {
|
|
|
211
211
|
if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
|
|
212
212
|
return null;
|
|
213
213
|
};
|
|
214
|
-
const
|
|
214
|
+
const getTypeSettingsDiff = _ref7 => {
|
|
215
|
+
var _context17;
|
|
215
216
|
let previousValue = _ref7.previousValue,
|
|
216
217
|
nextValue = _ref7.nextValue;
|
|
218
|
+
const nonNullablePreviousValue = previousValue || {};
|
|
219
|
+
const nonNullableNextValue = nextValue || {};
|
|
220
|
+
const indentLevel = 1;
|
|
221
|
+
const typeSettingsDiff = ["".concat(indent(indentLevel - 1), "type settings changed")];
|
|
222
|
+
_forEachInstanceProperty__default["default"](_context17 = _Object$keys__default["default"](nonNullablePreviousValue)).call(_context17, key => {
|
|
223
|
+
const typeSettingDiff = getStringDiff({
|
|
224
|
+
previousValue: nonNullablePreviousValue[key],
|
|
225
|
+
nextValue: nonNullableNextValue[key],
|
|
226
|
+
label: key,
|
|
227
|
+
indentLevel
|
|
228
|
+
});
|
|
229
|
+
if (typeSettingDiff) {
|
|
230
|
+
typeSettingsDiff.push(typeSettingDiff);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (typeSettingsDiff.length > 1) return typeSettingsDiff.join('\n');
|
|
234
|
+
return null;
|
|
235
|
+
};
|
|
236
|
+
const getLocatorsDiff = _ref8 => {
|
|
237
|
+
let previousValue = _ref8.previousValue,
|
|
238
|
+
nextValue = _ref8.nextValue;
|
|
239
|
+
const diff = [];
|
|
240
|
+
const locatorsDiff = getArrayDiff({
|
|
241
|
+
previousValue: previousValue,
|
|
242
|
+
nextValue: nextValue,
|
|
243
|
+
label: 'locators',
|
|
244
|
+
indentLevel: 1
|
|
245
|
+
});
|
|
246
|
+
if (locatorsDiff) {
|
|
247
|
+
diff.push('locators changed');
|
|
248
|
+
diff.push(locatorsDiff);
|
|
249
|
+
}
|
|
250
|
+
return diff.join('\n');
|
|
251
|
+
};
|
|
252
|
+
const getMainMenuLinkDiff = _ref9 => {
|
|
253
|
+
let previousValue = _ref9.previousValue,
|
|
254
|
+
nextValue = _ref9.nextValue;
|
|
217
255
|
const mainMenuLinkDiff = ['mainMenuLink changed'];
|
|
218
256
|
const menuDiff = getStringDiff({
|
|
219
257
|
previousValue: previousValue.defaultLabel,
|
|
@@ -246,10 +284,10 @@ const getMainMenuLinkDiff = _ref7 => {
|
|
|
246
284
|
if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
|
|
247
285
|
return null;
|
|
248
286
|
};
|
|
249
|
-
const getSubmenuLinksDiff =
|
|
250
|
-
var
|
|
251
|
-
let previousValue =
|
|
252
|
-
nextValue =
|
|
287
|
+
const getSubmenuLinksDiff = _ref10 => {
|
|
288
|
+
var _context20;
|
|
289
|
+
let previousValue = _ref10.previousValue,
|
|
290
|
+
nextValue = _ref10.nextValue;
|
|
253
291
|
const submenuLinksDiff = ['submenuLink changed'];
|
|
254
292
|
const mappedSubmenuLinks = _reduceInstanceProperty__default["default"](previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread$1(_objectSpread$1({}, previousSubmenuLink), {}, {
|
|
255
293
|
[currentSubmenuLink.uriPath]: currentSubmenuLink
|
|
@@ -257,9 +295,9 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
257
295
|
_forEachInstanceProperty__default["default"](nextValue).call(nextValue, newSubmenuLink => {
|
|
258
296
|
const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
|
|
259
297
|
if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
|
|
260
|
-
var
|
|
261
|
-
const submenuLinkDiff = [_concatInstanceProperty__default["default"](
|
|
262
|
-
_forEachInstanceProperty__default["default"](
|
|
298
|
+
var _context18, _context19;
|
|
299
|
+
const submenuLinkDiff = [_concatInstanceProperty__default["default"](_context18 = "".concat(indent(1), "menu link \"")).call(_context18, newSubmenuLink.uriPath, "\" changed")];
|
|
300
|
+
_forEachInstanceProperty__default["default"](_context19 = _Object$keys__default["default"](mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context19, key => {
|
|
263
301
|
switch (key) {
|
|
264
302
|
case 'defaultLabel':
|
|
265
303
|
{
|
|
@@ -318,7 +356,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
318
356
|
}
|
|
319
357
|
}
|
|
320
358
|
});
|
|
321
|
-
_forEachInstanceProperty__default["default"](
|
|
359
|
+
_forEachInstanceProperty__default["default"](_context20 = _Object$keys__default["default"](mappedSubmenuLinks)).call(_context20, key => {
|
|
322
360
|
const linksDiff = getStringDiff({
|
|
323
361
|
previousValue: key,
|
|
324
362
|
label: 'menu link',
|
|
@@ -332,7 +370,7 @@ const getSubmenuLinksDiff = _ref8 => {
|
|
|
332
370
|
|
|
333
371
|
// Compute diff changes of the Custom Application config.
|
|
334
372
|
// NOTE: Only known keys are evaluated.
|
|
335
|
-
const
|
|
373
|
+
const getCustomApplicationConfigDiff = (oldConfig, newConfig) => {
|
|
336
374
|
const diff = [];
|
|
337
375
|
|
|
338
376
|
// Name
|
|
@@ -407,12 +445,99 @@ const getConfigDiff = (oldConfig, newConfig) => {
|
|
|
407
445
|
return diff.join('\n');
|
|
408
446
|
};
|
|
409
447
|
|
|
448
|
+
// Compute diff changes of the Custom View config.
|
|
449
|
+
// NOTE: Only known keys are evaluated.
|
|
450
|
+
const getCustomViewConfigDiff = (oldConfig, newConfig) => {
|
|
451
|
+
const diff = [];
|
|
452
|
+
|
|
453
|
+
// Default Label
|
|
454
|
+
const defaultLabelDiff = getStringDiff({
|
|
455
|
+
previousValue: oldConfig.defaultLabel,
|
|
456
|
+
nextValue: newConfig.defaultLabel,
|
|
457
|
+
label: 'defaultLabel'
|
|
458
|
+
});
|
|
459
|
+
if (defaultLabelDiff) {
|
|
460
|
+
diff.push(defaultLabelDiff);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Description
|
|
464
|
+
const descriptionDiff = getStringDiff({
|
|
465
|
+
previousValue: oldConfig.description,
|
|
466
|
+
nextValue: newConfig.description,
|
|
467
|
+
label: 'description'
|
|
468
|
+
});
|
|
469
|
+
if (descriptionDiff) {
|
|
470
|
+
diff.push(descriptionDiff);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// URL
|
|
474
|
+
const urlDiff = getStringDiff({
|
|
475
|
+
previousValue: oldConfig.url,
|
|
476
|
+
nextValue: newConfig.url,
|
|
477
|
+
label: 'url'
|
|
478
|
+
});
|
|
479
|
+
if (urlDiff) {
|
|
480
|
+
diff.push(urlDiff);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// Type
|
|
484
|
+
const typeDiff = getStringDiff({
|
|
485
|
+
previousValue: oldConfig.type,
|
|
486
|
+
nextValue: newConfig.type,
|
|
487
|
+
label: 'type'
|
|
488
|
+
});
|
|
489
|
+
if (typeDiff) {
|
|
490
|
+
diff.push(typeDiff);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Permissions
|
|
494
|
+
const permissionsDiff = getPermissionsDiff({
|
|
495
|
+
previousValue: oldConfig.permissions,
|
|
496
|
+
nextValue: newConfig.permissions
|
|
497
|
+
});
|
|
498
|
+
if (permissionsDiff) {
|
|
499
|
+
diff.push(permissionsDiff);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Label All Locales
|
|
503
|
+
const labelsDiff = getLabelAllLocalesDiff({
|
|
504
|
+
previousValue: oldConfig.labelAllLocales,
|
|
505
|
+
nextValue: newConfig.labelAllLocales,
|
|
506
|
+
indentLevel: 1
|
|
507
|
+
});
|
|
508
|
+
if (labelsDiff) {
|
|
509
|
+
diff.push(labelsDiff);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// Type settings
|
|
513
|
+
const typeSettingsDiff = getTypeSettingsDiff({
|
|
514
|
+
previousValue: oldConfig.typeSettings,
|
|
515
|
+
nextValue: newConfig.typeSettings
|
|
516
|
+
});
|
|
517
|
+
if (typeSettingsDiff) {
|
|
518
|
+
diff.push(typeSettingsDiff);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Locators
|
|
522
|
+
const locatorsDiff = getLocatorsDiff({
|
|
523
|
+
previousValue: oldConfig.locators,
|
|
524
|
+
nextValue: newConfig.locators
|
|
525
|
+
});
|
|
526
|
+
if (locatorsDiff) {
|
|
527
|
+
diff.push(locatorsDiff);
|
|
528
|
+
}
|
|
529
|
+
return diff.join('\n');
|
|
530
|
+
};
|
|
531
|
+
|
|
410
532
|
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
411
533
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
412
534
|
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 } } } };
|
|
535
|
+
var CreateCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomViewFromCli" }, 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: "CustomViewDraftDataInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomView" }, 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: 180, source: { body: "mutation CreateCustomViewFromCli(\n $organizationId: String!\n $data: CustomViewDraftDataInput!\n) {\n createCustomView(organizationId: $organizationId, data: $data) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
413
536
|
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 } } } };
|
|
537
|
+
var FetchCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "query", name: { kind: "Name", value: "FetchCustomViewFromCli" }, variableDefinitions: [{ kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "customViewId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationExtensionForCustomView" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "customViewId" }, value: { kind: "Variable", name: { kind: "Name", value: "customViewId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "organizationId" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "customView" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "defaultLabel" }, 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: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "type" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "typeSettings" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "size" }, arguments: [], directives: [] }] } }, { kind: "Field", name: { kind: "Name", value: "locators" }, 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: [] }] } }] } }] } }] } }], loc: { start: 0, end: 399, source: { body: "query FetchCustomViewFromCli($customViewId: String!) {\n organizationExtensionForCustomView(customViewId: $customViewId) {\n organizationId\n customView {\n id\n defaultLabel\n labelAllLocales {\n locale\n value\n }\n url\n type\n typeSettings {\n size\n }\n locators\n permissions {\n name\n oAuthScopes\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
414
538
|
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 } } } };
|
|
415
539
|
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 } } } };
|
|
540
|
+
var UpdateCustomViewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomViewFromCli" }, 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: "CustomViewDraftDataInput" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "customViewId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "String" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomView" }, 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: "customViewId" }, value: { kind: "Variable", name: { kind: "Name", value: "customViewId" } } }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 248, source: { body: "mutation UpdateCustomViewFromCli(\n $organizationId: String!\n $data: CustomViewDraftDataInput!\n $customViewId: String!\n) {\n updateCustomView(\n organizationId: $organizationId\n data: $data\n customViewId: $customViewId\n ) {\n id\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
416
541
|
const credentialsStorage$1 = new credentialsStorage$2.CredentialsStorage();
|
|
417
542
|
async function requestWithTokenRetry(document, requestOptions) {
|
|
418
543
|
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
@@ -480,12 +605,29 @@ const fetchCustomApplication = async _ref => {
|
|
|
480
605
|
});
|
|
481
606
|
return customAppData.organizationExtensionForCustomApplication;
|
|
482
607
|
};
|
|
483
|
-
const
|
|
608
|
+
const fetchCustomView = async _ref2 => {
|
|
484
609
|
let mcApiUrl = _ref2.mcApiUrl,
|
|
485
|
-
|
|
486
|
-
organizationId = _ref2.organizationId,
|
|
487
|
-
data = _ref2.data,
|
|
610
|
+
customViewId = _ref2.customViewId,
|
|
488
611
|
applicationIdentifier = _ref2.applicationIdentifier;
|
|
612
|
+
const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
|
|
613
|
+
variables: {
|
|
614
|
+
customViewId
|
|
615
|
+
},
|
|
616
|
+
mcApiUrl,
|
|
617
|
+
headers: {
|
|
618
|
+
'x-custom-view-id': customViewId,
|
|
619
|
+
'x-application-id': applicationIdentifier,
|
|
620
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
return customViewData.organizationExtensionForCustomView;
|
|
624
|
+
};
|
|
625
|
+
const updateCustomApplication = async _ref3 => {
|
|
626
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
627
|
+
applicationId = _ref3.applicationId,
|
|
628
|
+
organizationId = _ref3.organizationId,
|
|
629
|
+
data = _ref3.data,
|
|
630
|
+
applicationIdentifier = _ref3.applicationIdentifier;
|
|
489
631
|
const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
|
|
490
632
|
variables: {
|
|
491
633
|
organizationId,
|
|
@@ -500,11 +642,32 @@ const updateCustomApplication = async _ref2 => {
|
|
|
500
642
|
});
|
|
501
643
|
return updatedCustomAppsData.updateCustomApplication;
|
|
502
644
|
};
|
|
503
|
-
const
|
|
504
|
-
let mcApiUrl =
|
|
505
|
-
organizationId =
|
|
506
|
-
data =
|
|
507
|
-
|
|
645
|
+
const updateCustomView = async _ref4 => {
|
|
646
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
647
|
+
organizationId = _ref4.organizationId,
|
|
648
|
+
data = _ref4.data,
|
|
649
|
+
customViewId = _ref4.customViewId,
|
|
650
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
651
|
+
const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
|
|
652
|
+
variables: {
|
|
653
|
+
organizationId,
|
|
654
|
+
customViewId,
|
|
655
|
+
data
|
|
656
|
+
},
|
|
657
|
+
mcApiUrl,
|
|
658
|
+
headers: {
|
|
659
|
+
'x-custom-view-id': customViewId,
|
|
660
|
+
'x-application-id': applicationIdentifier,
|
|
661
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
return updatedCustomViewData.updateCustomView;
|
|
665
|
+
};
|
|
666
|
+
const createCustomApplication = async _ref5 => {
|
|
667
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
668
|
+
organizationId = _ref5.organizationId,
|
|
669
|
+
data = _ref5.data,
|
|
670
|
+
applicationIdentifier = _ref5.applicationIdentifier;
|
|
508
671
|
const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
|
|
509
672
|
variables: {
|
|
510
673
|
organizationId,
|
|
@@ -518,50 +681,66 @@ const createCustomApplication = async _ref3 => {
|
|
|
518
681
|
});
|
|
519
682
|
return createdCustomAppData.createCustomApplication;
|
|
520
683
|
};
|
|
521
|
-
const
|
|
522
|
-
let mcApiUrl =
|
|
523
|
-
|
|
524
|
-
|
|
684
|
+
const createCustomView = async _ref6 => {
|
|
685
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
686
|
+
organizationId = _ref6.organizationId,
|
|
687
|
+
data = _ref6.data,
|
|
688
|
+
applicationIdentifier = _ref6.applicationIdentifier;
|
|
689
|
+
const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
|
|
690
|
+
variables: {
|
|
691
|
+
organizationId,
|
|
692
|
+
data
|
|
693
|
+
},
|
|
525
694
|
mcApiUrl,
|
|
526
695
|
headers: {
|
|
527
696
|
'x-application-id': applicationIdentifier,
|
|
528
|
-
'x-graphql-target': constants.GRAPHQL_TARGETS.
|
|
697
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
529
698
|
}
|
|
530
699
|
});
|
|
700
|
+
return createdCustomViewData.createCustomView;
|
|
701
|
+
};
|
|
702
|
+
const fetchUserOrganizations = async _ref7 => {
|
|
703
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
704
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
705
|
+
customViewId = _ref7.customViewId;
|
|
706
|
+
const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
|
|
707
|
+
mcApiUrl,
|
|
708
|
+
headers: _objectSpread(_objectSpread({
|
|
709
|
+
'x-application-id': applicationIdentifier
|
|
710
|
+
}, customViewId && {
|
|
711
|
+
'x-custom-view-id': customViewId
|
|
712
|
+
}), {}, {
|
|
713
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
714
|
+
})
|
|
715
|
+
});
|
|
531
716
|
return userOrganizations.myOrganizations;
|
|
532
717
|
};
|
|
533
718
|
|
|
534
719
|
const credentialsStorage = new credentialsStorage$2.CredentialsStorage();
|
|
535
|
-
const getMcUrlLink =
|
|
536
|
-
var _context, _context2;
|
|
720
|
+
const getMcUrlLink = _ref => {
|
|
721
|
+
var _context, _context2, _context3;
|
|
722
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
723
|
+
organizationId = _ref.organizationId,
|
|
724
|
+
customEntityId = _ref.customEntityId,
|
|
725
|
+
isCustomView = _ref.isCustomView;
|
|
537
726
|
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
538
|
-
const
|
|
539
|
-
return
|
|
727
|
+
const customEntityLink = _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = "".concat(mcUrl, "/account/organizations/")).call(_context3, organizationId, "/custom-")).call(_context2, isCustomView ? 'views' : 'applications', "/owned/")).call(_context, customEntityId);
|
|
728
|
+
return customEntityLink;
|
|
540
729
|
};
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
customViewId = _applicationConfig$en.customViewId;
|
|
549
|
-
if (customViewId) {
|
|
550
|
-
throw new Error("Syncing the configuration for Custom Views is not supported at the moment.");
|
|
551
|
-
}
|
|
552
|
-
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
553
|
-
console.log();
|
|
554
|
-
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
555
|
-
if (!isSessionValid) {
|
|
556
|
-
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
557
|
-
}
|
|
730
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
731
|
+
async function createOrUpdateCustomApplication(_ref2) {
|
|
732
|
+
var _context6;
|
|
733
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
734
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
735
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
736
|
+
options = _ref2.options;
|
|
558
737
|
const fetchedCustomApplication = await fetchCustomApplication({
|
|
559
738
|
mcApiUrl,
|
|
560
|
-
entryPointUriPath:
|
|
739
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
561
740
|
applicationIdentifier
|
|
562
741
|
});
|
|
563
742
|
if (!fetchedCustomApplication) {
|
|
564
|
-
var
|
|
743
|
+
var _context5;
|
|
565
744
|
const userOrganizations = await fetchUserOrganizations({
|
|
566
745
|
mcApiUrl,
|
|
567
746
|
applicationIdentifier
|
|
@@ -576,8 +755,8 @@ async function run(options) {
|
|
|
576
755
|
organizationId = organization.id;
|
|
577
756
|
organizationName = organization.name;
|
|
578
757
|
} else {
|
|
579
|
-
var
|
|
580
|
-
const organizationChoices = _mapInstanceProperty__default["default"](
|
|
758
|
+
var _context4;
|
|
759
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context4 = userOrganizations.results).call(_context4, organization => ({
|
|
581
760
|
title: organization.name,
|
|
582
761
|
value: organization.id
|
|
583
762
|
}));
|
|
@@ -593,15 +772,15 @@ async function run(options) {
|
|
|
593
772
|
throw new Error("No Organization selected, aborting.");
|
|
594
773
|
}
|
|
595
774
|
organizationId = selectedOrganizationId;
|
|
596
|
-
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices,
|
|
597
|
-
let value =
|
|
775
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref3 => {
|
|
776
|
+
let value = _ref3.value;
|
|
598
777
|
return value === organizationId;
|
|
599
778
|
}).title;
|
|
600
779
|
}
|
|
601
780
|
const _await$prompts2 = await prompts__default["default"]({
|
|
602
781
|
type: 'text',
|
|
603
782
|
name: 'confirmation',
|
|
604
|
-
message: _filterInstanceProperty__default["default"](
|
|
783
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["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(_context5, Boolean).join('\n'),
|
|
605
784
|
initial: 'yes'
|
|
606
785
|
}),
|
|
607
786
|
confirmation = _await$prompts2.confirmation;
|
|
@@ -609,7 +788,7 @@ async function run(options) {
|
|
|
609
788
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
610
789
|
return;
|
|
611
790
|
}
|
|
612
|
-
const data = omit__default["default"](
|
|
791
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
613
792
|
if (options.dryRun) {
|
|
614
793
|
console.log();
|
|
615
794
|
console.log("The following payload would be used to create a new Custom Application.");
|
|
@@ -631,13 +810,21 @@ async function run(options) {
|
|
|
631
810
|
if (!createdCustomApplication) {
|
|
632
811
|
throw new Error('Failed to create the Custom Application.');
|
|
633
812
|
}
|
|
634
|
-
const customAppLink = getMcUrlLink(
|
|
813
|
+
const customAppLink = getMcUrlLink({
|
|
814
|
+
mcApiUrl,
|
|
815
|
+
organizationId,
|
|
816
|
+
customEntityId: createdCustomApplication.id
|
|
817
|
+
});
|
|
635
818
|
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), "\".")));
|
|
636
819
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
637
820
|
return;
|
|
638
821
|
}
|
|
639
|
-
const customAppLink = getMcUrlLink(
|
|
640
|
-
|
|
822
|
+
const customAppLink = getMcUrlLink({
|
|
823
|
+
mcApiUrl,
|
|
824
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
825
|
+
customEntityId: fetchedCustomApplication.application.id
|
|
826
|
+
});
|
|
827
|
+
const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
|
|
641
828
|
if (!configDiff) {
|
|
642
829
|
console.log(chalk__default["default"].green("Custom Application up-to-date."));
|
|
643
830
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
@@ -649,7 +836,7 @@ async function run(options) {
|
|
|
649
836
|
const _await$prompts3 = await prompts__default["default"]({
|
|
650
837
|
type: 'text',
|
|
651
838
|
name: 'confirmation',
|
|
652
|
-
message: _filterInstanceProperty__default["default"](
|
|
839
|
+
message: _filterInstanceProperty__default["default"](_context6 = ["You are about to update the Custom Application \"".concat(chalk__default["default"].green(localCustomEntityData.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(_context6, Boolean).join('\n'),
|
|
653
840
|
initial: 'yes'
|
|
654
841
|
}),
|
|
655
842
|
confirmation = _await$prompts3.confirmation;
|
|
@@ -657,7 +844,7 @@ async function run(options) {
|
|
|
657
844
|
console.log(chalk__default["default"].red('Aborted.'));
|
|
658
845
|
return;
|
|
659
846
|
}
|
|
660
|
-
const data = omit__default["default"](
|
|
847
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
661
848
|
if (options.dryRun) {
|
|
662
849
|
console.log();
|
|
663
850
|
console.log("The following payload would be used to update the Custom Application \"".concat(chalk__default["default"].green(data.entryPointUriPath), "\"."));
|
|
@@ -668,12 +855,180 @@ async function run(options) {
|
|
|
668
855
|
await updateCustomApplication({
|
|
669
856
|
mcApiUrl,
|
|
670
857
|
organizationId: fetchedCustomApplication.organizationId,
|
|
671
|
-
data: omit__default["default"](
|
|
858
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
672
859
|
applicationId: fetchedCustomApplication.application.id,
|
|
673
860
|
applicationIdentifier
|
|
674
861
|
});
|
|
675
862
|
console.log(chalk__default["default"].green("Custom Application updated."));
|
|
676
863
|
console.log("You can inspect the Custom Application data in the Merchant Center at \"".concat(chalk__default["default"].gray(customAppLink), "\"."));
|
|
677
864
|
}
|
|
865
|
+
async function createOrUpdateCustomView(_ref4) {
|
|
866
|
+
var _fetchedCustomView$cu, _context9, _fetchedCustomView$cu2;
|
|
867
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
868
|
+
localCustomEntityData = _ref4.localCustomEntityData,
|
|
869
|
+
customViewId = _ref4.customViewId,
|
|
870
|
+
options = _ref4.options,
|
|
871
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
872
|
+
const fetchedCustomView = await fetchCustomView({
|
|
873
|
+
mcApiUrl,
|
|
874
|
+
customViewId,
|
|
875
|
+
applicationIdentifier
|
|
876
|
+
});
|
|
877
|
+
if (!fetchedCustomView) {
|
|
878
|
+
var _context8;
|
|
879
|
+
const userOrganizations = await fetchUserOrganizations({
|
|
880
|
+
mcApiUrl,
|
|
881
|
+
customViewId,
|
|
882
|
+
applicationIdentifier
|
|
883
|
+
});
|
|
884
|
+
let organizationId, organizationName;
|
|
885
|
+
if (userOrganizations.total === 0) {
|
|
886
|
+
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 View to be configured to.");
|
|
887
|
+
}
|
|
888
|
+
if (userOrganizations.total === 1) {
|
|
889
|
+
const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
|
|
890
|
+
organization = _userOrganizations$re2[0];
|
|
891
|
+
organizationId = organization.id;
|
|
892
|
+
organizationName = organization.name;
|
|
893
|
+
} else {
|
|
894
|
+
var _context7;
|
|
895
|
+
const organizationChoices = _mapInstanceProperty__default["default"](_context7 = userOrganizations.results).call(_context7, organization => ({
|
|
896
|
+
title: organization.name,
|
|
897
|
+
value: organization.id
|
|
898
|
+
}));
|
|
899
|
+
const _await$prompts4 = await prompts__default["default"]({
|
|
900
|
+
type: 'select',
|
|
901
|
+
name: 'organizationId',
|
|
902
|
+
message: 'Select an Organization',
|
|
903
|
+
choices: organizationChoices,
|
|
904
|
+
initial: 0
|
|
905
|
+
}),
|
|
906
|
+
selectedOrganizationId = _await$prompts4.organizationId;
|
|
907
|
+
if (!selectedOrganizationId) {
|
|
908
|
+
throw new Error("No Organization selected, aborting.");
|
|
909
|
+
}
|
|
910
|
+
organizationId = selectedOrganizationId;
|
|
911
|
+
organizationName = _findInstanceProperty__default["default"](organizationChoices).call(organizationChoices, _ref5 => {
|
|
912
|
+
let value = _ref5.value;
|
|
913
|
+
return value === organizationId;
|
|
914
|
+
}).title;
|
|
915
|
+
}
|
|
916
|
+
const _await$prompts5 = await prompts__default["default"]({
|
|
917
|
+
type: 'text',
|
|
918
|
+
name: 'confirmation',
|
|
919
|
+
message: _filterInstanceProperty__default["default"](_context8 = ["You are about to create a new Custom View 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(_context8, Boolean).join('\n'),
|
|
920
|
+
initial: 'yes'
|
|
921
|
+
}),
|
|
922
|
+
confirmation = _await$prompts5.confirmation;
|
|
923
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
924
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
928
|
+
if (options.dryRun) {
|
|
929
|
+
console.log();
|
|
930
|
+
console.log("The following payload would be used to create a new Custom View.");
|
|
931
|
+
console.log();
|
|
932
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const createdCustomView = await createCustomView({
|
|
936
|
+
mcApiUrl,
|
|
937
|
+
organizationId,
|
|
938
|
+
data,
|
|
939
|
+
applicationIdentifier
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
// This check is technically not necessary, as the `graphql-request` client
|
|
943
|
+
// throws an error in case of GraphQL errors.
|
|
944
|
+
// However, the generated TypeScript data related to the GraphQL query has the
|
|
945
|
+
// field typed as optional, thus having an extra check for type correctness.
|
|
946
|
+
if (!createdCustomView) {
|
|
947
|
+
throw new Error('Failed to create the Custom View.');
|
|
948
|
+
}
|
|
949
|
+
const customViewLink = getMcUrlLink({
|
|
950
|
+
mcApiUrl,
|
|
951
|
+
organizationId,
|
|
952
|
+
customEntityId: createdCustomView.id,
|
|
953
|
+
isCustomView: true
|
|
954
|
+
});
|
|
955
|
+
console.log(chalk__default["default"].green("Custom View created.\nPlease update the \"env.production.customViewId\" field in your local Custom View config file with the following value: \"".concat(chalk__default["default"].green(createdCustomView.id), "\".")));
|
|
956
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
const customViewLink = getMcUrlLink({
|
|
960
|
+
mcApiUrl,
|
|
961
|
+
organizationId: fetchedCustomView.organizationId,
|
|
962
|
+
customEntityId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu = fetchedCustomView.customView) === null || _fetchedCustomView$cu === void 0 ? void 0 : _fetchedCustomView$cu.id) || '',
|
|
963
|
+
isCustomView: true
|
|
964
|
+
});
|
|
965
|
+
const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
|
|
966
|
+
if (!configDiff) {
|
|
967
|
+
console.log(chalk__default["default"].green("Custom View up-to-date."));
|
|
968
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
console.log('Changes detected:');
|
|
972
|
+
console.log(configDiff);
|
|
973
|
+
console.log();
|
|
974
|
+
const _await$prompts6 = await prompts__default["default"]({
|
|
975
|
+
type: 'text',
|
|
976
|
+
name: 'confirmation',
|
|
977
|
+
message: _filterInstanceProperty__default["default"](_context9 = ["You are about to update the Custom View \"".concat(chalk__default["default"].green(localCustomEntityData.defaultLabel), "\" 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(_context9, Boolean).join('\n'),
|
|
978
|
+
initial: 'yes'
|
|
979
|
+
}),
|
|
980
|
+
confirmation = _await$prompts6.confirmation;
|
|
981
|
+
if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
|
|
982
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
const data = omit__default["default"](localCustomEntityData, ['id']);
|
|
986
|
+
if (options.dryRun) {
|
|
987
|
+
console.log();
|
|
988
|
+
console.log("The following payload would be used to update the Custom View \"".concat(chalk__default["default"].green(data.defaultLabel), "\"."));
|
|
989
|
+
console.log();
|
|
990
|
+
console.log(chalk__default["default"].gray(_JSON$stringify__default["default"](data, null, 2)));
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
await updateCustomView({
|
|
994
|
+
mcApiUrl,
|
|
995
|
+
organizationId: fetchedCustomView.organizationId,
|
|
996
|
+
data: omit__default["default"](localCustomEntityData, ['id']),
|
|
997
|
+
customViewId: (fetchedCustomView === null || fetchedCustomView === void 0 || (_fetchedCustomView$cu2 = fetchedCustomView.customView) === null || _fetchedCustomView$cu2 === void 0 ? void 0 : _fetchedCustomView$cu2.id) || '',
|
|
998
|
+
applicationIdentifier
|
|
999
|
+
});
|
|
1000
|
+
console.log(chalk__default["default"].green("Custom View updated."));
|
|
1001
|
+
console.log("You can inspect the Custom View data in the Merchant Center at \"".concat(chalk__default["default"].gray(customViewLink), "\"."));
|
|
1002
|
+
}
|
|
1003
|
+
async function run(options) {
|
|
1004
|
+
const applicationConfig$1 = applicationConfig.processConfig();
|
|
1005
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
1006
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
1007
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
1008
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier,
|
|
1009
|
+
customViewId = _applicationConfig$en.customViewId;
|
|
1010
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
1011
|
+
console.log();
|
|
1012
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
1013
|
+
if (!isSessionValid) {
|
|
1014
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
1015
|
+
}
|
|
1016
|
+
if (isCustomViewData(localCustomEntityData)) {
|
|
1017
|
+
createOrUpdateCustomView({
|
|
1018
|
+
mcApiUrl,
|
|
1019
|
+
localCustomEntityData,
|
|
1020
|
+
applicationIdentifier,
|
|
1021
|
+
customViewId: customViewId || localCustomEntityData.id,
|
|
1022
|
+
options
|
|
1023
|
+
});
|
|
1024
|
+
} else {
|
|
1025
|
+
createOrUpdateCustomApplication({
|
|
1026
|
+
mcApiUrl,
|
|
1027
|
+
localCustomEntityData,
|
|
1028
|
+
applicationIdentifier,
|
|
1029
|
+
options
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
678
1033
|
|
|
679
1034
|
exports["default"] = run;
|