@wirecat/cli-core 0.662.0 → 0.664.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 +213 -0
- package/dist/calendar/cli/bodies.js +2 -1
- package/dist/calendar/cli/index.js +13 -10
- package/dist/calendar/mcp/index.d.ts +3 -1
- package/dist/calendar/mcp/index.js +4 -4
- package/dist/cli/call-stats-command.d.ts +18 -0
- package/dist/cli/call-stats-command.js +52 -0
- package/dist/cli/chat-sending-command.d.ts +14 -0
- package/dist/cli/chat-sending-command.js +64 -0
- package/dist/cli/context.d.ts +7 -0
- package/dist/cli/context.js +12 -4
- package/dist/cli/contract-templates.js +2 -0
- package/dist/cli/envelope.d.ts +0 -5
- package/dist/cli/envelope.js +25 -0
- package/dist/cli/index.d.ts +4 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/meeting-batch.d.ts +2 -1
- package/dist/cli/meeting-batch.js +7 -5
- package/dist/cli/meeting-meaning-command.d.ts +47 -0
- package/dist/cli/meeting-meaning-command.js +136 -0
- package/dist/cli/meeting-preparation-answer.d.ts +6 -0
- package/dist/cli/meeting-preparation-command.js +5 -5
- package/dist/cli/meeting-preparation-projects.d.ts +6 -0
- package/dist/cli/meeting-preparation-read.d.ts +11 -5
- package/dist/cli/meeting-preparation-read.js +13 -21
- package/dist/cli/meeting-series-inventory-command.js +2 -2
- package/dist/cli/meeting-series-inventory-read.d.ts +2 -2
- package/dist/cli/meeting-series-inventory-read.js +7 -15
- package/dist/cli/meeting-tags-command.d.ts +18 -0
- package/dist/cli/meeting-tags-command.js +74 -0
- package/dist/cli/messenger/admin-statistics-command.js +2 -2
- package/dist/cli/messenger/conversation-answers.d.ts +1 -1
- package/dist/cli/messenger/conversation-answers.js +1 -0
- package/dist/cli/messenger/conversations-command.js +38 -12
- package/dist/cli/messenger/counters-command.js +2 -2
- package/dist/cli/messenger/media-archive-command.js +5 -4
- package/dist/cli/messenger/media-archive-move-command.js +1 -1
- package/dist/cli/messenger/media-archive-timer-command.js +5 -4
- package/dist/cli/messenger/metadata-command.js +3 -3
- package/dist/cli/messenger/models-command.js +7 -0
- package/dist/cli/messenger/rankings-command.js +3 -3
- package/dist/cli/messenger/records-command.d.ts +4 -1
- package/dist/cli/messenger/records-command.js +6 -1
- package/dist/cli/messenger/tags-command.js +7 -2
- package/dist/cli/messenger/tasks-command.js +2 -2
- package/dist/cli/model-catalogue-command.js +2 -0
- package/dist/cli/paging.d.ts +10 -0
- package/dist/cli/paging.js +29 -0
- package/dist/cli/profile-token.d.ts +15 -1
- package/dist/cli/profile-token.js +103 -7
- package/dist/cli/program.js +2 -2
- package/dist/cli/runs/command.js +6 -4
- package/dist/cli/runs/search-command.js +9 -5
- package/dist/cli/schedule/schedule-command.js +1 -5
- package/dist/domain/links.d.ts +11 -0
- package/dist/domain/links.js +4 -0
- package/dist/domain/moment.d.ts +29 -0
- package/dist/domain/moment.js +58 -0
- package/dist/domain/providers.d.ts +6 -4
- package/dist/domain/providers.js +10 -5
- package/dist/domain/send-time.d.ts +3 -4
- package/dist/domain/send-time.js +10 -24
- package/dist/entities/chat-sending.d.ts +10 -0
- package/dist/entities/chat-sending.js +11 -0
- package/dist/entities/fields.d.ts +2 -2
- package/dist/entities/fields.js +2 -2
- package/dist/entities/index.d.ts +135 -2
- package/dist/entities/index.js +8 -3
- package/dist/entities/meeting-preparation.d.ts +6 -0
- package/dist/entities/meeting.d.ts +1 -1
- package/dist/entities/meeting.js +1 -1
- package/dist/errors/reasons.js +25 -2
- package/dist/mail/cli/index.js +4 -2
- package/dist/mail/facts.d.ts +5 -2
- package/dist/mail/facts.js +6 -3
- package/dist/mail/index.d.ts +1 -1
- package/dist/mail/meeting-notes.js +1 -1
- package/dist/mail/probe.d.ts +5 -2
- package/dist/mail/probe.js +9 -5
- package/dist/mail/server-search.js +1 -1
- package/dist/mail/sync.js +1 -1
- package/dist/mcp/meeting-preparation.d.ts +6 -0
- package/dist/mcp/meeting-preparation.js +1 -1
- package/dist/mcp/meeting-series-inventory.js +1 -1
- package/dist/mcp/prompts.js +6 -9
- package/dist/meetings/answers.d.ts +7 -0
- package/dist/meetings/answers.js +4 -0
- package/dist/meetings/call-answers.d.ts +106 -0
- package/dist/meetings/call-answers.js +171 -0
- package/dist/meetings/call-stats.d.ts +121 -0
- package/dist/meetings/call-stats.js +211 -0
- package/dist/meetings/calls.d.ts +76 -0
- package/dist/meetings/calls.js +78 -0
- package/dist/meetings/cli/index.d.ts +8 -0
- package/dist/meetings/cli/index.js +10 -22
- package/dist/meetings/cli/search.d.ts +9 -2
- package/dist/meetings/cli/search.js +16 -26
- package/dist/meetings/index.d.ts +4 -0
- package/dist/meetings/index.js +4 -0
- package/dist/meetings/mcp/index.d.ts +6 -3
- package/dist/meetings/mcp/index.js +2 -4
- package/dist/meetings/mcp/search.d.ts +12 -1
- package/dist/meetings/mcp/search.js +3 -3
- package/dist/meetings/project-evidence-answer.d.ts +6 -0
- package/dist/meetings/read-through.d.ts +2 -1
- package/dist/meetings/read-through.js +10 -1
- package/dist/meetings/stats.d.ts +3 -0
- package/dist/meetings/stats.js +3 -3
- package/dist/meetings/tag-answers.d.ts +43 -0
- package/dist/meetings/tag-answers.js +41 -0
- package/dist/meetings/testing/index.d.ts +1 -0
- package/dist/meetings/testing/index.js +1 -0
- package/dist/meetings/testing/paging.d.ts +6 -0
- package/dist/meetings/testing/paging.js +5 -0
- package/dist/models/chat-sending.d.ts +24 -0
- package/dist/models/chat-sending.js +40 -0
- package/dist/moderation/rules.d.ts +2 -0
- package/dist/moderation/rules.js +16 -2
- package/dist/runs/events.d.ts +1 -1
- package/dist/search/fusion.d.ts +17 -0
- package/dist/search/fusion.js +17 -0
- package/dist/search/lucene/resolved.d.ts +2 -0
- package/dist/search/question-plan.d.ts +4 -0
- package/dist/search/question-plan.js +7 -0
- package/dist/search/service-query.d.ts +6 -1
- package/dist/search/service-query.js +9 -1
- package/dist/search/task-similarity.d.ts +1 -0
- package/dist/search/task-similarity.js +1 -1
- package/dist/services/agenda-mail.js +2 -1
- package/dist/services/agenda.js +5 -3
- package/dist/services/attachments.js +4 -2
- package/dist/services/call-stats.d.ts +17 -0
- package/dist/services/call-stats.js +41 -0
- package/dist/services/chats.js +4 -2
- package/dist/services/conversations.js +4 -2
- package/dist/services/deps.d.ts +1 -1
- package/dist/services/document-source.d.ts +1 -1
- package/dist/services/document-source.js +4 -3
- package/dist/services/documents/ingestion.js +11 -40
- package/dist/services/documents/plan.d.ts +1 -1
- package/dist/services/documents/plan.js +30 -17
- package/dist/services/documents/ports.d.ts +5 -0
- package/dist/services/documents/sync.js +1 -1
- package/dist/services/embeddings-search.js +39 -9
- package/dist/services/embeddings.d.ts +4 -0
- package/dist/services/events-search.js +2 -1
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +3 -0
- package/dist/services/mail-search.d.ts +1 -1
- package/dist/services/mail-search.js +10 -11
- package/dist/services/media-archive-move.js +2 -4
- package/dist/services/media-archive.d.ts +0 -1
- package/dist/services/media-archive.js +2 -12
- package/dist/services/meeting-combined.js +1 -1
- package/dist/services/meeting-meaning.d.ts +47 -0
- package/dist/services/meeting-meaning.js +158 -0
- package/dist/services/meeting-tags.d.ts +27 -0
- package/dist/services/meeting-tags.js +81 -0
- package/dist/services/messages-combined.js +15 -4
- package/dist/services/messages-discovery.js +2 -2
- package/dist/services/moderation.js +10 -2
- package/dist/services/moment.d.ts +4 -10
- package/dist/services/moment.js +16 -44
- package/dist/services/notes-search.d.ts +0 -2
- package/dist/services/notes-search.js +1 -2
- package/dist/services/search-all.js +2 -1
- package/dist/services/tags.js +4 -2
- package/dist/services/task-stats.js +2 -2
- package/dist/services/tasks.js +2 -2
- package/dist/sftp/index.d.ts +1 -1
- package/dist/sftp/index.js +1 -1
- package/dist/sftp/session.d.ts +30 -4
- package/dist/sftp/session.js +195 -11
- package/dist/sftp/ssh2.d.ts +19 -4
- package/dist/sftp/ssh2.js +144 -17
- package/dist/speech/cloud.d.ts +47 -0
- package/dist/speech/cloud.js +73 -0
- package/dist/speech/decode.d.ts +36 -9
- package/dist/speech/decode.js +208 -61
- package/dist/speech/index.d.ts +2 -1
- package/dist/speech/index.js +2 -1
- package/dist/speech/openai.d.ts +4 -0
- package/dist/speech/openai.js +13 -12
- package/dist/sql/index.d.ts +1 -0
- package/dist/sql/index.js +1 -0
- package/dist/sql/reader.d.ts +95 -0
- package/dist/sql/reader.js +214 -0
- package/dist/store/accounts.js +2 -1
- package/dist/store/sqlite/account-purge.d.ts +3 -0
- package/dist/store/sqlite/account-purge.js +143 -0
- package/dist/store/sqlite/accounts.d.ts +0 -2
- package/dist/store/sqlite/accounts.js +2 -134
- package/dist/store/sqlite/calendar.d.ts +1 -0
- package/dist/store/sqlite/calendar.js +5 -5
- package/dist/store/sqlite/catalog.js +2 -16
- package/dist/store/sqlite/chats.js +2 -1
- package/dist/store/sqlite/context-document-source.d.ts +3 -3
- package/dist/store/sqlite/context-document-source.js +9 -7
- package/dist/store/sqlite/context-evidence.js +9 -3
- package/dist/store/sqlite/document-listing.js +2 -1
- package/dist/store/sqlite/drizzle/bun.js +4 -4
- package/dist/store/sqlite/drizzle/bun.js.map +1 -1
- package/dist/store/sqlite/drizzle/core.js +5 -5
- package/dist/store/sqlite/drizzle/core.js.map +1 -1
- package/dist/store/sqlite/drizzle/node.js +4 -4
- package/dist/store/sqlite/drizzle/node.js.map +1 -1
- package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js → shared-5XR7K42U.js} +58 -58
- package/dist/store/sqlite/drizzle/{shared-55XJMTPA.js.map → shared-5XR7K42U.js.map} +1 -1
- package/dist/store/sqlite/events.js +2 -1
- package/dist/store/sqlite/file-note.d.ts +6 -0
- package/dist/store/sqlite/file-note.js +15 -0
- package/dist/store/sqlite/files.d.ts +3 -2
- package/dist/store/sqlite/files.js +5 -3
- package/dist/store/sqlite/identities.js +2 -1
- package/dist/store/sqlite/imported-documents.js +2 -2
- package/dist/store/sqlite/knowledge.d.ts +1 -1
- package/dist/store/sqlite/knowledge.js +27 -23
- package/dist/store/sqlite/labelled.d.ts +5 -0
- package/dist/store/sqlite/labelled.js +6 -0
- package/dist/store/sqlite/link-row.d.ts +1 -0
- package/dist/store/sqlite/link-row.js +2 -0
- package/dist/store/sqlite/lucene-fields.js +8 -12
- package/dist/store/sqlite/mail-rules.js +2 -1
- package/dist/store/sqlite/meeting-calls.d.ts +4 -0
- package/dist/store/sqlite/meeting-calls.js +66 -0
- package/dist/store/sqlite/meetings.d.ts +2 -2
- package/dist/store/sqlite/meetings.js +4 -1
- package/dist/store/sqlite/mention-sources.js +2 -1
- package/dist/store/sqlite/mentions.js +2 -2
- package/dist/store/sqlite/messages.js +6 -1
- package/dist/store/sqlite/note-search.js +8 -11
- package/dist/store/sqlite/notes.d.ts +3 -1
- package/dist/store/sqlite/notes.js +25 -14
- package/dist/store/sqlite/organizations.js +2 -2
- package/dist/store/sqlite/people-list.js +3 -3
- package/dist/store/sqlite/query-filter.d.ts +3 -3
- package/dist/store/sqlite/query-filter.js +3 -3
- package/dist/store/sqlite/reads.d.ts +4 -4
- package/dist/store/sqlite/reads.js +4 -4
- package/dist/store/sqlite/search.js +11 -7
- package/dist/store/sqlite/test-accounts.js +1 -1
- package/dist/store/sqlite/trigram-match.d.ts +9 -0
- package/dist/store/sqlite/trigram-match.js +28 -0
- package/dist/store/sqlite/work-tasks.js +1 -1
- package/package.json +18 -3
- package/parity.json +20 -1
- package/skills/link-conversations/SKILL.md +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
1
2
|
import { joinKeyOf, } from "../../meetings/index.js";
|
|
2
3
|
import { queryFilter } from "./query-filter.js";
|
|
3
4
|
import { write } from "./transaction.js";
|
|
@@ -51,7 +52,7 @@ export const events = (database, query) => {
|
|
|
51
52
|
ends_at: { type: "time", sql: "ends_at" },
|
|
52
53
|
created_at: { type: "time", sql: "created_at" },
|
|
53
54
|
updated_at: { type: "time", sql: "updated_at" },
|
|
54
|
-
});
|
|
55
|
+
}, { zone: timezoneOf() });
|
|
55
56
|
return database
|
|
56
57
|
.prepare(`SELECT * FROM events WHERE deleted_at IS NULL${where ? ` AND (${where.sql})` : ""} ORDER BY id`)
|
|
57
58
|
.all(...(where?.params ?? []))
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CacheDatabase } from "../driver.js";
|
|
2
|
+
/**
|
|
3
|
+
* The document row of the live file at `path` in an account, shaped as `notes({ folderId })` lists it. A local folder
|
|
4
|
+
* names its files by their own path; any other account by its document's key.
|
|
5
|
+
*/
|
|
6
|
+
export declare const fileNoteRow: (database: CacheDatabase, account: number, local: boolean, path: string) => Record<string, unknown> | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const LIVE = "f.deleted_at IS NULL AND d.deleted_at IS NULL AND coalesce(json_extract(d.metadata, '$.catalog.active'), 1)=1";
|
|
2
|
+
/**
|
|
3
|
+
* The document row of the live file at `path` in an account, shaped as `notes({ folderId })` lists it. A local folder
|
|
4
|
+
* names its files by their own path; any other account by its document's key.
|
|
5
|
+
*/
|
|
6
|
+
export const fileNoteRow = (database, account, local, path) => database
|
|
7
|
+
.prepare(local
|
|
8
|
+
? "SELECT d.*, f.account_id AS account_id, f.external_id AS external_id, " +
|
|
9
|
+
"coalesce(f.external_updated_at, d.external_updated_at) AS external_updated_at FROM files f " +
|
|
10
|
+
`JOIN documents d ON d.id = f.document_id WHERE f.account_id = ? AND f.external_id = ? AND ${LIVE} ` +
|
|
11
|
+
"ORDER BY d.created_at, d.id LIMIT 1"
|
|
12
|
+
: "SELECT d.*, f.account_id AS account_id, coalesce(f.external_updated_at, d.external_updated_at) AS " +
|
|
13
|
+
"external_updated_at FROM documents d JOIN files f ON f.document_id = d.id AND f.account_id = d.account_id " +
|
|
14
|
+
`WHERE d.account_id = ? AND d.external_id = ? AND ${LIVE} LIMIT 1`)
|
|
15
|
+
.get(account, path);
|
|
@@ -20,8 +20,9 @@ export declare const driveFileTarget: (fileId: string) => string;
|
|
|
20
20
|
/** The document of the Drive file with this id; `null` when no Drive account holds it, or two do. */
|
|
21
21
|
export declare const driveDocumentOf: (database: CacheDatabase, fileId: string) => number | null;
|
|
22
22
|
/**
|
|
23
|
-
* Writes the `files` row of one document from the document as it is now: the document's source record. A
|
|
24
|
-
* document (catalog metadata or
|
|
23
|
+
* Writes the `files` row of one document from the document as it is now: the document's source record. A documents
|
|
24
|
+
* provider's document (catalog metadata, or front matter whose `source` names the provider) is keyed by its file id
|
|
25
|
+
* (`fileId` in the front matter, else its own key) and placed under its first parent;
|
|
25
26
|
* a local one by its path, under folder rows made from that path. `seen` marks a sync or import that returned it.
|
|
26
27
|
* `place` names a local file of the document other than the one its own columns name: a copy in another folder.
|
|
27
28
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { isDocumentAccountProvider } from "../../domain/providers.js";
|
|
2
3
|
import { fold } from "../normalize.js";
|
|
3
4
|
import { write, writeBatch } from "./transaction.js";
|
|
4
5
|
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -79,8 +80,9 @@ const movePaths = (database, accountId, from, to) => {
|
|
|
79
80
|
.run(to, from.length + 1, accountId, from.length + 1, `${from}/`);
|
|
80
81
|
};
|
|
81
82
|
/**
|
|
82
|
-
* Writes the `files` row of one document from the document as it is now: the document's source record. A
|
|
83
|
-
* document (catalog metadata or
|
|
83
|
+
* Writes the `files` row of one document from the document as it is now: the document's source record. A documents
|
|
84
|
+
* provider's document (catalog metadata, or front matter whose `source` names the provider) is keyed by its file id
|
|
85
|
+
* (`fileId` in the front matter, else its own key) and placed under its first parent;
|
|
84
86
|
* a local one by its path, under folder rows made from that path. `seen` marks a sync or import that returned it.
|
|
85
87
|
* `place` names a local file of the document other than the one its own columns name: a copy in another folder.
|
|
86
88
|
*/
|
|
@@ -93,7 +95,7 @@ export const syncFile = (database, now, documentId, { seen = true, depth = 0, pl
|
|
|
93
95
|
const catalog = place ? undefined : objectOf(objectOf(doc.metadata)?.catalog);
|
|
94
96
|
const provider = database.prepare("SELECT provider FROM accounts WHERE id = ?").get(accountId)?.provider;
|
|
95
97
|
// A vault file may carry an exported Drive file's front matter and still be a file on disk.
|
|
96
|
-
const remote = catalog !== undefined || (front?.source
|
|
98
|
+
const remote = catalog !== undefined || (isDocumentAccountProvider(front?.source) && !LOCAL.has(String(provider)));
|
|
97
99
|
const externalId = (remote && stringOf(front?.fileId)) || (place?.path ?? String(doc.external_id));
|
|
98
100
|
const kind = doc.kind === "folder" ? "folder" : doc.kind === "page" ? "page" : "file";
|
|
99
101
|
let name;
|
|
@@ -7,6 +7,7 @@ import { holdingText } from "./note-index.js";
|
|
|
7
7
|
import { resolvePersonLinks } from "./person-resolution.js";
|
|
8
8
|
import { bound } from "./query-filter.js";
|
|
9
9
|
import { accountIdentities, accounts, aliases, chatMembers, chats, identities, identityLinkEvents, identityLinks, identityRevisions, messages, persons, } from "./schema.js";
|
|
10
|
+
import { trigramPart } from "./trigram-match.js";
|
|
10
11
|
import { toIso } from "./values.js";
|
|
11
12
|
/** The source's every phone and address as a JSON patch of `metadata`; `undefined` when it gave no list. */
|
|
12
13
|
const contactsOf = ({ phones, emails }) => {
|
|
@@ -244,7 +245,7 @@ const contactsWhere = (accountKey, key, { query, notes, email, phone }) => {
|
|
|
244
245
|
WHERE ${chatMembers.identityId} = ${identities.id} AND ${chats.accountId} = ${accountIdentities.accountId}
|
|
245
246
|
AND ${chats.kind} = 'dialog')`, query === undefined
|
|
246
247
|
? undefined
|
|
247
|
-
: sql `(${identities.id} IN (SELECT rowid FROM identities_fts WHERE identities_fts MATCH ${
|
|
248
|
+
: sql `(${identities.id} IN (SELECT rowid FROM identities_fts WHERE identities_fts MATCH ${trigramPart(query.trim())}) OR EXISTS (SELECT 1 FROM aliases ca WHERE ca.aliasable_type='identity' AND ca.display=1 AND ca.account_id=${accountKey} AND ca.aliasable_id=${identities.id} AND instr(ca.name_folded, ${fold(query.trim())}) > 0))`, notes === undefined
|
|
248
249
|
? undefined
|
|
249
250
|
: sql `EXISTS (SELECT 1 FROM notes n WHERE n.notable_type='identity' AND n.notable_id=${identities.id} AND n.deleted_at IS NULL${noted ? sql ` AND ${bound(noted)}` : sql ``})`, email === undefined
|
|
250
251
|
? undefined
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineQuery, validateQuery } from "@wirecat/cli-base/query";
|
|
1
|
+
import { defineQuery, timezoneOf, validateQuery } from "@wirecat/cli-base/query";
|
|
2
2
|
import { normalizeTag } from "../../domain/tags.js";
|
|
3
3
|
import { idsOf } from "./merged-persons.js";
|
|
4
4
|
import { queryFilter } from "./query-filter.js";
|
|
@@ -51,5 +51,5 @@ export const importedDocumentWhere = (database, query) => {
|
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
|
|
54
|
+
return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns, { zone: timezoneOf() });
|
|
55
55
|
};
|
|
@@ -143,7 +143,7 @@ export interface KnowledgeStore extends VocabularyStore, MeetingProjectsStore, O
|
|
|
143
143
|
} & TagCreationOptions): Promise<TagRow>;
|
|
144
144
|
/** Marks a topic as the thing's main one, or clears it with `null`; one per thing. */
|
|
145
145
|
setMainTopic(key: KnowledgeScope, target: KnowledgeTarget, topic: string | null): Promise<void>;
|
|
146
|
-
/** Every labelled note, document, person, organization, project, task and folder. */
|
|
146
|
+
/** Every labelled note, document, person, organization, project, task, meeting and folder; an account: its meetings. */
|
|
147
147
|
labelled(key: KnowledgeScope, options?: {
|
|
148
148
|
tag?: string;
|
|
149
149
|
type?: LabelledType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { walkQuery } from "@wirecat/cli-base/query";
|
|
2
|
+
import { timezoneOf, walkQuery } from "@wirecat/cli-base/query";
|
|
3
3
|
import { parseLocator } from "../../domain/locator.js";
|
|
4
4
|
import { isBusinessType } from "../../domain/record-types.js";
|
|
5
5
|
import { formatReference, parseReference } from "../../domain/references.js";
|
|
@@ -13,12 +13,12 @@ import { fold } from "../normalize.js";
|
|
|
13
13
|
import { ulid } from "../ulid.js";
|
|
14
14
|
import { ownerPerson } from "./actors.js";
|
|
15
15
|
import { forgetEvidenceToRow } from "./evidence-signature.js";
|
|
16
|
-
import { LABELLED } from "./labelled.js";
|
|
16
|
+
import { accountMeetingTagging, LABELLED } from "./labelled.js";
|
|
17
17
|
import { linkKind, RELATION_KINDS, REPORTER_SQL } from "./link-kinds.js";
|
|
18
18
|
import { meetingProjectsStoreOver } from "./meeting-projects.js";
|
|
19
19
|
import { idsOf } from "./merged-persons.js";
|
|
20
20
|
import { holdingText } from "./note-index.js";
|
|
21
|
-
import { insertLink, linkOf } from "./notes.js";
|
|
21
|
+
import { hasBothEnds, insertLink, linkOf } from "./notes.js";
|
|
22
22
|
import { organizationOf, organizationsStoreOver } from "./organizations.js";
|
|
23
23
|
import { queryFilter } from "./query-filter.js";
|
|
24
24
|
import { relationOf as relationAt, relationProposalsOver, } from "./relation-proposals.js";
|
|
@@ -64,6 +64,22 @@ const oneOf = (value, allowed, what) => {
|
|
|
64
64
|
/** What a relationship may connect; a deal or a lead only as the end its people hang from. */
|
|
65
65
|
const RELATED = ["person", "organization", "project", "task"];
|
|
66
66
|
const DEALS = ["deal", "lead"];
|
|
67
|
+
const PROJECT_COLUMNS = {
|
|
68
|
+
id: { type: "kw", sql: "CAST(id AS TEXT)" },
|
|
69
|
+
key: { type: "kw", sql: "key" },
|
|
70
|
+
name: { type: "kw", sql: "name_folded", folded: true },
|
|
71
|
+
kind: { type: "enum", sql: `CASE WHEN length(key) = ${INBOX_KEY_LENGTH} THEN 'inbox' ELSE 'project' END` },
|
|
72
|
+
type: { type: "enum", sql: "type" },
|
|
73
|
+
organization_id: { type: "kw", sql: "CAST(organization_id AS TEXT)" },
|
|
74
|
+
scope: { type: "enum", sql: "scope" },
|
|
75
|
+
created_at: { type: "time", sql: "created_at" },
|
|
76
|
+
};
|
|
77
|
+
const REMINDER_COLUMNS = {
|
|
78
|
+
id: { type: "kw", sql: "CAST(id AS TEXT)" },
|
|
79
|
+
state: { type: "enum", sql: "state" },
|
|
80
|
+
due_at: { type: "time", sql: "due_at" },
|
|
81
|
+
revision: { type: "num", sql: "revision" },
|
|
82
|
+
};
|
|
67
83
|
export const knowledgeStoreOver = (context) => {
|
|
68
84
|
const { database, now } = context;
|
|
69
85
|
const ids = (thing) => thing ? idsOf(database, thing.type, thing.id) : null;
|
|
@@ -414,6 +430,7 @@ export const knowledgeStoreOver = (context) => {
|
|
|
414
430
|
labelled: async (key, options = {}) => {
|
|
415
431
|
const { limit, offset } = bounded(options.limit, options.offset);
|
|
416
432
|
checked(key);
|
|
433
|
+
const meetingAccount = key === null ? null : account(key);
|
|
417
434
|
const tag = options.tag === undefined ? null : canonicalTagName(options.tag);
|
|
418
435
|
const types = Object.entries(LABELLED)
|
|
419
436
|
.filter(([, type]) => options.type === undefined || type === options.type)
|
|
@@ -423,10 +440,11 @@ export const knowledgeStoreOver = (context) => {
|
|
|
423
440
|
.prepare("SELECT * FROM (" +
|
|
424
441
|
"SELECT DISTINCT g.taggable_type AS type, g.taggable_id AS id, NULL AS path FROM taggings g JOIN resolved_tags t ON t.id=g.tag_id " +
|
|
425
442
|
`WHERE g.taggable_type IN (${types.map(() => "?").join(",") || "NULL"}) AND (? IS NULL OR t.name = ?) AND ${liveTagging("g")} ` +
|
|
443
|
+
`AND ${accountMeetingTagging("g")} ` +
|
|
426
444
|
"UNION SELECT DISTINCT 'account' AS type, l.from_id AS id, l.anchor AS path FROM links l JOIN resolved_tags t ON t.id=l.to_id " +
|
|
427
445
|
`WHERE ? = 1 AND l.from_type = 'account' AND l.kind = ${linkKind("labelled")} AND l.to_type = 'tag' AND (? IS NULL OR t.name = ?)` +
|
|
428
446
|
") ORDER BY type = 'account', type, id, path LIMIT ? OFFSET ?")
|
|
429
|
-
.all(...types, tag, tag, subfolders ? 1 : 0, tag, tag, limit + 1, offset);
|
|
447
|
+
.all(...types, tag, tag, meetingAccount, meetingAccount, subfolders ? 1 : 0, tag, tag, limit + 1, offset);
|
|
430
448
|
return {
|
|
431
449
|
items: rows.slice(0, limit).flatMap((row) => {
|
|
432
450
|
const thing = storedThing(row.type, row.id);
|
|
@@ -455,17 +473,7 @@ export const knowledgeStoreOver = (context) => {
|
|
|
455
473
|
addProject: async (input) => write(database, () => projectOf(insertProject(context, input))),
|
|
456
474
|
projects: async (query) => {
|
|
457
475
|
const asksKind = query !== undefined && walkQuery(query.root).some((node) => node.field === "kind");
|
|
458
|
-
const where = query &&
|
|
459
|
-
queryFilter(query, {
|
|
460
|
-
id: { type: "kw", sql: "CAST(id AS TEXT)" },
|
|
461
|
-
key: { type: "kw", sql: "key" },
|
|
462
|
-
name: { type: "kw", sql: "name_folded", folded: true },
|
|
463
|
-
kind: { type: "enum", sql: `CASE WHEN length(key) = ${INBOX_KEY_LENGTH} THEN 'inbox' ELSE 'project' END` },
|
|
464
|
-
type: { type: "enum", sql: "type" },
|
|
465
|
-
organization_id: { type: "kw", sql: "CAST(organization_id AS TEXT)" },
|
|
466
|
-
scope: { type: "enum", sql: "scope" },
|
|
467
|
-
created_at: { type: "time", sql: "created_at" },
|
|
468
|
-
});
|
|
476
|
+
const where = query && queryFilter(query, PROJECT_COLUMNS, { zone: timezoneOf() });
|
|
469
477
|
return database
|
|
470
478
|
.prepare(`SELECT * FROM projects WHERE deleted_at IS NULL${asksKind ? "" : ` AND length(key) <> ${INBOX_KEY_LENGTH}`}${where ? ` AND (${where.sql})` : ""} ORDER BY name, id LIMIT 500`)
|
|
471
479
|
.all(...(where?.params ?? []))
|
|
@@ -529,7 +537,9 @@ export const knowledgeStoreOver = (context) => {
|
|
|
529
537
|
// Live ones first: a long history of withdrawn links never pushes them past the cap.
|
|
530
538
|
`${RELATIONS} AND ${notOverriddenSql("links")} AND (? IS NULL OR (from_type=? AND from_id IN (SELECT value FROM json_each(?))) OR (to_type=? AND to_id IN (SELECT value FROM json_each(?)))) ORDER BY deleted_at IS NOT NULL, created_at, id LIMIT 500`)
|
|
531
539
|
.all(thing?.type ?? null, thing?.type ?? null, ids(thing), thing?.type ?? null, ids(thing))
|
|
532
|
-
.map((row) =>
|
|
540
|
+
.map((row) => linkOf(database, row))
|
|
541
|
+
.filter(hasBothEnds)
|
|
542
|
+
.map(relationOf);
|
|
533
543
|
},
|
|
534
544
|
removeRelation: async (key, id, by) => {
|
|
535
545
|
checked(key);
|
|
@@ -579,13 +589,7 @@ export const knowledgeStoreOver = (context) => {
|
|
|
579
589
|
return reminder(key, String(made?.id));
|
|
580
590
|
},
|
|
581
591
|
reminders: async (key, query) => {
|
|
582
|
-
const where = query &&
|
|
583
|
-
queryFilter(query, {
|
|
584
|
-
id: { type: "kw", sql: "CAST(id AS TEXT)" },
|
|
585
|
-
state: { type: "enum", sql: "state" },
|
|
586
|
-
due_at: { type: "time", sql: "due_at" },
|
|
587
|
-
revision: { type: "num", sql: "revision" },
|
|
588
|
-
});
|
|
592
|
+
const where = query && queryFilter(query, REMINDER_COLUMNS, { zone: timezoneOf() });
|
|
589
593
|
return database
|
|
590
594
|
.prepare(`SELECT * FROM reminders WHERE account_id=?${where ? ` AND (${where.sql})` : ""} ORDER BY due_at, id LIMIT 500`)
|
|
591
595
|
.all(account(key), ...(where?.params ?? []))
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export type LabelledType = "note" | "document" | "person" | "organization" | "project" | "task" | "meeting" | "folder";
|
|
2
2
|
/** What a label without an account may sit on; a chat, contact or message is the messenger's tag. */
|
|
3
3
|
export declare const LABELLED: Record<string, LabelledType>;
|
|
4
|
+
/**
|
|
5
|
+
* A meeting is one account's, like a chat: with the account id bound twice, a tagging of another account's meeting is
|
|
6
|
+
* left out, and with `NULL` none is; a deleted meeting's never counts.
|
|
7
|
+
*/
|
|
8
|
+
export declare const accountMeetingTagging: (alias: string) => string;
|
|
@@ -9,3 +9,9 @@ export const LABELLED = {
|
|
|
9
9
|
meeting: "meeting",
|
|
10
10
|
account: "folder",
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* A meeting is one account's, like a chat: with the account id bound twice, a tagging of another account's meeting is
|
|
14
|
+
* left out, and with `NULL` none is; a deleted meeting's never counts.
|
|
15
|
+
*/
|
|
16
|
+
export const accountMeetingTagging = (alias) => `(${alias}.taggable_type <> 'meeting' OR EXISTS (SELECT 1 FROM meetings mt WHERE mt.id = ${alias}.taggable_id ` +
|
|
17
|
+
"AND mt.deleted_at IS NULL AND (? IS NULL OR mt.account_id = ?)))";
|
|
@@ -2,5 +2,6 @@ import type { CacheDatabase } from "../driver.js";
|
|
|
2
2
|
import type { Link } from "./notes.js";
|
|
3
3
|
type Row = Record<string, unknown>;
|
|
4
4
|
export declare const thingRef: (database: CacheDatabase, type: unknown, id: unknown) => string | null;
|
|
5
|
+
export declare const hasBothEnds: (link: Link) => boolean;
|
|
5
6
|
export declare const linkOf: (database: CacheDatabase, row: Row) => Link;
|
|
6
7
|
export {};
|
|
@@ -3,6 +3,8 @@ import { sourceOf } from "./link-source.js";
|
|
|
3
3
|
import { referenceOfThing, storedThing } from "./things.js";
|
|
4
4
|
const iso = (value) => new Date(Number(value)).toISOString();
|
|
5
5
|
export const thingRef = (database, type, id) => type == null || id == null ? null : (referenceOfThing(database, storedThing(type, id)) ?? null);
|
|
6
|
+
// A chat or meeting deleted since leaves its links behind with no end to name.
|
|
7
|
+
export const hasBothEnds = (link) => link.from !== null && link.to !== null;
|
|
6
8
|
export const linkOf = (database, row) => {
|
|
7
9
|
const metadata = row.metadata == null ? {} : JSON.parse(String(row.metadata));
|
|
8
10
|
// An older row holds one word; every reader gets a list.
|
|
@@ -13,6 +13,7 @@ import { fold, normalize } from "../normalize.js";
|
|
|
13
13
|
import { linkMatch } from "./mention-links.js";
|
|
14
14
|
import { valueMatch } from "./phone-countries.js";
|
|
15
15
|
import { canonicalTagNamed } from "./tags.js";
|
|
16
|
+
import { yoSpellings } from "./trigram-match.js";
|
|
16
17
|
/**
|
|
17
18
|
* A voice note's transcript is its attachment's text, whoever wrote it: speech recognition (`speech:<model>`) or an
|
|
18
19
|
* agent, which writes the text of a voice attachment as `agent`. The voice attachment is the one
|
|
@@ -181,17 +182,6 @@ const literalRuns = (value) => {
|
|
|
181
182
|
}
|
|
182
183
|
return runs.filter(Boolean);
|
|
183
184
|
};
|
|
184
|
-
const MOST_YO_SPELLINGS = 64;
|
|
185
|
-
/** Every spelling of `run` with each е or ё as either: the trigram index keeps the text as written. */
|
|
186
|
-
const yoSpellings = (run) => {
|
|
187
|
-
let spellings = [""];
|
|
188
|
-
for (const c of run) {
|
|
189
|
-
spellings = spellings.flatMap((start) => (c === "е" || c === "ё" ? [`${start}е`, `${start}ё`] : [`${start}${c}`]));
|
|
190
|
-
if (spellings.length > MOST_YO_SPELLINGS)
|
|
191
|
-
return undefined;
|
|
192
|
-
}
|
|
193
|
-
return spellings;
|
|
194
|
-
};
|
|
195
185
|
/**
|
|
196
186
|
* A pattern with no start to read the word list from (`*договор*`, `*ость`), in chat messages: the trigram index of
|
|
197
187
|
* their text finds where its longest part occurs, so a large store does not refuse it: the whole search took 0.5–1 s at
|
|
@@ -243,8 +233,14 @@ const words = (node, scope) => {
|
|
|
243
233
|
const terms = scope.database
|
|
244
234
|
.prepare(`SELECT term FROM ${corpus.vocab} WHERE col='normalized_text'${prefix ? " AND term>=? AND term<=?" : ""} ORDER BY term LIMIT ?`)
|
|
245
235
|
.all(...(prefix ? [prefix, `${prefix}\u{10ffff}`] : []), QUERY_LIMITS.expansions + 1);
|
|
246
|
-
if (scope.expand(terms.length) > QUERY_LIMITS.expansions)
|
|
236
|
+
if (scope.expand(terms.length) > QUERY_LIMITS.expansions) {
|
|
237
|
+
if (node.widened) {
|
|
238
|
+
scope.expand(-terms.length);
|
|
239
|
+
const { widened: _, ...typed } = node;
|
|
240
|
+
return words({ ...typed, operator: "term", value: node.value.replace(/\*$/u, "") }, scope);
|
|
241
|
+
}
|
|
247
242
|
tooManyWords(node, terms.length > QUERY_LIMITS.expansions, prefix, scope.mail);
|
|
243
|
+
}
|
|
248
244
|
const matches = terms.flatMap(({ term }) => {
|
|
249
245
|
scope.check();
|
|
250
246
|
return automaton.test(String(term), scope.budget) ? [quoted(String(term))] : [];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
1
2
|
import { queryFilter } from "./query-filter.js";
|
|
2
3
|
import { write } from "./transaction.js";
|
|
3
4
|
const sorted = (value) => Array.isArray(value)
|
|
@@ -30,7 +31,7 @@ export const mailRulesOver = (database) => ({
|
|
|
30
31
|
id: { type: "num", sql: "id" },
|
|
31
32
|
protected: { type: "bool", sql: "protected" },
|
|
32
33
|
source: { type: "kw", sql: "source" },
|
|
33
|
-
});
|
|
34
|
+
}, { zone: timezoneOf() });
|
|
34
35
|
return database
|
|
35
36
|
.prepare(`SELECT * FROM mail_rules WHERE account_id = ?${where ? ` AND (${where.sql})` : ""} ORDER BY id`)
|
|
36
37
|
.all(accountId, ...(where?.params ?? []))
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MeetingCallsStore } from "../../meetings/index.js";
|
|
2
|
+
import type { StoreContext } from "./open.js";
|
|
3
|
+
/** The selected meetings with their metadata and people, through the same filters as meeting search and stats. */
|
|
4
|
+
export declare const meetingCallsOver: ({ database }: StoreContext) => MeetingCallsStore;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { int, str } from "./events.js";
|
|
3
|
+
import { checkMeetingCancelled } from "./meeting-operation.js";
|
|
4
|
+
import { positiveReadInteger } from "./meeting-reads.js";
|
|
5
|
+
import { meetingSelectionSql } from "./meeting-selection.js";
|
|
6
|
+
import { read } from "./transaction.js";
|
|
7
|
+
const MOST_CALLS = 200_000;
|
|
8
|
+
// The store keeps what the provider wrote; one unreadable value must not fail the whole report.
|
|
9
|
+
const parsed = (value) => {
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(value);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/** The selected meetings with their metadata and people, through the same filters as meeting search and stats. */
|
|
20
|
+
export const meetingCallsOver = ({ database }) => ({
|
|
21
|
+
async meetingCalls(input) {
|
|
22
|
+
checkMeetingCancelled(input.signal);
|
|
23
|
+
positiveReadInteger(input.accountId, "accountId");
|
|
24
|
+
const maxRows = input.maxRows ?? MOST_CALLS;
|
|
25
|
+
if (!Number.isSafeInteger(maxRows) || maxRows < 1 || maxRows > MOST_CALLS)
|
|
26
|
+
throw new CliError("validation_error", `call stats read 1 through ${MOST_CALLS} calls`);
|
|
27
|
+
return read(database, () => {
|
|
28
|
+
const { clauses, params } = meetingSelectionSql(input);
|
|
29
|
+
const meetings = database
|
|
30
|
+
.prepare(`SELECT m.id, m.started_at, coalesce(m.duration_ms, m.ended_at - m.started_at) AS duration_ms, m.metadata
|
|
31
|
+
FROM meetings m WHERE ${clauses.join(" AND ")} ORDER BY m.started_at, m.id LIMIT ?`)
|
|
32
|
+
.all(...params, maxRows + 1);
|
|
33
|
+
if (meetings.length > maxRows)
|
|
34
|
+
throw new CliError("validation_error", `the selection has more than ${maxRows} meetings; narrow it`);
|
|
35
|
+
checkMeetingCancelled(input.signal);
|
|
36
|
+
const people = new Map();
|
|
37
|
+
const rows = database
|
|
38
|
+
.prepare(`SELECT p.meeting_id, p.identity_id, i.external_id AS identity_key, p.role,
|
|
39
|
+
coalesce(p.display_name, i.name) AS name, p.external_id
|
|
40
|
+
FROM meeting_participants p JOIN identities i ON i.id = p.identity_id
|
|
41
|
+
WHERE p.meeting_id IN (SELECT m.id FROM meetings m WHERE ${clauses.join(" AND ")})
|
|
42
|
+
ORDER BY p.id`)
|
|
43
|
+
.all(...params);
|
|
44
|
+
for (const row of rows) {
|
|
45
|
+
const meetingId = Number(row.meeting_id);
|
|
46
|
+
people.set(meetingId, [
|
|
47
|
+
...(people.get(meetingId) ?? []),
|
|
48
|
+
{
|
|
49
|
+
identityId: Number(row.identity_id),
|
|
50
|
+
identityKey: String(row.identity_key),
|
|
51
|
+
role: str(row.role),
|
|
52
|
+
name: str(row.name),
|
|
53
|
+
externalId: str(row.external_id),
|
|
54
|
+
},
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
return meetings.map((row) => ({
|
|
58
|
+
meetingId: Number(row.id),
|
|
59
|
+
startedAt: int(row.started_at),
|
|
60
|
+
durationMs: int(row.duration_ms),
|
|
61
|
+
metadata: parsed(row.metadata),
|
|
62
|
+
participants: people.get(Number(row.id)) ?? [],
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attachment, MeetingChatLinesStore, MeetingContextStore, MeetingParticipantSearchStore, MeetingPreparationContextStore, MeetingPreparationKnowledgeStore, MeetingPreparationNotesStore, MeetingRelatedHistoryStore, MeetingReviewStore, MeetingSearchIndexStore, MeetingSearchStore, MeetingSeriesHistoryStore, MeetingStatsStore, MeetingStore, MeetingTranscriptDocumentStore, MeetingTranscriptReceiptStore, MeetingTranscriptStore, NewRecord } from "../../meetings/index.js";
|
|
1
|
+
import type { Attachment, MeetingCallsStore, MeetingChatLinesStore, MeetingContextStore, MeetingParticipantSearchStore, MeetingPreparationContextStore, MeetingPreparationKnowledgeStore, MeetingPreparationNotesStore, MeetingRelatedHistoryStore, MeetingReviewStore, MeetingSearchIndexStore, MeetingSearchStore, MeetingSeriesHistoryStore, MeetingStatsStore, MeetingStore, MeetingTranscriptDocumentStore, MeetingTranscriptReceiptStore, MeetingTranscriptStore, NewRecord } from "../../meetings/index.js";
|
|
2
2
|
import type { CacheDatabase } from "../driver.js";
|
|
3
3
|
import { type MeetingLanguageStore } from "./meeting-languages.js";
|
|
4
4
|
import { type MeetingContextReadCapabilities, type MeetingReadCapabilities } from "./meeting-reads.js";
|
|
@@ -12,7 +12,7 @@ export declare const saveAttachment: (database: CacheDatabase, type: string, par
|
|
|
12
12
|
export declare const drainMeetingIndex: (database: CacheDatabase, batch?: number) => number;
|
|
13
13
|
/** Each word of the query, as a prefix, all required. */
|
|
14
14
|
export declare const wordsQuery: (query: string) => string | null;
|
|
15
|
-
export type StoredMeetings = MeetingStore & MeetingPreparationContextStore & MeetingPreparationKnowledgeStore & MeetingPreparationNotesStore & MeetingRelatedHistoryStore & MeetingSeriesHistoryStore & MeetingTranscriptStore & MeetingReadCapabilities & MeetingContextReadCapabilities & MeetingParticipantSearchStore & MeetingSearchStore & MeetingTranscriptReceiptStore & MeetingContextStore & MeetingSearchIndexStore & MeetingStatsStore & MeetingReviewStore & MeetingChatLinesStore & MeetingLanguageStore & MeetingTranscriptDocumentStore;
|
|
15
|
+
export type StoredMeetings = MeetingStore & MeetingPreparationContextStore & MeetingPreparationKnowledgeStore & MeetingPreparationNotesStore & MeetingRelatedHistoryStore & MeetingSeriesHistoryStore & MeetingTranscriptStore & MeetingReadCapabilities & MeetingContextReadCapabilities & MeetingParticipantSearchStore & MeetingSearchStore & MeetingTranscriptReceiptStore & MeetingContextStore & MeetingSearchIndexStore & MeetingStatsStore & MeetingCallsStore & MeetingReviewStore & MeetingChatLinesStore & MeetingLanguageStore & MeetingTranscriptDocumentStore;
|
|
16
16
|
/** The `MeetingStore` of `src/meetings/` over the shared store. */
|
|
17
17
|
export declare const meetingStoreOver: (context: StoreContext) => StoredMeetings;
|
|
18
18
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
2
3
|
import { formatMeetingReference, joinKeyOf, MeetingError } from "../../meetings/index.js";
|
|
3
4
|
import { normalize } from "../normalize.js";
|
|
4
5
|
import * as eventQueries from "./events.js";
|
|
@@ -6,6 +7,7 @@ import { fromJson, int, page, str, toJson } from "./events.js";
|
|
|
6
7
|
import { folded } from "./folded.js";
|
|
7
8
|
import { meetingIdentityPk } from "./identities.js";
|
|
8
9
|
import { reviewLink } from "./link-reviews.js";
|
|
10
|
+
import { meetingCallsOver } from "./meeting-calls.js";
|
|
9
11
|
import { meetingChatLinesOver } from "./meeting-chat-lines.js";
|
|
10
12
|
import { meetingContextLinksOver } from "./meeting-context-links.js";
|
|
11
13
|
import { attachListedDocument, attachTranscriptFile, meetingDocumentsOf, meetingTranscriptDocumentsOver, } from "./meeting-documents.js";
|
|
@@ -459,7 +461,7 @@ const filtered = (filter = {}) => {
|
|
|
459
461
|
if (filter.query !== undefined) {
|
|
460
462
|
const compiled = queryFilter(filter.query, MEETING_COLUMNS, {
|
|
461
463
|
command: "meetings list",
|
|
462
|
-
|
|
464
|
+
zone: timezoneOf(filter.timezone),
|
|
463
465
|
...(filter.now === undefined ? {} : { now: filter.now }),
|
|
464
466
|
});
|
|
465
467
|
where.push(`(${compiled.sql})`);
|
|
@@ -621,6 +623,7 @@ export const meetingStoreOver = (context) => {
|
|
|
621
623
|
...meetingRelatedHistoryOver(context),
|
|
622
624
|
...meetingHitSearchOver(context),
|
|
623
625
|
...meetingStatsOver(context),
|
|
626
|
+
...meetingCallsOver(context),
|
|
624
627
|
...meetingReviewOver(context),
|
|
625
628
|
...meetingChatLinesOver(context),
|
|
626
629
|
...meetingParticipantSearchOver(context),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { timezoneOf } from "@wirecat/cli-base/query";
|
|
2
3
|
import { findAccountPk } from "./accounts.js";
|
|
3
4
|
import { candidatesOf, columnsOf, confirmMention, mentionOwner, rejectMention, } from "./mentions.js";
|
|
4
5
|
import { queryFilter } from "./query-filter.js";
|
|
@@ -67,7 +68,7 @@ export const sourceMentionStoreOver = (context) => {
|
|
|
67
68
|
const where = [scope.sql];
|
|
68
69
|
let params = scope.params;
|
|
69
70
|
if (query) {
|
|
70
|
-
const compiled = queryFilter(query, columnsOf(database));
|
|
71
|
+
const compiled = queryFilter(query, columnsOf(database), { zone: timezoneOf() });
|
|
71
72
|
if (compiled.sql) {
|
|
72
73
|
where.push(`AND (${compiled.sql}) `);
|
|
73
74
|
params = params.concat(compiled.params);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { defineQuery } from "@wirecat/cli-base/query";
|
|
2
|
+
import { defineQuery, timezoneOf } from "@wirecat/cli-base/query";
|
|
3
3
|
import { MENTION_KINDS, siteOf } from "../../domain/mentions.js";
|
|
4
4
|
import { findNames, nameIndex } from "../../domain/person-names.js";
|
|
5
5
|
import { createStemmer } from "../../search/stem.js";
|
|
@@ -130,7 +130,7 @@ export const listMentions = (database, accountPk, query, { limit, offset, foundA
|
|
|
130
130
|
params.push(foundAfter);
|
|
131
131
|
}
|
|
132
132
|
if (query) {
|
|
133
|
-
const compiled = queryFilter(query, columnsOf(database));
|
|
133
|
+
const compiled = queryFilter(query, columnsOf(database), { zone: timezoneOf() });
|
|
134
134
|
if (compiled.sql) {
|
|
135
135
|
where.push(`(${compiled.sql})`);
|
|
136
136
|
params.push(...compiled.params);
|
|
@@ -188,8 +188,13 @@ export const upsertMessage = (context, key, accountKey, chatKey, received, via,
|
|
|
188
188
|
orm.update(messages).set({ text: message.text }).where(eq(messages.id, pk)).run();
|
|
189
189
|
purgeVectorsOf(context, pk);
|
|
190
190
|
}
|
|
191
|
+
// Saved anew for `changes`: a reader told it was deleted must hear that it is back.
|
|
191
192
|
if (revived)
|
|
192
|
-
orm
|
|
193
|
+
orm
|
|
194
|
+
.update(messages)
|
|
195
|
+
.set({ deletedAt: null, text: message.text, createdAt: now() })
|
|
196
|
+
.where(eq(messages.id, pk))
|
|
197
|
+
.run();
|
|
193
198
|
}
|
|
194
199
|
const derived = derivedReactions(context, chatKey, message.id);
|
|
195
200
|
if (derived)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { tagOf } from "../../domain/tags.js";
|
|
3
|
+
import { fuseRanked } from "../../search/fusion.js";
|
|
3
4
|
import { compileAutomaton, foldRegex, wildcardPattern, } from "../../search/lucene/automaton.js";
|
|
4
5
|
import { isStemmed } from "../../search/lucene/resolved.js";
|
|
5
6
|
import { exhausted, outOfTime, QUERY_LIMITS, searchError } from "../../search/lucene/types.js";
|
|
@@ -44,7 +45,9 @@ const CORPORA = [
|
|
|
44
45
|
type: "document",
|
|
45
46
|
noun: "note",
|
|
46
47
|
fields: NOTE_FIELDS,
|
|
47
|
-
view
|
|
48
|
+
get view() {
|
|
49
|
+
return `(SELECT n.id, n.account_id AS folder_id, n.external_id AS path, n.title, coalesce(n.body, '') AS text, n.metadata, ${contextDocumentTime()} AS at, n.deleted_at FROM documents n)`;
|
|
50
|
+
},
|
|
48
51
|
words: "document_words",
|
|
49
52
|
stems: "document_stems",
|
|
50
53
|
live: "coalesce(json_extract(n.metadata, '$.catalog.active'), 1)=1",
|
|
@@ -68,21 +71,15 @@ const matchedRows = (context, query) => {
|
|
|
68
71
|
const chosen = CORPORA.filter(({ type }) => (query.source === undefined || (query.source === "file") === (type === "document")) &&
|
|
69
72
|
(!query.folderIds?.length || query.withInternal === true || type === "document"));
|
|
70
73
|
const idsOf = (type) => query.refs?.flatMap((ref) => (ref.startsWith(`${type}:`) ? [Number(ref.slice(type.length + 1))] : []));
|
|
71
|
-
const
|
|
74
|
+
const lists = chosen.map((corpus) => {
|
|
72
75
|
const ids = idsOf(corpus.type);
|
|
73
76
|
if (ids?.length === 0)
|
|
74
77
|
return [];
|
|
75
78
|
return searchCorpus(context, { ...query, ...(query.folderIds ? { accountIds: query.folderIds } : {}), ...(ids ? { ids } : {}) }, corpus);
|
|
76
79
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: (exactFirst ? Number(b.exact === true) - Number(a.exact === true) : 0) ||
|
|
81
|
-
Number(a.relevance === null) - Number(b.relevance === null) ||
|
|
82
|
-
(a.relevance ?? 0) - (b.relevance ?? 0) ||
|
|
83
|
-
(b.at ?? 0) - (a.at ?? 0) ||
|
|
84
|
-
a.id - b.id);
|
|
85
|
-
return rows;
|
|
80
|
+
if (query.newest)
|
|
81
|
+
return lists.flat().sort((a, b) => (b.at ?? 0) - (a.at ?? 0) || a.id - b.id);
|
|
82
|
+
return fuseRanked(lists, (row) => ({ exact: row.exact, ranked: row.relevance !== null, at: row.at ?? 0 }));
|
|
86
83
|
};
|
|
87
84
|
/** Notes matching a parsed query, by the same language as messages: files and written notes, merged. */
|
|
88
85
|
export const searchNotes = (context, query) => {
|
|
@@ -6,7 +6,7 @@ import type { AddedSources } from "./added-sources.js";
|
|
|
6
6
|
import { type DocumentMetadata } from "./document-metadata.js";
|
|
7
7
|
import { type ImportedDocuments } from "./imported-documents.js";
|
|
8
8
|
import { LINK_KINDS, LINK_ORIGINS, type LINK_SOURCES } from "./link-kinds.js";
|
|
9
|
-
export { linkOf, thingRef } from "./link-row.js";
|
|
9
|
+
export { hasBothEnds, linkOf, thingRef } from "./link-row.js";
|
|
10
10
|
import type { NoteSearch } from "./note-search.js";
|
|
11
11
|
import type { StoreContext } from "./open.js";
|
|
12
12
|
import { type Label } from "./tags.js";
|
|
@@ -155,6 +155,8 @@ export interface NotesStore extends NoteSearch, ImportedDocuments, AddedSources
|
|
|
155
155
|
note(reference: string): Promise<Note>;
|
|
156
156
|
resolveNote(reference: string): Promise<Note | undefined>;
|
|
157
157
|
noteReferences(reference: string): Promise<string[]>;
|
|
158
|
+
/** The live file note at this path of a folder or documents account, as `notes({ folderId })` lists it. */
|
|
159
|
+
fileNote(folderId: string, path: string): Promise<Note | undefined>;
|
|
158
160
|
notes(options?: {
|
|
159
161
|
folderId?: string;
|
|
160
162
|
source?: Note["source"];
|