@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/CHANGELOG.md +29 -0
- package/dist/{chunk-NY4EJZNK.js → chunk-23SS5EX2.js} +90 -38
- package/dist/{index-r0bUxDu_.d.cts → index-C7dqDM91.d.cts} +24 -3
- package/dist/{index-r0bUxDu_.d.ts → index-C7dqDM91.d.ts} +24 -3
- package/dist/index.cjs +98 -38
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -2
- package/dist/utils/index.cjs +91 -37
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +5 -1
- package/package.json +11 -22
- package/src/requester/Requester.ts +13 -0
- package/src/utils/currency.ts +112 -32
- package/src/utils/types.ts +8 -0
package/dist/utils/index.cjs
CHANGED
|
@@ -63,10 +63,12 @@ __export(utils_exports, {
|
|
|
63
63
|
isNode: () => isNode,
|
|
64
64
|
isNumber: () => isNumber,
|
|
65
65
|
isObject: () => isObject2,
|
|
66
|
+
isRecord: () => isRecord,
|
|
66
67
|
isSDKCurrencyAmount: () => isSDKCurrencyAmount,
|
|
67
68
|
isTest: () => isTest,
|
|
68
69
|
isType: () => isType,
|
|
69
70
|
isUint8Array: () => isUint8Array,
|
|
71
|
+
isUmaCurrencyAmount: () => isUmaCurrencyAmount,
|
|
70
72
|
linearInterpolate: () => linearInterpolate,
|
|
71
73
|
localeToCurrencyCode: () => localeToCurrencyCode,
|
|
72
74
|
localeToCurrencySymbol: () => localeToCurrencySymbol,
|
|
@@ -492,6 +494,7 @@ var CurrencyUnit = {
|
|
|
492
494
|
USD: "USD",
|
|
493
495
|
MXN: "MXN",
|
|
494
496
|
PHP: "PHP",
|
|
497
|
+
EUR: "EUR",
|
|
495
498
|
Bitcoin: "BITCOIN",
|
|
496
499
|
Microbitcoin: "MICROBITCOIN",
|
|
497
500
|
Millibitcoin: "MILLIBITCOIN",
|
|
@@ -512,7 +515,8 @@ var standardUnitConversionObj = {
|
|
|
512
515
|
/* Converting between two different fiat types is not currently supported */
|
|
513
516
|
[CurrencyUnit.USD]: (v) => v,
|
|
514
517
|
[CurrencyUnit.MXN]: (v) => v,
|
|
515
|
-
[CurrencyUnit.PHP]: (v) => v
|
|
518
|
+
[CurrencyUnit.PHP]: (v) => v,
|
|
519
|
+
[CurrencyUnit.EUR]: (v) => v
|
|
516
520
|
};
|
|
517
521
|
var toBitcoinConversion = (v, unitsPerBtc = 1) => round(v * unitsPerBtc);
|
|
518
522
|
var toMicrobitcoinConversion = (v, unitsPerBtc = 1) => round(v / 1e6 * unitsPerBtc);
|
|
@@ -530,7 +534,8 @@ var CONVERSION_MAP = {
|
|
|
530
534
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e8,
|
|
531
535
|
[CurrencyUnit.USD]: toBitcoinConversion,
|
|
532
536
|
[CurrencyUnit.MXN]: toBitcoinConversion,
|
|
533
|
-
[CurrencyUnit.PHP]: toBitcoinConversion
|
|
537
|
+
[CurrencyUnit.PHP]: toBitcoinConversion,
|
|
538
|
+
[CurrencyUnit.EUR]: toBitcoinConversion
|
|
534
539
|
},
|
|
535
540
|
[CurrencyUnit.MICROBITCOIN]: {
|
|
536
541
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e6,
|
|
@@ -541,7 +546,8 @@ var CONVERSION_MAP = {
|
|
|
541
546
|
[CurrencyUnit.SATOSHI]: (v) => v * 100,
|
|
542
547
|
[CurrencyUnit.USD]: toMicrobitcoinConversion,
|
|
543
548
|
[CurrencyUnit.MXN]: toMicrobitcoinConversion,
|
|
544
|
-
[CurrencyUnit.PHP]: toMicrobitcoinConversion
|
|
549
|
+
[CurrencyUnit.PHP]: toMicrobitcoinConversion,
|
|
550
|
+
[CurrencyUnit.EUR]: toMicrobitcoinConversion
|
|
545
551
|
},
|
|
546
552
|
[CurrencyUnit.MILLIBITCOIN]: {
|
|
547
553
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e3,
|
|
@@ -552,7 +558,8 @@ var CONVERSION_MAP = {
|
|
|
552
558
|
[CurrencyUnit.SATOSHI]: (v) => v * 1e5,
|
|
553
559
|
[CurrencyUnit.USD]: toMillibitcoinConversion,
|
|
554
560
|
[CurrencyUnit.MXN]: toMillibitcoinConversion,
|
|
555
|
-
[CurrencyUnit.PHP]: toMillibitcoinConversion
|
|
561
|
+
[CurrencyUnit.PHP]: toMillibitcoinConversion,
|
|
562
|
+
[CurrencyUnit.EUR]: toMillibitcoinConversion
|
|
556
563
|
},
|
|
557
564
|
[CurrencyUnit.MILLISATOSHI]: {
|
|
558
565
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e11,
|
|
@@ -563,7 +570,8 @@ var CONVERSION_MAP = {
|
|
|
563
570
|
[CurrencyUnit.SATOSHI]: (v) => v / 1e3,
|
|
564
571
|
[CurrencyUnit.USD]: toMillisatoshiConversion,
|
|
565
572
|
[CurrencyUnit.MXN]: toMillisatoshiConversion,
|
|
566
|
-
[CurrencyUnit.PHP]: toMillisatoshiConversion
|
|
573
|
+
[CurrencyUnit.PHP]: toMillisatoshiConversion,
|
|
574
|
+
[CurrencyUnit.EUR]: toMillisatoshiConversion
|
|
567
575
|
},
|
|
568
576
|
[CurrencyUnit.NANOBITCOIN]: {
|
|
569
577
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e9,
|
|
@@ -574,7 +582,8 @@ var CONVERSION_MAP = {
|
|
|
574
582
|
[CurrencyUnit.SATOSHI]: (v) => v / 10,
|
|
575
583
|
[CurrencyUnit.USD]: toNanobitcoinConversion,
|
|
576
584
|
[CurrencyUnit.MXN]: toNanobitcoinConversion,
|
|
577
|
-
[CurrencyUnit.PHP]: toNanobitcoinConversion
|
|
585
|
+
[CurrencyUnit.PHP]: toNanobitcoinConversion,
|
|
586
|
+
[CurrencyUnit.EUR]: toNanobitcoinConversion
|
|
578
587
|
},
|
|
579
588
|
[CurrencyUnit.SATOSHI]: {
|
|
580
589
|
[CurrencyUnit.BITCOIN]: (v) => v / 1e8,
|
|
@@ -585,11 +594,13 @@ var CONVERSION_MAP = {
|
|
|
585
594
|
[CurrencyUnit.SATOSHI]: (v) => v,
|
|
586
595
|
[CurrencyUnit.USD]: toSatoshiConversion,
|
|
587
596
|
[CurrencyUnit.MXN]: toSatoshiConversion,
|
|
588
|
-
[CurrencyUnit.PHP]: toSatoshiConversion
|
|
597
|
+
[CurrencyUnit.PHP]: toSatoshiConversion,
|
|
598
|
+
[CurrencyUnit.EUR]: toSatoshiConversion
|
|
589
599
|
},
|
|
590
600
|
[CurrencyUnit.USD]: standardUnitConversionObj,
|
|
591
601
|
[CurrencyUnit.MXN]: standardUnitConversionObj,
|
|
592
|
-
[CurrencyUnit.PHP]: standardUnitConversionObj
|
|
602
|
+
[CurrencyUnit.PHP]: standardUnitConversionObj,
|
|
603
|
+
[CurrencyUnit.EUR]: standardUnitConversionObj
|
|
593
604
|
};
|
|
594
605
|
function convertCurrencyAmountValue(fromUnit, toUnit, amount, unitsPerBtc = 1) {
|
|
595
606
|
if (fromUnit === CurrencyUnit.FUTURE_VALUE || toUnit === CurrencyUnit.FUTURE_VALUE) {
|
|
@@ -623,6 +634,9 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
623
634
|
function isCurrencyAmountInputObj(arg) {
|
|
624
635
|
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";
|
|
625
636
|
}
|
|
637
|
+
function isUmaCurrencyAmount(arg) {
|
|
638
|
+
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";
|
|
639
|
+
}
|
|
626
640
|
function isDeprecatedCurrencyAmountObj(arg) {
|
|
627
641
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
628
642
|
}
|
|
@@ -669,6 +683,7 @@ function convertCurrencyAmountValues(fromUnit, amount, unitsPerBtc = 1, conversi
|
|
|
669
683
|
usd: CurrencyUnit.USD,
|
|
670
684
|
mxn: CurrencyUnit.MXN,
|
|
671
685
|
php: CurrencyUnit.PHP,
|
|
686
|
+
eur: CurrencyUnit.EUR,
|
|
672
687
|
mibtc: CurrencyUnit.MICROBITCOIN,
|
|
673
688
|
mlbtc: CurrencyUnit.MILLIBITCOIN,
|
|
674
689
|
nbtc: CurrencyUnit.NANOBITCOIN
|
|
@@ -707,7 +722,7 @@ function getPreferredConversionOverride(currencyAmountArg) {
|
|
|
707
722
|
function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
708
723
|
const { value, unit } = getCurrencyAmount(currencyAmountArg);
|
|
709
724
|
const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
|
|
710
|
-
const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
725
|
+
const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } = convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
|
|
711
726
|
const mapWithCurrencyUnits = {
|
|
712
727
|
[CurrencyUnit.BITCOIN]: btc,
|
|
713
728
|
[CurrencyUnit.SATOSHI]: sats,
|
|
@@ -715,6 +730,7 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
715
730
|
[CurrencyUnit.USD]: usd,
|
|
716
731
|
[CurrencyUnit.MXN]: mxn,
|
|
717
732
|
[CurrencyUnit.PHP]: php,
|
|
733
|
+
[CurrencyUnit.EUR]: eur,
|
|
718
734
|
[CurrencyUnit.MICROBITCOIN]: mibtc,
|
|
719
735
|
[CurrencyUnit.MILLIBITCOIN]: mlbtc,
|
|
720
736
|
[CurrencyUnit.NANOBITCOIN]: nbtc,
|
|
@@ -756,6 +772,10 @@ function mapCurrencyAmount(currencyAmountArg, unitsPerBtc = 1) {
|
|
|
756
772
|
value: php,
|
|
757
773
|
unit: CurrencyUnit.PHP
|
|
758
774
|
}),
|
|
775
|
+
[CurrencyUnit.EUR]: formatCurrencyStr({
|
|
776
|
+
value: eur,
|
|
777
|
+
unit: CurrencyUnit.EUR
|
|
778
|
+
}),
|
|
759
779
|
[CurrencyUnit.FUTURE_VALUE]: "-"
|
|
760
780
|
}
|
|
761
781
|
};
|
|
@@ -820,6 +840,8 @@ var abbrCurrencyUnit = (unit) => {
|
|
|
820
840
|
return "MXN";
|
|
821
841
|
case CurrencyUnit.PHP:
|
|
822
842
|
return "PHP";
|
|
843
|
+
case CurrencyUnit.EUR:
|
|
844
|
+
return "EUR";
|
|
823
845
|
}
|
|
824
846
|
return "Unsupported CurrencyUnit";
|
|
825
847
|
};
|
|
@@ -835,16 +857,27 @@ function formatCurrencyStr(amount, options) {
|
|
|
835
857
|
...defaultOptions,
|
|
836
858
|
...options
|
|
837
859
|
};
|
|
838
|
-
|
|
839
|
-
let
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
860
|
+
let num;
|
|
861
|
+
let unit;
|
|
862
|
+
if (isUmaCurrencyAmount(amount)) {
|
|
863
|
+
num = amount.value;
|
|
864
|
+
unit = amount.currency.code;
|
|
865
|
+
if (amount.currency.decimals > 0) {
|
|
866
|
+
num = amount.value / Math.pow(10, amount.currency.decimals);
|
|
867
|
+
}
|
|
868
|
+
} else {
|
|
869
|
+
const currencyAmount = getCurrencyAmount(amount);
|
|
870
|
+
num = currencyAmount.value;
|
|
871
|
+
unit = currencyAmount.unit;
|
|
872
|
+
const centCurrencies = [
|
|
873
|
+
CurrencyUnit.USD,
|
|
874
|
+
CurrencyUnit.MXN,
|
|
875
|
+
CurrencyUnit.PHP,
|
|
876
|
+
CurrencyUnit.EUR
|
|
877
|
+
];
|
|
878
|
+
if (centCurrencies.includes(unit)) {
|
|
879
|
+
num = num / 100;
|
|
880
|
+
}
|
|
848
881
|
}
|
|
849
882
|
function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
|
|
850
883
|
let digits = defaultDigits;
|
|
@@ -857,21 +890,22 @@ function formatCurrencyStr(amount, options) {
|
|
|
857
890
|
}
|
|
858
891
|
return digits;
|
|
859
892
|
}
|
|
860
|
-
const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
|
|
893
|
+
const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI || unit === abbrCurrencyUnit(CurrencyUnit.SATOSHI) ? "\uE902" : "";
|
|
861
894
|
const currentLocale = getCurrentLocale();
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
case CurrencyUnit.USD:
|
|
866
|
-
case CurrencyUnit.PHP:
|
|
867
|
-
formattedStr = num.toLocaleString(currentLocale, {
|
|
895
|
+
function isFormattableFiatCurrencyCode(currencyCode) {
|
|
896
|
+
try {
|
|
897
|
+
new Intl.NumberFormat(currentLocale, {
|
|
868
898
|
style: "currency",
|
|
869
|
-
currency:
|
|
870
|
-
currencyDisplay: "narrowSymbol",
|
|
871
|
-
notation: compact ? "compact" : void 0,
|
|
872
|
-
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
899
|
+
currency: currencyCode
|
|
873
900
|
});
|
|
874
|
-
|
|
901
|
+
return true;
|
|
902
|
+
} catch (e) {
|
|
903
|
+
return false;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
let formattedStr = "";
|
|
907
|
+
let forceAppendUnits = false;
|
|
908
|
+
switch (unit) {
|
|
875
909
|
case CurrencyUnit.BITCOIN:
|
|
876
910
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
877
911
|
notation: compact ? "compact" : void 0,
|
|
@@ -879,6 +913,7 @@ function formatCurrencyStr(amount, options) {
|
|
|
879
913
|
})}`;
|
|
880
914
|
break;
|
|
881
915
|
case CurrencyUnit.SATOSHI:
|
|
916
|
+
case abbrCurrencyUnit(CurrencyUnit.SATOSHI):
|
|
882
917
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
883
918
|
notation: compact ? "compact" : void 0,
|
|
884
919
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
|
|
@@ -888,21 +923,35 @@ function formatCurrencyStr(amount, options) {
|
|
|
888
923
|
case CurrencyUnit.MICROBITCOIN:
|
|
889
924
|
case CurrencyUnit.MILLIBITCOIN:
|
|
890
925
|
case CurrencyUnit.NANOBITCOIN:
|
|
891
|
-
default:
|
|
892
926
|
formattedStr = `${symbol}${num.toLocaleString(currentLocale, {
|
|
893
927
|
notation: compact ? "compact" : void 0,
|
|
894
928
|
maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
|
|
895
929
|
})}`;
|
|
930
|
+
break;
|
|
931
|
+
default:
|
|
932
|
+
if (isFormattableFiatCurrencyCode(unit)) {
|
|
933
|
+
formattedStr = num.toLocaleString(currentLocale, {
|
|
934
|
+
style: "currency",
|
|
935
|
+
currency: unit,
|
|
936
|
+
currencyDisplay: "narrowSymbol",
|
|
937
|
+
notation: compact ? "compact" : void 0,
|
|
938
|
+
maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
|
|
939
|
+
});
|
|
940
|
+
} else {
|
|
941
|
+
formattedStr = `${num}`;
|
|
942
|
+
forceAppendUnits = true;
|
|
943
|
+
}
|
|
944
|
+
break;
|
|
896
945
|
}
|
|
897
|
-
if (options?.appendUnits) {
|
|
946
|
+
if (options?.appendUnits || forceAppendUnits) {
|
|
898
947
|
const localeCurrencyCode = localeToCurrencyCode(currentLocale);
|
|
899
|
-
if (unit === localeCurrencyCode && !options.appendUnits.showForCurrentLocaleUnit) {
|
|
948
|
+
if (unit === localeCurrencyCode && options?.appendUnits && !options.appendUnits.showForCurrentLocaleUnit) {
|
|
900
949
|
return formattedStr;
|
|
901
950
|
}
|
|
902
|
-
const unitStr = abbrCurrencyUnit(unit);
|
|
903
|
-
const unitSuffix = options
|
|
951
|
+
const unitStr = isUmaCurrencyAmount(amount) ? amount.currency.code : abbrCurrencyUnit(unit);
|
|
952
|
+
const unitSuffix = options?.appendUnits?.plural && num > 1 ? "s" : "";
|
|
904
953
|
const unitStrWithSuffix = `${unitStr}${unitSuffix}`;
|
|
905
|
-
formattedStr += ` ${options
|
|
954
|
+
formattedStr += ` ${options?.appendUnits?.lowercase ? unitStrWithSuffix.toLowerCase() : unitStrWithSuffix}`;
|
|
906
955
|
}
|
|
907
956
|
return formattedStr;
|
|
908
957
|
}
|
|
@@ -1127,6 +1176,9 @@ var isType = (typename) => (node) => {
|
|
|
1127
1176
|
function notNullUndefined(value) {
|
|
1128
1177
|
return value !== null && value !== void 0;
|
|
1129
1178
|
}
|
|
1179
|
+
function isRecord(value) {
|
|
1180
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1181
|
+
}
|
|
1130
1182
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1131
1183
|
0 && (module.exports = {
|
|
1132
1184
|
CurrencyUnit,
|
|
@@ -1162,10 +1214,12 @@ function notNullUndefined(value) {
|
|
|
1162
1214
|
isNode,
|
|
1163
1215
|
isNumber,
|
|
1164
1216
|
isObject,
|
|
1217
|
+
isRecord,
|
|
1165
1218
|
isSDKCurrencyAmount,
|
|
1166
1219
|
isTest,
|
|
1167
1220
|
isType,
|
|
1168
1221
|
isUint8Array,
|
|
1222
|
+
isUmaCurrencyAmount,
|
|
1169
1223
|
linearInterpolate,
|
|
1170
1224
|
localeToCurrencyCode,
|
|
1171
1225
|
localeToCurrencySymbol,
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AppendUnitsOptions,
|
|
1
|
+
export { A as AppendUnitsOptions, aa as ById, al as Complete, 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';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as AppendUnitsOptions,
|
|
1
|
+
export { A as AppendUnitsOptions, aa as ById, al as Complete, 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';
|
package/dist/utils/index.js
CHANGED
|
@@ -32,10 +32,12 @@ import {
|
|
|
32
32
|
isNode,
|
|
33
33
|
isNumber,
|
|
34
34
|
isObject,
|
|
35
|
+
isRecord,
|
|
35
36
|
isSDKCurrencyAmount,
|
|
36
37
|
isTest,
|
|
37
38
|
isType,
|
|
38
39
|
isUint8Array,
|
|
40
|
+
isUmaCurrencyAmount,
|
|
39
41
|
linearInterpolate,
|
|
40
42
|
localeToCurrencyCode,
|
|
41
43
|
localeToCurrencySymbol,
|
|
@@ -48,7 +50,7 @@ import {
|
|
|
48
50
|
setLocalStorageBoolean,
|
|
49
51
|
sleep,
|
|
50
52
|
urlsafe_b64decode
|
|
51
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-23SS5EX2.js";
|
|
52
54
|
export {
|
|
53
55
|
CurrencyUnit,
|
|
54
56
|
abbrCurrencyUnit,
|
|
@@ -83,10 +85,12 @@ export {
|
|
|
83
85
|
isNode,
|
|
84
86
|
isNumber,
|
|
85
87
|
isObject,
|
|
88
|
+
isRecord,
|
|
86
89
|
isSDKCurrencyAmount,
|
|
87
90
|
isTest,
|
|
88
91
|
isType,
|
|
89
92
|
isUint8Array,
|
|
93
|
+
isUmaCurrencyAmount,
|
|
90
94
|
linearInterpolate,
|
|
91
95
|
localeToCurrencyCode,
|
|
92
96
|
localeToCurrencySymbol,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -13,38 +13,23 @@
|
|
|
13
13
|
"homepage": "https://github.com/lightsparkdev/js-sdk",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/lightsparkdev/js-sdk.git"
|
|
16
|
+
"url": "git+https://github.com/lightsparkdev/js-sdk.git"
|
|
17
17
|
},
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/lightsparkdev/js-sdk/issues"
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
22
|
-
"main": "./dist/index.
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
23
|
"module": "./dist/index.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
30
|
-
"default": "./dist/index.js"
|
|
31
|
-
},
|
|
32
|
-
"require": {
|
|
33
|
-
"types": "./dist/index.d.ts",
|
|
34
|
-
"default": "./dist/index.cjs"
|
|
35
|
-
}
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
36
29
|
},
|
|
37
30
|
"./utils": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"types": "./dist/utils/index.d.ts",
|
|
41
|
-
"default": "./dist/utils/index.js"
|
|
42
|
-
},
|
|
43
|
-
"module": "./dist/utils/index.js",
|
|
44
|
-
"require": {
|
|
45
|
-
"types": "./dist/utils/index.d.ts",
|
|
46
|
-
"default": "./dist/utils/index.cjs"
|
|
47
|
-
}
|
|
31
|
+
"import": "./dist/utils/index.js",
|
|
32
|
+
"require": "./dist/utils/index.cjs"
|
|
48
33
|
}
|
|
49
34
|
},
|
|
50
35
|
"browser": {
|
|
@@ -53,6 +38,7 @@
|
|
|
53
38
|
"files": [
|
|
54
39
|
"src/*",
|
|
55
40
|
"dist/*",
|
|
41
|
+
"dist/utils/*",
|
|
56
42
|
"CHANGELOG.md"
|
|
57
43
|
],
|
|
58
44
|
"scripts": {
|
|
@@ -65,6 +51,7 @@
|
|
|
65
51
|
"lint:fix": "eslint --fix .",
|
|
66
52
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
67
53
|
"lint": "eslint .",
|
|
54
|
+
"package:checks": "yarn publint && yarn attw --pack .",
|
|
68
55
|
"postversion": "yarn build",
|
|
69
56
|
"test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail src/**/tests/**/*.test.ts",
|
|
70
57
|
"types:watch": "tsc-absolute --watch",
|
|
@@ -81,6 +68,7 @@
|
|
|
81
68
|
"zen-observable-ts": "^1.1.0"
|
|
82
69
|
},
|
|
83
70
|
"devDependencies": {
|
|
71
|
+
"@arethetypeswrong/cli": "^0.17.4",
|
|
84
72
|
"@lightsparkdev/eslint-config": "*",
|
|
85
73
|
"@lightsparkdev/tsconfig": "0.0.1",
|
|
86
74
|
"@types/crypto-js": "^4.1.1",
|
|
@@ -95,6 +83,7 @@
|
|
|
95
83
|
"lodash-es": "^4.17.21",
|
|
96
84
|
"prettier": "3.0.3",
|
|
97
85
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
86
|
+
"publint": "^0.3.9",
|
|
98
87
|
"ts-jest": "^29.1.1",
|
|
99
88
|
"tsc-absolute": "^1.0.1",
|
|
100
89
|
"tsup": "^8.2.4",
|
|
@@ -208,9 +208,22 @@ class Requester {
|
|
|
208
208
|
};
|
|
209
209
|
const data = responseJson.data;
|
|
210
210
|
if (!data) {
|
|
211
|
+
let firstErrorName: string | undefined = undefined;
|
|
212
|
+
if (
|
|
213
|
+
Array.isArray(responseJson.errors) &&
|
|
214
|
+
responseJson.errors.length > 0
|
|
215
|
+
) {
|
|
216
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
217
|
+
const firstError = responseJson.errors[0];
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
219
|
+
firstErrorName = firstError["extensions"]?.["error_name"] as
|
|
220
|
+
| string
|
|
221
|
+
| undefined;
|
|
222
|
+
}
|
|
211
223
|
throw new LightsparkException(
|
|
212
224
|
"RequestFailed",
|
|
213
225
|
`Request ${operation} failed. ${JSON.stringify(responseJson.errors)}`,
|
|
226
|
+
{ errorName: firstErrorName },
|
|
214
227
|
);
|
|
215
228
|
}
|
|
216
229
|
return data;
|