@commercetools-frontend/mc-scripts 22.28.0 → 22.29.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 +20 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +20 -5
- package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +20 -5
- package/dist/{build-e34b99e8.cjs.prod.js → build-62792a03.cjs.prod.js} +4 -5
- package/dist/{build-5fa51b8c.esm.js → build-66dc70af.esm.js} +4 -5
- package/dist/{build-999eabc6.cjs.dev.js → build-e3be9274.cjs.dev.js} +4 -5
- package/dist/{build-vite-0ec1e9cf.cjs.dev.js → build-vite-87662f4d.cjs.dev.js} +16 -11
- package/dist/{build-vite-5d0fa021.esm.js → build-vite-b19a39fb.esm.js} +16 -11
- package/dist/{build-vite-acf05a1a.cjs.prod.js → build-vite-c7ccff49.cjs.prod.js} +16 -11
- 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-3aaa3f5d.cjs.dev.js → config-sync-3c396d96.cjs.dev.js} +21 -208
- package/dist/{config-sync-cabd5374.esm.js → config-sync-98db26e7.esm.js} +12 -198
- package/dist/{config-sync-97ba72f5.cjs.prod.js → config-sync-b4656190.cjs.prod.js} +21 -208
- package/dist/{create-postcss-config-069ef9c3.cjs.prod.js → create-postcss-config-12b7a8d6.cjs.prod.js} +1 -1
- package/dist/{create-postcss-config-5d1737f0.cjs.dev.js → create-postcss-config-f7a8f441.cjs.dev.js} +1 -1
- package/dist/{create-postcss-config-0323c669.esm.js → create-postcss-config-fba058e4.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-43c88bf6.esm.js → create-webpack-config-for-development-5b46add2.esm.js} +1 -1
- package/dist/{create-webpack-config-for-development-e7733a1b.cjs.prod.js → create-webpack-config-for-development-ab714b8d.cjs.prod.js} +1 -1
- package/dist/{create-webpack-config-for-development-4690f4cf.cjs.dev.js → create-webpack-config-for-development-fb65e8be.cjs.dev.js} +1 -1
- package/dist/{create-webpack-config-for-production-778d2b5e.cjs.dev.js → create-webpack-config-for-production-167f752a.cjs.dev.js} +2 -2
- package/dist/{create-webpack-config-for-production-28d51113.esm.js → create-webpack-config-for-production-6125de30.esm.js} +2 -2
- package/dist/{create-webpack-config-for-production-cbf22a83.cjs.prod.js → create-webpack-config-for-production-959fa22b.cjs.prod.js} +2 -2
- package/dist/{credentials-storage-f4e08e09.esm.js → credentials-storage-0b44c17e.esm.js} +1 -1
- package/dist/{credentials-storage-0fb8f4a6.cjs.prod.js → credentials-storage-4222b4e8.cjs.prod.js} +1 -1
- package/dist/{credentials-storage-8b9ddb0b.cjs.dev.js → credentials-storage-94fe55f8.cjs.dev.js} +1 -1
- package/dist/declarations/src/commands/deployment-previews-set.d.ts +3 -0
- package/dist/declarations/src/generated/settings.d.ts +45 -0
- package/dist/declarations/src/types.d.ts +5 -0
- package/dist/declarations/src/utils/graphql-requests.d.ts +41 -2
- package/dist/declarations/src/utils/i18n-message-complilation.d.ts +4 -0
- package/dist/deployment-previews-set-848a1bf9.esm.js +197 -0
- package/dist/deployment-previews-set-dc99dc5c.cjs.dev.js +209 -0
- package/dist/deployment-previews-set-ee78c1da.cjs.prod.js +209 -0
- package/dist/graphql-requests-734ca08d.cjs.prod.js +269 -0
- package/dist/graphql-requests-9f05bdac.cjs.dev.js +269 -0
- package/dist/graphql-requests-ffd9c148.esm.js +246 -0
- package/dist/i18n-message-complilation-393d344a.cjs.prod.js +23 -0
- package/dist/i18n-message-complilation-3f80e8d6.cjs.dev.js +23 -0
- package/dist/i18n-message-complilation-8aec9d1b.esm.js +15 -0
- package/dist/{login-bd94d195.cjs.dev.js → login-8a734416.cjs.dev.js} +2 -2
- package/dist/{login-90029738.esm.js → login-933238a2.esm.js} +2 -2
- package/dist/{login-9ee301cd.cjs.prod.js → login-db3ba9ca.cjs.prod.js} +2 -2
- package/dist/{package-1bf866e8.cjs.dev.js → package-2e7a3b2c.cjs.prod.js} +12 -12
- package/dist/{package-d977cdc9.cjs.prod.js → package-5c8e1e42.cjs.dev.js} +12 -12
- package/dist/{package-50be39f9.esm.js → package-61d870ab.esm.js} +12 -12
- package/dist/{start-a0031945.cjs.prod.js → start-27e158a1.cjs.prod.js} +3 -3
- package/dist/{start-4671c540.esm.js → start-2c0c7162.esm.js} +3 -3
- package/dist/{start-54be934f.cjs.dev.js → start-336282f7.cjs.dev.js} +3 -3
- package/package.json +12 -12
- 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
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +12 -2
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +12 -2
- package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +12 -2
- package/dist/declarations/src/utils/get-i18n-message-format.d.ts +0 -3
- package/dist/get-i18n-message-format-3e59a0d7.cjs.prod.js +0 -15
- package/dist/get-i18n-message-format-44a20fa2.cjs.dev.js +0 -15
- package/dist/get-i18n-message-format-58852baf.esm.js +0 -9
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _URL = require('@babel/runtime-corejs3/core-js-stable/url');
|
|
4
|
+
var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
|
|
5
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
6
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
7
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
8
|
+
var chalk = require('chalk');
|
|
9
|
+
var prompts = require('prompts');
|
|
10
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
11
|
+
var credentialsStorage$1 = require('./credentials-storage-4222b4e8.cjs.prod.js');
|
|
12
|
+
var graphqlRequests = require('./graphql-requests-734ca08d.cjs.prod.js');
|
|
13
|
+
require('@commercetools/http-user-agent');
|
|
14
|
+
require('./package-2e7a3b2c.cjs.prod.js');
|
|
15
|
+
require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
16
|
+
require('@babel/runtime-corejs3/helpers/createClass');
|
|
17
|
+
require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
18
|
+
require('@babel/runtime-corejs3/core-js-stable/date/now');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('os');
|
|
21
|
+
require('path');
|
|
22
|
+
require('./does-file-exist-be53305d.cjs.prod.js');
|
|
23
|
+
require('node:fs');
|
|
24
|
+
require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
25
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
26
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
27
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
28
|
+
require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
29
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
30
|
+
require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
31
|
+
require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
32
|
+
require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
33
|
+
require('graphql');
|
|
34
|
+
require('graphql-request');
|
|
35
|
+
require('@commercetools-frontend/constants');
|
|
36
|
+
|
|
37
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
38
|
+
|
|
39
|
+
var _URL__default = /*#__PURE__*/_interopDefault(_URL);
|
|
40
|
+
var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
|
|
41
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
42
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
43
|
+
var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
|
|
44
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
45
|
+
var prompts__default = /*#__PURE__*/_interopDefault(prompts);
|
|
46
|
+
|
|
47
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
48
|
+
const validateUrl = function () {
|
|
49
|
+
let url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
50
|
+
try {
|
|
51
|
+
var _context;
|
|
52
|
+
const urlSchema = new _URL__default["default"](url);
|
|
53
|
+
return _includesInstanceProperty__default["default"](_context = ['http:', 'https:']).call(_context, urlSchema.protocol);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const validateAlias = function () {
|
|
59
|
+
let alias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
60
|
+
try {
|
|
61
|
+
new _URL__default["default"]("https://".concat(alias, ".commercetools.com/"));
|
|
62
|
+
return true;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const getMcUrlLink = _ref => {
|
|
68
|
+
var _context2, _context3, _context4;
|
|
69
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
70
|
+
organizationId = _ref.organizationId,
|
|
71
|
+
customEntityId = _ref.customEntityId,
|
|
72
|
+
isCustomView = _ref.isCustomView;
|
|
73
|
+
const mcUrl = mcApiUrl.replace('mc-api', 'mc');
|
|
74
|
+
const customEntityLink = _concatInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](_context3 = _concatInstanceProperty__default["default"](_context4 = "".concat(mcUrl, "/account/organizations/")).call(_context4, organizationId, "/custom-")).call(_context3, isCustomView ? 'views' : 'applications', "/owned/")).call(_context2, customEntityId, "/deployment-previews");
|
|
75
|
+
return customEntityLink;
|
|
76
|
+
};
|
|
77
|
+
const isCustomViewData = data => data.entryPointUriPath === undefined;
|
|
78
|
+
async function setDeploymentPreview(_ref2) {
|
|
79
|
+
var _context6;
|
|
80
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
81
|
+
applicationId = _ref2.applicationId,
|
|
82
|
+
applicationIdentifier = _ref2.applicationIdentifier,
|
|
83
|
+
localCustomEntityData = _ref2.localCustomEntityData,
|
|
84
|
+
isCustomView = _ref2.isCustomView,
|
|
85
|
+
options = _ref2.options;
|
|
86
|
+
/*
|
|
87
|
+
1. Check if the Custom Application exists in the Merchant Center.
|
|
88
|
+
2. Ask for the alias and URL of the deployment preview.
|
|
89
|
+
3. Check whether it exists a deployment preview with the same alias.
|
|
90
|
+
4. If it exists, ask for confirmation to update it.
|
|
91
|
+
5. If it doesn't exist, ask for confirmation to create it.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
const fetchedCustomApplication = await graphqlRequests.fetchCustomApplication({
|
|
95
|
+
mcApiUrl,
|
|
96
|
+
entryPointUriPath: localCustomEntityData.entryPointUriPath,
|
|
97
|
+
applicationIdentifier
|
|
98
|
+
});
|
|
99
|
+
if (!fetchedCustomApplication) {
|
|
100
|
+
throw new Error("The Custom Application \"".concat(applicationIdentifier, "\" does not exist in the Merchant Center. Please create a Custom Application first before configuring deployment previews."));
|
|
101
|
+
}
|
|
102
|
+
let deploymentAlias = options.alias;
|
|
103
|
+
// If the alias was not provided as an argument to the script, let's ask for it.
|
|
104
|
+
if (!deploymentAlias) {
|
|
105
|
+
var _context5;
|
|
106
|
+
const _await$prompts = await prompts__default["default"]({
|
|
107
|
+
type: 'text',
|
|
108
|
+
name: 'alias',
|
|
109
|
+
message: _filterInstanceProperty__default["default"](_context5 = ["Enter the alias for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context5, Boolean).join('\n'),
|
|
110
|
+
validate: value => validateAlias(value)
|
|
111
|
+
}),
|
|
112
|
+
alias = _await$prompts.alias;
|
|
113
|
+
deploymentAlias = alias;
|
|
114
|
+
}
|
|
115
|
+
const existingDeploymentPreview = _findInstanceProperty__default["default"](_context6 = fetchedCustomApplication.application.deployments).call(_context6, deployment => deployment.alias === deploymentAlias);
|
|
116
|
+
if (!options.alias && !options.url && existingDeploymentPreview) {
|
|
117
|
+
var _context7;
|
|
118
|
+
const _await$prompts2 = await prompts__default["default"]({
|
|
119
|
+
type: 'confirm',
|
|
120
|
+
name: 'aliasOverrideConfirmation',
|
|
121
|
+
message: _filterInstanceProperty__default["default"](_context7 = ["The alias \"".concat(chalk__default["default"].green(deploymentAlias), "\" already exists. Do you want to proceed and update the URL?"), options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context7, Boolean).join('\n'),
|
|
122
|
+
initial: false
|
|
123
|
+
}),
|
|
124
|
+
aliasOverrideConfirmation = _await$prompts2.aliasOverrideConfirmation;
|
|
125
|
+
if (!aliasOverrideConfirmation) {
|
|
126
|
+
console.log(chalk__default["default"].red('Aborted.'));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let deploymentUrl = options.url;
|
|
131
|
+
if (!deploymentUrl) {
|
|
132
|
+
var _context8;
|
|
133
|
+
const _await$prompts3 = await prompts__default["default"]({
|
|
134
|
+
type: 'text',
|
|
135
|
+
name: 'url',
|
|
136
|
+
message: _filterInstanceProperty__default["default"](_context8 = ["Enter the URL for the deployment preview", options.dryRun && chalk__default["default"].gray('Using "--dry-run", no deployment preview will be created.')]).call(_context8, Boolean).join('\n'),
|
|
137
|
+
validate: value => validateUrl(value)
|
|
138
|
+
}),
|
|
139
|
+
url = _await$prompts3.url;
|
|
140
|
+
deploymentUrl = url;
|
|
141
|
+
}
|
|
142
|
+
if (options.dryRun) {
|
|
143
|
+
var _context9, _context10;
|
|
144
|
+
const message = existingDeploymentPreview ? _concatInstanceProperty__default["default"](_context9 = "The existing deployment preview with alias \"".concat(deploymentAlias, "\" would have been updated with this url: \"")).call(_context9, deploymentUrl, "\".") : _concatInstanceProperty__default["default"](_context10 = "A new deployment preview with alias \"".concat(deploymentAlias, "\" would have been created with this url: \"")).call(_context10, deploymentUrl, "\".");
|
|
145
|
+
console.log("\n".concat(message, "\n"));
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const mcDeploymentPreviewsLink = getMcUrlLink({
|
|
149
|
+
mcApiUrl,
|
|
150
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
151
|
+
customEntityId: fetchedCustomApplication.application.id,
|
|
152
|
+
isCustomView
|
|
153
|
+
});
|
|
154
|
+
if (existingDeploymentPreview) {
|
|
155
|
+
var _context11;
|
|
156
|
+
await graphqlRequests.updateCustomApplicationDeploymentPreview({
|
|
157
|
+
mcApiUrl,
|
|
158
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
159
|
+
applicationIdentifier,
|
|
160
|
+
deploymentId: existingDeploymentPreview.id,
|
|
161
|
+
data: {
|
|
162
|
+
url: deploymentUrl
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context11 = "Deployment preview with alias \"".concat(deploymentAlias, "\" updated successfully with URL \"")).call(_context11, deploymentUrl, "\".")));
|
|
166
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
167
|
+
} else {
|
|
168
|
+
var _context12;
|
|
169
|
+
await graphqlRequests.createCustomApplicationDeploymentPreview({
|
|
170
|
+
mcApiUrl,
|
|
171
|
+
organizationId: fetchedCustomApplication.organizationId,
|
|
172
|
+
applicationIdentifier,
|
|
173
|
+
applicationId,
|
|
174
|
+
data: {
|
|
175
|
+
alias: deploymentAlias,
|
|
176
|
+
url: deploymentUrl
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
console.log(chalk__default["default"].green(_concatInstanceProperty__default["default"](_context12 = "Deployment preview with alias \"".concat(deploymentAlias, "\" created successfully with URL \"")).call(_context12, deploymentUrl, "\".")));
|
|
180
|
+
console.log(chalk__default["default"].green("You can access the deployment previews at: ".concat(mcDeploymentPreviewsLink)));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async function run(options) {
|
|
184
|
+
const applicationConfig$1 = applicationConfig.processConfig();
|
|
185
|
+
const localCustomEntityData = applicationConfig$1.data;
|
|
186
|
+
const _applicationConfig$en = applicationConfig$1.env,
|
|
187
|
+
mcApiUrl = _applicationConfig$en.mcApiUrl,
|
|
188
|
+
applicationIdentifier = _applicationConfig$en.applicationIdentifier;
|
|
189
|
+
const isCustomView = isCustomViewData(localCustomEntityData);
|
|
190
|
+
console.log("Using Merchant Center environment \"".concat(chalk__default["default"].green(mcApiUrl), "\"."));
|
|
191
|
+
console.log();
|
|
192
|
+
const isSessionValid = credentialsStorage.isSessionValid(mcApiUrl);
|
|
193
|
+
if (!isSessionValid) {
|
|
194
|
+
throw new Error("You don't have a valid session. Please, run the \"mc-scripts login\" command to authenticate yourself.");
|
|
195
|
+
}
|
|
196
|
+
if (isCustomView) {
|
|
197
|
+
throw new Error('Deployments previews are not supported for Custom Views.');
|
|
198
|
+
}
|
|
199
|
+
await setDeploymentPreview({
|
|
200
|
+
mcApiUrl,
|
|
201
|
+
applicationId: localCustomEntityData.id,
|
|
202
|
+
applicationIdentifier,
|
|
203
|
+
localCustomEntityData,
|
|
204
|
+
isCustomView,
|
|
205
|
+
options
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports["default"] = run;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
4
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
6
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
7
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
9
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
11
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
12
|
+
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
13
|
+
var chalk = require('chalk');
|
|
14
|
+
var graphql = require('graphql');
|
|
15
|
+
var graphqlRequest = require('graphql-request');
|
|
16
|
+
var constants = require('@commercetools-frontend/constants');
|
|
17
|
+
var credentialsStorage$1 = require('./credentials-storage-4222b4e8.cjs.prod.js');
|
|
18
|
+
|
|
19
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
20
|
+
|
|
21
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
22
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
23
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
24
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
25
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
26
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
27
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
28
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
29
|
+
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
30
|
+
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
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; }
|
|
34
|
+
var CreateCustomApplicationDeploymentPreviewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "CreateCustomApplicationDeploymentPreview" }, 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: "applicationId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "ID" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDeploymentPreviewCreateInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "createCustomApplicationDeploymentPreview" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "applicationId" }, value: { kind: "Variable", name: { kind: "Name", value: "applicationId" } } }, { 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: [] }, { kind: "Field", name: { kind: "Name", value: "alias" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 327, source: { body: "mutation CreateCustomApplicationDeploymentPreview(\n $organizationId: String!\n $applicationId: ID!\n $data: CustomApplicationDeploymentPreviewCreateInput!\n) {\n createCustomApplicationDeploymentPreview(\n organizationId: $organizationId\n applicationId: $applicationId\n data: $data\n ) {\n id\n alias\n url\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
35
|
+
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 } } } };
|
|
36
|
+
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 } } } };
|
|
37
|
+
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: [] }] } }] } }, { kind: "Field", name: { kind: "Name", value: "deployments" }, arguments: [], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "id" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "alias" }, arguments: [], directives: [] }] } }] } }] } }] } }], loc: { start: 0, end: 712, 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 deployments {\n id\n url\n alias\n }\n }\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
38
|
+
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 } } } };
|
|
39
|
+
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 } } } };
|
|
40
|
+
var UpdateCustomApplicationDeploymentPreviewFromCli = { kind: "Document", definitions: [{ kind: "OperationDefinition", operation: "mutation", name: { kind: "Name", value: "UpdateCustomApplicationDeploymentPreview" }, 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: "deploymentId" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "ID" } } }, directives: [] }, { kind: "VariableDefinition", variable: { kind: "Variable", name: { kind: "Name", value: "data" } }, type: { kind: "NonNullType", type: { kind: "NamedType", name: { kind: "Name", value: "CustomApplicationDeploymentPreviewUpdateInput" } } }, directives: [] }], directives: [], selectionSet: { kind: "SelectionSet", selections: [{ kind: "Field", name: { kind: "Name", value: "updateCustomApplicationDeploymentPreview" }, arguments: [{ kind: "Argument", name: { kind: "Name", value: "organizationId" }, value: { kind: "Variable", name: { kind: "Name", value: "organizationId" } } }, { kind: "Argument", name: { kind: "Name", value: "deploymentId" }, value: { kind: "Variable", name: { kind: "Name", value: "deploymentId" } } }, { 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: [] }, { kind: "Field", name: { kind: "Name", value: "alias" }, arguments: [], directives: [] }, { kind: "Field", name: { kind: "Name", value: "url" }, arguments: [], directives: [] }] } }] } }], loc: { start: 0, end: 324, source: { body: "mutation UpdateCustomApplicationDeploymentPreview(\n $organizationId: String!\n $deploymentId: ID!\n $data: CustomApplicationDeploymentPreviewUpdateInput!\n) {\n updateCustomApplicationDeploymentPreview(\n organizationId: $organizationId\n deploymentId: $deploymentId\n data: $data\n ) {\n id\n alias\n url\n }\n}\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } } } };
|
|
41
|
+
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 } } } };
|
|
42
|
+
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 } } } };
|
|
43
|
+
const credentialsStorage = new credentialsStorage$1.CredentialsStorage();
|
|
44
|
+
async function requestWithTokenRetry(document, requestOptions) {
|
|
45
|
+
let retryCount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
46
|
+
const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
|
|
47
|
+
const client = new graphqlRequest.GraphQLClient("".concat(requestOptions.mcApiUrl, "/graphql"), {
|
|
48
|
+
headers: _objectSpread(_objectSpread({
|
|
49
|
+
Accept: 'application/json',
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
'x-user-agent': credentialsStorage$1.userAgent
|
|
52
|
+
}, token ? {
|
|
53
|
+
'x-mc-cli-access-token': token
|
|
54
|
+
} : {}), requestOptions.headers)
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
|
|
58
|
+
|
|
59
|
+
// In case a new session token is returned from the server, save it.
|
|
60
|
+
const refreshedSessionToken = result.headers.get('x-refreshed-session-token');
|
|
61
|
+
if (refreshedSessionToken) {
|
|
62
|
+
console.log(chalk__default["default"].green('Session token refreshed.'));
|
|
63
|
+
console.log();
|
|
64
|
+
const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
|
|
65
|
+
// Store the updated access token.
|
|
66
|
+
credentialsStorage.setToken(requestOptions.mcApiUrl, {
|
|
67
|
+
token: refreshedSessionToken,
|
|
68
|
+
expiresAt: Number(refreshedSessionTokenExpiresAt)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return result.data;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
if (error instanceof graphqlRequest.ClientError) {
|
|
74
|
+
// If it's an unauthorized error, retry the request to force the token to be refreshed.
|
|
75
|
+
if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
|
|
76
|
+
var _context;
|
|
77
|
+
const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => {
|
|
78
|
+
var _graphqlError$extensi;
|
|
79
|
+
return ((_graphqlError$extensi = graphqlError.extensions) === null || _graphqlError$extensi === void 0 ? void 0 : _graphqlError$extensi.code) === 'UNAUTHENTICATED';
|
|
80
|
+
});
|
|
81
|
+
if (isUnauthorizedError) {
|
|
82
|
+
console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
|
|
83
|
+
return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
|
|
84
|
+
headers: _objectSpread(_objectSpread({}, requestOptions.headers), {}, {
|
|
85
|
+
'X-Force-Token': 'true'
|
|
86
|
+
})
|
|
87
|
+
}), retryCount + 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const fetchCustomApplication = async _ref => {
|
|
95
|
+
let mcApiUrl = _ref.mcApiUrl,
|
|
96
|
+
entryPointUriPath = _ref.entryPointUriPath,
|
|
97
|
+
applicationIdentifier = _ref.applicationIdentifier;
|
|
98
|
+
const customAppData = await requestWithTokenRetry(FetchCustomApplicationFromCli, {
|
|
99
|
+
variables: {
|
|
100
|
+
entryPointUriPath
|
|
101
|
+
},
|
|
102
|
+
mcApiUrl,
|
|
103
|
+
headers: {
|
|
104
|
+
'x-application-id': applicationIdentifier,
|
|
105
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return customAppData.organizationExtensionForCustomApplication;
|
|
109
|
+
};
|
|
110
|
+
const fetchCustomView = async _ref2 => {
|
|
111
|
+
let mcApiUrl = _ref2.mcApiUrl,
|
|
112
|
+
customViewId = _ref2.customViewId,
|
|
113
|
+
applicationIdentifier = _ref2.applicationIdentifier;
|
|
114
|
+
const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
|
|
115
|
+
variables: {
|
|
116
|
+
customViewId
|
|
117
|
+
},
|
|
118
|
+
mcApiUrl,
|
|
119
|
+
headers: {
|
|
120
|
+
'x-custom-view-id': customViewId,
|
|
121
|
+
'x-application-id': applicationIdentifier,
|
|
122
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return customViewData.organizationExtensionForCustomView;
|
|
126
|
+
};
|
|
127
|
+
const updateCustomApplication = async _ref3 => {
|
|
128
|
+
let mcApiUrl = _ref3.mcApiUrl,
|
|
129
|
+
applicationId = _ref3.applicationId,
|
|
130
|
+
organizationId = _ref3.organizationId,
|
|
131
|
+
data = _ref3.data,
|
|
132
|
+
applicationIdentifier = _ref3.applicationIdentifier;
|
|
133
|
+
const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
|
|
134
|
+
variables: {
|
|
135
|
+
organizationId,
|
|
136
|
+
applicationId,
|
|
137
|
+
data
|
|
138
|
+
},
|
|
139
|
+
mcApiUrl,
|
|
140
|
+
headers: {
|
|
141
|
+
'x-application-id': applicationIdentifier,
|
|
142
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return updatedCustomAppsData.updateCustomApplication;
|
|
146
|
+
};
|
|
147
|
+
const updateCustomView = async _ref4 => {
|
|
148
|
+
let mcApiUrl = _ref4.mcApiUrl,
|
|
149
|
+
organizationId = _ref4.organizationId,
|
|
150
|
+
data = _ref4.data,
|
|
151
|
+
customViewId = _ref4.customViewId,
|
|
152
|
+
applicationIdentifier = _ref4.applicationIdentifier;
|
|
153
|
+
const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
|
|
154
|
+
variables: {
|
|
155
|
+
organizationId,
|
|
156
|
+
customViewId,
|
|
157
|
+
data
|
|
158
|
+
},
|
|
159
|
+
mcApiUrl,
|
|
160
|
+
headers: {
|
|
161
|
+
'x-custom-view-id': customViewId,
|
|
162
|
+
'x-application-id': applicationIdentifier,
|
|
163
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return updatedCustomViewData.updateCustomView;
|
|
167
|
+
};
|
|
168
|
+
const createCustomApplication = async _ref5 => {
|
|
169
|
+
let mcApiUrl = _ref5.mcApiUrl,
|
|
170
|
+
organizationId = _ref5.organizationId,
|
|
171
|
+
data = _ref5.data,
|
|
172
|
+
applicationIdentifier = _ref5.applicationIdentifier;
|
|
173
|
+
const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
|
|
174
|
+
variables: {
|
|
175
|
+
organizationId,
|
|
176
|
+
data
|
|
177
|
+
},
|
|
178
|
+
mcApiUrl,
|
|
179
|
+
headers: {
|
|
180
|
+
'x-application-id': applicationIdentifier,
|
|
181
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return createdCustomAppData.createCustomApplication;
|
|
185
|
+
};
|
|
186
|
+
const createCustomView = async _ref6 => {
|
|
187
|
+
let mcApiUrl = _ref6.mcApiUrl,
|
|
188
|
+
organizationId = _ref6.organizationId,
|
|
189
|
+
data = _ref6.data,
|
|
190
|
+
applicationIdentifier = _ref6.applicationIdentifier;
|
|
191
|
+
const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
|
|
192
|
+
variables: {
|
|
193
|
+
organizationId,
|
|
194
|
+
data
|
|
195
|
+
},
|
|
196
|
+
mcApiUrl,
|
|
197
|
+
headers: {
|
|
198
|
+
'x-application-id': applicationIdentifier,
|
|
199
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return createdCustomViewData.createCustomView;
|
|
203
|
+
};
|
|
204
|
+
const fetchUserOrganizations = async _ref7 => {
|
|
205
|
+
let mcApiUrl = _ref7.mcApiUrl,
|
|
206
|
+
applicationIdentifier = _ref7.applicationIdentifier,
|
|
207
|
+
customViewId = _ref7.customViewId;
|
|
208
|
+
const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
|
|
209
|
+
mcApiUrl,
|
|
210
|
+
headers: _objectSpread(_objectSpread({
|
|
211
|
+
'x-application-id': applicationIdentifier
|
|
212
|
+
}, customViewId && {
|
|
213
|
+
'x-custom-view-id': customViewId
|
|
214
|
+
}), {}, {
|
|
215
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
return userOrganizations.myOrganizations;
|
|
219
|
+
};
|
|
220
|
+
const createCustomApplicationDeploymentPreview = async _ref8 => {
|
|
221
|
+
let mcApiUrl = _ref8.mcApiUrl,
|
|
222
|
+
organizationId = _ref8.organizationId,
|
|
223
|
+
applicationId = _ref8.applicationId,
|
|
224
|
+
applicationIdentifier = _ref8.applicationIdentifier,
|
|
225
|
+
data = _ref8.data;
|
|
226
|
+
const createdDeploymentPreviewResult = await requestWithTokenRetry(CreateCustomApplicationDeploymentPreviewFromCli, {
|
|
227
|
+
variables: {
|
|
228
|
+
organizationId,
|
|
229
|
+
applicationId,
|
|
230
|
+
data
|
|
231
|
+
},
|
|
232
|
+
mcApiUrl,
|
|
233
|
+
headers: {
|
|
234
|
+
'x-application-id': applicationIdentifier,
|
|
235
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return createdDeploymentPreviewResult.createCustomApplicationDeploymentPreview;
|
|
239
|
+
};
|
|
240
|
+
const updateCustomApplicationDeploymentPreview = async _ref9 => {
|
|
241
|
+
let mcApiUrl = _ref9.mcApiUrl,
|
|
242
|
+
organizationId = _ref9.organizationId,
|
|
243
|
+
deploymentId = _ref9.deploymentId,
|
|
244
|
+
data = _ref9.data,
|
|
245
|
+
applicationIdentifier = _ref9.applicationIdentifier;
|
|
246
|
+
const updatedDeploymentPreviewResult = await requestWithTokenRetry(UpdateCustomApplicationDeploymentPreviewFromCli, {
|
|
247
|
+
variables: {
|
|
248
|
+
organizationId,
|
|
249
|
+
deploymentId,
|
|
250
|
+
data
|
|
251
|
+
},
|
|
252
|
+
mcApiUrl,
|
|
253
|
+
headers: {
|
|
254
|
+
'x-application-id': applicationIdentifier,
|
|
255
|
+
'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
exports.createCustomApplication = createCustomApplication;
|
|
262
|
+
exports.createCustomApplicationDeploymentPreview = createCustomApplicationDeploymentPreview;
|
|
263
|
+
exports.createCustomView = createCustomView;
|
|
264
|
+
exports.fetchCustomApplication = fetchCustomApplication;
|
|
265
|
+
exports.fetchCustomView = fetchCustomView;
|
|
266
|
+
exports.fetchUserOrganizations = fetchUserOrganizations;
|
|
267
|
+
exports.updateCustomApplication = updateCustomApplication;
|
|
268
|
+
exports.updateCustomApplicationDeploymentPreview = updateCustomApplicationDeploymentPreview;
|
|
269
|
+
exports.updateCustomView = updateCustomView;
|