@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,254 @@
|
|
|
1
|
+
|
|
2
|
+
import { G as ReviewUpdateWrite, Gn as HTTPExceptionResponse, K as ReviewRead, M as SupplierGrantRead, Un as LastPositionWrite, ft as RatingUpdateWrite, hr as DocumentRead, mr as DocumentSearchWrite, t as ValidationErrorResponse, vr as DocumentPage } from "../index-wL_20vR8.js";
|
|
3
|
+
import { a as ErrorType, c as request, n as BodyType } from "../client-BDwBZYB0.js";
|
|
4
|
+
import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
5
|
+
//#region src/react/cvs-documents/cvs-documents.d.ts
|
|
6
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
7
|
+
export declare const getSearchDocumentsUrl: () => string;
|
|
8
|
+
/**
|
|
9
|
+
* Search the CVS catalogue.
|
|
10
|
+
*
|
|
11
|
+
* ``POST`` because the legacy put the query in the body and the mobile clients
|
|
12
|
+
* send it that way. It is a read, so it stays safe: nothing here writes.
|
|
13
|
+
*
|
|
14
|
+
* Same division as ``/search``: the index ranks, PostgreSQL authorises. An
|
|
15
|
+
* index outage degrades to no results rather than to an unfiltered catalogue.
|
|
16
|
+
* @summary Search Documents
|
|
17
|
+
*/
|
|
18
|
+
export declare const searchDocuments: (documentSearchWrite: DocumentSearchWrite, options?: Parameters<typeof request>[1]) => Promise<DocumentPage>;
|
|
19
|
+
export declare const getSearchDocumentsMutationKey: () => readonly ['searchDocuments'];
|
|
20
|
+
export declare const getSearchDocumentsMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
21
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof searchDocuments>>, TError, SearchDocumentsMutationVariables, TContext>;
|
|
22
|
+
request?: SecondParameter<typeof request>;
|
|
23
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof searchDocuments>>, TError, SearchDocumentsMutationVariables, TContext>;
|
|
24
|
+
export type SearchDocumentsMutationResult = NonNullable<Awaited<ReturnType<typeof searchDocuments>>>;
|
|
25
|
+
export type SearchDocumentsMutationBody = BodyType<DocumentSearchWrite>;
|
|
26
|
+
export type SearchDocumentsMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
27
|
+
export type SearchDocumentsMutationVariables = {
|
|
28
|
+
data: BodyType<DocumentSearchWrite>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @summary Search Documents
|
|
32
|
+
*/
|
|
33
|
+
export declare const useSearchDocuments: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
34
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof searchDocuments>>, TError, SearchDocumentsMutationVariables, TContext>;
|
|
35
|
+
request?: SecondParameter<typeof request>;
|
|
36
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof searchDocuments>>, TError, SearchDocumentsMutationVariables, TContext>;
|
|
37
|
+
export declare const getReadDocumentUrl: (docId: number) => string;
|
|
38
|
+
/**
|
|
39
|
+
* One work, if this caller's contract reaches it.
|
|
40
|
+
*
|
|
41
|
+
* Missing until now, which was an oversight rather than a decision: search,
|
|
42
|
+
* rating, review and position all existed and there was no way to fetch the
|
|
43
|
+
* thing they act on. The legacy has no equivalent either — the app assembles a
|
|
44
|
+
* document sheet from whatever the menu endpoint already returned, which is why
|
|
45
|
+
* a deep link into a title has never worked properly.
|
|
46
|
+
* @summary Read Document
|
|
47
|
+
*/
|
|
48
|
+
export declare const readDocument: (docId: number, options?: Parameters<typeof request>[1]) => Promise<DocumentRead>;
|
|
49
|
+
export declare const getReadDocumentQueryKey: (docId: number) => readonly [`/cvs/documents/${number}`];
|
|
50
|
+
export declare const getReadDocumentQueryOptions: <TData = Awaited<ReturnType<typeof readDocument>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
51
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readDocument>>, TError, TData>>;
|
|
52
|
+
request?: SecondParameter<typeof request>;
|
|
53
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof readDocument>>, TError, TData> & {
|
|
54
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
55
|
+
};
|
|
56
|
+
export type ReadDocumentQueryResult = NonNullable<Awaited<ReturnType<typeof readDocument>>>;
|
|
57
|
+
export type ReadDocumentQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
58
|
+
export declare function useReadDocument<TData = Awaited<ReturnType<typeof readDocument>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options: {
|
|
59
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof readDocument>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof readDocument>>, TError, Awaited<ReturnType<typeof readDocument>>>, 'initialData'>;
|
|
60
|
+
request?: SecondParameter<typeof request>;
|
|
61
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
62
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
63
|
+
};
|
|
64
|
+
export declare function useReadDocument<TData = Awaited<ReturnType<typeof readDocument>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
65
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readDocument>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof readDocument>>, TError, Awaited<ReturnType<typeof readDocument>>>, 'initialData'>;
|
|
66
|
+
request?: SecondParameter<typeof request>;
|
|
67
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
68
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
69
|
+
};
|
|
70
|
+
export declare function useReadDocument<TData = Awaited<ReturnType<typeof readDocument>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
71
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readDocument>>, TError, TData>>;
|
|
72
|
+
request?: SecondParameter<typeof request>;
|
|
73
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
74
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
75
|
+
};
|
|
76
|
+
export declare const getOpenAtSupplierUrl: (docId: number) => string;
|
|
77
|
+
/**
|
|
78
|
+
* Authorise this patron to open one title at the supplier hosting it.
|
|
79
|
+
*
|
|
80
|
+
* Replaces the legacy ``wstoken``: 4,878 lines dispatching on
|
|
81
|
+
* ``frn.plate_forme`` through 57 near-identical arms. The signing schemes
|
|
82
|
+
* reduce to eight (:class:`~app.models.enums.TokenFormula`) and the platform
|
|
83
|
+
* map to a table, so what is left here is the order of operations.
|
|
84
|
+
*
|
|
85
|
+
* **Entitle, seat, then sign** — the same order the streaming route uses, and
|
|
86
|
+
* for the same reason. A signature is cheap to produce and impossible to
|
|
87
|
+
* recall once it has left; a seat can be released. Signing first would mean a
|
|
88
|
+
* refused request had already handed a patron something that works.
|
|
89
|
+
*
|
|
90
|
+
* ``404`` when the caller is not entitled or the title does not exist — the
|
|
91
|
+
* two are deliberately indistinguishable, as everywhere else in this API.
|
|
92
|
+
* ``409`` when every seat is taken: the caller *is* entitled and should be
|
|
93
|
+
* offered "try later", not "buy a subscription". ``409`` too when the supplier
|
|
94
|
+
* sits on a platform nobody implemented — four do, and the legacy cannot serve
|
|
95
|
+
* them either, so the honest answer is that this title is not openable rather
|
|
96
|
+
* than a 500 from a missing branch.
|
|
97
|
+
*
|
|
98
|
+
* The returned token is for the *supplier*, not for us. See
|
|
99
|
+
* :class:`~app.datamodels.cvs.downloads.SupplierGrantRead`.
|
|
100
|
+
* @summary Open At Supplier
|
|
101
|
+
*/
|
|
102
|
+
export declare const openAtSupplier: (docId: number, options?: Parameters<typeof request>[1]) => Promise<SupplierGrantRead>;
|
|
103
|
+
export declare const getOpenAtSupplierMutationKey: () => readonly ['openAtSupplier'];
|
|
104
|
+
export declare const getOpenAtSupplierMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
105
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openAtSupplier>>, TError, OpenAtSupplierMutationVariables, TContext>;
|
|
106
|
+
request?: SecondParameter<typeof request>;
|
|
107
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof openAtSupplier>>, TError, OpenAtSupplierMutationVariables, TContext>;
|
|
108
|
+
export type OpenAtSupplierMutationResult = NonNullable<Awaited<ReturnType<typeof openAtSupplier>>>;
|
|
109
|
+
export type OpenAtSupplierMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
110
|
+
export type OpenAtSupplierMutationVariables = {
|
|
111
|
+
docId: number;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* @summary Open At Supplier
|
|
115
|
+
*/
|
|
116
|
+
export declare const useOpenAtSupplier: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
117
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openAtSupplier>>, TError, OpenAtSupplierMutationVariables, TContext>;
|
|
118
|
+
request?: SecondParameter<typeof request>;
|
|
119
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof openAtSupplier>>, TError, OpenAtSupplierMutationVariables, TContext>;
|
|
120
|
+
export declare const getReadLastPositionUrl: (docId: number) => string;
|
|
121
|
+
/**
|
|
122
|
+
* Where this patron got to, or ``0`` if they have not started.
|
|
123
|
+
*
|
|
124
|
+
* New: the legacy has no way to read the position back, so a client that lost
|
|
125
|
+
* its local state could never resume. Absent means not started, which is why
|
|
126
|
+
* the row is not created on read.
|
|
127
|
+
* @summary Read Last Position
|
|
128
|
+
*/
|
|
129
|
+
export declare const readLastPosition: (docId: number, options?: Parameters<typeof request>[1]) => Promise<LastPositionWrite>;
|
|
130
|
+
export declare const getReadLastPositionQueryKey: (docId: number) => readonly [`/cvs/documents/${number}/position`];
|
|
131
|
+
export declare const getReadLastPositionQueryOptions: <TData = Awaited<ReturnType<typeof readLastPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
132
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, TData>>;
|
|
133
|
+
request?: SecondParameter<typeof request>;
|
|
134
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, TData> & {
|
|
135
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
136
|
+
};
|
|
137
|
+
export type ReadLastPositionQueryResult = NonNullable<Awaited<ReturnType<typeof readLastPosition>>>;
|
|
138
|
+
export type ReadLastPositionQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
139
|
+
export declare function useReadLastPosition<TData = Awaited<ReturnType<typeof readLastPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options: {
|
|
140
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, Awaited<ReturnType<typeof readLastPosition>>>, 'initialData'>;
|
|
141
|
+
request?: SecondParameter<typeof request>;
|
|
142
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
143
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
144
|
+
};
|
|
145
|
+
export declare function useReadLastPosition<TData = Awaited<ReturnType<typeof readLastPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
146
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, Awaited<ReturnType<typeof readLastPosition>>>, 'initialData'>;
|
|
147
|
+
request?: SecondParameter<typeof request>;
|
|
148
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
149
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
150
|
+
};
|
|
151
|
+
export declare function useReadLastPosition<TData = Awaited<ReturnType<typeof readLastPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(docId: number, options?: {
|
|
152
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readLastPosition>>, TError, TData>>;
|
|
153
|
+
request?: SecondParameter<typeof request>;
|
|
154
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
155
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
156
|
+
};
|
|
157
|
+
export declare const getSetLastPositionUrl: (docId: number) => string;
|
|
158
|
+
/**
|
|
159
|
+
* Record where this patron got to.
|
|
160
|
+
*
|
|
161
|
+
* A write, and the legacy declares it ``GET`` with the position in the query
|
|
162
|
+
* string — which makes resuming a book a cacheable idempotent read that mutates
|
|
163
|
+
* state, and puts it outside the CSRF layer for free.
|
|
164
|
+
*
|
|
165
|
+
* Stored in :class:`~app.models.activity.ReadingPosition`, which the products
|
|
166
|
+
* share — CVS and the partner reader today — so a member who reads across them
|
|
167
|
+
* keeps their place in one shape.
|
|
168
|
+
* @summary Set Last Position
|
|
169
|
+
*/
|
|
170
|
+
export declare const setLastPosition: (docId: number, lastPositionWrite: LastPositionWrite, options?: Parameters<typeof request>[1]) => Promise<void>;
|
|
171
|
+
export declare const getSetLastPositionMutationKey: () => readonly ['setLastPosition'];
|
|
172
|
+
export declare const getSetLastPositionMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
173
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof setLastPosition>>, TError, SetLastPositionMutationVariables, TContext>;
|
|
174
|
+
request?: SecondParameter<typeof request>;
|
|
175
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof setLastPosition>>, TError, SetLastPositionMutationVariables, TContext>;
|
|
176
|
+
export type SetLastPositionMutationResult = NonNullable<Awaited<ReturnType<typeof setLastPosition>>>;
|
|
177
|
+
export type SetLastPositionMutationBody = BodyType<LastPositionWrite>;
|
|
178
|
+
export type SetLastPositionMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
179
|
+
export type SetLastPositionMutationVariables = {
|
|
180
|
+
docId: number;
|
|
181
|
+
data: BodyType<LastPositionWrite>;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* @summary Set Last Position
|
|
185
|
+
*/
|
|
186
|
+
export declare const useSetLastPosition: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
187
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof setLastPosition>>, TError, SetLastPositionMutationVariables, TContext>;
|
|
188
|
+
request?: SecondParameter<typeof request>;
|
|
189
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof setLastPosition>>, TError, SetLastPositionMutationVariables, TContext>;
|
|
190
|
+
export declare const getRateDocumentUrl: (docId: number) => string;
|
|
191
|
+
/**
|
|
192
|
+
* Rate a document. Idempotent — rating again replaces the earlier score.
|
|
193
|
+
*
|
|
194
|
+
* ``PUT`` on the rating sub-resource rather than the legacy
|
|
195
|
+
* ``POST /document/rating/update`` with the id in the body: the identifier
|
|
196
|
+
* belongs in the path, and "update" in a path names an operation in a position
|
|
197
|
+
* reserved for a resource.
|
|
198
|
+
* @summary Rate Document
|
|
199
|
+
*/
|
|
200
|
+
export declare const rateDocument: (docId: number, ratingUpdateWrite: RatingUpdateWrite, options?: Parameters<typeof request>[1]) => Promise<void>;
|
|
201
|
+
export declare const getRateDocumentMutationKey: () => readonly ['rateDocument'];
|
|
202
|
+
export declare const getRateDocumentMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
203
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof rateDocument>>, TError, RateDocumentMutationVariables, TContext>;
|
|
204
|
+
request?: SecondParameter<typeof request>;
|
|
205
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof rateDocument>>, TError, RateDocumentMutationVariables, TContext>;
|
|
206
|
+
export type RateDocumentMutationResult = NonNullable<Awaited<ReturnType<typeof rateDocument>>>;
|
|
207
|
+
export type RateDocumentMutationBody = BodyType<RatingUpdateWrite>;
|
|
208
|
+
export type RateDocumentMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
209
|
+
export type RateDocumentMutationVariables = {
|
|
210
|
+
docId: number;
|
|
211
|
+
data: BodyType<RatingUpdateWrite>;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* @summary Rate Document
|
|
215
|
+
*/
|
|
216
|
+
export declare const useRateDocument: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
217
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof rateDocument>>, TError, RateDocumentMutationVariables, TContext>;
|
|
218
|
+
request?: SecondParameter<typeof request>;
|
|
219
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof rateDocument>>, TError, RateDocumentMutationVariables, TContext>;
|
|
220
|
+
export declare const getWriteReviewUrl: (docId: number) => string;
|
|
221
|
+
/**
|
|
222
|
+
* Write or replace this patron's review of a document.
|
|
223
|
+
*
|
|
224
|
+
* One review per person per document, so this is a ``PUT`` on a singular
|
|
225
|
+
* sub-resource rather than a ``POST`` to a collection. The legacy had two routes
|
|
226
|
+
* — with and without an ``avisId`` — for what is one row.
|
|
227
|
+
*
|
|
228
|
+
* Every write resets the review to unpublished. An edit after moderation is a
|
|
229
|
+
* new thing to moderate, and carrying the old approval forward is how an
|
|
230
|
+
* approved review becomes a different text.
|
|
231
|
+
* @summary Write Review
|
|
232
|
+
*/
|
|
233
|
+
export declare const writeReview: (docId: number, reviewUpdateWrite: ReviewUpdateWrite, options?: Parameters<typeof request>[1]) => Promise<ReviewRead>;
|
|
234
|
+
export declare const getWriteReviewMutationKey: () => readonly ['writeReview'];
|
|
235
|
+
export declare const getWriteReviewMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
236
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof writeReview>>, TError, WriteReviewMutationVariables, TContext>;
|
|
237
|
+
request?: SecondParameter<typeof request>;
|
|
238
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof writeReview>>, TError, WriteReviewMutationVariables, TContext>;
|
|
239
|
+
export type WriteReviewMutationResult = NonNullable<Awaited<ReturnType<typeof writeReview>>>;
|
|
240
|
+
export type WriteReviewMutationBody = BodyType<ReviewUpdateWrite>;
|
|
241
|
+
export type WriteReviewMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
242
|
+
export type WriteReviewMutationVariables = {
|
|
243
|
+
docId: number;
|
|
244
|
+
data: BodyType<ReviewUpdateWrite>;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* @summary Write Review
|
|
248
|
+
*/
|
|
249
|
+
export declare const useWriteReview: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
250
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof writeReview>>, TError, WriteReviewMutationVariables, TContext>;
|
|
251
|
+
request?: SecondParameter<typeof request>;
|
|
252
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof writeReview>>, TError, WriteReviewMutationVariables, TContext>;
|
|
253
|
+
//#endregion
|
|
254
|
+
//# sourceMappingURL=cvs-documents.d.ts.map
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../client-D3kMOcIr.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/cvs-documents/cvs-documents.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 getSearchDocumentsUrl = () => {
|
|
25
|
+
return `/cvs/documents/search`;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Search the CVS catalogue.
|
|
29
|
+
*
|
|
30
|
+
* ``POST`` because the legacy put the query in the body and the mobile clients
|
|
31
|
+
* send it that way. It is a read, so it stays safe: nothing here writes.
|
|
32
|
+
*
|
|
33
|
+
* Same division as ``/search``: the index ranks, PostgreSQL authorises. An
|
|
34
|
+
* index outage degrades to no results rather than to an unfiltered catalogue.
|
|
35
|
+
* @summary Search Documents
|
|
36
|
+
*/
|
|
37
|
+
const searchDocuments = async (documentSearchWrite, options) => {
|
|
38
|
+
const getHeaders = (h) => {
|
|
39
|
+
if (!h) return {};
|
|
40
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
41
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
42
|
+
const headers = {};
|
|
43
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
44
|
+
return headers;
|
|
45
|
+
};
|
|
46
|
+
return request(getSearchDocumentsUrl(), {
|
|
47
|
+
...options,
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
...getHeaders(options?.headers)
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify(documentSearchWrite)
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
const getSearchDocumentsMutationKey = () => ["searchDocuments"];
|
|
57
|
+
const getSearchDocumentsMutationOptions = (options) => {
|
|
58
|
+
const mutationKey = getSearchDocumentsMutationKey();
|
|
59
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
60
|
+
...options,
|
|
61
|
+
mutation: {
|
|
62
|
+
...options.mutation,
|
|
63
|
+
mutationKey
|
|
64
|
+
}
|
|
65
|
+
} : {
|
|
66
|
+
mutation: { mutationKey },
|
|
67
|
+
request: void 0
|
|
68
|
+
};
|
|
69
|
+
const mutationFn = (props) => {
|
|
70
|
+
const { data } = props ?? {};
|
|
71
|
+
return searchDocuments(data, requestOptions);
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
mutationFn,
|
|
75
|
+
...mutationOptions
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* @summary Search Documents
|
|
80
|
+
*/
|
|
81
|
+
const useSearchDocuments = (options, queryClient) => {
|
|
82
|
+
return useMutation(getSearchDocumentsMutationOptions(options), queryClient);
|
|
83
|
+
};
|
|
84
|
+
const getReadDocumentUrl = (docId) => {
|
|
85
|
+
return `/cvs/documents/${docId}`;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* One work, if this caller's contract reaches it.
|
|
89
|
+
*
|
|
90
|
+
* Missing until now, which was an oversight rather than a decision: search,
|
|
91
|
+
* rating, review and position all existed and there was no way to fetch the
|
|
92
|
+
* thing they act on. The legacy has no equivalent either — the app assembles a
|
|
93
|
+
* document sheet from whatever the menu endpoint already returned, which is why
|
|
94
|
+
* a deep link into a title has never worked properly.
|
|
95
|
+
* @summary Read Document
|
|
96
|
+
*/
|
|
97
|
+
const readDocument = async (docId, options) => {
|
|
98
|
+
return request(getReadDocumentUrl(docId), {
|
|
99
|
+
...options,
|
|
100
|
+
method: "GET"
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const getReadDocumentQueryKey = (docId) => {
|
|
104
|
+
return [`/cvs/documents/${docId}`];
|
|
105
|
+
};
|
|
106
|
+
const getReadDocumentQueryOptions = (docId, options) => {
|
|
107
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
108
|
+
const queryKey = queryOptions?.queryKey ?? getReadDocumentQueryKey(docId);
|
|
109
|
+
const queryFn = ({ signal }) => readDocument(docId, {
|
|
110
|
+
signal,
|
|
111
|
+
...requestOptions
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
queryKey,
|
|
115
|
+
queryFn,
|
|
116
|
+
enabled: docId !== null && docId !== void 0,
|
|
117
|
+
...queryOptions
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* @summary Read Document
|
|
122
|
+
*/
|
|
123
|
+
function useReadDocument(docId, options, queryClient) {
|
|
124
|
+
const queryOptions = getReadDocumentQueryOptions(docId, options);
|
|
125
|
+
const query = useQuery(queryOptions, queryClient);
|
|
126
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
127
|
+
}
|
|
128
|
+
const getOpenAtSupplierUrl = (docId) => {
|
|
129
|
+
return `/cvs/documents/${docId}/grant`;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Authorise this patron to open one title at the supplier hosting it.
|
|
133
|
+
*
|
|
134
|
+
* Replaces the legacy ``wstoken``: 4,878 lines dispatching on
|
|
135
|
+
* ``frn.plate_forme`` through 57 near-identical arms. The signing schemes
|
|
136
|
+
* reduce to eight (:class:`~app.models.enums.TokenFormula`) and the platform
|
|
137
|
+
* map to a table, so what is left here is the order of operations.
|
|
138
|
+
*
|
|
139
|
+
* **Entitle, seat, then sign** — the same order the streaming route uses, and
|
|
140
|
+
* for the same reason. A signature is cheap to produce and impossible to
|
|
141
|
+
* recall once it has left; a seat can be released. Signing first would mean a
|
|
142
|
+
* refused request had already handed a patron something that works.
|
|
143
|
+
*
|
|
144
|
+
* ``404`` when the caller is not entitled or the title does not exist — the
|
|
145
|
+
* two are deliberately indistinguishable, as everywhere else in this API.
|
|
146
|
+
* ``409`` when every seat is taken: the caller *is* entitled and should be
|
|
147
|
+
* offered "try later", not "buy a subscription". ``409`` too when the supplier
|
|
148
|
+
* sits on a platform nobody implemented — four do, and the legacy cannot serve
|
|
149
|
+
* them either, so the honest answer is that this title is not openable rather
|
|
150
|
+
* than a 500 from a missing branch.
|
|
151
|
+
*
|
|
152
|
+
* The returned token is for the *supplier*, not for us. See
|
|
153
|
+
* :class:`~app.datamodels.cvs.downloads.SupplierGrantRead`.
|
|
154
|
+
* @summary Open At Supplier
|
|
155
|
+
*/
|
|
156
|
+
const openAtSupplier = async (docId, options) => {
|
|
157
|
+
return request(getOpenAtSupplierUrl(docId), {
|
|
158
|
+
...options,
|
|
159
|
+
method: "POST"
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const getOpenAtSupplierMutationKey = () => ["openAtSupplier"];
|
|
163
|
+
const getOpenAtSupplierMutationOptions = (options) => {
|
|
164
|
+
const mutationKey = getOpenAtSupplierMutationKey();
|
|
165
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
166
|
+
...options,
|
|
167
|
+
mutation: {
|
|
168
|
+
...options.mutation,
|
|
169
|
+
mutationKey
|
|
170
|
+
}
|
|
171
|
+
} : {
|
|
172
|
+
mutation: { mutationKey },
|
|
173
|
+
request: void 0
|
|
174
|
+
};
|
|
175
|
+
const mutationFn = (props) => {
|
|
176
|
+
const { docId } = props ?? {};
|
|
177
|
+
return openAtSupplier(docId, requestOptions);
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
mutationFn,
|
|
181
|
+
...mutationOptions
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* @summary Open At Supplier
|
|
186
|
+
*/
|
|
187
|
+
const useOpenAtSupplier = (options, queryClient) => {
|
|
188
|
+
return useMutation(getOpenAtSupplierMutationOptions(options), queryClient);
|
|
189
|
+
};
|
|
190
|
+
const getReadLastPositionUrl = (docId) => {
|
|
191
|
+
return `/cvs/documents/${docId}/position`;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Where this patron got to, or ``0`` if they have not started.
|
|
195
|
+
*
|
|
196
|
+
* New: the legacy has no way to read the position back, so a client that lost
|
|
197
|
+
* its local state could never resume. Absent means not started, which is why
|
|
198
|
+
* the row is not created on read.
|
|
199
|
+
* @summary Read Last Position
|
|
200
|
+
*/
|
|
201
|
+
const readLastPosition = async (docId, options) => {
|
|
202
|
+
return request(getReadLastPositionUrl(docId), {
|
|
203
|
+
...options,
|
|
204
|
+
method: "GET"
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const getReadLastPositionQueryKey = (docId) => {
|
|
208
|
+
return [`/cvs/documents/${docId}/position`];
|
|
209
|
+
};
|
|
210
|
+
const getReadLastPositionQueryOptions = (docId, options) => {
|
|
211
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
212
|
+
const queryKey = queryOptions?.queryKey ?? getReadLastPositionQueryKey(docId);
|
|
213
|
+
const queryFn = ({ signal }) => readLastPosition(docId, {
|
|
214
|
+
signal,
|
|
215
|
+
...requestOptions
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
queryKey,
|
|
219
|
+
queryFn,
|
|
220
|
+
enabled: docId !== null && docId !== void 0,
|
|
221
|
+
...queryOptions
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* @summary Read Last Position
|
|
226
|
+
*/
|
|
227
|
+
function useReadLastPosition(docId, options, queryClient) {
|
|
228
|
+
const queryOptions = getReadLastPositionQueryOptions(docId, options);
|
|
229
|
+
const query = useQuery(queryOptions, queryClient);
|
|
230
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
231
|
+
}
|
|
232
|
+
const getSetLastPositionUrl = (docId) => {
|
|
233
|
+
return `/cvs/documents/${docId}/position`;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Record where this patron got to.
|
|
237
|
+
*
|
|
238
|
+
* A write, and the legacy declares it ``GET`` with the position in the query
|
|
239
|
+
* string — which makes resuming a book a cacheable idempotent read that mutates
|
|
240
|
+
* state, and puts it outside the CSRF layer for free.
|
|
241
|
+
*
|
|
242
|
+
* Stored in :class:`~app.models.activity.ReadingPosition`, which the products
|
|
243
|
+
* share — CVS and the partner reader today — so a member who reads across them
|
|
244
|
+
* keeps their place in one shape.
|
|
245
|
+
* @summary Set Last Position
|
|
246
|
+
*/
|
|
247
|
+
const setLastPosition = async (docId, lastPositionWrite, options) => {
|
|
248
|
+
const getHeaders = (h) => {
|
|
249
|
+
if (!h) return {};
|
|
250
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
251
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
252
|
+
const headers = {};
|
|
253
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
254
|
+
return headers;
|
|
255
|
+
};
|
|
256
|
+
return request(getSetLastPositionUrl(docId), {
|
|
257
|
+
...options,
|
|
258
|
+
method: "PUT",
|
|
259
|
+
headers: {
|
|
260
|
+
"Content-Type": "application/json",
|
|
261
|
+
...getHeaders(options?.headers)
|
|
262
|
+
},
|
|
263
|
+
body: JSON.stringify(lastPositionWrite)
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
const getSetLastPositionMutationKey = () => ["setLastPosition"];
|
|
267
|
+
const getSetLastPositionMutationOptions = (options) => {
|
|
268
|
+
const mutationKey = getSetLastPositionMutationKey();
|
|
269
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
270
|
+
...options,
|
|
271
|
+
mutation: {
|
|
272
|
+
...options.mutation,
|
|
273
|
+
mutationKey
|
|
274
|
+
}
|
|
275
|
+
} : {
|
|
276
|
+
mutation: { mutationKey },
|
|
277
|
+
request: void 0
|
|
278
|
+
};
|
|
279
|
+
const mutationFn = (props) => {
|
|
280
|
+
const { docId, data } = props ?? {};
|
|
281
|
+
return setLastPosition(docId, data, requestOptions);
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
mutationFn,
|
|
285
|
+
...mutationOptions
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* @summary Set Last Position
|
|
290
|
+
*/
|
|
291
|
+
const useSetLastPosition = (options, queryClient) => {
|
|
292
|
+
return useMutation(getSetLastPositionMutationOptions(options), queryClient);
|
|
293
|
+
};
|
|
294
|
+
const getRateDocumentUrl = (docId) => {
|
|
295
|
+
return `/cvs/documents/${docId}/rating`;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Rate a document. Idempotent — rating again replaces the earlier score.
|
|
299
|
+
*
|
|
300
|
+
* ``PUT`` on the rating sub-resource rather than the legacy
|
|
301
|
+
* ``POST /document/rating/update`` with the id in the body: the identifier
|
|
302
|
+
* belongs in the path, and "update" in a path names an operation in a position
|
|
303
|
+
* reserved for a resource.
|
|
304
|
+
* @summary Rate Document
|
|
305
|
+
*/
|
|
306
|
+
const rateDocument = async (docId, ratingUpdateWrite, options) => {
|
|
307
|
+
const getHeaders = (h) => {
|
|
308
|
+
if (!h) return {};
|
|
309
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
310
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
311
|
+
const headers = {};
|
|
312
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
313
|
+
return headers;
|
|
314
|
+
};
|
|
315
|
+
return request(getRateDocumentUrl(docId), {
|
|
316
|
+
...options,
|
|
317
|
+
method: "PUT",
|
|
318
|
+
headers: {
|
|
319
|
+
"Content-Type": "application/json",
|
|
320
|
+
...getHeaders(options?.headers)
|
|
321
|
+
},
|
|
322
|
+
body: JSON.stringify(ratingUpdateWrite)
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
const getRateDocumentMutationKey = () => ["rateDocument"];
|
|
326
|
+
const getRateDocumentMutationOptions = (options) => {
|
|
327
|
+
const mutationKey = getRateDocumentMutationKey();
|
|
328
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
329
|
+
...options,
|
|
330
|
+
mutation: {
|
|
331
|
+
...options.mutation,
|
|
332
|
+
mutationKey
|
|
333
|
+
}
|
|
334
|
+
} : {
|
|
335
|
+
mutation: { mutationKey },
|
|
336
|
+
request: void 0
|
|
337
|
+
};
|
|
338
|
+
const mutationFn = (props) => {
|
|
339
|
+
const { docId, data } = props ?? {};
|
|
340
|
+
return rateDocument(docId, data, requestOptions);
|
|
341
|
+
};
|
|
342
|
+
return {
|
|
343
|
+
mutationFn,
|
|
344
|
+
...mutationOptions
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* @summary Rate Document
|
|
349
|
+
*/
|
|
350
|
+
const useRateDocument = (options, queryClient) => {
|
|
351
|
+
return useMutation(getRateDocumentMutationOptions(options), queryClient);
|
|
352
|
+
};
|
|
353
|
+
const getWriteReviewUrl = (docId) => {
|
|
354
|
+
return `/cvs/documents/${docId}/review`;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Write or replace this patron's review of a document.
|
|
358
|
+
*
|
|
359
|
+
* One review per person per document, so this is a ``PUT`` on a singular
|
|
360
|
+
* sub-resource rather than a ``POST`` to a collection. The legacy had two routes
|
|
361
|
+
* — with and without an ``avisId`` — for what is one row.
|
|
362
|
+
*
|
|
363
|
+
* Every write resets the review to unpublished. An edit after moderation is a
|
|
364
|
+
* new thing to moderate, and carrying the old approval forward is how an
|
|
365
|
+
* approved review becomes a different text.
|
|
366
|
+
* @summary Write Review
|
|
367
|
+
*/
|
|
368
|
+
const writeReview = async (docId, reviewUpdateWrite, options) => {
|
|
369
|
+
const getHeaders = (h) => {
|
|
370
|
+
if (!h) return {};
|
|
371
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
372
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
373
|
+
const headers = {};
|
|
374
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
375
|
+
return headers;
|
|
376
|
+
};
|
|
377
|
+
return request(getWriteReviewUrl(docId), {
|
|
378
|
+
...options,
|
|
379
|
+
method: "PUT",
|
|
380
|
+
headers: {
|
|
381
|
+
"Content-Type": "application/json",
|
|
382
|
+
...getHeaders(options?.headers)
|
|
383
|
+
},
|
|
384
|
+
body: JSON.stringify(reviewUpdateWrite)
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
const getWriteReviewMutationKey = () => ["writeReview"];
|
|
388
|
+
const getWriteReviewMutationOptions = (options) => {
|
|
389
|
+
const mutationKey = getWriteReviewMutationKey();
|
|
390
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
391
|
+
...options,
|
|
392
|
+
mutation: {
|
|
393
|
+
...options.mutation,
|
|
394
|
+
mutationKey
|
|
395
|
+
}
|
|
396
|
+
} : {
|
|
397
|
+
mutation: { mutationKey },
|
|
398
|
+
request: void 0
|
|
399
|
+
};
|
|
400
|
+
const mutationFn = (props) => {
|
|
401
|
+
const { docId, data } = props ?? {};
|
|
402
|
+
return writeReview(docId, data, requestOptions);
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
mutationFn,
|
|
406
|
+
...mutationOptions
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* @summary Write Review
|
|
411
|
+
*/
|
|
412
|
+
const useWriteReview = (options, queryClient) => {
|
|
413
|
+
return useMutation(getWriteReviewMutationOptions(options), queryClient);
|
|
414
|
+
};
|
|
415
|
+
//#endregion
|
|
416
|
+
export { getOpenAtSupplierMutationKey, getOpenAtSupplierMutationOptions, getOpenAtSupplierUrl, getRateDocumentMutationKey, getRateDocumentMutationOptions, getRateDocumentUrl, getReadDocumentQueryKey, getReadDocumentQueryOptions, getReadDocumentUrl, getReadLastPositionQueryKey, getReadLastPositionQueryOptions, getReadLastPositionUrl, getSearchDocumentsMutationKey, getSearchDocumentsMutationOptions, getSearchDocumentsUrl, getSetLastPositionMutationKey, getSetLastPositionMutationOptions, getSetLastPositionUrl, getWriteReviewMutationKey, getWriteReviewMutationOptions, getWriteReviewUrl, openAtSupplier, rateDocument, readDocument, readLastPosition, searchDocuments, setLastPosition, useOpenAtSupplier, useRateDocument, useReadDocument, useReadLastPosition, useSearchDocuments, useSetLastPosition, useWriteReview, writeReview };
|
|
417
|
+
|
|
418
|
+
//# sourceMappingURL=cvs-documents.js.map
|