@thetechfossil/upfiles 0.5.0 → 1.0.0

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;
@@ -96,11 +97,16 @@ type UploaderProps = {
96
97
  folderPath?: string;
97
98
  onComplete?: (files: UploaderFile[]) => void;
98
99
  onError?: (error: Error) => void;
100
+ onUploadBegin?: (fileName: string) => void;
101
+ onUploadProgress?: (fileName: string, progress: number) => void;
102
+ onClientUploadComplete?: (file: UploaderFile) => void;
99
103
  className?: string;
100
104
  buttonClassName?: string;
101
105
  dropzoneClassName?: string;
102
106
  children?: React.ReactNode;
103
107
  fetchThumbnails?: boolean;
108
+ autoRecordToDb?: boolean;
109
+ recordUrl?: string;
104
110
  };
105
111
  declare const Uploader: React.FC<UploaderProps>;
106
112
 
@@ -126,7 +132,106 @@ type ProjectFilesWidgetProps = {
126
132
  contentType: string;
127
133
  }) => Promise<void> | void;
128
134
  onSaved?: (result?: any) => void;
135
+ onDelete?: (key: string) => Promise<void>;
136
+ deleteUrl?: string;
137
+ showDelete?: boolean;
129
138
  };
130
139
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
131
140
 
132
- export { type FileListItem, type PresignResponse, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps };
141
+ type ConnectProjectDialogProps = {
142
+ baseUrl: string;
143
+ open: boolean;
144
+ onOpenChange: (open: boolean) => void;
145
+ onConnected: (apiKey: string, meta: {
146
+ projectId?: string;
147
+ source: 'existing' | 'new' | 'manual';
148
+ }) => void;
149
+ fetchImpl?: typeof fetch;
150
+ title?: string;
151
+ description?: string;
152
+ className?: string;
153
+ };
154
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
155
+
156
+ type ConnectOptions = {
157
+ baseUrl: string;
158
+ fetch?: typeof fetch;
159
+ };
160
+ type Project = {
161
+ id: string;
162
+ name: string;
163
+ createdAt?: string;
164
+ };
165
+ declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
166
+ declare function createProject(opts: ConnectOptions & {
167
+ name: string;
168
+ keyName?: string;
169
+ }): Promise<{
170
+ apiKey: string;
171
+ projectId: string;
172
+ }>;
173
+ declare function connectProject(opts: ConnectOptions & {
174
+ projectId: string;
175
+ keyName?: string;
176
+ }): Promise<{
177
+ apiKey: string;
178
+ }>;
179
+ declare function addApiKeyManually(apiKey: string): {
180
+ apiKey: string;
181
+ };
182
+ declare function createClientWithKey(baseUrl: string, apiKey: string): UpfilesClient;
183
+ declare function connectUsingApiKey(opts: {
184
+ baseUrl: string;
185
+ apiKey: string;
186
+ apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
187
+ }): {
188
+ apiKey: string;
189
+ client: UpfilesClient;
190
+ };
191
+
192
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
193
+ declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
194
+ type ImageWithThumbs = FileListItem & {
195
+ thumbnails?: Thumbnail[];
196
+ };
197
+ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
198
+ folderPath?: string;
199
+ limitConcurrent?: number;
200
+ }): Promise<ImageWithThumbs[]>;
201
+
202
+ type ImageManagerProps = {
203
+ open: boolean;
204
+ onOpenChange: (open: boolean) => void;
205
+ clientOptions: UpfilesClientOptions;
206
+ projectId?: string;
207
+ folderPath?: string;
208
+ title?: string;
209
+ description?: string;
210
+ className?: string;
211
+ gridClassName?: string;
212
+ onSelect: (image: {
213
+ url: string;
214
+ key: string;
215
+ originalName: string;
216
+ size: number;
217
+ contentType: string;
218
+ thumbnails?: {
219
+ id: string;
220
+ key: string;
221
+ url: string;
222
+ size: number;
223
+ sizeType?: string;
224
+ }[];
225
+ }) => void;
226
+ onDelete?: (key: string) => Promise<void>;
227
+ deleteUrl?: string;
228
+ autoRecordToDb?: boolean;
229
+ fetchThumbnails?: boolean;
230
+ maxFileSize?: number;
231
+ maxFiles?: number;
232
+ mode?: 'full' | 'browse' | 'upload';
233
+ showDelete?: boolean;
234
+ };
235
+ declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
236
+
237
+ 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;
@@ -96,11 +97,16 @@ type UploaderProps = {
96
97
  folderPath?: string;
97
98
  onComplete?: (files: UploaderFile[]) => void;
98
99
  onError?: (error: Error) => void;
100
+ onUploadBegin?: (fileName: string) => void;
101
+ onUploadProgress?: (fileName: string, progress: number) => void;
102
+ onClientUploadComplete?: (file: UploaderFile) => void;
99
103
  className?: string;
100
104
  buttonClassName?: string;
101
105
  dropzoneClassName?: string;
102
106
  children?: React.ReactNode;
103
107
  fetchThumbnails?: boolean;
108
+ autoRecordToDb?: boolean;
109
+ recordUrl?: string;
104
110
  };
105
111
  declare const Uploader: React.FC<UploaderProps>;
106
112
 
@@ -126,7 +132,106 @@ type ProjectFilesWidgetProps = {
126
132
  contentType: string;
127
133
  }) => Promise<void> | void;
128
134
  onSaved?: (result?: any) => void;
135
+ onDelete?: (key: string) => Promise<void>;
136
+ deleteUrl?: string;
137
+ showDelete?: boolean;
129
138
  };
130
139
  declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
131
140
 
132
- export { type FileListItem, type PresignResponse, ProjectFilesWidget, type ProjectFilesWidgetProps, type Thumbnail, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps };
141
+ type ConnectProjectDialogProps = {
142
+ baseUrl: string;
143
+ open: boolean;
144
+ onOpenChange: (open: boolean) => void;
145
+ onConnected: (apiKey: string, meta: {
146
+ projectId?: string;
147
+ source: 'existing' | 'new' | 'manual';
148
+ }) => void;
149
+ fetchImpl?: typeof fetch;
150
+ title?: string;
151
+ description?: string;
152
+ className?: string;
153
+ };
154
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
155
+
156
+ type ConnectOptions = {
157
+ baseUrl: string;
158
+ fetch?: typeof fetch;
159
+ };
160
+ type Project = {
161
+ id: string;
162
+ name: string;
163
+ createdAt?: string;
164
+ };
165
+ declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
166
+ declare function createProject(opts: ConnectOptions & {
167
+ name: string;
168
+ keyName?: string;
169
+ }): Promise<{
170
+ apiKey: string;
171
+ projectId: string;
172
+ }>;
173
+ declare function connectProject(opts: ConnectOptions & {
174
+ projectId: string;
175
+ keyName?: string;
176
+ }): Promise<{
177
+ apiKey: string;
178
+ }>;
179
+ declare function addApiKeyManually(apiKey: string): {
180
+ apiKey: string;
181
+ };
182
+ declare function createClientWithKey(baseUrl: string, apiKey: string): UpfilesClient;
183
+ declare function connectUsingApiKey(opts: {
184
+ baseUrl: string;
185
+ apiKey: string;
186
+ apiKeyHeader?: 'authorization' | 'x-api-key' | 'x-up-api-key';
187
+ }): {
188
+ apiKey: string;
189
+ client: UpfilesClient;
190
+ };
191
+
192
+ declare function fetchProjectFiles(clientOptions: UpfilesClientOptions, folderPath?: string): Promise<FileListItem[]>;
193
+ declare function fetchFileThumbnails(clientOptions: UpfilesClientOptions, fileKey: string): Promise<Thumbnail[]>;
194
+ type ImageWithThumbs = FileListItem & {
195
+ thumbnails?: Thumbnail[];
196
+ };
197
+ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOptions, opts?: {
198
+ folderPath?: string;
199
+ limitConcurrent?: number;
200
+ }): Promise<ImageWithThumbs[]>;
201
+
202
+ type ImageManagerProps = {
203
+ open: boolean;
204
+ onOpenChange: (open: boolean) => void;
205
+ clientOptions: UpfilesClientOptions;
206
+ projectId?: string;
207
+ folderPath?: string;
208
+ title?: string;
209
+ description?: string;
210
+ className?: string;
211
+ gridClassName?: string;
212
+ onSelect: (image: {
213
+ url: string;
214
+ key: string;
215
+ originalName: string;
216
+ size: number;
217
+ contentType: string;
218
+ thumbnails?: {
219
+ id: string;
220
+ key: string;
221
+ url: string;
222
+ size: number;
223
+ sizeType?: string;
224
+ }[];
225
+ }) => void;
226
+ onDelete?: (key: string) => Promise<void>;
227
+ deleteUrl?: string;
228
+ autoRecordToDb?: boolean;
229
+ fetchThumbnails?: boolean;
230
+ maxFileSize?: number;
231
+ maxFiles?: number;
232
+ mode?: 'full' | 'browse' | 'upload';
233
+ showDelete?: boolean;
234
+ };
235
+ declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
236
+
237
+ 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 };