@wirecat/cli-core 0.634.0 → 0.635.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 +66 -0
- package/dist/domain/display-names.d.ts +4 -2
- package/dist/domain/display-names.js +5 -2
- package/dist/errors/reasons.js +5 -0
- package/dist/search/groups.d.ts +2 -0
- package/dist/search/groups.js +1 -0
- package/dist/services/account-groups.d.ts +30 -1
- package/dist/services/account-groups.js +27 -0
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/metadata.d.ts +1 -1
- package/dist/store/accounts.d.ts +10 -1
- package/dist/store/accounts.js +3 -2
- package/dist/store/chats.d.ts +5 -0
- package/dist/store/chats.js +6 -0
- package/dist/store/exports.d.ts +1 -1
- package/dist/store/identity-links.d.ts +21 -0
- package/dist/store/identity-splits.d.ts +2 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/keys.d.ts +1 -1
- package/dist/store/keys.js +1 -1
- package/dist/store/people.d.ts +10 -4
- package/dist/store/sqlite/accounts.d.ts +12 -2
- package/dist/store/sqlite/accounts.js +42 -3
- package/dist/store/sqlite/address-organization.d.ts +18 -0
- package/dist/store/sqlite/address-organization.js +48 -0
- package/dist/store/sqlite/chats.d.ts +3 -1
- package/dist/store/sqlite/chats.js +8 -0
- package/dist/store/sqlite/identity-link-rows.d.ts +5 -1
- package/dist/store/sqlite/identity-link-rows.js +9 -3
- package/dist/store/sqlite/identity-proposals.d.ts +5 -3
- package/dist/store/sqlite/identity-proposals.js +66 -7
- package/dist/store/sqlite/identity-split-proposals.js +3 -1
- package/dist/store/sqlite/mail-findings.js +10 -44
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/migrations.generated.js +6 -0
- package/dist/store/sqlite/name-traces.d.ts +5 -2
- package/dist/store/sqlite/name-traces.js +8 -5
- package/dist/store/sqlite/open-store.js +2 -0
- package/dist/store/sqlite/people-list.js +7 -3
- package/dist/store/sqlite/person-doubts.d.ts +4 -1
- package/dist/store/sqlite/person-doubts.js +4 -2
- package/dist/store/sqlite/person-links.d.ts +7 -2
- package/dist/store/sqlite/person-links.js +26 -1
- package/dist/store/sqlite/person-match-scan.js +74 -4
- package/dist/store/sqlite/person-merges.js +3 -7
- package/dist/store/sqlite/task-titles.d.ts +12 -1
- package/dist/store/sqlite/task-titles.js +42 -1
- package/dist/store/sqlite/tasks.js +6 -1
- package/dist/store/types.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,72 @@ 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.635.0 — 10.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **The owner sets an account's scope, personal or work, and pins or clears a chat's.** `setAccountScope` and
|
|
13
|
+
`setChatScope` (from `/services`) take an account as `--source` names it (`bitrix24:acme.bitrix24.ru`, `tg:work`),
|
|
14
|
+
refuse a run locked to a group, and are for an owner-only command (`grantsAuthority`). An account's change moves
|
|
15
|
+
what search copied of its old scope: its conversation pieces and involvements, its other search pieces, and the word
|
|
16
|
+
indexes of its documents, mail and calendar events, which are built again on the next search. A chat with its own
|
|
17
|
+
scope keeps it; memories and facts keep the scope they were written with. A chat's change is recorded in its
|
|
18
|
+
history as the owner's. The store methods are `accounts.setScope` and `chats.setChatScope`.
|
|
19
|
+
- **A CLI chooses the scope its new accounts start as.** `accounts.saveAccount(key, { name, scope: "work" })` makes a
|
|
20
|
+
new account work; an account already stored keeps its scope, so a sync never undoes the owner's choice. A `scope`
|
|
21
|
+
in the `AccountKey` itself still overwrites the stored one on every save.
|
|
22
|
+
- **Each member of an account group carries its account's `scope`**, so a groups view shows and switches it in place.
|
|
23
|
+
- **The owner can answer a shared-mailbox proposal with "this is the company's mailbox".** `people.decideLink` with
|
|
24
|
+
`company` (`{}`, `{ organization }` or `{ name }`) gives the address to an organization: the one named, else the one
|
|
25
|
+
that holds the address or its company domain, else one of that name, else a new company named after the domain. The
|
|
26
|
+
proposal is turned down, so the two people are not joined and are not proposed again on that address. Only the
|
|
27
|
+
owner decides it; a proposal that is not about a shared mailbox is refused with `identity.not-shared`
|
|
28
|
+
([ARCHITECTURE.md](docs/dev/ARCHITECTURE.md)).
|
|
29
|
+
|
|
30
|
+
- **`IdentityLinkRow.mailbox` names the shared address**, beside `shared`, so a review can show which mailbox it is.
|
|
31
|
+
|
|
32
|
+
- **`people.linkProposals({ order: "score" })` lists the highest score first**, proposals with no score last, each
|
|
33
|
+
newest first. Without `order` the list stays newest first.
|
|
34
|
+
- **A shared mailbox proposes the people who have it again, scored, and still never joins them.** A role address such
|
|
35
|
+
as `info@` or `office@`, and a company's address (one an organization holds, or two people of one source list have),
|
|
36
|
+
now opens a proposal for each pair of its people instead of being skipped; a no-reply address still proposes no one,
|
|
37
|
+
and the owner is still never proposed. The proposal's `score` says what else the two share: 0.1 for the mailbox
|
|
38
|
+
alone, more for one name, a phone or another address only they hold, a chat or a company's domain
|
|
39
|
+
([ARCHITECTURE.md](docs/dev/ARCHITECTURE.md)). The first people scan after the upgrade reads every address once,
|
|
40
|
+
so mailboxes nobody touched since are proposed too. Proposals already stored stay as they are.
|
|
41
|
+
|
|
42
|
+
- **`IdentityLinkRow.shared`: `role`, `line` or `null`.** Says that the address behind an `identity_link` proposal is
|
|
43
|
+
a shared mailbox, so a review can show it as one; `null` on proposals made before this release.
|
|
44
|
+
|
|
45
|
+
### Changed — may break callers
|
|
46
|
+
|
|
47
|
+
- **A person with no readable name of their own is shown by an account's name before its username.** `people.list`
|
|
48
|
+
gave such a person `displayName` `@Xorlov` although their Telegram account is named «Ярослав Орлов» (a person left
|
|
49
|
+
with no name after a split, for one). The first readable account name now comes first, then the username, phone and
|
|
50
|
+
email as before; `displayName(name, { name })` takes it. The shown name also drives the sort by name and the
|
|
51
|
+
automated and company checks, so such a person may move in the list or between kinds.
|
|
52
|
+
- **Taking identities off a person can name that person, and is refused when they sit on someone else.**
|
|
53
|
+
`people.unlinkIdentity(ref, { from })` and `people.proposeSplit({ identities, from })` take the uid of the person the
|
|
54
|
+
identities leave; `people.split(uid, …)` checks its `uid` the same way. An identity on another person is refused with
|
|
55
|
+
`validation_error`, reason `identity.held-elsewhere`, `param: "from"` and `reference: "person:<uid>"` of whoever holds
|
|
56
|
+
it, and the message names them, so nothing moves. Before, a script that meant to take a colleague's mailbox off the
|
|
57
|
+
owner's card took it off the colleague. `split`'s refusal for an identity of another person is now this one (it said
|
|
58
|
+
"is not an identity of person:<n>").
|
|
59
|
+
- **A doubt's unlink names the person it takes the identities from.** `people.doubts()` gives each `unlink` move a
|
|
60
|
+
`from` (`person:<uid>`), and its `fix` command ends in `--from person:<uid>`, which memo's `people unlink` needs.
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
|
|
64
|
+
- **A task found in a message keeps the message's first line as its title after the message is deleted.** The line is
|
|
65
|
+
now stored as the title when the task is found, as store version 65 did for the tasks found before. A task found
|
|
66
|
+
before its message is saved still shows the line once the message arrives, and a title the finder or a person sets
|
|
67
|
+
replaces it as before.
|
|
68
|
+
- **Tasks found in messages before 0.630 keep their message's first line as their title (store version 65).** Since
|
|
69
|
+
0.630 such a task showed the first line only while its message was in the store, and its title went back to
|
|
70
|
+
`question — msg:…` once the message was deleted. Store version 65 stores that line as the title of every live
|
|
71
|
+
found task still titled `<kind> — <source>`, once, on the next writable open, in batches. A title a person wrote, a
|
|
72
|
+
project task, and a task whose message is missing, deleted or empty keep their title.
|
|
73
|
+
|
|
8
74
|
## 0.634.0 — 10.11.2026
|
|
9
75
|
|
|
10
76
|
### Added
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/** What a person can be shown as when their name has nothing to read. */
|
|
2
2
|
export interface NameFallbacks {
|
|
3
|
+
/** A name one of the person's accounts carries: a real name beats a handle. */
|
|
4
|
+
name?: string | null;
|
|
3
5
|
username?: string | null;
|
|
4
6
|
phone?: string | null;
|
|
5
7
|
email?: string | null;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`), or a
|
|
9
|
-
* placeholder such as `null` or «Без имени», gives way to
|
|
10
|
-
* stays as it came.
|
|
11
|
+
* placeholder such as `null` or «Без имени», gives way to an account's name, then the username, the phone, the email;
|
|
12
|
+
* the stored name stays as it came.
|
|
11
13
|
*/
|
|
12
14
|
export declare const displayName: (name: string | null | undefined, fallbacks?: NameFallbacks) => string | null;
|
|
13
15
|
/**
|
|
@@ -26,14 +26,17 @@ const given = (value) => {
|
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* A name as it is shown: no wrapping quotes, no repeated or edge spaces. One with no letter or digit (`!`, `!$`), or a
|
|
29
|
-
* placeholder such as `null` or «Без имени», gives way to
|
|
30
|
-
* stays as it came.
|
|
29
|
+
* placeholder such as `null` or «Без имени», gives way to an account's name, then the username, the phone, the email;
|
|
30
|
+
* the stored name stays as it came.
|
|
31
31
|
*/
|
|
32
32
|
export const displayName = (name, fallbacks = {}) => {
|
|
33
33
|
const unwrapped = typeof name === "string" ? unquoted(name) : "";
|
|
34
34
|
const cleaned = PLACEHOLDERS.has(unwrapped.toLowerCase()) ? "" : unwrapped;
|
|
35
35
|
if (READABLE.test(cleaned))
|
|
36
36
|
return cleaned;
|
|
37
|
+
const borrowed = fallbacks.name === undefined || fallbacks.name === null ? null : displayName(fallbacks.name);
|
|
38
|
+
if (borrowed !== null && READABLE.test(borrowed) && !borrowed.startsWith("@"))
|
|
39
|
+
return borrowed;
|
|
37
40
|
const username = given(fallbacks.username);
|
|
38
41
|
return ((username === undefined ? undefined : username.startsWith("@") ? username : `@${username}`) ??
|
|
39
42
|
given(fallbacks.phone) ??
|
package/dist/errors/reasons.js
CHANGED
|
@@ -392,6 +392,7 @@ const OTHERS = [
|
|
|
392
392
|
"the people a merge or a proposed link names changed since; undo the later merge, or propose the link again",
|
|
393
393
|
],
|
|
394
394
|
["identity.no-merge", "not_found", "nothing of that person is merged into the other; people show lists the merges"],
|
|
395
|
+
validation("identity.held-elsewhere", "the identity sits on another person than the one named; name that person to take it off them"),
|
|
395
396
|
validation("identity.several-persons", "the identities that leave a person are all of that one person"),
|
|
396
397
|
validation("identity.nothing-left", "a split leaves at least one identity with the person"),
|
|
397
398
|
[
|
|
@@ -405,6 +406,10 @@ const OTHERS = [
|
|
|
405
406
|
"the owner rejected linking these people on this evidence; only a new signal or identity proposes them again",
|
|
406
407
|
],
|
|
407
408
|
validation("identity.same", "the two identities are one person already"),
|
|
409
|
+
validation("identity.not-shared", "only a match on a shared mailbox can say the mailbox is a company's"),
|
|
410
|
+
["organization.not-found", "not_found", "no stored organization has that id"],
|
|
411
|
+
validation("organization.unnamed", "a free mailbox names no company; name the organization or the company"),
|
|
412
|
+
validation("organization.ambiguous", "more than one organization matches; name the one meant as a reference"),
|
|
408
413
|
validation("identity.shared-phone", "more than six people share the phone number, so it proposes no one"),
|
|
409
414
|
validation("identity.common-name", "more than six people have the name, so it proposes no one"),
|
|
410
415
|
validation("identity.owner", "one side is the owner's person, and only the owner joins anyone to themselves"),
|
package/dist/search/groups.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export declare const NOT_GROUP_NAMES: ReadonlySet<string>;
|
|
|
9
9
|
/** `setting`: a saved group lists it; `all`: the default group, which holds every account. */
|
|
10
10
|
export type GroupReason = "setting" | "all";
|
|
11
11
|
export interface GroupMember extends AccountKey {
|
|
12
|
+
/** The account's scope as the store holds it, so a group view shows and switches it in place. */
|
|
13
|
+
scope?: "personal" | "work";
|
|
12
14
|
/** Every saved entry that names it; its `provider:account` in `all`. */
|
|
13
15
|
entries: string[];
|
|
14
16
|
reason: GroupReason;
|
package/dist/search/groups.js
CHANGED
|
@@ -66,6 +66,7 @@ export const groupMembership = (context) => {
|
|
|
66
66
|
holding.set(keyOf(one), [...(holding.get(keyOf(one)) ?? []), name]);
|
|
67
67
|
for (const [name, members] of [...Object.entries(groups), [ALL, every]])
|
|
68
68
|
for (const one of members) {
|
|
69
|
+
one.scope = context.held.find(sameAs(one))?.scope ?? "personal";
|
|
69
70
|
one.profiles = recorded.filter(({ key }) => sameAs(key)(one)).map(({ app, profile }) => `${app} ${profile}`);
|
|
70
71
|
one.also_in = (holding.get(keyOf(one)) ?? []).filter((other) => other !== name);
|
|
71
72
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Id } from "../domain/models.js";
|
|
1
2
|
import type { AppIdentity } from "../ports/app.js";
|
|
2
3
|
import { type GroupMembership } from "../search/groups.js";
|
|
3
|
-
import type { AccountKey, MessageStore } from "../store/store.js";
|
|
4
|
+
import type { AccountKey, MessageStore, StoredAccount } from "../store/store.js";
|
|
4
5
|
/** The store, the account running and its app: what every group edit resolves members against. */
|
|
5
6
|
export interface GroupStore {
|
|
6
7
|
store: MessageStore;
|
|
@@ -20,9 +21,37 @@ export interface GroupMemberMove extends Omit<GroupMemberChange, "group"> {
|
|
|
20
21
|
from: string;
|
|
21
22
|
to: string;
|
|
22
23
|
}
|
|
24
|
+
type Scope = StoredAccount["scope"];
|
|
25
|
+
export interface AccountScopeChange {
|
|
26
|
+
/** One account, as `--source` names it: `bitrix24:acme.bitrix24.ru`, `tg:work`. */
|
|
27
|
+
member: string;
|
|
28
|
+
scope: Scope;
|
|
29
|
+
}
|
|
30
|
+
export interface ChatScopeChange {
|
|
31
|
+
member: string;
|
|
32
|
+
/** The chat's id in that account. */
|
|
33
|
+
chat: Id;
|
|
34
|
+
/** `null` takes the chat's own scope off, so it follows its account again. */
|
|
35
|
+
scope: Scope | null;
|
|
36
|
+
}
|
|
37
|
+
export interface ChatScope extends AccountKey {
|
|
38
|
+
chat: Id;
|
|
39
|
+
/** The chat's own scope; `null` when it follows its account. */
|
|
40
|
+
own: Scope | null;
|
|
41
|
+
/** What every reader applies: its own, or else its account's. */
|
|
42
|
+
scope: Scope;
|
|
43
|
+
}
|
|
23
44
|
/** Every group with its members, why each is in, its profiles and other groups, the duplicates and the suggestions. */
|
|
24
45
|
export declare const listAccountGroups: (at: GroupStore) => Promise<GroupMembership>;
|
|
25
46
|
export declare const addGroupMember: (at: GroupStore, change: GroupMemberChange) => Promise<GroupMembership>;
|
|
26
47
|
export declare const removeGroupMember: (at: GroupStore, change: GroupMemberChange) => Promise<GroupMembership>;
|
|
27
48
|
/** Out of one group and into another in one write: what a drag between groups does. */
|
|
28
49
|
export declare const moveGroupMember: (at: GroupStore, move: GroupMemberMove) => Promise<GroupMembership>;
|
|
50
|
+
/**
|
|
51
|
+
* The owner's choice of which side of his life an account is on, as the store now holds it. Moving an account to work
|
|
52
|
+
* lets work views and meeting preparation read it, so a command over this is the owner's alone (`grantsAuthority`).
|
|
53
|
+
*/
|
|
54
|
+
export declare const setAccountScope: (at: GroupStore, change: AccountScopeChange) => Promise<StoredAccount>;
|
|
55
|
+
/** The owner pins one chat to a scope, or with `null` lets it follow its account; the owner's alone, as above. */
|
|
56
|
+
export declare const setChatScope: (at: GroupStore, change: ChatScopeChange) => Promise<ChatScope>;
|
|
57
|
+
export {};
|
|
@@ -2,6 +2,12 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { accountsOfList, groupName, sameAs, sourceOf } from "../search/account-list.js";
|
|
3
3
|
import { ALL, hasGroup, NOT_GROUP_NAMES } from "../search/groups.js";
|
|
4
4
|
import { groupLockOf, listContextOf } from "./search-kind.js";
|
|
5
|
+
const SCOPES = ["personal", "work"];
|
|
6
|
+
const scopeOf = (scope) => {
|
|
7
|
+
if (!SCOPES.includes(scope))
|
|
8
|
+
throw new CliError("validation_error", `${scope} is not a scope — personal or work`, { reason: "input.invalid" });
|
|
9
|
+
return scope;
|
|
10
|
+
};
|
|
5
11
|
const fail = (code, message) => {
|
|
6
12
|
throw new CliError(code, message);
|
|
7
13
|
};
|
|
@@ -87,3 +93,24 @@ export const moveGroupMember = async (at, move) => {
|
|
|
87
93
|
});
|
|
88
94
|
return listAccountGroups(at);
|
|
89
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* The owner's choice of which side of his life an account is on, as the store now holds it. Moving an account to work
|
|
98
|
+
* lets work views and meeting preparation read it, so a command over this is the owner's alone (`grantsAuthority`).
|
|
99
|
+
*/
|
|
100
|
+
export const setAccountScope = async (at, change) => {
|
|
101
|
+
unlocked(at);
|
|
102
|
+
const scope = scopeOf(change.scope);
|
|
103
|
+
const { provider, account } = accountOf(await contextOf(at), change.member);
|
|
104
|
+
return at.store.accounts.setScope({ provider, account }, scope);
|
|
105
|
+
};
|
|
106
|
+
/** The owner pins one chat to a scope, or with `null` lets it follow its account; the owner's alone, as above. */
|
|
107
|
+
export const setChatScope = async (at, change) => {
|
|
108
|
+
unlocked(at);
|
|
109
|
+
const scope = change.scope === null ? null : scopeOf(change.scope);
|
|
110
|
+
const { provider, account } = accountOf(await contextOf(at), change.member);
|
|
111
|
+
const key = { provider, account };
|
|
112
|
+
if (!(await at.store.chats.setChatScope(key, change.chat, scope)))
|
|
113
|
+
fail("not_found", `no chat ${change.chat} stored in ${sourceOf(key)}`);
|
|
114
|
+
const effective = (await at.store.chats.chatScopes(key, [change.chat])).get(change.chat) ?? "personal";
|
|
115
|
+
return { ...key, chat: change.chat, own: scope, scope: effective };
|
|
116
|
+
};
|
package/dist/services/index.d.ts
CHANGED
|
@@ -174,7 +174,7 @@ export { QUERY_LIMITS, QUERY_VERSION } from "../search/lucene/types.js";
|
|
|
174
174
|
export { questionLookup } from "../search/question-plan.js";
|
|
175
175
|
export { type SearchTotal, TOTAL_CAP } from "../search/total.js";
|
|
176
176
|
export { TASK_KINDS, TASK_ORIGINS, type TaskKind, type TaskOrigin } from "../tasks/index.js";
|
|
177
|
-
export { addGroupMember, type GroupMemberChange, type GroupMemberMove, type GroupStore, listAccountGroups, moveGroupMember, removeGroupMember, } from "./account-groups.js";
|
|
177
|
+
export { type AccountScopeChange, addGroupMember, type ChatScope, type ChatScopeChange, type GroupMemberChange, type GroupMemberMove, type GroupStore, listAccountGroups, moveGroupMember, removeGroupMember, setAccountScope, setChatScope, } from "./account-groups.js";
|
|
178
178
|
export type { AdminFound, AdminQuery, AdminSelection, AdminStatisticsService } from "./admin-statistics.js";
|
|
179
179
|
export { adminStatisticsService } from "./admin-statistics.js";
|
|
180
180
|
export { GAP_BOUNDS, type GapPlan, type GapRepair, gapsService, type RepairOptions } from "./archive-gaps.js";
|
package/dist/services/index.js
CHANGED
|
@@ -133,7 +133,7 @@ export { QUERY_LIMITS, QUERY_VERSION } from "../search/lucene/types.js";
|
|
|
133
133
|
export { questionLookup } from "../search/question-plan.js";
|
|
134
134
|
export { TOTAL_CAP } from "../search/total.js";
|
|
135
135
|
export { TASK_KINDS, TASK_ORIGINS } from "../tasks/index.js";
|
|
136
|
-
export { addGroupMember, listAccountGroups, moveGroupMember, removeGroupMember, } from "./account-groups.js";
|
|
136
|
+
export { addGroupMember, listAccountGroups, moveGroupMember, removeGroupMember, setAccountScope, setChatScope, } from "./account-groups.js";
|
|
137
137
|
export { adminStatisticsService } from "./admin-statistics.js";
|
|
138
138
|
export { GAP_BOUNDS, gapsService } from "./archive-gaps.js";
|
|
139
139
|
export { countersService } from "./counters.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
|
@@ -3,9 +3,13 @@ import { type AccountGroups, type Profiles } from "../search/account-list.js";
|
|
|
3
3
|
import type { StoreContext } from "./sqlite/open.js";
|
|
4
4
|
import type { AccountKey, StoredAccount } from "./types.js";
|
|
5
5
|
export interface AccountAccounts {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Answers the store's id for the account, which `meetings` and `mail` take. `scope` is what a new account starts
|
|
8
|
+
* as (a CRM's `work`); an account already stored keeps the scope it has.
|
|
9
|
+
*/
|
|
7
10
|
saveAccount(key: AccountKey, account: {
|
|
8
11
|
name: string | null;
|
|
12
|
+
scope?: StoredAccount["scope"];
|
|
9
13
|
}): Promise<number>;
|
|
10
14
|
/** One account by provider and external id, never created: `not_found` when the store has none. */
|
|
11
15
|
storedAccount(key: AccountKey): Promise<StoredAccount>;
|
|
@@ -33,6 +37,11 @@ export interface AccountsStore extends AccountAccounts {
|
|
|
33
37
|
accounts(): Promise<AccountKey[]>;
|
|
34
38
|
/** Every account with the store's id for it, by provider then external id. */
|
|
35
39
|
storedAccounts(): Promise<StoredAccount[]>;
|
|
40
|
+
/**
|
|
41
|
+
* The owner's choice of an account's scope, personal or work; what search copied of the old one follows. A
|
|
42
|
+
* missing account is `not_found`.
|
|
43
|
+
*/
|
|
44
|
+
setScope(key: AccountKey, scope: StoredAccount["scope"]): Promise<StoredAccount>;
|
|
36
45
|
/** The account groups `--source group:<name>` reads: each group's entries as saved, store-wide. */
|
|
37
46
|
accountGroups(): Promise<AccountGroups>;
|
|
38
47
|
/** Saves one group's entries; `undefined` removes the group. */
|
package/dist/store/accounts.js
CHANGED
|
@@ -10,9 +10,9 @@ export const accountAccountsOver = (context) => {
|
|
|
10
10
|
const { database } = context;
|
|
11
11
|
const { accountPk, findAccountPk } = keysOver(context);
|
|
12
12
|
return {
|
|
13
|
-
saveAccount: async (key, { name }) => {
|
|
13
|
+
saveAccount: async (key, { name, scope }) => {
|
|
14
14
|
const pk = write(database, () => {
|
|
15
|
-
const made = accountPk(key, name);
|
|
15
|
+
const made = accountPk(key, name, scope);
|
|
16
16
|
linkInbox(database, `${key.provider}:${key.account}`, made);
|
|
17
17
|
return made;
|
|
18
18
|
});
|
|
@@ -38,6 +38,7 @@ export const accountsStoreOver = (context, keyed) => {
|
|
|
38
38
|
...keyed,
|
|
39
39
|
accounts: async () => accounts.heldAccounts(context),
|
|
40
40
|
storedAccounts: async () => accounts.storedAccounts(context),
|
|
41
|
+
setScope: async (key, scope) => write(database, () => accounts.setAccountScope(context, key, scope)),
|
|
41
42
|
accountGroups: async () => accountGroupsOf(database),
|
|
42
43
|
profiles: async () => profilesOf(database),
|
|
43
44
|
saveProfile: async (app, profile, key) => write(database, () => saveProfile(database, app, profile, key, context.now())),
|
package/dist/store/chats.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ export interface ChatsStore {
|
|
|
25
25
|
countChats(key: AccountKey, filter?: StoredChatFilter): Promise<number>;
|
|
26
26
|
/** The chats a person is in, newest first — as far as the saved member lists go. */
|
|
27
27
|
chatsWith(key: AccountKey, memberId: Id): Promise<Chat[]>;
|
|
28
|
+
/**
|
|
29
|
+
* The owner pins one chat to a scope, or with `null` lets it follow its account again; `false` when the store does
|
|
30
|
+
* not know the chat. Its conversation pieces and involvements follow; its messages' search pieces keep the account's.
|
|
31
|
+
*/
|
|
32
|
+
setChatScope(key: AccountKey, chatId: Id, scope: StoredAccount["scope"] | null): Promise<boolean>;
|
|
28
33
|
/** Each stored chat's scope, its own or else its account's; a chat the store lacks is left out. */
|
|
29
34
|
chatScopes(key: AccountKey, chatIds: readonly Id[]): Promise<Map<Id, StoredAccount["scope"]>>;
|
|
30
35
|
/**
|
package/dist/store/chats.js
CHANGED
|
@@ -31,6 +31,12 @@ export const chatsStoreOver = (context) => {
|
|
|
31
31
|
const accountKey = findAccountPk(key);
|
|
32
32
|
return accountKey === undefined ? [] : chatQueries.chatsWith(context, accountKey, key, memberId);
|
|
33
33
|
},
|
|
34
|
+
setChatScope: async (key, chatId, scope) => {
|
|
35
|
+
const accountKey = findAccountPk(key);
|
|
36
|
+
if (accountKey === undefined)
|
|
37
|
+
return false;
|
|
38
|
+
return write(database, () => chatQueries.setChatScope(context, accountKey, chatId, scope));
|
|
39
|
+
},
|
|
34
40
|
chatScopes: async (key, chatIds) => {
|
|
35
41
|
const accountKey = findAccountPk(key);
|
|
36
42
|
return accountKey === undefined
|
package/dist/store/exports.d.ts
CHANGED
|
@@ -70,5 +70,5 @@ export type { MatchPlace, ScoredHit } from "./sqlite/words.js";
|
|
|
70
70
|
export type { TaskDetails } from "./sqlite/work-tasks.js";
|
|
71
71
|
export type { SyncStore } from "./sync.js";
|
|
72
72
|
export type { TagsStore } from "./tags.js";
|
|
73
|
-
export type { AccountKey, AccountMessageFilter, AgentAnswer, BatchMessage, ChatActivity, ChatStats, ConversationBuild, ConversationHit, ConversationSummary, DeletionScope, Delta, IdentityRef, IngestedVia, LinkBatch, LinkedIdentity, LinkOptions, MessageFilter, PersonFacts, PersonRecord, PictureInput, Range, SenderChatStats, StoredAccount, StoredChatFilter, StoredHit, StoredLink, StoredReadiness, TaskAnalysisMark, TaskAnalysisMarkWrite, } from "./types.js";
|
|
73
|
+
export type { AccountKey, AccountMessageFilter, AgentAnswer, BatchMessage, ChatActivity, ChatStats, ConversationBuild, ConversationHit, ConversationSummary, DeletionScope, Delta, IdentityRef, IngestedVia, LinkBatch, LinkedIdentity, LinkOptions, MessageFilter, PersonFacts, PersonRecord, PictureInput, Range, SenderChatStats, StoredAccount, StoredChatFilter, StoredHit, StoredLink, StoredReadiness, TaskAnalysisMark, TaskAnalysisMarkWrite, UnlinkOptions, } from "./types.js";
|
|
74
74
|
export type { AccountVectors, VectorsStore } from "./vectors.js";
|
|
@@ -9,6 +9,8 @@ export declare const IDENTITY_LINK_KIND = "identity_link";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const IDENTITY_LINK_SIGNALS: readonly ["agent", "phone", "email", "guest-email", "name", "account"];
|
|
11
11
|
export type IdentityLinkSignal = (typeof IDENTITY_LINK_SIGNALS)[number];
|
|
12
|
+
/** A mailbox more than one person reads: a role address such as `info@`, or a company's line (`sharedLine`). */
|
|
13
|
+
export type SharedMailbox = "role" | "line";
|
|
12
14
|
/** An `identity_link` proposal's payload. */
|
|
13
15
|
export interface IdentityLinkPayload {
|
|
14
16
|
/** `provider:id` of the identity that would move. */
|
|
@@ -26,6 +28,10 @@ export interface IdentityLinkPayload {
|
|
|
26
28
|
/** Every person the signal points at, the two included, when it points at more than two. */
|
|
27
29
|
candidates?: string[];
|
|
28
30
|
evidence: string[];
|
|
31
|
+
/** The address both people have is a shared mailbox; absent on proposals made before it was recorded. */
|
|
32
|
+
shared?: SharedMailbox;
|
|
33
|
+
/** The shared mailbox's address, with `shared`. */
|
|
34
|
+
mailbox?: string;
|
|
29
35
|
}
|
|
30
36
|
export interface IdentityLinkInput {
|
|
31
37
|
identity: IdentityRef;
|
|
@@ -41,6 +47,15 @@ export interface IdentityLinkDecision {
|
|
|
41
47
|
/** `"owner"` only on a path that established the owner decides; an agent is refused whatever the policy says. */
|
|
42
48
|
by: Decider;
|
|
43
49
|
reason?: string;
|
|
50
|
+
/**
|
|
51
|
+
* With `confirm: false` on a shared-mailbox proposal: the address is this organization's, not one of the two people.
|
|
52
|
+
* `organization` names one; otherwise the one holding the address or its company domain, or one of `name`, or a new
|
|
53
|
+
* company named `name` or the domain.
|
|
54
|
+
*/
|
|
55
|
+
company?: {
|
|
56
|
+
organization?: number;
|
|
57
|
+
name?: string;
|
|
58
|
+
};
|
|
44
59
|
}
|
|
45
60
|
/** One `identity_link`, naming the people as they are now, not as they were when it was proposed. */
|
|
46
61
|
export interface IdentityLinkRow {
|
|
@@ -53,6 +68,10 @@ export interface IdentityLinkRow {
|
|
|
53
68
|
joins: IdentityLinkPayload["joins"];
|
|
54
69
|
signal: IdentityLinkSignal;
|
|
55
70
|
score: number | null;
|
|
71
|
+
/** The address the two people share is a role address (`role`) or a company's line (`line`), not one person's. */
|
|
72
|
+
shared: SharedMailbox | null;
|
|
73
|
+
/** That shared address, which `decideLink` with `company` gives to an organization. */
|
|
74
|
+
mailbox: string | null;
|
|
56
75
|
candidates: string[];
|
|
57
76
|
reason: string | null;
|
|
58
77
|
evidence: string[];
|
|
@@ -64,6 +83,8 @@ export interface IdentityLinkFilter {
|
|
|
64
83
|
person?: string;
|
|
65
84
|
/** `proposed` unless named. */
|
|
66
85
|
status?: IdentityLinkRow["status"] | "all";
|
|
86
|
+
/** `score`: highest score first, proposals without one last, each newest first; newest first otherwise. */
|
|
87
|
+
order?: "newest" | "score";
|
|
67
88
|
limit: number;
|
|
68
89
|
offset: number;
|
|
69
90
|
}
|
|
@@ -24,6 +24,8 @@ export interface IdentitySplitPayload {
|
|
|
24
24
|
/** Either the identities that leave, all of one person, or the merge to undo. */
|
|
25
25
|
export type IdentitySplitInput = ({
|
|
26
26
|
identities: IdentityRef[];
|
|
27
|
+
/** The uid of the person they leave; refused when they sit on someone else. */
|
|
28
|
+
from?: string;
|
|
27
29
|
} | {
|
|
28
30
|
merge: string;
|
|
29
31
|
}) & {
|
package/dist/store/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type { CacheDatabase, CacheStatement, OpenDatabase, SqlValue } from "./dr
|
|
|
20
20
|
export { PRAGMAS } from "./driver.js";
|
|
21
21
|
export { type CitableRecord, EVIDENCE_FINDINGS_KIND, type EvidenceFindingsBatch, type EvidenceFindingsDecider, type EvidenceFindingsReceipt, type EvidenceFindingsStore, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
22
22
|
export { type DamagedTable, type InvalidJson, QUICK_HEALTH_CHECKS, type SearchIndexHealth, type StoreHealth, storeHealth, } from "./health.js";
|
|
23
|
-
export { IDENTITY_LINK_KIND, IDENTITY_LINK_SIGNALS, type IdentityLinkDecision, type IdentityLinkFilter, type IdentityLinkInput, type IdentityLinkPayload, type IdentityLinkRow, type IdentityLinkSignal, type MatchScan, } from "./identity-links.js";
|
|
23
|
+
export { IDENTITY_LINK_KIND, IDENTITY_LINK_SIGNALS, type IdentityLinkDecision, type IdentityLinkFilter, type IdentityLinkInput, type IdentityLinkPayload, type IdentityLinkRow, type IdentityLinkSignal, type MatchScan, type SharedMailbox, } from "./identity-links.js";
|
|
24
24
|
export { IDENTITY_SPLIT_KIND, type IdentitySplitDecision, type IdentitySplitFilter, type IdentitySplitInput, type IdentitySplitMove, type IdentitySplitPayload, type IdentitySplitRow, } from "./identity-splits.js";
|
|
25
25
|
export { ORGANIZATIONS_QUERY, organization, PROJECTS_QUERY, project, REMINDERS_QUERY, reminder, } from "./knowledge-query.js";
|
|
26
26
|
export { MAIL_FINDINGS_KIND, type MailFindingsBatch, type MailFindingsCheck, type MailFindingsStore, } from "./mail-findings.js";
|
package/dist/store/keys.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { StoreContext } from "./sqlite/open.js";
|
|
|
3
3
|
import type { AccountKey, PersonFacts } from "./types.js";
|
|
4
4
|
/** The row ids behind an account and a chat, and the writes several areas share. */
|
|
5
5
|
export declare const keysOver: (context: StoreContext) => {
|
|
6
|
-
accountPk: (key: AccountKey, name?: string | null) => number;
|
|
6
|
+
accountPk: (key: AccountKey, name?: string | null, startScope?: AccountKey["scope"]) => number;
|
|
7
7
|
findAccountPk: (key: AccountKey) => number | undefined;
|
|
8
8
|
findChatPk: (accountKey: number, chatId: Id) => number | undefined;
|
|
9
9
|
chatKeyOf: (key: AccountKey, chatId: Id) => number | undefined;
|
package/dist/store/keys.js
CHANGED
|
@@ -8,7 +8,7 @@ export const keysOver = (context) => {
|
|
|
8
8
|
const findAccountPk = (key) => accounts.findAccountPk(context, key);
|
|
9
9
|
const findChatPk = (accountKey, chatId) => chatQueries.findChatPk(context, accountKey, chatId);
|
|
10
10
|
return {
|
|
11
|
-
accountPk: (key, name = null) => accounts.accountPk(context, key, name),
|
|
11
|
+
accountPk: (key, name = null, startScope) => accounts.accountPk(context, key, name, startScope),
|
|
12
12
|
findAccountPk,
|
|
13
13
|
findChatPk,
|
|
14
14
|
chatKeyOf: (key, chatId) => {
|
package/dist/store/people.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { type PersonPreparationRead } from "./sqlite/person-preparation.js";
|
|
|
12
12
|
import { type ShownBecause } from "./sqlite/person-ties.js";
|
|
13
13
|
import type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
14
14
|
import type { ProposedAction } from "./sqlite/proposed-actions.js";
|
|
15
|
-
import type { AccountKey, IdentityRef, LinkOptions, PersonFacts, PersonRecord, StoredAccount } from "./types.js";
|
|
15
|
+
import type { AccountKey, IdentityRef, LinkOptions, PersonFacts, PersonRecord, StoredAccount, UnlinkOptions } from "./types.js";
|
|
16
16
|
export interface AccountPeople {
|
|
17
17
|
savePeople(key: AccountKey, people: PersonFacts[]): Promise<void>;
|
|
18
18
|
/**
|
|
@@ -73,7 +73,7 @@ export interface PeopleStore extends AccountPeople {
|
|
|
73
73
|
}): Promise<PersonPreparationRead>;
|
|
74
74
|
/** Records the decision in `identity_link_events`; `unlinkIdentity` undoes it. */
|
|
75
75
|
linkIdentities(person: IdentityRef, other: IdentityRef, options: LinkOptions): Promise<PersonRecord>;
|
|
76
|
-
unlinkIdentity(identity: IdentityRef, options:
|
|
76
|
+
unlinkIdentity(identity: IdentityRef, options: UnlinkOptions): Promise<PersonRecord>;
|
|
77
77
|
/** The people merged into this one, newest first, each with the identities that came from it. */
|
|
78
78
|
merges(uid: string): Promise<PersonMerge[]>;
|
|
79
79
|
/** The owner's undo of a merge: the identities that came from `from` go back to it. Gives `from` again. */
|
|
@@ -85,7 +85,10 @@ export interface PeopleStore extends AccountPeople {
|
|
|
85
85
|
* owner's separation or rejection; an open proposal for the same two people is given back instead of a second.
|
|
86
86
|
*/
|
|
87
87
|
proposeLink(input: IdentityLinkInput): Promise<ProposedAction>;
|
|
88
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The owner's decision on an `identity_link`; confirm is refused with `identity.stale` when either person changed.
|
|
90
|
+
* `company` turns down a shared-mailbox proposal and gives its address to an organization (NEED-2528).
|
|
91
|
+
*/
|
|
89
92
|
decideLink(id: string, decision: IdentityLinkDecision): Promise<ProposedAction>;
|
|
90
93
|
/**
|
|
91
94
|
* One pass of the people matcher: the same address joins people in every scope, a phone exactly two people have
|
|
@@ -95,7 +98,10 @@ export interface PeopleStore extends AccountPeople {
|
|
|
95
98
|
scanMatches(options?: {
|
|
96
99
|
full?: boolean;
|
|
97
100
|
}): Promise<MatchScan>;
|
|
98
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* The `identity_link` proposals, newest first or by score (`order`), naming the people as they are now; `proposed`
|
|
103
|
+
* unless `status` says.
|
|
104
|
+
*/
|
|
99
105
|
linkProposals(filter: IdentityLinkFilter): Promise<{
|
|
100
106
|
items: IdentityLinkRow[];
|
|
101
107
|
hasMore: boolean;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import type { CacheDatabase } from "../driver.js";
|
|
2
2
|
import type { AccountKey, StoredAccount } from "../types.js";
|
|
3
3
|
import type { StoreContext } from "./open.js";
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* An account's row, made on first sight; a name only replaces what was known when there is one. `startScope` is the
|
|
6
|
+
* scope a new row takes; an existing row keeps its own, so a CLI's default never undoes the owner's choice.
|
|
7
|
+
*/
|
|
8
|
+
export declare const accountPk: ({ orm, now }: StoreContext, { provider, account, scope }: AccountKey, name?: string | null, startScope?: StoredAccount["scope"]) => number;
|
|
6
9
|
export declare const findAccountPk: ({ orm }: StoreContext, { provider, account }: AccountKey) => number | undefined;
|
|
7
10
|
export declare const accountName: ({ orm }: StoreContext, { provider, account }: AccountKey) => string | null;
|
|
8
11
|
export declare const heldAccounts: ({ orm }: StoreContext) => AccountKey[];
|
|
9
12
|
export declare const storedAccounts: ({ orm }: StoreContext) => StoredAccount[];
|
|
10
13
|
/** One account by provider and external id, never created; a missing one is `not_found`. */
|
|
11
14
|
export declare const storedAccount: ({ orm }: StoreContext, { provider, account }: AccountKey) => StoredAccount;
|
|
15
|
+
/**
|
|
16
|
+
* The owner's word on which side of his life an account is. Triggers move its conversation pieces and involvements;
|
|
17
|
+
* the other search pieces copied the account's scope when they were cut, so they move here, and the word indexes of
|
|
18
|
+
* its documents, mail and calendar events are queued to be built again. A chat with its own scope keeps it; memories
|
|
19
|
+
* and facts carry the scope they were written with.
|
|
20
|
+
*/
|
|
21
|
+
export declare const setAccountScope: (context: StoreContext, key: AccountKey, scope: StoredAccount["scope"]) => StoredAccount;
|
|
12
22
|
/** Everything the account holds, children before parents: the foreign keys are enforced. */
|
|
13
23
|
export declare const purgeAccount: ({ orm, database, now }: StoreContext, accountKey: number) => void;
|
|
14
24
|
/** Identity and person rows a person's own record keeps, not evidence that anyone saw them. */
|
|
@@ -7,10 +7,20 @@ import { forgetErasedSplits } from "./identity-split-proposals.js";
|
|
|
7
7
|
import { mergeSql } from "./merged-persons.js";
|
|
8
8
|
import { accountIdentities, accounts, aliases, botUpdates, chatEventPeople, chatEvents, chatMembers, chats, chunks, fetchLeases, involvements, memberCounts, memberObservationMembers, memberObservations, memberStays, messageReactions, messageRevisions, messages, messageTranscripts, pollVotes, projects, syncCursors, syncRanges, syncs, } from "./schema.js";
|
|
9
9
|
import { dropUnusedVectors } from "./vector-index.js";
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* An account's row, made on first sight; a name only replaces what was known when there is one. `startScope` is the
|
|
12
|
+
* scope a new row takes; an existing row keeps its own, so a CLI's default never undoes the owner's choice.
|
|
13
|
+
*/
|
|
14
|
+
export const accountPk = ({ orm, now }, { provider, account, scope }, name = null, startScope) => Number(orm
|
|
12
15
|
.insert(accounts)
|
|
13
|
-
.values({
|
|
16
|
+
.values({
|
|
17
|
+
provider,
|
|
18
|
+
externalId: account,
|
|
19
|
+
name,
|
|
20
|
+
scope: scope ?? startScope ?? "personal",
|
|
21
|
+
createdAt: now(),
|
|
22
|
+
updatedAt: now(),
|
|
23
|
+
})
|
|
14
24
|
.onConflictDoUpdate({
|
|
15
25
|
target: [accounts.provider, accounts.externalId],
|
|
16
26
|
set: {
|
|
@@ -56,6 +66,35 @@ export const storedAccount = ({ orm }, { provider, account }) => {
|
|
|
56
66
|
throw new CliError("not_found", `no ${provider} account ${account} in the store`);
|
|
57
67
|
return found;
|
|
58
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* The owner's word on which side of his life an account is. Triggers move its conversation pieces and involvements;
|
|
71
|
+
* the other search pieces copied the account's scope when they were cut, so they move here, and the word indexes of
|
|
72
|
+
* its documents, mail and calendar events are queued to be built again. A chat with its own scope keeps it; memories
|
|
73
|
+
* and facts carry the scope they were written with.
|
|
74
|
+
*/
|
|
75
|
+
export const setAccountScope = (context, key, scope) => {
|
|
76
|
+
const { database, now } = context;
|
|
77
|
+
const held = storedAccount(context, key);
|
|
78
|
+
if (held.scope === scope)
|
|
79
|
+
return held;
|
|
80
|
+
database.prepare("UPDATE accounts SET scope = ?, updated_at = ? WHERE id = ?").run(scope, now(), held.id);
|
|
81
|
+
database
|
|
82
|
+
.prepare("UPDATE chunks SET scope = ? WHERE account_id = ? AND chunkable_type <> 'conversation' AND scope IN ('personal', 'work')")
|
|
83
|
+
.run(scope, held.id);
|
|
84
|
+
for (const [type, ids] of [
|
|
85
|
+
["document", "SELECT id FROM documents WHERE account_id = ?"],
|
|
86
|
+
["email", "SELECT id FROM emails WHERE account_id = ?"],
|
|
87
|
+
[
|
|
88
|
+
"event",
|
|
89
|
+
"SELECT DISTINCT ce.event_id AS id FROM calendar_entries ce JOIN calendars c ON c.id = ce.calendar_id " +
|
|
90
|
+
"WHERE c.account_id = ? AND ce.event_id IS NOT NULL",
|
|
91
|
+
],
|
|
92
|
+
])
|
|
93
|
+
database
|
|
94
|
+
.prepare(`INSERT OR IGNORE INTO ${type}_index_pending (indexable_type, id) SELECT '${type}', id FROM (${ids})`)
|
|
95
|
+
.run(held.id);
|
|
96
|
+
return { ...held, scope };
|
|
97
|
+
};
|
|
59
98
|
/** Everything the account holds, children before parents: the foreign keys are enforced. */
|
|
60
99
|
export const purgeAccount = ({ orm, database, now }, accountKey) => {
|
|
61
100
|
const unseenBefore = unreferenced(database, "identities");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoreContext } from "./open.js";
|
|
2
|
+
/** Gives the address to the organization, making its `email` identity when the store has none. */
|
|
3
|
+
export declare const holdAddress: ({ database, now }: StoreContext, organization: number, email: string, { method, author }: {
|
|
4
|
+
method: string;
|
|
5
|
+
author: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The organization an address belongs to: the one holding the address, else the one holding its company domain, else
|
|
9
|
+
* the one of exactly this name; else a new company of this name. The address joins it, so the next lookup finds it.
|
|
10
|
+
* More than one match is refused with `reason`, for the caller to name the one meant.
|
|
11
|
+
*/
|
|
12
|
+
export declare const organizationOfAddress: (context: StoreContext, { name, email, method, author, reason, }: {
|
|
13
|
+
name: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
method: string;
|
|
16
|
+
author: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
}) => number;
|