@thetechfossil/upfiles 0.6.0 → 1.0.2

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.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  type PresignResponse = {
4
5
  presignedUrl: string;
@@ -33,6 +34,19 @@ type FileListItem = {
33
34
  uploadedAt: string;
34
35
  url: string;
35
36
  };
37
+ /**
38
+ * Upfiles Client - JavaScript client for Upfiles Plugin API
39
+ *
40
+ * 📚 Full documentation: https://ttf-upfiles-docs.netlify.app/
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const client = new UpfilesClient({
45
+ * baseUrl: 'https://your-upfiles.example.com',
46
+ * apiKey: 'upk_...',
47
+ * });
48
+ * ```
49
+ */
36
50
  type UpfilesClientOptions = {
37
51
  baseUrl?: string;
38
52
  presignPath?: string;
@@ -43,6 +57,21 @@ type UpfilesClientOptions = {
43
57
  apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
44
58
  thumbnailsPath?: string;
45
59
  };
60
+ /**
61
+ * UpfilesClient - Main client class for interacting with Upfiles Plugin API
62
+ *
63
+ * 📚 Documentation: https://ttf-upfiles-docs.netlify.app/
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const client = new UpfilesClient({
68
+ * baseUrl: 'https://your-upfiles.example.com',
69
+ * apiKey: 'upk_...',
70
+ * });
71
+ *
72
+ * const result = await client.upload(file, { folderPath: 'uploads/' });
73
+ * ```
74
+ */
46
75
  declare class UpfilesClient {
47
76
  private baseUrl?;
48
77
  private presignPath;
@@ -96,11 +125,16 @@ type UploaderProps = {
96
125
  folderPath?: string;
97
126
  onComplete?: (files: UploaderFile[]) => void;
98
127
  onError?: (error: Error) => void;
128
+ onUploadBegin?: (fileName: string) => void;
129
+ onUploadProgress?: (fileName: string, progress: number) => void;
130
+ onClientUploadComplete?: (file: UploaderFile) => void;
99
131
  className?: string;
100
132
  buttonClassName?: string;
101
133
  dropzoneClassName?: string;
102
134
  children?: React.ReactNode;
103
135
  fetchThumbnails?: boolean;
136
+ autoRecordToDb?: boolean;
137
+ recordUrl?: string;
104
138
  };
105
139
  declare const Uploader: React.FC<UploaderProps>;
106
140
 
@@ -126,7 +160,106 @@ type ProjectFilesWidgetProps = {
126
160
  contentType: string;
127
161
  }) => Promise<void> | void;
128
162
  onSaved?: (result?: any) => void;
163
+ onDelete?: (key: string) => Promise<void>;
164
+ deleteUrl?: string;
165
+ showDelete?: boolean;
129
166
  };
130
167
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
131
168
 
132
- export { type FileListItem, type PresignResponse, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps };
169
+ type ConnectProjectDialogProps = {
170
+ baseUrl: string;
171
+ open: boolean;
172
+ onOpenChange: (open: boolean) => void;
173
+ onConnected: (apiKey: string, meta: {
174
+ projectId?: string;
175
+ source: 'existing' | 'new' | 'manual';
176
+ }) => void;
177
+ fetchImpl?: typeof fetch;
178
+ title?: string;
179
+ description?: string;
180
+ className?: string;
181
+ };
182
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
183
+
184
+ type ConnectOptions = {
185
+ baseUrl: string;
186
+ fetch?: typeof fetch;
187
+ };
188
+ type Project = {
189
+ id: string;
190
+ name: string;
191
+ createdAt?: string;
192
+ };
193
+ declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
194
+ declare function createProject(opts: ConnectOptions & {
195
+ name: string;
196
+ keyName?: string;
197
+ }): Promise<{
198
+ apiKey: string;
199
+ projectId: string;
200
+ }>;
201
+ declare function connectProject(opts: ConnectOptions & {
202
+ projectId: string;
203
+ keyName?: string;
204
+ }): Promise<{
205
+ apiKey: string;
206
+ }>;
207
+ declare function addApiKeyManually(apiKey: string): {
208
+ apiKey: string;
209
+ };
210
+ declare function createClientWithKey(baseUrl: string, apiKey: string): UpfilesClient;
211
+ declare function connectUsingApiKey(opts: {
212
+ baseUrl: string;
213
+ apiKey: string;
214
+ apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
215
+ }): {
216
+ apiKey: string;
217
+ client: UpfilesClient;
218
+ };
219
+
220
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
221
+ declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
222
+ type ImageWithThumbs = FileListItem & {
223
+ thumbnails?: Thumbnail[];
224
+ };
225
+ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
226
+ folderPath?: string;
227
+ limitConcurrent?: number;
228
+ }): Promise<ImageWithThumbs[]>;
229
+
230
+ type ImageManagerProps = {
231
+ open: boolean;
232
+ onOpenChange: (open: boolean) => void;
233
+ clientOptions: UpfilesClientOptions;
234
+ projectId?: string;
235
+ folderPath?: string;
236
+ title?: string;
237
+ description?: string;
238
+ className?: string;
239
+ gridClassName?: string;
240
+ onSelect: (image: {
241
+ url: string;
242
+ key: string;
243
+ originalName: string;
244
+ size: number;
245
+ contentType: string;
246
+ thumbnails?: {
247
+ id: string;
248
+ key: string;
249
+ url: string;
250
+ size: number;
251
+ sizeType?: string;
252
+ }[];
253
+ }) => void;
254
+ onDelete?: (key: string) => Promise<void>;
255
+ deleteUrl?: string;
256
+ autoRecordToDb?: boolean;
257
+ fetchThumbnails?: boolean;
258
+ maxFileSize?: number;
259
+ maxFiles?: number;
260
+ mode?: 'full' | 'browse' | 'upload';
261
+ showDelete?: boolean;
262
+ };
263
+ declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
264
+
265
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, ImageManager, type ImageManagerProps, type ImageWithThumbs, type PresignResponse, type Project, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps, addApiKeyManually, connectProject, connectUsingApiKey, createClientWithKey, createProject, fetchFileThumbnails, fetchProjectFiles, fetchProjectImagesWithThumbs, listProjects };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
3
 
3
4
  type PresignResponse = {
4
5
  presignedUrl: string;
@@ -33,6 +34,19 @@ type FileListItem = {
33
34
  uploadedAt: string;
34
35
  url: string;
35
36
  };
37
+ /**
38
+ * Upfiles Client - JavaScript client for Upfiles Plugin API
39
+ *
40
+ * 📚 Full documentation: https://ttf-upfiles-docs.netlify.app/
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const client = new UpfilesClient({
45
+ * baseUrl: 'https://your-upfiles.example.com',
46
+ * apiKey: 'upk_...',
47
+ * });
48
+ * ```
49
+ */
36
50
  type UpfilesClientOptions = {
37
51
  baseUrl?: string;
38
52
  presignPath?: string;
@@ -43,6 +57,21 @@ type UpfilesClientOptions = {
43
57
  apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
44
58
  thumbnailsPath?: string;
45
59
  };
60
+ /**
61
+ * UpfilesClient - Main client class for interacting with Upfiles Plugin API
62
+ *
63
+ * 📚 Documentation: https://ttf-upfiles-docs.netlify.app/
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const client = new UpfilesClient({
68
+ * baseUrl: 'https://your-upfiles.example.com',
69
+ * apiKey: 'upk_...',
70
+ * });
71
+ *
72
+ * const result = await client.upload(file, { folderPath: 'uploads/' });
73
+ * ```
74
+ */
46
75
  declare class UpfilesClient {
47
76
  private baseUrl?;
48
77
  private presignPath;
@@ -96,11 +125,16 @@ type UploaderProps = {
96
125
  folderPath?: string;
97
126
  onComplete?: (files: UploaderFile[]) => void;
98
127
  onError?: (error: Error) => void;
128
+ onUploadBegin?: (fileName: string) => void;
129
+ onUploadProgress?: (fileName: string, progress: number) => void;
130
+ onClientUploadComplete?: (file: UploaderFile) => void;
99
131
  className?: string;
100
132
  buttonClassName?: string;
101
133
  dropzoneClassName?: string;
102
134
  children?: React.ReactNode;
103
135
  fetchThumbnails?: boolean;
136
+ autoRecordToDb?: boolean;
137
+ recordUrl?: string;
104
138
  };
105
139
  declare const Uploader: React.FC<UploaderProps>;
106
140
 
@@ -126,7 +160,106 @@ type ProjectFilesWidgetProps = {
126
160
  contentType: string;
127
161
  }) => Promise<void> | void;
128
162
  onSaved?: (result?: any) => void;
163
+ onDelete?: (key: string) => Promise<void>;
164
+ deleteUrl?: string;
165
+ showDelete?: boolean;
129
166
  };
130
167
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
131
168
 
132
- export { type FileListItem, type PresignResponse, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps };
169
+ type ConnectProjectDialogProps = {
170
+ baseUrl: string;
171
+ open: boolean;
172
+ onOpenChange: (open: boolean) => void;
173
+ onConnected: (apiKey: string, meta: {
174
+ projectId?: string;
175
+ source: 'existing' | 'new' | 'manual';
176
+ }) => void;
177
+ fetchImpl?: typeof fetch;
178
+ title?: string;
179
+ description?: string;
180
+ className?: string;
181
+ };
182
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
183
+
184
+ type ConnectOptions = {
185
+ baseUrl: string;
186
+ fetch?: typeof fetch;
187
+ };
188
+ type Project = {
189
+ id: string;
190
+ name: string;
191
+ createdAt?: string;
192
+ };
193
+ declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
194
+ declare function createProject(opts: ConnectOptions & {
195
+ name: string;
196
+ keyName?: string;
197
+ }): Promise<{
198
+ apiKey: string;
199
+ projectId: string;
200
+ }>;
201
+ declare function connectProject(opts: ConnectOptions & {
202
+ projectId: string;
203
+ keyName?: string;
204
+ }): Promise<{
205
+ apiKey: string;
206
+ }>;
207
+ declare function addApiKeyManually(apiKey: string): {
208
+ apiKey: string;
209
+ };
210
+ declare function createClientWithKey(baseUrl: string, apiKey: string): UpfilesClient;
211
+ declare function connectUsingApiKey(opts: {
212
+ baseUrl: string;
213
+ apiKey: string;
214
+ apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
215
+ }): {
216
+ apiKey: string;
217
+ client: UpfilesClient;
218
+ };
219
+
220
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
221
+ declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
222
+ type ImageWithThumbs = FileListItem & {
223
+ thumbnails?: Thumbnail[];
224
+ };
225
+ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
226
+ folderPath?: string;
227
+ limitConcurrent?: number;
228
+ }): Promise<ImageWithThumbs[]>;
229
+
230
+ type ImageManagerProps = {
231
+ open: boolean;
232
+ onOpenChange: (open: boolean) => void;
233
+ clientOptions: UpfilesClientOptions;
234
+ projectId?: string;
235
+ folderPath?: string;
236
+ title?: string;
237
+ description?: string;
238
+ className?: string;
239
+ gridClassName?: string;
240
+ onSelect: (image: {
241
+ url: string;
242
+ key: string;
243
+ originalName: string;
244
+ size: number;
245
+ contentType: string;
246
+ thumbnails?: {
247
+ id: string;
248
+ key: string;
249
+ url: string;
250
+ size: number;
251
+ sizeType?: string;
252
+ }[];
253
+ }) => void;
254
+ onDelete?: (key: string) => Promise<void>;
255
+ deleteUrl?: string;
256
+ autoRecordToDb?: boolean;
257
+ fetchThumbnails?: boolean;
258
+ maxFileSize?: number;
259
+ maxFiles?: number;
260
+ mode?: 'full' | 'browse' | 'upload';
261
+ showDelete?: boolean;
262
+ };
263
+ declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
264
+
265
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, ImageManager, type ImageManagerProps, type ImageWithThumbs, type PresignResponse, type Project, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps, addApiKeyManually, connectProject, connectUsingApiKey, createClientWithKey, createProject, fetchFileThumbnails, fetchProjectFiles, fetchProjectImagesWithThumbs, listProjects };