@putkoff/abstract-utilities 0.1.106 → 0.1.108
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/functions/fetch_utils/src/fetchIt_utils.d.ts +1 -1
- package/dist/cjs/functions/ui_utils/imports.d.ts +0 -2
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +99 -556
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/functions/fetch_utils/src/fetchIt_utils.d.ts +1 -1
- package/dist/esm/functions/ui_utils/imports.d.ts +0 -2
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +100 -534
- package/dist/esm/index.js.map +1 -1
- package/dist/functions/fetch_utils/src/fetchIt_utils.d.ts +1 -1
- package/dist/functions/ui_utils/imports.d.ts +0 -2
- package/dist/hooks/useFiles/imports.d.ts +9 -5
- package/dist/hooks/useFiles/src/index.d.ts +1 -0
- package/dist/hooks/useFiles/src/patchShareSettings.d.ts +1 -4
- package/dist/hooks/useFiles/src/useFiles.d.ts +2 -2
- package/dist/hooks/useFiles/src/useSaveShareSettings.d.ts +2 -0
- package/dist/index.d.ts +23 -116
- package/package.json +2 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
10
10
|
export declare function get_app_config_url(endpoint: any): string;
|
|
11
11
|
export 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>;
|
|
12
|
-
export declare function secureFetchIt<T>(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: false, noApi?: boolean,
|
|
12
|
+
export declare function secureFetchIt<T>(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: false, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<T>;
|
|
13
13
|
export declare function secureFetchIt(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<Blob>;
|
|
14
14
|
export declare function requestPatch(url: string, body?: unknown): Promise<Response>;
|
|
15
15
|
export declare function fetchSharePatch(file: unknown): Promise<void>;
|
|
@@ -2,5 +2,3 @@ import React from 'react';
|
|
|
2
2
|
export declare const useState: typeof React.useState, useEffect: typeof React.useEffect, useCallback: typeof React.useCallback;
|
|
3
3
|
export { fetchIt } from './../fetch_utils';
|
|
4
4
|
export { currentUsername, isTokenExpired, getToken } from './../auth_utils';
|
|
5
|
-
export { uploadFile, downloadFile } from './../../file_utils';
|
|
6
|
-
export { useFiles } from './../../hooks/useFiles';
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { useCallback } from 'react';
|
|
2
|
-
export type { FileItem, ApiRow } from '
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
2
|
+
export type { FileItem, ApiRow } from './../..//components/FileHandlers/types';
|
|
3
|
+
export { getAuthorizationHeader } from "./../auth_utils";
|
|
4
|
+
export { make_path } from './../path_utils';
|
|
5
|
+
export { stripPrefixes } from './../string_utils';
|
|
6
|
+
export { alertit } from './../rndm_utils';
|
|
7
|
+
export { ensure_list } from './../type_utils';
|
|
8
|
+
export { eatInner } from './../string_utils';
|
|
9
|
+
export { secureFetchIt, fetchSharePatch } from './../fetch_utils';
|
|
10
|
+
export { toggleShare, removeFile, listFiles, downloadFile } from './../../file_utils';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { FileItem } from './../imports';
|
|
2
|
-
/**
|
|
3
|
-
* Custom hook for optimistic share-setting patch updates
|
|
4
|
-
*/
|
|
5
2
|
/**
|
|
6
3
|
* Custom hook to toggle share settings on a file item
|
|
7
4
|
*/
|
|
8
|
-
export declare const usePatchShareSettings: (setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => (file:
|
|
5
|
+
export declare const usePatchShareSettings: (setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => (file: any) => Promise<void>;
|
|
9
6
|
export default usePatchShareSettings;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FileItem } from './../imports';
|
|
1
|
+
import type { FileItem } from './../imports';
|
|
2
2
|
export declare function useFiles(): {
|
|
3
3
|
files: FileItem[];
|
|
4
4
|
loading: boolean;
|
|
5
5
|
error: Error | null;
|
|
6
6
|
load: () => Promise<void>;
|
|
7
7
|
toggleShare: (file: FileItem) => Promise<void>;
|
|
8
|
-
patchShareSettings: (
|
|
8
|
+
patchShareSettings: (updated: FileItem) => Promise<void>;
|
|
9
9
|
deleteFile: (file: FileItem) => Promise<void>;
|
|
10
10
|
setFiles: import("react").Dispatch<import("react").SetStateAction<FileItem[]>>;
|
|
11
11
|
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import react__default from 'react';
|
|
1
|
+
import React$1 from 'react';
|
|
3
2
|
export { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
4
|
|
|
6
|
-
/** Non-React “direct download” used by some old links (kept for parity) */
|
|
7
|
-
declare function directDownload(relPath: string, filename: string): Promise<void>;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
|
|
12
|
-
*
|
|
13
|
-
*4. **secureFetchIt** (`src/functions/fetch/secureFetchIt.ts`):
|
|
14
|
-
* 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.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
18
|
-
declare function get_app_config_url(endpoint: any): string;
|
|
19
|
-
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>;
|
|
20
|
-
declare function secureFetchIt<T>(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: false, noApi?: boolean, requireAuth?: boolean): Promise<T>;
|
|
21
|
-
declare function secureFetchIt(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<Blob>;
|
|
22
|
-
declare function requestPatch(url: string, body?: unknown): Promise<Response>;
|
|
23
|
-
declare function fetchSharePatch(file: unknown): Promise<void>;
|
|
24
|
-
|
|
25
5
|
interface FileItem {
|
|
26
6
|
id: number | string;
|
|
27
7
|
filename: string;
|
|
@@ -140,61 +120,6 @@ declare function currentUsername(): string | null;
|
|
|
140
120
|
declare function currentUsernames(): any;
|
|
141
121
|
declare function decodeJwt(token: string): JwtPayload;
|
|
142
122
|
|
|
143
|
-
declare function alertit(obj?: any): void;
|
|
144
|
-
|
|
145
|
-
declare function downloadFile(item: FileItem): Promise<void>;
|
|
146
|
-
|
|
147
|
-
declare function downloadSelect(relPath: string, filename: string): Promise<void>;
|
|
148
|
-
|
|
149
|
-
/** Given a checkbox inside a table-row → download that row’s file. */
|
|
150
|
-
declare function downloadRow(cb: HTMLInputElement): Promise<void>;
|
|
151
|
-
/** Bulk download: pass a NodeList or array of checkboxes. */
|
|
152
|
-
declare function downloadSelected(checkboxes: Iterable<HTMLInputElement>): Promise<void>;
|
|
153
|
-
|
|
154
|
-
/** Helper function to trigger file download */
|
|
155
|
-
declare function triggerDownload(blob: Blob, filename: string): void;
|
|
156
|
-
|
|
157
|
-
/** Wire up header + row checkboxes once the table is in the DOM. */
|
|
158
|
-
declare function initSelectAll(): void;
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Classic “select all rows” logic (still handy in non-React views
|
|
162
|
-
* such as the admin dashboard).
|
|
163
|
-
*/
|
|
164
|
-
declare function syncHeaderCheckbox(): void;
|
|
165
|
-
|
|
166
|
-
/** Utility for other screens: toggle a list of checkboxes on/off. */
|
|
167
|
-
declare function toggleCheckboxes(cbs: HTMLInputElement[]): void;
|
|
168
|
-
|
|
169
|
-
/** Generic PATCH helper kept for other admin forms */
|
|
170
|
-
declare function patchFileSetting(fileId: string, field: string, value: unknown): Promise<Record<string, unknown>>;
|
|
171
|
-
|
|
172
|
-
/** Classic file-upload for the fallback HTML page. */
|
|
173
|
-
declare function uploadFile(file: any, subdir: any): Promise<any>;
|
|
174
|
-
|
|
175
|
-
interface UploadResponse {
|
|
176
|
-
filepath: string;
|
|
177
|
-
}
|
|
178
|
-
declare function uploadFiles(file: File, subdir?: string): Promise<UploadResponse>;
|
|
179
|
-
|
|
180
|
-
declare function removeFile(item: any): Promise<void>;
|
|
181
|
-
|
|
182
|
-
/** Bulk download: pass a NodeList or array of checkboxes. */
|
|
183
|
-
declare function removeSelected(checkboxes: Iterable<HTMLInputElement>): Promise<void>;
|
|
184
|
-
|
|
185
|
-
/** Given a checkbox inside a table-row → download that row’s file. */
|
|
186
|
-
declare function removeRow(cb: HTMLInputElement): Promise<void>;
|
|
187
|
-
|
|
188
|
-
/** GET /secure-list */
|
|
189
|
-
declare function listFiles(setFiles?: any): Promise<any>;
|
|
190
|
-
|
|
191
|
-
declare function getToggleShare(file: any): boolean;
|
|
192
|
-
declare function updateFileShare(file: any): FileItem;
|
|
193
|
-
/**
|
|
194
|
-
* Custom hook to toggle share settings on a file item
|
|
195
|
-
*/
|
|
196
|
-
declare function toggleShare(file: FileItem): Promise<void>;
|
|
197
|
-
|
|
198
123
|
declare const PROTOCOL = "https://";
|
|
199
124
|
declare const DOMAIN_NAME = "abstractendeavors";
|
|
200
125
|
declare const BASE_URL = "https://abstractendeavors.com";
|
|
@@ -208,6 +133,22 @@ declare function get_window_location(): Location | "https://abstractendeavors.co
|
|
|
208
133
|
declare function get_window_pathname(): string | null;
|
|
209
134
|
declare function get_window_parts(): Location | "https://abstractendeavors.com" | null;
|
|
210
135
|
|
|
136
|
+
/**
|
|
137
|
+
|
|
138
|
+
***Changes**: None, as it’s self-contained and doesn’t rely on external imports.
|
|
139
|
+
*
|
|
140
|
+
*4. **secureFetchIt** (`src/functions/fetch/secureFetchIt.ts`):
|
|
141
|
+
* 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.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
/** Pulls base-URL from AppConfig.API_BASE_URL, strips trailing slashes */
|
|
145
|
+
declare function get_app_config_url(endpoint: any): string;
|
|
146
|
+
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>;
|
|
147
|
+
declare function secureFetchIt<T>(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: false, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<T>;
|
|
148
|
+
declare function secureFetchIt(endpoint: string, body?: unknown, method?: string, headers?: Record<string, string> | null, blob?: boolean, noApi?: boolean, withCredentials?: boolean, returnJson?: boolean, returnReult?: boolean): Promise<Blob>;
|
|
149
|
+
declare function requestPatch(url: string, body?: unknown): Promise<Response>;
|
|
150
|
+
declare function fetchSharePatch(file: unknown): Promise<void>;
|
|
151
|
+
|
|
211
152
|
declare function get_dirname(filePath: string | null): string;
|
|
212
153
|
declare function get_basename(filePath: string | null): string;
|
|
213
154
|
declare function get_filename(file_path: string): string;
|
|
@@ -260,6 +201,8 @@ declare function getDbConfigsPath(): string;
|
|
|
260
201
|
declare function getSchemasPath(): string;
|
|
261
202
|
declare function getSchemasDirPath(subPath: string): string;
|
|
262
203
|
|
|
204
|
+
declare function alertit(obj?: any): void;
|
|
205
|
+
|
|
263
206
|
declare function getSubstring(obj: string, maxLength?: number | null, minLength?: number | null): string;
|
|
264
207
|
declare function truncateString(obj: string, maxLength?: number): string;
|
|
265
208
|
/**
|
|
@@ -308,51 +251,15 @@ declare function Button({ children, color, variant, className, ...rest }: React.
|
|
|
308
251
|
className?: string;
|
|
309
252
|
}): react_jsx_runtime.JSX.Element;
|
|
310
253
|
|
|
311
|
-
declare function Checkbox({ label, ...rest }:
|
|
254
|
+
declare function Checkbox({ label, ...rest }: React$1.InputHTMLAttributes<HTMLInputElement> & {
|
|
312
255
|
label: string;
|
|
313
256
|
}): react_jsx_runtime.JSX.Element;
|
|
314
257
|
|
|
315
|
-
declare function Input({ label, trailing, ...rest }:
|
|
258
|
+
declare function Input({ label, trailing, ...rest }: React$1.InputHTMLAttributes<HTMLInputElement> & {
|
|
316
259
|
label: string;
|
|
317
|
-
trailing?:
|
|
260
|
+
trailing?: React$1.ReactNode;
|
|
318
261
|
}): react_jsx_runtime.JSX.Element;
|
|
319
262
|
|
|
320
263
|
declare function Spinner(): react_jsx_runtime.JSX.Element;
|
|
321
264
|
|
|
322
|
-
|
|
323
|
-
* Custom hook that returns a memoized loadFiles callback
|
|
324
|
-
*/
|
|
325
|
-
declare const useLoadFiles: (setLoading: React.Dispatch<React.SetStateAction<boolean>>, setError: React.Dispatch<React.SetStateAction<Error | null>>, setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => () => Promise<void>;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Custom hook to toggle share settings on a file item
|
|
329
|
-
*/
|
|
330
|
-
declare const useToggleShare: (setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => (file: FileItem) => Promise<void>;
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Custom hook for optimistic share-setting patch updates
|
|
334
|
-
*/
|
|
335
|
-
/**
|
|
336
|
-
* Custom hook to toggle share settings on a file item
|
|
337
|
-
*/
|
|
338
|
-
declare const usePatchShareSettings: (setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => (file: FileItem) => Promise<void>;
|
|
339
|
-
|
|
340
|
-
declare function useFiles(): {
|
|
341
|
-
files: FileItem[];
|
|
342
|
-
loading: boolean;
|
|
343
|
-
error: Error | null;
|
|
344
|
-
load: () => Promise<void>;
|
|
345
|
-
toggleShare: (file: FileItem) => Promise<void>;
|
|
346
|
-
patchShareSettings: (file: FileItem) => Promise<void>;
|
|
347
|
-
deleteFile: (file: FileItem) => Promise<void>;
|
|
348
|
-
setFiles: react.Dispatch<react.SetStateAction<FileItem[]>>;
|
|
349
|
-
setLoading: react.Dispatch<react.SetStateAction<boolean>>;
|
|
350
|
-
setError: react.Dispatch<react.SetStateAction<Error | null>>;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Custom hook to toggle share settings on a file item
|
|
355
|
-
*/
|
|
356
|
-
declare const useDeleteFile: (setFiles: React.Dispatch<React.SetStateAction<FileItem[]>>) => (file: FileItem) => Promise<void>;
|
|
357
|
-
|
|
358
|
-
export { API_PREFIX, type ApiRow, 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, SUB_DIR, Spinner, alertit, currentUsername, currentUsernames, decodeJwt, directDownload, downloadFile, downloadRow, downloadSelect, downloadSelected, eatAll, eatEnd, eatInner, eatOuter, ensure_list, fetchIt, fetchSharePatch, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, getAbsDir, getAbsPath, getAuthorizationHeader, getBaseDir, getComponentsUtilsDirectory, getDbConfigsPath, getDistDir, getEnvDir, getEnvPath, getFunctionsDir, getFunctionsUtilsDirectory, getHooksUtilsDirectory, getLibUtilsDirectory, getPublicDir, getSchemasDirPath, getSchemasPath, getSrcDir, getSubstring, getToggleShare, 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, initSelectAll, isLoggedIn, isTokenExpired, listFiles, make_path, make_sanitized_path, normalizeUrl, patchFileSetting, removeFile, removeRow, removeSelected, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, syncHeaderCheckbox, toggleCheckboxes, toggleShare, triggerDownload, truncateString, updateFileShare, uploadFile, uploadFiles, useDeleteFile, useFiles, useLoadFiles, usePatchShareSettings, useToggleShare };
|
|
265
|
+
export { API_PREFIX, type ApiRow, 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, 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, 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, requestPatch, requireToken, sanitizeFilename, secureFetchIt, stripPrefixes, truncateString };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putkoff/abstract-utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.108",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A reusable React Login component with JWT authentication",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
],
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@putkoff/abstract_utilities": "^0.0.1",
|
|
75
|
+
"@putkoff/abstract-utilities": "^0.1.107",
|
|
75
76
|
"path-browserify": "^1.0.1"
|
|
76
77
|
}
|
|
77
78
|
}
|