Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.2 KB
Raw Blame
import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types';
import queryString from 'query-string';
import { buildV1Url } from 'services/api';

import type { ImageDTO, ListGalleryItemsArgs, ListImagesArgs, ListVideosArgs } from './types';

export const getCategories = (imageDTO: ImageDTO) => {
  if (IMAGE_CATEGORIES.includes(imageDTO.image_category)) {
    return IMAGE_CATEGORIES;
  }
  return ASSETS_CATEGORIES;
};

// Helper to create the url for the listImages endpoint. Also we use it to create the cache key.
export const getListImagesUrl = (queryArgs: ListImagesArgs) =>
  buildV1Url(`images/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`);

// Helper to create the url for the listVideos endpoint. Also we use it to create the cache key.
export const getListVideosUrl = (queryArgs: ListVideosArgs) =>
  buildV1Url(`videos/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`);

// Helper to create the url for the polymorphic listGalleryItems endpoint.
export const getListGalleryItemsUrl = (queryArgs: ListGalleryItemsArgs) =>
  buildV1Url(`gallery/items/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`);