@ovok/core 0.4.49-rc.1 → 0.4.49-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -79
- package/dist/client/observation/measurement-fields.d.ts +1 -1
- package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
- package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
- package/dist/client/observation/services/base-observation-service.d.ts +1 -1
- package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
- package/dist/client/observation/services/blood-oxygen.js +7 -7
- package/dist/client/observation/services/blood-pressure.d.ts +1 -1
- package/dist/client/observation/services/blood-pressure.js +16 -16
- package/dist/client/observation/services/component-observation-services.d.ts +1 -1
- package/dist/client/observation/services/component-observation-services.js +3 -3
- package/dist/client/observation/services/creator.d.ts +1 -1
- package/dist/client/observation/services/creator.js +10 -10
- package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
- package/dist/client/observation/services/ecg.d.ts +1 -1
- package/dist/client/observation/services/ecg.js +10 -10
- package/dist/client/observation/services/lipid-panel.d.ts +1 -1
- package/dist/client/observation/services/lipid-panel.js +13 -13
- package/dist/client/observation/services/single-value-services.d.ts +1 -1
- package/dist/client/observation/services/single-value-services.js +19 -19
- package/dist/client/observation/services/step-count.d.ts +1 -1
- package/dist/client/observation/services/step-count.js +5 -5
- package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
- package/dist/client/observation/services/uric-acid-service.js +7 -7
- package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
- package/dist/client/signals/methods.d.ts +2 -23
- package/dist/client/signals/methods.js +10 -93
- package/dist/client/signals/types.d.ts +6 -132
- package/dist/client/wearables/types.d.ts +5 -0
- package/dist/conformance/api-requirements.js +2 -9
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +1 -9
- package/dist/hooks/notification-invalidation.d.ts +0 -7
- package/dist/hooks/signals-hooks.d.ts +2 -23
- package/dist/hooks/signals-hooks.js +1 -15
- package/dist/next/auth/access-token.d.ts +9 -0
- package/dist/next/auth/access-token.js +18 -0
- package/dist/next/auth/client-credentials.d.ts +16 -0
- package/dist/next/auth/client-credentials.js +40 -0
- package/dist/next/auth/credentials.d.ts +5 -0
- package/dist/next/auth/credentials.js +7 -0
- package/dist/next/auth/saved-accounts-store.d.ts +26 -0
- package/dist/next/auth/saved-accounts-store.js +93 -0
- package/dist/next/auth/session-store.d.ts +12 -0
- package/dist/next/auth/session-store.js +33 -0
- package/dist/next/auth/session.d.ts +28 -0
- package/dist/next/auth/session.js +27 -0
- package/dist/next/auth/token-endpoint.d.ts +12 -0
- package/dist/next/auth/token-endpoint.js +28 -0
- package/dist/next/auth/user-session.d.ts +39 -0
- package/dist/next/auth/user-session.js +183 -0
- package/dist/next/config/ovok-config.d.ts +42 -0
- package/dist/next/config/ovok-config.js +2 -0
- package/dist/next/config/settings.d.ts +6 -0
- package/dist/next/config/settings.js +74 -0
- package/dist/next/errors/error-from-response.d.ts +2 -0
- package/dist/next/errors/error-from-response.js +35 -0
- package/dist/next/errors/ovok-account-error.d.ts +5 -0
- package/dist/next/errors/ovok-account-error.js +13 -0
- package/dist/next/errors/ovok-errors.d.ts +42 -0
- package/dist/next/errors/ovok-errors.js +74 -0
- package/dist/next/http/http-client.d.ts +36 -0
- package/dist/next/http/http-client.js +116 -0
- package/dist/next/http/retry-after.d.ts +1 -0
- package/dist/next/http/retry-after.js +16 -0
- package/dist/next/http/retry-policy.d.ts +13 -0
- package/dist/next/http/retry-policy.js +27 -0
- package/dist/next/http/transmit.d.ts +14 -0
- package/dist/next/http/transmit.js +57 -0
- package/dist/next/http/url.d.ts +6 -0
- package/dist/next/http/url.js +22 -0
- package/dist/next/index.d.ts +77 -0
- package/dist/next/index.js +35 -0
- package/dist/next/ovok.d.ts +56 -0
- package/dist/next/ovok.js +86 -0
- package/dist/next/paging/bundle-page.d.ts +4 -0
- package/dist/next/paging/bundle-page.js +25 -0
- package/dist/next/paging/cursor-pages.d.ts +7 -0
- package/dist/next/paging/cursor-pages.js +14 -0
- package/dist/next/paging/numbered-pages.d.ts +15 -0
- package/dist/next/paging/numbered-pages.js +20 -0
- package/dist/next/paging/page.d.ts +12 -0
- package/dist/next/paging/page.js +17 -0
- package/dist/next/react/context.d.ts +4 -0
- package/dist/{hooks/signals-alert-item-hooks.js → next/react/context.js} +10 -26
- package/dist/next/react/index.d.ts +14 -0
- package/dist/next/react/index.js +68 -0
- package/dist/next/react/query-hooks.d.ts +31 -0
- package/dist/next/react/query-hooks.js +160 -0
- package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
- package/dist/next/resources/accounts/accounts-resource.js +13 -0
- package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
- package/dist/next/resources/ai/ai-chat-resource.js +12 -0
- package/dist/next/resources/ai/ai-resource.d.ts +16 -0
- package/dist/next/resources/ai/ai-resource.js +19 -0
- package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
- package/dist/next/resources/ai/chat-messages-resource.js +18 -0
- package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
- package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
- package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
- package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
- package/dist/next/resources/auth/registration.d.ts +35 -0
- package/dist/next/resources/auth/registration.js +24 -0
- package/dist/next/resources/auth/social-login.d.ts +8 -0
- package/dist/next/resources/auth/social-login.js +7 -0
- package/dist/next/resources/auth-resource.d.ts +63 -0
- package/dist/next/resources/auth-resource.js +119 -0
- package/dist/next/resources/bots/bots-resource.d.ts +10 -0
- package/dist/next/resources/bots/bots-resource.js +15 -0
- package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
- package/dist/next/resources/cms/cms-delivery.js +36 -0
- package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
- package/dist/next/resources/cms/cms-documents-resource.js +17 -0
- package/dist/next/resources/cms/cms-resource.d.ts +17 -0
- package/dist/next/resources/cms/cms-resource.js +38 -0
- package/dist/next/resources/cms/payload-pages.d.ts +6 -0
- package/dist/next/resources/cms/payload-pages.js +15 -0
- package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
- package/dist/next/resources/cms/release-notes-resource.js +15 -0
- package/dist/next/resources/cms/translation-tree.d.ts +3 -0
- package/dist/next/resources/cms/translation-tree.js +45 -0
- package/dist/next/resources/consent/consent-resource.d.ts +23 -0
- package/dist/next/resources/consent/consent-resource.js +43 -0
- package/dist/next/resources/content/content-resource.d.ts +19 -0
- package/dist/next/resources/content/content-resource.js +41 -0
- package/dist/next/resources/documents/documents-resource.d.ts +26 -0
- package/dist/next/resources/documents/documents-resource.js +41 -0
- package/dist/next/resources/email/email-resource.d.ts +6 -0
- package/dist/next/resources/email/email-resource.js +10 -0
- package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
- package/dist/next/resources/email/email-templates-resource.js +13 -0
- package/dist/next/resources/fhir-resource.d.ts +28 -0
- package/dist/next/resources/fhir-resource.js +64 -0
- package/dist/next/resources/health-resource.d.ts +17 -0
- package/dist/next/resources/health-resource.js +14 -0
- package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
- package/dist/next/resources/invites/invite-flow-resource.js +19 -0
- package/dist/next/resources/invites/invites-resource.d.ts +22 -0
- package/dist/next/resources/invites/invites-resource.js +29 -0
- package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
- package/dist/next/resources/localization/i18next-resource.js +18 -0
- package/dist/next/resources/localization/locales-resource.d.ts +9 -0
- package/dist/next/resources/localization/locales-resource.js +16 -0
- package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
- package/dist/next/resources/localization/localizations-resource.js +27 -0
- package/dist/next/resources/measurements/measurements-resource.d.ts +68 -0
- package/dist/next/resources/measurements/measurements-resource.js +116 -0
- package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
- package/dist/next/resources/measurements/observation-builder.js +57 -0
- package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +22 -0
- package/dist/next/resources/measurements/offline-measurement-queue-types.js +2 -0
- package/dist/next/resources/measurements/offline-measurement-queue.d.ts +25 -0
- package/dist/next/resources/measurements/offline-measurement-queue.js +154 -0
- package/dist/next/resources/measurements/save-error.d.ts +5 -0
- package/dist/next/resources/measurements/save-error.js +18 -0
- package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
- package/dist/next/resources/measurements/signed-in-account.js +26 -0
- package/dist/next/resources/patient/fhir-records.d.ts +19 -0
- package/dist/next/resources/patient/fhir-records.js +33 -0
- package/dist/next/resources/patient/patient-resource.d.ts +21 -0
- package/dist/next/resources/patient/patient-resource.js +38 -0
- package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
- package/dist/next/resources/projects/project-features-resource.js +17 -0
- package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
- package/dist/next/resources/projects/project-members-resource.js +25 -0
- package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
- package/dist/next/resources/projects/project-settings-resource.js +21 -0
- package/dist/next/resources/projects/projects-resource.d.ts +20 -0
- package/dist/next/resources/projects/projects-resource.js +21 -0
- package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
- package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
- package/dist/next/resources/realtime/realtime-binding.d.ts +7 -0
- package/dist/next/resources/realtime/realtime-binding.js +44 -0
- package/dist/next/resources/realtime/realtime-connection.d.ts +38 -0
- package/dist/next/resources/realtime/realtime-connection.js +167 -0
- package/dist/next/resources/realtime/realtime-resource.d.ts +13 -0
- package/dist/next/resources/realtime/realtime-resource.js +39 -0
- package/dist/next/resources/realtime/realtime-socket.d.ts +23 -0
- package/dist/next/resources/realtime/realtime-socket.js +152 -0
- package/dist/next/resources/realtime/realtime-types.d.ts +6 -0
- package/dist/next/resources/realtime/realtime-types.js +2 -0
- package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
- package/dist/next/resources/session/saved-accounts-resource.js +44 -0
- package/dist/next/resources/session/session-resource.d.ts +12 -0
- package/dist/next/resources/session/session-resource.js +19 -0
- package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
- package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
- package/dist/next/resources/sharing/sharing-resource.js +14 -0
- package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
- package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
- package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
- package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
- package/dist/next/resources/signals/signals-resource.d.ts +13 -0
- package/dist/next/resources/signals/signals-resource.js +19 -0
- package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
- package/dist/next/resources/signals/undeliverable-resource.js +18 -0
- package/dist/next/resources/slim/live-reads.d.ts +13 -0
- package/dist/next/resources/slim/live-reads.js +87 -0
- package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
- package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
- package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
- package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
- package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
- package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
- package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
- package/dist/next/resources/slim/slim-devices-resource.js +81 -0
- package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
- package/dist/next/resources/slim/slim-exports-resource.js +14 -0
- package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
- package/dist/next/resources/slim/slim-locations-resource.js +30 -0
- package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
- package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
- package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
- package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
- package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
- package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
- package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
- package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
- package/dist/next/resources/slim/slim-paths.d.ts +6 -0
- package/dist/next/resources/slim/slim-paths.js +9 -0
- package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
- package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
- package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
- package/dist/next/resources/slim/slim-patients-resource.js +39 -0
- package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-policies-resource.js +29 -0
- package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
- package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
- package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
- package/dist/next/resources/slim/slim-projects-resource.js +35 -0
- package/dist/next/resources/slim/slim-queries.d.ts +34 -0
- package/dist/next/resources/slim/slim-queries.js +2 -0
- package/dist/next/resources/slim/slim-resource.d.ts +39 -0
- package/dist/next/resources/slim/slim-resource.js +44 -0
- package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
- package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
- package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
- package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-trends-resource.js +19 -0
- package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-users-resource.js +15 -0
- package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-zones-resource.js +24 -0
- package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
- package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
- package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
- package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
- package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
- package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
- package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
- package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
- package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
- package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
- package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
- package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
- package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
- package/dist/next/resources/wearables/wearables-resource.js +14 -0
- package/dist/next/storage/ovok-storage.d.ts +11 -0
- package/dist/next/storage/ovok-storage.js +19 -0
- package/dist/types/MeasurementTypes.d.ts +5 -0
- package/dist/types/MeasurementTypes.js +21 -0
- package/dist/types/index.d.ts +1 -5
- package/dist/types/index.js +1 -5
- package/next/index.d.ts +1 -0
- package/next/index.js +3 -0
- package/next/react/index.d.ts +1 -0
- package/next/react/index.js +1 -0
- package/package.json +14 -2
- package/dist/hooks/signals-alert-hooks.d.ts +0 -22
- package/dist/hooks/signals-alert-hooks.js +0 -166
- package/dist/hooks/signals-alert-item-hooks.d.ts +0 -19
|
@@ -1,166 +0,0 @@
|
|
|
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.useSignalsAlert = exports.useAcknowledgeSignalsAlert = void 0;
|
|
38
|
-
exports.useSignalsAlerts = useSignalsAlerts;
|
|
39
|
-
const React = __importStar(require("react"));
|
|
40
|
-
const ovok_error_utils_1 = require("../client/errors/ovok-error-utils");
|
|
41
|
-
const notification_invalidation_1 = require("./notification-invalidation");
|
|
42
|
-
const index_1 = require("./index");
|
|
43
|
-
var signals_alert_item_hooks_1 = require("./signals-alert-item-hooks");
|
|
44
|
-
Object.defineProperty(exports, "useAcknowledgeSignalsAlert", { enumerable: true, get: function () { return signals_alert_item_hooks_1.useAcknowledgeSignalsAlert; } });
|
|
45
|
-
Object.defineProperty(exports, "useSignalsAlert", { enumerable: true, get: function () { return signals_alert_item_hooks_1.useSignalsAlert; } });
|
|
46
|
-
function useSignalsAlerts(query = {}) {
|
|
47
|
-
const client = (0, index_1.useClient)();
|
|
48
|
-
const queryKey = JSON.stringify(query);
|
|
49
|
-
const querySnapshot = React.useMemo(() => JSON.parse(queryKey), [queryKey]);
|
|
50
|
-
const listPage = React.useCallback((cursor, signal) => {
|
|
51
|
-
const at = cursor === undefined ? {} : { cursor };
|
|
52
|
-
if (querySnapshot.episodes === false) {
|
|
53
|
-
const { episodes: _grain, ...filters } = querySnapshot;
|
|
54
|
-
return client.listSignalsRawAlerts({ ...filters, ...at }, { signal });
|
|
55
|
-
}
|
|
56
|
-
const { episodes: _grain, ...filters } = querySnapshot;
|
|
57
|
-
return client.listSignalsAlerts({ ...filters, ...at }, { signal });
|
|
58
|
-
}, [client, querySnapshot]);
|
|
59
|
-
const [items, setItems] = React.useState([]);
|
|
60
|
-
const [nextCursor, setNextCursor] = React.useState(null);
|
|
61
|
-
const [loading, setLoading] = React.useState(true);
|
|
62
|
-
const [error, setError] = React.useState();
|
|
63
|
-
const [dataUpdatedAt, setDataUpdatedAt] = React.useState();
|
|
64
|
-
const [revision, setRevision] = React.useState(0);
|
|
65
|
-
const generation = React.useRef(0);
|
|
66
|
-
const loadMoreController = React.useRef();
|
|
67
|
-
const loadingRef = React.useRef(false);
|
|
68
|
-
const previousQueryKey = React.useRef(queryKey);
|
|
69
|
-
React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
|
|
70
|
-
if (!change) {
|
|
71
|
-
setRevision((value) => value + 1);
|
|
72
|
-
}
|
|
73
|
-
else if (change.type === (querySnapshot.episodes === false ? "signals-raw-alert" : "signals-alert")) {
|
|
74
|
-
setItems((current) => current.map((item) => item.id === change.alert.id ? { ...item, ...change.alert } : item));
|
|
75
|
-
}
|
|
76
|
-
}), [client, querySnapshot.episodes]);
|
|
77
|
-
React.useEffect(() => {
|
|
78
|
-
const requestGeneration = generation.current + 1;
|
|
79
|
-
const controller = new AbortController();
|
|
80
|
-
const queryChanged = previousQueryKey.current !== queryKey;
|
|
81
|
-
generation.current = requestGeneration;
|
|
82
|
-
previousQueryKey.current = queryKey;
|
|
83
|
-
loadingRef.current = true;
|
|
84
|
-
if (queryChanged) {
|
|
85
|
-
setItems([]);
|
|
86
|
-
setNextCursor(null);
|
|
87
|
-
setDataUpdatedAt(undefined);
|
|
88
|
-
}
|
|
89
|
-
setError(undefined);
|
|
90
|
-
setLoading(true);
|
|
91
|
-
listPage(undefined, controller.signal)
|
|
92
|
-
.then((page) => {
|
|
93
|
-
if (generation.current === requestGeneration) {
|
|
94
|
-
setItems(page.items);
|
|
95
|
-
setNextCursor(page.nextCursor);
|
|
96
|
-
setDataUpdatedAt(Date.now());
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
.catch((reason) => {
|
|
100
|
-
if (generation.current === requestGeneration) {
|
|
101
|
-
setError((0, ovok_error_utils_1.toError)(reason));
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
.finally(() => {
|
|
105
|
-
if (generation.current === requestGeneration) {
|
|
106
|
-
loadingRef.current = false;
|
|
107
|
-
setLoading(false);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return () => {
|
|
111
|
-
var _a;
|
|
112
|
-
controller.abort();
|
|
113
|
-
(_a = loadMoreController.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
114
|
-
generation.current += 1;
|
|
115
|
-
};
|
|
116
|
-
}, [listPage, queryKey, revision]);
|
|
117
|
-
const loadMore = React.useCallback(async () => {
|
|
118
|
-
var _a;
|
|
119
|
-
if (nextCursor === null || loadingRef.current) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const requestGeneration = generation.current;
|
|
123
|
-
const controller = new AbortController();
|
|
124
|
-
(_a = loadMoreController.current) === null || _a === void 0 ? void 0 : _a.abort();
|
|
125
|
-
loadMoreController.current = controller;
|
|
126
|
-
loadingRef.current = true;
|
|
127
|
-
setLoading(true);
|
|
128
|
-
setError(undefined);
|
|
129
|
-
try {
|
|
130
|
-
const page = await listPage(nextCursor, controller.signal);
|
|
131
|
-
if (generation.current === requestGeneration) {
|
|
132
|
-
setItems((current) => [...current, ...page.items]);
|
|
133
|
-
setNextCursor(page.nextCursor);
|
|
134
|
-
setDataUpdatedAt(Date.now());
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
catch (reason) {
|
|
138
|
-
if (generation.current === requestGeneration) {
|
|
139
|
-
setError((0, ovok_error_utils_1.toError)(reason));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
if (generation.current === requestGeneration) {
|
|
144
|
-
loadingRef.current = false;
|
|
145
|
-
setLoading(false);
|
|
146
|
-
}
|
|
147
|
-
if (loadMoreController.current === controller) {
|
|
148
|
-
loadMoreController.current = undefined;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}, [listPage, nextCursor]);
|
|
152
|
-
const reload = React.useCallback(() => {
|
|
153
|
-
setRevision((current) => current + 1);
|
|
154
|
-
}, []);
|
|
155
|
-
return {
|
|
156
|
-
items,
|
|
157
|
-
dataUpdatedAt,
|
|
158
|
-
loading,
|
|
159
|
-
isRefreshing: items.length > 0 && loading,
|
|
160
|
-
isStale: items.length > 0 && (loading || error !== undefined),
|
|
161
|
-
error,
|
|
162
|
-
reload,
|
|
163
|
-
hasMore: nextCursor !== null,
|
|
164
|
-
loadMore,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SignalsAlert, SignalsRawAlert } from "../client/signals";
|
|
2
|
-
import { OvokMutationState, OvokRequestState } from "./api-hooks";
|
|
3
|
-
export type SignalsAlertGrain = {
|
|
4
|
-
episodes?: boolean;
|
|
5
|
-
};
|
|
6
|
-
/** One episode by id, or one raw alert with `{ episodes: false }`. */
|
|
7
|
-
export declare function useSignalsAlert(id: string | undefined, grain: {
|
|
8
|
-
episodes: false;
|
|
9
|
-
}): OvokRequestState<SignalsRawAlert>;
|
|
10
|
-
export declare function useSignalsAlert(id?: string, grain?: {
|
|
11
|
-
episodes?: true;
|
|
12
|
-
}): OvokRequestState<SignalsAlert>;
|
|
13
|
-
/** Acknowledges an episode, or a raw alert with `{ episodes: false }`. */
|
|
14
|
-
export declare function useAcknowledgeSignalsAlert(grain: {
|
|
15
|
-
episodes: false;
|
|
16
|
-
}): OvokMutationState<string, SignalsRawAlert>;
|
|
17
|
-
export declare function useAcknowledgeSignalsAlert(grain?: {
|
|
18
|
-
episodes?: true;
|
|
19
|
-
}): OvokMutationState<string, SignalsAlert>;
|