@wirecat/cli-core 0.351.0 → 0.352.0
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
CHANGED
|
@@ -7,6 +7,27 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.352.0 — 19.10.2026
|
|
11
|
+
|
|
12
|
+
### Changed — may break callers
|
|
13
|
+
|
|
14
|
+
- **A saved chat keeps its membership when the update leaves it out**: `saveChats`, `Delta.chats` and
|
|
15
|
+
`HistoryBatch.chats` no longer take a "left" mark off a chat that comes without `membershipState`. So a late
|
|
16
|
+
community notice for a group the owner left no longer marks it rejoined. A value sets the membership; `null`
|
|
17
|
+
(newly allowed on `ChatUpdate`) clears it. A page of the adapter's `chats`, complete or not, still rejoins the
|
|
18
|
+
chats it names, through `markChatsLeft` (now also takes the mark off the chats its complete list names) or the new
|
|
19
|
+
`rejoinChats`; other states such as "archived" are kept. A client that saves its own chat list must call
|
|
20
|
+
`rejoinChats(key, ids)` for a list that is not complete, or a chat the owner rejoined stays hidden from stored
|
|
21
|
+
reads until the next complete one. **max-cli must do this in the bump that takes this version**: in
|
|
22
|
+
`rememberChats` (`src/record.ts`), `else await db.chats.rejoinChats(key, ids)`; without it a chat rejoined while
|
|
23
|
+
the session list is cut stays "left", is hidden from `max chats list`, and `archive clear --left` deletes it.
|
|
24
|
+
A caller that learns of a rejoin any other way sends `membershipState: null`.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **`ChatsStore.rejoinChats(key, ids)`** takes the "left" mark off the chats a messenger's chat list names, from any
|
|
29
|
+
page of it, and says how many.
|
|
30
|
+
|
|
10
31
|
## 0.351.0 — 19.10.2026
|
|
11
32
|
|
|
12
33
|
### Added
|
|
@@ -186,8 +186,11 @@ export const stored = (messenger, { account, store, warn, events, pending, annou
|
|
|
186
186
|
const complete = window.offset === 0 && !page.hasMore && page.items.length > 0;
|
|
187
187
|
await save("chats.list", async (opened) => {
|
|
188
188
|
await opened.chats.saveChats(account, page.items);
|
|
189
|
+
const ids = page.items.map((chat) => chat.id);
|
|
189
190
|
if (complete)
|
|
190
|
-
await opened.chats.markChatsLeft(account,
|
|
191
|
+
await opened.chats.markChatsLeft(account, ids);
|
|
192
|
+
else
|
|
193
|
+
await opened.chats.rejoinChats(account, ids);
|
|
191
194
|
});
|
|
192
195
|
return page;
|
|
193
196
|
},
|
package/dist/domain/models.d.ts
CHANGED
|
@@ -47,11 +47,13 @@ export interface Chat {
|
|
|
47
47
|
providerMetadata?: ProviderMetadata;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* A chat as an adapter saves it. A `title`, `unreadCount`, `lastMessageAt` or `
|
|
51
|
-
* stored value; `null` stores none. So a push that knows only some of them, such as a notice that
|
|
52
|
-
* community, leaves the rest out.
|
|
50
|
+
* A chat as an adapter saves it. A `title`, `unreadCount`, `lastMessageAt`, `participantsCount` or `membershipState`
|
|
51
|
+
* left out keeps the stored value; `null` stores none. So a push that knows only some of them, such as a notice that
|
|
52
|
+
* a group left its community, leaves the rest out.
|
|
53
53
|
*/
|
|
54
|
-
export type ChatUpdate = Omit<Chat, KeptFields> & Partial<Pick<Chat, KeptFields
|
|
54
|
+
export type ChatUpdate = Omit<Chat, KeptFields | "membershipState"> & Partial<Pick<Chat, KeptFields>> & {
|
|
55
|
+
membershipState?: MembershipState | null;
|
|
56
|
+
};
|
|
55
57
|
type KeptFields = "title" | "unreadCount" | "lastMessageAt" | "participantsCount";
|
|
56
58
|
/** A group's switches; `null` where the messenger does not say, or has no such switch. */
|
|
57
59
|
export interface GroupSettings {
|
package/dist/store/chats.d.ts
CHANGED
|
@@ -17,11 +17,16 @@ export interface ChatsStore {
|
|
|
17
17
|
/** The chats a person is in, newest first — as far as the saved member lists go. */
|
|
18
18
|
chatsWith(key: AccountKey, memberId: Id): Promise<Chat[]>;
|
|
19
19
|
/**
|
|
20
|
-
* Given every chat the account is in, marks the rest `left
|
|
21
|
-
* ever from a complete list: a page or a cut list says nothing about the chats it leaves out.
|
|
20
|
+
* Given every chat the account is in, marks the rest `left`, takes the mark off those it names, and says how many
|
|
21
|
+
* it marked. Only ever from a complete list: a page or a cut list says nothing about the chats it leaves out.
|
|
22
22
|
* Remembers when, so a search can say the store knows the account's whole chat list.
|
|
23
23
|
*/
|
|
24
24
|
markChatsLeft(key: AccountKey, present: Id[]): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Takes the `left` mark off the chats a messenger's own chat list names, from any page of it: the list holds only
|
|
27
|
+
* chats the account is in. Other states are kept. Says how many it took the mark off.
|
|
28
|
+
*/
|
|
29
|
+
rejoinChats(key: AccountKey, present: Id[]): Promise<number>;
|
|
25
30
|
/**
|
|
26
31
|
* The chat the messenger now names `to` instead of `from`: renamed, or merged into the chat already stored as
|
|
27
32
|
* `to`. Replaying it changes nothing.
|
package/dist/store/chats.js
CHANGED
|
@@ -39,6 +39,10 @@ export const chatsStoreOver = (context) => {
|
|
|
39
39
|
});
|
|
40
40
|
return marked;
|
|
41
41
|
},
|
|
42
|
+
rejoinChats: async (key, present) => {
|
|
43
|
+
const accountKey = findAccountPk(key);
|
|
44
|
+
return accountKey === undefined ? 0 : write(database, () => chatQueries.rejoin(context, accountKey, present));
|
|
45
|
+
},
|
|
42
46
|
rekeyChat: async (key, from, to) => {
|
|
43
47
|
const accountKey = findAccountPk(key);
|
|
44
48
|
if (accountKey === undefined)
|
|
@@ -11,8 +11,13 @@ export declare const upsertChat: (context: StoreContext, accountKey: number, cha
|
|
|
11
11
|
/** Replaces who is in the chat, whole. */
|
|
12
12
|
export declare const writeMembers: (context: StoreContext, key: AccountKey, accountKey: number, chatId: Id, memberIds: Id[]) => void;
|
|
13
13
|
export declare const members: ({ orm }: StoreContext, chatKey: number) => Member[];
|
|
14
|
-
/**
|
|
15
|
-
export declare const
|
|
14
|
+
/** Takes the left mark off the chats `present` names; any other state is kept. Answers how many. */
|
|
15
|
+
export declare const rejoin: ({ orm }: StoreContext, accountKey: number, present: Id[]) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Marks this account's chats that `present` does not name, and rejoins those it names. Only ever given a complete
|
|
18
|
+
* list. Answers how many it marked.
|
|
19
|
+
*/
|
|
20
|
+
export declare const markLeft: (context: StoreContext, accountKey: number, present: Id[]) => number;
|
|
16
21
|
/** The chats marked left, and how many messages they hold. */
|
|
17
22
|
export declare const leftChats: ({ orm }: StoreContext, accountKey: number) => {
|
|
18
23
|
pks: number[];
|
|
@@ -65,9 +65,7 @@ export const upsertChat = (context, accountKey, chat) => {
|
|
|
65
65
|
...(chat.lastMessageAt === undefined ? {} : { lastMessageAt: sql `excluded.last_message_at` }),
|
|
66
66
|
...(chat.participantsCount === undefined ? {} : { participantsCount: sql `excluded.participants_count` }),
|
|
67
67
|
metadata: sql `excluded.metadata`,
|
|
68
|
-
|
|
69
|
-
membershipState: sql `CASE WHEN excluded.membership_state IS NOT NULL THEN excluded.membership_state
|
|
70
|
-
WHEN ${chats.membershipState} = 'left' THEN NULL ELSE ${chats.membershipState} END`,
|
|
68
|
+
...(chat.membershipState === undefined ? {} : { membershipState: sql `excluded.membership_state` }),
|
|
71
69
|
updatedAt: sql `excluded.updated_at`,
|
|
72
70
|
},
|
|
73
71
|
})
|
|
@@ -113,13 +111,27 @@ export const members = ({ orm }, chatKey) => orm
|
|
|
113
111
|
.all();
|
|
114
112
|
const byRecency = [sql `${chats.lastMessageAt} DESC NULLS LAST`, chats.id];
|
|
115
113
|
const notLeft = sql `${chats.membershipState} IS NOT 'left'`;
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
const named = (present) => sql `${chats.externalId} IN (SELECT value FROM json_each(${JSON.stringify(present)}))`;
|
|
115
|
+
/** Takes the left mark off the chats `present` names; any other state is kept. Answers how many. */
|
|
116
|
+
export const rejoin = ({ orm }, accountKey, present) => orm
|
|
118
117
|
.update(chats)
|
|
119
|
-
.set({ membershipState:
|
|
120
|
-
.where(and(eq(chats.accountId, accountKey),
|
|
118
|
+
.set({ membershipState: null })
|
|
119
|
+
.where(and(eq(chats.accountId, accountKey), eq(chats.membershipState, "left"), named(present)))
|
|
121
120
|
.returning({ pk: chats.id })
|
|
122
121
|
.all().length;
|
|
122
|
+
/**
|
|
123
|
+
* Marks this account's chats that `present` does not name, and rejoins those it names. Only ever given a complete
|
|
124
|
+
* list. Answers how many it marked.
|
|
125
|
+
*/
|
|
126
|
+
export const markLeft = (context, accountKey, present) => {
|
|
127
|
+
rejoin(context, accountKey, present);
|
|
128
|
+
return context.orm
|
|
129
|
+
.update(chats)
|
|
130
|
+
.set({ membershipState: "left" })
|
|
131
|
+
.where(and(eq(chats.accountId, accountKey), notLeft, sql `NOT (${named(present)})`))
|
|
132
|
+
.returning({ pk: chats.id })
|
|
133
|
+
.all().length;
|
|
134
|
+
};
|
|
123
135
|
/** The chats marked left, and how many messages they hold. */
|
|
124
136
|
export const leftChats = ({ orm }, accountKey) => {
|
|
125
137
|
const pks = orm
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.352.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|