Skip to content

Commit

Permalink
fix: add interface for catalogContent
Browse files Browse the repository at this point in the history
[CIUG-791]
  • Loading branch information
mogagnon authored Mar 19, 2024
1 parent bdc96cf commit ea03e8f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/resources/Catalogs/CatalogContent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import API from '../../APICore.js';
import Resource from '../Resource.js';
import {CatalogMetadata, CatalogMetadataName} from './CatalogInterfaces.js';

export type ObjectType = {
objectType: string;
Expand All @@ -9,14 +10,18 @@ export default class CatalogContent extends Resource {
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/catalogcontent/source`;

getObjectTypes(sourceId: string) {
return this.api.get(`${CatalogContent.baseUrl}/${sourceId}/objecttypes`);
return this.api.get<string[]>(`${CatalogContent.baseUrl}/${sourceId}/objecttypes`);
}

getMetadataValues(sourceId: string, objectType: ObjectType) {
return this.api.get(this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadatavalues`, objectType));
return this.api.get<CatalogMetadata>(
this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadatavalues`, objectType),
);
}

getMetadata(sourceId: string, objectType: ObjectType) {
return this.api.get(this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, objectType));
return this.api.get<CatalogMetadataName>(
this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, objectType),
);
}
}
16 changes: 16 additions & 0 deletions src/resources/Catalogs/CatalogInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,19 @@ export interface CatalogFieldStatsOptions {
*/
forceRefresh?: boolean;
}

export interface CatalogMetadata {
/**
* Metadata seen on catalog documents with a sample of values.
*/
metadataValuesByName: {
[name: string]: string[];
};
}

export interface CatalogMetadataName {
/**
* Metadata name seen on catalog documents.
*/
metadataNames: string[];
}

0 comments on commit ea03e8f

Please sign in to comment.