@bigbinary/neeto-commons-frontend 2.0.0 → 2.0.3

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/utils.js CHANGED
@@ -1,22 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var axios = require('axios');
6
- var ramda = require('ramda');
7
- var i18next = require('i18next');
8
- var general = require('pure/general');
9
- var dayjs = require('dayjs');
10
- var relativeTime = require('dayjs/plugin/relativeTime');
11
- var updateLocale = require('dayjs/plugin/updateLocale');
12
-
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
16
- var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
17
- var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
18
- var relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
19
- var updateLocale__default = /*#__PURE__*/_interopDefaultLegacy(updateLocale);
1
+ import axios from 'axios';
2
+ import { values, complement, isNil, isEmpty, curry, equals, toPairs, omit } from 'ramda';
3
+ import i18next from 'i18next';
4
+ import dayjs from 'dayjs';
5
+ import relativeTime from 'dayjs/plugin/relativeTime';
6
+ import updateLocale from 'dayjs/plugin/updateLocale';
20
7
 
21
8
  var HEADERS_KEYS = {
22
9
  xAuthEmail: "X-Auth-Email",
@@ -25,11 +12,72 @@ var HEADERS_KEYS = {
25
12
  };
26
13
 
27
14
  var resetAuthTokens = function resetAuthTokens() {
28
- ramda.values(HEADERS_KEYS).forEach(function (header) {
29
- delete axios__default["default"].defaults.headers[header];
15
+ values(HEADERS_KEYS).forEach(function (header) {
16
+ delete axios.defaults.headers[header];
30
17
  });
31
18
  };
32
19
 
20
+ function _arrayWithHoles(arr) {
21
+ if (Array.isArray(arr)) return arr;
22
+ }
23
+
24
+ function _iterableToArrayLimit(arr, i) {
25
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
26
+
27
+ if (_i == null) return;
28
+ var _arr = [];
29
+ var _n = true;
30
+ var _d = false;
31
+
32
+ var _s, _e;
33
+
34
+ try {
35
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
36
+ _arr.push(_s.value);
37
+
38
+ if (i && _arr.length === i) break;
39
+ }
40
+ } catch (err) {
41
+ _d = true;
42
+ _e = err;
43
+ } finally {
44
+ try {
45
+ if (!_n && _i["return"] != null) _i["return"]();
46
+ } finally {
47
+ if (_d) throw _e;
48
+ }
49
+ }
50
+
51
+ return _arr;
52
+ }
53
+
54
+ function _arrayLikeToArray(arr, len) {
55
+ if (len == null || len > arr.length) len = arr.length;
56
+
57
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
58
+ arr2[i] = arr[i];
59
+ }
60
+
61
+ return arr2;
62
+ }
63
+
64
+ function _unsupportedIterableToArray(o, minLen) {
65
+ if (!o) return;
66
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
67
+ var n = Object.prototype.toString.call(o).slice(8, -1);
68
+ if (n === "Object" && o.constructor) n = o.constructor.name;
69
+ if (n === "Map" || n === "Set") return Array.from(o);
70
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
71
+ }
72
+
73
+ function _nonIterableRest() {
74
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
75
+ }
76
+
77
+ function _slicedToArray(arr, i) {
78
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
79
+ }
80
+
33
81
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
34
82
  try {
35
83
  var info = gen[key](arg);
@@ -471,10 +519,651 @@ try {
471
519
  }
472
520
  }
473
521
 
522
+ var getRandomInt = function getRandomInt() {
523
+ var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Number.MAX_SAFE_INTEGER;
524
+ var b = arguments.length > 1 ? arguments[1] : undefined;
525
+
526
+ if (b) {
527
+ a = Math.ceil(a);
528
+ b = Math.floor(b);
529
+ } else {
530
+ b = a;
531
+ a = 0;
532
+ }
533
+
534
+ return Math.floor(Math.random() * (b - a) + a);
535
+ };
536
+ complement(isNil);
537
+ complement(isEmpty);
538
+ curry(function (x, y) {
539
+ return x !== y;
540
+ });
541
+ complement(equals);
542
+
543
+ var queryString = {};
544
+
545
+ var strictUriEncode = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
546
+
547
+ var token = '%[a-f0-9]{2}';
548
+ var singleMatcher = new RegExp(token, 'gi');
549
+ var multiMatcher = new RegExp('(' + token + ')+', 'gi');
550
+
551
+ function decodeComponents(components, split) {
552
+ try {
553
+ // Try to decode the entire string first
554
+ return decodeURIComponent(components.join(''));
555
+ } catch (err) {
556
+ // Do nothing
557
+ }
558
+
559
+ if (components.length === 1) {
560
+ return components;
561
+ }
562
+
563
+ split = split || 1;
564
+
565
+ // Split the array in 2 parts
566
+ var left = components.slice(0, split);
567
+ var right = components.slice(split);
568
+
569
+ return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
570
+ }
571
+
572
+ function decode(input) {
573
+ try {
574
+ return decodeURIComponent(input);
575
+ } catch (err) {
576
+ var tokens = input.match(singleMatcher);
577
+
578
+ for (var i = 1; i < tokens.length; i++) {
579
+ input = decodeComponents(tokens, i).join('');
580
+
581
+ tokens = input.match(singleMatcher);
582
+ }
583
+
584
+ return input;
585
+ }
586
+ }
587
+
588
+ function customDecodeURIComponent(input) {
589
+ // Keep track of all the replacements and prefill the map with the `BOM`
590
+ var replaceMap = {
591
+ '%FE%FF': '\uFFFD\uFFFD',
592
+ '%FF%FE': '\uFFFD\uFFFD'
593
+ };
594
+
595
+ var match = multiMatcher.exec(input);
596
+ while (match) {
597
+ try {
598
+ // Decode as big chunks as possible
599
+ replaceMap[match[0]] = decodeURIComponent(match[0]);
600
+ } catch (err) {
601
+ var result = decode(match[0]);
602
+
603
+ if (result !== match[0]) {
604
+ replaceMap[match[0]] = result;
605
+ }
606
+ }
607
+
608
+ match = multiMatcher.exec(input);
609
+ }
610
+
611
+ // Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
612
+ replaceMap['%C2'] = '\uFFFD';
613
+
614
+ var entries = Object.keys(replaceMap);
615
+
616
+ for (var i = 0; i < entries.length; i++) {
617
+ // Replace all decoded components
618
+ var key = entries[i];
619
+ input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
620
+ }
621
+
622
+ return input;
623
+ }
624
+
625
+ var decodeUriComponent = function (encodedURI) {
626
+ if (typeof encodedURI !== 'string') {
627
+ throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
628
+ }
629
+
630
+ try {
631
+ encodedURI = encodedURI.replace(/\+/g, ' ');
632
+
633
+ // Try the built in decoder first
634
+ return decodeURIComponent(encodedURI);
635
+ } catch (err) {
636
+ // Fallback to a more advanced decoder
637
+ return customDecodeURIComponent(encodedURI);
638
+ }
639
+ };
640
+
641
+ var splitOnFirst = (string, separator) => {
642
+ if (!(typeof string === 'string' && typeof separator === 'string')) {
643
+ throw new TypeError('Expected the arguments to be of type `string`');
644
+ }
645
+
646
+ if (separator === '') {
647
+ return [string];
648
+ }
649
+
650
+ const separatorIndex = string.indexOf(separator);
651
+
652
+ if (separatorIndex === -1) {
653
+ return [string];
654
+ }
655
+
656
+ return [
657
+ string.slice(0, separatorIndex),
658
+ string.slice(separatorIndex + separator.length)
659
+ ];
660
+ };
661
+
662
+ var filterObj = function (obj, predicate) {
663
+ var ret = {};
664
+ var keys = Object.keys(obj);
665
+ var isArr = Array.isArray(predicate);
666
+
667
+ for (var i = 0; i < keys.length; i++) {
668
+ var key = keys[i];
669
+ var val = obj[key];
670
+
671
+ if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
672
+ ret[key] = val;
673
+ }
674
+ }
675
+
676
+ return ret;
677
+ };
678
+
679
+ (function (exports) {
680
+ const strictUriEncode$1 = strictUriEncode;
681
+ const decodeComponent = decodeUriComponent;
682
+ const splitOnFirst$1 = splitOnFirst;
683
+ const filterObject = filterObj;
684
+
685
+ const isNullOrUndefined = value => value === null || value === undefined;
686
+
687
+ const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
688
+
689
+ function encoderForArrayFormat(options) {
690
+ switch (options.arrayFormat) {
691
+ case 'index':
692
+ return key => (result, value) => {
693
+ const index = result.length;
694
+
695
+ if (
696
+ value === undefined ||
697
+ (options.skipNull && value === null) ||
698
+ (options.skipEmptyString && value === '')
699
+ ) {
700
+ return result;
701
+ }
702
+
703
+ if (value === null) {
704
+ return [...result, [encode(key, options), '[', index, ']'].join('')];
705
+ }
706
+
707
+ return [
708
+ ...result,
709
+ [encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
710
+ ];
711
+ };
712
+
713
+ case 'bracket':
714
+ return key => (result, value) => {
715
+ if (
716
+ value === undefined ||
717
+ (options.skipNull && value === null) ||
718
+ (options.skipEmptyString && value === '')
719
+ ) {
720
+ return result;
721
+ }
722
+
723
+ if (value === null) {
724
+ return [...result, [encode(key, options), '[]'].join('')];
725
+ }
726
+
727
+ return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
728
+ };
729
+
730
+ case 'colon-list-separator':
731
+ return key => (result, value) => {
732
+ if (
733
+ value === undefined ||
734
+ (options.skipNull && value === null) ||
735
+ (options.skipEmptyString && value === '')
736
+ ) {
737
+ return result;
738
+ }
739
+
740
+ if (value === null) {
741
+ return [...result, [encode(key, options), ':list='].join('')];
742
+ }
743
+
744
+ return [...result, [encode(key, options), ':list=', encode(value, options)].join('')];
745
+ };
746
+
747
+ case 'comma':
748
+ case 'separator':
749
+ case 'bracket-separator': {
750
+ const keyValueSep = options.arrayFormat === 'bracket-separator' ?
751
+ '[]=' :
752
+ '=';
753
+
754
+ return key => (result, value) => {
755
+ if (
756
+ value === undefined ||
757
+ (options.skipNull && value === null) ||
758
+ (options.skipEmptyString && value === '')
759
+ ) {
760
+ return result;
761
+ }
762
+
763
+ // Translate null to an empty string so that it doesn't serialize as 'null'
764
+ value = value === null ? '' : value;
765
+
766
+ if (result.length === 0) {
767
+ return [[encode(key, options), keyValueSep, encode(value, options)].join('')];
768
+ }
769
+
770
+ return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
771
+ };
772
+ }
773
+
774
+ default:
775
+ return key => (result, value) => {
776
+ if (
777
+ value === undefined ||
778
+ (options.skipNull && value === null) ||
779
+ (options.skipEmptyString && value === '')
780
+ ) {
781
+ return result;
782
+ }
783
+
784
+ if (value === null) {
785
+ return [...result, encode(key, options)];
786
+ }
787
+
788
+ return [...result, [encode(key, options), '=', encode(value, options)].join('')];
789
+ };
790
+ }
791
+ }
792
+
793
+ function parserForArrayFormat(options) {
794
+ let result;
795
+
796
+ switch (options.arrayFormat) {
797
+ case 'index':
798
+ return (key, value, accumulator) => {
799
+ result = /\[(\d*)\]$/.exec(key);
800
+
801
+ key = key.replace(/\[\d*\]$/, '');
802
+
803
+ if (!result) {
804
+ accumulator[key] = value;
805
+ return;
806
+ }
807
+
808
+ if (accumulator[key] === undefined) {
809
+ accumulator[key] = {};
810
+ }
811
+
812
+ accumulator[key][result[1]] = value;
813
+ };
814
+
815
+ case 'bracket':
816
+ return (key, value, accumulator) => {
817
+ result = /(\[\])$/.exec(key);
818
+ key = key.replace(/\[\]$/, '');
819
+
820
+ if (!result) {
821
+ accumulator[key] = value;
822
+ return;
823
+ }
824
+
825
+ if (accumulator[key] === undefined) {
826
+ accumulator[key] = [value];
827
+ return;
828
+ }
829
+
830
+ accumulator[key] = [].concat(accumulator[key], value);
831
+ };
832
+
833
+ case 'colon-list-separator':
834
+ return (key, value, accumulator) => {
835
+ result = /(:list)$/.exec(key);
836
+ key = key.replace(/:list$/, '');
837
+
838
+ if (!result) {
839
+ accumulator[key] = value;
840
+ return;
841
+ }
842
+
843
+ if (accumulator[key] === undefined) {
844
+ accumulator[key] = [value];
845
+ return;
846
+ }
847
+
848
+ accumulator[key] = [].concat(accumulator[key], value);
849
+ };
850
+
851
+ case 'comma':
852
+ case 'separator':
853
+ return (key, value, accumulator) => {
854
+ const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
855
+ const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
856
+ value = isEncodedArray ? decode(value, options) : value;
857
+ const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
858
+ accumulator[key] = newValue;
859
+ };
860
+
861
+ case 'bracket-separator':
862
+ return (key, value, accumulator) => {
863
+ const isArray = /(\[\])$/.test(key);
864
+ key = key.replace(/\[\]$/, '');
865
+
866
+ if (!isArray) {
867
+ accumulator[key] = value ? decode(value, options) : value;
868
+ return;
869
+ }
870
+
871
+ const arrayValue = value === null ?
872
+ [] :
873
+ value.split(options.arrayFormatSeparator).map(item => decode(item, options));
874
+
875
+ if (accumulator[key] === undefined) {
876
+ accumulator[key] = arrayValue;
877
+ return;
878
+ }
879
+
880
+ accumulator[key] = [].concat(accumulator[key], arrayValue);
881
+ };
882
+
883
+ default:
884
+ return (key, value, accumulator) => {
885
+ if (accumulator[key] === undefined) {
886
+ accumulator[key] = value;
887
+ return;
888
+ }
889
+
890
+ accumulator[key] = [].concat(accumulator[key], value);
891
+ };
892
+ }
893
+ }
894
+
895
+ function validateArrayFormatSeparator(value) {
896
+ if (typeof value !== 'string' || value.length !== 1) {
897
+ throw new TypeError('arrayFormatSeparator must be single character string');
898
+ }
899
+ }
900
+
901
+ function encode(value, options) {
902
+ if (options.encode) {
903
+ return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
904
+ }
905
+
906
+ return value;
907
+ }
908
+
909
+ function decode(value, options) {
910
+ if (options.decode) {
911
+ return decodeComponent(value);
912
+ }
913
+
914
+ return value;
915
+ }
916
+
917
+ function keysSorter(input) {
918
+ if (Array.isArray(input)) {
919
+ return input.sort();
920
+ }
921
+
922
+ if (typeof input === 'object') {
923
+ return keysSorter(Object.keys(input))
924
+ .sort((a, b) => Number(a) - Number(b))
925
+ .map(key => input[key]);
926
+ }
927
+
928
+ return input;
929
+ }
930
+
931
+ function removeHash(input) {
932
+ const hashStart = input.indexOf('#');
933
+ if (hashStart !== -1) {
934
+ input = input.slice(0, hashStart);
935
+ }
936
+
937
+ return input;
938
+ }
939
+
940
+ function getHash(url) {
941
+ let hash = '';
942
+ const hashStart = url.indexOf('#');
943
+ if (hashStart !== -1) {
944
+ hash = url.slice(hashStart);
945
+ }
946
+
947
+ return hash;
948
+ }
949
+
950
+ function extract(input) {
951
+ input = removeHash(input);
952
+ const queryStart = input.indexOf('?');
953
+ if (queryStart === -1) {
954
+ return '';
955
+ }
956
+
957
+ return input.slice(queryStart + 1);
958
+ }
959
+
960
+ function parseValue(value, options) {
961
+ if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
962
+ value = Number(value);
963
+ } else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
964
+ value = value.toLowerCase() === 'true';
965
+ }
966
+
967
+ return value;
968
+ }
969
+
970
+ function parse(query, options) {
971
+ options = Object.assign({
972
+ decode: true,
973
+ sort: true,
974
+ arrayFormat: 'none',
975
+ arrayFormatSeparator: ',',
976
+ parseNumbers: false,
977
+ parseBooleans: false
978
+ }, options);
979
+
980
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
981
+
982
+ const formatter = parserForArrayFormat(options);
983
+
984
+ // Create an object with no prototype
985
+ const ret = Object.create(null);
986
+
987
+ if (typeof query !== 'string') {
988
+ return ret;
989
+ }
990
+
991
+ query = query.trim().replace(/^[?#&]/, '');
992
+
993
+ if (!query) {
994
+ return ret;
995
+ }
996
+
997
+ for (const param of query.split('&')) {
998
+ if (param === '') {
999
+ continue;
1000
+ }
1001
+
1002
+ let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, ' ') : param, '=');
1003
+
1004
+ // Missing `=` should be `null`:
1005
+ // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
1006
+ value = value === undefined ? null : ['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options);
1007
+ formatter(decode(key, options), value, ret);
1008
+ }
1009
+
1010
+ for (const key of Object.keys(ret)) {
1011
+ const value = ret[key];
1012
+ if (typeof value === 'object' && value !== null) {
1013
+ for (const k of Object.keys(value)) {
1014
+ value[k] = parseValue(value[k], options);
1015
+ }
1016
+ } else {
1017
+ ret[key] = parseValue(value, options);
1018
+ }
1019
+ }
1020
+
1021
+ if (options.sort === false) {
1022
+ return ret;
1023
+ }
1024
+
1025
+ return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
1026
+ const value = ret[key];
1027
+ if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
1028
+ // Sort object keys, not values
1029
+ result[key] = keysSorter(value);
1030
+ } else {
1031
+ result[key] = value;
1032
+ }
1033
+
1034
+ return result;
1035
+ }, Object.create(null));
1036
+ }
1037
+
1038
+ exports.extract = extract;
1039
+ exports.parse = parse;
1040
+
1041
+ exports.stringify = (object, options) => {
1042
+ if (!object) {
1043
+ return '';
1044
+ }
1045
+
1046
+ options = Object.assign({
1047
+ encode: true,
1048
+ strict: true,
1049
+ arrayFormat: 'none',
1050
+ arrayFormatSeparator: ','
1051
+ }, options);
1052
+
1053
+ validateArrayFormatSeparator(options.arrayFormatSeparator);
1054
+
1055
+ const shouldFilter = key => (
1056
+ (options.skipNull && isNullOrUndefined(object[key])) ||
1057
+ (options.skipEmptyString && object[key] === '')
1058
+ );
1059
+
1060
+ const formatter = encoderForArrayFormat(options);
1061
+
1062
+ const objectCopy = {};
1063
+
1064
+ for (const key of Object.keys(object)) {
1065
+ if (!shouldFilter(key)) {
1066
+ objectCopy[key] = object[key];
1067
+ }
1068
+ }
1069
+
1070
+ const keys = Object.keys(objectCopy);
1071
+
1072
+ if (options.sort !== false) {
1073
+ keys.sort(options.sort);
1074
+ }
1075
+
1076
+ return keys.map(key => {
1077
+ const value = object[key];
1078
+
1079
+ if (value === undefined) {
1080
+ return '';
1081
+ }
1082
+
1083
+ if (value === null) {
1084
+ return encode(key, options);
1085
+ }
1086
+
1087
+ if (Array.isArray(value)) {
1088
+ if (value.length === 0 && options.arrayFormat === 'bracket-separator') {
1089
+ return encode(key, options) + '[]';
1090
+ }
1091
+
1092
+ return value
1093
+ .reduce(formatter(key), [])
1094
+ .join('&');
1095
+ }
1096
+
1097
+ return encode(key, options) + '=' + encode(value, options);
1098
+ }).filter(x => x.length > 0).join('&');
1099
+ };
1100
+
1101
+ exports.parseUrl = (url, options) => {
1102
+ options = Object.assign({
1103
+ decode: true
1104
+ }, options);
1105
+
1106
+ const [url_, hash] = splitOnFirst$1(url, '#');
1107
+
1108
+ return Object.assign(
1109
+ {
1110
+ url: url_.split('?')[0] || '',
1111
+ query: parse(extract(url), options)
1112
+ },
1113
+ options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}
1114
+ );
1115
+ };
1116
+
1117
+ exports.stringifyUrl = (object, options) => {
1118
+ options = Object.assign({
1119
+ encode: true,
1120
+ strict: true,
1121
+ [encodeFragmentIdentifier]: true
1122
+ }, options);
1123
+
1124
+ const url = removeHash(object.url).split('?')[0] || '';
1125
+ const queryFromUrl = exports.extract(object.url);
1126
+ const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
1127
+
1128
+ const query = Object.assign(parsedQueryFromUrl, object.query);
1129
+ let queryString = exports.stringify(query, options);
1130
+ if (queryString) {
1131
+ queryString = `?${queryString}`;
1132
+ }
1133
+
1134
+ let hash = getHash(object.url);
1135
+ if (object.fragmentIdentifier) {
1136
+ hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
1137
+ }
1138
+
1139
+ return `${url}${queryString}${hash}`;
1140
+ };
1141
+
1142
+ exports.pick = (input, filter, options) => {
1143
+ options = Object.assign({
1144
+ parseFragmentIdentifier: true,
1145
+ [encodeFragmentIdentifier]: false
1146
+ }, options);
1147
+
1148
+ const {url, query, fragmentIdentifier} = exports.parseUrl(input, options);
1149
+ return exports.stringifyUrl({
1150
+ url,
1151
+ query: filterObject(query, filter),
1152
+ fragmentIdentifier
1153
+ }, options);
1154
+ };
1155
+
1156
+ exports.exclude = (input, filter, options) => {
1157
+ const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
1158
+
1159
+ return exports.pick(input, exclusionFilter, options);
1160
+ };
1161
+ } (queryString));
1162
+
474
1163
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
475
1164
 
476
1165
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
477
- var withEventTargetValue = ramda.curry(function (func, event) {
1166
+ var withEventTargetValue = curry(function (func, event) {
478
1167
  return func(event.target.value);
479
1168
  });
480
1169
  var getSubdomain = function getSubdomain() {
@@ -484,12 +1173,12 @@ var getSubdomain = function getSubdomain() {
484
1173
  };
485
1174
  var simulateApiCall = function simulateApiCall(result, error) {
486
1175
  var errorProbability = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.1;
487
- var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : general.getRandomInt(350, 1000);
1176
+ var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : getRandomInt(350, 1000);
488
1177
  return new Promise(function (resolve, reject) {
489
1178
  return setTimeout(function () {
490
1179
  var defaultErrorObj = {
491
1180
  success: false,
492
- notice: i18next__default["default"].t("neetoCommons.notice.errorOccurred")
1181
+ notice: i18next.t("neetoCommons.notice.errorOccurred")
493
1182
  };
494
1183
  Math.random() < errorProbability ? reject(_objectSpread(_objectSpread({}, defaultErrorObj), error)) : resolve(result);
495
1184
  }, delay);
@@ -511,7 +1200,7 @@ var copyToClipboard = /*#__PURE__*/function () {
511
1200
  while (1) {
512
1201
  switch (_context.prev = _context.next) {
513
1202
  case 0:
514
- _ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref2$showToastr = _ref2.showToastr, showToastr = _ref2$showToastr === void 0 ? true : _ref2$showToastr, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? i18next__default["default"].t("neetoCommons.toastr.success.copiedToClipboard") : _ref2$message;
1203
+ _ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref2$showToastr = _ref2.showToastr, showToastr = _ref2$showToastr === void 0 ? true : _ref2$showToastr, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? i18next.t("neetoCommons.toastr.success.copiedToClipboard") : _ref2$message;
515
1204
 
516
1205
  /*
517
1206
  This is a workaround to prevent the jest tests from failing. Once the issue in neetoUI
@@ -566,40 +1255,52 @@ var copyToClipboard = /*#__PURE__*/function () {
566
1255
  return _ref.apply(this, arguments);
567
1256
  };
568
1257
  }();
1258
+ var buildUrl = function buildUrl(route, params) {
1259
+ var placeHolders = [];
1260
+ toPairs(params).forEach(function (_ref3) {
1261
+ var _ref4 = _slicedToArray(_ref3, 2),
1262
+ key = _ref4[0],
1263
+ value = _ref4[1];
1264
+
1265
+ if (route.includes(":".concat(key))) {
1266
+ placeHolders.push(key);
1267
+ route = route.replace(":".concat(key), encodeURIComponent(value));
1268
+ }
1269
+ });
1270
+ var queryParams = omit(placeHolders, params);
1271
+ return isEmpty(queryParams) ? route : "".concat(route, "?").concat(queryString.stringify(queryParams));
1272
+ };
569
1273
 
570
- dayjs__default["default"].extend(relativeTime__default["default"]);
571
- dayjs__default["default"].extend(updateLocale__default["default"]);
1274
+ dayjs.extend(relativeTime);
1275
+ dayjs.extend(updateLocale);
572
1276
  var timeFormat = {
573
1277
  fromNow: function fromNow(time) {
574
- return dayjs__default["default"](time).fromNow();
1278
+ return dayjs(time).fromNow();
575
1279
  },
576
1280
  time: function time(_time) {
577
- return dayjs__default["default"](_time).format("h:mm A");
1281
+ return dayjs(_time).format("h:mm A");
578
1282
  },
579
1283
  date: function date(time) {
580
- return dayjs__default["default"](time).format("MMM D, YYYY");
1284
+ return dayjs(time).format("MMM D, YYYY");
581
1285
  },
582
1286
  dateWeek: function dateWeek(time) {
583
- return dayjs__default["default"](time).format("MMM D, YYYY ddd");
1287
+ return dayjs(time).format("MMM D, YYYY ddd");
1288
+ },
1289
+ dateWeekWithoutYear: function dateWeekWithoutYear(time) {
1290
+ return dayjs(time).format("MMM D, ddd");
584
1291
  },
585
1292
  dateTime: function dateTime(time) {
586
- return dayjs__default["default"](time).format("MMM D, YYYY h:mm A");
1293
+ return dayjs(time).format("MMM D, YYYY h:mm A");
587
1294
  },
588
1295
  dateWeekTime: function dateWeekTime(time) {
589
- return dayjs__default["default"](time).format("MMM D, YYYY ddd h:mm A");
1296
+ return dayjs(time).format("MMM D, YYYY ddd h:mm A");
590
1297
  },
591
1298
  extended: function extended(time) {
592
- var dateTime = dayjs__default["default"](time).format("dddd MMMM D, YYYY h:mm A");
593
- var fromNow = dayjs__default["default"](time).fromNow();
1299
+ var dateTime = dayjs(time).format("dddd MMMM D, YYYY h:mm A");
1300
+ var fromNow = dayjs(time).fromNow();
594
1301
  return "".concat(dateTime, " (").concat(fromNow, ")");
595
1302
  }
596
1303
  };
597
1304
  var dateFormat = timeFormat;
598
1305
 
599
- exports.copyToClipboard = copyToClipboard;
600
- exports.dateFormat = dateFormat;
601
- exports.getSubdomain = getSubdomain;
602
- exports.resetAuthTokens = resetAuthTokens;
603
- exports.simulateApiCall = simulateApiCall;
604
- exports.timeFormat = timeFormat;
605
- exports.withEventTargetValue = withEventTargetValue;
1306
+ export { buildUrl, copyToClipboard, dateFormat, getSubdomain, resetAuthTokens, simulateApiCall, timeFormat, withEventTargetValue };