@commercetools-frontend/mc-scripts 0.0.0-CRAFT-1791-20251006162610

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 (121) 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.dev.js +7 -0
  5. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.js +7 -0
  6. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.cjs.prod.js +7 -0
  7. package/application-runtime/dist/commercetools-frontend-mc-scripts-application-runtime.esm.js +5 -0
  8. package/application-runtime/package.json +4 -0
  9. package/bin/cli.js +8 -0
  10. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.d.ts +2 -0
  11. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.dev.js +199 -0
  12. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.js +7 -0
  13. package/cli/dist/commercetools-frontend-mc-scripts-cli.cjs.prod.js +199 -0
  14. package/cli/dist/commercetools-frontend-mc-scripts-cli.esm.js +184 -0
  15. package/cli/package.json +4 -0
  16. package/config/create-webpack-config-for-development.js +8 -0
  17. package/config/create-webpack-config-for-production.js +8 -0
  18. package/config/vendors-to-transpile.js +6 -0
  19. package/dist/build-2a0a18bd.esm.js +155 -0
  20. package/dist/build-521f3f9f.cjs.prod.js +169 -0
  21. package/dist/build-988fc0f7.cjs.dev.js +169 -0
  22. package/dist/build-vite-16b1a575.cjs.dev.js +238 -0
  23. package/dist/build-vite-59e1f185.esm.js +208 -0
  24. package/dist/build-vite-5d317720.cjs.prod.js +238 -0
  25. package/dist/commercetools-frontend-mc-scripts.cjs.d.ts +2 -0
  26. package/dist/commercetools-frontend-mc-scripts.cjs.dev.js +29 -0
  27. package/dist/commercetools-frontend-mc-scripts.cjs.js +7 -0
  28. package/dist/commercetools-frontend-mc-scripts.cjs.prod.js +29 -0
  29. package/dist/commercetools-frontend-mc-scripts.esm.js +21 -0
  30. package/dist/compile-html-025cd493.esm.js +34 -0
  31. package/dist/compile-html-50fd05ec.cjs.prod.js +42 -0
  32. package/dist/compile-html-f4ac88cc.cjs.dev.js +42 -0
  33. package/dist/config-sync-70a16916.cjs.dev.js +852 -0
  34. package/dist/config-sync-72c20d80.cjs.prod.js +846 -0
  35. package/dist/config-sync-bc895390.esm.js +830 -0
  36. package/dist/create-postcss-config-cb7be312.cjs.dev.js +81 -0
  37. package/dist/create-postcss-config-dde0ccf1.esm.js +75 -0
  38. package/dist/create-postcss-config-edca0c33.cjs.prod.js +81 -0
  39. package/dist/create-webpack-config-for-development-1aed1cc0.cjs.prod.js +465 -0
  40. package/dist/create-webpack-config-for-development-a95f3634.esm.js +440 -0
  41. package/dist/create-webpack-config-for-development-d003697b.cjs.dev.js +465 -0
  42. package/dist/create-webpack-config-for-production-15fbe7db.cjs.dev.js +523 -0
  43. package/dist/create-webpack-config-for-production-764c482f.cjs.prod.js +523 -0
  44. package/dist/create-webpack-config-for-production-9f42c336.esm.js +493 -0
  45. package/dist/credentials-storage-66c1e51f.cjs.prod.js +95 -0
  46. package/dist/credentials-storage-d001f726.esm.js +83 -0
  47. package/dist/credentials-storage-e7884d17.cjs.dev.js +95 -0
  48. package/dist/declarations/src/application-runtime.d.ts +1 -0
  49. package/dist/declarations/src/cli.d.ts +4 -0
  50. package/dist/declarations/src/config/create-postcss-config.d.ts +4 -0
  51. package/dist/declarations/src/config/create-webpack-config-for-development.d.ts +10 -0
  52. package/dist/declarations/src/config/create-webpack-config-for-production.d.ts +10 -0
  53. package/dist/declarations/src/config/vendors-to-transpile.d.ts +2 -0
  54. package/dist/declarations/src/deprecated-entry-points.d.ts +7 -0
  55. package/dist/declarations/src/index.d.ts +3 -0
  56. package/dist/declarations/src/postcss.d.ts +1 -0
  57. package/dist/declarations/src/types.d.ts +94 -0
  58. package/dist/declarations/src/version.d.ts +2 -0
  59. package/dist/declarations/src/webpack-loaders/i18n-message-compilation-loader.d.ts +3 -0
  60. package/dist/declarations/src/webpack.d.ts +2 -0
  61. package/dist/deployment-previews-set-17e8ed48.cjs.prod.js +202 -0
  62. package/dist/deployment-previews-set-3648972f.esm.js +191 -0
  63. package/dist/deployment-previews-set-37aef990.cjs.dev.js +202 -0
  64. package/dist/does-file-exist-32618334.esm.js +12 -0
  65. package/dist/does-file-exist-be53305d.cjs.prod.js +18 -0
  66. package/dist/does-file-exist-eb86baca.cjs.dev.js +18 -0
  67. package/dist/graphql-requests-6a47ad5b.esm.js +247 -0
  68. package/dist/graphql-requests-779b867b.cjs.dev.js +270 -0
  69. package/dist/graphql-requests-8086eba7.cjs.prod.js +270 -0
  70. package/dist/has-jsx-runtime-aa5d21ee.cjs.dev.js +15 -0
  71. package/dist/has-jsx-runtime-c3202df5.cjs.prod.js +15 -0
  72. package/dist/has-jsx-runtime-e3ecb09b.esm.js +13 -0
  73. package/dist/i18n-message-complilation-21d3b0aa.esm.js +15 -0
  74. package/dist/i18n-message-complilation-7311cb29.cjs.dev.js +23 -0
  75. package/dist/i18n-message-complilation-7762da61.cjs.prod.js +23 -0
  76. package/dist/login-0a728449.esm.js +229 -0
  77. package/dist/login-817a5a26.cjs.dev.js +270 -0
  78. package/dist/login-85c25393.cjs.prod.js +270 -0
  79. package/dist/optimizations-7789145e.cjs.dev.js +85 -0
  80. package/dist/optimizations-bf991634.esm.js +67 -0
  81. package/dist/optimizations-fb93514f.cjs.prod.js +85 -0
  82. package/dist/package-7e170dc4.cjs.dev.js +160 -0
  83. package/dist/package-940b0a2a.cjs.prod.js +160 -0
  84. package/dist/package-99e547a7.esm.js +158 -0
  85. package/dist/paths-39f22b8b.esm.js +36 -0
  86. package/dist/paths-7768b440.cjs.prod.js +44 -0
  87. package/dist/paths-b76fc753.cjs.dev.js +44 -0
  88. package/dist/serve-1036c2de.esm.js +55 -0
  89. package/dist/serve-50d33f0b.cjs.dev.js +64 -0
  90. package/dist/serve-8a506da6.cjs.prod.js +64 -0
  91. package/dist/start-1d677ad8.cjs.dev.js +177 -0
  92. package/dist/start-2a7ae03d.esm.js +164 -0
  93. package/dist/start-f56cb5f7.cjs.prod.js +177 -0
  94. package/dist/start-vite-068e9f73.cjs.dev.js +128 -0
  95. package/dist/start-vite-29078b3a.cjs.prod.js +128 -0
  96. package/dist/start-vite-7d1161e8.esm.js +116 -0
  97. package/dist/vendors-to-transpile-04a49d40.cjs.prod.js +5 -0
  98. package/dist/vendors-to-transpile-6ab4ea06.cjs.dev.js +5 -0
  99. package/dist/vendors-to-transpile-7dc84a72.esm.js +3 -0
  100. package/dist/vite-plugin-svgr-4034a834.cjs.prod.js +151 -0
  101. package/dist/vite-plugin-svgr-7d06f400.cjs.dev.js +151 -0
  102. package/dist/vite-plugin-svgr-de6ee7da.esm.js +125 -0
  103. package/package.json +156 -0
  104. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.d.ts +2 -0
  105. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.dev.js +12 -0
  106. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.js +7 -0
  107. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.cjs.prod.js +12 -0
  108. package/postcss/dist/commercetools-frontend-mc-scripts-postcss.esm.js +4 -0
  109. package/postcss/package.json +4 -0
  110. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.d.ts +2 -0
  111. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.dev.js +57 -0
  112. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.js +7 -0
  113. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.cjs.prod.js +57 -0
  114. package/webpack/dist/commercetools-frontend-mc-scripts-webpack.esm.js +48 -0
  115. package/webpack/package.json +4 -0
  116. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.d.ts +3 -0
  117. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.dev.js +30 -0
  118. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.js +7 -0
  119. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.cjs.prod.js +30 -0
  120. package/webpack-loaders/i18n-message-compilation-loader/dist/commercetools-frontend-mc-scripts-webpack-loaders-i18n-message-compilation-loader.esm.js +26 -0
  121. package/webpack-loaders/i18n-message-compilation-loader/package.json +4 -0
@@ -0,0 +1,270 @@
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-e7884d17.cjs.dev.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 shouldUseExperimentalIdentityAuthFlow = process.env.ENABLE_EXPERIMENTAL_IDENTITY_AUTH_FLOW === 'true';
47
+ const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
48
+ const tokenHeader = shouldUseExperimentalIdentityAuthFlow ? {
49
+ [constants.SUPPORTED_HEADERS.AUTHORIZATION]: `Bearer ${token}`
50
+ } : {
51
+ 'x-mc-cli-access-token': token
52
+ };
53
+ const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
54
+ headers: _objectSpread(_objectSpread({
55
+ Accept: 'application/json',
56
+ 'Content-Type': 'application/json',
57
+ 'x-user-agent': credentialsStorage$1.userAgent
58
+ }, token ? tokenHeader : {}), requestOptions.headers)
59
+ });
60
+ try {
61
+ const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
62
+
63
+ // In case a new session token is returned from the server, save it.
64
+ const refreshedSessionToken = result.headers.get('x-refreshed-session-token');
65
+ if (refreshedSessionToken) {
66
+ console.log(chalk__default["default"].green('Session token refreshed.'));
67
+ console.log();
68
+ const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
69
+ // Store the updated access token.
70
+ credentialsStorage.setToken(requestOptions.mcApiUrl, {
71
+ token: refreshedSessionToken,
72
+ expiresAt: Number(refreshedSessionTokenExpiresAt)
73
+ });
74
+ }
75
+ return result.data;
76
+ } catch (error) {
77
+ if (error instanceof graphqlRequest.ClientError) {
78
+ // If it's an unauthorized error, retry the request to force the token to be refreshed.
79
+ if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
80
+ var _context;
81
+ const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => graphqlError.extensions?.code === 'UNAUTHENTICATED');
82
+ if (isUnauthorizedError) {
83
+ console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
84
+ return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
85
+ headers: _objectSpread(_objectSpread({}, requestOptions.headers), {}, {
86
+ 'X-Force-Token': 'true'
87
+ })
88
+ }), retryCount + 1);
89
+ }
90
+ }
91
+ }
92
+ throw error;
93
+ }
94
+ }
95
+ const fetchCustomApplication = async _ref => {
96
+ let mcApiUrl = _ref.mcApiUrl,
97
+ entryPointUriPath = _ref.entryPointUriPath,
98
+ applicationIdentifier = _ref.applicationIdentifier;
99
+ const customAppData = await requestWithTokenRetry(FetchCustomApplicationFromCli, {
100
+ variables: {
101
+ entryPointUriPath
102
+ },
103
+ mcApiUrl,
104
+ headers: {
105
+ 'x-application-id': applicationIdentifier,
106
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
107
+ }
108
+ });
109
+ return customAppData.organizationExtensionForCustomApplication;
110
+ };
111
+ const fetchCustomView = async _ref2 => {
112
+ let mcApiUrl = _ref2.mcApiUrl,
113
+ customViewId = _ref2.customViewId,
114
+ applicationIdentifier = _ref2.applicationIdentifier;
115
+ const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
116
+ variables: {
117
+ customViewId
118
+ },
119
+ mcApiUrl,
120
+ headers: {
121
+ 'x-custom-view-id': customViewId,
122
+ 'x-application-id': applicationIdentifier,
123
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
124
+ }
125
+ });
126
+ return customViewData.organizationExtensionForCustomView;
127
+ };
128
+ const updateCustomApplication = async _ref3 => {
129
+ let mcApiUrl = _ref3.mcApiUrl,
130
+ applicationId = _ref3.applicationId,
131
+ organizationId = _ref3.organizationId,
132
+ data = _ref3.data,
133
+ applicationIdentifier = _ref3.applicationIdentifier;
134
+ const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
135
+ variables: {
136
+ organizationId,
137
+ applicationId,
138
+ data
139
+ },
140
+ mcApiUrl,
141
+ headers: {
142
+ 'x-application-id': applicationIdentifier,
143
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
144
+ }
145
+ });
146
+ return updatedCustomAppsData.updateCustomApplication;
147
+ };
148
+ const updateCustomView = async _ref4 => {
149
+ let mcApiUrl = _ref4.mcApiUrl,
150
+ organizationId = _ref4.organizationId,
151
+ data = _ref4.data,
152
+ customViewId = _ref4.customViewId,
153
+ applicationIdentifier = _ref4.applicationIdentifier;
154
+ const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
155
+ variables: {
156
+ organizationId,
157
+ customViewId,
158
+ data
159
+ },
160
+ mcApiUrl,
161
+ headers: {
162
+ 'x-custom-view-id': customViewId,
163
+ 'x-application-id': applicationIdentifier,
164
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
165
+ }
166
+ });
167
+ return updatedCustomViewData.updateCustomView;
168
+ };
169
+ const createCustomApplication = async _ref5 => {
170
+ let mcApiUrl = _ref5.mcApiUrl,
171
+ organizationId = _ref5.organizationId,
172
+ data = _ref5.data,
173
+ applicationIdentifier = _ref5.applicationIdentifier;
174
+ const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
175
+ variables: {
176
+ organizationId,
177
+ data
178
+ },
179
+ mcApiUrl,
180
+ headers: {
181
+ 'x-application-id': applicationIdentifier,
182
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
183
+ }
184
+ });
185
+ return createdCustomAppData.createCustomApplication;
186
+ };
187
+ const createCustomView = async _ref6 => {
188
+ let mcApiUrl = _ref6.mcApiUrl,
189
+ organizationId = _ref6.organizationId,
190
+ data = _ref6.data,
191
+ applicationIdentifier = _ref6.applicationIdentifier;
192
+ const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
193
+ variables: {
194
+ organizationId,
195
+ data
196
+ },
197
+ mcApiUrl,
198
+ headers: {
199
+ 'x-application-id': applicationIdentifier,
200
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
201
+ }
202
+ });
203
+ return createdCustomViewData.createCustomView;
204
+ };
205
+ const fetchUserOrganizations = async _ref7 => {
206
+ let mcApiUrl = _ref7.mcApiUrl,
207
+ applicationIdentifier = _ref7.applicationIdentifier,
208
+ customViewId = _ref7.customViewId;
209
+ const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
210
+ mcApiUrl,
211
+ headers: _objectSpread(_objectSpread({
212
+ 'x-application-id': applicationIdentifier
213
+ }, customViewId && {
214
+ 'x-custom-view-id': customViewId
215
+ }), {}, {
216
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
217
+ })
218
+ });
219
+ return userOrganizations.myOrganizations;
220
+ };
221
+ const createCustomApplicationDeploymentPreview = async _ref8 => {
222
+ let mcApiUrl = _ref8.mcApiUrl,
223
+ organizationId = _ref8.organizationId,
224
+ applicationId = _ref8.applicationId,
225
+ applicationIdentifier = _ref8.applicationIdentifier,
226
+ data = _ref8.data;
227
+ const createdDeploymentPreviewResult = await requestWithTokenRetry(CreateCustomApplicationDeploymentPreviewFromCli, {
228
+ variables: {
229
+ organizationId,
230
+ applicationId,
231
+ data
232
+ },
233
+ mcApiUrl,
234
+ headers: {
235
+ 'x-application-id': applicationIdentifier,
236
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
237
+ }
238
+ });
239
+ return createdDeploymentPreviewResult.createCustomApplicationDeploymentPreview;
240
+ };
241
+ const updateCustomApplicationDeploymentPreview = async _ref9 => {
242
+ let mcApiUrl = _ref9.mcApiUrl,
243
+ organizationId = _ref9.organizationId,
244
+ deploymentId = _ref9.deploymentId,
245
+ data = _ref9.data,
246
+ applicationIdentifier = _ref9.applicationIdentifier;
247
+ const updatedDeploymentPreviewResult = await requestWithTokenRetry(UpdateCustomApplicationDeploymentPreviewFromCli, {
248
+ variables: {
249
+ organizationId,
250
+ deploymentId,
251
+ data
252
+ },
253
+ mcApiUrl,
254
+ headers: {
255
+ 'x-application-id': applicationIdentifier,
256
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
257
+ }
258
+ });
259
+ return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
260
+ };
261
+
262
+ exports.createCustomApplication = createCustomApplication;
263
+ exports.createCustomApplicationDeploymentPreview = createCustomApplicationDeploymentPreview;
264
+ exports.createCustomView = createCustomView;
265
+ exports.fetchCustomApplication = fetchCustomApplication;
266
+ exports.fetchCustomView = fetchCustomView;
267
+ exports.fetchUserOrganizations = fetchUserOrganizations;
268
+ exports.updateCustomApplication = updateCustomApplication;
269
+ exports.updateCustomApplicationDeploymentPreview = updateCustomApplicationDeploymentPreview;
270
+ exports.updateCustomView = updateCustomView;
@@ -0,0 +1,270 @@
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-66c1e51f.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 shouldUseExperimentalIdentityAuthFlow = process.env.ENABLE_EXPERIMENTAL_IDENTITY_AUTH_FLOW === 'true';
47
+ const token = credentialsStorage.getToken(requestOptions.mcApiUrl);
48
+ const tokenHeader = shouldUseExperimentalIdentityAuthFlow ? {
49
+ [constants.SUPPORTED_HEADERS.AUTHORIZATION]: `Bearer ${token}`
50
+ } : {
51
+ 'x-mc-cli-access-token': token
52
+ };
53
+ const client = new graphqlRequest.GraphQLClient(`${requestOptions.mcApiUrl}/graphql`, {
54
+ headers: _objectSpread(_objectSpread({
55
+ Accept: 'application/json',
56
+ 'Content-Type': 'application/json',
57
+ 'x-user-agent': credentialsStorage$1.userAgent
58
+ }, token ? tokenHeader : {}), requestOptions.headers)
59
+ });
60
+ try {
61
+ const result = await client.rawRequest(graphql.print(document), requestOptions.variables);
62
+
63
+ // In case a new session token is returned from the server, save it.
64
+ const refreshedSessionToken = result.headers.get('x-refreshed-session-token');
65
+ if (refreshedSessionToken) {
66
+ console.log(chalk__default["default"].green('Session token refreshed.'));
67
+ console.log();
68
+ const refreshedSessionTokenExpiresAt = result.headers.get('x-refreshed-session-token-expires-at');
69
+ // Store the updated access token.
70
+ credentialsStorage.setToken(requestOptions.mcApiUrl, {
71
+ token: refreshedSessionToken,
72
+ expiresAt: Number(refreshedSessionTokenExpiresAt)
73
+ });
74
+ }
75
+ return result.data;
76
+ } catch (error) {
77
+ if (error instanceof graphqlRequest.ClientError) {
78
+ // If it's an unauthorized error, retry the request to force the token to be refreshed.
79
+ if (retryCount === 0 && error.response.errors && error.response.errors.length > 0) {
80
+ var _context;
81
+ const isUnauthorizedError = _someInstanceProperty__default["default"](_context = error.response.errors).call(_context, graphqlError => graphqlError.extensions?.code === 'UNAUTHENTICATED');
82
+ if (isUnauthorizedError) {
83
+ console.log(chalk__default["default"].yellow('Expired or invalid session token, attempting to retry the request with a refreshed token...'));
84
+ return requestWithTokenRetry(document, _objectSpread(_objectSpread({}, requestOptions), {}, {
85
+ headers: _objectSpread(_objectSpread({}, requestOptions.headers), {}, {
86
+ 'X-Force-Token': 'true'
87
+ })
88
+ }), retryCount + 1);
89
+ }
90
+ }
91
+ }
92
+ throw error;
93
+ }
94
+ }
95
+ const fetchCustomApplication = async _ref => {
96
+ let mcApiUrl = _ref.mcApiUrl,
97
+ entryPointUriPath = _ref.entryPointUriPath,
98
+ applicationIdentifier = _ref.applicationIdentifier;
99
+ const customAppData = await requestWithTokenRetry(FetchCustomApplicationFromCli, {
100
+ variables: {
101
+ entryPointUriPath
102
+ },
103
+ mcApiUrl,
104
+ headers: {
105
+ 'x-application-id': applicationIdentifier,
106
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
107
+ }
108
+ });
109
+ return customAppData.organizationExtensionForCustomApplication;
110
+ };
111
+ const fetchCustomView = async _ref2 => {
112
+ let mcApiUrl = _ref2.mcApiUrl,
113
+ customViewId = _ref2.customViewId,
114
+ applicationIdentifier = _ref2.applicationIdentifier;
115
+ const customViewData = await requestWithTokenRetry(FetchCustomViewFromCli, {
116
+ variables: {
117
+ customViewId
118
+ },
119
+ mcApiUrl,
120
+ headers: {
121
+ 'x-custom-view-id': customViewId,
122
+ 'x-application-id': applicationIdentifier,
123
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
124
+ }
125
+ });
126
+ return customViewData.organizationExtensionForCustomView;
127
+ };
128
+ const updateCustomApplication = async _ref3 => {
129
+ let mcApiUrl = _ref3.mcApiUrl,
130
+ applicationId = _ref3.applicationId,
131
+ organizationId = _ref3.organizationId,
132
+ data = _ref3.data,
133
+ applicationIdentifier = _ref3.applicationIdentifier;
134
+ const updatedCustomAppsData = await requestWithTokenRetry(UpdateCustomApplicationFromCli, {
135
+ variables: {
136
+ organizationId,
137
+ applicationId,
138
+ data
139
+ },
140
+ mcApiUrl,
141
+ headers: {
142
+ 'x-application-id': applicationIdentifier,
143
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
144
+ }
145
+ });
146
+ return updatedCustomAppsData.updateCustomApplication;
147
+ };
148
+ const updateCustomView = async _ref4 => {
149
+ let mcApiUrl = _ref4.mcApiUrl,
150
+ organizationId = _ref4.organizationId,
151
+ data = _ref4.data,
152
+ customViewId = _ref4.customViewId,
153
+ applicationIdentifier = _ref4.applicationIdentifier;
154
+ const updatedCustomViewData = await requestWithTokenRetry(UpdateCustomViewFromCli, {
155
+ variables: {
156
+ organizationId,
157
+ customViewId,
158
+ data
159
+ },
160
+ mcApiUrl,
161
+ headers: {
162
+ 'x-custom-view-id': customViewId,
163
+ 'x-application-id': applicationIdentifier,
164
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
165
+ }
166
+ });
167
+ return updatedCustomViewData.updateCustomView;
168
+ };
169
+ const createCustomApplication = async _ref5 => {
170
+ let mcApiUrl = _ref5.mcApiUrl,
171
+ organizationId = _ref5.organizationId,
172
+ data = _ref5.data,
173
+ applicationIdentifier = _ref5.applicationIdentifier;
174
+ const createdCustomAppData = await requestWithTokenRetry(CreateCustomApplicationFromCli, {
175
+ variables: {
176
+ organizationId,
177
+ data
178
+ },
179
+ mcApiUrl,
180
+ headers: {
181
+ 'x-application-id': applicationIdentifier,
182
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
183
+ }
184
+ });
185
+ return createdCustomAppData.createCustomApplication;
186
+ };
187
+ const createCustomView = async _ref6 => {
188
+ let mcApiUrl = _ref6.mcApiUrl,
189
+ organizationId = _ref6.organizationId,
190
+ data = _ref6.data,
191
+ applicationIdentifier = _ref6.applicationIdentifier;
192
+ const createdCustomViewData = await requestWithTokenRetry(CreateCustomViewFromCli, {
193
+ variables: {
194
+ organizationId,
195
+ data
196
+ },
197
+ mcApiUrl,
198
+ headers: {
199
+ 'x-application-id': applicationIdentifier,
200
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
201
+ }
202
+ });
203
+ return createdCustomViewData.createCustomView;
204
+ };
205
+ const fetchUserOrganizations = async _ref7 => {
206
+ let mcApiUrl = _ref7.mcApiUrl,
207
+ applicationIdentifier = _ref7.applicationIdentifier,
208
+ customViewId = _ref7.customViewId;
209
+ const userOrganizations = await requestWithTokenRetry(FetchMyOrganizationsFromCli, {
210
+ mcApiUrl,
211
+ headers: _objectSpread(_objectSpread({
212
+ 'x-application-id': applicationIdentifier
213
+ }, customViewId && {
214
+ 'x-custom-view-id': customViewId
215
+ }), {}, {
216
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.ADMINISTRATION_SERVICE
217
+ })
218
+ });
219
+ return userOrganizations.myOrganizations;
220
+ };
221
+ const createCustomApplicationDeploymentPreview = async _ref8 => {
222
+ let mcApiUrl = _ref8.mcApiUrl,
223
+ organizationId = _ref8.organizationId,
224
+ applicationId = _ref8.applicationId,
225
+ applicationIdentifier = _ref8.applicationIdentifier,
226
+ data = _ref8.data;
227
+ const createdDeploymentPreviewResult = await requestWithTokenRetry(CreateCustomApplicationDeploymentPreviewFromCli, {
228
+ variables: {
229
+ organizationId,
230
+ applicationId,
231
+ data
232
+ },
233
+ mcApiUrl,
234
+ headers: {
235
+ 'x-application-id': applicationIdentifier,
236
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
237
+ }
238
+ });
239
+ return createdDeploymentPreviewResult.createCustomApplicationDeploymentPreview;
240
+ };
241
+ const updateCustomApplicationDeploymentPreview = async _ref9 => {
242
+ let mcApiUrl = _ref9.mcApiUrl,
243
+ organizationId = _ref9.organizationId,
244
+ deploymentId = _ref9.deploymentId,
245
+ data = _ref9.data,
246
+ applicationIdentifier = _ref9.applicationIdentifier;
247
+ const updatedDeploymentPreviewResult = await requestWithTokenRetry(UpdateCustomApplicationDeploymentPreviewFromCli, {
248
+ variables: {
249
+ organizationId,
250
+ deploymentId,
251
+ data
252
+ },
253
+ mcApiUrl,
254
+ headers: {
255
+ 'x-application-id': applicationIdentifier,
256
+ 'x-graphql-target': constants.GRAPHQL_TARGETS.SETTINGS_SERVICE
257
+ }
258
+ });
259
+ return updatedDeploymentPreviewResult.updateCustomApplicationDeploymentPreview;
260
+ };
261
+
262
+ exports.createCustomApplication = createCustomApplication;
263
+ exports.createCustomApplicationDeploymentPreview = createCustomApplicationDeploymentPreview;
264
+ exports.createCustomView = createCustomView;
265
+ exports.fetchCustomApplication = fetchCustomApplication;
266
+ exports.fetchCustomView = fetchCustomView;
267
+ exports.fetchUserOrganizations = fetchUserOrganizations;
268
+ exports.updateCustomApplication = updateCustomApplication;
269
+ exports.updateCustomApplicationDeploymentPreview = updateCustomApplicationDeploymentPreview;
270
+ exports.updateCustomView = updateCustomView;