packageDocumentation module public export interface LabelCompositeValue { separator : string ; values : LabelDefinition [ ] ; } public export interface LabelCompositeValueJSON { separator : string ; values : LabelDefinitionJSON [ ] ; } public export namespace LabelCompositeValue { /** Serialize given [[LabelCompositeValue]] to JSON */ export function toJSON ( compositeValue ) { return { ... compositeValue , values : compositeValue . values . map ( LabelDefinition . toJSON ) } ; } /** Deserialize [[LabelCompositeValue]] from JSON */ export function fromJSON ( json ) { return { ... json , values : json . values . map ( LabelDefinition . fromJSON ) } ; } } public export type LabelRawValue = string | number | boolean | LabelCompositeValue ; public export type LabelRawValueJSON = string | number | boolean | LabelCompositeValueJSON ; public export interface LabelDefinition { /** Display value of label */ displayValue : string ; /** Raw value of label */ rawValue : LabelRawValue ; /** Type name of raw value */ typeName : string ; } public export interface LabelDefinitionJSON { displayValue : string ; rawValue : LabelRawValueJSON ; typeName : string ; } public export namespace LabelDefinition { /** Serialize given [[LabelDefinition]] to JSON */ export function toJSON ( labelDefinition ) { return { displayValue : labelDefinition . displayValue , typeName : labelDefinition . typeName , rawValue : isCompositeDefinition ( labelDefinition ) ? LabelCompositeValue . toJSON ( labelDefinition . rawValue ) : labelDefinition . rawValue } ; } /** Deserialize [[LabelDefinition]] from JSON */ export function fromJSON ( json ) { if ( typeof json === "string" ) return JSON . parse ( json , reviver ) ; return { ... json , rawValue : isCompositeDefinition ( json ) ? LabelCompositeValue . fromJSON ( json . rawValue ) : json . rawValue } ; } internal export const COMPOSITE_DEFINITION_TYPENAME = "composite" ; internal export function reviver ( key , value ) { return key === "" ? fromJSON ( value ) : value ; } internal export function isCompositeDefinition ( def ) { return def . typeName === COMPOSITE_DEFINITION_TYPENAME ; } internal export function fromLabelString ( label ) { return { displayValue : label , rawValue : label , typeName : "string" } ; } }