@thetechfossil/upfiles 1.0.9 → 1.0.12

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/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @thetechfossil/upfiles
2
2
 
3
- Lightweight JavaScript client and React component to upload files via a presigned S3 flow. Similar to UploadThing-like DX.
3
+ Lightweight JavaScript client and React component to upload files via a presigned S3 flow with excellent developer experience.
4
4
 
5
5
  ## Documentation
6
6
 
7
- 📚 **Full documentation available at:** [https://ttf-upfiles-docs.netlify.app/](https://ttf-upfiles-docs.netlify.app/)
7
+ 📚 **Full documentation available at:** [https://ktw-upfiles-docs.netlify.app/](https://ktw-upfiles-docs.netlify.app/)
8
8
 
9
9
  For detailed API reference, guides, examples, and more information, visit the documentation site.
10
10
 
@@ -12,6 +12,14 @@ For detailed API reference, guides, examples, and more information, visit the do
12
12
  - React `<Uploader />`: drag/drop, progress, single/multiple, accepts/types, size limits
13
13
  - React `<ProjectFilesWidget />`: list all files for a project (Plugin API), pick one, and optionally auto-save to your app
14
14
 
15
+ ## API Key Permissions (Scopes)
16
+
17
+ API keys can have granular scopes. When using an API key with this SDK, ensure it has the necessary scopes:
18
+
19
+ - **`read`**: access `getProjectFiles`, `getThumbnails`, `download`
20
+ - **`write`**: access `upload`, `generateThumbnails`
21
+ - **`delete`**: access file deletion
22
+
15
23
  ## Installation
16
24
 
17
25
  ```bash
package/dist/index.d.mts CHANGED
@@ -26,6 +26,14 @@ type Thumbnail = {
26
26
  sizeType?: string;
27
27
  createdAt?: string;
28
28
  };
29
+ type Folder = {
30
+ id: string;
31
+ name: string;
32
+ parentId: string | null;
33
+ projectId: string;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ };
29
37
  type FileListItem = {
30
38
  key: string;
31
39
  originalName: string;
@@ -37,7 +45,7 @@ type FileListItem = {
37
45
  /**
38
46
  * Upfiles Client - JavaScript client for Upfiles Plugin API
39
47
  *
40
- * 📚 Full documentation: https://ttf-upfiles-docs.netlify.app/
48
+ * 📚 Full documentation: https://ktw-upfiles-docs.netlify.app/
41
49
  *
42
50
  * @example
43
51
  * ```ts
@@ -57,12 +65,13 @@ type UpfilesClientOptions = {
57
65
  apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
58
66
  thumbnailsPath?: string;
59
67
  completionPath?: string;
68
+ foldersPath?: string;
60
69
  callCompletionEndpoint?: boolean;
61
70
  };
62
71
  /**
63
72
  * UpfilesClient - Main client class for interacting with Upfiles Plugin API
64
73
  *
65
- * 📚 Documentation: https://ttf-upfiles-docs.netlify.app/
74
+ * 📚 Documentation: https://ktw-upfiles-docs.netlify.app/
66
75
  *
67
76
  * @example
68
77
  * ```ts
@@ -84,6 +93,7 @@ declare class UpfilesClient {
84
93
  private apiKeyHeader;
85
94
  private thumbnailsPath;
86
95
  private completionPath;
96
+ private foldersPath;
87
97
  private callCompletionEndpoint;
88
98
  constructor(opts: UpfilesClientOptions);
89
99
  getPresignedUrl(params: {
@@ -106,7 +116,23 @@ declare class UpfilesClient {
106
116
  size: number;
107
117
  contentType: string;
108
118
  projectId?: string;
109
- }): Promise<void>;
119
+ }): Promise<{
120
+ success: boolean;
121
+ file: {
122
+ id: string;
123
+ key: string;
124
+ originalName: string;
125
+ size: number;
126
+ contentType: string;
127
+ url: string;
128
+ uploadedAt: string;
129
+ };
130
+ thumbnails?: Thumbnail[];
131
+ masterWebp?: {
132
+ key: string;
133
+ url: string;
134
+ };
135
+ }>;
110
136
  getThumbnails(fileKey: string): Promise<Thumbnail[]>;
111
137
  generateThumbnails(fileKey: string): Promise<{
112
138
  masterWebp?: {
@@ -115,9 +141,15 @@ declare class UpfilesClient {
115
141
  };
116
142
  thumbnails: Thumbnail[];
117
143
  }>;
144
+ getFolders(parentId?: string): Promise<Folder[]>;
145
+ createFolder(name: string, parentId?: string): Promise<Folder>;
118
146
  getProjectFiles(params?: {
119
147
  folderPath?: string;
120
- }): Promise<FileListItem[]>;
148
+ }): Promise<{
149
+ files: FileListItem[];
150
+ updatedAt: string | null;
151
+ }>;
152
+ getEventsUrl(projectId?: string): string;
121
153
  }
122
154
 
123
155
  type UploaderFile = {
@@ -183,6 +215,7 @@ type ProjectFilesWidgetProps = {
183
215
  onDelete?: (key: string) => Promise<void>;
184
216
  deleteUrl?: string;
185
217
  showDelete?: boolean;
218
+ refreshInterval?: number;
186
219
  };
187
220
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
188
221
 
@@ -237,7 +270,10 @@ declare function connectUsingApiKey(opts: {
237
270
  client: UpfilesClient;
238
271
  };
239
272
 
240
- declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
273
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<{
274
+ files: FileListItem[];
275
+ updatedAt: string | null;
276
+ }>;
241
277
  declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
242
278
  type ImageWithThumbs = FileListItem & {
243
279
  thumbnails?: Thumbnail[];
@@ -245,7 +281,10 @@ type ImageWithThumbs = FileListItem & {
245
281
  declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
246
282
  folderPath?: string;
247
283
  limitConcurrent?: number;
248
- }): Promise<ImageWithThumbs[]>;
284
+ }): Promise<{
285
+ items: ImageWithThumbs[];
286
+ updatedAt: string | null;
287
+ }>;
249
288
 
250
289
  type ImageManagerProps = {
251
290
  open: boolean;
@@ -270,6 +309,13 @@ type ImageManagerProps = {
270
309
  size: number;
271
310
  sizeType?: string;
272
311
  }[];
312
+ selectedThumbnail?: {
313
+ id: string;
314
+ key: string;
315
+ url: string;
316
+ size: number;
317
+ sizeType?: string;
318
+ };
273
319
  }) => void;
274
320
  onDelete?: (key: string) => Promise<void>;
275
321
  deleteUrl?: string;
@@ -279,7 +325,8 @@ type ImageManagerProps = {
279
325
  maxFiles?: number;
280
326
  mode?: 'full' | 'browse' | 'upload';
281
327
  showDelete?: boolean;
328
+ refreshInterval?: number;
282
329
  };
283
330
  declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
284
331
 
285
- 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 };
332
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, type Folder, 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
@@ -26,6 +26,14 @@ type Thumbnail = {
26
26
  sizeType?: string;
27
27
  createdAt?: string;
28
28
  };
29
+ type Folder = {
30
+ id: string;
31
+ name: string;
32
+ parentId: string | null;
33
+ projectId: string;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ };
29
37
  type FileListItem = {
30
38
  key: string;
31
39
  originalName: string;
@@ -37,7 +45,7 @@ type FileListItem = {
37
45
  /**
38
46
  * Upfiles Client - JavaScript client for Upfiles Plugin API
39
47
  *
40
- * 📚 Full documentation: https://ttf-upfiles-docs.netlify.app/
48
+ * 📚 Full documentation: https://ktw-upfiles-docs.netlify.app/
41
49
  *
42
50
  * @example
43
51
  * ```ts
@@ -57,12 +65,13 @@ type UpfilesClientOptions = {
57
65
  apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
58
66
  thumbnailsPath?: string;
59
67
  completionPath?: string;
68
+ foldersPath?: string;
60
69
  callCompletionEndpoint?: boolean;
61
70
  };
62
71
  /**
63
72
  * UpfilesClient - Main client class for interacting with Upfiles Plugin API
64
73
  *
65
- * 📚 Documentation: https://ttf-upfiles-docs.netlify.app/
74
+ * 📚 Documentation: https://ktw-upfiles-docs.netlify.app/
66
75
  *
67
76
  * @example
68
77
  * ```ts
@@ -84,6 +93,7 @@ declare class UpfilesClient {
84
93
  private apiKeyHeader;
85
94
  private thumbnailsPath;
86
95
  private completionPath;
96
+ private foldersPath;
87
97
  private callCompletionEndpoint;
88
98
  constructor(opts: UpfilesClientOptions);
89
99
  getPresignedUrl(params: {
@@ -106,7 +116,23 @@ declare class UpfilesClient {
106
116
  size: number;
107
117
  contentType: string;
108
118
  projectId?: string;
109
- }): Promise<void>;
119
+ }): Promise<{
120
+ success: boolean;
121
+ file: {
122
+ id: string;
123
+ key: string;
124
+ originalName: string;
125
+ size: number;
126
+ contentType: string;
127
+ url: string;
128
+ uploadedAt: string;
129
+ };
130
+ thumbnails?: Thumbnail[];
131
+ masterWebp?: {
132
+ key: string;
133
+ url: string;
134
+ };
135
+ }>;
110
136
  getThumbnails(fileKey: string): Promise<Thumbnail[]>;
111
137
  generateThumbnails(fileKey: string): Promise<{
112
138
  masterWebp?: {
@@ -115,9 +141,15 @@ declare class UpfilesClient {
115
141
  };
116
142
  thumbnails: Thumbnail[];
117
143
  }>;
144
+ getFolders(parentId?: string): Promise<Folder[]>;
145
+ createFolder(name: string, parentId?: string): Promise<Folder>;
118
146
  getProjectFiles(params?: {
119
147
  folderPath?: string;
120
- }): Promise<FileListItem[]>;
148
+ }): Promise<{
149
+ files: FileListItem[];
150
+ updatedAt: string | null;
151
+ }>;
152
+ getEventsUrl(projectId?: string): string;
121
153
  }
122
154
 
123
155
  type UploaderFile = {
@@ -183,6 +215,7 @@ type ProjectFilesWidgetProps = {
183
215
  onDelete?: (key: string) => Promise<void>;
184
216
  deleteUrl?: string;
185
217
  showDelete?: boolean;
218
+ refreshInterval?: number;
186
219
  };
187
220
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
188
221
 
@@ -237,7 +270,10 @@ declare function connectUsingApiKey(opts: {
237
270
  client: UpfilesClient;
238
271
  };
239
272
 
240
- declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
273
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<{
274
+ files: FileListItem[];
275
+ updatedAt: string | null;
276
+ }>;
241
277
  declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
242
278
  type ImageWithThumbs = FileListItem & {
243
279
  thumbnails?: Thumbnail[];
@@ -245,7 +281,10 @@ type ImageWithThumbs = FileListItem & {
245
281
  declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
246
282
  folderPath?: string;
247
283
  limitConcurrent?: number;
248
- }): Promise<ImageWithThumbs[]>;
284
+ }): Promise<{
285
+ items: ImageWithThumbs[];
286
+ updatedAt: string | null;
287
+ }>;
249
288
 
250
289
  type ImageManagerProps = {
251
290
  open: boolean;
@@ -270,6 +309,13 @@ type ImageManagerProps = {
270
309
  size: number;
271
310
  sizeType?: string;
272
311
  }[];
312
+ selectedThumbnail?: {
313
+ id: string;
314
+ key: string;
315
+ url: string;
316
+ size: number;
317
+ sizeType?: string;
318
+ };
273
319
  }) => void;
274
320
  onDelete?: (key: string) => Promise<void>;
275
321
  deleteUrl?: string;
@@ -279,7 +325,8 @@ type ImageManagerProps = {
279
325
  maxFiles?: number;
280
326
  mode?: 'full' | 'browse' | 'upload';
281
327
  showDelete?: boolean;
328
+ refreshInterval?: number;
282
329
  };
283
330
  declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
284
331
 
285
- 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 };
332
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, type Folder, 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 };