@lightsparkdev/core 1.0.22 → 1.1.0

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fda487d: - Move formatCurrencyStr options into an object (#1095)
8
+ - Compress requests with deflate (#10512)
9
+
3
10
  ## 1.0.22
4
11
 
5
12
  ### Patch Changes
@@ -656,15 +656,33 @@ var abbrCurrencyUnit = (unit) => {
656
656
  }
657
657
  return "Unsupported CurrencyUnit";
658
658
  };
659
- function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = false, options = {}) {
659
+ var defaultOptions = {
660
+ /* undefined indicates to use default precision for unit defined below */
661
+ precision: void 0,
662
+ compact: false,
663
+ showBtcSymbol: false
664
+ };
665
+ function formatCurrencyStr(amount, options) {
666
+ const { precision, compact, showBtcSymbol } = {
667
+ ...defaultOptions,
668
+ ...options
669
+ };
660
670
  const currencyAmount = getCurrencyAmount(amount);
661
671
  let { value: num } = currencyAmount;
662
672
  const { unit } = currencyAmount;
663
673
  if (unit === CurrencyUnit.USD) {
664
674
  num = num / 100;
665
675
  }
666
- function getDefaultMaxFractionDigits(defaultDigits) {
667
- return typeof maxFractionDigits === "undefined" ? compact ? 1 : defaultDigits : maxFractionDigits;
676
+ function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
677
+ let digits = defaultDigits;
678
+ if (precision === "full") {
679
+ digits = fullPrecisionDigits;
680
+ } else if (typeof precision === "number") {
681
+ digits = precision;
682
+ } else if (compact) {
683
+ digits = 1;
684
+ }
685
+ return digits;
668
686
  }
669
687
  const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
670
688
  const currentLocale = getCurrentLocale();
@@ -672,27 +690,28 @@ function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = f
672
690
  case CurrencyUnit.BITCOIN:
673
691
  return `${symbol}${num.toLocaleString(currentLocale, {
674
692
  notation: compact ? "compact" : void 0,
675
- maximumFractionDigits: getDefaultMaxFractionDigits(4),
676
- ...options
693
+ maximumFractionDigits: getDefaultMaxFractionDigits(4, 8)
677
694
  })}`;
678
- case CurrencyUnit.MILLISATOSHI:
679
695
  case CurrencyUnit.SATOSHI:
696
+ return `${symbol}${num.toLocaleString(currentLocale, {
697
+ notation: compact ? "compact" : void 0,
698
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
699
+ })}`;
700
+ case CurrencyUnit.MILLISATOSHI:
680
701
  case CurrencyUnit.MICROBITCOIN:
681
702
  case CurrencyUnit.MILLIBITCOIN:
682
703
  case CurrencyUnit.NANOBITCOIN:
683
704
  default:
684
705
  return `${symbol}${num.toLocaleString(currentLocale, {
685
706
  notation: compact ? "compact" : void 0,
686
- maximumFractionDigits: getDefaultMaxFractionDigits(0),
687
- ...options
707
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
688
708
  })}`;
689
709
  case CurrencyUnit.USD:
690
710
  return num.toLocaleString(currentLocale, {
691
711
  style: "currency",
692
712
  currency: defaultCurrencyCode,
693
713
  notation: compact ? "compact" : void 0,
694
- maximumFractionDigits: getDefaultMaxFractionDigits(2),
695
- ...options
714
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
696
715
  });
697
716
  }
698
717
  }
@@ -82,7 +82,12 @@ declare function isSDKCurrencyAmount(arg: unknown): arg is SDKCurrencyAmountType
82
82
  declare function mapCurrencyAmount(currencyAmountArg: CurrencyAmountArg, centsPerBtc?: number): CurrencyMap;
83
83
  declare const isCurrencyMap: (currencyMap: unknown) => currencyMap is CurrencyMap;
84
84
  declare const abbrCurrencyUnit: (unit: CurrencyUnitType) => "USD" | "BTC" | "SAT" | "MSAT" | "Unsupported CurrencyUnit";
85
- declare function formatCurrencyStr(amount: CurrencyAmountArg, maxFractionDigits?: number, compact?: boolean, showBtcSymbol?: boolean, options?: Intl.NumberFormatOptions): string;
85
+ type FormatCurrencyStrOptions = {
86
+ precision?: number | "full" | undefined;
87
+ compact?: boolean | undefined;
88
+ showBtcSymbol?: boolean | undefined;
89
+ };
90
+ declare function formatCurrencyStr(amount: CurrencyAmountArg, options?: FormatCurrencyStrOptions): string;
86
91
  declare function separateCurrencyStrParts(currencyStr: string): {
87
92
  symbol: string;
88
93
  amount: string;
@@ -118,6 +123,10 @@ type JSONObject = {
118
123
  };
119
124
  type NN<T> = NonNullable<T>;
120
125
  declare function notNullUndefined<TValue>(value: TValue | null | undefined): value is TValue;
126
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
127
+ type Complete<T> = {
128
+ [P in keyof T]-?: NonNullable<T[P]>;
129
+ };
121
130
 
122
131
  declare const isError: (e: unknown) => e is Error;
123
132
  type ErrorWithMessage = {
@@ -229,4 +238,4 @@ declare function lsidToUUID(lsid: string): string;
229
238
 
230
239
  declare function isUint8Array(variable: unknown): variable is Uint8Array;
231
240
 
232
- export { isType as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, SDKCurrencyAmountType as S, pollUntil as T, sleep as U, lsidToUUID as V, isUint8Array as W, Maybe as X, ExpandRecursively as Y, ById as Z, OmitTypename as _, b64encode as a, DeepPartial as a0, JSONLiteral as a1, JSONType as a2, JSONObject as a3, NN as a4, notNullUndefined as a5, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyUnitType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isSDKCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
241
+ export { isType as $, isErrorMsg as A, errorToJSON as B, ConfigKeys as C, bytesToHex as D, hexToBytes as E, getLocalStorageConfigItem as F, getLocalStorageBoolean as G, setLocalStorageBoolean as H, deleteLocalStorageItem as I, getCurrentLocale as J, countryCodesToCurrencyCodes as K, CurrencyLocales as L, CurrencyCodes as M, localeToCurrencyCode as N, clamp as O, linearInterpolate as P, round as Q, isNumber as R, SDKCurrencyAmountType as S, pollUntil as T, sleep as U, lsidToUUID as V, isUint8Array as W, Maybe as X, ExpandRecursively as Y, ById as Z, OmitTypename as _, b64encode as a, DeepPartial as a0, JSONLiteral as a1, JSONType as a2, JSONObject as a3, NN as a4, notNullUndefined as a5, PartialBy as a6, Complete as a7, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyUnitType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isSDKCurrencyAmount as m, mapCurrencyAmount as n, isCurrencyMap as o, abbrCurrencyUnit as p, formatCurrencyStr as q, localeToCurrencySymbol as r, separateCurrencyStrParts as s, isBrowser as t, urlsafe_b64decode as u, isNode as v, isTest as w, isError as x, isErrorWithMessage as y, getErrorMsg as z };
package/dist/index.cjs CHANGED
@@ -1100,15 +1100,33 @@ var abbrCurrencyUnit = (unit) => {
1100
1100
  }
1101
1101
  return "Unsupported CurrencyUnit";
1102
1102
  };
1103
- function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = false, options = {}) {
1103
+ var defaultOptions = {
1104
+ /* undefined indicates to use default precision for unit defined below */
1105
+ precision: void 0,
1106
+ compact: false,
1107
+ showBtcSymbol: false
1108
+ };
1109
+ function formatCurrencyStr(amount, options) {
1110
+ const { precision, compact, showBtcSymbol } = {
1111
+ ...defaultOptions,
1112
+ ...options
1113
+ };
1104
1114
  const currencyAmount = getCurrencyAmount(amount);
1105
1115
  let { value: num } = currencyAmount;
1106
1116
  const { unit } = currencyAmount;
1107
1117
  if (unit === CurrencyUnit.USD) {
1108
1118
  num = num / 100;
1109
1119
  }
1110
- function getDefaultMaxFractionDigits(defaultDigits) {
1111
- return typeof maxFractionDigits === "undefined" ? compact ? 1 : defaultDigits : maxFractionDigits;
1120
+ function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
1121
+ let digits = defaultDigits;
1122
+ if (precision === "full") {
1123
+ digits = fullPrecisionDigits;
1124
+ } else if (typeof precision === "number") {
1125
+ digits = precision;
1126
+ } else if (compact) {
1127
+ digits = 1;
1128
+ }
1129
+ return digits;
1112
1130
  }
1113
1131
  const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
1114
1132
  const currentLocale = getCurrentLocale();
@@ -1116,27 +1134,28 @@ function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = f
1116
1134
  case CurrencyUnit.BITCOIN:
1117
1135
  return `${symbol}${num.toLocaleString(currentLocale, {
1118
1136
  notation: compact ? "compact" : void 0,
1119
- maximumFractionDigits: getDefaultMaxFractionDigits(4),
1120
- ...options
1137
+ maximumFractionDigits: getDefaultMaxFractionDigits(4, 8)
1121
1138
  })}`;
1122
- case CurrencyUnit.MILLISATOSHI:
1123
1139
  case CurrencyUnit.SATOSHI:
1140
+ return `${symbol}${num.toLocaleString(currentLocale, {
1141
+ notation: compact ? "compact" : void 0,
1142
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
1143
+ })}`;
1144
+ case CurrencyUnit.MILLISATOSHI:
1124
1145
  case CurrencyUnit.MICROBITCOIN:
1125
1146
  case CurrencyUnit.MILLIBITCOIN:
1126
1147
  case CurrencyUnit.NANOBITCOIN:
1127
1148
  default:
1128
1149
  return `${symbol}${num.toLocaleString(currentLocale, {
1129
1150
  notation: compact ? "compact" : void 0,
1130
- maximumFractionDigits: getDefaultMaxFractionDigits(0),
1131
- ...options
1151
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
1132
1152
  })}`;
1133
1153
  case CurrencyUnit.USD:
1134
1154
  return num.toLocaleString(currentLocale, {
1135
1155
  style: "currency",
1136
1156
  currency: defaultCurrencyCode,
1137
1157
  notation: compact ? "compact" : void 0,
1138
- maximumFractionDigits: getDefaultMaxFractionDigits(2),
1139
- ...options
1158
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
1140
1159
  });
1141
1160
  }
1142
1161
  }
@@ -1548,7 +1567,7 @@ var Requester = class {
1548
1567
  }
1549
1568
  }
1550
1569
  const operation = operationMatch[2];
1551
- let bodyData = {
1570
+ const payload = {
1552
1571
  query: queryPayload,
1553
1572
  variables,
1554
1573
  operationName: operation
@@ -1558,14 +1577,19 @@ var Requester = class {
1558
1577
  const baseHeaders = {
1559
1578
  "Content-Type": "application/json",
1560
1579
  "X-Lightspark-SDK": sdkUserAgent,
1561
- "User-Agent": browserUserAgent || sdkUserAgent
1580
+ "User-Agent": browserUserAgent || sdkUserAgent,
1581
+ "X-GraphQL-Operation": operation
1562
1582
  };
1563
1583
  const headers = skipAuth ? baseHeaders : await this.authProvider.addAuthHeaders(baseHeaders);
1564
- bodyData = await this.addSigningDataIfNeeded(
1565
- bodyData,
1584
+ let bodyData = await this.addSigningDataIfNeeded(
1585
+ payload,
1566
1586
  headers,
1567
1587
  signingNodeId
1568
1588
  );
1589
+ if (bodyData.length > 1024 && typeof CompressionStream != "undefined") {
1590
+ bodyData = await compress(bodyData);
1591
+ headers["Content-Encoding"] = "deflate";
1592
+ }
1569
1593
  let urlWithProtocol = this.baseUrl;
1570
1594
  if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
1571
1595
  urlWithProtocol = `https://${urlWithProtocol}`;
@@ -1579,7 +1603,7 @@ var Requester = class {
1579
1603
  const response = await fetch(url, {
1580
1604
  method: "POST",
1581
1605
  headers,
1582
- body: JSON.stringify(bodyData)
1606
+ body: bodyData
1583
1607
  });
1584
1608
  if (!response.ok) {
1585
1609
  throw new LightsparkException_default(
@@ -1606,8 +1630,14 @@ var Requester = class {
1606
1630
  return url.replace(/.*?:\/\//g, "");
1607
1631
  }
1608
1632
  async addSigningDataIfNeeded(queryPayload, headers, signingNodeId) {
1633
+ let TextEncoderImpl;
1634
+ if (typeof TextEncoder === "undefined") {
1635
+ TextEncoderImpl = (await import("text-encoding")).TextEncoder;
1636
+ } else {
1637
+ TextEncoderImpl = TextEncoder;
1638
+ }
1609
1639
  if (!signingNodeId) {
1610
- return queryPayload;
1640
+ return new TextEncoderImpl().encode(JSON.stringify(queryPayload));
1611
1641
  }
1612
1642
  const query = queryPayload.query;
1613
1643
  const variables = queryPayload.variables;
@@ -1627,12 +1657,6 @@ var Requester = class {
1627
1657
  "Missing node of encrypted_signing_private_key"
1628
1658
  );
1629
1659
  }
1630
- let TextEncoderImpl;
1631
- if (typeof TextEncoder === "undefined") {
1632
- TextEncoderImpl = (await import("text-encoding")).TextEncoder;
1633
- } else {
1634
- TextEncoderImpl = TextEncoder;
1635
- }
1636
1660
  const encodedPayload = new TextEncoderImpl().encode(
1637
1661
  JSON.stringify(payload)
1638
1662
  );
@@ -1642,9 +1666,22 @@ var Requester = class {
1642
1666
  v: "1",
1643
1667
  signature: encodedSignedPayload
1644
1668
  });
1645
- return payload;
1669
+ return encodedPayload;
1646
1670
  }
1647
1671
  };
1672
+ async function compress(data) {
1673
+ const stream = new Blob([data]).stream();
1674
+ const compressedStream = stream.pipeThrough(new CompressionStream("deflate"));
1675
+ const reader = compressedStream.getReader();
1676
+ const chunks = [];
1677
+ let done, value;
1678
+ while (!done) {
1679
+ ({ done, value } = await reader.read());
1680
+ chunks.push(value);
1681
+ }
1682
+ const blob = new Blob(chunks);
1683
+ return new Uint8Array(await blob.arrayBuffer());
1684
+ }
1648
1685
  var Requester_default = Requester;
1649
1686
  // Annotate the CommonJS export names for ESM import in node:
1650
1687
  0 && (module.exports = {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { Z as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-9ecb1570.js';
1
+ export { Z as ById, a7 as Complete, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, a6 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-4698c2db.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  declare class LightsparkException extends Error {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Z as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-9ecb1570.js';
1
+ export { Z as ById, a7 as Complete, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, a6 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from './index-4698c2db.js';
2
2
  import { Observable } from 'zen-observable-ts';
3
3
 
4
4
  declare class LightsparkException extends Error {
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  setLocalStorageBoolean,
44
44
  sleep,
45
45
  urlsafe_b64decode
46
- } from "./chunk-RC2KOZKZ.js";
46
+ } from "./chunk-XRYQNSG7.js";
47
47
 
48
48
  // src/Logger.ts
49
49
  var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
@@ -582,7 +582,7 @@ var Requester = class {
582
582
  }
583
583
  }
584
584
  const operation = operationMatch[2];
585
- let bodyData = {
585
+ const payload = {
586
586
  query: queryPayload,
587
587
  variables,
588
588
  operationName: operation
@@ -592,14 +592,19 @@ var Requester = class {
592
592
  const baseHeaders = {
593
593
  "Content-Type": "application/json",
594
594
  "X-Lightspark-SDK": sdkUserAgent,
595
- "User-Agent": browserUserAgent || sdkUserAgent
595
+ "User-Agent": browserUserAgent || sdkUserAgent,
596
+ "X-GraphQL-Operation": operation
596
597
  };
597
598
  const headers = skipAuth ? baseHeaders : await this.authProvider.addAuthHeaders(baseHeaders);
598
- bodyData = await this.addSigningDataIfNeeded(
599
- bodyData,
599
+ let bodyData = await this.addSigningDataIfNeeded(
600
+ payload,
600
601
  headers,
601
602
  signingNodeId
602
603
  );
604
+ if (bodyData.length > 1024 && typeof CompressionStream != "undefined") {
605
+ bodyData = await compress(bodyData);
606
+ headers["Content-Encoding"] = "deflate";
607
+ }
603
608
  let urlWithProtocol = this.baseUrl;
604
609
  if (!urlWithProtocol.startsWith("https://") && !urlWithProtocol.startsWith("http://")) {
605
610
  urlWithProtocol = `https://${urlWithProtocol}`;
@@ -613,7 +618,7 @@ var Requester = class {
613
618
  const response = await fetch(url, {
614
619
  method: "POST",
615
620
  headers,
616
- body: JSON.stringify(bodyData)
621
+ body: bodyData
617
622
  });
618
623
  if (!response.ok) {
619
624
  throw new LightsparkException_default(
@@ -640,8 +645,14 @@ var Requester = class {
640
645
  return url.replace(/.*?:\/\//g, "");
641
646
  }
642
647
  async addSigningDataIfNeeded(queryPayload, headers, signingNodeId) {
648
+ let TextEncoderImpl;
649
+ if (typeof TextEncoder === "undefined") {
650
+ TextEncoderImpl = (await import("text-encoding")).TextEncoder;
651
+ } else {
652
+ TextEncoderImpl = TextEncoder;
653
+ }
643
654
  if (!signingNodeId) {
644
- return queryPayload;
655
+ return new TextEncoderImpl().encode(JSON.stringify(queryPayload));
645
656
  }
646
657
  const query = queryPayload.query;
647
658
  const variables = queryPayload.variables;
@@ -661,12 +672,6 @@ var Requester = class {
661
672
  "Missing node of encrypted_signing_private_key"
662
673
  );
663
674
  }
664
- let TextEncoderImpl;
665
- if (typeof TextEncoder === "undefined") {
666
- TextEncoderImpl = (await import("text-encoding")).TextEncoder;
667
- } else {
668
- TextEncoderImpl = TextEncoder;
669
- }
670
675
  const encodedPayload = new TextEncoderImpl().encode(
671
676
  JSON.stringify(payload)
672
677
  );
@@ -676,9 +681,22 @@ var Requester = class {
676
681
  v: "1",
677
682
  signature: encodedSignedPayload
678
683
  });
679
- return payload;
684
+ return encodedPayload;
680
685
  }
681
686
  };
687
+ async function compress(data) {
688
+ const stream = new Blob([data]).stream();
689
+ const compressedStream = stream.pipeThrough(new CompressionStream("deflate"));
690
+ const reader = compressedStream.getReader();
691
+ const chunks = [];
692
+ let done, value;
693
+ while (!done) {
694
+ ({ done, value } = await reader.read());
695
+ chunks.push(value);
696
+ }
697
+ const blob = new Blob(chunks);
698
+ return new Uint8Array(await blob.arrayBuffer());
699
+ }
682
700
  var Requester_default = Requester;
683
701
  export {
684
702
  ConfigKeys,
@@ -734,15 +734,33 @@ var abbrCurrencyUnit = (unit) => {
734
734
  }
735
735
  return "Unsupported CurrencyUnit";
736
736
  };
737
- function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = false, options = {}) {
737
+ var defaultOptions = {
738
+ /* undefined indicates to use default precision for unit defined below */
739
+ precision: void 0,
740
+ compact: false,
741
+ showBtcSymbol: false
742
+ };
743
+ function formatCurrencyStr(amount, options) {
744
+ const { precision, compact, showBtcSymbol } = {
745
+ ...defaultOptions,
746
+ ...options
747
+ };
738
748
  const currencyAmount = getCurrencyAmount(amount);
739
749
  let { value: num } = currencyAmount;
740
750
  const { unit } = currencyAmount;
741
751
  if (unit === CurrencyUnit.USD) {
742
752
  num = num / 100;
743
753
  }
744
- function getDefaultMaxFractionDigits(defaultDigits) {
745
- return typeof maxFractionDigits === "undefined" ? compact ? 1 : defaultDigits : maxFractionDigits;
754
+ function getDefaultMaxFractionDigits(defaultDigits, fullPrecisionDigits) {
755
+ let digits = defaultDigits;
756
+ if (precision === "full") {
757
+ digits = fullPrecisionDigits;
758
+ } else if (typeof precision === "number") {
759
+ digits = precision;
760
+ } else if (compact) {
761
+ digits = 1;
762
+ }
763
+ return digits;
746
764
  }
747
765
  const symbol = !showBtcSymbol ? "" : unit === CurrencyUnit.BITCOIN ? "\uE903" : unit === CurrencyUnit.SATOSHI ? "\uE902" : "";
748
766
  const currentLocale = getCurrentLocale();
@@ -750,27 +768,28 @@ function formatCurrencyStr(amount, maxFractionDigits, compact, showBtcSymbol = f
750
768
  case CurrencyUnit.BITCOIN:
751
769
  return `${symbol}${num.toLocaleString(currentLocale, {
752
770
  notation: compact ? "compact" : void 0,
753
- maximumFractionDigits: getDefaultMaxFractionDigits(4),
754
- ...options
771
+ maximumFractionDigits: getDefaultMaxFractionDigits(4, 8)
755
772
  })}`;
756
- case CurrencyUnit.MILLISATOSHI:
757
773
  case CurrencyUnit.SATOSHI:
774
+ return `${symbol}${num.toLocaleString(currentLocale, {
775
+ notation: compact ? "compact" : void 0,
776
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 3)
777
+ })}`;
778
+ case CurrencyUnit.MILLISATOSHI:
758
779
  case CurrencyUnit.MICROBITCOIN:
759
780
  case CurrencyUnit.MILLIBITCOIN:
760
781
  case CurrencyUnit.NANOBITCOIN:
761
782
  default:
762
783
  return `${symbol}${num.toLocaleString(currentLocale, {
763
784
  notation: compact ? "compact" : void 0,
764
- maximumFractionDigits: getDefaultMaxFractionDigits(0),
765
- ...options
785
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 0)
766
786
  })}`;
767
787
  case CurrencyUnit.USD:
768
788
  return num.toLocaleString(currentLocale, {
769
789
  style: "currency",
770
790
  currency: defaultCurrencyCode,
771
791
  notation: compact ? "compact" : void 0,
772
- maximumFractionDigits: getDefaultMaxFractionDigits(2),
773
- ...options
792
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2)
774
793
  });
775
794
  }
776
795
  }
@@ -1 +1 @@
1
- export { Z as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from '../index-9ecb1570.js';
1
+ export { Z as ById, a7 as Complete, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, a6 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from '../index-4698c2db.js';
@@ -1 +1 @@
1
- export { Z as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from '../index-9ecb1570.js';
1
+ export { Z as ById, a7 as Complete, k as CurrencyAmountArg, j as CurrencyAmountObj, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, f as CurrencyUnitType, a0 as DeepPartial, Y as ExpandRecursively, a1 as JSONLiteral, a3 as JSONObject, a2 as JSONType, X as Maybe, a4 as NN, _ as OmitTypename, a6 as PartialBy, S as SDKCurrencyAmountType, p as abbrCurrencyUnit, b as b64decode, a as b64encode, D as bytesToHex, O as clamp, h as convertCurrencyAmount, g as convertCurrencyAmountValue, K as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, I as deleteLocalStorageItem, B as errorToJSON, q as formatCurrencyStr, J as getCurrentLocale, z as getErrorMsg, G as getLocalStorageBoolean, F as getLocalStorageConfigItem, E as hexToBytes, t as isBrowser, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, m as isSDKCurrencyAmount, w as isTest, $ as isType, W as isUint8Array, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, V as lsidToUUID, n as mapCurrencyAmount, a5 as notNullUndefined, T as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, U as sleep, u as urlsafe_b64decode } from '../index-4698c2db.js';
@@ -42,7 +42,7 @@ import {
42
42
  setLocalStorageBoolean,
43
43
  sleep,
44
44
  urlsafe_b64decode
45
- } from "../chunk-RC2KOZKZ.js";
45
+ } from "../chunk-XRYQNSG7.js";
46
46
  export {
47
47
  CurrencyUnit,
48
48
  abbrCurrencyUnit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.0.22",
3
+ "version": "1.1.0",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -137,7 +137,7 @@ class Requester {
137
137
  }
138
138
  }
139
139
  const operation = operationMatch[2];
140
- let bodyData: BodyData = {
140
+ const payload: BodyData = {
141
141
  query: queryPayload,
142
142
  variables,
143
143
  operationName: operation,
@@ -149,16 +149,22 @@ class Requester {
149
149
  "Content-Type": "application/json",
150
150
  "X-Lightspark-SDK": sdkUserAgent,
151
151
  "User-Agent": browserUserAgent || sdkUserAgent,
152
+ "X-GraphQL-Operation": operation,
152
153
  };
153
- const headers = skipAuth
154
+ const headers: { [key: string]: string } = skipAuth
154
155
  ? baseHeaders
155
156
  : await this.authProvider.addAuthHeaders(baseHeaders);
156
- bodyData = await this.addSigningDataIfNeeded(
157
- bodyData,
157
+ let bodyData = await this.addSigningDataIfNeeded(
158
+ payload,
158
159
  headers,
159
160
  signingNodeId,
160
161
  );
161
162
 
163
+ if (bodyData.length > 1024 && typeof CompressionStream != "undefined") {
164
+ bodyData = await compress(bodyData);
165
+ headers["Content-Encoding"] = "deflate";
166
+ }
167
+
162
168
  let urlWithProtocol = this.baseUrl;
163
169
  if (
164
170
  !urlWithProtocol.startsWith("https://") &&
@@ -177,7 +183,7 @@ class Requester {
177
183
  const response = await fetch(url, {
178
184
  method: "POST",
179
185
  headers: headers,
180
- body: JSON.stringify(bodyData),
186
+ body: bodyData,
181
187
  });
182
188
  if (!response.ok) {
183
189
  throw new LightsparkException(
@@ -214,9 +220,16 @@ class Requester {
214
220
  headers: { [key: string]: string },
215
221
  signingNodeId: string | undefined,
216
222
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any -- LIG-3400 */
217
- ): Promise<BodyData> {
223
+ ): Promise<Uint8Array> {
224
+ let TextEncoderImpl;
225
+ if (typeof TextEncoder === "undefined") {
226
+ TextEncoderImpl = (await import("text-encoding")).TextEncoder;
227
+ } else {
228
+ TextEncoderImpl = TextEncoder;
229
+ }
230
+
218
231
  if (!signingNodeId) {
219
- return queryPayload;
232
+ return new TextEncoderImpl().encode(JSON.stringify(queryPayload));
220
233
  }
221
234
 
222
235
  const query = queryPayload.query;
@@ -241,12 +254,6 @@ class Requester {
241
254
  );
242
255
  }
243
256
 
244
- let TextEncoderImpl;
245
- if (typeof TextEncoder === "undefined") {
246
- TextEncoderImpl = (await import("text-encoding")).TextEncoder;
247
- } else {
248
- TextEncoderImpl = TextEncoder;
249
- }
250
257
  const encodedPayload = new TextEncoderImpl().encode(
251
258
  JSON.stringify(payload),
252
259
  );
@@ -258,8 +265,22 @@ class Requester {
258
265
  v: "1",
259
266
  signature: encodedSignedPayload,
260
267
  });
261
- return payload;
268
+ return encodedPayload;
269
+ }
270
+ }
271
+
272
+ async function compress(data: Uint8Array): Promise<Uint8Array> {
273
+ const stream = new Blob([data]).stream();
274
+ const compressedStream = stream.pipeThrough(new CompressionStream("deflate"));
275
+ const reader = compressedStream.getReader();
276
+ const chunks = [];
277
+ let done, value;
278
+ while (!done) {
279
+ ({ done, value } = await reader.read()); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
280
+ chunks.push(value);
262
281
  }
282
+ const blob = new Blob(chunks);
283
+ return new Uint8Array(await blob.arrayBuffer());
263
284
  }
264
285
 
265
286
  export default Requester;
@@ -382,35 +382,54 @@ export const abbrCurrencyUnit = (unit: CurrencyUnitType) => {
382
382
  return "Unsupported CurrencyUnit";
383
383
  };
384
384
 
385
+ const defaultOptions = {
386
+ /* undefined indicates to use default precision for unit defined below */
387
+ precision: undefined,
388
+ compact: false,
389
+ showBtcSymbol: false,
390
+ };
391
+
392
+ type FormatCurrencyStrOptions = {
393
+ /* undefined indicates to use default precision for unit defined below */
394
+ precision?: number | "full" | undefined;
395
+ compact?: boolean | undefined;
396
+ showBtcSymbol?: boolean | undefined;
397
+ };
398
+
385
399
  export function formatCurrencyStr(
386
400
  amount: CurrencyAmountArg,
387
- maxFractionDigits?: number,
388
- compact?: boolean,
389
- showBtcSymbol = false,
390
- options: Intl.NumberFormatOptions = {},
401
+ options?: FormatCurrencyStrOptions,
391
402
  ) {
403
+ const { precision, compact, showBtcSymbol } = {
404
+ ...defaultOptions,
405
+ ...options,
406
+ };
407
+
392
408
  const currencyAmount = getCurrencyAmount(amount);
393
409
  let { value: num } = currencyAmount;
394
410
  const { unit } = currencyAmount;
395
411
 
396
- /**
397
- * Currencies should always be represented in the smallest unit, e.g.
398
- * cents for USD:
399
- */
412
+ /* Currencies should always be represented in the smallest unit, e.g. cents for USD: */
400
413
  if (unit === CurrencyUnit.USD) {
401
414
  num = num / 100;
402
415
  }
403
416
 
404
- function getDefaultMaxFractionDigits(defaultDigits: number) {
405
- return typeof maxFractionDigits === "undefined"
406
- ? compact
407
- ? 1
408
- : defaultDigits
409
- : maxFractionDigits;
417
+ function getDefaultMaxFractionDigits(
418
+ defaultDigits: number,
419
+ fullPrecisionDigits: number,
420
+ ) {
421
+ let digits = defaultDigits;
422
+ if (precision === "full") {
423
+ digits = fullPrecisionDigits;
424
+ } else if (typeof precision === "number") {
425
+ digits = precision;
426
+ } else if (compact) {
427
+ digits = 1;
428
+ }
429
+ return digits;
410
430
  }
411
431
 
412
- // Symbol handled by toLocaleString for USD.
413
- // These rely on the LightsparkIcons font
432
+ /* Symbol handled by toLocaleString for USD. These rely on the LightsparkIcons font: */
414
433
  const symbol = !showBtcSymbol
415
434
  ? ""
416
435
  : unit === CurrencyUnit.BITCOIN
@@ -423,35 +442,41 @@ export function formatCurrencyStr(
423
442
 
424
443
  switch (unit) {
425
444
  case CurrencyUnit.BITCOIN:
445
+ /* In most cases product prefers 4 precision digtis for BTC. In a few places
446
+ full precision (8 digits) are preferred, e.g. for a transaction details page: */
426
447
  return `${symbol}${num.toLocaleString(currentLocale, {
427
448
  notation: compact ? ("compact" as const) : undefined,
428
- maximumFractionDigits: getDefaultMaxFractionDigits(4),
429
- ...options,
449
+ maximumFractionDigits: getDefaultMaxFractionDigits(4, 8),
430
450
  })}`;
431
- case CurrencyUnit.MILLISATOSHI:
432
451
  case CurrencyUnit.SATOSHI:
452
+ /* In most cases product prefers hiding sub sat precision (msats). In a few
453
+ places full precision (3 digits) are preferred, e.g. for Lightning fees
454
+ paid on a transaction details page: */
455
+ return `${symbol}${num.toLocaleString(currentLocale, {
456
+ notation: compact ? ("compact" as const) : undefined,
457
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 3),
458
+ })}`;
459
+ case CurrencyUnit.MILLISATOSHI:
433
460
  case CurrencyUnit.MICROBITCOIN:
434
461
  case CurrencyUnit.MILLIBITCOIN:
435
462
  case CurrencyUnit.NANOBITCOIN:
436
463
  default:
437
464
  return `${symbol}${num.toLocaleString(currentLocale, {
438
465
  notation: compact ? ("compact" as const) : undefined,
439
- maximumFractionDigits: getDefaultMaxFractionDigits(0),
440
- ...options,
466
+ maximumFractionDigits: getDefaultMaxFractionDigits(0, 0),
441
467
  })}`;
442
468
  case CurrencyUnit.USD:
443
469
  return num.toLocaleString(currentLocale, {
444
470
  style: "currency",
445
471
  currency: defaultCurrencyCode,
446
472
  notation: compact ? ("compact" as const) : undefined,
447
- maximumFractionDigits: getDefaultMaxFractionDigits(2),
448
- ...options,
473
+ maximumFractionDigits: getDefaultMaxFractionDigits(2, 2),
449
474
  });
450
475
  }
451
476
  }
452
477
 
453
478
  export function separateCurrencyStrParts(currencyStr: string) {
454
- // split the currency string into the symbol and the amount
479
+ /* split the currency string into the symbol and the amount */
455
480
  const symbol = currencyStr.replace(/[0-9\s\u00a0.,]/g, "");
456
481
  const amount = currencyStr.replace(/[^\d.,-]/g, "");
457
482
  return { symbol, amount };
@@ -467,8 +492,7 @@ export function localeToCurrencySymbol(locale: string) {
467
492
  maximumFractionDigits: 0,
468
493
  }).format(0);
469
494
 
470
- // Remove numeric and non-breaking space characters to extract the currency
471
- // symbol
495
+ /* Remove numeric and non-breaking space characters to extract the currency symbol */
472
496
  const { symbol } = separateCurrencyStrParts(formatted);
473
497
  return symbol;
474
498
  }
@@ -39,3 +39,9 @@ export function notNullUndefined<TValue>(
39
39
  ): value is TValue {
40
40
  return value !== null && value !== undefined;
41
41
  }
42
+
43
+ /* Make specific properties on object optional: */
44
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
45
+
46
+ /* Opposite of Partial - make all keys required with NonNullable values */
47
+ export type Complete<T> = { [P in keyof T]-?: NonNullable<T[P]> };