@wirecat/cli-core 0.652.0 → 0.653.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 +16 -0
- package/dist/domain/providers.js +3 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.js +1 -0
- package/dist/mail/meeting-notes.d.ts +50 -0
- package/dist/mail/meeting-notes.js +198 -0
- package/dist/mail/rule-input.d.ts +1 -0
- package/dist/mail/rule-input.js +1 -0
- package/dist/mail/rule-stored.js +2 -0
- package/dist/mail/rules.d.ts +2 -0
- package/dist/mail/sync-types.d.ts +3 -0
- package/dist/mail/sync.js +12 -0
- package/dist/meetings/events.d.ts +3 -1
- package/dist/meetings/events.js +3 -1
- package/dist/meetings/pull.js +1 -1
- package/dist/meetings/source.d.ts +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.653.0 — 13.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Mail can be a meeting's notes.** A mail rule's `meeting_notes: "<provider>"` saves each email it matches as a
|
|
13
|
+
meeting of that provider too, in the account named by the mailbox's address, once at the end of every mail sync;
|
|
14
|
+
`saveMeetingNotes(store, address, rules, { since })` reads mail stored earlier the same way, and a provider that
|
|
15
|
+
fails is a warning, never a failed sync. The first provider is `telemost`: Yandex Telemost mails its notes from
|
|
16
|
+
`keeper@telemost.yandex.ru` (`MEETING_NOTES`). The notes give the day, not the hours, so the meeting takes its times
|
|
17
|
+
from the event it is linked to, or from the owner's one calendar entry in the same room that day (in Moscow's zone
|
|
18
|
+
or the computer's); otherwise it starts at the day's start with `metadata.time_precision: "day"`, and no event is
|
|
19
|
+
made for it. The saved notes are cleaned as calendar text is: links without their queries, passcode lines dropped.
|
|
20
|
+
- **`MeetingSource.createsEvents: false`** links a source's meetings to an event the owner already has and never
|
|
21
|
+
makes one; `linkEvent` takes `{ create: false }` for it.
|
|
22
|
+
- **`telemost` is a provider** (kind `meetings`).
|
|
23
|
+
|
|
8
24
|
## 0.652.0 — 13.11.2026
|
|
9
25
|
|
|
10
26
|
### Added
|
package/dist/domain/providers.js
CHANGED
|
@@ -19,6 +19,8 @@ export const PROVIDERS = [
|
|
|
19
19
|
{ name: "obsidian", kind: "notes", aliases: [] },
|
|
20
20
|
{ name: "added", kind: "notes", aliases: [] },
|
|
21
21
|
{ name: "zoom", kind: "meetings", aliases: [] },
|
|
22
|
+
// Its meetings come from the notes Telemost mails (`keeper@telemost.yandex.ru`), read by a mail rule.
|
|
23
|
+
{ name: "telemost", kind: "meetings", aliases: [] },
|
|
22
24
|
// A phone export's records: its SMS and its calls in the one account the import names.
|
|
23
25
|
{ name: "phone", kind: "messages", kinds: ["messages", "events"], aliases: [], imported: true },
|
|
24
26
|
// Any other import: a folder of notes, a CRM's export, a script's records, under `import:<what it is>`.
|
|
@@ -34,6 +36,7 @@ const LABELS = {
|
|
|
34
36
|
"google-drive": "Google Drive",
|
|
35
37
|
added: "added by hand",
|
|
36
38
|
email: "mail",
|
|
39
|
+
telemost: "Telemost",
|
|
37
40
|
};
|
|
38
41
|
/** How a text names a provider to a person: `MAX`, not `max`. */
|
|
39
42
|
export const providerLabel = (provider) => LABELS[provider] ?? provider;
|
package/dist/mail/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { type AuthVerdicts, HEADER_FIELDS, headersOf, type MailHeaders, mailHead
|
|
|
10
10
|
export { type MailIdsInput, mailIds } from "./ids.js";
|
|
11
11
|
export { decodedLabelName, decodeMailboxName, labelName, systemLabel } from "./labels.js";
|
|
12
12
|
export { acknowledgeMark, advancePastSkipped, type BulkExcerpt, cursorOf, HOLD_PARTIAL_MS, HOLDER, MARK_BATCH, type MailMark, type MailWaiting, type MarkedHit, type MarkRead, type MarkRewind, mailWaiting, markOf, marksOf, type RewoundMark, readPastMark, rewindMark, type SkipReason, } from "./marks.js";
|
|
13
|
+
export { MEETING_NOTES, MEETING_NOTES_PROVIDERS, mailMeetingSource, notesOf, saveMeetingNotes, } from "./meeting-notes.js";
|
|
13
14
|
export { BULK_TRIAGE_DEFAULTS, type BulkSorted, type BulkTriage, excerptOf, NEWSLETTER_DEFAULTS, NEWSLETTER_SENDERS, NEWSLETTER_WORDS, type NewsletterCues, newsletterSorter, ORDER_WORDS, } from "./newsletter.js";
|
|
14
15
|
export { type MailTurn, mailTurn } from "./owed.js";
|
|
15
16
|
export { type Address, htmlToText, looksLikeHtml, MAX_ATTACHMENTS, MAX_BODY_CHARS, type ParsedMail, parseMail, } from "./parse.js";
|
package/dist/mail/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { HEADER_FIELDS, headersOf, mailHeadersOf } from "./headers.js";
|
|
|
10
10
|
export { mailIds } from "./ids.js";
|
|
11
11
|
export { decodedLabelName, decodeMailboxName, labelName, systemLabel } from "./labels.js";
|
|
12
12
|
export { acknowledgeMark, advancePastSkipped, cursorOf, HOLD_PARTIAL_MS, HOLDER, MARK_BATCH, mailWaiting, markOf, marksOf, readPastMark, rewindMark, } from "./marks.js";
|
|
13
|
+
export { MEETING_NOTES, MEETING_NOTES_PROVIDERS, mailMeetingSource, notesOf, saveMeetingNotes, } from "./meeting-notes.js";
|
|
13
14
|
export { BULK_TRIAGE_DEFAULTS, excerptOf, NEWSLETTER_DEFAULTS, NEWSLETTER_SENDERS, NEWSLETTER_WORDS, newsletterSorter, ORDER_WORDS, } from "./newsletter.js";
|
|
14
15
|
export { mailTurn } from "./owed.js";
|
|
15
16
|
export { htmlToText, looksLikeHtml, MAX_ATTACHMENTS, MAX_BODY_CHARS, parseMail, } from "./parse.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type MeetingSource, type MeetingStore, type RunReport, type SummaryContent } from "../meetings/index.js";
|
|
2
|
+
import type { MessageStore } from "../store/index.js";
|
|
3
|
+
import { type MailRule } from "./rules.js";
|
|
4
|
+
interface NotesKind {
|
|
5
|
+
/** Who mails them: what `rules add --meeting-notes <provider>` matches when no sender is given. */
|
|
6
|
+
senders: readonly string[];
|
|
7
|
+
/** The meeting's day, from the subject; null when the subject does not say. */
|
|
8
|
+
day(subject: string): {
|
|
9
|
+
year: number;
|
|
10
|
+
month: number;
|
|
11
|
+
day: number;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* The UTC offsets, in hours, the subject's day may be written in. The day window spans all of them and the
|
|
15
|
+
* computer's own zone, so a meeting just after midnight in one is still found.
|
|
16
|
+
*/
|
|
17
|
+
offsets: readonly number[];
|
|
18
|
+
/** The headings the notes are split under, in the case they are written. */
|
|
19
|
+
headings: readonly string[];
|
|
20
|
+
overview: string;
|
|
21
|
+
}
|
|
22
|
+
/** The meeting-notes mail each provider sends. A provider not here cannot be named by a rule. */
|
|
23
|
+
export declare const MEETING_NOTES: Readonly<Record<string, NotesKind>>;
|
|
24
|
+
export declare const MEETING_NOTES_PROVIDERS: string[];
|
|
25
|
+
/** The notes cut at their headings; text before the first heading stays only in `content`. */
|
|
26
|
+
export declare const notesOf: (text: string, kind: Pick<NotesKind, "headings" | "overview">) => SummaryContent;
|
|
27
|
+
/**
|
|
28
|
+
* Meetings read from stored mail a meeting-notes rule matches, for `pull`. The notes give the day, not the hours:
|
|
29
|
+
* the event the meeting is already linked to, or the one event in the same room that day, gives its times; otherwise
|
|
30
|
+
* it starts at the day's start, says so in `metadata.time_precision`, and no event is made for it.
|
|
31
|
+
*/
|
|
32
|
+
export declare const mailMeetingSource: ({ store, meetings, address, rules, provider, accountId, }: {
|
|
33
|
+
store: MessageStore;
|
|
34
|
+
meetings: Pick<MeetingStore, "eventCandidates" | "meetings" | "events">;
|
|
35
|
+
address: string;
|
|
36
|
+
rules: readonly MailRule[];
|
|
37
|
+
provider: string;
|
|
38
|
+
/** The provider's account the meetings are saved in; absent before its first save. */
|
|
39
|
+
accountId?: number;
|
|
40
|
+
}) => MeetingSource;
|
|
41
|
+
/**
|
|
42
|
+
* Saves as meetings the stored mail each meeting-notes rule matches, from `since`, into the provider's account named
|
|
43
|
+
* by the mailbox's address. Mail stored before the rule was made is read the same way, with an early `since`. A
|
|
44
|
+
* provider that fails is a warning in its report: the mail it was read from is already saved.
|
|
45
|
+
*/
|
|
46
|
+
export declare const saveMeetingNotes: (store: MessageStore, address: string, rules: readonly MailRule[], { since, now }: {
|
|
47
|
+
since: string;
|
|
48
|
+
now?: number;
|
|
49
|
+
}) => Promise<Record<string, RunReport>>;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { calendarText, joinKeyOf, pull, } from "../meetings/index.js";
|
|
3
|
+
import { mailAccountKey } from "./account-key.js";
|
|
4
|
+
import { factsOf } from "./facts.js";
|
|
5
|
+
import { matches } from "./rules.js";
|
|
6
|
+
import { listedOf } from "./stored.js";
|
|
7
|
+
const HOUR_MS = 3_600_000;
|
|
8
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
9
|
+
/** The meeting-notes mail each provider sends. A provider not here cannot be named by a rule. */
|
|
10
|
+
export const MEETING_NOTES = {
|
|
11
|
+
telemost: {
|
|
12
|
+
senders: ["keeper@telemost.yandex.ru"],
|
|
13
|
+
day: (subject) => {
|
|
14
|
+
const found = /(\d{2})\.(\d{2})\.(\d{4})/u.exec(subject);
|
|
15
|
+
return found ? { day: Number(found[1]), month: Number(found[2]), year: Number(found[3]) } : null;
|
|
16
|
+
},
|
|
17
|
+
// Moscow, Yandex's default; the zone of the owner's Yandex account is not known here.
|
|
18
|
+
offsets: [3],
|
|
19
|
+
headings: ["Итоги", "Что обсудили", "Задачи", "Открытые вопросы", "Следующая встреча"],
|
|
20
|
+
overview: "Итоги",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export const MEETING_NOTES_PROVIDERS = Object.keys(MEETING_NOTES);
|
|
24
|
+
const LINK = /https?:\/\/[^\s<>"')\]]+/giu;
|
|
25
|
+
const textOf = (email) => calendarText(email.bodyText?.trim() ? email.bodyText : email.bodyHtml)?.replace(/\r\n?/gu, "\n") ?? "";
|
|
26
|
+
const headingOf = (line, headings) => {
|
|
27
|
+
const plain = line
|
|
28
|
+
.replace(/^(?:[\s#*>-]|\p{Extended_Pictographic}|️)+/u, "")
|
|
29
|
+
.replace(/[\s:*]+$/u, "")
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
return headings.find((heading) => heading.toLowerCase() === plain);
|
|
32
|
+
};
|
|
33
|
+
/** The notes cut at their headings; text before the first heading stays only in `content`. */
|
|
34
|
+
export const notesOf = (text, kind) => {
|
|
35
|
+
const parts = [];
|
|
36
|
+
for (const line of text.split("\n")) {
|
|
37
|
+
const heading = headingOf(line, kind.headings);
|
|
38
|
+
if (heading !== undefined)
|
|
39
|
+
parts.push({ label: heading, lines: [] });
|
|
40
|
+
else
|
|
41
|
+
parts.at(-1)?.lines.push(line);
|
|
42
|
+
}
|
|
43
|
+
const sections = parts
|
|
44
|
+
.map(({ label, lines }) => ({ label, text: lines.join("\n").trim() }))
|
|
45
|
+
.filter(({ text }) => text !== "");
|
|
46
|
+
return {
|
|
47
|
+
title: null,
|
|
48
|
+
overview: sections.find(({ label }) => label === kind.overview)?.text ?? null,
|
|
49
|
+
sections: sections.filter(({ label }) => label !== kind.overview),
|
|
50
|
+
nextSteps: [],
|
|
51
|
+
content: text.trim() || null,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** The first link in the notes that names a meeting room, as `joinKeyOf` reads it: never a plain page link. */
|
|
55
|
+
const roomOf = (text) => {
|
|
56
|
+
for (const [url] of text.matchAll(LINK))
|
|
57
|
+
if (/\/j\/[^/]+$/u.test(url) && joinKeyOf(url))
|
|
58
|
+
return url;
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
/** The day as a window: from its first midnight in any of the zones to its last. */
|
|
62
|
+
const dayWindow = (kind, date) => {
|
|
63
|
+
const local = new Date(date.year, date.month - 1, date.day).getTime();
|
|
64
|
+
const utc = Date.UTC(date.year, date.month - 1, date.day);
|
|
65
|
+
const starts = [local, ...kind.offsets.map((offset) => utc - offset * HOUR_MS)];
|
|
66
|
+
const start = starts.reduce((low, at) => Math.min(low, at));
|
|
67
|
+
const end = starts.reduce((high, at) => Math.max(high, at)) + DAY_MS;
|
|
68
|
+
return { start, end, local };
|
|
69
|
+
};
|
|
70
|
+
/** The stored mail the rules can be matching: by sender when every rule names one, else the whole window. */
|
|
71
|
+
const candidateFacts = async (store, accountId, since, rules) => {
|
|
72
|
+
const senders = rules.map(({ match }) => match.from);
|
|
73
|
+
if (senders.some((sender) => sender === undefined))
|
|
74
|
+
return store.mail.emailFacts({ accountId, since });
|
|
75
|
+
const found = new Map();
|
|
76
|
+
for (const sender of new Set(senders))
|
|
77
|
+
for (const facts of await store.mail.emailFacts({ accountId, since, participant: sender }))
|
|
78
|
+
found.set(facts.externalId, facts);
|
|
79
|
+
return [...found.values()];
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Meetings read from stored mail a meeting-notes rule matches, for `pull`. The notes give the day, not the hours:
|
|
83
|
+
* the event the meeting is already linked to, or the one event in the same room that day, gives its times; otherwise
|
|
84
|
+
* it starts at the day's start, says so in `metadata.time_precision`, and no event is made for it.
|
|
85
|
+
*/
|
|
86
|
+
export const mailMeetingSource = ({ store, meetings, address, rules, provider, accountId, }) => {
|
|
87
|
+
const kind = MEETING_NOTES[provider];
|
|
88
|
+
const ruling = rules.filter((rule) => rule.meeting_notes === provider);
|
|
89
|
+
const notes = new Map();
|
|
90
|
+
const none = async () => null;
|
|
91
|
+
return {
|
|
92
|
+
provider,
|
|
93
|
+
name: "mail",
|
|
94
|
+
createsEvents: false,
|
|
95
|
+
async meetings(since) {
|
|
96
|
+
if (kind === undefined || ruling.length === 0)
|
|
97
|
+
return [];
|
|
98
|
+
const stored = await store.accounts.storedAccount(mailAccountKey(address)).catch((error) => {
|
|
99
|
+
if (error instanceof CliError && error.code === "not_found")
|
|
100
|
+
return null;
|
|
101
|
+
throw error;
|
|
102
|
+
});
|
|
103
|
+
if (stored === null)
|
|
104
|
+
return [];
|
|
105
|
+
const listed = (await candidateFacts(store, stored.id, Date.parse(since), ruling)).map(listedOf);
|
|
106
|
+
const factsFor = factsOf(listed, ruling);
|
|
107
|
+
const saved = accountId === undefined ? [] : await meetings.meetings({ accountId, includeDeleted: true });
|
|
108
|
+
const linked = new Map(saved.flatMap(({ externalId, eventId }) => (eventId === null ? [] : [[externalId, eventId]])));
|
|
109
|
+
const events = new Map(linked.size ? (await meetings.events()).map((event) => [event.id, event]) : []);
|
|
110
|
+
const found = [];
|
|
111
|
+
for (const item of listed) {
|
|
112
|
+
if (!ruling.some((rule) => matches(rule.match, factsFor(item))))
|
|
113
|
+
continue;
|
|
114
|
+
const email = await store.mail.email(stored.id, item.messageId);
|
|
115
|
+
if (email === null || email.deletedAt !== null)
|
|
116
|
+
continue;
|
|
117
|
+
const subject = email.subject ?? "";
|
|
118
|
+
const sent = email.sentAt ?? email.receivedAt;
|
|
119
|
+
const date = kind.day(subject) ??
|
|
120
|
+
(sent === null
|
|
121
|
+
? null
|
|
122
|
+
: {
|
|
123
|
+
year: new Date(sent).getFullYear(),
|
|
124
|
+
month: new Date(sent).getMonth() + 1,
|
|
125
|
+
day: new Date(sent).getDate(),
|
|
126
|
+
});
|
|
127
|
+
if (date === null)
|
|
128
|
+
continue;
|
|
129
|
+
const window = dayWindow(kind, date);
|
|
130
|
+
if (!Number.isFinite(window.local))
|
|
131
|
+
continue;
|
|
132
|
+
const text = textOf(email);
|
|
133
|
+
const joinUrl = roomOf(text);
|
|
134
|
+
const linkedId = linked.get(email.externalId);
|
|
135
|
+
const linkedEvent = linkedId === undefined ? undefined : events.get(linkedId);
|
|
136
|
+
const candidates = linkedEvent !== undefined || joinUrl === null
|
|
137
|
+
? []
|
|
138
|
+
: await meetings.eventCandidates({
|
|
139
|
+
meetingSeriesId: null,
|
|
140
|
+
joinUrl,
|
|
141
|
+
startsAt: window.start,
|
|
142
|
+
endsAt: window.end,
|
|
143
|
+
});
|
|
144
|
+
const timed = linkedEvent ?? (candidates.length === 1 ? candidates[0] : undefined);
|
|
145
|
+
const startsAt = timed?.startsAt ?? null;
|
|
146
|
+
const meeting = {
|
|
147
|
+
joinUrl,
|
|
148
|
+
metadata: { email: email.externalId, time_precision: startsAt === null ? "day" : "event" },
|
|
149
|
+
series: null,
|
|
150
|
+
occurrence: {
|
|
151
|
+
id: email.externalId,
|
|
152
|
+
seriesId: email.externalId,
|
|
153
|
+
title: timed?.title ?? (subject || null),
|
|
154
|
+
startedAt: new Date(startsAt ?? window.local).toISOString(),
|
|
155
|
+
endedAt: startsAt === null || timed?.endsAt == null ? null : new Date(timed.endsAt).toISOString(),
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
notes.set(email.externalId, { meeting, summary: notesOf(text, kind) });
|
|
159
|
+
found.push(meeting);
|
|
160
|
+
}
|
|
161
|
+
return found;
|
|
162
|
+
},
|
|
163
|
+
participants: none,
|
|
164
|
+
transcript: none,
|
|
165
|
+
chat: none,
|
|
166
|
+
summary: async (id) => notes.get(id)?.summary ?? null,
|
|
167
|
+
files: none,
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Saves as meetings the stored mail each meeting-notes rule matches, from `since`, into the provider's account named
|
|
172
|
+
* by the mailbox's address. Mail stored before the rule was made is read the same way, with an early `since`. A
|
|
173
|
+
* provider that fails is a warning in its report: the mail it was read from is already saved.
|
|
174
|
+
*/
|
|
175
|
+
export const saveMeetingNotes = async (store, address, rules, { since, now = Date.now() }) => {
|
|
176
|
+
const reports = {};
|
|
177
|
+
for (const provider of new Set(rules.flatMap(({ meeting_notes }) => (meeting_notes ? [meeting_notes] : [])))) {
|
|
178
|
+
if (MEETING_NOTES[provider] === undefined)
|
|
179
|
+
continue;
|
|
180
|
+
try {
|
|
181
|
+
const key = { provider, account: address.toLowerCase() };
|
|
182
|
+
const accountId = await store.accounts.saveAccount(key, { name: address.toLowerCase() });
|
|
183
|
+
const source = mailMeetingSource({ store, meetings: store.meetings, address, rules, provider, accountId });
|
|
184
|
+
reports[provider] = await pull(source, store.meetings, { accountId, since, now });
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
const message = error instanceof Error ? error.message : "meeting notes could not be saved";
|
|
188
|
+
reports[provider] = {
|
|
189
|
+
meetings: 0,
|
|
190
|
+
participants: 0,
|
|
191
|
+
transcriptRows: 0,
|
|
192
|
+
summaries: 0,
|
|
193
|
+
warnings: [{ externalId: "", message }],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return reports;
|
|
198
|
+
};
|
package/dist/mail/rule-input.js
CHANGED
|
@@ -24,6 +24,7 @@ export const ruleInput = (rule, source = rule.source ?? "owner") => ({
|
|
|
24
24
|
store: STORE_ACTION[rule.action],
|
|
25
25
|
...(rule.tags?.length ? { tags: rule.tags } : {}),
|
|
26
26
|
...(rule.tags_skipped && Object.keys(rule.tags_skipped).length ? { tags_skipped: rule.tags_skipped } : {}),
|
|
27
|
+
...(rule.meeting_notes ? { meeting_notes: rule.meeting_notes } : {}),
|
|
27
28
|
},
|
|
28
29
|
protected: rule.protected === true,
|
|
29
30
|
source,
|
package/dist/mail/rule-stored.js
CHANGED
|
@@ -41,11 +41,13 @@ export const storedMailRule = (stored) => {
|
|
|
41
41
|
const tagsSkipped = skipped !== null && typeof skipped === "object" && !Array.isArray(skipped)
|
|
42
42
|
? Object.fromEntries(Object.entries(skipped).filter(([, why]) => typeof why === "string"))
|
|
43
43
|
: {};
|
|
44
|
+
const meetingNotes = stored.actions.meeting_notes;
|
|
44
45
|
return {
|
|
45
46
|
id: stored.id,
|
|
46
47
|
match: Object.fromEntries(entries),
|
|
47
48
|
action,
|
|
48
49
|
...(tags.length ? { tags: tags } : {}),
|
|
50
|
+
...(typeof meetingNotes === "string" && meetingNotes ? { meeting_notes: meetingNotes } : {}),
|
|
49
51
|
...(Object.keys(tagsSkipped).length ? { tags_skipped: tagsSkipped } : {}),
|
|
50
52
|
...(stored.reason === null ? {} : { reason: stored.reason }),
|
|
51
53
|
...(stored.protected ? { protected: true } : {}),
|
package/dist/mail/rules.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface MailRule {
|
|
|
39
39
|
reason?: string;
|
|
40
40
|
/** Stored in full, and no cleanup may cut, archive or trash it, whatever other rules or presets say. */
|
|
41
41
|
protected?: boolean;
|
|
42
|
+
/** The mail is a meeting's notes from this provider (`telemost`): each email it matches is saved as a meeting too. */
|
|
43
|
+
meeting_notes?: string;
|
|
42
44
|
/** owner, preset:<name>, probe or gmail-filter. */
|
|
43
45
|
source?: string;
|
|
44
46
|
decided_at: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BudgetStop, RunBudget } from "../background/budget.js";
|
|
2
|
+
import type { RunReport } from "../meetings/index.js";
|
|
2
3
|
import type { LoadEngine } from "../readers/types.js";
|
|
3
4
|
import type { AccountKey, MessageStore } from "../store/index.js";
|
|
4
5
|
import type { MailAttachmentPolicy } from "./attachments.js";
|
|
@@ -78,6 +79,8 @@ export interface MailSyncResult {
|
|
|
78
79
|
stillFailed: number;
|
|
79
80
|
missing: number;
|
|
80
81
|
};
|
|
82
|
+
/** Per provider, the meetings saved from mail a meeting-notes rule matches. */
|
|
83
|
+
meetingNotes?: Record<string, RunReport>;
|
|
81
84
|
}
|
|
82
85
|
export interface MailSyncOptions {
|
|
83
86
|
account: MailAccount;
|
package/dist/mail/sync.js
CHANGED
|
@@ -11,6 +11,7 @@ import { GMAIL_ALL_MAIL, mailFolders } from "./folders.js";
|
|
|
11
11
|
import { dropMissing, tooManyGone } from "./gone.js";
|
|
12
12
|
import { mailHeadersOf } from "./headers.js";
|
|
13
13
|
import { flagsToRefresh, proveByLocation } from "./locations.js";
|
|
14
|
+
import { saveMeetingNotes } from "./meeting-notes.js";
|
|
14
15
|
import { MAX_BODY_CHARS, parseMail } from "./parse.js";
|
|
15
16
|
import { completePartial } from "./partial.js";
|
|
16
17
|
import { FETCH_SLICE, keyOf, readQuick } from "./quick.js";
|
|
@@ -36,6 +37,17 @@ const LIST_SLICE = 200;
|
|
|
36
37
|
const STORE_BUSY_TRIES = 5;
|
|
37
38
|
const STORE_BUSY_WAIT_MS = 2_000;
|
|
38
39
|
export const syncMail = async (source, store, options) => {
|
|
40
|
+
const result = await syncAndComplete(source, store, options);
|
|
41
|
+
const rules = options.account.rules ?? [];
|
|
42
|
+
if (!rules.some(({ meeting_notes }) => meeting_notes) || options.signal?.aborted)
|
|
43
|
+
return result;
|
|
44
|
+
const now = (options.now ?? Date.now)();
|
|
45
|
+
return {
|
|
46
|
+
...result,
|
|
47
|
+
meetingNotes: await saveMeetingNotes(store, options.account.address, rules, { since: result.since, now }),
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const syncAndComplete = async (source, store, options) => {
|
|
39
51
|
const result = await syncRounds(source, store, options);
|
|
40
52
|
if (options.completePartial === false || options.retryAttachments || options.account.mode === "mbox")
|
|
41
53
|
return result;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Event } from "./model.js";
|
|
2
2
|
import type { MeetingDetails, MeetingStore } from "./store.js";
|
|
3
|
-
export declare const linkEvent: (store: MeetingStore, details: MeetingDetails, now?: number
|
|
3
|
+
export declare const linkEvent: (store: MeetingStore, details: MeetingDetails, now?: number, { create }?: {
|
|
4
|
+
create?: boolean;
|
|
5
|
+
}) => Promise<Event | null>;
|
package/dist/meetings/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const linkEvent = async (store, details, now = Date.now()) => {
|
|
1
|
+
export const linkEvent = async (store, details, now = Date.now(), { create = true } = {}) => {
|
|
2
2
|
const current = await store.meeting(details.meeting.id);
|
|
3
3
|
if (!current)
|
|
4
4
|
return null;
|
|
@@ -18,6 +18,8 @@ export const linkEvent = async (store, details, now = Date.now()) => {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
let event = candidates[0];
|
|
21
|
+
if (!event && !create)
|
|
22
|
+
return null;
|
|
21
23
|
if (!event) {
|
|
22
24
|
let eventSeriesId = series?.eventSeriesId ?? null;
|
|
23
25
|
if (series?.kind === "recurring" && eventSeriesId === null) {
|
package/dist/meetings/pull.js
CHANGED
|
@@ -173,7 +173,7 @@ export const pull = async (source, store, options) => {
|
|
|
173
173
|
transcripts: [await transcriptInput(lines, [], source.name, `${JSON.stringify(lines)}\nunlinked`, format)],
|
|
174
174
|
now,
|
|
175
175
|
});
|
|
176
|
-
await linkEvent(store, details, now);
|
|
176
|
+
await linkEvent(store, details, now, { create: source.createsEvents !== false });
|
|
177
177
|
for (const p of participants)
|
|
178
178
|
if (p.identity.phone)
|
|
179
179
|
callers.add(p.identity.externalId);
|
|
@@ -27,6 +27,11 @@ export interface MeetingSource {
|
|
|
27
27
|
* meeting only once it has ended, or adds its recording later, sets it. 0 when absent; `--lookback-days` widens it.
|
|
28
28
|
*/
|
|
29
29
|
readonly overlapMs?: number;
|
|
30
|
+
/**
|
|
31
|
+
* False for a source that knows a meeting's day but not its hours, such as meeting notes from mail: its meetings
|
|
32
|
+
* link to an event the owner already has and never make one. True when absent.
|
|
33
|
+
*/
|
|
34
|
+
readonly createsEvents?: boolean;
|
|
30
35
|
meetings(since: string): Promise<SourceMeeting[]>;
|
|
31
36
|
participants(occurrenceId: string): Promise<SourceParticipant[] | null>;
|
|
32
37
|
transcript(occurrenceId: string): Promise<TranscriptLine[] | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.653.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",
|