store: Update content-sources API schema

This adds `searchRpm` as a filtered endpoint.
This commit is contained in:
regexowl 2024-02-19 08:59:04 +01:00 committed by Lucas Garfield
parent ac4a0829e2
commit e955293538
2 changed files with 34 additions and 3 deletions

View file

@ -7,7 +7,7 @@ const config: ConfigFile = {
outputFile: '../../src/store/contentSourcesApi.ts', outputFile: '../../src/store/contentSourcesApi.ts',
exportName: 'contentSourcesApi', exportName: 'contentSourcesApi',
hooks: true, hooks: true,
filterEndpoints: ['listRepositories', 'listRepositoriesRpms'], filterEndpoints: ['listRepositories', 'listRepositoriesRpms', 'searchRpm'],
}; };
export default config; export default config;

View file

@ -39,6 +39,13 @@ const injectedRtkApi = api.injectEndpoints({
}, },
}), }),
}), }),
searchRpm: build.mutation<SearchRpmApiResponse, SearchRpmApiArg>({
query: (queryArg) => ({
url: `/rpms/names`,
method: "POST",
body: queryArg.apiContentUnitSearchRequest,
}),
}),
}), }),
overrideExisting: false, overrideExisting: false,
}); });
@ -89,6 +96,11 @@ export type ListRepositoriesRpmsApiArg = {
/** Sort the response based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */ /** Sort the response based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */
sortBy?: string; sortBy?: string;
}; };
export type SearchRpmApiResponse = /** status 200 OK */ ApiSearchRpmResponse[];
export type SearchRpmApiArg = {
/** request body */
apiContentUnitSearchRequest: ApiContentUnitSearchRequest;
};
export type ApiSnapshotResponse = { export type ApiSnapshotResponse = {
/** Count of each content type */ /** Count of each content type */
added_counts?: { added_counts?: {
@ -263,5 +275,24 @@ export type ApiRepositoryRpmCollectionResponse = {
links?: ApiLinks; links?: ApiLinks;
meta?: ApiResponseMetadata; meta?: ApiResponseMetadata;
}; };
export const { useListRepositoriesQuery, useListRepositoriesRpmsQuery } = export type ApiSearchRpmResponse = {
injectedRtkApi; /** Package name found */
package_name?: string;
/** Summary of the package found */
summary?: string;
};
export type ApiContentUnitSearchRequest = {
/** Maximum number of records to return for the search */
limit?: number;
/** Search string to search content unit names */
search?: string;
/** URLs of repositories to search */
urls?: string[];
/** List of RepositoryConfig UUIDs to search */
uuids?: string[];
};
export const {
useListRepositoriesQuery,
useListRepositoriesRpmsQuery,
useSearchRpmMutation,
} = injectedRtkApi;