@scm-manager/ui-api 2.33.1-20220411-113741 → 2.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ import {
30
30
  Repository,
31
31
  RepositoryCollection,
32
32
  RepositoryCreation,
33
- RepositoryTypeCollection,
33
+ RepositoryTypeCollection
34
34
  } from "@scm-manager/ui-types";
35
35
  import { useMutation, useQuery, useQueryClient } from "react-query";
36
36
  import { apiClient } from "./apiclient";
@@ -64,7 +64,7 @@ export const useRepositories = (request?: UseRepositoriesRequest): ApiResult<Rep
64
64
  }
65
65
  return useQuery<RepositoryCollection, Error>(
66
66
  ["repositories", request?.namespace?.namespace, request?.search || "", request?.page || 0],
67
- () => apiClient.get(`${link}?${createQueryString(queryParams)}`).then((response) => response.json()),
67
+ () => apiClient.get(`${link}?${createQueryString(queryParams)}`).then(response => response.json()),
68
68
  {
69
69
  enabled: !request?.disabled,
70
70
  onSuccess: (repositories: RepositoryCollection) => {
@@ -72,7 +72,7 @@ export const useRepositories = (request?: UseRepositoriesRequest): ApiResult<Rep
72
72
  repositories._embedded?.repositories.forEach((repository: Repository) => {
73
73
  queryClient.setQueryData(["repository", repository.namespace, repository.name], repository);
74
74
  });
75
- },
75
+ }
76
76
  }
77
77
  );
78
78
  };
@@ -90,14 +90,14 @@ const createRepository = (link: string) => {
90
90
  }
91
91
  return apiClient
92
92
  .post(createLink, request.repository, "application/vnd.scmm-repository+json;v=2")
93
- .then((response) => {
93
+ .then(response => {
94
94
  const location = response.headers.get("Location");
95
95
  if (!location) {
96
96
  throw new Error("Server does not return required Location header");
97
97
  }
98
98
  return apiClient.get(location);
99
99
  })
100
- .then((response) => response.json());
100
+ .then(response => response.json());
101
101
  };
102
102
  };
103
103
 
@@ -109,10 +109,10 @@ export const useCreateRepository = () => {
109
109
  const { mutate, data, isLoading, error } = useMutation<Repository, Error, CreateRepositoryRequest>(
110
110
  createRepository(link),
111
111
  {
112
- onSuccess: (repository) => {
112
+ onSuccess: repository => {
113
113
  queryClient.setQueryData(["repository", repository.namespace, repository.name], repository);
114
114
  return queryClient.invalidateQueries(["repositories"]);
115
- },
115
+ }
116
116
  }
117
117
  );
118
118
  return {
@@ -121,7 +121,7 @@ export const useCreateRepository = () => {
121
121
  },
122
122
  isLoading,
123
123
  error,
124
- repository: data,
124
+ repository: data
125
125
  };
126
126
  };
127
127
 
@@ -131,7 +131,7 @@ export const useRepositoryTypes = () => useIndexJsonResource<RepositoryTypeColle
131
131
  export const useRepository = (namespace: string, name: string): ApiResult<Repository> => {
132
132
  const link = useRequiredIndexLink("repositories");
133
133
  return useQuery<Repository, Error>(["repository", namespace, name], () =>
134
- apiClient.get(concat(link, namespace, name)).then((response) => response.json())
134
+ apiClient.get(concat(link, namespace, name)).then(response => response.json())
135
135
  );
136
136
  };
137
137
 
@@ -142,7 +142,7 @@ export type UseDeleteRepositoryOptions = {
142
142
  export const useDeleteRepository = (options?: UseDeleteRepositoryOptions) => {
143
143
  const queryClient = useQueryClient();
144
144
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
145
- (repository) => {
145
+ repository => {
146
146
  const link = requiredLink(repository, "delete");
147
147
  return apiClient.delete(link);
148
148
  },
@@ -153,21 +153,21 @@ export const useDeleteRepository = (options?: UseDeleteRepositoryOptions) => {
153
153
  }
154
154
  queryClient.removeQueries(repoQueryKey(repository));
155
155
  await queryClient.invalidateQueries(["repositories"]);
156
- },
156
+ }
157
157
  }
158
158
  );
159
159
  return {
160
160
  remove: (repository: Repository) => mutate(repository),
161
161
  isLoading,
162
162
  error,
163
- isDeleted: !!data,
163
+ isDeleted: !!data
164
164
  };
165
165
  };
166
166
 
167
167
  export const useUpdateRepository = () => {
168
168
  const queryClient = useQueryClient();
169
169
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
170
- (repository) => {
170
+ repository => {
171
171
  const link = requiredLink(repository, "update");
172
172
  return apiClient.put(link, repository, "application/vnd.scmm-repository+json;v=2");
173
173
  },
@@ -175,21 +175,21 @@ export const useUpdateRepository = () => {
175
175
  onSuccess: async (_, repository) => {
176
176
  await queryClient.invalidateQueries(repoQueryKey(repository));
177
177
  await queryClient.invalidateQueries(["repositories"]);
178
- },
178
+ }
179
179
  }
180
180
  );
181
181
  return {
182
182
  update: (repository: Repository) => mutate(repository),
183
183
  isLoading,
184
184
  error,
185
- isUpdated: !!data,
185
+ isUpdated: !!data
186
186
  };
187
187
  };
188
188
 
189
189
  export const useArchiveRepository = () => {
190
190
  const queryClient = useQueryClient();
191
191
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
192
- (repository) => {
192
+ repository => {
193
193
  const link = requiredLink(repository, "archive");
194
194
  return apiClient.post(link);
195
195
  },
@@ -197,21 +197,21 @@ export const useArchiveRepository = () => {
197
197
  onSuccess: async (_, repository) => {
198
198
  await queryClient.invalidateQueries(repoQueryKey(repository));
199
199
  await queryClient.invalidateQueries(["repositories"]);
200
- },
200
+ }
201
201
  }
202
202
  );
203
203
  return {
204
204
  archive: (repository: Repository) => mutate(repository),
205
205
  isLoading,
206
206
  error,
207
- isArchived: !!data,
207
+ isArchived: !!data
208
208
  };
209
209
  };
210
210
 
211
211
  export const useUnarchiveRepository = () => {
212
212
  const queryClient = useQueryClient();
213
213
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
214
- (repository) => {
214
+ repository => {
215
215
  const link = requiredLink(repository, "unarchive");
216
216
  return apiClient.post(link);
217
217
  },
@@ -219,35 +219,35 @@ export const useUnarchiveRepository = () => {
219
219
  onSuccess: async (_, repository) => {
220
220
  await queryClient.invalidateQueries(repoQueryKey(repository));
221
221
  await queryClient.invalidateQueries(["repositories"]);
222
- },
222
+ }
223
223
  }
224
224
  );
225
225
  return {
226
226
  unarchive: (repository: Repository) => mutate(repository),
227
227
  isLoading,
228
228
  error,
229
- isUnarchived: !!data,
229
+ isUnarchived: !!data
230
230
  };
231
231
  };
232
232
 
233
233
  export const useRunHealthCheck = () => {
234
234
  const queryClient = useQueryClient();
235
235
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Repository>(
236
- (repository) => {
236
+ repository => {
237
237
  const link = requiredLink(repository, "runHealthCheck");
238
238
  return apiClient.post(link);
239
239
  },
240
240
  {
241
241
  onSuccess: async (_, repository) => {
242
242
  await queryClient.invalidateQueries(repoQueryKey(repository));
243
- },
243
+ }
244
244
  }
245
245
  );
246
246
  return {
247
247
  runHealthCheck: (repository: Repository) => mutate(repository),
248
248
  isLoading,
249
249
  error,
250
- isRunning: !!data,
250
+ isRunning: !!data
251
251
  };
252
252
  };
253
253
 
@@ -256,7 +256,7 @@ export const useExportInfo = (repository: Repository): ApiResultWithFetching<Exp
256
256
  //TODO Refetch while exporting to update the page
257
257
  const { isLoading, isFetching, error, data } = useQuery<ExportInfo, Error>(
258
258
  ["repository", repository.namespace, repository.name, "exportInfo"],
259
- () => apiClient.get(link).then((response) => response.json()),
259
+ () => apiClient.get(link).then(response => response.json()),
260
260
  {}
261
261
  );
262
262
 
@@ -264,7 +264,7 @@ export const useExportInfo = (repository: Repository): ApiResultWithFetching<Exp
264
264
  isLoading,
265
265
  isFetching,
266
266
  error: error instanceof NotFoundError ? null : error,
267
- data,
267
+ data
268
268
  };
269
269
  };
270
270
 
@@ -307,14 +307,14 @@ export const useExportRepository = () => {
307
307
  const id = setInterval(() => {
308
308
  apiClient
309
309
  .get(infolink)
310
- .then((r) => r.json())
310
+ .then(r => r.json())
311
311
  .then((info: ExportInfo) => {
312
312
  if (info._links.download) {
313
313
  clearInterval(id);
314
314
  resolve(info);
315
315
  }
316
316
  })
317
- .catch((e) => {
317
+ .catch(e => {
318
318
  clearInterval(id);
319
319
  reject(e);
320
320
  });
@@ -327,21 +327,21 @@ export const useExportRepository = () => {
327
327
  onSuccess: async (_, { repository }) => {
328
328
  await queryClient.invalidateQueries(repoQueryKey(repository));
329
329
  await queryClient.invalidateQueries(["repositories"]);
330
- },
330
+ }
331
331
  }
332
332
  );
333
333
  return {
334
334
  exportRepository: (repository: Repository, options: ExportOptions) => mutate({ repository, options }),
335
335
  isLoading,
336
336
  error,
337
- data,
337
+ data
338
338
  };
339
339
  };
340
340
 
341
341
  export const usePaths = (repository: Repository, revision: string): ApiResult<Paths> => {
342
342
  const link = requiredLink(repository, "paths").replace("{revision}", revision);
343
343
  return useQuery<Paths, Error>(repoQueryKey(repository, "paths", revision), () =>
344
- apiClient.get(link).then((response) => response.json())
344
+ apiClient.get(link).then(response => response.json())
345
345
  );
346
346
  };
347
347
 
@@ -362,7 +362,7 @@ export const useRenameRepository = (repository: Repository) => {
362
362
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, RenameRepositoryRequest>(
363
363
  ({ name, namespace }) => apiClient.post(url, { namespace, name }, "application/vnd.scmm-repository+json;v=2"),
364
364
  {
365
- onSuccess: () => queryClient.removeQueries(repoQueryKey(repository)),
365
+ onSuccess: () => queryClient.removeQueries(repoQueryKey(repository))
366
366
  }
367
367
  );
368
368
 
@@ -370,6 +370,6 @@ export const useRenameRepository = (repository: Repository) => {
370
370
  renameRepository: (namespace: string, name: string) => mutate({ namespace, name }),
371
371
  isLoading,
372
372
  error,
373
- isRenamed: !!data,
373
+ isRenamed: !!data
374
374
  };
375
375
  };
package/src/sources.ts CHANGED
@@ -41,7 +41,7 @@ export type UseSourcesOptions = {
41
41
  const UseSourcesDefaultOptions: UseSourcesOptions = {
42
42
  enabled: true,
43
43
  refetchPartialInterval: 3000,
44
- collapse: true,
44
+ collapse: true
45
45
  };
46
46
 
47
47
  export const useSources = (repository: Repository, opts: UseSourcesOptions = UseSourcesDefaultOptions) => {
@@ -49,7 +49,7 @@ export const usePluginCenterAuthInfo = (): ApiResult<PluginCenterAuthenticationI
49
49
  }
50
50
  return apiClient
51
51
  .get(link)
52
- .then((response) => response.json())
52
+ .then(response => response.json())
53
53
  .then((result: PluginCenterAuthenticationInfo) => {
54
54
  if (result._links?.login) {
55
55
  appendQueryParam(result._links.login as Link, "source", location.pathname);
@@ -61,7 +61,7 @@ export const usePluginCenterAuthInfo = (): ApiResult<PluginCenterAuthenticationI
61
61
  });
62
62
  },
63
63
  {
64
- enabled: !!link,
64
+ enabled: !!link
65
65
  }
66
66
  );
67
67
  };
@@ -77,7 +77,7 @@ export const usePluginCenterLogout = (authenticationInfo: PluginCenterAuthentica
77
77
  return apiClient.delete(logout.href);
78
78
  },
79
79
  {
80
- onSuccess: () => queryClient.invalidateQueries("pluginCenterAuth"),
80
+ onSuccess: () => queryClient.invalidateQueries("pluginCenterAuth")
81
81
  }
82
82
  );
83
83
 
@@ -86,6 +86,6 @@ export const usePluginCenterLogout = (authenticationInfo: PluginCenterAuthentica
86
86
  mutate();
87
87
  },
88
88
  isLoading,
89
- error,
89
+ error
90
90
  };
91
91
  };