@wirecat/cli-core 1.0.0 → 1.2.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 (111) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/THIRD_PARTY_NOTICES +43 -0
  3. package/dist/background/daily-archive-timer.d.ts +1 -1
  4. package/dist/cli/account-remove.d.ts +3 -0
  5. package/dist/cli/account-remove.js +1 -1
  6. package/dist/cli/documents/index.d.ts +2 -1
  7. package/dist/cli/documents/index.js +4 -1
  8. package/dist/cli/documents/words.d.ts +1 -1
  9. package/dist/cli/domain-lists-command.d.ts +16 -0
  10. package/dist/cli/domain-lists-command.js +88 -0
  11. package/dist/cli/index.d.ts +4 -3
  12. package/dist/cli/index.js +4 -3
  13. package/dist/cli/messenger/conversation-answers.d.ts +2 -0
  14. package/dist/cli/messenger/message-answers.d.ts +2 -0
  15. package/dist/cli/messenger/message-items.js +2 -0
  16. package/dist/cli/messenger/message-writes.d.ts +4 -0
  17. package/dist/cli/messenger/search-answers.js +2 -0
  18. package/dist/cli/model-catalogue-command.d.ts +6 -0
  19. package/dist/cli/model-catalogue-command.js +1 -1
  20. package/dist/cli/oauth-session.d.ts +38 -4
  21. package/dist/cli/oauth-session.js +72 -25
  22. package/dist/cli/shared-command-exports.d.ts +4 -0
  23. package/dist/cli/shared-command-exports.js +6 -0
  24. package/dist/cli/token-session.d.ts +9 -3
  25. package/dist/cli/token-session.js +34 -3
  26. package/dist/domain/domain-lists.d.ts +86 -0
  27. package/dist/domain/domain-lists.js +110 -0
  28. package/dist/domain/free-mail-domains.generated.d.ts +1 -0
  29. package/dist/domain/free-mail-domains.generated.js +4 -0
  30. package/dist/domain/models.d.ts +5 -0
  31. package/dist/domain/organization-sectors.d.ts +9 -3
  32. package/dist/domain/organization-sectors.generated.d.ts +1 -0
  33. package/dist/domain/organization-sectors.generated.js +1 -0
  34. package/dist/domain/organization-sectors.js +16 -3
  35. package/dist/domain/person-kinds.d.ts +6 -1
  36. package/dist/domain/person-kinds.js +5 -0
  37. package/dist/entities/contact-context.d.ts +4 -0
  38. package/dist/entities/conversation-results.d.ts +4 -0
  39. package/dist/entities/domain-list.d.ts +27 -0
  40. package/dist/entities/domain-list.js +28 -0
  41. package/dist/entities/evidence.d.ts +16 -0
  42. package/dist/entities/index.d.ts +56 -2
  43. package/dist/entities/index.js +3 -1
  44. package/dist/entities/knowledge-lists.d.ts +1 -1
  45. package/dist/entities/listener.d.ts +8 -0
  46. package/dist/entities/message-change.d.ts +2 -0
  47. package/dist/entities/message-context.d.ts +6 -0
  48. package/dist/entities/message-write.d.ts +8 -0
  49. package/dist/entities/message.d.ts +4 -0
  50. package/dist/entities/message.js +4 -0
  51. package/dist/entities/store-records.d.ts +2 -0
  52. package/dist/errors/reasons.js +20 -2
  53. package/dist/mail/cli/index.js +1 -1
  54. package/dist/mail/headers.d.ts +2 -0
  55. package/dist/mail/headers.js +2 -1
  56. package/dist/mail/mail-types.d.ts +48 -0
  57. package/dist/mail/mail-types.js +218 -0
  58. package/dist/mail/read.js +1 -0
  59. package/dist/mail/sort-rules.d.ts +58 -0
  60. package/dist/mail/sort-rules.js +79 -0
  61. package/dist/oauth/index.d.ts +1 -1
  62. package/dist/oauth/storage.d.ts +10 -2
  63. package/dist/oauth/storage.js +23 -9
  64. package/dist/search/lucene/registry.js +24 -0
  65. package/dist/services/domain-lists-download.d.ts +26 -0
  66. package/dist/services/domain-lists-download.js +155 -0
  67. package/dist/services/messages-search.js +1 -1
  68. package/dist/services/metadata.d.ts +1 -1
  69. package/dist/store/areas.d.ts +3 -1
  70. package/dist/store/areas.js +2 -0
  71. package/dist/store/index.d.ts +2 -2
  72. package/dist/store/index.js +1 -1
  73. package/dist/store/people.d.ts +18 -9
  74. package/dist/store/people.js +8 -7
  75. package/dist/store/public.d.ts +1 -1
  76. package/dist/store/public.js +1 -1
  77. package/dist/store/queries.js +9 -2
  78. package/dist/store/sqlite/accounts.js +3 -1
  79. package/dist/store/sqlite/domain-organizations.d.ts +7 -4
  80. package/dist/store/sqlite/domain-organizations.js +94 -36
  81. package/dist/store/sqlite/email-types.d.ts +87 -0
  82. package/dist/store/sqlite/email-types.js +296 -0
  83. package/dist/store/sqlite/emails.d.ts +14 -2
  84. package/dist/store/sqlite/emails.js +32 -12
  85. package/dist/store/sqlite/identities.d.ts +4 -1
  86. package/dist/store/sqlite/identities.js +11 -2
  87. package/dist/store/sqlite/identity-rekey.js +2 -0
  88. package/dist/store/sqlite/lucene-fields.d.ts +6 -0
  89. package/dist/store/sqlite/lucene-fields.js +10 -0
  90. package/dist/store/sqlite/lucene.js +6 -0
  91. package/dist/store/sqlite/mail-sorting.d.ts +122 -0
  92. package/dist/store/sqlite/mail-sorting.js +482 -0
  93. package/dist/store/sqlite/manifest.js +6 -0
  94. package/dist/store/sqlite/merged-persons.d.ts +3 -2
  95. package/dist/store/sqlite/merged-persons.js +5 -3
  96. package/dist/store/sqlite/migrations.generated.js +76 -0
  97. package/dist/store/sqlite/people-list.d.ts +1 -6
  98. package/dist/store/sqlite/people-list.js +97 -42
  99. package/dist/store/sqlite/person-links.js +13 -3
  100. package/dist/store/sqlite/person-match-scan.js +5 -2
  101. package/dist/store/sqlite/schema/mail-sorting.d.ts +384 -0
  102. package/dist/store/sqlite/schema/mail-sorting.js +31 -0
  103. package/dist/store/sqlite/schema/sender-bots.d.ts +56 -0
  104. package/dist/store/sqlite/schema/sender-bots.js +9 -1
  105. package/dist/store/sqlite/schema.d.ts +66 -1
  106. package/dist/store/sqlite/schema.js +9 -1
  107. package/dist/store/sqlite/sender-bots.d.ts +89 -15
  108. package/dist/store/sqlite/sender-bots.js +417 -136
  109. package/dist/store/sqlite/sender-signals.d.ts +11 -4
  110. package/dist/store/sqlite/sender-signals.js +14 -10
  111. package/package.json +2 -2
@@ -1,41 +1,115 @@
1
1
  import type { CacheDatabase } from "../driver.js";
2
2
  import type { IdentityRef, PersonRecord } from "../types.js";
3
3
  import type { StoreContext } from "./open.js";
4
- export declare const SENDER_BOT_PREFIX = "sender-bot:";
4
+ import { type Reach, type SenderSignal } from "./sender-signals.js";
5
5
  export type BotAuthor = "rules" | "owner";
6
- /** A sender bot as the people list reads it, keyed by the person row whose identities are the bot's. */
7
- export interface HeldBot {
8
- id: number;
9
- author: BotAuthor;
6
+ /** @experimental */
7
+ export interface BotIdentity {
8
+ provider: string;
9
+ id: string;
10
10
  name: string | null;
11
+ username: string | null;
11
12
  }
13
+ /** A program that writes to the owner, apart from people: it has no ties, no tasks and no merge review. @experimental */
12
14
  export interface SenderBot {
15
+ /** `sender-bot:<id>`. */
13
16
  bot: string;
14
- /** The person row whose identities are the bot's: its handle in `people list` and `people show`. */
15
- person: string;
17
+ /** The owner's name for it; `displayName` falls back to its identities'. */
16
18
  name: string | null;
19
+ displayName: string | null;
20
+ /** The organization it sends for (`organization:<id>`), from its mail domain or the owner. */
21
+ organization: string | null;
22
+ /** `owner` when the owner moved it: no rule gives it back to a person. */
23
+ author: BotAuthor;
24
+ /** The kind signals that sorted it, or the owner's words. */
25
+ reason: string | null;
26
+ identities: BotIdentity[];
27
+ /** Messages and mail it sent, every account together. */
28
+ messagesFrom: number;
29
+ lastContact: string | null;
30
+ reach: Reach | null;
31
+ signals: SenderSignal[];
32
+ }
33
+ /** One move of an identity between a person and a bot. @experimental */
34
+ export interface BotMove {
35
+ identity: IdentityRef;
36
+ /** `person:<uid>` or `sender-bot:<id>`; `null` for none. */
37
+ from: string | null;
38
+ to: string | null;
17
39
  author: BotAuthor;
18
40
  reason: string | null;
41
+ at: string;
19
42
  }
20
- export declare const senderBotsOf: (database: CacheDatabase) => Map<number, HeldBot>;
43
+ /** @experimental */
44
+ export interface SenderBotDetails extends SenderBot {
45
+ /** Every move to or from this bot, oldest first. */
46
+ moves: BotMove[];
47
+ }
48
+ /** @experimental */
49
+ export interface BotListOptions {
50
+ /** Part of a name, address or username, at least 3 characters. */
51
+ query?: string;
52
+ /** `organization:<id>`: the bots that send for it. */
53
+ organization?: string;
54
+ limit: number;
55
+ offset?: number;
56
+ }
57
+ /** @experimental */
58
+ export interface BotList {
59
+ items: SenderBot[];
60
+ hasMore: boolean;
61
+ total: number;
62
+ }
63
+ /**
64
+ * The source re-keyed `from` onto `to`, both stored: a bot holding `from` takes `to` from its person, since one
65
+ * account is one program. The person it leaves is hidden as `intoBot` hides one. The caller holds the write lock.
66
+ */
67
+ export declare const rekeyIntoBot: (database: CacheDatabase, from: number, to: number, at: number) => void;
21
68
  /** People holding an identity the owner last moved to a person, or kept as one: no rule makes them a bot. */
22
69
  export declare const ownerPeopleOf: (database: CacheDatabase) => Set<number>;
70
+ /** A person every identity left for a bot is no one's assignee: the bot has no tasks. */
23
71
  export declare const refuseBotAssignee: (database: CacheDatabase, person: number) => void;
24
- /** A rule's move of a whole person to a bot, or of a rule's bot back to a person; the caller holds the write lock. */
25
- export declare const ruleMove: (database: CacheDatabase, person: number, to: "bot" | "person", reason: string, at: number) => void;
72
+ /** A rule's move of a whole person to a new bot; answers the bot. The caller holds the write lock. */
73
+ export declare const ruleToBot: (database: CacheDatabase, person: number, reason: string, at: number) => number;
74
+ /** The reason of a bot that only sent a newsletter: a mail written to the owner alone gives it back to a person. */
75
+ export declare const NEWSLETTER_ONLY = "newsletter-only";
76
+ /**
77
+ * A rule's bot the owner wrote to, or a newsletter's that wrote to the owner alone, by mail or in a private chat both wrote in, goes back to the people its identities
78
+ * came from; a messenger's own bot flag holds anyway. The caller holds the write lock.
79
+ */
80
+ export declare const ruleBotsBack: (database: CacheDatabase, at: number) => void;
81
+ /**
82
+ * Mail a newsletter's bot sent since the last check: no trigger makes a kind stale for it, so a 1-to-1 mail would wait
83
+ * for someone else's change to give the bot back. Answers the newest email id to check up to, or `undefined`.
84
+ */
85
+ export declare const newsletterBotsMail: (database: CacheDatabase) => number | undefined;
86
+ /** Gives back the newsletter bots a 1-to-1 mail came from, and keeps how far the mail was checked. */
87
+ export declare const settleNewsletterBots: (database: CacheDatabase, newest: number, at: number) => void;
88
+ /** Whether a build before version 75 sorted a bot onto a person row since the last kept list. */
89
+ export declare const hasLegacyBots: (database: CacheDatabase) => boolean;
90
+ /**
91
+ * A bot a build before version 75 sorted after the upgrade holds its person row's identities there: they move to the
92
+ * bot, as the upgrade moved the others. The caller holds the write lock.
93
+ */
94
+ export declare const settleLegacyBots: (database: CacheDatabase, at: number) => void;
95
+ /** The sender bots, by name; a bot a build before version 75 sorted shows once a list has settled it. */
96
+ export declare const listBots: (database: CacheDatabase, options: BotListOptions) => BotList;
97
+ /** One sender bot with its identities and every move to or from it. */
98
+ export declare const showBot: (database: CacheDatabase, ref: string) => SenderBotDetails;
26
99
  /**
27
- * The owner's word that a person, or one of their identities, is a program, for its whole history: its messages stay
28
- * where they are, and no rule moves it back. `bot` joins it to a bot already stored; one identity of a person with
29
- * others gets a person row of its own first.
100
+ * The owner's word that a person, a bot or one identity is a program, for its whole history: its messages stay where
101
+ * they are, and no rule gives it back. `bot` joins it to a stored bot; else a bot that already holds it keeps it, or a
102
+ * new one takes it. A person every identity left is hidden, and a move back gives their uid back.
30
103
  */
31
104
  export declare const moveToBot: (context: StoreContext, subject: string | IdentityRef, options?: {
32
105
  bot?: string;
33
106
  name?: string;
34
107
  reason?: string;
35
- }) => SenderBot;
108
+ }) => SenderBotDetails;
36
109
  /**
37
110
  * The owner's word that a bot, a person or one identity is a person, for its whole history; no rule makes it a bot
38
- * again. `person` joins it to that person; one identity of a bot with others gets a person row of its own.
111
+ * again. `person` takes it; else each identity goes back to the person it came from, or a person of its own. Said of a
112
+ * person, it keeps them one. Answers the person the first identity is on.
39
113
  */
40
114
  export declare const moveToPerson: (context: StoreContext, subject: string | IdentityRef, options?: {
41
115
  person?: string;