All files / lib/libs/api/package getPackage.ts

85.71% Statements 6/7
100% Branches 0/0
66.66% Functions 2/3
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                    37x       116x 115x     37x 116x   37x    
import * as os from "libs/opensearch-lib";
import { BaseIndex } from "shared-types/opensearch";
import type { ItemResult } from "shared-types/opensearch/main";
 
import { getDomainAndNamespace } from "../../utils";
 
export interface ExtendedItemResult extends ItemResult {
  appkChildren?: Omit<ItemResult, "found">[];
}
 
const getPackageByIndex = async (
  id: string,
  baseIndex: BaseIndex,
): Promise<ItemResult | undefined> => {
  const { domain, index } = getDomainAndNamespace(baseIndex);
  return await os.getItem(domain, index, id);
};
 
export const getPackage = async (id: string): Promise<ItemResult | undefined> =>
  getPackageByIndex(id, "main");
 
export const getDraftPackage = async (id: string): Promise<ItemResult | undefined> =>
  getPackageByIndex(id, "draftmain");