import { PostSort } from "../../../discussions/api/enums/postSort";
import { SortOrder } from "../../../discussions/api/enums/sortOrder";
/**
 * A map of HubSearchPostSortFields to PostSort
 */
const SORT_BY_MAP = {
    body: PostSort.BODY,
    channelId: PostSort.CHANNEL_ID,
    created: PostSort.CREATED_AT,
    modified: PostSort.UPDATED_AT,
    owner: PostSort.CREATOR,
    discussion: PostSort.DISCUSSION,
    editor: PostSort.EDITOR,
    id: PostSort.ID,
    parentId: PostSort.PARENT_ID,
    status: PostSort.STATUS,
    title: PostSort.TITLE,
};
const SORT_ORDER_MAP = {
    desc: SortOrder.DESC,
    asc: SortOrder.ASC,
};
/**
 * Builds a Partial<ISearchPosts> for the given IHubSearchOptions
 * @param options An IHubSearchOptions object
 * @returns a Partial<ISearchPosts> for the given IHubSearchOptions
 */
export function processPostOptions(options) {
    const processedOptions = {};
    // num
    if (options.num > 0) {
        processedOptions.num = options.num;
    }
    // start
    if (options.start > 1) {
        processedOptions.start = options.start;
    }
    // sort order
    if (options.sortOrder && SORT_ORDER_MAP[options.sortOrder]) {
        processedOptions.sortOrder = SORT_ORDER_MAP[options.sortOrder];
    }
    // sort field
    const sortField = SORT_BY_MAP[options.sortField];
    if (sortField) {
        processedOptions.sortBy = sortField;
    }
    return processedOptions;
}
//# sourceMappingURL=processPostOptions.js.map