@learnorama/mozaik-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -0
- package/dist/api/account.d.ts +75 -0
- package/dist/api/account.js +117 -0
- package/dist/api/account.js.map +1 -0
- package/dist/api/admin-catalogue.d.ts +68 -0
- package/dist/api/admin-catalogue.js +155 -0
- package/dist/api/admin-catalogue.js.map +1 -0
- package/dist/api/admin-consumption.d.ts +27 -0
- package/dist/api/admin-consumption.js +55 -0
- package/dist/api/admin-consumption.js.map +1 -0
- package/dist/api/admin-licenses.d.ts +21 -0
- package/dist/api/admin-licenses.js +34 -0
- package/dist/api/admin-licenses.js.map +1 -0
- package/dist/api/admin-patrons.d.ts +36 -0
- package/dist/api/admin-patrons.js +76 -0
- package/dist/api/admin-patrons.js.map +1 -0
- package/dist/api/admin-reviews.d.ts +30 -0
- package/dist/api/admin-reviews.js +63 -0
- package/dist/api/admin-reviews.js.map +1 -0
- package/dist/api/admin-roles.d.ts +34 -0
- package/dist/api/admin-roles.js +62 -0
- package/dist/api/admin-roles.js.map +1 -0
- package/dist/api/admin-support.d.ts +68 -0
- package/dist/api/admin-support.js +116 -0
- package/dist/api/admin-support.js.map +1 -0
- package/dist/api/admin-tenants.d.ts +33 -0
- package/dist/api/admin-tenants.js +68 -0
- package/dist/api/admin-tenants.js.map +1 -0
- package/dist/api/admin-tutoring.d.ts +159 -0
- package/dist/api/admin-tutoring.js +455 -0
- package/dist/api/admin-tutoring.js.map +1 -0
- package/dist/api/auth.d.ts +92 -0
- package/dist/api/auth.js +192 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/biblio-catalogue.d.ts +122 -0
- package/dist/api/biblio-catalogue.js +223 -0
- package/dist/api/biblio-catalogue.js.map +1 -0
- package/dist/api/biblio-home.d.ts +18 -0
- package/dist/api/biblio-home.js +31 -0
- package/dist/api/biblio-home.js.map +1 -0
- package/dist/api/biblio-library.d.ts +94 -0
- package/dist/api/biblio-library.js +187 -0
- package/dist/api/biblio-library.js.map +1 -0
- package/dist/api/biblio-nextory.d.ts +43 -0
- package/dist/api/biblio-nextory.js +65 -0
- package/dist/api/biblio-nextory.js.map +1 -0
- package/dist/api/biblio-press.d.ts +38 -0
- package/dist/api/biblio-press.js +70 -0
- package/dist/api/biblio-press.js.map +1 -0
- package/dist/api/biblio-search.d.ts +17 -0
- package/dist/api/biblio-search.js +30 -0
- package/dist/api/biblio-search.js.map +1 -0
- package/dist/api/biblio-telemetry.d.ts +28 -0
- package/dist/api/biblio-telemetry.js +49 -0
- package/dist/api/biblio-telemetry.js.map +1 -0
- package/dist/api/consumption.d.ts +30 -0
- package/dist/api/consumption.js +45 -0
- package/dist/api/consumption.js.map +1 -0
- package/dist/api/cvs-app.d.ts +39 -0
- package/dist/api/cvs-app.js +72 -0
- package/dist/api/cvs-app.js.map +1 -0
- package/dist/api/cvs-documents.d.ts +106 -0
- package/dist/api/cvs-documents.js +208 -0
- package/dist/api/cvs-documents.js.map +1 -0
- package/dist/api/cvs-favorites.d.ts +53 -0
- package/dist/api/cvs-favorites.js +82 -0
- package/dist/api/cvs-favorites.js.map +1 -0
- package/dist/api/cvs-loans.d.ts +59 -0
- package/dist/api/cvs-loans.js +106 -0
- package/dist/api/cvs-loans.js.map +1 -0
- package/dist/api/cvs-streaming.d.ts +40 -0
- package/dist/api/cvs-streaming.js +68 -0
- package/dist/api/cvs-streaming.js.map +1 -0
- package/dist/api/index.d.ts +34 -0
- package/dist/api/index.js +34 -0
- package/dist/api/partner-catalogue.d.ts +77 -0
- package/dist/api/partner-catalogue.js +125 -0
- package/dist/api/partner-catalogue.js.map +1 -0
- package/dist/api/partner-reader.d.ts +56 -0
- package/dist/api/partner-reader.js +103 -0
- package/dist/api/partner-reader.js.map +1 -0
- package/dist/api/profiles.d.ts +64 -0
- package/dist/api/profiles.js +126 -0
- package/dist/api/profiles.js.map +1 -0
- package/dist/api/tutoring-catalogue.d.ts +32 -0
- package/dist/api/tutoring-catalogue.js +59 -0
- package/dist/api/tutoring-catalogue.js.map +1 -0
- package/dist/api/tutoring-chat.d.ts +31 -0
- package/dist/api/tutoring-chat.js +71 -0
- package/dist/api/tutoring-chat.js.map +1 -0
- package/dist/api/tutoring-dispatch.d.ts +37 -0
- package/dist/api/tutoring-dispatch.js +83 -0
- package/dist/api/tutoring-dispatch.js.map +1 -0
- package/dist/api/tutoring-practitioner.d.ts +55 -0
- package/dist/api/tutoring-practitioner.js +110 -0
- package/dist/api/tutoring-practitioner.js.map +1 -0
- package/dist/api/tutoring-requests.d.ts +86 -0
- package/dist/api/tutoring-requests.js +176 -0
- package/dist/api/tutoring-requests.js.map +1 -0
- package/dist/client-BDwBZYB0.d.ts +28 -0
- package/dist/client-D3kMOcIr.js +61 -0
- package/dist/client-D3kMOcIr.js.map +1 -0
- package/dist/index-wL_20vR8.d.ts +4566 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +3 -0
- package/dist/models.js +175 -0
- package/dist/models.js.map +1 -0
- package/dist/react/account.d.ts +163 -0
- package/dist/react/account.js +240 -0
- package/dist/react/account.js.map +1 -0
- package/dist/react/admin-catalogue.d.ts +196 -0
- package/dist/react/admin-catalogue.js +336 -0
- package/dist/react/admin-catalogue.js.map +1 -0
- package/dist/react/admin-consumption.d.ts +75 -0
- package/dist/react/admin-consumption.js +127 -0
- package/dist/react/admin-consumption.js.map +1 -0
- package/dist/react/admin-licenses.d.ts +50 -0
- package/dist/react/admin-licenses.js +78 -0
- package/dist/react/admin-licenses.js.map +1 -0
- package/dist/react/admin-patrons.d.ts +111 -0
- package/dist/react/admin-patrons.js +173 -0
- package/dist/react/admin-patrons.js.map +1 -0
- package/dist/react/admin-reviews.d.ts +78 -0
- package/dist/react/admin-reviews.js +135 -0
- package/dist/react/admin-reviews.js.map +1 -0
- package/dist/react/admin-roles.d.ts +82 -0
- package/dist/react/admin-roles.js +135 -0
- package/dist/react/admin-roles.js.map +1 -0
- package/dist/react/admin-support.d.ts +123 -0
- package/dist/react/admin-support.js +208 -0
- package/dist/react/admin-support.js.map +1 -0
- package/dist/react/admin-tenants.d.ts +108 -0
- package/dist/react/admin-tenants.js +165 -0
- package/dist/react/admin-tenants.js.map +1 -0
- package/dist/react/admin-tutoring.d.ts +556 -0
- package/dist/react/admin-tutoring.js +954 -0
- package/dist/react/admin-tutoring.js.map +1 -0
- package/dist/react/auth.d.ts +220 -0
- package/dist/react/auth.js +372 -0
- package/dist/react/auth.js.map +1 -0
- package/dist/react/biblio-catalogue.d.ts +374 -0
- package/dist/react/biblio-catalogue.js +498 -0
- package/dist/react/biblio-catalogue.js.map +1 -0
- package/dist/react/biblio-home.d.ts +47 -0
- package/dist/react/biblio-home.js +75 -0
- package/dist/react/biblio-home.js.map +1 -0
- package/dist/react/biblio-library.d.ts +285 -0
- package/dist/react/biblio-library.js +411 -0
- package/dist/react/biblio-library.js.map +1 -0
- package/dist/react/biblio-nextory.d.ts +100 -0
- package/dist/react/biblio-nextory.js +163 -0
- package/dist/react/biblio-nextory.js.map +1 -0
- package/dist/react/biblio-press.d.ts +121 -0
- package/dist/react/biblio-press.js +163 -0
- package/dist/react/biblio-press.js.map +1 -0
- package/dist/react/biblio-search.d.ts +46 -0
- package/dist/react/biblio-search.js +74 -0
- package/dist/react/biblio-search.js.map +1 -0
- package/dist/react/biblio-telemetry.d.ts +49 -0
- package/dist/react/biblio-telemetry.js +85 -0
- package/dist/react/biblio-telemetry.js.map +1 -0
- package/dist/react/consumption.d.ts +66 -0
- package/dist/react/consumption.js +109 -0
- package/dist/react/consumption.js.map +1 -0
- package/dist/react/cvs-app.d.ts +86 -0
- package/dist/react/cvs-app.js +144 -0
- package/dist/react/cvs-app.js.map +1 -0
- package/dist/react/cvs-documents.d.ts +254 -0
- package/dist/react/cvs-documents.js +418 -0
- package/dist/react/cvs-documents.js.map +1 -0
- package/dist/react/cvs-favorites.d.ts +143 -0
- package/dist/react/cvs-favorites.js +206 -0
- package/dist/react/cvs-favorites.js.map +1 -0
- package/dist/react/cvs-loans.d.ts +140 -0
- package/dist/react/cvs-loans.js +234 -0
- package/dist/react/cvs-loans.js.map +1 -0
- package/dist/react/cvs-streaming.d.ts +87 -0
- package/dist/react/cvs-streaming.js +141 -0
- package/dist/react/cvs-streaming.js.map +1 -0
- package/dist/react/index.d.ts +34 -0
- package/dist/react/index.js +34 -0
- package/dist/react/partner-catalogue.d.ts +223 -0
- package/dist/react/partner-catalogue.js +301 -0
- package/dist/react/partner-catalogue.js.map +1 -0
- package/dist/react/partner-reader.d.ts +159 -0
- package/dist/react/partner-reader.js +226 -0
- package/dist/react/partner-reader.js.map +1 -0
- package/dist/react/profiles.d.ts +174 -0
- package/dist/react/profiles.js +279 -0
- package/dist/react/profiles.js.map +1 -0
- package/dist/react/tutoring-catalogue.d.ts +115 -0
- package/dist/react/tutoring-catalogue.js +151 -0
- package/dist/react/tutoring-catalogue.js.map +1 -0
- package/dist/react/tutoring-chat.d.ts +96 -0
- package/dist/react/tutoring-chat.js +172 -0
- package/dist/react/tutoring-chat.js.map +1 -0
- package/dist/react/tutoring-dispatch.d.ts +102 -0
- package/dist/react/tutoring-dispatch.js +183 -0
- package/dist/react/tutoring-dispatch.js.map +1 -0
- package/dist/react/tutoring-practitioner.d.ts +129 -0
- package/dist/react/tutoring-practitioner.js +230 -0
- package/dist/react/tutoring-practitioner.js.map +1 -0
- package/dist/react/tutoring-requests.d.ts +233 -0
- package/dist/react/tutoring-requests.js +385 -0
- package/dist/react/tutoring-requests.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
import { Gn as HTTPExceptionResponse, Nr as ChatTicketRead, Xt as MessagePage, Yt as MessageWrite, Zt as MessageRead, gn as ListMessagesParams, t as ValidationErrorResponse } from "../index-wL_20vR8.js";
|
|
3
|
+
import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
|
|
4
|
+
import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
5
|
+
//#region src/react/tutoring-chat/tutoring-chat.d.ts
|
|
6
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
7
|
+
export declare const getMintChatTicketUrl: (requestId: number) => string;
|
|
8
|
+
/**
|
|
9
|
+
* A single-use credential for opening the socket from a browser.
|
|
10
|
+
*
|
|
11
|
+
* Authenticated the ordinary way, with the ordinary bearer token, because this
|
|
12
|
+
* is an ordinary HTTP request. What it returns is what goes in the socket URL.
|
|
13
|
+
* @summary Mint Chat Ticket
|
|
14
|
+
*/
|
|
15
|
+
export declare const mintChatTicket: (requestId: number, options?: Parameters<typeof request>[1]) => Promise<ChatTicketRead>;
|
|
16
|
+
export declare const getMintChatTicketMutationKey: () => readonly ['mintChatTicket'];
|
|
17
|
+
export declare const getMintChatTicketMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
18
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError, MintChatTicketMutationVariables, TContext>;
|
|
19
|
+
request?: SecondParameter<typeof request>;
|
|
20
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError, MintChatTicketMutationVariables, TContext>;
|
|
21
|
+
export type MintChatTicketMutationResult = NonNullable<Awaited<ReturnType<typeof mintChatTicket>>>;
|
|
22
|
+
export type MintChatTicketMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
23
|
+
export type MintChatTicketMutationVariables = {
|
|
24
|
+
requestId: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @summary Mint Chat Ticket
|
|
28
|
+
*/
|
|
29
|
+
export declare const useMintChatTicket: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
30
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError, MintChatTicketMutationVariables, TContext>;
|
|
31
|
+
request?: SecondParameter<typeof request>;
|
|
32
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof mintChatTicket>>, TError, MintChatTicketMutationVariables, TContext>;
|
|
33
|
+
export declare const getListMessagesUrl: (requestId: number, params?: ListMessagesParams) => string;
|
|
34
|
+
/**
|
|
35
|
+
* The conversation so far, newest first.
|
|
36
|
+
*
|
|
37
|
+
* One extra row is fetched to answer ``hasMore`` without a second count. A
|
|
38
|
+
* ``COUNT(*)`` over a thread on every scroll is a table scan for a number no
|
|
39
|
+
* interface displays.
|
|
40
|
+
* @summary List Messages
|
|
41
|
+
*/
|
|
42
|
+
export declare const listMessages: (requestId: number, params?: ListMessagesParams, options?: Parameters<typeof request>[1]) => Promise<MessagePage>;
|
|
43
|
+
export declare const getListMessagesQueryKey: (requestId: number, params?: ListMessagesParams) => readonly [`/tutoring/requests/${number}/messages`, ...ListMessagesParams[]];
|
|
44
|
+
export declare const getListMessagesQueryOptions: <TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(requestId: number, params?: ListMessagesParams, options?: {
|
|
45
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>>;
|
|
46
|
+
request?: SecondParameter<typeof request>;
|
|
47
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData> & {
|
|
48
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
49
|
+
};
|
|
50
|
+
export type ListMessagesQueryResult = NonNullable<Awaited<ReturnType<typeof listMessages>>>;
|
|
51
|
+
export type ListMessagesQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
52
|
+
export declare function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(requestId: number, params: undefined | ListMessagesParams, options: {
|
|
53
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof listMessages>>, TError, Awaited<ReturnType<typeof listMessages>>>, 'initialData'>;
|
|
54
|
+
request?: SecondParameter<typeof request>;
|
|
55
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
56
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
57
|
+
};
|
|
58
|
+
export declare function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(requestId: number, params?: ListMessagesParams, options?: {
|
|
59
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof listMessages>>, TError, Awaited<ReturnType<typeof listMessages>>>, 'initialData'>;
|
|
60
|
+
request?: SecondParameter<typeof request>;
|
|
61
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
62
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
63
|
+
};
|
|
64
|
+
export declare function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(requestId: number, params?: ListMessagesParams, options?: {
|
|
65
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>>;
|
|
66
|
+
request?: SecondParameter<typeof request>;
|
|
67
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
68
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
69
|
+
};
|
|
70
|
+
export declare const getSendMessageUrl: (requestId: number) => string;
|
|
71
|
+
/**
|
|
72
|
+
* Say something, without holding a socket open.
|
|
73
|
+
* @summary Send Message
|
|
74
|
+
*/
|
|
75
|
+
export declare const sendMessage: (requestId: number, messageWrite: MessageWrite, options?: Parameters<typeof request>[1]) => Promise<MessageRead>;
|
|
76
|
+
export declare const getSendMessageMutationKey: () => readonly ['sendMessage'];
|
|
77
|
+
export declare const getSendMessageMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
78
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError, SendMessageMutationVariables, TContext>;
|
|
79
|
+
request?: SecondParameter<typeof request>;
|
|
80
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError, SendMessageMutationVariables, TContext>;
|
|
81
|
+
export type SendMessageMutationResult = NonNullable<Awaited<ReturnType<typeof sendMessage>>>;
|
|
82
|
+
export type SendMessageMutationBody = BodyType<MessageWrite>;
|
|
83
|
+
export type SendMessageMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
84
|
+
export type SendMessageMutationVariables = {
|
|
85
|
+
requestId: number;
|
|
86
|
+
data: BodyType<MessageWrite>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @summary Send Message
|
|
90
|
+
*/
|
|
91
|
+
export declare const useSendMessage: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
92
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError, SendMessageMutationVariables, TContext>;
|
|
93
|
+
request?: SecondParameter<typeof request>;
|
|
94
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof sendMessage>>, TError, SendMessageMutationVariables, TContext>;
|
|
95
|
+
//#endregion
|
|
96
|
+
//# sourceMappingURL=tutoring-chat.d.ts.map
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../client-D3kMOcIr.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/tutoring-chat/tutoring-chat.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generated by orval 🍺
|
|
7
|
+
* Do not edit manually.
|
|
8
|
+
* Mozaik backend
|
|
9
|
+
* Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
|
|
10
|
+
* OpenAPI spec version: 0.1.0
|
|
11
|
+
*/
|
|
12
|
+
const withQueryKey = (query, queryKey) => {
|
|
13
|
+
const result = { queryKey };
|
|
14
|
+
for (const key of Object.keys(query)) {
|
|
15
|
+
if (key === "queryKey") continue;
|
|
16
|
+
Object.defineProperty(result, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
get: () => query[key]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const getMintChatTicketUrl = (requestId) => {
|
|
25
|
+
return `/tutoring/requests/${requestId}/chat/ticket`;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A single-use credential for opening the socket from a browser.
|
|
29
|
+
*
|
|
30
|
+
* Authenticated the ordinary way, with the ordinary bearer token, because this
|
|
31
|
+
* is an ordinary HTTP request. What it returns is what goes in the socket URL.
|
|
32
|
+
* @summary Mint Chat Ticket
|
|
33
|
+
*/
|
|
34
|
+
const mintChatTicket = async (requestId, options) => {
|
|
35
|
+
return request(getMintChatTicketUrl(requestId), {
|
|
36
|
+
...options,
|
|
37
|
+
method: "POST"
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const getMintChatTicketMutationKey = () => ["mintChatTicket"];
|
|
41
|
+
const getMintChatTicketMutationOptions = (options) => {
|
|
42
|
+
const mutationKey = getMintChatTicketMutationKey();
|
|
43
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
44
|
+
...options,
|
|
45
|
+
mutation: {
|
|
46
|
+
...options.mutation,
|
|
47
|
+
mutationKey
|
|
48
|
+
}
|
|
49
|
+
} : {
|
|
50
|
+
mutation: { mutationKey },
|
|
51
|
+
request: void 0
|
|
52
|
+
};
|
|
53
|
+
const mutationFn = (props) => {
|
|
54
|
+
const { requestId } = props ?? {};
|
|
55
|
+
return mintChatTicket(requestId, requestOptions);
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
mutationFn,
|
|
59
|
+
...mutationOptions
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @summary Mint Chat Ticket
|
|
64
|
+
*/
|
|
65
|
+
const useMintChatTicket = (options, queryClient) => {
|
|
66
|
+
return useMutation(getMintChatTicketMutationOptions(options), queryClient);
|
|
67
|
+
};
|
|
68
|
+
const getListMessagesUrl = (requestId, params) => {
|
|
69
|
+
const normalizedParams = new URLSearchParams();
|
|
70
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
71
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
72
|
+
});
|
|
73
|
+
const stringifiedParams = normalizedParams.toString();
|
|
74
|
+
return stringifiedParams.length > 0 ? `/tutoring/requests/${requestId}/messages?${stringifiedParams}` : `/tutoring/requests/${requestId}/messages`;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The conversation so far, newest first.
|
|
78
|
+
*
|
|
79
|
+
* One extra row is fetched to answer ``hasMore`` without a second count. A
|
|
80
|
+
* ``COUNT(*)`` over a thread on every scroll is a table scan for a number no
|
|
81
|
+
* interface displays.
|
|
82
|
+
* @summary List Messages
|
|
83
|
+
*/
|
|
84
|
+
const listMessages = async (requestId, params, options) => {
|
|
85
|
+
return request(getListMessagesUrl(requestId, params), {
|
|
86
|
+
...options,
|
|
87
|
+
method: "GET"
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const getListMessagesQueryKey = (requestId, params) => {
|
|
91
|
+
return [`/tutoring/requests/${requestId}/messages`, ...params ? [params] : []];
|
|
92
|
+
};
|
|
93
|
+
const getListMessagesQueryOptions = (requestId, params, options) => {
|
|
94
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
95
|
+
const queryKey = queryOptions?.queryKey ?? getListMessagesQueryKey(requestId, params);
|
|
96
|
+
const queryFn = ({ signal }) => listMessages(requestId, params, {
|
|
97
|
+
signal,
|
|
98
|
+
...requestOptions
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
queryKey,
|
|
102
|
+
queryFn,
|
|
103
|
+
enabled: requestId !== null && requestId !== void 0,
|
|
104
|
+
...queryOptions
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @summary List Messages
|
|
109
|
+
*/
|
|
110
|
+
function useListMessages(requestId, params, options, queryClient) {
|
|
111
|
+
const queryOptions = getListMessagesQueryOptions(requestId, params, options);
|
|
112
|
+
const query = useQuery(queryOptions, queryClient);
|
|
113
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
114
|
+
}
|
|
115
|
+
const getSendMessageUrl = (requestId) => {
|
|
116
|
+
return `/tutoring/requests/${requestId}/messages`;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Say something, without holding a socket open.
|
|
120
|
+
* @summary Send Message
|
|
121
|
+
*/
|
|
122
|
+
const sendMessage = async (requestId, messageWrite, options) => {
|
|
123
|
+
const getHeaders = (h) => {
|
|
124
|
+
if (!h) return {};
|
|
125
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
126
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
127
|
+
const headers = {};
|
|
128
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
129
|
+
return headers;
|
|
130
|
+
};
|
|
131
|
+
return request(getSendMessageUrl(requestId), {
|
|
132
|
+
...options,
|
|
133
|
+
method: "POST",
|
|
134
|
+
headers: {
|
|
135
|
+
"Content-Type": "application/json",
|
|
136
|
+
...getHeaders(options?.headers)
|
|
137
|
+
},
|
|
138
|
+
body: JSON.stringify(messageWrite)
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const getSendMessageMutationKey = () => ["sendMessage"];
|
|
142
|
+
const getSendMessageMutationOptions = (options) => {
|
|
143
|
+
const mutationKey = getSendMessageMutationKey();
|
|
144
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
145
|
+
...options,
|
|
146
|
+
mutation: {
|
|
147
|
+
...options.mutation,
|
|
148
|
+
mutationKey
|
|
149
|
+
}
|
|
150
|
+
} : {
|
|
151
|
+
mutation: { mutationKey },
|
|
152
|
+
request: void 0
|
|
153
|
+
};
|
|
154
|
+
const mutationFn = (props) => {
|
|
155
|
+
const { requestId, data } = props ?? {};
|
|
156
|
+
return sendMessage(requestId, data, requestOptions);
|
|
157
|
+
};
|
|
158
|
+
return {
|
|
159
|
+
mutationFn,
|
|
160
|
+
...mutationOptions
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* @summary Send Message
|
|
165
|
+
*/
|
|
166
|
+
const useSendMessage = (options, queryClient) => {
|
|
167
|
+
return useMutation(getSendMessageMutationOptions(options), queryClient);
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { getListMessagesQueryKey, getListMessagesQueryOptions, getListMessagesUrl, getMintChatTicketMutationKey, getMintChatTicketMutationOptions, getMintChatTicketUrl, getSendMessageMutationKey, getSendMessageMutationOptions, getSendMessageUrl, listMessages, mintChatTicket, sendMessage, useListMessages, useMintChatTicket, useSendMessage };
|
|
171
|
+
|
|
172
|
+
//# sourceMappingURL=tutoring-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tutoring-chat.js","names":[],"sources":["../../src/react/tutoring-chat/tutoring-chat.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 ChatTicketRead,\n HTTPExceptionResponse,\n ListMessagesParams,\n MessagePage,\n MessageRead,\n MessageWrite,\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 getMintChatTicketUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/chat/ticket`\n}\n\n/**\n * A single-use credential for opening the socket from a browser.\n *\n * Authenticated the ordinary way, with the ordinary bearer token, because this\n * is an ordinary HTTP request. What it returns is what goes in the socket URL.\n * @summary Mint Chat Ticket\n */\nexport const mintChatTicket = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<ChatTicketRead> => {\n\n return request<ChatTicketRead>(getMintChatTicketUrl(requestId),\n {\n ...options,\n method: 'POST'\n\n\n }\n);}\n\n\n\n\n\nexport const getMintChatTicketMutationKey = () => ['mintChatTicket'] as const;\n\nexport const getMintChatTicketMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError,MintChatTicketMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError,MintChatTicketMutationVariables, TContext> => {\n\nconst mutationKey = getMintChatTicketMutationKey();\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 mintChatTicket>>, MintChatTicketMutationVariables> = (props) => {\n const {requestId} = props ?? {};\n\n return mintChatTicket(requestId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type MintChatTicketMutationResult = NonNullable<Awaited<ReturnType<typeof mintChatTicket>>>\n\n export type MintChatTicketMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type MintChatTicketMutationVariables = {requestId: number}\n\n /**\n * @summary Mint Chat Ticket\n */\nexport const useMintChatTicket = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof mintChatTicket>>, TError,MintChatTicketMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof mintChatTicket>>,\n TError,\n MintChatTicketMutationVariables,\n TContext\n > => {\n return useMutation(getMintChatTicketMutationOptions(options), queryClient);\n }\n export const getListMessagesUrl = (requestId: number,\n params?: ListMessagesParams,) => {\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 ? `/tutoring/requests/${requestId}/messages?${stringifiedParams}` : `/tutoring/requests/${requestId}/messages`\n}\n\n/**\n * The conversation so far, newest first.\n *\n * One extra row is fetched to answer ``hasMore`` without a second count. A\n * ``COUNT(*)`` over a thread on every scroll is a table scan for a number no\n * interface displays.\n * @summary List Messages\n */\nexport const listMessages = async (requestId: number,\n params?: ListMessagesParams, options?: Parameters<typeof request>[1]): Promise<MessagePage> => {\n\n return request<MessagePage>(getListMessagesUrl(requestId,params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListMessagesQueryKey = (requestId: number,\n params?: ListMessagesParams,) => {\n return [\n `/tutoring/requests/${requestId}/messages`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getListMessagesQueryOptions = <TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(requestId: number,\n params?: ListMessagesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListMessagesQueryKey(requestId,params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listMessages>>> = ({ signal }) => listMessages(requestId,params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, enabled: requestId !== null && requestId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListMessagesQueryResult = NonNullable<Awaited<ReturnType<typeof listMessages>>>\nexport type ListMessagesQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n requestId: number,\n params: undefined | ListMessagesParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listMessages>>,\n TError,\n Awaited<ReturnType<typeof listMessages>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n requestId: number,\n params?: ListMessagesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listMessages>>,\n TError,\n Awaited<ReturnType<typeof listMessages>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n requestId: number,\n params?: ListMessagesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Messages\n */\n\nexport function useListMessages<TData = Awaited<ReturnType<typeof listMessages>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n requestId: number,\n params?: ListMessagesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listMessages>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListMessagesQueryOptions(requestId,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 getSendMessageUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/messages`\n}\n\n/**\n * Say something, without holding a socket open.\n * @summary Send Message\n */\nexport const sendMessage = async (requestId: number,\n messageWrite: MessageWrite, options?: Parameters<typeof request>[1]): Promise<MessageRead> => {\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<MessageRead>(getSendMessageUrl(requestId),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(messageWrite)\n }\n);}\n\n\n\n\n\nexport const getSendMessageMutationKey = () => ['sendMessage'] as const;\n\nexport const getSendMessageMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError,SendMessageMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError,SendMessageMutationVariables, TContext> => {\n\nconst mutationKey = getSendMessageMutationKey();\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 sendMessage>>, SendMessageMutationVariables> = (props) => {\n const {requestId,data} = props ?? {};\n\n return sendMessage(requestId,data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type SendMessageMutationResult = NonNullable<Awaited<ReturnType<typeof sendMessage>>>\n export type SendMessageMutationBody = BodyType<MessageWrite>\n export type SendMessageMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type SendMessageMutationVariables = {requestId: number;data: BodyType<MessageWrite>}\n\n /**\n * @summary Send Message\n */\nexport const useSendMessage = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof sendMessage>>, TError,SendMessageMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof sendMessage>>,\n TError,\n SendMessageMutationVariables,\n TContext\n > => {\n return useMutation(getSendMessageMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA4CA,MAAM,gBAAqC,OAAU,aAAqC;CACxF,MAAM,SAAS,EAAE,SAAS;CAC1B,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EAGpC,IAAI,QAAQ,YAAY;EACxB,OAAO,eAAe,QAAQ,KAAK;GACjC,YAAY;GACZ,cAAc;GACd,WAAY,MAAkC;EAChD,CAAC;CACH;CACA,OAAO;AACT;AAEA,MAAa,wBAAwB,cAAuB;CAK1D,OAAO,sBAAsB,UAAU;AACzC;;;;;;;;AASA,MAAa,iBAAiB,OAAO,WAAmB,YAAqE;CAE3H,OAAO,QAAwB,qBAAqB,SAAS,GAC7D;EACE,GAAG;EACH,QAAQ;CAGV,CACF;AAAE;AAMF,MAAa,qCAAqC,CAAC,gBAAgB;AAEnE,MAAa,oCACW,YAC+F;CAEvH,MAAM,cAAc,6BAA6B;CACjD,MAAM,EAAC,UAAU,iBAAiB,SAAS,mBAAkB,UACvD,QAAQ,YAAY,iBAAiB,QAAQ,YAAY,QAAQ,SAAS,c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AAM,cAAuG,UAAU;EACnH,MAAM,EAAC,WAAU,SAAQ,SAAS,CAAC;EAEnC,OAAQ,YAAY,WAAU,MAAK,cAAc;CACnD;CAON,OAAQ;EAAE;EAAY,GAAG;CAAgB;AAAC;;;;AAU5C,MAAa,kBACW,SACrB,gBAKQ;CACL,OAAO,YAAY,8BAA8B,OAAO,GAAG,WAAW;AACxE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
import { Gn as HTTPExceptionResponse, _ as TutoringDispatchWrite, d as TutoringQueuePage, t as ValidationErrorResponse, un as ListQueueParams } from "../index-wL_20vR8.js";
|
|
3
|
+
import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
|
|
4
|
+
import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
5
|
+
//#region src/react/tutoring-dispatch/tutoring-dispatch.d.ts
|
|
6
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
7
|
+
export declare const getListQueueUrl: (params?: ListQueueParams) => string;
|
|
8
|
+
/**
|
|
9
|
+
* What is waiting, oldest first.
|
|
10
|
+
*
|
|
11
|
+
* Scoped to the dispatcher's tenant. Defaults to the four open statuses, which
|
|
12
|
+
* is what the partial index on the table is built for — pass ``?status=`` to
|
|
13
|
+
* look at something else and the query stops using it, which is the honest
|
|
14
|
+
* trade rather than a hidden one.
|
|
15
|
+
* @summary List Queue
|
|
16
|
+
*/
|
|
17
|
+
export declare const listQueue: (params?: ListQueueParams, options?: Parameters<typeof request>[1]) => Promise<TutoringQueuePage>;
|
|
18
|
+
export declare const getListQueueQueryKey: (params?: ListQueueParams) => readonly ["/tutoring/queue", ...ListQueueParams[]];
|
|
19
|
+
export declare const getListQueueQueryOptions: <TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListQueueParams, options?: {
|
|
20
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>>;
|
|
21
|
+
request?: SecondParameter<typeof request>;
|
|
22
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData> & {
|
|
23
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
24
|
+
};
|
|
25
|
+
export type ListQueueQueryResult = NonNullable<Awaited<ReturnType<typeof listQueue>>>;
|
|
26
|
+
export type ListQueueQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
27
|
+
export declare function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params: undefined | ListQueueParams, options: {
|
|
28
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof listQueue>>, TError, Awaited<ReturnType<typeof listQueue>>>, 'initialData'>;
|
|
29
|
+
request?: SecondParameter<typeof request>;
|
|
30
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
31
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
32
|
+
};
|
|
33
|
+
export declare function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListQueueParams, options?: {
|
|
34
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof listQueue>>, TError, Awaited<ReturnType<typeof listQueue>>>, 'initialData'>;
|
|
35
|
+
request?: SecondParameter<typeof request>;
|
|
36
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
37
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
38
|
+
};
|
|
39
|
+
export declare function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListQueueParams, options?: {
|
|
40
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>>;
|
|
41
|
+
request?: SecondParameter<typeof request>;
|
|
42
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
43
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
44
|
+
};
|
|
45
|
+
export declare const getDispatchRequestUrl: (requestId: number) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Route it — to somebody named, or to the open pool.
|
|
48
|
+
*
|
|
49
|
+
* Changing the channel here is deliberate and common: pupils pick a classroom
|
|
50
|
+
* and turn out to have no microphone, and the dispatcher is the person who
|
|
51
|
+
* finds that out.
|
|
52
|
+
* @summary Dispatch Request
|
|
53
|
+
*/
|
|
54
|
+
export declare const dispatchRequest: (requestId: number, tutoringDispatchWrite: TutoringDispatchWrite, options?: Parameters<typeof request>[1]) => Promise<void>;
|
|
55
|
+
export declare const getDispatchRequestMutationKey: () => readonly ['dispatchRequest'];
|
|
56
|
+
export declare const getDispatchRequestMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
57
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError, DispatchRequestMutationVariables, TContext>;
|
|
58
|
+
request?: SecondParameter<typeof request>;
|
|
59
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError, DispatchRequestMutationVariables, TContext>;
|
|
60
|
+
export type DispatchRequestMutationResult = NonNullable<Awaited<ReturnType<typeof dispatchRequest>>>;
|
|
61
|
+
export type DispatchRequestMutationBody = BodyType<TutoringDispatchWrite>;
|
|
62
|
+
export type DispatchRequestMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
63
|
+
export type DispatchRequestMutationVariables = {
|
|
64
|
+
requestId: number;
|
|
65
|
+
data: BodyType<TutoringDispatchWrite>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* @summary Dispatch Request
|
|
69
|
+
*/
|
|
70
|
+
export declare const useDispatchRequest: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
71
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError, DispatchRequestMutationVariables, TContext>;
|
|
72
|
+
request?: SecondParameter<typeof request>;
|
|
73
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof dispatchRequest>>, TError, DispatchRequestMutationVariables, TContext>;
|
|
74
|
+
export declare const getTriageRequestUrl: (requestId: number) => string;
|
|
75
|
+
/**
|
|
76
|
+
* Take a request off the queue to look at it.
|
|
77
|
+
*
|
|
78
|
+
* Separate from dispatching because the legacy's own timestamps separate them —
|
|
79
|
+
* ``picked_by_switchman_at`` then ``validated_at`` — and the gap between the
|
|
80
|
+
* two is the figure that tells you whether the queue is staffed.
|
|
81
|
+
* @summary Triage Request
|
|
82
|
+
*/
|
|
83
|
+
export declare const triageRequest: (requestId: number, options?: Parameters<typeof request>[1]) => Promise<void>;
|
|
84
|
+
export declare const getTriageRequestMutationKey: () => readonly ['triageRequest'];
|
|
85
|
+
export declare const getTriageRequestMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
86
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError, TriageRequestMutationVariables, TContext>;
|
|
87
|
+
request?: SecondParameter<typeof request>;
|
|
88
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError, TriageRequestMutationVariables, TContext>;
|
|
89
|
+
export type TriageRequestMutationResult = NonNullable<Awaited<ReturnType<typeof triageRequest>>>;
|
|
90
|
+
export type TriageRequestMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
91
|
+
export type TriageRequestMutationVariables = {
|
|
92
|
+
requestId: number;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @summary Triage Request
|
|
96
|
+
*/
|
|
97
|
+
export declare const useTriageRequest: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
98
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError, TriageRequestMutationVariables, TContext>;
|
|
99
|
+
request?: SecondParameter<typeof request>;
|
|
100
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof triageRequest>>, TError, TriageRequestMutationVariables, TContext>;
|
|
101
|
+
//#endregion
|
|
102
|
+
//# sourceMappingURL=tutoring-dispatch.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../client-D3kMOcIr.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/tutoring-dispatch/tutoring-dispatch.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generated by orval 🍺
|
|
7
|
+
* Do not edit manually.
|
|
8
|
+
* Mozaik backend
|
|
9
|
+
* Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
|
|
10
|
+
* OpenAPI spec version: 0.1.0
|
|
11
|
+
*/
|
|
12
|
+
const withQueryKey = (query, queryKey) => {
|
|
13
|
+
const result = { queryKey };
|
|
14
|
+
for (const key of Object.keys(query)) {
|
|
15
|
+
if (key === "queryKey") continue;
|
|
16
|
+
Object.defineProperty(result, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
get: () => query[key]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const getListQueueUrl = (params) => {
|
|
25
|
+
const normalizedParams = new URLSearchParams();
|
|
26
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
27
|
+
if (Array.isArray(value) && ["status"].includes(key)) {
|
|
28
|
+
value.forEach((v) => {
|
|
29
|
+
normalizedParams.append(key, v === null ? "null" : String(v));
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
34
|
+
});
|
|
35
|
+
const stringifiedParams = normalizedParams.toString();
|
|
36
|
+
return stringifiedParams.length > 0 ? `/tutoring/queue?${stringifiedParams}` : `/tutoring/queue`;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* What is waiting, oldest first.
|
|
40
|
+
*
|
|
41
|
+
* Scoped to the dispatcher's tenant. Defaults to the four open statuses, which
|
|
42
|
+
* is what the partial index on the table is built for — pass ``?status=`` to
|
|
43
|
+
* look at something else and the query stops using it, which is the honest
|
|
44
|
+
* trade rather than a hidden one.
|
|
45
|
+
* @summary List Queue
|
|
46
|
+
*/
|
|
47
|
+
const listQueue = async (params, options) => {
|
|
48
|
+
return request(getListQueueUrl(params), {
|
|
49
|
+
...options,
|
|
50
|
+
method: "GET"
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const getListQueueQueryKey = (params) => {
|
|
54
|
+
return [`/tutoring/queue`, ...params ? [params] : []];
|
|
55
|
+
};
|
|
56
|
+
const getListQueueQueryOptions = (params, options) => {
|
|
57
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
58
|
+
const queryKey = queryOptions?.queryKey ?? getListQueueQueryKey(params);
|
|
59
|
+
const queryFn = ({ signal }) => listQueue(params, {
|
|
60
|
+
signal,
|
|
61
|
+
...requestOptions
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
queryKey,
|
|
65
|
+
queryFn,
|
|
66
|
+
...queryOptions
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* @summary List Queue
|
|
71
|
+
*/
|
|
72
|
+
function useListQueue(params, options, queryClient) {
|
|
73
|
+
const queryOptions = getListQueueQueryOptions(params, options);
|
|
74
|
+
const query = useQuery(queryOptions, queryClient);
|
|
75
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
76
|
+
}
|
|
77
|
+
const getDispatchRequestUrl = (requestId) => {
|
|
78
|
+
return `/tutoring/requests/${requestId}/dispatch`;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Route it — to somebody named, or to the open pool.
|
|
82
|
+
*
|
|
83
|
+
* Changing the channel here is deliberate and common: pupils pick a classroom
|
|
84
|
+
* and turn out to have no microphone, and the dispatcher is the person who
|
|
85
|
+
* finds that out.
|
|
86
|
+
* @summary Dispatch Request
|
|
87
|
+
*/
|
|
88
|
+
const dispatchRequest = async (requestId, tutoringDispatchWrite, options) => {
|
|
89
|
+
const getHeaders = (h) => {
|
|
90
|
+
if (!h) return {};
|
|
91
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
92
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
93
|
+
const headers = {};
|
|
94
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
95
|
+
return headers;
|
|
96
|
+
};
|
|
97
|
+
return request(getDispatchRequestUrl(requestId), {
|
|
98
|
+
...options,
|
|
99
|
+
method: "POST",
|
|
100
|
+
headers: {
|
|
101
|
+
"Content-Type": "application/json",
|
|
102
|
+
...getHeaders(options?.headers)
|
|
103
|
+
},
|
|
104
|
+
body: JSON.stringify(tutoringDispatchWrite)
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const getDispatchRequestMutationKey = () => ["dispatchRequest"];
|
|
108
|
+
const getDispatchRequestMutationOptions = (options) => {
|
|
109
|
+
const mutationKey = getDispatchRequestMutationKey();
|
|
110
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
111
|
+
...options,
|
|
112
|
+
mutation: {
|
|
113
|
+
...options.mutation,
|
|
114
|
+
mutationKey
|
|
115
|
+
}
|
|
116
|
+
} : {
|
|
117
|
+
mutation: { mutationKey },
|
|
118
|
+
request: void 0
|
|
119
|
+
};
|
|
120
|
+
const mutationFn = (props) => {
|
|
121
|
+
const { requestId, data } = props ?? {};
|
|
122
|
+
return dispatchRequest(requestId, data, requestOptions);
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
mutationFn,
|
|
126
|
+
...mutationOptions
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* @summary Dispatch Request
|
|
131
|
+
*/
|
|
132
|
+
const useDispatchRequest = (options, queryClient) => {
|
|
133
|
+
return useMutation(getDispatchRequestMutationOptions(options), queryClient);
|
|
134
|
+
};
|
|
135
|
+
const getTriageRequestUrl = (requestId) => {
|
|
136
|
+
return `/tutoring/requests/${requestId}/triage`;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Take a request off the queue to look at it.
|
|
140
|
+
*
|
|
141
|
+
* Separate from dispatching because the legacy's own timestamps separate them —
|
|
142
|
+
* ``picked_by_switchman_at`` then ``validated_at`` — and the gap between the
|
|
143
|
+
* two is the figure that tells you whether the queue is staffed.
|
|
144
|
+
* @summary Triage Request
|
|
145
|
+
*/
|
|
146
|
+
const triageRequest = async (requestId, options) => {
|
|
147
|
+
return request(getTriageRequestUrl(requestId), {
|
|
148
|
+
...options,
|
|
149
|
+
method: "POST"
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const getTriageRequestMutationKey = () => ["triageRequest"];
|
|
153
|
+
const getTriageRequestMutationOptions = (options) => {
|
|
154
|
+
const mutationKey = getTriageRequestMutationKey();
|
|
155
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
156
|
+
...options,
|
|
157
|
+
mutation: {
|
|
158
|
+
...options.mutation,
|
|
159
|
+
mutationKey
|
|
160
|
+
}
|
|
161
|
+
} : {
|
|
162
|
+
mutation: { mutationKey },
|
|
163
|
+
request: void 0
|
|
164
|
+
};
|
|
165
|
+
const mutationFn = (props) => {
|
|
166
|
+
const { requestId } = props ?? {};
|
|
167
|
+
return triageRequest(requestId, requestOptions);
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
mutationFn,
|
|
171
|
+
...mutationOptions
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* @summary Triage Request
|
|
176
|
+
*/
|
|
177
|
+
const useTriageRequest = (options, queryClient) => {
|
|
178
|
+
return useMutation(getTriageRequestMutationOptions(options), queryClient);
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
export { dispatchRequest, getDispatchRequestMutationKey, getDispatchRequestMutationOptions, getDispatchRequestUrl, getListQueueQueryKey, getListQueueQueryOptions, getListQueueUrl, getTriageRequestMutationKey, getTriageRequestMutationOptions, getTriageRequestUrl, listQueue, triageRequest, useDispatchRequest, useListQueue, useTriageRequest };
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=tutoring-dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tutoring-dispatch.js","names":[],"sources":["../../src/react/tutoring-dispatch/tutoring-dispatch.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 ListQueueParams,\n TutoringDispatchWrite,\n TutoringQueuePage,\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 getListQueueUrl = (params?: ListQueueParams,) => {\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/queue?${stringifiedParams}` : `/tutoring/queue`\n}\n\n/**\n * What is waiting, oldest first.\n *\n * Scoped to the dispatcher's tenant. Defaults to the four open statuses, which\n * is what the partial index on the table is built for — pass ``?status=`` to\n * look at something else and the query stops using it, which is the honest\n * trade rather than a hidden one.\n * @summary List Queue\n */\nexport const listQueue = async (params?: ListQueueParams, options?: Parameters<typeof request>[1]): Promise<TutoringQueuePage> => {\n\n return request<TutoringQueuePage>(getListQueueUrl(params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getListQueueQueryKey = (params?: ListQueueParams,) => {\n return [\n `/tutoring/queue`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getListQueueQueryOptions = <TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(params?: ListQueueParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getListQueueQueryKey(params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof listQueue>>> = ({ signal }) => listQueue(params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ListQueueQueryResult = NonNullable<Awaited<ReturnType<typeof listQueue>>>\nexport type ListQueueQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params: undefined | ListQueueParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof listQueue>>,\n TError,\n Awaited<ReturnType<typeof listQueue>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListQueueParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof listQueue>>,\n TError,\n Awaited<ReturnType<typeof listQueue>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListQueueParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary List Queue\n */\n\nexport function useListQueue<TData = Awaited<ReturnType<typeof listQueue>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n params?: ListQueueParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listQueue>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getListQueueQueryOptions(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 getDispatchRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/dispatch`\n}\n\n/**\n * Route it — to somebody named, or to the open pool.\n *\n * Changing the channel here is deliberate and common: pupils pick a classroom\n * and turn out to have no microphone, and the dispatcher is the person who\n * finds that out.\n * @summary Dispatch Request\n */\nexport const dispatchRequest = async (requestId: number,\n tutoringDispatchWrite: TutoringDispatchWrite, 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>(getDispatchRequestUrl(requestId),\n {\n ...options,\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(tutoringDispatchWrite)\n }\n);}\n\n\n\n\n\nexport const getDispatchRequestMutationKey = () => ['dispatchRequest'] as const;\n\nexport const getDispatchRequestMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError,DispatchRequestMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError,DispatchRequestMutationVariables, TContext> => {\n\nconst mutationKey = getDispatchRequestMutationKey();\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 dispatchRequest>>, DispatchRequestMutationVariables> = (props) => {\n const {requestId,data} = props ?? {};\n\n return dispatchRequest(requestId,data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type DispatchRequestMutationResult = NonNullable<Awaited<ReturnType<typeof dispatchRequest>>>\n export type DispatchRequestMutationBody = BodyType<TutoringDispatchWrite>\n export type DispatchRequestMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type DispatchRequestMutationVariables = {requestId: number;data: BodyType<TutoringDispatchWrite>}\n\n /**\n * @summary Dispatch Request\n */\nexport const useDispatchRequest = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof dispatchRequest>>, TError,DispatchRequestMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof dispatchRequest>>,\n TError,\n DispatchRequestMutationVariables,\n TContext\n > => {\n return useMutation(getDispatchRequestMutationOptions(options), queryClient);\n }\n export const getTriageRequestUrl = (requestId: number,) => {\n\n\n\n\n return `/tutoring/requests/${requestId}/triage`\n}\n\n/**\n * Take a request off the queue to look at it.\n *\n * Separate from dispatching because the legacy's own timestamps separate them —\n * ``picked_by_switchman_at`` then ``validated_at`` — and the gap between the\n * two is the figure that tells you whether the queue is staffed.\n * @summary Triage Request\n */\nexport const triageRequest = async (requestId: number, options?: Parameters<typeof request>[1]): Promise<void> => {\n\n return request<void>(getTriageRequestUrl(requestId),\n {\n ...options,\n method: 'POST'\n\n\n }\n);}\n\n\n\n\n\nexport const getTriageRequestMutationKey = () => ['triageRequest'] as const;\n\nexport const getTriageRequestMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError,TriageRequestMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError,TriageRequestMutationVariables, TContext> => {\n\nconst mutationKey = getTriageRequestMutationKey();\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 triageRequest>>, TriageRequestMutationVariables> = (props) => {\n const {requestId} = props ?? {};\n\n return triageRequest(requestId,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type TriageRequestMutationResult = NonNullable<Awaited<ReturnType<typeof triageRequest>>>\n\n export type TriageRequestMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type TriageRequestMutationVariables = {requestId: number}\n\n /**\n * @summary Triage Request\n */\nexport const useTriageRequest = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof triageRequest>>, TError,TriageRequestMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof triageRequest>>,\n TError,\n TriageRequestMutationVariables,\n TContext\n > => {\n return useMutation(getTriageRequestMutationOptions(options), queryClient);\n }\n"],"mappings":";;;;;;;;;;;AA0CA,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,mBAAmB,WAA8B;CAC5D,MAAM,mBAAmB,IAAI,gBAAgB;CAE7C,OAAO,QAAQ,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;EAGrD,IAAI,MAAM,QAAQ,KAAK,KAAK,CAFD,QAEiB,CAAC,CAAC,SAAS,GAAG,GAAG;GAC3D,MAAM,SAAS,MAAM;IACnB,iBAAiB,OAAO,KAAK,MAAM,OAAO,SAAS,OAAO,CAAC,CAAC;GAC9D,CAAC;GACD;EACF;EAEA,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,mBAAmB,sBAAsB;AACjF;;;;;;;;;;AAWA,MAAa,YAAY,OAAO,QAA0B,YAAwE;CAEhI,OAAO,QAA2B,gBAAgB,MAAM,GACxD;EACE,GAAG;EACH,QAAQ;CAGV,C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