@putkoff/abstract-utilities 0.1.103 → 0.1.105
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/config/apiBase.d.ts +8 -0
- package/dist/cjs/functions/fetch_utils/imports.d.ts +0 -1
- package/dist/cjs/functions/fetch_utils/src/utils.d.ts +0 -2
- package/dist/cjs/functions/index.d.ts +1 -0
- package/dist/cjs/index.js +15 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/config/apiBase.d.ts +8 -0
- package/dist/esm/config/apiBase.d.ts +8 -0
- package/dist/esm/functions/fetch_utils/imports.d.ts +0 -1
- package/dist/esm/functions/fetch_utils/src/utils.d.ts +0 -2
- package/dist/esm/functions/index.d.ts +1 -0
- package/dist/esm/index.js +4 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/functions/fetch_utils/imports.d.ts +0 -1
- package/dist/functions/fetch_utils/src/utils.d.ts +0 -2
- package/dist/functions/index.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Runtime-loaded JSON (config.json) shape */
|
|
2
|
+
export interface RuntimeConfig {
|
|
3
|
+
API_BASE_URL: string;
|
|
4
|
+
}
|
|
5
|
+
/** Call once, early in app startup (e.g. in index.tsx) */
|
|
6
|
+
export declare function load(): Promise<void>;
|
|
7
|
+
/** Get the base (after `load()`), or '' if not loaded yet */
|
|
8
|
+
export declare function apiBase(): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Runtime-loaded JSON (config.json) shape */
|
|
2
|
+
export interface RuntimeConfig {
|
|
3
|
+
API_BASE_URL: string;
|
|
4
|
+
}
|
|
5
|
+
/** Call once, early in app startup (e.g. in index.tsx) */
|
|
6
|
+
export declare function load(): Promise<void>;
|
|
7
|
+
/** Get the base (after `load()`), or '' if not loaded yet */
|
|
8
|
+
export declare function apiBase(): string;
|
|
@@ -4,5 +4,4 @@ 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';
|
|
8
7
|
export type { LogoutButtonProps, FetchVariables } from './../../types';
|
|
@@ -4,8 +4,6 @@ export declare function ensureAbstractUrl(endpoint: string, slices?: string[]):
|
|
|
4
4
|
* Unwraps nested { result } fields until you hit a non-object or no more "result" keys.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getResult<T>(obj: unknown): T;
|
|
7
|
-
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
8
|
-
export declare function getRawConfigUrl(): any;
|
|
9
7
|
export declare function api(endpoint: string): string;
|
|
10
8
|
export declare function checkResponse(res: Response): any;
|
|
11
9
|
export declare function parseResult(res: Response): Promise<unknown>;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
1
|
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
export { useCallback, useRef, useState } from 'react';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
4
|
|
|
4
5
|
/******************************************************************************
|
|
5
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1108,15 +1109,8 @@ function getFetchVars(headers = null, method = null, body = null) {
|
|
|
1108
1109
|
}
|
|
1109
1110
|
|
|
1110
1111
|
function getAppConfig(endpoint) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
const base = rawBase.replace(/\/+$/, "");
|
|
1114
|
-
// strip any leading slashes on endpoint, then prefix “/api/”
|
|
1115
|
-
const cleanEndpoint = endpoint.replace(/^\/+/, "");
|
|
1116
|
-
const url = base
|
|
1117
|
-
? `${base}/${cleanEndpoint}`
|
|
1118
|
-
: `/api/${cleanEndpoint}`;
|
|
1119
|
-
return url;
|
|
1112
|
+
const clean = endpoint.replace(/^\/+/, '');
|
|
1113
|
+
return `/api/${clean}`;
|
|
1120
1114
|
}
|
|
1121
1115
|
|
|
1122
1116
|
/**
|