fixes#6024.
### Problem
- `getPlugin()` defaults to `UnknownPlugin`, so methods like `openModal`
are not visible , since core is not aware of that plugin type
### Proposed change
- Introduce a types-only registry in core:
- `export interface PluginTypeRegistry<M extends Meta, B extends Body>
{}`
- Overload `getPlugin` to return a precise type when the id is a known
key of the registry.
- add `Dashboard` to PluginTypeRegistry through module augmentation:
- `'Dashboard': Dashboard<M, B>`.
- When a project imports from `@uppy/dashboard`, its module augmentation
extends PluginTypeRegistry, adding the correct type into it
- I've added Tests , kept them in a separate file so it's easier to
review , once this approach gets approved I'll add them to
`Uppy.test.ts`
Once this PR gets a positive review I'll add this for other plugins ,
currently only added for `@uppy/dashboard`
**Build with Local tarball can be checked here**
https://stackblitz.com/~/github.com/qxprakash/uppy-type-test?file=type_test.ts
Probably best reviewed commit by commit.
I also split UppyFile into two intefaces distinguished by the `isRemote`
boolean:
- LocalUppyFile
- RemoteUppyFile
Also:
- Removed the TagFile type
- Don't re-upload completed files - fixes#5930
- Clean up stored files on `complete` event *only* if *all* files
succeeded (no failed files). this allows the user to retry failed files
if the browser & upload get interrupted - fixes#5927, closes#5955
- Only set `isGhost` for non-successful files. it doesn't make sense for
successfully uploaded files to be ghosted because they're already done.
#5930fixes#6013
---------
Co-authored-by: Prakash <qxprakash@gmail.com>
- cleanup `@uppy/utils ` removed unused / redundant modules .
- migrated modules and tests from `.js` to `.ts`
- removed all the nested export paths
- updated `@uppy/utils` import paths for all packages
- `@uppy/angular` is still failing while running`yarn build` , I'm
looking into it.
---------
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
- added export maps to all the @uppy packages .
- imports remain unaffected except for peerDep packages in `@uppy/react`
`@uppy/svelte` and `@uppy/vue3`.
- export maps added for index files , css , and package.json.
- Added side effects for all the packages.
---------
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* fix uploadRemoteFile undefined
for some reason, only when testing locally using VITE_COMPANION_URL=https://api2.transloadit.com/companion only
we get this error...
i'm thinking for some reason, the remote file gets serialized into state and then de-serialized again
causing remote.requestClient to be gone
so I solve it by instead storing the request clients in Uppy
fixes#4791
* fix bugs
* remove unrelated space changes
* apply suggestions
* Update Uppy.js
* fix lint
---------
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
* respond with 500 if unhandled upload error
400 seems inappropriate
* add todo
* fix companion download error
respond with correct response code when calling /get
and request to the upstream server fail
also add a unit test for this
* forward 429 from provider
allows us to retry it
* rename fn
* add a way to test refresh tokens
* fix race condtiion with refreshing token
* implement retry and fix socket
- Make sure we don't instantiate a new Provider for every file uploaded (reuse the original provider instead) - this caused the refresh token synchronization not to work
- Retry most errors when uploading (`/get`) using companion, but for HTTP, only retry certain HTTP status codes
- Reimplement the websocket code to be more stable and retry as well
* remove unused socket wrapper
* remove useFastRemoteRetry
because it isn't supported in Companion as far as I can tell
* fix error handling
* remove unneeded logic
* apply review suggestion
* retry awaiting for companion socket too
* retry whole operation instead of individually
or else we risk getting stuck retrying just half of the operation, which might never recover
* improvements
- rewrite so we can use p-retry for exponential backoff for socket reconnect too
- improve logging
- simplify/reuse code
* Update packages/@uppy/utils/src/fetchWithNetworkError.js
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* Explain requestClient Symbol with comment
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
* Update packages/@uppy/provider-views/src/View.js
* fixes
preventing socket.send when the socket is not in the connected state
catch errors in handlers
* log if trying to refresh with no token
* log whether we got a refresh token
* dont log retrying when in reality not
* always prompt: consent
for google drive
* add signal to post
* refactor away eventmanager
and event handler error catching
* don't fail with upload-error
if a file is canceled
* fix expect
* add capabilities support
* make requestClient non-enumerable
---------
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* When file is removed (or all are canceled), controller.abort queued requests
* add controller.abort to all other remote uploaders too
* fix the queue
---------
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
* Don't close socket while upload is still in progress
* Don't close sockets randomly in AWS S3 either, close on error/cancel
* First send the socket message, then call .abort()
* show how many files are added when loading
remake of https://github.com/transloadit/uppy/pull/4388
* add french (cherry pick)
* implement concurrent file listing
* refactor / fix lint
* refactor/reduce duplication
* pull out totals validation
don't do it for every file added, as it's very slow
instead do the check at the end when all files are added.
this allows us to easily work with 10k+ files
fixes#4389
* Update packages/@uppy/core/src/Uppy.js
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
* make restricter.validate validate everything
instead make more specific methods for sub-validation
also rename validateTotals to validateAggregateRestrictions
* improve errors and user feedback
- handle errors centrally so that we can limit the amount of toasts (informers) sent to the users (prevent flooding hundreds/thousands of them)
- introduce FileRestrictionError which is a restriction error for a specific file
- introduce isUserFacing field for RestrictionError
* fix performance issue reintroduced
* improvements
- show "%{count} additional restrictions were not fulfilled" for any restriction errors more than 4
- refactor/rename methods
- improve ghost logic/comments
* improve performance when uploading
- introduce new event "upload-start" that can contain multiple files
- make a new patchFilesState method to allow updating more files
- unify "upload-start" logic in all plugins (send it before files start uploading)
- defer slicing buffer until we need the data
- refactor to reuse code
* fix e2e build issue
* try to upgrade cypress
maybe it fixes the error
* Revert "fix e2e build issue"
This reverts commit ff3e580c0f.
* upgrade parcel
* move mutation logic to end
* remove FileRestrictionError
merge it with RestrictionError
* fix silly bug
looks like the e2e tests are doing its job 👏
---------
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>