@ovok/core 0.4.59-dev.563 → 0.4.59-dev.565

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 (25) hide show
  1. package/dist/conformance/capability-requirements.js +1 -1
  2. package/dist/next/index.d.ts +5 -1
  3. package/dist/next/ovok.d.ts +3 -0
  4. package/dist/next/ovok.js +2 -0
  5. package/dist/next/resources/chat/chat-catch-up.d.ts +26 -0
  6. package/dist/next/resources/chat/chat-catch-up.js +46 -0
  7. package/dist/next/resources/chat/chat-connection.d.ts +51 -0
  8. package/dist/next/resources/chat/chat-connection.js +188 -0
  9. package/dist/next/resources/chat/chat-errors.d.ts +4 -0
  10. package/dist/next/resources/chat/chat-errors.js +17 -0
  11. package/dist/next/resources/chat/chat-history.d.ts +16 -0
  12. package/dist/next/resources/chat/chat-history.js +49 -0
  13. package/dist/next/resources/chat/chat-messages-resource.d.ts +25 -0
  14. package/dist/next/resources/chat/chat-messages-resource.js +42 -0
  15. package/dist/next/resources/chat/chat-resource.d.ts +44 -0
  16. package/dist/next/resources/chat/chat-resource.js +49 -0
  17. package/dist/next/resources/chat/chat-threads-resource.d.ts +26 -0
  18. package/dist/next/resources/chat/chat-threads-resource.js +44 -0
  19. package/dist/next/resources/chat/chat-types.d.ts +157 -0
  20. package/dist/next/resources/chat/chat-types.js +2 -0
  21. package/dist/next/resources/omnichannel-alerts/notifications-rules-resource.d.ts +4 -3
  22. package/dist/next/resources/omnichannel-alerts/notifications-rules-resource.js +1 -1
  23. package/dist/next/resources/omnichannel-alerts/omnichannel-alerts-resource.d.ts +27 -23
  24. package/dist/next/resources/omnichannel-alerts/omnichannel-alerts-resource.js +3 -3
  25. package/package.json +4 -1
@@ -26,7 +26,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
26
26
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
27
27
  software: {
28
28
  name: "@ovok/core",
29
- version: "0.4.59-dev.563+fdd295b",
29
+ version: "0.4.59-dev.565+16c360c",
30
30
  },
31
31
  fhirVersion: "4.0.1",
32
32
  format: ["json"],
@@ -51,13 +51,17 @@ export type { DeletedDocument, DocumentDownloadParams } from "./resources/docume
51
51
  export type { BotInput, BotOutput } from "./resources/bots/bots-resource";
52
52
  export type { PushDevice, PushDeviceList, PushPlatform, RegisterPushDeviceRequest, } from "./resources/push/push-devices-resource";
53
53
  export type { ApnsEnvironment, ApnsPushProvider, ApnsPushProviderChange, CreatePushProviderRequest, ExpoPushProvider, FcmPushProvider, PushProviderName, PushProviderSettings, RelayPushProvider, UpdatePushProviderRequest, } from "./resources/push/push-provider-resource";
54
+ export type { ChatEvent, ChatEventHandler, ChatMessage, ChatMessageListParams, ChatParticipant, ChatRead, ChatReadRequest, ChatStopListening, ChatThread, ChatThreadListParams, OpenChatThreadRequest, SendChatMessageRequest, } from "./resources/chat/chat-types";
54
55
  export type { NotificationsRule, NotificationsRuleResponse } from "./resources/omnichannel-alerts/notifications-rules-resource";
55
- export type { NotificationsPreviewAlert, NotificationsPreviewRecipient, NotificationsPreviewRequest, NotificationsPreviewResponse, NotificationsPreviewStep, } from "./resources/omnichannel-alerts/omnichannel-alerts-resource";
56
+ export type { NotificationsPreviewAlert, NotificationsPreviewNotify, NotificationsPreviewRecipient, NotificationsPreviewRequest, NotificationsPreviewResponse, OmnichannelAlertEvent, } from "./resources/omnichannel-alerts/omnichannel-alerts-resource";
56
57
  export type * from "./resources/slim/slim-queries";
57
58
  export type { AccountsResource } from "./resources/accounts/accounts-resource";
58
59
  export type { AiResource } from "./resources/ai/ai-resource";
59
60
  export type { AuthResource } from "./resources/auth-resource";
60
61
  export type { BotsResource } from "./resources/bots/bots-resource";
62
+ export type { ChatResource, ChatSettings } from "./resources/chat/chat-resource";
63
+ export type { ChatThreadMessagesResource } from "./resources/chat/chat-messages-resource";
64
+ export type { ChatThreadsResource } from "./resources/chat/chat-threads-resource";
61
65
  export type { CmsResource } from "./resources/cms/cms-resource";
62
66
  export type { ConsentResource } from "./resources/consent/consent-resource";
63
67
  export type { ContentResource } from "./resources/content/content-resource";
@@ -4,6 +4,7 @@ import { AccountsResource } from "./resources/accounts/accounts-resource";
4
4
  import { AiResource } from "./resources/ai/ai-resource";
5
5
  import { AuthResource } from "./resources/auth-resource";
6
6
  import { BotsResource } from "./resources/bots/bots-resource";
7
+ import { ChatResource } from "./resources/chat/chat-resource";
7
8
  import { CmsResource } from "./resources/cms/cms-resource";
8
9
  import { ConsentResource } from "./resources/consent/consent-resource";
9
10
  import { ContentResource } from "./resources/content/content-resource";
@@ -91,5 +92,7 @@ export declare class Ovok {
91
92
  readonly push: PushResource;
92
93
  /** The rule that decides who hears of each Signals alert, and its preview. */
93
94
  readonly omnichannelAlerts: OmnichannelAlertsResource;
95
+ /** Chat between patients and their care team. */
96
+ readonly chat: ChatResource;
94
97
  constructor(config: OvokConfig);
95
98
  }
package/dist/next/ovok.js CHANGED
@@ -13,6 +13,7 @@ const accounts_resource_1 = require("./resources/accounts/accounts-resource");
13
13
  const ai_resource_1 = require("./resources/ai/ai-resource");
14
14
  const auth_resource_1 = require("./resources/auth-resource");
15
15
  const bots_resource_1 = require("./resources/bots/bots-resource");
16
+ const chat_resource_1 = require("./resources/chat/chat-resource");
16
17
  const cms_resource_1 = require("./resources/cms/cms-resource");
17
18
  const consent_resource_1 = require("./resources/consent/consent-resource");
18
19
  const content_resource_1 = require("./resources/content/content-resource");
@@ -94,6 +95,7 @@ class Ovok {
94
95
  this.bots = new bots_resource_1.BotsResource(http);
95
96
  this.push = new push_resource_1.PushResource(http);
96
97
  this.omnichannelAlerts = new omnichannel_alerts_resource_1.OmnichannelAlertsResource(http);
98
+ this.chat = new chat_resource_1.ChatResource(http, this.session, settings);
97
99
  }
98
100
  }
99
101
  exports.Ovok = Ovok;
@@ -0,0 +1,26 @@
1
+ import { ScopedLogger } from "../../logging/ovok-logger";
2
+ import { ChatHistory } from "./chat-history";
3
+ import { ChatThreadMessagesResource } from "./chat-messages-resource";
4
+ import { ChatThreadsResource } from "./chat-threads-resource";
5
+ import { ChatMessage, ChatThread } from "./chat-types";
6
+ export type ChatCatchUpDependencies = {
7
+ threads: ChatThreadsResource;
8
+ messages: ChatThreadMessagesResource;
9
+ history: ChatHistory;
10
+ logger: ScopedLogger;
11
+ receiveThread: (thread: ChatThread) => void;
12
+ receiveMessage: (message: ChatMessage) => void;
13
+ };
14
+ /** Delivery on the socket is at-most-once, so what changed while it was down is read back from the REST routes. */
15
+ export declare class ChatCatchUp {
16
+ private readonly deps;
17
+ private pendingFrom;
18
+ private running;
19
+ constructor(deps: ChatCatchUpDependencies);
20
+ /** Runs one catch-up after any still running; a failed one starts from the same point next time. */
21
+ run(): Promise<void>;
22
+ reset(): void;
23
+ private catchUp;
24
+ /** The server pages newest first; missed messages are delivered oldest first. */
25
+ private catchUpThread;
26
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatCatchUp = void 0;
4
+ /** Delivery on the socket is at-most-once, so what changed while it was down is read back from the REST routes. */
5
+ class ChatCatchUp {
6
+ constructor(deps) {
7
+ this.deps = deps;
8
+ this.pendingFrom = null;
9
+ this.running = Promise.resolve();
10
+ }
11
+ /** Runs one catch-up after any still running; a failed one starts from the same point next time. */
12
+ run() {
13
+ this.running = this.running.then(() => this.catchUp());
14
+ return this.running;
15
+ }
16
+ reset() {
17
+ this.pendingFrom = null;
18
+ }
19
+ async catchUp() {
20
+ var _a;
21
+ const from = (_a = this.pendingFrom) !== null && _a !== void 0 ? _a : this.deps.history.watermark;
22
+ if (from === null) {
23
+ return;
24
+ }
25
+ this.pendingFrom = from;
26
+ try {
27
+ for await (const thread of this.deps.threads.list({ updatedSince: from })) {
28
+ this.deps.receiveThread(thread);
29
+ await this.catchUpThread(thread.id, from);
30
+ }
31
+ this.pendingFrom = null;
32
+ }
33
+ catch (error) {
34
+ this.deps.logger.warn("chat.catch_up.failed", { error: error instanceof Error ? error.name : "unknown" });
35
+ }
36
+ }
37
+ /** The server pages newest first; missed messages are delivered oldest first. */
38
+ async catchUpThread(threadId, since) {
39
+ const missed = [];
40
+ for await (const message of this.deps.messages.list(threadId, { since })) {
41
+ missed.push(message);
42
+ }
43
+ missed.reverse().forEach(this.deps.receiveMessage);
44
+ }
45
+ }
46
+ exports.ChatCatchUp = ChatCatchUp;
@@ -0,0 +1,51 @@
1
+ import type { ManagerOptions, Socket, SocketOptions } from "socket.io-client";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { ScopedLogger } from "../../logging/ovok-logger";
4
+ import { SessionResource } from "../session/session-resource";
5
+ import { ChatHistory } from "./chat-history";
6
+ import { ChatThreadMessagesResource } from "./chat-messages-resource";
7
+ import { ChatThreadsResource } from "./chat-threads-resource";
8
+ import { ChatEventHandler, ChatStopListening } from "./chat-types";
9
+ export type OpenSocket = (url: string, options: Partial<ManagerOptions & SocketOptions>) => Socket;
10
+ export type ChatConnectionDependencies = {
11
+ http: HttpClient;
12
+ session: SessionResource;
13
+ baseUrl: string;
14
+ threads: ChatThreadsResource;
15
+ messages: ChatThreadMessagesResource;
16
+ history: ChatHistory;
17
+ logger: ScopedLogger;
18
+ openSocket: OpenSocket;
19
+ };
20
+ /** One `/events` socket shared by every `listen` of a client, open while at least one listener is left. */
21
+ export declare class ChatConnection {
22
+ private readonly deps;
23
+ private readonly handlers;
24
+ private readonly catchUp;
25
+ private socket;
26
+ private ready;
27
+ private start;
28
+ private profile;
29
+ private stopWatchingSession;
30
+ private retryTimer;
31
+ private retries;
32
+ constructor(deps: ChatConnectionDependencies);
33
+ listen(handler: ChatEventHandler): Promise<ChatStopListening>;
34
+ private remove;
35
+ private open;
36
+ private connect;
37
+ private newSocket;
38
+ /** Every connection attempt spends a fresh single-use ticket, so the access token never travels on the socket. */
39
+ private sendTicket;
40
+ private subscribe;
41
+ /** A connection that came up but cannot be used is closed, so `reconnectLater` takes over from socket.io. */
42
+ private failed;
43
+ private connectFailed;
44
+ /** socket.io reconnects a dropped connection itself; a refused ticket or subscription needs a new attempt. */
45
+ private reconnectLater;
46
+ private receiveMessage;
47
+ private receiveThread;
48
+ private emit;
49
+ private signedOut;
50
+ private close;
51
+ }
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatConnection = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const chat_catch_up_1 = require("./chat-catch-up");
6
+ const chat_errors_1 = require("./chat-errors");
7
+ const chat_history_1 = require("./chat-history");
8
+ const EVENTS_NAMESPACE = "/events";
9
+ const TICKET_PATH = "v1/events/ticket";
10
+ const CHAT_TOPIC = "chat";
11
+ const SUBSCRIBE_TIMEOUT_MS = 10000;
12
+ const RECONNECT_DELAY_MS = 1000;
13
+ const RECONNECT_DELAY_MAX_MS = 30000;
14
+ const RECONNECT_JITTER = 0.5;
15
+ const reconnectDelay = (attempt) => {
16
+ const jitter = 1 + RECONNECT_JITTER * (Math.random() * 2 - 1);
17
+ return Math.min(RECONNECT_DELAY_MAX_MS, RECONNECT_DELAY_MS * 2 ** attempt) * jitter;
18
+ };
19
+ /** One `/events` socket shared by every `listen` of a client, open while at least one listener is left. */
20
+ class ChatConnection {
21
+ constructor(deps) {
22
+ this.deps = deps;
23
+ this.handlers = new Set();
24
+ this.socket = null;
25
+ this.ready = null;
26
+ this.start = null;
27
+ this.profile = null;
28
+ this.stopWatchingSession = null;
29
+ this.retryTimer = null;
30
+ this.retries = 0;
31
+ this.catchUp = new chat_catch_up_1.ChatCatchUp({
32
+ ...deps,
33
+ receiveThread: (thread) => this.receiveThread(thread),
34
+ receiveMessage: (message) => this.receiveMessage(message),
35
+ });
36
+ }
37
+ async listen(handler) {
38
+ const listener = (event) => handler(event);
39
+ this.handlers.add(listener);
40
+ try {
41
+ await this.open();
42
+ }
43
+ catch (error) {
44
+ this.handlers.delete(listener);
45
+ throw error;
46
+ }
47
+ return async () => this.remove(listener);
48
+ }
49
+ remove(listener) {
50
+ this.handlers.delete(listener);
51
+ if (this.handlers.size === 0) {
52
+ this.close();
53
+ }
54
+ }
55
+ open() {
56
+ var _a;
57
+ (_a = this.ready) !== null && _a !== void 0 ? _a : (this.ready = this.connect().catch((error) => {
58
+ this.close();
59
+ throw error;
60
+ }));
61
+ return this.ready;
62
+ }
63
+ async connect() {
64
+ var _a, _b;
65
+ this.profile = (_b = (_a = (await this.deps.session.current())) === null || _a === void 0 ? void 0 : _a.profile.reference) !== null && _b !== void 0 ? _b : null;
66
+ this.stopWatchingSession = this.deps.session.onChange((session) => {
67
+ var _a;
68
+ if (((_a = session === null || session === void 0 ? void 0 : session.profile.reference) !== null && _a !== void 0 ? _a : null) !== this.profile) {
69
+ this.signedOut();
70
+ }
71
+ });
72
+ return new Promise((resolve, reject) => {
73
+ this.start = { resolve, reject };
74
+ this.socket = this.newSocket();
75
+ this.socket.connect();
76
+ });
77
+ }
78
+ newSocket() {
79
+ const socket = this.deps.openSocket(new URL(EVENTS_NAMESPACE, this.deps.baseUrl).toString(), {
80
+ auth: (send) => this.sendTicket(socket, send),
81
+ autoConnect: false,
82
+ forceNew: true,
83
+ reconnectionDelay: RECONNECT_DELAY_MS,
84
+ reconnectionDelayMax: RECONNECT_DELAY_MAX_MS,
85
+ randomizationFactor: RECONNECT_JITTER,
86
+ });
87
+ socket.on("connect", () => void this.subscribe(socket));
88
+ socket.on("connect_error", (error) => this.connectFailed(socket, error));
89
+ socket.on("disconnect", () => this.reconnectLater(socket));
90
+ socket.on("subscription_ended", () => socket.disconnect());
91
+ socket.on("chat.message", (message) => this.receiveMessage(message));
92
+ socket.on("chat.read", (read) => this.emit({ type: "read", ...read }));
93
+ socket.on("chat.thread", (thread) => this.receiveThread(thread));
94
+ return socket;
95
+ }
96
+ /** Every connection attempt spends a fresh single-use ticket, so the access token never travels on the socket. */
97
+ sendTicket(socket, send) {
98
+ this.deps.http.post(TICKET_PATH).then(({ ticket }) => send({ ticket }), (error) => this.failed(socket, error));
99
+ }
100
+ async subscribe(socket) {
101
+ var _a;
102
+ try {
103
+ const answer = await socket
104
+ .timeout(SUBSCRIBE_TIMEOUT_MS)
105
+ .emitWithAck("subscribe", { topic: CHAT_TOPIC });
106
+ if ("error" in answer) {
107
+ throw (0, chat_errors_1.subscribeRefusal)(answer.error);
108
+ }
109
+ }
110
+ catch (error) {
111
+ this.failed(socket, error);
112
+ return;
113
+ }
114
+ this.retries = 0;
115
+ (_a = this.start) === null || _a === void 0 ? void 0 : _a.resolve();
116
+ await this.catchUp.run();
117
+ }
118
+ /** A connection that came up but cannot be used is closed, so `reconnectLater` takes over from socket.io. */
119
+ failed(socket, error) {
120
+ socket.disconnect();
121
+ this.connectFailed(socket, error);
122
+ }
123
+ connectFailed(socket, error) {
124
+ var _a;
125
+ if (socket !== this.socket) {
126
+ return;
127
+ }
128
+ const failure = (0, chat_errors_1.asOvokError)(error);
129
+ (_a = this.start) === null || _a === void 0 ? void 0 : _a.reject(failure);
130
+ this.deps.logger.warn("chat.listen.failed", { error: failure.name, status: failure.status });
131
+ this.reconnectLater(socket);
132
+ }
133
+ /** socket.io reconnects a dropped connection itself; a refused ticket or subscription needs a new attempt. */
134
+ reconnectLater(socket) {
135
+ if (socket !== this.socket || socket.active || this.retryTimer !== null) {
136
+ return;
137
+ }
138
+ this.retryTimer = setTimeout(() => {
139
+ this.retryTimer = null;
140
+ socket.connect();
141
+ }, reconnectDelay(this.retries));
142
+ this.retries += 1;
143
+ }
144
+ receiveMessage(message) {
145
+ if (this.deps.history.deliver(message)) {
146
+ this.emit({ type: "message", message });
147
+ }
148
+ }
149
+ receiveThread(thread) {
150
+ this.deps.history.observe((0, chat_history_1.activityOf)(thread));
151
+ this.emit({ type: "thread", thread });
152
+ }
153
+ emit(event) {
154
+ for (const handler of [...this.handlers]) {
155
+ try {
156
+ handler(event);
157
+ }
158
+ catch (error) {
159
+ const name = error instanceof Error ? error.name : "unknown";
160
+ this.deps.logger.error("chat.listen.handler_failed", { error: name, event: event.type });
161
+ }
162
+ }
163
+ }
164
+ signedOut() {
165
+ this.handlers.clear();
166
+ this.close();
167
+ this.deps.history.forget();
168
+ }
169
+ close() {
170
+ var _a, _b;
171
+ const socket = this.socket;
172
+ (_a = this.start) === null || _a === void 0 ? void 0 : _a.reject(new ovok_errors_1.OvokConnectionError((0, ovok_errors_1.detailsFor)("Chat stopped listening before it connected.")));
173
+ this.start = null;
174
+ this.socket = null;
175
+ this.ready = null;
176
+ this.retries = 0;
177
+ this.catchUp.reset();
178
+ (_b = this.stopWatchingSession) === null || _b === void 0 ? void 0 : _b.call(this);
179
+ this.stopWatchingSession = null;
180
+ if (this.retryTimer !== null) {
181
+ clearTimeout(this.retryTimer);
182
+ }
183
+ this.retryTimer = null;
184
+ socket === null || socket === void 0 ? void 0 : socket.off();
185
+ socket === null || socket === void 0 ? void 0 : socket.disconnect();
186
+ }
187
+ }
188
+ exports.ChatConnection = ChatConnection;
@@ -0,0 +1,4 @@
1
+ import { OvokError } from "../../errors/ovok-errors";
2
+ /** The `/events` gateway answers a refused `subscribe` with a code instead of a status. */
3
+ export declare const subscribeRefusal: (code: string) => OvokError;
4
+ export declare const asOvokError: (error: unknown) => OvokError;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.asOvokError = exports.subscribeRefusal = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const SUBSCRIBE_REFUSALS = {
6
+ forbidden: ovok_errors_1.OvokPermissionError,
7
+ no_project: ovok_errors_1.OvokPermissionError,
8
+ };
9
+ /** The `/events` gateway answers a refused `subscribe` with a code instead of a status. */
10
+ const subscribeRefusal = (code) => {
11
+ var _a;
12
+ const ErrorClass = (_a = SUBSCRIBE_REFUSALS[code]) !== null && _a !== void 0 ? _a : ovok_errors_1.OvokServiceError;
13
+ return new ErrorClass({ ...(0, ovok_errors_1.detailsFor)(`The chat subscription was refused: ${code}.`), code });
14
+ };
15
+ exports.subscribeRefusal = subscribeRefusal;
16
+ const asOvokError = (error) => error instanceof ovok_errors_1.OvokError ? error : new ovok_errors_1.OvokConnectionError((0, ovok_errors_1.detailsFor)("Could not connect to chat events."), error);
17
+ exports.asOvokError = asOvokError;
@@ -0,0 +1,16 @@
1
+ import type { ChatMessage, ChatThread } from "./chat-types";
2
+ export declare const activityOf: (thread: ChatThread) => string;
3
+ /** The newest server time this client has seen in chat, and the messages `listen` has already delivered. */
4
+ export declare class ChatHistory {
5
+ private newest;
6
+ private readonly delivered;
7
+ get watermark(): string | null;
8
+ /** A read during a gap must not move the watermark past messages the gap hid, so reads only set the first one. */
9
+ seed(times: string[]): void;
10
+ observe(time: string): void;
11
+ /** Records the message as delivered; false when it already was. */
12
+ deliver(message: ChatMessage): boolean;
13
+ forget(): void;
14
+ /** Only recent ids matter: a catch-up re-reads just the messages after the watermark. */
15
+ private forgetOldest;
16
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatHistory = exports.activityOf = void 0;
4
+ const REMEMBERED_MESSAGES = 1000;
5
+ const isLater = (time, than) => Date.parse(time) > Date.parse(than);
6
+ const activityOf = (thread) => { var _a; return (_a = thread.lastMessageAt) !== null && _a !== void 0 ? _a : thread.createdAt; };
7
+ exports.activityOf = activityOf;
8
+ /** The newest server time this client has seen in chat, and the messages `listen` has already delivered. */
9
+ class ChatHistory {
10
+ constructor() {
11
+ this.newest = null;
12
+ this.delivered = new Set();
13
+ }
14
+ get watermark() {
15
+ return this.newest;
16
+ }
17
+ /** A read during a gap must not move the watermark past messages the gap hid, so reads only set the first one. */
18
+ seed(times) {
19
+ if (this.newest === null) {
20
+ times.forEach((time) => this.observe(time));
21
+ }
22
+ }
23
+ observe(time) {
24
+ if (this.newest === null || isLater(time, this.newest)) {
25
+ this.newest = time;
26
+ }
27
+ }
28
+ /** Records the message as delivered; false when it already was. */
29
+ deliver(message) {
30
+ if (this.delivered.has(message.id)) {
31
+ return false;
32
+ }
33
+ this.delivered.add(message.id);
34
+ this.forgetOldest();
35
+ this.observe(message.sentAt);
36
+ return true;
37
+ }
38
+ forget() {
39
+ this.newest = null;
40
+ this.delivered.clear();
41
+ }
42
+ /** Only recent ids matter: a catch-up re-reads just the messages after the watermark. */
43
+ forgetOldest() {
44
+ if (this.delivered.size > REMEMBERED_MESSAGES) {
45
+ this.delivered.delete(this.delivered.values().next().value);
46
+ }
47
+ }
48
+ }
49
+ exports.ChatHistory = ChatHistory;
@@ -0,0 +1,25 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { RequestOptions } from "../../http/transmit";
3
+ import { PagePromise } from "../../paging/page";
4
+ import { ChatHistory } from "./chat-history";
5
+ import { ChatMessage, ChatMessageListParams, SendChatMessageRequest } from "./chat-types";
6
+ /**
7
+ * Messages in a chat thread.
8
+ *
9
+ * @category chat
10
+ */
11
+ export declare class ChatThreadMessagesResource {
12
+ private readonly chat;
13
+ private readonly history;
14
+ constructor(chat: HttpClient, history: ChatHistory);
15
+ /**
16
+ * Lists a thread's messages, newest first; later pages go further back. Calls
17
+ * `GET v1/chat/threads/{threadId}/messages`.
18
+ */
19
+ list(threadId: string, params?: ChatMessageListParams, options?: RequestOptions): PagePromise<ChatMessage>;
20
+ /**
21
+ * Sends a text message. It carries a client id the server remembers, so a retried send is stored once. Calls
22
+ * `POST v1/chat/threads/{threadId}/messages`.
23
+ */
24
+ send(threadId: string, body: SendChatMessageRequest, options?: RequestOptions): Promise<ChatMessage>;
25
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatThreadMessagesResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const cursor_pages_1 = require("../../paging/cursor-pages");
6
+ const chat_threads_resource_1 = require("./chat-threads-resource");
7
+ const CLIENT_ID_BYTES = 16;
8
+ const messagesPath = (threadId) => `${(0, chat_threads_resource_1.threadPath)(threadId)}/messages`;
9
+ const newClientId = () => Array.from(crypto.getRandomValues(new Uint8Array(CLIENT_ID_BYTES)), (byte) => byte.toString(16).padStart(2, "0"))
10
+ .join("");
11
+ /**
12
+ * Messages in a chat thread.
13
+ *
14
+ * @category chat
15
+ */
16
+ class ChatThreadMessagesResource {
17
+ constructor(chat, history) {
18
+ this.chat = chat;
19
+ this.history = history;
20
+ }
21
+ /**
22
+ * Lists a thread's messages, newest first; later pages go further back. Calls
23
+ * `GET v1/chat/threads/{threadId}/messages`.
24
+ */
25
+ list(threadId, params = {}, options) {
26
+ return (0, cursor_pages_1.cursorPages)(async (cursor) => {
27
+ const page = await this.chat.get(`${messagesPath(threadId)}${(0, url_1.toSearchQuery)({ ...params, cursor })}`, options);
28
+ this.history.seed(page.items.map((message) => message.sentAt));
29
+ return page;
30
+ });
31
+ }
32
+ /**
33
+ * Sends a text message. It carries a client id the server remembers, so a retried send is stored once. Calls
34
+ * `POST v1/chat/threads/{threadId}/messages`.
35
+ */
36
+ async send(threadId, body, options) {
37
+ const message = await this.chat.send({ method: "POST", path: messagesPath(threadId), body: { ...body, clientId: newClientId() }, idempotent: true }, options);
38
+ this.history.seed([message.sentAt]);
39
+ return message;
40
+ }
41
+ }
42
+ exports.ChatThreadMessagesResource = ChatThreadMessagesResource;
@@ -0,0 +1,44 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { RequestOptions } from "../../http/transmit";
3
+ import { OvokLogger } from "../../logging/ovok-logger";
4
+ import { SessionResource } from "../session/session-resource";
5
+ import { OpenSocket } from "./chat-connection";
6
+ import { ChatThreadMessagesResource } from "./chat-messages-resource";
7
+ import { ChatThreadsResource } from "./chat-threads-resource";
8
+ import { ChatEventHandler, ChatReadRequest, ChatStopListening } from "./chat-types";
9
+ /**
10
+ * Where the chat socket connects and logs.
11
+ *
12
+ * @category chat
13
+ */
14
+ export type ChatSettings = {
15
+ /** The API base URL; the socket connects to its origin. */
16
+ baseUrl: string;
17
+ /** Receives structured log entries. */
18
+ logger: OvokLogger;
19
+ };
20
+ /**
21
+ * Person-to-person chat between patients and their care team. Calls routes under `v1/chat`.
22
+ *
23
+ * @category chat
24
+ */
25
+ export declare class ChatResource {
26
+ /** The signed-in person's threads. */
27
+ readonly threads: ChatThreadsResource;
28
+ /** Messages in a thread. */
29
+ readonly messages: ChatThreadMessagesResource;
30
+ private readonly chat;
31
+ private readonly connection;
32
+ constructor(http: HttpClient, session: SessionResource, settings: ChatSettings, openSocket?: OpenSocket);
33
+ /** Marks a thread read by the signed-in person, now or at `readAt`. Calls `POST v1/chat/threads/{threadId}/read`. */
34
+ read(threadId: string, body?: ChatReadRequest, options?: RequestOptions): Promise<void>;
35
+ /**
36
+ * Calls `handler` for each new message, read receipt and new or changed thread of the signed-in person, live over
37
+ * the `/events` socket. One socket serves every `listen` of the client. After each reconnect it reads back what was
38
+ * missed and delivers it once, so a handler sees every message without polling. Listening ends on sign-out.
39
+ *
40
+ * @returns A function that stops this listener.
41
+ * @throws OvokPermissionError when chat is turned off or not allowed, or OvokConnectionError when it cannot connect.
42
+ */
43
+ listen(handler: ChatEventHandler): Promise<ChatStopListening>;
44
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatResource = void 0;
4
+ const socket_io_client_1 = require("socket.io-client");
5
+ const ovok_logger_1 = require("../../logging/ovok-logger");
6
+ const chat_connection_1 = require("./chat-connection");
7
+ const chat_history_1 = require("./chat-history");
8
+ const chat_messages_resource_1 = require("./chat-messages-resource");
9
+ const chat_threads_resource_1 = require("./chat-threads-resource");
10
+ const CHAT_PATH = "v1/chat";
11
+ /**
12
+ * Person-to-person chat between patients and their care team. Calls routes under `v1/chat`.
13
+ *
14
+ * @category chat
15
+ */
16
+ class ChatResource {
17
+ constructor(http, session, settings, openSocket = socket_io_client_1.io) {
18
+ const history = new chat_history_1.ChatHistory();
19
+ this.chat = http.under(CHAT_PATH);
20
+ this.threads = new chat_threads_resource_1.ChatThreadsResource(this.chat, history);
21
+ this.messages = new chat_messages_resource_1.ChatThreadMessagesResource(this.chat, history);
22
+ this.connection = new chat_connection_1.ChatConnection({
23
+ http,
24
+ session,
25
+ baseUrl: settings.baseUrl,
26
+ threads: this.threads,
27
+ messages: this.messages,
28
+ history,
29
+ logger: (0, ovok_logger_1.scopedLogger)(settings.logger, "chat"),
30
+ openSocket,
31
+ });
32
+ }
33
+ /** Marks a thread read by the signed-in person, now or at `readAt`. Calls `POST v1/chat/threads/{threadId}/read`. */
34
+ read(threadId, body = {}, options) {
35
+ return this.chat.post(`${(0, chat_threads_resource_1.threadPath)(threadId)}/read`, body, options);
36
+ }
37
+ /**
38
+ * Calls `handler` for each new message, read receipt and new or changed thread of the signed-in person, live over
39
+ * the `/events` socket. One socket serves every `listen` of the client. After each reconnect it reads back what was
40
+ * missed and delivers it once, so a handler sees every message without polling. Listening ends on sign-out.
41
+ *
42
+ * @returns A function that stops this listener.
43
+ * @throws OvokPermissionError when chat is turned off or not allowed, or OvokConnectionError when it cannot connect.
44
+ */
45
+ listen(handler) {
46
+ return this.connection.listen(handler);
47
+ }
48
+ }
49
+ exports.ChatResource = ChatResource;
@@ -0,0 +1,26 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { RequestOptions } from "../../http/transmit";
3
+ import { PagePromise } from "../../paging/page";
4
+ import { ChatHistory } from "./chat-history";
5
+ import { ChatThread, ChatThreadListParams, OpenChatThreadRequest } from "./chat-types";
6
+ export declare const threadPath: (threadId: string) => string;
7
+ /**
8
+ * The signed-in person's chat threads.
9
+ *
10
+ * @category chat
11
+ */
12
+ export declare class ChatThreadsResource {
13
+ private readonly chat;
14
+ private readonly history;
15
+ constructor(chat: HttpClient, history: ChatHistory);
16
+ /**
17
+ * Opens a thread about a patient, or answers the one these participants already have. Every participant must be
18
+ * allowed to read the patient. Calls `POST v1/chat/threads`.
19
+ */
20
+ open(body: OpenChatThreadRequest, options?: RequestOptions): Promise<ChatThread>;
21
+ /** Lists the signed-in person's threads, newest message first. Calls `GET v1/chat/threads`. */
22
+ list(params?: ChatThreadListParams, options?: RequestOptions): PagePromise<ChatThread>;
23
+ /** Reads one thread. Calls `GET v1/chat/threads/{threadId}`. */
24
+ retrieve(threadId: string, options?: RequestOptions): Promise<ChatThread>;
25
+ private seen;
26
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatThreadsResource = exports.threadPath = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const cursor_pages_1 = require("../../paging/cursor-pages");
6
+ const chat_history_1 = require("./chat-history");
7
+ const THREADS_PATH = "threads";
8
+ const threadPath = (threadId) => `${THREADS_PATH}/${(0, url_1.pathSegment)(threadId)}`;
9
+ exports.threadPath = threadPath;
10
+ /**
11
+ * The signed-in person's chat threads.
12
+ *
13
+ * @category chat
14
+ */
15
+ class ChatThreadsResource {
16
+ constructor(chat, history) {
17
+ this.chat = chat;
18
+ this.history = history;
19
+ }
20
+ /**
21
+ * Opens a thread about a patient, or answers the one these participants already have. Every participant must be
22
+ * allowed to read the patient. Calls `POST v1/chat/threads`.
23
+ */
24
+ async open(body, options) {
25
+ return this.seen(await this.chat.post(THREADS_PATH, body, options));
26
+ }
27
+ /** Lists the signed-in person's threads, newest message first. Calls `GET v1/chat/threads`. */
28
+ list(params = {}, options) {
29
+ return (0, cursor_pages_1.cursorPages)(async (cursor) => {
30
+ const page = await this.chat.get(`${THREADS_PATH}${(0, url_1.toSearchQuery)({ ...params, cursor })}`, options);
31
+ this.history.seed(page.items.map(chat_history_1.activityOf));
32
+ return page;
33
+ });
34
+ }
35
+ /** Reads one thread. Calls `GET v1/chat/threads/{threadId}`. */
36
+ async retrieve(threadId, options) {
37
+ return this.seen(await this.chat.get((0, exports.threadPath)(threadId), options));
38
+ }
39
+ seen(thread) {
40
+ this.history.seed([(0, chat_history_1.activityOf)(thread)]);
41
+ return thread;
42
+ }
43
+ }
44
+ exports.ChatThreadsResource = ChatThreadsResource;
@@ -0,0 +1,157 @@
1
+ import type { OvokReference } from "../../auth/session";
2
+ /**
3
+ * Someone in a chat thread: a patient, practitioner or related person.
4
+ *
5
+ * @category chat
6
+ */
7
+ export type ChatParticipant = OvokReference;
8
+ /**
9
+ * One message in a chat thread.
10
+ *
11
+ * @category chat
12
+ */
13
+ export type ChatMessage = {
14
+ /** The message id. */
15
+ id: string;
16
+ /** The thread the message belongs to. */
17
+ threadId: string;
18
+ /** Who wrote it. */
19
+ sender: ChatParticipant;
20
+ /** The message text. */
21
+ text: string;
22
+ /** When the server accepted it, as an ISO date-time. */
23
+ sentAt: string;
24
+ /** The id of the message it replies to, or null. */
25
+ replyTo: string | null;
26
+ /** The id the sending client gave it, which makes a repeated send safe; null when none was given. */
27
+ clientId: string | null;
28
+ };
29
+ /**
30
+ * When one participant last read a thread.
31
+ *
32
+ * @category chat
33
+ */
34
+ export type ChatRead = {
35
+ /** The participant's reference. */
36
+ participant: string;
37
+ /** When they read it, as an ISO date-time. */
38
+ readAt: string;
39
+ };
40
+ /**
41
+ * A conversation about one patient between the patient and any of their care team.
42
+ *
43
+ * @category chat
44
+ */
45
+ export type ChatThread = {
46
+ /** The thread id. */
47
+ id: string;
48
+ /** The patient the thread is about. */
49
+ patient: ChatParticipant;
50
+ /** Everyone in the thread, the patient included. */
51
+ participants: ChatParticipant[];
52
+ /** The thread title, or null. */
53
+ title: string | null;
54
+ /** Whether new messages can be sent. */
55
+ status: "open" | "closed";
56
+ /** The newest message, or null when there is none yet. */
57
+ lastMessage: ChatMessage | null;
58
+ /** When the newest message was sent, or null when there is none yet. */
59
+ lastMessageAt: string | null;
60
+ /** Messages the signed-in person has not read. */
61
+ unreadCount: number;
62
+ /** When each participant last read the thread. */
63
+ reads: ChatRead[];
64
+ /** When the thread was opened, as an ISO date-time. */
65
+ createdAt: string;
66
+ };
67
+ /**
68
+ * Request body for opening a thread.
69
+ *
70
+ * @category chat
71
+ */
72
+ export type OpenChatThreadRequest = {
73
+ /** The patient the thread is about, as `Patient/<id>`. */
74
+ patient: string;
75
+ /** References of the other participants; the signed-in person is added. */
76
+ participants: string[];
77
+ /** An optional title. */
78
+ title?: string;
79
+ };
80
+ /**
81
+ * Filters for listing threads.
82
+ *
83
+ * @category chat
84
+ */
85
+ export type ChatThreadListParams = {
86
+ /** Only threads about this patient, as `Patient/<id>`. */
87
+ patient?: string;
88
+ /** Only threads changed at or after this ISO date-time. */
89
+ updatedSince?: string;
90
+ /** Threads per page. */
91
+ limit?: number;
92
+ };
93
+ /**
94
+ * Filters for listing messages.
95
+ *
96
+ * @category chat
97
+ */
98
+ export type ChatMessageListParams = {
99
+ /** Only messages sent after this ISO date-time. */
100
+ since?: string;
101
+ /** Messages per page. */
102
+ limit?: number;
103
+ };
104
+ /**
105
+ * Request body for sending a message.
106
+ *
107
+ * @category chat
108
+ */
109
+ export type SendChatMessageRequest = {
110
+ /** The message text. */
111
+ text: string;
112
+ /** The id of the message this one replies to. */
113
+ replyTo?: string;
114
+ };
115
+ /**
116
+ * Request body for marking a thread read.
117
+ *
118
+ * @category chat
119
+ */
120
+ export type ChatReadRequest = {
121
+ /** When the thread was read, as an ISO date-time; the server time when omitted. */
122
+ readAt?: string;
123
+ };
124
+ /**
125
+ * Something that happened in the signed-in person's threads: a message, a read receipt, or a thread that is new or
126
+ * changed.
127
+ *
128
+ * @category chat
129
+ */
130
+ export type ChatEvent = {
131
+ /** A new message, the signed-in person's own included. */
132
+ type: "message";
133
+ /** The message. */
134
+ message: ChatMessage;
135
+ } | ({
136
+ /** A participant read a thread. */
137
+ type: "read";
138
+ /** The thread that was read. */
139
+ threadId: string;
140
+ } & ChatRead) | {
141
+ /** A thread is new or changed. */
142
+ type: "thread";
143
+ /** The thread as it is now. */
144
+ thread: ChatThread;
145
+ };
146
+ /**
147
+ * Receives chat events.
148
+ *
149
+ * @category chat
150
+ */
151
+ export type ChatEventHandler = (event: ChatEvent) => void;
152
+ /**
153
+ * Stops one `listen`; the socket closes once no listener is left.
154
+ *
155
+ * @category chat
156
+ */
157
+ export type ChatStopListening = () => Promise<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,8 @@
1
1
  import { HttpClient } from "../../http/http-client";
2
2
  import { RequestOptions } from "../../http/transmit";
3
3
  /**
4
- * The project's alert notifications rule, as Signals runs it. `logic` is JSON Logic that answers the `notify` steps.
4
+ * The project's alert notifications rule, which Ovok runs on each Signals alert event. `logic` is JSON Logic that
5
+ * answers `notify` entries, each naming `channels` and the roles to tell (`to`).
5
6
  *
6
7
  * @category omnichannelAlerts
7
8
  */
@@ -15,7 +16,7 @@ export type NotificationsRule = {
15
16
  * @category omnichannelAlerts
16
17
  */
17
18
  export type NotificationsRuleResponse = {
18
- /** The rule Signals runs for the project, or null when it has none and nobody is told. */
19
+ /** The rule Ovok runs for the project, or null when it has none and nobody is told. */
19
20
  notifications: Record<string, unknown> | null;
20
21
  };
21
22
  /**
@@ -28,7 +29,7 @@ export declare class NotificationsRulesResource {
28
29
  constructor(omnichannelAlerts: HttpClient);
29
30
  /** Reads the rule. Calls `GET v1/omnichannel-alerts/rules`. */
30
31
  retrieve(options?: RequestOptions): Promise<NotificationsRuleResponse>;
31
- /** Sets the rule; Ovok checks its channels and recipients, then Signals checks its steps. Calls `PUT v1/omnichannel-alerts/rules`. */
32
+ /** Sets the rule; Ovok checks the channels and recipients it names. Calls `PUT v1/omnichannel-alerts/rules`. */
32
33
  update(rule: NotificationsRule, options?: RequestOptions): Promise<NotificationsRuleResponse>;
33
34
  /** Removes the rule, so nobody is told of a new alert. Calls `DELETE v1/omnichannel-alerts/rules`. */
34
35
  remove(options?: RequestOptions): Promise<void>;
@@ -15,7 +15,7 @@ class NotificationsRulesResource {
15
15
  retrieve(options) {
16
16
  return this.omnichannelAlerts.get(RULES_PATH, options);
17
17
  }
18
- /** Sets the rule; Ovok checks its channels and recipients, then Signals checks its steps. Calls `PUT v1/omnichannel-alerts/rules`. */
18
+ /** Sets the rule; Ovok checks the channels and recipients it names. Calls `PUT v1/omnichannel-alerts/rules`. */
19
19
  update(rule, options) {
20
20
  return this.omnichannelAlerts.put(RULES_PATH, rule, options);
21
21
  }
@@ -1,36 +1,44 @@
1
1
  import { HttpClient } from "../../http/http-client";
2
2
  import { RequestOptions } from "../../http/transmit";
3
3
  import { NotificationsRule, NotificationsRulesResource } from "./notifications-rules-resource";
4
+ /**
5
+ * A Signals alert event the rule runs on.
6
+ *
7
+ * @category omnichannelAlerts
8
+ */
9
+ export type OmnichannelAlertEvent = "alert.triggered" | "alert.empty" | "alert.note" | "alert.inactive" | "alert.refired" | "alert.resolved" | "alert.acknowledged";
4
10
  /**
5
11
  * A sample alert to preview the rule against.
6
12
  *
7
13
  * @category omnichannelAlerts
8
14
  */
9
15
  export type NotificationsPreviewAlert = {
10
- /** Why the alert fired; `trigger` when omitted. */
11
- reason?: "trigger" | "empty" | "note" | "inactive";
12
- /** The alert code, such as a LOINC code. */
13
- code?: string;
14
- /** The alert variant, such as `high`. */
15
- variant?: string;
16
+ /** Why the alert was raised; `trigger` when omitted. */
17
+ reason?: string;
18
+ /** The alert code. */
19
+ code?: string | null;
16
20
  /** The alert message. */
17
- message?: string;
21
+ message?: string | null;
22
+ /** The alert value. */
23
+ value?: number | null;
18
24
  };
19
25
  /**
20
- * Request body for previewing who an alert's notifications reach.
26
+ * Request body for previewing who an alert event reaches.
21
27
  *
22
28
  * @category omnichannelAlerts
23
29
  */
24
30
  export type NotificationsPreviewRequest = {
25
31
  /** The FHIR Patient id whose people are resolved. */
26
32
  patientId: string;
33
+ /** The event to try the rule on; `alert.triggered` when omitted. */
34
+ event?: OmnichannelAlertEvent;
27
35
  /** The sample alert. */
28
36
  alert?: NotificationsPreviewAlert;
29
37
  /** The rule to try, instead of the project's own. */
30
38
  notifications?: NotificationsRule;
31
39
  };
32
40
  /**
33
- * A person a preview step reaches.
41
+ * A person a `notify` entry reaches.
34
42
  *
35
43
  * @category omnichannelAlerts
36
44
  */
@@ -43,18 +51,14 @@ export type NotificationsPreviewRecipient = {
43
51
  email: boolean;
44
52
  };
45
53
  /**
46
- * One step the rule plans, and the people it reaches.
54
+ * One `notify` entry the rule answers, and the people it reaches.
47
55
  *
48
56
  * @category omnichannelAlerts
49
57
  */
50
- export type NotificationsPreviewStep = {
51
- /** The step number, from 0. */
52
- step: number;
53
- /** Minutes after the alert fired. */
54
- after: number;
55
- /** The channels the step names. */
58
+ export type NotificationsPreviewNotify = {
59
+ /** The channels the entry names. */
56
60
  channels: string[];
57
- /** The recipient roles the step names. */
61
+ /** The recipient roles the entry names. */
58
62
  to: string[];
59
63
  /** The people the roles resolve to. */
60
64
  recipients: NotificationsPreviewRecipient[];
@@ -64,17 +68,17 @@ export type NotificationsPreviewStep = {
64
68
  unknownRoles: string[];
65
69
  };
66
70
  /**
67
- * Each step the rule plans for a sample alert. Nothing is sent.
71
+ * Who the rule tells of a sample alert event. Nothing is sent.
68
72
  *
69
73
  * @category omnichannelAlerts
70
74
  */
71
75
  export type NotificationsPreviewResponse = {
72
- /** The planned steps. */
73
- steps: NotificationsPreviewStep[];
76
+ /** The `notify` entries the rule answers, empty when it tells nobody. */
77
+ notify: NotificationsPreviewNotify[];
74
78
  };
75
79
  /**
76
- * Omni-channel alerts: Signals generates each alert's notification steps from the project's rule, and Ovok delivers
77
- * them by push and email. Calls routes under `v1/omnichannel-alerts`. For project admins.
80
+ * Omni-channel alerts: Ovok runs the project's rule on each Signals alert event and tells the people it names by push
81
+ * and email. Calls routes under `v1/omnichannel-alerts`. For project admins.
78
82
  *
79
83
  * @category omnichannelAlerts
80
84
  */
@@ -83,6 +87,6 @@ export declare class OmnichannelAlertsResource {
83
87
  readonly rules: NotificationsRulesResource;
84
88
  private readonly omnichannelAlerts;
85
89
  constructor(http: HttpClient);
86
- /** Previews who a sample alert's notifications reach, step by step. Sends nothing. Calls `POST v1/omnichannel-alerts/preview`. */
90
+ /** Previews who the rule tells of a sample alert event. Sends nothing. Calls `POST v1/omnichannel-alerts/preview`. */
87
91
  preview(body: NotificationsPreviewRequest, options?: RequestOptions): Promise<NotificationsPreviewResponse>;
88
92
  }
@@ -5,8 +5,8 @@ const notifications_rules_resource_1 = require("./notifications-rules-resource")
5
5
  const OMNICHANNEL_ALERTS_PATH = "v1/omnichannel-alerts";
6
6
  const PREVIEW_PATH = "preview";
7
7
  /**
8
- * Omni-channel alerts: Signals generates each alert's notification steps from the project's rule, and Ovok delivers
9
- * them by push and email. Calls routes under `v1/omnichannel-alerts`. For project admins.
8
+ * Omni-channel alerts: Ovok runs the project's rule on each Signals alert event and tells the people it names by push
9
+ * and email. Calls routes under `v1/omnichannel-alerts`. For project admins.
10
10
  *
11
11
  * @category omnichannelAlerts
12
12
  */
@@ -15,7 +15,7 @@ class OmnichannelAlertsResource {
15
15
  this.omnichannelAlerts = http.under(OMNICHANNEL_ALERTS_PATH);
16
16
  this.rules = new notifications_rules_resource_1.NotificationsRulesResource(this.omnichannelAlerts);
17
17
  }
18
- /** Previews who a sample alert's notifications reach, step by step. Sends nothing. Calls `POST v1/omnichannel-alerts/preview`. */
18
+ /** Previews who the rule tells of a sample alert event. Sends nothing. Calls `POST v1/omnichannel-alerts/preview`. */
19
19
  preview(body, options) {
20
20
  return this.omnichannelAlerts.post(PREVIEW_PATH, body, options);
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.59-dev.563+fdd295b",
3
+ "version": "0.4.59-dev.565+16c360c",
4
4
  "private": false,
5
5
  "main": "dist/next/index.js",
6
6
  "types": "dist/next/index.d.ts",
@@ -101,6 +101,9 @@
101
101
  "typescript": "^5.3.3",
102
102
  "typescript-eslint": "^8.15.0"
103
103
  },
104
+ "dependencies": {
105
+ "socket.io-client": "^4.8.3"
106
+ },
104
107
  "peerDependencies": {
105
108
  "@medplum/fhirtypes": ">=3.2.22",
106
109
  "react": "*"