@ovok/core 0.4.49 → 0.4.51
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/cms/locale.d.ts +3 -3
- package/dist/client/cms/locale.js +14 -2
- package/dist/client/observation/fhir-systems.d.ts +12 -0
- package/dist/client/observation/fhir-systems.js +13 -1
- package/dist/client/observation/observation-groups.d.ts +4 -3
- package/dist/client/observation/observation-groups.js +8 -4
- package/dist/client/observation/series.d.ts +23 -3
- package/dist/client/observation/series.js +22 -4
- package/dist/client/observation/services/ecg-observation-fragments.js +1 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +2 -0
- package/dist/client/offline/offline-measurement-queue.d.ts +3 -1
- package/dist/client/offline/offline-measurement-queue.js +2 -1
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/next/config/ovok-config.d.ts +18 -0
- package/dist/next/config/settings.js +10 -1
- package/dist/next/errors/ovok-errors.d.ts +7 -0
- package/dist/next/errors/ovok-errors.js +9 -1
- package/dist/next/http/transmit.js +4 -2
- package/dist/next/index.d.ts +15 -1
- package/dist/next/index.js +18 -1
- package/dist/next/logging/ovok-logger.d.ts +26 -0
- package/dist/next/logging/ovok-logger.js +10 -0
- package/dist/next/outbox/entry-observation.d.ts +3 -0
- package/dist/next/outbox/entry-observation.js +6 -0
- package/dist/next/outbox/failure-policy.d.ts +45 -0
- package/dist/next/outbox/failure-policy.js +92 -0
- package/dist/next/outbox/group-links.d.ts +19 -0
- package/dist/next/outbox/group-links.js +65 -0
- package/dist/next/outbox/indexed-db-outbox-store.d.ts +38 -0
- package/dist/next/outbox/indexed-db-outbox-store.js +90 -0
- package/dist/next/outbox/item-settler.d.ts +37 -0
- package/dist/next/outbox/item-settler.js +49 -0
- package/dist/next/outbox/legacy-queue-import.d.ts +7 -0
- package/dist/next/outbox/legacy-queue-import.js +50 -0
- package/dist/next/outbox/memory-outbox-store.d.ts +22 -0
- package/dist/next/outbox/memory-outbox-store.js +40 -0
- package/dist/next/outbox/outbox-items.d.ts +17 -0
- package/dist/next/outbox/outbox-items.js +89 -0
- package/dist/next/outbox/outbox-queries.d.ts +4 -0
- package/dist/next/outbox/outbox-queries.js +9 -0
- package/dist/next/outbox/outbox-resource.d.ts +73 -0
- package/dist/next/outbox/outbox-resource.js +170 -0
- package/dist/next/outbox/outbox-runner.d.ts +56 -0
- package/dist/next/outbox/outbox-runner.js +179 -0
- package/dist/next/outbox/outbox-snapshot.d.ts +3 -0
- package/dist/next/outbox/outbox-snapshot.js +40 -0
- package/dist/next/outbox/outbox-store.d.ts +21 -0
- package/dist/next/outbox/outbox-store.js +2 -0
- package/dist/next/outbox/outbox-triggers.d.ts +30 -0
- package/dist/next/outbox/outbox-triggers.js +38 -0
- package/dist/next/outbox/outbox-types.d.ts +138 -0
- package/dist/next/outbox/outbox-types.js +2 -0
- package/dist/next/outbox/outcome-handlers.d.ts +30 -0
- package/dist/next/outbox/outcome-handlers.js +50 -0
- package/dist/next/outbox/pending-saves.d.ts +6 -0
- package/dist/next/outbox/pending-saves.js +18 -0
- package/dist/next/outbox/request-budget.d.ts +10 -0
- package/dist/next/outbox/request-budget.js +22 -0
- package/dist/next/outbox/request-planner.d.ts +5 -0
- package/dist/next/outbox/request-planner.js +39 -0
- package/dist/next/outbox/runner-state.d.ts +34 -0
- package/dist/next/outbox/runner-state.js +61 -0
- package/dist/next/outbox/store-contract.d.ts +19 -0
- package/dist/next/outbox/store-contract.js +108 -0
- package/dist/next/outbox/wakeup.d.ts +11 -0
- package/dist/next/outbox/wakeup.js +34 -0
- package/dist/next/ovok.d.ts +3 -0
- package/dist/next/ovok.js +13 -2
- package/dist/next/react/index.d.ts +11 -1
- package/dist/next/react/index.js +15 -1
- package/dist/next/resources/measurements/measurement-sender.d.ts +27 -0
- package/dist/next/resources/measurements/measurement-sender.js +66 -0
- package/dist/next/resources/measurements/measurements-resource.d.ts +36 -25
- package/dist/next/resources/measurements/measurements-resource.js +62 -65
- package/dist/next/resources/measurements/observation-builder.js +6 -3
- package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +12 -14
- package/dist/next/resources/measurements/offline-measurement-queue.d.ts +4 -23
- package/dist/next/resources/measurements/offline-measurement-queue.js +18 -143
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Ovok CMS locales
|
|
2
|
+
* The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
|
|
3
3
|
*/
|
|
4
|
-
export declare const OVOK_CMS_LOCALES: readonly ["en", "de", "
|
|
4
|
+
export declare const OVOK_CMS_LOCALES: readonly ["en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm", "bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee", "el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv", "ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it", "iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky", "la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt", "my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa", "pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl", "sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn", "to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo", "za", "zh", "zu"];
|
|
5
5
|
/**
|
|
6
|
-
* One of the supported CMS locales
|
|
6
|
+
* One of the supported CMS locales, an ISO 639-1 code such as `en`, `de` or `zh`.
|
|
7
7
|
*/
|
|
8
8
|
export type OvokCmsLocale = (typeof OVOK_CMS_LOCALES)[number];
|
|
9
9
|
/**
|
|
@@ -4,9 +4,21 @@ exports.OVOK_CMS_DEFAULT_LOCALE = exports.OVOK_CMS_LOCALES = void 0;
|
|
|
4
4
|
exports.toCmsLocale = toCmsLocale;
|
|
5
5
|
exports.defaultCmsLocale = defaultCmsLocale;
|
|
6
6
|
/**
|
|
7
|
-
* The Ovok CMS locales
|
|
7
|
+
* The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
|
|
8
8
|
*/
|
|
9
|
-
exports.OVOK_CMS_LOCALES = [
|
|
9
|
+
exports.OVOK_CMS_LOCALES = [
|
|
10
|
+
"en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm",
|
|
11
|
+
"bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee",
|
|
12
|
+
"el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv",
|
|
13
|
+
"ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it",
|
|
14
|
+
"iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky",
|
|
15
|
+
"la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt",
|
|
16
|
+
"my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa",
|
|
17
|
+
"pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl",
|
|
18
|
+
"sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn",
|
|
19
|
+
"to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo",
|
|
20
|
+
"za", "zh", "zu"
|
|
21
|
+
];
|
|
10
22
|
/**
|
|
11
23
|
* Locale the CMS answers in when none is requested or supported.
|
|
12
24
|
*/
|
|
@@ -8,4 +8,16 @@ export declare const MEASUREMENT_TYPE_SYSTEM = "https://sdk.ovok.com/fhir/CodeSy
|
|
|
8
8
|
export declare const OBSERVATION_CATEGORY_SYSTEM = "http://terminology.hl7.org/CodeSystem/observation-category";
|
|
9
9
|
/** Identifier system of the device-side reading id that makes a save idempotent. */
|
|
10
10
|
export declare const DEVICE_READING_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/device-reading-id";
|
|
11
|
+
/**
|
|
12
|
+
* Identifier system of a series' stable id, so a series that grows is written over, not repeated.
|
|
13
|
+
*
|
|
14
|
+
* @category measurements
|
|
15
|
+
*/
|
|
16
|
+
export declare const SERIES_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/series-id";
|
|
17
|
+
/**
|
|
18
|
+
* Identifier system of one piece of a long recording, valued `<recording id>/<position>`.
|
|
19
|
+
*
|
|
20
|
+
* @category measurements
|
|
21
|
+
*/
|
|
22
|
+
export declare const SEGMENT_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/recording-segment-id";
|
|
11
23
|
export declare const OVOK_EXTENSION_BASE_URL = "http://ovok.com/fhir/StructureDefinition";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OVOK_EXTENSION_BASE_URL = exports.DEVICE_READING_IDENTIFIER_SYSTEM = exports.OBSERVATION_CATEGORY_SYSTEM = exports.MEASUREMENT_TYPE_SYSTEM = exports.MDC_SYSTEM = exports.SNOMED_SYSTEM = exports.UCUM_SYSTEM = exports.LOINC_SYSTEM = void 0;
|
|
3
|
+
exports.OVOK_EXTENSION_BASE_URL = exports.SEGMENT_IDENTIFIER_SYSTEM = exports.SERIES_IDENTIFIER_SYSTEM = exports.DEVICE_READING_IDENTIFIER_SYSTEM = exports.OBSERVATION_CATEGORY_SYSTEM = exports.MEASUREMENT_TYPE_SYSTEM = exports.MDC_SYSTEM = exports.SNOMED_SYSTEM = exports.UCUM_SYSTEM = exports.LOINC_SYSTEM = void 0;
|
|
4
4
|
exports.LOINC_SYSTEM = "http://loinc.org";
|
|
5
5
|
exports.UCUM_SYSTEM = "http://unitsofmeasure.org";
|
|
6
6
|
exports.SNOMED_SYSTEM = "http://snomed.info/sct";
|
|
@@ -11,4 +11,16 @@ exports.MEASUREMENT_TYPE_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurem
|
|
|
11
11
|
exports.OBSERVATION_CATEGORY_SYSTEM = "http://terminology.hl7.org/CodeSystem/observation-category";
|
|
12
12
|
/** Identifier system of the device-side reading id that makes a save idempotent. */
|
|
13
13
|
exports.DEVICE_READING_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/device-reading-id";
|
|
14
|
+
/**
|
|
15
|
+
* Identifier system of a series' stable id, so a series that grows is written over, not repeated.
|
|
16
|
+
*
|
|
17
|
+
* @category measurements
|
|
18
|
+
*/
|
|
19
|
+
exports.SERIES_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/series-id";
|
|
20
|
+
/**
|
|
21
|
+
* Identifier system of one piece of a long recording, valued `<recording id>/<position>`.
|
|
22
|
+
*
|
|
23
|
+
* @category measurements
|
|
24
|
+
*/
|
|
25
|
+
exports.SEGMENT_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/recording-segment-id";
|
|
14
26
|
exports.OVOK_EXTENSION_BASE_URL = "http://ovok.com/fhir/StructureDefinition";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Bundle, BundleEntry } from "@medplum/fhirtypes";
|
|
2
2
|
/**
|
|
3
|
-
* Readings' entries packed into as few requests as fit `MAX_OBSERVATION_BUNDLE_BYTES
|
|
4
|
-
* too big for one request is a request by itself, which `executeObservationBundle`
|
|
3
|
+
* Readings' entries packed into as few requests as fit `MAX_OBSERVATION_BUNDLE_BYTES` and, when given, `maxEntries`,
|
|
4
|
+
* each reading whole. A reading too big for one request is a request by itself, which `executeObservationBundle`
|
|
5
|
+
* splits.
|
|
5
6
|
*/
|
|
6
|
-
export declare const packObservationGroups: (groups: BundleEntry[][]) => BundleEntry[][][];
|
|
7
|
+
export declare const packObservationGroups: (groups: BundleEntry[][], maxEntries?: number) => BundleEntry[][][];
|
|
7
8
|
/**
|
|
8
9
|
* Saves several readings as two batches, every main observation first, so a reading's other observations only ever
|
|
9
10
|
* point at a main observation the server saved. A main that matched several saved copies keeps the members saved
|
|
@@ -3,24 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeReadingsBatch = exports.packObservationGroups = void 0;
|
|
4
4
|
const observation_bundle_utils_1 = require("./observation-bundle-utils");
|
|
5
5
|
/**
|
|
6
|
-
* Readings' entries packed into as few requests as fit `MAX_OBSERVATION_BUNDLE_BYTES
|
|
7
|
-
* too big for one request is a request by itself, which `executeObservationBundle`
|
|
6
|
+
* Readings' entries packed into as few requests as fit `MAX_OBSERVATION_BUNDLE_BYTES` and, when given, `maxEntries`,
|
|
7
|
+
* each reading whole. A reading too big for one request is a request by itself, which `executeObservationBundle`
|
|
8
|
+
* splits.
|
|
8
9
|
*/
|
|
9
|
-
const packObservationGroups = (groups) => {
|
|
10
|
+
const packObservationGroups = (groups, maxEntries = Infinity) => {
|
|
10
11
|
const envelope = JSON.stringify({ resourceType: "Bundle", type: "batch", entry: [] }).length;
|
|
11
12
|
const requests = [];
|
|
12
13
|
let request = [];
|
|
13
14
|
let size = envelope;
|
|
15
|
+
let entries = 0;
|
|
14
16
|
for (const group of groups) {
|
|
15
17
|
// Each entry adds its JSON and a separating comma.
|
|
16
18
|
const groupSize = group.reduce((total, entry) => total + JSON.stringify(entry).length + 1, 0);
|
|
17
|
-
if (request.length > 0 && size + groupSize > observation_bundle_utils_1.MAX_OBSERVATION_BUNDLE_BYTES) {
|
|
19
|
+
if (request.length > 0 && (size + groupSize > observation_bundle_utils_1.MAX_OBSERVATION_BUNDLE_BYTES || entries + group.length > maxEntries)) {
|
|
18
20
|
requests.push(request);
|
|
19
21
|
request = [];
|
|
20
22
|
size = envelope;
|
|
23
|
+
entries = 0;
|
|
21
24
|
}
|
|
22
25
|
request.push(group);
|
|
23
26
|
size += groupSize;
|
|
27
|
+
entries += group.length;
|
|
24
28
|
}
|
|
25
29
|
if (request.length > 0) {
|
|
26
30
|
requests.push(request);
|
|
@@ -3,6 +3,8 @@ import { MeasurementDevice } from "./types/measurement/MeasurementDevice";
|
|
|
3
3
|
import { MeasurementSeries } from "./types/measurement/MeasurementSeries";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters of `seriesObservations`.
|
|
6
|
+
*
|
|
7
|
+
* @category measurements
|
|
6
8
|
*/
|
|
7
9
|
export type SeriesObservationParams = {
|
|
8
10
|
/** The series to convert. */
|
|
@@ -13,9 +15,19 @@ export type SeriesObservationParams = {
|
|
|
13
15
|
device?: MeasurementDevice;
|
|
14
16
|
/** Defaults to `final`; `preliminary` for values a device's own recording may still replace. */
|
|
15
17
|
status?: Observation["status"];
|
|
18
|
+
/**
|
|
19
|
+
* Names where the series comes from. With the property and the start, it makes the series' identifier, so a
|
|
20
|
+
* series that grows is written over, not repeated. Defaults to the device's serial number or id; with neither,
|
|
21
|
+
* the series has no identifier and is saved once.
|
|
22
|
+
*/
|
|
23
|
+
sourceId?: string;
|
|
24
|
+
/** Earlier sources of the same series; each adds an identifier, so a save finds the series saved under any of them. */
|
|
25
|
+
formerSourceIds?: string[];
|
|
16
26
|
};
|
|
17
27
|
/**
|
|
18
28
|
* The values of a series observation, one per slot from `start`.
|
|
29
|
+
*
|
|
30
|
+
* @category measurements
|
|
19
31
|
*/
|
|
20
32
|
export type ReadSeries = {
|
|
21
33
|
/** When the first slot starts. */
|
|
@@ -27,6 +39,8 @@ export type ReadSeries = {
|
|
|
27
39
|
};
|
|
28
40
|
/**
|
|
29
41
|
* Lowest, highest and mean of a series' values.
|
|
42
|
+
*
|
|
43
|
+
* @category measurements
|
|
30
44
|
*/
|
|
31
45
|
export type SeriesSummary = {
|
|
32
46
|
/** Lowest value. */
|
|
@@ -42,15 +56,21 @@ export type SeriesSummary = {
|
|
|
42
56
|
* A series as observations: one per measured property, in `MEASUREMENT_FIELDS` order with the main one first, each
|
|
43
57
|
* holding its values as `valueSampledData` across the series' `effectivePeriod`. They carry the same codes as a
|
|
44
58
|
* single reading of that kind, and a series of several properties ends with their group. Save them with
|
|
45
|
-
* `saveObservations`, which links the rest to the first
|
|
46
|
-
* keep their own path, `generateObservationBodiesByMeasurement`.
|
|
59
|
+
* `saveObservations`, which links the rest to the first and, by their identifiers, writes a series that grew over
|
|
60
|
+
* the one saved before. ECG recordings keep their own path, `generateObservationBodiesByMeasurement`.
|
|
61
|
+
*
|
|
62
|
+
* @category measurements
|
|
47
63
|
*/
|
|
48
|
-
export declare const seriesObservations: ({ series, patientId, device, status, }: SeriesObservationParams) => Observation[];
|
|
64
|
+
export declare const seriesObservations: ({ series, patientId, device, status, sourceId, formerSourceIds, }: SeriesObservationParams) => Observation[];
|
|
49
65
|
/**
|
|
50
66
|
* The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
|
|
67
|
+
*
|
|
68
|
+
* @category measurements
|
|
51
69
|
*/
|
|
52
70
|
export declare const readSeries: (observation: Observation) => ReadSeries | undefined;
|
|
53
71
|
/**
|
|
54
72
|
* The lowest, highest and mean of a series' values, or `undefined` when it holds none.
|
|
73
|
+
*
|
|
74
|
+
* @category measurements
|
|
55
75
|
*/
|
|
56
76
|
export declare const summarizeSeries: (values: ReadonlyArray<number | null>) => SeriesSummary | undefined;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.summarizeSeries = exports.readSeries = exports.seriesObservations = void 0;
|
|
4
|
+
const fhir_systems_1 = require("./fhir-systems");
|
|
4
5
|
const observation_coding_1 = require("./observation-coding");
|
|
5
6
|
const reading_group_1 = require("./reading-group");
|
|
6
7
|
const creator_1 = require("./services/creator");
|
|
7
8
|
const getDeviceObject_1 = require("./utils/getDeviceObject");
|
|
8
9
|
/** FHIR's mark for a slot with no value. */
|
|
9
10
|
const NO_VALUE = "E";
|
|
11
|
+
const identifierFor = (sources, name, start) => sources.length > 0
|
|
12
|
+
? {
|
|
13
|
+
identifier: sources.map((source) => ({
|
|
14
|
+
system: fhir_systems_1.SERIES_IDENTIFIER_SYSTEM,
|
|
15
|
+
value: `${source}|${name}|${start.toISOString()}`,
|
|
16
|
+
})),
|
|
17
|
+
}
|
|
18
|
+
: {};
|
|
10
19
|
const sampledData = (values, decimals) => values
|
|
11
20
|
.map((value) => (value === null || !Number.isFinite(value) ? NO_VALUE : String(Number(value.toFixed(decimals)))))
|
|
12
21
|
.join(" ");
|
|
@@ -14,10 +23,14 @@ const sampledData = (values, decimals) => values
|
|
|
14
23
|
* A series as observations: one per measured property, in `MEASUREMENT_FIELDS` order with the main one first, each
|
|
15
24
|
* holding its values as `valueSampledData` across the series' `effectivePeriod`. They carry the same codes as a
|
|
16
25
|
* single reading of that kind, and a series of several properties ends with their group. Save them with
|
|
17
|
-
* `saveObservations`, which links the rest to the first
|
|
18
|
-
* keep their own path, `generateObservationBodiesByMeasurement`.
|
|
26
|
+
* `saveObservations`, which links the rest to the first and, by their identifiers, writes a series that grew over
|
|
27
|
+
* the one saved before. ECG recordings keep their own path, `generateObservationBodiesByMeasurement`.
|
|
28
|
+
*
|
|
29
|
+
* @category measurements
|
|
19
30
|
*/
|
|
20
|
-
const seriesObservations = ({ series, patientId, device, status = "final", }) => {
|
|
31
|
+
const seriesObservations = ({ series, patientId, device, status = "final", sourceId, formerSourceIds = [], }) => {
|
|
32
|
+
const source = sourceId !== null && sourceId !== void 0 ? sourceId : ((device === null || device === void 0 ? void 0 : device.sn) || (device === null || device === void 0 ? void 0 : device.id));
|
|
33
|
+
const sources = source ? [source, ...formerSourceIds] : [];
|
|
21
34
|
const service = creator_1.ObservationServiceCreator.getInstance().getService(series.measurementTypeKey);
|
|
22
35
|
const codes = service.getObservationCodes();
|
|
23
36
|
const slots = Math.max(0, ...Object.values(series.values).map((values) => { var _a; return (_a = values === null || values === void 0 ? void 0 : values.length) !== null && _a !== void 0 ? _a : 0; }));
|
|
@@ -45,14 +58,17 @@ const seriesObservations = ({ series, patientId, device, status = "final", }) =>
|
|
|
45
58
|
dimensions: 1,
|
|
46
59
|
data: sampledData(values, field.decimals),
|
|
47
60
|
},
|
|
61
|
+
...identifierFor(sources, field.key, series.start),
|
|
48
62
|
}];
|
|
49
63
|
});
|
|
50
64
|
const group = (0, reading_group_1.readingGroupOf)(series.measurementTypeKey, parts);
|
|
51
|
-
return group ? [...parts, group] : parts;
|
|
65
|
+
return group ? [...parts, { ...group, ...identifierFor(sources, "group", series.start) }] : parts;
|
|
52
66
|
};
|
|
53
67
|
exports.seriesObservations = seriesObservations;
|
|
54
68
|
/**
|
|
55
69
|
* The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
|
|
70
|
+
*
|
|
71
|
+
* @category measurements
|
|
56
72
|
*/
|
|
57
73
|
const readSeries = (observation) => {
|
|
58
74
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -76,6 +92,8 @@ const readSeries = (observation) => {
|
|
|
76
92
|
exports.readSeries = readSeries;
|
|
77
93
|
/**
|
|
78
94
|
* The lowest, highest and mean of a series' values, or `undefined` when it holds none.
|
|
95
|
+
*
|
|
96
|
+
* @category measurements
|
|
79
97
|
*/
|
|
80
98
|
const summarizeSeries = (values) => {
|
|
81
99
|
let min = Infinity, max = -Infinity, total = 0, count = 0;
|
|
@@ -50,6 +50,7 @@ const generateEcgObservationFragments = (measurement, observationCodes) => {
|
|
|
50
50
|
},
|
|
51
51
|
additionalProperties: {
|
|
52
52
|
id: segmentIndex === 0 ? firstId : `${recordingId}-${segmentIndex}`,
|
|
53
|
+
identifier: [{ system: fhir_systems_1.SEGMENT_IDENTIFIER_SYSTEM, value: `${recordingId}/${segmentIndex}` }],
|
|
53
54
|
effectivePeriod: {
|
|
54
55
|
start: segmentStart.toISOString(),
|
|
55
56
|
end: segmentEnd.toISOString(),
|
package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export type GenerateObservationBodyParams = {
|
|
|
14
14
|
patientId?: string;
|
|
15
15
|
/** Stable ID from the originating device reading. */
|
|
16
16
|
sourceId?: string;
|
|
17
|
+
/** Earlier stable IDs of the same reading; a save that finds an observation under any of them creates nothing. */
|
|
18
|
+
formerSourceIds?: string[];
|
|
17
19
|
/** The measurement to convert. */
|
|
18
20
|
measurement: Measurement;
|
|
19
21
|
};
|
|
@@ -63,6 +63,8 @@ export type OfflineMeasurementFailure = {
|
|
|
63
63
|
status?: number;
|
|
64
64
|
};
|
|
65
65
|
type MeasurementTransport = (bundle: Bundle, requestOptions?: MedplumRequestOptions) => Promise<Bundle>;
|
|
66
|
+
/** RFC 4122-shaped deterministic UUID for canonical queue content. */
|
|
67
|
+
declare const stableValueId: (input: unknown) => string;
|
|
66
68
|
/**
|
|
67
69
|
* Deterministic UUID for an observation, ignoring its device-reading identifier.
|
|
68
70
|
*
|
|
@@ -116,4 +118,4 @@ export declare class OfflineMeasurementQueue {
|
|
|
116
118
|
private flushQueue;
|
|
117
119
|
}
|
|
118
120
|
export type { ObservationEntryOptions };
|
|
119
|
-
export { OFFLINE_MEASUREMENT_QUEUE_STORAGE_KEY as DEFAULT_OFFLINE_MEASUREMENT_QUEUE_KEY, IDENTIFIER_SYSTEM as OFFLINE_MEASUREMENT_IDENTIFIER_SYSTEM, entryForObservation, stableMeasurementId, };
|
|
121
|
+
export { OFFLINE_MEASUREMENT_QUEUE_STORAGE_KEY as DEFAULT_OFFLINE_MEASUREMENT_QUEUE_KEY, IDENTIFIER_SYSTEM as OFFLINE_MEASUREMENT_IDENTIFIER_SYSTEM, entryForObservation, stableMeasurementId, stableValueId, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stableMeasurementId = exports.entryForObservation = exports.OFFLINE_MEASUREMENT_IDENTIFIER_SYSTEM = exports.DEFAULT_OFFLINE_MEASUREMENT_QUEUE_KEY = exports.OfflineMeasurementQueue = exports.OFFLINE_MEASUREMENT_QUEUE_STORAGE_KEY = void 0;
|
|
3
|
+
exports.stableValueId = exports.stableMeasurementId = exports.entryForObservation = exports.OFFLINE_MEASUREMENT_IDENTIFIER_SYSTEM = exports.DEFAULT_OFFLINE_MEASUREMENT_QUEUE_KEY = exports.OfflineMeasurementQueue = exports.OFFLINE_MEASUREMENT_QUEUE_STORAGE_KEY = void 0;
|
|
4
4
|
const bundle_entry_status_1 = require("../observation/bundle-entry-status");
|
|
5
5
|
const fhir_systems_1 = require("../observation/fhir-systems");
|
|
6
6
|
const request_options_1 = require("../request-options");
|
|
@@ -53,6 +53,7 @@ const stableValueId = (input) => {
|
|
|
53
53
|
hex[16] = ((Number.parseInt(hex[16], 16) & 0x3) | 0x8).toString(16);
|
|
54
54
|
return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
|
|
55
55
|
};
|
|
56
|
+
exports.stableValueId = stableValueId;
|
|
56
57
|
/**
|
|
57
58
|
* Deterministic UUID for an observation, ignoring its device-reading identifier.
|
|
58
59
|
*
|
|
@@ -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.
|
|
29
|
+
version: "0.4.51",
|
|
30
30
|
},
|
|
31
31
|
fhirVersion: "4.0.1",
|
|
32
32
|
format: ["json"],
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { OvokLogger } from "../logging/ovok-logger";
|
|
2
|
+
import type { OutboxStore } from "../outbox/outbox-store";
|
|
3
|
+
import type { OutboxConnectivity, OutboxLifecycle } from "../outbox/outbox-triggers";
|
|
1
4
|
import { OvokStorage } from "../storage/ovok-storage";
|
|
2
5
|
/**
|
|
3
6
|
* Fetch implementation used for every request.
|
|
@@ -38,6 +41,16 @@ type OvokBaseConfig = {
|
|
|
38
41
|
maxNetworkRetries?: number;
|
|
39
42
|
/** Called when the session can no longer be refreshed. */
|
|
40
43
|
onUnauthenticated?: (reason: OvokUnauthenticatedReason) => void;
|
|
44
|
+
/** Where measurements wait to be sent. Defaults to memory, which loses them when the app closes. */
|
|
45
|
+
outboxStore?: OutboxStore;
|
|
46
|
+
/** Tells the outbox when the network returns. Defaults to the browser's `online` event. */
|
|
47
|
+
connectivity?: OutboxConnectivity;
|
|
48
|
+
/** Tells the outbox when the app comes to the foreground. Defaults to the browser tab becoming visible. */
|
|
49
|
+
lifecycle?: OutboxLifecycle;
|
|
50
|
+
/** Requests the outbox may make in 30 seconds, to stay under the rate limit. Defaults to 40. */
|
|
51
|
+
outboxRequestBudget?: number;
|
|
52
|
+
/** Receives the client's structured log entries. Defaults to none. */
|
|
53
|
+
logger?: OvokLogger;
|
|
41
54
|
};
|
|
42
55
|
/**
|
|
43
56
|
* Client configuration for end users, without a secret.
|
|
@@ -83,5 +96,10 @@ export type OvokSettings = {
|
|
|
83
96
|
clientId: string | null;
|
|
84
97
|
machineClient: MachineClient | null;
|
|
85
98
|
onUnauthenticated: (reason: OvokUnauthenticatedReason) => void;
|
|
99
|
+
outboxStore: OutboxStore;
|
|
100
|
+
connectivity: OutboxConnectivity;
|
|
101
|
+
lifecycle: OutboxLifecycle;
|
|
102
|
+
outboxRequestBudget: number;
|
|
103
|
+
logger: OvokLogger;
|
|
86
104
|
};
|
|
87
105
|
export {};
|
|
@@ -3,15 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.currentEnvironment = void 0;
|
|
4
4
|
exports.readSettings = readSettings;
|
|
5
5
|
const ovok_errors_1 = require("../errors/ovok-errors");
|
|
6
|
+
const ovok_logger_1 = require("../logging/ovok-logger");
|
|
7
|
+
const memory_outbox_store_1 = require("../outbox/memory-outbox-store");
|
|
8
|
+
const outbox_triggers_1 = require("../outbox/outbox-triggers");
|
|
6
9
|
const ovok_storage_1 = require("../storage/ovok-storage");
|
|
7
10
|
const DEFAULT_FHIR_PATH = "fhir";
|
|
8
11
|
const DEFAULT_TIMEOUT_MS = 30000;
|
|
9
12
|
const DEFAULT_MAX_NETWORK_RETRIES = 2;
|
|
13
|
+
const DEFAULT_OUTBOX_REQUEST_BUDGET = 40;
|
|
10
14
|
const ABSOLUTE_HTTP_URL = /^https?:\/\/[^/\s]+/i;
|
|
11
15
|
const currentEnvironment = () => ({ hasDocument: typeof document !== "undefined" });
|
|
12
16
|
exports.currentEnvironment = currentEnvironment;
|
|
13
17
|
function readSettings(config, environment) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
15
19
|
const machineClient = readMachineClient(config, environment);
|
|
16
20
|
return {
|
|
17
21
|
baseUrl: readBaseUrl(config.baseUrl),
|
|
@@ -24,6 +28,11 @@ function readSettings(config, environment) {
|
|
|
24
28
|
clientId: (_f = config.clientId) !== null && _f !== void 0 ? _f : null,
|
|
25
29
|
machineClient,
|
|
26
30
|
onUnauthenticated: (_g = config.onUnauthenticated) !== null && _g !== void 0 ? _g : (() => undefined),
|
|
31
|
+
outboxStore: (_h = config.outboxStore) !== null && _h !== void 0 ? _h : new memory_outbox_store_1.MemoryOutboxStore(),
|
|
32
|
+
connectivity: (_j = config.connectivity) !== null && _j !== void 0 ? _j : outbox_triggers_1.browserConnectivity,
|
|
33
|
+
lifecycle: (_k = config.lifecycle) !== null && _k !== void 0 ? _k : outbox_triggers_1.browserLifecycle,
|
|
34
|
+
outboxRequestBudget: requirePositive((_l = config.outboxRequestBudget) !== null && _l !== void 0 ? _l : DEFAULT_OUTBOX_REQUEST_BUDGET, "outboxRequestBudget"),
|
|
35
|
+
logger: (_m = config.logger) !== null && _m !== void 0 ? _m : ovok_logger_1.silentLogger,
|
|
27
36
|
};
|
|
28
37
|
}
|
|
29
38
|
const configError = (message) => new ovok_errors_1.OvokConfigError((0, ovok_errors_1.detailsFor)(message));
|
|
@@ -119,6 +119,13 @@ export declare class OvokServiceError extends OvokError {
|
|
|
119
119
|
*/
|
|
120
120
|
export declare class OvokConnectionError extends OvokError {
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* The server did not answer within the request timeout.
|
|
124
|
+
*
|
|
125
|
+
* @category Errors
|
|
126
|
+
*/
|
|
127
|
+
export declare class OvokTimeoutError extends OvokConnectionError {
|
|
128
|
+
}
|
|
122
129
|
/**
|
|
123
130
|
* The client is misconfigured.
|
|
124
131
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detailsFor = exports.OvokConfigError = exports.OvokConnectionError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokConflictError = exports.OvokNotFoundError = exports.OvokPermissionError = exports.OvokAuthenticationError = exports.OvokValidationError = exports.OvokError = void 0;
|
|
3
|
+
exports.detailsFor = exports.OvokConfigError = exports.OvokTimeoutError = exports.OvokConnectionError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokConflictError = exports.OvokNotFoundError = exports.OvokPermissionError = exports.OvokAuthenticationError = exports.OvokValidationError = exports.OvokError = void 0;
|
|
4
4
|
exports.errorForStatus = errorForStatus;
|
|
5
5
|
/**
|
|
6
6
|
* Base class of every error the `next` clients throw; the subclass reflects the HTTP status.
|
|
@@ -103,6 +103,14 @@ exports.OvokServiceError = OvokServiceError;
|
|
|
103
103
|
class OvokConnectionError extends OvokError {
|
|
104
104
|
}
|
|
105
105
|
exports.OvokConnectionError = OvokConnectionError;
|
|
106
|
+
/**
|
|
107
|
+
* The server did not answer within the request timeout.
|
|
108
|
+
*
|
|
109
|
+
* @category Errors
|
|
110
|
+
*/
|
|
111
|
+
class OvokTimeoutError extends OvokConnectionError {
|
|
112
|
+
}
|
|
113
|
+
exports.OvokTimeoutError = OvokTimeoutError;
|
|
106
114
|
/**
|
|
107
115
|
* The client is misconfigured.
|
|
108
116
|
*
|
|
@@ -42,8 +42,10 @@ class Deadline {
|
|
|
42
42
|
if ((_a = this.callerSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
43
43
|
return (_b = this.callerSignal.reason) !== null && _b !== void 0 ? _b : error;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (this.expired) {
|
|
46
|
+
return new ovok_errors_1.OvokTimeoutError((0, ovok_errors_1.detailsFor)(`The request timed out after ${this.timeoutMs} ms.`), error);
|
|
47
|
+
}
|
|
48
|
+
return new ovok_errors_1.OvokConnectionError((0, ovok_errors_1.detailsFor)("Could not reach the Ovok API."), error);
|
|
47
49
|
}
|
|
48
50
|
clear() {
|
|
49
51
|
var _a;
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
export { Ovok } from "./ovok";
|
|
2
2
|
export type { OvokConfig, OvokFetch, OvokUnauthenticatedReason } from "./config/ovok-config";
|
|
3
3
|
export { MemoryStorage } from "./storage/ovok-storage";
|
|
4
|
+
export { seriesObservations, readSeries, summarizeSeries } from "../client/observation/series";
|
|
5
|
+
export type { ReadSeries, SeriesObservationParams, SeriesSummary } from "../client/observation/series";
|
|
6
|
+
export { SEGMENT_IDENTIFIER_SYSTEM, SERIES_IDENTIFIER_SYSTEM } from "../client/observation/fhir-systems";
|
|
7
|
+
export { IndexedDbOutboxStore } from "./outbox/indexed-db-outbox-store";
|
|
8
|
+
export { MemoryOutboxStore } from "./outbox/memory-outbox-store";
|
|
9
|
+
export { outboxStoreContract } from "./outbox/store-contract";
|
|
10
|
+
export { browserConnectivity, browserLifecycle } from "./outbox/outbox-triggers";
|
|
11
|
+
export type { IndexedDbOutboxOptions } from "./outbox/indexed-db-outbox-store";
|
|
12
|
+
export type { OutboxStore } from "./outbox/outbox-store";
|
|
13
|
+
export type { OutboxStoreCheck } from "./outbox/store-contract";
|
|
14
|
+
export type { OutboxConnectivity, OutboxLifecycle } from "./outbox/outbox-triggers";
|
|
15
|
+
export type { OutboxDeleteTarget, OutboxFailure, OutboxFlushResult, OutboxGroupProgress, OutboxItem, OutboxItemSummary, OutboxKind, OutboxSentItem, OutboxSnapshot, OutboxState, } from "./outbox/outbox-types";
|
|
16
|
+
export type { OvokLogEntry, OvokLogger } from "./logging/ovok-logger";
|
|
4
17
|
export type { OvokStorage } from "./storage/ovok-storage";
|
|
5
|
-
export { OvokAuthenticationError, OvokConfigError, OvokConflictError, OvokConnectionError, OvokError, OvokNotFoundError, OvokPermissionError, OvokRateLimitError, OvokServiceError, OvokValidationError, } from "./errors/ovok-errors";
|
|
18
|
+
export { OvokAuthenticationError, OvokConfigError, OvokConflictError, OvokConnectionError, OvokError, OvokNotFoundError, OvokPermissionError, OvokRateLimitError, OvokServiceError, OvokTimeoutError, OvokValidationError, } from "./errors/ovok-errors";
|
|
6
19
|
export { OvokAccountError } from "./errors/ovok-account-error";
|
|
7
20
|
export type { OvokErrorDetails } from "./errors/ovok-errors";
|
|
8
21
|
export type { RequestOptions } from "./http/transmit";
|
|
@@ -50,6 +63,7 @@ export type { InvitesResource } from "./resources/invites/invites-resource";
|
|
|
50
63
|
export type { LocalesResource } from "./resources/localization/locales-resource";
|
|
51
64
|
export type { LocalizationsResource } from "./resources/localization/localizations-resource";
|
|
52
65
|
export type { MeasurementsResource } from "./resources/measurements/measurements-resource";
|
|
66
|
+
export type { OutboxResource } from "./outbox/outbox-resource";
|
|
53
67
|
export type { PatientResource } from "./resources/patient/patient-resource";
|
|
54
68
|
export type { ProjectsResource } from "./resources/projects/projects-resource";
|
|
55
69
|
export type { QuestionnaireResponsesResource, QuestionnairesResource, } from "./resources/questionnaires/questionnaires-resource";
|
package/dist/next/index.js
CHANGED
|
@@ -14,11 +14,27 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.OvokAccountError = exports.OvokValidationError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokPermissionError = exports.OvokNotFoundError = exports.OvokError = exports.OvokConnectionError = exports.OvokConflictError = exports.OvokConfigError = exports.OvokAuthenticationError = exports.MemoryStorage = exports.Ovok = void 0;
|
|
17
|
+
exports.OvokAccountError = exports.OvokValidationError = exports.OvokTimeoutError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokPermissionError = exports.OvokNotFoundError = exports.OvokError = exports.OvokConnectionError = exports.OvokConflictError = exports.OvokConfigError = exports.OvokAuthenticationError = exports.browserLifecycle = exports.browserConnectivity = exports.outboxStoreContract = exports.MemoryOutboxStore = exports.IndexedDbOutboxStore = exports.SERIES_IDENTIFIER_SYSTEM = exports.SEGMENT_IDENTIFIER_SYSTEM = exports.summarizeSeries = exports.readSeries = exports.seriesObservations = exports.MemoryStorage = exports.Ovok = void 0;
|
|
18
18
|
var ovok_1 = require("./ovok");
|
|
19
19
|
Object.defineProperty(exports, "Ovok", { enumerable: true, get: function () { return ovok_1.Ovok; } });
|
|
20
20
|
var ovok_storage_1 = require("./storage/ovok-storage");
|
|
21
21
|
Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return ovok_storage_1.MemoryStorage; } });
|
|
22
|
+
var series_1 = require("../client/observation/series");
|
|
23
|
+
Object.defineProperty(exports, "seriesObservations", { enumerable: true, get: function () { return series_1.seriesObservations; } });
|
|
24
|
+
Object.defineProperty(exports, "readSeries", { enumerable: true, get: function () { return series_1.readSeries; } });
|
|
25
|
+
Object.defineProperty(exports, "summarizeSeries", { enumerable: true, get: function () { return series_1.summarizeSeries; } });
|
|
26
|
+
var fhir_systems_1 = require("../client/observation/fhir-systems");
|
|
27
|
+
Object.defineProperty(exports, "SEGMENT_IDENTIFIER_SYSTEM", { enumerable: true, get: function () { return fhir_systems_1.SEGMENT_IDENTIFIER_SYSTEM; } });
|
|
28
|
+
Object.defineProperty(exports, "SERIES_IDENTIFIER_SYSTEM", { enumerable: true, get: function () { return fhir_systems_1.SERIES_IDENTIFIER_SYSTEM; } });
|
|
29
|
+
var indexed_db_outbox_store_1 = require("./outbox/indexed-db-outbox-store");
|
|
30
|
+
Object.defineProperty(exports, "IndexedDbOutboxStore", { enumerable: true, get: function () { return indexed_db_outbox_store_1.IndexedDbOutboxStore; } });
|
|
31
|
+
var memory_outbox_store_1 = require("./outbox/memory-outbox-store");
|
|
32
|
+
Object.defineProperty(exports, "MemoryOutboxStore", { enumerable: true, get: function () { return memory_outbox_store_1.MemoryOutboxStore; } });
|
|
33
|
+
var store_contract_1 = require("./outbox/store-contract");
|
|
34
|
+
Object.defineProperty(exports, "outboxStoreContract", { enumerable: true, get: function () { return store_contract_1.outboxStoreContract; } });
|
|
35
|
+
var outbox_triggers_1 = require("./outbox/outbox-triggers");
|
|
36
|
+
Object.defineProperty(exports, "browserConnectivity", { enumerable: true, get: function () { return outbox_triggers_1.browserConnectivity; } });
|
|
37
|
+
Object.defineProperty(exports, "browserLifecycle", { enumerable: true, get: function () { return outbox_triggers_1.browserLifecycle; } });
|
|
22
38
|
var ovok_errors_1 = require("./errors/ovok-errors");
|
|
23
39
|
Object.defineProperty(exports, "OvokAuthenticationError", { enumerable: true, get: function () { return ovok_errors_1.OvokAuthenticationError; } });
|
|
24
40
|
Object.defineProperty(exports, "OvokConfigError", { enumerable: true, get: function () { return ovok_errors_1.OvokConfigError; } });
|
|
@@ -29,6 +45,7 @@ Object.defineProperty(exports, "OvokNotFoundError", { enumerable: true, get: fun
|
|
|
29
45
|
Object.defineProperty(exports, "OvokPermissionError", { enumerable: true, get: function () { return ovok_errors_1.OvokPermissionError; } });
|
|
30
46
|
Object.defineProperty(exports, "OvokRateLimitError", { enumerable: true, get: function () { return ovok_errors_1.OvokRateLimitError; } });
|
|
31
47
|
Object.defineProperty(exports, "OvokServiceError", { enumerable: true, get: function () { return ovok_errors_1.OvokServiceError; } });
|
|
48
|
+
Object.defineProperty(exports, "OvokTimeoutError", { enumerable: true, get: function () { return ovok_errors_1.OvokTimeoutError; } });
|
|
32
49
|
Object.defineProperty(exports, "OvokValidationError", { enumerable: true, get: function () { return ovok_errors_1.OvokValidationError; } });
|
|
33
50
|
var ovok_account_error_1 = require("./errors/ovok-account-error");
|
|
34
51
|
Object.defineProperty(exports, "OvokAccountError", { enumerable: true, get: function () { return ovok_account_error_1.OvokAccountError; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One structured log entry: a stable message with a small context of counts and reasons, never values or PHI.
|
|
3
|
+
*
|
|
4
|
+
* @category Ovok client
|
|
5
|
+
*/
|
|
6
|
+
export type OvokLogEntry = {
|
|
7
|
+
/** Severity of the event. */
|
|
8
|
+
level: "debug" | "info" | "warn" | "error";
|
|
9
|
+
/** Module that logged the event, such as `outbox`. */
|
|
10
|
+
logger: string;
|
|
11
|
+
/** Stable event name, such as `outbox.flushed`. */
|
|
12
|
+
message: string;
|
|
13
|
+
/** Counts and reasons that describe the event. */
|
|
14
|
+
context: Record<string, string | number | boolean | null>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Receives the client's log entries; the client logs nothing unless one is configured.
|
|
18
|
+
*
|
|
19
|
+
* @category Ovok client
|
|
20
|
+
*/
|
|
21
|
+
export type OvokLogger = (entry: OvokLogEntry) => void;
|
|
22
|
+
type LogLevel = OvokLogEntry["level"];
|
|
23
|
+
export type ScopedLogger = Record<LogLevel, (message: string, context?: OvokLogEntry["context"]) => void>;
|
|
24
|
+
export declare const silentLogger: OvokLogger;
|
|
25
|
+
export declare const scopedLogger: (logger: OvokLogger, scope: string) => ScopedLogger;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scopedLogger = exports.silentLogger = void 0;
|
|
4
|
+
const silentLogger = () => undefined;
|
|
5
|
+
exports.silentLogger = silentLogger;
|
|
6
|
+
const scopedLogger = (logger, scope) => {
|
|
7
|
+
const at = (level) => (message, context = {}) => logger({ level, logger: scope, message, context });
|
|
8
|
+
return { debug: at("debug"), info: at("info"), warn: at("warn"), error: at("error") };
|
|
9
|
+
};
|
|
10
|
+
exports.scopedLogger = scopedLogger;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.observationOf = void 0;
|
|
4
|
+
/** The Observation a bundle entry carries; a deletion carries none. */
|
|
5
|
+
const observationOf = (entry) => { var _a; return ((_a = entry === null || entry === void 0 ? void 0 : entry.resource) === null || _a === void 0 ? void 0 : _a.resourceType) === "Observation" ? entry.resource : undefined; };
|
|
6
|
+
exports.observationOf = observationOf;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { OutboxFailure, OutboxItem } from "./outbox-types";
|
|
2
|
+
/** What a failed send means for the items in it. */
|
|
3
|
+
export type Outcome = {
|
|
4
|
+
type: "interrupted";
|
|
5
|
+
} | {
|
|
6
|
+
type: "offline";
|
|
7
|
+
failure: OutboxFailure;
|
|
8
|
+
} | {
|
|
9
|
+
type: "owner-unavailable";
|
|
10
|
+
failure: OutboxFailure;
|
|
11
|
+
} | {
|
|
12
|
+
type: "pause";
|
|
13
|
+
reason: PauseReason;
|
|
14
|
+
retryAfterMs: number | null;
|
|
15
|
+
failure: OutboxFailure;
|
|
16
|
+
} | {
|
|
17
|
+
type: "already-applied";
|
|
18
|
+
} | {
|
|
19
|
+
type: "timeout";
|
|
20
|
+
failure: OutboxFailure;
|
|
21
|
+
error: unknown;
|
|
22
|
+
} | {
|
|
23
|
+
type: "retry";
|
|
24
|
+
failure: OutboxFailure;
|
|
25
|
+
error: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
type: "reject";
|
|
28
|
+
failure: OutboxFailure;
|
|
29
|
+
error: unknown;
|
|
30
|
+
};
|
|
31
|
+
export type PauseReason = "rate-limited" | "server-error";
|
|
32
|
+
export type FailureContext = {
|
|
33
|
+
items: OutboxItem[];
|
|
34
|
+
signal: AbortSignal | undefined;
|
|
35
|
+
};
|
|
36
|
+
export declare const summarizeFailure: (error: unknown) => OutboxFailure;
|
|
37
|
+
/** Anything the rules do not name is tried again on the timeout schedule, then refused. */
|
|
38
|
+
export declare const classify: (error: unknown, context: FailureContext) => Outcome;
|
|
39
|
+
export declare const retryDelayMs: (attempts: number) => number;
|
|
40
|
+
/** How long the whole outbox waits after a 429 or a 5xx; repeated server errors wait longer each time. */
|
|
41
|
+
export declare class PauseLadder {
|
|
42
|
+
private serverErrors;
|
|
43
|
+
durationMs(reason: PauseReason, retryAfterMs: number | null): number;
|
|
44
|
+
reset(): void;
|
|
45
|
+
}
|