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

@uppy/url: migrate to TS #4980

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 5 additions & 32 deletions packages/@uppy/provider-views/src/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,12 @@ import type {
UnknownProviderPlugin,
UnknownSearchProviderPlugin,
} from '@uppy/core/lib/Uppy'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Body, Meta, TagFile } from '@uppy/utils/lib/UppyFile'
import type { CompanionFile } from '@uppy/utils/lib/CompanionFile'
import getFileType from '@uppy/utils/lib/getFileType'
import isPreviewSupported from '@uppy/utils/lib/isPreviewSupported'
import remoteFileObjToLocal from '@uppy/utils/lib/remoteFileObjToLocal'

type TagFile<M extends Meta> = {
id: string
source: string
data: Blob
name: string
type: string
isRemote: boolean
preview?: string
meta: {
authorName?: string
authorUrl?: string
relativePath?: string | null
absolutePath?: string
} & M
remote: {
companionUrl: string
url: string
body: {
fileId: string
}
providerName: string
provider: string
requestClientId: string
}
}

type PluginType = 'Provider' | 'SearchProvider'

// Conditional type for selecting the plugin
Expand Down Expand Up @@ -155,7 +129,6 @@ export default class View<
name: file.name || file.id,
type: file.mimeType,
isRemote: true,
// @ts-expect-error meta is filled conditionally below
data: file,
// @ts-expect-error meta is filled conditionally below
meta: {},
Expand Down Expand Up @@ -184,17 +157,17 @@ export default class View<

if (file.author) {
if (file.author.name != null)
tagFile.meta.authorName = String(file.author.name)
if (file.author.url) tagFile.meta.authorUrl = file.author.url
tagFile.meta!.authorName = String(file.author.name)
if (file.author.url) tagFile.meta!.authorUrl = file.author.url
}

// add relativePath similar to non-remote files: https://github.com/transloadit/uppy/pull/4486#issuecomment-1579203717
if (file.relDirPath != null)
tagFile.meta.relativePath =
tagFile.meta!.relativePath =
file.relDirPath ? `${file.relDirPath}/${tagFile.name}` : null
// and absolutePath (with leading slash) https://github.com/transloadit/uppy/pull/4537#issuecomment-1614236655
if (file.absDirPath != null)
tagFile.meta.absolutePath =
tagFile.meta!.absolutePath =
file.absDirPath ?
`/${file.absDirPath}/${tagFile.name}`
: `/${tagFile.name}`
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/provider-views/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export {
default as ProviderViews,
defaultPickerIcon,
} from './ProviderView/index.ts'

export { default as SearchProviderViews } from './SearchProviderView/index.ts'
1 change: 1 addition & 0 deletions packages/@uppy/url/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tsconfig.*
195 changes: 0 additions & 195 deletions packages/@uppy/url/src/Url.jsx

This file was deleted.