@ovok/core 0.4.36 → 0.4.38
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/auth/account-storage.d.ts +1 -0
- package/dist/client/auth/account-storage.js +2 -1
- package/dist/{utils → client}/auth/exchange-code.d.ts +1 -1
- package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.js +5 -17
- package/dist/{utils → client}/auth/handle-tenant-code.d.ts +1 -1
- package/dist/{utils → client}/auth/handle-tenant-code.js +1 -1
- package/dist/client/auth/methods/appleLogin.js +2 -6
- package/dist/client/auth/methods/changePassword.js +2 -1
- package/dist/client/auth/methods/getSessions.js +2 -1
- package/dist/client/auth/methods/googleLogin.js +2 -6
- package/dist/client/auth/methods/login.js +26 -44
- package/dist/client/auth/methods/logout.js +2 -1
- package/dist/client/auth/methods/requestDeleteUser.js +5 -4
- package/dist/client/auth/methods/revokeSessions.js +2 -1
- package/dist/client/auth/methods/socialLogin.d.ts +7 -0
- package/dist/client/auth/methods/socialLogin.js +11 -0
- package/dist/client/auth/session-fetch.d.ts +35 -0
- package/dist/client/auth/session-fetch.js +206 -0
- package/dist/client/auth/session-http.d.ts +11 -0
- package/dist/client/auth/session-http.js +169 -0
- package/dist/client/auth/sha256.d.ts +2 -0
- package/dist/client/auth/sha256.js +65 -0
- package/dist/{utils → client}/auth/start-login.d.ts +2 -2
- package/dist/client/change-history/methods.js +2 -1
- package/dist/client/cms/methods.js +16 -28
- package/dist/client/consent/methods.js +3 -2
- package/dist/client/email/methods.js +2 -1
- package/dist/client/errors/ovok-error-utils.d.ts +6 -0
- package/dist/client/errors/ovok-error-utils.js +10 -1
- package/dist/client/errors/ovok-error.js +6 -13
- package/dist/client/errors/rate-limit-error.js +2 -6
- package/dist/client/experience/methods.js +28 -37
- package/dist/client/invites/methods.js +8 -12
- package/dist/client/notifications/methods.js +5 -5
- package/dist/client/observation/fhir-systems.d.ts +4 -0
- package/dist/client/observation/fhir-systems.js +7 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +23 -29
- package/dist/client/observation/methods/getLatestObservationsByCodes.js +6 -9
- package/dist/client/observation/methods/observationsToMeasurements.js +44 -91
- package/dist/client/observation/services/base-observation-service.js +4 -3
- package/dist/client/observation/services/blood-pressure.js +1 -4
- package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts} +18 -13
- package/dist/client/observation/services/component-observation-services.js +69 -0
- package/dist/client/observation/services/creator.d.ts +1 -2
- package/dist/client/observation/services/creator.js +15 -33
- package/dist/client/observation/services/ecg-observation-fragments.js +5 -6
- package/dist/client/observation/services/ecg.js +3 -2
- package/dist/client/observation/services/lipid-panel.js +8 -12
- package/dist/client/observation/services/measurement-time.d.ts +4 -0
- package/dist/client/observation/services/measurement-time.js +6 -0
- package/dist/client/observation/services/single-value-services.d.ts +36 -0
- package/dist/client/observation/services/single-value-services.js +100 -0
- package/dist/client/observation/services/uric-acid-service.js +6 -7
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +2 -458
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +0 -6
- package/dist/client/offline/offline-measurement-queue.js +31 -28
- package/dist/client/ovok-client.d.ts +7 -15
- package/dist/client/ovok-client.js +54 -398
- package/dist/client/patient/methods.js +27 -36
- package/dist/client/patient-sharing/methods.js +4 -4
- package/dist/client/platform/methods.js +21 -30
- package/dist/client/platform/types.d.ts +3 -6
- package/dist/client/query-string.d.ts +3 -0
- package/dist/client/query-string.js +15 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
- package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.js +1 -2
- package/dist/client/questionnaire-response/methods/populateQuestionnaire.js +1 -2
- package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -1
- package/dist/client/request-options.d.ts +2 -0
- package/dist/client/request-options.js +6 -0
- package/dist/client/signals/errors.js +2 -6
- package/dist/client/signals/methods.js +22 -22
- package/dist/client/slim/live-read.d.ts +4 -0
- package/dist/client/slim/live-read.js +87 -0
- package/dist/client/slim/methods.d.ts +3 -0
- package/dist/client/slim/methods.js +73 -166
- package/dist/client/storage.js +3 -2
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/conformance/capability.js +8 -7
- package/dist/hooks/account-hooks.js +6 -68
- package/dist/hooks/api-hooks.d.ts +10 -6
- package/dist/hooks/api-hooks.js +29 -88
- package/dist/hooks/cms-hooks.js +8 -13
- package/dist/hooks/email-hooks.js +1 -40
- package/dist/hooks/experience-hooks.js +4 -60
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/invites-hooks.js +0 -1
- package/dist/hooks/notification-hooks.d.ts +4 -1
- package/dist/hooks/notification-hooks.js +29 -86
- package/dist/hooks/notification-invalidation.d.ts +6 -0
- package/dist/hooks/notification-invalidation.js +52 -0
- package/dist/hooks/notification-note-hooks.js +13 -28
- package/dist/hooks/observation-hooks.js +2 -4
- package/dist/hooks/patient-hooks.js +13 -113
- package/dist/hooks/patient-sharing-hooks.js +2 -7
- package/dist/hooks/platform-hooks.js +3 -51
- package/dist/hooks/poll-hooks.js +10 -8
- package/dist/hooks/signals-alert-hooks.js +4 -6
- package/dist/hooks/signals-hooks.js +2 -45
- package/package.json +1 -1
- package/dist/client/observation/services/baby-sleep.js +0 -69
- package/dist/client/observation/services/blood-glucose.d.ts +0 -12
- package/dist/client/observation/services/blood-glucose.js +0 -36
- package/dist/client/observation/services/body-temperature.d.ts +0 -13
- package/dist/client/observation/services/body-temperature.js +0 -36
- package/dist/client/observation/services/body-weight.d.ts +0 -13
- package/dist/client/observation/services/body-weight.js +0 -36
- package/dist/client/observation/services/heart-rate-variability.d.ts +0 -13
- package/dist/client/observation/services/heart-rate-variability.js +0 -38
- package/dist/client/observation/services/heart-rate.d.ts +0 -13
- package/dist/client/observation/services/heart-rate.js +0 -39
- package/dist/client/observation/services/respiratory-rate.d.ts +0 -13
- package/dist/client/observation/services/respiratory-rate.js +0 -38
- package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
- package/dist/client/observation/services/respiratory-therapy.js +0 -69
- package/dist/client/observation/services/resting-heart-rate.d.ts +0 -13
- package/dist/client/observation/services/resting-heart-rate.js +0 -38
- package/dist/client/observation/services/vo2-max.d.ts +0 -13
- package/dist/client/observation/services/vo2-max.js +0 -38
- package/dist/client/observation/services/walking-heart-rate-average.d.ts +0 -12
- package/dist/client/observation/services/walking-heart-rate-average.js +0 -38
- package/dist/utils/auth/sha256.d.ts +0 -8
- package/dist/utils/auth/sha256.js +0 -300
- /package/dist/{utils → client}/auth/exchange-code.js +0 -0
- /package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.d.ts +0 -0
- /package/dist/{utils → client}/auth/start-login.js +0 -0
package/dist/hooks/api-hooks.js
CHANGED
|
@@ -34,14 +34,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
37
|
+
exports.useSlimDeviceTelemetry = exports.useSlimDevices = exports.useSlimPatients = exports.useProjectFeatures = exports.useProjectSettings = exports.useAdministeredProjects = exports.usePublicApiEndpoints = exports.useCapabilityStatement = void 0;
|
|
38
38
|
exports.useOvokRequest = useOvokRequest;
|
|
39
39
|
exports.useOvokRequestWithUpdater = useOvokRequestWithUpdater;
|
|
40
|
+
exports.useOvokClientRequest = useOvokClientRequest;
|
|
41
|
+
exports.useOvokClientRequestFor = useOvokClientRequestFor;
|
|
40
42
|
exports.useOvokMutation = useOvokMutation;
|
|
41
43
|
const React = __importStar(require("react"));
|
|
42
|
-
const
|
|
44
|
+
const ovok_error_utils_1 = require("../client/errors/ovok-error-utils");
|
|
43
45
|
const index_1 = require("./index");
|
|
44
|
-
const toError = (error) => error instanceof Error ? error : new Error(String(error));
|
|
45
46
|
/**
|
|
46
47
|
* Small request primitive for the typed Ovok hooks. It deliberately does not
|
|
47
48
|
* add a cache or retry policy: MedplumClient already owns request caching and
|
|
@@ -87,7 +88,7 @@ function useOvokRequestWithUpdater(load, enabled = true) {
|
|
|
87
88
|
})
|
|
88
89
|
.catch((reason) => {
|
|
89
90
|
if (!disposed) {
|
|
90
|
-
setError(toError(reason));
|
|
91
|
+
setError((0, ovok_error_utils_1.toError)(reason));
|
|
91
92
|
setLoading(false);
|
|
92
93
|
}
|
|
93
94
|
});
|
|
@@ -112,6 +113,21 @@ function useOvokRequestWithUpdater(load, enabled = true) {
|
|
|
112
113
|
updateData,
|
|
113
114
|
};
|
|
114
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Reads through the active client. `inputs` holds every value the request depends on and is
|
|
118
|
+
* compared by value, so callers can pass a fresh params object each render.
|
|
119
|
+
*/
|
|
120
|
+
function useOvokClientRequest(request, inputs, enabled = true) {
|
|
121
|
+
const client = (0, index_1.useClient)();
|
|
122
|
+
const key = JSON.stringify(inputs);
|
|
123
|
+
// `inputs` is compared by value through `key`, so the request closure isn't a dependency.
|
|
124
|
+
const load = React.useCallback((signal) => request(client, signal), [client, key]);
|
|
125
|
+
return useOvokRequest(load, enabled);
|
|
126
|
+
}
|
|
127
|
+
/** Reads by id: waits while `id` is undefined and rejects an empty id with "<name> is required". */
|
|
128
|
+
function useOvokClientRequestFor(name, id, request) {
|
|
129
|
+
return useOvokClientRequest((client, signal) => (id ? request(client, id, signal) : Promise.reject(new Error(`${name} is required`))), id, id !== undefined);
|
|
130
|
+
}
|
|
115
131
|
/** Generic mutation hook for any typed OvokClient method. */
|
|
116
132
|
function useOvokMutation(mutateRequest) {
|
|
117
133
|
const client = (0, index_1.useClient)();
|
|
@@ -127,7 +143,7 @@ function useOvokMutation(mutateRequest) {
|
|
|
127
143
|
return value;
|
|
128
144
|
}
|
|
129
145
|
catch (reason) {
|
|
130
|
-
const requestError = toError(reason);
|
|
146
|
+
const requestError = (0, ovok_error_utils_1.toError)(reason);
|
|
131
147
|
setError(requestError);
|
|
132
148
|
throw requestError;
|
|
133
149
|
}
|
|
@@ -142,94 +158,19 @@ function useOvokMutation(mutateRequest) {
|
|
|
142
158
|
}, []);
|
|
143
159
|
return { data, loading, error, mutate, reset };
|
|
144
160
|
}
|
|
145
|
-
const useCapabilityStatement = (version = "R4") => {
|
|
146
|
-
const client = (0, index_1.useClient)();
|
|
147
|
-
const load = React.useCallback((signal) => client.getCapabilityStatement(version, { signal }), [client, version]);
|
|
148
|
-
return useOvokRequest(load);
|
|
149
|
-
};
|
|
161
|
+
const useCapabilityStatement = (version = "R4") => useOvokClientRequest((client, signal) => client.getCapabilityStatement(version, { signal }), version);
|
|
150
162
|
exports.useCapabilityStatement = useCapabilityStatement;
|
|
151
|
-
const usePublicApiEndpoints = (version = "R4") => {
|
|
152
|
-
const client = (0, index_1.useClient)();
|
|
153
|
-
const load = React.useCallback((signal) => client.getPublicApiEndpoints(version, { signal }), [client, version]);
|
|
154
|
-
return useOvokRequest(load);
|
|
155
|
-
};
|
|
163
|
+
const usePublicApiEndpoints = (version = "R4") => useOvokClientRequest((client, signal) => client.getPublicApiEndpoints(version, { signal }), version);
|
|
156
164
|
exports.usePublicApiEndpoints = usePublicApiEndpoints;
|
|
157
|
-
const useAdministeredProjects = (params = {}) => {
|
|
158
|
-
const client = (0, index_1.useClient)();
|
|
159
|
-
const serialized = JSON.stringify(params);
|
|
160
|
-
const load = React.useCallback((signal) => client.listAdministeredProjects(params, { signal }), [client, serialized]);
|
|
161
|
-
return useOvokRequest(load);
|
|
162
|
-
};
|
|
165
|
+
const useAdministeredProjects = (params = {}) => useOvokClientRequest((client, signal) => client.listAdministeredProjects(params, { signal }), params);
|
|
163
166
|
exports.useAdministeredProjects = useAdministeredProjects;
|
|
164
|
-
const useProjectSettings = () => {
|
|
165
|
-
const client = (0, index_1.useClient)();
|
|
166
|
-
const load = React.useCallback((signal) => client.getProjectSettings({ signal }), [client]);
|
|
167
|
-
return useOvokRequest(load);
|
|
168
|
-
};
|
|
167
|
+
const useProjectSettings = () => useOvokClientRequest((client, signal) => client.getProjectSettings({ signal }));
|
|
169
168
|
exports.useProjectSettings = useProjectSettings;
|
|
170
|
-
const useProjectFeatures = () => {
|
|
171
|
-
const client = (0, index_1.useClient)();
|
|
172
|
-
const load = React.useCallback((signal) => client.getProjectFeatures({ signal }), [client]);
|
|
173
|
-
return useOvokRequest(load);
|
|
174
|
-
};
|
|
169
|
+
const useProjectFeatures = () => useOvokClientRequest((client, signal) => client.getProjectFeatures({ signal }));
|
|
175
170
|
exports.useProjectFeatures = useProjectFeatures;
|
|
176
|
-
const useSlimPatients = (params = {}) => {
|
|
177
|
-
const client = (0, index_1.useClient)();
|
|
178
|
-
const serialized = JSON.stringify(params);
|
|
179
|
-
const load = React.useCallback((signal) => client.listSlimPatients(params, { signal }), [client, serialized]);
|
|
180
|
-
return useOvokRequest(load);
|
|
181
|
-
};
|
|
171
|
+
const useSlimPatients = (params = {}) => useOvokClientRequest((client, signal) => client.listSlimPatients(params, { signal }), params);
|
|
182
172
|
exports.useSlimPatients = useSlimPatients;
|
|
183
|
-
const useSlimDevices = (params = {}) => {
|
|
184
|
-
const client = (0, index_1.useClient)();
|
|
185
|
-
const serialized = JSON.stringify(params);
|
|
186
|
-
const load = React.useCallback((signal) => client.listSlimDevices(params, { signal }), [client, serialized]);
|
|
187
|
-
return useOvokRequest(load);
|
|
188
|
-
};
|
|
173
|
+
const useSlimDevices = (params = {}) => useOvokClientRequest((client, signal) => client.listSlimDevices(params, { signal }), params);
|
|
189
174
|
exports.useSlimDevices = useSlimDevices;
|
|
190
|
-
const useSlimDeviceTelemetry = (deviceId) => {
|
|
191
|
-
const client = (0, index_1.useClient)();
|
|
192
|
-
const load = React.useCallback((signal) => deviceId
|
|
193
|
-
? client.getSlimDeviceTelemetry(deviceId, { signal })
|
|
194
|
-
: Promise.reject(new Error("deviceId is required")), [client, deviceId]);
|
|
195
|
-
return useOvokRequest(load, deviceId !== undefined);
|
|
196
|
-
};
|
|
175
|
+
const useSlimDeviceTelemetry = (deviceId) => useOvokClientRequestFor("deviceId", deviceId, (client, id, signal) => client.getSlimDeviceTelemetry(id, { signal }));
|
|
197
176
|
exports.useSlimDeviceTelemetry = useSlimDeviceTelemetry;
|
|
198
|
-
/** @deprecated Use useSlimOutOfBedNotifications, useSlimAlarms, or useSlimMedicalNotifications. */
|
|
199
|
-
const useSlimNotifications = (params = {}) => {
|
|
200
|
-
const client = (0, index_1.useClient)();
|
|
201
|
-
const serialized = JSON.stringify(params);
|
|
202
|
-
const load = React.useCallback((signal) => client.listSlimNotifications(params, { signal }), [client, serialized]);
|
|
203
|
-
const { updateData, ...state } = useOvokRequestWithUpdater(load);
|
|
204
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
205
|
-
if (!change) {
|
|
206
|
-
state.reload();
|
|
207
|
-
}
|
|
208
|
-
else if (change.type === "slim") {
|
|
209
|
-
updateData((current) => current && ({
|
|
210
|
-
...current,
|
|
211
|
-
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
212
|
-
}));
|
|
213
|
-
}
|
|
214
|
-
}), [client, state.reload, updateData]);
|
|
215
|
-
return state;
|
|
216
|
-
};
|
|
217
|
-
exports.useSlimNotifications = useSlimNotifications;
|
|
218
|
-
const useRecentSlimNotifications = (count) => {
|
|
219
|
-
const client = (0, index_1.useClient)();
|
|
220
|
-
const load = React.useCallback((signal) => client.getRecentSlimNotifications(count, { signal }), [client, count]);
|
|
221
|
-
const { updateData, ...state } = useOvokRequestWithUpdater(load);
|
|
222
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
223
|
-
if (!change) {
|
|
224
|
-
state.reload();
|
|
225
|
-
}
|
|
226
|
-
else if (change.type === "slim") {
|
|
227
|
-
updateData((current) => current && ({
|
|
228
|
-
...current,
|
|
229
|
-
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
230
|
-
}));
|
|
231
|
-
}
|
|
232
|
-
}), [client, state.reload, updateData]);
|
|
233
|
-
return state;
|
|
234
|
-
};
|
|
235
|
-
exports.useRecentSlimNotifications = useRecentSlimNotifications;
|
package/dist/hooks/cms-hooks.js
CHANGED
|
@@ -38,26 +38,23 @@ exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = expor
|
|
|
38
38
|
const React = __importStar(require("react"));
|
|
39
39
|
const cms_1 = require("../client/cms");
|
|
40
40
|
const api_hooks_1 = require("./api-hooks");
|
|
41
|
-
|
|
41
|
+
/** `locale` as a CMS locale, else the runtime's language; recomputed only when `locale` changes. */
|
|
42
|
+
const useCmsLocale = (locale) => React.useMemo(() => (0, cms_1.toCmsLocale)(locale || (0, cms_1.defaultCmsLocale)()), [locale]);
|
|
42
43
|
/**
|
|
43
44
|
* A published CMS document by slug, in `options.locale` or else the runtime's
|
|
44
45
|
* language. Waits while `slug` is empty; a new CMS locale reads it again.
|
|
45
46
|
*/
|
|
46
47
|
const useCmsDocument = (collection, slug, options = {}) => {
|
|
47
|
-
const client = (0, index_1.useClient)();
|
|
48
48
|
const { tenantCode, environment, allowSignedOut } = options;
|
|
49
|
-
const locale =
|
|
50
|
-
|
|
51
|
-
return (0, api_hooks_1.useOvokRequest)(load, Boolean(slug));
|
|
49
|
+
const locale = useCmsLocale(options.locale);
|
|
50
|
+
return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getCmsDocument(collection, slug, { locale, tenantCode, environment, allowSignedOut }, { signal }), [collection, slug, locale, tenantCode, environment, allowSignedOut], Boolean(slug));
|
|
52
51
|
};
|
|
53
52
|
exports.useCmsDocument = useCmsDocument;
|
|
54
53
|
/** A page of a CMS collection, in `options.locale` or else the runtime's language. */
|
|
55
54
|
const useCmsDocuments = (collection, options = {}) => {
|
|
56
|
-
const client = (0, index_1.useClient)();
|
|
57
55
|
const { tenantCode, environment, allowSignedOut, page, limit, sort } = options;
|
|
58
|
-
const locale =
|
|
59
|
-
|
|
60
|
-
return (0, api_hooks_1.useOvokRequest)(load);
|
|
56
|
+
const locale = useCmsLocale(options.locale);
|
|
57
|
+
return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listCmsDocuments(collection, { locale, tenantCode, environment, allowSignedOut, page, limit, sort }, { signal }), [collection, locale, tenantCode, environment, allowSignedOut, page, limit, sort]);
|
|
61
58
|
};
|
|
62
59
|
exports.useCmsDocuments = useCmsDocuments;
|
|
63
60
|
/** A legal page by slug; with `tenantCode`, readable before sign-in. */
|
|
@@ -71,10 +68,8 @@ exports.useReleaseNotes = useReleaseNotes;
|
|
|
71
68
|
* runtime's language; with `tenantCode`, readable before sign-in.
|
|
72
69
|
*/
|
|
73
70
|
const useTranslations = (options = {}) => {
|
|
74
|
-
const client = (0, index_1.useClient)();
|
|
75
71
|
const { tenantCode, environment, allowSignedOut } = options;
|
|
76
|
-
const locale =
|
|
77
|
-
|
|
78
|
-
return (0, api_hooks_1.useOvokRequest)(load);
|
|
72
|
+
const locale = useCmsLocale(options.locale);
|
|
73
|
+
return (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getTranslations({ locale, tenantCode, environment, allowSignedOut }, { signal }), [locale, tenantCode, environment, allowSignedOut]);
|
|
79
74
|
};
|
|
80
75
|
exports.useTranslations = useTranslations;
|
|
@@ -1,46 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
4
|
exports.useEmailTemplates = void 0;
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
5
|
const api_hooks_1 = require("./api-hooks");
|
|
40
|
-
const
|
|
41
|
-
const useEmailTemplates = () => {
|
|
42
|
-
const client = (0, index_1.useClient)();
|
|
43
|
-
const load = React.useCallback((signal) => client.getEmailTemplates({ signal }), [client]);
|
|
44
|
-
return (0, api_hooks_1.useOvokRequest)(load);
|
|
45
|
-
};
|
|
6
|
+
const useEmailTemplates = () => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getEmailTemplates({ signal }));
|
|
46
7
|
exports.useEmailTemplates = useEmailTemplates;
|
|
@@ -1,73 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
4
|
exports.useCreateVideoCallUserAccess = exports.useCreateVideoCallAppointment = exports.useVideoCallAccess = exports.useVideoCallAppointments = exports.useContent = exports.useDocuments = exports.useConsentSignature = void 0;
|
|
38
|
-
const React = __importStar(require("react"));
|
|
39
5
|
const api_hooks_1 = require("./api-hooks");
|
|
40
|
-
const index_1 = require("./index");
|
|
41
6
|
const useConsentSignature = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.requestConsentSignature(params.consentId));
|
|
42
7
|
exports.useConsentSignature = useConsentSignature;
|
|
43
|
-
const useDocuments = (params = {}) => {
|
|
44
|
-
const client = (0, index_1.useClient)();
|
|
45
|
-
const serialized = JSON.stringify(params);
|
|
46
|
-
const load = React.useCallback((signal) => client.listDocuments(params, { signal }), [client, serialized]);
|
|
47
|
-
return (0, api_hooks_1.useOvokRequest)(load);
|
|
48
|
-
};
|
|
8
|
+
const useDocuments = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listDocuments(params, { signal }), params);
|
|
49
9
|
exports.useDocuments = useDocuments;
|
|
50
|
-
const useContent = (type, language, params = {}) => {
|
|
51
|
-
const client = (0, index_1.useClient)();
|
|
52
|
-
const serialized = JSON.stringify(params);
|
|
53
|
-
const load = React.useCallback((signal) => client.searchContent(type, language, params, { signal }), [client, language, serialized, type]);
|
|
54
|
-
return (0, api_hooks_1.useOvokRequest)(load, type.length > 0 && language.length > 0);
|
|
55
|
-
};
|
|
10
|
+
const useContent = (type, language, params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.searchContent(type, language, params, { signal }), [language, params, type], type.length > 0 && language.length > 0);
|
|
56
11
|
exports.useContent = useContent;
|
|
57
|
-
const useVideoCallAppointments = (params = {}) => {
|
|
58
|
-
const client = (0, index_1.useClient)();
|
|
59
|
-
const serialized = JSON.stringify(params);
|
|
60
|
-
const load = React.useCallback((signal) => client.listVideoCallAppointments(params, { signal }), [client, serialized]);
|
|
61
|
-
return (0, api_hooks_1.useOvokRequest)(load);
|
|
62
|
-
};
|
|
12
|
+
const useVideoCallAppointments = (params = {}) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.listVideoCallAppointments(params, { signal }), params);
|
|
63
13
|
exports.useVideoCallAppointments = useVideoCallAppointments;
|
|
64
|
-
const useVideoCallAccess = (appointmentId) => {
|
|
65
|
-
const client = (0, index_1.useClient)();
|
|
66
|
-
const load = React.useCallback((signal) => appointmentId
|
|
67
|
-
? client.getVideoCallAccessPermission(appointmentId, { signal })
|
|
68
|
-
: Promise.reject(new Error("appointmentId is required")), [appointmentId, client]);
|
|
69
|
-
return (0, api_hooks_1.useOvokRequest)(load, appointmentId !== undefined);
|
|
70
|
-
};
|
|
14
|
+
const useVideoCallAccess = (appointmentId) => (0, api_hooks_1.useOvokClientRequestFor)("appointmentId", appointmentId, (client, id, signal) => client.getVideoCallAccessPermission(id, { signal }));
|
|
71
15
|
exports.useVideoCallAccess = useVideoCallAccess;
|
|
72
16
|
const useCreateVideoCallAppointment = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.createVideoCallAppointment(params));
|
|
73
17
|
exports.useCreateVideoCallAppointment = useCreateVideoCallAppointment;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const OvokProvider: (props: React.PropsWithChildren<{
|
|
|
6
6
|
client: OvokClient;
|
|
7
7
|
}>) => React.JSX.Element;
|
|
8
8
|
export { observationsToMeasurements, useEcgRecording, useObservations, useSaveMeasurement, useUrineTests, } from "./observation-hooks";
|
|
9
|
-
export { useAdministeredProjects, useSlimDeviceTelemetry, useSlimDevices,
|
|
9
|
+
export { useAdministeredProjects, useSlimDeviceTelemetry, useSlimDevices, useSlimPatients, useCapabilityStatement, useOvokMutation, useOvokRequest, useProjectFeatures, useProjectSettings, usePublicApiEndpoints, } from "./api-hooks";
|
|
10
10
|
export type { OvokMutationState, OvokRequestState } from "./api-hooks";
|
|
11
11
|
export { useOvokPoll } from "./poll-hooks";
|
|
12
12
|
export type { OvokPollOptions, OvokPollState } from "./poll-hooks";
|
|
@@ -14,7 +14,7 @@ export { useConsentSignature, useContent, useCreateVideoCallAppointment, useCrea
|
|
|
14
14
|
export { useI18nextDocument, useLocales, useLocalizations, useUpdateI18nextDocument, useUpdateLocalization, useUpdateProjectTextSetting, } from "./platform-hooks";
|
|
15
15
|
export { useEmailTemplates } from "./email-hooks";
|
|
16
16
|
export { useChangeHistory, useLegalConsent, useMedicalConsent, useRepushUnconfirmedLimits, useSetLegalConsent, useSetMedicalConsent, useSlimPatientThresholdV2, useSlimThresholdV2, useUnconfirmedLimits, useUpdateSlimPatientThresholdV2, useUpdateSlimThresholdV2, } from "./account-hooks";
|
|
17
|
-
export { useRecentAlarms, useRecentOutOfBed, useSlimAlarms, useSlimMedicalNotifications, useSlimOutOfBedNotifications, } from "./notification-hooks";
|
|
17
|
+
export { useRecentAlarms, useRecentOutOfBed, useRecentSlimNotifications, useSlimAlarms, useSlimMedicalNotifications, useSlimNotifications, useSlimOutOfBedNotifications, } from "./notification-hooks";
|
|
18
18
|
export { useCreateNotificationNote, useCreateSignalsAlertNote, useCreateSignalsRawAlertNote, useDeleteNotificationNote, useDeleteSignalsNote, useNotificationNotes, useSignalsAlertNotes, useSignalsRawAlertNotes, useUpdateNotificationNote, useUpdateSignalsNote, } from "./notification-note-hooks";
|
|
19
19
|
export { useAcknowledgeSlimAlarm, useAcknowledgeSlimMedicalNotification, } from "./notification-ack-hooks";
|
|
20
20
|
export { useCmsDocument, useCmsDocuments, useLegalPage, useReleaseNotes, useTranslations, } from "./cms-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.useSetLegalConsent = exports.useRepushUnconfirmedLimits = exports.useMedicalConsent = exports.useLegalConsent = exports.useChangeHistory = 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.useOvokPoll = exports.
|
|
38
|
-
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.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = exports.useAcceptInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = exports.useUpdateSignalsNote = exports.useUpdateNotificationNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useNotificationNotes = exports.useDeleteSignalsNote = exports.useDeleteNotificationNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useCreateNotificationNote = exports.useSlimOutOfBedNotifications = exports.
|
|
37
|
+
exports.useSlimPatientThresholdV2 = exports.useSetMedicalConsent = exports.useSetLegalConsent = exports.useRepushUnconfirmedLimits = exports.useMedicalConsent = exports.useLegalConsent = exports.useChangeHistory = 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.useOvokPoll = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = 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.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.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = exports.useAcceptInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = exports.useUpdateSignalsNote = exports.useUpdateNotificationNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useNotificationNotes = exports.useDeleteSignalsNote = exports.useDeleteNotificationNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useCreateNotificationNote = exports.useSlimOutOfBedNotifications = exports.useSlimNotifications = exports.useSlimMedicalNotifications = exports.useSlimAlarms = exports.useRecentSlimNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useUpdateSlimThresholdV2 = exports.useUpdateSlimPatientThresholdV2 = exports.useUnconfirmedLimits = exports.useSlimThresholdV2 = void 0;
|
|
39
39
|
exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = void 0;
|
|
40
40
|
/*
|
|
41
41
|
* The only React-dependent module in the package.
|
|
@@ -82,7 +82,6 @@ var api_hooks_1 = require("./api-hooks");
|
|
|
82
82
|
Object.defineProperty(exports, "useAdministeredProjects", { enumerable: true, get: function () { return api_hooks_1.useAdministeredProjects; } });
|
|
83
83
|
Object.defineProperty(exports, "useSlimDeviceTelemetry", { enumerable: true, get: function () { return api_hooks_1.useSlimDeviceTelemetry; } });
|
|
84
84
|
Object.defineProperty(exports, "useSlimDevices", { enumerable: true, get: function () { return api_hooks_1.useSlimDevices; } });
|
|
85
|
-
Object.defineProperty(exports, "useSlimNotifications", { enumerable: true, get: function () { return api_hooks_1.useSlimNotifications; } });
|
|
86
85
|
Object.defineProperty(exports, "useSlimPatients", { enumerable: true, get: function () { return api_hooks_1.useSlimPatients; } });
|
|
87
86
|
Object.defineProperty(exports, "useCapabilityStatement", { enumerable: true, get: function () { return api_hooks_1.useCapabilityStatement; } });
|
|
88
87
|
Object.defineProperty(exports, "useOvokMutation", { enumerable: true, get: function () { return api_hooks_1.useOvokMutation; } });
|
|
@@ -90,7 +89,6 @@ Object.defineProperty(exports, "useOvokRequest", { enumerable: true, get: functi
|
|
|
90
89
|
Object.defineProperty(exports, "useProjectFeatures", { enumerable: true, get: function () { return api_hooks_1.useProjectFeatures; } });
|
|
91
90
|
Object.defineProperty(exports, "useProjectSettings", { enumerable: true, get: function () { return api_hooks_1.useProjectSettings; } });
|
|
92
91
|
Object.defineProperty(exports, "usePublicApiEndpoints", { enumerable: true, get: function () { return api_hooks_1.usePublicApiEndpoints; } });
|
|
93
|
-
Object.defineProperty(exports, "useRecentSlimNotifications", { enumerable: true, get: function () { return api_hooks_1.useRecentSlimNotifications; } });
|
|
94
92
|
var poll_hooks_1 = require("./poll-hooks");
|
|
95
93
|
Object.defineProperty(exports, "useOvokPoll", { enumerable: true, get: function () { return poll_hooks_1.useOvokPoll; } });
|
|
96
94
|
var experience_hooks_1 = require("./experience-hooks");
|
|
@@ -125,8 +123,10 @@ Object.defineProperty(exports, "useUpdateSlimThresholdV2", { enumerable: true, g
|
|
|
125
123
|
var notification_hooks_1 = require("./notification-hooks");
|
|
126
124
|
Object.defineProperty(exports, "useRecentAlarms", { enumerable: true, get: function () { return notification_hooks_1.useRecentAlarms; } });
|
|
127
125
|
Object.defineProperty(exports, "useRecentOutOfBed", { enumerable: true, get: function () { return notification_hooks_1.useRecentOutOfBed; } });
|
|
126
|
+
Object.defineProperty(exports, "useRecentSlimNotifications", { enumerable: true, get: function () { return notification_hooks_1.useRecentSlimNotifications; } });
|
|
128
127
|
Object.defineProperty(exports, "useSlimAlarms", { enumerable: true, get: function () { return notification_hooks_1.useSlimAlarms; } });
|
|
129
128
|
Object.defineProperty(exports, "useSlimMedicalNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimMedicalNotifications; } });
|
|
129
|
+
Object.defineProperty(exports, "useSlimNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimNotifications; } });
|
|
130
130
|
Object.defineProperty(exports, "useSlimOutOfBedNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimOutOfBedNotifications; } });
|
|
131
131
|
var notification_note_hooks_1 = require("./notification-note-hooks");
|
|
132
132
|
Object.defineProperty(exports, "useCreateNotificationNote", { enumerable: true, get: function () { return notification_note_hooks_1.useCreateNotificationNote; } });
|
|
@@ -10,7 +10,6 @@ const useInvitePatient = () => (0, api_hooks_1.useOvokMutation)((client, body) =
|
|
|
10
10
|
exports.useInvitePatient = useInvitePatient;
|
|
11
11
|
const useAcceptInvite = () => (0, api_hooks_1.useOvokMutation)(async (client, body) => {
|
|
12
12
|
const result = await client.acceptInvite(body);
|
|
13
|
-
client.invalidateUrl("/v1/patient-sharing/shares");
|
|
14
13
|
(0, notification_invalidation_1.notifyNotificationChanges)(client, { type: "patient-sharing" });
|
|
15
14
|
return result;
|
|
16
15
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SlimAlarmQuery, SlimAlarmsPage, SlimMedicalNotificationsQuery, SlimMedicalNotificationsCollection, SlimRecentAlarms, SlimRecentOutOfBed } from "../client/notifications";
|
|
2
|
-
import { SlimNotificationsQuery, SlimNotificationsResponse } from "../client/slim/types";
|
|
2
|
+
import { SlimNotificationsQuery, SlimNotificationsResponse, SlimRecentNotificationsResponse } from "../client/slim/types";
|
|
3
3
|
import { OvokRequestState } from "./api-hooks";
|
|
4
|
+
/** @deprecated Use useSlimOutOfBedNotifications, useSlimAlarms, or useSlimMedicalNotifications. */
|
|
5
|
+
export declare const useSlimNotifications: (params?: SlimNotificationsQuery) => OvokRequestState<SlimNotificationsResponse>;
|
|
6
|
+
export declare const useRecentSlimNotifications: (count?: number) => OvokRequestState<SlimRecentNotificationsResponse>;
|
|
4
7
|
export declare const useSlimAlarms: (params?: SlimAlarmQuery) => OvokRequestState<SlimAlarmsPage>;
|
|
5
8
|
export declare const useRecentAlarms: (count?: number) => OvokRequestState<SlimRecentAlarms>;
|
|
6
9
|
export declare const useRecentOutOfBed: (count?: number) => OvokRequestState<SlimRecentOutOfBed>;
|
|
@@ -34,107 +34,50 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.useSlimMedicalNotifications = exports.useSlimOutOfBedNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useSlimAlarms = void 0;
|
|
37
|
+
exports.useSlimMedicalNotifications = exports.useSlimOutOfBedNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useSlimAlarms = exports.useRecentSlimNotifications = exports.useSlimNotifications = void 0;
|
|
38
38
|
const React = __importStar(require("react"));
|
|
39
39
|
const paging_1 = require("../client/slim/paging");
|
|
40
40
|
const api_hooks_1 = require("./api-hooks");
|
|
41
41
|
const notification_invalidation_1 = require("./notification-invalidation");
|
|
42
42
|
const index_1 = require("./index");
|
|
43
|
+
/**
|
|
44
|
+
* A Slim notification list kept current by notification changes. `inputs` holds every value
|
|
45
|
+
* the request depends on and is compared by value, as in `useOvokClientRequest`.
|
|
46
|
+
*/
|
|
47
|
+
function useSlimNotificationFeed(request, inputs, field) {
|
|
48
|
+
const client = (0, index_1.useClient)();
|
|
49
|
+
const key = JSON.stringify(inputs);
|
|
50
|
+
// `inputs` is compared by value through `key`, so the request closure isn't a dependency.
|
|
51
|
+
const load = React.useCallback((signal) => request(client, signal), [client, key]);
|
|
52
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
53
|
+
(0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, field);
|
|
54
|
+
return state;
|
|
55
|
+
}
|
|
56
|
+
/** @deprecated Use useSlimOutOfBedNotifications, useSlimAlarms, or useSlimMedicalNotifications. */
|
|
57
|
+
const useSlimNotifications = (params = {}) => useSlimNotificationFeed((client, signal) => client.listSlimNotifications(params, { signal }), params, "resources");
|
|
58
|
+
exports.useSlimNotifications = useSlimNotifications;
|
|
59
|
+
const useRecentSlimNotifications = (count) => useSlimNotificationFeed((client, signal) => client.getRecentSlimNotifications(count, { signal }), count, "recent");
|
|
60
|
+
exports.useRecentSlimNotifications = useRecentSlimNotifications;
|
|
43
61
|
const useSlimAlarms = (params = {}) => {
|
|
44
62
|
const client = (0, index_1.useClient)();
|
|
45
63
|
const serialized = JSON.stringify(params);
|
|
46
64
|
const [revision, setRevision] = React.useState(0);
|
|
47
65
|
const load = React.useCallback((signal) => client.listSlimAlarms(params, { signal }), [client, serialized, revision]);
|
|
48
66
|
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
else if (change.type === "slim") {
|
|
54
|
-
updateData((current) => current && ({
|
|
55
|
-
...current,
|
|
56
|
-
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
}), [client, state.reload, updateData]);
|
|
60
|
-
return { ...state, reload: () => setRevision((value) => value + 1) };
|
|
67
|
+
(0, notification_invalidation_1.useSlimNotificationSync)(client, state.reload, updateData, "resources");
|
|
68
|
+
const reload = React.useCallback(() => setRevision((value) => value + 1), []);
|
|
69
|
+
return { ...state, reload };
|
|
61
70
|
};
|
|
62
71
|
exports.useSlimAlarms = useSlimAlarms;
|
|
63
|
-
const useRecentAlarms = (count) => {
|
|
64
|
-
const client = (0, index_1.useClient)();
|
|
65
|
-
const load = React.useCallback((signal) => client.getRecentAlarms(count, { signal }), [client, count]);
|
|
66
|
-
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
67
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
68
|
-
if (!change) {
|
|
69
|
-
state.reload();
|
|
70
|
-
}
|
|
71
|
-
else if (change.type === "slim") {
|
|
72
|
-
updateData((current) => current && ({
|
|
73
|
-
...current,
|
|
74
|
-
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
}), [client, state.reload, updateData]);
|
|
78
|
-
return state;
|
|
79
|
-
};
|
|
72
|
+
const useRecentAlarms = (count) => useSlimNotificationFeed((client, signal) => client.getRecentAlarms(count, { signal }), count, "recent");
|
|
80
73
|
exports.useRecentAlarms = useRecentAlarms;
|
|
81
|
-
const useRecentOutOfBed = (count) => {
|
|
82
|
-
const client = (0, index_1.useClient)();
|
|
83
|
-
const load = React.useCallback((signal) => client.getRecentOutOfBed(count, { signal }), [client, count]);
|
|
84
|
-
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
85
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
86
|
-
if (!change) {
|
|
87
|
-
state.reload();
|
|
88
|
-
}
|
|
89
|
-
else if (change.type === "slim") {
|
|
90
|
-
updateData((current) => current && ({
|
|
91
|
-
...current,
|
|
92
|
-
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
}), [client, state.reload, updateData]);
|
|
96
|
-
return state;
|
|
97
|
-
};
|
|
74
|
+
const useRecentOutOfBed = (count) => useSlimNotificationFeed((client, signal) => client.getRecentOutOfBed(count, { signal }), count, "recent");
|
|
98
75
|
exports.useRecentOutOfBed = useRecentOutOfBed;
|
|
99
|
-
const useSlimOutOfBedNotifications = (params = {}) => {
|
|
100
|
-
const client = (0, index_1.useClient)();
|
|
101
|
-
const serialized = JSON.stringify(params);
|
|
102
|
-
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(React.useCallback((signal) => client.listSlimOutOfBedNotifications(params, { signal }), [client, serialized]));
|
|
103
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
104
|
-
if (!change) {
|
|
105
|
-
state.reload();
|
|
106
|
-
}
|
|
107
|
-
else if (change.type === "slim") {
|
|
108
|
-
updateData((current) => current && ({
|
|
109
|
-
...current,
|
|
110
|
-
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
}), [client, state.reload, updateData]);
|
|
114
|
-
return state;
|
|
115
|
-
};
|
|
76
|
+
const useSlimOutOfBedNotifications = (params = {}) => useSlimNotificationFeed((client, signal) => client.listSlimOutOfBedNotifications(params, { signal }), params, "resources");
|
|
116
77
|
exports.useSlimOutOfBedNotifications = useSlimOutOfBedNotifications;
|
|
117
78
|
/** Fetches every cursor page; a short page is not treated as the end of the feed. */
|
|
118
|
-
const useSlimMedicalNotifications = (params = {}, options = {}) => {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const load = React.useCallback(async (signal) => {
|
|
123
|
-
const result = await (0, paging_1.iterateCursor)((cursor) => client.listSlimMedicalNotifications({ ...params, cursor }, { signal }), options);
|
|
124
|
-
return { items: result.rows, nextCursor: null, total: result.total, truncated: result.truncated };
|
|
125
|
-
}, [client, serialized, serializedOptions]);
|
|
126
|
-
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
127
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
128
|
-
if (!change) {
|
|
129
|
-
state.reload();
|
|
130
|
-
}
|
|
131
|
-
else if (change.type === "slim") {
|
|
132
|
-
updateData((current) => current && ({
|
|
133
|
-
...current,
|
|
134
|
-
items: current.items.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
}), [client, state.reload, updateData]);
|
|
138
|
-
return state;
|
|
139
|
-
};
|
|
79
|
+
const useSlimMedicalNotifications = (params = {}, options = {}) => useSlimNotificationFeed(async (client, signal) => {
|
|
80
|
+
const result = await (0, paging_1.iterateCursor)((cursor) => client.listSlimMedicalNotifications({ ...params, cursor }, { signal }), options);
|
|
81
|
+
return { items: result.rows, nextCursor: null, total: result.total, truncated: result.truncated };
|
|
82
|
+
}, [params, options], "items");
|
|
140
83
|
exports.useSlimMedicalNotifications = useSlimMedicalNotifications;
|
|
@@ -18,4 +18,10 @@ type NotificationChangeListener = (change?: NotificationChange) => void;
|
|
|
18
18
|
export declare function subscribeToNotificationChanges(client: OvokClient, listener: NotificationChangeListener): () => void;
|
|
19
19
|
export declare function notifyNotificationChanges(client: OvokClient, change?: NotificationChange): void;
|
|
20
20
|
export declare function mergeSlimNotification<T extends object>(item: T, notification: SlimNotification | SlimMedicalNotificationRow): T;
|
|
21
|
+
export type SlimListField = "resources" | "recent" | "items";
|
|
22
|
+
/**
|
|
23
|
+
* Keeps a mounted Slim notification list current: a full invalidation reloads it, a single
|
|
24
|
+
* Slim change is merged into the matching rows of `field`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useSlimNotificationSync<K extends SlimListField, T extends Record<K, readonly object[]>>(client: OvokClient, reload: () => void, updateData: (update: (current: T | undefined) => T | undefined) => void, field: K): void;
|
|
21
27
|
export {};
|