@putkoff/abstract-utilities 0.1.0 → 0.1.101

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.
@@ -1,4 +1,3 @@
1
- export * from './config';
2
1
  export * from './file_utils';
3
2
  export * from './functions';
4
3
  export * from './hooks';
package/dist/cjs/index.js CHANGED
@@ -48,18 +48,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
48
48
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
49
49
  };
50
50
 
51
- exports.AppConfig = void 0;
52
- function loadConfig() {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const base = (process.env.PUBLIC_URL || "").replace(/\/+$/, "");
55
- const url = `${base}/config.json`;
56
- const res = yield fetch(url);
57
- if (!res.ok)
58
- throw new Error(`Failed to load ${url}: ${res.status}`);
59
- exports.AppConfig = yield res.json();
60
- });
61
- }
62
-
63
51
  /** Helper function to trigger file download */
64
52
  function triggerDownload(blob, filename) {
65
53
  const url = URL.createObjectURL(blob);
@@ -1188,15 +1176,22 @@ function requestPatch(url_1) {
1188
1176
  // Performs PATCH request for file sharing
1189
1177
  function fetchSharePatch(file) {
1190
1178
  return __awaiter(this, void 0, void 0, function* () {
1191
- const url = getAppConfig('/files/share');
1179
+ const cleanEndpoint = '/files/share';
1180
+ const baseUrl = getAppConfig(cleanEndpoint);
1181
+ const baseSlices = baseUrl.split("/").filter(Boolean);
1182
+ // build final URL
1183
+ const url = ensureAbstractUrl(cleanEndpoint, baseSlices);
1192
1184
  const token = localStorage.getItem('token');
1185
+ const body = JSON.stringify(file);
1186
+ const method = 'PATCH';
1187
+ const headers = {
1188
+ 'Content-Type': 'application/json',
1189
+ 'Authorization': `Bearer ${token}`,
1190
+ };
1193
1191
  const resp = yield fetch(url, {
1194
- method: 'PATCH',
1195
- headers: {
1196
- 'Content-Type': 'application/json',
1197
- 'Authorization': `Bearer ${token}`,
1198
- },
1199
- body: JSON.stringify(file),
1192
+ method,
1193
+ headers,
1194
+ body
1200
1195
  });
1201
1196
  if (!resp.ok) {
1202
1197
  console.error('Error from server', yield resp.text());
@@ -1765,7 +1760,6 @@ exports.initSelectAll = initSelectAll;
1765
1760
  exports.isLoggedIn = isLoggedIn;
1766
1761
  exports.isTokenExpired = isTokenExpired;
1767
1762
  exports.listFiles = listFiles;
1768
- exports.loadConfig = loadConfig;
1769
1763
  exports.make_path = make_path;
1770
1764
  exports.make_sanitized_path = make_sanitized_path;
1771
1765
  exports.normalizeUrl = normalizeUrl;