@commercetools-frontend/constants 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.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/commercetools-frontend-constants.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-constants.cjs.dev.js +265 -0
- package/dist/commercetools-frontend-constants.cjs.js +7 -0
- package/dist/commercetools-frontend-constants.cjs.prod.js +265 -0
- package/dist/commercetools-frontend-constants.esm.js +230 -0
- package/dist/declarations/src/constants.d.ts +288 -0
- package/dist/declarations/src/feature-toggles.d.ts +7 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/types/generated/settings.d.ts +1653 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @commercetools-frontend/constants
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@commercetools-frontend/constants"><img src="https://badgen.net/npm/v/@commercetools-frontend/constants" alt="Latest release (latest dist-tag)" /></a> <a href="https://www.npmjs.com/package/@commercetools-frontend/constants"><img src="https://badgen.net/npm/v/@commercetools-frontend/constants/next" alt="Latest release (next dist-tag)" /></a> <a href="https://bundlephobia.com/result?p=@commercetools-frontend/constants"><img src="https://badgen.net/bundlephobia/minzip/@commercetools-frontend/constants" alt="Minified + GZipped size" /></a> <a href="https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE"><img src="https://badgen.net/github/license/commercetools/merchant-center-application-kit" alt="GitHub license" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
Check out the [documentation](https://docs.commercetools.com/merchant-center-customizations/api-reference/commercetools-frontend-constants) for more information.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1jb25zdGFudHMuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
6
|
+
var version = "24.7.2";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The project key must be between 2 and 36 characters long. It can only contain alphanumeric lowercase characters (a-z, 0-9),
|
|
10
|
+
* up to two consecutive underscores (_) and hyphens (-). Leading and trailing underscore and hyphens are also not allowed.
|
|
11
|
+
*
|
|
12
|
+
* This regular expression has been generated using ChatGPT.
|
|
13
|
+
* Explanation of the regular expression:
|
|
14
|
+
* 1. ^: Asserts the start of the string.
|
|
15
|
+
* 2. (?!.*(?:[-_]{3}|^[-_]|[-_]$)): Negative lookahead assertion ensures that there are no three consecutive hyphens or underscores ([-_]{3}), no leading hyphen or underscore (^[-_]), and no trailing hyphen or underscore ([-_]$).
|
|
16
|
+
* 3. (?=.{2,36}$): Positive lookahead assertion ensures that the length of the string is between 2 and 36 characters.
|
|
17
|
+
* 4. (?:[a-z1-9][a-z0-9]*)?: Non-capturing group matches an optional first character that cannot be '0' ([a-z1-9]) followed by zero or more lowercase alphanumeric characters ([a-z0-9]*).
|
|
18
|
+
* 5. (?:[-_]{0,2}[a-z0-9]+)*: Non-capturing group matches zero, one, or two hyphens or underscores followed by one or more lowercase alphanumeric characters. This group can repeat zero or more times.
|
|
19
|
+
* 6. $: Asserts the end of the string.
|
|
20
|
+
*/
|
|
21
|
+
const PROJECT_KEY_REGEX = /^(?!.*(?:[-_]{3}|^[-_]|[-_]$))(?=.{2,36}$)(?:[a-z1-9][a-z0-9]*)?(?:[-_]{0,2}[a-z0-9]+)*$/;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The entryPointUriPath may be between 2 and 64 characters and only contain alphabetic lowercase characters,
|
|
25
|
+
* non-consecutive underscores and hyphens. Leading and trailing underscore and hyphens are also not allowed.
|
|
26
|
+
*
|
|
27
|
+
* This regular expression has been generated using ChatGPT.
|
|
28
|
+
* Explanation of the regular expression:
|
|
29
|
+
* 1. ^: Asserts the start of the string.
|
|
30
|
+
* 2. (?!.*(?:[-_]{2}|^[-_]|[-_]$)): Negative lookahead assertion ensures that there are no two consecutive hyphens or underscores ([-_]{2}), no leading hyphen or underscore (^[-_]), and no trailing hyphen or underscore ([-_]$).
|
|
31
|
+
* 3. (?=.{2,64}$): Positive lookahead assertion ensures that the length of the string is between 2 and 64 characters.
|
|
32
|
+
* 4. (?:[a-z1-9][a-z0-9]*)?: Non-capturing group matches an optional first character that cannot be '0' ([a-z1-9]) followed by zero or more lowercase alphanumeric characters ([a-z0-9]*).
|
|
33
|
+
* 5. (?:[-_]{0,1}[a-z0-9]+)*: Non-capturing group matches zero, or one hyphen or underscore followed by one or more lowercase alphanumeric characters. This group can repeat zero or more times.
|
|
34
|
+
* 6. $: Asserts the end of the string.
|
|
35
|
+
*/
|
|
36
|
+
const ENTRY_POINT_URI_PATH_REGEX = /^(?!.*(?:[-_]{2}|^[-_]|[-_]$))(?=.{2,64}$)(?:[a-z1-9][a-z0-9]*)?(?:[-_]{0,1}[a-z0-9]+)*$/;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The permission group name may be between 2 and 64 characters and only contain alphanumeric lowercase characters and non-consecutive hyphens.
|
|
40
|
+
* Leading and trailing hyphens are also not allowed.
|
|
41
|
+
*/
|
|
42
|
+
const PERMISSION_GROUP_NAME_REGEX = /^[^-#\W]([a-z]|[-](?![-])){0,62}[^-#\W]$/;
|
|
43
|
+
|
|
44
|
+
// DOM elements
|
|
45
|
+
const PORTALS_CONTAINER_ID = 'portals-container';
|
|
46
|
+
const PORTALS_CONTAINER_INDENTATION_SIZE = '48px';
|
|
47
|
+
|
|
48
|
+
// Links
|
|
49
|
+
const SUPPORT_PORTAL_URL = 'https://support.commercetools.com';
|
|
50
|
+
|
|
51
|
+
// Notification actions
|
|
52
|
+
const SHOW_LOADING = 'SHOW_LOADING';
|
|
53
|
+
const HIDE_LOADING = 'HIDE_LOADING';
|
|
54
|
+
const HIDE_ALL_PAGE_NOTIFICATIONS = 'HIDE_ALL_PAGE_NOTIFICATIONS';
|
|
55
|
+
|
|
56
|
+
// Notifications
|
|
57
|
+
const NOTIFICATION_DOMAINS = {
|
|
58
|
+
GLOBAL: 'global',
|
|
59
|
+
PAGE: 'page',
|
|
60
|
+
SIDE: 'side'
|
|
61
|
+
};
|
|
62
|
+
const NOTIFICATION_KINDS_SIDE = {
|
|
63
|
+
error: 'error',
|
|
64
|
+
warning: 'warning',
|
|
65
|
+
info: 'info',
|
|
66
|
+
success: 'success'
|
|
67
|
+
};
|
|
68
|
+
const NOTIFICATION_KINDS_GLOBAL = {
|
|
69
|
+
error: 'error',
|
|
70
|
+
warning: 'warning',
|
|
71
|
+
info: 'info',
|
|
72
|
+
success: 'success',
|
|
73
|
+
'unexpected-error': 'unexpected-error'
|
|
74
|
+
};
|
|
75
|
+
const NOTIFICATION_KINDS_PAGE = {
|
|
76
|
+
error: 'error',
|
|
77
|
+
warning: 'warning',
|
|
78
|
+
info: 'info',
|
|
79
|
+
success: 'success',
|
|
80
|
+
'unexpected-error': 'unexpected-error',
|
|
81
|
+
'api-error': 'api-error'
|
|
82
|
+
};
|
|
83
|
+
// Alias to `NOTIFICATION_DOMAINS` for backwards compatibility
|
|
84
|
+
const DOMAINS = NOTIFICATION_DOMAINS;
|
|
85
|
+
// Fallback string when there is no localized value
|
|
86
|
+
const NO_VALUE_FALLBACK = '- -';
|
|
87
|
+
|
|
88
|
+
// HTTP requests and responses
|
|
89
|
+
const STATUS_CODES = {
|
|
90
|
+
UNAUTHORIZED: 401,
|
|
91
|
+
FORBIDDEN: 403,
|
|
92
|
+
UNAUTHENTICATED: 299,
|
|
93
|
+
NOT_FOUND: 404
|
|
94
|
+
};
|
|
95
|
+
const LOGOUT_REASONS = {
|
|
96
|
+
USER: 'user',
|
|
97
|
+
UNAUTHORIZED: 'unauthorized',
|
|
98
|
+
INVALID: 'invalid',
|
|
99
|
+
DELETED: 'deleted',
|
|
100
|
+
NO_PROJECTS: 'no-projects'
|
|
101
|
+
};
|
|
102
|
+
const GRAPHQL_TARGETS = {
|
|
103
|
+
MERCHANT_CENTER_BACKEND: 'mc',
|
|
104
|
+
COMMERCETOOLS_PLATFORM: 'ctp',
|
|
105
|
+
DASHBOARD_SERVICE: 'dashboard',
|
|
106
|
+
CHANGE_HISTORY_SERVICE: 'change-history',
|
|
107
|
+
PIM_INDEXER: 'pim-indexer',
|
|
108
|
+
ORDER_INDEXER: 'order-indexer',
|
|
109
|
+
SETTINGS_SERVICE: 'settings',
|
|
110
|
+
ADMINISTRATION_SERVICE: 'administration',
|
|
111
|
+
STANDALONE_PRICES_INDEXER: 'standalone-prices-indexer',
|
|
112
|
+
PLATFORM_INSIGHTS: 'platform-insights'
|
|
113
|
+
};
|
|
114
|
+
const MC_API_PROXY_TARGETS = {
|
|
115
|
+
COMMERCETOOLS_PLATFORM: 'ctp',
|
|
116
|
+
MACHINE_LEARNING: 'ml',
|
|
117
|
+
PIM_SEARCH: 'pim-search',
|
|
118
|
+
ORDER_SEARCH: 'order-search',
|
|
119
|
+
IMPORT: 'import',
|
|
120
|
+
EXPORT: 'export',
|
|
121
|
+
STANDALONE_PRICES_SEARCH: 'standalone-prices-search'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Global application environment on window object
|
|
125
|
+
|
|
126
|
+
// Used for Custom Views, as we want to keep the `entryPointUriPath` value required in the runtime config.
|
|
127
|
+
const CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH = '@@custom-view-host@@';
|
|
128
|
+
const SUPPORTED_HEADERS = {
|
|
129
|
+
ACCEPT: 'Accept',
|
|
130
|
+
ACCEPT_VERSION: 'Accept-version',
|
|
131
|
+
AUTHORIZATION: 'Authorization',
|
|
132
|
+
CONTENT_TYPE: 'Content-Type',
|
|
133
|
+
X_APPLICATION_ID: 'X-Application-Id',
|
|
134
|
+
X_CUSTOM_VIEW_ID: 'X-Custom-View-Id',
|
|
135
|
+
X_CORRELATION_ID: 'X-Correlation-Id',
|
|
136
|
+
X_FEATURE_FLAG: 'X-Feature-Flag',
|
|
137
|
+
X_FORWARD_TO: 'X-Forward-To',
|
|
138
|
+
X_FORWARD_TO_AUDIENCE_POLICY: 'X-Forward-To-Audience-Policy',
|
|
139
|
+
X_FORWARD_TO_CLAIMS: 'X-Forward-To-Claims',
|
|
140
|
+
X_GRAPHQL_TARGET: 'X-Graphql-Target',
|
|
141
|
+
X_GRAPHQL_OPERATION_NAME: 'X-Graphql-Operation-Name',
|
|
142
|
+
X_PROJECT_KEY: 'X-Project-Key',
|
|
143
|
+
X_TEAM_ID: 'X-Team-Id',
|
|
144
|
+
X_TOKEN_RETRY: 'X-Force-Token',
|
|
145
|
+
X_USER_AGENT: 'X-User-Agent'
|
|
146
|
+
};
|
|
147
|
+
const STORAGE_KEYS = {
|
|
148
|
+
NONCE: 'nonce',
|
|
149
|
+
IS_AUTHENTICATED: 'isAuthenticated',
|
|
150
|
+
SESSION_TOKEN: 'sessionToken',
|
|
151
|
+
SESSION_SCOPE: 'sessionScope',
|
|
152
|
+
ACTIVE_PROJECT_KEY: 'activeProjectKey',
|
|
153
|
+
ACTIVE_TEAM_ID: 'activeTeamId',
|
|
154
|
+
SELECTED_DATA_LOCALE: 'selectedDataLocale',
|
|
155
|
+
IS_FORCED_MENU_OPEN: 'isForcedMenuOpen',
|
|
156
|
+
LOGIN_STRATEGY: 'loginStrategy'
|
|
157
|
+
};
|
|
158
|
+
const HTTP_SECURITY_HEADER_KEYS = {
|
|
159
|
+
'Content-Security-Policy': 'Content-Security-Policy',
|
|
160
|
+
'Permissions-Policy': 'Permissions-Policy',
|
|
161
|
+
'Referrer-Policy': 'Referrer-Policy',
|
|
162
|
+
'Strict-Transport-Security': 'Strict-Transport-Security',
|
|
163
|
+
'X-Content-Type-Options': 'X-Content-Type-Options',
|
|
164
|
+
'X-Frame-Options': 'X-Frame-Options',
|
|
165
|
+
// @deprecated: this header is not supported by the browser anymore. Use `Content-Security-Policy` instead.
|
|
166
|
+
'X-XSS-Protection': 'X-XSS-Protection'
|
|
167
|
+
};
|
|
168
|
+
const HTTP_SECURITY_HEADERS = {
|
|
169
|
+
[HTTP_SECURITY_HEADER_KEYS['Referrer-Policy']]: 'same-origin',
|
|
170
|
+
[HTTP_SECURITY_HEADER_KEYS['Permissions-Policy']]:
|
|
171
|
+
// Note: we need to use `(self)` to ensure that Custom Views (rendered within an `<iframe>`)
|
|
172
|
+
// can inherit the main application permissions policy and override other directives if needed.
|
|
173
|
+
'microphone=(self), camera=(self), payment=(self), usb=(self), geolocation=(self)',
|
|
174
|
+
[HTTP_SECURITY_HEADER_KEYS['Strict-Transport-Security']]: 'max-age=31536000; includeSubDomains; preload',
|
|
175
|
+
[HTTP_SECURITY_HEADER_KEYS['X-Content-Type-Options']]: 'nosniff',
|
|
176
|
+
[HTTP_SECURITY_HEADER_KEYS['X-Frame-Options']]: 'SAMEORIGIN'
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Custom Views events (messages sent between the host application and the custom view)
|
|
180
|
+
const CUSTOM_VIEWS_EVENTS_NAMES = {
|
|
181
|
+
CUSTOM_VIEW_BOOTSTRAP: 'custom-view-bootstrap',
|
|
182
|
+
CUSTOM_VIEW_INITIALIZATION: 'custom-view-initialization',
|
|
183
|
+
CUSTOM_VIEW_CLOSE: 'custom-view-close',
|
|
184
|
+
CUSTOM_VIEW_READY: 'custom-view-ready',
|
|
185
|
+
CUSTOM_VIEW_ON_CLOSE_AFTER: 'custom-view-on-close-after'
|
|
186
|
+
};
|
|
187
|
+
const CUSTOM_VIEWS_EVENTS_META = {
|
|
188
|
+
HOST_APPLICATION_CODE: 'mc-host-application',
|
|
189
|
+
CUSTOM_VIEW_KEY_PREFIX: 'custom-view-'
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// SSO
|
|
193
|
+
const ORGANIZATION_GENERAL_ERROR = 'organizationGeneralError';
|
|
194
|
+
const LOGIN_STRATEGY_DEFAULT = 'default';
|
|
195
|
+
const LOGIN_STRATEGY_OIDC = 'oidc';
|
|
196
|
+
const LOGIN_STRATEGY_SSO = 'sso';
|
|
197
|
+
|
|
198
|
+
/*
|
|
199
|
+
* This file contains a list of all feature toggles used within
|
|
200
|
+
* the app shell. Each feature toggle should be a constant.
|
|
201
|
+
*
|
|
202
|
+
* ```
|
|
203
|
+
* export const FEATURE_TOGGLE_NAME = 'featureToggleName';
|
|
204
|
+
* export const FLAGS = {
|
|
205
|
+
* [FEATURE_TOGGLE_NAME]: false,
|
|
206
|
+
* };
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* NOTE:
|
|
210
|
+
* Default values are not yet passed to flopflip and it has to be decided
|
|
211
|
+
* how the integrate with the plugin API.
|
|
212
|
+
* The default values would be used whenever feature toggles have not been
|
|
213
|
+
* fetched from LaunchDarkly (without default values flopflip will default
|
|
214
|
+
* them to off until fetched).
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
const CUSTOM_VIEWS = 'enableCustomViews';
|
|
218
|
+
const FLAGS = {};
|
|
219
|
+
|
|
220
|
+
// Long-lived feature flags, defined in the MC API.
|
|
221
|
+
const DEFAULT_FLAGS = {
|
|
222
|
+
[CUSTOM_VIEWS]: {
|
|
223
|
+
value: true
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
var featureToggles = /*#__PURE__*/Object.freeze({
|
|
228
|
+
__proto__: null,
|
|
229
|
+
CUSTOM_VIEWS: CUSTOM_VIEWS,
|
|
230
|
+
FLAGS: FLAGS,
|
|
231
|
+
DEFAULT_FLAGS: DEFAULT_FLAGS
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
exports.CUSTOM_VIEWS_EVENTS_META = CUSTOM_VIEWS_EVENTS_META;
|
|
235
|
+
exports.CUSTOM_VIEWS_EVENTS_NAMES = CUSTOM_VIEWS_EVENTS_NAMES;
|
|
236
|
+
exports.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH = CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
|
|
237
|
+
exports.DOMAINS = DOMAINS;
|
|
238
|
+
exports.ENTRY_POINT_URI_PATH_REGEX = ENTRY_POINT_URI_PATH_REGEX;
|
|
239
|
+
exports.GRAPHQL_TARGETS = GRAPHQL_TARGETS;
|
|
240
|
+
exports.HIDE_ALL_PAGE_NOTIFICATIONS = HIDE_ALL_PAGE_NOTIFICATIONS;
|
|
241
|
+
exports.HIDE_LOADING = HIDE_LOADING;
|
|
242
|
+
exports.HTTP_SECURITY_HEADERS = HTTP_SECURITY_HEADERS;
|
|
243
|
+
exports.HTTP_SECURITY_HEADER_KEYS = HTTP_SECURITY_HEADER_KEYS;
|
|
244
|
+
exports.LOGIN_STRATEGY_DEFAULT = LOGIN_STRATEGY_DEFAULT;
|
|
245
|
+
exports.LOGIN_STRATEGY_OIDC = LOGIN_STRATEGY_OIDC;
|
|
246
|
+
exports.LOGIN_STRATEGY_SSO = LOGIN_STRATEGY_SSO;
|
|
247
|
+
exports.LOGOUT_REASONS = LOGOUT_REASONS;
|
|
248
|
+
exports.MC_API_PROXY_TARGETS = MC_API_PROXY_TARGETS;
|
|
249
|
+
exports.NOTIFICATION_DOMAINS = NOTIFICATION_DOMAINS;
|
|
250
|
+
exports.NOTIFICATION_KINDS_GLOBAL = NOTIFICATION_KINDS_GLOBAL;
|
|
251
|
+
exports.NOTIFICATION_KINDS_PAGE = NOTIFICATION_KINDS_PAGE;
|
|
252
|
+
exports.NOTIFICATION_KINDS_SIDE = NOTIFICATION_KINDS_SIDE;
|
|
253
|
+
exports.NO_VALUE_FALLBACK = NO_VALUE_FALLBACK;
|
|
254
|
+
exports.ORGANIZATION_GENERAL_ERROR = ORGANIZATION_GENERAL_ERROR;
|
|
255
|
+
exports.PERMISSION_GROUP_NAME_REGEX = PERMISSION_GROUP_NAME_REGEX;
|
|
256
|
+
exports.PORTALS_CONTAINER_ID = PORTALS_CONTAINER_ID;
|
|
257
|
+
exports.PORTALS_CONTAINER_INDENTATION_SIZE = PORTALS_CONTAINER_INDENTATION_SIZE;
|
|
258
|
+
exports.PROJECT_KEY_REGEX = PROJECT_KEY_REGEX;
|
|
259
|
+
exports.SHOW_LOADING = SHOW_LOADING;
|
|
260
|
+
exports.STATUS_CODES = STATUS_CODES;
|
|
261
|
+
exports.STORAGE_KEYS = STORAGE_KEYS;
|
|
262
|
+
exports.SUPPORTED_HEADERS = SUPPORTED_HEADERS;
|
|
263
|
+
exports.SUPPORT_PORTAL_URL = SUPPORT_PORTAL_URL;
|
|
264
|
+
exports.featureFlags = featureToggles;
|
|
265
|
+
exports.version = version;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
6
|
+
var version = "24.7.2";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The project key must be between 2 and 36 characters long. It can only contain alphanumeric lowercase characters (a-z, 0-9),
|
|
10
|
+
* up to two consecutive underscores (_) and hyphens (-). Leading and trailing underscore and hyphens are also not allowed.
|
|
11
|
+
*
|
|
12
|
+
* This regular expression has been generated using ChatGPT.
|
|
13
|
+
* Explanation of the regular expression:
|
|
14
|
+
* 1. ^: Asserts the start of the string.
|
|
15
|
+
* 2. (?!.*(?:[-_]{3}|^[-_]|[-_]$)): Negative lookahead assertion ensures that there are no three consecutive hyphens or underscores ([-_]{3}), no leading hyphen or underscore (^[-_]), and no trailing hyphen or underscore ([-_]$).
|
|
16
|
+
* 3. (?=.{2,36}$): Positive lookahead assertion ensures that the length of the string is between 2 and 36 characters.
|
|
17
|
+
* 4. (?:[a-z1-9][a-z0-9]*)?: Non-capturing group matches an optional first character that cannot be '0' ([a-z1-9]) followed by zero or more lowercase alphanumeric characters ([a-z0-9]*).
|
|
18
|
+
* 5. (?:[-_]{0,2}[a-z0-9]+)*: Non-capturing group matches zero, one, or two hyphens or underscores followed by one or more lowercase alphanumeric characters. This group can repeat zero or more times.
|
|
19
|
+
* 6. $: Asserts the end of the string.
|
|
20
|
+
*/
|
|
21
|
+
const PROJECT_KEY_REGEX = /^(?!.*(?:[-_]{3}|^[-_]|[-_]$))(?=.{2,36}$)(?:[a-z1-9][a-z0-9]*)?(?:[-_]{0,2}[a-z0-9]+)*$/;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The entryPointUriPath may be between 2 and 64 characters and only contain alphabetic lowercase characters,
|
|
25
|
+
* non-consecutive underscores and hyphens. Leading and trailing underscore and hyphens are also not allowed.
|
|
26
|
+
*
|
|
27
|
+
* This regular expression has been generated using ChatGPT.
|
|
28
|
+
* Explanation of the regular expression:
|
|
29
|
+
* 1. ^: Asserts the start of the string.
|
|
30
|
+
* 2. (?!.*(?:[-_]{2}|^[-_]|[-_]$)): Negative lookahead assertion ensures that there are no two consecutive hyphens or underscores ([-_]{2}), no leading hyphen or underscore (^[-_]), and no trailing hyphen or underscore ([-_]$).
|
|
31
|
+
* 3. (?=.{2,64}$): Positive lookahead assertion ensures that the length of the string is between 2 and 64 characters.
|
|
32
|
+
* 4. (?:[a-z1-9][a-z0-9]*)?: Non-capturing group matches an optional first character that cannot be '0' ([a-z1-9]) followed by zero or more lowercase alphanumeric characters ([a-z0-9]*).
|
|
33
|
+
* 5. (?:[-_]{0,1}[a-z0-9]+)*: Non-capturing group matches zero, or one hyphen or underscore followed by one or more lowercase alphanumeric characters. This group can repeat zero or more times.
|
|
34
|
+
* 6. $: Asserts the end of the string.
|
|
35
|
+
*/
|
|
36
|
+
const ENTRY_POINT_URI_PATH_REGEX = /^(?!.*(?:[-_]{2}|^[-_]|[-_]$))(?=.{2,64}$)(?:[a-z1-9][a-z0-9]*)?(?:[-_]{0,1}[a-z0-9]+)*$/;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The permission group name may be between 2 and 64 characters and only contain alphanumeric lowercase characters and non-consecutive hyphens.
|
|
40
|
+
* Leading and trailing hyphens are also not allowed.
|
|
41
|
+
*/
|
|
42
|
+
const PERMISSION_GROUP_NAME_REGEX = /^[^-#\W]([a-z]|[-](?![-])){0,62}[^-#\W]$/;
|
|
43
|
+
|
|
44
|
+
// DOM elements
|
|
45
|
+
const PORTALS_CONTAINER_ID = 'portals-container';
|
|
46
|
+
const PORTALS_CONTAINER_INDENTATION_SIZE = '48px';
|
|
47
|
+
|
|
48
|
+
// Links
|
|
49
|
+
const SUPPORT_PORTAL_URL = 'https://support.commercetools.com';
|
|
50
|
+
|
|
51
|
+
// Notification actions
|
|
52
|
+
const SHOW_LOADING = 'SHOW_LOADING';
|
|
53
|
+
const HIDE_LOADING = 'HIDE_LOADING';
|
|
54
|
+
const HIDE_ALL_PAGE_NOTIFICATIONS = 'HIDE_ALL_PAGE_NOTIFICATIONS';
|
|
55
|
+
|
|
56
|
+
// Notifications
|
|
57
|
+
const NOTIFICATION_DOMAINS = {
|
|
58
|
+
GLOBAL: 'global',
|
|
59
|
+
PAGE: 'page',
|
|
60
|
+
SIDE: 'side'
|
|
61
|
+
};
|
|
62
|
+
const NOTIFICATION_KINDS_SIDE = {
|
|
63
|
+
error: 'error',
|
|
64
|
+
warning: 'warning',
|
|
65
|
+
info: 'info',
|
|
66
|
+
success: 'success'
|
|
67
|
+
};
|
|
68
|
+
const NOTIFICATION_KINDS_GLOBAL = {
|
|
69
|
+
error: 'error',
|
|
70
|
+
warning: 'warning',
|
|
71
|
+
info: 'info',
|
|
72
|
+
success: 'success',
|
|
73
|
+
'unexpected-error': 'unexpected-error'
|
|
74
|
+
};
|
|
75
|
+
const NOTIFICATION_KINDS_PAGE = {
|
|
76
|
+
error: 'error',
|
|
77
|
+
warning: 'warning',
|
|
78
|
+
info: 'info',
|
|
79
|
+
success: 'success',
|
|
80
|
+
'unexpected-error': 'unexpected-error',
|
|
81
|
+
'api-error': 'api-error'
|
|
82
|
+
};
|
|
83
|
+
// Alias to `NOTIFICATION_DOMAINS` for backwards compatibility
|
|
84
|
+
const DOMAINS = NOTIFICATION_DOMAINS;
|
|
85
|
+
// Fallback string when there is no localized value
|
|
86
|
+
const NO_VALUE_FALLBACK = '- -';
|
|
87
|
+
|
|
88
|
+
// HTTP requests and responses
|
|
89
|
+
const STATUS_CODES = {
|
|
90
|
+
UNAUTHORIZED: 401,
|
|
91
|
+
FORBIDDEN: 403,
|
|
92
|
+
UNAUTHENTICATED: 299,
|
|
93
|
+
NOT_FOUND: 404
|
|
94
|
+
};
|
|
95
|
+
const LOGOUT_REASONS = {
|
|
96
|
+
USER: 'user',
|
|
97
|
+
UNAUTHORIZED: 'unauthorized',
|
|
98
|
+
INVALID: 'invalid',
|
|
99
|
+
DELETED: 'deleted',
|
|
100
|
+
NO_PROJECTS: 'no-projects'
|
|
101
|
+
};
|
|
102
|
+
const GRAPHQL_TARGETS = {
|
|
103
|
+
MERCHANT_CENTER_BACKEND: 'mc',
|
|
104
|
+
COMMERCETOOLS_PLATFORM: 'ctp',
|
|
105
|
+
DASHBOARD_SERVICE: 'dashboard',
|
|
106
|
+
CHANGE_HISTORY_SERVICE: 'change-history',
|
|
107
|
+
PIM_INDEXER: 'pim-indexer',
|
|
108
|
+
ORDER_INDEXER: 'order-indexer',
|
|
109
|
+
SETTINGS_SERVICE: 'settings',
|
|
110
|
+
ADMINISTRATION_SERVICE: 'administration',
|
|
111
|
+
STANDALONE_PRICES_INDEXER: 'standalone-prices-indexer',
|
|
112
|
+
PLATFORM_INSIGHTS: 'platform-insights'
|
|
113
|
+
};
|
|
114
|
+
const MC_API_PROXY_TARGETS = {
|
|
115
|
+
COMMERCETOOLS_PLATFORM: 'ctp',
|
|
116
|
+
MACHINE_LEARNING: 'ml',
|
|
117
|
+
PIM_SEARCH: 'pim-search',
|
|
118
|
+
ORDER_SEARCH: 'order-search',
|
|
119
|
+
IMPORT: 'import',
|
|
120
|
+
EXPORT: 'export',
|
|
121
|
+
STANDALONE_PRICES_SEARCH: 'standalone-prices-search'
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Global application environment on window object
|
|
125
|
+
|
|
126
|
+
// Used for Custom Views, as we want to keep the `entryPointUriPath` value required in the runtime config.
|
|
127
|
+
const CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH = '@@custom-view-host@@';
|
|
128
|
+
const SUPPORTED_HEADERS = {
|
|
129
|
+
ACCEPT: 'Accept',
|
|
130
|
+
ACCEPT_VERSION: 'Accept-version',
|
|
131
|
+
AUTHORIZATION: 'Authorization',
|
|
132
|
+
CONTENT_TYPE: 'Content-Type',
|
|
133
|
+
X_APPLICATION_ID: 'X-Application-Id',
|
|
134
|
+
X_CUSTOM_VIEW_ID: 'X-Custom-View-Id',
|
|
135
|
+
X_CORRELATION_ID: 'X-Correlation-Id',
|
|
136
|
+
X_FEATURE_FLAG: 'X-Feature-Flag',
|
|
137
|
+
X_FORWARD_TO: 'X-Forward-To',
|
|
138
|
+
X_FORWARD_TO_AUDIENCE_POLICY: 'X-Forward-To-Audience-Policy',
|
|
139
|
+
X_FORWARD_TO_CLAIMS: 'X-Forward-To-Claims',
|
|
140
|
+
X_GRAPHQL_TARGET: 'X-Graphql-Target',
|
|
141
|
+
X_GRAPHQL_OPERATION_NAME: 'X-Graphql-Operation-Name',
|
|
142
|
+
X_PROJECT_KEY: 'X-Project-Key',
|
|
143
|
+
X_TEAM_ID: 'X-Team-Id',
|
|
144
|
+
X_TOKEN_RETRY: 'X-Force-Token',
|
|
145
|
+
X_USER_AGENT: 'X-User-Agent'
|
|
146
|
+
};
|
|
147
|
+
const STORAGE_KEYS = {
|
|
148
|
+
NONCE: 'nonce',
|
|
149
|
+
IS_AUTHENTICATED: 'isAuthenticated',
|
|
150
|
+
SESSION_TOKEN: 'sessionToken',
|
|
151
|
+
SESSION_SCOPE: 'sessionScope',
|
|
152
|
+
ACTIVE_PROJECT_KEY: 'activeProjectKey',
|
|
153
|
+
ACTIVE_TEAM_ID: 'activeTeamId',
|
|
154
|
+
SELECTED_DATA_LOCALE: 'selectedDataLocale',
|
|
155
|
+
IS_FORCED_MENU_OPEN: 'isForcedMenuOpen',
|
|
156
|
+
LOGIN_STRATEGY: 'loginStrategy'
|
|
157
|
+
};
|
|
158
|
+
const HTTP_SECURITY_HEADER_KEYS = {
|
|
159
|
+
'Content-Security-Policy': 'Content-Security-Policy',
|
|
160
|
+
'Permissions-Policy': 'Permissions-Policy',
|
|
161
|
+
'Referrer-Policy': 'Referrer-Policy',
|
|
162
|
+
'Strict-Transport-Security': 'Strict-Transport-Security',
|
|
163
|
+
'X-Content-Type-Options': 'X-Content-Type-Options',
|
|
164
|
+
'X-Frame-Options': 'X-Frame-Options',
|
|
165
|
+
// @deprecated: this header is not supported by the browser anymore. Use `Content-Security-Policy` instead.
|
|
166
|
+
'X-XSS-Protection': 'X-XSS-Protection'
|
|
167
|
+
};
|
|
168
|
+
const HTTP_SECURITY_HEADERS = {
|
|
169
|
+
[HTTP_SECURITY_HEADER_KEYS['Referrer-Policy']]: 'same-origin',
|
|
170
|
+
[HTTP_SECURITY_HEADER_KEYS['Permissions-Policy']]:
|
|
171
|
+
// Note: we need to use `(self)` to ensure that Custom Views (rendered within an `<iframe>`)
|
|
172
|
+
// can inherit the main application permissions policy and override other directives if needed.
|
|
173
|
+
'microphone=(self), camera=(self), payment=(self), usb=(self), geolocation=(self)',
|
|
174
|
+
[HTTP_SECURITY_HEADER_KEYS['Strict-Transport-Security']]: 'max-age=31536000; includeSubDomains; preload',
|
|
175
|
+
[HTTP_SECURITY_HEADER_KEYS['X-Content-Type-Options']]: 'nosniff',
|
|
176
|
+
[HTTP_SECURITY_HEADER_KEYS['X-Frame-Options']]: 'SAMEORIGIN'
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Custom Views events (messages sent between the host application and the custom view)
|
|
180
|
+
const CUSTOM_VIEWS_EVENTS_NAMES = {
|
|
181
|
+
CUSTOM_VIEW_BOOTSTRAP: 'custom-view-bootstrap',
|
|
182
|
+
CUSTOM_VIEW_INITIALIZATION: 'custom-view-initialization',
|
|
183
|
+
CUSTOM_VIEW_CLOSE: 'custom-view-close',
|
|
184
|
+
CUSTOM_VIEW_READY: 'custom-view-ready',
|
|
185
|
+
CUSTOM_VIEW_ON_CLOSE_AFTER: 'custom-view-on-close-after'
|
|
186
|
+
};
|
|
187
|
+
const CUSTOM_VIEWS_EVENTS_META = {
|
|
188
|
+
HOST_APPLICATION_CODE: 'mc-host-application',
|
|
189
|
+
CUSTOM_VIEW_KEY_PREFIX: 'custom-view-'
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// SSO
|
|
193
|
+
const ORGANIZATION_GENERAL_ERROR = 'organizationGeneralError';
|
|
194
|
+
const LOGIN_STRATEGY_DEFAULT = 'default';
|
|
195
|
+
const LOGIN_STRATEGY_OIDC = 'oidc';
|
|
196
|
+
const LOGIN_STRATEGY_SSO = 'sso';
|
|
197
|
+
|
|
198
|
+
/*
|
|
199
|
+
* This file contains a list of all feature toggles used within
|
|
200
|
+
* the app shell. Each feature toggle should be a constant.
|
|
201
|
+
*
|
|
202
|
+
* ```
|
|
203
|
+
* export const FEATURE_TOGGLE_NAME = 'featureToggleName';
|
|
204
|
+
* export const FLAGS = {
|
|
205
|
+
* [FEATURE_TOGGLE_NAME]: false,
|
|
206
|
+
* };
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* NOTE:
|
|
210
|
+
* Default values are not yet passed to flopflip and it has to be decided
|
|
211
|
+
* how the integrate with the plugin API.
|
|
212
|
+
* The default values would be used whenever feature toggles have not been
|
|
213
|
+
* fetched from LaunchDarkly (without default values flopflip will default
|
|
214
|
+
* them to off until fetched).
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
const CUSTOM_VIEWS = 'enableCustomViews';
|
|
218
|
+
const FLAGS = {};
|
|
219
|
+
|
|
220
|
+
// Long-lived feature flags, defined in the MC API.
|
|
221
|
+
const DEFAULT_FLAGS = {
|
|
222
|
+
[CUSTOM_VIEWS]: {
|
|
223
|
+
value: true
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
var featureToggles = /*#__PURE__*/Object.freeze({
|
|
228
|
+
__proto__: null,
|
|
229
|
+
CUSTOM_VIEWS: CUSTOM_VIEWS,
|
|
230
|
+
FLAGS: FLAGS,
|
|
231
|
+
DEFAULT_FLAGS: DEFAULT_FLAGS
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
exports.CUSTOM_VIEWS_EVENTS_META = CUSTOM_VIEWS_EVENTS_META;
|
|
235
|
+
exports.CUSTOM_VIEWS_EVENTS_NAMES = CUSTOM_VIEWS_EVENTS_NAMES;
|
|
236
|
+
exports.CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH = CUSTOM_VIEW_HOST_ENTRY_POINT_URI_PATH;
|
|
237
|
+
exports.DOMAINS = DOMAINS;
|
|
238
|
+
exports.ENTRY_POINT_URI_PATH_REGEX = ENTRY_POINT_URI_PATH_REGEX;
|
|
239
|
+
exports.GRAPHQL_TARGETS = GRAPHQL_TARGETS;
|
|
240
|
+
exports.HIDE_ALL_PAGE_NOTIFICATIONS = HIDE_ALL_PAGE_NOTIFICATIONS;
|
|
241
|
+
exports.HIDE_LOADING = HIDE_LOADING;
|
|
242
|
+
exports.HTTP_SECURITY_HEADERS = HTTP_SECURITY_HEADERS;
|
|
243
|
+
exports.HTTP_SECURITY_HEADER_KEYS = HTTP_SECURITY_HEADER_KEYS;
|
|
244
|
+
exports.LOGIN_STRATEGY_DEFAULT = LOGIN_STRATEGY_DEFAULT;
|
|
245
|
+
exports.LOGIN_STRATEGY_OIDC = LOGIN_STRATEGY_OIDC;
|
|
246
|
+
exports.LOGIN_STRATEGY_SSO = LOGIN_STRATEGY_SSO;
|
|
247
|
+
exports.LOGOUT_REASONS = LOGOUT_REASONS;
|
|
248
|
+
exports.MC_API_PROXY_TARGETS = MC_API_PROXY_TARGETS;
|
|
249
|
+
exports.NOTIFICATION_DOMAINS = NOTIFICATION_DOMAINS;
|
|
250
|
+
exports.NOTIFICATION_KINDS_GLOBAL = NOTIFICATION_KINDS_GLOBAL;
|
|
251
|
+
exports.NOTIFICATION_KINDS_PAGE = NOTIFICATION_KINDS_PAGE;
|
|
252
|
+
exports.NOTIFICATION_KINDS_SIDE = NOTIFICATION_KINDS_SIDE;
|
|
253
|
+
exports.NO_VALUE_FALLBACK = NO_VALUE_FALLBACK;
|
|
254
|
+
exports.ORGANIZATION_GENERAL_ERROR = ORGANIZATION_GENERAL_ERROR;
|
|
255
|
+
exports.PERMISSION_GROUP_NAME_REGEX = PERMISSION_GROUP_NAME_REGEX;
|
|
256
|
+
exports.PORTALS_CONTAINER_ID = PORTALS_CONTAINER_ID;
|
|
257
|
+
exports.PORTALS_CONTAINER_INDENTATION_SIZE = PORTALS_CONTAINER_INDENTATION_SIZE;
|
|
258
|
+
exports.PROJECT_KEY_REGEX = PROJECT_KEY_REGEX;
|
|
259
|
+
exports.SHOW_LOADING = SHOW_LOADING;
|
|
260
|
+
exports.STATUS_CODES = STATUS_CODES;
|
|
261
|
+
exports.STORAGE_KEYS = STORAGE_KEYS;
|
|
262
|
+
exports.SUPPORTED_HEADERS = SUPPORTED_HEADERS;
|
|
263
|
+
exports.SUPPORT_PORTAL_URL = SUPPORT_PORTAL_URL;
|
|
264
|
+
exports.featureFlags = featureToggles;
|
|
265
|
+
exports.version = version;
|