@lightsparkdev/core 1.2.8 → 1.3.1

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/dist/index.cjs CHANGED
@@ -80,10 +80,12 @@ __export(src_exports, {
80
80
  isNode: () => isNode,
81
81
  isNumber: () => isNumber,
82
82
  isObject: () => isObject2,
83
+ isRecord: () => isRecord,
83
84
  isSDKCurrencyAmount: () => isSDKCurrencyAmount,
84
85
  isTest: () => isTest,
85
86
  isType: () => isType,
86
87
  isUint8Array: () => isUint8Array,
88
+ isUmaCurrencyAmount: () => isUmaCurrencyAmount,
87
89
  linearInterpolate: () => linearInterpolate,
88
90
  localeToCurrencyCode: () => localeToCurrencyCode,
89
91
  localeToCurrencySymbol: () => localeToCurrencySymbol,
@@ -797,6 +799,7 @@ var CurrencyUnit = {
797
799
  USD: "USD",
798
800
  MXN: "MXN",
799
801
  PHP: "PHP",
802
+ EUR: "EUR",
800
803
  Bitcoin: "BITCOIN",
801
804
  Microbitcoin: "MICROBITCOIN",
802
805
  Millibitcoin: "MILLIBITCOIN",
@@ -817,7 +820,8 @@ var standardUnitConversionObj = {
817
820
  /* Converting between two different fiat types is not currently supported */
818
821
  [CurrencyUnit.USD]: (v) => v,
819
822
  [CurrencyUnit.MXN]: (v) => v,
820
- [CurrencyUnit.PHP]: (v) => v
823
+ [CurrencyUnit.PHP]: (v) => v,
824
+ [CurrencyUnit.EUR]: (v) => v
821
825
  };
822
826
  var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
823
827
  var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
@@ -835,7 +839,8 @@ var CONVERSION_MAP = {
835
839
  [CurrencyUnit.SATOSHI]: (v) => v * 1e8,
836
840
  [CurrencyUnit.USD]: toBitcoinConversion,
837
841
  [CurrencyUnit.MXN]: toBitcoinConversion,
838
- [CurrencyUnit.PHP]: toBitcoinConversion
842
+ [CurrencyUnit.PHP]: toBitcoinConversion,
843
+ [CurrencyUnit.EUR]: toBitcoinConversion
839
844
  },
840
845
  [CurrencyUnit.MICROBITCOIN]: {
841
846
  [CurrencyUnit.BITCOIN]: (v) => v / 1e6,
@@ -846,7 +851,8 @@ var CONVERSION_MAP = {
846
851
  [CurrencyUnit.SATOSHI]: (v) => v * 100,
847
852
  [CurrencyUnit.USD]: toMicrobitcoinConversion,
848
853
  [CurrencyUnit.MXN]: toMicrobitcoinConversion,
849
- [CurrencyUnit.PHP]: toMicrobitcoinConversion
854
+ [CurrencyUnit.PHP]: toMicrobitcoinConversion,
855
+ [CurrencyUnit.EUR]: toMicrobitcoinConversion
850
856
  },
851
857
  [CurrencyUnit.MILLIBITCOIN]: {
852
858
  [CurrencyUnit.BITCOIN]: (v) => v / 1e3,
@@ -857,7 +863,8 @@ var CONVERSION_MAP = {
857
863
  [CurrencyUnit.SATOSHI]: (v) => v * 1e5,
858
864
  [CurrencyUnit.USD]: toMillibitcoinConversion,
859
865
  [CurrencyUnit.MXN]: toMillibitcoinConversion,
860
- [CurrencyUnit.PHP]: toMillibitcoinConversion
866
+ [CurrencyUnit.PHP]: toMillibitcoinConversion,
867
+ [CurrencyUnit.EUR]: toMillibitcoinConversion
861
868
  },
862
869
  [CurrencyUnit.MILLISATOSHI]: {
863
870
  [CurrencyUnit.BITCOIN]: (v) => v / 1e11,
@@ -868,7 +875,8 @@ var CONVERSION_MAP = {
868
875
  [CurrencyUnit.SATOSHI]: (v) => v / 1e3,
869
876
  [CurrencyUnit.USD]: toMillisatoshiConversion,
870
877
  [CurrencyUnit.MXN]: toMillisatoshiConversion,
871
- [CurrencyUnit.PHP]: toMillisatoshiConversion
878
+ [CurrencyUnit.PHP]: toMillisatoshiConversion,
879
+ [CurrencyUnit.EUR]: toMillisatoshiConversion
872
880
  },
873
881
  [CurrencyUnit.NANOBITCOIN]: {
874
882
  [CurrencyUnit.BITCOIN]: (v) => v / 1e9,
@@ -879,7 +887,8 @@ var CONVERSION_MAP = {
879
887
  [CurrencyUnit.SATOSHI]: (v) => v / 10,
880
888
  [CurrencyUnit.USD]: toNanobitcoinConversion,
881
889
  [CurrencyUnit.MXN]: toNanobitcoinConversion,
882
- [CurrencyUnit.PHP]: toNanobitcoinConversion
890
+ [CurrencyUnit.PHP]: toNanobitcoinConversion,
891
+ [CurrencyUnit.EUR]: toNanobitcoinConversion
883
892
  },
884
893
  [CurrencyUnit.SATOSHI]: {
885
894
  [CurrencyUnit.BITCOIN]: (v) => v / 1e8,
@@ -890,11 +899,13 @@ var CONVERSION_MAP = {
890
899
  [CurrencyUnit.SATOSHI]: (v) => v,
891
900
  [CurrencyUnit.USD]: toSatoshiConversion,
892
901
  [CurrencyUnit.MXN]: toSatoshiConversion,
893
- [CurrencyUnit.PHP]: toSatoshiConversion
902
+ [CurrencyUnit.PHP]: toSatoshiConversion,
903
+ [CurrencyUnit.EUR]: toSatoshiConversion
894
904
  },
895
905
  [CurrencyUnit.USD]: standardUnitConversionObj,
896
906
  [CurrencyUnit.MXN]: standardUnitConversionObj,
897
- [CurrencyUnit.PHP]: standardUnitConversionObj
907
+ [CurrencyUnit.PHP]: standardUnitConversionObj,
908
+ [CurrencyUnit.EUR]: standardUnitConversionObj
898
909
  };
899
910
  function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
900
911
  if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
@@ -928,6 +939,9 @@ var convertCurrencyAmount = (from, toUnit) => {
928
939
  function isCurrencyAmountInputObj(arg) {
929
940
  return typeof arg === "object" && arg !== null && "value" in arg && (typeof arg.value === "number" || typeof arg.value === "string" || arg.value === null) && "unit" in arg && typeof arg.unit === "string";
930
941
  }
942
+ function isUmaCurrencyAmount(arg) {
943
+ return typeof arg === "object" && arg !== null && "value" in arg && typeof arg.value === "number" && "currency" in arg && typeof arg.currency === "object" && typeof arg.currency.code === "string" && typeof arg.currency.symbol === "string" && typeof arg.currency.name === "string" && typeof arg.currency.decimals === "number";
944
+ }
931
945
  function isDeprecatedCurrencyAmountObj(arg) {
932
946
  return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
933
947
  }
@@ -974,6 +988,7 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
974
988
  usd: CurrencyUnit.USD,
975
989
  mxn: CurrencyUnit.MXN,
976
990
  php: CurrencyUnit.PHP,
991
+ eur: CurrencyUnit.EUR,
977
992
  mibtc: CurrencyUnit.MICROBITCOIN,
978
993
  mlbtc: CurrencyUnit.MILLIBITCOIN,
979
994
  nbtc: CurrencyUnit.NANOBITCOIN
@@ -1012,7 +1027,7 @@ function getPreferredConversionOverride(currencyAmountArg) {
1012
1027
  function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
1013
1028
  const { value, unit } = getCurrencyAmount(currencyAmountArg);
1014
1029
  const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
1015
- const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
1030
+ const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
1016
1031
  const mapWithCurrencyUnits = {
1017
1032
  [CurrencyUnit.BITCOIN]: btc,
1018
1033
  [CurrencyUnit.SATOSHI]: sats,
@@ -1020,6 +1035,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
1020
1035
  [CurrencyUnit.USD]: usd,
1021
1036
  [CurrencyUnit.MXN]: mxn,
1022
1037
  [CurrencyUnit.PHP]: php,
1038
+ [CurrencyUnit.EUR]: eur,
1023
1039
  [CurrencyUnit.MICROBITCOIN]: mibtc,
1024
1040
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
1025
1041
  [CurrencyUnit.NANOBITCOIN]: nbtc,
@@ -1061,6 +1077,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
1061
1077
  value: php,
1062
1078
  unit: CurrencyUnit.PHP
1063
1079
  }),
1080
+ [CurrencyUnit.EUR]: formatCurrencyStr({
1081
+ value: eur,
1082
+ unit: CurrencyUnit.EUR
1083
+ }),
1064
1084
  [CurrencyUnit.FUTURE_VALUE]: "-"
1065
1085
  }
1066
1086
  };
@@ -1125,6 +1145,8 @@ var abbrCurrencyUnit = (unit) => {
1125
1145
  return "MXN";
1126
1146
  case CurrencyUnit.PHP:
1127
1147
  return "PHP";
1148
+ case CurrencyUnit.EUR:
1149
+ return "EUR";
1128
1150
  }
1129
1151
  return "Unsupported CurrencyUnit";
1130
1152
  };
@@ -1140,16 +1162,27 @@ function formatCurrencyStr(amount, options) {
1140
1162
  ...defaultOptions,
1141
1163
  ...options
1142
1164
  };
1143
- const currencyAmount = getCurrencyAmount(amount);
1144
- let { value: num } = currencyAmount;
1145
- const { unit } = currencyAmount;
1146
- const centCurrencies = [
1147
- CurrencyUnit.USD,
1148
- CurrencyUnit.MXN,
1149
- CurrencyUnit.PHP
1150
- ];
1151
- if (centCurrencies.includes(unit)) {
1152
- num = num / 100;
1165
+ let num;
1166
+ let unit;
1167
+ if (isUmaCurrencyAmount(amount)) {
1168
+ num = amount.value;
1169
+ unit = amount.currency.code;
1170
+ if (amount.currency.decimals > 0) {
1171
+ num = amount.value / Math.pow(10, amount.currency.decimals);
1172
+ }
1173
+ } else {
1174
+ const currencyAmount = getCurrencyAmount(amount);
1175
+ num = currencyAmount.value;
1176
+ unit = currencyAmount.unit;
1177
+ const centCurrencies = [
1178
+ CurrencyUnit.USD,
1179
+ CurrencyUnit.MXN,
1180
+ CurrencyUnit.PHP,
1181
+ CurrencyUnit.EUR
1182
+ ];
1183
+ if (centCurrencies.includes(unit)) {
1184
+ num = num / 100;
1185
+ }
1153
1186
  }
1154
1187
  function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
1155
1188
  let digits = defaultDigits;
@@ -1162,21 +1195,22 @@ function formatCurrencyStr(amount, options) {
1162
1195
  }
1163
1196
  return digits;
1164
1197
  }
1165
- const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
1198
+ const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
1166
1199
  const currentLocale = getCurrentLocale();
1167
- let formattedStr = "";
1168
- switch (unit) {
1169
- case CurrencyUnit.MXN:
1170
- case CurrencyUnit.USD:
1171
- case CurrencyUnit.PHP:
1172
- formattedStr = num.toLocaleString(currentLocale, {
1200
+ function isFormattableFiatCurrencyCode(currencyCode) {
1201
+ try {
1202
+ new Intl.NumberFormat(currentLocale, {
1173
1203
  style: "currency",
1174
- currency: unit,
1175
- currencyDisplay: "narrowSymbol",
1176
- notation: compact ? "compact" : void 0,
1177
- maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
1204
+ currency: currencyCode
1178
1205
  });
1179
- break;
1206
+ return true;
1207
+ } catch (e) {
1208
+ return false;
1209
+ }
1210
+ }
1211
+ let formattedStr = "";
1212
+ let forceAppendUnits = false;
1213
+ switch (unit) {
1180
1214
  case CurrencyUnit.BITCOIN:
1181
1215
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1182
1216
  notation: compact ? "compact" : void 0,
@@ -1184,6 +1218,7 @@ function formatCurrencyStr(amount, options) {
1184
1218
  })}`;
1185
1219
  break;
1186
1220
  case CurrencyUnit.SATOSHI:
1221
+ case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
1187
1222
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1188
1223
  notation: compact ? "compact" : void 0,
1189
1224
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
@@ -1193,21 +1228,35 @@ function formatCurrencyStr(amount, options) {
1193
1228
  case CurrencyUnit.MICROBITCOIN:
1194
1229
  case CurrencyUnit.MILLIBITCOIN:
1195
1230
  case CurrencyUnit.NANOBITCOIN:
1196
- default:
1197
1231
  formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
1198
1232
  notation: compact ? "compact" : void 0,
1199
1233
  maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
1200
1234
  })}`;
1235
+ break;
1236
+ default:
1237
+ if (isFormattableFiatCurrencyCode(unit)) {
1238
+ formattedStr = num.toLocaleString(currentLocale, {
1239
+ style: "currency",
1240
+ currency: unit,
1241
+ currencyDisplay: "narrowSymbol",
1242
+ notation: compact ? "compact" : void 0,
1243
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
1244
+ });
1245
+ } else {
1246
+ formattedStr = `${num}`;
1247
+ forceAppendUnits = true;
1248
+ }
1249
+ break;
1201
1250
  }
1202
- if (options?.appendUnits) {
1251
+ if (options?.appendUnits || forceAppendUnits) {
1203
1252
  const localeCurrencyCode = localeToCurrencyCode(currentLocale);
1204
- if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
1253
+ if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
1205
1254
  return formattedStr;
1206
1255
  }
1207
- const unitStr = abbrCurrencyUnit(unit);
1208
- const unitSuffix = options.appendUnits.plural && num > 1 ? "s" : "";
1256
+ const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
1257
+ const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
1209
1258
  const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
1210
- formattedStr += ` ${options.appendUnits.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
1259
+ formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
1211
1260
  }
1212
1261
  return formattedStr;
1213
1262
  }
@@ -1432,6 +1481,9 @@ var isType = (typename) => (node) => {
1432
1481
  function notNullUndefined(value) {
1433
1482
  return value !== null && value !== void 0;
1434
1483
  }
1484
+ function isRecord(value) {
1485
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1486
+ }
1435
1487
 
1436
1488
  // src/crypto/SigningKey.ts
1437
1489
  function isAlias(key) {
@@ -1730,9 +1782,15 @@ var Requester = class {
1730
1782
  const responseJson = await response.json();
1731
1783
  const data = responseJson.data;
1732
1784
  if (!data) {
1785
+ let firstErrorName = void 0;
1786
+ if (Array.isArray(responseJson.errors) && responseJson.errors.length > 0) {
1787
+ const firstError = responseJson.errors[0];
1788
+ firstErrorName = firstError["extensions"]?.["error_name"];
1789
+ }
1733
1790
  throw new LightsparkException_default(
1734
1791
  "RequestFailed",
1735
- `Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`
1792
+ `Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`,
1793
+ { errorName: firstErrorName }
1736
1794
  );
1737
1795
  }
1738
1796
  return data;
@@ -1859,10 +1917,12 @@ var ServerEnvironment_default = ServerEnvironment;
1859
1917
  isNode,
1860
1918
  isNumber,
1861
1919
  isObject,
1920
+ isRecord,
1862
1921
  isSDKCurrencyAmount,
1863
1922
  isTest,
1864
1923
  isType,
1865
1924
  isUint8Array,
1925
+ isUmaCurrencyAmount,
1866
1926
  linearInterpolate,
1867
1927
  localeToCurrencyCode,
1868
1928
  localeToCurrencySymbol,
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AppendUnitsOptions, a7 as ById, ah as Complete, C as ConfigKeys, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from './index-r0bUxDu_.cjs';
1
+ export { A as AppendUnitsOptions, aa as ById, al as Complete, C as ConfigKeys, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ae as DeepPartial, D as DeprecatedCurrencyAmountObj, a9 as ExpandRecursively, ad as ExtractByTypename, af as JSONLiteral, ah as JSONObject, ag as JSONType, a8 as Maybe, ai as NN, ab as OmitTypename, ak as PartialBy, am as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, an as isRecord, v as isSDKCurrencyAmount, I as isTest, ac as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, aj as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from './index-C7dqDM91.cjs';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  type Headers = Record<string, string>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AppendUnitsOptions, a7 as ById, ah as Complete, C as ConfigKeys, n as CurrencyAmountArg, k as CurrencyAmountInputObj, l as CurrencyAmountObj, m as CurrencyAmountPreferenceObj, R as CurrencyCodes, Q as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, aa as DeepPartial, D as DeprecatedCurrencyAmountObj, a6 as ExpandRecursively, ab as JSONLiteral, ad as JSONObject, ac as JSONType, a5 as Maybe, ae as NN, a8 as OmitTypename, ag as PartialBy, ai as RequiredKeys, S as SDKCurrencyAmountType, x as abbrCurrencyUnit, b as b64decode, a as b64encode, M as bytesToHex, Y as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, P as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, X as deleteLocalStorageItem, e as ensureArray, L as errorToJSON, y as formatCurrencyStr, t as getCurrencyAmount, O as getCurrentLocale, J as getErrorMsg, V as getLocalStorageBoolean, U as getLocalStorageConfigItem, N as hexToBytes, E as isBrowser, o as isCurrencyAmountInputObj, q as isCurrencyAmountObj, r as isCurrencyAmountPreferenceObj, w as isCurrencyMap, p as isDeprecatedCurrencyAmountObj, H as isError, K as isErrorMsg, I as isErrorWithMessage, F as isNode, $ as isNumber, a4 as isObject, s as isSDKCurrencyAmount, G as isTest, a9 as isType, a3 as isUint8Array, Z as linearInterpolate, T as localeToCurrencyCode, B as localeToCurrencySymbol, a2 as lsidToUUID, v as mapCurrencyAmount, af as notNullUndefined, a0 as pollUntil, _ as round, z as separateCurrencyStrParts, W as setLocalStorageBoolean, a1 as sleep, u as urlsafe_b64decode } from './index-r0bUxDu_.js';
1
+ export { A as AppendUnitsOptions, aa as ById, al as Complete, C as ConfigKeys, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ae as DeepPartial, D as DeprecatedCurrencyAmountObj, a9 as ExpandRecursively, ad as ExtractByTypename, af as JSONLiteral, ah as JSONObject, ag as JSONType, a8 as Maybe, ai as NN, ab as OmitTypename, ak as PartialBy, am as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, an as isRecord, v as isSDKCurrencyAmount, I as isTest, ac as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, aj as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from './index-C7dqDM91.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  type Headers = Record<string, string>;
package/dist/index.js CHANGED
@@ -33,10 +33,12 @@ import {
33
33
  isNode,
34
34
  isNumber,
35
35
  isObject,
36
+ isRecord,
36
37
  isSDKCurrencyAmount,
37
38
  isTest,
38
39
  isType,
39
40
  isUint8Array,
41
+ isUmaCurrencyAmount,
40
42
  linearInterpolate,
41
43
  localeToCurrencyCode,
42
44
  localeToCurrencySymbol,
@@ -49,7 +51,7 @@ import {
49
51
  setLocalStorageBoolean,
50
52
  sleep,
51
53
  urlsafe_b64decode
52
- } from "./chunk-NY4EJZNK.js";
54
+ } from "./chunk-23SS5EX2.js";
53
55
 
54
56
  // src/auth/LightsparkAuthException.ts
55
57
  var LightsparkAuthException = class extends LightsparkException_default {
@@ -633,9 +635,15 @@ var Requester = class {
633
635
  const responseJson = await response.json();
634
636
  const data = responseJson.data;
635
637
  if (!data) {
638
+ let firstErrorName = void 0;
639
+ if (Array.isArray(responseJson.errors) && responseJson.errors.length > 0) {
640
+ const firstError = responseJson.errors[0];
641
+ firstErrorName = firstError["extensions"]?.["error_name"];
642
+ }
636
643
  throw new LightsparkException_default(
637
644
  "RequestFailed",
638
- `Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`
645
+ `Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`,
646
+ { errorName: firstErrorName }
639
647
  );
640
648
  }
641
649
  return data;
@@ -761,10 +769,12 @@ export {
761
769
  isNode,
762
770
  isNumber,
763
771
  isObject,
772
+ isRecord,
764
773
  isSDKCurrencyAmount,
765
774
  isTest,
766
775
  isType,
767
776
  isUint8Array,
777
+ isUmaCurrencyAmount,
768
778
  linearInterpolate,
769
779
  localeToCurrencyCode,
770
780
  localeToCurrencySymbol,