@fixefy/fixefy-ui-utils 0.2.69 → 0.2.70
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.d.ts +1 -1
- package/dist/fixefy-ui-utils/src/auth/index.js +80 -0
- package/dist/fixefy-ui-utils/src/commander/index.js +391 -0
- package/dist/fixefy-ui-utils/src/constants/index.js +177 -0
- package/dist/fixefy-ui-utils/src/files/index.js +41 -0
- package/dist/fixefy-ui-utils/src/graphql/index.js +375 -0
- package/dist/fixefy-ui-utils/src/headers/index.js +148 -0
- package/dist/fixefy-ui-utils/src/images/index.js +34 -0
- package/dist/fixefy-ui-utils/src/index.js +41 -0
- package/dist/fixefy-ui-utils/src/json/index.js +170 -0
- package/dist/fixefy-ui-utils/src/makeStyles/index.js +23 -0
- package/dist/fixefy-ui-utils/src/page_context/index.js +1000 -0
- package/dist/fixefy-ui-utils/src/redirect/index.js +31 -0
- package/dist/fixefy-ui-utils/src/resolvers/index.js +51 -0
- package/dist/fixefy-ui-utils/src/transform/index.js +96 -0
- package/dist/fixefy-ui-utils/src/types/index.js +4 -0
- package/dist/headers/index.d.ts +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getJPart: function() {
|
|
13
|
+
return getJPart;
|
|
14
|
+
},
|
|
15
|
+
getJToken: function() {
|
|
16
|
+
return getJToken;
|
|
17
|
+
},
|
|
18
|
+
isHasKey: function() {
|
|
19
|
+
return isHasKey;
|
|
20
|
+
},
|
|
21
|
+
isJson: function() {
|
|
22
|
+
return isJson;
|
|
23
|
+
},
|
|
24
|
+
isNested: function() {
|
|
25
|
+
return isNested;
|
|
26
|
+
},
|
|
27
|
+
isResultValid: function() {
|
|
28
|
+
return isResultValid;
|
|
29
|
+
},
|
|
30
|
+
setJToken: function() {
|
|
31
|
+
return setJToken;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
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
|
+
}
|
|
40
|
+
const getJToken = (jToken, jsonPath, defaultValue)=>{
|
|
41
|
+
// input check - if key is invalid - return error
|
|
42
|
+
if (_fixefyvalidate.default.is_object_valid(jToken) === false) return defaultValue;
|
|
43
|
+
// convert indexes to properties
|
|
44
|
+
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
|
|
45
|
+
// strip a leading dot
|
|
46
|
+
jsonPath = jsonPath.replace(/^\./, '');
|
|
47
|
+
// split path by '.'
|
|
48
|
+
let isContinueLoop = true;
|
|
49
|
+
let currentToken;
|
|
50
|
+
const jsonPathParts = jsonPath.split('.');
|
|
51
|
+
try {
|
|
52
|
+
//for ( let i = 0, n = jsonPathParts.length && isContinueLoop; i < n; ++i ) {
|
|
53
|
+
for(let i = 0, n = jsonPathParts.length; isContinueLoop && i < n; ++i){
|
|
54
|
+
currentToken = jsonPathParts[i];
|
|
55
|
+
if (typeof jToken === 'string') {
|
|
56
|
+
jToken = JSON.parse(jToken);
|
|
57
|
+
}
|
|
58
|
+
if (currentToken in jToken) {
|
|
59
|
+
jToken = jToken[currentToken];
|
|
60
|
+
} else {
|
|
61
|
+
// if something in the process failed:
|
|
62
|
+
// 1. set the rv as the default value
|
|
63
|
+
// 2. stop the loop
|
|
64
|
+
jToken = defaultValue;
|
|
65
|
+
isContinueLoop = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} catch (_e) {
|
|
69
|
+
jToken = 'No Value Found';
|
|
70
|
+
}
|
|
71
|
+
return jToken;
|
|
72
|
+
};
|
|
73
|
+
const getJPart = (j, jsonPath, defaultValue)=>{
|
|
74
|
+
// if key is invalid - return error
|
|
75
|
+
if (j == null) return defaultValue;
|
|
76
|
+
// convert indexes to properties
|
|
77
|
+
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1');
|
|
78
|
+
// strip a leading dot
|
|
79
|
+
jsonPath = jsonPath.replace(/^\./, '');
|
|
80
|
+
// split path by '.'
|
|
81
|
+
let _isArrayValid = false, _isStringValid = false, currentPathPart, isLoop = true;
|
|
82
|
+
const pathParts = jsonPath.split('.');
|
|
83
|
+
for(let i = 0, n = pathParts.length; isLoop && i < n; ++i){
|
|
84
|
+
currentPathPart = pathParts[i];
|
|
85
|
+
_isStringValid = _fixefyvalidate.default.is_string_valid(j);
|
|
86
|
+
_isArrayValid = _fixefyvalidate.default.is_array_valid(j);
|
|
87
|
+
if (_isStringValid === true || _isArrayValid === true) {
|
|
88
|
+
if (_isStringValid === true) {
|
|
89
|
+
j = JSON.parse(j);
|
|
90
|
+
} else {
|
|
91
|
+
j = j.reduce((acc, cur)=>{
|
|
92
|
+
const innerJ = getJPart(cur, pathParts.slice(i).join('.'), defaultValue);
|
|
93
|
+
if (_fixefyvalidate.default.is_array_valid(innerJ)) {
|
|
94
|
+
acc.push(...innerJ);
|
|
95
|
+
} else {
|
|
96
|
+
acc.push(innerJ);
|
|
97
|
+
}
|
|
98
|
+
return acc;
|
|
99
|
+
}, []);
|
|
100
|
+
isLoop = false;
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
if (j[currentPathPart] != null && currentPathPart in j) {
|
|
104
|
+
j = j[currentPathPart];
|
|
105
|
+
} else {
|
|
106
|
+
// if something in the process failed:
|
|
107
|
+
// 1. set the rv as the default value
|
|
108
|
+
// 2. stop the loop`
|
|
109
|
+
j = defaultValue;
|
|
110
|
+
isLoop = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return j;
|
|
115
|
+
};
|
|
116
|
+
const isHasKey = (array, key)=>{
|
|
117
|
+
let rv = false, isContinueLoop = true, current_keys;
|
|
118
|
+
for(let i = 0; i < array.length && isContinueLoop; ++i){
|
|
119
|
+
current_keys = Object.keys(array[i]);
|
|
120
|
+
if ((current_keys || []).indexOf(key) > -1) {
|
|
121
|
+
rv = true;
|
|
122
|
+
isContinueLoop = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return rv;
|
|
126
|
+
};
|
|
127
|
+
const isJson = (obj)=>{
|
|
128
|
+
let objAsString;
|
|
129
|
+
try {
|
|
130
|
+
objAsString = JSON.stringify(obj);
|
|
131
|
+
} catch (_e) {
|
|
132
|
+
objAsString = null;
|
|
133
|
+
}
|
|
134
|
+
if (_fixefyvalidate.default.is_string_valid(objAsString) == false) return false;
|
|
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;
|
|
136
|
+
return rv;
|
|
137
|
+
};
|
|
138
|
+
const isNested = (obj)=>{
|
|
139
|
+
const rv = Object.keys(obj).some((key)=>{
|
|
140
|
+
return obj[key] && typeof obj[key] === 'object';
|
|
141
|
+
});
|
|
142
|
+
return rv;
|
|
143
|
+
};
|
|
144
|
+
const isResultValid = (jResult)=>{
|
|
145
|
+
if (_fixefyvalidate.default.is_object_valid(jResult) === false) return false;
|
|
146
|
+
const rv = getJPart(jResult, 'ok', 0);
|
|
147
|
+
return !!rv;
|
|
148
|
+
};
|
|
149
|
+
const setJToken = (jEntity, fieldPathsAndValues)=>{
|
|
150
|
+
let jCurrentToken, currentPath, pathParts, fieldName;
|
|
151
|
+
for(let i = 0; i < fieldPathsAndValues.length; ++i){
|
|
152
|
+
currentPath = fieldPathsAndValues[i]['json_path'];
|
|
153
|
+
if (_fixefyvalidate.default.is_string_valid(currentPath)) {
|
|
154
|
+
fieldName = currentPath;
|
|
155
|
+
pathParts = currentPath.split('.');
|
|
156
|
+
if (_fixefyvalidate.default.is_array_valid(pathParts)) {
|
|
157
|
+
fieldName = pathParts[pathParts.length - 1];
|
|
158
|
+
pathParts = pathParts.splice(0, Math.max(0, pathParts.length - 1));
|
|
159
|
+
if (_fixefyvalidate.default.is_array_valid(pathParts)) {
|
|
160
|
+
currentPath = pathParts.join('.');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
jCurrentToken = getJPart(jEntity, currentPath, null);
|
|
164
|
+
if (_fixefyvalidate.default.is_object_valid(jCurrentToken) || isJson(jCurrentToken) === false) {
|
|
165
|
+
jCurrentToken = jEntity;
|
|
166
|
+
}
|
|
167
|
+
jCurrentToken[fieldName] = fieldPathsAndValues[i]['value'];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
makeStyles: function() {
|
|
13
|
+
return makeStyles;
|
|
14
|
+
},
|
|
15
|
+
useStyles: function() {
|
|
16
|
+
return useStyles;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _tssreact = require("tss-react");
|
|
20
|
+
const _styles = require("@mui/material/styles");
|
|
21
|
+
const { makeStyles, useStyles } = (0, _tssreact.createMakeStyles)({
|
|
22
|
+
useTheme: _styles.useTheme
|
|
23
|
+
});
|