@scaleflex/widget-core 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.5.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.4.0...v4.5.0) (2025-10-08)
7
+
8
+ **Note:** Version bump only for package @scaleflex/widget-core
9
+
10
+
11
+
12
+
13
+
6
14
  # [4.4.0](https://code.scaleflex.cloud/scaleflex/widget/compare/v4.1.0...v4.4.0) (2025-10-07)
7
15
 
8
16
  **Note:** Version bump only for package @scaleflex/widget-core
package/dist/style.css ADDED
@@ -0,0 +1,229 @@
1
+ @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");
2
+ /**
3
+ * General Scaleflex styles that apply to everything inside the .filerobot-Root container
4
+ */
5
+ .filerobot-Root {
6
+ overflow: hidden;
7
+ box-sizing: border-box;
8
+ font-family: "Roboto", sans-serif, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
9
+ line-height: 1;
10
+ -webkit-font-smoothing: antialiased;
11
+ -moz-osx-font-smoothing: grayscale;
12
+ text-align: left;
13
+ position: relative;
14
+ color: #333;
15
+ }
16
+ .filerobot-Root :disabled {
17
+ cursor: not-allowed;
18
+ }
19
+
20
+ .SfxModal-Wrapper, .filerobot-Root *, #SfxPopper * {
21
+ font-family: "Roboto", sans-serif, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
22
+ }
23
+
24
+ #SfxPopper * {
25
+ box-sizing: border-box;
26
+ }
27
+
28
+ .SfxModal-Wrapper *, .filerobot-Root *, #SfxPopper * {
29
+ scrollbar-color: auto !important;
30
+ }
31
+ .SfxModal-Wrapper *::-webkit-scrollbar, .filerobot-Root *::-webkit-scrollbar, #SfxPopper *::-webkit-scrollbar {
32
+ width: 12px !important;
33
+ height: 12px !important;
34
+ }
35
+ .SfxModal-Wrapper *, .filerobot-Root *, #SfxPopper * {
36
+ /* Track */
37
+ }
38
+ .SfxModal-Wrapper *::-webkit-scrollbar-track, .filerobot-Root *::-webkit-scrollbar-track, #SfxPopper *::-webkit-scrollbar-track {
39
+ background: transparent !important;
40
+ }
41
+ .SfxModal-Wrapper *, .filerobot-Root *, #SfxPopper * {
42
+ /* Handle */
43
+ }
44
+ .SfxModal-Wrapper *::-webkit-scrollbar-thumb, .filerobot-Root *::-webkit-scrollbar-thumb, #SfxPopper *::-webkit-scrollbar-thumb {
45
+ background: #CCD6DE;
46
+ border: 4px solid #FFFFFF;
47
+ border-radius: 99px;
48
+ padding: 4px 6px;
49
+ }
50
+
51
+ .filerobot-Root *, .filerobot-Root *:before, .filerobot-Root *:after {
52
+ box-sizing: inherit;
53
+ }
54
+
55
+ .filerobot-Root [hidden] {
56
+ display: none;
57
+ }
58
+
59
+ .filerobot-u-reset {
60
+ -webkit-appearance: none;
61
+ line-height: 1;
62
+ padding: 0;
63
+ margin: 0;
64
+ border: 0;
65
+ color: inherit;
66
+ backface-visibility: visible;
67
+ background: none;
68
+ border: medium none currentColor;
69
+ border-collapse: separate;
70
+ -o-border-image: none;
71
+ border-image: none;
72
+ border-radius: 0;
73
+ border-spacing: 0;
74
+ box-shadow: none;
75
+ clear: none;
76
+ cursor: auto;
77
+ display: inline;
78
+ empty-cells: show;
79
+ float: none;
80
+ font-family: inherit;
81
+ font-size: inherit;
82
+ font-style: normal;
83
+ font-variant: normal;
84
+ font-weight: normal;
85
+ font-stretch: normal;
86
+ -webkit-hyphens: none;
87
+ hyphens: none;
88
+ left: auto;
89
+ letter-spacing: normal;
90
+ list-style: none;
91
+ margin: 0;
92
+ max-height: none;
93
+ max-width: none;
94
+ min-height: 0;
95
+ min-width: 0;
96
+ opacity: 1;
97
+ outline: medium none invert;
98
+ overflow: visible;
99
+ overflow-x: visible;
100
+ overflow-y: visible;
101
+ text-align: left;
102
+ text-decoration: none;
103
+ text-indent: 0;
104
+ text-shadow: none;
105
+ text-transform: none;
106
+ top: auto;
107
+ transform: none;
108
+ transform-origin: 50% 50% 0;
109
+ transform-style: flat;
110
+ transition: none 0s ease 0s;
111
+ unicode-bidi: normal;
112
+ vertical-align: baseline;
113
+ visibility: visible;
114
+ white-space: normal;
115
+ z-index: auto;
116
+ }
117
+ .filerobot-u-reset span {
118
+ max-width: 250px;
119
+ overflow: hidden;
120
+ text-overflow: ellipsis;
121
+ }
122
+ .filerobot-u-reset span :not(:disabled) :active {
123
+ background-color: #eceef2;
124
+ }
125
+
126
+ .filerobot-c-horizontal-separator {
127
+ width: 100%;
128
+ border-bottom: 1px solid #DFE7ED;
129
+ height: 1px;
130
+ display: block;
131
+ position: absolute;
132
+ left: 0;
133
+ right: 0;
134
+ }
135
+
136
+ .filerobot-c-icon {
137
+ max-width: 100%;
138
+ max-height: 100%;
139
+ fill: currentColor;
140
+ display: inline-block;
141
+ overflow: hidden;
142
+ }
143
+
144
+ .filerobot-c-btn {
145
+ display: inline-block;
146
+ text-align: center;
147
+ white-space: nowrap;
148
+ vertical-align: middle;
149
+ font-family: inherit;
150
+ font-size: 16px;
151
+ line-height: 1;
152
+ font-weight: 500;
153
+ transition-property: background-color, color;
154
+ transition-duration: 0.3s;
155
+ -webkit-user-select: none;
156
+ -moz-user-select: none;
157
+ user-select: none;
158
+ }
159
+
160
+ .filerobot-c-btn:not(:disabled):not(.disabled) {
161
+ cursor: pointer;
162
+ }
163
+
164
+ .filerobot-c-btn::-moz-focus-inner {
165
+ border: 0;
166
+ }
167
+
168
+ .filerobot-c-btn-primary {
169
+ font-size: 14px;
170
+ padding: 10px 18px;
171
+ border-radius: 4px;
172
+ background-color: #5282DB;
173
+ color: #fff;
174
+ }
175
+ .filerobot-c-btn-primary:hover {
176
+ background-color: rgb(43.0622009569, 100.4784688995, 206.9377990431);
177
+ }
178
+ .filerobot-c-btn-primary:focus {
179
+ outline: none;
180
+ box-shadow: 0 0 0 3px rgba(82, 130, 219, 0.4);
181
+ }
182
+ .filerobot-size--md .filerobot-c-btn-primary {
183
+ padding: 13px 22px;
184
+ }
185
+ [data-filerobot-theme=dark] .filerobot-c-btn-primary {
186
+ color: #eaeaea;
187
+ }
188
+ [data-filerobot-theme=dark] .filerobot-c-btn-primary:focus {
189
+ outline: none;
190
+ }
191
+ [data-filerobot-theme=dark] .filerobot-c-btn-primary::-moz-focus-inner {
192
+ border: 0;
193
+ }
194
+ [data-filerobot-theme=dark] .filerobot-c-btn-primary:focus {
195
+ box-shadow: 0 0 0 2px rgba(170, 225, 255, 0.85);
196
+ }
197
+
198
+ .filerobot-c-empty-wrapper {
199
+ display: flex;
200
+ height: 100%;
201
+ }
202
+ .filerobot-c-empty {
203
+ height: 100%;
204
+ width: 100%;
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ flex-flow: column wrap;
209
+ flex: 1;
210
+ color: #939393;
211
+ background-color: #ffffff;
212
+ line-height: 14px;
213
+ font-size: 12px;
214
+ }
215
+ .filerobot-c-empty.left {
216
+ align-items: flex-start;
217
+ }
218
+ .filerobot-c-empty.right {
219
+ align-items: flex-end;
220
+ }
221
+
222
+ .filerobot-c-empty {
223
+ align-items: flex-start;
224
+ color: #768A9F;
225
+ }
226
+
227
+ svg {
228
+ outline: none;
229
+ }
@@ -0,0 +1 @@
1
+ @import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");.filerobot-Root{box-sizing:border-box;font-family:Roboto,sans-serif,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;line-height:1;overflow:hidden;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#333;position:relative;text-align:left}.filerobot-Root :disabled{cursor:not-allowed}#SfxPopper *,.SfxModal-Wrapper,.filerobot-Root *{font-family:Roboto,sans-serif,Helvetica,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol}#SfxPopper *{box-sizing:border-box}#SfxPopper *,.SfxModal-Wrapper *,.filerobot-Root *{scrollbar-color:auto!important}#SfxPopper ::-webkit-scrollbar,.SfxModal-Wrapper ::-webkit-scrollbar,.filerobot-Root ::-webkit-scrollbar{height:12px!important;width:12px!important}#SfxPopper ::-webkit-scrollbar-track,.SfxModal-Wrapper ::-webkit-scrollbar-track,.filerobot-Root ::-webkit-scrollbar-track{background:transparent!important}#SfxPopper ::-webkit-scrollbar-thumb,.SfxModal-Wrapper ::-webkit-scrollbar-thumb,.filerobot-Root ::-webkit-scrollbar-thumb{background:#ccd6de;border:4px solid #fff;border-radius:99px;padding:4px 6px}.filerobot-Root *,.filerobot-Root :after,.filerobot-Root :before{box-sizing:inherit}.filerobot-Root [hidden]{display:none}.filerobot-u-reset{-webkit-appearance:none;backface-visibility:visible;background:none;border:none;border-collapse:separate;-o-border-image:none;border-image:none;border-radius:0;border-spacing:0;box-shadow:none;clear:none;color:inherit;cursor:auto;display:inline;empty-cells:show;float:none;font-family:inherit;font-size:inherit;font-stretch:normal;font-style:normal;font-variant:normal;font-weight:400;-webkit-hyphens:none;hyphens:none;left:auto;letter-spacing:normal;line-height:1;list-style:none;margin:0;max-height:none;max-width:none;min-height:0;min-width:0;opacity:1;outline:medium none invert;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;top:auto;transform:none;transform-origin:50% 50% 0;transform-style:flat;transition:none 0s ease 0s;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;z-index:auto}.filerobot-u-reset span{max-width:250px;overflow:hidden;text-overflow:ellipsis}.filerobot-u-reset span :not(:disabled) :active{background-color:#eceef2}.filerobot-c-horizontal-separator{border-bottom:1px solid #dfe7ed;display:block;height:1px;left:0;position:absolute;right:0;width:100%}.filerobot-c-icon{max-height:100%;max-width:100%;fill:currentColor;display:inline-block;overflow:hidden}.filerobot-c-btn{display:inline-block;font-family:inherit;font-size:16px;font-weight:500;line-height:1;text-align:center;transition-duration:.3s;transition-property:background-color,color;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}.filerobot-c-btn:not(:disabled):not(.disabled){cursor:pointer}.filerobot-c-btn::-moz-focus-inner{border:0}.filerobot-c-btn-primary{background-color:#5282db;border-radius:4px;color:#fff;font-size:14px;padding:10px 18px}.filerobot-c-btn-primary:hover{background-color:#2b64cf}.filerobot-c-btn-primary:focus{box-shadow:0 0 0 3px rgba(82,130,219,.4);outline:none}.filerobot-size--md .filerobot-c-btn-primary{padding:13px 22px}[data-filerobot-theme=dark] .filerobot-c-btn-primary{color:#eaeaea}[data-filerobot-theme=dark] .filerobot-c-btn-primary:focus{outline:none}[data-filerobot-theme=dark] .filerobot-c-btn-primary::-moz-focus-inner{border:0}[data-filerobot-theme=dark] .filerobot-c-btn-primary:focus{box-shadow:0 0 0 2px rgba(170,225,255,.85)}.filerobot-c-empty,.filerobot-c-empty-wrapper{display:flex;height:100%}.filerobot-c-empty{align-items:center;background-color:#fff;color:#939393;flex:1;flex-flow:column wrap;font-size:12px;justify-content:center;line-height:14px;width:100%}.filerobot-c-empty.left{align-items:flex-start}.filerobot-c-empty.right{align-items:flex-end}.filerobot-c-empty{align-items:flex-start;color:#768a9f}svg{outline:none}
package/lib/Client.js ADDED
@@ -0,0 +1,390 @@
1
+ var _excluded = ["sorting", "recursive", "filters", "offset", "limit", "format", "noPagination", "noFormatAndSortParams", "noRecursiveParam", "moreQueries", "useCustomEncoding"];
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
5
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
6
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
8
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
9
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ import RequestError from '@scaleflex/widget-utils/lib/RequestError';
14
+ import { PERMISSIONS, ABORTED_ERROR, RESPONSE_CODES } from '@scaleflex/widget-utils/lib/constants';
15
+ import checkConnection from '@scaleflex/widget-utils/lib/checkConnection';
16
+ import { customEncodeURIComponent } from '@scaleflex/widget-utils/lib/customEncodeURIComponent';
17
+ import { selectUser } from './slices/user.slice';
18
+ var Client = /*#__PURE__*/_createClass(function Client(filerobot) {
19
+ var _this = this;
20
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21
+ _classCallCheck(this, Client);
22
+ _defineProperty(this, "getSecretHeaderName", function () {
23
+ return 'X-Filerobot-Key';
24
+ });
25
+ _defineProperty(this, "getSecretKeyValue", function () {
26
+ var _selectUser;
27
+ return (_selectUser = selectUser(_this.filerobot.getGlobalState())) === null || _selectUser === void 0 ? void 0 : _selectUser.sassKey;
28
+ });
29
+ /**
30
+ * @param {string|string[]} id
31
+ */
32
+ _defineProperty(this, "abort", function (id) {
33
+ var abortSingleId = function abortSingleId(_id) {
34
+ if (_this.xhrs && _this.xhrs[_id]) {
35
+ _this.xhrs[_id].abort();
36
+ delete _this.xhrs[_id];
37
+ }
38
+ };
39
+ if (typeof id === 'string') {
40
+ abortSingleId(id);
41
+ } else if (Array.isArray(id)) {
42
+ id.forEach(abortSingleId);
43
+ }
44
+ });
45
+ _defineProperty(this, "_generateFetchUrl", function (_ref) {
46
+ var apiPath = _ref.apiPath,
47
+ _ref$queries = _ref.queries,
48
+ queries = _ref$queries === void 0 ? {} : _ref$queries,
49
+ _ref$useCustomEncodin = _ref.useCustomEncoding,
50
+ useCustomEncoding = _ref$useCustomEncodin === void 0 ? false : _ref$useCustomEncodin;
51
+ var queryItems = [];
52
+ Object.keys(queries).forEach(function (key) {
53
+ var queryValue = queries[key];
54
+ if (Array.isArray(queryValue)) {
55
+ queryItems = queryItems.concat(queryValue);
56
+ } else if (!['undefined', 'object'].includes(_typeof(queryValue))) {
57
+ queryItems.push("".concat(key, "=").concat((useCustomEncoding ? customEncodeURIComponent : encodeURIComponent)(queryValue)));
58
+ }
59
+ });
60
+ return "".concat(apiPath).concat(queryItems.length > 0 ? "".concat(apiPath.includes('?') ? '&' : '?').concat(queryItems.join('&')) : '');
61
+ });
62
+ _defineProperty(this, "_send", function (url) {
63
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
+ var _options$method = options.method,
65
+ method = _options$method === void 0 ? 'GET' : _options$method,
66
+ data = options.data,
67
+ _options$headers = options.headers,
68
+ headers = _options$headers === void 0 ? {} : _options$headers,
69
+ abortSignal = options.abortSignal,
70
+ onAbort = options.onAbort,
71
+ onProgress = options.onProgress,
72
+ onError = options.onError,
73
+ avoidErrorMsg = options.avoidErrorMsg,
74
+ baseApi = options.baseApi,
75
+ _options$responseType = options.responseType,
76
+ responseType = _options$responseType === void 0 ? 'json' : _options$responseType,
77
+ dataTransformationsCbk = options.dataTransformationsCbk,
78
+ permissionsToCheck = options.permissionsToCheck,
79
+ id = options.id,
80
+ _options$requestIdsTo = options.requestIdsToAbort,
81
+ requestIdsToAbort = _options$requestIdsTo === void 0 ? [] : _options$requestIdsTo,
82
+ _options$noContentTyp = options.noContentType,
83
+ noContentType = _options$noContentTyp === void 0 ? false : _options$noContentTyp,
84
+ _options$enabledAbort = options.enabledAbort,
85
+ enabledAbort = _options$enabledAbort === void 0 ? true : _options$enabledAbort,
86
+ checkOnlySuccessStatus = options.checkOnlySuccessStatus,
87
+ _options$noDefaultHea = options.noDefaultHeaders,
88
+ noDefaultHeaders = _options$noDefaultHea === void 0 ? false : _options$noDefaultHea;
89
+ if (permissionsToCheck && permissionsToCheck.length > 0 && !_this.filerobot.checkUserPermissions(permissionsToCheck, true)) {
90
+ return Promise.reject(_this._i18n('filerobotInvalidPermissionError'));
91
+ }
92
+ return new Promise(function (resolve, reject) {
93
+ if (enabledAbort && id) {
94
+ _this.abort(id);
95
+ }
96
+ var xhr = new XMLHttpRequest();
97
+ if (enabledAbort && Array.isArray(requestIdsToAbort) && requestIdsToAbort.length > 0 && Object.keys(_this.xhrs).length > 0) {
98
+ _this.abort(requestIdsToAbort);
99
+ }
100
+ if (id) {
101
+ _this.xhrs[id] = xhr;
102
+ }
103
+ var finalUrl = (/^(http:|https:)?\/\//.test(url) ? url : "".concat(baseApi || _this._baseEndpoint).concat(url)).replace('#', '%23');
104
+ var isFilerobotApiRequest = new RegExp("^".concat(_this._baseEndpointWithoutVersion)).test(finalUrl);
105
+ xhr.open(method, finalUrl);
106
+ xhr.responseType = responseType;
107
+ if (!noContentType) {
108
+ xhr.setRequestHeader('Content-Type', 'application/json');
109
+ }
110
+ Object.keys(headers).map(function (header) {
111
+ return xhr.setRequestHeader(header, headers[header]);
112
+ });
113
+ if (isFilerobotApiRequest && !(headers !== null && headers !== void 0 && headers[_this.getSecretHeaderName()]) && !noDefaultHeaders) {
114
+ _this.filerobot.emit('sass-key-empty-header', {
115
+ url: finalUrl,
116
+ headers: headers
117
+ });
118
+ _this.filerobot.hideInfo();
119
+ _this.filerobot.info(_this._i18n('explorerServiceEmptySassKeyHeaderError'), 'error');
120
+ }
121
+ var hideOrShowError = function hideOrShowError(error) {
122
+ var _xhr$response, _xhr$response2;
123
+ var infoType = ((_xhr$response = xhr.response) === null || _xhr$response === void 0 ? void 0 : _xhr$response.status) === 'cancelled' ? 'error' : (_xhr$response2 = xhr.response) === null || _xhr$response2 === void 0 ? void 0 : _xhr$response2.status;
124
+ var showErrorMessage = function showErrorMessage() {
125
+ var _xhr$response3;
126
+ _this.filerobot.hideInfo();
127
+ _this.filerobot.info(((_xhr$response3 = xhr.response) === null || _xhr$response3 === void 0 ? void 0 : _xhr$response3.code) === RESPONSE_CODES.KEY_EXPIRED ? _this._i18n('explorerServiceExpiredSassKeyHeaderError') : error, infoType);
128
+ };
129
+ if (typeof avoidErrorMsg === 'function') {
130
+ if (!avoidErrorMsg(xhr.response)) {
131
+ showErrorMessage();
132
+ }
133
+ return;
134
+ }
135
+ if (!avoidErrorMsg) {
136
+ showErrorMessage();
137
+ }
138
+ };
139
+
140
+ /**
141
+ * Handle 'KEY_EXPIRED' response code by sending renew SassKey request
142
+ * @returns {boolean} - TRUE if handled
143
+ */
144
+ var handleKeyExpiredCode = function handleKeyExpiredCode() {
145
+ var _xhr$response4, _xhr$response5, _this$filerobot, _this$filerobot$sassK;
146
+ if ([(_xhr$response4 = xhr.response) === null || _xhr$response4 === void 0 ? void 0 : _xhr$response4.msg, (_xhr$response5 = xhr.response) === null || _xhr$response5 === void 0 ? void 0 : _xhr$response5.code].includes(RESPONSE_CODES.KEY_EXPIRED) && _this.filerobot.opts.sassKeyRenewerEnabled && (_this$filerobot = _this.filerobot) !== null && _this$filerobot !== void 0 && (_this$filerobot$sassK = _this$filerobot.sassKeyRenewer) !== null && _this$filerobot$sassK !== void 0 && _this$filerobot$sassK.sendRenewRequest) {
147
+ if (_this.filerobot.sassKeyRenewer.logEnabled) {
148
+ _this.filerobot.sassKeyRenewer.log("Request ".concat(url, " got KEY_EXPIRED, need to renew the sass key"));
149
+ }
150
+ _this.filerobot.sassKeyRenewer.sendRenewRequestForce(function () {
151
+ _this._send(url, options);
152
+ }, id);
153
+ return true;
154
+ }
155
+ return false;
156
+ };
157
+ xhr.onload = function () {
158
+ var _response$status;
159
+ var response = xhr.response || {};
160
+ var responseContentType = xhr.getResponseHeader('Content-Type');
161
+ var responseStatusKeys = ['ok', 'success', 'cancelled'];
162
+ if (xhr.status >= 200 && xhr.status < 300 && (checkOnlySuccessStatus || responseContentType !== 'application/json' || responseStatusKeys.includes((_response$status = response.status) === null || _response$status === void 0 ? void 0 : _response$status.toLowerCase()))) {
163
+ resolve(response || {});
164
+ } else {
165
+ var _response$result, _response$result2;
166
+ handleKeyExpiredCode();
167
+ var error = new RequestError({
168
+ code: xhr.status,
169
+ codeLabel: response.code,
170
+ message: response.msg || response.message || response.messages || ((_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.msg) || "Error code ".concat(xhr.status),
171
+ details: response.hint || response.msg || response.detail || ((_response$result2 = response.result) === null || _response$result2 === void 0 ? void 0 : _response$result2.hint) || _this._i18n('explorerServiceUnknownBackendError')
172
+ });
173
+ if (onError && typeof onError === 'function') {
174
+ onError(response);
175
+ }
176
+ hideOrShowError(error);
177
+ reject(error);
178
+ }
179
+ delete _this.xhrs[id];
180
+ };
181
+ xhr.onprogress = function (e) {
182
+ var isOnline = checkConnection();
183
+ if (!isOnline) {
184
+ xhr.abort();
185
+ var error = new Error(_this.filerobot.i18n('filerobotNoInternetConnectionInfo'));
186
+ reject(error);
187
+ return;
188
+ }
189
+ if (typeof onProgress === 'function' && e.lengthComputable) {
190
+ onProgress(e.loaded, e.total);
191
+ }
192
+ };
193
+ var isAborted = false;
194
+ xhr.onerror = function () {
195
+ if (isAborted) {
196
+ return;
197
+ }
198
+ if (handleKeyExpiredCode()) {
199
+ return;
200
+ }
201
+ var error = new RequestError({
202
+ code: xhr.status,
203
+ message: _this._i18n('mutualizedUnknownErrorMessage')
204
+ });
205
+ hideOrShowError(error);
206
+ reject(error);
207
+ };
208
+ xhr.onabort = function () {
209
+ isAborted = true;
210
+ if (typeof onAbort === 'function') {
211
+ onAbort(xhr, reject);
212
+ }
213
+
214
+ // No need for an error as this cancellation won't be considered as error and we might need to cancel/abort the request silently.
215
+ // we are disabling eslint here as it's anomaly.
216
+ // eslint-disable-next-line prefer-promise-reject-errors
217
+ reject(ABORTED_ERROR);
218
+ };
219
+ var transformData = typeof dataTransformationsCbk === 'function' ? dataTransformationsCbk : JSON.stringify;
220
+ xhr.send(transformData(data));
221
+ if (abortSignal) {
222
+ abortSignal.addEventListener('abort', function () {
223
+ xhr.abort();
224
+ }, {
225
+ once: true
226
+ });
227
+ }
228
+ });
229
+ });
230
+ // diff between fetch & get:
231
+ // -- fetch => supports filters, sort, pagination, recursive...etc. by receiving the args. and processing/combining them inside the function to prepare the final url.
232
+ // -- get => receives the prepared url that's ready to be called to have the results without any further processing.
233
+ _defineProperty(this, "fetch", function (path) {
234
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
235
+ sort = _ref2.sorting,
236
+ _ref2$recursive = _ref2.recursive,
237
+ recursive = _ref2$recursive === void 0 ? false : _ref2$recursive,
238
+ _ref2$filters = _ref2.filters,
239
+ filters = _ref2$filters === void 0 ? [] : _ref2$filters,
240
+ _ref2$offset = _ref2.offset,
241
+ offset = _ref2$offset === void 0 ? _this._defaultOffset : _ref2$offset,
242
+ _ref2$limit = _ref2.limit,
243
+ limit = _ref2$limit === void 0 ? _this._defaultLimit : _ref2$limit,
244
+ format = _ref2.format,
245
+ _ref2$noPagination = _ref2.noPagination,
246
+ noPagination = _ref2$noPagination === void 0 ? false : _ref2$noPagination,
247
+ _ref2$noFormatAndSort = _ref2.noFormatAndSortParams,
248
+ noFormatAndSortParams = _ref2$noFormatAndSort === void 0 ? false : _ref2$noFormatAndSort,
249
+ _ref2$noRecursivePara = _ref2.noRecursiveParam,
250
+ noRecursiveParam = _ref2$noRecursivePara === void 0 ? true : _ref2$noRecursivePara,
251
+ _ref2$moreQueries = _ref2.moreQueries,
252
+ moreQueries = _ref2$moreQueries === void 0 ? {} : _ref2$moreQueries,
253
+ _ref2$useCustomEncodi = _ref2.useCustomEncoding,
254
+ useCustomEncoding = _ref2$useCustomEncodi === void 0 ? false : _ref2$useCustomEncodi,
255
+ options = _objectWithoutProperties(_ref2, _excluded);
256
+ var params = {
257
+ apiPath: path,
258
+ queries: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, moreQueries), !noFormatAndSortParams && {
259
+ format: format,
260
+ sort: sort
261
+ }), !noPagination && {
262
+ offset: offset,
263
+ limit: limit
264
+ }), (filters === null || filters === void 0 ? void 0 : filters.length) > 0 && {
265
+ filters: filters
266
+ }), (!noRecursiveParam || recursive) && {
267
+ recursive: recursive ? 1 : 0
268
+ }),
269
+ useCustomEncoding: useCustomEncoding
270
+ };
271
+ var url = _this._generateFetchUrl(params);
272
+ return _this._send(url, _objectSpread(_objectSpread({}, options), {}, {
273
+ permissionToCheck: [PERMISSIONS.LIST_ALL],
274
+ headers: _this._combineHeaders(options)
275
+ }));
276
+ });
277
+ _defineProperty(this, "_sendAdminRequest", function (path, options) {
278
+ var _selectUser2, _selectUser2$info;
279
+ var sessionUuid = (_selectUser2 = selectUser(_this.filerobot.getGlobalState())) === null || _selectUser2 === void 0 ? void 0 : (_selectUser2$info = _selectUser2.info) === null || _selectUser2$info === void 0 ? void 0 : _selectUser2$info.sessionUuid;
280
+ return _this._send(path, _objectSpread(_objectSpread({
281
+ method: 'GET'
282
+ }, options), {}, {
283
+ headers: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, options.headers), sessionUuid && {
284
+ 'X-Session-Token': sessionUuid
285
+ }), _this._companyUuid && {
286
+ 'X-Company-Token': _this._companyUuid
287
+ }), _this._projectUuid && {
288
+ 'X-Project-Token': _this._projectUuid
289
+ }),
290
+ baseApi: "".concat(_this.filerobot.opts.adminApiEndpoint, "/")
291
+ }));
292
+ });
293
+ _defineProperty(this, "_sendShareRequest", function (path, options) {
294
+ return _this._send(path, _objectSpread(_objectSpread({
295
+ method: 'GET'
296
+ }, options), {}, {
297
+ baseApi: "".concat(_this.filerobot.opts.shareApiEndpoint, "/").concat(_this._container, "/v4/")
298
+ }));
299
+ });
300
+ _defineProperty(this, "_combineHeaders", function (_ref3) {
301
+ var _ref3$noDefaultHeader = _ref3.noDefaultHeaders,
302
+ noDefaultHeaders = _ref3$noDefaultHeader === void 0 ? false : _ref3$noDefaultHeader,
303
+ _ref3$headers = _ref3.headers,
304
+ headers = _ref3$headers === void 0 ? {} : _ref3$headers;
305
+ return noDefaultHeaders ? headers : _objectSpread(_objectSpread({}, headers), {}, _defineProperty({}, _this.getSecretHeaderName(), _this.getSecretKeyValue()));
306
+ });
307
+ _defineProperty(this, "get", function (path) {
308
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
309
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
310
+ method: 'GET',
311
+ headers: _this._combineHeaders(options)
312
+ }));
313
+ });
314
+ _defineProperty(this, "post", function (path) {
315
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
316
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
317
+ data: options.data,
318
+ method: 'POST',
319
+ headers: _this._combineHeaders(options)
320
+ }));
321
+ });
322
+ _defineProperty(this, "put", function (path) {
323
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
324
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
325
+ method: 'PUT',
326
+ data: options.data,
327
+ headers: _this._combineHeaders(options)
328
+ }));
329
+ });
330
+ _defineProperty(this, "patch", function (path) {
331
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
332
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
333
+ method: 'PATCH',
334
+ data: options.data,
335
+ headers: _this._combineHeaders(options)
336
+ }));
337
+ });
338
+ _defineProperty(this, "delete", function (path) {
339
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
340
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
341
+ method: 'DELETE',
342
+ data: options.data,
343
+ headers: _this._combineHeaders(options)
344
+ }));
345
+ });
346
+ _defineProperty(this, "getAdmin", function (path) {
347
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
348
+ return _this._sendAdminRequest(path, options);
349
+ });
350
+ _defineProperty(this, "postAdmin", function (path) {
351
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
352
+ return _this._sendAdminRequest(path, _objectSpread(_objectSpread({}, options), {}, {
353
+ method: 'POST',
354
+ data: options.data
355
+ }));
356
+ });
357
+ _defineProperty(this, "putAdmin", function (path) {
358
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
359
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
360
+ method: 'PUT',
361
+ data: options.data
362
+ }));
363
+ });
364
+ _defineProperty(this, "deleteAdmin", function (path) {
365
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
366
+ var data = arguments.length > 2 ? arguments[2] : undefined;
367
+ return _this._send(path, _objectSpread(_objectSpread({}, options), {}, {
368
+ method: 'PUT',
369
+ data: data
370
+ }));
371
+ });
372
+ _defineProperty(this, "getShare", function (path) {
373
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
374
+ return _this._sendShareRequest(path, options);
375
+ });
376
+ this.filerobot = filerobot;
377
+ this.opts = opts;
378
+ this._projectUuid = filerobot.opts.projectUuid;
379
+ this._companyUuid = filerobot.opts.companyUuid;
380
+ this._container = filerobot.opts.container;
381
+ this._baseEndpointWithoutVersion = filerobot.opts.apiEndpointWithContainer;
382
+ this._baseEndpoint = "".concat(this._baseEndpointWithoutVersion, "/").concat(filerobot.opts.apiEndpointVersion, "/");
383
+ this._adminEndpoint = filerobot.opts.adminApiEndpoint;
384
+ this._shareEndpoint = filerobot.opts.shareApiEndpoint;
385
+ this._i18n = filerobot.i18n;
386
+ this._defaultOffset = 0; // almost shouldn't be used as offset should be provided.
387
+ this._defaultLimit = 100;
388
+ this.xhrs = {};
389
+ });
390
+ export default Client;