@eclipse-scout/core
Version:
Eclipse Scout runtime
55 lines • 2.65 kB
TypeScript
/**
* Utility to parse id strings into their components and create qualified or unqualified strings from their components.
*/
export declare const idCodec: {
TYPE_NAME_DELIMITER: string;
COMPONENT_DELIMITER: string;
SIGNATURE_DELIMITER: string;
/**
* Parses the given id string into its parts. Automatically detects if the id is qualified or unqualified based on content.
* @param rawId The raw string to parse (mandatory).
* @param typeNameProvider An optional provider for the typeName. Called in case the id is unqualified to compute its typeName. Must return the corresponding typeName for the given id.
* @returns the parsed {@link IdInfo} or null if there is no value.
*/
parse<TTypeName extends string>(rawId: string, typeNameProvider?: () => TTypeName): IdInfo<TTypeName>;
/**
* Parses the given unqualified id string into its parts.
* @param value The raw string to parse (mandatory).
* @param typeName The typeName of the id.
* @returns the parsed {@link IdInfo} or null if there is no value.
*/
fromUnqualified<TTypeName_1 extends string>(value: string, typeName: TTypeName_1): IdInfo<TTypeName_1>;
/**
* Parses the given qualified id string into its parts.
* @param qualifiedId The string to parse including the typeName prefix.
* @returns the parsed {@link IdInfo} or null if there is no value.
*/
fromQualified<TTypeName_2 extends string>(qualifiedId: string): IdInfo<TTypeName_2>;
/**
* @returns the given {@link IdInfo} converted to its unqualified string representation. Unqualified means only value and signature are part of the result, the typeName is omitted. Returns null if there is no input.
*/
toUnqualified(id: IdInfo): string;
/**
* @returns the given {@link IdInfo} converted to its qualified string representation including typeName, value and signature. Returns null if there is no input.
*/
toQualified(id: IdInfo): string;
};
export interface IdInfo<TIdTypeName extends string = string> {
/**
* The typeName of the id. Typically, set using the @IdTypeName annotation on an IId instance on the Java backend.
*/
typeName?: TIdTypeName;
/**
* The full value of the id. If it has multiple elements (e.g. for composites) all elements are part of this value including the separators.
*/
value: string;
/**
* The elements of the id. These are the parts of the value split by their separator.
*/
elements?: string[];
/**
* The signature of the id.
*/
signature?: string;
}
//# sourceMappingURL=idCodec.d.ts.map