@ovok/core 0.4.30 → 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 +28 -11
  65. package/dist/client/ovok-client.js +353 -31
  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 +4 -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
@@ -44,6 +44,7 @@ exports.updateSlimThresholdV2 = updateSlimThresholdV2;
44
44
  exports.getSlimPatientThresholdV2 = getSlimPatientThresholdV2;
45
45
  exports.updateSlimPatientThresholdV2 = updateSlimPatientThresholdV2;
46
46
  exports.getSlimTrends = getSlimTrends;
47
+ exports.getSlimRealtimeTrends = getSlimRealtimeTrends;
47
48
  exports.getSlimSleepStatistics = getSlimSleepStatistics;
48
49
  exports.listSlimLocations = listSlimLocations;
49
50
  exports.getSlimLocation = getSlimLocation;
@@ -54,6 +55,28 @@ exports.listSlimZones = listSlimZones;
54
55
  exports.getSlimZone = getSlimZone;
55
56
  exports.getSlimZoneDeviceCounts = getSlimZoneDeviceCounts;
56
57
  exports.exportSlimPatientPdf = exportSlimPatientPdf;
58
+ exports.listSlimProjectUsers = listSlimProjectUsers;
59
+ exports.createSlimChildProject = createSlimChildProject;
60
+ exports.getSlimProjectRelationships = getSlimProjectRelationships;
61
+ exports.getSlimProjectRelationshipsV2 = getSlimProjectRelationshipsV2;
62
+ exports.deleteSlimChildProject = deleteSlimChildProject;
63
+ exports.listSlimProjectUsersById = listSlimProjectUsersById;
64
+ exports.getSlimProjectDeviceCounts = getSlimProjectDeviceCounts;
65
+ exports.getSlimProjectPatientCounts = getSlimProjectPatientCounts;
66
+ exports.updateSlimProject = updateSlimProject;
67
+ exports.getSlimProject = getSlimProject;
68
+ exports.listSlimPolicies = listSlimPolicies;
69
+ exports.getSlimPolicy = getSlimPolicy;
70
+ exports.createSlimPolicy = createSlimPolicy;
71
+ exports.updateSlimPolicy = updateSlimPolicy;
72
+ exports.deleteSlimPolicy = deleteSlimPolicy;
73
+ exports.getSlimOrganization = getSlimOrganization;
74
+ exports.createSlimOrganization = createSlimOrganization;
75
+ exports.updateSlimOrganization = updateSlimOrganization;
76
+ exports.deleteSlimOrganization = deleteSlimOrganization;
77
+ exports.inviteSlimPractitioner = inviteSlimPractitioner;
78
+ exports.deleteSlimUser = deleteSlimUser;
79
+ exports.getSlimHealth = getSlimHealth;
57
80
  const query = (params) => {
58
81
  const values = new URLSearchParams();
59
82
  for (const [key, value] of Object.entries(params)) {
@@ -65,100 +88,195 @@ const query = (params) => {
65
88
  return encoded === "" ? "" : `?${encoded}`;
66
89
  };
67
90
  const segment = (value) => encodeURIComponent(value);
68
- async function listSlimPatients(params = {}) {
69
- return this.get(`/v1/slim/patient${query(params)}`);
91
+ const inFlightLiveReads = new Map();
92
+ const dedupeLiveRead = (client, path, load, options) => {
93
+ var _a, _b, _c, _d, _e, _f, _g;
94
+ const signal = (_a = options === null || options === void 0 ? void 0 : options.signal) !== null && _a !== void 0 ? _a : undefined;
95
+ const canShare = Object.keys(options !== null && options !== void 0 ? options : {}).every((key) => key === "signal" || key === "cache");
96
+ if (!canShare) {
97
+ return load(signal);
98
+ }
99
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
100
+ return Promise.reject((_b = signal.reason) !== null && _b !== void 0 ? _b : abortError());
101
+ }
102
+ const login = client.getActiveLogin();
103
+ const key = [
104
+ client.getBaseUrl(),
105
+ (_d = (_c = login === null || login === void 0 ? void 0 : login.profile) === null || _c === void 0 ? void 0 : _c.reference) !== null && _d !== void 0 ? _d : "",
106
+ (_f = (_e = login === null || login === void 0 ? void 0 : login.project) === null || _e === void 0 ? void 0 : _e.reference) !== null && _f !== void 0 ? _f : "",
107
+ (_g = options === null || options === void 0 ? void 0 : options.cache) !== null && _g !== void 0 ? _g : "reload",
108
+ path,
109
+ ].join("\0");
110
+ let inFlight = inFlightLiveReads.get(key);
111
+ if (!inFlight) {
112
+ const controller = new AbortController();
113
+ const sharedRead = {
114
+ controller,
115
+ promise: Promise.resolve(),
116
+ subscribers: 0,
117
+ settled: false,
118
+ };
119
+ let request;
120
+ try {
121
+ request = load(signal ? controller.signal : undefined);
122
+ }
123
+ catch (error) {
124
+ request = Promise.reject(error);
125
+ }
126
+ sharedRead.promise = request.finally(() => {
127
+ if (inFlightLiveReads.get(key) === sharedRead) {
128
+ inFlightLiveReads.delete(key);
129
+ }
130
+ sharedRead.settled = true;
131
+ });
132
+ inFlight = sharedRead;
133
+ inFlightLiveReads.set(key, sharedRead);
134
+ void sharedRead.promise.catch(() => undefined);
135
+ }
136
+ const shared = inFlight;
137
+ return new Promise((resolve, reject) => {
138
+ let active = true;
139
+ shared.subscribers += 1;
140
+ const release = () => {
141
+ if (!active) {
142
+ return false;
143
+ }
144
+ active = false;
145
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", onAbort);
146
+ shared.subscribers -= 1;
147
+ if (!shared.settled && shared.subscribers === 0) {
148
+ shared.controller.abort();
149
+ }
150
+ return true;
151
+ };
152
+ const onAbort = () => {
153
+ var _a;
154
+ if (release()) {
155
+ reject((_a = signal === null || signal === void 0 ? void 0 : signal.reason) !== null && _a !== void 0 ? _a : abortError());
156
+ }
157
+ };
158
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
159
+ shared.promise.then((value) => {
160
+ if (release()) {
161
+ resolve(value);
162
+ }
163
+ }, (error) => {
164
+ if (release()) {
165
+ reject(error);
166
+ }
167
+ });
168
+ });
169
+ };
170
+ const abortError = () => {
171
+ const error = new Error("The request was aborted.");
172
+ error.name = "AbortError";
173
+ return error;
174
+ };
175
+ const validateLiveCount = (params) => {
176
+ if (params.count !== undefined && (!Number.isInteger(params.count) || params.count < 1 || params.count > 100)) {
177
+ throw new RangeError("count must be an integer from 1 to 100.");
178
+ }
179
+ };
180
+ async function listSlimPatients(params = {}, requestOptions) {
181
+ return this.get(`/v1/slim/patient${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
70
182
  }
71
- async function getSlimPatient(patientId) {
72
- return this.get(`/v1/slim/patient/${segment(patientId)}`);
183
+ async function getSlimPatient(patientId, requestOptions) {
184
+ return this.get(`/v1/slim/patient/${segment(patientId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
73
185
  }
74
- async function getSlimPatientEverything(patientId) {
75
- return this.get(`/v1/slim/patient/${segment(patientId)}/$everything`);
186
+ async function getSlimPatientEverything(patientId, requestOptions) {
187
+ return this.get(`/v1/slim/patient/${segment(patientId)}/$everything`, ...(requestOptions === undefined ? [] : [requestOptions]));
76
188
  }
77
- async function getSlimPatientCurrentVitals(patientId) {
78
- return this.get(`/v1/slim/patient/${segment(patientId)}/current-vitals`);
189
+ async function getSlimPatientCurrentVitals(patientId, requestOptions) {
190
+ return this.get(`/v1/slim/patient/${segment(patientId)}/current-vitals`, ...(requestOptions === undefined ? [] : [requestOptions]));
79
191
  }
80
- async function createSlimPatient(body) {
81
- return this.post("/v1/slim/patient", body);
192
+ async function createSlimPatient(body, requestOptions) {
193
+ return this.post("/v1/slim/patient", body, undefined, requestOptions);
82
194
  }
83
- async function updateSlimPatient(patientId, body) {
84
- return (await this.put(`/v1/slim/patient/${segment(patientId)}`, body));
195
+ async function updateSlimPatient(patientId, body, requestOptions) {
196
+ return (await this.put(`/v1/slim/patient/${segment(patientId)}`, body, undefined, requestOptions));
85
197
  }
86
- async function deleteSlimPatient(patientId) {
87
- await this.delete(`/v1/slim/patient/${segment(patientId)}`);
198
+ async function deleteSlimPatient(patientId, requestOptions) {
199
+ await this.delete(`/v1/slim/patient/${segment(patientId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
88
200
  }
89
- async function listSlimDevices(params = {}) {
90
- return this.get(`/v1/slim/device${query(params)}`);
201
+ async function listSlimDevices(params = {}, requestOptions) {
202
+ return this.get(`/v1/slim/device${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
91
203
  }
92
- async function getSlimDevice(deviceId) {
93
- return this.get(`/v1/slim/device/${segment(deviceId)}`);
204
+ async function getSlimDevice(deviceId, requestOptions) {
205
+ return this.get(`/v1/slim/device/${segment(deviceId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
94
206
  }
95
- async function createSlimDevice(body) {
96
- return this.post("/v1/slim/device", body);
207
+ async function createSlimDevice(body, requestOptions) {
208
+ return this.post("/v1/slim/device", body, undefined, requestOptions);
97
209
  }
98
- async function updateSlimDevice(deviceId, body) {
99
- return (await this.put(`/v1/slim/device/${segment(deviceId)}`, body));
210
+ async function updateSlimDevice(deviceId, body, requestOptions) {
211
+ return (await this.put(`/v1/slim/device/${segment(deviceId)}`, body, undefined, requestOptions));
100
212
  }
101
- async function deleteSlimDevice(deviceId) {
102
- await this.delete(`/v1/slim/device/${segment(deviceId)}`);
213
+ async function deleteSlimDevice(deviceId, requestOptions) {
214
+ await this.delete(`/v1/slim/device/${segment(deviceId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
103
215
  }
104
- async function assignSlimDeviceToProject(body) {
105
- return (await this.put("/v1/slim/device/assign/project", body));
216
+ async function assignSlimDeviceToProject(body, requestOptions) {
217
+ return (await this.put("/v1/slim/device/assign/project", body, undefined, requestOptions));
106
218
  }
107
- async function listSlimLiveDevices(params = {}) {
108
- return this.get(`/v1/slim/device/live${query(params)}`, { cache: "reload" });
219
+ async function listSlimLiveDevices(params = {}, requestOptions) {
220
+ validateLiveCount(params);
221
+ const path = `/v1/slim/device/live${query(params)}`;
222
+ return dedupeLiveRead(this, path, (signal) => this.get(path, { cache: "reload", ...requestOptions, ...(signal ? { signal } : {}) }), requestOptions);
109
223
  }
110
- async function listSlimLiveTelemetry(params = {}) {
111
- return this.get(`/v1/slim/device/live/telemetry${query(params)}`, { cache: "reload" });
224
+ async function listSlimLiveTelemetry(params = {}, requestOptions) {
225
+ validateLiveCount(params);
226
+ const path = `/v1/slim/device/live/telemetry${query(params)}`;
227
+ return dedupeLiveRead(this, path, (signal) => this.get(path, { cache: "reload", ...requestOptions, ...(signal ? { signal } : {}) }), requestOptions);
112
228
  }
113
- async function getSlimDeviceSleepStatus(deviceId) {
114
- return this.get(`/v1/slim/device/live/cloudwatch/${segment(deviceId)}`, { cache: "reload" });
229
+ async function getSlimDeviceSleepStatus(deviceId, requestOptions) {
230
+ const path = `/v1/slim/device/live/cloudwatch/${segment(deviceId)}`;
231
+ return dedupeLiveRead(this, path, (signal) => this.get(path, { cache: "reload", ...requestOptions, ...(signal ? { signal } : {}) }), requestOptions);
115
232
  }
116
- async function getSlimDeviceTelemetry(deviceId) {
117
- return this.get(`/v1/slim/telemetry/${segment(deviceId)}`, { cache: "reload" });
233
+ async function getSlimDeviceTelemetry(deviceId, requestOptions) {
234
+ const path = `/v1/slim/telemetry/${segment(deviceId)}`;
235
+ return dedupeLiveRead(this, path, (signal) => this.get(path, { cache: "reload", ...requestOptions, ...(signal ? { signal } : {}) }), requestOptions);
118
236
  }
119
- async function listSlimEffectiveObservationIds() {
120
- return this.get("/v1/slim/telemetry/effectiveIds");
237
+ async function listSlimEffectiveObservationIds(requestOptions) {
238
+ return this.get("/v1/slim/telemetry/effectiveIds", ...(requestOptions === undefined ? [] : [requestOptions]));
121
239
  }
122
- async function listSlimLastObservationIds() {
123
- return this.get("/v1/slim/telemetry/lastIds");
240
+ async function listSlimLastObservationIds(requestOptions) {
241
+ return this.get("/v1/slim/telemetry/lastIds", ...(requestOptions === undefined ? [] : [requestOptions]));
124
242
  }
125
- async function getSlimDeviceEffectiveObservationIds(deviceId) {
126
- return this.get(`/v1/slim/telemetry/${segment(deviceId)}/effectiveIds`);
243
+ async function getSlimDeviceEffectiveObservationIds(deviceId, requestOptions) {
244
+ return this.get(`/v1/slim/telemetry/${segment(deviceId)}/effectiveIds`, ...(requestOptions === undefined ? [] : [requestOptions]));
127
245
  }
128
- async function getSlimDeviceLastObservationIds(deviceId) {
129
- return this.get(`/v1/slim/telemetry/${segment(deviceId)}/lastIds`);
246
+ async function getSlimDeviceLastObservationIds(deviceId, requestOptions) {
247
+ return this.get(`/v1/slim/telemetry/${segment(deviceId)}/lastIds`, ...(requestOptions === undefined ? [] : [requestOptions]));
130
248
  }
131
249
  /** @deprecated Use listSlimOutOfBedNotifications, listSlimAlarms, or listSlimMedicalNotifications. */
132
- async function listSlimNotifications(params = {}) {
133
- return this.get(`/v1/slim/notifications${query(params)}`, { cache: "reload" });
250
+ async function listSlimNotifications(params = {}, requestOptions) {
251
+ return this.get(`/v1/slim/notifications${query(params)}`, { ...{ cache: "reload" }, ...requestOptions });
134
252
  }
135
- async function getRecentSlimNotifications(count) {
136
- return this.get(`/v1/slim/notifications/recent${query({ count })}`, { cache: "reload" });
253
+ async function getRecentSlimNotifications(count, requestOptions) {
254
+ return this.get(`/v1/slim/notifications/recent${query({ count })}`, { ...{ cache: "reload" }, ...requestOptions });
137
255
  }
138
- async function listSlimAlarms(params = {}) {
139
- return this.get(`/v1/slim/notifications/alarms${query(params)}`, { cache: "reload" });
256
+ async function listSlimAlarms(params = {}, requestOptions) {
257
+ return this.get(`/v1/slim/notifications/alarms${query(params)}`, { ...{ cache: "reload" }, ...requestOptions });
140
258
  }
141
- async function acknowledgeSlimAlarm(notificationId) {
142
- return (await this.patch(`/v1/slim/notifications/${segment(notificationId)}/ack`, []));
259
+ async function acknowledgeSlimAlarm(notificationId, requestOptions) {
260
+ return (await this.patch(`/v1/slim/notifications/${segment(notificationId)}/ack`, [], ...(requestOptions === undefined ? [] : [requestOptions])));
143
261
  }
144
- async function getRecentSlimAlarms(count) {
145
- return this.get(`/v1/slim/notifications/recent/alarms${query({ count })}`, { cache: "reload" });
262
+ async function getRecentSlimAlarms(count, requestOptions) {
263
+ return this.get(`/v1/slim/notifications/recent/alarms${query({ count })}`, { ...{ cache: "reload" }, ...requestOptions });
146
264
  }
147
- function getRecentAlarms(count) {
148
- return getRecentSlimAlarms.call(this, count);
265
+ function getRecentAlarms(count, requestOptions) {
266
+ return getRecentSlimAlarms.call(this, count, ...(requestOptions === undefined ? [] : [requestOptions]));
149
267
  }
150
- async function getRecentSlimOutOfBed(count) {
151
- return this.get(`/v1/slim/notifications/recent/oob${query({ count })}`, { cache: "reload" });
268
+ async function getRecentSlimOutOfBed(count, requestOptions) {
269
+ return this.get(`/v1/slim/notifications/recent/oob${query({ count })}`, { ...{ cache: "reload" }, ...requestOptions });
152
270
  }
153
- function getRecentOutOfBed(count) {
154
- return getRecentSlimOutOfBed.call(this, count);
271
+ function getRecentOutOfBed(count, requestOptions) {
272
+ return getRecentSlimOutOfBed.call(this, count, ...(requestOptions === undefined ? [] : [requestOptions]));
155
273
  }
156
- async function listSlimOutOfBedNotifications(params = {}) {
157
- return this.get(`/v1/slim/notifications/oob${query(params)}`, { cache: "reload" });
274
+ async function listSlimOutOfBedNotifications(params = {}, requestOptions) {
275
+ return this.get(`/v1/slim/notifications/oob${query(params)}`, { ...{ cache: "reload" }, ...requestOptions });
158
276
  }
159
- async function listSlimMedicalNotifications(params = {}) {
277
+ async function listSlimMedicalNotifications(params = {}, requestOptions) {
160
278
  validateMedicalCodes(params.codes);
161
- return this.get(`/v1/slim/notifications/medical${query(params)}`, { cache: "reload" });
279
+ return this.get(`/v1/slim/notifications/medical${query(params)}`, { ...{ cache: "reload" }, ...requestOptions });
162
280
  }
163
281
  const MEDICAL_CODE = /^(?:\d{1,7}-\d|PI)$/;
164
282
  function validateMedicalCodes(codes) {
@@ -167,72 +285,141 @@ function validateMedicalCodes(codes) {
167
285
  throw new TypeError("codes must contain at most 32 valid LOINC codes or PI.");
168
286
  }
169
287
  }
170
- async function getRecentSlimMedicalNotifications(count) {
171
- return this.get(`/v1/slim/notifications/recent/medical${query({ count })}`, { cache: "reload" });
288
+ async function getRecentSlimMedicalNotifications(count, requestOptions) {
289
+ return this.get(`/v1/slim/notifications/recent/medical${query({ count })}`, { ...{ cache: "reload" }, ...requestOptions });
290
+ }
291
+ async function getSlimMedicalNotification(episodeId, requestOptions) {
292
+ return this.get(`/v1/slim/notifications/medical/${segment(episodeId)}`, { ...{ cache: "reload" }, ...requestOptions });
293
+ }
294
+ async function acknowledgeSlimMedicalNotification(episodeId, requestOptions) {
295
+ return this.post(`/v1/slim/notifications/medical/${segment(episodeId)}/ack`, undefined, undefined, requestOptions);
296
+ }
297
+ async function acknowledgeSlimNotification(notificationId, requestOptions) {
298
+ return (await this.patch(`/v1/slim/notifications/${segment(notificationId)}/ack`, [], ...(requestOptions === undefined ? [] : [requestOptions])));
299
+ }
300
+ async function getSlimThreshold(requestOptions) {
301
+ return this.get("/v1/slim/threshold", ...(requestOptions === undefined ? [] : [requestOptions]));
302
+ }
303
+ async function updateSlimThreshold(body, requestOptions) {
304
+ return (await this.put("/v1/slim/threshold", body, undefined, requestOptions));
305
+ }
306
+ async function getSlimPatientThreshold(patientId, requestOptions) {
307
+ return this.get(`/v1/slim/threshold/patient/${segment(patientId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
308
+ }
309
+ async function updateSlimPatientThreshold(patientId, body, requestOptions) {
310
+ return (await this.put(`/v1/slim/threshold/patient/${segment(patientId)}`, body, undefined, requestOptions));
311
+ }
312
+ async function getSlimThresholdV2(requestOptions) {
313
+ return this.get("/v2/slim/threshold", ...(requestOptions === undefined ? [] : [requestOptions]));
314
+ }
315
+ async function updateSlimThresholdV2(body, requestOptions) {
316
+ return (await this.put("/v2/slim/threshold", body, undefined, requestOptions));
317
+ }
318
+ async function getSlimPatientThresholdV2(patientId, requestOptions) {
319
+ return this.get(`/v2/slim/threshold/patient/${segment(patientId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
320
+ }
321
+ async function updateSlimPatientThresholdV2(patientId, body, requestOptions) {
322
+ return (await this.put(`/v2/slim/threshold/patient/${segment(patientId)}`, body, undefined, requestOptions));
323
+ }
324
+ async function getSlimTrends(params, requestOptions) {
325
+ return this.get(`/v1/slim/trends/graphs${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
326
+ }
327
+ async function getSlimRealtimeTrends(params, requestOptions) {
328
+ return this.get(`/v1/slim/trends/realtime${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
329
+ }
330
+ async function getSlimSleepStatistics(params, requestOptions) {
331
+ return this.get(`/v1/slim/sleep/statistics${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
332
+ }
333
+ async function listSlimLocations(params = {}, requestOptions) {
334
+ return this.get(`/v1/slim/location${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
335
+ }
336
+ async function getSlimLocation(locationId, requestOptions) {
337
+ return this.get(`/v1/slim/location/${segment(locationId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
338
+ }
339
+ async function createSlimLocation(body, requestOptions) {
340
+ return this.post("/v1/slim/location", body, undefined, requestOptions);
341
+ }
342
+ async function updateSlimLocation(locationId, body, requestOptions) {
343
+ return (await this.put(`/v1/slim/location/${segment(locationId)}`, body, undefined, requestOptions));
344
+ }
345
+ async function deleteSlimLocation(locationId, requestOptions) {
346
+ await this.delete(`/v1/slim/location/${segment(locationId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
347
+ }
348
+ async function listSlimZones(params = {}, requestOptions) {
349
+ return this.get(`/v1/slim/zones${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
350
+ }
351
+ async function getSlimZone(zoneId, requestOptions) {
352
+ return this.get(`/v1/slim/zones/${segment(zoneId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
353
+ }
354
+ async function getSlimZoneDeviceCounts(params = {}, requestOptions) {
355
+ return this.get(`/v1/slim/zones/device-counts${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
356
+ }
357
+ async function exportSlimPatientPdf(body, requestOptions) {
358
+ return this.post("/v1/slim/export/pdf", body, undefined, requestOptions);
172
359
  }
173
- async function getSlimMedicalNotification(episodeId) {
174
- return this.get(`/v1/slim/notifications/medical/${segment(episodeId)}`, { cache: "reload" });
360
+ function listSlimProjectUsers(params = {}, requestOptions) {
361
+ return this.get(`/v1/slim/project/users${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
175
362
  }
176
- async function acknowledgeSlimMedicalNotification(episodeId) {
177
- return this.post(`/v1/slim/notifications/medical/${segment(episodeId)}/ack`);
363
+ function createSlimChildProject(body, requestOptions) {
364
+ return this.post("/v1/slim/project/child", body, undefined, requestOptions);
178
365
  }
179
- async function acknowledgeSlimNotification(notificationId) {
180
- return (await this.patch(`/v1/slim/notifications/${segment(notificationId)}/ack`, []));
366
+ function getSlimProjectRelationships(requestOptions) {
367
+ return this.get("/v1/slim/project/child", ...(requestOptions === undefined ? [] : [requestOptions]));
181
368
  }
182
- async function getSlimThreshold() {
183
- return this.get("/v1/slim/threshold");
369
+ function getSlimProjectRelationshipsV2(requestOptions) {
370
+ return this.get("/v2/slim/project/child", ...(requestOptions === undefined ? [] : [requestOptions]));
184
371
  }
185
- async function updateSlimThreshold(body) {
186
- return (await this.put("/v1/slim/threshold", body));
372
+ function deleteSlimChildProject(subProjectId, requestOptions) {
373
+ return this.delete(`/v1/slim/project/child/${segment(subProjectId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
187
374
  }
188
- async function getSlimPatientThreshold(patientId) {
189
- return this.get(`/v1/slim/threshold/patient/${segment(patientId)}`);
375
+ function listSlimProjectUsersById(projectId, params = {}, requestOptions) {
376
+ return this.get(`/v1/slim/project/${segment(projectId)}/users${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
190
377
  }
191
- async function updateSlimPatientThreshold(patientId, body) {
192
- return (await this.put(`/v1/slim/threshold/patient/${segment(patientId)}`, body));
378
+ function getSlimProjectDeviceCounts(projectId, requestOptions) {
379
+ return this.get(`/v1/slim/project/${segment(projectId)}/device-counts`, ...(requestOptions === undefined ? [] : [requestOptions]));
193
380
  }
194
- async function getSlimThresholdV2() {
195
- return this.get("/v2/slim/threshold");
381
+ function getSlimProjectPatientCounts(projectId, requestOptions) {
382
+ return this.get(`/v1/slim/project/${segment(projectId)}/patient-counts`, ...(requestOptions === undefined ? [] : [requestOptions]));
196
383
  }
197
- async function updateSlimThresholdV2(body) {
198
- return (await this.put("/v2/slim/threshold", body));
384
+ function updateSlimProject(projectId, body, requestOptions) {
385
+ return this.put(`/v1/slim/project/${segment(projectId)}`, body, undefined, requestOptions);
199
386
  }
200
- async function getSlimPatientThresholdV2(patientId) {
201
- return this.get(`/v2/slim/threshold/patient/${segment(patientId)}`);
387
+ function getSlimProject(projectId, requestOptions) {
388
+ return this.get(`/v1/slim/project/${segment(projectId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
202
389
  }
203
- async function updateSlimPatientThresholdV2(patientId, body) {
204
- return (await this.put(`/v2/slim/threshold/patient/${segment(patientId)}`, body));
390
+ function listSlimPolicies(params = {}, requestOptions) {
391
+ return this.get(`/v1/slim/policy${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
205
392
  }
206
- async function getSlimTrends(params) {
207
- return this.get(`/v1/slim/trends/graphs${query(params)}`);
393
+ function getSlimPolicy(policyId, requestOptions) {
394
+ return this.get(`/v1/slim/policy/${segment(policyId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
208
395
  }
209
- async function getSlimSleepStatistics(params) {
210
- return this.get(`/v1/slim/sleep/statistics${query(params)}`);
396
+ function createSlimPolicy(body, requestOptions) {
397
+ return this.post("/v1/slim/policy", body, undefined, requestOptions);
211
398
  }
212
- async function listSlimLocations(params = {}) {
213
- return this.get(`/v1/slim/location${query(params)}`);
399
+ function updateSlimPolicy(policyId, body, requestOptions) {
400
+ return this.put(`/v1/slim/policy/${segment(policyId)}`, body, undefined, requestOptions);
214
401
  }
215
- async function getSlimLocation(locationId) {
216
- return this.get(`/v1/slim/location/${segment(locationId)}`);
402
+ async function deleteSlimPolicy(policyId, requestOptions) {
403
+ await this.delete(`/v1/slim/policy/${segment(policyId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
217
404
  }
218
- async function createSlimLocation(body) {
219
- return this.post("/v1/slim/location", body);
405
+ function getSlimOrganization(organizationId, requestOptions) {
406
+ return this.get(`/v1/slim/organization/${segment(organizationId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
220
407
  }
221
- async function updateSlimLocation(locationId, body) {
222
- return (await this.put(`/v1/slim/location/${segment(locationId)}`, body));
408
+ function createSlimOrganization(body, requestOptions) {
409
+ return this.post("/v1/slim/organization", body, undefined, requestOptions);
223
410
  }
224
- async function deleteSlimLocation(locationId) {
225
- await this.delete(`/v1/slim/location/${segment(locationId)}`);
411
+ function updateSlimOrganization(organizationId, body, requestOptions) {
412
+ return this.put(`/v1/slim/organization/${segment(organizationId)}`, body, undefined, requestOptions);
226
413
  }
227
- async function listSlimZones(params = {}) {
228
- return this.get(`/v1/slim/zones${query(params)}`);
414
+ async function deleteSlimOrganization(organizationId, requestOptions) {
415
+ await this.delete(`/v1/slim/organization/${segment(organizationId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
229
416
  }
230
- async function getSlimZone(zoneId) {
231
- return this.get(`/v1/slim/zones/${segment(zoneId)}`);
417
+ function inviteSlimPractitioner(body, requestOptions) {
418
+ return this.post("/v1/slim/invite/practitioner", body, undefined, requestOptions);
232
419
  }
233
- async function getSlimZoneDeviceCounts(params = {}) {
234
- return this.get(`/v1/slim/zones/device-counts${query(params)}`);
420
+ function deleteSlimUser(profileType, profileId, requestOptions) {
421
+ return this.delete(`/v1/slim/user/${segment(profileType)}/${segment(profileId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
235
422
  }
236
- async function exportSlimPatientPdf(body) {
237
- return this.post("/v1/slim/export/pdf", body);
423
+ function getSlimHealth(requestOptions) {
424
+ return this.get("/v1/slim/health", ...(requestOptions === undefined ? [] : [requestOptions]));
238
425
  }
@@ -0,0 +1,18 @@
1
+ import { SlimPage } from "./types";
2
+ export type SlimPagingOptions = {
3
+ maxPages?: number;
4
+ };
5
+ export type SlimPageCollection<T> = {
6
+ rows: T[];
7
+ total: number;
8
+ truncated: boolean;
9
+ };
10
+ /** Collects numbered Slim pages without exceeding the optional page limit. */
11
+ export declare function iterateSlimPages<T>(loadPage: (page: number) => Promise<SlimPage<T>>, options?: SlimPagingOptions): Promise<SlimPageCollection<T>>;
12
+ export type SlimCursorPage<T> = {
13
+ items: T[];
14
+ nextCursor: string | null;
15
+ total?: number;
16
+ };
17
+ /** Collects cursor pages, stopping at maxPages and rejecting a repeated cursor. */
18
+ export declare function iterateCursor<T>(loadPage: (cursor?: string) => Promise<SlimCursorPage<T>>, options?: SlimPagingOptions): Promise<SlimPageCollection<T>>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.iterateSlimPages = iterateSlimPages;
4
+ exports.iterateCursor = iterateCursor;
5
+ const pageLimit = ({ maxPages }) => {
6
+ if (maxPages === undefined) {
7
+ return Number.MAX_SAFE_INTEGER;
8
+ }
9
+ if (!Number.isInteger(maxPages) || maxPages < 1) {
10
+ throw new RangeError("maxPages must be a positive integer.");
11
+ }
12
+ return maxPages;
13
+ };
14
+ /** Collects numbered Slim pages without exceeding the optional page limit. */
15
+ async function iterateSlimPages(loadPage, options = {}) {
16
+ const rows = [];
17
+ const maxPages = pageLimit(options);
18
+ let total = 0;
19
+ let pageNumber = 1;
20
+ let hasMore = false;
21
+ for (let index = 0; index < maxPages; index += 1) {
22
+ const page = await loadPage(pageNumber);
23
+ rows.push(...page.resources);
24
+ total = page.total;
25
+ hasMore = page.resources.length > 0 && page.page * page.count < page.total;
26
+ if (!hasMore) {
27
+ break;
28
+ }
29
+ pageNumber = page.page + 1;
30
+ }
31
+ return { rows, total, truncated: hasMore };
32
+ }
33
+ /** Collects cursor pages, stopping at maxPages and rejecting a repeated cursor. */
34
+ async function iterateCursor(loadPage, options = {}) {
35
+ var _a, _b;
36
+ const rows = [];
37
+ const seen = new Set();
38
+ const maxPages = pageLimit(options);
39
+ let cursor;
40
+ let total;
41
+ let truncated = false;
42
+ for (let index = 0; index < maxPages; index += 1) {
43
+ const page = await loadPage(cursor);
44
+ rows.push(...page.items);
45
+ total = (_a = page.total) !== null && _a !== void 0 ? _a : total;
46
+ cursor = (_b = page.nextCursor) !== null && _b !== void 0 ? _b : undefined;
47
+ if (!cursor) {
48
+ break;
49
+ }
50
+ if (seen.has(cursor)) {
51
+ throw new Error("Cursor paging returned a repeated cursor.");
52
+ }
53
+ seen.add(cursor);
54
+ truncated = index === maxPages - 1;
55
+ }
56
+ return { rows, total: total !== null && total !== void 0 ? total : rows.length, truncated };
57
+ }