packageDocumentation module import { CompressedId64Set , Id64String } from "@itwin/core-bentley" ; public export enum VariableValueTypes { /** Integer value */ Int = "int" , /** Array of integer values */ IntArray = "int[]" , /** Boolean value */ Bool = "bool" , /** String value */ String = "string" , /** Id64String value */ Id64 = "id64" , /** Array of Id64String values */ Id64Array = "id64[]" } public export type VariableValue = boolean | string | number | number [ ] | Id64String | Id64String [ ] ; public export type VariableValueJSON = boolean | string | number | number [ ] | Id64String | Id64String [ ] | CompressedId64Set ; public export interface RulesetVariableBase { id : string ; type : VariableValueTypes ; value : VariableValue ; } public export interface BooleanRulesetVariable extends RulesetVariableBase { type : VariableValueTypes . Bool ; value : boolean ; } public export interface StringRulesetVariable extends RulesetVariableBase { type : VariableValueTypes . String ; value : string ; } public export interface IntRulesetVariable extends RulesetVariableBase { type : VariableValueTypes . Int ; value : number ; } public export interface IntsRulesetVariable extends RulesetVariableBase { type : VariableValueTypes . IntArray ; value : number [ ] ; } public export interface Id64RulesetVariable extends RulesetVariableBase { type : VariableValueTypes . Id64 ; value : Id64String ; } public export interface Id64sRulesetVariable extends RulesetVariableBase { type : VariableValueTypes . Id64Array ; value : Id64String [ ] ; } public export type RulesetVariable = BooleanRulesetVariable | StringRulesetVariable | IntRulesetVariable | IntsRulesetVariable | Id64RulesetVariable | Id64sRulesetVariable ; public export interface RulesetVariableBaseJSON { id : string ; type : VariableValueTypes ; value : VariableValueJSON ; } public export interface BooleanRulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . Bool ; value : boolean ; } public export interface StringRulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . String ; value : string ; } public export interface IntRulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . Int ; value : number ; } public export interface IntsRulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . IntArray ; value : number [ ] ; } public export interface Id64RulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . Id64 ; value : Id64String ; } public export interface Id64sRulesetVariableJSON extends RulesetVariableBaseJSON { type : VariableValueTypes . Id64Array ; value : Id64String [ ] | CompressedId64Set ; } public export type RulesetVariableJSON = BooleanRulesetVariableJSON | StringRulesetVariableJSON | IntRulesetVariableJSON | IntsRulesetVariableJSON | Id64RulesetVariableJSON | Id64sRulesetVariableJSON ; public export namespace RulesetVariable { /**
     * Serialize given RulesetVariable to JSON.
     * Note: In case of [[Id64sRulesetVariable]], this method expects IDs are sorted. See [[OrderedId64Iterable.sortArray]].
     */ export function toJSON ( variable ) { if ( variable . type === VariableValueTypes . Id64Array ) return { ... variable , value : CompressedId64Set . compressArray ( variable . value ) } ; return variable ; } /** Deserialize [[RulesetVariable]] from JSON. */ export function fromJSON ( json ) { if ( json . type === VariableValueTypes . Id64Array ) { if ( typeof json . value === "string" ) return { ... json , value : CompressedId64Set . decompressArray ( json . value ) } ; return json as any ; } return json ; } }