@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/esm/index.js CHANGED
@@ -45,18 +45,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
45
45
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
46
46
  };
47
47
 
48
- let AppConfig;
49
- function loadConfig() {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const base = (process.env.PUBLIC_URL || "").replace(/\/+$/, "");
52
- const url = `${base}/config.json`;
53
- const res = yield fetch(url);
54
- if (!res.ok)
55
- throw new Error(`Failed to load ${url}: ${res.status}`);
56
- AppConfig = yield res.json();
57
- });
58
- }
59
-
60
48
  /** Helper function to trigger file download */
61
49
  function triggerDownload(blob, filename) {
62
50
  const url = URL.createObjectURL(blob);
@@ -1185,15 +1173,22 @@ function requestPatch(url_1) {
1185
1173
  // Performs PATCH request for file sharing
1186
1174
  function fetchSharePatch(file) {
1187
1175
  return __awaiter(this, void 0, void 0, function* () {
1188
- const url = getAppConfig('/files/share');
1176
+ const cleanEndpoint = '/files/share';
1177
+ const baseUrl = getAppConfig(cleanEndpoint);
1178
+ const baseSlices = baseUrl.split("/").filter(Boolean);
1179
+ // build final URL
1180
+ const url = ensureAbstractUrl(cleanEndpoint, baseSlices);
1189
1181
  const token = localStorage.getItem('token');
1182
+ const body = JSON.stringify(file);
1183
+ const method = 'PATCH';
1184
+ const headers = {
1185
+ 'Content-Type': 'application/json',
1186
+ 'Authorization': `Bearer ${token}`,
1187
+ };
1190
1188
  const resp = yield fetch(url, {
1191
- method: 'PATCH',
1192
- headers: {
1193
- 'Content-Type': 'application/json',
1194
- 'Authorization': `Bearer ${token}`,
1195
- },
1196
- body: JSON.stringify(file),
1189
+ method,
1190
+ headers,
1191
+ body
1197
1192
  });
1198
1193
  if (!resp.ok) {
1199
1194
  console.error('Error from server', yield resp.text());
@@ -1692,5 +1687,5 @@ function useFiles() {
1692
1687
  };
1693
1688
  }
1694
1689
 
1695
- export { API_PREFIX, AppConfig, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, directDownload, downloadFile, downloadRow, downloadSelect, downloadSelected, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToggleShare, getToken, get_basename, get_dirname, get_extname, get_filename, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, initSelectAll, isLoggedIn, isTokenExpired, listFiles, loadConfig, make_path, make_sanitized_path, normalizeUrl, patchFileSetting, removeFile, removeRow, removeSelected, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, syncHeaderCheckbox, toggleCheckboxes, toggleShare, triggerDownload, truncateString, updateFileShare, uploadFile, uploadFiles, useDeleteFile, useFiles, useLoadFiles, usePatchShareSettings, useToggleShare };
1690
+ export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, directDownload, downloadFile, downloadRow, downloadSelect, downloadSelected, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToggleShare, getToken, get_basename, get_dirname, get_extname, get_filename, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, initSelectAll, isLoggedIn, isTokenExpired, listFiles, make_path, make_sanitized_path, normalizeUrl, patchFileSetting, removeFile, removeRow, removeSelected, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, syncHeaderCheckbox, toggleCheckboxes, toggleShare, triggerDownload, truncateString, updateFileShare, uploadFile, uploadFiles, useDeleteFile, useFiles, useLoadFiles, usePatchShareSettings, useToggleShare };
1696
1691
  //# sourceMappingURL=index.js.map