mailery 0.5.1 → 0.7.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.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, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-BYB6v4Iv.cjs';
2
- export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RedisOptions, u as SegmentDefinition, v as SendDoc, w as SendStatus, x as SenderDomainConfig, y as SenderDomainRegistry, z as SenderDomainValidation, D as SubscriptionDoc, G as SubscriptionStatus, I as SuppressionDoc, J as SuppressionReason, K as TemplateKind, Q as TemplateVersionDoc, W as WebhookEventDoc, U as ensureIndexes, V as getCollections, X as validateSenderDomain } from './null-BYB6v4Iv.cjs';
1
+ import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-B0rPgE5_.cjs';
2
+ export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-B0rPgE5_.cjs';
3
3
  import { ObjectId, Db, Filter } from 'mongodb';
4
4
  import { Request, Router } from 'express';
5
5
  import Handlebars from 'handlebars';
@@ -250,8 +250,16 @@ declare function compileMailyTemplate(content: unknown): Promise<CompileResult>;
250
250
  /** Auto-derive plain text from compiled HTML. */
251
251
  declare function derivePlaintext(html: string): string;
252
252
  interface RenderContext {
253
+ /**
254
+ * Host-resolved variables (varsAdapter) live at the context root, so a
255
+ * schema key `user` renders as `{{user.name}}`. Reserved keys below always
256
+ * win over resolved keys.
257
+ */
258
+ [resolvedVar: string]: unknown;
253
259
  contact: Contact;
254
260
  vars: Record<string, unknown>;
261
+ /** Properties of the event that triggered the flow run ({{event.*}}). Empty outside flow sends. */
262
+ event?: Record<string, unknown>;
255
263
  /** URL the recipient hits to one-click unsubscribe. */
256
264
  unsubscribeUrl: string;
257
265
  /** URL to view this email in a browser (when implemented). */
@@ -325,6 +333,20 @@ declare function verifyUnsubscribeToken(token: string, secret: string, now?: Dat
325
333
  */
326
334
  declare function sha256Hex(input: string): string;
327
335
 
336
+ /**
337
+ * Delivery-window math. Pure — no I/O, no Date.now(); callers pass `now`.
338
+ *
339
+ * Given the moment a send step becomes runnable, `computeDeliveryTime`
340
+ * returns the earliest instant the email is allowed to go out. It only ever
341
+ * moves forward: a send already inside its window returns `now` unchanged.
342
+ *
343
+ * Timezone handling uses the Intl API (no dependency). DST transitions are
344
+ * resolved with a two-pass offset fix; the worst case during a transition is
345
+ * being off by the shifted hour, which is fine for email delivery.
346
+ */
347
+
348
+ declare function computeDeliveryTime(now: Date, window: DeliveryWindow, contactTimezone?: string): Date;
349
+
328
350
  /**
329
351
  * Enumerable option lists for the union types in `./types.ts`. Used by the
330
352
  * admin client to render dropdowns + by tooling to enumerate the surface.
@@ -376,6 +398,6 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
376
398
  /**
377
399
  * Public exports for the `mailery` package.
378
400
  */
379
- declare const VERSION = "0.1.0";
401
+ declare const VERSION = "0.7.0";
380
402
 
381
- export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
403
+ export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, DeliveryWindow, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, 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, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-BYB6v4Iv.js';
2
- export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RedisOptions, u as SegmentDefinition, v as SendDoc, w as SendStatus, x as SenderDomainConfig, y as SenderDomainRegistry, z as SenderDomainValidation, D as SubscriptionDoc, G as SubscriptionStatus, I as SuppressionDoc, J as SuppressionReason, K as TemplateKind, Q as TemplateVersionDoc, W as WebhookEventDoc, U as ensureIndexes, V as getCollections, X as validateSenderDomain } from './null-BYB6v4Iv.js';
1
+ import { R as RunnerContext, N as NormalizedEvent, C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, c as MailTesterFeedback, d as Mailer, T as TemplateDoc, e as SuppressionScope, D as DeliveryWindow, F as FlowStep, f as SegmentFilter, P as Predicate } from './null-B0rPgE5_.js';
2
+ export { g as AuditLogDoc, B as BroadcastDoc, h as BroadcastStatus, i as CircuitBreakerThresholds, j as Collections, k as ContactTagDoc, E as EventDoc, l as FlowDoc, m as FlowGoal, n as FlowRunDoc, o as FlowRunStatus, p as FlowVersionDoc, H as HealthDoc, q as HealthStatus, L as LeadDoc, r as MailerConfig, s as NullProvider, O as OutboxDoc, t as RESERVED_VAR_KEYS, u as RedisOptions, v as SegmentDefinition, w as SendDoc, x as SendStatus, y as SenderDomainConfig, z as SenderDomainRegistry, G as SenderDomainValidation, I as SubscriptionDoc, J as SubscriptionStatus, K as SuppressionDoc, Q as SuppressionReason, U as TemplateKind, V as TemplateVersionDoc, W as VarsAdapter, X as VarsResolveInfo, Y as WebhookEventDoc, Z as defineVars, _ as ensureIndexes, $ as getCollections, a0 as validateSenderDomain, a1 as varsJsonSchema } from './null-B0rPgE5_.js';
3
3
  import { ObjectId, Db, Filter } from 'mongodb';
4
4
  import { Request, Router } from 'express';
5
5
  import Handlebars from 'handlebars';
@@ -250,8 +250,16 @@ declare function compileMailyTemplate(content: unknown): Promise<CompileResult>;
250
250
  /** Auto-derive plain text from compiled HTML. */
251
251
  declare function derivePlaintext(html: string): string;
252
252
  interface RenderContext {
253
+ /**
254
+ * Host-resolved variables (varsAdapter) live at the context root, so a
255
+ * schema key `user` renders as `{{user.name}}`. Reserved keys below always
256
+ * win over resolved keys.
257
+ */
258
+ [resolvedVar: string]: unknown;
253
259
  contact: Contact;
254
260
  vars: Record<string, unknown>;
261
+ /** Properties of the event that triggered the flow run ({{event.*}}). Empty outside flow sends. */
262
+ event?: Record<string, unknown>;
255
263
  /** URL the recipient hits to one-click unsubscribe. */
256
264
  unsubscribeUrl: string;
257
265
  /** URL to view this email in a browser (when implemented). */
@@ -325,6 +333,20 @@ declare function verifyUnsubscribeToken(token: string, secret: string, now?: Dat
325
333
  */
326
334
  declare function sha256Hex(input: string): string;
327
335
 
336
+ /**
337
+ * Delivery-window math. Pure — no I/O, no Date.now(); callers pass `now`.
338
+ *
339
+ * Given the moment a send step becomes runnable, `computeDeliveryTime`
340
+ * returns the earliest instant the email is allowed to go out. It only ever
341
+ * moves forward: a send already inside its window returns `now` unchanged.
342
+ *
343
+ * Timezone handling uses the Intl API (no dependency). DST transitions are
344
+ * resolved with a two-pass offset fix; the worst case during a transition is
345
+ * being off by the shifted hour, which is fine for email delivery.
346
+ */
347
+
348
+ declare function computeDeliveryTime(now: Date, window: DeliveryWindow, contactTimezone?: string): Date;
349
+
328
350
  /**
329
351
  * Enumerable option lists for the union types in `./types.ts`. Used by the
330
352
  * admin client to render dropdowns + by tooling to enumerate the surface.
@@ -376,6 +398,6 @@ declare const DEDUPE_POLICIES: readonly DedupePolicyOption[];
376
398
  /**
377
399
  * Public exports for the `mailery` package.
378
400
  */
379
- declare const VERSION = "0.1.0";
401
+ declare const VERSION = "0.7.0";
380
402
 
381
- export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };
403
+ export { AdapterFilter, type AdminRouterOptions, Contact, ContactAdapter, DEDUPE_POLICIES, type DedupePolicyOption, DeliveryWindow, FLOW_STEP_KINDS, FlowStep, type FlowStepKindOption, MailProvider, Mailer, MongoContactAdapter, type MongoContactAdapterOptions, NormalizedEvent, PREDICATE_KINDS, Predicate, type PredicateKind, type PredicateKindOption, type PublicRouterOptions, SEGMENT_FILTER_KINDS, SegmentFilter, type SegmentFilterKind, type SegmentFilterKindOption, SendArgs, SendGridProvider, type SendGridProviderOptions, SendResult, SuppressionScope, TemplateDoc, VERSION, applyTracking, applyWebhookEvent, compileMailyTemplate, compileTemplate, computeDeliveryTime, createAdminRouter, createPublicRouter, defaultFlowStep, defaultPredicate, defaultSegmentFilter, derivePlaintext, dispatchSend, predicateKind, processNewlyFiredEventTriggers, processOneRunStep, renderTemplate, runTick, sha256Hex, signUnsubscribeToken, sweepStrandedFlowRuns, verifyUnsubscribeToken };