akeyless-client-commons 1.1.40 → 1.1.42

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.
@@ -1157,37 +1157,69 @@ function cn() {
1157
1157
  var import_firestore2 = require("firebase/firestore");
1158
1158
  var import_moment_timezone = __toESM(require("moment-timezone"));
1159
1159
  function timestamp_to_string(firebaseTimestamp, options) {
1160
- var _options_defaultReturnedValue, _options_format, _options_fromFormat;
1160
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
1161
1161
  var _ref = {
1162
1162
  defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
1163
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
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
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz;
1167
- if (!firebaseTimestamp) {
1168
- return defaultReturnedValue;
1169
- }
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;
1170
1168
  var date;
1171
- if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
1172
- date = firebaseTimestamp.toDate();
1173
- } else if (_instanceof(firebaseTimestamp, Date)) {
1174
- date = firebaseTimestamp;
1175
- } else if (typeof firebaseTimestamp === "string") {
1176
- date = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat).toDate();
1177
- if (isNaN(date.getTime())) {
1178
- return defaultReturnedValue;
1179
- }
1180
- } else if (firebaseTimestamp._seconds) {
1181
- var _firebaseTimestamp__nanoseconds;
1182
- date = new Date(firebaseTimestamp._seconds * 1e3 + ((_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0) / 1e6);
1183
- } else {
1184
- console.error("Invalid timestamp format: ", firebaseTimestamp);
1185
- return defaultReturnedValue;
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
+ }
1186
1216
  }
1187
- if (tz) {
1188
- return (0, import_moment_timezone.default)(date).tz(tz).format(format);
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);
1189
1222
  }
1190
- return import_moment_timezone.default.utc(date).format(format);
1191
1223
  }
1192
1224
  // src/helpers/api.ts
1193
1225
  var import_axios2 = __toESM(require("axios"));
@@ -935,37 +935,69 @@ function cn() {
935
935
  import { Timestamp as Timestamp2 } from "firebase/firestore";
936
936
  import moment2 from "moment-timezone";
937
937
  function timestamp_to_string(firebaseTimestamp, options) {
938
- var _options_defaultReturnedValue, _options_format, _options_fromFormat;
938
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
939
939
  var _ref = {
940
940
  defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
941
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
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
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz;
945
- if (!firebaseTimestamp) {
946
- return defaultReturnedValue;
947
- }
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;
948
946
  var date;
949
- if (_instanceof(firebaseTimestamp, Timestamp2)) {
950
- date = firebaseTimestamp.toDate();
951
- } else if (_instanceof(firebaseTimestamp, Date)) {
952
- date = firebaseTimestamp;
953
- } else if (typeof firebaseTimestamp === "string") {
954
- date = moment2.utc(firebaseTimestamp, fromFormat).toDate();
955
- if (isNaN(date.getTime())) {
956
- return defaultReturnedValue;
957
- }
958
- } else if (firebaseTimestamp._seconds) {
959
- var _firebaseTimestamp__nanoseconds;
960
- date = new Date(firebaseTimestamp._seconds * 1e3 + ((_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0) / 1e6);
961
- } else {
962
- console.error("Invalid timestamp format: ", firebaseTimestamp);
963
- return defaultReturnedValue;
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
+ }
964
994
  }
965
- if (tz) {
966
- return moment2(date).tz(tz).format(format);
995
+ switch(Boolean(tz)){
996
+ case true:
997
+ return moment2(date).tz(tz).format(format);
998
+ default:
999
+ return moment2.utc(date).format(format);
967
1000
  }
968
- return moment2.utc(date).format(format);
969
1001
  }
970
1002
  // src/helpers/api.ts
971
1003
  import axios2 from "axios";
@@ -229,18 +229,18 @@ declare const is_iccid: (number: string) => boolean;
229
229
 
230
230
  declare function cn(...inputs: ClassValue[]): string;
231
231
 
232
- interface TimeOptions {
232
+ interface TimeToStringOptions {
233
233
  format?: string;
234
234
  fromFormat?: string;
235
235
  tz?: string;
236
236
  defaultReturnedValue?: string;
237
+ debug?: boolean;
237
238
  }
238
- declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeOptions): string;
239
- declare function timestamp_to_millis(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: {
240
- fromFormat?: string;
241
- tz?: string;
239
+ declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeToStringOptions): string;
240
+ interface TimeToMillisOptions extends Omit<TimeToStringOptions, "defaultReturnedValue" | "format"> {
242
241
  defaultReturnedValue?: number;
243
- }): number;
242
+ }
243
+ declare function timestamp_to_millis(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeToMillisOptions): number;
244
244
  declare function sort_by_timestamp(a: Timestamp, b: Timestamp, reverse?: boolean): number;
245
245
 
246
246
  declare const baseDomain: string;
@@ -229,18 +229,18 @@ declare const is_iccid: (number: string) => boolean;
229
229
 
230
230
  declare function cn(...inputs: ClassValue[]): string;
231
231
 
232
- interface TimeOptions {
232
+ interface TimeToStringOptions {
233
233
  format?: string;
234
234
  fromFormat?: string;
235
235
  tz?: string;
236
236
  defaultReturnedValue?: string;
237
+ debug?: boolean;
237
238
  }
238
- declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeOptions): string;
239
- declare function timestamp_to_millis(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: {
240
- fromFormat?: string;
241
- tz?: string;
239
+ declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeToStringOptions): string;
240
+ interface TimeToMillisOptions extends Omit<TimeToStringOptions, "defaultReturnedValue" | "format"> {
242
241
  defaultReturnedValue?: number;
243
- }): number;
242
+ }
243
+ declare function timestamp_to_millis(firebaseTimestamp: Timestamp | Date | string | firebase_timestamp, options?: TimeToMillisOptions): number;
244
244
  declare function sort_by_timestamp(a: Timestamp, b: Timestamp, reverse?: boolean): number;
245
245
 
246
246
  declare const baseDomain: string;
@@ -2335,63 +2335,123 @@ function cn() {
2335
2335
  var import_firestore2 = require("firebase/firestore");
2336
2336
  var import_moment_timezone = __toESM(require("moment-timezone"));
2337
2337
  function timestamp_to_string(firebaseTimestamp, options) {
2338
- var _options_defaultReturnedValue, _options_format, _options_fromFormat;
2338
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
2339
2339
  var _ref = {
2340
2340
  defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
2341
2341
  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",
2342
2342
  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",
2343
- tz: options === null || options === void 0 ? void 0 : options.tz
2344
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz;
2345
- if (!firebaseTimestamp) {
2346
- return defaultReturnedValue;
2347
- }
2343
+ tz: options === null || options === void 0 ? void 0 : options.tz,
2344
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2345
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2348
2346
  var date;
2349
- if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
2350
- date = firebaseTimestamp.toDate();
2351
- } else if (_instanceof(firebaseTimestamp, Date)) {
2352
- date = firebaseTimestamp;
2353
- } else if (typeof firebaseTimestamp === "string") {
2354
- date = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat).toDate();
2355
- if (isNaN(date.getTime())) {
2356
- return defaultReturnedValue;
2357
- }
2358
- } else if (firebaseTimestamp._seconds) {
2359
- var _firebaseTimestamp__nanoseconds;
2360
- date = new Date(firebaseTimestamp._seconds * 1e3 + ((_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0) / 1e6);
2361
- } else {
2362
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2363
- return defaultReturnedValue;
2347
+ switch(true){
2348
+ case !firebaseTimestamp:
2349
+ {
2350
+ return defaultReturnedValue;
2351
+ }
2352
+ case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2353
+ {
2354
+ date = firebaseTimestamp.toDate();
2355
+ break;
2356
+ }
2357
+ case _instanceof(firebaseTimestamp, Date):
2358
+ {
2359
+ date = firebaseTimestamp;
2360
+ break;
2361
+ }
2362
+ case typeof firebaseTimestamp === "string":
2363
+ {
2364
+ var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2365
+ switch(m.isValid()){
2366
+ case true:
2367
+ date = m.toDate();
2368
+ break;
2369
+ default:
2370
+ return defaultReturnedValue;
2371
+ }
2372
+ break;
2373
+ }
2374
+ case !!firebaseTimestamp._seconds:
2375
+ {
2376
+ var ft = firebaseTimestamp;
2377
+ var _ft__nanoseconds;
2378
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
2379
+ break;
2380
+ }
2381
+ case !!firebaseTimestamp.seconds:
2382
+ {
2383
+ var ft1 = firebaseTimestamp;
2384
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
2385
+ break;
2386
+ }
2387
+ default:
2388
+ {
2389
+ if (debug) {
2390
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
2391
+ }
2392
+ return defaultReturnedValue;
2393
+ }
2364
2394
  }
2365
- if (tz) {
2366
- return (0, import_moment_timezone.default)(date).tz(tz).format(format);
2395
+ switch(Boolean(tz)){
2396
+ case true:
2397
+ return (0, import_moment_timezone.default)(date).tz(tz).format(format);
2398
+ default:
2399
+ return import_moment_timezone.default.utc(date).format(format);
2367
2400
  }
2368
- return import_moment_timezone.default.utc(date).format(format);
2369
2401
  }
2370
2402
  function timestamp_to_millis(firebaseTimestamp, options) {
2371
- var _options_fromFormat;
2372
- var 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";
2373
- var _options_defaultReturnedValue;
2374
- var defaultReturnedValue = (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0;
2375
- var tz = options === null || options === void 0 ? void 0 : options.tz;
2376
- if (!firebaseTimestamp) {
2377
- return defaultReturnedValue;
2378
- }
2379
- if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
2380
- return firebaseTimestamp.toMillis();
2381
- } else if (_instanceof(firebaseTimestamp, Date)) {
2382
- var ms = firebaseTimestamp.getTime();
2383
- return isNaN(ms) ? defaultReturnedValue : ms;
2384
- } else if (typeof firebaseTimestamp === "string") {
2385
- var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2386
- return m.isValid() ? m.valueOf() : defaultReturnedValue;
2387
- } else if (firebaseTimestamp._seconds) {
2388
- var seconds = firebaseTimestamp._seconds;
2389
- var _firebaseTimestamp__nanoseconds;
2390
- var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2391
- return seconds * 1e3 + Math.floor(nanos / 1e6);
2392
- } else {
2393
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2394
- return defaultReturnedValue;
2403
+ var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
2404
+ var _ref = {
2405
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
2406
+ 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",
2407
+ tz: options === null || options === void 0 ? void 0 : options.tz,
2408
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2409
+ }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2410
+ switch(true){
2411
+ case !firebaseTimestamp:
2412
+ {
2413
+ return defaultReturnedValue;
2414
+ }
2415
+ case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2416
+ {
2417
+ return firebaseTimestamp.toMillis();
2418
+ }
2419
+ case _instanceof(firebaseTimestamp, Date):
2420
+ {
2421
+ var ms = firebaseTimestamp.getTime();
2422
+ return isNaN(ms) ? defaultReturnedValue : ms;
2423
+ }
2424
+ case typeof firebaseTimestamp === "string":
2425
+ {
2426
+ var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2427
+ switch(m.isValid()){
2428
+ case true:
2429
+ return m.valueOf();
2430
+ default:
2431
+ return defaultReturnedValue;
2432
+ }
2433
+ }
2434
+ case !!firebaseTimestamp._seconds:
2435
+ {
2436
+ var seconds = firebaseTimestamp._seconds;
2437
+ var _firebaseTimestamp__nanoseconds;
2438
+ var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2439
+ return seconds * 1e3 + Math.floor(nanos / 1e6);
2440
+ }
2441
+ case !!firebaseTimestamp.seconds:
2442
+ {
2443
+ var seconds1 = firebaseTimestamp.seconds;
2444
+ var _firebaseTimestamp_nanoseconds;
2445
+ var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
2446
+ return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
2447
+ }
2448
+ default:
2449
+ {
2450
+ if (debug) {
2451
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
2452
+ }
2453
+ return defaultReturnedValue;
2454
+ }
2395
2455
  }
2396
2456
  }
2397
2457
  function sort_by_timestamp(a, b) {
@@ -1956,63 +1956,123 @@ function cn() {
1956
1956
  import { Timestamp as Timestamp2 } from "firebase/firestore";
1957
1957
  import moment2 from "moment-timezone";
1958
1958
  function timestamp_to_string(firebaseTimestamp, options) {
1959
- var _options_defaultReturnedValue, _options_format, _options_fromFormat;
1959
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
1960
1960
  var _ref = {
1961
1961
  defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
1962
1962
  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",
1963
1963
  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",
1964
- tz: options === null || options === void 0 ? void 0 : options.tz
1965
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz;
1966
- if (!firebaseTimestamp) {
1967
- return defaultReturnedValue;
1968
- }
1964
+ tz: options === null || options === void 0 ? void 0 : options.tz,
1965
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
1966
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
1969
1967
  var date;
1970
- if (_instanceof(firebaseTimestamp, Timestamp2)) {
1971
- date = firebaseTimestamp.toDate();
1972
- } else if (_instanceof(firebaseTimestamp, Date)) {
1973
- date = firebaseTimestamp;
1974
- } else if (typeof firebaseTimestamp === "string") {
1975
- date = moment2.utc(firebaseTimestamp, fromFormat).toDate();
1976
- if (isNaN(date.getTime())) {
1977
- return defaultReturnedValue;
1978
- }
1979
- } else if (firebaseTimestamp._seconds) {
1980
- var _firebaseTimestamp__nanoseconds;
1981
- date = new Date(firebaseTimestamp._seconds * 1e3 + ((_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0) / 1e6);
1982
- } else {
1983
- console.error("Invalid timestamp format: ", firebaseTimestamp);
1984
- return defaultReturnedValue;
1968
+ switch(true){
1969
+ case !firebaseTimestamp:
1970
+ {
1971
+ return defaultReturnedValue;
1972
+ }
1973
+ case _instanceof(firebaseTimestamp, Timestamp2):
1974
+ {
1975
+ date = firebaseTimestamp.toDate();
1976
+ break;
1977
+ }
1978
+ case _instanceof(firebaseTimestamp, Date):
1979
+ {
1980
+ date = firebaseTimestamp;
1981
+ break;
1982
+ }
1983
+ case typeof firebaseTimestamp === "string":
1984
+ {
1985
+ var m = moment2.utc(firebaseTimestamp, fromFormat);
1986
+ switch(m.isValid()){
1987
+ case true:
1988
+ date = m.toDate();
1989
+ break;
1990
+ default:
1991
+ return defaultReturnedValue;
1992
+ }
1993
+ break;
1994
+ }
1995
+ case !!firebaseTimestamp._seconds:
1996
+ {
1997
+ var ft = firebaseTimestamp;
1998
+ var _ft__nanoseconds;
1999
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
2000
+ break;
2001
+ }
2002
+ case !!firebaseTimestamp.seconds:
2003
+ {
2004
+ var ft1 = firebaseTimestamp;
2005
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
2006
+ break;
2007
+ }
2008
+ default:
2009
+ {
2010
+ if (debug) {
2011
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
2012
+ }
2013
+ return defaultReturnedValue;
2014
+ }
1985
2015
  }
1986
- if (tz) {
1987
- return moment2(date).tz(tz).format(format);
2016
+ switch(Boolean(tz)){
2017
+ case true:
2018
+ return moment2(date).tz(tz).format(format);
2019
+ default:
2020
+ return moment2.utc(date).format(format);
1988
2021
  }
1989
- return moment2.utc(date).format(format);
1990
2022
  }
1991
2023
  function timestamp_to_millis(firebaseTimestamp, options) {
1992
- var _options_fromFormat;
1993
- var 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";
1994
- var _options_defaultReturnedValue;
1995
- var defaultReturnedValue = (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0;
1996
- var tz = options === null || options === void 0 ? void 0 : options.tz;
1997
- if (!firebaseTimestamp) {
1998
- return defaultReturnedValue;
1999
- }
2000
- if (_instanceof(firebaseTimestamp, Timestamp2)) {
2001
- return firebaseTimestamp.toMillis();
2002
- } else if (_instanceof(firebaseTimestamp, Date)) {
2003
- var ms = firebaseTimestamp.getTime();
2004
- return isNaN(ms) ? defaultReturnedValue : ms;
2005
- } else if (typeof firebaseTimestamp === "string") {
2006
- var m = tz ? moment2.tz(firebaseTimestamp, fromFormat, tz) : moment2.utc(firebaseTimestamp, fromFormat);
2007
- return m.isValid() ? m.valueOf() : defaultReturnedValue;
2008
- } else if (firebaseTimestamp._seconds) {
2009
- var seconds = firebaseTimestamp._seconds;
2010
- var _firebaseTimestamp__nanoseconds;
2011
- var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2012
- return seconds * 1e3 + Math.floor(nanos / 1e6);
2013
- } else {
2014
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2015
- return defaultReturnedValue;
2024
+ var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
2025
+ var _ref = {
2026
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
2027
+ 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",
2028
+ tz: options === null || options === void 0 ? void 0 : options.tz,
2029
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2030
+ }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2031
+ switch(true){
2032
+ case !firebaseTimestamp:
2033
+ {
2034
+ return defaultReturnedValue;
2035
+ }
2036
+ case _instanceof(firebaseTimestamp, Timestamp2):
2037
+ {
2038
+ return firebaseTimestamp.toMillis();
2039
+ }
2040
+ case _instanceof(firebaseTimestamp, Date):
2041
+ {
2042
+ var ms = firebaseTimestamp.getTime();
2043
+ return isNaN(ms) ? defaultReturnedValue : ms;
2044
+ }
2045
+ case typeof firebaseTimestamp === "string":
2046
+ {
2047
+ var m = tz ? moment2.tz(firebaseTimestamp, fromFormat, tz) : moment2.utc(firebaseTimestamp, fromFormat);
2048
+ switch(m.isValid()){
2049
+ case true:
2050
+ return m.valueOf();
2051
+ default:
2052
+ return defaultReturnedValue;
2053
+ }
2054
+ }
2055
+ case !!firebaseTimestamp._seconds:
2056
+ {
2057
+ var seconds = firebaseTimestamp._seconds;
2058
+ var _firebaseTimestamp__nanoseconds;
2059
+ var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2060
+ return seconds * 1e3 + Math.floor(nanos / 1e6);
2061
+ }
2062
+ case !!firebaseTimestamp.seconds:
2063
+ {
2064
+ var seconds1 = firebaseTimestamp.seconds;
2065
+ var _firebaseTimestamp_nanoseconds;
2066
+ var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
2067
+ return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
2068
+ }
2069
+ default:
2070
+ {
2071
+ if (debug) {
2072
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
2073
+ }
2074
+ return defaultReturnedValue;
2075
+ }
2016
2076
  }
2017
2077
  }
2018
2078
  function sort_by_timestamp(a, b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",