@lightsparkdev/core 1.0.14 → 1.0.16
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 +12 -0
- package/dist/{chunk-ZLX5HJ4C.js → chunk-JTLRW26V.js} +5 -1
- package/dist/{index-d0c72658.d.ts → index-2708d41b.d.ts} +2 -1
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -4
- package/dist/utils/index.cjs +5 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/src/requester/Requester.ts +0 -4
- package/src/utils/errors.ts +11 -1
- package/src/utils/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @lightsparkdev/core
|
|
2
2
|
|
|
3
|
+
## 1.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- cb28f0e: - Serialize errors that have messages but not own properties
|
|
8
|
+
|
|
9
|
+
## 1.0.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 66e76d3: - Remove beta headers in Requester
|
|
14
|
+
|
|
3
15
|
## 1.0.14
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -732,9 +732,13 @@ function errorToJSON(err) {
|
|
|
732
732
|
if (!err) {
|
|
733
733
|
return null;
|
|
734
734
|
}
|
|
735
|
-
if (typeof err === "object" &&
|
|
735
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
736
736
|
return err.toJSON();
|
|
737
737
|
}
|
|
738
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
739
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
740
|
+
return { message: err.message };
|
|
741
|
+
}
|
|
738
742
|
return JSON.parse(
|
|
739
743
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
740
744
|
);
|
|
@@ -161,6 +161,7 @@ type JSONType = JSONLiteral | JSONType[] | {
|
|
|
161
161
|
type JSONObject = {
|
|
162
162
|
[key: string]: JSONType;
|
|
163
163
|
};
|
|
164
|
+
type NN<T> = NonNullable<T>;
|
|
164
165
|
|
|
165
166
|
declare const isError: (e: unknown) => e is Error;
|
|
166
167
|
type ErrorWithMessage = {
|
|
@@ -268,4 +269,4 @@ declare function pollUntil<D extends () => Promise<unknown>, T>(asyncFn: D, getV
|
|
|
268
269
|
|
|
269
270
|
declare function sleep(ms: number): Promise<unknown>;
|
|
270
271
|
|
|
271
|
-
export { JSONType 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, pollUntil as S, sleep as T, Maybe as U, ExpandRecursively as V, ById as W, OmitTypename as X, isType as Y, DeepPartial as Z, JSONLiteral as _, b64encode as a, JSONObject as a0, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount 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 };
|
|
272
|
+
export { JSONType 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, pollUntil as S, sleep as T, Maybe as U, ExpandRecursively as V, ById as W, OmitTypename as X, isType as Y, DeepPartial as Z, JSONLiteral as _, b64encode as a, JSONObject as a0, NN as a1, b64decode as b, createSha256Hash as c, defaultCurrencyCode as d, CurrencyUnit as e, CurrencyAmountType as f, convertCurrencyAmountValue as g, convertCurrencyAmount as h, CurrencyMap as i, CurrencyAmountObj as j, CurrencyAmountArg as k, isCurrencyAmountObj as l, isCurrencyAmount 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
|
@@ -1135,9 +1135,13 @@ function errorToJSON(err) {
|
|
|
1135
1135
|
if (!err) {
|
|
1136
1136
|
return null;
|
|
1137
1137
|
}
|
|
1138
|
-
if (typeof err === "object" &&
|
|
1138
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
1139
1139
|
return err.toJSON();
|
|
1140
1140
|
}
|
|
1141
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
1142
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
1143
|
+
return { message: err.message };
|
|
1144
|
+
}
|
|
1141
1145
|
return JSON.parse(
|
|
1142
1146
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
1143
1147
|
);
|
|
@@ -1396,8 +1400,6 @@ var import_graphql_ws = require("graphql-ws");
|
|
|
1396
1400
|
var import_ws = __toESM(require("ws"), 1);
|
|
1397
1401
|
var import_zen_observable_ts = require("zen-observable-ts");
|
|
1398
1402
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
1399
|
-
var LIGHTSPARK_BETA_HEADER_KEY = "X-Lightspark-Beta";
|
|
1400
|
-
var LIGHTSPARK_BETA_HEADER_VALUE = "z2h0BBYxTA83cjW7fi8QwWtBPCzkQKiemcuhKY08LOo";
|
|
1401
1403
|
import_dayjs.default.extend(import_utc.default);
|
|
1402
1404
|
var Requester = class {
|
|
1403
1405
|
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
@@ -1495,7 +1497,6 @@ var Requester = class {
|
|
|
1495
1497
|
const sdkUserAgent = this.getSdkUserAgent();
|
|
1496
1498
|
const baseHeaders = {
|
|
1497
1499
|
"Content-Type": "application/json",
|
|
1498
|
-
[LIGHTSPARK_BETA_HEADER_KEY]: LIGHTSPARK_BETA_HEADER_VALUE,
|
|
1499
1500
|
"X-Lightspark-SDK": sdkUserAgent,
|
|
1500
1501
|
"User-Agent": browserUserAgent || sdkUserAgent
|
|
1501
1502
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-
|
|
1
|
+
export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-2708d41b.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 { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-
|
|
1
|
+
export { W as ById, C as ConfigKeys, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from './index-2708d41b.js';
|
|
2
2
|
import { Observable } from 'zen-observable-ts';
|
|
3
3
|
|
|
4
4
|
declare class LightsparkException extends Error {
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
setLocalStorageBoolean,
|
|
41
41
|
sleep,
|
|
42
42
|
urlsafe_b64decode
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-JTLRW26V.js";
|
|
44
44
|
|
|
45
45
|
// src/Logger.ts
|
|
46
46
|
var Logger = class {
|
|
@@ -455,8 +455,6 @@ import { createClient } from "graphql-ws";
|
|
|
455
455
|
import NodeWebSocket from "ws";
|
|
456
456
|
import { Observable } from "zen-observable-ts";
|
|
457
457
|
var DEFAULT_BASE_URL = "api.lightspark.com";
|
|
458
|
-
var LIGHTSPARK_BETA_HEADER_KEY = "X-Lightspark-Beta";
|
|
459
|
-
var LIGHTSPARK_BETA_HEADER_VALUE = "z2h0BBYxTA83cjW7fi8QwWtBPCzkQKiemcuhKY08LOo";
|
|
460
458
|
dayjs.extend(utc);
|
|
461
459
|
var Requester = class {
|
|
462
460
|
constructor(nodeKeyCache, schemaEndpoint, sdkUserAgent, authProvider = new StubAuthProvider(), baseUrl = DEFAULT_BASE_URL, cryptoImpl = DefaultCrypto) {
|
|
@@ -554,7 +552,6 @@ var Requester = class {
|
|
|
554
552
|
const sdkUserAgent = this.getSdkUserAgent();
|
|
555
553
|
const baseHeaders = {
|
|
556
554
|
"Content-Type": "application/json",
|
|
557
|
-
[LIGHTSPARK_BETA_HEADER_KEY]: LIGHTSPARK_BETA_HEADER_VALUE,
|
|
558
555
|
"X-Lightspark-SDK": sdkUserAgent,
|
|
559
556
|
"User-Agent": browserUserAgent || sdkUserAgent
|
|
560
557
|
};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -807,9 +807,13 @@ function errorToJSON(err) {
|
|
|
807
807
|
if (!err) {
|
|
808
808
|
return null;
|
|
809
809
|
}
|
|
810
|
-
if (typeof err === "object" &&
|
|
810
|
+
if (typeof err === "object" && "toJSON" in err && typeof err.toJSON === "function") {
|
|
811
811
|
return err.toJSON();
|
|
812
812
|
}
|
|
813
|
+
if (typeof err === "object" && /* This happens for certain errors like DOMException: */
|
|
814
|
+
Object.getOwnPropertyNames(err).length === 0 && "message" in err && typeof err.message === "string") {
|
|
815
|
+
return { message: err.message };
|
|
816
|
+
}
|
|
813
817
|
return JSON.parse(
|
|
814
818
|
JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
815
819
|
);
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-
|
|
1
|
+
export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-2708d41b.js';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-
|
|
1
|
+
export { W as ById, k as CurrencyAmountArg, j as CurrencyAmountObj, f as CurrencyAmountType, M as CurrencyCodes, L as CurrencyLocales, i as CurrencyMap, e as CurrencyUnit, Z as DeepPartial, V as ExpandRecursively, _ as JSONLiteral, a0 as JSONObject, $ as JSONType, U as Maybe, a1 as NN, X as OmitTypename, 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, m as isCurrencyAmount, l as isCurrencyAmountObj, o as isCurrencyMap, x as isError, A as isErrorMsg, y as isErrorWithMessage, v as isNode, R as isNumber, w as isTest, Y as isType, P as linearInterpolate, N as localeToCurrencyCode, r as localeToCurrencySymbol, n as mapCurrencyAmount, S as pollUntil, Q as round, s as separateCurrencyStrParts, H as setLocalStorageBoolean, T as sleep, u as urlsafe_b64decode } from '../index-2708d41b.js';
|
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -21,9 +21,6 @@ import { b64encode } from "../utils/base64.js";
|
|
|
21
21
|
import { isNode } from "../utils/environment.js";
|
|
22
22
|
|
|
23
23
|
const DEFAULT_BASE_URL = "api.lightspark.com";
|
|
24
|
-
export const LIGHTSPARK_BETA_HEADER_KEY = "X-Lightspark-Beta";
|
|
25
|
-
export const LIGHTSPARK_BETA_HEADER_VALUE =
|
|
26
|
-
"z2h0BBYxTA83cjW7fi8QwWtBPCzkQKiemcuhKY08LOo";
|
|
27
24
|
dayjs.extend(utc);
|
|
28
25
|
|
|
29
26
|
type BodyData = {
|
|
@@ -150,7 +147,6 @@ class Requester {
|
|
|
150
147
|
const sdkUserAgent = this.getSdkUserAgent();
|
|
151
148
|
const baseHeaders = {
|
|
152
149
|
"Content-Type": "application/json",
|
|
153
|
-
[LIGHTSPARK_BETA_HEADER_KEY]: LIGHTSPARK_BETA_HEADER_VALUE,
|
|
154
150
|
"X-Lightspark-SDK": sdkUserAgent,
|
|
155
151
|
"User-Agent": browserUserAgent || sdkUserAgent,
|
|
156
152
|
};
|
package/src/utils/errors.ts
CHANGED
|
@@ -43,12 +43,22 @@ export function errorToJSON(err: unknown) {
|
|
|
43
43
|
}
|
|
44
44
|
if (
|
|
45
45
|
typeof err === "object" &&
|
|
46
|
-
err !== null &&
|
|
47
46
|
"toJSON" in err &&
|
|
48
47
|
typeof err.toJSON === "function"
|
|
49
48
|
) {
|
|
50
49
|
return err.toJSON() as JSONType;
|
|
51
50
|
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
typeof err === "object" &&
|
|
54
|
+
/* This happens for certain errors like DOMException: */
|
|
55
|
+
Object.getOwnPropertyNames(err).length === 0 &&
|
|
56
|
+
"message" in err &&
|
|
57
|
+
typeof err.message === "string"
|
|
58
|
+
) {
|
|
59
|
+
return { message: err.message };
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
return JSON.parse(
|
|
53
63
|
JSON.stringify(err, Object.getOwnPropertyNames(err)),
|
|
54
64
|
) as JSONType;
|
package/src/utils/types.ts
CHANGED
|
@@ -31,3 +31,5 @@ export type DeepPartial<T> = T extends object
|
|
|
31
31
|
export type JSONLiteral = string | number | boolean | null;
|
|
32
32
|
export type JSONType = JSONLiteral | JSONType[] | { [key: string]: JSONType };
|
|
33
33
|
export type JSONObject = { [key: string]: JSONType };
|
|
34
|
+
|
|
35
|
+
export type NN<T> = NonNullable<T>;
|