@wirecat/cli-core 0.654.0 → 0.656.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 +48 -0
- package/dist/cli/messenger/search-answers.js +1 -0
- package/dist/domain/providers.js +2 -0
- package/dist/entities/hit.d.ts +2 -0
- package/dist/entities/hit.js +2 -0
- package/dist/entities/index.d.ts +7 -0
- package/dist/google/errors.d.ts +18 -0
- package/dist/google/errors.js +71 -0
- package/dist/google/index.d.ts +2 -0
- package/dist/google/index.js +2 -0
- package/dist/google/pages.d.ts +11 -0
- package/dist/google/pages.js +23 -0
- package/dist/kit/sync-after-install.js +13 -3
- package/dist/meetings/answers.d.ts +11 -1
- package/dist/meetings/answers.js +17 -0
- package/dist/meetings/index.d.ts +3 -3
- package/dist/meetings/index.js +1 -1
- package/dist/meetings/pull.js +3 -0
- package/dist/meetings/source.d.ts +3 -1
- package/dist/meetings/store.d.ts +24 -0
- package/dist/meetings/store.js +1 -0
- package/dist/meetings/transcript-store.d.ts +9 -1
- package/dist/oauth/requests.js +22 -4
- package/dist/services/search-all.d.ts +2 -0
- package/dist/services/search-all.js +30 -11
- package/dist/store/shared-config.js +2 -1
- package/dist/store/sqlite/meeting-documents.d.ts +13 -0
- package/dist/store/sqlite/meeting-documents.js +110 -0
- package/dist/store/sqlite/meetings.js +5 -2
- package/package.json +5 -1
- package/dist/store/sqlite/meeting-transcript-documents.d.ts +0 -10
- package/dist/store/sqlite/meeting-transcript-documents.js +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,54 @@ 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.656.0 — 13.11.2026
|
|
9
|
+
|
|
10
|
+
### Changed — may break callers
|
|
11
|
+
|
|
12
|
+
- **`syncAfterInstallCases` asks only "no `permission_error`" of a shared config that is not JSON or is a folder.** A
|
|
13
|
+
step that reads such a file may fail and name it; the other states must still exit 0.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **The shared config is read with a byte-order mark.** `~/.config/WireCat/config.json` saved by a Windows editor
|
|
18
|
+
starts with one; every reader of the file (setup's answer, task categories, models, search settings) refused it as
|
|
19
|
+
not JSON, and a sync that reads the meaning-search model ended incomplete.
|
|
20
|
+
|
|
21
|
+
## 0.655.0 — 13.11.2026
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`@wirecat/cli-core/google`**, what every Google API client shares: `googleError` turns a refusal into a
|
|
26
|
+
`CliError` by Google's reasons, with the codes and reasons gcal uses (`api.disabled`, `oauth.scope-missing`,
|
|
27
|
+
`provider.usage-limit`…) and never Google's own message; `service` names the API in messages. Calendar's
|
|
28
|
+
organizer-only refusal is the generic `access.denied` here; gcal keeps its own. `googlePages` reads every
|
|
29
|
+
`pageToken` page and refuses a repeated token or more than 1,000 pages with `invalid_response`.
|
|
30
|
+
- **A meeting's Drive documents** (`MeetingSave.documents`, `MeetingSource.documents`): a meeting tool names the
|
|
31
|
+
transcript, recording and notes files the service saved, by Drive file id. The store links them whichever arrives
|
|
32
|
+
first, Drive's import or the meeting, from any Drive profile, with no store migration. A file the service stops
|
|
33
|
+
listing stays linked. `meetings show` lists them as `documents[]`: `file_id`, `role`, `title` and `document`, the
|
|
34
|
+
stored `document:<id>` once Drive has the file, else `null`.
|
|
35
|
+
- **A `search all` document hit names its meeting** (`meeting`, `meeting:<account>/<id>`) when it is a meeting's
|
|
36
|
+
transcript, recording or notes and the search read the meeting's account. A listed transcript is shown once with its
|
|
37
|
+
meeting, as a `driveFileId` one is.
|
|
38
|
+
- **`google-meet` among the known providers** (meetings, from the `meet` tool).
|
|
39
|
+
|
|
40
|
+
### Changed — may break callers
|
|
41
|
+
|
|
42
|
+
- **`MeetingTranscriptDocumentStore` has a new method, `documentMeetings`**: the meeting each document is a
|
|
43
|
+
transcript, recording or notes of. The store implements it; a caller's own implementation of the interface adds it.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- **A meeting transcript's Drive file** (`TranscriptInput.driveFileId`): a new version now replaces only the link the
|
|
48
|
+
previous version of the same transcript source named. Before, it dropped every other transcript link of the
|
|
49
|
+
meeting, so two sources in one save kept one link. A version naming a file the meeting tool listed keeps that
|
|
50
|
+
file's role and title.
|
|
51
|
+
- **`account remove` finishes when Google already dropped the sign-in.** `revokeToken` took Google's HTTP 400
|
|
52
|
+
`invalid_token` answer, given for a grant that is no longer valid, as `outcome_unknown` (`oauth.revoke-failed`), so
|
|
53
|
+
the removal stopped with everything kept. That answer now counts as revoked, as RFC 7009 has such a token answered.
|
|
54
|
+
Every other failed answer still stops the removal.
|
|
55
|
+
|
|
8
56
|
## 0.654.0 — 13.11.2026
|
|
9
57
|
|
|
10
58
|
### Added
|
|
@@ -345,6 +345,7 @@ export const allHitItem = (item) => item.kind === "meeting"
|
|
|
345
345
|
external_id: item.sourceRecord.externalId,
|
|
346
346
|
},
|
|
347
347
|
attachments: item.attachments === undefined ? undefined : nonEmpty(item.attachments),
|
|
348
|
+
meeting: item.meeting,
|
|
348
349
|
untrusted: ALL_HIT_UNTRUSTED[item.kind],
|
|
349
350
|
});
|
|
350
351
|
/** Meaning was not searched because the model is not downloaded; `--exact` leaving it out is no gap. */
|
package/dist/domain/providers.js
CHANGED
|
@@ -19,6 +19,7 @@ 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
|
+
{ name: "google-meet", kind: "meetings", aliases: [], command: "meet" },
|
|
22
23
|
// Its meetings come from the notes Telemost mails (`keeper@telemost.yandex.ru`), read by a mail rule.
|
|
23
24
|
{ name: "telemost", kind: "meetings", aliases: [] },
|
|
24
25
|
// A phone export's records: its SMS and its calls in the one account the import names.
|
|
@@ -34,6 +35,7 @@ const LABELS = {
|
|
|
34
35
|
whatsapp: "WhatsApp",
|
|
35
36
|
"whatsapp-bot": "WhatsApp bot",
|
|
36
37
|
"google-drive": "Google Drive",
|
|
38
|
+
"google-meet": "Google Meet",
|
|
37
39
|
added: "added by hand",
|
|
38
40
|
email: "mail",
|
|
39
41
|
telemost: "Telemost",
|
package/dist/entities/hit.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare const hit: v.StrictObjectSchema<{
|
|
|
49
49
|
readonly account: v.StringSchema<undefined>;
|
|
50
50
|
readonly external_id: v.StringSchema<undefined>;
|
|
51
51
|
}, undefined>, undefined>;
|
|
52
|
+
/** A document's: the meeting it is the transcript, recording or notes of. */
|
|
53
|
+
readonly meeting: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
52
54
|
/** A message's files; absent when it has none. */
|
|
53
55
|
readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
54
56
|
readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
package/dist/entities/hit.js
CHANGED
|
@@ -45,6 +45,8 @@ export const hit = v.strictObject({
|
|
|
45
45
|
review: v.optional(v.picklist(["proposed", "confirmed"])),
|
|
46
46
|
/** A business hit's record in the import that made it; absent for one the owner or an agent wrote. */
|
|
47
47
|
source_record: v.optional(v.strictObject({ provider: text, account: text, external_id: text })),
|
|
48
|
+
/** A document's: the meeting it is the transcript, recording or notes of. */
|
|
49
|
+
meeting: v.optional(reference),
|
|
48
50
|
/** A message's files; absent when it has none. */
|
|
49
51
|
attachments: v.optional(v.array(hitFile)),
|
|
50
52
|
/** Absent on a note hit: the owner wrote it. */
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -4378,6 +4378,7 @@ export declare const ENTITIES: {
|
|
|
4378
4378
|
readonly account: v.StringSchema<undefined>;
|
|
4379
4379
|
readonly external_id: v.StringSchema<undefined>;
|
|
4380
4380
|
}, undefined>, undefined>;
|
|
4381
|
+
readonly meeting: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4381
4382
|
readonly attachments: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
4382
4383
|
readonly position: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
4383
4384
|
readonly kind: v.StringSchema<undefined>;
|
|
@@ -5498,6 +5499,12 @@ export declare const ENTITIES: {
|
|
|
5498
5499
|
readonly size: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
5499
5500
|
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5500
5501
|
}, undefined>, undefined>;
|
|
5502
|
+
readonly documents: v.ArraySchema<v.StrictObjectSchema<{
|
|
5503
|
+
readonly file_id: v.StringSchema<undefined>;
|
|
5504
|
+
readonly role: v.PicklistSchema<readonly ["transcript", "recording", "notes"], undefined>;
|
|
5505
|
+
readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5506
|
+
readonly document: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
5507
|
+
}, undefined>, undefined>;
|
|
5501
5508
|
}, undefined>;
|
|
5502
5509
|
readonly meeting_hit: v.StrictObjectSchema<{
|
|
5503
5510
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
export interface GoogleFailure {
|
|
3
|
+
status: number;
|
|
4
|
+
/** The answer's parsed JSON body, or anything else it held. */
|
|
5
|
+
body: unknown;
|
|
6
|
+
/** The request may have changed something: a 5xx then has no certain outcome. */
|
|
7
|
+
mutates: boolean;
|
|
8
|
+
retryAfterMs?: number | undefined;
|
|
9
|
+
/** The API as people know it, in messages: `Google Calendar`, `Google Meet`. `Google` when left out. */
|
|
10
|
+
service?: string;
|
|
11
|
+
/** The API's errors guide, named when the usage limits are exceeded. */
|
|
12
|
+
errorsGuide?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A Google API refusal as a CliError, from the answer's status and body. Google's own message is never repeated: it
|
|
16
|
+
* can quote the ids and text that were asked for (WC-SECR-6).
|
|
17
|
+
*/
|
|
18
|
+
export declare const googleError: ({ status, body, mutates, retryAfterMs, service, errorsGuide, }: GoogleFailure) => CliError;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { statusToCode } from "@wirecat/cli-base/http";
|
|
3
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
4
|
+
const reasonsOf = (body) => {
|
|
5
|
+
const error = isRecord(body) ? body.error : undefined;
|
|
6
|
+
if (!isRecord(error))
|
|
7
|
+
return [];
|
|
8
|
+
return [
|
|
9
|
+
...(Array.isArray(error.errors) ? error.errors.map((item) => item?.reason) : []),
|
|
10
|
+
...(Array.isArray(error.details)
|
|
11
|
+
? error.details
|
|
12
|
+
.filter((detail) => detail?.["@type"] === "type.googleapis.com/google.rpc.ErrorInfo")
|
|
13
|
+
.map((detail) => detail.reason)
|
|
14
|
+
: []),
|
|
15
|
+
error.status,
|
|
16
|
+
].filter((reason) => typeof reason === "string");
|
|
17
|
+
};
|
|
18
|
+
const RATE = new Set(["rateLimitExceeded", "userRateLimitExceeded", "RESOURCE_EXHAUSTED"]);
|
|
19
|
+
/**
|
|
20
|
+
* A Google API refusal as a CliError, from the answer's status and body. Google's own message is never repeated: it
|
|
21
|
+
* can quote the ids and text that were asked for (WC-SECR-6).
|
|
22
|
+
*/
|
|
23
|
+
export const googleError = ({ status, body, mutates, retryAfterMs, service = "Google", errorsGuide, }) => {
|
|
24
|
+
const reasons = reasonsOf(body);
|
|
25
|
+
const wait = retryAfterMs === undefined ? {} : { retry_after_ms: retryAfterMs };
|
|
26
|
+
if (status === 401)
|
|
27
|
+
return new CliError("authentication_error", "Google sign-in expired", {
|
|
28
|
+
reason: "oauth.expired",
|
|
29
|
+
status,
|
|
30
|
+
});
|
|
31
|
+
if (reasons.some((reason) => reason === "accessNotConfigured" || reason === "SERVICE_DISABLED"))
|
|
32
|
+
return new CliError("configuration_error", `the ${service} API is turned off for this OAuth project; its owner turns it on in Google Cloud API Library`, { reason: "api.disabled", status });
|
|
33
|
+
if (reasons.some((reason) => reason === "insufficientPermissions" || reason === "ACCESS_TOKEN_SCOPE_INSUFFICIENT"))
|
|
34
|
+
return new CliError("permission_error", "the sign-in lacks the Google permission this method needs", {
|
|
35
|
+
reason: "oauth.scope-missing",
|
|
36
|
+
status,
|
|
37
|
+
});
|
|
38
|
+
// Google answers it with the Workspace usage limits, not with a retry.
|
|
39
|
+
if (reasons.includes("quotaExceeded"))
|
|
40
|
+
return new CliError("rate_limited", `${service} usage limits are exceeded for this account; wait before trying again` +
|
|
41
|
+
(errorsGuide ? ` (${errorsGuide})` : ""), { reason: "provider.usage-limit", retryable: false, status });
|
|
42
|
+
if (status === 429 || reasons.some((reason) => RATE.has(reason)))
|
|
43
|
+
// Google turned the request away before acting on it, so even a write is safe to send again.
|
|
44
|
+
return new CliError("rate_limited", "Google rate limit reached; retry the command", {
|
|
45
|
+
retryable: true,
|
|
46
|
+
status,
|
|
47
|
+
...wait,
|
|
48
|
+
});
|
|
49
|
+
if (status >= 500)
|
|
50
|
+
return mutates
|
|
51
|
+
? new CliError("outcome_unknown", "Google write has no certain outcome; check Google before repeating it", {
|
|
52
|
+
retryable: false,
|
|
53
|
+
status,
|
|
54
|
+
})
|
|
55
|
+
: new CliError(statusToCode(status), `${service} failed (HTTP ${status}); retry the command`, {
|
|
56
|
+
retryable: true,
|
|
57
|
+
status,
|
|
58
|
+
...wait,
|
|
59
|
+
});
|
|
60
|
+
if (status === 403)
|
|
61
|
+
return new CliError("permission_error", `${service} denied this operation; check this account's access to it`, {
|
|
62
|
+
reason: "access.denied",
|
|
63
|
+
status,
|
|
64
|
+
});
|
|
65
|
+
if (status === 404)
|
|
66
|
+
return new CliError("not_found", `${service} has no such item, or this account cannot see it`, {
|
|
67
|
+
reason: "item.not-found",
|
|
68
|
+
status,
|
|
69
|
+
});
|
|
70
|
+
return new CliError(statusToCode(status), `${service} refused the request (HTTP ${status})`, { status });
|
|
71
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const GOOGLE_MAX_PAGES = 1000;
|
|
2
|
+
/** One page of a Google list, its items under the name `items` whatever the API calls them. */
|
|
3
|
+
export interface GooglePage<T> {
|
|
4
|
+
items?: readonly T[] | null;
|
|
5
|
+
nextPageToken?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Every page of one Google list, following `nextPageToken`. A repeated page token or a list past `maxPages` is
|
|
9
|
+
* Google's fault and stops the read with `invalid_response`, instead of looping forever.
|
|
10
|
+
*/
|
|
11
|
+
export declare const googlePages: <T>(what: string, read: (pageToken?: string) => Promise<GooglePage<T>>, maxPages?: number) => Promise<T[]>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
export const GOOGLE_MAX_PAGES = 1000;
|
|
3
|
+
/**
|
|
4
|
+
* Every page of one Google list, following `nextPageToken`. A repeated page token or a list past `maxPages` is
|
|
5
|
+
* Google's fault and stops the read with `invalid_response`, instead of looping forever.
|
|
6
|
+
*/
|
|
7
|
+
export const googlePages = async (what, read, maxPages = GOOGLE_MAX_PAGES) => {
|
|
8
|
+
const items = [];
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
let pageToken;
|
|
11
|
+
for (let page = 0; page < maxPages; page++) {
|
|
12
|
+
const answer = await read(pageToken);
|
|
13
|
+
for (const item of answer.items ?? [])
|
|
14
|
+
items.push(item);
|
|
15
|
+
if (!answer.nextPageToken)
|
|
16
|
+
return items;
|
|
17
|
+
if (seen.has(answer.nextPageToken))
|
|
18
|
+
throw new CliError("invalid_response", `Google repeated a page token of ${what}`);
|
|
19
|
+
seen.add(answer.nextPageToken);
|
|
20
|
+
pageToken = answer.nextPageToken;
|
|
21
|
+
}
|
|
22
|
+
throw new CliError("invalid_response", `Google listed ${what} past ${maxPages} pages`);
|
|
23
|
+
};
|
|
@@ -8,12 +8,20 @@ import { join } from "node:path";
|
|
|
8
8
|
*/
|
|
9
9
|
const SHARED_CONFIGS = [
|
|
10
10
|
{ state: "no shared config, as on a fresh install" },
|
|
11
|
-
{
|
|
11
|
+
{
|
|
12
|
+
state: "a shared config that is not JSON",
|
|
13
|
+
write: (dir) => writeFileSync(join(dir, "config.json"), "{ setup: "),
|
|
14
|
+
broken: true,
|
|
15
|
+
},
|
|
12
16
|
{
|
|
13
17
|
state: "a shared config with a byte-order mark",
|
|
14
18
|
write: (dir) => writeFileSync(join(dir, "config.json"), '{"setup":{"permissions":"allow"}}'),
|
|
15
19
|
},
|
|
16
|
-
{
|
|
20
|
+
{
|
|
21
|
+
state: "a folder where the shared config should be",
|
|
22
|
+
write: (dir) => mkdirSync(join(dir, "config.json")),
|
|
23
|
+
broken: true,
|
|
24
|
+
},
|
|
17
25
|
{
|
|
18
26
|
state: "a setup section in a shape this version does not take",
|
|
19
27
|
write: (dir) => writeFileSync(join(dir, "config.json"), JSON.stringify({ setup: { languages: ["en"], permissions: "ask" } })),
|
|
@@ -53,7 +61,9 @@ export const syncAfterInstallCases = (options) => {
|
|
|
53
61
|
run: async () => {
|
|
54
62
|
const ran = await cli(sync, shared);
|
|
55
63
|
assert.notEqual(errorCodeOf(ran.err), "permission_error", `sync was refused: ${ran.err}`);
|
|
56
|
-
|
|
64
|
+
// A file no reader can parse may fail a step that reads it, loudly and by name; it never restricts.
|
|
65
|
+
if (!shared.broken)
|
|
66
|
+
assert.equal(ran.code, 0, `sync exited ${ran.code}: ${ran.out}${ran.err}`);
|
|
57
67
|
},
|
|
58
68
|
})),
|
|
59
69
|
...(refusedUnderReadOnly
|
|
@@ -3,7 +3,7 @@ import * as v from "valibot";
|
|
|
3
3
|
import { type MeetingOwner } from "./item.js";
|
|
4
4
|
import type { Summary, Transcript, TranscriptRow } from "./model.js";
|
|
5
5
|
import type { MeetingSearchPage } from "./search-store.js";
|
|
6
|
-
import type
|
|
6
|
+
import { type MeetingDetails, type SearchHit } from "./store.js";
|
|
7
7
|
/** A passage `search meetings` found: a transcript cue, a chat line or a summary. */
|
|
8
8
|
export declare const meetingHit: v.StrictObjectSchema<{
|
|
9
9
|
/** The cue for a transcript passage, else the meeting. */
|
|
@@ -140,6 +140,16 @@ export declare const meetingDetails: v.StrictObjectSchema<{
|
|
|
140
140
|
readonly size: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
141
141
|
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
142
142
|
}, undefined>, undefined>;
|
|
143
|
+
/**
|
|
144
|
+
* The Drive files the meeting service saved for it, by role. `document` is the stored document (`document:<id>`) once
|
|
145
|
+
* a Drive profile has imported the file, else `null`: then `drive` can fetch it by `file_id`.
|
|
146
|
+
*/
|
|
147
|
+
readonly documents: v.ArraySchema<v.StrictObjectSchema<{
|
|
148
|
+
readonly file_id: v.StringSchema<undefined>;
|
|
149
|
+
readonly role: v.PicklistSchema<readonly ["transcript", "recording", "notes"], undefined>;
|
|
150
|
+
readonly title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
151
|
+
readonly document: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
152
|
+
}, undefined>, undefined>;
|
|
143
153
|
}, undefined>;
|
|
144
154
|
export type MeetingHitItem = v.InferOutput<typeof meetingHit>;
|
|
145
155
|
export type MeetingTranscriptItem = v.InferOutput<typeof meetingTranscript>;
|
package/dist/meetings/answers.js
CHANGED
|
@@ -2,6 +2,7 @@ import { defineSteps, isoTime, reference, STEPS, stepOf, } from "@wirecat/cli-ba
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
import { meeting, meetingItem } from "./item.js";
|
|
4
4
|
import { formatMeetingReference, parseMeetingReference } from "./reference.js";
|
|
5
|
+
import { MEETING_DOCUMENT_ROLES } from "./store.js";
|
|
5
6
|
const text = v.string();
|
|
6
7
|
const count = v.pipe(v.number(), v.integer(), v.minValue(0));
|
|
7
8
|
const iso = (ms) => (ms === null ? null : new Date(ms).toISOString());
|
|
@@ -93,6 +94,16 @@ export const meetingDetails = v.strictObject({
|
|
|
93
94
|
size: v.nullable(count),
|
|
94
95
|
url: v.nullable(text),
|
|
95
96
|
})),
|
|
97
|
+
/**
|
|
98
|
+
* The Drive files the meeting service saved for it, by role. `document` is the stored document (`document:<id>`) once
|
|
99
|
+
* a Drive profile has imported the file, else `null`: then `drive` can fetch it by `file_id`.
|
|
100
|
+
*/
|
|
101
|
+
documents: v.array(v.strictObject({
|
|
102
|
+
file_id: text,
|
|
103
|
+
role: v.picklist(MEETING_DOCUMENT_ROLES),
|
|
104
|
+
title: v.nullable(text),
|
|
105
|
+
document: v.nullable(reference),
|
|
106
|
+
})),
|
|
96
107
|
});
|
|
97
108
|
const meetingRef = (accountId, meetingId) => formatMeetingReference({ type: "meeting", accountId, meetingId });
|
|
98
109
|
export const meetingTranscriptItem = (accountId, transcript, rows) => ({
|
|
@@ -172,6 +183,12 @@ export const meetingDetailsItem = (details, owner) => {
|
|
|
172
183
|
size: one.size,
|
|
173
184
|
url: one.url,
|
|
174
185
|
})),
|
|
186
|
+
documents: (details.documents ?? []).map((one) => ({
|
|
187
|
+
file_id: one.fileId,
|
|
188
|
+
role: one.role,
|
|
189
|
+
title: one.title,
|
|
190
|
+
document: one.documentId === null ? null : `document:${one.documentId}`,
|
|
191
|
+
})),
|
|
175
192
|
};
|
|
176
193
|
};
|
|
177
194
|
/** A list read whole: every item on one page. */
|
package/dist/meetings/index.d.ts
CHANGED
|
@@ -52,10 +52,10 @@ export type { MeetingSeriesCandidate, MeetingSeriesInventoryPage, MeetingSeriesI
|
|
|
52
52
|
export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
|
|
53
53
|
export type { MeetingSource, SourceParticipant } from "./source.js";
|
|
54
54
|
export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, type MeetingCounts, type MeetingCountsGrouping, type MeetingCountsInput, type MeetingCountsMeeting, type MeetingCountsRow, type MeetingSpeakerStats, type MeetingStats, type MeetingStatsInput, type MeetingStatsRow, type MeetingStatsSelection, type MeetingStatsStore, type MeetingWeekStats, NO_SERIES, } from "./stats.js";
|
|
55
|
-
export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingFilter, MeetingHitSource, MeetingInput, MeetingParticipant, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
|
|
56
|
-
export { READ_BUDGET_EXCEEDED } from "./store.js";
|
|
55
|
+
export type { ChatInput, ContractCase, EventCandidateFilter, IdentityInput, MeetingDetails, MeetingDocument, MeetingDocumentInput, MeetingDocumentRole, MeetingFilter, MeetingHitSource, MeetingInput, MeetingParticipant, MeetingSave, MeetingStore, NewRecord, ParticipantInput, SearchHit, TranscriptInput, TranscriptLanguageFill, TranscriptRowInput, } from "./store.js";
|
|
56
|
+
export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED } from "./store.js";
|
|
57
57
|
export { meetingTimestamp } from "./timestamp.js";
|
|
58
|
-
export type { MeetingTranscriptDocumentStore, MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
|
|
58
|
+
export type { DocumentMeeting, MeetingTranscriptDocumentStore, MeetingTranscriptReceiptStore, MeetingTranscriptStore, TranscriptAppend, TranscriptAppendReceipt, UnlinkedTranscriptInput, } from "./transcript-store.js";
|
|
59
59
|
export { parseTranscriptText, TranscriptTextError, type TranscriptTextHeader } from "./transcript-text.js";
|
|
60
60
|
export { type MeetingMediaDescriptor, type MeetingRecognitionSegment, type MeetingTranscriptionContext, type MeetingTranscriptionOptions, type MeetingTranscriptionReceipt, type MeetingTranscriptionSource, transcribeMeeting, } from "./transcription.js";
|
|
61
61
|
export { createUpcomingMeetingReader } from "./upcoming.js";
|
package/dist/meetings/index.js
CHANGED
|
@@ -39,7 +39,7 @@ export { validateMeetingSeriesHistory, } from "./series-history.js";
|
|
|
39
39
|
export { createMeetingSeriesInventoryReader } from "./series-inventory.js";
|
|
40
40
|
export { validateMeetingSeriesInventoryCursor } from "./series-inventory-validation.js";
|
|
41
41
|
export { aggregateMeetingCounts, aggregateMeetingStats, MEETING_COUNTS_GROUPINGS, NO_SERIES, } from "./stats.js";
|
|
42
|
-
export { READ_BUDGET_EXCEEDED } from "./store.js";
|
|
42
|
+
export { MEETING_DOCUMENT_ROLES, READ_BUDGET_EXCEEDED } from "./store.js";
|
|
43
43
|
export { meetingTimestamp } from "./timestamp.js";
|
|
44
44
|
export { parseTranscriptText, TranscriptTextError } from "./transcript-text.js";
|
|
45
45
|
export { transcribeMeeting, } from "./transcription.js";
|
package/dist/meetings/pull.js
CHANGED
|
@@ -98,6 +98,8 @@ export const pull = async (source, store, options) => {
|
|
|
98
98
|
const chat = await read("chat", () => source.chat(id));
|
|
99
99
|
const summary = await read("summary", () => source.summary(id));
|
|
100
100
|
const attachments = await read("files", () => source.files(id));
|
|
101
|
+
const listDocuments = source.documents?.bind(source);
|
|
102
|
+
const documents = listDocuments ? await read("documents", () => listDocuments(id)) : undefined;
|
|
101
103
|
const startedAt = timestamp(m.occurrence.startedAt);
|
|
102
104
|
const endedAt = m.occurrence.endedAt === null ? null : timestamp(m.occurrence.endedAt);
|
|
103
105
|
if (endedAt !== null && endedAt < startedAt)
|
|
@@ -161,6 +163,7 @@ export const pull = async (source, store, options) => {
|
|
|
161
163
|
]
|
|
162
164
|
: undefined,
|
|
163
165
|
attachments: attachments ?? undefined,
|
|
166
|
+
documents: documents ?? undefined,
|
|
164
167
|
now,
|
|
165
168
|
});
|
|
166
169
|
// Without participants the rows cannot be linked: they are saved only when the meeting has no current
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Metadata, SourceChatLine, SourceMeeting, SummaryContent, TranscriptLine } from "./model.js";
|
|
2
|
-
import type { MeetingSave } from "./store.js";
|
|
2
|
+
import type { MeetingDocumentInput, MeetingSave } from "./store.js";
|
|
3
3
|
export interface SourceParticipant {
|
|
4
4
|
identityExternalId: string | null;
|
|
5
5
|
email: string | null;
|
|
@@ -38,4 +38,6 @@ export interface MeetingSource {
|
|
|
38
38
|
chat(occurrenceId: string): Promise<SourceChatLine[] | null>;
|
|
39
39
|
summary(occurrenceId: string): Promise<SummaryContent | null>;
|
|
40
40
|
files(occurrenceId: string): Promise<NonNullable<MeetingSave["attachments"]> | null>;
|
|
41
|
+
/** The Drive files the service saved for the occurrence: its transcript, recording and notes documents. */
|
|
42
|
+
documents?(occurrenceId: string): Promise<MeetingDocumentInput[] | null>;
|
|
41
43
|
}
|
package/dist/meetings/store.d.ts
CHANGED
|
@@ -28,6 +28,26 @@ export interface TranscriptInput extends Omit<NewRecord<Transcript>, "meetingId"
|
|
|
28
28
|
*/
|
|
29
29
|
driveFileId?: string;
|
|
30
30
|
}
|
|
31
|
+
export declare const MEETING_DOCUMENT_ROLES: readonly ["transcript", "recording", "notes"];
|
|
32
|
+
export type MeetingDocumentRole = (typeof MEETING_DOCUMENT_ROLES)[number];
|
|
33
|
+
/**
|
|
34
|
+
* A Drive file the meeting service saved for the meeting: its transcript, its recording or its notes (Meet's
|
|
35
|
+
* `docsDestination.document`, `driveDestination.file`, Gemini's notes). Keyed by the Drive file id alone, so the Drive
|
|
36
|
+
* profile that imports the file may differ from the meeting's.
|
|
37
|
+
*/
|
|
38
|
+
export interface MeetingDocumentInput {
|
|
39
|
+
fileId: string;
|
|
40
|
+
role: MeetingDocumentRole;
|
|
41
|
+
title?: string | null;
|
|
42
|
+
}
|
|
43
|
+
/** A meeting's Drive file, and the document it is once a Drive account has stored it. */
|
|
44
|
+
export interface MeetingDocument {
|
|
45
|
+
fileId: string;
|
|
46
|
+
role: MeetingDocumentRole;
|
|
47
|
+
title: string | null;
|
|
48
|
+
/** `null` while no Drive account holds the file, while two do (CORE-54), or while its document is deleted. */
|
|
49
|
+
documentId: number | null;
|
|
50
|
+
}
|
|
31
51
|
export interface ChatInput extends Omit<NewRecord<ChatLine>, "meetingId" | "senderParticipantId"> {
|
|
32
52
|
senderParticipantPosition: number | null;
|
|
33
53
|
}
|
|
@@ -43,6 +63,8 @@ export interface MeetingSave {
|
|
|
43
63
|
chat?: ChatInput[];
|
|
44
64
|
summaries?: Omit<NewRecord<Summary>, "meetingId">[];
|
|
45
65
|
attachments?: Omit<NewRecord<Attachment>, "attachableType" | "attachableId">[];
|
|
66
|
+
/** Adds to the documents held and retitles them; one left out stays linked, since the service forgets its files. */
|
|
67
|
+
documents?: MeetingDocumentInput[];
|
|
46
68
|
now: number;
|
|
47
69
|
/**
|
|
48
70
|
* A copy of the occurrence read from a file, not from the provider. It joins the provider's record of the same
|
|
@@ -69,6 +91,8 @@ export interface MeetingDetails {
|
|
|
69
91
|
chat: ChatLine[];
|
|
70
92
|
summaries: Summary[];
|
|
71
93
|
attachments: Attachment[];
|
|
94
|
+
/** Left out by a store that keeps no Drive links. */
|
|
95
|
+
documents?: MeetingDocument[];
|
|
72
96
|
}
|
|
73
97
|
export interface MeetingFilter {
|
|
74
98
|
accountId?: number;
|
package/dist/meetings/store.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
export const MEETING_DOCUMENT_ROLES = ["transcript", "recording", "notes"];
|
|
1
2
|
/** `searchHits`' refusal of a page whose stored text passes `maxReadBytes`; a reader may ask for fewer rows. */
|
|
2
3
|
export const READ_BUDGET_EXCEEDED = "Meeting search exceeds its stored text byte budget";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MeetingDetails, TranscriptInput, TranscriptRowInput } from "./store.js";
|
|
1
|
+
import type { MeetingDetails, MeetingDocumentRole, TranscriptInput, TranscriptRowInput } from "./store.js";
|
|
2
2
|
export type UnlinkedTranscriptInput = Omit<TranscriptInput, "rows" | "contentHash"> & {
|
|
3
3
|
contentHash: string;
|
|
4
4
|
rows: Omit<TranscriptRowInput, "speakerParticipantPosition">[];
|
|
@@ -35,7 +35,15 @@ export interface TranscriptAppendReceipt {
|
|
|
35
35
|
export interface MeetingTranscriptReceiptStore {
|
|
36
36
|
appendTranscriptsWithReceipt(input: TranscriptAppend): Promise<TranscriptAppendReceipt>;
|
|
37
37
|
}
|
|
38
|
+
/** The meeting a Drive document belongs to, and as what. */
|
|
39
|
+
export interface DocumentMeeting {
|
|
40
|
+
meetingId: number;
|
|
41
|
+
accountId: number;
|
|
42
|
+
role: MeetingDocumentRole;
|
|
43
|
+
}
|
|
38
44
|
/** The meeting whose transcript a Drive document is, by the `driveFileId` the meeting's transcript named. */
|
|
39
45
|
export interface MeetingTranscriptDocumentStore {
|
|
40
46
|
transcriptMeetings(documentIds: readonly number[]): Promise<Map<number, number>>;
|
|
47
|
+
/** The meeting each document is a transcript, recording or notes of; a document of two meetings names the first. */
|
|
48
|
+
documentMeetings(documentIds: readonly number[]): Promise<Map<number, DocumentMeeting>>;
|
|
41
49
|
}
|
package/dist/oauth/requests.js
CHANGED
|
@@ -108,6 +108,20 @@ const exchangeTokens = async (provider, params, context, deadline) => {
|
|
|
108
108
|
...(tokenType ? { tokenType } : {}),
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Google answers 400 `invalid_token` for a grant the owner or Google already took back: nothing is left to revoke.
|
|
113
|
+
* RFC 7009 §2.2 has such a token answered 200; this is the same outcome said another way.
|
|
114
|
+
*/
|
|
115
|
+
const alreadyRevoked = async (response) => {
|
|
116
|
+
if (response.status !== 400)
|
|
117
|
+
return false;
|
|
118
|
+
try {
|
|
119
|
+
return object(JSON.parse(await response.text())).error === "invalid_token";
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
111
125
|
/** Revokes the refresh token at `revokeUrl`. A provider without one, or with another method, declares `revoke`. */
|
|
112
126
|
export const revokeToken = async (provider, tokens, context) => {
|
|
113
127
|
if (provider.revoke)
|
|
@@ -116,16 +130,20 @@ export const revokeToken = async (provider, tokens, context) => {
|
|
|
116
130
|
throw new CliError("validation_error", `${provider.name} declares no way to revoke a sign-in`);
|
|
117
131
|
const { revokeUrl } = provider;
|
|
118
132
|
const form = new URLSearchParams({ token: tokens.refreshToken, ...clientFields(context) });
|
|
119
|
-
const response = await withTimeLimit(REQUEST_LIMIT_MS, (deadline) =>
|
|
120
|
-
|
|
133
|
+
const { response, gone } = await withTimeLimit(REQUEST_LIMIT_MS, async (deadline) => {
|
|
134
|
+
const response = await post(revokeUrl, form, context, deadline);
|
|
135
|
+
return { response, gone: response ? await alreadyRevoked(response) : false };
|
|
136
|
+
});
|
|
137
|
+
const done = response?.ok || gone;
|
|
138
|
+
context.log?.[done ? "info" : "warn"]({
|
|
121
139
|
event: TOKEN_LOG_EVENT,
|
|
122
140
|
provider: provider.id,
|
|
123
141
|
operation: "revoke",
|
|
124
142
|
pid: process.pid,
|
|
125
|
-
outcome: response?.ok ? "revoked" : response ? "rejected" : "no_response",
|
|
143
|
+
outcome: response?.ok ? "revoked" : gone ? "already_revoked" : response ? "rejected" : "no_response",
|
|
126
144
|
...(response ? { status: response.status } : {}),
|
|
127
145
|
});
|
|
128
|
-
if (!
|
|
146
|
+
if (!done)
|
|
129
147
|
throw new CliError("outcome_unknown", `${provider.name} did not confirm the revoke`, {
|
|
130
148
|
reason: "oauth.revoke-failed",
|
|
131
149
|
...(response ? { status: response.status } : {}),
|
|
@@ -51,6 +51,8 @@ export interface SearchAllRecordItem {
|
|
|
51
51
|
review?: "proposed" | "confirmed";
|
|
52
52
|
/** A business hit's source record, when an import made it. */
|
|
53
53
|
sourceRecord?: BusinessSource;
|
|
54
|
+
/** A document's: the meeting it is the transcript, recording or notes of (`meeting:<account>/<meeting>`). */
|
|
55
|
+
meeting?: string;
|
|
54
56
|
}
|
|
55
57
|
/** One account a search read, by the kind it was read for: the shape memo's `search all` answers too. */
|
|
56
58
|
export interface SearchedAccount {
|
|
@@ -6,6 +6,7 @@ import { senderIsMe } from "../domain/models.js";
|
|
|
6
6
|
import { holdsKind, INTERNAL_NOTES } from "../domain/providers.js";
|
|
7
7
|
import { runEmbedders } from "../embeddings/embed.js";
|
|
8
8
|
import { chosenTextModel } from "../embeddings/models.js";
|
|
9
|
+
import { formatMeetingReference } from "../meetings/index.js";
|
|
9
10
|
import { entriesOfList, fitting, listedHolds } from "../search/account-list.js";
|
|
10
11
|
import { plainQuery } from "../search/lucene/plain.js";
|
|
11
12
|
import { MESSAGE_PARSING, SEARCH_QUERY } from "../search/lucene/types.js";
|
|
@@ -143,6 +144,7 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
143
144
|
/** Each hit found by meaning, by its cosine: one model for every source, so these compare across them. */
|
|
144
145
|
const cosines = new Map();
|
|
145
146
|
let coverage;
|
|
147
|
+
const meetingAccountsRead = new Set();
|
|
146
148
|
let meetings;
|
|
147
149
|
const messagesOf = async (kind) => {
|
|
148
150
|
const given = scope?.[kind];
|
|
@@ -382,6 +384,8 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
382
384
|
continue;
|
|
383
385
|
hasMore ||= found.hasMore;
|
|
384
386
|
meetings = found.coverage;
|
|
387
|
+
for (const { id } of found.read)
|
|
388
|
+
meetingAccountsRead.add(id);
|
|
385
389
|
lists.push(found.items);
|
|
386
390
|
for (const { provider, account } of found.read)
|
|
387
391
|
accounts.push({ resource, provider, account });
|
|
@@ -400,7 +404,7 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
400
404
|
finally {
|
|
401
405
|
await embedders.close();
|
|
402
406
|
}
|
|
403
|
-
let ordered = insidePeriodFirst(oneList(await
|
|
407
|
+
let ordered = insidePeriodFirst(oneList(await withMeetingDocuments(store, lists, meetingAccountsRead), cosines), period);
|
|
404
408
|
let harder;
|
|
405
409
|
if (request.harder) {
|
|
406
410
|
const asking = {
|
|
@@ -443,22 +447,37 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
443
447
|
};
|
|
444
448
|
};
|
|
445
449
|
/**
|
|
446
|
-
* A meeting's transcript
|
|
447
|
-
*
|
|
450
|
+
* A document that is a meeting's transcript, recording or notes names that meeting, when this search read the
|
|
451
|
+
* meeting's account: a search that may not read meetings, or not that account, never learns of it. A transcript that Drive also
|
|
452
|
+
* imported as a document is one thing with its meeting: when the meeting is among the hits, the document's hit is
|
|
453
|
+
* dropped. Alone, the document stays, so nothing found is lost.
|
|
448
454
|
*/
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
if (!meetings.size)
|
|
455
|
+
const withMeetingDocuments = async (store, lists, read) => {
|
|
456
|
+
if (!read.size)
|
|
452
457
|
return lists;
|
|
453
458
|
const documentOf = (item) => item.kind === "document" && /^document:\d+$/.test(item.ref) ? Number(item.ref.slice("document:".length)) : undefined;
|
|
454
459
|
const documents = lists.flat().flatMap((item) => documentOf(item) ?? []);
|
|
455
|
-
|
|
456
|
-
|
|
460
|
+
if (!documents.length)
|
|
461
|
+
return lists;
|
|
462
|
+
const owners = await store.meetings.documentMeetings(documents);
|
|
463
|
+
if (!owners.size)
|
|
457
464
|
return lists;
|
|
458
|
-
|
|
465
|
+
const meetings = new Set(lists.flat().flatMap((item) => (item.kind === "meeting" ? [item.meetingId] : [])));
|
|
466
|
+
return lists.map((list) => list.flatMap((item) => {
|
|
459
467
|
const document = documentOf(item);
|
|
460
|
-
const
|
|
461
|
-
|
|
468
|
+
const owner = document === undefined ? undefined : owners.get(document);
|
|
469
|
+
if (owner === undefined || item.kind === "meeting")
|
|
470
|
+
return [item];
|
|
471
|
+
if (owner.role === "transcript" && meetings.has(owner.meetingId))
|
|
472
|
+
return [];
|
|
473
|
+
if (!read.has(owner.accountId))
|
|
474
|
+
return [item];
|
|
475
|
+
return [
|
|
476
|
+
{
|
|
477
|
+
...item,
|
|
478
|
+
meeting: formatMeetingReference({ type: "meeting", accountId: owner.accountId, meetingId: owner.meetingId }),
|
|
479
|
+
},
|
|
480
|
+
];
|
|
462
481
|
}));
|
|
463
482
|
};
|
|
464
483
|
/** Passages of one meeting share its `ref`, the reference evidence cites; each is still a hit of its own. */
|
|
@@ -28,7 +28,8 @@ const readJson = (path) => {
|
|
|
28
28
|
}
|
|
29
29
|
let parsed;
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
// Windows editors save JSON with a byte-order mark, which JSON.parse refuses.
|
|
32
|
+
parsed = JSON.parse(text.replace(/^\uFEFF/u, ""));
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
35
|
throw new CliError("configuration_error", `${path} is not valid JSON: ${error.message}`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type MeetingDocument, type MeetingDocumentInput, type MeetingTranscriptDocumentStore } from "../../meetings/index.js";
|
|
2
|
+
import type { CacheDatabase } from "../driver.js";
|
|
3
|
+
import type { StoreContext } from "./open.js";
|
|
4
|
+
/** A file the meeting's source listed. Listed links only grow: a file left out of a later list stays linked. */
|
|
5
|
+
export declare const attachListedDocument: (database: CacheDatabase, meetingId: number, { fileId, role, title }: MeetingDocumentInput, now: number) => void;
|
|
6
|
+
/**
|
|
7
|
+
* The file one transcript source saved its transcript as. A new version (`replaces`) drops the links an earlier
|
|
8
|
+
* version of the same source named, never a listed link or another source's; a replay of an old version keeps them.
|
|
9
|
+
*/
|
|
10
|
+
export declare const attachTranscriptFile: (database: CacheDatabase, meetingId: number, fileId: string, source: string, now: number, replaces: boolean) => void;
|
|
11
|
+
/** The meeting's Drive files, in the order they were first named. */
|
|
12
|
+
export declare const meetingDocumentsOf: (database: CacheDatabase, meetingId: number) => MeetingDocument[];
|
|
13
|
+
export declare const meetingTranscriptDocumentsOver: ({ database }: StoreContext) => MeetingTranscriptDocumentStore;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { MEETING_DOCUMENT_ROLES, } from "../../meetings/index.js";
|
|
2
|
+
import { fromJson, int, str } from "./events.js";
|
|
3
|
+
import { driveDocumentOf, driveFileTarget } from "./files.js";
|
|
4
|
+
import { read } from "./transaction.js";
|
|
5
|
+
const TRANSCRIPT_ROLE = "transcript";
|
|
6
|
+
const roleOf = (value) => MEETING_DOCUMENT_ROLES.find((role) => role === value);
|
|
7
|
+
/**
|
|
8
|
+
* The meeting's Drive file as an `attached` link to the file's document, waiting by its Drive id when Drive has not
|
|
9
|
+
* stored it yet. Drive's later import resolves it (`linkAttached`), so either order ends in one link.
|
|
10
|
+
*
|
|
11
|
+
* Metadata tells who named the file: `{ listed: true, title? }` the source's list (`MeetingSave.documents`), or
|
|
12
|
+
* `{ source }` a transcript version (`TranscriptInput.driveFileId`). A listing wins: it sets the role and title, and a
|
|
13
|
+
* transcript version never changes a listed link.
|
|
14
|
+
*/
|
|
15
|
+
const attach = (database, meetingId, fileId, role, metadata, listed, now) => {
|
|
16
|
+
const target = driveFileTarget(fileId);
|
|
17
|
+
const held = database
|
|
18
|
+
.prepare("SELECT id, to_id, role, metadata FROM links WHERE from_type = 'meeting' AND from_id = ? AND kind = 'attached' " +
|
|
19
|
+
"AND target_text = ?")
|
|
20
|
+
.get(meetingId, target);
|
|
21
|
+
if (!held) {
|
|
22
|
+
database
|
|
23
|
+
.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, source, target_text, role, metadata, confirmed,
|
|
24
|
+
author, created_at, updated_at) VALUES ('meeting', ?, 'document', ?, 'attached', 'meeting', ?, ?, ?, 1, 'rule',
|
|
25
|
+
?, ?)`)
|
|
26
|
+
.run(meetingId, driveDocumentOf(database, fileId), target, role, metadata, now, now);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const document = held.to_id == null ? driveDocumentOf(database, fileId) : int(held.to_id);
|
|
30
|
+
const nextRole = listed ? role : str(held.role);
|
|
31
|
+
const nextMetadata = listed ? metadata : str(held.metadata);
|
|
32
|
+
database
|
|
33
|
+
.prepare("UPDATE links SET to_id = ?, role = ?, metadata = ?, updated_at = ? WHERE id = ? " +
|
|
34
|
+
"AND (to_id IS NOT ? OR role IS NOT ? OR metadata IS NOT ?)")
|
|
35
|
+
.run(document, nextRole, nextMetadata, now, Number(held.id), document, nextRole, nextMetadata);
|
|
36
|
+
};
|
|
37
|
+
/** A file the meeting's source listed. Listed links only grow: a file left out of a later list stays linked. */
|
|
38
|
+
export const attachListedDocument = (database, meetingId, { fileId, role, title }, now) => {
|
|
39
|
+
const file = fileId.trim();
|
|
40
|
+
if (file)
|
|
41
|
+
attach(database, meetingId, file, role, JSON.stringify({ listed: true, ...(title ? { title } : {}) }), true, now);
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The file one transcript source saved its transcript as. A new version (`replaces`) drops the links an earlier
|
|
45
|
+
* version of the same source named, never a listed link or another source's; a replay of an old version keeps them.
|
|
46
|
+
*/
|
|
47
|
+
export const attachTranscriptFile = (database, meetingId, fileId, source, now, replaces) => {
|
|
48
|
+
const file = fileId.trim();
|
|
49
|
+
if (!file)
|
|
50
|
+
return;
|
|
51
|
+
if (replaces)
|
|
52
|
+
database
|
|
53
|
+
.prepare("DELETE FROM links WHERE from_type = 'meeting' AND from_id = ? AND kind = 'attached' AND role = ? " +
|
|
54
|
+
"AND target_text <> ? AND json_extract(metadata, '$.source') = ? AND json_extract(metadata, '$.listed') IS NULL")
|
|
55
|
+
.run(meetingId, TRANSCRIPT_ROLE, driveFileTarget(file), source);
|
|
56
|
+
attach(database, meetingId, file, TRANSCRIPT_ROLE, JSON.stringify({ source }), false, now);
|
|
57
|
+
};
|
|
58
|
+
/** The meeting's Drive files, in the order they were first named. */
|
|
59
|
+
export const meetingDocumentsOf = (database, meetingId) => database
|
|
60
|
+
.prepare("SELECT l.target_text, l.role, l.metadata, CASE WHEN d.deleted_at IS NULL THEN l.to_id END AS to_id " +
|
|
61
|
+
"FROM links l LEFT JOIN documents d ON d.id = l.to_id WHERE l.from_type = 'meeting' AND l.from_id = ? " +
|
|
62
|
+
"AND l.kind = 'attached' AND l.to_type = 'document' ORDER BY l.id")
|
|
63
|
+
.all(meetingId)
|
|
64
|
+
.flatMap((row) => {
|
|
65
|
+
const role = roleOf(row.role);
|
|
66
|
+
return role === undefined
|
|
67
|
+
? []
|
|
68
|
+
: [
|
|
69
|
+
{
|
|
70
|
+
fileId: String(row.target_text).slice(driveFileTarget("").length),
|
|
71
|
+
role,
|
|
72
|
+
title: str(fromJson(row.metadata)?.title),
|
|
73
|
+
documentId: int(row.to_id),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
});
|
|
77
|
+
export const meetingTranscriptDocumentsOver = ({ database }) => {
|
|
78
|
+
const meetingsOf = (documentIds, roles) => read(database, () => {
|
|
79
|
+
const rows = database
|
|
80
|
+
.prepare(`SELECT l.to_id AS document_id, l.from_id AS meeting_id, m.account_id, l.role FROM links l
|
|
81
|
+
JOIN meetings m ON m.id = l.from_id
|
|
82
|
+
WHERE l.kind = 'attached' AND l.from_type = 'meeting' AND l.to_type = 'document'
|
|
83
|
+
AND l.role IN (SELECT value FROM json_each(?)) AND m.deleted_at IS NULL
|
|
84
|
+
AND l.to_id IN (SELECT value FROM json_each(?))
|
|
85
|
+
ORDER BY l.role = ? DESC, l.id`)
|
|
86
|
+
.all(JSON.stringify(roles), JSON.stringify(documentIds), TRANSCRIPT_ROLE);
|
|
87
|
+
const found = new Map();
|
|
88
|
+
for (const row of rows) {
|
|
89
|
+
const role = roleOf(row.role);
|
|
90
|
+
if (role !== undefined && !found.has(Number(row.document_id)))
|
|
91
|
+
found.set(Number(row.document_id), {
|
|
92
|
+
meetingId: Number(row.meeting_id),
|
|
93
|
+
accountId: Number(row.account_id),
|
|
94
|
+
role,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return found;
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
async transcriptMeetings(documentIds) {
|
|
101
|
+
if (!documentIds.length)
|
|
102
|
+
return new Map();
|
|
103
|
+
const found = await meetingsOf(documentIds, [TRANSCRIPT_ROLE]);
|
|
104
|
+
return new Map([...found].map(([document, { meetingId }]) => [document, meetingId]));
|
|
105
|
+
},
|
|
106
|
+
async documentMeetings(documentIds) {
|
|
107
|
+
return documentIds.length ? meetingsOf(documentIds, MEETING_DOCUMENT_ROLES) : new Map();
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -8,6 +8,7 @@ import { meetingIdentityPk } from "./identities.js";
|
|
|
8
8
|
import { reviewLink } from "./link-reviews.js";
|
|
9
9
|
import { meetingChatLinesOver } from "./meeting-chat-lines.js";
|
|
10
10
|
import { meetingContextLinksOver } from "./meeting-context-links.js";
|
|
11
|
+
import { attachListedDocument, attachTranscriptFile, meetingDocumentsOf, meetingTranscriptDocumentsOver, } from "./meeting-documents.js";
|
|
11
12
|
import { meetingHitIndexOver } from "./meeting-hit-index.js";
|
|
12
13
|
import { meetingHitSearchOver } from "./meeting-hit-search.js";
|
|
13
14
|
import { INDEX_CODES, indexedText, meetingRowid, summaryOf } from "./meeting-index-values.js";
|
|
@@ -22,7 +23,6 @@ import { meetingReviewOver } from "./meeting-review.js";
|
|
|
22
23
|
import { meetingSeriesHistoryOver } from "./meeting-series-history.js";
|
|
23
24
|
import { meetingStatsOver } from "./meeting-stats.js";
|
|
24
25
|
import { invalidateMeetingStems } from "./meeting-stem-state.js";
|
|
25
|
-
import { attachTranscriptDocument, meetingTranscriptDocumentsOver } from "./meeting-transcript-documents.js";
|
|
26
26
|
import { meetingOf, transcriptOf, transcriptRowOf } from "./meeting-values.js";
|
|
27
27
|
import { linkPhones } from "./person-match-scan.js";
|
|
28
28
|
import { queryFilter } from "./query-filter.js";
|
|
@@ -134,6 +134,7 @@ const details = (database, id) => {
|
|
|
134
134
|
.prepare("SELECT * FROM attachments WHERE attachable_type = 'meeting' AND attachable_id = ? ORDER BY position")
|
|
135
135
|
.all(id)
|
|
136
136
|
.map(attachmentOf),
|
|
137
|
+
documents: meetingDocumentsOf(database, id),
|
|
137
138
|
};
|
|
138
139
|
};
|
|
139
140
|
/** Inserts or updates the row the key finds; `values` are the columns besides the key and the times. */
|
|
@@ -332,6 +333,8 @@ const save = (context, input) => {
|
|
|
332
333
|
}, now);
|
|
333
334
|
for (const a of input.attachments ?? [])
|
|
334
335
|
saveAttachment(database, "meeting", meetingId, a, now);
|
|
336
|
+
for (const document of input.documents ?? [])
|
|
337
|
+
attachListedDocument(database, meetingId, document, now);
|
|
335
338
|
return meetingId;
|
|
336
339
|
};
|
|
337
340
|
const saveTranscripts = (database, meetingId, transcripts, participantId, now) => {
|
|
@@ -346,7 +349,7 @@ const saveTranscripts = (database, meetingId, transcripts, participantId, now) =
|
|
|
346
349
|
for (const { rows, driveFileId, ...t } of transcripts) {
|
|
347
350
|
const replayed = t.contentHash !== null && Boolean(sameContent.get(meetingId, t.source, t.contentHash));
|
|
348
351
|
if (driveFileId !== undefined)
|
|
349
|
-
|
|
352
|
+
attachTranscriptFile(database, meetingId, driveFileId, t.source, now, !replayed);
|
|
350
353
|
if (replayed) {
|
|
351
354
|
counts.replayedTranscripts++;
|
|
352
355
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.656.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",
|
|
@@ -187,6 +187,10 @@
|
|
|
187
187
|
"types": "./dist/sftp/index.d.ts",
|
|
188
188
|
"default": "./dist/sftp/index.js"
|
|
189
189
|
},
|
|
190
|
+
"./google": {
|
|
191
|
+
"types": "./dist/google/index.d.ts",
|
|
192
|
+
"default": "./dist/google/index.js"
|
|
193
|
+
},
|
|
190
194
|
"./oauth": {
|
|
191
195
|
"types": "./dist/oauth/index.d.ts",
|
|
192
196
|
"default": "./dist/oauth/index.js"
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { MeetingTranscriptDocumentStore } from "../../meetings/index.js";
|
|
2
|
-
import type { CacheDatabase } from "../driver.js";
|
|
3
|
-
import type { StoreContext } from "./open.js";
|
|
4
|
-
/**
|
|
5
|
-
* The meeting's transcript is this Drive file: an `attached` link to the file's document, waiting by its Drive id when
|
|
6
|
-
* Drive has not stored it yet. Drive's later import resolves it (`linkAttached`), so either order ends in one link.
|
|
7
|
-
* A new transcript version that names another file replaces the old link; a replay of an old version keeps it.
|
|
8
|
-
*/
|
|
9
|
-
export declare const attachTranscriptDocument: (database: CacheDatabase, meetingId: number, fileId: string, now: number, replaces: boolean) => void;
|
|
10
|
-
export declare const meetingTranscriptDocumentsOver: ({ database }: StoreContext) => MeetingTranscriptDocumentStore;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { driveDocumentOf, driveFileTarget } from "./files.js";
|
|
2
|
-
import { read } from "./transaction.js";
|
|
3
|
-
const TRANSCRIPT_ROLE = "transcript";
|
|
4
|
-
/**
|
|
5
|
-
* The meeting's transcript is this Drive file: an `attached` link to the file's document, waiting by its Drive id when
|
|
6
|
-
* Drive has not stored it yet. Drive's later import resolves it (`linkAttached`), so either order ends in one link.
|
|
7
|
-
* A new transcript version that names another file replaces the old link; a replay of an old version keeps it.
|
|
8
|
-
*/
|
|
9
|
-
export const attachTranscriptDocument = (database, meetingId, fileId, now, replaces) => {
|
|
10
|
-
const file = fileId.trim();
|
|
11
|
-
if (!file)
|
|
12
|
-
return;
|
|
13
|
-
const target = driveFileTarget(file);
|
|
14
|
-
if (replaces)
|
|
15
|
-
database
|
|
16
|
-
.prepare("DELETE FROM links WHERE from_type = 'meeting' AND from_id = ? AND kind = 'attached' AND role = ? " +
|
|
17
|
-
"AND target_text <> ?")
|
|
18
|
-
.run(meetingId, TRANSCRIPT_ROLE, target);
|
|
19
|
-
const held = database
|
|
20
|
-
.prepare("SELECT id, to_id FROM links WHERE from_type = 'meeting' AND from_id = ? AND kind = 'attached' AND target_text = ?")
|
|
21
|
-
.get(meetingId, target);
|
|
22
|
-
if (!held) {
|
|
23
|
-
database
|
|
24
|
-
.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, source, target_text, role, confirmed, author,
|
|
25
|
-
created_at, updated_at) VALUES ('meeting', ?, 'document', ?, 'attached', 'meeting', ?, ?, 1, 'rule', ?, ?)`)
|
|
26
|
-
.run(meetingId, driveDocumentOf(database, file), target, TRANSCRIPT_ROLE, now, now);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (held.to_id != null)
|
|
30
|
-
return;
|
|
31
|
-
const document = driveDocumentOf(database, file);
|
|
32
|
-
if (document !== null)
|
|
33
|
-
database.prepare("UPDATE links SET to_id = ?, updated_at = ? WHERE id = ?").run(document, now, Number(held.id));
|
|
34
|
-
};
|
|
35
|
-
export const meetingTranscriptDocumentsOver = ({ database }) => ({
|
|
36
|
-
async transcriptMeetings(documentIds) {
|
|
37
|
-
if (!documentIds.length)
|
|
38
|
-
return new Map();
|
|
39
|
-
return read(database, () => {
|
|
40
|
-
const rows = database
|
|
41
|
-
.prepare(`SELECT l.to_id AS document_id, l.from_id AS meeting_id FROM links l JOIN meetings m ON m.id = l.from_id
|
|
42
|
-
WHERE l.kind = 'attached' AND l.from_type = 'meeting' AND l.to_type = 'document' AND l.role = ?
|
|
43
|
-
AND m.deleted_at IS NULL AND l.to_id IN (SELECT value FROM json_each(?)) ORDER BY l.id`)
|
|
44
|
-
.all(TRANSCRIPT_ROLE, JSON.stringify(documentIds));
|
|
45
|
-
const found = new Map();
|
|
46
|
-
for (const row of rows)
|
|
47
|
-
if (!found.has(Number(row.document_id)))
|
|
48
|
-
found.set(Number(row.document_id), Number(row.meeting_id));
|
|
49
|
-
return found;
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
});
|