knowmax-quest-utils
Version:
Utilities for creating a Knowmax Quest client.
50 lines • 3.22 kB
TypeScript
import type { IMetadata } from 'knowmax-quest-types';
import { MetadataOrigin } from 'knowmax-quest-types';
/** Match given IMetadata value with given label specification.
* @param metadata value to evaluate.
* @param labelOrFamilyWithLabel Either string or array of strings which should be evaluated. Allowed formats: 'familylabel:label' and 'label'. In case of array, a match is considered if at least one value matches.
* @param origin Optional origin to match.
* @returns Boolean indicating match.
*/
export declare const metadataMatch: (metadata: IMetadata, labelOrFamilyWithLabel: string | string[], origin?: MetadataOrigin) => boolean;
/** Parse optional family label and label from given label.
* @param label Allowed format: 'familylabel:label' and 'label'
* @returns Object containing optional familyLabel and label.
*/
export declare const parseMetadataLabel: (label: string) => {
family?: string;
label: string;
};
/** Combine family label and label. */
export declare const formatMetadataLabel: (familyLabel: string, label: string) => string;
/** Get first value from metadata matching family label and label. Returns undefined in case value not found. */
export declare const metadataValue: (familyLabel: string, label: string, list?: IMetadata[]) => string | undefined;
/** Get array with all values matching family label and label. Returns empty array in case no values found. */
export declare const metadataValues: (familyLabel: string, label: string, list?: IMetadata[]) => string[];
/** Format given prefix value in given value by convention "[prefix]value". */
export declare const formatMetadataValueWithPrefix: (value: string, prefix: string) => string;
/** Format given postfix value in given value by convention "value[postfix]" */
export declare const formatMetadataValueWithPostfix: (value: string, postfix: string) => string;
/** Parses prefix by convention using [prefix] from metadata value.
* @param value Metadata value to parse. Prefix formatted like [text] at beginning of value.
* @returns Tuple containing value and optional prefix.
*/
export declare const parseMetadataValueWithPrefix: (value: string) => [string, string?];
/** Parses postfix by convention using [postfix] from metadata value.
* @param value Metadata value to parse. Postfix formatted like [text] at end of value.
* @returns Tuple containing value and optional postfix.
*/
export declare const parseMetadataValueWithPostfix: (value: string) => [string, string?];
/** Parses pair id and value from metadata values with pair id.
* @param value Metadata value to parse. Pair id formatted like [number] at beginning of value.
* @returns Tuple containing value and optional numeric pair id.
*/
export declare const parseMetadataValueWithPairId: (value: string) => [string, number?];
/** Parses list of IMetadata with pair id specified into IMetadata type expaned with pairId.
* @param data List of IMetadata to parse.
* @returns List of IMetadata extended numeric with pair id. Values without or invalid pair id are filtered out.
*/
export declare const parseMetadataValueListWithPairId: (data: IMetadata[]) => (IMetadata & {
pairId: number;
})[];
//# sourceMappingURL=metadata.d.ts.map