@@ -11,7 +11,9 @@ import type {
1111/** Unmarshals {@link Money} */
1212export const unmarshalMoney = ( data : unknown ) => {
1313 if ( ! isJSONObject ( data ) ) {
14- throw new TypeError ( `Expected input isn't a dictionary.` )
14+ throw new TypeError (
15+ `Unmarshalling the type 'Money' failed as data isn't a dictionary.` ,
16+ )
1517 }
1618
1719 return {
@@ -28,7 +30,9 @@ export const unmarshalMoney = (data: unknown) => {
2830 */
2931export const unmarshalServiceInfo = ( data : unknown ) => {
3032 if ( ! isJSONObject ( data ) ) {
31- throw new TypeError ( `Expected input isn't a dictionary.` )
33+ throw new TypeError (
34+ `Unmarshalling the type 'ServiceInfo' failed as data isn't a dictionary.` ,
35+ )
3236 }
3337
3438 return {
@@ -46,7 +50,9 @@ export const unmarshalServiceInfo = (data: unknown) => {
4650 */
4751export const unmarshalScwFile = ( data : unknown ) => {
4852 if ( ! isJSONObject ( data ) ) {
49- throw new TypeError ( `Expected input isn't a dictionary.` )
53+ throw new TypeError (
54+ `Unmarshalling the type 'ScwFile' failed as data isn't a dictionary.` ,
55+ )
5056 }
5157
5258 return {
@@ -59,16 +65,22 @@ export const unmarshalScwFile = (data: unknown) => {
5965/**
6066 * Unmarshals {@link TimeSeriesPoint}
6167 *
68+ * @remarks To optimize the size of this message,
69+ * the JSON is compressed in an array instead of a dictionary.
70+ * Example: `["2019-08-08T15:00:00Z", 0.2]`.
71+ *
6272 * @internal
6373 */
6474export const unmarshalTimeSeriesPoint = ( data : unknown ) => {
65- if ( ! isJSONObject ( data ) ) {
66- throw new TypeError ( `Expected input isn't a dictionary.` )
75+ if ( ! Array . isArray ( data ) ) {
76+ throw new TypeError (
77+ `Unmarshalling the type 'TimeSeriesPoint' failed as data isn't an array.` ,
78+ )
6779 }
6880
6981 return {
70- timestamp : unmarshalDate ( data . timestamp ) ,
71- value : data . value ,
82+ timestamp : unmarshalDate ( data [ 0 ] ) ,
83+ value : data [ 1 ] as number ,
7284 } as TimeSeriesPoint
7385}
7486
@@ -79,7 +91,9 @@ export const unmarshalTimeSeriesPoint = (data: unknown) => {
7991 */
8092export const unmarshalTimeSeries = ( data : unknown ) => {
8193 if ( ! isJSONObject ( data ) ) {
82- throw new TypeError ( `Expected input isn't a dictionary.` )
94+ throw new TypeError (
95+ `Unmarshalling the type 'TimeSeries' failed as data isn't a dictionary.` ,
96+ )
8397 }
8498
8599 return {
0 commit comments