@marlinjai/mail-contract 0.8.1 → 0.10.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/dist/index.js CHANGED
@@ -382,6 +382,8 @@ __export(index_exports, {
382
382
  TEMPLATE_INPUT_KINDS: () => TEMPLATE_INPUT_KINDS,
383
383
  TEMPLATE_INPUT_PROBLEM_REASONS: () => TEMPLATE_INPUT_PROBLEM_REASONS,
384
384
  TEMPLATE_LANGUAGE_STATUSES: () => TEMPLATE_LANGUAGE_STATUSES,
385
+ TEMPLATE_SORTS: () => TEMPLATE_SORTS,
386
+ TEMPLATE_SORT_DEFAULT_ORDER: () => TEMPLATE_SORT_DEFAULT_ORDER,
385
387
  TERMINAL_MAILING_STATUSES: () => TERMINAL_MAILING_STATUSES,
386
388
  Tag: () => Tag,
387
389
  TagAssignment: () => TagAssignment,
@@ -390,6 +392,7 @@ __export(index_exports, {
390
392
  TemplateCompileRequest: () => TemplateCompileRequest,
391
393
  TemplateCreate: () => TemplateCreate,
392
394
  TemplateCreatedData: () => TemplateCreatedData,
395
+ TemplateDeleteQuery: () => TemplateDeleteQuery,
393
396
  TemplateDeletedData: () => TemplateDeletedData,
394
397
  TemplateDocument: () => TemplateDocument,
395
398
  TemplateExportQuery: () => TemplateExportQuery,
@@ -1287,8 +1290,15 @@ var SavedSectionUpdate = import_zod5.z.object({
1287
1290
  description: import_zod5.z.string().max(2e3).nullable().optional(),
1288
1291
  section: SavedSectionBody.optional()
1289
1292
  }).refine((v) => v.name !== void 0 || v.description !== void 0 || v.section !== void 0, "at least one field");
1293
+ var TemplateDeleteQuery = import_zod5.z.object({
1294
+ base_version: import_zod5.z.coerce.number().int().min(1).optional()
1295
+ });
1296
+ var TEMPLATE_SORTS = ["updated_at", "name", "version"];
1297
+ var TEMPLATE_SORT_DEFAULT_ORDER = { updated_at: "desc", name: "asc", version: "desc" };
1290
1298
  var TemplateListQuery = PageQuery.extend({
1291
- archived: import_zod5.z.enum(["true", "false"]).optional()
1299
+ archived: import_zod5.z.enum(["true", "false"]).optional(),
1300
+ sort: import_zod5.z.enum(TEMPLATE_SORTS).optional(),
1301
+ order: import_zod5.z.enum(["asc", "desc"]).optional()
1292
1302
  });
1293
1303
  var TemplateVersion = import_zod5.z.object({
1294
1304
  template_id: Id,
@@ -1567,6 +1577,14 @@ var Mailing = import_zod7.z.object({
1567
1577
  * language: without a ready version in it, the main language goes out.
1568
1578
  */
1569
1579
  send_locale: LocaleTag.nullable(),
1580
+ /**
1581
+ * The template's language version the mailing was written from
1582
+ * (`MailingCreate.template_locale`), or null. When set, it equals `locale`
1583
+ * and `send_locale`: the mailing is one letter in that language, and the
1584
+ * template's other versions never go out with it (see "Writing from one
1585
+ * language version" in the contract's documentation).
1586
+ */
1587
+ template_locale: LocaleTag.nullable().default(null),
1570
1588
  /**
1571
1589
  * The topic the mailing is sent under. Null for a letter (a one-to-one
1572
1590
  * mailing with at most one recipient, which belongs to no topic and whose
@@ -1613,10 +1631,14 @@ var MailingCreate = import_zod7.z.object({
1613
1631
  ...MailingContent,
1614
1632
  subject: MailingContent.subject.optional(),
1615
1633
  document: TemplateDocument.optional(),
1616
- template_id: Id.optional()
1634
+ template_id: Id.optional(),
1635
+ template_locale: LocaleTag.optional()
1617
1636
  }).refine((v) => v.document === void 0 !== (v.template_id === void 0), {
1618
1637
  message: "exactly one of document or template_id",
1619
1638
  path: ["document"]
1639
+ }).refine((v) => v.template_locale === void 0 || v.template_id !== void 0, {
1640
+ message: "template_locale names a version of template_id",
1641
+ path: ["template_locale"]
1620
1642
  }).refine((v) => v.template_id !== void 0 || v.subject !== void 0, {
1621
1643
  message: "a mailing made from a document needs a subject",
1622
1644
  path: ["subject"]
@@ -4894,6 +4916,7 @@ var templateRoutes = {
4894
4916
  method: "DELETE",
4895
4917
  path: "/v1/templates/:id",
4896
4918
  params: IdParams,
4919
+ query: TemplateDeleteQuery,
4897
4920
  response: Ok,
4898
4921
  status: 200,
4899
4922
  access: "write",
@@ -6473,6 +6496,8 @@ function matchRoute(method, pathname) {
6473
6496
  TEMPLATE_INPUT_KINDS,
6474
6497
  TEMPLATE_INPUT_PROBLEM_REASONS,
6475
6498
  TEMPLATE_LANGUAGE_STATUSES,
6499
+ TEMPLATE_SORTS,
6500
+ TEMPLATE_SORT_DEFAULT_ORDER,
6476
6501
  TERMINAL_MAILING_STATUSES,
6477
6502
  Tag,
6478
6503
  TagAssignment,
@@ -6481,6 +6506,7 @@ function matchRoute(method, pathname) {
6481
6506
  TemplateCompileRequest,
6482
6507
  TemplateCreate,
6483
6508
  TemplateCreatedData,
6509
+ TemplateDeleteQuery,
6484
6510
  TemplateDeletedData,
6485
6511
  TemplateDocument,
6486
6512
  TemplateExportQuery,
package/dist/index.mjs CHANGED
@@ -690,8 +690,15 @@ var SavedSectionUpdate = z5.object({
690
690
  description: z5.string().max(2e3).nullable().optional(),
691
691
  section: SavedSectionBody.optional()
692
692
  }).refine((v) => v.name !== void 0 || v.description !== void 0 || v.section !== void 0, "at least one field");
693
+ var TemplateDeleteQuery = z5.object({
694
+ base_version: z5.coerce.number().int().min(1).optional()
695
+ });
696
+ var TEMPLATE_SORTS = ["updated_at", "name", "version"];
697
+ var TEMPLATE_SORT_DEFAULT_ORDER = { updated_at: "desc", name: "asc", version: "desc" };
693
698
  var TemplateListQuery = PageQuery.extend({
694
- archived: z5.enum(["true", "false"]).optional()
699
+ archived: z5.enum(["true", "false"]).optional(),
700
+ sort: z5.enum(TEMPLATE_SORTS).optional(),
701
+ order: z5.enum(["asc", "desc"]).optional()
695
702
  });
696
703
  var TemplateVersion = z5.object({
697
704
  template_id: Id,
@@ -970,6 +977,14 @@ var Mailing = z7.object({
970
977
  * language: without a ready version in it, the main language goes out.
971
978
  */
972
979
  send_locale: LocaleTag.nullable(),
980
+ /**
981
+ * The template's language version the mailing was written from
982
+ * (`MailingCreate.template_locale`), or null. When set, it equals `locale`
983
+ * and `send_locale`: the mailing is one letter in that language, and the
984
+ * template's other versions never go out with it (see "Writing from one
985
+ * language version" in the contract's documentation).
986
+ */
987
+ template_locale: LocaleTag.nullable().default(null),
973
988
  /**
974
989
  * The topic the mailing is sent under. Null for a letter (a one-to-one
975
990
  * mailing with at most one recipient, which belongs to no topic and whose
@@ -1016,10 +1031,14 @@ var MailingCreate = z7.object({
1016
1031
  ...MailingContent,
1017
1032
  subject: MailingContent.subject.optional(),
1018
1033
  document: TemplateDocument.optional(),
1019
- template_id: Id.optional()
1034
+ template_id: Id.optional(),
1035
+ template_locale: LocaleTag.optional()
1020
1036
  }).refine((v) => v.document === void 0 !== (v.template_id === void 0), {
1021
1037
  message: "exactly one of document or template_id",
1022
1038
  path: ["document"]
1039
+ }).refine((v) => v.template_locale === void 0 || v.template_id !== void 0, {
1040
+ message: "template_locale names a version of template_id",
1041
+ path: ["template_locale"]
1023
1042
  }).refine((v) => v.template_id !== void 0 || v.subject !== void 0, {
1024
1043
  message: "a mailing made from a document needs a subject",
1025
1044
  path: ["subject"]
@@ -4297,6 +4316,7 @@ var templateRoutes = {
4297
4316
  method: "DELETE",
4298
4317
  path: "/v1/templates/:id",
4299
4318
  params: IdParams,
4319
+ query: TemplateDeleteQuery,
4300
4320
  response: Ok,
4301
4321
  status: 200,
4302
4322
  access: "write",
@@ -5875,6 +5895,8 @@ export {
5875
5895
  TEMPLATE_INPUT_KINDS,
5876
5896
  TEMPLATE_INPUT_PROBLEM_REASONS,
5877
5897
  TEMPLATE_LANGUAGE_STATUSES,
5898
+ TEMPLATE_SORTS,
5899
+ TEMPLATE_SORT_DEFAULT_ORDER,
5878
5900
  TERMINAL_MAILING_STATUSES,
5879
5901
  Tag,
5880
5902
  TagAssignment,
@@ -5883,6 +5905,7 @@ export {
5883
5905
  TemplateCompileRequest,
5884
5906
  TemplateCreate,
5885
5907
  TemplateCreatedData,
5908
+ TemplateDeleteQuery,
5886
5909
  TemplateDeletedData,
5887
5910
  TemplateDocument,
5888
5911
  TemplateExportQuery,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.8.1",
6
+ "version": "0.10.0",
7
7
  "description": "The v1 API contract of the mail service: zod schemas and types for every request, response, error and webhook, the route table, and webhook signing helpers",
8
8
  "license": "MIT",
9
9
  "repository": {