@wirecat/cli-core 1.0.0-rc.0 → 1.0.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 +97 -0
- package/THIRD_PARTY_NOTICES +4 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/account-rename.js +1 -1
- package/dist/cli/bot/api-input.d.ts +5 -0
- package/dist/cli/bot/api-input.js +6 -1
- package/dist/cli/bot/api.js +7 -1
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/service-api.js +3 -1
- package/dist/crm/manifest/map.d.ts +5 -2
- package/dist/crm/manifest/map.js +14 -2
- package/dist/domain/organization-sectors.d.ts +10 -0
- package/dist/domain/organization-sectors.generated.d.ts +11 -0
- package/dist/domain/organization-sectors.generated.js +14 -0
- package/dist/domain/organization-sectors.js +9 -0
- package/dist/domain/person-kinds.d.ts +1 -1
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/knowledge-lists.d.ts +1 -0
- package/dist/entities/knowledge-lists.js +2 -0
- package/dist/errors/reasons.js +12 -3
- package/dist/mail/score.d.ts +2 -0
- package/dist/mail/score.js +9 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/search-all-rank.d.ts +44 -0
- package/dist/services/search-all-rank.js +112 -0
- package/dist/services/search-all-tracker.d.ts +58 -0
- package/dist/services/search-all-tracker.js +155 -0
- package/dist/services/search-all.d.ts +1 -8
- package/dist/services/search-all.js +18 -199
- package/dist/services/tracker-meaning.js +1 -1
- package/dist/store/areas.d.ts +1 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/people.d.ts +22 -1
- package/dist/store/people.js +15 -1
- package/dist/store/sqlite/domain-organizations.d.ts +33 -0
- package/dist/store/sqlite/domain-organizations.js +230 -0
- package/dist/store/sqlite/knowledge.d.ts +2 -9
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +21 -0
- package/dist/store/sqlite/organizations.d.ts +12 -1
- package/dist/store/sqlite/organizations.js +9 -1
- package/dist/store/sqlite/people-list.d.ts +6 -1
- package/dist/store/sqlite/people-list.js +66 -14
- package/dist/store/sqlite/person-match-scan.js +11 -1
- package/dist/store/sqlite/schema/sender-bots.d.ts +288 -0
- package/dist/store/sqlite/schema/sender-bots.js +22 -0
- package/dist/store/sqlite/schema.d.ts +1 -0
- package/dist/store/sqlite/schema.js +2 -0
- package/dist/store/sqlite/sender-bots.d.ts +43 -0
- package/dist/store/sqlite/sender-bots.js +189 -0
- package/dist/store/sqlite/sender-signals.d.ts +5 -2
- package/dist/store/sqlite/sender-signals.js +6 -6
- package/dist/store/sqlite/tracker.d.ts +11 -9
- package/dist/store/sqlite/tracker.js +27 -12
- package/dist/store/sqlite/work-tasks.js +2 -0
- package/dist/tracker/cli/index.d.ts +1 -1
- package/dist/tracker/cli/index.js +83 -24
- package/dist/tracker/sync.js +43 -20
- package/dist/tracker/writes.d.ts +28 -0
- package/dist/tracker/writes.js +141 -19
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,103 @@ 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
|
+
## 1.0.0 — 25.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Sender bots, apart from people (store version 74).** A program that writes to the owner becomes a `sender_bots`
|
|
13
|
+
row. That covers a no-reply or alert address, a messenger bot, and a service's signed automatic mail. A bot is never
|
|
14
|
+
proposed as the same person and never offered by `people.similar`. It has no ties, and `tasks.assign` refuses it
|
|
15
|
+
with `sender-bot.assignee`. The owner's `store.people.moveToBot` and `moveToPerson` move a person, a bot or one
|
|
16
|
+
identity for its whole history. The owner's choice wins over the rules, and every move is logged in
|
|
17
|
+
`sender_bot_moves`. See [ARCHITECTURE.md, "Sender bots"](docs/dev/ARCHITECTURE.md) and
|
|
18
|
+
[schema.md](docs/storage/schema.md#sender_bots).
|
|
19
|
+
- **A page of people reads its List-Ids through an index** (`emails_by_list_id`). It no longer reads the List-Id of
|
|
20
|
+
every stored email.
|
|
21
|
+
- **An organization says what it does: `Organization.sector`.** An organization holding a company mail domain gets
|
|
22
|
+
`bank`, `airline`, `shop`, `news`, `government`, `telecom`, `social`, `delivery` or `financial` from a table of
|
|
23
|
+
domains built into the package from Wikidata (CC0), so no sender is looked up online. It is stored in the
|
|
24
|
+
organization's `metadata.sector`; free mail and sending platforms never give one. The first list after the
|
|
25
|
+
upgrade sets it for the organizations already stored
|
|
26
|
+
([ARCHITECTURE](docs/dev/ARCHITECTURE.md#entities-and-source-records)).
|
|
27
|
+
- **Organizations from mail domains.** A sender bot or a shared mailbox at a company domain joins that domain's
|
|
28
|
+
organization when people are listed: the one already holding an address there, else a new one, named by the sender
|
|
29
|
+
when the name is a company's, else by the domain. Subdomains count as their registrable domain. A human writing
|
|
30
|
+
from that domain gets a `member-of` link to it and is never merged. Free mail, throwaway mail and sending platforms
|
|
31
|
+
(newsletter hosts and mail services) make no organization. The owner's word holds: a membership the owner removed,
|
|
32
|
+
an organization the owner erased and a bot the owner moved to a person are not grouped again. See
|
|
33
|
+
[ARCHITECTURE.md, "Organizations from mail domains"](docs/dev/ARCHITECTURE.md).
|
|
34
|
+
- **`issues search` finds issues, projects and comments by meaning too**, once `sync --embed` built their vectors, and
|
|
35
|
+
ranks them as the `tracker` lane of `search all` does: the same lane, now `searchTracker` in
|
|
36
|
+
`src/services/search-all-tracker.ts`. A question finds what holds some of its words. Each hit has `found_by`;
|
|
37
|
+
searched by words only, the answer says why in `missing` (`field: found_by`) with a `sync --embed` step
|
|
38
|
+
([TRACKER.md](docs/dev/TRACKER.md#commands)). The linear rivals benchmark found 7 of 27 with this command and 27
|
|
39
|
+
of 27 with memo's `search all` over the same copy
|
|
40
|
+
([cli-testing](https://github.com/WireCatLabs/cli-testing/blob/main/performance/tracker/linear-rivals/README.md)).
|
|
41
|
+
- **A label, state, user, team or project made after the last sync is found for a write.** A deleted one is not. `issues create` and
|
|
42
|
+
`issues update` look a name the copy lacks up in one `changes` call from that kind's last sync cursor, and keep the
|
|
43
|
+
row in the copy; with no cursor, or more changes than one page, the refusal says it is not in the copy and to run
|
|
44
|
+
sync. A name no row has is refused with the nearest names as `candidates`, each with its team.
|
|
45
|
+
- **`store.tracker.save` and `removeUnlisted` take sync state to save in the same transaction**: `save(key, kind,
|
|
46
|
+
records, now, state?)` and `removeUnlisted(..., { state })`, as `mail.saveThreads` takes its states. `syncTracker`
|
|
47
|
+
saves a page's cursor this way, so a wrapper around `store.tracker` must pass `state` on. A dry run of
|
|
48
|
+
`removeUnlisted` now only reads
|
|
49
|
+
([TRACKER.md](docs/dev/TRACKER.md#synctrackersource-store-account-options)).
|
|
50
|
+
|
|
51
|
+
### Changed — may break callers
|
|
52
|
+
|
|
53
|
+
- **`account rename` refuses an unreadable config file with `config.unreadable`, not `account-rename.config`.** The
|
|
54
|
+
family audit found one failure, "the config file cannot be read", under two names: this one and mail-cli's
|
|
55
|
+
`mail.config-unreadable`. `config.unreadable` is the one name for it, and mail-cli raises it too.
|
|
56
|
+
|
|
57
|
+
### Changed — experimental
|
|
58
|
+
|
|
59
|
+
- **`people.list` rows have `bot`**: `sender-bot:<id>` for a sender bot, else `null`. A bot is still listed as
|
|
60
|
+
`automated` under its `person:<uid>` ref, so `people list kind:automated` and `people show` keep working. A bot's
|
|
61
|
+
`ties` are empty.
|
|
62
|
+
- **`KindSignal` gains `owner-choice`**: the signal of a bot the owner made when nothing else marks it.
|
|
63
|
+
- **`KIND_RULES` goes to 7.** The first list after the upgrade works out every kind again and moves the programs it
|
|
64
|
+
finds.
|
|
65
|
+
- **`KIND_RULES` goes to 8.** The first list after the upgrade works out every kind again and groups the senders it
|
|
66
|
+
finds under their organizations. A shared mailbox an organization now holds gains the `organization` kind signal.
|
|
67
|
+
The tracker commands are not in the stable API; these may still break a caller that relied on the old answers.
|
|
68
|
+
|
|
69
|
+
- **A quoted argument to `issues search` is words in any order, not a phrase.** `issues search "invoice currency"`
|
|
70
|
+
now matches as `issues search invoice currency` does, as its help says. Quote marks inside the query
|
|
71
|
+
(`'"invoice currency"'`) still match a phrase, as in `search all`. A query naming a field (`from:`) is refused.
|
|
72
|
+
- **An `issues list` filter value the copy holds no row of is refused** (`validation_error`, `tracker.reference`)
|
|
73
|
+
instead of answering no issues. A caller that passed an id of a row not yet synced gets the error and runs sync.
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
- **A question in `search all` no longer finds deals, leads, tracker items or business records by its function
|
|
78
|
+
words.** A question is searched by any of its words, so «что с логотипом?» also found a deal titled «Что мы
|
|
79
|
+
обещали», and «кто ругался что мы…» put a note ranked by «что» first. The CRM, tracker and business lanes now
|
|
80
|
+
leave out words like «что», «кто», «мы», "the", the same list the message search uses; a question made only of
|
|
81
|
+
them is searched as typed.
|
|
82
|
+
- **A CRM's own address field is copied.** A typed entry of type `location` (Attio) was skipped, so the field never
|
|
83
|
+
reached the store. It is now one line of the parts present, street to country, and a search finds the record by its
|
|
84
|
+
city. See [CRM.md](docs/dev/CRM.md).
|
|
85
|
+
- **A tracker's `sync --embed` offers to run again while chunks are left without vectors.** One run embeds at most
|
|
86
|
+
600 chunks; past that it answered `left: true` and no next step, so an agent stopped with part of the issues,
|
|
87
|
+
projects and comments missing from `search all` by meaning. It now adds a `tracker.sync` step with `embed: true`
|
|
88
|
+
and the count left, as a CRM CLI's `sync --embed` does.
|
|
89
|
+
- **`issues list` filters by name.** `label:Bug`, `state:"In Progress"`, `assignee:"Ada Owner"`, `team:ENG`,
|
|
90
|
+
`project:"Billing revamp"` and `sprint:12` match a name in any letter case, or the id as before; a name several
|
|
91
|
+
rows have (every team's "In Progress") matches each. An unknown name is `tracker.reference` with the nearest names
|
|
92
|
+
in `candidates`, no longer an empty list. `TrackerFilter`'s `assignee`, `project`, `state`, `label` and `sprint`
|
|
93
|
+
take several ids too.
|
|
94
|
+
- **Scoring mail senders no longer rebuilds the throwaway-domain list for each sender.** The spam score
|
|
95
|
+
(`scoreGroup`) and the organizations from mail domains now share one set built on first use
|
|
96
|
+
(`isDisposableDomain`). Scoring 20,000 senders took about 7 s and now takes about 0.2 s.
|
|
97
|
+
- **A tracker sync commits half as often** (#3336). Each page of changes is saved with the cursor after it in one
|
|
98
|
+
transaction, the end of an id pass with its marks, and the end of the run in one more. Each commit waits for the
|
|
99
|
+
disk: the strict fake's 8 kinds of 3 rows went from 79 commits to 38 (median 354 → 214 ms on a busy disk), 2,000
|
|
100
|
+
issues from 101 to 53
|
|
101
|
+
([sync-writes](https://github.com/WireCatLabs/cli-testing/tree/main/performance/tracker/sync-writes)). What is
|
|
102
|
+
stored is the same. A page is now saved with its cursor or not at all; before, a crash between the two read the
|
|
103
|
+
page again.
|
|
104
|
+
|
|
8
105
|
## 1.0.0-rc.0 — 25.11.2026
|
|
9
106
|
|
|
10
107
|
### Added
|
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -802,3 +802,7 @@ SPDX-License-Identifier: Unicode-3.0
|
|
|
802
802
|
|
|
803
803
|
EmbeddingGemma (Google) is used under the Gemma Terms of Use, https://ai.google.dev/gemma/terms, including its use
|
|
804
804
|
restrictions (https://ai.google.dev/gemma/prohibited_use_policy).
|
|
805
|
+
|
|
806
|
+
The domain-to-sector table (src/domain/organization-sectors.generated.ts) is built from Wikidata
|
|
807
|
+
(https://www.wikidata.org), whose structured data is available under CC0 1.0
|
|
808
|
+
(https://creativecommons.org/publicdomain/zero/1.0/). The export date is in the file's header.
|
|
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
|
|
26
26
|
export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
|
|
27
|
+
action?: undefined;
|
|
27
28
|
name: string;
|
|
28
29
|
installed: boolean;
|
|
29
30
|
active: boolean;
|
|
30
31
|
servicePath: string;
|
|
31
32
|
timerPath: string;
|
|
32
|
-
action?: undefined;
|
|
33
33
|
} | {
|
|
34
34
|
active?: undefined;
|
|
35
35
|
name: string;
|
|
@@ -147,7 +147,7 @@ export const accountRenameCommand = (app, renaming, options = {}) => annotate(ne
|
|
|
147
147
|
const read = readConfigFile(settings.configPath);
|
|
148
148
|
if ("issue" in read)
|
|
149
149
|
throw new CliError("configuration_error", `${settings.configPath} cannot be read — fix it first`, {
|
|
150
|
-
reason: "
|
|
150
|
+
reason: "config.unreadable",
|
|
151
151
|
});
|
|
152
152
|
const sections = [["profiles"], ["personal", "profiles"]].filter((path) => at(read.raw, [...path, profile]) !== undefined);
|
|
153
153
|
const storeHere = existsSync(storePath(env));
|
|
@@ -16,6 +16,11 @@ export declare const checkApiBody: (operation: ManifestOperation, text: string |
|
|
|
16
16
|
export declare const parseApiJson: (text: string) => unknown;
|
|
17
17
|
export declare const apiJson: (value: unknown) => string;
|
|
18
18
|
export declare const apiPlainJson: (value: unknown) => unknown;
|
|
19
|
+
/**
|
|
20
|
+
* An empty or all-space text in a required argument or parameter: the service may read it as no id at all, and an empty
|
|
21
|
+
* path segment can reach another endpoint, so it is refused before anything is sent.
|
|
22
|
+
*/
|
|
23
|
+
export declare const isBlank: (value: unknown) => boolean;
|
|
19
24
|
/**
|
|
20
25
|
* A GraphQL operation's variables: the body's (`--body`, all of them as one object) with each flag over it, read by
|
|
21
26
|
* the variable's schema. A name the operation does not declare, or a required one left out, is refused unsent.
|
|
@@ -119,6 +119,11 @@ const finite = (key, value) => {
|
|
|
119
119
|
};
|
|
120
120
|
export const apiJson = (value) => stringify(value, finite) ?? "null";
|
|
121
121
|
export const apiPlainJson = (value) => JSON.parse(stringify(value, (key, inner) => isLosslessNumber(inner) && !isSafeNumber(inner.value) ? inner.toString() : finite(key, inner)) ?? "null");
|
|
122
|
+
/**
|
|
123
|
+
* An empty or all-space text in a required argument or parameter: the service may read it as no id at all, and an empty
|
|
124
|
+
* path segment can reach another endpoint, so it is refused before anything is sent.
|
|
125
|
+
*/
|
|
126
|
+
export const isBlank = (value) => typeof value === "string" && value.trim() === "";
|
|
122
127
|
/** A JSON object with no lossless number at its top: what a GraphQL body of variables must be. */
|
|
123
128
|
const isVariables = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && !isLosslessNumber(value);
|
|
124
129
|
/**
|
|
@@ -145,7 +150,7 @@ export const graphqlVariables = (operation, body, fields) => {
|
|
|
145
150
|
sent: false,
|
|
146
151
|
});
|
|
147
152
|
const missing = Object.entries(binding.variables)
|
|
148
|
-
.filter(([name, type]) => type.endsWith("!") && variables[name] == null)
|
|
153
|
+
.filter(([name, type]) => type.endsWith("!") && (variables[name] == null || isBlank(variables[name])))
|
|
149
154
|
.map(([name]) => `--${apiFlagOf(name)}`);
|
|
150
155
|
if (missing.length > 0)
|
|
151
156
|
throw new CliError("validation_error", `${operation.command} needs ${missing.join(", ")}`, { sent: false });
|
package/dist/cli/bot/api.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Command, Option } from "commander";
|
|
|
4
4
|
import { secretInput } from "../../runs/run-context.js";
|
|
5
5
|
import { NO_EFFECTS, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
6
|
import { API_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
7
|
-
import { apiFlagOf, apiJson, apiOptionKey, graphqlVariables, readApiBody, readApiBytes, sendsBytes, } from "./api-input.js";
|
|
7
|
+
import { apiFlagOf, apiJson, apiOptionKey, graphqlVariables, isBlank, readApiBody, readApiBytes, sendsBytes, } from "./api-input.js";
|
|
8
8
|
/**
|
|
9
9
|
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
10
10
|
* name, and an operation without a group stays `api <command>`. The same rule as cli-base's `apiCommandPath`; `group`
|
|
@@ -82,6 +82,12 @@ export const generatedApiCommand = (api) => {
|
|
|
82
82
|
const raw = options[apiOptionKey(parameter.name)];
|
|
83
83
|
if (raw === undefined)
|
|
84
84
|
continue;
|
|
85
|
+
// A body field may be empty on purpose (Telegram's setWebhook url removes the hook); GraphQL's are checked as
|
|
86
|
+
// variables.
|
|
87
|
+
if (parameter.required && parameter.in !== "body" && isBlank(raw))
|
|
88
|
+
throw new CliError("validation_error", `--${apiFlagOf(parameter.name)} of ${operation.command} is empty`, {
|
|
89
|
+
sent: false,
|
|
90
|
+
});
|
|
85
91
|
if (parameter.in !== "body") {
|
|
86
92
|
const problem = api.checkParameter(parameter.name, parameter.schema, raw);
|
|
87
93
|
if (problem)
|
|
@@ -58,8 +58,8 @@ export interface CopyAge {
|
|
|
58
58
|
}
|
|
59
59
|
export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
|
|
60
60
|
export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
|
|
61
|
-
missing?: undefined;
|
|
62
61
|
next?: undefined;
|
|
62
|
+
missing?: undefined;
|
|
63
63
|
meta?: undefined;
|
|
64
64
|
} | {
|
|
65
65
|
missing: {
|
package/dist/cli/service-api.js
CHANGED
|
@@ -9,7 +9,7 @@ import { newOperationId } from "../sends/send-id.js";
|
|
|
9
9
|
import { refusedPlace } from "../sends/upload.js";
|
|
10
10
|
import { apiPathOf, generatedApiCommand } from "./bot/api.js";
|
|
11
11
|
import { httpApiExchange, httpApiRequest, unsendableBody } from "./bot/api-http.js";
|
|
12
|
-
import { apiJson, checkApiBody, checkApiParameter, graphqlVariables, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
12
|
+
import { apiJson, checkApiBody, checkApiParameter, graphqlVariables, isBlank, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
13
13
|
import { baseContext, outputFor } from "./context.js";
|
|
14
14
|
import { NO_EFFECTS } from "./effects.js";
|
|
15
15
|
import { itemOf, listOf, renderAnswer } from "./envelope.js";
|
|
@@ -459,6 +459,8 @@ export const serviceApiWriter = (options) => {
|
|
|
459
459
|
: parameter.in === "query" || parameter.in === "path"
|
|
460
460
|
? input[parameter.in][parameter.name]
|
|
461
461
|
: undefined;
|
|
462
|
+
if (parameter.required && raw !== undefined && isBlank(flagText(raw)))
|
|
463
|
+
throw new CliError("validation_error", `${parameter.name} of ${operation.command} is empty`, { sent: false });
|
|
462
464
|
const problem = raw === undefined ? undefined : checkApiParameter(parameter.name, parameter.schema, flagText(raw), schemas);
|
|
463
465
|
if (problem)
|
|
464
466
|
throw new CliError("validation_error", problem);
|
|
@@ -44,8 +44,11 @@ export declare const FIELDS: {
|
|
|
44
44
|
export declare const convert: (conversion: Conversion, value: unknown) => unknown;
|
|
45
45
|
/** Our fields from the rules, each converted by `types`; a rule whose path is missing gives no key. */
|
|
46
46
|
export declare const mapFields: (rules: Readonly<Record<string, CrmRule | undefined>>, types: Readonly<Record<string, Conversion>>, raw: CrmRaw) => Record<string, unknown>;
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Where a typed entry keeps its value, by its type, as Attio names them; a manifest's `typed.paths` adds or replaces.
|
|
49
|
+
* A list of paths is one text of the parts present: an address is kept in parts, and searched as one line.
|
|
50
|
+
*/
|
|
51
|
+
export declare const TYPED_VALUE_PATHS: Readonly<Record<string, string | readonly string[]>>;
|
|
49
52
|
export interface RecordRules {
|
|
50
53
|
map: Readonly<Record<string, CrmRule | undefined>>;
|
|
51
54
|
custom?: {
|
package/dist/crm/manifest/map.js
CHANGED
|
@@ -178,7 +178,10 @@ export const mapFields = (rules, types, raw) => {
|
|
|
178
178
|
}
|
|
179
179
|
return out;
|
|
180
180
|
};
|
|
181
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* Where a typed entry keeps its value, by its type, as Attio names them; a manifest's `typed.paths` adds or replaces.
|
|
183
|
+
* A list of paths is one text of the parts present: an address is kept in parts, and searched as one line.
|
|
184
|
+
*/
|
|
182
185
|
export const TYPED_VALUE_PATHS = {
|
|
183
186
|
text: "value",
|
|
184
187
|
number: "value",
|
|
@@ -196,6 +199,15 @@ export const TYPED_VALUE_PATHS = {
|
|
|
196
199
|
"phone-number": "phone_number",
|
|
197
200
|
"personal-name": "full_name",
|
|
198
201
|
interaction: "interacted_at",
|
|
202
|
+
location: ["line_1", "line_2", "line_3", "line_4", "locality", "region", "postcode", "country_code"],
|
|
203
|
+
};
|
|
204
|
+
const typedValue = (entry, path) => {
|
|
205
|
+
if (typeof path === "string")
|
|
206
|
+
return at(entry, path);
|
|
207
|
+
return path
|
|
208
|
+
?.map((one) => text(at(entry, one)))
|
|
209
|
+
.filter((part) => part !== null)
|
|
210
|
+
.join(", ");
|
|
199
211
|
};
|
|
200
212
|
/** The current entries' values: one alone is the value, several a list, none no value. */
|
|
201
213
|
const typedOf = (entries, typed) => {
|
|
@@ -206,7 +218,7 @@ const typedOf = (entries, typed) => {
|
|
|
206
218
|
return [];
|
|
207
219
|
const type = text(at(entry, typed.by));
|
|
208
220
|
const path = type === null ? undefined : (typed.paths?.[type] ?? TYPED_VALUE_PATHS[type]);
|
|
209
|
-
const value =
|
|
221
|
+
const value = typedValue(entry, path);
|
|
210
222
|
return value === null || value === undefined || value === "" ? [] : [value];
|
|
211
223
|
});
|
|
212
224
|
return values.length > 1 ? values : (values[0] ?? null);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SECTOR_DOMAINS } from "./organization-sectors.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* What an organization does (a bank, an airline, a shop), from the websites Wikidata lists, built into the package by
|
|
4
|
+
* `scripts/organization-sectors.ts`. Apart from `Category`, which says what an organization is to the owner.
|
|
5
|
+
*/
|
|
6
|
+
export type Sector = keyof typeof SECTOR_DOMAINS;
|
|
7
|
+
/** Most specific first: an organization holding domains of two sectors takes the first. */
|
|
8
|
+
export declare const SECTORS: Sector[];
|
|
9
|
+
/** The sector of a registrable domain, lower case as `registrableOf` gives it. */
|
|
10
|
+
export declare const sectorOfDomain: (domain: string) => Sector | undefined;
|