@wirecat/cli-core 1.0.0 → 1.1.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 (72) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/THIRD_PARTY_NOTICES +43 -0
  3. package/dist/background/daily-archive-timer.d.ts +1 -1
  4. package/dist/cli/documents/words.d.ts +1 -1
  5. package/dist/cli/domain-lists-command.d.ts +16 -0
  6. package/dist/cli/domain-lists-command.js +88 -0
  7. package/dist/cli/index.d.ts +4 -3
  8. package/dist/cli/index.js +3 -2
  9. package/dist/cli/model-catalogue-command.d.ts +6 -0
  10. package/dist/cli/model-catalogue-command.js +1 -1
  11. package/dist/cli/oauth-session.d.ts +38 -4
  12. package/dist/cli/oauth-session.js +66 -22
  13. package/dist/cli/shared-command-exports.d.ts +2 -0
  14. package/dist/cli/shared-command-exports.js +3 -0
  15. package/dist/cli/token-session.d.ts +9 -0
  16. package/dist/cli/token-session.js +29 -2
  17. package/dist/domain/domain-lists.d.ts +86 -0
  18. package/dist/domain/domain-lists.js +110 -0
  19. package/dist/domain/free-mail-domains.generated.d.ts +1 -0
  20. package/dist/domain/free-mail-domains.generated.js +4 -0
  21. package/dist/domain/organization-sectors.d.ts +9 -3
  22. package/dist/domain/organization-sectors.generated.d.ts +1 -0
  23. package/dist/domain/organization-sectors.generated.js +1 -0
  24. package/dist/domain/organization-sectors.js +16 -3
  25. package/dist/domain/person-kinds.d.ts +6 -1
  26. package/dist/domain/person-kinds.js +5 -0
  27. package/dist/entities/domain-list.d.ts +27 -0
  28. package/dist/entities/domain-list.js +28 -0
  29. package/dist/entities/index.d.ts +20 -2
  30. package/dist/entities/index.js +3 -1
  31. package/dist/entities/knowledge-lists.d.ts +1 -1
  32. package/dist/errors/reasons.js +4 -2
  33. package/dist/mail/mail-types.d.ts +48 -0
  34. package/dist/mail/mail-types.js +218 -0
  35. package/dist/oauth/index.d.ts +1 -1
  36. package/dist/oauth/storage.d.ts +10 -2
  37. package/dist/oauth/storage.js +23 -9
  38. package/dist/services/domain-lists-download.d.ts +26 -0
  39. package/dist/services/domain-lists-download.js +155 -0
  40. package/dist/services/metadata.d.ts +1 -1
  41. package/dist/store/areas.d.ts +1 -1
  42. package/dist/store/index.d.ts +2 -2
  43. package/dist/store/index.js +1 -1
  44. package/dist/store/people.d.ts +18 -9
  45. package/dist/store/people.js +8 -7
  46. package/dist/store/sqlite/accounts.js +3 -1
  47. package/dist/store/sqlite/domain-organizations.d.ts +7 -4
  48. package/dist/store/sqlite/domain-organizations.js +94 -36
  49. package/dist/store/sqlite/email-types.d.ts +79 -0
  50. package/dist/store/sqlite/email-types.js +261 -0
  51. package/dist/store/sqlite/emails.d.ts +11 -2
  52. package/dist/store/sqlite/emails.js +18 -7
  53. package/dist/store/sqlite/identities.d.ts +4 -1
  54. package/dist/store/sqlite/identities.js +11 -2
  55. package/dist/store/sqlite/identity-rekey.js +2 -0
  56. package/dist/store/sqlite/manifest.js +4 -0
  57. package/dist/store/sqlite/merged-persons.d.ts +3 -2
  58. package/dist/store/sqlite/merged-persons.js +5 -3
  59. package/dist/store/sqlite/migrations.generated.js +56 -0
  60. package/dist/store/sqlite/people-list.d.ts +1 -6
  61. package/dist/store/sqlite/people-list.js +38 -32
  62. package/dist/store/sqlite/person-links.js +13 -3
  63. package/dist/store/sqlite/person-match-scan.js +5 -2
  64. package/dist/store/sqlite/schema/sender-bots.d.ts +56 -0
  65. package/dist/store/sqlite/schema/sender-bots.js +9 -1
  66. package/dist/store/sqlite/schema.d.ts +49 -1
  67. package/dist/store/sqlite/schema.js +6 -1
  68. package/dist/store/sqlite/sender-bots.d.ts +80 -15
  69. package/dist/store/sqlite/sender-bots.js +378 -136
  70. package/dist/store/sqlite/sender-signals.d.ts +11 -4
  71. package/dist/store/sqlite/sender-signals.js +14 -10
  72. package/package.json +2 -2
@@ -34,6 +34,7 @@ import { counterRefresh, counters } from "./counters.js";
34
34
  import { deal, lead, pipeline, stage } from "./deal.js";
35
35
  import { document } from "./document.js";
36
36
  import { documentLink } from "./document-link.js";
37
+ import { domainList } from "./domain-list.js";
37
38
  import { evidence } from "./evidence.js";
38
39
  import { fact } from "./fact.js";
39
40
  import { reference, untrusted } from "./fields.js";
@@ -101,7 +102,7 @@ import { topic } from "./topic.js";
101
102
  * subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
102
103
  * is the target, not a description of today's output.
103
104
  */
104
- export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledCancellation, scheduledJob, scheduledSend, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
105
+ export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, domainList, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledCancellation, scheduledJob, scheduledSend, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
105
106
  export const ENTITIES = {
106
107
  sync_progress: syncProgress,
107
108
  deal,
@@ -357,6 +358,7 @@ export const ENTITIES = {
357
358
  chat_rules: chatRules,
358
359
  chat_moderation: chatModeration,
359
360
  "model.chosen": chosenModel,
361
+ domain_list: domainList,
360
362
  model_key: modelKey,
361
363
  chat_sending: chatSending,
362
364
  "model_key.stored": storedModelKey,
@@ -6,7 +6,7 @@ export declare const organization: v.StrictObjectSchema<{
6
6
  readonly kind: v.PicklistSchema<["company", "team", "family", "community"], undefined>;
7
7
  readonly name: v.StringSchema<undefined>;
8
8
  readonly scope: v.PicklistSchema<["personal", "work"], undefined>;
9
- readonly sector: v.NullableSchema<v.PicklistSchema<("airline" | "bank" | "delivery" | "financial" | "government" | "news" | "shop" | "social" | "telecom")[], undefined>, undefined>;
9
+ readonly sector: v.NullableSchema<v.PicklistSchema<import("../domain/organization-sectors.js").Sector[], undefined>, undefined>;
10
10
  readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
11
11
  }, undefined>;
12
12
  /** @experimental */
@@ -141,6 +141,7 @@ const OTHERS = [
141
141
  ["enrichment.owner-only", "permission_error", "only the owner turns enrichment on, not an agent"],
142
142
  ["search-harder.owner-only", "permission_error", "only the owner allows search all --harder, not an agent"],
143
143
  ["model.offline", "permission_error", "downloading a model needs the network; --offline was requested"],
144
+ ["domain-lists.offline", "permission_error", "updating the domain lists needs the network; --offline was requested"],
144
145
  ["model.key-rejected", "invalid_response", "the model provider refused the API key (401 or 403)"],
145
146
  ["model.unreachable", "invalid_response", "the model provider could not be reached over the network"],
146
147
  [
@@ -662,9 +663,10 @@ const OTHERS = [
662
663
  validation("identity.common-name", "more than six people have the name, so it proposes no one"),
663
664
  validation("identity.not-a-person", "a bot, a program or an organization is never proposed as a person by name"),
664
665
  validation("identity.owner", "one side is the owner's person, and only the owner joins anyone to themselves"),
665
- ["sender-bot.not-found", "not_found", "no sender bot has that id; people list kind:automated lists them"],
666
+ ["sender-bot.not-found", "not_found", "no sender bot has that id; the bots list names them"],
666
667
  validation("sender-bot.owner", "the owner's own person is never a bot"),
667
- validation("sender-bot.not-a-person", "the person named is a sender bot; name a person"),
668
+ validation("sender-bot.not-a-person", "the identity named is a sender bot's, not a person's; name a person"),
669
+ validation("sender-bot.empty", "the person or bot named holds no identity to move"),
668
670
  validation("sender-bot.assignee", "a sender bot is no one's assignee; move it to a person first"),
669
671
  validation("identity.shared-email", "more than six people share the address, so it proposes no one"),
670
672
  validation("identity-link.dedicated-review", "an identity link is staged and decided through the people review"),
@@ -0,0 +1,48 @@
1
+ import type { Sector } from "../domain/organization-sectors.js";
2
+ import { type Reach } from "../store/sqlite/sender-signals.js";
3
+ /**
4
+ * What one email is, apart from who sent it: a shop's receipt is an `order` and its sale a `promotion`. The first
5
+ * that matches wins, in this order, with one exception: an automated sender's List-Unsubscribe mail with no campaign
6
+ * marker is an `account_notice` before the list types are tried (Zero's rule that keeps receipts out of promotions).
7
+ * `system_alert` comes before `account_notice`: an alert carries Auto-Submitted too, and would never be reached.
8
+ * @experimental
9
+ */
10
+ export declare const MAIL_TYPES: readonly ["auto_reply", "security", "calendar", "travel", "event_ticket", "order", "shipping", "bill", "social_notification", "discussion_list", "newsletter", "promotion", "system_alert", "account_notice", "personal", "other"];
11
+ /** @experimental */
12
+ export type MailType = (typeof MAIL_TYPES)[number];
13
+ /** What the store keeps of one email that its type is worked out from. @experimental */
14
+ export interface MailTypeInput {
15
+ from: string | null;
16
+ subject: string | null;
17
+ /** As `mailHeadersOf` keeps them: what marks a program or a list counts only under the From domain's DKIM. */
18
+ headers: Record<string, unknown>;
19
+ /** To and Cc together; `null` when the store holds no recipients (mail recorded as an envelope). */
20
+ recipients: number | null;
21
+ /** The media types of its parts the store keeps as attachments, lower case. */
22
+ parts: readonly string[];
23
+ /** schema.org types its HTML declares (`Order`, `FlightReservation`). */
24
+ schemaTypes: readonly string[];
25
+ /** Distinct addresses that send to its List-Id. */
26
+ listSenders: number;
27
+ /** The owner sent mail to this address, or this is the owner's own mail. */
28
+ ownerWrote: boolean;
29
+ /** The sender is a sender bot. */
30
+ bot: boolean;
31
+ /** The sector of the organization the sender's address belongs to. */
32
+ sector: Sector | null;
33
+ }
34
+ /** @experimental */
35
+ export interface MailTypeOf {
36
+ type: MailType;
37
+ reach: Reach;
38
+ /** What decided the type; `null` for `other`. */
39
+ signal: string | null;
40
+ }
41
+ /**
42
+ * One email's type, reach and the signal behind the type, from what the store keeps of it alone: no lookup, no model.
43
+ * Mail from someone the owner writes to is typed by what the mail itself carries (a calendar or report part, schema.org
44
+ * markup, list headers), never by an address word or a subject alone: `info@` is often a person. @experimental
45
+ */
46
+ export declare const mailTypeOf: (input: MailTypeInput) => MailTypeOf;
47
+ /** The schema.org types an email's HTML declares, in JSON-LD or microdata, as Gmail's markup reads them. @experimental */
48
+ export declare const schemaTypesOf: (html: string | null) => string[];
@@ -0,0 +1,218 @@
1
+ /*
2
+ * The order of the checks and the AUTOMATED_SENDER and MARKETING_SENDER patterns are ported from Zero's header
3
+ * classifier, apps/server/src/lib/imap/categorize.ts at commit 4b642dfd9890a1fdcb1b98a177fe74ca3142c445:
4
+ *
5
+ * MIT License
6
+ *
7
+ * Copyright (c) 2025 Zero Email
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10
+ * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12
+ * permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
15
+ * Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+ */
22
+ import { isNoReplyAddress } from "../domain/addresses.js";
23
+ import { DISCUSSION_SENDERS, reachOfOne } from "../store/sqlite/sender-signals.js";
24
+ /**
25
+ * What one email is, apart from who sent it: a shop's receipt is an `order` and its sale a `promotion`. The first
26
+ * that matches wins, in this order, with one exception: an automated sender's List-Unsubscribe mail with no campaign
27
+ * marker is an `account_notice` before the list types are tried (Zero's rule that keeps receipts out of promotions).
28
+ * `system_alert` comes before `account_notice`: an alert carries Auto-Submitted too, and would never be reached.
29
+ * @experimental
30
+ */
31
+ export const MAIL_TYPES = [
32
+ "auto_reply",
33
+ "security",
34
+ "calendar",
35
+ "travel",
36
+ "event_ticket",
37
+ "order",
38
+ "shipping",
39
+ "bill",
40
+ "social_notification",
41
+ "discussion_list",
42
+ "newsletter",
43
+ "promotion",
44
+ "system_alert",
45
+ "account_notice",
46
+ "personal",
47
+ "other",
48
+ ];
49
+ /** Automated senders: notifications, receipts, alerts (Zero). */
50
+ const AUTOMATED_SENDER = /^(no-?reply|do-?not-?reply|donotreply|notifications?|notify|alerts?|mailer-daemon|postmaster|bounces?|automated|system|accounts?|security|billing|receipts?|orders?|shipping|support|service|updates?)([+._-].*)?@/i;
51
+ /** Marketing senders (Zero). */
52
+ const MARKETING_SENDER = /^(news(letters?)?|marketing|promo(tions?)?|offers?|deals?|sales|hello|hi|team|info|digest)([+._-].*)?@/i;
53
+ const local = (words) => new RegExp(`^(${words})([+._-].*)?@`, "i");
54
+ const MAILER_DAEMON = local("mailer-daemon|postmaster");
55
+ const SECURITY_SENDER = local("security|account-?security|verify|verification|auth|2fa|otp|login|signin|password");
56
+ const ORDER_SENDER = local("orders?|receipts?|order-?confirm(ation)?|purchases?");
57
+ const SHIPPING_SENDER = local("shipping|shipments?|tracking|deliver(y|ies)|dispatch");
58
+ const BILL_SENDER = local("billing|invoices?|payments?|statements?");
59
+ const ALERT_SENDER = local("alerts?|alertmanager|monitoring|monitor|cron|root|ci|builds?|jenkins|nagios|zabbix|sentry");
60
+ const NEWS_SENDER = local("news(letters?)?|digest|editors?|weekly");
61
+ const AUTO_REPLY_SUBJECT = /^(auto(matic)?[ -]?(reply|response)|out of (the )?office|abwesenheit|réponse automatique|respuesta automática|автоответ|автоматический ответ|undeliverable|undelivered mail|delivery status notification|mail delivery (failed|subsystem)|returned mail|failure notice|не доставлено)/iu;
62
+ const SECURITY_SUBJECT = /\b(verification code|security code|one[- ]time (pass)?code|sign[- ]?in (attempt|alert|code)|new (sign[- ]?in|login|device)|log[- ]?in (attempt|alert|code)|password (reset|change)|reset your password|two[- ]factor|2-step|confirm your (email|account)|verify your (email|account|identity))\b|код (подтверждения|для входа|безопасности)|вход в (аккаунт|учётную|учетную)|сброс пароля|código de (verificación|seguridad|acceso)|restablecer (tu |la )?contraseña|inicio de sesión/iu;
63
+ const TRAVEL_SUBJECT = /\b(boarding pass|e-?ticket|itinerary|flight (confirmation|booking|reservation)|booking confirm(ation|ed)|check[- ]in (now|is open|online))\b|посадочный талон|маршрутная квитанция|tarjeta de embarque|confirmación de (reserva|vuelo)/iu;
64
+ const EVENT_SUBJECT = /\b(your tickets?|ticket confirmation|tickets? for)\b|билеты? на|tus entradas|entradas para/iu;
65
+ const ORDER_SUBJECT = /\b(order (confirmation|confirmed|received|#|no\.?|number)|your order|thank(s| you) for your (order|purchase)|purchase confirmation|your receipt|receipt for|payment receipt)\b|ваш заказ|заказ (№|#|оформлен|принят)|tu pedido|confirmación de (pedido|compra)/iu;
66
+ const SHIPPING_SUBJECT = /\b(has (been )?shipped|out for delivery|has been delivered|on (its|the) way|tracking (number|info)|track your (order|package|parcel)|shipment|dispatched)\b|отправлен|доставлен|посылк|tu (pedido|paquete) (ha sido enviado|está en camino)|en camino/iu;
67
+ const BILL_SUBJECT = /\b(invoice|statement (is )?(ready|available)|your (monthly |account )?statement|payment (due|reminder|received|confirmation|failed)|bill (is )?(ready|due)|your bill)\b|сч[её]т (на оплату|№|#)|выписка|квитанция|factura|extracto|recibo de pago/iu;
68
+ const ALERT_SUBJECT = /^\[(firing|resolved|alert)|\b(build (failed|passed|fixed|broken)|pipeline (failed|succeeded)|cron <|is down|downtime)\b/iu;
69
+ const PROMOTION_SUBJECT = /\d+\s?%|\b(sale|discount|deals?|offers?|coupon|promo(code)?|free shipping|black friday|cyber monday|limited time|last chance)\b|скидк|распродаж|промокод|descuento|oferta|rebajas|cupón/iu;
70
+ const NEWS_SUBJECT = /\b(newsletter|digest|weekly|monthly|issue\s?#?\d+|edition)\b|рассылка|дайджест|boletín/iu;
71
+ const REPORT_PARTS = new Set(["message/delivery-status", "message/disposition-notification"]);
72
+ const CALENDAR_PARTS = new Set(["text/calendar", "application/ics"]);
73
+ const TRAVEL_SCHEMA = /^(Flight|Train|Bus|Lodging|RentalCar|Taxi|Boat)Reservation$/;
74
+ const schemaOf = (types, wanted) => types.find((one) => (typeof wanted === "string" ? one === wanted : wanted.test(one)));
75
+ /**
76
+ * One email's type, reach and the signal behind the type, from what the store keeps of it alone: no lookup, no model.
77
+ * Mail from someone the owner writes to is typed by what the mail itself carries (a calendar or report part, schema.org
78
+ * markup, list headers), never by an address word or a subject alone: `info@` is often a person. @experimental
79
+ */
80
+ export const mailTypeOf = (input) => {
81
+ const { headers } = input;
82
+ const from = input.from ?? "";
83
+ const subject = input.subject ?? "";
84
+ const oneClick = headers["list-unsubscribe-post"] === true;
85
+ const feedbackId = headers["feedback-id"] === true;
86
+ const listUnsubscribe = headers["list-unsubscribe"] === true;
87
+ const listId = typeof headers["list-id"] === "string";
88
+ const precedence = typeof headers.precedence === "string" ? headers.precedence : "";
89
+ const bulkPrecedence = precedence === "bulk" || precedence === "junk";
90
+ const autoSubmitted = headers["auto-submitted"] !== undefined;
91
+ // With a List-Id, its senders decide: one sender, even under `+tag` addresses, writes a newsletter.
92
+ const discussion = listId
93
+ ? input.listSenders >= DISCUSSION_SENDERS
94
+ : precedence === "list" && !feedbackId && !MARKETING_SENDER.test(from);
95
+ const mass = listUnsubscribe || bulkPrecedence || listId || oneClick;
96
+ const transactional = !mass && !feedbackId;
97
+ const noReply = from !== "" && isNoReplyAddress(from);
98
+ const person = input.ownerWrote && !input.bot;
99
+ // A forged `security@` would lend a phishing mail the look of a real alert.
100
+ const trusted = headers.dmarc !== "fail" && headers.dkim !== "fail";
101
+ const weak = !person && !oneClick && !listId;
102
+ const reach = reachOfOne({
103
+ autoSubmitted,
104
+ nullReturnPath: headers["null-return-path"] === true,
105
+ oneClick,
106
+ feedbackId,
107
+ bulk: mass || precedence === "list",
108
+ discussionList: discussion,
109
+ recipients: input.recipients,
110
+ }).reach;
111
+ const typed = (type, signal) => ({ type, reach, signal });
112
+ const schema = (wanted) => schemaOf(input.schemaTypes, wanted);
113
+ const report = input.parts.find((part) => REPORT_PARTS.has(part));
114
+ if (report !== undefined)
115
+ return typed("auto_reply", report);
116
+ if (MAILER_DAEMON.test(from))
117
+ return typed("auto_reply", "mailer-daemon");
118
+ if (!mass && AUTO_REPLY_SUBJECT.test(subject))
119
+ return typed("auto_reply", "auto-reply-subject");
120
+ if (weak && trusted && SECURITY_SENDER.test(from))
121
+ return typed("security", "security-address");
122
+ if (weak && trusted && SECURITY_SUBJECT.test(subject))
123
+ return typed("security", "security-subject");
124
+ const calendar = input.parts.find((part) => CALENDAR_PARTS.has(part));
125
+ if (calendar !== undefined)
126
+ return typed("calendar", calendar);
127
+ const travel = schema(TRAVEL_SCHEMA);
128
+ if (travel !== undefined)
129
+ return typed("travel", `schema:${travel}`);
130
+ if (weak && TRAVEL_SUBJECT.test(subject))
131
+ return typed("travel", "travel-subject");
132
+ if (weak && transactional && input.sector === "airline")
133
+ return typed("travel", "sector:airline");
134
+ if (schema("EventReservation") !== undefined)
135
+ return typed("event_ticket", "schema:EventReservation");
136
+ if (weak && EVENT_SUBJECT.test(subject))
137
+ return typed("event_ticket", "ticket-subject");
138
+ if (schema("Order") !== undefined)
139
+ return typed("order", "schema:Order");
140
+ if (weak && ORDER_SENDER.test(from))
141
+ return typed("order", "order-address");
142
+ // "Your order has shipped" names the order but reports the parcel.
143
+ if (weak && ORDER_SUBJECT.test(subject) && !SHIPPING_SUBJECT.test(subject))
144
+ return typed("order", "order-subject");
145
+ if (schema("ParcelDelivery") !== undefined)
146
+ return typed("shipping", "schema:ParcelDelivery");
147
+ if (weak && SHIPPING_SENDER.test(from))
148
+ return typed("shipping", "shipping-address");
149
+ if (weak && SHIPPING_SUBJECT.test(subject))
150
+ return typed("shipping", "shipping-subject");
151
+ if (weak && transactional && input.sector === "delivery")
152
+ return typed("shipping", "sector:delivery");
153
+ if (schema("Invoice") !== undefined)
154
+ return typed("bill", "schema:Invoice");
155
+ if (weak && BILL_SENDER.test(from))
156
+ return typed("bill", "bill-address");
157
+ if (weak && BILL_SUBJECT.test(subject))
158
+ return typed("bill", "bill-subject");
159
+ if (!person && input.sector === "social")
160
+ return typed("social_notification", "sector:social");
161
+ if (discussion)
162
+ return typed("discussion_list", listId ? "discussion-list" : "precedence-list");
163
+ // Transactional mail sometimes carries List-Unsubscribe: an automated sender with no campaign marker sends notices.
164
+ const automated = AUTOMATED_SENDER.test(from) && !MARKETING_SENDER.test(from);
165
+ if (listUnsubscribe && !oneClick && !feedbackId && !bulkPrecedence && automated)
166
+ return typed("account_notice", "automated-address");
167
+ if (mass || feedbackId) {
168
+ if (PROMOTION_SUBJECT.test(subject))
169
+ return typed("promotion", "promotion-subject");
170
+ if (MARKETING_SENDER.test(from) && !NEWS_SENDER.test(from))
171
+ return typed("promotion", "marketing-address");
172
+ if (listId)
173
+ return typed("newsletter", "list-id");
174
+ if (NEWS_SENDER.test(from))
175
+ return typed("newsletter", "newsletter-address");
176
+ if (NEWS_SUBJECT.test(subject))
177
+ return typed("newsletter", "newsletter-subject");
178
+ if (input.sector === "news")
179
+ return typed("newsletter", "sector:news");
180
+ if (!input.bot && !noReply)
181
+ return typed("newsletter", "person-sender");
182
+ return typed("promotion", oneClick ? "one-click-unsubscribe" : feedbackId ? "feedback-id" : "bulk-mail");
183
+ }
184
+ if (!person && (ALERT_SENDER.test(from) || ALERT_SUBJECT.test(subject)))
185
+ return typed("system_alert", ALERT_SENDER.test(from) ? "alert-address" : "alert-subject");
186
+ if (!person && autoSubmitted)
187
+ return typed("account_notice", "auto-submitted");
188
+ if (!person && noReply)
189
+ return typed("account_notice", "no-reply");
190
+ if (!person && AUTOMATED_SENDER.test(from))
191
+ return typed("account_notice", "automated-address");
192
+ if (person)
193
+ return typed("personal", "owner-wrote");
194
+ if (!input.bot && headers["null-return-path"] !== true)
195
+ return typed("personal", "person");
196
+ return typed("other", null);
197
+ };
198
+ const JSON_LD_OPEN = /<script[^>]*type\s*=\s*["']?application\/ld\+json[^>]*>/gi;
199
+ const ITEM_TYPE = /\bitemtype\s*=\s*["']?https?:\/\/schema\.org\/([A-Za-z]+)/gi;
200
+ const LD_TYPE = /"@type"\s*:\s*"(?:https?:\/\/schema\.org\/)?([A-Za-z]+)"/g;
201
+ /** The schema.org types an email's HTML declares, in JSON-LD or microdata, as Gmail's markup reads them. @experimental */
202
+ export const schemaTypesOf = (html) => {
203
+ if (html === null || html === "")
204
+ return [];
205
+ const found = new Set();
206
+ for (const open of html.matchAll(JSON_LD_OPEN)) {
207
+ const start = open.index + open[0].length;
208
+ const end = html.indexOf("</script>", start);
209
+ // An unclosed block ends the scan: every later opener would search to the end again.
210
+ if (end === -1)
211
+ break;
212
+ for (const [, type] of html.slice(start, end).matchAll(LD_TYPE))
213
+ found.add(type);
214
+ }
215
+ for (const [, type] of html.matchAll(ITEM_TYPE))
216
+ found.add(type);
217
+ return [...found];
218
+ };
@@ -3,4 +3,4 @@ export { type ClientFileOptions, readClientFile } from "./client-file.js";
3
3
  export { type SignInOptions, type TokenKeeper, type TokenKeeperOptions, type TokensOptions, tokenKeeper, } from "./keeper.js";
4
4
  export { type AppSource, type ExchangeContext, googleProvider, type OAuthClient, type OAuthProvider, type RequestContext, type TokenSet, } from "./provider.js";
5
5
  export { requestTokens, revokeToken, TOKEN_LOG_ALLOW, TOKEN_LOG_EVENT } from "./requests.js";
6
- export { accountTokenCodec, type CredentialStorageOptions, credentialStorage, driveSessionCodec, type EncodeInput, googleTokenCodec, oauthAccount, type StoredTokens, standardCodec, type TokenCodec, type TokenStorage, zoomTokenCodec, } from "./storage.js";
6
+ export { accountTokenCodec, type CredentialStorageOptions, credentialStorage, driveSessionCodec, type EncodeInput, googleTokenCodec, type LegacyAccount, oauthAccount, type StoredTokens, standardCodec, type TokenCodec, type TokenStorage, zoomTokenCodec, } from "./storage.js";
@@ -69,12 +69,20 @@ export declare const googleTokenCodec: TokenCodec;
69
69
  export declare const accountTokenCodec: (providerId: string) => TokenCodec;
70
70
  /** zm's entry as zoom-cli writes it today: `{accessToken, refreshToken, expiresAt, scopes}`, all four required. */
71
71
  export declare const zoomTokenCodec: TokenCodec;
72
+ /** An older entry: an account under the same service, or one an older version kept under another service. */
73
+ export type LegacyAccount = string | {
74
+ service: string;
75
+ account: string;
76
+ };
72
77
  export interface CredentialStorageOptions {
73
78
  /** What the CLI passes `Credentials` today; the same options address the same entry. */
74
79
  credentials: CredentialsOptions;
75
80
  account: string;
76
- /** Older accounts read when `account` is empty; a hit is copied to `account` and left in place. */
77
- legacyAccounts?: readonly string[];
81
+ /**
82
+ * Older entries read when `account` is empty. A hit is copied to `account`, in the store it was read from, and left
83
+ * in place; `remove` removes them too. A run with moved folders only reads them.
84
+ */
85
+ legacyAccounts?: readonly LegacyAccount[];
78
86
  codec: TokenCodec;
79
87
  }
80
88
  export declare const credentialStorage: (options: CredentialStorageOptions) => TokenStorage;
@@ -217,9 +217,12 @@ export const credentialStorage = (options) => {
217
217
  (options.credentials.keyring === systemKeyring &&
218
218
  isMovedRun({ appName: options.credentials.service, env: options.credentials.env ?? process.env }));
219
219
  const service = keyringService(options.credentials.service, options.credentials.configDir, options.credentials.isolated);
220
- const raw = (name) => {
220
+ const legacies = (options.legacyAccounts ?? []).map((legacy) => typeof legacy === "string"
221
+ ? { account: legacy, store: credentials }
222
+ : { account: legacy.account, store: new Credentials({ ...options.credentials, service: legacy.service }) });
223
+ const sourced = (name, store = credentials) => {
221
224
  try {
222
- return credentials.read(name)?.secret;
225
+ return store.read(name);
223
226
  }
224
227
  catch (error) {
225
228
  // cli-base's own error already says what to do, in words safe for the answer.
@@ -228,6 +231,7 @@ export const credentialStorage = (options) => {
228
231
  throw keyringFailure(error);
229
232
  }
230
233
  };
234
+ const raw = (name) => sourced(name)?.secret;
231
235
  // A sign-in on a machine with no keyring writes to the file, so an old entry it cannot read is no old entry. With
232
236
  // `storage: "keyring"` there is no file to fall back on: the save would fail too, after the browser.
233
237
  const fallsBack = options.credentials.storage !== "keyring";
@@ -253,14 +257,22 @@ export const credentialStorage = (options) => {
253
257
  const own = raw(account);
254
258
  if (own !== undefined)
255
259
  return own;
256
- for (const legacy of options.legacyAccounts ?? []) {
257
- const found = raw(legacy);
260
+ for (const legacy of legacies) {
261
+ const found = sourced(legacy.account, legacy.store);
258
262
  if (found === undefined)
259
263
  continue;
260
- codec.decode(found);
261
- if (!moved)
262
- save(found);
263
- return found;
264
+ codec.decode(found.secret);
265
+ // A sign-in the owner kept in the file must not move to the keyring by being copied.
266
+ if (!moved && found.source === "file")
267
+ try {
268
+ new Credentials({ ...options.credentials, storage: "file" }).write(account, found.secret);
269
+ }
270
+ catch (error) {
271
+ throw keyringFailure(error, found.secret);
272
+ }
273
+ else if (!moved)
274
+ save(found.secret);
275
+ return found.secret;
264
276
  }
265
277
  return undefined;
266
278
  };
@@ -278,7 +290,9 @@ export const credentialStorage = (options) => {
278
290
  write: (input, writeOptions) => save(codec.encode({ ...input, previous: replaced(account), ...(writeOptions?.signIn ? { signIn: true } : {}) }), writeOptions),
279
291
  remove: () => {
280
292
  try {
281
- return credentials.remove(account);
293
+ // The next read would copy an older entry back and sign the profile in again.
294
+ const older = moved ? [] : legacies.flatMap((legacy) => legacy.store.remove(legacy.account));
295
+ return [...new Set([...credentials.remove(account), ...older])];
282
296
  }
283
297
  catch (error) {
284
298
  throw keyringFailure(error);
@@ -0,0 +1,26 @@
1
+ import { type InstalledPack, type PackManifest } from "../domain/domain-lists.js";
2
+ import { type Fetch } from "../speech/install.js";
3
+ export interface DomainListsUpdateOptions {
4
+ env: NodeJS.ProcessEnv;
5
+ /** Leave out `non-commercial` sources, and remove those already here. */
6
+ commercialOnly?: boolean;
7
+ fetch?: Fetch;
8
+ manifestUrl?: string;
9
+ progress?: (line: string) => void;
10
+ bytes?: (done: number, total: number) => void;
11
+ }
12
+ export interface DomainListsUpdate {
13
+ pack: InstalledPack;
14
+ updated: boolean;
15
+ previous: string | null;
16
+ }
17
+ /** The hosts a download may reach, each once: `hostFetch` refuses a list that names one twice. */
18
+ export declare const packHosts: (urls: readonly string[]) => string[];
19
+ /** The manifest as a release serves it, refused whole when a source would write outside the pack or skip its check. */
20
+ export declare const parseManifest: (value: unknown) => PackManifest;
21
+ /**
22
+ * Brings the pack to the newest release: every file checked against the manifest's sha256 as it arrives, then the
23
+ * whole folder swapped at once, so a failed download leaves the pack as it was. Nothing is downloaded when the pack
24
+ * here is already that version with the same sources.
25
+ */
26
+ export declare const updateDomainLists: ({ env, commercialOnly, fetch: given, manifestUrl, progress, bytes, }: DomainListsUpdateOptions) => Promise<DomainListsUpdate>;
@@ -0,0 +1,155 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { createReadStream, createWriteStream, mkdirSync, writeFileSync } from "node:fs";
3
+ import { rename, rm } from "node:fs/promises";
4
+ import { dirname, join } from "node:path";
5
+ import { pipeline } from "node:stream/promises";
6
+ import { createGunzip } from "node:zlib";
7
+ import { CliError } from "@wirecat/cli-base";
8
+ import { hostFetch } from "@wirecat/cli-base/http";
9
+ import { domainListsDirectory, installedPack, listFile, PACK_MANIFEST_URL, } from "../domain/domain-lists.js";
10
+ import { installFiles, megabytes } from "../speech/install.js";
11
+ /** Where a release asset is served from: GitHub answers with a redirect to its asset host. */
12
+ const RELEASE_HOSTS = ["github.com", "release-assets.githubusercontent.com", "objects.githubusercontent.com"];
13
+ const DOWNLOAD_MS = 10 * 60_000;
14
+ /** The hosts a download may reach, each once: `hostFetch` refuses a list that names one twice. */
15
+ export const packHosts = (urls) => [
16
+ ...new Set([...RELEASE_HOSTS, ...urls.map((url) => new URL(url).hostname)]),
17
+ ];
18
+ const ID = /^[a-z0-9][a-z0-9-]{0,62}$/;
19
+ const SHA256 = /^[0-9a-f]{64}$/;
20
+ const DOMAIN = /^[a-z0-9_]([a-z0-9_.-]*[a-z0-9])?$/;
21
+ const invalid = (what) => new CliError("invalid_response", `the domain-list manifest ${what}`);
22
+ /** The manifest as a release serves it, refused whole when a source would write outside the pack or skip its check. */
23
+ export const parseManifest = (value) => {
24
+ const manifest = value;
25
+ if (typeof manifest?.version !== "string" || !Array.isArray(manifest.sources))
26
+ throw invalid("has no version or sources");
27
+ const ids = new Set();
28
+ for (const source of manifest.sources) {
29
+ if (typeof source.id !== "string" || !ID.test(source.id) || ids.has(source.id))
30
+ throw invalid(`names a bad or repeated source id: ${String(source.id)}`);
31
+ ids.add(source.id);
32
+ if (typeof source.url !== "string" || !source.url.startsWith("https://"))
33
+ throw invalid(`gives ${source.id} a url that is not https`);
34
+ if (!["sector", "freemail", "bad"].includes(source.signal))
35
+ throw invalid(`gives ${source.id} no signal`);
36
+ if (source.class !== "commercial-ok" && source.class !== "non-commercial")
37
+ throw invalid(`gives ${source.id} no licence class`);
38
+ if (source.upstream === true) {
39
+ if (!Number.isSafeInteger(source.max_bytes))
40
+ throw invalid(`gives upstream ${source.id} no size limit`);
41
+ }
42
+ else if (!SHA256.test(source.sha256 ?? "") || !Number.isSafeInteger(source.bytes))
43
+ throw invalid(`gives ${source.id} no sha256 and size`);
44
+ }
45
+ return manifest;
46
+ };
47
+ const fetchManifest = async (url, get) => {
48
+ const response = await get(url, { signal: AbortSignal.timeout(60_000) });
49
+ if (!response.ok) {
50
+ await response.body?.cancel();
51
+ throw new CliError("network_error", `the domain-list manifest could not be downloaded: HTTP ${response.status}`);
52
+ }
53
+ try {
54
+ return parseManifest(await response.json());
55
+ }
56
+ catch (error) {
57
+ if (error instanceof CliError)
58
+ throw error;
59
+ throw invalid("is not JSON");
60
+ }
61
+ };
62
+ const gunzipTo = async (from, to) => pipeline(createReadStream(from), createGunzip(), createWriteStream(to, { flags: "wx", mode: 0o600 }));
63
+ /**
64
+ * A list the source does not let us redistribute, fetched from the source itself, whole. Nothing pins its bytes, so
65
+ * its sha256 is recorded as it arrived, and only lines that read as a domain are kept.
66
+ */
67
+ const fetchUpstream = async (source, path, get) => {
68
+ const response = await get(source.url, { signal: AbortSignal.timeout(120_000) });
69
+ if (!response.ok || !response.body) {
70
+ await response.body?.cancel();
71
+ throw new CliError("network_error", `${source.id} could not be downloaded from its source: HTTP ${response.status}`);
72
+ }
73
+ const limit = source.max_bytes ?? 0;
74
+ const hash = createHash("sha256");
75
+ const chunks = [];
76
+ let bytes = 0;
77
+ for await (const chunk of response.body) {
78
+ bytes += chunk.length;
79
+ if (bytes > limit)
80
+ throw new CliError("invalid_response", `${source.id} is larger than ${megabytes(limit)}`);
81
+ hash.update(chunk);
82
+ chunks.push(Buffer.from(chunk));
83
+ }
84
+ const lines = [
85
+ ...new Set(Buffer.concat(chunks)
86
+ .toString("utf8")
87
+ .split("\n")
88
+ .map((line) => line.trim().toLowerCase())
89
+ .filter((line) => DOMAIN.test(line) && line.includes("."))),
90
+ ];
91
+ writeFileSync(path, lines.length === 0 ? "" : `${lines.join("\n")}\n`, { flag: "wx", mode: 0o600 });
92
+ return { sha256: hash.digest("hex"), lines: lines.length, bytes };
93
+ };
94
+ /**
95
+ * Brings the pack to the newest release: every file checked against the manifest's sha256 as it arrives, then the
96
+ * whole folder swapped at once, so a failed download leaves the pack as it was. Nothing is downloaded when the pack
97
+ * here is already that version with the same sources.
98
+ */
99
+ export const updateDomainLists = async ({ env, commercialOnly = false, fetch: given, manifestUrl = PACK_MANIFEST_URL, progress = () => { }, bytes, }) => {
100
+ const manifest = await fetchManifest(manifestUrl, given ?? hostFetch({ hosts: packHosts([manifestUrl]), timeoutMs: 60_000 }));
101
+ const get = given ??
102
+ hostFetch({
103
+ hosts: packHosts(manifest.sources.map((one) => one.url)),
104
+ timeoutMs: DOWNLOAD_MS,
105
+ });
106
+ const before = installedPack(env);
107
+ const sources = manifest.sources.filter((one) => !commercialOnly || one.class === "commercial-ok");
108
+ if (before !== undefined &&
109
+ before.version === manifest.version &&
110
+ before.commercial_only === commercialOnly &&
111
+ sources.every((one) => before.files[one.id] !== undefined))
112
+ return { pack: before, updated: false, previous: before.version };
113
+ const directory = domainListsDirectory(env);
114
+ const staging = `${directory}.${randomUUID()}.part`;
115
+ mkdirSync(staging, { recursive: true, mode: 0o700 });
116
+ try {
117
+ const published = sources.filter((one) => !one.upstream);
118
+ const weight = published.reduce((sum, one) => sum + (one.bytes ?? 0), 0);
119
+ progress(`domain lists ${manifest.version}: ${megabytes(weight)} from the WireCat release`);
120
+ await installFiles(published.map((one) => [
121
+ { name: `${one.id}.txt.gz`, url: one.url, sha256: one.sha256 ?? "", bytes: one.bytes ?? 0 },
122
+ `${listFile(staging, one.id)}.gz`,
123
+ ]), { fetch: get, progress, ...(bytes ? { bytes } : {}) });
124
+ const files = {};
125
+ for (const source of published) {
126
+ const path = listFile(staging, source.id);
127
+ await gunzipTo(`${path}.gz`, path);
128
+ await rm(`${path}.gz`);
129
+ files[source.id] = { sha256: source.sha256 ?? "", lines: source.count ?? 0, bytes: source.bytes ?? 0 };
130
+ }
131
+ for (const source of sources.filter((one) => one.upstream)) {
132
+ progress(`${source.id}: from ${new URL(source.url).host}, under its own terms (${source.licence})`);
133
+ files[source.id] = await fetchUpstream(source, listFile(staging, source.id), get);
134
+ }
135
+ const pack = {
136
+ ...manifest,
137
+ installed_at: new Date().toISOString(),
138
+ commercial_only: commercialOnly,
139
+ files,
140
+ };
141
+ writeFileSync(join(staging, "manifest.json"), `${JSON.stringify(pack, null, 2)}\n`, { mode: 0o600 });
142
+ mkdirSync(dirname(directory), { recursive: true, mode: 0o700 });
143
+ const old = `${directory}.${randomUUID()}.old`;
144
+ await rename(directory, old).catch((error) => {
145
+ if (error.code !== "ENOENT")
146
+ throw error;
147
+ });
148
+ await rename(staging, directory);
149
+ await rm(old, { recursive: true, force: true });
150
+ return { pack, updated: true, previous: before?.version ?? null };
151
+ }
152
+ finally {
153
+ await rm(staging, { recursive: true, force: true });
154
+ }
155
+ };
@@ -14,12 +14,12 @@ export declare const metadataService: (deps: ServiceDeps) => {
14
14
  dryRun?: boolean;
15
15
  }) => Promise<{
16
16
  items: ({
17
- error?: undefined;
18
17
  chatId: string;
19
18
  tags: import("../domain/channel-tags.js").ChannelTagMatch[];
20
19
  algorithm: string;
21
20
  fetchedAt: string | null;
22
21
  source: string;
22
+ error?: undefined;
23
23
  } | {
24
24
  tags?: undefined;
25
25
  algorithm?: undefined;
@@ -30,7 +30,7 @@ export type { ProductFilter } from "./sqlite/products.js";
30
30
  export { PROPOSAL_STATUSES, type ProposedAction } from "./sqlite/proposed-actions.js";
31
31
  export type { MatchRun, RecordKey } from "./sqlite/records.js";
32
32
  export type { RelationListItem } from "./sqlite/relation-list.js";
33
- export type { SenderBot } from "./sqlite/sender-bots.js";
33
+ export type { BotIdentity, BotList, BotListOptions, BotMove, SenderBot, SenderBotDetails, } from "./sqlite/sender-bots.js";
34
34
  export type { SubscriptionFilter } from "./sqlite/subscriptions.js";
35
35
  export { PROJECT_TASK_FIELDS, TASK_SORTS, type TaskSort } from "./sqlite/task-board.js";
36
36
  export { TASK_RELATION_KINDS, type TaskRelationKind } from "./sqlite/task-relations.js";