Skip to content

Commit ec05e4a

Browse files
authored
Routine maintenance 2023-07 (#158)
* Large package updates * Run yarn upgrade * Bump major * Update axios dev dependency * Do not use undeclared dependency * Remove axios as dev dependency (unneeded) * Add husky * Update yarn.lock * Add GH action
1 parent b0dea64 commit ec05e4a

File tree

9 files changed

+4935
-6875
lines changed

9 files changed

+4935
-6875
lines changed

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish
2+
run-name: ${{ github.actor }} published a new release
3+
on:
4+
release:
5+
types: [published]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out latest code
11+
uses: actions/checkout@v3
12+
- name: Set up node
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: '18.x'
16+
registry-url: 'https://registry.npmjs.org'
17+
scope: '@launchpadlab'
18+
- name: Install dependencies
19+
run: HUSKY=0 yarn --frozen-lockfile
20+
- name: Publish package on NPM
21+
run: npm publish
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn run docs && git add docs.md

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: node_js
2+
dist: focal
23
node_js:
3-
- '8'
4+
- '18'
45
before_script:
56
- 'yarn lint'
67
notifications:

docs.md

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,45 @@
22

33
### Table of Contents
44

5-
- [handleSuccess][1]
6-
- [Parameters][2]
7-
- [Examples][3]
8-
- [handleFailure][4]
9-
- [Parameters][5]
10-
- [Examples][6]
11-
- [handleResponse][7]
12-
- [Parameters][8]
13-
- [Examples][9]
14-
- [setOnSuccess][10]
15-
- [Parameters][11]
16-
- [Examples][12]
17-
- [setOnFailure][13]
18-
- [Parameters][14]
19-
- [Examples][15]
20-
- [setOnResponse][16]
21-
- [Parameters][17]
22-
- [Examples][18]
23-
- [LP_API][19]
24-
- [Examples][20]
25-
- [createRequest][21]
26-
- [Parameters][22]
27-
- [Examples][23]
28-
- [middleware][24]
29-
- [reducer][25]
30-
- [Examples][26]
31-
- [selectors][27]
32-
- [Examples][28]
33-
- [createStubRequest][29]
34-
- [Parameters][30]
35-
- [Examples][31]
5+
* [handleSuccess][1]
6+
* [Parameters][2]
7+
* [Examples][3]
8+
* [handleFailure][4]
9+
* [Parameters][5]
10+
* [Examples][6]
11+
* [handleResponse][7]
12+
* [Parameters][8]
13+
* [Examples][9]
14+
* [setOnSuccess][10]
15+
* [Parameters][11]
16+
* [Examples][12]
17+
* [setOnFailure][13]
18+
* [Parameters][14]
19+
* [Examples][15]
20+
* [setOnResponse][16]
21+
* [Parameters][17]
22+
* [Examples][18]
23+
* [LP\_API][19]
24+
* [Examples][20]
25+
* [createRequest][21]
26+
* [Parameters][22]
27+
* [Examples][23]
28+
* [middleware][24]
29+
* [reducer][25]
30+
* [Examples][26]
31+
* [selectors][27]
32+
* [Examples][28]
33+
* [createStubRequest][29]
34+
* [Parameters][30]
35+
* [Examples][31]
3636

3737
## handleSuccess
3838

3939
A function that takes an API action handler and only applies that handler when the request succeeds.
4040

4141
### Parameters
4242

43-
- `handler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
43+
* `handler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
4444

4545
### Examples
4646

@@ -61,7 +61,7 @@ A function that takes an API action handler and only applies that handler when t
6161

6262
### Parameters
6363

64-
- `handler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
64+
* `handler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
6565

6666
### Examples
6767

@@ -83,8 +83,8 @@ and applies the handlers when the responses have the correct status.
8383

8484
### Parameters
8585

86-
- `successHandler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
87-
- `failureHandler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
86+
* `successHandler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
87+
* `failureHandler` **[Function][32]** An action handler that is passed `state`, `action` and `data` params
8888

8989
### Examples
9090

@@ -111,8 +111,8 @@ A function that creates an API action handler that sets a path in the state with
111111

112112
### Parameters
113113

114-
- `path` **[String][33]** The path in the state to set with the returned data
115-
- `transform` **[Function][32]?** A function that determines the data that is set in the state. Passed `action` and `state` params.
114+
* `path` **[String][33]** The path in the state to set with the returned data
115+
* `transform` **[Function][32]?** A function that determines the data that is set in the state. Passed `action` and `state` params.
116116

117117
### Examples
118118

@@ -131,8 +131,8 @@ A function that creates an API action handler that sets a path in the state with
131131

132132
### Parameters
133133

134-
- `path` **[String][33]** The path in the state to set with the returned error
135-
- `transform` **[Function][32]?** A function that determines the data that is set in the state. Passed `action` and `state` params.
134+
* `path` **[String][33]** The path in the state to set with the returned error
135+
* `transform` **[Function][32]?** A function that determines the data that is set in the state. Passed `action` and `state` params.
136136

137137
### Examples
138138

@@ -151,10 +151,10 @@ A function that creates an API action handler that sets one of two given paths i
151151

152152
### Parameters
153153

154-
- `path` **[String][33]** The path in the state to set with the returned data on success
155-
- `path` **[String][33]** The path in the state to set with the returned error on failure
156-
- `transform` **[Function][32]?** A function that determines the success data that is set in the state. Passed `action` and `state` params.
157-
- `transform` **[Function][32]?** A function that determines the error data that is set in the state. Passed `action` and `state` params.
154+
* `path` **[String][33]** The path in the state to set with the returned data on success
155+
* `path` **[String][33]** The path in the state to set with the returned error on failure
156+
* `transform` **[Function][32]?** A function that determines the success data that is set in the state. Passed `action` and `state` params.
157+
* `transform` **[Function][32]?** A function that determines the error data that is set in the state. Passed `action` and `state` params.
158158

159159
### Examples
160160

@@ -167,7 +167,7 @@ handleActions({
167167

168168
Returns **[Function][32]** An action handler
169169

170-
## LP_API
170+
## LP\_API
171171

172172
A unique key that identifies dispatched actions to be handled by the LP
173173
Redux Api middleware. This is implemented as a Symbol, instead of a String
@@ -186,8 +186,8 @@ function fooAction () {
186186
return {
187187
[LP_API]: {
188188
url: 'http://foo.com/posts',
189-
requestAction: 'REQUEST',
190-
successAction: 'SUCCESS',
189+
requestAction: 'REQUEST',
190+
successAction: 'SUCCESS',
191191
failureAction: 'FAILURE',
192192
}
193193
}
@@ -202,8 +202,8 @@ Note: there are convenience functions for each request method: `createPostReques
202202

203203
### Parameters
204204

205-
- `type` **[String][33]** A unique key that will be used to identify the request internally in redux
206-
- `definition` **([Object][36] \| [Function][32])** An object of config options for the adapter, or a function that returns config options.
205+
* `type` **[String][33]** A unique key that will be used to identify the request internally in redux
206+
* `definition` **([Object][36] | [Function][32])** An object of config options for the adapter, or a function that returns config options.
207207

208208
### Examples
209209

@@ -243,11 +243,11 @@ The `adapter` argument is the function that will be invoked to make the API requ
243243

244244
The following options may be used to configure the middleware:
245245

246-
- `onUnauthorized` (default=`null`): An action creator to be called and dispatched when the server rejects a request with a status of `unauthorized`.
247-
- `requestAction` (default=`null`): An action creator to be called and dispatched when the initial request is made.
248-
- `successAction` (default=`null`): An action creator to be called and dispatched if the request succeeds.
249-
- `failureAction` (default=`null`): An action creator to be called and dispatched if the request fails.
250-
- any options used by the adapter
246+
* `onUnauthorized` (default=`null`): An action creator to be called and dispatched when the server rejects a request with a status of `unauthorized`.
247+
* `requestAction` (default=`null`): An action creator to be called and dispatched when the initial request is made.
248+
* `successAction` (default=`null`): An action creator to be called and dispatched if the request succeeds.
249+
* `failureAction` (default=`null`): An action creator to be called and dispatched if the request fails.
250+
* any options used by the adapter
251251

252252
## reducer
253253

@@ -286,22 +286,22 @@ selectStatus(REQ_FETCH_USERS, state) // -> 'loading'
286286

287287
This library exports the following selectors for determining the status of requests:
288288

289-
- `selectors.status(state, requestAction, [slice])`
290-
- `selectors.hasStatus(state, requestAction, [slice])`
291-
- `selectors.isLoading(state, requestAction, [slice])`
292-
- `selectors.isComplete(state, requestAction, [slice])`
293-
- `selectors.isSuccess(state, requestAction, [slice])`
294-
- `selectors.isFailure(state, requestAction, [slice])`
289+
* `selectors.status(state, requestAction, [slice])`
290+
* `selectors.hasStatus(state, requestAction, [slice])`
291+
* `selectors.isLoading(state, requestAction, [slice])`
292+
* `selectors.isComplete(state, requestAction, [slice])`
293+
* `selectors.isSuccess(state, requestAction, [slice])`
294+
* `selectors.isFailure(state, requestAction, [slice])`
295295

296296
In order to work, the `lp-redux-api` reducer must be included in `combineReducers()`.
297297
Selectors expect the reducer to be keyed under `'api'`- if a different key is used,
298298
it must be passed as the optional `slice` parameter.
299299

300300
The status returned by `selectors.status()` can be one of the following exported constants:
301301

302-
- `LP_API_STATUS_LOADING`: `'loading'`
303-
- `LP_API_STATUS_SUCCESS`: `'success'`
304-
- `LP_API_STATUS_FAILURE`: `'failure'`
302+
* `LP_API_STATUS_LOADING`: `'loading'`
303+
* `LP_API_STATUS_SUCCESS`: `'success'`
304+
* `LP_API_STATUS_FAILURE`: `'failure'`
305305

306306
### Examples
307307

@@ -336,10 +336,11 @@ If an exception is thrown from the data creator function, the "request" will rej
336336

337337
### Parameters
338338

339-
- `type` **[String][33]** A unique key that will be used to identify the request internally in redux
340-
- `dataDefinition` **([Object][36] \| [Function][32])** Data that the request will resolve with, or a function that returns data to resolve with.
341-
- `options` **[Object][36]?** Options object
342-
- `options.delay` **[Number][39]** Time (in ms) to delay the API request. Particularly useful when attempting to simulate loading states. (optional, default `0`)
339+
* `type` **[String][33]** A unique key that will be used to identify the request internally in redux
340+
* `dataDefinition` **([Object][36] | [Function][32])** Data that the request will resolve with, or a function that returns data to resolve with.
341+
* `options` **[Object][36]?** Options object
342+
343+
* `options.delay` **[Number][39]** Time (in ms) to delay the API request. Particularly useful when attempting to simulate loading states. (optional, default `0`)
343344

344345
### Examples
345346

package.json

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
{
22
"name": "@launchpadlab/lp-redux-api",
3-
"version": "6.3.1",
3+
"version": "7.0.0",
44
"description": "redux middleware and api library",
55
"main": "lib/index.js",
66
"scripts": {
77
"start": "yarn install && yarn run build:development",
88
"build": "mkdir -p lib && babel src --out-dir lib --no-comments --minified",
99
"build:development": "mkdir -p lib && babel src --watch --out-dir lib",
10-
"clean": "rimraf lib",
10+
"clean": "rm -rf lib",
1111
"docs": "documentation build src/index.js -f md -o docs.md",
1212
"lint": "eslint src",
13-
"precommit": "yarn run docs && git add docs.md",
14-
"prepublish": "yarn run lint && yarn run clean && yarn run build",
13+
"prepare": "yarn run lint && yarn run clean && yarn run build && husky install",
1514
"test": "jest",
1615
"test:coverage": "jest --coverage",
1716
"report-coverage": "codeclimate-test-reporter < coverage/lcov.info"
@@ -36,22 +35,20 @@
3635
"lib/"
3736
],
3837
"devDependencies": {
39-
"@babel/cli": "^7.5.5",
40-
"@babel/core": "^7.5.5",
41-
"@launchpadlab/babel-preset": "^2.1.0",
42-
"@launchpadlab/eslint-config": "^2.4.1",
43-
"axios": "^0.18.0",
44-
"codeclimate-test-reporter": "^0.5.0",
45-
"documentation": "^12.1.1",
46-
"eslint": "^6.2.1",
47-
"husky": "^3.0.4",
48-
"jest": "^24.9.0",
49-
"redux": "^4.0.4",
50-
"redux-mock-store": "^1.2.3"
38+
"@babel/cli": "^7.22.9",
39+
"@babel/core": "^7.22.9",
40+
"@launchpadlab/babel-preset": "^2.1.1",
41+
"@launchpadlab/eslint-config": "^3.0.1",
42+
"codeclimate-test-reporter": "^0.5.1",
43+
"documentation": "^14.0.2",
44+
"eslint": "^8.46.0",
45+
"husky": "^8.0.0",
46+
"jest": "^29.6.2",
47+
"redux": "^4.2.1",
48+
"redux-mock-store": "^1.5.4"
5149
},
5250
"dependencies": {
53-
"es6-symbol": "^3.1.1",
54-
"lodash": "^4.17.4",
51+
"lodash": "^4.17.21",
5552
"util-deprecate": "^1.0.2"
5653
}
5754
}

src/LP_API.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
import Symbol from 'es6-symbol'
2-
31
/**
42
* A unique key that identifies dispatched actions to be handled by the LP
53
* Redux Api middleware. This is implemented as a Symbol, instead of a String
64
* to guarantee uniqueness.
7-
*
5+
*
86
* The params provided as the value include anything that is supported by
97
* {@link middleware|LP Redux Api Middleware}
10-
*
8+
*
119
* @constant
1210
* @type {Symbol}
1311
* @default
1412
* @example
15-
*
13+
*
1614
* // An example action creator
1715
* function fooAction () {
1816
* return {
1917
* [LP_API]: {
2018
* url: 'http://foo.com/posts',
21-
* requestAction: 'REQUEST',
22-
* successAction: 'SUCCESS',
19+
* requestAction: 'REQUEST',
20+
* successAction: 'SUCCESS',
2321
* failureAction: 'FAILURE',
2422
* }
2523
* }
26-
* }
24+
* }
2725
*/
2826

2927
const LP_API = Symbol('Lp Api')

0 commit comments

Comments
 (0)