mailery 0.17.1 → 0.18.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.cjs +1501 -332
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +1501 -332
- package/dist/index.js.map +1 -1
- package/dist/{null-DhkTG7mq.d.cts → null-BFipn5tF.d.cts} +146 -3
- package/dist/{null-DhkTG7mq.d.ts → null-BFipn5tF.d.ts} +146 -3
- package/dist/testing.cjs +760 -188
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +5 -2
- package/dist/testing.d.ts +5 -2
- package/dist/testing.js +760 -188
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-BFipn5tF.cjs';
|
|
2
|
+
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactTagDoc, E as EventDoc, q as FlowGoal, r as FlowRunDoc, s as FlowRunStatus, t as FlowVersionDoc, H as HealthDoc, u as HealthStatus, L as LeadDoc, v as MailerConfig, w as NullProvider, O as OutboxDoc, x as RESERVED_VAR_KEYS, y as RedisOptions, z as SegmentDefinition, G as SendDoc, I as SendStatus, J as SenderDomainConfig, K as SenderDomainRegistry, Q as SenderDomainValidation, U as SubscriptionDoc, V as SubscriptionStatus, W as SuppressionDoc, X as SuppressionReason, Y as TemplateKind, Z as TemplateVersionDoc, _ as VarsAdapter, $ as VarsResolveInfo, a0 as WebhookEventDoc, a1 as defineVars, a2 as ensureIndexes, a3 as getCollections, a4 as validateSenderDomain, a5 as varsJsonSchema } from './null-BFipn5tF.cjs';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
@@ -153,14 +153,34 @@ declare class MongoContactAdapter implements ContactAdapter {
|
|
|
153
153
|
getById(externalId: string): Promise<Contact | null>;
|
|
154
154
|
getByEmail(email: string): Promise<Contact | null>;
|
|
155
155
|
getBatch(externalIds: string[]): Promise<Map<string, Contact>>;
|
|
156
|
+
/** `query` honours `opts.sort` — see `querySorted`. */
|
|
157
|
+
readonly supportsSort = true;
|
|
156
158
|
query(filter: AdapterFilter, opts: {
|
|
157
159
|
limit: number;
|
|
158
160
|
cursor?: string;
|
|
161
|
+
sort?: AdapterSort;
|
|
159
162
|
}): Promise<{
|
|
160
163
|
contacts: Contact[];
|
|
161
164
|
nextCursor?: string;
|
|
162
165
|
}>;
|
|
163
166
|
count(filter: AdapterFilter): Promise<number>;
|
|
167
|
+
/**
|
|
168
|
+
* Keyset pagination in (sort.field, idField) order. The cursor encodes the
|
|
169
|
+
* last row's sort value and id, and the next page is every row strictly
|
|
170
|
+
* after that position. Mongo sorts a null or missing value lowest, so
|
|
171
|
+
* `desc` puts contacts without the field last and `asc` puts them first;
|
|
172
|
+
* the position predicate follows the same rule, so they are neither
|
|
173
|
+
* skipped nor repeated.
|
|
174
|
+
*
|
|
175
|
+
* The field should hold one BSON type (or be absent): range operators only
|
|
176
|
+
* compare within a type. A value that moves while a pass is paging (a
|
|
177
|
+
* contact whose `updatedAt` changes mid-dispatch) can be seen twice or not
|
|
178
|
+
* at all in that pass; broadcast dispatch tolerates both (the per-recipient
|
|
179
|
+
* dedupe key stops a second send, and a later pass picks up a skipped one).
|
|
180
|
+
* Index `{ <field>: -1, <idField>: 1 }` on a large collection.
|
|
181
|
+
*/
|
|
182
|
+
private querySorted;
|
|
183
|
+
private afterPosition;
|
|
164
184
|
addTags?: (externalId: string, tags: string[]) => Promise<void>;
|
|
165
185
|
removeTags?: (externalId: string, tags: string[]) => Promise<void>;
|
|
166
186
|
private idFilter;
|
|
@@ -914,16 +934,20 @@ declare function createPublicRouter(mailer: Mailer, opts?: PublicRouterOptions):
|
|
|
914
934
|
* HMAC-signed tokens for unsubscribe + preference-center URLs.
|
|
915
935
|
*
|
|
916
936
|
* Format: base64url(payload) '.' base64url(hmac)
|
|
917
|
-
* payload = JSON.stringify({ e: email, s: scope, x: expiresAtMs })
|
|
937
|
+
* payload = JSON.stringify({ e: email, s: scope, x: expiresAtMs, i?: sendId })
|
|
918
938
|
* hmac = HMAC-SHA256(secret, payload)
|
|
919
939
|
*
|
|
920
|
-
* Tokens expire because long-lived signed URLs are a liability.
|
|
940
|
+
* Tokens expire because long-lived signed URLs are a liability. `i` (0.18+)
|
|
941
|
+
* names the send the link was rendered into, so an unsubscribe can be
|
|
942
|
+
* attributed to it; tokens without it verify exactly as before.
|
|
921
943
|
*/
|
|
922
944
|
|
|
923
945
|
interface UnsubscribeTokenPayload {
|
|
924
946
|
email: string;
|
|
925
947
|
scope: SuppressionScope;
|
|
926
948
|
expiresAt: Date;
|
|
949
|
+
/** The send the link was rendered into (24 hex chars). Optional. */
|
|
950
|
+
sendId?: string;
|
|
927
951
|
}
|
|
928
952
|
declare function signUnsubscribeToken(payload: UnsubscribeTokenPayload, secret: string): string;
|
|
929
953
|
declare function verifyUnsubscribeToken(token: string, secret: string, now?: Date): UnsubscribeTokenPayload | null;
|
|
@@ -1063,4 +1087,4 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
|
1063
1087
|
*/
|
|
1064
1088
|
declare const VERSION: string;
|
|
1065
1089
|
|
|
1066
|
-
export { AdapterFilter, type AdminRouterOptions, type AgentRouterOptions, type AgentToken, type ArmFlowOptions, type ArmFlowResult, Collections, Contact, ContactAdapter, DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, type DedupePolicyOption, DeliveryWindow, type DmarcInboundOptions, type DrainPendingUnsubsOptions, type DrainPendingUnsubsResult, FLOW_STEP_KINDS, FlowDoc, FlowOperationError, FlowStep, type FlowStepKindOption, type GateFlowResult, type InboundAttachment, type InboundParser, MIN_AGENT_TOKEN_LENGTH, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, type RouteLogger, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, type SimulateOptions, type SimulatedStep, type SimulationResult, SuppressionScope, TRACKING_SIG_LENGTH, TemplateDoc, type TrackingScope, type TrackingTokenParams, type UngateFlowResult, VERSION, type VerifyOptions, type VerifyReport, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, gateFlow, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
|
|
1090
|
+
export { AdapterFilter, AdapterSort, type AdminRouterOptions, type AgentRouterOptions, type AgentToken, type ArmFlowOptions, type ArmFlowResult, Collections, Contact, ContactAdapter, DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, type DedupePolicyOption, DeliveryWindow, type DmarcInboundOptions, type DrainPendingUnsubsOptions, type DrainPendingUnsubsResult, FLOW_STEP_KINDS, FlowDoc, FlowOperationError, FlowStep, type FlowStepKindOption, type GateFlowResult, type InboundAttachment, type InboundParser, MIN_AGENT_TOKEN_LENGTH, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, type RouteLogger, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, type SimulateOptions, type SimulatedStep, type SimulationResult, SuppressionScope, TRACKING_SIG_LENGTH, TemplateDoc, type TrackingScope, type TrackingTokenParams, type UngateFlowResult, VERSION, type VerifyOptions, type VerifyReport, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, gateFlow, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, b as AdapterSort, M as MailProvider, S as SendArgs, c as SendResult, d as MailTesterFeedback, e as Mailer, T as TemplateDoc, F as FlowStep, f as Collections, g as FlowDoc, h as SuppressionScope, D as DeliveryWindow, i as SegmentFilter, P as Predicate } from './null-BFipn5tF.js';
|
|
2
|
+
export { j as AuditLogDoc, B as BotFilterConfig, k as BroadcastDoc, l as BroadcastOrder, m as BroadcastPauseReason, n as BroadcastStatus, o as CircuitBreakerThresholds, p as ContactTagDoc, E as EventDoc, q as FlowGoal, r as FlowRunDoc, s as FlowRunStatus, t as FlowVersionDoc, H as HealthDoc, u as HealthStatus, L as LeadDoc, v as MailerConfig, w as NullProvider, O as OutboxDoc, x as RESERVED_VAR_KEYS, y as RedisOptions, z as SegmentDefinition, G as SendDoc, I as SendStatus, J as SenderDomainConfig, K as SenderDomainRegistry, Q as SenderDomainValidation, U as SubscriptionDoc, V as SubscriptionStatus, W as SuppressionDoc, X as SuppressionReason, Y as TemplateKind, Z as TemplateVersionDoc, _ as VarsAdapter, $ as VarsResolveInfo, a0 as WebhookEventDoc, a1 as defineVars, a2 as ensureIndexes, a3 as getCollections, a4 as validateSenderDomain, a5 as varsJsonSchema } from './null-BFipn5tF.js';
|
|
3
3
|
import { ObjectId, Db, Filter } from 'mongodb';
|
|
4
4
|
import { Request, Router } from 'express';
|
|
5
5
|
import Handlebars from 'handlebars';
|
|
@@ -153,14 +153,34 @@ declare class MongoContactAdapter implements ContactAdapter {
|
|
|
153
153
|
getById(externalId: string): Promise<Contact | null>;
|
|
154
154
|
getByEmail(email: string): Promise<Contact | null>;
|
|
155
155
|
getBatch(externalIds: string[]): Promise<Map<string, Contact>>;
|
|
156
|
+
/** `query` honours `opts.sort` — see `querySorted`. */
|
|
157
|
+
readonly supportsSort = true;
|
|
156
158
|
query(filter: AdapterFilter, opts: {
|
|
157
159
|
limit: number;
|
|
158
160
|
cursor?: string;
|
|
161
|
+
sort?: AdapterSort;
|
|
159
162
|
}): Promise<{
|
|
160
163
|
contacts: Contact[];
|
|
161
164
|
nextCursor?: string;
|
|
162
165
|
}>;
|
|
163
166
|
count(filter: AdapterFilter): Promise<number>;
|
|
167
|
+
/**
|
|
168
|
+
* Keyset pagination in (sort.field, idField) order. The cursor encodes the
|
|
169
|
+
* last row's sort value and id, and the next page is every row strictly
|
|
170
|
+
* after that position. Mongo sorts a null or missing value lowest, so
|
|
171
|
+
* `desc` puts contacts without the field last and `asc` puts them first;
|
|
172
|
+
* the position predicate follows the same rule, so they are neither
|
|
173
|
+
* skipped nor repeated.
|
|
174
|
+
*
|
|
175
|
+
* The field should hold one BSON type (or be absent): range operators only
|
|
176
|
+
* compare within a type. A value that moves while a pass is paging (a
|
|
177
|
+
* contact whose `updatedAt` changes mid-dispatch) can be seen twice or not
|
|
178
|
+
* at all in that pass; broadcast dispatch tolerates both (the per-recipient
|
|
179
|
+
* dedupe key stops a second send, and a later pass picks up a skipped one).
|
|
180
|
+
* Index `{ <field>: -1, <idField>: 1 }` on a large collection.
|
|
181
|
+
*/
|
|
182
|
+
private querySorted;
|
|
183
|
+
private afterPosition;
|
|
164
184
|
addTags?: (externalId: string, tags: string[]) => Promise<void>;
|
|
165
185
|
removeTags?: (externalId: string, tags: string[]) => Promise<void>;
|
|
166
186
|
private idFilter;
|
|
@@ -914,16 +934,20 @@ declare function createPublicRouter(mailer: Mailer, opts?: PublicRouterOptions):
|
|
|
914
934
|
* HMAC-signed tokens for unsubscribe + preference-center URLs.
|
|
915
935
|
*
|
|
916
936
|
* Format: base64url(payload) '.' base64url(hmac)
|
|
917
|
-
* payload = JSON.stringify({ e: email, s: scope, x: expiresAtMs })
|
|
937
|
+
* payload = JSON.stringify({ e: email, s: scope, x: expiresAtMs, i?: sendId })
|
|
918
938
|
* hmac = HMAC-SHA256(secret, payload)
|
|
919
939
|
*
|
|
920
|
-
* Tokens expire because long-lived signed URLs are a liability.
|
|
940
|
+
* Tokens expire because long-lived signed URLs are a liability. `i` (0.18+)
|
|
941
|
+
* names the send the link was rendered into, so an unsubscribe can be
|
|
942
|
+
* attributed to it; tokens without it verify exactly as before.
|
|
921
943
|
*/
|
|
922
944
|
|
|
923
945
|
interface UnsubscribeTokenPayload {
|
|
924
946
|
email: string;
|
|
925
947
|
scope: SuppressionScope;
|
|
926
948
|
expiresAt: Date;
|
|
949
|
+
/** The send the link was rendered into (24 hex chars). Optional. */
|
|
950
|
+
sendId?: string;
|
|
927
951
|
}
|
|
928
952
|
declare function signUnsubscribeToken(payload: UnsubscribeTokenPayload, secret: string): string;
|
|
929
953
|
declare function verifyUnsubscribeToken(token: string, secret: string, now?: Date): UnsubscribeTokenPayload | null;
|
|
@@ -1063,4 +1087,4 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
|
|
|
1063
1087
|
*/
|
|
1064
1088
|
declare const VERSION: string;
|
|
1065
1089
|
|
|
1066
|
-
export { AdapterFilter, type AdminRouterOptions, type AgentRouterOptions, type AgentToken, type ArmFlowOptions, type ArmFlowResult, Collections, Contact, ContactAdapter, DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, type DedupePolicyOption, DeliveryWindow, type DmarcInboundOptions, type DrainPendingUnsubsOptions, type DrainPendingUnsubsResult, FLOW_STEP_KINDS, FlowDoc, FlowOperationError, FlowStep, type FlowStepKindOption, type GateFlowResult, type InboundAttachment, type InboundParser, MIN_AGENT_TOKEN_LENGTH, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, type RouteLogger, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, type SimulateOptions, type SimulatedStep, type SimulationResult, SuppressionScope, TRACKING_SIG_LENGTH, TemplateDoc, type TrackingScope, type TrackingTokenParams, type UngateFlowResult, VERSION, type VerifyOptions, type VerifyReport, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, gateFlow, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
|
|
1090
|
+
export { AdapterFilter, AdapterSort, type AdminRouterOptions, type AgentRouterOptions, type AgentToken, type ArmFlowOptions, type ArmFlowResult, Collections, Contact, ContactAdapter, DEDUPE_POLICIES, DEFAULT_BOT_UA_RE, type DedupePolicyOption, DeliveryWindow, type DmarcInboundOptions, type DrainPendingUnsubsOptions, type DrainPendingUnsubsResult, FLOW_STEP_KINDS, FlowDoc, FlowOperationError, FlowStep, type FlowStepKindOption, type GateFlowResult, type InboundAttachment, type InboundParser, MIN_AGENT_TOKEN_LENGTH, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, type RouteLogger, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, type SimulateOptions, type SimulatedStep, type SimulationResult, SuppressionScope, TRACKING_SIG_LENGTH, TemplateDoc, type TrackingScope, type TrackingTokenParams, type UngateFlowResult, VERSION, type VerifyOptions, type VerifyReport, applyTracking, applyWebhookEvent, armFlow, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminApiRouter, createAdminRouter, createAgentRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, disarmFlow, dispatchSend, drainPendingUnsubscribes, gateFlow, isCanaryGate, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, referencedPaths, renderForContact, renderTemplate, runTick, sendgridInboundParser, sha256Hex, signTrackingToken, signUnsubscribeToken, simulateFlow, stampWatermarkIfNull, sweepStrandedFlowRuns, ungateFlow, verifyTemplate, verifyTrackingToken, verifyUnsubscribeToken };
|