@lightsparkdev/core 1.2.1 → 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 +14 -0
- package/dist/{chunk-YRWJVCZI.js → chunk-ZU7NVHMW.js} +25 -5
- package/dist/{index-b1e5d968.d.ts → index-DWJjMhfr.d.cts} +23 -9
- package/dist/index-DWJjMhfr.d.ts +256 -0
- package/dist/index.cjs +156 -119
- package/dist/index.d.cts +47 -45
- package/dist/index.d.ts +47 -45
- package/dist/index.js +124 -105
- package/dist/utils/index.cjs +25 -2
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +7 -1
- package/package.json +5 -6
- package/src/Logger.ts +5 -0
- package/src/crypto/crypto.ts +2 -1
- package/src/crypto/index.ts +1 -1
- package/src/index.ts +5 -5
- package/src/requester/Requester.ts +9 -1
- package/src/utils/arrays.ts +3 -0
- package/src/utils/currency.ts +50 -2
- package/src/utils/errors.ts +1 -3
- package/src/utils/index.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @lightsparkdev/core
|
|
2
2
|
|
|
3
|
+
## 1.2.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d61a209: - Changes to internal use of currency utils
|
|
8
|
+
|
|
9
|
+
## 1.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 07900ac: - Upgrade deps
|
|
14
|
+
- Upgrade TypeScript to 5.6.2 and some related type fixes
|
|
15
|
+
- Improve clean scripts
|
|
16
|
+
|
|
3
17
|
## 1.2.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// src/utils/arrays.ts
|
|
2
|
+
function ensureArray(value) {
|
|
3
|
+
return Array.isArray(value) ? value : [value];
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// src/utils/base64.ts
|
|
2
7
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
3
8
|
var Base64 = {
|
|
@@ -521,9 +526,15 @@ var convertCurrencyAmount = (from, toUnit) => {
|
|
|
521
526
|
preferredCurrencyValueRounded: value
|
|
522
527
|
};
|
|
523
528
|
};
|
|
524
|
-
function
|
|
529
|
+
function isDeprecatedCurrencyAmountObj(arg) {
|
|
525
530
|
return typeof arg === "object" && arg !== null && "value" in arg && "unit" in arg;
|
|
526
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
|
+
}
|
|
527
538
|
function isSDKCurrencyAmount(arg) {
|
|
528
539
|
return typeof arg === "object" && arg !== null && /* We can expect all SDK CurrencyAmount types to always have these exact properties: */
|
|
529
540
|
"originalValue" in arg && "originalUnit" in arg && "preferredCurrencyUnit" in arg && "preferredCurrencyValueRounded" in arg && "preferredCurrencyValueApprox" in arg;
|
|
@@ -540,7 +551,13 @@ function getCurrencyAmount(currencyAmountArg) {
|
|
|
540
551
|
if (isSDKCurrencyAmount(currencyAmountArg)) {
|
|
541
552
|
value = currencyAmountArg.originalValue;
|
|
542
553
|
unit = currencyAmountArg.originalUnit;
|
|
554
|
+
} else if (isCurrencyAmountPreferenceObj(currencyAmountArg)) {
|
|
555
|
+
value = asNumber(currencyAmountArg.preferred_currency_value_rounded);
|
|
556
|
+
unit = currencyAmountArg.preferred_currency_unit;
|
|
543
557
|
} else if (isCurrencyAmountObj(currencyAmountArg)) {
|
|
558
|
+
value = asNumber(currencyAmountArg.original_value);
|
|
559
|
+
unit = currencyAmountArg.original_unit;
|
|
560
|
+
} else if (isDeprecatedCurrencyAmountObj(currencyAmountArg)) {
|
|
544
561
|
value = asNumber(currencyAmountArg.value);
|
|
545
562
|
unit = currencyAmountArg.unit;
|
|
546
563
|
}
|
|
@@ -737,7 +754,7 @@ function localeToCurrencySymbol(locale) {
|
|
|
737
754
|
// src/utils/errors.ts
|
|
738
755
|
var isError = (e) => {
|
|
739
756
|
return Boolean(
|
|
740
|
-
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
757
|
+
typeof e === "object" && e !== null && "name" in e && typeof e.name === "string" && "message" in e && typeof e.message === "string"
|
|
741
758
|
);
|
|
742
759
|
};
|
|
743
760
|
var isErrorWithMessage = (e) => {
|
|
@@ -939,12 +956,13 @@ function notNullUndefined(value) {
|
|
|
939
956
|
|
|
940
957
|
export {
|
|
941
958
|
LightsparkException_default,
|
|
942
|
-
isBrowser,
|
|
943
|
-
isNode,
|
|
944
|
-
isTest,
|
|
945
959
|
b64decode,
|
|
946
960
|
urlsafe_b64decode,
|
|
947
961
|
b64encode,
|
|
962
|
+
ensureArray,
|
|
963
|
+
isBrowser,
|
|
964
|
+
isNode,
|
|
965
|
+
isTest,
|
|
948
966
|
bytesToHex,
|
|
949
967
|
hexToBytes,
|
|
950
968
|
createSha256Hash,
|
|
@@ -959,7 +977,9 @@ export {
|
|
|
959
977
|
CurrencyUnit,
|
|
960
978
|
convertCurrencyAmountValue,
|
|
961
979
|
convertCurrencyAmount,
|
|
980
|
+
isDeprecatedCurrencyAmountObj,
|
|
962
981
|
isCurrencyAmountObj,
|
|
982
|
+
isCurrencyAmountPreferenceObj,
|
|
963
983
|
isSDKCurrencyAmount,
|
|
964
984
|
mapCurrencyAmount,
|
|
965
985
|
isCurrencyMap,
|
|
@@ -4,6 +4,8 @@ declare const ConfigKeys: {
|
|
|
4
4
|
};
|
|
5
5
|
type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
6
6
|
|
|
7
|
+
declare function ensureArray<T>(value: T | T[]): T[];
|
|
8
|
+
|
|
7
9
|
declare const b64decode: (encoded: string) => Uint8Array;
|
|
8
10
|
declare const urlsafe_b64decode: (encoded: string) => Uint8Array;
|
|
9
11
|
declare const b64encode: (data: ArrayBuffer) => string;
|
|
@@ -71,13 +73,25 @@ type CurrencyMap = {
|
|
|
71
73
|
isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
72
74
|
type: "CurrencyMap";
|
|
73
75
|
};
|
|
74
|
-
type
|
|
76
|
+
type DeprecatedCurrencyAmountObj = {
|
|
75
77
|
value?: number | string | null;
|
|
76
78
|
unit?: CurrencyUnitType;
|
|
77
79
|
__typename?: "CurrencyAmount" | undefined;
|
|
78
80
|
};
|
|
79
|
-
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;
|
|
80
93
|
declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
|
|
94
|
+
declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
|
|
81
95
|
declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
|
|
82
96
|
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
|
|
83
97
|
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
@@ -108,7 +122,7 @@ type ById<T> = {
|
|
|
108
122
|
type OmitTypename<T> = Omit<T, "__typename">;
|
|
109
123
|
declare const isType: <T extends string>(typename: T) => <N extends {
|
|
110
124
|
__typename: string;
|
|
111
|
-
}>(node: N |
|
|
125
|
+
}>(node: N | undefined | null) => node is Extract<N, {
|
|
112
126
|
__typename: T;
|
|
113
127
|
}>;
|
|
114
128
|
type DeepPartial<T> = T extends object ? {
|
|
@@ -140,11 +154,6 @@ declare function errorToJSON(err: unknown): JSONType;
|
|
|
140
154
|
declare const bytesToHex: (bytes: Uint8Array) => string;
|
|
141
155
|
declare const hexToBytes: (hex: string) => Uint8Array;
|
|
142
156
|
|
|
143
|
-
declare function getLocalStorageConfigItem(key: ConfigKeys): boolean;
|
|
144
|
-
declare function getLocalStorageBoolean(key: string): boolean;
|
|
145
|
-
declare function setLocalStorageBoolean(key: string, value: boolean): void;
|
|
146
|
-
declare const deleteLocalStorageItem: (key: string) => void;
|
|
147
|
-
|
|
148
157
|
declare function getCurrentLocale(): string;
|
|
149
158
|
|
|
150
159
|
declare const countryCodesToCurrencyCodes: {
|
|
@@ -218,6 +227,11 @@ type CurrencyLocales = keyof typeof countryCodesToCurrencyCodes;
|
|
|
218
227
|
type CurrencyCodes = (typeof countryCodesToCurrencyCodes)[CurrencyLocales];
|
|
219
228
|
declare function localeToCurrencyCode(locale: string): CurrencyCodes;
|
|
220
229
|
|
|
230
|
+
declare function getLocalStorageConfigItem(key: ConfigKeys): boolean;
|
|
231
|
+
declare function getLocalStorageBoolean(key: string): boolean;
|
|
232
|
+
declare function setLocalStorageBoolean(key: string, value: boolean): void;
|
|
233
|
+
declare const deleteLocalStorageItem: (key: string) => void;
|
|
234
|
+
|
|
221
235
|
declare function clamp(val: number, min: number, max: number): number;
|
|
222
236
|
declare function linearInterpolate(value: number, fromRangeStart: number, fromRangeEnd: number, toRangeStart: number, toRangeEnd: number): number;
|
|
223
237
|
declare function round(num: number, decimalPlaces?: number): number;
|
|
@@ -239,4 +253,4 @@ declare function lsidToUUID(lsid: string): string;
|
|
|
239
253
|
declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
240
254
|
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
241
255
|
|
|
242
|
-
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 };
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
declare const ConfigKeys: {
|
|
2
|
+
readonly LoggingEnabled: "lightspark-logging-enabled";
|
|
3
|
+
readonly ConsoleToolsEnabled: "lightspark-console-tools-enabled";
|
|
4
|
+
};
|
|
5
|
+
type ConfigKeys = (typeof ConfigKeys)[keyof typeof ConfigKeys];
|
|
6
|
+
|
|
7
|
+
declare function ensureArray<T>(value: T | T[]): T[];
|
|
8
|
+
|
|
9
|
+
declare const b64decode: (encoded: string) => Uint8Array;
|
|
10
|
+
declare const urlsafe_b64decode: (encoded: string) => Uint8Array;
|
|
11
|
+
declare const b64encode: (data: ArrayBuffer) => string;
|
|
12
|
+
|
|
13
|
+
type SourceData = Uint8Array | string;
|
|
14
|
+
declare function createSha256Hash(data: SourceData): Promise<Uint8Array>;
|
|
15
|
+
declare function createSha256Hash(data: SourceData, asHex: true): Promise<string>;
|
|
16
|
+
|
|
17
|
+
declare const defaultCurrencyCode = "USD";
|
|
18
|
+
declare const CurrencyUnit: {
|
|
19
|
+
readonly FUTURE_VALUE: "FUTURE_VALUE";
|
|
20
|
+
readonly BITCOIN: "BITCOIN";
|
|
21
|
+
readonly SATOSHI: "SATOSHI";
|
|
22
|
+
readonly MILLISATOSHI: "MILLISATOSHI";
|
|
23
|
+
readonly USD: "USD";
|
|
24
|
+
readonly NANOBITCOIN: "NANOBITCOIN";
|
|
25
|
+
readonly MICROBITCOIN: "MICROBITCOIN";
|
|
26
|
+
readonly MILLIBITCOIN: "MILLIBITCOIN";
|
|
27
|
+
readonly Bitcoin: "BITCOIN";
|
|
28
|
+
readonly Microbitcoin: "MICROBITCOIN";
|
|
29
|
+
readonly Millibitcoin: "MILLIBITCOIN";
|
|
30
|
+
readonly Millisatoshi: "MILLISATOSHI";
|
|
31
|
+
readonly Nanobitcoin: "NANOBITCOIN";
|
|
32
|
+
readonly Satoshi: "SATOSHI";
|
|
33
|
+
readonly Usd: "USD";
|
|
34
|
+
};
|
|
35
|
+
type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
|
|
36
|
+
type SDKCurrencyAmountType = {
|
|
37
|
+
originalValue: number;
|
|
38
|
+
originalUnit: CurrencyUnitType;
|
|
39
|
+
preferredCurrencyUnit: CurrencyUnitType;
|
|
40
|
+
preferredCurrencyValueRounded: number;
|
|
41
|
+
preferredCurrencyValueApprox: number;
|
|
42
|
+
};
|
|
43
|
+
declare function convertCurrencyAmountValue(fromUnit: CurrencyUnitType, toUnit: CurrencyUnitType, amount: number, centsPerBtc?: number): number;
|
|
44
|
+
declare const convertCurrencyAmount: (from: SDKCurrencyAmountType, toUnit: CurrencyUnitType) => SDKCurrencyAmountType;
|
|
45
|
+
type CurrencyMap = {
|
|
46
|
+
sats: number;
|
|
47
|
+
msats: number;
|
|
48
|
+
btc: number;
|
|
49
|
+
[CurrencyUnit.BITCOIN]: number;
|
|
50
|
+
[CurrencyUnit.SATOSHI]: number;
|
|
51
|
+
[CurrencyUnit.MILLISATOSHI]: number;
|
|
52
|
+
[CurrencyUnit.MICROBITCOIN]: number;
|
|
53
|
+
[CurrencyUnit.MILLIBITCOIN]: number;
|
|
54
|
+
[CurrencyUnit.NANOBITCOIN]: number;
|
|
55
|
+
[CurrencyUnit.USD]: number;
|
|
56
|
+
[CurrencyUnit.FUTURE_VALUE]: number;
|
|
57
|
+
formatted: {
|
|
58
|
+
sats: string;
|
|
59
|
+
msats: string;
|
|
60
|
+
btc: string;
|
|
61
|
+
[CurrencyUnit.BITCOIN]: string;
|
|
62
|
+
[CurrencyUnit.SATOSHI]: string;
|
|
63
|
+
[CurrencyUnit.MILLISATOSHI]: string;
|
|
64
|
+
[CurrencyUnit.MILLIBITCOIN]: string;
|
|
65
|
+
[CurrencyUnit.MICROBITCOIN]: string;
|
|
66
|
+
[CurrencyUnit.NANOBITCOIN]: string;
|
|
67
|
+
[CurrencyUnit.USD]: string;
|
|
68
|
+
[CurrencyUnit.FUTURE_VALUE]: string;
|
|
69
|
+
};
|
|
70
|
+
isZero: boolean;
|
|
71
|
+
isLessThan: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
72
|
+
isGreaterThan: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
73
|
+
isEqualTo: (other: CurrencyMap | CurrencyAmountObj | number) => boolean;
|
|
74
|
+
type: "CurrencyMap";
|
|
75
|
+
};
|
|
76
|
+
type DeprecatedCurrencyAmountObj = {
|
|
77
|
+
value?: number | string | null;
|
|
78
|
+
unit?: CurrencyUnitType;
|
|
79
|
+
__typename?: "CurrencyAmount" | undefined;
|
|
80
|
+
};
|
|
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;
|
|
93
|
+
declare function isCurrencyAmountObj(arg: unknown): arg is CurrencyAmountObj;
|
|
94
|
+
declare function isCurrencyAmountPreferenceObj(arg: unknown): arg is CurrencyAmountPreferenceObj;
|
|
95
|
+
declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType;
|
|
96
|
+
declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
|
|
97
|
+
declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
|
|
98
|
+
declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "BTC" | "SAT" | "MSAT" | "Unsupported CurrencyUnit";
|
|
99
|
+
type FormatCurrencyStrOptions = {
|
|
100
|
+
precision?: number | "full" | undefined;
|
|
101
|
+
compact?: boolean | undefined;
|
|
102
|
+
showBtcSymbol?: boolean | undefined;
|
|
103
|
+
};
|
|
104
|
+
declare function formatCurrencyStr(amount: CurrencyAmountArg, options?: FormatCurrencyStrOptions): string;
|
|
105
|
+
declare function separateCurrencyStrParts(currencyStr: string): {
|
|
106
|
+
symbol: string;
|
|
107
|
+
amount: string;
|
|
108
|
+
};
|
|
109
|
+
declare function localeToCurrencySymbol(locale: string): string;
|
|
110
|
+
|
|
111
|
+
declare const isBrowser: boolean;
|
|
112
|
+
declare const isNode: boolean;
|
|
113
|
+
declare const isTest: boolean;
|
|
114
|
+
|
|
115
|
+
type Maybe<T> = T | null | undefined;
|
|
116
|
+
type ExpandRecursively<T> = T extends object ? T extends infer O ? {
|
|
117
|
+
[K in keyof O]: ExpandRecursively<O[K]>;
|
|
118
|
+
} : never : T;
|
|
119
|
+
type ById<T> = {
|
|
120
|
+
[id: string]: T;
|
|
121
|
+
};
|
|
122
|
+
type OmitTypename<T> = Omit<T, "__typename">;
|
|
123
|
+
declare const isType: <T extends string>(typename: T) => <N extends {
|
|
124
|
+
__typename: string;
|
|
125
|
+
}>(node: N | undefined | null) => node is Extract<N, {
|
|
126
|
+
__typename: T;
|
|
127
|
+
}>;
|
|
128
|
+
type DeepPartial<T> = T extends object ? {
|
|
129
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
130
|
+
} : T;
|
|
131
|
+
type JSONLiteral = string | number | boolean | null;
|
|
132
|
+
type JSONType = JSONLiteral | JSONType[] | {
|
|
133
|
+
[key: string]: JSONType;
|
|
134
|
+
};
|
|
135
|
+
type JSONObject = {
|
|
136
|
+
[key: string]: JSONType;
|
|
137
|
+
};
|
|
138
|
+
type NN<T> = NonNullable<T>;
|
|
139
|
+
declare function notNullUndefined<TValue>(value: TValue | null | undefined): value is TValue;
|
|
140
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
141
|
+
type Complete<T> = {
|
|
142
|
+
[P in keyof T]-?: NonNullable<T[P]>;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
declare const isError: (e: unknown) => e is Error;
|
|
146
|
+
type ErrorWithMessage = {
|
|
147
|
+
message: string;
|
|
148
|
+
};
|
|
149
|
+
declare const isErrorWithMessage: (e: unknown) => e is ErrorWithMessage;
|
|
150
|
+
declare const getErrorMsg: (e: unknown) => string;
|
|
151
|
+
declare const isErrorMsg: (e: unknown, msg: string) => boolean;
|
|
152
|
+
declare function errorToJSON(err: unknown): JSONType;
|
|
153
|
+
|
|
154
|
+
declare const bytesToHex: (bytes: Uint8Array) => string;
|
|
155
|
+
declare const hexToBytes: (hex: string) => Uint8Array;
|
|
156
|
+
|
|
157
|
+
declare function getCurrentLocale(): string;
|
|
158
|
+
|
|
159
|
+
declare const countryCodesToCurrencyCodes: {
|
|
160
|
+
readonly AD: "EUR";
|
|
161
|
+
readonly AR: "ARS";
|
|
162
|
+
readonly AS: "USD";
|
|
163
|
+
readonly AT: "EUR";
|
|
164
|
+
readonly AU: "AUD";
|
|
165
|
+
readonly AX: "EUR";
|
|
166
|
+
readonly BE: "EUR";
|
|
167
|
+
readonly BL: "EUR";
|
|
168
|
+
readonly BQ: "USD";
|
|
169
|
+
readonly BR: "BRL";
|
|
170
|
+
readonly CA: "CAD";
|
|
171
|
+
readonly CO: "COP";
|
|
172
|
+
readonly CY: "EUR";
|
|
173
|
+
readonly DE: "EUR";
|
|
174
|
+
readonly EC: "USD";
|
|
175
|
+
readonly EE: "EUR";
|
|
176
|
+
readonly ES: "EUR";
|
|
177
|
+
readonly FI: "EUR";
|
|
178
|
+
readonly FM: "USD";
|
|
179
|
+
readonly FR: "EUR";
|
|
180
|
+
readonly GB: "GBP";
|
|
181
|
+
readonly GF: "EUR";
|
|
182
|
+
readonly GG: "GBP";
|
|
183
|
+
readonly GP: "EUR";
|
|
184
|
+
readonly GR: "EUR";
|
|
185
|
+
readonly GS: "GBP";
|
|
186
|
+
readonly GU: "USD";
|
|
187
|
+
readonly IE: "EUR";
|
|
188
|
+
readonly IM: "GBP";
|
|
189
|
+
readonly IN: "INR";
|
|
190
|
+
readonly IO: "USD";
|
|
191
|
+
readonly IT: "EUR";
|
|
192
|
+
readonly JE: "GBP";
|
|
193
|
+
readonly LT: "EUR";
|
|
194
|
+
readonly LU: "EUR";
|
|
195
|
+
readonly LV: "EUR";
|
|
196
|
+
readonly MC: "EUR";
|
|
197
|
+
readonly ME: "EUR";
|
|
198
|
+
readonly MF: "EUR";
|
|
199
|
+
readonly MH: "USD";
|
|
200
|
+
readonly MP: "USD";
|
|
201
|
+
readonly MQ: "EUR";
|
|
202
|
+
readonly MT: "EUR";
|
|
203
|
+
readonly MX: "MXN";
|
|
204
|
+
readonly NF: "AUD";
|
|
205
|
+
readonly NL: "EUR";
|
|
206
|
+
readonly NR: "AUD";
|
|
207
|
+
readonly PM: "EUR";
|
|
208
|
+
readonly PR: "USD";
|
|
209
|
+
readonly PT: "EUR";
|
|
210
|
+
readonly PW: "USD";
|
|
211
|
+
readonly RE: "EUR";
|
|
212
|
+
readonly SI: "EUR";
|
|
213
|
+
readonly SK: "EUR";
|
|
214
|
+
readonly SM: "EUR";
|
|
215
|
+
readonly TC: "USD";
|
|
216
|
+
readonly TF: "EUR";
|
|
217
|
+
readonly TL: "USD";
|
|
218
|
+
readonly TV: "AUD";
|
|
219
|
+
readonly UM: "USD";
|
|
220
|
+
readonly US: "USD";
|
|
221
|
+
readonly VA: "EUR";
|
|
222
|
+
readonly VG: "USD";
|
|
223
|
+
readonly VI: "USD";
|
|
224
|
+
readonly YT: "EUR";
|
|
225
|
+
};
|
|
226
|
+
type CurrencyLocales = keyof typeof countryCodesToCurrencyCodes;
|
|
227
|
+
type CurrencyCodes = (typeof countryCodesToCurrencyCodes)[CurrencyLocales];
|
|
228
|
+
declare function localeToCurrencyCode(locale: string): CurrencyCodes;
|
|
229
|
+
|
|
230
|
+
declare function getLocalStorageConfigItem(key: ConfigKeys): boolean;
|
|
231
|
+
declare function getLocalStorageBoolean(key: string): boolean;
|
|
232
|
+
declare function setLocalStorageBoolean(key: string, value: boolean): void;
|
|
233
|
+
declare const deleteLocalStorageItem: (key: string) => void;
|
|
234
|
+
|
|
235
|
+
declare function clamp(val: number, min: number, max: number): number;
|
|
236
|
+
declare function linearInterpolate(value: number, fromRangeStart: number, fromRangeEnd: number, toRangeStart: number, toRangeEnd: number): number;
|
|
237
|
+
declare function round(num: number, decimalPlaces?: number): number;
|
|
238
|
+
declare function isNumber(value: unknown): value is number;
|
|
239
|
+
|
|
240
|
+
type GetValueResult<T> = {
|
|
241
|
+
stopPolling: boolean;
|
|
242
|
+
value: null | T;
|
|
243
|
+
};
|
|
244
|
+
declare function pollUntil<D extends () => Promise<unknown>, T>(asyncFn: D, getValue: (data: Awaited<ReturnType<D>>, response: {
|
|
245
|
+
stopPolling: boolean;
|
|
246
|
+
value: null | T;
|
|
247
|
+
}) => GetValueResult<T>, maxPolls?: number, pollIntervalMs?: number, ignoreErrors?: boolean | ((e: unknown) => boolean), getMaxPollsError?: (maxPolls: number) => Error): Promise<T>;
|
|
248
|
+
|
|
249
|
+
declare function sleep(ms: number): Promise<unknown>;
|
|
250
|
+
|
|
251
|
+
declare function lsidToUUID(lsid: string): string;
|
|
252
|
+
|
|
253
|
+
declare function isUint8Array(value: unknown): value is Uint8Array;
|
|
254
|
+
declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
255
|
+
|
|
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 };
|