Enterprise-CMCS/macpro-mako

View on GitHub
lib/libs/api/package/appk.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import * as os from "../../opensearch-lib";
import { opensearch } from "shared-types";

export const getAppkChildren = async (
  packageId: string,
  filter: any[] = [],
) => {
  if (!process.env.osDomain) {
    throw new Error("process.env.osDomain must be defined");
  }

  const response = (await os.search(
    process.env.osDomain,
    `${process.env.indexNamespace}main`,
    {
      from: 0,
      size: 200,
      query: {
        bool: {
          must: [{ term: { "appkParentId.keyword": packageId } }].concat(
            filter,
          ),
        },
      },
    },
  )) as opensearch.main.Response;

  return response;
};