@wirecat/cli-core 0.618.0 → 0.620.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 +453 -1
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES +3 -0
- package/dist/background/deliver.d.ts +5 -2
- package/dist/background/deliver.js +30 -12
- package/dist/background/report/render.d.ts +3 -1
- package/dist/background/report/render.js +3 -1
- package/dist/calendar/cli/answers.d.ts +1 -0
- package/dist/calendar/cli/answers.js +6 -1
- package/dist/calendar/cli/index.js +2 -14
- package/dist/calendar/cli/people-link.d.ts +3 -0
- package/dist/calendar/cli/people-link.js +23 -0
- package/dist/calendar/cli/search-all.d.ts +1 -1
- package/dist/calendar/cli/search-all.js +9 -10
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/calendar/prepare.js +1 -0
- package/dist/cli/base-stages-command.d.ts +22 -0
- package/dist/cli/base-stages-command.js +174 -0
- package/dist/cli/bot/buttons.d.ts +3 -0
- package/dist/cli/bot/buttons.js +24 -0
- package/dist/cli/bot/messages.js +14 -1
- package/dist/cli/bot/port.d.ts +8 -0
- package/dist/cli/command-runs.d.ts +2 -0
- package/dist/cli/command-runs.js +3 -1
- package/dist/cli/config-command.js +6 -1
- package/dist/cli/context.js +1 -0
- package/dist/cli/contract-templates.js +31 -2
- package/dist/cli/group-lock.d.ts +42 -0
- package/dist/cli/group-lock.js +130 -0
- package/dist/cli/index.d.ts +7 -2
- package/dist/cli/index.js +7 -2
- package/dist/cli/messenger/backfill-command.js +27 -15
- package/dist/cli/messenger/contacts-command.js +12 -4
- package/dist/cli/messenger/context.js +1 -0
- package/dist/cli/messenger/conversations-command.js +2 -1
- package/dist/cli/messenger/doctor-command.js +3 -1
- package/dist/cli/messenger/message-items.js +1 -1
- package/dist/cli/messenger/models-command.js +1 -1
- package/dist/cli/messenger/search-answers.d.ts +5 -5
- package/dist/cli/messenger/search-answers.js +9 -20
- package/dist/cli/messenger/search-command.d.ts +2 -2
- package/dist/cli/messenger/search-command.js +8 -18
- package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
- package/dist/cli/messenger/store-maintenance-command.js +9 -4
- package/dist/cli/model-catalogue-command.d.ts +3 -1
- package/dist/cli/model-catalogue-command.js +48 -2
- package/dist/cli/profile.d.ts +8 -0
- package/dist/cli/profile.js +25 -0
- package/dist/cli/program.js +2 -0
- package/dist/cli/runs/search-query.d.ts +1 -1
- package/dist/cli/runs/search-query.js +4 -0
- package/dist/cli/runs/search.d.ts +5 -1
- package/dist/cli/runs/search.js +12 -1
- package/dist/cli/search-harder-consents-command.d.ts +18 -0
- package/dist/cli/search-harder-consents-command.js +83 -0
- package/dist/cli/search-left-out.d.ts +6 -1
- package/dist/cli/search-left-out.js +9 -4
- package/dist/cli/settings.d.ts +8 -0
- package/dist/cli/settings.js +17 -2
- package/dist/cli/shared-command-exports.d.ts +16 -0
- package/dist/cli/steps.js +0 -6
- package/dist/cli/store-recover.d.ts +3 -3
- package/dist/cli/store-recover.js +26 -26
- package/dist/cli/store-settings.d.ts +2 -0
- package/dist/cli/store-settings.js +37 -9
- package/dist/cli/templates-command.js +4 -4
- package/dist/crm/cli/index.js +40 -8
- package/dist/crm/cli/search-all.js +7 -6
- package/dist/crm/group-hint.d.ts +8 -0
- package/dist/crm/group-hint.js +13 -0
- package/dist/crm/source.d.ts +12 -1
- package/dist/crm/sync.d.ts +31 -2
- package/dist/crm/sync.js +110 -3
- package/dist/crm/testing/acme-scenario.d.ts +40 -0
- package/dist/crm/testing/acme-scenario.js +170 -0
- package/dist/crm/testing/index.d.ts +1 -0
- package/dist/crm/testing/index.js +1 -0
- package/dist/crm/testing/source-contract.js +12 -0
- package/dist/crm/testing/source.d.ts +2 -0
- package/dist/crm/testing/source.js +1 -0
- package/dist/domain/addresses.d.ts +13 -0
- package/dist/domain/addresses.js +63 -0
- package/dist/domain/categories.d.ts +3 -0
- package/dist/domain/categories.js +2 -0
- package/dist/domain/crm.d.ts +23 -0
- package/dist/domain/crm.js +7 -0
- package/dist/domain/mentions.d.ts +2 -12
- package/dist/domain/mentions.js +2 -19
- package/dist/domain/models.d.ts +2 -0
- package/dist/domain/orders.d.ts +8 -1
- package/dist/domain/orders.js +6 -2
- package/dist/domain/phones.d.ts +26 -0
- package/dist/domain/phones.js +48 -0
- package/dist/domain/record-types.d.ts +1 -1
- package/dist/domain/record-types.js +1 -0
- package/dist/domain/records.d.ts +5 -0
- package/dist/domain/ref-summaries.d.ts +39 -0
- package/dist/domain/ref-summaries.js +51 -3
- package/dist/domain/relations.d.ts +12 -2
- package/dist/domain/relations.js +14 -3
- package/dist/domain/vcard.d.ts +2 -2
- package/dist/domain/vcard.js +4 -10
- package/dist/embeddings/models.d.ts +11 -3
- package/dist/embeddings/models.js +28 -4
- package/dist/entities/business-context.d.ts +149 -0
- package/dist/entities/business-context.js +192 -0
- package/dist/entities/contact-activity.d.ts +2 -0
- package/dist/entities/contact-activity.js +7 -1
- package/dist/entities/contact-context.d.ts +160 -0
- package/dist/entities/contact-context.js +6 -0
- package/dist/entities/deal.d.ts +10 -0
- package/dist/entities/deal.js +2 -0
- package/dist/entities/hit.d.ts +9 -2
- package/dist/entities/hit.js +6 -2
- package/dist/entities/index.d.ts +32 -4
- package/dist/entities/index.js +5 -0
- package/dist/entities/mention.d.ts +4 -3
- package/dist/entities/mention.js +2 -1
- package/dist/entities/message-transfer.d.ts +4 -2
- package/dist/entities/message-transfer.js +2 -2
- package/dist/entities/model.d.ts +2 -2
- package/dist/entities/model.js +1 -1
- package/dist/entities/relationship.d.ts +4 -0
- package/dist/entities/relationship.js +4 -0
- package/dist/errors/reasons.js +39 -4
- package/dist/fetch/page.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/meetings/context-store.d.ts +2 -0
- package/dist/meetings/findings-rules.d.ts +4 -0
- package/dist/meetings/findings-rules.js +5 -2
- package/dist/meetings/hit-query.d.ts +1 -1
- package/dist/meetings/hit-query.js +2 -2
- package/dist/meetings/index.d.ts +1 -0
- package/dist/meetings/index.js +1 -0
- package/dist/meetings/result-items.d.ts +1 -0
- package/dist/meetings/result-items.js +1 -0
- package/dist/meetings/store.d.ts +4 -0
- package/dist/meetings/store.js +2 -1
- package/dist/models/anthropic.js +5 -0
- package/dist/models/index.js +22 -5
- package/dist/runs/events.d.ts +11 -1
- package/dist/runs/events.js +3 -1
- package/dist/runs/log-attributes.js +4 -0
- package/dist/runs/log-events.js +2 -0
- package/dist/runs/recording.d.ts +3 -0
- package/dist/runs/recording.js +36 -12
- package/dist/runs/run.d.ts +12 -3
- package/dist/runs/run.js +32 -13
- package/dist/search/account-list.d.ts +6 -0
- package/dist/search/account-list.js +9 -3
- package/dist/search/groups.d.ts +68 -0
- package/dist/search/groups.js +172 -0
- package/dist/search/question-period.d.ts +10 -0
- package/dist/search/question-period.js +133 -0
- package/dist/sends/buttons.d.ts +2 -0
- package/dist/sends/buttons.js +6 -1
- package/dist/services/account-groups.d.ts +28 -0
- package/dist/services/account-groups.js +89 -0
- package/dist/services/archive.d.ts +7 -1
- package/dist/services/archive.js +19 -3
- package/dist/services/business-context.d.ts +113 -0
- package/dist/services/business-context.js +156 -0
- package/dist/services/communications.d.ts +50 -0
- package/dist/services/communications.js +140 -0
- package/dist/services/deal-context.d.ts +90 -0
- package/dist/services/deal-context.js +131 -0
- package/dist/services/deps.d.ts +2 -0
- package/dist/services/enrichment.d.ts +12 -2
- package/dist/services/enrichment.js +47 -6
- package/dist/services/events-search.js +2 -1
- package/dist/services/group-guard.d.ts +28 -0
- package/dist/services/group-guard.js +131 -0
- package/dist/services/index.d.ts +19 -4
- package/dist/services/index.js +12 -3
- package/dist/services/ingest.d.ts +12 -0
- package/dist/services/ingest.js +4 -0
- package/dist/services/meaning-model.d.ts +7 -0
- package/dist/services/meaning-model.js +20 -0
- package/dist/services/meeting-context.d.ts +6 -1
- package/dist/services/meeting-context.js +12 -5
- package/dist/services/message-resolution.js +2 -3
- package/dist/services/messages-meaning.js +4 -5
- package/dist/services/messages-search.d.ts +5 -1
- package/dist/services/messages-search.js +1 -1
- package/dist/services/messages.d.ts +1 -4
- package/dist/services/messages.js +0 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/model-downloads.d.ts +1 -1
- package/dist/services/model-downloads.js +6 -4
- package/dist/services/money-context.d.ts +73 -0
- package/dist/services/money-context.js +77 -0
- package/dist/services/notes-search.d.ts +4 -1
- package/dist/services/notes-search.js +19 -7
- package/dist/services/organization-context.d.ts +80 -0
- package/dist/services/organization-context.js +154 -0
- package/dist/services/people.d.ts +22 -6
- package/dist/services/people.js +38 -8
- package/dist/services/person-business.d.ts +43 -0
- package/dist/services/person-business.js +67 -0
- package/dist/services/person-context.d.ts +11 -1
- package/dist/services/person-context.js +25 -10
- package/dist/services/person-preparation.d.ts +5 -1
- package/dist/services/person-preparation.js +10 -3
- package/dist/services/person-timeline.d.ts +6 -1
- package/dist/services/person-timeline.js +10 -2
- package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
- package/dist/services/proposals/kinds/identity-link.js +48 -0
- package/dist/services/proposals/kinds/orders.js +1 -1
- package/dist/services/proposals/registry.js +2 -0
- package/dist/services/search-all-deprecated.d.ts +40 -0
- package/dist/services/search-all-deprecated.js +10 -0
- package/dist/services/search-all-meetings.d.ts +50 -52
- package/dist/services/search-all-meetings.js +265 -272
- package/dist/services/search-all.d.ts +34 -6
- package/dist/services/search-all.js +118 -24
- package/dist/services/search-harder.d.ts +64 -0
- package/dist/services/search-harder.js +194 -0
- package/dist/services/search-kind.d.ts +12 -5
- package/dist/services/search-kind.js +49 -10
- package/dist/services/text-model-choice.js +1 -1
- package/dist/store/accounts.d.ts +18 -0
- package/dist/store/accounts.js +18 -3
- package/dist/store/chats.d.ts +3 -1
- package/dist/store/chats.js +6 -0
- package/dist/store/damage.d.ts +43 -10
- package/dist/store/damage.js +119 -36
- package/dist/store/decisions.js +3 -1
- package/dist/store/evidence-findings.d.ts +14 -0
- package/dist/store/evidence-findings.js +2 -0
- package/dist/store/exports.d.ts +2 -1
- package/dist/store/identity-links.d.ts +92 -0
- package/dist/store/identity-links.js +6 -0
- package/dist/store/index.d.ts +11 -5
- package/dist/store/index.js +5 -2
- package/dist/store/journal.d.ts +10 -0
- package/dist/store/journal.js +33 -0
- package/dist/store/marks.d.ts +19 -1
- package/dist/store/marks.js +23 -1
- package/dist/store/people.d.ts +28 -2
- package/dist/store/people.js +15 -1
- package/dist/store/sqlite/accounts.js +2 -0
- package/dist/store/sqlite/added-sources.d.ts +15 -3
- package/dist/store/sqlite/added-sources.js +26 -5
- package/dist/store/sqlite/base-stages.d.ts +122 -0
- package/dist/store/sqlite/base-stages.js +443 -0
- package/dist/store/sqlite/base-suggest.d.ts +13 -0
- package/dist/store/sqlite/base-suggest.js +62 -0
- package/dist/store/sqlite/business-contracts.js +10 -1
- package/dist/store/sqlite/chats.d.ts +2 -0
- package/dist/store/sqlite/chats.js +6 -0
- package/dist/store/sqlite/crm-settings.d.ts +12 -2
- package/dist/store/sqlite/crm-settings.js +56 -13
- package/dist/store/sqlite/crm.d.ts +13 -1
- package/dist/store/sqlite/crm.js +20 -4
- package/dist/store/sqlite/deals.d.ts +33 -0
- package/dist/store/sqlite/deals.js +42 -4
- package/dist/store/sqlite/decision-requests.js +7 -3
- package/dist/store/sqlite/email-index.js +8 -4
- package/dist/store/sqlite/evidence-findings.js +29 -5
- package/dist/store/sqlite/findings-core.js +4 -2
- package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
- package/dist/store/sqlite/identity-link-rows.js +146 -0
- package/dist/store/sqlite/identity-proposals.d.ts +53 -0
- package/dist/store/sqlite/identity-proposals.js +234 -0
- package/dist/store/sqlite/involvements.d.ts +1 -1
- package/dist/store/sqlite/involvements.js +4 -2
- package/dist/store/sqlite/knowledge.js +2 -2
- package/dist/store/sqlite/link-kinds.d.ts +1 -0
- package/dist/store/sqlite/link-kinds.js +1 -0
- package/dist/store/sqlite/link-row.d.ts +6 -0
- package/dist/store/sqlite/link-row.js +35 -0
- package/dist/store/sqlite/link-source.d.ts +10 -0
- package/dist/store/sqlite/link-source.js +16 -0
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/meeting-context-links.js +9 -6
- package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
- package/dist/store/sqlite/meeting-hit-query.js +33 -0
- package/dist/store/sqlite/meeting-hit-search.js +10 -8
- package/dist/store/sqlite/meetings.js +1 -1
- package/dist/store/sqlite/memories.js +9 -7
- package/dist/store/sqlite/mentions.d.ts +4 -1
- package/dist/store/sqlite/mentions.js +14 -9
- package/dist/store/sqlite/migrations.generated.js +8 -0
- package/dist/store/sqlite/notes.d.ts +8 -2
- package/dist/store/sqlite/notes.js +17 -34
- package/dist/store/sqlite/open-store.js +3 -0
- package/dist/store/sqlite/open.js +11 -2
- package/dist/store/sqlite/orders.d.ts +2 -0
- package/dist/store/sqlite/orders.js +9 -3
- package/dist/store/sqlite/organization-categories.d.ts +18 -0
- package/dist/store/sqlite/organization-categories.js +34 -0
- package/dist/store/sqlite/organizations.d.ts +5 -1
- package/dist/store/sqlite/organizations.js +14 -4
- package/dist/store/sqlite/person-links.d.ts +19 -4
- package/dist/store/sqlite/person-links.js +49 -11
- package/dist/store/sqlite/person-match-scan.d.ts +13 -0
- package/dist/store/sqlite/person-match-scan.js +251 -0
- package/dist/store/sqlite/person-matcher.d.ts +16 -0
- package/dist/store/sqlite/person-matcher.js +32 -0
- package/dist/store/sqlite/person-preparation.d.ts +7 -3
- package/dist/store/sqlite/person-preparation.js +20 -6
- package/dist/store/sqlite/proposed-actions.js +6 -0
- package/dist/store/sqlite/record-matching.d.ts +2 -8
- package/dist/store/sqlite/record-matching.js +8 -40
- package/dist/store/sqlite/record-projectors-phone.js +2 -1
- package/dist/store/sqlite/record-relationships.d.ts +52 -0
- package/dist/store/sqlite/record-relationships.js +243 -0
- package/dist/store/sqlite/record-run.d.ts +5 -0
- package/dist/store/sqlite/record-run.js +62 -2
- package/dist/store/sqlite/record-writes.d.ts +1 -1
- package/dist/store/sqlite/record-writes.js +4 -2
- package/dist/store/sqlite/records.js +27 -2
- package/dist/store/sqlite/ref-accounts.d.ts +13 -0
- package/dist/store/sqlite/ref-accounts.js +117 -0
- package/dist/store/sqlite/ref-summaries.js +5 -1
- package/dist/store/sqlite/relation-list.d.ts +4 -1
- package/dist/store/sqlite/relation-list.js +22 -4
- package/dist/store/sqlite/relation-proposals.d.ts +6 -0
- package/dist/store/sqlite/relation-proposals.js +3 -0
- package/dist/store/sqlite/relation-roles.js +12 -6
- package/dist/store/sqlite/reported-relations.d.ts +11 -1
- package/dist/store/sqlite/reported-relations.js +59 -18
- package/dist/store/sqlite/schema.d.ts +32 -0
- package/dist/store/sqlite/schema.js +3 -0
- package/dist/store/sqlite/transaction.js +11 -1
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/store/write-events.d.ts +18 -0
- package/dist/store/write-events.js +88 -0
- package/package.json +3 -3
- package/parity.json +37 -16
- package/schemas/records-envelope.v1.schema.json +3 -0
package/dist/store/index.d.ts
CHANGED
|
@@ -10,18 +10,19 @@ export type { FindingEvidence, FindingOutcome, MeetingFactFinding, MeetingFindin
|
|
|
10
10
|
export { PAYMENT_DIRECTIONS, PAYMENT_STATES, type Payment, paymentTitle, validatePayment } from "../meetings/index.js";
|
|
11
11
|
export { CLOSED_STATES, isClosedState, PRIORITY_LABELS, type PriorityLabel, priorityLabel, priorityOf, priorityOption, TASK_STATES, type TaskState, } from "../tasks/index.js";
|
|
12
12
|
export type { AccountMail, AccountMeetings, AccountStore } from "./account-store.js";
|
|
13
|
-
export { type
|
|
13
|
+
export { type DamageCause, type DamageFindings, type RecoveryStep, type StoreDamageReport, storeDamageReport, } from "./damage.js";
|
|
14
14
|
export { CALLBACK_PREFIX, callbackDataOf, DECISION_ACTIONS, DECISION_TTL_MS, type DecisionAction, isDecisionToken, parseCallbackData, } from "./decision-requests.js";
|
|
15
15
|
export { assertMayDecide, DEFAULT_DECISION_POLICY, type Decider, type DecisionPolicy, isOwnerOnlyKind, mayDecide, type Proposer, type Refusal, } from "./decisions.js";
|
|
16
16
|
export type { DocumentTransferOptions, DocumentTransferPreview, DocumentTransferReceipt, } from "./document-transfer/index.js";
|
|
17
17
|
export { applyDocumentTransfer, previewDocumentTransfer } from "./document-transfer/index.js";
|
|
18
18
|
export type { CacheDatabase, CacheStatement, OpenDatabase, SqlValue } from "./driver.js";
|
|
19
19
|
export { PRAGMAS } from "./driver.js";
|
|
20
|
-
export { EVIDENCE_FINDINGS_KIND, type EvidenceFindingsBatch, type EvidenceFindingsDecider, type EvidenceFindingsReceipt, type EvidenceFindingsStore, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
20
|
+
export { type CitableRecord, EVIDENCE_FINDINGS_KIND, type EvidenceFindingsBatch, type EvidenceFindingsDecider, type EvidenceFindingsReceipt, type EvidenceFindingsStore, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
21
21
|
export { type DamagedTable, type InvalidJson, QUICK_HEALTH_CHECKS, type SearchIndexHealth, type StoreHealth, storeHealth, } from "./health.js";
|
|
22
|
+
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";
|
|
22
23
|
export { ORGANIZATIONS_QUERY, organization, PROJECTS_QUERY, project, REMINDERS_QUERY, reminder, } from "./knowledge-query.js";
|
|
23
24
|
export { MAIL_FINDINGS_KIND, type MailFindingsBatch, type MailFindingsCheck, type MailFindingsStore, } from "./mail-findings.js";
|
|
24
|
-
export { clearDamageMark, type DamageMark, damageMarkPath, type HealthMark, healthMarkPath, markStoreDamaged, readDamageMark, readHealthMark, recordDeepCheck, } from "./marks.js";
|
|
25
|
+
export { clearDamageMark, type DamageMark, damageMarkPath, type HealthMark, healthMarkPath, type JournalMark, journalMarkPath, markStoreDamaged, readDamageMark, readHealthMark, readJournalMark, recordDeepCheck, } from "./marks.js";
|
|
25
26
|
export type { MeetingFindingsBatch, MeetingFindingsStore } from "./meeting-findings.js";
|
|
26
27
|
export { MIGRATIONS, type Migration, migrate } from "./migrations.js";
|
|
27
28
|
export { openCache } from "./open.js";
|
|
@@ -37,6 +38,8 @@ export { ADDED_KINDS, type AddedSource, type AddedSourceContent, type AddedSourc
|
|
|
37
38
|
export type { AgentAction, AgentActionInput, AgentActionsStore } from "./sqlite/agent-actions.js";
|
|
38
39
|
export { resetAttachmentWords } from "./sqlite/attachment-texts.js";
|
|
39
40
|
export { backfillNormalized, pendingNormalization } from "./sqlite/backfill.js";
|
|
41
|
+
export type { BaseColumn, BaseScope, BaseSet, BaseStagesStore, MappingFilter, StageMapping, StageName, } from "./sqlite/base-stages.js";
|
|
42
|
+
export { baseSettingKey } from "./sqlite/base-suggest.js";
|
|
40
43
|
export type { BotUpdate, BotUpdateStore } from "./sqlite/bot-updates.js";
|
|
41
44
|
export type { Contract, ContractFields, ContractFilter, ContractInput, ContractsStore, ContractUpdate, } from "./sqlite/business-contracts.js";
|
|
42
45
|
export type { BusinessHit, BusinessSearch, BusinessSearchStore, BusinessSource } from "./sqlite/business-search.js";
|
|
@@ -46,11 +49,12 @@ export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
|
46
49
|
export type { ChatMetadata } from "./sqlite/chats.js";
|
|
47
50
|
export { type CrmCopies, type CrmRelationIssue, type CrmSaved, type CrmSkipped, crmIdentityId } from "./sqlite/crm.js";
|
|
48
51
|
export { COMPANY_TYPE_MEANINGS, type CompanyTypeMeaning, CRM_LINK_MODES, type CrmLinkMode, crmSettingKey, } from "./sqlite/crm-settings.js";
|
|
49
|
-
export type { Deal, DealFilter, DealInput, DealPerson, DealScope, DealsStore, FunnelStage, Pipeline, PipelineInput, PipelineReport, PipelineStage, } from "./sqlite/deals.js";
|
|
52
|
+
export type { Deal, DealFilter, DealInput, DealPerson, DealScope, DealsStore, FunnelStage, Pipeline, PipelineInput, PipelineReport, PipelineStage, StageChange, } from "./sqlite/deals.js";
|
|
50
53
|
export type { DecisionMessage, DecisionPress, DecisionRefusal, DecisionRequest, DecisionRequestInput, DecisionRequestStore, TakeResult, } from "./sqlite/decision-requests.js";
|
|
51
54
|
export type { Email, EmailAddress, EmailAttachment, EmailFacts, EmailFilter, EmailInput, EmailInThread, EmailLocationInput, EmailRecipient, EmailRef, EmailThread, EmailVectorHit, FolderEmail, Mailbox, MailboxInput, MailFilter, MailStore, PartialEmail, SenderScore, ThreadDetails, ThreadSave, } from "./sqlite/emails.js";
|
|
52
55
|
export { EVENT_FIELDS, type EventChunkToEmbed, type EventHit, type EventQuery, type EventSearch, type NearestEvent, } from "./sqlite/event-search.js";
|
|
53
56
|
export type { EvidenceInput, EvidenceMetadata } from "./sqlite/evidence-signature.js";
|
|
57
|
+
export { QUOTE_LIMIT, quoteKept } from "./sqlite/evidence-signature.js";
|
|
54
58
|
export type { EvidenceSource } from "./sqlite/evidence-sources.js";
|
|
55
59
|
export type { Fact, FactInput, FactsStore } from "./sqlite/facts.js";
|
|
56
60
|
export type { FileListQuery, FilesStore, StoredFile } from "./sqlite/files.js";
|
|
@@ -71,11 +75,13 @@ export type { NoteIndexState } from "./sqlite/note-index.js";
|
|
|
71
75
|
export { type NearestNote, NOTE_FIELDS, type NoteChunkToEmbed, type NoteHit, type NoteQuery, type NoteSearch, } from "./sqlite/note-search.js";
|
|
72
76
|
export type { FileNoteInput, Link, LinkInput, LinkListFilter, Note, NoteFolder, NotesStore, NoteTag, } from "./sqlite/notes.js";
|
|
73
77
|
export type { Order, OrderDetail, OrderFilter, OrderInput, OrdersStore } from "./sqlite/orders.js";
|
|
78
|
+
export type { OrganizationFilter } from "./sqlite/organization-categories.js";
|
|
74
79
|
export { DEFAULT_OWNER_LANGUAGES, ownerLanguages } from "./sqlite/owner-languages.js";
|
|
75
80
|
export { mergeId, type PersonMerge, parseMergeId } from "./sqlite/person-merges.js";
|
|
76
81
|
export type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
77
82
|
export type { Product, ProductFilter, ProductInput, ProductsStore, ProductUpdate } from "./sqlite/products.js";
|
|
78
83
|
export { assertGenericAction, PROPOSAL_STATUSES, type ProposalInput, type ProposedAction, type ProposedActionsStore, proposerOfAction, } from "./sqlite/proposed-actions.js";
|
|
84
|
+
export type { RelationshipCounts } from "./sqlite/record-relationships.js";
|
|
79
85
|
export { type FlaggedRecord, type IncomingRelation, type MappedRecord, type MatchRun, type RecordKey, type RecordStore, type RecordsRun, type RunItem, type RunOptions, type SourceRecord, type SourceRecordRelation, type Unmatched, waitingPointer, } from "./sqlite/records.js";
|
|
80
86
|
export type { RelationFilter, RelationList, RelationListItem } from "./sqlite/relation-list.js";
|
|
81
87
|
export type { LinkDecision, RelationUpdate } from "./sqlite/relation-proposals.js";
|
|
@@ -105,4 +111,4 @@ export type { TagPreflight, VocabularyAlias, VocabularyAliasReceipt, VocabularyA
|
|
|
105
111
|
export type { Wallet, WalletFilter, WalletInput, WalletsStore, WalletUpdate } from "./sqlite/wallets.js";
|
|
106
112
|
export type { BoardCounts, BoardOptions, EditedTask, MovedSubtask, NewWorkTask, RevisionCheck, TaskAssignment, TaskDetails, TaskEvent, TaskFields, TaskMove, TaskMoved, TaskRole, TaskType, WorkTaskType, } from "./sqlite/work-tasks.js";
|
|
107
113
|
export { TASK_EVENT_KINDS, TASK_ROLES } from "./sqlite/work-tasks.js";
|
|
108
|
-
export { type AccountAccounts, type AccountAttachments, type AccountCounters, type AccountKey, type AccountMentions, type AccountMessageFilter, type AccountMessages, type AccountPeople, type AccountsStore, type AccountVectors, type AttachmentsStore, type AttachmentTextEntry, type AttachmentView, type ChatStats, type ChatsStore, type ConversationsStore, type CountersStore, type DeletionScope, type Delta, type FileAttachment, type IdentityRef, type IngestedVia, type LinkedIdentity, type LinkOptions, MENTION_QUERY, MENTION_STATUSES, type MentionsStore, type MessageFilter, type MessageStore, type MessagesStore, OTHER_SOURCES, openStore, type PeopleStore, type PersonFacts, type PersonRecord, type QueriesStore, type Range, type RankedEvidence, type RankedStoreFound, type RankedStoreRow, type RankingEvidenceItem, type RankingEvidenceRequest, type RankingRequest, type RosterStore, type SearchCommand, type SearchesStore, type SearchIndexStore, type SearchRecord, type StoredAccount, type StoredChatFilter, type StoredHit, type StoredSearch, type StoredTag, type StoreOptions, type SyncStore, type TagFilter, type TagsStore, type TagTarget, type TaskAnalysisMark, type TaskAnalysisMarkWrite, type TaskTagTarget, type TextOrigin, type VectorsStore, } from "./store.js";
|
|
114
|
+
export { type AccountAccounts, type AccountAttachments, type AccountCounters, type AccountGroupChange, type AccountKey, type AccountMentions, type AccountMessageFilter, type AccountMessages, type AccountPeople, type AccountsStore, type AccountVectors, type AttachmentsStore, type AttachmentTextEntry, type AttachmentView, type ChatStats, type ChatsStore, type ConversationsStore, type CountersStore, type DeletionScope, type Delta, type FileAttachment, type IdentityRef, type IngestedVia, type LinkedIdentity, type LinkOptions, MENTION_QUERY, MENTION_STATUSES, type MentionsStore, type MessageFilter, type MessageStore, type MessagesStore, OTHER_SOURCES, openStore, type PeopleStore, type PersonFacts, type PersonRecord, type QueriesStore, type Range, type RankedEvidence, type RankedStoreFound, type RankedStoreRow, type RankingEvidenceItem, type RankingEvidenceRequest, type RankingRequest, type RosterStore, type SearchCommand, type SearchesStore, type SearchIndexStore, type SearchRecord, type StoredAccount, type StoredChatFilter, type StoredHit, type StoredSearch, type StoredTag, type StoreOptions, type SyncStore, type TagFilter, type TagsStore, type TagTarget, type TaskAnalysisMark, type TaskAnalysisMarkWrite, type TaskTagTarget, type TextOrigin, type VectorsStore, } from "./store.js";
|
package/dist/store/index.js
CHANGED
|
@@ -4,16 +4,17 @@ export { createTagRedirectIndex } from "../domain/tag-redirects.js";
|
|
|
4
4
|
export { note } from "../entities/note.js";
|
|
5
5
|
export { PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment } from "../meetings/index.js";
|
|
6
6
|
export { CLOSED_STATES, isClosedState, PRIORITY_LABELS, priorityLabel, priorityOf, priorityOption, TASK_STATES, } from "../tasks/index.js";
|
|
7
|
-
export {
|
|
7
|
+
export { storeDamageReport, } from "./damage.js";
|
|
8
8
|
export { CALLBACK_PREFIX, callbackDataOf, DECISION_ACTIONS, DECISION_TTL_MS, isDecisionToken, parseCallbackData, } from "./decision-requests.js";
|
|
9
9
|
export { assertMayDecide, DEFAULT_DECISION_POLICY, isOwnerOnlyKind, mayDecide, } from "./decisions.js";
|
|
10
10
|
export { applyDocumentTransfer, previewDocumentTransfer } from "./document-transfer/index.js";
|
|
11
11
|
export { PRAGMAS } from "./driver.js";
|
|
12
12
|
export { EVIDENCE_FINDINGS_KIND, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
13
13
|
export { QUICK_HEALTH_CHECKS, storeHealth, } from "./health.js";
|
|
14
|
+
export { IDENTITY_LINK_KIND, IDENTITY_LINK_SIGNALS, } from "./identity-links.js";
|
|
14
15
|
export { ORGANIZATIONS_QUERY, organization, PROJECTS_QUERY, project, REMINDERS_QUERY, reminder, } from "./knowledge-query.js";
|
|
15
16
|
export { MAIL_FINDINGS_KIND, } from "./mail-findings.js";
|
|
16
|
-
export { clearDamageMark, damageMarkPath, healthMarkPath, markStoreDamaged, readDamageMark, readHealthMark, recordDeepCheck, } from "./marks.js";
|
|
17
|
+
export { clearDamageMark, damageMarkPath, healthMarkPath, journalMarkPath, markStoreDamaged, readDamageMark, readHealthMark, readJournalMark, recordDeepCheck, } from "./marks.js";
|
|
17
18
|
export { MIGRATIONS, migrate } from "./migrations.js";
|
|
18
19
|
export { openCache } from "./open.js";
|
|
19
20
|
export { storePath } from "./path.js";
|
|
@@ -26,11 +27,13 @@ export { SOURCE_REVIEW_CAUSES, SOURCE_REVIEW_KIND, } from "./source-review.js";
|
|
|
26
27
|
export { ADDED_KINDS, addedSourceKeyOf, } from "./sqlite/added-sources.js";
|
|
27
28
|
export { resetAttachmentWords } from "./sqlite/attachment-texts.js";
|
|
28
29
|
export { backfillNormalized, pendingNormalization } from "./sqlite/backfill.js";
|
|
30
|
+
export { baseSettingKey } from "./sqlite/base-suggest.js";
|
|
29
31
|
export { BUSINESS_FIND_MAX } from "./sqlite/business-search.js";
|
|
30
32
|
export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
31
33
|
export { crmIdentityId } from "./sqlite/crm.js";
|
|
32
34
|
export { COMPANY_TYPE_MEANINGS, CRM_LINK_MODES, crmSettingKey, } from "./sqlite/crm-settings.js";
|
|
33
35
|
export { EVENT_FIELDS, } from "./sqlite/event-search.js";
|
|
36
|
+
export { QUOTE_LIMIT, quoteKept } from "./sqlite/evidence-signature.js";
|
|
34
37
|
export { IMPORTED_DOCUMENT_QUERY } from "./sqlite/imported-documents.js";
|
|
35
38
|
export { ORGANIZATION_KINDS, PROJECT_TYPES, SCOPES } from "./sqlite/knowledge.js";
|
|
36
39
|
export { NOTE_FIELDS, } from "./sqlite/note-search.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CacheDatabase } from "./driver.js";
|
|
2
|
+
/** Before the open. SQLite creates `-wal` before `-shm` and deletes it after, so it never leaves `-shm` alone itself. */
|
|
3
|
+
export declare const noteShmWithoutWal: (store: string, command: string) => void;
|
|
4
|
+
export declare const watchJournal: (database: CacheDatabase, store: string, command: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Called before each outermost commit. A connection keeps writing into a `-wal` that was unlinked under it while the
|
|
7
|
+
* next process starts a fresh one, and the two journals then overwrite each other's pages: refusing the commit is
|
|
8
|
+
* the only point at which this process can still keep out of it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const checkJournal: (database: CacheDatabase) => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { CliError } from "@wirecat/cli-base";
|
|
3
|
+
import { markJournalLost } from "./marks.js";
|
|
4
|
+
const watched = new WeakMap();
|
|
5
|
+
const walInode = (store) => statSync(`${store}-wal`, { throwIfNoEntry: false })?.ino;
|
|
6
|
+
/** Before the open. SQLite creates `-wal` before `-shm` and deletes it after, so it never leaves `-shm` alone itself. */
|
|
7
|
+
export const noteShmWithoutWal = (store, command) => {
|
|
8
|
+
if (existsSync(`${store}-shm`) && !existsSync(`${store}-wal`))
|
|
9
|
+
markJournalLost(store, { seen: "shm-without-wal", command });
|
|
10
|
+
};
|
|
11
|
+
export const watchJournal = (database, store, command) => {
|
|
12
|
+
watched.set(database, { store, command, inode: walInode(store) });
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Called before each outermost commit. A connection keeps writing into a `-wal` that was unlinked under it while the
|
|
16
|
+
* next process starts a fresh one, and the two journals then overwrite each other's pages: refusing the commit is
|
|
17
|
+
* the only point at which this process can still keep out of it.
|
|
18
|
+
*/
|
|
19
|
+
export const checkJournal = (database) => {
|
|
20
|
+
const watch = watched.get(database);
|
|
21
|
+
if (!watch)
|
|
22
|
+
return;
|
|
23
|
+
const inode = walInode(watch.store);
|
|
24
|
+
if (watch.inode === undefined) {
|
|
25
|
+
watch.inode = inode;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (inode === watch.inode)
|
|
29
|
+
return;
|
|
30
|
+
markJournalLost(watch.store, { seen: inode === undefined ? "missing" : "replaced", command: watch.command });
|
|
31
|
+
throw new CliError("conflict", "the store's journal file was deleted or replaced by another program while this command had the store open, " +
|
|
32
|
+
"so nothing more is written; `store recover` says what to do", { reason: "store.journal-replaced" });
|
|
33
|
+
};
|
package/dist/store/marks.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { StoreHealth } from "./health.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const damageMarkPath: (store: string) => string;
|
|
7
7
|
export declare const healthMarkPath: (store: string) => string;
|
|
8
|
+
export declare const journalMarkPath: (store: string) => string;
|
|
8
9
|
/** A run saw SQLite say the store is damaged. Every writable open refuses while it names the file in place. */
|
|
9
10
|
export interface DamageMark {
|
|
10
11
|
at: string;
|
|
@@ -25,6 +26,15 @@ export interface HealthMark {
|
|
|
25
26
|
cli_version?: string;
|
|
26
27
|
last_ok_at: string | null;
|
|
27
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The store's `-wal` file went away or was swapped while a run held the store open, or a `-shm` stood without it at
|
|
31
|
+
* open: another program deleted or replaced the journal. Evidence for the damage report, not a refusal.
|
|
32
|
+
*/
|
|
33
|
+
export interface JournalMark {
|
|
34
|
+
at: string;
|
|
35
|
+
command: string;
|
|
36
|
+
seen: "missing" | "replaced" | "shm-without-wal";
|
|
37
|
+
}
|
|
28
38
|
/**
|
|
29
39
|
* Leaves the damage mark when `error` is SQLite saying the store is damaged; the first sighting is kept. Never
|
|
30
40
|
* throws: the failure being reported matters more than the mark.
|
|
@@ -41,10 +51,18 @@ export declare const readDamageMark: (store: string) => DamageMark | null;
|
|
|
41
51
|
export declare const clearDamageMark: (store: string) => void;
|
|
42
52
|
/** Thrown by a writable open of a store a run found damaged, so timers fail fast instead of writing into it. */
|
|
43
53
|
export declare const refuseDamagedStore: (store: string, cli?: string) => void;
|
|
54
|
+
/** Keeps the first sighting; never throws. */
|
|
55
|
+
export declare const markJournalLost: (store: string, { seen, command, now }: {
|
|
56
|
+
seen: JournalMark["seen"];
|
|
57
|
+
command: string;
|
|
58
|
+
now?: () => number;
|
|
59
|
+
}) => void;
|
|
60
|
+
export declare const readJournalMark: (store: string) => JournalMark | null;
|
|
44
61
|
export declare const readHealthMark: (store: string) => HealthMark | null;
|
|
45
62
|
/**
|
|
46
63
|
* Records a deep check of the store. One that passed also removes the damage mark: the file reads whole. Returns the
|
|
47
|
-
* mark it replaced, whose `last_ok_at` is the last known good before this check, and the damage mark it removed.
|
|
64
|
+
* mark it replaced, whose `last_ok_at` is the last known good before this check, and the damage mark it removed. A pass
|
|
65
|
+
* also removes the journal mark: whatever the lost journal held is gone or was never needed.
|
|
48
66
|
*/
|
|
49
67
|
export declare const recordDeepCheck: (store: string, health: Pick<StoreHealth, "ok" | "problems">, { cli, version, schema, now, }: {
|
|
50
68
|
cli: string;
|
package/dist/store/marks.js
CHANGED
|
@@ -8,6 +8,7 @@ import { refuseOwnerStoreInTests } from "./path.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const damageMarkPath = (store) => `${store}.damaged.json`;
|
|
10
10
|
export const healthMarkPath = (store) => `${store}.health.json`;
|
|
11
|
+
export const journalMarkPath = (store) => `${store}.journal.json`;
|
|
11
12
|
const inodeOf = (store) => statSync(store, { throwIfNoEntry: false })?.ino;
|
|
12
13
|
const readJson = (path) => {
|
|
13
14
|
try {
|
|
@@ -84,6 +85,24 @@ export const refuseDamagedStore = (store, cli) => {
|
|
|
84
85
|
throw new CliError("configuration_error", `the store was found damaged at ${mark.at} by \`${mark.command}\` (${mark.error}), so nothing writes to it until ` +
|
|
85
86
|
`it is recovered; \`${cli ?? "<cli>"} store recover\` says what is damaged and what to do`, { reason: "store.damaged" });
|
|
86
87
|
};
|
|
88
|
+
/** Keeps the first sighting; never throws. */
|
|
89
|
+
export const markJournalLost = (store, { seen, command, now = Date.now }) => {
|
|
90
|
+
if (ownerStoreInTests(store))
|
|
91
|
+
return;
|
|
92
|
+
const mark = { at: new Date(now()).toISOString(), command, seen };
|
|
93
|
+
try {
|
|
94
|
+
writeFileSync(journalMarkPath(store), `${JSON.stringify(mark, null, 2)}\n`, { flag: "wx", mode: 0o600 });
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
};
|
|
98
|
+
export const readJournalMark = (store) => {
|
|
99
|
+
try {
|
|
100
|
+
return readJson(journalMarkPath(store));
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
87
106
|
export const readHealthMark = (store) => {
|
|
88
107
|
try {
|
|
89
108
|
return readJson(healthMarkPath(store));
|
|
@@ -94,7 +113,8 @@ export const readHealthMark = (store) => {
|
|
|
94
113
|
};
|
|
95
114
|
/**
|
|
96
115
|
* Records a deep check of the store. One that passed also removes the damage mark: the file reads whole. Returns the
|
|
97
|
-
* mark it replaced, whose `last_ok_at` is the last known good before this check, and the damage mark it removed.
|
|
116
|
+
* mark it replaced, whose `last_ok_at` is the last known good before this check, and the damage mark it removed. A pass
|
|
117
|
+
* also removes the journal mark: whatever the lost journal held is gone or was never needed.
|
|
98
118
|
*/
|
|
99
119
|
export const recordDeepCheck = (store, health, { cli, version, schema, now = Date.now, }) => {
|
|
100
120
|
const previous = readHealthMark(store);
|
|
@@ -117,5 +137,7 @@ export const recordDeepCheck = (store, health, { cli, version, schema, now = Dat
|
|
|
117
137
|
catch { }
|
|
118
138
|
if (cleared)
|
|
119
139
|
clearDamageMark(store);
|
|
140
|
+
if (health.ok)
|
|
141
|
+
rmSync(journalMarkPath(store), { force: true });
|
|
120
142
|
return { previous, cleared };
|
|
121
143
|
};
|
package/dist/store/people.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { Contact, Id, Page, PersonAlias, Provider } from "../domain/models.js";
|
|
2
2
|
import type { PeopleLookup } from "../resolve.js";
|
|
3
|
+
import type { IdentityLinkDecision, IdentityLinkFilter, IdentityLinkInput, IdentityLinkRow, MatchScan } from "./identity-links.js";
|
|
3
4
|
import type { ContactFilter } from "./sqlite/identities.js";
|
|
4
5
|
import type { StoreContext } from "./sqlite/open.js";
|
|
5
6
|
import type { PersonMerge } from "./sqlite/person-merges.js";
|
|
6
7
|
import { type PersonPreparationRead } from "./sqlite/person-preparation.js";
|
|
7
8
|
import type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
8
|
-
import type {
|
|
9
|
+
import type { ProposedAction } from "./sqlite/proposed-actions.js";
|
|
10
|
+
import type { AccountKey, IdentityRef, LinkOptions, PersonFacts, PersonRecord, StoredAccount } from "./types.js";
|
|
9
11
|
export interface AccountPeople {
|
|
10
12
|
savePeople(key: AccountKey, people: PersonFacts[]): Promise<void>;
|
|
11
13
|
/**
|
|
@@ -50,9 +52,13 @@ export interface PeopleStore extends AccountPeople {
|
|
|
50
52
|
personByUid(uid: string): Promise<PersonRecord | undefined>;
|
|
51
53
|
/** The person marked as the owner, with every identity linked to them; `undefined` when none is. */
|
|
52
54
|
owner(): Promise<PersonRecord | undefined>;
|
|
53
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Accepted facts, the owner's notes and open tasks about them; tasks of an account only if `accounts` holds it,
|
|
57
|
+
* and what belongs to no account only in `scopes`.
|
|
58
|
+
*/
|
|
54
59
|
preparation(uid: string, options: {
|
|
55
60
|
accounts: readonly AccountKey[];
|
|
61
|
+
scopes: readonly StoredAccount["scope"][];
|
|
56
62
|
limit: number;
|
|
57
63
|
}): Promise<PersonPreparationRead>;
|
|
58
64
|
/** Records the decision in `identity_link_events`; `unlinkIdentity` undoes it. */
|
|
@@ -64,6 +70,26 @@ export interface PeopleStore extends AccountPeople {
|
|
|
64
70
|
undoMerge(to: string, from: string, by: string): Promise<PersonRecord>;
|
|
65
71
|
/** The owner's split: the chosen identities become one new person, which this gives. */
|
|
66
72
|
split(uid: string, identities: IdentityRef[], by: string): Promise<PersonRecord>;
|
|
73
|
+
/**
|
|
74
|
+
* Proposes that two identities' people are one, as an `identity_link` only the owner decides. Refused over the
|
|
75
|
+
* owner's separation or rejection; an open proposal for the same two people is given back instead of a second.
|
|
76
|
+
*/
|
|
77
|
+
proposeLink(input: IdentityLinkInput): Promise<ProposedAction>;
|
|
78
|
+
/** The owner's decision on an `identity_link`; confirm is refused with `identity.stale` when either person changed. */
|
|
79
|
+
decideLink(id: string, decision: IdentityLinkDecision): Promise<ProposedAction>;
|
|
80
|
+
/**
|
|
81
|
+
* One pass of the people matcher: the same address joins people in every scope, a phone exactly two people have
|
|
82
|
+
* joins them, a phone more people share, a role address such as `info@` and a meeting guest's typed address become
|
|
83
|
+
* proposals. Never over the owner's separation; a pair the owner rejected is proposed again only on new evidence.
|
|
84
|
+
*/
|
|
85
|
+
scanMatches(options?: {
|
|
86
|
+
full?: boolean;
|
|
87
|
+
}): Promise<MatchScan>;
|
|
88
|
+
/** The `identity_link` proposals, newest first, naming the people as they are now; `proposed` unless `status` says. */
|
|
89
|
+
linkProposals(filter: IdentityLinkFilter): Promise<{
|
|
90
|
+
items: IdentityLinkRow[];
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
}>;
|
|
67
93
|
/** The identity, and everyone linked with it, is the owner. */
|
|
68
94
|
linkToOwner(identity: IdentityRef): Promise<PersonRecord>;
|
|
69
95
|
/** A person known by name only, with no identity yet: someone to assign a task to before any message names them. */
|
package/dist/store/people.js
CHANGED
|
@@ -2,8 +2,10 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { keysOver } from "./keys.js";
|
|
3
3
|
import { ownerPerson } from "./sqlite/actors.js";
|
|
4
4
|
import * as identities from "./sqlite/identities.js";
|
|
5
|
+
import * as identityProposals from "./sqlite/identity-proposals.js";
|
|
5
6
|
import { linkToOwner } from "./sqlite/own-identities.js";
|
|
6
7
|
import * as personLinks from "./sqlite/person-links.js";
|
|
8
|
+
import { RULE, scanMatches } from "./sqlite/person-match-scan.js";
|
|
7
9
|
import * as personMerges from "./sqlite/person-merges.js";
|
|
8
10
|
import { personPreparation } from "./sqlite/person-preparation.js";
|
|
9
11
|
import { personSeenInAccounts } from "./sqlite/person-scope.js";
|
|
@@ -18,7 +20,15 @@ export const accountPeopleOver = (context) => {
|
|
|
18
20
|
for (const person of people) {
|
|
19
21
|
identityPk(accountKey, key.provider, person.id, person.name, person);
|
|
20
22
|
if (person.email)
|
|
21
|
-
personLinks.
|
|
23
|
+
personLinks.noteAddress(context, { provider: key.provider, id: person.id }, person.email);
|
|
24
|
+
}
|
|
25
|
+
// Every address of the batch is noted before any joins, so one shared by the whole batch is seen as shared.
|
|
26
|
+
for (const person of people) {
|
|
27
|
+
if (!person.email)
|
|
28
|
+
continue;
|
|
29
|
+
const held = personLinks.joinByAddress(context, { provider: key.provider, id: person.id }, person.email, key.provider);
|
|
30
|
+
if (held)
|
|
31
|
+
identityProposals.openIdentityLink(context, { ...held, joins: "person", signal: "email", by: RULE });
|
|
22
32
|
}
|
|
23
33
|
}),
|
|
24
34
|
contacts: async (key, options) => {
|
|
@@ -95,6 +105,10 @@ export const peopleStoreOver = (context, keyed) => {
|
|
|
95
105
|
merges: async (uid) => personMerges.merges(context, uid),
|
|
96
106
|
undoMerge: async (to, from, by) => write(database, () => personMerges.undoMerge(context, to, from, by)),
|
|
97
107
|
split: async (uid, chosen, by) => write(database, () => personMerges.split(context, uid, chosen, by)),
|
|
108
|
+
proposeLink: async (input) => identityProposals.proposeIdentityLink(context, input),
|
|
109
|
+
decideLink: async (id, decision) => identityProposals.decideIdentityLink(context, id, decision),
|
|
110
|
+
scanMatches: async (options) => scanMatches(context, options),
|
|
111
|
+
linkProposals: async (filter) => identityProposals.identityLinkRows(context, filter),
|
|
98
112
|
linkToOwner: async (identity) => linkToOwner(context, identity),
|
|
99
113
|
};
|
|
100
114
|
};
|
|
@@ -2,6 +2,7 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { and, asc, eq, inArray, sql } from "./drizzle/core.js";
|
|
3
3
|
import { pointerPairs } from "./entity-types.js";
|
|
4
4
|
import { forgetDanglingEvidence, forgetEvidenceTo } from "./evidence-signature.js";
|
|
5
|
+
import { forgetErasedLinks } from "./identity-link-rows.js";
|
|
5
6
|
import { mergeSql } from "./merged-persons.js";
|
|
6
7
|
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";
|
|
7
8
|
import { dropUnusedVectors } from "./vector-index.js";
|
|
@@ -198,6 +199,7 @@ export const dropOrphanPeople = (database, unseenBefore) => {
|
|
|
198
199
|
for (const table of ["identity_revisions", "identity_link_events", "identity_links"])
|
|
199
200
|
database.prepare(`DELETE FROM ${table} WHERE identity_id IN (SELECT value FROM json_each(?))`).run(gone);
|
|
200
201
|
database.prepare("DELETE FROM identities WHERE id IN (SELECT value FROM json_each(?))").run(gone);
|
|
202
|
+
forgetErasedLinks(database);
|
|
201
203
|
database
|
|
202
204
|
.prepare(`DELETE FROM persons WHERE id IN (SELECT value FROM json_each(?)) AND owner = 0
|
|
203
205
|
AND NOT EXISTS (SELECT 1 FROM identity_links l WHERE l.person_id = persons.id)
|
|
@@ -28,9 +28,15 @@ export interface AddedSourceInput {
|
|
|
28
28
|
};
|
|
29
29
|
metadata?: DocumentMetadata;
|
|
30
30
|
sections?: Section[];
|
|
31
|
+
/**
|
|
32
|
+
* What names it where it came from, `<namespace>:<id>` (`google-drive:<fileId>`). A source saved again under the
|
|
33
|
+
* same key is that source: changed text becomes its next revision, so what cites it is reviewed, never a second
|
|
34
|
+
* copy. Without a key a source is named by its content.
|
|
35
|
+
*/
|
|
36
|
+
sourceKey?: string;
|
|
31
37
|
}
|
|
32
38
|
/** What names an added source: enough to find it before anything is written. */
|
|
33
|
-
export type AddedSourceContent = Pick<AddedSourceInput, "kind" | "text" | "url" | "bytes">;
|
|
39
|
+
export type AddedSourceContent = Pick<AddedSourceInput, "kind" | "text" | "url" | "bytes" | "sourceKey">;
|
|
34
40
|
/** The part of `store.notes` that keeps the sources added by hand. */
|
|
35
41
|
export interface AddedSources {
|
|
36
42
|
/**
|
|
@@ -69,6 +75,11 @@ export interface AddedSource {
|
|
|
69
75
|
duplicateOf: string | null;
|
|
70
76
|
/** What is kept of the source: its text, or its text and a copy; `null` for a duplicate. */
|
|
71
77
|
kept: "text" | "copy" | null;
|
|
78
|
+
/**
|
|
79
|
+
* Whether its text was written now: a new source, a revived one, or a new revision under its source key. Optional
|
|
80
|
+
* because a host store that wraps this one (drive-cli) may not report it; absent means not reported.
|
|
81
|
+
*/
|
|
82
|
+
changed?: boolean;
|
|
72
83
|
/** Every subject the document is about now, the ones linked before included. */
|
|
73
84
|
subjects: string[];
|
|
74
85
|
}
|
|
@@ -87,8 +98,9 @@ export interface AddedSourceDetails {
|
|
|
87
98
|
copy: string | null;
|
|
88
99
|
}
|
|
89
100
|
/**
|
|
90
|
-
* The key an added source is stored under, `sha256:<hash>` (a file's bytes; pasted text or a page
|
|
91
|
-
* text, or its address when it has none), and every hash a folder or Drive document of the same
|
|
101
|
+
* The key an added source is stored under: its source key, else `sha256:<hash>` (a file's bytes; pasted text or a page
|
|
102
|
+
* by its normalized text, or its address when it has none), and every hash a folder or Drive document of the same
|
|
103
|
+
* content may carry.
|
|
92
104
|
*/
|
|
93
105
|
export declare const addedSourceKeyOf: (content: AddedSourceContent) => {
|
|
94
106
|
externalId: string;
|
|
@@ -6,14 +6,22 @@ import { fold } from "../normalize.js";
|
|
|
6
6
|
import { encodeDocumentMetadata, languageOf } from "./document-metadata.js";
|
|
7
7
|
import { syncFile } from "./files.js";
|
|
8
8
|
import { linkKind } from "./link-kinds.js";
|
|
9
|
-
import { documentOf, folderOf, insertLink, pathParts, requiredThing, thingRef, } from "./notes.js";
|
|
9
|
+
import { documentOf, folderOf, insertLink, keepRevision, pathParts, requiredThing, thingRef, } from "./notes.js";
|
|
10
10
|
import { oneOf, textOf } from "./text-input.js";
|
|
11
11
|
import { write } from "./transaction.js";
|
|
12
12
|
export const ADDED_KINDS = ["text", "file", "page"];
|
|
13
13
|
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
14
|
+
// `sha256:` is the content's own name, so no key may take it.
|
|
15
|
+
const SOURCE_KEY = /^(?!sha256:)[a-z][a-z0-9-]{0,39}:[A-Za-z0-9._~-]{1,200}$/;
|
|
16
|
+
const sourceKeyOf = (key) => {
|
|
17
|
+
if (!SOURCE_KEY.test(key))
|
|
18
|
+
throw new CliError("validation_error", "a source key is <namespace>:<id>: a lower-case namespace other than sha256, then letters, digits, . _ ~ or -", { param: "sourceKey" });
|
|
19
|
+
return key;
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
|
-
* The key an added source is stored under, `sha256:<hash>` (a file's bytes; pasted text or a page
|
|
16
|
-
* text, or its address when it has none), and every hash a folder or Drive document of the same
|
|
22
|
+
* The key an added source is stored under: its source key, else `sha256:<hash>` (a file's bytes; pasted text or a page
|
|
23
|
+
* by its normalized text, or its address when it has none), and every hash a folder or Drive document of the same
|
|
24
|
+
* content may carry.
|
|
17
25
|
*/
|
|
18
26
|
export const addedSourceKeyOf = (content) => {
|
|
19
27
|
const kind = oneOf(content.kind, ADDED_KINDS, "an added source's kind");
|
|
@@ -27,7 +35,8 @@ export const addedSourceKeyOf = (content) => {
|
|
|
27
35
|
const hash = kind === "file" ? sha256(content.bytes) : sha256(normalized || url);
|
|
28
36
|
// Drive keeps the sha256 of the text it exported, as is: pasted text or a page with that text is that file.
|
|
29
37
|
const hashes = [...new Set(kind === "file" || !text ? [hash] : [hash, sha256(content.text)])];
|
|
30
|
-
|
|
38
|
+
const externalId = content.sourceKey === undefined ? `sha256:${hash}` : sourceKeyOf(content.sourceKey);
|
|
39
|
+
return { externalId, hash, hashes };
|
|
31
40
|
};
|
|
32
41
|
/** The input checked. */
|
|
33
42
|
const checked = (input) => {
|
|
@@ -189,6 +198,16 @@ export const addedSourcesOver = (context) => {
|
|
|
189
198
|
const own = ownRow(source.externalId);
|
|
190
199
|
if (own !== undefined && own.deleted_at == null) {
|
|
191
200
|
const id = Number(own.id);
|
|
201
|
+
const revised = input.sourceKey !== undefined && own.content_hash !== source.hash;
|
|
202
|
+
if (revised) {
|
|
203
|
+
keepRevision(database, own, at);
|
|
204
|
+
database
|
|
205
|
+
.prepare("UPDATE documents SET kind = ?, title = ?, file_name = ?, extension = ?, url = ?, mime = ?, size = ?, " +
|
|
206
|
+
"content_hash = ?, body = ?, extraction = ?, metadata = ?, language = ?, revision = revision + 1, " +
|
|
207
|
+
"updated_at = ? WHERE id = ?")
|
|
208
|
+
.run(source.kind, source.title, source.fileName, source.extension, source.url, input.mime ?? null, input.size ?? input.bytes?.byteLength ?? null, source.hash, source.text, source.read === "extracted" ? "text" : "none", metadata, languageOf(input.metadata), at, id);
|
|
209
|
+
placeFile(id, at, source.fileName ?? source.title ?? source.externalId);
|
|
210
|
+
}
|
|
192
211
|
if (source.copy !== null && own.storage !== "copy")
|
|
193
212
|
database
|
|
194
213
|
.prepare("UPDATE documents SET storage = 'copy', local_path = ?, updated_at = ? WHERE id = ?")
|
|
@@ -199,6 +218,7 @@ export const addedSourcesOver = (context) => {
|
|
|
199
218
|
created: false,
|
|
200
219
|
duplicateOf: null,
|
|
201
220
|
kept,
|
|
221
|
+
changed: revised,
|
|
202
222
|
subjects: about(id, subjects, input.by),
|
|
203
223
|
};
|
|
204
224
|
}
|
|
@@ -206,7 +226,7 @@ export const addedSourcesOver = (context) => {
|
|
|
206
226
|
if (duplicate !== undefined) {
|
|
207
227
|
const linked = about(duplicate, subjects, input.by);
|
|
208
228
|
const note = documentAt(duplicate);
|
|
209
|
-
return { note, created: false, duplicateOf: note.ref, kept: null, subjects: linked };
|
|
229
|
+
return { note, created: false, duplicateOf: note.ref, kept: null, changed: false, subjects: linked };
|
|
210
230
|
}
|
|
211
231
|
const values = [
|
|
212
232
|
source.kind,
|
|
@@ -251,6 +271,7 @@ export const addedSourcesOver = (context) => {
|
|
|
251
271
|
created: !own,
|
|
252
272
|
duplicateOf: null,
|
|
253
273
|
kept: source.copy === null ? "text" : "copy",
|
|
274
|
+
changed: true,
|
|
254
275
|
subjects: about(id, subjects, input.by),
|
|
255
276
|
};
|
|
256
277
|
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type DealKind, type StageOutcome } from "../../domain/deals.js";
|
|
2
|
+
import type { AccountKey } from "../types.js";
|
|
3
|
+
import type { StoreContext } from "./open.js";
|
|
4
|
+
export interface StageName {
|
|
5
|
+
/** `stage:<id>`: a stage of any pipeline, as these commands name it. */
|
|
6
|
+
ref: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
/** One column of a base set: the open deals or leads whose stage maps to it, and how many stages do. */
|
|
10
|
+
export interface BaseColumn extends Omit<StageName, "ref"> {
|
|
11
|
+
/** `null` only in a set read from a read-only store before its first use made it. */
|
|
12
|
+
ref: string | null;
|
|
13
|
+
position: number;
|
|
14
|
+
outcome: StageOutcome;
|
|
15
|
+
open: number;
|
|
16
|
+
/** Stages of other pipelines confirmed onto it. */
|
|
17
|
+
mapped: number;
|
|
18
|
+
}
|
|
19
|
+
export interface BaseSet {
|
|
20
|
+
kind: DealKind;
|
|
21
|
+
/** The owner's own pipeline that holds the set; `null` while a read-only read shows the defaults not made yet. */
|
|
22
|
+
pipeline: string | null;
|
|
23
|
+
stages: BaseColumn[];
|
|
24
|
+
/** What no column holds yet: open rows whose stage is unmapped or only suggested, and those stages. */
|
|
25
|
+
unsorted: {
|
|
26
|
+
open: number;
|
|
27
|
+
stages: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** A stage of a pipeline outside the base set, and the base stage it maps to. */
|
|
31
|
+
export interface StageMapping extends StageName {
|
|
32
|
+
position: number;
|
|
33
|
+
outcome: StageOutcome;
|
|
34
|
+
/** The CRM's own id of the stage, which a CRM CLI's move matches first; `null` in an own pipeline. */
|
|
35
|
+
externalId: string | null;
|
|
36
|
+
kind: DealKind;
|
|
37
|
+
pipeline: string;
|
|
38
|
+
pipelineName: string;
|
|
39
|
+
account: AccountKey | null;
|
|
40
|
+
/** Suggested or confirmed; `null` until the base set exists or when nothing fits. */
|
|
41
|
+
baseStage: StageName | null;
|
|
42
|
+
confirmed: boolean;
|
|
43
|
+
open: number;
|
|
44
|
+
}
|
|
45
|
+
export interface BaseScope {
|
|
46
|
+
/** Only these CRM accounts' pipelines, with the owner's own; absent, every one. */
|
|
47
|
+
accounts?: readonly AccountKey[];
|
|
48
|
+
}
|
|
49
|
+
export interface MappingFilter extends BaseScope {
|
|
50
|
+
kind?: DealKind;
|
|
51
|
+
/** `pipeline:<id>`, or a name only one pipeline has. */
|
|
52
|
+
pipeline?: string;
|
|
53
|
+
unconfirmed?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** The base set of each kind, the mapping of every other pipeline's stages onto it, and moves by base stage. */
|
|
56
|
+
export interface BaseStagesStore {
|
|
57
|
+
/** The set with its board counts; the first use makes the default set and suggests every stage's mapping. */
|
|
58
|
+
show(kind: DealKind, scope?: BaseScope): Promise<BaseSet>;
|
|
59
|
+
/** Open stages go before the first won or lost one unless `position` says where. */
|
|
60
|
+
add(kind: DealKind, input: {
|
|
61
|
+
name: string;
|
|
62
|
+
outcome?: StageOutcome;
|
|
63
|
+
position?: number;
|
|
64
|
+
}): Promise<BaseSet>;
|
|
65
|
+
rename(kind: DealKind, stage: string, name: string): Promise<BaseSet>;
|
|
66
|
+
move(kind: DealKind, stage: string, position: number): Promise<BaseSet>;
|
|
67
|
+
/** Refused for the last stage of its outcome and for one the owner's own rows stand or stood in. */
|
|
68
|
+
remove(kind: DealKind, stage: string): Promise<BaseSet>;
|
|
69
|
+
mappings(filter?: MappingFilter): Promise<StageMapping[]>;
|
|
70
|
+
/** Maps `stage:<id>` onto a base stage of its kind, confirmed unless `confirmed: false` (an agent's suggestion). */
|
|
71
|
+
map(stage: string, base: string, scope?: BaseScope, options?: {
|
|
72
|
+
confirmed?: boolean;
|
|
73
|
+
}): Promise<StageMapping>;
|
|
74
|
+
/** Confirms every suggestion of one pipeline, or of all of them in scope; answers how many. */
|
|
75
|
+
confirm(target: {
|
|
76
|
+
pipeline: string;
|
|
77
|
+
} | {
|
|
78
|
+
all: true;
|
|
79
|
+
kind?: DealKind;
|
|
80
|
+
}, scope?: BaseScope): Promise<number>;
|
|
81
|
+
/**
|
|
82
|
+
* The stage of the row's own pipeline confirmed onto `base` (a base stage by `stage:<id>` or name), or `base` itself
|
|
83
|
+
* when it is a `stage:<id>` of that pipeline. Refused with `stage.choice-required` and the candidates when several
|
|
84
|
+
* are confirmed onto it, and with `stage.unmapped` when none is.
|
|
85
|
+
*/
|
|
86
|
+
resolve(item: string, base: string): Promise<{
|
|
87
|
+
stage: StageName & {
|
|
88
|
+
externalId: string | null;
|
|
89
|
+
outcome: StageOutcome;
|
|
90
|
+
};
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
export declare const baseStagesOver: (context: StoreContext) => {
|
|
94
|
+
show: (kind: DealKind, scope?: BaseScope) => BaseSet;
|
|
95
|
+
add: (kind: DealKind, input: {
|
|
96
|
+
name: string;
|
|
97
|
+
outcome?: StageOutcome;
|
|
98
|
+
position?: number;
|
|
99
|
+
}) => BaseSet;
|
|
100
|
+
rename: (kind: DealKind, stage: string, name: string) => BaseSet;
|
|
101
|
+
move: (kind: DealKind, stage: string, position: number) => BaseSet;
|
|
102
|
+
remove: (kind: DealKind, stage: string) => BaseSet;
|
|
103
|
+
mappings: (filter?: MappingFilter) => StageMapping[];
|
|
104
|
+
map: (stage: string, base: string, scope?: BaseScope, { confirmed }?: {
|
|
105
|
+
confirmed?: boolean;
|
|
106
|
+
}) => StageMapping;
|
|
107
|
+
confirm: (target: {
|
|
108
|
+
pipeline: string;
|
|
109
|
+
} | {
|
|
110
|
+
all: true;
|
|
111
|
+
kind?: DealKind;
|
|
112
|
+
}, scope?: BaseScope) => number;
|
|
113
|
+
resolve: (item: string, base: string) => {
|
|
114
|
+
stage: {
|
|
115
|
+
ref: string;
|
|
116
|
+
name: string;
|
|
117
|
+
externalId: string | null;
|
|
118
|
+
outcome: StageOutcome;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export declare const baseStagesStoreOver: (context: StoreContext) => BaseStagesStore;
|