@remit/api-zod-schemas 0.0.88 → 0.0.89

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/schemas.ts CHANGED
@@ -135,6 +135,16 @@ export const PlacementActionSchema = z.enum(["MoveToInbox", "MoveToJunk"]);
135
135
 
136
136
  export const PlacementConfidenceSchema = z.enum(["Confident", "Unsure"]);
137
137
 
138
+ export const SpamSenderScreenRuleSchema = z.enum(["ReportedSender", "NeverSpam", "Vip", "WellKnown", "Newsletter"]);
139
+
140
+ export const SpamActionSchema = z.enum(["None", "Warn", "Junk"]);
141
+
142
+ export const SpamKindSchema = z.enum(["Spam", "Phishing"]);
143
+
144
+ export const SpamReasonNameSchema = z.enum(["DmarcFail", "SignerMismatch", "ReplyToMismatch", "LinkTextMismatch", "LinkDomainDistant", "PunycodeDomain", "MixedScriptDomain", "ConfusableDomains", "SingleOffDomainLink", "GeneratedName", "FirstContactDomain", "RecentlyRegisteredDomain", "UnknownRegistrationDate", "ClassifierSpam", "ClassifierPhishing", "ProviderSpam", "DisplayNameForeignAddress", "DisplayNameLookalike", "BackendSymbol"]);
145
+
146
+ export const SpamFailureKindSchema = z.enum(["Unreachable", "TimedOut", "ServiceError", "Unparseable"]);
147
+
138
148
  export const OutboxAttachmentStateSchema = z.enum(["Pending", "Stored"]);
139
149
 
140
150
  export const OutboxAttachmentRejectionReasonSchema = z.enum(["EmptyFile", "UnusableFilename", "FileTooLarge", "MessageTooLarge", "TooManyAttachments", "ReservationExpired", "UploadMissing", "SizeMismatch"]);
@@ -187,6 +197,8 @@ export const ConfigImportRefKindSchema = z.enum(["FolderRole", "MailboxOverride"
187
197
 
188
198
  export const SyncWarningStateSchema = z.enum(["Retrying", "GaveUp"]);
189
199
 
200
+ export const ProviderSpamVerdictSchema = z.enum(["Spam", "Clean", "Absent"]);
201
+
190
202
  export const MessagePlacementMoveStateSchema = z.enum(["pending", "queued", "processing", "processed"]);
191
203
 
192
204
  export const FlagPushOperationSchema = z.enum(["add", "remove"]);
@@ -1636,6 +1648,45 @@ export const MessagePlacementVerdictSchema = z.object({
1636
1648
  decidedAt: z.number()
1637
1649
  });
1638
1650
 
1651
+ export const SpamVerdictNotCheckedSchema = z.object({
1652
+ state: z.literal("NotChecked")
1653
+ });
1654
+
1655
+ export const SpamScreenBySenderSchema = z.object({
1656
+ rule: SpamSenderScreenRuleSchema
1657
+ });
1658
+
1659
+ export const SpamScreenByFilterSchema = z.object({
1660
+ rule: z.literal("Filter"),
1661
+ filterId: z.string().min(25).max(25)
1662
+ });
1663
+
1664
+ export const SpamVerdictScreenedOutSchema = z.object({
1665
+ state: z.literal("ScreenedOut"),
1666
+ screen: z.union([SpamScreenBySenderSchema, SpamScreenByFilterSchema])
1667
+ });
1668
+
1669
+ export const SpamReasonSchema = z.object({
1670
+ name: SpamReasonNameSchema,
1671
+ symbol: z.string(),
1672
+ score: z.number(),
1673
+ options: z.array(z.string())
1674
+ });
1675
+
1676
+ export const SpamCheckedSchema = z.object({
1677
+ state: z.literal("Checked"),
1678
+ score: z.number().min(0).max(1),
1679
+ action: SpamActionSchema,
1680
+ kind: SpamKindSchema,
1681
+ reasons: z.array(SpamReasonSchema),
1682
+ modelCalled: z.boolean()
1683
+ });
1684
+
1685
+ export const SpamFailedSchema = z.object({
1686
+ state: z.literal("Failed"),
1687
+ kind: SpamFailureKindSchema
1688
+ });
1689
+
1639
1690
  export const ThreadMessageResponseSchema = z.object({
1640
1691
  threadMessageId: z.string().min(25).max(25),
1641
1692
  threadId: z.string().min(25).max(25),
@@ -1665,7 +1716,8 @@ export const ThreadMessageResponseSchema = z.object({
1665
1716
  autoMoved: AutoMovedInfoSchema.optional(),
1666
1717
  labels: z.array(LabelSummaryResponseSchema).optional(),
1667
1718
  spamReport: MessageSpamReportSchema.optional(),
1668
- placementVerdict: MessagePlacementVerdictSchema.optional()
1719
+ placementVerdict: MessagePlacementVerdictSchema.optional(),
1720
+ spamVerdict: z.union([SpamVerdictNotCheckedSchema, SpamVerdictScreenedOutSchema, SpamCheckedSchema, SpamFailedSchema])
1669
1721
  });
1670
1722
 
1671
1723
  export const ThreadMessageListResponseSchema = z.object({
@@ -1965,6 +2017,7 @@ export const MessageSummaryResponseSchema = z.object({
1965
2017
  syncStatus: MessageSyncStatusSchema,
1966
2018
  abandonedMutation: MessageMutationSchema,
1967
2019
  authenticity: MessageAuthenticitySchema.optional(),
2020
+ spamVerdict: z.union([SpamVerdictNotCheckedSchema, SpamVerdictScreenedOutSchema, SpamCheckedSchema, SpamFailedSchema]),
1968
2021
  messageIdHeader: z.string().optional(),
1969
2022
  autoMoved: AutoMovedInfoSchema.optional(),
1970
2023
  labels: z.array(LabelSummaryResponseSchema).optional(),
@@ -2074,6 +2127,7 @@ export const MessageRecordSchema = z.object({
2074
2127
  placementDecidedAt: z.number().optional(),
2075
2128
  classifierScores: z.array(ClassifierScoreSchema),
2076
2129
  spamReport: MessageSpamReportSchema.optional(),
2130
+ spamVerdict: z.union([SpamVerdictNotCheckedSchema, SpamVerdictScreenedOutSchema, SpamCheckedSchema, SpamFailedSchema]),
2077
2131
  createdAt: z.number(),
2078
2132
  updatedAt: z.number()
2079
2133
  });
@@ -2106,6 +2160,7 @@ export const MessageSchema = z.object({
2106
2160
  placementDecidedAt: z.number().optional(),
2107
2161
  classifierScores: z.array(ClassifierScoreSchema),
2108
2162
  spamReport: MessageSpamReportSchema.optional(),
2163
+ spamVerdict: z.union([SpamVerdictNotCheckedSchema, SpamVerdictScreenedOutSchema, SpamCheckedSchema, SpamFailedSchema]),
2109
2164
  createdAt: z.number(),
2110
2165
  updatedAt: z.number(),
2111
2166
  messageIdHeader: z.string().optional()
@@ -2387,6 +2442,63 @@ export const MessageFlagSchema = z.object({
2387
2442
  updatedAt: z.number()
2388
2443
  });
2389
2444
 
2445
+ export const SpamHeaderSchema = z.object({
2446
+ name: z.string(),
2447
+ value: z.string()
2448
+ });
2449
+
2450
+ export const SpamLinkSchema = z.object({
2451
+ href: z.string(),
2452
+ text: z.string()
2453
+ });
2454
+
2455
+ export const SpamRequestMessageSchema = z.object({
2456
+ raw: z.string(),
2457
+ headers: z.array(SpamHeaderSchema),
2458
+ text: z.string(),
2459
+ html: z.string(),
2460
+ links: z.array(SpamLinkSchema)
2461
+ });
2462
+
2463
+ export const SpamRequestEnvelopeSchema = z.object({
2464
+ mailFrom: z.string(),
2465
+ rcpt: z.array(z.string()),
2466
+ ip: z.string(),
2467
+ helo: z.string()
2468
+ });
2469
+
2470
+ export const SpamRequestAuthenticationSchema = z.object({
2471
+ dmarc: AuthResultVerdictSchema,
2472
+ spf: AuthResultVerdictSchema,
2473
+ dkim: AuthResultVerdictSchema,
2474
+ signerDomain: z.string(),
2475
+ envelopeDomain: z.string()
2476
+ });
2477
+
2478
+ export const SpamRequestProviderSchema = z.object({
2479
+ verdict: ProviderSpamVerdictSchema,
2480
+ score: z.string(),
2481
+ headers: z.array(SpamHeaderSchema)
2482
+ });
2483
+
2484
+ export const SpamRequestContextSchema = z.object({
2485
+ knownSender: z.boolean(),
2486
+ senderMessagesSeen: z.number(),
2487
+ senderDomainMessagesSeen: z.number(),
2488
+ senderDomainRegisteredAt: z.string().optional(),
2489
+ receivedAt: z.string(),
2490
+ classifierScores: z.array(ClassifierScoreSchema),
2491
+ modelAllowed: z.boolean()
2492
+ });
2493
+
2494
+ export const SpamRequestSchema = z.object({
2495
+ message: SpamRequestMessageSchema,
2496
+ envelope: SpamRequestEnvelopeSchema,
2497
+ authentication: SpamRequestAuthenticationSchema,
2498
+ provider: SpamRequestProviderSchema,
2499
+ context: SpamRequestContextSchema
2500
+ });
2501
+
2390
2502
  export const MessagePlacementMoveSchema = z.object({
2391
2503
  messageId: z.string().min(25).max(25),
2392
2504
  accountId: z.string().min(25).max(25),
@@ -2421,6 +2533,22 @@ export const EnvelopeSchema = z.object({
2421
2533
  updatedAt: z.number()
2422
2534
  });
2423
2535
 
2536
+ export const DomainRegistrationPublishedSchema = z.object({
2537
+ state: z.literal("Published"),
2538
+ registeredAt: z.string()
2539
+ });
2540
+
2541
+ export const DomainRegistrationUnpublishedSchema = z.object({
2542
+ state: z.literal("Unpublished")
2543
+ });
2544
+
2545
+ export const DomainRegistrationSchema = z.object({
2546
+ domainRegistrationId: z.string().max(256),
2547
+ registration: z.union([DomainRegistrationPublishedSchema, DomainRegistrationUnpublishedSchema]),
2548
+ createdAt: z.number(),
2549
+ updatedAt: z.number()
2550
+ });
2551
+
2424
2552
  export const SenderSignerStandingSchema = z.object({
2425
2553
  accountConfigId: z.string().min(25).max(25),
2426
2554
  senderKey: z.string().max(256),