Skip to content

Commit

Permalink
chore: release v2.0.0 (#352)
Browse files Browse the repository at this point in the history
* chore: release v2.0.0

* chore: refactor custom user agent types

* chore: update changelog

* chore: update readme

* chore: update changelog

* chore: update readme

* chore: update readme

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: nd0ut <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2021
1 parent 27ee7b9 commit c60bb20
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 11,775 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# [2.0.0](https://github.com/uploadcare/uploadcare-upload-client/compare/v1.1.5...v2.0.0) (2021-11-15)


### Features

* feat!: add cjs and esm support (#283) ([081f27e](https://github.com/uploadcare/uploadcare-upload-client/commit/081f27ef6022e6bdc605bc25e18313786c3f65d0)), closes [#283](https://github.com/uploadcare/uploadcare-upload-client/issues/283)
* feat!: replace CancelController with native AbortController (#282) ([020e1ae](https://github.com/uploadcare/uploadcare-upload-client/commit/020e1aeca1507979dbd123711a600e6692ca911f)), closes [#282](https://github.com/uploadcare/uploadcare-upload-client/issues/282)
* add mimeType to UploadcareFile type ([33b6c58](https://github.com/uploadcare/uploadcare-upload-client/commit/33b6c586f291569ff8eabbd488d8f61bde66de4b))
* export high-level upload methods ([1354018](https://github.com/uploadcare/uploadcare-upload-client/commit/1354018ce350895f638ba7be6ade6223193df407))
* handle server error codes ([948c9d1](https://github.com/uploadcare/uploadcare-upload-client/commit/948c9d140685aa2d0325904220ff42c262aaae79))
* add option `userAgent` to pass custom user agent string or function ([d74fefb](https://github.com/uploadcare/uploadcare-upload-client/commit/d74fefb18168fbfec8aa3daf2707da3305846879))


### BREAKING CHANGES

* remove default export because webpack can't handle it without bugs
* replace `cancel` key with `signal` in all cancelable methods
* property `response` of `UploadClientError` now contains the whole response object (`{ error: {...}}`)



## [1.1.5](https://github.com/uploadcare/uploadcare-upload-client/compare/v1.1.4...v1.1.5) (2021-06-28)


Expand Down
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ providing the necessary settings. Specifying `YOUR_PUBLIC_KEY` is mandatory: it
points to the specific Uploadcare project:

```javascript
import UploadClient from '@uploadcare/upload-client'
import { UploadClient } from '@uploadcare/upload-client'

const client = new UploadClient({ publicKey: 'YOUR_PUBLIC_KEY' })
```
Expand Down Expand Up @@ -94,10 +94,10 @@ You can cancel file uploading and track this event:

```javascript
const fileUUID = 'edfdf045-34c0-4087-bbdd-e3834921f890'
const controller = new CancelController()
const abortController = new AbortController()

client
.uploadFile(fileUUID, { cancel: controller })
.uploadFile(fileUUID, { signal: abortController })
.then(file => console.log(file.uuid))
.catch(error => {
if (error.isCancel) {
Expand All @@ -106,7 +106,7 @@ client
})

// Cancel uploading
controller.cancel()
abortController.abort()
```

List of all available `UploadClient` API methods:
Expand Down Expand Up @@ -163,17 +163,30 @@ interface UploadClient {
}
```

You can import only needed methods directly, without `UploadClient` wrapper:

```javascript
import {
uploadFile,
uploadFromUrl,
uploadBase,
uploadFromUploaded,
uploadMultipart,
uploadFileGroup
} from '@uploadcare/upload-client'
```

### Low-Level API

Also, you can use low-level wrappers to call the API endpoints directly:

```javascript
import { base, CancelController } from '@uploadcare/upload-client'
import { base, AbortController } from '@uploadcare/upload-client'

const onProgress = ({ value }) => console.log(value)
const cancelController = new CancelController()
const abortController = new AbortController()

base(fileData, { onProgress, cancel: cancelController }) // fileData must be `Blob` or `File` or `Buffer`
base(fileData, { onProgress, signal: abortController }) // fileData must be `Blob` or `File` or `Buffer`
.then(data => console.log(data.file))
.catch(error => {
if (error.isCancel) {
Expand All @@ -182,7 +195,7 @@ base(fileData, { onProgress, cancel: cancelController }) // fileData must be `Bl
})

// Also you can cancel upload:
cancelController.cancel()
abortController.abort()
```

List of all available API methods:
Expand Down Expand Up @@ -290,7 +303,19 @@ of `API secret key` and `secureExpire`.

Stands for the Unix time to which the signature is valid, e.g., `1454902434`.

#### `integration: string`
#### `integration: string | CustomUserAgentFn`

```typescript
type CustomUserAgentOptions = {
publicKey: string
libraryName: string
libraryVersion: string
languageName: string
integration?: string
}

type CustomUserAgentFn = (options: CustomUserAgentOptions) => string
```
`X-UC-User-Agent` header value.
Expand Down Expand Up @@ -372,7 +397,7 @@ npm run test
By default, tests runs with mock server, but you can run tests with
production environment.
Run test on production servers:
Run test on production servers:
```bash
npm run test:production
Expand Down
Loading

0 comments on commit c60bb20

Please sign in to comment.