@wirecat/cli-core 0.606.0 → 0.608.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 +196 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/reads.js +5 -0
- package/dist/cli/app-mcp-command.d.ts +6 -2
- package/dist/cli/app-mcp-command.js +11 -2
- package/dist/cli/csv.d.ts +10 -0
- package/dist/cli/csv.js +22 -0
- package/dist/cli/early-refusal.d.ts +10 -0
- package/dist/cli/early-refusal.js +19 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/profile-token.d.ts +29 -0
- package/dist/cli/profile-token.js +65 -0
- package/dist/cli/program.js +4 -2
- package/dist/crm/cli/csv.d.ts +23 -0
- package/dist/crm/cli/csv.js +135 -0
- package/dist/crm/cli/index.d.ts +1 -1
- package/dist/crm/cli/index.js +33 -21
- package/dist/crm/cli/pipeline-view.d.ts +3 -0
- package/dist/crm/cli/pipeline-view.js +36 -0
- package/dist/crm/writes.d.ts +6 -4
- package/dist/crm/writes.js +17 -13
- package/dist/documents.d.ts +2 -0
- package/dist/documents.js +2 -0
- package/dist/domain/business.d.ts +79 -0
- package/dist/domain/business.js +42 -0
- package/dist/domain/finance.d.ts +2 -0
- package/dist/domain/finance.js +2 -2
- package/dist/domain/google-documents.d.ts +2 -0
- package/dist/domain/google-documents.js +3 -1
- package/dist/domain/money.d.ts +2 -0
- package/dist/domain/money.js +11 -3
- package/dist/domain/providers.d.ts +36 -1
- package/dist/domain/providers.js +69 -7
- package/dist/domain/record-fields.d.ts +42 -0
- package/dist/domain/record-fields.js +122 -0
- package/dist/domain/record-types.d.ts +489 -16
- package/dist/domain/record-types.js +374 -7
- package/dist/domain/records.d.ts +96 -5
- package/dist/domain/records.js +178 -32
- package/dist/domain/ref-summaries.js +5 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +5 -0
- package/dist/domain/vcard.d.ts +25 -0
- package/dist/domain/vcard.js +267 -0
- package/dist/entities/deal.d.ts +14 -0
- package/dist/entities/deal.js +3 -0
- package/dist/entities/index.d.ts +12 -0
- package/dist/errors/reasons.js +63 -4
- package/dist/fetch/addresses.d.ts +5 -0
- package/dist/fetch/addresses.js +76 -0
- package/dist/fetch/page.d.ts +64 -0
- package/dist/fetch/page.js +256 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/meetings/calendar-text.d.ts +1 -1
- package/dist/meetings/calendar-text.js +4 -0
- package/dist/meetings/event-store.d.ts +2 -2
- package/dist/search/account-list.d.ts +4 -0
- package/dist/search/account-list.js +19 -8
- package/dist/search/query.js +2 -2
- package/dist/services/events-search.js +2 -2
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/ingest.d.ts +56 -8
- package/dist/services/ingest.js +95 -61
- package/dist/services/messages-search.js +3 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/notes-search.js +1 -0
- package/dist/services/proposals/kinds/contracts.d.ts +4 -0
- package/dist/services/proposals/kinds/contracts.js +9 -0
- package/dist/services/proposals/kinds/finance.d.ts +4 -0
- package/dist/services/proposals/kinds/finance.js +14 -35
- package/dist/services/proposals/kinds/orders.js +7 -30
- package/dist/services/proposals/kinds/shared.d.ts +27 -1
- package/dist/services/proposals/kinds/shared.js +34 -0
- package/dist/services/proposals/kinds/source-review.d.ts +4 -0
- package/dist/services/proposals/kinds/source-review.js +45 -0
- package/dist/services/proposals/kinds/subscriptions.d.ts +9 -0
- package/dist/services/proposals/kinds/subscriptions.js +24 -0
- package/dist/services/proposals/kinds/transactions.d.ts +4 -0
- package/dist/services/proposals/kinds/transactions.js +10 -0
- package/dist/services/proposals/registry.js +9 -0
- package/dist/services/search-all-meetings.js +2 -2
- package/dist/services/search-all.js +4 -3
- package/dist/services/search-kind.js +3 -3
- package/dist/store/decisions.js +5 -1
- package/dist/store/index.d.ts +14 -3
- package/dist/store/index.js +3 -0
- package/dist/store/people.js +1 -1
- package/dist/store/source-review.d.ts +64 -0
- package/dist/store/source-review.js +7 -0
- package/dist/store/sqlite/accounts.d.ts +1 -1
- package/dist/store/sqlite/accounts.js +24 -1
- package/dist/store/sqlite/added-sources.d.ts +82 -0
- package/dist/store/sqlite/added-sources.js +237 -0
- package/dist/store/sqlite/business-contracts.d.ts +90 -0
- package/dist/store/sqlite/business-contracts.js +182 -0
- package/dist/store/sqlite/calendar-events.js +7 -3
- package/dist/store/sqlite/calendar-forget.js +3 -0
- package/dist/store/sqlite/calendar.d.ts +21 -1
- package/dist/store/sqlite/calendar.js +27 -7
- package/dist/store/sqlite/chat-rekey.js +7 -0
- package/dist/store/sqlite/chats.d.ts +3 -1
- package/dist/store/sqlite/chats.js +15 -1
- package/dist/store/sqlite/crm-rows.d.ts +44 -0
- package/dist/store/sqlite/crm-rows.js +195 -0
- package/dist/store/sqlite/crm.d.ts +2 -11
- package/dist/store/sqlite/crm.js +11 -166
- package/dist/store/sqlite/deals.d.ts +4 -8
- package/dist/store/sqlite/deals.js +5 -3
- package/dist/store/sqlite/document-transfer/snapshot.js +2 -2
- package/dist/store/sqlite/emails.js +2 -0
- package/dist/store/sqlite/entity-types.d.ts +14 -9
- package/dist/store/sqlite/entity-types.js +4 -10
- package/dist/store/sqlite/evidence-signature.d.ts +114 -0
- package/dist/store/sqlite/evidence-signature.js +349 -0
- package/dist/store/sqlite/evidence-sources.d.ts +2 -1
- package/dist/store/sqlite/evidence-sources.js +7 -3
- package/dist/store/sqlite/facts.d.ts +7 -2
- package/dist/store/sqlite/facts.js +21 -5
- package/dist/store/sqlite/finance.d.ts +18 -105
- package/dist/store/sqlite/finance.js +100 -219
- package/dist/store/sqlite/knowledge.d.ts +8 -2
- package/dist/store/sqlite/knowledge.js +65 -71
- package/dist/store/sqlite/labelled.d.ts +3 -0
- package/dist/store/sqlite/labelled.js +11 -0
- package/dist/store/sqlite/link-kinds.d.ts +2 -0
- package/dist/store/sqlite/link-kinds.js +2 -0
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/memories.d.ts +23 -9
- package/dist/store/sqlite/memories.js +41 -13
- package/dist/store/sqlite/messages.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +103 -0
- package/dist/store/sqlite/money-lines.d.ts +48 -0
- package/dist/store/sqlite/money-lines.js +76 -0
- package/dist/store/sqlite/money-transactions.d.ts +132 -0
- package/dist/store/sqlite/money-transactions.js +295 -0
- package/dist/store/sqlite/notes.d.ts +11 -2
- package/dist/store/sqlite/notes.js +20 -25
- package/dist/store/sqlite/orders.d.ts +36 -6
- package/dist/store/sqlite/orders.js +126 -46
- package/dist/store/sqlite/payment-facts.js +1 -1
- package/dist/store/sqlite/private-people.js +2 -0
- package/dist/store/sqlite/products.d.ts +78 -0
- package/dist/store/sqlite/products.js +131 -0
- package/dist/store/sqlite/project-transfer/records.js +26 -1
- package/dist/store/sqlite/project-transfer/snapshot.js +5 -3
- package/dist/store/sqlite/proposed-actions.d.ts +1 -1
- package/dist/store/sqlite/proposed-actions.js +24 -7
- package/dist/store/sqlite/providers.d.ts +0 -4
- package/dist/store/sqlite/providers.js +20 -2
- package/dist/store/sqlite/record-matching.d.ts +80 -0
- package/dist/store/sqlite/record-matching.js +264 -0
- package/dist/store/sqlite/record-projection.d.ts +89 -0
- package/dist/store/sqlite/record-projection.js +50 -0
- package/dist/store/sqlite/record-projectors-direct.d.ts +17 -0
- package/dist/store/sqlite/record-projectors-direct.js +125 -0
- package/dist/store/sqlite/record-projectors-money.d.ts +26 -0
- package/dist/store/sqlite/record-projectors-money.js +214 -0
- package/dist/store/sqlite/record-projectors-phone.d.ts +28 -0
- package/dist/store/sqlite/record-projectors-phone.js +212 -0
- package/dist/store/sqlite/record-projectors.d.ts +3 -44
- package/dist/store/sqlite/record-projectors.js +7 -67
- package/dist/store/sqlite/record-relations.d.ts +24 -0
- package/dist/store/sqlite/record-relations.js +92 -0
- package/dist/store/sqlite/record-remap.d.ts +12 -0
- package/dist/store/sqlite/record-remap.js +92 -0
- package/dist/store/sqlite/record-run.d.ts +71 -0
- package/dist/store/sqlite/record-run.js +179 -0
- package/dist/store/sqlite/record-settling.d.ts +9 -0
- package/dist/store/sqlite/record-settling.js +74 -0
- package/dist/store/sqlite/record-stamps.d.ts +13 -0
- package/dist/store/sqlite/record-stamps.js +30 -0
- package/dist/store/sqlite/record-writes.d.ts +43 -0
- package/dist/store/sqlite/record-writes.js +307 -0
- package/dist/store/sqlite/records.d.ts +52 -42
- package/dist/store/sqlite/records.js +123 -353
- package/dist/store/sqlite/ref-summaries.d.ts +6 -5
- package/dist/store/sqlite/ref-summaries.js +60 -8
- package/dist/store/sqlite/refunds.d.ts +31 -0
- package/dist/store/sqlite/refunds.js +112 -0
- package/dist/store/sqlite/reviewed.d.ts +109 -0
- package/dist/store/sqlite/reviewed.js +173 -0
- package/dist/store/sqlite/schema.d.ts +2840 -83
- package/dist/store/sqlite/schema.js +256 -1
- package/dist/store/sqlite/source-review-marks.d.ts +54 -0
- package/dist/store/sqlite/source-review-marks.js +143 -0
- package/dist/store/sqlite/source-review.d.ts +54 -0
- package/dist/store/sqlite/source-review.js +221 -0
- package/dist/store/sqlite/stage-amounts.d.ts +14 -0
- package/dist/store/sqlite/stage-amounts.js +23 -0
- package/dist/store/sqlite/subscriptions.d.ts +135 -0
- package/dist/store/sqlite/subscriptions.js +294 -0
- package/dist/store/sqlite/text-input.d.ts +3 -0
- package/dist/store/sqlite/text-input.js +13 -0
- package/dist/store/sqlite/things.js +2 -9
- package/dist/store/sqlite/transaction.d.ts +15 -0
- package/dist/store/sqlite/transaction.js +57 -0
- package/dist/store/sqlite/wallets.d.ts +88 -0
- package/dist/store/sqlite/wallets.js +143 -0
- package/dist/store/store-errors.d.ts +1 -0
- package/dist/store/store-errors.js +45 -0
- package/dist/store/store.d.ts +16 -1
- package/dist/store/store.js +30 -6
- package/package.json +5 -2
- package/schemas/examples/records-business.jsonl +11 -0
- package/schemas/records-envelope.v1.schema.json +1160 -5
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { CATALOG_KINDS, CONTRACT_KINDS, CONTRACT_STATUSES, intervalOf, intervalText, ORDER_DIRECTIONS, PERIOD_UNITS, SUBSCRIPTION_STATUSES, TRANSACTION_STATUSES, WALLET_KINDS, } from "./domain/business.js";
|
|
1
2
|
export { bareCheck, checkWords } from "./domain/checks.js";
|
|
2
3
|
export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
|
|
3
4
|
export { CRM_KINDS, isItemKind, } from "./domain/crm.js";
|
|
@@ -7,15 +8,16 @@ export { validateFormattedText, } from "./domain/formatting.js";
|
|
|
7
8
|
export { formatLocator, isLocator, parseLocator } from "./domain/locator.js";
|
|
8
9
|
export { parseMarkdown } from "./domain/markdown.js";
|
|
9
10
|
export { parseMarkdownSpans } from "./domain/markdown-spans.js";
|
|
10
|
-
export { CURRENCY_SCALES, currencyOf, minorUnits, moneyLabel, moneyOf, } from "./domain/money.js";
|
|
11
|
+
export { CURRENCY_SCALES, currencyOf, formatDecimal, minorUnits, moneyLabel, moneyOf, signedMinorUnits, } from "./domain/money.js";
|
|
11
12
|
export { ORDER_PURPOSES, ORDER_STATUSES, } from "./domain/orders.js";
|
|
12
13
|
export { countedPoll } from "./domain/polls.js";
|
|
13
|
-
export { CRM_OPENS, FOLDER_PROVIDERS, isFolderProvider, isKind, KINDS, kindIn, kindOf, PROVIDERS, providerNamed, providers, UNKNOWN_PROVIDER, useProviders, } from "./domain/providers.js";
|
|
14
|
+
export { ADDED_ACCOUNT, ADDED_PROVIDER, CRM_OPENS, FOLDER_PROVIDERS, holdsKind, isFolderProvider, isKind, KINDS, kindIn, kindOf, kindsIn, PROVIDERS, providerNamed, providers, UNKNOWN_PROVIDER, useProviders, } from "./domain/providers.js";
|
|
14
15
|
export { rankingOptions } from "./domain/rankings-options.js";
|
|
15
|
-
export { envelopeOfJsonl, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, } from "./domain/records.js";
|
|
16
|
+
export { envelopeOfJsonl, envelopeOfText, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, } from "./domain/records.js";
|
|
16
17
|
export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, } from "./domain/references.js";
|
|
17
18
|
export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, ROLE_LISTS, rolesOf, STANDINGS, standingOf, usableLink, } from "./domain/relations.js";
|
|
18
19
|
export { normalizeTag, TAG_TYPES } from "./domain/tags.js";
|
|
20
|
+
export { envelopeOfVcard, isVcard } from "./domain/vcard.js";
|
|
19
21
|
export { DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
|
|
20
22
|
export { canonicalMeetingReference, formatMeetingReference, parseMeetingReference, } from "./meetings/index.js";
|
|
21
23
|
export { act, judge } from "./moderation/check.js";
|
|
@@ -9,5 +9,5 @@ export declare const calendarText: (text: string | null | undefined, { dropSecre
|
|
|
9
9
|
dropSecretLines?: boolean;
|
|
10
10
|
}) => string | null;
|
|
11
11
|
/** The provider fields a calendar entry may keep in `metadata`: none of them can open a meeting. */
|
|
12
|
-
export declare const ENTRY_METADATA_KEYS: readonly ["colorId", "guestsCanInviteOthers", "guestsCanModify", "guestsCanSeeOtherGuests", "hangoutLink", "locked", "privateCopy"];
|
|
12
|
+
export declare const ENTRY_METADATA_KEYS: readonly ["colorId", "guestsCanInviteOthers", "guestsCanModify", "guestsCanSeeOtherGuests", "hangoutLink", "locked", "privateCopy", "callDirection", "callSeconds", "callNumber"];
|
|
13
13
|
export declare const entryMetadata: (metadata: Record<string, unknown> | null | undefined) => Record<string, unknown>;
|
|
@@ -42,6 +42,10 @@ export const ENTRY_METADATA_KEYS = [
|
|
|
42
42
|
"hangoutLink",
|
|
43
43
|
"locked",
|
|
44
44
|
"privateCopy",
|
|
45
|
+
// A phone call's, from a records import: the entry's other columns have no place for them.
|
|
46
|
+
"callDirection",
|
|
47
|
+
"callSeconds",
|
|
48
|
+
"callNumber",
|
|
45
49
|
];
|
|
46
50
|
export const entryMetadata = (metadata) => {
|
|
47
51
|
const kept = {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Event } from "./model.js";
|
|
2
2
|
/** RFC 5545 PARTSTAT: a participant's answer, and the owner's own. */
|
|
3
3
|
export type ParticipantResponse = "needs-action" | "accepted" | "tentative" | "declined" | "delegated";
|
|
4
|
-
/** What kind of entry it is.
|
|
5
|
-
export type EntryEventType = "default" | "out-of-office" | "focus" | "working-location" | "birthday" | "from-mail";
|
|
4
|
+
/** What kind of entry it is. `default`, `from-mail` and `call` are searched (requirements 3.4); `call` is a phone's. */
|
|
5
|
+
export type EntryEventType = "default" | "out-of-office" | "focus" | "working-location" | "birthday" | "from-mail" | "call";
|
|
6
6
|
/** RFC 5545 TRANSP. */
|
|
7
7
|
export type EntryTransparency = "opaque" | "transparent";
|
|
8
8
|
/** RFC 5545 CLASS, plus `default`: the calendar's own setting. */
|
|
@@ -30,7 +30,11 @@ export interface ListContext {
|
|
|
30
30
|
*/
|
|
31
31
|
export interface ListedAccount extends AccountKey {
|
|
32
32
|
kind: Kind | undefined;
|
|
33
|
+
/** Only when it holds more than `kind`: a phone account holds messages and events. */
|
|
34
|
+
kinds?: readonly Kind[];
|
|
33
35
|
}
|
|
36
|
+
/** Whether a listed account holds `kind`. */
|
|
37
|
+
export declare const listedHolds: (account: Pick<ListedAccount, "kind" | "kinds">, kind: Kind) => boolean;
|
|
34
38
|
/** One entry of the list as written, a group's member included, and the accounts it named. */
|
|
35
39
|
export interface ListedEntry {
|
|
36
40
|
entry: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { INTERNAL_NOTES, isDocumentAccountProvider, isFolderProvider, isKind, kindIn, kindOf, providerNamed, providers as registered, UNKNOWN_PROVIDER, } from "../domain/providers.js";
|
|
2
|
+
import { ADDED_PROVIDER, INTERNAL_NOTES, isDocumentAccountProvider, isFolderProvider, isKind, kindIn, kindOf, kindsIn, providerNamed, providers as registered, UNKNOWN_PROVIDER, } from "../domain/providers.js";
|
|
3
3
|
import { isBotProvider } from "./query.js";
|
|
4
4
|
/** Store-wide: every profile, tg, MAX and memo reads the same groups. */
|
|
5
5
|
export const ACCOUNT_GROUPS = "accountGroups";
|
|
@@ -25,12 +25,18 @@ export const groupMembers = (value) => itemsOf(value).map((item) => item.toLower
|
|
|
25
25
|
? fail(`"${item}" names no account after the colon`)
|
|
26
26
|
: item);
|
|
27
27
|
const describe = (accounts) => accounts.map(({ provider, account, name }) => `${provider}:${account}${name ? ` (${name})` : ""}`).join(", ");
|
|
28
|
+
/** Whether a listed account holds `kind`. */
|
|
29
|
+
export const listedHolds = (account, kind) => (account.kinds ?? (account.kind === undefined ? [] : [account.kind])).includes(kind);
|
|
28
30
|
/** The app running knows its own provider is a messenger, entry or not. */
|
|
29
31
|
const kindHere = (provider, running) => provider === running.provider ? kindOf(provider) : kindIn(provider);
|
|
32
|
+
const kindsOfHere = (provider, running) => {
|
|
33
|
+
const kinds = kindsIn(provider);
|
|
34
|
+
return { kind: kindHere(provider, running), ...(kinds.length > 1 ? { kinds } : {}) };
|
|
35
|
+
};
|
|
30
36
|
const heldOf = (stored, running) => [
|
|
31
37
|
...stored
|
|
32
38
|
.filter(({ provider }) => kindIn(provider) !== "notes" && !isDocumentAccountProvider(provider))
|
|
33
|
-
.map(({ provider, account, name }) => ({ provider, account, name,
|
|
39
|
+
.map(({ provider, account, name }) => ({ provider, account, name, ...kindsOfHere(provider, running) })),
|
|
34
40
|
{ provider: "notes", account: INTERNAL_NOTES, name: null, kind: "notes" },
|
|
35
41
|
...stored
|
|
36
42
|
.filter(({ provider }) => isFolderProvider(provider))
|
|
@@ -42,7 +48,7 @@ const heldOf = (stored, running) => [
|
|
|
42
48
|
stored: { provider, account },
|
|
43
49
|
})),
|
|
44
50
|
...stored
|
|
45
|
-
.filter(({ provider }) => isDocumentAccountProvider(provider))
|
|
51
|
+
.filter(({ provider }) => isDocumentAccountProvider(provider) || provider === ADDED_PROVIDER)
|
|
46
52
|
.map(({ id, provider, account, name }) => ({
|
|
47
53
|
provider: "notes",
|
|
48
54
|
account: String(id),
|
|
@@ -88,7 +94,7 @@ const accountOf = (prefix, ref, held, context) => {
|
|
|
88
94
|
const keyed = (key) => ofProvider.find(({ account }) => account === key.account) ?? {
|
|
89
95
|
...key,
|
|
90
96
|
name: null,
|
|
91
|
-
|
|
97
|
+
...kindsOfHere(key.provider, context.running),
|
|
92
98
|
};
|
|
93
99
|
const recorded = context.profiles[prefix.toLowerCase()]?.[ref];
|
|
94
100
|
if (recorded && isFolderProvider(recorded.provider)) {
|
|
@@ -127,9 +133,9 @@ const accountsOfWord = (word, held, context) => {
|
|
|
127
133
|
if (wanted === "all")
|
|
128
134
|
return [...held];
|
|
129
135
|
if (wanted === "personal" || wanted === "bots")
|
|
130
|
-
return held.filter((
|
|
136
|
+
return held.filter((one) => listedHolds(one, "messages") && isBotProvider(one.provider) === (wanted === "bots"));
|
|
131
137
|
if (isKind(wanted))
|
|
132
|
-
return held.filter((
|
|
138
|
+
return held.filter((one) => listedHolds(one, wanted));
|
|
133
139
|
const recorded = context.profiles[wanted];
|
|
134
140
|
if (recorded &&
|
|
135
141
|
Object.values(recorded).every((key) => isFolderProvider(key.provider) || isDocumentAccountProvider(key.provider)))
|
|
@@ -184,7 +190,12 @@ export const entriesOfList = (value, context) => {
|
|
|
184
190
|
entry(item);
|
|
185
191
|
return entries.map(({ entry, accounts }) => ({
|
|
186
192
|
entry,
|
|
187
|
-
accounts: accounts.map(({ provider, account, kind }) => ({
|
|
193
|
+
accounts: accounts.map(({ provider, account, kind, kinds }) => ({
|
|
194
|
+
provider,
|
|
195
|
+
account,
|
|
196
|
+
kind,
|
|
197
|
+
...(kinds === undefined ? {} : { kinds }),
|
|
198
|
+
})),
|
|
188
199
|
}));
|
|
189
200
|
};
|
|
190
201
|
/** Every account the list names, in order and once each. */
|
|
@@ -213,7 +224,7 @@ export const fitting = (entries, kinds, what, reasonOf = (kind) => READS[kind])
|
|
|
213
224
|
const chosen = new Map();
|
|
214
225
|
const skipped = [];
|
|
215
226
|
for (const { entry, accounts } of entries) {
|
|
216
|
-
const fits = accounts.filter((
|
|
227
|
+
const fits = accounts.filter((one) => kinds.some((kind) => listedHolds(one, kind)));
|
|
217
228
|
for (const { provider, account } of fits)
|
|
218
229
|
if (!chosen.has(keyOf({ provider, account })))
|
|
219
230
|
chosen.set(keyOf({ provider, account }), { provider, account });
|
package/dist/search/query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import {
|
|
2
|
+
import { holdsKindOf, isKind, providerNamed } from "../domain/providers.js";
|
|
3
3
|
/** How the store tells a bot's copy from a personal account: `max-bot`, `telegram-bot`. */
|
|
4
4
|
export const isBotProvider = (provider) => provider.endsWith("-bot");
|
|
5
5
|
/** Whether an account of `provider` is inside `source`: also a kind (`messages`, `mail`) or a provider's alias (`tg`). */
|
|
@@ -8,7 +8,7 @@ export const inSource = (source, provider) => source === "all" ||
|
|
|
8
8
|
(source === "personal" && !isBotProvider(provider)) ||
|
|
9
9
|
source === provider ||
|
|
10
10
|
providerNamed(source)?.name === provider ||
|
|
11
|
-
(isKind(source) &&
|
|
11
|
+
(isKind(source) && holdsKindOf(provider, source));
|
|
12
12
|
const fail = (message) => {
|
|
13
13
|
throw new CliError("validation_error", message);
|
|
14
14
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import {
|
|
2
|
+
import { holdsKind } from "../domain/providers.js";
|
|
3
3
|
import { meaningFloor } from "../embeddings/models.js";
|
|
4
4
|
import { plainQuery } from "../search/lucene/plain.js";
|
|
5
5
|
import { questionLookup, questionText } from "../search/question-plan.js";
|
|
@@ -17,7 +17,7 @@ const accountIdsOf = async (store, accounts) => {
|
|
|
17
17
|
};
|
|
18
18
|
/** The calendar accounts the store holds: every account whose provider is of the `events` kind. */
|
|
19
19
|
export const calendarAccounts = async (store) => (await store.accounts.storedAccounts())
|
|
20
|
-
.filter(({ provider }) =>
|
|
20
|
+
.filter(({ provider }) => holdsKind(provider, "events"))
|
|
21
21
|
.map(({ provider, account }) => ({ provider, account }));
|
|
22
22
|
export const foundEvent = (hit, query, foundBy) => ({
|
|
23
23
|
ref: hit.ref,
|
package/dist/services/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { type ChatCoverage, chatCoverage } from "./chat-coverage.js";
|
|
|
6
6
|
export type { ContextEvidenceItem, ContextEvidencePage, ContextEvidenceReader, ContextEvidenceRequest, ContextEvidenceSender, ContextIndex, ContextReadLimits, ContextReadUsage, ContextRecordReader, ContextSource, ScopedContextEvidenceReader, } from "./context-evidence.js";
|
|
7
7
|
export { contextEvidenceFingerprint, createContextEvidenceReader } from "./context-evidence.js";
|
|
8
8
|
export { excerpt } from "./excerpt.js";
|
|
9
|
-
export { type IngestOptions, type IngestReceipt, ingest } from "./ingest.js";
|
|
9
|
+
export { type IngestLinesOptions, type IngestOptions, type IngestReceipt, type IngestVcardOptions, ingest, ingestLines, ingestVcard, jsonlLines, } from "./ingest.js";
|
|
10
10
|
export { aliasHits, chatSenders, chatTitle, combinedScore, DEFAULT_LIMIT as DEFAULT_LINK_SCAN_LIMIT, DEFAULT_THRESHOLD as DEFAULT_LINK_SCAN_THRESHOLD, emailDomain, type LinkCandidate, type LinkScorer, mailThread, memberChats, memberDialog, PERSON_SCORERS, PERSON_THRESHOLD as PERSON_LINK_SCAN_THRESHOLD, SCAN_BOT, SCORERS, type ScanInput as LinkScanInput, type ScannedProject, type ScannedProposal, type ScanResult as LinkScanResult, type ScorerInput, type Signal as LinkSignal, scanProjectLinks, } from "./link-scorers/index.js";
|
|
11
11
|
export type { MediaArchiveOptions, MediaArchivePorts } from "./media-archive.js";
|
|
12
12
|
export { archiveMedia, checkMediaArchive } from "./media-archive.js";
|
package/dist/services/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { AGENDA_DEFAULTS } from "./agenda.js";
|
|
|
5
5
|
export { chatCoverage } from "./chat-coverage.js";
|
|
6
6
|
export { contextEvidenceFingerprint, createContextEvidenceReader } from "./context-evidence.js";
|
|
7
7
|
export { excerpt } from "./excerpt.js";
|
|
8
|
-
export { ingest } from "./ingest.js";
|
|
8
|
+
export { ingest, ingestLines, ingestVcard, jsonlLines, } from "./ingest.js";
|
|
9
9
|
export { aliasHits, chatSenders, chatTitle, combinedScore, DEFAULT_LIMIT as DEFAULT_LINK_SCAN_LIMIT, DEFAULT_THRESHOLD as DEFAULT_LINK_SCAN_THRESHOLD, emailDomain, mailThread, memberChats, memberDialog, PERSON_SCORERS, PERSON_THRESHOLD as PERSON_LINK_SCAN_THRESHOLD, SCAN_BOT, SCORERS, scanProjectLinks, } from "./link-scorers/index.js";
|
|
10
10
|
export { archiveMedia, checkMediaArchive } from "./media-archive.js";
|
|
11
11
|
export { moveMediaArchive } from "./media-archive-move.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IngestError } from "../domain/records.js";
|
|
2
|
+
import { type VcardIssue, type VcardOptions } from "../domain/vcard.js";
|
|
2
3
|
import type { MessageStore } from "../store/store.js";
|
|
3
4
|
export interface IngestOptions {
|
|
4
5
|
/** The account the caller means; the envelope's `source.account` must be this one. */
|
|
@@ -7,7 +8,10 @@ export interface IngestOptions {
|
|
|
7
8
|
dryRun?: boolean;
|
|
8
9
|
/** Records per transaction, 1000 by default. */
|
|
9
10
|
chunk?: number;
|
|
11
|
+
/** Every refusal as it happens, also the ones past the receipt's 1000. It must not use the store (see `RunOptions`). */
|
|
12
|
+
onIssue?: (issue: IngestError) => void;
|
|
10
13
|
}
|
|
14
|
+
export type IngestLinesOptions = IngestOptions;
|
|
11
15
|
export interface IngestReceipt {
|
|
12
16
|
dryRun: boolean;
|
|
13
17
|
source: {
|
|
@@ -20,26 +24,70 @@ export interface IngestReceipt {
|
|
|
20
24
|
unchanged: number;
|
|
21
25
|
deleted: number;
|
|
22
26
|
refused: number;
|
|
23
|
-
/**
|
|
27
|
+
/** The proposals this import made or changed, of every type that feeds money; the owner decides them in review. */
|
|
24
28
|
proposed: string[];
|
|
25
|
-
/** Kept, with no entity yet: each named role points at a record not imported, or one with no entity. */
|
|
29
|
+
/** Kept, with no entity yet: each named role or field points at a record not imported, or one with no entity. */
|
|
26
30
|
waiting: {
|
|
27
31
|
key: string;
|
|
28
32
|
pointer: string;
|
|
29
33
|
missing: string[];
|
|
30
34
|
}[];
|
|
31
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Changed or deleted at the source after the entity was made from it: the entity was not touched. `reason` and
|
|
37
|
+
* `candidates` say when the change named another entity's identifiers.
|
|
38
|
+
*/
|
|
32
39
|
flagged: {
|
|
33
40
|
key: string;
|
|
34
41
|
pointer: string;
|
|
35
42
|
entity: string;
|
|
43
|
+
reason?: string;
|
|
44
|
+
candidates?: string[];
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* A person, organization or project whose identifiers point at more than one entity (`record.ambiguous`), or at one
|
|
48
|
+
* the owner separated from them (`record.separated`): it waits, and the owner says which one it is.
|
|
49
|
+
*/
|
|
50
|
+
unmatched: {
|
|
51
|
+
key: string;
|
|
52
|
+
pointer: string;
|
|
53
|
+
reason: string;
|
|
54
|
+
candidates: string[];
|
|
55
|
+
}[];
|
|
56
|
+
/**
|
|
57
|
+
* Values that look like an identifier and were kept as data only, never matched: a phone without `+` when the
|
|
58
|
+
* envelope names no `options.phone_region` (`record.phone-region`).
|
|
59
|
+
*/
|
|
60
|
+
ignored: {
|
|
61
|
+
key: string;
|
|
62
|
+
pointer: string;
|
|
63
|
+
reason: string;
|
|
36
64
|
}[];
|
|
37
65
|
errors: IngestError[];
|
|
66
|
+
/** A list stopped at 1000 entries; the counts are exact. */
|
|
67
|
+
truncated: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Takes a v1 records envelope into the store: checks it, then writes per chunk in one transaction. The same import
|
|
71
|
+
* twice writes nothing new. A record with a lower revision than the stored one is refused, a delete is soft, a
|
|
72
|
+
* reference to a record not yet imported waits for it, and nothing is linked by name: a person, organization or
|
|
73
|
+
* project is linked by an exact strong identifier, or made. What feeds money totals becomes a proposal: an import
|
|
74
|
+
* never writes confirmed money.
|
|
75
|
+
*/
|
|
76
|
+
export declare const ingest: (store: Pick<MessageStore, "records">, envelope: unknown, { account, dryRun, chunk, onIssue }: IngestOptions) => Promise<IngestReceipt>;
|
|
77
|
+
/** The lines of a file or of stdin, one at a time, never the whole text. */
|
|
78
|
+
export declare const jsonlLines: (stream: NodeJS.ReadableStream) => AsyncIterable<string>;
|
|
79
|
+
/**
|
|
80
|
+
* `ingest` over a JSONL stream: the first non-empty line is the header (`schema_version`, `source`, `options`), each
|
|
81
|
+
* further non-empty line one record. Records are written per chunk as they arrive; a dry run is one transaction
|
|
82
|
+
* rolled back at the end, holding the store's write lock until then.
|
|
83
|
+
*/
|
|
84
|
+
export declare const ingestLines: (store: Pick<MessageStore, "records">, lines: AsyncIterable<string>, { account, dryRun, chunk, onIssue }: IngestOptions) => Promise<IngestReceipt>;
|
|
85
|
+
export interface IngestVcardOptions extends IngestOptions, Omit<VcardOptions, "account"> {
|
|
38
86
|
}
|
|
39
87
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* one is refused, a delete is soft, a reference to a record not yet imported waits for it, and nothing is linked by
|
|
43
|
-
* name. An invoice or a payment becomes a proposal: an import never writes confirmed money.
|
|
88
|
+
* A `.vcf` address book (`isVcard`) through `envelopeOfVcard`, then `ingest`: the receipt, and what the converter kept
|
|
89
|
+
* without matching (a national number with no `region`, a card repeated in the file).
|
|
44
90
|
*/
|
|
45
|
-
export declare const
|
|
91
|
+
export declare const ingestVcard: (store: Pick<MessageStore, "records">, text: string, { provider, batchId, region, ...options }: IngestVcardOptions) => Promise<IngestReceipt & {
|
|
92
|
+
vcard: VcardIssue[];
|
|
93
|
+
}>;
|
package/dist/services/ingest.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { envelopeErrors, headerErrors, jsonLine, pointerOf, recordErrors, } from "../domain/records.js";
|
|
3
|
+
import { envelopeOfVcard } from "../domain/vcard.js";
|
|
4
|
+
import { waitingPointer } from "../store/index.js";
|
|
5
|
+
const emptyReceipt = (dryRun, errors) => ({
|
|
3
6
|
dryRun,
|
|
4
7
|
source: null,
|
|
5
8
|
created: 0,
|
|
@@ -10,71 +13,102 @@ const emptyReceipt = (dryRun) => ({
|
|
|
10
13
|
proposed: [],
|
|
11
14
|
waiting: [],
|
|
12
15
|
flagged: [],
|
|
13
|
-
|
|
16
|
+
unmatched: [],
|
|
17
|
+
ignored: [],
|
|
18
|
+
errors,
|
|
19
|
+
truncated: false,
|
|
14
20
|
});
|
|
21
|
+
const receiptOf = (dryRun, source, run) => ({
|
|
22
|
+
dryRun,
|
|
23
|
+
source: { provider: source.provider, account: source.account, batchId: source.batch_id },
|
|
24
|
+
created: run.created,
|
|
25
|
+
updated: run.updated,
|
|
26
|
+
unchanged: run.unchanged,
|
|
27
|
+
deleted: run.deleted,
|
|
28
|
+
refused: run.refused,
|
|
29
|
+
proposed: run.proposed,
|
|
30
|
+
waiting: run.waiting.map(({ index, key, missing }) => ({ key, pointer: waitingPointer(index, missing), missing })),
|
|
31
|
+
flagged: run.flagged.map(({ index, ...flag }) => ({ ...flag, pointer: pointerOf("records", index) })),
|
|
32
|
+
unmatched: run.unmatched.map(({ index, key, reason, candidates }) => ({
|
|
33
|
+
key,
|
|
34
|
+
pointer: pointerOf("records", index, "fields"),
|
|
35
|
+
reason,
|
|
36
|
+
candidates,
|
|
37
|
+
})),
|
|
38
|
+
ignored: run.ignored.map(({ index, key, at, reason }) => ({
|
|
39
|
+
key,
|
|
40
|
+
pointer: pointerOf("records", index, ...at),
|
|
41
|
+
reason,
|
|
42
|
+
})),
|
|
43
|
+
errors: run.errors,
|
|
44
|
+
truncated: run.truncated,
|
|
45
|
+
});
|
|
46
|
+
const itemOf = (record, index) => {
|
|
47
|
+
const errors = recordErrors(record, index);
|
|
48
|
+
return { index, record: record, ...(errors.length > 0 ? { errors } : {}) };
|
|
49
|
+
};
|
|
50
|
+
const refusedAll = (dryRun, errors, onIssue) => {
|
|
51
|
+
for (const error of errors)
|
|
52
|
+
onIssue?.(error);
|
|
53
|
+
return emptyReceipt(dryRun, errors);
|
|
54
|
+
};
|
|
15
55
|
/**
|
|
16
|
-
* Takes a v1 records envelope
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
56
|
+
* Takes a v1 records envelope into the store: checks it, then writes per chunk in one transaction. The same import
|
|
57
|
+
* twice writes nothing new. A record with a lower revision than the stored one is refused, a delete is soft, a
|
|
58
|
+
* reference to a record not yet imported waits for it, and nothing is linked by name: a person, organization or
|
|
59
|
+
* project is linked by an exact strong identifier, or made. What feeds money totals becomes a proposal: an import
|
|
60
|
+
* never writes confirmed money.
|
|
20
61
|
*/
|
|
21
|
-
export const ingest = async (store, envelope, { account, dryRun = false, chunk = 1000 }) => {
|
|
22
|
-
const receipt = emptyReceipt(dryRun);
|
|
62
|
+
export const ingest = async (store, envelope, { account, dryRun = false, chunk = 1000, onIssue }) => {
|
|
23
63
|
const broken = envelopeErrors(envelope, account);
|
|
24
64
|
if (broken.length > 0)
|
|
25
|
-
return
|
|
26
|
-
const { source, records } = envelope;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
pointer: pointerOf("records", index, "external_id"),
|
|
45
|
-
code: "record.duplicate",
|
|
46
|
-
message: `another record of this envelope is ${valid.type} ${valid.external_id}`,
|
|
47
|
-
key: valid.key,
|
|
48
|
-
});
|
|
49
|
-
if (errors.length > 0) {
|
|
50
|
-
receipt.refused += 1;
|
|
51
|
-
for (const error of errors)
|
|
52
|
-
receipt.errors.push(error);
|
|
53
|
-
continue;
|
|
65
|
+
return refusedAll(dryRun, broken, onIssue);
|
|
66
|
+
const { source, records, options } = envelope;
|
|
67
|
+
const items = records.map(itemOf);
|
|
68
|
+
return receiptOf(dryRun, source, await store.records.run(source, items, { dryRun, chunk, options, onIssue }));
|
|
69
|
+
};
|
|
70
|
+
/** The lines of a file or of stdin, one at a time, never the whole text. */
|
|
71
|
+
export const jsonlLines = (stream) => createInterface({ input: stream, crlfDelay: Number.POSITIVE_INFINITY });
|
|
72
|
+
/**
|
|
73
|
+
* `ingest` over a JSONL stream: the first non-empty line is the header (`schema_version`, `source`, `options`), each
|
|
74
|
+
* further non-empty line one record. Records are written per chunk as they arrive; a dry run is one transaction
|
|
75
|
+
* rolled back at the end, holding the store's write lock until then.
|
|
76
|
+
*/
|
|
77
|
+
export const ingestLines = async (store, lines, { account, dryRun = false, chunk = 1000, onIssue }) => {
|
|
78
|
+
const iterator = lines[Symbol.asyncIterator]();
|
|
79
|
+
let header = {};
|
|
80
|
+
for (let next = await iterator.next(); !next.done; next = await iterator.next())
|
|
81
|
+
if (next.value.trim() !== "" && next.value !== "") {
|
|
82
|
+
header = jsonLine(next.value);
|
|
83
|
+
break;
|
|
54
84
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
const broken = headerErrors(header, account);
|
|
86
|
+
if (broken.length > 0) {
|
|
87
|
+
await iterator.return?.();
|
|
88
|
+
return refusedAll(dryRun, broken, onIssue);
|
|
58
89
|
}
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
const { source, options } = header;
|
|
91
|
+
async function* items() {
|
|
92
|
+
let index = 0;
|
|
93
|
+
for (let next = await iterator.next(); !next.done; next = await iterator.next()) {
|
|
94
|
+
if (next.value.trim() === "")
|
|
95
|
+
continue;
|
|
96
|
+
yield itemOf(jsonLine(next.value), index);
|
|
97
|
+
index += 1;
|
|
98
|
+
}
|
|
64
99
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return receipt;
|
|
100
|
+
return receiptOf(dryRun, source, await store.records.run(source, items(), { dryRun, chunk, options, onIssue }));
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* A `.vcf` address book (`isVcard`) through `envelopeOfVcard`, then `ingest`: the receipt, and what the converter kept
|
|
104
|
+
* without matching (a national number with no `region`, a card repeated in the file).
|
|
105
|
+
*/
|
|
106
|
+
export const ingestVcard = async (store, text, { provider, batchId, region, ...options }) => {
|
|
107
|
+
const { envelope, issues } = envelopeOfVcard(text, {
|
|
108
|
+
provider,
|
|
109
|
+
account: options.account,
|
|
110
|
+
batchId,
|
|
111
|
+
...(region === undefined ? {} : { region }),
|
|
112
|
+
});
|
|
113
|
+
return { ...(await ingest(store, envelope, options)), vcard: issues };
|
|
80
114
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { calendarKey } from "../domain/calendar.js";
|
|
3
3
|
import { parseLocator } from "../domain/locator.js";
|
|
4
|
-
import { kindIn, UNKNOWN_PROVIDER } from "../domain/providers.js";
|
|
4
|
+
import { isImportedProvider, kindIn, UNKNOWN_PROVIDER } from "../domain/providers.js";
|
|
5
5
|
import { syncsOneChat } from "../ports/traits.js";
|
|
6
6
|
import { PRESET_VERSION } from "../search/lucene/presets.js";
|
|
7
7
|
import { FIELD_VERSION, validateAst, validateFields } from "../search/lucene/registry.js";
|
|
@@ -235,7 +235,8 @@ export const coverageOf = async (store, { scopeAccounts, selectedChat }, messeng
|
|
|
235
235
|
const completeness = [];
|
|
236
236
|
const stats = new Map();
|
|
237
237
|
let inventoryComplete = scopeAccounts.length > 0;
|
|
238
|
-
|
|
238
|
+
// An import-only account holds what its import wrote: no fetch could add to it, so it says nothing of coverage.
|
|
239
|
+
for (const selected of scopeAccounts.filter(({ provider }) => !isImportedProvider(provider))) {
|
|
239
240
|
if (!(await store.sync.syncState(selected, CHAT_LIST_KEY))) {
|
|
240
241
|
inventoryComplete = false;
|
|
241
242
|
}
|
|
@@ -14,12 +14,12 @@ export declare const metadataService: (deps: ServiceDeps) => {
|
|
|
14
14
|
dryRun?: boolean;
|
|
15
15
|
}) => Promise<{
|
|
16
16
|
items: ({
|
|
17
|
-
error?: undefined;
|
|
18
17
|
chatId: string;
|
|
19
18
|
tags: import("../domain/channel-tags.js").ChannelTagMatch[];
|
|
20
19
|
algorithm: string;
|
|
21
20
|
fetchedAt: string | null;
|
|
22
21
|
source: string;
|
|
22
|
+
error?: undefined;
|
|
23
23
|
} | {
|
|
24
24
|
tags?: undefined;
|
|
25
25
|
algorithm?: undefined;
|
|
@@ -528,6 +528,7 @@ export const searchNotesOf = async (store, account, text, { accounts: list, app,
|
|
|
528
528
|
{ provider: "notes", account: INTERNAL_NOTES },
|
|
529
529
|
...(await store.notes.folders()).map(({ id }) => ({ provider: "notes", account: id })),
|
|
530
530
|
...(await store.notes.documentsAccounts()).map(({ id }) => ({ provider: "notes", account: id })),
|
|
531
|
+
...[await store.notes.addedAccount()].flatMap((added) => (added ? [{ provider: "notes", account: added.id }] : [])),
|
|
531
532
|
];
|
|
532
533
|
const named = list === undefined
|
|
533
534
|
? { accounts: held, skipped: [] }
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MessageStore } from "../../../store/index.js";
|
|
2
|
+
import type { ProposalKind } from "../types.js";
|
|
3
|
+
/** An agent's or an import's contract with a value, by its own ref (`contract:12`); only the owner decides it. */
|
|
4
|
+
export declare const contractKind: (store: Pick<MessageStore, "contracts">) => ProposalKind;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { reviewedKind, reviewedRow } from "./shared.js";
|
|
2
|
+
/** An agent's or an import's contract with a value, by its own ref (`contract:12`); only the owner decides it. */
|
|
3
|
+
export const contractKind = (store) => reviewedKind({
|
|
4
|
+
type: "contract",
|
|
5
|
+
list: (options) => store.contracts.list(options),
|
|
6
|
+
get: (id) => store.contracts.get(id),
|
|
7
|
+
row: (contract) => reviewedRow("contract", contract, contract.deal),
|
|
8
|
+
decide: async (id, confirm, { by, reason }) => (confirm ? await store.contracts.confirm(id, by, reason) : await store.contracts.reject(id, by, reason)).ref,
|
|
9
|
+
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { MessageStore } from "../../../store/index.js";
|
|
2
2
|
import type { ProposalKind } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* An agent's or an import's invoice or payment. One kind per entity, because the registry routes an id by its prefix
|
|
5
|
+
* and the id is the entry's own ref (`payment:12`), as a fact's is. Only the owner decides money.
|
|
6
|
+
*/
|
|
3
7
|
export declare const invoiceKind: (store: Pick<MessageStore, "finance">) => ProposalKind;
|
|
4
8
|
export declare const paymentKind: (store: Pick<MessageStore, "finance">) => ProposalKind;
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const rowOf = (kind, entry) => ({
|
|
3
|
-
id: entry.ref,
|
|
4
|
-
kind,
|
|
5
|
-
status: entry.review,
|
|
6
|
-
project: entry.project,
|
|
7
|
-
subject: entry.ref,
|
|
8
|
-
object: "counterparty" in entry
|
|
9
|
-
? entry.counterparty.ref
|
|
10
|
-
: ((entry.direction === "in" ? entry.payer : entry.payee)?.ref ?? null),
|
|
11
|
-
summary: entry.title,
|
|
12
|
-
proposedBy: proposerOfAuthor(entry.author),
|
|
13
|
-
reason: entry.reason,
|
|
14
|
-
evidence: [],
|
|
15
|
-
score: null,
|
|
16
|
-
signals: null,
|
|
17
|
-
parts: null,
|
|
18
|
-
createdAt: entry.createdAt,
|
|
19
|
-
});
|
|
1
|
+
import { reviewedKind, reviewedRow } from "./shared.js";
|
|
20
2
|
/**
|
|
21
3
|
* An agent's or an import's invoice or payment. One kind per entity, because the registry routes an id by its prefix
|
|
22
4
|
* and the id is the entry's own ref (`payment:12`), as a fact's is. Only the owner decides money.
|
|
23
5
|
*/
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
6
|
+
export const invoiceKind = (store) => reviewedKind({
|
|
7
|
+
type: "invoice",
|
|
8
|
+
list: (options) => store.finance.invoices(options),
|
|
9
|
+
get: (id) => store.finance.invoice(id),
|
|
10
|
+
row: (invoice) => reviewedRow("invoice", invoice, invoice.counterparty.ref),
|
|
11
|
+
decide: async (id, confirm, { by, reason }) => (confirm ? await store.finance.confirm(id, by, reason) : await store.finance.reject(id, by, reason)).ref,
|
|
12
|
+
});
|
|
13
|
+
export const paymentKind = (store) => reviewedKind({
|
|
14
|
+
type: "payment",
|
|
15
|
+
list: (options) => store.finance.payments(options),
|
|
16
|
+
get: (id) => store.finance.payment(id),
|
|
17
|
+
row: (payment) => reviewedRow("payment", payment, (payment.direction === "in" ? payment.payer : payment.payee)?.ref ?? null),
|
|
18
|
+
decide: async (id, confirm, { by, reason }) => (confirm ? await store.finance.confirm(id, by, reason) : await store.finance.reject(id, by, reason)).ref,
|
|
38
19
|
});
|
|
39
|
-
export const invoiceKind = (store) => financeKind(store, "invoice");
|
|
40
|
-
export const paymentKind = (store) => financeKind(store, "payment");
|