sendlit 0.2.0 → 0.3.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.mjs CHANGED
@@ -586,10 +586,204 @@ var sendingOptionSchema = z.discriminatedUnion("type", [
586
586
  countsAgainstQuota: z.literal(false)
587
587
  })
588
588
  ]);
589
+ var EVENT_NAME_MAX_LENGTH = 128;
590
+ var EVENT_PROPERTIES_MAX_BYTES = 32 * 1024;
591
+ var EVENT_PROPERTIES_MAX_KEYS = 100;
592
+ var EVENT_PROPERTIES_MAX_DEPTH = 3;
593
+ var EVENT_FILTER_MAX_CONDITIONS = 10;
594
+ var EVENT_MAX_FUTURE_MS = 24 * 60 * 60 * 1e3;
595
+ var eventPropertyKeyPattern = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
596
+ var controlCharacters = /[\u0000-\u001f\u007f]/;
597
+ var eventNameSchema = z.string().trim().min(1).max(EVENT_NAME_MAX_LENGTH).refine((name) => !controlCharacters.test(name), {
598
+ message: "Event names can't contain control characters"
599
+ }).refine((name) => !name.startsWith("$"), {
600
+ message: "Event names can't start with $"
601
+ });
602
+ function propertiesProblem(value, depth) {
603
+ if (Array.isArray(value)) {
604
+ for (const item of value) {
605
+ const problem = propertiesProblem(item, depth + 1);
606
+ if (problem)
607
+ return problem;
608
+ }
609
+ return null;
610
+ }
611
+ if (value && typeof value === "object") {
612
+ if (depth >= EVENT_PROPERTIES_MAX_DEPTH) {
613
+ return `Properties can be nested at most ${EVENT_PROPERTIES_MAX_DEPTH} levels`;
614
+ }
615
+ for (const [key, nested] of Object.entries(value)) {
616
+ if (!eventPropertyKeyPattern.test(key)) {
617
+ return `Property key "${key}" must start with a letter or _ and contain only letters, digits and _ (max 64)`;
618
+ }
619
+ const problem = propertiesProblem(nested, depth + 1);
620
+ if (problem)
621
+ return problem;
622
+ }
623
+ }
624
+ return null;
625
+ }
626
+ var eventPropertiesSchema = z.record(z.unknown()).superRefine((properties, ctx) => {
627
+ if (Object.keys(properties).length > EVENT_PROPERTIES_MAX_KEYS) {
628
+ ctx.addIssue({
629
+ code: z.ZodIssueCode.custom,
630
+ message: `At most ${EVENT_PROPERTIES_MAX_KEYS} top-level properties`
631
+ });
632
+ return;
633
+ }
634
+ const bytes = new TextEncoder().encode(JSON.stringify(properties)).length;
635
+ if (bytes > EVENT_PROPERTIES_MAX_BYTES) {
636
+ ctx.addIssue({
637
+ code: z.ZodIssueCode.custom,
638
+ message: `Properties can be at most ${EVENT_PROPERTIES_MAX_BYTES} bytes as JSON`
639
+ });
640
+ return;
641
+ }
642
+ const problem = propertiesProblem(properties, 0);
643
+ if (problem)
644
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: problem });
645
+ });
646
+ var trackEventFieldsSchema = z.object({
647
+ email: z.string().email().optional(),
648
+ contactId: z.string().min(1).optional(),
649
+ eventName: eventNameSchema,
650
+ properties: eventPropertiesSchema.optional(),
651
+ occurredAt: z.string().datetime({ offset: true }).optional().describe("When it happened. At most 24 h in the future; defaults to now."),
652
+ idempotencyKey: z.string().min(1).max(256).optional().describe("The same key within 30 days stores one event and enrolls once."),
653
+ backfill: z.boolean().optional().describe("Record only: the event never starts a sequence."),
654
+ createContact: z.boolean().optional().describe(
655
+ "Create the contact when the email is unknown (default true). Ignored with contactId."
656
+ ),
657
+ contact: z.object({
658
+ name: z.string().optional(),
659
+ customFields: customFieldsSchema.optional()
660
+ }).strict().optional().describe(
661
+ "Applied to the contact. Custom fields are merged into the existing ones."
662
+ )
663
+ }).strict();
664
+ var trackEventBodySchema = trackEventFieldsSchema.refine((body) => !!body.email !== !!body.contactId, {
665
+ message: "Provide exactly one of email or contactId"
666
+ }).refine(
667
+ (body) => !body.occurredAt || new Date(body.occurredAt).getTime() <= Date.now() + EVENT_MAX_FUTURE_MS,
668
+ { message: "occurredAt can be at most 24 hours in the future" }
669
+ );
670
+ var trackEventResponseSchema = z.object({
671
+ eventId: z.string(),
672
+ contactId: z.string(),
673
+ duplicate: z.boolean(),
674
+ contactCreated: z.boolean()
675
+ });
676
+ var eventSources = ["api", "session", "mcp"];
677
+ var contactEventSchema = z.object({
678
+ eventId: z.string(),
679
+ name: z.string(),
680
+ properties: z.record(z.unknown()),
681
+ occurredAt: z.string(),
682
+ receivedAt: z.string(),
683
+ source: z.enum(eventSources),
684
+ backfill: z.boolean(),
685
+ triggers: z.boolean(),
686
+ enrolledSequences: z.array(z.object({ sequenceId: z.string(), title: z.string() }))
687
+ });
688
+ var listContactEventsQuerySchema = z.object({
689
+ page: z.coerce.number().int().min(1).optional(),
690
+ limit: z.coerce.number().int().min(1).max(50).optional(),
691
+ name: eventNameSchema.optional()
692
+ });
693
+ var eventPropertyTypes = [
694
+ "string",
695
+ "number",
696
+ "boolean",
697
+ "date",
698
+ "object",
699
+ "array"
700
+ ];
701
+ var eventDefinitionPropertySchema = z.object({
702
+ key: z.string().regex(eventPropertyKeyPattern),
703
+ type: z.enum(eventPropertyTypes),
704
+ declared: z.boolean()
705
+ });
706
+ var eventDefinitionSchema = z.object({
707
+ name: z.string(),
708
+ origin: z.enum(["received", "manual"]),
709
+ description: z.string().nullable(),
710
+ properties: z.array(eventDefinitionPropertySchema),
711
+ firstSeenAt: z.string().nullable(),
712
+ lastSeenAt: z.string().nullable(),
713
+ createdAt: z.string(),
714
+ /** Non-deleted sequences whose trigger is this event. */
715
+ sequenceCount: z.number().int()
716
+ });
717
+ var eventDefinitionDetailSchema = eventDefinitionSchema.extend({
718
+ lastProperties: z.record(z.unknown()).nullable()
719
+ });
720
+ var declaredPropertiesSchema = z.array(
721
+ z.object({
722
+ key: z.string().regex(eventPropertyKeyPattern),
723
+ type: z.enum(eventPropertyTypes)
724
+ })
725
+ ).max(EVENT_PROPERTIES_MAX_KEYS).refine((props) => new Set(props.map((p) => p.key)).size === props.length, {
726
+ message: "Property keys must be unique"
727
+ });
728
+ var createEventDefinitionBodySchema = z.object({
729
+ name: eventNameSchema,
730
+ description: z.string().max(500).optional(),
731
+ properties: declaredPropertiesSchema.optional()
732
+ }).strict();
733
+ var updateEventDefinitionBodySchema = z.object({
734
+ description: z.string().max(500).nullable().optional(),
735
+ properties: declaredPropertiesSchema.optional().describe("Replaces the declared properties. Observed keys stay.")
736
+ }).strict();
737
+ var filterScalarSchema = z.union([z.string(), z.number(), z.boolean()]);
738
+ var eventFilterConditions = [
739
+ "is",
740
+ "is_not",
741
+ "contains",
742
+ "not_contains",
743
+ "gt",
744
+ "gte",
745
+ "lt",
746
+ "lte",
747
+ "exists",
748
+ "not_exists"
749
+ ];
750
+ var eventFilterKeySchema = z.string().refine(
751
+ (key) => {
752
+ const parts = key.split(".");
753
+ return parts.length <= EVENT_PROPERTIES_MAX_DEPTH && parts.every((part) => eventPropertyKeyPattern.test(part));
754
+ },
755
+ { message: "Use a property key, or a dot path up to 3 levels" }
756
+ );
757
+ var eventPropertyFilterSchema = z.object({
758
+ aggregator: z.enum(["and", "or"]),
759
+ filters: z.array(
760
+ z.object({
761
+ key: eventFilterKeySchema,
762
+ condition: z.enum(eventFilterConditions),
763
+ value: filterScalarSchema.optional()
764
+ }).refine(
765
+ (f) => f.condition === "exists" || f.condition === "not_exists" || f.value !== void 0,
766
+ { message: "This condition needs a value" }
767
+ )
768
+ ).min(1).max(EVENT_FILTER_MAX_CONDITIONS)
769
+ });
770
+ var propertyChangeFilterSchema = z.object({
771
+ from: filterScalarSchema.nullable().optional(),
772
+ to: filterScalarSchema.nullable().optional()
773
+ }).strict();
589
774
 
590
775
  // ../api-contract/src/schemas/sequences.ts
591
776
  var mailTypes = ["broadcast", "sequence"];
592
777
  var emailActionTypes = ["tag:add", "tag:remove"];
778
+ var triggerTypes = [
779
+ "subscriber:added",
780
+ "tag:added",
781
+ "tag:removed",
782
+ "date:occurred",
783
+ "event:custom",
784
+ "contact:property_changed"
785
+ ];
786
+ var reentryModes = ["every_time", "once", "once_per_period"];
593
787
  var sequenceEmailSchema = z.object({
594
788
  // NOTE: intentionally no `id`/`sequenceId` here — `sequence_emails.id` is
595
789
  // internal-only, and its `sequence_id` column holds the *parent*
@@ -686,8 +880,14 @@ var sequenceSchema = z.object({
686
880
  title: z.string(),
687
881
  status: z.string(),
688
882
  deliverySource: deliverySourceSelectionSchema.nullable(),
689
- triggerType: z.string().nullable().optional(),
883
+ triggerType: z.enum(triggerTypes).nullable().optional(),
690
884
  triggerData: z.string().nullable().optional(),
885
+ /** Property filter (`event:custom`) or from/to filter
886
+ * (`contact:property_changed`). */
887
+ triggerFilter: z.any().nullable().optional(),
888
+ /** Who can enter again: sequences only. */
889
+ reentry: z.enum(reentryModes).optional(),
890
+ reentryPeriodDays: z.number().int().nullable().optional(),
691
891
  filter: z.any().nullable().optional(),
692
892
  excludeFilter: z.any().nullable().optional(),
693
893
  /** Active enrollments for a sequence or its locked recipient count for a broadcast. */
@@ -695,6 +895,9 @@ var sequenceSchema = z.object({
695
895
  emailsOrder: z.array(z.string()),
696
896
  entrants: z.array(z.string()),
697
897
  report: z.any(),
898
+ /** Whether sends link a hosted web version ("View in browser"). On for
899
+ * new broadcasts, off for new sequences. */
900
+ viewInBrowser: z.boolean(),
698
901
  createdAt: z.string().nullable(),
699
902
  updatedAt: z.string().nullable(),
700
903
  emails: z.array(sequenceEmailSchema),
@@ -720,8 +923,19 @@ var createSequenceBodySchema = z.object({
720
923
  });
721
924
  var updateSequenceBodySchema = z.object({
722
925
  title: z.string().optional(),
723
- triggerType: z.string().optional(),
724
- triggerData: z.string().optional(),
926
+ triggerType: z.enum(triggerTypes).optional().describe(
927
+ "Broadcasts use date:occurred. Sequences: subscriber:added, tag:added, tag:removed, event:custom or contact:property_changed."
928
+ ),
929
+ triggerData: z.string().optional().describe(
930
+ "Tag name for tag triggers, event name for event:custom, custom field key for contact:property_changed."
931
+ ),
932
+ triggerFilter: z.union([eventPropertyFilterSchema, propertyChangeFilterSchema]).nullable().optional().describe(
933
+ "event:custom: { aggregator, filters: [{ key, condition, value }] }. contact:property_changed: { from?, to? }. null clears it."
934
+ ),
935
+ reentry: z.enum(reentryModes).optional().describe(
936
+ "Sequences only. every_time (default), once, or once_per_period with reentryPeriodDays."
937
+ ),
938
+ reentryPeriodDays: z.number().int().min(1).max(365).nullable().optional(),
725
939
  filter: contactFilterSchema.optional().describe(
726
940
  "Audience: subscribed contacts matching this filter; empty means everyone"
727
941
  ),
@@ -730,7 +944,10 @@ var updateSequenceBodySchema = z.object({
730
944
  ),
731
945
  emailsOrder: z.array(z.string()).optional(),
732
946
  /** `null` clears the intent so the default is resolved on next start. */
733
- deliverySource: deliverySourceSelectionSchema.nullable().optional()
947
+ deliverySource: deliverySourceSelectionSchema.nullable().optional(),
948
+ viewInBrowser: z.boolean().optional().describe(
949
+ 'Whether emails link a hosted web version ("View in browser"). `false` leaves the link out of later sends and takes down the web versions behind links already sent. Can be changed at any time.'
950
+ )
734
951
  });
735
952
  var addSequenceEmailBodySchema = z.object({
736
953
  templateId: z.string().min(1)
@@ -752,7 +969,10 @@ var sendSequenceEmailTestBodySchema = z.object({
752
969
  var sequenceEmailTestResultSchema = z.object({
753
970
  sent: z.array(z.string()).describe("Addresses the test was sent to"),
754
971
  skipped: z.array(z.object({ email: z.string(), reason: z.enum(["suppressed"]) })).describe("Addresses on the suppression list, which never get mail"),
755
- lastTestSentAt: z.string().nullable()
972
+ lastTestSentAt: z.string().nullable(),
973
+ /** Event-triggered sequences: `last_event` when `{{ event.* }}` used the
974
+ * last payload received for the event, `none` when there is none yet. */
975
+ eventSample: z.enum(["last_event", "none"]).optional()
756
976
  });
757
977
  var sequenceStatsSchema = z.object({
758
978
  sent: z.number(),
@@ -1811,6 +2031,14 @@ var contactsContract = c.router(
1811
2031
  },
1812
2032
  summary: "List broadcasts/sequence emails delivered to a contact"
1813
2033
  },
2034
+ events: {
2035
+ method: "GET",
2036
+ path: "/contacts/:contactId/events",
2037
+ query: listContactEventsQuerySchema,
2038
+ responses: { 200: paginated(contactEventSchema), 404: errorSchema },
2039
+ summary: "List the custom events received for a contact",
2040
+ description: "Newest first by occurredAt. `enrolledSequences` lists the sequences each event started."
2041
+ },
1814
2042
  remove: {
1815
2043
  method: "DELETE",
1816
2044
  path: "/contacts/:contactId",
@@ -2027,7 +2255,7 @@ var sequencesContract = c.router(
2027
2255
  404: errorSchema
2028
2256
  },
2029
2257
  summary: "Update a broadcast or sequence",
2030
- description: `A broadcast's title is its email's subject, so once the broadcast has been sent, changing the title returns 400 with the error "This broadcast has already been sent".`
2258
+ description: "A broadcast's title is its email's subject, so once the broadcast has been sent, changing the title returns 400 with the error \"This broadcast has already been sent\". `viewInBrowser` can be changed at any time; turning it off also takes down the web versions linked from emails already sent."
2031
2259
  },
2032
2260
  remove: {
2033
2261
  method: "DELETE",
@@ -2178,6 +2406,70 @@ var transactionalContract = c.router(
2178
2406
  },
2179
2407
  { metadata: { tag: "Transactional Emails" } }
2180
2408
  );
2409
+ var eventsContract = c.router(
2410
+ {
2411
+ track: {
2412
+ method: "POST",
2413
+ path: "/events",
2414
+ body: trackEventBodySchema,
2415
+ responses: {
2416
+ 202: trackEventResponseSchema,
2417
+ 400: errorSchema,
2418
+ 402: errorSchema,
2419
+ 404: errorSchema,
2420
+ 409: errorSchema,
2421
+ 422: errorSchema,
2422
+ 429: errorSchema
2423
+ },
2424
+ summary: "Track a custom event",
2425
+ description: "Stores the event, then starts every active sequence whose trigger is `event:custom` with this name and whose filters match. An unknown email creates the contact unless `createContact` is false (then 404). An unknown `contactId` is always 404. The same `idempotencyKey` within 30 days returns the original event with `duplicate: true`. Events with `backfill: true`, or an `occurredAt` more than 72 hours old, are stored but never start a sequence."
2426
+ },
2427
+ definitions: {
2428
+ method: "GET",
2429
+ path: "/events/definitions",
2430
+ responses: { 200: itemsList(eventDefinitionSchema) },
2431
+ summary: "List the team's events"
2432
+ },
2433
+ definition: {
2434
+ method: "GET",
2435
+ path: "/events/definitions/:name",
2436
+ responses: { 200: eventDefinitionDetailSchema, 404: errorSchema },
2437
+ summary: "Get an event, with its last payload"
2438
+ },
2439
+ createDefinition: {
2440
+ method: "POST",
2441
+ path: "/events/definitions",
2442
+ body: createEventDefinitionBodySchema,
2443
+ responses: {
2444
+ 201: eventDefinitionDetailSchema,
2445
+ 400: errorSchema,
2446
+ 409: errorSchema,
2447
+ 422: errorSchema
2448
+ },
2449
+ summary: "Register an event before it is sent"
2450
+ },
2451
+ updateDefinition: {
2452
+ method: "PATCH",
2453
+ path: "/events/definitions/:name",
2454
+ body: updateEventDefinitionBodySchema,
2455
+ responses: {
2456
+ 200: eventDefinitionDetailSchema,
2457
+ 400: errorSchema,
2458
+ 404: errorSchema
2459
+ },
2460
+ summary: "Update an event's description or declared properties"
2461
+ },
2462
+ deleteDefinition: {
2463
+ method: "DELETE",
2464
+ path: "/events/definitions/:name",
2465
+ body: c.noBody(),
2466
+ responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
2467
+ summary: "Remove an event from the list",
2468
+ description: "Stored events are kept, and a later event with this name registers it again. Returns 409 event_definition_in_use while a sequence uses it as its trigger."
2469
+ }
2470
+ },
2471
+ { metadata: { tag: "Events" } }
2472
+ );
2181
2473
  var espCollectionContract = c.router(
2182
2474
  {
2183
2475
  list: {
@@ -3480,6 +3772,7 @@ var contract = c.router({
3480
3772
  templates: templatesContract,
3481
3773
  sequences: sequencesContract,
3482
3774
  transactional: transactionalContract,
3775
+ events: eventsContract,
3483
3776
  settings: settingsContract,
3484
3777
  teams: teamsContract,
3485
3778
  organizations: organizationsContract,
@@ -3578,6 +3871,14 @@ var Contacts = class {
3578
3871
  params: { contactId: assertId(contactId, "contactId") }
3579
3872
  });
3580
3873
  }
3874
+ /** Custom events received for this contact, newest first, with the
3875
+ * sequences each one started. */
3876
+ async events(contactId, query = {}) {
3877
+ return this.http.request(routes.events, {
3878
+ params: { contactId: assertId(contactId, "contactId") },
3879
+ query
3880
+ });
3881
+ }
3581
3882
  };
3582
3883
 
3583
3884
  // src/resources/delivery-events.ts
@@ -3629,8 +3930,67 @@ var Emails = class {
3629
3930
  }
3630
3931
  };
3631
3932
 
3933
+ // src/resources/events.ts
3934
+ var routes4 = contract.events;
3935
+ var EventDefinitions = class {
3936
+ constructor(http) {
3937
+ this.http = http;
3938
+ }
3939
+ async list() {
3940
+ return this.http.request(routes4.definitions);
3941
+ }
3942
+ /** One event with its last received payload. Names are case-sensitive. */
3943
+ async get(name) {
3944
+ return this.http.request(routes4.definition, {
3945
+ params: { name: encodeSegment(name, "name") }
3946
+ });
3947
+ }
3948
+ async create(input) {
3949
+ return this.http.request(routes4.createDefinition, { body: input });
3950
+ }
3951
+ /** `properties` replaces the declared set; observed keys stay. */
3952
+ async update(name, input) {
3953
+ return this.http.request(routes4.updateDefinition, {
3954
+ params: { name: encodeSegment(name, "name") },
3955
+ body: input
3956
+ });
3957
+ }
3958
+ /** Removes the event from the list. Stored events are kept, and the API
3959
+ * refuses (409 `event_definition_in_use`) while a sequence uses it. */
3960
+ async delete(name) {
3961
+ await this.http.request(routes4.deleteDefinition, {
3962
+ params: { name: encodeSegment(name, "name") }
3963
+ });
3964
+ }
3965
+ };
3966
+ var Events = class {
3967
+ constructor(http) {
3968
+ this.http = http;
3969
+ this.definitions = new EventDefinitions(http);
3970
+ }
3971
+ /**
3972
+ * Records an event for one contact (by `email` or `contactId`) and starts
3973
+ * every active sequence listening for `eventName`.
3974
+ *
3975
+ * - An unknown `email` creates the contact, since `createContact`
3976
+ * defaults to `true`. Pass `false` to get a 404 instead. An unknown
3977
+ * `contactId` is always a 404.
3978
+ * - The same `idempotencyKey` within 30 days stores one event and
3979
+ * returns the original with `duplicate: true`. With a key, the SDK
3980
+ * also retries the call on 5xx and network errors.
3981
+ * - `backfill: true` stores history without starting sequences. Events
3982
+ * whose `occurredAt` is more than 72 hours old never start one either.
3983
+ */
3984
+ async track(input) {
3985
+ return this.http.request(routes4.track, {
3986
+ body: input,
3987
+ retrySafe: !!input.idempotencyKey
3988
+ });
3989
+ }
3990
+ };
3991
+
3632
3992
  // src/resources/provisioning.ts
3633
- var routes4 = contract.provisioning;
3993
+ var routes5 = contract.provisioning;
3634
3994
  var Provisioning = class {
3635
3995
  constructor(http) {
3636
3996
  this.http = http;
@@ -3641,20 +4001,20 @@ var Provisioning = class {
3641
4001
  * `created: false, apiKey: null`, so it's safe to retry.
3642
4002
  */
3643
4003
  async provisionTeam(input) {
3644
- return this.http.request(routes4.provisionTeam, {
4004
+ return this.http.request(routes5.provisionTeam, {
3645
4005
  body: input,
3646
4006
  retrySafe: true
3647
4007
  });
3648
4008
  }
3649
4009
  /** `teams:read` */
3650
4010
  async getTeam(teamId) {
3651
- return this.http.request(routes4.getTeam, {
4011
+ return this.http.request(routes5.getTeam, {
3652
4012
  params: { teamId: assertId(teamId, "teamId") }
3653
4013
  });
3654
4014
  }
3655
4015
  /** `teams:manage` */
3656
4016
  async updateTeam(teamId, input) {
3657
- return this.http.request(routes4.updateTeam, {
4017
+ return this.http.request(routes5.updateTeam, {
3658
4018
  params: { teamId: assertId(teamId, "teamId") },
3659
4019
  body: input
3660
4020
  });
@@ -3662,106 +4022,106 @@ var Provisioning = class {
3662
4022
  /** Replaces the team's integration key (`teams:keys`); keys previously
3663
4023
  * issued through provisioning are revoked. */
3664
4024
  async createTeamKey(teamId, input) {
3665
- return this.http.request(routes4.createTeamKey, {
4025
+ return this.http.request(routes5.createTeamKey, {
3666
4026
  params: { teamId: assertId(teamId, "teamId") },
3667
4027
  body: input
3668
4028
  });
3669
4029
  }
3670
4030
  /** `teams:manage` */
3671
4031
  async suspendTeam(teamId) {
3672
- return this.http.request(routes4.suspendTeam, {
4032
+ return this.http.request(routes5.suspendTeam, {
3673
4033
  params: { teamId: assertId(teamId, "teamId") }
3674
4034
  });
3675
4035
  }
3676
4036
  /** `teams:manage` */
3677
4037
  async resumeTeam(teamId) {
3678
- return this.http.request(routes4.resumeTeam, {
4038
+ return this.http.request(routes5.resumeTeam, {
3679
4039
  params: { teamId: assertId(teamId, "teamId") }
3680
4040
  });
3681
4041
  }
3682
4042
  /** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
3683
4043
  async archiveTeam(teamId) {
3684
- await this.http.request(routes4.archiveTeam, {
4044
+ await this.http.request(routes5.archiveTeam, {
3685
4045
  params: { teamId: assertId(teamId, "teamId") }
3686
4046
  });
3687
4047
  }
3688
4048
  /** `usage:read` */
3689
4049
  async getTeamUsage(teamId) {
3690
- return this.http.request(routes4.getTeamUsage, {
4050
+ return this.http.request(routes5.getTeamUsage, {
3691
4051
  params: { teamId: assertId(teamId, "teamId") }
3692
4052
  });
3693
4053
  }
3694
4054
  };
3695
4055
 
3696
4056
  // src/resources/segments.ts
3697
- var routes5 = contract.segments;
4057
+ var routes6 = contract.segments;
3698
4058
  var Segments = class {
3699
4059
  constructor(http) {
3700
4060
  this.http = http;
3701
4061
  }
3702
4062
  async create(input) {
3703
- return this.http.request(routes5.create, { body: input });
4063
+ return this.http.request(routes6.create, { body: input });
3704
4064
  }
3705
4065
  async list() {
3706
- return this.http.request(routes5.list);
4066
+ return this.http.request(routes6.list);
3707
4067
  }
3708
4068
  async get(segmentId) {
3709
- return this.http.request(routes5.get, {
4069
+ return this.http.request(routes6.get, {
3710
4070
  params: { segmentId: assertId(segmentId, "segmentId") }
3711
4071
  });
3712
4072
  }
3713
4073
  async update(segmentId, input) {
3714
- return this.http.request(routes5.update, {
4074
+ return this.http.request(routes6.update, {
3715
4075
  params: { segmentId: assertId(segmentId, "segmentId") },
3716
4076
  body: input
3717
4077
  });
3718
4078
  }
3719
4079
  async remove(segmentId) {
3720
- await this.http.request(routes5.remove, {
4080
+ await this.http.request(routes6.remove, {
3721
4081
  params: { segmentId: assertId(segmentId, "segmentId") }
3722
4082
  });
3723
4083
  }
3724
4084
  };
3725
4085
 
3726
4086
  // src/resources/sequences.ts
3727
- var routes6 = contract.sequences;
4087
+ var routes7 = contract.sequences;
3728
4088
  var Sequences = class {
3729
4089
  constructor(http) {
3730
4090
  this.http = http;
3731
4091
  }
3732
4092
  async create(input) {
3733
- return this.http.request(routes6.create, { body: input });
4093
+ return this.http.request(routes7.create, { body: input });
3734
4094
  }
3735
4095
  async list(query) {
3736
- return this.http.request(routes6.list, { query });
4096
+ return this.http.request(routes7.list, { query });
3737
4097
  }
3738
4098
  listAll(query) {
3739
4099
  return paginate((offset) => this.list({ ...query, offset }));
3740
4100
  }
3741
4101
  async get(sequenceId) {
3742
- return this.http.request(routes6.get, {
4102
+ return this.http.request(routes7.get, {
3743
4103
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
3744
4104
  });
3745
4105
  }
3746
4106
  async update(sequenceId, input) {
3747
- return this.http.request(routes6.update, {
4107
+ return this.http.request(routes7.update, {
3748
4108
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
3749
4109
  body: input
3750
4110
  });
3751
4111
  }
3752
4112
  async remove(sequenceId) {
3753
- await this.http.request(routes6.remove, {
4113
+ await this.http.request(routes7.remove, {
3754
4114
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
3755
4115
  });
3756
4116
  }
3757
4117
  async addEmail(sequenceId, input) {
3758
- return this.http.request(routes6.addEmail, {
4118
+ return this.http.request(routes7.addEmail, {
3759
4119
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
3760
4120
  body: input
3761
4121
  });
3762
4122
  }
3763
4123
  async updateEmail(sequenceId, emailId, input) {
3764
- return this.http.request(routes6.updateEmail, {
4124
+ return this.http.request(routes7.updateEmail, {
3765
4125
  params: {
3766
4126
  sequenceId: assertId(sequenceId, "sequenceId"),
3767
4127
  emailId: assertId(emailId, "emailId")
@@ -3770,7 +4130,7 @@ var Sequences = class {
3770
4130
  });
3771
4131
  }
3772
4132
  async removeEmail(sequenceId, emailId) {
3773
- return this.http.request(routes6.removeEmail, {
4133
+ return this.http.request(routes7.removeEmail, {
3774
4134
  params: {
3775
4135
  sequenceId: assertId(sequenceId, "sequenceId"),
3776
4136
  emailId: assertId(emailId, "emailId")
@@ -3780,23 +4140,23 @@ var Sequences = class {
3780
4140
  /** Sends a broadcast, or activates a sequence so its trigger starts
3781
4141
  * enrolling contacts. Requires a mailing address in general settings. */
3782
4142
  async start(sequenceId) {
3783
- return this.http.request(routes6.start, {
4143
+ return this.http.request(routes7.start, {
3784
4144
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
3785
4145
  });
3786
4146
  }
3787
4147
  async pause(sequenceId) {
3788
- return this.http.request(routes6.pause, {
4148
+ return this.http.request(routes7.pause, {
3789
4149
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
3790
4150
  });
3791
4151
  }
3792
4152
  async stats(sequenceId) {
3793
- return this.http.request(routes6.stats, {
4153
+ return this.http.request(routes7.stats, {
3794
4154
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
3795
4155
  });
3796
4156
  }
3797
4157
  /** IDs of contacts that have received this broadcast or sequence. */
3798
4158
  async subscribers(sequenceId, query = {}) {
3799
- return this.http.request(routes6.subscribers, {
4159
+ return this.http.request(routes7.subscribers, {
3800
4160
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
3801
4161
  query
3802
4162
  });
@@ -3804,26 +4164,26 @@ var Sequences = class {
3804
4164
  };
3805
4165
 
3806
4166
  // src/resources/suppressions.ts
3807
- var routes7 = contract.suppressions;
4167
+ var routes8 = contract.suppressions;
3808
4168
  var Suppressions = class {
3809
4169
  constructor(http) {
3810
4170
  this.http = http;
3811
4171
  }
3812
4172
  async list(query = {}) {
3813
- return this.http.request(routes7.list, { query });
4173
+ return this.http.request(routes8.list, { query });
3814
4174
  }
3815
4175
  listAll(query = {}) {
3816
4176
  return paginate((offset) => this.list({ ...query, offset }));
3817
4177
  }
3818
4178
  async get(suppressionId) {
3819
- return this.http.request(routes7.get, {
4179
+ return this.http.request(routes8.get, {
3820
4180
  params: { suppressionId: assertId(suppressionId, "suppressionId") }
3821
4181
  });
3822
4182
  }
3823
4183
  /** Complaint suppressions can't be released (409
3824
4184
  * `suppression_not_releasable`). */
3825
4185
  async release(suppressionId, input = {}) {
3826
- return this.http.request(routes7.release, {
4186
+ return this.http.request(routes8.release, {
3827
4187
  params: { suppressionId: assertId(suppressionId, "suppressionId") },
3828
4188
  body: input
3829
4189
  });
@@ -3831,41 +4191,41 @@ var Suppressions = class {
3831
4191
  };
3832
4192
 
3833
4193
  // src/resources/templates.ts
3834
- var routes8 = contract.templates;
4194
+ var routes9 = contract.templates;
3835
4195
  var Templates = class {
3836
4196
  constructor(http) {
3837
4197
  this.http = http;
3838
4198
  }
3839
4199
  async list(query = {}) {
3840
- return this.http.request(routes8.list, { query });
4200
+ return this.http.request(routes9.list, { query });
3841
4201
  }
3842
4202
  /** Built-in starters, shared by every team. Duplicate one into the team
3843
4203
  * before using it for transactional sends. */
3844
4204
  async listSystem(query = {}) {
3845
- return this.http.request(routes8.listSystem, { query });
4205
+ return this.http.request(routes9.listSystem, { query });
3846
4206
  }
3847
4207
  async get(templateId) {
3848
- return this.http.request(routes8.get, {
4208
+ return this.http.request(routes9.get, {
3849
4209
  params: { templateId: assertId(templateId, "templateId") }
3850
4210
  });
3851
4211
  }
3852
4212
  async create(input) {
3853
- return this.http.request(routes8.create, { body: input });
4213
+ return this.http.request(routes9.create, { body: input });
3854
4214
  }
3855
4215
  async update(templateId, input) {
3856
- return this.http.request(routes8.update, {
4216
+ return this.http.request(routes9.update, {
3857
4217
  params: { templateId: assertId(templateId, "templateId") },
3858
4218
  body: input
3859
4219
  });
3860
4220
  }
3861
4221
  async duplicate(templateId, input = {}) {
3862
- return this.http.request(routes8.duplicate, {
4222
+ return this.http.request(routes9.duplicate, {
3863
4223
  params: { templateId: assertId(templateId, "templateId") },
3864
4224
  body: input
3865
4225
  });
3866
4226
  }
3867
4227
  async remove(templateId) {
3868
- await this.http.request(routes8.remove, {
4228
+ await this.http.request(routes9.remove, {
3869
4229
  params: { templateId: assertId(templateId, "templateId") }
3870
4230
  });
3871
4231
  }
@@ -3929,10 +4289,11 @@ var SendLit = class {
3929
4289
  this.templates = new Templates(http);
3930
4290
  this.sequences = new Sequences(http);
3931
4291
  this.emails = new Emails(http);
4292
+ this.events = new Events(http);
3932
4293
  this.provisioning = new Provisioning(http);
3933
4294
  this.suppressions = new Suppressions(http);
3934
4295
  this.deliveryEvents = new DeliveryEvents(http);
3935
4296
  }
3936
4297
  };
3937
4298
 
3938
- export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, Provisioning, Segments, SendLit, SendLitError, Sequences, Suppressions, Templates };
4299
+ export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, Provisioning, Segments, SendLit, SendLitError, Sequences, Suppressions, Templates };