@ovok/core 0.4.29 → 0.4.30
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/notifications/methods.js +1 -1
- package/dist/client/signals/methods.js +6 -6
- package/dist/client/slim/methods.js +13 -13
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/hooks/api-hooks.d.ts +4 -0
- package/dist/hooks/api-hooks.js +35 -3
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.js +16 -12
- package/dist/hooks/notification-ack-hooks.d.ts +6 -0
- package/dist/hooks/notification-ack-hooks.js +20 -0
- package/dist/hooks/notification-hooks.d.ts +2 -25
- package/dist/hooks/notification-hooks.js +63 -55
- package/dist/hooks/notification-invalidation.d.ts +17 -2
- package/dist/hooks/notification-invalidation.js +7 -2
- package/dist/hooks/notification-note-hooks.d.ts +25 -0
- package/dist/hooks/notification-note-hooks.js +99 -0
- package/dist/hooks/signals-alert-hooks.js +20 -4
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ function createNotificationNote(body) {
|
|
|
16
16
|
return this.post("/v1/slim/notifications/notes", body);
|
|
17
17
|
}
|
|
18
18
|
function listNotificationNotes(kind, id) {
|
|
19
|
-
return this.get(`/v1/slim/notifications/${TARGET_PATH[kind]}/${segment(id)}/notes
|
|
19
|
+
return this.get(`/v1/slim/notifications/${TARGET_PATH[kind]}/${segment(id)}/notes`, { cache: "reload" });
|
|
20
20
|
}
|
|
21
21
|
function updateNotificationNote(noteId, body) {
|
|
22
22
|
return this.put(`/v1/slim/notifications/notes/${segment(noteId)}`, body);
|
|
@@ -72,22 +72,22 @@ function serializeSignalsAlertsQuery(query = {}, keys = EPISODE_QUERY_KEYS) {
|
|
|
72
72
|
}
|
|
73
73
|
function listSignalsAlerts(query = {}) {
|
|
74
74
|
const serialized = serializeSignalsAlertsQuery(query);
|
|
75
|
-
return this.get(`/v1/signals/alerts${serialized ? `?${serialized}` : ""}
|
|
75
|
+
return this.get(`/v1/signals/alerts${serialized ? `?${serialized}` : ""}`, { cache: "reload" });
|
|
76
76
|
}
|
|
77
77
|
function getSignalsAlert(episodeId) {
|
|
78
|
-
return this.get(`/v1/signals/alerts/${segment(episodeId)}
|
|
78
|
+
return this.get(`/v1/signals/alerts/${segment(episodeId)}`, { cache: "reload" });
|
|
79
79
|
}
|
|
80
80
|
function acknowledgeSignalsAlert(episodeId) {
|
|
81
81
|
return this.post(`/v1/signals/alerts/${segment(episodeId)}/ack`);
|
|
82
82
|
}
|
|
83
83
|
function listSignalsAlertNotes(episodeId) {
|
|
84
|
-
return this.get(`/v1/signals/alerts/${segment(episodeId)}/notes
|
|
84
|
+
return this.get(`/v1/signals/alerts/${segment(episodeId)}/notes`, { cache: "reload" });
|
|
85
85
|
}
|
|
86
86
|
function createSignalsAlertNote(episodeId, body) {
|
|
87
87
|
return this.post(`/v1/signals/alerts/${segment(episodeId)}/notes`, body);
|
|
88
88
|
}
|
|
89
89
|
function listSignalsRawAlertNotes(alertId) {
|
|
90
|
-
return this.get(`/v1/signals/raw-alerts/${segment(alertId)}/notes
|
|
90
|
+
return this.get(`/v1/signals/raw-alerts/${segment(alertId)}/notes`, { cache: "reload" });
|
|
91
91
|
}
|
|
92
92
|
function createSignalsRawAlertNote(alertId, body) {
|
|
93
93
|
return this.post(`/v1/signals/raw-alerts/${segment(alertId)}/notes`, body);
|
|
@@ -107,10 +107,10 @@ async function deleteSignalsNote(noteId) {
|
|
|
107
107
|
*/
|
|
108
108
|
function listSignalsRawAlerts(query = {}) {
|
|
109
109
|
const serialized = serializeSignalsAlertsQuery(query, RAW_ALERT_QUERY_KEYS);
|
|
110
|
-
return this.get(`/v1/signals/raw-alerts${serialized ? `?${serialized}` : ""}
|
|
110
|
+
return this.get(`/v1/signals/raw-alerts${serialized ? `?${serialized}` : ""}`, { cache: "reload" });
|
|
111
111
|
}
|
|
112
112
|
function getSignalsRawAlert(alertId) {
|
|
113
|
-
return this.get(`/v1/signals/raw-alerts/${segment(alertId)}
|
|
113
|
+
return this.get(`/v1/signals/raw-alerts/${segment(alertId)}`, { cache: "reload" });
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Acknowledges one alert: it resolves, and `acknowledgedAt` and `acknowledgedActor` record when
|
|
@@ -105,16 +105,16 @@ async function assignSlimDeviceToProject(body) {
|
|
|
105
105
|
return (await this.put("/v1/slim/device/assign/project", body));
|
|
106
106
|
}
|
|
107
107
|
async function listSlimLiveDevices(params = {}) {
|
|
108
|
-
return this.get(`/v1/slim/device/live${query(params)}
|
|
108
|
+
return this.get(`/v1/slim/device/live${query(params)}`, { cache: "reload" });
|
|
109
109
|
}
|
|
110
110
|
async function listSlimLiveTelemetry(params = {}) {
|
|
111
|
-
return this.get(`/v1/slim/device/live/telemetry${query(params)}
|
|
111
|
+
return this.get(`/v1/slim/device/live/telemetry${query(params)}`, { cache: "reload" });
|
|
112
112
|
}
|
|
113
113
|
async function getSlimDeviceSleepStatus(deviceId) {
|
|
114
|
-
return this.get(`/v1/slim/device/live/cloudwatch/${segment(deviceId)}
|
|
114
|
+
return this.get(`/v1/slim/device/live/cloudwatch/${segment(deviceId)}`, { cache: "reload" });
|
|
115
115
|
}
|
|
116
116
|
async function getSlimDeviceTelemetry(deviceId) {
|
|
117
|
-
return this.get(`/v1/slim/telemetry/${segment(deviceId)}
|
|
117
|
+
return this.get(`/v1/slim/telemetry/${segment(deviceId)}`, { cache: "reload" });
|
|
118
118
|
}
|
|
119
119
|
async function listSlimEffectiveObservationIds() {
|
|
120
120
|
return this.get("/v1/slim/telemetry/effectiveIds");
|
|
@@ -130,35 +130,35 @@ async function getSlimDeviceLastObservationIds(deviceId) {
|
|
|
130
130
|
}
|
|
131
131
|
/** @deprecated Use listSlimOutOfBedNotifications, listSlimAlarms, or listSlimMedicalNotifications. */
|
|
132
132
|
async function listSlimNotifications(params = {}) {
|
|
133
|
-
return this.get(`/v1/slim/notifications${query(params)}
|
|
133
|
+
return this.get(`/v1/slim/notifications${query(params)}`, { cache: "reload" });
|
|
134
134
|
}
|
|
135
135
|
async function getRecentSlimNotifications(count) {
|
|
136
|
-
return this.get(`/v1/slim/notifications/recent${query({ count })}
|
|
136
|
+
return this.get(`/v1/slim/notifications/recent${query({ count })}`, { cache: "reload" });
|
|
137
137
|
}
|
|
138
138
|
async function listSlimAlarms(params = {}) {
|
|
139
|
-
return this.get(`/v1/slim/notifications/alarms${query(params)}
|
|
139
|
+
return this.get(`/v1/slim/notifications/alarms${query(params)}`, { cache: "reload" });
|
|
140
140
|
}
|
|
141
141
|
async function acknowledgeSlimAlarm(notificationId) {
|
|
142
142
|
return (await this.patch(`/v1/slim/notifications/${segment(notificationId)}/ack`, []));
|
|
143
143
|
}
|
|
144
144
|
async function getRecentSlimAlarms(count) {
|
|
145
|
-
return this.get(`/v1/slim/notifications/recent/alarms${query({ count })}
|
|
145
|
+
return this.get(`/v1/slim/notifications/recent/alarms${query({ count })}`, { cache: "reload" });
|
|
146
146
|
}
|
|
147
147
|
function getRecentAlarms(count) {
|
|
148
148
|
return getRecentSlimAlarms.call(this, count);
|
|
149
149
|
}
|
|
150
150
|
async function getRecentSlimOutOfBed(count) {
|
|
151
|
-
return this.get(`/v1/slim/notifications/recent/oob${query({ count })}
|
|
151
|
+
return this.get(`/v1/slim/notifications/recent/oob${query({ count })}`, { cache: "reload" });
|
|
152
152
|
}
|
|
153
153
|
function getRecentOutOfBed(count) {
|
|
154
154
|
return getRecentSlimOutOfBed.call(this, count);
|
|
155
155
|
}
|
|
156
156
|
async function listSlimOutOfBedNotifications(params = {}) {
|
|
157
|
-
return this.get(`/v1/slim/notifications/oob${query(params)}
|
|
157
|
+
return this.get(`/v1/slim/notifications/oob${query(params)}`, { cache: "reload" });
|
|
158
158
|
}
|
|
159
159
|
async function listSlimMedicalNotifications(params = {}) {
|
|
160
160
|
validateMedicalCodes(params.codes);
|
|
161
|
-
return this.get(`/v1/slim/notifications/medical${query(params)}
|
|
161
|
+
return this.get(`/v1/slim/notifications/medical${query(params)}`, { cache: "reload" });
|
|
162
162
|
}
|
|
163
163
|
const MEDICAL_CODE = /^(?:\d{1,7}-\d|PI)$/;
|
|
164
164
|
function validateMedicalCodes(codes) {
|
|
@@ -168,10 +168,10 @@ function validateMedicalCodes(codes) {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
async function getRecentSlimMedicalNotifications(count) {
|
|
171
|
-
return this.get(`/v1/slim/notifications/recent/medical${query({ count })}
|
|
171
|
+
return this.get(`/v1/slim/notifications/recent/medical${query({ count })}`, { cache: "reload" });
|
|
172
172
|
}
|
|
173
173
|
async function getSlimMedicalNotification(episodeId) {
|
|
174
|
-
return this.get(`/v1/slim/notifications/medical/${segment(episodeId)}
|
|
174
|
+
return this.get(`/v1/slim/notifications/medical/${segment(episodeId)}`, { cache: "reload" });
|
|
175
175
|
}
|
|
176
176
|
async function acknowledgeSlimMedicalNotification(episodeId) {
|
|
177
177
|
return this.post(`/v1/slim/notifications/medical/${segment(episodeId)}/ack`);
|
|
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
|
|
|
48
48
|
description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
|
|
49
49
|
software: {
|
|
50
50
|
name: "@ovok/core",
|
|
51
|
-
version: "0.4.
|
|
51
|
+
version: "0.4.30",
|
|
52
52
|
},
|
|
53
53
|
fhirVersion: "4.0.1",
|
|
54
54
|
format: ["json"],
|
|
@@ -22,6 +22,10 @@ export type OvokMutationState<TParams, TData> = {
|
|
|
22
22
|
* the host app owns the retry policy appropriate to its screen.
|
|
23
23
|
*/
|
|
24
24
|
export declare function useOvokRequest<T>(load: () => Promise<T>, enabled?: boolean): OvokRequestState<T>;
|
|
25
|
+
/** Internal variant for list hooks that reconcile server-confirmed changes in mounted data. */
|
|
26
|
+
export declare function useOvokRequestWithUpdater<T>(load: () => Promise<T>, enabled?: boolean): OvokRequestState<T> & {
|
|
27
|
+
updateData(update: (current: T | undefined) => T | undefined): void;
|
|
28
|
+
};
|
|
25
29
|
/** Generic mutation hook for any typed OvokClient method. */
|
|
26
30
|
export declare function useOvokMutation<TParams, TData>(mutateRequest: (client: OvokClient, params: TParams) => Promise<TData>): OvokMutationState<TParams, TData>;
|
|
27
31
|
export declare const useCapabilityStatement: (version?: OvokFhirVersion) => OvokRequestState<CapabilityStatement>;
|
package/dist/hooks/api-hooks.js
CHANGED
|
@@ -36,8 +36,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.useRecentSlimNotifications = exports.useSlimNotifications = exports.useSlimDeviceTelemetry = exports.useSlimDevices = exports.useSlimPatients = exports.useProjectFeatures = exports.useProjectSettings = exports.useAdministeredProjects = exports.usePublicApiEndpoints = exports.useCapabilityStatement = void 0;
|
|
38
38
|
exports.useOvokRequest = useOvokRequest;
|
|
39
|
+
exports.useOvokRequestWithUpdater = useOvokRequestWithUpdater;
|
|
39
40
|
exports.useOvokMutation = useOvokMutation;
|
|
40
41
|
const React = __importStar(require("react"));
|
|
42
|
+
const notification_invalidation_1 = require("./notification-invalidation");
|
|
41
43
|
const index_1 = require("./index");
|
|
42
44
|
const toError = (error) => error instanceof Error ? error : new Error(String(error));
|
|
43
45
|
/**
|
|
@@ -46,6 +48,11 @@ const toError = (error) => error instanceof Error ? error : new Error(String(err
|
|
|
46
48
|
* the host app owns the retry policy appropriate to its screen.
|
|
47
49
|
*/
|
|
48
50
|
function useOvokRequest(load, enabled = true) {
|
|
51
|
+
const { data, loading, error, reload } = useOvokRequestWithUpdater(load, enabled);
|
|
52
|
+
return { data, loading, error, reload };
|
|
53
|
+
}
|
|
54
|
+
/** Internal variant for list hooks that reconcile server-confirmed changes in mounted data. */
|
|
55
|
+
function useOvokRequestWithUpdater(load, enabled = true) {
|
|
49
56
|
const [data, setData] = React.useState();
|
|
50
57
|
const [error, setError] = React.useState();
|
|
51
58
|
const [loading, setLoading] = React.useState(enabled);
|
|
@@ -79,7 +86,8 @@ function useOvokRequest(load, enabled = true) {
|
|
|
79
86
|
};
|
|
80
87
|
}, [enabled, load, revision]);
|
|
81
88
|
const reload = React.useCallback(() => setRevision((value) => value + 1), []);
|
|
82
|
-
|
|
89
|
+
const updateData = React.useCallback((update) => setData(update), []);
|
|
90
|
+
return { data, loading, error, reload, updateData };
|
|
83
91
|
}
|
|
84
92
|
/** Generic mutation hook for any typed OvokClient method. */
|
|
85
93
|
function useOvokMutation(mutateRequest) {
|
|
@@ -169,12 +177,36 @@ const useSlimNotifications = (params = {}) => {
|
|
|
169
177
|
const client = (0, index_1.useClient)();
|
|
170
178
|
const serialized = JSON.stringify(params);
|
|
171
179
|
const load = React.useCallback(() => client.listSlimNotifications(params), [client, serialized]);
|
|
172
|
-
|
|
180
|
+
const { updateData, ...state } = useOvokRequestWithUpdater(load);
|
|
181
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
182
|
+
if (!change) {
|
|
183
|
+
state.reload();
|
|
184
|
+
}
|
|
185
|
+
else if (change.type === "slim") {
|
|
186
|
+
updateData((current) => current && ({
|
|
187
|
+
...current,
|
|
188
|
+
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
}), [client, state.reload, updateData]);
|
|
192
|
+
return state;
|
|
173
193
|
};
|
|
174
194
|
exports.useSlimNotifications = useSlimNotifications;
|
|
175
195
|
const useRecentSlimNotifications = (count) => {
|
|
176
196
|
const client = (0, index_1.useClient)();
|
|
177
197
|
const load = React.useCallback(() => client.getRecentSlimNotifications(count), [client, count]);
|
|
178
|
-
|
|
198
|
+
const { updateData, ...state } = useOvokRequestWithUpdater(load);
|
|
199
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
200
|
+
if (!change) {
|
|
201
|
+
state.reload();
|
|
202
|
+
}
|
|
203
|
+
else if (change.type === "slim") {
|
|
204
|
+
updateData((current) => current && ({
|
|
205
|
+
...current,
|
|
206
|
+
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
}), [client, state.reload, updateData]);
|
|
210
|
+
return state;
|
|
179
211
|
};
|
|
180
212
|
exports.useRecentSlimNotifications = useRecentSlimNotifications;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export { useConsentSignature, useContent, useCreateVideoCallAppointment, useCrea
|
|
|
12
12
|
export { useI18nextDocument, useLocales, useLocalizations, useUpdateI18nextDocument, useUpdateLocalization, useUpdateProjectTextSetting, } from "./platform-hooks";
|
|
13
13
|
export { useEmailTemplates } from "./email-hooks";
|
|
14
14
|
export { useChangeHistory, useLegalConsent, useMedicalConsent, useRepushUnconfirmedLimits, useSetLegalConsent, useSetMedicalConsent, useSlimPatientThresholdV2, useSlimThresholdV2, useUnconfirmedLimits, useUpdateSlimPatientThresholdV2, useUpdateSlimThresholdV2, } from "./account-hooks";
|
|
15
|
-
export {
|
|
15
|
+
export { useRecentAlarms, useRecentOutOfBed, useSlimAlarms, useSlimMedicalNotifications, useSlimOutOfBedNotifications, } from "./notification-hooks";
|
|
16
|
+
export { useCreateNotificationNote, useCreateSignalsAlertNote, useCreateSignalsRawAlertNote, useDeleteNotificationNote, useDeleteSignalsNote, useNotificationNotes, useSignalsAlertNotes, useSignalsRawAlertNotes, useUpdateNotificationNote, useUpdateSignalsNote, } from "./notification-note-hooks";
|
|
17
|
+
export { useAcknowledgeSlimAlarm, useAcknowledgeSlimMedicalNotification, } from "./notification-ack-hooks";
|
|
16
18
|
export { useCmsDocument, useCmsDocuments, useLegalPage, useReleaseNotes, useTranslations, } from "./cms-hooks";
|
|
17
19
|
export { useAcceptInvite, useInvitePatient, useInvitePractitioner, } from "./invites-hooks";
|
|
18
20
|
export { useCurrentPatientProfile, useExtractQuestionnaireObservations, usePatientAppointments, usePatientCarePlans, usePatientDevices, usePatientDeviceTelemetry, usePatientDeviceTelemetryHistory, usePatientMeasurement, usePatientMeasurementHistory, usePatientDashboard, usePatientLatestObservations, usePatientNotifications, usePatientQuestionnaireResponses, usePatientQuestionnaires, usePatientSchedules, usePatientSlots, usePopulateQuestionnaire, useSubmitQuestionnaireResponse, } from "./patient-hooks";
|
package/dist/hooks/index.js
CHANGED
|
@@ -35,8 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
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.useRecentSlimNotifications = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = exports.useSlimNotifications = exports.useSlimDevices = exports.useSlimDeviceTelemetry = exports.useAdministeredProjects = exports.useUrineTests = exports.useSaveMeasurement = exports.useObservations = exports.useEcgRecording = exports.observationsToMeasurements = exports.OvokProvider = exports.useClient = exports.useCachedBinaryUrl = exports.reactContext = exports.useSubscription = exports.useSearchResources = exports.useSearchOne = exports.useSearch = exports.useResource = exports.usePrevious = exports.useMedplumProfile = exports.useMedplumNavigate = exports.useMedplumContext = void 0;
|
|
38
|
-
exports.
|
|
39
|
-
exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = void 0;
|
|
38
|
+
exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDeviceTelemetryHistory = exports.usePatientDeviceTelemetry = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useInvitePractitioner = exports.useInvitePatient = 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.useSlimMedicalNotifications = exports.useSlimAlarms = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useUpdateSlimThresholdV2 = exports.useUpdateSlimPatientThresholdV2 = exports.useUnconfirmedLimits = exports.useSlimThresholdV2 = exports.useSlimPatientThresholdV2 = void 0;
|
|
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 = exports.usePatientSharingSettings = void 0;
|
|
40
40
|
/*
|
|
41
41
|
* The only React-dependent module in the package.
|
|
42
42
|
*
|
|
@@ -121,21 +121,25 @@ Object.defineProperty(exports, "useUnconfirmedLimits", { enumerable: true, get:
|
|
|
121
121
|
Object.defineProperty(exports, "useUpdateSlimPatientThresholdV2", { enumerable: true, get: function () { return account_hooks_1.useUpdateSlimPatientThresholdV2; } });
|
|
122
122
|
Object.defineProperty(exports, "useUpdateSlimThresholdV2", { enumerable: true, get: function () { return account_hooks_1.useUpdateSlimThresholdV2; } });
|
|
123
123
|
var notification_hooks_1 = require("./notification-hooks");
|
|
124
|
-
Object.defineProperty(exports, "useCreateNotificationNote", { enumerable: true, get: function () { return notification_hooks_1.useCreateNotificationNote; } });
|
|
125
|
-
Object.defineProperty(exports, "useCreateSignalsAlertNote", { enumerable: true, get: function () { return notification_hooks_1.useCreateSignalsAlertNote; } });
|
|
126
|
-
Object.defineProperty(exports, "useCreateSignalsRawAlertNote", { enumerable: true, get: function () { return notification_hooks_1.useCreateSignalsRawAlertNote; } });
|
|
127
|
-
Object.defineProperty(exports, "useDeleteNotificationNote", { enumerable: true, get: function () { return notification_hooks_1.useDeleteNotificationNote; } });
|
|
128
|
-
Object.defineProperty(exports, "useDeleteSignalsNote", { enumerable: true, get: function () { return notification_hooks_1.useDeleteSignalsNote; } });
|
|
129
|
-
Object.defineProperty(exports, "useNotificationNotes", { enumerable: true, get: function () { return notification_hooks_1.useNotificationNotes; } });
|
|
130
124
|
Object.defineProperty(exports, "useRecentAlarms", { enumerable: true, get: function () { return notification_hooks_1.useRecentAlarms; } });
|
|
131
125
|
Object.defineProperty(exports, "useRecentOutOfBed", { enumerable: true, get: function () { return notification_hooks_1.useRecentOutOfBed; } });
|
|
132
|
-
Object.defineProperty(exports, "useSignalsAlertNotes", { enumerable: true, get: function () { return notification_hooks_1.useSignalsAlertNotes; } });
|
|
133
|
-
Object.defineProperty(exports, "useSignalsRawAlertNotes", { enumerable: true, get: function () { return notification_hooks_1.useSignalsRawAlertNotes; } });
|
|
134
126
|
Object.defineProperty(exports, "useSlimAlarms", { enumerable: true, get: function () { return notification_hooks_1.useSlimAlarms; } });
|
|
135
127
|
Object.defineProperty(exports, "useSlimMedicalNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimMedicalNotifications; } });
|
|
136
128
|
Object.defineProperty(exports, "useSlimOutOfBedNotifications", { enumerable: true, get: function () { return notification_hooks_1.useSlimOutOfBedNotifications; } });
|
|
137
|
-
|
|
138
|
-
Object.defineProperty(exports, "
|
|
129
|
+
var notification_note_hooks_1 = require("./notification-note-hooks");
|
|
130
|
+
Object.defineProperty(exports, "useCreateNotificationNote", { enumerable: true, get: function () { return notification_note_hooks_1.useCreateNotificationNote; } });
|
|
131
|
+
Object.defineProperty(exports, "useCreateSignalsAlertNote", { enumerable: true, get: function () { return notification_note_hooks_1.useCreateSignalsAlertNote; } });
|
|
132
|
+
Object.defineProperty(exports, "useCreateSignalsRawAlertNote", { enumerable: true, get: function () { return notification_note_hooks_1.useCreateSignalsRawAlertNote; } });
|
|
133
|
+
Object.defineProperty(exports, "useDeleteNotificationNote", { enumerable: true, get: function () { return notification_note_hooks_1.useDeleteNotificationNote; } });
|
|
134
|
+
Object.defineProperty(exports, "useDeleteSignalsNote", { enumerable: true, get: function () { return notification_note_hooks_1.useDeleteSignalsNote; } });
|
|
135
|
+
Object.defineProperty(exports, "useNotificationNotes", { enumerable: true, get: function () { return notification_note_hooks_1.useNotificationNotes; } });
|
|
136
|
+
Object.defineProperty(exports, "useSignalsAlertNotes", { enumerable: true, get: function () { return notification_note_hooks_1.useSignalsAlertNotes; } });
|
|
137
|
+
Object.defineProperty(exports, "useSignalsRawAlertNotes", { enumerable: true, get: function () { return notification_note_hooks_1.useSignalsRawAlertNotes; } });
|
|
138
|
+
Object.defineProperty(exports, "useUpdateNotificationNote", { enumerable: true, get: function () { return notification_note_hooks_1.useUpdateNotificationNote; } });
|
|
139
|
+
Object.defineProperty(exports, "useUpdateSignalsNote", { enumerable: true, get: function () { return notification_note_hooks_1.useUpdateSignalsNote; } });
|
|
140
|
+
var notification_ack_hooks_1 = require("./notification-ack-hooks");
|
|
141
|
+
Object.defineProperty(exports, "useAcknowledgeSlimAlarm", { enumerable: true, get: function () { return notification_ack_hooks_1.useAcknowledgeSlimAlarm; } });
|
|
142
|
+
Object.defineProperty(exports, "useAcknowledgeSlimMedicalNotification", { enumerable: true, get: function () { return notification_ack_hooks_1.useAcknowledgeSlimMedicalNotification; } });
|
|
139
143
|
var cms_hooks_1 = require("./cms-hooks");
|
|
140
144
|
Object.defineProperty(exports, "useCmsDocument", { enumerable: true, get: function () { return cms_hooks_1.useCmsDocument; } });
|
|
141
145
|
Object.defineProperty(exports, "useCmsDocuments", { enumerable: true, get: function () { return cms_hooks_1.useCmsDocuments; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SlimNotification } from "../client/slim/types";
|
|
2
|
+
import { OvokMutationState } from "./api-hooks";
|
|
3
|
+
/** Acknowledges one Slim alarm and updates matching mounted rows using the same client. */
|
|
4
|
+
export declare const useAcknowledgeSlimAlarm: () => OvokMutationState<string, SlimNotification>;
|
|
5
|
+
/** Acknowledges one medical notification and updates matching mounted rows using the same client. */
|
|
6
|
+
export declare const useAcknowledgeSlimMedicalNotification: () => OvokMutationState<string, SlimNotification>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = void 0;
|
|
5
|
+
const api_hooks_1 = require("./api-hooks");
|
|
6
|
+
const notification_invalidation_1 = require("./notification-invalidation");
|
|
7
|
+
/** Acknowledges one Slim alarm and updates matching mounted rows using the same client. */
|
|
8
|
+
const useAcknowledgeSlimAlarm = () => (0, api_hooks_1.useOvokMutation)(async (client, notificationId) => {
|
|
9
|
+
const result = await client.acknowledgeSlimAlarm(notificationId);
|
|
10
|
+
(0, notification_invalidation_1.notifyNotificationChanges)(client, { type: "slim", notification: result });
|
|
11
|
+
return result;
|
|
12
|
+
});
|
|
13
|
+
exports.useAcknowledgeSlimAlarm = useAcknowledgeSlimAlarm;
|
|
14
|
+
/** Acknowledges one medical notification and updates matching mounted rows using the same client. */
|
|
15
|
+
const useAcknowledgeSlimMedicalNotification = () => (0, api_hooks_1.useOvokMutation)(async (client, episodeId) => {
|
|
16
|
+
const result = await client.acknowledgeSlimMedicalNotification(episodeId);
|
|
17
|
+
(0, notification_invalidation_1.notifyNotificationChanges)(client, { type: "slim", notification: result });
|
|
18
|
+
return result;
|
|
19
|
+
});
|
|
20
|
+
exports.useAcknowledgeSlimMedicalNotification = useAcknowledgeSlimMedicalNotification;
|
|
@@ -1,32 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NotificationTargetKind } from "../client/notifications/types";
|
|
1
|
+
import { SlimAlarmQuery, SlimAlarmsPage, SlimMedicalNotificationsQuery, SlimMedicalNotificationsPage, SlimRecentAlarms, SlimRecentOutOfBed } from "../client/notifications";
|
|
3
2
|
import { SlimNotificationsQuery, SlimNotificationsResponse } from "../client/slim/types";
|
|
4
|
-
import {
|
|
3
|
+
import { OvokRequestState } from "./api-hooks";
|
|
5
4
|
export declare const useSlimAlarms: (params?: SlimAlarmQuery) => OvokRequestState<SlimAlarmsPage>;
|
|
6
5
|
export declare const useRecentAlarms: (count?: number) => OvokRequestState<SlimRecentAlarms>;
|
|
7
6
|
export declare const useRecentOutOfBed: (count?: number) => OvokRequestState<SlimRecentOutOfBed>;
|
|
8
7
|
export declare const useSlimOutOfBedNotifications: (params?: Omit<SlimNotificationsQuery, "type">) => OvokRequestState<SlimNotificationsResponse>;
|
|
9
8
|
/** Fetches every cursor page; a short page is not treated as the end of the feed. */
|
|
10
9
|
export declare const useSlimMedicalNotifications: (params?: Omit<SlimMedicalNotificationsQuery, "cursor">) => OvokRequestState<SlimMedicalNotificationsPage>;
|
|
11
|
-
export declare const useNotificationNotes: (kind: NotificationTargetKind, id?: string) => OvokRequestState<NotificationNotes>;
|
|
12
|
-
export declare const useCreateNotificationNote: () => OvokMutationState<CreateNotificationNote, NotificationNote>;
|
|
13
|
-
export declare const useUpdateNotificationNote: () => OvokMutationState<{
|
|
14
|
-
noteId: string;
|
|
15
|
-
body: UpdateNotificationNote;
|
|
16
|
-
}, NotificationNote>;
|
|
17
|
-
export declare const useDeleteNotificationNote: () => OvokMutationState<string, void>;
|
|
18
|
-
export declare const useSignalsAlertNotes: (episodeId?: string) => OvokRequestState<NotificationNotes>;
|
|
19
|
-
export declare const useSignalsRawAlertNotes: (alertId?: string) => OvokRequestState<NotificationNotes>;
|
|
20
|
-
export declare const useCreateSignalsAlertNote: () => OvokMutationState<{
|
|
21
|
-
episodeId: string;
|
|
22
|
-
text: string;
|
|
23
|
-
}, NotificationNote>;
|
|
24
|
-
export declare const useCreateSignalsRawAlertNote: () => OvokMutationState<{
|
|
25
|
-
alertId: string;
|
|
26
|
-
text: string;
|
|
27
|
-
}, NotificationNote>;
|
|
28
|
-
export declare const useUpdateSignalsNote: () => OvokMutationState<{
|
|
29
|
-
noteId: string;
|
|
30
|
-
body: UpdateNotificationNote;
|
|
31
|
-
}, NotificationNote>;
|
|
32
|
-
export declare const useDeleteSignalsNote: () => OvokMutationState<string, void>;
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
37
|
+
exports.useSlimMedicalNotifications = exports.useSlimOutOfBedNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useSlimAlarms = void 0;
|
|
38
38
|
const React = __importStar(require("react"));
|
|
39
39
|
const api_hooks_1 = require("./api-hooks");
|
|
40
40
|
const notification_invalidation_1 = require("./notification-invalidation");
|
|
@@ -44,28 +44,72 @@ const useSlimAlarms = (params = {}) => {
|
|
|
44
44
|
const serialized = JSON.stringify(params);
|
|
45
45
|
const [revision, setRevision] = React.useState(0);
|
|
46
46
|
const load = React.useCallback(() => client.listSlimAlarms(params), [client, serialized, revision]);
|
|
47
|
-
const state = (0, api_hooks_1.
|
|
48
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client,
|
|
47
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
48
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
49
|
+
if (!change) {
|
|
50
|
+
state.reload();
|
|
51
|
+
}
|
|
52
|
+
else if (change.type === "slim") {
|
|
53
|
+
updateData((current) => current && ({
|
|
54
|
+
...current,
|
|
55
|
+
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
}), [client, state.reload, updateData]);
|
|
49
59
|
return { ...state, reload: () => setRevision((value) => value + 1) };
|
|
50
60
|
};
|
|
51
61
|
exports.useSlimAlarms = useSlimAlarms;
|
|
52
62
|
const useRecentAlarms = (count) => {
|
|
53
63
|
const client = (0, index_1.useClient)();
|
|
54
64
|
const load = React.useCallback(() => client.getRecentAlarms(count), [client, count]);
|
|
55
|
-
|
|
65
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
66
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
67
|
+
if (!change) {
|
|
68
|
+
state.reload();
|
|
69
|
+
}
|
|
70
|
+
else if (change.type === "slim") {
|
|
71
|
+
updateData((current) => current && ({
|
|
72
|
+
...current,
|
|
73
|
+
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
}), [client, state.reload, updateData]);
|
|
77
|
+
return state;
|
|
56
78
|
};
|
|
57
79
|
exports.useRecentAlarms = useRecentAlarms;
|
|
58
80
|
const useRecentOutOfBed = (count) => {
|
|
59
81
|
const client = (0, index_1.useClient)();
|
|
60
82
|
const load = React.useCallback(() => client.getRecentOutOfBed(count), [client, count]);
|
|
61
|
-
|
|
83
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
84
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
85
|
+
if (!change) {
|
|
86
|
+
state.reload();
|
|
87
|
+
}
|
|
88
|
+
else if (change.type === "slim") {
|
|
89
|
+
updateData((current) => current && ({
|
|
90
|
+
...current,
|
|
91
|
+
recent: current.recent.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}), [client, state.reload, updateData]);
|
|
95
|
+
return state;
|
|
62
96
|
};
|
|
63
97
|
exports.useRecentOutOfBed = useRecentOutOfBed;
|
|
64
98
|
const useSlimOutOfBedNotifications = (params = {}) => {
|
|
65
99
|
const client = (0, index_1.useClient)();
|
|
66
100
|
const serialized = JSON.stringify(params);
|
|
67
|
-
const state = (0, api_hooks_1.
|
|
68
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client,
|
|
101
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(React.useCallback(() => client.listSlimOutOfBedNotifications(params), [client, serialized]));
|
|
102
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
103
|
+
if (!change) {
|
|
104
|
+
state.reload();
|
|
105
|
+
}
|
|
106
|
+
else if (change.type === "slim") {
|
|
107
|
+
updateData((current) => current && ({
|
|
108
|
+
...current,
|
|
109
|
+
resources: current.resources.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
}), [client, state.reload, updateData]);
|
|
69
113
|
return state;
|
|
70
114
|
};
|
|
71
115
|
exports.useSlimOutOfBedNotifications = useSlimOutOfBedNotifications;
|
|
@@ -91,54 +135,18 @@ const useSlimMedicalNotifications = (params = {}) => {
|
|
|
91
135
|
} while (cursor !== undefined);
|
|
92
136
|
return { items, nextCursor: null };
|
|
93
137
|
}, [client, serialized]);
|
|
94
|
-
const state = (0, api_hooks_1.
|
|
95
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client,
|
|
138
|
+
const { updateData, ...state } = (0, api_hooks_1.useOvokRequestWithUpdater)(load);
|
|
139
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
140
|
+
if (!change) {
|
|
141
|
+
state.reload();
|
|
142
|
+
}
|
|
143
|
+
else if (change.type === "slim") {
|
|
144
|
+
updateData((current) => current && ({
|
|
145
|
+
...current,
|
|
146
|
+
items: current.items.map((item) => (0, notification_invalidation_1.mergeSlimNotification)(item, change.notification)),
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
}), [client, state.reload, updateData]);
|
|
96
150
|
return state;
|
|
97
151
|
};
|
|
98
152
|
exports.useSlimMedicalNotifications = useSlimMedicalNotifications;
|
|
99
|
-
const useNotificationNotes = (kind, id) => {
|
|
100
|
-
const client = (0, index_1.useClient)();
|
|
101
|
-
const [revision, setRevision] = React.useState(0);
|
|
102
|
-
const load = React.useCallback(() => (id ? client.listNotificationNotes(kind, id) : Promise.reject(new Error("id is required"))), [client, kind, id, revision]);
|
|
103
|
-
const state = (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
|
|
104
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, () => setRevision((value) => value + 1)), [client, kind, id]);
|
|
105
|
-
return state;
|
|
106
|
-
};
|
|
107
|
-
exports.useNotificationNotes = useNotificationNotes;
|
|
108
|
-
function useNoteMutation(request) {
|
|
109
|
-
return (0, api_hooks_1.useOvokMutation)(async (client, params) => {
|
|
110
|
-
const result = await request(client, params);
|
|
111
|
-
(0, notification_invalidation_1.notifyNotificationChanges)(client);
|
|
112
|
-
return result;
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
const useCreateNotificationNote = () => useNoteMutation((client, body) => client.createNotificationNote(body));
|
|
116
|
-
exports.useCreateNotificationNote = useCreateNotificationNote;
|
|
117
|
-
const useUpdateNotificationNote = () => useNoteMutation((client, params) => client.updateNotificationNote(params.noteId, params.body));
|
|
118
|
-
exports.useUpdateNotificationNote = useUpdateNotificationNote;
|
|
119
|
-
const useDeleteNotificationNote = () => useNoteMutation((client, noteId) => client.deleteNotificationNote(noteId));
|
|
120
|
-
exports.useDeleteNotificationNote = useDeleteNotificationNote;
|
|
121
|
-
const useSignalsAlertNotes = (episodeId) => {
|
|
122
|
-
const client = (0, index_1.useClient)();
|
|
123
|
-
const [revision, setRevision] = React.useState(0);
|
|
124
|
-
const load = React.useCallback(() => (episodeId ? client.listSignalsAlertNotes(episodeId) : Promise.reject(new Error("episodeId is required"))), [client, episodeId, revision]);
|
|
125
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, () => setRevision((value) => value + 1)), [client, episodeId]);
|
|
126
|
-
return (0, api_hooks_1.useOvokRequest)(load, episodeId !== undefined);
|
|
127
|
-
};
|
|
128
|
-
exports.useSignalsAlertNotes = useSignalsAlertNotes;
|
|
129
|
-
const useSignalsRawAlertNotes = (alertId) => {
|
|
130
|
-
const client = (0, index_1.useClient)();
|
|
131
|
-
const [revision, setRevision] = React.useState(0);
|
|
132
|
-
const load = React.useCallback(() => (alertId ? client.listSignalsRawAlertNotes(alertId) : Promise.reject(new Error("alertId is required"))), [client, alertId, revision]);
|
|
133
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, () => setRevision((value) => value + 1)), [client, alertId]);
|
|
134
|
-
return (0, api_hooks_1.useOvokRequest)(load, alertId !== undefined);
|
|
135
|
-
};
|
|
136
|
-
exports.useSignalsRawAlertNotes = useSignalsRawAlertNotes;
|
|
137
|
-
const useCreateSignalsAlertNote = () => useNoteMutation((client, params) => client.createSignalsAlertNote(params.episodeId, { text: params.text }));
|
|
138
|
-
exports.useCreateSignalsAlertNote = useCreateSignalsAlertNote;
|
|
139
|
-
const useCreateSignalsRawAlertNote = () => useNoteMutation((client, params) => client.createSignalsRawAlertNote(params.alertId, { text: params.text }));
|
|
140
|
-
exports.useCreateSignalsRawAlertNote = useCreateSignalsRawAlertNote;
|
|
141
|
-
const useUpdateSignalsNote = () => useNoteMutation((client, params) => client.updateSignalsNote(params.noteId, params.body));
|
|
142
|
-
exports.useUpdateSignalsNote = useUpdateSignalsNote;
|
|
143
|
-
const useDeleteSignalsNote = () => useNoteMutation((client, noteId) => client.deleteSignalsNote(noteId));
|
|
144
|
-
exports.useDeleteSignalsNote = useDeleteSignalsNote;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import { OvokClient } from "../client/ovok-client";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { SignalsAlert, SignalsRawAlert } from "../client/signals/types";
|
|
3
|
+
import { SlimNotification } from "../client/slim/types";
|
|
4
|
+
export type NotificationChange = {
|
|
5
|
+
type: "slim";
|
|
6
|
+
notification: SlimNotification;
|
|
7
|
+
} | {
|
|
8
|
+
type: "signals-alert";
|
|
9
|
+
alert: SignalsAlert;
|
|
10
|
+
} | {
|
|
11
|
+
type: "signals-raw-alert";
|
|
12
|
+
alert: SignalsRawAlert;
|
|
13
|
+
};
|
|
14
|
+
type NotificationChangeListener = (change?: NotificationChange) => void;
|
|
15
|
+
export declare function subscribeToNotificationChanges(client: OvokClient, listener: NotificationChangeListener): () => void;
|
|
16
|
+
export declare function notifyNotificationChanges(client: OvokClient, change?: NotificationChange): void;
|
|
17
|
+
export declare function mergeSlimNotification<T extends object>(item: T, notification: SlimNotification): T;
|
|
18
|
+
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subscribeToNotificationChanges = subscribeToNotificationChanges;
|
|
4
4
|
exports.notifyNotificationChanges = notifyNotificationChanges;
|
|
5
|
+
exports.mergeSlimNotification = mergeSlimNotification;
|
|
5
6
|
const listeners = new WeakMap();
|
|
6
7
|
function subscribeToNotificationChanges(client, listener) {
|
|
7
8
|
var _a;
|
|
@@ -15,9 +16,13 @@ function subscribeToNotificationChanges(client, listener) {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
function notifyNotificationChanges(client) {
|
|
19
|
+
function notifyNotificationChanges(client, change) {
|
|
19
20
|
var _a;
|
|
20
21
|
for (const listener of (_a = listeners.get(client)) !== null && _a !== void 0 ? _a : []) {
|
|
21
|
-
listener();
|
|
22
|
+
listener(change);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
25
|
+
function mergeSlimNotification(item, notification) {
|
|
26
|
+
const commId = item.commId;
|
|
27
|
+
return commId === notification.commId ? { ...item, ...notification } : item;
|
|
28
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CreateNotificationNote, NotificationNote, NotificationNotes, UpdateNotificationNote } from "../client/notifications";
|
|
2
|
+
import { NotificationTargetKind } from "../client/notifications/types";
|
|
3
|
+
import { OvokMutationState, OvokRequestState } from "./api-hooks";
|
|
4
|
+
export declare const useNotificationNotes: (kind: NotificationTargetKind, id?: string) => OvokRequestState<NotificationNotes>;
|
|
5
|
+
export declare const useCreateNotificationNote: () => OvokMutationState<CreateNotificationNote, NotificationNote>;
|
|
6
|
+
export declare const useUpdateNotificationNote: () => OvokMutationState<{
|
|
7
|
+
noteId: string;
|
|
8
|
+
body: UpdateNotificationNote;
|
|
9
|
+
}, NotificationNote>;
|
|
10
|
+
export declare const useDeleteNotificationNote: () => OvokMutationState<string, void>;
|
|
11
|
+
export declare const useSignalsAlertNotes: (episodeId?: string) => OvokRequestState<NotificationNotes>;
|
|
12
|
+
export declare const useSignalsRawAlertNotes: (alertId?: string) => OvokRequestState<NotificationNotes>;
|
|
13
|
+
export declare const useCreateSignalsAlertNote: () => OvokMutationState<{
|
|
14
|
+
episodeId: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}, NotificationNote>;
|
|
17
|
+
export declare const useCreateSignalsRawAlertNote: () => OvokMutationState<{
|
|
18
|
+
alertId: string;
|
|
19
|
+
text: string;
|
|
20
|
+
}, NotificationNote>;
|
|
21
|
+
export declare const useUpdateSignalsNote: () => OvokMutationState<{
|
|
22
|
+
noteId: string;
|
|
23
|
+
body: UpdateNotificationNote;
|
|
24
|
+
}, NotificationNote>;
|
|
25
|
+
export declare const useDeleteSignalsNote: () => OvokMutationState<string, void>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.useDeleteSignalsNote = exports.useUpdateSignalsNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useDeleteNotificationNote = exports.useUpdateNotificationNote = exports.useCreateNotificationNote = exports.useNotificationNotes = void 0;
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const api_hooks_1 = require("./api-hooks");
|
|
40
|
+
const notification_invalidation_1 = require("./notification-invalidation");
|
|
41
|
+
const index_1 = require("./index");
|
|
42
|
+
const useNotificationNotes = (kind, id) => {
|
|
43
|
+
const client = (0, index_1.useClient)();
|
|
44
|
+
const [revision, setRevision] = React.useState(0);
|
|
45
|
+
const load = React.useCallback(() => (id ? client.listNotificationNotes(kind, id) : Promise.reject(new Error("id is required"))), [client, kind, id, revision]);
|
|
46
|
+
const state = (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
|
|
47
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
48
|
+
if (!change) {
|
|
49
|
+
setRevision((value) => value + 1);
|
|
50
|
+
}
|
|
51
|
+
}), [client, kind, id]);
|
|
52
|
+
return state;
|
|
53
|
+
};
|
|
54
|
+
exports.useNotificationNotes = useNotificationNotes;
|
|
55
|
+
function useNoteMutation(request) {
|
|
56
|
+
return (0, api_hooks_1.useOvokMutation)(async (client, params) => {
|
|
57
|
+
const result = await request(client, params);
|
|
58
|
+
(0, notification_invalidation_1.notifyNotificationChanges)(client);
|
|
59
|
+
return result;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const useCreateNotificationNote = () => useNoteMutation((client, body) => client.createNotificationNote(body));
|
|
63
|
+
exports.useCreateNotificationNote = useCreateNotificationNote;
|
|
64
|
+
const useUpdateNotificationNote = () => useNoteMutation((client, params) => client.updateNotificationNote(params.noteId, params.body));
|
|
65
|
+
exports.useUpdateNotificationNote = useUpdateNotificationNote;
|
|
66
|
+
const useDeleteNotificationNote = () => useNoteMutation((client, noteId) => client.deleteNotificationNote(noteId));
|
|
67
|
+
exports.useDeleteNotificationNote = useDeleteNotificationNote;
|
|
68
|
+
const useSignalsAlertNotes = (episodeId) => {
|
|
69
|
+
const client = (0, index_1.useClient)();
|
|
70
|
+
const [revision, setRevision] = React.useState(0);
|
|
71
|
+
const load = React.useCallback(() => (episodeId ? client.listSignalsAlertNotes(episodeId) : Promise.reject(new Error("episodeId is required"))), [client, episodeId, revision]);
|
|
72
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
73
|
+
if (!change) {
|
|
74
|
+
setRevision((value) => value + 1);
|
|
75
|
+
}
|
|
76
|
+
}), [client, episodeId]);
|
|
77
|
+
return (0, api_hooks_1.useOvokRequest)(load, episodeId !== undefined);
|
|
78
|
+
};
|
|
79
|
+
exports.useSignalsAlertNotes = useSignalsAlertNotes;
|
|
80
|
+
const useSignalsRawAlertNotes = (alertId) => {
|
|
81
|
+
const client = (0, index_1.useClient)();
|
|
82
|
+
const [revision, setRevision] = React.useState(0);
|
|
83
|
+
const load = React.useCallback(() => (alertId ? client.listSignalsRawAlertNotes(alertId) : Promise.reject(new Error("alertId is required"))), [client, alertId, revision]);
|
|
84
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
85
|
+
if (!change) {
|
|
86
|
+
setRevision((value) => value + 1);
|
|
87
|
+
}
|
|
88
|
+
}), [client, alertId]);
|
|
89
|
+
return (0, api_hooks_1.useOvokRequest)(load, alertId !== undefined);
|
|
90
|
+
};
|
|
91
|
+
exports.useSignalsRawAlertNotes = useSignalsRawAlertNotes;
|
|
92
|
+
const useCreateSignalsAlertNote = () => useNoteMutation((client, params) => client.createSignalsAlertNote(params.episodeId, { text: params.text }));
|
|
93
|
+
exports.useCreateSignalsAlertNote = useCreateSignalsAlertNote;
|
|
94
|
+
const useCreateSignalsRawAlertNote = () => useNoteMutation((client, params) => client.createSignalsRawAlertNote(params.alertId, { text: params.text }));
|
|
95
|
+
exports.useCreateSignalsRawAlertNote = useCreateSignalsRawAlertNote;
|
|
96
|
+
const useUpdateSignalsNote = () => useNoteMutation((client, params) => client.updateSignalsNote(params.noteId, params.body));
|
|
97
|
+
exports.useUpdateSignalsNote = useUpdateSignalsNote;
|
|
98
|
+
const useDeleteSignalsNote = () => useNoteMutation((client, noteId) => client.deleteSignalsNote(noteId));
|
|
99
|
+
exports.useDeleteSignalsNote = useDeleteSignalsNote;
|
|
@@ -61,7 +61,17 @@ function useSignalsAlerts(query = {}) {
|
|
|
61
61
|
const [revision, setRevision] = React.useState(0);
|
|
62
62
|
const generation = React.useRef(0);
|
|
63
63
|
const loadingRef = React.useRef(false);
|
|
64
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, () =>
|
|
64
|
+
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
65
|
+
if (!change) {
|
|
66
|
+
setRevision((value) => value + 1);
|
|
67
|
+
}
|
|
68
|
+
else if (querySnapshot.episodes === false && change.type === "signals-raw-alert") {
|
|
69
|
+
setItems((current) => current.map((item) => item.id === change.alert.id ? { ...item, ...change.alert } : item));
|
|
70
|
+
}
|
|
71
|
+
else if (querySnapshot.episodes !== false && change.type === "signals-alert") {
|
|
72
|
+
setItems((current) => current.map((item) => item.id === change.alert.id ? { ...item, ...change.alert } : item));
|
|
73
|
+
}
|
|
74
|
+
}), [client, querySnapshot.episodes]);
|
|
65
75
|
React.useEffect(() => {
|
|
66
76
|
const requestGeneration = generation.current + 1;
|
|
67
77
|
generation.current = requestGeneration;
|
|
@@ -141,8 +151,14 @@ function useSignalsAlert(id, grain = {}) {
|
|
|
141
151
|
}
|
|
142
152
|
function useAcknowledgeSignalsAlert(grain = {}) {
|
|
143
153
|
const episodes = grain.episodes !== false;
|
|
144
|
-
return (0, api_hooks_1.useOvokMutation)((client, id) =>
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
return (0, api_hooks_1.useOvokMutation)(async (client, id) => {
|
|
155
|
+
const result = episodes
|
|
156
|
+
? await client.acknowledgeSignalsAlert(id)
|
|
157
|
+
: await client.acknowledgeSignalsRawAlert(id);
|
|
158
|
+
(0, notification_invalidation_1.notifyNotificationChanges)(client, episodes
|
|
159
|
+
? { type: "signals-alert", alert: result }
|
|
160
|
+
: { type: "signals-raw-alert", alert: result });
|
|
161
|
+
return result;
|
|
162
|
+
});
|
|
147
163
|
}
|
|
148
164
|
const toError = (error) => error instanceof Error ? error : new Error(String(error));
|