akeyless-client-commons 1.1.69 → 1.1.71

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.
@@ -583,7 +583,7 @@ var import_app = require("firebase/app");
583
583
  var import_storage = require("firebase/storage");
584
584
  var import_auth = require("firebase/auth");
585
585
  var import_app_check = require("firebase/app-check");
586
- var import_firestore = require("firebase/firestore");
586
+ var import_firestore2 = require("firebase/firestore");
587
587
  var import_react = require("react");
588
588
  // src/helpers/phoneNumber.ts
589
589
  var import_libphonenumber_js = require("libphonenumber-js");
@@ -632,6 +632,75 @@ var parsePermissions = function(object) {
632
632
  };
633
633
  // src/helpers/firebase.ts
634
634
  var import_storage2 = require("firebase/storage");
635
+ // src/helpers/time_helpers.ts
636
+ var import_firestore = require("firebase/firestore");
637
+ var import_moment_timezone = __toESM(require("moment-timezone"));
638
+ function timestamp_to_string(firebaseTimestamp, options) {
639
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
640
+ var _ref = {
641
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
642
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
643
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
644
+ tz: options === null || options === void 0 ? void 0 : options.tz,
645
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
646
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
647
+ var date;
648
+ switch(true){
649
+ case !firebaseTimestamp:
650
+ {
651
+ return defaultReturnedValue;
652
+ }
653
+ case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
654
+ {
655
+ date = firebaseTimestamp.toDate();
656
+ break;
657
+ }
658
+ case _instanceof(firebaseTimestamp, Date):
659
+ {
660
+ date = firebaseTimestamp;
661
+ break;
662
+ }
663
+ case typeof firebaseTimestamp === "string":
664
+ {
665
+ var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
666
+ switch(m.isValid()){
667
+ case true:
668
+ date = m.toDate();
669
+ break;
670
+ default:
671
+ return defaultReturnedValue;
672
+ }
673
+ break;
674
+ }
675
+ case !!firebaseTimestamp._seconds:
676
+ {
677
+ var ft = firebaseTimestamp;
678
+ var _ft__nanoseconds;
679
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
680
+ break;
681
+ }
682
+ case !!firebaseTimestamp.seconds:
683
+ {
684
+ var ft1 = firebaseTimestamp;
685
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
686
+ break;
687
+ }
688
+ default:
689
+ {
690
+ if (debug) {
691
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
692
+ }
693
+ return defaultReturnedValue;
694
+ }
695
+ }
696
+ switch(Boolean(tz)){
697
+ case true:
698
+ return (0, import_moment_timezone.default)(date).tz(tz).format(format);
699
+ default:
700
+ return import_moment_timezone.default.utc(date).format(format);
701
+ }
702
+ }
703
+ // src/helpers/firebase.ts
635
704
  var import_meta = {};
636
705
  var initApp = function() {
637
706
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
@@ -647,7 +716,7 @@ var initApp = function() {
647
716
  var app2 = (0, import_app.initializeApp)(firebaseConfig);
648
717
  var auth2 = (0, import_auth.getAuth)(app2);
649
718
  auth2.settings.appVerificationDisabledForTesting = false;
650
- var db2 = (0, import_firestore.getFirestore)(app2);
719
+ var db2 = (0, import_firestore2.getFirestore)(app2);
651
720
  var storage2 = (0, import_storage.getStorage)(app2);
652
721
  var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
653
722
  var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
@@ -697,33 +766,33 @@ var useLoginWithGoogle = function() {
697
766
  return signInWithGoogle;
698
767
  };
699
768
  var collections = {
700
- clients: (0, import_firestore.collection)(db, "nx-clients"),
701
- sites: (0, import_firestore.collection)(db, "nx-sites"),
702
- cars: (0, import_firestore.collection)(db, "units"),
703
- users: (0, import_firestore.collection)(db, "nx-users"),
704
- lastLocations: (0, import_firestore.collection)(db, "last_locations"),
705
- ermEvents: (0, import_firestore.collection)(db, "erm_events_general"),
706
- erm2Events: (0, import_firestore.collection)(db, "erm2_events_general"),
707
- ruptelaEvents: (0, import_firestore.collection)(db, "ruptela_events_general"),
708
- polygons: (0, import_firestore.collection)(db, "nx-polygons"),
709
- polygonEvents: (0, import_firestore.collection)(db, "polygon_events"),
710
- polygonCars: (0, import_firestore.collection)(db, "polygon_cars"),
711
- canbus: (0, import_firestore.collection)(db, "erm_canbus_parameters"),
712
- states: (0, import_firestore.collection)(db, "erm_states"),
713
- app_pro_commands_queue: (0, import_firestore.collection)(db, "app_pro_commands_queue"),
714
- trips: (0, import_firestore.collection)(db, "erm2_trip"),
715
- tripsDetails: (0, import_firestore.collection)(db, "erm2_trip_details"),
716
- audit: (0, import_firestore.collection)(db, "nx-audit"),
717
- nx_settings: (0, import_firestore.collection)(db, "nx-settings"),
718
- settings: (0, import_firestore.collection)(db, "settings"),
719
- translations: (0, import_firestore.collection)(db, "nx-translations"),
720
- nx_cars: (0, import_firestore.collection)(db, "nx-cars"),
721
- boards: (0, import_firestore.collection)(db, "boards"),
722
- protection_types: (0, import_firestore.collection)(db, "protectionTypes"),
723
- board_types: (0, import_firestore.collection)(db, "boardTypes"),
724
- charge_capacities: (0, import_firestore.collection)(db, "nx-charge-capacities")
769
+ clients: (0, import_firestore2.collection)(db, "nx-clients"),
770
+ sites: (0, import_firestore2.collection)(db, "nx-sites"),
771
+ cars: (0, import_firestore2.collection)(db, "units"),
772
+ users: (0, import_firestore2.collection)(db, "nx-users"),
773
+ lastLocations: (0, import_firestore2.collection)(db, "last_locations"),
774
+ ermEvents: (0, import_firestore2.collection)(db, "erm_events_general"),
775
+ erm2Events: (0, import_firestore2.collection)(db, "erm2_events_general"),
776
+ ruptelaEvents: (0, import_firestore2.collection)(db, "ruptela_events_general"),
777
+ polygons: (0, import_firestore2.collection)(db, "nx-polygons"),
778
+ polygonEvents: (0, import_firestore2.collection)(db, "polygon_events"),
779
+ polygonCars: (0, import_firestore2.collection)(db, "polygon_cars"),
780
+ canbus: (0, import_firestore2.collection)(db, "erm_canbus_parameters"),
781
+ states: (0, import_firestore2.collection)(db, "erm_states"),
782
+ app_pro_commands_queue: (0, import_firestore2.collection)(db, "app_pro_commands_queue"),
783
+ trips: (0, import_firestore2.collection)(db, "erm2_trip"),
784
+ tripsDetails: (0, import_firestore2.collection)(db, "erm2_trip_details"),
785
+ audit: (0, import_firestore2.collection)(db, "nx-audit"),
786
+ nx_settings: (0, import_firestore2.collection)(db, "nx-settings"),
787
+ settings: (0, import_firestore2.collection)(db, "settings"),
788
+ translations: (0, import_firestore2.collection)(db, "nx-translations"),
789
+ nx_cars: (0, import_firestore2.collection)(db, "nx-cars"),
790
+ boards: (0, import_firestore2.collection)(db, "boards"),
791
+ protection_types: (0, import_firestore2.collection)(db, "protectionTypes"),
792
+ board_types: (0, import_firestore2.collection)(db, "boardTypes"),
793
+ charge_capacities: (0, import_firestore2.collection)(db, "nx-charge-capacities")
725
794
  };
726
- var fire_base_TIME_TEMP = import_firestore.Timestamp.now;
795
+ var fire_base_TIME_TEMP = import_firestore2.Timestamp.now;
727
796
  var simpleExtractData = function(doc2) {
728
797
  var docData = doc2.data();
729
798
  return _object_spread_props(_object_spread({}, docData), {
@@ -742,10 +811,10 @@ var set_document = /*#__PURE__*/ function() {
742
811
  ,
743
812
  3
744
813
  ]);
745
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
814
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
746
815
  return [
747
816
  4,
748
- (0, import_firestore.setDoc)(doc_ref, data, {
817
+ (0, import_firestore2.setDoc)(doc_ref, data, {
749
818
  merge: true
750
819
  })
751
820
  ];
@@ -792,10 +861,10 @@ var query_document = /*#__PURE__*/ function() {
792
861
  ,
793
862
  4
794
863
  ]);
795
- q = (0, import_firestore.query)((0, import_firestore.collection)(db, collection_path), (0, import_firestore.where)(field_name, operator, value));
864
+ q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
796
865
  return [
797
866
  4,
798
- (0, import_firestore.getDocs)(q)
867
+ (0, import_firestore2.getDocs)(q)
799
868
  ];
800
869
  case 2:
801
870
  query_snapshot = _state.sent();
@@ -957,7 +1026,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
957
1026
  ,
958
1027
  3
959
1028
  ]);
960
- ref2 = (0, import_firestore.doc)(collections.audit);
1029
+ ref2 = (0, import_firestore2.doc)(collections.audit);
961
1030
  data = {
962
1031
  action: action,
963
1032
  entity: entity,
@@ -972,7 +1041,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
972
1041
  };
973
1042
  return [
974
1043
  4,
975
- (0, import_firestore.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
1044
+ (0, import_firestore2.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
976
1045
  datetime: fire_base_TIME_TEMP()
977
1046
  }))
978
1047
  ];
@@ -1153,74 +1222,6 @@ function cn() {
1153
1222
  }
1154
1223
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
1155
1224
  }
1156
- // src/helpers/time_helpers.ts
1157
- var import_firestore2 = require("firebase/firestore");
1158
- var import_moment_timezone = __toESM(require("moment-timezone"));
1159
- function timestamp_to_string(firebaseTimestamp, options) {
1160
- var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
1161
- var _ref = {
1162
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
1163
- format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
1164
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
1165
- tz: options === null || options === void 0 ? void 0 : options.tz,
1166
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
1167
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
1168
- var date;
1169
- switch(true){
1170
- case !firebaseTimestamp:
1171
- {
1172
- return defaultReturnedValue;
1173
- }
1174
- case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
1175
- {
1176
- date = firebaseTimestamp.toDate();
1177
- break;
1178
- }
1179
- case _instanceof(firebaseTimestamp, Date):
1180
- {
1181
- date = firebaseTimestamp;
1182
- break;
1183
- }
1184
- case typeof firebaseTimestamp === "string":
1185
- {
1186
- var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
1187
- switch(m.isValid()){
1188
- case true:
1189
- date = m.toDate();
1190
- break;
1191
- default:
1192
- return defaultReturnedValue;
1193
- }
1194
- break;
1195
- }
1196
- case !!firebaseTimestamp._seconds:
1197
- {
1198
- var ft = firebaseTimestamp;
1199
- var _ft__nanoseconds;
1200
- date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
1201
- break;
1202
- }
1203
- case !!firebaseTimestamp.seconds:
1204
- {
1205
- var ft1 = firebaseTimestamp;
1206
- date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
1207
- break;
1208
- }
1209
- default:
1210
- {
1211
- if (debug) {
1212
- console.error("Invalid timestamp format: ", firebaseTimestamp);
1213
- }
1214
- return defaultReturnedValue;
1215
- }
1216
- }
1217
- switch(Boolean(tz)){
1218
- case true:
1219
- return (0, import_moment_timezone.default)(date).tz(tz).format(format);
1220
- default:
1221
- return import_moment_timezone.default.utc(date).format(format);
1222
- }
1223
- }
1224
1225
  // src/helpers/api.ts
1225
1226
  var import_axios2 = __toESM(require("axios"));
1226
1227
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
@@ -358,12 +358,12 @@ function _ts_generator(thisArg, body) {
358
358
  };
359
359
  }
360
360
  }
361
- import moment from "moment";
361
+ import moment2 from "moment";
362
362
  import { initializeApp } from "firebase/app";
363
363
  import { getStorage } from "firebase/storage";
364
364
  import { getAuth, GoogleAuthProvider, signInWithPopup } from "firebase/auth";
365
365
  import { initializeAppCheck, ReCaptchaEnterpriseProvider } from "firebase/app-check";
366
- import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
366
+ import { addDoc, collection, deleteDoc, doc, getDoc, getDocs, query, setDoc, Timestamp as Timestamp2, where, getFirestore, onSnapshot, orderBy } from "firebase/firestore";
367
367
  import { useCallback } from "react";
368
368
  // src/helpers/phoneNumber.ts
369
369
  import { parsePhoneNumberFromString } from "libphonenumber-js";
@@ -412,6 +412,75 @@ var parsePermissions = function(object) {
412
412
  };
413
413
  // src/helpers/firebase.ts
414
414
  import { ref, getDownloadURL, uploadBytes } from "firebase/storage";
415
+ // src/helpers/time_helpers.ts
416
+ import { Timestamp } from "firebase/firestore";
417
+ import moment from "moment-timezone";
418
+ function timestamp_to_string(firebaseTimestamp, options) {
419
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
420
+ var _ref = {
421
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
422
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
423
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
424
+ tz: options === null || options === void 0 ? void 0 : options.tz,
425
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
426
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
427
+ var date;
428
+ switch(true){
429
+ case !firebaseTimestamp:
430
+ {
431
+ return defaultReturnedValue;
432
+ }
433
+ case _instanceof(firebaseTimestamp, Timestamp):
434
+ {
435
+ date = firebaseTimestamp.toDate();
436
+ break;
437
+ }
438
+ case _instanceof(firebaseTimestamp, Date):
439
+ {
440
+ date = firebaseTimestamp;
441
+ break;
442
+ }
443
+ case typeof firebaseTimestamp === "string":
444
+ {
445
+ var m = moment.utc(firebaseTimestamp, fromFormat);
446
+ switch(m.isValid()){
447
+ case true:
448
+ date = m.toDate();
449
+ break;
450
+ default:
451
+ return defaultReturnedValue;
452
+ }
453
+ break;
454
+ }
455
+ case !!firebaseTimestamp._seconds:
456
+ {
457
+ var ft = firebaseTimestamp;
458
+ var _ft__nanoseconds;
459
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
460
+ break;
461
+ }
462
+ case !!firebaseTimestamp.seconds:
463
+ {
464
+ var ft1 = firebaseTimestamp;
465
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
466
+ break;
467
+ }
468
+ default:
469
+ {
470
+ if (debug) {
471
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
472
+ }
473
+ return defaultReturnedValue;
474
+ }
475
+ }
476
+ switch(Boolean(tz)){
477
+ case true:
478
+ return moment(date).tz(tz).format(format);
479
+ default:
480
+ return moment.utc(date).format(format);
481
+ }
482
+ }
483
+ // src/helpers/firebase.ts
415
484
  var initApp = function() {
416
485
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
417
486
  var firebaseConfig = {
@@ -502,7 +571,7 @@ var collections = {
502
571
  board_types: collection(db, "boardTypes"),
503
572
  charge_capacities: collection(db, "nx-charge-capacities")
504
573
  };
505
- var fire_base_TIME_TEMP = Timestamp.now;
574
+ var fire_base_TIME_TEMP = Timestamp2.now;
506
575
  var simpleExtractData = function(doc2) {
507
576
  var docData = doc2.data();
508
577
  return _object_spread_props(_object_spread({}, docData), {
@@ -931,74 +1000,6 @@ function cn() {
931
1000
  }
932
1001
  return twMerge(clsx(inputs));
933
1002
  }
934
- // src/helpers/time_helpers.ts
935
- import { Timestamp as Timestamp2 } from "firebase/firestore";
936
- import moment2 from "moment-timezone";
937
- function timestamp_to_string(firebaseTimestamp, options) {
938
- var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
939
- var _ref = {
940
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
941
- format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
942
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
943
- tz: options === null || options === void 0 ? void 0 : options.tz,
944
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
945
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
946
- var date;
947
- switch(true){
948
- case !firebaseTimestamp:
949
- {
950
- return defaultReturnedValue;
951
- }
952
- case _instanceof(firebaseTimestamp, Timestamp2):
953
- {
954
- date = firebaseTimestamp.toDate();
955
- break;
956
- }
957
- case _instanceof(firebaseTimestamp, Date):
958
- {
959
- date = firebaseTimestamp;
960
- break;
961
- }
962
- case typeof firebaseTimestamp === "string":
963
- {
964
- var m = moment2.utc(firebaseTimestamp, fromFormat);
965
- switch(m.isValid()){
966
- case true:
967
- date = m.toDate();
968
- break;
969
- default:
970
- return defaultReturnedValue;
971
- }
972
- break;
973
- }
974
- case !!firebaseTimestamp._seconds:
975
- {
976
- var ft = firebaseTimestamp;
977
- var _ft__nanoseconds;
978
- date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
979
- break;
980
- }
981
- case !!firebaseTimestamp.seconds:
982
- {
983
- var ft1 = firebaseTimestamp;
984
- date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
985
- break;
986
- }
987
- default:
988
- {
989
- if (debug) {
990
- console.error("Invalid timestamp format: ", firebaseTimestamp);
991
- }
992
- return defaultReturnedValue;
993
- }
994
- }
995
- switch(Boolean(tz)){
996
- case true:
997
- return moment2(date).tz(tz).format(format);
998
- default:
999
- return moment2.utc(date).format(format);
1000
- }
1001
- }
1002
1003
  // src/helpers/api.ts
1003
1004
  import axios2 from "axios";
1004
1005
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";