apply feedback

This commit is contained in:
prakash 2026-06-24 16:43:31 +05:30
parent 439787021b
commit 1f4b8e187c
No known key found for this signature in database
3 changed files with 34 additions and 10 deletions

View file

@ -177,7 +177,19 @@ export type UnknownProviderPlugin<
BaseProviderPlugin & {
rootFolderId: string | null
files: UppyFile<M, B>[]
provider: Provider<M, B>
// Structural subset of the real `Provider` class,structural rather than the nominal class type so custom
// providers matching the public surface aren't forced to inherit from `Provider`.
provider: Pick<
Provider<M, B>,
| 'name'
| 'provider'
| 'login'
| 'logout'
| 'fetchPreAuthToken'
| 'fileUrl'
| 'list'
| 'search'
>
view: ProviderView<M, B>
}
@ -199,7 +211,11 @@ export type UnknownSearchProviderPlugin<
B extends Body,
> = UnknownPlugin<M, B, UnknownSearchProviderPluginState> &
BaseProviderPlugin & {
provider: SearchProvider<M, B>
// Structural subset of the real `SearchProvider` class (see note above).
provider: Pick<
SearchProvider<M, B>,
'name' | 'provider' | 'fileUrl' | 'search'
>
}
// for better readability

View file

@ -1,6 +1,8 @@
import type Provider from '../../companion-client/Provider.js'
import type SearchProvider from '../../companion-client/SearchProvider.js'
import type { UnknownPlugin } from '../../index.js'
import type {
UnknownPlugin,
UnknownProviderPlugin,
UnknownSearchProviderPlugin,
} from '../../index.js'
import type {
Body,
CompanionFile,
@ -13,7 +15,9 @@ import companionFileToUppyFile from './companionFileToUppyFile.js'
const addFiles = <M extends Meta, B extends Body>(
companionFiles: CompanionFile[],
plugin: UnknownPlugin<M, B>,
provider: Provider<M, B> | SearchProvider<M, B>,
provider:
| UnknownProviderPlugin<M, B>['provider']
| UnknownSearchProviderPlugin<M, B>['provider'],
): void => {
const uppyFiles = companionFiles.map((f) =>
companionFileToUppyFile<M, B>(f, plugin, provider),

View file

@ -1,6 +1,8 @@
import type Provider from '../../companion-client/Provider.js'
import type SearchProvider from '../../companion-client/SearchProvider.js'
import type { UnknownPlugin } from '../../index.js'
import type {
UnknownPlugin,
UnknownProviderPlugin,
UnknownSearchProviderPlugin,
} from '../../index.js'
import type {
Body,
CompanionFile,
@ -11,7 +13,9 @@ import type {
const companionFileToUppyFile = <M extends Meta, B extends Body>(
file: CompanionFile,
plugin: UnknownPlugin<M, B>,
provider: Provider<M, B> | SearchProvider<M, B>,
provider:
| UnknownProviderPlugin<M, B>['provider']
| UnknownSearchProviderPlugin<M, B>['provider'],
): RemoteUppyFile<M, B> => {
const name = file.name || file.id