@wirecat/cli-core 0.411.0 → 0.412.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 +18 -0
- package/dist/cli/bot/command.js +3 -3
- package/dist/cli/bot/messages-sync.d.ts +7 -0
- package/dist/cli/bot/{store.js → messages-sync.js} +4 -5
- package/dist/cli/bot/port.d.ts +3 -3
- package/dist/cli/config-command.js +1 -0
- package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
- package/dist/cli/messenger/tasks-command.js +2 -2
- package/dist/cli/moved.js +1 -0
- package/dist/cli/settings.d.ts +2 -0
- package/dist/cli/settings.js +5 -1
- package/dist/domain/providers.d.ts +25 -3
- package/dist/domain/providers.js +89 -5
- package/dist/entities/index.d.ts +29 -1
- package/dist/entities/index.js +5 -1
- package/dist/entities/knowledge-lists.d.ts +28 -0
- package/dist/entities/knowledge-lists.js +29 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/search/account-list.d.ts +5 -2
- package/dist/search/account-list.js +27 -11
- package/dist/search/query.js +3 -1
- package/dist/sends/permission-aliases.js +1 -0
- package/dist/services/documents/knowledge.d.ts +5 -3
- package/dist/services/documents/knowledge.js +4 -4
- package/dist/services/meeting-links.d.ts +3 -1
- package/dist/services/meeting-links.js +2 -2
- package/dist/services/messages-search.js +15 -3
- package/dist/services/search-all.js +5 -2
- package/dist/store/accounts.d.ts +3 -0
- package/dist/store/accounts.js +2 -0
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/index.d.ts +3 -1
- package/dist/store/index.js +2 -0
- package/dist/store/knowledge-query.d.ts +6 -0
- package/dist/store/knowledge-query.js +34 -0
- package/dist/store/providers.d.ts +7 -0
- package/dist/store/providers.js +5 -0
- package/dist/store/sqlite/knowledge.d.ts +5 -4
- package/dist/store/sqlite/knowledge.js +50 -17
- package/dist/store/sqlite/mail-rules.d.ts +2 -1
- package/dist/store/sqlite/mail-rules.js +12 -2
- package/dist/store/sqlite/notes.d.ts +11 -5
- package/dist/store/sqlite/notes.js +9 -2
- package/dist/store/sqlite/open-store.js +2 -0
- package/dist/store/sqlite/providers.d.ts +12 -0
- package/dist/store/sqlite/providers.js +45 -0
- package/dist/store/sqlite/tags.d.ts +1 -1
- package/dist/store/sqlite/tags.js +3 -3
- package/package.json +1 -1
- package/parity.json +31 -35
- package/dist/cli/bot/store.d.ts +0 -7
|
@@ -404,10 +404,17 @@ export const notesStoreOver = (context) => {
|
|
|
404
404
|
const to = pair(options.to);
|
|
405
405
|
if (!from.known || !to.known)
|
|
406
406
|
return [];
|
|
407
|
+
const filters = [
|
|
408
|
+
...(options.id === undefined ? [] : [{ sql: "CAST(id AS TEXT) = ?", value: options.id }]),
|
|
409
|
+
...(options.kind === undefined ? [] : [{ sql: "kind = ?", value: options.kind }]),
|
|
410
|
+
...(options.role === undefined ? [] : [{ sql: "role = ?", value: options.role }]),
|
|
411
|
+
...(options.origin === undefined ? [] : [{ sql: "source = ?", value: options.origin }]),
|
|
412
|
+
...(options.confirmed === undefined ? [] : [{ sql: "confirmed = ?", value: options.confirmed ? 1 : 0 }]),
|
|
413
|
+
];
|
|
407
414
|
return database
|
|
408
415
|
.prepare("SELECT * FROM links WHERE (? IS NULL OR (from_type = ? AND from_id = ?)) AND (? IS NULL OR (to_type = ? AND to_id = ?)) " +
|
|
409
|
-
|
|
410
|
-
.all(from.type, from.type, from.id, to.type, to.type, to.id, options.unresolved ? 1 : 0)
|
|
416
|
+
`AND (? = 0 OR to_id IS NULL)${filters.map(({ sql }) => ` AND (${sql})`).join("")} ORDER BY created_at, id LIMIT 5000`)
|
|
417
|
+
.all(from.type, from.type, from.id, to.type, to.type, to.id, options.unresolved ? 1 : 0, ...filters.map(({ value }) => value))
|
|
411
418
|
.map((row) => linkOf(database, row));
|
|
412
419
|
},
|
|
413
420
|
removeLink: async (id) => write(database, () => {
|
|
@@ -9,6 +9,7 @@ import { backfillNormalized, pendingNormalization } from "./backfill.js";
|
|
|
9
9
|
import { fillFolded } from "./folded.js";
|
|
10
10
|
import { logPruner } from "./log-pruning.js";
|
|
11
11
|
import { openSqlite } from "./open.js";
|
|
12
|
+
import { loadProviders } from "./providers.js";
|
|
12
13
|
import { assertReadCompatible } from "./read-compatibility.js";
|
|
13
14
|
import { stemsState } from "./stems.js";
|
|
14
15
|
import { fillStems, followDefaultStemmers } from "./stems-fill.js";
|
|
@@ -56,6 +57,7 @@ export const openStoreContext = async ({ path, env, now = Date.now, command, rea
|
|
|
56
57
|
fillStems(database, { now });
|
|
57
58
|
logPruner(database, now)();
|
|
58
59
|
}
|
|
60
|
+
loadProviders(database);
|
|
59
61
|
return { ...opened, now, sharedConfig: sharedConfigPath(file, env ?? process.env) };
|
|
60
62
|
}
|
|
61
63
|
catch (error) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ProviderEntry } from "../../domain/providers.js";
|
|
2
|
+
import type { CacheDatabase } from "../driver.js";
|
|
3
|
+
export declare const PROVIDERS_SETTING = "providers";
|
|
4
|
+
/** The entries as stored, unchecked: a newer CLI may have written a kind this build does not know. */
|
|
5
|
+
export declare const storedProvidersOf: (database: CacheDatabase) => unknown[];
|
|
6
|
+
/** Called on every open: the module state follows the store the process opened last. */
|
|
7
|
+
export declare const loadProviders: (database: CacheDatabase) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Writes `entry` over the stored one of its name and loads the result. Every run of every CLI calls it, so it
|
|
10
|
+
* writes only when the entry changed. Entries this build cannot read stay stored for the CLIs that can.
|
|
11
|
+
*/
|
|
12
|
+
export declare const registerProvider: (database: CacheDatabase, value: ProviderEntry, now: number) => void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { addProvider, providerEntryOf, useStoredProviders } from "../../domain/providers.js";
|
|
2
|
+
import { write } from "./transaction.js";
|
|
3
|
+
export const PROVIDERS_SETTING = "providers";
|
|
4
|
+
/** The entries as stored, unchecked: a newer CLI may have written a kind this build does not know. */
|
|
5
|
+
export const storedProvidersOf = (database) => {
|
|
6
|
+
const row = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
|
|
7
|
+
if (!row)
|
|
8
|
+
return [];
|
|
9
|
+
try {
|
|
10
|
+
const value = JSON.parse(String(row.value));
|
|
11
|
+
return Array.isArray(value) ? value : [];
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/** Called on every open: the module state follows the store the process opened last. */
|
|
18
|
+
export const loadProviders = (database) => {
|
|
19
|
+
useStoredProviders(storedProvidersOf(database));
|
|
20
|
+
};
|
|
21
|
+
const nameOf = (stored) => typeof stored === "object" && stored !== null ? stored.name : undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Writes `entry` over the stored one of its name and loads the result. Every run of every CLI calls it, so it
|
|
24
|
+
* writes only when the entry changed. Entries this build cannot read stay stored for the CLIs that can.
|
|
25
|
+
*/
|
|
26
|
+
export const registerProvider = (database, value, now) => {
|
|
27
|
+
const entry = providerEntryOf(value);
|
|
28
|
+
write(database, () => {
|
|
29
|
+
const stored = storedProvidersOf(database);
|
|
30
|
+
const others = stored.filter((one) => nameOf(one) !== entry.name);
|
|
31
|
+
try {
|
|
32
|
+
useStoredProviders(others);
|
|
33
|
+
addProvider(entry);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
useStoredProviders(stored);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
if (stored.some((one) => JSON.stringify(one) === JSON.stringify(entry)))
|
|
40
|
+
return;
|
|
41
|
+
database
|
|
42
|
+
.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)")
|
|
43
|
+
.run(PROVIDERS_SETTING, JSON.stringify([...others, entry]), now);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -83,7 +83,7 @@ export interface Label {
|
|
|
83
83
|
origin: "file" | "owner";
|
|
84
84
|
}
|
|
85
85
|
/** A thing's tags by name, with whether only a file states each. */
|
|
86
|
-
export declare const labelsOf: (database: CacheDatabase, thing: Thing) => Label[];
|
|
86
|
+
export declare const labelsOf: (database: CacheDatabase, thing: Thing, tag?: string) => Label[];
|
|
87
87
|
/**
|
|
88
88
|
* Marks one topic as the thing's main one, or clears it with `null`: the topic is tagged on it if it was
|
|
89
89
|
* not, and any other main topic stops being main.
|
|
@@ -156,9 +156,9 @@ export const removeTags = ({ database }, thing, tags, source) => {
|
|
|
156
156
|
});
|
|
157
157
|
};
|
|
158
158
|
/** A thing's tags by name, with whether only a file states each. */
|
|
159
|
-
export const labelsOf = (database, thing) => database
|
|
160
|
-
.prepare(
|
|
161
|
-
.all(thing.type, thing.id)
|
|
159
|
+
export const labelsOf = (database, thing, tag) => database
|
|
160
|
+
.prepare(`SELECT t.name, g.source FROM taggings g JOIN tags t ON t.id = g.tag_id WHERE g.taggable_type=? AND g.taggable_id=?${tag === undefined ? "" : " AND t.name = ?"} ORDER BY t.name`)
|
|
161
|
+
.all(thing.type, thing.id, ...(tag === undefined ? [] : [tag]))
|
|
162
162
|
.map((row) => ({ tag: String(row.name), origin: row.source === "file" ? "file" : "owner" }));
|
|
163
163
|
/**
|
|
164
164
|
* Marks one topic as the thing's main one, or clears it with `null`: the topic is tagged on it if it was
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.412.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",
|
package/parity.json
CHANGED
|
@@ -1065,7 +1065,7 @@
|
|
|
1065
1065
|
"--until-id": {
|
|
1066
1066
|
"value": "<id>",
|
|
1067
1067
|
"meaning": "only up to this message id, inclusive; the newest by default",
|
|
1068
|
-
"note": "tg's `bot
|
|
1068
|
+
"note": "tg's `bot messages sync` takes a message link here, the message the sync starts at, inclusive"
|
|
1069
1069
|
},
|
|
1070
1070
|
"--until-time": {
|
|
1071
1071
|
"value": "<time>",
|
|
@@ -1917,6 +1917,36 @@
|
|
|
1917
1917
|
"wa": "whatsapp-cli: wa bot API, plans/2026-10-22-wa-bot-api"
|
|
1918
1918
|
}
|
|
1919
1919
|
},
|
|
1920
|
+
"bot messages sync": {
|
|
1921
|
+
"in": ["max", "tg"],
|
|
1922
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account",
|
|
1923
|
+
"options": {
|
|
1924
|
+
"--last": {
|
|
1925
|
+
"in": ["max", "tg"],
|
|
1926
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1927
|
+
},
|
|
1928
|
+
"--limit": {
|
|
1929
|
+
"in": ["max", "tg"],
|
|
1930
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1931
|
+
},
|
|
1932
|
+
"--page-size": {
|
|
1933
|
+
"in": ["max", "tg"],
|
|
1934
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1935
|
+
},
|
|
1936
|
+
"--pause": {
|
|
1937
|
+
"in": ["max", "tg"],
|
|
1938
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1939
|
+
},
|
|
1940
|
+
"--since-time": {
|
|
1941
|
+
"in": ["max", "tg"],
|
|
1942
|
+
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1943
|
+
},
|
|
1944
|
+
"--until-id": {
|
|
1945
|
+
"in": ["tg"],
|
|
1946
|
+
"reason": "Telegram bots read message numbers and need a starting link when none is known; MAX pages chat history directly; WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
},
|
|
1920
1950
|
"bot messages unpin": {
|
|
1921
1951
|
"in": ["max", "tg"],
|
|
1922
1952
|
"planned": {
|
|
@@ -2015,40 +2045,6 @@
|
|
|
2015
2045
|
"wa": "whatsapp-cli: wa bot API, plans/2026-10-22-wa-bot-api"
|
|
2016
2046
|
}
|
|
2017
2047
|
},
|
|
2018
|
-
"bot store": {
|
|
2019
|
-
"in": ["max", "tg"],
|
|
2020
|
-
"reason": "Meta's Cloud API keeps no history a bot can fetch; WhatsApp bots get only what arrives by webhook"
|
|
2021
|
-
},
|
|
2022
|
-
"bot store fetch": {
|
|
2023
|
-
"in": ["max", "tg"],
|
|
2024
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account",
|
|
2025
|
-
"options": {
|
|
2026
|
-
"--last": {
|
|
2027
|
-
"in": ["max", "tg"],
|
|
2028
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2029
|
-
},
|
|
2030
|
-
"--limit": {
|
|
2031
|
-
"in": ["max", "tg"],
|
|
2032
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2033
|
-
},
|
|
2034
|
-
"--page-size": {
|
|
2035
|
-
"in": ["max", "tg"],
|
|
2036
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2037
|
-
},
|
|
2038
|
-
"--pause": {
|
|
2039
|
-
"in": ["max", "tg"],
|
|
2040
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2041
|
-
},
|
|
2042
|
-
"--since-time": {
|
|
2043
|
-
"in": ["max", "tg"],
|
|
2044
|
-
"reason": "WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2045
|
-
},
|
|
2046
|
-
"--until-id": {
|
|
2047
|
-
"in": ["tg"],
|
|
2048
|
-
"reason": "Telegram bots read message numbers and need a starting link when none is known; MAX pages chat history directly; WhatsApp's bots are the Business Platform's, on a business number; wa links a personal account"
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
},
|
|
2052
2048
|
"bot templates": {
|
|
2053
2049
|
"in": [],
|
|
2054
2050
|
"reason": "message templates are WhatsApp Business's; MAX and Telegram bots write freely",
|
package/dist/cli/bot/store.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import type { BotMessenger } from "./port.js";
|
|
3
|
-
/**
|
|
4
|
-
* `bot store fetch`: a chat's history into the bot's local copy, newest to oldest and resumable, as the
|
|
5
|
-
* personal `messages sync` does. Mounted for a messenger whose Bot API pages back through a chat.
|
|
6
|
-
*/
|
|
7
|
-
export declare const botStoreCommand: (bot: BotMessenger, fetching: NonNullable<BotMessenger["fetching"]>) => Command;
|