@fixefy/fixefy-ui-utils 0.2.60 → 0.2.61
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/auth/index.js +1 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/json/index.js +16 -11
- package/package.json +2 -1
package/dist/auth/index.js
CHANGED
|
@@ -77,13 +77,4 @@ const attachAuth = (ctx, headers)=>{
|
|
|
77
77
|
};
|
|
78
78
|
const getToken = (ctx)=>{
|
|
79
79
|
return (0, _nookies.parseCookies)(ctx)['token'];
|
|
80
|
-
}
|
|
81
|
-
// const rv = await client
|
|
82
|
-
// .query({ query: gql(ME_QUERY) })
|
|
83
|
-
// .then(({ data }) => ({ loggedInUser: data }))
|
|
84
|
-
// .catch(() => ({
|
|
85
|
-
// loggedInUser: null,
|
|
86
|
-
// })); // Fail gracefully
|
|
87
|
-
// return rv;
|
|
88
|
-
// };
|
|
89
|
-
;
|
|
80
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ const _page_context = /*#__PURE__*/ _interop_require_default(_export_star(requir
|
|
|
21
21
|
_export_star(require("./redirect"), exports);
|
|
22
22
|
_export_star(require("./transform"), exports);
|
|
23
23
|
_export_star(require("./types"), exports);
|
|
24
|
-
_export_star(require("./validate"), exports);
|
|
25
24
|
function _export_star(from, to) {
|
|
26
25
|
Object.keys(from).forEach(function(k) {
|
|
27
26
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/dist/json/index.js
CHANGED
|
@@ -31,10 +31,15 @@ _export(exports, {
|
|
|
31
31
|
return setJToken;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
const
|
|
34
|
+
const _fixefyvalidate = /*#__PURE__*/ _interop_require_default(require("@fixefy/fixefy-validate"));
|
|
35
|
+
function _interop_require_default(obj) {
|
|
36
|
+
return obj && obj.__esModule ? obj : {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
35
40
|
const getJToken = (jToken, jsonPath, defaultValue)=>{
|
|
36
41
|
// input check - if key is invalid - return error
|
|
37
|
-
if (
|
|
42
|
+
if (_fixefyvalidate.default.is_object_valid(jToken) === false) return defaultValue;
|
|
38
43
|
// convert indexes to properties
|
|
39
44
|
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
|
|
40
45
|
// strip a leading dot
|
|
@@ -77,15 +82,15 @@ const getJPart = (j, jsonPath, defaultValue)=>{
|
|
|
77
82
|
const pathParts = jsonPath.split('.');
|
|
78
83
|
for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
|
|
79
84
|
currentPathPart = pathParts[i];
|
|
80
|
-
_isStringValid =
|
|
81
|
-
_isArrayValid =
|
|
85
|
+
_isStringValid = _fixefyvalidate.default.is_string_valid(j);
|
|
86
|
+
_isArrayValid = _fixefyvalidate.default.is_array_valid(j);
|
|
82
87
|
if (_isStringValid === true || _isArrayValid === true) {
|
|
83
88
|
if (_isStringValid === true) {
|
|
84
89
|
j = JSON.parse(j);
|
|
85
90
|
} else {
|
|
86
91
|
j = j.reduce((acc, cur)=>{
|
|
87
92
|
const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
|
|
88
|
-
if (
|
|
93
|
+
if (_fixefyvalidate.default.is_array_valid(innerJ)) {
|
|
89
94
|
acc.push(...innerJ);
|
|
90
95
|
} else {
|
|
91
96
|
acc.push(innerJ);
|
|
@@ -126,7 +131,7 @@ const isJson = (obj)=>{
|
|
|
126
131
|
} catch (_e) {
|
|
127
132
|
objAsString = null;
|
|
128
133
|
}
|
|
129
|
-
if (
|
|
134
|
+
if (_fixefyvalidate.default.is_string_valid(objAsString) == false) return false;
|
|
130
135
|
const rv = (objAsString === null || objAsString === void 0 ? void 0 : objAsString.indexOf('{')) === 0 && (objAsString === null || objAsString === void 0 ? void 0 : objAsString.indexOf('}')) === (objAsString === null || objAsString === void 0 ? void 0 : objAsString.length) - 1;
|
|
131
136
|
return rv;
|
|
132
137
|
};
|
|
@@ -137,7 +142,7 @@ const isNested = (obj)=>{
|
|
|
137
142
|
return rv;
|
|
138
143
|
};
|
|
139
144
|
const isResultValid = (jResult)=>{
|
|
140
|
-
if (
|
|
145
|
+
if (_fixefyvalidate.default.is_object_valid(jResult) === false) return false;
|
|
141
146
|
const rv = getJPart(jResult, 'ok', 0);
|
|
142
147
|
return !!rv;
|
|
143
148
|
};
|
|
@@ -145,18 +150,18 @@ const setJToken = (jEntity, fieldPathsAndValues)=>{
|
|
|
145
150
|
let jCurrentToken, currentPath, pathParts, fieldName;
|
|
146
151
|
for(let i = 0; i < fieldPathsAndValues.length; ++i){
|
|
147
152
|
currentPath = fieldPathsAndValues[i]['json_path'];
|
|
148
|
-
if (
|
|
153
|
+
if (_fixefyvalidate.default.is_string_valid(currentPath)) {
|
|
149
154
|
fieldName = currentPath;
|
|
150
155
|
pathParts = currentPath.split('.');
|
|
151
|
-
if (
|
|
156
|
+
if (_fixefyvalidate.default.is_array_valid(pathParts)) {
|
|
152
157
|
fieldName = pathParts[pathParts.length - 1];
|
|
153
158
|
pathParts = pathParts.splice(0, Math.max(0, pathParts.length - 1));
|
|
154
|
-
if (
|
|
159
|
+
if (_fixefyvalidate.default.is_array_valid(pathParts)) {
|
|
155
160
|
currentPath = pathParts.join('.');
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
jCurrentToken = getJPart(jEntity, currentPath, null);
|
|
159
|
-
if (
|
|
164
|
+
if (_fixefyvalidate.default.is_object_valid(jCurrentToken) || isJson(jCurrentToken) === false) {
|
|
160
165
|
jCurrentToken = jEntity;
|
|
161
166
|
}
|
|
162
167
|
jCurrentToken[fieldName] = fieldPathsAndValues[i]['value'];
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@fixefy/fixefy-entities": ">=0.1.20",
|
|
8
8
|
"@fixefy/fixefy-numeric": ">=0.1.3",
|
|
9
|
+
"@fixefy/fixefy-validate": ">=0.1.25",
|
|
9
10
|
"@mui/material": ">=5.16.12",
|
|
10
11
|
"@mui/styles": ">=5.16.12",
|
|
11
12
|
"convert-excel-to-json": ">=1.7.0",
|
|
@@ -65,5 +66,5 @@
|
|
|
65
66
|
"require": "./dist/index.js"
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
|
-
"version": "0.2.
|
|
69
|
+
"version": "0.2.61"
|
|
69
70
|
}
|