@bigbinary/neeto-commons-frontend 2.0.31 → 2.0.32
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/cypress-commands.d.ts +1 -0
- package/cypress-utils.cjs.js +1035 -52
- package/cypress-utils.d.ts +27 -42
- package/cypress-utils.js +1035 -52
- package/initializers.cjs.js +39 -5
- package/initializers.js +40 -6
- package/package.json +1 -1
package/initializers.cjs.js
CHANGED
|
@@ -164,6 +164,19 @@ nullSafe(snakeToCamelCase);
|
|
|
164
164
|
nullSafe(camelToSnakeCase);
|
|
165
165
|
nullSafe(capitalize);
|
|
166
166
|
|
|
167
|
+
var matchesImpl = function matchesImpl(pattern, object) {
|
|
168
|
+
var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
169
|
+
if (object === pattern) return true;
|
|
170
|
+
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
171
|
+
if (ramda.isNil(pattern) || ramda.isNil(object)) return false;
|
|
172
|
+
if (_typeof(pattern) !== "object") return false;
|
|
173
|
+
return Object.entries(pattern).every(function (_ref) {
|
|
174
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
175
|
+
key = _ref2[0],
|
|
176
|
+
value = _ref2[1];
|
|
177
|
+
return matchesImpl(value, object[key], __parent);
|
|
178
|
+
});
|
|
179
|
+
};
|
|
167
180
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
168
181
|
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
169
182
|
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
@@ -204,6 +217,9 @@ var deepFreezeObject = function deepFreezeObject(object) {
|
|
|
204
217
|
}
|
|
205
218
|
return object;
|
|
206
219
|
};
|
|
220
|
+
var matches = /*#__PURE__*/ramda.curry(function (pattern, object) {
|
|
221
|
+
return matchesImpl(pattern, object);
|
|
222
|
+
});
|
|
207
223
|
var filterNonNull = function filterNonNull(object) {
|
|
208
224
|
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
209
225
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
@@ -810,6 +826,7 @@ var shouldShowToastr = function shouldShowToastr(response) {
|
|
|
810
826
|
};
|
|
811
827
|
var setAuthHeaders = function setAuthHeaders() {
|
|
812
828
|
var _document$querySelect, _axios$defaults$heade, _globalProps$user, _globalProps$user2;
|
|
829
|
+
// @ts-ignore
|
|
813
830
|
axios__default["default"].defaults.headers = (_axios$defaults$heade = {}, _defineProperty(_axios$defaults$heade, HEADERS_KEYS.accept, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.contentType, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.xCsrfToken, (_document$querySelect = document.querySelector('[name="csrf-token"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("content")), _axios$defaults$heade);
|
|
814
831
|
var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
|
|
815
832
|
var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
|
|
@@ -849,7 +866,16 @@ var transformErrorKeysToCamelCase = function transformErrorKeysToCamelCase(error
|
|
|
849
866
|
var showSuccessToastr = function showSuccessToastr(response) {
|
|
850
867
|
var _response$config$show = response.config.showToastr,
|
|
851
868
|
showToastr = _response$config$show === void 0 ? true : _response$config$show;
|
|
852
|
-
if (showToastr
|
|
869
|
+
if (!showToastr) return response;
|
|
870
|
+
if (matches({
|
|
871
|
+
showThumbsUpToastr: true
|
|
872
|
+
}, response.data)) {
|
|
873
|
+
// @ts-ignore
|
|
874
|
+
neetoui.Toastr.success("", {
|
|
875
|
+
icon: "👍",
|
|
876
|
+
className: "w-20"
|
|
877
|
+
});
|
|
878
|
+
} else if (shouldShowToastr(response.data)) {
|
|
853
879
|
neetoui.Toastr.success(response.data);
|
|
854
880
|
}
|
|
855
881
|
return response;
|
|
@@ -888,8 +914,10 @@ var showErrorToastr = function showErrorToastr(error) {
|
|
|
888
914
|
showToastr = _ref3$showToastr === void 0 ? true : _ref3$showToastr;
|
|
889
915
|
if (!showToastr) return error;
|
|
890
916
|
if (axios__default["default"].isCancel(error)) {
|
|
917
|
+
// @ts-ignore
|
|
891
918
|
neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.requestCanceled"));
|
|
892
919
|
} else if (error.message === "Network Error") {
|
|
920
|
+
// @ts-ignore
|
|
893
921
|
neetoui.Toastr.error(i18next__default["default"].t("neetoCommons.toastr.error.networkError"));
|
|
894
922
|
} else {
|
|
895
923
|
neetoui.Toastr.error(error);
|
|
@@ -977,14 +1005,20 @@ var resource = {
|
|
|
977
1005
|
add_one: "{{entity}} has been added successfully.",
|
|
978
1006
|
add_other: "{{entity}} have been added successfully.",
|
|
979
1007
|
save: "{{entity}} has been saved successfully.",
|
|
1008
|
+
save_one: "{{entity}} has been saved successfully.",
|
|
1009
|
+
save_other: "{{entity}} have been saved successfully.",
|
|
980
1010
|
update: "{{entity}} has been updated successfully.",
|
|
1011
|
+
update_one: "{{entity}} has been updated successfully.",
|
|
1012
|
+
update_other: "{{entity}} have been updated successfully.",
|
|
981
1013
|
delete_one: "{{entity}} has been deleted successfully.",
|
|
982
1014
|
delete_other: "{{entity}} have been deleted successfully.",
|
|
983
1015
|
clone: "{{entity}} has been cloned successfully.",
|
|
984
1016
|
notFound: "{{entity}} does not exist.",
|
|
985
|
-
remove_one: "{{entity}}
|
|
986
|
-
remove_other: "{{entity}}
|
|
987
|
-
sent: "{{entity}} sent successfully."
|
|
1017
|
+
remove_one: "{{entity}} has been removed successfully.",
|
|
1018
|
+
remove_other: "{{entity}} have been removed successfully.",
|
|
1019
|
+
sent: "{{entity}} sent successfully.",
|
|
1020
|
+
merged: "{{entity}} have been successfully merged.",
|
|
1021
|
+
disconnected: "{{entity}} has been successfully disconnected."
|
|
988
1022
|
};
|
|
989
1023
|
var otp = {
|
|
990
1024
|
sent: "OTP has been sent successfully.",
|
|
@@ -992,7 +1026,7 @@ var otp = {
|
|
|
992
1026
|
verified: "OTP has been verified successfully."
|
|
993
1027
|
};
|
|
994
1028
|
var upload = {
|
|
995
|
-
error: "An error
|
|
1029
|
+
error: "An error occurred while uploading the file"
|
|
996
1030
|
};
|
|
997
1031
|
var image = {
|
|
998
1032
|
profile: {
|
package/initializers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Toastr } from '@bigbinary/neetoui';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import i18next from 'i18next';
|
|
4
|
-
import { curryN, isNil, values, prop, evolve, omit, mergeDeepLeft, either, isEmpty } from 'ramda';
|
|
4
|
+
import { curryN, isNil, curry, values, prop, evolve, omit, mergeDeepLeft, either, isEmpty } from 'ramda';
|
|
5
5
|
import require$$0, { useDebugValue } from 'react';
|
|
6
6
|
import { initReactI18next } from 'react-i18next';
|
|
7
7
|
import Logger from 'js-logger';
|
|
@@ -152,6 +152,19 @@ nullSafe(snakeToCamelCase);
|
|
|
152
152
|
nullSafe(camelToSnakeCase);
|
|
153
153
|
nullSafe(capitalize);
|
|
154
154
|
|
|
155
|
+
var matchesImpl = function matchesImpl(pattern, object) {
|
|
156
|
+
var __parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : object;
|
|
157
|
+
if (object === pattern) return true;
|
|
158
|
+
if (typeof pattern === "function" && pattern(object, __parent)) return true;
|
|
159
|
+
if (isNil(pattern) || isNil(object)) return false;
|
|
160
|
+
if (_typeof(pattern) !== "object") return false;
|
|
161
|
+
return Object.entries(pattern).every(function (_ref) {
|
|
162
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
163
|
+
key = _ref2[0],
|
|
164
|
+
value = _ref2[1];
|
|
165
|
+
return matchesImpl(value, object[key], __parent);
|
|
166
|
+
});
|
|
167
|
+
};
|
|
155
168
|
var transformObjectDeep = function transformObjectDeep(object, keyValueTransformer) {
|
|
156
169
|
var objectPreProcessor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
157
170
|
if (objectPreProcessor && typeof objectPreProcessor === "function") {
|
|
@@ -192,6 +205,9 @@ var deepFreezeObject = function deepFreezeObject(object) {
|
|
|
192
205
|
}
|
|
193
206
|
return object;
|
|
194
207
|
};
|
|
208
|
+
var matches = /*#__PURE__*/curry(function (pattern, object) {
|
|
209
|
+
return matchesImpl(pattern, object);
|
|
210
|
+
});
|
|
195
211
|
var filterNonNull = function filterNonNull(object) {
|
|
196
212
|
return Object.fromEntries(Object.entries(object).filter(function (_ref5) {
|
|
197
213
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
@@ -798,6 +814,7 @@ var shouldShowToastr = function shouldShowToastr(response) {
|
|
|
798
814
|
};
|
|
799
815
|
var setAuthHeaders = function setAuthHeaders() {
|
|
800
816
|
var _document$querySelect, _axios$defaults$heade, _globalProps$user, _globalProps$user2;
|
|
817
|
+
// @ts-ignore
|
|
801
818
|
axios.defaults.headers = (_axios$defaults$heade = {}, _defineProperty(_axios$defaults$heade, HEADERS_KEYS.accept, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.contentType, "application/json"), _defineProperty(_axios$defaults$heade, HEADERS_KEYS.xCsrfToken, (_document$querySelect = document.querySelector('[name="csrf-token"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("content")), _axios$defaults$heade);
|
|
802
819
|
var token = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.authenticationToken;
|
|
803
820
|
var email = (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email;
|
|
@@ -837,7 +854,16 @@ var transformErrorKeysToCamelCase = function transformErrorKeysToCamelCase(error
|
|
|
837
854
|
var showSuccessToastr = function showSuccessToastr(response) {
|
|
838
855
|
var _response$config$show = response.config.showToastr,
|
|
839
856
|
showToastr = _response$config$show === void 0 ? true : _response$config$show;
|
|
840
|
-
if (showToastr
|
|
857
|
+
if (!showToastr) return response;
|
|
858
|
+
if (matches({
|
|
859
|
+
showThumbsUpToastr: true
|
|
860
|
+
}, response.data)) {
|
|
861
|
+
// @ts-ignore
|
|
862
|
+
Toastr.success("", {
|
|
863
|
+
icon: "👍",
|
|
864
|
+
className: "w-20"
|
|
865
|
+
});
|
|
866
|
+
} else if (shouldShowToastr(response.data)) {
|
|
841
867
|
Toastr.success(response.data);
|
|
842
868
|
}
|
|
843
869
|
return response;
|
|
@@ -876,8 +902,10 @@ var showErrorToastr = function showErrorToastr(error) {
|
|
|
876
902
|
showToastr = _ref3$showToastr === void 0 ? true : _ref3$showToastr;
|
|
877
903
|
if (!showToastr) return error;
|
|
878
904
|
if (axios.isCancel(error)) {
|
|
905
|
+
// @ts-ignore
|
|
879
906
|
Toastr.error(i18next.t("neetoCommons.toastr.error.requestCanceled"));
|
|
880
907
|
} else if (error.message === "Network Error") {
|
|
908
|
+
// @ts-ignore
|
|
881
909
|
Toastr.error(i18next.t("neetoCommons.toastr.error.networkError"));
|
|
882
910
|
} else {
|
|
883
911
|
Toastr.error(error);
|
|
@@ -965,14 +993,20 @@ var resource = {
|
|
|
965
993
|
add_one: "{{entity}} has been added successfully.",
|
|
966
994
|
add_other: "{{entity}} have been added successfully.",
|
|
967
995
|
save: "{{entity}} has been saved successfully.",
|
|
996
|
+
save_one: "{{entity}} has been saved successfully.",
|
|
997
|
+
save_other: "{{entity}} have been saved successfully.",
|
|
968
998
|
update: "{{entity}} has been updated successfully.",
|
|
999
|
+
update_one: "{{entity}} has been updated successfully.",
|
|
1000
|
+
update_other: "{{entity}} have been updated successfully.",
|
|
969
1001
|
delete_one: "{{entity}} has been deleted successfully.",
|
|
970
1002
|
delete_other: "{{entity}} have been deleted successfully.",
|
|
971
1003
|
clone: "{{entity}} has been cloned successfully.",
|
|
972
1004
|
notFound: "{{entity}} does not exist.",
|
|
973
|
-
remove_one: "{{entity}}
|
|
974
|
-
remove_other: "{{entity}}
|
|
975
|
-
sent: "{{entity}} sent successfully."
|
|
1005
|
+
remove_one: "{{entity}} has been removed successfully.",
|
|
1006
|
+
remove_other: "{{entity}} have been removed successfully.",
|
|
1007
|
+
sent: "{{entity}} sent successfully.",
|
|
1008
|
+
merged: "{{entity}} have been successfully merged.",
|
|
1009
|
+
disconnected: "{{entity}} has been successfully disconnected."
|
|
976
1010
|
};
|
|
977
1011
|
var otp = {
|
|
978
1012
|
sent: "OTP has been sent successfully.",
|
|
@@ -980,7 +1014,7 @@ var otp = {
|
|
|
980
1014
|
verified: "OTP has been verified successfully."
|
|
981
1015
|
};
|
|
982
1016
|
var upload = {
|
|
983
|
-
error: "An error
|
|
1017
|
+
error: "An error occurred while uploading the file"
|
|
984
1018
|
};
|
|
985
1019
|
var image = {
|
|
986
1020
|
profile: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.32",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|