@ovok/core 0.4.49-rc.5 → 0.4.49-rc.7
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/dist/client/observation/observation-coding.js +4 -1
- package/dist/client/observation/services/base-observation-service.js +6 -2
- package/dist/client/observation/services/blood-oxygen.js +8 -0
- package/dist/client/observation/services/ecg.d.ts +1 -3
- package/dist/client/observation/services/ecg.js +0 -10
- package/dist/client/observation/types/ObservationCode.d.ts +2 -0
- package/dist/client/observation/types/ObservationCode.js +2 -0
- package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +2 -0
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/next/index.d.ts +1 -0
- package/dist/next/resources/auth/adopted-session.d.ts +30 -0
- package/dist/next/resources/auth/adopted-session.js +46 -0
- package/dist/next/resources/auth-resource.d.ts +16 -0
- package/dist/next/resources/auth-resource.js +21 -2
- package/dist/next/resources/cms/cms-resource.d.ts +8 -1
- package/dist/next/resources/cms/cms-resource.js +19 -6
- package/package.json +1 -1
|
@@ -20,7 +20,10 @@ const UCUM_CODES = {
|
|
|
20
20
|
/** A quantity in `unit`, coded in UCUM when the unit has a UCUM code. */
|
|
21
21
|
const ucumQuantity = (value, unit) => {
|
|
22
22
|
const code = UCUM_CODES[unit];
|
|
23
|
-
|
|
23
|
+
if (code) {
|
|
24
|
+
return { value, unit, system: fhir_systems_1.UCUM_SYSTEM, code };
|
|
25
|
+
}
|
|
26
|
+
return unit ? { value, unit } : { value };
|
|
24
27
|
};
|
|
25
28
|
exports.ucumQuantity = ucumQuantity;
|
|
26
29
|
const CATEGORY_BY_TYPE = {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseObservationService = void 0;
|
|
4
|
+
const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
|
|
4
5
|
const fhir_systems_1 = require("../fhir-systems");
|
|
5
6
|
const observation_coding_1 = require("../observation-coding");
|
|
6
7
|
const measurement_time_1 = require("./measurement-time");
|
|
8
|
+
/** Waveforms are coded in the ISO/IEEE 11073 nomenclature, everything else in LOINC. */
|
|
9
|
+
const MDC_CODES = new Set([MeasurementTypes_1.ObservationCode.ECG, MeasurementTypes_1.ObservationCode.PULSE_WAVE]);
|
|
10
|
+
const systemOf = (code) => (MDC_CODES.has(code) ? fhir_systems_1.MDC_SYSTEM : fhir_systems_1.LOINC_SYSTEM);
|
|
7
11
|
class BaseObservationService {
|
|
8
12
|
getFields() {
|
|
9
13
|
return this.observationMetadata.map(({ valueKey, primaryCode, unit, toFixed, display }) => ({
|
|
@@ -41,12 +45,12 @@ class BaseObservationService {
|
|
|
41
45
|
{
|
|
42
46
|
code: metadata.primaryCode,
|
|
43
47
|
display: metadata.display,
|
|
44
|
-
system:
|
|
48
|
+
system: systemOf(metadata.primaryCode),
|
|
45
49
|
},
|
|
46
50
|
...metadata.additionalCodes.map((code) => ({
|
|
47
51
|
code,
|
|
48
52
|
display: metadata.display,
|
|
49
|
-
system:
|
|
53
|
+
system: systemOf(code),
|
|
50
54
|
})),
|
|
51
55
|
],
|
|
52
56
|
text: metadata.display,
|
|
@@ -25,6 +25,14 @@ class BloodOxygenService extends base_observation_service_1.BaseObservationServi
|
|
|
25
25
|
valueKey: "pulseRate",
|
|
26
26
|
toFixed: 0,
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
primaryCode: MeasurementTypes_1.ObservationCode.PULSE_WAVE,
|
|
30
|
+
additionalCodes: [],
|
|
31
|
+
display: "Pulse wave",
|
|
32
|
+
unit: "",
|
|
33
|
+
valueKey: "pulseWave",
|
|
34
|
+
toFixed: 0,
|
|
35
|
+
},
|
|
28
36
|
];
|
|
29
37
|
}
|
|
30
38
|
getMeasurementDisplay(measurement) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Observation } from "@medplum/fhirtypes";
|
|
2
2
|
import { EcgMeasurement, Measurement, MeasurementTypeKey } from "../../../types/MeasurementTypes";
|
|
3
3
|
import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
|
|
4
4
|
import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
|
|
@@ -12,8 +12,6 @@ export declare class EcgService extends BaseObservationService<EcgMeasurement> {
|
|
|
12
12
|
/** Expand long recordings into bounded, timestamped observations. */
|
|
13
13
|
generateObservationFragments(measurement: Measurement): ObservationFragment[];
|
|
14
14
|
getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
|
|
15
|
-
/** The waveform is coded in the ISO/IEEE 11073 nomenclature, not LOINC. */
|
|
16
|
-
getObservationCodes(): CodeableConcept[];
|
|
17
15
|
getMeasurementDisplay(measurement: Measurement): string;
|
|
18
16
|
getObservationDisplay(observations: Observation[]): string | undefined;
|
|
19
17
|
convertSamplesToMeasurement(): EcgMeasurement;
|
|
@@ -92,16 +92,6 @@ class EcgService extends base_observation_service_1.BaseObservationService {
|
|
|
92
92
|
];
|
|
93
93
|
return additionalProperties;
|
|
94
94
|
}
|
|
95
|
-
/** The waveform is coded in the ISO/IEEE 11073 nomenclature, not LOINC. */
|
|
96
|
-
getObservationCodes() {
|
|
97
|
-
return super.getObservationCodes().map((concept) => {
|
|
98
|
-
var _a;
|
|
99
|
-
return ({
|
|
100
|
-
...concept,
|
|
101
|
-
coding: (_a = concept.coding) === null || _a === void 0 ? void 0 : _a.map((coding) => coding.code === MeasurementTypes_1.ObservationCode.ECG ? { ...coding, system: fhir_systems_1.MDC_SYSTEM } : coding),
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
95
|
getMeasurementDisplay(measurement) {
|
|
106
96
|
const castedMeasurement = this.getCastedMeasurement(measurement);
|
|
107
97
|
return castedMeasurement.diagnosticResult || "Unknown";
|
|
@@ -38,6 +38,8 @@ export declare enum ObservationCode {
|
|
|
38
38
|
BODY_TEMPERATURE = "8310-5",
|
|
39
39
|
/** ECG waveform. */
|
|
40
40
|
ECG = "131328",
|
|
41
|
+
/** A pulse oximeter's pulse wave (plethysmogram). */
|
|
42
|
+
PULSE_WAVE = "150452",
|
|
41
43
|
/** Respiratory rate. */
|
|
42
44
|
RESPIRATORY_RATE = "9279-1",
|
|
43
45
|
/** Spirometry panel. */
|
|
@@ -42,6 +42,8 @@ var ObservationCode;
|
|
|
42
42
|
ObservationCode["BODY_TEMPERATURE"] = "8310-5";
|
|
43
43
|
/** ECG waveform. */
|
|
44
44
|
ObservationCode["ECG"] = "131328";
|
|
45
|
+
/** A pulse oximeter's pulse wave (plethysmogram). */
|
|
46
|
+
ObservationCode["PULSE_WAVE"] = "150452";
|
|
45
47
|
/** Respiratory rate. */
|
|
46
48
|
ObservationCode["RESPIRATORY_RATE"] = "9279-1";
|
|
47
49
|
/** Spirometry panel. */
|
|
@@ -16,4 +16,6 @@ export type PulseOximeterMeasurement = Measurement & {
|
|
|
16
16
|
bloodOxygen?: number;
|
|
17
17
|
/** Perfusion index. */
|
|
18
18
|
perfusionIndex?: number;
|
|
19
|
+
/** One pulse wave sample, in the sensor's own units; a series holds the wave at the sensor's rate. */
|
|
20
|
+
pulseWave?: number;
|
|
19
21
|
};
|
|
@@ -26,7 +26,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
|
|
|
26
26
|
description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
|
|
27
27
|
software: {
|
|
28
28
|
name: "@ovok/core",
|
|
29
|
-
version: "0.4.49-rc.
|
|
29
|
+
version: "0.4.49-rc.7",
|
|
30
30
|
},
|
|
31
31
|
fhirVersion: "4.0.1",
|
|
32
32
|
format: ["json"],
|
package/dist/next/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type { SessionChangeListener } from "./auth/user-session";
|
|
|
15
15
|
export type { LoginCredentials, LoginResult, MfaChallenge, ProfileType } from "./resources/auth-resource";
|
|
16
16
|
export type { CreateOptions, PatchOperation } from "./resources/fhir-resource";
|
|
17
17
|
export type { HealthCheck } from "./resources/health-resource";
|
|
18
|
+
export type { AdoptedSession } from "./resources/auth/adopted-session";
|
|
18
19
|
export type { PatientRegistration, PractitionerRegistration, RegisterResult } from "./resources/auth/registration";
|
|
19
20
|
export type { SocialCredentials, SocialProvider } from "./resources/auth/social-login";
|
|
20
21
|
export type { LastObservationsQuery, LastnQuery, LatestObservationsParams, MeasurementCodeTypes, SaveObservationsOptions, SaveObservationsResult, } from "./resources/measurements/measurements-resource";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { LoginTokens } from "../../auth/session";
|
|
2
|
+
/**
|
|
3
|
+
* A sign-in made elsewhere, such as the session an earlier client stored, for `ovok.auth.adoptSession` to continue.
|
|
4
|
+
*
|
|
5
|
+
* @category auth
|
|
6
|
+
*/
|
|
7
|
+
export type AdoptedSession = {
|
|
8
|
+
/** Bearer token for API requests. */
|
|
9
|
+
accessToken: string;
|
|
10
|
+
/** Token that renews the session; null or omitted when there is none. */
|
|
11
|
+
refreshToken?: string | null;
|
|
12
|
+
/** Seconds until `accessToken` expires. Omit it when unknown: the first request then refreshes the session. */
|
|
13
|
+
expiresIn?: number;
|
|
14
|
+
/** The signed-in profile. */
|
|
15
|
+
profile: {
|
|
16
|
+
/** FHIR reference, such as `Patient/123`. */
|
|
17
|
+
reference: string;
|
|
18
|
+
/** Display name, if known. */
|
|
19
|
+
display?: string | null;
|
|
20
|
+
};
|
|
21
|
+
/** The project the session belongs to. Omit it when unknown. */
|
|
22
|
+
project?: {
|
|
23
|
+
/** FHIR reference, such as `Project/123`. */
|
|
24
|
+
reference: string;
|
|
25
|
+
/** Display name, if known. */
|
|
26
|
+
display?: string | null;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/** Checks the input at the trust boundary: it is often parsed from storage, so its types are not given. */
|
|
30
|
+
export declare function loginTokensFromAdopted(adopted: AdoptedSession): LoginTokens;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loginTokensFromAdopted = loginTokensFromAdopted;
|
|
4
|
+
const ovok_errors_1 = require("../../errors/ovok-errors");
|
|
5
|
+
const FHIR_REFERENCE = /^[A-Za-z]+\/[A-Za-z0-9\-.]{1,64}$/;
|
|
6
|
+
const DUE_AT_ONCE_SECONDS = 0;
|
|
7
|
+
const NO_PROJECT = { reference: "" };
|
|
8
|
+
/** Checks the input at the trust boundary: it is often parsed from storage, so its types are not given. */
|
|
9
|
+
function loginTokensFromAdopted(adopted) {
|
|
10
|
+
const { accessToken, refreshToken, expiresIn, profile, project } = (adopted !== null && adopted !== void 0 ? adopted : {});
|
|
11
|
+
return {
|
|
12
|
+
accessToken: requiredText("accessToken", accessToken),
|
|
13
|
+
refreshToken: optionalText("refreshToken", refreshToken),
|
|
14
|
+
expiresIn: expiresInSeconds(expiresIn),
|
|
15
|
+
profile: checkedReference("profile", profile),
|
|
16
|
+
project: project === undefined ? NO_PROJECT : checkedReference("project", project),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function reject(problem) {
|
|
20
|
+
throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)(`Cannot adopt the session: ${problem}.`));
|
|
21
|
+
}
|
|
22
|
+
const isText = (value) => typeof value === "string" && value !== "";
|
|
23
|
+
function requiredText(field, value) {
|
|
24
|
+
return isText(value) ? value : reject(`${field} must be a non-empty string`);
|
|
25
|
+
}
|
|
26
|
+
function optionalText(field, value) {
|
|
27
|
+
return value === undefined || value === null ? null : requiredText(field, value);
|
|
28
|
+
}
|
|
29
|
+
function expiresInSeconds(value) {
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
return DUE_AT_ONCE_SECONDS;
|
|
32
|
+
}
|
|
33
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
34
|
+
? value
|
|
35
|
+
: reject("expiresIn must be a number of seconds, zero or more");
|
|
36
|
+
}
|
|
37
|
+
function checkedReference(field, value) {
|
|
38
|
+
const { reference, display = null } = (value !== null && value !== void 0 ? value : {});
|
|
39
|
+
if (typeof reference !== "string" || !FHIR_REFERENCE.test(reference)) {
|
|
40
|
+
reject(`${field}.reference must be a FHIR reference like ResourceType/id`);
|
|
41
|
+
}
|
|
42
|
+
if (display !== null && typeof display !== "string") {
|
|
43
|
+
reject(`${field}.display must be a string or null`);
|
|
44
|
+
}
|
|
45
|
+
return { reference, display };
|
|
46
|
+
}
|
|
@@ -10,6 +10,7 @@ import { Session } from "../auth/session";
|
|
|
10
10
|
import { UserSession } from "../auth/user-session";
|
|
11
11
|
import { HttpClient } from "../http/http-client";
|
|
12
12
|
import { RequestOptions } from "../http/transmit";
|
|
13
|
+
import { AdoptedSession } from "./auth/adopted-session";
|
|
13
14
|
import { AuthSessionsResource } from "./auth/auth-sessions-resource";
|
|
14
15
|
import { PatientRegistration, PractitionerRegistration, RegisterResult } from "./auth/registration";
|
|
15
16
|
import { SocialCredentials, SocialProvider } from "./auth/social-login";
|
|
@@ -96,6 +97,21 @@ export declare class AuthResource {
|
|
|
96
97
|
registerPractitioner(details: PractitionerRegistration, options?: RequestOptions): Promise<Session>;
|
|
97
98
|
/** Signs in with an Apple or Google token. Calls `POST auth/external/{provider}`. */
|
|
98
99
|
socialLogin<P extends SocialProvider>(provider: P, credential: SocialCredentials[P], options?: RequestOptions): Promise<Session>;
|
|
100
|
+
/**
|
|
101
|
+
* Continues a sign-in made elsewhere, such as the session an earlier client stored, as if the user had just signed in.
|
|
102
|
+
* It replaces any current session, is saved and announced like a login, and refreshes like one.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const session = await ovok.auth.adoptSession({
|
|
106
|
+
* accessToken,
|
|
107
|
+
* refreshToken,
|
|
108
|
+
* profile: { reference: "Patient/123" },
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* @throws OvokValidationError when the access token or profile reference is missing or malformed, or another field is invalid.
|
|
112
|
+
* @throws OvokConfigError when the client was created with `clientSecret`.
|
|
113
|
+
*/
|
|
114
|
+
adoptSession(adopted: AdoptedSession): Promise<Session>;
|
|
99
115
|
/** Returns the current session, or null when signed out. */
|
|
100
116
|
current(): Promise<Session | null>;
|
|
101
117
|
/** Fetches the signed-in user's profile. Calls `GET auth/me`. */
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AuthResource = exports.ME_PATH = void 0;
|
|
4
4
|
const generate_code_challenge_and_verifier_1 = require("../../client/auth/generate-code-challenge-and-verifier");
|
|
5
5
|
const ovok_errors_1 = require("../errors/ovok-errors");
|
|
6
|
+
const adopted_session_1 = require("./auth/adopted-session");
|
|
6
7
|
const auth_sessions_resource_1 = require("./auth/auth-sessions-resource");
|
|
7
8
|
const registration_1 = require("./auth/registration");
|
|
8
9
|
const social_login_1 = require("./auth/social-login");
|
|
@@ -39,7 +40,7 @@ class AuthResource {
|
|
|
39
40
|
const { profileType, email, password } = credentials;
|
|
40
41
|
const step = await this.http
|
|
41
42
|
.anonymous()
|
|
42
|
-
.post(loginPath(profileType, "start"), { email, password, codeChallenge }, options);
|
|
43
|
+
.post(loginPath(profileType, "start"), { email, password, codeChallenge, tenantCode: this.tenantCode }, options);
|
|
43
44
|
if (step.nextStep === "mfa") {
|
|
44
45
|
return { status: "mfa-required", challenge: { profileType, loginId: step.loginId, codeVerifier } };
|
|
45
46
|
}
|
|
@@ -51,7 +52,7 @@ class AuthResource {
|
|
|
51
52
|
const { profileType, loginId, codeVerifier } = challenge;
|
|
52
53
|
const step = await this.http
|
|
53
54
|
.anonymous()
|
|
54
|
-
.post(loginPath(profileType, "mfa"), { loginId, mfaToken: code }, options);
|
|
55
|
+
.post(loginPath(profileType, "mfa"), { loginId, mfaToken: code, tenantCode: this.tenantCode }, options);
|
|
55
56
|
return this.exchange(session, { profileType, sessionCode: step.sessionCode, codeVerifier }, options);
|
|
56
57
|
}
|
|
57
58
|
/** A project that routes the email to a clinician invitation signs no one in. */
|
|
@@ -81,6 +82,24 @@ class AuthResource {
|
|
|
81
82
|
const path = (0, social_login_1.socialLoginPath)(provider, this.socialLoginClientId(), internalId);
|
|
82
83
|
return session.begin(await this.http.anonymous().post(path, providerResult, options));
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Continues a sign-in made elsewhere, such as the session an earlier client stored, as if the user had just signed in.
|
|
87
|
+
* It replaces any current session, is saved and announced like a login, and refreshes like one.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const session = await ovok.auth.adoptSession({
|
|
91
|
+
* accessToken,
|
|
92
|
+
* refreshToken,
|
|
93
|
+
* profile: { reference: "Patient/123" },
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* @throws OvokValidationError when the access token or profile reference is missing or malformed, or another field is invalid.
|
|
97
|
+
* @throws OvokConfigError when the client was created with `clientSecret`.
|
|
98
|
+
*/
|
|
99
|
+
async adoptSession(adopted) {
|
|
100
|
+
const session = this.userSession();
|
|
101
|
+
return session.begin((0, adopted_session_1.loginTokensFromAdopted)(adopted));
|
|
102
|
+
}
|
|
84
103
|
/** Returns the current session, or null when signed out. */
|
|
85
104
|
async current() {
|
|
86
105
|
return this.session === null ? null : this.session.current();
|
|
@@ -4,6 +4,8 @@ import { RequestOptions } from "../../http/transmit";
|
|
|
4
4
|
import { CmsReadParams } from "./cms-delivery";
|
|
5
5
|
import { CmsDocumentsResource } from "./cms-documents-resource";
|
|
6
6
|
import { ReleaseNotesResource } from "./release-notes-resource";
|
|
7
|
+
/** 25,000 documents: far beyond any real collection, so reaching it means the CMS never ends its pages. */
|
|
8
|
+
export declare const MAX_TRANSLATION_PAGES = 500;
|
|
7
9
|
/**
|
|
8
10
|
* Published CMS content: documents, legal pages, release notes and translations. Calls routes under `v1/public/cms`.
|
|
9
11
|
*
|
|
@@ -18,7 +20,12 @@ export declare class CmsResource {
|
|
|
18
20
|
constructor(http: HttpClient, tenantCode: string);
|
|
19
21
|
/** "terms-and-conditions", "data-privacy", …: readable before sign-in. */
|
|
20
22
|
legalPage(slug: string, params?: CmsReadParams, options?: RequestOptions): Promise<OvokCmsDocument>;
|
|
21
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The `translations` collection as one tree, readable before sign-in; nothing is kept on the device.
|
|
25
|
+
* Reads every page of the collection.
|
|
26
|
+
*
|
|
27
|
+
* @throws OvokError with code `cms_translations_page_limit` when the CMS is still offering pages after 500, rather than return a partial tree.
|
|
28
|
+
*/
|
|
22
29
|
translations(locale?: string, options?: RequestOptions): Promise<OvokTranslations>;
|
|
23
30
|
private translationDocuments;
|
|
24
31
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CmsResource = void 0;
|
|
3
|
+
exports.CmsResource = exports.MAX_TRANSLATION_PAGES = void 0;
|
|
4
|
+
const ovok_errors_1 = require("../../errors/ovok-errors");
|
|
4
5
|
const cms_delivery_1 = require("./cms-delivery");
|
|
5
6
|
const cms_documents_resource_1 = require("./cms-documents-resource");
|
|
6
7
|
const release_notes_resource_1 = require("./release-notes-resource");
|
|
@@ -9,7 +10,9 @@ const LEGAL_PAGES = "legal-pages";
|
|
|
9
10
|
const TRANSLATIONS = "translations";
|
|
10
11
|
const FIRST_PAGE = 1;
|
|
11
12
|
const LARGEST_PAGE_SIZE = 50;
|
|
12
|
-
|
|
13
|
+
/** 25,000 documents: far beyond any real collection, so reaching it means the CMS never ends its pages. */
|
|
14
|
+
exports.MAX_TRANSLATION_PAGES = 500;
|
|
15
|
+
const TRANSLATION_PAGE_LIMIT_CODE = "cms_translations_page_limit";
|
|
13
16
|
/**
|
|
14
17
|
* Published CMS content: documents, legal pages, release notes and translations. Calls routes under `v1/public/cms`.
|
|
15
18
|
*
|
|
@@ -25,19 +28,29 @@ class CmsResource {
|
|
|
25
28
|
legalPage(slug, params = {}, options) {
|
|
26
29
|
return this.documents.retrieve(LEGAL_PAGES, slug, params, options);
|
|
27
30
|
}
|
|
28
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The `translations` collection as one tree, readable before sign-in; nothing is kept on the device.
|
|
33
|
+
* Reads every page of the collection.
|
|
34
|
+
*
|
|
35
|
+
* @throws OvokError with code `cms_translations_page_limit` when the CMS is still offering pages after 500, rather than return a partial tree.
|
|
36
|
+
*/
|
|
29
37
|
async translations(locale, options) {
|
|
30
38
|
return (0, translation_tree_1.translationTree)(await this.translationDocuments(locale, options));
|
|
31
39
|
}
|
|
32
40
|
async translationDocuments(locale, options) {
|
|
33
41
|
const documents = [];
|
|
34
|
-
for (let page = FIRST_PAGE
|
|
42
|
+
for (let page = FIRST_PAGE; page <= exports.MAX_TRANSLATION_PAGES; page++) {
|
|
35
43
|
const params = { locale, page, limit: LARGEST_PAGE_SIZE };
|
|
36
44
|
const result = await this.delivery.listPage(TRANSLATIONS, params, options);
|
|
37
45
|
documents.push(...result.docs);
|
|
38
|
-
|
|
46
|
+
if (!result.hasNextPage) {
|
|
47
|
+
return documents;
|
|
48
|
+
}
|
|
39
49
|
}
|
|
40
|
-
|
|
50
|
+
throw new ovok_errors_1.OvokError({
|
|
51
|
+
...(0, ovok_errors_1.detailsFor)(`The CMS still had translation pages after ${exports.MAX_TRANSLATION_PAGES}; none were returned.`),
|
|
52
|
+
code: TRANSLATION_PAGE_LIMIT_CODE,
|
|
53
|
+
});
|
|
41
54
|
}
|
|
42
55
|
}
|
|
43
56
|
exports.CmsResource = CmsResource;
|