@karpeleslab/klbfw 0.2.20 → 0.2.21

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.
Files changed (2) hide show
  1. package/index.d.ts +72 -3
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -35,7 +35,38 @@ declare function restGet(name: string, params?: Record<string, any>): Promise<an
35
35
  declare function restSSE(name: string, method: 'GET', params?: Record<string, any>, context?: Record<string, any>): EventSource;
36
36
 
37
37
  // Upload module types
38
- interface UploadOptions {
38
+
39
+ /** File input types supported by uploadFile */
40
+ type UploadFileInput =
41
+ | ArrayBuffer
42
+ | Uint8Array
43
+ | File
44
+ | string
45
+ | { name?: string; size?: number; type?: string; content: ArrayBuffer | Uint8Array | string; lastModified?: number }
46
+ | NodeJS.ReadableStream;
47
+
48
+ /** Options for uploadFile */
49
+ interface UploadFileOptions {
50
+ /** Progress callback (0-1) */
51
+ onProgress?: (progress: number) => void;
52
+ /** Error callback - resolve to retry, reject to fail */
53
+ onError?: (error: Error, context: { phase: string; blockNum?: number; attempt: number }) => Promise<void>;
54
+ }
55
+
56
+ /** Options for uploadManyFiles */
57
+ interface UploadManyFilesOptions extends UploadFileOptions {
58
+ /** Progress callback with file-level details */
59
+ onProgress?: (progress: { fileIndex: number; fileCount: number; fileProgress: number; totalProgress: number }) => void;
60
+ /** Called when each file completes */
61
+ onFileComplete?: (info: { fileIndex: number; fileCount: number; result: any }) => void;
62
+ /** Error callback - context includes fileIndex */
63
+ onError?: (error: Error, context: { fileIndex: number; phase: string; blockNum?: number; attempt: number }) => Promise<void>;
64
+ /** Maximum concurrent uploads (1-10, default 3) */
65
+ concurrency?: number;
66
+ }
67
+
68
+ /** @deprecated Use uploadFile() instead */
69
+ interface UploadLegacyOptions {
39
70
  progress?: (progress: number) => void;
40
71
  endpoint?: string;
41
72
  headers?: Record<string, string>;
@@ -44,7 +75,40 @@ interface UploadOptions {
44
75
  params?: Record<string, any>;
45
76
  }
46
77
 
47
- declare function upload(file: File, options?: UploadOptions): Promise<any>;
78
+ /** @deprecated Use uploadFile() instead */
79
+ declare const upload: {
80
+ init(path: string, params?: Record<string, any>, notify?: (status: any) => void): Promise<any> | ((files: any) => Promise<any>);
81
+ append(path: string, file: File | object, params?: Record<string, any>, context?: Record<string, any>): Promise<any>;
82
+ run(): void;
83
+ getStatus(): { queue: any[]; running: any[]; failed: any[] };
84
+ resume(): void;
85
+ cancelItem(uploadId: number): void;
86
+ deleteItem(uploadId: number): void;
87
+ pauseItem(uploadId: number): void;
88
+ resumeItem(uploadId: number): void;
89
+ retryItem(uploadId: number): void;
90
+ onprogress?: (status: { queue: any[]; running: any[]; failed: any[] }) => void;
91
+ };
92
+
93
+ /** Upload a single file */
94
+ declare function uploadFile(
95
+ api: string,
96
+ buffer: UploadFileInput,
97
+ method?: string,
98
+ params?: Record<string, any>,
99
+ context?: Record<string, any>,
100
+ options?: UploadFileOptions
101
+ ): Promise<any>;
102
+
103
+ /** Upload multiple files with concurrency control */
104
+ declare function uploadManyFiles(
105
+ api: string,
106
+ files: UploadFileInput[],
107
+ method?: string,
108
+ params?: Record<string, any>,
109
+ context?: Record<string, any>,
110
+ options?: UploadManyFilesOptions
111
+ ): Promise<any[]>;
48
112
 
49
113
  // Utility types
50
114
  declare function getI18N(key: string, args?: Record<string, any>): string;
@@ -78,6 +142,11 @@ export {
78
142
  restGet,
79
143
  restSSE,
80
144
  upload,
145
+ uploadFile,
146
+ uploadManyFiles,
81
147
  getI18N,
82
- trimPrefix
148
+ trimPrefix,
149
+ UploadFileInput,
150
+ UploadFileOptions,
151
+ UploadManyFilesOptions
83
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karpeleslab/klbfw",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "Frontend Framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",