@putkoff/abstract-utilities 0.1.127 → 0.1.128

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
@@ -48,8 +48,8 @@ interface ChangePasswordFormProps {
48
48
  }
49
49
 
50
50
  interface AppConfig {
51
- BASE_URL: string;
52
51
  BASE_API_URL: string;
52
+ BASE_OTHER_URL: string;
53
53
  FEATURE_FLAG?: boolean;
54
54
  SOME_NUMBER?: number;
55
55
  }
@@ -68,6 +68,7 @@ interface InputProps {
68
68
  placeholder?: any;
69
69
  error?: string;
70
70
  }
71
+ type UrlKey = Extract<keyof AppConfig, `BASE_${string}_URL`>;
71
72
  interface FetchVariables {
72
73
  method: string;
73
74
  headers: Record<string, string>;
@@ -145,6 +146,17 @@ declare function get_window_location(): Location | "https://abstractendeavors.co
145
146
  declare function get_window_pathname(): string | null;
146
147
  declare function get_window_parts(): Location | "https://abstractendeavors.com" | null;
147
148
 
149
+ /**
150
+ * Given an “endpoint” slug like "api/list", build the full URL
151
+ * from the BASE_API_URL entry in your JSON config.
152
+ */
153
+ declare function get_app_config_url(endpoint: string): Promise<string>;
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<unknown>;
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
+ 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
+ declare function requestPatch(url: string, body?: unknown): Promise<Response>;
158
+ declare function fetchSharePatch(file: unknown, appKey?: any): Promise<void>;
159
+
148
160
  declare function get_dirname(filePath: string | null): string;
149
161
  declare function get_basename(filePath: string | null): string;
150
162
  declare function get_filename(file_path: string): string;
@@ -197,6 +209,8 @@ declare function getDbConfigsPath(): string;
197
209
  declare function getSchemasPath(): string;
198
210
  declare function getSchemasDirPath(subPath: string): string;
199
211
 
212
+ declare function alertit(obj?: any): void;
213
+
200
214
  declare function getSubstring(obj: string, maxLength?: number | null, minLength?: number | null): string;
201
215
  declare function truncateString(obj: string, maxLength?: number): string;
202
216
  /**
@@ -237,33 +251,8 @@ declare function eatOuter(str: string, listObjects: string | string[]): string;
237
251
  declare function eatAll(str: string, listObjects: string | string[]): string;
238
252
  declare function eatEnd(obj: string, endings?: string[]): string;
239
253
 
240
- declare function alertit(obj?: any): void;
241
-
242
254
  declare function ensure_list<T>(obj: T | T[]): T[];
243
255
 
244
- /**
245
- * getConfig(): load the full AppConfig
246
- * getConfig(key): load just that key
247
- */
248
- declare function getConfig(): Promise<AppConfig>;
249
- declare function getConfig<K extends keyof AppConfig>(key: K): Promise<AppConfig[K]>;
250
-
251
- /**
252
-
253
- ***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
254
- *
255
- *4. **secureFetchIt** (`src/functions/fetch/secureFetchIt.ts`):
256
- * Since `secureFetchIt` isn’t provided, we’ll create a minimal implementation based on its usage in `Login` and `uploadFiles`. It’s assumed to be a wrapper around `fetch` that handles authentication and JSON parsing.
257
- *
258
- */
259
- /** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
260
- declare function get_app_config_url(endpoint: string, appKey?: keyof AppConfig): Promise<string>;
261
- declare function fetchIt(endpoint: string, body?: unknown, method?: string | null, headers?: Record<string, string> | null, blob?: boolean | null, no_api?: boolean, requireAuth?: boolean): Promise<unknown>;
262
- 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>;
263
- 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>;
264
- declare function requestPatch(url: string, body?: unknown): Promise<Response>;
265
- declare function fetchSharePatch(file: unknown, appKey?: any): Promise<void>;
266
-
267
256
  declare function Button({ children, color, variant, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
268
257
  color?: 'gray' | 'green' | 'blue';
269
258
  variant?: 'default' | 'icon' | 'primary' | 'secondary';
@@ -281,6 +270,14 @@ declare function Input({ label, trailing, ...rest }: React$1.InputHTMLAttributes
281
270
 
282
271
  declare function Spinner(): react_jsx_runtime.JSX.Element;
283
272
 
273
+ declare function loadConfig(filePath?: string | null): Promise<AppConfig>;
274
+ /**
275
+ * getConfig(): load the full AppConfig
276
+ * getConfig(key): load just that key
277
+ */
278
+ declare function getConfig(): Promise<AppConfig>;
279
+ declare function getConfig<K extends keyof AppConfig>(key: K): Promise<AppConfig[K]>;
280
+
284
281
  /**
285
282
  * Reads a file at `relativeOrAbsolutePath` and returns its contents as a string.
286
283
  * In a browser this will reject immediately.
@@ -291,4 +288,4 @@ declare function readFileContents(relativeOrAbsolutePath: string): Promise<strin
291
288
  */
292
289
  declare function readJsonFile<T = any>(relativeOrAbsolutePath: string): Promise<T>;
293
290
 
294
- 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, 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, make_path, make_sanitized_path, normalizeUrl, readFileContents, readJsonFile, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, truncateString };
291
+ 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 };
@@ -1,6 +1,6 @@
1
1
  export interface AppConfig {
2
- BASE_URL: string;
3
2
  BASE_API_URL: string;
3
+ BASE_OTHER_URL: string;
4
4
  FEATURE_FLAG?: boolean;
5
5
  SOME_NUMBER?: number;
6
6
  }
@@ -19,6 +19,7 @@ export interface InputProps {
19
19
  placeholder?: any;
20
20
  error?: string;
21
21
  }
22
+ export type UrlKey = Extract<keyof AppConfig, `BASE_${string}_URL`>;
22
23
  export interface FetchVariables {
23
24
  method: string;
24
25
  headers: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putkoff/abstract-utilities",
3
- "version": "0.1.127",
3
+ "version": "0.1.128",
4
4
  "type": "module",
5
5
  "description": "A reusable React Login component with JWT authentication",
6
6
  "main": "dist/cjs/index.js",