@uppy/companion-client
Advanced tools
Comparing version 4.0.0-beta.6 to 4.0.0-beta.7
# @uppy/companion-client | ||
## 4.0.0-beta.7 | ||
Released: 2024-06-04 | ||
Included in: Uppy v4.0.0-beta.10 | ||
- @uppy/companion-client: do not allow boolean `RequestOptions` (Mikael Finstad / #5198) | ||
- @uppy/companion-client: remove deprecated options (Mikael Finstad / #5198) | ||
- @uppy/companion-client: make `supportsRefreshToken` default (Mikael Finstad / #5198) | ||
- @uppy/companion-client: remove optional chaining (Mikael Finstad / #5198) | ||
- @uppy/companion-client: remove `Socket` (Mikael Finstad / #5198) | ||
## 4.0.0-beta.6 | ||
@@ -4,0 +15,0 @@ |
@@ -10,3 +10,2 @@ /** | ||
export type { CompanionPluginOptions } from './CompanionPluginOptions.ts'; | ||
export { default as Socket } from './Socket.ts'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,4 +10,2 @@ /** | ||
import * as _tokenStorage from "./tokenStorage.js"; | ||
export { _tokenStorage as tokenStorage }; | ||
// TODO: remove in the next major | ||
export { default as Socket } from "./Socket.js"; | ||
export { _tokenStorage as tokenStorage }; |
@@ -8,6 +8,2 @@ import type { Uppy } from '@uppy/core'; | ||
export interface Opts extends PluginOpts, CompanionPluginOptions { | ||
/** @deprecated */ | ||
serverUrl?: string; | ||
/** @deprecated */ | ||
serverPattern?: string; | ||
pluginId: string; | ||
@@ -14,0 +10,0 @@ name?: string; |
@@ -1,8 +0,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; } | ||
function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; } | ||
function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; } | ||
import RequestClient, { authErrorStatusCode } from "./RequestClient.js"; | ||
// TODO: remove deprecated options in next major release | ||
const getName = id => { | ||
@@ -33,3 +30,2 @@ return id.split('-').map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' '); | ||
constructor(uppy, opts) { | ||
var _opts$supportsRefresh; | ||
super(uppy, opts); | ||
@@ -53,3 +49,3 @@ Object.defineProperty(this, _getPlugin, { | ||
this.preAuthToken = null; | ||
this.supportsRefreshToken = (_opts$supportsRefresh = opts.supportsRefreshToken) != null ? _opts$supportsRefresh : true; // todo false in next major | ||
this.supportsRefreshToken = !!opts.supportsRefreshToken; | ||
} | ||
@@ -56,0 +52,0 @@ async headers() { |
@@ -14,3 +14,2 @@ import type Uppy from '@uppy/core'; | ||
}; | ||
type _RequestOptions = boolean | RequestOptions; | ||
export declare const authErrorStatusCode = 401; | ||
@@ -34,5 +33,5 @@ export default class RequestClient<M extends Meta, B extends Body> { | ||
}): Promise<ResBody>; | ||
get<PostBody>(path: string, options?: _RequestOptions): Promise<PostBody>; | ||
post<PostBody>(path: string, data: Record<string, unknown>, options?: _RequestOptions): Promise<PostBody>; | ||
delete<T>(path: string, data?: Record<string, unknown>, options?: _RequestOptions): Promise<T>; | ||
get<PostBody>(path: string, options?: RequestOptions): Promise<PostBody>; | ||
post<PostBody>(path: string, data: Record<string, unknown>, options?: RequestOptions): Promise<PostBody>; | ||
delete<T>(path: string, data?: Record<string, unknown>, options?: RequestOptions): Promise<T>; | ||
/** | ||
@@ -39,0 +38,0 @@ * Remote uploading consists of two steps: |
@@ -1,4 +0,4 @@ | ||
function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; } | ||
function _classPrivateFieldLooseBase(e, t) { if (!{}.hasOwnProperty.call(e, t)) throw new TypeError("attempted to use private field on non-instance"); return e; } | ||
var id = 0; | ||
function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; } | ||
function _classPrivateFieldLooseKey(e) { return "__private_" + id++ + "_" + e; } | ||
import UserFacingApiError from '@uppy/utils/lib/UserFacingApiError'; | ||
@@ -15,3 +15,3 @@ // eslint-disable-next-line import/no-extraneous-dependencies | ||
const packageJson = { | ||
"version": "4.0.0-beta.6" | ||
"version": "4.0.0-beta.7" | ||
}; | ||
@@ -109,4 +109,3 @@ // Remove the trailing slash so we can always safely append /xyz. | ||
this.onReceiveResponse = this.onReceiveResponse.bind(this); | ||
// TODO: Remove optional chaining | ||
_classPrivateFieldLooseBase(this, _companionHeaders)[_companionHeaders] = opts == null ? void 0 : opts.companionHeaders; | ||
_classPrivateFieldLooseBase(this, _companionHeaders)[_companionHeaders] = opts.companionHeaders; | ||
} | ||
@@ -188,7 +187,2 @@ setCompanionHeaders(headers) { | ||
async get(path, options) { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { | ||
skipPostResponse: options | ||
}; | ||
return this.request({ | ||
@@ -200,7 +194,2 @@ ...options, | ||
async post(path, data, options) { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { | ||
skipPostResponse: options | ||
}; | ||
return this.request({ | ||
@@ -214,7 +203,2 @@ ...options, | ||
async delete(path, data, options) { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { | ||
skipPostResponse: options | ||
}; | ||
return this.request({ | ||
@@ -480,10 +464,5 @@ ...options, | ||
}; | ||
const onCancelAll = _ref5 => { | ||
const onCancelAll = () => { | ||
var _socketAbortControlle5; | ||
let { | ||
reason | ||
} = _ref5; | ||
if (reason === 'user') { | ||
socketSend('cancel'); | ||
} | ||
socketSend('cancel'); | ||
(_socketAbortControlle5 = socketAbortController) == null || _socketAbortControlle5.abort == null || _socketAbortControlle5.abort(); | ||
@@ -493,4 +472,4 @@ this.uppy.log(`upload ${file.id} was canceled`, 'info'); | ||
}; | ||
const onFilePausedChange = (targetFileId, newPausedState) => { | ||
if (targetFileId !== file.id) return; | ||
const onFilePausedChange = (targetFile, newPausedState) => { | ||
if ((targetFile == null ? void 0 : targetFile.id) !== file.id) return; | ||
pause(newPausedState); | ||
@@ -497,0 +476,0 @@ }; |
{ | ||
"name": "@uppy/companion-client", | ||
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.", | ||
"version": "4.0.0-beta.6", | ||
"version": "4.0.0-beta.7", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/utils": "^6.0.0-beta.6", | ||
"@uppy/utils": "^6.0.0-beta.8", | ||
"namespace-emitter": "^2.0.1", | ||
@@ -33,5 +33,5 @@ "p-retry": "^6.1.0" | ||
"peerDependencies": { | ||
"@uppy/core": "^4.0.0-beta.7" | ||
"@uppy/core": "^4.0.0-beta.9" | ||
}, | ||
"stableVersion": "3.8.0" | ||
} |
@@ -14,4 +14,1 @@ /** | ||
export type { CompanionPluginOptions } from './CompanionPluginOptions.ts' | ||
// TODO: remove in the next major | ||
export { default as Socket } from './Socket.ts' |
@@ -12,8 +12,3 @@ import type { Uppy } from '@uppy/core' | ||
// TODO: remove deprecated options in next major release | ||
export interface Opts extends PluginOpts, CompanionPluginOptions { | ||
/** @deprecated */ | ||
serverUrl?: string | ||
/** @deprecated */ | ||
serverPattern?: string | ||
pluginId: string | ||
@@ -91,3 +86,3 @@ name?: string | ||
this.preAuthToken = null | ||
this.supportsRefreshToken = opts.supportsRefreshToken ?? true // todo false in next major | ||
this.supportsRefreshToken = !!opts.supportsRefreshToken | ||
} | ||
@@ -94,0 +89,0 @@ |
@@ -30,6 +30,2 @@ import UserFacingApiError from '@uppy/utils/lib/UserFacingApiError' | ||
type _RequestOptions = | ||
| boolean // TODO: remove this on the next major | ||
| RequestOptions | ||
// Remove the trailing slash so we can always safely append /xyz. | ||
@@ -102,4 +98,3 @@ function stripSlash(url: string) { | ||
this.onReceiveResponse = this.onReceiveResponse.bind(this) | ||
// TODO: Remove optional chaining | ||
this.#companionHeaders = opts?.companionHeaders | ||
this.#companionHeaders = opts.companionHeaders | ||
} | ||
@@ -201,7 +196,4 @@ | ||
path: string, | ||
options?: _RequestOptions, | ||
options?: RequestOptions, | ||
): Promise<PostBody> { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { skipPostResponse: options } | ||
return this.request({ ...options, path }) | ||
@@ -213,7 +205,4 @@ } | ||
data: Record<string, unknown>, | ||
options?: _RequestOptions, | ||
options?: RequestOptions, | ||
): Promise<PostBody> { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { skipPostResponse: options } | ||
return this.request<PostBody>({ ...options, path, method: 'POST', data }) | ||
@@ -225,7 +214,4 @@ } | ||
data?: Record<string, unknown>, | ||
options?: _RequestOptions, | ||
options?: RequestOptions, | ||
): Promise<T> { | ||
// TODO: remove boolean support for options that was added for backward compatibility. | ||
// eslint-disable-next-line no-param-reassign | ||
if (typeof options === 'boolean') options = { skipPostResponse: options } | ||
return this.request({ ...options, path, method: 'DELETE', data }) | ||
@@ -582,6 +568,4 @@ } | ||
const onCancelAll = ({ reason }: { reason?: string }) => { | ||
if (reason === 'user') { | ||
socketSend('cancel') | ||
} | ||
const onCancelAll = () => { | ||
socketSend('cancel') | ||
socketAbortController?.abort?.() | ||
@@ -593,6 +577,6 @@ this.uppy.log(`upload ${file.id} was canceled`, 'info') | ||
const onFilePausedChange = ( | ||
targetFileId: string | undefined, | ||
targetFile: UppyFile<M, B> | undefined, | ||
newPausedState: boolean, | ||
) => { | ||
if (targetFileId !== file.id) return | ||
if (targetFile?.id !== file.id) return | ||
pause(newPausedState) | ||
@@ -599,0 +583,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
156265
45
1968
Updated@uppy/utils@^6.0.0-beta.8