@putkoff/abstract-utilities 0.0.7 → 0.1.1

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 (35) hide show
  1. package/dist/cjs/functions/fetch_utils/imports.d.ts +1 -0
  2. package/dist/cjs/functions/fetch_utils/index.d.ts +1 -1
  3. package/dist/cjs/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
  4. package/dist/cjs/functions/fetch_utils/src/index.d.ts +1 -1
  5. package/dist/cjs/index.d.ts +0 -1
  6. package/dist/cjs/index.js +14 -23
  7. package/dist/cjs/index.js.map +1 -1
  8. package/dist/cjs/utils/imports.d.ts +1 -0
  9. package/dist/cjs/utils/index.d.ts +1 -0
  10. package/dist/cjs/utils/src/Input.d.ts +13 -0
  11. package/dist/cjs/utils/src/config.d.ts +5 -0
  12. package/dist/cjs/utils/src/index.d.ts +2 -0
  13. package/dist/esm/functions/fetch_utils/imports.d.ts +1 -0
  14. package/dist/esm/functions/fetch_utils/index.d.ts +1 -1
  15. package/dist/esm/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
  16. package/dist/esm/functions/fetch_utils/src/index.d.ts +1 -1
  17. package/dist/esm/index.d.ts +0 -1
  18. package/dist/esm/index.js +15 -23
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/utils/imports.d.ts +1 -0
  21. package/dist/esm/utils/index.d.ts +1 -0
  22. package/dist/esm/utils/src/Input.d.ts +13 -0
  23. package/dist/esm/utils/src/config.d.ts +5 -0
  24. package/dist/esm/utils/src/index.d.ts +2 -0
  25. package/dist/functions/fetch_utils/imports.d.ts +1 -0
  26. package/dist/functions/fetch_utils/index.d.ts +1 -1
  27. package/dist/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
  28. package/dist/functions/fetch_utils/src/index.d.ts +1 -1
  29. package/dist/index.d.ts +1 -7
  30. package/dist/utils/imports.d.ts +1 -0
  31. package/dist/utils/index.d.ts +1 -0
  32. package/dist/utils/src/Input.d.ts +13 -0
  33. package/dist/utils/src/config.d.ts +5 -0
  34. package/dist/utils/src/index.d.ts +2 -0
  35. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export type { InputProps } from "./../types";
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,13 @@
1
+ /**
2
+
3
+ ***Changes**:
4
+ *- Updated import paths to match the library structure (`../utils`, `../functions/fetch`, `../functions/auth`).
5
+ *- Added `getAuthorizationHeader` import to support token-based authentication.
6
+ *- Adjusted the `secureFetchIt` call to expect a response with `{ result: { token: string }; success: boolean }`, matching the `api.ts` expectation.
7
+ *
8
+ *2. **Input Component** (`src/utils/Input.tsx`):
9
+ * Copy from `/var/www/abstractendeavors/my-login-app/src/components/utils/src/Inputs.tsx`.
10
+ *
11
+ */
12
+ import type { InputProps } from "./../imports";
13
+ export declare const Input: React.FC<InputProps>;
@@ -0,0 +1,5 @@
1
+ export interface AppConfig {
2
+ API_BASE_URL: string;
3
+ }
4
+ export declare let AppConfig: AppConfig;
5
+ export declare function loadConfig(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export * from "./Input";
2
+ export { loadConfig } from './config';
@@ -4,4 +4,5 @@ export { stripPrefixes } from './../string_utils';
4
4
  export { alertit } from './../rndm_utils';
5
5
  export { ensure_list } from './../type_utils';
6
6
  export { eatInner } from './../string_utils';
7
+ export { AppConfig } from './../../utils/src/config';
7
8
  export type { LogoutButtonProps, FetchVariables } from './../../types';
@@ -1 +1 @@
1
- export * from './fetchIt_utils';
1
+ export * from './src';
@@ -0,0 +1 @@
1
+ export declare function getAppConfig(endpoint: string): string;
@@ -1 +1 @@
1
- export * from './utils';
1
+ export * from './fetchIt_utils';
@@ -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);
@@ -1018,13 +1006,6 @@ function ensureAbstractUrl(endpoint, slices = []) {
1018
1006
  // 5) hand it back to make_path to join “target” + “strippedEndpoint”
1019
1007
  return make_path(target, strippedEndpoint);
1020
1008
  }
1021
- /** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
1022
- function getRawConfigUrl() {
1023
- var _a;
1024
- // Now AppConfig[key] is allowed because of the index signature
1025
- const rawBase = (_a = AppConfig.API_BASE_URL) !== null && _a !== void 0 ? _a : "";
1026
- return rawBase.replace(/\/+$/, "");
1027
- }
1028
1009
  // Constructs API URL from endpoint
1029
1010
  function api(endpoint) {
1030
1011
  return ensureAbstractUrl(endpoint);
@@ -1114,6 +1095,18 @@ function getFetchVars(headers = null, method = null, body = null) {
1114
1095
  return { method, headers, body };
1115
1096
  }
1116
1097
 
1098
+ function getAppConfig(endpoint) {
1099
+ var _a;
1100
+ const rawBase = (_a = void 0 ) !== null && _a !== void 0 ? _a : "";
1101
+ const base = rawBase.replace(/\/+$/, "");
1102
+ // strip any leading slashes on endpoint, then prefix “/api/”
1103
+ const cleanEndpoint = endpoint.replace(/^\/+/, "");
1104
+ const url = base
1105
+ ? `${base}/${cleanEndpoint}`
1106
+ : `/api/${cleanEndpoint}`;
1107
+ return url;
1108
+ }
1109
+
1117
1110
  /**
1118
1111
 
1119
1112
  ***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
@@ -1139,7 +1132,7 @@ function secureFetchIt(endpoint_1) {
1139
1132
  method = method || "GET";
1140
1133
  const cleanEndpoint = endpoint.replace(/^\/+/, "");
1141
1134
  // decide whether to build off your API_BASE_URL or not
1142
- const rawBase = getRawConfigUrl();
1135
+ const rawBase = getAppConfig(cleanEndpoint);
1143
1136
  const baseSlices = noApi
1144
1137
  ? []
1145
1138
  : rawBase.split("/").filter(Boolean);
@@ -1180,8 +1173,7 @@ function requestPatch(url_1) {
1180
1173
  // Performs PATCH request for file sharing
1181
1174
  function fetchSharePatch(file) {
1182
1175
  return __awaiter(this, void 0, void 0, function* () {
1183
- const base = getRawConfigUrl();
1184
- const url = `${base}/files/share`;
1176
+ const url = getAppConfig('/files/share');
1185
1177
  const token = localStorage.getItem('token');
1186
1178
  const resp = yield fetch(url, {
1187
1179
  method: 'PATCH',
@@ -1688,5 +1680,5 @@ function useFiles() {
1688
1680
  };
1689
1681
  }
1690
1682
 
1691
- 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 };
1683
+ 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 };
1692
1684
  //# sourceMappingURL=index.js.map