/**
 * @aurora-catalyst-generated
 * @source cliter/iam/bounded-context.aurora.yaml
 */
import { type ResolveFn } from '@angular/router';
import {
  buildSortOrder,
  DEFAULT_PAGE_SIZE,
  queryFindById,
  queryPaginate,
  type DataTableData,
} from '@aurora';
import { type IamBoundedContext } from '@src/src/app/aurora.types';
import { BOUNDED_CONTEXT_DETAIL_CONFIG } from './bounded-context.detail-config';
import { BOUNDED_CONTEXT_LIST_CONFIG } from './bounded-context.list-config';
export const boundedContextListResolver: ResolveFn<DataTableData<IamBoundedContext>> = () => {
  const { queryPagination, paginationKey, fields } = BOUNDED_CONTEXT_LIST_CONFIG;
  return queryPaginate<IamBoundedContext>(queryPagination, paginationKey, fields, {
    query: {
      offset: 0,
      limit: DEFAULT_PAGE_SIZE,
      order: buildSortOrder([]),
    },
  });
};

export const boundedContextNewResolver: ResolveFn<boolean> = () => {
  return true;
};

export const boundedContextDetailResolver: ResolveFn<IamBoundedContext | null> = (route) => {
  const id = route.paramMap.get('id');
  if (!id) return null;
  const { queryObject, objectKey, fields } = BOUNDED_CONTEXT_DETAIL_CONFIG;
  return queryFindById<IamBoundedContext>(queryObject, objectKey, id, fields);
};
