UNPKG

@itwin/presentation-common

Version:

Common pieces for iModel.js presentation packages

58 lines 2.42 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Core */ Object.defineProperty(exports, "__esModule", { value: true }); exports.RulesetVariable = exports.VariableValueTypes = void 0; const core_bentley_1 = require("@itwin/core-bentley"); /** * Possible variable value types * @public */ var VariableValueTypes; (function (VariableValueTypes) { /** Integer value */ VariableValueTypes["Int"] = "int"; /** Array of integer values */ VariableValueTypes["IntArray"] = "int[]"; /** Boolean value */ VariableValueTypes["Bool"] = "bool"; /** String value */ VariableValueTypes["String"] = "string"; /** Id64String value */ VariableValueTypes["Id64"] = "id64"; /** Array of Id64String values */ VariableValueTypes["Id64Array"] = "id64[]"; })(VariableValueTypes || (exports.VariableValueTypes = VariableValueTypes = {})); /** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare var RulesetVariable; (function (RulesetVariable) { /** * Serialize given RulesetVariable to JSON. * Note: In case of [[Id64sRulesetVariable]], this method expects IDs are sorted. See [[OrderedId64Iterable.sortArray]]. */ function toJSON(variable) { if (variable.type === VariableValueTypes.Id64Array) { return { ...variable, value: core_bentley_1.CompressedId64Set.compressArray(variable.value) }; } return variable; } RulesetVariable.toJSON = toJSON; /** Deserialize [[RulesetVariable]] from JSON. */ function fromJSON(json) { if (json.type === VariableValueTypes.Id64Array) { if (typeof json.value === "string") { return { ...json, value: core_bentley_1.CompressedId64Set.decompressArray(json.value) }; } return json; // for some reason TS doesn't understand that `json.value` is always an array here } return json; } RulesetVariable.fromJSON = fromJSON; })(RulesetVariable || (exports.RulesetVariable = RulesetVariable = {})); //# sourceMappingURL=RulesetVariables.js.map