@wirecat/cli-core 0.605.0 → 0.606.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/dist/cli/index.d.ts +1 -1
  3. package/dist/cli/index.js +1 -0
  4. package/dist/cli/store-settings.js +38 -4
  5. package/dist/crm/cli/index.js +3 -1
  6. package/dist/crm/index.d.ts +2 -2
  7. package/dist/crm/index.js +1 -1
  8. package/dist/crm/source.d.ts +35 -5
  9. package/dist/crm/sync.d.ts +15 -7
  10. package/dist/crm/sync.js +169 -11
  11. package/dist/domain/crm.d.ts +41 -2
  12. package/dist/domain/deals.d.ts +5 -2
  13. package/dist/domain/deals.js +5 -2
  14. package/dist/domain/relations.d.ts +125 -0
  15. package/dist/domain/relations.js +107 -0
  16. package/dist/entities/deal.d.ts +2 -2
  17. package/dist/entities/deal.js +2 -1
  18. package/dist/entities/index.d.ts +17 -13
  19. package/dist/entities/relationship.d.ts +8 -2
  20. package/dist/entities/relationship.js +8 -2
  21. package/dist/entities/task-results.d.ts +10 -10
  22. package/dist/errors/reasons.js +12 -0
  23. package/dist/index.d.ts +2 -1
  24. package/dist/index.js +1 -0
  25. package/dist/mail/cli/review.js +20 -6
  26. package/dist/mail/index.d.ts +1 -1
  27. package/dist/mail/marks.d.ts +10 -5
  28. package/dist/mail/marks.js +16 -8
  29. package/dist/mail/review.d.ts +5 -0
  30. package/dist/services/link-scorers/scan.js +2 -1
  31. package/dist/services/link-scorers/shared.js +2 -1
  32. package/dist/services/project-status/index.js +2 -1
  33. package/dist/services/stored-project-gathering.js +4 -3
  34. package/dist/store/exports.d.ts +1 -0
  35. package/dist/store/exports.js +1 -0
  36. package/dist/store/index.d.ts +6 -1
  37. package/dist/store/index.js +1 -0
  38. package/dist/store/project-transfer/request.d.ts +4 -1
  39. package/dist/store/project-transfer/schema.d.ts +9 -2
  40. package/dist/store/project-transfer/schema.js +4 -0
  41. package/dist/store/project-transfer/snapshot-model.d.ts +8 -2
  42. package/dist/store/sqlite/crm-settings.d.ts +28 -0
  43. package/dist/store/sqlite/crm-settings.js +80 -0
  44. package/dist/store/sqlite/crm.d.ts +42 -2
  45. package/dist/store/sqlite/crm.js +397 -36
  46. package/dist/store/sqlite/deals.js +3 -2
  47. package/dist/store/sqlite/involvement-queue.js +4 -3
  48. package/dist/store/sqlite/knowledge.d.ts +7 -3
  49. package/dist/store/sqlite/knowledge.js +43 -31
  50. package/dist/store/sqlite/link-kinds.d.ts +2 -3
  51. package/dist/store/sqlite/link-kinds.js +4 -2
  52. package/dist/store/sqlite/manifest.js +5 -0
  53. package/dist/store/sqlite/memories.d.ts +1 -1
  54. package/dist/store/sqlite/memories.js +33 -7
  55. package/dist/store/sqlite/migrations.generated.js +31 -0
  56. package/dist/store/sqlite/notes.d.ts +3 -2
  57. package/dist/store/sqlite/notes.js +23 -6
  58. package/dist/store/sqlite/organizations.d.ts +8 -0
  59. package/dist/store/sqlite/organizations.js +14 -0
  60. package/dist/store/sqlite/person-preparation.d.ts +1 -1
  61. package/dist/store/sqlite/person-preparation.js +3 -2
  62. package/dist/store/sqlite/project-transfer/records.js +14 -3
  63. package/dist/store/sqlite/project-transfer/snapshot.d.ts +4 -1
  64. package/dist/store/sqlite/project-transfer/snapshot.js +6 -0
  65. package/dist/store/sqlite/relation-list.d.ts +43 -0
  66. package/dist/store/sqlite/relation-list.js +133 -0
  67. package/dist/store/sqlite/relation-proposals.d.ts +28 -6
  68. package/dist/store/sqlite/relation-proposals.js +134 -10
  69. package/dist/store/sqlite/relation-reads.d.ts +8 -0
  70. package/dist/store/sqlite/relation-reads.js +7 -0
  71. package/dist/store/sqlite/relation-roles.d.ts +26 -0
  72. package/dist/store/sqlite/relation-roles.js +91 -0
  73. package/dist/store/sqlite/reported-relations.d.ts +63 -0
  74. package/dist/store/sqlite/reported-relations.js +132 -0
  75. package/dist/store/sqlite/schema/link-revisions.d.ts +136 -0
  76. package/dist/store/sqlite/schema/link-revisions.js +11 -0
  77. package/dist/store/sqlite/schema/links.d.ts +360 -0
  78. package/dist/store/sqlite/schema/links.js +32 -0
  79. package/dist/store/sqlite/schema.d.ts +2 -296
  80. package/dist/store/sqlite/schema.js +2 -24
  81. package/dist/store/store.d.ts +3 -0
  82. package/dist/store/store.js +5 -0
  83. package/package.json +3 -3
@@ -52,7 +52,7 @@ export declare const taskCard: v.StrictObjectSchema<{
52
52
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
53
53
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
54
54
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
55
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
55
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
56
56
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
57
57
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
58
58
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -67,7 +67,7 @@ export declare const taskCard: v.StrictObjectSchema<{
67
67
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
68
68
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
69
69
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
70
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
70
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
71
71
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
72
72
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
73
73
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -170,7 +170,7 @@ export declare const taskCreated: v.StrictObjectSchema<{
170
170
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
171
171
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
172
172
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
173
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
173
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
174
174
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
175
175
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
176
176
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -185,7 +185,7 @@ export declare const taskCreated: v.StrictObjectSchema<{
185
185
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
186
186
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
187
187
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
188
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
188
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
189
189
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
190
190
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
191
191
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -289,7 +289,7 @@ export declare const taskLinks: v.UnionSchema<[v.StrictObjectSchema<{
289
289
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
290
290
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
291
291
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
292
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
292
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
293
293
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
294
294
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
295
295
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -304,7 +304,7 @@ export declare const taskLinks: v.UnionSchema<[v.StrictObjectSchema<{
304
304
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
305
305
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
306
306
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
307
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
307
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
308
308
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
309
309
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
310
310
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -436,7 +436,7 @@ export declare const taskMerge: v.StrictObjectSchema<{
436
436
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
437
437
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
438
438
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
439
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
439
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
440
440
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
441
441
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
442
442
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -451,7 +451,7 @@ export declare const taskMerge: v.StrictObjectSchema<{
451
451
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
452
452
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
453
453
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
454
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
454
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
455
455
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
456
456
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
457
457
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -548,7 +548,7 @@ export declare const taskUnmerge: v.StrictObjectSchema<{
548
548
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
549
549
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
550
550
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
551
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
551
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
552
552
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
553
553
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
554
554
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -563,7 +563,7 @@ export declare const taskUnmerge: v.StrictObjectSchema<{
563
563
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
564
564
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
565
565
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
566
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
566
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
567
567
  readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
568
568
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
569
569
  readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
@@ -219,6 +219,7 @@ const OTHERS = [
219
219
  validation("record.reference-not-found", "a reference in the record's fields is not in the store"),
220
220
  validation("record.relation-ambiguous", "the record names more than one target for a role that takes one"),
221
221
  validation("record.stale-revision", "the store holds a newer revision of the record"),
222
+ validation("memory.already-superseded", "the memory was already replaced by another"),
222
223
  validation("memory.evidence-required", "a memory needs its evidence"),
223
224
  validation("memory.scope-required", "a memory needs its scope"),
224
225
  validation("money.amount", "the amount is not a decimal string in the currency's scale"),
@@ -242,6 +243,13 @@ const OTHERS = [
242
243
  validation("field.unknown-kind", "fields are listed for deals, leads, people and organizations only"),
243
244
  validation("crm.write-unsupported", "the CRM does not take this write, or does not recognise a repeated one"),
244
245
  validation("crm.unlisted-held", "a list of every id would mark most of a kind deleted; nothing was, until --rescan"),
246
+ validation("crm.not-reported", "the CRM did not list users or departments; what they would say is unknown, nothing withdrawn"),
247
+ validation("crm.reference-unknown", "a CRM row names a contact, company or user the store does not hold; that link was not made"),
248
+ validation("crm.pending-dropped", "relationships waited too long for an end that never came; they were dropped"),
249
+ validation("crm.email-ambiguous", "a CRM contact's email belongs to more than one person; the owner decides"),
250
+ validation("crm.own-unknown", "no own company of the CRM account is stored, so its users are no one's employees yet"),
251
+ validation("relationship.reference-unknown", "a reported relationship names something the store does not hold"),
252
+ validation("relationship.invalid", "a reported relationship joins ends or takes a role the registry refuses"),
245
253
  validation("order.duplicate", "the shop's order with this number is already stored; change its status instead"),
246
254
  validation("order.proposed", "the shop's order with this number already waits for the owner in a findings batch"),
247
255
  validation("order.field", "a field of the order is not valid"),
@@ -293,6 +301,10 @@ const OTHERS = [
293
301
  ["proposals.agent-decisions-off", "permission_error", "agent decisions are turned off; the owner decides"],
294
302
  ["proposal.unknown-kind", "not_found", "no registered proposal kind holds this id"],
295
303
  validation("relationship.exists", "a confirmed relationship already links them"),
304
+ validation("relationship.role-exists", "the role list holds that role already"),
305
+ validation("relationship.role-built-in", "a built-in role stays on its list"),
306
+ validation("relationship.role-in-use", "relationships still hold that role; change them first (details.count)"),
307
+ validation("relationship.role-unknown", "the role is not one the relationship takes; the message lists them"),
296
308
  validation("ranking.invalid", "the ranking is not valid"),
297
309
  validation("ref.malformed", "the reference has a known kind but not its shape"),
298
310
  validation("ref.unknown-kind", "the text names no kind of reference"),
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { bareCheck, type CheckWords, checkWords } from "./domain/checks.js";
2
2
  export type { CounterField, CounterObservation, CounterObservations, CounterState } from "./domain/counters.js";
3
3
  export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
4
- export { CRM_KINDS, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmStage, type CrmValue, isItemKind, } from "./domain/crm.js";
4
+ export { CRM_KINDS, type CrmDepartment, type CrmField, type CrmItem, type CrmKind, type CrmOrganization, type CrmPerson, type CrmPipeline, type CrmRecords, type CrmStage, type CrmUser, type CrmValue, isItemKind, } from "./domain/crm.js";
5
5
  export { DEAL_KINDS, DEAL_ROLES, DEAL_STATUSES, type DealKind, type DealRole, type DealStatus, STAGE_OUTCOMES, type StageOutcome, } from "./domain/deals.js";
6
6
  export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
7
7
  export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
@@ -19,6 +19,7 @@ export type { RankingComponent, RankingInput, RankingMeasure, RankingOptions, Ra
19
19
  export { rankingOptions } from "./domain/rankings-options.js";
20
20
  export { type EnvelopeRecord, type EnvelopeSource, envelopeOfJsonl, type IngestError, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, type RecordEntityType, type RecordOperation, type RecordRelation, type RecordsEnvelope, } from "./domain/records.js";
21
21
  export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, type Reference, type RefKindName, type RefKindSpec, } from "./domain/references.js";
22
+ export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, type RelationKind, ROLE_LISTS, type RoleList, rolesOf, STANDINGS, type Standing, standingOf, usableLink, } from "./domain/relations.js";
22
23
  export { normalizeTag, TAG_TYPES, type TagType } from "./domain/tags.js";
23
24
  export { type AppErrors, DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
24
25
  export { canonicalMeetingReference, formatMeetingReference, type MeetingReference, parseMeetingReference, } from "./meetings/index.js";
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export { CRM_OPENS, FOLDER_PROVIDERS, isFolderProvider, isKind, KINDS, kindIn, k
14
14
  export { rankingOptions } from "./domain/rankings-options.js";
15
15
  export { envelopeOfJsonl, RECORD_ENTITY_TYPES, RECORD_OPERATIONS, RECORDS_ENVELOPE_SCHEMA, RECORDS_SCHEMA_VERSION, } from "./domain/records.js";
16
16
  export { canonicalReference, formatReference, looksLikeReference, parseReference, REF_KINDS, } from "./domain/references.js";
17
+ export { inverseOf, isUsable, ORGANIZATION_ROLES, PROJECT_ROLES, RELATION_KINDS, RELATIONS, ROLE_LISTS, rolesOf, STANDINGS, standingOf, usableLink, } from "./domain/relations.js";
17
18
  export { normalizeTag, TAG_TYPES } from "./domain/tags.js";
18
19
  export { DETAILS as CORE_DETAILS, failureContext, REASONS as CORE_REASONS } from "./errors/reasons.js";
19
20
  export { canonicalMeetingReference, formatMeetingReference, parseMeetingReference, } from "./meetings/index.js";
@@ -19,7 +19,7 @@ import { parseDuration } from "../../domain/duration.js";
19
19
  import { formatReference } from "../../domain/references.js";
20
20
  import { AGENDA_DEFAULTS } from "../../services/agenda.js";
21
21
  import { REVIEW_DAYS, reviewStart } from "../../services/inbox.js";
22
- import { readPastMark } from "../marks.js";
22
+ import { cursorOf, findingsKeyOf, readPastMark } from "../marks.js";
23
23
  import { BULK_TRIAGE_DEFAULTS } from "../newsletter.js";
24
24
  import { hitText } from "../read.js";
25
25
  import { OWED_DAYS, REVIEW_THREADS, reviewMail } from "../review.js";
@@ -146,6 +146,7 @@ const reviewAnswer = (found, mailbox, fresh, step) => {
146
146
  bulk: (message.marks?.bulk ?? false) || message.excerptOnly === true,
147
147
  ...(message.excerptOnly ? { excerpt_only: true } : {}),
148
148
  ...(message.partialExcerpt ? { partial: true } : {}),
149
+ ...(message.through ? { cursor: message.through.cursor, findings_key: message.through.findingsKey } : {}),
149
150
  list_id: message.marks?.listId ?? null,
150
151
  rule_id: message.marks?.ruleId ?? null,
151
152
  ...(message.marks
@@ -170,15 +171,27 @@ const holderReview = async (command, mail, holder, query) => {
170
171
  if (typedQuery(query).trim() || unanswered !== undefined || waiting !== undefined)
171
172
  throw new CliError("validation_error", "--holder reads past its own mark — not with a query, --unanswered or --waiting");
172
173
  const triage = mail.bulkTriage?.(command) ?? BULK_TRIAGE_DEFAULTS;
174
+ const now = Date.now();
173
175
  const { read, mailbox, marks } = await mail.read(command, async (store, mailbox) => {
174
- const read = await readPastMark(store, mailbox, holder, { triage });
176
+ const read = await readPastMark(store, mailbox, holder, { triage, now });
175
177
  const ids = [...read.emails, ...read.excerpts.map(({ email }) => email)].map((one) => one.id);
176
178
  const account = ids.length ? await store.accounts.storedAccount(mailbox) : undefined;
177
179
  const marks = account ? await store.mail.emailMarks(account.id, ids) : new Map();
178
180
  return { read, mailbox, marks };
179
181
  });
182
+ const markedThrough = read.mark?.throughId ?? 0;
183
+ const heldThrough = [...read.emails, ...read.excerpts.map(({ email }) => email)].reduce((most, { storeId }) => (storeId <= markedThrough ? Math.max(most, storeId) : most), 0);
184
+ // A held email is older than the mark, and a cursor never moves the mark back.
185
+ const through = (id) => {
186
+ const held = id <= markedThrough;
187
+ const at = held ? markedThrough : id;
188
+ return {
189
+ cursor: cursorOf(at, now),
190
+ findingsKey: findingsKeyOf(holder, at, read.mark?.resets ?? 0, held ? heldThrough : undefined),
191
+ };
192
+ };
180
193
  // An agent reads this: earlier mail and signatures stay out of its text; the fingerprint is over the stored body.
181
- const emails = [
194
+ const listed = [
182
195
  ...read.emails.map((email) => ({ ...email, text: mailOwnText(email.text) })),
183
196
  ...read.excerpts.map(({ email, excerpt, partial }) => {
184
197
  const subject = email.email?.subject;
@@ -190,6 +203,7 @@ const holderReview = async (command, mail, holder, query) => {
190
203
  };
191
204
  }),
192
205
  ];
206
+ const emails = listed.map(({ storeId, ...email }) => ({ ...email, through: through(storeId) }));
193
207
  const chats = new Map();
194
208
  for (const email of emails) {
195
209
  const chat = chats.get(email.chatId) ?? {
@@ -203,10 +217,10 @@ const holderReview = async (command, mail, holder, query) => {
203
217
  chat.messages.push(mark ? { ...email, marks: mark } : email);
204
218
  chats.set(email.chatId, chat);
205
219
  }
206
- const now = new Date().toISOString();
220
+ const until = new Date(now).toISOString();
207
221
  const found = {
208
- since: read.mark?.throughAt ? new Date(read.mark.throughAt).toISOString() : now,
209
- until: now,
222
+ since: read.mark?.throughAt ? new Date(read.mark.throughAt).toISOString() : until,
223
+ until,
210
224
  complete: !read.more,
211
225
  chats: [...chats.values()],
212
226
  skipped: [],
@@ -9,7 +9,7 @@ export { dropMissing, type Gone, tooManyGone } from "./gone.js";
9
9
  export { type AuthVerdicts, HEADER_FIELDS, headersOf, type MailHeaders, mailHeadersOf } from "./headers.js";
10
10
  export { type MailIdsInput, mailIds } from "./ids.js";
11
11
  export { decodedLabelName, decodeMailboxName, labelName, systemLabel } from "./labels.js";
12
- export { acknowledgeMark, advancePastSkipped, type BulkExcerpt, cursorOf, HOLD_PARTIAL_MS, HOLDER, MARK_BATCH, type MailMark, type MailWaiting, type MarkRead, type MarkRewind, mailWaiting, markOf, marksOf, type RewoundMark, readPastMark, rewindMark, type SkipReason, } from "./marks.js";
12
+ export { acknowledgeMark, advancePastSkipped, type BulkExcerpt, cursorOf, HOLD_PARTIAL_MS, HOLDER, MARK_BATCH, type MailMark, type MailWaiting, type MarkedHit, type MarkRead, type MarkRewind, mailWaiting, markOf, marksOf, type RewoundMark, readPastMark, rewindMark, type SkipReason, } from "./marks.js";
13
13
  export { BULK_TRIAGE_DEFAULTS, type BulkSorted, type BulkTriage, excerptOf, NEWSLETTER_DEFAULTS, NEWSLETTER_SENDERS, NEWSLETTER_WORDS, type NewsletterCues, newsletterSorter, ORDER_WORDS, } from "./newsletter.js";
14
14
  export { type MailTurn, mailTurn } from "./owed.js";
15
15
  export { type Address, htmlToText, looksLikeHtml, MAX_ATTACHMENTS, MAX_BODY_CHARS, type ParsedMail, parseMail, } from "./parse.js";
@@ -34,13 +34,18 @@ export declare const marksOf: (store: MessageStore, mailbox: AccountKey) => Prom
34
34
  export declare const cursorOf: (throughId: number, readAt: number) => string;
35
35
  /**
36
36
  * The findings key of one run: `<holder>:<through_id>`, and `-r<resets>` once the owner moved the mark back, so the
37
- * runs after a reset never reach a key a batch staged before it holds. The same review gives the same key: a retry
38
- * of one run stages nothing twice.
37
+ * runs after a reset never reach a key a batch staged before it holds. A batch that ends at the mark itself, held
38
+ * emails only, adds `-h<highest held id>`: the run that set the mark already holds the plain key. The same review
39
+ * gives the same key: a retry of one run stages nothing twice.
39
40
  */
40
- export declare const findingsKeyOf: (holder: string, throughId: number, resets: number) => string;
41
+ export declare const findingsKeyOf: (holder: string, throughId: number, resets: number, heldThrough?: number) => string;
41
42
  /** A bulk email that is not surely a newsletter: the holder gets its subject and first lines only. */
43
+ /** An email as a hit, with its store id: the order a mark counts by. */
44
+ export type MarkedHit = StoredHit & {
45
+ storeId: number;
46
+ };
42
47
  export interface BulkExcerpt {
43
- email: StoredHit;
48
+ email: MarkedHit;
44
49
  /** The first lines of its own text, without the subject. */
45
50
  excerpt: string;
46
51
  /** What kept it, or the newsletter signs too few to leave it out. */
@@ -50,7 +55,7 @@ export interface BulkExcerpt {
50
55
  }
51
56
  export interface MarkRead {
52
57
  /** The emails for the holder, oldest first; bulk, envelopes, drafts, suspicious senders and partial mail left out. */
53
- emails: StoredHit[];
58
+ emails: MarkedHit[];
54
59
  /** Bulk mail past the mark that is not surely a newsletter, oldest first; none when the triage gives no excerpts. */
55
60
  excerpts: BulkExcerpt[];
56
61
  /** What `acknowledge --cursor` takes once the holder is done with these. */
@@ -85,10 +85,11 @@ const verdict = (email, now) => {
85
85
  export const cursorOf = (throughId, readAt) => `${throughId}.${readAt}`;
86
86
  /**
87
87
  * The findings key of one run: `<holder>:<through_id>`, and `-r<resets>` once the owner moved the mark back, so the
88
- * runs after a reset never reach a key a batch staged before it holds. The same review gives the same key: a retry
89
- * of one run stages nothing twice.
88
+ * runs after a reset never reach a key a batch staged before it holds. A batch that ends at the mark itself, held
89
+ * emails only, adds `-h<highest held id>`: the run that set the mark already holds the plain key. The same review
90
+ * gives the same key: a retry of one run stages nothing twice.
90
91
  */
91
- export const findingsKeyOf = (holder, throughId, resets) => `${holder}:${throughId}${resets > 0 ? `-r${resets}` : ""}`;
92
+ export const findingsKeyOf = (holder, throughId, resets, heldThrough) => `${holder}:${throughId}${heldThrough === undefined ? "" : `-h${heldThrough}`}${resets > 0 ? `-r${resets}` : ""}`;
92
93
  const parseCursor = (cursor) => {
93
94
  const match = /^(\d+)\.(\d+)$/.exec(cursor.trim());
94
95
  if (!match)
@@ -106,7 +107,14 @@ export const readPastMark = async (store, mailbox, holder, options = {}) => {
106
107
  const one = sorted.get(id);
107
108
  return one ? [{ email: one.email, excerpt: one.excerpt, cues: one.cues, partial: one.partial }] : [];
108
109
  });
109
- const emails = await store.mail.emailHits(wanted.filter((id) => !sorted.has(id)));
110
+ const ids = wanted.filter((one) => !sorted.has(one));
111
+ const hits = await store.mail.emailHits(ids);
112
+ // emailHits keeps the ids' order and drops an email deleted since; only then is each one asked for alone.
113
+ const emails = hits.length === ids.length ? hits.map((hit, index) => ({ ...hit, storeId: ids[index] })) : [];
114
+ if (hits.length !== ids.length)
115
+ for (const id of ids)
116
+ for (const hit of await store.mail.emailHits([id]))
117
+ emails.push({ ...hit, storeId: id });
110
118
  return { emails, excerpts, ...read };
111
119
  };
112
120
  /**
@@ -132,7 +140,7 @@ const sortBulk = async (store, batch, triage) => {
132
140
  return { sorted, end: index };
133
141
  if (one.verdict === "excerpt")
134
142
  excerpts += 1;
135
- sorted.set(marked.id, { ...one, email, partial: marked.partial });
143
+ sorted.set(marked.id, { ...one, email: { ...email, storeId: marked.id }, partial: marked.partial });
136
144
  }
137
145
  return { sorted, end: batch.length };
138
146
  };
@@ -149,9 +157,9 @@ const examine = async (store, mailbox, holder, { now = Date.now(), limit = MARK_
149
157
  skipped: noneSkipped(),
150
158
  mark: saved,
151
159
  };
152
- const keyed = (throughId) => ({
160
+ const keyed = (throughId, heldThrough) => ({
153
161
  cursor: cursorOf(throughId, now),
154
- findingsKey: throughId > 0 ? findingsKeyOf(holder, throughId, saved?.resets ?? 0) : undefined,
162
+ findingsKey: throughId > 0 ? findingsKeyOf(holder, throughId, saved?.resets ?? 0, heldThrough) : undefined,
155
163
  });
156
164
  if (!account)
157
165
  return { ...empty, ...keyed(0) };
@@ -192,7 +200,7 @@ const examine = async (store, mailbox, holder, { now = Date.now(), limit = MARK_
192
200
  wanted: wanted.sort((a, b) => a - b),
193
201
  sorted: new Map([...sorted].filter(([, one]) => one.verdict === "excerpt")),
194
202
  oldestStoredAt,
195
- ...keyed(batch.at(-1)?.id ?? mark.throughId),
203
+ ...(batch.length > 0 ? keyed(batch.at(-1)?.id ?? mark.throughId) : keyed(mark.throughId, wanted.at(-1))),
196
204
  more: newer.length > batch.length,
197
205
  held,
198
206
  skipped,
@@ -23,6 +23,11 @@ export type MailHit = StoredHit & {
23
23
  marks?: EmailMarks;
24
24
  excerptOnly?: true;
25
25
  partialExcerpt?: true;
26
+ /** A holder's read: the cursor and findings key that end the batch at this email. */
27
+ through?: {
28
+ cursor: string;
29
+ findingsKey: string;
30
+ };
26
31
  };
27
32
  export interface MailReview extends Review {
28
33
  chats: (Omit<ReviewChat, "messages"> & {
@@ -1,5 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { parseReference } from "../../domain/references.js";
3
+ import { isUsable } from "../../domain/relations.js";
3
4
  import { BUILT_IN_PURPOSES } from "../project-purposes.js";
4
5
  import { canonicalProjectRef } from "../stored-project-gathering.js";
5
6
  import { aliasHits } from "./alias-hits.js";
@@ -32,7 +33,7 @@ const projectOf = async (store, reference) => {
32
33
  const confirmedOf = async (store, project) => {
33
34
  if (!project)
34
35
  return { chats: [], people: [] };
35
- const members = (await store.knowledge.relations(null, project.ref)).filter((one) => one.confirmed && one.kind === "member-of" && one.to === project.ref);
36
+ const members = (await store.knowledge.relations(null, project.ref)).filter((one) => isUsable(one.standing) && one.kind === "member-of" && one.to === project.ref);
36
37
  return {
37
38
  chats: [...new Set(members.map((one) => one.from).filter((ref) => ref.startsWith("chat:")))].sort(),
38
39
  people: [...new Set(members.map((one) => one.from).filter((ref) => ref.startsWith("person:")))].sort(),
@@ -1,4 +1,5 @@
1
1
  import { formatReference } from "../../domain/references.js";
2
+ import { isUsable } from "../../domain/relations.js";
2
3
  import { normalizeVocabularyName } from "../../domain/vocabulary.js";
3
4
  const escaped = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
5
  const folded = (text) => text.normalize("NFKC").toLowerCase().replace(/\s+/gu, " ");
@@ -34,7 +35,7 @@ export const personRefOf = async (store, provider, id) => {
34
35
  export const projectsOf = async (store, person, project) => new Set([
35
36
  project,
36
37
  ...(await store.knowledge.relations(null, person))
37
- .filter((one) => one.confirmed && one.kind === "member-of" && one.from === person && one.to.startsWith("project:"))
38
+ .filter((one) => isUsable(one.standing) && one.kind === "member-of" && one.from === person && one.to.startsWith("project:"))
38
39
  .map((one) => one.to),
39
40
  ]).size;
40
41
  /** Each confirmed member's identities in one messenger, by member. */
@@ -1,5 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { formatReference } from "../../domain/references.js";
3
+ import { isUsable } from "../../domain/relations.js";
3
4
  import { chatCoverage } from "../chat-coverage.js";
4
5
  import { LINK_PURPOSE, purposeRead, purposesOf } from "../project-purposes.js";
5
6
  import { canonicalProjectRef, linkedChatsOf, storedChatCount, } from "../stored-project-gathering.js";
@@ -24,7 +25,7 @@ const childrenOf = async (store, root, catalog) => {
24
25
  const below = [];
25
26
  for (const parent of level)
26
27
  for (const relation of await store.knowledge.relations(null, parent)) {
27
- if (!relation.confirmed || relation.kind !== "member-of" || relation.to !== parent)
28
+ if (!isUsable(relation.standing) || relation.kind !== "member-of" || relation.to !== parent)
28
29
  continue;
29
30
  if (!relation.from.startsWith("project:"))
30
31
  continue;
@@ -1,5 +1,6 @@
1
1
  import { CliError } from "@wirecat/cli-base";
2
2
  import { formatReference, parseReference } from "../domain/references.js";
3
+ import { isUsable } from "../domain/relations.js";
3
4
  import { chatCoverage } from "./chat-coverage.js";
4
5
  import { gatherProjectEvidence } from "./project-gathering.js";
5
6
  import { storedNeighbours } from "./project-gathering-around.js";
@@ -121,7 +122,7 @@ const proposedLinksOf = async (store, project) => {
121
122
  })
122
123
  .sort((a, b) => Number(a.id) - Number(b.id));
123
124
  const legacy = (await store.knowledge.relations(null, project))
124
- .filter((one) => !one.confirmed && one.kind === "member-of" && one.to === project)
125
+ .filter((one) => one.standing === "proposed" && one.kind === "member-of" && one.to === project)
125
126
  .map((one) => ({ from: one.from, id: `link:${one.id}`, role: one.role, purpose: one.purpose }));
126
127
  return [...proposals, ...legacy];
127
128
  };
@@ -131,7 +132,7 @@ const memberRefsOf = async (store, project, includeProposed) => {
131
132
  return [];
132
133
  const confirmed = new Set();
133
134
  for (const relation of await store.knowledge.relations(null, project))
134
- if (relation.confirmed &&
135
+ if (isUsable(relation.standing) &&
135
136
  relation.kind === "member-of" &&
136
137
  relation.to === project &&
137
138
  /^person:.+/.test(relation.from))
@@ -180,7 +181,7 @@ export const linkedChatsOf = async (store, project, options = {}) => {
180
181
  return [];
181
182
  const chats = [];
182
183
  for (const relation of await store.knowledge.relations(null, project)) {
183
- if (!relation.confirmed || relation.kind !== "member-of" || relation.to !== project)
184
+ if (!isUsable(relation.standing) || relation.kind !== "member-of" || relation.to !== project)
184
185
  continue;
185
186
  const reference = chatOf(relation.from);
186
187
  if (reference)
@@ -23,6 +23,7 @@ export { storeClients } from "./sqlite/clients.js";
23
23
  export { CHAT_LIST_KEY, type ChatCompleteness, type ChatCoverage, fetchedKey, historyStartKey, } from "./sqlite/completeness.js";
24
24
  export { CONVERSATION_COLUMNS } from "./sqlite/conversations.js";
25
25
  export type { CounterTarget } from "./sqlite/counters.js";
26
+ export { crmSettingsOf, parseCrmSetting, parseCrmSettingValue, saveCrmSetting } from "./sqlite/crm-settings.js";
26
27
  export { type EmailMarks, MAIL_AGENDA_COLUMNS, type MarkedEmail, type NewestEmail, type ThreadActivity, } from "./sqlite/email-activity.js";
27
28
  export { messageOfEmail, threadConversation } from "./sqlite/emails.js";
28
29
  export { orphanPointers } from "./sqlite/entity-types.js";
@@ -6,6 +6,7 @@ export { CHAT_COLUMNS, TRACKED_CHAT_COLUMNS, titlePart } from "./sqlite/chats.js
6
6
  export { storeClients } from "./sqlite/clients.js";
7
7
  export { CHAT_LIST_KEY, fetchedKey, historyStartKey, } from "./sqlite/completeness.js";
8
8
  export { CONVERSATION_COLUMNS } from "./sqlite/conversations.js";
9
+ export { crmSettingsOf, parseCrmSetting, parseCrmSettingValue, saveCrmSetting } from "./sqlite/crm-settings.js";
9
10
  export { MAIL_AGENDA_COLUMNS, } from "./sqlite/email-activity.js";
10
11
  export { messageOfEmail, threadConversation } from "./sqlite/emails.js";
11
12
  export { orphanPointers } from "./sqlite/entity-types.js";
@@ -38,7 +38,8 @@ export type { BotUpdate, BotUpdateStore } from "./sqlite/bot-updates.js";
38
38
  export type { CatalogActor, CatalogEntry, CatalogInput, CatalogQuery, CatalogStore } from "./sqlite/catalog.js";
39
39
  export { CATALOG_QUERY } from "./sqlite/catalog.js";
40
40
  export type { ChatMetadata } from "./sqlite/chats.js";
41
- export { type CrmCopies, type CrmSaved, type CrmSkipped, crmIdentityId } from "./sqlite/crm.js";
41
+ export { type CrmCopies, type CrmRelationIssue, type CrmSaved, type CrmSkipped, crmIdentityId } from "./sqlite/crm.js";
42
+ export { COMPANY_TYPE_MEANINGS, type CompanyTypeMeaning, CRM_LINK_MODES, type CrmLinkMode, crmSettingKey, } from "./sqlite/crm-settings.js";
42
43
  export type { Deal, DealFilter, DealInput, DealPerson, DealScope, DealsStore, FunnelStage, Pipeline, PipelineInput, PipelineReport, PipelineStage, } from "./sqlite/deals.js";
43
44
  export type { DecisionMessage, DecisionPress, DecisionRefusal, DecisionRequest, DecisionRequestInput, DecisionRequestStore, TakeResult, } from "./sqlite/decision-requests.js";
44
45
  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";
@@ -64,7 +65,11 @@ export type { Order, OrderFilter, OrderInput, OrdersStore } from "./sqlite/order
64
65
  export type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
65
66
  export { assertGenericAction, PROPOSAL_STATUSES, type ProposalInput, type ProposedAction, type ProposedActionsStore, proposerOfAction, } from "./sqlite/proposed-actions.js";
66
67
  export type { RecordKey, RecordOutcome, RecordStore, RecordsWritten, SourceRecord, } from "./sqlite/records.js";
68
+ export type { RelationFilter, RelationList, RelationListItem } from "./sqlite/relation-list.js";
67
69
  export type { LinkDecision, RelationUpdate } from "./sqlite/relation-proposals.js";
70
+ export type { RelationReads } from "./sqlite/relation-reads.js";
71
+ export type { RelationRole, RelationRoles } from "./sqlite/relation-roles.js";
72
+ export type { RelationsStore, ReportedIssue, ReportedRelation, ReportedScope, ReportedSync, } from "./sqlite/reported-relations.js";
68
73
  export { fillSearchIndex, resetSearchIndex, type SearchIndexFill, type SearchIndexState, searchIndexState, } from "./sqlite/search-index.js";
69
74
  export type { SyncStateSave } from "./sqlite/sync.js";
70
75
  export type { TagCreationOptions, TagCreationReview } from "./sqlite/tag-creation.js";
@@ -25,6 +25,7 @@ export { resetAttachmentWords } from "./sqlite/attachment-texts.js";
25
25
  export { backfillNormalized, pendingNormalization } from "./sqlite/backfill.js";
26
26
  export { CATALOG_QUERY } from "./sqlite/catalog.js";
27
27
  export { crmIdentityId } from "./sqlite/crm.js";
28
+ export { COMPANY_TYPE_MEANINGS, CRM_LINK_MODES, crmSettingKey, } from "./sqlite/crm-settings.js";
28
29
  export { EVENT_FIELDS, } from "./sqlite/event-search.js";
29
30
  export { IMPORTED_DOCUMENT_QUERY } from "./sqlite/imported-documents.js";
30
31
  export { ORGANIZATION_KINDS, PROJECT_TYPES, SCOPES } from "./sqlite/knowledge.js";
@@ -22,7 +22,7 @@ export declare const projectAnnotationRequest: (request: ProjectAnnotationTarget
22
22
  ref: string;
23
23
  from: string;
24
24
  to: string | null;
25
- kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "related-to";
25
+ kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "customer-of" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "partner-of" | "related-to" | "reports-to";
26
26
  origin: "file" | "message" | "owner" | "suggested";
27
27
  anchor: string | null;
28
28
  target_text: string | null;
@@ -33,6 +33,9 @@ export declare const projectAnnotationRequest: (request: ProjectAnnotationTarget
33
33
  created_at: number;
34
34
  updated_at: number;
35
35
  author: string | null;
36
+ starts_at?: number | undefined;
37
+ ends_at?: number | undefined;
38
+ deleted_at?: number | undefined;
36
39
  }[];
37
40
  external: {
38
41
  ref: string;
@@ -56,7 +56,7 @@ export declare const projectAnnotationsSchema: v.StrictObjectSchema<{
56
56
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;
57
57
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;
58
58
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
59
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
59
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
60
60
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message"], undefined>;
61
61
  readonly anchor: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
62
62
  readonly target_text: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
@@ -67,11 +67,15 @@ export declare const projectAnnotationsSchema: v.StrictObjectSchema<{
67
67
  readonly created_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
68
68
  readonly updated_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
69
69
  readonly author: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
70
+ /** When a relationship held, if known; left out otherwise, so an older reader still reads the snapshot. */
71
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
72
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
73
+ readonly deleted_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
70
74
  }, undefined>, undefined>, v.MaxLengthAction<{
71
75
  ref: string;
72
76
  from: string;
73
77
  to: string | null;
74
- kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "related-to";
78
+ kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "customer-of" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "partner-of" | "related-to" | "reports-to";
75
79
  origin: "file" | "message" | "owner" | "suggested";
76
80
  anchor: string | null;
77
81
  target_text: string | null;
@@ -82,6 +86,9 @@ export declare const projectAnnotationsSchema: v.StrictObjectSchema<{
82
86
  created_at: number;
83
87
  updated_at: number;
84
88
  author: string | null;
89
+ starts_at?: number | undefined;
90
+ ends_at?: number | undefined;
91
+ deleted_at?: number | undefined;
85
92
  }[], 1000, undefined>]>;
86
93
  readonly external: v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
87
94
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;
@@ -60,6 +60,10 @@ export const projectAnnotationsSchema = v.strictObject({
60
60
  created_at: timestamp,
61
61
  updated_at: timestamp,
62
62
  author: v.nullable(text(200)),
63
+ /** When a relationship held, if known; left out otherwise, so an older reader still reads the snapshot. */
64
+ starts_at: v.optional(timestamp),
65
+ ends_at: v.optional(timestamp),
66
+ deleted_at: v.optional(timestamp),
63
67
  })),
64
68
  external: bounded(v.strictObject({
65
69
  ref,
@@ -37,7 +37,7 @@ export declare const projectAnnotationSnapshotSchema: v.StrictObjectSchema<{
37
37
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;
38
38
  readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;
39
39
  readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
40
- readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
40
+ readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
41
41
  readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message"], undefined>;
42
42
  readonly anchor: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
43
43
  readonly target_text: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
@@ -48,11 +48,14 @@ export declare const projectAnnotationSnapshotSchema: v.StrictObjectSchema<{
48
48
  readonly created_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
49
49
  readonly updated_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
50
50
  readonly author: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>, undefined>;
51
+ readonly starts_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
52
+ readonly ends_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
53
+ readonly deleted_at: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
51
54
  }, undefined>, undefined>, v.MaxLengthAction<{
52
55
  ref: string;
53
56
  from: string;
54
57
  to: string | null;
55
- kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "related-to";
58
+ kind: "about" | "answered-by" | "assigned-to" | "attached" | "blocked-by" | "created-from" | "customer-of" | "duplicate-of" | "evidence" | "follow-up-of" | "labelled" | "links-to" | "member-of" | "partner-of" | "related-to" | "reports-to";
56
59
  origin: "file" | "message" | "owner" | "suggested";
57
60
  anchor: string | null;
58
61
  target_text: string | null;
@@ -63,6 +66,9 @@ export declare const projectAnnotationSnapshotSchema: v.StrictObjectSchema<{
63
66
  created_at: number;
64
67
  updated_at: number;
65
68
  author: string | null;
69
+ starts_at?: number | undefined;
70
+ ends_at?: number | undefined;
71
+ deleted_at?: number | undefined;
66
72
  }[], 1000, undefined>]>;
67
73
  readonly external: v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
68
74
  readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, number, undefined>]>;