akeyless-client-commons 1.0.147 → 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.
@@ -1098,7 +1098,8 @@ 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
1100
  if (!firebaseTimestamp) {
1101
- return "-";
1101
+ var _options_defaultReturnedValue;
1102
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
1102
1103
  }
1103
1104
  var date;
1104
1105
  if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
@@ -1108,10 +1109,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
1108
1109
  } else if (typeof firebaseTimestamp === "string") {
1109
1110
  date = import_moment_timezone.default.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
1110
1111
  if (isNaN(date.getTime())) {
1111
- throw new Error("Invalid date string format");
1112
+ var _options_defaultReturnedValue1;
1113
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
1112
1114
  }
1113
1115
  } else {
1114
- 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 : "-";
1115
1118
  }
1116
1119
  if (options === null || options === void 0 ? void 0 : options.tz) {
1117
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");
@@ -885,7 +885,8 @@ import { Timestamp as Timestamp2 } from "firebase/firestore";
885
885
  import moment2 from "moment-timezone";
886
886
  function timestamp_to_string(firebaseTimestamp, options) {
887
887
  if (!firebaseTimestamp) {
888
- return "-";
888
+ var _options_defaultReturnedValue;
889
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
889
890
  }
890
891
  var date;
891
892
  if (_instanceof(firebaseTimestamp, Timestamp2)) {
@@ -895,10 +896,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
895
896
  } else if (typeof firebaseTimestamp === "string") {
896
897
  date = moment2.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
897
898
  if (isNaN(date.getTime())) {
898
- throw new Error("Invalid date string format");
899
+ var _options_defaultReturnedValue1;
900
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
899
901
  }
900
902
  } else {
901
- 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 : "-";
902
905
  }
903
906
  if (options === null || options === void 0 ? void 0 : options.tz) {
904
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;
@@ -2013,7 +2013,8 @@ 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
2015
  if (!firebaseTimestamp) {
2016
- return "-";
2016
+ var _options_defaultReturnedValue;
2017
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
2017
2018
  }
2018
2019
  var date;
2019
2020
  if (_instanceof(firebaseTimestamp, import_firestore2.Timestamp)) {
@@ -2023,10 +2024,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
2023
2024
  } else if (typeof firebaseTimestamp === "string") {
2024
2025
  date = import_moment_timezone.default.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
2025
2026
  if (isNaN(date.getTime())) {
2026
- throw new Error("Invalid date string format");
2027
+ var _options_defaultReturnedValue1;
2028
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
2027
2029
  }
2028
2030
  } else {
2029
- 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 : "-";
2030
2033
  }
2031
2034
  if (options === null || options === void 0 ? void 0 : options.tz) {
2032
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");
@@ -2035,6 +2038,9 @@ function timestamp_to_string(firebaseTimestamp, options) {
2035
2038
  return import_moment_timezone.default.utc(date).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
2036
2039
  }
2037
2040
  function timestamp_to_millis(firebaseTimestamp) {
2041
+ if (!firebaseTimestamp) {
2042
+ return 0;
2043
+ }
2038
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);
2039
2045
  return timestamp.toMillis();
2040
2046
  }
@@ -1682,7 +1682,8 @@ import { Timestamp as Timestamp2 } from "firebase/firestore";
1682
1682
  import moment2 from "moment-timezone";
1683
1683
  function timestamp_to_string(firebaseTimestamp, options) {
1684
1684
  if (!firebaseTimestamp) {
1685
- return "-";
1685
+ var _options_defaultReturnedValue;
1686
+ return (_options_defaultReturnedValue = options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-";
1686
1687
  }
1687
1688
  var date;
1688
1689
  if (_instanceof(firebaseTimestamp, Timestamp2)) {
@@ -1692,10 +1693,12 @@ function timestamp_to_string(firebaseTimestamp, options) {
1692
1693
  } else if (typeof firebaseTimestamp === "string") {
1693
1694
  date = moment2.utc(firebaseTimestamp, (options === null || options === void 0 ? void 0 : options.fromFormat) || "DD/MM/YYYY HH:mm:ss").toDate();
1694
1695
  if (isNaN(date.getTime())) {
1695
- throw new Error("Invalid date string format");
1696
+ var _options_defaultReturnedValue1;
1697
+ return (_options_defaultReturnedValue1 = options.defaultReturnedValue) !== null && _options_defaultReturnedValue1 !== void 0 ? _options_defaultReturnedValue1 : "-";
1696
1698
  }
1697
1699
  } else {
1698
- 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 : "-";
1699
1702
  }
1700
1703
  if (options === null || options === void 0 ? void 0 : options.tz) {
1701
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");
@@ -1704,6 +1707,9 @@ function timestamp_to_string(firebaseTimestamp, options) {
1704
1707
  return moment2.utc(date).format((options === null || options === void 0 ? void 0 : options.format) || "DD/MM/YYYY HH:mm:ss");
1705
1708
  }
1706
1709
  function timestamp_to_millis(firebaseTimestamp) {
1710
+ if (!firebaseTimestamp) {
1711
+ return 0;
1712
+ }
1707
1713
  var timestamp = new Timestamp2(firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.seconds, firebaseTimestamp === null || firebaseTimestamp === void 0 ? void 0 : firebaseTimestamp.nanoseconds);
1708
1714
  return timestamp.toMillis();
1709
1715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.0.147",
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",