@uppy/remote-sources
Advanced tools
Comparing version 2.1.0 to 2.2.0
# @uppy/remote-sources | ||
## 2.2.0 | ||
Released: 2024-08-29 | ||
Included in: Uppy v4.3.0 | ||
- @uppy/remote-sources: support companionKeysParams (Merlijn Vos / #5434) | ||
## 2.1.0 | ||
@@ -4,0 +11,0 @@ |
import { BasePlugin, Uppy } from '@uppy/core'; | ||
import Dropbox from '@uppy/dropbox'; | ||
import GoogleDrive from '@uppy/google-drive'; | ||
import GooglePhotos from '@uppy/google-photos'; | ||
import Instagram from '@uppy/instagram'; | ||
import Facebook from '@uppy/facebook'; | ||
import OneDrive from '@uppy/onedrive'; | ||
import Box from '@uppy/box'; | ||
import Unsplash from '@uppy/unsplash'; | ||
import Url from '@uppy/url'; | ||
import Zoom from '@uppy/zoom'; | ||
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'; | ||
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'; | ||
import type { CompanionPluginOptions } from '@uppy/companion-client'; | ||
declare const availablePlugins: { | ||
__proto__: null; | ||
Box: typeof Box; | ||
Dropbox: typeof Dropbox; | ||
Facebook: typeof Facebook; | ||
GoogleDrive: typeof GoogleDrive; | ||
GooglePhotos: typeof GooglePhotos; | ||
Instagram: typeof Instagram; | ||
OneDrive: typeof OneDrive; | ||
Unsplash: typeof Unsplash; | ||
Url: typeof Url; | ||
Zoom: typeof Zoom; | ||
type AvailablePluginsKeys = 'Box' | 'Dropbox' | 'Facebook' | 'GoogleDrive' | 'GooglePhotos' | 'Instagram' | 'OneDrive' | 'Unsplash' | 'Url' | 'Zoom'; | ||
type NestedCompanionKeysParams = { | ||
[key in AvailablePluginsKeys]?: CompanionPluginOptions['companionKeysParams']; | ||
}; | ||
export interface RemoteSourcesOptions extends CompanionPluginOptions { | ||
sources?: Array<keyof Omit<typeof availablePlugins, '__proto__'>>; | ||
export interface RemoteSourcesOptions extends Omit<CompanionPluginOptions, 'companionKeysParams'> { | ||
sources?: Array<AvailablePluginsKeys>; | ||
companionKeysParams?: NestedCompanionKeysParams; | ||
} | ||
declare const defaultOptions: { | ||
sources: ("Box" | "Dropbox" | "Facebook" | "GoogleDrive" | "GooglePhotos" | "Instagram" | "OneDrive" | "Unsplash" | "Url" | "Zoom")[]; | ||
sources: AvailablePluginsKeys[]; | ||
}; | ||
@@ -34,0 +16,0 @@ type Opts = DefinePluginOpts<RemoteSourcesOptions, keyof typeof defaultOptions>; |
@@ -18,3 +18,3 @@ function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
const packageJson = { | ||
"version": "2.1.0" | ||
"version": "2.2.0" | ||
}; | ||
@@ -62,5 +62,11 @@ const availablePlugins = { | ||
this.opts.sources.forEach(pluginId => { | ||
var _this$opts$companionK; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { | ||
sources, | ||
...rest | ||
} = this.opts; | ||
const optsForRemoteSourcePlugin = { | ||
...this.opts, | ||
sources: undefined | ||
...rest, | ||
companionKeysParams: (_this$opts$companionK = this.opts.companionKeysParams) == null ? void 0 : _this$opts$companionK[pluginId] | ||
}; | ||
@@ -67,0 +73,0 @@ const plugin = availablePlugins[pluginId]; |
{ | ||
"name": "@uppy/remote-sources", | ||
"description": "Uppy plugin that includes all remote sources that Uppy+Companion offer, like Instagram, Google Drive, Dropox, Box, Unsplash, Url etc", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"license": "MIT", | ||
@@ -30,16 +30,16 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/box": "^3.0.0", | ||
"@uppy/dashboard": "^4.0.2", | ||
"@uppy/dropbox": "^4.0.0", | ||
"@uppy/facebook": "^4.0.0", | ||
"@uppy/google-drive": "^4.0.0", | ||
"@uppy/google-photos": "^0.2.0", | ||
"@uppy/instagram": "^4.0.0", | ||
"@uppy/onedrive": "^4.0.0", | ||
"@uppy/unsplash": "^4.0.0", | ||
"@uppy/url": "^4.0.0", | ||
"@uppy/zoom": "^3.0.0" | ||
"@uppy/box": "^3.1.0", | ||
"@uppy/dashboard": "^4.1.0", | ||
"@uppy/dropbox": "^4.1.0", | ||
"@uppy/facebook": "^4.1.0", | ||
"@uppy/google-drive": "^4.1.0", | ||
"@uppy/google-photos": "^0.3.0", | ||
"@uppy/instagram": "^4.1.0", | ||
"@uppy/onedrive": "^4.1.0", | ||
"@uppy/unsplash": "^4.1.0", | ||
"@uppy/url": "^4.1.0", | ||
"@uppy/zoom": "^3.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@uppy/core": "^4.1.0" | ||
"@uppy/core": "^4.2.0" | ||
}, | ||
@@ -46,0 +46,0 @@ "publishConfig": { |
@@ -53,2 +53,17 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' | ||
}) | ||
it('should pass companionKeysParams', () => { | ||
const core = new Core() | ||
const companionKeysParams = { | ||
GoogleDrive: { key: 'google', credentialsName: 'google' }, | ||
} | ||
core.use(Dashboard) | ||
core.use(RemoteSources, { | ||
companionUrl: 'https://example.com', | ||
companionKeysParams, | ||
}) | ||
expect(core.getPlugin('GoogleDrive')?.opts.companionKeysParams).toEqual( | ||
companionKeysParams.GoogleDrive, | ||
) | ||
}) | ||
}) |
@@ -35,10 +35,29 @@ import { BasePlugin, Uppy, type UnknownProviderPlugin } from '@uppy/core' | ||
export interface RemoteSourcesOptions extends CompanionPluginOptions { | ||
sources?: Array<keyof Omit<typeof availablePlugins, '__proto__'>> | ||
type AvailablePluginsKeys = | ||
| 'Box' | ||
| 'Dropbox' | ||
| 'Facebook' | ||
| 'GoogleDrive' | ||
| 'GooglePhotos' | ||
| 'Instagram' | ||
| 'OneDrive' | ||
| 'Unsplash' | ||
| 'Url' | ||
| 'Zoom' | ||
type NestedCompanionKeysParams = { | ||
[key in AvailablePluginsKeys]?: CompanionPluginOptions['companionKeysParams'] | ||
} | ||
export interface RemoteSourcesOptions | ||
extends Omit<CompanionPluginOptions, 'companionKeysParams'> { | ||
sources?: Array<AvailablePluginsKeys> | ||
// Individual remote source plugins set the `key` and `credentialsName` | ||
// in `companionKeysParams` but because this is a preset we need to change | ||
// this to a record of plugin IDs to their respective `companionKeysParams`. | ||
companionKeysParams?: NestedCompanionKeysParams | ||
} | ||
const defaultOptions = { | ||
sources: Object.keys(availablePlugins) as Array< | ||
keyof Omit<typeof availablePlugins, '__proto__'> | ||
>, | ||
sources: Object.keys(availablePlugins) as Array<AvailablePluginsKeys>, | ||
} satisfies Partial<RemoteSourcesOptions> | ||
@@ -76,3 +95,8 @@ | ||
this.opts.sources.forEach((pluginId) => { | ||
const optsForRemoteSourcePlugin = { ...this.opts, sources: undefined } | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { sources, ...rest } = this.opts | ||
const optsForRemoteSourcePlugin: CompanionPluginOptions = { | ||
...rest, | ||
companionKeysParams: this.opts.companionKeysParams?.[pluginId], | ||
} | ||
const plugin = availablePlugins[pluginId] | ||
@@ -79,0 +103,0 @@ if (plugin == null) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24572
291
+ Added@uppy/google-photos@0.3.1(transitive)
- Removed@uppy/google-photos@0.2.0(transitive)
Updated@uppy/box@^3.1.0
Updated@uppy/dashboard@^4.1.0
Updated@uppy/dropbox@^4.1.0
Updated@uppy/facebook@^4.1.0
Updated@uppy/google-drive@^4.1.0
Updated@uppy/google-photos@^0.3.0
Updated@uppy/instagram@^4.1.0
Updated@uppy/onedrive@^4.1.0
Updated@uppy/unsplash@^4.1.0
Updated@uppy/url@^4.1.0
Updated@uppy/zoom@^3.1.0