@marktiderman/genesis-chat 0.10.2 → 0.11.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/README.md +26 -0
- package/dist/index.d.ts +37 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/__tests__/conversation-inbox.test.ts +53 -0
- package/src/core/inbox.ts +50 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -38,6 +38,32 @@ for your own attachment kinds, `composerAccessory`). Mount a Genesis `<Toaster /
|
|
|
38
38
|
(`@source "../node_modules/@marktiderman/genesis-chat/dist"`). `createMemoryChatClient` runs it
|
|
39
39
|
all with no backend, for demos, stories and tests.
|
|
40
40
|
|
|
41
|
+
### As a view's inbox
|
|
42
|
+
|
|
43
|
+
A list of conversations an app reads through the data provider (genesis_chat's `inbox` function
|
|
44
|
+
as a source, or a view of its own) can be a Genesis view drawn by `<ResourceView type="inbox">`
|
|
45
|
+
(genesis-ui): the rail of its segments, the conversations, and the open one as the reading pane.
|
|
46
|
+
`conversationInbox({ resolveUser })` says which column is which: the title (a direct
|
|
47
|
+
conversation's is the other member's name, from `resolveUser`), the latest message as the preview,
|
|
48
|
+
its time, and unread above 0. `renderReading` holds the thread. genesis_chat's `inbox` function
|
|
49
|
+
returns at most 50 conversations by default (`p_limit`, 200 at most) and pages by `p_before`, so as
|
|
50
|
+
a provider source it isn't paged or counted past that; read a longer list through a view of the
|
|
51
|
+
app's own.
|
|
52
|
+
|
|
53
|
+
<!-- docs-check: skip -->
|
|
54
|
+
```tsx
|
|
55
|
+
export const conversationsView = defineView(conversationsContract, { inbox: conversationInbox({ resolveUser }), types: ["inbox"] });
|
|
56
|
+
|
|
57
|
+
<ResourceView
|
|
58
|
+
view={conversationsView}
|
|
59
|
+
inbox={{
|
|
60
|
+
selected: conversationId,
|
|
61
|
+
onSelectedChange: setConversationId,
|
|
62
|
+
renderReading: (c) => <ChatThread conversationId={String(c.conversation_id)} resolveUser={resolveUser} />,
|
|
63
|
+
}}
|
|
64
|
+
/>;
|
|
65
|
+
```
|
|
66
|
+
|
|
41
67
|
## The chat dock
|
|
42
68
|
|
|
43
69
|
Conversations that stay open while people move around the app. On a wide screen there are up to
|
package/dist/index.d.ts
CHANGED
|
@@ -97,4 +97,40 @@ declare function isSchedulable(at: Date, now?: Date): boolean;
|
|
|
97
97
|
/** A topic's key from its title: "Week 1: Habits" → "week-1-habits" (at most 120 characters). */
|
|
98
98
|
declare function topicKey(title: string): string;
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
type InboxSourceRow = Record<string, unknown>;
|
|
101
|
+
interface ConversationInboxOptions {
|
|
102
|
+
/** Names a person (the app's people, as ChatThread's `resolveUser`): a direct conversation's title is the other member's name. */
|
|
103
|
+
resolveUser?: (userId: string) => {
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
/** The title of a conversation with no title and no other member to name. Default "Conversation". */
|
|
107
|
+
fallbackTitle?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A list of conversations as a Genesis view's inbox (`<ResourceView type="inbox">`): a plain
|
|
111
|
+
* block an app passes to `defineView` over its conversations (rows shaped like genesis_chat's
|
|
112
|
+
* `inbox` function: `title`, `other_user_id`, `last_message`, `last_message_at`, `unread`), with the
|
|
113
|
+
* open conversation as the reading pane:
|
|
114
|
+
*
|
|
115
|
+
* ```tsx
|
|
116
|
+
* const conversationsView = defineView(conversationsContract, { inbox: conversationInbox({ resolveUser }), types: ["inbox"] });
|
|
117
|
+
* <ResourceView view={conversationsView} inbox={{ renderReading: (c) => <ChatThread conversationId={String(c.conversation_id)} resolveUser={resolveUser} /> }} />
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* A direct conversation has no title of its own (genesis_chat returns null): it is named after the
|
|
121
|
+
* other member through `resolveUser`. The preview is the latest message's text (or what it carries:
|
|
122
|
+
* a photo, a file, a deleted message).
|
|
123
|
+
*
|
|
124
|
+
* genesis_chat's `inbox` function returns at most `p_limit` conversations (50 by default, 200 at
|
|
125
|
+
* most) and pages by `p_before`, not by offset. As a provider source it isn't paged or counted
|
|
126
|
+
* past that cap; for more, read the conversations through a view of the app's own.
|
|
127
|
+
*/
|
|
128
|
+
declare function conversationInbox(options?: ConversationInboxOptions): Readonly<{
|
|
129
|
+
readonly title: (row: InboxSourceRow) => string;
|
|
130
|
+
readonly preview: (row: InboxSourceRow) => string | undefined;
|
|
131
|
+
readonly time: "last_message_at";
|
|
132
|
+
/** genesis_chat's inbox counts what you haven't read (to 99): a row is unread above 0. */
|
|
133
|
+
readonly unread: (row: InboxSourceRow) => boolean;
|
|
134
|
+
}>;
|
|
135
|
+
|
|
136
|
+
export { type AwayLineOptions, ChatAvailability, type ConversationInboxOptions, MAX_RANGES_PER_DAY, type QuickPick, type SnippetPart, WEEKDAYS, Weekday, WorkingHours, awayLine, awaySummary, conversationInbox, extractLinks, hoursSummary, isAway, isHttpsUrl, isSchedulable, isWithinWorkingHours, localClock, minutesOf, namesLine, normalizeHours, scheduleLabel, scheduleQuickPicks, snippetParts, timeZoneLabel, topicKey, untilLabel };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
export { extractLinks, isHttpsUrl, isSchedulable, scheduleLabel, scheduleQuickPicks, snippetParts, topicKey } from './chunk-BJCE5O7V.js';
|
|
2
|
+
import { previewText } from './chunk-ZQFREERR.js';
|
|
2
3
|
export { activityLine, createOutbox, currentActivity, dayLabel, firstUnreadId, itemSender, itemTime, memoryOutboxStore, mergeThread, parseMentions, previewText, releaseObjectUrl, sameDay, startsDay, startsGroup, summarizeReactions, throttle, upsertMessages } from './chunk-ZQFREERR.js';
|
|
3
4
|
export { ALLOWED_EXTENSIONS, CHAT_BUCKET, CHAT_LIMITS, CHAT_SCHEMA, ChatError, MAX_RANGES_PER_DAY, PLAYBACK_RATES, WEEKDAYS, attachmentKindFor, awayLine, awaySummary, conversationTopic, createChatClient, fileExtension, formatDuration, hoursSummary, isAllowedExtension, isAway, isWithinWorkingHours, localClock, minutesOf, namesLine, nextPlaybackRate, normalizeHours, randomId, recordingLimitMs, sendBytes, timeZoneLabel, toAttachment, toAvailability, toLinkPreview, toMessage, toScheduled, toSearchHit, toTopic, untilLabel, userTopic, waveformFromMetering, waveformPeaks } from './chunk-5XYDVUPS.js';
|
|
5
|
+
|
|
6
|
+
// src/core/inbox.ts
|
|
7
|
+
function conversationInbox(options = {}) {
|
|
8
|
+
const fallback = options.fallbackTitle ?? "Conversation";
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
title: (row) => {
|
|
11
|
+
const own = typeof row["title"] === "string" ? row["title"].trim() : "";
|
|
12
|
+
if (own) return own;
|
|
13
|
+
const other = typeof row["other_user_id"] === "string" ? row["other_user_id"] : void 0;
|
|
14
|
+
return other && options.resolveUser?.(other).name || fallback;
|
|
15
|
+
},
|
|
16
|
+
preview: (row) => {
|
|
17
|
+
const last = row["last_message"];
|
|
18
|
+
if (!last || typeof last !== "object") return void 0;
|
|
19
|
+
const message = last;
|
|
20
|
+
return previewText(typeof message.body === "string" ? message.body : "", typeof message.attachment === "string" ? message.attachment : null, message.deleted === true) || void 0;
|
|
21
|
+
},
|
|
22
|
+
time: "last_message_at",
|
|
23
|
+
/** genesis_chat's inbox counts what you haven't read (to 99): a row is unread above 0. */
|
|
24
|
+
unread: (row) => Number(row["unread"] ?? 0) > 0
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { conversationInbox };
|
|
4
29
|
//# sourceMappingURL=index.js.map
|
|
5
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../src/core/inbox.ts"],"names":[],"mappings":";;;;;;AA8BO,SAAS,iBAAA,CAAkB,OAAA,GAAoC,EAAC,EAAG;AACxE,EAAA,MAAM,QAAA,GAAW,QAAQ,aAAA,IAAiB,cAAA;AAC1C,EAAA,OAAO,OAAO,MAAA,CAAO;AAAA,IACnB,KAAA,EAAO,CAAC,GAAA,KAAwB;AAC9B,MAAA,MAAM,GAAA,GAAM,OAAO,GAAA,CAAI,OAAO,CAAA,KAAM,WAAW,GAAA,CAAI,OAAO,CAAA,CAAE,IAAA,EAAK,GAAI,EAAA;AACrE,MAAA,IAAI,KAAK,OAAO,GAAA;AAChB,MAAA,MAAM,KAAA,GAAQ,OAAO,GAAA,CAAI,eAAe,MAAM,QAAA,GAAW,GAAA,CAAI,eAAe,CAAA,GAAI,MAAA;AAChF,MAAA,OAAQ,KAAA,IAAS,OAAA,CAAQ,WAAA,GAAc,KAAK,EAAE,IAAA,IAAS,QAAA;AAAA,IACzD,CAAA;AAAA,IACA,OAAA,EAAS,CAAC,GAAA,KAAwB;AAChC,MAAA,MAAM,IAAA,GAAO,IAAI,cAAc,CAAA;AAC/B,MAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,UAAU,OAAO,MAAA;AAC9C,MAAA,MAAM,OAAA,GAAU,IAAA;AAChB,MAAA,OAAO,YAAY,OAAO,OAAA,CAAQ,SAAS,QAAA,GAAW,OAAA,CAAQ,OAAO,EAAA,EAAI,OAAO,OAAA,CAAQ,UAAA,KAAe,WAAW,OAAA,CAAQ,UAAA,GAAa,MAAM,OAAA,CAAQ,OAAA,KAAY,IAAI,CAAA,IAAK,MAAA;AAAA,IAC5K,CAAA;AAAA,IACA,IAAA,EAAM,iBAAA;AAAA;AAAA,IAEN,MAAA,EAAQ,CAAC,GAAA,KAAwB,MAAA,CAAO,IAAI,QAAQ,CAAA,IAAK,CAAC,CAAA,GAAI;AAAA,GACtD,CAAA;AACZ","file":"index.js","sourcesContent":["import { previewText } from \"./thread\";\n\ntype InboxSourceRow = Record<string, unknown>;\n\nexport interface ConversationInboxOptions {\n /** Names a person (the app's people, as ChatThread's `resolveUser`): a direct conversation's title is the other member's name. */\n resolveUser?: (userId: string) => { name: string };\n /** The title of a conversation with no title and no other member to name. Default \"Conversation\". */\n fallbackTitle?: string;\n}\n\n/**\n * A list of conversations as a Genesis view's inbox (`<ResourceView type=\"inbox\">`): a plain\n * block an app passes to `defineView` over its conversations (rows shaped like genesis_chat's\n * `inbox` function: `title`, `other_user_id`, `last_message`, `last_message_at`, `unread`), with the\n * open conversation as the reading pane:\n *\n * ```tsx\n * const conversationsView = defineView(conversationsContract, { inbox: conversationInbox({ resolveUser }), types: [\"inbox\"] });\n * <ResourceView view={conversationsView} inbox={{ renderReading: (c) => <ChatThread conversationId={String(c.conversation_id)} resolveUser={resolveUser} /> }} />\n * ```\n *\n * A direct conversation has no title of its own (genesis_chat returns null): it is named after the\n * other member through `resolveUser`. The preview is the latest message's text (or what it carries:\n * a photo, a file, a deleted message).\n *\n * genesis_chat's `inbox` function returns at most `p_limit` conversations (50 by default, 200 at\n * most) and pages by `p_before`, not by offset. As a provider source it isn't paged or counted\n * past that cap; for more, read the conversations through a view of the app's own.\n */\nexport function conversationInbox(options: ConversationInboxOptions = {}) {\n const fallback = options.fallbackTitle ?? \"Conversation\";\n return Object.freeze({\n title: (row: InboxSourceRow) => {\n const own = typeof row[\"title\"] === \"string\" ? row[\"title\"].trim() : \"\";\n if (own) return own;\n const other = typeof row[\"other_user_id\"] === \"string\" ? row[\"other_user_id\"] : undefined;\n return (other && options.resolveUser?.(other).name) || fallback;\n },\n preview: (row: InboxSourceRow) => {\n const last = row[\"last_message\"];\n if (!last || typeof last !== \"object\") return undefined;\n const message = last as { body?: unknown; attachment?: unknown; deleted?: unknown };\n return previewText(typeof message.body === \"string\" ? message.body : \"\", typeof message.attachment === \"string\" ? message.attachment : null, message.deleted === true) || undefined;\n },\n time: \"last_message_at\",\n /** genesis_chat's inbox counts what you haven't read (to 99): a row is unread above 0. */\n unread: (row: InboxSourceRow) => Number(row[\"unread\"] ?? 0) > 0,\n } as const);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marktiderman/genesis-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"README.md"
|
|
87
87
|
],
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@marktiderman/genesis-features": "^0.9.
|
|
89
|
+
"@marktiderman/genesis-features": "^0.9.1",
|
|
90
90
|
"frimousse": "0.4.0"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@marktiderman/genesis-ai": ">=0.1.0 <1.0.0",
|
|
94
94
|
"@marktiderman/genesis-core": ">=2.13.0 <3.0.0",
|
|
95
|
-
"@marktiderman/genesis-ui": ">=2.32.0 <
|
|
95
|
+
"@marktiderman/genesis-ui": ">=2.32.0 <4.0.0",
|
|
96
96
|
"@marktiderman/genesis-ui-native": ">=3.8.0 <4.0.0",
|
|
97
97
|
"@supabase/supabase-js": "^2.118.0",
|
|
98
98
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -173,21 +173,21 @@
|
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
"devDependencies": {
|
|
176
|
-
"@ai-sdk/anthropic": "4.0.
|
|
176
|
+
"@ai-sdk/anthropic": "4.0.98",
|
|
177
177
|
"@marktiderman/genesis-ai": "^0.3.0",
|
|
178
|
-
"@marktiderman/genesis-core": "^2.
|
|
179
|
-
"@marktiderman/genesis-notifications": "^0.4.
|
|
180
|
-
"@marktiderman/genesis-ui": "^
|
|
181
|
-
"@marktiderman/genesis-ui-native": "^3.
|
|
178
|
+
"@marktiderman/genesis-core": "^2.17.0",
|
|
179
|
+
"@marktiderman/genesis-notifications": "^0.4.4",
|
|
180
|
+
"@marktiderman/genesis-ui": "^3.0.0",
|
|
181
|
+
"@marktiderman/genesis-ui-native": "^3.13.0",
|
|
182
182
|
"@supabase/supabase-js": "^2.118.0",
|
|
183
183
|
"@tanstack/react-query": "^5.105.0",
|
|
184
184
|
"@testing-library/react": "^16.3.2",
|
|
185
185
|
"@types/node": "^22",
|
|
186
186
|
"@types/react": "^19.2.14",
|
|
187
187
|
"@types/react-dom": "^19.2.3",
|
|
188
|
-
"ai": "7.0.
|
|
188
|
+
"ai": "7.0.164",
|
|
189
189
|
"happy-dom": "^21.0.4",
|
|
190
|
-
"hls.js": "1.7.
|
|
190
|
+
"hls.js": "1.7.4",
|
|
191
191
|
"lucide-react": "^1.28.0",
|
|
192
192
|
"react": "^19.2.5",
|
|
193
193
|
"react-dom": "^19.2.5",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @feat:view-inbox
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { defineResource } from "@marktiderman/genesis-core";
|
|
4
|
+
import { defineView } from "@marktiderman/genesis-core/resource-view";
|
|
5
|
+
import { conversationInbox } from "../core/inbox";
|
|
6
|
+
|
|
7
|
+
const conversations = defineResource<Record<string, unknown>>()({
|
|
8
|
+
name: "genesis_chat.inbox",
|
|
9
|
+
key: "conversation_id",
|
|
10
|
+
fields: [
|
|
11
|
+
{ name: "conversation_id", type: "string" },
|
|
12
|
+
{ name: "title", type: "string", optional: true },
|
|
13
|
+
{ name: "other_user_id", type: "string", optional: true },
|
|
14
|
+
{ name: "unread", type: "number" },
|
|
15
|
+
{ name: "last_message_at", type: "datetime", optional: true },
|
|
16
|
+
{ name: "last_message", type: "json", optional: true },
|
|
17
|
+
],
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("conversationInbox", () => {
|
|
21
|
+
const view = defineView(conversations, {
|
|
22
|
+
inbox: conversationInbox({ resolveUser: (id) => ({ name: id === "u-2" ? "Sam Rivera" : "Someone" }) }),
|
|
23
|
+
types: ["inbox"],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("names a direct conversation after the other member, and previews the latest message", () => {
|
|
27
|
+
const row = view.inboxRow({
|
|
28
|
+
conversation_id: "c-1",
|
|
29
|
+
title: null,
|
|
30
|
+
other_user_id: "u-2",
|
|
31
|
+
unread: 3,
|
|
32
|
+
last_message_at: "2026-11-01T10:00:00Z",
|
|
33
|
+
last_message: { body: "See you **at nine**", attachment: null, deleted: false },
|
|
34
|
+
});
|
|
35
|
+
expect(row).toMatchObject({ id: "c-1", title: "Sam Rivera", preview: "See you at nine", unread: true, time: "2026-11-01T10:00:00Z" });
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("keeps a group's own title, says what a message without text carries, and falls back", () => {
|
|
39
|
+
expect(view.inboxRow({ conversation_id: "c-2", title: "Launch", unread: 0, last_message: { body: "", attachment: "image" } })).toMatchObject({
|
|
40
|
+
title: "Launch",
|
|
41
|
+
preview: "Photo",
|
|
42
|
+
unread: false,
|
|
43
|
+
});
|
|
44
|
+
expect(view.inboxRow({ conversation_id: "c-3", title: null, unread: 0, last_message: { body: "x", deleted: true } })).toMatchObject({
|
|
45
|
+
title: "Conversation",
|
|
46
|
+
preview: "Message deleted",
|
|
47
|
+
});
|
|
48
|
+
const plain = defineView(conversations, { inbox: conversationInbox({ fallbackTitle: "Chat" }) });
|
|
49
|
+
const row = plain.inboxRow({ conversation_id: "c-4", other_user_id: "u-9", unread: 0, last_message: null });
|
|
50
|
+
expect(row.title).toBe("Chat");
|
|
51
|
+
expect(row.preview).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { previewText } from "./thread";
|
|
2
|
+
|
|
3
|
+
type InboxSourceRow = Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
export interface ConversationInboxOptions {
|
|
6
|
+
/** Names a person (the app's people, as ChatThread's `resolveUser`): a direct conversation's title is the other member's name. */
|
|
7
|
+
resolveUser?: (userId: string) => { name: string };
|
|
8
|
+
/** The title of a conversation with no title and no other member to name. Default "Conversation". */
|
|
9
|
+
fallbackTitle?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A list of conversations as a Genesis view's inbox (`<ResourceView type="inbox">`): a plain
|
|
14
|
+
* block an app passes to `defineView` over its conversations (rows shaped like genesis_chat's
|
|
15
|
+
* `inbox` function: `title`, `other_user_id`, `last_message`, `last_message_at`, `unread`), with the
|
|
16
|
+
* open conversation as the reading pane:
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const conversationsView = defineView(conversationsContract, { inbox: conversationInbox({ resolveUser }), types: ["inbox"] });
|
|
20
|
+
* <ResourceView view={conversationsView} inbox={{ renderReading: (c) => <ChatThread conversationId={String(c.conversation_id)} resolveUser={resolveUser} /> }} />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* A direct conversation has no title of its own (genesis_chat returns null): it is named after the
|
|
24
|
+
* other member through `resolveUser`. The preview is the latest message's text (or what it carries:
|
|
25
|
+
* a photo, a file, a deleted message).
|
|
26
|
+
*
|
|
27
|
+
* genesis_chat's `inbox` function returns at most `p_limit` conversations (50 by default, 200 at
|
|
28
|
+
* most) and pages by `p_before`, not by offset. As a provider source it isn't paged or counted
|
|
29
|
+
* past that cap; for more, read the conversations through a view of the app's own.
|
|
30
|
+
*/
|
|
31
|
+
export function conversationInbox(options: ConversationInboxOptions = {}) {
|
|
32
|
+
const fallback = options.fallbackTitle ?? "Conversation";
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
title: (row: InboxSourceRow) => {
|
|
35
|
+
const own = typeof row["title"] === "string" ? row["title"].trim() : "";
|
|
36
|
+
if (own) return own;
|
|
37
|
+
const other = typeof row["other_user_id"] === "string" ? row["other_user_id"] : undefined;
|
|
38
|
+
return (other && options.resolveUser?.(other).name) || fallback;
|
|
39
|
+
},
|
|
40
|
+
preview: (row: InboxSourceRow) => {
|
|
41
|
+
const last = row["last_message"];
|
|
42
|
+
if (!last || typeof last !== "object") return undefined;
|
|
43
|
+
const message = last as { body?: unknown; attachment?: unknown; deleted?: unknown };
|
|
44
|
+
return previewText(typeof message.body === "string" ? message.body : "", typeof message.attachment === "string" ? message.attachment : null, message.deleted === true) || undefined;
|
|
45
|
+
},
|
|
46
|
+
time: "last_message_at",
|
|
47
|
+
/** genesis_chat's inbox counts what you haven't read (to 99): a row is unread above 0. */
|
|
48
|
+
unread: (row: InboxSourceRow) => Number(row["unread"] ?? 0) > 0,
|
|
49
|
+
} as const);
|
|
50
|
+
}
|
package/src/index.ts
CHANGED