Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new paged metadataNames call #837

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/resources/Catalogs/CatalogContent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import API from '../../APICore.js';
import Resource from '../Resource.js';
import {CatalogMetadata, CatalogMetadataName, CatalogObjectType} from './CatalogInterfaces.js';
import {MetadataPageModel} from '../Sources/index.js';
import {
CatalogMetadata,
CatalogMetadataName,
CatalogMetadataNameParams,
CatalogObjectType,
} from './CatalogInterfaces.js';

export type ObjectType = {
objectType: string;
Expand All @@ -24,4 +30,10 @@ export default class CatalogContent extends Resource {
this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, objectType),
);
}

getMetadataV2(sourceId: string, params?: CatalogMetadataNameParams) {
return this.api.get<MetadataPageModel>(
this.buildPath(`${CatalogContent.baseUrl}/${sourceId}/metadata`, params),
cjun-coveo marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
18 changes: 18 additions & 0 deletions src/resources/Catalogs/CatalogInterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {Paginated} from '../BaseInterfaces.js';

export interface CatalogsListOptions {
/**
* Filter that will be matched against the catalog name, description and its configuration name.
Expand Down Expand Up @@ -457,3 +459,19 @@ export interface CatalogMetadataName {
*/
metadataNames: string[];
}

export interface CatalogMetadataNameParams extends Paginated {
/**
* Object type parameter.
*/
objectType: string;
/**
* Filters applied to the returned metadata. Only applies to metadata names, not values or origins.
*/
filter?: string;

/**
* Indicate the version of MetadataName call
*/
version?: number;
}
22 changes: 22 additions & 0 deletions src/resources/Catalogs/tests/CatalogContent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import API from '../../../APICore.js';
import CatalogContent, {ObjectType} from '../CatalogContent.js';
import {CatalogMetadataNameParams} from '../CatalogInterfaces.js';
import queryString from '#query-string';

jest.mock('../../../APICore.js');
Expand Down Expand Up @@ -55,4 +56,25 @@ describe('CatalogContent', () => {
);
});
});

describe('getMetadataV2', () => {
it('should make a GET call to the specific metadataName url', () => {
const defaultOptions: queryString.StringifyOptions = {skipEmptyString: true, skipNull: true, sort: false};
const sourceId = 'KFC';

const params: CatalogMetadataNameParams = {
objectType: 'provigo',
filter: 'a',
version: 2,
page: 0,
perPage: 100,
};

metadata.getMetadataV2(sourceId, params);
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(
`${baseUrl}/${sourceId}/metadata?${queryString.stringify(params, {...defaultOptions})}`,
);
});
});
});