@thetechfossil/upfiles 1.0.12 → 1.0.13

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
@@ -110,7 +110,7 @@ export default function Page() {
110
110
  // clientOptions={{
111
111
  // baseUrl: 'https://YOUR_APP_HOST',
112
112
  // // or presignUrl: 'https://YOUR_APP_HOST/api/plugin/upload/presigned-url',
113
- // apiKey: process.env.NEXT_PUBLIC_UPFILES_API_KEY!,
113
+ // apiKey: process.env.UPFILES_API_KEY!,
114
114
  // apiKeyHeader: 'authorization', // or 'x-api-key' | 'x-up-api-key'
115
115
  // }}
116
116
  />
@@ -130,7 +130,7 @@ const client = new UpfilesClient({
130
130
  // presignPath: '/api/plugin/upload/presigned-url', // default
131
131
  // withCredentials: true, // for session routes (not typical for Plugin API)
132
132
  // Provide API key for Plugin API auth:
133
- // apiKey: 'upk_...'
133
+ // apiKey: 'upf_...'
134
134
  // apiKeyHeader: 'authorization' // or 'x-api-key' | 'x-up-api-key'
135
135
  });
136
136
 
@@ -154,8 +154,8 @@ async function upload(file) {
154
154
  - `baseUrl` (optional): API base origin. Used with `presignPath`.
155
155
  - `presignPath` (optional): relative path, default `/api/plugin/upload/presigned-url`.
156
156
  - `headers` (optional): extra headers to send.
157
- - `apiKey` (optional): API key value (e.g., `upk_...`).
158
- - `apiKeyHeader` (optional): one of `'authorization' | 'x-api-key' | 'x-up-api-key'` (default `'authorization'`). If `'authorization'`, `Bearer` prefix is auto-added for `upk_...`.
157
+ - `apiKey` (optional): API key value (e.g., `upf_...`).
158
+ - `apiKeyHeader` (optional): one of `'authorization' | 'x-api-key' | 'x-up-api-key'` (default `'authorization'`). If `'authorization'`, `Bearer` prefix is auto-added for `upf_...`.
159
159
  - `withCredentials` (optional): `true` to send cookies.
160
160
  - Defaults: same-origin requests to `/api/plugin/upload/presigned-url`.
161
161
  - `client.getPresignedUrl({ fileName, fileType, fileSize, projectId?, folderPath? })`
@@ -195,7 +195,7 @@ import { UpfilesClient } from '@thetechfossil/upfiles';
195
195
 
196
196
  const client = new UpfilesClient({
197
197
  baseUrl: 'https://YOUR_APP_HOST',
198
- apiKey: 'upk_...',
198
+ apiKey: 'upf_...',
199
199
  thumbnailsPath: '/api/plugin/thumbnails', // used to derive /api/plugin/files
200
200
  });
201
201
 
@@ -215,7 +215,7 @@ export default function PickFile() {
215
215
  <ProjectFilesWidget
216
216
  clientOptions={{
217
217
  baseUrl: 'https://YOUR_APP_HOST',
218
- apiKey: process.env.NEXT_PUBLIC_UPFILES_API_KEY!,
218
+ apiKey: process.env.UPFILES_API_KEY!,
219
219
  apiKeyHeader: 'authorization',
220
220
  thumbnailsPath: '/api/plugin/thumbnails',
221
221
  }}
@@ -366,7 +366,7 @@ const { apiKey, projectId } = await createProject({ baseUrl, name: 'My App' });
366
366
  const key2 = await connectProject({ baseUrl, projectId: 'proj_123' });
367
367
 
368
368
  // 4) Manual
369
- const manual = addApiKeyManually('upk_...');
369
+ const manual = addApiKeyManually('upf_...');
370
370
 
371
371
  // 5) Build an upload client with the key
372
372
  const client = createClientWithKey(baseUrl, apiKey);
@@ -425,7 +425,7 @@ export default function PickImage() {
425
425
  mode="browse"
426
426
  clientOptions={{
427
427
  baseUrl: process.env.NEXT_PUBLIC_UPFILES_APP_URL!,
428
- apiKey: process.env.NEXT_PUBLIC_UPFILES_API_KEY!,
428
+ apiKey: process.env.UPFILES_API_KEY!,
429
429
  apiKeyHeader: 'authorization',
430
430
  }}
431
431
  // folderPath="my-plugin/images/" // optional
@@ -454,4 +454,4 @@ export default function PickImage() {
454
454
  - __401 Unauthorized when listing/creating projects__: The `projects` and `keys` endpoints require a signed-in session on the main app domain. Open the dialog from a page that can send cookies to `{baseUrl}` or run from the same origin; otherwise configure auth/CORS accordingly.
455
455
  - __CORS errors calling main app__: Ensure the main app allows your consumer origin in CORS and, if you use cookies, sets the correct `Access-Control-Allow-Credentials` headers and SameSite attributes.
456
456
  - __Uploads fail__: Verify S3 bucket CORS and that `POST /api/plugin/upload/presigned-url` is accessible from the consumer app.
457
- - __API key header__: Default is `Authorization: Bearer upk_...`. If your server expects a different header, set `apiKeyHeader: 'x-api-key' | 'x-up-api-key'` in `UpfilesClient` options.
457
+ - __API key header__: Default is `Authorization: Bearer upf_...`. If your server expects a different header, set `apiKeyHeader: 'x-api-key' | 'x-up-api-key'` in `UpfilesClient` options.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,25 @@
1
- import React from 'react';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
3
 
4
+ type QuotaInfo = {
5
+ limitBytes: number;
6
+ usedBytes: number;
7
+ remainingBytes: number;
8
+ };
9
+ declare class StorageQuotaError extends Error {
10
+ details?: {
11
+ limit: number;
12
+ used: number;
13
+ remaining: number;
14
+ fileSize: number;
15
+ };
16
+ constructor(message: string, details?: {
17
+ limit: number;
18
+ used: number;
19
+ remaining: number;
20
+ fileSize: number;
21
+ });
22
+ }
4
23
  type PresignResponse = {
5
24
  presignedUrl: string;
6
25
  fileKey: string;
@@ -51,7 +70,7 @@ type FileListItem = {
51
70
  * ```ts
52
71
  * const client = new UpfilesClient({
53
72
  * baseUrl: 'https://your-upfiles.example.com',
54
- * apiKey: 'upk_...',
73
+ * apiKey: 'upf_...',
55
74
  * });
56
75
  * ```
57
76
  */
@@ -67,6 +86,12 @@ type UpfilesClientOptions = {
67
86
  completionPath?: string;
68
87
  foldersPath?: string;
69
88
  callCompletionEndpoint?: boolean;
89
+ /** Dynamic token getter for JWT-based auth (inhouse mode). Called on each request for fresh token. Takes priority over apiKey. */
90
+ getToken?: () => string | null | undefined | Promise<string | null | undefined>;
91
+ /** Project ID sent as x-project-id header when using getToken (JWT auth) */
92
+ projectId?: string;
93
+ /** Project name sent as x-project-name in in-house mode so the browser does not need the project id. */
94
+ projectName?: string;
70
95
  };
71
96
  /**
72
97
  * UpfilesClient - Main client class for interacting with Upfiles Plugin API
@@ -77,7 +102,7 @@ type UpfilesClientOptions = {
77
102
  * ```ts
78
103
  * const client = new UpfilesClient({
79
104
  * baseUrl: 'https://your-upfiles.example.com',
80
- * apiKey: 'upk_...',
105
+ * apiKey: 'upf_...',
81
106
  * });
82
107
  *
83
108
  * const result = await client.upload(file, { folderPath: 'uploads/' });
@@ -95,7 +120,14 @@ declare class UpfilesClient {
95
120
  private completionPath;
96
121
  private foldersPath;
97
122
  private callCompletionEndpoint;
123
+ private getToken?;
124
+ private projectId?;
125
+ private projectName?;
98
126
  constructor(opts: UpfilesClientOptions);
127
+ /** Build auth headers for API requests. Priority: getToken (JWT) > apiKey > static headers */
128
+ private buildAuthHeaders;
129
+ /** Get storage quota info for the project */
130
+ getQuota(): Promise<QuotaInfo>;
99
131
  getPresignedUrl(params: {
100
132
  fileName: string;
101
133
  fileType: string;
@@ -109,6 +141,7 @@ declare class UpfilesClient {
109
141
  folderPath?: string;
110
142
  fetchThumbnails?: boolean;
111
143
  callCompletionEndpoint?: boolean;
144
+ userId?: string;
112
145
  }): Promise<UploadedFileResult>;
113
146
  completeUpload(params: {
114
147
  fileKey: string;
@@ -116,6 +149,8 @@ declare class UpfilesClient {
116
149
  size: number;
117
150
  contentType: string;
118
151
  projectId?: string;
152
+ url?: string;
153
+ userId?: string;
119
154
  }): Promise<{
120
155
  success: boolean;
121
156
  file: {
@@ -134,13 +169,26 @@ declare class UpfilesClient {
134
169
  };
135
170
  }>;
136
171
  getThumbnails(fileKey: string): Promise<Thumbnail[]>;
137
- generateThumbnails(fileKey: string): Promise<{
172
+ generateThumbnails(fileKey: string, sizes?: number[]): Promise<{
138
173
  masterWebp?: {
139
174
  key: string;
140
175
  url: string;
141
176
  };
142
177
  thumbnails: Thumbnail[];
143
178
  }>;
179
+ /** Get thumbnail settings for the project (requires API key) */
180
+ getThumbnailSettings(): Promise<{
181
+ enabled: boolean;
182
+ sizes: number[];
183
+ }>;
184
+ /** Update thumbnail settings for the project (requires API key with write scope) */
185
+ updateThumbnailSettings(settings: {
186
+ enabled?: boolean;
187
+ sizes?: number[];
188
+ }): Promise<{
189
+ enabled: boolean;
190
+ sizes: number[];
191
+ }>;
144
192
  getFolders(parentId?: string): Promise<Folder[]>;
145
193
  createFolder(name: string, parentId?: string): Promise<Folder>;
146
194
  getProjectFiles(params?: {
@@ -165,6 +213,10 @@ type UploaderFile = {
165
213
  fileKey?: string;
166
214
  projectId?: string;
167
215
  apiKeyId?: string;
216
+ /** Whether thumbnails should be generated for this file (set from per-file selection) */
217
+ thumbnailEnabled?: boolean;
218
+ /** Which thumbnail sizes were selected for this file */
219
+ thumbnailSizesSelected?: number[];
168
220
  };
169
221
  type UploaderProps = {
170
222
  clientOptions?: UpfilesClientOptions;
@@ -173,6 +225,7 @@ type UploaderProps = {
173
225
  maxFileSize?: number;
174
226
  maxFiles?: number;
175
227
  projectId?: string;
228
+ userId?: string;
176
229
  folderPath?: string;
177
230
  onComplete?: (files: UploaderFile[]) => void;
178
231
  onError?: (error: Error) => void;
@@ -182,13 +235,20 @@ type UploaderProps = {
182
235
  className?: string;
183
236
  buttonClassName?: string;
184
237
  dropzoneClassName?: string;
185
- children?: React.ReactNode;
238
+ children?: React__default.ReactNode;
186
239
  fetchThumbnails?: boolean;
187
240
  autoRecordToDb?: boolean;
188
241
  recordUrl?: string;
189
242
  autoUpload?: boolean;
243
+ /**
244
+ * If defined, show the per-image thumbnail configuration panel.
245
+ * Value is the initial enabled state (default: true when panel is shown).
246
+ */
247
+ thumbnailEnabled?: boolean;
248
+ /** Default thumbnail sizes to generate. Supported: 64, 128, 256, 512. Default: [256, 512] */
249
+ thumbnailSizes?: number[];
190
250
  };
191
- declare const Uploader: React.FC<UploaderProps>;
251
+ declare const Uploader: React__default.FC<UploaderProps>;
192
252
 
193
253
  type ProjectFilesWidgetProps = {
194
254
  clientOptions: UpfilesClientOptions;
@@ -217,7 +277,7 @@ type ProjectFilesWidgetProps = {
217
277
  showDelete?: boolean;
218
278
  refreshInterval?: number;
219
279
  };
220
- declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
280
+ declare const ProjectFilesWidget: React__default.FC<ProjectFilesWidgetProps>;
221
281
 
222
282
  type ConnectProjectDialogProps = {
223
283
  baseUrl: string;
@@ -232,11 +292,12 @@ type ConnectProjectDialogProps = {
232
292
  description?: string;
233
293
  className?: string;
234
294
  };
235
- declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
295
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): React.JSX.Element;
236
296
 
237
297
  type ConnectOptions = {
238
298
  baseUrl: string;
239
299
  fetch?: typeof fetch;
300
+ token?: string;
240
301
  };
241
302
  type Project = {
242
303
  id: string;
@@ -245,12 +306,25 @@ type Project = {
245
306
  };
246
307
  declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
247
308
  declare function createProject(opts: ConnectOptions & {
309
+ name: string;
310
+ isInHouse?: boolean;
311
+ freeStorageLimitBytes?: number;
312
+ }): Promise<{
313
+ projectId: string;
314
+ project: Project | undefined;
315
+ }>;
316
+ declare function createProjectWithApiKey(opts: ConnectOptions & {
248
317
  name: string;
249
318
  keyName?: string;
250
319
  }): Promise<{
251
320
  apiKey: string;
252
321
  projectId: string;
253
322
  }>;
323
+ declare function updateProject(opts: ConnectOptions & {
324
+ projectId: string;
325
+ isInHouse?: boolean;
326
+ freeStorageLimitBytes?: number;
327
+ }): Promise<void>;
254
328
  declare function connectProject(opts: ConnectOptions & {
255
329
  projectId: string;
256
330
  keyName?: string;
@@ -286,12 +360,19 @@ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOption
286
360
  updatedAt: string | null;
287
361
  }>;
288
362
 
363
+ type ThumbnailConfig = {
364
+ /** Whether thumbnail generation is enabled (default: true) */
365
+ enabled?: boolean;
366
+ /** Pixel sizes to generate. Supported: 64, 128, 256, 512. Default: [256, 512] */
367
+ sizes?: number[];
368
+ };
289
369
  type ImageManagerProps = {
290
370
  open: boolean;
291
371
  onOpenChange: (open: boolean) => void;
292
372
  clientOptions: UpfilesClientOptions;
293
373
  projectId?: string;
294
374
  folderPath?: string;
375
+ userId?: string;
295
376
  title?: string;
296
377
  description?: string;
297
378
  className?: string;
@@ -326,7 +407,42 @@ type ImageManagerProps = {
326
407
  mode?: 'full' | 'browse' | 'upload';
327
408
  showDelete?: boolean;
328
409
  refreshInterval?: number;
410
+ stayOnUploadAfterComplete?: boolean;
411
+ /** Thumbnail generation config. Users can override per-upload in the upload panel. */
412
+ thumbnailConfig?: ThumbnailConfig;
413
+ };
414
+ declare function ImageManager(props: ImageManagerProps): React.JSX.Element;
415
+
416
+ type InhouseConfig = {
417
+ /** Upfiles backend base URL (e.g., http://localhost:4021) */
418
+ baseUrl: string;
419
+ /** Function returning the current JWT token, or a token string directly */
420
+ getToken: (() => string | null | undefined | Promise<string | null | undefined>) | string | null | undefined;
421
+ /** Current user ID. Required before in-house provisioning starts. */
422
+ userId: string | null | undefined;
423
+ /** Project name to auto-create (default: 'default') */
424
+ projectName?: string;
425
+ /** @deprecated In-house project data is no longer cached in browser storage. */
426
+ cachePrefix?: string;
427
+ /** Whether to enable auto-connect (default: true) */
428
+ enabled?: boolean;
429
+ };
430
+ type InhouseResult = {
431
+ /** Ready-to-use UpfilesClientOptions for ImageManager, Uploader, etc. */
432
+ clientOptions: UpfilesClientOptions | null;
433
+ /** Project ID is intentionally not exposed in secure in-house mode. */
434
+ projectId: string | null;
435
+ /** Whether the hook is currently provisioning */
436
+ loading: boolean;
437
+ /** Error message if provisioning failed */
438
+ error: string | null;
439
+ /** Whether credentials are ready to use */
440
+ isReady: boolean;
441
+ /** Force re-provision. */
442
+ retry: () => void;
443
+ /** Clear in-memory credentials. */
444
+ clearCache: () => void;
329
445
  };
330
- declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
446
+ declare function useUpfilesInhouse(config: InhouseConfig): InhouseResult;
331
447
 
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 };
448
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, type Folder, ImageManager, type ImageManagerProps, type ImageWithThumbs, type InhouseConfig, type InhouseResult, type PresignResponse, type Project, ProjectFilesWidget, type ProjectFilesWidgetProps, type QuotaInfo, StorageQuotaError, type Thumbnail, type ThumbnailConfig, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps, addApiKeyManually, connectProject, connectUsingApiKey, createClientWithKey, createProject, createProjectWithApiKey, fetchFileThumbnails, fetchProjectFiles, fetchProjectImagesWithThumbs, listProjects, updateProject, useUpfilesInhouse };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,25 @@
1
- import React from 'react';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
3
 
4
+ type QuotaInfo = {
5
+ limitBytes: number;
6
+ usedBytes: number;
7
+ remainingBytes: number;
8
+ };
9
+ declare class StorageQuotaError extends Error {
10
+ details?: {
11
+ limit: number;
12
+ used: number;
13
+ remaining: number;
14
+ fileSize: number;
15
+ };
16
+ constructor(message: string, details?: {
17
+ limit: number;
18
+ used: number;
19
+ remaining: number;
20
+ fileSize: number;
21
+ });
22
+ }
4
23
  type PresignResponse = {
5
24
  presignedUrl: string;
6
25
  fileKey: string;
@@ -51,7 +70,7 @@ type FileListItem = {
51
70
  * ```ts
52
71
  * const client = new UpfilesClient({
53
72
  * baseUrl: 'https://your-upfiles.example.com',
54
- * apiKey: 'upk_...',
73
+ * apiKey: 'upf_...',
55
74
  * });
56
75
  * ```
57
76
  */
@@ -67,6 +86,12 @@ type UpfilesClientOptions = {
67
86
  completionPath?: string;
68
87
  foldersPath?: string;
69
88
  callCompletionEndpoint?: boolean;
89
+ /** Dynamic token getter for JWT-based auth (inhouse mode). Called on each request for fresh token. Takes priority over apiKey. */
90
+ getToken?: () => string | null | undefined | Promise<string | null | undefined>;
91
+ /** Project ID sent as x-project-id header when using getToken (JWT auth) */
92
+ projectId?: string;
93
+ /** Project name sent as x-project-name in in-house mode so the browser does not need the project id. */
94
+ projectName?: string;
70
95
  };
71
96
  /**
72
97
  * UpfilesClient - Main client class for interacting with Upfiles Plugin API
@@ -77,7 +102,7 @@ type UpfilesClientOptions = {
77
102
  * ```ts
78
103
  * const client = new UpfilesClient({
79
104
  * baseUrl: 'https://your-upfiles.example.com',
80
- * apiKey: 'upk_...',
105
+ * apiKey: 'upf_...',
81
106
  * });
82
107
  *
83
108
  * const result = await client.upload(file, { folderPath: 'uploads/' });
@@ -95,7 +120,14 @@ declare class UpfilesClient {
95
120
  private completionPath;
96
121
  private foldersPath;
97
122
  private callCompletionEndpoint;
123
+ private getToken?;
124
+ private projectId?;
125
+ private projectName?;
98
126
  constructor(opts: UpfilesClientOptions);
127
+ /** Build auth headers for API requests. Priority: getToken (JWT) > apiKey > static headers */
128
+ private buildAuthHeaders;
129
+ /** Get storage quota info for the project */
130
+ getQuota(): Promise<QuotaInfo>;
99
131
  getPresignedUrl(params: {
100
132
  fileName: string;
101
133
  fileType: string;
@@ -109,6 +141,7 @@ declare class UpfilesClient {
109
141
  folderPath?: string;
110
142
  fetchThumbnails?: boolean;
111
143
  callCompletionEndpoint?: boolean;
144
+ userId?: string;
112
145
  }): Promise<UploadedFileResult>;
113
146
  completeUpload(params: {
114
147
  fileKey: string;
@@ -116,6 +149,8 @@ declare class UpfilesClient {
116
149
  size: number;
117
150
  contentType: string;
118
151
  projectId?: string;
152
+ url?: string;
153
+ userId?: string;
119
154
  }): Promise<{
120
155
  success: boolean;
121
156
  file: {
@@ -134,13 +169,26 @@ declare class UpfilesClient {
134
169
  };
135
170
  }>;
136
171
  getThumbnails(fileKey: string): Promise<Thumbnail[]>;
137
- generateThumbnails(fileKey: string): Promise<{
172
+ generateThumbnails(fileKey: string, sizes?: number[]): Promise<{
138
173
  masterWebp?: {
139
174
  key: string;
140
175
  url: string;
141
176
  };
142
177
  thumbnails: Thumbnail[];
143
178
  }>;
179
+ /** Get thumbnail settings for the project (requires API key) */
180
+ getThumbnailSettings(): Promise<{
181
+ enabled: boolean;
182
+ sizes: number[];
183
+ }>;
184
+ /** Update thumbnail settings for the project (requires API key with write scope) */
185
+ updateThumbnailSettings(settings: {
186
+ enabled?: boolean;
187
+ sizes?: number[];
188
+ }): Promise<{
189
+ enabled: boolean;
190
+ sizes: number[];
191
+ }>;
144
192
  getFolders(parentId?: string): Promise<Folder[]>;
145
193
  createFolder(name: string, parentId?: string): Promise<Folder>;
146
194
  getProjectFiles(params?: {
@@ -165,6 +213,10 @@ type UploaderFile = {
165
213
  fileKey?: string;
166
214
  projectId?: string;
167
215
  apiKeyId?: string;
216
+ /** Whether thumbnails should be generated for this file (set from per-file selection) */
217
+ thumbnailEnabled?: boolean;
218
+ /** Which thumbnail sizes were selected for this file */
219
+ thumbnailSizesSelected?: number[];
168
220
  };
169
221
  type UploaderProps = {
170
222
  clientOptions?: UpfilesClientOptions;
@@ -173,6 +225,7 @@ type UploaderProps = {
173
225
  maxFileSize?: number;
174
226
  maxFiles?: number;
175
227
  projectId?: string;
228
+ userId?: string;
176
229
  folderPath?: string;
177
230
  onComplete?: (files: UploaderFile[]) => void;
178
231
  onError?: (error: Error) => void;
@@ -182,13 +235,20 @@ type UploaderProps = {
182
235
  className?: string;
183
236
  buttonClassName?: string;
184
237
  dropzoneClassName?: string;
185
- children?: React.ReactNode;
238
+ children?: React__default.ReactNode;
186
239
  fetchThumbnails?: boolean;
187
240
  autoRecordToDb?: boolean;
188
241
  recordUrl?: string;
189
242
  autoUpload?: boolean;
243
+ /**
244
+ * If defined, show the per-image thumbnail configuration panel.
245
+ * Value is the initial enabled state (default: true when panel is shown).
246
+ */
247
+ thumbnailEnabled?: boolean;
248
+ /** Default thumbnail sizes to generate. Supported: 64, 128, 256, 512. Default: [256, 512] */
249
+ thumbnailSizes?: number[];
190
250
  };
191
- declare const Uploader: React.FC<UploaderProps>;
251
+ declare const Uploader: React__default.FC<UploaderProps>;
192
252
 
193
253
  type ProjectFilesWidgetProps = {
194
254
  clientOptions: UpfilesClientOptions;
@@ -217,7 +277,7 @@ type ProjectFilesWidgetProps = {
217
277
  showDelete?: boolean;
218
278
  refreshInterval?: number;
219
279
  };
220
- declare const ProjectFilesWidget: React.FC<ProjectFilesWidgetProps>;
280
+ declare const ProjectFilesWidget: React__default.FC<ProjectFilesWidgetProps>;
221
281
 
222
282
  type ConnectProjectDialogProps = {
223
283
  baseUrl: string;
@@ -232,11 +292,12 @@ type ConnectProjectDialogProps = {
232
292
  description?: string;
233
293
  className?: string;
234
294
  };
235
- declare function ConnectProjectDialog(props: ConnectProjectDialogProps): react_jsx_runtime.JSX.Element;
295
+ declare function ConnectProjectDialog(props: ConnectProjectDialogProps): React.JSX.Element;
236
296
 
237
297
  type ConnectOptions = {
238
298
  baseUrl: string;
239
299
  fetch?: typeof fetch;
300
+ token?: string;
240
301
  };
241
302
  type Project = {
242
303
  id: string;
@@ -245,12 +306,25 @@ type Project = {
245
306
  };
246
307
  declare function listProjects(opts: ConnectOptions): Promise<Project[]>;
247
308
  declare function createProject(opts: ConnectOptions & {
309
+ name: string;
310
+ isInHouse?: boolean;
311
+ freeStorageLimitBytes?: number;
312
+ }): Promise<{
313
+ projectId: string;
314
+ project: Project | undefined;
315
+ }>;
316
+ declare function createProjectWithApiKey(opts: ConnectOptions & {
248
317
  name: string;
249
318
  keyName?: string;
250
319
  }): Promise<{
251
320
  apiKey: string;
252
321
  projectId: string;
253
322
  }>;
323
+ declare function updateProject(opts: ConnectOptions & {
324
+ projectId: string;
325
+ isInHouse?: boolean;
326
+ freeStorageLimitBytes?: number;
327
+ }): Promise<void>;
254
328
  declare function connectProject(opts: ConnectOptions & {
255
329
  projectId: string;
256
330
  keyName?: string;
@@ -286,12 +360,19 @@ declare function fetchProjectImagesWithThumbs(clientOptions: UpfilesClientOption
286
360
  updatedAt: string | null;
287
361
  }>;
288
362
 
363
+ type ThumbnailConfig = {
364
+ /** Whether thumbnail generation is enabled (default: true) */
365
+ enabled?: boolean;
366
+ /** Pixel sizes to generate. Supported: 64, 128, 256, 512. Default: [256, 512] */
367
+ sizes?: number[];
368
+ };
289
369
  type ImageManagerProps = {
290
370
  open: boolean;
291
371
  onOpenChange: (open: boolean) => void;
292
372
  clientOptions: UpfilesClientOptions;
293
373
  projectId?: string;
294
374
  folderPath?: string;
375
+ userId?: string;
295
376
  title?: string;
296
377
  description?: string;
297
378
  className?: string;
@@ -326,7 +407,42 @@ type ImageManagerProps = {
326
407
  mode?: 'full' | 'browse' | 'upload';
327
408
  showDelete?: boolean;
328
409
  refreshInterval?: number;
410
+ stayOnUploadAfterComplete?: boolean;
411
+ /** Thumbnail generation config. Users can override per-upload in the upload panel. */
412
+ thumbnailConfig?: ThumbnailConfig;
413
+ };
414
+ declare function ImageManager(props: ImageManagerProps): React.JSX.Element;
415
+
416
+ type InhouseConfig = {
417
+ /** Upfiles backend base URL (e.g., http://localhost:4021) */
418
+ baseUrl: string;
419
+ /** Function returning the current JWT token, or a token string directly */
420
+ getToken: (() => string | null | undefined | Promise<string | null | undefined>) | string | null | undefined;
421
+ /** Current user ID. Required before in-house provisioning starts. */
422
+ userId: string | null | undefined;
423
+ /** Project name to auto-create (default: 'default') */
424
+ projectName?: string;
425
+ /** @deprecated In-house project data is no longer cached in browser storage. */
426
+ cachePrefix?: string;
427
+ /** Whether to enable auto-connect (default: true) */
428
+ enabled?: boolean;
429
+ };
430
+ type InhouseResult = {
431
+ /** Ready-to-use UpfilesClientOptions for ImageManager, Uploader, etc. */
432
+ clientOptions: UpfilesClientOptions | null;
433
+ /** Project ID is intentionally not exposed in secure in-house mode. */
434
+ projectId: string | null;
435
+ /** Whether the hook is currently provisioning */
436
+ loading: boolean;
437
+ /** Error message if provisioning failed */
438
+ error: string | null;
439
+ /** Whether credentials are ready to use */
440
+ isReady: boolean;
441
+ /** Force re-provision. */
442
+ retry: () => void;
443
+ /** Clear in-memory credentials. */
444
+ clearCache: () => void;
329
445
  };
330
- declare function ImageManager(props: ImageManagerProps): react_jsx_runtime.JSX.Element;
446
+ declare function useUpfilesInhouse(config: InhouseConfig): InhouseResult;
331
447
 
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 };
448
+ export { type ConnectOptions, ConnectProjectDialog, type ConnectProjectDialogProps, type FileListItem, type Folder, ImageManager, type ImageManagerProps, type ImageWithThumbs, type InhouseConfig, type InhouseResult, type PresignResponse, type Project, ProjectFilesWidget, type ProjectFilesWidgetProps, type QuotaInfo, StorageQuotaError, type Thumbnail, type ThumbnailConfig, UpfilesClient, type UpfilesClientOptions, type UploadedFileResult, Uploader, type UploaderFile, type UploaderProps, addApiKeyManually, connectProject, connectUsingApiKey, createClientWithKey, createProject, createProjectWithApiKey, fetchFileThumbnails, fetchProjectFiles, fetchProjectImagesWithThumbs, listProjects, updateProject, useUpfilesInhouse };