@putkoff/abstract-utilities 0.1.127 → 0.1.128

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/dist/esm/index.js CHANGED
@@ -1049,6 +1049,9 @@ function ensureAbstractUrl(endpoint, slices = []) {
1049
1049
  `${window.location.host}/api` // etc, if you need it
1050
1050
  ];
1051
1051
  const stripped = stripPrefixes(endpoint, normalized);
1052
+ console.log('BUILD PREFIX:', prefix);
1053
+ console.log('RAW ENDPOINT:', endpoint);
1054
+ console.log('STRIPPED ENDPT:', stripped);
1052
1055
  return make_path(prefix, stripped);
1053
1056
  }
1054
1057
  /**
@@ -1153,24 +1156,32 @@ function getFetchVars(headers = null, method = null, body = null) {
1153
1156
  }
1154
1157
 
1155
1158
  /**
1156
-
1157
- ***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
1158
- *
1159
- *4. **secureFetchIt** (`src/functions/fetch/secureFetchIt.ts`):
1160
- * Since `secureFetchIt` isn’t provided, we’ll create a minimal implementation based on its usage in `Login` and `uploadFiles`. It’s assumed to be a wrapper around `fetch` that handles authentication and JSON parsing.
1161
- *
1162
- */
1163
- /** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
1164
- // src/functions/fetch/secureFetchIt.ts
1165
- // --- fetch_utils/src/fetch_utils.ts ----------------------------
1166
- function get_app_config_url(endpoint_1) {
1167
- return __awaiter(this, arguments, void 0, function* (endpoint, appKey = 'BASE_API_URL') {
1168
- const cleanEndpoint = endpoint.replace(/^\/+/, '');
1169
- const config = yield getConfig(appKey);
1170
- appKey = appKey || 'BASE_API_URL';
1171
- const base = config[appKey]; // full AppConfig object
1172
- const slices = base.split('/').filter(Boolean);
1173
- return ensureAbstractUrl(cleanEndpoint, slices);
1159
+ * Strip a leading host (http://host) from any URL-like string.
1160
+ */
1161
+ function stripHost(str) {
1162
+ return str.replace(/^https?:\/\/[^/]+/, '');
1163
+ }
1164
+ /**
1165
+ * Given an “endpoint” slug like "api/list", build the full URL
1166
+ * from the BASE_API_URL entry in your JSON config.
1167
+ */
1168
+ function get_app_config_url(endpoint) {
1169
+ return __awaiter(this, void 0, void 0, function* () {
1170
+ // 1) normalize your input
1171
+ const clean = stripHost(endpoint.trim().toLowerCase());
1172
+ const cfg = yield loadConfig();
1173
+ // 2) pick the key you expect in your JSON
1174
+ const appKey = (`BASE_API_URL`);
1175
+ const base = cfg[appKey]; // TS now infers `base: AppConfig[UrlKey]`
1176
+ // 3) load your JSON (this returns an AppConfig)
1177
+ // 4) pull out the base for that key
1178
+ if (!base) {
1179
+ throw new Error(`Missing configuration key "${appKey}". ` +
1180
+ `Available: ${Object.keys(cfg).join(', ')}`);
1181
+ }
1182
+ // 5) build the final URL (this handles trailing/slashes)
1183
+ const normalizedBase = base.replace(/\/+$/, '') + '/';
1184
+ return new URL(clean, normalizedBase).toString();
1174
1185
  });
1175
1186
  }
1176
1187
  function fetchIt(endpoint_1) {
@@ -1333,5 +1344,5 @@ function readJsonFile(relativeOrAbsolutePath) {
1333
1344
  });
1334
1345
  }
1335
1346
 
1336
- export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getConfig, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, get_app_config_url, get_basename, get_dirname, get_extname, get_filename, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, make_path, make_sanitized_path, normalizeUrl, readFileContents, readJsonFile, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, truncateString };
1347
+ export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getConfig, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, get_app_config_url, get_basename, get_dirname, get_extname, get_filename, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, loadConfig, make_path, make_sanitized_path, normalizeUrl, readFileContents, readJsonFile, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, truncateString };
1337
1348
  //# sourceMappingURL=index.js.map