@putkoff/abstract-utilities 0.1.156 → 0.1.158

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/index.d.ts CHANGED
@@ -151,7 +151,7 @@ declare function get_window_parts(): Location | "https://abstractendeavors.com"
151
151
  * from the BASE_API_URL entry in your JSON config.
152
152
  */
153
153
  declare function get_app_config_url(endpoint: string): Promise<any>;
154
- 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>;
154
+ declare function fetchIt(endpoint: any, body?: any, method?: any, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<any>;
155
155
  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>;
156
156
  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>;
157
157
  declare function requestPatch(url: string, body?: unknown): Promise<Response>;
@@ -211,6 +211,8 @@ declare function getSchemasDirPath(subPath: string): string;
211
211
 
212
212
  declare function alertit(obj?: any): void;
213
213
 
214
+ declare function ensure_list<T>(obj: T | T[]): T[];
215
+
214
216
  declare function getSubstring(obj: string, maxLength?: number | null, minLength?: number | null): string;
215
217
  declare function truncateString(obj: string, maxLength?: number): string;
216
218
  declare function stripPrefixes(str: string, bases?: string | string[]): string;
@@ -243,7 +245,37 @@ declare function eatOuter(str: string, listObjects: string | string[]): string;
243
245
  declare function eatAll(str: string, listObjects: string | string[]): string;
244
246
  declare function eatEnd(obj: string, endings?: string[]): string;
245
247
 
246
- declare function ensure_list<T>(obj: T | T[]): T[];
248
+ declare function loadConfig(filePath?: string | null): Promise<AppConfig>;
249
+ /**
250
+ * getConfig(): load the full AppConfig
251
+ * getConfig(key): load just that key
252
+ */
253
+ declare function getConfig(): Promise<AppConfig>;
254
+ declare function getConfig<K extends keyof AppConfig>(key: K): Promise<AppConfig[K]>;
255
+
256
+ declare function ensureAbstractUrl(endpoint: string, slices?: string[]): string;
257
+ /**
258
+ * Unwraps nested { result } fields until you hit a non-object or no more "result" keys.
259
+ */
260
+ declare function getResult<T>(obj: unknown): T;
261
+ declare function api(endpoint: string): string;
262
+ /**
263
+ * Intercept 401/403 and force a clean redirect to login
264
+ * without ever showing an alert.
265
+ */
266
+ declare function checkResponse(res: Response): Response;
267
+ /**
268
+ * parseResult no longer needs to worry about JSON vs HTML redirect errors;
269
+ * all 401/403 have already been handled above.
270
+ */
271
+ declare function parseResult(res: Response): Promise<unknown>;
272
+ declare function getMethod(method?: string | null, body?: unknown): string;
273
+ declare function getHeaders(headers?: Record<string, string>, method?: string | null, body?: unknown): Record<string, string>;
274
+ declare function getBody(body?: unknown, method?: string | null): string | undefined;
275
+ declare function getFetchVars(headers?: Record<string, string> | null, method?: string | null, body?: any): FetchVariables;
276
+ declare function getHtmlDirectory(directory: string, filename: string): string;
277
+ declare function fetchIndexHtml(filename: string, directory?: string, base?: string): Promise<string>;
278
+ declare function fetchIndexHtmlContainer(filename: string, doc?: Document, directory?: string): Promise<void>;
247
279
 
248
280
  declare function Button({ children, color, variant, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
249
281
  color?: 'gray' | 'green' | 'blue';
@@ -262,14 +294,6 @@ declare function Input({ label, trailing, ...rest }: React$1.InputHTMLAttributes
262
294
 
263
295
  declare function Spinner(): react_jsx_runtime.JSX.Element;
264
296
 
265
- declare function loadConfig(filePath?: string | null): Promise<AppConfig>;
266
- /**
267
- * getConfig(): load the full AppConfig
268
- * getConfig(key): load just that key
269
- */
270
- declare function getConfig(): Promise<AppConfig>;
271
- declare function getConfig<K extends keyof AppConfig>(key: K): Promise<AppConfig[K]>;
272
-
273
297
  /**
274
298
  * Reads a file at `relativeOrAbsolutePath` and returns its contents as a string.
275
299
  * In a browser this will reject immediately.
@@ -280,4 +304,5 @@ declare function readFileContents(relativeOrAbsolutePath: string): Promise<strin
280
304
  */
281
305
  declare function readJsonFile<T = any>(relativeOrAbsolutePath: string): Promise<T>;
282
306
 
283
- export { API_PREFIX, type ApiRow, type AppConfig, BASE_URL, Button, type ChangePasswordFormProps, type ChangePasswordProps, Checkbox, DEV_PREFIX, DOMAIN_NAME, type FetchVariables, type FileItem, type FileListResponse, Input, type InputProps, type JwtPayload, type LoginFormProps, type LoginProps, type LogoutButtonProps, PROD_PREFIX, PROTOCOL, type Promise$1 as Promise, SUB_DIR, Spinner, type UrlKey, 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 };
307
+ export { API_PREFIX, BASE_URL, Button, Checkbox, DEV_PREFIX, DOMAIN_NAME, Input, PROD_PREFIX, PROTOCOL, SUB_DIR, Spinner, alertit, api, checkResponse, currentUsername, currentUsernames, decodeJwt, eatAll, eatEnd, eatInner, eatOuter, ensureAbstractUrl, ensure_list, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getBody, getComponentsUtilsDirectory, getConfig, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFetchVars, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMethod, getPublicDir, getResult, 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, parseResult, readFileContents, readJsonFile, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, truncateString };
308
+ export type { ApiRow, AppConfig, ChangePasswordFormProps, ChangePasswordProps, FetchVariables, FileItem, FileListResponse, InputProps, JwtPayload, LoginFormProps, LoginProps, LogoutButtonProps, Promise$1 as Promise, UrlKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putkoff/abstract-utilities",
3
- "version": "0.1.156",
3
+ "version": "0.1.158",
4
4
  "type": "module",
5
5
  "description": "A reusable React Login component with JWT authentication",
6
6
  "main": "dist/cjs/index.js",
@@ -32,7 +32,7 @@
32
32
  "@testing-library/jest-dom": "^6.4.2",
33
33
  "@testing-library/react": "^14.2.1",
34
34
  "@types/jest": "^29.5.12",
35
- "@types/node": "^24.0.10",
35
+ "@types/node": "^24.0.13",
36
36
  "@types/react": "^18.2.55",
37
37
  "@types/react-dom": "^18.2.19",
38
38
  "jest": "^29.7.0",