@putkoff/abstract-utilities 0.0.5 → 0.1.0
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/fetch_utils/imports.d.ts +1 -0
- package/dist/cjs/functions/fetch_utils/index.d.ts +1 -1
- package/dist/cjs/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
- package/dist/cjs/functions/fetch_utils/src/index.d.ts +1 -1
- package/dist/cjs/index.js +14 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/imports.d.ts +1 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/src/Input.d.ts +13 -0
- package/dist/cjs/utils/src/config.d.ts +5 -0
- package/dist/cjs/utils/src/index.d.ts +2 -0
- package/dist/esm/functions/fetch_utils/imports.d.ts +1 -0
- package/dist/esm/functions/fetch_utils/index.d.ts +1 -1
- package/dist/esm/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
- package/dist/esm/functions/fetch_utils/src/index.d.ts +1 -1
- package/dist/esm/index.js +14 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/imports.d.ts +1 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/src/Input.d.ts +13 -0
- package/dist/esm/utils/src/config.d.ts +5 -0
- package/dist/esm/utils/src/index.d.ts +2 -0
- package/dist/functions/fetch_utils/imports.d.ts +1 -0
- package/dist/functions/fetch_utils/index.d.ts +1 -1
- package/dist/functions/fetch_utils/src/getAppConfig.d.ts +1 -0
- package/dist/functions/fetch_utils/src/index.d.ts +1 -1
- package/dist/utils/imports.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/src/Input.d.ts +13 -0
- package/dist/utils/src/config.d.ts +5 -0
- package/dist/utils/src/index.d.ts +2 -0
- package/package.json +77 -1
|
@@ -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 './
|
|
1
|
+
export * from './src';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAppConfig(endpoint: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './fetchIt_utils';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1021,13 +1021,6 @@ function ensureAbstractUrl(endpoint, slices = []) {
|
|
|
1021
1021
|
// 5) hand it back to make_path to join “target” + “strippedEndpoint”
|
|
1022
1022
|
return make_path(target, strippedEndpoint);
|
|
1023
1023
|
}
|
|
1024
|
-
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
1025
|
-
function getRawConfigUrl() {
|
|
1026
|
-
var _a;
|
|
1027
|
-
// Now AppConfig[key] is allowed because of the index signature
|
|
1028
|
-
const rawBase = (_a = exports.AppConfig.API_BASE_URL) !== null && _a !== void 0 ? _a : "";
|
|
1029
|
-
return rawBase.replace(/\/+$/, "");
|
|
1030
|
-
}
|
|
1031
1024
|
// Constructs API URL from endpoint
|
|
1032
1025
|
function api(endpoint) {
|
|
1033
1026
|
return ensureAbstractUrl(endpoint);
|
|
@@ -1117,6 +1110,18 @@ function getFetchVars(headers = null, method = null, body = null) {
|
|
|
1117
1110
|
return { method, headers, body };
|
|
1118
1111
|
}
|
|
1119
1112
|
|
|
1113
|
+
function getAppConfig(endpoint) {
|
|
1114
|
+
var _a;
|
|
1115
|
+
const rawBase = (_a = void 0 ) !== null && _a !== void 0 ? _a : "";
|
|
1116
|
+
const base = rawBase.replace(/\/+$/, "");
|
|
1117
|
+
// strip any leading slashes on endpoint, then prefix “/api/”
|
|
1118
|
+
const cleanEndpoint = endpoint.replace(/^\/+/, "");
|
|
1119
|
+
const url = base
|
|
1120
|
+
? `${base}/${cleanEndpoint}`
|
|
1121
|
+
: `/api/${cleanEndpoint}`;
|
|
1122
|
+
return url;
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1120
1125
|
/**
|
|
1121
1126
|
|
|
1122
1127
|
***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
|
|
@@ -1142,7 +1147,7 @@ function secureFetchIt(endpoint_1) {
|
|
|
1142
1147
|
method = method || "GET";
|
|
1143
1148
|
const cleanEndpoint = endpoint.replace(/^\/+/, "");
|
|
1144
1149
|
// decide whether to build off your API_BASE_URL or not
|
|
1145
|
-
const rawBase =
|
|
1150
|
+
const rawBase = getAppConfig(cleanEndpoint);
|
|
1146
1151
|
const baseSlices = noApi
|
|
1147
1152
|
? []
|
|
1148
1153
|
: rawBase.split("/").filter(Boolean);
|
|
@@ -1183,8 +1188,7 @@ function requestPatch(url_1) {
|
|
|
1183
1188
|
// Performs PATCH request for file sharing
|
|
1184
1189
|
function fetchSharePatch(file) {
|
|
1185
1190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1186
|
-
const
|
|
1187
|
-
const url = `${base}/files/share`;
|
|
1191
|
+
const url = getAppConfig('/files/share');
|
|
1188
1192
|
const token = localStorage.getItem('token');
|
|
1189
1193
|
const resp = yield fetch(url, {
|
|
1190
1194
|
method: 'PATCH',
|