akeyless-client-commons 1.0.146 → 1.0.148

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.
@@ -1097,6 +1097,10 @@ function cn() {
1097
1097
  var import_firestore2 = require("firebase/firestore");
1098
1098
  var import_moment_timezone = __toESM(require("moment-timezone"));
1099
1099
  function timestamp_to_string(firebaseTimestamp, options) {
1100
+ if (!firebaseTimestamp) {
1101
+ var _options_defaultReturnedValue;
1102
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
1103
+ }
1100
1104
  var date;
1101
1105
  if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
1102
1106
  date = firebaseTimestamp.toDate();
@@ -1105,10 +1109,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
1105
1109
  } else if (typeof firebaseTimestamp === "string") {
1106
1110
  date = import_moment_timezone.default.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
1107
1111
  if (isNaN(date.getTime())) {
1108
- throw new Error("Invalid date string format");
1112
+ var _options_defaultReturnedValue1;
1113
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
1109
1114
  }
1110
1115
  } else {
1111
- throw new Error("Invalid input: firebaseTimestamp must be a Timestamp, Date, or valid date string.");
1116
+ var _options_defaultReturnedValue2;
1117
+ return (_options_defaultReturnedValue2 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue2 !== void 0 ? _options_defaultReturnedValue2 : "-";
1112
1118
  }
1113
1119
  if (options === null || options === void 0 ? void 0 : options.tz) {
1114
1120
  var result = (0, import_moment_timezone.default)(date).tz(options === null || options === void 0 ? void 0 : options.tz).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
@@ -884,6 +884,10 @@ function cn() {
884
884
  import { Timestamp as Timestamp2 } from "firebase/firestore";
885
885
  import moment2 from "moment-timezone";
886
886
  function timestamp_to_string(firebaseTimestamp, options) {
887
+ if (!firebaseTimestamp) {
888
+ var _options_defaultReturnedValue;
889
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
890
+ }
887
891
  var date;
888
892
  if (_instanceof(firebaseTimestamp, Timestamp2)) {
889
893
  date = firebaseTimestamp.toDate();
@@ -892,10 +896,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
892
896
  } else if (typeof firebaseTimestamp === "string") {
893
897
  date = moment2.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
894
898
  if (isNaN(date.getTime())) {
895
- throw new Error("Invalid date string format");
899
+ var _options_defaultReturnedValue1;
900
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
896
901
  }
897
902
  } else {
898
- throw new Error("Invalid input: firebaseTimestamp must be a Timestamp, Date, or valid date string.");
903
+ var _options_defaultReturnedValue2;
904
+ return (_options_defaultReturnedValue2 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue2 !== void 0 ? _options_defaultReturnedValue2 : "-";
899
905
  }
900
906
  if (options === null || options === void 0 ? void 0 : options.tz) {
901
907
  var result = moment2(date).tz(options === null || options === void 0 ? void 0 : options.tz).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
@@ -224,6 +224,7 @@ interface TimeOptions {
224
224
  format?: string;
225
225
  fromFormat?: string;
226
226
  tz?: string;
227
+ defaultReturnedValue?: string;
227
228
  }
228
229
  declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string, options?: TimeOptions): string;
229
230
  declare function timestamp_to_millis(firebaseTimestamp: Timestamp): number;
@@ -224,6 +224,7 @@ interface TimeOptions {
224
224
  format?: string;
225
225
  fromFormat?: string;
226
226
  tz?: string;
227
+ defaultReturnedValue?: string;
227
228
  }
228
229
  declare function timestamp_to_string(firebaseTimestamp: Timestamp | Date | string, options?: TimeOptions): string;
229
230
  declare function timestamp_to_millis(firebaseTimestamp: Timestamp): number;
@@ -2012,6 +2012,10 @@ function cn() {
2012
2012
  var import_firestore2 = require("firebase/firestore");
2013
2013
  var import_moment_timezone = __toESM(require("moment-timezone"));
2014
2014
  function timestamp_to_string(firebaseTimestamp, options) {
2015
+ if (!firebaseTimestamp) {
2016
+ var _options_defaultReturnedValue;
2017
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
2018
+ }
2015
2019
  var date;
2016
2020
  if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
2017
2021
  date = firebaseTimestamp.toDate();
@@ -2020,10 +2024,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
2020
2024
  } else if (typeof firebaseTimestamp === "string") {
2021
2025
  date = import_moment_timezone.default.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
2022
2026
  if (isNaN(date.getTime())) {
2023
- throw new Error("Invalid date string format");
2027
+ var _options_defaultReturnedValue1;
2028
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
2024
2029
  }
2025
2030
  } else {
2026
- throw new Error("Invalid input: firebaseTimestamp must be a Timestamp, Date, or valid date string.");
2031
+ var _options_defaultReturnedValue2;
2032
+ return (_options_defaultReturnedValue2 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue2 !== void 0 ? _options_defaultReturnedValue2 : "-";
2027
2033
  }
2028
2034
  if (options === null || options === void 0 ? void 0 : options.tz) {
2029
2035
  var result = (0, import_moment_timezone.default)(date).tz(options === null || options === void 0 ? void 0 : options.tz).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
@@ -2032,6 +2038,9 @@ function timestamp_to_string(firebaseTimestamp, options) {
2032
2038
  return import_moment_timezone.default.utc(date).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
2033
2039
  }
2034
2040
  function timestamp_to_millis(firebaseTimestamp) {
2041
+ if (!firebaseTimestamp) {
2042
+ return 0;
2043
+ }
2035
2044
  var timestamp = new import_firestore2.Timestamp(firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.seconds, firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.nanoseconds);
2036
2045
  return timestamp.toMillis();
2037
2046
  }
@@ -1681,6 +1681,10 @@ function cn() {
1681
1681
  import { Timestamp as Timestamp2 } from "firebase/firestore";
1682
1682
  import moment2 from "moment-timezone";
1683
1683
  function timestamp_to_string(firebaseTimestamp, options) {
1684
+ if (!firebaseTimestamp) {
1685
+ var _options_defaultReturnedValue;
1686
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
1687
+ }
1684
1688
  var date;
1685
1689
  if (_instanceof(firebaseTimestamp, Timestamp2)) {
1686
1690
  date = firebaseTimestamp.toDate();
@@ -1689,10 +1693,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
1689
1693
  } else if (typeof firebaseTimestamp === "string") {
1690
1694
  date = moment2.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
1691
1695
  if (isNaN(date.getTime())) {
1692
- throw new Error("Invalid date string format");
1696
+ var _options_defaultReturnedValue1;
1697
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
1693
1698
  }
1694
1699
  } else {
1695
- throw new Error("Invalid input: firebaseTimestamp must be a Timestamp, Date, or valid date string.");
1700
+ var _options_defaultReturnedValue2;
1701
+ return (_options_defaultReturnedValue2 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue2 !== void 0 ? _options_defaultReturnedValue2 : "-";
1696
1702
  }
1697
1703
  if (options === null || options === void 0 ? void 0 : options.tz) {
1698
1704
  var result = moment2(date).tz(options === null || options === void 0 ? void 0 : options.tz).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
@@ -1701,6 +1707,9 @@ function timestamp_to_string(firebaseTimestamp, options) {
1701
1707
  return moment2.utc(date).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
1702
1708
  }
1703
1709
  function timestamp_to_millis(firebaseTimestamp) {
1710
+ if (!firebaseTimestamp) {
1711
+ return 0;
1712
+ }
1704
1713
  var timestamp = new Timestamp2(firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.seconds, firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.nanoseconds);
1705
1714
  return timestamp.toMillis();
1706
1715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.0.146",
3
+ "version": "1.0.148",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",