@commercetools-frontend/mc-scripts 0.0.0-FEC-157-preview-releases-20241126230331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts +2 -0
  4. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.d.ts.map +1 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.dev.js +7 -0
  6. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
  8. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  9. package/application-runtime/package.json +4 -0
  10. package/bin/cli.js +8 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts.map +1 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +211 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  15. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +211 -0
  16. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +196 -0
  17. package/cli/package.json +4 -0
  18. package/config/create-webpack-config-for-development.js +8 -0
  19. package/config/create-webpack-config-for-production.js +8 -0
  20. package/config/vendors-to-transpile.js +6 -0
  21. package/dist/build-99744dae.cjs.prod.js +166 -0
  22. package/dist/build-a93715aa.esm.js +152 -0
  23. package/dist/build-f56ce7ec.cjs.dev.js +166 -0
  24. package/dist/build-vite-000f0a2d.cjs.prod.js +193 -0
  25. package/dist/build-vite-722f0dcf.esm.js +182 -0
  26. package/dist/build-vite-838c8e01.cjs.dev.js +193 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts.map +1 -0
  29. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
  30. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  31. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
  32. package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
  33. package/dist/compile-html-025cd493.esm.js +34 -0
  34. package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
  35. package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
  36. package/dist/config-sync-2ff62f08.cjs.dev.js +845 -0
  37. package/dist/config-sync-b57f79e2.cjs.prod.js +839 -0
  38. package/dist/config-sync-cda7662e.esm.js +823 -0
  39. package/dist/create-postcss-config-2f709335.esm.js +75 -0
  40. package/dist/create-postcss-config-3b540c7c.cjs.prod.js +81 -0
  41. package/dist/create-postcss-config-5962fa01.cjs.dev.js +81 -0
  42. package/dist/create-webpack-config-for-development-7d9e4dc4.cjs.prod.js +463 -0
  43. package/dist/create-webpack-config-for-development-86baace3.esm.js +438 -0
  44. package/dist/create-webpack-config-for-development-b379913b.cjs.dev.js +463 -0
  45. package/dist/create-webpack-config-for-production-3a40f56b.cjs.dev.js +518 -0
  46. package/dist/create-webpack-config-for-production-5ec9d0e2.cjs.prod.js +518 -0
  47. package/dist/create-webpack-config-for-production-b6ee3116.esm.js +488 -0
  48. package/dist/credentials-storage-3cea94ea.cjs.dev.js +95 -0
  49. package/dist/credentials-storage-b13e1406.esm.js +83 -0
  50. package/dist/credentials-storage-dc849808.cjs.prod.js +95 -0
  51. package/dist/declarations/src/application-runtime.d.ts +1 -0
  52. package/dist/declarations/src/cli.d.ts +4 -0
  53. package/dist/declarations/src/commands/build-vite.d.ts +2 -0
  54. package/dist/declarations/src/commands/build.d.ts +2 -0
  55. package/dist/declarations/src/commands/compile-html.d.ts +3 -0
  56. package/dist/declarations/src/commands/config-sync.d.ts +3 -0
  57. package/dist/declarations/src/commands/deployment-previews-set.d.ts +3 -0
  58. package/dist/declarations/src/commands/login.d.ts +2 -0
  59. package/dist/declarations/src/commands/serve.d.ts +2 -0
  60. package/dist/declarations/src/commands/start-vite.d.ts +2 -0
  61. package/dist/declarations/src/commands/start.d.ts +2 -0
  62. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  63. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  64. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  65. package/dist/declarations/src/config/has-jsx-runtime.d.ts +2 -0
  66. package/dist/declarations/src/config/moment-locales.d.ts +2 -0
  67. package/dist/declarations/src/config/optimizations.d.ts +2 -0
  68. package/dist/declarations/src/config/paths.d.ts +12 -0
  69. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  70. package/dist/declarations/src/config/webpack-dev-server.config.d.ts +6 -0
  71. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  72. package/dist/declarations/src/generated/core.d.ts +739 -0
  73. package/dist/declarations/src/generated/settings.d.ts +2116 -0
  74. package/dist/declarations/src/index.d.ts +3 -0
  75. package/dist/declarations/src/postcss.d.ts +1 -0
  76. package/dist/declarations/src/types.d.ts +87 -0
  77. package/dist/declarations/src/utils/auth.d.ts +6 -0
  78. package/dist/declarations/src/utils/credentials-storage.d.ts +11 -0
  79. package/dist/declarations/src/utils/does-file-exist.d.ts +2 -0
  80. package/dist/declarations/src/utils/get-config-diff.d.ts +3 -0
  81. package/dist/declarations/src/utils/graphql-requests.d.ts +172 -0
  82. package/dist/declarations/src/utils/i18n-message-complilation.d.ts +4 -0
  83. package/dist/declarations/src/utils/user-agent.d.ts +2 -0
  84. package/dist/declarations/src/version.d.ts +2 -0
  85. package/dist/declarations/src/vite-plugins/vite-plugin-dynamic-base-assets-globals.d.ts +3 -0
  86. package/dist/declarations/src/vite-plugins/vite-plugin-i18n-message-compilation.d.ts +3 -0
  87. package/dist/declarations/src/vite-plugins/vite-plugin-merchant-center-customization.d.ts +4 -0
  88. package/dist/declarations/src/vite-plugins/vite-plugin-svgr.d.ts +3 -0
  89. package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
  90. package/dist/declarations/src/webpack-plugins/final-stats-writer-plugin.d.ts +12 -0
  91. package/dist/declarations/src/webpack-plugins/local-html-webpack-plugin.d.ts +5 -0
  92. package/dist/declarations/src/webpack.d.ts +2 -0
  93. package/dist/deployment-previews-set-173d8491.cjs.dev.js +203 -0
  94. package/dist/deployment-previews-set-923f79de.esm.js +192 -0
  95. package/dist/deployment-previews-set-f451242a.cjs.prod.js +203 -0
  96. package/dist/does-file-exist-32618334.esm.js +12 -0
  97. package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
  98. package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
  99. package/dist/graphql-requests-0e427050.esm.js +243 -0
  100. package/dist/graphql-requests-733aac06.cjs.dev.js +266 -0
  101. package/dist/graphql-requests-db54706e.cjs.prod.js +266 -0
  102. package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
  103. package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
  104. package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
  105. package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
  106. package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
  107. package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
  108. package/dist/login-35f578e3.esm.js +86 -0
  109. package/dist/login-65c78b83.cjs.dev.js +103 -0
  110. package/dist/login-c616d769.cjs.prod.js +103 -0
  111. package/dist/optimizations-7789145e.cjs.dev.js +85 -0
  112. package/dist/optimizations-bf991634.esm.js +67 -0
  113. package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
  114. package/dist/package-436331e6.cjs.dev.js +151 -0
  115. package/dist/package-a7096308.cjs.prod.js +151 -0
  116. package/dist/package-b2f2b4e5.esm.js +149 -0
  117. package/dist/paths-39f22b8b.esm.js +36 -0
  118. package/dist/paths-7768b440.cjs.prod.js +44 -0
  119. package/dist/paths-b76fc753.cjs.dev.js +44 -0
  120. package/dist/serve-5666b16a.cjs.prod.js +48 -0
  121. package/dist/serve-6a951584.esm.js +41 -0
  122. package/dist/serve-f898c45e.cjs.dev.js +48 -0
  123. package/dist/start-4e79e08f.esm.js +164 -0
  124. package/dist/start-569eb0f9.cjs.dev.js +177 -0
  125. package/dist/start-b0765c9a.cjs.prod.js +177 -0
  126. package/dist/start-vite-45bfc42f.esm.js +110 -0
  127. package/dist/start-vite-a68e1b9f.cjs.prod.js +122 -0
  128. package/dist/start-vite-a787f80d.cjs.dev.js +122 -0
  129. package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
  130. package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
  131. package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
  132. package/dist/vite-plugin-svgr-069f402d.esm.js +83 -0
  133. package/dist/vite-plugin-svgr-7fb42bbf.cjs.dev.js +108 -0
  134. package/dist/vite-plugin-svgr-b080c510.cjs.prod.js +108 -0
  135. package/package.json +147 -0
  136. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
  137. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts.map +1 -0
  138. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
  139. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  140. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
  141. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
  142. package/postcss/package.json +4 -0
  143. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
  144. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts.map +1 -0
  145. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
  146. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  147. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
  148. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
  149. package/webpack/package.json +4 -0
  150. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
  151. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts.map +1 -0
  152. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
  153. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
  154. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
  155. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
  156. package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
@@ -0,0 +1,823 @@
1
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
2
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
3
+ import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
4
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
5
+ import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
6
+ import chalk from 'chalk';
7
+ import omit from 'lodash/omit';
8
+ import prompts from 'prompts';
9
+ import { sanitizeSvg, processConfig } from '@commercetools-frontend/application-config';
10
+ import { C as CredentialsStorage } from './credentials-storage-b13e1406.esm.js';
11
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
12
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
13
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
14
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
15
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
16
+ import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
17
+ import _repeatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/repeat';
18
+ import _Set from '@babel/runtime-corejs3/core-js-stable/set';
19
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
20
+ import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
21
+ import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
22
+ import { f as fetchCustomApplication, a as fetchUserOrganizations, c as createCustomApplication, u as updateCustomApplication, b as fetchCustomView, d as createCustomView, e as updateCustomView } from './graphql-requests-0e427050.esm.js';
23
+ import '@commercetools/http-user-agent';
24
+ import './package-b2f2b4e5.esm.js';
25
+ import '@babel/runtime-corejs3/helpers/classCallCheck';
26
+ import '@babel/runtime-corejs3/helpers/createClass';
27
+ import '@babel/runtime-corejs3/core-js-stable/date/now';
28
+ import 'fs';
29
+ import 'os';
30
+ import 'path';
31
+ import './does-file-exist-32618334.esm.js';
32
+ import 'node:fs';
33
+ import '@babel/runtime-corejs3/core-js-stable/instance/some';
34
+ import 'graphql';
35
+ import 'graphql-request';
36
+ import '@commercetools-frontend/constants';
37
+
38
+ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
39
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
40
+
41
+ // Since not all terminal supports colors, to make things more consistent for testing purposes,
42
+ // during tests the color used is appended before the string instead of coloring it.
43
+ const isTest = process.env.NODE_ENV === 'test';
44
+ const red = str => {
45
+ if (isTest) return `<color-red>${str}</color-red>`;
46
+ return chalk.red(str);
47
+ };
48
+ const green = str => {
49
+ if (isTest) return `<color-green>${str}</color-green>`;
50
+ return chalk.green(str);
51
+ };
52
+
53
+ // Two spaces are used for indentation.
54
+ const indent = indentLevel => {
55
+ var _context;
56
+ return _repeatInstanceProperty(_context = ' ').call(_context, indentLevel);
57
+ };
58
+ const getStringDiff = _ref => {
59
+ let previousValue = _ref.previousValue,
60
+ nextValue = _ref.nextValue,
61
+ label = _ref.label,
62
+ _ref$indentLevel = _ref.indentLevel,
63
+ indentLevel = _ref$indentLevel === void 0 ? 0 : _ref$indentLevel;
64
+ if (!previousValue && nextValue) {
65
+ return `${indent(indentLevel)}${label} added: ${green(nextValue)}`;
66
+ }
67
+ if (previousValue && !nextValue) {
68
+ return `${indent(indentLevel)}${label} removed: ${red(previousValue)}`;
69
+ }
70
+ if (previousValue && nextValue && previousValue !== nextValue) {
71
+ return `${indent(indentLevel)}${label} changed: ${red(previousValue)} => ${green(nextValue)}`;
72
+ }
73
+ return null;
74
+ };
75
+ // NOTE: this assumes that the array values are scalar values (not objects).
76
+ const getArrayDiff = _ref2 => {
77
+ let previousValue = _ref2.previousValue,
78
+ nextValue = _ref2.nextValue,
79
+ label = _ref2.label,
80
+ _ref2$indentLevel = _ref2.indentLevel,
81
+ indentLevel = _ref2$indentLevel === void 0 ? 0 : _ref2$indentLevel;
82
+ const oldArraySet = new _Set(previousValue);
83
+ const arrayDiff = [];
84
+ nextValue?.forEach(item => {
85
+ if (oldArraySet.has(item)) {
86
+ oldArraySet.delete(item);
87
+ } else {
88
+ arrayDiff.push(getStringDiff({
89
+ nextValue: item,
90
+ label,
91
+ indentLevel
92
+ }));
93
+ }
94
+ });
95
+ _forEachInstanceProperty(oldArraySet).call(oldArraySet, item => {
96
+ arrayDiff.push(getStringDiff({
97
+ previousValue: item,
98
+ label,
99
+ indentLevel
100
+ }));
101
+ });
102
+ return arrayDiff.join('\n');
103
+ };
104
+ const getPermissionsDiff = _ref3 => {
105
+ var _context2;
106
+ let previousValue = _ref3.previousValue,
107
+ nextValue = _ref3.nextValue;
108
+ const permissionDiff = ['permissions changed'];
109
+ const mappedOldPermissions = _reduceInstanceProperty(previousValue).call(previousValue, (previousPermission, _ref4) => {
110
+ let name = _ref4.name,
111
+ oAuthScopes = _ref4.oAuthScopes;
112
+ return _objectSpread(_objectSpread({}, previousPermission), {}, {
113
+ [name]: oAuthScopes
114
+ });
115
+ }, {});
116
+ const indentLevel = 1;
117
+ _forEachInstanceProperty(nextValue).call(nextValue, newPermission => {
118
+ const currentDiff = [`${indent(indentLevel)}"${newPermission.name}" changed`];
119
+ // if the permission name is not in the old config, it means it is a new addition.
120
+ if (!mappedOldPermissions[newPermission.name]) {
121
+ permissionDiff.push(`${indent(indentLevel)}"${green(newPermission.name)}" was added`);
122
+ }
123
+
124
+ // if permission name is in the old config, now we check if there was a change
125
+ else {
126
+ currentDiff.push(getArrayDiff({
127
+ previousValue: mappedOldPermissions[newPermission.name],
128
+ nextValue: newPermission.oAuthScopes,
129
+ label: 'oauth scope',
130
+ indentLevel: 2
131
+ }));
132
+ delete mappedOldPermissions[newPermission.name];
133
+ }
134
+ _filterInstanceProperty(currentDiff).call(currentDiff, Boolean).length > 1 && permissionDiff.push(currentDiff.join('\n'));
135
+ });
136
+
137
+ // if there are old permissions left, it means they were deleted in the new Permissions.
138
+ _forEachInstanceProperty(_context2 = _Object$keys(mappedOldPermissions)).call(_context2, oldPermissionName => {
139
+ permissionDiff.push(`${indent(indentLevel)}"${red(oldPermissionName)}" was removed`);
140
+ });
141
+ if (permissionDiff.length > 1) return permissionDiff.join('\n');
142
+ return null;
143
+ };
144
+ const getLabelAllLocalesDiff = _ref5 => {
145
+ var _context3;
146
+ let _ref5$previousValue = _ref5.previousValue,
147
+ previousValue = _ref5$previousValue === void 0 ? [] : _ref5$previousValue,
148
+ _ref5$nextValue = _ref5.nextValue,
149
+ nextValue = _ref5$nextValue === void 0 ? [] : _ref5$nextValue,
150
+ _ref5$indentLevel = _ref5.indentLevel,
151
+ indentLevel = _ref5$indentLevel === void 0 ? 0 : _ref5$indentLevel;
152
+ const labelAllLocalesDiff = [`${indent(indentLevel - 1)}labelAllLocales changed`];
153
+ const mappedOldLabelAllLocales = _reduceInstanceProperty(previousValue).call(previousValue, (previousLabelAllLocale, _ref6) => {
154
+ let locale = _ref6.locale,
155
+ value = _ref6.value;
156
+ return _objectSpread(_objectSpread({}, previousLabelAllLocale), {}, {
157
+ [locale]: value
158
+ });
159
+ }, {});
160
+ _forEachInstanceProperty(nextValue).call(nextValue, newLabelAllLocale => {
161
+ if (newLabelAllLocale.locale in mappedOldLabelAllLocales) {
162
+ const oldLocaleValue = mappedOldLabelAllLocales[newLabelAllLocale.locale];
163
+ if (oldLocaleValue !== newLabelAllLocale.value) {
164
+ labelAllLocalesDiff.push(`${indent(indentLevel)}locale "${newLabelAllLocale.locale}" changed: ${red(oldLocaleValue)} => ${green(newLabelAllLocale.value)}`);
165
+ }
166
+ delete mappedOldLabelAllLocales[newLabelAllLocale.locale];
167
+ } else {
168
+ const localeDiff = getStringDiff({
169
+ nextValue: newLabelAllLocale.locale,
170
+ label: 'locale',
171
+ indentLevel
172
+ });
173
+ if (localeDiff) {
174
+ labelAllLocalesDiff.push(localeDiff);
175
+ }
176
+ }
177
+ });
178
+ _forEachInstanceProperty(_context3 = _Object$keys(mappedOldLabelAllLocales)).call(_context3, key => {
179
+ const localeDiff = getStringDiff({
180
+ previousValue: key,
181
+ label: 'locale',
182
+ indentLevel
183
+ });
184
+ if (localeDiff) {
185
+ labelAllLocalesDiff.push(localeDiff);
186
+ }
187
+ });
188
+ if (labelAllLocalesDiff.length > 1) return labelAllLocalesDiff.join('\n');
189
+ return null;
190
+ };
191
+ const getTypeSettingsDiff = _ref7 => {
192
+ var _context4;
193
+ let previousValue = _ref7.previousValue,
194
+ nextValue = _ref7.nextValue;
195
+ const nonNullablePreviousValue = previousValue || {};
196
+ const nonNullableNextValue = nextValue || {};
197
+ const indentLevel = 1;
198
+ const typeSettingsDiff = [`${indent(indentLevel - 1)}type settings changed`];
199
+ _forEachInstanceProperty(_context4 = _Object$keys(nonNullablePreviousValue)).call(_context4, key => {
200
+ const typeSettingDiff = getStringDiff({
201
+ previousValue: nonNullablePreviousValue[key],
202
+ nextValue: nonNullableNextValue[key],
203
+ label: key,
204
+ indentLevel
205
+ });
206
+ if (typeSettingDiff) {
207
+ typeSettingsDiff.push(typeSettingDiff);
208
+ }
209
+ });
210
+ if (typeSettingsDiff.length > 1) return typeSettingsDiff.join('\n');
211
+ return null;
212
+ };
213
+ const getLocatorsDiff = _ref8 => {
214
+ let previousValue = _ref8.previousValue,
215
+ nextValue = _ref8.nextValue;
216
+ const diff = [];
217
+ const locatorsDiff = getArrayDiff({
218
+ previousValue: previousValue,
219
+ nextValue: nextValue,
220
+ label: 'locators',
221
+ indentLevel: 1
222
+ });
223
+ if (locatorsDiff) {
224
+ diff.push('locators changed');
225
+ diff.push(locatorsDiff);
226
+ }
227
+ return diff.join('\n');
228
+ };
229
+ const getMainMenuLinkDiff = _ref9 => {
230
+ let previousValue = _ref9.previousValue,
231
+ nextValue = _ref9.nextValue;
232
+ const mainMenuLinkDiff = ['mainMenuLink changed'];
233
+ const menuDiff = getStringDiff({
234
+ previousValue: previousValue.defaultLabel,
235
+ nextValue: nextValue.defaultLabel,
236
+ label: 'defaultLabel',
237
+ indentLevel: 1
238
+ });
239
+ if (menuDiff) {
240
+ mainMenuLinkDiff.push(menuDiff);
241
+ }
242
+ const mainMenuLinkPermissionsDiff = getArrayDiff({
243
+ previousValue: previousValue.permissions,
244
+ nextValue: nextValue.permissions,
245
+ label: 'applied permission',
246
+ indentLevel: 2
247
+ });
248
+ if (mainMenuLinkPermissionsDiff.length > 0) {
249
+ mainMenuLinkDiff.push(`${indent(1)}permissions changed`);
250
+ mainMenuLinkDiff.push(mainMenuLinkPermissionsDiff);
251
+ }
252
+ const menuLabelsDiff = getLabelAllLocalesDiff({
253
+ previousValue: previousValue.labelAllLocales,
254
+ nextValue: nextValue.labelAllLocales,
255
+ indentLevel: 2
256
+ });
257
+ if (menuLabelsDiff) {
258
+ mainMenuLinkDiff.push(menuLabelsDiff);
259
+ }
260
+ const filteredMainMenuLinkDiff = _filterInstanceProperty(mainMenuLinkDiff).call(mainMenuLinkDiff, Boolean);
261
+ if (filteredMainMenuLinkDiff.length > 1) return filteredMainMenuLinkDiff.join('\n');
262
+ return null;
263
+ };
264
+ const getSubmenuLinksDiff = _ref10 => {
265
+ var _context6;
266
+ let previousValue = _ref10.previousValue,
267
+ nextValue = _ref10.nextValue;
268
+ const submenuLinksDiff = ['submenuLink changed'];
269
+ const mappedSubmenuLinks = _reduceInstanceProperty(previousValue).call(previousValue, (previousSubmenuLink, currentSubmenuLink) => _objectSpread(_objectSpread({}, previousSubmenuLink), {}, {
270
+ [currentSubmenuLink.uriPath]: currentSubmenuLink
271
+ }), {});
272
+ _forEachInstanceProperty(nextValue).call(nextValue, newSubmenuLink => {
273
+ const oldSubMenuLink = mappedSubmenuLinks[newSubmenuLink.uriPath];
274
+ if (newSubmenuLink.uriPath in mappedSubmenuLinks) {
275
+ var _context5;
276
+ const submenuLinkDiff = [`${indent(1)}menu link "${newSubmenuLink.uriPath}" changed`];
277
+ _forEachInstanceProperty(_context5 = _Object$keys(mappedSubmenuLinks[newSubmenuLink.uriPath])).call(_context5, key => {
278
+ switch (key) {
279
+ case 'defaultLabel':
280
+ {
281
+ const labelDiff = getStringDiff({
282
+ previousValue: oldSubMenuLink.defaultLabel,
283
+ nextValue: newSubmenuLink.defaultLabel,
284
+ label: 'defaultLabel',
285
+ indentLevel: 2
286
+ });
287
+ if (labelDiff) {
288
+ submenuLinkDiff.push(labelDiff);
289
+ }
290
+ break;
291
+ }
292
+ case 'permissions':
293
+ {
294
+ const submenuLinkPermissionsDiff = getArrayDiff({
295
+ previousValue: oldSubMenuLink.permissions,
296
+ nextValue: newSubmenuLink.permissions,
297
+ label: 'applied permission',
298
+ indentLevel: 3
299
+ });
300
+ if (submenuLinkPermissionsDiff.length > 0) {
301
+ submenuLinkDiff.push(`${indent(2)}permissions changed`);
302
+ submenuLinkDiff.push(submenuLinkPermissionsDiff);
303
+ }
304
+ break;
305
+ }
306
+ case 'labelAllLocales':
307
+ {
308
+ const labelsDiff = getLabelAllLocalesDiff({
309
+ previousValue: oldSubMenuLink.labelAllLocales,
310
+ nextValue: newSubmenuLink.labelAllLocales,
311
+ indentLevel: 3
312
+ });
313
+ if (labelsDiff) {
314
+ submenuLinkDiff.push(labelsDiff);
315
+ }
316
+ break;
317
+ }
318
+ }
319
+ });
320
+ delete mappedSubmenuLinks[newSubmenuLink.uriPath];
321
+ const filteredSubmenuLinksDiff = _filterInstanceProperty(submenuLinkDiff).call(submenuLinkDiff, Boolean);
322
+ if (filteredSubmenuLinksDiff.length > 1) {
323
+ submenuLinksDiff.push(filteredSubmenuLinksDiff.join('\n'));
324
+ }
325
+ } else {
326
+ const linksDiff = getStringDiff({
327
+ nextValue: newSubmenuLink.uriPath,
328
+ label: 'menu link',
329
+ indentLevel: 1
330
+ });
331
+ if (linksDiff) {
332
+ submenuLinksDiff.push(linksDiff);
333
+ }
334
+ }
335
+ });
336
+ _forEachInstanceProperty(_context6 = _Object$keys(mappedSubmenuLinks)).call(_context6, key => {
337
+ const linksDiff = getStringDiff({
338
+ previousValue: key,
339
+ label: 'menu link',
340
+ indentLevel: 1
341
+ });
342
+ if (linksDiff) submenuLinksDiff.push(linksDiff);
343
+ });
344
+ if (submenuLinksDiff.length > 1) return submenuLinksDiff.join('\n');
345
+ return null;
346
+ };
347
+
348
+ // Compute diff changes of the Custom Application config.
349
+ // NOTE: Only known keys are evaluated.
350
+ const getCustomApplicationConfigDiff = (oldConfig, newConfig) => {
351
+ const diff = [];
352
+
353
+ // Name
354
+ const nameDiff = getStringDiff({
355
+ previousValue: oldConfig.name,
356
+ nextValue: newConfig.name,
357
+ label: 'name'
358
+ });
359
+ if (nameDiff) {
360
+ diff.push(nameDiff);
361
+ }
362
+
363
+ // Description
364
+ const descriptionDiff = getStringDiff({
365
+ previousValue: oldConfig.description,
366
+ nextValue: newConfig.description,
367
+ label: 'description'
368
+ });
369
+ if (descriptionDiff) {
370
+ diff.push(descriptionDiff);
371
+ }
372
+
373
+ // URL
374
+ const urlDiff = getStringDiff({
375
+ previousValue: oldConfig.url,
376
+ nextValue: newConfig.url,
377
+ label: 'url'
378
+ });
379
+ if (urlDiff) {
380
+ diff.push(urlDiff);
381
+ }
382
+
383
+ // Icon
384
+ const iconDiff = getStringDiff({
385
+ // This icon stored in the database has already been sanitized.
386
+ previousValue: oldConfig.icon,
387
+ // Sanitize the raw icon as-if it was stored in the database,
388
+ // to ensure the data can be safely compared.
389
+ nextValue: sanitizeSvg(newConfig.icon),
390
+ label: 'icon'
391
+ });
392
+ if (iconDiff) {
393
+ diff.push(iconDiff);
394
+ }
395
+
396
+ // Permissions
397
+ const permissionsDiff = getPermissionsDiff({
398
+ previousValue: oldConfig.permissions,
399
+ nextValue: newConfig.permissions
400
+ });
401
+ if (permissionsDiff) {
402
+ diff.push(permissionsDiff);
403
+ }
404
+
405
+ // Main menu link
406
+ const mainMenuDiff = getMainMenuLinkDiff({
407
+ previousValue: oldConfig.mainMenuLink,
408
+ nextValue: newConfig.mainMenuLink
409
+ });
410
+ if (mainMenuDiff) {
411
+ diff.push(mainMenuDiff);
412
+ }
413
+
414
+ // Submenu links
415
+ const submenuDiff = getSubmenuLinksDiff({
416
+ previousValue: oldConfig.submenuLinks,
417
+ nextValue: newConfig.submenuLinks
418
+ });
419
+ if (submenuDiff) {
420
+ diff.push(submenuDiff);
421
+ }
422
+ return diff.join('\n');
423
+ };
424
+
425
+ // Compute diff changes of the Custom View config.
426
+ // NOTE: Only known keys are evaluated.
427
+ const getCustomViewConfigDiff = (oldConfig, newConfig) => {
428
+ const diff = [];
429
+
430
+ // Default Label
431
+ const defaultLabelDiff = getStringDiff({
432
+ previousValue: oldConfig.defaultLabel,
433
+ nextValue: newConfig.defaultLabel,
434
+ label: 'defaultLabel'
435
+ });
436
+ if (defaultLabelDiff) {
437
+ diff.push(defaultLabelDiff);
438
+ }
439
+
440
+ // Description
441
+ const descriptionDiff = getStringDiff({
442
+ previousValue: oldConfig.description,
443
+ nextValue: newConfig.description,
444
+ label: 'description'
445
+ });
446
+ if (descriptionDiff) {
447
+ diff.push(descriptionDiff);
448
+ }
449
+
450
+ // URL
451
+ const urlDiff = getStringDiff({
452
+ previousValue: oldConfig.url,
453
+ nextValue: newConfig.url,
454
+ label: 'url'
455
+ });
456
+ if (urlDiff) {
457
+ diff.push(urlDiff);
458
+ }
459
+
460
+ // Type
461
+ const typeDiff = getStringDiff({
462
+ previousValue: oldConfig.type,
463
+ nextValue: newConfig.type,
464
+ label: 'type'
465
+ });
466
+ if (typeDiff) {
467
+ diff.push(typeDiff);
468
+ }
469
+
470
+ // Permissions
471
+ const permissionsDiff = getPermissionsDiff({
472
+ previousValue: oldConfig.permissions,
473
+ nextValue: newConfig.permissions
474
+ });
475
+ if (permissionsDiff) {
476
+ diff.push(permissionsDiff);
477
+ }
478
+
479
+ // Label All Locales
480
+ const labelsDiff = getLabelAllLocalesDiff({
481
+ previousValue: oldConfig.labelAllLocales,
482
+ nextValue: newConfig.labelAllLocales,
483
+ indentLevel: 1
484
+ });
485
+ if (labelsDiff) {
486
+ diff.push(labelsDiff);
487
+ }
488
+
489
+ // Type settings
490
+ const typeSettingsDiff = getTypeSettingsDiff({
491
+ previousValue: oldConfig.typeSettings,
492
+ nextValue: newConfig.typeSettings
493
+ });
494
+ if (typeSettingsDiff) {
495
+ diff.push(typeSettingsDiff);
496
+ }
497
+
498
+ // Locators
499
+ const locatorsDiff = getLocatorsDiff({
500
+ previousValue: oldConfig.locators,
501
+ nextValue: newConfig.locators
502
+ });
503
+ if (locatorsDiff) {
504
+ diff.push(locatorsDiff);
505
+ }
506
+ return diff.join('\n');
507
+ };
508
+
509
+ const credentialsStorage = new CredentialsStorage();
510
+ const getMcUrlLink = _ref => {
511
+ let mcApiUrl = _ref.mcApiUrl,
512
+ organizationId = _ref.organizationId,
513
+ customEntityId = _ref.customEntityId,
514
+ isCustomView = _ref.isCustomView;
515
+ const mcUrl = mcApiUrl.replace('mc-api', 'mc');
516
+ const customEntityLink = `${mcUrl}/account/organizations/${organizationId}/custom-${isCustomView ? 'views' : 'applications'}/owned/${customEntityId}`;
517
+ return customEntityLink;
518
+ };
519
+ const isCustomViewData = data => data.entryPointUriPath === undefined;
520
+ async function createOrUpdateCustomApplication(_ref2) {
521
+ var _context3;
522
+ let mcApiUrl = _ref2.mcApiUrl,
523
+ localCustomEntityData = _ref2.localCustomEntityData,
524
+ applicationIdentifier = _ref2.applicationIdentifier,
525
+ options = _ref2.options;
526
+ const fetchedCustomApplication = await fetchCustomApplication({
527
+ mcApiUrl,
528
+ entryPointUriPath: localCustomEntityData.entryPointUriPath,
529
+ applicationIdentifier
530
+ });
531
+ if (!fetchedCustomApplication) {
532
+ var _context2;
533
+ const userOrganizations = await fetchUserOrganizations({
534
+ mcApiUrl,
535
+ applicationIdentifier
536
+ });
537
+ let organizationId, organizationName;
538
+ if (userOrganizations.total === 0) {
539
+ 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.`);
540
+ }
541
+ if (userOrganizations.total === 1) {
542
+ const _userOrganizations$re = _slicedToArray(userOrganizations.results, 1),
543
+ organization = _userOrganizations$re[0];
544
+ organizationId = organization.id;
545
+ organizationName = organization.name;
546
+ } else {
547
+ var _context;
548
+ const organizationChoices = _mapInstanceProperty(_context = userOrganizations.results).call(_context, organization => ({
549
+ title: organization.name,
550
+ value: organization.id
551
+ }));
552
+ const _await$prompts = await prompts({
553
+ type: 'select',
554
+ name: 'organizationId',
555
+ message: 'Select an Organization',
556
+ choices: organizationChoices,
557
+ initial: 0
558
+ }),
559
+ selectedOrganizationId = _await$prompts.organizationId;
560
+ if (!selectedOrganizationId) {
561
+ throw new Error(`No Organization selected, aborting.`);
562
+ }
563
+ organizationId = selectedOrganizationId;
564
+ organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref3 => {
565
+ let value = _ref3.value;
566
+ return value === organizationId;
567
+ }).title;
568
+ }
569
+ const _await$prompts2 = await prompts({
570
+ type: 'text',
571
+ name: 'confirmation',
572
+ message: _filterInstanceProperty(_context2 = [`You are about to create a new Custom Application in the "${chalk.green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be created.')]).call(_context2, Boolean).join('\n'),
573
+ initial: 'yes'
574
+ }),
575
+ confirmation = _await$prompts2.confirmation;
576
+ if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
577
+ console.log(chalk.red('Aborted.'));
578
+ return;
579
+ }
580
+ const data = omit(localCustomEntityData, ['id']);
581
+ if (options.dryRun) {
582
+ console.log();
583
+ console.log(`The following payload would be used to create a new Custom Application.`);
584
+ console.log();
585
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
586
+ return;
587
+ }
588
+ const createdCustomApplication = await createCustomApplication({
589
+ mcApiUrl,
590
+ organizationId,
591
+ data,
592
+ applicationIdentifier
593
+ });
594
+
595
+ // This check is technically not necessary, as the `graphql-request` client
596
+ // throws an error in case of GraphQL errors.
597
+ // However, the generated TypeScript data related to the GraphQL query has the
598
+ // field typed as optional, thus having an extra check for type correctness.
599
+ if (!createdCustomApplication) {
600
+ throw new Error('Failed to create the Custom Application.');
601
+ }
602
+ const customAppLink = getMcUrlLink({
603
+ mcApiUrl,
604
+ organizationId,
605
+ customEntityId: createdCustomApplication.id
606
+ });
607
+ console.log(chalk.green(`Custom Application created.\nPlease update the "env.production.applicationId" field in your local Custom Application config file with the following value: "${chalk.green(createdCustomApplication.id)}".`));
608
+ console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
609
+ return;
610
+ }
611
+ const customAppLink = getMcUrlLink({
612
+ mcApiUrl,
613
+ organizationId: fetchedCustomApplication.organizationId,
614
+ customEntityId: fetchedCustomApplication.application.id
615
+ });
616
+ const configDiff = getCustomApplicationConfigDiff(fetchedCustomApplication.application, localCustomEntityData);
617
+ if (!configDiff) {
618
+ console.log(chalk.green(`Custom Application up-to-date.`));
619
+ console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
620
+ return;
621
+ }
622
+ console.log('Changes detected:');
623
+ console.log(configDiff);
624
+ console.log();
625
+ const _await$prompts3 = await prompts({
626
+ type: 'text',
627
+ name: 'confirmation',
628
+ message: _filterInstanceProperty(_context3 = [`You are about to update the Custom Application "${chalk.green(localCustomEntityData.entryPointUriPath)}" with the changes above. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be updated.')]).call(_context3, Boolean).join('\n'),
629
+ initial: 'yes'
630
+ }),
631
+ confirmation = _await$prompts3.confirmation;
632
+ if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
633
+ console.log(chalk.red('Aborted.'));
634
+ return;
635
+ }
636
+ const data = omit(localCustomEntityData, ['id']);
637
+ if (options.dryRun) {
638
+ console.log();
639
+ console.log(`The following payload would be used to update the Custom Application "${chalk.green(data.entryPointUriPath)}".`);
640
+ console.log();
641
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
642
+ return;
643
+ }
644
+ await updateCustomApplication({
645
+ mcApiUrl,
646
+ organizationId: fetchedCustomApplication.organizationId,
647
+ data: omit(localCustomEntityData, ['id']),
648
+ applicationId: fetchedCustomApplication.application.id,
649
+ applicationIdentifier
650
+ });
651
+ console.log(chalk.green(`Custom Application updated.`));
652
+ console.log(`You can inspect the Custom Application data in the Merchant Center at "${chalk.gray(customAppLink)}".`);
653
+ }
654
+ async function createOrUpdateCustomView(_ref4) {
655
+ var _context6;
656
+ let mcApiUrl = _ref4.mcApiUrl,
657
+ localCustomEntityData = _ref4.localCustomEntityData,
658
+ customViewId = _ref4.customViewId,
659
+ options = _ref4.options,
660
+ applicationIdentifier = _ref4.applicationIdentifier;
661
+ const fetchedCustomView = await fetchCustomView({
662
+ mcApiUrl,
663
+ customViewId,
664
+ applicationIdentifier
665
+ });
666
+ if (!fetchedCustomView) {
667
+ var _context5;
668
+ const userOrganizations = await fetchUserOrganizations({
669
+ mcApiUrl,
670
+ customViewId,
671
+ applicationIdentifier
672
+ });
673
+ let organizationId, organizationName;
674
+ if (userOrganizations.total === 0) {
675
+ 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.`);
676
+ }
677
+ if (userOrganizations.total === 1) {
678
+ const _userOrganizations$re2 = _slicedToArray(userOrganizations.results, 1),
679
+ organization = _userOrganizations$re2[0];
680
+ organizationId = organization.id;
681
+ organizationName = organization.name;
682
+ } else {
683
+ var _context4;
684
+ const organizationChoices = _mapInstanceProperty(_context4 = userOrganizations.results).call(_context4, organization => ({
685
+ title: organization.name,
686
+ value: organization.id
687
+ }));
688
+ const _await$prompts4 = await prompts({
689
+ type: 'select',
690
+ name: 'organizationId',
691
+ message: 'Select an Organization',
692
+ choices: organizationChoices,
693
+ initial: 0
694
+ }),
695
+ selectedOrganizationId = _await$prompts4.organizationId;
696
+ if (!selectedOrganizationId) {
697
+ throw new Error(`No Organization selected, aborting.`);
698
+ }
699
+ organizationId = selectedOrganizationId;
700
+ organizationName = _findInstanceProperty(organizationChoices).call(organizationChoices, _ref5 => {
701
+ let value = _ref5.value;
702
+ return value === organizationId;
703
+ }).title;
704
+ }
705
+ const _await$prompts5 = await prompts({
706
+ type: 'text',
707
+ name: 'confirmation',
708
+ message: _filterInstanceProperty(_context5 = [`You are about to create a new Custom View in the "${chalk.green(organizationName)}" organization. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be created.')]).call(_context5, Boolean).join('\n'),
709
+ initial: 'yes'
710
+ }),
711
+ confirmation = _await$prompts5.confirmation;
712
+ if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
713
+ console.log(chalk.red('Aborted.'));
714
+ return;
715
+ }
716
+ const data = omit(localCustomEntityData, ['id']);
717
+ if (options.dryRun) {
718
+ console.log();
719
+ console.log(`The following payload would be used to create a new Custom View.`);
720
+ console.log();
721
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
722
+ return;
723
+ }
724
+ const createdCustomView = await createCustomView({
725
+ mcApiUrl,
726
+ organizationId,
727
+ data,
728
+ applicationIdentifier
729
+ });
730
+
731
+ // This check is technically not necessary, as the `graphql-request` client
732
+ // throws an error in case of GraphQL errors.
733
+ // However, the generated TypeScript data related to the GraphQL query has the
734
+ // field typed as optional, thus having an extra check for type correctness.
735
+ if (!createdCustomView) {
736
+ throw new Error('Failed to create the Custom View.');
737
+ }
738
+ const customViewLink = getMcUrlLink({
739
+ mcApiUrl,
740
+ organizationId,
741
+ customEntityId: createdCustomView.id,
742
+ isCustomView: true
743
+ });
744
+ console.log(chalk.green(`Custom View created.\nPlease update the "env.production.customViewId" field in your local Custom View config file with the following value: "${chalk.green(createdCustomView.id)}".`));
745
+ console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
746
+ return;
747
+ }
748
+ const customViewLink = getMcUrlLink({
749
+ mcApiUrl,
750
+ organizationId: fetchedCustomView.organizationId,
751
+ customEntityId: fetchedCustomView?.customView?.id || '',
752
+ isCustomView: true
753
+ });
754
+ const configDiff = getCustomViewConfigDiff(fetchedCustomView.customView, localCustomEntityData);
755
+ if (!configDiff) {
756
+ console.log(chalk.green(`Custom View up-to-date.`));
757
+ console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
758
+ return;
759
+ }
760
+ console.log('Changes detected:');
761
+ console.log(configDiff);
762
+ console.log();
763
+ const _await$prompts6 = await prompts({
764
+ type: 'text',
765
+ name: 'confirmation',
766
+ message: _filterInstanceProperty(_context6 = [`You are about to update the Custom View "${chalk.green(localCustomEntityData.defaultLabel)}" with the changes above. Are you sure you want to proceed?`, options.dryRun && chalk.gray('Using "--dry-run", no data will be updated.')]).call(_context6, Boolean).join('\n'),
767
+ initial: 'yes'
768
+ }),
769
+ confirmation = _await$prompts6.confirmation;
770
+ if (!confirmation || confirmation.toLowerCase().charAt(0) !== 'y') {
771
+ console.log(chalk.red('Aborted.'));
772
+ return;
773
+ }
774
+ const data = omit(localCustomEntityData, ['id']);
775
+ if (options.dryRun) {
776
+ console.log();
777
+ console.log(`The following payload would be used to update the Custom View "${chalk.green(data.defaultLabel)}".`);
778
+ console.log();
779
+ console.log(chalk.gray(_JSON$stringify(data, null, 2)));
780
+ return;
781
+ }
782
+ await updateCustomView({
783
+ mcApiUrl,
784
+ organizationId: fetchedCustomView.organizationId,
785
+ data: omit(localCustomEntityData, ['id']),
786
+ customViewId: fetchedCustomView?.customView?.id || '',
787
+ applicationIdentifier
788
+ });
789
+ console.log(chalk.green(`Custom View updated.`));
790
+ console.log(`You can inspect the Custom View data in the Merchant Center at "${chalk.gray(customViewLink)}".`);
791
+ }
792
+ async function run(options) {
793
+ const applicationConfig = processConfig();
794
+ const localCustomEntityData = applicationConfig.data;
795
+ const _applicationConfig$en = applicationConfig.env,
796
+ mcApiUrl = _applicationConfig$en.mcApiUrl,
797
+ applicationIdentifier = _applicationConfig$en.applicationIdentifier,
798
+ customViewId = _applicationConfig$en.customViewId;
799
+ console.log(`Using Merchant Center environment "${chalk.green(mcApiUrl)}".`);
800
+ console.log();
801
+ const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
802
+ if (!isSessionValid) {
803
+ throw new Error(`You don't have a valid session. Please, run the "mc-scripts login" command to authenticate yourself.`);
804
+ }
805
+ if (isCustomViewData(localCustomEntityData)) {
806
+ createOrUpdateCustomView({
807
+ mcApiUrl,
808
+ localCustomEntityData,
809
+ applicationIdentifier,
810
+ customViewId: customViewId || localCustomEntityData.id,
811
+ options
812
+ });
813
+ } else {
814
+ createOrUpdateCustomApplication({
815
+ mcApiUrl,
816
+ localCustomEntityData,
817
+ applicationIdentifier,
818
+ options
819
+ });
820
+ }
821
+ }
822
+
823
+ export { run as default };