@lightsparkdev/core 1.2.2 → 1.2.3
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 +6 -0
- package/dist/{chunk-22DUJXVY.js → chunk-ZU7NVHMW.js} +15 -1
- package/dist/{index-DdZ7x9Ef.d.cts → index-DWJjMhfr.d.cts} +15 -3
- package/dist/{index-DdZ7x9Ef.d.ts → index-DWJjMhfr.d.ts} +15 -3
- package/dist/index.cjs +17 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/utils/index.cjs +17 -1
- 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 +1 -1
- package/src/utils/currency.ts +50 -2
package/CHANGELOG.md
CHANGED
|
@@ -526,9 +526,15 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
526
526
|
preferredCurrencyValueRounded: value
|
|
527
527
|
};
|
|
528
528
|
};
|
|
529
|
-
function
|
|
529
|
+
function isDeprecatedCurrencyAmountObj(arg) {
|
|
530
530
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
531
531
|
}
|
|
532
|
+
function isCurrencyAmountObj(arg) {
|
|
533
|
+
return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
|
|
534
|
+
}
|
|
535
|
+
function isCurrencyAmountPreferenceObj(arg) {
|
|
536
|
+
return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "preferred_currency_value_rounded" in arg;
|
|
537
|
+
}
|
|
532
538
|
function isSDKCurrencyAmount(arg) {
|
|
533
539
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
534
540
|
"originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
|
|
@@ -545,7 +551,13 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
545
551
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
546
552
|
value = currencyAmountArg.originalValue;
|
|
547
553
|
unit = currencyAmountArg.originalUnit;
|
|
554
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
555
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
556
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
548
557
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
558
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
559
|
+
unit = currencyAmountArg.original_unit;
|
|
560
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
549
561
|
value = asNumber(currencyAmountArg.value);
|
|
550
562
|
unit = currencyAmountArg.unit;
|
|
551
563
|
}
|
|
@@ -965,7 +977,9 @@ export {
|
|
|
965
977
|
CurrencyUnit,
|
|
966
978
|
convertCurrencyAmountValue,
|
|
967
979
|
convertCurrencyAmount,
|
|
980
|
+
isDeprecatedCurrencyAmountObj,
|
|
968
981
|
isCurrencyAmountObj,
|
|
982
|
+
isCurrencyAmountPreferenceObj,
|
|
969
983
|
isSDKCurrencyAmount,
|
|
970
984
|
mapCurrencyAmount,
|
|
971
985
|
isCurrencyMap,
|
|
@@ -73,13 +73,25 @@ type CurrencyMap = {
|
|
|
73
73
|
isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
74
74
|
type: "CurrencyMap";
|
|
75
75
|
};
|
|
76
|
-
type
|
|
76
|
+
type DeprecatedCurrencyAmountObj = {
|
|
77
77
|
value?: number | string | null;
|
|
78
78
|
unit?: CurrencyUnitType;
|
|
79
79
|
__typename?: "CurrencyAmount" | undefined;
|
|
80
80
|
};
|
|
81
|
-
type
|
|
81
|
+
type CurrencyAmountObj = {
|
|
82
|
+
original_value?: number | string | null;
|
|
83
|
+
original_unit?: CurrencyUnitType;
|
|
84
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
85
|
+
};
|
|
86
|
+
type CurrencyAmountPreferenceObj = {
|
|
87
|
+
preferred_currency_unit?: CurrencyUnitType;
|
|
88
|
+
preferred_currency_value_rounded?: number | string | null;
|
|
89
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
90
|
+
};
|
|
91
|
+
type CurrencyAmountArg = DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
|
|
92
|
+
declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
|
|
82
93
|
declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
|
|
94
|
+
declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
|
|
83
95
|
declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
|
|
84
96
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
|
|
85
97
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
@@ -241,4 +253,4 @@ declare function lsidToUUID(lsid: string): string;
|
|
|
241
253
|
declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
242
254
|
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
243
255
|
|
|
244
|
-
export {
|
|
256
|
+
export { isUint8Array as $, isTest as A, isError as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isErrorWithMessage as E, getErrorMsg as F, isErrorMsg as G, errorToJSON as H, bytesToHex as I, hexToBytes as J, getCurrentLocale as K, countryCodesToCurrencyCodes as L, type CurrencyLocales as M, type CurrencyCodes as N, localeToCurrencyCode as O, getLocalStorageConfigItem as P, getLocalStorageBoolean as Q, setLocalStorageBoolean as R, type SDKCurrencyAmountType as S, deleteLocalStorageItem as T, clamp as U, linearInterpolate as V, round as W, isNumber as X, pollUntil as Y, sleep as Z, lsidToUUID as _, b64encode as a, isObject as a0, type Maybe as a1, type ExpandRecursively as a2, type ById as a3, type OmitTypename as a4, isType as a5, type DeepPartial as a6, type JSONLiteral as a7, type JSONType as a8, type JSONObject as a9, type NN as aa, notNullUndefined as ab, type PartialBy as ac, type Complete as ad, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountPreferenceObj as l, type CurrencyAmountArg as m, isDeprecatedCurrencyAmountObj as n, isCurrencyAmountObj as o, isCurrencyAmountPreferenceObj as p, isSDKCurrencyAmount as q, mapCurrencyAmount as r, isCurrencyMap as s, abbrCurrencyUnit as t, urlsafe_b64decode as u, formatCurrencyStr as v, separateCurrencyStrParts as w, localeToCurrencySymbol as x, isBrowser as y, isNode as z };
|
|
@@ -73,13 +73,25 @@ type CurrencyMap = {
|
|
|
73
73
|
isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
74
74
|
type: "CurrencyMap";
|
|
75
75
|
};
|
|
76
|
-
type
|
|
76
|
+
type DeprecatedCurrencyAmountObj = {
|
|
77
77
|
value?: number | string | null;
|
|
78
78
|
unit?: CurrencyUnitType;
|
|
79
79
|
__typename?: "CurrencyAmount" | undefined;
|
|
80
80
|
};
|
|
81
|
-
type
|
|
81
|
+
type CurrencyAmountObj = {
|
|
82
|
+
original_value?: number | string | null;
|
|
83
|
+
original_unit?: CurrencyUnitType;
|
|
84
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
85
|
+
};
|
|
86
|
+
type CurrencyAmountPreferenceObj = {
|
|
87
|
+
preferred_currency_unit?: CurrencyUnitType;
|
|
88
|
+
preferred_currency_value_rounded?: number | string | null;
|
|
89
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
90
|
+
};
|
|
91
|
+
type CurrencyAmountArg = DeprecatedCurrencyAmountObj | CurrencyAmountObj | CurrencyAmountPreferenceObj | SDKCurrencyAmountType | undefined | null;
|
|
92
|
+
declare function isDeprecatedCurrencyAmountObj(arg: unknown): arg is DeprecatedCurrencyAmountObj;
|
|
82
93
|
declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
|
|
94
|
+
declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
|
|
83
95
|
declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
|
|
84
96
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
|
|
85
97
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
@@ -241,4 +253,4 @@ declare function lsidToUUID(lsid: string): string;
|
|
|
241
253
|
declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
242
254
|
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
243
255
|
|
|
244
|
-
export {
|
|
256
|
+
export { isUint8Array as $, isTest as A, isError as B, ConfigKeys as C, type DeprecatedCurrencyAmountObj as D, isErrorWithMessage as E, getErrorMsg as F, isErrorMsg as G, errorToJSON as H, bytesToHex as I, hexToBytes as J, getCurrentLocale as K, countryCodesToCurrencyCodes as L, type CurrencyLocales as M, type CurrencyCodes as N, localeToCurrencyCode as O, getLocalStorageConfigItem as P, getLocalStorageBoolean as Q, setLocalStorageBoolean as R, type SDKCurrencyAmountType as S, deleteLocalStorageItem as T, clamp as U, linearInterpolate as V, round as W, isNumber as X, pollUntil as Y, sleep as Z, lsidToUUID as _, b64encode as a, isObject as a0, type Maybe as a1, type ExpandRecursively as a2, type ById as a3, type OmitTypename as a4, isType as a5, type DeepPartial as a6, type JSONLiteral as a7, type JSONType as a8, type JSONObject as a9, type NN as aa, notNullUndefined as ab, type PartialBy as ac, type Complete as ad, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, ensureArray as e, CurrencyUnit as f, type CurrencyUnitType as g, convertCurrencyAmountValue as h, convertCurrencyAmount as i, type CurrencyMap as j, type CurrencyAmountObj as k, type CurrencyAmountPreferenceObj as l, type CurrencyAmountArg as m, isDeprecatedCurrencyAmountObj as n, isCurrencyAmountObj as o, isCurrencyAmountPreferenceObj as p, isSDKCurrencyAmount as q, mapCurrencyAmount as r, isCurrencyMap as s, abbrCurrencyUnit as t, urlsafe_b64decode as u, formatCurrencyStr as v, separateCurrencyStrParts as w, localeToCurrencySymbol as x, isBrowser as y, isNode as z };
|
package/dist/index.cjs
CHANGED
|
@@ -69,7 +69,9 @@ __export(src_exports, {
|
|
|
69
69
|
hexToBytes: () => hexToBytes,
|
|
70
70
|
isBrowser: () => isBrowser,
|
|
71
71
|
isCurrencyAmountObj: () => isCurrencyAmountObj,
|
|
72
|
+
isCurrencyAmountPreferenceObj: () => isCurrencyAmountPreferenceObj,
|
|
72
73
|
isCurrencyMap: () => isCurrencyMap,
|
|
74
|
+
isDeprecatedCurrencyAmountObj: () => isDeprecatedCurrencyAmountObj,
|
|
73
75
|
isError: () => isError,
|
|
74
76
|
isErrorMsg: () => isErrorMsg,
|
|
75
77
|
isErrorWithMessage: () => isErrorWithMessage,
|
|
@@ -911,9 +913,15 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
911
913
|
preferredCurrencyValueRounded: value
|
|
912
914
|
};
|
|
913
915
|
};
|
|
914
|
-
function
|
|
916
|
+
function isDeprecatedCurrencyAmountObj(arg) {
|
|
915
917
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
916
918
|
}
|
|
919
|
+
function isCurrencyAmountObj(arg) {
|
|
920
|
+
return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
|
|
921
|
+
}
|
|
922
|
+
function isCurrencyAmountPreferenceObj(arg) {
|
|
923
|
+
return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "preferred_currency_value_rounded" in arg;
|
|
924
|
+
}
|
|
917
925
|
function isSDKCurrencyAmount(arg) {
|
|
918
926
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
919
927
|
"originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
|
|
@@ -930,7 +938,13 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
930
938
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
931
939
|
value = currencyAmountArg.originalValue;
|
|
932
940
|
unit = currencyAmountArg.originalUnit;
|
|
941
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
942
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
943
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
933
944
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
945
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
946
|
+
unit = currencyAmountArg.original_unit;
|
|
947
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
934
948
|
value = asNumber(currencyAmountArg.value);
|
|
935
949
|
unit = currencyAmountArg.unit;
|
|
936
950
|
}
|
|
@@ -1748,7 +1762,9 @@ var ServerEnvironment_default = ServerEnvironment;
|
|
|
1748
1762
|
hexToBytes,
|
|
1749
1763
|
isBrowser,
|
|
1750
1764
|
isCurrencyAmountObj,
|
|
1765
|
+
isCurrencyAmountPreferenceObj,
|
|
1751
1766
|
isCurrencyMap,
|
|
1767
|
+
isDeprecatedCurrencyAmountObj,
|
|
1752
1768
|
isError,
|
|
1753
1769
|
isErrorMsg,
|
|
1754
1770
|
isErrorWithMessage,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as ById, ad as Complete, C as ConfigKeys, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from './index-DWJjMhfr.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 {
|
|
1
|
+
export { a3 as ById, ad as Complete, C as ConfigKeys, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from './index-DWJjMhfr.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
type Headers = Record<string, string>;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ import {
|
|
|
22
22
|
hexToBytes,
|
|
23
23
|
isBrowser,
|
|
24
24
|
isCurrencyAmountObj,
|
|
25
|
+
isCurrencyAmountPreferenceObj,
|
|
25
26
|
isCurrencyMap,
|
|
27
|
+
isDeprecatedCurrencyAmountObj,
|
|
26
28
|
isError,
|
|
27
29
|
isErrorMsg,
|
|
28
30
|
isErrorWithMessage,
|
|
@@ -45,7 +47,7 @@ import {
|
|
|
45
47
|
setLocalStorageBoolean,
|
|
46
48
|
sleep,
|
|
47
49
|
urlsafe_b64decode
|
|
48
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-ZU7NVHMW.js";
|
|
49
51
|
|
|
50
52
|
// src/auth/LightsparkAuthException.ts
|
|
51
53
|
var LightsparkAuthException = class extends LightsparkException_default {
|
|
@@ -752,7 +754,9 @@ export {
|
|
|
752
754
|
hexToBytes,
|
|
753
755
|
isBrowser,
|
|
754
756
|
isCurrencyAmountObj,
|
|
757
|
+
isCurrencyAmountPreferenceObj,
|
|
755
758
|
isCurrencyMap,
|
|
759
|
+
isDeprecatedCurrencyAmountObj,
|
|
756
760
|
isError,
|
|
757
761
|
isErrorMsg,
|
|
758
762
|
isErrorWithMessage,
|
package/dist/utils/index.cjs
CHANGED
|
@@ -52,7 +52,9 @@ __export(utils_exports, {
|
|
|
52
52
|
hexToBytes: () => hexToBytes,
|
|
53
53
|
isBrowser: () => isBrowser,
|
|
54
54
|
isCurrencyAmountObj: () => isCurrencyAmountObj,
|
|
55
|
+
isCurrencyAmountPreferenceObj: () => isCurrencyAmountPreferenceObj,
|
|
55
56
|
isCurrencyMap: () => isCurrencyMap,
|
|
57
|
+
isDeprecatedCurrencyAmountObj: () => isDeprecatedCurrencyAmountObj,
|
|
56
58
|
isError: () => isError,
|
|
57
59
|
isErrorMsg: () => isErrorMsg,
|
|
58
60
|
isErrorWithMessage: () => isErrorWithMessage,
|
|
@@ -606,9 +608,15 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
606
608
|
preferredCurrencyValueRounded: value
|
|
607
609
|
};
|
|
608
610
|
};
|
|
609
|
-
function
|
|
611
|
+
function isDeprecatedCurrencyAmountObj(arg) {
|
|
610
612
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
611
613
|
}
|
|
614
|
+
function isCurrencyAmountObj(arg) {
|
|
615
|
+
return typeof arg === "object" && arg !== null && "original_value" in arg && "original_unit" in arg;
|
|
616
|
+
}
|
|
617
|
+
function isCurrencyAmountPreferenceObj(arg) {
|
|
618
|
+
return typeof arg === "object" && arg !== null && "preferred_currency_unit" in arg && "preferred_currency_value_rounded" in arg;
|
|
619
|
+
}
|
|
612
620
|
function isSDKCurrencyAmount(arg) {
|
|
613
621
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
614
622
|
"originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
|
|
@@ -625,7 +633,13 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
625
633
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
626
634
|
value = currencyAmountArg.originalValue;
|
|
627
635
|
unit = currencyAmountArg.originalUnit;
|
|
636
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
637
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
638
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
628
639
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
640
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
641
|
+
unit = currencyAmountArg.original_unit;
|
|
642
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
629
643
|
value = asNumber(currencyAmountArg.value);
|
|
630
644
|
unit = currencyAmountArg.unit;
|
|
631
645
|
}
|
|
@@ -1045,7 +1059,9 @@ function notNullUndefined(value) {
|
|
|
1045
1059
|
hexToBytes,
|
|
1046
1060
|
isBrowser,
|
|
1047
1061
|
isCurrencyAmountObj,
|
|
1062
|
+
isCurrencyAmountPreferenceObj,
|
|
1048
1063
|
isCurrencyMap,
|
|
1064
|
+
isDeprecatedCurrencyAmountObj,
|
|
1049
1065
|
isError,
|
|
1050
1066
|
isErrorMsg,
|
|
1051
1067
|
isErrorWithMessage,
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as ById, ad as Complete, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from '../index-DWJjMhfr.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a3 as ById, ad as Complete, m as CurrencyAmountArg, k as CurrencyAmountObj, l as CurrencyAmountPreferenceObj, N as CurrencyCodes, M as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, a6 as DeepPartial, D as DeprecatedCurrencyAmountObj, a2 as ExpandRecursively, a7 as JSONLiteral, a9 as JSONObject, a8 as JSONType, a1 as Maybe, aa as NN, a4 as OmitTypename, ac as PartialBy, S as SDKCurrencyAmountType, t as abbrCurrencyUnit, b as b64decode, a as b64encode, I as bytesToHex, U as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, L as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, T as deleteLocalStorageItem, e as ensureArray, H as errorToJSON, v as formatCurrencyStr, K as getCurrentLocale, F as getErrorMsg, Q as getLocalStorageBoolean, P as getLocalStorageConfigItem, J as hexToBytes, y as isBrowser, o as isCurrencyAmountObj, p as isCurrencyAmountPreferenceObj, s as isCurrencyMap, n as isDeprecatedCurrencyAmountObj, B as isError, G as isErrorMsg, E as isErrorWithMessage, z as isNode, X as isNumber, a0 as isObject, q as isSDKCurrencyAmount, A as isTest, a5 as isType, $ as isUint8Array, V as linearInterpolate, O as localeToCurrencyCode, x as localeToCurrencySymbol, _ as lsidToUUID, r as mapCurrencyAmount, ab as notNullUndefined, Y as pollUntil, W as round, w as separateCurrencyStrParts, R as setLocalStorageBoolean, Z as sleep, u as urlsafe_b64decode } from '../index-DWJjMhfr.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -21,7 +21,9 @@ import {
|
|
|
21
21
|
hexToBytes,
|
|
22
22
|
isBrowser,
|
|
23
23
|
isCurrencyAmountObj,
|
|
24
|
+
isCurrencyAmountPreferenceObj,
|
|
24
25
|
isCurrencyMap,
|
|
26
|
+
isDeprecatedCurrencyAmountObj,
|
|
25
27
|
isError,
|
|
26
28
|
isErrorMsg,
|
|
27
29
|
isErrorWithMessage,
|
|
@@ -44,7 +46,7 @@ import {
|
|
|
44
46
|
setLocalStorageBoolean,
|
|
45
47
|
sleep,
|
|
46
48
|
urlsafe_b64decode
|
|
47
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-ZU7NVHMW.js";
|
|
48
50
|
export {
|
|
49
51
|
CurrencyUnit,
|
|
50
52
|
abbrCurrencyUnit,
|
|
@@ -68,7 +70,9 @@ export {
|
|
|
68
70
|
hexToBytes,
|
|
69
71
|
isBrowser,
|
|
70
72
|
isCurrencyAmountObj,
|
|
73
|
+
isCurrencyAmountPreferenceObj,
|
|
71
74
|
isCurrencyMap,
|
|
75
|
+
isDeprecatedCurrencyAmountObj,
|
|
72
76
|
isError,
|
|
73
77
|
isErrorMsg,
|
|
74
78
|
isErrorWithMessage,
|
package/package.json
CHANGED
package/src/utils/currency.ts
CHANGED
|
@@ -199,7 +199,7 @@ export type CurrencyMap = {
|
|
|
199
199
|
type: "CurrencyMap";
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
-
export type
|
|
202
|
+
export type DeprecatedCurrencyAmountObj = {
|
|
203
203
|
/* Technically the generated graphql schema has value as `any` but it's always a number.
|
|
204
204
|
* We are intentionally widening the type here to allow for more forgiving input: */
|
|
205
205
|
value?: number | string | null;
|
|
@@ -208,18 +208,60 @@ export type CurrencyAmountObj = {
|
|
|
208
208
|
__typename?: "CurrencyAmount" | undefined;
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
+
export type CurrencyAmountObj = {
|
|
212
|
+
/* Technically the generated graphql schema has value as `any` but it's always a number.
|
|
213
|
+
* We are intentionally widening the type here to allow for more forgiving input: */
|
|
214
|
+
original_value?: number | string | null;
|
|
215
|
+
/* assume satoshi if not provided */
|
|
216
|
+
original_unit?: CurrencyUnitType;
|
|
217
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export type CurrencyAmountPreferenceObj = {
|
|
221
|
+
/* Technically the generated graphql schema has value as `any` but it's always a number.
|
|
222
|
+
* We are intentionally widening the type here to allow for more forgiving input: */
|
|
223
|
+
preferred_currency_unit?: CurrencyUnitType;
|
|
224
|
+
/* assume satoshi if not provided */
|
|
225
|
+
preferred_currency_value_rounded?: number | string | null;
|
|
226
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
227
|
+
};
|
|
228
|
+
|
|
211
229
|
export type CurrencyAmountArg =
|
|
230
|
+
| DeprecatedCurrencyAmountObj
|
|
212
231
|
| CurrencyAmountObj
|
|
232
|
+
| CurrencyAmountPreferenceObj
|
|
213
233
|
| SDKCurrencyAmountType
|
|
214
234
|
| undefined
|
|
215
235
|
| null;
|
|
216
236
|
|
|
217
|
-
export function
|
|
237
|
+
export function isDeprecatedCurrencyAmountObj(
|
|
238
|
+
arg: unknown,
|
|
239
|
+
): arg is DeprecatedCurrencyAmountObj {
|
|
218
240
|
return (
|
|
219
241
|
typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg
|
|
220
242
|
);
|
|
221
243
|
}
|
|
222
244
|
|
|
245
|
+
export function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj {
|
|
246
|
+
return (
|
|
247
|
+
typeof arg === "object" &&
|
|
248
|
+
arg !== null &&
|
|
249
|
+
"original_value" in arg &&
|
|
250
|
+
"original_unit" in arg
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function isCurrencyAmountPreferenceObj(
|
|
255
|
+
arg: unknown,
|
|
256
|
+
): arg is CurrencyAmountPreferenceObj {
|
|
257
|
+
return (
|
|
258
|
+
typeof arg === "object" &&
|
|
259
|
+
arg !== null &&
|
|
260
|
+
"preferred_currency_unit" in arg &&
|
|
261
|
+
"preferred_currency_value_rounded" in arg
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
223
265
|
export function isSDKCurrencyAmount(
|
|
224
266
|
arg: unknown,
|
|
225
267
|
): arg is SDKCurrencyAmountType {
|
|
@@ -248,7 +290,13 @@ function getCurrencyAmount(currencyAmountArg: CurrencyAmountArg) {
|
|
|
248
290
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
249
291
|
value = currencyAmountArg.originalValue;
|
|
250
292
|
unit = currencyAmountArg.originalUnit;
|
|
293
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
294
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
295
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
251
296
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
297
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
298
|
+
unit = currencyAmountArg.original_unit;
|
|
299
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
252
300
|
value = asNumber(currencyAmountArg.value);
|
|
253
301
|
unit = currencyAmountArg.unit;
|
|
254
302
|
}
|