@thetechfossil/upfiles 1.0.9 → 1.0.11
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 +8 -0
- package/dist/index.d.mts +45 -5
- package/dist/index.d.ts +45 -5
- package/dist/index.js +731 -250
- package/dist/index.mjs +732 -251
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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;
|
|
@@ -57,6 +65,7 @@ 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
|
/**
|
|
@@ -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<
|
|
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<
|
|
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<
|
|
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<
|
|
284
|
+
}): Promise<{
|
|
285
|
+
items: ImageWithThumbs[];
|
|
286
|
+
updatedAt: string | null;
|
|
287
|
+
}>;
|
|
249
288
|
|
|
250
289
|
type ImageManagerProps = {
|
|
251
290
|
open: boolean;
|
|
@@ -279,7 +318,8 @@ type ImageManagerProps = {
|
|
|
279
318
|
maxFiles?: number;
|
|
280
319
|
mode?: 'full' | 'browse' | 'upload';
|
|
281
320
|
showDelete?: boolean;
|
|
321
|
+
refreshInterval?: number;
|
|
282
322
|
};
|
|
283
323
|
declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
|
|
284
324
|
|
|
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 };
|
|
325
|
+
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;
|
|
@@ -57,6 +65,7 @@ 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
|
/**
|
|
@@ -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<
|
|
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<
|
|
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<
|
|
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<
|
|
284
|
+
}): Promise<{
|
|
285
|
+
items: ImageWithThumbs[];
|
|
286
|
+
updatedAt: string | null;
|
|
287
|
+
}>;
|
|
249
288
|
|
|
250
289
|
type ImageManagerProps = {
|
|
251
290
|
open: boolean;
|
|
@@ -279,7 +318,8 @@ type ImageManagerProps = {
|
|
|
279
318
|
maxFiles?: number;
|
|
280
319
|
mode?: 'full' | 'browse' | 'upload';
|
|
281
320
|
showDelete?: boolean;
|
|
321
|
+
refreshInterval?: number;
|
|
282
322
|
};
|
|
283
323
|
declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
|
|
284
324
|
|
|
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 };
|
|
325
|
+
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 };
|