@wirecat/cli-core 0.612.0 → 0.614.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 +55 -0
- package/dist/background/report/render.d.ts +10 -1
- package/dist/background/report/render.js +20 -7
- package/dist/background/report/schema.d.ts +37 -0
- package/dist/background/report/schema.js +98 -4
- package/dist/background/report/templates/morning-digest.email.en.liquid +49 -8
- package/dist/background/report/templates/morning-digest.email.ru.liquid +49 -8
- package/dist/background/report/templates/morning-digest.telegram.en.liquid +49 -9
- package/dist/background/report/templates/morning-digest.telegram.ru.liquid +49 -9
- package/dist/background/report/templates/morning-digest.text.en.liquid +49 -9
- package/dist/background/report/templates/morning-digest.text.ru.liquid +49 -9
- package/dist/background/report/view.d.ts +34 -3
- package/dist/background/report/view.js +59 -5
- package/dist/background/schedules.js +19 -3
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/cli/account-remove.d.ts +67 -0
- package/dist/cli/account-remove.js +285 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/messenger/account-command.js +6 -0
- package/dist/cli/messenger/context.d.ts +2 -0
- package/dist/cli/messenger/serve-relay.d.ts +1 -0
- package/dist/cli/profile-files.d.ts +7 -0
- package/dist/cli/profile-files.js +43 -0
- package/dist/domain/links.d.ts +72 -0
- package/dist/domain/links.js +139 -0
- package/dist/entities/account-change.d.ts +20 -0
- package/dist/entities/account-change.js +12 -1
- package/dist/entities/index.d.ts +20 -0
- package/dist/entities/index.js +2 -1
- package/dist/errors/reasons.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/accounts.d.ts +2 -0
- package/dist/store/accounts.js +2 -1
- package/dist/store/sqlite/account-groups.d.ts +1 -0
- package/dist/store/sqlite/account-groups.js +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { parseReference } from "./references.js";
|
|
2
|
+
export const LINK_VERSION = "v1";
|
|
3
|
+
export const DEFAULT_LINK_CONFIG = { base: "https://wirecat.dev/o", enabled: true };
|
|
4
|
+
const APP_PREFIX = "wirecat://open";
|
|
5
|
+
const MAX_PATH = 512;
|
|
6
|
+
const MAX_SEGMENTS = 6;
|
|
7
|
+
const TASK_FILTERS = ["overdue", "today", "tomorrow"];
|
|
8
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
9
|
+
const DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
10
|
+
const isMoment = (text, pattern) => pattern.test(text) && !Number.isNaN(Date.parse(text));
|
|
11
|
+
const partsOf = (target) => {
|
|
12
|
+
switch (target.type) {
|
|
13
|
+
case "message":
|
|
14
|
+
return ["msg", target.provider, target.account, target.chat, target.message];
|
|
15
|
+
case "chat":
|
|
16
|
+
return ["chat", target.provider, target.account, target.chat];
|
|
17
|
+
case "task":
|
|
18
|
+
return ["task", target.id];
|
|
19
|
+
case "tasks":
|
|
20
|
+
return target.filter === "new" ? ["tasks", "new", target.since] : ["tasks", target.filter];
|
|
21
|
+
case "proposal":
|
|
22
|
+
return ["proposal", target.id];
|
|
23
|
+
case "digest":
|
|
24
|
+
return ["digest", target.date];
|
|
25
|
+
case "sync":
|
|
26
|
+
return target.account === undefined ? ["sync", target.tool] : ["sync", target.tool, target.account];
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/** The path after the version, `msg/max/1001/-2002/3003`: each part percent-encoded, so no id can add a part. */
|
|
30
|
+
const pathOf = (target) => partsOf(target).map(encodeURIComponent).join("/");
|
|
31
|
+
const targetOfParts = (parts) => {
|
|
32
|
+
const [kind, ...rest] = parts;
|
|
33
|
+
const [a = "", b = "", c = "", d = ""] = rest;
|
|
34
|
+
switch (kind) {
|
|
35
|
+
case "msg":
|
|
36
|
+
return rest.length === 4 ? { type: "message", provider: a, account: b, chat: c, message: d } : null;
|
|
37
|
+
case "chat":
|
|
38
|
+
return rest.length === 3 ? { type: "chat", provider: a, account: b, chat: c } : null;
|
|
39
|
+
case "task":
|
|
40
|
+
return rest.length === 1 ? { type: "task", id: a } : null;
|
|
41
|
+
case "tasks":
|
|
42
|
+
if (rest.length === 1 && TASK_FILTERS.includes(a))
|
|
43
|
+
return { type: "tasks", filter: a };
|
|
44
|
+
return rest.length === 2 && a === "new" && (isMoment(b, DATE) || isMoment(b, DATE_TIME))
|
|
45
|
+
? { type: "tasks", filter: "new", since: b }
|
|
46
|
+
: null;
|
|
47
|
+
case "proposal":
|
|
48
|
+
return rest.length === 1 ? { type: "proposal", id: a } : null;
|
|
49
|
+
case "digest":
|
|
50
|
+
return rest.length === 1 && isMoment(a, DATE) ? { type: "digest", date: a } : null;
|
|
51
|
+
case "sync":
|
|
52
|
+
return rest.length === 1 || rest.length === 2
|
|
53
|
+
? { type: "sync", tool: a, ...(rest.length === 2 ? { account: b } : {}) }
|
|
54
|
+
: null;
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
/** A path after the version, or `null`: an empty part or one that does not decode is not a WireCat link. */
|
|
60
|
+
const targetOfPath = (path) => {
|
|
61
|
+
const raw = path.split("/");
|
|
62
|
+
if (raw.some((part) => part === ""))
|
|
63
|
+
return null;
|
|
64
|
+
try {
|
|
65
|
+
return targetOfParts(raw.map(decodeURIComponent));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** `/v1/msg/max/1001/-2002/3003`, the part both forms share. */
|
|
72
|
+
export const formatLink = (target) => `/${LINK_VERSION}/${pathOf(target)}`;
|
|
73
|
+
/**
|
|
74
|
+
* The target of a link in either form (`https://…#/v1/…`, `wirecat://open/v1/…`) or of its bare path (`/v1/…`), or
|
|
75
|
+
* `null` for anything else: another version, an unknown kind, a part too many or empty, a path over 512 characters.
|
|
76
|
+
*/
|
|
77
|
+
export const parseLink = (text) => {
|
|
78
|
+
const link = text.trim();
|
|
79
|
+
const path = link.startsWith(`${APP_PREFIX}/`)
|
|
80
|
+
? link.slice(APP_PREFIX.length)
|
|
81
|
+
: link.startsWith("https://") && link.includes("#")
|
|
82
|
+
? link.slice(link.indexOf("#") + 1)
|
|
83
|
+
: link;
|
|
84
|
+
if (path.length > MAX_PATH || !path.startsWith(`/${LINK_VERSION}/`))
|
|
85
|
+
return null;
|
|
86
|
+
// A later version may add extras as a query; a v1 reader ignores them rather than refusing the link.
|
|
87
|
+
const rest = path.split("?")[0].slice(LINK_VERSION.length + 2);
|
|
88
|
+
if (rest.split("/").length + 1 > MAX_SEGMENTS)
|
|
89
|
+
return null;
|
|
90
|
+
return targetOfPath(rest);
|
|
91
|
+
};
|
|
92
|
+
const LINK_ONLY = new Set(["tasks", "proposal", "digest", "sync"]);
|
|
93
|
+
const FROM_REFERENCE = new Set(["message", "chat", "task"]);
|
|
94
|
+
/**
|
|
95
|
+
* The target a ref names, or `null` when it names nothing a link opens. A store reference (`msg:`, `chat:`, `task:`)
|
|
96
|
+
* is read by its own grammar; the kinds that are no reference are written as their path with a colon after the
|
|
97
|
+
* kind: `proposal:fact%3A512`, `tasks:overdue`, `tasks:new/2026-11-07T08%3A00%3A00Z`, `digest:2026-11-08`,
|
|
98
|
+
* `sync:telegram/1001`.
|
|
99
|
+
*/
|
|
100
|
+
export const linkTargetOf = (ref) => {
|
|
101
|
+
const text = ref.trim();
|
|
102
|
+
const colon = text.indexOf(":");
|
|
103
|
+
if (colon < 0)
|
|
104
|
+
return null;
|
|
105
|
+
const kind = text.slice(0, colon);
|
|
106
|
+
if (LINK_ONLY.has(kind))
|
|
107
|
+
return targetOfPath(`${kind}/${text.slice(colon + 1)}`);
|
|
108
|
+
try {
|
|
109
|
+
const reference = parseReference(text);
|
|
110
|
+
return FROM_REFERENCE.has(reference.type) ? reference : null;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/** The `links` section of the shared config, with the default for what is missing or not a usable value. */
|
|
117
|
+
export const linkConfigOf = (section) => {
|
|
118
|
+
const value = section && typeof section === "object" ? section : {};
|
|
119
|
+
const base = typeof value.base === "string" && /^https:\/\/[^\s#?]+$/.test(value.base)
|
|
120
|
+
? value.base.replace(/\/+$/, "")
|
|
121
|
+
: DEFAULT_LINK_CONFIG.base;
|
|
122
|
+
return { base, enabled: typeof value.enabled === "boolean" ? value.enabled : DEFAULT_LINK_CONFIG.enabled };
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* The one way to build a WireCat link: the web form for messages and mail (an https page that hands it to the app),
|
|
126
|
+
* the app form for a desktop terminal. `null` when links are off (`links.enabled: false`, or `WIRECAT_LINKS=off` for
|
|
127
|
+
* one run) or the ref names nothing a link opens; the caller then leaves the link out.
|
|
128
|
+
*/
|
|
129
|
+
export const linkFor = (ref, { form, config = DEFAULT_LINK_CONFIG, env = process.env, }) => {
|
|
130
|
+
if (!config.enabled || env.WIRECAT_LINKS === "off")
|
|
131
|
+
return null;
|
|
132
|
+
const target = typeof ref === "string" ? linkTargetOf(ref) : ref;
|
|
133
|
+
if (target === null)
|
|
134
|
+
return null;
|
|
135
|
+
const path = formatLink(target);
|
|
136
|
+
if (path.length > MAX_PATH || parseLink(path) === null)
|
|
137
|
+
return null;
|
|
138
|
+
return form === "app" ? `${APP_PREFIX}${path}` : `${config.base}#${path}`;
|
|
139
|
+
};
|
|
@@ -87,3 +87,23 @@ export declare const accountPrivacyChange: v.StrictObjectSchema<{
|
|
|
87
87
|
readonly last_seen: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
88
88
|
}, undefined>;
|
|
89
89
|
}, undefined>;
|
|
90
|
+
export declare const accountRemoval: v.StrictObjectSchema<{
|
|
91
|
+
readonly profile: v.StringSchema<undefined>;
|
|
92
|
+
readonly data: v.PicklistSchema<["kept", "deleted"], undefined>;
|
|
93
|
+
readonly dry_run: v.BooleanSchema<undefined>;
|
|
94
|
+
readonly account: v.NullableSchema<v.StrictObjectSchema<{
|
|
95
|
+
readonly provider: v.StringSchema<undefined>;
|
|
96
|
+
readonly account: v.StringSchema<undefined>;
|
|
97
|
+
}, undefined>, undefined>;
|
|
98
|
+
readonly revoked: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
99
|
+
readonly config_file: v.StringSchema<undefined>;
|
|
100
|
+
readonly removed: v.ArraySchema<v.StrictObjectSchema<{
|
|
101
|
+
readonly kind: v.PicklistSchema<["sign_in", "keyring", "config", "file", "store", "unit", "schedule"], undefined>;
|
|
102
|
+
readonly target: v.StringSchema<undefined>;
|
|
103
|
+
}, undefined>, undefined>;
|
|
104
|
+
readonly kept: v.ArraySchema<v.StrictObjectSchema<{
|
|
105
|
+
readonly kind: v.PicklistSchema<["sign_in", "keyring", "config", "file", "store", "unit", "schedule"], undefined>;
|
|
106
|
+
readonly target: v.StringSchema<undefined>;
|
|
107
|
+
readonly reason: v.StringSchema<undefined>;
|
|
108
|
+
}, undefined>, undefined>;
|
|
109
|
+
}, undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { account } from "./account.js";
|
|
3
3
|
import { accountSession } from "./account-session.js";
|
|
4
|
-
import { id } from "./fields.js";
|
|
4
|
+
import { id, text } from "./fields.js";
|
|
5
5
|
export const accountChange = v.strictObject({ operation_id: id, account: v.omit(account, ["provider", "scope"]) });
|
|
6
6
|
export const endedAccountSessions = v.strictObject({ operation_id: id, sessions: v.array(accountSession) });
|
|
7
7
|
const audience = v.picklist(["everyone", "contacts", "nobody"]);
|
|
@@ -18,3 +18,14 @@ export const accountPrivacy = v.strictObject({
|
|
|
18
18
|
last_seen: v.optional(shownAudience),
|
|
19
19
|
});
|
|
20
20
|
export const accountPrivacyChange = v.strictObject({ operation_id: id, privacy: accountPrivacy });
|
|
21
|
+
const removalKind = v.picklist(["sign_in", "keyring", "config", "file", "store", "unit", "schedule"]);
|
|
22
|
+
export const accountRemoval = v.strictObject({
|
|
23
|
+
profile: text,
|
|
24
|
+
data: v.picklist(["kept", "deleted"]),
|
|
25
|
+
dry_run: v.boolean(),
|
|
26
|
+
account: v.nullable(v.strictObject({ provider: text, account: text })),
|
|
27
|
+
revoked: v.nullable(v.boolean()),
|
|
28
|
+
config_file: text,
|
|
29
|
+
removed: v.array(v.strictObject({ kind: removalKind, target: text })),
|
|
30
|
+
kept: v.array(v.strictObject({ kind: removalKind, target: text, reason: text })),
|
|
31
|
+
});
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -4041,6 +4041,26 @@ export declare const ENTITIES: {
|
|
|
4041
4041
|
readonly created_at: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>, undefined>;
|
|
4042
4042
|
}, undefined>, undefined>;
|
|
4043
4043
|
}, undefined>;
|
|
4044
|
+
readonly account_removal: v.StrictObjectSchema<{
|
|
4045
|
+
readonly profile: v.StringSchema<undefined>;
|
|
4046
|
+
readonly data: v.PicklistSchema<["kept", "deleted"], undefined>;
|
|
4047
|
+
readonly dry_run: v.BooleanSchema<undefined>;
|
|
4048
|
+
readonly account: v.NullableSchema<v.StrictObjectSchema<{
|
|
4049
|
+
readonly provider: v.StringSchema<undefined>;
|
|
4050
|
+
readonly account: v.StringSchema<undefined>;
|
|
4051
|
+
}, undefined>, undefined>;
|
|
4052
|
+
readonly revoked: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
4053
|
+
readonly config_file: v.StringSchema<undefined>;
|
|
4054
|
+
readonly removed: v.ArraySchema<v.StrictObjectSchema<{
|
|
4055
|
+
readonly kind: v.PicklistSchema<["sign_in", "keyring", "config", "file", "store", "unit", "schedule"], undefined>;
|
|
4056
|
+
readonly target: v.StringSchema<undefined>;
|
|
4057
|
+
}, undefined>, undefined>;
|
|
4058
|
+
readonly kept: v.ArraySchema<v.StrictObjectSchema<{
|
|
4059
|
+
readonly kind: v.PicklistSchema<["sign_in", "keyring", "config", "file", "store", "unit", "schedule"], undefined>;
|
|
4060
|
+
readonly target: v.StringSchema<undefined>;
|
|
4061
|
+
readonly reason: v.StringSchema<undefined>;
|
|
4062
|
+
}, undefined>, undefined>;
|
|
4063
|
+
}, undefined>;
|
|
4044
4064
|
readonly account_privacy: v.StrictObjectSchema<{
|
|
4045
4065
|
readonly find_by_phone: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
4046
4066
|
readonly phone_number: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
package/dist/entities/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsonSchemaOf } from "@wirecat/cli-base/standards";
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
import { MEETING_RESULT_ENTITIES } from "../meetings/index.js";
|
|
4
4
|
import { account } from "./account.js";
|
|
5
|
-
import { accountChange, accountPrivacy, accountPrivacyChange, endedAccountSessions } from "./account-change.js";
|
|
5
|
+
import { accountChange, accountPrivacy, accountPrivacyChange, accountRemoval, endedAccountSessions, } from "./account-change.js";
|
|
6
6
|
import { accountProfile } from "./account-profile.js";
|
|
7
7
|
import { accountSession } from "./account-session.js";
|
|
8
8
|
import { adminReport } from "./admin-report.js";
|
|
@@ -186,6 +186,7 @@ export const ENTITIES = {
|
|
|
186
186
|
account_session: accountSession,
|
|
187
187
|
account_change: accountChange,
|
|
188
188
|
ended_account_sessions: endedAccountSessions,
|
|
189
|
+
account_removal: accountRemoval,
|
|
189
190
|
account_privacy: accountPrivacy,
|
|
190
191
|
account_privacy_change: accountPrivacyChange,
|
|
191
192
|
account_profile: accountProfile,
|
package/dist/errors/reasons.js
CHANGED
|
@@ -35,6 +35,16 @@ const SIGN_IN = [
|
|
|
35
35
|
["oauth.scope-missing", "permission_error", "the sign-in lacks a permission this command needs"],
|
|
36
36
|
["sign-in.client-rejected", "configuration_error", "the provider rejected the OAuth client"],
|
|
37
37
|
["sign-in.secret-without-id", "configuration_error", "an OAuth client secret is set without its client id"],
|
|
38
|
+
validation("account-remove.no-choice", "account remove needs --keep-data or --delete-data, one of them"),
|
|
39
|
+
["account-remove.unknown-profile", "not_found", "no profile by this name on this computer"],
|
|
40
|
+
["account-remove.busy", "conflict", "a serve or a sync runs for this profile; stop it first"],
|
|
41
|
+
["account-remove.unconfirmed", "confirmation_required", "removing an account asks first; add --yes"],
|
|
42
|
+
["account-remove.path-outside", "configuration_error", "the tool named a path outside its own folders"],
|
|
43
|
+
[
|
|
44
|
+
"account-remove.folder-outside",
|
|
45
|
+
"configuration_error",
|
|
46
|
+
"the tool named a folder of its own outside the home folder",
|
|
47
|
+
],
|
|
38
48
|
];
|
|
39
49
|
/** Reasons every CLI over a provider's API raises alike: gcal and drive today. */
|
|
40
50
|
const PROVIDER_API = [
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { CRM_KINDS, type CrmDepartment, type CrmField, type CrmItem, type CrmKin
|
|
|
6
6
|
export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, type DealKind, type DealRole, type DealStatus, STAGE_OUTCOMES, type StageOutcome, } from "./domain/deals.js";
|
|
7
7
|
export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
|
|
8
8
|
export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
|
|
9
|
+
export { DEFAULT_LINK_CONFIG, type DeepLinkTarget, formatLink, LINK_VERSION, type LinkConfig, type LinkForm, linkConfigOf, linkFor, linkTargetOf, parseLink, } from "./domain/links.js";
|
|
9
10
|
export { formatLocator, isLocator, type MessageLocator, parseLocator } from "./domain/locator.js";
|
|
10
11
|
export { type Markup, parseMarkdown } from "./domain/markdown.js";
|
|
11
12
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { CRM_KINDS, isItemKind, } from "./domain/crm.js";
|
|
|
5
5
|
export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, STAGE_OUTCOMES, } from "./domain/deals.js";
|
|
6
6
|
export { FINANCE_REVIEWS, INVOICE_DIRECTIONS, INVOICE_STATUSES, MONEY_DIRECTIONS, } from "./domain/finance.js";
|
|
7
7
|
export { validateFormattedText, } from "./domain/formatting.js";
|
|
8
|
+
export { DEFAULT_LINK_CONFIG, formatLink, LINK_VERSION, linkConfigOf, linkFor, linkTargetOf, parseLink, } from "./domain/links.js";
|
|
8
9
|
export { formatLocator, isLocator, parseLocator } from "./domain/locator.js";
|
|
9
10
|
export { parseMarkdown } from "./domain/markdown.js";
|
|
10
11
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
|
@@ -14,12 +14,12 @@ export declare const metadataService: (deps: ServiceDeps) => {
|
|
|
14
14
|
dryRun?: boolean;
|
|
15
15
|
}) => Promise<{
|
|
16
16
|
items: ({
|
|
17
|
+
error?: undefined;
|
|
17
18
|
chatId: string;
|
|
18
19
|
tags: import("../domain/channel-tags.js").ChannelTagMatch[];
|
|
19
20
|
algorithm: string;
|
|
20
21
|
fetchedAt: string | null;
|
|
21
22
|
source: string;
|
|
22
|
-
error?: undefined;
|
|
23
23
|
} | {
|
|
24
24
|
tags?: undefined;
|
|
25
25
|
algorithm?: undefined;
|
package/dist/store/accounts.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface AccountsStore extends AccountAccounts {
|
|
|
30
30
|
profiles(): Promise<Profiles>;
|
|
31
31
|
/** Records which account a profile of `app` is; a no-op when the store already says so. */
|
|
32
32
|
saveProfile(app: string, profile: string, key: AccountKey): Promise<void>;
|
|
33
|
+
/** Forgets which account a profile of `app` is; a no-op when the store never knew. */
|
|
34
|
+
forgetProfile(app: string, profile: string): Promise<void>;
|
|
33
35
|
/** Writes a CLI's provider entry for every tool on this store to read; see `registerProvider`. */
|
|
34
36
|
registerProvider(entry: ProviderEntry): Promise<void>;
|
|
35
37
|
}
|
package/dist/store/accounts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ACCOUNT_GROUPS } from "../search/account-list.js";
|
|
2
2
|
import { keysOver } from "./keys.js";
|
|
3
|
-
import { accountGroupsOf, profilesOf, saveProfile } from "./sqlite/account-groups.js";
|
|
3
|
+
import { accountGroupsOf, forgetProfile, profilesOf, saveProfile } from "./sqlite/account-groups.js";
|
|
4
4
|
import * as accounts from "./sqlite/accounts.js";
|
|
5
5
|
import { linkOwnIdentities } from "./sqlite/own-identities.js";
|
|
6
6
|
import { registerProvider } from "./sqlite/providers.js";
|
|
@@ -38,6 +38,7 @@ export const accountsStoreOver = (context, keyed) => {
|
|
|
38
38
|
accountGroups: async () => accountGroupsOf(database),
|
|
39
39
|
profiles: async () => profilesOf(database),
|
|
40
40
|
saveProfile: async (app, profile, key) => write(database, () => saveProfile(database, app, profile, key, context.now())),
|
|
41
|
+
forgetProfile: async (app, profile) => write(database, () => forgetProfile(database, app, profile, context.now())),
|
|
41
42
|
registerProvider: async (entry) => registerProvider(database, entry, context.now()),
|
|
42
43
|
saveAccountGroup: async (name, members) => write(database, () => {
|
|
43
44
|
const groups = accountGroupsOf(database);
|
|
@@ -38,3 +38,17 @@ export const saveProfile = (database, app, profile, key, now) => {
|
|
|
38
38
|
.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)")
|
|
39
39
|
.run(PROFILES, JSON.stringify(profiles), now);
|
|
40
40
|
};
|
|
41
|
+
export const forgetProfile = (database, app, profile, now) => {
|
|
42
|
+
const profiles = profilesOf(database);
|
|
43
|
+
const own = profiles[app];
|
|
44
|
+
if (own?.[profile] === undefined)
|
|
45
|
+
return;
|
|
46
|
+
const { [profile]: _, ...rest } = own;
|
|
47
|
+
if (Object.keys(rest).length === 0)
|
|
48
|
+
delete profiles[app];
|
|
49
|
+
else
|
|
50
|
+
profiles[app] = rest;
|
|
51
|
+
database
|
|
52
|
+
.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)")
|
|
53
|
+
.run(PROFILES, JSON.stringify(profiles), now);
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.614.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",
|