@wirecat/cli-core 1.1.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.
- package/CHANGELOG.md +55 -0
- package/dist/cli/account-remove.d.ts +3 -0
- package/dist/cli/account-remove.js +1 -1
- package/dist/cli/documents/index.d.ts +2 -1
- package/dist/cli/documents/index.js +4 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +2 -2
- package/dist/cli/messenger/conversation-answers.d.ts +2 -0
- package/dist/cli/messenger/message-answers.d.ts +2 -0
- package/dist/cli/messenger/message-items.js +2 -0
- package/dist/cli/messenger/message-writes.d.ts +4 -0
- package/dist/cli/messenger/search-answers.js +2 -0
- package/dist/cli/oauth-session.js +6 -3
- package/dist/cli/shared-command-exports.d.ts +2 -0
- package/dist/cli/shared-command-exports.js +3 -0
- package/dist/cli/token-session.d.ts +1 -4
- package/dist/cli/token-session.js +5 -1
- package/dist/domain/models.d.ts +5 -0
- package/dist/domain/person-kinds.d.ts +1 -1
- package/dist/entities/contact-context.d.ts +4 -0
- package/dist/entities/conversation-results.d.ts +4 -0
- package/dist/entities/evidence.d.ts +16 -0
- package/dist/entities/index.d.ts +36 -0
- package/dist/entities/listener.d.ts +8 -0
- package/dist/entities/message-change.d.ts +2 -0
- package/dist/entities/message-context.d.ts +6 -0
- package/dist/entities/message-write.d.ts +8 -0
- package/dist/entities/message.d.ts +4 -0
- package/dist/entities/message.js +4 -0
- package/dist/entities/store-records.d.ts +2 -0
- package/dist/errors/reasons.js +16 -0
- package/dist/mail/cli/index.js +1 -1
- package/dist/mail/headers.d.ts +2 -0
- package/dist/mail/headers.js +2 -1
- package/dist/mail/read.js +1 -0
- package/dist/mail/sort-rules.d.ts +58 -0
- package/dist/mail/sort-rules.js +79 -0
- package/dist/search/lucene/registry.js +24 -0
- package/dist/services/messages-search.js +1 -1
- package/dist/store/areas.d.ts +2 -0
- package/dist/store/areas.js +2 -0
- package/dist/store/public.d.ts +1 -1
- package/dist/store/public.js +1 -1
- package/dist/store/queries.js +9 -2
- package/dist/store/sqlite/email-types.d.ts +8 -0
- package/dist/store/sqlite/email-types.js +45 -10
- package/dist/store/sqlite/emails.d.ts +3 -0
- package/dist/store/sqlite/emails.js +14 -5
- package/dist/store/sqlite/lucene-fields.d.ts +6 -0
- package/dist/store/sqlite/lucene-fields.js +10 -0
- package/dist/store/sqlite/lucene.js +6 -0
- package/dist/store/sqlite/mail-sorting.d.ts +122 -0
- package/dist/store/sqlite/mail-sorting.js +482 -0
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +20 -0
- package/dist/store/sqlite/people-list.js +65 -16
- package/dist/store/sqlite/schema/mail-sorting.d.ts +384 -0
- package/dist/store/sqlite/schema/mail-sorting.js +31 -0
- package/dist/store/sqlite/schema.d.ts +17 -0
- package/dist/store/sqlite/schema.js +3 -0
- package/dist/store/sqlite/sender-bots.d.ts +10 -1
- package/dist/store/sqlite/sender-bots.js +47 -8
- package/package.json +2 -2
package/dist/entities/index.d.ts
CHANGED
|
@@ -651,6 +651,8 @@ export declare const ENTITIES: {
|
|
|
651
651
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
652
652
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
653
653
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
654
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
655
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
654
656
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
655
657
|
readonly score: v.NumberSchema<undefined>;
|
|
656
658
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -878,6 +880,8 @@ export declare const ENTITIES: {
|
|
|
878
880
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
879
881
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
880
882
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
883
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
884
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
881
885
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
882
886
|
readonly score: v.NumberSchema<undefined>;
|
|
883
887
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1110,6 +1114,8 @@ export declare const ENTITIES: {
|
|
|
1110
1114
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1111
1115
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1112
1116
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1117
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1118
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1113
1119
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1114
1120
|
readonly score: v.NumberSchema<undefined>;
|
|
1115
1121
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1481,6 +1487,8 @@ export declare const ENTITIES: {
|
|
|
1481
1487
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1482
1488
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1483
1489
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1490
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1491
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1484
1492
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1485
1493
|
readonly score: v.NumberSchema<undefined>;
|
|
1486
1494
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1732,6 +1740,8 @@ export declare const ENTITIES: {
|
|
|
1732
1740
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1733
1741
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1734
1742
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1743
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1744
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1735
1745
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1736
1746
|
readonly score: v.NumberSchema<undefined>;
|
|
1737
1747
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1959,6 +1969,8 @@ export declare const ENTITIES: {
|
|
|
1959
1969
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1960
1970
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1961
1971
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1972
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1973
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1962
1974
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1963
1975
|
readonly score: v.NumberSchema<undefined>;
|
|
1964
1976
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -2190,6 +2202,8 @@ export declare const ENTITIES: {
|
|
|
2190
2202
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
2191
2203
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
2192
2204
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
2205
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
2206
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
2193
2207
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
2194
2208
|
readonly score: v.NumberSchema<undefined>;
|
|
2195
2209
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -2417,6 +2431,8 @@ export declare const ENTITIES: {
|
|
|
2417
2431
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
2418
2432
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
2419
2433
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
2434
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
2435
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
2420
2436
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
2421
2437
|
readonly score: v.NumberSchema<undefined>;
|
|
2422
2438
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -3166,6 +3182,8 @@ export declare const ENTITIES: {
|
|
|
3166
3182
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
3167
3183
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
3168
3184
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
3185
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
3186
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
3169
3187
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
3170
3188
|
readonly score: v.NumberSchema<undefined>;
|
|
3171
3189
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -7348,6 +7366,8 @@ export declare const ENTITIES: {
|
|
|
7348
7366
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
7349
7367
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
7350
7368
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
7369
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
7370
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
7351
7371
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
7352
7372
|
readonly score: v.NumberSchema<undefined>;
|
|
7353
7373
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -7575,6 +7595,8 @@ export declare const ENTITIES: {
|
|
|
7575
7595
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
7576
7596
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
7577
7597
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
7598
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
7599
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
7578
7600
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
7579
7601
|
readonly score: v.NumberSchema<undefined>;
|
|
7580
7602
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -8047,6 +8069,8 @@ export declare const ENTITIES: {
|
|
|
8047
8069
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
8048
8070
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8049
8071
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8072
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8073
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8050
8074
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
8051
8075
|
readonly score: v.NumberSchema<undefined>;
|
|
8052
8076
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -8565,6 +8589,8 @@ export declare const ENTITIES: {
|
|
|
8565
8589
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
8566
8590
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8567
8591
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8592
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8593
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8568
8594
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
8569
8595
|
readonly score: v.NumberSchema<undefined>;
|
|
8570
8596
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -9273,6 +9299,8 @@ export declare const ENTITIES: {
|
|
|
9273
9299
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
9274
9300
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
9275
9301
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
9302
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
9303
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
9276
9304
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
9277
9305
|
readonly score: v.NumberSchema<undefined>;
|
|
9278
9306
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -11068,6 +11096,8 @@ export declare const ENTITIES: {
|
|
|
11068
11096
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
11069
11097
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11070
11098
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11099
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11100
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11071
11101
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
11072
11102
|
readonly score: v.NumberSchema<undefined>;
|
|
11073
11103
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -11295,6 +11325,8 @@ export declare const ENTITIES: {
|
|
|
11295
11325
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
11296
11326
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11297
11327
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11328
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11329
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11298
11330
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
11299
11331
|
readonly score: v.NumberSchema<undefined>;
|
|
11300
11332
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -11560,6 +11592,8 @@ export declare const ENTITIES: {
|
|
|
11560
11592
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
11561
11593
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11562
11594
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11595
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11596
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11563
11597
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
11564
11598
|
readonly score: v.NumberSchema<undefined>;
|
|
11565
11599
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -11787,6 +11821,8 @@ export declare const ENTITIES: {
|
|
|
11787
11821
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
11788
11822
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11789
11823
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
11824
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11825
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
11790
11826
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
11791
11827
|
readonly score: v.NumberSchema<undefined>;
|
|
11792
11828
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -208,6 +208,8 @@ export declare const watchedMessage: v.StrictObjectSchema<{
|
|
|
208
208
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
209
209
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
210
210
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
211
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
212
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
211
213
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
212
214
|
readonly score: v.NumberSchema<undefined>;
|
|
213
215
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -727,6 +729,8 @@ export declare const messageEvent: v.VariantSchema<"event", [v.StrictObjectSchem
|
|
|
727
729
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
728
730
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
729
731
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
732
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
733
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
730
734
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
731
735
|
readonly score: v.NumberSchema<undefined>;
|
|
732
736
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1353,6 +1357,8 @@ export declare const watchItem: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1353
1357
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1354
1358
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1355
1359
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1360
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1361
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1356
1362
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1357
1363
|
readonly score: v.NumberSchema<undefined>;
|
|
1358
1364
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1871,6 +1877,8 @@ export declare const watchItem: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1871
1877
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
1872
1878
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1873
1879
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1880
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1881
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1874
1882
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1875
1883
|
readonly score: v.NumberSchema<undefined>;
|
|
1876
1884
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -236,6 +236,8 @@ declare const scheduledSendEntries: {
|
|
|
236
236
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
237
237
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
238
238
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
239
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
240
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
239
241
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
240
242
|
readonly score: v.NumberSchema<undefined>;
|
|
241
243
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -214,6 +214,8 @@ export declare const messageThread: v.StrictObjectSchema<{
|
|
|
214
214
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
215
215
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
216
216
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
217
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
218
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
217
219
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
218
220
|
readonly score: v.NumberSchema<undefined>;
|
|
219
221
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -465,6 +467,8 @@ export declare const messageContext: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
465
467
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
466
468
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
467
469
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
470
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
471
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
468
472
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
469
473
|
readonly score: v.NumberSchema<undefined>;
|
|
470
474
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -697,6 +701,8 @@ export declare const messageContext: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
697
701
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
698
702
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
699
703
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
704
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
705
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
700
706
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
701
707
|
readonly score: v.NumberSchema<undefined>;
|
|
702
708
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -210,6 +210,8 @@ export declare const messageWrite: v.StrictObjectSchema<{
|
|
|
210
210
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
211
211
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
212
212
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
213
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
214
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
213
215
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
214
216
|
readonly score: v.NumberSchema<undefined>;
|
|
215
217
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -438,6 +440,8 @@ export declare const messageWrite: v.StrictObjectSchema<{
|
|
|
438
440
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
439
441
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
440
442
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
443
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
444
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
441
445
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
442
446
|
readonly score: v.NumberSchema<undefined>;
|
|
443
447
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -674,6 +678,8 @@ export declare const messageSend: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
674
678
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
675
679
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
676
680
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
681
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
682
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
677
683
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
678
684
|
readonly score: v.NumberSchema<undefined>;
|
|
679
685
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -902,6 +908,8 @@ export declare const messageSend: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
902
908
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
903
909
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
904
910
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
911
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
912
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
905
913
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
906
914
|
readonly score: v.NumberSchema<undefined>;
|
|
907
915
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -232,6 +232,10 @@ export declare const message: v.StrictObjectSchema<{
|
|
|
232
232
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
233
233
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
234
234
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
235
|
+
/** What the email is, apart from its sender: one of the mail types. @experimental */
|
|
236
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
237
|
+
/** How it reached the owner: direct, group or broadcast. @experimental */
|
|
238
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
235
239
|
/** How much the sender's mail looks like spam, a scam or a robot (memo's score), and why; absent when unscored. */
|
|
236
240
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
237
241
|
readonly score: v.NumberSchema<undefined>;
|
package/dist/entities/message.js
CHANGED
|
@@ -101,6 +101,10 @@ export const message = v.strictObject({
|
|
|
101
101
|
thread: reference,
|
|
102
102
|
read: v.nullable(v.boolean()),
|
|
103
103
|
flagged: v.nullable(v.boolean()),
|
|
104
|
+
/** What the email is, apart from its sender: one of the mail types. @experimental */
|
|
105
|
+
mail_type: v.optional(text),
|
|
106
|
+
/** How it reached the owner: direct, group or broadcast. @experimental */
|
|
107
|
+
reach: v.optional(text),
|
|
104
108
|
/** How much the sender's mail looks like spam, a scam or a robot (memo's score), and why; absent when unscored. */
|
|
105
109
|
sender_score: v.optional(v.strictObject({ score: v.number(), signals: v.array(text), demoted: v.optional(v.literal(true)) })),
|
|
106
110
|
/** Mail `review`: filed in the mailbox of mail sent to many. */
|
|
@@ -241,6 +241,8 @@ export declare const storeExport: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
241
241
|
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
242
242
|
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
243
243
|
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
244
|
+
readonly mail_type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
245
|
+
readonly reach: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
244
246
|
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
245
247
|
readonly score: v.NumberSchema<undefined>;
|
|
246
248
|
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
package/dist/errors/reasons.js
CHANGED
|
@@ -668,6 +668,22 @@ const OTHERS = [
|
|
|
668
668
|
validation("sender-bot.not-a-person", "the identity named is a sender bot's, not a person's; name a person"),
|
|
669
669
|
validation("sender-bot.empty", "the person or bot named holds no identity to move"),
|
|
670
670
|
validation("sender-bot.assignee", "a sender bot is no one's assignee; move it to a person first"),
|
|
671
|
+
validation("mail-sort.scope", "a sorting rule's scope is mail, list, subject, address or domain"),
|
|
672
|
+
validation("mail-sort.apply-to", "a sorting rule says whether it sorts past mail too: applyTo all or new"),
|
|
673
|
+
validation("mail-sort.value", "the value names no mail, list, subject, address or domain of that scope"),
|
|
674
|
+
validation("mail-sort.mail-type", "the mail type is not one of the known types"),
|
|
675
|
+
validation("mail-sort.sender", "a sorting rule makes a sender a bot or a person"),
|
|
676
|
+
validation("mail-sort.no-action", "a sorting rule sets a mail type, a sender or an organization"),
|
|
677
|
+
validation("mail-sort.owner-only", "only the owner moves or files senders, undoes and resets; a program removes its own rules"),
|
|
678
|
+
validation("mail-sort.sender-scope", "a sorting rule moves or files a sender at address or domain scope only"),
|
|
679
|
+
validation("mail-sort.sender-new", "a sender moves with its whole history, so an address rule that moves one applies to all"),
|
|
680
|
+
validation("mail-sort.over-addresses", "only a domain rule can beat the address rules"),
|
|
681
|
+
validation("mail-sort.free-mail-program", "only the owner sets a sorting rule on a free-mail or throwaway domain"),
|
|
682
|
+
validation("mail-sort.organization", "the organization named is not in the store"),
|
|
683
|
+
validation("mail-sort.confirm", "a free-mail domain rule needs the confirm of a dry run whose counts still hold; run the dry run again"),
|
|
684
|
+
validation("mail-sort.sender-ref", "the sender is named by an address, a person: ref or a sender-bot: ref"),
|
|
685
|
+
["mail-sort.not-found", "not_found", "no mail sorting rule has that id; the rules list names them"],
|
|
686
|
+
["mail-sort.email", "not_found", "no incoming email has that id"],
|
|
671
687
|
validation("identity.shared-email", "more than six people share the address, so it proposes no one"),
|
|
672
688
|
validation("identity-link.dedicated-review", "an identity link is staged and decided through the people review"),
|
|
673
689
|
validation("identity-split.dedicated-review", "a split of a person is staged and decided through the people review"),
|
package/dist/mail/cli/index.js
CHANGED
|
@@ -123,7 +123,7 @@ const searchCommand = (mail) => {
|
|
|
123
123
|
.option("--timezone <zone>", "the IANA timezone for calendar date boundaries")
|
|
124
124
|
.addHelpText("after", `
|
|
125
125
|
Fields: from: to: cc: bcc: subject: body: mailbox: (or label:) list: (a List-Id or its domain) is:unread|read|starred
|
|
126
|
-
has:attachment, filename:, content: (the text of attachments), size>, date: — \`${mail.app.command} personal search messages 'content:invoice'\`.
|
|
126
|
+
type: (order, bill, promotion… — what the email is) reach:direct|group|broadcast has:attachment, filename:, content: (the text of attachments), size>, date: — \`${mail.app.command} personal search messages 'content:invoice'\`.
|
|
127
127
|
chat: names a thread by its subject. Mail sent to many is in the mailbox bulk; NOT mailbox:bulk leaves it out.
|
|
128
128
|
Mail from senders with signs of fraud comes after the rest of the page; --plain-order keeps it in place.
|
|
129
129
|
--json: the list is items; each hit's reference is ref (msg:email/…), which messages show reads.${mail.server
|
package/dist/mail/headers.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const authOf: (unfolded: string) => AuthVerdicts | undefined;
|
|
|
37
37
|
*/
|
|
38
38
|
export declare const signedFieldsOf: (unfolded: string, from: string | undefined) => Set<string>;
|
|
39
39
|
export declare const addressesOf: (value: string | undefined) => string[];
|
|
40
|
+
/** A List-Id as the store keeps it: the part inside angle brackets, lower case. */
|
|
41
|
+
export declare const listIdOf: (raw: string | undefined) => string | undefined;
|
|
40
42
|
/** The header fields of one email, from its header text. */
|
|
41
43
|
export declare const headersOf: (text: string) => MailHeaders;
|
|
42
44
|
/** The header fields of a whole email, as `headersOf` reads them from a listing. */
|
package/dist/mail/headers.js
CHANGED
|
@@ -95,7 +95,8 @@ const nameOf = (value) => {
|
|
|
95
95
|
const name = before?.replace(/^"(.*)"$/, "$1").trim();
|
|
96
96
|
return name ? decodeWords(name) : undefined;
|
|
97
97
|
};
|
|
98
|
-
|
|
98
|
+
/** A List-Id as the store keeps it: the part inside angle brackets, lower case. */
|
|
99
|
+
export const listIdOf = (raw) => raw === undefined ? undefined : (/<([^>]+)>/.exec(raw)?.[1] ?? raw).trim().toLowerCase() || undefined;
|
|
99
100
|
/** The header fields of one email, from its header text. */
|
|
100
101
|
export const headersOf = (text) => {
|
|
101
102
|
const unfolded = unfold(text);
|
package/dist/mail/read.js
CHANGED
|
@@ -90,6 +90,7 @@ export const hitText = (item, level, shown = (time) => time) => {
|
|
|
90
90
|
mail.to.length ? `to ${names(mail.to)}` : "",
|
|
91
91
|
mail.cc.length ? `cc ${names(mail.cc)}` : "",
|
|
92
92
|
mail.labels.join(", "),
|
|
93
|
+
[mail.mailType, mail.reach].filter(Boolean).join(", "),
|
|
93
94
|
]
|
|
94
95
|
.filter(Boolean)
|
|
95
96
|
.join(" · ")
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { MailType } from "./mail-types.js";
|
|
2
|
+
/** What a sorting rule names, most specific first. @experimental */
|
|
3
|
+
export declare const SORT_SCOPES: readonly ["mail", "list", "subject", "address", "domain"];
|
|
4
|
+
/** @experimental */
|
|
5
|
+
export type SortScope = (typeof SORT_SCOPES)[number];
|
|
6
|
+
/** @experimental */
|
|
7
|
+
export type SortAuthor = "owner" | "program";
|
|
8
|
+
/** One sorting rule as the matcher reads it. @experimental */
|
|
9
|
+
export interface SortRuleFacts {
|
|
10
|
+
id: number;
|
|
11
|
+
scope: SortScope;
|
|
12
|
+
value: string;
|
|
13
|
+
author: SortAuthor;
|
|
14
|
+
/** A domain rule that beats the address rules at its domain. */
|
|
15
|
+
overAddresses: boolean;
|
|
16
|
+
/** `false`: only mail dated from `createdAt` on. */
|
|
17
|
+
past: boolean;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
}
|
|
20
|
+
/** What a rule is matched against for one email. @experimental */
|
|
21
|
+
export interface SortedMail {
|
|
22
|
+
id: number;
|
|
23
|
+
/** Lower case. */
|
|
24
|
+
from: string | null;
|
|
25
|
+
subject: string | null;
|
|
26
|
+
/** As `listIdOf` keeps it. */
|
|
27
|
+
list: string | null;
|
|
28
|
+
/** The mail's own date, ms. */
|
|
29
|
+
at: number | null;
|
|
30
|
+
}
|
|
31
|
+
/** A subject pattern: any case, and any number stands for any other, so "Order 4411" matches "order 9". */
|
|
32
|
+
export declare const subjectKeyOf: (text: string) => string;
|
|
33
|
+
/** Rules filed by what they name, each list in the order a match takes them. @experimental */
|
|
34
|
+
export interface SortIndex<R extends SortRuleFacts> {
|
|
35
|
+
byKey: Map<string, R[]>;
|
|
36
|
+
subjects: R[];
|
|
37
|
+
size: number;
|
|
38
|
+
}
|
|
39
|
+
/** @experimental */
|
|
40
|
+
export declare const sortIndexOf: <R extends SortRuleFacts>(rules: readonly R[]) => SortIndex<R>;
|
|
41
|
+
/**
|
|
42
|
+
* The rule that decides this email, the first scope that has one: the mail, its List-Id or a subject pattern, its
|
|
43
|
+
* address, its domain. Within a scope the owner's rule beats the program's and the newest wins. A domain rule marked
|
|
44
|
+
* `overAddresses` beats the address rules. Addresses match whole and domains on a label boundary, so `ann@` never
|
|
45
|
+
* matches `joann@` and `shop.example` never matches `myshop.example`. @experimental
|
|
46
|
+
*/
|
|
47
|
+
export declare const sortRuleFor: <R extends SortRuleFacts>(index: SortIndex<R>, mail: SortedMail) => R | undefined;
|
|
48
|
+
/** Whether a scope is more specific than another. @experimental */
|
|
49
|
+
export declare const narrower: (a: SortScope, b: SortScope) => boolean;
|
|
50
|
+
/** What a rule of this scope keeps as its value, or `undefined` when the value names nothing. @experimental */
|
|
51
|
+
export declare const sortValueOf: (scope: SortScope, value: string | number) => string | undefined;
|
|
52
|
+
/** What a rule sets on mail and on its sender. @experimental */
|
|
53
|
+
export interface SortAction {
|
|
54
|
+
mailType?: MailType;
|
|
55
|
+
sender?: "bot" | "person";
|
|
56
|
+
/** `organization:<id>`. */
|
|
57
|
+
organization?: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { getDomain } from "tldts";
|
|
2
|
+
import { listIdOf } from "./headers.js";
|
|
3
|
+
/** What a sorting rule names, most specific first. @experimental */
|
|
4
|
+
export const SORT_SCOPES = ["mail", "list", "subject", "address", "domain"];
|
|
5
|
+
/** A List-Id and a subject pattern are one level: neither is more specific than the other. */
|
|
6
|
+
const LEVEL = { mail: 1, list: 2, subject: 2, address: 3, domain: 4 };
|
|
7
|
+
/** A subject pattern: any case, and any number stands for any other, so "Order 4411" matches "order 9". */
|
|
8
|
+
export const subjectKeyOf = (text) => text.toLowerCase().replace(/\d+/g, "0").replace(/\s+/g, " ").trim();
|
|
9
|
+
const hostOf = (address) => address.slice(address.lastIndexOf("@") + 1);
|
|
10
|
+
/** The registrable domains a host sits under, itself first: `a.mail.shop.example` → `mail.shop.example`, `shop.example`… */
|
|
11
|
+
const suffixesOf = (host) => {
|
|
12
|
+
const labels = host.split(".");
|
|
13
|
+
return labels.slice(0, -1).map((_, at) => labels.slice(at).join("."));
|
|
14
|
+
};
|
|
15
|
+
/** The owner's rule first, then the newest. */
|
|
16
|
+
const before = (a, b) => (a.author === "owner" ? 0 : 1) - (b.author === "owner" ? 0 : 1) || b.createdAt - a.createdAt || b.id - a.id;
|
|
17
|
+
const keyOf = (scope, value) => `${scope}\u0000${value}`;
|
|
18
|
+
/** @experimental */
|
|
19
|
+
export const sortIndexOf = (rules) => {
|
|
20
|
+
const byKey = new Map();
|
|
21
|
+
const subjects = [];
|
|
22
|
+
for (const rule of rules) {
|
|
23
|
+
if (rule.scope === "subject")
|
|
24
|
+
subjects.push(rule);
|
|
25
|
+
else
|
|
26
|
+
byKey.set(keyOf(rule.scope, rule.value), [...(byKey.get(keyOf(rule.scope, rule.value)) ?? []), rule]);
|
|
27
|
+
}
|
|
28
|
+
for (const list of byKey.values())
|
|
29
|
+
list.sort(before);
|
|
30
|
+
return { byKey, subjects: subjects.sort(before), size: rules.length };
|
|
31
|
+
};
|
|
32
|
+
const applies = (rule, mail) => rule.past || (mail.at !== null && mail.at >= rule.createdAt);
|
|
33
|
+
const first = (rules, mail) => rules.find((rule) => applies(rule, mail));
|
|
34
|
+
/**
|
|
35
|
+
* The rule that decides this email, the first scope that has one: the mail, its List-Id or a subject pattern, its
|
|
36
|
+
* address, its domain. Within a scope the owner's rule beats the program's and the newest wins. A domain rule marked
|
|
37
|
+
* `overAddresses` beats the address rules. Addresses match whole and domains on a label boundary, so `ann@` never
|
|
38
|
+
* matches `joann@` and `shop.example` never matches `myshop.example`. @experimental
|
|
39
|
+
*/
|
|
40
|
+
export const sortRuleFor = (index, mail) => {
|
|
41
|
+
if (index.size === 0)
|
|
42
|
+
return undefined;
|
|
43
|
+
const at = (scope, value) => value === null ? undefined : first(index.byKey.get(keyOf(scope, value)) ?? [], mail);
|
|
44
|
+
const own = at("mail", String(mail.id));
|
|
45
|
+
if (own !== undefined)
|
|
46
|
+
return own;
|
|
47
|
+
const subject = mail.subject === null ? undefined : subjectKeyOf(mail.subject);
|
|
48
|
+
const second = [
|
|
49
|
+
at("list", mail.list),
|
|
50
|
+
subject === undefined
|
|
51
|
+
? undefined
|
|
52
|
+
: first(index.subjects.filter((rule) => subject.includes(rule.value)), mail),
|
|
53
|
+
].filter((rule) => rule !== undefined);
|
|
54
|
+
if (second.length > 0)
|
|
55
|
+
return second.sort(before)[0];
|
|
56
|
+
if (mail.from === null || !mail.from.includes("@"))
|
|
57
|
+
return undefined;
|
|
58
|
+
const domain = suffixesOf(hostOf(mail.from))
|
|
59
|
+
.map((host) => at("domain", host))
|
|
60
|
+
.find((rule) => rule !== undefined);
|
|
61
|
+
if (domain?.overAddresses)
|
|
62
|
+
return domain;
|
|
63
|
+
return at("address", mail.from) ?? domain;
|
|
64
|
+
};
|
|
65
|
+
/** Whether a scope is more specific than another. @experimental */
|
|
66
|
+
export const narrower = (a, b) => LEVEL[a] < LEVEL[b];
|
|
67
|
+
/** What a rule of this scope keeps as its value, or `undefined` when the value names nothing. @experimental */
|
|
68
|
+
export const sortValueOf = (scope, value) => {
|
|
69
|
+
const text = String(value).trim();
|
|
70
|
+
if (scope === "mail")
|
|
71
|
+
return /^[1-9]\d*$/.test(text) ? text : undefined;
|
|
72
|
+
if (scope === "list")
|
|
73
|
+
return listIdOf(text);
|
|
74
|
+
if (scope === "subject")
|
|
75
|
+
return subjectKeyOf(text) || undefined;
|
|
76
|
+
if (scope === "address")
|
|
77
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(text) ? text.toLowerCase() : undefined;
|
|
78
|
+
return getDomain(text.replace(/^.*@/, "").toLowerCase()) ?? undefined;
|
|
79
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { queryAstSchema, validateQuery, walkQuery, } from "@wirecat/cli-base/query";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
import { tagOf } from "../../domain/tags.js";
|
|
4
|
+
import { MAIL_TYPES } from "../../mail/mail-types.js";
|
|
5
|
+
import { REACHES } from "../../store/sqlite/sender-signals.js";
|
|
4
6
|
import { MOST_WORDS_APART, QUERY_LIMITS, SEARCH_QUERY, searchError } from "./types.js";
|
|
5
7
|
export const FIELD_VERSION = 2;
|
|
6
8
|
const UNITS = {
|
|
@@ -149,6 +151,28 @@ export const QUERY_FIELDS = [
|
|
|
149
151
|
support: "A1",
|
|
150
152
|
values: ["unread", "read", "starred"],
|
|
151
153
|
},
|
|
154
|
+
{
|
|
155
|
+
name: "type",
|
|
156
|
+
example: "type:order OR type:bill",
|
|
157
|
+
index: "emails.mail_type (emails_by_mail_type)",
|
|
158
|
+
aliases: [],
|
|
159
|
+
type: "enum",
|
|
160
|
+
operators: terms,
|
|
161
|
+
normalization: "lowercase; what one email is, apart from its sender; mail not typed yet is typed before the search; mail only",
|
|
162
|
+
support: "A1",
|
|
163
|
+
values: MAIL_TYPES,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "reach",
|
|
167
|
+
example: "reach:direct",
|
|
168
|
+
index: "emails.reach",
|
|
169
|
+
aliases: [],
|
|
170
|
+
type: "enum",
|
|
171
|
+
operators: terms,
|
|
172
|
+
normalization: "lowercase; how one email reached the owner; mail only",
|
|
173
|
+
support: "A1",
|
|
174
|
+
values: REACHES,
|
|
175
|
+
},
|
|
152
176
|
{
|
|
153
177
|
name: "chat",
|
|
154
178
|
example: "chat:*fixture*",
|
|
@@ -15,7 +15,7 @@ import { mailAround, mergeMail, withMailThreads } from "./mail-search.js";
|
|
|
15
15
|
import { chatAmong, chatsMatchingIn, senderAmong, sendersMatching } from "./message-resolution.js";
|
|
16
16
|
import { accountsOfKind, listedAccounts, MAIL } from "./search-kind.js";
|
|
17
17
|
const PERSON_FIELDS = new Set(["from", "to", "cc", "bcc"]);
|
|
18
|
-
const MAIL_FIELDS = new Set(["to", "cc", "bcc", "subject", "mailbox", "label", "is", "list"]);
|
|
18
|
+
const MAIL_FIELDS = new Set(["to", "cc", "bcc", "subject", "mailbox", "label", "is", "list", "type", "reach"]);
|
|
19
19
|
import { parseLucene, timezoneOf, walkQuery, } from "@wirecat/cli-base/query";
|
|
20
20
|
import { MESSAGE_PARSING, searchError } from "../search/lucene/types.js";
|
|
21
21
|
import { rangeOf } from "../search/service-query.js";
|
package/dist/store/areas.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Store area types and constants some CLIs use beyond the stable `@wirecat/cli-core/store`: experimental, so a
|
|
3
3
|
* minor release may change them.
|
|
4
4
|
*/
|
|
5
|
+
export { MAIL_TYPES, type MailType } from "../mail/mail-types.js";
|
|
5
6
|
export { type AddedSource, type AddedSourceContent, type AddedSourceInput, addedSourceKeyOf, } from "./sqlite/added-sources.js";
|
|
6
7
|
export type { ContractFilter } from "./sqlite/business-contracts.js";
|
|
7
8
|
export type { CatalogEntry, CatalogInput, CatalogQuery } from "./sqlite/catalog.js";
|
|
@@ -31,6 +32,7 @@ export { PROPOSAL_STATUSES, type ProposedAction } from "./sqlite/proposed-action
|
|
|
31
32
|
export type { MatchRun, RecordKey } from "./sqlite/records.js";
|
|
32
33
|
export type { RelationListItem } from "./sqlite/relation-list.js";
|
|
33
34
|
export type { BotIdentity, BotList, BotListOptions, BotMove, SenderBot, SenderBotDetails, } from "./sqlite/sender-bots.js";
|
|
35
|
+
export { REACHES, type Reach } from "./sqlite/sender-signals.js";
|
|
34
36
|
export type { SubscriptionFilter } from "./sqlite/subscriptions.js";
|
|
35
37
|
export { PROJECT_TASK_FIELDS, TASK_SORTS, type TaskSort } from "./sqlite/task-board.js";
|
|
36
38
|
export { TASK_RELATION_KINDS, type TaskRelationKind } from "./sqlite/task-relations.js";
|
package/dist/store/areas.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Store area types and constants some CLIs use beyond the stable `@wirecat/cli-core/store`: experimental, so a
|
|
3
3
|
* minor release may change them.
|
|
4
4
|
*/
|
|
5
|
+
export { MAIL_TYPES } from "../mail/mail-types.js";
|
|
5
6
|
export { addedSourceKeyOf, } from "./sqlite/added-sources.js";
|
|
6
7
|
export { crmIdentityId } from "./sqlite/crm-rows.js";
|
|
7
8
|
export { crmSettingKey } from "./sqlite/crm-settings.js";
|
|
@@ -11,6 +12,7 @@ export { ORGANIZATION_KINDS, PROJECT_TYPES, SCOPES, } from "./sqlite/knowledge.j
|
|
|
11
12
|
export { PEOPLE_SORTS } from "./sqlite/people-list.js";
|
|
12
13
|
export { parseMergeId } from "./sqlite/person-merges.js";
|
|
13
14
|
export { PROPOSAL_STATUSES } from "./sqlite/proposed-actions.js";
|
|
15
|
+
export { REACHES } from "./sqlite/sender-signals.js";
|
|
14
16
|
export { PROJECT_TASK_FIELDS, TASK_SORTS } from "./sqlite/task-board.js";
|
|
15
17
|
export { TASK_RELATION_KINDS } from "./sqlite/task-relations.js";
|
|
16
18
|
export { TASK_ROLES, } from "./sqlite/work-tasks.js";
|
package/dist/store/public.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { ContextEvidenceItem, ContextEvidencePage, ContextEvidenceReader, ContextEvidenceRequest, ContextEvidenceSender, ContextSource, } from "../context/evidence.js";
|
|
2
2
|
export { BUSINESS_KINDS, type BusinessKind } from "../domain/business.js";
|
|
3
3
|
export { FACT_STATUSES, FACT_TYPES, MEMORY_KINDS, MEMORY_SCOPES, MEMORY_STATUSES, TASK_TYPES, WORK_TASK_TYPES, } from "../domain/knowledge.js";
|
|
4
|
-
export { type KindSignal, PERSON_KINDS, type PersonKind } from "../domain/person-kinds.js";
|
|
4
|
+
export { type KindSignal, PERSON_KINDS, type PersonKind, SENDER_BOT_PREFIX } from "../domain/person-kinds.js";
|
|
5
5
|
export type { RefState, RefSummary, RefSummaryKind, RefsStore } from "../domain/ref-summaries.js";
|
|
6
6
|
export type { TagConsolidationApplyOptions, TagConsolidationOptions, TagConsolidationPreview, TagConsolidationReceipt, TagConsolidationStore, } from "../domain/tag-consolidation.js";
|
|
7
7
|
export type { TagRedirectIndex, TagRedirectResolution, TagRedirectSnapshot } from "../domain/tag-redirects.js";
|
package/dist/store/public.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BUSINESS_KINDS } from "../domain/business.js";
|
|
2
2
|
export { FACT_STATUSES, FACT_TYPES, MEMORY_KINDS, MEMORY_SCOPES, MEMORY_STATUSES, TASK_TYPES, WORK_TASK_TYPES, } from "../domain/knowledge.js";
|
|
3
|
-
export { PERSON_KINDS } from "../domain/person-kinds.js";
|
|
3
|
+
export { PERSON_KINDS, SENDER_BOT_PREFIX } from "../domain/person-kinds.js";
|
|
4
4
|
export { createTagRedirectIndex } from "../domain/tag-redirects.js";
|
|
5
5
|
export { note } from "../entities/note.js";
|
|
6
6
|
export { PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment } from "../meetings/index.js";
|