@builttocreate/engine-utils 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -5
- package/dist/paginationHelper.js +39 -0
- package/dist/reduxApiMiddleware.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
4
|
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -13,7 +11,13 @@ Object.defineProperty(exports, "reduxApiMiddleware", {
|
|
|
13
11
|
return _reduxApiMiddleware["default"];
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
|
-
|
|
14
|
+
Object.defineProperty(exports, "CALL_API", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _reduxApiMiddleware.CALL_API;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.paginationHelper = exports.activityHelper = exports.fieldHelper = exports.chartHelper = exports.tableHelper = exports["default"] = void 0;
|
|
17
21
|
|
|
18
22
|
var tableHelper = _interopRequireWildcard(require("./tableHelper"));
|
|
19
23
|
|
|
@@ -31,13 +35,18 @@ var activityHelper = _interopRequireWildcard(require("./activityHelper"));
|
|
|
31
35
|
|
|
32
36
|
exports.activityHelper = activityHelper;
|
|
33
37
|
|
|
34
|
-
var _reduxApiMiddleware =
|
|
38
|
+
var _reduxApiMiddleware = _interopRequireWildcard(require("./reduxApiMiddleware"));
|
|
39
|
+
|
|
40
|
+
var paginationHelper = _interopRequireWildcard(require("./paginationHelper"));
|
|
35
41
|
|
|
42
|
+
exports.paginationHelper = paginationHelper;
|
|
36
43
|
var _default = {
|
|
37
44
|
tableHelper: tableHelper,
|
|
38
45
|
chartHelper: chartHelper,
|
|
39
46
|
fieldHelper: fieldHelper,
|
|
40
47
|
activityHelper: activityHelper,
|
|
41
|
-
reduxApiMiddleware: _reduxApiMiddleware["default"]
|
|
48
|
+
reduxApiMiddleware: _reduxApiMiddleware["default"],
|
|
49
|
+
CALL_API: _reduxApiMiddleware.CALL_API,
|
|
50
|
+
paginationHelper: paginationHelper
|
|
42
51
|
};
|
|
43
52
|
exports["default"] = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.normalizeArray = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Normalize an array of objects
|
|
10
|
+
*
|
|
11
|
+
* @param {String|Func} key
|
|
12
|
+
* @param {Array} array
|
|
13
|
+
* @param {Function} keyExtractor //optional
|
|
14
|
+
*
|
|
15
|
+
* Example Input:
|
|
16
|
+
* param key = 'name';
|
|
17
|
+
* param array = [{name: 'frank', age: 19}, {name: 'joe', age: 22}, {name: 'bob', age: 44}]
|
|
18
|
+
*
|
|
19
|
+
* Example return:
|
|
20
|
+
* {
|
|
21
|
+
* 'frank': {name: 'frank', age: 19} ,
|
|
22
|
+
* 'joe': {name: 'joe', age: 22} ,
|
|
23
|
+
* 'bob': {name: 'bob', age: 44} ,
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
var normalizeArray = function normalizeArray(key, array) {
|
|
27
|
+
var obj = {};
|
|
28
|
+
array.forEach(function (e) {
|
|
29
|
+
var objectKey = typeof key === 'function' ? key(e) : e[key];
|
|
30
|
+
obj[objectKey] = e;
|
|
31
|
+
});
|
|
32
|
+
return obj;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.normalizeArray = normalizeArray;
|
|
36
|
+
var _default = {
|
|
37
|
+
normalizeArray: normalizeArray
|
|
38
|
+
};
|
|
39
|
+
exports["default"] = _default;
|
|
@@ -23,7 +23,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
|
|
|
23
23
|
getState = _ref.getState;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @param next //Callback for the action
|
|
26
|
+
* @param next //Callback for the action
|
|
27
27
|
* @param action //Action object
|
|
28
28
|
*
|
|
29
29
|
* async action example: {
|
|
@@ -37,7 +37,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
|
|
|
37
37
|
*/
|
|
38
38
|
return function (next) {
|
|
39
39
|
return function (action) {
|
|
40
|
-
var callApi = action[CALL_API]; //If callApi is not defined then it is a normal action (synchronous) pass it through
|
|
40
|
+
var callApi = action[CALL_API]; //If callApi is not defined then it is a normal action (synchronous) pass it through
|
|
41
41
|
|
|
42
42
|
if (typeof callApi === 'undefined') return next(action);
|
|
43
43
|
var types = callApi.types,
|
|
@@ -51,7 +51,7 @@ var callApiMiddleware = function callApiMiddleware(_ref) {
|
|
|
51
51
|
* All async actions should have three action types: requested, success, & failure
|
|
52
52
|
* All actions should be strings.
|
|
53
53
|
*
|
|
54
|
-
* apiCall:
|
|
54
|
+
* apiCall:
|
|
55
55
|
* All aysnc actions should have an apiCall function
|
|
56
56
|
*/
|
|
57
57
|
|