@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/cjs/functions/config_utils/src/config_utils.d.ts +1 -0
- package/dist/cjs/functions/fetch_utils/imports.d.ts +2 -2
- package/dist/cjs/functions/fetch_utils/src/fetchIt_utils.d.ts +4 -10
- package/dist/cjs/index.js +30 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/utils.d.ts +2 -1
- package/dist/esm/functions/config_utils/src/config_utils.d.ts +1 -0
- package/dist/esm/functions/fetch_utils/imports.d.ts +2 -2
- package/dist/esm/functions/fetch_utils/src/fetchIt_utils.d.ts +4 -10
- package/dist/esm/index.js +30 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/utils.d.ts +2 -1
- package/dist/functions/config_utils/src/config_utils.d.ts +1 -0
- package/dist/functions/fetch_utils/imports.d.ts +2 -2
- package/dist/functions/fetch_utils/src/fetchIt_utils.d.ts +4 -10
- package/dist/index.d.ts +24 -27
- package/dist/types/src/utils.d.ts +2 -1
- package/package.json +1 -1
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
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
function
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1172
|
-
const
|
|
1173
|
-
|
|
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
|