mailery 0.16.5 → 0.16.6

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.cjs CHANGED
@@ -8271,7 +8271,11 @@ function unitToMs2(value, unit) {
8271
8271
  }
8272
8272
 
8273
8273
  // src/server/api/agent.ts
8274
- var VERSION = "0.16.5" ;
8274
+ var VERSION = "0.16.6" ;
8275
+ var agentTagsInputSchema = zod.z.object({
8276
+ add: zod.z.array(zod.z.string().min(1).max(128)).max(25).default([]),
8277
+ remove: zod.z.array(zod.z.string().min(1).max(128)).max(25).default([])
8278
+ });
8275
8279
  var publishTemplateInputSchema = zod.z.object({
8276
8280
  name: zod.z.string().min(1).max(200),
8277
8281
  description: zod.z.string().max(2e3).default(""),
@@ -8875,6 +8879,41 @@ function createAgentRouter(mailer, opts) {
8875
8879
  res.json({ subscription: sub });
8876
8880
  })
8877
8881
  );
8882
+ router.post(
8883
+ "/contacts/:externalId/tags",
8884
+ wrap2(async (req, res) => {
8885
+ const contact = await loadContact(res, String(req.params.externalId));
8886
+ if (!contact) return;
8887
+ if (!guardTestContact(res, contact)) return;
8888
+ const parsed = agentTagsInputSchema.safeParse(req.body ?? {});
8889
+ if (!parsed.success) {
8890
+ return res.status(400).json({ error: "validation_failed", issues: parsed.error.issues });
8891
+ }
8892
+ const { add, remove } = parsed.data;
8893
+ if (add.length === 0 && remove.length === 0) {
8894
+ return res.status(400).json({ error: "no_tags", message: "Pass {add: [...]} and/or {remove: [...]}." });
8895
+ }
8896
+ const overlap = add.filter((t) => remove.includes(t));
8897
+ if (overlap.length > 0) {
8898
+ return res.status(400).json({ error: "tag_conflict", tags: overlap });
8899
+ }
8900
+ for (const tag of add) await mailer.tag(contact.externalId, tag);
8901
+ for (const tag of remove) await mailer.untag(contact.externalId, tag);
8902
+ const after = await mailer.adapter.getById(contact.externalId);
8903
+ await mailer.audit({
8904
+ actor: actorOf(req),
8905
+ action: "agent.contact.tags",
8906
+ resource: { collection: "contacts", id: contact.externalId },
8907
+ diffSummary: `${contact.email}: ${add.length ? `+${add.join(", +")}` : ""}${add.length && remove.length ? " " : ""}${remove.length ? `-${remove.join(", -")}` : ""}`
8908
+ });
8909
+ res.json({
8910
+ contact: { externalId: contact.externalId, email: contact.email },
8911
+ added: add,
8912
+ removed: remove,
8913
+ tags: after?.tags ?? []
8914
+ });
8915
+ })
8916
+ );
8878
8917
  router.post(
8879
8918
  "/contacts/:externalId/reset",
8880
8919
  wrap2(async (req, res) => {
@@ -9393,6 +9432,7 @@ var ENDPOINTS = [
9393
9432
  { method: "GET", path: "/contacts/:externalId/unsubscribe-url", summary: "A signed one-click unsubscribe URL for a test contact, to exercise POST /m/unsub/:token.", testContactsOnly: true },
9394
9433
  { method: "POST", path: "/contacts/:externalId/subscribe", summary: "Subscribe a test contact.", testContactsOnly: true },
9395
9434
  { method: "POST", path: "/contacts/:externalId/unsubscribe", summary: "Unsubscribe a test contact (marketing scope).", testContactsOnly: true },
9435
+ { method: "POST", path: "/contacts/:externalId/tags", summary: "Add or remove tags on a test contact ({add: [...], remove: [...]}), so a gated flow lets it through.", testContactsOnly: true },
9396
9436
  { method: "POST", path: "/contacts/:externalId/reset", summary: "Delete a test contact's runs, sends, events ({events: [names]} to narrow) and suppressions, then resubscribe. Each part can be turned off with false.", testContactsOnly: true },
9397
9437
  { method: "POST", path: "/tick", summary: "Run the runner tick now (trigger scan, sweeps, outbox, webhook backlog)." },
9398
9438
  { method: "GET", path: "/webhooks/status", summary: "Provider webhook ingest: last event received, counts by type (24h), unprocessed backlog." },
@@ -10109,7 +10149,7 @@ var DEDUPE_POLICIES = [
10109
10149
  ];
10110
10150
 
10111
10151
  // src/server/index.ts
10112
- var VERSION2 = "0.16.5" ;
10152
+ var VERSION2 = "0.16.6" ;
10113
10153
 
10114
10154
  exports.DEDUPE_POLICIES = DEDUPE_POLICIES;
10115
10155
  exports.DEFAULT_BOT_UA_RE = DEFAULT_BOT_UA_RE;