Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DX): added describe the file uploader options #768

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions types/exported.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,59 +24,215 @@ export type CollectionValidators = FuncCollectionValidator[];
export type SourceTypes = import('../blocks/utils/UploadSource').SourceTypes

export type ConfigType = {
/**
* Your project’s Public Key.
*/
pubkey: string;
/**
* Allow multiple file uploads.
*/
multiple: boolean;
/**
* Minimum number of files to upload.
*/
multipleMin: number;
/**
* Maximum number of files to upload.
*/
multipleMax: number;
/**
* Require user confirmation before uploading.
*/
confirmUpload: boolean;
/**
* Allow only image files.
*/
imgOnly: boolean;
/**
* Native file input accept attribute value. Also affects client validation settings.
*/
accept: string;
/**
* Preferred types for external sources.
* See [here](https://uploadcare.com/docs/file-uploader/options/#external-sources-preferred-types)
*/
externalSourcesPreferredTypes: string;
/**
* Store uploaded files.
*/
store: boolean | 'auto';
/**
* Mirror the camera view.
*/
cameraMirror: boolean;
/**
* Default camera capture mode.
*/
cameraCapture: 'user' | 'environment' | '';
/**
* List of sources for file uploads.
*/
sourceList: string;
/**
* Maximum size of local files in bytes.
*/
maxLocalFileSizeBytes: number;
/**
* Thumbnail size.
*/
thumbSize: number;
/**
* Show the upload list even if it is empty.
*/
showEmptyList: boolean;
/**
* Use local image editor.
*/
useLocalImageEditor: boolean;
/**
* Enable cloud image editing.
*/
useCloudImageEditor: boolean;
/**
* Tabs to show in the cloud image editor.
*
* @default 'crop, tuning, filters'
*/
cloudImageEditorTabs: string;
/**
* Remove copyright information.
*/
removeCopyright: boolean;
/**
* Defines the crop behavior. When uploading images, your users can select a crop area with a defined aspect ratio.
*/
cropPreset: string;
/**
* Image shrink options.
*/
imageShrink: string;
/**
* Lock scroll when modal is open.
*/
modalScrollLock: boolean;
/**
* Show strokes on modal backdrop.
*/
modalBackdropStrokes: boolean;
/**
* Wrap the source list.
*/
sourceListWrap: boolean;
/**
* Key to revoke Custom OAuth access. See [OAuth docs](https://uploadcare.com/docs/upload-sources/#oauth) for details.
*/
remoteTabSessionKey: string;
/**
* Set custom CNAME.
*/
cdnCname: string;
/**
* Set a custom upload URL.
*/
baseUrl: string;
/**
* Set a custom social sources URL.
*/
socialBaseUrl: string;
/**
* Secure signature for uploads.
*/
secureSignature: string;
/**
* Expiry time for secure uploads.
*/
secureExpire: string;
Comment on lines +147 to 149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify the type and format of secureExpire property

The secureExpire property is currently typed as string. Please clarify the expected format (e.g., timestamp, ISO date string) and consider using a more specific type such as number (Unix timestamp) to prevent potential misuse.

If secureExpire represents a Unix timestamp, you could change its type to number.

Apply this diff if appropriate:

-      secureExpire: string;
+      secureExpire: number;

Update the documentation:

      /**
       * Expiry time for secure uploads.
+       * Expected to be a Unix timestamp (in seconds).
       */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* Expiry time for secure uploads.
*/
secureExpire: string;
/**
* Expiry time for secure uploads.
* Expected to be a Unix timestamp (in seconds).
*/
secureExpire: number;

/**
* Proxy URL for secure delivery.
*/
secureDeliveryProxy: string;
/**
* Maximum number of retry attempts for throttled requests.
*/
retryThrottledRequestMaxTimes: number;
/**
* Minimum file size for multipart uploads.
*/
multipartMinFileSize: number;
/**
* Chunk size for multipart uploads.
*/
multipartChunkSize: number;
/**
* Maximum number of concurrent requests.
*/
maxConcurrentRequests: number;
/**
* Maximum number of concurrent multipart requests.
*/
multipartMaxConcurrentRequests: number;
/**
* Maximum number of attempts for multipart uploads.
*/
multipartMaxAttempts: number;
/**
* Check for URL duplicates.
*/
checkForUrlDuplicates: boolean;
/**
* Save URL for recurrent uploads.
*/
saveUrlForRecurrentUploads: boolean;
/**
* Group output files.
*/
groupOutput: boolean;
/**
* User agent integration string.
*/
userAgentIntegration: string;
/**
* Enable debug mode.
*/
debug: boolean;
/**
* Locale name for the uploader.
*/
localeName: string;
/**
* Expiry threshold for secure uploads.
*/
secureUploadsExpireThreshold: number;

// Complex types
/**
* Metadata for the file.
*/
metadata: Metadata | MetadataCallback | null;
/**
* Override locale definitions.
*/
localeDefinitionOverride: LocaleDefinitionOverride | null;
/**
* Resolver for secure uploads signature.
*/
secureUploadsSignatureResolver: SecureUploadsSignatureResolver | null;
/**
* Resolver for secure delivery proxy URL.
*/
secureDeliveryProxyUrlResolver: SecureDeliveryProxyUrlResolver | null;
/**
* Resolver for icon href.
*/
iconHrefResolver: IconHrefResolver | null;

/**
* Validators for individual files.
*/
fileValidators: FileValidators;
/**
* Validators for file collections.
*/
collectionValidators: CollectionValidators;

/**
Expand All @@ -85,7 +241,15 @@ export type ConfigType = {
* @default 'photo'
*/
defaultCameraMode: 'photo' | 'video';
/**
* Enable audio recording.
* @default true
*/
enableAudioRecording: boolean;
/**
* Enable video recording.
* @default true
*/
enableVideoRecording: boolean;

/**
Expand Down
Loading