@segmentstream/ontology 0.156.0 → 0.156.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/runtime/chat-messages.d.ts +8 -7
- package/dist/runtime/chat-messages.js +11 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.156.1
|
|
4
|
+
|
|
5
|
+
Every reader of a chat in the workspace's chat store now reads only what reached the provider:
|
|
6
|
+
people's messages and the sends the provider took (`sent`, `delivered`, `read`, and one it took
|
|
7
|
+
and later failed, as `failed`). A person reading their own private chat, the agent in their
|
|
8
|
+
session, a group's members and readers with `agent_chat:read` no longer see a staff send still
|
|
9
|
+
`pending` or `uncertain`, a send refused before the provider took it, or the agent's internal
|
|
10
|
+
notes, such as the questions it could not answer, through `chat_history`, `chat_search` or
|
|
11
|
+
`POST /api/ontology/chat/history`, in one chat or across chats. Staff reading a chat the inbox
|
|
12
|
+
registered, and workflows, already read it so. A send appears once the provider takes it, under a
|
|
13
|
+
new revision, so a page polling with `after` receives it then. The agent's logs and figures are
|
|
14
|
+
unchanged.
|
|
15
|
+
|
|
3
16
|
## 0.156.0
|
|
4
17
|
|
|
5
18
|
Staff sends live in the workspace chat store. Once `_chat_messages` holds a message, which means the
|
|
@@ -242,12 +242,13 @@ export interface ChatMessageSearch {
|
|
|
242
242
|
}
|
|
243
243
|
/**
|
|
244
244
|
* Who reads, as the chat archive's reader rule takes it: every group message (`groups`, from
|
|
245
|
-
* `agent_chat:read` or membership of the chat), this exact chat's messages
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
245
|
+
* `agent_chat:read` or membership of the chat), this exact chat's messages (`chat`, a chat the
|
|
246
|
+
* ontology checked the reader may read), and the private messages whose `participants` hold
|
|
247
|
+
* `participantId`, row by row. A search of several chats names, by `<channel>:<chat id>`, the
|
|
248
|
+
* groups the reader is in (`groupChats`), read as `groups` reads every group, and the chats the
|
|
249
|
+
* ontology checked (`chats`), each read as `chat` reads the one searched. Every rule reads only
|
|
250
|
+
* what reached the provider: never an internal row, a send still unsent, or one that failed
|
|
251
|
+
* before the provider took it.
|
|
251
252
|
*/
|
|
252
253
|
export interface ChatMessageReader {
|
|
253
254
|
readonly participantId: string | null;
|
|
@@ -299,7 +300,7 @@ export interface ChatMessageStore {
|
|
|
299
300
|
}) => Effect.Effect<boolean>;
|
|
300
301
|
/** The send an `operation` keys, its tombstone included; `undefined` when the key has none. */
|
|
301
302
|
readonly findSend: (operation: string) => Effect.Effect<ChatSend | undefined>;
|
|
302
|
-
/**
|
|
303
|
+
/** Messages as a reader may read them, row by row: only what reached the provider. */
|
|
303
304
|
readonly search: (search: ChatMessageSearch, reader: ChatMessageReader) => Effect.Effect<ChatMessagePage>;
|
|
304
305
|
/**
|
|
305
306
|
* Deletes the messages older than `retentionDays`, in bounded batches, and scrubs a send's row to
|
|
@@ -583,12 +583,6 @@ export function sqlChatMessageStore(sql) {
|
|
|
583
583
|
if (input.q !== undefined && input.q.trim() !== "") {
|
|
584
584
|
conditions.push(`to_tsvector('simple', coalesce("text", '')) @@ plainto_tsquery('simple', ${params.add(input.q, "text")})`);
|
|
585
585
|
}
|
|
586
|
-
// An exact chat reads what reached the provider: never a send still unsent, nor one that
|
|
587
|
-
// failed before the provider took it. One it took and later failed stays, `failed`, so a
|
|
588
|
-
// reader polling after a revision sees the same chat as one reading it whole.
|
|
589
|
-
const shown = `("direction" = 'inbound' OR ("direction" = 'outbound' AND ` +
|
|
590
|
-
`("status" IS NULL OR "status" IN ('sent', 'delivered', 'read') OR ` +
|
|
591
|
-
`("status" = 'failed' AND "message_id" IS NOT NULL))))`;
|
|
592
586
|
// A row's chat as the reader's lists name it.
|
|
593
587
|
const chatKey = `("channel" || ':' || "chat_id")`;
|
|
594
588
|
const groupChats = reader.groupChats ?? [];
|
|
@@ -599,10 +593,9 @@ export function sqlChatMessageStore(sql) {
|
|
|
599
593
|
...(groupChats.length === 0
|
|
600
594
|
? []
|
|
601
595
|
: [`("chat_type" <> 'private' AND ${chatKey} = ANY(${params.add(groupChats, "text[]")}))`]),
|
|
602
|
-
|
|
603
|
-
...(
|
|
604
|
-
|
|
605
|
-
: [`(${chatKey} = ANY(${params.add(chats, "text[]")}) AND ${shown})`]),
|
|
596
|
+
// The chat searched, which the ontology checked: every message of it.
|
|
597
|
+
...(reader.chat ? ["TRUE"] : []),
|
|
598
|
+
...(chats.length === 0 ? [] : [`${chatKey} = ANY(${params.add(chats, "text[]")})`]),
|
|
606
599
|
...(reader.participantId === null
|
|
607
600
|
? []
|
|
608
601
|
: [
|
|
@@ -614,6 +607,14 @@ export function sqlChatMessageStore(sql) {
|
|
|
614
607
|
return Effect.succeed({ messages: [], nextCursor: null });
|
|
615
608
|
}
|
|
616
609
|
conditions.push(`(${rules.join(" OR ")})`);
|
|
610
|
+
// Every rule reads what reached the provider: never an internal row, a send still unsent, nor
|
|
611
|
+
// one that failed before the provider took it; a send becomes readable under the revision its
|
|
612
|
+
// receipt takes. One the provider took and later failed stays, `failed`, and an echo a send
|
|
613
|
+
// took over stays a change, so a reader polling after a revision sees the same chat as one
|
|
614
|
+
// reading it whole.
|
|
615
|
+
conditions.push(`("direction" = 'inbound' OR "replaced_by" IS NOT NULL OR ("direction" = 'outbound' AND ` +
|
|
616
|
+
`("status" IS NULL OR "status" IN ('sent', 'delivered', 'read') OR ` +
|
|
617
|
+
`("status" = 'failed' AND "message_id" IS NOT NULL))))`);
|
|
617
618
|
return page(conditions, params, input);
|
|
618
619
|
};
|
|
619
620
|
const holds = (chat) => rows(chat === undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.156.
|
|
3
|
+
"version": "0.156.1",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|