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.js CHANGED
@@ -8253,7 +8253,11 @@ function unitToMs2(value, unit) {
8253
8253
  }
8254
8254
 
8255
8255
  // src/server/api/agent.ts
8256
- var VERSION = "0.16.5" ;
8256
+ var VERSION = "0.16.6" ;
8257
+ var agentTagsInputSchema = z.object({
8258
+ add: z.array(z.string().min(1).max(128)).max(25).default([]),
8259
+ remove: z.array(z.string().min(1).max(128)).max(25).default([])
8260
+ });
8257
8261
  var publishTemplateInputSchema = z.object({
8258
8262
  name: z.string().min(1).max(200),
8259
8263
  description: z.string().max(2e3).default(""),
@@ -8857,6 +8861,41 @@ function createAgentRouter(mailer, opts) {
8857
8861
  res.json({ subscription: sub });
8858
8862
  })
8859
8863
  );
8864
+ router.post(
8865
+ "/contacts/:externalId/tags",
8866
+ wrap2(async (req, res) => {
8867
+ const contact = await loadContact(res, String(req.params.externalId));
8868
+ if (!contact) return;
8869
+ if (!guardTestContact(res, contact)) return;
8870
+ const parsed = agentTagsInputSchema.safeParse(req.body ?? {});
8871
+ if (!parsed.success) {
8872
+ return res.status(400).json({ error: "validation_failed", issues: parsed.error.issues });
8873
+ }
8874
+ const { add, remove } = parsed.data;
8875
+ if (add.length === 0 && remove.length === 0) {
8876
+ return res.status(400).json({ error: "no_tags", message: "Pass {add: [...]} and/or {remove: [...]}." });
8877
+ }
8878
+ const overlap = add.filter((t) => remove.includes(t));
8879
+ if (overlap.length > 0) {
8880
+ return res.status(400).json({ error: "tag_conflict", tags: overlap });
8881
+ }
8882
+ for (const tag of add) await mailer.tag(contact.externalId, tag);
8883
+ for (const tag of remove) await mailer.untag(contact.externalId, tag);
8884
+ const after = await mailer.adapter.getById(contact.externalId);
8885
+ await mailer.audit({
8886
+ actor: actorOf(req),
8887
+ action: "agent.contact.tags",
8888
+ resource: { collection: "contacts", id: contact.externalId },
8889
+ diffSummary: `${contact.email}: ${add.length ? `+${add.join(", +")}` : ""}${add.length && remove.length ? " " : ""}${remove.length ? `-${remove.join(", -")}` : ""}`
8890
+ });
8891
+ res.json({
8892
+ contact: { externalId: contact.externalId, email: contact.email },
8893
+ added: add,
8894
+ removed: remove,
8895
+ tags: after?.tags ?? []
8896
+ });
8897
+ })
8898
+ );
8860
8899
  router.post(
8861
8900
  "/contacts/:externalId/reset",
8862
8901
  wrap2(async (req, res) => {
@@ -9375,6 +9414,7 @@ var ENDPOINTS = [
9375
9414
  { 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 },
9376
9415
  { method: "POST", path: "/contacts/:externalId/subscribe", summary: "Subscribe a test contact.", testContactsOnly: true },
9377
9416
  { method: "POST", path: "/contacts/:externalId/unsubscribe", summary: "Unsubscribe a test contact (marketing scope).", testContactsOnly: true },
9417
+ { 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 },
9378
9418
  { 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 },
9379
9419
  { method: "POST", path: "/tick", summary: "Run the runner tick now (trigger scan, sweeps, outbox, webhook backlog)." },
9380
9420
  { method: "GET", path: "/webhooks/status", summary: "Provider webhook ingest: last event received, counts by type (24h), unprocessed backlog." },
@@ -10091,7 +10131,7 @@ var DEDUPE_POLICIES = [
10091
10131
  ];
10092
10132
 
10093
10133
  // src/server/index.ts
10094
- var VERSION2 = "0.16.5" ;
10134
+ var VERSION2 = "0.16.6" ;
10095
10135
 
10096
10136
  export { DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, FLOW_STEP_KINDS, FlowOperationError, MIN_AGENT_TOKEN_LENGTH, Mailer, MongoContactAdapter, NullProvider, PREDICATE_KINDS, RESERVED_VAR_KEYS, SEGMENT_FILTER_KINDS, SendGridProvider, TRACKING_SIG_LENGTH, VERSION2 as VERSION, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, defineVars, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, ensureIndexes, gateFlow, getCollections, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, validateSenderDomain, varsJsonSchema, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
10097
10137
  //# sourceMappingURL=index.js.map