@ovok/core 0.4.8 → 0.4.10
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 +23 -5
- package/dist/client/cms/methods.d.ts +12 -3
- package/dist/client/cms/methods.js +76 -10
- package/dist/client/cms/types.d.ts +18 -3
- package/dist/client/observation/services/uric-acid-service.js +3 -0
- package/dist/client/observation/types/UrineAnalytes.d.ts +2 -2
- package/dist/client/observation/types/UrineAnalytes.js +22 -1
- package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +3 -0
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/hooks/cms-hooks.d.ts +6 -1
- package/dist/hooks/cms-hooks.js +18 -6
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -379,14 +379,17 @@ The backend allows three kinds of read:
|
|
|
379
379
|
|
|
380
380
|
- **Signed in**: the session reads its own tenant's content with no API key. Naming another
|
|
381
381
|
tenant without a key is refused with 403.
|
|
382
|
-
- **Legal pages**: no key and no session are needed. Before sign-in, pass the
|
|
382
|
+
- **Legal pages and translations**: no key and no session are needed. Before sign-in, pass the
|
|
383
|
+
tenant's `tenantCode`.
|
|
383
384
|
- **Anything else**: it needs the public API key, and is a 401 without one. This SDK does not
|
|
384
385
|
send a key.
|
|
385
386
|
|
|
386
|
-
Signed out,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
Signed out, a read rejects with `SignInRequiredError` (`isSignInRequiredError(error)`) before
|
|
388
|
+
any request is sent, unless it passes `allowSignedOut: true` and a `tenantCode`. `getLegalPage`,
|
|
389
|
+
`getTranslations` and their hooks turn `allowSignedOut` on by default; pass it yourself only for
|
|
390
|
+
another collection the backend serves without a key or session. This matters because
|
|
391
|
+
`MedplumClient` answers any 401 by clearing its storage and calling `onUnauthenticated`. A hook
|
|
392
|
+
that rendered before sign-in needs `reload()` once the session exists.
|
|
390
393
|
|
|
391
394
|
`locale` takes an app language or a CMS locale (`en`, `de`, `fr`, `es`). `toCmsLocale` maps
|
|
392
395
|
`de-CH` to `de`, and a language the CMS does not carry to `en`. The hooks default to the
|
|
@@ -395,6 +398,21 @@ maps to the same CMS locale does not read again. Lists use the CMS envelope (`Ov
|
|
|
395
398
|
`prevPage` and `nextPage` are `null` at either end, and `limit` is at most 50. Release notes are
|
|
396
399
|
newest first unless `sort` says otherwise. The backend merges in a shared tenant's documents.
|
|
397
400
|
|
|
401
|
+
### Translations
|
|
402
|
+
|
|
403
|
+
`getTranslations()` and `useTranslations()` read the whole `translations` collection as one tree
|
|
404
|
+
(`OvokTranslations`): each document's `slug` is a group, and each of its `strings` rows puts its
|
|
405
|
+
`value` at its `key`, nested at the dots.
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
const { data: translations } = useTranslations({ tenantCode });
|
|
409
|
+
// { "sign-in": { title: "Anmelden", errors: { required: "Pflichtfeld" } } }
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
The CMS answers a row with no text in the locale in English. A row with no text at all, and a row
|
|
413
|
+
whose key is taken (or clashes with a nested key), are left out. Nothing is kept on the device, so
|
|
414
|
+
offline the app shows its own and the SDK's built-in text.
|
|
415
|
+
|
|
398
416
|
These routes ship with an Ovok Core backend release. Deploy that backend before releasing this
|
|
399
417
|
SDK version.
|
|
400
418
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { OvokClient } from "../ovok-client";
|
|
2
|
-
import { OvokCmsDocument, OvokCmsListOptions, OvokCmsOptions, OvokCmsPage } from "./types";
|
|
2
|
+
import { OvokCmsDocument, OvokCmsListOptions, OvokCmsOptions, OvokCmsPage, OvokTranslations } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* A published document of a CMS collection by slug, the shared tenant's when
|
|
5
|
-
* the tenant has none of its own. Signed out,
|
|
6
|
-
* `
|
|
5
|
+
* the tenant has none of its own. Signed out, it is read only with
|
|
6
|
+
* `allowSignedOut` and a `tenantCode`; otherwise it rejects with
|
|
7
|
+
* `SignInRequiredError`.
|
|
7
8
|
*/
|
|
8
9
|
export declare function getCmsDocument<T extends object = OvokCmsDocument>(this: OvokClient, collection: string, slug: string, options?: OvokCmsOptions): Promise<T>;
|
|
9
10
|
/**
|
|
@@ -15,3 +16,11 @@ export declare function listCmsDocuments<T extends object = OvokCmsDocument>(thi
|
|
|
15
16
|
export declare function getLegalPage(this: OvokClient, slug: string, options?: OvokCmsOptions): Promise<OvokCmsDocument>;
|
|
16
17
|
/** Release notes, newest first unless `sort` says otherwise. Needs a session. */
|
|
17
18
|
export declare function listReleaseNotes(this: OvokClient, options?: OvokCmsListOptions): Promise<OvokCmsPage>;
|
|
19
|
+
/**
|
|
20
|
+
* The `translations` collection as one tree: a group per document slug, and
|
|
21
|
+
* each of its `strings` rows' `value` at its `key`, nested at the dots. Rows
|
|
22
|
+
* without a text, and rows whose path is taken, are left out. Readable before
|
|
23
|
+
* sign-in with a tenant code. Nothing is kept on the device: on native the
|
|
24
|
+
* client's storage is SecureStore, read whole at every launch.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getTranslations(this: OvokClient, options?: OvokCmsOptions): Promise<OvokTranslations>;
|
|
@@ -4,6 +4,7 @@ exports.getCmsDocument = getCmsDocument;
|
|
|
4
4
|
exports.listCmsDocuments = listCmsDocuments;
|
|
5
5
|
exports.getLegalPage = getLegalPage;
|
|
6
6
|
exports.listReleaseNotes = listReleaseNotes;
|
|
7
|
+
exports.getTranslations = getTranslations;
|
|
7
8
|
const sign_in_required_error_1 = require("../errors/sign-in-required-error");
|
|
8
9
|
const locale_1 = require("./locale");
|
|
9
10
|
const collectionPath = (collection) => `/v1/public/cms/collections/${encodeURIComponent(collection)}/items`;
|
|
@@ -31,25 +32,27 @@ const cmsQuery = ({ locale, tenantCode, environment, page, limit, sort }) => {
|
|
|
31
32
|
return query ? `?${query}` : "";
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
34
|
-
* Signed out, the backend serves only
|
|
35
|
-
* other read is a 401, which MedplumClient answers by clearing its
|
|
36
|
-
*
|
|
35
|
+
* Signed out, the backend serves only a few collections, read by tenant code;
|
|
36
|
+
* any other read is a 401, which MedplumClient answers by clearing its
|
|
37
|
+
* storage. So a signed-out read is refused here, before a request, unless it
|
|
38
|
+
* opts in with `allowSignedOut` and names its tenant.
|
|
37
39
|
*/
|
|
38
|
-
const assertReadable = (client, collection, tenantCode) => {
|
|
39
|
-
if (!client.getActiveLogin() && !(
|
|
40
|
+
const assertReadable = (client, collection, { allowSignedOut, tenantCode }) => {
|
|
41
|
+
if (!client.getActiveLogin() && !(allowSignedOut && tenantCode)) {
|
|
40
42
|
throw new sign_in_required_error_1.SignInRequiredError(`Sign in to read the CMS collection "${collection}".`);
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
/**
|
|
44
46
|
* A published document of a CMS collection by slug, the shared tenant's when
|
|
45
|
-
* the tenant has none of its own. Signed out,
|
|
46
|
-
* `
|
|
47
|
+
* the tenant has none of its own. Signed out, it is read only with
|
|
48
|
+
* `allowSignedOut` and a `tenantCode`; otherwise it rejects with
|
|
49
|
+
* `SignInRequiredError`.
|
|
47
50
|
*/
|
|
48
51
|
async function getCmsDocument(collection, slug, options = {}) {
|
|
49
52
|
if (!slug) {
|
|
50
53
|
throw new Error("A CMS document read needs a slug.");
|
|
51
54
|
}
|
|
52
|
-
assertReadable(this, collection, options
|
|
55
|
+
assertReadable(this, collection, options);
|
|
53
56
|
return this.get(`${collectionPath(collection)}/${encodeURIComponent(slug)}${cmsQuery(options)}`);
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
@@ -57,15 +60,78 @@ async function getCmsDocument(collection, slug, options = {}) {
|
|
|
57
60
|
* tenant's. Signed out, as `getCmsDocument`.
|
|
58
61
|
*/
|
|
59
62
|
async function listCmsDocuments(collection, options = {}) {
|
|
60
|
-
assertReadable(this, collection, options
|
|
63
|
+
assertReadable(this, collection, options);
|
|
61
64
|
return this.get(`${collectionPath(collection)}${cmsQuery(options)}`);
|
|
62
65
|
}
|
|
63
66
|
/** A legal page ("terms-and-conditions", "data-privacy", …). Readable before sign-in with a tenant code. */
|
|
64
67
|
function getLegalPage(slug, options = {}) {
|
|
65
|
-
|
|
68
|
+
var _a;
|
|
69
|
+
return this.getCmsDocument("legal-pages", slug, { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true });
|
|
66
70
|
}
|
|
67
71
|
/** Release notes, newest first unless `sort` says otherwise. Needs a session. */
|
|
68
72
|
function listReleaseNotes(options = {}) {
|
|
69
73
|
var _a;
|
|
70
74
|
return this.listCmsDocuments("release-notes", { ...options, sort: (_a = options.sort) !== null && _a !== void 0 ? _a : "-publishedAt" });
|
|
71
75
|
}
|
|
76
|
+
/** A translations read takes pages of 50 documents, the CMS's most, and at most this many. */
|
|
77
|
+
const MAX_TRANSLATION_PAGES = 20;
|
|
78
|
+
/** Keys that would reach a prototype instead of the tree. */
|
|
79
|
+
const UNSAFE_KEYS = ["__proto__", "constructor", "prototype"];
|
|
80
|
+
const isText = (value) => typeof value === "string" && value !== "";
|
|
81
|
+
const hasOwn = (tree, key) => Object.prototype.hasOwnProperty.call(tree, key);
|
|
82
|
+
/**
|
|
83
|
+
* Sets `text` at `path` unless something is in the way: a text where a group
|
|
84
|
+
* is needed, or anything where the text goes, so the first row wins. Keys are
|
|
85
|
+
* CMS input, so a path through a prototype key is skipped too.
|
|
86
|
+
*/
|
|
87
|
+
const setTranslation = (tree, path, text) => {
|
|
88
|
+
if (path.some((key) => UNSAFE_KEYS.includes(key))) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
let node = tree;
|
|
92
|
+
for (const key of path.slice(0, -1)) {
|
|
93
|
+
const next = hasOwn(node, key) ? node[key] : (node[key] = {});
|
|
94
|
+
if (typeof next === "string") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
node = next;
|
|
98
|
+
}
|
|
99
|
+
const leaf = path[path.length - 1];
|
|
100
|
+
if (!hasOwn(node, leaf)) {
|
|
101
|
+
node[leaf] = text;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/** Adds each document's `strings` rows under its slug; a row needs a key and a text. */
|
|
105
|
+
const addTranslations = (translations, docs) => {
|
|
106
|
+
for (const { slug, strings } of docs) {
|
|
107
|
+
if (!isText(slug) || !Array.isArray(strings)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
for (const row of strings) {
|
|
111
|
+
const { key, value } = (row !== null && row !== void 0 ? row : {});
|
|
112
|
+
if (isText(key) && isText(value)) {
|
|
113
|
+
setTranslation(translations, [slug, ...key.split(".")], value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The `translations` collection as one tree: a group per document slug, and
|
|
120
|
+
* each of its `strings` rows' `value` at its `key`, nested at the dots. Rows
|
|
121
|
+
* without a text, and rows whose path is taken, are left out. Readable before
|
|
122
|
+
* sign-in with a tenant code. Nothing is kept on the device: on native the
|
|
123
|
+
* client's storage is SecureStore, read whole at every launch.
|
|
124
|
+
*/
|
|
125
|
+
async function getTranslations(options = {}) {
|
|
126
|
+
var _a;
|
|
127
|
+
const readOptions = { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true };
|
|
128
|
+
const translations = {};
|
|
129
|
+
for (let page = 1; page <= MAX_TRANSLATION_PAGES; page++) {
|
|
130
|
+
const { docs, hasNextPage } = await this.listCmsDocuments("translations", { ...readOptions, page, limit: 50 });
|
|
131
|
+
addTranslations(translations, docs);
|
|
132
|
+
if (!hasNextPage) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return translations;
|
|
137
|
+
}
|
|
@@ -40,13 +40,28 @@ export type OvokCmsOptions = {
|
|
|
40
40
|
*/
|
|
41
41
|
locale?: string;
|
|
42
42
|
/**
|
|
43
|
-
* The tenant's code. Signed out,
|
|
44
|
-
*
|
|
45
|
-
*
|
|
43
|
+
* The tenant's code. Signed out, a read needs this and `allowSignedOut`.
|
|
44
|
+
* Signed in, the session's own tenant is read; naming another tenant is
|
|
45
|
+
* refused (403).
|
|
46
46
|
*/
|
|
47
47
|
tenantCode?: string;
|
|
48
48
|
/** Omitted, the backend's own. */
|
|
49
49
|
environment?: "dev" | "staging" | "prod";
|
|
50
|
+
/**
|
|
51
|
+
* Read signed out. Only for collections the backend serves without a key or
|
|
52
|
+
* session: legal pages and translations, which turn it on by default. It
|
|
53
|
+
* needs `tenantCode`; without both, a signed-out read is refused before a
|
|
54
|
+
* request, because a 401 makes MedplumClient clear its storage.
|
|
55
|
+
*/
|
|
56
|
+
allowSignedOut?: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** Translation keys, nested at their dots, down to the text in one locale. */
|
|
59
|
+
export type OvokTranslationTree = {
|
|
60
|
+
[key: string]: string | OvokTranslationTree;
|
|
61
|
+
};
|
|
62
|
+
/** The `translations` collection: a tree per group, named by the document's slug ("sign-in"). */
|
|
63
|
+
export type OvokTranslations = {
|
|
64
|
+
[group: string]: OvokTranslationTree;
|
|
50
65
|
};
|
|
51
66
|
export type OvokCmsListOptions = OvokCmsOptions & {
|
|
52
67
|
page?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type UrineAnalyteKey = "uro" | "bil" | "ket" | "glu" | "pro" | "ph" | "bld" | "nit" | "leu" | "sg" | "vc";
|
|
1
|
+
export type UrineAnalyteKey = "uro" | "bil" | "ket" | "glu" | "pro" | "ph" | "bld" | "nit" | "leu" | "sg" | "vc" | "mal" | "cr" | "uca";
|
|
2
2
|
export type UrineAnalyteDefinition = {
|
|
3
3
|
key: UrineAnalyteKey;
|
|
4
4
|
code: string;
|
|
@@ -9,7 +9,7 @@ export type UrineAnalyteDefinition = {
|
|
|
9
9
|
unitCode?: string;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* LOINC mappings for the
|
|
12
|
+
* LOINC mappings for the analytes returned by Contec's BC401 strips.
|
|
13
13
|
* These are exported so Native declarations and consuming apps can describe
|
|
14
14
|
* the same analytes without maintaining a second, drifting table.
|
|
15
15
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.URINE_ANALYTE_DEFINITIONS = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* LOINC mappings for the
|
|
5
|
+
* LOINC mappings for the analytes returned by Contec's BC401 strips.
|
|
6
6
|
* These are exported so Native declarations and consuming apps can describe
|
|
7
7
|
* the same analytes without maintaining a second, drifting table.
|
|
8
8
|
*/
|
|
@@ -71,4 +71,25 @@ exports.URINE_ANALYTE_DEFINITIONS = [
|
|
|
71
71
|
unit: "mg/dL",
|
|
72
72
|
unitCode: "mg/dL",
|
|
73
73
|
},
|
|
74
|
+
{
|
|
75
|
+
key: "mal",
|
|
76
|
+
code: "14957-5",
|
|
77
|
+
display: "Microalbumin",
|
|
78
|
+
unit: "mg/dL",
|
|
79
|
+
unitCode: "mg/dL",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
key: "cr",
|
|
83
|
+
code: "2161-8",
|
|
84
|
+
display: "Creatinine",
|
|
85
|
+
unit: "mg/dL",
|
|
86
|
+
unitCode: "mg/dL",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: "uca",
|
|
90
|
+
code: "3086-6",
|
|
91
|
+
display: "Urate",
|
|
92
|
+
unit: "mg/dL",
|
|
93
|
+
unitCode: "mg/dL",
|
|
94
|
+
},
|
|
74
95
|
];
|
|
@@ -14,6 +14,9 @@ export type UrineAnalyzeMeasurement = Measurement & {
|
|
|
14
14
|
leu?: number;
|
|
15
15
|
sg?: number;
|
|
16
16
|
vc?: number;
|
|
17
|
+
mal?: number;
|
|
18
|
+
cr?: number;
|
|
19
|
+
uca?: number;
|
|
17
20
|
urineValues: UrineAnalysisValue[];
|
|
18
21
|
/** Time at which the analyzer recorded the strip. */
|
|
19
22
|
recordedAt?: Date;
|
|
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
|
|
|
48
48
|
description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
|
|
49
49
|
software: {
|
|
50
50
|
name: "@ovok/core",
|
|
51
|
-
version: "0.4.
|
|
51
|
+
version: "0.4.10",
|
|
52
52
|
},
|
|
53
53
|
fhirVersion: "4.0.1",
|
|
54
54
|
format: ["json"],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OvokCmsDocument, OvokCmsListOptions, OvokCmsOptions, OvokCmsPage } from "../client/cms";
|
|
1
|
+
import { OvokCmsDocument, OvokCmsListOptions, OvokCmsOptions, OvokCmsPage, OvokTranslations } from "../client/cms";
|
|
2
2
|
import { OvokRequestState } from "./api-hooks";
|
|
3
3
|
/**
|
|
4
4
|
* A published CMS document by slug, in `options.locale` or else the runtime's
|
|
@@ -11,3 +11,8 @@ export declare const useCmsDocuments: <T extends object = OvokCmsDocument>(colle
|
|
|
11
11
|
export declare const useLegalPage: (slug: string | undefined, options?: OvokCmsOptions) => OvokRequestState<OvokCmsDocument>;
|
|
12
12
|
/** Release notes, newest first unless `sort` says otherwise. Needs a session. */
|
|
13
13
|
export declare const useReleaseNotes: (options?: OvokCmsListOptions) => OvokRequestState<OvokCmsPage>;
|
|
14
|
+
/**
|
|
15
|
+
* The `translations` collection as one tree, in `options.locale` or else the
|
|
16
|
+
* runtime's language; with `tenantCode`, readable before sign-in.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useTranslations: (options?: OvokCmsOptions) => OvokRequestState<OvokTranslations>;
|
package/dist/hooks/cms-hooks.js
CHANGED
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = void 0;
|
|
37
|
+
exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = void 0;
|
|
38
38
|
const React = __importStar(require("react"));
|
|
39
39
|
const cms_1 = require("../client/cms");
|
|
40
40
|
const api_hooks_1 = require("./api-hooks");
|
|
@@ -45,24 +45,36 @@ const index_1 = require("./index");
|
|
|
45
45
|
*/
|
|
46
46
|
const useCmsDocument = (collection, slug, options = {}) => {
|
|
47
47
|
const client = (0, index_1.useClient)();
|
|
48
|
-
const { tenantCode, environment } = options;
|
|
48
|
+
const { tenantCode, environment, allowSignedOut } = options;
|
|
49
49
|
const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
|
|
50
|
-
const load = React.useCallback(() => client.getCmsDocument(collection, slug, { locale, tenantCode, environment }), [client, collection, slug, locale, tenantCode, environment]);
|
|
50
|
+
const load = React.useCallback(() => client.getCmsDocument(collection, slug, { locale, tenantCode, environment, allowSignedOut }), [client, collection, slug, locale, tenantCode, environment, allowSignedOut]);
|
|
51
51
|
return (0, api_hooks_1.useOvokRequest)(load, Boolean(slug));
|
|
52
52
|
};
|
|
53
53
|
exports.useCmsDocument = useCmsDocument;
|
|
54
54
|
/** A page of a CMS collection, in `options.locale` or else the runtime's language. */
|
|
55
55
|
const useCmsDocuments = (collection, options = {}) => {
|
|
56
56
|
const client = (0, index_1.useClient)();
|
|
57
|
-
const { tenantCode, environment, page, limit, sort } = options;
|
|
57
|
+
const { tenantCode, environment, allowSignedOut, page, limit, sort } = options;
|
|
58
58
|
const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
|
|
59
|
-
const load = React.useCallback(() => client.listCmsDocuments(collection, { locale, tenantCode, environment, page, limit, sort }), [client, collection, locale, tenantCode, environment, page, limit, sort]);
|
|
59
|
+
const load = React.useCallback(() => client.listCmsDocuments(collection, { locale, tenantCode, environment, allowSignedOut, page, limit, sort }), [client, collection, locale, tenantCode, environment, allowSignedOut, page, limit, sort]);
|
|
60
60
|
return (0, api_hooks_1.useOvokRequest)(load);
|
|
61
61
|
};
|
|
62
62
|
exports.useCmsDocuments = useCmsDocuments;
|
|
63
63
|
/** A legal page by slug; with `tenantCode`, readable before sign-in. */
|
|
64
|
-
const useLegalPage = (slug, options = {}) => (0, exports.useCmsDocument)("legal-pages", slug, options);
|
|
64
|
+
const useLegalPage = (slug, options = {}) => { var _a; return (0, exports.useCmsDocument)("legal-pages", slug, { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true }); };
|
|
65
65
|
exports.useLegalPage = useLegalPage;
|
|
66
66
|
/** Release notes, newest first unless `sort` says otherwise. Needs a session. */
|
|
67
67
|
const useReleaseNotes = (options = {}) => { var _a; return (0, exports.useCmsDocuments)("release-notes", { ...options, sort: (_a = options.sort) !== null && _a !== void 0 ? _a : "-publishedAt" }); };
|
|
68
68
|
exports.useReleaseNotes = useReleaseNotes;
|
|
69
|
+
/**
|
|
70
|
+
* The `translations` collection as one tree, in `options.locale` or else the
|
|
71
|
+
* runtime's language; with `tenantCode`, readable before sign-in.
|
|
72
|
+
*/
|
|
73
|
+
const useTranslations = (options = {}) => {
|
|
74
|
+
const client = (0, index_1.useClient)();
|
|
75
|
+
const { tenantCode, environment, allowSignedOut } = options;
|
|
76
|
+
const locale = React.useMemo(() => (0, cms_1.toCmsLocale)(options.locale || (0, cms_1.defaultCmsLocale)()), [options.locale]);
|
|
77
|
+
const load = React.useCallback(() => client.getTranslations({ locale, tenantCode, environment, allowSignedOut }), [client, locale, tenantCode, environment, allowSignedOut]);
|
|
78
|
+
return (0, api_hooks_1.useOvokRequest)(load);
|
|
79
|
+
};
|
|
80
|
+
exports.useTranslations = useTranslations;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { OvokMutationState, OvokRequestState } from "./api-hooks";
|
|
|
11
11
|
export { useConsentSignature, useContent, useCreateVideoCallAppointment, useCreateVideoCallUserAccess, useDocuments, useVideoCallAccess, useVideoCallAppointments, } from "./experience-hooks";
|
|
12
12
|
export { useI18nextDocument, useLocales, useLocalizations, useUpdateI18nextDocument, useUpdateLocalization, useUpdateProjectTextSetting, } from "./platform-hooks";
|
|
13
13
|
export { useEmailTemplates } from "./email-hooks";
|
|
14
|
-
export { useCmsDocument, useCmsDocuments, useLegalPage, useReleaseNotes, } from "./cms-hooks";
|
|
14
|
+
export { useCmsDocument, useCmsDocuments, useLegalPage, useReleaseNotes, useTranslations, } from "./cms-hooks";
|
|
15
15
|
export { useAcceptInvite, useInvitePatient, useInvitePractitioner, } from "./invites-hooks";
|
|
16
16
|
export { useCurrentPatientProfile, useExtractQuestionnaireObservations, usePatientAppointments, usePatientCarePlans, usePatientDevices, usePatientDeviceTelemetry, usePatientDeviceTelemetryHistory, usePatientMeasurement, usePatientMeasurementHistory, usePatientDashboard, usePatientLatestObservations, usePatientNotifications, usePatientQuestionnaireResponses, usePatientQuestionnaires, usePatientSchedules, usePatientSlots, usePopulateQuestionnaire, useSubmitQuestionnaireResponse, } from "./patient-hooks";
|
|
17
17
|
export { useCreatePatientSharingInvite, usePatientSharing, usePatientSharingSettings, useRedeemPatientSharingInvite, useRevokePatientSharing, useUpdatePatientSharingSettings, } from "./patient-sharing-hooks";
|
package/dist/hooks/index.js
CHANGED
|
@@ -34,8 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
38
|
-
exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDeviceTelemetryHistory = exports.usePatientDeviceTelemetry = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = void 0;
|
|
37
|
+
exports.useAcceptInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useEmailTemplates = exports.useUpdateProjectTextSetting = exports.useUpdateLocalization = exports.useUpdateI18nextDocument = exports.useLocalizations = exports.useLocales = exports.useI18nextDocument = exports.useVideoCallAppointments = exports.useVideoCallAccess = exports.useDocuments = exports.useCreateVideoCallUserAccess = exports.useCreateVideoCallAppointment = exports.useContent = exports.useConsentSignature = exports.useRecentSlimNotifications = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = exports.useSlimNotifications = exports.useSlimDevices = exports.useSlimDeviceTelemetry = exports.useAdministeredProjects = exports.useUrineTests = exports.useSaveMeasurement = exports.useObservations = exports.useEcgRecording = exports.observationsToMeasurements = exports.OvokProvider = exports.useClient = exports.useCachedBinaryUrl = exports.reactContext = exports.useSubscription = exports.useSearchResources = exports.useSearchOne = exports.useSearch = exports.useResource = exports.usePrevious = exports.useMedplumProfile = exports.useMedplumNavigate = exports.useMedplumContext = void 0;
|
|
38
|
+
exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDeviceTelemetryHistory = exports.usePatientDeviceTelemetry = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = void 0;
|
|
39
39
|
/*
|
|
40
40
|
* The only React-dependent module in the package.
|
|
41
41
|
*
|
|
@@ -112,6 +112,7 @@ Object.defineProperty(exports, "useCmsDocument", { enumerable: true, get: functi
|
|
|
112
112
|
Object.defineProperty(exports, "useCmsDocuments", { enumerable: true, get: function () { return cms_hooks_1.useCmsDocuments; } });
|
|
113
113
|
Object.defineProperty(exports, "useLegalPage", { enumerable: true, get: function () { return cms_hooks_1.useLegalPage; } });
|
|
114
114
|
Object.defineProperty(exports, "useReleaseNotes", { enumerable: true, get: function () { return cms_hooks_1.useReleaseNotes; } });
|
|
115
|
+
Object.defineProperty(exports, "useTranslations", { enumerable: true, get: function () { return cms_hooks_1.useTranslations; } });
|
|
115
116
|
var invites_hooks_1 = require("./invites-hooks");
|
|
116
117
|
Object.defineProperty(exports, "useAcceptInvite", { enumerable: true, get: function () { return invites_hooks_1.useAcceptInvite; } });
|
|
117
118
|
Object.defineProperty(exports, "useInvitePatient", { enumerable: true, get: function () { return invites_hooks_1.useInvitePatient; } });
|