@uppy/transloadit
Advanced tools
Comparing version 3.1.0 to 3.1.1
# @uppy/transloadit | ||
## 3.1.1 | ||
Released: 2023-02-13 | ||
Included in: Uppy v3.5.0 | ||
- @uppy/transloadit: fix `assemblyOptions` option (Antoine du Hamel / #4316) | ||
## 3.1.0 | ||
@@ -4,0 +11,0 @@ |
@@ -71,7 +71,15 @@ import ErrorWithCause from '@uppy/utils/lib/ErrorWithCause'; | ||
function getFields(file, assemblyOptions) { | ||
if (Array.isArray(assemblyOptions.fields)) { | ||
return Object.fromEntries(assemblyOptions.fields.map(fieldName => [fieldName, file.meta[fieldName]])); | ||
const { | ||
fields | ||
} = assemblyOptions; | ||
if (fields == null) { | ||
return {}; | ||
} | ||
return {}; | ||
if (Array.isArray(fields)) { | ||
return Object.fromEntries(fields.map(fieldName => [fieldName, file.meta[fieldName]])); | ||
} | ||
return fields; | ||
} | ||
@@ -78,0 +86,0 @@ /** |
@@ -18,13 +18,5 @@ function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
const packageJson = { | ||
"version": "3.1.0" | ||
"version": "3.1.1" | ||
}; | ||
function defaultGetAssemblyOptions(file, options) { | ||
return { | ||
params: options.params, | ||
signature: options.signature, | ||
fields: options.fields | ||
}; | ||
} | ||
const sendErrorToConsole = originalErr => err => { | ||
@@ -96,3 +88,3 @@ const error = new ErrorWithCause('Failed to send error to the client', { | ||
constructor(uppy, opts) { | ||
var _this, _opts$assemblyOptions; | ||
var _this, _this$opts, _this$opts$assemblyOp, _this$opts$getAssembl; | ||
@@ -495,6 +487,6 @@ super(uppy, opts); | ||
/** @deprecated use `assemblyOptions` instead */ | ||
fields: {}, | ||
fields: null, | ||
/** @deprecated use `assemblyOptions` instead */ | ||
getAssemblyOptions: defaultGetAssemblyOptions, | ||
getAssemblyOptions: null, | ||
limit: 20, | ||
@@ -505,17 +497,16 @@ retryDelays: [7000, 10000, 15000, 20000] | ||
...opts | ||
}; // TODO: move this into `defaultOptions` once we remove the deprecated options | ||
}; // TODO: remove this fallback in the next major | ||
this.opts.assemblyOptions = (_opts$assemblyOptions = opts.assemblyOptions) != null ? _opts$assemblyOptions : this.opts.getAssemblyOptions; | ||
_classPrivateFieldLooseBase(this, _rateLimitedQueue)[_rateLimitedQueue] = new RateLimitedQueue(this.opts.limit); | ||
this.i18nInit(); | ||
const hasCustomAssemblyOptions = this.opts.assemblyOptions !== defaultOptions.assemblyOptions; | ||
(_this$opts$assemblyOp = (_this$opts = this.opts).assemblyOptions) != null ? _this$opts$assemblyOp : _this$opts.assemblyOptions = (_this$opts$getAssembl = this.opts.getAssemblyOptions) != null ? _this$opts$getAssembl : { | ||
params: this.opts.params, | ||
signature: this.opts.signature, | ||
fields: this.opts.fields | ||
}; // TODO: remove this check in the next major (validating params when creating the assembly should be enough) | ||
if (this.opts.params) { | ||
validateParams(this.opts.params); | ||
} else if (!hasCustomAssemblyOptions) { | ||
// Throw the same error that we'd throw if the `params` returned from a | ||
// `getAssemblyOptions()` function is null. | ||
validateParams(null); | ||
if ((opts == null ? void 0 : opts.params) != null && opts.getAssemblyOptions == null && opts.assemblyOptions == null) { | ||
validateParams(this.opts.assemblyOptions.params); | ||
} | ||
_classPrivateFieldLooseBase(this, _rateLimitedQueue)[_rateLimitedQueue] = new RateLimitedQueue(this.opts.limit); | ||
this.i18nInit(); | ||
this.client = new Client({ | ||
@@ -522,0 +513,0 @@ service: this.opts.service, |
{ | ||
"name": "@uppy/transloadit", | ||
"description": "The Transloadit plugin can be used to upload files to Transloadit for all kinds of processing, such as transcoding video, resizing images, zipping/unzipping, and more", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"license": "MIT", | ||
@@ -39,3 +39,3 @@ "main": "lib/index.js", | ||
"peerDependencies": { | ||
"@uppy/core": "^3.0.5" | ||
"@uppy/core": "^3.0.6" | ||
}, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
@@ -62,8 +62,12 @@ import ErrorWithCause from '@uppy/utils/lib/ErrorWithCause' | ||
function getFields (file, assemblyOptions) { | ||
if (Array.isArray(assemblyOptions.fields)) { | ||
const { fields } = assemblyOptions | ||
if (fields == null) { | ||
return {} | ||
} | ||
if (Array.isArray(fields)) { | ||
return Object.fromEntries( | ||
assemblyOptions.fields.map((fieldName) => [fieldName, file.meta[fieldName]]), | ||
fields.map((fieldName) => [fieldName, file.meta[fieldName]]), | ||
) | ||
} | ||
return {} | ||
return fields | ||
} | ||
@@ -70,0 +74,0 @@ |
@@ -14,10 +14,2 @@ import hasProperty from '@uppy/utils/lib/hasProperty' | ||
function defaultGetAssemblyOptions (file, options) { | ||
return { | ||
params: options.params, | ||
signature: options.signature, | ||
fields: options.fields, | ||
} | ||
} | ||
const sendErrorToConsole = originalErr => err => { | ||
@@ -69,5 +61,5 @@ const error = new ErrorWithCause('Failed to send error to the client', { cause: err }) | ||
/** @deprecated use `assemblyOptions` instead */ | ||
fields: {}, | ||
fields: null, | ||
/** @deprecated use `assemblyOptions` instead */ | ||
getAssemblyOptions: defaultGetAssemblyOptions, | ||
getAssemblyOptions: null, | ||
limit: 20, | ||
@@ -78,4 +70,15 @@ retryDelays: [7_000, 10_000, 15_000, 20_000], | ||
this.opts = { ...defaultOptions, ...opts } | ||
// TODO: move this into `defaultOptions` once we remove the deprecated options | ||
this.opts.assemblyOptions = opts.assemblyOptions ?? this.opts.getAssemblyOptions | ||
// TODO: remove this fallback in the next major | ||
this.opts.assemblyOptions ??= this.opts.getAssemblyOptions ?? { | ||
params: this.opts.params, | ||
signature: this.opts.signature, | ||
fields: this.opts.fields, | ||
} | ||
// TODO: remove this check in the next major (validating params when creating the assembly should be enough) | ||
if (opts?.params != null && opts.getAssemblyOptions == null && opts.assemblyOptions == null) { | ||
validateParams(this.opts.assemblyOptions.params) | ||
} | ||
this.#rateLimitedQueue = new RateLimitedQueue(this.opts.limit) | ||
@@ -85,11 +88,2 @@ | ||
const hasCustomAssemblyOptions = this.opts.assemblyOptions !== defaultOptions.assemblyOptions | ||
if (this.opts.params) { | ||
validateParams(this.opts.params) | ||
} else if (!hasCustomAssemblyOptions) { | ||
// Throw the same error that we'd throw if the `params` returned from a | ||
// `getAssemblyOptions()` function is null. | ||
validateParams(null) | ||
} | ||
this.client = new Client({ | ||
@@ -96,0 +90,0 @@ service: this.opts.service, |
@@ -100,3 +100,3 @@ import type { PluginOptions, UppyFile, BasePlugin } from '@uppy/core' | ||
params?: AssemblyParameters | ||
fields?: { [name: string]: number | string } | ||
fields?: { [name: string]: number | string } | string[] | ||
// TODO (major): move signature into params.auth. | ||
@@ -147,3 +147,3 @@ signature?: string | ||
/** @deprecated use `assemblyOptions` instead */ | ||
fields?: { [name: string]: number | string } | ||
fields?: { [name: string]: number | string } | string[] | ||
/** @deprecated use `assemblyOptions` instead */ | ||
@@ -150,0 +150,0 @@ signature?: string |
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
237849
3634