@gooddata/sdk-model 11.51.0-alpha.3 → 11.51.0-alpha.5

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.
@@ -6,7 +6,7 @@
6
6
  * @internal
7
7
  */
8
8
  export const assertNever = (value) => {
9
- console.error(`Unhandled discriminated union member: ${value}`);
9
+ console.error(`Unhandled discriminated union member: ${safeStringify(value)}`);
10
10
  };
11
11
  /**
12
12
  * Throwing exhaustiveness check for discriminated unions: the `never` parameter fails the build on an
@@ -15,5 +15,21 @@ export const assertNever = (value) => {
15
15
  * @internal
16
16
  */
17
17
  export const throwUnexpected = (value) => {
18
- throw new Error(`Unexpected value: ${JSON.stringify(value)}`);
18
+ throw new Error(`Unexpected value: ${safeStringify(value)}`);
19
19
  };
20
+ /**
21
+ * JSON.stringify wrapper that never throws (e.g. on circular references, or values whose
22
+ * serialization/coercion hooks themselves throw), so logging an unexpected value can't
23
+ * itself crash the caller.
24
+ */
25
+ function safeStringify(value) {
26
+ try {
27
+ // JSON.stringify returns undefined (not a throw) for functions/symbols/undefined;
28
+ // String() covers those without risk, since we only reach it when JSON.stringify
29
+ // itself didn't throw.
30
+ return JSON.stringify(value) ?? String(value);
31
+ }
32
+ catch {
33
+ return "<unserializable value>";
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-model",
3
- "version": "11.51.0-alpha.3",
3
+ "version": "11.51.0-alpha.5",
4
4
  "description": "GoodData Model definitions used by UI components and Backend SPI",
5
5
  "license": "MIT",
6
6
  "author": "GoodData",
@@ -57,8 +57,8 @@
57
57
  "oxlint-tsgolint": "0.15.0",
58
58
  "typescript": "5.9.3",
59
59
  "vitest": "4.1.8",
60
- "@gooddata/eslint-config": "11.51.0-alpha.3",
61
- "@gooddata/oxlint-config": "11.51.0-alpha.3"
60
+ "@gooddata/eslint-config": "11.51.0-alpha.5",
61
+ "@gooddata/oxlint-config": "11.51.0-alpha.5"
62
62
  },
63
63
  "scripts": {
64
64
  "_phase:build": "npm run build",