@learnorama/mozaik-sdk 0.14.2-staging.52.1 → 0.15.0-staging.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -11
- package/dist/api/account.d.ts +1 -1
- package/dist/api/account.js.map +1 -1
- package/dist/api/admin-catalogue.d.ts +1 -1
- package/dist/api/admin-catalogue.js.map +1 -1
- package/dist/api/admin-consumption.d.ts +1 -1
- package/dist/api/admin-consumption.js.map +1 -1
- package/dist/api/admin-contracts.d.ts +1 -1
- package/dist/api/admin-contracts.js.map +1 -1
- package/dist/api/admin-customer.d.ts +1 -1
- package/dist/api/admin-customer.js.map +1 -1
- package/dist/api/admin-desk.d.ts +1 -1
- package/dist/api/admin-desk.js.map +1 -1
- package/dist/api/admin-licenses.js.map +1 -1
- package/dist/api/admin-partner-selections.d.ts +1 -1
- package/dist/api/admin-partner-selections.js.map +1 -1
- package/dist/api/admin-patrons.d.ts +1 -1
- package/dist/api/admin-patrons.js.map +1 -1
- package/dist/api/admin-reviews.d.ts +1 -1
- package/dist/api/admin-reviews.js.map +1 -1
- package/dist/api/admin-roles.d.ts +1 -1
- package/dist/api/admin-roles.js.map +1 -1
- package/dist/api/admin-support.d.ts +1 -1
- package/dist/api/admin-support.js.map +1 -1
- package/dist/api/admin-tenants.js.map +1 -1
- package/dist/api/admin-tutoring.d.ts +1 -1
- package/dist/api/admin-tutoring.js.map +1 -1
- package/dist/api/auth-device.d.ts +1 -1
- package/dist/api/auth-device.js.map +1 -1
- package/dist/api/auth.d.ts +1 -1
- package/dist/api/auth.js.map +1 -1
- package/dist/api/biblio-billing-webhooks.d.ts +1 -1
- package/dist/api/biblio-billing-webhooks.js.map +1 -1
- package/dist/api/biblio-billing.d.ts +1 -1
- package/dist/api/biblio-billing.js.map +1 -1
- package/dist/api/biblio-catalogue.d.ts +1 -1
- package/dist/api/biblio-catalogue.js.map +1 -1
- package/dist/api/biblio-home.d.ts +1 -1
- package/dist/api/biblio-home.js.map +1 -1
- package/dist/api/biblio-learning-author-profiles.d.ts +1 -1
- package/dist/api/biblio-learning-author-profiles.js.map +1 -1
- package/dist/api/biblio-learning-authoring.d.ts +1 -1
- package/dist/api/biblio-learning-authoring.js.map +1 -1
- package/dist/api/biblio-learning-editorial.d.ts +1 -1
- package/dist/api/biblio-learning-editorial.js.map +1 -1
- package/dist/api/biblio-learning-feedback.d.ts +1 -1
- package/dist/api/biblio-learning-feedback.js.map +1 -1
- package/dist/api/biblio-learning-finance.d.ts +1 -1
- package/dist/api/biblio-learning-finance.js.map +1 -1
- package/dist/api/biblio-learning-integrations.d.ts +1 -1
- package/dist/api/biblio-learning-integrations.js.map +1 -1
- package/dist/api/biblio-learning-membership.d.ts +1 -1
- package/dist/api/biblio-learning-membership.js.map +1 -1
- package/dist/api/biblio-learning.d.ts +1 -1
- package/dist/api/biblio-learning.js.map +1 -1
- package/dist/api/biblio-library.d.ts +1 -1
- package/dist/api/biblio-library.js.map +1 -1
- package/dist/api/biblio-nextory.d.ts +1 -1
- package/dist/api/biblio-nextory.js.map +1 -1
- package/dist/api/biblio-press.d.ts +1 -1
- package/dist/api/biblio-press.js.map +1 -1
- package/dist/api/biblio-search.js.map +1 -1
- package/dist/api/biblio-telemetry.js.map +1 -1
- package/dist/api/biblio-youscribe.d.ts +51 -0
- package/dist/api/biblio-youscribe.js +66 -0
- package/dist/api/biblio-youscribe.js.map +1 -0
- package/dist/api/consumption.d.ts +1 -1
- package/dist/api/consumption.js.map +1 -1
- package/dist/api/cvs-app.d.ts +1 -1
- package/dist/api/cvs-app.js.map +1 -1
- package/dist/api/cvs-documents.d.ts +1 -1
- package/dist/api/cvs-documents.js.map +1 -1
- package/dist/api/cvs-favorites.d.ts +1 -1
- package/dist/api/cvs-favorites.js.map +1 -1
- package/dist/api/cvs-ils.d.ts +1 -1
- package/dist/api/cvs-ils.js.map +1 -1
- package/dist/api/cvs-loans.d.ts +1 -1
- package/dist/api/cvs-loans.js.map +1 -1
- package/dist/api/cvs-payments.d.ts +1 -1
- package/dist/api/cvs-payments.js.map +1 -1
- package/dist/api/cvs-streaming.js.map +1 -1
- package/dist/api/index.d.ts +5 -3
- package/dist/api/index.js +5 -3
- package/dist/api/partner-catalogue.d.ts +21 -1
- package/dist/api/partner-catalogue.js +28 -1
- package/dist/api/partner-catalogue.js.map +1 -1
- package/dist/api/partner-reader-nextory.d.ts +52 -0
- package/dist/api/partner-reader-nextory.js +92 -0
- package/dist/api/partner-reader-nextory.js.map +1 -0
- package/dist/api/partner-reader-youscribe.d.ts +63 -0
- package/dist/api/partner-reader-youscribe.js +97 -0
- package/dist/api/partner-reader-youscribe.js.map +1 -0
- package/dist/api/profiles.d.ts +1 -1
- package/dist/api/profiles.js.map +1 -1
- package/dist/api/search.d.ts +6 -1
- package/dist/api/search.js +10 -1
- package/dist/api/search.js.map +1 -1
- package/dist/api/tutoring-catalogue.d.ts +1 -1
- package/dist/api/tutoring-catalogue.js.map +1 -1
- package/dist/api/tutoring-chat.d.ts +1 -1
- package/dist/api/tutoring-chat.js.map +1 -1
- package/dist/api/tutoring-dispatch.d.ts +1 -1
- package/dist/api/tutoring-dispatch.js.map +1 -1
- package/dist/api/tutoring-practitioner.js.map +1 -1
- package/dist/api/tutoring-requests.d.ts +1 -1
- package/dist/api/tutoring-requests.js.map +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/chunks/client2.d.ts +1 -1
- package/dist/chunks/connection.d.ts +1 -1
- package/dist/chunks/index.d.ts +542 -508
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +2 -2
- package/dist/models.js +7 -1
- package/dist/models.js.map +1 -1
- package/dist/react/account.d.ts +1 -1
- package/dist/react/account.js +1 -1
- package/dist/react/account.js.map +1 -1
- package/dist/react/admin-catalogue.d.ts +1 -1
- package/dist/react/admin-catalogue.js +1 -1
- package/dist/react/admin-catalogue.js.map +1 -1
- package/dist/react/admin-consumption.d.ts +1 -1
- package/dist/react/admin-consumption.js +1 -1
- package/dist/react/admin-consumption.js.map +1 -1
- package/dist/react/admin-contracts.d.ts +1 -1
- package/dist/react/admin-contracts.js +1 -1
- package/dist/react/admin-contracts.js.map +1 -1
- package/dist/react/admin-customer.d.ts +1 -1
- package/dist/react/admin-customer.js +1 -1
- package/dist/react/admin-customer.js.map +1 -1
- package/dist/react/admin-desk.d.ts +1 -1
- package/dist/react/admin-desk.js +1 -1
- package/dist/react/admin-desk.js.map +1 -1
- package/dist/react/admin-licenses.d.ts +1 -1
- package/dist/react/admin-licenses.js +1 -1
- package/dist/react/admin-licenses.js.map +1 -1
- package/dist/react/admin-partner-selections.d.ts +1 -1
- package/dist/react/admin-partner-selections.js +1 -1
- package/dist/react/admin-partner-selections.js.map +1 -1
- package/dist/react/admin-patrons.d.ts +1 -1
- package/dist/react/admin-patrons.js +1 -1
- package/dist/react/admin-patrons.js.map +1 -1
- package/dist/react/admin-reviews.d.ts +1 -1
- package/dist/react/admin-reviews.js +1 -1
- package/dist/react/admin-reviews.js.map +1 -1
- package/dist/react/admin-roles.d.ts +1 -1
- package/dist/react/admin-roles.js +1 -1
- package/dist/react/admin-roles.js.map +1 -1
- package/dist/react/admin-support.d.ts +1 -1
- package/dist/react/admin-support.js +1 -1
- package/dist/react/admin-support.js.map +1 -1
- package/dist/react/admin-tenants.d.ts +1 -1
- package/dist/react/admin-tenants.js +1 -1
- package/dist/react/admin-tenants.js.map +1 -1
- package/dist/react/admin-tutoring.d.ts +1 -1
- package/dist/react/admin-tutoring.js +1 -1
- package/dist/react/admin-tutoring.js.map +1 -1
- package/dist/react/auth-device.d.ts +1 -1
- package/dist/react/auth-device.js +1 -1
- package/dist/react/auth-device.js.map +1 -1
- package/dist/react/auth.d.ts +1 -1
- package/dist/react/auth.js +1 -1
- package/dist/react/auth.js.map +1 -1
- package/dist/react/biblio-billing-webhooks.d.ts +1 -1
- package/dist/react/biblio-billing-webhooks.js +1 -1
- package/dist/react/biblio-billing-webhooks.js.map +1 -1
- package/dist/react/biblio-billing.d.ts +1 -1
- package/dist/react/biblio-billing.js +1 -1
- package/dist/react/biblio-billing.js.map +1 -1
- package/dist/react/biblio-catalogue.d.ts +1 -1
- package/dist/react/biblio-catalogue.js +1 -1
- package/dist/react/biblio-catalogue.js.map +1 -1
- package/dist/react/biblio-home.d.ts +1 -1
- package/dist/react/biblio-home.js +1 -1
- package/dist/react/biblio-home.js.map +1 -1
- package/dist/react/biblio-learning-author-profiles.d.ts +1 -1
- package/dist/react/biblio-learning-author-profiles.js +1 -1
- package/dist/react/biblio-learning-author-profiles.js.map +1 -1
- package/dist/react/biblio-learning-authoring.d.ts +1 -1
- package/dist/react/biblio-learning-authoring.js +1 -1
- package/dist/react/biblio-learning-authoring.js.map +1 -1
- package/dist/react/biblio-learning-editorial.d.ts +1 -1
- package/dist/react/biblio-learning-editorial.js +1 -1
- package/dist/react/biblio-learning-editorial.js.map +1 -1
- package/dist/react/biblio-learning-feedback.d.ts +1 -1
- package/dist/react/biblio-learning-feedback.js +1 -1
- package/dist/react/biblio-learning-feedback.js.map +1 -1
- package/dist/react/biblio-learning-finance.d.ts +1 -1
- package/dist/react/biblio-learning-finance.js +1 -1
- package/dist/react/biblio-learning-finance.js.map +1 -1
- package/dist/react/biblio-learning-integrations.d.ts +1 -1
- package/dist/react/biblio-learning-integrations.js +1 -1
- package/dist/react/biblio-learning-integrations.js.map +1 -1
- package/dist/react/biblio-learning-membership.d.ts +1 -1
- package/dist/react/biblio-learning-membership.js +1 -1
- package/dist/react/biblio-learning-membership.js.map +1 -1
- package/dist/react/biblio-learning.d.ts +1 -1
- package/dist/react/biblio-learning.js +1 -1
- package/dist/react/biblio-learning.js.map +1 -1
- package/dist/react/biblio-library.d.ts +1 -1
- package/dist/react/biblio-library.js +1 -1
- package/dist/react/biblio-library.js.map +1 -1
- package/dist/react/biblio-nextory.d.ts +1 -1
- package/dist/react/biblio-nextory.js +1 -1
- package/dist/react/biblio-nextory.js.map +1 -1
- package/dist/react/biblio-press.d.ts +1 -1
- package/dist/react/biblio-press.js +1 -1
- package/dist/react/biblio-press.js.map +1 -1
- package/dist/react/biblio-search.d.ts +1 -1
- package/dist/react/biblio-search.js +1 -1
- package/dist/react/biblio-search.js.map +1 -1
- package/dist/react/biblio-telemetry.d.ts +1 -1
- package/dist/react/biblio-telemetry.js +1 -1
- package/dist/react/biblio-telemetry.js.map +1 -1
- package/dist/react/biblio-youscribe.d.ts +81 -0
- package/dist/react/biblio-youscribe.js +128 -0
- package/dist/react/biblio-youscribe.js.map +1 -0
- package/dist/react/chat.d.ts +1 -1
- package/dist/react/consumption.d.ts +1 -1
- package/dist/react/consumption.js +1 -1
- package/dist/react/consumption.js.map +1 -1
- package/dist/react/cvs-app.d.ts +1 -1
- package/dist/react/cvs-app.js +1 -1
- package/dist/react/cvs-app.js.map +1 -1
- package/dist/react/cvs-documents.d.ts +1 -1
- package/dist/react/cvs-documents.js +1 -1
- package/dist/react/cvs-documents.js.map +1 -1
- package/dist/react/cvs-favorites.d.ts +1 -1
- package/dist/react/cvs-favorites.js +1 -1
- package/dist/react/cvs-favorites.js.map +1 -1
- package/dist/react/cvs-ils.d.ts +1 -1
- package/dist/react/cvs-ils.js +1 -1
- package/dist/react/cvs-ils.js.map +1 -1
- package/dist/react/cvs-loans.d.ts +1 -1
- package/dist/react/cvs-loans.js +1 -1
- package/dist/react/cvs-loans.js.map +1 -1
- package/dist/react/cvs-payments.d.ts +1 -1
- package/dist/react/cvs-payments.js +1 -1
- package/dist/react/cvs-payments.js.map +1 -1
- package/dist/react/cvs-streaming.d.ts +1 -1
- package/dist/react/cvs-streaming.js +1 -1
- package/dist/react/cvs-streaming.js.map +1 -1
- package/dist/react/index.d.ts +5 -3
- package/dist/react/index.js +5 -3
- package/dist/react/partner-catalogue.d.ts +48 -1
- package/dist/react/partner-catalogue.js +54 -2
- package/dist/react/partner-catalogue.js.map +1 -1
- package/dist/react/partner-reader-nextory.d.ts +127 -0
- package/dist/react/partner-reader-nextory.js +190 -0
- package/dist/react/partner-reader-nextory.js.map +1 -0
- package/dist/react/partner-reader-youscribe.d.ts +152 -0
- package/dist/react/partner-reader-youscribe.js +224 -0
- package/dist/react/partner-reader-youscribe.js.map +1 -0
- package/dist/react/profiles.d.ts +1 -1
- package/dist/react/profiles.js +1 -1
- package/dist/react/profiles.js.map +1 -1
- package/dist/react/search.d.ts +6 -1
- package/dist/react/search.js +11 -2
- package/dist/react/search.js.map +1 -1
- package/dist/react/tutoring-catalogue.d.ts +1 -1
- package/dist/react/tutoring-catalogue.js +1 -1
- package/dist/react/tutoring-catalogue.js.map +1 -1
- package/dist/react/tutoring-chat.d.ts +1 -1
- package/dist/react/tutoring-chat.js +1 -1
- package/dist/react/tutoring-chat.js.map +1 -1
- package/dist/react/tutoring-dispatch.d.ts +1 -1
- package/dist/react/tutoring-dispatch.js +1 -1
- package/dist/react/tutoring-dispatch.js.map +1 -1
- package/dist/react/tutoring-practitioner.d.ts +1 -1
- package/dist/react/tutoring-practitioner.js +1 -1
- package/dist/react/tutoring-practitioner.js.map +1 -1
- package/dist/react/tutoring-requests.d.ts +1 -1
- package/dist/react/tutoring-requests.js +1 -1
- package/dist/react/tutoring-requests.js.map +1 -1
- package/package.json +7 -7
- package/dist/api/partner-reader.d.ts +0 -96
- package/dist/api/partner-reader.js +0 -164
- package/dist/api/partner-reader.js.map +0 -1
- package/dist/react/partner-reader.d.ts +0 -261
- package/dist/react/partner-reader.js +0 -368
- package/dist/react/partner-reader.js.map +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../chunks/client.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/partner-reader-nextory/partner-reader-nextory.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.15.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 getReadPackageUrl = (mediaId, params) => {
|
|
25
|
+
const normalizedParams = new URLSearchParams();
|
|
26
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
27
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
28
|
+
});
|
|
29
|
+
const stringifiedParams = normalizedParams.toString();
|
|
30
|
+
return stringifiedParams.length > 0 ? `/partners/nextory/media/${mediaId}/package?${stringifiedParams}` : `/partners/nextory/media/${mediaId}/package`;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Where to fetch the content itself.
|
|
34
|
+
*
|
|
35
|
+
* The returned URL is a short-lived DRM-wrapped credential. It is not cached
|
|
36
|
+
* here and should not be stored by the client.
|
|
37
|
+
*
|
|
38
|
+
* Opens a consumption lease, so the read appears in the ledger and counts
|
|
39
|
+
* against the establishment's live seats like any other. Its id comes back in
|
|
40
|
+
* ``lease``: keep it alive with ``PUT /consumption/{eventId}`` and drop it with
|
|
41
|
+
* ``DELETE`` when the reader closes. A client that does neither is not broken
|
|
42
|
+
* — the reaper closes the lease about a minute after the last heartbeat — but
|
|
43
|
+
* every such read is a seat held past the end of it.
|
|
44
|
+
*
|
|
45
|
+
* Re-opening the same title returns the lease already held rather than a
|
|
46
|
+
* second one, so a page reload does not leak a seat.
|
|
47
|
+
* @summary Read Package
|
|
48
|
+
*/
|
|
49
|
+
const readPackage = async (mediaId, params, options) => {
|
|
50
|
+
return request(getReadPackageUrl(mediaId, params), {
|
|
51
|
+
...options,
|
|
52
|
+
method: "GET"
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const getReadPackageQueryKey = (mediaId, params) => {
|
|
56
|
+
return [`/partners/nextory/media/${mediaId}/package`, ...params ? [params] : []];
|
|
57
|
+
};
|
|
58
|
+
const getReadPackageQueryOptions = (mediaId, params, options) => {
|
|
59
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
60
|
+
const queryKey = queryOptions?.queryKey ?? getReadPackageQueryKey(mediaId, params);
|
|
61
|
+
const queryFn = ({ signal }) => readPackage(mediaId, params, {
|
|
62
|
+
signal,
|
|
63
|
+
...requestOptions
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
queryKey,
|
|
67
|
+
queryFn,
|
|
68
|
+
enabled: mediaId !== null && mediaId !== void 0,
|
|
69
|
+
...queryOptions
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @summary Read Package
|
|
74
|
+
*/
|
|
75
|
+
function useReadPackage(mediaId, params, options, queryClient) {
|
|
76
|
+
const queryOptions = getReadPackageQueryOptions(mediaId, params, options);
|
|
77
|
+
const query = useQuery(queryOptions, queryClient);
|
|
78
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
79
|
+
}
|
|
80
|
+
const getReadPositionUrl = (mediaId) => {
|
|
81
|
+
return `/partners/nextory/media/${mediaId}/position`;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The last synchronized local position, or the partner's when none is saved.
|
|
85
|
+
*
|
|
86
|
+
* ``404`` when the partner holds no position — a book never opened has no
|
|
87
|
+
* place to return to, and reporting zero would make a client jump a reader who
|
|
88
|
+
* *is* mid-book back to the start if the call ever failed soft.
|
|
89
|
+
* @summary Read Position
|
|
90
|
+
*/
|
|
91
|
+
const readPosition = async (mediaId, options) => {
|
|
92
|
+
return request(getReadPositionUrl(mediaId), {
|
|
93
|
+
...options,
|
|
94
|
+
method: "GET"
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const getReadPositionQueryKey = (mediaId) => {
|
|
98
|
+
return [`/partners/nextory/media/${mediaId}/position`];
|
|
99
|
+
};
|
|
100
|
+
const getReadPositionQueryOptions = (mediaId, options) => {
|
|
101
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
102
|
+
const queryKey = queryOptions?.queryKey ?? getReadPositionQueryKey(mediaId);
|
|
103
|
+
const queryFn = ({ signal }) => readPosition(mediaId, {
|
|
104
|
+
signal,
|
|
105
|
+
...requestOptions
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
queryKey,
|
|
109
|
+
queryFn,
|
|
110
|
+
enabled: mediaId !== null && mediaId !== void 0,
|
|
111
|
+
...queryOptions
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @summary Read Position
|
|
116
|
+
*/
|
|
117
|
+
function useReadPosition(mediaId, options, queryClient) {
|
|
118
|
+
const queryOptions = getReadPositionQueryOptions(mediaId, options);
|
|
119
|
+
const query = useQuery(queryOptions, queryClient);
|
|
120
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
121
|
+
}
|
|
122
|
+
const getWritePositionUrl = (mediaId) => {
|
|
123
|
+
return `/partners/nextory/media/${mediaId}/position`;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Synchronize and save progress, with the partner's metering alongside it.
|
|
127
|
+
*
|
|
128
|
+
* ``usage_blocks`` is forwarded before a new position, matching the legacy's
|
|
129
|
+
* call order. The two reports are independent: an older position may carry
|
|
130
|
+
* usage the partner has not received yet.
|
|
131
|
+
*
|
|
132
|
+
* Only a strictly newer ``reachedAt`` replaces the saved position. Stale or
|
|
133
|
+
* duplicate writes return that saved position without updating it upstream.
|
|
134
|
+
* Provided usage blocks are still forwarded, including on retries; the
|
|
135
|
+
* partner's deduplication contract is unknown. Conflicting positions at the
|
|
136
|
+
* same instant return 409 before any outbound write.
|
|
137
|
+
* Progress is a resume point, not a measurement of time spent reading.
|
|
138
|
+
* @summary Write Position
|
|
139
|
+
*/
|
|
140
|
+
const writePosition = async (mediaId, readingPositionWrite, options) => {
|
|
141
|
+
const getHeaders = (h) => {
|
|
142
|
+
if (!h) return {};
|
|
143
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
144
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
145
|
+
const headers = {};
|
|
146
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
147
|
+
return headers;
|
|
148
|
+
};
|
|
149
|
+
return request(getWritePositionUrl(mediaId), {
|
|
150
|
+
...options,
|
|
151
|
+
method: "PATCH",
|
|
152
|
+
headers: {
|
|
153
|
+
"Content-Type": "application/json",
|
|
154
|
+
...getHeaders(options?.headers)
|
|
155
|
+
},
|
|
156
|
+
body: JSON.stringify(readingPositionWrite)
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
const getWritePositionMutationKey = () => ["writePosition"];
|
|
160
|
+
const getWritePositionMutationOptions = (options) => {
|
|
161
|
+
const mutationKey = getWritePositionMutationKey();
|
|
162
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
163
|
+
...options,
|
|
164
|
+
mutation: {
|
|
165
|
+
...options.mutation,
|
|
166
|
+
mutationKey
|
|
167
|
+
}
|
|
168
|
+
} : {
|
|
169
|
+
mutation: { mutationKey },
|
|
170
|
+
request: void 0
|
|
171
|
+
};
|
|
172
|
+
const mutationFn = (props) => {
|
|
173
|
+
const { mediaId, data } = props ?? {};
|
|
174
|
+
return writePosition(mediaId, data, requestOptions);
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
mutationFn,
|
|
178
|
+
...mutationOptions
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* @summary Write Position
|
|
183
|
+
*/
|
|
184
|
+
const useWritePosition = (options, queryClient) => {
|
|
185
|
+
return useMutation(getWritePositionMutationOptions(options), queryClient);
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
export { getReadPackageQueryKey, getReadPackageQueryOptions, getReadPackageUrl, getReadPositionQueryKey, getReadPositionQueryOptions, getReadPositionUrl, getWritePositionMutationKey, getWritePositionMutationOptions, getWritePositionUrl, readPackage, readPosition, useReadPackage, useReadPosition, useWritePosition, writePosition };
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=partner-reader-nextory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partner-reader-nextory.js","names":[],"sources":["../../src/react/partner-reader-nextory/partner-reader-nextory.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.15.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 ReadPackageParams,\n ReaderPackageRead,\n ReadingPositionRead,\n ReadingPositionWrite,\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 getReadPackageUrl = (mediaId: number,\n params?: ReadPackageParams,) => {\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 ? `/partners/nextory/media/${mediaId}/package?${stringifiedParams}` : `/partners/nextory/media/${mediaId}/package`\n}\n\n/**\n * Where to fetch the content itself.\n *\n * The returned URL is a short-lived DRM-wrapped credential. It is not cached\n * here and should not be stored by the client.\n *\n * Opens a consumption lease, so the read appears in the ledger and counts\n * against the establishment's live seats like any other. Its id comes back in\n * ``lease``: keep it alive with ``PUT /consumption/{eventId}`` and drop it with\n * ``DELETE`` when the reader closes. A client that does neither is not broken\n * — the reaper closes the lease about a minute after the last heartbeat — but\n * every such read is a seat held past the end of it.\n *\n * Re-opening the same title returns the lease already held rather than a\n * second one, so a page reload does not leak a seat.\n * @summary Read Package\n */\nexport const readPackage = async (mediaId: number,\n params?: ReadPackageParams, options?: Parameters<typeof request>[1]): Promise<ReaderPackageRead> => {\n\n return request<ReaderPackageRead>(getReadPackageUrl(mediaId,params),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getReadPackageQueryKey = (mediaId: number,\n params?: ReadPackageParams,) => {\n return [\n `/partners/nextory/media/${mediaId}/package`, ...(params ? [params] : [])\n ] as const;\n }\n\n\nexport const getReadPackageQueryOptions = <TData = Awaited<ReturnType<typeof readPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number,\n params?: ReadPackageParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getReadPackageQueryKey(mediaId,params);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof readPackage>>> = ({ signal }) => readPackage(mediaId,params, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, enabled: mediaId !== null && mediaId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ReadPackageQueryResult = NonNullable<Awaited<ReturnType<typeof readPackage>>>\nexport type ReadPackageQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useReadPackage<TData = Awaited<ReturnType<typeof readPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number,\n params: undefined | ReadPackageParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof readPackage>>,\n TError,\n Awaited<ReturnType<typeof readPackage>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadPackage<TData = Awaited<ReturnType<typeof readPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number,\n params?: ReadPackageParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof readPackage>>,\n TError,\n Awaited<ReturnType<typeof readPackage>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadPackage<TData = Awaited<ReturnType<typeof readPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number,\n params?: ReadPackageParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary Read Package\n */\n\nexport function useReadPackage<TData = Awaited<ReturnType<typeof readPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number,\n params?: ReadPackageParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPackage>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getReadPackageQueryOptions(mediaId,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 getReadPositionUrl = (mediaId: number,) => {\n\n\n\n\n return `/partners/nextory/media/${mediaId}/position`\n}\n\n/**\n * The last synchronized local position, or the partner's when none is saved.\n *\n * ``404`` when the partner holds no position — a book never opened has no\n * place to return to, and reporting zero would make a client jump a reader who\n * *is* mid-book back to the start if the call ever failed soft.\n * @summary Read Position\n */\nexport const readPosition = async (mediaId: number, options?: Parameters<typeof request>[1]): Promise<ReadingPositionRead> => {\n\n return request<ReadingPositionRead>(getReadPositionUrl(mediaId),\n {\n ...options,\n method: 'GET'\n\n\n }\n);}\n\n\n\n\n\nexport const getReadPositionQueryKey = (mediaId: number,) => {\n return [\n `/partners/nextory/media/${mediaId}/position`\n ] as const;\n }\n\n\nexport const getReadPositionQueryOptions = <TData = Awaited<ReturnType<typeof readPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData>>, request?: SecondParameter<typeof request>}\n) => {\n\nconst {query: queryOptions, request: requestOptions} = options ?? {};\n\n const queryKey = queryOptions?.queryKey ?? getReadPositionQueryKey(mediaId);\n\n\n\n const queryFn: QueryFunction<Awaited<ReturnType<typeof readPosition>>> = ({ signal }) => readPosition(mediaId, { signal, ...requestOptions });\n\n\n\n\n\n return { queryKey, queryFn, enabled: mediaId !== null && mediaId !== undefined, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }\n}\n\nexport type ReadPositionQueryResult = NonNullable<Awaited<ReturnType<typeof readPosition>>>\nexport type ReadPositionQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n\n\nexport function useReadPosition<TData = Awaited<ReturnType<typeof readPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData>> & Pick<\n DefinedInitialDataOptions<\n Awaited<ReturnType<typeof readPosition>>,\n TError,\n Awaited<ReturnType<typeof readPosition>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadPosition<TData = Awaited<ReturnType<typeof readPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData>> & Pick<\n UndefinedInitialDataOptions<\n Awaited<ReturnType<typeof readPosition>>,\n TError,\n Awaited<ReturnType<typeof readPosition>>\n > , 'initialData'\n >, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\nexport function useReadPosition<TData = Awaited<ReturnType<typeof readPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }\n/**\n * @summary Read Position\n */\n\nexport function useReadPosition<TData = Awaited<ReturnType<typeof readPosition>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(\n mediaId: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof readPosition>>, TError, TData>>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient\n ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {\n\n const queryOptions = getReadPositionQueryOptions(mediaId,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 getWritePositionUrl = (mediaId: number,) => {\n\n\n\n\n return `/partners/nextory/media/${mediaId}/position`\n}\n\n/**\n * Synchronize and save progress, with the partner's metering alongside it.\n *\n * ``usage_blocks`` is forwarded before a new position, matching the legacy's\n * call order. The two reports are independent: an older position may carry\n * usage the partner has not received yet.\n *\n * Only a strictly newer ``reachedAt`` replaces the saved position. Stale or\n * duplicate writes return that saved position without updating it upstream.\n * Provided usage blocks are still forwarded, including on retries; the\n * partner's deduplication contract is unknown. Conflicting positions at the\n * same instant return 409 before any outbound write.\n * Progress is a resume point, not a measurement of time spent reading.\n * @summary Write Position\n */\nexport const writePosition = async (mediaId: number,\n readingPositionWrite: ReadingPositionWrite, options?: Parameters<typeof request>[1]): Promise<ReadingPositionRead> => {\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<ReadingPositionRead>(getWritePositionUrl(mediaId),\n {\n ...options,\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },\n body: JSON.stringify(readingPositionWrite)\n }\n);}\n\n\n\n\n\nexport const getWritePositionMutationKey = () => ['writePosition'] as const;\n\nexport const getWritePositionMutationOptions = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof writePosition>>, TError,WritePositionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n): UseMutationOptions<Awaited<ReturnType<typeof writePosition>>, TError,WritePositionMutationVariables, TContext> => {\n\nconst mutationKey = getWritePositionMutationKey();\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 writePosition>>, WritePositionMutationVariables> = (props) => {\n const {mediaId,data} = props ?? {};\n\n return writePosition(mediaId,data,requestOptions)\n }\n\n\n\n\n\n\n return { mutationFn, ...mutationOptions }}\n\n export type WritePositionMutationResult = NonNullable<Awaited<ReturnType<typeof writePosition>>>\n export type WritePositionMutationBody = BodyType<ReadingPositionWrite>\n export type WritePositionMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>\n export type WritePositionMutationVariables = {mediaId: number;data: BodyType<ReadingPositionWrite>}\n\n /**\n * @summary Write Position\n */\nexport const useWritePosition = <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>,\n TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof writePosition>>, TError,WritePositionMutationVariables, TContext>, request?: SecondParameter<typeof request>}\n , queryClient?: QueryClient): UseMutationResult<\n Awaited<ReturnType<typeof writePosition>>,\n TError,\n WritePositionMutationVariables,\n TContext\n > => {\n return useMutation(getWritePositionMutationOptions(options), queryClient);\n }\n"],"mappings":"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"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
|
|
2
|
+
import { Nt as ReaderPackageRead, a as ValidationErrorResponse, gl as HTTPExceptionResponse, kt as ReadHostedPackageParams, n as YouScribeAuthRead, t as YouScribeReaderRead } from "../chunks/index.js";
|
|
3
|
+
import { a as ErrorType, c as request } from "../chunks/client.js";
|
|
4
|
+
import { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryKey, UndefinedInitialDataOptions, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
5
|
+
//#region src/react/partner-reader-youscribe/partner-reader-youscribe.d.ts
|
|
6
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
7
|
+
export declare const getReadHostedPackageUrl: (mediaId: number, params?: ReadHostedPackageParams) => string;
|
|
8
|
+
/**
|
|
9
|
+
* **Deprecated**: the hosted reader's address and a lease. As in 0.13.0.
|
|
10
|
+
*
|
|
11
|
+
* Requires a seat already taken and never takes one: a GET does not buy a
|
|
12
|
+
* subscription.
|
|
13
|
+
* @deprecated
|
|
14
|
+
* @summary Read Hosted Package
|
|
15
|
+
*/
|
|
16
|
+
export declare const readHostedPackage: (mediaId: number, params?: ReadHostedPackageParams, options?: Parameters<typeof request>[1]) => Promise<ReaderPackageRead>;
|
|
17
|
+
export declare const getReadHostedPackageQueryKey: (mediaId: number, params?: ReadHostedPackageParams) => readonly [`/partners/youscribe/media/${number}/package`, ...ReadHostedPackageParams[]];
|
|
18
|
+
export declare const getReadHostedPackageQueryOptions: <TData = Awaited<ReturnType<typeof readHostedPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number, params?: ReadHostedPackageParams, options?: {
|
|
19
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, TData>>;
|
|
20
|
+
request?: SecondParameter<typeof request>;
|
|
21
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, TData> & {
|
|
22
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
23
|
+
};
|
|
24
|
+
export type ReadHostedPackageQueryResult = NonNullable<Awaited<ReturnType<typeof readHostedPackage>>>;
|
|
25
|
+
export type ReadHostedPackageQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
26
|
+
export declare function useReadHostedPackage<TData = Awaited<ReturnType<typeof readHostedPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number, params: undefined | ReadHostedPackageParams, options: {
|
|
27
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, Awaited<ReturnType<typeof readHostedPackage>>>, 'initialData'>;
|
|
28
|
+
request?: SecondParameter<typeof request>;
|
|
29
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
30
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
31
|
+
};
|
|
32
|
+
export declare function useReadHostedPackage<TData = Awaited<ReturnType<typeof readHostedPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number, params?: ReadHostedPackageParams, options?: {
|
|
33
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, Awaited<ReturnType<typeof readHostedPackage>>>, 'initialData'>;
|
|
34
|
+
request?: SecondParameter<typeof request>;
|
|
35
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
36
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
37
|
+
};
|
|
38
|
+
export declare function useReadHostedPackage<TData = Awaited<ReturnType<typeof readHostedPackage>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(mediaId: number, params?: ReadHostedPackageParams, options?: {
|
|
39
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readHostedPackage>>, TError, TData>>;
|
|
40
|
+
request?: SecondParameter<typeof request>;
|
|
41
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
42
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
43
|
+
};
|
|
44
|
+
export declare const getOpenNativeReaderUrl: (mediaId: number) => string;
|
|
45
|
+
/**
|
|
46
|
+
* **Deprecated**: take the seat with ``POST /biblio/me/youscribe/license``. As in 0.13.0.
|
|
47
|
+
*
|
|
48
|
+
* Credentials for one title, taking a seat on first use, and the consumption
|
|
49
|
+
* lease that records the opening. Renew ``lease.eventId`` while the reader is
|
|
50
|
+
* open and close it when it exits.
|
|
51
|
+
* @deprecated
|
|
52
|
+
* @summary Open Native Reader
|
|
53
|
+
*/
|
|
54
|
+
export declare const openNativeReader: (mediaId: number, options?: Parameters<typeof request>[1]) => Promise<YouScribeReaderRead>;
|
|
55
|
+
export declare const getOpenNativeReaderMutationKey: () => readonly ['openNativeReader'];
|
|
56
|
+
export declare const getOpenNativeReaderMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
57
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openNativeReader>>, TError, OpenNativeReaderMutationVariables, TContext>;
|
|
58
|
+
request?: SecondParameter<typeof request>;
|
|
59
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof openNativeReader>>, TError, OpenNativeReaderMutationVariables, TContext>;
|
|
60
|
+
export type OpenNativeReaderMutationResult = NonNullable<Awaited<ReturnType<typeof openNativeReader>>>;
|
|
61
|
+
export type OpenNativeReaderMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
62
|
+
export type OpenNativeReaderMutationVariables = {
|
|
63
|
+
mediaId: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated
|
|
67
|
+
* @summary Open Native Reader
|
|
68
|
+
*/
|
|
69
|
+
export declare const useOpenNativeReader: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
70
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openNativeReader>>, TError, OpenNativeReaderMutationVariables, TContext>;
|
|
71
|
+
request?: SecondParameter<typeof request>;
|
|
72
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof openNativeReader>>, TError, OpenNativeReaderMutationVariables, TContext>;
|
|
73
|
+
export declare const getReadNativeAuthUrl: () => string;
|
|
74
|
+
/**
|
|
75
|
+
* YouScribe native SDK credentials for the selected, authorized profile.
|
|
76
|
+
*
|
|
77
|
+
* The legacy's ``GET /api/v1/{catalog}/user/auth``, and the only YouScribe
|
|
78
|
+
* credentials endpoint — because a YouScribe token is issued **per patron and
|
|
79
|
+
* not per title**, so an authorization keyed by media was answering a question
|
|
80
|
+
* nobody asked. ``POST /media/{id}/reader-auth`` and ``POST /user/auth`` were
|
|
81
|
+
* both this endpoint again: the first added a ``mediaId`` the caller already
|
|
82
|
+
* knew, the second provisioned a seat it no longer provisions.
|
|
83
|
+
*
|
|
84
|
+
* **This is an authentication, not a read.** It exchanges the patron's licence
|
|
85
|
+
* for a session token on YouScribe's REST API, and nothing follows from it: a
|
|
86
|
+
* caller may ask for a token and never open a title. So there is no licence to
|
|
87
|
+
* create and no consumption to record here, not as a policy but because
|
|
88
|
+
* nothing has been consumed.
|
|
89
|
+
*
|
|
90
|
+
* The reading itself happens in the partner's own player — hosted on the web,
|
|
91
|
+
* through their SDK inside the mobile app — and **that player reports its
|
|
92
|
+
* consumption to YouScribe**. We hand over credentials and hear nothing more.
|
|
93
|
+
*
|
|
94
|
+
* The token is personal: never persist it, log it, or share it between
|
|
95
|
+
* profiles.
|
|
96
|
+
* @summary Read Native Auth
|
|
97
|
+
*/
|
|
98
|
+
export declare const readNativeAuth: (options?: Parameters<typeof request>[1]) => Promise<YouScribeAuthRead>;
|
|
99
|
+
export declare const getReadNativeAuthQueryKey: () => readonly [`/partners/youscribe/user/auth`];
|
|
100
|
+
export declare const getReadNativeAuthQueryOptions: <TData = Awaited<ReturnType<typeof readNativeAuth>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
|
|
101
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, TData>>;
|
|
102
|
+
request?: SecondParameter<typeof request>;
|
|
103
|
+
}) => UseQueryOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, TData> & {
|
|
104
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
105
|
+
};
|
|
106
|
+
export type ReadNativeAuthQueryResult = NonNullable<Awaited<ReturnType<typeof readNativeAuth>>>;
|
|
107
|
+
export type ReadNativeAuthQueryError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
108
|
+
export declare function useReadNativeAuth<TData = Awaited<ReturnType<typeof readNativeAuth>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options: {
|
|
109
|
+
query: Partial<UseQueryOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, TData>> & Pick<DefinedInitialDataOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, Awaited<ReturnType<typeof readNativeAuth>>>, 'initialData'>;
|
|
110
|
+
request?: SecondParameter<typeof request>;
|
|
111
|
+
}, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError> & {
|
|
112
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
113
|
+
};
|
|
114
|
+
export declare function useReadNativeAuth<TData = Awaited<ReturnType<typeof readNativeAuth>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
|
|
115
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, TData>> & Pick<UndefinedInitialDataOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, Awaited<ReturnType<typeof readNativeAuth>>>, 'initialData'>;
|
|
116
|
+
request?: SecondParameter<typeof request>;
|
|
117
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
118
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
119
|
+
};
|
|
120
|
+
export declare function useReadNativeAuth<TData = Awaited<ReturnType<typeof readNativeAuth>>, TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>>(options?: {
|
|
121
|
+
query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof readNativeAuth>>, TError, TData>>;
|
|
122
|
+
request?: SecondParameter<typeof request>;
|
|
123
|
+
}, queryClient?: QueryClient): UseQueryResult<TData, TError> & {
|
|
124
|
+
queryKey: DataTag<QueryKey, TData, TError>;
|
|
125
|
+
};
|
|
126
|
+
export declare const getOpenNativeAuthUrl: () => string;
|
|
127
|
+
/**
|
|
128
|
+
* **Deprecated**: ``POST /biblio/me/youscribe/license``. As in 0.13.0.
|
|
129
|
+
*
|
|
130
|
+
* Credentials for this profile, taking a seat on first use. Call only on the
|
|
131
|
+
* patron's explicit Read: it can create a paid subscription.
|
|
132
|
+
* @deprecated
|
|
133
|
+
* @summary Open Native Auth
|
|
134
|
+
*/
|
|
135
|
+
export declare const openNativeAuth: (options?: Parameters<typeof request>[1]) => Promise<YouScribeAuthRead>;
|
|
136
|
+
export declare const getOpenNativeAuthMutationKey: () => readonly ['openNativeAuth'];
|
|
137
|
+
export declare const getOpenNativeAuthMutationOptions: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
138
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openNativeAuth>>, TError, void, TContext>;
|
|
139
|
+
request?: SecondParameter<typeof request>;
|
|
140
|
+
}) => UseMutationOptions<Awaited<ReturnType<typeof openNativeAuth>>, TError, void, TContext>;
|
|
141
|
+
export type OpenNativeAuthMutationResult = NonNullable<Awaited<ReturnType<typeof openNativeAuth>>>;
|
|
142
|
+
export type OpenNativeAuthMutationError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated
|
|
145
|
+
* @summary Open Native Auth
|
|
146
|
+
*/
|
|
147
|
+
export declare const useOpenNativeAuth: <TError = ErrorType<HTTPExceptionResponse | ValidationErrorResponse>, TContext = unknown>(options?: {
|
|
148
|
+
mutation?: UseMutationOptions<Awaited<ReturnType<typeof openNativeAuth>>, TError, void, TContext>;
|
|
149
|
+
request?: SecondParameter<typeof request>;
|
|
150
|
+
}, queryClient?: QueryClient) => UseMutationResult<Awaited<ReturnType<typeof openNativeAuth>>, TError, void, TContext>;
|
|
151
|
+
//#endregion
|
|
152
|
+
//# sourceMappingURL=partner-reader-youscribe.d.ts.map
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../chunks/client.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/partner-reader-youscribe/partner-reader-youscribe.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.15.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 getReadHostedPackageUrl = (mediaId, params) => {
|
|
25
|
+
const normalizedParams = new URLSearchParams();
|
|
26
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
27
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
28
|
+
});
|
|
29
|
+
const stringifiedParams = normalizedParams.toString();
|
|
30
|
+
return stringifiedParams.length > 0 ? `/partners/youscribe/media/${mediaId}/package?${stringifiedParams}` : `/partners/youscribe/media/${mediaId}/package`;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* **Deprecated**: the hosted reader's address and a lease. As in 0.13.0.
|
|
34
|
+
*
|
|
35
|
+
* Requires a seat already taken and never takes one: a GET does not buy a
|
|
36
|
+
* subscription.
|
|
37
|
+
* @deprecated
|
|
38
|
+
* @summary Read Hosted Package
|
|
39
|
+
*/
|
|
40
|
+
const readHostedPackage = async (mediaId, params, options) => {
|
|
41
|
+
return request(getReadHostedPackageUrl(mediaId, params), {
|
|
42
|
+
...options,
|
|
43
|
+
method: "GET"
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const getReadHostedPackageQueryKey = (mediaId, params) => {
|
|
47
|
+
return [`/partners/youscribe/media/${mediaId}/package`, ...params ? [params] : []];
|
|
48
|
+
};
|
|
49
|
+
const getReadHostedPackageQueryOptions = (mediaId, params, options) => {
|
|
50
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
51
|
+
const queryKey = queryOptions?.queryKey ?? getReadHostedPackageQueryKey(mediaId, params);
|
|
52
|
+
const queryFn = ({ signal }) => readHostedPackage(mediaId, params, {
|
|
53
|
+
signal,
|
|
54
|
+
...requestOptions
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
queryKey,
|
|
58
|
+
queryFn,
|
|
59
|
+
enabled: mediaId !== null && mediaId !== void 0,
|
|
60
|
+
...queryOptions
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated
|
|
65
|
+
* @summary Read Hosted Package
|
|
66
|
+
*/
|
|
67
|
+
function useReadHostedPackage(mediaId, params, options, queryClient) {
|
|
68
|
+
const queryOptions = getReadHostedPackageQueryOptions(mediaId, params, options);
|
|
69
|
+
const query = useQuery(queryOptions, queryClient);
|
|
70
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
71
|
+
}
|
|
72
|
+
const getOpenNativeReaderUrl = (mediaId) => {
|
|
73
|
+
return `/partners/youscribe/media/${mediaId}/reader-auth`;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* **Deprecated**: take the seat with ``POST /biblio/me/youscribe/license``. As in 0.13.0.
|
|
77
|
+
*
|
|
78
|
+
* Credentials for one title, taking a seat on first use, and the consumption
|
|
79
|
+
* lease that records the opening. Renew ``lease.eventId`` while the reader is
|
|
80
|
+
* open and close it when it exits.
|
|
81
|
+
* @deprecated
|
|
82
|
+
* @summary Open Native Reader
|
|
83
|
+
*/
|
|
84
|
+
const openNativeReader = async (mediaId, options) => {
|
|
85
|
+
return request(getOpenNativeReaderUrl(mediaId), {
|
|
86
|
+
...options,
|
|
87
|
+
method: "POST"
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const getOpenNativeReaderMutationKey = () => ["openNativeReader"];
|
|
91
|
+
const getOpenNativeReaderMutationOptions = (options) => {
|
|
92
|
+
const mutationKey = getOpenNativeReaderMutationKey();
|
|
93
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
94
|
+
...options,
|
|
95
|
+
mutation: {
|
|
96
|
+
...options.mutation,
|
|
97
|
+
mutationKey
|
|
98
|
+
}
|
|
99
|
+
} : {
|
|
100
|
+
mutation: { mutationKey },
|
|
101
|
+
request: void 0
|
|
102
|
+
};
|
|
103
|
+
const mutationFn = (props) => {
|
|
104
|
+
const { mediaId } = props ?? {};
|
|
105
|
+
return openNativeReader(mediaId, requestOptions);
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
mutationFn,
|
|
109
|
+
...mutationOptions
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated
|
|
114
|
+
* @summary Open Native Reader
|
|
115
|
+
*/
|
|
116
|
+
const useOpenNativeReader = (options, queryClient) => {
|
|
117
|
+
return useMutation(getOpenNativeReaderMutationOptions(options), queryClient);
|
|
118
|
+
};
|
|
119
|
+
const getReadNativeAuthUrl = () => {
|
|
120
|
+
return `/partners/youscribe/user/auth`;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* YouScribe native SDK credentials for the selected, authorized profile.
|
|
124
|
+
*
|
|
125
|
+
* The legacy's ``GET /api/v1/{catalog}/user/auth``, and the only YouScribe
|
|
126
|
+
* credentials endpoint — because a YouScribe token is issued **per patron and
|
|
127
|
+
* not per title**, so an authorization keyed by media was answering a question
|
|
128
|
+
* nobody asked. ``POST /media/{id}/reader-auth`` and ``POST /user/auth`` were
|
|
129
|
+
* both this endpoint again: the first added a ``mediaId`` the caller already
|
|
130
|
+
* knew, the second provisioned a seat it no longer provisions.
|
|
131
|
+
*
|
|
132
|
+
* **This is an authentication, not a read.** It exchanges the patron's licence
|
|
133
|
+
* for a session token on YouScribe's REST API, and nothing follows from it: a
|
|
134
|
+
* caller may ask for a token and never open a title. So there is no licence to
|
|
135
|
+
* create and no consumption to record here, not as a policy but because
|
|
136
|
+
* nothing has been consumed.
|
|
137
|
+
*
|
|
138
|
+
* The reading itself happens in the partner's own player — hosted on the web,
|
|
139
|
+
* through their SDK inside the mobile app — and **that player reports its
|
|
140
|
+
* consumption to YouScribe**. We hand over credentials and hear nothing more.
|
|
141
|
+
*
|
|
142
|
+
* The token is personal: never persist it, log it, or share it between
|
|
143
|
+
* profiles.
|
|
144
|
+
* @summary Read Native Auth
|
|
145
|
+
*/
|
|
146
|
+
const readNativeAuth = async (options) => {
|
|
147
|
+
return request(getReadNativeAuthUrl(), {
|
|
148
|
+
...options,
|
|
149
|
+
method: "GET"
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const getReadNativeAuthQueryKey = () => {
|
|
153
|
+
return [`/partners/youscribe/user/auth`];
|
|
154
|
+
};
|
|
155
|
+
const getReadNativeAuthQueryOptions = (options) => {
|
|
156
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
157
|
+
const queryKey = queryOptions?.queryKey ?? getReadNativeAuthQueryKey();
|
|
158
|
+
const queryFn = ({ signal }) => readNativeAuth({
|
|
159
|
+
signal,
|
|
160
|
+
...requestOptions
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
queryKey,
|
|
164
|
+
queryFn,
|
|
165
|
+
...queryOptions
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* @summary Read Native Auth
|
|
170
|
+
*/
|
|
171
|
+
function useReadNativeAuth(options, queryClient) {
|
|
172
|
+
const queryOptions = getReadNativeAuthQueryOptions(options);
|
|
173
|
+
const query = useQuery(queryOptions, queryClient);
|
|
174
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
175
|
+
}
|
|
176
|
+
const getOpenNativeAuthUrl = () => {
|
|
177
|
+
return `/partners/youscribe/user/auth`;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* **Deprecated**: ``POST /biblio/me/youscribe/license``. As in 0.13.0.
|
|
181
|
+
*
|
|
182
|
+
* Credentials for this profile, taking a seat on first use. Call only on the
|
|
183
|
+
* patron's explicit Read: it can create a paid subscription.
|
|
184
|
+
* @deprecated
|
|
185
|
+
* @summary Open Native Auth
|
|
186
|
+
*/
|
|
187
|
+
const openNativeAuth = async (options) => {
|
|
188
|
+
return request(getOpenNativeAuthUrl(), {
|
|
189
|
+
...options,
|
|
190
|
+
method: "POST"
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const getOpenNativeAuthMutationKey = () => ["openNativeAuth"];
|
|
194
|
+
const getOpenNativeAuthMutationOptions = (options) => {
|
|
195
|
+
const mutationKey = getOpenNativeAuthMutationKey();
|
|
196
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
197
|
+
...options,
|
|
198
|
+
mutation: {
|
|
199
|
+
...options.mutation,
|
|
200
|
+
mutationKey
|
|
201
|
+
}
|
|
202
|
+
} : {
|
|
203
|
+
mutation: { mutationKey },
|
|
204
|
+
request: void 0
|
|
205
|
+
};
|
|
206
|
+
const mutationFn = () => {
|
|
207
|
+
return openNativeAuth(requestOptions);
|
|
208
|
+
};
|
|
209
|
+
return {
|
|
210
|
+
mutationFn,
|
|
211
|
+
...mutationOptions
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated
|
|
216
|
+
* @summary Open Native Auth
|
|
217
|
+
*/
|
|
218
|
+
const useOpenNativeAuth = (options, queryClient) => {
|
|
219
|
+
return useMutation(getOpenNativeAuthMutationOptions(options), queryClient);
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
222
|
+
export { getOpenNativeAuthMutationKey, getOpenNativeAuthMutationOptions, getOpenNativeAuthUrl, getOpenNativeReaderMutationKey, getOpenNativeReaderMutationOptions, getOpenNativeReaderUrl, getReadHostedPackageQueryKey, getReadHostedPackageQueryOptions, getReadHostedPackageUrl, getReadNativeAuthQueryKey, getReadNativeAuthQueryOptions, getReadNativeAuthUrl, openNativeAuth, openNativeReader, readHostedPackage, readNativeAuth, useOpenNativeAuth, useOpenNativeReader, useReadHostedPackage, useReadNativeAuth };
|
|
223
|
+
|
|
224
|
+
//# sourceMappingURL=partner-reader-youscribe.js.map
|