UNPKG

@altostra/core

Version:

Core library for shared types and logic

21 lines (20 loc) 1.3 kB
import type { EntityId } from "../../common/CustomTypes/EntityId"; import type { Name } from "../../common/Models/Name"; export interface ItemById { id: EntityId; } export interface ItemByName { name: Name; } export declare type ItemSelection = ItemById | ItemByName; export declare const isItemById: import("@altostra/type-validations").ObjectOfTypeValidation<ItemById>; export declare const isItemByName: import("@altostra/type-validations").ObjectOfTypeValidation<ItemByName>; export declare const isItemSelection: import("@altostra/type-validations").TypeValidation<ItemById | ItemByName>; export declare const queryByParamName = "query-by"; export declare type QueryByParamName = typeof queryByParamName; export declare type QueryByType = 'id' | 'name'; export declare function selectionQueryParam(itemSelection: ItemSelection): Record<string, QueryByType>; export declare type ItemSelectionValue<T extends ItemSelection> = T extends ItemById ? EntityId : T extends ItemByName ? Name : ItemSelection[keyof ItemSelection]; export declare function selectionValue<T extends ItemSelection>(selection: T): ItemSelectionValue<T>; export declare function appendUrlQuery(url: string, query?: Record<string, string>): string; export declare function printSelection(selection: ItemSelection): string;