@learnorama/mozaik-sdk 0.1.0-staging.11.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 (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/chunks/client.d.ts +28 -0
  101. package/dist/chunks/client.js +61 -0
  102. package/dist/chunks/client.js.map +1 -0
  103. package/dist/chunks/index.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 +70 -0
@@ -0,0 +1,110 @@
1
+
2
+ import { r as request } from "../chunks/client.js";
3
+ //#region src/api/tutoring-practitioner/tutoring-practitioner.ts
4
+ const getAnswerRequestUrl = (requestId) => {
5
+ return `/tutoring/requests/${requestId}/answer`;
6
+ };
7
+ /**
8
+ * Deliver the answer.
9
+ *
10
+ * The body is stored as the answer and any named attachments are re-roled to
11
+ * ``answer`` — they were uploaded against this request, so no id from another
12
+ * request can be attached here.
13
+ * @summary Answer Request
14
+ */
15
+ const answerRequest = async (requestId, tutoringAnswerWrite, options) => {
16
+ const getHeaders = (h) => {
17
+ if (!h) return {};
18
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
19
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
20
+ const headers = {};
21
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
22
+ return headers;
23
+ };
24
+ return request(getAnswerRequestUrl(requestId), {
25
+ ...options,
26
+ method: "POST",
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ ...getHeaders(options?.headers)
30
+ },
31
+ body: JSON.stringify(tutoringAnswerWrite)
32
+ });
33
+ };
34
+ const getClaimRequestUrl = (requestId) => {
35
+ return `/tutoring/requests/${requestId}/claim`;
36
+ };
37
+ /**
38
+ * Take a dispatched request.
39
+ *
40
+ * ``409`` if somebody else already holds it. The check and the write are one
41
+ * statement so that two practitioners hitting claim in the same instant cannot
42
+ * both win — the legacy reads then writes, so both do.
43
+ * @summary Claim Request
44
+ */
45
+ const claimRequest = async (requestId, options) => {
46
+ return request(getClaimRequestUrl(requestId), {
47
+ ...options,
48
+ method: "POST"
49
+ });
50
+ };
51
+ const getCloseRequestUrl = (requestId) => {
52
+ return `/tutoring/requests/${requestId}/close`;
53
+ };
54
+ /**
55
+ * Close a request that will not be answered, with a reason.
56
+ *
57
+ * A dispatcher's job rather than a practitioner's: giving up on a request is a
58
+ * decision about the queue, and the person who could not answer it is not the
59
+ * person who should decide nobody will.
60
+ * @summary Close Request
61
+ */
62
+ const closeRequest = async (requestId, tutoringCloseWrite, options) => {
63
+ const getHeaders = (h) => {
64
+ if (!h) return {};
65
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
66
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
67
+ const headers = {};
68
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
69
+ return headers;
70
+ };
71
+ return request(getCloseRequestUrl(requestId), {
72
+ ...options,
73
+ method: "POST",
74
+ headers: {
75
+ "Content-Type": "application/json",
76
+ ...getHeaders(options?.headers)
77
+ },
78
+ body: JSON.stringify(tutoringCloseWrite)
79
+ });
80
+ };
81
+ const getOpenRoomUrl = (requestId) => {
82
+ return `/tutoring/requests/${requestId}/room`;
83
+ };
84
+ /**
85
+ * Open the room for a live request. The practitioner decides when.
86
+ *
87
+ * Deliberately an explicit action rather than a side effect of claiming, which
88
+ * is what Prof Express does: the teacher presses a button in their own queue,
89
+ * and ``createTeacherVedamoClasssroom`` refuses unless a teacher is assigned.
90
+ * A room provisioned at dispatch is a room the pupil joins alone.
91
+ *
92
+ * Only the assigned practitioner may open it, and only once — a second call
93
+ * returns the room that is already open rather than provisioning another. The
94
+ * legacy has no such check, so pressing its button twice orphans a room the
95
+ * pupil may already hold a link to.
96
+ *
97
+ * ``409`` for a channel with nothing to join, and for a request nobody has
98
+ * claimed.
99
+ * @summary Open Room
100
+ */
101
+ const openRoom = async (requestId, options) => {
102
+ return request(getOpenRoomUrl(requestId), {
103
+ ...options,
104
+ method: "POST"
105
+ });
106
+ };
107
+ //#endregion
108
+ export { answerRequest, claimRequest, closeRequest, getAnswerRequestUrl, getClaimRequestUrl, getCloseRequestUrl, getOpenRoomUrl, openRoom };
109
+
110
+ //# sourceMappingURL=tutoring-practitioner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tutoring-practitioner.js","names":[],"sources":["../../src/api/tutoring-practitioner/tutoring-practitioner.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 type {\n TutoringAnswerWrite,\n TutoringCloseWrite,\n TutoringRoomRead\n} from '../../models';\n\nimport { request } from '../../client';\n\nexport const getAnswerRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/answer`\n}\n\n/**\n * Deliver the answer.\n *\n * The body is stored as the answer and any named attachments are re-roled to\n * ``answer`` — they were uploaded against this request, so no id from another\n * request can be attached here.\n * @summary Answer Request\n */\nexport const answerRequest = async (requestId: number,\n tutoringAnswerWrite: TutoringAnswerWrite, 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>(getAnswerRequestUrl(requestId),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(tutoringAnswerWrite)\n }\n);}\n\n\nexport const getClaimRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/claim`\n}\n\n/**\n * Take a dispatched request.\n *\n * ``409`` if somebody else already holds it. The check and the write are one\n * statement so that two practitioners hitting claim in the same instant cannot\n * both win — the legacy reads then writes, so both do.\n * @summary Claim Request\n */\nexport const claimRequest = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getClaimRequestUrl(requestId),\n {\n ...options,\n method: 'POST'\n\n\n }\n);}\n\n\nexport const getCloseRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/close`\n}\n\n/**\n * Close a request that will not be answered, with a reason.\n *\n * A dispatcher's job rather than a practitioner's: giving up on a request is a\n * decision about the queue, and the person who could not answer it is not the\n * person who should decide nobody will.\n * @summary Close Request\n */\nexport const closeRequest = async (requestId: number,\n tutoringCloseWrite: TutoringCloseWrite, 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>(getCloseRequestUrl(requestId),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(tutoringCloseWrite)\n }\n);}\n\n\nexport const getOpenRoomUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/room`\n}\n\n/**\n * Open the room for a live request. The practitioner decides when.\n *\n * Deliberately an explicit action rather than a side effect of claiming, which\n * is what Prof Express does: the teacher presses a button in their own queue,\n * and ``createTeacherVedamoClasssroom`` refuses unless a teacher is assigned.\n * A room provisioned at dispatch is a room the pupil joins alone.\n *\n * Only the assigned practitioner may open it, and only once — a second call\n * returns the room that is already open rather than provisioning another. The\n * legacy has no such check, so pressing its button twice orphans a room the\n * pupil may already hold a link to.\n *\n * ``409`` for a channel with nothing to join, and for a request nobody has\n * claimed.\n * @summary Open Room\n */\nexport const openRoom = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<TutoringRoomRead> => {\n\n return request<TutoringRoomRead>(getOpenRoomUrl(requestId),\n {\n ...options,\n method: 'POST'\n\n\n }\n);}\n\n\n"],"mappings":";;;AAeA,MAAa,uBAAuB,cAAuB;CAKzD,OAAO,sBAAsB,UAAU;AACzC;;;;;;;;;AAUA,MAAa,gBAAgB,OAAO,WAChC,qBAA0C,YAA2D;CAErG,MAAM,cAAc,MAAwF;EAC5G,IAAI,CAAC,GAAG,OAAO,CAAC;EAChB,IAAI,aAAa,SAAS,OAAO,OAAO,YAAY,EAAE,QAAQ,CAAC;EAC/D,IAAI,OAAO,YAAY,GACrB,OAAO,OAAO,YACZ,MAAM,KAAK,IAAkC,UAAU,MAAM,KAAK,KAAK,CAAqB,CAC9F;EAEF,MAAM,UAAsD,CAAC;EAC7D,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAgD,CAAC,GAClF,IAAI,UAAU,KAAA,GAAW,QAAQ,QAAQ;EAE3C,OAAO;CACT;CACF,OAAO,QAAc,oBAAoB,SAAS,GAChD;EACE,GAAG;EACH,QAAQ;EACR,SAAS;GAAE,gBAAgB;GAAoB,GAAG,WAAW,SAAS,OAAO;EAAE;EAC/E,MAAM,KAAK,UAAU,mBAAmB;CAC1C,CACF;AAAE;AAGF,MAAa,sBAAsB,cAAuB;CAKxD,OAAO,sBAAsB,UAAU;AACzC;;;;;;;;;AAUA,MAAa,eAAe,OAAO,WAAmB,YAA2D;CAE/G,OAAO,QAAc,mBAAmB,SAAS,GACjD;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAGF,MAAa,sBAAsB,cAAuB;CAKxD,OAAO,sBAAsB,UAAU;AACzC;;;;;;;;;AAUA,MAAa,eAAe,OAAO,WAC/B,oBAAwC,YAA2D;CAEnG,MAAM,cAAc,MAAwF;EAC5G,IAAI,CAAC,GAAG,OAAO,CAAC;EAChB,IAAI,aAAa,SAAS,OAAO,OAAO,YAAY,EAAE,QAAQ,CAAC;EAC/D,IAAI,OAAO,YAAY,GACrB,OAAO,OAAO,YACZ,MAAM,KAAK,IAAkC,UAAU,MAAM,KAAK,KAAK,CAAqB,CAC9F;EAEF,MAAM,UAAsD,CAAC;EAC7D,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAgD,CAAC,GAClF,IAAI,UAAU,KAAA,GAAW,QAAQ,QAAQ;EAE3C,OAAO;CACT;CACF,OAAO,QAAc,mBAAmB,SAAS,GAC/C;EACE,GAAG;EACH,QAAQ;EACR,SAAS;GAAE,gBAAgB;GAAoB,GAAG,WAAW,SAAS,OAAO;EAAE;EAC/E,MAAM,KAAK,UAAU,kBAAkB;CACzC,CACF;AAAE;AAGF,MAAa,kBAAkB,cAAuB;CAKpD,OAAO,sBAAsB,UAAU;AACzC;;;;;;;;;;;;;;;;;;AAmBA,MAAa,WAAW,OAAO,WAAmB,YAAuE;CAEvH,OAAO,QAA0B,eAAe,SAAS,GACzD;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE"}
@@ -0,0 +1,86 @@
1
+
2
+ import { Gr as BodyUploadAttachment, a as TutoringRequestWrite, c as TutoringRequestRead, hn as ListMyRequestsParams, p as TutoringFeedbackWrite, s as TutoringRequestPage, x as TutoringAttachmentRead } from "../chunks/index.js";
3
+ import { c as request } from "../chunks/client.js";
4
+ //#region src/api/tutoring-requests/tutoring-requests.d.ts
5
+ export declare const getListMyRequestsUrl: (params?: ListMyRequestsParams) => string;
6
+ /**
7
+ * The caller's own requests, newest first.
8
+ *
9
+ * Includes requests they submitted for a child profile, which is what the
10
+ * ``requested_by_id`` half of the predicate is for — a parent's list should not
11
+ * go empty the moment they ask on somebody else's behalf.
12
+ * @summary List My Requests
13
+ */
14
+ export declare const listMyRequests: (params?: ListMyRequestsParams, options?: Parameters<typeof request>[1]) => Promise<TutoringRequestPage>;
15
+ export declare const getSubmitRequestUrl: () => string;
16
+ /**
17
+ * Ask for help.
18
+ *
19
+ * Debits the tenant's tutoring entitlement, which is what makes this a ``409``
20
+ * when the allowance is spent rather than a queued request nobody may answer.
21
+ * ``403`` from the entitlement layer is reported as ``404`` for the subject, per
22
+ * the convention the loan routes already follow.
23
+ *
24
+ * ``onBehalfOfId`` must name a profile of the caller. Anything else is ``403``:
25
+ * the legacy accepts a ``user_id`` in the body and trusts it, which is an
26
+ * authorization decision made by whoever wrote the client.
27
+ * @summary Submit Request
28
+ */
29
+ export declare const submitRequest: (tutoringRequestWrite: TutoringRequestWrite, options?: Parameters<typeof request>[1]) => Promise<TutoringRequestRead>;
30
+ export declare const getGetRequestUrl: (requestId: number) => string;
31
+ /**
32
+ * One of the caller's own requests, with signed links to its files.
33
+ * @summary Get Request
34
+ */
35
+ export declare const getRequest: (requestId: number, options?: Parameters<typeof request>[1]) => Promise<TutoringRequestRead>;
36
+ export declare const getUploadAttachmentUrl: (requestId: number) => string;
37
+ /**
38
+ * Attach a file to a request. One per call.
39
+ *
40
+ * One per call rather than an array, deliberately. A pupil photographing four
41
+ * pages on a phone connection wants three of them to survive the fourth
42
+ * timing out, and the legacy's ``documents[]`` array is all-or-nothing — with
43
+ * no cap on how many, so a single request can be arbitrarily large.
44
+ *
45
+ * The role follows from who is asking: the pupil is attaching to a question,
46
+ * the assigned practitioner to an answer. Nobody declares it, so nobody can
47
+ * claim the wrong one.
48
+ *
49
+ * ``415`` for a format we do not accept, ``413`` for a file over the ceiling,
50
+ * ``409`` once the per-request cap is reached, and ``404`` for a request that
51
+ * is not the caller's.
52
+ * @summary Upload Attachment
53
+ */
54
+ export declare const uploadAttachment: (requestId: number, bodyUploadAttachment: BodyUploadAttachment, options?: Parameters<typeof request>[1]) => Promise<TutoringAttachmentRead>;
55
+ export declare const getDeleteAttachmentUrl: (requestId: number, attachmentId: number) => string;
56
+ /**
57
+ * Remove a file the caller uploaded.
58
+ *
59
+ * Only the uploader, and only while the request is still open — a file that
60
+ * formed part of a delivered answer is part of the record.
61
+ *
62
+ * The object goes and the row goes with it: this is a mistaken upload being
63
+ * withdrawn, not a retention event. Retention is the bucket's lifecycle rule,
64
+ * which removes objects and leaves rows behind.
65
+ * @summary Delete Attachment
66
+ */
67
+ export declare const deleteAttachment: (requestId: number, attachmentId: number, options?: Parameters<typeof request>[1]) => Promise<void>;
68
+ export declare const getCancelRequestUrl: (requestId: number) => string;
69
+ /**
70
+ * Withdraw a request the caller asked.
71
+ *
72
+ * The debit is **not** reversed. A pupil who asks and withdraws has occupied a
73
+ * dispatcher's attention, and refunding it would make cancel-and-resubmit a way
74
+ * around the allowance. If a tenant should get the unit back, that is a credit
75
+ * somebody grants, which is a different act with a different audit trail.
76
+ * @summary Cancel Request
77
+ */
78
+ export declare const cancelRequest: (requestId: number, options?: Parameters<typeof request>[1]) => Promise<TutoringRequestRead>;
79
+ export declare const getRateRequestUrl: (requestId: number) => string;
80
+ /**
81
+ * Rate the answer. One rating per request, enforced by the table.
82
+ * @summary Rate Request
83
+ */
84
+ export declare const rateRequest: (requestId: number, tutoringFeedbackWrite: TutoringFeedbackWrite, options?: Parameters<typeof request>[1]) => Promise<void>;
85
+ //#endregion
86
+ //# sourceMappingURL=tutoring-requests.d.ts.map
@@ -0,0 +1,176 @@
1
+
2
+ import { r as request } from "../chunks/client.js";
3
+ //#region src/api/tutoring-requests/tutoring-requests.ts
4
+ const getListMyRequestsUrl = (params) => {
5
+ const normalizedParams = new URLSearchParams();
6
+ Object.entries(params || {}).forEach(([key, value]) => {
7
+ if (Array.isArray(value) && ["status"].includes(key)) {
8
+ value.forEach((v) => {
9
+ normalizedParams.append(key, v === null ? "null" : String(v));
10
+ });
11
+ return;
12
+ }
13
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
14
+ });
15
+ const stringifiedParams = normalizedParams.toString();
16
+ return stringifiedParams.length > 0 ? `/tutoring/requests?${stringifiedParams}` : `/tutoring/requests`;
17
+ };
18
+ /**
19
+ * The caller's own requests, newest first.
20
+ *
21
+ * Includes requests they submitted for a child profile, which is what the
22
+ * ``requested_by_id`` half of the predicate is for — a parent's list should not
23
+ * go empty the moment they ask on somebody else's behalf.
24
+ * @summary List My Requests
25
+ */
26
+ const listMyRequests = async (params, options) => {
27
+ return request(getListMyRequestsUrl(params), {
28
+ ...options,
29
+ method: "GET"
30
+ });
31
+ };
32
+ const getSubmitRequestUrl = () => {
33
+ return `/tutoring/requests`;
34
+ };
35
+ /**
36
+ * Ask for help.
37
+ *
38
+ * Debits the tenant's tutoring entitlement, which is what makes this a ``409``
39
+ * when the allowance is spent rather than a queued request nobody may answer.
40
+ * ``403`` from the entitlement layer is reported as ``404`` for the subject, per
41
+ * the convention the loan routes already follow.
42
+ *
43
+ * ``onBehalfOfId`` must name a profile of the caller. Anything else is ``403``:
44
+ * the legacy accepts a ``user_id`` in the body and trusts it, which is an
45
+ * authorization decision made by whoever wrote the client.
46
+ * @summary Submit Request
47
+ */
48
+ const submitRequest = async (tutoringRequestWrite, options) => {
49
+ const getHeaders = (h) => {
50
+ if (!h) return {};
51
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
52
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
53
+ const headers = {};
54
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
55
+ return headers;
56
+ };
57
+ return request(getSubmitRequestUrl(), {
58
+ ...options,
59
+ method: "POST",
60
+ headers: {
61
+ "Content-Type": "application/json",
62
+ ...getHeaders(options?.headers)
63
+ },
64
+ body: JSON.stringify(tutoringRequestWrite)
65
+ });
66
+ };
67
+ const getGetRequestUrl = (requestId) => {
68
+ return `/tutoring/requests/${requestId}`;
69
+ };
70
+ /**
71
+ * One of the caller's own requests, with signed links to its files.
72
+ * @summary Get Request
73
+ */
74
+ const getRequest = async (requestId, options) => {
75
+ return request(getGetRequestUrl(requestId), {
76
+ ...options,
77
+ method: "GET"
78
+ });
79
+ };
80
+ const getUploadAttachmentUrl = (requestId) => {
81
+ return `/tutoring/requests/${requestId}/attachments`;
82
+ };
83
+ /**
84
+ * Attach a file to a request. One per call.
85
+ *
86
+ * One per call rather than an array, deliberately. A pupil photographing four
87
+ * pages on a phone connection wants three of them to survive the fourth
88
+ * timing out, and the legacy's ``documents[]`` array is all-or-nothing — with
89
+ * no cap on how many, so a single request can be arbitrarily large.
90
+ *
91
+ * The role follows from who is asking: the pupil is attaching to a question,
92
+ * the assigned practitioner to an answer. Nobody declares it, so nobody can
93
+ * claim the wrong one.
94
+ *
95
+ * ``415`` for a format we do not accept, ``413`` for a file over the ceiling,
96
+ * ``409`` once the per-request cap is reached, and ``404`` for a request that
97
+ * is not the caller's.
98
+ * @summary Upload Attachment
99
+ */
100
+ const uploadAttachment = async (requestId, bodyUploadAttachment, options) => {
101
+ const formData = new FormData();
102
+ formData.append(`file`, bodyUploadAttachment.file);
103
+ return request(getUploadAttachmentUrl(requestId), {
104
+ ...options,
105
+ method: "POST",
106
+ body: formData
107
+ });
108
+ };
109
+ const getDeleteAttachmentUrl = (requestId, attachmentId) => {
110
+ return `/tutoring/requests/${requestId}/attachments/${attachmentId}`;
111
+ };
112
+ /**
113
+ * Remove a file the caller uploaded.
114
+ *
115
+ * Only the uploader, and only while the request is still open — a file that
116
+ * formed part of a delivered answer is part of the record.
117
+ *
118
+ * The object goes and the row goes with it: this is a mistaken upload being
119
+ * withdrawn, not a retention event. Retention is the bucket's lifecycle rule,
120
+ * which removes objects and leaves rows behind.
121
+ * @summary Delete Attachment
122
+ */
123
+ const deleteAttachment = async (requestId, attachmentId, options) => {
124
+ return request(getDeleteAttachmentUrl(requestId, attachmentId), {
125
+ ...options,
126
+ method: "DELETE"
127
+ });
128
+ };
129
+ const getCancelRequestUrl = (requestId) => {
130
+ return `/tutoring/requests/${requestId}/cancel`;
131
+ };
132
+ /**
133
+ * Withdraw a request the caller asked.
134
+ *
135
+ * The debit is **not** reversed. A pupil who asks and withdraws has occupied a
136
+ * dispatcher's attention, and refunding it would make cancel-and-resubmit a way
137
+ * around the allowance. If a tenant should get the unit back, that is a credit
138
+ * somebody grants, which is a different act with a different audit trail.
139
+ * @summary Cancel Request
140
+ */
141
+ const cancelRequest = async (requestId, options) => {
142
+ return request(getCancelRequestUrl(requestId), {
143
+ ...options,
144
+ method: "POST"
145
+ });
146
+ };
147
+ const getRateRequestUrl = (requestId) => {
148
+ return `/tutoring/requests/${requestId}/feedback`;
149
+ };
150
+ /**
151
+ * Rate the answer. One rating per request, enforced by the table.
152
+ * @summary Rate Request
153
+ */
154
+ const rateRequest = async (requestId, tutoringFeedbackWrite, options) => {
155
+ const getHeaders = (h) => {
156
+ if (!h) return {};
157
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
158
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
159
+ const headers = {};
160
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
161
+ return headers;
162
+ };
163
+ return request(getRateRequestUrl(requestId), {
164
+ ...options,
165
+ method: "POST",
166
+ headers: {
167
+ "Content-Type": "application/json",
168
+ ...getHeaders(options?.headers)
169
+ },
170
+ body: JSON.stringify(tutoringFeedbackWrite)
171
+ });
172
+ };
173
+ //#endregion
174
+ export { cancelRequest, deleteAttachment, getCancelRequestUrl, getDeleteAttachmentUrl, getGetRequestUrl, getListMyRequestsUrl, getRateRequestUrl, getRequest, getSubmitRequestUrl, getUploadAttachmentUrl, listMyRequests, rateRequest, submitRequest, uploadAttachment };
175
+
176
+ //# sourceMappingURL=tutoring-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tutoring-requests.js","names":[],"sources":["../../src/api/tutoring-requests/tutoring-requests.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 type {\n BodyUploadAttachment,\n ListMyRequestsParams,\n TutoringAttachmentRead,\n TutoringFeedbackWrite,\n TutoringRequestPage,\n TutoringRequestRead,\n TutoringRequestWrite\n} from '../../models';\n\nimport { request } from '../../client';\n\nexport const getListMyRequestsUrl = (params?: ListMyRequestsParams,) => {\n const normalizedParams = new URLSearchParams();\n\n Object.entries(params || {}).forEach(([key, value]) => {\n const explodeParameters = [\"status\"];\n\n if (Array.isArray(value) && explodeParameters.includes(key)) {\n value.forEach((v) => {\n normalizedParams.append(key, v === null ? 'null' : String(v));\n });\n return;\n }\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 ? `/tutoring/requests?${stringifiedParams}` : `/tutoring/requests`\n}\n\n/**\n * The caller's own requests, newest first.\n *\n * Includes requests they submitted for a child profile, which is what the\n * ``requested_by_id`` half of the predicate is for — a parent's list should not\n * go empty the moment they ask on somebody else's behalf.\n * @summary List My Requests\n */\nexport const listMyRequests = async (params?: ListMyRequestsParams, options?: Parameters<typeof request>[1]): Promise<TutoringRequestPage> => {\n\n return request<TutoringRequestPage>(getListMyRequestsUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\nexport const getSubmitRequestUrl = () => {\n\n\n\n\n return `/tutoring/requests`\n}\n\n/**\n * Ask for help.\n *\n * Debits the tenant's tutoring entitlement, which is what makes this a ``409``\n * when the allowance is spent rather than a queued request nobody may answer.\n * ``403`` from the entitlement layer is reported as ``404`` for the subject, per\n * the convention the loan routes already follow.\n *\n * ``onBehalfOfId`` must name a profile of the caller. Anything else is ``403``:\n * the legacy accepts a ``user_id`` in the body and trusts it, which is an\n * authorization decision made by whoever wrote the client.\n * @summary Submit Request\n */\nexport const submitRequest = async (tutoringRequestWrite: TutoringRequestWrite, options?: Parameters<typeof request>[1]): Promise<TutoringRequestRead> => {\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<TutoringRequestRead>(getSubmitRequestUrl(),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(tutoringRequestWrite)\n }\n);}\n\n\nexport const getGetRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}`\n}\n\n/**\n * One of the caller's own requests, with signed links to its files.\n * @summary Get Request\n */\nexport const getRequest = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<TutoringRequestRead> => {\n\n return request<TutoringRequestRead>(getGetRequestUrl(requestId),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\nexport const getUploadAttachmentUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/attachments`\n}\n\n/**\n * Attach a file to a request. One per call.\n *\n * One per call rather than an array, deliberately. A pupil photographing four\n * pages on a phone connection wants three of them to survive the fourth\n * timing out, and the legacy's ``documents[]`` array is all-or-nothing — with\n * no cap on how many, so a single request can be arbitrarily large.\n *\n * The role follows from who is asking: the pupil is attaching to a question,\n * the assigned practitioner to an answer. Nobody declares it, so nobody can\n * claim the wrong one.\n *\n * ``415`` for a format we do not accept, ``413`` for a file over the ceiling,\n * ``409`` once the per-request cap is reached, and ``404`` for a request that\n * is not the caller's.\n * @summary Upload Attachment\n */\nexport const uploadAttachment = async (requestId: number,\n bodyUploadAttachment: BodyUploadAttachment, options?: Parameters<typeof request>[1]): Promise<TutoringAttachmentRead> => {\n const formData = new FormData();\nformData.append(`file`, bodyUploadAttachment.file);\n\n return request<TutoringAttachmentRead>(getUploadAttachmentUrl(requestId),\n {\n ...options,\n method: 'POST'\n ,\n body: formData\n }\n);}\n\n\nexport const getDeleteAttachmentUrl = (requestId: number,\n attachmentId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/attachments/${attachmentId}`\n}\n\n/**\n * Remove a file the caller uploaded.\n *\n * Only the uploader, and only while the request is still open — a file that\n * formed part of a delivered answer is part of the record.\n *\n * The object goes and the row goes with it: this is a mistaken upload being\n * withdrawn, not a retention event. Retention is the bucket's lifecycle rule,\n * which removes objects and leaves rows behind.\n * @summary Delete Attachment\n */\nexport const deleteAttachment = async (requestId: number,\n attachmentId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getDeleteAttachmentUrl(requestId,attachmentId),\n {\n ...options,\n method: 'DELETE'\n\n\n }\n);}\n\n\nexport const getCancelRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/cancel`\n}\n\n/**\n * Withdraw a request the caller asked.\n *\n * The debit is **not** reversed. A pupil who asks and withdraws has occupied a\n * dispatcher's attention, and refunding it would make cancel-and-resubmit a way\n * around the allowance. If a tenant should get the unit back, that is a credit\n * somebody grants, which is a different act with a different audit trail.\n * @summary Cancel Request\n */\nexport const cancelRequest = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<TutoringRequestRead> => {\n\n return request<TutoringRequestRead>(getCancelRequestUrl(requestId),\n {\n ...options,\n method: 'POST'\n\n\n }\n);}\n\n\nexport const getRateRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/feedback`\n}\n\n/**\n * Rate the answer. One rating per request, enforced by the table.\n * @summary Rate Request\n */\nexport const rateRequest = async (requestId: number,\n tutoringFeedbackWrite: TutoringFeedbackWrite, 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>(getRateRequestUrl(requestId),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(tutoringFeedbackWrite)\n }\n);}\n\n\n"],"mappings":"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"}
@@ -0,0 +1,28 @@
1
+
2
+ //#region src/client.d.ts
3
+ /** Configuration belongs to a client instance, never to global authentication state. */
4
+ interface ClientOptions {
5
+ baseUrl: string;
6
+ getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;
7
+ headers?: HeadersInit;
8
+ fetch?: typeof globalThis.fetch;
9
+ }
10
+ interface Client extends Readonly<ClientOptions> {}
11
+ interface RequestOptions extends RequestInit {
12
+ client?: Client;
13
+ }
14
+ declare class ApiError<T = unknown> extends Error {
15
+ readonly status: number;
16
+ readonly data: T;
17
+ readonly headers: Headers;
18
+ constructor(response: Response, data: T);
19
+ }
20
+ declare function createClient(options: ClientOptions): Client;
21
+ /** Orval transport: typed successful data, rejected HTTP errors, native cancellation. */
22
+ declare function request<T>(path: string, options?: RequestOptions): Promise<T>;
23
+ /** Used by generated React Query hooks for HTTP failures. */
24
+ type ErrorType<T> = ApiError<T>;
25
+ type BodyType<T> = T;
26
+ //#endregion
27
+ export { ErrorType as a, request as c, ClientOptions as i, BodyType as n, RequestOptions as o, Client as r, createClient as s, ApiError as t };
28
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,61 @@
1
+
2
+ //#region src/client.ts
3
+ var ApiError = class extends Error {
4
+ status;
5
+ data;
6
+ headers;
7
+ constructor(response, data) {
8
+ super(`Mozaik API returned HTTP ${response.status}`);
9
+ this.name = "ApiError";
10
+ this.status = response.status;
11
+ this.data = data;
12
+ this.headers = response.headers;
13
+ }
14
+ };
15
+ function createClient(options) {
16
+ const url = new URL(options.baseUrl);
17
+ if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== "/") throw new TypeError("baseUrl must be an HTTP(S) origin without credentials, path, query or fragment");
18
+ return Object.freeze({
19
+ ...options,
20
+ baseUrl: url.origin,
21
+ headers: new Headers(options.headers)
22
+ });
23
+ }
24
+ /** Orval transport: typed successful data, rejected HTTP errors, native cancellation. */
25
+ async function request(path, options = {}) {
26
+ const { client, headers: requestHeaders, ...init } = options;
27
+ const headers = new Headers(client?.headers);
28
+ new Headers(requestHeaders).forEach((value, key) => headers.set(key, value));
29
+ const url = client ? new URL(path, client.baseUrl) : void 0;
30
+ if (client && url?.origin !== client.baseUrl) throw new TypeError("Refusing to send client credentials to another origin");
31
+ if (!headers.has("Authorization")) {
32
+ const token = await client?.getAccessToken?.();
33
+ if (token) headers.set("Authorization", `Bearer ${token}`);
34
+ }
35
+ if (init.body instanceof FormData) headers.delete("Content-Type");
36
+ if (!headers.has("Accept")) headers.set("Accept", "application/json");
37
+ const response = await (client?.fetch ?? globalThis.fetch)(url?.href ?? path, {
38
+ credentials: "omit",
39
+ ...init,
40
+ headers
41
+ });
42
+ let data;
43
+ if (response.status !== 204 && response.status !== 205 && init.method !== "HEAD") {
44
+ const text = await response.text();
45
+ if (text) {
46
+ if (response.headers.get("Content-Type")?.includes("json")) try {
47
+ data = JSON.parse(text);
48
+ } catch (error) {
49
+ if (response.ok) throw error;
50
+ data = text;
51
+ }
52
+ else data = text;
53
+ }
54
+ }
55
+ if (!response.ok) throw new ApiError(response, data);
56
+ return data;
57
+ }
58
+ //#endregion
59
+ export { createClient as n, request as r, ApiError as t };
60
+
61
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/client.ts"],"sourcesContent":["/** Configuration belongs to a client instance, never to global authentication state. */\nexport interface ClientOptions {\n baseUrl: string;\n getAccessToken?: () => string | null | undefined | Promise<string | null | undefined>;\n headers?: HeadersInit;\n fetch?: typeof globalThis.fetch;\n}\n\nexport interface Client extends Readonly<ClientOptions> {}\n\nexport interface RequestOptions extends RequestInit {\n client?: Client;\n}\n\nexport class ApiError<T = unknown> extends Error {\n readonly status: number;\n readonly data: T;\n readonly headers: Headers;\n\n constructor(response: Response, data: T) {\n super(`Mozaik API returned HTTP ${response.status}`);\n this.name = 'ApiError';\n this.status = response.status;\n this.data = data;\n this.headers = response.headers;\n }\n}\n\nexport function createClient(options: ClientOptions): Client {\n const url = new URL(options.baseUrl);\n if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== '/') {\n throw new TypeError('baseUrl must be an HTTP(S) origin without credentials, path, query or fragment');\n }\n return Object.freeze({ ...options, baseUrl: url.origin, headers: new Headers(options.headers) });\n}\n\n/** Orval transport: typed successful data, rejected HTTP errors, native cancellation. */\nexport async function request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { client, headers: requestHeaders, ...init } = options;\n const headers = new Headers(client?.headers);\n new Headers(requestHeaders).forEach((value, key) => headers.set(key, value));\n const url = client ? new URL(path, client.baseUrl) : undefined;\n if (client && url?.origin !== client.baseUrl) {\n throw new TypeError('Refusing to send client credentials to another origin');\n }\n if (!headers.has('Authorization')) {\n const token = await client?.getAccessToken?.();\n if (token) headers.set('Authorization', `Bearer ${token}`);\n }\n if (init.body instanceof FormData) headers.delete('Content-Type');\n if (!headers.has('Accept')) headers.set('Accept', 'application/json');\n const response = await (client?.fetch ?? globalThis.fetch)(url?.href ?? path, {\n credentials: 'omit', ...init, headers,\n });\n let data: unknown;\n if (response.status !== 204 && response.status !== 205 && init.method !== 'HEAD') {\n const text = await response.text();\n if (text) {\n if (response.headers.get('Content-Type')?.includes('json')) {\n try { data = JSON.parse(text); }\n catch (error) { if (response.ok) throw error; data = text; }\n } else data = text;\n }\n }\n if (!response.ok) throw new ApiError(response, data);\n return data as T;\n}\n\n/** Used by generated React Query hooks for HTTP failures. */\nexport type ErrorType<T> = ApiError<T>;\nexport type BodyType<T> = T;\n"],"mappings":";;AAcA,IAAa,WAAb,cAA2C,MAAM;CAC/C;CACA;CACA;CAEA,YAAY,UAAoB,MAAS;EACvC,MAAM,4BAA4B,SAAS,QAAQ;EACnD,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS;EACvB,KAAK,OAAO;EACZ,KAAK,UAAU,SAAS;CAC1B;AACF;AAEA,SAAgB,aAAa,SAAgC;CAC3D,MAAM,MAAM,IAAI,IAAI,QAAQ,OAAO;CACnC,IAAI,CAAC,CAAC,UAAU,OAAO,CAAC,CAAC,SAAS,IAAI,QAAQ,KAAK,IAAI,YAAY,IAAI,YAAY,IAAI,UAAU,IAAI,QAAQ,IAAI,aAAa,KAC5H,MAAM,IAAI,UAAU,gFAAgF;CAEtG,OAAO,OAAO,OAAO;EAAE,GAAG;EAAS,SAAS,IAAI;EAAQ,SAAS,IAAI,QAAQ,QAAQ,OAAO;CAAE,CAAC;AACjG;;AAGA,eAAsB,QAAW,MAAc,UAA0B,CAAC,GAAe;CACvF,MAAM,EAAE,QAAQ,SAAS,gBAAgB,GAAG,SAAS;CACrD,MAAM,UAAU,IAAI,QAAQ,QAAQ,OAAO;CAC3C,IAAI,QAAQ,cAAc,CAAC,CAAC,SAAS,OAAO,QAAQ,QAAQ,IAAI,KAAK,KAAK,CAAC;CAC3E,MAAM,MAAM,SAAS,IAAI,IAAI,MAAM,OAAO,OAAO,IAAI,KAAA;CACrD,IAAI,UAAU,KAAK,WAAW,OAAO,SACnC,MAAM,IAAI,UAAU,uDAAuD;CAE7E,IAAI,CAAC,QAAQ,IAAI,eAAe,GAAG;EACjC,MAAM,QAAQ,MAAM,QAAQ,iBAAiB;EAC7C,IAAI,OAAO,QAAQ,IAAI,iBAAiB,UAAU,OAAO;CAC3D;CACA,IAAI,KAAK,gBAAgB,UAAU,QAAQ,OAAO,cAAc;CAChE,IAAI,CAAC,QAAQ,IAAI,QAAQ,GAAG,QAAQ,IAAI,UAAU,kBAAkB;CACpE,MAAM,WAAW,OAAO,QAAQ,SAAS,WAAW,MAAA,CAAO,KAAK,QAAQ,MAAM;EAC5E,aAAa;EAAQ,GAAG;EAAM;CAChC,CAAC;CACD,IAAI;CACJ,IAAI,SAAS,WAAW,OAAO,SAAS,WAAW,OAAO,KAAK,WAAW,QAAQ;EAChF,MAAM,OAAO,MAAM,SAAS,KAAK;EACjC,IAAI,MAAM;GACR,IAAI,SAAS,QAAQ,IAAI,cAAc,CAAC,EAAE,SAAS,MAAM,GACvD,IAAI;IAAE,OAAO,KAAK,MAAM,IAAI;GAAG,SACxB,OAAO;IAAE,IAAI,SAAS,IAAI,MAAM;IAAO,OAAO;GAAM;QACtD,OAAO;EAChB;CACF;CACA,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,SAAS,UAAU,IAAI;CACnD,OAAO;AACT"}