@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.
Files changed (83) hide show
  1. package/dist/cjs/index.js +113 -7
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/index.js +105 -8
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.ts +268 -0
  6. package/dist/{functions → types/functions}/index.d.ts +1 -0
  7. package/dist/{functions → types/functions}/path_utils/src/path_utils.d.ts +8 -1
  8. package/dist/types/functions/type_utils/src/type_utils.d.ts +8 -0
  9. package/dist/types/functions/variable_utils/imports.d.ts +1 -0
  10. package/dist/types/functions/variable_utils/src/index.d.ts +1 -0
  11. package/dist/types/functions/variable_utils/src/variable_utils.d.ts +15 -0
  12. package/dist/types/index.d.ts +2 -1
  13. package/dist/types/types/index.d.ts +1 -0
  14. package/dist/types/utils/index.d.ts +1 -0
  15. package/package.json +4 -3
  16. package/dist/functions/type_utils/src/type_utils.d.ts +0 -1
  17. /package/dist/{functions → types/functions}/auth_utils/imports.d.ts +0 -0
  18. /package/dist/{functions → types/functions}/auth_utils/index.d.ts +0 -0
  19. /package/dist/{functions → types/functions}/auth_utils/src/index.d.ts +0 -0
  20. /package/dist/{functions → types/functions}/auth_utils/src/token_utils.d.ts +0 -0
  21. /package/dist/{functions → types/functions}/config_utils/imports.d.ts +0 -0
  22. /package/dist/{functions → types/functions}/config_utils/index.d.ts +0 -0
  23. /package/dist/{functions → types/functions}/config_utils/src/config_utils.d.ts +0 -0
  24. /package/dist/{functions → types/functions}/config_utils/src/index.d.ts +0 -0
  25. /package/dist/{functions → types/functions}/constants_utils/index.d.ts +0 -0
  26. /package/dist/{functions → types/functions}/constants_utils/src/constants.d.ts +0 -0
  27. /package/dist/{functions → types/functions}/constants_utils/src/index.d.ts +0 -0
  28. /package/dist/{functions → types/functions}/env_utils/imports.d.ts +0 -0
  29. /package/dist/{functions → types/functions}/env_utils/index.d.ts +0 -0
  30. /package/dist/{functions → types/functions}/env_utils/src/index.d.ts +0 -0
  31. /package/dist/{functions → types/functions}/env_utils/src/window_utils.d.ts +0 -0
  32. /package/dist/{functions → types/functions}/fetch_utils/imports.d.ts +0 -0
  33. /package/dist/{functions → types/functions}/fetch_utils/index.d.ts +0 -0
  34. /package/dist/{functions → types/functions}/fetch_utils/src/fetch_utils.d.ts +0 -0
  35. /package/dist/{functions → types/functions}/fetch_utils/src/index.d.ts +0 -0
  36. /package/dist/{functions → types/functions}/fetch_utils/src/utils.d.ts +0 -0
  37. /package/dist/{functions → types/functions}/path_utils/imports.d.ts +0 -0
  38. /package/dist/{functions → types/functions}/path_utils/index.d.ts +0 -0
  39. /package/dist/{functions → types/functions}/path_utils/src/base_dirs.d.ts +0 -0
  40. /package/dist/{functions → types/functions}/path_utils/src/function_dirs.d.ts +0 -0
  41. /package/dist/{functions → types/functions}/path_utils/src/index.d.ts +0 -0
  42. /package/dist/{functions → types/functions}/path_utils/src/misc_dirs.d.ts +0 -0
  43. /package/dist/{functions → types/functions}/path_utils/src/paths.d.ts +0 -0
  44. /package/dist/{functions → types/functions}/path_utils/src/src_dirs.d.ts +0 -0
  45. /package/dist/{functions → types/functions}/read_utils/imports.d.ts +0 -0
  46. /package/dist/{functions → types/functions}/read_utils/index.d.ts +0 -0
  47. /package/dist/{functions → types/functions}/read_utils/src/index.d.ts +0 -0
  48. /package/dist/{functions → types/functions}/read_utils/src/utils.d.ts +0 -0
  49. /package/dist/{functions → types/functions}/rndm_utils/imports.d.ts +0 -0
  50. /package/dist/{functions → types/functions}/rndm_utils/index.d.ts +0 -0
  51. /package/dist/{functions → types/functions}/rndm_utils/src/index.d.ts +0 -0
  52. /package/dist/{functions → types/functions}/rndm_utils/src/utils.d.ts +0 -0
  53. /package/dist/{functions → types/functions}/safe_utils/imports.d.ts +0 -0
  54. /package/dist/{functions → types/functions}/safe_utils/index.d.ts +0 -0
  55. /package/dist/{functions → types/functions}/safe_utils/src/index.d.ts +0 -0
  56. /package/dist/{functions → types/functions}/safe_utils/src/safe_document.d.ts +0 -0
  57. /package/dist/{functions → types/functions}/safe_utils/src/safe_globals.d.ts +0 -0
  58. /package/dist/{functions → types/functions}/safe_utils/src/safe_storage.d.ts +0 -0
  59. /package/dist/{functions → types/functions}/safe_utils/src/safe_window.d.ts +0 -0
  60. /package/dist/{functions → types/functions}/string_utils/index.d.ts +0 -0
  61. /package/dist/{functions → types/functions}/string_utils/src/index.d.ts +0 -0
  62. /package/dist/{functions → types/functions}/string_utils/src/string_utils.d.ts +0 -0
  63. /package/dist/{functions → types/functions}/type_utils/imports.d.ts +0 -0
  64. /package/dist/{functions → types/functions}/type_utils/index.d.ts +0 -0
  65. /package/dist/{functions → types/functions}/type_utils/src/index.d.ts +0 -0
  66. /package/dist/{functions → types/functions}/ui_utils/imports.d.ts +0 -0
  67. /package/dist/{functions → types/functions}/ui_utils/index.d.ts +0 -0
  68. /package/dist/{functions → types/functions}/ui_utils/src/button.d.ts +0 -0
  69. /package/dist/{functions → types/functions}/ui_utils/src/checkbox.d.ts +0 -0
  70. /package/dist/{functions → types/functions}/ui_utils/src/index.d.ts +0 -0
  71. /package/dist/{functions → types/functions}/ui_utils/src/input.d.ts +0 -0
  72. /package/dist/{functions → types/functions}/ui_utils/src/spinner.d.ts +0 -0
  73. /package/dist/{utils → types/functions/variable_utils}/index.d.ts +0 -0
  74. /package/dist/types/{src → types/src}/ChangePassword.d.ts +0 -0
  75. /package/dist/types/{src → types/src}/Files.d.ts +0 -0
  76. /package/dist/types/{src → types/src}/index.d.ts +0 -0
  77. /package/dist/types/{src → types/src}/login.d.ts +0 -0
  78. /package/dist/types/{src → types/src}/logout.d.ts +0 -0
  79. /package/dist/types/{src → types/src}/utils.d.ts +0 -0
  80. /package/dist/{utils → types/utils}/imports.d.ts +0 -0
  81. /package/dist/{utils → types/utils}/src/Input.d.ts +0 -0
  82. /package/dist/{utils → types/utils}/src/config.d.ts +0 -0
  83. /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
- function make_path(...segments) {
1243
- const list = ensure_list(segments);
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 < list.length; i++) {
1246
- let segment = list[i]; // renamed, no shadowing
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
- segment = eatInner(segment, ['/']);
1252
- real_path = eatOuter(real_path, ['/']);
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
- export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, callStorage, callWindowMethod, checkResponse, 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, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getBody, 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_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, isLoggedIn, isTokenExpired, loadConfig, make_path, make_sanitized_path, normalizeUrl, parseResult, readJsonFile, requireToken, safeGlobalProp, safeStorage, sanitizeFilename, stripPrefixes, truncateString, tryParse };
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