UNPKG

ibm-appconfiguration-js-client-sdk

Version:
87 lines (86 loc) 3.37 kB
/** * Copyright 2022 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { IPropertySegmentRule } from './PropertySegmentRule'; export interface IProperty { name: string; property_id: string; type: string; format?: string; value: any; segment_rules: IPropertySegmentRule[]; } export default class Property { private name; private property_id; private type; private format; private value; private segment_rules; constructor({ name, property_id, type, format, value, segment_rules, }: IProperty); /** * Get the Property name. * * @return {*} {string} The Property name. * @memberof Property */ getPropertyName(): string; /** * Get the Property id. * * @return {*} {string} The Property Id. * @memberof Property */ getPropertyId(): string; /** * Get the Property data type. * * @return {*} {string} string named BOOLEAN/STRING/NUMERIC. * @memberof Property */ getPropertyDataType(): string; /** * Get the Property data format. * Applicable only for STRING datatype property. * * @return {*} {(string | undefined)} string named TEXT/JSON/YAML. * @memberof Property */ getPropertyDataFormat(): string | undefined; /** * Get the evaluated value of the property. * * @param {string} entityId - Id of the Entity. * This will be a string identifier related to the Entity against which the property is evaluated. * For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. * For any entity to interact with App Configuration, it must provide a unique entity ID. * * @param {{ [x: string]: any; }} entityAttributes - A JSON object consisting of the attribute name and their values that defines the specified entity. * This is an optional parameter if the property is not configured with any targeting definition. If the targeting is configured, then entityAttributes should be provided for the rule evaluation. * An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine if the * specified entity satisfies the targeting rules, and returns the appropriate property value. * * @return {*} {*} Returns the default property value or its overridden value based on the evaluation. * The data type of returned value matches that of property. * @memberof Property */ getCurrentValue(entityId: string, entityAttributes?: { [x: string]: any; }): any; private propertyEvaluation; private parseRules; private evaluateRules; private evaluateSegment; }