@remit/api-zod-schemas 0.0.81 → 0.0.83

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
@@ -61,6 +61,12 @@ export const FilterMatchOperatorSchema = z.enum(["And", "Or"]);
61
61
 
62
62
  export const FilterClauseFieldSchema = z.enum(["From", "Subject", "HasWords", "ListId", "FromDomain"]);
63
63
 
64
+ export const FilterRuleMatchSchema = z.enum(["Is", "Contains"]);
65
+
66
+ export const FilterRuleHeaderSchema = z.enum(["From", "Subject", "ListId"]);
67
+
68
+ export const FilterRuleAddressPartSchema = z.enum(["All", "Localpart", "Domain", "RegistrableDomain"]);
69
+
64
70
  export const LabelColorSchema = z.enum(["Default", "Red", "Orange", "Yellow", "Green", "Teal", "Blue", "Purple", "Gray"]);
65
71
 
66
72
  export const OrganizeJobStateSchema = z.enum(["Pending", "Running", "Complete", "Failed"]);
@@ -101,18 +107,18 @@ export const ClassificationValueSourceSchema = z.enum(["Saved", "Deployment", "D
101
107
 
102
108
  export const ClassificationUnrunnableReasonSchema = z.enum(["NoBaseUrl", "NoApiKey"]);
103
109
 
104
- export const ClassificationLabelSchema = z.enum(["Spam", "Phishing", "Priority", "Personal", "Newsletter", "Marketing", "Automated", "Transactional", "Social"]);
110
+ export const ClassificationLabelSchema = z.enum(["Spam", "Phishing", "Priority", "Personal", "Newsletter", "Marketing", "Automated", "Transactional", "Social", "ColdOutreach"]);
105
111
 
106
112
  export const ClassificationFailureKindSchema = z.enum(["Unauthorized", "ModelNotFound", "RateLimited", "Rejected", "ProviderError", "Unreachable", "TimedOut", "Unparseable"]);
107
113
 
108
114
  export const ClassificationFieldSchema = z.enum(["ApiKey", "Model", "BaseUrl"]);
109
115
 
116
+ export const MessageCategorySchema = z.enum(["uncategorized", "personal", "newsletter", "marketing", "automated", "transactional", "social", "coldOutreach"]);
117
+
110
118
  export const SortOrderSchema = z.enum(["asc", "desc"]);
111
119
 
112
120
  export const StarColorSchema = z.enum(["none", "yellow", "orange", "red", "purple", "blue", "teal", "green", "yellow_bang", "red_bang", "purple_question", "blue_info", "orange_guillemet", "green_check", "yellow_check", "blue_star"]);
113
121
 
114
- export const MessageCategorySchema = z.enum(["uncategorized", "personal", "newsletter", "marketing", "automated", "transactional", "social"]);
115
-
116
122
  export const SenderTrustSchema = z.enum(["unknown", "wellknown", "vip"]);
117
123
 
118
124
  export const DisplayNameCorrespondenceSchema = z.enum(["Corresponds", "Lookalike", "ForeignAddress", "Unrelated", "NoClaim"]);
@@ -795,6 +801,55 @@ export const FilterClauseSchema = z.object({
795
801
  value: z.string().max(256)
796
802
  });
797
803
 
804
+ export const FilterRuleV0Schema = z.object({
805
+ version: z.literal(0)
806
+ });
807
+
808
+ export const FilterHeaderTestSchema = z.object({
809
+ test: z.literal("header"),
810
+ match: FilterRuleMatchSchema,
811
+ header: FilterRuleHeaderSchema,
812
+ key: z.string().max(256)
813
+ });
814
+
815
+ export const FilterAddressTestSchema = z.object({
816
+ test: z.literal("address"),
817
+ match: FilterRuleMatchSchema,
818
+ part: FilterRuleAddressPartSchema,
819
+ key: z.string().max(256)
820
+ });
821
+
822
+ export const FilterHasWordsTestSchema = z.object({
823
+ test: z.literal("hasWords"),
824
+ words: z.array(z.string().max(256))
825
+ });
826
+
827
+ export type FilterAllOfTest = { test: "allof"; tests: Array<FilterAllOfTest | FilterAnyOfTest | FilterNotTest | z.infer<typeof FilterHeaderTestSchema> | z.infer<typeof FilterAddressTestSchema> | z.infer<typeof FilterHasWordsTestSchema>> };
828
+
829
+ export const FilterAllOfTestSchema: z.ZodType<FilterAllOfTest> = z.object({
830
+ test: z.literal("allof"),
831
+ tests: z.array(z.union([z.lazy(() => FilterAllOfTestSchema), z.lazy(() => FilterAnyOfTestSchema), z.lazy(() => FilterNotTestSchema), FilterHeaderTestSchema, FilterAddressTestSchema, FilterHasWordsTestSchema]))
832
+ });
833
+
834
+ export type FilterAnyOfTest = { test: "anyof"; tests: Array<FilterAllOfTest | FilterAnyOfTest | FilterNotTest | z.infer<typeof FilterHeaderTestSchema> | z.infer<typeof FilterAddressTestSchema> | z.infer<typeof FilterHasWordsTestSchema>> };
835
+
836
+ export const FilterAnyOfTestSchema: z.ZodType<FilterAnyOfTest> = z.object({
837
+ test: z.literal("anyof"),
838
+ tests: z.array(z.union([FilterAllOfTestSchema, z.lazy(() => FilterAnyOfTestSchema), z.lazy(() => FilterNotTestSchema), FilterHeaderTestSchema, FilterAddressTestSchema, FilterHasWordsTestSchema]))
839
+ });
840
+
841
+ export type FilterNotTest = { test: "not"; operand: FilterAllOfTest | FilterAnyOfTest | FilterNotTest | z.infer<typeof FilterHeaderTestSchema> | z.infer<typeof FilterAddressTestSchema> | z.infer<typeof FilterHasWordsTestSchema> };
842
+
843
+ export const FilterNotTestSchema: z.ZodType<FilterNotTest> = z.object({
844
+ test: z.literal("not"),
845
+ operand: z.union([FilterAllOfTestSchema, FilterAnyOfTestSchema, z.lazy(() => FilterNotTestSchema), FilterHeaderTestSchema, FilterAddressTestSchema, FilterHasWordsTestSchema])
846
+ });
847
+
848
+ export const FilterRuleV1Schema = z.object({
849
+ version: z.literal(1),
850
+ test: z.union([FilterAllOfTestSchema, FilterAnyOfTestSchema, FilterNotTestSchema, FilterHeaderTestSchema, FilterAddressTestSchema, FilterHasWordsTestSchema])
851
+ });
852
+
798
853
  export const FilterSchema = z.object({
799
854
  filterId: z.string().min(25).max(25),
800
855
  accountConfigId: z.string().min(25).max(25),
@@ -808,6 +863,7 @@ export const FilterSchema = z.object({
808
863
  actionChangedAt: z.number(),
809
864
  matchOperator: FilterMatchOperatorSchema,
810
865
  literalClauses: z.array(FilterClauseSchema).min(1),
866
+ rule: z.union([FilterRuleV0Schema, FilterRuleV1Schema]),
811
867
  actionLabelId: z.string(),
812
868
  actionMailboxId: z.string(),
813
869
  createdAt: z.number(),
@@ -929,6 +985,7 @@ export const OrganizeJobRequestSchema = z.object({
929
985
  filterId: z.string(),
930
986
  matchOperator: FilterMatchOperatorSchema,
931
987
  literalClauses: z.array(FilterClauseSchema),
988
+ rule: z.union([FilterRuleV0Schema, FilterRuleV1Schema]),
932
989
  actionLabelId: z.string(),
933
990
  actionMailboxId: z.string(),
934
991
  matchedCount: z.number(),
@@ -1298,6 +1355,29 @@ export const ClassificationTestFailedSchema = z.object({
1298
1355
  fix: z.string()
1299
1356
  });
1300
1357
 
1358
+ export const ClassifierCategoryCountSchema = z.object({
1359
+ category: MessageCategorySchema,
1360
+ count: z.number()
1361
+ });
1362
+
1363
+ export const ClassifierLabelCountSchema = z.object({
1364
+ label: ClassificationLabelSchema,
1365
+ count: z.number()
1366
+ });
1367
+
1368
+ export const ClassifierCorrectionsSchema = z.object({
1369
+ spamReportedNotJunk: z.number(),
1370
+ categoryOverridden: z.number()
1371
+ });
1372
+
1373
+ export const ClassifierStatsSchema = z.object({
1374
+ since: z.string(),
1375
+ examined: z.number(),
1376
+ byCategory: z.array(ClassifierCategoryCountSchema),
1377
+ byLabel: z.array(ClassifierLabelCountSchema),
1378
+ corrections: ClassifierCorrectionsSchema
1379
+ });
1380
+
1301
1381
  export const CalendarTaskResponseSchema = z.object({
1302
1382
  calendarTaskId: z.string().min(25).max(25),
1303
1383
  calendarId: z.string().min(25).max(25),
@@ -1923,6 +2003,12 @@ export const MessageFilterMoveSchema = z.object({
1923
2003
  decidedAt: z.number()
1924
2004
  });
1925
2005
 
2006
+ export const ClassifierScoreSchema = z.object({
2007
+ label: ClassificationLabelSchema,
2008
+ confidence: z.number().min(0).max(1),
2009
+ confident: z.boolean()
2010
+ });
2011
+
1926
2012
  export const MessageRecordSchema = z.object({
1927
2013
  messageId: z.string().min(25).max(25),
1928
2014
  mailboxId: z.string().min(25).max(25),
@@ -1949,6 +2035,7 @@ export const MessageRecordSchema = z.object({
1949
2035
  placementVerdict: MessagePlacementVerdictSchema.optional(),
1950
2036
  filterMove: MessageFilterMoveSchema.optional(),
1951
2037
  placementDecidedAt: z.number().optional(),
2038
+ classifierScores: z.array(ClassifierScoreSchema),
1952
2039
  spamReport: MessageSpamReportSchema.optional(),
1953
2040
  createdAt: z.number(),
1954
2041
  updatedAt: z.number()
@@ -1980,6 +2067,7 @@ export const MessageSchema = z.object({
1980
2067
  placementVerdict: MessagePlacementVerdictSchema.optional(),
1981
2068
  filterMove: MessageFilterMoveSchema.optional(),
1982
2069
  placementDecidedAt: z.number().optional(),
2070
+ classifierScores: z.array(ClassifierScoreSchema),
1983
2071
  spamReport: MessageSpamReportSchema.optional(),
1984
2072
  createdAt: z.number(),
1985
2073
  updatedAt: z.number(),