@putkoff/abstract-utilities 0.1.127 → 0.1.129
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 +5 -11
- 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 +5 -11
- 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 +5 -11
- package/dist/index.d.ts +24 -27
- package/dist/types/src/utils.d.ts +2 -1
- package/package.json +1 -1
|
@@ -4,5 +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 type { LogoutButtonProps, FetchVariables,
|
|
8
|
-
export { getConfig } from './../config_utils';
|
|
7
|
+
export type { LogoutButtonProps, FetchVariables, UrlKey } from './../../types';
|
|
8
|
+
export { getConfig, loadConfig } from './../config_utils';
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import type { AppConfig } from './../imports';
|
|
2
1
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
11
|
-
export declare function get_app_config_url(endpoint: string, appKey?: keyof AppConfig): Promise<string>;
|
|
12
|
-
export declare function fetchIt(endpoint: string, body?: unknown, method?: string | null, headers?: Record<string, string> | null, blob?: boolean | null, no_api?: boolean, requireAuth?: boolean): Promise<unknown>;
|
|
2
|
+
* Given an “endpoint” slug like "api/list", build the full URL
|
|
3
|
+
* from the BASE_API_URL entry in your JSON config.
|
|
4
|
+
*/
|
|
5
|
+
export declare function get_app_config_url(endpoint: string): Promise<string>;
|
|
6
|
+
export declare function fetchIt(endpoint: string, body?: unknown, method?: string | null, headers?: Record<string, string> | null, blob?: boolean | null, no_api?: boolean, requireAuth?: boolean): Promise<any>;
|
|
13
7
|
export declare function secureFetchIt<T>(endpoint: any, body?: any, method?: any, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<T>;
|
|
14
8
|
export declare function secureFetchIt(endpoint: any, body?: any, method?: any, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<Blob>;
|
|
15
9
|
export declare function requestPatch(url: string, body?: unknown): Promise<Response>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1052,6 +1052,9 @@ function ensureAbstractUrl(endpoint, slices = []) {
|
|
|
1052
1052
|
`${window.location.host}/api` // etc, if you need it
|
|
1053
1053
|
];
|
|
1054
1054
|
const stripped = stripPrefixes(endpoint, normalized);
|
|
1055
|
+
console.log('BUILD PREFIX:', prefix);
|
|
1056
|
+
console.log('RAW ENDPOINT:', endpoint);
|
|
1057
|
+
console.log('STRIPPED ENDPT:', stripped);
|
|
1055
1058
|
return make_path(prefix, stripped);
|
|
1056
1059
|
}
|
|
1057
1060
|
/**
|
|
@@ -1156,24 +1159,32 @@ function getFetchVars(headers = null, method = null, body = null) {
|
|
|
1156
1159
|
}
|
|
1157
1160
|
|
|
1158
1161
|
/**
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
function
|
|
1170
|
-
|
|
1171
|
-
const
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
const
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1162
|
+
* Strip a leading host (http://host) from any URL-like string.
|
|
1163
|
+
*/
|
|
1164
|
+
function stripHost(str) {
|
|
1165
|
+
return str.replace(/^https?:\/\/[^/]+/, '');
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Given an “endpoint” slug like "api/list", build the full URL
|
|
1169
|
+
* from the BASE_API_URL entry in your JSON config.
|
|
1170
|
+
*/
|
|
1171
|
+
function get_app_config_url(endpoint) {
|
|
1172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1173
|
+
// 1) normalize your input
|
|
1174
|
+
const clean = stripHost(endpoint.trim().toLowerCase());
|
|
1175
|
+
const cfg = yield loadConfig();
|
|
1176
|
+
// 2) pick the key you expect in your JSON
|
|
1177
|
+
const appKey = (`BASE_API_URL`);
|
|
1178
|
+
const base = yield fetchIt('https://abtractendeavors.com/api/secure_env', { "key": 'BASE_API_URL', 'path': '/var/www/abstractendeavors/secure-files/public/config.json' }, 'POST');
|
|
1179
|
+
// 3) load your JSON (this returns an AppConfig)
|
|
1180
|
+
// 4) pull out the base for that key
|
|
1181
|
+
if (!base) {
|
|
1182
|
+
throw new Error(`Missing configuration key "${appKey}". ` +
|
|
1183
|
+
`Available: ${Object.keys(cfg).join(', ')}`);
|
|
1184
|
+
}
|
|
1185
|
+
// 5) build the final URL (this handles trailing/slashes)
|
|
1186
|
+
const normalizedBase = base.replace(/\/+$/, '') + '/';
|
|
1187
|
+
return new URL(clean, normalizedBase).toString();
|
|
1177
1188
|
});
|
|
1178
1189
|
}
|
|
1179
1190
|
function fetchIt(endpoint_1) {
|
|
@@ -1416,6 +1427,7 @@ exports.get_window_parts = get_window_parts;
|
|
|
1416
1427
|
exports.get_window_pathname = get_window_pathname;
|
|
1417
1428
|
exports.isLoggedIn = isLoggedIn;
|
|
1418
1429
|
exports.isTokenExpired = isTokenExpired;
|
|
1430
|
+
exports.loadConfig = loadConfig;
|
|
1419
1431
|
exports.make_path = make_path;
|
|
1420
1432
|
exports.make_sanitized_path = make_sanitized_path;
|
|
1421
1433
|
exports.normalizeUrl = normalizeUrl;
|