@ovok/core 0.4.31 → 0.4.32

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.
Files changed (123) hide show
  1. package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +2 -1
  2. package/dist/client/ai-fhir/methods/AIFhirResources.js +2 -2
  3. package/dist/client/auth/methods/appleLogin.d.ts +2 -1
  4. package/dist/client/auth/methods/appleLogin.js +2 -2
  5. package/dist/client/auth/methods/changePassword.d.ts +2 -1
  6. package/dist/client/auth/methods/changePassword.js +2 -2
  7. package/dist/client/auth/methods/getSessions.d.ts +2 -1
  8. package/dist/client/auth/methods/getSessions.js +2 -2
  9. package/dist/client/auth/methods/googleLogin.d.ts +2 -1
  10. package/dist/client/auth/methods/googleLogin.js +2 -2
  11. package/dist/client/auth/methods/index.d.ts +1 -0
  12. package/dist/client/auth/methods/index.js +1 -0
  13. package/dist/client/auth/methods/login.d.ts +6 -2
  14. package/dist/client/auth/methods/login.js +60 -44
  15. package/dist/client/auth/methods/logout.d.ts +2 -1
  16. package/dist/client/auth/methods/logout.js +2 -2
  17. package/dist/client/auth/methods/refetchProfile.d.ts +2 -1
  18. package/dist/client/auth/methods/refetchProfile.js +3 -4
  19. package/dist/client/auth/methods/register.d.ts +2 -1
  20. package/dist/client/auth/methods/register.js +2 -2
  21. package/dist/client/auth/methods/registerPractitioner.d.ts +2 -1
  22. package/dist/client/auth/methods/registerPractitioner.js +2 -2
  23. package/dist/client/auth/methods/reloadSession.d.ts +7 -0
  24. package/dist/client/auth/methods/reloadSession.js +23 -0
  25. package/dist/client/auth/methods/requestDeleteUser.d.ts +2 -1
  26. package/dist/client/auth/methods/requestDeleteUser.js +5 -5
  27. package/dist/client/auth/methods/resetPassword.d.ts +2 -1
  28. package/dist/client/auth/methods/resetPassword.js +2 -2
  29. package/dist/client/auth/methods/revokeSessions.d.ts +2 -1
  30. package/dist/client/auth/methods/revokeSessions.js +2 -2
  31. package/dist/client/auth/methods/setPasswordFromReset.d.ts +2 -1
  32. package/dist/client/auth/methods/setPasswordFromReset.js +2 -2
  33. package/dist/client/auth/types/LoginBody.d.ts +10 -20
  34. package/dist/client/auth/types/LoginError.d.ts +15 -0
  35. package/dist/client/auth/types/LoginError.js +15 -0
  36. package/dist/client/bot/methods/executeBot.d.ts +2 -1
  37. package/dist/client/bot/methods/executeBot.js +2 -2
  38. package/dist/client/change-history/methods.d.ts +2 -1
  39. package/dist/client/change-history/methods.js +2 -2
  40. package/dist/client/chat/ai/methods/createAiSession.d.ts +2 -1
  41. package/dist/client/chat/ai/methods/createAiSession.js +2 -2
  42. package/dist/client/cms/methods.d.ts +6 -5
  43. package/dist/client/cms/methods.js +10 -10
  44. package/dist/client/consent/methods.d.ts +5 -4
  45. package/dist/client/consent/methods.js +8 -8
  46. package/dist/client/email/methods.d.ts +2 -1
  47. package/dist/client/email/methods.js +2 -2
  48. package/dist/client/errors/ovok-error-utils.d.ts +7 -0
  49. package/dist/client/errors/ovok-error-utils.js +49 -5
  50. package/dist/client/errors/ovok-error.d.ts +4 -0
  51. package/dist/client/errors/ovok-error.js +17 -4
  52. package/dist/client/errors/rate-limit-error.js +5 -3
  53. package/dist/client/experience/methods.d.ts +32 -31
  54. package/dist/client/experience/methods.js +62 -62
  55. package/dist/client/invites/methods.d.ts +6 -5
  56. package/dist/client/invites/methods.js +11 -11
  57. package/dist/client/notifications/methods.d.ts +6 -5
  58. package/dist/client/notifications/methods.js +10 -10
  59. package/dist/client/notifications/types.d.ts +92 -11
  60. package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +2 -1
  61. package/dist/client/observation/methods/getLatestObservationsByCodes.js +4 -4
  62. package/dist/client/offline/offline-measurement-queue.d.ts +4 -3
  63. package/dist/client/offline/offline-measurement-queue.js +6 -6
  64. package/dist/client/ovok-client.d.ts +9 -7
  65. package/dist/client/ovok-client.js +148 -22
  66. package/dist/client/patient/methods.d.ts +24 -23
  67. package/dist/client/patient/methods.js +49 -49
  68. package/dist/client/patient-sharing/methods.d.ts +7 -6
  69. package/dist/client/patient-sharing/methods.js +12 -12
  70. package/dist/client/platform/methods.d.ts +24 -23
  71. package/dist/client/platform/methods.js +46 -46
  72. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +2 -1
  73. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -2
  74. package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.d.ts +2 -1
  75. package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.js +2 -2
  76. package/dist/client/questionnaire-response/methods/populateQuestionnaire.d.ts +2 -1
  77. package/dist/client/questionnaire-response/methods/populateQuestionnaire.js +2 -2
  78. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.d.ts +2 -1
  79. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -2
  80. package/dist/client/signals/methods.d.ts +22 -21
  81. package/dist/client/signals/methods.js +42 -42
  82. package/dist/client/slim/methods.d.ts +93 -57
  83. package/dist/client/slim/methods.js +295 -108
  84. package/dist/client/slim/paging.d.ts +18 -0
  85. package/dist/client/slim/paging.js +57 -0
  86. package/dist/client/slim/types.d.ts +370 -3
  87. package/dist/conformance/api-requirements.js +22 -0
  88. package/dist/conformance/capability-requirements.js +1 -1
  89. package/dist/hooks/account-hooks.js +7 -7
  90. package/dist/hooks/api-hooks.d.ts +5 -2
  91. package/dist/hooks/api-hooks.js +39 -16
  92. package/dist/hooks/cms-hooks.js +3 -3
  93. package/dist/hooks/email-hooks.js +1 -1
  94. package/dist/hooks/experience-hooks.js +5 -5
  95. package/dist/hooks/index.d.ts +2 -0
  96. package/dist/hooks/index.js +5 -3
  97. package/dist/hooks/notification-ack-hooks.d.ts +2 -1
  98. package/dist/hooks/notification-hooks.d.ts +4 -2
  99. package/dist/hooks/notification-hooks.js +11 -23
  100. package/dist/hooks/notification-invalidation.d.ts +3 -2
  101. package/dist/hooks/notification-invalidation.js +10 -1
  102. package/dist/hooks/notification-note-hooks.js +3 -3
  103. package/dist/hooks/observation-hooks.d.ts +5 -1
  104. package/dist/hooks/observation-hooks.js +6 -6
  105. package/dist/hooks/patient-hooks.js +18 -18
  106. package/dist/hooks/patient-sharing-hooks.js +2 -2
  107. package/dist/hooks/platform-hooks.js +3 -3
  108. package/dist/hooks/poll-hooks.d.ts +14 -0
  109. package/dist/hooks/poll-hooks.js +127 -0
  110. package/dist/hooks/signals-alert-hooks.d.ts +5 -20
  111. package/dist/hooks/signals-alert-hooks.js +38 -34
  112. package/dist/hooks/signals-alert-item-hooks.d.ts +19 -0
  113. package/dist/hooks/signals-alert-item-hooks.js +62 -0
  114. package/dist/hooks/signals-hooks.js +2 -2
  115. package/dist/index.d.ts +3 -0
  116. package/dist/index.js +4 -1
  117. package/dist/utils/auth/exchange-code.d.ts +2 -0
  118. package/dist/utils/auth/exchange-code.js +2 -2
  119. package/dist/utils/auth/handle-tenant-code.d.ts +1 -1
  120. package/dist/utils/auth/handle-tenant-code.js +13 -4
  121. package/dist/utils/auth/start-login.d.ts +3 -1
  122. package/dist/utils/auth/start-login.js +3 -3
  123. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
1
  import { SignalsAlert, SignalsAlertsQuery, SignalsRawAlert, SignalsRawAlertsQuery } from "../client/signals";
2
- import { OvokMutationState, OvokRequestState } from "./api-hooks";
2
+ export { useAcknowledgeSignalsAlert, useSignalsAlert } from "./signals-alert-item-hooks";
3
+ export type { SignalsAlertGrain } from "./signals-alert-item-hooks";
3
4
  type SignalsAlertsHookQuery = Omit<SignalsAlertsQuery, "cursor"> & {
4
5
  episodes?: true;
5
6
  };
6
7
  type SignalsRawAlertsHookQuery = Omit<SignalsRawAlertsQuery, "cursor"> & {
7
8
  episodes: false;
8
9
  };
9
- /** Which grain an alert hook reads: episodes unless `episodes` is `false`. */
10
- export type SignalsAlertGrain = {
11
- episodes?: boolean;
12
- };
13
10
  export type SignalsAlertsHookState<TAlert = SignalsAlert> = {
14
11
  items: TAlert[];
12
+ dataUpdatedAt: number | undefined;
15
13
  loading: boolean;
14
+ isRefreshing: boolean;
15
+ isStale: boolean;
16
16
  error: Error | undefined;
17
17
  reload: () => void;
18
18
  hasMore: boolean;
@@ -20,18 +20,3 @@ export type SignalsAlertsHookState<TAlert = SignalsAlert> = {
20
20
  };
21
21
  export declare function useSignalsAlerts(query: SignalsRawAlertsHookQuery): SignalsAlertsHookState<SignalsRawAlert>;
22
22
  export declare function useSignalsAlerts(query?: SignalsAlertsHookQuery): SignalsAlertsHookState<SignalsAlert>;
23
- /** One episode by id, or one raw alert with `{ episodes: false }`. */
24
- export declare function useSignalsAlert(id: string | undefined, grain: {
25
- episodes: false;
26
- }): OvokRequestState<SignalsRawAlert>;
27
- export declare function useSignalsAlert(id?: string, grain?: {
28
- episodes?: true;
29
- }): OvokRequestState<SignalsAlert>;
30
- /** Acknowledges an episode, or a raw alert with `{ episodes: false }`. */
31
- export declare function useAcknowledgeSignalsAlert(grain: {
32
- episodes: false;
33
- }): OvokMutationState<string, SignalsRawAlert>;
34
- export declare function useAcknowledgeSignalsAlert(grain?: {
35
- episodes?: true;
36
- }): OvokMutationState<string, SignalsAlert>;
37
- export {};
@@ -34,33 +34,37 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.useSignalsAlert = exports.useAcknowledgeSignalsAlert = void 0;
37
38
  exports.useSignalsAlerts = useSignalsAlerts;
38
- exports.useSignalsAlert = useSignalsAlert;
39
- exports.useAcknowledgeSignalsAlert = useAcknowledgeSignalsAlert;
40
39
  const React = __importStar(require("react"));
41
- const api_hooks_1 = require("./api-hooks");
42
40
  const notification_invalidation_1 = require("./notification-invalidation");
43
41
  const index_1 = require("./index");
42
+ var signals_alert_item_hooks_1 = require("./signals-alert-item-hooks");
43
+ Object.defineProperty(exports, "useAcknowledgeSignalsAlert", { enumerable: true, get: function () { return signals_alert_item_hooks_1.useAcknowledgeSignalsAlert; } });
44
+ Object.defineProperty(exports, "useSignalsAlert", { enumerable: true, get: function () { return signals_alert_item_hooks_1.useSignalsAlert; } });
44
45
  function useSignalsAlerts(query = {}) {
45
46
  const client = (0, index_1.useClient)();
46
47
  const queryKey = JSON.stringify(query);
47
48
  const querySnapshot = React.useMemo(() => JSON.parse(queryKey), [queryKey]);
48
- const listPage = React.useCallback((cursor) => {
49
+ const listPage = React.useCallback((cursor, signal) => {
49
50
  const at = cursor === undefined ? {} : { cursor };
50
51
  if (querySnapshot.episodes === false) {
51
52
  const { episodes: _grain, ...filters } = querySnapshot;
52
- return client.listSignalsRawAlerts({ ...filters, ...at });
53
+ return client.listSignalsRawAlerts({ ...filters, ...at }, { signal });
53
54
  }
54
55
  const { episodes: _grain, ...filters } = querySnapshot;
55
- return client.listSignalsAlerts({ ...filters, ...at });
56
+ return client.listSignalsAlerts({ ...filters, ...at }, { signal });
56
57
  }, [client, querySnapshot]);
57
58
  const [items, setItems] = React.useState([]);
58
59
  const [nextCursor, setNextCursor] = React.useState(null);
59
60
  const [loading, setLoading] = React.useState(true);
60
61
  const [error, setError] = React.useState();
62
+ const [dataUpdatedAt, setDataUpdatedAt] = React.useState();
61
63
  const [revision, setRevision] = React.useState(0);
62
64
  const generation = React.useRef(0);
65
+ const loadMoreController = React.useRef();
63
66
  const loadingRef = React.useRef(false);
67
+ const previousQueryKey = React.useRef(queryKey);
64
68
  React.useEffect(() => (0, notification_invalidation_1.subscribeToNotificationChanges)(client, (change) => {
65
69
  if (!change) {
66
70
  setRevision((value) => value + 1);
@@ -74,22 +78,29 @@ function useSignalsAlerts(query = {}) {
74
78
  }), [client, querySnapshot.episodes]);
75
79
  React.useEffect(() => {
76
80
  const requestGeneration = generation.current + 1;
81
+ const controller = new AbortController();
82
+ const queryChanged = previousQueryKey.current !== queryKey;
77
83
  generation.current = requestGeneration;
84
+ previousQueryKey.current = queryKey;
78
85
  loadingRef.current = true;
79
- setItems([]);
80
- setNextCursor(null);
86
+ if (queryChanged) {
87
+ setItems([]);
88
+ setNextCursor(null);
89
+ setDataUpdatedAt(undefined);
90
+ }
81
91
  setError(undefined);
82
92
  setLoading(true);
83
- listPage()
93
+ listPage(undefined, controller.signal)
84
94
  .then((page) => {
85
95
  if (generation.current === requestGeneration) {
86
96
  setItems(page.items);
87
97
  setNextCursor(page.nextCursor);
98
+ setDataUpdatedAt(Date.now());
88
99
  }
89
100
  })
90
101
  .catch((reason) => {
91
102
  if (generation.current === requestGeneration) {
92
- setError(toError(reason));
103
+ setError(reason instanceof Error ? reason : new Error(String(reason)));
93
104
  }
94
105
  })
95
106
  .finally(() => {
@@ -99,27 +110,35 @@ function useSignalsAlerts(query = {}) {
99
110
  }
100
111
  });
101
112
  return () => {
113
+ var _a;
114
+ controller.abort();
115
+ (_a = loadMoreController.current) === null || _a === void 0 ? void 0 : _a.abort();
102
116
  generation.current += 1;
103
117
  };
104
- }, [listPage, revision]);
118
+ }, [listPage, queryKey, revision]);
105
119
  const loadMore = React.useCallback(async () => {
120
+ var _a;
106
121
  if (nextCursor === null || loadingRef.current) {
107
122
  return;
108
123
  }
109
124
  const requestGeneration = generation.current;
125
+ const controller = new AbortController();
126
+ (_a = loadMoreController.current) === null || _a === void 0 ? void 0 : _a.abort();
127
+ loadMoreController.current = controller;
110
128
  loadingRef.current = true;
111
129
  setLoading(true);
112
130
  setError(undefined);
113
131
  try {
114
- const page = await listPage(nextCursor);
132
+ const page = await listPage(nextCursor, controller.signal);
115
133
  if (generation.current === requestGeneration) {
116
134
  setItems((current) => [...current, ...page.items]);
117
135
  setNextCursor(page.nextCursor);
136
+ setDataUpdatedAt(Date.now());
118
137
  }
119
138
  }
120
139
  catch (reason) {
121
140
  if (generation.current === requestGeneration) {
122
- setError(toError(reason));
141
+ setError(reason instanceof Error ? reason : new Error(String(reason)));
123
142
  }
124
143
  }
125
144
  finally {
@@ -127,6 +146,9 @@ function useSignalsAlerts(query = {}) {
127
146
  loadingRef.current = false;
128
147
  setLoading(false);
129
148
  }
149
+ if (loadMoreController.current === controller) {
150
+ loadMoreController.current = undefined;
151
+ }
130
152
  }
131
153
  }, [listPage, nextCursor]);
132
154
  const reload = React.useCallback(() => {
@@ -134,31 +156,13 @@ function useSignalsAlerts(query = {}) {
134
156
  }, []);
135
157
  return {
136
158
  items,
159
+ dataUpdatedAt,
137
160
  loading,
161
+ isRefreshing: items.length > 0 && loading,
162
+ isStale: items.length > 0 && (loading || error !== undefined),
138
163
  error,
139
164
  reload,
140
165
  hasMore: nextCursor !== null,
141
166
  loadMore,
142
167
  };
143
168
  }
144
- function useSignalsAlert(id, grain = {}) {
145
- const client = (0, index_1.useClient)();
146
- const episodes = grain.episodes !== false;
147
- const load = React.useCallback(() => episodes
148
- ? client.getSignalsAlert(id)
149
- : client.getSignalsRawAlert(id), [client, id, episodes]);
150
- return (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
151
- }
152
- function useAcknowledgeSignalsAlert(grain = {}) {
153
- const episodes = grain.episodes !== false;
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
- });
163
- }
164
- const toError = (error) => error instanceof Error ? error : new Error(String(error));
@@ -0,0 +1,19 @@
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>;
@@ -0,0 +1,62 @@
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 = useSignalsAlert;
38
+ exports.useAcknowledgeSignalsAlert = useAcknowledgeSignalsAlert;
39
+ const React = __importStar(require("react"));
40
+ const api_hooks_1 = require("./api-hooks");
41
+ const notification_invalidation_1 = require("./notification-invalidation");
42
+ const index_1 = require("./index");
43
+ function useSignalsAlert(id, grain = {}) {
44
+ const client = (0, index_1.useClient)();
45
+ const episodes = grain.episodes !== false;
46
+ const load = React.useCallback((signal) => episodes
47
+ ? client.getSignalsAlert(id, { signal })
48
+ : client.getSignalsRawAlert(id, { signal }), [client, id, episodes]);
49
+ return (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
50
+ }
51
+ function useAcknowledgeSignalsAlert(grain = {}) {
52
+ const episodes = grain.episodes !== false;
53
+ return (0, api_hooks_1.useOvokMutation)(async (client, id) => {
54
+ const result = episodes
55
+ ? await client.acknowledgeSignalsAlert(id)
56
+ : await client.acknowledgeSignalsRawAlert(id);
57
+ (0, notification_invalidation_1.notifyNotificationChanges)(client, episodes
58
+ ? { type: "signals-alert", alert: result }
59
+ : { type: "signals-raw-alert", alert: result });
60
+ return result;
61
+ });
62
+ }
@@ -46,7 +46,7 @@ const useEnableSignalsForPatient = () => (0, api_hooks_1.useOvokMutation)((clien
46
46
  exports.useEnableSignalsForPatient = useEnableSignalsForPatient;
47
47
  const useSignalsThresholds = (patientId) => {
48
48
  const client = (0, index_1.useClient)();
49
- const load = React.useCallback(() => client.getSignalsThresholds(patientId), [client, patientId]);
49
+ const load = React.useCallback((signal) => client.getSignalsThresholds(patientId, { signal }), [client, patientId]);
50
50
  return (0, api_hooks_1.useOvokRequest)(load, patientId !== undefined);
51
51
  };
52
52
  exports.useSignalsThresholds = useSignalsThresholds;
@@ -56,7 +56,7 @@ const useRemoveSignalsThreshold = () => (0, api_hooks_1.useOvokMutation)((client
56
56
  exports.useRemoveSignalsThreshold = useRemoveSignalsThreshold;
57
57
  const useSignalsSettings = () => {
58
58
  const client = (0, index_1.useClient)();
59
- const load = React.useCallback(() => client.getSignalsSettings(), [client]);
59
+ const load = React.useCallback((signal) => client.getSignalsSettings({ signal }), [client]);
60
60
  return (0, api_hooks_1.useOvokRequest)(load);
61
61
  };
62
62
  exports.useSignalsSettings = useSignalsSettings;
package/dist/index.d.ts CHANGED
@@ -931,6 +931,8 @@ export * from "./client/auth/errors";
931
931
  export type { RegisterBody } from "./client/auth/types/RegisterBody";
932
932
  export type { RegisterPractitionerBody } from "./client/auth/types/RegisterPractitionerBody";
933
933
  export type { OvokSavedAccount } from "./client/auth/types/Account";
934
+ export { LoginError } from "./client/auth/types/LoginError";
935
+ export type { LoginProfile, TenantLoginStart } from "./client/auth/types/LoginError";
934
936
  export { MAX_CONDITIONAL_OBSERVATION_ENTRIES, MAX_OBSERVATION_BUNDLE_BYTES, } from "./client/ovok-client";
935
937
  export type { SaveObservationsResult } from "./client/ovok-client";
936
938
  export * from "./client/offline";
@@ -950,6 +952,7 @@ export * from "./client/cms";
950
952
  export * from "./client/invites";
951
953
  export * from "./client/notifications";
952
954
  export * from "./client/slim/types";
955
+ export * from "./client/slim/paging";
953
956
  export * from "./client/experience/types";
954
957
  export * from "./client/patient/types";
955
958
  export * from "./client/patient-sharing";
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.mapSignalsError = exports.isSignalsError = exports.SignalsError = exports.saveMeasurement = exports.MAX_OBSERVATION_BUNDLE_BYTES = exports.MAX_CONDITIONAL_OBSERVATION_ENTRIES = exports.OvokClient = exports.Medplum = void 0;
39
+ exports.mapSignalsError = exports.isSignalsError = exports.SignalsError = exports.saveMeasurement = exports.MAX_OBSERVATION_BUNDLE_BYTES = exports.MAX_CONDITIONAL_OBSERVATION_ENTRIES = exports.LoginError = exports.OvokClient = exports.Medplum = void 0;
40
40
  const MedplumCore = __importStar(require("@medplum/core"));
41
41
  __exportStar(require("./types"), exports);
42
42
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -48,6 +48,8 @@ __exportStar(require("./client/errors/rate-limit-error"), exports);
48
48
  __exportStar(require("./client/errors/sign-in-required-error"), exports);
49
49
  __exportStar(require("./client/errors/ovok-error"), exports);
50
50
  __exportStar(require("./client/auth/errors"), exports);
51
+ var LoginError_1 = require("./client/auth/types/LoginError");
52
+ Object.defineProperty(exports, "LoginError", { enumerable: true, get: function () { return LoginError_1.LoginError; } });
51
53
  var ovok_client_2 = require("./client/ovok-client");
52
54
  Object.defineProperty(exports, "MAX_CONDITIONAL_OBSERVATION_ENTRIES", { enumerable: true, get: function () { return ovok_client_2.MAX_CONDITIONAL_OBSERVATION_ENTRIES; } });
53
55
  Object.defineProperty(exports, "MAX_OBSERVATION_BUNDLE_BYTES", { enumerable: true, get: function () { return ovok_client_2.MAX_OBSERVATION_BUNDLE_BYTES; } });
@@ -69,6 +71,7 @@ __exportStar(require("./client/cms"), exports);
69
71
  __exportStar(require("./client/invites"), exports);
70
72
  __exportStar(require("./client/notifications"), exports);
71
73
  __exportStar(require("./client/slim/types"), exports);
74
+ __exportStar(require("./client/slim/paging"), exports);
72
75
  __exportStar(require("./client/experience/types"), exports);
73
76
  __exportStar(require("./client/patient/types"), exports);
74
77
  __exportStar(require("./client/patient-sharing"), exports);
@@ -1,9 +1,11 @@
1
+ import type { MedplumRequestOptions } from "@medplum/core";
1
2
  import { OvokClient } from "../../client/ovok-client";
2
3
  import { AuthResponse } from "../../types";
3
4
  type ExchangeCodeProps = {
4
5
  client: OvokClient;
5
6
  sessionCode: string;
6
7
  codeVerifier: string;
8
+ requestOptions?: MedplumRequestOptions;
7
9
  } & ({
8
10
  type: "Patient";
9
11
  } | {
@@ -7,11 +7,11 @@ const exchangeCode = async ({ ...props }) => {
7
7
  sessionCode: props.sessionCode,
8
8
  codeVerifier: props.codeVerifier,
9
9
  tenantCode: props.tenantCode,
10
- });
10
+ }, undefined, props.requestOptions);
11
11
  }
12
12
  return props.client.post("auth/tenant/Patient/login/token", {
13
13
  sessionCode: props.sessionCode,
14
14
  codeVerifier: props.codeVerifier,
15
- });
15
+ }, undefined, props.requestOptions);
16
16
  };
17
17
  exports.exchangeCode = exchangeCode;
@@ -3,4 +3,4 @@ export declare const handleTenantCode: ({ profiles, tenantCode, type, }: {
3
3
  profiles: StartLoginResponse["profiles"];
4
4
  tenantCode?: string;
5
5
  type: "Practitioner" | "Patient";
6
- }) => string | undefined;
6
+ }) => string;
@@ -1,20 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleTenantCode = void 0;
4
+ const LoginError_1 = require("../../client/auth/types/LoginError");
4
5
  const handleTenantCode = ({ profiles, tenantCode, type, }) => {
5
- var _a;
6
6
  if (type !== "Practitioner") {
7
+ if (!tenantCode) {
8
+ throw new LoginError_1.LoginError("tenant_code_required", "A tenant code is required for patient login.");
9
+ }
7
10
  return tenantCode;
8
11
  }
9
12
  if (!profiles || !(profiles === null || profiles === void 0 ? void 0 : profiles.length)) {
10
- throw new Error("No profiles found");
13
+ if (tenantCode) {
14
+ return tenantCode;
15
+ }
16
+ throw new LoginError_1.LoginError("profile_not_found", "No practitioner profiles were returned.");
11
17
  }
12
18
  if (!tenantCode) {
13
- return (_a = profiles === null || profiles === void 0 ? void 0 : profiles[0]) === null || _a === void 0 ? void 0 : _a.tenantCode;
19
+ if (profiles.length === 1) {
20
+ return profiles[0].tenantCode;
21
+ }
22
+ throw new LoginError_1.LoginError("tenant_code_required", "Choose a project before completing sign-in.", profiles);
14
23
  }
15
24
  const matchingProfile = profiles.find((profile) => profile.tenantCode === tenantCode);
16
25
  if (!matchingProfile) {
17
- throw new Error("No matching profile found");
26
+ throw new LoginError_1.LoginError("tenant_code_not_found", "No practitioner profile matches that project.", profiles);
18
27
  }
19
28
  return matchingProfile.tenantCode;
20
29
  };
@@ -1,3 +1,4 @@
1
+ import type { MedplumRequestOptions } from "@medplum/core";
1
2
  import { StartLoginResponse } from "../../client/auth/types/StartLoginResponse";
2
3
  import { OvokClient } from "../../client/ovok-client";
3
4
  import { LoginBody } from "../../types";
@@ -5,6 +6,7 @@ type StartLoginProps = {
5
6
  client: OvokClient;
6
7
  body: LoginBody;
7
8
  codeChallenge: string;
9
+ requestOptions?: MedplumRequestOptions;
8
10
  };
9
- export declare const startLogin: ({ client, body, codeChallenge, }: StartLoginProps) => Promise<StartLoginResponse>;
11
+ export declare const startLogin: ({ client, body, codeChallenge, requestOptions, }: StartLoginProps) => Promise<StartLoginResponse>;
10
12
  export {};
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startLogin = void 0;
4
- const startLogin = async ({ client, body, codeChallenge, }) => {
4
+ const startLogin = async ({ client, body, codeChallenge, requestOptions, }) => {
5
5
  if (body.type === "Patient") {
6
6
  return client.post("auth/tenant/Patient/login/start", {
7
7
  email: body.email,
8
8
  password: body.password,
9
9
  codeChallenge,
10
10
  tenantCode: body.tenantCode,
11
- }, "application/json");
11
+ }, "application/json", requestOptions);
12
12
  }
13
13
  return client.post("auth/tenant/Practitioner/login/start", {
14
14
  email: body.email,
15
15
  password: body.password,
16
16
  codeChallenge,
17
- }, "application/json");
17
+ }, "application/json", requestOptions);
18
18
  };
19
19
  exports.startLogin = startLogin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.31",
3
+ "version": "0.4.32",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",