@learnorama/mozaik-sdk 0.1.0 → 0.3.2-staging.19.1

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 (242) hide show
  1. package/README.md +186 -5
  2. package/dist/api/account.d.ts +2 -2
  3. package/dist/api/account.js +1 -1
  4. package/dist/api/account.js.map +1 -1
  5. package/dist/api/admin-catalogue.d.ts +2 -2
  6. package/dist/api/admin-catalogue.js +1 -1
  7. package/dist/api/admin-catalogue.js.map +1 -1
  8. package/dist/api/admin-consumption.d.ts +7 -2
  9. package/dist/api/admin-consumption.js +6 -1
  10. package/dist/api/admin-consumption.js.map +1 -1
  11. package/dist/api/admin-licenses.d.ts +2 -2
  12. package/dist/api/admin-licenses.js +1 -1
  13. package/dist/api/admin-licenses.js.map +1 -1
  14. package/dist/api/admin-patrons.d.ts +3 -3
  15. package/dist/api/admin-patrons.js +2 -2
  16. package/dist/api/admin-patrons.js.map +1 -1
  17. package/dist/api/admin-reviews.d.ts +2 -2
  18. package/dist/api/admin-reviews.js +1 -1
  19. package/dist/api/admin-reviews.js.map +1 -1
  20. package/dist/api/admin-roles.d.ts +3 -3
  21. package/dist/api/admin-roles.js +2 -2
  22. package/dist/api/admin-roles.js.map +1 -1
  23. package/dist/api/admin-support.d.ts +2 -2
  24. package/dist/api/admin-support.js +1 -1
  25. package/dist/api/admin-support.js.map +1 -1
  26. package/dist/api/admin-tenants.d.ts +8 -2
  27. package/dist/api/admin-tenants.js +20 -2
  28. package/dist/api/admin-tenants.js.map +1 -1
  29. package/dist/api/admin-tutoring.d.ts +2 -2
  30. package/dist/api/admin-tutoring.js +1 -1
  31. package/dist/api/admin-tutoring.js.map +1 -1
  32. package/dist/api/auth.d.ts +2 -2
  33. package/dist/api/auth.js +1 -1
  34. package/dist/api/auth.js.map +1 -1
  35. package/dist/api/biblio-catalogue.d.ts +2 -2
  36. package/dist/api/biblio-catalogue.js +1 -1
  37. package/dist/api/biblio-catalogue.js.map +1 -1
  38. package/dist/api/biblio-home.d.ts +2 -2
  39. package/dist/api/biblio-home.js +1 -1
  40. package/dist/api/biblio-home.js.map +1 -1
  41. package/dist/api/biblio-library.d.ts +2 -2
  42. package/dist/api/biblio-library.js +1 -1
  43. package/dist/api/biblio-library.js.map +1 -1
  44. package/dist/api/biblio-nextory.d.ts +2 -2
  45. package/dist/api/biblio-nextory.js +1 -1
  46. package/dist/api/biblio-nextory.js.map +1 -1
  47. package/dist/api/biblio-press.d.ts +2 -2
  48. package/dist/api/biblio-press.js +1 -1
  49. package/dist/api/biblio-press.js.map +1 -1
  50. package/dist/api/biblio-search.d.ts +2 -2
  51. package/dist/api/biblio-search.js +1 -1
  52. package/dist/api/biblio-search.js.map +1 -1
  53. package/dist/api/biblio-telemetry.d.ts +2 -2
  54. package/dist/api/biblio-telemetry.js +1 -1
  55. package/dist/api/biblio-telemetry.js.map +1 -1
  56. package/dist/api/consumption.d.ts +2 -2
  57. package/dist/api/consumption.js +1 -1
  58. package/dist/api/consumption.js.map +1 -1
  59. package/dist/api/cvs-app.d.ts +2 -2
  60. package/dist/api/cvs-app.js +1 -1
  61. package/dist/api/cvs-app.js.map +1 -1
  62. package/dist/api/cvs-documents.d.ts +16 -4
  63. package/dist/api/cvs-documents.js +22 -5
  64. package/dist/api/cvs-documents.js.map +1 -1
  65. package/dist/api/cvs-favorites.d.ts +2 -2
  66. package/dist/api/cvs-favorites.js +1 -1
  67. package/dist/api/cvs-favorites.js.map +1 -1
  68. package/dist/api/cvs-ils.d.ts +167 -0
  69. package/dist/api/cvs-ils.js +362 -0
  70. package/dist/api/cvs-ils.js.map +1 -0
  71. package/dist/api/cvs-loans.d.ts +2 -2
  72. package/dist/api/cvs-loans.js +1 -1
  73. package/dist/api/cvs-loans.js.map +1 -1
  74. package/dist/api/cvs-payments.d.ts +49 -0
  75. package/dist/api/cvs-payments.js +84 -0
  76. package/dist/api/cvs-payments.js.map +1 -0
  77. package/dist/api/cvs-streaming.d.ts +2 -2
  78. package/dist/api/cvs-streaming.js +1 -1
  79. package/dist/api/cvs-streaming.js.map +1 -1
  80. package/dist/api/index.d.ts +5 -2
  81. package/dist/api/index.js +7 -4
  82. package/dist/api/partner-catalogue.d.ts +2 -2
  83. package/dist/api/partner-catalogue.js +1 -1
  84. package/dist/api/partner-catalogue.js.map +1 -1
  85. package/dist/api/partner-reader.d.ts +2 -2
  86. package/dist/api/partner-reader.js +1 -1
  87. package/dist/api/partner-reader.js.map +1 -1
  88. package/dist/api/profiles.d.ts +2 -2
  89. package/dist/api/profiles.js +1 -1
  90. package/dist/api/profiles.js.map +1 -1
  91. package/dist/api/search.d.ts +18 -0
  92. package/dist/api/search.js +37 -0
  93. package/dist/api/search.js.map +1 -0
  94. package/dist/api/tutoring-catalogue.d.ts +2 -2
  95. package/dist/api/tutoring-catalogue.js +1 -1
  96. package/dist/api/tutoring-catalogue.js.map +1 -1
  97. package/dist/api/tutoring-chat.d.ts +2 -2
  98. package/dist/api/tutoring-chat.js +1 -1
  99. package/dist/api/tutoring-chat.js.map +1 -1
  100. package/dist/api/tutoring-dispatch.d.ts +2 -2
  101. package/dist/api/tutoring-dispatch.js +1 -1
  102. package/dist/api/tutoring-dispatch.js.map +1 -1
  103. package/dist/api/tutoring-practitioner.d.ts +2 -2
  104. package/dist/api/tutoring-practitioner.js +1 -1
  105. package/dist/api/tutoring-practitioner.js.map +1 -1
  106. package/dist/api/tutoring-requests.d.ts +2 -2
  107. package/dist/api/tutoring-requests.js +1 -1
  108. package/dist/api/tutoring-requests.js.map +1 -1
  109. package/dist/auth.d.ts +10 -0
  110. package/dist/auth.js +451 -0
  111. package/dist/auth.js.map +1 -0
  112. package/dist/chat.d.ts +3 -0
  113. package/dist/chat.js +3 -0
  114. package/dist/{client-BDwBZYB0.d.ts → chunks/client.d.ts} +1 -1
  115. package/dist/{client-D3kMOcIr.js → chunks/client.js} +1 -1
  116. package/dist/chunks/client.js.map +1 -0
  117. package/dist/chunks/client2.d.ts +53 -0
  118. package/dist/chunks/connection.d.ts +28 -0
  119. package/dist/chunks/connection.js +141 -0
  120. package/dist/chunks/connection.js.map +1 -0
  121. package/dist/{index-wL_20vR8.d.ts → chunks/index.d.ts} +901 -128
  122. package/dist/index.d.ts +4 -4
  123. package/dist/index.js +4 -4
  124. package/dist/index.js.map +1 -1
  125. package/dist/models.d.ts +2 -2
  126. package/dist/models.js +44 -1
  127. package/dist/models.js.map +1 -1
  128. package/dist/react/account.d.ts +2 -2
  129. package/dist/react/account.js +2 -2
  130. package/dist/react/account.js.map +1 -1
  131. package/dist/react/admin-catalogue.d.ts +2 -2
  132. package/dist/react/admin-catalogue.js +2 -2
  133. package/dist/react/admin-catalogue.js.map +1 -1
  134. package/dist/react/admin-consumption.d.ts +7 -2
  135. package/dist/react/admin-consumption.js +7 -2
  136. package/dist/react/admin-consumption.js.map +1 -1
  137. package/dist/react/admin-licenses.d.ts +2 -2
  138. package/dist/react/admin-licenses.js +2 -2
  139. package/dist/react/admin-licenses.js.map +1 -1
  140. package/dist/react/admin-patrons.d.ts +3 -3
  141. package/dist/react/admin-patrons.js +3 -3
  142. package/dist/react/admin-patrons.js.map +1 -1
  143. package/dist/react/admin-reviews.d.ts +2 -2
  144. package/dist/react/admin-reviews.js +2 -2
  145. package/dist/react/admin-reviews.js.map +1 -1
  146. package/dist/react/admin-roles.d.ts +3 -3
  147. package/dist/react/admin-roles.js +3 -3
  148. package/dist/react/admin-roles.js.map +1 -1
  149. package/dist/react/admin-support.d.ts +2 -2
  150. package/dist/react/admin-support.js +2 -2
  151. package/dist/react/admin-support.js.map +1 -1
  152. package/dist/react/admin-tenants.d.ts +35 -2
  153. package/dist/react/admin-tenants.js +45 -3
  154. package/dist/react/admin-tenants.js.map +1 -1
  155. package/dist/react/admin-tutoring.d.ts +2 -2
  156. package/dist/react/admin-tutoring.js +2 -2
  157. package/dist/react/admin-tutoring.js.map +1 -1
  158. package/dist/react/auth.d.ts +2 -2
  159. package/dist/react/auth.js +2 -2
  160. package/dist/react/auth.js.map +1 -1
  161. package/dist/react/biblio-catalogue.d.ts +2 -2
  162. package/dist/react/biblio-catalogue.js +2 -2
  163. package/dist/react/biblio-catalogue.js.map +1 -1
  164. package/dist/react/biblio-home.d.ts +2 -2
  165. package/dist/react/biblio-home.js +2 -2
  166. package/dist/react/biblio-home.js.map +1 -1
  167. package/dist/react/biblio-library.d.ts +2 -2
  168. package/dist/react/biblio-library.js +2 -2
  169. package/dist/react/biblio-library.js.map +1 -1
  170. package/dist/react/biblio-nextory.d.ts +2 -2
  171. package/dist/react/biblio-nextory.js +2 -2
  172. package/dist/react/biblio-nextory.js.map +1 -1
  173. package/dist/react/biblio-press.d.ts +2 -2
  174. package/dist/react/biblio-press.js +2 -2
  175. package/dist/react/biblio-press.js.map +1 -1
  176. package/dist/react/biblio-search.d.ts +2 -2
  177. package/dist/react/biblio-search.js +2 -2
  178. package/dist/react/biblio-search.js.map +1 -1
  179. package/dist/react/biblio-telemetry.d.ts +2 -2
  180. package/dist/react/biblio-telemetry.js +2 -2
  181. package/dist/react/biblio-telemetry.js.map +1 -1
  182. package/dist/react/chat.d.ts +36 -0
  183. package/dist/react/chat.js +234 -0
  184. package/dist/react/chat.js.map +1 -0
  185. package/dist/react/consumption.d.ts +2 -2
  186. package/dist/react/consumption.js +2 -2
  187. package/dist/react/consumption.js.map +1 -1
  188. package/dist/react/cvs-app.d.ts +2 -2
  189. package/dist/react/cvs-app.js +2 -2
  190. package/dist/react/cvs-app.js.map +1 -1
  191. package/dist/react/cvs-documents.d.ts +17 -4
  192. package/dist/react/cvs-documents.js +25 -8
  193. package/dist/react/cvs-documents.js.map +1 -1
  194. package/dist/react/cvs-favorites.d.ts +2 -2
  195. package/dist/react/cvs-favorites.js +2 -2
  196. package/dist/react/cvs-favorites.js.map +1 -1
  197. package/dist/react/cvs-ils.d.ts +552 -0
  198. package/dist/react/cvs-ils.js +822 -0
  199. package/dist/react/cvs-ils.js.map +1 -0
  200. package/dist/react/cvs-loans.d.ts +2 -2
  201. package/dist/react/cvs-loans.js +2 -2
  202. package/dist/react/cvs-loans.js.map +1 -1
  203. package/dist/react/cvs-payments.d.ts +123 -0
  204. package/dist/react/cvs-payments.js +181 -0
  205. package/dist/react/cvs-payments.js.map +1 -0
  206. package/dist/react/cvs-streaming.d.ts +2 -2
  207. package/dist/react/cvs-streaming.js +2 -2
  208. package/dist/react/cvs-streaming.js.map +1 -1
  209. package/dist/react/index.d.ts +5 -2
  210. package/dist/react/index.js +5 -2
  211. package/dist/react/partner-catalogue.d.ts +2 -2
  212. package/dist/react/partner-catalogue.js +2 -2
  213. package/dist/react/partner-catalogue.js.map +1 -1
  214. package/dist/react/partner-reader.d.ts +2 -2
  215. package/dist/react/partner-reader.js +2 -2
  216. package/dist/react/partner-reader.js.map +1 -1
  217. package/dist/react/profiles.d.ts +2 -2
  218. package/dist/react/profiles.js +2 -2
  219. package/dist/react/profiles.js.map +1 -1
  220. package/dist/react/search.d.ts +47 -0
  221. package/dist/react/search.js +81 -0
  222. package/dist/react/search.js.map +1 -0
  223. package/dist/react/sso.d.ts +15 -0
  224. package/dist/react/sso.js +48 -0
  225. package/dist/react/sso.js.map +1 -0
  226. package/dist/react/tutoring-catalogue.d.ts +2 -2
  227. package/dist/react/tutoring-catalogue.js +2 -2
  228. package/dist/react/tutoring-catalogue.js.map +1 -1
  229. package/dist/react/tutoring-chat.d.ts +2 -2
  230. package/dist/react/tutoring-chat.js +2 -2
  231. package/dist/react/tutoring-chat.js.map +1 -1
  232. package/dist/react/tutoring-dispatch.d.ts +2 -2
  233. package/dist/react/tutoring-dispatch.js +2 -2
  234. package/dist/react/tutoring-dispatch.js.map +1 -1
  235. package/dist/react/tutoring-practitioner.d.ts +2 -2
  236. package/dist/react/tutoring-practitioner.js +2 -2
  237. package/dist/react/tutoring-practitioner.js.map +1 -1
  238. package/dist/react/tutoring-requests.d.ts +2 -2
  239. package/dist/react/tutoring-requests.js +2 -2
  240. package/dist/react/tutoring-requests.js.map +1 -1
  241. package/package.json +29 -1
  242. package/dist/client-D3kMOcIr.js.map +0 -1
@@ -0,0 +1,36 @@
1
+
2
+ import { cn as MessageWrite, un as MessageRead } from "../chunks/index.js";
3
+ import { r as Client } from "../chunks/client.js";
4
+ import { n as ChatConnectionOptions, r as ChatStatus } from "../chunks/connection.js";
5
+ //#region src/chat/react.d.ts
6
+ export interface UseTutoringChatOptions {
7
+ /** Keep this instance stable (create it once per signed-in account). */
8
+ client: Client;
9
+ requestId: number | null;
10
+ enabled?: boolean;
11
+ pageSize?: number;
12
+ webSocketFactory?: ChatConnectionOptions['webSocketFactory'];
13
+ retryDelay?: ChatConnectionOptions['retryDelay'];
14
+ connectTimeoutMs?: number;
15
+ }
16
+ /** Student/teacher chat: persisted history, confirmed HTTP sends and a recovering live feed. */
17
+ export declare function useTutoringChat({ client, requestId, enabled, pageSize, webSocketFactory, retryDelay, connectTimeoutMs }: UseTutoringChatOptions): {
18
+ /** Oldest first; duplicates from HTTP responses, history and live delivery are merged. */
19
+ messages: MessageRead[];
20
+ status: ChatStatus;
21
+ error: Error | null;
22
+ hasMore: boolean;
23
+ isLoading: boolean;
24
+ loadOlder: () => Promise<void>;
25
+ isLoadingOlder: boolean;
26
+ loadOlderError: Error | null;
27
+ /** Supply the same clientKey when explicitly retrying a failed send. */
28
+ sendMessage: (message: MessageWrite) => Promise<MessageRead>;
29
+ isSending: boolean;
30
+ sendError: Error | null;
31
+ /** Contains the generated clientKey, allowing safe explicit retries. */
32
+ lastSend: MessageWrite | undefined;
33
+ };
34
+ export type TutoringChatResult = ReturnType<typeof useTutoringChat>;
35
+ //#endregion
36
+ //# sourceMappingURL=chat.d.ts.map
@@ -0,0 +1,234 @@
1
+ "use client";
2
+ "use client";
3
+ import { listMessages, sendMessage } from "../api/tutoring-chat.js";
4
+ import { n as parseMessage, t as connectTutoringChat } from "../chunks/connection.js";
5
+ import { useEffect, useId, useMemo, useState } from "react";
6
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
7
+ //#region src/chat/react.ts
8
+ const emptyHistory = {
9
+ messages: [],
10
+ initialized: false,
11
+ hasMore: false,
12
+ nextBefore: null
13
+ };
14
+ const clientIds = /* @__PURE__ */ new WeakMap();
15
+ let nextClientId = 0;
16
+ function clientId(client) {
17
+ let id = clientIds.get(client);
18
+ if (id === void 0) {
19
+ id = ++nextClientId;
20
+ clientIds.set(client, id);
21
+ }
22
+ return id;
23
+ }
24
+ function merge(previous, messages) {
25
+ const byId = new Map((previous?.messages ?? []).map((message) => [message.id, message]));
26
+ for (const message of messages) byId.set(message.id, message);
27
+ return {
28
+ ...previous ?? emptyHistory,
29
+ messages: [...byId.values()].sort((a, b) => a.id - b.id)
30
+ };
31
+ }
32
+ /** Student/teacher chat: persisted history, confirmed HTTP sends and a recovering live feed. */
33
+ function useTutoringChat({ client, requestId, enabled = true, pageSize = 50, webSocketFactory, retryDelay, connectTimeoutMs }) {
34
+ if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 200) throw new TypeError("pageSize must be between 1 and 200");
35
+ if (requestId !== null && (!Number.isSafeInteger(requestId) || requestId <= 0)) throw new TypeError("requestId must be a positive safe integer or null");
36
+ const queryClient = useQueryClient();
37
+ const instance = useId();
38
+ const queryKey = useMemo(() => [
39
+ "mozaik",
40
+ "chat",
41
+ instance,
42
+ clientId(client),
43
+ requestId
44
+ ], [
45
+ instance,
46
+ client,
47
+ requestId
48
+ ]);
49
+ const active = enabled && requestId !== null;
50
+ const [connection, setConnection] = useState({
51
+ key: queryKey,
52
+ status: active ? "connecting" : "closed",
53
+ error: null
54
+ });
55
+ const history = useQuery({
56
+ queryKey,
57
+ enabled: false,
58
+ gcTime: 0,
59
+ retry: false,
60
+ queryFn: async ({ signal }) => {
61
+ const previous = queryClient.getQueryData(queryKey);
62
+ const newest = previous?.receivedThrough;
63
+ const recovered = [];
64
+ let before;
65
+ let lastPage;
66
+ do {
67
+ const page = await listMessages(requestId, {
68
+ limit: pageSize,
69
+ before
70
+ }, {
71
+ client,
72
+ signal: AbortSignal.any([signal, AbortSignal.timeout(2e4)])
73
+ });
74
+ recovered.push(...page.data.map((message) => parseMessage(message, requestId)));
75
+ lastPage = page;
76
+ if (!newest || !page.hasMore || page.data.some((message) => message.id <= newest)) break;
77
+ if (!page.nextBefore || before !== void 0 && page.nextBefore >= before) throw new Error("Invalid chat history cursor");
78
+ before = page.nextBefore;
79
+ } while (true);
80
+ const result = merge(queryClient.getQueryData(queryKey), recovered);
81
+ result.initialized = true;
82
+ result.receivedThrough = recovered.reduce((id, row) => Math.max(id, row.id), newest ?? 0) || void 0;
83
+ if (!previous?.initialized || !previous.messages.length) {
84
+ result.hasMore = Boolean(lastPage.hasMore);
85
+ result.nextBefore = lastPage.nextBefore ?? null;
86
+ }
87
+ return result;
88
+ }
89
+ });
90
+ useEffect(() => {
91
+ if (!active) return;
92
+ let alive = true;
93
+ const live = connectTutoringChat({
94
+ client,
95
+ requestId,
96
+ webSocketFactory,
97
+ retryDelay,
98
+ connectTimeoutMs,
99
+ onConnect: async (signal) => {
100
+ const cancel = () => {
101
+ queryClient.cancelQueries({
102
+ queryKey,
103
+ exact: true
104
+ });
105
+ };
106
+ signal.addEventListener("abort", cancel, { once: true });
107
+ try {
108
+ const result = await history.refetch({
109
+ throwOnError: true,
110
+ cancelRefetch: true
111
+ });
112
+ signal.throwIfAborted();
113
+ if (result.isError) throw result.error;
114
+ } finally {
115
+ signal.removeEventListener("abort", cancel);
116
+ }
117
+ },
118
+ onMessage: (message) => {
119
+ if (alive) queryClient.setQueryData(queryKey, (previous) => ({
120
+ ...merge(previous, [message]),
121
+ receivedThrough: Math.max(previous?.receivedThrough ?? 0, message.id)
122
+ }));
123
+ },
124
+ onStatusChange: (status) => {
125
+ if (alive) setConnection((previous) => ({
126
+ key: queryKey,
127
+ status,
128
+ error: status === "connected" ? null : previous.error
129
+ }));
130
+ },
131
+ onError: (error) => {
132
+ if (alive) setConnection((previous) => ({
133
+ key: queryKey,
134
+ status: previous.status,
135
+ error
136
+ }));
137
+ }
138
+ });
139
+ return () => {
140
+ alive = false;
141
+ live.close();
142
+ queryClient.resetQueries({
143
+ queryKey,
144
+ exact: true
145
+ });
146
+ };
147
+ }, [
148
+ active,
149
+ client,
150
+ requestId,
151
+ queryKey,
152
+ queryClient,
153
+ webSocketFactory,
154
+ retryDelay,
155
+ connectTimeoutMs,
156
+ history.refetch
157
+ ]);
158
+ const lifetime = useMemo(() => ({ abort: new AbortController() }), [queryKey, active]);
159
+ useEffect(() => {
160
+ lifetime.abort = new AbortController();
161
+ return () => lifetime.abort.abort();
162
+ }, [lifetime]);
163
+ const sending = useMutation({
164
+ mutationKey: [...queryKey, "send"],
165
+ retry: false,
166
+ gcTime: 0,
167
+ mutationFn: async ({ message, scope }) => {
168
+ if (!active || scope !== lifetime) throw new Error("Chat is disabled");
169
+ const signal = lifetime.abort.signal;
170
+ const saved = parseMessage(await sendMessage(requestId, message, {
171
+ client,
172
+ signal: AbortSignal.any([signal, AbortSignal.timeout(2e4)])
173
+ }), requestId);
174
+ signal.throwIfAborted();
175
+ queryClient.setQueryData(queryKey, (previous) => merge(previous, [saved]));
176
+ return saved;
177
+ }
178
+ });
179
+ const older = useMutation({
180
+ mutationKey: [...queryKey, "older"],
181
+ retry: false,
182
+ gcTime: 0,
183
+ mutationFn: async () => {
184
+ const previous = queryClient.getQueryData(queryKey);
185
+ if (!active || !previous?.hasMore || !previous.nextBefore) return;
186
+ const signal = lifetime.abort.signal;
187
+ const page = await listMessages(requestId, {
188
+ before: previous.nextBefore,
189
+ limit: pageSize
190
+ }, {
191
+ client,
192
+ signal: AbortSignal.any([signal, AbortSignal.timeout(2e4)])
193
+ });
194
+ signal.throwIfAborted();
195
+ queryClient.setQueryData(queryKey, (current) => ({
196
+ ...merge(current, page.data.map((message) => parseMessage(message, requestId))),
197
+ hasMore: Boolean(page.hasMore),
198
+ nextBefore: page.nextBefore ?? null
199
+ }));
200
+ }
201
+ });
202
+ return {
203
+ /** Oldest first; duplicates from HTTP responses, history and live delivery are merged. */
204
+ messages: active ? history.data?.messages ?? emptyHistory.messages : emptyHistory.messages,
205
+ status: !active ? "closed" : connection.key === queryKey ? connection.status : "connecting",
206
+ error: active && connection.key === queryKey ? connection.error : null,
207
+ hasMore: active && Boolean(history.data?.hasMore),
208
+ isLoading: active && !history.data?.initialized && connection.status !== "error",
209
+ loadOlder: () => {
210
+ if (!lifetime.older) lifetime.older = older.mutateAsync().finally(() => {
211
+ lifetime.older = void 0;
212
+ });
213
+ return lifetime.older;
214
+ },
215
+ isLoadingOlder: older.isPending,
216
+ loadOlderError: older.error,
217
+ /** Supply the same clientKey when explicitly retrying a failed send. */
218
+ sendMessage: (message) => sending.mutateAsync({
219
+ message: {
220
+ ...message,
221
+ clientKey: message.clientKey ?? crypto.randomUUID()
222
+ },
223
+ scope: lifetime
224
+ }),
225
+ isSending: active && sending.variables?.scope === lifetime && sending.isPending,
226
+ sendError: active && sending.variables?.scope === lifetime ? sending.error : null,
227
+ /** Contains the generated clientKey, allowing safe explicit retries. */
228
+ lastSend: active && sending.variables?.scope === lifetime ? sending.variables.message : void 0
229
+ };
230
+ }
231
+ //#endregion
232
+ export { useTutoringChat };
233
+
234
+ //# sourceMappingURL=chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat.js","names":[],"sources":["../../src/chat/react.ts"],"sourcesContent":["'use client';\n\n// Kept outside src/react: prepare-schema deletes that generated directory.\nimport { useEffect, useId, useMemo, useState } from 'react';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport type { Client } from '../client';\nimport { listMessages, sendMessage } from '../api/tutoring-chat/tutoring-chat';\nimport type { MessageRead, MessageWrite } from '../models';\nimport { connectTutoringChat, parseMessage, type ChatConnectionOptions, type ChatStatus } from './connection';\n\nexport interface UseTutoringChatOptions {\n /** Keep this instance stable (create it once per signed-in account). */\n client: Client;\n requestId: number | null;\n enabled?: boolean;\n pageSize?: number;\n webSocketFactory?: ChatConnectionOptions['webSocketFactory'];\n retryDelay?: ChatConnectionOptions['retryDelay'];\n connectTimeoutMs?: number;\n}\n\ninterface History {\n messages: MessageRead[];\n initialized: boolean;\n receivedThrough?: number;\n hasMore: boolean;\n nextBefore: number | null;\n}\n\nconst emptyHistory: History = { messages: [], initialized: false, hasMore: false, nextBefore: null };\nconst clientIds = new WeakMap<Client, number>();\nlet nextClientId = 0;\nfunction clientId(client: Client): number {\n let id = clientIds.get(client);\n if (id === undefined) { id = ++nextClientId; clientIds.set(client, id); }\n return id;\n}\nfunction merge(previous: History | undefined, messages: MessageRead[]): History {\n const byId = new Map((previous?.messages ?? []).map(message => [message.id, message]));\n for (const message of messages) byId.set(message.id, message);\n return { ...previous ?? emptyHistory, messages: [...byId.values()].sort((a, b) => a.id - b.id) };\n}\n\n/** Student/teacher chat: persisted history, confirmed HTTP sends and a recovering live feed. */\nexport function useTutoringChat({\n client, requestId, enabled = true, pageSize = 50,\n webSocketFactory, retryDelay, connectTimeoutMs,\n}: UseTutoringChatOptions) {\n if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 200) throw new TypeError('pageSize must be between 1 and 200');\n if (requestId !== null && (!Number.isSafeInteger(requestId) || requestId <= 0)) throw new TypeError('requestId must be a positive safe integer or null');\n const queryClient = useQueryClient();\n const instance = useId();\n // Private per hook/account/room: neither credentials nor another room's data\n // can be inherited through an otherwise identical generated REST query key.\n const queryKey = useMemo(() => ['mozaik', 'chat', instance, clientId(client), requestId] as const, [instance, client, requestId]);\n const active = enabled && requestId !== null;\n const [connection, setConnection] = useState<{ key: typeof queryKey; status: ChatStatus; error: Error | null }>({ key: queryKey, status: active ? 'connecting' : 'closed', error: null });\n\n const history = useQuery<History>({\n queryKey, enabled: false, gcTime: 0, retry: false,\n // Only fetched after WebSocket open guarantees subscription readiness.\n // Live frames are buffered by the transport while this snapshot is fetched.\n queryFn: async ({ signal }) => {\n const previous = queryClient.getQueryData<History>(queryKey);\n // A confirmed HTTP send while disconnected must not advance the replay\n // boundary past other participants' missed messages.\n const newest = previous?.receivedThrough;\n const recovered: MessageRead[] = [];\n let before: number | undefined;\n let lastPage;\n do {\n const page = await listMessages(requestId!, { limit: pageSize, before }, {\n client, signal: AbortSignal.any([signal, AbortSignal.timeout(20_000)]),\n });\n recovered.push(...page.data.map(message => parseMessage(message, requestId!)));\n lastPage = page;\n if (!newest || !page.hasMore || page.data.some(message => message.id <= newest)) break;\n if (!page.nextBefore || (before !== undefined && page.nextBefore >= before)) throw new Error('Invalid chat history cursor');\n before = page.nextBefore;\n } while (true);\n // HTTP sends can complete while recovery is in flight; retain those too.\n const current = queryClient.getQueryData<History>(queryKey);\n const result = merge(current, recovered);\n result.initialized = true;\n result.receivedThrough = recovered.reduce((id, row) => Math.max(id, row.id), newest ?? 0) || undefined;\n if (!previous?.initialized || !previous.messages.length) {\n result.hasMore = Boolean(lastPage.hasMore);\n result.nextBefore = lastPage.nextBefore ?? null;\n }\n return result;\n },\n });\n\n useEffect(() => {\n if (!active) return;\n let alive = true;\n const live = connectTutoringChat({\n client, requestId: requestId!, webSocketFactory, retryDelay, connectTimeoutMs,\n onConnect: async signal => {\n const cancel = () => { void queryClient.cancelQueries({ queryKey, exact: true }); };\n signal.addEventListener('abort', cancel, { once: true });\n try {\n const result = await history.refetch({ throwOnError: true, cancelRefetch: true });\n signal.throwIfAborted();\n if (result.isError) throw result.error;\n } finally { signal.removeEventListener('abort', cancel); }\n },\n onMessage: message => {\n if (alive) queryClient.setQueryData<History>(queryKey, previous => ({\n ...merge(previous, [message]), receivedThrough: Math.max(previous?.receivedThrough ?? 0, message.id),\n }));\n },\n onStatusChange: status => {\n if (alive) setConnection(previous => ({ key: queryKey, status, error: status === 'connected' ? null : previous.error }));\n },\n onError: error => {\n if (alive) setConnection(previous => ({ key: queryKey, status: previous.status, error }));\n },\n });\n return () => {\n alive = false;\n live.close();\n // Reset also aborts outstanding history. gcTime: 0 removes the private\n // cache once its observer unmounts; resetting is safe under Strict Mode.\n void queryClient.resetQueries({ queryKey, exact: true });\n };\n }, [active, client, requestId, queryKey, queryClient, webSocketFactory, retryDelay, connectTimeoutMs, history.refetch]);\n\n // The lifetime signal fences sends/older-history requests across room/account\n // switches and Strict Mode's setup → cleanup → setup cycle.\n const lifetime = useMemo<{ abort: AbortController; older?: Promise<void> }>(() => ({ abort: new AbortController() }), [queryKey, active]);\n useEffect(() => {\n lifetime.abort = new AbortController();\n return () => lifetime.abort.abort();\n }, [lifetime]);\n\n const sending = useMutation({\n mutationKey: [...queryKey, 'send'], retry: false, gcTime: 0,\n mutationFn: async ({ message, scope }: { message: MessageWrite; scope: object }) => {\n if (!active || scope !== lifetime) throw new Error('Chat is disabled');\n const signal = lifetime.abort.signal;\n const saved = parseMessage(await sendMessage(requestId!, message, {\n client, signal: AbortSignal.any([signal, AbortSignal.timeout(20_000)]),\n }), requestId!);\n signal.throwIfAborted();\n queryClient.setQueryData<History>(queryKey, previous => merge(previous, [saved]));\n return saved;\n },\n });\n\n const older = useMutation({\n mutationKey: [...queryKey, 'older'], retry: false, gcTime: 0,\n mutationFn: async () => {\n const previous = queryClient.getQueryData<History>(queryKey);\n if (!active || !previous?.hasMore || !previous.nextBefore) return;\n const signal = lifetime.abort.signal;\n const page = await listMessages(requestId!, { before: previous.nextBefore, limit: pageSize }, {\n client, signal: AbortSignal.any([signal, AbortSignal.timeout(20_000)]),\n });\n signal.throwIfAborted();\n queryClient.setQueryData<History>(queryKey, current => ({\n ...merge(current, page.data.map(message => parseMessage(message, requestId!))),\n hasMore: Boolean(page.hasMore), nextBefore: page.nextBefore ?? null,\n }));\n },\n });\n\n return {\n /** Oldest first; duplicates from HTTP responses, history and live delivery are merged. */\n messages: active ? history.data?.messages ?? emptyHistory.messages : emptyHistory.messages,\n status: !active ? 'closed' as const : connection.key === queryKey ? connection.status : 'connecting' as const,\n error: active && connection.key === queryKey ? connection.error : null,\n hasMore: active && Boolean(history.data?.hasMore),\n isLoading: active && !history.data?.initialized && connection.status !== 'error',\n loadOlder: () => {\n if (!lifetime.older) {\n lifetime.older = older.mutateAsync().finally(() => { lifetime.older = undefined; });\n }\n return lifetime.older;\n },\n isLoadingOlder: older.isPending,\n loadOlderError: older.error,\n /** Supply the same clientKey when explicitly retrying a failed send. */\n sendMessage: (message: MessageWrite) => sending.mutateAsync({\n message: { ...message, clientKey: message.clientKey ?? crypto.randomUUID() }, scope: lifetime,\n }),\n isSending: active && sending.variables?.scope === lifetime && sending.isPending,\n sendError: active && sending.variables?.scope === lifetime ? sending.error : null,\n /** Contains the generated clientKey, allowing safe explicit retries. */\n lastSend: active && sending.variables?.scope === lifetime ? sending.variables.message : undefined,\n };\n}\n\nexport type TutoringChatResult = ReturnType<typeof useTutoringChat>;\n"],"mappings":";;;;;;;AA6BA,MAAM,eAAwB;CAAE,UAAU,CAAC;CAAG,aAAa;CAAO,SAAS;CAAO,YAAY;AAAK;AACnG,MAAM,4BAAY,IAAI,QAAwB;AAC9C,IAAI,eAAe;AACnB,SAAS,SAAS,QAAwB;CACxC,IAAI,KAAK,UAAU,IAAI,MAAM;CAC7B,IAAI,OAAO,KAAA,GAAW;EAAE,KAAK,EAAE;EAAc,UAAU,IAAI,QAAQ,EAAE;CAAG;CACxE,OAAO;AACT;AACA,SAAS,MAAM,UAA+B,UAAkC;CAC9E,MAAM,OAAO,IAAI,KAAK,UAAU,YAAY,CAAC,EAAA,CAAG,KAAI,YAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;CACrF,KAAK,MAAM,WAAW,UAAU,KAAK,IAAI,QAAQ,IAAI,OAAO;CAC5D,OAAO;EAAE,GAAG,YAAY;EAAc,UAAU,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE;CAAE;AACjG;;AAGA,SAAgB,gBAAgB,EAC9B,QAAQ,WAAW,UAAU,MAAM,WAAW,IAC9C,kBAAkB,YAAY,oBACL;CACzB,IAAI,CAAC,OAAO,UAAU,QAAQ,KAAK,WAAW,KAAK,WAAW,KAAK,MAAM,IAAI,UAAU,oCA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AC7E,SAAS,QAAQ,KAAK,OAAO;IAAG,YAAY,KAAK,cAAc;GACjE,EAAE;EACJ;CACF,CAAC;CAED,OAAO;;EAEL,UAAU,SAAS,QAAQ,MAAM,YAAY,aAAa,WAAW,aAAa;EAClF,QAAQ,CAAC,SAAS,WAAoB,WAAW,QAAQ,WAAW,WAAW,SAAS;EACxF,OAAO,UAAU,WAAW,QAAQ,WAAW,WAAW,QAAQ;EAClE,SAAS,UAAU,QAAQ,QAAQ,MAAM,OAAO;EAChD,WAAW,UAAU,CAAC,QAAQ,MAAM,eAAe,WAAW,WAAW;EACzE,iBAAiB;GACf,IAAI,CAAC,SAAS,OACZ,SAAS,QAAQ,MAAM,YAAY,CAAC,CAAC,cAAc;IAAE,SAAS,QAAQ,KAAA;GAAW,CAAC;GAEpF,OAAO,SAAS;EAClB;EACA,gBAAgB,MAAM;EACtB,gBAAgB,MAAM;;EAEtB,cAAc,YAA0B,QAAQ,YAAY;GAC1D,SAAS;IAAE,GAAG;IAAS,WAAW,QAAQ,aAAa,OAAO,WAAW;GAAE;GAAG,OAAO;EACvF,CAAC;EACD,WAAW,UAAU,QAAQ,WAAW,UAAU,YAAY,QAAQ;EACtE,WAAW,UAAU,QAAQ,WAAW,UAAU,WAAW,QAAQ,QAAQ;;EAE7E,UAAU,UAAU,QAAQ,WAAW,UAAU,WAAW,QAAQ,UAAU,UAAU,KAAA;CAC1F;AACF"}
@@ -1,6 +1,6 @@
1
1
 
2
- import { Gn as HTTPExceptionResponse, Rn as LeaseRead, t as ValidationErrorResponse } from "../index-wL_20vR8.js";
3
- import { a as ErrorType, c as request } from "../client-BDwBZYB0.js";
2
+ import { Cr as HTTPExceptionResponse, Qn as LeaseRead, t as ValidationErrorResponse } from "../chunks/index.js";
3
+ import { a as ErrorType, c as request } from "../chunks/client.js";
4
4
  import { QueryClient, UseMutationOptions, UseMutationResult } from "@tanstack/react-query";
5
5
  //#region src/react/consumption/consumption.d.ts
6
6
  type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { r as request } from "../client-D3kMOcIr.js";
2
+ import { r as request } from "../chunks/client.js";
3
3
  import { useMutation } from "@tanstack/react-query";
4
4
  //#region src/react/consumption/consumption.ts
5
5
  /**
@@ -7,7 +7,7 @@ import { useMutation } from "@tanstack/react-query";
7
7
  * Do not edit manually.
8
8
  * Mozaik backend
9
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
10
+ * OpenAPI spec version: 0.3.2
11
11
  */
12
12
  const getCloseLeaseUrl = (eventId) => {
13
13
  return `/consumption/${eventId}`;
@@ -1 +1 @@
1
- {"version":3,"file":"consumption.js","names":[],"sources":["../../src/react/consumption/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} from '@tanstack/react-query';\nimport type {\n MutationFunction,\n QueryClient,\n UseMutationOptions,\n UseMutationResult\n} from '@tanstack/react-query';\n\nimport type {\n HTTPExceptionResponse,\n LeaseRead,\n ValidationErrorResponse\n} from '../../models';\n\nimport { request } from '../../client';\nimport type { ErrorType } from '../../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n\nexport const getCloseLeaseUrl = (eventId: number,) => {\n\n\n\n\n return `/consumption/${eventId}`\n}\n\n/**\n * Finish reading. Returns the seat immediately rather than at lapse.\n *\n * ``204`` whether or not the lease was still open: the desired end state is\n * \"closed\", and a client that lost its connection and retried should not get an\n * error for succeeding twice.\n * @summary Close Lease\n */\nexport const closeLease = async (eventId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getCloseLeaseUrl(eventId),\n {\n ...options,\n method: 'DELETE'\n\n\n }\n);}\n\n\n\n\n\nexport const getCloseLeaseMutationKey = () => ['closeLease'] as const;\n\nexport const getCloseLeaseMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext> => {\n\nconst mutationKey = getCloseLeaseMutationKey();\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 closeLease>>, CloseLeaseMutationVariables> = (props) => {\n const {eventId} = props ?? {};\n\n return closeLease(eventId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CloseLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof closeLease>>>\n\n export type CloseLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CloseLeaseMutationVariables = {eventId: number}\n\n /**\n * @summary Close Lease\n */\nexport const useCloseLease = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof closeLease>>,\n TError,\n CloseLeaseMutationVariables,\n TContext\n > => {\n return useMutation(getCloseLeaseMutationOptions(options), queryClient);\n }\n export const getRenewLeaseUrl = (eventId: number,) => {\n\n\n\n\n return `/consumption/${eventId}`\n}\n\n/**\n * Heartbeat. Push the lease out; the client repeats before it lapses.\n *\n * ``404`` when the lease is closed, reaped, or somebody else's — the three are\n * deliberately indistinguishable, because a lease id is a bare integer and\n * guessing one must not reveal whether it exists.\n *\n * This does not write the ledger. A reader refreshing every thirty seconds for\n * an hour would be 120 UPDATEs on the table we bill from, for a value that only\n * matters while it is current; the durable extent is settled once, at close.\n * @summary Renew Lease\n */\nexport const renewLease = async (eventId: number, options?: Parameters<typeof request>[1]): Promise<LeaseRead> => {\n\n return request<LeaseRead>(getRenewLeaseUrl(eventId),\n {\n ...options,\n method: 'PUT'\n\n\n }\n);}\n\n\n\n\n\nexport const getRenewLeaseMutationKey = () => ['renewLease'] as const;\n\nexport const getRenewLeaseMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext> => {\n\nconst mutationKey = getRenewLeaseMutationKey();\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 renewLease>>, RenewLeaseMutationVariables> = (props) => {\n const {eventId} = props ?? {};\n\n return renewLease(eventId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type RenewLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof renewLease>>>\n\n export type RenewLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type RenewLeaseMutationVariables = {eventId: number}\n\n /**\n * @summary Renew Lease\n */\nexport const useRenewLease = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof renewLease>>,\n TError,\n RenewLeaseMutationVariables,\n TContext\n > => {\n return useMutation(getRenewLeaseMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA+BA,MAAa,oBAAoB,YAAqB;CAKpD,OAAO,gBAAgB;AACzB;;;;;;;;;AAUA,MAAa,aAAa,OAAO,SAAiB,YAA2D;CAE3G,OAAO,QAAc,iBAAiB,OAAO,GAC7C;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,iCAAiC,CAAC,YAAY;AAE3D,MAAa,gCACW,YACuF;CAE/G,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAC,UAAU,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,YAAW,SAAS,CAAC;EAE5B,OAAQ,WAAW,SAAQ,cAAc;CAC3C;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,iBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,6BAA6B,OAAO,GAAG,WAAW;AACvE;AACA,MAAa,oBAAoB,YAAqB;CAKxD,OAAO,gBAAgB;AACzB;;;;;;;;;;;;;AAcA,MAAa,aAAa,OAAO,SAAiB,YAAgE;CAEhH,OAAO,QAAmB,iBAAiB,OAAO,GAClD;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,iCAAiC,CAAC,YAAY;AAE3D,MAAa,gCACW,YACuF;CAE/G,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAC,UAAU,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,YAAW,SAAS,CAAC;EAE5B,OAAQ,WAAW,SAAQ,cAAc;CAC3C;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,iBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,6BAA6B,OAAO,GAAG,WAAW;AACvE"}
1
+ {"version":3,"file":"consumption.js","names":[],"sources":["../../src/react/consumption/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.3.2\n */\nimport {\n useMutation\n} from '@tanstack/react-query';\nimport type {\n MutationFunction,\n QueryClient,\n UseMutationOptions,\n UseMutationResult\n} from '@tanstack/react-query';\n\nimport type {\n HTTPExceptionResponse,\n LeaseRead,\n ValidationErrorResponse\n} from '../../models';\n\nimport { request } from '../../client';\nimport type { ErrorType } from '../../client';\n\n\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n\nexport const getCloseLeaseUrl = (eventId: number,) => {\n\n\n\n\n return `/consumption/${eventId}`\n}\n\n/**\n * Finish reading. Returns the seat immediately rather than at lapse.\n *\n * ``204`` whether or not the lease was still open: the desired end state is\n * \"closed\", and a client that lost its connection and retried should not get an\n * error for succeeding twice.\n * @summary Close Lease\n */\nexport const closeLease = async (eventId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getCloseLeaseUrl(eventId),\n {\n ...options,\n method: 'DELETE'\n\n\n }\n);}\n\n\n\n\n\nexport const getCloseLeaseMutationKey = () => ['closeLease'] as const;\n\nexport const getCloseLeaseMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext> => {\n\nconst mutationKey = getCloseLeaseMutationKey();\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 closeLease>>, CloseLeaseMutationVariables> = (props) => {\n const {eventId} = props ?? {};\n\n return closeLease(eventId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CloseLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof closeLease>>>\n\n export type CloseLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CloseLeaseMutationVariables = {eventId: number}\n\n /**\n * @summary Close Lease\n */\nexport const useCloseLease = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof closeLease>>, TError,CloseLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof closeLease>>,\n TError,\n CloseLeaseMutationVariables,\n TContext\n > => {\n return useMutation(getCloseLeaseMutationOptions(options), queryClient);\n }\n export const getRenewLeaseUrl = (eventId: number,) => {\n\n\n\n\n return `/consumption/${eventId}`\n}\n\n/**\n * Heartbeat. Push the lease out; the client repeats before it lapses.\n *\n * ``404`` when the lease is closed, reaped, or somebody else's — the three are\n * deliberately indistinguishable, because a lease id is a bare integer and\n * guessing one must not reveal whether it exists.\n *\n * This does not write the ledger. A reader refreshing every thirty seconds for\n * an hour would be 120 UPDATEs on the table we bill from, for a value that only\n * matters while it is current; the durable extent is settled once, at close.\n * @summary Renew Lease\n */\nexport const renewLease = async (eventId: number, options?: Parameters<typeof request>[1]): Promise<LeaseRead> => {\n\n return request<LeaseRead>(getRenewLeaseUrl(eventId),\n {\n ...options,\n method: 'PUT'\n\n\n }\n);}\n\n\n\n\n\nexport const getRenewLeaseMutationKey = () => ['renewLease'] as const;\n\nexport const getRenewLeaseMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext> => {\n\nconst mutationKey = getRenewLeaseMutationKey();\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 renewLease>>, RenewLeaseMutationVariables> = (props) => {\n const {eventId} = props ?? {};\n\n return renewLease(eventId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type RenewLeaseMutationResult = NonNullable<Awaited<ReturnType<typeof renewLease>>>\n\n export type RenewLeaseMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type RenewLeaseMutationVariables = {eventId: number}\n\n /**\n * @summary Renew Lease\n */\nexport const useRenewLease = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof renewLease>>, TError,RenewLeaseMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof renewLease>>,\n TError,\n RenewLeaseMutationVariables,\n TContext\n > => {\n return useMutation(getRenewLeaseMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA+BA,MAAa,oBAAoB,YAAqB;CAKpD,OAAO,gBAAgB;AACzB;;;;;;;;;AAUA,MAAa,aAAa,OAAO,SAAiB,YAA2D;CAE3G,OAAO,QAAc,iBAAiB,OAAO,GAC7C;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,iCAAiC,CAAC,YAAY;AAE3D,MAAa,gCACW,YACuF;CAE/G,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAC,UAAU,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,YAAW,SAAS,CAAC;EAE5B,OAAQ,WAAW,SAAQ,cAAc;CAC3C;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,iBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,6BAA6B,OAAO,GAAG,WAAW;AACvE;AACA,MAAa,oBAAoB,YAAqB;CAKxD,OAAO,gBAAgB;AACzB;;;;;;;;;;;;;AAcA,MAAa,aAAa,OAAO,SAAiB,YAAgE;CAEhH,OAAO,QAAmB,iBAAiB,OAAO,GAClD;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,iCAAiC,CAAC,YAAY;AAE3D,MAAa,gCACW,YACuF;CAE/G,MAAM,cAAc,yBAAyB;CAC7C,MAAM,EAAC,UAAU,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,YAAW,SAAS,CAAC;EAE5B,OAAQ,WAAW,SAAQ,cAAc;CAC3C;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,iBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,6BAA6B,OAAO,GAAG,WAAW;AACvE"}
@@ -1,6 +1,6 @@
1
1
 
2
- import { At as PlaybackReportWrite, Gn as HTTPExceptionResponse, Kt as NotificationListRead, jt as PlaybackReportRead, mn as ListNotificationsParams, t as ValidationErrorResponse } from "../index-wL_20vR8.js";
3
- import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
2
+ import { Cr as HTTPExceptionResponse, Dn as ListNotificationsParams, Ft as PlaybackReportWrite, It as PlaybackReportRead, an as NotificationListRead, t as ValidationErrorResponse } from "../chunks/index.js";
3
+ import { a as ErrorType, c as request, n as BodyType } from "../chunks/client.js";
4
4
  import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
5
5
  //#region src/react/cvs-app/cvs-app.d.ts
6
6
  type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { r as request } from "../client-D3kMOcIr.js";
2
+ import { r as request } from "../chunks/client.js";
3
3
  import { useMutation, useQuery } from "@tanstack/react-query";
4
4
  //#region src/react/cvs-app/cvs-app.ts
5
5
  /**
@@ -7,7 +7,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
7
7
  * Do not edit manually.
8
8
  * Mozaik backend
9
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
10
+ * OpenAPI spec version: 0.3.2
11
11
  */
12
12
  const withQueryKey = (query, queryKey) => {
13
13
  const result = { queryKey };
@@ -1 +1 @@
1
- {"version":3,"file":"cvs-app.js","names":[],"sources":["../../src/react/cvs-app/cvs-app.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 ListNotificationsParams,\n NotificationListRead,\n PlaybackReportRead,\n PlaybackReportWrite,\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 getListNotificationsUrl = (params?: ListNotificationsParams,) => {\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 ? `/cvs/notifications?${stringifiedParams}` : `/cvs/notifications`\n}\n\n/**\n * Notifications published to this caller's library.\n *\n * **These are tenant broadcasts, not a per-user inbox.** ``app_notification``\n * has no user column and no read state — ``app_notification_bm`` links a\n * notification to a library and that is the whole model. So ``unread_count`` is\n * always ``0`` here and every notification is returned every time.\n *\n * Giving each member their own read state is a schema change (a\n * ``notification_read`` row per user and notification), not a query change. It\n * is worth doing — a broadcast list that never shrinks is one people stop\n * opening — but it is a decision rather than a port, so it is not made here.\n * @summary List Notifications\n */\nexport const listNotifications = async (params?: ListNotificationsParams, options?: Parameters<typeof request>[1]): Promise<NotificationListRead> => {\n\n return request<NotificationListRead>(getListNotificationsUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListNotificationsQueryKey = (params?: ListNotificationsParams,) => {\n return [\n `/cvs/notifications`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getListNotificationsQueryOptions = <TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListNotificationsQueryKey(params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listNotifications>>> = ({ signal }) => listNotifications(params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListNotificationsQueryResult = NonNullable<Awaited<ReturnType<typeof listNotifications>>>\nexport type ListNotificationsQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: undefined | ListNotificationsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listNotifications>>,\n TError,\n Awaited<ReturnType<typeof listNotifications>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listNotifications>>,\n TError,\n Awaited<ReturnType<typeof listNotifications>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Notifications\n */\n\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListNotificationsQueryOptions(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 getCreateReportUrl = () => {\n\n\n\n\n return `/cvs/reports`\n}\n\n/**\n * Report a playback problem.\n *\n * The identifying fields are taken from the credential, not the body. The\n * legacy took ``adhId``, ``bmId`` and ``bmBibLocaleId`` from the query string\n * and declared no ``Authorization`` at all, so anyone holding the shared\n * ``api_key`` — which every deployed app binary contains — could file a report\n * in any patron's name, at any library. The DTO still carries those three\n * fields, marked transition-only, and this handler ignores every one of them.\n *\n * ``email`` is free text that ends up in a message. Authenticated and\n * rate-limited it is a support channel; unauthenticated it is a spam relay with\n * the library's return address on it.\n * @summary Create Report\n */\nexport const createReport = async (playbackReportWrite: PlaybackReportWrite, options?: Parameters<typeof request>[1]): Promise<PlaybackReportRead> => {\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<PlaybackReportRead>(getCreateReportUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(playbackReportWrite)\n }\n);}\n\n\n\n\n\nexport const getCreateReportMutationKey = () => ['createReport'] as const;\n\nexport const getCreateReportMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext> => {\n\nconst mutationKey = getCreateReportMutationKey();\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 createReport>>, CreateReportMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return createReport(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CreateReportMutationResult = NonNullable<Awaited<ReturnType<typeof createReport>>>\n export type CreateReportMutationBody = BodyType<PlaybackReportWrite>\n export type CreateReportMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CreateReportMutationVariables = {data: BodyType<PlaybackReportWrite>}\n\n /**\n * @summary Create Report\n */\nexport const useCreateReport = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof createReport>>,\n TError,\n CreateReportMutationVariables,\n TContext\n > => {\n return useMutation(getCreateReportMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA2CA,MAAM,gBAAqC,OAAU,aAAqC;CACxF,MAAM,SAAS,EAAE,SAAS;CAC1B,KAAK,MAAM,OAAO,OAAO,KAAK,KA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* 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.3.2\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 ListNotificationsParams,\n NotificationListRead,\n PlaybackReportRead,\n PlaybackReportWrite,\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 getListNotificationsUrl = (params?: ListNotificationsParams,) => {\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 ? `/cvs/notifications?${stringifiedParams}` : `/cvs/notifications`\n}\n\n/**\n * Notifications published to this caller's library.\n *\n * **These are tenant broadcasts, not a per-user inbox.** ``app_notification``\n * has no user column and no read state — ``app_notification_bm`` links a\n * notification to a library and that is the whole model. So ``unread_count`` is\n * always ``0`` here and every notification is returned every time.\n *\n * Giving each member their own read state is a schema change (a\n * ``notification_read`` row per user and notification), not a query change. It\n * is worth doing — a broadcast list that never shrinks is one people stop\n * opening — but it is a decision rather than a port, so it is not made here.\n * @summary List Notifications\n */\nexport const listNotifications = async (params?: ListNotificationsParams, options?: Parameters<typeof request>[1]): Promise<NotificationListRead> => {\n\n return request<NotificationListRead>(getListNotificationsUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListNotificationsQueryKey = (params?: ListNotificationsParams,) => {\n return [\n `/cvs/notifications`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getListNotificationsQueryOptions = <TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListNotificationsQueryKey(params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listNotifications>>> = ({ signal }) => listNotifications(params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListNotificationsQueryResult = NonNullable<Awaited<ReturnType<typeof listNotifications>>>\nexport type ListNotificationsQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: undefined | ListNotificationsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listNotifications>>,\n TError,\n Awaited<ReturnType<typeof listNotifications>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listNotifications>>,\n TError,\n Awaited<ReturnType<typeof listNotifications>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Notifications\n */\n\nexport function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListNotificationsQueryOptions(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 getCreateReportUrl = () => {\n\n\n\n\n return `/cvs/reports`\n}\n\n/**\n * Report a playback problem.\n *\n * The identifying fields are taken from the credential, not the body. The\n * legacy took ``adhId``, ``bmId`` and ``bmBibLocaleId`` from the query string\n * and declared no ``Authorization`` at all, so anyone holding the shared\n * ``api_key`` — which every deployed app binary contains — could file a report\n * in any patron's name, at any library. The DTO still carries those three\n * fields, marked transition-only, and this handler ignores every one of them.\n *\n * ``email`` is free text that ends up in a message. Authenticated and\n * rate-limited it is a support channel; unauthenticated it is a spam relay with\n * the library's return address on it.\n * @summary Create Report\n */\nexport const createReport = async (playbackReportWrite: PlaybackReportWrite, options?: Parameters<typeof request>[1]): Promise<PlaybackReportRead> => {\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<PlaybackReportRead>(getCreateReportUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(playbackReportWrite)\n }\n);}\n\n\n\n\n\nexport const getCreateReportMutationKey = () => ['createReport'] as const;\n\nexport const getCreateReportMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext> => {\n\nconst mutationKey = getCreateReportMutationKey();\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 createReport>>, CreateReportMutationVariables> = (props) => {\n const {data} = props ?? {};\n\n return createReport(data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type CreateReportMutationResult = NonNullable<Awaited<ReturnType<typeof createReport>>>\n export type CreateReportMutationBody = BodyType<PlaybackReportWrite>\n export type CreateReportMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type CreateReportMutationVariables = {data: BodyType<PlaybackReportWrite>}\n\n /**\n * @summary Create Report\n */\nexport const useCreateReport = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createReport>>, TError,CreateReportMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof createReport>>,\n TError,\n CreateReportMutationVariables,\n TContext\n > => {\n return useMutation(getCreateReportMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA2CA,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,2BAA2B,WAAsC;CAC5E,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,sBAAsB,sBAAsB;AAC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AgB;GAAoB,GAAG,WAAW,SAAS,OAAO;EAAE;EAC/E,MAAM,KAAK,UAAU,mBAAmB;CAC1C,CACF;AAAE;AAMF,MAAa,mCAAmC,CAAC,cAAc;AAE/D,MAAa,kCACW,YAC2F;CAEnH,MAAM,cAAc,2BAA2B;CAC/C,MAAM,EAAC,UAAU,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,cAAyG,UAAU;EACrH,MAAM,EAAC,SAAQ,SAAS,CAAC;EAEzB,OAAQ,aAAa,MAAK,cAAc;CAC1C;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,mBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,+BAA+B,OAAO,GAAG,WAAW;AACzE"}
@@ -1,6 +1,6 @@
1
1
 
2
- import { G as ReviewUpdateWrite, Gn as HTTPExceptionResponse, K as ReviewRead, M as SupplierGrantRead, Un as LastPositionWrite, ft as RatingUpdateWrite, hr as DocumentRead, mr as DocumentSearchWrite, t as ValidationErrorResponse, vr as DocumentPage } from "../index-wL_20vR8.js";
3
- import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
2
+ import { Cr as HTTPExceptionResponse, Jr as DocumentRead, P as SupplierGrantRead, X as ReviewRead, Y as ReviewUpdateWrite, Zr as DocumentPage, _t as RatingUpdateWrite, in as OpenAtSupplierParams, qr as DocumentSearchWrite, rr as LastPositionWrite, t as ValidationErrorResponse } from "../chunks/index.js";
3
+ import { a as ErrorType, c as request, n as BodyType } from "../chunks/client.js";
4
4
  import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
5
5
  //#region src/react/cvs-documents/cvs-documents.d.ts
6
6
  type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
@@ -73,7 +73,7 @@ export declare function useReadDocument<TData = Awaited<ReturnType<typeof readDo
73
73
  }, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
74
74
  queryKey: DataTag<QueryKey, TData, TError>;
75
75
  };
76
- export declare const getOpenAtSupplierUrl: (docId: number) => string;
76
+ export declare const getOpenAtSupplierUrl: (docId: number, params?: OpenAtSupplierParams) => string;
77
77
  /**
78
78
  * Authorise this patron to open one title at the supplier hosting it.
79
79
  *
@@ -95,11 +95,23 @@ export declare const getOpenAtSupplierUrl: (docId: number) => string;
95
95
  * them either, so the honest answer is that this title is not openable rather
96
96
  * than a 500 from a missing branch.
97
97
  *
98
+ * ``mode`` is the legacy's ``$upload``: ``stream`` to consult in place,
99
+ * ``download`` to take a copy away. It does two things, and both matter —
100
+ *
101
+ * * **The library is billed for the right act.** ``exemp`` records streaming
102
+ * and download separately, and ``pret_download`` is the only column where a
103
+ * loan duration ever appears. Granting a download as a view bills the wrong
104
+ * quota.
105
+ * * **Three platforms sign it.** Jeux CVS, CVS Livres and Komics Initiative
106
+ * append the flag *after* the second key, so a stream and a download of the
107
+ * same title by the same patron at the same second carry different
108
+ * signatures. For the other platforms it is inert.
109
+ *
98
110
  * The returned token is for the *supplier*, not for us. See
99
111
  * :class:`~app.datamodels.cvs.downloads.SupplierGrantRead`.
100
112
  * @summary Open At Supplier
101
113
  */
102
- export declare const openAtSupplier: (docId: number, options?: Parameters<typeof request>[1]) => Promise<SupplierGrantRead>;
114
+ export declare const openAtSupplier: (docId: number, params?: OpenAtSupplierParams, options?: Parameters<typeof request>[1]) => Promise<SupplierGrantRead>;
103
115
  export declare const getOpenAtSupplierMutationKey: () => readonly ['openAtSupplier'];
104
116
  export declare const getOpenAtSupplierMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
105
117
  mutation?: UseMutationOptions<Awaited<ReturnType<typeof openAtSupplier>>, TError, OpenAtSupplierMutationVariables, TContext>;
@@ -109,6 +121,7 @@ export type OpenAtSupplierMutationResult = NonNullable<Awaited<ReturnType<typeof
109
121
  export type OpenAtSupplierMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
110
122
  export type OpenAtSupplierMutationVariables = {
111
123
  docId: number;
124
+ params?: OpenAtSupplierParams;
112
125
  };
113
126
  /**
114
127
  * @summary Open At Supplier
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { r as request } from "../client-D3kMOcIr.js";
2
+ import { r as request } from "../chunks/client.js";
3
3
  import { useMutation, useQuery } from "@tanstack/react-query";
4
4
  //#region src/react/cvs-documents/cvs-documents.ts
5
5
  /**
@@ -7,7 +7,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
7
7
  * Do not edit manually.
8
8
  * Mozaik backend
9
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
10
+ * OpenAPI spec version: 0.3.2
11
11
  */
12
12
  const withQueryKey = (query, queryKey) => {
13
13
  const result = { queryKey };
@@ -125,8 +125,13 @@ function useReadDocument(docId, options, queryClient) {
125
125
  const query = useQuery(queryOptions, queryClient);
126
126
  return withQueryKey(query, queryOptions.queryKey);
127
127
  }
128
- const getOpenAtSupplierUrl = (docId) => {
129
- return `/cvs/documents/${docId}/grant`;
128
+ const getOpenAtSupplierUrl = (docId, params) => {
129
+ const normalizedParams = new URLSearchParams();
130
+ Object.entries(params || {}).forEach(([key, value]) => {
131
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
132
+ });
133
+ const stringifiedParams = normalizedParams.toString();
134
+ return stringifiedParams.length > 0 ? `/cvs/documents/${docId}/grant?${stringifiedParams}` : `/cvs/documents/${docId}/grant`;
130
135
  };
131
136
  /**
132
137
  * Authorise this patron to open one title at the supplier hosting it.
@@ -149,12 +154,24 @@ const getOpenAtSupplierUrl = (docId) => {
149
154
  * them either, so the honest answer is that this title is not openable rather
150
155
  * than a 500 from a missing branch.
151
156
  *
157
+ * ``mode`` is the legacy's ``$upload``: ``stream`` to consult in place,
158
+ * ``download`` to take a copy away. It does two things, and both matter —
159
+ *
160
+ * * **The library is billed for the right act.** ``exemp`` records streaming
161
+ * and download separately, and ``pret_download`` is the only column where a
162
+ * loan duration ever appears. Granting a download as a view bills the wrong
163
+ * quota.
164
+ * * **Three platforms sign it.** Jeux CVS, CVS Livres and Komics Initiative
165
+ * append the flag *after* the second key, so a stream and a download of the
166
+ * same title by the same patron at the same second carry different
167
+ * signatures. For the other platforms it is inert.
168
+ *
152
169
  * The returned token is for the *supplier*, not for us. See
153
170
  * :class:`~app.datamodels.cvs.downloads.SupplierGrantRead`.
154
171
  * @summary Open At Supplier
155
172
  */
156
- const openAtSupplier = async (docId, options) => {
157
- return request(getOpenAtSupplierUrl(docId), {
173
+ const openAtSupplier = async (docId, params, options) => {
174
+ return request(getOpenAtSupplierUrl(docId, params), {
158
175
  ...options,
159
176
  method: "POST"
160
177
  });
@@ -173,8 +190,8 @@ const getOpenAtSupplierMutationOptions = (options) => {
173
190
  request: void 0
174
191
  };
175
192
  const mutationFn = (props) => {
176
- const { docId } = props ?? {};
177
- return openAtSupplier(docId, requestOptions);
193
+ const { docId, params } = props ?? {};
194
+ return openAtSupplier(docId, params, requestOptions);
178
195
  };
179
196
  return {
180
197
  mutationFn,