@putkoff/abstract-utilities 0.1.194 → 0.1.197
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/index.js +113 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +105 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +268 -0
- package/dist/{functions → types/functions}/index.d.ts +1 -0
- package/dist/{functions → types/functions}/path_utils/src/path_utils.d.ts +8 -1
- package/dist/types/functions/type_utils/src/type_utils.d.ts +8 -0
- package/dist/types/functions/variable_utils/imports.d.ts +1 -0
- package/dist/types/functions/variable_utils/src/index.d.ts +1 -0
- package/dist/types/functions/variable_utils/src/variable_utils.d.ts +15 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +4 -3
- package/dist/functions/type_utils/src/type_utils.d.ts +0 -1
- /package/dist/{functions → types/functions}/auth_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/auth_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/auth_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/auth_utils/src/token_utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/config_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/config_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/config_utils/src/config_utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/config_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/constants_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/constants_utils/src/constants.d.ts +0 -0
- /package/dist/{functions → types/functions}/constants_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/env_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/env_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/env_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/env_utils/src/window_utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/fetch_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/fetch_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/fetch_utils/src/fetch_utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/fetch_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/fetch_utils/src/utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/base_dirs.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/function_dirs.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/misc_dirs.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/paths.d.ts +0 -0
- /package/dist/{functions → types/functions}/path_utils/src/src_dirs.d.ts +0 -0
- /package/dist/{functions → types/functions}/read_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/read_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/read_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/read_utils/src/utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/rndm_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/rndm_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/rndm_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/rndm_utils/src/utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/src/safe_document.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/src/safe_globals.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/src/safe_storage.d.ts +0 -0
- /package/dist/{functions → types/functions}/safe_utils/src/safe_window.d.ts +0 -0
- /package/dist/{functions → types/functions}/string_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/string_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/string_utils/src/string_utils.d.ts +0 -0
- /package/dist/{functions → types/functions}/type_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/type_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/type_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/imports.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/src/button.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/src/checkbox.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/src/index.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/src/input.d.ts +0 -0
- /package/dist/{functions → types/functions}/ui_utils/src/spinner.d.ts +0 -0
- /package/dist/{utils → types/functions/variable_utils}/index.d.ts +0 -0
- /package/dist/types/{src → types/src}/ChangePassword.d.ts +0 -0
- /package/dist/types/{src → types/src}/Files.d.ts +0 -0
- /package/dist/types/{src → types/src}/index.d.ts +0 -0
- /package/dist/types/{src → types/src}/login.d.ts +0 -0
- /package/dist/types/{src → types/src}/logout.d.ts +0 -0
- /package/dist/types/{src → types/src}/utils.d.ts +0 -0
- /package/dist/{utils → types/utils}/imports.d.ts +0 -0
- /package/dist/{utils → types/utils}/src/Input.d.ts +0 -0
- /package/dist/{utils → types/utils}/src/config.d.ts +0 -0
- /package/dist/{utils → types/utils}/src/index.d.ts +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1188,6 +1188,57 @@ function ensure_list(obj) {
|
|
|
1188
1188
|
const objArray = Array.isArray(obj) ? obj : [obj];
|
|
1189
1189
|
return objArray;
|
|
1190
1190
|
}
|
|
1191
|
+
function assureString(obj) {
|
|
1192
|
+
return String(obj);
|
|
1193
|
+
}
|
|
1194
|
+
function cleanArray(obj) {
|
|
1195
|
+
obj = assureArray(obj);
|
|
1196
|
+
return Array.from(new Set(obj));
|
|
1197
|
+
}
|
|
1198
|
+
function assureArray(input) {
|
|
1199
|
+
if (typeof input === 'string') {
|
|
1200
|
+
return [input];
|
|
1201
|
+
}
|
|
1202
|
+
if (Array.isArray(input)) {
|
|
1203
|
+
return input.map(item => assureString(item));
|
|
1204
|
+
}
|
|
1205
|
+
return [];
|
|
1206
|
+
}
|
|
1207
|
+
// Constrain T so 'in obj' is allowed
|
|
1208
|
+
function get_key_value(obj, key) {
|
|
1209
|
+
// we cast to any for the indexing, since TS can’t infer arbitrary string keys
|
|
1210
|
+
if (key in obj && obj[key] != null) {
|
|
1211
|
+
return obj[key];
|
|
1212
|
+
}
|
|
1213
|
+
return null;
|
|
1214
|
+
}
|
|
1215
|
+
function get(obj, keys, defaultValue = null) {
|
|
1216
|
+
const keyArray = assureArray(keys);
|
|
1217
|
+
if (!obj || keyArray.length === 0) {
|
|
1218
|
+
return defaultValue;
|
|
1219
|
+
}
|
|
1220
|
+
for (const key of keyArray) {
|
|
1221
|
+
const val = get_key_value(obj, key);
|
|
1222
|
+
if (val != null) {
|
|
1223
|
+
return val;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return defaultValue;
|
|
1227
|
+
}
|
|
1228
|
+
function cleanText(input) {
|
|
1229
|
+
// Replace delimiters with spaces and split
|
|
1230
|
+
const str = assureString(input);
|
|
1231
|
+
const words = str.replace(/[_.-]/g, ' '); // Replace _, -, . with space
|
|
1232
|
+
return words;
|
|
1233
|
+
}
|
|
1234
|
+
function getCleanArray(obj) {
|
|
1235
|
+
obj = obj.split(/\s+/) // Split on any whitespace
|
|
1236
|
+
.filter((item) => typeof item === 'string' && item !== '');
|
|
1237
|
+
// Get basename
|
|
1238
|
+
// Remove duplicates using Set
|
|
1239
|
+
const uniqueWords = cleanArray(obj);
|
|
1240
|
+
return uniqueWords;
|
|
1241
|
+
}
|
|
1191
1242
|
|
|
1192
1243
|
/**
|
|
1193
1244
|
* In the browser we already have a WHATWG URL constructor on window.
|
|
@@ -1239,21 +1290,33 @@ function get_splitext(filePath) {
|
|
|
1239
1290
|
const filename = pathBrowserify.basename(filePath, ext);
|
|
1240
1291
|
return { filename, ext };
|
|
1241
1292
|
}
|
|
1242
|
-
|
|
1243
|
-
|
|
1293
|
+
/**
|
|
1294
|
+
* Join multiple path segments, normalizing leading/trailing slashes.
|
|
1295
|
+
*
|
|
1296
|
+
* Usage:
|
|
1297
|
+
* make_path('/foo','bar','baz')
|
|
1298
|
+
* make_path(['/foo','bar','baz'])
|
|
1299
|
+
*/
|
|
1300
|
+
function make_path(...paths) {
|
|
1301
|
+
// If someone passed a single array, unwrap it:
|
|
1302
|
+
const pathArray = (paths.length === 1 && Array.isArray(paths[0])
|
|
1303
|
+
? paths[0]
|
|
1304
|
+
: paths);
|
|
1244
1305
|
let real_path = '';
|
|
1245
|
-
for (let i = 0; i <
|
|
1246
|
-
let segment =
|
|
1306
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
1307
|
+
let segment = pathArray[i];
|
|
1247
1308
|
if (i === 0) {
|
|
1248
1309
|
real_path = segment;
|
|
1249
1310
|
}
|
|
1250
1311
|
else {
|
|
1251
|
-
|
|
1252
|
-
|
|
1312
|
+
// remove any leading slash on this segment
|
|
1313
|
+
segment = segment.replace(/^\/+/, '');
|
|
1314
|
+
// remove any trailing slash on the accumulator
|
|
1315
|
+
real_path = real_path.replace(/\/+$/, '');
|
|
1253
1316
|
real_path = `${real_path}/${segment}`;
|
|
1254
1317
|
}
|
|
1255
1318
|
}
|
|
1256
|
-
return real_path
|
|
1319
|
+
return real_path;
|
|
1257
1320
|
}
|
|
1258
1321
|
function sanitizeFilename(filename) {
|
|
1259
1322
|
return filename
|
|
@@ -1492,5 +1555,39 @@ function getConfig(key) {
|
|
|
1492
1555
|
});
|
|
1493
1556
|
}
|
|
1494
1557
|
|
|
1495
|
-
|
|
1558
|
+
/**
|
|
1559
|
+
* Processes keywords by checking if keywords is a string and splitting it.
|
|
1560
|
+
* Then cleans each keyword using `eatAll` with a set of characters to remove.
|
|
1561
|
+
*
|
|
1562
|
+
* @param keywords - The keywords as a comma-separated string or as an array.
|
|
1563
|
+
* @returns An array of cleaned keywords.
|
|
1564
|
+
*/
|
|
1565
|
+
function processKeywords(keywords) {
|
|
1566
|
+
let keywordArray;
|
|
1567
|
+
// If keywords is a string, split it on commas
|
|
1568
|
+
if (typeof keywords === "string") {
|
|
1569
|
+
keywordArray = keywords.split(",");
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
keywordArray = keywords;
|
|
1573
|
+
}
|
|
1574
|
+
// Clean each keyword by removing unwanted characters
|
|
1575
|
+
return keywordArray.map(keyword => eatAll(keyword, [",", "\n", "\t", " ", "#"]));
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Constructs a keyword string where each keyword is prefixed with a hash (#).
|
|
1579
|
+
*
|
|
1580
|
+
* @param keywords - An array of keywords.
|
|
1581
|
+
* @returns A string with each keyword prefixed by '#'.
|
|
1582
|
+
*/
|
|
1583
|
+
function get_keyword_string(keywords) {
|
|
1584
|
+
keywords = processKeywords(keywords);
|
|
1585
|
+
let allString = "";
|
|
1586
|
+
for (const keyword of keywords) {
|
|
1587
|
+
allString += ` #${keyword}`;
|
|
1588
|
+
}
|
|
1589
|
+
return allString;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, assureArray, assureString, callStorage, callWindowMethod, checkResponse, cleanArray, cleanText, create_list_string, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getBody, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToken, getWindowHost, getWindowProp, get_basename, get_dirname, get_extname, get_filename, get_key_value, get_keyword_string, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, loadConfig, make_path, make_sanitized_path, normalizeUrl, parseResult, processKeywords, readJsonFile, requireToken, safeGlobalProp, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse };
|
|
1496
1593
|
//# sourceMappingURL=index.js.map
|