Skip to content

Commit

Permalink
Upgrade Prettier; allow using from both CommonJS and ESM code (#5)
Browse files Browse the repository at this point in the history
## PRs in the Stack
- ➡ #5

(The stack is managed by
[git-grok](https://github.com/dimikot/git-grok).)
  • Loading branch information
dimikot authored Jan 13, 2024
2 parents a5ae2ea + e4242e3 commit 64d0467
Show file tree
Hide file tree
Showing 54 changed files with 367 additions and 293 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ module.exports = (projectRoot) => ({
},
ignorePatterns: [
"node_modules",
"dist",
"webpack.config.ts",
"**/bin/**",
"*.d.ts",
"**/jest.config.js",
"*.js",
],
rules: {
// TODO: slowly enable no-extraneous-dependencies rule below. For now, it's
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build
- run: npm run test
- run: npm run lint
- run: npm install -g pnpm --force
- run: pnpm install
- run: pnpm run build
- run: pnpm run lint
- run: pnpm run test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist

node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock
.DS_Store
*.log
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tsconfig.tsbuildinfo

node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock
.DS_Store
*.log
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

See also [Full API documentation](https://github.com/clickup/rest-client/blob/master/docs/modules.md).

![CI run](https://github.com/clickup/rest-client/actions/workflows/ci.yml/badge.svg?branch=main)

## Examples

In the example below we use
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

See also [Full API documentation](https://github.com/clickup/rest-client/blob/master/docs/modules.md).

![CI run](https://github.com/clickup/rest-client/actions/workflows/ci.yml/badge.svg?branch=main)

## Examples

In the example below we use
Expand Down
10 changes: 7 additions & 3 deletions docs/classes/PacerComposite.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ A Pacer which runs all sub-pacers and chooses the largest delay.

### constructor

**new PacerComposite**(`_pacers`)
**new PacerComposite**(`_pacers`): [`PacerComposite`](PacerComposite.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `_pacers` | [`Pacer`](../interfaces/Pacer.md)[] |

#### Returns

[`PacerComposite`](PacerComposite.md)

#### Defined in

[src/pacers/PacerComposite.ts:10](https://github.com/clickup/rest-client/blob/master/src/pacers/PacerComposite.ts#L10)
Expand All @@ -44,14 +48,14 @@ Human readable name of the pacer, used when composing multiple pacers.

### touch

**touch**(): `Promise`<{ `delayMs`: `number` ; `reason`: `string` }\>
**touch**(): `Promise`\<\{ `delayMs`: `number` ; `reason`: `string` }\>

Signals that we're about to send a request. Returns the delay we need to
wait for before actually sending.

#### Returns

`Promise`<{ `delayMs`: `number` ; `reason`: `string` }\>
`Promise`\<\{ `delayMs`: `number` ; `reason`: `string` }\>

#### Implementation of

Expand Down
10 changes: 7 additions & 3 deletions docs/classes/PacerQPS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the pacing algorithm.

### constructor

**new PacerQPS**(`_options`, `_backend`)
**new PacerQPS**(`_options`, `_backend`): [`PacerQPS`](PacerQPS.md)

#### Parameters

Expand All @@ -29,6 +29,10 @@ the pacing algorithm.
| `_options` | [`PacerQPSOptions`](../interfaces/PacerQPSOptions.md) |
| `_backend` | [`PacerQPSBackend`](../interfaces/PacerQPSBackend.md) |

#### Returns

[`PacerQPS`](PacerQPS.md)

#### Defined in

[src/pacers/PacerQPS.ts:74](https://github.com/clickup/rest-client/blob/master/src/pacers/PacerQPS.ts#L74)
Expand Down Expand Up @@ -57,14 +61,14 @@ Human readable name of the pacer, used when composing multiple pacers.

### touch

**touch**(): `Promise`<[`PacerDelay`](../interfaces/PacerDelay.md)\>
**touch**(): `Promise`\<[`PacerDelay`](../interfaces/PacerDelay.md)\>

Signals that we're about to send a request. Returns the delay we need to
wait for before actually sending.

#### Returns

`Promise`<[`PacerDelay`](../interfaces/PacerDelay.md)\>
`Promise`\<[`PacerDelay`](../interfaces/PacerDelay.md)\>

#### Implementation of

Expand Down
60 changes: 32 additions & 28 deletions docs/classes/RestClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ RestClient is an immutable object which allows to:

### constructor

**new RestClient**(`options?`)
**new RestClient**(`options?`): [`RestClient`](RestClient.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | `Partial`<[`RestOptions`](../interfaces/RestOptions.md)\> |
| `options` | `Partial`\<[`RestOptions`](../interfaces/RestOptions.md)\> |

#### Returns

[`RestClient`](RestClient.md)

#### Defined in

Expand All @@ -35,7 +39,7 @@ Returns a new RestClient with some options updated with the passed ones.

| Name | Type |
| :------ | :------ |
| `options` | `Partial`<[`RestOptions`](../interfaces/RestOptions.md)\> |
| `options` | `Partial`\<[`RestOptions`](../interfaces/RestOptions.md)\> |

#### Returns

Expand Down Expand Up @@ -86,7 +90,7 @@ appears here which we must protect against in the code below.

| Name | Type |
| :------ | :------ |
| `base` | `string` \| () => `Promise`<`string`\> |
| `base` | `string` \| () => `Promise`\<`string`\> |

#### Returns

Expand All @@ -109,7 +113,7 @@ Returns a new RestClient with a custom header.
| Name | Type |
| :------ | :------ |
| `name` | `string` |
| `value` | `string` \| () => `Promise`<`string`\> |
| `value` | `string` \| () => `Promise`\<`string`\> |

#### Returns

Expand Down Expand Up @@ -152,7 +156,7 @@ logic, e.g.:

| Name | Type | Default value |
| :------ | :------ | :------ |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)<`string`\> | `undefined` |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)\<`string`\> | `undefined` |
| `bearerPrefix` | `string` | `"Bearer "` |

#### Returns
Expand Down Expand Up @@ -186,7 +190,7 @@ of arbitrary requests, it can only send its own requests.
| `consumer` | `Object` |
| `consumer.consumerKey` | `string` |
| `consumer.consumerSecret` | `string` |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)<{ `token`: `string` ; `tokenSecret`: `string` }\> |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)\<\{ `token`: `string` ; `tokenSecret`: `string` }\> |

#### Returns

Expand All @@ -208,7 +212,7 @@ Returns a new RestClient with basic authorization workflow.

| Name | Type |
| :------ | :------ |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)<{ `name`: `string` ; `password`: `string` }\> |
| `token` | [`TokenGetter`](../interfaces/TokenGetter.md)\<\{ `name`: `string` ; `password`: `string` }\> |

#### Returns

Expand All @@ -222,7 +226,7 @@ ___

### get

**get**(`path`, `args?`, `accept?`): [`RestRequest`](RestRequest.md)<`any`\>
**get**(`path`, `args?`, `accept?`): [`RestRequest`](RestRequest.md)\<`any`\>

Sends a plain GET request without body.

Expand All @@ -233,12 +237,12 @@ NOTE, all args will be passed through `encodeURIComponent`.
| Name | Type | Default value |
| :------ | :------ | :------ |
| `path` | `string` | `undefined` |
| `args` | `Partial`<`Record`<`string`, `string` \| `number` \| `string`[]\>\> | `{}` |
| `args` | `Partial`\<`Record`\<`string`, `string` \| `number` \| `string`[]\>\> | `{}` |
| `accept` | `string` | `"application/json"` |

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -248,7 +252,7 @@ ___

### writeRaw

**writeRaw**(`path`, `body`, `contentType`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)<`any`\>
**writeRaw**(`path`, `body`, `contentType`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)\<`any`\>

Writes some raw string, buffer or a stream.

Expand All @@ -264,7 +268,7 @@ Writes some raw string, buffer or a stream.

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -274,7 +278,7 @@ ___

### writeJson

**writeJson**(`path`, `body`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)<`any`\>
**writeJson**(`path`, `body`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)\<`any`\>

A shortcut method to write JSON body.

Expand All @@ -289,7 +293,7 @@ A shortcut method to write JSON body.

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -299,7 +303,7 @@ ___

### writeForm

**writeForm**(`path`, `body`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)<`any`\>
**writeForm**(`path`, `body`, `method?`, `accept?`): [`RestRequest`](RestRequest.md)\<`any`\>

A shortcut method to write "application/x-www-form-urlencoded" data.

Expand All @@ -308,13 +312,13 @@ A shortcut method to write "application/x-www-form-urlencoded" data.
| Name | Type | Default value |
| :------ | :------ | :------ |
| `path` | `string` | `undefined` |
| `body` | `string` \| `Partial`<`Record`<`string`, `string`\>\> | `undefined` |
| `body` | `string` \| `Partial`\<`Record`\<`string`, `string`\>\> | `undefined` |
| `method` | ``"POST"`` \| ``"PUT"`` \| ``"PATCH"`` | `"POST"` |
| `accept` | `string` | `"application/json"` |

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -324,7 +328,7 @@ ___

### writeDelete

**writeDelete**(`path`, `args?`, `accept?`): [`RestRequest`](RestRequest.md)<`any`\>
**writeDelete**(`path`, `args?`, `accept?`): [`RestRequest`](RestRequest.md)\<`any`\>

A shortcut method to write DELETE request.

Expand All @@ -333,12 +337,12 @@ A shortcut method to write DELETE request.
| Name | Type | Default value |
| :------ | :------ | :------ |
| `path` | `string` | `undefined` |
| `args` | `Partial`<`Record`<`string`, `string`\>\> | `{}` |
| `args` | `Partial`\<`Record`\<`string`, `string`\>\> | `{}` |
| `accept` | `string` | `"application/json"` |

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -348,7 +352,7 @@ ___

### writeGraphQLX

**writeGraphQLX**(`query`, `variables?`): [`RestRequest`](RestRequest.md)<`any`\>
**writeGraphQLX**(`query`, `variables?`): [`RestRequest`](RestRequest.md)\<`any`\>

Returns a RestRequest prepared for sending GraphQL operation.
- Expects the response to contain no errors; throws otherwise.
Expand All @@ -365,7 +369,7 @@ Returns a RestRequest prepared for sending GraphQL operation.

#### Returns

[`RestRequest`](RestRequest.md)<`any`\>
[`RestRequest`](RestRequest.md)\<`any`\>

#### Defined in

Expand All @@ -375,7 +379,7 @@ ___

### writeGraphQLNullable

**writeGraphQLNullable**(`query`, `variables?`): [`RestRequest`](RestRequest.md)<`undefined` \| ``null`` \| { `data?`: `any` ; `error?`: `any` ; `errors?`: `any`[] }\>
**writeGraphQLNullable**(`query`, `variables?`): [`RestRequest`](RestRequest.md)\<`undefined` \| ``null`` \| \{ `data?`: `any` ; `error?`: `any` ; `errors?`: `any`[] }\>

Same as writeGraphQLX(), but doesn't throw if GraphQL response contains
non-empty `error` or `errors` fields and instead returns the full response.
Expand All @@ -390,7 +394,7 @@ I.e. allows the caller to process these errors.

#### Returns

[`RestRequest`](RestRequest.md)<`undefined` \| ``null`` \| { `data?`: `any` ; `error?`: `any` ; `errors?`: `any`[] }\>
[`RestRequest`](RestRequest.md)\<`undefined` \| ``null`` \| \{ `data?`: `any` ; `error?`: `any` ; `errors?`: `any`[] }\>

#### Defined in

Expand All @@ -400,7 +404,7 @@ ___

### rangeUpload

**rangeUpload**(`path`, `mimeType`, `stream`, `method?`, `chunkSize`): `Promise`<``null`` \| `string`\>
**rangeUpload**(`path`, `mimeType`, `stream`, `method?`, `chunkSize`): `Promise`\<``null`` \| `string`\>

Performs a series of Content-Range requests with content from a sequence of
Buffers.
Expand All @@ -411,13 +415,13 @@ Buffers.
| :------ | :------ | :------ |
| `path` | `string` | `undefined` |
| `mimeType` | `string` | `undefined` |
| `stream` | `AsyncIterable`<`Buffer`\> | `undefined` |
| `stream` | `AsyncIterable`\<`Buffer`\> | `undefined` |
| `method` | ``"POST"`` \| ``"PUT"`` | `"POST"` |
| `chunkSize` | `number` | `undefined` |

#### Returns

`Promise`<``null`` \| `string`\>
`Promise`\<``null`` \| `string`\>

#### Defined in

Expand Down
6 changes: 5 additions & 1 deletion docs/classes/RestContentSizeOverLimitError.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### constructor

**new RestContentSizeOverLimitError**(`message`, `res`)
**new RestContentSizeOverLimitError**(`message`, `res`): [`RestContentSizeOverLimitError`](RestContentSizeOverLimitError.md)

#### Parameters

Expand All @@ -21,6 +21,10 @@
| `message` | `string` |
| `res` | [`RestResponse`](RestResponse.md) |

#### Returns

[`RestContentSizeOverLimitError`](RestContentSizeOverLimitError.md)

#### Inherited from

[RestResponseError](RestResponseError.md).[constructor](RestResponseError.md#constructor)
Expand Down
Loading

0 comments on commit 64d0467

Please sign in to comment.