|
1 | | -import { searchV2EmptyApi as api } from "./searchV2-empty.api"; |
2 | | -const injectedRtkApi = api.injectEndpoints({ |
| 1 | +/*! |
| 2 | + * Copyright 2025 - Swiss Data Science Center (SDSC) |
| 3 | + * A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and |
| 4 | + * Eidgenössische Technische Hochschule Zürich (ETHZ). |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +import { |
| 20 | + GetSearchQueryApiArg, |
| 21 | + GetSearchQueryApiResponse, |
| 22 | + searchV2GeneratedApi, |
| 23 | +} from "./searchV2Api.generated-api"; |
| 24 | + |
| 25 | +// Fixes some API endpoints |
| 26 | +export const searchV2Api = searchV2GeneratedApi.injectEndpoints({ |
| 27 | + overrideExisting: true, |
3 | 28 | endpoints: (build) => ({ |
4 | | - getQuery: build.query<GetQueryApiResponse, GetQueryApiArg>({ |
5 | | - query: (queryArg) => ({ |
6 | | - url: `/query`, |
7 | | - headers: { "Renku-Auth-Anon-Id": queryArg["Renku-Auth-Anon-Id"] }, |
8 | | - params: { |
9 | | - q: queryArg.q, |
10 | | - page: queryArg.page, |
11 | | - per_page: queryArg.perPage, |
12 | | - }, |
13 | | - }), |
14 | | - }), |
15 | | - getVersion: build.query<GetVersionApiResponse, GetVersionApiArg>({ |
16 | | - query: () => ({ url: `/version` }), |
17 | | - }), |
18 | | - $get: build.query<$getApiResponse, $getApiArg>({ |
19 | | - query: (queryArg) => ({ |
20 | | - url: `/`, |
21 | | - headers: { "Renku-Auth-Anon-Id": queryArg["Renku-Auth-Anon-Id"] }, |
22 | | - params: { |
23 | | - q: queryArg.q, |
24 | | - page: queryArg.page, |
25 | | - per_page: queryArg.perPage, |
26 | | - }, |
| 29 | + getSearchQuery: build.query< |
| 30 | + GetSearchQueryApiResponse, |
| 31 | + GetSearchQueryApiArg |
| 32 | + >({ |
| 33 | + query: ({ params }) => ({ |
| 34 | + url: "/search/query", |
| 35 | + params, |
27 | 36 | }), |
28 | 37 | }), |
29 | 38 | }), |
30 | | - overrideExisting: false, |
31 | 39 | }); |
32 | | -export { injectedRtkApi as searchV2Api }; |
33 | | -export type GetQueryApiResponse = /** status 200 */ SearchResult; |
34 | | -export type GetQueryApiArg = { |
35 | | - "Renku-Auth-Anon-Id"?: string; |
36 | | - /** User defined search query */ |
37 | | - q?: string; |
38 | | - /** The page to retrieve, starting at 1 */ |
39 | | - page?: number; |
40 | | - /** How many items to return for one page */ |
41 | | - perPage?: number; |
42 | | -}; |
43 | | -export type GetVersionApiResponse = /** status 200 */ CurrentVersion; |
44 | | -export type GetVersionApiArg = void; |
45 | | -export type $getApiResponse = /** status 200 */ SearchResult; |
46 | | -export type $getApiArg = { |
47 | | - "Renku-Auth-Anon-Id"?: string; |
48 | | - /** User defined search query */ |
49 | | - q?: string; |
50 | | - /** The page to retrieve, starting at 1 */ |
51 | | - page?: number; |
52 | | - /** How many items to return for one page */ |
53 | | - perPage?: number; |
54 | | -}; |
55 | | -export type Group = { |
56 | | - id: string; |
57 | | - name: string; |
58 | | - namespace: string; |
59 | | - description?: string; |
60 | | - score?: number; |
61 | | - type: string; |
62 | | -}; |
63 | | -export type User = { |
64 | | - id: string; |
65 | | - namespace?: string; |
66 | | - firstName?: string; |
67 | | - lastName?: string; |
68 | | - score?: number; |
69 | | - type: string; |
70 | | -}; |
71 | | -export type UserOrGroup = |
72 | | - | ({ |
73 | | - type: "Group"; |
74 | | - } & Group) |
75 | | - | ({ |
76 | | - type: "User"; |
77 | | - } & User); |
78 | | -export type Visibility = "Private" | "Public"; |
79 | | -export type Project = { |
80 | | - id: string; |
81 | | - name: string; |
82 | | - slug: string; |
83 | | - namespace?: UserOrGroup; |
84 | | - repositories?: string[]; |
85 | | - visibility: Visibility; |
86 | | - description?: string; |
87 | | - createdBy?: User; |
88 | | - creationDate: string; |
89 | | - keywords?: string[]; |
90 | | - score?: number; |
91 | | - type: string; |
92 | | -}; |
93 | | -export type SearchEntity = |
94 | | - | ({ |
95 | | - type: "Group"; |
96 | | - } & Group) |
97 | | - | ({ |
98 | | - type: "Project"; |
99 | | - } & Project) |
100 | | - | ({ |
101 | | - type: "User"; |
102 | | - } & User); |
103 | | -export type MapEntityTypeInt = { |
104 | | - [key: string]: number; |
105 | | -}; |
106 | | -export type FacetData = { |
107 | | - entityType: MapEntityTypeInt; |
108 | | -}; |
109 | | -export type PageDef = { |
110 | | - limit: number; |
111 | | - offset: number; |
112 | | -}; |
113 | | -export type PageWithTotals = { |
114 | | - page: PageDef; |
115 | | - totalResult: number; |
116 | | - totalPages: number; |
117 | | - prevPage?: number; |
118 | | - nextPage?: number; |
119 | | -}; |
120 | | -export type SearchResult = { |
121 | | - items?: SearchEntity[]; |
122 | | - facets: FacetData; |
123 | | - pagingInfo: PageWithTotals; |
124 | | -}; |
125 | | -export type CurrentVersion = { |
126 | | - name: string; |
127 | | - version: string; |
128 | | - headCommit: string; |
129 | | - describedVersion: string; |
130 | | -}; |
131 | | -export const { useGetQueryQuery, useGetVersionQuery, use$getQuery } = |
132 | | - injectedRtkApi; |
| 40 | + |
| 41 | +export const { useGetSearchQueryQuery } = searchV2Api; |
| 42 | + |
| 43 | +export type * from "./searchV2Api.generated-api"; |
0 commit comments