@learnorama/mozaik-sdk 0.1.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.
Files changed (208) hide show
  1. package/README.md +94 -0
  2. package/dist/api/account.d.ts +75 -0
  3. package/dist/api/account.js +117 -0
  4. package/dist/api/account.js.map +1 -0
  5. package/dist/api/admin-catalogue.d.ts +68 -0
  6. package/dist/api/admin-catalogue.js +155 -0
  7. package/dist/api/admin-catalogue.js.map +1 -0
  8. package/dist/api/admin-consumption.d.ts +27 -0
  9. package/dist/api/admin-consumption.js +55 -0
  10. package/dist/api/admin-consumption.js.map +1 -0
  11. package/dist/api/admin-licenses.d.ts +21 -0
  12. package/dist/api/admin-licenses.js +34 -0
  13. package/dist/api/admin-licenses.js.map +1 -0
  14. package/dist/api/admin-patrons.d.ts +36 -0
  15. package/dist/api/admin-patrons.js +76 -0
  16. package/dist/api/admin-patrons.js.map +1 -0
  17. package/dist/api/admin-reviews.d.ts +30 -0
  18. package/dist/api/admin-reviews.js +63 -0
  19. package/dist/api/admin-reviews.js.map +1 -0
  20. package/dist/api/admin-roles.d.ts +34 -0
  21. package/dist/api/admin-roles.js +62 -0
  22. package/dist/api/admin-roles.js.map +1 -0
  23. package/dist/api/admin-support.d.ts +68 -0
  24. package/dist/api/admin-support.js +116 -0
  25. package/dist/api/admin-support.js.map +1 -0
  26. package/dist/api/admin-tenants.d.ts +33 -0
  27. package/dist/api/admin-tenants.js +68 -0
  28. package/dist/api/admin-tenants.js.map +1 -0
  29. package/dist/api/admin-tutoring.d.ts +159 -0
  30. package/dist/api/admin-tutoring.js +455 -0
  31. package/dist/api/admin-tutoring.js.map +1 -0
  32. package/dist/api/auth.d.ts +92 -0
  33. package/dist/api/auth.js +192 -0
  34. package/dist/api/auth.js.map +1 -0
  35. package/dist/api/biblio-catalogue.d.ts +122 -0
  36. package/dist/api/biblio-catalogue.js +223 -0
  37. package/dist/api/biblio-catalogue.js.map +1 -0
  38. package/dist/api/biblio-home.d.ts +18 -0
  39. package/dist/api/biblio-home.js +31 -0
  40. package/dist/api/biblio-home.js.map +1 -0
  41. package/dist/api/biblio-library.d.ts +94 -0
  42. package/dist/api/biblio-library.js +187 -0
  43. package/dist/api/biblio-library.js.map +1 -0
  44. package/dist/api/biblio-nextory.d.ts +43 -0
  45. package/dist/api/biblio-nextory.js +65 -0
  46. package/dist/api/biblio-nextory.js.map +1 -0
  47. package/dist/api/biblio-press.d.ts +38 -0
  48. package/dist/api/biblio-press.js +70 -0
  49. package/dist/api/biblio-press.js.map +1 -0
  50. package/dist/api/biblio-search.d.ts +17 -0
  51. package/dist/api/biblio-search.js +30 -0
  52. package/dist/api/biblio-search.js.map +1 -0
  53. package/dist/api/biblio-telemetry.d.ts +28 -0
  54. package/dist/api/biblio-telemetry.js +49 -0
  55. package/dist/api/biblio-telemetry.js.map +1 -0
  56. package/dist/api/consumption.d.ts +30 -0
  57. package/dist/api/consumption.js +45 -0
  58. package/dist/api/consumption.js.map +1 -0
  59. package/dist/api/cvs-app.d.ts +39 -0
  60. package/dist/api/cvs-app.js +72 -0
  61. package/dist/api/cvs-app.js.map +1 -0
  62. package/dist/api/cvs-documents.d.ts +106 -0
  63. package/dist/api/cvs-documents.js +208 -0
  64. package/dist/api/cvs-documents.js.map +1 -0
  65. package/dist/api/cvs-favorites.d.ts +53 -0
  66. package/dist/api/cvs-favorites.js +82 -0
  67. package/dist/api/cvs-favorites.js.map +1 -0
  68. package/dist/api/cvs-loans.d.ts +59 -0
  69. package/dist/api/cvs-loans.js +106 -0
  70. package/dist/api/cvs-loans.js.map +1 -0
  71. package/dist/api/cvs-streaming.d.ts +40 -0
  72. package/dist/api/cvs-streaming.js +68 -0
  73. package/dist/api/cvs-streaming.js.map +1 -0
  74. package/dist/api/index.d.ts +34 -0
  75. package/dist/api/index.js +34 -0
  76. package/dist/api/partner-catalogue.d.ts +77 -0
  77. package/dist/api/partner-catalogue.js +125 -0
  78. package/dist/api/partner-catalogue.js.map +1 -0
  79. package/dist/api/partner-reader.d.ts +56 -0
  80. package/dist/api/partner-reader.js +103 -0
  81. package/dist/api/partner-reader.js.map +1 -0
  82. package/dist/api/profiles.d.ts +64 -0
  83. package/dist/api/profiles.js +126 -0
  84. package/dist/api/profiles.js.map +1 -0
  85. package/dist/api/tutoring-catalogue.d.ts +32 -0
  86. package/dist/api/tutoring-catalogue.js +59 -0
  87. package/dist/api/tutoring-catalogue.js.map +1 -0
  88. package/dist/api/tutoring-chat.d.ts +31 -0
  89. package/dist/api/tutoring-chat.js +71 -0
  90. package/dist/api/tutoring-chat.js.map +1 -0
  91. package/dist/api/tutoring-dispatch.d.ts +37 -0
  92. package/dist/api/tutoring-dispatch.js +83 -0
  93. package/dist/api/tutoring-dispatch.js.map +1 -0
  94. package/dist/api/tutoring-practitioner.d.ts +55 -0
  95. package/dist/api/tutoring-practitioner.js +110 -0
  96. package/dist/api/tutoring-practitioner.js.map +1 -0
  97. package/dist/api/tutoring-requests.d.ts +86 -0
  98. package/dist/api/tutoring-requests.js +176 -0
  99. package/dist/api/tutoring-requests.js.map +1 -0
  100. package/dist/client-BDwBZYB0.d.ts +28 -0
  101. package/dist/client-D3kMOcIr.js +61 -0
  102. package/dist/client-D3kMOcIr.js.map +1 -0
  103. package/dist/index-wL_20vR8.d.ts +4566 -0
  104. package/dist/index.d.ts +9 -0
  105. package/dist/index.js +10 -0
  106. package/dist/index.js.map +1 -0
  107. package/dist/models.d.ts +3 -0
  108. package/dist/models.js +175 -0
  109. package/dist/models.js.map +1 -0
  110. package/dist/react/account.d.ts +163 -0
  111. package/dist/react/account.js +240 -0
  112. package/dist/react/account.js.map +1 -0
  113. package/dist/react/admin-catalogue.d.ts +196 -0
  114. package/dist/react/admin-catalogue.js +336 -0
  115. package/dist/react/admin-catalogue.js.map +1 -0
  116. package/dist/react/admin-consumption.d.ts +75 -0
  117. package/dist/react/admin-consumption.js +127 -0
  118. package/dist/react/admin-consumption.js.map +1 -0
  119. package/dist/react/admin-licenses.d.ts +50 -0
  120. package/dist/react/admin-licenses.js +78 -0
  121. package/dist/react/admin-licenses.js.map +1 -0
  122. package/dist/react/admin-patrons.d.ts +111 -0
  123. package/dist/react/admin-patrons.js +173 -0
  124. package/dist/react/admin-patrons.js.map +1 -0
  125. package/dist/react/admin-reviews.d.ts +78 -0
  126. package/dist/react/admin-reviews.js +135 -0
  127. package/dist/react/admin-reviews.js.map +1 -0
  128. package/dist/react/admin-roles.d.ts +82 -0
  129. package/dist/react/admin-roles.js +135 -0
  130. package/dist/react/admin-roles.js.map +1 -0
  131. package/dist/react/admin-support.d.ts +123 -0
  132. package/dist/react/admin-support.js +208 -0
  133. package/dist/react/admin-support.js.map +1 -0
  134. package/dist/react/admin-tenants.d.ts +108 -0
  135. package/dist/react/admin-tenants.js +165 -0
  136. package/dist/react/admin-tenants.js.map +1 -0
  137. package/dist/react/admin-tutoring.d.ts +556 -0
  138. package/dist/react/admin-tutoring.js +954 -0
  139. package/dist/react/admin-tutoring.js.map +1 -0
  140. package/dist/react/auth.d.ts +220 -0
  141. package/dist/react/auth.js +372 -0
  142. package/dist/react/auth.js.map +1 -0
  143. package/dist/react/biblio-catalogue.d.ts +374 -0
  144. package/dist/react/biblio-catalogue.js +498 -0
  145. package/dist/react/biblio-catalogue.js.map +1 -0
  146. package/dist/react/biblio-home.d.ts +47 -0
  147. package/dist/react/biblio-home.js +75 -0
  148. package/dist/react/biblio-home.js.map +1 -0
  149. package/dist/react/biblio-library.d.ts +285 -0
  150. package/dist/react/biblio-library.js +411 -0
  151. package/dist/react/biblio-library.js.map +1 -0
  152. package/dist/react/biblio-nextory.d.ts +100 -0
  153. package/dist/react/biblio-nextory.js +163 -0
  154. package/dist/react/biblio-nextory.js.map +1 -0
  155. package/dist/react/biblio-press.d.ts +121 -0
  156. package/dist/react/biblio-press.js +163 -0
  157. package/dist/react/biblio-press.js.map +1 -0
  158. package/dist/react/biblio-search.d.ts +46 -0
  159. package/dist/react/biblio-search.js +74 -0
  160. package/dist/react/biblio-search.js.map +1 -0
  161. package/dist/react/biblio-telemetry.d.ts +49 -0
  162. package/dist/react/biblio-telemetry.js +85 -0
  163. package/dist/react/biblio-telemetry.js.map +1 -0
  164. package/dist/react/consumption.d.ts +66 -0
  165. package/dist/react/consumption.js +109 -0
  166. package/dist/react/consumption.js.map +1 -0
  167. package/dist/react/cvs-app.d.ts +86 -0
  168. package/dist/react/cvs-app.js +144 -0
  169. package/dist/react/cvs-app.js.map +1 -0
  170. package/dist/react/cvs-documents.d.ts +254 -0
  171. package/dist/react/cvs-documents.js +418 -0
  172. package/dist/react/cvs-documents.js.map +1 -0
  173. package/dist/react/cvs-favorites.d.ts +143 -0
  174. package/dist/react/cvs-favorites.js +206 -0
  175. package/dist/react/cvs-favorites.js.map +1 -0
  176. package/dist/react/cvs-loans.d.ts +140 -0
  177. package/dist/react/cvs-loans.js +234 -0
  178. package/dist/react/cvs-loans.js.map +1 -0
  179. package/dist/react/cvs-streaming.d.ts +87 -0
  180. package/dist/react/cvs-streaming.js +141 -0
  181. package/dist/react/cvs-streaming.js.map +1 -0
  182. package/dist/react/index.d.ts +34 -0
  183. package/dist/react/index.js +34 -0
  184. package/dist/react/partner-catalogue.d.ts +223 -0
  185. package/dist/react/partner-catalogue.js +301 -0
  186. package/dist/react/partner-catalogue.js.map +1 -0
  187. package/dist/react/partner-reader.d.ts +159 -0
  188. package/dist/react/partner-reader.js +226 -0
  189. package/dist/react/partner-reader.js.map +1 -0
  190. package/dist/react/profiles.d.ts +174 -0
  191. package/dist/react/profiles.js +279 -0
  192. package/dist/react/profiles.js.map +1 -0
  193. package/dist/react/tutoring-catalogue.d.ts +115 -0
  194. package/dist/react/tutoring-catalogue.js +151 -0
  195. package/dist/react/tutoring-catalogue.js.map +1 -0
  196. package/dist/react/tutoring-chat.d.ts +96 -0
  197. package/dist/react/tutoring-chat.js +172 -0
  198. package/dist/react/tutoring-chat.js.map +1 -0
  199. package/dist/react/tutoring-dispatch.d.ts +102 -0
  200. package/dist/react/tutoring-dispatch.js +183 -0
  201. package/dist/react/tutoring-dispatch.js.map +1 -0
  202. package/dist/react/tutoring-practitioner.d.ts +129 -0
  203. package/dist/react/tutoring-practitioner.js +230 -0
  204. package/dist/react/tutoring-practitioner.js.map +1 -0
  205. package/dist/react/tutoring-requests.d.ts +233 -0
  206. package/dist/react/tutoring-requests.js +385 -0
  207. package/dist/react/tutoring-requests.js.map +1 -0
  208. package/package.json +58 -0
@@ -0,0 +1,336 @@
1
+ "use client";
2
+ import { r as request } from "../client-D3kMOcIr.js";
3
+ import { useMutation, useQuery } from "@tanstack/react-query";
4
+ //#region src/react/admin-catalogue/admin-catalogue.ts
5
+ /**
6
+ * Generated by orval 🍺
7
+ * Do not edit manually.
8
+ * Mozaik backend
9
+ * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
10
+ * OpenAPI spec version: 0.1.0
11
+ */
12
+ const withQueryKey = (query, queryKey) => {
13
+ const result = { queryKey };
14
+ for (const key of Object.keys(query)) {
15
+ if (key === "queryKey") continue;
16
+ Object.defineProperty(result, key, {
17
+ enumerable: true,
18
+ configurable: true,
19
+ get: () => query[key]
20
+ });
21
+ }
22
+ return result;
23
+ };
24
+ const getListThemesUrl = (params) => {
25
+ const normalizedParams = new URLSearchParams();
26
+ Object.entries(params || {}).forEach(([key, value]) => {
27
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
28
+ });
29
+ const stringifiedParams = normalizedParams.toString();
30
+ return stringifiedParams.length > 0 ? `/admin/themes?${stringifiedParams}` : `/admin/themes`;
31
+ };
32
+ /**
33
+ * Every theme, or one pillar's, in display order.
34
+ *
35
+ * Not paginated. There are 27 of them, and a client that has to page through
36
+ * a list it is about to reorder cannot reorder it.
37
+ * @summary List Themes
38
+ */
39
+ const listThemes = async (params, options) => {
40
+ return request(getListThemesUrl(params), {
41
+ ...options,
42
+ method: "GET"
43
+ });
44
+ };
45
+ const getListThemesQueryKey = (params) => {
46
+ return [`/admin/themes`, ...params ? [params] : []];
47
+ };
48
+ const getListThemesQueryOptions = (params, options) => {
49
+ const { query: queryOptions, request: requestOptions } = options ?? {};
50
+ const queryKey = queryOptions?.queryKey ?? getListThemesQueryKey(params);
51
+ const queryFn = ({ signal }) => listThemes(params, {
52
+ signal,
53
+ ...requestOptions
54
+ });
55
+ return {
56
+ queryKey,
57
+ queryFn,
58
+ ...queryOptions
59
+ };
60
+ };
61
+ /**
62
+ * @summary List Themes
63
+ */
64
+ function useListThemes(params, options, queryClient) {
65
+ const queryOptions = getListThemesQueryOptions(params, options);
66
+ const query = useQuery(queryOptions, queryClient);
67
+ return withQueryKey(query, queryOptions.queryKey);
68
+ }
69
+ const getCreateThemeUrl = () => {
70
+ return `/admin/themes`;
71
+ };
72
+ /**
73
+ * Add a theme.
74
+ *
75
+ * ``409`` on a duplicate ``(pillar, title)``: that pair is unique in the
76
+ * schema, and two themes with the same name in the same pillar are
77
+ * indistinguishable to everyone downstream.
78
+ *
79
+ * With no ``sortOrder`` it goes last, which is what the legacy's form does by
80
+ * defaulting the field to the current maximum plus one.
81
+ * @summary Create Theme
82
+ */
83
+ const createTheme = async (themeWrite, options) => {
84
+ const getHeaders = (h) => {
85
+ if (!h) return {};
86
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
87
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
88
+ const headers = {};
89
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
90
+ return headers;
91
+ };
92
+ return request(getCreateThemeUrl(), {
93
+ ...options,
94
+ method: "POST",
95
+ headers: {
96
+ "Content-Type": "application/json",
97
+ ...getHeaders(options?.headers)
98
+ },
99
+ body: JSON.stringify(themeWrite)
100
+ });
101
+ };
102
+ const getCreateThemeMutationKey = () => ["createTheme"];
103
+ const getCreateThemeMutationOptions = (options) => {
104
+ const mutationKey = getCreateThemeMutationKey();
105
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
106
+ ...options,
107
+ mutation: {
108
+ ...options.mutation,
109
+ mutationKey
110
+ }
111
+ } : {
112
+ mutation: { mutationKey },
113
+ request: void 0
114
+ };
115
+ const mutationFn = (props) => {
116
+ const { data } = props ?? {};
117
+ return createTheme(data, requestOptions);
118
+ };
119
+ return {
120
+ mutationFn,
121
+ ...mutationOptions
122
+ };
123
+ };
124
+ /**
125
+ * @summary Create Theme
126
+ */
127
+ const useCreateTheme = (options, queryClient) => {
128
+ return useMutation(getCreateThemeMutationOptions(options), queryClient);
129
+ };
130
+ const getReorderThemesUrl = () => {
131
+ return `/admin/themes/order`;
132
+ };
133
+ /**
134
+ * Set the display order for a set of themes, in one transaction.
135
+ *
136
+ * The legacy renumbers one theme per request, so dragging an item in a list of
137
+ * thirty was thirty requests — and closing the tab halfway left the order
138
+ * half-applied, with two themes claiming the same position and the listing
139
+ * silently choosing between them.
140
+ *
141
+ * Ids not named keep their relative order after the ones that are, so a client
142
+ * may send only what moved. An unknown id is ``404`` and nothing is written:
143
+ * a partially applied reorder is the failure this endpoint exists to prevent.
144
+ * @summary Reorder Themes
145
+ */
146
+ const reorderThemes = async (themeOrderWrite, options) => {
147
+ const getHeaders = (h) => {
148
+ if (!h) return {};
149
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
150
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
151
+ const headers = {};
152
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
153
+ return headers;
154
+ };
155
+ return request(getReorderThemesUrl(), {
156
+ ...options,
157
+ method: "PUT",
158
+ headers: {
159
+ "Content-Type": "application/json",
160
+ ...getHeaders(options?.headers)
161
+ },
162
+ body: JSON.stringify(themeOrderWrite)
163
+ });
164
+ };
165
+ const getReorderThemesMutationKey = () => ["reorderThemes"];
166
+ const getReorderThemesMutationOptions = (options) => {
167
+ const mutationKey = getReorderThemesMutationKey();
168
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
169
+ ...options,
170
+ mutation: {
171
+ ...options.mutation,
172
+ mutationKey
173
+ }
174
+ } : {
175
+ mutation: { mutationKey },
176
+ request: void 0
177
+ };
178
+ const mutationFn = (props) => {
179
+ const { data } = props ?? {};
180
+ return reorderThemes(data, requestOptions);
181
+ };
182
+ return {
183
+ mutationFn,
184
+ ...mutationOptions
185
+ };
186
+ };
187
+ /**
188
+ * @summary Reorder Themes
189
+ */
190
+ const useReorderThemes = (options, queryClient) => {
191
+ return useMutation(getReorderThemesMutationOptions(options), queryClient);
192
+ };
193
+ const getDeleteThemeUrl = (themeId) => {
194
+ return `/admin/themes/${themeId}`;
195
+ };
196
+ /**
197
+ * Remove a theme.
198
+ *
199
+ * ``409`` when works still carry it. The legacy deletes and leaves the
200
+ * references dangling, which is how a catalogue ends up with items filed under
201
+ * a theme that no longer exists and no screen that can find them.
202
+ *
203
+ * Idempotent otherwise: deleting something already gone is ``204``, because
204
+ * the caller wanted it gone and it is gone.
205
+ * @summary Delete Theme
206
+ */
207
+ const deleteTheme = async (themeId, options) => {
208
+ return request(getDeleteThemeUrl(themeId), {
209
+ ...options,
210
+ method: "DELETE"
211
+ });
212
+ };
213
+ const getDeleteThemeMutationKey = () => ["deleteTheme"];
214
+ const getDeleteThemeMutationOptions = (options) => {
215
+ const mutationKey = getDeleteThemeMutationKey();
216
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
217
+ ...options,
218
+ mutation: {
219
+ ...options.mutation,
220
+ mutationKey
221
+ }
222
+ } : {
223
+ mutation: { mutationKey },
224
+ request: void 0
225
+ };
226
+ const mutationFn = (props) => {
227
+ const { themeId } = props ?? {};
228
+ return deleteTheme(themeId, requestOptions);
229
+ };
230
+ return {
231
+ mutationFn,
232
+ ...mutationOptions
233
+ };
234
+ };
235
+ /**
236
+ * @summary Delete Theme
237
+ */
238
+ const useDeleteTheme = (options, queryClient) => {
239
+ return useMutation(getDeleteThemeMutationOptions(options), queryClient);
240
+ };
241
+ const getReadThemeUrl = (themeId) => {
242
+ return `/admin/themes/${themeId}`;
243
+ };
244
+ /**
245
+ * One theme.
246
+ * @summary Read Theme
247
+ */
248
+ const readTheme = async (themeId, options) => {
249
+ return request(getReadThemeUrl(themeId), {
250
+ ...options,
251
+ method: "GET"
252
+ });
253
+ };
254
+ const getReadThemeQueryKey = (themeId) => {
255
+ return [`/admin/themes/${themeId}`];
256
+ };
257
+ const getReadThemeQueryOptions = (themeId, options) => {
258
+ const { query: queryOptions, request: requestOptions } = options ?? {};
259
+ const queryKey = queryOptions?.queryKey ?? getReadThemeQueryKey(themeId);
260
+ const queryFn = ({ signal }) => readTheme(themeId, {
261
+ signal,
262
+ ...requestOptions
263
+ });
264
+ return {
265
+ queryKey,
266
+ queryFn,
267
+ enabled: themeId !== null && themeId !== void 0,
268
+ ...queryOptions
269
+ };
270
+ };
271
+ /**
272
+ * @summary Read Theme
273
+ */
274
+ function useReadTheme(themeId, options, queryClient) {
275
+ const queryOptions = getReadThemeQueryOptions(themeId, options);
276
+ const query = useQuery(queryOptions, queryClient);
277
+ return withQueryKey(query, queryOptions.queryKey);
278
+ }
279
+ const getAmendThemeUrl = (themeId) => {
280
+ return `/admin/themes/${themeId}`;
281
+ };
282
+ /**
283
+ * Amend a theme. Same uniqueness rule as creating one.
284
+ * @summary Amend Theme
285
+ */
286
+ const amendTheme = async (themeId, themeWrite, options) => {
287
+ const getHeaders = (h) => {
288
+ if (!h) return {};
289
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
290
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
291
+ const headers = {};
292
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
293
+ return headers;
294
+ };
295
+ return request(getAmendThemeUrl(themeId), {
296
+ ...options,
297
+ method: "PATCH",
298
+ headers: {
299
+ "Content-Type": "application/json",
300
+ ...getHeaders(options?.headers)
301
+ },
302
+ body: JSON.stringify(themeWrite)
303
+ });
304
+ };
305
+ const getAmendThemeMutationKey = () => ["amendTheme"];
306
+ const getAmendThemeMutationOptions = (options) => {
307
+ const mutationKey = getAmendThemeMutationKey();
308
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
309
+ ...options,
310
+ mutation: {
311
+ ...options.mutation,
312
+ mutationKey
313
+ }
314
+ } : {
315
+ mutation: { mutationKey },
316
+ request: void 0
317
+ };
318
+ const mutationFn = (props) => {
319
+ const { themeId, data } = props ?? {};
320
+ return amendTheme(themeId, data, requestOptions);
321
+ };
322
+ return {
323
+ mutationFn,
324
+ ...mutationOptions
325
+ };
326
+ };
327
+ /**
328
+ * @summary Amend Theme
329
+ */
330
+ const useAmendTheme = (options, queryClient) => {
331
+ return useMutation(getAmendThemeMutationOptions(options), queryClient);
332
+ };
333
+ //#endregion
334
+ export { amendTheme, createTheme, deleteTheme, getAmendThemeMutationKey, getAmendThemeMutationOptions, getAmendThemeUrl, getCreateThemeMutationKey, getCreateThemeMutationOptions, getCreateThemeUrl, getDeleteThemeMutationKey, getDeleteThemeMutationOptions, getDeleteThemeUrl, getListThemesQueryKey, getListThemesQueryOptions, getListThemesUrl, getReadThemeQueryKey, getReadThemeQueryOptions, getReadThemeUrl, getReorderThemesMutationKey, getReorderThemesMutationOptions, getReorderThemesUrl, listThemes, readTheme, reorderThemes, useAmendTheme, useCreateTheme, useDeleteTheme, useListThemes, useReadTheme, useReorderThemes };
335
+
336
+ //# sourceMappingURL=admin-catalogue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-catalogue.js","names":[],"sources":["../../src/react/admin-catalogue/admin-catalogue.ts"],"sourcesContent":["/**\n * Generated by orval 🍺\n * Do not edit manually.\n * Mozaik backend\n * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.\n * OpenAPI spec version: 0.1.0\n */\nimport {\n useMutation,\n useQuery\n} from '@tanstack/react-query';\nimport type {\n DataTag,\n DefinedInitialDataOptions,\n DefinedUseQueryResult,\n MutationFunction,\n QueryClient,\n QueryFunction,\n QueryKey,\n UndefinedInitialDataOptions,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult\n} from '@tanstack/react-query';\n\nimport type {\n HTTPExceptionResponse,\n ListThemesParams,\n ThemeListRead,\n ThemeOrderWrite,\n ThemeRead,\n ThemeWrite,\n ValidationErrorResponse\n} from '../../models';\n\nimport { request } from '../../client';\nimport type { ErrorType , BodyType } from '../../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n\nconst withQueryKey = <T extends object, K>(query: T, queryKey: K): T & { queryKey: K } => {\n const result = { queryKey } as T & { queryKey: K };\n for (const key of Object.keys(query)) {\n // The explicit queryKey always wins, matching the previous\n // `{ ...query, queryKey }` spread where it was set last.\n if (key === 'queryKey') continue;\n Object.defineProperty(result, key, {\n enumerable: true,\n configurable: true,\n get: () => (query as Record<string, unknown>)[key],\n });\n }\n return result;\n};\n\nexport const getListThemesUrl = (params?: ListThemesParams,) => {\n const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n\n if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : String(value))\n }\n });\n\n const stringifiedParams = normalizedParams.toString();\n\n return stringifiedParams.length > 0 ? `/admin/themes?${stringifiedParams}` : `/admin/themes`\n}\n\n/**\n * Every theme, or one pillar's, in display order.\n *\n * Not paginated. There are 27 of them, and a client that has to page through\n * a list it is about to reorder cannot reorder it.\n * @summary List Themes\n */\nexport const listThemes = async (params?: ListThemesParams, options?: Parameters<typeof request>[1]): Promise<ThemeListRead> => {\n\n return request<ThemeListRead>(getListThemesUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListThemesQueryKey = (params?: ListThemesParams,) => {\n return [\n `/admin/themes`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getListThemesQueryOptions = <TData = Awaited<ReturnType<typeof listThemes>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListThemesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListThemesQueryKey(params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listThemes>>> = ({ signal }) => listThemes(params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListThemesQueryResult = NonNullable<Awaited<ReturnType<typeof listThemes>>>\nexport type ListThemesQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListThemes<TData = Awaited<ReturnType<typeof listThemes>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: undefined | ListThemesParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listThemes>>,\n TError,\n Awaited<ReturnType<typeof listThemes>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListThemes<TData = Awaited<ReturnType<typeof listThemes>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListThemesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listThemes>>,\n TError,\n Awaited<ReturnType<typeof listThemes>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListThemes<TData = Awaited<ReturnType<typeof listThemes>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListThemesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Themes\n */\n\nexport function useListThemes<TData = Awaited<ReturnType<typeof listThemes>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListThemesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listThemes>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListThemesQueryOptions(params,options)\n\n const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };\n\n return withQueryKey(query, queryOptions.queryKey);\n}\n\n\n\n\n\n\nexport const getCreateThemeUrl = () => {\n\n\n\n\n return `/admin/themes`\n}\n\n/**\n * Add a theme.\n *\n * ``409`` on a duplicate ``(pillar, title)``: that pair is unique in the\n * schema, and two themes with the same name in the same pillar are\n * indistinguishable to everyone downstream.\n *\n * With no ``sortOrder`` it goes last, which is what the legacy's form does by\n * defaulting the field to the current maximum plus one.\n * @summary Create Theme\n */\nexport const createTheme = async (themeWrite: ThemeWrite, options?: Parameters<typeof request>[1]): Promise<ThemeRead> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<ThemeRead>(getCreateThemeUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(themeWrite)\n }\n);}\n\n\n\n\n\nexport const getCreateThemeMutationKey = () => ['createTheme'] as const;\n\nexport const getCreateThemeMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createTheme>>, TError,CreateThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof createTheme>>, TError,CreateThemeMutationVariables, TContext> => {\n\nconst mutationKey = getCreateThemeMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof createTheme>>, CreateThemeMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return createTheme(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CreateThemeMutationResult = NonNullable<Awaited<ReturnType<typeof createTheme>>>\n export type CreateThemeMutationBody = BodyType<ThemeWrite>\n export type CreateThemeMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CreateThemeMutationVariables = {data: BodyType<ThemeWrite>}\n\n /**\n * @summary Create Theme\n */\nexport const useCreateTheme = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createTheme>>, TError,CreateThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof createTheme>>,\n TError,\n CreateThemeMutationVariables,\n TContext\n > => {\n return useMutation(getCreateThemeMutationOptions(options), queryClient);\n }\n export const getReorderThemesUrl = () => {\n\n\n\n\n return `/admin/themes/order`\n}\n\n/**\n * Set the display order for a set of themes, in one transaction.\n *\n * The legacy renumbers one theme per request, so dragging an item in a list of\n * thirty was thirty requests — and closing the tab halfway left the order\n * half-applied, with two themes claiming the same position and the listing\n * silently choosing between them.\n *\n * Ids not named keep their relative order after the ones that are, so a client\n * may send only what moved. An unknown id is ``404`` and nothing is written:\n * a partially applied reorder is the failure this endpoint exists to prevent.\n * @summary Reorder Themes\n */\nexport const reorderThemes = async (themeOrderWrite: ThemeOrderWrite, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<void>(getReorderThemesUrl(),\n {\n ...options,\n method: 'PUT',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(themeOrderWrite)\n }\n);}\n\n\n\n\n\nexport const getReorderThemesMutationKey = () => ['reorderThemes'] as const;\n\nexport const getReorderThemesMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof reorderThemes>>, TError,ReorderThemesMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof reorderThemes>>, TError,ReorderThemesMutationVariables, TContext> => {\n\nconst mutationKey = getReorderThemesMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof reorderThemes>>, ReorderThemesMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return reorderThemes(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type ReorderThemesMutationResult = NonNullable<Awaited<ReturnType<typeof reorderThemes>>>\n export type ReorderThemesMutationBody = BodyType<ThemeOrderWrite>\n export type ReorderThemesMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type ReorderThemesMutationVariables = {data: BodyType<ThemeOrderWrite>}\n\n /**\n * @summary Reorder Themes\n */\nexport const useReorderThemes = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof reorderThemes>>, TError,ReorderThemesMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof reorderThemes>>,\n TError,\n ReorderThemesMutationVariables,\n TContext\n > => {\n return useMutation(getReorderThemesMutationOptions(options), queryClient);\n }\n export const getDeleteThemeUrl = (themeId: number,) => {\n\n\n\n\n return `/admin/themes/${themeId}`\n}\n\n/**\n * Remove a theme.\n *\n * ``409`` when works still carry it. The legacy deletes and leaves the\n * references dangling, which is how a catalogue ends up with items filed under\n * a theme that no longer exists and no screen that can find them.\n *\n * Idempotent otherwise: deleting something already gone is ``204``, because\n * the caller wanted it gone and it is gone.\n * @summary Delete Theme\n */\nexport const deleteTheme = async (themeId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getDeleteThemeUrl(themeId),\n {\n ...options,\n method: 'DELETE'\n\n\n }\n);}\n\n\n\n\n\nexport const getDeleteThemeMutationKey = () => ['deleteTheme'] as const;\n\nexport const getDeleteThemeMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteTheme>>, TError,DeleteThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof deleteTheme>>, TError,DeleteThemeMutationVariables, TContext> => {\n\nconst mutationKey = getDeleteThemeMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteTheme>>, DeleteThemeMutationVariables> = (props) => {\n const {themeId} = props ?? {};\n\n return deleteTheme(themeId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type DeleteThemeMutationResult = NonNullable<Awaited<ReturnType<typeof deleteTheme>>>\n\n export type DeleteThemeMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type DeleteThemeMutationVariables = {themeId: number}\n\n /**\n * @summary Delete Theme\n */\nexport const useDeleteTheme = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteTheme>>, TError,DeleteThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof deleteTheme>>,\n TError,\n DeleteThemeMutationVariables,\n TContext\n > => {\n return useMutation(getDeleteThemeMutationOptions(options), queryClient);\n }\n export const getReadThemeUrl = (themeId: number,) => {\n\n\n\n\n return `/admin/themes/${themeId}`\n}\n\n/**\n * One theme.\n * @summary Read Theme\n */\nexport const readTheme = async (themeId: number, options?: Parameters<typeof request>[1]): Promise<ThemeRead> => {\n\n return request<ThemeRead>(getReadThemeUrl(themeId),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getReadThemeQueryKey = (themeId: number,) => {\n return [\n `/admin/themes/${themeId}`\n ] as const;\n }\n\n\nexport const getReadThemeQueryOptions = <TData = Awaited<ReturnType<typeof readTheme>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(themeId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getReadThemeQueryKey(themeId);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof readTheme>>> = ({ signal }) => readTheme(themeId, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, enabled: themeId !== null && themeId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ReadThemeQueryResult = NonNullable<Awaited<ReturnType<typeof readTheme>>>\nexport type ReadThemeQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useReadTheme<TData = Awaited<ReturnType<typeof readTheme>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n themeId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof readTheme>>,\n TError,\n Awaited<ReturnType<typeof readTheme>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadTheme<TData = Awaited<ReturnType<typeof readTheme>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n themeId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof readTheme>>,\n TError,\n Awaited<ReturnType<typeof readTheme>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadTheme<TData = Awaited<ReturnType<typeof readTheme>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n themeId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary Read Theme\n */\n\nexport function useReadTheme<TData = Awaited<ReturnType<typeof readTheme>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n themeId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readTheme>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getReadThemeQueryOptions(themeId,options)\n\n const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };\n\n return withQueryKey(query, queryOptions.queryKey);\n}\n\n\n\n\n\n\nexport const getAmendThemeUrl = (themeId: number,) => {\n\n\n\n\n return `/admin/themes/${themeId}`\n}\n\n/**\n * Amend a theme. Same uniqueness rule as creating one.\n * @summary Amend Theme\n */\nexport const amendTheme = async (themeId: number,\n themeWrite: ThemeWrite, options?: Parameters<typeof request>[1]): Promise<ThemeRead> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<ThemeRead>(getAmendThemeUrl(themeId),\n {\n ...options,\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(themeWrite)\n }\n);}\n\n\n\n\n\nexport const getAmendThemeMutationKey = () => ['amendTheme'] as const;\n\nexport const getAmendThemeMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof amendTheme>>, TError,AmendThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof amendTheme>>, TError,AmendThemeMutationVariables, TContext> => {\n\nconst mutationKey = getAmendThemeMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof amendTheme>>, AmendThemeMutationVariables> = (props) => {\n const {themeId,data} = props ?? {};\n\n return amendTheme(themeId,data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type AmendThemeMutationResult = NonNullable<Awaited<ReturnType<typeof amendTheme>>>\n export type AmendThemeMutationBody = BodyType<ThemeWrite>\n export type AmendThemeMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type AmendThemeMutationVariables = {themeId: number;data: BodyType<ThemeWrite>}\n\n /**\n * @summary Amend Theme\n */\nexport const useAmendTheme = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof amendTheme>>, TError,AmendThemeMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof amendTheme>>,\n TError,\n AmendThemeMutationVariables,\n TContext\n > => {\n return useMutation(getAmendThemeMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA4CA,MAAM,gBAAqC,OAAU,aAAqC;CACxF,MAAM,SAAS,EAAE,SAAS;CAC1B,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EAGpC,IAAI,QAAQ,YAAY;EACxB,OAAO,eAAe,QAAQ,KAAK;GACjC,YAAY;GACZ,cAAc;GACd,WAAY,MAAkC;EAChD,CAAC;CACH;CACA,OAAO;AACT;AAEA,MAAa,oBAAoB,WAA+B;CAC9D,MAAM,mBAAmB,IAAI,gBAAgB;CAE7C,OAAO,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAErD,IAAI,UAAU,KAAA,GACZ,iBAAiB,OAAO,KAAK,UAAU,OAAO,SAAS,OAAO,KAAK,CAAC;CAExE,CAAC;CAED,MAAM,oBAAoB,iBAAiB,SAAS;CAEpD,OAAO,kBAAkB,SAAS,IAAI,iBAAiB,sBAAsB;AAC/E;;;;;;;;AASA,MAAa,aAAa,OAAO,QAA2B,YAAoE;CAE9H,OAAO,QAAuB,iBAAiB,MAAM,GACrD;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,yBAAyB,WAA+B;CACjE,OAAO,CACP,iBAAiB,GAAI,SAAS,CAAC,MAAM,IAAI,CAAC,CAC1C;AACA;AAGJ,MAAa,6BAAkJ,QAA2B,YACrL;CAEL,MAAM,EAAC,OAAO,cAAc,SAAS,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AAU,iBAAiB,SAAS,mBAAkB,UACvD,QAAQ,YAAY,iBAAiB,QAAQ,YAAY,QAAQ,SAAS,cAC1E,UACE;EAAC,GAAG;EAAS,UAAU;GAAC,GAAG,QAAQ;GAAU;EAAW;CAAC,IACzD;EAAC,UAAU,EAAE,YAAa;EAAG,SAAS,KAAA;CAAS;CAKjD,MAAM,cAAqG,UAAU;EACjH,MAAM,EAAC,SAAQ,SAAQ,SAAS,CAAC;EAEjC,OAAQ,WAAW,SAAQ,MAAK,cAAc;CAChD;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,iBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,6BAA6B,OAAO,GAAG,WAAW;AACvE"}
@@ -0,0 +1,75 @@
1
+
2
+ import { Gn as HTTPExceptionResponse, in as LiveLeaseListRead, t as ValidationErrorResponse, zn as LeaseCloseWrite } from "../index-wL_20vR8.js";
3
+ import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
4
+ import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
5
+ //#region src/react/admin-consumption/admin-consumption.d.ts
6
+ type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
7
+ export declare const getListLiveLeasesUrl: () => string;
8
+ /**
9
+ * What is open right now, within the caller's tenant scope.
10
+ *
11
+ * Read from the ledger rather than the Redis live set: this is a diagnostic and
12
+ * must show the truth even when the cache is cold, and it runs once when
13
+ * somebody opens a screen rather than on every read.
14
+ * @summary List Live Leases
15
+ */
16
+ export declare const listLiveLeases: (options?: Parameters<typeof request>[1]) => Promise<LiveLeaseListRead>;
17
+ export declare const getListLiveLeasesQueryKey: () => readonly [`/admin/consumption/live`];
18
+ export declare const getListLiveLeasesQueryOptions: <TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
19
+ query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>>;
20
+ request?: SecondParameter<typeof request>;
21
+ }) => UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData> & {
22
+ queryKey: DataTag<QueryKey, TData, TError>;
23
+ };
24
+ export type ListLiveLeasesQueryResult = NonNullable<Awaited<ReturnType<typeof listLiveLeases>>>;
25
+ export type ListLiveLeasesQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
26
+ export declare function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options: {
27
+ query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, Awaited<ReturnType<typeof listLiveLeases>>>, 'initialData'>;
28
+ request?: SecondParameter<typeof request>;
29
+ }, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
30
+ queryKey: DataTag<QueryKey, TData, TError>;
31
+ };
32
+ export declare function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
33
+ query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, Awaited<ReturnType<typeof listLiveLeases>>>, 'initialData'>;
34
+ request?: SecondParameter<typeof request>;
35
+ }, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
36
+ queryKey: DataTag<QueryKey, TData, TError>;
37
+ };
38
+ export declare function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
39
+ query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>>;
40
+ request?: SecondParameter<typeof request>;
41
+ }, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
42
+ queryKey: DataTag<QueryKey, TData, TError>;
43
+ };
44
+ export declare const getForceCloseLeaseUrl: (eventId: number) => string;
45
+ /**
46
+ * Force-close somebody else's lease. The legacy's ``FermeSessionAdherent``.
47
+ *
48
+ * Audited, which the legacy's was not: a button that ends a stranger's reading
49
+ * session and leaves no trace is indistinguishable from abuse of the same
50
+ * button. Tenant-scoped like every staff action, so a lease outside the
51
+ * caller's scope is ``404`` rather than ``403``.
52
+ * @summary Force Close Lease
53
+ */
54
+ export declare const forceCloseLease: (eventId: number, leaseCloseWrite: LeaseCloseWrite, options?: Parameters<typeof request>[1]) => Promise<void>;
55
+ export declare const getForceCloseLeaseMutationKey: () => readonly ['forceCloseLease'];
56
+ export declare const getForceCloseLeaseMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
57
+ mutation?: UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError, ForceCloseLeaseMutationVariables, TContext>;
58
+ request?: SecondParameter<typeof request>;
59
+ }) => UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError, ForceCloseLeaseMutationVariables, TContext>;
60
+ export type ForceCloseLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof forceCloseLease>>>;
61
+ export type ForceCloseLeaseMutationBody = BodyType<LeaseCloseWrite>;
62
+ export type ForceCloseLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
63
+ export type ForceCloseLeaseMutationVariables = {
64
+ eventId: number;
65
+ data: BodyType<LeaseCloseWrite>;
66
+ };
67
+ /**
68
+ * @summary Force Close Lease
69
+ */
70
+ export declare const useForceCloseLease: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
71
+ mutation?: UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError, ForceCloseLeaseMutationVariables, TContext>;
72
+ request?: SecondParameter<typeof request>;
73
+ }, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof forceCloseLease>>, TError, ForceCloseLeaseMutationVariables, TContext>;
74
+ //#endregion
75
+ //# sourceMappingURL=admin-consumption.d.ts.map
@@ -0,0 +1,127 @@
1
+ "use client";
2
+ import { r as request } from "../client-D3kMOcIr.js";
3
+ import { useMutation, useQuery } from "@tanstack/react-query";
4
+ //#region src/react/admin-consumption/admin-consumption.ts
5
+ /**
6
+ * Generated by orval 🍺
7
+ * Do not edit manually.
8
+ * Mozaik backend
9
+ * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
10
+ * OpenAPI spec version: 0.1.0
11
+ */
12
+ const withQueryKey = (query, queryKey) => {
13
+ const result = { queryKey };
14
+ for (const key of Object.keys(query)) {
15
+ if (key === "queryKey") continue;
16
+ Object.defineProperty(result, key, {
17
+ enumerable: true,
18
+ configurable: true,
19
+ get: () => query[key]
20
+ });
21
+ }
22
+ return result;
23
+ };
24
+ const getListLiveLeasesUrl = () => {
25
+ return `/admin/consumption/live`;
26
+ };
27
+ /**
28
+ * What is open right now, within the caller's tenant scope.
29
+ *
30
+ * Read from the ledger rather than the Redis live set: this is a diagnostic and
31
+ * must show the truth even when the cache is cold, and it runs once when
32
+ * somebody opens a screen rather than on every read.
33
+ * @summary List Live Leases
34
+ */
35
+ const listLiveLeases = async (options) => {
36
+ return request(getListLiveLeasesUrl(), {
37
+ ...options,
38
+ method: "GET"
39
+ });
40
+ };
41
+ const getListLiveLeasesQueryKey = () => {
42
+ return [`/admin/consumption/live`];
43
+ };
44
+ const getListLiveLeasesQueryOptions = (options) => {
45
+ const { query: queryOptions, request: requestOptions } = options ?? {};
46
+ const queryKey = queryOptions?.queryKey ?? getListLiveLeasesQueryKey();
47
+ const queryFn = ({ signal }) => listLiveLeases({
48
+ signal,
49
+ ...requestOptions
50
+ });
51
+ return {
52
+ queryKey,
53
+ queryFn,
54
+ ...queryOptions
55
+ };
56
+ };
57
+ /**
58
+ * @summary List Live Leases
59
+ */
60
+ function useListLiveLeases(options, queryClient) {
61
+ const queryOptions = getListLiveLeasesQueryOptions(options);
62
+ const query = useQuery(queryOptions, queryClient);
63
+ return withQueryKey(query, queryOptions.queryKey);
64
+ }
65
+ const getForceCloseLeaseUrl = (eventId) => {
66
+ return `/admin/consumption/${eventId}`;
67
+ };
68
+ /**
69
+ * Force-close somebody else's lease. The legacy's ``FermeSessionAdherent``.
70
+ *
71
+ * Audited, which the legacy's was not: a button that ends a stranger's reading
72
+ * session and leaves no trace is indistinguishable from abuse of the same
73
+ * button. Tenant-scoped like every staff action, so a lease outside the
74
+ * caller's scope is ``404`` rather than ``403``.
75
+ * @summary Force Close Lease
76
+ */
77
+ const forceCloseLease = async (eventId, leaseCloseWrite, options) => {
78
+ const getHeaders = (h) => {
79
+ if (!h) return {};
80
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
81
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
82
+ const headers = {};
83
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
84
+ return headers;
85
+ };
86
+ return request(getForceCloseLeaseUrl(eventId), {
87
+ ...options,
88
+ method: "DELETE",
89
+ headers: {
90
+ "Content-Type": "application/json",
91
+ ...getHeaders(options?.headers)
92
+ },
93
+ body: JSON.stringify(leaseCloseWrite)
94
+ });
95
+ };
96
+ const getForceCloseLeaseMutationKey = () => ["forceCloseLease"];
97
+ const getForceCloseLeaseMutationOptions = (options) => {
98
+ const mutationKey = getForceCloseLeaseMutationKey();
99
+ const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
100
+ ...options,
101
+ mutation: {
102
+ ...options.mutation,
103
+ mutationKey
104
+ }
105
+ } : {
106
+ mutation: { mutationKey },
107
+ request: void 0
108
+ };
109
+ const mutationFn = (props) => {
110
+ const { eventId, data } = props ?? {};
111
+ return forceCloseLease(eventId, data, requestOptions);
112
+ };
113
+ return {
114
+ mutationFn,
115
+ ...mutationOptions
116
+ };
117
+ };
118
+ /**
119
+ * @summary Force Close Lease
120
+ */
121
+ const useForceCloseLease = (options, queryClient) => {
122
+ return useMutation(getForceCloseLeaseMutationOptions(options), queryClient);
123
+ };
124
+ //#endregion
125
+ export { forceCloseLease, getForceCloseLeaseMutationKey, getForceCloseLeaseMutationOptions, getForceCloseLeaseUrl, getListLiveLeasesQueryKey, getListLiveLeasesQueryOptions, getListLiveLeasesUrl, listLiveLeases, useForceCloseLease, useListLiveLeases };
126
+
127
+ //# sourceMappingURL=admin-consumption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-consumption.js","names":[],"sources":["../../src/react/admin-consumption/admin-consumption.ts"],"sourcesContent":["/**\n * Generated by orval 🍺\n * Do not edit manually.\n * Mozaik backend\n * Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.\n * OpenAPI spec version: 0.1.0\n */\nimport {\n useMutation,\n useQuery\n} from '@tanstack/react-query';\nimport type {\n DataTag,\n DefinedInitialDataOptions,\n DefinedUseQueryResult,\n MutationFunction,\n QueryClient,\n QueryFunction,\n QueryKey,\n UndefinedInitialDataOptions,\n UseMutationOptions,\n UseMutationResult,\n UseQueryOptions,\n UseQueryResult\n} from '@tanstack/react-query';\n\nimport type {\n HTTPExceptionResponse,\n LeaseCloseWrite,\n LiveLeaseListRead,\n ValidationErrorResponse\n} from '../../models';\n\nimport { request } from '../../client';\nimport type { ErrorType , BodyType } from '../../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n\nconst withQueryKey = <T extends object, K>(query: T, queryKey: K): T & { queryKey: K } => {\n const result = { queryKey } as T & { queryKey: K };\n for (const key of Object.keys(query)) {\n // The explicit queryKey always wins, matching the previous\n // `{ ...query, queryKey }` spread where it was set last.\n if (key === 'queryKey') continue;\n Object.defineProperty(result, key, {\n enumerable: true,\n configurable: true,\n get: () => (query as Record<string, unknown>)[key],\n });\n }\n return result;\n};\n\nexport const getListLiveLeasesUrl = () => {\n\n\n\n\n return `/admin/consumption/live`\n}\n\n/**\n * What is open right now, within the caller's tenant scope.\n *\n * Read from the ledger rather than the Redis live set: this is a diagnostic and\n * must show the truth even when the cache is cold, and it runs once when\n * somebody opens a screen rather than on every read.\n * @summary List Live Leases\n */\nexport const listLiveLeases = async ( options?: Parameters<typeof request>[1]): Promise<LiveLeaseListRead> => {\n\n return request<LiveLeaseListRead>(getListLiveLeasesUrl(),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListLiveLeasesQueryKey = () => {\n return [\n `/admin/consumption/live`\n ] as const;\n }\n\n\nexport const getListLiveLeasesQueryOptions = <TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>( options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListLiveLeasesQueryKey();\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listLiveLeases>>> = ({ signal }) => listLiveLeases({ signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListLiveLeasesQueryResult = NonNullable<Awaited<ReturnType<typeof listLiveLeases>>>\nexport type ListLiveLeasesQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listLiveLeases>>,\n TError,\n Awaited<ReturnType<typeof listLiveLeases>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listLiveLeases>>,\n TError,\n Awaited<ReturnType<typeof listLiveLeases>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Live Leases\n */\n\nexport function useListLiveLeases<TData = Awaited<ReturnType<typeof listLiveLeases>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listLiveLeases>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListLiveLeasesQueryOptions(options)\n\n const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };\n\n return withQueryKey(query, queryOptions.queryKey);\n}\n\n\n\n\n\n\nexport const getForceCloseLeaseUrl = (eventId: number,) => {\n\n\n\n\n return `/admin/consumption/${eventId}`\n}\n\n/**\n * Force-close somebody else's lease. The legacy's ``FermeSessionAdherent``.\n *\n * Audited, which the legacy's was not: a button that ends a stranger's reading\n * session and leaves no trace is indistinguishable from abuse of the same\n * button. Tenant-scoped like every staff action, so a lease outside the\n * caller's scope is ``404`` rather than ``403``.\n * @summary Force Close Lease\n */\nexport const forceCloseLease = async (eventId: number,\n leaseCloseWrite: LeaseCloseWrite, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {\n if (!h) return {};\n if (h instanceof Headers) return Object.fromEntries(h.entries());\n if (Symbol.iterator in h) {\n return Object.fromEntries(\n Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),\n );\n }\n const headers: Record<string, string | readonly string[]> = {};\n for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {\n if (value !== undefined) headers[name] = value;\n }\n return headers;\n };\nreturn request<void>(getForceCloseLeaseUrl(eventId),\n {\n ...options,\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(leaseCloseWrite)\n }\n);}\n\n\n\n\n\nexport const getForceCloseLeaseMutationKey = () => ['forceCloseLease'] as const;\n\nexport const getForceCloseLeaseMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError,ForceCloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError,ForceCloseLeaseMutationVariables, TContext> => {\n\nconst mutationKey = getForceCloseLeaseMutationKey();\nconst {mutation: mutationOptions, request: requestOptions} = options ?\n options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?\n options\n : {...options, mutation: {...options.mutation, mutationKey}}\n : {mutation: { mutationKey, }, request: undefined};\n\n\n\n\n const mutationFn: MutationFunction<Awaited<ReturnType<typeof forceCloseLease>>, ForceCloseLeaseMutationVariables> = (props) => {\n const {eventId,data} = props ?? {};\n\n return forceCloseLease(eventId,data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type ForceCloseLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof forceCloseLease>>>\n export type ForceCloseLeaseMutationBody = BodyType<LeaseCloseWrite>\n export type ForceCloseLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type ForceCloseLeaseMutationVariables = {eventId: number;data: BodyType<LeaseCloseWrite>}\n\n /**\n * @summary Force Close Lease\n */\nexport const useForceCloseLease = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof forceCloseLease>>, TError,ForceCloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof forceCloseLease>>,\n TError,\n ForceCloseLeaseMutationVariables,\n TContext\n > => {\n return useMutation(getForceCloseLeaseMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AAyCA,MAAM,gBAAqC,OAAU,aAAqC;CACxF,MAAM,SAAS,EAAE,SAAS;CAC1B,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EAGpC,IAAI,QAAQ,YAAY;EACxB,OAAO,eAAe,QAAQ,KAAK;GACjC,YAAY;GACZ,cAAc;GACd,WAAY,MAAkC;EAChD,CAAC;CACH;CACA,OAAO;AACT;AAEA,MAAa,6BAA6B;CAKxC,OAAO;AACT;;;;;;;;;AAUA,MAAa,iBAAiB,OAAQ,YAAwE;CAE5G,OAAO,QAA2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