@putkoff/abstract-utilities 0.1.190 → 0.1.193
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 +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/functions/fetch_utils/imports.d.ts +1 -1
- package/dist/functions/fetch_utils/src/fetch_utils.d.ts +0 -15
- package/dist/functions/fetch_utils/src/index.d.ts +1 -0
- package/dist/functions/fetch_utils/src/utils.d.ts +15 -5
- package/package.json +1 -2
- package/dist/functions/fetch_utils/src/fetchIt_utils.d.ts +0 -2
- package/dist/functions/read_utils/src/read_utils.d.ts +0 -8
- package/dist/functions/safe_utils/src/safe_utils.d.ts +0 -12
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
1
|
+
import { FetchVariables } from './../imports';
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps nested { result } fields until you hit a non-object or no more "result" keys.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getResult<T>(obj: unknown): T;
|
|
6
|
+
export declare function getMethod(method?: string | null, body?: unknown): string;
|
|
7
|
+
export declare function getHeaders(headers?: Record<string, string>, method?: string | null, body?: unknown): Record<string, string>;
|
|
8
|
+
export declare function getBody(body?: unknown, method?: string | null): string | undefined;
|
|
9
|
+
export declare function getFetchVars(headers?: Record<string, string> | null, method?: string | null, body?: any): FetchVariables;
|
|
10
|
+
export declare function parseResult(res: Response): Promise<unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Intercept 401/403 and force a clean redirect to login
|
|
13
|
+
* without ever showing an alert.
|
|
14
|
+
*/
|
|
15
|
+
export declare function checkResponse(res: Response): Response;
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putkoff/abstract-utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.193",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A reusable React Login component with JWT authentication",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"dev:fetch-utils": "ts-node-esm --experimental-specifier-resolution=node src/functions/fetch_utils/index.ts",
|
|
11
10
|
"build": "tsc --emitDeclarationOnly && rollup -c",
|
|
12
11
|
"test": "jest",
|
|
13
12
|
"prepublishOnly": "npm run build"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reads a JSON file, either via Node’s fs (if available)
|
|
3
|
-
* or via window.fetch in the browser. Never throws — returns
|
|
4
|
-
* the parsed object or null on any error.
|
|
5
|
-
*/
|
|
6
|
-
export declare function readJsonFile<T = any>(relativeOrAbsolutePath: string): Promise<T | null>;
|
|
7
|
-
export declare function getConfigContent<T = Record<string, any>>(): Promise<T | null>;
|
|
8
|
-
export declare function getConfigVar<T = any>(key?: any): Promise<T | undefined>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns `window` if running in a browser, otherwise `undefined`.
|
|
3
|
-
*/
|
|
4
|
-
export declare function getSafeLocalStorage(): Storage | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Call a Storage method by name, silencing any errors or missing storage.
|
|
7
|
-
*
|
|
8
|
-
* @param method One of the keys of the Storage interface: "getItem", "setItem", etc.
|
|
9
|
-
* @param args The arguments you’d normally pass to that method.
|
|
10
|
-
* @returns The method’s return value, or undefined if storage/method isn’t available.
|
|
11
|
-
*/
|
|
12
|
-
export declare function callStorage<K extends keyof Storage>(method: K, ...args: Parameters<Storage[K]>): ReturnType<Storage[K]> | undefined;
|