diff --git a/src/resources/Catalogs/CatalogContent.ts b/src/resources/Catalogs/CatalogContent.ts index 625a2a44a..86578aa91 100644 --- a/src/resources/Catalogs/CatalogContent.ts +++ b/src/resources/Catalogs/CatalogContent.ts @@ -1,14 +1,24 @@ import API from '../../APICore.js'; import Resource from '../Resource.js'; -import {CatalogMetadata, CatalogMetadataName} from './CatalogInterfaces.js'; +import {CatalogMetadata, CatalogMetadataName, CatalogObjectType} from './CatalogInterfaces.js'; export type ObjectType = { objectType: string; }; +export type Version = { + version: number; +}; + export default class CatalogContent extends Resource { static baseUrl = `/rest/organizations/${API.orgPlaceholder}/catalogcontent/source`; + getObjectTypeV2(sourceId: string, version: Version) { + return this.api.get( + this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/objecttypes`, version), + ); + } + getObjectTypes(sourceId: string) { return this.api.get(`${CatalogContent.baseUrl}/${sourceId}/objecttypes`); } diff --git a/src/resources/Catalogs/CatalogInterfaces.ts b/src/resources/Catalogs/CatalogInterfaces.ts index 4a231af7f..5771291d9 100644 --- a/src/resources/Catalogs/CatalogInterfaces.ts +++ b/src/resources/Catalogs/CatalogInterfaces.ts @@ -431,6 +431,17 @@ export interface CatalogFieldStatsOptions { forceRefresh?: boolean; } +export interface CatalogObjectType { + /** + * If catalog content exist in source + */ + hasCatalogContent: boolean; + /** + * Object type values seen on catalog content + */ + objectTypeValues: string[]; +} + export interface CatalogMetadata { /** * Metadata seen on catalog documents with a sample of values. diff --git a/src/resources/Catalogs/tests/CatalogContent.spec.ts b/src/resources/Catalogs/tests/CatalogContent.spec.ts index abcb722ca..65908995c 100644 --- a/src/resources/Catalogs/tests/CatalogContent.spec.ts +++ b/src/resources/Catalogs/tests/CatalogContent.spec.ts @@ -18,6 +18,20 @@ describe('CatalogContent', () => { metadata = new CatalogContent(api, serverlessApi); }); + describe('getObjectTypeV2', () => { + it('should make a GET call to the specific CatalogContent url', () => { + const defaultOptions: queryString.StringifyOptions = {skipEmptyString: true, skipNull: true, sort: false}; + const sourceId = 'McDonald'; + const version = {version: 2}; + + metadata.getObjectTypeV2(sourceId, version); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith( + `${baseUrl}/${sourceId}/objecttypes?${queryString.stringify(version, {...defaultOptions})}`, + ); + }); + }); + describe('getObjectTypes', () => { it('should make a GET call to the specific CatalogContent url', () => { const sourceId = 'McDonald';